-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[mlir] Return vectorized values instead of replacing #144158
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
Changes from all commits
Commits
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 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
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
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
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.
Valuewould be sufficient. This could be something for a follow-up PR.VectorizationResult->VectorizedResult? This name is a bit too close toVectorizationHookResultand the distinction is not well documented. My suggestion is not that much better, but it "hints" it's just the actual vectorized Op (as opposed to "vectorized Op + status flag"). I will try to come back with sth better :)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.
You make some good points. I was trying to follow the naming of other similar structs (
SCFTilingResult,DropUnitDimsResult,ElementwiseOpFusionResult), but I think it is a little bit weird in this case, because we are only returning the results. I like staying consistent with the other transform names, though. Perhaps we can come up with a better name forVectorizationHookResultinstead? I can try to think of something that is less similar to VectorizationResult.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.
RE (2): I didn't know about this, but I looked into some of the lit tests, and there does seem to be an example of a linalg op with multiple results:
llvm-project/mlir/test/Dialect/Linalg/vectorization/linalg-ops-with-patterns.mlir
Lines 1390 to 1406 in cd91d0f
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.
Thanks for your replies!
Great find 🙏🏻
Aligning with other transformations makes sense, but, as you note, it doesn't work particular well in this case.. Why not:
using vectorizedValues = SmallVector<Value>;?
Also, the newly introduced/renamed
VectorizationHookResultis used more widely thanVectorizationResult- I would optimise for what's more commonly used and just keep the old name,VectorizationResult. However, it would be good to add a comment. Something along the lines of:// Encapsulates vectorisation result for a single Op vectorized using a custom vectorization hook.WDYT?
In general, my main ask is to make it clear (with comments) what the distinction between the two is. Naming in this case is particularly hard :)
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 made it a struct because it leaves more room for extending the return type with less code churn in downstream projects, although I don't have a strong opinion on this.
IMO, the naming of this new return type is more important to get right, because the
VectorizationHookResultis just an internal implementation detail to the file. The newVectorizationResultis exposed as the return type of the public vectorize function, which means there will be more pain in downstream projects any time the type name is changed. A change toVectorizationHookResultis done with a single PR here in mlir, but changingVectorizationResultmeans every downstream project must integrate the change as well. Again, I don't have a particularly strong opinion here, but it just seems nice to avoid potential extra integration pain downstream.That said, comments to distinguish the two are always great! I'll try to clarify it in the code comments.
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.
These are great points - thanks!
Let’s park the bikeshedding here (which I kicked off 😅). What you’re proposing makes sense to me!