Skip to content

Commit d2d2928

Browse files
authored
[mlir][sparse] code cleanup (llvm#73047)
removed two unused methods, removed obsoleted FIXME
1 parent 2743b30 commit d2d2928

File tree

2 files changed

+7
-27
lines changed

2 files changed

+7
-27
lines changed

mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,10 +412,8 @@ def SparseTensorEncodingAttr : SparseTensor_Attr<"SparseTensorEncoding",
412412
::mlir::sparse_tensor::SparseTensorDimSliceAttr getDimSlice(::mlir::sparse_tensor::Dimension dim) const;
413413

414414
std::optional<uint64_t> getStaticDimSliceOffset(::mlir::sparse_tensor::Dimension dim) const;
415-
std::optional<uint64_t> getStaticDimSliceSize(::mlir::sparse_tensor::Dimension dim) const;
416415
std::optional<uint64_t> getStaticDimSliceStride(::mlir::sparse_tensor::Dimension dim) const;
417416
std::optional<uint64_t> getStaticLvlSliceOffset(::mlir::sparse_tensor::Level lvl) const;
418-
std::optional<uint64_t> getStaticLvlSliceSize(::mlir::sparse_tensor::Level lvl) const;
419417
std::optional<uint64_t> getStaticLvlSliceStride(::mlir::sparse_tensor::Level lvl) const;
420418

421419
//

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

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,6 @@ SparseTensorEncodingAttr::getStaticDimSliceOffset(Dimension dim) const {
368368
return getDimSlice(dim).getStaticOffset();
369369
}
370370

371-
std::optional<uint64_t>
372-
SparseTensorEncodingAttr::getStaticDimSliceSize(Dimension dim) const {
373-
return getDimSlice(dim).getStaticSize();
374-
}
375-
376371
std::optional<uint64_t>
377372
SparseTensorEncodingAttr::getStaticDimSliceStride(Dimension dim) const {
378373
return getDimSlice(dim).getStaticStride();
@@ -384,12 +379,6 @@ SparseTensorEncodingAttr::getStaticLvlSliceOffset(Level lvl) const {
384379
return getStaticDimSliceOffset(toOrigDim(*this, lvl));
385380
}
386381

387-
std::optional<uint64_t>
388-
SparseTensorEncodingAttr::getStaticLvlSliceSize(Level lvl) const {
389-
// FIXME: `toOrigDim` is deprecated.
390-
return getStaticDimSliceSize(toOrigDim(*this, lvl));
391-
}
392-
393382
std::optional<uint64_t>
394383
SparseTensorEncodingAttr::getStaticLvlSliceStride(Level lvl) const {
395384
// FIXME: `toOrigDim` is deprecated.
@@ -1744,33 +1733,26 @@ LogicalResult SortOp::verify() {
17441733
if (!xPerm.isPermutation())
17451734
emitError(llvm::formatv("Expected a permutation map, got {0}", xPerm));
17461735

1747-
std::optional<int64_t> cn = getConstantIntValue(getN());
17481736
// We can't check the size of the buffers when n or buffer dimensions aren't
17491737
// compile-time constants.
1738+
std::optional<int64_t> cn = getConstantIntValue(getN());
17501739
if (!cn)
17511740
return success();
17521741

1753-
uint64_t n = cn.value();
1754-
uint64_t ny = 0;
1755-
if (auto nyAttr = getNyAttr()) {
1756-
ny = nyAttr.getInt();
1757-
}
1758-
1759-
// FIXME: update the types of variables used in expressions bassed as
1760-
// the `minSize` argument, to avoid implicit casting at the callsites
1761-
// of this lambda.
1742+
// Verify dimensions.
17621743
const auto checkDim = [&](Value v, Size minSize, const char *message) {
17631744
const Size sh = getMemRefType(v).getShape()[0];
17641745
if (!ShapedType::isDynamic(sh) && sh < minSize)
17651746
emitError(llvm::formatv("{0} got {1} < {2}", message, sh, minSize));
17661747
};
1767-
1748+
uint64_t n = cn.value();
1749+
uint64_t ny = 0;
1750+
if (auto nyAttr = getNyAttr())
1751+
ny = nyAttr.getInt();
17681752
checkDim(getXy(), n * (nx + ny),
17691753
"Expected dimension(xy) >= n * (rank(perm_map) + ny)");
1770-
1771-
for (Value opnd : getYs()) {
1754+
for (Value opnd : getYs())
17721755
checkDim(opnd, n, "Expected dimension(y) >= n");
1773-
}
17741756

17751757
return success();
17761758
}

0 commit comments

Comments
 (0)