Repository: opencv
Issue: Node [Conv]:(res) parse error  Number of input channels should be multiple of 6 but got 0?
Labels: bug,category: dnn

##### System information (version)
- OpenCV => 4.5.3.36
- Operating System / Platform => Windows 64 Bit
- Compiler => Visual Studio 2019
- Python => 3.7.4
- Onnx => 1.10.2
- Onnxruntime => 1.9.0
- pytorch => 1.5.0


##### Detailed description

I am trained my model by pytorch(1.5.0). I want to use dnn module to call the model. Firstly, I have converted the model from pytorch to onnx .  It runs correctly in both pytorch and onnx, but I got the following error  when run it by cv.
```bash
[ERROR:0] global C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-c2l3r8zm\opencv\modules\dnn\src\onnx\onnx_importer.cpp (2127) cv::dnn::dnn4_v20210608::ONNXImporter::handleNode DNN/ONNX: ERROR during processing node with 3 inputs and 1 outputs: [Conv]:(res)
Traceback (most recent call last):
  File "E:/testFunction1.py", line 834, in <module>
    net = cv2.dnn.readNetFromONNX(onnx_path)
cv2.error: OpenCV(4.5.3) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-c2l3r8zm\opencv\modules\dnn\src\onnx\onnx_importer.cpp:2146: error: (-2:Unspecified error) in function 'cv::dnn::dnn4_v20210608::ONNXImporter::handleNode'
> Node [Conv]:(res) parse error: OpenCV(4.5.3) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-c2l3r8zm\opencv\modules\dnn\src\layers\convolution_layer.cpp:386: error: (-2:Unspecified error) Number of input channels should be multiple of 6 but got 0 in function 'cv::dnn::ConvolutionLayerImpl::getMemoryShapes'
> 

```

##### Steps to reproduce

- `testFunction1.py` code 
```python
class TestNet(nn.Module):
    def __init__(self):
        super(TestNet, self).__init__()
        self.conv = nn.Conv2d(6, 64, 1)

    def forward(self, xyz):
        xyz = xyz.squeeze(0)    # xyz is B * C * N
        l0_points = xyz
        l0_xyz = xyz
        
        xyz = l0_xyz.permute(0, 2, 1)
        points = l0_points.permute(0, 2, 1)

        B, N, C = xyz.shape
        grouped_xyz = xyz.view(B, 1, N, C)
        print("grouped_xyz shape: ", grouped_xyz.shape, " points.shape: ", points.shape)
        new_points = torch.cat([grouped_xyz, points.view(B, 1, N, C)], dim=-1)
        new_points = new_points.permute(0, 3, 2, 1)
        print(new_points.shape)
        new_points = self.conv(new_points)
        return new_points


if __name__ == "__main__":
    net = TestNet()
    inputs = torch.randn((1, 3, 150))
    inputs = inputs.unsqueeze(0)

    out = net(inputs)
    print("**** torch out ******: ", out.shape)
    onnx_path = "./test1.onnx"
    print("start convert model to onnx >>>")
    torch.onnx.export(net,  # support torch.nn.Module, torch.jit.ScriptModule or torch.jit.ScriptFunction
                      (inputs, ),
                      onnx_path,
                      verbose=True,
                      input_names=["points"],
                      output_names=["res"],
                      opset_version=12,
                      operator_export_type=torch.onnx.OperatorExportTypes.ONNX,  # ONNX_ATEN_FALLBACK,
                      dynamic_axes={
                          "points": {1: "b", 2: "c", 3: "n"},
                          "res": {0: "b", 1: "n"}
                      }
                      )

    print("onnx model has exported!")

    import cv2
    net = cv2.dnn.readNetFromONNX(onnx_path)
    # 获取各层信息
    layer_names = net.getLayerNames()

    for name in layer_names:
        id = net.getLayerId(name)
        layer = net.getLayer(id)
        print("layer id : %d, type : %s, name: %s" % (id, layer.type, layer.name))

    print("cv2 load model is OK!")
    print("start set input")
    print("inputs shape: ", inputs.shape)
    net.setInput(inputs.numpy().astype(np.float32), name="points")
    # net.setInput(center.numpy().astype(np.float32), name="center")
    print("set input Done")
    cv_res = net.forward()
    print("$$$$$cv res$$$$: ", cv_res.shape, cv_res.dtype, type(cv_res))
```

