Skip to content
Merged
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
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Strided"
uuid = "5e0ebb24-38b0-5f93-81fe-25c709ecae67"
version = "2.3.2"
version = "2.3.3"
authors = ["Lukas Devos <lukas.devos@ugent.be>", "Maarten Van Damme <maartenvd1994@gmail.com>", "Jutho Haegeman <jutho.haegeman@ugent.be>"]

[deps]
Expand Down Expand Up @@ -28,7 +28,7 @@ JLArrays = "0.3.1"
GPUArrays = "11.4.1"
LinearAlgebra = "1.6"
Random = "1.6"
StridedViews = "0.4.5"
StridedViews = "0.4.6"
Test = "1.6"
TupleTools = "1.6"
julia = "1.6"
Expand Down
7 changes: 7 additions & 0 deletions ext/StridedGPUArraysExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,11 @@ function Base.Broadcast.BroadcastStyle(gpu_sv::StridedView{T, N, TA}) where {T,
return typeof(raw_style)(Val(N)) # sets the dimensionality correctly
end

function Base.copy!(dst::AbstractArray{TD, ND}, src::StridedView{TS, NS, TAS, FS}) where {TD <: Number, ND, TS <: Number, NS, TAS <: AbstractGPUArray{TS}, FS <: ALL_FS}
bc_style = Base.Broadcast.BroadcastStyle(TAS)
bc = Base.Broadcast.Broadcasted(bc_style, identity, (src,), axes(dst))
GPUArrays._copyto!(dst, bc)
return dst
end

end
7 changes: 0 additions & 7 deletions ext/StridedJLArraysExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,4 @@ function Base.copy!(dst::StridedView{TD, ND, TAD, FD}, src::StridedView{TS, NS,
return dst
end

function Base.copy!(dst::AbstractArray{TD, ND}, src::StridedView{TS, NS, TAS, FS}) where {TD <: Number, ND, TS <: Number, NS, TAS <: JLArray{TS}, FS <: ALL_FS}
bc_style = Base.Broadcast.BroadcastStyle(TAS)
bc = Base.Broadcast.Broadcasted(bc_style, identity, (src,), axes(dst))
GPUArrays._copyto!(dst, bc)
return dst
end

end
3 changes: 3 additions & 0 deletions test/amd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ for T in (Float32, Float64, Complex{Float32}, Complex{Float64})
A1 = ROCMatrix(randn(T, (m1, m2)))
end
A2 = similar(A1)
zA1 = ROCMatrix(f1(zeros(T, (m1, m2))))
zA2 = ROCMatrix(f2(zeros(T, (m1, m2))))
A1c = copy(A1)
A2c = copy(A2)
B1 = f1(StridedView(A1c))
B2 = f2(StridedView(A2c))
axes(f1(A1)) == axes(f2(A2)) || continue
@test collect(ROCMatrix(copy!(f2(A2), f1(A1)))) == AMDGPU.Adapt.adapt(Vector{T}, copy!(B2, B1))
@test copy!(zA1, f1(A1)) == copy!(zA2, B1)
end
end
end
3 changes: 3 additions & 0 deletions test/cuda.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ for T in (Float32, Float64, Complex{Float32}, Complex{Float64})
for m1 in (0, 16, 32), m2 in (0, 16, 32)
A1 = CUDA.randn(T, (m1, m2))
A2 = similar(A1)
zA1 = CuMatrix(f1(zeros(T, (m1, m2))))
zA2 = CuMatrix(f2(zeros(T, (m1, m2))))
A1c = copy(A1)
A2c = copy(A2)
B1 = f1(StridedView(A1c))
B2 = f2(StridedView(A2c))
axes(f1(A1)) == axes(f2(A2)) || continue
@test collect(CuMatrix(copy!(f2(A2), f1(A1)))) == CUDA.Adapt.adapt(Vector{T}, copy!(B2, B1))
@test copy!(zA1, f1(A1)) == copy!(zA2, B1)
end
end
end
3 changes: 3 additions & 0 deletions test/jlarrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ for T in (Float32, Float64, Complex{Float32}, Complex{Float64})
for m1 in (0, 16, 32), m2 in (0, 16, 32)
A1 = JLArray(randn(T, (m1, m2)))
A2 = similar(A1)
zA1 = JLArray(f1(zeros(T, (m1, m2))))
zA2 = JLArray(f2(zeros(T, (m1, m2))))
A1c = copy(A1)
A2c = copy(A2)
B1 = f1(StridedView(A1c))
B2 = f2(StridedView(A2c))
axes(f1(A1)) == axes(f2(A2)) || continue
@test collect(Matrix(copy!(f2(A2), f1(A1)))) == JLArrays.Adapt.adapt(Vector{T}, copy!(B2, B1))
@test copy!(zA1, f1(A1)) == copy!(zA2, B1)
end
end
end
Loading