---
title: "ClikaRT::ops::rand_like"
sidebar_label: "rand_like"
description: "Uniform [0, 1) draws shaped and typed like reference. reference the tensor whose shape/dtype the output copies. device stream or device; default = the default device."
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--function">function</span>

## rand\_like() {#rand_like}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`rand_like`**([`Tensor`](../Tensor.md) `reference`, [`StreamOrDevice`](../StreamOrDevice.md) `device` `=` `{}`)

</div>

Uniform `[0, 1)` draws shaped and typed like `reference`.

**Parameters**

- `reference`: the tensor whose shape/dtype the output copies.
- `device`: stream or device; default = the default device.

**Returns:** uniform draws, `reference`'s shape and dtype.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) on a non-float reference dtype.

<div class="api-declared">

Declared in `ClikaRT/compute/ops.h`, line 4195

</div>
