support unit-aware sparse computation: CSR, CSC, COO#80
Merged
chaoming0625 merged 5 commits intomainfrom Dec 14, 2024
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant updates to the
brainunitpackage, focusing on the addition of sparse matrix support and enhancements to data type promotion functions. Key changes include the integration of theSparseMatrixclass, updates to arithmetic operations to handle sparse matrices, and new utility functions for data type promotion.Sparse Matrix Support:
SparseMatrixclass inbrainunit/_sparse_base.pywith various arithmetic operations (__add__,__sub__,__mul__, etc.) and placeholder methods for future implementation.brainunit/_base.pyto handle instances ofSparseMatrix. [1] [2] [3] [4] [5] [6] [7]brainunit/sparse/__init__.pyto expose theCOO,CSR, andCSCclasses and their associated functions.COOclass inbrainunit/sparse/coo_test.pyto validate matrix operations likematvec,matmul,add,sub,mul,div,mod,pos,neg, andabs.Data Type Promotion Enhancements:
promote_dtypesfunction inbrainunit/math/_fun_keep_unit.pyto promote the data types of input arrays to a common type.get_promote_dtypesfunction inbrainunit/math/_fun_remove_unit.pyto facilitate data type promotion for input arrays.Documentation:
docs/apis/brainunit.sparse.rstto include documentation for the new sparse data structures and operations.Import and Export Updates:
sparsemodule inbrainunit/__init__.pyand updated the__all__list to reflect the new module. [1] [2]SparseMatrixinbrainunit/_base.pyand addedsplit_mantissa_unitfunction. [1] [2] [3]promote_dtypesfromjaxinbrainunit/math/_fun_keep_unit.py. [1] [2]These changes significantly enhance the functionality and versatility of the
brainunitpackage, particularly in handling sparse matrices and promoting data types efficiently.