[Mlir-commits] [mlir] [mlir][sparse] Change sparse_tensor.print format (PR #91528)
Aart Bik
llvmlistbot at llvm.org
Wed May 8 14:37:53 PDT 2024
================
@@ -842,6 +844,31 @@ struct PrintRewriter : public OpRewritePattern<PrintOp> {
rewriter.create<vector::PrintOp>(loc, vector::PrintPunctuation::Close);
}
+ // Helper method to print the ending of memref (no punctuation after the last
+ // element).
+ static void printEnding(PatternRewriter &rewriter, Location loc, Value indVar,
+ Value step, Value upperBound, bool isComplex,
+ Value val) {
+ auto bound = rewriter.create<arith::AddIOp>(loc, indVar, step);
+ Value cond = rewriter.create<arith::CmpIOp>(loc, arith::CmpIPredicate::eq,
+ bound, upperBound);
+ scf::IfOp ifOp = rewriter.create<scf::IfOp>(loc, cond, /*else*/ true);
+ if (isComplex) {
----------------
aartbik wrote:
// Terminating comma (except at end).
auto bound = rewriter.create<arith::AddIOp>(loc, idxs.back(), step);
Value cond = rewriter.create<arith::CmpIOp>(loc, arith::CmpIPredicate::ne, bound, size);
scf::IfOp ifOp = rewriter.create<scf::IfOp>(loc, cond, /*else*/ true);
rewriter.setInsertionPointToStart(&ifOp.getThenRegion().front());
rewriter.create<vector::PrintOp>(loc, vector::PrintPunctuation::Comma);
https://github.com/llvm/llvm-project/pull/91528
More information about the Mlir-commits
mailing list