Toybrick

ONNX Slice转换报错

theantbully

注册会员

积分
63
楼主
发表于 2021-9-9 16:36:55    查看: 4300|回复: 6 | [复制链接]    打印 | 只看该作者
--> Loading model
I Start importing onnx...
W Call onnx.optimizer.optimize fail, skip optimize
I Current ONNX Model use ir_version 6 opset_version 11
W Infer onnx shape: Meet empty shape tensor, reshape () to (1,)!
D Calc tensor Constant_426 (1,)
W Infer onnx shape: Meet empty shape tensor, reshape () to (1,)!
D Calc tensor Constant_423 (1,)
W Infer onnx shape: Meet empty shape tensor, reshape () to (1,)!
D Calc tensor Constant_420 (1,)
W Infer onnx shape: Meet empty shape tensor, reshape () to (1,)!
D Calc tensor Constant_406 (1,)
W Infer onnx shape: Meet empty shape tensor, reshape () to (1,)!
D Calc tensor Constant_403 (1,)
W Infer onnx shape: Meet empty shape tensor, reshape () to (1,)!
D Calc tensor Constant_400 (1,)
W Infer onnx shape: Meet empty shape tensor, reshape () to (1,)!
D Calc tensor Constant_386 (1,)
W Infer onnx shape: Meet empty shape tensor, reshape () to (1,)!
D Calc tensor Constant_383 (1,)
W Infer onnx shape: Meet empty shape tensor, reshape () to (1,)!
D Calc tensor Constant_380 (1,)

.....

I Try match Slice_Slice_39ut0
W Not match tensor Slice_Slice_39ut0
E Try match Slice_Slice_39ut0 failed, catch exception!
W ----------------Warning(12)----------------
E Catch exception when loading onnx model: yolov5s.onnx!
E Traceback (most recent call last):
E   File "rknn/base/RKNNlib/converter/convert_onnx.py", line 1152, in rknn.base.RKNNlib.converter.convert_onnx.convert_onnx.match_paragraph_and_param
E   File "rknn/base/RKNNlib/converter/convert_onnx.py", line 1054, in rknn.base.RKNNlib.converter.convert_onnx.convert_onnx._onnx_push_ready_tensor

使用Netron查看ONNX 模型, 存在节点 Slice_Slice_39


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复

使用道具 举报

theantbully

注册会员

积分
63
沙发
 楼主| 发表于 2021-9-9 19:47:03 | 只看该作者
out = self.conv(torch.cat([x[..., ::2, ::2], x[..., 1::2, ::2], x[..., ::2, 1::2], x[..., 1::2, 1::2]], 1))
这里 Slice 操作的 Step = 2, 应该是RKNN不支持导致的问题,,, 有谁知道怎么处理吗?
回复

使用道具 举报

theantbully

注册会员

积分
63
板凳
 楼主| 发表于 2021-9-10 10:14:11 | 只看该作者
自问自答,解决方案:
使用其他操作替代原来步长为2的切片操作,如下修改测试时可以的:
        pooled = self.maxpool2d(x) #[N, 4*C, W/2, H/2]
        reutrn self.conv( torch.cat([pooled, pooled, pooled, pooled], 1))
回复

使用道具 举报

rakidis

高级会员

积分
507
地板
发表于 2021-9-21 21:22:44 | 只看该作者
You changed the layer's operation like that though. The shape will be the same, but slice and maxpool do different operations, your network will behave wrong after that modification.
回复

使用道具 举报

zjleung

注册会员

积分
186
5#
发表于 2021-9-22 09:25:16 | 只看该作者
rakidis 发表于 2021-9-21 21:22
You changed the layer's operation like that though. The shape will be the same, but slice and maxpoo ...

absolutely agree
回复

使用道具 举报

theantbully

注册会员

积分
63
6#
 楼主| 发表于 2021-9-28 18:44:36 | 只看该作者
rakidis 发表于 2021-9-21 21:22
You changed the layer's operation like that though. The shape will be the same, but slice and maxpoo ...

Thanks for you reply.
That's true. Then I replace maxpool with conv operation and retrain the model. The mAP seems not degrade too much.
Just provide a guide for sb. who might encounter similar issue.
回复

使用道具 举报

rakidis

高级会员

积分
507
7#
发表于 2021-9-30 16:22:15 | 只看该作者
May I ask which neural network you were trying to convert spesifically? I bumped into similiar situation and managed to solve it with another method
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

产品中心 购买渠道 开源社区 Wiki教程 资料下载 关于Toybrick


快速回复 返回顶部 返回列表