-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[Unity][Graph matching] Automatically add used-by constraints for is_op pattern
#14439
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 |
| inline tvm::runtime::Map<DFPattern, Var> MatchGraphDefault(const DataflowBlock& dfb, | ||
| Optional<Var> start_hint = NullOpt, | ||
| bool must_include_hint = false) { | ||
| return MatchGraph(PatternContext::Current(), dfb, start_hint, must_include_hint); |
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.
This gets removed since it is not used anywhere but it touches PatternContext::Current() (which is now Optional)
| Q_weight_pat.only_used_by(matmul1, 1) | ||
| K_weight_pat.only_used_by(matmul2, 1) | ||
| V_weight_pat.only_used_by(matmul3, 1) |
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.
I understand used_by can be removed now as it is implied by a function call. However, only_used_by is a stronger constraint that cannot be implied via a fn call right?
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.
But yeah I guess you meant oftentimes we don't fold Q, K, and V so it is fine if they are being used by others at the same time.
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. Thanks for the improvement!
…is_op` pattern (#14439) * Automatically add used-by constraints for is_op pattern * [DOC fix] pass context -> constraint context
…is_op` pattern (#14439) * Automatically add used-by constraints for is_op pattern * [DOC fix] pass context -> constraint context
…is_op` pattern (#14439) * Automatically add used-by constraints for is_op pattern * [DOC fix] pass context -> constraint context
Compared to the typical, structural matching (e.g. matching
is_opbased pattern againstCallNode), graph pattern matching requires additionally specifyingused_byconstraints. This leads to an obvious redundancy in the usage:This PR hacks
is_opconstructor by automatically adding suchused_byconstraints between caller and callee patterns. See the simplified test case for QOL improvement.@ganler @sunggg