pub struct WeaklyCheckedView<S: Storage, L: Layout> { /* private fields */ }
Expand description
A view of a tensor which does “weak” checking when indexing via
view[<index>]
. This means that it does not bounds-check individual
dimensions, but does bounds-check the computed offset.
This offers a middle-ground between regular indexing, which bounds-checks each index element, and unchecked indexing, which does no bounds-checking at all and is thus unsafe.
Trait Implementations§
Source§impl<T, S: StorageMut<Elem = T>, L: Layout, I: AsIndex<L>> IndexMut<I> for WeaklyCheckedView<S, L>
impl<T, S: StorageMut<Elem = T>, L: Layout, I: AsIndex<L>> IndexMut<I> for WeaklyCheckedView<S, L>
Source§impl<T, S: Storage<Elem = T>, L: Layout> Layout for WeaklyCheckedView<S, L>
impl<T, S: Storage<Elem = T>, L: Layout> Layout for WeaklyCheckedView<S, L>
Source§fn offset(&self, index: Self::Index<'_>) -> Option<usize>
fn offset(&self, index: Self::Index<'_>) -> Option<usize>
Map an index to a storage offset, or return
None
if the index is out
of bounds along any dimension. Read moreSource§fn offset_unchecked(&self, index: Self::Index<'_>) -> usize
fn offset_unchecked(&self, index: Self::Index<'_>) -> usize
Map an index to a storage offset, without checking if it is valid for
the tensor’s shape. Read more
Source§fn is_contiguous(&self) -> bool
fn is_contiguous(&self) -> bool
Return true if this layout describes a contiguous tensor, where the
logical order of elements matches the order in which they are stored.
Source§fn is_broadcast(&self) -> bool
fn is_broadcast(&self) -> bool
Return true if iterating over elements in this layout will visit
elements multiple times.
Source§fn stride(&self, dim: usize) -> usize
fn stride(&self, dim: usize) -> usize
Returns the offset between adjacent indices along dimension
dim
.Source§fn can_broadcast_to(&self, target_shape: &[usize]) -> bool
fn can_broadcast_to(&self, target_shape: &[usize]) -> bool
Return true if this layout’s shape can be broadcast to the given shape.
Source§fn can_broadcast_with(&self, shape: &[usize]) -> bool
fn can_broadcast_with(&self, shape: &[usize]) -> bool
Return true if the tensor/view can be broadcast with another tensor or
view with a given
shape
as part of a binary operation. Read moreSource§fn min_data_len(&self) -> usize
fn min_data_len(&self) -> usize
Return the minimum length required for the element data buffer used
with this layout.
Auto Trait Implementations§
impl<S, L> Freeze for WeaklyCheckedView<S, L>
impl<S, L> RefUnwindSafe for WeaklyCheckedView<S, L>where
S: RefUnwindSafe,
L: RefUnwindSafe,
impl<S, L> Send for WeaklyCheckedView<S, L>
impl<S, L> Sync for WeaklyCheckedView<S, L>
impl<S, L> Unpin for WeaklyCheckedView<S, L>
impl<S, L> UnwindSafe for WeaklyCheckedView<S, L>where
S: UnwindSafe,
L: 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> 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