[][src]Struct melange::tensor::slice_layout::SliceLayout

pub struct SliceLayout<'a, T> { /* fields omitted */ }

SliceLayout is a very flexible non-contiguous slice-backed layout. It enables the creation of tensors that are views on other tensors becuase it does not own the data. The internal slice can actually point to any contiguous part of memory on the stack or the heap that can be borrowed.

SliceLayout comes with some memory overhead to be able to keep track of how borrowed data is used. It stores:

  • the shape
  • the actual strides (i.e. product of intrinsic and extrinsic strides)
  • the number of elements
  • the optimal chunk size (i.e. largest contiguous data pieces)

Note: The intrinsic strides are the cumulative product of the dimensions and the extrinsic strides follow the ususal ML definition.

SliceLayout is the default view layout in Melange and should be prefered unless you have specific needs.

Implementations

impl<'a, T> SliceLayout<'a, T>[src]

pub fn from_slice_unchecked(
    slice: &'a [T],
    shape: Vec<usize>,
    strides: Vec<usize>,
    num_elements: usize,
    opt_chunk_size: usize
) -> Self
[src]

Trait Implementations

impl<'a, T: Clone> Clone for SliceLayout<'a, T>[src]

impl<'a, T: Debug> Debug for SliceLayout<'a, T>[src]

impl<'a, T> Deref for SliceLayout<'a, T>[src]

type Target = [T]

The resulting type after dereferencing.

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> PartialEq<SliceLayout<'a, T>> for SliceLayout<'a, T> where
    T: Send + Sync + PartialEq + 'static, 
[src]

Auto Trait Implementations

impl<'a, T> RefUnwindSafe for SliceLayout<'a, T> where
    T: RefUnwindSafe

impl<'a, T> Send for SliceLayout<'a, T> where
    T: Sync

impl<'a, T> Sync for SliceLayout<'a, T> where
    T: Sync

impl<'a, T> Unpin for SliceLayout<'a, T>

impl<'a, T> UnwindSafe for SliceLayout<'a, T> where
    T: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.