tvm
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
expr.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
24 #ifndef TVM_IR_EXPR_H_
25 #define TVM_IR_EXPR_H_
26 
27 #include <tvm/ir/source_map.h>
28 #include <tvm/ir/type.h>
29 #include <tvm/node/node.h>
31 #include <tvm/runtime/object.h>
32 
33 #include <algorithm>
34 #include <functional>
35 #include <limits>
36 #include <string>
37 #include <type_traits>
38 
39 namespace tvm {
40 
42 
43 // Forward-declare VirtualDevice to avoid circular imports.
44 class VirtualDevice;
45 
50 class BaseExprNode : public Object {
51  public:
56  mutable Span span;
57 
58  static constexpr const char* _type_key = "BaseExpr";
59  static constexpr const bool _type_has_method_sequal_reduce = true;
60  static constexpr const bool _type_has_method_shash_reduce = true;
61  static constexpr const uint32_t _type_child_slots = 64;
63 };
64 
69 class BaseExpr : public ObjectRef {
70  public:
72 };
73 
86 class PrimExprNode : public BaseExprNode {
87  public:
103 
105 
106  static constexpr const char* _type_key = "PrimExpr";
107  static constexpr const uint32_t _type_child_slots = 40;
109 };
110 
115 class PrimExpr : public BaseExpr {
116  public:
121  TVM_DLL PrimExpr(int32_t value); // NOLINT(*)
126  TVM_DLL PrimExpr(float value); // NOLINT(*)
127 
129  DataType dtype() const { return static_cast<const PrimExprNode*>(get())->dtype; }
130 
132 
133  private:
134  // Internal function for conversion.
136  TVM_DLL static PrimExpr FromObject_(ObjectRef ref);
137 };
138 
149 
160 
170 
181 
192 
203 
214 
225 
236 
247 
258 
269 
280 
290 
300 
309 
320 
331 
342 
352 
362 class RelaxExprNode : public BaseExprNode {
363  public:
370  mutable Type checked_type_ = Type(nullptr);
371 
378 
382  inline const Type& checked_type() const;
393  template <typename TTypeNode>
394  inline const TTypeNode* type_as() const;
395 
396  static constexpr const char* _type_key = "RelaxExpr";
397  static constexpr const uint32_t _type_child_slots = 22;
399 };
400 
405 class RelaxExpr : public BaseExpr {
406  public:
408 };
409 
410 class GlobalVar;
419 class GlobalVarNode : public RelaxExprNode {
420  public:
423 
425  v->Visit("name_hint", &name_hint);
426  v->Visit("span", &span);
427  v->Visit("_checked_type_", &checked_type_);
428  v->Visit("struct_info_", &struct_info_);
429  }
430 
431  bool SEqualReduce(const GlobalVarNode* other, SEqualReducer equal) const {
432  // name matters for global var.
433  return equal(name_hint, other->name_hint) && equal.FreeVarEqualImpl(this, other);
434  }
435 
436  void SHashReduce(SHashReducer hash_reduce) const {
437  hash_reduce(name_hint);
438  hash_reduce.FreeVarHashImpl(this);
439  }
440 
441  static constexpr const char* _type_key = "GlobalVar";
443 };
444 
449 class GlobalVar : public RelaxExpr {
450  public:
451  TVM_DLL explicit GlobalVar(String name_hint, Type type = {}, Span span = {});
452 
455 };
456 
457 // PrimExprs that are useful as runtime containers.
458 //
463 class IntImmNode : public PrimExprNode {
464  public:
466  int64_t value;
467 
469  v->Visit("dtype", &dtype);
470  v->Visit("value", &value);
471  v->Visit("span", &span);
472  }
473 
474  bool SEqualReduce(const IntImmNode* other, SEqualReducer equal) const {
475  return equal(dtype, other->dtype) && equal(value, other->value);
476  }
477 
478  void SHashReduce(SHashReducer hash_reduce) const {
479  hash_reduce(dtype);
480  hash_reduce(value);
481  }
482 
483  static constexpr const char* _type_key = "IntImm";
485 };
486 
492 class IntImm : public PrimExpr {
493  public:
500  TVM_DLL IntImm(DataType dtype, int64_t value, Span span = Span());
501 
504 };
505 
510 class FloatImmNode : public PrimExprNode {
511  public:
513  double value;
514 
516  v->Visit("dtype", &dtype);
517  v->Visit("value", &value);
518  v->Visit("span", &span);
519  }
520 
521  bool SEqualReduce(const FloatImmNode* other, SEqualReducer equal) const {
522  return equal(dtype, other->dtype) && equal(value, other->value);
523  }
524 
525  void SHashReduce(SHashReducer hash_reduce) const {
526  hash_reduce(dtype);
527  hash_reduce(value);
528  }
529 
530  static constexpr const char* _type_key = "FloatImm";
532 };
533 
539 class FloatImm : public PrimExpr {
540  public:
547  TVM_DLL FloatImm(DataType dtype, double value, Span span = Span());
548 
551 };
552 
559 class Bool : public IntImm {
560  public:
561  explicit Bool(bool value, Span span = Span()) : IntImm(DataType::Bool(), value, span) {}
562  Bool operator!() const { return Bool((*this)->value == 0); }
563  operator bool() const { return (*this)->value != 0; }
564 
566 };
567 
568 // Overload operators to make sure we have the most fine grained types.
569 inline Bool operator||(const Bool& a, bool b) { return Bool(a.operator bool() || b); }
570 inline Bool operator||(bool a, const Bool& b) { return Bool(a || b.operator bool()); }
571 inline Bool operator||(const Bool& a, const Bool& b) {
572  return Bool(a.operator bool() || b.operator bool());
573 }
574 inline Bool operator&&(const Bool& a, bool b) { return Bool(a.operator bool() && b); }
575 inline Bool operator&&(bool a, const Bool& b) { return Bool(a && b.operator bool()); }
576 inline Bool operator&&(const Bool& a, const Bool& b) {
577  return Bool(a.operator bool() && b.operator bool());
578 }
579 
580 inline bool operator==(const Bool& a, bool b) { return a.operator bool() == b; }
581 inline bool operator==(bool a, const Bool& b) { return a == b.operator bool(); }
582 inline bool operator==(const Bool& a, const Bool& b) {
583  return a.operator bool() == b.operator bool();
584 }
585 
594 class Integer : public IntImm {
595  public:
596  Integer() {}
600  explicit Integer(ObjectPtr<Object> node) : IntImm(node) {}
604  Integer(int value, Span span = Span()) : IntImm(DataType::Int(32), value, span) {} // NOLINT(*)
609  Integer(IntImm other) : IntImm(std::move(other)) {} // NOLINT(*)
615  template <typename Enum, typename = typename std::enable_if<std::is_enum<Enum>::value>::type>
616  explicit Integer(Enum value) : Integer(static_cast<int>(value)) {
617  static_assert(std::is_same<int, typename std::underlying_type<Enum>::type>::value,
618  "declare enum to be enum int to use visitor");
619  }
624  Integer& operator=(const IntImm& other) {
625  data_ = ObjectRef::GetDataPtr<Object>(other);
626  return *this;
627  }
631  int64_t IntValue() const {
632  ICHECK(data_ != nullptr) << " Trying to reference a null Integer";
633  return (*this)->value;
634  }
635  // comparators
636  Bool operator==(int other) const {
637  if (data_ == nullptr) return Bool(false);
638  return Bool((*this)->value == other);
639  }
640  Bool operator!=(int other) const { return !(*this == other); }
641  template <typename Enum, typename = typename std::enable_if<std::is_enum<Enum>::value>::type>
642  Bool operator==(Enum other) const {
643  return *this == static_cast<int>(other);
644  }
645  template <typename Enum, typename = typename std::enable_if<std::is_enum<Enum>::value>::type>
646  Bool operator!=(Enum other) const {
647  return *this != static_cast<int>(other);
648  }
649 };
650 
652 class RangeNode : public Object {
653  public:
659  mutable Span span;
663  : min(min), extent(extent), span(span) {}
664 
666  v->Visit("min", &min);
667  v->Visit("extent", &extent);
668  v->Visit("span", &span);
669  }
670 
671  bool SEqualReduce(const RangeNode* other, SEqualReducer equal) const {
672  return equal(min, other->min) && equal(extent, other->extent);
673  }
674 
675  void SHashReduce(SHashReducer hash_reduce) const {
676  hash_reduce(min);
677  hash_reduce(extent);
678  }
679 
680  static constexpr const char* _type_key = "Range";
681  static constexpr const bool _type_has_method_sequal_reduce = true;
682  static constexpr const bool _type_has_method_shash_reduce = true;
684 };
685 
687 class Range : public ObjectRef {
688  public:
695  TVM_DLL Range(PrimExpr begin, PrimExpr end, Span span = Span());
706  static Range FromMinExtent(PrimExpr min, PrimExpr extent, Span span = Span());
707  // declare range.
709 };
710 
711 // implementations
712 inline const Type& RelaxExprNode::checked_type() const {
713  ICHECK(checked_type_.defined()) << "internal error: the type checker has "
714  << "not populated the checked_type "
715  << "field for " << GetRef<RelaxExpr>(this);
716  return this->checked_type_;
717 }
718 
719 template <typename TTypeNode>
720 inline const TTypeNode* RelaxExprNode::type_as() const {
721  static_assert(std::is_base_of<TypeNode, TTypeNode>::value,
722  "TType must be a special case of type");
723  ICHECK(checked_type_.defined())
724  << "Type inference for this Expr has not completed. Try to call infer_type pass.";
725  const TTypeNode* node = checked_type_.as<TTypeNode>();
726  ICHECK(node != nullptr) << "Expected type to be " << TTypeNode::_type_key << ", but get "
727  << checked_type_->GetTypeKey();
728  return node;
729 }
730 
731 } // namespace tvm
732 
733 namespace tvm {
734 namespace runtime {
735 
736 // Automatic conversion into IntImm, Integer, and Bool, when called
737 // through the FFI. Automatic conversions into PrimExpr are
738 // registered in "tvm/tir/expr.h", as it includes conversions to the
739 // TIR-only StringImm.
740 //
741 // While the FFI only requires the From() method, these
742 // implementations also define a TryFrom() method to avoid duplicate
743 // logic in the PrimExpr conversion.
744 
745 template <>
747  template <typename PODSubclass>
748  static Optional<tvm::IntImm> TryFrom(const PODSubclass& val) {
749  if (auto opt = val.TryAsInt()) {
750  int64_t value = opt.value();
751  auto dtype =
753  ? DataType::Int(64)
754  : DataType::Int(32);
755  return IntImm(dtype, value);
756  } else if (auto opt = val.TryAsBool()) {
757  return IntImm(DataType::Int(32), opt.value());
758  } else {
759  return NullOpt;
760  }
761  }
762 
763  template <typename PODSubclass>
764  static tvm::IntImm From(const PODSubclass& val) {
765  if (auto opt = TryFrom(val)) {
766  return opt.value();
767  } else {
768  return val.template AsObjectRef<tvm::IntImm>();
769  }
770  }
771 };
772 
773 template <>
775  template <typename PODSubclass>
776  static tvm::Integer From(const PODSubclass& val) {
778  return Integer(opt.value());
779  } else {
780  return val.template AsObjectRef<tvm::Integer>();
781  }
782  }
783 };
784 
785 template <>
787  template <typename PODSubclass>
788  static Optional<tvm::Bool> TryFrom(const PODSubclass& val) {
789  if (auto opt = val.TryAsBool()) {
790  return tvm::Bool(opt.value());
791  } else if (auto opt = val.TryAsInt()) {
792  int value = opt.value();
793  ICHECK(value == 0 || value == 1)
794  << "ValueError: boolean value can only be 0 or 1, but get " << value;
795  return tvm::Bool(static_cast<bool>(value));
796  } else {
797  return NullOpt;
798  }
799  }
800 
801  template <typename PODSubclass>
802  static tvm::Bool From(const PODSubclass& val) {
803  if (auto opt = TryFrom(val)) {
804  return opt.value();
805  } else {
806  return val.template AsObjectRef<tvm::Bool>();
807  }
808  }
809 };
810 
811 template <>
814  if (auto opt = val.TryAsFloat()) {
815  return FloatImm(runtime::DataType::Float(32), opt.value());
816  } else {
817  return NullOpt;
818  }
819  }
820 
821  template <typename PODSubclass>
822  static tvm::FloatImm From(const PODSubclass& val) {
823  if (auto opt = TryFrom(val)) {
824  return opt.value();
825  } else {
826  return val.template AsObjectRef<tvm::FloatImm>();
827  }
828  }
829 };
830 
831 /* \brief Backwards compatibility wrapper for IntImm arguments
832  *
833  * In previous versions of TVM, IntImm was the default FFI type for
834  * integer arguments, instead of runtime::Int. For backwards
835  * compatibility where the callee has been updated to expected a
836  * runtime::Int, the caller has not been updated to provide a
837  * runtime::Int, and the auto-unboxing of
838  * runtime::Int does not apply (e.g. making an `Array<runtime::Int>`),
839  * allow the IntImm to be generated.
840  */
841 template <>
842 struct PackedFuncValueConverter<runtime::Int> {
843  template <typename PODSubclass>
844  static runtime::Int From(const PODSubclass& val) {
845  if (val.template IsObjectRef<tvm::IntImm>()) {
846  return runtime::Int(val.template AsObjectRef<tvm::IntImm>()->value);
847  } else {
848  return val.template AsObjectRef<runtime::Int>();
849  }
850  }
851 };
852 
853 } // namespace runtime
854 } // namespace tvm
855 
856 /* \brief Allow tvm.GLobalVar as key in STL tables
857  *
858  * For most IR expressions, it would be ambiguous whether the
859  * expression should follow reference equality or structural equality.
860  * This is not the case for variables, which do not contain nested
861  * internal structure, and are frequently used as keys in lookup
862  * tables.
863  *
864  * Providing `std::hash` and `std::equal_to` specializations for
865  * `tvm::GlobalVar` allows it to be used as a key in STL tables. For
866  * other IR expressions, the user must specify the type of equality
867  * used (e.g. `std::unordered_set<T, StructuralHash, StructuralEqual>`
868  * or `std::unordered_set<T, ObjectPtrHash, ObjectPtrEqual>`).
869  */
870 template <>
871 struct std::hash<tvm::GlobalVar> {
872  std::size_t operator()(const tvm::GlobalVar& var) const {
874  }
875 };
876 
877 template <>
878 struct std::equal_to<tvm::GlobalVar> {
879  bool operator()(const tvm::GlobalVar& var_a, const tvm::GlobalVar& var_b) const {
880  return tvm::runtime::ObjectPtrEqual()(var_a, var_b);
881  }
882 };
883 #endif // TVM_IR_EXPR_H_
Visitor class to get the attributes of an AST/IR node. The content is going to be called for each fie...
Definition: reflection.h:52
Base type of all the expressions.
Definition: expr.h:50
static constexpr const char * _type_key
Definition: expr.h:58
static constexpr const bool _type_has_method_shash_reduce
Definition: expr.h:60
static constexpr const uint32_t _type_child_slots
Definition: expr.h:61
TVM_DECLARE_BASE_OBJECT_INFO(BaseExprNode, Object)
static constexpr const bool _type_has_method_sequal_reduce
Definition: expr.h:59
Span span
Span that points to the original source code. Reserved debug information.
Definition: expr.h:56
Managed reference to BaseExprNode.
Definition: expr.h:69
TVM_DEFINE_OBJECT_REF_METHODS(BaseExpr, ObjectRef, BaseExprNode)
Boolean constant.
Definition: expr.h:559
Bool operator!() const
Definition: expr.h:562
Bool(bool value, Span span=Span())
Definition: expr.h:561
TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(Bool, IntImm, IntImmNode)
Constant floating point literals in the program.
Definition: expr.h:510
bool SEqualReduce(const FloatImmNode *other, SEqualReducer equal) const
Definition: expr.h:521
TVM_DECLARE_FINAL_OBJECT_INFO(FloatImmNode, PrimExprNode)
void VisitAttrs(AttrVisitor *v)
Definition: expr.h:515
double value
The constant value content.
Definition: expr.h:513
static constexpr const char * _type_key
Definition: expr.h:530
void SHashReduce(SHashReducer hash_reduce) const
Definition: expr.h:525
Managed reference class to FloatImmNode.
Definition: expr.h:539
TVM_DEFINE_OBJECT_REF_COW_METHOD(FloatImmNode)
TVM_DEFINE_OBJECT_REF_METHODS(FloatImm, PrimExpr, FloatImmNode)
FloatImm(DataType dtype, double value, Span span=Span())
Constructor.
Global variable that lives in the top-level module.
Definition: expr.h:419
TVM_DECLARE_FINAL_OBJECT_INFO(GlobalVarNode, RelaxExprNode)
void SHashReduce(SHashReducer hash_reduce) const
Definition: expr.h:436
void VisitAttrs(AttrVisitor *v)
Definition: expr.h:424
static constexpr const char * _type_key
Definition: expr.h:441
String name_hint
The name of the variable, this only acts as a hint.
Definition: expr.h:422
bool SEqualReduce(const GlobalVarNode *other, SEqualReducer equal) const
Definition: expr.h:431
Managed reference to GlobalVarNode.
Definition: expr.h:449
GlobalVar(String name_hint, Type type={}, Span span={})
TVM_DEFINE_OBJECT_REF_COW_METHOD(GlobalVarNode)
TVM_DEFINE_OBJECT_REF_METHODS(GlobalVar, RelaxExpr, GlobalVarNode)
Constant integer literals in the program.
Definition: expr.h:463
TVM_DECLARE_FINAL_OBJECT_INFO(IntImmNode, PrimExprNode)
void VisitAttrs(AttrVisitor *v)
Definition: expr.h:468
static constexpr const char * _type_key
Definition: expr.h:483
int64_t value
the Internal value.
Definition: expr.h:466
void SHashReduce(SHashReducer hash_reduce) const
Definition: expr.h:478
bool SEqualReduce(const IntImmNode *other, SEqualReducer equal) const
Definition: expr.h:474
Managed reference class to IntImmNode.
Definition: expr.h:492
TVM_DEFINE_OBJECT_REF_COW_METHOD(IntImmNode)
TVM_DEFINE_OBJECT_REF_METHODS(IntImm, PrimExpr, IntImmNode)
IntImm(DataType dtype, int64_t value, Span span=Span())
Constructor.
Container of constant int that adds more constructors.
Definition: expr.h:594
Bool operator!=(Enum other) const
Definition: expr.h:646
Integer(ObjectPtr< Object > node)
constructor from node.
Definition: expr.h:600
Integer()
Definition: expr.h:596
Bool operator!=(int other) const
Definition: expr.h:640
Integer(Enum value)
Constructor from enum.
Definition: expr.h:616
Bool operator==(int other) const
Definition: expr.h:636
Integer(IntImm other)
Construct integer from int imm.
Definition: expr.h:609
int64_t IntValue() const
convert to int64_t
Definition: expr.h:631
Bool operator==(Enum other) const
Definition: expr.h:642
Integer & operator=(const IntImm &other)
Assign an expression to integer.
Definition: expr.h:624
Integer(int value, Span span=Span())
Construct integer from int value.
Definition: expr.h:604
Base node of all primitive expressions.
Definition: expr.h:86
static constexpr const uint32_t _type_child_slots
Definition: expr.h:107
TVM_OBJECT_ENABLE_SCRIPT_PRINTER()
DataType dtype
The runtime data type of the primitive expression.
Definition: expr.h:102
static constexpr const char * _type_key
Definition: expr.h:106
TVM_DECLARE_BASE_OBJECT_INFO(PrimExprNode, BaseExprNode)
Reference to PrimExprNode.
Definition: expr.h:115
DataType dtype() const
Definition: expr.h:129
TVM_DEFINE_OBJECT_REF_METHODS(PrimExpr, BaseExpr, PrimExprNode)
PrimExpr(float value)
construct from float.
PrimExpr(int32_t value)
construct from integer.
range over one dimension
Definition: expr.h:652
PrimExpr min
beginning of the node
Definition: expr.h:655
void VisitAttrs(AttrVisitor *v)
Definition: expr.h:665
RangeNode(PrimExpr min, PrimExpr extent, Span span=Span())
Definition: expr.h:662
bool SEqualReduce(const RangeNode *other, SEqualReducer equal) const
Definition: expr.h:671
static constexpr const char * _type_key
Definition: expr.h:680
void SHashReduce(SHashReducer hash_reduce) const
Definition: expr.h:675
TVM_DECLARE_FINAL_OBJECT_INFO(RangeNode, Object)
RangeNode()
constructor
Definition: expr.h:661
static constexpr const bool _type_has_method_shash_reduce
Definition: expr.h:682
PrimExpr extent
the extend of range
Definition: expr.h:657
static constexpr const bool _type_has_method_sequal_reduce
Definition: expr.h:681
Span span
the location of this range in the source
Definition: expr.h:659
Range container
Definition: expr.h:687
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
TVM_DEFINE_OBJECT_REF_METHODS(Range, ObjectRef, RangeNode)
Base node of all non-primitive expressions.
Definition: expr.h:362
Type checked_type_
Stores the result of type inference(type checking).
Definition: expr.h:370
static constexpr const char * _type_key
Definition: expr.h:396
const Type & checked_type() const
Definition: expr.h:712
Optional< ObjectRef > struct_info_
Stores the result of structure information of the expression that encapsulate both static shape and r...
Definition: expr.h:377
TVM_DECLARE_BASE_OBJECT_INFO(RelaxExprNode, BaseExprNode)
const TTypeNode * type_as() const
Check if the inferred(checked) type of the Expr is backed by a TTypeNode and return it.
Definition: expr.h:720
static constexpr const uint32_t _type_child_slots
Definition: expr.h:397
Managed reference to RelaxExprNode.
Definition: expr.h:405
TVM_DEFINE_OBJECT_REF_METHODS(RelaxExpr, BaseExpr, RelaxExprNode)
A Reducer class to reduce the structural equality result of two objects.
Definition: structural_equal.h:135
A Reducer class to reduce the structural hash value.
Definition: structural_hash.h:121
void FreeVarHashImpl(const runtime::Object *var) const
Implementation for hash for a free var.
Definition: structural_hash.h:203
Definition: source_map.h:120
Managed reference to TypeNode.
Definition: type.h:93
Definition: boxed_primitive.h:81
Runtime primitive data type.
Definition: data_type.h:43
static DataType Float(int bits, int lanes=1)
Construct an float type.
Definition: data_type.h:244
static DataType Int(int bits, int lanes=1)
Construct an int type.
Definition: data_type.h:227
A custom smart pointer for Object.
Definition: object.h:363
Base class of all object reference.
Definition: object.h:520
bool defined() const
Definition: object.h:553
const Object * get() const
Definition: object.h:555
ObjectPtr< Object > data_
Internal pointer that backs the reference.
Definition: object.h:606
const ObjectType * as() const
Try to downcast the internal Object to a raw pointer of a corresponding type.
Definition: object.h:911
base class of all object containers.
Definition: object.h:172
Optional container that to represent to a Nullable variant of T.
Definition: optional.h:51
T value() const
Definition: optional.h:92
Reference to string objects.
Definition: string.h:97
Internal base class to handle conversion to POD values.
Definition: packed_func.h:615
std::optional< double > TryAsFloat() const
Definition: packed_func.h:689
IR/AST nodes for the unified type system in TVM.
Box< bool > Bool
Boxed version of C++ bool.
Definition: boxed_primitive.h:121
Box< int64_t > Int
Boxed version of C++ int64_t.
Definition: boxed_primitive.h:99
Var var(std::string name_hint, DataType t=DataType::Int(32))
Construct a new Var expression.
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:36
PrimExpr operator!=(PrimExpr a, PrimExpr b)
not_equal
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, PrimExpr b)
equal
PrimExpr operator~(PrimExpr a)
take bitwise negation of two values
PrimExpr operator>=(PrimExpr a, PrimExpr b)
greater_equal
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
constexpr runtime::NullOptType NullOpt
Definition: optional.h:169
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
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
Definitions and helper macros for IR/AST nodes.
A managed object in the TVM runtime.
A map from source names to source code.
Runtime String container types.
ObjectRef equal functor.
Definition: object.h:666
ObjectRef hash functor.
Definition: object.h:656
static runtime::Int From(const PODSubclass &val)
Definition: expr.h:844
static tvm::Bool From(const PODSubclass &val)
Definition: expr.h:802
static Optional< tvm::Bool > TryFrom(const PODSubclass &val)
Definition: expr.h:788
static Optional< tvm::FloatImm > TryFrom(const TVMPODValue_ &val)
Definition: expr.h:813
static tvm::FloatImm From(const PODSubclass &val)
Definition: expr.h:822
static tvm::IntImm From(const PODSubclass &val)
Definition: expr.h:764
static Optional< tvm::IntImm > TryFrom(const PODSubclass &val)
Definition: expr.h:748
static tvm::Integer From(const PODSubclass &val)
Definition: expr.h:776
Type trait to specify special value conversion rules from TVMArgValue and TVMRetValue.
Definition: packed_func.h:1246