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转ncnn的问题 #3

Open
queenmary55 opened this issue Nov 23, 2021 · 9 comments
Open

onnx转ncnn的问题 #3

queenmary55 opened this issue Nov 23, 2021 · 9 comments

Comments

@queenmary55
Copy link

queenmary55 commented Nov 23, 2021

pytorch模型转onnx,使用rvm作者给的代码,没报错,但是有警告:
onnx_helper.py:20: TracerWarning: Converting a tensor to a Pyth on number might cause the trace to be incorrect. We can't record the data flow of Python values, so this value wil l be treated as a constant in the future. This means that the trace might not generalize to other inputs! return F.interpolate(x, scale_factor=scale_factor.item(),

使用该onnx模型,进行简化,命令如下:
python -m onnxsim model.onnx model_sim.onnx --dynamic-input-shape --input-shape src:1,3,1280,720 r1i:1,16,256,144 r2i:1,20,128,72 r3i:1,40,64,36 r4i:1,64,32,18 downsample_ratio:1
报错如下
onnxruntime.capi.onnxruntime_pybind11_state.InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Non-zero status code returned while running Expand node. Name:'Expand_174' Status Message: invalid expand shape

请大神赐教。我用netron查看了onnx模型的网络图,找到了Expand_174节点,该节点是接收一个shape,然后对r4i进行操作(我去onnx的github上查看,说expand操作是广播)onnx中expand操作的解释
但是我仔细查看并打印了decoder.py里面相关位置的tensor形状,没有自动广播的情况

@FeiGeChuanShu
Copy link
Owner

这个跟onnx的版本也有关系,会给你搞出很多莫名其妙的op,要不你试一下pnnx? 可以直接torchscript转ncnn,不会涉及onnx这个中间商。 https://github.com/Tencent/ncnn/tree/master/tools/pnnx

@FeiGeChuanShu
Copy link
Owner

@queenmary55

@queenmary55
Copy link
Author

@FeiGeChuanShu 感谢回复!我去试试pnnx

@queenmary55
Copy link
Author

@FeiGeChuanShu 请教一下,使用pnnx进行转换的过程中,是否需要对原网络结构的代码进行修改,您在转换的时候有什么注意事项么,我尝试从torchscript用pnnx转ncnn报错如下
。。。。。。。。
############# pass_level2
############# pass_level3
############# pass_level4
############# pass_level5
make_slice_expression input 173
make_slice_expression end 174
terminate called after throwing an instance of 'std::out_of_range'
what(): map::at
Aborted (core dumped)

@FengMu1995
Copy link

@queenmary55 问下你上面的问题了吗

@queenmary55
Copy link
Author

@FengMu1995 没有解决。我感觉是level1的时候,就有不支持的算子,在encoder部分的featuremap形状就不太对,最后在decoder部分报错了,out of range。不知道怎么排查错误

@queenmary55
Copy link
Author

@FengMu1995 方便留个邮箱联系下吗

@li-wenquan
Copy link

@queenmary55 请问您后来如何转换成功?是否愿意分享一下?谢谢。即使我使用了onnxsim简化,最后再转换为ncnn时报以下错误(似乎onnxsim没有作用?):
Unknown data type 0
Unsupported Resize scales and sizes are all empty!
Unsupported split axis !
Shape not supported yet!
Expand not supported yet!
Shape not supported yet!
Unknown data type 0
Shape not supported yet!
Expand not supported yet!
Shape not supported yet!
Unknown data type 0
Shape not supported yet!
Expand not supported yet!
Shape not supported yet!
Unknown data type 0
Shape not supported yet!
Expand not supported yet!
Shape not supported yet!
Unknown data type 0
Unsupported split axis !
Shape not supported yet!
Shape not supported yet!
Unknown data type 0
Unsupported Resize scales and sizes are all empty!
Shape not supported yet!
Shape not supported yet!
Unknown data type 0
Unsupported Resize scales and sizes are all empty!

@rose-jinyang
Copy link

Hi @FeiGeChuanShu
How are you?
Thanks for contributing to this project.
I am going to use your NCNN model in Visual Studio C++ on Windows 10.
But it is impossible to run your NCNN model.
First, I see a message which shows that your ncnn model is too old.
Could u share the method for converting the original rvm model to ncnn model?
Thanks

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

5 participants