19 using namespace sparse_tensor;
27 std::optional<Level> lvl) {
35 static std::optional<LogicalResult>
46 assert(fieldIdx == fields.size());
47 fields.push_back(fieldType);
58 addConversion([](
Type type) {
return type; });
62 addSourceMaterialization([](
OpBuilder &builder, RankedTensorType tp,
64 Location loc) -> std::optional<Value> {
69 return genTuple(builder, loc, tp, inputs);
79 return builder.
create<StorageSpecifierInitOp>(
84 StorageSpecifierKind kind,
85 std::optional<Level> lvl) {
86 return builder.
create<GetStorageSpecifierOp>(
92 StorageSpecifierKind kind,
93 std::optional<Level> lvl) {
96 specifier = builder.
create<SetStorageSpecifierOp>(
111 Value size = getCrdMemSize(builder, loc, cooStart);
112 size = builder.
create<arith::DivUIOp>(loc, size, stride);
113 return builder.
create<memref::SubViewOp>(
static std::optional< LogicalResult > convertSparseTensorType(RankedTensorType rtp, SmallVectorImpl< Type > &fields)
static IntegerAttr optionalLevelAttr(MLIRContext *ctx, std::optional< Level > lvl)
Constructs a nullable LevelAttr from the std::optional<Level>.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
MLIRContext is the top-level object for a collection of MLIR operations.
This class helps build Operations.
Operation * create(const OperationState &state)
Creates an operation given the fields represented as an OperationState.
SparseTensorTypeToBufferConverter()
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
This class provides an abstraction over the different types of ranges over Values.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Type getType() const
Return the type of this value.
Value getCrdMemRefOrView(OpBuilder &builder, Location loc, Level lvl) const
void setSpecifierField(OpBuilder &builder, Location loc, Value v, StorageSpecifierKind kind, std::optional< Level > lvl)
Value getSpecifierField(OpBuilder &builder, Location loc, StorageSpecifierKind kind, std::optional< Level > lvl)
static Value getInitValue(OpBuilder &builder, Location loc, SparseTensorType stt)
A wrapper around RankedTensorType, which has three goals:
bool hasEncoding() const
Returns true for tensors which have an encoding, and false for those which do not.
SparseTensorEncodingAttr getEncoding() const
Value constantIndex(OpBuilder &builder, Location loc, int64_t i)
Generates a constant of index type.
Level getCOOStart(SparseTensorEncodingAttr enc)
Returns the starting level for a trailing COO region that spans at least two levels.
void foreachFieldAndTypeInSparseTensor(SparseTensorType, llvm::function_ref< bool(Type, FieldIndex, SparseTensorFieldKind, Level, LevelType)>)
unsigned FieldIndex
The type of field indices.
uint64_t Level
The type of level identifiers and level-ranks.
Value genTuple(OpBuilder &builder, Location loc, Type tp, ValueRange values)
Packs the given values as a "tuple" value.
LevelType
This enum defines all the sparse representations supportable by the SparseTensor dialect.
SparseTensorEncodingAttr getSparseTensorEncoding(Type type)
Convenience method to get a sparse encoding attribute from a type.
SparseTensorFieldKind
===-------------------------------------------------------------------—===// The sparse tensor storag...
Include the generated interface declarations.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...