Skip to content

[mlir][sparse] remove (some) deprecated dim/lvl methods #71125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,10 @@ bool isBlockSparsity(AffineMap dimToLvl);
/// [deprecated] Convenience method to translate the given level to the
/// corresponding dimension. Requires: `0 <= l < lvlRank`.
Dimension toOrigDim(SparseTensorEncodingAttr enc, Level l);
Dimension toOrigDim(RankedTensorType type, Level l);

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

} // namespace sparse_tensor
} // namespace mlir
Expand Down
16 changes: 1 addition & 15 deletions mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ SparseTensorEncodingAttr::tranlateShape(ArrayRef<int64_t> srcShape,

if (isPermutation()) {
for (unsigned r = 0; r < rank; r++) {
// FIXME: `toOrigDim` and `toStoredDim` are deprecated.
unsigned trans = dir == CrdTransDirectionKind::dim2lvl
? toOrigDim(*this, r)
: toStoredDim(*this, r);
Expand Down Expand Up @@ -953,21 +954,6 @@ Level mlir::sparse_tensor::toStoredDim(SparseTensorEncodingAttr enc,
return d;
}

// TODO: Remove this definition once all use-sites have been fixed to
// properly handle non-permutations.
Dimension mlir::sparse_tensor::toOrigDim(RankedTensorType type, Level l) {
const auto enc = getSparseTensorEncoding(type);
assert(!enc || l < enc.getLvlRank());
return toOrigDim(enc, l);
}

// TODO: Remove this definition once all use-sites have been fixed to
// properly handle non-permutations.
Level mlir::sparse_tensor::toStoredDim(RankedTensorType type, Dimension d) {
assert(d < static_cast<Dimension>(type.getRank()));
return toStoredDim(getSparseTensorEncoding(type), d);
}

/// We normalized sparse tensor encoding attribute by always using
/// ordered/unique DLT such that "compressed_nu_no" and "compressed_nu" (as well
/// as other variants) lead to the same storage specifier type, and stripping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ static void createAllocFields(OpBuilder &builder, Location loc,
for (Level lvlRank = stt.getLvlRank(), l = 0; l < lvlRank; l++) {
// Fills dim sizes array.
// FIXME: `toOrigDim` is deprecated.
desc.setLvlSize(builder, loc, l, dimSizes[toOrigDim(stt, l)]);
desc.setLvlSize(builder, loc, l, dimSizes[toOrigDim(stt.getEncoding(), l)]);
// Pushes a leading zero to positions memref.
if (stt.isCompressedLvl(l))
createPushback(builder, loc, desc, SparseTensorFieldKind::PosMemRef, l,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -872,8 +872,9 @@ struct SparseTensorDimOpRewriter : public OpRewritePattern<tensor::DimOp> {
return failure();

if (stt.isPermutation()) {
// FIXME: `toStoredDim` is deprecated
rewriter.replaceOpWithNewOp<LvlOp>(op, op.getSource(),
toStoredDim(stt, *dim));
toStoredDim(stt.getEncoding(), *dim));
return success();
}

Expand Down