Fix Tensor's __repr__ for printing out grad (#3673)

* update check for Tensor's __repr__ with grad

* add test for repr with grad bugfix
This commit is contained in:
Francis Lata
2024-03-10 17:04:29 -04:00
committed by GitHub
parent 0f16729023
commit 957ae9b594
2 changed files with 7 additions and 1 deletions

View File

@@ -334,6 +334,12 @@ class TestTinygrad(unittest.TestCase):
with self.assertRaises(TypeError):
_a = Tensor([3]) in [Tensor([3]), Tensor([4]), Tensor([5])]
def test_repr_with_grad(self):
a = Tensor([1])
b = Tensor([1])
c = (a + b).mean().backward()
print(c)
@unittest.skipIf(CI and Device.DEFAULT in {"GPU", "CUDA", "METAL"}, "no GPU CI")
class TestMoveTensor(unittest.TestCase):
d0, d1 = f"{Device.DEFAULT}:0", f"{Device.DEFAULT}:1"