24 #ifndef TVM_RELAY_EXECUTOR_H_ 25 #define TVM_RELAY_EXECUTOR_H_ 27 #include <dmlc/registry.h> 36 #include <unordered_map> 42 template <
typename,
typename>
67 return name ==
"aot" || GetAttr<Bool>(
"link-params").value_or(
Bool(
false));
89 template <
typename TObjectRef>
91 const std::string& attr_key,
93 return attrs.
GetAttr(attr_key, default_value);
96 template <
typename TObjectRef>
102 v->Visit(
"name", &name);
103 v->Visit(
"attrs", &attrs);
160 auto n = make_object<ExecutorNode>();
161 n->name = std::move(name);
162 n->attrs = std::move(attrs);
163 data_ = std::move(n);
178 template <
typename ValueType>
187 template <
typename ValueType>
199 struct ValueTypeInfo {
200 std::string type_key;
203 std::unordered_map<std::string, ValueTypeInfo> key2vtype_;
205 std::unordered_map<String, ObjectRef> key2default_;
214 uint32_t AttrRegistryIndex()
const {
return index_; }
216 String AttrRegistryName()
const {
return name; }
224 template <
typename,
typename>
229 template <
typename ValueType>
231 ICHECK(!key2vtype_.count(key)) <<
"AttributeError: add_attr_option failed because '" << key
232 <<
"' has been set once";
234 using ValueNodeType =
typename ValueType::ContainerType;
236 uint32_t value_type_index = ValueNodeType::_GetOrAllocRuntimeTypeIndex();
239 info.type_index = value_type_index;
241 key2vtype_[key] = info;
245 template <
typename ValueType>
248 add_attr_option<ValueType>(key);
249 key2default_[key] = default_value;
254 #define TVM_EXECUTOR_REGISTER_VAR_DEF \ 255 static DMLC_ATTRIBUTE_UNUSED ::tvm::relay::ExecutorRegEntry& __make_##Executor 271 #define TVM_REGISTER_EXECUTOR(ExecutorName) \ 272 TVM_STR_CONCAT(TVM_EXECUTOR_REGISTER_VAR_DEF, __COUNTER__) = \ 273 ::tvm::relay::ExecutorRegEntry::RegisterOrGet(ExecutorName) 277 #endif // TVM_RELAY_EXECUTOR_H_ TVM_DECLARE_FINAL_OBJECT_INFO(ExecutorNode, Object)
bool DefEqual(const ObjectRef &lhs, const ObjectRef &rhs)
Reduce condition to comparison of two definitions, where free vars can be mapped. ...
void SHashReduce(SHashReducer hash_reduce) const
Definition: executor.h:110
Boolean constant.
Definition: expr.h:587
Optional< TObjectRef > GetAttr(const std::string &attr_key, Optional< TObjectRef > default_value=Optional< TObjectRef >(nullptr)) const
Get an attribute.
Definition: executor.h:90
static constexpr const bool _type_has_method_sequal_reduce
Definition: executor.h:116
A Reducer class to reduce the structural equality result of two objects.
Definition: structural_equal.h:124
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
A Reducer class to reduce the structural hash value.
Definition: structural_hash.h:110
Type relation and function for type inference(checking).
PrimExpr equal(PrimExpr a, PrimExpr b, Span span=Span())
equal
void VisitAttrs(AttrVisitor *v)
Definition: executor.h:101
Managed reference to DictAttrsNode.
Definition: attrs.h:227
Optional< TObjectRef > GetAttr(const std::string &attr_key, TObjectRef default_value) const
Definition: executor.h:97
base class of all object containers.
Definition: object.h:167
Definition: executor.h:43
static constexpr const bool _type_has_method_shash_reduce
Definition: executor.h:117
Helpers for attribute objects.
Executor information.
Definition: executor.h:55
Generic attribute map.
Definition: attr_registry_map.h:38
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
Helper structure to register Executors.
Definition: executor.h:171
IR/AST nodes for the unified type system in TVM.
Optional< TObjectRef > GetAttr(const std::string &attr_key, Optional< TObjectRef > default_value=Optional< TObjectRef >(nullptr)) const
Get a function attribute.
Definition: attrs.h:259
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
Managed reference class to ExecutorNode.
Definition: executor.h:125
static constexpr const char * _type_key
Definition: executor.h:115
ExecutorRegEntry & add_attr_option(const String &key)
Register a valid configuration option and its ValueType for validation.
Definition: executor.h:230
Reference to string objects.
Definition: string.h:98
#define TVM_DEFINE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName)
Definition: object.h:713
DictAttrs attrs
Definition: executor.h:60
Base class of all object reference.
Definition: object.h:511
#define TVM_DEFINE_OBJECT_REF_COW_METHOD(ObjectName)
Define CopyOnWrite function in an ObjectRef.
Definition: object.h:785
Attribute map used in registry.
Bool ShouldLinkParameters() const
Should Link Parameters into the module.
Definition: executor.h:66
uint32_t type_index() const
Definition: object.h:175
Map container of NodeRef->NodeRef in DSL graph. Map implements copy on write semantics, which means map is mutable but copy will happen when array is referenced in more than two places.
Definition: map.h:1271
static std::string TypeIndex2Key(uint32_t tindex)
Get the type key of the corresponding index from runtime.
Optional container that to represent to a Nullable variant of T.
Definition: optional.h:51
String name
name of the Executor
Definition: executor.h:58
bool SEqualReduce(const ExecutorNode *other, SEqualReducer equal) const
Definition: executor.h:106
This file defines the TVM global function registry.