-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add API for quantization-aware training in dygraph mode #49398
Conversation
1. Expose an API named paddle.quantization.QAT 2. Define a wrapper class to insert quanters into model for QAT 3. Add some functions in QuantConfig for QAT 4. Add unittest for QAT
你的PR提交成功,感谢你对开源项目的贡献! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for setup.py.in
PR types
Others
PR changes
APIs
Describe
Add API for quantization-aware training in dygraph mode
如下图所示,本PR主要新增三个模块:Wrapper、QuantedLayers(包括QuantedConv2D、QquantedLinear)、QAT
Wrapper
装饰器,将任意Layer和Quanter/Observer包装成一个Layer。
QuantedLayers
与Wrapper类似,装饰器类,用于在Layer前插入Observer/Qaunter. Wrapper针对无权重Layer,QuantedLayers针对带权重的特定Layer,比如QuantedConv2D.
QAT
类图
时序图
示例
以下示例来自
paddle/tests/quantization/test_qat.py
原始模型
调用
qat.quantize(mdoel)
之后的模型: