-
Notifications
You must be signed in to change notification settings - Fork 976
[DispatchCreation] Extend multi-use producer fusion #18551
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
Changes from 3 commits
ec06464
a1891f1
fbbcd12
eb24954
b34e384
5cef6c5
4bccc77
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,11 @@ | |
| #include "compiler/src/iree/compiler/DispatchCreation/FusionUtils.h" | ||
| #include "compiler/src/iree/compiler/Dialect/Flow/Transforms/RegionOpUtils.h" | ||
| #include "iree/compiler/Dialect/LinalgExt/Utils/Utils.h" | ||
| #include "mlir/Analysis/SliceAnalysis.h" | ||
| #include "mlir/Dialect/Linalg/IR/Linalg.h" | ||
| #include "mlir/IR/Dominance.h" | ||
| #include "mlir/IR/OpDefinition.h" | ||
| #include "mlir/Transforms/RegionUtils.h" | ||
|
|
||
| namespace mlir::iree_compiler::DispatchCreation { | ||
|
|
||
|
|
@@ -97,4 +101,35 @@ bool areFusableAsElementwiseOps(MLIRContext *context, OpOperand *fusedOperand, | |
| return true; | ||
| } | ||
|
|
||
| // Returns true when an operation `op` is horizontal to `currGroup` when | ||
| // considering the program slice between `seedOp` and `op`. | ||
|
IanWood1 marked this conversation as resolved.
Outdated
|
||
| bool isHorizontalToGroup(Operation *op, ArrayRef<Operation *> currGroup, | ||
| const DominanceInfo &dominanceInfo, | ||
| Operation *seedOp) { | ||
| assert(dominanceInfo.properlyDominates(seedOp, op) && | ||
| op->getParentRegion() == seedOp->getParentRegion()); | ||
| BackwardSliceOptions options; | ||
| // Limit the slice to the seed to make sure the slice is small. | ||
| options.filter = [&](Operation *op) { | ||
| return !dominanceInfo.properlyDominates(op, seedOp); | ||
| }; | ||
| llvm::SetVector<Operation *> slice; | ||
| getBackwardSlice(op, &slice, options); | ||
|
|
||
| // `getBackwardSlice` doesnt track uses from within an ops region, so make | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure I follow this comment. Can you explain more?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. %0 = linalg.generic
%1 = linalg.generic %0
%2 = linalg.generic %1 ins(%0 : tensor<...>) {
^bb0(%in: i64, %out: i64):
%extracted = tensor.extract %1 [...]
linalg.yield %extracted : f16
} -> tensor<...>In the above, the backward slice starting at This was causing issues with the open llama regression tests since (i think) there are multiple gathers
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to use a slice of the values that are captured from above to make sure that there is no dependence?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I think so. Maybe this could be a option of
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe... lets leave this this way for now.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I am seeing the test added in this PR correctly there wasnt a test added for this? The failure in #18879 seems related to this.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nirvedhmeshram There were several other tests that failed related to the backward slice problem (regression tests), but none were because the |
||
| // sure there are no values defined above. | ||
| for (Operation *sliceOp : slice) { | ||
| bool usesValuesFromAbove = false; | ||
| mlir::visitUsedValuesDefinedAbove( | ||
| sliceOp->getRegions(), [&](void *) { usesValuesFromAbove = true; }); | ||
| if (usesValuesFromAbove) { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| return !llvm::any_of(currGroup, [&](Operation *groupedOp) { | ||
| return slice.contains(groupedOp); | ||
| }); | ||
| } | ||
|
|
||
| } // namespace mlir::iree_compiler::DispatchCreation | ||
Uh oh!
There was an error while loading. Please reload this page.