Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #416 +/- ##
=======================================
Coverage 99.49% 99.49%
=======================================
Files 13 13
Lines 786 786
=======================================
Hits 782 782
Misses 4 4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@tmigot Can you try this function to see if it allocates please. function hess_op!(
nlp::AbstractNLPModel,
x::AbstractVector,
Hv::AbstractVector,
obj_weight::Real = one(eltype(x)),
)
@lencheck nlp.meta.nvar x Hv
prod = (res, v) -> hprod!(nlp, x, v, res; obj_weight = obj_weight)
return LinearOperator{eltype(x)}(nlp.meta.nvar, nlp.meta.nvar, true, true, prod, prod, prod)
end |
|
I am not sure to see which vector we allocate there |
|
The creation of a linear operator structure just allocates maybe and it can't be avoided. |
|
Hm, not sure why my link didn't work. I mean that hprod!() without the multipliers calls hprod!() with multipliers by allocating a vector of zero multipliers: https://github.com/JuliaSmoothOptimizers/NLPModels.jl/blob/main/src/nlp/api.jl#L1141. Could that be it? |
That's probably true. And in fact I would expect |
You are right, this allocates in general. But not here as we now redefine |
Okay, but still what is strange is that computing a product |
|
Ok. Did you confirm that https://github.com/JuliaSmoothOptimizers/NLPModelsTest.jl/blob/32ff072119733adc0c8637c2cc8380d108108939/src/nlp/problems/brownden.jl#L107 does not allocate? |
Yes, I updated JuliaSmoothOptimizers/NLPModelsTest.jl#60 (comment) |
|
All the allocations are in LinearOperators.jl. using NLPModelsTest
nlp = eval(Meta.parse(NLPModelsTest.nlp_problems[1]))()
test_allocs_nlpmodels(nlp)
using Profile, PProf
Profile.Allocs.clear()
Profile.Allocs.@profile sample_rate=1 test_allocs_nlpmodels(nlp)
PProf.Allocs.pprof(from_c = false) |
I would say that those allocations are somewhat expected. This is the reason why I think |
returns
and after this PR, it returns
We can do the same for
jac_op,jac_lin_op, andjac_nln_op.@geoffroyleconte @amontoison @dpo @abelsiqueira I am slightly surprised the
hess_op!allocates and using the resulting linear operator for products also allocates. Any idea, where this is coming from? And, can we improve?