Skip to content

Commit 7db3a5f

Browse files
committed
Copy G_arr back into G when G is not an Array in fgh!
1 parent e067321 commit 7db3a5f

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

lib/OptimizationBase/ext/OptimizationEnzymeExt.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ function OptimizationBase.instantiate_function(
196196
vdbθ = Tuple(zeros(eltype(θ), length(θ)) for i in eachindex(θ))
197197
θ_arr = θ isa Array ? θ : Array(θ)
198198
G_arr = G isa Array ? G : Array(G)
199+
Enzyme.make_zero!(G_arr)
199200

200201
Enzyme.autodiff(
201202
fmode,
@@ -207,6 +208,10 @@ function OptimizationBase.instantiate_function(
207208
Const(p)
208209
)
209210

211+
if G !== G_arr
212+
G .= G_arr
213+
end
214+
210215
for i in eachindex(θ)
211216
H[i, :] .= vdbθ[i]
212217
end

0 commit comments

Comments
 (0)