专栏算法工具链Precision loss of GlobalAveragePool operator

Precision loss of GlobalAveragePool operator

已解决
cherry2023-03-30
41
5
1.芯片型号:X3派
2.天工开物开发包OpenExplorer版本:horizon_xj3_open_explorer_v2.4.2_20221227
3.问题定位:模型转换<-->板端部署
4.问题具体描述

During using "hb_mapper makertbin" to convert my *.onnx to *.bin, i have found that one operator named "GlobalAveragePool_380" has low cosine similarity (about 0.84). It is this operator that brings about my single object tracking model generating invalid outputs. After executing "GlobalAveragePool_380" on CPU, i have had success in reducing loss of precision. However, this will make my *.bin have higher latency. Now, i want to question how can i execute this operator on BPU while having both low latency and high cosine similarity (0.90 may be enough) ?

Some extra descriptions:

  • My DCMT_sim.onnx has other GlobalAveragePool operators, but those operators (such as GlobalAveragePool_306) have high cosine similarity.

  • GlobalAveragePool_380 meets the restrictions mentioned in Horizon supported_op_list_and_restrictions document (https://developer.horizon.ai/api/v1/fileData/documents_pi/ai_toolchain_develop/horizon_ai_toolchain_user_guide/supported_op_list_and_restrictions.html).

  • Even if i put GlobalAveragePool_380 on CPU, the cosine similarity of it is not very high yet (about 0.90).

  • No matter what the inputs are, the second ouput (named output2) of *.bin with GlobalAveragePool_380 on BPU has constant values. You can see the strange phenomenon by changing the inputs in debug.py provided below.

My config.yaml is as follows:

The DCMT_sim.onnx and files of calibration can be found in the link below:

链接: https://pan.baidu.com/s/1xh4KNGrXgJkPHrrdYX6oZg 提取码: zshn

PS: DCMT_sim.onnx and files of calibration has been validated and they are good~

To verify the *.bin, you can use codes of debug.py as follows:

x.bin, z.bin and b.bin can be found in https://developer.horizon.ai/forumDetail/146176815327779277

THANKS VERY MUCH~

算法工具链
技术深度解析
评论2
0/1000
  • 颜值即正义
    Lv.2

    Hi, it is recommended to try only using Exp_ 474 run_ on_ cpu. Other issues will be discussed after your feedback. Look forward to your reply~

    2023-03-31
    2
    3
    • cherry回复颜值即正义:

      Emm...If i execute only Exp_474 on cpu, it seems that the model's outputs are right (with some precision loss but the outputs' value of "output2" are not constant)! ?

      So, the operator Exp_474 causes the problem of constant outputs?!! Why?

      and How can i execute the operator on BPU well? ?

      I also notice that if i put Exp_474 on cpu and GlobalAveragePool_380 on BPU, the cosine similarity of GlobalAveragePool_380 is not high(0.839681).

      The hb_mapper_makertbin.log and other model files can be found in the following link:

      链接: https://pan.baidu.com/s/1fkAB7REE_lpHLvBof1fwQw 提取码: n5kf

      2023-03-31
      0
    • 颜值即正义回复cherry:

      Emm...We are still analyzing the problem of the Exp_474 operator.

      It is recommended to verify the accuracy of the model. Cosine similarity is not necessarily proportional to accuracy, it is only used as a reference indicator

      2023-04-03
      0
    • 颜值即正义回复cherry:

      Hi,Please install the three patches in the compressed package. Then, Exp_474 can be run on bpu.

      链接:https://pan.horizon.ai/index.php/s/X9QAAGziJKP98AJ

      2023-04-03
      0
  • 颜值即正义
    Lv.2
    2023-04-24
    0
    0