Skip to content

Commit

Permalink
Clean up var memory in laplace_sample
Browse files Browse the repository at this point in the history
  • Loading branch information
WardBrian committed Dec 12, 2024
1 parent f4fb7cb commit dc654e0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/stan/services/optimize/laplace_sample.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ void laplace_sample(const Model& model, const Eigen::VectorXd& theta_hat,

double log_p;
if (calculate_lp) {
// clean up created vars after scope exit
stan::math::nested_rev_autodiff stack;
log_p = log_density_fun(unc_draw).val();
} else {
log_p = std::numeric_limits<double>::quiet_NaN();
Expand Down

0 comments on commit dc654e0

Please sign in to comment.