Automatic Differentiation
 
Loading...
Searching...
No Matches
reverse_pass_callback.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_FUNCTOR_REVERSE_PASS_CALLBACK_HPP
2#define STAN_MATH_REV_FUNCTOR_REVERSE_PASS_CALLBACK_HPP
3
5#include <new>
6
7namespace stan {
8namespace math {
9namespace internal {
10
11template <typename F>
14
16 F&& rev_functor)
17 : rev_functor_(std::forward<F>(rev_functor)) {
19 }
20
21 inline void chain() final { rev_functor_(); }
22 inline void set_zero_adjoint() final {}
23 inline void init_dependent() {}
24};
25
26} // namespace internal
27
39template <typename F>
41 // Captures such as fixed-size Eigen matrices can need more than the 8 byte
42 // alignment of `vari_base::operator new`.
44 ::new (ChainableStack::instance_->memalloc_.alloc(
45 sizeof(vari_t), alignof(vari_t))) vari_t(std::forward<F>(functor));
46}
47
48} // namespace math
49} // namespace stan
50
51#endif
Abstract base class that all vari_value and it's derived classes inherit.
Definition vari.hpp:28
#define STAN_STRONG_INLINE
#define STAN_HOT_PATH
void reverse_pass_callback(F &&functor)
Puts a callback on the autodiff stack to be called in reverse pass.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
STL namespace.
static thread_local AutodiffStackStorage * instance_
void chain() final
Apply the chain rule to this variable based on the variables on which it depends.