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

Function test_inline_simple

tests/python/relax/test_inline_functions.py:29–67  ·  view source on GitHub ↗

Simple case of inlining Inlining can be done either by providing a string name or a GlobalVar.

(key_type)

Source from the content-addressed store, hash-verified

27
28@pytest.mark.parametrize("key_type", [tvm.ir.GlobalVar, str])
29def test_inline_simple(key_type):
30 """Simple case of inlining
31
32 Inlining can be done either by providing a string name or a
33 GlobalVar.
34 """
35
36 @I.ir_module
37 class Before:
38 @R.function(private=True)
39 def main(A: R.Tensor([16, 16], "int32")) -> R.Tensor([16, 32], "int32"):
40 B = A * A
41 C = Before.subroutine(B)
42 D = C + C
43 return D
44
45 @R.function(private=True)
46 def subroutine(B: R.Tensor([16, 16], "int32")) -> R.Tensor([16, 32], "int32"):
47 C = R.concat([B, B], axis=1)
48 return C
49
50 @R.function(private=True)
51 def expected(A: R.Tensor([16, 16], "int32")) -> R.Tensor([16, 32], "int32"):
52 B = A * A
53 C = R.concat([B, B], axis=1)
54 D = C + C
55 return D
56
57 gvar = Before.get_global_var("subroutine")
58 if key_type is tvm.ir.GlobalVar:
59 key = gvar
60 elif key_type is str:
61 key = gvar.name_hint
62 else:
63 raise TypeError(f"Unknown key_type: {key_type}")
64
65 after = Before["main"].inline_functions({key: Before[gvar]})
66
67 tvm.ir.assert_structural_equal(expected, after)
68
69
70def test_ambiguous_function_name():

Callers

nothing calls this directly

Calls 2

get_global_varMethod · 0.80
inline_functionsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…