pub struct Shape(/* private fields */);Expand description
The extents of a tensor, one entry per dimension, outermost first (row-major convention throughout the project).
A rank-0 shape ([]) is a scalar and is valid. A dimension of size 0 is
valid and makes the element count 0.
Implementations§
Source§impl Shape
impl Shape
Sourcepub fn numel(&self) -> usize
pub fn numel(&self) -> usize
The total number of elements.
A scalar has 1 element; any zero-sized dimension makes this 0.
Sourcepub fn checked_numel(&self) -> Option<usize>
pub fn checked_numel(&self) -> Option<usize>
Total number of elements, or None when the product of the
dimensions does not fit in usize.
Every constructor that accepts a caller-supplied shape validates
with this before allocating: a wrapped product would let a shape
claim 2^64 elements over an empty buffer and pass the
data.len() == numel check (a reported class of bug); with the
check, such a shape is a typed error instead.
Trait Implementations§
impl Eq for Shape
impl StructuralPartialEq for Shape
Auto Trait Implementations§
impl Freeze for Shape
impl RefUnwindSafe for Shape
impl Send for Shape
impl Sync for Shape
impl Unpin for Shape
impl UnsafeUnpin for Shape
impl UnwindSafe for Shape
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