[Mlir-commits] [mlir] 51e0946 - [mlir][linalg] Retire Linalg's StrategyVectorizePass
Guray Ozen
llvmlistbot at llvm.org
Thu Sep 15 02:12:29 PDT 2022
Author: Guray Ozen
Date: 2022-09-15T11:12:18+02:00
New Revision: 51e09465913a3a114053375c27b411f9d2a80602
URL: https://github.com/llvm/llvm-project/commit/51e09465913a3a114053375c27b411f9d2a80602
DIFF: https://github.com/llvm/llvm-project/commit/51e09465913a3a114053375c27b411f9d2a80602.diff
LOG: [mlir][linalg] Retire Linalg's StrategyVectorizePass
We retire linalg's strategy vectorize pass. Our goal is to use transform dialect instead of passes.
Reviewed By: nicolasvasilache
Differential Revision: https://reviews.llvm.org/D133684
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 820c5a870359d..830299ea707a4 100644
--- a/mlir/include/mlir/Dialect/Linalg/Passes.h
+++ b/mlir/include/mlir/Dialect/Linalg/Passes.h
@@ -134,15 +134,6 @@ std::unique_ptr<OperationPass<func::FuncOp>> createLinalgStrategyPeelPass(
const linalg::LinalgTransformationFilter &filter =
linalg::LinalgTransformationFilter());
-/// Create a LinalgStrategyVectorizePass.
-std::unique_ptr<OperationPass<func::FuncOp>> createLinalgStrategyVectorizePass(
- StringRef opName = "",
- linalg::LinalgVectorizationOptions opt =
- linalg::LinalgVectorizationOptions(),
- const linalg::LinalgTransformationFilter &filter =
- linalg::LinalgTransformationFilter(),
- bool padVectorize = false);
-
/// Create a LinalgStrategyLowerVectorsPass.
std::unique_ptr<OperationPass<func::FuncOp>>
createLinalgStrategyLowerVectorsPass(
diff --git a/mlir/include/mlir/Dialect/Linalg/Passes.td b/mlir/include/mlir/Dialect/Linalg/Passes.td
index d12ef02de3600..b6ed7a7fc1b14 100644
--- a/mlir/include/mlir/Dialect/Linalg/Passes.td
+++ b/mlir/include/mlir/Dialect/Linalg/Passes.td
@@ -238,21 +238,6 @@ def LinalgStrategyPeelPass
];
}
-def LinalgStrategyVectorizePass
- : Pass<"linalg-strategy-vectorize-pass", "func::FuncOp"> {
- let summary = "Configurable pass to apply pattern-based linalg vectorization.";
- let constructor = "mlir::createLinalgStrategyVectorizePass()";
- 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.">,
- Option<"vectorizePadding", "vectorize-padding", "bool", "false",
- "Enable vectorization of padding ops.">,
- ];
-}
-
def LinalgStrategyLowerVectorsPass
: Pass<"linalg-strategy-lower-vectors-pass", "func::FuncOp"> {
let summary = "Configurable pass to lower vector operations.";
diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h b/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h
index 21246d438737d..a5dfb5e693b35 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h
@@ -112,32 +112,6 @@ struct Peel : public Transformation {
linalg::LinalgPeelOptions options;
};
-/// Represent one application of createLinalgStrategyVectorizePass.
-struct Vectorize : public Transformation {
- explicit Vectorize(linalg::LinalgVectorizationOptions options,
- LinalgTransformationFilter::FilterFunction f = nullptr,
- bool padVectorize = false)
- : Transformation(std::move(f)), options(options),
- vectorizePadding(padVectorize) {}
-
- Vectorize(StringRef name, linalg::LinalgVectorizationOptions options,
- LinalgTransformationFilter::FilterFunction f = nullptr,
- bool padVectorize = false)
- : Transformation(std::move(f)), opName(name), options(options),
- vectorizePadding(padVectorize) {}
-
- void addToPassPipeline(OpPassManager &pm,
- LinalgTransformationFilter m) const override {
- pm.addPass(createLinalgStrategyVectorizePass(opName, options, m,
- vectorizePadding));
- }
-
-private:
- std::string opName;
- linalg::LinalgVectorizationOptions options;
- bool vectorizePadding;
-};
-
/// Represent one application of createLinalgStrategyLowerVectorsPass.
struct VectorLowering : public Transformation {
explicit VectorLowering(
@@ -203,7 +177,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 patterns to decompose convolutions.
CodegenStrategy &
decompose(const LinalgTransformationFilter::FilterFunction &f = nullptr) {
@@ -229,23 +203,6 @@ struct CodegenStrategy {
LinalgTransformationFilter::FilterFunction f = nullptr) {
return b ? peel(opName, options, std::move(f)) : *this;
}
- /// Append a pattern to rewrite `LinalgOpType` as a vector operation.
- CodegenStrategy &
- vectorize(StringRef opName,
- const LinalgTransformationFilter::FilterFunction &f = nullptr,
- bool vectorizePadding = false) {
- transformationSequence.emplace_back(std::make_unique<Vectorize>(
- opName, linalg::LinalgVectorizationOptions(), f, vectorizePadding));
- return *this;
- }
- /// Conditionally append a pattern to rewrite `LinalgOpType` as a vector
- /// operation.
- CodegenStrategy &
- vectorizeIf(bool b, StringRef opName,
- LinalgTransformationFilter::FilterFunction f = nullptr,
- bool vectorizePadding = false) {
- return b ? vectorize(opName, std::move(f), vectorizePadding) : *this;
- }
/// Append a pattern to lower all vector operations.
CodegenStrategy &vectorLowering(LinalgVectorLoweringOptions options) {
transformationSequence.emplace_back(
diff --git a/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp b/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp
index 05a47942c2da7..e2f272ff3955b 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp
@@ -40,7 +40,6 @@ namespace mlir {
#define GEN_PASS_DEF_LINALGSTRATEGYPADPASS
#define GEN_PASS_DEF_LINALGSTRATEGYDECOMPOSEPASS
#define GEN_PASS_DEF_LINALGSTRATEGYPEELPASS
-#define GEN_PASS_DEF_LINALGSTRATEGYVECTORIZEPASS
#define GEN_PASS_DEF_LINALGSTRATEGYLOWERVECTORSPASS
#define GEN_PASS_DEF_LINALGSTRATEGYREMOVEMARKERSPASS
#include "mlir/Dialect/Linalg/Passes.h.inc"
@@ -215,62 +214,6 @@ struct LinalgStrategyPeelPass
LinalgTransformationFilter filter;
};
-/// Configurable pass to apply pattern-based linalg vectorization.
-struct LinalgStrategyVectorizePass
- : public impl::LinalgStrategyVectorizePassBase<
- LinalgStrategyVectorizePass> {
-
- LinalgStrategyVectorizePass() = default;
-
- LinalgStrategyVectorizePass(StringRef opName, LinalgVectorizationOptions opt,
- LinalgTransformationFilter filt,
- bool padVectorize = false)
- : options(opt), filter(std::move(filt)) {
- this->anchorOpName.setValue(opName.str());
- this->vectorizePadding.setValue(padVectorize);
- }
-
- void runOnOperation() override {
- auto funcOp = getOperation();
- if (!anchorFuncName.empty() && funcOp.getName() != anchorFuncName)
- return;
-
- RewritePatternSet vectorizationPatterns(funcOp.getContext());
- if (!anchorOpName.empty()) {
- vectorizationPatterns.add<LinalgVectorizationPattern>(
- anchorOpName, funcOp.getContext(), options, filter);
- } else {
- vectorizationPatterns.add<LinalgVectorizationPattern>(funcOp.getContext(),
- filter, options);
- }
- vector::populateVectorTransferPermutationMapLoweringPatterns(
- vectorizationPatterns);
- vector::populateVectorReductionToContractPatterns(vectorizationPatterns);
- vectorizationPatterns.add<linalg::LinalgCopyVTRForwardingPattern,
- linalg::LinalgCopyVTWForwardingPattern>(
- funcOp.getContext(), /*benefit=*/2);
- TransferReadOp::getCanonicalizationPatterns(vectorizationPatterns,
- funcOp.getContext());
- TransferWriteOp::getCanonicalizationPatterns(vectorizationPatterns,
- funcOp.getContext());
- (void)applyPatternsAndFoldGreedily(funcOp,
- std::move(vectorizationPatterns));
-
- // Apply the pad tensor op vectorization separately to avoid running the
- // GenericPadOpVectorizationPattern too early.
- // TODO: Improve once we have better infrastructure to control pattern
- // application.
- if (vectorizePadding) {
- RewritePatternSet patterns(funcOp.getContext());
- linalg::populatePadOpVectorizationPatterns(patterns);
- (void)applyPatternsAndFoldGreedily(funcOp, std::move(patterns));
- }
- }
-
- LinalgVectorizationOptions options;
- LinalgTransformationFilter filter;
-};
-
/// Configurable pass to lower vector operations.
struct LinalgStrategyLowerVectorsPass
: public impl::LinalgStrategyLowerVectorsPassBase<
@@ -393,15 +336,6 @@ mlir::createLinalgStrategyPeelPass(StringRef opName,
return std::make_unique<LinalgStrategyPeelPass>(opName, opt, filter);
}
-/// Create a LinalgStrategyVectorizePass.
-std::unique_ptr<OperationPass<func::FuncOp>>
-mlir::createLinalgStrategyVectorizePass(
- StringRef opName, LinalgVectorizationOptions opt,
- const LinalgTransformationFilter &filter, bool padVectorize) {
- return std::make_unique<LinalgStrategyVectorizePass>(opName, opt, filter,
- padVectorize);
-}
-
/// Create a LinalgStrategyLowerVectorsPass.
std::unique_ptr<OperationPass<func::FuncOp>>
mlir::createLinalgStrategyLowerVectorsPass(
More information about the Mlir-commits
mailing list