Skip to contents

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 a PJRTBuffer.

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 (for integer data).

  • "f{32,64}": Floating point (for double or integer 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.

Value

PJRTBuffer

Details

R does not have 0-dimensional arrays, hence we need the extra pjrt_scalar function.

Extractors

Converters