@@ -22,6 +22,9 @@ __max_tdir(a, b, x0, x1) = ifelse(x1 > x0, max(a, b), min(a, b))
2222__standard_tag (:: Nothing , f:: F , x:: AbstractArray{T} ) where {F, T} = ForwardDiff. Tag (f, T)
2323__standard_tag (tag:: ForwardDiff.Tag , f:: F , x:: AbstractArray{T} ) where {F, T} = tag
2424__standard_tag (tag, f:: F , x:: AbstractArray{T} ) where {F, T} = ForwardDiff. Tag (tag, T)
25+ __standard_tag (:: Nothing , f:: F , x:: T ) where {F, T <: Number } = ForwardDiff. Tag (f, T)
26+ __standard_tag (tag:: ForwardDiff.Tag , f:: F , x:: T ) where {F, T <: Number } = tag
27+ __standard_tag (tag, f:: F , x:: T ) where {F, T <: Number } = ForwardDiff. Tag (tag, T)
2528
2629__pick_forwarddiff_chunk (x) = ForwardDiff. Chunk (length (x))
2730function __pick_forwarddiff_chunk (x:: StaticArray )
@@ -40,7 +43,7 @@ function __get_jacobian_config(ad::AutoForwardDiff{CS}, f::F, x) where {F, CS}
4043end
4144function __get_jacobian_config (ad:: AutoForwardDiff{CS} , f!:: F , y, x) where {F, CS}
4245 ck = (CS === nothing || CS ≤ 0 ) ? __pick_forwarddiff_chunk (x) : ForwardDiff. Chunk {CS} ()
43- tag = __standard_tag (ad. tag, f, x)
46+ tag = __standard_tag (ad. tag, f! , x)
4447 return ForwardDiff. JacobianConfig (f!, y, x, ck, tag)
4548end
4649
@@ -76,7 +79,7 @@ function value_and_jacobian(ad, f::F, y, x::X, p, cache; J = nothing) where {F,
7679 return y, J
7780 elseif ad isa AutoForwardDiff
7881 res = DiffResults. DiffResult (y, J)
79- ForwardDiff. jacobian! (res, _f, y, x, cache)
82+ ForwardDiff. jacobian! (res, _f, y, x, cache, Val ( false ) )
8083 return DiffResults. value (res), DiffResults. jacobian (res)
8184 elseif ad isa AutoFiniteDiff
8285 FiniteDiff. finite_difference_jacobian! (J, _f, x, cache)
@@ -95,10 +98,10 @@ function value_and_jacobian(ad, f::F, y, x::X, p, cache; J = nothing) where {F,
9598 elseif ad isa AutoForwardDiff
9699 if ArrayInterface. can_setindex (x)
97100 res = DiffResults. DiffResult (y, J)
98- ForwardDiff. jacobian! (res, _f, x, cache)
101+ ForwardDiff. jacobian! (res, _f, x, cache, Val ( false ) )
99102 return DiffResults. value (res), DiffResults. jacobian (res)
100103 else
101- J_fd = ForwardDiff. jacobian (_f, x, cache)
104+ J_fd = ForwardDiff. jacobian (_f, x, cache, Val ( false ) )
102105 return _f (x), J_fd
103106 end
104107 elseif ad isa AutoFiniteDiff
0 commit comments