rockchip-linux / rknn-toolkit2

BSD 3-Clause "New" or "Revised" License
828 stars 151 forks source link

rknn-toolkits不支持pytorch的per_channel量化模型 #292

Closed Spratumn closed 3 months ago

Spratumn commented 3 months ago

使用pytorch per_channel量化感知训练导出的模型在转换到rknn时报错:

W __init__: rknn-toolkit2 version: 1.6.0+81f21f4d
PtParse: 100%|███████████████████████████████████████████████████| 825/825 [00:03<00:00, 268.68it/s]
Loading : 100%|█████████████████████████████████████████████████| 945/945 [00:00<00:00, 7005.35it/s]
W load_pytorch: The QAT model is loaded, but the config.optimization_level = 3, and some performance optimization passes will affect the accuracy.
                              If you need more consistent accuracy, you can try changing config.optimization_level to 2.
W build: The qat_inf is not Empty!
W build: qat_inf = {'input0.7': {'dtype': 'int8', 'scale': [0.03606110066175461], 'zero_point': [-128], 'min': [0.0], 'max': [9.195580668747425]}, 'input0.11': {'dtype': 'int8', 'scale': [0.030879171565175056], 'zero_point': [-128], 'min': [0.0], 'max': [7.874188749119639]}, 'input0.9': {'dtype': 'int8', 'scale': [0.0422576367855072], 'zero_point': [-128], 'min': [0.0], 'max': [10.775697380304337]}, 'input0.13': {'dtype': 'int8', 'scale': [0.1534958779811859], 'zero_point': [-128], 'min': [0.0], 'max': [39.14144888520241]}, 'input0.22': {'dtype': 'int8', 'scale': [0.3345894515514374], 'zero_point': [-128], 'min': [0.0], 'max': [85.32031014561653]}, 'input0.28': {'dtype': 'int8', 'scale': [0.47960084676742554], 'zero_point': [-128], 'min': [0.0], 'max': [122.29821592569351]}, 'input0.34': {'dtype': 'int8', 'scale': [0.509178876876831], 'zero_point': [-128], 'min': [0.0], 'max': [129.84061360359192]}, 'input0.1': {'dtype': 'int8', 'scale': [0.2029087096452713], 'zero_point': [-128], 'min': [0.0], 'max': [51.74172095954418]}}

E build: Catch exception when building RKNN model!
E build: Traceback (most recent call last):
E build:   File "rknn/api/rknn_base.py", line 2003, in rknn.api.rknn_base.RKNNBase.build
E build:   File "rknn/api/graph_optimizer.py", line 1751, in rknn.api.graph_optimizer.GraphOptimizer.fuse_ops
E build:   File "rknn/api/fuse_rules.py", line 1570, in rknn.api.fuse_rules._p_fuse_align_conv_backward
E build: IndexError: list index out of range
Spratumn commented 3 months ago

solved in 1.6.2b2+d0f49553