Skip to content

Commit 9aff34e

Browse files
mtsokolSterling-Augustine
authored andcommitted
[MLIR][sparse] Add soa property to sparse_tensor Python bindings (llvm#109135)
1 parent a187e3c commit 9aff34e

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ enum MlirSparseTensorLevelFormat {
3939
enum MlirSparseTensorLevelPropertyNondefault {
4040
MLIR_SPARSE_PROPERTY_NON_UNIQUE = 0x0001,
4141
MLIR_SPARSE_PROPERTY_NON_ORDERED = 0x0002,
42+
MLIR_SPARSE_PROPERTY_SOA = 0x0004,
4243
};
4344

4445
//===----------------------------------------------------------------------===//

mlir/lib/Bindings/Python/DialectSparseTensor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ static void populateDialectSparseTensorSubmodule(const py::module &m) {
3333
py::enum_<MlirSparseTensorLevelPropertyNondefault>(m, "LevelProperty",
3434
py::module_local())
3535
.value("non_ordered", MLIR_SPARSE_PROPERTY_NON_ORDERED)
36-
.value("non_unique", MLIR_SPARSE_PROPERTY_NON_UNIQUE);
36+
.value("non_unique", MLIR_SPARSE_PROPERTY_NON_UNIQUE)
37+
.value("soa", MLIR_SPARSE_PROPERTY_SOA);
3738

3839
mlir_attribute_subclass(m, "EncodingAttr",
3940
mlirAttributeIsASparseTensorEncodingAttr)

mlir/lib/CAPI/Dialect/SparseTensor.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ static_assert(
3636
static_assert(static_cast<int>(MLIR_SPARSE_PROPERTY_NON_ORDERED) ==
3737
static_cast<int>(LevelPropNonDefault::Nonordered) &&
3838
static_cast<int>(MLIR_SPARSE_PROPERTY_NON_UNIQUE) ==
39-
static_cast<int>(LevelPropNonDefault::Nonunique),
39+
static_cast<int>(LevelPropNonDefault::Nonunique) &&
40+
static_cast<int>(MLIR_SPARSE_PROPERTY_SOA) ==
41+
static_cast<int>(LevelPropNonDefault::SoA),
4042
"MlirSparseTensorLevelProperty (C-API) and "
4143
"LevelPropertyNondefault (C++) mismatch");
4244

mlir/test/Integration/Dialect/SparseTensor/python/test_output.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ def main():
129129
prop = st.LevelProperty
130130
levels = [
131131
[builder(fmt.compressed, [prop.non_unique]), builder(fmt.singleton)],
132+
[
133+
builder(fmt.compressed, [prop.non_unique]),
134+
builder(fmt.singleton, [prop.soa]),
135+
],
132136
[builder(fmt.dense), builder(fmt.compressed)],
133137
[builder(fmt.dense), builder(fmt.loose_compressed)],
134138
[builder(fmt.compressed), builder(fmt.compressed)],

0 commit comments

Comments
 (0)