Skip to content

Commit

Permalink
only releveant change
Browse files Browse the repository at this point in the history
  • Loading branch information
newling committed Aug 26, 2024
1 parent 93c04dc commit 6dd21f0
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions compiler/plugins/target/AMD-AIE/iree-amd-aie/Transforms/Passes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,15 +481,15 @@ void addConvDecomposePassPipeline(OpPassManager &funcPassManager,
// Pad the linalg operation
{
AMDAIEPadOptions padOptions;
padOptions.paddingLevel = 0;
padOptions.paddingLevel = 1;
funcPassManager.addPass(createAMDAIEPadPass(padOptions));
}

// Only promote the result to local memory
{
AMDAIEBufferizeToAllocationOptions bufferizeOptions;
bufferizeOptions.memorySpace = 2;
bufferizeOptions.bufferizeOperand = BufferizeOperand::InputOutput;
bufferizeOptions.bufferizeOperand = BufferizeOperand::Output;
funcPassManager.addPass(
createAMDAIEBufferizeToAllocationPass(bufferizeOptions));
}
Expand All @@ -505,6 +505,22 @@ void addConvDecomposePassPipeline(OpPassManager &funcPassManager,
funcPassManager.addPass(createCanonicalizerPass());
funcPassManager.addPass(createCSEPass());

// Pad the linalg operation
{
AMDAIEPadOptions padOptions;
padOptions.paddingLevel = 2;
funcPassManager.addPass(createAMDAIEPadPass(padOptions));
}

// Promote the inputs to local memory
{
AMDAIEBufferizeToAllocationOptions bufferizeOptions;
bufferizeOptions.memorySpace = 2;
bufferizeOptions.bufferizeOperand = BufferizeOperand::Input;
funcPassManager.addPass(
createAMDAIEBufferizeToAllocationPass(bufferizeOptions));
}

// Decompose Conv2d ops to Conv1d ops
funcPassManager.addPass(createDecomposeConvolutionToLowerDimOpsPass());

Expand Down Expand Up @@ -628,23 +644,6 @@ void addMLIRAIRLoweringPasses(OpPassManager &passManager, AMDAIEDevice device) {
passManager.addPass(memref::createFoldMemRefAliasOpsPass());
passManager.addPass(createAMDAIEBridgeToAIRPass());

// Running canonicalization for all pipelines here results in failures.
// Example
// ```
// 'memref.cast' op is an unsupported operation. This pass currently only
// supports AllocOp and SubViewOp as inputs.
// ```
// It is currently required for the convolution pipeline though, to remove the
// extra (size-1) thread- and group- dimensions.
//
// TODO(newling) there are better solutions like:
// 1) make canonicalization work for scf.forall
// 2) pass to collapse rank-4 scf.foralls to rank-2 scf.foralls.
// 3) resolve above 'unsupproted operation' error.
if (clUseTilePipeline == TilePassPipeline::ConvDecomposePipeline) {
passManager.addPass(createCanonicalizerPass());
}

// TODO (Erwei): Figure out a way to work with AMDAIEPackToDmaPass.
if (clUseTilePipeline == TilePassPipeline::PackPeelPipeline)
passManager.addPass(createAMDAIEDecomposeLinalgExtPackUnPackToAIRPass());
Expand Down

0 comments on commit 6dd21f0

Please sign in to comment.