1#ifndef STAN_MATH_OPENCL_PRIM_ORDERED_LOGISTIC_LPMF_HPP 
    2#define STAN_MATH_OPENCL_PRIM_ORDERED_LOGISTIC_LPMF_HPP 
   67template <
bool propto, 
typename T_y_cl, 
typename T_loc_cl, 
typename T_cuts_cl,
 
   69                                                      T_cuts_cl>* = 
nullptr>
 
   71    const T_y_cl& y, 
const T_loc_cl& lambda, 
const T_cuts_cl& cuts) {
 
   73  static constexpr const char* function = 
"ordered_logistic_lpmf(OpenCL)";
 
   80  int N_instances = 
max_size(y, lambda);
 
   81  int N_classes = cuts.rows() + 1;
 
   82  int N_cut_sets = cuts.cols();
 
   86                     "Number of cutpoint vectors ", N_cut_sets);
 
   88  if (N_instances == 0 || N_classes == 1) {
 
   97    check_cl(function, 
"Cuts", cuts_head, 
"ordered and finite")
 
   99  } 
else if (N_classes == 1) {
 
  114  const int wgs = (N_instances + local_size - 1) / local_size;
 
  116  bool need_lambda_derivative = is_autodiff_v<T_loc_cl>;
 
  117  bool need_cuts_derivative = is_autodiff_v<T_cuts_cl>;
 
  118  bool need_broadcasting = N_cut_sets == 1 && N_instances != 1;
 
  121                                         need_lambda_derivative ? 1 : 0);
 
  124      need_cuts_derivative ? (need_broadcasting ? wgs : N_cut_sets) : 0);
 
  128        cl::NDRange(local_size * wgs), cl::NDRange(local_size), logp_cl,
 
  129        lambda_derivative_cl, cuts_derivative_cl, y_val_cl, lambda_val,
 
  130        cuts_val, N_instances, N_classes, is_y_vector, !need_broadcasting,
 
  131        need_lambda_derivative, need_cuts_derivative);
 
  132  } 
catch (
const cl::Error& 
e) {
 
  138  if (!std::isfinite(logp)) {
 
  140                     "between 0 and number of classes"),
 
  141            check_cl(function, 
"lambda vector", lambda_val, 
"finite"))
 
  142        = 
expressions(y_val >= 1 && y_val <= 
static_cast<int>(N_classes),
 
  147  if constexpr (is_autodiff_v<T_loc_cl>) {
 
  148    partials<0>(ops_partials) = lambda_derivative_cl;
 
  150  if constexpr (is_autodiff_v<T_cuts_cl>) {
 
  151    if (need_broadcasting) {
 
  152      partials<1>(ops_partials) = 
rowwise_sum(cuts_derivative_cl);
 
  154      partials<1>(ops_partials) = std::move(cuts_derivative_cl);
 
  157  return ops_partials.build(logp);
 
Represents an arithmetic matrix on the OpenCL device.
 
void check_opencl_error(const char *function, const cl::Error &e)
Throws the domain error with specifying the OpenCL error that occurred.
 
isfinite_< as_operation_cl_t< T > > isfinite(T &&a)
 
auto check_cl(const char *function, const char *var_name, T &&y, const char *must_be)
Constructs a check on opencl matrix or expression.
 
auto block_zero_based(T &&a, int start_row, int start_col, int rows, int cols)
Block of a kernel generator expression.
 
results_cl< T_results... > results(T_results &&... results)
Deduces types for constructing results_cl object.
 
auto rowwise_sum(T &&a)
Rowwise sum reduction of a kernel generator expression.
 
expressions_cl< T_expressions... > expressions(T_expressions &&... expressions)
Deduces types for constructing expressions_cl object.
 
const kernel_cl< out_buffer, out_buffer, out_buffer, in_buffer, in_buffer, in_buffer, int, int, int, int, int, int > ordered_logistic("ordered_logistic", {log1p_exp_device_function, log1m_exp_device_function, inv_logit_device_function, ordered_logistic_kernel_code}, {{"REDUCTION_STEP_SIZE", 4}, {"LOCAL_SIZE_", 64}})
See the docs for ordered_logistic() .
 
matrix_cl< scalar_type_t< T > > to_matrix_cl(T &&src)
Copies the source Eigen matrix, std::vector or scalar to the destination matrix that is stored on the...
 
return_type_t< T_y_cl, T_loc_cl, T_cuts_cl > ordered_logistic_lpmf(const T_y_cl &y, const T_loc_cl &lambda, const T_cuts_cl &cuts)
Returns the (natural) log probability of the specified array of integers given the vector of continuo...
 
auto from_matrix_cl(const T &src)
Copies the source matrix that is stored on the OpenCL device to the destination Eigen matrix.
 
require_all_t< is_prim_or_rev_kernel_expression< std::decay_t< Types > >... > require_all_prim_or_rev_kernel_expression_t
Require type satisfies is_prim_or_rev_kernel_expression.
 
typename return_type< Ts... >::type return_type_t
Convenience type for the return type of the specified template parameters.
 
int64_t size(const T &m)
Returns the size (number of the elements) of a matrix_cl or var_value<matrix_cl<T>>.
 
static constexpr double e()
Return the base of the natural logarithm.
 
T eval(T &&arg)
Inputs which have a plain_type equal to the own time are forwarded unmodified (for Eigen expressions ...
 
T value_of(const fvar< T > &v)
Return the value of the specified variable.
 
auto sum(const std::vector< T > &m)
Return the sum of the entries of the specified standard vector.
 
void check_size_match(const char *function, const char *name_i, T_size1 i, const char *name_j, T_size2 j)
Check if the provided sizes match.
 
int64_t max_size(const T1 &x1, const Ts &... xs)
Calculate the size of the largest input.
 
auto make_partials_propagator(Ops &&... ops)
Construct an partials_propagator.
 
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
 
Checks if decayed type is a var, fvar, or arithmetic.
 
Template metaprogram to calculate whether a summand needs to be included in a proportional (log) prob...