mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-10 07:28:15 -05:00
add a test for untested Tensor.assign behavior (#12448)
* add a test for untested Tensor.assign behavior * better
This commit is contained in:
@@ -119,6 +119,17 @@ class TestAssign(unittest.TestCase):
|
||||
new = a + old_a
|
||||
np.testing.assert_allclose(new.numpy(), 4)
|
||||
|
||||
def test_assign_changes_alt(self, realize=False):
|
||||
a = Tensor(1).contiguous()
|
||||
if realize: a.realize()
|
||||
b = a.contiguous() # b returns a new Tensor
|
||||
b.assign(2)
|
||||
b.realize()
|
||||
self.assertNotEqual(a.item(), b.item())
|
||||
# on a realized Tensor contiguous child changes the source
|
||||
@unittest.expectedFailure
|
||||
def test_assign_changes_realized_alt(self): return self.test_assign_changes_alt(realize=True)
|
||||
|
||||
def test_assign_diamond_cycle(self):
|
||||
# NOTE: should *not* raise AssertionError from numpy
|
||||
with self.assertRaisesRegex(RuntimeError, "cycle"):
|
||||
|
||||
Reference in New Issue
Block a user