Skip to content

Commit 9130c1d

Browse files
authored
Merge 25b36fc into 5a48912
2 parents 5a48912 + 25b36fc commit 9130c1d

72 files changed

Lines changed: 535 additions & 959 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

compiler/src/iree/compiler/Codegen/Common/AddFastMathFlags.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66

7-
#include "iree/compiler/Codegen/Common/PassDetail.h"
87
#include "iree/compiler/Codegen/Common/Passes.h"
98
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
109
#include "mlir/IR/Matchers.h"
@@ -13,8 +12,10 @@
1312

1413
#define DEBUG_TYPE "iree-codegen-add-fast-math-flags"
1514

16-
using namespace mlir;
17-
using namespace mlir::iree_compiler;
15+
namespace mlir::iree_compiler {
16+
17+
#define GEN_PASS_DEF_ADDFASTMATHFLAGSPASS
18+
#include "iree/compiler/Codegen/Common/Passes.h.inc"
1819

1920
/// Add `contract` FMF to operations that support it.
2021
static void addContractFMF(Operation *op) {
@@ -29,19 +30,16 @@ namespace {
2930
/// Add the corresponding fast-math flags to operations given a floating-point
3031
/// optimization mode.
3132
// TODO: For now we only allow default flags, such as arithmetic reassociation.
32-
struct AddFastMathFlagsPass
33-
: public AddFastMathFlagsBase<AddFastMathFlagsPass> {
33+
struct AddFastMathFlagsPass final
34+
: impl::AddFastMathFlagsPassBase<AddFastMathFlagsPass> {
3435
public:
35-
using AddFastMathFlagsBase::AddFastMathFlagsBase;
36+
using impl::AddFastMathFlagsPassBase<
37+
AddFastMathFlagsPass>::AddFastMathFlagsPassBase;
3638

3739
void runOnOperation() override {
3840
getOperation()->walk([](Operation *op) { addContractFMF(op); });
3941
}
4042
};
4143

4244
} // namespace
43-
44-
std::unique_ptr<OperationPass<LLVM::LLVMFuncOp>>
45-
mlir::iree_compiler::createAddFastMathFlagsPass() {
46-
return std::make_unique<AddFastMathFlagsPass>();
47-
}
45+
} // namespace mlir::iree_compiler

compiler/src/iree/compiler/Codegen/Common/BUILD.bazel

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ iree_gentbl_cc_library(
2828
iree_compiler_cc_library(
2929
name = "PassHeaders",
3030
hdrs = [
31-
"PassDetail.h",
3231
"Passes.h",
3332
"Passes.h.inc",
3433
],
@@ -133,9 +132,10 @@ iree_compiler_cc_library(
133132
"PropagateReshapesByExpansion.cpp",
134133
"ReconcileTranslationInfo.cpp",
135134
"RematerializeParallelOps.cpp",
136-
"RemoveTrivialLoops.cpp",
135+
"RemoveSingleIterationLoop.cpp",
137136
"ReplaceSlowMinMaxOps.cpp",
138137
"SplitFullPartialTransferPass.cpp",
138+
"TensorToVectorVectorizePad.cpp",
139139
"TestExecutablePreprocessing.cpp",
140140
"TestPartitionableLoopsInterface.cpp",
141141
"TileAndDistributeToWorkgroupsPass.cpp",
@@ -144,7 +144,6 @@ iree_compiler_cc_library(
144144
"TypePropagationPass.cpp",
145145
"UserConfig.cpp",
146146
"VectorizeMemrefCopy.cpp",
147-
"VectorizePad.cpp",
148147
],
149148
hdrs = [
150149
"BufferizationAnalysis.h",

compiler/src/iree/compiler/Codegen/Common/BubbleUpOrdinalOps.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@
1111
//
1212
//===---------------------------------------------------------------------===//
1313

14-
#include "iree/compiler/Codegen/Common/PassDetail.h"
1514
#include "iree/compiler/Codegen/Common/Passes.h"
1615
#include "iree/compiler/Dialect/Flow/IR/FlowOps.h"
1716
#include "mlir/Dialect/Arith/IR/Arith.h"
1817
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
1918

2019
namespace mlir::iree_compiler {
2120

21+
#define GEN_PASS_DEF_BUBBLEUPORDINALOPSPASS
22+
#include "iree/compiler/Codegen/Common/Passes.h.inc"
23+
2224
namespace {
2325

2426
/// Replace the following sequence
@@ -62,8 +64,8 @@ struct BubbleUpAcrossCastOp
6264
}
6365
};
6466

65-
struct BubbleUpOrdinalOpsPass
66-
: public BubbleUpOrdinalOpsBase<BubbleUpOrdinalOpsPass> {
67+
struct BubbleUpOrdinalOpsPass final
68+
: impl::BubbleUpOrdinalOpsPassBase<BubbleUpOrdinalOpsPass> {
6769
void runOnOperation() override;
6870
};
6971
} // namespace
@@ -77,9 +79,4 @@ void BubbleUpOrdinalOpsPass::runOnOperation() {
7779
return signalPassFailure();
7880
}
7981
}
80-
81-
std::unique_ptr<Pass> createBubbleUpOrdinalOpsPass() {
82-
return std::make_unique<BubbleUpOrdinalOpsPass>();
83-
}
84-
8582
} // namespace mlir::iree_compiler

compiler/src/iree/compiler/Codegen/Common/BufferizeCopyOnlyDispatchesPass.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//
1212
//===----------------------------------------------------------------------===//
1313

14-
#include "iree/compiler/Codegen/Common/PassDetail.h"
1514
#include "iree/compiler/Codegen/Common/PassUtils.h"
1615
#include "iree/compiler/Codegen/Common/Passes.h"
1716
#include "iree/compiler/Codegen/Utils/Utils.h"
@@ -30,16 +29,18 @@
3029

3130
namespace mlir::iree_compiler {
3231

32+
#define GEN_PASS_DEF_BUFFERIZECOPYONLYDISPATCHESPASS
33+
#include "iree/compiler/Codegen/Common/Passes.h.inc"
34+
3335
namespace {
3436

3537
/// Pass to bufferize early copy-only dispatches. This allows backends
3638
/// to use the `linalg.generic` operation generated for lowering the dispatch.
37-
struct BufferizeCopyOnlyDispatchesPass
38-
: public BufferizeCopyOnlyDispatchesBase<BufferizeCopyOnlyDispatchesPass> {
39-
BufferizeCopyOnlyDispatchesPass() = default;
40-
BufferizeCopyOnlyDispatchesPass(const BufferizeCopyOnlyDispatchesPass &pass) {
41-
}
42-
39+
struct BufferizeCopyOnlyDispatchesPass final
40+
: impl::BufferizeCopyOnlyDispatchesPassBase<
41+
BufferizeCopyOnlyDispatchesPass> {
42+
using impl::BufferizeCopyOnlyDispatchesPassBase<
43+
BufferizeCopyOnlyDispatchesPass>::BufferizeCopyOnlyDispatchesPassBase;
4344
void getDependentDialects(DialectRegistry &registry) const override {
4445
registry.insert<affine::AffineDialect, bufferization::BufferizationDialect,
4546
IREE::Flow::FlowDialect, linalg::LinalgDialect,
@@ -109,9 +110,4 @@ void BufferizeCopyOnlyDispatchesPass::runOnOperation() {
109110
}
110111
}
111112

112-
std::unique_ptr<InterfacePass<FunctionOpInterface>>
113-
createBufferizeCopyOnlyDispatchesPass() {
114-
return std::make_unique<BufferizeCopyOnlyDispatchesPass>();
115-
}
116-
117113
} // namespace mlir::iree_compiler

compiler/src/iree/compiler/Codegen/Common/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ iree_cc_library(
2323
NAME
2424
PassHeaders
2525
HDRS
26-
"PassDetail.h"
2726
"Passes.h"
2827
"Passes.h.inc"
2928
DEPS
@@ -124,9 +123,10 @@ iree_cc_library(
124123
"PropagateReshapesByExpansion.cpp"
125124
"ReconcileTranslationInfo.cpp"
126125
"RematerializeParallelOps.cpp"
127-
"RemoveTrivialLoops.cpp"
126+
"RemoveSingleIterationLoop.cpp"
128127
"ReplaceSlowMinMaxOps.cpp"
129128
"SplitFullPartialTransferPass.cpp"
129+
"TensorToVectorVectorizePad.cpp"
130130
"TestExecutablePreprocessing.cpp"
131131
"TestPartitionableLoopsInterface.cpp"
132132
"TileAndDistributeToWorkgroupsPass.cpp"
@@ -135,7 +135,6 @@ iree_cc_library(
135135
"TypePropagationPass.cpp"
136136
"UserConfig.cpp"
137137
"VectorizeMemrefCopy.cpp"
138-
"VectorizePad.cpp"
139138
DEPS
140139
::PassHeaders
141140
::PassesIncGen

compiler/src/iree/compiler/Codegen/Common/CleanupBufferAllocViewPass.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
#include "iree/compiler/Codegen/Common/PassDetail.h"
1615
#include "iree/compiler/Codegen/Common/Passes.h"
1716
#include "iree/compiler/Codegen/Transforms/Transforms.h"
1817
#include "iree/compiler/Dialect/Flow/IR/FlowOps.h"
@@ -26,11 +25,14 @@
2625

2726
namespace mlir::iree_compiler {
2827

28+
#define GEN_PASS_DEF_CLEANUPBUFFERALLOCVIEWPASS
29+
#include "iree/compiler/Codegen/Common/Passes.h.inc"
30+
2931
namespace {
3032

3133
/// Runs canonicalization patterns on interface load/store ops.
32-
struct CleanupBufferAllocViewPass
33-
: public CleanupBufferAllocViewBase<CleanupBufferAllocViewPass> {
34+
struct CleanupBufferAllocViewPass final
35+
: impl::CleanupBufferAllocViewPassBase<CleanupBufferAllocViewPass> {
3436
void runOnOperation() override {
3537
RewritePatternSet patterns(&getContext());
3638
populateReshapeToInterfaceTensorPatterns(patterns);
@@ -43,10 +45,4 @@ struct CleanupBufferAllocViewPass
4345
};
4446

4547
} // namespace
46-
47-
std::unique_ptr<InterfacePass<mlir::FunctionOpInterface>>
48-
createCleanupBufferAllocViewPass() {
49-
return std::make_unique<CleanupBufferAllocViewPass>();
50-
}
51-
5248
} // namespace mlir::iree_compiler

compiler/src/iree/compiler/Codegen/Common/CommonDialectRegistration.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66

77
#include "iree-dialects/Dialect/LinalgTransform/StructuredTransformOpsExt.h"
8-
#include "iree/compiler/Codegen/Common/PassDetail.h"
98
#include "iree/compiler/Codegen/Common/Passes.h"
109
#include "iree/compiler/Codegen/Common/TransformExtensions/CommonExtensions.h"
1110
#include "iree/compiler/Codegen/Dialect/Codegen/IR/IREECodegenDialect.h"

compiler/src/iree/compiler/Codegen/Common/ConcretizePadResultShape.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66

7-
#include "iree/compiler/Codegen/Common/PassDetail.h"
87
#include "iree/compiler/Codegen/Common/Passes.h"
98
#include "iree/compiler/Dialect/Flow/IR/FlowOps.h"
109
#include "llvm/Support/Debug.h"
@@ -24,6 +23,9 @@
2423

2524
namespace mlir::iree_compiler {
2625

26+
#define GEN_PASS_DEF_CONCRETIZEPADRESULTSHAPEPASS
27+
#include "iree/compiler/Codegen/Common/Passes.h.inc"
28+
2729
/// Gets the given `attrOrValue` as an index value by creating constant ops
2830
/// for attributes.
2931
static Value getAsIndexValue(OpFoldResult attrOrValue, OpBuilder &builder,
@@ -126,12 +128,9 @@ struct ConcretizePadResultShape final : public OpRewritePattern<tensor::PadOp> {
126128
};
127129

128130
class ConcretizePadResultShapePass final
129-
: public ConcretizePadResultShapeBase<ConcretizePadResultShapePass> {
131+
: public impl::ConcretizePadResultShapePassBase<
132+
ConcretizePadResultShapePass> {
130133
public:
131-
ConcretizePadResultShapePass() = default;
132-
ConcretizePadResultShapePass(const ConcretizePadResultShapePass &pass) =
133-
default;
134-
135134
void runOnOperation() override {
136135
MLIRContext *context = &getContext();
137136
auto funcOp = getOperation();
@@ -155,11 +154,6 @@ class ConcretizePadResultShapePass final
155154

156155
} // namespace
157156

158-
std::unique_ptr<InterfacePass<mlir::FunctionOpInterface>>
159-
createConcretizePadResultShapePass() {
160-
return std::make_unique<ConcretizePadResultShapePass>();
161-
}
162-
163157
void populateConcretizePadResultShapePatterns(RewritePatternSet &patterns,
164158
ArrayRef<int64_t> numWorkgroups) {
165159
MLIRContext *context = patterns.getContext();

compiler/src/iree/compiler/Codegen/Common/ConvertBf16ArithToF32.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <memory>
1515
#include <utility>
1616

17-
#include "iree/compiler/Codegen/Common/PassDetail.h"
1817
#include "iree/compiler/Codegen/Common/Passes.h"
1918
#include "iree/compiler/Dialect/HAL/IR/HALDialect.h"
2019
#include "iree/compiler/Dialect/HAL/IR/HALOps.h"
@@ -39,6 +38,9 @@
3938

4039
namespace mlir::iree_compiler {
4140

41+
#define GEN_PASS_DEF_CONVERTBF16ARITHTOF32PASS
42+
#include "iree/compiler/Codegen/Common/Passes.h.inc"
43+
4244
namespace {
4345

4446
Value convertRankedFloat(OpBuilder &builder, Type type, ValueRange inputs,
@@ -235,9 +237,10 @@ struct PromoteBF16ToF32Converter
235237
}
236238
};
237239

238-
struct ConvertBf16ArithToF32Pass
239-
: public ConvertBf16ArithToF32Base<ConvertBf16ArithToF32Pass> {
240-
using ConvertBf16ArithToF32Base::ConvertBf16ArithToF32Base;
240+
struct ConvertBf16ArithToF32Pass final
241+
: impl::ConvertBf16ArithToF32PassBase<ConvertBf16ArithToF32Pass> {
242+
using impl::ConvertBf16ArithToF32PassBase<
243+
ConvertBf16ArithToF32Pass>::ConvertBf16ArithToF32PassBase;
241244
void runOnOperation() override {
242245
MLIRContext *context = &this->getContext();
243246
RewritePatternSet patterns(context);
@@ -312,9 +315,4 @@ struct ConvertBf16ArithToF32Pass
312315
};
313316

314317
} // namespace
315-
316-
std::unique_ptr<OperationPass<>> createConvertBf16ArithToF32Pass() {
317-
return std::make_unique<ConvertBf16ArithToF32Pass>();
318-
}
319-
320318
} // namespace mlir::iree_compiler

compiler/src/iree/compiler/Codegen/Common/ConvertBf16ToUInt16Buffers.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//
1212
//===----------------------------------------------------------------------===//
1313

14-
#include "iree/compiler/Codegen/Common/PassDetail.h"
1514
#include "iree/compiler/Codegen/Common/Passes.h"
1615
#include "iree/compiler/Codegen/Dialect/Codegen/IR/IREECodegenDialect.h"
1716
#include "iree/compiler/Dialect/HAL/IR/HALDialect.h"
@@ -24,6 +23,7 @@
2423
#include "mlir/Dialect/Arith/Transforms/Passes.h"
2524
#include "mlir/Dialect/Func/IR/FuncOps.h"
2625
#include "mlir/Dialect/Func/Transforms/FuncConversions.h"
26+
#include "mlir/Dialect/MemRef/IR/MemRef.h"
2727
#include "mlir/Dialect/MemRef/Transforms/Transforms.h"
2828
#include "mlir/Dialect/SCF/IR/SCF.h"
2929
#include "mlir/Dialect/Vector/IR/VectorOps.h"
@@ -34,10 +34,13 @@
3434
#include "mlir/Transforms/DialectConversion.h"
3535
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
3636

37-
#define DEBUG_TYPE "iree-spirv-emulate-bf16"
37+
#define DEBUG_TYPE "iree-codegen-convert-bf16-to-uint16-buffers"
3838

3939
namespace mlir::iree_compiler {
4040

41+
#define GEN_PASS_DEF_CONVERTBF16TOUINT16BUFFERSPASS
42+
#include "iree/compiler/Codegen/Common/Passes.h.inc"
43+
4144
namespace {
4245

4346
class Bf16EmulationConverter : public TypeConverter {
@@ -249,7 +252,7 @@ static void populateIreeBf16EmulationPatterns(RewritePatternSet &patterns,
249252
//===----------------------------------------------------------------------===//
250253

251254
struct ConvertBf16ToUInt16BuffersPass final
252-
: public ConvertBf16ToUInt16BuffersBase<ConvertBf16ToUInt16BuffersPass> {
255+
: impl::ConvertBf16ToUInt16BuffersPassBase<ConvertBf16ToUInt16BuffersPass> {
253256
void getDependentDialects(DialectRegistry &registry) const override {
254257
registry.insert<vector::VectorDialect>();
255258
}
@@ -312,13 +315,4 @@ struct ConvertBf16ToUInt16BuffersPass final
312315
};
313316

314317
} // namespace
315-
316-
//===----------------------------------------------------------------------===//
317-
// Public interface
318-
//===----------------------------------------------------------------------===//
319-
320-
std::unique_ptr<OperationPass<>> createConvertBf16ToUInt16BuffersPass() {
321-
return std::make_unique<ConvertBf16ToUInt16BuffersPass>();
322-
}
323-
324318
} // namespace mlir::iree_compiler

0 commit comments

Comments
 (0)