MCPcopy
hub / github.com/tinygrad/tinygrad / test_buffer_has_buffer

Method test_buffer_has_buffer

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

Source from the content-addressed store, hash-verified

34class TestBufferUOp(unittest.TestCase):
35 # BUFFER has a ShapeTracker of shape=(n,) and stride=(1,)
36 def test_buffer_has_buffer(self):
37 buf = Tensor.empty(10)
38 self.assertIsNotNone(buf.uop.buffer)
39 self.assertEqual(buf.uop.shape, (10,))
40 # the device Buffer remains unallocated until it's we run the schedule
41 self.assertFalse(buf.uop.buffer.is_allocated())
42 add = buf+1
43 linear, var_vals = add.linear_with_vars()
44 self.assertFalse(buf.uop.buffer.is_allocated())
45 run_linear(linear, var_vals)
46 self.assertTrue(buf.uop.buffer.is_allocated())
47
48 def test_buffer_has_unique_buffer(self):
49 buf = Tensor.empty(10)

Callers

nothing calls this directly

Calls 4

run_linearFunction · 0.90
linear_with_varsMethod · 0.80
emptyMethod · 0.45
is_allocatedMethod · 0.45

Tested by

no test coverage detected