Automatic Differentiation
 
Loading...
Searching...
No Matches
add.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_OPENCL_KERNELS_ADD_HPP
2#define STAN_MATH_OPENCL_KERNELS_ADD_HPP
3#ifdef STAN_OPENCL
4
8#include <string>
9
10namespace stan {
11namespace math {
12namespace opencl_kernels {
13
14// \cond
15static constexpr const char *add_batch_kernel_code = STRINGIFY(
16 // \endcond
32 __kernel void add_batch(__global double *B, __global double *A,
33 unsigned int rows, unsigned int cols,
34 unsigned int batch_size) {
35 const int i = get_global_id(0);
36 const int j = get_global_id(1);
37 if (i < rows && j < cols) {
38 double temp = 0.0;
39 for (int k = 0; k < batch_size; k++) {
40 temp += A_batch(i, j, k);
41 }
42 B(i, j) = temp;
43 }
44 }
45 // \cond
46);
47// \endcond
48
53 "add_batch", {indexing_helpers, add_batch_kernel_code});
54} // namespace opencl_kernels
55} // namespace math
56} // namespace stan
57#endif
58#endif
const kernel_cl< out_buffer, in_buffer, int, int, int > add_batch("add_batch", {indexing_helpers, add_batch_kernel_code})
See the docs for add_batch() .
int64_t cols(const T_x &x)
Returns the number of columns in the specified kernel generator expression.
Definition cols.hpp:21
int64_t rows(const T_x &x)
Returns the number of rows in the specified kernel generator expression.
Definition rows.hpp:22
static const std::string indexing_helpers
Defines helper macros for common matrix indexing operations.
Definition helpers.hpp:14
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
#define STRINGIFY(...)
Definition stringify.hpp:9
Creates functor for kernels.