From d16d8464090c0e74f185681a3195f180f979a828 Mon Sep 17 00:00:00 2001 From: Stanley Winata Date: Wed, 13 Dec 2023 01:35:53 -0600 Subject: [PATCH] Single line syntax + introduce wrapConsectutiveOp header to fuseDequant. --- .../GlobalOptimization/FuseDequantizationMatmul.cpp | 1 + .../Preprocessing/Common/ConvertConvNchwToNhwc.cpp | 8 ++------ .../Preprocessing/Common/ConvertConvToChannelsLast.cpp | 8 ++------ .../Preprocessing/Common/GeneralizeConvolutions.cpp | 8 ++------ compiler/src/iree/compiler/Preprocessing/Common/Passes.td | 6 +++--- 5 files changed, 10 insertions(+), 21 deletions(-) diff --git a/compiler/src/iree/compiler/GlobalOptimization/FuseDequantizationMatmul.cpp b/compiler/src/iree/compiler/GlobalOptimization/FuseDequantizationMatmul.cpp index aa3473b5cbf1..9c6f0c5badc8 100644 --- a/compiler/src/iree/compiler/GlobalOptimization/FuseDequantizationMatmul.cpp +++ b/compiler/src/iree/compiler/GlobalOptimization/FuseDequantizationMatmul.cpp @@ -8,6 +8,7 @@ #include "iree/compiler/Dialect/Flow/Transforms/RegionOpUtils.h" #include "iree/compiler/GlobalOptimization/PassDetail.h" #include "iree/compiler/GlobalOptimization/Passes.h" +#include "iree/compiler/GlobalOptimization/Utils.h" #include "mlir/Dialect/Arith/IR/Arith.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" #include "mlir/Dialect/Linalg/IR/LinalgInterfaces.h" diff --git a/compiler/src/iree/compiler/Preprocessing/Common/ConvertConvNchwToNhwc.cpp b/compiler/src/iree/compiler/Preprocessing/Common/ConvertConvNchwToNhwc.cpp index 5704f18ed466..fdf60f9e4493 100644 --- a/compiler/src/iree/compiler/Preprocessing/Common/ConvertConvNchwToNhwc.cpp +++ b/compiler/src/iree/compiler/Preprocessing/Common/ConvertConvNchwToNhwc.cpp @@ -18,9 +18,7 @@ #define DEBUG_TYPE "iree-flow-convert-conv-nchw-to-nhwc" -namespace mlir { -namespace iree_compiler { -namespace IREE { +namespace mlir::iree_compiler::Preprocessing { using TransposeIndices = SmallVector; @@ -559,6 +557,4 @@ createConvertConvNchwToNhwcPass() { return std::make_unique(); } -} // namespace IREE -} // namespace iree_compiler -} // namespace mlir +} // namespace mlir::iree_compiler::Preprocessing diff --git a/compiler/src/iree/compiler/Preprocessing/Common/ConvertConvToChannelsLast.cpp b/compiler/src/iree/compiler/Preprocessing/Common/ConvertConvToChannelsLast.cpp index 4a8b833bfb1a..f7d278b318d7 100644 --- a/compiler/src/iree/compiler/Preprocessing/Common/ConvertConvToChannelsLast.cpp +++ b/compiler/src/iree/compiler/Preprocessing/Common/ConvertConvToChannelsLast.cpp @@ -23,9 +23,7 @@ #define DEBUG_TYPE "iree-preprocessing-convert-conv-to-channels-last" -namespace mlir { -namespace iree_compiler { -namespace IREE { +namespace mlir::iree_compiler::Preprocessing { static const StringLiteral fullTileTransposeMarker = "__fully_transpose_tile__"; @@ -885,6 +883,4 @@ std::unique_ptr createConvertConvToChannelsLastPass() { return std::make_unique(); } -} // namespace IREE -} // namespace iree_compiler -} // namespace mlir +} // namespace mlir::iree_compiler::Preprocessing diff --git a/compiler/src/iree/compiler/Preprocessing/Common/GeneralizeConvolutions.cpp b/compiler/src/iree/compiler/Preprocessing/Common/GeneralizeConvolutions.cpp index ada980a788ed..f3a56404375e 100644 --- a/compiler/src/iree/compiler/Preprocessing/Common/GeneralizeConvolutions.cpp +++ b/compiler/src/iree/compiler/Preprocessing/Common/GeneralizeConvolutions.cpp @@ -20,9 +20,7 @@ #include "mlir/Pass/Pass.h" #include "mlir/Transforms/GreedyPatternRewriteDriver.h" -namespace mlir { -namespace iree_compiler { -namespace IREE { +namespace mlir::iree_compiler::Preprocessing { namespace { @@ -63,6 +61,4 @@ std::unique_ptr createGeneralizeConvolutionsPass() { return std::make_unique(); } -} // namespace IREE -} // namespace iree_compiler -} // namespace mlir +} // namespace mlir::iree_compiler::Preprocessing diff --git a/compiler/src/iree/compiler/Preprocessing/Common/Passes.td b/compiler/src/iree/compiler/Preprocessing/Common/Passes.td index a2fb9328965f..0f523fdcd3c9 100644 --- a/compiler/src/iree/compiler/Preprocessing/Common/Passes.td +++ b/compiler/src/iree/compiler/Preprocessing/Common/Passes.td @@ -19,7 +19,7 @@ def ConvertConvNchwToNhwc : InterfacePass<"iree-flow-convert-conv-nchw-to-nhwc", "mlir::FunctionOpInterface"> { let summary = "Convert linalg NCHW Convolutions to NHWC"; let constructor = - "mlir::iree_compiler::IREE::createConvertConvNchwToNhwcPass()"; + "mlir::iree_compiler::Preprocessing::createConvertConvNchwToNhwcPass()"; } def MakeSingleDispatchForFunction : @@ -31,14 +31,14 @@ def MakeSingleDispatchForFunction : def GeneralizeConvolutions : Pass<"iree-preprocessing-generalize-convolutions", ""> { let summary = "Generalize all convolution ops"; - let constructor = "mlir::iree_compiler::IREE::createGeneralizeConvolutionsPass()"; + let constructor = "mlir::iree_compiler::Preprocessing::createGeneralizeConvolutionsPass()"; } def ConvertConvToChannelsLast : Pass<"iree-preprocessing-convert-conv-to-channels-last", ""> { let summary = "Convert linalg convolutions to channels last."; let constructor = - "mlir::iree_compiler::IREE::createConvertConvToChannelsLastPass()"; + "mlir::iree_compiler::Preprocessing::createConvertConvToChannelsLastPass()"; let options = [ Option<"tileSize", "tile-size", "int", /*default=*/"0",