pub unsafe fn TensorPtr_new(
sizes: UniquePtr<CxxVector<i32>>,
data: *mut u8,
dim_order: UniquePtr<CxxVector<u8>>,
strides: UniquePtr<CxxVector<i32>>,
scalar_type: ET_ScalarType,
dynamism: ET_TensorShapeDynamism,
allocation: Box<RustAny>,
device: ET_Device,
) -> SharedPtr<Tensor>Available on crate features
std and tensor-ptr only.Expand description
Create a new tensor pointer.
The device parameter sets the Tensor’s device location only — no data is allocated or
copied. The caller is responsible for ensuring data already lives on the requested
device. To copy CPU data to a device, use TensorPtr_clone_to instead.
Arguments:
sizes: The dimensions of the tensor.data: A pointer to the beginning of the data buffer.dim_order: The order of the dimensions.strides: The strides of the tensor, in units of elements (not bytes).scalar_type: The scalar type of the tensor.dynamism: The dynamism of the tensor.allocation: ABox<RustAny>object that will be dropped when the tensor is dropped. Can be used to manage the lifetime of the data buffer.device: The device on whichdataresides.
Returns a shared pointer to the tensor.
§Safety
The data pointer must be valid for the lifetime of the tensor, and accessing it according to the data
type, sizes, dim order, and strides must be valid. The data pointer must reside on device.