26 #ifndef TVM_RUNTIME_MODULE_H_
27 #define TVM_RUNTIME_MODULE_H_
38 #include <unordered_map>
225 const std::vector<Module>&
imports()
const {
return imports_; }
257 static constexpr
const char* _type_key =
"runtime.Module";
264 friend class ModuleInternal;
270 std::unordered_map<std::string, std::shared_ptr<PackedFunc>> import_cache_;
316 out <<
"Module(type_key= ";
Base container of module.
Definition: module.h:142
virtual void SaveToFile(const String &file_name, const String &format)
Save the module to file.
const std::vector< Module > & imports() const
Definition: module.h:225
virtual PackedFunc GetFunction(const String &name, const ObjectPtr< Object > &sptr_to_self)=0
Get a PackedFunc from module.
virtual const char * type_key() const =0
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,...
void Import(Module other)
Import another module into this module.
void ClearImports()
Clear all imports of the module.
Definition: module.h:222
virtual String GetSource(const String &format="")
Get the source code of module, when available.
bool IsDSOExportable() const
Returns true if this module is 'DSO exportable'.
Definition: module.h:235
const PackedFunc * GetFuncFromEnv(const String &name)
Get a function from current environment The environment includes all the imports as well as Global fu...
TVM_DECLARE_FINAL_OBJECT_INFO(ModuleNode, Object)
bool IsBinarySerializable() const
Returns true if this module is 'Binary Serializable'.
Definition: module.h:240
virtual void SaveToBinary(dmlc::Stream *stream)
Save the module to binary stream.
virtual int GetPropertyMask() const
Returns bitmap of property. By default, none of the property is set. Derived class can override this ...
Definition: module.h:232
PackedFunc GetFunction(const String &name, bool query_imports=false)
Get packed function from current module by name.
std::vector< Module > imports_
The modules this module depend on.
Definition: module.h:266
virtual String GetFormat()
Get the format of the module, when available.
virtual ~ModuleNode()=default
virtual destructor
Module container of TVM.
Definition: module.h:79
static Module LoadFromFile(const String &file_name, const String &format="")
Load a module from file.
PackedFunc GetFunction(const String &name, bool query_imports=false)
Get packed function from current module by name.
Definition: packed_func.h:2462
ModuleNode * operator->()
Definition: module.h:309
friend class ModuleNode
Definition: module.h:117
Module(ObjectPtr< Object > n)
Definition: module.h:83
Module()
Definition: module.h:81
void Import(Module other)
Import another module into this module.
Definition: module.h:307
A custom smart pointer for Object.
Definition: object.h:362
Base class of all object reference.
Definition: object.h:519
const Object * get() const
Definition: object.h:554
Object * get_mutable() const
Definition: object.h:607
base class of all object containers.
Definition: object.h:171
Packed function is a type-erased function. The arguments are passed by packed format.
Definition: packed_func.h:141
Reference to string objects.
Definition: string.h:98
constexpr const char * tvm_entrypoint_suffix
Model entrypoint generated as an interface to the AOT function outside of TIR.
Definition: module.h:302
constexpr const char * tvm_lookup_linked_param
A PackedFunc that looks up linked parameters by storage_id.
Definition: module.h:300
constexpr const char * tvm_dev_mblob
Global variable to store device module blob.
Definition: module.h:288
constexpr const char * tvm_set_device
global function to set device
Definition: module.h:290
constexpr const char * tvm_module_main
Placeholder for the module's entry function.
Definition: module.h:296
constexpr const char * tvm_global_barrier_state
Auxiliary counter to global barrier.
Definition: module.h:292
constexpr const char * tvm_param_prefix
Prefix for parameter symbols emitted into the main program.
Definition: module.h:298
constexpr const char * tvm_module_ctx
Global variable to store module context.
Definition: module.h:286
constexpr const char * tvm_prepare_global_barrier
Prepare the global barrier before kernels that uses global barrier.
Definition: module.h:294
constexpr const char * tvm_get_c_metadata
A PackedFunc that retrieves exported metadata.
Definition: module.h:284
ModulePropertyMask
Property of runtime module We classify the property of runtime module into the following categories.
Definition: module.h:48
@ kRunnable
kRunnable we can run the module directly. LLVM/CUDA/JSON runtime, executors (e.g, virtual machine) ru...
Definition: module.h:62
@ kBinarySerializable
kBinarySerializable we can serialize the module to the stream of bytes. CUDA/OpenCL/JSON runtime are ...
Definition: module.h:56
@ kDSOExportable
kDSOExportable we can export the module as DSO. A DSO exportable module (e.g., a CSourceModuleNode of...
Definition: module.h:70
bool RuntimeEnabled(const String &target)
Check if runtime module is enabled for target.
std::ostream & operator<<(std::ostream &os, const ObjectRef &n)
Definition: repr_printer.h:97
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
A managed object in the TVM runtime.
Type-erased function used across TVM API.
Runtime memory management.
Runtime String container types.
@ kRuntimeModule
runtime::Module.
Definition: object.h:62