使用mindX推理接口调用 yolov5.om模型,量化前模型居然比量化后模型推理的更快?
收藏回复举报
使用mindX推理接口调用 yolov5.om模型,量化前模型居然比量化后模型推理的更快?
t('forum.solved') 已解决
发表于2025-03-05 12:02:51
0 查看

问题

量化后模型比量化前更慢

复现流程

  1. pt模型转onnx 按照yolov5官方流程export动态模型
  2. om模型转换
    #fp32模型转换
    atc --framework=5 --model=$model --input_shape=$input_shape --insert_op_conf=aipp-bgr.cfg --output=./outputs/$model_name --soc_version=Ascend310P3 --log=info 
    #int8 模型转换
     atc --framework=5 --model=$model --input_shape=$input_shape --insert_op_conf=aipp-bgr.cfg --output=./outputs/$model_name  --compression_optimize=$cfg_name --soc_version=Ascend310P3 --log
    aipp-bgr.cfg
    aipp_op {
    aipp_mode : static
    input_format : RGB888_U8
    src_image_size_w : 640 
    src_image_size_h : 640
    
    csc_switch : false
    rbuv_swap_switch : true
    
    min_chn_0 : 0
    min_chn_1 : 0
    min_chn_2 : 0
    var_reci_chn_0: 0.0039215686274509803921568627451
    var_reci_chn_1: 0.0039215686274509803921568627451
    var_reci_chn_2: 0.0039215686274509803921568627451}
    cfg_name文件内容
    enable_first_layer_quantization:true
    calibration:
    {
        input_data_dir: ./data/images/calibration.bin
        input_shape: images:1,3,640,640
        infer_soc: Ascend310P3
        log: info
    }
  3. 使用mindX Model类的Infer方法进行推理,统计推理时间如下:
    batch数  推理时间
    1                 13.8          int8量化 
    1                 8.67          fp32

本帖最后由 匿名用户2025/03/12 14:52:21 编辑

我要发帖子