Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor BufferizeOperand naming for clarity #981

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Refactor BufferizeOperand naming for clarity
jtuyls committed Dec 11, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit a1fd889a9fc12f3172ae19813655f8619f6c382b
Original file line number Diff line number Diff line change
@@ -103,13 +103,13 @@ static FailureOr<SmallVector<Value>> getOperandsToBufferize(
uint32_t packDepth) {
switch (bufferizeOperand) {
/// Create new allocations for Lhs, Rhs and Out.
case BufferizeOperand::InputOutput:
case BufferizeOperand::LinalgInputOutput:
return getInputOutputOperands(linalgOp);
/// Create new allocation only for Lhs, Rhs.
case BufferizeOperand::Input:
case BufferizeOperand::LinalgInput:
return getInputOperands(linalgOp);
/// Create new allocations only for Out.
case BufferizeOperand::Output:
case BufferizeOperand::LinalgOutput:
return SmallVector<Value>(linalgOp.getDpsInits());
/// Create new allocations for operands from the pack ops.
case BufferizeOperand::PackInput:
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ enum class TilePassPipeline {
enum class PeelingType { First, Last, FirstLast };

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

LogicalResult initAIELaunchConfig(FunctionOpInterface funcOp,
TilePassPipeline useTilePipeline,
Original file line number Diff line number Diff line change
@@ -155,7 +155,7 @@ void addPackPeelBasedPassPipeline(OpPassManager &funcPassManager,
{
AMDAIEBufferizeToAllocationOptions bufferizeOptions;
bufferizeOptions.memorySpace = 1;
bufferizeOptions.bufferizeOperand = BufferizeOperand::Output;
bufferizeOptions.bufferizeOperand = BufferizeOperand::LinalgOutput;
funcPassManager.addPass(
createAMDAIEBufferizeToAllocationPass(bufferizeOptions));
}
@@ -165,7 +165,7 @@ void addPackPeelBasedPassPipeline(OpPassManager &funcPassManager,
AMDAIEBufferizeToAllocationOptions bufferizeOptions;
bufferizeOptions.memorySpace = 1;
bufferizeOptions.bufferizeElementwise = true;
bufferizeOptions.bufferizeOperand = BufferizeOperand::Input;
bufferizeOptions.bufferizeOperand = BufferizeOperand::LinalgInput;
funcPassManager.addPass(
createAMDAIEBufferizeToAllocationPass(bufferizeOptions));
}
@@ -241,7 +241,7 @@ void addPackPeelBasedPassPipeline(OpPassManager &funcPassManager,
{
AMDAIEBufferizeToAllocationOptions bufferizeOptions;
bufferizeOptions.memorySpace = 2;
bufferizeOptions.bufferizeOperand = BufferizeOperand::Input;
bufferizeOptions.bufferizeOperand = BufferizeOperand::LinalgInput;
funcPassManager.addPass(
createAMDAIEBufferizeToAllocationPass(bufferizeOptions));
}
@@ -280,7 +280,7 @@ void addPackPeelBasedPassPipeline(OpPassManager &funcPassManager,
AMDAIEBufferizeToAllocationOptions bufferizeOptions;
bufferizeOptions.memorySpace = 2;
bufferizeOptions.bufferizeElementwise = true;
bufferizeOptions.bufferizeOperand = BufferizeOperand::Input;
bufferizeOptions.bufferizeOperand = BufferizeOperand::LinalgInput;
funcPassManager.addPass(
createAMDAIEBufferizeToAllocationPass(bufferizeOptions));
}
@@ -325,7 +325,7 @@ void addPadPackBasedPassPipeline(OpPassManager &funcPassManager,
{
AMDAIEBufferizeToAllocationOptions bufferizeOptions;
bufferizeOptions.memorySpace = 1;
bufferizeOptions.bufferizeOperand = BufferizeOperand::InputOutput;
bufferizeOptions.bufferizeOperand = BufferizeOperand::LinalgInputOutput;
funcPassManager.addPass(
createAMDAIEBufferizeToAllocationPass(bufferizeOptions));
}
@@ -362,7 +362,7 @@ void addPadPackBasedPassPipeline(OpPassManager &funcPassManager,
{
AMDAIEBufferizeToAllocationOptions bufferizeOptions;
bufferizeOptions.memorySpace = 2;
bufferizeOptions.bufferizeOperand = BufferizeOperand::Output;
bufferizeOptions.bufferizeOperand = BufferizeOperand::LinalgOutput;
funcPassManager.addPass(
createAMDAIEBufferizeToAllocationPass(bufferizeOptions));
}
@@ -388,7 +388,7 @@ void addPadPackBasedPassPipeline(OpPassManager &funcPassManager,
{
AMDAIEBufferizeToAllocationOptions bufferizeOptions;
bufferizeOptions.memorySpace = 2;
bufferizeOptions.bufferizeOperand = BufferizeOperand::Input;
bufferizeOptions.bufferizeOperand = BufferizeOperand::LinalgInput;
funcPassManager.addPass(
createAMDAIEBufferizeToAllocationPass(bufferizeOptions));
}
@@ -438,7 +438,7 @@ void addConvDecomposePassPipeline(OpPassManager &funcPassManager,
{
AMDAIEBufferizeToAllocationOptions bufferizeOptions;
bufferizeOptions.memorySpace = 1;
bufferizeOptions.bufferizeOperand = BufferizeOperand::InputOutput;
bufferizeOptions.bufferizeOperand = BufferizeOperand::LinalgInputOutput;
funcPassManager.addPass(
createAMDAIEBufferizeToAllocationPass(bufferizeOptions));
}
@@ -466,7 +466,7 @@ void addConvDecomposePassPipeline(OpPassManager &funcPassManager,
{
AMDAIEBufferizeToAllocationOptions bufferizeOptions;
bufferizeOptions.memorySpace = 2;
bufferizeOptions.bufferizeOperand = BufferizeOperand::InputOutput;
bufferizeOptions.bufferizeOperand = BufferizeOperand::LinalgInputOutput;
funcPassManager.addPass(
createAMDAIEBufferizeToAllocationPass(bufferizeOptions));
addCleanups();
Original file line number Diff line number Diff line change
@@ -90,14 +90,14 @@ def AMDAIEBufferizeToAllocation :
"Indicator of whether the target op for bufferization is an elementwise op">,
Option<"bufferizeOperand", "bufferize-operand",
"mlir::iree_compiler::AMDAIE::BufferizeOperand",
/*default=*/"mlir::iree_compiler::AMDAIE::BufferizeOperand::InputOutput",
/*default=*/"mlir::iree_compiler::AMDAIE::BufferizeOperand::LinalgInputOutput",
"Select which operands of a linalg op to be bufferized to allocation",
[{::llvm::cl::values(
clEnumValN(mlir::iree_compiler::AMDAIE::BufferizeOperand::InputOutput, "input-output",
clEnumValN(mlir::iree_compiler::AMDAIE::BufferizeOperand::LinalgInputOutput, "linalg-input-output",
"Create new allocations for lhs, rhs and output of a linalg op."),
clEnumValN(mlir::iree_compiler::AMDAIE::BufferizeOperand::Input, "input",
clEnumValN(mlir::iree_compiler::AMDAIE::BufferizeOperand::LinalgInput, "linalg-input",
"Create new allocations for lhs, rhs of a linalg op."),
clEnumValN(mlir::iree_compiler::AMDAIE::BufferizeOperand::Output, "output",
clEnumValN(mlir::iree_compiler::AMDAIE::BufferizeOperand::LinalgOutput, "linalg-output",
"Create new allocations for output of a linalg op."),
clEnumValN(mlir::iree_compiler::AMDAIE::BufferizeOperand::PackInput, "pack-input",
"Create new allocations for operands from the pack op inputs of a linalg op.")
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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

#map = affine_map<(d0, d1, d2, d3, d4, d5, d6, d7, d8) -> (d0, d2, d3, d5, d6, d8)>
#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
return %unpack_3 : tensor<1024x512xi32>
}

// INPUT-OUTPUT-NOT: memref.alloc
// INPUT-OUTPUT: tensor.pack
// INPUT-OUTPUT-NOT: memref.alloc
// INPUT-OUTPUT: tensor.pack
// INPUT-OUTPUT: memref.alloc() : memref<16x32x16x8x4x8xi32, 2 : i32>
// INPUT-OUTPUT: bufferization.to_tensor
// INPUT-OUTPUT: tensor.pack
// INPUT-OUTPUT: memref.alloc() : memref<32x8x8x8x8x8xi32, 2 : i32>
// INPUT-OUTPUT: bufferization.to_tensor
// INPUT-OUTPUT: tensor.pack
// INPUT-OUTPUT: memref.alloc() : memref<16x8x16x8x4x8xi32, 2 : i32>
// INPUT-OUTPUT: bufferization.to_tensor
// INPUT-OUTPUT: linalg.fill
// INPUT-OUTPUT: linalg.generic
// LINALG-INPUT-OUTPUT-NOT: memref.alloc
// LINALG-INPUT-OUTPUT: tensor.pack
// LINALG-INPUT-OUTPUT-NOT: memref.alloc
// LINALG-INPUT-OUTPUT: tensor.pack
// LINALG-INPUT-OUTPUT: memref.alloc() : memref<16x32x16x8x4x8xi32, 2 : i32>
// LINALG-INPUT-OUTPUT: bufferization.to_tensor
// LINALG-INPUT-OUTPUT: tensor.pack
// LINALG-INPUT-OUTPUT: memref.alloc() : memref<32x8x8x8x8x8xi32, 2 : i32>
// LINALG-INPUT-OUTPUT: bufferization.to_tensor
// LINALG-INPUT-OUTPUT: tensor.pack
// LINALG-INPUT-OUTPUT: memref.alloc() : memref<16x8x16x8x4x8xi32, 2 : i32>
// LINALG-INPUT-OUTPUT: bufferization.to_tensor
// LINALG-INPUT-OUTPUT: linalg.fill
// LINALG-INPUT-OUTPUT: linalg.generic

// INPUT-NOT: memref.alloc
// INPUT: tensor.pack
// INPUT-NOT: memref.alloc
// INPUT: tensor.pack
// INPUT: memref.alloc() : memref<16x32x16x8x4x8xi32, 2 : i32>
// INPUT: bufferization.to_tensor
// INPUT: tensor.pack
// INPUT: memref.alloc() : memref<32x8x8x8x8x8xi32, 2 : i32>
// INPUT: bufferization.to_tensor
// INPUT: tensor.pack
// INPUT-NOT: memref.alloc
// INPUT: linalg.fill
// INPUT: linalg.generic
// LINALG-INPUT-NOT: memref.alloc
// LINALG-INPUT: tensor.pack
// LINALG-INPUT-NOT: memref.alloc
// LINALG-INPUT: tensor.pack
// LINALG-INPUT: memref.alloc() : memref<16x32x16x8x4x8xi32, 2 : i32>
// LINALG-INPUT: bufferization.to_tensor
// LINALG-INPUT: tensor.pack
// LINALG-INPUT: memref.alloc() : memref<32x8x8x8x8x8xi32, 2 : i32>
// LINALG-INPUT: bufferization.to_tensor
// LINALG-INPUT: tensor.pack
// LINALG-INPUT-NOT: memref.alloc
// LINALG-INPUT: linalg.fill
// LINALG-INPUT: linalg.generic

// OUTPUT-NOT: memref.alloc
// OUTPUT: tensor.pack
// OUTPUT-NOT: memref.alloc
// OUTPUT: tensor.pack
// OUTPUT-NOT: memref.alloc
// OUTPUT: tensor.pack
// OUTPUT-NOT: memref.alloc
// OUTPUT: tensor.pack
// OUTPUT: memref.alloc() : memref<16x8x16x8x4x8xi32, 2 : i32>
// OUTPUT: bufferization.to_tensor
// OUTPUT: linalg.fill
// OUTPUT: linalg.generic
// LINALG-OUTPUT-NOT: memref.alloc
// LINALG-OUTPUT: tensor.pack
// LINALG-OUTPUT-NOT: memref.alloc
// LINALG-OUTPUT: tensor.pack
// LINALG-OUTPUT-NOT: memref.alloc
// LINALG-OUTPUT: tensor.pack
// LINALG-OUTPUT-NOT: memref.alloc
// LINALG-OUTPUT: tensor.pack
// LINALG-OUTPUT: memref.alloc() : memref<16x8x16x8x4x8xi32, 2 : i32>
// LINALG-OUTPUT: bufferization.to_tensor
// LINALG-OUTPUT: linalg.fill
// LINALG-OUTPUT: linalg.generic

// PACK: memref.alloc() : memref<16x32x64x64xi32, 1 : i32>
// PACK: bufferization.to_tensor
// PACK: tensor.pack
// PACK: memref.alloc() : memref<32x8x64x64xi32, 1 : i32>
// PACK: bufferization.to_tensor
// PACK: tensor.pack
// PACK-NOT: memref.alloc
// PACK: tensor.pack
// PACK-NOT: memref.alloc
// PACK: tensor.pack
// PACK-NOT: memref.alloc
// PACK: linalg.fill
// PACK: linalg.generic
// PACK-INPUT: memref.alloc() : memref<16x32x64x64xi32, 1 : i32>
// PACK-INPUT: bufferization.to_tensor
// PACK-INPUT: tensor.pack
// PACK-INPUT: memref.alloc() : memref<32x8x64x64xi32, 1 : i32>
// PACK-INPUT: bufferization.to_tensor
// PACK-INPUT: tensor.pack
// PACK-INPUT-NOT: memref.alloc
// PACK-INPUT: tensor.pack
// PACK-INPUT-NOT: memref.alloc
// PACK-INPUT: tensor.pack
// PACK-INPUT-NOT: memref.alloc
// PACK-INPUT: linalg.fill
// PACK-INPUT: linalg.generic

// -----

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

// ELEMENTWISE-INPUT-COUNT-4: tensor.pack
// ELEMENTWISE-INPUT: linalg.fill
// ELEMENTWISE-INPUT: linalg.generic
// ELEMENTWISE-INPUT-NOT: memref.alloc
// ELEMENTWISE-INPUT: tensor.pack
// ELEMENTWISE-INPUT-NOT: memref.alloc
// ELEMENTWISE-INPUT: tensor.pack
// ELEMENTWISE-INPUT-NOT: memref.alloc
// ELEMENTWISE-INPUT: tensor.pack
// ELEMENTWISE-INPUT: memref.alloc() : memref<1x1x8x16x4x8xi32, 2 : i32>
// ELEMENTWISE-INPUT: bufferization.to_tensor
// ELEMENTWISE-INPUT: tensor.pack
// ELEMENTWISE-INPUT: linalg.generic
// ELEMENTWISE-INPUT-COUNT-4: tensor.pack
// ELEMENTWISE-INPUT: linalg.fill
// ELEMENTWISE-INPUT: linalg.generic
// ELEMENTWISE-INPUT-NOT: memref.alloc
// ELEMENTWISE-INPUT: tensor.pack
// ELEMENTWISE-INPUT-NOT: memref.alloc
// ELEMENTWISE-INPUT: tensor.pack
// ELEMENTWISE-INPUT-NOT: memref.alloc
// ELEMENTWISE-INPUT: tensor.pack
// ELEMENTWISE-INPUT: memref.alloc() : memref<1x1x8x16x4x8xi32, 2 : i32>
// ELEMENTWISE-INPUT: bufferization.to_tensor
// ELEMENTWISE-INPUT: tensor.pack
// ELEMENTWISE-INPUT: linalg.generic

// ELEMENTWISE-INPUT-OUTPUT-COUNT-4: tensor.pack
// ELEMENTWISE-INPUT-OUTPUT: linalg.fill
// ELEMENTWISE-INPUT-OUTPUT: linalg.generic
// ELEMENTWISE-INPUT-OUTPUT-NOT: memref.alloc
// ELEMENTWISE-INPUT-OUTPUT: tensor.pack
// ELEMENTWISE-INPUT-OUTPUT-NOT: memref.alloc
// ELEMENTWISE-INPUT-OUTPUT: tensor.pack
// ELEMENTWISE-INPUT-OUTPUT: memref.alloc() : memref<1x1x8x16x4x8xi32, 2 : i32>
// ELEMENTWISE-INPUT-OUTPUT: bufferization.to_tensor
// ELEMENTWISE-INPUT-OUTPUT: tensor.pack
// ELEMENTWISE-INPUT-OUTPUT: memref.alloc() : memref<1x1x8x16x4x8xi32, 2 : i32>
// ELEMENTWISE-INPUT-OUTPUT: bufferization.to_tensor
// ELEMENTWISE-INPUT-OUTPUT: tensor.pack
// ELEMENTWISE-INPUT-OUTPUT: linalg.generic
// ELEMENTWISE-INPUT-OUTPUT: linalg.fill
// ELEMENTWISE-INPUT-OUTPUT: linalg.generic
// ELEMENTWISE-INPUT-OUTPUT-NOT: memref.alloc
// ELEMENTWISE-INPUT-OUTPUT: tensor.pack
// ELEMENTWISE-INPUT-OUTPUT-NOT: memref.alloc
// ELEMENTWISE-INPUT-OUTPUT: tensor.pack
// ELEMENTWISE-INPUT-OUTPUT: memref.alloc() : memref<1x1x8x16x4x8xi32, 2 : i32>
// ELEMENTWISE-INPUT-OUTPUT: bufferization.to_tensor
// ELEMENTWISE-INPUT-OUTPUT: tensor.pack
// ELEMENTWISE-INPUT-OUTPUT: memref.alloc() : memref<1x1x8x16x4x8xi32, 2 : i32>
// ELEMENTWISE-INPUT-OUTPUT: bufferization.to_tensor
// ELEMENTWISE-INPUT-OUTPUT: tensor.pack
// ELEMENTWISE-INPUT-OUTPUT: linalg.generic

Unchanged files with check annotations Beta

rhs, VectorOfShapeAndType<[8, 4], BF16>,
acc, VectorOfShapeAndType<[4, 4], F32>>]>>;
class isOperandResultTypePairValidForAIE2MulElem<string lhs, string rhs, string acc> :

Check warning on line 149 in compiler/plugins/target/AMD-AIE/aievec/AIEVecTypeConstraints.td

GitHub Actions / Build and Test (windows, ASSERTIONS)

unused template argument: isOperandResultTypePairValidForAIE2MulElem:rhs

Check warning on line 149 in compiler/plugins/target/AMD-AIE/aievec/AIEVecTypeConstraints.td

GitHub Actions / Build and Test (windows, ASSERTIONS)

unused template argument: isOperandResultTypePairValidForAIE2MulElem:rhs

Check warning on line 149 in compiler/plugins/target/AMD-AIE/aievec/AIEVecTypeConstraints.td

GitHub Actions / Build and Test (windows, ASSERTIONS)

unused template argument: isOperandResultTypePairValidForAIE2MulElem:rhs

Check warning on line 149 in compiler/plugins/target/AMD-AIE/aievec/AIEVecTypeConstraints.td

GitHub Actions / Build and Test (windows, ASSERTIONS)

unused template argument: isOperandResultTypePairValidForAIE2MulElem:rhs
PredOpTrait<acc # " type is a valid accumulator type given the type of the" #
" operands.",
Or<[