Skip to content

Commit

Permalink
test: add test for broadcast autodiff
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Dec 29, 2023
1 parent a8d416a commit 035e20a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/adjoints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ function loss6(x)
sum(abs2, Array(_prob.u0))
end

function loss7(x)
_x = VectorOfArray([x .* i for i in 1:5])
return sum(abs2, x .- 1)
end

x = float.(6:10)
loss(x)
@test Zygote.gradient(loss, x)[1] == ForwardDiff.gradient(loss, x)
Expand All @@ -45,3 +50,4 @@ loss(x)
@test Zygote.gradient(loss4, x)[1] == ForwardDiff.gradient(loss4, x)
@test Zygote.gradient(loss5, x)[1] == ForwardDiff.gradient(loss5, x)
@test Zygote.gradient(loss6, x)[1] == ForwardDiff.gradient(loss6, x)
@test Zygote.gradient(loss7, x)[1] == ForwardDiff.gradient(loss7, x)

0 comments on commit 035e20a

Please sign in to comment.