pub struct Shape(/* private fields */);Implementations§
Source§impl Shape
impl Shape
pub fn scalar() -> Self
pub fn is_scalar(&self) -> bool
pub fn rank(&self) -> usize
pub fn dims(&self) -> &[usize]
pub fn into_dims(self) -> Vec<usize>
pub fn dim(&self, dim: impl Dim) -> Result<usize>
pub fn element_count(&self) -> usize
pub fn is_contiguous(&self, stride: &[usize]) -> bool
pub fn extend(self, additional_dims: &[usize]) -> Self
Sourcepub fn broadcast_shape_binary_op(
&self,
rhs: &Self,
op: &'static str,
) -> Result<Shape>
pub fn broadcast_shape_binary_op( &self, rhs: &Self, op: &'static str, ) -> Result<Shape>
Check whether the two shapes are compatible for broadcast, and if it is the case return the broadcasted shape. This is to be used for binary pointwise ops. Copy from https://github.com/huggingface/candle
Sourcepub fn dim_coordinates(&self) -> DimCoordinates ⓘ
pub fn dim_coordinates(&self) -> DimCoordinates ⓘ
Returns an iterator over dimension coordinates.
This iterator yields the multi-dimensional coordinates
(e.g., [i, j, k, ...]) of each element in the array, independent
of the physical storage layout.
Example for shape = (2, 2):
yields: [0, 0], [0, 1], [1, 0], [1, 1]
pub fn dims_coordinates<const N: usize>(&self) -> Result<DimNCoordinates<N>>
pub fn dim2_coordinates(&self) -> Result<DimNCoordinates<2>>
pub fn dim3_coordinates(&self) -> Result<DimNCoordinates<3>>
pub fn dim4_coordinates(&self) -> Result<DimNCoordinates<4>>
pub fn dim5_coordinates(&self) -> Result<DimNCoordinates<5>>
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