Skip to content

Commit 8c8918c

Browse files
author
ngimel
authored
make half overflow checks consistent with other types (#7382)
1 parent 8f27582 commit 8c8918c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

aten/src/ATen/Half.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ template<> AT_API int64_t convert(Half f) {
3333
}
3434

3535
template<> bool overflows<Half, double>(double f) {
36+
using limit = std::numeric_limits<double>;
37+
if (limit::has_infinity && std::isinf(f)) {
38+
return false;
39+
}
3640
return f > 65504 || f < -65504;
3741
}
3842
template<> bool overflows<Half, int64_t>(int64_t f) {

0 commit comments

Comments
 (0)