Tencent / ncnn

ncnn is a high-performance neural network inference framework optimized for the mobile platform
Other
20.47k stars 4.17k forks source link

pytorch转onnx之后再转ncnn: Split not supported yet! # axis=1 # split=7 #911

Closed hackeritchy closed 5 years ago

hackeritchy commented 5 years ago

我的模型结构中使用到了torch.split对channel进行切割,转换到onnx没有问题,但是通过onnx转换到ncnn出错,请问split操作是支持的嘛?或者有什么办法可以替换这个操作?

hanfanggithub commented 5 years ago

ncnn 中split操作是整个blob复制,没有做channel切割,真正做channel切割的是slice层,但不支持onnx::split 到 ncnn::slice的转换,可以pytorch > caffe > ncnn ,或者改写onnx2ncnn.cpp 添加split to slice操作,我改了一版但是slice层好像有bug ,一到这层就崩

nihui commented 5 years ago

了解,我看看w

hackeritchy commented 5 years ago

@nihui @hanfanggithub 请问这个问题有解决方案了嘛

soham24 commented 5 years ago

@hanfanggithub I am stuck at the same problem. @nihui overriding split to slice is buggy. Can we expect a proper split operation in onnxtoncnn or any work around?

soham24 commented 5 years ago

@hanfanggithub did you found solution to this?

biubug6 commented 5 years ago

@soham24 You may be able to try the following https://github.com/biubug6/ncnn_faceboxes/tree/master/tools/onnx

nihui commented 5 years ago

https://github.com/Tencent/ncnn/commit/1b910efea52621e36813874334d18920c48ec6d4 slice op should be converted to ncnn crop properly now

li-wenquan commented 1 year ago

请教一下,我刚接触ncnn,我在将onnx模型转ncnn模型时遇到这个问题:Unsupported split axis ! ,我使用的是官方提供的预编译版本:ncnn-20221128-windows-vs2019-shared,请问我如何才能解决这个问题?谢谢。

nihui commented 3 months ago

针对onnx模型转换的各种问题,推荐使用最新的pnnx工具转换到ncnn In view of various problems in onnx model conversion, it is recommended to use the latest pnnx tool to convert your model to ncnn

pip install pnnx
pnnx model.onnx inputshape=[1,3,224,224]

详细参考文档 Detailed reference documentation https://github.com/pnnx/pnnx https://github.com/Tencent/ncnn/wiki/use-ncnn-with-pytorch-or-onnx#how-to-use-pnnx