tvm
Classes | Namespaces | Macros | Functions
attrs.h File Reference

Helpers for attribute objects. More...

#include <dmlc/common.h>
#include <tvm/ir/expr.h>
#include <tvm/node/structural_equal.h>
#include <tvm/node/structural_hash.h>
#include <tvm/runtime/packed_func.h>
#include <functional>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>
Include dependency graph for attrs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tvm::AttrError
 Error thrown during attribute checking. More...
 
class  tvm::AttrFieldInfoNode
 Information about attribute fields in string representations. More...
 
class  tvm::AttrFieldInfo
 AttrFieldInfo. More...
 
class  tvm::BaseAttrsNode
 Base class of all attribute class. More...
 
class  tvm::Attrs
 Managed reference to BaseAttrsNode. More...
 
class  tvm::DictAttrsNode
 Specialized attribute type that is backed by a map. The DictAttrsNode implements the Attrs behavior, its fields are directly accessible via object.field_name like other normal nodes. More...
 
class  tvm::DictAttrs
 Managed reference to DictAttrsNode. More...
 
struct  tvm::detail::AttrNopEntry
 
class  tvm::detail::AttrNormalVisitor
 
class  tvm::detail::AttrsSEqualVisitor
 
class  tvm::detail::AttrsSHashVisitor
 
struct  tvm::detail::AttrInitEntry< T >
 
class  tvm::detail::AttrInitVisitor< FFind >
 
struct  tvm::detail::TypeName< T >
 Helper struct to get the type name known to tvm. More...
 
struct  tvm::detail::TypeName< int >
 
struct  tvm::detail::TypeName< int64_t >
 
struct  tvm::detail::TypeName< uint64_t >
 
struct  tvm::detail::TypeName< DataType >
 
struct  tvm::detail::TypeName< bool >
 
struct  tvm::detail::TypeName< void * >
 
struct  tvm::detail::TypeName< double >
 
class  tvm::detail::AttrDocEntry
 
class  tvm::detail::AttrDocVisitor
 
class  tvm::detail::AttrExistVisitor
 
struct  tvm::detail::AttrTriggerNonDefaultEntry< T >
 
class  tvm::detail::AttrNonDefaultVisitor
 
class  tvm::AttrsNode< DerivedType >
 The base class of the all the Use "curiously recurring template pattern". More...
 

Namespaces

 tvm
 runtime implementation for LibTorch/TorchScript.
 
 tvm::detail
 

Macros

#define TVM_DECLARE_ATTRS(ClassName, TypeKey)
 Declare an attribute function. More...
 
#define TVM_ATTR_FIELD(FieldName)   _tvm_fvisit(#FieldName, &FieldName)
 Declare an attribute field. More...
 

Functions

template<typename TObjectRef >
TObjectRef tvm::NullValue ()
 Create a NodeRef type that represents null. More...
 
template<>
DataType tvm::NullValue< DataType > ()
 
template<typename TAttrs >
TAttrs tvm::AttrsWithDefaultValues ()
 Create an Attr object with all default values. More...
 
DictAttrs tvm::WithAttrs (DictAttrs attrs, Map< String, ObjectRef > new_attrs)
 Copy the DictAttrs, but overrides attributes with the entries from attrs. More...
 
DictAttrs tvm::WithAttr (DictAttrs attrs, String key, ObjectRef value)
 Copy the DictAttrs, but overrides a single attribute. More...
 
DictAttrs tvm::WithAttr (DictAttrs attrs, const std::string &key, ObjectRef value)
 
DictAttrs tvm::WithoutAttr (DictAttrs attrs, const std::string &key)
 Copy the DictAttrs, but without a specific attribute. More...
 
template<typename TFunc >
TFunc tvm::WithAttr (TFunc input, const std::string &attr_key, ObjectRef attr_value)
 Copy the function or module, but overrides the attribute value key with the value. More...
 
template<typename TFunc >
TFunc tvm::WithAttrs (TFunc input, Map< String, ObjectRef > attrs)
 Copy the function or module, but overrides the attributes with the entries from attrs. More...
 
template<typename TFunc >
TFunc tvm::WithoutAttr (TFunc input, const std::string &attr_key)
 Copy the function or module, but removes the specified attribute. More...
 
template<typename T >
void tvm::detail::SetValue (T *ptr, const TVMArgValue &val)
 
template<typename T >
void tvm::detail::SetIntValue (T *ptr, const TVMArgValue &val)
 
template<>
void tvm::detail::SetValue< DataType > (DataType *ptr, const TVMArgValue &val)
 
template<>
void tvm::detail::SetValue< double > (double *ptr, const TVMArgValue &val)
 
template<>
void tvm::detail::SetValue< int > (int *ptr, const TVMArgValue &val)
 
template<>
void tvm::detail::SetValue< int64_t > (int64_t *ptr, const TVMArgValue &val)
 
template<>
void tvm::detail::SetValue< uint64_t > (uint64_t *ptr, const TVMArgValue &val)
 
template<>
void tvm::detail::SetValue< bool > (bool *ptr, const TVMArgValue &val)
 
template<typename FFind >
AttrInitVisitor< FFind > tvm::detail::CreateInitVisitor (const char *type_key, FFind ffind)
 

Detailed Description

Helpers for attribute objects.

This module enables declaration of named attributes which support default value setup and bound checking.

struct MyAttrs : public tvm::AttrsNode<MyAttrs> {
float learning_rate;
int num_hidden;
String name;
// declare attribute fields in header file
TVM_DECLARE_ATTRS(MyAttrs, "attrs.MyAttrs") {
TVM_ATTR_FIELD(num_hidden).set_lower_bound(1);
TVM_ATTR_FIELD(learning_rate).set_default(0.01f);
TVM_ATTR_FIELD(name).set_default("hello");
}
};
// register it in cc file
The base class of the all the Use "curiously recurring template pattern".
Definition: attrs.h:870
#define TVM_ATTR_FIELD(FieldName)
Declare an attribute field.
Definition: attrs.h:76
#define TVM_DECLARE_ATTRS(ClassName, TypeKey)
Declare an attribute function.
Definition: attrs.h:66
#define TVM_REGISTER_NODE_TYPE(TypeName)
Register a node type to object registry and reflection registry.
Definition: reflection.h:275
See also
AttrsNode, TVM_DECLARE_ATTRS, TVM_ATTR_FIELD

Macro Definition Documentation

◆ TVM_ATTR_FIELD

#define TVM_ATTR_FIELD (   FieldName)    _tvm_fvisit(#FieldName, &FieldName)

Declare an attribute field.

Parameters
FieldNameThe field name.

◆ TVM_DECLARE_ATTRS

#define TVM_DECLARE_ATTRS (   ClassName,
  TypeKey 
)
Value:
static constexpr const char* _type_key = TypeKey; \
TVM_DECLARE_FINAL_OBJECT_INFO(ClassName, ::tvm::BaseAttrsNode) \
template <typename FVisit> \
void _tvm_VisitAttrs(FVisit& _tvm_fvisit)
Base class of all attribute class.
Definition: attrs.h:139

Declare an attribute function.

Parameters
ClassNameThe name of the class.
TypeKeyThe type key to be used by the TVM node system.