diff options
author | Matthias Springer <springerm@google.com> | 2022-10-31 10:24:02 +0100 |
---|---|---|
committer | Matthias Springer <springerm@google.com> | 2022-10-31 10:26:26 +0100 |
commit | df23ede2f117c8a6483cf6cded09fa63f1deda23 (patch) | |
tree | 4436443064a7b868d4dabb5c3f25e1ede55f5a51 | |
parent | 181ede0ebd724ff38a605fd11a5a601ed0360a16 (diff) | |
download | llvm-df23ede2f117c8a6483cf6cded09fa63f1deda23.zip llvm-df23ede2f117c8a6483cf6cded09fa63f1deda23.tar.gz llvm-df23ede2f117c8a6483cf6cded09fa63f1deda23.tar.bz2 |
[mlir][bufferize][NFC] Debug output during bufferization
When running with `-debug`, print the IR after bufferizing each op.
Differential Revision: https://reviews.llvm.org/D137065
-rw-r--r-- | mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp b/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp index 517ef21..25d2e51 100644 --- a/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp +++ b/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp @@ -30,6 +30,8 @@ namespace bufferization { } // namespace bufferization } // namespace mlir +#define DEBUG_TYPE "bufferize" + using namespace mlir; using namespace mlir::bufferization; @@ -436,23 +438,33 @@ LogicalResult bufferization::bufferizeOp(Operation *op, BufferizationRewriter rewriter(op->getContext(), erasedOps, toMemrefOps, worklist, options, opFilter); for (unsigned i = 0; i < worklist.size(); ++i) { - Operation *op = worklist[i]; + Operation *nextOp = worklist[i]; // Skip ops that were erased. - if (erasedOps.contains(op)) + if (erasedOps.contains(nextOp)) continue; // Skip ops that are not bufferizable or not allowed. - auto bufferizableOp = options.dynCastBufferizableOp(op); + auto bufferizableOp = options.dynCastBufferizableOp(nextOp); if (!bufferizableOp) continue; - if (opFilter && !opFilter->isOpAllowed(op)) + if (opFilter && !opFilter->isOpAllowed(nextOp)) continue; // Skip ops that no longer have tensor semantics. - if (!hasTensorSemantics(op)) + if (!hasTensorSemantics(nextOp)) continue; // Bufferize the op. - rewriter.setInsertionPoint(op); - if (failed(bufferizableOp.bufferize(rewriter, options))) - return op->emitError("failed to bufferize op"); + LLVM_DEBUG(llvm::dbgs() + << "//===-------------------------------------------===//\n" + << "IR after bufferizing: " << nextOp->getName() << "\n"); + rewriter.setInsertionPoint(nextOp); + if (failed(bufferizableOp.bufferize(rewriter, options))) { + LLVM_DEBUG(llvm::dbgs() + << "failed to bufferize\n" + << "//===-------------------------------------------===//\n"); + return nextOp->emitError("failed to bufferize op"); + } + LLVM_DEBUG(llvm::dbgs() + << *op + << "\n//===-------------------------------------------===//\n"); } // Fold all to_memref(to_tensor(x)) pairs. |