Struct microtensor::Shape
source · pub struct Shape {
pub dims: Vec<usize>,
/* private fields */
}
Expand description
The shape of a Tensor.
Fields§
§dims: Vec<usize>
Implementations§
source§impl Shape
impl Shape
pub fn new(dims: &[usize]) -> Self
pub fn strided(dims: &[usize], strides: &[isize]) -> Self
pub fn offset(dims: &[usize], strides: &[isize], offset: usize) -> Self
pub fn size(&self) -> usize
pub fn rank(&self) -> usize
pub fn contiguous(&self) -> bool
pub fn at_or(&self, idx: isize, or: usize) -> usize
pub fn iter(&self) -> Box<dyn Iterator<Item = usize> + '_>
pub fn view(&self, shape: &[usize]) -> Self
pub fn range(&self, ranges: &[Range<isize>]) -> Self
pub fn step(&self, steps: &[isize]) -> Self
pub fn squeeze(&self, squeezed: &[isize]) -> Self
pub fn squeeze_first(&self, n: usize) -> Self
pub fn squeeze_all(&self) -> Self
pub fn unsqueeze(&self, dim: isize) -> Self
pub fn extend_front(&self, size: usize) -> Self
pub fn broadcast(&self, other: &Self, ignore_from: Option<isize>) -> Self
pub fn transpose(&self, dim1: isize, dim2: isize) -> Self
Trait Implementations§
source§impl<'de> Deserialize<'de> for Shape
impl<'de> Deserialize<'de> for Shape
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl PartialEq<Shape> for Shape
impl PartialEq<Shape> for Shape
impl StructuralPartialEq for Shape
Auto Trait Implementations§
impl RefUnwindSafe for Shape
impl Send for Shape
impl Sync for Shape
impl Unpin for Shape
impl UnwindSafe for Shape
Blanket Implementations§
source§impl<T> Serialize for Twhere
T: Serialize + ?Sized,
impl<T> Serialize for Twhere T: Serialize + ?Sized,
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>
source§impl<T> Type for Twhere
T: ?Sized,
impl<T> Type for Twhere T: ?Sized,
source§default fn dangling(t: <T as Type>::Meta) -> NonNull<T>
default fn dangling(t: <T as Type>::Meta) -> NonNull<T>
Create a dangling non-null
*const Self
with the provided Self::Meta
.source§default fn fatten(thin: *mut (), t: <T as Type>::Meta) -> *mut T
default fn fatten(thin: *mut (), t: <T as Type>::Meta) -> *mut T
Create a
*mut Self
with the provided Self::Meta
.source§fn meta_type(self: *const Self) -> MetaType
fn meta_type(self: *const Self) -> MetaType
Helper method describing whether a type is
TraitObject
, Slice
or Concrete
.source§impl<T> Type for T
impl<T> Type for T
source§const METATYPE: MetaType = MetaType::Concrete
const METATYPE: MetaType = MetaType::Concrete
Enum describing whether a type is
TraitObject
, Slice
or Concrete
.source§fn dangling(_t: <T as Type>::Meta) -> NonNull<T>
fn dangling(_t: <T as Type>::Meta) -> NonNull<T>
Create a dangling non-null
*const Self
with the provided Self::Meta
.source§fn fatten(thin: *mut (), _t: <T as Type>::Meta) -> *mut T
fn fatten(thin: *mut (), _t: <T as Type>::Meta) -> *mut T
Create a
*mut Self
with the provided Self::Meta
.source§fn meta_type(self: *const Self) -> MetaType
fn meta_type(self: *const Self) -> MetaType
Helper method describing whether a type is
TraitObject
, Slice
or Concrete
.