Test function to run remote code such as cl This is not enabled because there is forking issue of TVM runtime when server launches after OpenCL runtime initializes. We leave it as an example on how to do rpc when we want to do linking on remote.
(remote)
| 305 | rpc.PopenSession(path_minrpc) |
| 306 | |
| 307 | def check_remote_link_cl(remote): |
| 308 | """Test function to run remote code such as cl |
| 309 | |
| 310 | This is not enabled because there is forking issue |
| 311 | of TVM runtime when server launches after OpenCL |
| 312 | runtime initializes. We leave it as an example |
| 313 | on how to do rpc when we want to do linking on remote. |
| 314 | """ |
| 315 | if not tvm.testing.device_enabled("opencl"): |
| 316 | print("Skip because opencl is not enabled") |
| 317 | return |
| 318 | temp = utils.tempdir() |
| 319 | dev = remote.cl(0) |
| 320 | |
| 321 | s = tvm.s_tir.Schedule(mod) |
| 322 | |
| 323 | x = s.get_loops(s.get_sblock("B")) |
| 324 | xo, xi = s.split(x, factors=[None, 32]) |
| 325 | s.bind(xo, "blockIdx.x") |
| 326 | s.bind(xi, "threadIdx.x") |
| 327 | f = tvm.compile(s.mod, tvm.target.Target("opencl", host="llvm")) |
| 328 | path_tar = temp.relpath("myadd.tar") |
| 329 | f.export_library(path_tar) |
| 330 | remote.upload(path_tar) |
| 331 | fhost = remote.load_module("myadd.tar") |
| 332 | a = tvm.runtime.tensor(np.random.uniform(size=102).astype(A.dtype), dev) |
| 333 | b = tvm.runtime.tensor(np.zeros(102, dtype=A.dtype), dev) |
| 334 | fhost(a, b) |
| 335 | np.testing.assert_equal(b.numpy(), a.numpy() + 1) |
| 336 | |
| 337 | check_remote(rpc.LocalSession()) |
| 338 | check_remote(client) |
nothing calls this directly
no test coverage detected
searching dependent graphs…