You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

find_library.patch 2.5 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. --- tvm/python/tvm/_ffi/base.py 2020-03-12 16:17:39.089828527 +0800
  2. +++ tvm_new/python/tvm/_ffi/base.py 2020-03-12 16:17:16.829829558 +0800
  3. @@ -16,6 +16,9 @@
  4. # under the License.
  5. # coding: utf-8
  6. # pylint: disable=invalid-name
  7. +
  8. +# 2019.12.30 - Modify _load_lib function.
  9. +
  10. """Base library for TVM FFI."""
  11. from __future__ import absolute_import
  12. @@ -47,8 +50,18 @@ else:
  13. def _load_lib():
  14. - """Load libary by searching possible path."""
  15. - lib_path = libinfo.find_lib_path()
  16. + """Load library by searching possible path."""
  17. + pwd = os.path.dirname(os.path.realpath(__file__))
  18. + path = os.path.realpath(pwd+"/../../../mindspore/lib")
  19. + lib_path = []
  20. + files = os.listdir(path)
  21. + for f in files:
  22. + if f.startswith("libtvm.") and f.endswith(".so"):
  23. + lib_path.append(path+"/"+f)
  24. + break
  25. + if not lib_path:
  26. + raise RuntimeError("mindspore library cannot find.")
  27. +
  28. lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_GLOBAL)
  29. # DMatrix functions
  30. lib.TVMGetLastError.restype = ctypes.c_char_p
  31. diff -Npur tvm/topi/python/topi/cpp/impl.py tvm_new/topi/python/topi/cpp/impl.py
  32. --- tvm/topi/python/topi/cpp/impl.py 2020-03-12 16:17:39.129828525 +0800
  33. +++ tvm_new/topi/python/topi/cpp/impl.py 2020-03-12 16:17:16.873829556 +0800
  34. @@ -14,6 +14,9 @@
  35. # KIND, either express or implied. See the License for the
  36. # specific language governing permissions and limitations
  37. # under the License.
  38. +
  39. +# 2019.12.30 - Modify _load_lib function.
  40. +
  41. """Load Lib for C++ TOPI ops and schedules"""
  42. import sys
  43. import os
  44. @@ -30,12 +33,18 @@ def _get_lib_names():
  45. return ['libtvm_topi.so', 'tvm_topi.so']
  46. def _load_lib():
  47. - """Load libary by searching possible path."""
  48. - curr_path = os.path.dirname(os.path.realpath(os.path.expanduser(__file__)))
  49. - lib_search = curr_path
  50. - lib_path = libinfo.find_lib_path(_get_lib_names(), lib_search, optional=True)
  51. - if lib_path is None:
  52. - return None, None
  53. + """Load library by searching possible path."""
  54. + pwd = os.path.dirname(os.path.realpath(__file__))
  55. + path = os.path.realpath(pwd+"/../../../mindspore/lib")
  56. + lib_path = []
  57. + files = os.listdir(path)
  58. + for f in files:
  59. + if f.startswith("libtvm.") and f.endswith(".so"):
  60. + lib_path.append(path+"/"+f)
  61. + break
  62. + if not lib_path:
  63. + raise RuntimeError("mindspore library cannot find.")
  64. +
  65. lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_GLOBAL)
  66. return lib, os.path.basename(lib_path[0])