[Mlir-commits] [mlir] [MLIR][SparseTensor] Dense Outer Loop Ordering Strategy (PR #160168)
Aart Bik
llvmlistbot at llvm.org
Mon Oct 20 12:59:45 PDT 2025
================
@@ -80,6 +80,52 @@ inline static bool includesDenseOutput(SortMask mask) {
return includesAny(mask, SortMask::kIncludeDenseOutput);
}
+/// Returns a sparsity rank for loop ordering: lower values indicate
+/// dimensions that should be placed in outer loops.
+/// 0 = Dense, 1 = Compressed, 2 = Singleton, 3 = Other/Unknown
+static unsigned getLoopSparsityRank(unsigned loop, ArrayRef<Value> allTensors,
+ ArrayRef<AffineMap> allMaps) {
+ unsigned bestRank = 3; // Default: most sparse (unknown/singleton-like)
+
+ for (auto [tensor, map] : llvm::zip(allTensors, allMaps)) {
+ // Check if this loop accesses this tensor
----------------
aartbik wrote:
Here and elsewhere, sorry to nitpick, but keep the "period at end" in mind for non-inline comments
https://github.com/llvm/llvm-project/pull/160168
More information about the Mlir-commits
mailing list