Skip to main content

TensorViewable

Trait TensorViewable 

Source
pub trait TensorViewable {
    // Required methods
    fn view(&self, slices: Vec<SliceSpec>) -> Result<TensorView, String>;
    fn stride(&self, strides: Vec<isize>) -> Result<TensorView, String>;
    fn reshape_view(&self, new_shape: Vec<usize>) -> Result<TensorView, String>;

    // Provided methods
    fn slice(&self, ranges: &[Range<usize>]) -> Result<TensorView, String> { ... }
    fn at(&self, indices: &[usize]) -> Result<TensorView, String> { ... }
}
Expand description

Trait for tensors that support zero-copy views

Required Methods§

Source

fn view(&self, slices: Vec<SliceSpec>) -> Result<TensorView, String>

Create a view of this tensor

Source

fn stride(&self, strides: Vec<isize>) -> Result<TensorView, String>

Create a strided view

Source

fn reshape_view(&self, new_shape: Vec<usize>) -> Result<TensorView, String>

Reshape view (if possible without copying)

Provided Methods§

Source

fn slice(&self, ranges: &[Range<usize>]) -> Result<TensorView, String>

Create a slice of this tensor

Source

fn at(&self, indices: &[usize]) -> Result<TensorView, String>

Get a single element view

Implementors§