Test __getitem__ method of Executable class.
()
| 49 | |
| 50 | |
| 51 | def test_executable_getitem(): |
| 52 | """Test __getitem__ method of Executable class.""" |
| 53 | lib = tvm.tirx.build(MyModule, target="llvm") |
| 54 | executable = Executable(lib) |
| 55 | |
| 56 | # Jit the module first |
| 57 | executable.jit() |
| 58 | |
| 59 | # Test __getitem__ |
| 60 | add_func = executable["add"] |
| 61 | |
| 62 | # Verify the function works |
| 63 | a = tvm.runtime.tensor(np.array([1.0] * 10, dtype="float32")) |
| 64 | b = tvm.runtime.tensor(np.array([2.0] * 10, dtype="float32")) |
| 65 | c = tvm.runtime.tensor(np.array([0.0] * 10, dtype="float32")) |
| 66 | |
| 67 | add_func(a, b, c) |
| 68 | |
| 69 | # Check results |
| 70 | tvm.testing.assert_allclose(c.numpy(), np.array([3.0] * 10, dtype="float32")) |
| 71 | |
| 72 | |
| 73 | def test_executable_jit_already_jitted(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…