Skip to content

Commit b0e4e04

Browse files
committed
Add allocation tests
1 parent 1970207 commit b0e4e04

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

test/Nonlinear/ReverseAD.jl

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,24 +153,18 @@ function test_objective_quadratic_multivariate_subexpressions()
153153
@test evaluator.backend.max_chunk == 2
154154
# The call of `_eval_hessian_inner` from `_eval_hessian` needs dynamic dispatch for `Val(chunk)` so it allocates.
155155
# We call directly `_eval_hessian_inner` to check that the rest does not allocates.
156-
@test @allocated MOI.Nonlinear.ReverseAD._eval_hessian_inner(evaluator.backend, evaluator.backend.objective, H, 1.0, 0, Val(2))
156+
@test 0 == @allocated MOI.Nonlinear.ReverseAD._eval_hessian_inner(evaluator.backend, evaluator.backend.objective, H, 1.0, 0, Val(2))
157157
@test MOI.hessian_lagrangian_structure(evaluator) ==
158158
[(1, 1), (2, 2), (2, 1)]
159159
H = [NaN, NaN, NaN]
160-
MOI.eval_hessian_lagrangian(evaluator, H, val, 1.5, Float64[])
160+
μ = Float64[]
161+
MOI.eval_hessian_lagrangian(evaluator, H, val, 1.5, μ)
161162
@test H == 1.5 .* [2.0, 2.0, 1.0]
162-
MOI.eval_hessian_lagrangian(evaluator, H, val, 1.5, Float64[])
163163
v = [0.3, 0.4]
164164
hv = [NaN, NaN]
165-
MOI.eval_hessian_lagrangian_product(
166-
evaluator,
167-
hv,
168-
[1.2, 2.3],
169-
v,
170-
1.5,
171-
Float64[],
172-
)
165+
MOI.eval_hessian_lagrangian_product(evaluator, hv, val, v, 1.5, μ)
173166
@test hv 1.5 .* [2 1; 1 2] * v
167+
@test 0 == @allocated MOI.eval_hessian_lagrangian_product(evaluator, hv, val, v, 1.5, μ)
174168
return
175169
end
176170

0 commit comments

Comments
 (0)