41
41
function hv_f2_alloc (x, f, p)
42
42
dx = Enzyme. make_zero (x)
43
43
Enzyme. autodiff_deferred (Enzyme. Reverse,
44
- firstapply,
44
+ Const ( firstapply) ,
45
45
Active,
46
46
Const (f),
47
47
Enzyme. Duplicated (x, dx),
@@ -58,7 +58,8 @@ function inner_cons(x, fcons::Function, p::Union{SciMLBase.NullParameters, Nothi
58
58
end
59
59
60
60
function cons_f2 (x, dx, fcons, p, num_cons, i)
61
- Enzyme. autodiff_deferred (Enzyme. Reverse, inner_cons, Active, Enzyme. Duplicated (x, dx),
61
+ Enzyme. autodiff_deferred (
62
+ Enzyme. Reverse, Const (inner_cons), Active, Enzyme. Duplicated (x, dx),
62
63
Const (fcons), Const (p), Const (num_cons), Const (i))
63
64
return nothing
64
65
end
71
72
72
73
function cons_f2_oop (x, dx, fcons, p, i)
73
74
Enzyme. autodiff_deferred (
74
- Enzyme. Reverse, inner_cons_oop, Active, Enzyme. Duplicated (x, dx),
75
+ Enzyme. Reverse, Const ( inner_cons_oop) , Active, Enzyme. Duplicated (x, dx),
75
76
Const (fcons), Const (p), Const (i))
76
77
return nothing
77
78
end
@@ -83,7 +84,8 @@ function lagrangian(x, _f::Function, cons::Function, p, λ, σ = one(eltype(x)))
83
84
end
84
85
85
86
function lag_grad (x, dx, lagrangian:: Function , _f:: Function , cons:: Function , p, σ, λ)
86
- Enzyme. autodiff_deferred (Enzyme. Reverse, lagrangian, Active, Enzyme. Duplicated (x, dx),
87
+ Enzyme. autodiff_deferred (
88
+ Enzyme. Reverse, Const (lagrangian), Active, Enzyme. Duplicated (x, dx),
87
89
Const (_f), Const (cons), Const (p), Const (λ), Const (σ))
88
90
return nothing
89
91
end
@@ -187,7 +189,7 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{true}, x,
187
189
if hv == true && f. hv === nothing
188
190
function hv! (H, θ, v, p = p)
189
191
H .= Enzyme. autodiff (
190
- Enzyme. Forward, hv_f2_alloc, DuplicatedNoNeed, Duplicated (θ, v),
192
+ Enzyme. Forward, hv_f2_alloc, Duplicated (θ, v),
191
193
Const (f. f), Const (p)
192
194
)[1 ]
193
195
end
@@ -531,7 +533,7 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, x
531
533
for i in eachindex (Jaccache)
532
534
Enzyme. make_zero! (Jaccache[i])
533
535
end
534
- y, Jaccache = Enzyme. autodiff (Enzyme. Forward , f. cons, Duplicated,
536
+ Jaccache, y = Enzyme. autodiff (Enzyme. ForwardWithPrimal , f. cons, Duplicated,
535
537
BatchDuplicated (θ, seeds), Const (p))
536
538
if size (y, 1 ) == 1
537
539
return reduce (vcat, Jaccache)
0 commit comments