alibaba / MNN

MNN is a blazing fast, lightweight deep learning framework, battle-tested by business-critical use cases in Alibaba
http://www.mnn.zone/
8.72k stars 1.67k forks source link

Error for MNN/source/shape/ShapeSqueeze.cpp, 80 #446

Closed kl456123 closed 4 years ago

kl456123 commented 4 years ago

What's wrong with the problem, I am new to MNN, I can only get this line but I know nothing about their meanings

MNN_ASSERT(squeezeDimSize< ib.dimensions);

czy2014hust commented 4 years ago

The number of Squeeze parameter(squeeze dim) you specify should be less than the input dimension

kl456123 commented 4 years ago

The problem is that how to convert the following code, Can I make it?

 def xcorr_depthwise(x, kernel):
          """depthwise cross correlation
          """
          batch = kernel.size(0)
          channel = kernel.size(1)
         x = x.view(1, batch*channel, x.size(2), x.size(3))
         kernel = kernel.view(batch*channel, 1, kernel.size(2), kernel.size(3))
         out = F.conv2d(x, kernel, groups=batch*channel)
         out = out.view(batch, channel, out.size(2), out.size(3))
         return out
kl456123 commented 4 years ago

I try to solve it. It cost me much time to make it. I think the error info is helpless for me...

def xcorr_depthwise(x, kernel):
    """depthwise cross correlation
    """
    batch = kernel.size(0)
    channel = kernel.size(1)
    kernel = kernel.squeeze(0).unsqueeze(1)
    new_kernel = torch.rand(256,1, 5,5,  device='cpu')
    new_kernel.copy_(kernel)
    out = F.conv2d(x, new_kernel, groups=256)

several places should be pointed out.

  1. view op is needed
  2. tensor size is very strange, Converter cannot get the correct size of tensor.
czy2014hust commented 4 years ago

Please use netron to check the squeeze parameter in the onnx model. Put it in the below comment.

kl456123 commented 4 years ago

OK, I will read your source code to know more. Thanks all the same

dan520520520 commented 2 years ago

你好,请问转换成mnn模型,xcorr_depthwise中的卷积操作,kernel参数可以传进去吗?