9 #ifndef MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSOR_H_
10 #define MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSOR_H_
32 namespace sparse_tensor {
51 #define GET_ATTRDEF_CLASSES
52 #include "mlir/Dialect/SparseTensor/IR/SparseTensorAttrEnums.h.inc"
54 #define GET_ATTRDEF_CLASSES
55 #include "mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.h.inc"
57 #define GET_TYPEDEF_CLASSES
58 #include "mlir/Dialect/SparseTensor/IR/SparseTensorTypes.h.inc"
60 #define GET_OP_CLASSES
61 #include "mlir/Dialect/SparseTensor/IR/SparseTensorOps.h.inc"
63 #include "mlir/Dialect/SparseTensor/IR/SparseTensorOpsDialect.h.inc"
70 namespace sparse_tensor {
75 assert(
static_cast<bool>(std::forward<T>(t)) &&
76 "getRankedTensorType got null argument");
77 return dyn_cast<RankedTensorType>(std::forward<T>(t).getType());
83 assert(
static_cast<bool>(std::forward<T>(t)) &&
84 "getMemRefType got null argument");
85 return cast<MemRefType>(std::forward<T>(t).getType());
94 return llvm::any_of(op->getOperands().getTypes(), [](
Type t) {
95 return getSparseTensorEncoding(t) != nullptr;
101 return llvm::any_of(op->getResults().getTypes(), [](
Type t) {
102 return getSparseTensorEncoding(t) != nullptr;
A multi-dimensional affine map Affine map's are immutable like Type's, and they are uniqued.
MLIRContext is the top-level object for a collection of MLIR operations.
Operation is the basic unit of execution within MLIR.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
bool hasAnySparseOperandOrResult(Operation *op)
Returns true iff MLIR operand has any sparse operand or result.
Dimension toDim(SparseTensorEncodingAttr enc, Level l)
Convenience method to translate the given level to the corresponding dimension.
uint64_t Dimension
The type of dimension identifiers and dimension-ranks.
uint64_t Level
The type of level identifiers and level-ranks.
int64_t Size
The type for individual components of a compile-time shape, including the value ShapedType::kDynamic ...
RankedTensorType getRankedTensorType(T &&t)
Convenience method to abbreviate casting getType().
AffineMap inferLvlToDim(AffineMap dimToLvl, MLIRContext *context)
Given the dimToLvl map, infers the lvlToDim map, or returns empty Affine map when inference fails.
SparseTensorEncodingAttr getSparseTensorEncoding(Type type)
Convenience method to get a sparse encoding attribute from a type.
MemRefType getMemRefType(T &&t)
Convenience method to abbreviate casting getType().
Level toLvl(SparseTensorEncodingAttr enc, Dimension d)
Convenience method to translate the given dimension to the corresponding level.
bool isBlockSparsity(AffineMap dimToLvl)
Given the dimToLvl map, returns if it's block sparsity.
bool hasAnyNonIdentityOperandsOrResults(Operation *op)
Returns true iff MLIR operation has any sparse tensor with non-identity dim2lvl maps.
bool hasAnySparseResult(Operation *op)
Returns true iff MLIR operand has any sparse result.
bool hasAnySparseOperand(Operation *op)
Returns true iff MLIR operand has any sparse operand.
SmallVector< unsigned > getBlockSize(AffineMap dimToLvl)
Given the dimToLvl map, returns the block sizes in a vector.
AffineMap inverseBlockSparsity(AffineMap dimToLvl, MLIRContext *context)
Returns the lvlToDim map for the given dimToLvl map specific to the block sparse cases.
Include the generated interface declarations.