Skip to content

Commit

Permalink
fix #422: nightly failures due to instabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
simeonschaub committed Jun 2, 2021
1 parent f46d7cb commit 7d18f6f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/rulesets/LinearAlgebra/factorization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,15 @@ end
= rand_tangent(X)
F = eigen!(copy(X))
F_fwd, Ḟ_ad = frule((ZeroTangent(), copy(Ẋ)), eigen!, copy(X))
@test F_fwd == F
test_approx(F_fwd, F)
@test Ḟ_ad isa Tangent{typeof(F)}
Ḟ_fd = jvp(_fdm, asnt eigen! copy, (X, Ẋ))
@test Ḟ_ad.values Ḟ_fd.values
@test Ḟ_ad.vectors Ḟ_fd.vectors
@test frule((ZeroTangent(), ZeroTangent()), eigen!, copy(X)) == (F, ZeroTangent())
test_approx(
frule((ZeroTangent(), ZeroTangent()), eigen!, copy(X)),
(F, ZeroTangent()),
)

@testset "tangents are real when outputs are" begin
# hermitian matrices have real eigenvalues and, when real, real eigenvectors
Expand All @@ -179,7 +182,7 @@ end
λ̄ = rand_tangent(F.values)
CT = Tangent{typeof(F)}
F_rev, back = rrule(eigen, X)
@test F_rev == F
test_approx(F_rev, F)
# NOTE: eigen is not type-stable, so neither are is its rrule
_, X̄_values_ad = @inferred back(CT(values = λ̄))
@test X̄_values_ad j′vp(_fdm, x -> eigen(x).values, λ̄, X)[1]
Expand Down

0 comments on commit 7d18f6f

Please sign in to comment.