Skip to content

Commit

Permalink
Merge #934
Browse files Browse the repository at this point in the history
934: Fix \ for Cholesky r=DhairyaLGandhi a=devmotion

This PR fixes #932 and includes the MWE mentioned in the issue.

Co-authored-by: David Widmann <[email protected]>
  • Loading branch information
bors[bot] and devmotion authored Mar 28, 2021
2 parents 56f4118 + 71b5be1 commit 4b7e70d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ end
Y, back = Zygote.pullback((U, B)->U \ (U' \ B), A.U, B)
return Y, function(Ȳ)
Ā_factors, B̄ = back(Ȳ)
return ((uplo=nothing, status=nothing, factors=Ā_factors), B̄)
return ((uplo=nothing, info=nothing, factors=Ā_factors), B̄)
end
end

Expand Down
6 changes: 6 additions & 0 deletions test/gradcheck.jl
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,12 @@ end
@test Zygote.pullback(g, X)[2]((factors=LowerTriangular(X),)) ==
Zygote.pullback(g, X)[2]((factors=Matrix(LowerTriangular(X)),))
@test_throws PosDefException Zygote.pullback(X -> cholesky(X, check = false), X)[2]((factors=X,))

# https://github.com/FluxML/Zygote.jl/issues/932
@test gradcheck(rand(5, 5), rand(5)) do A, x
C = cholesky(Symmetric(A' * A + I))
return sum(C \ x) + logdet(C)
end
end
end

Expand Down

0 comments on commit 4b7e70d

Please sign in to comment.