| 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: |