Automatic Differentiation
 
Loading...
Searching...
No Matches
recover_memory_nested.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_CORE_RECOVER_MEMORY_NESTED_HPP
2#define STAN_MATH_REV_CORE_RECOVER_MEMORY_NESTED_HPP
3
7#include <stdexcept>
8
9namespace stan {
10namespace math {
11
23static inline void recover_memory_nested() {
24 if (empty_nested()) {
25 throw std::logic_error(
26 "empty_nested() must be false"
27 " before calling recover_memory_nested()");
28 }
29
31 ChainableStack::instance_->nested_var_stack_sizes_.back());
33
35 ChainableStack::instance_->nested_var_nochain_stack_sizes_.back());
37
38 for (size_t i
39 = ChainableStack::instance_->nested_var_alloc_stack_starts_.back();
42 }
44 ChainableStack::instance_->nested_var_alloc_stack_starts_.back());
46
48}
49
50} // namespace math
51} // namespace stan
52#endif
void recover_nested()
recover memory back to the last start_nested call.
static bool empty_nested()
Return true if there is no nested autodiff being executed.
static void recover_memory_nested()
Recover only the memory used for the top nested call.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
static thread_local AutodiffStackStorage * instance_