Skip to content

Commit

Permalink
rerun trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesLim-sy committed Sep 18, 2021
1 parent 8004f32 commit d8e4f42
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 27 deletions.
34 changes: 18 additions & 16 deletions paddle/fluid/operators/math/pooling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,9 @@ class Pool2dGradFunctor<platform::CPUDeviceContext, PoolProcess, T> {
for (int h = hstart; h < hend; ++h) {
for (int w = wstart; w < wend; ++w) {
pool_grad_process.compute(
input_data[h * input_width + w], output_data,
output_grad_data, ph * output_width + pw,
input_data[h * input_width + w],
output_data[ph * output_width + pw],
output_grad_data[ph * output_width + pw],
static_cast<T>(scale),
input_grad_data + h * input_width + w);
}
Expand Down Expand Up @@ -396,8 +397,9 @@ class Pool2dGradFunctor<platform::CPUDeviceContext, PoolProcess, T> {
for (int h = hstart; h < hend; ++h) {
for (int w = wstart; w < wend; ++w) {
pool_grad_process.compute(
input_data[h * input_width + w], output_data,
output_grad_data, ph * output_width + pw,
input_data[h * input_width + w],
output_data[ph * output_width + pw],
output_grad_data[ph * output_width + pw],
static_cast<T>(scale),
input_grad_data + h * input_width + w);
}
Expand Down Expand Up @@ -449,10 +451,10 @@ class Pool2dGradFunctor<platform::CPUDeviceContext, PoolProcess, T> {
h * input_width * input_channels + w * input_channels + c;
auto output_idx = ph * output_width * output_channels +
pw * output_channels + c;
pool_grad_process.compute(input_data[input_idx], output_data,
output_grad_data, output_idx,
static_cast<T>(scale),
input_grad_data + input_idx);
pool_grad_process.compute(
input_data[input_idx], output_data[output_idx],
output_grad_data[output_idx], static_cast<T>(scale),
input_grad_data + input_idx);
}
}
}
Expand Down Expand Up @@ -1049,10 +1051,10 @@ class Pool3dGradFunctor<platform::CPUDeviceContext, PoolProcess, T> {
int input_idx = (d * input_height + h) * input_width + w;
int output_idx =
(pd * output_height + ph) * output_width + pw;
pool_grad_process.compute(input_data[input_idx],
output_data, output_grad_data,
output_idx, static_cast<T>(scale),
input_grad_data + input_idx);
pool_grad_process.compute(
input_data[input_idx], output_data[output_idx],
output_grad_data[output_idx], static_cast<T>(scale),
input_grad_data + input_idx);
}
}
}
Expand Down Expand Up @@ -1163,8 +1165,8 @@ class Pool3dGradFunctor<platform::CPUDeviceContext, PoolProcess, T> {
int output_idx =
(pd * output_height + ph) * output_width + pw;
pool_grad_process.compute(
input_data[input_idx], output_data, output_grad_data,
output_idx, static_cast<T>(scale),
input_data[input_idx], output_data[output_idx],
output_grad_data[output_idx], static_cast<T>(scale),
input_grad_data + input_idx);
}
}
Expand Down Expand Up @@ -1240,8 +1242,8 @@ class Pool3dGradFunctor<platform::CPUDeviceContext, PoolProcess, T> {
output_channels +
c;
pool_grad_process.compute(
input_data[input_idx], output_data, output_grad_data,
output_idx, static_cast<T>(scale),
input_data[input_idx], output_data[output_idx],
output_grad_data[output_idx], static_cast<T>(scale),
input_grad_data + input_idx);
}
}
Expand Down
17 changes: 12 additions & 5 deletions paddle/fluid/operators/math/pooling.cu
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ __global__ void KernelPool2DGrad(
int output_sub_idx =
channel_last ? tmp_idx * divmods.channel.divisor + c_offset
: tmp_idx;
pool_process.compute(input, output_data, output_grad, output_sub_idx,
T ouput_value = pool_process.use_x ? output_data[output_sub_idx]
: static_cast<T>(0);
pool_process.compute(input, ouput_value, output_grad[output_sub_idx],
static_cast<T>(1.0 / pool_size),
&input_grad_data);
}
Expand All @@ -236,8 +238,10 @@ __global__ void KernelPool2DGrad(
int output_sub_idx =
channel_last ? tmp_idx * divmods.channel.divisor + c_offset
: tmp_idx;
T ouput_value = pool_process.use_x ? output_data[output_sub_idx]
: static_cast<T>(0);
pool_process.compute(
input, output_data, output_grad, output_sub_idx,
input, ouput_value, output_grad[output_sub_idx],
static_cast<T>(1.0 / pool_size), &input_grad_data);
}
}
Expand All @@ -249,8 +253,10 @@ __global__ void KernelPool2DGrad(
int output_sub_idx =
channel_last ? tmp_idx * divmods.channel.divisor + c_offset
: tmp_idx;
T ouput_value = pool_process.use_x ? output_data[output_sub_idx]
: static_cast<T>(0);
pool_process.compute(
input, output_data, output_grad, output_sub_idx,
input, ouput_value, output_grad[output_sub_idx],
static_cast<T>(1.0 / pool_size), &input_grad_data);
}
}
Expand Down Expand Up @@ -884,8 +890,9 @@ __global__ void KernelPool3DGrad(
? ((pd * output_height + ph) * output_width + pw) * channels +
c_offset
: (pd * output_height + ph) * output_width + pw;

pool_process.compute(input, output_data, output_grad, output_sub_idx,
T ouput_value = pool_process.use_x ? output_data[output_sub_idx]
: static_cast<T>(0);
pool_process.compute(input, ouput_value, output_grad[output_sub_idx],
static_cast<T>(1.0 / pool_size),
&input_grad_data);
}
Expand Down
12 changes: 6 additions & 6 deletions paddle/fluid/operators/math/pooling.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@ template <class T>
class MaxPoolGrad {
public:
static constexpr bool use_x = true;
HOSTDEVICE inline void compute(const T& x, const T* y, const T* dy,
int out_idx, T scale, T* dx) {
*dx += dy[out_idx] * static_cast<T>(x == y[out_idx]);
HOSTDEVICE inline void compute(const T& x, const T& y, const T& dy, T scale,
T* dx) {
*dx += dy * static_cast<T>(x == y);
}
};

template <class T>
class AvgPoolGrad {
public:
static constexpr bool use_x = false;
HOSTDEVICE inline void compute(const T& x, const T* y, const T* dy,
int out_idx, T scale, T* dx) {
*dx += (scale * dy[out_idx]);
HOSTDEVICE inline void compute(const T& x, const T& y, const T& dy, T scale,
T* dx) {
*dx += (scale * dy);
}
};

Expand Down

1 comment on commit d8e4f42

@paddle-bot-old
Copy link

@paddle-bot-old paddle-bot-old bot commented on d8e4f42 Sep 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵️ CI failures summary

🔍 PR: #35389 Commit ID: d8e4f42 contains failed CI.

🔹 Failed: PR-CI-OP-benchmark

Unknown Failed
2021-09-18 14:55:29 + for op_name in '${!CHANGE_OP_MAP[@]}'
2021-09-18 14:55:29 + '[' -z squeeze,squeeze,squeeze.json,True ']'
2021-09-18 14:55:29 + for op_name in '${!CHANGE_OP_MAP[@]}'
2021-09-18 14:55:29 + '[' -z max_pool2d,max_pool2d,max_pool2d.json,True ']'
2021-09-18 14:55:29 + for op_name in '${!CHANGE_OP_MAP[@]}'
2021-09-18 14:55:29 + '[' -z flatten,flatten,flatten.json,True ']'
2021-09-18 14:55:29 + for op_name in '${!CHANGE_OP_MAP[@]}'
2021-09-18 14:55:29 + '[' -z unsqueeze,unsqueeze,unsqueeze.json,True ']'
2021-09-18 14:55:29 + for op_name in '${!CHANGE_OP_MAP[@]}'
2021-09-18 14:55:29 + '[' -z avg_pool2d,avg_pool2d,avg_pool2d.json,True ']'
2021-09-18 14:55:29 + '[' 8 -ne 0 ']'
2021-09-18 14:55:29 + LOG '[INFO] See https://github.com/PaddlePaddle/Paddle/wiki/PR-CI-OP-benchmark-Manual for details.'
2021-09-18 14:55:29 + echo '[tools/test_ci_op_benchmark.sh:275] [INFO] See https://github.com/PaddlePaddle/Paddle/wiki/PR-CI-OP-benchmark-Manual for details.'
2021-09-18 14:55:29 [tools/test_ci_op_benchmark.sh:275] [INFO] See https://github.com/PaddlePaddle/Paddle/wiki/PR-CI-OP-benchmark-Manual for details.
2021-09-18 14:55:29 + LOG '[INFO] Or you can apply for one RD (Avin0323(Recommend), Xreki, luotao1) approval to pass this PR.'
2021-09-18 14:55:29 + echo '[tools/test_ci_op_benchmark.sh:276] [INFO] Or you can apply for one RD (Avin0323(Recommend), Xreki, luotao1) approval to pass this PR.'
2021-09-18 14:55:29 [tools/test_ci_op_benchmark.sh:276] [INFO] Or you can apply for one RD (Avin0323(Recommend), Xreki, luotao1) approval to pass this PR.
2021-09-18 14:55:29 + exit 8
2021-09-18 14:55:29 {build code state=8}

Please sign in to comment.