Skip to content

Commit 128e2a8

Browse files
committed
Fix double-promotion in rsqrt for reduced-precision types
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: [email protected] Change-Id: I8fbcc99d8aebac67c4164f2ad502e9b3081386b4
1 parent cdc2701 commit 128e2a8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

runtime/core/portable_type/c10/c10/util/BFloat16-math.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/*
2+
* Copyright 2025 Arm Limited and/or its affiliates.
3+
*
4+
* This source code is licensed under the BSD-style license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
18
#pragma once
29

310
#include <c10/util/BFloat16.h>
@@ -181,7 +188,7 @@ template <
181188
typename T,
182189
typename std::enable_if_t<c10::is_reduced_floating_point_v<T>, int> = 0>
183190
inline T rsqrt(T a) {
184-
return 1.0 / std::sqrt(float(a));
191+
return 1.0f / std::sqrt(float(a));
185192
}
186193
template <
187194
typename T,

0 commit comments

Comments
 (0)