[Mlir-commits] [mlir] [mlir][sparse] Add verification for explicit/implicit value (PR #90111)

Aart Bik llvmlistbot at llvm.org
Thu May 2 11:09:58 PDT 2024


================
@@ -502,9 +502,37 @@ def SparseTensorEncodingAttr : SparseTensor_Attr<"SparseTensorEncoding",
     //
     // Helper function to translate between level/dimension space.
     //
+
     SmallVector<int64_t> translateShape(::mlir::ArrayRef<int64_t> srcShape, ::mlir::sparse_tensor::CrdTransDirectionKind) const;
     ValueRange translateCrds(::mlir::OpBuilder &builder, ::mlir::Location loc, ::mlir::ValueRange crds, ::mlir::sparse_tensor::CrdTransDirectionKind) const;
 
+    //
+    // COO struct and methods.
+    //
+
+    /// A simple structure that encodes a range of levels in the sparse tensors
+    /// that forms a COO segment.
+    struct COOSegment {
+      std::pair<Level, Level> lvlRange; // [low, high)
+      bool isSoA;
+
+      bool isAoS() const { return !isSoA; }
+      bool isSegmentStart(Level l) const { return l == lvlRange.first; }
+      bool inSegment(Level l) const {
+        return l >= lvlRange.first && l < lvlRange.second;
+      }
+    };
----------------
aartbik wrote:

+1

in general I would like to have the encoding spec as simple as possible
and have implementation details be hidden in our header/cc files

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


More information about the Mlir-commits mailing list