Skip to content

Commit fd75aaf

Browse files
committed
fix double inline keywords
2 parents bf46263 + 340e343 commit fd75aaf

68 files changed

Lines changed: 559 additions & 596 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

stan/math/fwd/fun/hypergeometric_1F0.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ inline FvarT hypergeometric_1F0(const Ta& a, const Tz& z) {
3636
partials_type_t<Tz> z_val = value_of(z);
3737
FvarT rtn = FvarT(hypergeometric_1F0(a_val, z_val), 0.0);
3838
if constexpr (is_autodiff_v<Ta>) {
39-
rtn.d_ += forward_as<FvarT>(a).d() * -rtn.val() * log1m(z_val);
39+
rtn.d_ += a.d() * -rtn.val() * log1m(z_val);
4040
}
4141
if constexpr (is_autodiff_v<Tz>) {
42-
rtn.d_ += forward_as<FvarT>(z).d() * rtn.val() * a_val * inv(1 - z_val);
42+
rtn.d_ += z.d() * rtn.val() * a_val * inv(1 - z_val);
4343
}
4444
return rtn;
4545
}

stan/math/fwd/fun/hypergeometric_2F1.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@ inline return_type_t<Ta1, Ta2, Tb, Tz> hypergeometric_2F1(const Ta1& a1,
4646
typename fvar_t::Scalar grad = 0;
4747

4848
if constexpr (is_autodiff_v<Ta1>) {
49-
grad += forward_as<fvar_t>(a1).d() * std::get<0>(grad_tuple);
49+
grad += a1.d() * std::get<0>(grad_tuple);
5050
}
5151
if constexpr (is_autodiff_v<Ta2>) {
52-
grad += forward_as<fvar_t>(a2).d() * std::get<1>(grad_tuple);
52+
grad += a2.d() * std::get<1>(grad_tuple);
5353
}
5454
if constexpr (is_autodiff_v<Tb>) {
55-
grad += forward_as<fvar_t>(b).d() * std::get<2>(grad_tuple);
55+
grad += b.d() * std::get<2>(grad_tuple);
5656
}
5757
if constexpr (is_autodiff_v<Tz>) {
58-
grad += forward_as<fvar_t>(z).d() * std::get<3>(grad_tuple);
58+
grad += z.d() * std::get<3>(grad_tuple);
5959
}
6060

6161
return fvar_t(hypergeometric_2F1(a1_val, a2_val, b_val, z_val), grad);

stan/math/fwd/fun/inv_inc_beta.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ inline fvar<partials_return_t<T1, T2, T3>> inv_inc_beta(const T1& a,
6363
+ log(hypergeometric_3F2(da_a, da_b, w)) - 2 * lgamma(ap1));
6464
auto da3 = inc_beta(a_val, b_val, w) * exp(lbeta_ab)
6565
* (log_w - digamma(a_val) + digamma_apb);
66-
inv_d_ += forward_as<fvar<T_return>>(a).d_ * da1 * (da2 - da3);
66+
inv_d_ += a.d_ * da1 * (da2 - da3);
6767
}
6868

