Skip to contents

Reinterprets the bits of an array as a different data type without modifying the underlying data.

Usage

prim_bitcast_convert(operand, dtype)

Arguments

operand

(arrayish)
Arrayish value of any data type.

dtype

(character(1) | tengen::DataType)
Target data type. If it has the same bit width as the input, the output shape is unchanged. If narrower, an extra trailing dimension is added. If wider, the last dimension is consumed.

Value

arrayish
Has the given dtype.

Implemented Rules

  • stablehlo

  • reverse

StableHLO

Lowers to stablehlo::hlo_bitcast_convert().

Examples

x <- nv_array(1L)
prim_bitcast_convert(x, dtype = "i8")
#> AnvlArray
#>  1 0 0 0
#> [ CPUi8{1,4} ] 
x <- nv_array(rep(1L, 4), dtype = "i8")
prim_bitcast_convert(x, dtype = "i32")
#> AnvlArray
#>  1.6843e+07
#> [ CPUi32{} ]