forked from OSchip/llvm-project
[mlir][Linalg] NFC - Drop CodegenStrategy and remaining strategy passes
Differential Revision: https://reviews.llvm.org/D135759
This commit is contained in:
parent
8446f24ef0
commit
15faa55f65
|
@ -68,20 +68,6 @@ std::unique_ptr<OperationPass<func::FuncOp>> createLinalgGeneralizationPass();
|
|||
/// work on primitive types, if possible.
|
||||
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
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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_
|
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
}
|
|
@ -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>();
|
||||
}
|
Loading…
Reference in New Issue