MCPcopy
hub / github.com/tinygrad/tinygrad / copyout

Method copyout

tinygrad/device.py:211–216  ·  view source on GitHub ↗
(self, mv:memoryview)

Source from the content-addressed store, hash-verified

209 self.allocator._copyin(self._buf, mv)
210 return self
211 def copyout(self, mv:memoryview) -> memoryview:
212 mv = flat_mv(mv)
213 assert len(mv) == self.nbytes, f"size mismatch, {len(mv)=} != {self.dtype=} {self.size=}"
214 assert self.is_initialized(), "can't copyout unallocated buffer"
215 self.allocator._copyout(mv, self._buf)
216 return mv
217 def view(self, size:int, dtype:DType, offset:int) -> Buffer:
218 assert offset < self.nbytes, "offset must be less than nbytes"
219 return Buffer(self.device, size, dtype, base=self.base, offset=self.offset+offset)

Callers 9

__reduce__Method · 0.95
as_memoryviewMethod · 0.95
test_profile_multiopsMethod · 0.80
_test_single_valueFunction · 0.80
_test_single_value_constFunction · 0.80
_test_uops_resultFunction · 0.80
test_unaligned_copyMethod · 0.80

Calls 3

is_initializedMethod · 0.95
flat_mvFunction · 0.90
_copyoutMethod · 0.45

Tested by 7

test_profile_multiopsMethod · 0.64
_test_single_valueFunction · 0.64
_test_single_value_constFunction · 0.64
_test_uops_resultFunction · 0.64
test_unaligned_copyMethod · 0.64