mirror of
https://github.com/ml-explore/mlx.git
synced 2025-08-03 01:06:43 +08:00
Do not pass integers to isnan (#1664)
This commit is contained in:
parent
9635cffdc8
commit
6ae5423b4a
@ -500,8 +500,13 @@ struct Equal {
|
|||||||
struct NaNEqual {
|
struct NaNEqual {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool operator()(T x, T y) {
|
bool operator()(T x, T y) {
|
||||||
|
if constexpr (std::is_integral_v<T>) {
|
||||||
|
// isnan always returns false for integers, and MSVC refuses to compile.
|
||||||
|
return x == y;
|
||||||
|
} else {
|
||||||
return x == y || (std::isnan(x) && std::isnan(y));
|
return x == y || (std::isnan(x) && std::isnan(y));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Greater {
|
struct Greater {
|
||||||
|
Loading…
Reference in New Issue
Block a user