28 #include <tvm/ffi/function.h>
29 #include <tvm/ffi/reflection/registry.h>
35 #include <tvm/runtime/logging.h>
96 refl::ObjectDef<OpNode>()
98 .def_ro(
"op_type", &
OpNode::op_type, refl::AttachFieldFlag::SEqHashIgnore())
112 uint32_t AttrRegistryIndex()
const {
return index_; }
114 std::string AttrRegistryName()
const {
return name; }
119 template <
typename,
typename>
141 template <
typename ValueType>
155 TVM_DLL
static const Op&
Get(
const String& op_name);
175 const Op&
op()
const {
return op_; }
191 const std::string& description);
197 template <
typename AttrsType>
230 template <
typename ValueType>
232 const ValueType& value,
int plevel = 10);
242 if (get()->name.length() == 0) {
255 template <
typename,
typename>
266 TVM_DLL
void UpdateAttr(
const String& key, ffi::Any value,
int plevel);
273 template <
typename ValueType>
283 inline ValueType
get(
const RelaxExpr& expr, ValueType def_value)
const;
288 using TParent::operator[];
297 #define TVM_OP_REGISTER_VAR_DEF static DMLC_ATTRIBUTE_UNUSED ::tvm::OpRegEntry& __make_##Op
314 #define TVM_REGISTER_OP(OpName) \
315 TVM_STR_CONCAT(TVM_OP_REGISTER_VAR_DEF, __COUNTER__) = \
316 ::tvm::OpRegEntry::RegisterOrGet(OpName).set_name()
320 template <
typename ValueType>
325 inline OpNode* OpRegEntry::get() {
return const_cast<OpNode*
>(op_.operator->()); }
333 const std::string& description) {
334 auto n = make_object<AttrFieldInfoNode>();
337 n->description = description;
347 template <
typename AttrsType>
365 template <
typename ValueType>
367 const std::string& attr_name,
const ValueType& value,
int plevel) {
368 ICHECK_GT(plevel, 0) <<
"plevel in set_attr must be greater than 0";
369 UpdateAttr(attr_name, Any(value), plevel);
375 template <
typename ValueType>
377 ICHECK(expr.defined());
379 return this->map_.get(GetRef<Op>(op), def_value);
Attribute map used in registry.
Helpers for attribute objects.
AttrFieldInfo.
Definition: attrs.h:92
Generic attribute map.
Definition: attr_registry_map.h:38
Map<Key, ValueType> used to store meta-data.
Definition: attr_registry_map.h:105
ValueType get(const Op &key, ValueType def_value) const
get the corresponding value element at key with default value.
Definition: attr_registry_map.h:136
int count(const Op &key) const
Check if the map has op as key.
Definition: attr_registry_map.h:117
Definition: instruction.h:30
Managed reference to FuncTypeNode.
Definition: type.h:283
Map<Op,ValueType> used to store meta-information about Op.
Definition: op.h:274
ValueType get(const RelaxExpr &expr, ValueType def_value) const
get the corresponding value element at op with default value.
Definition: op.h:376
Primitive Op(builtin intrinsics)
Definition: op.h:59
static void RegisterReflection()
Definition: op.h:94
static constexpr const char * _type_key
Definition: op.h:107
String name
name of the operator
Definition: op.h:62
uint32_t attrs_type_index
attribute type index, this field varies in each run and is not exposed to frontend.
Definition: op.h:81
String attrs_type_key
The type key of the attribute field This can be empty, in which case it defaults to anything.
Definition: op.h:76
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition: op.h:106
int32_t support_level
support level of the operator, The lower the more priority it contains. This is in analogies to BLAS ...
Definition: op.h:92
TVM_DECLARE_FINAL_OBJECT_INFO(OpNode, RelaxExprNode)
int32_t num_inputs
number of input arguments to the operator, -1 means it is variable length
Definition: op.h:86
FuncType op_type
the type of the operator
Definition: op.h:64
String description
detailed description of the operator This can be used to generate docstring automatically for the ope...
Definition: op.h:69
Array< AttrFieldInfo > arguments
Definition: op.h:71
Helper structure to register operators.
Definition: op.h:172
OpRegEntry & set_attrs_type_key(const String &key)
Set the attrs type key and index to be AttrsType.
Definition: op.h:354
OpRegEntry & describe(const std::string &descr)
setter function during registration Set the description of operator
Definition: op.h:327
static OpRegEntry & RegisterOrGet(const String &name)
Register or get a new entry.
OpRegEntry & set_name()
Definition: op.h:241
void reset_attr(const std::string &attr_name)
Resets an attr of the registry.
OpRegEntry & add_argument(const std::string &name, const std::string &type, const std::string &description)
Add argument information to the function.
Definition: op.h:332
OpRegEntry & set_attrs_type()
Set the attrs type key and index to be AttrsType.
Definition: op.h:348
OpRegEntry & set_support_level(int32_t level)
Set the support level of op.
Definition: op.h:360
const Op & op() const
Definition: op.h:175
OpRegEntry & set_attr(const std::string &attr_name, const ValueType &value, int plevel=10)
Register additional attributes to operator.
Definition: op.h:366
OpRegEntry & set_num_inputs(int32_t n)
Set the num_inputs.
Definition: op.h:342
Managed reference class to OpNode.
Definition: op.h:132
static OpAttrMap< ValueType > GetAttrMap(const String &attr_name)
Get additional registered attribute about operators. If nothing has been registered,...
Definition: op.h:321
TVM_DEFINE_OBJECT_REF_METHODS(Op, RelaxExpr, OpNode)
static bool HasAttrMap(const String &attr_name)
Checks if an attr map is present in the registry.
static const Op & Get(const String &op_name)
Get an Op for a given operator name. Will raise an error if the op has not been registered.
Base node of all non-primitive expressions.
Definition: expr.h:422
Managed reference to RelaxExprNode.
Definition: expr.h:446
Serializable global function used in IR.
IR/AST nodes for the unified type system in TVM.
Definition: repr_printer.h:91
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:37