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
6namespace stan {
7namespace math {
8namespace internal {
9
10template <typename F>
13
14 explicit reverse_pass_callback_vari(F&& rev_functor)
15 : rev_functor_(std::forward<F>(rev_functor)) {
17 }
18
19 inline void chain() final { rev_functor_(); }
20 inline void set_zero_adjoint() final {}
21 inline void init_dependent() {}
22};
23
24} // namespace internal
25
37template <typename F>
38inline void reverse_pass_callback(F&& functor) {
39 new internal::reverse_pass_callback_vari<F>(std::forward<F>(functor));
40}
41
42} // namespace math
43} // namespace stan
44
45#endif
Abstract base class that all vari_value and it's derived classes inherit.
Definition vari.hpp:28
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 ...
Definition fvar.hpp:9
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.