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

Function check_device

tests/python/runtime/test_runtime_module_load.py:117–141  ·  view source on GitHub ↗
(device)

Source from the content-addressed store, hash-verified

115 sch.bind(tx, "threadIdx.x")
116
117 def check_device(device):
118 dev = tvm.device(device, 0)
119 if not tvm.testing.device_enabled(device):
120 print(f"Skip because {device} is not enabled")
121 return
122 temp = utils.tempdir()
123 f = tvm.compile(sch.mod, target=device)
124
125 path_dso = temp.relpath("dev_lib.so")
126 # test cross compiler function
127 f.export_library(path_dso, fcompile=cc.cross_compiler("g++"))
128
129 def popen_check():
130 import tvm
131
132 f1 = tvm.runtime.load_module(path_dso)
133 a = tvm.runtime.tensor(np.random.uniform(size=1024).astype(A.dtype), dev)
134 b = tvm.runtime.tensor(np.zeros(1024, dtype=A.dtype), dev)
135 f1(a, b)
136 np.testing.assert_equal(b.numpy(), a.numpy() + 1)
137
138 # system lib should be loaded in different process
139 worker = popen_pool.PopenWorker()
140 worker.send(popen_check)
141 worker.recv()
142
143 def check_c(device):
144 dev = tvm.device(device, 0)

Callers 1

test_device_module_dumpFunction · 0.85

Calls 7

sendMethod · 0.95
recvMethod · 0.95
printFunction · 0.85
relpathMethod · 0.80
deviceMethod · 0.45
compileMethod · 0.45
export_libraryMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…