Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test case for unsupported input-variable reuse in multi-output pattern matcher #1731

Merged
merged 5 commits into from
Jul 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions onnxscript/rewriter/generic_pattern_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,41 @@
self.assertEqual(len(graph.node), 2)
self.assertEqual(graph.node[0].op_type, "SinCos")

@unittest.skip("Input variable reuse not supported yet")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can xfail this so we know when it is fixed

def test_shared_root_value_extra_use(self):
def match_pattern(op, x):
t1 = op.Sin(x)
t2 = op.Cos(x)
return t1, t2

Check warning on line 289 in onnxscript/rewriter/generic_pattern_test.py

View check run for this annotation

Codecov / codecov/patch

onnxscript/rewriter/generic_pattern_test.py#L286-L289

Added lines #L286 - L289 were not covered by tests

def apply_pattern(op, x, **_):
return op.SinCos(x, domain="com.microsoft", outputs=2)

Check warning on line 292 in onnxscript/rewriter/generic_pattern_test.py

View check run for this annotation

Codecov / codecov/patch

onnxscript/rewriter/generic_pattern_test.py#L291-L292

Added lines #L291 - L292 were not covered by tests

rule = pattern.RewriteRule(

Check warning on line 294 in onnxscript/rewriter/generic_pattern_test.py

View check run for this annotation

Codecov / codecov/patch

onnxscript/rewriter/generic_pattern_test.py#L294

Added line #L294 was not covered by tests
match_pattern,
apply_pattern,
matcher=generic_pattern.GenericPatternMatcher,
)
model_proto = onnx.parser.parse_model(

Check warning on line 299 in onnxscript/rewriter/generic_pattern_test.py

View check run for this annotation

Codecov / codecov/patch

onnxscript/rewriter/generic_pattern_test.py#L299

Added line #L299 was not covered by tests
"""
<ir_version: 7, opset_import: [ "" : 17]>
agraph (float[N] y) => (float[N] z)
{
temp1 = Sin(y)
temp2 = Cos(y)
w = Add(temp1, temp2)
z = Mul(w, y)
}
"""
)
onnx.checker.check_model(model_proto)
model = onnx.shape_inference.infer_shapes(model_proto)
ir_model = ir.serde.deserialize_model(model)
rule.apply_to_model(ir_model)
graph = ir_model.graph
self.assertEqual(len(graph), 3)
self.assertEqual(graph.node[0].op_type, "SinCos")

Check warning on line 317 in onnxscript/rewriter/generic_pattern_test.py

View check run for this annotation

Codecov / codecov/patch

onnxscript/rewriter/generic_pattern_test.py#L311-L317

Added lines #L311 - L317 were not covered by tests

def test_rotary_embedding(self):
# The test work on a model if it has the expected name.
# A dummy model is used if not present (not implemented yet).
Expand Down
Loading