KellenSunderland commented on a change in pull request #13697: [MKLDNN] Enable 
signed int8 support for convolution.
URL: https://github.com/apache/incubator-mxnet/pull/13697#discussion_r244628057
 
 

 ##########
 File path: example/quantization/imagenet_gen_qsym_mkldnn.py
 ##########
 @@ -140,8 +140,8 @@ def save_params(fname, arg_params, aux_params, 
logger=None):
                              ' thresholds. This mode is expected to produce 
the best inference accuracy of all three'
                              ' kinds of quantized models if the calibration 
dataset is representative enough of the'
                              ' inference dataset.')
-    parser.add_argument('--quantized-dtype', type=str, default='uint8',
-                        choices=['int8', 'uint8'],
+    parser.add_argument('--quantized-dtype', type=str, default='auto',
 
 Review comment:
   So reading a bit more about this from 
https://intel.github.io/mkl-dnn/ex_int8_simplenet.html 
   
   ```C++
   const std::vector<float> src_scales = { 1.8 };
   const int src_mask = 0;
   auto user_src_memory = memory({ { { conv_src_tz }, memory::data_type::f32, 
memory::format::nchw }, cpu_engine }, user_src.data());
   auto conv_src_md = memory::desc( { conv_src_tz }, memory::data_type::u8, 
memory::format::any);
   auto conv_desc = convolution_forward::desc(prop_kind::forward,
           convolution_direct, conv_src_md, conv_weights_md, conv_bias_md,
           conv_dst_md, conv_strides, conv_padding, conv_padding,
           padding_kind::zero);
   auto conv_prim_desc = convolution_forward::primitive_desc(conv_desc, 
conv_attr, cpu_engine);
   auto conv_src_memory = memory(conv_prim_desc.src_primitive_desc());
   primitive_attr src_attr;
   src_attr.set_int_output_round_mode(round_mode::round_nearest);
   src_attr.set_output_scales(src_mask, src_scales);
   auto src_reorder_pd = 
reorder::primitive_desc(user_src_memory.get_primitive_desc(), 
conv_src_memory.get_primitive_desc(), src_attr);
   ```
   
   am I understanding correctly that we can convert from an fp32 input (with 
negative values) to uint8 via a reorder primitive.  Do we do this for the first 
negative input into subgraphs handled by mkldnn?  If so is there an advantage 
to doing the reorder into a signed type as opposed to unsigned?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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