mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-09 15:08:02 -05:00
realized only exists on base (#8815)
* realized only exists on base [pr] * shorter * update that too
This commit is contained in:
@@ -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 ***********")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user