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§
Sourcefn shape(&self) -> &[usize]
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.
Provided Methods§
Sourcefn index_offset(&self, idx: &[usize]) -> Option<usize>
fn index_offset(&self, idx: &[usize]) -> Option<usize>
Finds the index in data given a slice with one entry/dimension.