pub struct Shape { /* private fields */ }Expand description
Shape represents the dimensions of a tensor using u32 for memory efficiency.
This struct provides a type-safe wrapper around dimension vectors and includes utilities for shape manipulation and validation.
Implementations§
Source§impl Shape
impl Shape
Sourcepub fn can_broadcast_to(&self, target: &Shape) -> bool
pub fn can_broadcast_to(&self, target: &Shape) -> bool
Checks if this shape can be broadcast to the target shape.
Sourcepub fn broadcast_shape(lhs: &Shape, rhs: &Shape) -> Option<Shape>
pub fn broadcast_shape(lhs: &Shape, rhs: &Shape) -> Option<Shape>
Computes the broadcast shape between two shapes.
Sourcepub fn normalize_axis(&self, axis: i32) -> Option<u32>
pub fn normalize_axis(&self, axis: i32) -> Option<u32>
Normalizes a dimension index, handling negative indices.
Trait Implementations§
Source§impl<'__de, __Context> BorrowDecode<'__de, __Context> for Shape
impl<'__de, __Context> BorrowDecode<'__de, __Context> for Shape
Source§fn borrow_decode<__D>(decoder: &mut __D) -> Result<Shape, DecodeError>where
__D: BorrowDecoder<'__de, Context = __Context>,
fn borrow_decode<__D>(decoder: &mut __D) -> Result<Shape, DecodeError>where
__D: BorrowDecoder<'__de, Context = __Context>,
Attempt to decode this type with the given BorrowDecode.
Source§impl<'de> Deserialize<'de> for Shape
impl<'de> Deserialize<'de> for Shape
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Shape, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Shape, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Shape
Source§impl Serialize for Shape
impl Serialize for Shape
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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