6969
if constexpr (is_fvar<T2>::value) {
@@ -76,12 +76,11 @@ inline fvar<partials_return_t<T1, T2, T3>> inv_inc_beta(const T1& a,
7676
auto db3 = inc_beta(b_val, a_val, one_m_w) * exp(lbeta_ab)
7777
* (log1m_w - digamma(b_val) + digamma_apb);
7878

79-
inv_d_ += forward_as<fvar<T_return>>(b).d_ * db1 * (exp(db2) - db3);
79+
inv_d_ += b.d_ * db1 * (exp(db2) - db3);
8080
}
8181

8282
if constexpr (is_fvar<T3>::value) {
83-
inv_d_ += forward_as<fvar<T_return>>(p).d_
84-
* exp(one_m_b * log1m_w + one_m_a * log_w + lbeta_ab);
83+
inv_d_ += p.d_ * exp(one_m_b * log1m_w + one_m_a * log_w + lbeta_ab);
8584
}
8685

8786
return fvar<T_return>(w, inv_d_);

stan/math/fwd/functor/integrate_1d.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ inline return_type_t<T_a, T_b, Args...> integrate_1d_impl(
4848
if constexpr (is_fvar<T_a>::value || is_fvar<T_b>::value) {
4949
auto val_args = std::make_tuple(value_of(args)...);
5050
if constexpr (is_fvar<T_a>::value) {
51-
ret.d_ += math::forward_as<FvarT>(a).d_
51+
ret.d_ += a.d_
5252
* math::apply(
5353
[&](auto &&... tuple_args) {
5454
return -f(a_val, 0.0, msgs, tuple_args...);
5555
},
5656
val_args);
5757
}
5858
if constexpr (is_fvar<T_b>::value) {
59-
ret.d_ += math::forward_as<FvarT>(b).d_
59+
ret.d_ += b.d_
6060
* math::apply(
6161
[&](auto &&... tuple_args) {
6262
return f(b_val, 0.0, msgs, tuple_args...);

stan/math/opencl/prim/bernoulli_logit_glm_lpmf.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ inline return_type_t<T_x_cl, T_alpha_cl, T_beta_cl> bernoulli_logit_glm_lpmf(
144144
if constexpr (is_alpha_vector) {
145145
partials<1>(ops_partials) = theta_derivative_cl;
146146
} else {
147-
forward_as<internal::broadcast_array<double>>(
148-
partials<1>(ops_partials))[0]
147+
partials<1>(ops_partials)[0]
149148
= sum(from_matrix_cl(theta_derivative_sum_cl));
150149
}
151150
}

stan/math/opencl/prim/bernoulli_lpmf.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@ inline return_type_t<T_prob_cl> bernoulli_lpmf(const T_n_cl& n,
7777
partials<0>(ops_partials) = deriv_cl;
7878
}
7979
} else {
80-
auto n_sum_expr = rowwise_sum(forward_as<matrix_cl<int>>(n));
80+
auto n_sum_expr = rowwise_sum(n);
8181

8282
matrix_cl<int> n_sum_cl;
8383

8484
results(n_sum_cl, check_n_bounded)
8585
= expressions(n_sum_expr, n_bounded_expr);
8686

8787
size_t n_sum = sum(from_matrix_cl(n_sum_cl));
88-
double theta_val_scal = forward_as<double>(theta_val);
88+
double theta_val_scal = theta_val;
8989
if (n_sum == N) {
9090
logp = N * log(theta_val_scal);
9191
} else if (n_sum == 0) {
@@ -94,8 +94,7 @@ inline return_type_t<T_prob_cl> bernoulli_lpmf(const T_n_cl& n,
9494
logp = n_sum * log(theta_val_scal) + (N - n_sum) * log1m(theta_val_scal);
9595
}
9696
if constexpr (is_autodiff_v<T_prob_cl>) {
97-
double& edge1_partial = forward_as<internal::broadcast_array<double>>(
98-
partials<0>(ops_partials))[0];
97+
double& edge1_partial = partials<0>(ops_partials)[0];
9998
if (n_sum == N) {
10099
edge1_partial += N / theta_val_scal;
101100
} else if (n_sum == 0) {

stan/math/opencl/prim/binomial_logit_glm_lpmf.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@ inline return_type_t<T_x_cl, T_alpha_cl, T_beta_cl> binomial_logit_glm_lpmf(
111111
if constexpr (is_alpha_vector) {
112112
partials<1>(ops_partials) = theta_deriv_cl;
113113
} else {
114-
forward_as<internal::broadcast_array<double>>(
115-
partials<1>(ops_partials))[0]
116-
= sum(from_matrix_cl(theta_deriv_sum_cl));
114+
partials<1>(ops_partials)[0] = sum(from_matrix_cl(theta_deriv_sum_cl));
117115
}
118116
}
119117
if constexpr (is_autodiff_v<T_beta_cl>) {

stan/math/opencl/prim/binomial_lpmf.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,8 @@ inline return_type_t<T_prob_cl> binomial_lpmf(const T_n_cl& n, const T_N_cl N,
113113
if constexpr (need_sums) {
114114
int sum_n = sum(from_matrix_cl(sum_n_cl));
115115
int sum_N = sum(from_matrix_cl(sum_N_cl));
116-
double theta_dbl = forward_as<double>(theta_val);
117-
double& partial = forward_as<internal::broadcast_array<double>>(
118-
partials<0>(ops_partials))[0];
116+
double theta_dbl = theta_val;
117+
double& partial = partials<0>(ops_partials)[0];
119118
if (sum_N != 0) {
120119
if (sum_n == 0) {
121120
partial = -sum_N / (1.0 - theta_dbl);

stan/math/opencl/prim/categorical_logit_glm_lpmf.hpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ inline return_type_t<T_x, T_alpha, T_beta> categorical_logit_glm_lpmf(
8888
= opencl_kernels::categorical_logit_glm.get_option("LOCAL_SIZE_");
8989
const int wgs = (N_instances + local_size - 1) / local_size;
9090

91-
bool need_alpha_derivative = is_autodiff_v<T_alpha>;
92-
bool need_beta_derivative = is_autodiff_v<T_beta>;
91+
constexpr bool need_alpha_derivative = is_autodiff_v<T_alpha>;
92+
constexpr bool need_beta_derivative = is_autodiff_v<T_beta>;
9393

9494
matrix_cl<double> logp_cl(wgs, 1);
9595
matrix_cl<double> exp_lin_cl(N_instances, N_classes);
@@ -127,13 +127,12 @@ inline return_type_t<T_x, T_alpha, T_beta> categorical_logit_glm_lpmf(
127127
if constexpr (is_y_vector) {
128128
partials<0>(ops_partials)
129129
= indexing(beta_val, col_index(x.rows(), x.cols()),
130-
rowwise_broadcast(forward_as<matrix_cl<int>>(y_val) - 1))
130+
rowwise_broadcast(y_val - 1))
131131
- elt_multiply(exp_lin_cl * transpose(beta_val),
132132
rowwise_broadcast(inv_sum_exp_lin_cl));
133133
} else {
134134
partials<0>(ops_partials)
135-
= indexing(beta_val, col_index(x.rows(), x.cols()),
136-
forward_as<int>(y_val) - 1)
135+
= indexing(beta_val, col_index(x.rows(), x.cols()), y_val - 1)
137136
- elt_multiply(exp_lin_cl * transpose(beta_val),
138137
rowwise_broadcast(inv_sum_exp_lin_cl));
139138
}
@@ -152,9 +151,8 @@ inline return_type_t<T_x, T_alpha, T_beta> categorical_logit_glm_lpmf(
152151
try {
153152
opencl_kernels::categorical_logit_glm_beta_derivative(
154153
cl::NDRange(local_size * N_attributes), cl::NDRange(local_size),
155-
forward_as<arena_matrix_cl<double>>(partials<2>(ops_partials)),
156-
temp, y_val_cl, x_val, N_instances, N_attributes, N_classes,
157-
is_y_vector);
154+
partials<2>(ops_partials), temp, y_val_cl, x_val, N_instances,
155+
N_attributes, N_classes, is_y_vector);
158156
} catch (const cl::Error& e) {
159157
check_opencl_error(function, e);
160158
}

stan/math/opencl/prim/neg_binomial_2_log_glm_lpmf.hpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,11 @@ neg_binomial_2_log_glm_lpmf(const T_y_cl& y, const T_x_cl& x,
168168
}
169169

170170
if constexpr (include_summand<propto, T_phi_cl>::value && !is_phi_vector) {
171-
logp += N
172-
* (multiply_log(forward_as<double>(phi_val),
173-
forward_as<double>(phi_val))
174-
- lgamma(forward_as<double>(phi_val)));
171+
logp += N * (multiply_log(phi_val, phi_val) - lgamma(phi_val));
175172
}
176173
if constexpr (include_summand<propto, T_phi_cl>::value && !is_y_vector
177174
&& !is_phi_vector) {
178-
logp += forward_as<double>(lgamma(y_val + phi_val)) * N;
175+
logp += lgamma(y_val + phi_val) * N;
179176
}
180177

181178
auto ops_partials = make_partials_propagator(x, alpha, beta, phi);
@@ -203,18 +200,15 @@ neg_binomial_2_log_glm_lpmf(const T_y_cl& y, const T_x_cl& x,
203200
if constexpr (is_alpha_vector) {
204201
partials<1>(ops_partials) = std::move(theta_derivative_cl);
205202
} else {
206-
forward_as<internal::broadcast_array<double>>(
207-
partials<1>(ops_partials))[0]
203+
partials<1>(ops_partials)[0]
208204
= sum(from_matrix_cl(theta_derivative_sum_cl));
209205
}
210206
}
211207
if constexpr (is_autodiff_v<T_phi_cl>) {
212208
if constexpr (is_phi_vector) {
213209
partials<3>(ops_partials) = std::move(phi_derivative_cl);
214210
} else {
215-
forward_as<internal::broadcast_array<double>>(
216-
partials<3>(ops_partials))[0]
217-
= sum(from_matrix_cl(phi_derivative_cl));
211+
partials<3>(ops_partials)[0] = sum(from_matrix_cl(phi_derivative_cl));
218212
}
219213
}
220214
return ops_partials.build(logp);

0 commit comments

Comments
 (0)