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

source

pub fn new(dims: &[usize]) -> Self

source

pub fn strided(dims: &[usize], strides: &[isize]) -> Self

source

pub fn offset(dims: &[usize], strides: &[isize], offset: usize) -> Self

source

pub fn size(&self) -> usize

source

pub fn rank(&self) -> usize

source

pub fn contiguous(&self) -> bool

source

pub fn at_or(&self, idx: isize, or: usize) -> usize

source

pub fn iter(&self) -> Box<dyn Iterator<Item = usize> + '_>

source

pub fn view(&self, shape: &[usize]) -> Self

source

pub fn range(&self, ranges: &[Range<isize>]) -> Self

source

pub fn step(&self, steps: &[isize]) -> Self

source

pub fn squeeze(&self, squeezed: &[isize]) -> Self

source

pub fn squeeze_first(&self, n: usize) -> Self

source

pub fn squeeze_all(&self) -> Self

source

pub fn unsqueeze(&self, dim: isize) -> Self

source

pub fn extend_front(&self, size: usize) -> Self

source

pub fn broadcast(&self, other: &Self, ignore_from: Option<isize>) -> Self

source

pub fn transpose(&self, dim1: isize, dim2: isize) -> Self

Trait Implementations§

source§

impl Clone for Shape

source§

fn clone(&self) -> Shape

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Shape

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Shape

source§

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 Display for Shape

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Index<isize> for Shape

§

type Output = usize

The returned type after indexing.
source§

fn index<'a>(&'a self, i: isize) -> &'a usize

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

impl PartialEq<Shape> for Shape

source§

fn eq(&self, other: &Shape) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Shape

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Any for Twhere T: Any + Serialize + Deserialize,

source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert to a &std::any::Any.
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert to a &mut std::any::Any.
source§

fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>

Convert to a std::boxed::Box<dyn std::any::Any>.
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> Serialize for Twhere T: Serialize + ?Sized,

source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T> Type for Twhere T: ?Sized,

source§

default fn meta(self: *const T) -> <T as Type>::Meta

Retrieve TraitObject, Slice or Concrete meta data respectively for a type
source§

default fn data(self: *const T) -> *const ()

Retrieve pointer to the data
source§

default fn data_mut(self: *mut T) -> *mut ()

Retrieve mut pointer to the data
source§

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

Create a *mut Self with the provided Self::Meta.
source§

const METATYPE: MetaType

Enum describing whether a type is TraitObject, Slice or Concrete.
§

type Meta: 'static

Type of metadata for type.
source§

fn meta_type(self: *const Self) -> MetaType

Helper method describing whether a type is TraitObject, Slice or Concrete.
source§

impl<T> Type for T

source§

const METATYPE: MetaType = MetaType::Concrete

Enum describing whether a type is TraitObject, Slice or Concrete.
§

type Meta = Concrete

Type of metadata for type.
source§

fn meta(self: *const T) -> <T as Type>::Meta

Retrieve TraitObject, Slice or Concrete meta data respectively for a type
source§

fn data(self: *const T) -> *const ()

Retrieve pointer to the data
source§

fn data_mut(self: *mut T) -> *mut ()

Retrieve mut pointer to the data
source§

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

Create a *mut Self with the provided Self::Meta.
source§

fn meta_type(self: *const Self) -> MetaType

Helper method describing whether a type is TraitObject, Slice or Concrete.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> Debug for Twhere T: Debug + Serialize + Deserialize + ?Sized,

source§

impl<T> Deserialize for Twhere T: DeserializeOwned,

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,

source§

impl<T> Display for Twhere T: Display + Serialize + Deserialize + ?Sized,

source§

impl<T> Inner for Twhere T: PartialEq<T> + Clone + Send + Sync + Debug,

source§

impl<T> Serialize for Twhere T: Serialize + ?Sized,