From 377612c026bcfc1fd86e63b7c5f995101d7bebfd Mon Sep 17 00:00:00 2001 From: Renjie Liu Date: Thu, 14 May 2020 18:19:41 -0700 Subject: [PATCH] Fix hardswish test for ubsan. PiperOrigin-RevId: 311645688 Change-Id: Id9f3b31da09355c9997f3f2cc95dca5954c956ec --- tensorflow/lite/kernels/internal/reference/reference_ops.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/lite/kernels/internal/reference/reference_ops.h b/tensorflow/lite/kernels/internal/reference/reference_ops.h index f40b268b443..1a6c6d0d80e 100644 --- a/tensorflow/lite/kernels/internal/reference/reference_ops.h +++ b/tensorflow/lite/kernels/internal/reference/reference_ops.h @@ -2597,7 +2597,7 @@ inline void HardSwish(const HardSwishParams& params, // significant bits in the high bits of our 16-bit fixedpoint values, so // that fixed-point approximate computations below are as accurate as // possible. - const int16_t input_value_on_hires_input_scale = input_value << 7; + const int16_t input_value_on_hires_input_scale = input_value * (1 << 7); // Compute the input value on essentially the output scale, just not // right-shifted yet. This is the value that we'll use in the (x >= +3) // case, and that in the general case we'll multiply against the "relu-ish"