tvm_tirx.codegen.Executable

tvm_tirx.codegen.Executable#

class tvm_tirx.codegen.Executable(mod)#

Bases: object

The executable object generated by tvm_tirx.compile.

Parameters:

mod (Module)

jit(*, fcompile=None, addons=None, force_recompile=False, **kwargs)#

Just-in-time compile and link the modules.

The Executable returned by tvm_tirx.compile may not be directly runnable as they may contain CUDA source files and objects that are yet to be compiled and linked. This function helps to create a tvm_ffi.Module for these cases.

Parameters:
  • fcompile (function(target, file_list, kwargs), optional) – The compilation function to use create the final library object during

  • addons (list of str, optional) – Additional object files to link against.

  • force_recompile (bool, optional) – If True, force a recompile of the module.

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

Returns:

rt_mod (tvm_ffi.Module) – A runnable runtime module that can be passed to VirtualMachine.

Return type:

Module

Examples

ex = tvm_tirx.compile(mod, target)
rt_mod = ex.jit()
export_library(file_name, *, fcompile=None, fpack_imports=None, addons=None, workspace_dir=None, **kwargs)#

Export the module and all imported modules into a single device library.

This function only works on host LLVM modules, other runtime::Module subclasses will work with this API but they must support implement the save and load mechanisms of modules completely including saving from streams and files. This will pack your non-shared library module into a single shared library which can later be loaded by TVM.

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

  • fcompile (function(target, file_list, kwargs), optional) –

    The compilation function to use create the final library object during export.

    For example, when fcompile=_cc.create_shared, or when it is not supplied but module is “llvm,” this is used to link all produced artifacts into a final dynamic library.

    For WASM/TVMJS export, explicitly pass tvm.contrib.emcc.create_wasm as the compilation callback.

    This behavior is controlled by the type of object exported. If fcompile has attribute object_format, will compile host library to that format. Otherwise, will use default format “o”.

  • fpack_imports (function(mod: tvm_ffi.Module, is_system_lib: bool, symbol_prefix: str,) –

    workspace_dir: str) -> str Function used to pack imported modules from mod into a file suitable for passing to fcompile as an input file. The result can be a C source, or an .o object file, or any other file that the fcompile function can handle. The function returns the name of the created file.

    If not provided, the imported modules will be serialized either via packing to an LLVM module, or to a C source file.

  • workspace_dir (str, optional) – The path of the directory used to create the intermediate artifacts when exporting the module. If this is not provided a temporary dir will be created.

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

Returns:

result of fcompile() (unknown, optional) – If the compilation function returns an artifact it would be returned via export_library, if any.