realized only exists on base (#8815)

* realized only exists on base [pr]

* shorter

* update that too
This commit is contained in:
qazal
2025-01-30 16:02:25 -05:00
committed by GitHub
parent 7cdc607544
commit 530961f7d5
3 changed files with 3 additions and 5 deletions

View File

@@ -104,7 +104,7 @@ print(sched[-1].ast)
run_schedule(sched)
# check the data out
assert out.realized is not None and out.realized.as_buffer().cast('I')[0] == 5
assert out.is_realized and out.buffer.as_buffer().cast('I')[0] == 5
print("******** fourth, the Tensor ***********")

View File

@@ -2226,7 +2226,7 @@ class TestConst(unittest.TestCase):
self.assertEqual(len(sched), 1)
run_schedule(sched)
# add gets assigned to a new buffer
self.assertIsNot(add.lazydata.realized, b.lazydata.realized)
self.assertIsNot(add.lazydata.base.realized, b.lazydata.base.realized)
self.assertListEqual(add.tolist(), [4, 2, 2, 2, 2, 4])
# ** part 3: Tensor variable bindings

View File

@@ -545,9 +545,7 @@ class UOp(MathTrait, metaclass=UOpMetaClass):
buffers[self] = ret = Buffer(self.device, self.size, self.dtype if isinstance(self.dtype, ImageDType) else self.dtype.base)
return ret
@property
def realized(self) -> Optional[Buffer]:
if self.op is Ops.VIEW and len(self.src) == 1 and self.src[0].op is Ops.BUFFER: return self.src[0].realized
return self.buffer if self.op is Ops.BUFFER else None
def realized(self) -> Optional[Buffer]: return self.buffer if self.op is Ops.BUFFER else None
@property
def is_realized(self) -> bool:
return all(x.base.realized is not None for x in self.base.real_lbs) if self.base.op is Ops.MULTI else self.base.realized is not None