diff --git a/mlir/include/mlir/Dialect/Linalg/Passes.h b/mlir/include/mlir/Dialect/Linalg/Passes.h --- a/mlir/include/mlir/Dialect/Linalg/Passes.h +++ b/mlir/include/mlir/Dialect/Linalg/Passes.h @@ -134,15 +134,6 @@ const linalg::LinalgTransformationFilter &filter = linalg::LinalgTransformationFilter()); -/// Create a LinalgStrategyVectorizePass. -std::unique_ptr> createLinalgStrategyVectorizePass( - StringRef opName = "", - linalg::LinalgVectorizationOptions opt = - linalg::LinalgVectorizationOptions(), - const linalg::LinalgTransformationFilter &filter = - linalg::LinalgTransformationFilter(), - bool padVectorize = false); - /// Create a LinalgStrategyLowerVectorsPass. std::unique_ptr> createLinalgStrategyLowerVectorsPass( diff --git a/mlir/include/mlir/Dialect/Linalg/Passes.td b/mlir/include/mlir/Dialect/Linalg/Passes.td --- a/mlir/include/mlir/Dialect/Linalg/Passes.td +++ b/mlir/include/mlir/Dialect/Linalg/Passes.td @@ -238,21 +238,6 @@ ]; } -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 --- a/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h +++ b/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h @@ -112,32 +112,6 @@ 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 @@ 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 @@ 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( - 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 --- a/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp @@ -40,7 +40,6 @@ #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 @@ 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( - anchorOpName, funcOp.getContext(), options, filter); - } else { - vectorizationPatterns.add(funcOp.getContext(), - filter, options); - } - vector::populateVectorTransferPermutationMapLoweringPatterns( - vectorizationPatterns); - vector::populateVectorReductionToContractPatterns(vectorizationPatterns); - vectorizationPatterns.add( - 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 @@ return std::make_unique(opName, opt, filter); } -/// Create a LinalgStrategyVectorizePass. -std::unique_ptr> -mlir::createLinalgStrategyVectorizePass( - StringRef opName, LinalgVectorizationOptions opt, - const LinalgTransformationFilter &filter, bool padVectorize) { - return std::make_unique(opName, opt, filter, - padVectorize); -} - /// Create a LinalgStrategyLowerVectorsPass. std::unique_ptr> mlir::createLinalgStrategyLowerVectorsPass(