Skip to content

Commit bfe907b

Browse files
committed
[MLIR][SparseTensor] Address PR feedback to fix style
1 parent cc2e786 commit bfe907b

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,10 @@ enum class SparseEmitStrategy {
5858
namespace sparse_tensor {
5959

6060
/// Defines a strategy for loop ordering during sparse code generation.
61+
/// See Passes.td for strategy descriptions.
6162
enum class LoopOrderingStrategy : unsigned {
62-
kDefault, ///< Default strategy (eagerly selects last loop in topological
63-
///< sort).
64-
kDenseOuter, ///< Prefer dense, then compressed, then singleton dimensions
65-
///< outermost.
63+
kDefault,
64+
kDenseOuter,
6665
};
6766

6867
} // namespace sparse_tensor

mlir/lib/Dialect/SparseTensor/Transforms/Utils/IterationGraphSorter.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ inline static bool includesDenseOutput(SortMask mask) {
8282

8383
/// Returns a sparsity rank for loop ordering: lower values indicate
8484
/// dimensions that should be placed in outer loops.
85-
/// 0 = Dense, 1 = Compressed, 2 = Singleton, 3 = Other/Unknown
85+
/// 0 = Dense, 1 = Compressed, 2 = Singleton, 3 = Other/Unknown.
8686
static unsigned getLoopSparsityRank(unsigned loop, ArrayRef<Value> allTensors,
8787
ArrayRef<AffineMap> allMaps) {
88-
unsigned bestRank = 3; // Default: most sparse (unknown/singleton-like)
88+
unsigned bestRank = 3; // Default: most sparse (unknown/singleton-like).
8989

9090
for (auto [tensor, map] : llvm::zip(allTensors, allMaps)) {
91-
// Check if this loop accesses this tensor
91+
// Check if this loop accesses this tensor.
9292
bool loopAccessesTensor = false;
9393
unsigned tensorDim = 0;
9494
for (AffineExpr expr : map.getResults()) {
@@ -104,19 +104,19 @@ static unsigned getLoopSparsityRank(unsigned loop, ArrayRef<Value> allTensors,
104104
if (loopAccessesTensor) {
105105
const auto enc = getSparseTensorEncoding(tensor.getType());
106106
if (!enc) {
107-
// Dense tensor - highest priority
107+
// Dense tensor - highest priority.
108108
return 0;
109109
} else {
110-
// Sparse tensor - check the level type for this dimension
110+
// Sparse tensor - check the level type for this dimension.
111111
auto lvlTypes = enc.getLvlTypes();
112112
if (tensorDim < lvlTypes.size()) {
113113
auto lvlType = lvlTypes[tensorDim];
114114
if (isDenseLT(lvlType)) {
115-
return 0; // Dense level
115+
return 0; // Dense level.
116116
} else if (isCompressedLT(lvlType)) {
117-
bestRank = std::min(bestRank, 1u); // Compressed level
117+
bestRank = std::min(bestRank, 1u); // Compressed level.
118118
} else if (isSingletonLT(lvlType)) {
119-
bestRank = std::min(bestRank, 2u); // Singleton level
119+
bestRank = std::min(bestRank, 2u); // Singleton level.
120120
}
121121
}
122122
}

0 commit comments

Comments
 (0)