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

onnx 转换失败 #567

Closed
ShuangLiu1992 opened this issue Sep 10, 2018 · 3 comments
Closed

onnx 转换失败 #567

ShuangLiu1992 opened this issue Sep 10, 2018 · 3 comments

Comments

@ShuangLiu1992
Copy link
Contributor

pytorch 0.4.1 中带有reshape的网络转换后无法执行。onnx2ncnn中默认reshape会带有shape,但是现在reshape的实际shape是在另一个Constant中描述,由于缺乏注释我不太清楚reshape的转换具体是怎么执行的。

例子:
graph(%input : Float(64, 1, 28, 28)
%1 : Float(10, 1, 5, 5)
%2 : Float(10)
%3 : Float(20, 10, 5, 5)
%4 : Float(20)
%5 : Float(50, 320)
%6 : Float(50)
%7 : Float(10, 50)
%8 : Float(10)) {
%9 : Float(64, 10, 24, 24) = onnx::Conv[dilations=[1, 1], group=1, kernel_shape=[5, 5], pads=[0, 0, 0, 0], strides=[1, 1]](%input, %1, %2), scope: Net/Conv2d[conv1]
%10 : Float(64, 10, 12, 12) = onnx::MaxPoolkernel_shape=[2, 2], pads=[0, 0, 0, 0], strides=[2, 2], scope: Net
%11 : Float(64, 10, 12, 12) = onnx::Relu(%10), scope: Net
%12 : Float(64, 20, 8, 8) = onnx::Conv[dilations=[1, 1], group=1, kernel_shape=[5, 5], pads=[0, 0, 0, 0], strides=[1, 1]](%11, %3, %4), scope: Net/Conv2d[conv2]
%13 : Float(64, 20, 4, 4) = onnx::MaxPoolkernel_shape=[2, 2], pads=[0, 0, 0, 0], strides=[2, 2], scope: Net
%14 : Float(64, 20, 4, 4) = onnx::Relu(%13), scope: Net
%15 : Dynamic = onnx::Constantvalue= -1 320 [ CPULongTensor{2} ], scope: Net
%16 : Float(64, 320) = onnx::Reshape(%14, %15), scope: Net
%17 : Float(64, 50) = onnx::Gemm[alpha=1, beta=1, broadcast=1, transB=1](%16, %5, %6), scope: Net/Linear[fc1]
%18 : Float(64, 50) = onnx::Relu(%17), scope: Net
%19 : Float(64, 50), %20 : Dynamic = onnx::Dropoutis_test=1, ratio=0.5, scope: Net
%21 : Float(64, 10) = onnx::Gemm[alpha=1, beta=1, broadcast=1, transB=1](%19, %7, %8), scope: Net/Linear[fc2]
%output : Float(64, 10) = onnx::Softmaxaxis=1, scope: Net
return (%output);

@nihui
Copy link
Member

nihui commented Dec 15, 2018

onnx2ncnn 工具已更新,兼容了新 reshape

@nihui nihui closed this as completed Dec 15, 2018
@zhyj3038
Copy link

zhyj3038 commented Jul 9, 2019

这个问题依旧存在吧! 一个mat经过reshape以后,由于丢失了constant( 即shape)信息, 导致对应的node找不到,进而得到的mat为空

@zhangyufei49
Copy link

mark

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

4 participants