MCPcopy Create free account
hub / github.com/apache/tvm-ffi / run_check

Function run_check

tests/python/test_load_inline.py:245–258  ·  view source on GitHub ↗

Must run in a separate function to ensure deletion happens before mod unloads. When a module returns an object, the object deleter address is part of the loaded library. We need to keep the module loaded until the object is deleted.

()

Source from the content-addressed store, hash-verified

243 assert torch is not None
244
245 def run_check() -> None:
246 """Must run in a separate function to ensure deletion happens before mod unloads.
247
248 When a module returns an object, the object deleter address is part of the
249 loaded library. We need to keep the module loaded until the object is deleted.
250 """
251 assert torch is not None
252 x_cpu = torch.asarray([1, 2, 3, 4, 5], dtype=torch.float32, device="cpu")
253 # test support for nested container passing
254 y_cpu = mod.return_add_one({"x": [x_cpu]})
255 assert isinstance(y_cpu, torch.Tensor)
256 assert y_cpu.shape == (5,)
257 assert y_cpu.dtype == torch.float32
258 torch.testing.assert_close(x_cpu + 1, y_cpu)
259
260 run_check()
261

Calls

no outgoing calls

Tested by

no test coverage detected