在执行 snpe-onnx-to-dlc 命令时报错
AttributeError: op reduce_mean_0 has no attribute keepdims
原因好像是跟 keepdims 属性有关,对于 keepdims 这个属性我不太熟悉,于是我进行了以下处理:
old:
if input_buf.axis_format in format_to_permute_order:
target_format = format_to_format[input_buf.axis_format]
permute_order = format_to_permute_order[input_buf.axis_format]
# If keep dims = 0 we must permute as it will remove dimensions
if not node.op.keepdims:
AxisTracker.inject_implicit_permute(graph, input_name, target_format,
permute_order, [node.op.name])
output_buf.axis_format = AxisTracker.AxisFormat.NONTRIVIAL
else:
AxisTracker.eltwise_to_spatial_first_order(node, graph)
new:
if input_buf.axis_format in format_to_permute_order:
target_format = format_to_format[input_buf.axis_format]
permute_order = format_to_permute_order[input_buf.axis_format]
# If keep dims = 0 we must permute as it will remove dimensions
if not hasattr(node.op, "keepdims"):
AxisTracker.inject_implicit_permute(graph, input_name, target_format,
permute_order, [node.op.name])
output_buf.axis_format = AxisTracker.AxisFormat.NONTRIVIAL
else:
AxisTracker.eltwise_to_spatial_first_order(node, graph)
果不其然继续报错了,现在有点不知道怎么改了,网上也没相关信息。有没有熟悉这方面的老哥指点一二?
1
wutiantong 2020-05-15 17:03:36 +08:00
搞过一段时间 onnx,后来发现它代码质量真的不太行就弃坑了
|
2
MekoPan OP @wutiantong 感觉 snpe 对 onnx 转 dlc 也是一堆坑,基本都需要在原基础上修改。心累的要死。
|
3
minami 2020-05-15 17:39:06 +08:00
不了解 SNPE,不过你可以检查下 keep_dims 属性
|
6
MekoPan OP @minami 网上查`keepdims`是保持矩阵二维特性的意思,现在在研究什么情况下 keepdims 才会等于 0 。另外听你这么说感觉问题出现在 onnx 模型本身上
|
7
MekoPan OP @minami 按照我上面修改完 keepdims 之后,又报这个错
```python error_code=1004; error_message=Layer parameters combination is invalid. Layer fully_connected_0: mismatch between size of input 464 (7) and width of weight matrix (1280); error_component=Model Validation; line_no=1413; thread_id=139842232201088 ``` 快麻了 |