airockchip / rknn_model_zoo

Apache License 2.0
1.05k stars 192 forks source link

我自己想转化一个CNN模型(.pth),报错。有大佬知道为什么嘛,求指教 #145

Open 1030933569 opened 4 months ago

1030933569 commented 4 months ago

I FoldConstant : 63%|████████████████████████▌ | 806/1277 [00:27<00:04, 110.79it/s]E build: The input 0 of TopK('/rpn/TopK') need to be constant! It will cause the graph to be a dynamic graph! Remove TopK('/rpn/TopK') manually and try again! I ===================== WARN(0) ===================== E rknn-toolkit2 version: 2.0.0b0+9bab5682 I FoldConstant : 63%|█████████████████████████▎ | 809/1277 [00:27<00:16, 29.03it/s] E build: Catch exception when building RKNN model! E build: Traceback (most recent call last): E build: File "rknn/api/rknn_base.py", line 1977, in rknn.api.rknn_base.RKNNBase.build E build: File "rknn/api/graph_optimizer.py", line 814, in rknn.api.graph_optimizer.GraphOptimizer.fold_constant E build: File "rknn/api/graph_optimizer.py", line 361, in rknn.api.graph_optimizer._dynamic_check E build: File "rknn/api/rknn_log.py", line 92, in rknn.api.rknn_log.RKNNLog.e E build: ValueError: The input 0 of TopK('/rpn/TopK') need to be constant! It will cause the graph to be a dynamic graph! E build: Remove TopK('/rpn/TopK') manually and try again!

chuanzeruge commented 4 months ago

你好,请问你解决了吗。我上网搜好像是topk这个算子不支持。我把自己的pytorch模型转为了onnx,再转成rknn时也遇到了这个问题。

1030933569 commented 4 months ago

没有,太痛苦了,你有什么想法吗

chuanzeruge commented 4 months ago

@1030933569 我现在打算尝试自定义并注册这个算子,之前也问了一下交流群里的人,在rknntoolkit2官方仓库里doc/user下有第5.5章节有详细的流程,rknpu2的工程下有自定义算子的demo。可以学习一下。ps. 我也痛苦好久了(' ')

1030933569 commented 3 months ago

ok,感谢感谢

KIM7AZEN commented 3 months ago

会引入动态图,可以看看能不能转onnx的时候把这块固定。