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

Issues with CuPy and the Sparse Implementation #6

Open
crumleyc opened this issue Mar 3, 2020 · 4 comments
Open

Issues with CuPy and the Sparse Implementation #6

crumleyc opened this issue Mar 3, 2020 · 4 comments

Comments

@crumleyc
Copy link
Contributor

crumleyc commented Mar 3, 2020

Currently implemented is pydata's sparse.COO but it isn't compatable with cupy yet! It is part of their future plans, but currently not.

Other option but not really. Cupy has scipy coo_matrix implemented but it doesn't support 1D vectors.

The S Matrix is a cupy array, so the 1D array must be cupy or compatible with cupy and numpy aka sparse.COO

@crumleyc
Copy link
Contributor Author

crumleyc commented Mar 3, 2020

pydata/sparse#198

@crumleyc
Copy link
Contributor Author

crumleyc commented Mar 4, 2020

I have tried other unsuccessful attempts:

v = cp.random.random(176) #(176,)
indices = np.argpartition(v,-20)[-20:] #(20,)
col = cp.ones(20) #(20,)

cupyx.scipy.sparse.coo_matrix((v[indices],(indices,col)))

This results in an error saying that all parameters needs to be 1D arrays, even though they are all 1D.

v = cp.random.random(176) #(176,)
indices = np.argpartition(v,-20)[-20:] #(20,)
min = v[indices].min()
v[v < min] = 0
cupyx.scipy.sparse.coo_matrix(v)

I think this method only works when v is already a sparse matrix.

@crumleyc
Copy link
Contributor Author

I noticed in dask's distributed repository, they had some unit testing where they implemented the cupyx.scipy.sparse.coo_matrix here. I got that to work.

@crumleyc
Copy link
Contributor Author

u_new = da.dot(S,_V_.result()).compute() is causing an error:

TypeError: 'coo_matrix' object is not subscriptable

Where V.result() returns a dask cupy sparse array.

Looks like it is being looked into cupy/cupy#3178.

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

No branches or pull requests

1 participant