Skip to content

Commit c24506e

Browse files
switch names
1 parent fc0c9ab commit c24506e

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

mlir/include/mlir-c/Dialect/SparseTensor.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(SparseTensor, sparse_tensor);
2525
/// These correspond to SparseTensorEncodingAttr::LevelType in the C++ API.
2626
/// If updating, keep them in sync and update the static_assert in the impl
2727
/// file.
28-
typedef uint64_t MlirBaseLevelType;
28+
typedef uint64_t MlirSparseTensorLevelType;
2929

30-
enum MlirSparseTensorLevelType {
30+
enum MlirBaseLevelType {
3131
MLIR_SPARSE_TENSOR_LEVEL_DENSE = 4, // 0b00001_00
3232
MLIR_SPARSE_TENSOR_LEVEL_COMPRESSED = 8, // 0b00010_00
3333
MLIR_SPARSE_TENSOR_LEVEL_COMPRESSED_NU = 9, // 0b00010_01
@@ -54,15 +54,16 @@ mlirAttributeIsASparseTensorEncodingAttr(MlirAttribute attr);
5454

5555
/// Creates a `sparse_tensor.encoding` attribute with the given parameters.
5656
MLIR_CAPI_EXPORTED MlirAttribute mlirSparseTensorEncodingAttrGet(
57-
MlirContext ctx, intptr_t lvlRank, MlirBaseLevelType const *lvlTypes,
58-
MlirAffineMap dimToLvl, MlirAffineMap lvlTodim, int posWidth, int crdWidth);
57+
MlirContext ctx, intptr_t lvlRank,
58+
MlirSparseTensorLevelType const *lvlTypes, MlirAffineMap dimToLvl,
59+
MlirAffineMap lvlTodim, int posWidth, int crdWidth);
5960

6061
/// Returns the level-rank of the `sparse_tensor.encoding` attribute.
6162
MLIR_CAPI_EXPORTED intptr_t
6263
mlirSparseTensorEncodingGetLvlRank(MlirAttribute attr);
6364

6465
/// Returns a specified level-type of the `sparse_tensor.encoding` attribute.
65-
MLIR_CAPI_EXPORTED MlirBaseLevelType
66+
MLIR_CAPI_EXPORTED MlirSparseTensorLevelType
6667
mlirSparseTensorEncodingAttrGetLvlType(MlirAttribute attr, intptr_t lvl);
6768

6869
/// Returns the dimension-to-level mapping of the `sparse_tensor.encoding`

mlir/lib/Bindings/Python/DialectSparseTensor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static void populateDialectSparseTensorSubmodule(const py::module &m) {
4646
mlirAttributeIsASparseTensorEncodingAttr)
4747
.def_classmethod(
4848
"get",
49-
[](py::object cls, std::vector<MlirBaseLevelType> lvlTypes,
49+
[](py::object cls, std::vector<MlirSparseTensorLevelType> lvlTypes,
5050
std::optional<MlirAffineMap> dimToLvl,
5151
std::optional<MlirAffineMap> lvlToDim, int posWidth, int crdWidth,
5252
MlirContext context) {
@@ -64,7 +64,7 @@ static void populateDialectSparseTensorSubmodule(const py::module &m) {
6464
"lvl_types",
6565
[](MlirAttribute self) {
6666
const int lvlRank = mlirSparseTensorEncodingGetLvlRank(self);
67-
std::vector<MlirBaseLevelType> ret;
67+
std::vector<MlirSparseTensorLevelType> ret;
6868
ret.reserve(lvlRank);
6969
for (int l = 0; l < lvlRank; ++l)
7070
ret.push_back(mlirSparseTensorEncodingAttrGetLvlType(self, l));

mlir/lib/CAPI/Dialect/SparseTensor.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ bool mlirAttributeIsASparseTensorEncodingAttr(MlirAttribute attr) {
4444
return isa<SparseTensorEncodingAttr>(unwrap(attr));
4545
}
4646

47-
MlirAttribute mlirSparseTensorEncodingAttrGet(MlirContext ctx, intptr_t lvlRank,
48-
MlirBaseLevelType const *lvlTypes,
49-
MlirAffineMap dimToLvl,
50-
MlirAffineMap lvlToDim,
51-
int posWidth, int crdWidth) {
47+
MlirAttribute
48+
mlirSparseTensorEncodingAttrGet(MlirContext ctx, intptr_t lvlRank,
49+
MlirSparseTensorLevelType const *lvlTypes,
50+
MlirAffineMap dimToLvl, MlirAffineMap lvlToDim,
51+
int posWidth, int crdWidth) {
5252
SmallVector<LevelType> cppLvlTypes;
5353
cppLvlTypes.reserve(lvlRank);
5454
for (intptr_t l = 0; l < lvlRank; ++l)
@@ -70,9 +70,9 @@ intptr_t mlirSparseTensorEncodingGetLvlRank(MlirAttribute attr) {
7070
return cast<SparseTensorEncodingAttr>(unwrap(attr)).getLvlRank();
7171
}
7272

73-
MlirBaseLevelType mlirSparseTensorEncodingAttrGetLvlType(MlirAttribute attr,
74-
intptr_t lvl) {
75-
return static_cast<MlirBaseLevelType>(
73+
MlirSparseTensorLevelType
74+
mlirSparseTensorEncodingAttrGetLvlType(MlirAttribute attr, intptr_t lvl) {
75+
return static_cast<MlirSparseTensorLevelType>(
7676
cast<SparseTensorEncodingAttr>(unwrap(attr)).getLvlType(lvl));
7777
}
7878

mlir/test/CAPI/sparse_tensor.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ static int testRoundtripEncoding(MlirContext ctx) {
4343
MlirAffineMap lvlToDim =
4444
mlirSparseTensorEncodingAttrGetLvlToDim(originalAttr);
4545
int lvlRank = mlirSparseTensorEncodingGetLvlRank(originalAttr);
46-
MlirBaseLevelType *lvlTypes = malloc(sizeof(MlirBaseLevelType) * lvlRank);
46+
MlirSparseTensorLevelType *lvlTypes =
47+
malloc(sizeof(MlirSparseTensorLevelType) * lvlRank);
4748
for (int l = 0; l < lvlRank; ++l) {
4849
lvlTypes[l] = mlirSparseTensorEncodingAttrGetLvlType(originalAttr, l);
4950
fprintf(stderr, "level_type: %lu\n", lvlTypes[l]);

0 commit comments

Comments
 (0)