forked from OSchip/llvm-project
Fix the equality check of two floating point values
PiperOrigin-RevId: 266022088
This commit is contained in:
parent
29099e03ce
commit
7dd5efdf2c
|
@ -71,10 +71,12 @@ mlir::quant::fakeQuantAttrsToType(Location loc, unsigned numBits, double rmin,
|
|||
nullptr);
|
||||
}
|
||||
|
||||
// Special case where min/max is a point. Must be 0.
|
||||
if (rmin == rmax) {
|
||||
// Special case where min/max is close enough. The tensor contents are all
|
||||
// 0.0s, so the scale is set to 1.0 and the tensor can be quantized to zero
|
||||
// points and dequantized to 0.0.
|
||||
if (std::fabs(rmax - rmin) < std::numeric_limits<double>::epsilon()) {
|
||||
return UniformQuantizedType::getChecked(flags, storageType, expressedType,
|
||||
0.0, 0, qmin, qmax, loc);
|
||||
1.0, 0, qmin, qmax, loc);
|
||||
}
|
||||
|
||||
// Determine the scale.
|
||||
|
|
Loading…
Reference in New Issue