pub enum SymExpr {
Value(i32),
Var(Rc<Symbol>),
Add((Rc<SymExpr>, Rc<SymExpr>)),
Sub((Rc<SymExpr>, Rc<SymExpr>)),
Mul((Rc<SymExpr>, Rc<SymExpr>)),
Div((Rc<SymExpr>, Rc<SymExpr>)),
DivCeil((Rc<SymExpr>, Rc<SymExpr>)),
Max((Rc<SymExpr>, Rc<SymExpr>)),
Min((Rc<SymExpr>, Rc<SymExpr>)),
Broadcast((Rc<SymExpr>, Rc<SymExpr>)),
Neg(Rc<SymExpr>),
}Expand description
Symbolic expression representing an integer value.
Expressions can be known integer values, named symbols or composite expressions.
Variants§
Value(i32)
Element with a known integer value.
Var(Rc<Symbol>)
Symbolic value
Add((Rc<SymExpr>, Rc<SymExpr>))
Addition of two symbolic values
Sub((Rc<SymExpr>, Rc<SymExpr>))
Subtraction of two symbolic values
Mul((Rc<SymExpr>, Rc<SymExpr>))
Multiplication of two symbolic values
Div((Rc<SymExpr>, Rc<SymExpr>))
Flooring division of first expression by second.
DivCeil((Rc<SymExpr>, Rc<SymExpr>))
Ceiling division of first expression by second.
Max((Rc<SymExpr>, Rc<SymExpr>))
Maximum of two symbolic values
Min((Rc<SymExpr>, Rc<SymExpr>))
Minimum of two symbolic values
Broadcast((Rc<SymExpr>, Rc<SymExpr>))
Broadcast two symbolic values.
This behaves like Max, except it implies that both expressions are
positive and either equal or 1.
Neg(Rc<SymExpr>)
Negation of a value
Implementations§
Source§impl SymExpr
impl SymExpr
Sourcepub fn is_positive(&self) -> bool
pub fn is_positive(&self) -> bool
Return true if the value of this expression is known to be >= 0.
Sourcepub fn broadcast(&self, other: &SymExpr) -> SymExpr
pub fn broadcast(&self, other: &SymExpr) -> SymExpr
Return the result of broadcasting self and other.
Sourcepub fn div_ceil(&self, other: &SymExpr) -> SymExpr
pub fn div_ceil(&self, other: &SymExpr) -> SymExpr
Return the result of dividing self by other, rounded up.
Sourcepub fn simplify(&self) -> SymExpr
pub fn simplify(&self) -> SymExpr
Simplify an expression.
This simplifies expressions such as identities (eg. x + 0 becomes x).
Trait Implementations§
Source§impl AddAssign for SymExpr
impl AddAssign for SymExpr
Source§fn add_assign(&mut self, rhs: SymExpr)
fn add_assign(&mut self, rhs: SymExpr)
+= operation. Read moreSource§impl<'a> From<&'a str> for SymExpr
Create a symbol with a given name and an assumption that the value is
positive (>= 0).
impl<'a> From<&'a str> for SymExpr
Create a symbol with a given name and an assumption that the value is
positive (>= 0).
The rationale for the positivity assumption is that during shape inference, the most common use of symbols is to represent dimension sizes.
Auto Trait Implementations§
impl Freeze for SymExpr
impl RefUnwindSafe for SymExpr
impl !Send for SymExpr
impl !Sync for SymExpr
impl Unpin for SymExpr
impl UnwindSafe for SymExpr
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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