-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[Unity][Transform] Canonicalize and use CSE between pattern matches #15904
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
[Unity][Transform] Canonicalize and use CSE between pattern matches #15904
Conversation
masahi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, please fix the tests.
ae05763 to
c3d3bad
Compare
|
Tests should now be fixed. Rebased on |
|
Current CI failure is a segfault while generating TVMScript output. The segfault is caused by a dangling reference, and is resolved by #15923. |
|
@tvm-bot rerun |
|
Failed to re-run CI in https://github.com/apache/tvm/actions/runs/6502819765 Detailswith response |
The `PatternRewriter` is intended to iterate until no matching patterns remain. Prior to this commit, this only involved repeating the pattern match rewrite rules. However, intermediate results produced by pattern replacement could cause the iterative pattern matching to terminate early. * If two rewrite rules each introduce the same intermediate, there will exist two copies of that intermediate, which can prevent `only_used_by` patterns from matching. Applying `EliminateCommonSubexpr` allows the pattern matching to continue. * Applying a rewrite rule may result in dangling intermediates that are no longer used. These dangling intermediates may prevent the next application of a rewrite rule that uses the `only_used_by` constraint. Applying `RemoveAllUnused` allows the pattern matching to continue. * A rewrite rule that returns a `relax::Var` or `relax::TupleGetItem` as the replacement introduces trivial var-to-var rebinding, which are not tracked by `PatternRewriter`. Applying `CanonicalizeBindings` allows the pattern matching to continue. While this could be fixed externally by repeatedly applying `rewrite_call`, this would require re-inspecting the entire function, and not just the dataflow block in which the replacement occurred.
c3d3bad to
001298d
Compare
|
Thank you for re-launching the CI, and that's a weird HTTP error from it. I've started it up again, and hopefully it won't have the same issue. |
The
PatternRewriteris intended to iterate until no matching patterns remain, as implemented in #14446 and #15495. Prior to this commit, this only involved repeating the pattern match rewrite rules. However, intermediate results produced by pattern replacement could cause the iterative pattern matching to terminate early.If two rewrite rules each introduce the same intermediate, there will exist two copies of that intermediate, which can prevent
only_used_bypatterns from matching. ApplyingEliminateCommonSubexprallows the pattern matching to continue.Applying a rewrite rule may result in dangling intermediates that are no longer used. These dangling intermediates may prevent the next application of a rewrite rule that uses the
only_used_byconstraint. ApplyingRemoveAllUnusedallows the pattern matching to continue.A rewrite rule that returns a
relax::Varorrelax::TupleGetItemas the replacement introduces trivial var-to-var rebinding, which are not tracked byPatternRewriter. ApplyingCanonicalizeBindingsallows the pattern matching to continue.While this could be fixed externally by repeatedly applying
rewrite_call, this would require re-inspecting the entire function, and not just the dataflow block in which the replacement occurred.