MCPcopy
hub / github.com/tinygrad/tinygrad / test_new_buffer

Method test_new_buffer

test/null/test_schedule.py:1036–1046  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1034class TestUOpBecome(unittest.TestCase):
1035 # the simplest case, if we create a new BUFFER for this tensor UOp
1036 def test_new_buffer(self):
1037 a = Tensor.empty(4, 4)
1038 b = Tensor.empty(4, 4)
1039 add = a+b
1040 check_schedule(add, 1)
1041 # NOTE: realized base is always a flat buffer
1042 assert UPat(Ops.BUFFER).match(add.uop.base, {})
1043 # the Tensor UOp can optionally stack a VIEW on top of the BUFFER, in this case to preserve the (4, 4) shape of the tensor
1044 assert add.uop is not add.uop.base
1045 self.assertEqual(add.uop.numel(), 16)
1046 self.assertEqual(add.uop.shape, (4, 4))
1047
1048 def test_new_buffer_view(self):
1049 a = Tensor.empty(4, 4)

Callers

nothing calls this directly

Calls 5

UPatClass · 0.90
matchMethod · 0.80
numelMethod · 0.80
check_scheduleFunction · 0.70
emptyMethod · 0.45

Tested by

no test coverage detected