1
- struct SimpleNonlinearSolveTag end
2
-
3
- function ForwardDiff. checktag (:: Type{<:ForwardDiff.Tag{<:SimpleNonlinearSolveTag, <:T}} ,
4
- f:: F , x:: AbstractArray{T} ) where {T, F}
5
- return true
6
- end
7
-
8
1
"""
9
2
__prevfloat_tdir(x, x0, x1)
10
3
@@ -26,9 +19,9 @@ Return the maximum of `a` and `b` if `x1 > x0`, otherwise return the minimum.
26
19
"""
27
20
__max_tdir (a, b, x0, x1) = ifelse (x1 > x0, max (a, b), min (a, b))
28
21
29
- __standard_tag (:: Nothing , x) = ForwardDiff. Tag (SimpleNonlinearSolveTag (), eltype (x) )
30
- __standard_tag (tag:: ForwardDiff.Tag , _) = tag
31
- __standard_tag (tag, x) = ForwardDiff. Tag (tag, eltype (x) )
22
+ __standard_tag (:: Nothing , f :: F , x :: AbstractArray{T} ) where {F, T} = ForwardDiff. Tag (f, T )
23
+ __standard_tag (tag:: ForwardDiff.Tag , f :: F , x :: AbstractArray{T} ) where {F, T} = tag
24
+ __standard_tag (tag, f :: F , x :: AbstractArray{T} ) where {F, T} = ForwardDiff. Tag (tag, T )
32
25
33
26
__pick_forwarddiff_chunk (x) = ForwardDiff. Chunk (length (x))
34
27
function __pick_forwarddiff_chunk (x:: StaticArray )
42
35
43
36
function __get_jacobian_config (ad:: AutoForwardDiff{CS} , f:: F , x) where {F, CS}
44
37
ck = (CS === nothing || CS ≤ 0 ) ? __pick_forwarddiff_chunk (x) : ForwardDiff. Chunk {CS} ()
45
- tag = __standard_tag (ad. tag, x)
38
+ tag = __standard_tag (ad. tag, f, x)
46
39
return __forwarddiff_jacobian_config (f, x, ck, tag)
47
40
end
48
41
function __get_jacobian_config (ad:: AutoForwardDiff{CS} , f!:: F , y, x) where {F, CS}
49
42
ck = (CS === nothing || CS ≤ 0 ) ? __pick_forwarddiff_chunk (x) : ForwardDiff. Chunk {CS} ()
50
- tag = __standard_tag (ad. tag, x)
43
+ tag = __standard_tag (ad. tag, f, x)
51
44
return ForwardDiff. JacobianConfig (f!, y, x, ck, tag)
52
45
end
53
46
@@ -127,12 +120,12 @@ function value_and_jacobian(ad, f::F, y, x::Number, p, cache; J = nothing) where
127
120
if DiffEqBase. has_jac (f)
128
121
return f (x, p), f. jac (x, p)
129
122
elseif ad isa AutoForwardDiff
130
- T = typeof (__standard_tag (ad. tag, x))
123
+ T = typeof (__standard_tag (ad. tag, f, x))
131
124
out = f (ForwardDiff. Dual {T} (x, one (x)), p)
132
125
return ForwardDiff. value (out), ForwardDiff. extract_derivative (T, out)
133
126
elseif ad isa AutoPolyesterForwardDiff
134
127
# Just use ForwardDiff
135
- T = typeof (__standard_tag (nothing , x))
128
+ T = typeof (__standard_tag (nothing , f, x))
136
129
out = f (ForwardDiff. Dual {T} (x, one (x)), p)
137
130
return ForwardDiff. value (out), ForwardDiff. extract_derivative (T, out)
138
131
elseif ad isa AutoFiniteDiff
0 commit comments