junrushao commented on code in PR #336:
URL: https://github.com/apache/tvm-ffi/pull/336#discussion_r2613010881


##########
python/tvm_ffi/libinfo.py:
##########
@@ -169,6 +172,33 @@ def load_lib_ctypes(package: str, target_name: str, mode: 
str) -> ctypes.CDLL:
     return ctypes.CDLL(str(lib_path), getattr(ctypes, mode))
 
 
+def load_lib_module(package: str, target_name: str, keep_module_alive: bool = 
True) -> Module:
+    """Load the tvm_ffi shared library by searching likely paths.
+
+    Parameters
+    ----------
+    package
+        The package name where the library is expected to be found. For 
example,
+        ``"apache-tvm-ffi"`` is the package name of `tvm-ffi`.
+
+    target_name
+        Name of the CMake target, e.g., ``"tvm_ffi"``. It is used to derive 
the platform-specific
+        shared library name, e.g., ``"libtvm_ffi.so"`` on Linux, 
``"tvm_ffi.dll"`` on Windows.
+
+    keep_module_alive
+        Whether to keep the loaded module alive to prevent it from being 
unloaded.
+
+    Returns
+    -------
+    The loaded shared library.
+
+    """
+    from .module import load_module  # noqa: PLC0415
+
+    lib_path: Path = _find_library_by_basename(package, target_name)
+    return load_module(lib_path, keep_module_alive=keep_module_alive)

Review Comment:
   good catch!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to