Automatic Differentiation
 
Loading...
Searching...
No Matches
rows_dot_self.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_OPENCL_REV_ROWS_DOT_SELF_HPP
2#define STAN_MATH_OPENCL_REV_ROWS_DOT_SELF_HPP
3#ifdef STAN_OPENCL
4
10
11namespace stan {
12namespace math {
13
20template <typename T,
21 require_all_kernel_expressions_and_none_scalar_t<T>* = nullptr>
23 return make_callback_var(
25 [v](const vari_value<matrix_cl<double>>& res) mutable {
26 v.adj() += elt_multiply(rowwise_broadcast(res.adj() * 2), value_of(v));
27 });
28}
29
30} // namespace math
31} // namespace stan
32
33#endif
34#endif
Represents an arithmetic matrix on the OpenCL device.
Definition matrix_cl.hpp:47
elt_multiply_< as_operation_cl_t< T_a >, as_operation_cl_t< T_b > > elt_multiply(T_a &&a, T_b &&b)
auto rowwise_broadcast(T &&a)
Broadcast an expression in rowwise dimmension.
auto rows_dot_self(T_a &&a)
Returns the dot product of each row of a matrix with itself.
var_value< plain_type_t< T > > make_callback_var(T &&value, F &&functor)
Creates a new var initialized with a callback_vari with a given value and reverse-pass callback funct...
T value_of(const fvar< T > &v)
Return the value of the specified variable.
Definition value_of.hpp:18
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...