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);
63 return genTuple(builder, loc, tp, inputs);
67 addConversion([](
Type type) {
return type; });
83 return builder.
create<StorageSpecifierInitOp>(
88 StorageSpecifierKind kind,
89 std::optional<Level> lvl) {
90 return builder.
create<GetStorageSpecifierOp>(
96 StorageSpecifierKind kind,
97 std::optional<Level> lvl) {
100 specifier = builder.
create<SetStorageSpecifierOp>(
110 const Level cooStart = rType.getAoSCOOStart();
115 Value size = getCrdMemSize(builder, loc, cooStart);
116 size = builder.
create<arith::DivUIOp>(loc, size, stride);
117 return builder.
create<memref::SubViewOp>(
static std::optional< LogicalResult > convertSparseTensorType(RankedTensorType rtp, SmallVectorImpl< Type > &fields)
static Value materializeTuple(OpBuilder &builder, RankedTensorType tp, ValueRange inputs, Location loc)
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.
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.
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.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...
This enum defines all the sparse representations supportable by the SparseTensor dialect.