From 128e2a88f9119097aca2469367461cc8ad8c1863 Mon Sep 17 00:00:00 2001 From: Per Held Date: Thu, 11 Dec 2025 09:51:23 +0100 Subject: [PATCH] Fix double-promotion in rsqrt for reduced-precision types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Keep the bfloat16/fp16 rsqrt helper in float precision so Zephyr’s -Wdouble-promotion (treated as an error) no longer fires when ExecuTorch is built for Cortex-M targets. Signed-off-by: per.held@arm.com Change-Id: I8fbcc99d8aebac67c4164f2ad502e9b3081386b4 --- runtime/core/portable_type/c10/c10/util/BFloat16-math.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/runtime/core/portable_type/c10/c10/util/BFloat16-math.h b/runtime/core/portable_type/c10/c10/util/BFloat16-math.h index 8291cd74481..6c91fba79de 100644 --- a/runtime/core/portable_type/c10/c10/util/BFloat16-math.h +++ b/runtime/core/portable_type/c10/c10/util/BFloat16-math.h @@ -1,3 +1,10 @@ +/* + * Copyright 2025 Arm Limited and/or its affiliates. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. + */ + #pragma once #include @@ -181,7 +188,7 @@ template < typename T, typename std::enable_if_t, int> = 0> inline T rsqrt(T a) { - return 1.0 / std::sqrt(float(a)); + return 1.0f / std::sqrt(float(a)); } template < typename T,