MCPcopy
hub / github.com/apache/tvm / load_module

Function load_module

python/tvm/runtime/module.py:424–467  ·  view source on GitHub ↗

Load module from file. Parameters ---------- path : str The path to the module file. Returns ------- module : runtime.Module The loaded module Note ---- This function will automatically call cc.create_shared if the path is in format .o or .t

(path)

Source from the content-addressed store, hash-verified

422
423
424def load_module(path):
425 """Load module from file.
426
427 Parameters
428 ----------
429 path : str
430 The path to the module file.
431
432 Returns
433 -------
434 module : runtime.Module
435 The loaded module
436
437 Note
438 ----
439 This function will automatically call
440 cc.create_shared if the path is in format .o or .tar
441 """
442 if os.path.isfile(path):
443 path = os.path.realpath(path)
444 else:
445 raise ValueError(f"cannot find file {path}")
446
447 # High level handling for .o and .tar file.
448 # We support this to be consistent with RPC module load.
449 if path.endswith(".o"):
450 # Extra dependencies during runtime.
451 from tvm.support import cc as _cc
452
453 _cc.create_shared(path + ".so", path)
454 path += ".so"
455 elif path.endswith(".tar"):
456 # Extra dependencies during runtime.
457 from tvm.support import cc as _cc
458 from tvm.support import tar as _tar
459 from tvm.support import utils as _utils
460
461 tar_temp = _utils.tempdir(custom_path=path.replace(".tar", ""))
462 _tar.untar(path, tar_temp.temp_dir)
463 files = [tar_temp.relpath(x) for x in tar_temp.listdir()]
464 _cc.create_shared(path + ".so", files)
465 path += ".so"
466 # Redirect to the load API
467 return _load_module(path)
468
469
470def load_static_library(path, func_names):

Callers 1

local_runFunction · 0.90

Calls 3

relpathMethod · 0.80
replaceMethod · 0.45
listdirMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…