---
title: "ClikaRT::ops::cast_like"
sidebar_label: "cast_like"
description: "cast to another tensor's dtype: cast(x, reference.dtype()). ClikaRT::Error when the input's dtype/shape is not served for this operation (the machine-readable reason rides code_name())."
---

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

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

## cast\_like() {#cast_like}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`cast_like`**([`Tensor`](../Tensor.md) `input`, [`Tensor`](../Tensor.md) `reference`)

</div>

[`cast`](./cast.md#cast) to another tensor's dtype: [`cast`](./cast.md#cast)`(x, reference.dtype())`.

**Throws**

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

**Returns:** `input` converted to `reference`'s dtype; same shape as `input`.

<div class="api-declared">

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

</div>
