Skip to content

Commit 87691d3

Browse files
committed
add test from 536
1 parent e75d8eb commit 87691d3

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
@@ -185,7 +185,21 @@ end
185185

186186
# And issue 407
187187
@test ForwardDiff.hessian(det, A) ForwardDiff.hessian(det2, A)
188+
end
189+
190+
@testset "branches in mul!" begin
191+
a, b = rand(3,3), rand(3,3)
188192

193+
# Issue 536, version with 3-arg *, Julia 1.7:
194+
@test ForwardDiff.derivative(x -> sum(x*a*b), 0.0) sum(a * b)
195+
196+
# version with just mul!
197+
dx = ForwardDiff.derivative(0.0) do x
198+
c = similar(a, typeof(x))
199+
mul!(c, a, b, x, false)
200+
sum(c)
201+
end
202+
@test dx sum(a * b)
189203
end
190204

191205
end # module

0 commit comments

Comments
 (0)