Skip to content

Commit 36da825

Browse files
committed
Add code comments
1 parent e21e564 commit 36da825

File tree

2 files changed

+102
-2
lines changed

2 files changed

+102
-2
lines changed

paddle/operators/math/pooling.cc

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ namespace paddle {
1818
namespace operators {
1919
namespace math {
2020

21+
/*
22+
* All tensors are in NCHW format.
23+
* Ksize, strides, paddings are two elements. These two elements represent
24+
* height and width, respectively.
25+
*/
2126
template <typename PoolProcess, typename T>
2227
class Pool2dFunctor<platform::CPUPlace, PoolProcess, T> {
2328
public:
@@ -73,6 +78,11 @@ class Pool2dFunctor<platform::CPUPlace, PoolProcess, T> {
7378
}
7479
};
7580

81+
/*
82+
* All tensors are in NCHW format.
83+
* Ksize, strides, paddings are two elements. These two elements represent height
84+
* and width, respectively.
85+
*/
7686
template <typename PoolProcess, class T>
7787
class Pool2dGradFunctor<platform::CPUPlace, PoolProcess, T> {
7888
public:
@@ -135,6 +145,11 @@ class Pool2dGradFunctor<platform::CPUPlace, PoolProcess, T> {
135145
}
136146
};
137147

148+
/*
149+
* All tensors are in NCHW format.
150+
* Ksize, strides, paddings are two elements. These two elements represent
151+
* height and width, respectively.
152+
*/
138153
template <class T>
139154
class MaxPool2dGradFunctor<platform::CPUPlace, T> {
140155
public:
@@ -197,7 +212,7 @@ class MaxPool2dGradFunctor<platform::CPUPlace, T> {
197212
};
198213

199214
template class MaxPool2dGradFunctor<platform::CPUPlace, float>;
200-
// template class MaxPool2dGradFunctor<platform::CPUPlace, double>;
215+
template class MaxPool2dGradFunctor<platform::CPUPlace, double>;
201216

202217
template class Pool2dFunctor<platform::CPUPlace,
203218
paddle::operators::math::MaxPool<float>, float>;
@@ -216,6 +231,11 @@ template class Pool2dGradFunctor<
216231
template class Pool2dGradFunctor<
217232
platform::CPUPlace, paddle::operators::math::AvgPoolGrad<double>, double>;
218233

234+
/*
235+
* All tensors are in NCDHW format.
236+
* Ksize, strides, paddings are three elements. These three elements represent
237+
* depth, height and width, respectively.
238+
*/
219239
template <typename PoolProcess, class T>
220240
class Pool3dFunctor<platform::CPUPlace, PoolProcess, T> {
221241
public:
@@ -286,6 +306,11 @@ class Pool3dFunctor<platform::CPUPlace, PoolProcess, T> {
286306
}
287307
};
288308

309+
/*
310+
* All tensors are in NCDHW format.
311+
* Ksize, strides, paddings are three elements. These three elements represent
312+
* depth, height and width, respectively.
313+
*/
289314
template <typename PoolProcess, class T>
290315
class Pool3dGradFunctor<platform::CPUPlace, PoolProcess, T> {
291316
public:
@@ -364,6 +389,11 @@ class Pool3dGradFunctor<platform::CPUPlace, PoolProcess, T> {
364389
}
365390
};
366391

392+
/*
393+
* All tensors are in NCDHW format.
394+
* Ksize, strides, paddings are three elements. These three elements represent
395+
* depth, height and width, respectively.
396+
*/
367397
template <class T>
368398
class MaxPool3dGradFunctor<platform::CPUPlace, T> {
369399
public:
@@ -440,7 +470,7 @@ class MaxPool3dGradFunctor<platform::CPUPlace, T> {
440470
};
441471

442472
template class MaxPool3dGradFunctor<platform::CPUPlace, float>;
443-
// template class MaxPool3dGradFunctor<platform::CPUPlace, double>;
473+
template class MaxPool3dGradFunctor<platform::CPUPlace, double>;
444474

445475
template class Pool3dFunctor<platform::CPUPlace,
446476
paddle::operators::math::MaxPool<float>, float>;
@@ -459,6 +489,11 @@ template class Pool3dGradFunctor<
459489
template class Pool3dGradFunctor<
460490
platform::CPUPlace, paddle::operators::math::AvgPoolGrad<double>, double>;
461491

492+
/*
493+
* All tensors are in NCHW format.
494+
* Ksize, strides, paddings are two elements. These two elements represent
495+
* height and width, respectively.
496+
*/
462497
template <typename T>
463498
class MaxPool2dWithIndexFunctor<platform::CPUPlace, T> {
464499
public:
@@ -519,6 +554,11 @@ class MaxPool2dWithIndexFunctor<platform::CPUPlace, T> {
519554
}
520555
};
521556

557+
/*
558+
* All tensors are in NCHW format.
559+
* Ksize, strides, paddings are two elements. These two elements represent
560+
* height and width, respectively.
561+
*/
522562
template <typename T>
523563
class MaxPool2dWithIndexGradFunctor<platform::CPUPlace, T> {
524564
public:
@@ -563,6 +603,11 @@ template class MaxPool2dWithIndexGradFunctor<platform::CPUPlace, float>;
563603
template class MaxPool2dWithIndexFunctor<platform::CPUPlace, double>;
564604
template class MaxPool2dWithIndexGradFunctor<platform::CPUPlace, double>;
565605

606+
/*
607+
* All tensors are in NCDHW format.
608+
* Ksize, strides, paddings are three elements. These three elements represent
609+
* depth, height and width, respectively.
610+
*/
566611
template <typename T>
567612
class MaxPool3dWithIndexFunctor<platform::CPUPlace, T> {
568613
public:
@@ -637,6 +682,11 @@ class MaxPool3dWithIndexFunctor<platform::CPUPlace, T> {
637682
}
638683
};
639684

685+
/*
686+
* All tensors are in NCDHW format.
687+
* Ksize, strides, paddings are three elements. These three elements represent
688+
* depth, height and width, respectively.
689+
*/
640690
template <typename T>
641691
class MaxPool3dWithIndexGradFunctor<platform::CPUPlace, T> {
642692
public:

paddle/operators/math/pooling.cu

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ __global__ void KernelMaxPool2DGrad(
149149
}
150150
}
151151

152+
/*
153+
* All tensors are in NCHW format.
154+
* Ksize, strides, paddings are two elements. These two elements represent
155+
* height and width, respectively.
156+
*/
152157
template <typename PoolProcess, typename T>
153158
class Pool2dFunctor<platform::GPUPlace, PoolProcess, T> {
154159
public:
@@ -190,6 +195,11 @@ class Pool2dFunctor<platform::GPUPlace, PoolProcess, T> {
190195
}
191196
};
192197

198+
/*
199+
* All tensors are in NCHW format.
200+
* Ksize, strides, paddings are two elements. These two elements represent
201+
* height and width, respectively.
202+
*/
193203
template <typename PoolProcess, typename T>
194204
class Pool2dGradFunctor<platform::GPUPlace, PoolProcess, T> {
195205
public:
@@ -234,6 +244,11 @@ class Pool2dGradFunctor<platform::GPUPlace, PoolProcess, T> {
234244
}
235245
};
236246

247+
/*
248+
* All tensors are in NCHW format.
249+
* Ksize, strides, paddings are two elements. These two elements represent
250+
* height and width, respectively.
251+
*/
237252
template <typename T>
238253
class MaxPool2dGradFunctor<platform::GPUPlace, T> {
239254
public:
@@ -456,6 +471,11 @@ __global__ void KernelMaxPool3DGrad(
456471
}
457472
}
458473

474+
/*
475+
* All tensors are in NCDHW format.
476+
* Ksize, strides, paddings are three elements. These three elements represent
477+
* depth, height and width, respectively.
478+
*/
459479
template <typename PoolProcess, class T>
460480
class Pool3dFunctor<platform::GPUPlace, PoolProcess, T> {
461481
public:
@@ -504,6 +524,11 @@ class Pool3dFunctor<platform::GPUPlace, PoolProcess, T> {
504524
}
505525
};
506526

527+
/*
528+
* All tensors are in NCDHW format.
529+
* Ksize, strides, paddings are three elements. These three elements represent
530+
* depth, height and width, respectively.
531+
*/
507532
template <typename PoolProcess, class T>
508533
class Pool3dGradFunctor<platform::GPUPlace, PoolProcess, T> {
509534
public:
@@ -556,6 +581,11 @@ class Pool3dGradFunctor<platform::GPUPlace, PoolProcess, T> {
556581
}
557582
};
558583

584+
/*
585+
* All tensors are in NCDHW format.
586+
* Ksize, strides, paddings are three elements. These three elements represent
587+
* depth, height and width, respectively.
588+
*/
559589
template <class T>
560590
class MaxPool3dGradFunctor<platform::GPUPlace, T> {
561591
public:
@@ -709,6 +739,11 @@ __global__ void KernelMaxPool2DWithIdxGrad(
709739
}
710740
}
711741

742+
/*
743+
* All tensors are in NCHW format.
744+
* Ksize, strides, paddings are two elements. These two elements represent
745+
* height and width, respectively.
746+
*/
712747
template <typename T>
713748
class MaxPool2dWithIndexFunctor<platform::GPUPlace, T> {
714749
public:
@@ -750,6 +785,11 @@ class MaxPool2dWithIndexFunctor<platform::GPUPlace, T> {
750785
}
751786
};
752787

788+
/*
789+
* All tensors are in NCHW format.
790+
* Ksize, strides, paddings are two elements. These two elements represent
791+
* height and width, respectively.
792+
*/
753793
template <typename T>
754794
class MaxPool2dWithIndexGradFunctor<platform::GPUPlace, T> {
755795
public:
@@ -903,6 +943,11 @@ __global__ void KernelMaxPool3DWithIdxGrad(
903943
}
904944
}
905945

946+
/*
947+
* All tensors are in NCDHW format.
948+
* Ksize, strides, paddings are three elements. These three elements represent
949+
* depth, height and width, respectively.
950+
*/
906951
template <typename T>
907952
class MaxPool3dWithIndexFunctor<platform::GPUPlace, T> {
908953
public:
@@ -951,6 +996,11 @@ class MaxPool3dWithIndexFunctor<platform::GPUPlace, T> {
951996
}
952997
};
953998

999+
/*
1000+
* All tensors are in NCDHW format.
1001+
* Ksize, strides, paddings are three elements. These three elements represent
1002+
* depth, height and width, respectively.
1003+
*/
9541004
template <typename T>
9551005
class MaxPool3dWithIndexGradFunctor<platform::GPUPlace, T> {
9561006
public:

0 commit comments

Comments
 (0)