AMCT量化onnx,低版本onnx grid_sample算子版本不适配,expand算子无法命中高性能库,量化变慢
收藏回复举报
AMCT量化onnx,低版本onnx grid_sample算子版本不适配,expand算子无法命中高性能库,量化变慢
t('forum.solved') 已解决
发表于2024-10-04 15:30:11
0 查看

1.配置

硬件:Atlas200I A2 Ascend310B1

CANN:8.0.RC1.alpha003

操作系统:Ubuntu 22.04

2.问题现象

pytorch 导出onnx version16模型推理正常,atc转换om正常,fp32推理速度较慢,尝试AMCT量化int8提速。AMCT提示仅支持onnx版本到14,降低onnx版本导出pytorch模型时提示onnx低版本不支持torch grid_sample算子,用mmcv的grid_sample算子等效代替后导出onnx version12正常,AMCT量化成功,atc转换成功,但是大量expand无法命中高性能库,即mmcv grid_sample代替torch grid_sample算子位置

cke_22834.png

量化前om推理0.55s/it,量化后1.62s/it

3.量化命令

amct_onnx calibration --model ./onnx/rtdetr_dinov2_small_military_peft_ms_61_onnx12_pytorch.onnx --save_path ./result/rtdetr_dinov2_small_military_peft_ms_61_onnx12_pytorch --input_shape "images:1,3,672,672"  --data_dir "./data/calibration"  --data_types "float32"

atc转换命令

atc --model=rtdetr_dinov2_small_military_peft_ms_61_onnx12_pytorch_deploy_model.onnx --framework=5 --output=rtdetr_dinov2_small_military_peft_ms_61_onnx12_pytorch_deploy_model --input_shape="images:1,3,672,672" --soc_version=Ascend310B1

4.原onnx16、低版本onnx12、量化后的onnx12_int8,atc转换结果onnx12_int8_om,原onnx16转换fp32om,calibration.bin文件,推理图片,推理代码链接

https://pan.baidu.com/s/1vzBurnpK3LHnPlAMTkdSIA?pwd=wid9 

这种量化要求低版本onnx不支持gridsample有替代办法吗,expand命中不了高性能库有办法吗

我要发帖子