Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] Fix LinearAlgebra.lmul! on GPU #233

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
3 changes: 3 additions & 0 deletions src/linear_algebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ function LinearAlgebra.axpby!(α::Number, x::ComponentArray, β::Number, y::Comp
axpby!(α, getdata(x), β, getdata(y))
return ComponentArray(y, getaxes(y))
end

lmul!(a::Number, B::ComponentArray) = ComponentArray(lmul!(a, getdata(B)), getaxes(B))

14 changes: 13 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ caa = ComponentArray(a = ca, b = sq_mat)

_a, _b, _c = Val.((:a, :b, :c))


## Tests
@testset "Allocations and Inference" begin
@test @ballocated($ca.c.a.a) == 0
Expand Down Expand Up @@ -690,6 +689,19 @@ end
@test_throws ArgumentError axpby!(2, x, 3, y)
end

@testset "lmul!" begin
a = rand()
x = ComponentArray(a = rand(4), b = rand(4))

xdata = copy(getdata(x))
xaxes = getaxes(x)

y = lmul!(a, x)
@test y == x
@test getdata(x) ≈ a * xdata
@test getaxes(x) == xaxes
end

@testset "Autodiff" begin
include("autodiff_tests.jl")
end
Expand Down