[mlir][sparse] Change sparse_tensor.print format (#91528)

1. Remove the trailing comma for the last element of memref and add
closing parenthesis.
2. Change integration tests to use the new format.
This commit is contained in:
Yinying Li
2024-05-09 12:09:40 -04:00
committed by GitHub
parent df21ee4c62
commit eb177803bf
73 changed files with 1068 additions and 1059 deletions

View File

@@ -830,11 +830,17 @@ private:
vector::PrintPunctuation::Comma);
rewriter.create<vector::PrintOp>(loc, imag,
vector::PrintPunctuation::Close);
rewriter.create<vector::PrintOp>(loc, vector::PrintPunctuation::Comma);
} else {
rewriter.create<vector::PrintOp>(loc, val,
vector::PrintPunctuation::Comma);
rewriter.create<vector::PrintOp>(
loc, val, vector::PrintPunctuation::NoPunctuation);
}
// 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*/ false);
rewriter.setInsertionPointToStart(&ifOp.getThenRegion().front());
rewriter.create<vector::PrintOp>(loc, vector::PrintPunctuation::Comma);
}
idxs.pop_back();
rewriter.setInsertionPointAfter(forOp);