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

Function test_simple_remove_unused

tests/python/relax/test_binding_rewrite.py:103–136  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

101
102
103def 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
139def test_remove_unused_undef():

Callers

nothing calls this directly

Calls 5

remove_unusedMethod · 0.95
mutated_root_fnMethod · 0.95
name_to_bindingFunction · 0.90
assert_immutabilityFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…