Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quantize export in Python #651

Closed
wants to merge 122 commits into from

Conversation

yeliang2258
Copy link
Collaborator

@yeliang2258 yeliang2258 commented Mar 25, 2022

支持Paddle量化模型导出

  1. 如果你导出的ONNX模型用TensorRT进行部署,TensorRT可直接加载该模型做量化推理
paddle2onnx --model_dir quant_inference_model/ --model_filename model.pdmodel --params_filename model.pdiparams --save_file model.onnx --opset_version 13 --enable_onnx_checker True --deploy_backend TensorRT
  1. 如果你导出的ONNX模型用ONNXRuntime进行部署,ONNXRuntime可直接加载该模型做量化推理
paddle2onnx --model_dir quant_inference_model/ --model_filename model.pdmodel --params_filename model.pdiparams --save_file model.onnx --opset_version 13 --enable_onnx_checker True --deploy_backend ONNXRuntime
  1. 如果你导出的ONNX模型用其他推理引擎部署,将会导出float模型和量化表,量化表是内容:{tensor_name: scale_list, zero_list }
paddle2onnx --model_dir quant_inference_model/ --model_filename model.pdmodel --params_filename model.pdiparams --save_file model.onnx --opset_version 13 --enable_onnx_checker True --deploy_backend Others

yeliang2258 and others added 30 commits November 10, 2021 13:54
if node.type in ["dequantize_linear", "quantize_linear"]:
return "new_type"
# If the next op of conv or matmul is a dequantize OP, it is a static type
if node.type.count("conv") or node.type.count("matmul"):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么需要是op为conv/matmul,且下一个OP的名字中包含dequantize或quantize_dequantize,才为static。 直接判断模型中的OP是否存在dequantize或quantize_dequantize,会有什么问题

@yeliang2258 yeliang2258 changed the title New quantize dev Python quantize export Aug 9, 2022
@yeliang2258 yeliang2258 changed the title Python quantize export Quantize export in Python Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants