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

[WIP] Support deploy MMRazor quantized model #1471

Open
wants to merge 23 commits into
base: dev-1.x
Choose a base branch
from

Conversation

pppppM
Copy link
Contributor

@pppppM pppppM commented Nov 30, 2022

Motivation

The related pr in MMRazor is open-mmlab/mmrazor#365

MMRazor is developing quantization algorithms, including PTQ and QAT.
This PR is a draft code to deploy MMRazor quantization model in MMDeploy, mainly with the following two points.

Export FX Graph

MMRazor quantized model is FX graph, and the current function rewriter cannot handle FX graph correctly.
The function rewriter has been fine-tuned in this PR, which can handle FX graph correctly.

Export Quantized ONNX

Different backends have different ONNX formats for quantized models, TensorRT and Openvion's quantized onnx exporters are implemented in this pr.

Modification

Function Rewriter

The original function rewriter is a wrapper, and the first arg is ctx.
In order to process FX Graph, wrapper is no longer used in this pr.
The original function is directly replaced by rewritten function, and ctx is removed from args.
ctx becomes a global variable.

Quantize ONNX Exporter

This pr adds a fake quant symbolic op, with which a temporary non-running onnx can be exported.
Then, different backends quantize onnx exporter will convert it to final deployed onnx.

python tools/deploy.py configs/mmdet/detection/detection_openvino_dynamic-800x1344-quantize.py  $RETINANET $FLOAT_CKPT demo/resources/det.jpg --show

@CLAassistant
Copy link

CLAassistant commented Dec 12, 2022

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ pppppM
❌ grimoire


grimoire seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

3 participants