|
- class Model(torch.nn.Module):
- def __init__(self):
- super(Model, self).__init__()
- self.weights_0 = torch.nn.Parameter(torch.ones(1))
- self.weights_1 = torch.nn.Parameter(torch.ones(1))
- def forward(self, input_0, input_1):
- result = torch.mul(self.weights_0 , input_0) + torch.mul(self.weights_1 , input_1)
- return result
模型里需要通过 torch.nn.Parameter 的方式定义可学习参数,但是上面这个模型在 torch -> rknn 的时候会报错如下:WARNING: Token 'COMMENT' defined, but not used
WARNING: There is 1 unused token
W Not match tensor little_model_param.weights_0ut0
E Catch exception when loading pytorch model: little_model_param.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 104, in rknn.base.RKNNlib.app.importer.import_pytorch.ImportPytorch.run
E File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 1205, in rknn.base.RKNNlib.converter.convert_pytorch.convert_pytorch.match_paragraph_and_param
E File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 1129, in rknn.base.RKNNlib.converter.convert_pytorch.convert_pytorch._torch_push_ready_tensor
E TypeError: 'NoneType' object is not iterable
Load resnet50v2 failed!
我觉得主要原因是 W Not match tensor little_model_param.weights_0ut0 导致的。如果
self.weights_0 =torch.ones(1)
self.weights_1 =torch.ones(1)
则没有问题。
torch->onnx->rknn 应该没有问题,但是由于别的原因只能通过 pytorch -> rknn 直接转化。
谢谢
|
|