diff --git a/test/null/test_tensor_uop_mixin.py b/test/null/test_tensor_uop_mixin.py index e5009a5859..c7001a1136 100644 --- a/test/null/test_tensor_uop_mixin.py +++ b/test/null/test_tensor_uop_mixin.py @@ -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 ---- diff --git a/tinygrad/mixin/elementwise.py b/tinygrad/mixin/elementwise.py index c722064f58..6a2571f76e 100644 --- a/tinygrad/mixin/elementwise.py +++ b/tinygrad/mixin/elementwise.py @@ -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