提交 f1ab13bd 编写于 作者: C chengduoZH

refine

上级 293b292e
...@@ -105,8 +105,8 @@ class MidWiseTransformIterator<T, platform::CPUDeviceContext> { ...@@ -105,8 +105,8 @@ class MidWiseTransformIterator<T, platform::CPUDeviceContext> {
++j_; ++j_;
if (UNLIKELY(j_ == post_)) { if (UNLIKELY(j_ == post_)) {
++i_; ++i_;
j_ = 0;
if (UNLIKELY(i_ == n_)) { if (UNLIKELY(i_ == n_)) {
j_ = 0;
i_ = 0; i_ = 0;
} }
} }
...@@ -127,10 +127,10 @@ class MidWiseTransformIterator<T, platform::CPUDeviceContext> { ...@@ -127,10 +127,10 @@ class MidWiseTransformIterator<T, platform::CPUDeviceContext> {
private: private:
const T* ptr_; const T* ptr_;
int i_; int64_t i_;
int64_t j_; int64_t j_;
int64_t n_; int64_t n_;
int post_; int64_t post_;
}; };
#ifdef __NVCC__ #ifdef __NVCC__
......
...@@ -66,10 +66,10 @@ class Im2ColFunctor<paddle::operators::math::ColFormat::kCFO, ...@@ -66,10 +66,10 @@ class Im2ColFunctor<paddle::operators::math::ColFormat::kCFO,
int c_im = 0; int c_im = 0;
for (int c = 0; c < channels_col; ++c) { for (int c = 0; c < channels_col; ++c) {
++w_offset; ++w_offset;
if (UNLIKELY(w_offset == filter_width)) { if (w_offset == filter_width) {
w_offset = 0; w_offset = 0;
++h_offset; ++h_offset;
if (UNLIKELY(h_offset == filter_height)) { if (h_offset == filter_height) {
h_offset = 0; h_offset = 0;
++c_im; ++c_im;
} }
...@@ -140,10 +140,10 @@ class Col2ImFunctor<paddle::operators::math::ColFormat::kCFO, ...@@ -140,10 +140,10 @@ class Col2ImFunctor<paddle::operators::math::ColFormat::kCFO,
int c_im = 0; int c_im = 0;
for (int c = 0; c < channels_col; ++c) { for (int c = 0; c < channels_col; ++c) {
++w_offset; ++w_offset;
if (UNLIKELY(w_offset == filter_width)) { if (w_offset == filter_width) {
w_offset = 0; w_offset = 0;
++h_offset; ++h_offset;
if (UNLIKELY(h_offset == filter_height)) { if (h_offset == filter_height) {
h_offset = 0; h_offset = 0;
++c_im; ++c_im;
} }
...@@ -214,12 +214,13 @@ class Im2ColFunctor<paddle::operators::math::ColFormat::kOCF, ...@@ -214,12 +214,13 @@ class Im2ColFunctor<paddle::operators::math::ColFormat::kOCF,
for (int channel = 0; channel < im_channels; ++channel) { for (int channel = 0; channel < im_channels; ++channel) {
for (int filter_row_idx = 0; filter_row_idx < filter_height; for (int filter_row_idx = 0; filter_row_idx < filter_height;
++filter_row_idx) { ++filter_row_idx) {
int im_row_offset =
col_row_idx * stride[0] + filter_row_idx - padding[0];
for (int filter_col_idx = 0; filter_col_idx < filter_width; for (int filter_col_idx = 0; filter_col_idx < filter_width;
++filter_col_idx) { ++filter_col_idx) {
int im_row_offset =
col_row_idx * stride[0] + filter_row_idx - padding[0];
int im_col_offset = int im_col_offset =
col_col_idx * stride[1] + filter_col_idx - padding[1]; col_col_idx * stride[1] + filter_col_idx - padding[1];
int col_offset = int col_offset =
((((col_row_idx)*col_width + col_col_idx) * im_channels + ((((col_row_idx)*col_width + col_col_idx) * im_channels +
channel) * channel) *
...@@ -286,12 +287,13 @@ class Col2ImFunctor<paddle::operators::math::ColFormat::kOCF, ...@@ -286,12 +287,13 @@ class Col2ImFunctor<paddle::operators::math::ColFormat::kOCF,
for (int channel = 0; channel < im_channels; ++channel) { for (int channel = 0; channel < im_channels; ++channel) {
for (int filter_row_idx = 0; filter_row_idx < filter_height; for (int filter_row_idx = 0; filter_row_idx < filter_height;
++filter_row_idx) { ++filter_row_idx) {
int im_row_offset =
col_row_idx * stride[0] + filter_row_idx - padding[0];
for (int filter_col_idx = 0; filter_col_idx < filter_width; for (int filter_col_idx = 0; filter_col_idx < filter_width;
++filter_col_idx) { ++filter_col_idx) {
int im_row_offset =
col_row_idx * stride[0] + filter_row_idx - padding[0];
int im_col_offset = int im_col_offset =
col_col_idx * stride[1] + filter_col_idx - padding[1]; col_col_idx * stride[1] + filter_col_idx - padding[1];
int col_offset = int col_offset =
(((col_row_idx * col_width + col_col_idx) * im_channels + (((col_row_idx * col_width + col_col_idx) * im_channels +
channel) * channel) *
...@@ -299,6 +301,7 @@ class Col2ImFunctor<paddle::operators::math::ColFormat::kOCF, ...@@ -299,6 +301,7 @@ class Col2ImFunctor<paddle::operators::math::ColFormat::kOCF,
filter_row_idx) * filter_row_idx) *
filter_width + filter_width +
filter_col_idx; filter_col_idx;
if (im_row_offset >= 0 && im_row_offset < im_height && if (im_row_offset >= 0 && im_row_offset < im_height &&
im_col_offset >= 0 && im_col_offset < im_width) { im_col_offset >= 0 && im_col_offset < im_width) {
int im_offset = int im_offset =
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册