-
Notifications
You must be signed in to change notification settings - Fork 14
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
Remove allocations in callbacks #230
Conversation
- split slack from variable explicitly - remove all allocations in callbacks
Codecov Report
@@ Coverage Diff @@
## master #230 +/- ##
==========================================
- Coverage 74.31% 74.29% -0.03%
==========================================
Files 38 38
Lines 3703 3727 +24
==========================================
+ Hits 2752 2769 +17
- Misses 951 958 +7
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
4e89350
to
dbef23c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, @frapac! It overall looks great! I only have a few comments
x_nlpmodel = _madnlp_unsafe_wrap(x, get_nvar(nlp)) | ||
hess_nlpmodel = _madnlp_unsafe_wrap(hess, get_nnzh(nlp.meta)) | ||
scale = (get_minimize(nlp) ? one(T) : -one(T)) | ||
scale *= (is_resto ? zero(T) : solver.obj_scale[]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scale = is_resto ? zero(T) : get_minimize(nlp) ? one(T) : -one(T)
@test n_allocs == 0 | ||
n_allocs = @allocated MadNLP.eval_lag_hess_wrapper!(solver, kkt, x, solver.y) | ||
@test n_allocs == 0 | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is nice! maybe in the future we can do it for the whole solver level
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree! we should at least apply the same test on the linear solver wrapper.
@@ -7,6 +7,7 @@ Implement the [`AbstractReducedKKTSystem`](@ref) in sparse COO format. | |||
""" | |||
struct SparseKKTSystem{T, VT, MT} <: AbstractReducedKKTSystem{T, VT, MT} | |||
hess::VT | |||
jac_callback::VT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this do?
PrimalVector
abstraction to remove the need to use_madnlp_unsafe_wrapper
x
(without the slack)