MCPcopy Create free account
hub / github.com/apache/tvm-ffi / load_module

Function load_module

python/tvm_ffi/module.py:438–477  ·  view source on GitHub ↗

Load module from file. Parameters ---------- path The path to the module file. keep_module_alive Whether to keep the module alive. If True, the module will be kept alive for the duration of the program until libtvm_ffi.so is unloaded. Returns ------

(path: str | PathLike, keep_module_alive: bool = True)

Source from the content-addressed store, hash-verified

436
437
438def load_module(path: str | PathLike, keep_module_alive: bool = True) -> Module:
439 """Load module from file.
440
441 Parameters
442 ----------
443 path
444 The path to the module file.
445
446 keep_module_alive
447 Whether to keep the module alive. If True, the module will be kept alive
448 for the duration of the program until libtvm_ffi.so is unloaded.
449
450 Returns
451 -------
452 The loaded module
453
454 Examples
455 --------
456 .. code-block:: python
457
458 import tvm_ffi
459 from pathlib import Path
460
461 # Works with string paths
462 mod = tvm_ffi.load_module("path/to/module.so")
463 # Also works with pathlib.Path objects
464 mod = tvm_ffi.load_module(Path("path/to/module.so"))
465
466 mod.func_name(*args)
467
468 See Also
469 --------
470 :py:class:`tvm_ffi.Module`
471
472 """
473 path = fspath(path)
474 mod = _ffi_api.ModuleLoadFromFile(path)
475 if keep_module_alive:
476 _ffi_api.ModuleGlobalsAdd(mod)
477 return mod

Callers 8

load_inlineFunction · 0.90
loadFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
__init__.pyFile · 0.90
load_lib_moduleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected