Struct rten_tensor::WeaklyCheckedView
source · pub struct WeaklyCheckedView<T, S: AsRef<[T]>, L: MutLayout> { /* 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: AsRef<[T]> + AsMut<[T]>, L: MutLayout, I: AsIndex<L>> IndexMut<I> for WeaklyCheckedView<T, S, L>
impl<T, S: AsRef<[T]> + AsMut<[T]>, L: MutLayout, I: AsIndex<L>> IndexMut<I> for WeaklyCheckedView<T, S, L>
source§impl<T, S: AsRef<[T]>, L: MutLayout> Layout for WeaklyCheckedView<T, S, L>
impl<T, S: AsRef<[T]>, L: MutLayout> Layout for WeaklyCheckedView<T, S, L>
source§fn try_offset(&self, index: Self::Index<'_>) -> Option<usize>
fn try_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.source§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<T, S, L> Freeze for WeaklyCheckedView<T, S, L>
impl<T, S, L> RefUnwindSafe for WeaklyCheckedView<T, S, L>
impl<T, S, L> Send for WeaklyCheckedView<T, S, L>
impl<T, S, L> Sync for WeaklyCheckedView<T, S, L>
impl<T, S, L> Unpin for WeaklyCheckedView<T, S, L>
impl<T, S, L> UnwindSafe for WeaklyCheckedView<T, S, L>
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