[−][src]Trait melange::tensor::layout::Layout
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
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
&'a self,
shape: Vec<usize>,
strides: Vec<usize>,
num_elements: usize,
opt_chunk_size: usize
) -> Self::View
Implementors
impl<'a, 'b, T> Layout<'b, T> for SliceLayout<'a, T> where
T: 'static,
[src]
T: 'static,
type Iter = StridedChunks<'b, 'b, T>
type View = Self
fn shape(&self) -> Vec<usize>
[src]
fn strides(&self) -> Vec<usize>
[src]
fn opt_chunk_size(&self) -> usize
[src]
fn num_elements(&self) -> usize
[src]
fn chunks(&'b self, chunk_size: usize) -> Self::Iter
[src]
fn as_view_unchecked(
&'b self,
shape: Vec<usize>,
strides: Vec<usize>,
num_elements: usize,
opt_chunk_size: usize
) -> Self::View
[src]
&'b self,
shape: Vec<usize>,
strides: Vec<usize>,
num_elements: usize,
opt_chunk_size: usize
) -> Self::View
impl<'a, T> Layout<'a, T> for HeapLayout<T> where
T: 'static,
[src]
T: 'static,
type Iter = Chunks<'a, T>
type View = SliceLayout<'a, T>
fn shape(&self) -> Vec<usize>
[src]
fn strides(&self) -> Vec<usize>
[src]
fn opt_chunk_size(&self) -> usize
[src]
fn num_elements(&self) -> usize
[src]
fn chunks(&'a self, chunk_size: usize) -> Self::Iter
[src]
fn as_view_unchecked(
&'a self,
shape: Vec<usize>,
strides: Vec<usize>,
num_elements: usize,
opt_chunk_size: usize
) -> Self::View
[src]
&'a self,
shape: Vec<usize>,
strides: Vec<usize>,
num_elements: usize,
opt_chunk_size: usize
) -> Self::View
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]
S: StaticShape + NumElements<T>,
<S as NumElements<T>>::Output: 'static,
T: 'static,
type Iter = Chunks<'a, T>
type View = SliceLayout<'a, T>
fn shape(&self) -> Vec<usize>
[src]
fn strides(&self) -> Vec<usize>
[src]
fn opt_chunk_size(&self) -> usize
[src]
fn num_elements(&self) -> usize
[src]
fn chunks(&'a self, chunk_size: usize) -> Self::Iter
[src]
fn as_view_unchecked(
&'a self,
shape: Vec<usize>,
strides: Vec<usize>,
num_elements: usize,
opt_chunk_size: usize
) -> Self::View
[src]
&'a self,
shape: Vec<usize>,
strides: Vec<usize>,
num_elements: usize,
opt_chunk_size: usize
) -> Self::View
impl<'a, T, S> Layout<'a, T> for StaticHeapLayout<T, S> where
T: 'static,
S: StaticShape,
[src]
T: 'static,
S: StaticShape,
type Iter = Chunks<'a, T>
type View = SliceLayout<'a, T>
fn shape(&self) -> Vec<usize>
[src]
fn strides(&self) -> Vec<usize>
[src]
fn opt_chunk_size(&self) -> usize
[src]
fn num_elements(&self) -> usize
[src]
fn chunks(&'a self, chunk_size: usize) -> Self::Iter
[src]
fn as_view_unchecked(
&'a self,
shape: Vec<usize>,
strides: Vec<usize>,
num_elements: usize,
opt_chunk_size: usize
) -> Self::View
[src]
&'a self,
shape: Vec<usize>,
strides: Vec<usize>,
num_elements: usize,
opt_chunk_size: usize
) -> Self::View