@@ -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.
8686static 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