|
本帖最后由 xsky 于 2020-3-12 17:10 编辑
模型及代码:
链接:https://pan.baidu.com/s/1j9MPyahGshjuNfw5ijIqBQ
提取码:tbbr
pytorch 1.2 rknn v1.3
- rknn = RKNN(verbose=True)
- rknn.config(batch_size=1,
- epochs=1) # asymmetric_quantized-u8, quantized_dtype='dynamic_fixed_point-16' , channel_mean_value='0 0 0 1', reorder_channel='0 1 2',
- system = platform.system()
- seq_len = 64
- isize = 672
- # hsize = 6
- # hsize1 = 4
- pt_file = 'toml_fp32_acoustic.pt'
- #pt_file = 'toml_fp32_feat.pt'
- m = torch.jit.load(pt_file)
- m.eval()
- #x = torch.rand((1, seq_len, isize))
- x = torch.linspace(-1, 1, steps=(isize * seq_len))
- x = x.view(1, seq_len, -1)
- input_size_list = [[1, seq_len, isize]]
- #x1 = torch.full((1, hsize), fill_value=0.2, dtype=torch.float)
- ix = x.numpy()
- out = m.forward(x)
- print("torch out:")
- print(out)
- rknn.load_pytorch(model=pt_file, input_size_list=input_size_list)
- rknn_file = pt_file + '.rknn'
- print('--> Building model')
- ret = rknn.build(do_quantization=False, dataset='./dataset.txt')
- if ret != 0:
- print('Build pytorch failed!')
- exit(ret)
- print('build done')
- rm(rknn_file)
- rknn.export_rknn(rknn_file)
.load_pytorch时错
Syntax error in input! LexToken(NAMED_IDENTIFIER,'str',15,1100)
.build时报错
--> Building model
W Genreate input meta fail, please check model.
W External input meta file "C:\Users\dm\AppData\Local\Temp\tmpm1i9kbvb\toml_fp32_acoustic_inputmeta.yml" is not exists.
Traceback (most recent call last):
File "E:/Work/_Code/x4c/jasper/check-pt.py", line 77, in <module>
ret = rknn.build(do_quantization=False, dataset='./dataset.txt')
File "D:\Program Files\Python\Python36\lib\site-packages\rknn\api\rknn.py", line 238, in build
ret = self.rknn_base.build(do_quantization=do_quantization, dataset=dataset, pack_vdata=pre_compile, batch_size=rknn_batch_size)
File "rknn\api\rknn_base.py", line 719, in rknn.api.rknn_base.RKNNBase.build
File "rknn\api\rknn_base.py", line 2249, in rknn.api.rknn_base.RKNNBase._generate_inputmeta
IndexError: list index out of range
这错误怎么定位啊, torch.jit.load加载.pt模型是可以正常.frward()得到结果的。
|
|