27#include <tvm/ffi/big_int.h>
28#include <tvm/ffi/dtype.h>
29#include <tvm/ffi/error.h>
30#include <tvm/ffi/extra/dataclass.h>
31#include <tvm/ffi/reflection/registry.h>
32#include <tvm/ffi/string.h>
60 explicit Constant(ffi::ObjectPtr<ConstantNode> node) :
Expr(std::move(node)) {}
141 namespace refl = tvm::ffi::reflection;
162 template <
typename Enum, std::enable_if_t<std::is_enum_v<Enum>,
int> = 0>
164 :
IntImm(std::move(value_ty), ffi::BigInt(static_cast<std::underlying_type_t<Enum>>(value)),
185 template <
typename Enum, std::enable_if_t<std::is_enum_v<Enum>,
int> = 0>
199 template <
typename Enum, std::enable_if_t<std::is_enum_v<Enum>,
int> = 0>
221 namespace refl = tvm::ffi::reflection;
257struct TypeTraits<
IntImm> :
public ObjectRefWithFallbackTraitsBase<IntImm, int64_t> {
260 (value > std::numeric_limits<int>::max() || value < std::numeric_limits<int>::min())
263 return IntImm(value_ty, value);
271struct TypeTraits<
FloatImm> :
public ObjectRefWithFallbackTraitsBase<FloatImm, double> {
273 return FloatImm(PrimType::Float(32), value);
277inline constexpr bool use_default_type_traits_v<tvm::StringImm> =
false;
281 :
public ObjectRefWithFallbackTraitsBase<tvm::StringImm, ffi::String> {
293 :
public ObjectRefWithFallbackTraitsBase<PrimExpr, StrictBool, int64_t, double> {
294 using Base = ObjectRefWithFallbackTraitsBase<PrimExpr, StrictBool, int64_t, double>;
296 if (src->type_index == TypeIndex::kTVMFFINone)
return PrimExpr::_type_is_nullable;
297 return TypeTraits<TypedExpr<PrimType>>::CheckAnyStrict(src);
302 if (src->type_index == TypeIndex::kTVMFFINone)
return std::nullopt;
303 return Base::TryCastFromAnyView(src);
306 TVM_FFI_INLINE
static std::string
TypeStr() {
return "ir.PrimExpr"; }
309 return TypeTraits<TypedExpr<PrimType>>::GetMismatchTypeInfo(src);
313 return IntImm::Bool(value);
316 return TypeTraits<IntImm>::ConvertFallbackValue(value);
319 return TypeTraits<FloatImm>::ConvertFallbackValue(value);
327struct TypeTraits<
IntExpr> :
public ObjectRefWithFallbackTraitsBase<IntExpr, int64_t> {
328 using Base = ObjectRefWithFallbackTraitsBase<IntExpr, int64_t>;
331 if (!Base::CheckAnyStrict(src))
return false;
332 if (src->type_index == TypeIndex::kTVMFFINone)
return true;
333 const auto* expr = details::ObjectUnsafe::RawObjectPtrFromUnowned<ExprNode>(src->v_obj);
335 return ty !=
nullptr && ty->
dtype.lanes == 1 &&
336 (ty->dtype.code == kDLInt || ty->dtype.code == kDLUInt);
340 return TypeTraits<PrimExpr>::ConvertFallbackValue(value).as_or_throw<
IntExpr>();
343 TVM_FFI_INLINE
static std::string
TypeStr() {
return "ir.IntExpr"; }
346 return TypeTraits<TypedExpr<PrimType>>::GetMismatchTypeInfo(src);
355struct TypeTraits<
Expr> :
public ObjectRefWithFallbackTraitsBase<Expr, PrimExpr, ffi::String> {
358 static std::optional<Expr> TryCastFromAnyView(
const TVMFFIAny* src);
369 namespace refl = tvm::ffi::reflection;
386 explicit Tuple(ffi::ObjectPtr<TupleNode> node) :
Expr(std::move(node)) {}
393inline std::optional<Expr> ffi::TypeTraits<Expr>::TryCastFromAnyView(
const TVMFFIAny* src) {
395 ObjectRefWithFallbackTraitsBase<Expr, PrimExpr, ffi::String>::TryCastFromAnyView(src)) {
398 if (
auto fields = ffi::TypeTraits<ffi::Array<Expr>>::TryCastFromAnyView(src)) {
416 namespace refl = tvm::ffi::reflection;
417 refl::ObjectDef<TupleGetItemNode>()
454 namespace refl = tvm::ffi::reflection;
455 refl::ObjectDef<TensorLoadNode>()
700 namespace refl = tvm::ffi::reflection;
702 refl::AttachFieldFlag::SEqHashIgnore());
731 explicit Var(ffi::ObjectPtr<VarNode> node) :
Expr(std::move(node)) {}
747 :
PrimExpr(
Var(std::move(name), std::move(dtype), std::move(loc)).as_or_throw<
PrimExpr>()) {}
751 :
PrimExpr(
Var(std::move(name), std::move(type_annotation), std::move(loc))
755 operator Var()
const {
return this->as_or_throw<Var>(); }
796 namespace refl = tvm::ffi::reflection;
797 refl::ObjectDef<LambdaExprNode>()
827 namespace refl = tvm::ffi::reflection;
831 refl::TypeAttrDef<GlobalVarNode>()
837 ffi::TypedFunction<
bool(AnyView, AnyView,
bool, AnyView)>
equal)
const {
841 int64_t
SHash(int64_t init_hash, ffi::TypedFunction<int64_t(AnyView, int64_t,
bool)> hash)
const {
842 return hash(
name_hint, init_hash,
false);
857 explicit GlobalVar(ffi::ObjectPtr<GlobalVarNode> node) :
Expr(std::move(node)) {}
902 switch (side_effect) {
904 return os <<
"kExprAnnotation";
907 return os <<
"kPure";
910 return os <<
"kReadState";
913 return os <<
"kUpdateState";
916 return os <<
"kSpecialCallArg";
919 return os <<
"kEmbedInfo";
922 return os <<
"kControlJump";
925 TVM_FFI_THROW(InternalError) <<
"Unknown CallEffectKind: " <<
static_cast<int>(side_effect);
958 namespace refl = tvm::ffi::reflection;
959 refl::ObjectDef<CallNode>()
978 ffi::Optional<Attrs> attrs = std::nullopt,
991 explicit Call(ffi::ObjectPtr<CallNode> node) :
Expr(std::move(node)) {}
1012 namespace refl = tvm::ffi::reflection;
1013 refl::ObjectDef<RangeNode>()
1016 .def_ro(
"loc", &
RangeNode::loc, refl::AttachFieldFlag::SEqHashIgnore());
1047 explicit Range(ffi::UnsafeInit tag, ffi::ObjectPtr<RangeNode> n) : ffi::ObjectRef(tag) {
1048 data_ = std::move(n);
1066 namespace refl = tvm::ffi::reflection;
1069 refl::ObjectDef<TensorRegionNode>()
1112struct TypeTraits<
TensorRegion> :
public ObjectRefWithFallbackTraitsBase<TensorRegion, TensorLoad> {
1120struct TypeTraits<
PrimVar> :
public ObjectRefTypeTraitsBase<PrimVar> {
1121 using Base = ObjectRefTypeTraitsBase<PrimVar>;
1122 using Base::CopyFromAnyViewAfterCheck;
1123 using Base::CopyToAnyView;
1124 using Base::GetMismatchTypeInfo;
1125 using Base::MoveFromAnyAfterCheck;
1126 using Base::MoveToAny;
1127 using Base::TypeSchema;
1128 using Base::TypeStr;
1131 if (src->type_index == TypeIndex::kTVMFFINone) {
1132 return PrimVar::_type_is_nullable;
1134 if (src->type_index != VarNode::RuntimeTypeIndex()) {
1137 const auto* var =
static_cast<const VarNode*
>(
1138 details::ObjectUnsafe::ObjectPtrFromUnowned<Object>(src->v_obj).get());
1139 return details::AnyUnsafe::CheckAnyStrict<PrimType>(var->ExprNode::ty);
1143 if (CheckAnyStrict(src)) {
1144 if (src->type_index == TypeIndex::kTVMFFINone) {
1145 return details::ObjectUnsafe::ObjectRefFromObjectPtr<PrimVar>(
nullptr);
1147 return details::ObjectUnsafe::ObjectRefFromObjectPtr<PrimVar>(
1148 details::ObjectUnsafe::ObjectPtrFromUnowned<VarNode>(src->v_obj));
1150 return std::nullopt;
1167namespace type_attr {
1188struct std::hash<
tvm::Var> {
1189 std::size_t operator()(
const tvm::Var& var)
const {
return tvm::ffi::ObjectPtrHash()(var); }
1193struct std::equal_to<
tvm::Var> {
1195 return tvm::ffi::ObjectPtrEqual()(var_a, var_b);
1200struct std::hash<
tvm::GlobalVar> {
1201 std::size_t operator()(
const tvm::GlobalVar& var)
const {
return tvm::ffi::ObjectPtrHash()(
var); }
1205struct std::equal_to<
tvm::GlobalVar> {
1207 return tvm::ffi::ObjectPtrEqual()(var_a, var_b);
Helpers for attribute objects.
Base expression and primitive type nodes.
Call corresponds to callable invocation.
Definition expr.h:935
ffi::Optional< Attrs > attrs
The additional attributes.
Definition expr.h:952
ffi::Array< Expr > args
The arguments of the call.
Definition expr.h:949
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.Call", CallNode, ExprNode)
CallNode(ffi::UnsafeInit tag)
Definition expr.h:938
Expr op
The operator/function being invoked.
Definition expr.h:946
static void RegisterReflection()
Definition expr.h:957
CallNode(Expr op)
Definition expr.h:937
ffi::Array< Type > ty_args
The type information arguments passed to the callee.
Definition expr.h:955
Managed reference to CallNode.
Definition expr.h:972
TVM_TIRX_DLL Call(ffi::Optional< Type > ret_ty, Expr op, ffi::Array< Expr > args, ffi::Optional< Attrs > attrs=std::nullopt, ffi::Array< Type > ty_args=ffi::Array< Type >(), Location loc=UnknownLoc())
Construct a Call, inferring only when ret_ty is absent. Construction preserves provisional IR; invoke...
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Call, Expr, CallNode)
Call(ffi::ObjectPtr< CallNode > node)
Definition expr.h:991
TVM_DEFINE_OBJECT_REF_COW_METHOD(CallNode)
TVM_TIRX_DLL void Validate() const
Check this Call against its registered operator contract.
static TVM_TIRX_DLL Type ReinferType(const CallNode *call)
Recompute a result type from the Call's current explicit inputs.
Base node for literal constants.
Definition expr.h:50
static void RegisterReflection()
Definition expr.h:53
TVM_FFI_DECLARE_OBJECT_INFO("ir.Constant", ConstantNode, ExprNode)
static constexpr uint32_t _type_child_slots
Definition expr.h:52
Managed reference to a literal constant.
Definition expr.h:58
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Constant, Expr, ConstantNode)
Constant(ffi::ObjectPtr< ConstantNode > node)
Definition expr.h:60
A data type literal with AnyType as its expression type.
Definition expr.h:110
DLDataType value
Definition expr.h:112
static void RegisterReflection()
Definition expr.h:114
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.DataTypeImm", DataTypeImmNode, ConstantNode)
Managed reference to a data type literal.
Definition expr.h:121
DataTypeImm(ffi::ObjectPtr< DataTypeImmNode > node)
Definition expr.h:125
TVM_TIRX_DLL DataTypeImm(DLDataType value, Location loc=UnknownLoc())
TVM_DEFINE_OBJECT_REF_COW_METHOD(DataTypeImmNode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(DataTypeImm, Constant, DataTypeImmNode)
Base type of all the expressions.
Definition base_expr.h:324
Managed reference to ExprNode.
Definition base_expr.h:359
Constant floating point literals in the program.
Definition expr.h:215
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.FloatImm", FloatImmNode, ConstantNode)
double value
The constant value content.
Definition expr.h:218
static void RegisterReflection()
Definition expr.h:220
Managed reference class to FloatImmNode.
Definition expr.h:232
TVM_TIRX_DLL FloatImm(PrimType value_ty, double value, Location loc=UnknownLoc())
Constructor.
static constexpr bool _type_container_is_exact
Definition expr.h:245
TVM_DEFINE_OBJECT_REF_COW_METHOD(FloatImmNode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(FloatImm, PrimExpr, FloatImmNode)
FloatImm(ffi::ObjectPtr< FloatImmNode > node)
Definition expr.h:242
A constant whose payload is separate from its expression type.
Definition expr.h:66
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.GenericConst", GenericConstNode, ConstantNode)
static void RegisterReflection()
Definition expr.h:70
ffi::Any value
Definition expr.h:68
Managed reference to a generic constant.
Definition expr.h:77
TVM_DEFINE_OBJECT_REF_COW_METHOD(GenericConstNode)
GenericConst(ffi::ObjectPtr< GenericConstNode > node)
Definition expr.h:81
TVM_TIRX_DLL GenericConst(ffi::Any value, Type ty, Location loc=UnknownLoc())
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(GenericConst, Constant, GenericConstNode)
Global variable that lives in the top-level module.
Definition expr.h:821
int64_t SHash(int64_t init_hash, ffi::TypedFunction< int64_t(AnyView, int64_t, bool)> hash) const
Definition expr.h:841
ffi::String name_hint
The name of the variable, this only acts as a hint.
Definition expr.h:824
static void RegisterReflection()
Definition expr.h:826
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.GlobalVar", GlobalVarNode, ExprNode)
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition expr.h:845
bool SEqual(const GlobalVarNode *other, ffi::TypedFunction< bool(AnyView, AnyView, bool, AnyView)> equal) const
Definition expr.h:836
Managed reference to GlobalVarNode.
Definition expr.h:853
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(GlobalVar, Expr, GlobalVarNode)
TVM_DEFINE_OBJECT_REF_COW_METHOD(GlobalVarNode)
GlobalVar(ffi::ObjectPtr< GlobalVarNode > node)
Definition expr.h:857
TVM_TIRX_DLL GlobalVar(ffi::String name_hint, Location loc=UnknownLoc())
View over a scalar signed or unsigned integer expression of any bit width.
Definition base_expr.h:481
Constant integer literals in the program.
Definition expr.h:135
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.IntImm", IntImmNode, ConstantNode)
static void RegisterReflection()
Definition expr.h:140
ffi::BigInt value
the Internal value.
Definition expr.h:138
Managed reference class to IntImmNode.
Definition expr.h:152
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(IntImm, PrimExpr, IntImmNode)
static constexpr bool _type_container_is_exact
Definition expr.h:207
static IntImm Int64(ffi::BigInt value, Location loc=UnknownLoc())
Construct a scalar int64 constant.
Definition expr.h:195
TVM_TIRX_DLL IntImm(PrimType value_ty, ffi::BigInt value, Location loc=UnknownLoc())
Constructor.
TVM_DEFINE_OBJECT_REF_COW_METHOD(IntImmNode)
static IntImm Bool(bool value, Location loc=UnknownLoc())
Construct a scalar boolean constant.
Definition expr.h:172
IntImm(PrimType value_ty, Enum value, Location loc=UnknownLoc())
Definition expr.h:163
IntImm(ffi::ObjectPtr< IntImmNode > node)
Definition expr.h:204
static IntImm Int32(Enum value, Location loc=UnknownLoc())
Definition expr.h:186
static IntImm Int64(Enum value, Location loc=UnknownLoc())
Definition expr.h:200
static IntImm Int32(ffi::BigInt value, Location loc=UnknownLoc())
Construct a scalar int32 constant.
Definition expr.h:181
A typed staging expression representing a lambda computation.
Definition expr.h:783
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.LambdaExpr", LambdaExprNode, StagingExprNode)
Expr body
Computation over the parameters and captured expressions.
Definition expr.h:788
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition expr.h:801
TVM_TIRX_DLL Expr Apply(const ffi::Array< Expr > &arguments) const
Simultaneously substitute arguments for the bound parameters.
LambdaExprNode(ffi::UnsafeInit tag)
Definition expr.h:790
static void RegisterReflection()
Definition expr.h:795
ffi::Array< Var > vars
Lambda-local parameter definitions.
Definition expr.h:786
LambdaExprNode(Expr body)
Definition expr.h:791
Managed reference to a typed staging lambda.
Definition expr.h:806
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(LambdaExpr, StagingExpr, LambdaExprNode)
TVM_TIRX_DLL LambdaExpr(ffi::Array< Var > vars, Expr body)
Non-nullable source-location metadata.
Definition location.h:91
Typed reference/view over any Expr whose ExprNode::ty is PrimType.
Definition base_expr.h:447
Primitive data types used in the low-level IR.
Definition base_expr.h:143
DLDataType dtype
The raw DLPack dtype represented by this primitive type.
Definition base_expr.h:148
Definition base_expr.h:161
static TVM_TIRX_DLL PrimType Bool(int lanes=1)
Construct a boolean type with fixed lanes.
static TVM_TIRX_DLL PrimType Int(int bits, int lanes=1)
Construct a signed integer type with fixed lanes.
Checked scalar view over a VarNode.
Definition expr.h:742
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(PrimVar, PrimExpr, VarNode)
static constexpr bool _type_container_is_exact
Definition expr.h:767
PrimVar(ffi::ObjectPtr< VarNode > node)
Definition expr.h:764
PrimVar(ffi::String name, PrimType dtype=PrimType::Int(32), Location loc=UnknownLoc())
Construct a scalar variable directly from a primitive type.
Definition expr.h:745
PrimVar CopyWithDType(PrimType dtype) const
Definition expr.h:760
PrimVar CopyWithSuffix(const ffi::String &suffix) const
Definition expr.h:757
PrimVar(ffi::String name, Type type_annotation, Location loc=UnknownLoc())
Construct a scalar variable directly from a checked type annotation.
Definition expr.h:750
range over one dimension
Definition expr.h:998
static void RegisterReflection()
Definition expr.h:1011
PrimExpr min
beginning of the node
Definition expr.h:1001
RangeNode(PrimExpr min, PrimExpr extent, Location loc=UnknownLoc())
Definition expr.h:1008
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.Range", RangeNode, ffi::Object)
RangeNode(ffi::UnsafeInit tag)
constructor
Definition expr.h:1007
PrimExpr extent
the extend of range
Definition expr.h:1003
Location loc
the location of this range in the source
Definition expr.h:1005
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition expr.h:1019
Range container
Definition expr.h:1025
Range(ffi::UnsafeInit tag, ffi::ObjectPtr< RangeNode > n)
Definition expr.h:1047
static TVM_TIRX_DLL Range FromMinExtent(PrimExpr min, PrimExpr extent, Location loc=UnknownLoc())
construct a new range with min and extent The corresponding constructor is removed,...
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Range, ffi::ObjectRef, RangeNode)
TVM_TIRX_DLL Range(PrimExpr begin, PrimExpr end, Location loc=UnknownLoc())
constructor by begin and end
Base node for traversable expressions eliminated during compilation.
Definition base_expr.h:375
Managed reference to a staging expression.
Definition base_expr.h:383
A string literal with shared semantic StringType.
Definition expr.h:88
ffi::String value
Definition expr.h:90
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.StringImm", StringImmNode, ConstantNode)
static void RegisterReflection()
Definition expr.h:92
Managed reference to a string literal.
Definition expr.h:99
TVM_DEFINE_OBJECT_REF_COW_METHOD(StringImmNode)
TVM_TIRX_DLL StringImm(ffi::String value, Location loc=UnknownLoc())
StringImm(ffi::ObjectPtr< StringImmNode > node)
Definition expr.h:103
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(StringImm, Constant, StringImmNode)
Load a value from an indexed expression source.
Definition expr.h:443
TensorLoadNode(Expr source)
Definition expr.h:445
ffi::Array< PrimExpr > indices
The indices at which the source is loaded.
Definition expr.h:451
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.TensorLoad", TensorLoadNode, ExprNode)
TensorLoadNode(ffi::UnsafeInit tag)
Definition expr.h:446
Expr source
The indexed source expression.
Definition expr.h:449
static void RegisterReflection()
Definition expr.h:453
Managed reference to TensorLoadNode.
Definition expr.h:464
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(TensorLoad, PrimExpr, TensorLoadNode)
static constexpr bool _type_container_is_exact
Definition expr.h:469
TensorLoad(ffi::ObjectPtr< TensorLoadNode > node)
Definition expr.h:466
TVM_DEFINE_OBJECT_REF_COW_METHOD(TensorLoadNode)
A region of an indexed expression source.
Definition expr.h:1055
TensorRegionNode(ffi::UnsafeInit tag)
Definition expr.h:1058
Expr source
The indexed source expression.
Definition expr.h:1061
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.TensorRegion", TensorRegionNode, ExprNode)
TensorRegionNode(Expr source)
Definition expr.h:1057
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition expr.h:1074
ffi::Array< Range > region
The ranges selected from the source.
Definition expr.h:1063
static void RegisterReflection()
Definition expr.h:1065
Managed reference to TensorRegionNode.
Definition expr.h:1079
TVM_TIRX_DLL TensorRegion(Expr source, ffi::Array< Range > region, Type ty, Location loc=UnknownLoc())
TVM_DEFINE_OBJECT_REF_COW_METHOD(TensorRegionNode)
TensorRegion(ffi::ObjectPtr< TensorRegionNode > node)
Definition expr.h:1084
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(TensorRegion, Expr, TensorRegionNode)
Get the index-th field out of a tuple.
Definition expr.h:405
TupleGetItemNode(Expr tuple)
Definition expr.h:407
Expr tuple
The tuple expression.
Definition expr.h:411
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.TupleGetItem", TupleGetItemNode, ExprNode)
static void RegisterReflection()
Definition expr.h:415
TupleGetItemNode(ffi::UnsafeInit tag)
Definition expr.h:408
int index
The field index.
Definition expr.h:413
Managed reference to TupleGetItemNode.
Definition expr.h:426
TupleGetItem(ffi::ObjectPtr< TupleGetItemNode > node)
Definition expr.h:436
TVM_DEFINE_OBJECT_REF_COW_METHOD(TupleGetItemNode)
TVM_TIRX_DLL TupleGetItem(Expr tuple, int index, Location loc=UnknownLoc())
Construct a tuple field projection.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(TupleGetItem, Expr, TupleGetItemNode)
Tuple container.
Definition expr.h:363
ffi::Array< Expr > fields
The fields of the tuple.
Definition expr.h:366
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.Tuple", TupleNode, ExprNode)
static void RegisterReflection()
Definition expr.h:368
Managed reference to TupleNode.
Definition expr.h:377
TVM_TIRX_DLL Tuple(ffi::Array< Expr > fields, Location loc=UnknownLoc())
Construct a tuple from its fields.
TVM_DEFINE_OBJECT_REF_COW_METHOD(TupleNode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Tuple, Expr, TupleNode)
Tuple(ffi::ObjectPtr< TupleNode > node)
Definition expr.h:386
Managed reference to TypeNode.
Definition base_expr.h:80
Reference to the shared immutable unknown location.
Definition location.h:105
A local variable in the IR.
Definition expr.h:694
TVM_FFI_DECLARE_OBJECT_INFO("ir.Var", VarNode, ExprNode)
static constexpr const uint32_t _type_child_slots
Definition expr.h:706
static constexpr bool _type_child_slots_can_overflow
Definition expr.h:709
ffi::String name
The variable name.
Definition expr.h:697
static void RegisterReflection()
Definition expr.h:699
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition expr.h:705
Managed reference to VarNode.
Definition expr.h:714
TVM_TIRX_DLL Var CopyWithDType(PrimType dtype) const
Return a fresh ordinary Var with a new primitive type.
TVM_TIRX_DLL Var(ffi::String name, ffi::Optional< Type > ty_annotation, Location loc=UnknownLoc())
TVM_TIRX_DLL Var CopyWithType(Type type) const
Return a fresh ordinary Var with a new type, retaining its metadata.
TVM_TIRX_DLL Var CopyWithSuffix(const ffi::String &suffix) const
Return a fresh ordinary Var with a suffix appended to its name.
Var(ffi::ObjectPtr< VarNode > node)
Definition expr.h:731
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Var, Expr, VarNode)
TVM_TIRX_DLL Var CopyWithName(const ffi::String &name) const
Return a fresh ordinary Var with the same type and a new name.
Copy-on-write helper macro for IR ffi::ObjectRef types.
Source locations and source-text lookup.
constexpr bool use_default_type_traits_v< PrimVar >
Definition expr.h:1117
constexpr bool use_default_type_traits_v< Expr >
Definition expr.h:352
constexpr bool use_default_type_traits_v< PrimExpr >
Definition expr.h:289
constexpr bool use_default_type_traits_v< TensorRegion >
Definition expr.h:1109
constexpr bool object_ref_contains_v< PrimExpr, IntImmNode >
Definition expr.h:1155
constexpr bool object_ref_contains_v< PrimExpr, TensorLoadNode >
Definition expr.h:1159
constexpr bool use_default_type_traits_v< IntExpr >
Definition expr.h:324
constexpr bool object_ref_contains_v< PrimExpr, FloatImmNode >
Definition expr.h:1157
constexpr bool use_default_type_traits_v< FloatImm >
Definition expr.h:268
constexpr bool use_default_type_traits_v< IntImm >
Definition expr.h:253
constexpr const char * kCallEffectKind
Definition expr.h:1164
PrimVar var(std::string name_hint, PrimType t=PrimType::Int(32))
Construct a new Var expression.
constexpr const char * kSubscriptExprRealize
Definition expr.h:1168
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition attr.h:23
TVM_TIRX_DLL CallEffectKind SideEffect(const Expr &expr)
Analyze the runtime effects of an expression.
int64_t TCallEffectKind
Use integer to record the kind.
Definition expr.h:930
TVM_TIRX_DLL PrimExpr operator<(PrimExpr a, PrimExpr b)
less
TVM_TIRX_DLL PrimExpr operator!(PrimExpr a)
not
TVM_TIRX_DLL PrimExpr min(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
take minimum of two values
TVM_TIRX_DLL PrimExpr operator<=(PrimExpr a, PrimExpr b)
less_equal
bool operator!=(const PrimType &lhs, const PrimType &rhs)
Definition base_expr.h:318
TVM_TIRX_DLL PrimExpr operator~(PrimExpr a)
take bitwise negation of two values
TVM_TIRX_DLL PrimExpr operator>=(PrimExpr a, PrimExpr b)
greater_equal
TVM_TIRX_DLL PrimExpr operator+(PrimExpr a, PrimExpr b)
add operator
TVM_TIRX_DLL PrimExpr operator>(PrimExpr a, PrimExpr b)
greater
TVM_TIRX_DLL PrimExpr equal(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
equal
TVM_TIRX_DLL PrimExpr operator/(PrimExpr a, PrimExpr b)
division operator
TVM_TIRX_DLL PrimExpr operator||(PrimExpr a, PrimExpr b)
or
TVM_TIRX_DLL PrimExpr operator^(PrimExpr a, PrimExpr b)
take bitwise xor of two values
TVM_TIRX_DLL PrimExpr operator&(PrimExpr a, PrimExpr b)
take bitwise and of two values
CallEffectKind
The effect type of the call.
Definition expr.h:866
@ kControlJump
Function that changes control flow.
@ kOpaque
Opaque function, cannot make any assumption.
@ kExprAnnotation
Function corresponds to an annotation(e.g. likely) and can translate to identity.
@ kPure
Pure function that do not interacts with any external state.
@ kReadState
Function's that may read from states(e.g. RAM)
@ kEmbedInfo
Embed opaque information in the Expr, cannot be codegen.
@ kSpecialCallArg
Special intrinsic to annotate call arguments info only valid as a direct argument to a call.
@ kUpdateState
Function that may read/write from states(e.g. RAM).
TVM_TIRX_DLL PrimExpr operator>>(PrimExpr a, PrimExpr b)
right shift operator
bool operator==(const PrimType &lhs, const PrimType &rhs)
Definition base_expr.h:314
TVM_TIRX_DLL PrimExpr operator|(PrimExpr a, PrimExpr b)
take bitwise or of two values
TVM_TIRX_DLL PrimExpr operator&&(PrimExpr a, PrimExpr b)
and
TVM_TIRX_DLL PrimExpr operator*(PrimExpr a, PrimExpr b)
multiplication operator
TVM_TIRX_DLL PrimExpr operator<<(PrimExpr a, PrimExpr b)
left shift operator
TVM_TIRX_DLL PrimExpr operator-(PrimExpr a, PrimExpr b)
subtraction operator
#define TVM_TIRX_DLL
Definition base.h:83
static TVM_FFI_INLINE Expr ConvertFallbackValue(PrimExpr value)
Definition expr.h:356
static TVM_FFI_INLINE Expr ConvertFallbackValue(ffi::String value)
Definition expr.h:357
static TVM_FFI_INLINE FloatImm ConvertFallbackValue(double value)
Definition expr.h:272
static TVM_FFI_INLINE IntExpr ConvertFallbackValue(int64_t value)
Definition expr.h:339
static TVM_FFI_INLINE std::string GetMismatchTypeInfo(const TVMFFIAny *src)
Definition expr.h:345
static TVM_FFI_INLINE std::string TypeStr()
Definition expr.h:343
ObjectRefWithFallbackTraitsBase< IntExpr, int64_t > Base
Definition expr.h:328
static TVM_FFI_INLINE bool CheckAnyStrict(const TVMFFIAny *src)
Definition expr.h:330
static TVM_FFI_INLINE IntImm ConvertFallbackValue(int64_t value)
Definition expr.h:258
static TVM_FFI_INLINE PrimExpr ConvertFallbackValue(int64_t value)
Definition expr.h:315
static TVM_FFI_INLINE std::string GetMismatchTypeInfo(const TVMFFIAny *src)
Definition expr.h:308
static TVM_FFI_INLINE PrimExpr ConvertFallbackValue(double value)
Definition expr.h:318
static TVM_FFI_INLINE bool CheckAnyStrict(const TVMFFIAny *src)
Definition expr.h:295
ObjectRefWithFallbackTraitsBase< PrimExpr, StrictBool, int64_t, double > Base
Definition expr.h:294
static TVM_FFI_INLINE PrimExpr ConvertFallbackValue(StrictBool value)
Definition expr.h:312
static TVM_FFI_INLINE std::string TypeStr()
Definition expr.h:306
static TVM_FFI_INLINE std::optional< PrimExpr > TryCastFromAnyView(const TVMFFIAny *src)
Definition expr.h:300
static TVM_FFI_INLINE std::optional< PrimVar > TryCastFromAnyView(const TVMFFIAny *src)
Definition expr.h:1142
static TVM_FFI_INLINE bool CheckAnyStrict(const TVMFFIAny *src)
Definition expr.h:1130
ObjectRefTypeTraitsBase< PrimVar > Base
Definition expr.h:1121
static TVM_TIRX_DLL TensorRegion ConvertFallbackValue(TensorLoad value)
static TVM_FFI_INLINE tvm::StringImm ConvertFallbackValue(ffi::String value)
Definition expr.h:282