Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[int8] Add MobileNetV2_1.0 & ResNet18 Quantization #14823

Merged
merged 5 commits into from
Apr 30, 2019

Conversation

xinyu-intel
Copy link
Contributor

Description

Add MobileNetV2_1.0 & ResNet18 Quantization.

ResNet18 Performance on Skylake 8180 28c

resnet18_v1 fp32 int8 speedup
1 309.61 492.18 1.59
64 810.82 1341.55 1.65
accuracy 70.07%/89.30% 69.85%/89.23%  

#14819 will improve mobilenetv2 fp32/int8 performance

mobilenetv2_1.0 fp32 int8 speedup fp32_opt int8_opt speedup
1 75.22 162.12 2.16 240.51 413.92 1.72
64 291.63 469.28 1.61 795.86 3137.77 3.94
accuracy 70.14%/89.60% 63.62%/84.84%   70.14%/89.60% 69.53%/89.24%  

@pengzhao-intel @ZhennanQin

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 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:https://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

@xinyu-intel xinyu-intel requested a review from szha as a code owner April 28, 2019 07:34
@pengzhao-intel
Copy link
Contributor

cc @zhreshold

@pengzhao-intel pengzhao-intel added this to Review in progress in CPU Performance and Quantization Apr 28, 2019
CPU Performance and Quantization automation moved this from Review in progress to Reviewer approved Apr 28, 2019
Copy link
Contributor

@pengzhao-intel pengzhao-intel left a comment

Choose a reason for hiding this comment

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

LGTM, let's wait the CI back.

@@ -392,6 +392,7 @@ mkldnn_memory_format_t GetDefaultFormat(const mkldnn::memory::desc &desc) {
case mkldnn_gOhwi8o:
case mkldnn_gOhwi16o:
case mkldnn_gOhIw16o4i:
case mkldnn_Goihw16g_s8s8:
Copy link
Member

Choose a reason for hiding this comment

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

What's this? It's first time for us to have this format?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, when quantize s8s8 group conv.

@@ -234,6 +242,12 @@ def save_params(fname, arg_params, aux_params, logger=None):
'mobilenet0_pool0_fwd']
if exclude_first_conv:
excluded_sym_names += ['mobilenet0_conv0_fwd']
elif args.model == 'mobilenetv2_1.0':
rgb_mean = '123.68,116.779,103.939'
Copy link
Member

Choose a reason for hiding this comment

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

is there any exception that the rgb_mean dna std is not the same? otherwise repeatively coding it looks redundant

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree with @zhreshold, along with enabling more models, we don't need to show how to reproduce each one since most of the command is very similar. We need to define a template for the user to reproduce any existed models for classification networks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zhreshold @pengzhao-intel agree, I'll refactor this script along with enabling more models next time.

@roywei
Copy link
Member

roywei commented Apr 29, 2019

@mxnet-label-bot add [Quantization, Example]

@marcoabreu marcoabreu added Example Quantization Issues/Feature Requests related to Quantization labels Apr 29, 2019
@pengzhao-intel
Copy link
Contributor

pengzhao-intel commented Apr 30, 2019

Merging now. @xinyu-intel will refactor the script in the next PR.

@pengzhao-intel pengzhao-intel merged commit bde1b84 into apache:master Apr 30, 2019
CPU Performance and Quantization automation moved this from Reviewer approved to Done Apr 30, 2019
access2rohit pushed a commit to access2rohit/incubator-mxnet that referenced this pull request May 14, 2019
* add resnet18 and mobilenetv2 models

* add readme

* support mkldnn s8s8 goihw16g weight format

* fix_readme_typo
haohuanw pushed a commit to haohuanw/incubator-mxnet that referenced this pull request Jun 23, 2019
* add resnet18 and mobilenetv2 models

* add readme

* support mkldnn s8s8 goihw16g weight format

* fix_readme_typo
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Example Quantization Issues/Feature Requests related to Quantization
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

6 participants