Skip to content

Commit 989cc2a

Browse files
authored
Merge pull request #12913 from luotao1/concat
enhance the forward of concat op
2 parents 8650f6f + e999c74 commit 989cc2a

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

paddle/fluid/operators/math/concat.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ class ConcatFunctor<platform::CPUDeviceContext, T> {
4848
auto cpu_place = boost::get<platform::CPUPlace>(context.GetPlace());
4949

5050
// computation
51-
for (int k = 0; k < out_rows; ++k) {
52-
T* dst_ptr = output->data<T>() + k * out_cols;
53-
int col_idx = 0;
54-
for (int j = 0; j < num; ++j) {
55-
int col_len = input_cols[j];
56-
const T* src_prt = input[j].data<T>() + k * col_len;
57-
memory::Copy(cpu_place, dst_ptr + col_idx, cpu_place, src_prt,
58-
sizeof(T) * col_len);
59-
col_idx += col_len;
51+
auto output_data = output->data<T>();
52+
int col_idx = 0;
53+
for (int j = 0; j < num; ++j) {
54+
int col_len = input_cols[j];
55+
auto input_data = input[j].data<T>();
56+
for (int k = 0; k < out_rows; ++k) {
57+
memory::Copy(cpu_place, output_data + k * out_cols + col_idx, cpu_place,
58+
input_data + k * col_len, sizeof(T) * col_len);
6059
}
60+
col_idx += col_len;
6161
}
6262
}
6363
};

0 commit comments

Comments
 (0)