Skip to content

Commit

Permalink
fix tests and Zygote backend
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszbaran committed Sep 20, 2021
1 parent 7849fc0 commit 1ed46db
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/differentiation/zygote.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
struct ZygoteDiffBackend <: AbstractDiffBackend end

function Manifolds._gradient(f, p, ::ZygoteDiffBackend)
return Zygote.gradient(f, p)
return Zygote.gradient(f, p)[1]
end

function Manifolds._gradient!(f, X, p, ::ZygoteDiffBackend)
return Zygote.gradient!(X, f, p)
return copyto!(X, Zygote.gradient(f, p)[1])
end

push!(Manifolds._diff_backends, ZygoteDiffBackend())
1 change: 1 addition & 0 deletions test/differentiation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ using LinearAlgebra: Diagonal, dot
@test isapprox(X, [1.0, 0.0])
end
@testset for backend in [fd51, fwd_diff, finite_diff, reverse_diff, zygote_diff]
diff_backend!(backend)
X = [-1.0, -1.0]
@test _gradient(f1, [1.0, -1.0]) [1.0, -2.0]
@test _gradient!(f1, X, [1.0, -1.0]) === X
Expand Down

0 comments on commit 1ed46db

Please sign in to comment.