Skip to content

Commit 526aa97

Browse files
committed
add test from 536
1 parent 2de3609 commit 526aa97

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/GradientTest.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,21 @@ end
193193

194194
# And issue 407
195195
@test ForwardDiff.hessian(det, A) ForwardDiff.hessian(det2, A)
196+
end
197+
198+
@testset "branches in mul!" begin
199+
a, b = rand(3,3), rand(3,3)
196200

201+
# Issue 536, version with 3-arg *, Julia 1.7:
202+
@test ForwardDiff.derivative(x -> sum(x*a*b), 0.0) sum(a * b)
203+
204+
# version with just mul!
205+
dx = ForwardDiff.derivative(0.0) do x
206+
c = similar(a, typeof(x))
207+
mul!(c, a, b, x, false)
208+
sum(c)
209+
end
210+
@test dx sum(a * b)
197211
end
198212

199213
end # module

0 commit comments

Comments
 (0)