Class Module#

Inheritance Relationships#

Base Type#

Class Documentation#

class Module : public tvm::ffi::ObjectRef#

Reference to module object.

When invoking a function on a ModuleObj, such as GetFunction, use operator-> to get the ModuleObj pointer and invoke the member functions.

ffi::Module mod = ffi::Module::LoadFromFile("path/to/module.so");
ffi::Function func = mod->GetFunction(name);

Public Types

enum ModulePropertyMask#

Property of ffi::Module.

Values:

enumerator kBinarySerializable#

The module can be serialized to bytes.

This prooperty indicates that module implements SaveToBytes. The system also registers a GlobalDef function ffi.Module.load_from_bytes.<kind> with signature (Bytes) -> Module.

enumerator kRunnable#

The module can directly get runnable functions.

This property indicates that module implements GetFunction that returns runnable ffi::Functions.

enumerator kCompilationExportable#

The module can be exported to a object file or source file that then be compiled.

This property indicates that module implements WriteToFile with a given format that can be queried by GetLibExportFormat.

Examples include modules that can be exported to .o, .cc, .cu files.

Such modules can be exported, compiled and loaded back as a dynamic library module.

Public Functions

inline explicit Module(ObjectPtr<ModuleObj> ptr)#

Constructor from ObjectPtr<ModuleObj>.

Parameters:

ptr – The object pointer.

Public Static Functions

static Module LoadFromFile(const String &file_name)#

Load a module from file.

Note

This function won’t load the import relationship. Re-create import relationship by calling Import.

Parameters:

file_name – The name of the host function module.

static void VisitContextSymbols(const ffi::TypedFunction<void(String, void*)> &callback)#

Query context symbols that is registered via TVMEnvRegisterSymbols.

Note

This helper can be used to implement custom Module that needs to access context symbols.

Parameters:

callback – The callback to be called with the symbol name and address.