MCPcopy Index your code
hub / github.com/apache/tvm / test_variable_replacer

Function test_variable_replacer

tests/python/tirx-transform/test_tir_functor.py:228–243  ·  view source on GitHub ↗

Test expression mutator that replaces variables

()

Source from the content-addressed store, hash-verified

226
227
228def test_variable_replacer():
229 """Test expression mutator that replaces variables"""
230 x = Var("x", dtype="int32")
231 y = Var("y", dtype="int32")
232 expr = Add(x, Mul(y, IntImm("int32", 3)))
233
234 replacer = VariableReplacer({"x": 10, "y": 5})
235 result = replacer.visit_expr(expr)
236
237 # Should be Add(IntImm(10), Mul(IntImm(5), IntImm(3)))
238 assert isinstance(result, Add)
239 assert isinstance(result.a, IntImm)
240 assert result.a.value == 10
241 assert isinstance(result.b, Mul)
242 assert isinstance(result.b.a, IntImm)
243 assert result.b.a.value == 5
244
245
246def test_add_to_sub_mutator():

Callers

nothing calls this directly

Calls 6

VarClass · 0.90
AddClass · 0.90
MulClass · 0.90
IntImmClass · 0.90
VariableReplacerClass · 0.85
visit_exprMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…