-
Notifications
You must be signed in to change notification settings - Fork 631
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
Reapply "Propagate reshapes through generics with reduction… (#18968) #19113
base: main
Are you sure you want to change the base?
Conversation
Waiting to rebase on top of #19088, then will land |
Am I reading this right? The dispatch count seems to have regressed? |
Try rebasing |
6383ab6
to
4765737
Compare
I'll try that. I was getting some weird dispatch count results when testing locally with main |
I think it is all coming from:
Which could be cloned into the dispatch if the expand_shape wasn't blocking |
62bdaef
to
98aa2a5
Compare
Looks like there is some bad codegen when reductions aren't collapsed:
|
That's interesting, but shouldn't the collapse dimension fold those back? |
8409122
to
ef99f8d
Compare
Yeah, I had to change it a bit to make |
@hanhanW would you be able to look at this again? Only the latest commit is new since last review |
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.
@hanhanW would you be able to look at this again? Only the latest commit is new since last review
The PR title and description need to be updated. It is not just reapply a reverted commit. btw, should we create a separate PR for the last commit?
if (llvm::any_of(origType.getShape(), ShapedType::isDynamic) || | ||
llvm::any_of(extractedType.getShape(), ShapedType::isDynamic) || | ||
llvm::any_of(expandedType.getShape(), ShapedType::isDynamic)) { | ||
return failure(); | ||
} |
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 you can use !xxxType.hasStaticShape()
.
|
||
|
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.
nit: remove one blank line
genericOp.getDpsInputOperands(), [&](OpOperand *operand) -> bool { | ||
auto genericOperand = | ||
operand->get().getDefiningOp<linalg::GenericOp>(); | ||
if (!genericOperand) { | ||
return false; | ||
} | ||
|
||
if (genericOperand.getNumReductionLoops() == 0) { | ||
return false; | ||
} | ||
|
||
auto map = genericOp.getMatchingIndexingMap(operand); | ||
return !map.isPermutation() && map.isProjectedPermutation(); | ||
})) { |
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.
[optional]: It'd be easier if you declare a lambda/function for this.
remove my approval because of new changes.
That makes sense, this change had several perf regressions that needed to get fixed. Would you like me to create a new PR with the changes (with your comments applied) and then after landing I would rebase and force push so that this only contains the revert commit? |
Yes, that'd be great; it makes the codebase state and commit tracking better! |
I created 2 new PRs for each of the separate fixes and updated the description of this PR. I'll rebase this branch after those have landed so that this only serves as a revert. Before force pushing, the previous HEAD was ef99f8d |
This is the 1/2 changes needed to reland #18857 (with an open PR #19113). Adds pattern to bubble up expand shape through extract slice. i.e `expand(extract)` to `extract(expand)`. This only supports the case where the expanded dimensions are not modified by the extract slice and there are no dynamic dimensions. This is important because `tensor.expand_shape` ops _cannot be cloned_ while `tensor.extract_slice` ops _can be cloned_. So, if the `expand_shape` gets stuck on the bottom of the `extract_slice` it will block it from being cloned and the `extract_slice` will have to be put into its own dispatch. --------- Signed-off-by: Ian Wood <[email protected]>
…#19325) This is the 1/2 changes needed to reland iree-org#18857 (with an open PR iree-org#19113). Adds pattern to bubble up expand shape through extract slice. i.e `expand(extract)` to `extract(expand)`. This only supports the case where the expanded dimensions are not modified by the extract slice and there are no dynamic dimensions. This is important because `tensor.expand_shape` ops _cannot be cloned_ while `tensor.extract_slice` ops _can be cloned_. So, if the `expand_shape` gets stuck on the bottom of the `extract_slice` it will block it from being cloned and the `extract_slice` will have to be put into its own dispatch. --------- Signed-off-by: Ian Wood <[email protected]> Signed-off-by: Giacomo Serafini <[email protected]>
This is the 2/2 changes needed to reland #18857 (open PR #19113). There are 2 small subchanges in this pr: - Refactor to lambda `isPossiblySoftmax` and tweak the condition to check for operand indexing maps that are projected permutations but not permutations. - Extend `getCollapsibleLoops` look at all operations to get contiguous loops. Also, I added test case that needed both these changes to pass (without being collapsed it was causing regressions on the GPU backend). --------- Signed-off-by: Ian Wood <[email protected]>
044da91
to
1a747d5
Compare
…g#18968) This reverts commit 8d3faf8. Signed-off-by: Ian Wood <[email protected]>
1a747d5
to
e609b15
Compare
Reland after fixing sdxl int8 regressions via #19012.
Running CI revealed further performance regressions that have pending patches: #19325 and #19326.
This reverts commit 8d3faf8.