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

Type inconsistent error when running C++ inference script on quantized models #15057

Closed
wuxun-zhang opened this issue May 24, 2019 · 3 comments
Closed
Labels
Bug C++ Related to C++

Comments

@wuxun-zhang
Copy link
Contributor

Description

When I ran C++ inference script with quantized models, there always have a type inconsistent issue. Also current C++ script didn't support performance benchmark for int8/fp32 models which is not aligned with Python implementation.

Environment info (Required)

----------Python Info----------
Version      : 3.6.3
Compiler     : GCC 7.2.0
Build        : ('default', 'Oct 13 2017 12:02:49')
Arch         : ('64bit', '')
------------Pip Info-----------
Version      : 19.0.3
Directory    : /home/wuxunzha/anaconda3/lib/python3.6/site-packages/pip
----------MXNet Info-----------
Version      : 1.5.0
Directory    : /home/wuxunzha/github/incubator-mxnet/python/mxnet
Hashtag not found. Not installed from pre-built package.
----------System Info----------
Platform     : Linux-3.10.0-693.el7.x86_64-x86_64-with-centos-7.4.1708-Core
system       : Linux
node         : mlt-skx126
release      : 3.10.0-693.el7.x86_64
version      : #1 SMP Tue Aug 22 21:09:27 UTC 2017
----------Hardware Info----------
machine      : x86_64
processor    : x86_64
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                80
On-line CPU(s) list:   0-79
Thread(s) per core:    2
Core(s) per socket:    20
Socket(s):             2
NUMA node(s):          2
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 85
Model name:            Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz
Stepping:              4
CPU MHz:               2920.593
CPU max MHz:           3700.0000
CPU min MHz:           1000.0000
BogoMIPS:              4800.00
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              1024K
L3 cache:              28160K
NUMA node0 CPU(s):     0-19,40-59
NUMA node1 CPU(s):     20-39,60-79
Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb cat_l3 cdp_l3 intel_pt tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req
----------Network Test----------
Setting timeout: 10
Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.0037 sec, LOAD: 1.8064 sec.
Timing for Gluon Tutorial(en): http://gluon.mxnet.io, DNS: 1.1238 sec, LOAD: 2.2858 sec.
Timing for Gluon Tutorial(cn): https://zh.gluon.ai, DNS: 0.0083 sec, LOAD: 7.1059 sec.
Timing for FashionMNIST: https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.0102 sec, LOAD: 1.9081 sec.
Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0040 sec, LOAD: 25.4131 sec.
Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.0065 sec, LOAD: 1.9943 sec.

Package used :
I'm using C++ package.

Build info (Required if built from source)

Compiler (gcc/clang/mingw/visual studio): gcc

MXNet commit hash:
b0be6c5

Build config:
make USE_CPP_PACKAGE=1 USE_OPENCV=1 USE_MKLDNN=1 USE_BLAS=mkl -j

Error Message:

[12:52:10] inception_inference.cpp:150: Loading the model from ./model/mobilenet1.0-quantized-5batches-naive-symbol.json
[12:52:10] inception_inference.cpp:163: Loading the model parameters from ./model/mobilenet1.0-quantized-0000.params
[12:52:10] inception_inference.cpp:190: Loading the synset file.
[12:52:10] inception_inference.cpp:212: Load the mean image data that will be used to normalize the image before running forward pass.
[12:52:10] inception_inference.cpp:438: Execution failed with ERROR: Error in operator quantized_sg_mkldnn_fully_connected_0: Type inconsistent, Provided = float32, inferred type = int8

Minimum reproducible example

You can refer to this README to run C++ inference. Quantized models can be generated according to this flow .

Steps to reproduce

When you have already built inception_inference and prepared the quantized model, you can run ./inception_inference --symbol "./model/mobilenet1.0-quantized-5batches-naive-symbol.json" --params "./model/mobilenet1.0-quantized-0000.params" --mean "./model/mean_224.nd" --synset "./model/synset.txt" --image "./model/dog.jpg" to reproduce the issue.

What have you tried to solve it?

  1. This PR was already filed to fix the above type inconsistent error.
  2. We are also going to improve the performance benchmark of C++ inference in the future PR.
@mxnet-label-bot
Copy link
Contributor

Hey, this is the MXNet Label Bot.
Thank you for submitting the issue! I will try and suggest some labels so that the appropriate MXNet community members can help resolve it.
Here are my recommended labels: Bug, C++

@leleamol
Copy link
Contributor

@mxnet-label-bot add [C++, Bug]

@marcoabreu marcoabreu added Bug C++ Related to C++ labels May 26, 2019
@TaoLv
Copy link
Member

TaoLv commented May 26, 2019

Should be fixed via #15038 . Now closed.

@TaoLv TaoLv closed this as completed May 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug C++ Related to C++
Projects
None yet
Development

No branches or pull requests

5 participants