builder.getIndexAttr(lvl));
}
+Value sparse_tensor::genToCoordinatesBuffer(OpBuilder &builder, Location loc,
+ Value tensor) {
+ const auto srcTp = getSparseTensorType(tensor);
+ const Type crdTp = srcTp.getEncoding().getCrdType();
+ const Type memTp = get1DMemRefType(crdTp, /*withLayout=*/false);
+ return builder.create<ToCoordinatesBufferOp>(loc, memTp, tensor);
+}
+
Value sparse_tensor::genToValues(OpBuilder &builder, Location loc,
Value tensor) {
RankedTensorType srcTp = getRankedTensorType(tensor);
Value genToCoordinates(OpBuilder &builder, Location loc, Value tensor,
Level lvl, Level cooStart);
+/// Infers the result type and generates `ToCoordinatesBufferOp`.
+Value genToCoordinatesBuffer(OpBuilder &builder, Location loc, Value tensor);
+
/// Infers the result type and generates `ToValuesOp`.
Value genToValues(OpBuilder &builder, Location loc, Value tensor);
// coordinates for the storage ordering of the dst tensor. Use SortCoo
// if the COO tensor has the same ordering as the dst tensor.
if (dimRank > 1 && srcTp.hasSameDimToLvlMap(dstTp)) {
- MemRefType coordsTp =
- get1DMemRefType(encSrc.getCrdType(), /*withLayout=*/false);
- Value xs = rewriter.create<ToCoordinatesBufferOp>(loc, coordsTp, src);
+ Value xs = genToCoordinatesBuffer(rewriter, loc, src);
rewriter.create<SortCooOp>(
loc, nnz, xs, ValueRange{y}, rewriter.getIndexAttr(dimRank),
rewriter.getIndexAttr(0), SparseTensorSortKind::HybridQuickSort);