mirror of
https://github.com/ROCm/ROCm.git
synced 2026-04-05 03:01:17 -04:00
[OPTIMIZER] Using new multiRootGetSlice utility in memory coalescing pass (#1169)
This commit is contained in:
@@ -300,4 +300,29 @@ multiRootTopologicalSort(const SetVector<Operation *> &toSort) {
|
||||
return res;
|
||||
}
|
||||
|
||||
SetVector<Operation *> multiRootGetSlice(Operation *op,
|
||||
TransitiveFilter backwardFilter,
|
||||
TransitiveFilter forwardFilter) {
|
||||
SetVector<Operation *> slice;
|
||||
slice.insert(op);
|
||||
|
||||
unsigned currentIndex = 0;
|
||||
SetVector<Operation *> backwardSlice;
|
||||
SetVector<Operation *> forwardSlice;
|
||||
while (currentIndex != slice.size()) {
|
||||
auto *currentOp = (slice)[currentIndex];
|
||||
// Compute and insert the backwardSlice starting from currentOp.
|
||||
backwardSlice.clear();
|
||||
getBackwardSlice(currentOp, &backwardSlice, backwardFilter);
|
||||
slice.insert(backwardSlice.begin(), backwardSlice.end());
|
||||
|
||||
// Compute and insert the forwardSlice starting from currentOp.
|
||||
forwardSlice.clear();
|
||||
getForwardSlice(currentOp, &forwardSlice, forwardFilter);
|
||||
slice.insert(forwardSlice.begin(), forwardSlice.end());
|
||||
++currentIndex;
|
||||
}
|
||||
return multiRootTopologicalSort(slice);
|
||||
}
|
||||
|
||||
} // namespace mlir
|
||||
|
||||
Reference in New Issue
Block a user