tvm_ffi.init_ffi_api

Contents

tvm_ffi.init_ffi_api#

tvm_ffi.init_ffi_api(namespace, target_module_name=None)[source]#

Initialize register ffi api functions into a given module.

Parameters:
  • namespace (str) – The namespace of the source registry

  • target_module_name (str) – The target module name if different from namespace

Return type:

None

Examples

A typical usage pattern is to create a _ffi_api.py file to register the functions under a given module. The following code populates all registered global functions prefixed with mypackage. into the current module, then we can call the function through _ffi_api.func_name(*args) which will call into the registered global function “mypackage.func_name”.

# _ffi_api.py
import tvm_ffi

tvm_ffi.init_ffi_api("mypackage", __name__)