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

Commit b713dc5

Browse files
[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 <bartosz.kuncer@intel.com>
1 parent 5abdc77 commit b713dc5

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ static void DNNLRequantizeForward(const nnvm::NodeAttrs& attrs,
132132
data_min = data_mins[i];
133133
}
134134
float src_range = MinAbs(MinValue<SrcDType>(), MaxValue<SrcDType>());
135-
SrcDType data_range = MaxAbs(data_min, data_max);
135+
// MaxAbs is not used here as it converts data to float what could cause overflow errors.
136+
SrcDType data_range = std::max(std::abs(data_min), std::abs(data_max));
136137
float data_scale = MaxAbs(*inputs[1].data().dptr<float>(), *inputs[2].data().dptr<float>());
137138
real_range = data_range * data_scale / src_range;
138139
}

0 commit comments

Comments
 (0)