pub struct PrimExpr { /* private fields */ }Expand description
An expression typed by a PrimType (C++ PrimExpr): a constant, a variable, an operator
on scalars or vectors, or a call that returns one.
PrimExpr and IntExpr are typed views (C++ TypedExpr). A view holds an ir.Expr as
Expr does, and adds what the object class does not say: the type of the expression. An
ir.Call is a PrimExpr when its ty is a PrimType, and an IntExpr when that type is
a scalar integer. The views are checked when they are made, so a function that takes one
needs no check of its own:
- A view converts into the views and the
Exprit refines for free (From): anIntExprinto aPrimExprand both into anExpr. Borrowed, anIntExpris aPrimExprthroughAsRef, and both views read their object throughDeref, as anExprdoes. - An
Exprconverts into a view only through a check (TryFrom,ObjectRefCast::try_cast), as anAnydoes. A failed check names the expression and its type,ir.StringImm[ty=ir.StringType]. IntImm,FloatImmandTensorLoadare typed by aPrimTypewhen they are made, so they convert into aPrimExprfor free. Rust literals convert as they convert into anExpr: ani32and anf32as C++PrimExpr(int32_t)andPrimExpr(float)convert them.- The operators build a
PrimExpr: each step of anExprResultis checked, soPrimExpr::try_from(a + b)?reports only the errors of the operators. - The view holds its object privately and gives it out only to read, so its type cannot be
changed; the one way past the check is the
unsafeObjectRefCore::from_data.
fn widen(expr: Expr) -> PrimExpr {
expr // An `Expr` is not a `PrimExpr` until it is checked.
}fn narrow(expr: PrimExpr) -> IntExpr {
expr.into() // Nor is a `PrimExpr` an `IntExpr`.
}Implementations§
Trait Implementations§
Source§impl AnyCompatible for PrimExpr
impl AnyCompatible for PrimExpr
Source§unsafe fn is_undefined(field: *const Self) -> bool
unsafe fn is_undefined(field: *const Self) -> bool
field, which holds a value of this type or all-zero bytes,
holds all-zero bytes that are no value of this type, as a null object
reference, a string of type index None or a zero device type: a field
that a creator left undefined for reflection to set, as C++ UnsafeInit
leaves a reference undefined (null). Unlike a C++ undefined reference,
it is no value; a nullable reference is Option<T>, whose None is a
defined value. Read moreSource§fn get_mismatch_type_info(data: &TVMFFIAny) -> String
fn get_mismatch_type_info(data: &TVMFFIAny) -> String
Source§unsafe fn copy_to_any_view(src: &Self, data: &mut TVMFFIAny)
unsafe fn copy_to_any_view(src: &Self, data: &mut TVMFFIAny)
Source§unsafe fn move_to_any(src: Self, data: &mut TVMFFIAny)
unsafe fn move_to_any(src: Self, data: &mut TVMFFIAny)
unsafe fn check_any_strict(data: &TVMFFIAny) -> bool
Source§unsafe fn copy_from_any_view_after_check(data: &TVMFFIAny) -> Self
unsafe fn copy_from_any_view_after_check(data: &TVMFFIAny) -> Self
Source§unsafe fn move_from_any_after_check(data: &mut TVMFFIAny) -> Self
unsafe fn move_from_any_after_check(data: &mut TVMFFIAny) -> Self
Source§unsafe fn try_cast_from_any_view(data: &TVMFFIAny) -> Result<Self, ()>
unsafe fn try_cast_from_any_view(data: &TVMFFIAny) -> Result<Self, ()>
Source§fn type_schema() -> String
fn type_schema() -> String
TypeTraits<T>::TypeSchema writes, which the type schemas of functions
and fields embed. Read moreSource§impl<'a> ArgIntoRef for &'a PrimExpr
impl<'a> ArgIntoRef for &'a PrimExpr
Source§impl ArgIntoRef for PrimExpr
impl ArgIntoRef for PrimExpr
Source§impl AsRef<PrimExpr> for IntExpr
An IntExpr borrowed as the PrimExpr it is, as C++ IntExpr derives from PrimExpr.
impl AsRef<PrimExpr> for IntExpr
An IntExpr borrowed as the PrimExpr it is, as C++ IntExpr derives from PrimExpr.
Source§impl From<&PrimExpr> for ExprResult
impl From<&PrimExpr> for ExprResult
Source§impl From<&TensorLoad> for PrimExpr
impl From<&TensorLoad> for PrimExpr
Source§fn from(value: &TensorLoad) -> Self
fn from(value: &TensorLoad) -> Self
Source§impl From<PrimExpr> for ExprResult
impl From<PrimExpr> for ExprResult
Source§impl From<TensorLoad> for PrimExpr
impl From<TensorLoad> for PrimExpr
Source§fn from(value: TensorLoad) -> Self
fn from(value: TensorLoad) -> Self
Source§impl From<bool> for PrimExpr
A bool is a boolean constant, as C++ converts a bool held by an Any. (C++ promotes a
bool argument to PrimExpr(int32_t), an int32 constant.)
impl From<bool> for PrimExpr
A bool is a boolean constant, as C++ converts a bool held by an Any. (C++ promotes a
bool argument to PrimExpr(int32_t), an int32 constant.)
Source§impl From<f64> for PrimExpr
An f64 is a float64 constant, as C++ types a double next to an expression. (C++ converts
a double held by an Any to float32.)
impl From<f64> for PrimExpr
An f64 is a float64 constant, as C++ types a double next to an expression. (C++ converts
a double held by an Any to float32.)
Source§impl From<i64> for PrimExpr
An i64 is an int64 constant. (C++ converts an int64_t held by an Any to int32 when
the value fits.)
impl From<i64> for PrimExpr
An i64 is an int64 constant. (C++ converts an int64_t held by an Any to int32 when
the value fits.)
Source§impl<'a> IntoArgHolder for &'a PrimExpr
impl<'a> IntoArgHolder for &'a PrimExpr
Source§impl IntoArgHolder for PrimExpr
impl IntoArgHolder for PrimExpr
Source§impl ObjectRefCore for PrimExpr
impl ObjectRefCore for PrimExpr
type ContainerType = ExprObj
fn data(this: &Self) -> &ObjectArc<ExprObj>
fn into_data(this: Self) -> ObjectArc<ExprObj>
Source§fn same_as<Other>(&self, other: &Other) -> boolwhere
Other: ObjectRefCore,
fn same_as<Other>(&self, other: &Other) -> boolwhere
Other: ObjectRefCore,
Source§fn downcast_ref<T>(&self) -> Option<&T>where
T: ObjectCore,
fn downcast_ref<T>(&self) -> Option<&T>where
T: ObjectCore,
Source§impl PrimOps for PrimExpr
impl PrimOps for PrimExpr
Source§fn to_expr_result(&self) -> ExprResult
fn to_expr_result(&self) -> ExprResult
ExprResult (a reference-count increment).Source§fn less_equal(&self, rhs: impl Operand) -> ExprResult
fn less_equal(&self, rhs: impl Operand) -> ExprResult
a <= b (le).Source§fn greater_equal(&self, rhs: impl Operand) -> ExprResult
fn greater_equal(&self, rhs: impl Operand) -> ExprResult
a >= b (ge).Source§fn logical_and(&self, rhs: impl IntoExpr) -> ExprResult
fn logical_and(&self, rhs: impl IntoExpr) -> ExprResult
a && b (logical_and).Source§fn logical_or(&self, rhs: impl IntoExpr) -> ExprResult
fn logical_or(&self, rhs: impl IntoExpr) -> ExprResult
a || b (logical_or).Source§fn div(&self, rhs: impl Operand) -> ExprResult
fn div(&self, rhs: impl Operand) -> ExprResult
div: a / b, truncating for integers.Source§fn truncdiv(&self, rhs: impl Operand) -> ExprResult
fn truncdiv(&self, rhs: impl Operand) -> ExprResult
truncdiv.Source§fn truncmod(&self, rhs: impl Operand) -> ExprResult
fn truncmod(&self, rhs: impl Operand) -> ExprResult
truncmod.Source§fn floordiv(&self, rhs: impl Operand) -> ExprResult
fn floordiv(&self, rhs: impl Operand) -> ExprResult
floordiv.Source§fn floormod(&self, rhs: impl Operand) -> ExprResult
fn floormod(&self, rhs: impl Operand) -> ExprResult
floormod.Source§fn indexdiv(&self, rhs: impl Operand) -> ExprResult
fn indexdiv(&self, rhs: impl Operand) -> ExprResult
indexdiv.Source§fn indexmod(&self, rhs: impl Operand) -> ExprResult
fn indexmod(&self, rhs: impl Operand) -> ExprResult
indexmod.Source§fn ceildiv(&self, rhs: impl Operand) -> ExprResult
fn ceildiv(&self, rhs: impl Operand) -> ExprResult
ceildiv.Source§fn min(&self, rhs: impl Operand) -> ExprResult
fn min(&self, rhs: impl Operand) -> ExprResult
min.Source§fn max(&self, rhs: impl Operand) -> ExprResult
fn max(&self, rhs: impl Operand) -> ExprResult
max.Source§fn bitwise_not(&self) -> ExprResult
fn bitwise_not(&self) -> ExprResult
~a (bitwise_not).Source§fn floor(&self) -> ExprResult
fn floor(&self) -> ExprResult
floor.Source§fn ceil(&self) -> ExprResult
fn ceil(&self) -> ExprResult
ceil.Source§fn round(&self) -> ExprResult
fn round(&self) -> ExprResult
round.Source§fn nearbyint(&self) -> ExprResult
fn nearbyint(&self) -> ExprResult
nearbyint.Source§fn trunc(&self) -> ExprResult
fn trunc(&self) -> ExprResult
trunc.Source§fn abs(&self) -> ExprResult
fn abs(&self) -> ExprResult
abs.Source§fn isnan(&self) -> ExprResult
fn isnan(&self) -> ExprResult
isnan.Source§fn isinf(&self) -> ExprResult
fn isinf(&self) -> ExprResult
isinf.Source§fn isfinite(&self) -> ExprResult
fn isfinite(&self) -> ExprResult
isfinite.Source§fn likely(&self) -> ExprResult
fn likely(&self) -> ExprResult
likely.Source§fn assume(&self) -> ExprResult
fn assume(&self) -> ExprResult
assume.Source§fn clz(&self) -> ExprResult
fn clz(&self) -> ExprResult
clz.Source§fn exp(&self) -> ExprResult
fn exp(&self) -> ExprResult
exp.Source§fn exp2(&self) -> ExprResult
fn exp2(&self) -> ExprResult
exp2.Source§fn exp10(&self) -> ExprResult
fn exp10(&self) -> ExprResult
exp10.Source§fn erf(&self) -> ExprResult
fn erf(&self) -> ExprResult
erf.Source§fn sigmoid(&self) -> ExprResult
fn sigmoid(&self) -> ExprResult
sigmoid.Source§fn sqrt(&self) -> ExprResult
fn sqrt(&self) -> ExprResult
sqrt.Source§fn rsqrt(&self) -> ExprResult
fn rsqrt(&self) -> ExprResult
rsqrt.Source§fn log(&self) -> ExprResult
fn log(&self) -> ExprResult
log.Source§fn log2(&self) -> ExprResult
fn log2(&self) -> ExprResult
log2.Source§fn log10(&self) -> ExprResult
fn log10(&self) -> ExprResult
log10.Source§fn log1p(&self) -> ExprResult
fn log1p(&self) -> ExprResult
log1p.Source§fn popcount(&self) -> ExprResult
fn popcount(&self) -> ExprResult
popcount.Source§fn tanh(&self) -> ExprResult
fn tanh(&self) -> ExprResult
tanh.Source§fn tan(&self) -> ExprResult
fn tan(&self) -> ExprResult
tan.Source§fn cos(&self) -> ExprResult
fn cos(&self) -> ExprResult
cos.Source§fn cosh(&self) -> ExprResult
fn cosh(&self) -> ExprResult
cosh.Source§fn sin(&self) -> ExprResult
fn sin(&self) -> ExprResult
sin.Source§fn sinh(&self) -> ExprResult
fn sinh(&self) -> ExprResult
sinh.Source§fn asin(&self) -> ExprResult
fn asin(&self) -> ExprResult
asin.Source§fn acos(&self) -> ExprResult
fn acos(&self) -> ExprResult
acos.Source§fn atan(&self) -> ExprResult
fn atan(&self) -> ExprResult
atan.Source§fn acosh(&self) -> ExprResult
fn acosh(&self) -> ExprResult
acosh.Source§fn asinh(&self) -> ExprResult
fn asinh(&self) -> ExprResult
asinh.Source§fn atanh(&self) -> ExprResult
fn atanh(&self) -> ExprResult
atanh.Source§fn if_then_else(&self, t: impl IntoExpr, f: impl IntoExpr) -> ExprResult
fn if_then_else(&self, t: impl IntoExpr, f: impl IntoExpr) -> ExprResult
Source§impl TryFrom<Expr> for PrimExpr
The view of an expression whose type it accepts; a TypeError names any other.
impl TryFrom<Expr> for PrimExpr
The view of an expression whose type it accepts; a TypeError names any other.
Source§impl TryFrom<ExprResult> for PrimExpr
impl TryFrom<ExprResult> for PrimExpr
Auto Trait Implementations§
impl Freeze for PrimExpr
impl RefUnwindSafe for PrimExpr
impl Send for PrimExpr
impl Sync for PrimExpr
impl Unpin for PrimExpr
impl UnwindSafe for PrimExpr
Blanket Implementations§
Source§impl<T> ArgType for Twhere
T: ObjectRefCore + AnyCompatible + 'static,
impl<T> ArgType for Twhere
T: ObjectRefCore + AnyCompatible + 'static,
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> ObjectRefCast for Twhere
T: ObjectRefCore + AnyCompatible,
impl<T> ObjectRefCast for Twhere
T: ObjectRefCore + AnyCompatible,
Source§fn try_cast<B>(self) -> Result<B, Error>where
B: ObjectRefCore + AnyCompatible,
fn try_cast<B>(self) -> Result<B, Error>where
B: ObjectRefCore + AnyCompatible,
self and rewrap the underlying object as B without copying.