ZhennanQin opened a new pull request #15961: Improve quantization flow
URL: https://github.com/apache/incubator-mxnet/pull/15961
 
 
   ## Description ##
   @pengzhao-intel @TaoLv @xinyu-intel @reminisce @KellenSunderland @anirudh2290
   Major changes:
   * Don't need `calib_layer`, the layer list which needs calibrated will be 
generated from quantization pass, so user don't need to specify that. Only 
needed layer get calibrated, thus improve the calibration speed.
   
   * Entropy is refactored, only histogram of output is saved, which will help 
to reduce memory consumption. Entropy calculation is refactored as c++ 
operator, accuracy is improved, then entropy method can get same speed as naive.
   
   
   Model | FP32 Accuracy | INT8 Naïve | INT8 entropy_old | INT8 entropy_new
   -- | -- | -- | -- | --
   ResNet50-V1 | 76.340% | 76.060% | 76.006% | 76.053%
   Squeezenet 1.0 | 56.980% | 56.790% | 55.584% | 56.997%
   MobileNet 1.0 | 72.230% | 72.060% | 71.822% | 71.822%
   MobileNetV2 1.0 | 70.270% | 69.820% | 69.950% | 70.016%
   Inception V3 | 77.760% | 78.050% | 78.019% | 78.053%
   Inception-BN | 72.280% | 72.020% | 72.084% | 71.978%
   mean_for_all | 70.977% | 70.800% | 70.578% | 70.820%
   
   
   
   * Add new quantization mode `smart`, which will automatically decide each op 
should be quantized or not. This mode will only quantize nodes which have 
performance benefit(e.g. convolution and FC), and necessary nodes. For example, 
`A` is convolution or FC, which will be all quantized. `B` is Relu or Add, 
which is quantizable and quantization flow will make decision whether to 
quantize it or not. `C` is non-quantized node. For `A -> B -> A`, `B` will be 
quantized as it can pass down int8 data. For `C->B->C`, `A -> B -> C`, or `C -> 
B -> A`, `B` won't be quantized. 
   
   * Add log for quantization flow, this can help to user to understand what 
quantization flow does and what's changed.
   
   
   ## Checklist ##
   ### Essentials ###
   Please feel free to remove inapplicable items for your PR.
   - [ ] The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to 
the relevant [JIRA issue](https://issues.apache.org/jira/projects/MXNET/issues) 
created (except PRs with tiny changes)
   - [ ] Changes are complete (i.e. I finished coding on this PR)
   - [ ] All changes have test coverage:
   - Unit tests are added for small changes to verify correctness (e.g. adding 
a new operator)
   - Nightly tests are added for complicated/long-running ones (e.g. changing 
distributed kvstore)
   - Build tests will be added for build configuration changes (e.g. adding a 
new build option with NCCL)
   - [ ] Code is well-documented: 
   - For user-facing API changes, API doc string has been updated. 
   - For new C++ functions in header files, their functionalities and arguments 
are documented. 
   - For new examples, README.md is added to explain the what the example does, 
the source of the dataset, expected performance on test set and reference to 
the original paper if applicable
   - Check the API doc at 
http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
   - [ ] To the my best knowledge, examples are either not affected by this 
change, or have been fixed to be compatible with this change
   
   ### Changes ###
   - [ ] Feature1, tests, (and when applicable, API doc)
   - [ ] Feature2, tests, (and when applicable, API doc)
   
   ## Comments ##
   - If this change is a backward incompatible change, why must this change be 
made.
   - Interesting edge cases to note here
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to