|
tvm
|
Virtual function table to support IR/AST node reflection. More...
#include <reflection.h>
Classes | |
| class | Registry |
| Registry of a reflection table. More... | |
Public Types | |
| typedef void(* | FVisitAttrs) (Object *self, AttrVisitor *visitor) |
| Visitor function. More... | |
| typedef bool(* | FSEqualReduce) (const Object *self, const Object *other, SEqualReducer equal) |
| Equality comparison function. More... | |
| typedef void(* | FSHashReduce) (const Object *self, SHashReducer hash_reduce) |
| Structural hash reduction function. More... | |
| typedef ObjectPtr< Object >(* | FCreate) (const std::string &repr_bytes) |
| creator function. More... | |
| typedef std::string(* | FReprBytes) (const Object *self) |
| Function to get a byte representation that can be used to recover the object. More... | |
Public Member Functions | |
| void | VisitAttrs (Object *self, AttrVisitor *visitor) const |
| Dispatch the VisitAttrs function. More... | |
| bool | GetReprBytes (const Object *self, std::string *repr_bytes) const |
| Get repr bytes if any. More... | |
| bool | SEqualReduce (const Object *self, const Object *other, SEqualReducer equal) const |
| Dispatch the SEqualReduce function. More... | |
| void | SHashReduce (const Object *self, SHashReducer hash_reduce) const |
| Dispatch the SHashReduce function. More... | |
| ObjectPtr< Object > | CreateInitObject (const std::string &type_key, const std::string &repr_bytes="") const |
| Create an initial object using default constructor by type_key and global key. More... | |
| ObjectRef | CreateObject (const std::string &type_key, const runtime::TVMArgs &kwargs) |
| Create an object by giving kwargs about its fields. More... | |
| ObjectRef | CreateObject (const std::string &type_key, const Map< String, ObjectRef > &kwargs) |
| Create an object by giving kwargs about its fields. More... | |
| runtime::TVMRetValue | GetAttr (Object *self, const String &attr_name) const |
| Get an field object by the attr name. More... | |
| std::vector< std::string > | ListAttrNames (Object *self) const |
| List all the fields in the object. More... | |
| template<typename T , typename TraitName > | |
| Registry | Register () |
Static Public Member Functions | |
| static ReflectionVTable * | Global () |
Virtual function table to support IR/AST node reflection.
Functions are stored in columnar manner. Each column is a vector indexed by Object's type_index.
creator function.
| repr_bytes | Repr bytes to create the object. If this is not empty then FReprBytes must be defined for the object. |
| typedef std::string(* tvm::ReflectionVTable::FReprBytes) (const Object *self) |
Function to get a byte representation that can be used to recover the object.
| node | The node pointer. |
| typedef bool(* tvm::ReflectionVTable::FSEqualReduce) (const Object *self, const Object *other, SEqualReducer equal) |
Equality comparison function.
| typedef void(* tvm::ReflectionVTable::FSHashReduce) (const Object *self, SHashReducer hash_reduce) |
Structural hash reduction function.
| typedef void(* tvm::ReflectionVTable::FVisitAttrs) (Object *self, AttrVisitor *visitor) |
Visitor function.
| ObjectPtr<Object> tvm::ReflectionVTable::CreateInitObject | ( | const std::string & | type_key, |
| const std::string & | repr_bytes = "" |
||
| ) | const |
Create an initial object using default constructor by type_key and global key.
| type_key | The type key of the object. |
| repr_bytes | Bytes representation of the object if any. |
| ObjectRef tvm::ReflectionVTable::CreateObject | ( | const std::string & | type_key, |
| const runtime::TVMArgs & | kwargs | ||
| ) |
Create an object by giving kwargs about its fields.
| type_key | The type key. |
| kwargs | the arguments in format key1, value1, ..., key_n, value_n. |
| ObjectRef tvm::ReflectionVTable::CreateObject | ( | const std::string & | type_key, |
| const Map< String, ObjectRef > & | kwargs | ||
| ) |
Create an object by giving kwargs about its fields.
| type_key | The type key. |
| kwargs | The field arguments. |
| runtime::TVMRetValue tvm::ReflectionVTable::GetAttr | ( | Object * | self, |
| const String & | attr_name | ||
| ) | const |
Get an field object by the attr name.
| self | The pointer to the object. |
| attr_name | The name of the field. |
|
inline |
Get repr bytes if any.
| self | The pointer to the object. |
| repr_bytes | The output repr bytes, can be null, in which case the function simply queries if the ReprBytes function exists for the type. |
|
static |
| std::vector<std::string> tvm::ReflectionVTable::ListAttrNames | ( | Object * | self | ) | const |
List all the fields in the object.
|
inline |
| bool tvm::ReflectionVTable::SEqualReduce | ( | const Object * | self, |
| const Object * | other, | ||
| SEqualReducer | equal | ||
| ) | const |
Dispatch the SEqualReduce function.
| self | The pointer to the object. |
| other | The pointer to another object to be compared. |
| equal | The equality comparator. |
| void tvm::ReflectionVTable::SHashReduce | ( | const Object * | self, |
| SHashReducer | hash_reduce | ||
| ) | const |
Dispatch the SHashReduce function.
| self | The pointer to the object. |
| hash_reduce | The hash reducer. |
|
inline |
Dispatch the VisitAttrs function.
| self | The pointer to the object. |
| visitor | The attribute visitor. |
1.8.13