diff --git a/ethosu/regor/compiler/tflite_graph_optimiser_tp.cpp b/ethosu/regor/compiler/tflite_graph_optimiser_tp.cpp index 9c814103925f04f1c9ba440b0337e2ef08104e88..fe7676b67735750a9febf8249ee2592b77ca8230 100644 --- a/ethosu/regor/compiler/tflite_graph_optimiser_tp.cpp +++ b/ethosu/regor/compiler/tflite_graph_optimiser_tp.cpp @@ -1,5 +1,5 @@ // -// SPDX-FileCopyrightText: Copyright 2021, 2024 Arm Limited and/or its affiliates +// SPDX-FileCopyrightText: Copyright 2021, 2024-2025 Arm Limited and/or its affiliates // SPDX-FileCopyrightText: Copyright 2020 The TensorFlow Authors. All Rights Reserved. // // SPDX-License-Identifier: Apache-2.0 @@ -109,6 +109,13 @@ Operation *TFLiteGraphOptimiser::ConvertHardSwishToLUT(Graph *const graph, Opera reluValue = SaturatingLeftShift(reluValue, 1); } + // Try to get reluShift into the [-31, 0] range + if ( reluShift < -31 ) + { + reluValue = reluValue >> (-31 - reluShift); + reluShift = -31; + } + if ( reluShift < 0 ) { reluValue = gemmlowp::RoundingDivideByPOT(reluValue, -reluShift);