一. 说明
在模型量化过程中,经常要使用一些工具对onnx
或者量化后的模型(这里以TensorRT为例)进行推理,往往需要一些处理工具,比如:
- 拆分或者合并
onnx
; - 修改
onnx
中的量算子QuantizeLinear
的scale
值; - 以及使用
onnxruntime
进行推理; TensorRT
的序列化文件的inference
;- 隐式量化生成量化校准表
- …
现提供一些封装好的工具,作为记录,方便日后查阅使用
"""
Author : tianlianghuanji
Description : onnx and trt tools.
"""
import tensorrt as trt
import onnxruntime
import onnx
import torch
from onnxsim