Managed reference to DictAttrsNode.
More...
#include <attrs.h>
|
| DictAttrs (Map< String, ObjectRef > dict={}) |
| Consruct a Attrs backed by DictAttrsNode. More...
|
|
template<typename TObjectRef > |
Optional< TObjectRef > | GetAttr (const std::string &attr_key, Optional< TObjectRef > default_value=Optional< TObjectRef >(nullptr)) const |
| Get a function attribute. More...
|
|
template<typename TObjectRef > |
Optional< TObjectRef > | GetAttr (const std::string &attr_key, TObjectRef default_value) const |
|
bool | HasNonzeroAttr (const std::string &attr_key) const |
| Check whether the function has an non-zero integer attr. More...
|
|
| TVM_DEFINE_OBJECT_REF_METHODS_WITHOUT_DEFAULT_CONSTRUCTOR (DictAttrs, Attrs, DictAttrsNode) |
|
| TVM_DEFINE_OBJECT_REF_COW_METHOD (DictAttrsNode) |
|
| TVM_DEFINE_OBJECT_REF_METHODS (Attrs, ObjectRef, BaseAttrsNode) |
|
| ObjectRef ()=default |
| default constructor More...
|
|
| ObjectRef (ObjectPtr< Object > data) |
| Constructor from existing object ptr. More...
|
|
bool | same_as (const ObjectRef &other) const |
| Comparator. More...
|
|
bool | operator== (const ObjectRef &other) const |
| Comparator. More...
|
|
bool | operator!= (const ObjectRef &other) const |
| Comparator. More...
|
|
bool | operator< (const ObjectRef &other) const |
| Comparator. More...
|
|
bool | defined () const |
|
const Object * | get () const |
|
const Object * | operator-> () const |
|
bool | unique () const |
|
int | use_count () const |
|
template<typename ObjectType , typename = std::enable_if_t<std::is_base_of_v<Object, ObjectType>>> |
const ObjectType * | as () const |
| Try to downcast the internal Object to a raw pointer of a corresponding type. More...
|
|
template<typename ObjectRefType , typename = std::enable_if_t<std::is_base_of_v<ObjectRef, ObjectRefType>>> |
Optional< ObjectRefType > | as () const |
| Try to downcast the ObjectRef to a Optional<T> of the requested type. More...
|
|
Managed reference to DictAttrsNode.
- See also
- DictAttrsNode.
◆ DictAttrs()
◆ GetAttr() [1/2]
template<typename TObjectRef >
Optional<TObjectRef> tvm::DictAttrs::GetAttr |
( |
const std::string & |
attr_key, |
|
|
Optional< TObjectRef > |
default_value = Optional<TObjectRef>(nullptr) |
|
) |
| const |
|
inline |
Get a function attribute.
- Parameters
-
attr_key | The attribute key. |
default_value | The default value if the key does not exist, defaults to nullptr. |
- Returns
- The result
- Template Parameters
-
TOBjectRef | the expected object type. |
- Exceptions
-
Error | if the key exists but the value does not match TObjectRef |
void GetAttrExample(const BaseFunc& f) {
auto value = f->attrs.GetAttr<Integer>("AttrKey", 0);
}
◆ GetAttr() [2/2]
template<typename TObjectRef >
Optional<TObjectRef> tvm::DictAttrs::GetAttr |
( |
const std::string & |
attr_key, |
|
|
TObjectRef |
default_value |
|
) |
| const |
|
inline |
◆ HasNonzeroAttr()
bool tvm::DictAttrs::HasNonzeroAttr |
( |
const std::string & |
attr_key | ) |
const |
|
inline |
Check whether the function has an non-zero integer attr.
This function can be used to check whether an optional attribute mark(e.g. inline) exists.
- Parameters
-
attr_key | The key to the attribute. |
- Returns
- The check result.
void HasNonzeroAttrExample(const BaseFunc& f) {
if (f->HasNonzeroAttr(attr::kInline)) {
}
}
◆ TVM_DEFINE_OBJECT_REF_COW_METHOD()
tvm::DictAttrs::TVM_DEFINE_OBJECT_REF_COW_METHOD |
( |
DictAttrsNode |
| ) |
|
◆ TVM_DEFINE_OBJECT_REF_METHODS_WITHOUT_DEFAULT_CONSTRUCTOR()
The documentation for this class was generated from the following file: