1 #ifndef STAN__AGRAD__REV__VAR_STACK_HPP
2 #define STAN__AGRAD__REV__VAR_STACK_HPP
13 class chainable_alloc;
54 throw std::logic_error(
"empty_nested() must be true"
55 " before calling recover_memory()");
74 throw std::logic_error(
"empty_nested() must be false"
75 " before calling recover_memory_nested()");
static void recover_memory()
Recover memory used for all variables for reuse.
static void start_nested()
Record the current position so that recover_memory_nested() can find it.
memory::stack_alloc memalloc_
static size_t nested_size()
std::vector< size_t > nested_var_stack_sizes_
A chainable_alloc is an object which is constructed and destructed normally but the memory lifespan i...
std::vector< size_t > nested_var_alloc_stack_starts_
std::vector< chainable * > var_stack_
virtual ~chainable_alloc()
void start_nested()
Store current positions before doing nested operation so can recover back to start.
std::vector< chainable_alloc * > var_alloc_stack_
static void recover_memory_nested()
Recover only the memory used for the top nested call.
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.
std::vector< size_t > nested_var_nochain_stack_sizes_
void recover_all()
Recover all the memory used by the stack allocator.
std::vector< chainable * > var_nochain_stack_