From 660f281b5e755663b2d8ad061075eb5f5abdf9fb Mon Sep 17 00:00:00 2001 From: Nicolas Vasilache Date: Wed, 15 Sep 2021 11:00:06 +0000 Subject: [PATCH] [mlir][Linalg] Make codegen strategy late transformations opt-in Summary: Making the late transformations opt-in results in less surprising behavior when composing multiple calls to the codegen strategy. Reviewers: Subscribers: Differential revision: https://reviews.llvm.org/D109820 --- .../mlir/Dialect/Linalg/Transforms/CodegenStrategy.h | 10 +++++++--- .../lib/Dialect/Linalg/TestLinalgCodegenStrategy.cpp | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h b/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h index bee0d5a12800..d33dd81fa323 100644 --- a/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h +++ b/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h @@ -152,12 +152,16 @@ private: /// Options to control the application of late transformations. struct LateCodegenStrategyOptions { + /// Hoisting transformations are always deemed beneficial and must disabled + /// explicitly. bool enableLICM = true; bool enableHoistRedundantVectorTransfers = true; bool enableHoistRedundantVectorTransfersOnTensor = true; - bool enableVectorTransferPartialRewrite = true; - bool enableVectorContractLowering = true; - bool enableVectorToSCFConversion = true; + /// Vector lowering operations may result in surprising behavior when + /// composing multiple codegen strategies and must be enabled explicitly. + bool enableVectorTransferPartialRewrite = false; + bool enableVectorContractLowering = false; + bool enableVectorToSCFConversion = false; }; /// Codegen strategy controls how a Linalg op is progressively lowered. diff --git a/mlir/test/lib/Dialect/Linalg/TestLinalgCodegenStrategy.cpp b/mlir/test/lib/Dialect/Linalg/TestLinalgCodegenStrategy.cpp index 658eb8a61ac9..8f2cd6c689a0 100644 --- a/mlir/test/lib/Dialect/Linalg/TestLinalgCodegenStrategy.cpp +++ b/mlir/test/lib/Dialect/Linalg/TestLinalgCodegenStrategy.cpp @@ -148,6 +148,9 @@ void TestLinalgCodegenStrategy::runStrategy( .setAlignment(16) .setUseFullTileBuffersByDefault(registerPromoteFullTile)) .vectorizeIf(vectorize, anchorOpName) + .setEnableVectorTransferPartialRewrite(true) + .setEnableVectorContractLowering(true) + .setEnableVectorToSCFConversion(true) .setVectorTransformsOptions( vector::VectorTransformsOptions() .setVectorTransformsOptions(vectorContractLowering) @@ -177,6 +180,9 @@ void TestLinalgCodegenStrategy::runStrategy( .setAlignment(16) .setUseFullTileBuffersByDefault(registerPromoteFullTile)) .template vectorizeIf(vectorize) + .setEnableVectorTransferPartialRewrite(true) + .setEnableVectorContractLowering(true) + .setEnableVectorToSCFConversion(true) .setVectorTransformsOptions( vector::VectorTransformsOptions() .setVectorTransformsOptions(vectorContractLowering)