MCPcopy
hub / github.com/tinygrad/tinygrad / _buffer

Method _buffer

tinygrad/tensor.py:285–292  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

283 return self
284
285 def _buffer(self) -> Buffer:
286 from tinygrad.engine.realize import capturing
287 if capturing and not getenv("UNSAFE_ALLOW_JIT_BUFFER"):
288 from tinygrad.engine.jit import JitError
289 raise JitError("cannot access tensor data during JIT capture, the value will be baked in")
290 x = self.cast(self.dtype.base).contiguous()
291 if self.uop.device is None or isinstance(self.device, tuple): x = x.clone("CPU")
292 return cast(Buffer, x.realize().uop.buffer).ensure_allocated()
293 def _data(self) -> memoryview: return self._buffer().as_memoryview()
294
295 def data(self) -> memoryview:

Callers 4

assignMethod · 0.95
_dataMethod · 0.95
dataMethod · 0.95
numpyMethod · 0.95

Calls 8

castMethod · 0.95
getenvFunction · 0.90
JitErrorClass · 0.90
castFunction · 0.85
ensure_allocatedMethod · 0.80
realizeMethod · 0.80
contiguousMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected