rlmesh::ext::TensorExt
Additional tensor constructors and layout access.
trait TensorExt: SizedRequired methods
- from_vec()Adopt
dataas a C-contiguous tensor without copying. - zeros()A zero-filled tensor in fresh aligned storage.
- from_storage()A view over
storagewith element strides (None: C-contiguous) and a byte offset. - stack()Stack same-shaped tensors along a new leading dimension.
- unstack()Split along the leading dimension.
- storage()The shared backing storage.
- byte_offset()The first element's offset into the storage, in bytes.
- element_strides()Strides in elements.
from_vec
required method[source]fn from_vec(
data: Vec<u8>,
shape: &[usize],
dtype: DType,
) -> Result<Self>Adopt data as a C-contiguous tensor without copying.
zeros
required method[source]fn zeros(shape: &[usize], dtype: DType) -> Result<Self>A zero-filled tensor in fresh aligned storage.
from_storage
required method[source]fn from_storage(
storage: Storage,
dtype: DType,
shape: &[usize],
element_strides: Option<&[usize]>,
byte_offset: usize,
) -> Result<Self>A view over storage with element strides (None: C-contiguous) and
a byte offset.
stack
required method[source]fn stack(tensors: &[Self]) -> Result<Self>Stack same-shaped tensors along a new leading dimension.
unstack
required method[source]fn unstack(&self) -> Result<Vec<Self>>Split along the leading dimension.
storage
required method[source]fn storage(&self) -> &StorageThe shared backing storage.
byte_offset
required method[source]fn byte_offset(&self) -> usizeThe first element’s offset into the storage, in bytes.
element_strides
required method[source]fn element_strides(&self) -> Vec<usize>Strides in elements.