@@ -308,17 +308,46 @@ Value reshapeValuesToLevels(OpBuilder &builder, Location loc,
308
308
SparseTensorEncodingAttr enc, ValueRange dimSizes,
309
309
Value valuesBuffer, Value lvlCoords);
310
310
311
+ // Generates code to cast a tensor to a memref.
312
+ TypedValue<BaseMemRefType> genToMemref (OpBuilder &builder, Location loc,
313
+ Value tensor);
314
+
315
+ // / Infers the result type and generates `ToPositionsOp`.
316
+ Value genToPositions (OpBuilder &builder, Location loc, Value tensor, Level lvl);
317
+
318
+ // / Infers the result type and generates `ToCoordinatesOp`. If the
319
+ // / level is within a COO region, the result type is a memref with unknown
320
+ // / stride and offset. Otherwise, the result type is a memref without
321
+ // / any specified layout.
322
+ Value genToCoordinates (OpBuilder &builder, Location loc, Value tensor,
323
+ Level lvl, Level cooStart);
324
+
325
+ // / Infers the result type and generates `ToCoordinatesBufferOp`.
326
+ Value genToCoordinatesBuffer (OpBuilder &builder, Location loc, Value tensor);
327
+
328
+ // / Infers the result type and generates `ToValuesOp`.
329
+ Value genToValues (OpBuilder &builder, Location loc, Value tensor);
330
+
331
+ // / Generates code to retrieve the values size for the sparse tensor.
332
+ Value genValMemSize (OpBuilder &builder, Location loc, Value tensor);
333
+
334
+ // / Generates code to retrieve the slice offset for the sparse tensor slice,
335
+ // / return a constant if the offset is statically known.
336
+ Value createOrFoldSliceOffsetOp (OpBuilder &builder, Location loc, Value tensor,
337
+ Dimension dim);
338
+
339
+ // / Generates code to retrieve the slice slice for the sparse tensor slice,
340
+ // / return a constant if the offset is statically known.
341
+ Value createOrFoldSliceStrideOp (OpBuilder &builder, Location loc, Value tensor,
342
+ Dimension dim);
343
+
311
344
// ===----------------------------------------------------------------------===//
312
345
// Inlined constant generators.
313
346
//
314
347
// All these functions are just wrappers to improve code legibility;
315
348
// therefore, we mark them as `inline` to avoid introducing any additional
316
- // overhead due to the legibility.
349
+ // overhead due to the legibility. Ideally these should move upstream.
317
350
//
318
- // TODO: Ideally these should move upstream, so that we don't
319
- // develop a design island. However, doing so will involve
320
- // substantial design work. For related prior discussion, see
321
- // <https://llvm.discourse.group/t/evolving-builder-apis-based-on-lessons-learned-from-edsc/879>
322
351
// ===----------------------------------------------------------------------===//
323
352
324
353
// / Generates a 0-valued constant of the given type. In addition to
@@ -420,38 +449,6 @@ inline bool isZeroRankedTensorOrScalar(Type type) {
420
449
return !rtp || rtp.getRank () == 0 ;
421
450
}
422
451
423
- // Generates code to cast a tensor to a memref.
424
- TypedValue<BaseMemRefType> genToMemref (OpBuilder &builder, Location loc,
425
- Value tensor);
426
-
427
- // / Infers the result type and generates `ToPositionsOp`.
428
- Value genToPositions (OpBuilder &builder, Location loc, Value tensor, Level lvl);
429
-
430
- // / Infers the result type and generates `ToCoordinatesOp`. If the
431
- // / level is within a COO region, the result type is a memref with unknown
432
- // / stride and offset. Otherwise, the result type is a memref without
433
- // / any specified layout.
434
- Value genToCoordinates (OpBuilder &builder, Location loc, Value tensor,
435
- Level lvl, Level cooStart);
436
-
437
- // / Infers the result type and generates `ToCoordinatesBufferOp`.
438
- Value genToCoordinatesBuffer (OpBuilder &builder, Location loc, Value tensor);
439
-
440
- // / Infers the result type and generates `ToValuesOp`.
441
- Value genToValues (OpBuilder &builder, Location loc, Value tensor);
442
-
443
- // / Generates code to retrieve the values size for the sparse tensor.
444
- Value genValMemSize (OpBuilder &builder, Location loc, Value tensor);
445
-
446
- // / Generates code to retrieve the slice offset for the sparse tensor slice,
447
- // / return a constant if the offset is statically known.
448
- Value createOrFoldSliceOffsetOp (OpBuilder &builder, Location loc, Value tensor,
449
- Dimension dim);
450
-
451
- // / Generates code to retrieve the slice slice for the sparse tensor slice,
452
- // / return a constant if the offset is statically known.
453
- Value createOrFoldSliceStrideOp (OpBuilder &builder, Location loc, Value tensor,
454
- Dimension dim);
455
452
} // namespace sparse_tensor
456
453
} // namespace mlir
457
454
0 commit comments