- import torch
- import torch.nn as nn
- import numpy as np
- model = torch.nn.Tanh()
- dummy_input = torch.randn(1, 3, 32, 24)
- output = model(dummy_input)
- print(output.shape)
- traced = torch.jit.trace(model, dummy_input)
- traced.save('rknn_pytorch_tanh.pt')
- from rknn.api import RKNN
- rknn = RKNN(verbose=True)
- rknn.config()
- rknn.load_pytorch('rknn_pytorch_tanh.pt', input_size_list=[[3, 32, 24]])
复制代码
- ...
- warnings.warn(message)
- WARNING: Token 'COMMENT' defined, but not used
- WARNING: There is 1 unused token
- E Catch exception when loading pytorch model: rknn_pytorch_tanh.pt!
- E Traceback (most recent call last):
- E File "rknn/api/rknn_base.py", line 611, in rknn.api.rknn_base.RKNNBase.load_pytorch
- E File "rknn/base/RKNNlib/app/importer/import_pytorch.py", line 97, in rknn.base.RKNNlib.app.importer.import_pytorch.ImportPytorch.run
- E File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 570, in rknn.base.RKNNlib.converter.convert_pytorch.convert_pytorch.__init__
- E File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 654, in rknn.base.RKNNlib.converter.convert_pytorch.convert_pytorch.model_simplify
- E File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 113, in rknn.base.RKNNlib.converter.convert_pytorch.torch_inference_engine.shape_pick
- E File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 148, in rknn.base.RKNNlib.converter.convert_pytorch.torch_inference_engine.__ir_shape_inference
- E KeyError: 'aten::tanh'
复制代码
Aiden 发表于 2020-6-2 16:48
Hi, 我的试验环境是:
rknn-toolkit 1.3.2
leok 发表于 2020-6-2 17:11
1、首先,在pytorch保存部署模型时,需要调eval,去把模型中变量固化。
2、rknn不是单独的某个op或者acti ...
1、首先,在pytorch保存部署模型时,需要调eval,去把模型中变量固化。
2、rknn不是单独的某个op或者activation去支持,内部会进行优化组合,提高效率。
Aiden 发表于 2020-6-2 17:39
leok, 谢谢回复。
leok 发表于 2020-6-2 18:12
在pytorch-->rknn路走不通的情况下;可以尝试pytorch-->onnx-->rknn。
欢迎光临 Toybrick (https://t.rock-chips.com/) | Powered by Discuz! X3.3 |