Trait DimLike

Source
pub trait DimLike:
    Clone
    + Default
    + PartialEq
    + From<usize>
    + for<'a> TryFrom<&'a TDim, Error = Error>
    + Zero<Output = Self, Output = Self, Output = Self>
    + Debug
    + Display
    + Hash
    + Add
    + Add<usize>
    + for<'a> Add<&'a Self>
    + Sub<Output = Self, Output = Self, Output = Self>
    + Sub<usize>
    + for<'a> Sub<&'a Self>
    + Mul<Output = Self, Output = Self, Output = Self>
    + Mul<usize>
    + for<'a> Mul<&'a Self>
    + Div<usize, Output = Self>
    + Rem<usize, Output = Self>
    + Send
    + Sync
    + 'static
    + Sum
    + Product
    + ToDim
    + One {
Show 13 methods // Required methods fn maybe_div(&self, other: &Self) -> Result<(Self, u64), Error>; fn to_i64(&self) -> Result<i64, Error>; fn eval(&self, values: &SymbolValues) -> Self; fn eval_to_i64(&self, values: &SymbolValues) -> Result<i64, Error>; fn substitute(&self, from: &Symbol, to: &Self) -> Result<Self, Error>; fn broadcast(self, other: Self) -> Result<Self, Error>; fn mini(self, other: Self) -> Self; fn maxi(self, other: Self) -> Self; fn compatible_with(&self, other: &Self) -> bool; // Provided methods fn divceil(&self, other: usize) -> Self { ... } fn to_usize(&self) -> Result<usize, Error> { ... } fn to_isize(&self) -> Result<isize, Error> { ... } fn to_i32(&self) -> Result<i32, Error> { ... }
}
Expand description

A super-trait for value acting as tensor dimensions in tract.

Implemented by:

  • usize for regular dimensions
  • TDim supporting regular and streaming dimensions

Required Methods§

Source

fn maybe_div(&self, other: &Self) -> Result<(Self, u64), Error>

Source

fn to_i64(&self) -> Result<i64, Error>

Convert to regular integer.

Source

fn eval(&self, values: &SymbolValues) -> Self

Substitute as many symbols as possible in the dim value.

Source

fn eval_to_i64(&self, values: &SymbolValues) -> Result<i64, Error>

Full evaluation of the symbol, failing if a symbol is missing

Source

fn substitute(&self, from: &Symbol, to: &Self) -> Result<Self, Error>

Source

fn broadcast(self, other: Self) -> Result<Self, Error>

Source

fn mini(self, other: Self) -> Self

Source

fn maxi(self, other: Self) -> Self

Source

fn compatible_with(&self, other: &Self) -> bool

Provided Methods§

Source

fn divceil(&self, other: usize) -> Self

Integer divise, rounding up to next integer.

Source

fn to_usize(&self) -> Result<usize, Error>

Source

fn to_isize(&self) -> Result<isize, Error>

Source

fn to_i32(&self) -> Result<i32, Error>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl DimLike for usize

Source§

fn maybe_div(&self, other: &usize) -> Result<(usize, u64), Error>

Source§

fn to_i64(&self) -> Result<i64, Error>

Source§

fn eval(&self, _values: &SymbolValues) -> usize

Source§

fn substitute(&self, _from: &Symbol, _to: &usize) -> Result<usize, Error>

Source§

fn eval_to_i64(&self, _: &SymbolValues) -> Result<i64, Error>

Source§

fn broadcast(self, other: usize) -> Result<usize, Error>

Source§

fn compatible_with(&self, other: &usize) -> bool

Source§

fn mini(self, other: usize) -> usize

Source§

fn maxi(self, other: usize) -> usize

Implementors§