Fix equal operation of inf

This commit is contained in:
huangbingjian 2023-01-03 10:47:48 +08:00
parent 2a71edfbe8
commit 0f953400f4
2 changed files with 6 additions and 4 deletions

View File

@ -140,7 +140,7 @@ T InnerScalarPow(T x, U y) {
template <typename T, typename U>
bool InnerScalarEq(T x, U y) {
if (std::isinf(static_cast<double>(x)) && std::isinf(static_cast<double>(y))) {
return true;
return (x > 0 && y > 0) || (x < 0 && y < 0);
}
double error = static_cast<double>(x) - static_cast<double>(y);
error = fabs(error);

View File

@ -212,8 +212,10 @@ def test_equal_inf():
Expectation: success
"""
@ms.jit
def func(x):
return x == float("inf")
def func(x, y):
return x == float("inf"), y == float("-inf"), x == y
x = float("inf")
assert func(x)
y = float("-inf")
out = func(x, y)
assert out == (True, True, False)