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

Function test_executable_getitem

tests/python/runtime/test_executable.py:51–70  ·  view source on GitHub ↗

Test __getitem__ method of Executable class.

()

Source from the content-addressed store, hash-verified

49
50
51def 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
73def test_executable_jit_already_jitted():

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…