Support user-defined activation/weight quantize and preprocess. #28570
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR types
New features
PR changes
APIs
Describe
Support user-defined quantification and preprocessing methods, such as PACT.
QAT model without using PACT
----------------------------------------------------------------------------------------------- Layer (type) Input Shape Output Shape Param # =============================================================================================== FakeQuantMovingAverage-1 [[1, 1, 28, 28]] [1, 1, 28, 28] 3 FakeChannelWiseQuantDequantAbsMax-1 [[6, 1, 3, 3]] [6, 1, 3, 3] 6 QuantizedConv2D-1 [[1, 1, 28, 28]] [1, 6, 28, 28] 60 Pool2D-1 [[1, 6, 28, 28]] [1, 6, 14, 14] 0 FakeQuantMovingAverage-2 [[1, 6, 14, 14]] [1, 6, 14, 14] 3 FakeChannelWiseQuantDequantAbsMax-2 [[16, 6, 5, 5]] [16, 6, 5, 5] 16 QuantizedConv2D-2 [[1, 6, 14, 14]] [1, 16, 10, 10] 2,416 Pool2D-2 [[1, 16, 10, 10]] [1, 16, 5, 5] 0 FakeQuantMovingAverage-3 [[1, 400]] [1, 400] 3 FakeChannelWiseQuantDequantAbsMax-3 [[400, 120]] [400, 120] 120 QuantizedLinear-1 [[1, 400]] [1, 120] 48,120 FakeQuantMovingAverage-4 [[1, 120]] [1, 120] 3 FakeChannelWiseQuantDequantAbsMax-4 [[120, 84]] [120, 84] 84 QuantizedLinear-2 [[1, 120]] [1, 84] 10,164 FakeQuantMovingAverage-5 [[1, 84]] [1, 84] 3 FakeChannelWiseQuantDequantAbsMax-5 [[84, 10]] [84, 10] 10 QuantizedLinear-3 [[1, 84]] [1, 10] 850 =============================================================================================== Total params: 61,861 Trainable params: 61,610 Non-trainable params: 251 ----------------------------------------------------------------------------------------------- Input size (MB): 0.00 Forward/backward pass size (MB): 0.55 Params size (MB): 0.24 Estimated Total Size (MB): 0.79 -----------------------------------------------------------------------------------------------PACT QAT model:
----------------------------------------------------------------------------------------------- Layer (type) Input Shape Output Shape Param # =============================================================================================== PACT-1 [[1, 1, 28, 28]] [1, 1, 28, 28] 1 FakeQuantMovingAverage-1 [[1, 1, 28, 28]] [1, 1, 28, 28] 3 FakeChannelWiseQuantDequantAbsMax-1 [[6, 1, 3, 3]] [6, 1, 3, 3] 6 QuantizedConv2D-1 [[1, 1, 28, 28]] [1, 6, 28, 28] 60 Pool2D-1 [[1, 6, 28, 28]] [1, 6, 14, 14] 0 PACT-2 [[1, 6, 14, 14]] [1, 6, 14, 14] 1 FakeQuantMovingAverage-2 [[1, 6, 14, 14]] [1, 6, 14, 14] 3 FakeChannelWiseQuantDequantAbsMax-2 [[16, 6, 5, 5]] [16, 6, 5, 5] 16 QuantizedConv2D-2 [[1, 6, 14, 14]] [1, 16, 10, 10] 2,416 Pool2D-2 [[1, 16, 10, 10]] [1, 16, 5, 5] 0 PACT-3 [[1, 400]] [1, 400] 1 FakeQuantMovingAverage-3 [[1, 400]] [1, 400] 3 FakeChannelWiseQuantDequantAbsMax-3 [[400, 120]] [400, 120] 120 QuantizedLinear-1 [[1, 400]] [1, 120] 48,120 PACT-4 [[1, 120]] [1, 120] 1 FakeQuantMovingAverage-4 [[1, 120]] [1, 120] 3 FakeChannelWiseQuantDequantAbsMax-4 [[120, 84]] [120, 84] 84 QuantizedLinear-2 [[1, 120]] [1, 84] 10,164 PACT-5 [[1, 84]] [1, 84] 1 FakeQuantMovingAverage-5 [[1, 84]] [1, 84] 3 FakeChannelWiseQuantDequantAbsMax-5 [[84, 10]] [84, 10] 10 QuantizedLinear-3 [[1, 84]] [1, 10] 850 =============================================================================================== Total params: 61,866 Trainable params: 61,615 Non-trainable params: 251 ----------------------------------------------------------------------------------------------- Input size (MB): 0.00 Forward/backward pass size (MB): 0.57 Params size (MB): 0.24 Estimated Total Size (MB): 0.81 -----------------------------------------------------------------------------------------------