@@ -22,6 +22,9 @@ __max_tdir(a, b, x0, x1) = ifelse(x1 > x0, max(a, b), min(a, b))
22
22
__standard_tag (:: Nothing , f:: F , x:: AbstractArray{T} ) where {F, T} = ForwardDiff. Tag (f, T)
23
23
__standard_tag (tag:: ForwardDiff.Tag , f:: F , x:: AbstractArray{T} ) where {F, T} = tag
24
24
__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)
25
28
26
29
__pick_forwarddiff_chunk (x) = ForwardDiff. Chunk (length (x))
27
30
function __pick_forwarddiff_chunk (x:: StaticArray )
@@ -40,7 +43,7 @@ function __get_jacobian_config(ad::AutoForwardDiff{CS}, f::F, x) where {F, CS}
40
43
end
41
44
function __get_jacobian_config (ad:: AutoForwardDiff{CS} , f!:: F , y, x) where {F, CS}
42
45
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)
44
47
return ForwardDiff. JacobianConfig (f!, y, x, ck, tag)
45
48
end
46
49
@@ -76,7 +79,7 @@ function value_and_jacobian(ad, f::F, y, x::X, p, cache; J = nothing) where {F,
76
79
return y, J
77
80
elseif ad isa AutoForwardDiff
78
81
res = DiffResults. DiffResult (y, J)
79
- ForwardDiff. jacobian! (res, _f, y, x, cache)
82
+ ForwardDiff. jacobian! (res, _f, y, x, cache, Val ( false ) )
80
83
return DiffResults. value (res), DiffResults. jacobian (res)
81
84
elseif ad isa AutoFiniteDiff
82
85
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,
95
98
elseif ad isa AutoForwardDiff
96
99
if ArrayInterface. can_setindex (x)
97
100
res = DiffResults. DiffResult (y, J)
98
- ForwardDiff. jacobian! (res, _f, x, cache)
101
+ ForwardDiff. jacobian! (res, _f, x, cache, Val ( false ) )
99
102
return DiffResults. value (res), DiffResults. jacobian (res)
100
103
else
101
- J_fd = ForwardDiff. jacobian (_f, x, cache)
104
+ J_fd = ForwardDiff. jacobian (_f, x, cache, Val ( false ) )
102
105
return _f (x), J_fd
103
106
end
104
107
elseif ad isa AutoFiniteDiff
0 commit comments