Functions may be inlined within a dataflow block
()
| 86 | |
| 87 | |
| 88 | def test_inline_dataflow_block(): |
| 89 | """Functions may be inlined within a dataflow block""" |
| 90 | |
| 91 | @I.ir_module |
| 92 | class Before: |
| 93 | @R.function(private=True) |
| 94 | def main(A: R.Tensor([16, 16], "int32")) -> R.Tensor([16, 32], "int32"): |
| 95 | with R.dataflow(): |
| 96 | B = A * A |
| 97 | C = Before.subroutine(B) |
| 98 | D = C + C |
| 99 | R.output(D) |
| 100 | return D |
| 101 | |
| 102 | @R.function(private=True) |
| 103 | def subroutine(B: R.Tensor([16, 16], "int32")) -> R.Tensor([16, 32], "int32"): |
| 104 | with R.dataflow(): |
| 105 | C = R.concat([B, B], axis=1) |
| 106 | R.output(C) |
| 107 | return C |
| 108 | |
| 109 | @R.function(private=True) |
| 110 | def expected(A: R.Tensor([16, 16], "int32")) -> R.Tensor([16, 32], "int32"): |
| 111 | with R.dataflow(): |
| 112 | B = A * A |
| 113 | C = R.concat([B, B], axis=1) |
| 114 | D = C + C |
| 115 | R.output(D) |
| 116 | return D |
| 117 | |
| 118 | after = Before["main"].inline_functions({"subroutine": Before["subroutine"]}) |
| 119 | tvm.ir.assert_structural_equal(expected, after) |
| 120 | |
| 121 | |
| 122 | def test_inline_non_dataflow_block_into_dataflow_block(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…