@@ -18,8 +18,8 @@ using Core: Vararg
18
18
end
19
19
20
20
function inner_grad (θ, bθ, f, p)
21
- Enzyme. autodiff (Enzyme. Reverse,
22
- firstapply,
21
+ Enzyme. autodiff_deferred (Enzyme. Reverse,
22
+ Const ( firstapply) ,
23
23
Active,
24
24
Const (f),
25
25
Enzyme. Duplicated (θ, bθ),
@@ -29,8 +29,9 @@ function inner_grad(θ, bθ, f, p)
29
29
end
30
30
31
31
function inner_grad_primal (θ, bθ, f, p)
32
- Enzyme. autodiff (Enzyme. ReverseWithPrimal,
33
- firstapply,
32
+ Enzyme. autodiff_deferred (Enzyme. ReverseWithPrimal,
33
+ Const (firstapply),
34
+ Active,
34
35
Const (f),
35
36
Enzyme. Duplicated (θ, bθ),
36
37
Const (p)
39
40
40
41
function hv_f2_alloc (x, f, p)
41
42
dx = Enzyme. make_zero (x)
42
- Enzyme. autodiff (Enzyme. Reverse,
43
- firstapply,
43
+ Enzyme. autodiff_deferred (Enzyme. Reverse,
44
+ Const (firstapply),
45
+ Active,
44
46
Const (f),
45
47
Enzyme. Duplicated (x, dx),
46
48
Const (p)
@@ -56,7 +58,7 @@ function inner_cons(x, fcons::Function, p::Union{SciMLBase.NullParameters, Nothi
56
58
end
57
59
58
60
function cons_f2 (x, dx, fcons, p, num_cons, i)
59
- Enzyme. autodiff (Enzyme. Reverse, inner_cons, Enzyme. Duplicated (x, dx),
61
+ Enzyme. autodiff_deferred (Enzyme. Reverse, Const ( inner_cons), Active , Enzyme. Duplicated (x, dx),
60
62
Const (fcons), Const (p), Const (num_cons), Const (i))
61
63
return nothing
62
64
end
@@ -68,8 +70,8 @@ function inner_cons_oop(
68
70
end
69
71
70
72
function cons_f2_oop (x, dx, fcons, p, i)
71
- Enzyme. autodiff (
72
- Enzyme. Reverse, inner_cons_oop, Enzyme. Duplicated (x, dx),
73
+ Enzyme. autodiff_deferred (
74
+ Enzyme. Reverse, Const ( inner_cons_oop), Active , Enzyme. Duplicated (x, dx),
73
75
Const (fcons), Const (p), Const (i))
74
76
return nothing
75
77
end
@@ -81,7 +83,7 @@ function lagrangian(x, _f::Function, cons::Function, p, λ, σ = one(eltype(x)))
81
83
end
82
84
83
85
function lag_grad (x, dx, lagrangian:: Function , _f:: Function , cons:: Function , p, σ, λ)
84
- Enzyme. autodiff (Enzyme. Reverse, lagrangian, Active, Enzyme. Duplicated (x, dx),
86
+ Enzyme. autodiff_deferred (Enzyme. Reverse, Const ( lagrangian) , Active, Enzyme. Duplicated (x, dx),
85
87
Const (_f), Const (cons), Const (p), Const (λ), Const (σ))
86
88
return nothing
87
89
end
@@ -185,7 +187,7 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{true}, x,
185
187
if hv == true && f. hv === nothing
186
188
function hv! (H, θ, v, p = p)
187
189
H .= Enzyme. autodiff (
188
- Enzyme. Forward, hv_f2_alloc, DuplicatedNoNeed, Duplicated (θ, v),
190
+ Enzyme. Forward, hv_f2_alloc, Duplicated (θ, v),
189
191
Const (f. f), Const (p)
190
192
)[1 ]
191
193
end
@@ -529,7 +531,7 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, x
529
531
for i in eachindex (Jaccache)
530
532
Enzyme. make_zero! (Jaccache[i])
531
533
end
532
- y, Jaccache = Enzyme. autodiff (Enzyme. Forward , f. cons, Duplicated,
534
+ Jaccache, y = Enzyme. autodiff (Enzyme. ForwardWithPrimal , f. cons, Duplicated,
533
535
BatchDuplicated (θ, seeds), Const (p))
534
536
if size (y, 1 ) == 1
535
537
return reduce (vcat, Jaccache)
0 commit comments