---
title: "ClikaRT::ops::empty_like"
sidebar_label: "empty_like"
description: "Uninitialized tensor with reference's shape and dtype. reference supplies shape and dtype; its data is never read."
---

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

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

## empty\_like() {#empty_like}

<div class="api-signature">

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

</div>

Uninitialized tensor with `reference`'s shape and dtype.

**Parameters**

- `reference`: supplies shape and dtype; its data is never read.
- `device`: stream or device; absent = the REFERENCE's own device (an explicit stream/device wins). Default: absent.

**Throws**

- `ClikaRT::Error`: when the allocation cannot be served (`code_name()` carries the reason).

**Returns:** a new uninitialized tensor shaped like `reference`, on its device.

```cpp
auto scratch = ClikaRT::ops::empty_like(x);  // same shape/dtype/device as x
```

<div class="api-declared">

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

</div>
