68
68
jac_prototype = nothing ,
69
69
chunksize = nothing ,
70
70
dx = sparsity === nothing && jac_prototype === nothing ? nothing : copy (x)) # if dx is nothing, we will estimate dx at the cost of a function call
71
- @show typeof (x)
72
71
73
- if sparsity === nothing && jac_prototype === nothing || ! ArrayInterface . ismutable (x)
72
+ if sparsity === nothing && jac_prototype === nothing
74
73
cfg = chunksize === nothing ? ForwardDiff. JacobianConfig (f, x) : ForwardDiff. JacobianConfig (f, x, ForwardDiff. Chunk (getsize (chunksize)))
75
74
return ForwardDiff. jacobian (f, x, cfg)
76
75
end
77
76
if dx isa Nothing
78
77
dx = f (x)
79
78
end
80
- @show " Line 80"
81
79
forwarddiff_color_jacobian (f,x,ForwardColorJacCache (f,x,chunksize,dx= dx,colorvec= colorvec,sparsity= sparsity),jac_prototype)
82
80
end
83
81
88
86
jac_prototype = nothing ,
89
87
chunksize = nothing ,
90
88
dx = similar (x, size (J, 1 ))) # dx kwarg can be used to avoid re-allocating dx every time
91
- if sparsity === nothing && jac_prototype === nothing || ! ArrayInterface . ismutable (x)
89
+ if sparsity === nothing && jac_prototype === nothing
92
90
cfg = chunksize === nothing ? ForwardDiff. JacobianConfig (f, x) : ForwardDiff. JacobianConfig (f, x, ForwardDiff. Chunk (getsize (chunksize)))
93
91
return ForwardDiff. jacobian (f, x, cfg)
94
92
end
95
- @show " Line 95"
96
- forwarddiff_color_jacobian (J,f,x,ForwardColorJacCache (f,x,chunksize,dx= dx,colorvec= colorvec,sparsity= sparsity),jac_prototype)
93
+ forwarddiff_color_jacobian (J,f,x,ForwardColorJacCache (f,x,chunksize,dx= dx,colorvec= colorvec,sparsity= sparsity))
97
94
end
98
95
99
96
function forwarddiff_color_jacobian (f,x:: AbstractArray{<:Number} ,jac_cache:: ForwardColorJacCache ,jac_prototype= nothing )
@@ -103,13 +100,10 @@ function forwarddiff_color_jacobian(f,x::AbstractArray{<:Number},jac_cache::Forw
103
100
104
101
J = jac_prototype isa Nothing ? (sparsity isa Nothing ? false .* vec (dx) .* vecx' : zeros (eltype (x),size (sparsity))) : zero (jac_prototype)
105
102
106
- @show typeof (J)
107
103
if ArrayInterface. ismutable (J) # Whenever J is mutable, we mutate it to avoid allocations
108
- @show " Line 108"
109
- forwarddiff_color_jacobian (J, f, x, jac_cache, jac_prototype)
104
+ forwarddiff_color_jacobian (J, f, x, jac_cache)
110
105
else
111
- @show " Line 111"
112
- forwarddiff_color_jacobian_immutable (J, f, x, jac_cache, jac_prototype)
106
+ forwarddiff_color_jacobian_immutable (J, f, x, jac_cache)
113
107
end
114
108
end
115
109
0 commit comments