Skip to content

Commit 6a31a61

Browse files
authored
Merge pull request #2371 from bstatcomp/bugfix_reduce_sum
Fixes bug in `reduce_sum` handling expressions with threading enabled
2 parents 9db2e30 + 06737e6 commit 6a31a61

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

stan/math/prim/functor/reduce_sum.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ inline auto reduce_sum(Vec&& vmapped, int grainsize, std::ostream* msgs,
204204

205205
#ifdef STAN_THREADS
206206
return internal::reduce_sum_impl<ReduceFunction, void, return_type, Vec,
207-
Args...>()(std::forward<Vec>(vmapped), true,
208-
grainsize, msgs,
209-
std::forward<Args>(args)...);
207+
ref_type_t<Args&&>...>()(
208+
std::forward<Vec>(vmapped), true, grainsize, msgs,
209+
std::forward<Args>(args)...);
210210
#else
211211
if (vmapped.empty()) {
212212
return return_type(0.0);

stan/math/rev/core/deep_copy_vars.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace math {
2020
* Otherwise it will be moved.
2121
*/
2222
template <typename Arith, typename = require_arithmetic_t<scalar_type_t<Arith>>>
23-
inline decltype(auto) deep_copy_vars(Arith&& arg) {
23+
inline Arith deep_copy_vars(Arith&& arg) {
2424
return std::forward<Arith>(arg);
2525
}
2626

0 commit comments

Comments
 (0)