-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[mlir][transform] Overhaul RegionBranchOpInterface
implementations.
#111408
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
ingomueller-net
wants to merge
2
commits into
llvm:main
Choose a base branch
from
ingomueller-net:mlir-transform-yield
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.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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.
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.
Removing this does not seem right. When a region fails, the op jumps to the next region.
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.
In particular and unlike scf.for, transform.foreach does not pass control from one iteration of its body to the next directly; it rather passes the control back to the parent op, which then passes it back to the body for the next iteration. That can be seen by the fact that the body always gets arguments of the same type as the operands of the parent op (and none of the yielded types) and the types that are yielded correspond exactly to the result types of the parent op.
I don't follow this part. Where is the type mismatch here?
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.
Oh, I guess you are saying that the successor operands do not match with the block arguments of the next region.
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 the
RegionBranchOpInterface
does not support the use case here. When you branch back to the parent op, there is no way to go back into the op a second time.This sentence talks about results of the op, so if we would allow going back into the op, you could set the same results multiple times.
I think we should clarify this in the documentation of
RegionBranchOpInterface
. (We could also allow it but most transformations on top ofRegionBranchOpInterface
probably assume that you cannot go back into the op.)Do we have to implement the
RegionBranchOpInterface
on these transform ops at all?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.
In
sequence
, I think the sentence matches, no? When control reachesyield
, the operands of yield are forwarded to the parent op, they become the result of the op, and "control flow leaves [the] op," right?What doesn't quite fit for
foreach
andalternatives
is the "control flow leaves [the] op" part. One could argue that the "region successor is a [part of or a potential] range of results of [the] op," but then the control flow does not leave the op; instead it may go to the next region or re-enter the body. Plus there are rules about how to combine the different results yielded by different regions/iterations (though the types always match).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.
In practice, what's the difference between "no arguments are passed" and "it isn't specified which arguments are passed"? The former does not imply that the region must have 0 arguments.
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 believe that "it isn't specified which arguments are passed" cannot be expressed currently. An empty argument list is always interpreted as "no arguments are passed."
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.
Yes, that's correct. But I am wondering if it makes any difference for analyses and transformations.
If we a region has an argument, but the
RegionBranchOpInterface
says that no arguments are forwarded to that region: what does that mean? It means that we have no idea where the data for that block argument is coming from. Maybe the op itself produces it.Or maybe the value was actually forwarded from another region but we did not account for it in the
RegionBranchOpInterface
(and the terminator interface).Does it matter which one is the case for an analysis that checks the
RegionBranchOpInterface
? It has to be conservative around such cases anyway.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.
Are you sure that that can even exist? I think I ran into failed type check that seem to check exactly that while working on the last commit...
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 scf.forall is an example.