-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replace @.
in hess_op
#416
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportBase: 99.49% // Head: 99.49% // No change to project coverage 👍
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
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
@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?