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)
| 436 | |
| 437 | |
| 438 | def 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 |
no outgoing calls
no test coverage detected