Skip to content

Commit 4f145de

Browse files
Add issparsematrix
Looks like this is a missing verb in the sparse matrix vocabulary which is required for writing generic sparse functionality that also works on the GPU. Here's 3 PRs which currently only work on the CPU because of the missing verb: - JuliaDiff/SparseDiffTools.jl#179 - SciML/LinearSolve.jl#104 - JuliaDiff/FiniteDiff.jl#130
1 parent 75c9a32 commit 4f145de

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

docs/src/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ ArrayInterface.is_lazy_conjugate
2222
ArrayInterface.ismutable
2323
ArrayInterface.issingular
2424
ArrayInterface.isstructured
25+
ArrayInterface.issparsematrix
2526
ArrayInterface.is_splat_index
2627
ArrayInterface.known_dimnames
2728
ArrayInterface.known_first
@@ -85,4 +86,3 @@ ArrayInteraface.SOneTo
8586
ArrayInteraface.SUnitRange
8687
ArrayInterface.StrideIndex
8788
```
88-

src/ArrayInterface.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,15 @@ function restructure(x::Array, y)
400400
reshape(convert(Array, y), Base.size(x)...)
401401
end
402402

403+
"""
404+
issparsematrix(A)
405+
406+
Returns whether A is a structurally sparse matrix.
407+
"""
408+
issparsematrix(A::AbstractMatrix) = false
409+
issparsematrix(A::SparseMatrixCSC) = true
410+
411+
403412
abstract type AbstractDevice end
404413
abstract type AbstractCPU <: AbstractDevice end
405414
struct CPUPointer <: AbstractCPU end

src/cuarrays2.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ function restructure(x::CUDA.CuArray, y)
1313
end
1414

1515
device(::Type{<:CUDA.CuArray}) = GPU()
16-
16+
issparsematrix(A::CUDA.CUSPARSE.CuSparseMatrixCSC) = true

0 commit comments

Comments
 (0)