Repository navigation
[CodeGen] Fuse linalg.fill and reduction linalg.generic - #5242
Merged
Merged
Conversation
This commit adjusts dispatch region formation to additionally
recognize linalg.generic as a root op and reverses the order
with which we decide fusion groups. This enables us to fuse
linalg.generic output tensors into the same group, thus we
can pull in the linalg.fill for reduction linalg.generic. This
works for both tiled cases and non-tiled cases. We actually
already treat linalg.generic as a root op (as a second step
when deciding fusion groups). This simplifies the logic by
unifying them into one.
This avoids sad dispatch regions like the following:
```mlir
flow.executable @call_dispatch_143 attributes {sym_visibility = "private"} {
flow.dispatch.entry @call_dispatch_143 attributes {signature = () -> tensor<f32>, workgroup_rank = 3 : index}
module {
func @call_dispatch_143(%arg0: !flow.dispatch.tensor<writeonly:f32>) {
%cst = constant 0xFF800000 : f32
%0 = linalg.init_tensor [] : tensor<f32>
%1 = linalg.fill(%0, %cst) : tensor<f32>, f32 -> tensor<f32>
flow.dispatch.tensor.store %1, %arg0 : tensor<f32> -> !flow.dispatch.tensor<writeonly:f32>
return
}
}
}
```
Also split the dispatch region formation test file into two:
one with the cases we support now, another with forced on
fusion. This keeps us honest and avoids surprises between
tests and real behavior.
MaheshRavishankar
requested changes
Mar 28, 2021
MaheshRavishankar
left a comment
Collaborator
There was a problem hiding this comment.
Thanks! Mostly looks fine. Just a minor comment about removing legacy test file.
hanhanW
reviewed
Mar 29, 2021
hanhanW
approved these changes
Mar 30, 2021
MaheshRavishankar
approved these changes
Mar 30, 2021
ThomasRaoux
approved these changes
Mar 30, 2021
Merged
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
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.
This commit adjusts dispatch region formation to additionally
recognize linalg.generic as a root op and reverses the order
with which we decide fusion groups. This enables us to fuse
linalg.generic output tensors into the same group, thus we
can pull in the linalg.fill for reduction linalg.generic. This
works for both tiled cases and non-tiled cases. We actually
already treat linalg.generic as a root op (as a second step
when deciding fusion groups). This simplifies the logic by
unifying them into one.
This avoids sad dispatch regions like the following: