fix isclose mixin (#15898)

use `.eq` instead of `==`
This commit is contained in:
chenyu
2026-04-23 20:40:43 -04:00
committed by GitHub
parent 3072862e2c
commit 8cc2c69e21
2 changed files with 5 additions and 1 deletions
+4
View File
@@ -31,6 +31,10 @@ class TestTensorUOpBinop(unittest.TestCase):
def test_div_broadcast_tensor_by_tensor(self):
a, b = _t(3, 4).float(), _t(4).float() + 1
self.assertIs(_strip_unique((a/b).uop), _strip_unique(a.uop/b.uop))
# isclose used `self == other` which is Python identity on UOp (not elementwise); now uses .eq().
def test_isclose(self):
t = _t(4).float()
self.assertIs(_strip_unique(t.isclose(t).uop), _strip_unique(t.uop.isclose(t.uop)))
class TestTensorUOpGetitem(unittest.TestCase):
# ---- pure slice patterns ----
+1 -1
View File
@@ -567,7 +567,7 @@ class ElementwiseMixin(DTypeMixin, CreationMixin):
```
"""
is_finite_close = self.isfinite() & other.isfinite() & ((self - other).abs() <= atol + rtol * other.abs())
is_infinite_close = (self.isinf() | other.isinf()) & (self == other)
is_infinite_close = (self.isinf() | other.isinf()) & self.eq(other)
is_nan_close = (self.isnan() & other.isnan()) & equal_nan
return is_finite_close | is_infinite_close | is_nan_close