WeaklyCheckedView

Struct WeaklyCheckedView 

Source
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: Storage<Elem = T>, L: Layout, I: AsIndex<L>> Index<I> for WeaklyCheckedView<S, L>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: I) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T, S: StorageMut<Elem = T>, L: Layout, I: AsIndex<L>> IndexMut<I> for WeaklyCheckedView<S, L>

Source§

fn index_mut(&mut self, index: I) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T, S: Storage<Elem = T>, L: Layout> Layout for WeaklyCheckedView<S, L>

Source§

type Index<'a> = <L as Layout>::Index<'a>

Type used to represent indices. Read more
Source§

type Indices = <L as Layout>::Indices

Iterator over indices in this tensor.
Source§

fn ndim(&self) -> usize

Return the number of dimensions.
Source§

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 more
Source§

fn len(&self) -> usize

Returns the number of elements in the array.
Source§

fn shape(&self) -> Self::Index<'_>

Returns an array of the sizes of each dimension.
Source§

fn strides(&self) -> Self::Index<'_>

Returns an array of the strides of each dimension.
Source§

fn indices(&self) -> Self::Indices

Return an iterator over all valid indices in this tensor.
Source§

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

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

Return true if iterating over elements in this layout will visit elements multiple times.
Source§

fn is_empty(&self) -> bool

Returns true if the array has no elements.
Source§

fn size(&self, dim: usize) -> usize

Returns the size of the dimension dim.
Source§

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

Return true if this layout’s shape can be broadcast to the given shape.
Source§

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 more
Source§

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>
where S: Freeze, L: Freeze,

§

impl<S, L> RefUnwindSafe for WeaklyCheckedView<S, L>

§

impl<S, L> Send for WeaklyCheckedView<S, L>
where S: Send, L: Send,

§

impl<S, L> Sync for WeaklyCheckedView<S, L>
where S: Sync, L: Sync,

§

impl<S, L> Unpin for WeaklyCheckedView<S, L>
where S: Unpin, L: Unpin,

§

impl<S, L> UnwindSafe for WeaklyCheckedView<S, L>
where S: UnwindSafe, L: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.