-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[Unity][Graph matching] Clean up undo stack for parent and child nodes properly #14440
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
Conversation
|
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.
Generated by tvm-bot |
ganler
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.
LGTM.
Co-authored-by: Jiawei Liu <jaway.liu@gmail.com>
|
Hey I'm happy to report that I have pattern-based rewriter for dataflow block working. Compared to the existing call node based matching & rewriting that requires a common post-dominator in a pattern, it lets us match a tree structure and replace leaf nodes or branches with new expression. The branch is here which I'll send after this one. This can be immediately used for combining any number of multiple matmuls sharing the same LHS into one matmul. In Relay, we have a dedicated pass for that purpose ( For example, in SD UNet we have many three parallel matmul for QKV projections. In addition, there are also highly non-obvious parallel matmuls consisting of 32 or 22 of them. Those patterns can all be matched and rewritten via the following generic pattern and rewriter. I'm very excited about this! |
psrivas2
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.
Fantastic, thanks!
…s properly (#14440) * Clean up undo stack for parent and child nodes properly * Update src/relax/analysis/udchain.cc Co-authored-by: Jiawei Liu <jaway.liu@gmail.com> * minor change * stack -> vector * remove stack header * fix accidentally removed statement from recent commit --------- Co-authored-by: Jiawei Liu <jaway.liu@gmail.com>
…s properly (#14440) * Clean up undo stack for parent and child nodes properly * Update src/relax/analysis/udchain.cc Co-authored-by: Jiawei Liu <jaway.liu@gmail.com> * minor change * stack -> vector * remove stack header * fix accidentally removed statement from recent commit --------- Co-authored-by: Jiawei Liu <jaway.liu@gmail.com>
…s properly (#14440) * Clean up undo stack for parent and child nodes properly * Update src/relax/analysis/udchain.cc Co-authored-by: Jiawei Liu <jaway.liu@gmail.com> * minor change * stack -> vector * remove stack header * fix accidentally removed statement from recent commit --------- Co-authored-by: Jiawei Liu <jaway.liu@gmail.com>
This is a fix for the issue described in #14417 (comment)
In graph pattern matching, backtracking behavior is implemented by undoing matchings in
undo_stack. When an intermediate fails to match,undo_stacks for parent and child nodes that have matched tentatively also need to be cleaned up as well. This corner-case handling is missing in the current implementation.The fix is to return
undo_stackfrom recursivetry_matchcalls when matching succeeds, and merge parent / childundo_stackwith theundo_stackfor the "current" node@ganler @sunggg @cyx-6