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: 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 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(): 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])