[Mlir-commits] [mlir] [MLIR] [SparseTensor] Implement multiple loop ordering heuristics for sparse tensor dialect (PR #151885)

Aart Bik llvmlistbot at llvm.org
Fri Aug 8 10:50:53 PDT 2025


================
@@ -28,22 +31,28 @@ class GenericOp;
 
 namespace sparse_tensor {
 
+// Forward declaration for sparse tensor encoding
+class SparseTensorEncodingAttr;
+
 /// Iteration graph sorting mask,
 enum class SortMask : unsigned {
-  // The individual mask bits.
   kIncludeDenseOutput = 0x1, // b001
   kIncludeDenseInput = 0x2,  // b010
-  // The subsets of mask bits.
   kIncludeAll = 0x7,   // b111
   kIncludeDense = 0x3, // b011
   kSparseOnly = 0x0,   // b000
 };
 
 class IterationGraphSorter {
 public:
-  /// Factory method that construct an iteration graph sorter
-  /// for the given linalg.generic operation.
+  /// Factory method that constructs an iteration graph sorter
+  /// for the given linalg.generic operation (original behavior).
   static IterationGraphSorter fromGenericOp(linalg::GenericOp genericOp);
+  
+  /// Factory method that constructs an iteration graph sorter
+  /// for the given linalg.generic operation with the specified loop ordering strategy.
+  static IterationGraphSorter fromGenericOp(linalg::GenericOp genericOp, 
----------------
aartbik wrote:

is it really necessary to have two? I would much rather see the original behavior as part of the single factory

I understand this organization from your point of view (easy to revert back to old behavior without changes), but going forward it really does not make sense to have a "classic" and "improved" mode

that is what git history is for ;-)

https://github.com/llvm/llvm-project/pull/151885


More information about the Mlir-commits mailing list