20 mlir::sparse_tensor::SparseTensorDialect)
34 "MlirSparseTensorLevelFormat (C-API) and LevelFormat (C++) mismatch");
42 "MlirSparseTensorLevelProperty (C-API) and "
43 "LevelPropertyNondefault (C++) mismatch");
46 return isa<SparseTensorEncodingAttr>(
unwrap(attr));
52 MlirAffineMap lvlToDim,
int posWidth,
int crdWidth,
53 MlirAttribute explicitVal, MlirAttribute implicitVal) {
56 cppLvlTypes.reserve(lvlRank);
57 for (
intptr_t l = 0; l < lvlRank; ++l)
58 cppLvlTypes.push_back(
static_cast<LevelType>(lvlTypes[l]));
60 return wrap(SparseTensorEncodingAttr::get(
66 return wrap(SparseTensorEncodingAttr::name);
70 return wrap(cast<SparseTensorEncodingAttr>(
unwrap(attr)).getDimToLvl());
74 return wrap(cast<SparseTensorEncodingAttr>(
unwrap(attr)).getLvlToDim());
78 return cast<SparseTensorEncodingAttr>(
unwrap(attr)).getLvlRank();
84 cast<SparseTensorEncodingAttr>(
unwrap(attr)).getLvlType(lvl));
95 return cast<SparseTensorEncodingAttr>(
unwrap(attr)).getPosWidth();
99 return cast<SparseTensorEncodingAttr>(
unwrap(attr)).getCrdWidth();
103 return wrap(cast<SparseTensorEncodingAttr>(
unwrap(attr)).getExplicitVal());
107 return wrap(cast<SparseTensorEncodingAttr>(
unwrap(attr)).getImplicitVal());
113 unsigned size,
unsigned n,
unsigned m) {
115 std::vector<LevelPropNonDefault> props;
117 for (
unsigned i = 0; i < size; i++)
#define MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Name, Namespace, ClassName)
intptr_t mlirSparseTensorEncodingGetLvlRank(MlirAttribute attr)
Returns the level-rank of the sparse_tensor.encoding attribute.
MlirAffineMap mlirSparseTensorEncodingAttrGetLvlToDim(MlirAttribute attr)
Returns the level-to-dimension mapping of the sparse_tensor.encoding attribute.
int mlirSparseTensorEncodingAttrGetCrdWidth(MlirAttribute attr)
Returns the coordinate bitwidth of the sparse_tensor.encoding attribute.
MlirAttribute mlirSparseTensorEncodingAttrGet(MlirContext ctx, intptr_t lvlRank, MlirSparseTensorLevelType const *lvlTypes, MlirAffineMap dimToLvl, MlirAffineMap lvlToDim, int posWidth, int crdWidth, MlirAttribute explicitVal, MlirAttribute implicitVal)
Creates a sparse_tensor.encoding attribute with the given parameters.
MlirSparseTensorLevelType mlirSparseTensorEncodingAttrBuildLvlType(enum MlirSparseTensorLevelFormat lvlFmt, const enum MlirSparseTensorLevelPropertyNondefault *properties, unsigned size, unsigned n, unsigned m)
bool mlirAttributeIsASparseTensorEncodingAttr(MlirAttribute attr)
Checks whether the given attribute is a sparse_tensor.encoding attribute.
MlirStringRef mlirSparseTensorEncodingAttrGetName(void)
MlirAffineMap mlirSparseTensorEncodingAttrGetDimToLvl(MlirAttribute attr)
Returns the dimension-to-level mapping of the sparse_tensor.encoding attribute.
MlirAttribute mlirSparseTensorEncodingAttrGetExplicitVal(MlirAttribute attr)
Returns the explicit value of the sparse_tensor.encoding attribute.
int mlirSparseTensorEncodingAttrGetPosWidth(MlirAttribute attr)
Returns the position bitwidth of the sparse_tensor.encoding attribute.
unsigned mlirSparseTensorEncodingAttrGetStructuredN(MlirSparseTensorLevelType lvlType)
unsigned mlirSparseTensorEncodingAttrGetStructuredM(MlirSparseTensorLevelType lvlType)
MlirAttribute mlirSparseTensorEncodingAttrGetImplicitVal(MlirAttribute attr)
Returns the implicit value of the sparse_tensor.encoding attribute.
enum MlirSparseTensorLevelFormat mlirSparseTensorEncodingAttrGetLvlFmt(MlirAttribute attr, intptr_t lvl)
Returns a specified level-format of the sparse_tensor.encoding attribute.
MlirSparseTensorLevelType mlirSparseTensorEncodingAttrGetLvlType(MlirAttribute attr, intptr_t lvl)
Returns a specified level-type of the sparse_tensor.encoding attribute.
MlirDiagnostic wrap(mlir::Diagnostic &diagnostic)
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)
uint64_t MlirSparseTensorLevelType
Dimension level types (and properties) that define sparse tensors.
MlirSparseTensorLevelFormat
@ MLIR_SPARSE_TENSOR_LEVEL_N_OUT_OF_M
@ MLIR_SPARSE_TENSOR_LEVEL_COMPRESSED
@ MLIR_SPARSE_TENSOR_LEVEL_DENSE
@ MLIR_SPARSE_TENSOR_LEVEL_LOOSE_COMPRESSED
@ MLIR_SPARSE_TENSOR_LEVEL_SINGLETON
MlirSparseTensorLevelPropertyNondefault
@ MLIR_SPARSE_PROPERTY_NON_UNIQUE
@ MLIR_SPARSE_PROPERTY_NON_ORDERED
@ MLIR_SPARSE_PROPERTY_SOA
The OpAsmOpInterface, see OpAsmInterface.td for more details.
LevelFormat
This enum defines all supported storage format without the level properties.
std::optional< LevelType > buildLevelType(LevelFormat lf, const std::vector< LevelPropNonDefault > &properties, uint64_t n=0, uint64_t m=0)
uint64_t getN(LevelType lt)
uint64_t getM(LevelType lt)
LevelPropNonDefault
This enum defines all the nondefault properties for storage formats.
A pointer to a sized fragment of a string, not necessarily null-terminated.
This enum defines all the sparse representations supportable by the SparseTensor dialect.
constexpr LevelFormat getLvlFmt() const
Get the LevelFormat of the LevelType.