Skip to content

Commit 1964118

Browse files
authored
[mlir][sparse] fix codegen header ordering of methods into sections (#68175)
1 parent 714b4c8 commit 1964118

File tree

1 file changed

+34
-37
lines changed

1 file changed

+34
-37
lines changed

mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.h

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -308,17 +308,46 @@ Value reshapeValuesToLevels(OpBuilder &builder, Location loc,
308308
SparseTensorEncodingAttr enc, ValueRange dimSizes,
309309
Value valuesBuffer, Value lvlCoords);
310310

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+
311344
//===----------------------------------------------------------------------===//
312345
// Inlined constant generators.
313346
//
314347
// All these functions are just wrappers to improve code legibility;
315348
// 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.
317350
//
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>
322351
//===----------------------------------------------------------------------===//
323352

324353
/// Generates a 0-valued constant of the given type. In addition to
@@ -420,38 +449,6 @@ inline bool isZeroRankedTensorOrScalar(Type type) {
420449
return !rtp || rtp.getRank() == 0;
421450
}
422451

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);
455452
} // namespace sparse_tensor
456453
} // namespace mlir
457454

0 commit comments

Comments
 (0)