9 #ifndef MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSOR_H_
10 #define MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSOR_H_
24 #define GET_ATTRDEF_CLASSES
25 #include "mlir/Dialect/SparseTensor/IR/SparseTensorAttrEnums.h.inc"
27 #define GET_ATTRDEF_CLASSES
28 #include "mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.h.inc"
30 #define GET_TYPEDEF_CLASSES
31 #include "mlir/Dialect/SparseTensor/IR/SparseTensorTypes.h.inc"
33 #define GET_OP_CLASSES
34 #include "mlir/Dialect/SparseTensor/IR/SparseTensorOps.h.inc"
36 #include "mlir/Dialect/SparseTensor/IR/SparseTensorOpsDialect.h.inc"
39 namespace sparse_tensor {
44 return t.getType().template cast<RankedTensorType>();
50 return t.getType().template cast<MemRefType>();
77 auto types = enc.getDimLevelType();
78 assert(d < types.size() &&
"Dimension out of bounds");
89 inline bool isDenseDim(RankedTensorType type, uint64_t d) {
104 inline bool isDenseDim(SparseTensorEncodingAttr enc, uint64_t d) {
138 uint64_t
toOrigDim(SparseTensorEncodingAttr enc, uint64_t d);
139 uint64_t
toStoredDim(SparseTensorEncodingAttr enc, uint64_t d);
143 uint64_t
toOrigDim(RankedTensorType type, uint64_t d);
147 uint64_t
toStoredDim(RankedTensorType type, uint64_t d);
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
bool isOrderedDim(RankedTensorType type, uint64_t d)
Convenience function to test for ordered property in the given dimension (0 <= d < rank).
uint64_t toStoredDim(SparseTensorEncodingAttr enc, uint64_t d)
MemRefType getMemRefType(T t)
Convenience method to abbreviate casting getType().
constexpr bool isSingletonDLT(DimLevelType dlt)
Check if the DimLevelType is singleton (regardless of properties).
constexpr bool isUniqueDLT(DimLevelType dlt)
Check if the DimLevelType is unique (regardless of storage format).
uint64_t toOrigDim(SparseTensorEncodingAttr enc, uint64_t d)
bool isCompressedDim(RankedTensorType type, uint64_t d)
Convenience function to test for compressed dimension (0 <= d < rank).
constexpr bool isDenseDLT(DimLevelType dlt)
Check if the DimLevelType is dense.
unsigned getCOOStart(SparseTensorEncodingAttr enc)
Returns the starting dimension for a trailing COO region that spans across at least two dimensions.
bool isUniqueDim(RankedTensorType type, uint64_t d)
Convenience function to test for unique property in the given dimension (0 <= d < rank).
bool isDenseDim(RankedTensorType type, uint64_t d)
Convenience function to test for dense dimension (0 <= d < rank).
constexpr std::optional< DimLevelType > getDimLevelType(LevelFormat lf, bool ordered, bool unique)
Convert a LevelFormat to its corresponding DimLevelType with the given properties.
RankedTensorType getRankedTensorType(T t)
Convenience method to abbreviate casting getType().
SparseTensorEncodingAttr getSparseTensorEncoding(Type type)
Convenience method to get a sparse encoding attribute from a type.
DimLevelType
This enum defines all the sparse representations supportable by the SparseTensor dialect.
constexpr bool isCompressedDLT(DimLevelType dlt)
Check if the DimLevelType is compressed (regardless of properties).
bool isUniqueCOOType(RankedTensorType tp)
Returns true iff the given type is a type for a COO tensor with the last dimension level type being u...
bool isSingletonDim(RankedTensorType type, uint64_t d)
Convenience function to test for singleton dimension (0 <= d < rank).
constexpr bool isOrderedDLT(DimLevelType dlt)
Check if the DimLevelType is ordered (regardless of storage format).
Include the generated interface declarations.