提交 d8e00fac 编写于 作者: T tensor-tang

reuse im_size

上级 179dd0cb
...@@ -54,12 +54,13 @@ class Im2ColFunctor<paddle::operators::math::ColFormat::kCFO, ...@@ -54,12 +54,13 @@ class Im2ColFunctor<paddle::operators::math::ColFormat::kCFO,
if (stride[0] == 1 && stride[1] == 1 && dilation[0] == 1 && if (stride[0] == 1 && stride[1] == 1 && dilation[0] == 1 &&
dilation[1] == 1 && padding[0] == 0 && padding[1] == 0) { dilation[1] == 1 && padding[0] == 0 && padding[1] == 0) {
int col_matrix_width = output_width * output_height; int col_matrix_width = output_width * output_height;
int im_size = im_height * im_width;
size_t copy_size = sizeof(T) * output_width; size_t copy_size = sizeof(T) * output_width;
for (int oh = 0; oh < output_height; ++oh) { for (int oh = 0; oh < output_height; ++oh) {
const T* im_data_start = im_data + oh * im_width; const T* im_data_start = im_data + oh * im_width;
T* dst_data = col_data + oh * output_width; T* dst_data = col_data + oh * output_width;
for (int ic = 0; ic < im_channels; ++ic) { for (int ic = 0; ic < im_channels; ++ic) {
const T* src_data = im_data_start + ic * im_height * im_width; const T* src_data = im_data_start + ic * im_size;
for (int kh = 0; kh < filter_height; ++kh) { for (int kh = 0; kh < filter_height; ++kh) {
for (int kw = 0; kw < filter_width; ++kw) { for (int kw = 0; kw < filter_width; ++kw) {
std::memcpy(dst_data, src_data + kw, copy_size); std::memcpy(dst_data, src_data + kw, copy_size);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册