[−][src]Struct melange::tensor::slice_layout::SliceLayout
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]
slice: &'a [T],
shape: Vec<usize>,
strides: Vec<usize>,
num_elements: usize,
opt_chunk_size: usize
) -> Self
Trait Implementations
impl<'a, T: Clone> Clone for SliceLayout<'a, T>
[src]
fn clone(&self) -> SliceLayout<'a, T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a, T: Debug> Debug for SliceLayout<'a, T>
[src]
impl<'a, T> Deref for SliceLayout<'a, T>
[src]
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> PartialEq<SliceLayout<'a, T>> for SliceLayout<'a, T> where
T: Send + Sync + PartialEq + 'static,
[src]
T: Send + Sync + PartialEq + 'static,
Auto Trait Implementations
impl<'a, T> RefUnwindSafe for SliceLayout<'a, T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T> Send for SliceLayout<'a, T> where
T: Sync,
T: Sync,
impl<'a, T> Sync for SliceLayout<'a, T> where
T: Sync,
T: Sync,
impl<'a, T> Unpin for SliceLayout<'a, T>
impl<'a, T> UnwindSafe for SliceLayout<'a, T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,