WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 1cef7a9

Browse files
committed
cpu: fix cpp20 build after switching to capture-by-copy
1 parent 16a3e45 commit 1cef7a9

36 files changed

+185
-118
lines changed

src/cpu/matmul/ref_matmul.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
* limitations under the License.
1515
*******************************************************************************/
1616

17+
#include <algorithm>
1718
#include <assert.h>
1819
#include <float.h>
1920
#include <math.h>
2021

21-
#include <algorithm>
2222
#include "common/c_types_map.hpp"
23+
#include "common/compiler_workarounds.hpp"
2324
#include "common/dnnl_thread.hpp"
2425
#include "common/math_utils.hpp"
2526
#include "common/type_helpers.hpp"
@@ -261,7 +262,8 @@ status_t ref_matmul_t::execute_ref(const exec_ctx_t &ctx) const {
261262
dim_t M_chunks = utils::div_up(M, M_chunk_size);
262263
dim_t N_chunks = utils::div_up(N, N_chunk_size);
263264
parallel_nd_ext(pd()->nthr_, batch, M_chunks, N_chunks,
264-
[=](int ithr, int nthr, dim_t mb, dim_t mc, dim_t nc) {
265+
[= WA_THIS_COPY_CAPTURE](
266+
int ithr, int nthr, dim_t mb, dim_t mc, dim_t nc) {
265267
if (ithr >= pd()->ntasks_) return;
266268
for_(dim_t m_ = mc * M_chunk_size;
267269
m_ < std::min<dim_t>((mc + 1) * M_chunk_size, M);

src/cpu/matmul/ref_matmul_int8.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <math.h>
2020

2121
#include "common/c_types_map.hpp"
22+
#include "common/compiler_workarounds.hpp"
2223
#include "common/dnnl_thread.hpp"
2324
#include "common/math_utils.hpp"
2425
#include "common/type_helpers.hpp"
@@ -257,7 +258,8 @@ status_t ref_matmul_int8_t::execute_ref(const exec_ctx_t &ctx) const {
257258
auto sum_dt = pd()->attr()->post_ops_.get_sum_dt(dst_d.data_type());
258259

259260
// computations
260-
parallel_nd(batch, M, N, [=](dim_t mb, dim_t m, dim_t n) {
261+
parallel_nd(
262+
batch, M, N, [= WA_THIS_COPY_CAPTURE](dim_t mb, dim_t m, dim_t n) {
261263
dims_t dst_dims_idx;
262264
// account for M, N dims for index calculations
263265
const size_t l_offset = mb * M * N + m * N + n;

src/cpu/ref_binary.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <math.h>
2020

2121
#include "common/c_types_map.hpp"
22+
#include "common/compiler_workarounds.hpp"
2223
#include "common/dnnl_thread.hpp"
2324
#include "common/math_utils.hpp"
2425
#include "common/nstl.hpp"
@@ -94,7 +95,7 @@ status_t ref_binary_t::execute_ref(const exec_ctx_t &ctx) const {
9495
}
9596
}
9697

97-
parallel_nd(nelems, [=](dim_t i) {
98+
parallel_nd(nelems, [= WA_THIS_COPY_CAPTURE](dim_t i) {
9899
// decomposition for physical offsets
99100
dims_t dims_src0, dims_src1, dims_src2;
100101
utils::l_dims_by_l_offset(dims_src0, i, dst_d.dims(), ndims);

src/cpu/ref_convolution.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*******************************************************************************/
1616

1717
#include "common/c_types_map.hpp"
18+
#include "common/compiler_workarounds.hpp"
1819
#include "common/dnnl_thread.hpp"
1920
#include "common/dnnl_traits.hpp"
2021
#include "common/math_utils.hpp"
@@ -187,7 +188,8 @@ status_t ref_convolution_fwd_t::execute_forward(const exec_ctx_t &ctx) const {
187188
auto sum_dt = pd()->attr()->post_ops_.get_sum_dt(dst_d.data_type());
188189

189190
parallel_nd(G, MB, OC, OD, OH, OW,
190-
[=](dim_t g, dim_t mb, dim_t oc, dim_t od, dim_t oh, dim_t ow) {
191+
[= WA_THIS_COPY_CAPTURE](
192+
dim_t g, dim_t mb, dim_t oc, dim_t od, dim_t oh, dim_t ow) {
191193
float acc = 0;
192194
if (src_d.is_plain() && weights_d.is_plain() && src_ic_stride == 1
193195
&& weights_kw_stride == 1)

src/cpu/ref_convolution_int8.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*******************************************************************************/
1616

1717
#include "common/c_types_map.hpp"
18+
#include "common/compiler_workarounds.hpp"
1819
#include "common/dnnl_thread.hpp"
1920
#include "common/dnnl_traits.hpp"
2021
#include "common/math_utils.hpp"
@@ -237,7 +238,8 @@ status_t ref_convolution_int8_fwd_t::execute_forward(
237238
const auto sum_dt = pd()->attr()->post_ops_.get_sum_dt(dst_d.data_type());
238239

239240
parallel_nd(G, MB, OC, OD, OH, OW,
240-
[=](dim_t g, dim_t mb, dim_t oc, dim_t od, dim_t oh, dim_t ow) {
241+
[= WA_THIS_COPY_CAPTURE](
242+
dim_t g, dim_t mb, dim_t oc, dim_t od, dim_t oh, dim_t ow) {
241243
int acc = 0;
242244
if (src_d.is_plain() && weights_d.is_plain() && src_ic_stride == 1
243245
&& weights_kw_stride == 1)

src/cpu/ref_eltwise.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <assert.h>
1818

1919
#include "common/c_types_map.hpp"
20+
#include "common/compiler_workarounds.hpp"
2021
#include "common/dnnl_thread.hpp"
2122
#include "common/math_utils.hpp"
2223
#include "common/type_helpers.hpp"
@@ -62,8 +63,9 @@ status_t ref_eltwise_fwd_t::execute_forward_generic(
6263
const float beta = pd()->desc()->beta;
6364
const int ndims = pd()->ndims();
6465

65-
parallel_nd(
66-
MB, C, D, H, W, [=](dim_t n, dim_t c, dim_t d, dim_t h, dim_t w) {
66+
parallel_nd(MB, C, D, H, W,
67+
[= WA_THIS_COPY_CAPTURE](
68+
dim_t n, dim_t c, dim_t d, dim_t h, dim_t w) {
6769
auto data_p_off = DATA_OFF(src_d, n, c, d, h, w);
6870
const float s
6971
= io::load_float_value(src_d.data_type(), src, data_p_off);

src/cpu/ref_layer_normalization.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <math.h>
1919

2020
#include "common/c_types_map.hpp"
21+
#include "common/compiler_workarounds.hpp"
2122
#include "common/dnnl_thread.hpp"
2223
#include "common/type_helpers.hpp"
2324

@@ -76,7 +77,7 @@ status_t ref_layer_normalization_fwd_t::execute_forward(
7677
return status::success;
7778
}
7879

79-
parallel_nd(N, [=](dim_t n) {
80+
parallel_nd(N, [= WA_THIS_COPY_CAPTURE](dim_t n) {
8081
const size_t s_off = stat_d.off_l(n);
8182
auto v_mean = (calculate_stats || skip_mean) ? 0 : mean[s_off];
8283
auto v_variance = calculate_stats ? 0 : variance[s_off];

src/cpu/ref_reduction.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <math.h>
1818

1919
#include "common/c_types_map.hpp"
20+
#include "common/compiler_workarounds.hpp"
2021
#include "common/dnnl_thread.hpp"
2122
#include "common/nstl.hpp"
2223

@@ -169,7 +170,7 @@ status_t ref_reduction_t::execute_ref(const exec_ctx_t &ctx) const {
169170
}
170171
}
171172

172-
parallel_nd(idle_size, [=](dim_t l_offset) {
173+
parallel_nd(idle_size, [= WA_THIS_COPY_CAPTURE](dim_t l_offset) {
173174
dims_t idle_pos;
174175
utils::l_dims_by_l_offset(idle_pos, l_offset, dst_mdw.dims(), ndims);
175176

src/cpu/ref_softmax.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <math.h>
2020

2121
#include "common/c_types_map.hpp"
22+
#include "common/compiler_workarounds.hpp"
2223
#include "common/dnnl_thread.hpp"
2324
#include "common/type_helpers.hpp"
2425

@@ -78,7 +79,8 @@ status_t ref_softmax_fwd_t::execute_forward_dense(const exec_ctx_t &ctx) const {
7879

7980
const int nthr = pd()->nthr_;
8081

81-
parallel_nd_ext(nthr, outer_size_, [=](int ithr, int, dim_t ou) {
82+
parallel_nd_ext(nthr, outer_size_,
83+
[= WA_THIS_COPY_CAPTURE](int ithr, int, dim_t ou) {
8284
const void *src_data = reinterpret_cast<const char *>(src)
8385
+ ou * ou_stride * src_dt_size;
8486
void *dst_data
@@ -251,7 +253,8 @@ status_t ref_softmax_fwd_t::execute_forward_generic(
251253
const auto axis_size = pd()->axis_size(true);
252254
const int nthr = pd()->nthr_;
253255

254-
parallel_nd_ext(nthr, outer_size_, [=](int ithr, int, dim_t ou) {
256+
parallel_nd_ext(nthr, outer_size_,
257+
[= WA_THIS_COPY_CAPTURE](int ithr, int, dim_t ou) {
255258
const dim_t thr_shift = ithr * axis_size;
256259

257260
float space_max_val = 0, space_denom_val = 0;
@@ -344,7 +347,7 @@ status_t ref_softmax_bwd_t::execute_backward_dense(
344347
// previous dimension.
345348
const auto ou_stride = pd()->axis_size();
346349

347-
parallel_nd(outer_size_, [=](dim_t ou) {
350+
parallel_nd(outer_size_, [= WA_THIS_COPY_CAPTURE](dim_t ou) {
348351
float sbr = 0;
349352
size_t off = ou * ou_stride;
350353
if (pd()->is_softmax()) {
@@ -412,7 +415,8 @@ status_t ref_softmax_bwd_t::execute_backward_generic(
412415
ctx.zero_pad_output(DNNL_ARG_DIFF_SRC);
413416
}
414417

415-
parallel_nd(outer_size_, inner_size_, [=](dim_t ou, dim_t in) {
418+
parallel_nd(outer_size_, inner_size_,
419+
[= WA_THIS_COPY_CAPTURE](dim_t ou, dim_t in) {
416420
dim_t ou_in_offset = ou * channels_ * inner_size_ + in;
417421
float sbr = 0;
418422
for (int c = 0; c < channels_; ++c) {

src/cpu/simple_layer_normalization.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <math.h>
1919

2020
#include "common/c_types_map.hpp"
21+
#include "common/compiler_workarounds.hpp"
2122
#include "common/dnnl_thread.hpp"
2223
#include "common/reorder.hpp"
2324
#include "common/type_helpers.hpp"
@@ -133,7 +134,7 @@ status_t simple_layer_normalization_fwd_t::execute_forward(
133134
const auto eps = pd()->desc()->layer_norm_epsilon;
134135
const auto save_stats = pd()->is_training();
135136

136-
parallel(0, [=](const int ithr, const int nthr) {
137+
parallel(0, [= WA_THIS_COPY_CAPTURE](const int ithr, const int nthr) {
137138
dim_t N_start = 0, N_end = 0;
138139
balance211(N, nthr, ithr, N_start, N_end);
139140
const char *const __restrict src_ptr

0 commit comments

Comments
 (0)