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 aPJRTBuffer.- dtype
(
NULL|character(1)|stablehlo::TensorDataType)
One of pred, i8, i16, i32, i64, ui8, ui16, ui32, ui64, f32, f64 or astablehlo::TensorDataType. The default (NULL) usesf32for numeric data,i32for integer data, andpredfor 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 aPJRTBuffer. You can change the default by setting thePJRT_PLATFORMenvironment variable.- shape
(
NULL|integer())
Shape. The default (NULL) is to infer it from the data if possible. Note thatnv_tensorinterprets length 1 vectors as having shape(1). To create a "scalar" with dimension(), usenv_scalar.
Details
Internally calls pjrt_buffer.