Skip to content

Backward consistent behavior for AvgPool2d/avg_pool2d in PyTorch 1.2 #26610

@thanhmvu

Description

@thanhmvu

🐛 Bug

Hi, it seems that pytorch 1.2 fixed a bug with ceil_mode in F. avg_pool2d() in previous versions of pytorch (at least 1.0 and 1.1). Particularly, before the default says ceil_mode=False but it seems to always be True. However, I wonder if the default behavior in pytorch 1.2 should be set to ceil_mode=True for backward consistency with 1.1 and 1.0.

To Reproduce

import torch
import torch.nn
import torch.nn.functional

x = torch.ones(1,3,2,2)
print('default ceil_mode', torch.nn.functional.avg_pool2d(x, 4).shape)
print('ceil_mode=True', torch.nn.functional.avg_pool2d(x, 4, stride=4, padding=0, ceil_mode=True, count_include_pad=True).shape)
print('ceil_mode=False', torch.nn.functional.avg_pool2d(x, 4, stride=4, padding=0, ceil_mode=False, count_include_pad=True).shape)

torch 1.1

default ceil_mode torch.Size([1, 3, 1, 1])

ceil_mode=True torch.Size([1, 3, 1, 1])

ceil_mode=False torch.Size([1, 3, 1, 1])

torch 1.2

Traceback (most recent call last):
File "", line 1, in
RuntimeError: Given input size: (3x2x2). Calculated output size: (3x0x0). Output size is too small

ceil_mode=True torch.Size([1, 3, 1, 1])

Traceback (most recent call last):
File "", line 1, in
RuntimeError: Given input size: (3x2x2). Calculated output size: (3x0x0). Output size is too small

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: bootcampWe plan to do a full writeup on the issue, and then get someone to do it for onboardingmodule: nnRelated to torch.nntriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions