Skip to content

Commit 2b67942

Browse files
authored
[mlir][sparse] remove (some) deprecated dim/lvl methods (llvm#71125)
This removes the most obvious ones. The others are still TBD.
1 parent 7b5505b commit 2b67942

File tree

4 files changed

+4
-19
lines changed

4 files changed

+4
-19
lines changed

mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensor.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,10 @@ bool isBlockSparsity(AffineMap dimToLvl);
162162
/// [deprecated] Convenience method to translate the given level to the
163163
/// corresponding dimension. Requires: `0 <= l < lvlRank`.
164164
Dimension toOrigDim(SparseTensorEncodingAttr enc, Level l);
165-
Dimension toOrigDim(RankedTensorType type, Level l);
166165

167166
/// [deprecated] Convenience method to translate the given dimension to
168167
/// the corresponding level. Requires: `0 <= d < dimRank`.
169168
Level toStoredDim(SparseTensorEncodingAttr enc, Dimension d);
170-
Level toStoredDim(RankedTensorType type, Dimension d);
171169

172170
} // namespace sparse_tensor
173171
} // namespace mlir

mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ SparseTensorEncodingAttr::tranlateShape(ArrayRef<int64_t> srcShape,
409409

410410
if (isPermutation()) {
411411
for (unsigned r = 0; r < rank; r++) {
412+
// FIXME: `toOrigDim` and `toStoredDim` are deprecated.
412413
unsigned trans = dir == CrdTransDirectionKind::dim2lvl
413414
? toOrigDim(*this, r)
414415
: toStoredDim(*this, r);
@@ -953,21 +954,6 @@ Level mlir::sparse_tensor::toStoredDim(SparseTensorEncodingAttr enc,
953954
return d;
954955
}
955956

956-
// TODO: Remove this definition once all use-sites have been fixed to
957-
// properly handle non-permutations.
958-
Dimension mlir::sparse_tensor::toOrigDim(RankedTensorType type, Level l) {
959-
const auto enc = getSparseTensorEncoding(type);
960-
assert(!enc || l < enc.getLvlRank());
961-
return toOrigDim(enc, l);
962-
}
963-
964-
// TODO: Remove this definition once all use-sites have been fixed to
965-
// properly handle non-permutations.
966-
Level mlir::sparse_tensor::toStoredDim(RankedTensorType type, Dimension d) {
967-
assert(d < static_cast<Dimension>(type.getRank()));
968-
return toStoredDim(getSparseTensorEncoding(type), d);
969-
}
970-
971957
/// We normalized sparse tensor encoding attribute by always using
972958
/// ordered/unique DLT such that "compressed_nu_no" and "compressed_nu" (as well
973959
/// as other variants) lead to the same storage specifier type, and stripping

mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ static void createAllocFields(OpBuilder &builder, Location loc,
248248
for (Level lvlRank = stt.getLvlRank(), l = 0; l < lvlRank; l++) {
249249
// Fills dim sizes array.
250250
// FIXME: `toOrigDim` is deprecated.
251-
desc.setLvlSize(builder, loc, l, dimSizes[toOrigDim(stt, l)]);
251+
desc.setLvlSize(builder, loc, l, dimSizes[toOrigDim(stt.getEncoding(), l)]);
252252
// Pushes a leading zero to positions memref.
253253
if (stt.isCompressedLvl(l))
254254
createPushback(builder, loc, desc, SparseTensorFieldKind::PosMemRef, l,

mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,8 +872,9 @@ struct SparseTensorDimOpRewriter : public OpRewritePattern<tensor::DimOp> {
872872
return failure();
873873

874874
if (stt.isPermutation()) {
875+
// FIXME: `toStoredDim` is deprecated
875876
rewriter.replaceOpWithNewOp<LvlOp>(op, op.getSource(),
876-
toStoredDim(stt, *dim));
877+
toStoredDim(stt.getEncoding(), *dim));
877878
return success();
878879
}
879880

0 commit comments

Comments
 (0)