[Mlir-commits] [mlir] db0c7dd - [mlir][Linalg] Retire LinalgStrategyGeneralizePass

Guray Ozen llvmlistbot at llvm.org
Tue Aug 23 01:31:54 PDT 2022


Author: Guray Ozen
Date: 2022-08-23T10:31:43+02:00
New Revision: db0c7dde6b18035bd7d2022f3ea939d8323e72d5

URL: https://github.com/llvm/llvm-project/commit/db0c7dde6b18035bd7d2022f3ea939d8323e72d5
DIFF: https://github.com/llvm/llvm-project/commit/db0c7dde6b18035bd7d2022f3ea939d8323e72d5.diff

LOG: [mlir][Linalg] Retire LinalgStrategyGeneralizePass

This revision deletes LinalgStrategyGeneralizePass.

Context: https://discourse.llvm.org/t/psa-retire-linalg-filter-based-patterns/63785

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D132363

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/Linalg/Passes.h
    mlir/include/mlir/Dialect/Linalg/Passes.td
    mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h
    mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Linalg/Passes.h b/mlir/include/mlir/Dialect/Linalg/Passes.h
index ecf684c918d82..543a531f1234f 100644
--- a/mlir/include/mlir/Dialect/Linalg/Passes.h
+++ b/mlir/include/mlir/Dialect/Linalg/Passes.h
@@ -97,11 +97,6 @@ std::unique_ptr<OperationPass<func::FuncOp>> createLinalgStrategyPadPass(
     const linalg::LinalgTransformationFilter &filter =
         linalg::LinalgTransformationFilter());
 
-/// Create a LinalgStrategyGeneralizePass.
-std::unique_ptr<OperationPass<func::FuncOp>> createLinalgStrategyGeneralizePass(
-    StringRef opName = "", const linalg::LinalgTransformationFilter &filter =
-                               linalg::LinalgTransformationFilter());
-
 /// Create a LinalgStrategyDecomposePass.
 // TODO: if/when we need finer control add an `opName` parameter.
 std::unique_ptr<OperationPass<func::FuncOp>> createLinalgStrategyDecomposePass(

diff  --git a/mlir/include/mlir/Dialect/Linalg/Passes.td b/mlir/include/mlir/Dialect/Linalg/Passes.td
index 85cbdd83874ab..826d59f9b5415 100644
--- a/mlir/include/mlir/Dialect/Linalg/Passes.td
+++ b/mlir/include/mlir/Dialect/Linalg/Passes.td
@@ -210,19 +210,6 @@ def LinalgStrategyPadPass
   ];
 }
 
-def LinalgStrategyGeneralizePass
-    : Pass<"linalg-strategy-generalize-pass", "func::FuncOp"> {
-  let summary = "Configurable pass to apply pattern-based generalization.";
-  let constructor = "mlir::createLinalgStrategyGeneralizePass()";
-  let dependentDialects = ["linalg::LinalgDialect"];
-  let options = [
-    Option<"anchorFuncName", "anchor-func", "std::string", /*default=*/"",
-      "Which func op is the anchor to latch on.">,
-    Option<"anchorOpName", "anchor-op", "std::string", /*default=*/"",
-      "Which linalg op within the func is the anchor to latch on.">,
-  ];
-}
-
 // TODO: if/when we need finer control add an anchorOp option.
 def LinalgStrategyDecomposePass
     : Pass<"linalg-strategy-decompose-pass", "func::FuncOp"> {

diff  --git a/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h b/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h
index d28f1ccb3de3d..21246d438737d 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h
@@ -81,21 +81,6 @@ struct Pad : public Transformation {
   linalg::LinalgPaddingOptions options;
 };
 
-/// Represent one application of createLinalgStrategyGeneralizePass.
-struct Generalize : public Transformation {
-  explicit Generalize(StringRef name,
-                      LinalgTransformationFilter::FilterFunction f = nullptr)
-      : Transformation(std::move(f)), opName(name) {}
-
-  void addToPassPipeline(OpPassManager &pm,
-                         LinalgTransformationFilter m) const override {
-    pm.addPass(createLinalgStrategyGeneralizePass(opName, m));
-  }
-
-private:
-  std::string opName;
-};
-
 /// Represent one application of createLinalgStrategyDecomposePass.
 struct Decompose : public Transformation {
   explicit Decompose(LinalgTransformationFilter::FilterFunction f = nullptr)
@@ -218,21 +203,7 @@ struct CodegenStrategy {
   padIf(bool b, StringRef opName, linalg::LinalgPaddingOptions options,
         LinalgTransformationFilter::FilterFunction f = nullptr) {
     return b ? pad(opName, std::move(options), std::move(f)) : *this;
-  }
-  /// Append a pattern to generalize named operations.
-  CodegenStrategy &
-  generalize(StringRef opName,
-             const LinalgTransformationFilter::FilterFunction &f = nullptr) {
-    transformationSequence.emplace_back(
-        std::make_unique<Generalize>(opName, f));
-    return *this;
-  }
-  /// Conditionally append a pattern to generalize named operations.
-  CodegenStrategy &
-  generalizeIf(bool b, StringRef opName,
-               LinalgTransformationFilter::FilterFunction f = nullptr) {
-    return b ? generalize(opName, std::move(f)) : *this;
-  }
+  }  
   /// Append patterns to decompose convolutions.
   CodegenStrategy &
   decompose(const LinalgTransformationFilter::FilterFunction &f = nullptr) {

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp b/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp
index 22b97ffcf78ba..b8a8bbd40a0a3 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp
@@ -142,38 +142,6 @@ struct LinalgStrategyPadPass
   LinalgTransformationFilter filter;
 };
 
-/// Configurable pass to apply pattern-based linalg generalization.
-struct LinalgStrategyGeneralizePass
-    : public LinalgStrategyGeneralizePassBase<LinalgStrategyGeneralizePass> {
-
-  LinalgStrategyGeneralizePass() = default;
-
-  LinalgStrategyGeneralizePass(StringRef opName,
-                               LinalgTransformationFilter filter)
-      : filter(std::move(filter)) {
-    this->anchorOpName.setValue(opName.str());
-  }
-
-  void runOnOperation() override {
-    auto funcOp = getOperation();
-    if (!anchorFuncName.empty() && funcOp.getName() != anchorFuncName)
-      return;
-
-    RewritePatternSet generalizationPattern(funcOp.getContext());
-    if (!anchorOpName.empty()) {
-      generalizationPattern.add<LinalgGeneralizationPattern>(
-          anchorOpName, funcOp.getContext(), filter);
-    } else {
-      generalizationPattern.add<LinalgGeneralizationPattern>(
-          funcOp.getContext(), filter);
-    }
-    if (failed(applyPatternsAndFoldGreedily(funcOp,
-                                            std::move(generalizationPattern))))
-      signalPassFailure();
-  }
-
-  LinalgTransformationFilter filter;
-};
 
 /// Configurable pass to apply lowering of coarser-grained named linalg ops into
 /// finer-grained named versions.
@@ -445,13 +413,6 @@ mlir::createLinalgStrategyPadPass(StringRef opName,
   return std::make_unique<LinalgStrategyPadPass>(opName, opt, filter);
 }
 
-/// Create a LinalgStrategyGeneralizePass.
-std::unique_ptr<OperationPass<func::FuncOp>>
-mlir::createLinalgStrategyGeneralizePass(
-    StringRef opName, const LinalgTransformationFilter &filter) {
-  return std::make_unique<LinalgStrategyGeneralizePass>(opName, filter);
-}
-
 /// Create a LinalgStrategyDecomposePass.
 // TODO: if/when we need finer control add an `opName` parameter.
 std::unique_ptr<OperationPass<func::FuncOp>>


        


More information about the Mlir-commits mailing list