Skip to content

Commit 537b76e

Browse files
authored
Stop tracking allocations of (J::LinearOperator)' (#129)
* separate line * trick codecov
1 parent 1c12b35 commit 537b76e

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/allocs_model.jl

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ function test_allocs_nlpmodels(nlp::AbstractNLPModel; linear_api = false, exclud
112112
J = jac_op!(nlp, x, Jv, Jtv)
113113
mul!(Jv, J, v)
114114
nlp_allocations[:jac_op_prod!] = @allocated mul!(Jv, J, v)
115-
mul!(Jtv, J', w)
116-
nlp_allocations[:jac_op_transpose_prod!] = @allocated mul!(Jtv, J', w)
115+
Jt = J'
116+
mul!(Jtv, Jt, w)
117+
nlp_allocations[:jac_op_transpose_prod!] = @allocated mul!(Jtv, Jt, w)
117118
end
118119

119120
for type in (:nln, :lin)
@@ -169,14 +170,16 @@ function test_allocs_nlpmodels(nlp::AbstractNLPModel; linear_api = false, exclud
169170
J = jac_lin_op!(nlp, x, Jv, Jtv)
170171
mul!(Jv, J, v)
171172
nlp_allocations[Symbol(:jac_lin_op_prod!)] = @allocated mul!(Jv, J, v)
172-
mul!(Jtv, J', w)
173-
nlp_allocations[Symbol(:jac_lin_op_transpose_prod!)] = @allocated mul!(Jtv, J', w)
173+
Jt = J'
174+
mul!(Jtv, Jt, w)
175+
nlp_allocations[Symbol(:jac_lin_op_transpose_prod!)] = @allocated mul!(Jtv, Jt, w)
174176
else
175177
J = jac_nln_op!(nlp, x, Jv, Jtv)
176178
mul!(Jv, J, v)
177179
nlp_allocations[Symbol(:jac_nln_op_prod!)] = @allocated mul!(Jv, J, v)
178-
mul!(Jtv, J', w)
179-
nlp_allocations[Symbol(:jac_nln_op_transpose_prod!)] = @allocated mul!(Jtv, J', w)
180+
Jt = J'
181+
mul!(Jtv, Jt, w)
182+
nlp_allocations[Symbol(:jac_nln_op_transpose_prod!)] = @allocated mul!(Jtv, Jt, w)
180183
end
181184
end
182185
end
@@ -286,8 +289,9 @@ function test_allocs_nlsmodels(nlp::AbstractNLSModel; exclude = [])
286289
J = jac_op_residual!(nlp, x, Jv, Jtv)
287290
mul!(Jv, J, v)
288291
nlp_allocations[:jac_op_residual_prod!] = @allocated mul!(Jv, J, v)
289-
mul!(Jtv, J', w)
290-
nlp_allocations[:jac_op_residual_transpose_prod!] = @allocated mul!(Jtv, J', w)
292+
Jt = J'
293+
mul!(Jtv, Jt, w)
294+
nlp_allocations[:jac_op_residual_transpose_prod!] = @allocated mul!(Jtv, Jt, w)
291295
end
292296
if !(hess_residual in exclude)
293297
rows = Vector{Int}(undef, nlp.nls_meta.nnzh)
@@ -410,7 +414,10 @@ end
410414
function test_zero_allocations(table::Dict, name::String = "Generic")
411415
@testset "Test 0-allocations of NLPModel API for $name" begin
412416
for k in keys(table)
413-
isnan(table[k]) || @test table[k] == 0
417+
if !isnan(table[k])
418+
(table[k] != 0) && @info "Allocation of $k is $(table[k])"
419+
@test table[k] == 0
420+
end
414421
end
415422
end
416423
end

0 commit comments

Comments
 (0)