Skip to content

[mlir][sparse] fixed naming consistency #73053

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 2 commits into from
Nov 22, 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
10 changes: 4 additions & 6 deletions mlir/include/mlir/Dialect/SparseTensor/IR/Enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,12 @@ constexpr bool is2OutOf4DLT(DimLevelType dlt) {
}

/// Check if the `DimLevelType` needs positions array.
constexpr bool isDLTWithPos(DimLevelType dlt) {
constexpr bool isWithPosDLT(DimLevelType dlt) {
return isCompressedDLT(dlt) || isLooseCompressedDLT(dlt);
}

/// Check if the `DimLevelType` needs coordinates array.
constexpr bool isDLTWithCrd(DimLevelType dlt) {
constexpr bool isWithCrdDLT(DimLevelType dlt) {
return isCompressedDLT(dlt) || isSingletonDLT(dlt) ||
isLooseCompressedDLT(dlt) || is2OutOf4DLT(dlt);
}
Expand All @@ -311,10 +311,8 @@ constexpr std::optional<LevelFormat> getLevelFormat(DimLevelType dlt) {
}

/// Convert a LevelFormat to its corresponding DimLevelType with the given
/// properties. Returns std::nullopt when the properties are not applicable for
/// the input level format.
/// TODO: factor out a new LevelProperties type so we can add new properties
/// without changing this function's signature
/// properties. Returns std::nullopt when the properties are not applicable
/// for the input level format.
constexpr std::optional<DimLevelType>
buildLevelType(LevelFormat lf, bool ordered, bool unique) {
auto dlt = static_cast<DimLevelType>(static_cast<uint8_t>(lf) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ class SparseTensorType {
bool is2OutOf4Lvl(Level l) const { return is2OutOf4DLT(getLvlType(l)); }
bool isOrderedLvl(Level l) const { return isOrderedDLT(getLvlType(l)); }
bool isUniqueLvl(Level l) const { return isUniqueDLT(getLvlType(l)); }
bool isWithPos(Level l) const { return isDLTWithPos(getLvlType(l)); }
bool isWithCrd(Level l) const { return isDLTWithCrd(getLvlType(l)); }
bool isWithPos(Level l) const { return isWithPosDLT(getLvlType(l)); }
bool isWithCrd(Level l) const { return isWithCrdDLT(getLvlType(l)); }

/// Returns the coordinate-overhead bitwidth, defaulting to zero.
unsigned getCrdWidth() const { return enc ? enc.getCrdWidth() : 0; }
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ void StorageLayout::foreachField(
// Per-level storage.
for (Level l = 0; l < end; l++) {
const auto dlt = lvlTypes[l];
if (isDLTWithPos(dlt)) {
if (isWithPosDLT(dlt)) {
if (!(callback(fieldIdx++, SparseTensorFieldKind::PosMemRef, l, dlt)))
return;
}
if (isDLTWithCrd(dlt)) {
if (isWithCrdDLT(dlt)) {
if (!(callback(fieldIdx++, SparseTensorFieldKind::CrdMemRef, l, dlt)))
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ struct SparseAssembleOpConverter : public OpConversionPattern<AssembleOp> {
continue;
}

if (isDLTWithPos(dlt)) {
if (isWithPosDLT(dlt)) {
assert(isCompressedDLT(dlt) || isLooseCompressedDLT(dlt));
if (isLooseCompressedDLT(dlt)) {
memSize = rewriter.create<arith::MulIOp>(loc, memSize, c2);
Expand All @@ -1356,7 +1356,7 @@ struct SparseAssembleOpConverter : public OpConversionPattern<AssembleOp> {
memSize = genIndexLoad(rewriter, loc, desc.getPosMemRef(lvl), posBack);
posBack = rewriter.create<arith::SubIOp>(loc, posBack, c1);
}
assert(isDLTWithCrd(dlt) && lvl <= trailCOOStart);
assert(isWithCrdDLT(dlt) && lvl <= trailCOOStart);
// FIXME: This seems to be unnecessarily complex, can we simplify it?
if (lvl == trailCOOStart) {
Value cooSz = rewriter.create<arith::MulIOp>(
Expand Down