Skip to content

Commit ab11b32

Browse files
committed
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
1 parent 0255450 commit ab11b32

10 files changed

Lines changed: 118 additions & 99 deletions

File tree

stan/math/opencl/kernel_generator/as_operation_cl.hpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ inline T_operation&& as_operation_cl(T_operation&& a) {
4040
* @param a scalar
4141
* @return \c scalar_ wrapping the input
4242
*/
43-
template <assign_op_cl AssignOp = assign_op_cl::equals, typename T_scalar, typename = require_arithmetic_t<T_scalar>,
43+
template <assign_op_cl AssignOp = assign_op_cl::equals, typename T_scalar,
44+
typename = require_arithmetic_t<T_scalar>,
4445
require_not_same_t<T_scalar, bool>* = nullptr>
4546
inline scalar_<T_scalar> as_operation_cl(const T_scalar a) {
4647
return scalar_<T_scalar>(a);
@@ -55,13 +56,15 @@ inline scalar_<T_scalar> as_operation_cl(const T_scalar a) {
5556
* @return \c scalar_<char> wrapping the input
5657
*/
5758
template <assign_op_cl AssignOp = assign_op_cl::equals>
58-
inline scalar_<char> as_operation_cl(const bool a) { return scalar_<char>(a); }
59+
inline scalar_<char> as_operation_cl(const bool a) {
60+
return scalar_<char>(a);
61+
}
5962

6063
/**
6164
* Converts any valid kernel generator expression into an operation. This is an
6265
* overload for \c matrix_cl. It wraps them into into \c load_.
63-
* @tparam AssignOp an optional `assign_op_cl` that dictates whether the object
64-
* is assigned using standard or compound assign.
66+
* @tparam AssignOp an optional `assign_op_cl` that dictates whether the object
67+
* is assigned using standard or compound assign.
6568
* @tparam T_matrix_cl \c matrix_cl
6669
* @param a \c matrix_cl
6770
* @return \c load_ wrapping the input
@@ -80,15 +83,16 @@ inline load_<T_matrix_cl, AssignOp> as_operation_cl(T_matrix_cl&& a) {
8083
* as_operation_cl_t<T>. If the return value of \c as_operation_cl() would be a
8184
* rvalue reference, the reference is removed, so that a variable of this type
8285
* actually stores the value.
83-
* @tparam T a `matrix_cl` or `Scalar` type
84-
* @tparam AssignOp an optional `assign_op_cl` that dictates whether the object
85-
* is assigned using standard or compound assign.
86+
* @tparam T a `matrix_cl` or `Scalar` type
87+
* @tparam AssignOp an optional `assign_op_cl` that dictates whether the object
88+
* is assigned using standard or compound assign.
8689
*/
8790
template <typename T, assign_op_cl AssignOp = assign_op_cl::equals>
88-
using as_operation_cl_t = std::conditional_t<
89-
std::is_lvalue_reference<T>::value,
90-
decltype(as_operation_cl<AssignOp>(std::declval<T>())),
91-
std::remove_reference_t<decltype(as_operation_cl<AssignOp>(std::declval<T>()))>>;
91+
using as_operation_cl_t
92+
= std::conditional_t<std::is_lvalue_reference<T>::value,
93+
decltype(as_operation_cl<AssignOp>(std::declval<T>())),
94+
std::remove_reference_t<decltype(
95+
as_operation_cl<AssignOp>(std::declval<T>()))>>;
9296

9397
/** @}*/
9498
} // namespace math

stan/math/opencl/kernel_generator/assignment_ops.hpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,18 @@ namespace math {
99
/**
1010
* Ops that decide the type of assignment for LHS operations
1111
*/
12-
enum class assign_op_cl {equals, plus_equals, minus_equals, divide_equals, multiply_equals};
12+
enum class assign_op_cl {
13+
equals,
14+
plus_equals,
15+
minus_equals,
16+
divide_equals,
17+
multiply_equals
18+
};
1319

1420
namespace internal {
1521
/**
16-
* @param value A static constexpr const char* member for printing assignment ops
22+
* @param value A static constexpr const char* member for printing assignment
23+
* ops
1724
*/
1825
template <assign_op_cl assign_op>
1926
struct assignment_op_str_impl;
@@ -47,11 +54,11 @@ template <typename, typename = void>
4754
struct assignment_op_str : assignment_op_str_impl<assign_op_cl::equals> {};
4855

4956
template <typename T>
50-
struct assignment_op_str<T, void_t<decltype(T::assignment_op)>> : assignment_op_str_impl<T::assignment_op> {};
57+
struct assignment_op_str<T, void_t<decltype(T::assignment_op)>>
58+
: assignment_op_str_impl<T::assignment_op> {};
5159

5260
} // namespace internal
5361

54-
5562
/**
5663
* @tparam T A type that has an `assignment_op` static constexpr member type
5764
* @return The types assignment op as a constexpr const char*
@@ -61,7 +68,7 @@ inline constexpr const char* assignment_op() noexcept {
6168
return internal::assignment_op_str<std::decay_t<T>>::value;
6269
}
6370

64-
}
65-
}
71+
} // namespace math
72+
} // namespace stan
6673
#endif
6774
#endif

stan/math/opencl/kernel_generator/load.hpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ namespace math {
2525
/**
2626
* Represents an access to a \c matrix_cl in kernel generator expressions
2727
* @tparam T \c matrix_cl
28-
* @tparam AssignOp tells higher level operations whether the final operation should be an assignment or a type of compound assignment.
28+
* @tparam AssignOp tells higher level operations whether the final operation
29+
* should be an assignment or a type of compound assignment.
2930
*/
3031
template <typename T, assign_op_cl AssignOp = assign_op_cl::equals>
3132
class load_
@@ -35,7 +36,6 @@ class load_
3536
T a_;
3637

3738
public:
38-
3939
static constexpr assign_op_cl assignment_op = AssignOp;
4040
using Scalar = typename std::remove_reference_t<T>::type;
4141
using base = operation_cl<load_<T, AssignOp>, Scalar>;
@@ -57,8 +57,12 @@ class load_
5757
* @return copy of \c *this
5858
*/
5959
inline load_<T&, AssignOp> deep_copy() & { return load_<T&, AssignOp>(a_); }
60-
inline load_<const T&, AssignOp> deep_copy() const& { return load_<const T&, AssignOp>(a_); }
61-
inline load_<T, AssignOp> deep_copy() && { return load_<T, AssignOp>(std::forward<T>(a_)); }
60+
inline load_<const T&, AssignOp> deep_copy() const& {
61+
return load_<const T&, AssignOp>(a_);
62+
}
63+
inline load_<T, AssignOp> deep_copy() && {
64+
return load_<T, AssignOp>(std::forward<T>(a_));
65+
}
6266

6367
/**
6468
* Generates kernel code for this expression.

stan/math/opencl/kernel_generator/multi_result_kernel.hpp

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -323,16 +323,17 @@ class results_cl {
323323
});
324324
}
325325

326-
/**
326+
/**
327327
* Incrementing \c results_ object by \c expressions_cl object
328328
* executes the kernel that evaluates expressions and increments results by
329329
* those expressions.
330-
* @tparam AssignOp an optional `assign_op_cl` that dictates whether the object
331-
* is assigned using standard or compound assign.
330+
* @tparam AssignOp an optional `assign_op_cl` that dictates whether the
331+
* object is assigned using standard or compound assign.
332332
* @tparam T_expressions types of expressions
333333
* @param exprs expressions
334334
*/
335-
template <assign_op_cl AssignOp = assign_op_cl::plus_equals, typename... T_expressions,
335+
template <assign_op_cl AssignOp = assign_op_cl::plus_equals,
336+
typename... T_expressions,
336337
typename = std::enable_if_t<sizeof...(T_results)
337338
== sizeof...(T_expressions)>>
338339
void compound_assignment_impl(const expressions_cl<T_expressions...>& exprs) {
@@ -361,7 +362,7 @@ class results_cl {
361362
compound_assignment_impl<assign_op_cl::plus_equals>(exprs);
362363
}
363364

364-
/**
365+
/**
365366
* Decrement \c results_ object by \c expressions_cl object
366367
* executes the kernel that evaluates expressions and increments results by
367368
* those expressions.
@@ -375,7 +376,7 @@ class results_cl {
375376
compound_assignment_impl<assign_op_cl::minus_equals>(exprs);
376377
}
377378

378-
/**
379+
/**
379380
* Elementwise divide \c results_ object by \c expressions_cl object
380381
* executes the kernel that evaluates expressions and increments results by
381382
* those expressions.
@@ -389,7 +390,7 @@ class results_cl {
389390
compound_assignment_impl<assign_op_cl::divide_equals>(exprs);
390391
}
391392

392-
/**
393+
/**
393394
* Elementwise multiply \c results_ object by \c expressions_cl object
394395
* executes the kernel that evaluates expressions and increments results by
395396
* those expressions.
@@ -484,7 +485,7 @@ class results_cl {
484485
+ parts.reduction_2d +
485486
"}\n";
486487
}
487-
return src;
488+
return src;
488489
}
489490

490491
/**
@@ -583,38 +584,44 @@ class results_cl {
583584
/**
584585
* Makes a std::pair of one result and one expression and wraps it into a
585586
* tuple.
586-
* @tparam AssignOp an optional `assign_op_cl` that dictates whether the object
587-
* is assigned using standard or compound assign.
588-
* @tparam T_result An non scalar type that is normally an `result_cl` operation holding a `matrix_cl`
589-
* @tparam T_expression An expression of set of operations on `matrix_cl` and scalar types.
587+
* @tparam AssignOp an optional `assign_op_cl` that dictates whether the
588+
* object is assigned using standard or compound assign.
589+
* @tparam T_result An non scalar type that is normally an `result_cl`
590+
* operation holding a `matrix_cl`
591+
* @tparam T_expression An expression of set of operations on `matrix_cl` and
592+
* scalar types.
590593
* @param result result
591594
* @param expression expression
592595
* @return a tuple of pair of result and expression
593596
*/
594-
template <assign_op_cl AssignOp = assign_op_cl::equals, typename T_result, typename T_expression,
597+
template <assign_op_cl AssignOp = assign_op_cl::equals, typename T_result,
598+
typename T_expression,
595599
require_all_not_t<is_without_output<T_expression>,
596600
conjunction<internal::is_scalar_check<T_result>,
597601
std::is_arithmetic<std::decay_t<
598602
T_expression>>>>* = nullptr>
599603
static auto make_assignment_pair(T_result&& result,
600604
T_expression&& expression) {
601-
return std::make_tuple(
602-
std::pair<as_operation_cl_t<T_result, AssignOp>, as_operation_cl_t<T_expression>>(
603-
as_operation_cl<AssignOp>(std::forward<T_result>(result)),
604-
as_operation_cl(std::forward<T_expression>(expression))));
605+
return std::make_tuple(std::pair<as_operation_cl_t<T_result, AssignOp>,
606+
as_operation_cl_t<T_expression>>(
607+
as_operation_cl<AssignOp>(std::forward<T_result>(result)),
608+
as_operation_cl(std::forward<T_expression>(expression))));
605609
}
606610

607611
/**
608612
* If an expression does not need to be calculated this returns an empty tuple
609-
* @tparam AssignOp an optional `assign_op_cl` that dictates whether the object
610-
* is assigned using standard or compound assign.
611-
* @tparam T_result An non scalar type that is normally an `result_cl` operation holding a `matrix_cl`
612-
* @tparam T_expression An expression of set of operations on `matrix_cl` and scalar types.
613+
* @tparam AssignOp an optional `assign_op_cl` that dictates whether the
614+
* object is assigned using standard or compound assign.
615+
* @tparam T_result An non scalar type that is normally an `result_cl`
616+
* operation holding a `matrix_cl`
617+
* @tparam T_expression An expression of set of operations on `matrix_cl` and
618+
* scalar types.
613619
* @param result result
614620
* @param expression expression
615621
* @return a tuple of pair of result and expression
616622
*/
617-
template <assign_op_cl AssignOp = assign_op_cl::equals, typename T_result, typename T_expression,
623+
template <assign_op_cl AssignOp = assign_op_cl::equals, typename T_result,
624+
typename T_expression,
618625
require_t<is_without_output<T_expression>>* = nullptr>
619626
static auto make_assignment_pair(T_result&& result,
620627
T_expression&& expression) {
@@ -624,15 +631,16 @@ class results_cl {
624631
/**
625632
* Checks on scalars are done separately in this overload instead of in
626633
* kernel.
627-
* @tparam AssignOp an optional `assign_op_cl` that dictates whether the object
628-
* is assigned using standard or compound assign.
634+
* @tparam AssignOp an optional `assign_op_cl` that dictates whether the
635+
* object is assigned using standard or compound assign.
629636
* @tparam T_check A scalar type
630637
* @tparam T_pass An integral type
631638
* @param result result - check
632639
* @param pass bool scalar
633640
* @return an empty tuple
634641
*/
635-
template <assign_op_cl AssignOp = assign_op_cl::equals, typename T_check, typename T_pass,
642+
template <assign_op_cl AssignOp = assign_op_cl::equals, typename T_check,
643+
typename T_pass,
636644
require_t<internal::is_scalar_check<T_check>>* = nullptr,
637645
require_integral_t<T_pass>* = nullptr>
638646
static std::tuple<> make_assignment_pair(T_check&& result, T_pass&& pass) {

stan/math/opencl/kernel_generator/operation_cl.hpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,21 +76,21 @@ struct kernel_parts {
7676
};
7777

7878
std::ostream& operator<<(std::ostream& os, kernel_parts& parts) {
79-
os << "args:" << std::endl;
80-
os << parts.args.substr(0, parts.args.size() - 2) << std::endl;
81-
os << "Decl:" << std::endl;
82-
os << parts.declarations << std::endl;
83-
os << "Init:" << std::endl;
84-
os << parts.initialization << std::endl;
85-
os << "body:" << std::endl;
86-
os << parts.body << std::endl;
87-
os << "body_suffix:" << std::endl;
88-
os << parts.body_suffix << std::endl;
89-
os << "reduction_1d:" << std::endl;
90-
os << parts.reduction_1d << std::endl;
91-
os << "reduction_2d:" << std::endl;
92-
os << parts.reduction_2d << std::endl;
93-
return os;
79+
os << "args:" << std::endl;
80+
os << parts.args.substr(0, parts.args.size() - 2) << std::endl;
81+
os << "Decl:" << std::endl;
82+
os << parts.declarations << std::endl;
83+
os << "Init:" << std::endl;
84+
os << parts.initialization << std::endl;
85+
os << "body:" << std::endl;
86+
os << parts.body << std::endl;
87+
os << "body_suffix:" << std::endl;
88+
os << parts.body_suffix << std::endl;
89+
os << "reduction_1d:" << std::endl;
90+
os << parts.reduction_1d << std::endl;
91+
os << "reduction_2d:" << std::endl;
92+
os << parts.reduction_2d << std::endl;
93+
return os;
9494
}
9595

9696
/**

stan/math/opencl/rev/adjoint_results.hpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,24 @@ class adjoint_results_cl : protected results_cl<T_results...> {
4141
index_apply<sizeof...(T_expressions)>([&](auto... Is) {
4242
auto scalars = std::tuple_cat(select_scalar_assignments(
4343
std::get<Is>(this->results_), std::get<Is>(exprs.expressions_))...);
44-
auto nonscalars_tmp = std::tuple_cat(select_nonscalar_assignments<assign_op_cl::plus_equals>(
45-
std::get<Is>(this->results_), std::get<Is>(exprs.expressions_))...);
44+
auto nonscalars_tmp = std::tuple_cat(
45+
select_nonscalar_assignments<assign_op_cl::plus_equals>(
46+
std::get<Is>(this->results_),
47+
std::get<Is>(exprs.expressions_))...);
4648

4749
index_apply<std::tuple_size<decltype(nonscalars_tmp)>::value>(
4850
[&](auto... Is_nonscal) {
49-
auto nonscalars = std::make_tuple(std::make_pair(
50-
std::get<Is_nonscal>(nonscalars_tmp).first, std::get<Is_nonscal>(nonscalars_tmp).second)...);
51-
52-
51+
auto nonscalars = std::make_tuple(
52+
std::make_pair(std::get<Is_nonscal>(nonscalars_tmp).first,
53+
std::get<Is_nonscal>(nonscalars_tmp).second)...);
54+
5355
index_apply<std::tuple_size<decltype(scalars)>::value>(
5456
[&](auto... Is_scal) {
5557
// evaluate all expressions
5658
this->assignment_impl(std::tuple_cat(
5759
nonscalars,
58-
this->template make_assignment_pair<assign_op_cl::plus_equals>(
60+
this->template make_assignment_pair<
61+
assign_op_cl::plus_equals>(
5962
std::get<2>(std::get<Is_scal>(scalars)),
6063
sum_2d(std::get<1>(std::get<Is_scal>(scalars))))...));
6164

@@ -99,11 +102,10 @@ class adjoint_results_cl : protected results_cl<T_results...> {
99102
return std::make_tuple();
100103
}
101104

102-
103105
/**
104106
* Selects assignments that have non-scalar var results.
105-
* @tparam AssignOp an optional `assign_op_cl` that dictates whether the object
106-
* is assigned using standard or compound assign.
107+
* @tparam AssignOp an optional `assign_op_cl` that dictates whether the
108+
* object is assigned using standard or compound assign.
107109
* @tparam T_result type of result. This overload is used for non-scalar vars.
108110
* @tparam T_expression type of expression
109111
* @param result result
@@ -121,17 +123,17 @@ class adjoint_results_cl : protected results_cl<T_results...> {
121123
}
122124
/**
123125
* Selects assignments that have non-scalar var results.
124-
* @tparam AssignOp an optional `assign_op_cl` that dictates whether the object
125-
* is assigned using standard or compound assign.
126+
* @tparam AssignOp an optional `assign_op_cl` that dictates whether the
127+
* object is assigned using standard or compound assign.
126128
* @tparam T_result type of result. This overload is used for results that are
127129
* either scalars or not vars.
128130
* @tparam T_expression type of expression
129131
* @param result result
130132
* @param expression expression
131133
* @return empty tuple
132134
*/
133-
template <assign_op_cl AssignOp,
134-
typename T_result, typename T_expression,
135+
template <
136+
assign_op_cl AssignOp, typename T_result, typename T_expression,
135137
std::enable_if_t<is_stan_scalar<T_result>::value
136138
|| !is_var<scalar_type_t<T_result>>::value>* = nullptr>
137139
auto select_nonscalar_assignments(T_result&& result,

stan/math/opencl/rev/grad.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ namespace math {
1919
* @param[in] x Variables being differentiated with respect to
2020
* @param[out] g Gradient, d/dx v, evaluated at x.
2121
*/
22-
inline void grad(var& v, var_value<matrix_cl<double>>& x,
23-
Eigen::VectorXd& g) {
22+
inline void grad(var& v, var_value<matrix_cl<double>>& x, Eigen::VectorXd& g) {
2423
grad(v.vi_);
2524
g = from_matrix_cl<Eigen::VectorXd>(x.adj());
2625
}

0 commit comments

Comments
 (0)