TensorOps

Trait TensorOps 

Source
pub trait TensorOps<T> {
    // Required methods
    fn shape(&self) -> &[usize];
    fn data(&self) -> &[T];
    fn data_mut(&mut self) -> &mut [T];

    // Provided method
    fn index_offset(&self, idx: &[usize]) -> Option<usize> { ... }
}
Expand description

Operations even the simplest tensors need to get indexing, shape, and other content.

Required Methods§

Source

fn shape(&self) -> &[usize]

Provides the shape of the current tensor as a slice.

Note: the builtin index_offset method will work immediately if the shape is stored row-major.

Source

fn data(&self) -> &[T]

Provides the data of the current tensor in a slice of a generic T.

Note: the builtin index_offset method will work immediately if the data is stored row-major.

Source

fn data_mut(&mut self) -> &mut [T]

Provides the data of the current tensor in a slice of a generic T.

Note: the builtin index_offset method will work immediately if the data is stored row-major.

Provided Methods§

Source

fn index_offset(&self, idx: &[usize]) -> Option<usize>

Finds the index in data given a slice with one entry/dimension.

Implementors§

Source§

impl<T> TensorOps<T> for RefTensor<'_, T>

Source§

impl<T, const N: usize, const D: usize, const LANES: usize> TensorOps<T> for ArrTensor<T, N, D, LANES>