-
Notifications
You must be signed in to change notification settings - Fork 93
Description
Hello, I think it would be very helpful to add constructors to the generic GPU sparse arrays interface for building sparse matrices directly from index/value GPU vectors, bypassing the COO path used by sparse. This would enable packages to precompute the structure and values and construct sparse matrices efficiently across backends.
I was imaging something like:
# in GPUArrays.jl
export GPUSparseMatrixCSC, ...
function GPUSparseMatrixCSC end
# same for other formats
# in JLArrays.jl
GPUSparseMatrix{Tv, Ti}(rowPtr::JLArray, colVal::JLArray, nzVal::JLArray, dims) = JLSparseMatrixCSC{Tv, Ti}(rowPtr, colVal, nzVal, dims)
# in CUDA.jl
GPUSparseMatrix{Tv, Ti}(rowPtr::CuArray, colVal::CuArray, nzVal::CuArray, dims) = CuSparseMatrixCSC{Tv, Ti}(rowPtr, colVal, nzVal, dims)
# and so on in the other backendsOne issue is that the arguments might differ between backends or have different requirements on their values(see #648). I think in this case, the formats are so specific though, that the implementations will likely just differ in the types of their vectors.
An example use case can be seen here, where in initial tests the overhead of the COO format negates performance gains over the CPU implementation.
I'm not sure if I fully understand the relationship between AbstractGPUSparseMatrices and GPUSparseDeviceVector yet and if it would make sense to provide a default implementation for the constructor which defaults to reference to the corresponding default vector.
If this or another version of such a constructor seems sensible, I'd be happy to make PRs