MCPcopy Index your code
hub / github.com/apache/tvm / check_system_lib

Function check_system_lib

tests/python/runtime/test_runtime_module_load.py:194–229  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

192 np.testing.assert_equal(b.numpy(), a.numpy() + 1)
193
194 def check_system_lib():
195 dev = tvm.cpu(0)
196 if not tvm.testing.device_enabled("llvm"):
197 print("Skip because llvm is not enabled")
198 return
199 temp = utils.tempdir()
200 print("Running popen check")
201 fadd1 = tvm.tirx.build(mod1.with_attr("system_lib_prefix", ""), "llvm")
202 fadd2 = tvm.tirx.build(mod2.with_attr("system_lib_prefix", ""), "llvm")
203 path1 = temp.relpath("myadd1.o")
204 path2 = temp.relpath("myadd2.o")
205 path_dso = temp.relpath("mylib.so")
206 fadd1.write_to_file(path1)
207 fadd2.write_to_file(path2)
208 cc.create_shared(path_dso, [path1, path2])
209
210 def popen_check():
211 import ctypes
212
213 import tvm.runtime
214
215 # Load dll, will trigger system library registration
216 ctypes.CDLL(path_dso)
217 # Load the system wide library
218 mm = tvm.runtime.system_lib()
219 a = tvm.runtime.tensor(np.random.uniform(size=nn).astype(A.dtype), dev)
220 b = tvm.runtime.tensor(np.zeros(nn, dtype=A.dtype), dev)
221 mm["myadd1"](a, b)
222 np.testing.assert_equal(b.numpy(), a.numpy() + 1)
223 mm["myadd2"](a, b)
224 np.testing.assert_equal(b.numpy(), a.numpy() + 1)
225
226 # system lib should be loaded in different process
227 worker = popen_pool.PopenWorker()
228 worker.send(popen_check)
229 worker.recv()
230
231 if sys.platform != "win32":
232 check_system_lib()

Callers 1

test_combine_module_llvmFunction · 0.85

Calls 7

sendMethod · 0.95
recvMethod · 0.95
printFunction · 0.85
relpathMethod · 0.80
cpuMethod · 0.45
buildMethod · 0.45
with_attrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…