Automatic Differentiation
 
Loading...
Searching...
No Matches
append_row.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_OPENCL_REV_APPEND_ROW_HPP
2#define STAN_MATH_OPENCL_REV_APPEND_ROW_HPP
3#ifdef STAN_OPENCL
4
14
15namespace stan {
16namespace math {
17
36template <typename T_a, typename T_b,
37 require_all_prim_or_rev_kernel_expression_t<T_a, T_b>* = nullptr,
38 require_any_var_t<T_a, T_b>* = nullptr,
39 require_any_not_stan_scalar_t<T_a, T_b>* = nullptr>
40inline var_value<matrix_cl<double>> append_row(T_a&& a, T_b&& b) {
41 arena_t<T_a> a_arena = std::forward<T_a>(a);
42 arena_t<T_b> b_arena = std::forward<T_b>(b);
43
44 return make_callback_var(
45 append_row(value_of(a_arena), value_of(b_arena)),
46 [a_arena, b_arena](const vari_value<matrix_cl<double>>& res) mutable {
48 adjoint_of(a_arena) += block_zero_based(
49 res.adj(), 0, 0, a_arena.rows(), a_arena.cols());
50 }
52 adjoint_of(b_arena) += block_zero_based(
53 res.adj(), a_arena.rows(), 0, b_arena.rows(), b_arena.cols());
54 }
55 });
56}
57
58} // namespace math
59} // namespace stan
60
61#endif
62#endif
Represents an arithmetic matrix on the OpenCL device.
Definition matrix_cl.hpp:47
auto block_zero_based(T &&a, int start_row, int start_col, int rows, int cols)
Block of a kernel generator expression.
auto append_row(Ta &&a, Tb &&b)
Stack the rows of the first argument on top of the second argument.
Definition append.hpp:183
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...
auto & adjoint_of(const T &x)
Returns a reference to a variable's adjoint.
T value_of(const fvar< T > &v)
Return the value of the specified variable.
Definition value_of.hpp:18
typename internal::arena_type_impl< std::decay_t< T > >::type arena_t
Determines a type that can be used in place of T that does any dynamic allocations on the AD stack.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Metaprogramming struct to detect whether a given type is constant in the mathematical sense (not the ...