Prints an array value to the console during execution and returns the input unchanged. This is useful for debugging JIT-compiled code. Bare R inputs print at their category's default data type.
Arguments
- x
(
arrayish)
One input. Can be any data type. An R value materializes at its default data type.
Value
(arrayish)
Returns the input unchanged.
Order of prints
A print is currently not ordered with respect to other prints. Due to compiler reordering it is possible that the order of the prints differs from their location in the code.
StableHLO
Lowers to hlo_custom_call().
Examples
# the value is printed and handed back unchanged
x <- nv_array(c(1, 2, 3))
prim_print(x)
#> AnvlArray
#> 1
#> 2
#> 3
#> [ f32{3} ]
#> AnvlArray
#> 1
#> 2
#> 3
#> [ CPUf32{3} ]
# bare R inputs are printed at their category's default data type
prim_print(1L)
#> RData
#> 1
#> [ integer{} printed at i32 ]
#> AnvlArray
#> 1
#> [ CPUi32{} ]