Skip to content

Commit b9ed84e

Browse files
authored
Add a generic dot for GPUArrays (#427)
1 parent 837e88d commit b9ed84e

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/host/linalg.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,9 @@ function Base.similar(A::Hermitian{<:Any,<:AbstractGPUArray}, ::Type{T}) where T
441441
return Hermitian(B, ifelse(A.uplo == 'U', :U, :L))
442442
end
443443

444+
## dot
445+
446+
LinearAlgebra.dot(x::AbstractGPUArray, y::AbstractGPUArray) = mapreduce(dot, +, x, y)
444447

445448
## axp{b}y
446449

test/testsuite/linalg.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,12 @@
222222
end
223223

224224
@testset "axp{b}y" for T in eltypes
225-
alpha, beta = 0.5, 2.0
226-
x = T.([2,4,6])
227-
y = T.([3,4,5])
228-
@test axpby!(alpha,x,beta,y) T.([7,10,13])
229-
@test axpy!(alpha,x,y) T.([8,12,16])
225+
@test compare(axpby!, AT, Ref(rand(T)), rand(T,5), Ref(rand(T)), rand(T,5))
226+
@test compare(axpy!, AT, Ref(rand(T)), rand(T,5), rand(T,5))
227+
end
228+
229+
@testset "dot" for T in eltypes
230+
@test compare(dot, AT, rand(T,5), rand(T, 5))
230231
end
231232

232233
@testset "iszero and isone" for T in eltypes

0 commit comments

Comments
 (0)