Skip to content

Commit

Permalink
[NFC][Codegen] Move LLVMCPUDropVectorUnitDims to Common (iree-org#18578)
Browse files Browse the repository at this point in the history
The pass does not depend on anything LLVMCPU specific. Move it to common
for reuse with other backends.
  • Loading branch information
qedawkins authored Sep 23, 2024
1 parent 6fd9697 commit ac03e05
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 24 deletions.
1 change: 1 addition & 0 deletions compiler/src/iree/compiler/Codegen/Common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ iree_compiler_cc_library(
"DecomposeLinalgGeneric.cpp",
"DecomposePackUnPackOps.cpp",
"DecomposeSoftmax.cpp",
"DropVectorUnitDims.cpp",
"EmulateNarrowType.cpp",
"EncodingUtils.cpp",
"EraseDeadAllocAndStores.cpp",
Expand Down
1 change: 1 addition & 0 deletions compiler/src/iree/compiler/Codegen/Common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ iree_cc_library(
"DecomposeLinalgGeneric.cpp"
"DecomposePackUnPackOps.cpp"
"DecomposeSoftmax.cpp"
"DropVectorUnitDims.cpp"
"EmulateNarrowType.cpp"
"EncodingUtils.cpp"
"EraseDeadAllocAndStores.cpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,33 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include "iree/compiler/Codegen/LLVMCPU/Passes.h"
#include "iree/compiler/Codegen/Common/Passes.h"
#include "mlir/Dialect/Vector/Transforms/LoweringPatterns.h"
#include "mlir/Dialect/Vector/Transforms/VectorTransforms.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"

#define DEBUG_TYPE "iree-llvmcpu-drop-vector-unit-dims"
#define DEBUG_TYPE "iree-codegen-drop-vector-unit-dims"

namespace mlir::iree_compiler {

#define GEN_PASS_DEF_LLVMCPUDROPVECTORUNITDIMSPASS
#include "iree/compiler/Codegen/LLVMCPU/Passes.h.inc"
#define GEN_PASS_DEF_DROPVECTORUNITDIMSPASS
#include "iree/compiler/Codegen/Common/Passes.h.inc"

namespace {
class LLVMCPUDropVectorUnitDimsPass
: public impl::LLVMCPUDropVectorUnitDimsPassBase<
LLVMCPUDropVectorUnitDimsPass> {
class DropVectorUnitDimsPass
: public impl::DropVectorUnitDimsPassBase<DropVectorUnitDimsPass> {
public:
using impl::LLVMCPUDropVectorUnitDimsPassBase<
LLVMCPUDropVectorUnitDimsPass>::LLVMCPUDropVectorUnitDimsPassBase;
using impl::DropVectorUnitDimsPassBase<
DropVectorUnitDimsPass>::DropVectorUnitDimsPassBase;

void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<memref::MemRefDialect, vector::VectorDialect>();
}
void runOnOperation() override;
};

void LLVMCPUDropVectorUnitDimsPass::runOnOperation() {
void DropVectorUnitDimsPass::runOnOperation() {
MLIRContext *ctx = &getContext();
auto funcOp = getOperation();

Expand Down
17 changes: 11 additions & 6 deletions compiler/src/iree/compiler/Codegen/Common/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ def ConvertToDestinationPassingStylePass :
];
}

def ConvolutionToIGEMMPass :
InterfacePass<"iree-codegen-convolution-to-igemm", "mlir::FunctionOpInterface"> {
let summary =
"Transforms convolution operations into an implicit GEMM format.";
}

def DecomposeAffineOpsPass: Pass<"iree-codegen-decompose-affine-ops"> {
let summary = "Decompose `affine.apply` operations into sub `affine.apply`";
let description = [{
Expand Down Expand Up @@ -123,12 +129,6 @@ def DecomposeAffineOpsPass: Pass<"iree-codegen-decompose-affine-ops"> {
];
}

def ConvolutionToIGEMMPass :
InterfacePass<"iree-codegen-convolution-to-igemm", "mlir::FunctionOpInterface"> {
let summary =
"Transforms convolution operations into an implicit GEMM format.";
}

def DecomposeConvolutionToLowerDimOpsPass :
Pass<"iree-codegen-decompose-convolution-to-lower-dim-ops", ""> {
let summary = "Decomposes linalg convolution ops to lower dim ops";
Expand Down Expand Up @@ -170,6 +170,11 @@ def DecomposeSoftmaxPass :
];
}

def DropVectorUnitDimsPass :
InterfacePass<"iree-codegen-drop-vector-unit-dims", "mlir::FunctionOpInterface"> {
let summary = "Pass to drop vector unit dims.";
}

def ReconcileTranslationInfoPass
: Pass<"iree-codegen-reconcile-translation-info", "IREE::HAL::ExecutableVariantOp"> {
let summary =
Expand Down
1 change: 0 additions & 1 deletion compiler/src/iree/compiler/Codegen/LLVMCPU/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ iree_compiler_cc_library(
"LLVMCPUAssignConstantOrdinals.cpp",
"LLVMCPUAssignImportOrdinals.cpp",
"LLVMCPUCheckIRBeforeLLVMConversion.cpp",
"LLVMCPUDropVectorUnitDims.cpp",
"LLVMCPUEmitVectorizationRemarks.cpp",
"LLVMCPULinkExecutables.cpp",
"LLVMCPULowerExecutableTarget.cpp",
Expand Down
1 change: 0 additions & 1 deletion compiler/src/iree/compiler/Codegen/LLVMCPU/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ iree_cc_library(
"LLVMCPUAssignConstantOrdinals.cpp"
"LLVMCPUAssignImportOrdinals.cpp"
"LLVMCPUCheckIRBeforeLLVMConversion.cpp"
"LLVMCPUDropVectorUnitDims.cpp"
"LLVMCPUEmitVectorizationRemarks.cpp"
"LLVMCPULinkExecutables.cpp"
"LLVMCPULowerExecutableTarget.cpp"
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/iree/compiler/Codegen/LLVMCPU/Passes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ LogicalResult verifyConvTileAndDecomposeExpertConfig(
void buildLLVMCPUVectorLoweringPipeline(
OpPassManager &funcPassManager,
const LLVMCPUVectorLoweringPassOptions &options) {
funcPassManager.addPass(createLLVMCPUDropVectorUnitDimsPass());
funcPassManager.addPass(createDropVectorUnitDimsPass());
funcPassManager.addPass(createLLVMCPUVirtualVectorLoweringPass(
LLVMCPUVirtualVectorLoweringPassOptions{options.splitVectorTransfersTo,
options.enableArmI8mm}));
Expand Down
5 changes: 0 additions & 5 deletions compiler/src/iree/compiler/Codegen/LLVMCPU/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,6 @@ def LLVMCPUUnfuseFMAOpsPass :
let summary = "Convert llvm.fma into unfused mulf and addf ops";
}

def LLVMCPUDropVectorUnitDimsPass :
InterfacePass<"iree-llvmcpu-drop-vector-unit-dims", "mlir::FunctionOpInterface"> {
let summary = "Pass to drop vector unit dims.";
}

def LLVMCPUVirtualVectorLoweringPass :
InterfacePass<"iree-llvmcpu-virtual-vector-lowering", "mlir::FunctionOpInterface"> {
let summary = "Pass to lower high level vector operations like contract or multidim reduce ops to lower level vector ops.";
Expand Down

0 comments on commit ac03e05

Please sign in to comment.