diff --git a/kernels/portable/cpu/op_allclose.cpp b/kernels/portable/cpu/op_allclose.cpp index a1b2cb87389..32d81f1ad80 100644 --- a/kernels/portable/cpu/op_allclose.cpp +++ b/kernels/portable/cpu/op_allclose.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. - * Copyright 2025 Arm Limited and/or its affiliates. + * Copyright 2025-2026 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. @@ -41,8 +41,8 @@ bool data_is_close( return false; } } else { - auto allowed_error = atol + fabs(rtol * b[i]); - auto actual_error = fabs(a[i] - b[i]); + auto allowed_error = atol + std::fabs(rtol * b[i]); + auto actual_error = std::fabs(a[i] - b[i]); if (!std::isfinite(actual_error) || actual_error > allowed_error) { return false; } diff --git a/kernels/portable/cpu/util/upsample_util.h b/kernels/portable/cpu/util/upsample_util.h index 7ac1fec591f..6940c63dedb 100644 --- a/kernels/portable/cpu/util/upsample_util.h +++ b/kernels/portable/cpu/util/upsample_util.h @@ -1,6 +1,7 @@ /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. + * Copyright 2026 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. @@ -8,6 +9,8 @@ #pragma once +#include + #include #include #include @@ -98,8 +101,8 @@ inline void guard_index_and_lambda( const int64_t& input_size, int64_t& input_index, scalar_t& lambda) { - input_index = - std::min(static_cast(floorf(real_input_index)), input_size - 1); + input_index = std::min( + static_cast(std::floor(real_input_index)), input_size - 1); lambda = std::min( std::max(real_input_index - input_index, static_cast(0)), static_cast(1)); @@ -140,8 +143,8 @@ inline int64_t nearest_neighbor_compute_source_index( int64_t input_size) { // Index computation matching OpenCV INTER_NEAREST // which is buggy and kept for BC - const int64_t src_index = - std::min(static_cast(floorf(dst_index * scale)), input_size - 1); + const int64_t src_index = std::min( + static_cast(std::floor(dst_index * scale)), input_size - 1); return src_index; } diff --git a/kernels/portable/cpu/vec_ops.h b/kernels/portable/cpu/vec_ops.h index bafc1b24879..0580ddc9336 100644 --- a/kernels/portable/cpu/vec_ops.h +++ b/kernels/portable/cpu/vec_ops.h @@ -1,7 +1,7 @@ /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. - * Copyright 2024 Arm Limited and/or its affiliates. + * Copyright 2024,2026 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. @@ -201,7 +201,7 @@ inline void vec_softmax(T* ET_RESTRICT y, const U* ET_RESTRICT x, int n) { T sum = 0; for (const auto i : c10::irange(n)) { - y[i] = expf(x[i] - max_x); + y[i] = std::exp(x[i] - max_x); sum += y[i]; } @@ -230,7 +230,7 @@ inline void quantize_i8_f32( int32_t zero_point, size_t size) { for (const auto i : c10::irange(size)) { - float tmp = roundf(x[i] * scale + zero_point); + float tmp = std::round(x[i] * scale + zero_point); y[i] = internal::clamp(tmp, -128.f, 127.f); } }