MCPcopy
hub / github.com/tinygrad/tinygrad / readinto

Method readinto

tinygrad/nn/state.py:17–21  ·  view source on GitHub ↗
(self, buffer: Any)

Source from the content-addressed store, hash-verified

15 if (buf:=super().read(size)) is None: raise ValueError("io.RawIOBase.read returned None") # only happens if readinto returns None (never)
16 return buf
17 def readinto(self, buffer: Any) -> int:
18 data = self._tensor[self._position:self._position+len(buffer)].data()
19 buffer[:len(data)] = data
20 self._position += len(data)
21 return len(data)
22
23 def seekable(self) -> bool: return True
24 def seek(self, offset: int, whence: int = 0) -> int:

Callers 3

_copyinMethod · 0.80
_copyoutMethod · 0.80

Calls 1

dataMethod · 0.45

Tested by 1