Skip to content

Commit 3c1897a

Browse files
committed
pass's first commit
1 parent 7ac00fe commit 3c1897a

File tree

5 files changed

+46
-0
lines changed

5 files changed

+46
-0
lines changed

compiler/src/iree/compiler/GlobalOptimization/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ iree_compiler_cc_library(
5959
"InferNumericNarrowing.cpp",
6060
"MaterializeHomogeneousEncodings.cpp",
6161
"OptimizeNumerics.cpp",
62+
"PackedStorage.cpp",
6263
"Passes.cpp",
6364
"PropagateLinalgTranspose.cpp",
6465
"QuantizedConvToConv.cpp",

compiler/src/iree/compiler/GlobalOptimization/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ iree_cc_library(
5555
"InferNumericNarrowing.cpp"
5656
"MaterializeHomogeneousEncodings.cpp"
5757
"OptimizeNumerics.cpp"
58+
"PackedStorage.cpp"
5859
"Passes.cpp"
5960
"PropagateLinalgTranspose.cpp"
6061
"QuantizedConvToConv.cpp"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2024 The IREE Authors
2+
//
3+
// Licensed under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
7+
#include "iree/compiler/GlobalOptimization/Passes.h"
8+
#include "mlir/Dialect/Tensor/Transforms/Transforms.h"
9+
#include "mlir/Pass/Pass.h"
10+
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
11+
12+
namespace mlir::iree_compiler::GlobalOptimization {
13+
14+
#define GEN_PASS_DEF_PACKSTORAGEPASS
15+
#include "iree/compiler/GlobalOptimization/Passes.h.inc"
16+
17+
namespace {
18+
struct PackStoragePass
19+
: public impl::PackStoragePassBase<PackStoragePass> {
20+
21+
void runOnOperation() override;
22+
};
23+
} // namespace
24+
25+
void PackStoragePass::runOnOperation() {
26+
MLIRContext *context = &getContext();
27+
RewritePatternSet patterns(context);
28+
return signalPassFailure();
29+
}
30+
31+
} // namespace mlir::iree_compiler::GlobalOptimization

compiler/src/iree/compiler/GlobalOptimization/Passes.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ static llvm::cl::opt<int> clPadFactor(
6363
"encodings."),
6464
llvm::cl::init(32));
6565

66+
static llvm::cl::opt<bool> clEnablePackStorageForI1(
67+
"iree-global-opt-enable-pack-storage",
68+
llvm::cl::desc("Enables packed storage for i1 tensors."),
69+
llvm::cl::init(true));
70+
6671
void buildGlobalOptExprHoistingPassPipeline(
6772
OpPassManager &passManager, const TransformOptions &transformOptions) {
6873
IREE::Util::ExprHoistingOptions options;
@@ -249,6 +254,10 @@ void buildGlobalOptimizationPassPipeline(
249254
IREE::IO::Parameters::createGenerateSplatParameterArchivePass(
250255
generateSplatOptions));
251256
}
257+
258+
if (clEnablePackStorageForI1) {
259+
mainPassManager.addPass(createPackStoragePass());
260+
}
252261
}
253262

254263
namespace {

compiler/src/iree/compiler/GlobalOptimization/Passes.td

+4
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,8 @@ def DataLayoutPropagationPass : InterfacePass<"iree-global-opt-data-layout-propa
146146
let summary = "Propagate pack/unpack ops across other ops to improve fusion";
147147
}
148148

149+
def PackStoragePass : Pass<"iree-global-opt-pack-storage", ""> {
150+
let summary = "Pack sub-byte tensor ops to improve memory access patterns";
151+
}
152+
149153
#endif // IREE_COMPILER_GLOBALOPTIMIZATION_PASSES

0 commit comments

Comments
 (0)