[Mlir-commits] [mlir] 97d67f7 - [mlir][linalg] Add vector transfer lowering patters to codegen strategy.
Tobias Gysi
llvmlistbot at llvm.org
Tue Oct 12 07:20:43 PDT 2021
Author: Tobias Gysi
Date: 2021-10-12T14:19:45Z
New Revision: 97d67f7438703c9dbe494c9e675348fecc98106f
URL: https://github.com/llvm/llvm-project/commit/97d67f7438703c9dbe494c9e675348fecc98106f
DIFF: https://github.com/llvm/llvm-project/commit/97d67f7438703c9dbe494c9e675348fecc98106f.diff
LOG: [mlir][linalg] Add vector transfer lowering patters to codegen strategy.
Add the vector transfer patterns and introduce the max transfer rank option on the codegen strategy.
Reviewed By: nicolasvasilache
Differential Revision: https://reviews.llvm.org/D111635
Added:
Modified:
mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h
mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp
mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h b/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h
index 1745b797e5478..251b850f3c8c5 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h
@@ -224,6 +224,10 @@ struct CodegenStrategy {
.enableHoistRedundantVectorTransfersOnTensor = val;
return *this;
}
+ CodegenStrategy &setMaxTransferRank(int64_t val) {
+ this->lateCodegenStrategyOptions.maxTransferRank = val;
+ return *this;
+ }
CodegenStrategy &setEnableVectorTransferPartialRewrite(bool val) {
this->lateCodegenStrategyOptions.enableVectorTransferPartialRewrite = val;
return *this;
diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
index 60b6e1a2a13a8..6d8422f3fbd50 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
@@ -835,6 +835,7 @@ struct LateCodegenStrategyOptions {
bool enableHoistRedundantVectorTransfersOnTensor = true;
/// Vector lowering operations may result in surprising behavior when
/// composing multiple codegen strategies and must be enabled explicitly.
+ int64_t maxTransferRank = 1;
bool enableVectorTransferPartialRewrite = false;
bool enableVectorContractLowering = false;
bool enableVectorToSCFConversion = false;
@@ -852,6 +853,7 @@ struct LinalgEnablingOptions {
/// Vector lowering options control how ops are lowered down to 1-D and scf.for
/// form.
struct LinalgVectorLoweringOptions {
+ int64_t maxTransferRank = 1;
bool enableVectorTransferPartialRewrite = false;
bool enableVectorContractLowering = false;
bool enableVectorToSCFConversion = false;
diff --git a/mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp b/mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp
index cd0e75cc8a17b..04bdc4901cce2 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp
@@ -47,6 +47,8 @@ void mlir::linalg::CodegenStrategy::configurePassPipeline(
pm.addPass(createLinalgStrategyEnablePass());
}
LinalgVectorLoweringOptions vectorLoweringOptions;
+ vectorLoweringOptions.maxTransferRank =
+ lateCodegenStrategyOptions.maxTransferRank;
vectorLoweringOptions.enableVectorTransferPartialRewrite =
lateCodegenStrategyOptions.enableVectorTransferPartialRewrite;
vectorLoweringOptions.enableVectorContractLowering =
diff --git a/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp b/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp
index e21785d5cbb48..bb1793d424659 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp
@@ -260,6 +260,8 @@ struct LinalgStrategyLowerVectorsPass
MLIRContext *context = funcOp.getContext();
RewritePatternSet patterns(context);
+ vector::populateVectorTransferLoweringPatterns(patterns,
+ options.maxTransferRank);
if (options.enableVectorTransferPartialRewrite) {
patterns.add<vector::VectorTransferFullPartialRewriter>(
context, options.vectorTransformOptions);
More information about the Mlir-commits
mailing list