onnx相关包:
onnx 1.13.0
onnx-simplifier 0.4.33
onnx-tool 0.8.1
onnxconverter-common 1.14.0
onnxmltools 1.11.2
onnxruntime 1.16.0
skl2onnx 1.15.0
代码:
from onnxmltools.utils import float16_converter
import onnx
onnx_model = onnx.load_model(output_path)
trans_model = float16_converter.convert_float_to_float16(onnx_model, keep_io_types=False)
onnx.save_model(trans_model, output_path)
参考:
https://blog.csdn.net/qq_18236971/article/details/129635971#:~:text=%E4%B8%8B%E9%9D%A2%E6%98%AF%E4%B8%80%E4%B8%AA%E7%AE%80%E5%8D%95%E7%9A%84%E7%A4%BA%E4%BE%8B%E4%BB%A3%E7%A0%81%EF%BC%9A%20%60%60%60%20python%20import%20onnx%20from%20onnx%20import,onnx.save%20%28model%2C%20%22model_%20fp16.%20onnx%20%22%29%20%60%60%60%20%E8%AF%B7%E6%B3%A8%E6%84%8F%EF%BC%8C%E8%BF%99%E5%8F%AA%E6%98%AF%E4%B8%80%E4%B8%AA%E7%AE%80%E5%8D%95%E7%9A%84%E7%A4%BA%E4%BE%8B%E4%BB%A3%E7%A0%81%EF%BC%8C%E5%AE%9E%E9%99%85%E6%83%85%E5%86%B5%E5%8F%AF%E8%83%BD%E4%BC%9A%E6%9C%89%E6%89%80%E4%B8%8D%E5%90%8C%E3%80%82