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

Handling possibly sparse arrays #19

Closed
tkf opened this issue Nov 15, 2019 · 2 comments
Closed

Handling possibly sparse arrays #19

tkf opened this issue Nov 15, 2019 · 2 comments

Comments

@tkf
Copy link

tkf commented Nov 15, 2019

Currently, converting a matrix that could be dense or sparse requires explicit branching:

if x isa SparseMatrixCSC
    # adapt(CuSparseMatrixCSC, x) does not work, BTW
    CuSparseMatrixCSC(x)
else
    adapt(CuArray, x)
end

It would be nice if adapt can do something like

to = Union{CuArray, CuSparseMatrixCSC, CuSparseMatrixCSR}

adapt(to, zeros(2, 2)) :: CuArray
adapt(to, spzeros(2, 2)) :: CuSparseMatrixCSC
adapt(to, transpose(spzeros(2, 2))) :: CuSparseMatrixCSR

Is it in the scope of this package?

@MikeInnes
Copy link
Contributor

I think it'd be fine for adapt(CuArray, x) to support sparse arrays like this. However, that would have to happen in CuArrays.jl, not adapt.jl itself.

@tkf
Copy link
Author

tkf commented Nov 16, 2019

Thanks for the clarification. So I'll close this issue for now. Maybe I'll open a PR in CuArrays.jl later.

@tkf tkf closed this as completed Nov 16, 2019
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

2 participants