24 #ifndef TVM_IR_EXPR_H_
25 #define TVM_IR_EXPR_H_
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>
41 #include <type_traits>
277 namespace refl = tvm::ffi::reflection;
281 refl::TypeAttrDef<GlobalVarNode>()
287 ffi::TypedFunction<
bool(AnyView, AnyView,
bool, AnyView)>
equal)
const {
291 int64_t
SHash(int64_t init_hash, ffi::TypedFunction<int64_t(AnyView, int64_t,
bool)> hash)
const {
292 return hash(
name_hint, init_hash,
false);
334 namespace refl = tvm::ffi::reflection;
335 refl::ObjectDef<CallNode>()
351 ffi::Array<Type> ty_args = ffi::Array<Type>(),
Span span =
Span());
367 namespace refl = tvm::ffi::reflection;
430 namespace refl = tvm::ffi::reflection;
471 namespace refl = tvm::ffi::reflection;
472 refl::ObjectDef<RangeNode>()
475 .def_ro(
"span", &
RangeNode::span, refl::AttachFieldFlag::SEqHashIgnore());
484 class Range :
public ffi::ObjectRef {
521 struct TypeTraits<
IntImm> :
public ObjectRefWithFallbackTraitsBase<IntImm, int64_t> {
527 return IntImm(value_ty, value);
535 struct TypeTraits<
FloatImm> :
public ObjectRefWithFallbackTraitsBase<FloatImm, double> {
558 struct std::hash<
tvm::GlobalVar> {
559 std::size_t operator()(
const tvm::GlobalVar&
var)
const {
return tvm::ffi::ObjectPtrHash()(
var); }
563 struct std::equal_to<
tvm::GlobalVar> {
565 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:314
Attrs attrs
The additional attributes.
Definition: expr.h:328
ffi::Array< Expr > args
The arguments of the call.
Definition: expr.h:325
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.Call", CallNode, ExprNode)
Expr op
The operator/function being invoked.
Definition: expr.h:322
static void RegisterReflection()
Definition: expr.h:333
ffi::Array< Type > ty_args
The type information arguments passed to the callee.
Definition: expr.h:331
Managed reference to CallNode.
Definition: expr.h:348
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:276
Managed reference to ExprNode.
Definition: base_expr.h:311
Constant floating point literals in the program.
Definition: expr.h:424
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.FloatImm", FloatImmNode, ExprNode)
double value
The constant value content.
Definition: expr.h:427
static void RegisterReflection()
Definition: expr.h:429
Managed reference class to FloatImmNode.
Definition: expr.h:441
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:452
TVM_DEFINE_OBJECT_REF_COW_METHOD(FloatImmNode)
Global variable that lives in the top-level module.
Definition: expr.h:271
int64_t SHash(int64_t init_hash, ffi::TypedFunction< int64_t(AnyView, int64_t, bool)> hash) const
Definition: expr.h:291
ffi::String name_hint
The name of the variable, this only acts as a hint.
Definition: expr.h:274
static void RegisterReflection()
Definition: expr.h:276
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.GlobalVar", GlobalVarNode, ExprNode)
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition: expr.h:295
bool SEqual(const GlobalVarNode *other, ffi::TypedFunction< bool(AnyView, AnyView, bool, AnyView)> equal) const
Definition: expr.h:286
Managed reference to GlobalVarNode.
Definition: expr.h:303
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:361
static void RegisterReflection()
Definition: expr.h:366
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.IntImm", IntImmNode, ExprNode)
int64_t value
the Internal value.
Definition: expr.h:364
Managed reference class to IntImmNode.
Definition: expr.h:378
IntImm(PrimType value_ty, int64_t value, Span span=Span())
Constructor.
static constexpr bool _type_container_is_exact
Definition: expr.h:416
static IntImm Bool(bool value, Span span=Span())
Construct a scalar boolean constant.
Definition: expr.h:393
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:402
static IntImm Int64(int64_t value, Span span=Span())
Construct a scalar int64 constant.
Definition: expr.h:411
Typed reference/view over any Expr whose ExprNode::ty is PrimType.
Definition: base_expr.h:354
Definition: base_expr.h:113
static PrimType Float(int bits, int lanes=1)
Construct a floating-point type with fixed lanes.
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:457
static void RegisterReflection()
Definition: expr.h:470
PrimExpr min
beginning of the node
Definition: expr.h:460
RangeNode(PrimExpr min, PrimExpr extent, Span span=Span())
Definition: expr.h:467
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.Range", RangeNode, ffi::Object)
RangeNode()
constructor
Definition: expr.h:466
PrimExpr extent
the extend of range
Definition: expr.h:462
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition: expr.h:478
Span span
the location of this range in the source
Definition: expr.h:464
Range container
Definition: expr.h:484
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
Managed reference to TypeNode.
Definition: base_expr.h:77
Copy-on-write helper macro for IR ffi::ObjectRef types.
constexpr bool object_ref_contains_v< PrimExpr, IntImmNode >
Definition: expr.h:510
constexpr bool object_ref_contains_v< PrimExpr, FloatImmNode >
Definition: expr.h:512
constexpr bool use_default_type_traits_v< FloatImm >
Definition: expr.h:532
constexpr bool use_default_type_traits_v< IntImm >
Definition: expr.h:517
PrimVar var(std::string name_hint, PrimType t=PrimType::Int(32))
Construct a new Var expression.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition: analyzer.h:40
PrimExpr max(PrimExpr a, PrimExpr b, Span span=Span())
take maximum of two values
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:270
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:266
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:536
static TVM_FFI_INLINE IntImm ConvertFallbackValue(int64_t value)
Definition: expr.h:522