Skip to content

Commit 9c11d8a

Browse files
committed
🤖 Format .jl files
1 parent 10e6690 commit 9c11d8a

3 files changed

Lines changed: 24 additions & 12 deletions

File tree

src/enzyme.jl

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function EnzymeReverseADJacobian(
2323
return EnzymeReverseADJacobian()
2424
end
2525

26-
struct EnzymeReverseADHessian{T,F} <: ADBackend
26+
struct EnzymeReverseADHessian{T, F} <: ADBackend
2727
seed::Vector{T}
2828
Hv::Vector{T}
2929
f::F
@@ -383,7 +383,12 @@ end
383383

384384
function ADNLPModels.gradient(::EnzymeReverseADGradient, f, x)
385385
g = similar(x)
386-
Enzyme.autodiff(Enzyme.set_runtime_activity(Enzyme.Reverse), Enzyme.Const(f), Enzyme.Active, Enzyme.Duplicated(x, g))
386+
Enzyme.autodiff(
387+
Enzyme.set_runtime_activity(Enzyme.Reverse),
388+
Enzyme.Const(f),
389+
Enzyme.Active,
390+
Enzyme.Duplicated(x, g),
391+
)
387392
return g
388393
end
389394

@@ -505,7 +510,12 @@ end
505510
end
506511
_hvp!(
507512
Enzyme.DuplicatedNoNeed(b.grad, b.hvbuf),
508-
b.ℓ, b.xbuf, b.vbuf, b.ybuf, zero(eltype(x)), b.cx,
513+
b.ℓ,
514+
b.xbuf,
515+
b.vbuf,
516+
b.ybuf,
517+
zero(eltype(x)),
518+
b.cx,
509519
)
510520
copyto!(Hv, b.hvbuf)
511521
return Hv

test/enzyme.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,16 @@ _noop_ℓ(x, y, obj_weight, cx) = zero(eltype(x))
1818
# no constraints (ncon = 0). Fields: grad, hvbuf, xbuf, vbuf, cx, ybuf, f, c!, ℓ, ncon.
1919
function _make_enzyme_hvprod(n)
2020
ADNLPModels.EnzymeReverseADHvprod(
21-
zeros(n), zeros(n), zeros(n), zeros(n), zeros(0), zeros(0),
22-
identity, _noop_c!, _noop_ℓ, 0,
21+
zeros(n),
22+
zeros(n),
23+
zeros(n),
24+
zeros(n),
25+
zeros(0),
26+
zeros(0),
27+
identity,
28+
_noop_c!,
29+
_noop_ℓ,
30+
0,
2331
)
2432
end
2533

test/sparse_hessian.jl

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,7 @@ function sparse_hessian(backend, info, kw)
7171
n = length(x)
7272
sum(100 * (x[i + 1] - x[i]^2)^2 + (x[i] - 1)^2 for i = 1:(n - 1))
7373
end
74-
nlp = ADNLPModel(
75-
f,
76-
x0,
77-
hessian_backend = backend,
78-
name = "Extended Rosenbrock";
79-
kw...,
80-
)
74+
nlp = ADNLPModel(f, x0, hessian_backend = backend, name = "Extended Rosenbrock"; kw...)
8175
@test hess(nlp, x0) == T[802 -400 0 0; -400 1002 -400 0; 0 -400 1002 -400; 0 0 -400 200]
8276

8377
x = ones(T, 2)

0 commit comments

Comments
 (0)