-
-
Notifications
You must be signed in to change notification settings - Fork 131
ENH: Update MLIR backend to LLVM 20.dev #799
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,8 +5,8 @@ | |
| import re | ||
| import typing | ||
|
|
||
| from mlir import ir | ||
| from mlir.dialects import sparse_tensor | ||
| from mlir_finch import ir | ||
| from mlir_finch.dialects import sparse_tensor | ||
|
|
||
| import numpy as np | ||
|
|
||
|
|
@@ -36,6 +36,7 @@ def _camel_to_snake(name: str) -> str: | |
| class LevelProperties(enum.Flag): | ||
| NonOrdered = enum.auto() | ||
| NonUnique = enum.auto() | ||
| SOA = enum.auto() | ||
|
|
||
| def build(self) -> list[sparse_tensor.LevelProperty]: | ||
| return [getattr(sparse_tensor.LevelProperty, _camel_to_snake(p.name)) for p in type(self) if p in self] | ||
|
|
@@ -108,15 +109,28 @@ def _get_ctypes_type(self, *, owns_memory=False): | |
| def get_fields(): | ||
| fields = [] | ||
| compressed_counter = 0 | ||
| singleton_counter = 0 | ||
| for level, next_level in itertools.zip_longest(self.levels, self.levels[1:]): | ||
| if LevelFormat.Compressed == level.format: | ||
| compressed_counter += 1 | ||
| fields.append((f"pointers_to_{compressed_counter}", get_nd_memref_descr(1, ptr_dtype))) | ||
| if next_level is not None and LevelFormat.Singleton == next_level.format: | ||
| fields.append((f"indices_{compressed_counter}", get_nd_memref_descr(2, idx_dtype))) | ||
| singleton_counter += 1 | ||
| fields.append( | ||
| ( | ||
| f"indices_{compressed_counter}_coords_{singleton_counter}", | ||
| get_nd_memref_descr(1, idx_dtype), | ||
| ) | ||
| ) | ||
| else: | ||
| fields.append((f"indices_{compressed_counter}", get_nd_memref_descr(1, idx_dtype))) | ||
|
|
||
| if LevelFormat.Singleton == level.format: | ||
| singleton_counter += 1 | ||
| fields.append( | ||
| (f"indices_{compressed_counter}_coords_{singleton_counter}", get_nd_memref_descr(1, idx_dtype)) | ||
| ) | ||
|
|
||
|
Comment on lines
+118
to
+133
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably handle SOA and without SOA separately.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my opinion we should only support SoA singleton format:
What would be the benefit of supporting non-SoA singleton levels separately?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'd be able to support the current COO format only for non-SoA.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean by that? Can you give some example?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The existing Numba
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I'm still missing the point here. Numba is a separate backend that supports only 1D and 2D COO arrays. MLIR backend supports >=2D COO arrays.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, Ideally, I'd like to keep it a 2D We could do this with Also the current Numba backend supports ND, not 2D. SciPy supports only 2D, however. I'm thinking of a future where all of sparse is powered by Finch-MLIR, ideally.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think for accessing |
||
| fields.append(("values", get_nd_memref_descr(1, self.dtype))) | ||
| return fields | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.