[mlir][Linalg] NFC - Drop CodegenStrategy and remaining strategy passes
authorNicolas Vasilache <nicolas.vasilache@gmail.com>
Wed, 12 Oct 2022 10:26:55 +0000 (03:26 -0700)
committerNicolas Vasilache <nicolas.vasilache@gmail.com>
Wed, 12 Oct 2022 11:47:12 +0000 (04:47 -0700)
Differential Revision: https://reviews.llvm.org/D135759

mlir/include/mlir/Dialect/Linalg/Passes.h
mlir/include/mlir/Dialect/Linalg/Passes.td
mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h [deleted file]
mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt
mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp [deleted file]
mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp [deleted file]

index 40ca027..f2b5788 100644 (file)
@@ -69,20 +69,6 @@ std::unique_ptr<OperationPass<func::FuncOp>> createLinalgGeneralizationPass();
 std::unique_ptr<Pass> createLinalgDetensorizePass();
 
 //===----------------------------------------------------------------------===//
-/// Linalg strategy passes.
-//===----------------------------------------------------------------------===//
-/// Create a LinalgStrategyTilePass.
-std::unique_ptr<OperationPass<func::FuncOp>> createLinalgStrategyTilePass(
-    StringRef opName = "",
-    const linalg::LinalgTilingOptions &opt = linalg::LinalgTilingOptions(),
-    const linalg::LinalgTransformationFilter &filter =
-        linalg::LinalgTransformationFilter());
-
-/// Create a LinalgStrategyRemoveMarkersPass.
-std::unique_ptr<OperationPass<func::FuncOp>>
-createLinalgStrategyRemoveMarkersPass();
-
-//===----------------------------------------------------------------------===//
 // Registration
 //===----------------------------------------------------------------------===//
 
index 73fd30b..550feef 100644 (file)
@@ -146,15 +146,4 @@ def LinalgDetensorize : Pass<"linalg-detensorize", ""> {
   ];
 }
 
-def LinalgStrategyRemoveMarkersPass
-    : Pass<"linalg-strategy-remove-markers-pass", "func::FuncOp"> {
-  let summary = "Cleanup pass that drops markers.";
-  let constructor = "mlir::createLinalgStrategyRemoveMarkersPass()";
-  let dependentDialects = ["linalg::LinalgDialect"];
-  let options = [
-    Option<"anchorFuncName", "anchor-func", "std::string", /*default=*/"",
-      "Which func op is the anchor to latch on.">,
-  ];
-}
-
 #endif // MLIR_DIALECT_LINALG_PASSES
diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h b/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h
deleted file mode 100644 (file)
index ae3df32..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-//===- CodegenStrategy.h - Linalg programmable codegen strategy -*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef MLIR_DIALECT_LINALG_TRANSFORMS_CODEGENSTRATEGY_H_
-#define MLIR_DIALECT_LINALG_TRANSFORMS_CODEGENSTRATEGY_H_
-
-#include <utility>
-
-#include "mlir/Conversion/VectorToSCF/VectorToSCF.h"
-#include "mlir/Dialect/Linalg/Passes.h"
-#include "mlir/Pass/PassManager.h"
-
-namespace mlir {
-
-namespace linalg {
-
-/// Abstract Transformation class applied in a sequence that also handles state
-/// through markers.
-struct Transformation {
-  explicit Transformation(LinalgTransformationFilter::FilterFunction f)
-      : filter(std::move(f)) {}
-  virtual ~Transformation() = default;
-  virtual void addToPassPipeline(OpPassManager &pm,
-                                 LinalgTransformationFilter m) const = 0;
-  LinalgTransformationFilter::FilterFunction filter = nullptr;
-};
-
-/// Codegen strategy controls how a Linalg op is progressively lowered.
-struct CodegenStrategy {
-  /// Configure the post staged-patterns global enabling passes options.
-  CodegenStrategy &
-  setVectorTransferToSCFOptions(LinalgEnablingOptions options) {
-    linalgEnablingOptions = options;
-    return *this;
-  }
-
-  /// Apply the transformation patterns in sequence with cleanup
-  /// transformations interleaved.
-  void configurePassPipeline(OpPassManager &pm, MLIRContext *context,
-                             bool addEnablePass = true) const;
-
-private:
-  LogicalResult postPatternTransforms(Operation *func) const;
-
-  LinalgEnablingOptions linalgEnablingOptions;
-  SmallVector<std::unique_ptr<Transformation>, 4> transformationSequence;
-};
-
-} // namespace linalg
-} // namespace mlir
-
-#endif // MLIR_DIALECT_LINALG_TRANSFORMS_CODEGENSTRATEGY_H_
index c218ad2..24048c2 100644 (file)
@@ -2,7 +2,6 @@ add_mlir_dialect_library(MLIRLinalgTransforms
   BubbleUpExtractSlice.cpp
   BufferizableOpInterfaceImpl.cpp
   Bufferize.cpp
-  CodegenStrategy.cpp
   ConstantFold.cpp
   DecomposeLinalgOps.cpp
   Detensorize.cpp
@@ -18,7 +17,6 @@ add_mlir_dialect_library(MLIRLinalgTransforms
   InlineScalarOperands.cpp
   Interchange.cpp
   Loops.cpp
-  LinalgStrategyPasses.cpp
   NamedOpConversions.cpp
   Promotion.cpp
   Split.cpp
diff --git a/mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp b/mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp
deleted file mode 100644 (file)
index 6787de3..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-//===- CodegenStrategy.cpp - Linalg programmable codegen strategy ---------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements logic and helpers to expose Linalg transforms as
-// composable rewrite patterns through a programmable CodegenStrategy object.
-//
-//===----------------------------------------------------------------------===//
-
-#include "mlir/Dialect/Linalg/Transforms/CodegenStrategy.h"
-#include "mlir/Dialect/Linalg/Passes.h"
-#include "mlir/Dialect/Linalg/Transforms/Hoisting.h"
-#include "mlir/Dialect/SCF/Transforms/Transforms.h"
-#include "mlir/Dialect/Vector/IR/VectorOps.h"
-#include "mlir/Dialect/Vector/Transforms/VectorTransforms.h"
-#include "mlir/Pass/PassManager.h"
-#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
-#include "mlir/Transforms/Passes.h"
-
-using namespace mlir;
-using namespace mlir::linalg;
-
-#define DEBUG_TYPE "linalg-codegen-strategy"
-
-void mlir::linalg::CodegenStrategy::configurePassPipeline(
-    OpPassManager &pm, MLIRContext *context, bool addEnablePass) const {
-  for (unsigned stepCount = 0, e = transformationSequence.size(); stepCount < e;
-       ++stepCount) {
-    const std::unique_ptr<Transformation> &t =
-        transformationSequence[stepCount];
-    std::string currentStr = std::to_string(stepCount);
-    auto currentState = StringAttr::get(context, currentStr);
-    std::string nextStr = std::to_string(stepCount + 1);
-    auto nextState = StringAttr::get(context, nextStr);
-    auto filter = (currentState.str() == std::to_string(0))
-                      ? linalg::LinalgTransformationFilter(
-                            t->filter, ArrayRef<StringAttr>{}, nextState)
-                      : linalg::LinalgTransformationFilter(
-                            t->filter, currentState, nextState);
-    t->addToPassPipeline(pm, filter);
-  }
-  pm.addPass(createLinalgStrategyRemoveMarkersPass());
-}
diff --git a/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp b/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp
deleted file mode 100644 (file)
index 39a9c7f..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-//===- LinalgStrategyPasses.cpp - Implementation of Linalg passes ---------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements a configurable pass that can apply patterns liberally
-// and be plugged in a pass pipeline.
-//
-//===----------------------------------------------------------------------===//
-
-#include "mlir/Dialect/Linalg/Passes.h"
-
-#include "mlir/Analysis/SliceAnalysis.h"
-#include "mlir/Dialect/Affine/IR/AffineOps.h"
-#include "mlir/Dialect/Affine/LoopUtils.h"
-#include "mlir/Dialect/Affine/Utils.h"
-#include "mlir/Dialect/Func/IR/FuncOps.h"
-#include "mlir/Dialect/Linalg/IR/Linalg.h"
-#include "mlir/Dialect/Linalg/Transforms/Hoisting.h"
-#include "mlir/Dialect/Linalg/Transforms/Transforms.h"
-#include "mlir/Dialect/Linalg/Utils/Utils.h"
-#include "mlir/Dialect/SCF/Transforms/Transforms.h"
-#include "mlir/Dialect/Tensor/IR/Tensor.h"
-#include "mlir/Dialect/Vector/Transforms/VectorTransforms.h"
-#include "mlir/IR/AffineExpr.h"
-#include "mlir/IR/AffineMap.h"
-#include "mlir/Pass/PassManager.h"
-#include "mlir/Support/LLVM.h"
-#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
-#include "mlir/Transforms/LoopInvariantCodeMotionUtils.h"
-#include "mlir/Transforms/Passes.h"
-#include <utility>
-
-namespace mlir {
-#define GEN_PASS_DEF_LINALGSTRATEGYTILEANDFUSEPASS
-#define GEN_PASS_DEF_LINALGSTRATEGYTILEPASS
-#define GEN_PASS_DEF_LINALGSTRATEGYPADPASS
-#define GEN_PASS_DEF_LINALGSTRATEGYDECOMPOSEPASS
-#define GEN_PASS_DEF_LINALGSTRATEGYPEELPASS
-#define GEN_PASS_DEF_LINALGSTRATEGYLOWERVECTORSPASS
-#define GEN_PASS_DEF_LINALGSTRATEGYREMOVEMARKERSPASS
-#include "mlir/Dialect/Linalg/Passes.h.inc"
-} // namespace mlir
-
-using namespace mlir;
-using namespace mlir::vector;
-using namespace linalg;
-
-namespace {
-
-/// Configurable pass to lower vector operations.
-struct LinalgStrategyRemoveMarkersPass
-    : public impl::LinalgStrategyRemoveMarkersPassBase<
-          LinalgStrategyRemoveMarkersPass> {
-
-  void runOnOperation() override {
-    auto funcOp = getOperation();
-    if (!anchorFuncName.empty() && funcOp.getName() != anchorFuncName)
-      return;
-    funcOp.walk([](LinalgOp op) {
-      op->removeAttr(LinalgTransforms::kLinalgTransformMarker);
-    });
-  }
-};
-} // namespace
-
-/// Create a LinalgStrategyRemoveMarkersPass.
-std::unique_ptr<OperationPass<func::FuncOp>>
-mlir::createLinalgStrategyRemoveMarkersPass() {
-  return std::make_unique<LinalgStrategyRemoveMarkersPass>();
-}