[][src]Trait melange::tensor::layout::Layout

pub trait Layout<'a, T>: Deref<Target = [T]> where
    T: 'a, 
{ type Iter: Iterator<Item = &'a [T]>; type View: for<'b> Layout<'b, T>; fn shape(&self) -> Vec<usize>;
fn strides(&self) -> Vec<usize>;
fn opt_chunk_size(&self) -> usize;
fn num_elements(&self) -> usize;
fn chunks(&'a self, chunk_size: usize) -> Self::Iter;
fn as_view_unchecked(
        &'a self,
        shape: Vec<usize>,
        strides: Vec<usize>,
        num_elements: usize,
        opt_chunk_size: usize
    ) -> Self::View; }

This trait defines the basic behavior of any data layout.

It provides utility methods to access basic information about the data such as its shape and strides.

It also provides a chunks method that returns an Iterator of &[T] slices of a given length whose type is defined by the implementation. This method is virtually used by all the mathematical operations to get maximal contiguous chunks of data and optimize parallelization.

Layout also defines an associated type View that represents the Layout that should be used by all non-allocating operations (e.g. broadcasting).

Associated Types

type Iter: Iterator<Item = &'a [T]>

type View: for<'b> Layout<'b, T>

Loading content...

Required methods

fn shape(&self) -> Vec<usize>

fn strides(&self) -> Vec<usize>

fn opt_chunk_size(&self) -> usize

fn num_elements(&self) -> usize

fn chunks(&'a self, chunk_size: usize) -> Self::Iter

fn as_view_unchecked(
    &'a self,
    shape: Vec<usize>,
    strides: Vec<usize>,
    num_elements: usize,
    opt_chunk_size: usize
) -> Self::View

Loading content...

Implementors

impl<'a, 'b, T> Layout<'b, T> for SliceLayout<'a, T> where
    T: 'static, 
[src]

type Iter = StridedChunks<'b, 'b, T>

type View = Self

impl<'a, T> Layout<'a, T> for HeapLayout<T> where
    T: 'static, 
[src]

type Iter = Chunks<'a, T>

type View = SliceLayout<'a, T>

impl<'a, T, S> Layout<'a, T> for StackLayout<T, S> where
    S: StaticShape + NumElements<T>,
    <S as NumElements<T>>::Output: 'static,
    T: 'static, 
[src]

type Iter = Chunks<'a, T>

type View = SliceLayout<'a, T>

impl<'a, T, S> Layout<'a, T> for StaticHeapLayout<T, S> where
    T: 'static,
    S: StaticShape
[src]

type Iter = Chunks<'a, T>

type View = SliceLayout<'a, T>

Loading content...