[][src]Trait tract_onnx::prelude::tract_ndarray::Dimension

pub trait Dimension: Clone + Eq + Default + Send + Sync + Add<Self, Output = Self> + Sub<Self, Output = Self> + Mul<usize, Output = Self, Output = Self> + Mul<Self> + AddAssign<Self> + for<'x> AddAssign<&'x Self> + SubAssign<Self> + for<'x> SubAssign<&'x Self> + MulAssign<Self> + for<'x> MulAssign<&'x Self> + MulAssign<usize> + IndexMut<usize, Output = usize> + Debug where
    <Self::Pattern as IntoDimension>::Dim == Self, 
{ type SliceArg: AsRef<[SliceOrIndex]> + ?Sized; type Pattern: IntoDimension + Clone + PartialEq<Self::Pattern> + Eq + Default + Debug; type Smaller: Dimension; type Larger: Dimension; const NDIM: Option<usize>; fn ndim(&self) -> usize;
fn into_pattern(self) -> Self::Pattern;
fn zeros(ndim: usize) -> Self;
fn __private__(&self) -> PrivateMarker; fn size(&self) -> usize { ... }
fn size_checked(&self) -> Option<usize> { ... }
fn as_array_view(&self) -> ArrayBase<ViewRepr<&usize>, Dim<[usize; 1]>> { ... }
fn as_array_view_mut(
        &mut self
    ) -> ArrayBase<ViewRepr<&mut usize>, Dim<[usize; 1]>> { ... }
fn into_dyn(self) -> Dim<IxDynImpl> { ... } }

Array shape and index trait.

This trait defines a number of methods and operations that can be used on dimensions and indices.

Note: This trait can not be implemented outside the crate

Associated Types

type SliceArg: AsRef<[SliceOrIndex]> + ?Sized

SliceArg is the type which is used to specify slicing for this dimension.

For the fixed size dimensions it is a fixed size array of the correct size, which you pass by reference. For the dynamic dimension it is a slice.

  • For Ix1: [SliceOrIndex; 1]
  • For Ix2: [SliceOrIndex; 2]
  • and so on..
  • For IxDyn: [SliceOrIndex]

The easiest way to create a &SliceInfo<SliceArg, Do> is using the s![] macro.

type Pattern: IntoDimension + Clone + PartialEq<Self::Pattern> + Eq + Default + Debug

Pattern matching friendly form of the dimension value.

  • For Ix1: usize,
  • For Ix2: (usize, usize)
  • and so on..
  • For IxDyn: IxDyn

type Smaller: Dimension

Next smaller dimension (if applicable)

type Larger: Dimension

Next larger dimension

Loading content...

Associated Constants

const NDIM: Option<usize>

For fixed-size dimension representations (e.g. Ix2), this should be Some(ndim), and for variable-size dimension representations (e.g. IxDyn), this should be None.

Loading content...

Required methods

fn ndim(&self) -> usize

Returns the number of dimensions (number of axes).

fn into_pattern(self) -> Self::Pattern

Convert the dimension into a pattern matching friendly value.

fn zeros(ndim: usize) -> Self

Creates a dimension of all zeros with the specified ndim.

This method is useful for generalizing over fixed-size and variable-size dimension representations.

Panics if Self has a fixed size that is not ndim.

fn __private__(&self) -> PrivateMarker

This trait is private to implement; this method exists to make it impossible to implement outside the crate.

Loading content...

Provided methods

fn size(&self) -> usize

Compute the size of the dimension (number of elements)

fn size_checked(&self) -> Option<usize>

Compute the size while checking for overflow.

fn as_array_view(&self) -> ArrayBase<ViewRepr<&usize>, Dim<[usize; 1]>>

Borrow as a read-only array view.

fn as_array_view_mut(
    &mut self
) -> ArrayBase<ViewRepr<&mut usize>, Dim<[usize; 1]>>

Borrow as a read-write array view.

fn into_dyn(self) -> Dim<IxDynImpl>

Convert the dimensional into a dynamic dimensional (IxDyn).

Loading content...

Implementors

impl Dimension for Dim<[usize; 0]>[src]

type SliceArg = [SliceOrIndex; 0]

type Pattern = ()

type Smaller = Dim<[usize; 0]>

type Larger = Dim<[usize; 1]>

impl Dimension for Dim<[usize; 1]>[src]

type SliceArg = [SliceOrIndex; 1]

type Pattern = usize

type Smaller = Dim<[usize; 0]>

type Larger = Dim<[usize; 2]>

fn stride_offset(index: &Dim<[usize; 1]>, stride: &Dim<[usize; 1]>) -> isize[src]

fn stride_offset_checked(
    &self,
    stride: &Dim<[usize; 1]>,
    index: &Dim<[usize; 1]>
) -> Option<isize>
[src]

impl Dimension for Dim<[usize; 2]>[src]

type SliceArg = [SliceOrIndex; 2]

type Pattern = (usize, usize)

type Smaller = Dim<[usize; 1]>

type Larger = Dim<[usize; 3]>

fn stride_offset(index: &Dim<[usize; 2]>, strides: &Dim<[usize; 2]>) -> isize[src]

fn stride_offset_checked(
    &self,
    strides: &Dim<[usize; 2]>,
    index: &Dim<[usize; 2]>
) -> Option<isize>
[src]

impl Dimension for Dim<[usize; 3]>[src]

type SliceArg = [SliceOrIndex; 3]

type Pattern = (usize, usize, usize)

type Smaller = Dim<[usize; 2]>

type Larger = Dim<[usize; 4]>

fn stride_offset(index: &Dim<[usize; 3]>, strides: &Dim<[usize; 3]>) -> isize[src]

fn stride_offset_checked(
    &self,
    strides: &Dim<[usize; 3]>,
    index: &Dim<[usize; 3]>
) -> Option<isize>
[src]

impl Dimension for Dim<[usize; 4]>[src]

type SliceArg = [SliceOrIndex; 4]

type Pattern = (usize, usize, usize, usize)

type Smaller = Dim<[usize; 3]>

type Larger = Dim<[usize; 5]>

impl Dimension for Dim<[usize; 5]>[src]

type SliceArg = [SliceOrIndex; 5]

type Pattern = (usize, usize, usize, usize, usize)

type Smaller = Dim<[usize; 4]>

type Larger = Dim<[usize; 6]>

impl Dimension for Dim<[usize; 6]>[src]

type SliceArg = [SliceOrIndex; 6]

type Pattern = (usize, usize, usize, usize, usize, usize)

type Smaller = Dim<[usize; 5]>

type Larger = Dim<IxDynImpl>

impl Dimension for Dim<IxDynImpl>[src]

IxDyn is a "dynamic" index, pretty hard to use when indexing, and memory wasteful, but it allows an arbitrary and dynamic number of axes.

type SliceArg = [SliceOrIndex]

type Pattern = Dim<IxDynImpl>

type Smaller = Dim<IxDynImpl>

type Larger = Dim<IxDynImpl>

Loading content...