Skip to contents

Converts the elements of a tensor to a different data type. Returns the input unchanged if it already has the target type.

Usage

nv_convert(operand, dtype)

Arguments

operand

(tensorish)
Operand.

dtype

(character(1) | stablehlo::TensorDataType)
Data type.

Value

tensorish
Has the given dtype and the same shape as operand.

See also

nvl_convert() for the underlying primitive.

Examples

jit_eval({
  x <- nv_tensor(c(1L, 2L, 3L))
  nv_convert(x, dtype = "f32")
})
#> AnvilTensor
#>  1
#>  2
#>  3
#> [ CPUf32{3} ]