diff options
| author | Feng Liu <fengliuai@google.com> | 2019-08-28 16:39:18 -0700 |
|---|---|---|
| committer | A. Unique TensorFlower <gardener@tensorflow.org> | 2019-08-28 16:39:48 -0700 |
| commit | 7dd5efdf2c216330a1ae8d866ad4a0e0bf86265e (patch) | |
| tree | a9adf91152e3c2d2a742e859fd6c8a1947ab8f96 /mlir/lib/Dialect/QuantOps/Utils | |
| parent | 29099e03ce2f8e4546f3ba1086fb51749abc0c62 (diff) | |
| download | bcm5719-llvm-7dd5efdf2c216330a1ae8d866ad4a0e0bf86265e.tar.gz bcm5719-llvm-7dd5efdf2c216330a1ae8d866ad4a0e0bf86265e.zip | |
Fix the equality check of two floating point values
PiperOrigin-RevId: 266022088
Diffstat (limited to 'mlir/lib/Dialect/QuantOps/Utils')
| -rw-r--r-- | mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp b/mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp index 2667da98242..eeb69b77102 100644 --- a/mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp +++ b/mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp @@ -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. |

