MCPcopy Create free account
hub / github.com/apache/tvm / test_inline_multiple_instances

Function test_inline_multiple_instances

tests/python/relax/test_inline_functions.py:236–267  ·  view source on GitHub ↗

A subroutine may be inlined multiple times When inlining, SSA should still be respected.

()

Source from the content-addressed store, hash-verified

234
235
236def test_inline_multiple_instances():
237 """A subroutine may be inlined multiple times
238
239 When inlining, SSA should still be respected.
240 """
241
242 @I.ir_module
243 class Before:
244 @R.function(private=True)
245 def main(A: R.Tensor):
246 B = Before.subroutine(A)
247 C = Before.subroutine(B)
248 return C
249
250 @R.function(private=True)
251 def subroutine(A0: R.Tensor) -> R.Tensor:
252 A1 = A0 * A0
253 A2 = A1 + A1
254 return A2
255
256 @R.function(private=True)
257 def expected(A: R.Tensor):
258 # First call
259 B = A * A
260 C = B + B
261 # Second call
262 D = C * C
263 E = D + D
264 return E
265
266 after = Before["main"].inline_functions({"subroutine": Before["subroutine"]})
267 tvm.ir.assert_structural_equal(expected, after)
268
269
270def test_inline_multiple_instances_with_distinct_static_shapes():

Callers

nothing calls this directly

Calls 1

inline_functionsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…