- the all output
```bash
grouped_xyz shape:  torch.Size([1, 1, 150, 3])  points.shape:  torch.Size([1, 150, 3])
torch.Size([1, 6, 150, 1])
**** torch out ******:  torch.Size([1, 64, 150, 1])
start convert model to onnx >>>
grouped_xyz shape:  torch.Size([1, 1, 150, 3])  points.shape:  torch.Size([1, 150, 3])
torch.Size([1, 6, 150, 1])
graph(%points : Float(1, 1, 3, 150),
      %conv.weight : Float(64, 6, 1, 1),
      %conv.bias : Float(64)):
  %3 : Float(1, 3, 150) = onnx::Squeeze[axes=[0]](%points) 
  %4 : Float(1, 150, 3) = onnx::Transpose[perm=[0, 2, 1]](%3) 
  %5 : Float(1, 150, 3) = onnx::Transpose[perm=[0, 2, 1]](%3) 
  %6 : Tensor = onnx::Shape(%4)
  %7 : Tensor = onnx::Constant[value={0}]()
  %8 : Long() = onnx::Gather[axis=0](%6, %7) 
  %9 : Tensor = onnx::Shape(%4)
  %10 : Tensor = onnx::Constant[value={1}]()
  %11 : Long() = onnx::Gather[axis=0](%9, %10) 
  %12 : Tensor = onnx::Shape(%4)
  %13 : Tensor = onnx::Constant[value={2}]()
  %14 : Long() = onnx::Gather[axis=0](%12, %13)
  %15 : Long() = onnx::Constant[value={1}]()
  %16 : Tensor = onnx::Unsqueeze[axes=[0]](%8)
  %17 : Tensor = onnx::Unsqueeze[axes=[0]](%15)
  %18 : Tensor = onnx::Unsqueeze[axes=[0]](%11)
  %19 : Tensor = onnx::Unsqueeze[axes=[0]](%14)
  %20 : Tensor = onnx::Concat[axis=0](%16, %17, %18, %19)
  %21 : Float(1, 1, 150, 3) = onnx::Reshape(%4, %20) 
  %22 : Long() = onnx::Constant[value={1}]()
  %23 : Tensor = onnx::Unsqueeze[axes=[0]](%8)
  %24 : Tensor = onnx::Unsqueeze[axes=[0]](%22)
  %25 : Tensor = onnx::Unsqueeze[axes=[0]](%11)
  %26 : Tensor = onnx::Unsqueeze[axes=[0]](%14)
  %27 : Tensor = onnx::Concat[axis=0](%23, %24, %25, %26)
  %28 : Float(1, 1, 150, 3) = onnx::Reshape(%5, %27)
  %29 : Float(1, 1, 150, 6) = onnx::Concat[axis=-1](%21, %28) 
  %30 : Float(1, 6, 150, 1) = onnx::Transpose[perm=[0, 3, 2, 1]](%29) 
  %res : Float(1, 64, 150, 1) = onnx::Conv[dilations=[1, 1], group=1, kernel_shape=[1, 1], pads=[0, 0, 0, 0], strides=[1, 1]](%30, %conv.weight, %conv.bias) # D:\python\lib\site-packages\torch\nn\modules\conv.py:346:0
  return (%res)

[ERROR:0] global C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-c2l3r8zm\opencv\modules\dnn\src\onnx\onnx_importer.cpp (2127) cv::dnn::dnn4_v20210608::ONNXImporter::handleNode DNN/ONNX: ERROR during processing node with 3 inputs and 1 outputs: [Conv]:(res)
Traceback (most recent call last):
  File "E:/code/Server223/pointNet/inference_C++/testFunction.py", line 834, in <module>
    net = cv2.dnn.readNetFromONNX(onnx_path)
cv2.error: OpenCV(4.5.3) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-c2l3r8zm\opencv\modules\dnn\src\onnx\onnx_importer.cpp:2146: error: (-2:Unspecified error) in function 'cv::dnn::dnn4_v20210608::ONNXImporter::handleNode'
> Node [Conv]:(res) parse error: OpenCV(4.5.3) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-c2l3r8zm\opencv\modules\dnn\src\layers\convolution_layer.cpp:386: error: (-2:Unspecified error) Number of input channels should be multiple of 6 but got 0 in function 'cv::dnn::ConvolutionLayerImpl::getMemoryShapes'
> 
onnx model has exported!

Process finished with exit code 1

```

- test1.onnx
![image](https://user-images.githubusercontent.com/20365125/146719756-737702ae-4f0f-44b0-a0db-5b0547a6c407.png)

[test1.onnx](https://github.com/zhoujinhai/onnxModel/blob/master/test1.onnx)

##### Issue submission checklist

 - [x] I checked the problem with documentation, FAQ, open issues,
       forum.opencv.org, Stack Overflow, etc and have not found solution
 - [x] I updated to latest OpenCV version and the issue is still there