Use this to canonicalize inputs at the start of a function so it works
both with eager executing and in combination with jit().
Use as_anvl_array() for a single input and as_anvl_arrays() for multiple inputs.
The latter will also ensure all arrays are from the same backend and live on the same device.
Details
During tracing, boxes are returned as is.
During eager mode, R literals and arrays are converted to AnvlArrays on the specified device.
For AnvlArray inputs, we check that they live on provided device (if specified).
Examples
as_anvl_array(1L)
#> AnvlArray
#> 1
#> [ CPUi32?{} ]
as_anvl_arrays(nv_array(1:3), 1L)
#> [[1]]
#> AnvlArray
#> 1
#> 2
#> 3
#> [ CPUi32{3} ]
#>
#> [[2]]
#> AnvlArray
#> 1
#> [ CPUi32?{} ]
#>