26 #ifndef TVM_RUNTIME_MODULE_H_ 27 #define TVM_RUNTIME_MODULE_H_ 38 #include <unordered_map> 114 TVM_DLL
static Module LoadFromFile(
const std::string& file_name,
const std::string& format =
"");
150 virtual const char* type_key()
const = 0;
175 virtual void SaveToFile(
const std::string& file_name,
const std::string& format);
183 virtual void SaveToBinary(dmlc::Stream* stream);
189 virtual std::string GetSource(
const std::string& format =
"");
194 virtual std::string GetFormat();
220 const PackedFunc* GetFuncFromEnv(
const std::string& name);
222 const std::vector<Module>&
imports()
const {
return imports_; }
245 virtual bool ImplementsFunction(
const String& name,
bool query_imports =
false);
249 static constexpr
const char* _type_key =
"runtime.Module";
256 friend class ModuleInternal;
262 std::unordered_map<std::string, std::shared_ptr<PackedFunc>> import_cache_;
310 out <<
"Module(type_key= ";
321 #endif // TVM_RUNTIME_MODULE_H_ std::ostream & operator<<(std::ostream &os, const ObjectRef &n)
Definition: repr_printer.h:97
constexpr const char * tvm_set_device
global function to set device
Definition: module.h:284
PackedFunc GetFunction(const std::string &name, bool query_imports=false)
Get packed function from current module by name.
Definition: packed_func.h:1945
void Import(Module other)
Import another module into this module.
Definition: module.h:301
A custom smart pointer for Object.
Definition: object.h:358
runtime::Module.
Definition: object.h:62
constexpr const char * tvm_lookup_linked_param
A PackedFunc that looks up linked parameters by storage_id.
Definition: module.h:294
bool RuntimeEnabled(const std::string &target)
Check if runtime module is enabled for target.
Runtime String container types.
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
virtual const char * type_key() const =0
bool IsDSOExportable() const
Returns true if this module is 'DSO exportable'.
Definition: module.h:232
Runtime memory management.
kBinarySerializable we can serialize the module to the stream of bytes. CUDA/OpenCL/JSON runtime are ...
Definition: module.h:56
base class of all object containers.
Definition: object.h:167
constexpr const char * tvm_dev_mblob_nbytes
Number of bytes of device module blob.
Definition: module.h:282
kDSOExportable we can export the module as DSO. A DSO exportable module (e.g., a CSourceModuleNode of...
Definition: module.h:70
friend class ModuleNode
Definition: module.h:117
constexpr const char * tvm_global_barrier_state
Auxiliary counter to global barrier.
Definition: module.h:286
constexpr const char * tvm_module_main
Placeholder for the module's entry function.
Definition: module.h:290
constexpr const char * tvm_prepare_global_barrier
Prepare the global barrier before kernels that uses global barrier.
Definition: module.h:288
std::vector< Module > imports_
The modules this module depend on.
Definition: module.h:258
Reference to string objects.
Definition: string.h:98
ModulePropertyMask
Property of runtime module We classify the property of runtime module into the following categories...
Definition: module.h:48
Base class of all object reference.
Definition: object.h:511
kRunnable we can run the module directly. LLVM/CUDA/JSON runtime, executors (e.g, virtual machine) ru...
Definition: module.h:62
Base container of module.
Definition: module.h:142
A managed object in the TVM runtime.
#define TVM_DECLARE_FINAL_OBJECT_INFO(TypeName, ParentType)
helper macro to declare type information in a final class.
Definition: object.h:671
const std::vector< Module > & imports() const
Definition: module.h:222
virtual int GetPropertyMask() const
Returns bitmap of property. By default, none of the property is set. Derived class can override this ...
Definition: module.h:229
ModuleNode * operator->()
Definition: module.h:303
Module container of TVM.
Definition: module.h:79
constexpr const char * tvm_dev_mblob
Global variable to store device module blob.
Definition: module.h:280
static Module LoadFromFile(const std::string &file_name, const std::string &format="")
Load a module from file.
constexpr const char * tvm_param_prefix
Prefix for parameter symbols emitted into the main program.
Definition: module.h:292
Packed function is a type-erased function. The arguments are passed by packed format.
Definition: packed_func.h:138
constexpr const char * tvm_entrypoint_suffix
Model entrypoint generated as an interface to the AOT function outside of TIR.
Definition: module.h:296
Module()
Definition: module.h:81
Object * get_mutable() const
Definition: object.h:576
Module(ObjectPtr< Object > n)
Definition: module.h:83
Type-erased function used across TVM API.
constexpr const char * tvm_get_c_metadata
A PackedFunc that retrieves exported metadata.
Definition: module.h:276
constexpr const char * tvm_module_ctx
Global variable to store module context.
Definition: module.h:278