Skip to contents

Create a tensor.

Usage

nv_tensor(data, dtype = NULL, device = NULL, shape = NULL)

nv_scalar(data, dtype = NULL, device = NULL)

nv_empty(dtype, shape, device = NULL)

Arguments

data

(any)
Object convertible to a PJRTBuffer.

dtype

(NULL | character(1) | stablehlo::TensorDataType)
One of pred, i8, i16, i32, i64, ui8, ui16, ui32, ui64, f32, f64 or a stablehlo::TensorDataType. The default (NULL) uses f32 for numeric data, i32 for integer data, and pred for logical data.

device

(NULL | character(1) | PJRTDevice)
The platform name for the tensor ("cpu", "cuda", "metal"). Default is to use the CPU, unless the data is already a PJRTBuffer. You can change the default by setting the PJRT_PLATFORM environment variable.

shape

(NULL | integer())
Shape. The default (NULL) is to infer it from the data if possible. Note that nv_tensor interprets length 1 vectors as having shape (1). To create a "scalar" with dimension (), use nv_scalar.

Value

(AnvilTensor)

Details

Internally calls pjrt_buffer.