-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[mlir][Canonicalize] Copy ParallelOp Attributes in Single-iteration #145852
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
Open
mmarjieh
wants to merge
1
commit into
llvm:main
Choose a base branch
from
mmarjieh:parallelOp_copy_attributes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+42
−0
Open
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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
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 have an attribute that I wanted to preserve with this transformation.
How do you suggest I do that?
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 don't have a suggestion for this, because this is a fundamental issue in MLIR that is hard to resolve. I tried to look into this a while back (see https://discourse.llvm.org/t/rfc-implicit-propagation-of-dialect-attributes-best-effort/2657 for example) but we never found a solution.
For now "discardable attributes" are meant to be discarded outside of your own transformation that will understand them and preserve them.
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.
Sure its discardable, but it can also propagate it. It doesnt know/doesnt care. If the attribute is not valid anymore, then that is the problem of something that is adding the attribute downstream. I think it is a pragmatic solution to keep the attributes here without any gaurantee that the attribute semantics are preserved on the rewrite.
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.
And why would it round trip through the uniquer? It isnt creating a new attribute, just transfering it. It should be cheap.
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 already explained to you why this is incorrect, I won't get into it again, please refer to past discussions.
This is iterating through the dictionary of attributes of the original op, and for each of them it'll call
newOp->setAttr()
. This means that for each attribute it will take the existing incrementally built dictionary on the new op, unpack it to a list of NamedAttribute, append the new NamedAttribute, and build a new dictionary through the uniquer: as many times as there are attributes to be added.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.
@mmarjieh you will not get a resolution of this upstream. It will pull you into a discussion hole. Downstream in IREE we ended up using a listener based approach that adds back attributes that get dropped due to upstream https://github.com/iree-org/iree/blob/57d61720368c1f23bab13463cb52d0d785dd82f0/compiler/src/iree/compiler/Codegen/Common/ConfigTrackingCanonicalizer.cpp#L92 . Thats the best way forward for you
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 comment: in another downstream project I used regions to model custom op attributes https://github.com/intel/mlir-extensions/blob/main/docs/rfcs/RegionDialect.md, which is more likely to survive unrelated passes.
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.
@mmarjieh You may find this presentation from EuroLLVM 2025 conference interesting.
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.
@joker-eph @Hardcode84 @matthias-springer @MaheshRavishankar
Thanks everyone that replied. Bottom line, I can't rely on attributes to transfer data between different passes since every target has their own attributes and we can't simply propagate them without understanding if the semantics stays the same after the transformation,
I also went for a solution that doesn't rely on attributes.