Skip to content

Commit 99184f7

Browse files
Apply suggestions from code review
Co-authored-by: Vaibhav Kumar Dixit <[email protected]>
1 parent 36646c4 commit 99184f7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ext/OptimizationEnzymeExt.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function Optimization.instantiate_function(f::OptimizationFunction{true}, x,
1919
res .= zero(eltype(res))
2020
Enzyme.autodiff(Enzyme.Reverse,
2121
Const(firstapply),
22+
Active,
2223
Const(f.f),
2324
Enzyme.Duplicated(θ, res),
2425
Const(p),
@@ -32,6 +33,7 @@ function Optimization.instantiate_function(f::OptimizationFunction{true}, x,
3233
function g(θ, bθ, f, p, args...)
3334
Enzyme.autodiff_deferred(Enzyme.Reverse,
3435
Const(firstapply),
36+
Active,
3537
Const(f),
3638
Enzyme.Duplicated(θ, bθ),
3739
Const(p),
@@ -65,6 +67,7 @@ function Optimization.instantiate_function(f::OptimizationFunction{true}, x,
6567
dx = zeros(length(x))
6668
Enzyme.autodiff_deferred(Enzyme.Reverse,
6769
firstapply,
70+
Active,
6871
f,
6972
Enzyme.Duplicated(x, dx),
7073
Const(p),
@@ -155,6 +158,7 @@ function Optimization.instantiate_function(f::OptimizationFunction{true},
155158
res .= zero(eltype(res))
156159
Enzyme.autodiff(Enzyme.Reverse,
157160
Const(firstapply),
161+
Active,
158162
Const(f.f),
159163
Enzyme.Duplicated(θ, res),
160164
Const(p),
@@ -197,7 +201,7 @@ function Optimization.instantiate_function(f::OptimizationFunction{true},
197201
if f.hv === nothing
198202
function f2(x, f, p, args...)
199203
dx = zeros(length(x))
200-
Enzyme.autodiff_deferred(Enzyme.Reverse, firstapply,
204+
Enzyme.autodiff_deferred(Enzyme.Reverse, firstapply, Active,
201205
f,
202206
Enzyme.Duplicated(x, dx),
203207
Const(p),

0 commit comments

Comments
 (0)