27#include <tvm/ffi/dtype.h>
28#include <tvm/ffi/extra/dataclass.h>
29#include <tvm/ffi/reflection/registry.h>
30#include <tvm/ffi/string.h>
54 namespace refl = tvm::ffi::reflection;
84 namespace refl = tvm::ffi::reflection;
85 refl::ObjectDef<TupleGetItemNode>()
117 namespace refl = tvm::ffi::reflection;
118 refl::ObjectDef<TensorLoadNode>()
361 namespace refl = tvm::ffi::reflection;
363 refl::AttachFieldFlag::SEqHashIgnore());
403 namespace refl = tvm::ffi::reflection;
407 refl::TypeAttrDef<GlobalVarNode>()
460 namespace refl = tvm::ffi::reflection;
461 refl::ObjectDef<CallNode>()
477 ffi::Array<Type> ty_args = ffi::Array<Type>(),
Span span =
Span());
493 namespace refl = tvm::ffi::reflection;
556 namespace refl = tvm::ffi::reflection;
597 namespace refl = tvm::ffi::reflection;
598 refl::ObjectDef<RangeNode>()
601 .def_ro(
"span", &
RangeNode::span, refl::AttachFieldFlag::SEqHashIgnore());
610class Range :
public ffi::ObjectRef {
649struct TypeTraits<
IntImm> :
public ObjectRefWithFallbackTraitsBase<IntImm, int64_t> {
663struct TypeTraits<
FloatImm> :
public ObjectRefWithFallbackTraitsBase<FloatImm, double> {
665 return FloatImm(PrimType::Float(32), value);
686struct std::hash<
tvm::
Var> {
687 std::size_t operator()(
const tvm::Var& var)
const {
return tvm::ffi::ObjectPtrHash()(
var); }
691struct std::equal_to<
tvm::
Var> {
693 return tvm::ffi::ObjectPtrEqual()(var_a, var_b);
698struct std::hash<
tvm::GlobalVar> {
699 std::size_t operator()(
const tvm::GlobalVar& var)
const {
return tvm::ffi::ObjectPtrHash()(
var); }
703struct std::equal_to<
tvm::GlobalVar> {
705 return tvm::ffi::ObjectPtrEqual()(var_a, var_b);
Helpers for attribute objects.
Base expression and primitive type nodes.
Managed reference to AttrsNode.
Definition attrs.h:59
Call corresponds to callable invocation.
Definition expr.h:440
Attrs attrs
The additional attributes.
Definition expr.h:454
ffi::Array< Expr > args
The arguments of the call.
Definition expr.h:451
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.Call", CallNode, ExprNode)
Expr op
The operator/function being invoked.
Definition expr.h:448
static void RegisterReflection()
Definition expr.h:459
ffi::Array< Type > ty_args
The type information arguments passed to the callee.
Definition expr.h:457
Managed reference to CallNode.
Definition expr.h:474
Call(Type ret_ty, Expr op, ffi::Array< Expr > args, Attrs attrs=Attrs(), ffi::Array< Type > ty_args=ffi::Array< Type >(), Span span=Span())
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(Call, Expr, CallNode)
TVM_DEFINE_OBJECT_REF_COW_METHOD(CallNode)
Base type of all the expressions.
Definition base_expr.h:300
Managed reference to ExprNode.
Definition base_expr.h:335
Constant floating point literals in the program.
Definition expr.h:550
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.FloatImm", FloatImmNode, ExprNode)
double value
The constant value content.
Definition expr.h:553
static void RegisterReflection()
Definition expr.h:555
Managed reference class to FloatImmNode.
Definition expr.h:567
FloatImm(PrimType value_ty, double value, Span span=Span())
Constructor.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(FloatImm, PrimExpr, FloatImmNode)
static constexpr bool _type_container_is_exact
Definition expr.h:578
TVM_DEFINE_OBJECT_REF_COW_METHOD(FloatImmNode)
Global variable that lives in the top-level module.
Definition expr.h:397
int64_t SHash(int64_t init_hash, ffi::TypedFunction< int64_t(AnyView, int64_t, bool)> hash) const
Definition expr.h:417
ffi::String name_hint
The name of the variable, this only acts as a hint.
Definition expr.h:400
static void RegisterReflection()
Definition expr.h:402
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.GlobalVar", GlobalVarNode, ExprNode)
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition expr.h:421
bool SEqual(const GlobalVarNode *other, ffi::TypedFunction< bool(AnyView, AnyView, bool, AnyView)> equal) const
Definition expr.h:412
Managed reference to GlobalVarNode.
Definition expr.h:429
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(GlobalVar, Expr, GlobalVarNode)
TVM_DEFINE_OBJECT_REF_COW_METHOD(GlobalVarNode)
GlobalVar(ffi::String name_hint, Span span={})
Constant integer literals in the program.
Definition expr.h:487
static void RegisterReflection()
Definition expr.h:492
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.IntImm", IntImmNode, ExprNode)
int64_t value
the Internal value.
Definition expr.h:490
Managed reference class to IntImmNode.
Definition expr.h:504
IntImm(PrimType value_ty, int64_t value, Span span=Span())
Constructor.
static constexpr bool _type_container_is_exact
Definition expr.h:542
static IntImm Bool(bool value, Span span=Span())
Construct a scalar boolean constant.
Definition expr.h:519
TVM_DEFINE_OBJECT_REF_COW_METHOD(IntImmNode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(IntImm, PrimExpr, IntImmNode)
static IntImm Int32(int64_t value, Span span=Span())
Construct a scalar int32 constant.
Definition expr.h:528
static IntImm Int64(int64_t value, Span span=Span())
Construct a scalar int64 constant.
Definition expr.h:537
Typed reference/view over any Expr whose ExprNode::ty is PrimType.
Definition base_expr.h:401
Definition base_expr.h:137
static PrimType Int(int bits, int lanes=1)
Construct a signed integer type with fixed lanes.
static PrimType Bool(int lanes=1)
Construct a boolean type with fixed lanes.
range over one dimension
Definition expr.h:583
static void RegisterReflection()
Definition expr.h:596
PrimExpr min
beginning of the node
Definition expr.h:586
RangeNode(PrimExpr min, PrimExpr extent, Span span=Span())
Definition expr.h:593
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.Range", RangeNode, ffi::Object)
RangeNode()
constructor
Definition expr.h:592
PrimExpr extent
the extend of range
Definition expr.h:588
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition expr.h:604
Span span
the location of this range in the source
Definition expr.h:590
Range container
Definition expr.h:610
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(Range, ffi::ObjectRef, RangeNode)
static Range FromMinExtent(PrimExpr min, PrimExpr extent, Span span=Span())
construct a new range with min and extent The corresponding constructor is removed,...
Range(PrimExpr begin, PrimExpr end, Span span=Span())
constructor by begin and end
Definition source_map.h:111
Load a value from an indexed expression source.
Definition expr.h:109
ffi::Array< PrimExpr > indices
The indices at which the source is loaded.
Definition expr.h:114
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.TensorLoad", TensorLoadNode, ExprNode)
Expr source
The indexed source expression.
Definition expr.h:112
static void RegisterReflection()
Definition expr.h:116
Managed reference to TensorLoadNode.
Definition expr.h:127
static constexpr bool _type_container_is_exact
Definition expr.h:130
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(TensorLoad, PrimExpr, TensorLoadNode)
TVM_DEFINE_OBJECT_REF_COW_METHOD(TensorLoadNode)
Get the index-th field out of a tuple.
Definition expr.h:76
Expr tuple
The tuple expression.
Definition expr.h:79
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.TupleGetItem", TupleGetItemNode, ExprNode)
static void RegisterReflection()
Definition expr.h:83
int index
The field index.
Definition expr.h:81
Managed reference to TupleGetItemNode.
Definition expr.h:94
TVM_DEFINE_OBJECT_REF_COW_METHOD(TupleGetItemNode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(TupleGetItem, Expr, TupleGetItemNode)
TupleGetItem(Expr tuple, int index, Span span=Span())
Construct a tuple field projection.
Tuple container.
Definition expr.h:48
ffi::Array< Expr > fields
The fields of the tuple.
Definition expr.h:51
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.Tuple", TupleNode, ExprNode)
static void RegisterReflection()
Definition expr.h:53
Managed reference to TupleNode.
Definition expr.h:62
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(Tuple, Expr, TupleNode)
TVM_DEFINE_OBJECT_REF_COW_METHOD(TupleNode)
Tuple(ffi::Array< Expr > fields, Span span=Span())
Construct a tuple from its fields.
Managed reference to TypeNode.
Definition base_expr.h:77
A local variable in the IR.
Definition expr.h:355
TVM_FFI_DECLARE_OBJECT_INFO("ir.Var", VarNode, ExprNode)
static constexpr const uint32_t _type_child_slots
Definition expr.h:367
ffi::String name
The variable name.
Definition expr.h:358
static void RegisterReflection()
Definition expr.h:360
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition expr.h:366
Managed reference to VarNode.
Definition expr.h:372
Var CopyWithName(const ffi::String &name) const
Return a fresh ordinary Var with the same type and a new name.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(Var, Expr, VarNode)
Var CopyWithDType(PrimType dtype) const
Return a fresh ordinary Var with a new primitive type.
Var CopyWithSuffix(const ffi::String &suffix) const
Return a fresh ordinary Var with a suffix appended to its name.
Var(ffi::String name, ffi::Optional< Type > ty_annotation, Span span=Span())
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition with_context.h:59
Copy-on-write helper macro for IR ffi::ObjectRef types.
PrimVar var(std::string name_hint, PrimType t=PrimType::Int(32))
Construct a new Var expression.
tvm::Var Var
Definition var.h:38
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analyzer.h:40
PrimExpr operator/(PrimExpr a, PrimExpr b)
division operator
PrimExpr equal(PrimExpr a, PrimExpr b, Span span=Span())
equal
PrimExpr operator>>(PrimExpr a, PrimExpr b)
right shift operator
PrimExpr operator<(PrimExpr a, PrimExpr b)
less
PrimExpr operator|(PrimExpr a, PrimExpr b)
take bitwise or of two values
PrimExpr operator~(PrimExpr a)
take bitwise negation of two values
PrimExpr operator>=(PrimExpr a, PrimExpr b)
greater_equal
bool operator!=(const PrimType &lhs, const PrimType &rhs)
Definition base_expr.h:294
PrimExpr operator<=(PrimExpr a, PrimExpr b)
less_equal
PrimExpr operator*(PrimExpr a, PrimExpr b)
multiplication operator
PrimExpr operator&(PrimExpr a, PrimExpr b)
take bitwise and of two values
PrimExpr min(PrimExpr a, PrimExpr b, Span span=Span())
take minimum of two values
PrimExpr operator!(PrimExpr a)
not
PrimExpr operator^(PrimExpr a, PrimExpr b)
take bitwise xor of two values
PrimExpr operator-(PrimExpr a, PrimExpr b)
subtraction operator
PrimExpr operator||(PrimExpr a, PrimExpr b)
or
bool operator==(const PrimType &lhs, const PrimType &rhs)
Definition base_expr.h:290
PrimExpr operator>(PrimExpr a, PrimExpr b)
greater
PrimExpr operator+(PrimExpr a, PrimExpr b)
add operator
PrimExpr operator<<(PrimExpr a, PrimExpr b)
left shift operator
PrimExpr operator&&(PrimExpr a, PrimExpr b)
and
A map from source names to source code.
static TVM_FFI_INLINE FloatImm ConvertFallbackValue(double value)
Definition expr.h:664
static TVM_FFI_INLINE IntImm ConvertFallbackValue(int64_t value)
Definition expr.h:650