MCPcopy
hub / github.com/tinygrad/tinygrad / test_subbuffer_alloc

Method test_subbuffer_alloc

test/backend/test_subbuffer.py:144–153  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

142 assert expected_base_data == data_out_base
143
144 def test_subbuffer_alloc(self):
145 sub_buf = self.buf.view(4, dtypes.int8, offset=3)
146 sub_buf.allocate()
147 sub_buf.copyin(memoryview(bytearray(range(10, 14))))
148 assert self.buf.as_memoryview().tolist()[3:7] == sub_buf.as_memoryview().tolist()
149
150 sub_buf = self.buf_unalloc.view(4, dtypes.int8, offset=3)
151 sub_buf.allocate()
152 sub_buf.copyin(memoryview(bytearray(range(10, 14))))
153 assert self.buf_unalloc.as_memoryview().tolist()[3:7] == sub_buf.as_memoryview().tolist()
154
155 def test_subbuffer_dealloc(self):
156 sub_buf = self.buf.view(4, dtypes.int8, offset=3).ensure_allocated()

Callers

nothing calls this directly

Calls 5

allocateMethod · 0.80
copyinMethod · 0.80
as_memoryviewMethod · 0.80
viewMethod · 0.45
tolistMethod · 0.45

Tested by

no test coverage detected