Skip to content

Commit d8e00fa

Browse files
committed
reuse im_size
1 parent 179dd0c commit d8e00fa

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

paddle/fluid/operators/math/im2col.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,13 @@ class Im2ColFunctor<paddle::operators::math::ColFormat::kCFO,
5454
if (stride[0] == 1 && stride[1] == 1 && dilation[0] == 1 &&
5555
dilation[1] == 1 && padding[0] == 0 && padding[1] == 0) {
5656
int col_matrix_width = output_width * output_height;
57+
int im_size = im_height * im_width;
5758
size_t copy_size = sizeof(T) * output_width;
5859
for (int oh = 0; oh < output_height; ++oh) {
5960
const T* im_data_start = im_data + oh * im_width;
6061
T* dst_data = col_data + oh * output_width;
6162
for (int ic = 0; ic < im_channels; ++ic) {
62-
const T* src_data = im_data_start + ic * im_height * im_width;
63+
const T* src_data = im_data_start + ic * im_size;
6364
for (int kh = 0; kh < filter_height; ++kh) {
6465
for (int kw = 0; kw < filter_width; ++kw) {
6566
std::memcpy(dst_data, src_data + kw, copy_size);

0 commit comments

Comments
 (0)