mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-04-29 03:00:14 -04:00
test slice assign twice retains the buffer (#14807)
This commit is contained in:
@@ -55,6 +55,24 @@ class TestAssign(unittest.TestCase):
|
||||
with self.assertRaises(AssertionError):
|
||||
assert x.uop.base.realized is buf
|
||||
|
||||
def test_assign_slice_add(self):
|
||||
x = Tensor([0, 0]).realize()
|
||||
buf = x.uop.base.realized
|
||||
x[0] += 1
|
||||
x.realize()
|
||||
assert x.tolist() == [1, 0]
|
||||
assert x.uop.base.realized is buf
|
||||
|
||||
def test_assign_slice_add_twice(self):
|
||||
# NOTE: this has two kernels
|
||||
x = Tensor([0, 0]).realize()
|
||||
buf = x.uop.base.realized
|
||||
x[0] += 1
|
||||
x[0] += 1
|
||||
x.realize()
|
||||
assert x.tolist() == [2, 0]
|
||||
assert x.uop.base.realized is buf
|
||||
|
||||
def test_assign_add_double(self):
|
||||
def f(x):
|
||||
x += 1
|
||||
|
||||
Reference in New Issue
Block a user