tvm
|
Base container of module. More...
#include <module.h>
Public Member Functions | |
virtual | ~ModuleNode ()=default |
virtual destructor More... | |
virtual const char * | type_key () const =0 |
virtual PackedFunc | GetFunction (const String &name, const ObjectPtr< Object > &sptr_to_self)=0 |
Get a PackedFunc from module. More... | |
virtual void | SaveToFile (const String &file_name, const String &format) |
Save the module to file. More... | |
virtual void | SaveToBinary (dmlc::Stream *stream) |
Save the module to binary stream. More... | |
virtual String | GetSource (const String &format="") |
Get the source code of module, when available. More... | |
virtual String | GetFormat () |
Get the format of the module, when available. More... | |
PackedFunc | GetFunction (const String &name, bool query_imports=false) |
Get packed function from current module by name. More... | |
void | Import (Module other) |
Import another module into this module. More... | |
const PackedFunc * | GetFuncFromEnv (const String &name) |
Get a function from current environment The environment includes all the imports as well as Global functions. More... | |
void | ClearImports () |
Clear all imports of the module. More... | |
const std::vector< Module > & | imports () const |
virtual int | GetPropertyMask () const |
Returns bitmap of property. By default, none of the property is set. Derived class can override this function and set its own property. More... | |
bool | IsDSOExportable () const |
Returns true if this module is 'DSO exportable'. More... | |
bool | IsBinarySerializable () const |
Returns true if this module is 'Binary Serializable'. More... | |
virtual bool | ImplementsFunction (const String &name, bool query_imports=false) |
Returns true if this module has a definition for a function of name . If query_imports is true, also search in any imported modules. More... | |
TVM_DECLARE_FINAL_OBJECT_INFO (ModuleNode, Object) | |
Public Member Functions inherited from tvm::runtime::Object | |
uint32_t | type_index () const |
std::string | GetTypeKey () const |
size_t | GetTypeKeyHash () const |
template<typename TargetType > | |
bool | IsInstance () const |
bool | unique () const |
Object () | |
Object (const Object &other) | |
Object (Object &&other) | |
Object & | operator= (const Object &other) |
Object & | operator= (Object &&other) |
Static Public Attributes | |
static constexpr const uint32_t | _type_index = TypeIndex::kRuntimeModule |
static constexpr const char * | _type_key = "runtime.Module" |
Static Public Attributes inherited from tvm::runtime::Object | |
static constexpr const char * | _type_key = "runtime.Object" |
static constexpr bool | _type_final = false |
static constexpr uint32_t | _type_child_slots = 0 |
static constexpr bool | _type_child_slots_can_overflow = true |
static constexpr bool | _type_has_method_visit_attrs = true |
static constexpr bool | _type_has_method_sequal_reduce = false |
static constexpr bool | _type_has_method_shash_reduce = false |
static constexpr uint32_t | _type_index = TypeIndex::kDynamic |
Protected Attributes | |
std::vector< Module > | imports_ |
The modules this module depend on. More... | |
Protected Attributes inherited from tvm::runtime::Object | |
uint32_t | type_index_ {0} |
Type index(tag) that indicates the type of the object. More... | |
RefCounterType | ref_counter_ {0} |
The internal reference counter. More... | |
FDeleter | deleter_ = nullptr |
deleter of this object to enable customized allocation. If the deleter is nullptr, no deletion will be performed. The creator of the object must always set the deleter field properly. More... | |
Friends | |
class | Module |
class | ModuleInternal |
Additional Inherited Members | |
Public Types inherited from tvm::runtime::Object | |
typedef void(* | FDeleter) (Object *self) |
Object deleter. More... | |
using | RefCounterType = std::atomic< int32_t > |
Static Public Member Functions inherited from tvm::runtime::Object | |
static std::string | TypeIndex2Key (uint32_t tindex) |
Get the type key of the corresponding index from runtime. More... | |
static size_t | TypeIndex2KeyHash (uint32_t tindex) |
Get the type key hash of the corresponding index from runtime. More... | |
static uint32_t | TypeKey2Index (const std::string &key) |
Get the type index of the corresponding key from runtime. More... | |
static uint32_t | _GetOrAllocRuntimeTypeIndex () |
static uint32_t | RuntimeTypeIndex () |
Protected Member Functions inherited from tvm::runtime::Object | |
void | IncRef () |
developer function, increases reference counter. More... | |
void | DecRef () |
developer function, decrease reference counter. More... | |
Static Protected Member Functions inherited from tvm::runtime::Object | |
static uint32_t | GetOrAllocRuntimeTypeIndex (const std::string &key, uint32_t static_tindex, uint32_t parent_tindex, uint32_t type_child_slots, bool type_child_slots_can_overflow) |
Get the type index using type key. More... | |
Base container of module.
Please subclass ModuleNode to create a specific runtime module.
|
virtualdefault |
virtual destructor
|
inline |
Clear all imports of the module.
|
virtual |
Get the format of the module, when available.
const PackedFunc* tvm::runtime::ModuleNode::GetFuncFromEnv | ( | const String & | name | ) |
Get a function from current environment The environment includes all the imports as well as Global functions.
name | name of the function. |
PackedFunc tvm::runtime::ModuleNode::GetFunction | ( | const String & | name, |
bool | query_imports = false |
||
) |
Get packed function from current module by name.
name | The name of the function. |
query_imports | Whether also query dependency modules. |
|
pure virtual |
Get a PackedFunc from module.
The PackedFunc may not be fully initialized, there might still be first time running overhead when executing the function on certain devices. For benchmarking, use prepare to eliminate
name | the name of the function. |
sptr_to_self | The ObjectPtr that points to this module node. |
Implemented in tvm::runtime::vm::VirtualMachine.
|
inlinevirtual |
Returns bitmap of property. By default, none of the property is set. Derived class can override this function and set its own property.
Reimplemented in tvm::runtime::vm::VirtualMachine, tvm::runtime::vm::Executable, and tvm::runtime::relax_vm::Executable.
Get the source code of module, when available.
format | Format of the source code, can be empty by default. |
|
virtual |
Returns true if this module has a definition for a function of name
. If query_imports
is true, also search in any imported modules.
Note that even if this function returns true the corresponding GetFunction
result may be nullptr if the function is not yet callable without further compilation.
The default implementation just checkis if GetFunction
is non-null.
void tvm::runtime::ModuleNode::Import | ( | Module | other | ) |
Import another module into this module.
other | The module to be imported. |
|
inline |
|
inline |
Returns true if this module is 'Binary Serializable'.
|
inline |
Returns true if this module is 'DSO exportable'.
|
virtual |
Save the module to binary stream.
stream | The binary stream to save to. |
Reimplemented in tvm::runtime::vm::Executable, and tvm::runtime::relax_vm::Executable.
|
virtual |
Save the module to file.
file_name | The file to be saved to. |
format | The format of the file. |
Reimplemented in tvm::runtime::vm::Executable, and tvm::runtime::relax_vm::Executable.
tvm::runtime::ModuleNode::TVM_DECLARE_FINAL_OBJECT_INFO | ( | ModuleNode | , |
Object | |||
) |
|
pure virtual |
Implemented in tvm::runtime::vm::VirtualMachine.
|
friend |
|
friend |
|
staticconstexpr |
|
staticconstexpr |
|
protected |
The modules this module depend on.