Toybrick

ONNX [RK_nn_CalcReshapeTensor:973]Cannot calculate the reshape tensor

chuyee

中级会员

积分
352
楼主
发表于 2019-3-11 10:05:44    查看: 7766|回复: 5 | [复制链接]    打印 | 只看该作者
Hi,

When converting onnx model to rknn, the rknn load_onnx/build/export_rknn all succeeded. However rknn.init_runtime() reports error like "E [RK_nn_CalcReshapeTensor:973]Cannot calculate the reshape tensor 14745600 to 4915200. E [setup_node:330]Setup node[83] RESHAPE fail". What might be the problem? More detailed info as below. Please let me know if you need more info.

...

D [setup_node:324]Preprocess node[65] RESHAPE
D [setup_node:324]Preprocess node[66] CONV_RELU
D [setup_node:324]Preprocess node[67] RESHAPE
D [setup_node:324]Preprocess node[68] CONCAT
D [setup_node:324]Preprocess node[69] CONV_RELU
D [setup_node:324]Preprocess node[70] CONV_RELU
D [setup_node:324]Preprocess node[71] CONV_RELU
D [setup_node:324]Preprocess node[72] CONCAT
D [setup_node:324]Preprocess node[73] RESHAPE
D [setup_node:324]Preprocess node[74] CONV_RELU
D [setup_node:324]Preprocess node[75] RESHAPE
D [setup_node:324]Preprocess node[76] CONCAT
D [setup_node:324]Preprocess node[77] CONV_RELU
D [setup_node:324]Preprocess node[78] CONCAT
D [setup_node:324]Preprocess node[79] CONV_RELU
D [setup_node:324]Preprocess node[80] CONV_RELU
D [setup_node:324]Preprocess node[81] RESHAPE
D [setup_node:324]Preprocess node[82] PERMUTE
D [setup_node:324]Preprocess node[83] RESHAPE
E [RK_nn_CalcReshapeTensor:973]Cannot calculate the reshape tensor 14745600 to 4915200.
E [setup_node:330]Setup node[83] RESHAPE fail
Create RKNN model fail!
E Catch exception when init runtime!
T Traceback (most recent call last):
T   File "rknn/api/rknn_base.py", line 506, in rknn.api.rknn_base.RKNNBase.init_runtime
T   File "rknn/api/rknn_runtime.py", line 270, in rknn.api.rknn_runtime.RKNNRuntime.build_graph
T Exception: RKNN init failed. error code: RKNN_ERR_FAIL
Init runtime environment failed
回复

使用道具 举报

chuyee

中级会员

积分
352
沙发
 楼主| 发表于 2019-3-11 10:09:58 | 只看该作者
BTW, rknn prints warning about "Do not support shape > 4". Could this be the cause of the problem?

--> config model
done
--> Loading model
W Do not support shape > 4.
W Unhandle status: the input shape of reshape layer 166_8 is not 4-D
W Do not support shape > 4.
W Unhandle status: the input shape of reshape layer 173_3 is not 4-D
done
--> Building model
W Do not support shape > 4.
W Unhandle status: the input shape of reshape layer 166_8 is not 4-D
W Do not support shape > 4.
W Unhandle status: the input shape of reshape layer 173_3 is not 4-D
done
--> Export RKNN model
done
回复

使用道具 举报

raul

中级会员

积分
235
板凳
发表于 2019-3-12 11:16:27 | 只看该作者
When you built RKNN model, is the value of do_quantization is False?
回复

使用道具 举报

raul

中级会员

积分
235
地板
发表于 2019-3-12 11:25:50 | 只看该作者
Could you tell me the dimension of the input
回复

使用道具 举报

chuyee

中级会员

积分
352
5#
 楼主| 发表于 2019-3-12 14:58:17 | 只看该作者
The input size is 160x160x3. Yes, the log is from "do_quantization=False". Below is the log for "do_quantization=True". It fails during rknn.build now.

...
D Process 155_17 ...
D RKNN output shape(convolution): (1 160 160 64)
D Real output shape: (1, 160, 160, 64)
D Process 156_16 ...
D RKNN output shape(relu): (1 160 160 64)
D Real output shape: (1, 160, 160, 64)
D Process 157_15 ...
D RKNN output shape(concat): (1 160 160 256)
D Real output shape: (1, 160, 160, 256)
D Process 158_14 ...
D RKNN output shape(convolution): (1 160 160 64)
D Real output shape: (1, 160, 160, 64)
D Process 159_13 ...
D RKNN output shape(relu): (1 160 160 64)
D Real output shape: (1, 160, 160, 64)
D Process 160_12 ...
D RKNN output shape(convolution): (1 160 160 256)
D Real output shape: (1, 160, 160, 256)
D Process 161_11 ...
D RKNN output shape(relu): (1 160 160 256)
D Real output shape: (1, 160, 160, 256)
D Process 163_10 ...
W Do not support shape > 4.
D RKNN output shape(reshape): (1 2 64 160 160 2)
D Real output shape: (1, 2, 2, 64, 160, 160)
D Process 164_9 ...
D RKNN output shape(permute): (1 2 160 2 160 64)
D Real output shape: (1, 2, 160, 2, 160, 64)
D Process 166_8 ...
W Unhandle status: the input shape of reshape layer 166_8 is not 4-D
D RKNN output shape(reshape): (1 320 320 64)
D Real output shape: (1, 64, 320, 320)
D Process 167_7 ...
D RKNN output shape(convolution): (1 320 320 256)
E Catch exception when building RKNN model!
T Traceback (most recent call last):
T   File "/home/chuyee/.virtualenvs/dscape/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1567, in _create_c_op
T     c_op = c_api.TF_FinishOperation(op_desc)
T tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimensions must be equal, but are 320 and 64 for '167_7_2/Conv2D' (op: 'Conv2D') with input shapes: [1,66,322,320], [3,3,64,256].
T During handling of the above exception, another exception occurred:
T Traceback (most recent call last):
T   File "rknn/api/rknn_base.py", line 470, in rknn.api.rknn_base.RKNNBase.build
T   File "rknn/api/rknn_base.py", line 889, in rknn.api.rknn_base.RKNNBase._quantize
T   File "rknn/base/rknnlib/app/tensorzone/quantization.py", line 248, in rknn.base.rknnlib.app.tensorzone.quantization.Quantization.run
T   File "rknn/base/rknnlib/app/tensorzone/quantization.py", line 110, in rknn.base.rknnlib.app.tensorzone.quantization.Quantization._run_quantization
T   File "rknn/base/rknnlib/app/tensorzone/workspace.py", line 167, in rknn.base.rknnlib.app.tensorzone.workspace.Workspace._setup_graph
T   File "rknn/base/rknnlib/app/tensorzone/workspace.py", line 168, in rknn.base.rknnlib.app.tensorzone.workspace.Workspace._setup_graph
T   File "rknn/base/rknnlib/app/tensorzone/graph.py", line 59, in rknn.base.rknnlib.app.tensorzone.graph.Graph.generate
T   File "rknn/base/rknnlib/rknnnetbuilder.py", line 108, in rknn.base.rknnlib.rknnnetbuilder.rknnNetBuilder.build
T   File "rknn/base/rknnlib/rknnnetbuilder.py", line 110, in rknn.base.rknnlib.rknnnetbuilder.rknnNetBuilder.build
T   File "rknn/base/rknnlib/rknnnetbuilder.py", line 134, in rknn.base.rknnlib.rknnnetbuilder.rknnNetBuilder.build_layer
T   File "rknn/base/rknnlib/rknnnetbuilder.py", line 134, in rknn.base.rknnlib.rknnnetbuilder.rknnNetBuilder.build_layer
T   File "rknn/base/rknnlib/rknnnetbuilder.py", line 134, in rknn.base.rknnlib.rknnnetbuilder.rknnNetBuilder.build_layer
T   [Previous line repeated 4 more times]
T   File "rknn/base/rknnlib/rknnnetbuilder.py", line 153, in rknn.base.rknnlib.rknnnetbuilder.rknnNetBuilder.build_layer
T   File "rknn/base/rknnlib/rknnnetbuilder.py", line 154, in rknn.base.rknnlib.rknnnetbuilder.rknnNetBuilder.build_layer
T   File "rknn/base/rknnlib/layer/rknnlayer.py", line 265, in rknn.base.rknnlib.layer.rknnlayer.rknnLayer.compute_tensor
T   File "rknn/base/rknnlib/layer/convolution.py", line 117, in rknn.base.rknnlib.layer.convolution.Convolution.compute_out_tensor
T   File "/home/chuyee/.virtualenvs/dscape/lib/python3.6/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 956, in conv2d
T     data_format=data_format, dilations=dilations, name=name)
T   File "/home/chuyee/.virtualenvs/dscape/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
T     op_def=op_def)
T   File "/home/chuyee/.virtualenvs/dscape/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3392, in create_op
T     op_def=op_def)
T   File "/home/chuyee/.virtualenvs/dscape/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1734, in __init__
T     control_input_ops)
T   File "/home/chuyee/.virtualenvs/dscape/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1570, in _create_c_op
T     raise ValueError(str(e))
T ValueError: Dimensions must be equal, but are 320 and 64 for '167_7_2/Conv2D' (op: 'Conv2D') with input shapes: [1,66,322,320], [3,3,64,256].
Build carn failed!
回复

使用道具 举报

chuyee

中级会员

积分
352
6#
 楼主| 发表于 2019-3-12 15:08:54 | 只看该作者
I attached my onnx network graph file.

本帖子中包含更多资源

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

x
回复

使用道具 举报

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

本版积分规则

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


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