Skip to content

MaxPool should be corrected and documented properly #5711

@JagdishKolhe

Description

@JagdishKolhe

Bug Report

Is the issue related to model conversion?

Yes and No

Describe the bug

When I run the single node model with kernel_size 1*1, the ceil_mode docent make any sense. The output shape should always be floor.

System information

  • OS Platform and Distribution (e.g. Linux Ubuntu 20.04): Linux Ubuntu 20.04
  • ONNX version (e.g. 1.13): 1.13
  • Python version: 3.10

Reproduction instructions

import torch
import torch.nn as nn
from torch.nn.parameter import Parameter

class TorchNetwork(nn.Module):
    def __init__(self):
        super(TorchNetwork, self).__init__()
        self.maxpool_1 = nn.MaxPool2d(kernel_size = [1, 1], stride = [2, 2], padding = [0, 0],ceil_mode=True)

    def forward(self, V_0):
        V_maxpool = self.maxpool_1(V_0)
        return V_maxpool

input_tensor = torch.randn(4, 4, 12, 12)

When I run above model in torch 2.0 with input as input_tensor, it always gives output shape as (4, 4, 6, 6) ignoring ceil_mode as kernel_size is 1*1 and padding is 0, which is expected behavior.
Whereas, when I export above model in onnx and run it I get output shape as (4, 4, 7, 7) which should not be the case. Although its the converter issue, still this validation should happen in ONNX runtime and runtime should through error.

Expected behavior

ONNX Runtime should validate input and output shape w.r.t kernel_size, padding and dilation and throw the error.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions