Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization of pool2d grad #35389

Merged
merged 19 commits into from
Sep 19, 2021
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions paddle/fluid/operators/math/pooling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,8 @@ 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[ph * output_width + pw],
output_grad_data[ph * output_width + pw],
input_data[h * input_width + w], output_data,
output_grad_data, ph * output_width + pw,
static_cast<T>(scale),
input_grad_data + h * input_width + w);
}
Expand Down Expand Up @@ -397,9 +396,8 @@ 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[ph * output_width + pw],
output_grad_data[ph * output_width + pw],
input_data[h * input_width + w], output_data,
output_grad_data, ph * output_width + pw,
static_cast<T>(scale),
input_grad_data + h * input_width + w);
}
Expand Down Expand Up @@ -451,10 +449,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_idx],
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_grad_data, output_idx,
static_cast<T>(scale),
input_grad_data + input_idx);
}
}
}
Expand Down Expand Up @@ -1051,10 +1049,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_idx],
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_grad_data,
output_idx, static_cast<T>(scale),
input_grad_data + input_idx);
}
}
}
Expand Down Expand Up @@ -1165,8 +1163,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_idx],
output_grad_data[output_idx], static_cast<T>(scale),
input_data[input_idx], output_data, output_grad_data,
output_idx, static_cast<T>(scale),
input_grad_data + input_idx);
}
}
Expand Down Expand Up @@ -1242,8 +1240,8 @@ class Pool3dGradFunctor<platform::CPUDeviceContext, PoolProcess, T> {
output_channels +
c;
pool_grad_process.compute(
input_data[input_idx], output_data[output_idx],
output_grad_data[output_idx], static_cast<T>(scale),
input_data[input_idx], output_data, output_grad_data,
output_idx, static_cast<T>(scale),
input_grad_data + input_idx);
}
}
Expand Down
Loading