Create a PJRT Buffer from an R object.
Any numeric PJRT buffer is an array and 0-dimensional arrays are used as scalars.
pjrt_buffer
will create a array with dimensions (1)
for a vector of length 1, while
pjrt_scalar
will create a 0-dimensional array for an R vector of length 1.
Usage
pjrt_buffer(data, elt_type, client = pjrt_client(), ...)
pjrt_scalar(data, elt_type, client = pjrt_client(), ...)
# S3 method for class 'logical'
pjrt_buffer(
data,
elt_type = "pred",
client = pjrt_client(),
shape = get_dims(data),
...
)
# S3 method for class 'integer'
pjrt_buffer(
data,
elt_type = "i32",
client = pjrt_client(),
shape = get_dims(data),
...
)
# S3 method for class 'double'
pjrt_buffer(
data,
elt_type = "f32",
client = pjrt_client(),
shape = get_dims(data),
...
)
# S3 method for class 'raw'
pjrt_buffer(data, ..., elt_type, client = pjrt_client(), shape, row_major)
# S3 method for class 'logical'
pjrt_scalar(data, elt_type = "pred", client = pjrt_client(), ...)
# S3 method for class 'integer'
pjrt_scalar(data, elt_type = "i32", client = pjrt_client(), ...)
# S3 method for class 'double'
pjrt_scalar(data, elt_type = "f32", client = pjrt_client(), ...)
# S3 method for class 'raw'
pjrt_scalar(data, ..., elt_type, client = pjrt_client())
Arguments
- data
(any)
Data to convert to aPJRTBuffer
.- elt_type
(
character(1)
)
The type of the buffer. Currently supported types are:"pred"
: predicate (i.e. a boolean)"{s,u}{8,16,32,64}"
: (Un)signed integer (forinteger
data)."f{32,64}"
: Floating point (fordouble
orinteger
data).
- client
(
PJRTClient
|character(1)
)
A PJRT client object or the name of the platform to use ("cpu", "cuda", ...), from which the client will be created.- ...
(any)
Additional arguments.- shape
(
integer()
)
The dimensions of the buffer. The default is to infer them from the data.- row_major
(logical(1))
Whether to read the data in row-major format or column-major format. R uses column-major format.
Extractors
device()
for the device of the buffer.element_type()
for the element type of the buffer.
Converters
as_array()
for an array.as_raw()
for a raw vector.