23 #ifndef TVM_NODE_ATTR_REGISTRY_MAP_H_
24 #define TVM_NODE_ATTR_REGISTRY_MAP_H_
26 #include <tvm/ffi/string.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 if constexpr (std::is_same_v<ValueType, ffi::Any>) {
78 return data_[idx].first;
80 return data_[idx].first.template cast<ValueType>();
91 std::vector<std::pair<ffi::Any, int>> data_;
94 template <
typename,
typename>
104 template <
typename KeyType,
typename ValueType>
117 int count(
const KeyType& key)
const {
return map_.count(key); }
124 if constexpr (std::is_same_v<ValueType, ffi::Any>) {
127 return map_[key].template cast<ValueType>();
136 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 ffi::Any & 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:105
const AttrRegistryMapContainerMap< KeyType > & map_
The internal map field.
Definition: attr_registry_map.h:140
ValueType get(const KeyType &key, ValueType def_value) const
get the corresponding value element at key with default value.
Definition: attr_registry_map.h:136
int count(const KeyType &key) const
Check if the map has op as key.
Definition: attr_registry_map.h:117
ValueType operator[](const KeyType &key) const
get the corresponding value element at key.
Definition: attr_registry_map.h:123
AttrRegistryMap(const AttrRegistryMapContainerMap< KeyType > &map)
constructor
Definition: attr_registry_map.h:111
Definition: instruction.h:30
Helper structure to register operators.
Definition: op.h:172
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:37