8000 fix complex support · pytorch/pytorch@eb96330 · GitHub
[go: up one dir, main page]

Skip to content

Commit eb96330

Browse files
committed
fix complex support
1 parent 59311bd commit eb96330

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

aten/src/ATen/cuda/llvm_complex.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -750,24 +750,27 @@ inline
750750
complex<_Tp>
751751
reciprocal(const complex<_Tp>& __x)
752752
{
753+
// Handle extreme cases for numpy compatibility
753754
auto both_inf = [](T real, T imag) {
754-
return ::isinf(real) && ::isinf(imag);
755+
return isinf(real) && isinf(imag);
755756
}
756757
757758
auto either_inf = [](T real, T imag) {
758-
return ::isinf(real) || ::isinf(imag);
759+
return isinf(real) || isinf(imag);
759760
}
760761
761762
auto either_nan = [](T real, T imag) {
762-
return ::isnan(real) || ::isnan(imag);
763+
return isnan(real) || isnan(imag);
763764
}
764765
765766
if (either_nan(__x.real(), __x.imag()) || both_inf(__x.real(), __x.imag())) {
767+
// If either is Nan or both are infinite, return {nan, nan}
766768
return {std::numeric_limits<T>::quiet_NaN(), std::numeric_limits<T>::quiet_NaN()};
767769
} else if (either_inf(__x.real(), __x.imag())) {
770+
// If either is Inf, return {0, 0}
768771
return {0, 0};
769772
}
770-
const c10::complex<T> one = c10::complex<T>(1.0, 0);
773+
const complex<T> one = complex<T>(1.0, 0);
771774
return one/__x;
772775
}
773776

0 commit comments

Comments
 (0)
0