13 #ifndef MLIR_DIALECT_SPARSETENSOR_TRANSFORMS_CODEGENUTILS_H_ 14 #define MLIR_DIALECT_SPARSETENSOR_TRANSFORMS_CODEGENUTILS_H_ 27 namespace sparse_tensor {
50 const SparseTensorEncodingAttr &enc);
54 const SparseTensorEncodingAttr &enc);
85 Attribute
getOneAttr(Builder &builder, Type tp);
110 if (
auto ctp = tp.
dyn_cast<ComplexType>()) {
111 auto zeroe = builder.
getZeroAttr(ctp.getElementType());
113 return builder.
create<complex::ConstantOp>(loc, tp, zeroa);
121 if (
auto ctp = tp.
dyn_cast<ComplexType>()) {
122 auto zeroe = builder.
getZeroAttr(ctp.getElementType());
123 auto onee =
getOneAttr(builder, ctp.getElementType());
125 return builder.
create<complex::ConstantOp>(loc, tp, zeroa);
157 return constantI32(builder, loc, static_cast<uint32_t>(action));
170 const SparseTensorEncodingAttr &enc) {
177 const SparseTensorEncodingAttr &enc) {
199 #endif // MLIR_DIALECT_SPARSETENSOR_TRANSFORMS_CODEGENUTILS_H_ Value constantI8(OpBuilder &builder, Location loc, int8_t i)
Generates a constant of i8 type.
Include the generated interface declarations.
Value constantPointerTypeEncoding(OpBuilder &builder, Location loc, const SparseTensorEncodingAttr &enc)
Generates a constant of the internal type-encoding for pointer overhead storage.
PrimaryType
Encoding of the elemental type, for "overloading" .
Type getOverheadType(Builder &builder, OverheadType ot)
Converts the internal type-encoding for overhead storage to an mlir::Type.
Attribute getZeroAttr(Type type)
Specialization of arith.constant op that returns an integer value.
Value constantIndex(OpBuilder &builder, Location loc, int64_t i)
Generates a constant of index type.
Value constantZero(OpBuilder &builder, Location loc, Type tp)
Generates a 0-valued constant of the given type.
DimLevelType
This enum mimics SparseTensorEncodingAttr::DimLevelType for breaking dependency cycles.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Value constantDimLevelTypeEncoding(OpBuilder &builder, Location loc, SparseTensorEncodingAttr::DimLevelType dlt)
Generates a constant of the internal dimension level type encoding.
StringRef overheadTypeFunctionSuffix(OverheadType ot)
Convert OverheadType to its function-name suffix.
Value genIsNonzero(OpBuilder &builder, Location loc, Value v)
Generates the comparison v != 0 where v is of numeric type.
Value constantI1(OpBuilder &builder, Location loc, bool b)
Generates a constant of i1 type.
Operation * create(const OperationState &state)
Creates an operation given the fields represented as an OperationState.
Value constantIndexTypeEncoding(OpBuilder &builder, Location loc, const SparseTensorEncodingAttr &enc)
Generates a constant of the internal type-encoding for index overhead storage.
Type getPointerOverheadType(Builder &builder, const SparseTensorEncodingAttr &enc)
Returns the mlir::Type for pointer overhead storage.
DimLevelType dimLevelTypeEncoding(SparseTensorEncodingAttr::DimLevelType dlt)
Converts the IR's dimension level type to its internal type-encoding.
Value constantOne(OpBuilder &builder, Location loc, Type tp)
Generates a 1-valued constant of the given type.
Action
The actions performed by .
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Value constantPrimaryTypeEncoding(OpBuilder &builder, Location loc, Type elemTp)
Generates a constant of the internal type-encoding for primary storage.
Value constantOverheadTypeEncoding(OpBuilder &builder, Location loc, unsigned width)
Generates a constant of the internal type-encoding for overhead storage.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Attribute getOneAttr(Builder &builder, Type tp)
Generates a 1-valued attribute of the given type.
OverheadType pointerOverheadTypeEncoding(const SparseTensorEncodingAttr &enc)
Returns the OverheadType for pointer overhead storage.
Value constantAction(OpBuilder &builder, Location loc, Action action)
Generates a constant of the given Action.
Specialization of arith.constant op that returns an integer of index type.
OverheadType overheadTypeEncoding(unsigned width)
Converts an overhead storage bitwidth to its internal type-encoding.
Value constantI32(OpBuilder &builder, Location loc, int32_t i)
Generates a constant of i32 type.
Value constantI16(OpBuilder &builder, Location loc, int16_t i)
Generates a constant of i16 type.
OverheadType indexOverheadTypeEncoding(const SparseTensorEncodingAttr &enc)
Returns the OverheadType for index overhead storage.
Type getIndexOverheadType(Builder &builder, const SparseTensorEncodingAttr &enc)
Returns the mlir::Type for index overhead storage.
PrimaryType primaryTypeEncoding(Type elemTp)
Converts a primary storage type to its internal type-encoding.
StringRef primaryTypeFunctionSuffix(PrimaryType pt)
Convert PrimaryType to its function-name suffix.
This class helps build Operations.
ArrayAttr getArrayAttr(ArrayRef< Attribute > value)
OverheadType
Encoding of overhead types (both pointer overhead and indices overhead), for "overloading" ...