From 88f83019a8df581b6eb85cfbb3ae978733052895 Mon Sep 17 00:00:00 2001 From: Kainan Cha Date: Tue, 27 Apr 2021 15:30:15 +0800 Subject: [PATCH] Use RTNE as default rounding policy RTNE, Round To Nearest Even is a better rounding policy which aligns with implementation of Tensorflow Lite. Signed-off-by: Kainan Cha --- src/tim/vx/operation_private.h | 4 ++-- src/tim/vx/type_utils.cc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tim/vx/operation_private.h b/src/tim/vx/operation_private.h index 60c0be0..0ef428d 100644 --- a/src/tim/vx/operation_private.h +++ b/src/tim/vx/operation_private.h @@ -38,7 +38,7 @@ class OperationImpl { OperationImpl& BindOutput(const std::shared_ptr& tensor); OperationImpl& SetRoundingPolicy( OverflowPolicy overflow_policy = OverflowPolicy::SATURATE, - RoundingPolicy rounding_policy = RoundingPolicy::TO_ZERO, + RoundingPolicy rounding_policy = RoundingPolicy::RTNE, DownScaleSizeRounding down_scale_size_rounding = DownScaleSizeRounding::FLOOR, uint32_t accumulator_bits = 0); @@ -57,4 +57,4 @@ class OperationImpl { } // namespace vx } // namespace tim -#endif /* TIM_VX_OPERATION_PRIVATE_H_ */ \ No newline at end of file +#endif /* TIM_VX_OPERATION_PRIVATE_H_ */ diff --git a/src/tim/vx/type_utils.cc b/src/tim/vx/type_utils.cc index 21077fe..945f23a 100644 --- a/src/tim/vx/type_utils.cc +++ b/src/tim/vx/type_utils.cc @@ -129,7 +129,7 @@ vsi_enum TranslateRoundingPolicy(RoundingPolicy type) { default: break; } - return VX_ROUND_POLICY_TO_ZERO; + return VX_ROUND_POLICY_TO_NEAREST_EVEN; } vsi_enum TranslateDownScaleSizeRounding(DownScaleSizeRounding type) {