Skip to contents

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.

Usage

as_anvl_array(x, device = NULL)

as_anvl_arrays(...)

Arguments

x

(arrayish)
Input to standardize.

device

(NULL | device)
Target device. If x is an AnvlArray on a different device, an error is raised.

...

(arrayish)
Inputs to align.

Value

(AnvlArray for as_anvl_array(), list of AnvlArrays for as_anvl_arrays()).

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?{} ] 
#>