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

Commit

Permalink
[BUGFIX] Fix DNNL requantize operator overflow error (#21079)
Browse files Browse the repository at this point in the history
* Fix DNNL requantize operator overflow error

* Update src/operator/quantization/dnnl/dnnl_requantize-inl.h

Co-authored-by: bartekkuncer <bartosz.kuncer@intel.com>
  • Loading branch information
anko-intel and bartekkuncer authored Jul 5, 2022
1 parent 5abdc77 commit b713dc5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/operator/quantization/dnnl/dnnl_requantize-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit b713dc5

Please sign in to comment.