1#ifndef STAN_MATH_REV_CORE_SCOPED_CHAINABLESTACK_HPP
2#define STAN_MATH_REV_CORE_SCOPED_CHAINABLESTACK_HPP
43 throw std::logic_error{
"Cannot recurse same instance scoped stacks."};
67 template <
typename F,
typename... Args>
68 decltype(
auto)
execute(F&& f, Args&&... args) {
70 return std::forward<F>(f)(std::forward<Args>(args)...);
std::mutex local_stack_mutex_
ScopedChainableStack()=default
decltype(auto) execute(F &&f, Args &&... args)
Execute in the current thread a function and write the AD tape to local_stack_ of this instance.
ScopedChainableStack & operator=(const ScopedChainableStack &)=delete
ScopedChainableStack(const ScopedChainableStack &)=delete
ChainableStack::AutodiffStackStorage local_stack_
The AD tape of reverse mode AD is by default stored globally within the process (or thread).
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
static thread_local AutodiffStackStorage * instance_
This struct always provides access to the autodiff stack using the singleton pattern.
ScopedChainableStack & scoped_stack_
activate_scope(ScopedChainableStack &scoped_stack)
ChainableStack::AutodiffStackStorage * parent_stack_