23 #ifndef TVM_NODE_ATTR_REGISTRY_MAP_H_
24 #define TVM_NODE_ATTR_REGISTRY_MAP_H_
37 template <
typename KeyType>
45 int count(
const KeyType& key)
const {
47 const uint32_t idx = key->AttrRegistryIndex();
48 return idx < data_.size() ? (data_[idx].second != 0) : 0;
59 ICHECK(key.defined());
60 const uint32_t idx = key->AttrRegistryIndex();
61 ICHECK(idx < data_.size() && data_[idx].second != 0)
62 <<
"Attribute " << attr_name_ <<
" has not been registered for " << key->name;
63 return data_[idx].first;
72 template <
typename ValueType>
73 ValueType
get(
const KeyType& key, ValueType def_value)
const {
74 ICHECK(key.defined());
75 const uint32_t idx = key->AttrRegistryIndex();
76 if (idx < data_.size() && data_[idx].second != 0) {
77 return data_[idx].first;
87 std::vector<std::pair<runtime::TVMRetValue, int>> data_;
90 template <
typename,
typename>
100 template <
typename KeyType,
typename ValueType>
113 int count(
const KeyType& key)
const {
return map_.count(key); }
126 ValueType
get(
const KeyType& key, ValueType def_value)
const {
return map_.get(key, def_value); }
Generic attribute map.
Definition: attr_registry_map.h:38
const runtime::TVMRetValue & operator[](const KeyType &key) const
get the corresponding value element at key.
Definition: attr_registry_map.h:58
int count(const KeyType &key) const
Check if the map has key.
Definition: attr_registry_map.h:45
ValueType get(const KeyType &key, ValueType def_value) const
get the corresponding value element at key with default value.
Definition: attr_registry_map.h:73
Map<Key, ValueType> used to store meta-data.
Definition: attr_registry_map.h:101
const AttrRegistryMapContainerMap< KeyType > & map_
The internal map field.
Definition: attr_registry_map.h:130
ValueType get(const KeyType &key, ValueType def_value) const
get the corresponding value element at key with default value.
Definition: attr_registry_map.h:126
int count(const KeyType &key) const
Check if the map has op as key.
Definition: attr_registry_map.h:113
ValueType operator[](const KeyType &key) const
get the corresponding value element at key.
Definition: attr_registry_map.h:119
AttrRegistryMap(const AttrRegistryMapContainerMap< KeyType > &map)
constructor
Definition: attr_registry_map.h:107
Definition: executor.h:43
Helper structure to register operators.
Definition: op.h:205
Reference to string objects.
Definition: string.h:98
Return Value container, Unlike TVMArgValue, which only holds reference and do not delete the underlyi...
Definition: packed_func.h:946
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
Runtime String container types.