Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doxygen/parallelism_support/opencl_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ C_sum.grad();
- inv, inv_cloglog, inv_logit, inv_sqrt, inv_square, inv_Phi
- ldexp
- lgamma
- lmultiply
- log, log10, log1m, log1p, log2, logit
- log1m_exp, log1p_exp, log1m_inv_logit, log_inv_logit
- log_diff_exp, log_inv_logit_diff
Expand All @@ -149,7 +150,6 @@ C_sum.grad();
- mean
- mdivide_left_tri_low, mdivide_right_tri_low
- multiply, operator*
- multiply_log, lmultiply
- Phi, Phi_approx
- pow
- segment
Expand Down
1 change: 0 additions & 1 deletion stan/math/fwd/fun.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
#include <stan/math/fwd/fun/modified_bessel_first_kind.hpp>
#include <stan/math/fwd/fun/modified_bessel_second_kind.hpp>
#include <stan/math/fwd/fun/multiply.hpp>
#include <stan/math/fwd/fun/multiply_log.hpp>
#include <stan/math/fwd/fun/multiply_lower_tri_self_transpose.hpp>
#include <stan/math/fwd/fun/norm.hpp>
#include <stan/math/fwd/fun/norm1.hpp>
Expand Down
30 changes: 0 additions & 30 deletions stan/math/fwd/fun/multiply_log.hpp

This file was deleted.

