forked from mindspore-Ecosystem/mindspore
Fix equal operation of inf
This commit is contained in:
parent
2a71edfbe8
commit
0f953400f4
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue