incubator-tvm.patch 2.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
diff -Npur tvm_orig/python/tvm/_ffi/base.py tvm/python/tvm/_ffi/base.py
--- tvm_orig/python/tvm/_ffi/base.py	2020-07-16 14:39:28.859033775 +0800
+++ tvm/python/tvm/_ffi/base.py	2020-07-16 14:42:26.594223690 +0800
@@ -16,6 +16,11 @@
 # under the License.
 # coding: utf-8
 # pylint: disable=invalid-name
+
+#
+# 2020.7.16 - Modify _load_lib function to find the correct library.
+#
+
 """Base library for TVM FFI."""
 from __future__ import absolute_import

@@ -48,7 +53,18 @@ else:
C
ckey_Dou 已提交
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
 
 def _load_lib():
     """Load libary by searching possible path."""
-    lib_path = libinfo.find_lib_path()
+    tar_so = "libakg.so"
+    pwd = os.path.dirname(os.path.realpath(__file__))
+    path = os.path.realpath(pwd + "/../../../mindspore/lib")
+    lib_path = []
+    files = os.listdir(path)
+    for f in files:
+        if f == tar_so:
+            lib_path.append(path + "/" + f)
+            break
+    if not lib_path:
+        raise RuntimeError("Cannot find library {}.".format(tar_so))
+
     lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_GLOBAL)
     # DMatrix functions
     lib.TVMGetLastError.restype = ctypes.c_char_p
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
diff -Npur tvm_orig/topi/python/topi/cpp/impl.py tvm/topi/python/topi/cpp/impl.py
--- tvm_orig/topi/python/topi/cpp/impl.py	2020-07-16 14:40:07.754722324 +0800
+++ tvm/topi/python/topi/cpp/impl.py	2020-07-16 14:42:56.638225874 +0800
@@ -14,6 +14,11 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
+
+#
+# 2020.7.16 - Modify _load_lib function to find the correct library.
+#
+
 """Load Lib for C++ TOPI ops and schedules"""
 import sys
 import os
@@ -31,11 +36,18 @@ def _get_lib_names():
C
ckey_Dou 已提交
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
 
 def _load_lib():
     """Load libary by searching possible path."""
-    curr_path = os.path.dirname(os.path.realpath(os.path.expanduser(__file__)))
-    lib_search = curr_path
-    lib_path = libinfo.find_lib_path(_get_lib_names(), lib_search, optional=True)
-    if lib_path is None:
-        return None, None
+    tar_so = "libakg.so"
+    pwd = os.path.dirname(os.path.realpath(__file__))
+    path = os.path.realpath(pwd + "/../../../mindspore/lib")
+    lib_path = []
+    files = os.listdir(path)
+    for f in files:
+        if f == tar_so:
+            lib_path.append(path + "/" + f)
+            break
+    if not lib_path:
+        raise RuntimeError("Cannot find library {}.".format(tar_so))
+
     lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_GLOBAL)
     return lib, os.path.basename(lib_path[0])