Skip to content

Commit

Permalink
[AMD-AIE] Use emitOpError in consumer fusion pass and segregate the l…
Browse files Browse the repository at this point in the history
…it test (#410)

-- This commit uses emitOpError for pass failure instead of debug statements
and segregate the lit test.

Signed-off-by: Abhishek Varma <[email protected]>
  • Loading branch information
Abhishek-Varma authored Jun 12, 2024
1 parent b066a79 commit 7df3386
Show file tree
Hide file tree
Showing 5 changed files with 439 additions and 369 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void AMDAIEFuseConsumerIntoLoopPass::runOnOperation() {

if (!scfLoopOp) {
LLVM_DEBUG(llvm::dbgs()
<< "There is no scf.for/forall loop to fuse with.\n");
<< "There is no scf.for/forall loop to fuse with\n");
return;
}

Expand All @@ -80,36 +80,31 @@ void AMDAIEFuseConsumerIntoLoopPass::runOnOperation() {
});

if (!linalgOp) {
LLVM_DEBUG(llvm::dbgs() << "----- Could not find any compute op \n");
LLVM_DEBUG(llvm::dbgs() << "Could not find any compute op\n");
return;
}

Value::user_range users = linalgOp->getResult(0).getUsers();
if (!llvm::hasSingleElement(users)) {
LLVM_DEBUG(llvm::dbgs()
<< "----- Expected only one user of the compute op : "
<< linalgOp << "\n");
return;
linalgOp->emitOpError("Expected only one user of the compute op");
return signalPassFailure();
}

Operation *terminatorStoreOp = *(users.begin());
if (!(isa<tensor::InsertSliceOp, tensor::ParallelInsertSliceOp>(
terminatorStoreOp))) {
LLVM_DEBUG(llvm::dbgs()
<< "----- Expected either tensor.insert_slice OR "
"tensor.parallel_insert_slice to be the only user of the "
"compute op : "
<< linalgOp << "\n");
return;
terminatorStoreOp->emitOpError(
"Expected either tensor.insert_slice OR tensor.parallel_insert_slice "
"to be the only user of the compute op");
return signalPassFailure();
}

std::optional<scf::SCFFuseConsumerOfSliceResult> fusedConsumer =
scf::tileAndFuseConsumerOfSlice(rewriter, terminatorStoreOp);
if (!fusedConsumer) {
LLVM_DEBUG(
llvm::dbgs()
<< "Failed to fuse any consumer op into the producer scf loop\n");
return;
terminatorStoreOp->emitOpError(
"Failed to fuse any consumer op into the producer");
return signalPassFailure();
}
fusedConsumer->origConsumerOperand->getOwner()->erase();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ iree_lit_test_suite(
"disable_vectorization.mlir"
"distribute-cores-and-objectfifos.mlir"
"dma_to_circular_dma.mlir"
"fuse_consumer_into_loop.mlir"
"fuse_consumer_into_loop_scf_for.mlir"
"fuse_consumer_into_loop_scf_forall.mlir"
"fuse_fill_into_forall.mlir"
"fuse_pack_into_loop.mlir"
"hoist_for_affine_apply.mlir"
Expand Down
Loading

0 comments on commit 7df3386

Please sign in to comment.