[Mlir-commits] [mlir] f7751a3 - [mlir][linalg] Remove tile and fuse test pass (NFC).
Tobias Gysi
llvmlistbot at llvm.org
Mon Nov 22 04:44:09 PST 2021
Author: Tobias Gysi
Date: 2021-11-22T12:33:31Z
New Revision: f7751a3a4218229c59adced4964831f7a57d256d
URL: https://github.com/llvm/llvm-project/commit/f7751a3a4218229c59adced4964831f7a57d256d
DIFF: https://github.com/llvm/llvm-project/commit/f7751a3a4218229c59adced4964831f7a57d256d.diff
LOG: [mlir][linalg] Remove tile and fuse test pass (NFC).
Remove the tile and fuse test pass that has been replaced by codegen strategy.
Depends On D114067
Reviewed By: nicolasvasilache
Differential Revision: https://reviews.llvm.org/D114068
Added:
Modified:
mlir/include/mlir/Dialect/Linalg/Passes.h
mlir/include/mlir/Dialect/Linalg/Passes.td
mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Linalg/Passes.h b/mlir/include/mlir/Dialect/Linalg/Passes.h
index b25ba69a42a3..df26b9537377 100644
--- a/mlir/include/mlir/Dialect/Linalg/Passes.h
+++ b/mlir/include/mlir/Dialect/Linalg/Passes.h
@@ -75,9 +75,6 @@ std::unique_ptr<OperationPass<FuncOp>> createLinalgGeneralizationPass();
/// work on primitive types, if possible.
std::unique_ptr<Pass> createLinalgDetensorizePass();
-/// Create a pass to tile a LinalgOp and fuse its producers.
-std::unique_ptr<OperationPass<FuncOp>> createLinalgTileAndFuseTensorOpsPass();
-
//===----------------------------------------------------------------------===//
/// Linalg strategy passes.
//===----------------------------------------------------------------------===//
diff --git a/mlir/include/mlir/Dialect/Linalg/Passes.td b/mlir/include/mlir/Dialect/Linalg/Passes.td
index 4c55b4e349d7..b78187691875 100644
--- a/mlir/include/mlir/Dialect/Linalg/Passes.td
+++ b/mlir/include/mlir/Dialect/Linalg/Passes.td
@@ -221,20 +221,6 @@ def LinalgDetensorize : FunctionPass<"linalg-detensorize"> {
}];
}
-def LinalgTileAndFuseTensorOps
- : FunctionPass<"linalg-tile-and-fuse-tensor-ops"> {
- let summary = "Tile a LinalgOp and fuse its producers.";
- let constructor = "mlir::createLinalgTileAndFuseTensorOpsPass()";
- let options = [
- ListOption<"tileSizes", "tile-sizes", "int64_t", "Tile sizes",
- "llvm::cl::ZeroOrMore, llvm::cl::MiscFlags::CommaSeparated">,
- ListOption<"tileInterchange", "tile-interchange", "int64_t",
- "Tile loop interchange",
- "llvm::cl::ZeroOrMore, llvm::cl::MiscFlags::CommaSeparated">,
- ];
- let dependentDialects = ["linalg::LinalgDialect", "scf::SCFDialect"];
-}
-
def LinalgStrategyTileAndFusePass
: FunctionPass<"linalg-strategy-tile-and-fuse-pass"> {
let summary = "Configurable pass to apply pattern-based tiling and fusion.";
diff --git a/mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp b/mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
index 68d02db728df..6f08fc7ee88d 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
@@ -457,80 +457,3 @@ mlir::linalg::tileConsumerAndFuseProducers(OpBuilder &b, LinalgOp consumerOp,
return tileLoopNest;
}
-
-namespace {
-struct LinalgTileAndFuseTensorOps
- : public LinalgTileAndFuseTensorOpsBase<LinalgTileAndFuseTensorOps> {
-
- void notifyFailure(StringRef message) {
- llvm::errs() << " - LinalgTileAndFuseTensorOps: " << message << "\n";
- signalPassFailure();
- }
-
- void runOnFunction() override {
- FuncOp funcOp = getFunction();
- OpBuilder b(funcOp.getContext());
-
- // Heuristic to find a good operation to tile and start fusion. Walk all
- // operations and select the one with the maximal backward slice of fusion
- // candidates.
- LinalgOp rootOp = nullptr;
- int64_t numFusionCandidates = -1;
- funcOp.walk([&](LinalgOp linalgOp) {
- SetVector<Operation *> backwardSlice;
- getBackwardSlice(linalgOp, &backwardSlice);
- int64_t backwardSliceSize = count_if(
- backwardSlice, [](Operation *op) { return isa<LinalgOp>(op); });
- if (backwardSliceSize > numFusionCandidates) {
- rootOp = linalgOp;
- numFusionCandidates = backwardSliceSize;
- }
- });
- if (!rootOp)
- return notifyFailure("expect to find a root operation");
-
- // Check `tileSizes` contains a tile size for every `rootOp` loop dimension.
- if (tileSizes.size() < rootOp.getNumLoops())
- return notifyFailure("expect #tile sizes >= #loops");
-
- // Check `tileInterchange` contains no entries or as many as `tileSizes`.
- if (!tileInterchange.empty() &&
- tileInterchange.size() != tileSizes.size()) {
- return notifyFailure(
- "expect the number of tile sizes and interchange dims to match");
- }
-
- // Copy the `tileSizes` and `tileInterchange` prefixes needed to tile
- // `rootOp` or use the identity interchange if `tileInterchange` is empty.
- SmallVector<int64_t> rootTileSizes(
- tileSizes.begin(), tileSizes.begin() + rootOp.getNumLoops());
- SmallVector<int64_t> rootInterchange =
- tileInterchange.empty()
- ? llvm::to_vector<6>(llvm::seq<int64_t>(0, rootOp.getNumLoops()))
- : SmallVector<int64_t>(tileInterchange.begin(),
- tileInterchange.begin() +
- rootOp.getNumLoops());
-
- // Check `rootInterchange` is a permutation of the `rootOp` loop dimensions.
- // It has to be a permutation since the tiling cannot tile the same loop
- // dimension multiple times.
- if (!isPermutation(rootInterchange))
- return notifyFailure(
- "expect the tile interchange permutes the root loops");
-
- // Tile `rootOp` and fuse its producers.
- FailureOr<TileLoopNest> tileLoopNest =
- tileConsumerAndFuseProducers(b, rootOp, rootTileSizes, rootInterchange);
- if (failed(tileLoopNest))
- return notifyFailure("tileConsumerAndFuseProducers failed unexpectedly");
-
- // Replace all uses of the tiled loop operation.
- rootOp->replaceAllUsesWith(tileLoopNest->getRootOpReplacementResults());
- }
-};
-} // namespace
-
-std::unique_ptr<OperationPass<FuncOp>>
-mlir::createLinalgTileAndFuseTensorOpsPass() {
- return std::make_unique<LinalgTileAndFuseTensorOps>();
-}
More information about the Mlir-commits
mailing list