Test jit method when module is already jitted.
()
| 71 | |
| 72 | |
| 73 | def test_executable_jit_already_jitted(): |
| 74 | """Test jit method when module is already jitted.""" |
| 75 | lib = tvm.tirx.build(MyModule, target="llvm") |
| 76 | executable = Executable(lib) |
| 77 | |
| 78 | # First jit call |
| 79 | jitted_mod1 = executable.jit() |
| 80 | |
| 81 | # Second jit call should return the cached jitted module |
| 82 | jitted_mod2 = executable.jit() |
| 83 | assert jitted_mod2 is jitted_mod1 |
| 84 | |
| 85 | # Test with force_recompile |
| 86 | jitted_mod3 = executable.jit(force_recompile=True) |
| 87 | # The module might be different after force recompilation |
| 88 | |
| 89 | # Verify both modules work correctly |
| 90 | a = tvm.runtime.tensor(np.array([1.0] * 10, dtype="float32")) |
| 91 | b = tvm.runtime.tensor(np.array([2.0] * 10, dtype="float32")) |
| 92 | c1 = tvm.runtime.tensor(np.array([0.0] * 10, dtype="float32")) |
| 93 | c2 = tvm.runtime.tensor(np.array([0.0] * 10, dtype="float32")) |
| 94 | |
| 95 | jitted_mod1["add"](a, b, c1) |
| 96 | jitted_mod3["add"](a, b, c2) |
| 97 | |
| 98 | tvm.testing.assert_allclose(c1.numpy(), np.array([3.0] * 10, dtype="float32")) |
| 99 | tvm.testing.assert_allclose(c2.numpy(), np.array([3.0] * 10, dtype="float32")) |
| 100 | |
| 101 | |
| 102 | def test_executable_export_library(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…