提交 f1ab13bd 编写于 作者: C chengduoZH

refine

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