mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-04-07 03:00:26 -04:00
test Tensor.clone has a different lazydata [pr] (#8600)
This commit is contained in:
@@ -646,11 +646,20 @@ class TestZeroShapeTensor(unittest.TestCase):
|
||||
|
||||
def test_clone(self):
|
||||
a = Tensor.rand(16, 16).realize()
|
||||
self.assertIsNot(a.lazydata, a.clone().lazydata)
|
||||
np.testing.assert_allclose(a.numpy(), a.clone().numpy())
|
||||
|
||||
a = Tensor.rand(16, 16).mul(5.0).add(5.0)
|
||||
self.assertIsNot(a.lazydata, a.clone().lazydata)
|
||||
np.testing.assert_allclose(a.numpy(), a.clone().numpy())
|
||||
|
||||
def test_clone_with_shrink(self):
|
||||
a = Tensor.empty(16, 16)
|
||||
self.assertIsNot(a.lazydata, a.clone().lazydata)
|
||||
|
||||
b = a.shrink(((2, 10), None))
|
||||
self.assertIsNot(b.lazydata, b.clone().lazydata)
|
||||
|
||||
def test_clone_with_grad(self):
|
||||
a = Tensor.rand(16, 16, requires_grad=True)
|
||||
a.mul(5.0).add(5.0).mean().backward()
|
||||
|
||||
Reference in New Issue
Block a user