TensorPtr_new

Function TensorPtr_new 

Source
pub unsafe fn TensorPtr_new(
    sizes: UniquePtr<CxxVector<i32>>,
    data: *mut u8,
    dim_order: UniquePtr<CxxVector<u8>>,
    strides: UniquePtr<CxxVector<i32>>,
    scalar_type: ScalarType,
    dynamism: TensorShapeDynamism,
    allocation: Box<RustAny>,
) -> SharedPtr<Tensor>
Available on crate feature tensor-ptr only.
Expand description

Create a new tensor pointer.

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: A Box<RustAny> object that will be dropped when the tensor is dropped. Can be used to manage the lifetime of the data buffer.

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.