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

Function test_function_pattern

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

Source from the content-addressed store, hash-verified

144
145
146def test_function_pattern():
147 wc1 = wildcard()
148 wc2 = wildcard()
149 f = FunctionPattern([wc1, wc2], is_op("relax.add")(wc1, wc2))
150 assert isinstance(f, FunctionPattern)
151 assert isinstance(f.params[0], WildcardPattern)
152 assert isinstance(f.params[1], WildcardPattern)
153 assert isinstance(f.body, CallPattern)
154 assert isinstance(f.body.args[0], WildcardPattern)
155 assert isinstance(f.body.args[1], WildcardPattern)
156 x = rx.Var("x", R.Tensor("float32"))
157 y = rx.Var("y", R.Tensor("float32"))
158 assert f.match(rx.Function([x, y], rx.op.add(x, y), ret_struct_info=R.Tensor("float32")))
159 assert not f.match(
160 rx.Function([x, y], rx.op.multiply(x, y), ret_struct_info=R.Tensor("float32"))
161 )
162
163
164def test_tuple_pattern():

Callers

nothing calls this directly

Calls 8

wildcardFunction · 0.85
FunctionPatternClass · 0.85
is_opFunction · 0.85
TensorMethod · 0.80
FunctionMethod · 0.80
matchMethod · 0.45
addMethod · 0.45
multiplyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…