Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mindspore.nn.MaxPool2d throws exception but shows MaxPool3D #308

Open
PhyllisJi opened this issue Oct 25, 2024 · 2 comments
Open

mindspore.nn.MaxPool2d throws exception but shows MaxPool3D #308

PhyllisJi opened this issue Oct 25, 2024 · 2 comments

Comments

@PhyllisJi
Copy link

Environment

Hardware Environment(Ascend/GPU/CPU): GPU

Software Environment:

  • MindSpore version (source or binary): 2.2.14
  • Python version (e.g., Python 3.7.5): 3.8
  • OS platform and distribution (e.g., Linux Ubuntu 16.04):
  • GCC/Compiler version (if compiled from source):

Describe the current behavior

It should be mindspore.nn.MaxPool2d throwing exceptions, but the display is MaxPool3D, which looks misleading.

Steps to reproduce the issue

import mindspore
import numpy as np


class Model_ms(mindspore.nn.Cell):
    def __init__(self):
        super(Model_ms, self).__init__()
        self.conv1_mutated = mindspore.nn.Conv2d(in_channels=1, out_channels=6, kernel_size=(8, 8), stride=(1, 1), pad_mode="pad", padding=(0, 0, 0, 0), dilation=(1, 1), group=1, has_bias=True)
        self.relu1_mutated = mindspore.nn.HSwish()
        self.pool1 = mindspore.nn.MaxPool2d(kernel_size=(2, 2), stride=(2, 2), pad_mode="pad", padding=(0, 0), dilation=1, return_indices=False, ceil_mode=False)

    def construct(self, input):
        conv1_output = self.conv1_mutated(input)
        relu1_output = self.relu1_mutated(conv1_output)
        maxpool1_output = self.pool1(relu1_output)

        tail_fc_output = maxpool1_output
        return tail_fc_output


inp = np.random.random([1, 1, 8, 23]).astype(np.float32)
ms_model = Model_ms()
ms_input = mindspore.Tensor(inp)
ms_output = ms_model(ms_input)
print(ms_output)

Related log / screenshot

ValueError: for MaxPool3DWithArgmax, shape of out is [1, 6, 1, 0, 8]. It should be not less than zero.


  • C++ Call Stack: (For framework developers)

mindspore/core/ops/max_pool3d_with_argmax.cc:266 MaxPool3DWithArgmaxInferShape

@zhouyifeng888
Copy link

The reason for the error here is that the shape is [1, 6, 1, 0, 8], where the 0 in the fourth dimension is an invalid input; it must be greater than 0 to be correct. The error message from MaxPool3d is reported because the underlying implementation of mindspore.nn.MaxPool2d uses the maxpool3dwithargmax operator.

@PhyllisJi
Copy link
Author

The reason for the error here is that the shape is [1, 6, 1, 0, 8], where the 0 in the fourth dimension is an invalid input; it must be greater than 0 to be correct. The error message from MaxPool3d is reported because the underlying implementation of mindspore.nn.MaxPool2d uses the maxpool3dwithargmax operator.

Thank you for your reply! I think that's the case, mindspore should be catching exceptions at a higher level of code so that it doesn't throw confusing exception hints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants