-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
[mlir][vector] Restrict DropInnerMostUnitDimsTransfer{Read|Write} #96218
Merged
banach-space
merged 5 commits into
llvm:main
from
banach-space:andrzej/update_collapse_inner_6
Jul 12, 2024
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6f6d0c5
[mlir][vector] Restrict DropInnerMostUnitDimsTransferWrite
banach-space 72505d0
fixup! [mlir][vector] Restrict DropInnerMostUnitDimsTransferWrite
banach-space 6a3fe47
fixup! fixup! [mlir][vector] Restrict DropInnerMostUnitDimsTransferWrite
banach-space e2a35ec
fixup! fixup! fixup! [mlir][vector] Restrict DropInnerMostUnitDimsTra…
banach-space 2342b2f
fixup! fixup! fixup! [mlir][vector] Restrict DropInnerMostUnitDimsTra…
banach-space File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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 looks much more complex than I'd expect. I don't see the need to check the indices at all.
Also, dropping the dim if the index is zero and marked as out-of-bounds does not seem valid. If index zero is out-of-bounds, then we can't safely write to that unit dimension (I'm not sure of the precise meaning of that, but it does not seem like a safe transform in that case...).
Why not just:
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.
(or maybe even):
out-of-bounds dims are an edge-case (that I've not really seen used in practice, so are probably not worth worrying about much).
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.
Side note: If index 0 and in-bounds = false for a unit-dim actually means in-bounds = true, that should be an xferOp fold (not something everyone that looks at in-bounds values needs to interpret).
Edit: Looks like it already is! https://godbolt.org/z/9Gqo37YeG :) It's an actual fold too (
foldTransferInBoundsAttribute
, so it's running pretty much all the time).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.
As you observed further down:
:) So:
in_bounds
is effectively irrelevant (safe to collapse)in_bounds = true
, the index is effectively ==0 and (safe to collapse)in_bounds = false
, bail out.Note that once
in_bounds
is mandatory, I will be able to simply the above as:Not sure we can say that - the default for
in_bounds
is "out of bounds".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 knew about the folder, but incorrectly assumed that the "folder" wasn't guaranteed to be run before the pattern. I was wrong:
llvm-project/mlir/include/mlir/Transforms/GreedyPatternRewriteDriver.h
Lines 107 to 108 in 1ed84a8
So:
Yeah, that's perfectly sufficient and covers all the cases. Thanks!
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 think this is definitely safer.