()
| 101 | |
| 102 | |
| 103 | def test_simple_remove_unused(): |
| 104 | @tvm.script.ir_module |
| 105 | class IdentityUnused: |
| 106 | @R.function |
| 107 | def main(x: R.Tensor((32, 32), "float32")) -> R.Tensor: |
| 108 | with R.dataflow(): |
| 109 | lv0 = x |
| 110 | unused = lv0 |
| 111 | R.output(lv0) |
| 112 | return lv0 |
| 113 | |
| 114 | root_fn = IdentityUnused["main"] |
| 115 | dfb = root_fn.body.blocks[0] |
| 116 | |
| 117 | n2binding = name_to_binding(IdentityUnused["main"]) |
| 118 | |
| 119 | rwt = DataflowBlockRewrite(dfb, root_fn) |
| 120 | rwt.remove_unused(n2binding["unused"][0].var) |
| 121 | |
| 122 | assert_immutability(rwt, dfb, root_fn) |
| 123 | |
| 124 | # check "unused" removed |
| 125 | assert "unused" not in name_to_binding(rwt.mutated_root_fn()) |
| 126 | |
| 127 | @tvm.script.ir_module |
| 128 | class GroundTruth: |
| 129 | @R.function |
| 130 | def main(x: R.Tensor((32, 32), "float32")) -> R.Tensor: |
| 131 | with R.dataflow(): |
| 132 | lv0 = x |
| 133 | R.output(lv0) |
| 134 | return lv0 |
| 135 | |
| 136 | tvm.ir.assert_structural_equal(rwt.mutated_root_fn(), GroundTruth["main"]) |
| 137 | |
| 138 | |
| 139 | def test_remove_unused_undef(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…