6 changes: 0 additions & 6 deletions stan/math/opencl/kernel_generator/elt_function_cl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,11 @@
#include <stan/math/opencl/kernels/device_functions/log1m_inv_logit.hpp>
#include <stan/math/opencl/kernels/device_functions/log1p_exp.hpp>
#include <stan/math/opencl/kernels/device_functions/logit.hpp>
#include <stan/math/opencl/kernels/device_functions/multiply_log.hpp>
#include <stan/math/opencl/kernels/device_functions/Phi.hpp>
#include <stan/math/opencl/kernels/device_functions/Phi_approx.hpp>
#include <stan/math/opencl/kernels/device_functions/std_normal_lcdf.hpp>
#include <stan/math/opencl/kernels/device_functions/trigamma.hpp>
#include <stan/math/opencl/matrix_cl_view.hpp>
#include <stan/math/opencl/kernel_generator/common_return_scalar.hpp>
#include <stan/math/opencl/kernel_generator/type_str.hpp>
#include <stan/math/opencl/kernel_generator/name_generator.hpp>
#include <stan/math/opencl/kernel_generator/operation_cl.hpp>
#include <stan/math/opencl/kernel_generator/as_operation_cl.hpp>
#include <array>
Expand Down Expand Up @@ -417,8 +413,6 @@ ADD_BINARY_FUNCTION_WITH_INCLUDES(
ADD_BINARY_FUNCTION_WITH_INCLUDES(log_diff_exp,
opencl_kernels::log1m_exp_device_function,
opencl_kernels::log_diff_exp_device_function)
ADD_BINARY_FUNCTION_WITH_INCLUDES(
multiply_log, stan::math::opencl_kernels::multiply_log_device_function)
ADD_BINARY_FUNCTION_WITH_INCLUDES(
lmultiply, stan::math::opencl_kernels::lmultiply_device_function)

Expand Down
72 changes: 0 additions & 72 deletions stan/math/opencl/kernels/device_functions/multiply_log.hpp

This file was deleted.

10 changes: 2 additions & 8 deletions stan/math/opencl/prim/neg_binomial_2_log_glm_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,15 @@
#include <stan/math/opencl/rev/operands_and_partials.hpp>
#include <stan/math/opencl/copy.hpp>
#include <stan/math/opencl/prim/multiply.hpp>
#include <stan/math/opencl/plain_type.hpp>
#include <stan/math/opencl/kernel_generator.hpp>
#include <stan/math/opencl/kernels/neg_binomial_2_log_glm_lpmf.hpp>
#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/err.hpp>
#include <stan/math/prim/fun/constants.hpp>
#include <stan/math/prim/fun/eval.hpp>
#include <stan/math/prim/fun/digamma.hpp>
#include <stan/math/prim/fun/lgamma.hpp>
#include <stan/math/prim/fun/multiply_log.hpp>
#include <stan/math/prim/fun/lmultiply.hpp>
#include <stan/math/prim/fun/size.hpp>
#include <stan/math/prim/fun/sum.hpp>
#include <stan/math/prim/fun/to_ref.hpp>
#include <stan/math/prim/fun/value_of_rec.hpp>
#include <vector>
#include <cmath>

namespace stan {
Expand Down Expand Up @@ -167,7 +161,7 @@ neg_binomial_2_log_glm_lpmf(const T_y_cl& y, const T_x_cl& x,
}

if constexpr (include_summand<propto, T_phi_cl>::value && !is_phi_vector) {
logp += N * (multiply_log(phi_val, phi_val) - lgamma(phi_val));
logp += N * (lmultiply(phi_val, phi_val) - lgamma(phi_val));
}
if constexpr (include_summand<propto, T_phi_cl>::value && !is_y_vector
&& !is_phi_vector) {
Expand Down
6 changes: 2 additions & 4 deletions stan/math/opencl/prim/neg_binomial_2_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@

#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/err.hpp>
#include <stan/math/prim/fun/constants.hpp>
#include <stan/math/prim/fun/elt_divide.hpp>
#include <stan/math/prim/fun/elt_multiply.hpp>
#include <stan/math/prim/fun/exp.hpp>
#include <stan/math/opencl/kernel_generator.hpp>
#include <stan/math/prim/functor/partials_propagator.hpp>
#include <stan/math/prim/fun/multiply_log.hpp>
#include <stan/math/prim/fun/lmultiply.hpp>

namespace stan {
namespace math {
Expand Down Expand Up @@ -85,7 +83,7 @@ inline return_type_t<T_n_cl, T_location_cl, T_precision_cl> neg_binomial_2_lpmf(
logp1 + binomial_coefficient_log(n_plus_phi - 1, n), logp1);
auto logp_expr = colwise_sum(
static_select<include_summand<propto, T_location_cl>::value>(
logp2 + multiply_log(n, mu_val), logp2));
logp2 + lmultiply(n, mu_val), logp2));

auto mu_deriv = elt_divide(n, mu_val) - elt_divide(n + phi_val, mu_plus_phi);
auto log_term
Expand Down
3 changes: 1 addition & 2 deletions stan/math/opencl/prim/poisson_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/err.hpp>
#include <stan/math/prim/fun/constants.hpp>
#include <stan/math/prim/fun/log.hpp>
#include <stan/math/opencl/kernel_generator.hpp>
#include <stan/math/prim/functor/partials_propagator.hpp>

Expand Down Expand Up @@ -61,7 +60,7 @@ inline return_type_t<T_rate_cl> poisson_lpmf(const T_n_cl& n,
auto return_log_zero = colwise_max(
cast<char>(isinf(lambda_val) || (lambda_val == 0 && n != 0)));

auto logp1 = multiply_log(n, lambda_val);
auto logp1 = lmultiply(n, lambda_val);
auto logp2 = static_select<include_summand<propto, T_rate_cl>::value>(
logp1 - lambda_val, logp1);
auto logp_expr = colwise_sum(static_select<include_summand<propto>::value>(
Expand Down
1 change: 0 additions & 1 deletion stan/math/opencl/rev.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
#include <stan/math/opencl/rev/mdivide_left_tri_low.hpp>
#include <stan/math/opencl/rev/mdivide_right_tri_low.hpp>
#include <stan/math/opencl/rev/multiply.hpp>
#include <stan/math/opencl/rev/multiply_log.hpp>
#include <stan/math/opencl/rev/multiply_lower_tri_self_transpose.hpp>
#include <stan/math/opencl/rev/operands_and_partials.hpp>
#include <stan/math/opencl/rev/operator_unary_minus.hpp>
Expand Down
46 changes: 0 additions & 46 deletions stan/math/opencl/rev/multiply_log.hpp

This file was deleted.

6 changes: 2 additions & 4 deletions stan/math/prim/constraint/offset_multiplier_constrain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/err.hpp>
#include <stan/math/prim/fun/fma.hpp>
#include <stan/math/prim/constraint/identity_constrain.hpp>
#include <stan/math/prim/fun/multiply_log.hpp>
#include <stan/math/prim/fun/lmultiply.hpp>
#include <stan/math/prim/fun/size.hpp>
#include <stan/math/prim/fun/sum.hpp>
#include <stan/math/prim/fun/to_ref.hpp>
#include <stan/math/prim/fun/eval.hpp>
#include <stan/math/prim/functor/apply.hpp>
#include <cmath>

namespace stan {
Expand Down Expand Up @@ -111,7 +109,7 @@ inline auto offset_multiplier_constrain(const T& x, const M& mu, const S& sigma,
check_positive_finite("offset_multiplier_constrain", "multiplier",
value_of_rec(sigma_ref));
if (math::size(sigma_ref) == 1) {
lp += sum(multiply_log(math::size(x), sigma_ref));
lp += sum(lmultiply(math::size(x), sigma_ref));
} else {
lp += sum(log(sigma_ref));
}
Expand Down
8 changes: 3 additions & 5 deletions stan/math/prim/fun/grad_reg_inc_gamma.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/err.hpp>
#include <stan/math/prim/fun/constants.hpp>
#include <stan/math/prim/fun/exp.hpp>
#include <stan/math/prim/fun/gamma_p.hpp>
#include <stan/math/prim/fun/gamma_q.hpp>
#include <stan/math/prim/fun/is_any_nan.hpp>
#include <stan/math/prim/fun/is_inf.hpp>
#include <stan/math/prim/fun/log.hpp>
#include <stan/math/prim/fun/multiply_log.hpp>
#include <stan/math/prim/fun/lmultiply.hpp>
#include <cmath>
#include <limits>

Expand Down Expand Up @@ -93,12 +91,12 @@ inline return_type_t<T1, T2> grad_reg_inc_gamma(T1 a, T2 z, T1 g, T1 dig,
TP log_s = 0.0;
double s_sign = 1.0;
T2 log_z = log(z);
TP log_delta = log_s - multiply_log(2, a);
TP log_delta = log_s - lmultiply(2, a);
for (int k = 1; k <= max_steps; ++k) {
S += s_sign >= 0.0 ? exp(log_delta) : -exp(log_delta);
log_s += log_z - log(k);
s_sign = -s_sign;
log_delta = log_s - multiply_log(2, k + a);
log_delta = log_s - lmultiply(2, k + a);
if (is_inf(log_delta)) {
throw_domain_error("grad_reg_inc_gamma", "is not converging", "", "");
}
Expand Down
14 changes: 6 additions & 8 deletions stan/math/prim/fun/log_modified_bessel_first_kind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
#include <stan/math/prim/fun/inv.hpp>
#include <stan/math/prim/fun/is_inf.hpp>
#include <stan/math/prim/fun/lgamma.hpp>
#include <stan/math/prim/fun/log.hpp>
#include <stan/math/prim/fun/log_sum_exp.hpp>
#include <stan/math/prim/fun/log1p.hpp>
#include <stan/math/prim/fun/log1p_exp.hpp>
#include <stan/math/prim/fun/multiply_log.hpp>
#include <stan/math/prim/fun/sqrt.hpp>
#include <stan/math/prim/fun/lmultiply.hpp>
#include <stan/math/prim/fun/square.hpp>
#include <stan/math/prim/functor/apply_scalar_binary.hpp>
#include <boost/math/tools/rational.hpp>
Expand Down Expand Up @@ -100,7 +98,7 @@ inline return_type_t<T1, T2, double> log_modified_bessel_first_kind(
6.27767773636292611e-16, 4.34709704153272287e-18,
2.63417742690109154e-20, 1.13943037744822825e-22,
9.07926920085624812e-25};
return log1p_exp(multiply_log(2, z) - log(4.0)
return log1p_exp(lmultiply(2, z) - log(4.0)
+ log(evaluate_polynomial(P, 0.25 * square(z))));
}
if (z < 500) {
Expand All @@ -119,15 +117,15 @@ inline return_type_t<T1, T2, double> log_modified_bessel_first_kind(
-4.49034849696138065e+13, 2.24155239966958995e+14,
-8.13426467865659318e+14, 2.02391097391687777e+15,
-3.08675715295370878e+15, 2.17587543863819074e+15};
return z + log(evaluate_polynomial(P, inv(z))) - multiply_log(0.5, z);
return z + log(evaluate_polynomial(P, inv(z))) - lmultiply(0.5, z);
}
// Max error in interpolated form : 2.437e-18
// Max Error found at double precision = Poly : 1.216719e-16
static constexpr double P[5]
= {3.98942280401432905e-01, 4.98677850491434560e-02,
2.80506308916506102e-02, 2.92179096853915176e-02,
4.53371208762579442e-02};
return z + log(evaluate_polynomial(P, inv(z))) - multiply_log(0.5, z);
return z + log(evaluate_polynomial(P, inv(z))) - lmultiply(0.5, z);
}
if (v == 1) { // WARNING: will not autodiff for v = 1 correctly
// modified from Boost's bessel_i1_imp in the double precision case
Expand Down Expand Up @@ -165,15 +163,15 @@ inline return_type_t<T1, T2, double> log_modified_bessel_first_kind(
4.614040809616582764e+13, -2.298849639457172489e+14,
8.325554073334618015e+14, -2.067285045778906105e+15,
3.146401654361325073e+15, -2.213318202179221945e+15};
return z + log(evaluate_polynomial(P, inv(z))) - multiply_log(0.5, z);
return z + log(evaluate_polynomial(P, inv(z))) - lmultiply(0.5, z);
}
// Max error in interpolated form: 1.320e-19
// Max Error found at double precision = Poly: 7.065357e-17
static constexpr double P[5]
= {3.989422804014314820e-01, -1.496033551467584157e-01,
-4.675105322571775911e-02, -4.090421597376992892e-02,
-5.843630344778927582e-02};
return z + log(evaluate_polynomial(P, inv(z))) - multiply_log(0.5, z);
return z + log(evaluate_polynomial(P, inv(z))) - lmultiply(0.5, z);
}
if (z > 100) {
// Boost does something like this in asymptotic_bessel_i_large_x
Expand Down
Loading
Loading