---
title: "cast"
sidebar_label: "cast"
description: "Kotlin binding reference: cast."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

//[clika-runtime](../../../index.md)/[io.clika.runtime](../index.md)/[Ops](index.md)/[cast](cast.md)

# cast

[common]\
fun [cast](cast.md)(input: [Tensor](../Tensor/index.md), target: [DType](../DType/index.md), forceCopy: [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) = false): [Tensor](../Tensor/index.md)

`cast(input: Tensor, target: DType, forceCopy: Boolean = false)`: the `cast` operator. Same-device dtype conversion. Converts per element to `target`. When `input` already has `target`'s dtype and `force_copy` is `false`, the input passes through unchanged (no new storage); set `force_copy = true` to guarantee an owning copy.