diff --git a/src/operator/quantization/dnnl/dnnl_requantize-inl.h b/src/operator/quantization/dnnl/dnnl_requantize-inl.h index 3095b87bd4ad..e2009d65081c 100644 --- a/src/operator/quantization/dnnl/dnnl_requantize-inl.h +++ b/src/operator/quantization/dnnl/dnnl_requantize-inl.h @@ -132,7 +132,8 @@ static void DNNLRequantizeForward(const nnvm::NodeAttrs& attrs, data_min = data_mins[i]; } float src_range = MinAbs(MinValue(), MaxValue()); - SrcDType data_range = MaxAbs(data_min, data_max); + // MaxAbs is not used here as it converts data to float what could cause overflow errors. + SrcDType data_range = std::max(std::abs(data_min), std::abs(data_max)); float data_scale = MaxAbs(*inputs[1].data().dptr(), *inputs[2].data().dptr()); real_range = data_range * data_scale / src_range; }