oneDNN icon indicating copy to clipboard operation
oneDNN copied to clipboard

how to support quant tensor in mkldnn?

Open xiechao4 opened this issue 9 years ago • 1 comments

As the tensor is type of int8 with scale and zeropoint. it means that real_val = (quant_val - zeropoint) * scale. So how do i use mkldnn for the quant tensor? i suppose that reorder can change the quant to real value. but i do not see it in doc or example code.

xiechao4 avatar Dec 01 '17 08:12 xiechao4

Hi @kriszhangyf,

MKL-DNN doesn't support quantization with shifted zero. Reorders can do the following:

dst <-- saturate<dst_type>((float)reorder_scale * src)

Please see attributes API, and reorder harness in benchdnn. Convolution also supports conv_scale, to help using low-precision (int8) computations. Currently it supports the following:

dst <-- saturate<dst_type>((float)conv_scale * (conv(src_u8, wei_s8, accum data type = s32) + bia_zz))

Here bia_zz -- means that bias might be either f32, s32, s8, or u8 type. The same for dst_type -- it might be any of f32, s32, {u,s}8.

Please also note, that int8-convolution requires processor with avx512 (avx512_bw) support.

emfomenk avatar Dec 09 '17 23:12 emfomenk