Managed reference to DictAttrsObj.
More...
#include <attrs.h>
|
| | DictAttrs (ffi::Map< ffi::String, Any > dict={}) |
| | Construct a DictAttrs backed by DictAttrsObj.
|
| |
| | DictAttrs (DictAttrs &&other) noexcept |
| | Move constructor that leaves the source in a defined-but-empty state rather than null, preserving the NOTNULLABLE invariant even after std::move.
|
| |
| DictAttrs & | operator= (DictAttrs &&other) noexcept |
| | Move assignment that leaves the source in a defined-but-empty state rather than null, preserving the NOTNULLABLE invariant even after std::move.
|
| |
| | DictAttrs (const DictAttrs &other)=default |
| |
| DictAttrs & | operator= (const DictAttrs &other)=default |
| |
| template<typename TObjectRef > |
| ffi::Optional< TObjectRef > | GetAttr (const std::string &attr_key, ffi::Optional< TObjectRef > default_value=ffi::Optional< TObjectRef >(std::nullopt)) const |
| | Get a function attribute.
|
| |
| template<typename T > |
| ffi::Optional< T > | GetAttr (ffi::reflection::AttrKey< T > key, ffi::Optional< typename ffi::reflection::AttrKey< T >::ValueType > default_value=std::nullopt) const |
| | Get an attribute with its value type deduced only from the key.
|
| |
| template<typename T > |
| ffi::Optional< T > | GetAttr (ffi::reflection::AttrKey< T > key, typename ffi::reflection::AttrKey< T >::ValueType default_value) const |
| | Accept a default convertible to the key's value type.
|
| |
| template<typename TObjectRef > |
| ffi::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.
|
| |
| | DictAttrs (::tvm::ffi::UnsafeInit tag) |
| |
| __PtrType | operator-> () const |
| |
| __PtrType | get () const |
| |
| | TVM_DEFINE_OBJECT_REF_COW_METHOD (DictAttrsObj) |
| |
| | Attrs (ffi::ObjectPtr< AttrsObj > n) |
| |
| | TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE (Attrs, ffi::ObjectRef, AttrsObj) |
| |
Managed reference to DictAttrsObj.
- See also
- DictAttrsObj.
- Note
- DictAttrs is NOTNULLABLE: every instance must hold a backing DictAttrsObj. The class enforces this end-to-end by:
- the default constructor (no args) allocating an empty backing,
- the copy/move ctors and assignments leaving the moved-from instance in a defined-but-empty state rather than null,
- the FFI type traits rejecting None at deserialization boundaries (since
_type_is_nullable == false), and
- the FFI lambda for
ir.IRModule explicitly normalizing a missing/None attrs argument to DictAttrs() before forwarding to the C++ constructor. Callers (including third-party code via templates like WithAttr) can therefore rely on attrs->dict being safe to dereference without a .defined() guard.
◆ __PtrType
◆ ContainerType
◆ DictAttrs() [1/4]
| tvm::DictAttrs::DictAttrs |
( |
ffi::Map< ffi::String, Any > |
dict = {} | ) |
|
|
inlineexplicit |
◆ DictAttrs() [2/4]
| tvm::DictAttrs::DictAttrs |
( |
DictAttrs && |
other | ) |
|
|
inlinenoexcept |
Move constructor that leaves the source in a defined-but-empty state rather than null, preserving the NOTNULLABLE invariant even after std::move.
◆ DictAttrs() [3/4]
| tvm::DictAttrs::DictAttrs |
( |
const DictAttrs & |
other | ) |
|
|
default |
◆ DictAttrs() [4/4]
| tvm::DictAttrs::DictAttrs |
( |
::tvm::ffi::UnsafeInit |
tag | ) |
|
|
inlineexplicit |
◆ get()
◆ GetAttr() [1/4]
template<typename TObjectRef >
| ffi::Optional< TObjectRef > tvm::DictAttrs::GetAttr |
( |
const std::string & |
attr_key, |
|
|
ffi::Optional< TObjectRef > |
default_value = ffi::Optional<TObjectRef>(std::nullopt) |
|
) |
| 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<int64_t>("AttrKey", 0);
}
Managed reference to BaseFuncObj.
Definition function.h:202
◆ GetAttr() [2/4]
template<typename TObjectRef >
| ffi::Optional< TObjectRef > tvm::DictAttrs::GetAttr |
( |
const std::string & |
attr_key, |
|
|
TObjectRef |
default_value |
|
) |
| const |
|
inline |
◆ GetAttr() [3/4]
template<typename T >
| ffi::Optional< T > tvm::DictAttrs::GetAttr |
( |
ffi::reflection::AttrKey< T > |
key, |
|
|
ffi::Optional< typename ffi::reflection::AttrKey< T >::ValueType > |
default_value = std::nullopt |
|
) |
| const |
|
inline |
Get an attribute with its value type deduced only from the key.
- Parameters
-
| key | The typed attribute key. |
| default_value | Value returned only when the key is absent. |
- Returns
- The attribute or default, with the same conversions as the name-based getter.
◆ GetAttr() [4/4]
template<typename T >
| ffi::Optional< T > tvm::DictAttrs::GetAttr |
( |
ffi::reflection::AttrKey< T > |
key, |
|
|
typename ffi::reflection::AttrKey< T >::ValueType |
default_value |
|
) |
| const |
|
inline |
Accept a default convertible to the key's value type.
◆ 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)) {
}
}
◆ operator->()
| __PtrType tvm::DictAttrs::operator-> |
( |
| ) |
const |
|
inline |
◆ operator=() [1/2]
◆ operator=() [2/2]
Move assignment that leaves the source in a defined-but-empty state rather than null, preserving the NOTNULLABLE invariant even after std::move.
◆ TVM_DEFINE_OBJECT_REF_COW_METHOD()
| tvm::DictAttrs::TVM_DEFINE_OBJECT_REF_COW_METHOD |
( |
DictAttrsObj |
| ) |
|
◆ _type_is_nullable
| constexpr bool tvm::DictAttrs::_type_is_nullable = false |
|
staticconstexpr |
The documentation for this class was generated from the following file:
- 3rdparty/tvm-tirx/include/tvm/ir/attrs.h