diff --git a/mlx/backend/common/ops.h b/mlx/backend/common/ops.h index 824ea47240..115386ac58 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)); + } } };