Skip to content

Commit

Permalink
Move A \ B rule test
Browse files Browse the repository at this point in the history
  • Loading branch information
jgreener64 committed Oct 30, 2023
1 parent 7d55c2e commit d623661
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
22 changes: 22 additions & 0 deletions test/internal_rules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,26 @@ using Test
@test autodiff(Reverse, f2, Active, Active(2.0))[1][1] == -3
end

@testset "Linear Solve" begin
A = Float64[2 3; 5 7]
dA = zero(A)
b = Float64[11, 13]
db = zero(b)

forward, pullback = Enzyme.autodiff_thunk(ReverseSplitNoPrimal, Const{typeof(\)}, Duplicated, Duplicated{typeof(A)}, Duplicated{typeof(b)})

tape, primal, shadow = forward(Const(\), Duplicated(A, dA), Duplicated(b, db))

dy = Float64[17, 19]
copyto!(shadow, dy)

pullback(Const(\), Duplicated(A, dA), Duplicated(b, db), tape)

z = transpose(A) \ dy

y = A \ b
@test dA (-z * transpose(y))
@test db z
end

end # InternalRules
22 changes: 0 additions & 22 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2490,25 +2490,3 @@ end
@test autodiff(Forward, f9, Duplicated(2.0, 1.0))[1] == 1.2
end
end

@testset "Linear Solve" begin
A = Float64[2 3; 5 7]
dA = zero(A)
b = Float64[11, 13]
db = zero(b)

forward, pullback = Enzyme.autodiff_thunk(ReverseSplitNoPrimal, Const{typeof(\)}, Duplicated, Duplicated{typeof(A)}, Duplicated{typeof(b)})

tape, primal, shadow = forward(Const(\), Duplicated(A, dA), Duplicated(b, db))

dy = Float64[17, 19]
copyto!(shadow, dy)

pullback(Const(\), Duplicated(A, dA), Duplicated(b, db), tape)

z = transpose(A) \ dy

y = A \ b
@test dA (-z * transpose(y))
@test db z
end

0 comments on commit d623661

Please sign in to comment.