This is an automated email from the ASF dual-hosted git repository.

tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new d7e1f8e7e8 [Packaging] Include BYOC dynamic libraries into wheel 
(#16034)
d7e1f8e7e8 is described below

commit d7e1f8e7e81cafa99328ce61e70709c7c89e016d
Author: Sunghyun Park <[email protected]>
AuthorDate: Wed Nov 8 13:11:59 2023 -0800

    [Packaging] Include BYOC dynamic libraries into wheel (#16034)
    
    
    
    Co-authored-by: “Sunghyun <[email protected]>
---
 python/setup.py            |  5 +++++
 python/tvm/_ffi/libinfo.py | 18 ++++++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/python/setup.py b/python/setup.py
index 736aeab78f..6901fbf864 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -55,6 +55,11 @@ def get_lib_path():
                     libs.append(name)
                     break
 
+        # Add byoc shared libraries, if present
+        for name in lib_path:
+            if "3rdparty" in name:
+                libs.append(name)
+
         # Add standalone_crt, if present
         for name in lib_path:
             candidate_path = os.path.join(os.path.dirname(name), 
"standalone_crt")
diff --git a/python/tvm/_ffi/libinfo.py b/python/tvm/_ffi/libinfo.py
index 4cf3d3c22a..5fe501c8bd 100644
--- a/python/tvm/_ffi/libinfo.py
+++ b/python/tvm/_ffi/libinfo.py
@@ -112,25 +112,39 @@ def find_lib_path(name=None, search_path=None, 
optional=False):
         else:
             lib_dll_path = [os.path.join(p, name) for p in dll_path]
         runtime_dll_path = []
+        ext_lib_dll_path = []
     else:
         if sys.platform.startswith("win32"):
             lib_dll_names = ["libtvm.dll", "tvm.dll"]
             runtime_dll_names = ["libtvm_runtime.dll", "tvm_runtime.dll"]
+            ext_lib_dll_names = [
+                
"3rdparty/cutlass_fpA_intB_gemm/cutlass_kernels/libfpA_intB_gemm.dll",
+                "3rdparty/libflash_attn/src/libflash_attn.dll",
+            ]
         elif sys.platform.startswith("darwin"):
             lib_dll_names = ["libtvm.dylib"]
             runtime_dll_names = ["libtvm_runtime.dylib"]
+            ext_lib_dll_names = [
+                
"3rdparty/cutlass_fpA_intB_gemm/cutlass_kernels/libfpA_intB_gemm.dylib",
+                "3rdparty/libflash_attn/src/libflash_attn.dylib",
+            ]
         else:
             lib_dll_names = ["libtvm.so"]
             runtime_dll_names = ["libtvm_runtime.so"]
+            ext_lib_dll_names = [
+                
"3rdparty/cutlass_fpA_intB_gemm/cutlass_kernels/libfpA_intB_gemm.so",
+                "3rdparty/libflash_attn/src/libflash_attn.so",
+            ]
 
-        name = lib_dll_names + runtime_dll_names
+        name = lib_dll_names + runtime_dll_names + ext_lib_dll_names
         lib_dll_path = [os.path.join(p, name) for name in lib_dll_names for p 
in dll_path]
         runtime_dll_path = [os.path.join(p, name) for name in 
runtime_dll_names for p in dll_path]
-
+        ext_lib_dll_path = [os.path.join(p, name) for name in 
ext_lib_dll_names for p in dll_path]
     if not use_runtime:
         # try to find lib_dll_path
         lib_found = [p for p in lib_dll_path if os.path.exists(p) and 
os.path.isfile(p)]
         lib_found += [p for p in runtime_dll_path if os.path.exists(p) and 
os.path.isfile(p)]
+        lib_found += [p for p in ext_lib_dll_path if os.path.exists(p) and 
os.path.isfile(p)]
     else:
         # try to find runtime_dll_path
         use_runtime = True

Reply via email to