---
title: "ClikaRT::ops::ones_like"
sidebar_label: "ones_like"
description: "A one-filled tensor with reference's shape and dtype (data never read); device absent = the reference's own device."
---

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

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

## ones\_like() {#ones_like}

<div class="api-signature">

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

</div>

A one-filled tensor with `reference`'s shape and dtype (data never read); [`device`](../device-namespace/index.md) absent = the reference's own device.

**Throws**

- `ClikaRT::Error`: when the input's dtype is not served for this operation (the machine-readable reason rides `code_name()`).

**Returns:** a new one-filled tensor shaped like `reference`.

<div class="api-declared">

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

</div>
