File tree Expand file tree Collapse file tree
mlx/backend/metal/kernels Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -97,10 +97,6 @@ constexpr bool operator<(complex64_t a, complex64_t b) {
9797 return operator >(b, a);
9898}
9999
100- constexpr bool isnan (complex64_t x) {
101- return isnan (x.real ) || isnan (x.imag );
102- }
103-
104100constexpr bool operator ==(complex64_t a, complex64_t b) {
105101 return a.real == b.real && a.imag == b.imag ;
106102}
Original file line number Diff line number Diff line change @@ -40,10 +40,15 @@ template <typename T>
4040struct LessThan {
4141 static constexpr constant T init = Init<T>::v;
4242 METAL_FUNC bool operator ()(T a, T b) const {
43- if constexpr (
44- metal::is_floating_point_v<T> || metal::is_same_v<T, complex64_t >) {
45- bool an = isnan (a);
46- bool bn = isnan (b);
43+ if constexpr (metal::is_floating_point_v<T>) {
44+ bool an = metal::isnan (a);
45+ bool bn = metal::isnan (b);
46+ if (an | bn) {
47+ return (!an) & bn;
48+ }
49+ } else if constexpr (metal::is_same_v<T, complex64_t >) {
50+ bool an = metal::isnan (a.real ) || metal::isnan (a.imag );
51+ bool bn = metal::isnan (b.real ) || metal::isnan (b.imag );
4752 if (an | bn) {
4853 return (!an) & bn;
4954 }
You can’t perform that action at this time.
0 commit comments