Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions ext/SparseArraysExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import LinearAlgebra
import Dagger
import Dagger: Blocks, AutoBlocks, BlocksOrAuto, AssignmentType, DSparseArray, DSparseMatrix

# SparseArrays' vararg CSC indexing and Dagger's AbstractArray domain indexing
# each constrain a different argument. Resolve their intersection explicitly.
# SparseArrays' vararg CSC and sparse-vector indexing and Dagger's AbstractArray
# domain indexing each constrain a different argument. Resolve their
# intersection explicitly.
Base.getindex(A::SparseArrays.AbstractSparseMatrixCSC, d::Dagger.ArrayDomain) =
A[Dagger.indexes(d)...]
Base.getindex(x::SparseArrays.AbstractSparseVector, d::Dagger.ArrayDomain) =
x[Dagger.indexes(d)...]

# Keep tiles sparse through `collect`/`cat`; the outer `collect` densifies.
Dagger._sparse_collect(M::SparseMatrixCSC) = copy(M)
Expand Down
5 changes: 5 additions & 0 deletions test/array/allocation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ end
test_dist(rand(100, 100))
test_dist(sprand(100, 100, 0.1))

v = sprand(100, 0.1)
Dv = distribute(v, Blocks(10))
@test Dv isa DArray{eltype(v),1}
@test collect(Dv) == v

x = distribute(rand(10), 2)
@test collect(distribute(x, 3)) == collect(x)
end
Expand Down