27#include <tvm/ffi/big_int.h>
28#include <tvm/ffi/cast.h>
29#include <tvm/ffi/container/array.h>
30#include <tvm/ffi/container/tuple.h>
31#include <tvm/ffi/container/variant.h>
32#include <tvm/ffi/dtype.h>
33#include <tvm/ffi/error.h>
34#include <tvm/ffi/extra/dataclass.h>
35#include <tvm/ffi/extra/structural_equal.h>
36#include <tvm/ffi/extra/structural_hash.h>
37#include <tvm/ffi/extra/structural_mutate.h>
38#include <tvm/ffi/extra/structural_visit.h>
39#include <tvm/ffi/function.h>
40#include <tvm/ffi/optional.h>
41#include <tvm/ffi/reflection/native_function.h>
42#include <tvm/ffi/reflection/registry.h>
43#include <tvm/ffi/string.h>
83 namespace refl = tvm::ffi::reflection;
85 refl::ObjectDef<ExprObj>()
87 refl::AttachFieldFlag::SEqHashIgnore())
101class Expr :
public ffi::ObjectRef {
109 explicit Expr(ffi::ObjectPtr<ExprObj> node) : ffi::ObjectRef(std::move(node)) {
110 TVM_FFI_CHECK(defined(), ValueError) <<
"Expr expects a defined node";
139 namespace refl = tvm::ffi::reflection;
140 refl::ObjectDef<OpaqueExprObj>();
150 explicit OpaqueExpr(ffi::ObjectPtr<OpaqueExprObj> node) :
Expr(std::move(node)) {}
160template <
typename ExpectedType>
164 ExpectedType
ty()
const {
165 const auto* node = get();
166 TVM_FFI_DCHECK(node !=
nullptr);
167 const auto* ty_node = node->ExprObj::ty.template as<typename ExpectedType::ContainerType>();
168 TVM_FFI_DCHECK(ty_node !=
nullptr);
169 return ffi::GetRef<ExpectedType>(ty_node);
220namespace ffi::detail {
239 explicit Constant(ffi::ObjectPtr<ConstantObj> node) :
Expr(std::move(node)) {}
320 namespace refl = tvm::ffi::reflection;
341 template <
typename Enum, std::enable_if_t<std::is_enum_v<Enum>,
int> = 0>
343 :
IntImm(std::move(value_ty), ffi::BigInt(static_cast<std::underlying_type_t<Enum>>(value)),
364 template <
typename Enum, std::enable_if_t<std::is_enum_v<Enum>,
int> = 0>
378 template <
typename Enum, std::enable_if_t<std::is_enum_v<Enum>,
int> = 0>
400 namespace refl = tvm::ffi::reflection;
435 namespace refl = tvm::ffi::reflection;
452 explicit Tuple(ffi::ObjectPtr<TupleObj> node) :
Expr(std::move(node)) {}
470 namespace refl = tvm::ffi::reflection;
471 refl::ObjectDef<TupleGetItemObj>()
508 namespace refl = tvm::ffi::reflection;
509 refl::ObjectDef<TensorLoadObj>()
522inline constexpr ffi::reflection::AttrKey<
558 namespace refl = tvm::ffi::reflection;
559 refl::ObjectDef<VarObj>().def_ro(
"name", &
VarObj::name, refl::AttachFieldFlag::SEqHashIgnore());
587 explicit Var(ffi::ObjectPtr<VarObj> node) :
Expr(std::move(node)) {}
603 :
PrimExpr(
Var(std::move(name), std::move(dtype), std::move(loc)).as_or_throw<
PrimExpr>()) {}
607 :
PrimExpr(
Var(std::move(name), std::move(type_annotation), std::move(loc))
611 operator Var()
const {
return this->as_or_throw<Var>(); }
652 namespace refl = tvm::ffi::reflection;
653 refl::ObjectDef<LambdaExprObj>()
683 namespace refl = tvm::ffi::reflection;
687 refl::TypeAttrDef<GlobalVarObj>()
693 ffi::TypedFunction<
bool(AnyView, AnyView,
bool, AnyView)>
equal)
const {
697 int64_t
SHash(int64_t init_hash, ffi::TypedFunction<int64_t(AnyView, int64_t,
bool)> hash)
const {
698 return hash(
name_hint, init_hash,
false);
713 explicit GlobalVar(ffi::ObjectPtr<GlobalVarObj> node) :
Expr(std::move(node)) {}
758 switch (side_effect) {
760 return os <<
"kExprAnnotation";
763 return os <<
"kPure";
766 return os <<
"kReadState";
769 return os <<
"kUpdateState";
772 return os <<
"kSpecialCallArg";
775 return os <<
"kEmbedInfo";
778 return os <<
"kControlJump";
781 TVM_FFI_THROW(InternalError) <<
"Unknown CallEffectKind: " <<
static_cast<int>(side_effect);
811 namespace refl = tvm::ffi::reflection;
812 refl::ObjectDef<CallObj>()
831 ffi::Optional<Attrs> attrs = std::nullopt,
844 explicit Call(ffi::ObjectPtr<CallObj> node) :
Expr(std::move(node)) {}
852inline constexpr ffi::reflection::AttrKey<CallEffectKind>
kCallEffectKind{
"TCallEffectKind"};
870 namespace refl = tvm::ffi::reflection;
871 refl::ObjectDef<RangeObj>()
874 .def_ro(
"loc", &
RangeObj::loc, refl::AttachFieldFlag::SEqHashIgnore());
883class Range :
public ffi::ObjectRef {
912 explicit Range(ffi::UnsafeInit tag, ffi::ObjectPtr<RangeObj> n) : ffi::ObjectRef(tag) {
913 data_ = std::move(n);
931 namespace refl = tvm::ffi::reflection;
934 refl::ObjectDef<TensorRegionObj>()
981inline constexpr bool use_default_type_traits_v<tvm::StringImm> =
false;
985 :
public ObjectRefWithFallbackTraitsBase<tvm::StringImm, ffi::String> {
995struct TypeTraits<
IntImm> :
public ObjectRefWithFallbackTraitsBase<IntImm, int64_t> {
998 (value > std::numeric_limits<int>::max() || value < std::numeric_limits<int>::min())
1000 : PrimType::Int(32);
1001 return IntImm(value_ty, value);
1012struct TypeTraits<
FloatImm> :
public ObjectRefWithFallbackTraitsBase<FloatImm, double> {
1014 return FloatImm(PrimType::Float(32), value);
1024template <
typename ExpectedType>
1025inline constexpr bool use_default_type_traits_v<TypedExpr<ExpectedType>> =
false;
1027template <
typename ExpectedType>
1029 :
public ObjectRefTypeTraitsBase<TypedExpr<ExpectedType>> {
1031 if (src->type_index < TypeIndex::kTVMFFIStaticObjectBegin ||
1032 !detail::IsObjectInstance<ExprObj>(src->type_index)) {
1037 const auto* expr = detail::ObjectUnsafe::RawObjectPtrFromUnowned<ExprObj>(src->v_obj);
1038 return detail::AnyUnsafe::CheckAnyViewStrict<ExpectedType>(expr->ty);
1042 if (src->type_index >= TypeIndex::kTVMFFIStaticObjectBegin && src->v_obj !=
nullptr &&
1043 detail::IsObjectInstance<ExprObj>(src->type_index)) {
1044 const auto* expr = detail::ObjectUnsafe::RawObjectPtrFromUnowned<ExprObj>(src->v_obj);
1045 if (expr->ty.defined()) {
1048 prim_ty ? std::string(ffi::DLDataTypeToString(prim_ty->dtype)) : expr->ty.GetTypeKey();
1049 return TypeIndexToTypeKey(src->type_index) +
"[ty=" + ty +
"]";
1052 return TypeTraitsBase::GetMismatchTypeInfo(src);
1062 :
public ObjectRefWithFallbackTraitsBase<PrimExpr, StrictBool, int64_t, double> {
1064 return TypeTraits<TypedExpr<PrimType>>::CheckAnyStrict(src);
1067 TVM_FFI_INLINE
static std::string
TypeStr() {
return "ir.PrimExpr"; }
1070 return TypeTraits<TypedExpr<PrimType>>::GetMismatchTypeInfo(src);
1074 return IntImm::Bool(value);
1077 return TypeTraits<IntImm>::ConvertFallbackValue(value);
1080 return TypeTraits<FloatImm>::ConvertFallbackValue(value);
1089struct TypeTraits<
Expr> :
public ObjectRefWithFallbackTraitsBase<Expr, PrimExpr, ffi::String> {
1096 ObjectRefWithFallbackTraitsBase<Expr, PrimExpr, ffi::String>::TryCastFromAnyView(src)) {
1099 if (
auto fields = TypeTraits<ffi::Array<Expr>>::TryCastFromAnyView(src)) {
1102 return std::nullopt;
1110struct TypeTraits<
IntExpr> :
public ObjectRefWithFallbackTraitsBase<IntExpr, int64_t> {
1111 using Base = ObjectRefWithFallbackTraitsBase<IntExpr, int64_t>;
1114 if (!Base::CheckAnyStrict(src))
return false;
1115 const auto* expr = detail::ObjectUnsafe::RawObjectPtrFromUnowned<ExprObj>(src->v_obj);
1117 return ty !=
nullptr && ty->
dtype.lanes == 1 &&
1118 (ty->dtype.code == kDLInt || ty->dtype.code == kDLUInt);
1122 return TypeTraits<PrimExpr>::ConvertFallbackValue(value).as_or_throw<
IntExpr>();
1125 TVM_FFI_INLINE
static std::string
TypeStr() {
return "ir.IntExpr"; }
1128 return TypeTraits<TypedExpr<PrimType>>::GetMismatchTypeInfo(src);
1136struct TypeTraits<
PrimVar> :
public ObjectRefTypeTraitsBase<PrimVar> {
1137 using Base = ObjectRefTypeTraitsBase<PrimVar>;
1140 if (!Base::CheckAnyStrict(src))
return false;
1141 const auto* var = detail::ObjectUnsafe::RawObjectPtrFromUnowned<VarObj>(src->v_obj);
1150struct TypeTraits<
TensorRegion> :
public ObjectRefWithFallbackTraitsBase<TensorRegion, TensorLoad> {
1152 return TensorRegion::FromTensorLoad(std::move(value));
1160 ffi::Tuple<ffi::Optional<PrimExpr>, ffi::Optional<PrimExpr>, ffi::Optional<PrimExpr>>,
1163namespace type_attr {
1170inline constexpr ffi::reflection::AttrKey<
1192struct std::hash<
tvm::Var> {
1193 std::size_t operator()(
const tvm::Var& var)
const {
return tvm::ffi::ObjectPtrHash()(
var); }
1197struct std::equal_to<
tvm::Var> {
1199 return tvm::ffi::ObjectPtrEqual()(var_a, var_b);
1204struct std::hash<
tvm::GlobalVar> {
1205 std::size_t operator()(
const tvm::GlobalVar& var)
const {
return tvm::ffi::ObjectPtrHash()(
var); }
1209struct std::equal_to<
tvm::GlobalVar> {
1211 return tvm::ffi::ObjectPtrEqual()(var_a, var_b);
IR/AST nodes for TVM types shared across IR variants.
#define TVM_TIRX_DLL
Definition base.h:55
Helpers for attribute objects.
Call corresponds to callable invocation.
Definition expr.h:788
Expr op
The operator/function being invoked.
Definition expr.h:799
ffi::Array< Type > ty_args
The type information arguments passed to the callee.
Definition expr.h:808
CallObj(Expr op)
Definition expr.h:790
ffi::Optional< Attrs > attrs
The additional attributes.
Definition expr.h:805
ffi::Array< Expr > args
The arguments of the call.
Definition expr.h:802
CallObj(ffi::UnsafeInit tag)
Definition expr.h:791
static void RegisterReflection()
Definition expr.h:810
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.Call", CallObj, ExprObj)
Managed reference to CallObj.
Definition expr.h:825
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...
static TVM_TIRX_DLL Type ReinferType(const CallObj *call)
Recompute a result type from the Call's current explicit inputs.
TVM_DEFINE_OBJECT_REF_COW_METHOD(CallObj)
Call(ffi::ObjectPtr< CallObj > node)
Definition expr.h:844
TVM_TIRX_DLL void Validate() const
Check this Call against its registered operator contract.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Call, Expr, CallObj)
Base node for literal constants.
Definition expr.h:229
static constexpr uint32_t _type_child_slots
Definition expr.h:231
TVM_FFI_DECLARE_OBJECT_INFO("ir.Constant", ConstantObj, ExprObj)
static void RegisterReflection()
Definition expr.h:232
Managed reference to a literal constant.
Definition expr.h:237
Constant(ffi::ObjectPtr< ConstantObj > node)
Definition expr.h:239
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Constant, Expr, ConstantObj)
A data type literal with AnyType as its expression type.
Definition expr.h:289
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.DataTypeImm", DataTypeImmObj, ConstantObj)
DLDataType value
Definition expr.h:291
static void RegisterReflection()
Definition expr.h:293
Managed reference to a data type literal.
Definition expr.h:300
TVM_TIRX_DLL DataTypeImm(DLDataType value, Location loc=UnknownLoc())
DataTypeImm(ffi::ObjectPtr< DataTypeImmObj > node)
Definition expr.h:304
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(DataTypeImm, Constant, DataTypeImmObj)
TVM_DEFINE_OBJECT_REF_COW_METHOD(DataTypeImmObj)
Base type of all the expressions.
Definition expr.h:66
Type ty
The deduced or annotated type of the expression.
Definition expr.h:80
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition expr.h:91
static void RegisterReflection()
Definition expr.h:82
TVM_FFI_DECLARE_OBJECT_INFO("ir.Expr", ExprObj, ffi::Object)
Location loc
Location that points to the original source code. Reserved debug information.
Definition expr.h:72
static constexpr const uint32_t _type_child_slots
Definition expr.h:93
Managed reference to ExprObj.
Definition expr.h:101
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Expr, ffi::ObjectRef, ExprObj)
bool operator==(const Expr &other) const =delete
bool operator!=(const Expr &other) const =delete
Expr(ffi::ObjectPtr< ExprObj > node)
Definition expr.h:109
bool operator<(const Expr &other) const =delete
Constant floating point literals in the program.
Definition expr.h:394
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.FloatImm", FloatImmObj, ConstantObj)
static void RegisterReflection()
Definition expr.h:399
double value
The constant value content.
Definition expr.h:397
Managed reference class to FloatImmObj.
Definition expr.h:411
TVM_TIRX_DLL FloatImm(PrimType value_ty, double value, Location loc=UnknownLoc())
Constructor.
static constexpr bool _type_container_is_exact
Definition expr.h:424
FloatImm(ffi::ObjectPtr< FloatImmObj > node)
Definition expr.h:421
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(FloatImm, PrimExpr, FloatImmObj)
TVM_DEFINE_OBJECT_REF_COW_METHOD(FloatImmObj)
A constant whose payload is separate from its expression type.
Definition expr.h:245
ffi::Any value
Definition expr.h:247
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.GenericConst", GenericConstObj, ConstantObj)
static void RegisterReflection()
Definition expr.h:249
Managed reference to a generic constant.
Definition expr.h:256
TVM_TIRX_DLL GenericConst(Type ty, ffi::Any value, Location loc=UnknownLoc())
TVM_DEFINE_OBJECT_REF_COW_METHOD(GenericConstObj)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(GenericConst, Constant, GenericConstObj)
GenericConst(ffi::ObjectPtr< GenericConstObj > node)
Definition expr.h:260
Global variable that lives in the top-level module.
Definition expr.h:677
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.GlobalVar", GlobalVarObj, ExprObj)
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition expr.h:701
static void RegisterReflection()
Definition expr.h:682
bool SEqual(const GlobalVarObj *other, ffi::TypedFunction< bool(AnyView, AnyView, bool, AnyView)> equal) const
Definition expr.h:692
ffi::String name_hint
The name of the variable, this only acts as a hint.
Definition expr.h:680
int64_t SHash(int64_t init_hash, ffi::TypedFunction< int64_t(AnyView, int64_t, bool)> hash) const
Definition expr.h:697
Managed reference to GlobalVarObj.
Definition expr.h:709
GlobalVar(ffi::ObjectPtr< GlobalVarObj > node)
Definition expr.h:713
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(GlobalVar, Expr, GlobalVarObj)
TVM_DEFINE_OBJECT_REF_COW_METHOD(GlobalVarObj)
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 expr.h:214
static constexpr bool _type_container_is_exact
Definition expr.h:217
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(IntExpr, PrimExpr, ExprObj)
Constant integer literals in the program.
Definition expr.h:314
ffi::BigInt value
the Internal value.
Definition expr.h:317
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.IntImm", IntImmObj, ConstantObj)
static void RegisterReflection()
Definition expr.h:319
Managed reference class to IntImmObj.
Definition expr.h:331
static constexpr bool _type_container_is_exact
Definition expr.h:386
static IntImm Int64(ffi::BigInt value, Location loc=UnknownLoc())
Construct a scalar int64 constant.
Definition expr.h:374
TVM_DEFINE_OBJECT_REF_COW_METHOD(IntImmObj)
IntImm(ffi::ObjectPtr< IntImmObj > node)
Definition expr.h:383
TVM_TIRX_DLL IntImm(PrimType value_ty, ffi::BigInt value, Location loc=UnknownLoc())
Constructor.
static IntImm Bool(bool value, Location loc=UnknownLoc())
Construct a scalar boolean constant.
Definition expr.h:351
IntImm(PrimType value_ty, Enum value, Location loc=UnknownLoc())
Definition expr.h:342
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(IntImm, PrimExpr, IntImmObj)
static IntImm Int32(Enum value, Location loc=UnknownLoc())
Definition expr.h:365
static IntImm Int64(Enum value, Location loc=UnknownLoc())
Definition expr.h:379
static IntImm Int32(ffi::BigInt value, Location loc=UnknownLoc())
Construct a scalar int32 constant.
Definition expr.h:360
A typed staging expression representing a lambda computation.
Definition expr.h:639
LambdaExprObj(Expr body)
Definition expr.h:647
TVM_TIRX_DLL Expr Apply(const ffi::Array< Expr > &arguments) const
Simultaneously substitute arguments for the bound parameters.
LambdaExprObj(ffi::UnsafeInit tag)
Definition expr.h:646
static void RegisterReflection()
Definition expr.h:651
ffi::Array< Var > vars
Lambda-local parameter definitions.
Definition expr.h:642
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.LambdaExpr", LambdaExprObj, StagingExprObj)
Expr body
Computation over the parameters and captured expressions.
Definition expr.h:644
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition expr.h:657
Managed reference to a typed staging lambda.
Definition expr.h:662
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(LambdaExpr, StagingExpr, LambdaExprObj)
TVM_TIRX_DLL LambdaExpr(ffi::Array< Var > vars, Expr body, Location loc=UnknownLoc())
Non-nullable source-location metadata.
Definition location.h:91
Managed reference to the MissingTypeObj singleton.
Definition type.h:126
Base node for opaque construction-time expressions.
Definition expr.h:136
static void RegisterReflection()
Definition expr.h:138
TVM_FFI_DECLARE_OBJECT_INFO("ir.OpaqueExpr", OpaqueExprObj, ExprObj)
static constexpr const uint32_t _type_child_slots
Definition expr.h:143
Managed reference to OpaqueExprObj.
Definition expr.h:148
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(OpaqueExpr, Expr, OpaqueExprObj)
OpaqueExpr(ffi::ObjectPtr< OpaqueExprObj > node)
Definition expr.h:150
Typed reference/view over any Expr whose ExprObj::ty is PrimType.
Definition expr.h:187
static constexpr bool _type_container_is_exact
Definition expr.h:205
TVM_TIRX_DLL PrimExpr(int32_t value)
construct from integer.
TVM_TIRX_DLL PrimExpr(float value)
construct from float.
PrimExpr(ffi::ObjectPtr< ExprObj > node)
Definition expr.h:202
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(PrimExpr, TypedExpr< PrimType >, ExprObj)
Primitive data types used in the low-level IR.
Definition type.h:164
DLDataType dtype
The raw DLPack dtype represented by this primitive type.
Definition type.h:169
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 VarObj.
Definition expr.h:598
static constexpr bool _type_container_is_exact
Definition expr.h:623
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(PrimVar, PrimExpr, VarObj)
PrimVar(ffi::ObjectPtr< VarObj > node)
Definition expr.h:620
PrimVar(ffi::String name, PrimType dtype=PrimType::Int(32), Location loc=UnknownLoc())
Construct a scalar variable directly from a primitive type.
Definition expr.h:601
PrimVar CopyWithDType(PrimType dtype) const
Definition expr.h:616
PrimVar CopyWithSuffix(const ffi::String &suffix) const
Definition expr.h:613
PrimVar(ffi::String name, Type type_annotation, Location loc=UnknownLoc())
Construct a scalar variable directly from a checked type annotation.
Definition expr.h:606
range over one dimension
Definition expr.h:856
RangeObj(PrimExpr begin, PrimExpr extent, Location loc=UnknownLoc())
Definition expr.h:866
PrimExpr extent
Extent of the range.
Definition expr.h:861
RangeObj(ffi::UnsafeInit tag)
constructor
Definition expr.h:865
Location loc
the location of this range in the source
Definition expr.h:863
PrimExpr begin
Inclusive beginning of the range.
Definition expr.h:859
static void RegisterReflection()
Definition expr.h:869
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition expr.h:877
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.Range", RangeObj, ffi::Object)
Range container
Definition expr.h:883
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Range, ffi::ObjectRef, RangeObj)
static TVM_TIRX_DLL PrimExpr GetExtentFromBeginEnd(const PrimExpr &begin, const PrimExpr &end)
Extract the interval width from its endpoints without an analyzer.
Range(ffi::UnsafeInit tag, ffi::ObjectPtr< RangeObj > n)
Definition expr.h:912
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_TIRX_DLL Range(PrimExpr begin, PrimExpr end, Location loc=UnknownLoc())
constructor by begin and end
Base node for traversable expressions eliminated during compilation.
Definition expr.h:117
static void RegisterReflection()
Definition expr.h:119
TVM_FFI_DECLARE_OBJECT_INFO("ir.StagingExpr", StagingExprObj, ExprObj)
static constexpr const uint32_t _type_child_slots
Definition expr.h:120
Managed reference to a staging expression.
Definition expr.h:125
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(StagingExpr, Expr, StagingExprObj)
A string literal with shared semantic StringType.
Definition expr.h:267
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.StringImm", StringImmObj, ConstantObj)
ffi::String value
Definition expr.h:269
static void RegisterReflection()
Definition expr.h:271
Managed reference to a string literal.
Definition expr.h:278
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(StringImm, Constant, StringImmObj)
StringImm(ffi::ObjectPtr< StringImmObj > node)
Definition expr.h:282
TVM_DEFINE_OBJECT_REF_COW_METHOD(StringImmObj)
TVM_TIRX_DLL StringImm(ffi::String value, Location loc=UnknownLoc())
Load a value from an indexed expression source.
Definition expr.h:497
TensorLoadObj(ffi::UnsafeInit tag)
Definition expr.h:500
Expr source
The indexed source expression.
Definition expr.h:503
static void RegisterReflection()
Definition expr.h:507
TensorLoadObj(Expr source)
Definition expr.h:499
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.TensorLoad", TensorLoadObj, ExprObj)
ffi::Array< PrimExpr > indices
The indices at which the source is loaded.
Definition expr.h:505
Managed reference to TensorLoadObj.
Definition expr.h:528
TVM_TIRX_DLL TensorLoad(Expr source, ffi::Array< PrimExpr > indices, Location loc=UnknownLoc())
Construct a load using the inference hook on the runtime class of source->ty.
static constexpr bool _type_container_is_exact
Definition expr.h:541
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(TensorLoad, PrimExpr, TensorLoadObj)
TVM_DEFINE_OBJECT_REF_COW_METHOD(TensorLoadObj)
TVM_TIRX_DLL TensorLoad(ffi::ObjectPtr< TensorLoadObj > node)
Wrap an existing node, requiring a concrete primitive result type.
static TVM_TIRX_DLL TensorLoad Unchecked(PrimType ty, Expr source, ffi::Array< PrimExpr > indices, Location loc=UnknownLoc())
Construct with an explicit primitive result type, bypassing source-type inference.
A region of an indexed expression source.
Definition expr.h:920
ffi::Array< Range > region
The ranges selected from the source.
Definition expr.h:928
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.TensorRegion", TensorRegionObj, ExprObj)
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition expr.h:939
Expr source
The indexed source expression.
Definition expr.h:926
static void RegisterReflection()
Definition expr.h:930
TensorRegionObj(ffi::UnsafeInit tag)
Definition expr.h:923
TensorRegionObj(Expr source)
Definition expr.h:922
Managed reference to TensorRegionObj.
Definition expr.h:944
TVM_TIRX_DLL TensorRegion(Expr source, ffi::Array< Range > region, Type ty, Location loc=UnknownLoc())
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(TensorRegion, Expr, TensorRegionObj)
static TVM_TIRX_DLL TensorRegion FromTensorLoad(TensorLoad value)
Convert a tensor load to a region with unit extent at each index.
TVM_DEFINE_OBJECT_REF_COW_METHOD(TensorRegionObj)
TensorRegion(ffi::ObjectPtr< TensorRegionObj > node)
Definition expr.h:956
Get the index-th field out of a tuple.
Definition expr.h:459
TupleGetItemObj(ffi::UnsafeInit tag)
Definition expr.h:462
int index
The field index.
Definition expr.h:467
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.TupleGetItem", TupleGetItemObj, ExprObj)
Expr tuple
The tuple expression.
Definition expr.h:465
TupleGetItemObj(Expr tuple)
Definition expr.h:461
static void RegisterReflection()
Definition expr.h:469
Managed reference to TupleGetItemObj.
Definition expr.h:480
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, TupleGetItemObj)
TupleGetItem(ffi::ObjectPtr< TupleGetItemObj > node)
Definition expr.h:490
TVM_DEFINE_OBJECT_REF_COW_METHOD(TupleGetItemObj)
Tuple container.
Definition expr.h:429
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.Tuple", TupleObj, ExprObj)
ffi::Array< Expr > fields
The fields of the tuple.
Definition expr.h:432
static void RegisterReflection()
Definition expr.h:434
Managed reference to TupleObj.
Definition expr.h:443
TVM_TIRX_DLL Tuple(ffi::Array< Expr > fields, Location loc=UnknownLoc())
Construct a tuple from its fields.
Tuple(ffi::ObjectPtr< TupleObj > node)
Definition expr.h:452
TVM_DEFINE_OBJECT_REF_COW_METHOD(TupleObj)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Tuple, Expr, TupleObj)
Managed reference to TypeObj.
Definition type.h:75
Typed reference/view over an expression whose result type is a specific Type subtype.
Definition expr.h:161
static constexpr bool _type_container_is_exact
Definition expr.h:175
ExpectedType ty() const
Definition expr.h:164
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(TypedExpr, Expr, ExprObj)
TypedExpr(ffi::ObjectPtr< ExprObj > node)
Definition expr.h:172
Reference to the shared immutable unknown location.
Definition location.h:105
A local variable in the IR.
Definition expr.h:552
static void RegisterReflection()
Definition expr.h:557
static constexpr bool _type_child_slots_can_overflow
Definition expr.h:566
static constexpr const uint32_t _type_child_slots
Definition expr.h:563
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition expr.h:562
ffi::String name
The variable name.
Definition expr.h:555
TVM_FFI_DECLARE_OBJECT_INFO("ir.Var", VarObj, ExprObj)
Managed reference to VarObj.
Definition expr.h:571
TVM_TIRX_DLL Var CopyWithDType(PrimType dtype) const
Return a fresh ordinary Var with a new primitive type.
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.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Var, Expr, VarObj)
TVM_TIRX_DLL Var(ffi::String name, Type ty, Location loc=UnknownLoc())
Var(ffi::ObjectPtr< VarObj > node)
Definition expr.h:587
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 storage_enabled_v< PrimExpr >
Definition expr.h:225
constexpr bool storage_enabled_v< Expr >
Definition expr.h:223
constexpr bool use_default_type_traits_v< PrimVar >
Definition expr.h:1133
constexpr bool use_default_type_traits_v< Expr >
Definition expr.h:1086
constexpr bool use_default_type_traits_v< PrimExpr >
Definition expr.h:1058
constexpr bool use_default_type_traits_v< TensorRegion >
Definition expr.h:1147
constexpr bool object_ref_contains_v< PrimExpr, IntImmObj >
Definition expr.h:1006
constexpr bool object_ref_contains_v< PrimExpr, FloatImmObj >
Definition expr.h:1019
constexpr bool use_default_type_traits_v< IntExpr >
Definition expr.h:1107
constexpr bool use_default_type_traits_v< FloatImm >
Definition expr.h:1009
constexpr bool object_ref_contains_v< PrimExpr, TensorLoadObj >
Definition expr.h:1022
constexpr bool use_default_type_traits_v< IntImm >
Definition expr.h:992
constexpr ffi::reflection::AttrKey< CallEffectKind > kCallEffectKind
The runtime effect of an operator call.
Definition expr.h:852
PrimVar var(std::string name_hint, PrimType t=PrimType::Int(32))
Construct a new Var expression.
constexpr ffi::reflection::AttrKey< ffi::TypedFunction< ffi::ObjectRef(Expr, SubscriptSlice, Location)> > kExprSubscriptRealizeByTy
Realize a subscript of an expression, dispatched on the type of the expression.
Definition expr.h:1172
constexpr ffi::reflection::AttrKey< ffi::reflection::NativeFunctionView< PrimType(const TensorLoadObj *)> > kTensorLoadInferType
Infer a load's primitive result type from its populated source, indices and location.
Definition expr.h:524
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analysis.h:41
TVM_TIRX_DLL CallEffectKind SideEffect(const Expr &expr)
Analyze the runtime effects of an expression.
std::ostream & operator<<(std::ostream &os, CallEffectKind side_effect)
Definition expr.h:757
TVM_TIRX_DLL PrimExpr equal(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
equal
CallEffectKind
The effect type of the call.
Definition expr.h:722
@ 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).
ffi::Array< ffi::Variant< ffi::Tuple< ffi::Optional< PrimExpr >, ffi::Optional< PrimExpr >, ffi::Optional< PrimExpr > >, PrimExpr > > SubscriptSlice
Expression subscripts: point indices or (start, stop, step) slices.
Definition expr.h:1161
PrimExpr min(PrimExpr source, ffi::Array< s_tir::IterVar > axis, ffi::Array< PrimExpr > init={}, Location loc=UnknownLoc())
max of source expression over axis
static TVM_FFI_INLINE Expr ConvertFallbackValue(PrimExpr value)
Definition expr.h:1090
static std::optional< Expr > TryCastFromAnyView(const TVMFFIAny *src)
Definition expr.h:1094
static TVM_FFI_INLINE Expr ConvertFallbackValue(ffi::String value)
Definition expr.h:1091
static TVM_FFI_INLINE FloatImm ConvertFallbackValue(double value)
Definition expr.h:1013
static TVM_FFI_INLINE IntExpr ConvertFallbackValue(int64_t value)
Definition expr.h:1121
static TVM_FFI_INLINE std::string GetMismatchTypeInfo(const TVMFFIAny *src)
Definition expr.h:1127
static TVM_FFI_INLINE std::string TypeStr()
Definition expr.h:1125
ObjectRefWithFallbackTraitsBase< IntExpr, int64_t > Base
Definition expr.h:1111
static TVM_FFI_INLINE bool CheckAnyStrict(const TVMFFIAny *src)
Definition expr.h:1113
static TVM_FFI_INLINE IntImm ConvertFallbackValue(int64_t value)
Definition expr.h:996
static TVM_FFI_INLINE PrimExpr ConvertFallbackValue(int64_t value)
Definition expr.h:1076
static TVM_FFI_INLINE std::string GetMismatchTypeInfo(const TVMFFIAny *src)
Definition expr.h:1069
static TVM_FFI_INLINE PrimExpr ConvertFallbackValue(double value)
Definition expr.h:1079
static TVM_FFI_INLINE bool CheckAnyStrict(const TVMFFIAny *src)
Definition expr.h:1063
static TVM_FFI_INLINE PrimExpr ConvertFallbackValue(StrictBool value)
Definition expr.h:1073
static TVM_FFI_INLINE std::string TypeStr()
Definition expr.h:1067
static TVM_FFI_INLINE bool CheckAnyStrict(const TVMFFIAny *src)
Definition expr.h:1139
ObjectRefTypeTraitsBase< PrimVar > Base
Definition expr.h:1137
static TVM_FFI_INLINE TensorRegion ConvertFallbackValue(TensorLoad value)
Definition expr.h:1151
static TVM_FFI_INLINE bool CheckAnyStrict(const TVMFFIAny *src)
Definition expr.h:1030
static TVM_FFI_INLINE std::string GetMismatchTypeInfo(const TVMFFIAny *src)
Definition expr.h:1041
static TVM_FFI_INLINE tvm::StringImm ConvertFallbackValue(ffi::String value)
Definition expr.h:986