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

Function test_match_call_attr

tests/python/relax/test_dataflow_pattern.py:286–300  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

284
285
286def test_match_call_attr():
287 x = rx.Var("x", R.Tensor("float32"))
288 y = rx.Var("y", R.Tensor("float32"))
289 fn = rx.Function([x, y], rx.op.add(x, y), ret_struct_info=R.Tensor("float32"))
290 annotated_fn = fn.with_attr({"Codegen": "test-codegen", "global_symbol": "test-symbol"})
291 xp = is_var("x")
292 yp = is_var("y")
293 root_pattern = FunctionPattern([xp, yp], is_op("relax.add")(xp, yp))
294 assert root_pattern.has_attr({"Codegen": "test-codegen", "global_symbol": "test-symbol"}).match(
295 annotated_fn
296 )
297
298 assert root_pattern.has_attr({"Codegen": "test-codegen"}).match(annotated_fn)
299 assert not root_pattern.has_attr({"ping": "pong"}).match(annotated_fn)
300 assert root_pattern.has_attr({}).match(annotated_fn)
301
302
303def test_is_call_tir():

Callers

nothing calls this directly

Calls 9

is_varFunction · 0.85
FunctionPatternClass · 0.85
is_opFunction · 0.85
TensorMethod · 0.80
FunctionMethod · 0.80
addMethod · 0.45
with_attrMethod · 0.45
matchMethod · 0.45
has_attrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…