From 6ae5423b4a04e273495418a619c90e9b0fa31652 Mon Sep 17 00:00:00 2001 From: Cheng Date: Sun, 8 Dec 2024 11:26:23 +0900 Subject: [PATCH] Do not pass integers to isnan (#1664) --- mlx/backend/common/ops.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mlx/backend/common/ops.h b/mlx/backend/common/ops.h index 824ea4724..115386ac5 100644 --- a/mlx/backend/common/ops.h +++ b/mlx/backend/common/ops.h @@ -500,7 +500,12 @@ struct Equal { struct NaNEqual { template bool operator()(T x, T y) { - return x == y || (std::isnan(x) && std::isnan(y)); + if constexpr (std::is_integral_v) { + // isnan always returns false for integers, and MSVC refuses to compile. + return x == y; + } else { + return x == y || (std::isnan(x) && std::isnan(y)); + } } };