Create a Backend
Usage
AnvlBackend(
new_data,
new_empty,
dtype,
shape,
as_array,
as_raw,
platform,
device,
new_device,
print_data,
jit,
await_data,
default_dtypes
)Arguments
- new_data
(
function(data, dtype, shape, device, row_major = FALSE))
Constructs an AnvlArray from R data. Must returnstructure(list(data = , backend = <name>, ...), class = "AnvlArray"), wheredataholds the underlying data (aPJRTBufferfor the"pjrt"backend, an Rarray()for the"quickr"backend) andbackendis the name the backend is registered under.row_majorgives the element order of raw byte payloads; a backend that does not support rawdatashould abort on it.- new_empty
(
function(dtype, shape, device))
Constructs an AnvlArray of the givendtypeandshapewith unspecified contents. Called bynv_empty().- dtype
(
function(x))
Extracts the dtype from an AnvlArray.- shape
(
function(x))
Extracts the shape from an AnvlArray.- as_array
(
function(x, check))
Converts an AnvlArray to an R array. Thechecklevel is forwarded fromas_array(); backends may use it to abort when materialization would lose information (e.g. ui64 values wrapping throughbit64::integer64). Seepjrt::as_array.PJRTBuffer().- as_raw
(
function(x, row_major))
Converts an AnvlArray to raw bytes.- platform
(
function(x))
Returns the platform name (e.g."cpu").- device
(
function(x))
Returns the device object for an AnvlArray.- new_device
(
function(x))
Constructs a backend-specific device object from a device identifier (e.g."cpu"or"cuda:1"). Called bynv_device().- print_data
(
function(x, footer))
Prints the array data with a footer.- jit
(
function(f, static, cache_size, <options>, device = NULL))
Creates the backend's implementation of a JIT-compiled function and returns it as afunction. The formals in place of<options>are the backend-specific optionsjit()accepts through....- await_data
(
function(x))
Blocks until the array's underlying data is ready. Called byawait()forAnvlArrays; a no-op for backends without async execution.- default_dtypes
(
NULL|list(float, int))
The default data types for this backend. Can be overwritten, seedefault_dtypes().