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

Introduce Abstract types for sparse arrays #577

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

albertomercurio
Copy link
Contributor

@albertomercurio albertomercurio commented Dec 16, 2024

I find the AbstractGPUArray implementation very useful, which allows to have very generic methods for any GPU array, from CUDA.jl to Metal.jl and others.

Here, I try to implement such feature for sparse arrays. It is still a draft, but the basic method seems already to work. I can perform matrix-vector multiplication between a JLSparseMatrixCSC and a `JLVector.

What I would like to implement in this PR:

  • Abstract types for all the sparse arrays
  • Sparse Vector using JLArrays
  • CSC sparse matrix using JLArrays
  • CSR sparse matrix using JLArrays
  • COO sparse matrix using JLArrays
  • vector-vector dot product
  • matrix-vector multiplication with CSC types
  • matrix-vector multiplication with CSR types
  • matrix-vector multiplication with COO types
  • matrix-matrix multiplication with CSC types
  • matrix-matrix multiplication with CSR types
  • matrix-matrix multiplication with COO types
  • Add tests

I think this is already enough for a single PR.

Copy link
Member

@maleadt maleadt left a comment

Choose a reason for hiding this comment

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

Interesting!

FYI, CUDA.jl already has quite some native sparse operations implemented (including broadcast), so you may want to look there for inspiration, or to port additional functionality.

src/host/sparse.jl Outdated Show resolved Hide resolved
src/host/sparse.jl Outdated Show resolved Hide resolved
src/host/sparse.jl Outdated Show resolved Hide resolved
lib/GPUArraysCore/src/GPUArraysCore.jl Outdated Show resolved Hide resolved
@albertomercurio
Copy link
Contributor Author

Yes I'm already using some of them. I recently needed to implement sparse support for Metal.jl, so I decided to implement it very generally here.

I will for sure take inspiration from the CUDA sparse implementation.

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

Successfully merging this pull request may close these issues.

2 participants