Skip to content
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

[WIP] CSR/ CSC Elemwise #465

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft

[WIP] CSR/ CSC Elemwise #465

wants to merge 11 commits into from

Conversation

ivirshup
Copy link
Contributor

@ivirshup ivirshup commented Apr 24, 2021

Very WIP draft PR for elemwise operations on CSR and CSC arrays.

Currently just implements broadcasting operations between compressed 2d arrays. Cases that would be covered by a full implementation:

  • Unary broadcasting (e.g. -a)
  • Binary broadcasting
    • compressed_2d + compressed_2d
    • compressed_2d + scalar
    • compressed_2d + dense_1d
    • compressed_2d + sparse_1d

A quick benchmark:

import sparse
from sparse._compressed import CSR, CSC

gcxs_a = sparse.random((10000, 20000), .01, format="gcxs")
gcxs_b = sparse.random((10000, 20000), .01, format="gcxs")

csr_a = CSR(gcxs_a)
csr_b = CSR(gcxs_b)

scipy_a = csr_a.to_scipy_sparse()
scipy_b = csr_b.to_scipy_sparse()
%timeit gcxs_a + gcxs_b
# 999 ms ± 10.2 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

%timeit csr_a + csr_b
# 32.2 ms ± 1.9 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

%timeit scipy_a + scipy_b
# 27.5 ms ± 894 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

Should provide some insight for #460

@hameerabbasi
Copy link
Collaborator

Thanks for this, @ivirshup. Let me know if you need any help or direction.

@codecov
Copy link

codecov bot commented Jul 20, 2023

Codecov Report

Merging #465 (9b7f22c) into master (096f9b0) will decrease coverage by 1.24%.
The diff coverage is 64.42%.

@@            Coverage Diff             @@
##           master     #465      +/-   ##
==========================================
- Coverage   92.15%   90.91%   -1.24%     
==========================================
  Files          20       21       +1     
  Lines        3313     3445     +132     
==========================================
+ Hits         3053     3132      +79     
- Misses        260      313      +53     

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.

@hameerabbasi
Copy link
Collaborator

@ivirshup Do you plan to continue this?

@ivirshup
Copy link
Contributor Author

I have some interest but probably not time. I would love for someone to take it over.

IIRC the biggest stumbling block was dispatch. If that could get worked out by someone else, I'd be interested in collaborating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants