Skip to content

Commit 48e8049

Browse files
authored
Refactor BufferizeOperand naming for clarity (#981)
1 parent 71e17ed commit 48e8049

File tree

5 files changed

+101
-101
lines changed

5 files changed

+101
-101
lines changed

compiler/plugins/target/AMD-AIE/iree-amd-aie/Transforms/AMDAIEBufferizeToAllocation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ static FailureOr<SmallVector<Value>> getOperandsToBufferize(
103103
uint32_t packDepth) {
104104
switch (bufferizeOperand) {
105105
/// Create new allocations for Lhs, Rhs and Out.
106-
case BufferizeOperand::InputOutput:
106+
case BufferizeOperand::LinalgInputOutput:
107107
return getInputOutputOperands(linalgOp);
108108
/// Create new allocation only for Lhs, Rhs.
109-
case BufferizeOperand::Input:
109+
case BufferizeOperand::LinalgInput:
110110
return getInputOperands(linalgOp);
111111
/// Create new allocations only for Out.
112-
case BufferizeOperand::Output:
112+
case BufferizeOperand::LinalgOutput:
113113
return SmallVector<Value>(linalgOp.getDpsInits());
114114
/// Create new allocations for operands from the pack ops.
115115
case BufferizeOperand::PackInput:

compiler/plugins/target/AMD-AIE/iree-amd-aie/Transforms/KernelDispatch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ enum class TilePassPipeline {
3434
enum class PeelingType { First, Last, FirstLast };
3535

3636
/// Enum for operands to be bufferized to allocation.
37-
enum class BufferizeOperand { InputOutput, Input, Output, PackInput };
37+
enum class BufferizeOperand { LinalgInputOutput, LinalgInput, LinalgOutput, PackInput };
3838

3939
LogicalResult initAIELaunchConfig(FunctionOpInterface funcOp,
4040
TilePassPipeline useTilePipeline,

compiler/plugins/target/AMD-AIE/iree-amd-aie/Transforms/Passes.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void addPackPeelBasedPassPipeline(OpPassManager &funcPassManager,
155155
{
156156
AMDAIEBufferizeToAllocationOptions bufferizeOptions;
157157
bufferizeOptions.memorySpace = 1;
158-
bufferizeOptions.bufferizeOperand = BufferizeOperand::Output;
158+
bufferizeOptions.bufferizeOperand = BufferizeOperand::LinalgOutput;
159159
funcPassManager.addPass(
160160
createAMDAIEBufferizeToAllocationPass(bufferizeOptions));
161161
}
@@ -165,7 +165,7 @@ void addPackPeelBasedPassPipeline(OpPassManager &funcPassManager,
165165
AMDAIEBufferizeToAllocationOptions bufferizeOptions;
166166
bufferizeOptions.memorySpace = 1;
167167
bufferizeOptions.bufferizeElementwise = true;
168-
bufferizeOptions.bufferizeOperand = BufferizeOperand::Input;
168+
bufferizeOptions.bufferizeOperand = BufferizeOperand::LinalgInput;
169169
funcPassManager.addPass(
170170
createAMDAIEBufferizeToAllocationPass(bufferizeOptions));
171171
}
@@ -241,7 +241,7 @@ void addPackPeelBasedPassPipeline(OpPassManager &funcPassManager,
241241
{
242242
AMDAIEBufferizeToAllocationOptions bufferizeOptions;
243243
bufferizeOptions.memorySpace = 2;
244-
bufferizeOptions.bufferizeOperand = BufferizeOperand::Input;
244+
bufferizeOptions.bufferizeOperand = BufferizeOperand::LinalgInput;
245245
funcPassManager.addPass(
246246
createAMDAIEBufferizeToAllocationPass(bufferizeOptions));
247247
}
@@ -280,7 +280,7 @@ void addPackPeelBasedPassPipeline(OpPassManager &funcPassManager,
280280
AMDAIEBufferizeToAllocationOptions bufferizeOptions;
281281
bufferizeOptions.memorySpace = 2;
282282
bufferizeOptions.bufferizeElementwise = true;
283-
bufferizeOptions.bufferizeOperand = BufferizeOperand::Input;
283+
bufferizeOptions.bufferizeOperand = BufferizeOperand::LinalgInput;
284284
funcPassManager.addPass(
285285
createAMDAIEBufferizeToAllocationPass(bufferizeOptions));
286286
}
@@ -325,7 +325,7 @@ void addPadPackBasedPassPipeline(OpPassManager &funcPassManager,
325325
{
326326
AMDAIEBufferizeToAllocationOptions bufferizeOptions;
327327
bufferizeOptions.memorySpace = 1;
328-
bufferizeOptions.bufferizeOperand = BufferizeOperand::InputOutput;
328+
bufferizeOptions.bufferizeOperand = BufferizeOperand::LinalgInputOutput;
329329
funcPassManager.addPass(
330330
createAMDAIEBufferizeToAllocationPass(bufferizeOptions));
331331
}
@@ -362,7 +362,7 @@ void addPadPackBasedPassPipeline(OpPassManager &funcPassManager,
362362
{
363363
AMDAIEBufferizeToAllocationOptions bufferizeOptions;
364364
bufferizeOptions.memorySpace = 2;
365-
bufferizeOptions.bufferizeOperand = BufferizeOperand::Output;
365+
bufferizeOptions.bufferizeOperand = BufferizeOperand::LinalgOutput;
366366
funcPassManager.addPass(
367367
createAMDAIEBufferizeToAllocationPass(bufferizeOptions));
368368
}
@@ -388,7 +388,7 @@ void addPadPackBasedPassPipeline(OpPassManager &funcPassManager,
388388
{
389389
AMDAIEBufferizeToAllocationOptions bufferizeOptions;
390390
bufferizeOptions.memorySpace = 2;
391-
bufferizeOptions.bufferizeOperand = BufferizeOperand::Input;
391+
bufferizeOptions.bufferizeOperand = BufferizeOperand::LinalgInput;
392392
funcPassManager.addPass(
393393
createAMDAIEBufferizeToAllocationPass(bufferizeOptions));
394394
}
@@ -438,7 +438,7 @@ void addConvDecomposePassPipeline(OpPassManager &funcPassManager,
438438
{
439439
AMDAIEBufferizeToAllocationOptions bufferizeOptions;
440440
bufferizeOptions.memorySpace = 1;
441-
bufferizeOptions.bufferizeOperand = BufferizeOperand::InputOutput;
441+
bufferizeOptions.bufferizeOperand = BufferizeOperand::LinalgInputOutput;
442442
funcPassManager.addPass(
443443
createAMDAIEBufferizeToAllocationPass(bufferizeOptions));
444444
}
@@ -466,7 +466,7 @@ void addConvDecomposePassPipeline(OpPassManager &funcPassManager,
466466
{
467467
AMDAIEBufferizeToAllocationOptions bufferizeOptions;
468468
bufferizeOptions.memorySpace = 2;
469-
bufferizeOptions.bufferizeOperand = BufferizeOperand::InputOutput;
469+
bufferizeOptions.bufferizeOperand = BufferizeOperand::LinalgInputOutput;
470470
funcPassManager.addPass(
471471
createAMDAIEBufferizeToAllocationPass(bufferizeOptions));
472472
addCleanups();

compiler/plugins/target/AMD-AIE/iree-amd-aie/Transforms/Passes.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@ def AMDAIEBufferizeToAllocation :
9090
"Indicator of whether the target op for bufferization is an elementwise op">,
9191
Option<"bufferizeOperand", "bufferize-operand",
9292
"mlir::iree_compiler::AMDAIE::BufferizeOperand",
93-
/*default=*/"mlir::iree_compiler::AMDAIE::BufferizeOperand::InputOutput",
93+
/*default=*/"mlir::iree_compiler::AMDAIE::BufferizeOperand::LinalgInputOutput",
9494
"Select which operands of a linalg op to be bufferized to allocation",
9595
[{::llvm::cl::values(
96-
clEnumValN(mlir::iree_compiler::AMDAIE::BufferizeOperand::InputOutput, "input-output",
96+
clEnumValN(mlir::iree_compiler::AMDAIE::BufferizeOperand::LinalgInputOutput, "linalg-input-output",
9797
"Create new allocations for lhs, rhs and output of a linalg op."),
98-
clEnumValN(mlir::iree_compiler::AMDAIE::BufferizeOperand::Input, "input",
98+
clEnumValN(mlir::iree_compiler::AMDAIE::BufferizeOperand::LinalgInput, "linalg-input",
9999
"Create new allocations for lhs, rhs of a linalg op."),
100-
clEnumValN(mlir::iree_compiler::AMDAIE::BufferizeOperand::Output, "output",
100+
clEnumValN(mlir::iree_compiler::AMDAIE::BufferizeOperand::LinalgOutput, "linalg-output",
101101
"Create new allocations for output of a linalg op."),
102102
clEnumValN(mlir::iree_compiler::AMDAIE::BufferizeOperand::PackInput, "pack-input",
103103
"Create new allocations for operands from the pack op inputs of a linalg op.")
Lines changed: 84 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// RUN: iree-opt --pass-pipeline='builtin.module(func.func(iree-amdaie-bufferize-to-allocation{memory-space=2 bufferize-operand=input-output}))' --split-input-file %s | FileCheck %s --check-prefix=INPUT-OUTPUT
2-
// RUN: iree-opt --pass-pipeline='builtin.module(func.func(iree-amdaie-bufferize-to-allocation{memory-space=2 bufferize-operand=input}))' --split-input-file %s | FileCheck %s --check-prefix=INPUT
3-
// RUN: iree-opt --pass-pipeline='builtin.module(func.func(iree-amdaie-bufferize-to-allocation{memory-space=2 bufferize-operand=output}))' --split-input-file %s | FileCheck %s --check-prefix=OUTPUT
4-
// RUN: iree-opt --pass-pipeline='builtin.module(func.func(iree-amdaie-bufferize-to-allocation{memory-space=1 bufferize-operand=pack-input pack-depth=2}))' --split-input-file %s | FileCheck %s --check-prefix=PACK
5-
// RUN: iree-opt --pass-pipeline='builtin.module(func.func(iree-amdaie-bufferize-to-allocation{memory-space=2 bufferize-elementwise=true bufferize-operand=input}))' --split-input-file %s | FileCheck %s --check-prefix=ELEMENTWISE-INPUT
6-
// RUN: iree-opt --pass-pipeline='builtin.module(func.func(iree-amdaie-bufferize-to-allocation{memory-space=2 bufferize-elementwise=true bufferize-operand=input-output}))' --split-input-file %s | FileCheck %s --check-prefix=ELEMENTWISE-INPUT-OUTPUT
1+
// RUN: iree-opt --pass-pipeline='builtin.module(func.func(iree-amdaie-bufferize-to-allocation{memory-space=2 bufferize-operand=linalg-input-output}))' --split-input-file %s | FileCheck %s --check-prefix=LINALG-INPUT-OUTPUT
2+
// RUN: iree-opt --pass-pipeline='builtin.module(func.func(iree-amdaie-bufferize-to-allocation{memory-space=2 bufferize-operand=linalg-input}))' --split-input-file %s | FileCheck %s --check-prefix=LINALG-INPUT
3+
// RUN: iree-opt --pass-pipeline='builtin.module(func.func(iree-amdaie-bufferize-to-allocation{memory-space=2 bufferize-operand=linalg-output}))' --split-input-file %s | FileCheck %s --check-prefix=LINALG-OUTPUT
4+
// RUN: iree-opt --pass-pipeline='builtin.module(func.func(iree-amdaie-bufferize-to-allocation{memory-space=1 bufferize-operand=pack-input pack-depth=2}))' --split-input-file %s | FileCheck %s --check-prefix=PACK-INPUT
5+
// RUN: iree-opt --pass-pipeline='builtin.module(func.func(iree-amdaie-bufferize-to-allocation{memory-space=2 bufferize-elementwise=true bufferize-operand=linalg-input}))' --split-input-file %s | FileCheck %s --check-prefix=ELEMENTWISE-INPUT
6+
// RUN: iree-opt --pass-pipeline='builtin.module(func.func(iree-amdaie-bufferize-to-allocation{memory-space=2 bufferize-elementwise=true bufferize-operand=linalg-input-output}))' --split-input-file %s | FileCheck %s --check-prefix=ELEMENTWISE-INPUT-OUTPUT
77

88
#map = affine_map<(d0, d1, d2, d3, d4, d5, d6, d7, d8) -> (d0, d2, d3, d5, d6, d8)>
99
#map1 = affine_map<(d0, d1, d2, d3, d4, d5, d6, d7, d8) -> (d2, d1, d5, d4, d7, d8)>
@@ -35,61 +35,61 @@ func.func @matmul_static(%arg0 : tensor<1024x2048xi32>, %arg1 : tensor<2048x512x
3535
return %unpack_3 : tensor<1024x512xi32>
3636
}
3737

38-
// INPUT-OUTPUT-NOT: memref.alloc
39-
// INPUT-OUTPUT: tensor.pack
40-
// INPUT-OUTPUT-NOT: memref.alloc
41-
// INPUT-OUTPUT: tensor.pack
42-
// INPUT-OUTPUT: memref.alloc() : memref<16x32x16x8x4x8xi32, 2 : i32>
43-
// INPUT-OUTPUT: bufferization.to_tensor
44-
// INPUT-OUTPUT: tensor.pack
45-
// INPUT-OUTPUT: memref.alloc() : memref<32x8x8x8x8x8xi32, 2 : i32>
46-
// INPUT-OUTPUT: bufferization.to_tensor
47-
// INPUT-OUTPUT: tensor.pack
48-
// INPUT-OUTPUT: memref.alloc() : memref<16x8x16x8x4x8xi32, 2 : i32>
49-
// INPUT-OUTPUT: bufferization.to_tensor
50-
// INPUT-OUTPUT: linalg.fill
51-
// INPUT-OUTPUT: linalg.generic
38+
// LINALG-INPUT-OUTPUT-NOT: memref.alloc
39+
// LINALG-INPUT-OUTPUT: tensor.pack
40+
// LINALG-INPUT-OUTPUT-NOT: memref.alloc
41+
// LINALG-INPUT-OUTPUT: tensor.pack
42+
// LINALG-INPUT-OUTPUT: memref.alloc() : memref<16x32x16x8x4x8xi32, 2 : i32>
43+
// LINALG-INPUT-OUTPUT: bufferization.to_tensor
44+
// LINALG-INPUT-OUTPUT: tensor.pack
45+
// LINALG-INPUT-OUTPUT: memref.alloc() : memref<32x8x8x8x8x8xi32, 2 : i32>
46+
// LINALG-INPUT-OUTPUT: bufferization.to_tensor
47+
// LINALG-INPUT-OUTPUT: tensor.pack
48+
// LINALG-INPUT-OUTPUT: memref.alloc() : memref<16x8x16x8x4x8xi32, 2 : i32>
49+
// LINALG-INPUT-OUTPUT: bufferization.to_tensor
50+
// LINALG-INPUT-OUTPUT: linalg.fill
51+
// LINALG-INPUT-OUTPUT: linalg.generic
5252

53-
// INPUT-NOT: memref.alloc
54-
// INPUT: tensor.pack
55-
// INPUT-NOT: memref.alloc
56-
// INPUT: tensor.pack
57-
// INPUT: memref.alloc() : memref<16x32x16x8x4x8xi32, 2 : i32>
58-
// INPUT: bufferization.to_tensor
59-
// INPUT: tensor.pack
60-
// INPUT: memref.alloc() : memref<32x8x8x8x8x8xi32, 2 : i32>
61-
// INPUT: bufferization.to_tensor
62-
// INPUT: tensor.pack
63-
// INPUT-NOT: memref.alloc
64-
// INPUT: linalg.fill
65-
// INPUT: linalg.generic
53+
// LINALG-INPUT-NOT: memref.alloc
54+
// LINALG-INPUT: tensor.pack
55+
// LINALG-INPUT-NOT: memref.alloc
56+
// LINALG-INPUT: tensor.pack
57+
// LINALG-INPUT: memref.alloc() : memref<16x32x16x8x4x8xi32, 2 : i32>
58+
// LINALG-INPUT: bufferization.to_tensor
59+
// LINALG-INPUT: tensor.pack
60+
// LINALG-INPUT: memref.alloc() : memref<32x8x8x8x8x8xi32, 2 : i32>
61+
// LINALG-INPUT: bufferization.to_tensor
62+
// LINALG-INPUT: tensor.pack
63+
// LINALG-INPUT-NOT: memref.alloc
64+
// LINALG-INPUT: linalg.fill
65+
// LINALG-INPUT: linalg.generic
6666

67-
// OUTPUT-NOT: memref.alloc
68-
// OUTPUT: tensor.pack
69-
// OUTPUT-NOT: memref.alloc
70-
// OUTPUT: tensor.pack
71-
// OUTPUT-NOT: memref.alloc
72-
// OUTPUT: tensor.pack
73-
// OUTPUT-NOT: memref.alloc
74-
// OUTPUT: tensor.pack
75-
// OUTPUT: memref.alloc() : memref<16x8x16x8x4x8xi32, 2 : i32>
76-
// OUTPUT: bufferization.to_tensor
77-
// OUTPUT: linalg.fill
78-
// OUTPUT: linalg.generic
67+
// LINALG-OUTPUT-NOT: memref.alloc
68+
// LINALG-OUTPUT: tensor.pack
69+
// LINALG-OUTPUT-NOT: memref.alloc
70+
// LINALG-OUTPUT: tensor.pack
71+
// LINALG-OUTPUT-NOT: memref.alloc
72+
// LINALG-OUTPUT: tensor.pack
73+
// LINALG-OUTPUT-NOT: memref.alloc
74+
// LINALG-OUTPUT: tensor.pack
75+
// LINALG-OUTPUT: memref.alloc() : memref<16x8x16x8x4x8xi32, 2 : i32>
76+
// LINALG-OUTPUT: bufferization.to_tensor
77+
// LINALG-OUTPUT: linalg.fill
78+
// LINALG-OUTPUT: linalg.generic
7979

80-
// PACK: memref.alloc() : memref<16x32x64x64xi32, 1 : i32>
81-
// PACK: bufferization.to_tensor
82-
// PACK: tensor.pack
83-
// PACK: memref.alloc() : memref<32x8x64x64xi32, 1 : i32>
84-
// PACK: bufferization.to_tensor
85-
// PACK: tensor.pack
86-
// PACK-NOT: memref.alloc
87-
// PACK: tensor.pack
88-
// PACK-NOT: memref.alloc
89-
// PACK: tensor.pack
90-
// PACK-NOT: memref.alloc
91-
// PACK: linalg.fill
92-
// PACK: linalg.generic
80+
// PACK-INPUT: memref.alloc() : memref<16x32x64x64xi32, 1 : i32>
81+
// PACK-INPUT: bufferization.to_tensor
82+
// PACK-INPUT: tensor.pack
83+
// PACK-INPUT: memref.alloc() : memref<32x8x64x64xi32, 1 : i32>
84+
// PACK-INPUT: bufferization.to_tensor
85+
// PACK-INPUT: tensor.pack
86+
// PACK-INPUT-NOT: memref.alloc
87+
// PACK-INPUT: tensor.pack
88+
// PACK-INPUT-NOT: memref.alloc
89+
// PACK-INPUT: tensor.pack
90+
// PACK-INPUT-NOT: memref.alloc
91+
// PACK-INPUT: linalg.fill
92+
// PACK-INPUT: linalg.generic
9393

9494
// -----
9595

@@ -143,31 +143,31 @@ func.func @matmul_elementwise(%arg0: tensor<1024x512xi8>, %arg1: tensor<512x1024
143143
return %1 : tensor<1024x1024xi32>
144144
}
145145

146-
// ELEMENTWISE-INPUT-COUNT-4: tensor.pack
147-
// ELEMENTWISE-INPUT: linalg.fill
148-
// ELEMENTWISE-INPUT: linalg.generic
149-
// ELEMENTWISE-INPUT-NOT: memref.alloc
150-
// ELEMENTWISE-INPUT: tensor.pack
151-
// ELEMENTWISE-INPUT-NOT: memref.alloc
152-
// ELEMENTWISE-INPUT: tensor.pack
153-
// ELEMENTWISE-INPUT-NOT: memref.alloc
154-
// ELEMENTWISE-INPUT: tensor.pack
155-
// ELEMENTWISE-INPUT: memref.alloc() : memref<1x1x8x16x4x8xi32, 2 : i32>
156-
// ELEMENTWISE-INPUT: bufferization.to_tensor
157-
// ELEMENTWISE-INPUT: tensor.pack
158-
// ELEMENTWISE-INPUT: linalg.generic
146+
// ELEMENTWISE-INPUT-COUNT-4: tensor.pack
147+
// ELEMENTWISE-INPUT: linalg.fill
148+
// ELEMENTWISE-INPUT: linalg.generic
149+
// ELEMENTWISE-INPUT-NOT: memref.alloc
150+
// ELEMENTWISE-INPUT: tensor.pack
151+
// ELEMENTWISE-INPUT-NOT: memref.alloc
152+
// ELEMENTWISE-INPUT: tensor.pack
153+
// ELEMENTWISE-INPUT-NOT: memref.alloc
154+
// ELEMENTWISE-INPUT: tensor.pack
155+
// ELEMENTWISE-INPUT: memref.alloc() : memref<1x1x8x16x4x8xi32, 2 : i32>
156+
// ELEMENTWISE-INPUT: bufferization.to_tensor
157+
// ELEMENTWISE-INPUT: tensor.pack
158+
// ELEMENTWISE-INPUT: linalg.generic
159159

160160
// ELEMENTWISE-INPUT-OUTPUT-COUNT-4: tensor.pack
161-
// ELEMENTWISE-INPUT-OUTPUT: linalg.fill
162-
// ELEMENTWISE-INPUT-OUTPUT: linalg.generic
163-
// ELEMENTWISE-INPUT-OUTPUT-NOT: memref.alloc
164-
// ELEMENTWISE-INPUT-OUTPUT: tensor.pack
165-
// ELEMENTWISE-INPUT-OUTPUT-NOT: memref.alloc
166-
// ELEMENTWISE-INPUT-OUTPUT: tensor.pack
167-
// ELEMENTWISE-INPUT-OUTPUT: memref.alloc() : memref<1x1x8x16x4x8xi32, 2 : i32>
168-
// ELEMENTWISE-INPUT-OUTPUT: bufferization.to_tensor
169-
// ELEMENTWISE-INPUT-OUTPUT: tensor.pack
170-
// ELEMENTWISE-INPUT-OUTPUT: memref.alloc() : memref<1x1x8x16x4x8xi32, 2 : i32>
171-
// ELEMENTWISE-INPUT-OUTPUT: bufferization.to_tensor
172-
// ELEMENTWISE-INPUT-OUTPUT: tensor.pack
173-
// ELEMENTWISE-INPUT-OUTPUT: linalg.generic
161+
// ELEMENTWISE-INPUT-OUTPUT: linalg.fill
162+
// ELEMENTWISE-INPUT-OUTPUT: linalg.generic
163+
// ELEMENTWISE-INPUT-OUTPUT-NOT: memref.alloc
164+
// ELEMENTWISE-INPUT-OUTPUT: tensor.pack
165+
// ELEMENTWISE-INPUT-OUTPUT-NOT: memref.alloc
166+
// ELEMENTWISE-INPUT-OUTPUT: tensor.pack
167+
// ELEMENTWISE-INPUT-OUTPUT: memref.alloc() : memref<1x1x8x16x4x8xi32, 2 : i32>
168+
// ELEMENTWISE-INPUT-OUTPUT: bufferization.to_tensor
169+
// ELEMENTWISE-INPUT-OUTPUT: tensor.pack
170+
// ELEMENTWISE-INPUT-OUTPUT: memref.alloc() : memref<1x1x8x16x4x8xi32, 2 : i32>
171+
// ELEMENTWISE-INPUT-OUTPUT: bufferization.to_tensor
172+
// ELEMENTWISE-INPUT-OUTPUT: tensor.pack
173+
// ELEMENTWISE-INPUT-OUTPUT: linalg.generic

0 commit comments

Comments
 (0)