MCPcopy
hub / github.com/tinygrad/tinygrad / test_subbuffer_deallocate

Method test_subbuffer_deallocate

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

Source from the content-addressed store, hash-verified

50 assert out == [2, 3, 4]
51
52 def test_subbuffer_deallocate(self):
53 with Context(LRU=0):
54 vbuf = self.buf.view(2, dtypes.uint8, offset=3).ensure_allocated()
55 self.buf.deallocate()
56 vbuf.deallocate()
57
58 # Allocate a fake one on the same place
59 _ = Buffer(Device.DEFAULT, 10, dtypes.uint8).ensure_allocated()
60
61 self.buf.ensure_allocated()
62 self.buf.copyin(memoryview(bytearray(range(10, 20))))
63
64 vbuf.ensure_allocated()
65
66 tst = vbuf.as_memoryview().tolist()
67 assert tst == [13, 14]
68
69 def test_subbuffer_is_allocated(self):
70 buf = self.buf_unalloc

Callers

nothing calls this directly

Calls 8

ContextClass · 0.90
BufferClass · 0.90
ensure_allocatedMethod · 0.80
deallocateMethod · 0.80
copyinMethod · 0.80
as_memoryviewMethod · 0.80
viewMethod · 0.45
tolistMethod · 0.45

Tested by

no test coverage detected