MCPcopy
hub / github.com/tinygrad/tinygrad / test_subbuffer_cast

Method test_subbuffer_cast

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

Source from the content-addressed store, hash-verified

17 assert tst == [3, 4]
18
19 def test_subbuffer_cast(self):
20 # NOTE: bitcast depends on endianness
21 vbuf = self.buf.view(2, dtypes.uint16, offset=3).ensure_allocated()
22 tst = vbuf.as_memoryview().cast("H").tolist()
23 assert tst == [3|(4<<8), 5|(6<<8)]
24
25 def test_subbuffer_double(self):
26 vbuf = self.buf.view(4, dtypes.uint8, offset=3).ensure_allocated()

Callers

nothing calls this directly

Calls 5

ensure_allocatedMethod · 0.80
as_memoryviewMethod · 0.80
viewMethod · 0.45
tolistMethod · 0.45
castMethod · 0.45

Tested by

no test coverage detected