-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[Unity] Add pass for combining parallel matmul #14583
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Collaborator
|
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 |
e4ad212 to
ceee41c
Compare
jwfromm
approved these changes
Apr 12, 2023
Contributor
jwfromm
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 this awesome PR Masa!
vinx13
approved these changes
Apr 12, 2023
cyx-6
added a commit
to cyx-6/tvm
that referenced
this pull request
Apr 17, 2023
This PR expands the support for fused stacked attention patterns strating with `strided_slice`. Initially, we only support fused stacked attention pattern starting with `split` in apache#14608. But with the help of apache#14583, we may have similar patterns starting with `strided_slice` as well.
masahi
pushed a commit
that referenced
this pull request
Apr 18, 2023
* [Unity][BYOC] Fuse attention pattern with `strided_slice` This PR expands the support for fused stacked attention patterns strating with `strided_slice`. Initially, we only support fused stacked attention pattern starting with `split` in #14608. But with the help of #14583, we may have similar patterns starting with `strided_slice` as well. * remove useless code
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Building on pattern-based binding rewriting work #14446, I'm adding a new pass for combining parallel matmul sharing the same LHS into one. In contrast to the equivalent Relay pass which is based on dedicated pattern-matching algorithm (completely separate from dataflow pattern matcher), this pass is implemented in terms of the generic binding rewriting infra.
When all matmul branches in a tree have the same set of fused ops, the fused ops are applied to the combined matmul output before slicing. So bias adds are also combined, for example. See the test cases.
Applied to the SD UNet from web-stable-diffusion, it reduces the number of
R.matmulfrom 200 to 100. See below for the IR comparison.Before combining: https://gist.github.com/masahi/0dab4b8f53115da9c33f4352c9175a87
After: https://gist.github.com/masahi/57ab925a43d2343cbfdb79a31c5b9946
@vinx13 @sunggg @psrivas2 @spectrometerHBH