Skip to content

Commit e1e3859

Browse files
committed
remove custom attr checker and fix code format
1 parent 3c0f079 commit e1e3859

File tree

5 files changed

+153
-210
lines changed

5 files changed

+153
-210
lines changed

paddle/operators/math/pooling.cc

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Pool2dFunctor<platform::CPUPlace, PoolProcess, T> {
2424
void operator()(const platform::DeviceContext& context,
2525
const framework::Tensor& input, framework::Tensor& output,
2626
std::vector<int>& ksize, std::vector<int>& strides,
27-
std::vector<int>& paddings, PoolProcess pool_compute) {
27+
std::vector<int>& paddings, PoolProcess pool_process) {
2828
const int batch_size = input.dims()[0];
2929
const int input_height = input.dims()[2];
3030
const int input_width = input.dims()[3];
@@ -54,14 +54,15 @@ class Pool2dFunctor<platform::CPUPlace, PoolProcess, T> {
5454
int wstart = pw * stride_width - padding_width;
5555
int wend = std::min(wstart + ksize_width, input_width);
5656
wstart = std::max(wstart, 0);
57-
T ele = pool_compute.initial();
57+
58+
T ele = pool_process.initial();
5859
for (int h = hstart; h < hend; ++h) {
5960
for (int w = wstart; w < wend; ++w) {
60-
pool_compute.compute(ele, input_data[h * input_width + w]);
61+
pool_process.compute(ele, input_data[h * input_width + w]);
6162
}
6263
}
6364
int pool_size = (hend - hstart) * (wend - wstart);
64-
pool_compute.finalize(ele, (static_cast<T>(pool_size)));
65+
pool_process.finalize(ele, (static_cast<T>(pool_size)));
6566
output_data[ph * output_width + pw] = ele;
6667
}
6768
}
@@ -80,7 +81,7 @@ class Pool2dGradFunctor<platform::CPUPlace, PoolProcess, T> {
8081
const framework::Tensor& output,
8182
const framework::Tensor& output_grad, std::vector<int>& ksize,
8283
std::vector<int>& strides, std::vector<int>& paddings,
83-
PoolProcess pool_compute) {
84+
PoolProcess pool_grad_process) {
8485
const int batch_size = input.dims()[0];
8586
const int input_height = input.dims()[2];
8687
const int input_width = input.dims()[3];
@@ -115,11 +116,12 @@ class Pool2dGradFunctor<platform::CPUPlace, PoolProcess, T> {
115116
float scale = 1.0 / pool_size;
116117
for (int h = hstart; h < hend; ++h) {
117118
for (int w = wstart; w < wend; ++w) {
118-
pool_compute.compute(input_data[h * input_width + w],
119-
output_data[ph * output_width + pw],
120-
output_grad_data[ph * output_width + pw],
121-
input_grad_data[h * input_width + w],
122-
static_cast<T>(scale));
119+
pool_grad_process.compute(
120+
input_data[h * input_width + w],
121+
output_data[ph * output_width + pw],
122+
output_grad_data[ph * output_width + pw],
123+
input_grad_data[h * input_width + w],
124+
static_cast<T>(scale));
123125
}
124126
}
125127
}
@@ -198,29 +200,29 @@ template class MaxPool2dGradFunctor<platform::CPUPlace, float>;
198200
// template class MaxPool2dGradFunctor<platform::CPUPlace, double>;
199201

200202
template class Pool2dFunctor<platform::CPUPlace,
201-
paddle::operators::math::maxPool<float>, float>;
203+
paddle::operators::math::MaxPool<float>, float>;
202204
template class Pool2dFunctor<platform::CPUPlace,
203-
paddle::operators::math::avgPool<float>, float>;
205+
paddle::operators::math::AvgPool<float>, float>;
204206
template class Pool2dGradFunctor<
205-
platform::CPUPlace, paddle::operators::math::maxPoolGrad<float>, float>;
207+
platform::CPUPlace, paddle::operators::math::MaxPoolGrad<float>, float>;
206208
template class Pool2dGradFunctor<
207-
platform::CPUPlace, paddle::operators::math::avgPoolGrad<float>, float>;
209+
platform::CPUPlace, paddle::operators::math::AvgPoolGrad<float>, float>;
208210
template class Pool2dFunctor<platform::CPUPlace,
209-
paddle::operators::math::maxPool<double>, double>;
211+
paddle::operators::math::MaxPool<double>, double>;
210212
template class Pool2dFunctor<platform::CPUPlace,
211-
paddle::operators::math::avgPool<double>, double>;
213+
paddle::operators::math::AvgPool<double>, double>;
212214
template class Pool2dGradFunctor<
213-
platform::CPUPlace, paddle::operators::math::maxPoolGrad<double>, double>;
215+
platform::CPUPlace, paddle::operators::math::MaxPoolGrad<double>, double>;
214216
template class Pool2dGradFunctor<
215-
platform::CPUPlace, paddle::operators::math::avgPoolGrad<double>, double>;
217+
platform::CPUPlace, paddle::operators::math::AvgPoolGrad<double>, double>;
216218

217219
template <typename PoolProcess, class T>
218220
class Pool3dFunctor<platform::CPUPlace, PoolProcess, T> {
219221
public:
220222
void operator()(const platform::DeviceContext& context,
221223
const framework::Tensor& input, framework::Tensor& output,
222224
std::vector<int>& ksize, std::vector<int>& strides,
223-
std::vector<int>& paddings, PoolProcess pool_compute) {
225+
std::vector<int>& paddings, PoolProcess pool_process) {
224226
const int batch_size = input.dims()[0];
225227
const int input_depth = input.dims()[2];
226228
const int input_height = input.dims()[3];
@@ -260,19 +262,19 @@ class Pool3dFunctor<platform::CPUPlace, PoolProcess, T> {
260262
int wend = std::min(wstart + ksize_width, input_width);
261263
wstart = std::max(wstart, 0);
262264
int output_idx = (pd * output_height + ph) * output_width + pw;
263-
T ele = pool_compute.initial();
265+
T ele = pool_process.initial();
264266
for (int d = dstart; d < dend; ++d) {
265267
for (int h = hstart; h < hend; ++h) {
266268
for (int w = wstart; w < wend; ++w) {
267-
pool_compute.compute(
269+
pool_process.compute(
268270
ele,
269271
input_data[(d * input_height + h) * input_width + w]);
270272
}
271273
}
272274
}
273275
int pool_size =
274276
(dend - dstart) * (hend - hstart) * (wend - wstart);
275-
pool_compute.finalize(ele, static_cast<T>(pool_size));
277+
pool_process.finalize(ele, static_cast<T>(pool_size));
276278
output_data[output_idx] = ele;
277279
}
278280
}
@@ -292,7 +294,7 @@ class Pool3dGradFunctor<platform::CPUPlace, PoolProcess, T> {
292294
const framework::Tensor& output,
293295
const framework::Tensor& output_grad, std::vector<int>& ksize,
294296
std::vector<int>& strides, std::vector<int>& paddings,
295-
PoolProcess pool_compute) {
297+
PoolProcess pool_grad_process) {
296298
const int batch_size = input.dims()[0];
297299
const int input_depth = input.dims()[2];
298300
const int input_height = input.dims()[3];
@@ -343,7 +345,7 @@ class Pool3dGradFunctor<platform::CPUPlace, PoolProcess, T> {
343345
int input_idx = (d * input_height + h) * input_width + w;
344346
int output_idx =
345347
(pd * output_height + ph) * output_width + pw;
346-
pool_compute.compute(
348+
pool_grad_process.compute(
347349
input_data[input_idx], output_data[output_idx],
348350
output_grad_data[output_idx],
349351
input_grad_data[input_idx], static_cast<T>(scale));
@@ -441,21 +443,21 @@ template class MaxPool3dGradFunctor<platform::CPUPlace, float>;
441443
// template class MaxPool3dGradFunctor<platform::CPUPlace, double>;
442444

443445
template class Pool3dFunctor<platform::CPUPlace,
444-
paddle::operators::math::maxPool<float>, float>;
446+
paddle::operators::math::MaxPool<float>, float>;
445447
template class Pool3dFunctor<platform::CPUPlace,
446-
paddle::operators::math::avgPool<float>, float>;
448+
paddle::operators::math::AvgPool<float>, float>;
447449
template class Pool3dGradFunctor<
448-
platform::CPUPlace, paddle::operators::math::maxPoolGrad<float>, float>;
450+
platform::CPUPlace, paddle::operators::math::MaxPoolGrad<float>, float>;
449451
template class Pool3dGradFunctor<
450-
platform::CPUPlace, paddle::operators::math::avgPoolGrad<float>, float>;
452+
platform::CPUPlace, paddle::operators::math::AvgPoolGrad<float>, float>;
451453
template class Pool3dFunctor<platform::CPUPlace,
452-
paddle::operators::math::maxPool<double>, double>;
454+
paddle::operators::math::MaxPool<double>, double>;
453455
template class Pool3dFunctor<platform::CPUPlace,
454-
paddle::operators::math::avgPool<double>, double>;
456+
paddle::operators::math::AvgPool<double>, double>;
455457
template class Pool3dGradFunctor<
456-
platform::CPUPlace, paddle::operators::math::maxPoolGrad<double>, double>;
458+
platform::CPUPlace, paddle::operators::math::MaxPoolGrad<double>, double>;
457459
template class Pool3dGradFunctor<
458-
platform::CPUPlace, paddle::operators::math::avgPoolGrad<double>, double>;
460+
platform::CPUPlace, paddle::operators::math::AvgPoolGrad<double>, double>;
459461
} // namespace math
460462
} // namespace operators
461463
} // namespace paddle

0 commit comments

Comments
 (0)