Use rounding in requantize.
This is to avoid a systematic bias of ops using requantize.
Fixes: 134078526
Test: NeuralNetworksTest_static
Change-Id: I3f64f5b2d5778bfe613707cfa252f67e87dce9c5
Merged-In: I3f64f5b2d5778bfe613707cfa252f67e87dce9c5
(cherry picked from commit 654b735b8196ed5b703d73f3e4ab8a9bc354d471)
diff --git a/common/OperationsUtils.cpp b/common/OperationsUtils.cpp
index 99c1178..e128afb 100644
--- a/common/OperationsUtils.cpp
+++ b/common/OperationsUtils.cpp
@@ -340,7 +340,7 @@
double doubleRet = doubleValue / newShape.scale + newShape.offset;
if (doubleRet < 0) return 0;
if (doubleRet > 255) return 255;
- return static_cast<uint8_t>(doubleRet);
+ return static_cast<uint8_t>(std::round(doubleRet));
}
bool floorPrepare(const Shape& input, Shape* output) {