@@ -168,9 +168,10 @@ void Pool2dOpMaker::Make() {
168
168
" be ignored." ); // TODO(Chengduo): Add checker.
169
169
// (Currently,
170
170
// TypedAttrChecker don't support vector type.)
171
- AddAttr<bool >(" global_pooling" ,
172
- " (bool, default false) Whether to use the global pooling. "
173
- " If global_pooling = true, ksize and paddings will be ignored." )
171
+ AddAttr<bool >(
172
+ " global_pooling" ,
173
+ " (bool, default false) Whether to use the global pooling. "
174
+ " If global_pooling = true, kernel size and paddings will be ignored." )
174
175
.SetDefault (false );
175
176
AddAttr<std::vector<int >>(" strides" ,
176
177
" (vector<int>, default {1, 1}), strides(height, "
@@ -182,7 +183,7 @@ void Pool2dOpMaker::Make() {
182
183
" paddings" ,
183
184
" (vector<int>, default {0,0}), paddings(height, width) of pooling "
184
185
" operator."
185
- " If global_pooling = true, paddings and ksize will be ignored." )
186
+ " If global_pooling = true, paddings and kernel size will be ignored." )
186
187
.SetDefault ({0 , 0 });
187
188
AddAttr<bool >(
188
189
" exclusive" ,
@@ -204,7 +205,7 @@ void Pool2dOpMaker::Make() {
204
205
.SetDefault (false );
205
206
AddAttr<bool >(
206
207
" ceil_mode" ,
207
- " (bool, default false) Wether to use the ceil function to calculate "
208
+ " (bool, default false) Whether to use the ceil function to calculate "
208
209
" output height and width. False is the default. If it is set to False, "
209
210
" the floor function will be used." )
210
211
.SetDefault (false );
@@ -259,31 +260,40 @@ The input(X) size and output(Out) size may be different.
259
260
W_{out} = \\frac{(W_{in} - ksize[1] + 2 * paddings[1] + strides[1] - 1)}{strides[1]} + 1
260
261
$$
261
262
262
- For exclusive = true :
263
+ For exclusive = false :
263
264
$$
264
265
hstart = i * strides[0] - paddings[0]
266
+ $$
267
+ $$
265
268
hend = hstart + ksize[0]
269
+ $$
270
+ $$
266
271
wstart = j * strides[1] - paddings[1]
272
+ $$
273
+ $$
267
274
wend = wstart + ksize[1]
275
+ $$
276
+ $$
268
277
Output(i ,j) = \\frac{sum(Input[hstart:hend, wstart:wend])}{ksize[0] * ksize[1]}
269
278
$$
270
- For exclusive = false:
279
+
280
+ For exclusive = true:
271
281
$$
272
282
hstart = max(0, i * strides[0] - paddings[0])
283
+ $$
284
+ $$
273
285
hend = min(H, hstart + ksize[0])
286
+ $$
287
+ $$
274
288
wstart = max(0, j * strides[1] - paddings[1])
289
+ $$
290
+ $$
275
291
wend = min(W, wstart + ksize[1])
292
+ $$
293
+ $$
276
294
Output(i ,j) = \\frac{sum(Input[hstart:hend, wstart:wend])}{(hend - hstart) * (wend - wstart)}
277
295
$$
278
296
279
- For adaptive = true:
280
- $$
281
- hstart = floor(i * H_{in} / H_{out})
282
- hend = ceil((i + 1) * H_{in} / H_{out})
283
- wstart = floor(j * W_{in} / W_{out})
284
- wend = ceil((j + 1) * W_{in} / W_{out})
285
- Output(i ,j) = \\frac{sum(Input[hstart:hend, wstart:wend])}{(hend - hstart) * (wend - wstart)}
286
- $$
287
297
)DOC" );
288
298
}
289
299
@@ -324,7 +334,7 @@ void Pool3dOpMaker::Make() {
324
334
AddAttr<bool >(
325
335
" global_pooling" ,
326
336
" (bool, default false) Whether to use the global pooling. "
327
- " If global_pooling = true, ksize and paddings wille be ignored." )
337
+ " If global_pooling = true, kernel size and paddings will be ignored." )
328
338
.SetDefault (false );
329
339
AddAttr<std::vector<int >>(
330
340
" strides" ,
@@ -359,7 +369,7 @@ void Pool3dOpMaker::Make() {
359
369
.SetDefault (false );
360
370
AddAttr<bool >(
361
371
" ceil_mode" ,
362
- " (bool, default false) Wether to use the ceil function to calculate "
372
+ " (bool, default false) Whether to use the ceil function to calculate "
363
373
" output height and width. False is the default. If it is set to False, "
364
374
" the floor function will be used." )
365
375
.SetDefault (false );
@@ -392,48 +402,68 @@ width, respectively. The input(X) size and output(Out) size may be different.
392
402
Output:
393
403
Out shape: $(N, C, D_{out}, H_{out}, W_{out})$
394
404
For ceil_mode = false:
395
- $$
396
- D_{out} = \frac{(D_{in} - ksize[0] + 2 * paddings[0])}{strides[0]} + 1 \\
397
- H_{out} = \frac{(H_{in} - ksize[1] + 2 * paddings[1])}{strides[1]} + 1 \\
398
- W_{out} = \frac{(W_{in} - ksize[2] + 2 * paddings[2])}{strides[2]} + 1
399
- $$
405
+ $$
406
+ D_{out} = \\frac{(D_{in} - ksize[0] + 2 * paddings[0])}{strides[0]} + 1
407
+ $$
408
+ $$
409
+ H_{out} = \\frac{(H_{in} - ksize[1] + 2 * paddings[1])}{strides[2]} + 1
410
+ $$
411
+ $$
412
+ W_{out} = \\frac{(W_{in} - ksize[2] + 2 * paddings[2])}{strides[2]} + 1
413
+ $$
400
414
For ceil_mode = true:
401
- $$
402
- D_{out} = \frac{(D_{in} - ksize[0] + 2 * paddings[0] + strides[0] -1)}{strides[0]} + 1 \\
403
- H_{out} = \frac{(H_{in} - ksize[1] + 2 * paddings[1] + strides[1] -1)}{strides[1]} + 1 \\
404
- W_{out} = \frac{(W_{in} - ksize[2] + 2 * paddings[2] + strides[2] -1)}{strides[2]} + 1
405
- $$
406
- For exclusive = true:
407
- $$
408
- dstart = i * strides[0] - paddings[0]
409
- dend = dstart + ksize[0]
410
- hstart = j * strides[1] - paddings[1]
411
- hend = hstart + ksize[1]
412
- wstart = k * strides[2] - paddings[2]
413
- wend = wstart + ksize[2]
414
- Output(i ,j, k) = \\frac{sum(Input[dstart:dend, hstart:hend, wstart:wend])}{ksize[0] * ksize[1] * ksize[2]}
415
- $$
415
+ $$
416
+ D_{out} = \\frac{(D_{in} - ksize[0] + 2 * paddings[0] + strides[0] -1)}{strides[0]} + 1
417
+ $$
418
+ $$
419
+ H_{out} = \\frac{(H_{in} - ksize[1] + 2 * paddings[1] + strides[1] -1)}{strides[1]} + 1
420
+ $$
421
+ $$
422
+ W_{out} = \\frac{(W_{in} - ksize[2] + 2 * paddings[2] + strides[2] -1)}{strides[2]} + 1
423
+ $$
424
+
416
425
For exclusive = false:
417
- $$
418
- dstart = max(0, i * strides[0] - paddings[0])
419
- dend = min(D, dstart + ksize[0])
420
- hstart = max(0, j * strides[1] - paddings[1])
421
- hend = min(H, hstart + ksize[1])
422
- wstart = max(0, k * strides[2] - paddings[2])
423
- wend = min(W, wstart + ksize[2])
424
- Output(i ,j, k) = \\frac{sum(Input[dstart:dend, hstart:hend, wstart:wend])}{(dend - dstart) * (hend - hstart) * (wend - wstart)}
425
- $$
426
-
427
- For adaptive = true:
428
- $$
429
- dstart = floor(i * D_{in} / D_{out})
430
- dend = ceil((i + 1) * D_{in} / D_{out})
431
- hstart = floor(j * H_{in} / H_{out})
432
- hend = ceil((j + 1) * H_{in} / H_{out})
433
- wstart = floor(k * W_{in} / W_{out})
434
- wend = ceil((k + 1) * W_{in} / W_{out})
435
- Output(i ,j, k) = \\frac{sum(Input[dstart:dend, hstart:hend, wstart:wend])}{(dend - dstart) * (hend - hstart) * (wend - wstart)}
436
- $$
426
+ $$
427
+ dstart = i * strides[0] - paddings[0]
428
+ $$
429
+ $$
430
+ dend = dstart + ksize[0]
431
+ $$
432
+ $$
433
+ hstart = j * strides[1] - paddings[1]
434
+ $$
435
+ $$
436
+ hend = hstart + ksize[1]
437
+ $$
438
+ $$
439
+ wstart = k * strides[2] - paddings[2]
440
+ $$
441
+ $$
442
+ wend = wstart + ksize[2]
443
+ $$
444
+ $$
445
+ Output(i ,j, k) = \\frac{sum(Input[dstart:dend, hstart:hend, wstart:wend])}{ksize[0] * ksize[1] * ksize[2]}
446
+ $$
447
+
448
+ For exclusive = true:
449
+ $$
450
+ dstart = max(0, i * strides[0] - paddings[0])
451
+ $$
452
+ $$
453
+ dend = min(D, dstart + ksize[0])
454
+ $$
455
+ $$
456
+ hend = min(H, hstart + ksize[1])
457
+ $$
458
+ $$
459
+ wstart = max(0, k * strides[2] - paddings[2])
460
+ $$
461
+ $$
462
+ wend = min(W, wstart + ksize[2])
463
+ $$
464
+ $$
465
+ Output(i ,j, k) = \\frac{sum(Input[dstart:dend, hstart:hend, wstart:wend])}{(dend - dstart) * (hend - hstart) * (wend - wstart)}
466
+ $$
437
467
438
468
)DOC" );
439
469
}
0 commit comments