pub struct Contiguous<T>(/* private fields */);Expand description
A tensor wrapper which guarantees that the tensor has a contiguous layout.
A contiguous layout means that the order of elements in memory matches the logical row-major ordering of elements with no gaps.
Implementations§
Source§impl<T> Contiguous<T>
impl<T> Contiguous<T>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Extract the tensor from the wrapper.
Source§impl<S: Storage, L: Layout> Contiguous<TensorBase<S, L>>
impl<S: Storage, L: Layout> Contiguous<TensorBase<S, L>>
Sourcepub fn new(inner: TensorBase<S, L>) -> Option<Self>
pub fn new(inner: TensorBase<S, L>) -> Option<Self>
Wrap a tensor if it is contiguous, or return None if the tensor has
a non-contiguous layout.
Sourcepub fn data(&self) -> &[S::Elem]
pub fn data(&self) -> &[S::Elem]
Return the tensor’s underlying data as a slice.
Unlike TensorBase::data this returns a slice instead of an option
because the tensor is known to be contiguous.
Sourcepub fn view(&self) -> Contiguous<TensorBase<ViewData<'_, S::Elem>, L>>
pub fn view(&self) -> Contiguous<TensorBase<ViewData<'_, S::Elem>, L>>
Return a contiguous view of this tensor.
Source§impl<T, L: Clone + Layout> Contiguous<TensorBase<Vec<T>, L>>
impl<T, L: Clone + Layout> Contiguous<TensorBase<Vec<T>, L>>
Trait Implementations§
Source§impl<T: Clone> Clone for Contiguous<T>
impl<T: Clone> Clone for Contiguous<T>
Source§fn clone(&self) -> Contiguous<T>
fn clone(&self) -> Contiguous<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug> Debug for Contiguous<T>
impl<T: Debug> Debug for Contiguous<T>
Source§impl<T> Deref for Contiguous<T>
impl<T> Deref for Contiguous<T>
Source§impl<S: Storage, L: Layout> From<Contiguous<TensorBase<S, L>>> for TensorBase<S, L>
impl<S: Storage, L: Layout> From<Contiguous<TensorBase<S, L>>> for TensorBase<S, L>
Source§fn from(val: Contiguous<TensorBase<S, L>>) -> Self
fn from(val: Contiguous<TensorBase<S, L>>) -> Self
Converts to this type from the input type.
Source§impl<T: PartialEq> PartialEq for Contiguous<T>
impl<T: PartialEq> PartialEq for Contiguous<T>
impl<T: Copy> Copy for Contiguous<T>
impl<T> StructuralPartialEq for Contiguous<T>
Auto Trait Implementations§
impl<T> Freeze for Contiguous<T>where
T: Freeze,
impl<T> RefUnwindSafe for Contiguous<T>where
T: RefUnwindSafe,
impl<T> Send for Contiguous<T>where
T: Send,
impl<T> Sync for Contiguous<T>where
T: Sync,
impl<T> Unpin for Contiguous<T>where
T: Unpin,
impl<T> UnwindSafe for Contiguous<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more