Skip to content

Unexpected output size for Maxpool #21935

@lara-hdr

Description

@lara-hdr

The output of Maxpool has an unexpected size for some corner cases.

Repro:
Maxpool1d(kernel_size=3, stride=2, padding=0, dilation=2)
input=torch.randn(1,1,4)

If I use the L_out formula from the documentation (https://pytorch.org/docs/stable/nn.html?highlight=maxpool#torch.nn.MaxPool1d) to compute the output size, I get {1,1,0}.
However, the output generated has a size of {1, 1, 1}.

And with ONNX, the same operation results in an output of shape {1,1,0}
(microsoft/onnxruntime#1224).

Since this case is not mentioned in the documentation, I was wondering if this is a special case that is handled separately by design (to avoid returning an output with a dim of 0), or if it is a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: 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