-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MLIR][sparse] Add soa
property to sparse_tensor
Python bindings
#109135
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-mlir Author: Mateusz Sokół (mtsokol) ChangesHi! It looks like In [1]: from mlir.dialects import sparse_tensor
In [2]: sparse_tensor.LevelProperty.soa
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[2], line 1
----> 1 sparse_tensor.LevelProperty.soa
AttributeError: type object 'mlir._mlir_libs._mlirDialectsSparseTensor.LevelPro' has no attribute 'soa' which is required to get Python equivalent of: #COO = #sparse_tensor.encoding<{
map = (i, j) -> (i : compressed(nonunique), j : singleton(soa)), posWidth = 64, crdWidth = 64
}> Full diff: https://github.com/llvm/llvm-project/pull/109135.diff 4 Files Affected:
diff --git a/mlir/include/mlir-c/Dialect/SparseTensor.h b/mlir/include/mlir-c/Dialect/SparseTensor.h
index 125469f57c5f55..c816c1b58690ea 100644
--- a/mlir/include/mlir-c/Dialect/SparseTensor.h
+++ b/mlir/include/mlir-c/Dialect/SparseTensor.h
@@ -39,6 +39,7 @@ enum MlirSparseTensorLevelFormat {
enum MlirSparseTensorLevelPropertyNondefault {
MLIR_SPARSE_PROPERTY_NON_UNIQUE = 0x0001,
MLIR_SPARSE_PROPERTY_NON_ORDERED = 0x0002,
+ MLIR_SPARSE_PROPERTY_SOA = 0x0004,
};
//===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Bindings/Python/DialectSparseTensor.cpp b/mlir/lib/Bindings/Python/DialectSparseTensor.cpp
index 584981cfe99bf1..a730bf500be98c 100644
--- a/mlir/lib/Bindings/Python/DialectSparseTensor.cpp
+++ b/mlir/lib/Bindings/Python/DialectSparseTensor.cpp
@@ -33,7 +33,8 @@ static void populateDialectSparseTensorSubmodule(const py::module &m) {
py::enum_<MlirSparseTensorLevelPropertyNondefault>(m, "LevelProperty",
py::module_local())
.value("non_ordered", MLIR_SPARSE_PROPERTY_NON_ORDERED)
- .value("non_unique", MLIR_SPARSE_PROPERTY_NON_UNIQUE);
+ .value("non_unique", MLIR_SPARSE_PROPERTY_NON_UNIQUE)
+ .value("soa", MLIR_SPARSE_PROPERTY_SOA);
mlir_attribute_subclass(m, "EncodingAttr",
mlirAttributeIsASparseTensorEncodingAttr)
diff --git a/mlir/lib/CAPI/Dialect/SparseTensor.cpp b/mlir/lib/CAPI/Dialect/SparseTensor.cpp
index f2a0ab33c0224f..cf25b5263678fb 100644
--- a/mlir/lib/CAPI/Dialect/SparseTensor.cpp
+++ b/mlir/lib/CAPI/Dialect/SparseTensor.cpp
@@ -36,7 +36,9 @@ static_assert(
static_assert(static_cast<int>(MLIR_SPARSE_PROPERTY_NON_ORDERED) ==
static_cast<int>(LevelPropNonDefault::Nonordered) &&
static_cast<int>(MLIR_SPARSE_PROPERTY_NON_UNIQUE) ==
- static_cast<int>(LevelPropNonDefault::Nonunique),
+ static_cast<int>(LevelPropNonDefault::Nonunique) &&
+ static_cast<int>(MLIR_SPARSE_PROPERTY_SOA) ==
+ static_cast<int>(LevelPropNonDefault::SoA),
"MlirSparseTensorLevelProperty (C-API) and "
"LevelPropertyNondefault (C++) mismatch");
diff --git a/mlir/test/Integration/Dialect/SparseTensor/python/test_output.py b/mlir/test/Integration/Dialect/SparseTensor/python/test_output.py
index 544273eb18835e..7d9aa37ba2890c 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/python/test_output.py
+++ b/mlir/test/Integration/Dialect/SparseTensor/python/test_output.py
@@ -129,6 +129,10 @@ def main():
prop = st.LevelProperty
levels = [
[builder(fmt.compressed, [prop.non_unique]), builder(fmt.singleton)],
+ [
+ builder(fmt.compressed, [prop.non_unique]),
+ builder(fmt.singleton, [prop.soa]),
+ ],
[builder(fmt.dense), builder(fmt.compressed)],
[builder(fmt.dense), builder(fmt.loose_compressed)],
[builder(fmt.compressed), builder(fmt.compressed)],
|
@llvm/pr-subscribers-mlir-sparse Author: Mateusz Sokół (mtsokol) ChangesHi! It looks like In [1]: from mlir.dialects import sparse_tensor
In [2]: sparse_tensor.LevelProperty.soa
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[2], line 1
----> 1 sparse_tensor.LevelProperty.soa
AttributeError: type object 'mlir._mlir_libs._mlirDialectsSparseTensor.LevelPro' has no attribute 'soa' which is required to get Python equivalent of: #COO = #sparse_tensor.encoding<{
map = (i, j) -> (i : compressed(nonunique), j : singleton(soa)), posWidth = 64, crdWidth = 64
}> Full diff: https://github.com/llvm/llvm-project/pull/109135.diff 4 Files Affected:
diff --git a/mlir/include/mlir-c/Dialect/SparseTensor.h b/mlir/include/mlir-c/Dialect/SparseTensor.h
index 125469f57c5f55..c816c1b58690ea 100644
--- a/mlir/include/mlir-c/Dialect/SparseTensor.h
+++ b/mlir/include/mlir-c/Dialect/SparseTensor.h
@@ -39,6 +39,7 @@ enum MlirSparseTensorLevelFormat {
enum MlirSparseTensorLevelPropertyNondefault {
MLIR_SPARSE_PROPERTY_NON_UNIQUE = 0x0001,
MLIR_SPARSE_PROPERTY_NON_ORDERED = 0x0002,
+ MLIR_SPARSE_PROPERTY_SOA = 0x0004,
};
//===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Bindings/Python/DialectSparseTensor.cpp b/mlir/lib/Bindings/Python/DialectSparseTensor.cpp
index 584981cfe99bf1..a730bf500be98c 100644
--- a/mlir/lib/Bindings/Python/DialectSparseTensor.cpp
+++ b/mlir/lib/Bindings/Python/DialectSparseTensor.cpp
@@ -33,7 +33,8 @@ static void populateDialectSparseTensorSubmodule(const py::module &m) {
py::enum_<MlirSparseTensorLevelPropertyNondefault>(m, "LevelProperty",
py::module_local())
.value("non_ordered", MLIR_SPARSE_PROPERTY_NON_ORDERED)
- .value("non_unique", MLIR_SPARSE_PROPERTY_NON_UNIQUE);
+ .value("non_unique", MLIR_SPARSE_PROPERTY_NON_UNIQUE)
+ .value("soa", MLIR_SPARSE_PROPERTY_SOA);
mlir_attribute_subclass(m, "EncodingAttr",
mlirAttributeIsASparseTensorEncodingAttr)
diff --git a/mlir/lib/CAPI/Dialect/SparseTensor.cpp b/mlir/lib/CAPI/Dialect/SparseTensor.cpp
index f2a0ab33c0224f..cf25b5263678fb 100644
--- a/mlir/lib/CAPI/Dialect/SparseTensor.cpp
+++ b/mlir/lib/CAPI/Dialect/SparseTensor.cpp
@@ -36,7 +36,9 @@ static_assert(
static_assert(static_cast<int>(MLIR_SPARSE_PROPERTY_NON_ORDERED) ==
static_cast<int>(LevelPropNonDefault::Nonordered) &&
static_cast<int>(MLIR_SPARSE_PROPERTY_NON_UNIQUE) ==
- static_cast<int>(LevelPropNonDefault::Nonunique),
+ static_cast<int>(LevelPropNonDefault::Nonunique) &&
+ static_cast<int>(MLIR_SPARSE_PROPERTY_SOA) ==
+ static_cast<int>(LevelPropNonDefault::SoA),
"MlirSparseTensorLevelProperty (C-API) and "
"LevelPropertyNondefault (C++) mismatch");
diff --git a/mlir/test/Integration/Dialect/SparseTensor/python/test_output.py b/mlir/test/Integration/Dialect/SparseTensor/python/test_output.py
index 544273eb18835e..7d9aa37ba2890c 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/python/test_output.py
+++ b/mlir/test/Integration/Dialect/SparseTensor/python/test_output.py
@@ -129,6 +129,10 @@ def main():
prop = st.LevelProperty
levels = [
[builder(fmt.compressed, [prop.non_unique]), builder(fmt.singleton)],
+ [
+ builder(fmt.compressed, [prop.non_unique]),
+ builder(fmt.singleton, [prop.soa]),
+ ],
[builder(fmt.dense), builder(fmt.compressed)],
[builder(fmt.dense), builder(fmt.loose_compressed)],
[builder(fmt.compressed), builder(fmt.compressed)],
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding!
Hi! I think we can merge it? |
@mtsokol Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/177/builds/6026 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/116/builds/4512 Here is the relevant piece of the build log for the reference
|
It looks like I missed updating test count (I wonder why it wasn't caught in the PR's CI job). Here's a fix for it: #110882 |
This PR fixes a test failure introduced in #109135
This PR fixes a test failure introduced in llvm#109135
Hi!
It looks like
SoA
property is missing from the Python bindings:which is required to get Python equivalent of: