11# coding: utf-8
22"""Information about nnvm."""
33from __future__ import absolute_import
4+ import sys
45import os
56import platform
67
8+
79def find_lib_path ():
810 """Find dynamic library files.
911
@@ -12,6 +14,7 @@ def find_lib_path():
1214 lib_path : list(string)
1315 List of all found path to the libraries
1416 """
17+ use_runtime = os .environ .get ("TVM_USE_RUNTIME_LIB" , False )
1518 curr_path = os .path .dirname (os .path .abspath (os .path .expanduser (__file__ )))
1619 api_path = os .path .join (curr_path , '../../lib/' )
1720 cmake_build_path = os .path .join (curr_path , '../../build/Release/' )
@@ -26,15 +29,24 @@ def find_lib_path():
2629 dll_path .append (os .path .join (curr_path , '../../windows' , vs_configuration ))
2730 elif os .name == "posix" and os .environ .get ('LD_LIBRARY_PATH' , None ):
2831 dll_path .extend ([p .strip () for p in os .environ ['LD_LIBRARY_PATH' ].split (":" )])
32+
2933 if os .name == 'nt' :
30- dll_path = [os .path .join (p , 'libtvm.dll' ) for p in dll_path ]
34+ lib_dll_path = [os .path .join (p , 'libtvm.dll' ) for p in dll_path ]
35+ runtime_dll_path = [os .path .join (p , 'libtvm_runtime.dll' ) for p in dll_path ]
3136 else :
32- dll_path = [os .path .join (p , 'libtvm.so' ) for p in dll_path ]
33- lib_path = [p for p in dll_path if os .path .exists (p ) and os .path .isfile (p )]
34- if len (lib_path ) == 0 :
37+ lib_dll_path = [os .path .join (p , 'libtvm.so' ) for p in dll_path ]
38+ runtime_dll_path = [os .path .join (p , 'libtvm_runtime.so' ) for p in dll_path ]
39+
40+ dll_path = runtime_dll_path if use_runtime else lib_dll_path
41+ lib_found = [p for p in dll_path if os .path .exists (p ) and os .path .isfile (p )]
42+
43+ if len (lib_found ) == 0 :
3544 raise RuntimeError ('Cannot find the files.\n ' +
3645 'List of candidates:\n ' + str ('\n ' .join (dll_path )))
37- return lib_path
46+ if use_runtime :
47+ sys .stderr .write ("Loading runtime library... this is execution only\n " )
48+ sys .stderr .flush ()
49+ return lib_found
3850
3951
4052# current version
0 commit comments