-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ObjectFifo] Create a new pass to split logical objectFifos (#659)
-- This commit introduces a new pass `--iree-amdaie-split-logical-objectfifos-for-connection-reuse` to split logical objectFifos for dealing with Matmul+Elementwise. -- Also contains a utility to check whether splitting can be performed. -- It addresses sub-action 2 as well from #644 Signed-off-by: Abhishek Varma <[email protected]>
- Loading branch information
1 parent
e76600b
commit 3a6f183
Showing
10 changed files
with
1,936 additions
and
0 deletions.
There are no files selected for viewing
430 changes: 430 additions & 0 deletions
430
...ler/plugins/target/AMD-AIE/iree-amd-aie/Transforms/AMDAIELogicalObjFifoSplittingUtils.cpp
Large diffs are not rendered by default.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
compiler/plugins/target/AMD-AIE/iree-amd-aie/Transforms/AMDAIELogicalObjFifoSplittingUtils.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2024 The IREE Authors | ||
// | ||
// Licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#ifndef IREE_AMD_AIE_TRANSFORMS_AMDAIELOGICALOBJFIFOSPLITTINGUTILS_H_ | ||
#define IREE_AMD_AIE_TRANSFORMS_AMDAIELOGICALOBJFIFOSPLITTINGUTILS_H_ | ||
|
||
#include "iree-amd-aie/IR/AMDAIEOps.h" | ||
|
||
namespace mlir::iree_compiler::AMDAIE { | ||
|
||
/// Utility to split logicalobjectfifos given a struct | ||
/// `SplittingLogicalObjectFifoData` which contains all the required data to | ||
/// perform the splitting. | ||
LogicalResult splitLogicalObjectFifos( | ||
IRRewriter &rewriter, SmallVector<AMDAIE::DmaCpyNdOp> &l2ToL1DmaOps, | ||
MLIRContext *context); | ||
|
||
} // namespace mlir::iree_compiler::AMDAIE | ||
|
||
#endif |
71 changes: 71 additions & 0 deletions
71
...s/target/AMD-AIE/iree-amd-aie/Transforms/AMDAIESplitLogicalObjFifosForConnectionReuse.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright 2024 The IREE Authors | ||
// | ||
// Licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
#include "iree-amd-aie/IR/AMDAIEOps.h" | ||
#include "iree-amd-aie/Transforms/AMDAIELogicalObjFifoSplittingUtils.h" | ||
#include "iree-amd-aie/Transforms/Passes.h" | ||
// #include "llvm/Support/Debug.h" | ||
#include "mlir/IR/Iterators.h" | ||
#include "mlir/Pass/Pass.h" | ||
|
||
#define DEBUG_TYPE "iree-amdaie-split-logical-objectfifos-for-connection-reuse" | ||
|
||
namespace mlir::iree_compiler::AMDAIE { | ||
|
||
namespace { | ||
|
||
/// Utility to help fetch those input DmaCpyNd Ops which needs to be split. | ||
static SmallVector<AMDAIE::DmaCpyNdOp> fetchDmaCpyNdOpsToSplit( | ||
ModuleOp moduleOp) { | ||
SmallVector<AMDAIE::DmaCpyNdOp> l2ToL1DmaOps; | ||
// We are currently walking through CoreOps gathering 3rd Input DmaOp (if | ||
// applicable) from them. | ||
// TODO(avarma): We will generalize this later. | ||
moduleOp.walk([&](AMDAIE::CoreOp coreOp) { | ||
SmallVector<Value> inputDmas = coreOp.getInputDmas(); | ||
if (inputDmas.size() != 3) return WalkResult::skip(); | ||
auto dmaCpyNdOp = inputDmas[2].getDefiningOp<AMDAIE::DmaCpyNdOp>(); | ||
assert(dmaCpyNdOp && "expected an amdaie.dma_cpy_nd op"); | ||
l2ToL1DmaOps.push_back(dmaCpyNdOp); | ||
return WalkResult::advance(); | ||
}); | ||
return l2ToL1DmaOps; | ||
} | ||
|
||
class AMDAIESplitLogicalObjFifosForConnectionReusePass | ||
: public impl::AMDAIESplitLogicalObjFifosForConnectionReuseBase< | ||
AMDAIESplitLogicalObjFifosForConnectionReusePass> { | ||
public: | ||
using AMDAIESplitLogicalObjFifosForConnectionReuseBase:: | ||
AMDAIESplitLogicalObjFifosForConnectionReuseBase; | ||
|
||
void getDependentDialects(DialectRegistry ®istry) const override { | ||
registry.insert<AMDAIEDialect>(); | ||
} | ||
void runOnOperation() override; | ||
}; | ||
|
||
void AMDAIESplitLogicalObjFifosForConnectionReusePass::runOnOperation() { | ||
ModuleOp moduleOp = getOperation(); | ||
MLIRContext *context = &getContext(); | ||
IRRewriter rewriter(context); | ||
|
||
SmallVector<AMDAIE::DmaCpyNdOp> l2ToL1DmaOps = | ||
fetchDmaCpyNdOpsToSplit(moduleOp); | ||
|
||
if (failed(splitLogicalObjectFifos(rewriter, l2ToL1DmaOps, context))) { | ||
LLVM_DEBUG(llvm::dbgs() | ||
<< "Failed to perform splitting of logicalobjectfifos"); | ||
return signalPassFailure(); | ||
} | ||
} | ||
|
||
} // namespace | ||
|
||
std::unique_ptr<Pass> createAMDAIESplitLogicalObjFifosForConnectionReusePass() { | ||
return std::make_unique<AMDAIESplitLogicalObjFifosForConnectionReusePass>(); | ||
} | ||
|
||
} // namespace mlir::iree_compiler::AMDAIE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.