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

Function test_executable_jit_already_jitted

tests/python/runtime/test_executable.py:73–99  ·  view source on GitHub ↗

Test jit method when module is already jitted.

()

Source from the content-addressed store, hash-verified

71
72
73def 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
102def test_executable_export_library():

Callers

nothing calls this directly

Calls 4

jitMethod · 0.95
ExecutableClass · 0.90
numpyMethod · 0.80
buildMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…