matx.runtime.module module

Runtime Module namespace.

class matx.runtime.module.Module(handle)[源代码]

基类:object

Runtime Module.

__init__(handle)[源代码]
export_library(file_name, fcompile=None, addons=None, **kwargs)[源代码]

Export the module and its imported device code one library.

This function only works on host llvm modules. It will pack all the imported modules

参数:
  • file_name (str) – The name of the shared library.

  • fcompile (function(target, file_list, kwargs), optional) – Compilation function to use create dynamic library. If fcompile has attribute object_format, will compile host library to that format. Otherwise, will use default format “o”.

  • kwargs (dict, optional) – Additional arguments passed to fcompile

get_function(name, query_imports=False)[源代码]

Get function from the module.

参数:
  • name (str) – The name of the function

  • query_imports (bool) – Whether also query modules imported by this module.

返回:

f – The result function.

返回类型:

matx.runtime.PackedFunc

get_source(fmt='')[源代码]

Get source code from module, if available.

参数:

fmt (str, optional) – The specified format.

返回:

source – The result source code.

返回类型:

str

handle
import_module(module)[源代码]

Add module to the import list of current one.

参数:

module (matx.runtime.Module) – The other module.

property imported_modules

Get imported modules

返回:

modules – The module

返回类型:

list of Module

save(file_name, fmt='')[源代码]

Save the module to file.

This do not save the dependent device modules. See also export_shared

参数:
  • file_name (str) – The name of the file.

  • fmt (str) – The format of the file.

参见

runtime.Module.export_library

export the module to shared library.

property type_key

Get type key of the module.

matx.runtime.module.load_module(path, fmt='')[源代码]

Load module from file.

参数:
  • path (str) – The path to the module file.

  • fmt (str, optional) – The format of the file, if not specified it will be inferred from suffix of the file.

返回:

module – The loaded module

返回类型:

runtime.Module

matx.runtime.module.system_lib()[源代码]

Get system-wide library module singleton.

System lib is a global module that contains self register functions in startup. Unlike normal dso modules which need to be loaded explicitly. It is useful in environments where dynamic loading api like dlopen is banned.

To build system lib function, simply specify target option `llvm --system-lib` The system lib will be available as long as the result code is linked by the program.

The system lib is intended to be linked and loaded during the entire life-cyle of the program. If you want dynamic loading features, use dso modules instead.

返回:

module – The system-wide library module.

返回类型:

runtime.Module