# Load model
print('--> Loading model')
ret = rknn.load_onnx(model='./decoder_tiny_fix_kv_cache.opt2.onnx')
if ret != 0:
print('Load model failed!')
exit(ret)
print('done')
# Build model
print('--> Building model')
ret = rknn.build(do_quantization= False)
if ret != 0:
print('Build model failed!')
exit(ret)
print('done')
# Export rknn model
print('--> Export rknn model')
ret = rknn.export_rknn('./encoder_tiny.rknn')
if ret != 0:
print('Export rknn model failed!')
exit(ret)
print('done')
# Release
rknn.release()
转换结果
I rknn-toolkit2 version: 2.0.0b0+9bab5682
--> Config model
W config: Please make sure the model can be dynamic when enable 'config.dynamic_input'!
I The 'dynamic_input' function has been enabled, the MaxShape is dynamic_input[2] = [[3, 4], [3, 1500, 384], [8, 3, 451, 384], []]!
The following functions are subject to the MaxShape:
1. The quantified dataset needs to be configured according to MaxShape
2. The eval_perf or eval_memory return the results of MaxShape
done
--> Loading model
I It is recommended onnx opset 19, but your onnx model opset is 11!
I Loading : 0%| | 0/337 [00:00<?, ?I Loading : 30%|██████████████▍ | 101/337 [00:00<00:00, 533.10I Loading : 100%|███████████████████████████████████████████████| 337/337 [00:00<00:00, 1772.95it/s]
W load_onnx: Input dtype is 'int64', the mean_values for input 0 are ignored!
W load_onnx: Input dtype is 'int64', the std_values for input 0 are ignored!
done
--> Building model
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 874, in rknn.api.graph_optimizer.GraphOptimizer.fold_constant
E build: File "rknn/api/load_checker.py", line 91, in rknn.api.load_checker.create_random_data
E build: ValueError: operands could not be broadcast together with shapes (8,2,451,384) (1,3,1,1)
W If you can't handle this error, please try updating to the latest version of the toolkit2 and runtime from: https://console.zbox.filez.com/l/I00fc3 (Pwd: rknn) Path: RKNPU2_SDK / 2.X.X / develop /
If the error still exists in the latest version, please collect the corresponding error logs and the model,
convert script, and input data that can reproduce the problem, and then submit an issue on: https://redmine.rock-chips.com (Please consult our sales or FAE for the redmine account)
Build model failed!