This is an automated email from the ASF dual-hosted git repository.
bgawrych pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
The following commit(s) were added to refs/heads/master by this push:
new b713dc5aa3 [BUGFIX] Fix DNNL requantize operator overflow error
(#21079)
b713dc5aa3 is described below
commit b713dc5aa3da76e2244cd4df9715a4fb2b2545ac
Author: Andrzej Kotłowski <[email protected]>
AuthorDate: Tue Jul 5 09:42:02 2022 +0200
[BUGFIX] Fix DNNL requantize operator overflow error (#21079)
* Fix DNNL requantize operator overflow error
* Update src/operator/quantization/dnnl/dnnl_requantize-inl.h
Co-authored-by: bartekkuncer <[email protected]>
---
src/operator/quantization/dnnl/dnnl_requantize-inl.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/operator/quantization/dnnl/dnnl_requantize-inl.h
b/src/operator/quantization/dnnl/dnnl_requantize-inl.h
index 3095b87bd4..e2009d6508 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<SrcDType>(), MaxValue<SrcDType>());
- 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<float>(),
*inputs[2].data().dptr<float>());
real_range = data_range * data_scale / src_range;
}