From 795285ce437d337b9fba96c7858e08d29207d6fc Mon Sep 17 00:00:00 2001 From: George Hotz Date: Wed, 11 Jan 2023 21:12:50 -0800 Subject: [PATCH] actually fix early alloc --- tinygrad/llops/ops_gpu.py | 1 - tinygrad/ops.py | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/tinygrad/llops/ops_gpu.py b/tinygrad/llops/ops_gpu.py index 5ef5f3db10..f3d22e131e 100644 --- a/tinygrad/llops/ops_gpu.py +++ b/tinygrad/llops/ops_gpu.py @@ -198,7 +198,6 @@ class GPUBuffer(ExplicitExecAST): def __init__(self, shape:Union[ShapeTracker, Tuple[int, ...]], hostbuf:Optional[GPUBuffer]=None, backing:Optional[np.ndarray]=None): super().__init__(shape, hostbuf) - if hostbuf is not None and hostbuf._backing is None: hostbuf.cl # does the allocation of unbacked buffer, pylint: disable=W0104 self._buf : Optional[CLBuffer] = hostbuf._buf if hostbuf is not None else None self._base_shape : Tuple[int, ...] = hostbuf._base_shape if hostbuf is not None else self.shape self._backing : Optional[np.ndarray] = hostbuf._backing if hostbuf is not None else backing diff --git a/tinygrad/ops.py b/tinygrad/ops.py index 27c627d5ba..eef9534c60 100644 --- a/tinygrad/ops.py +++ b/tinygrad/ops.py @@ -118,6 +118,7 @@ class ASTKernel: # create the buffer we are returning (as the same type as the input buffers) and add it as the first buffer self.ret = type(self.bufs[0])(output_shape if output_shape else self.info.shape) + if hasattr(self.ret, "cl"): self.ret.cl # does the allocation of unbacked buffer, pylint: disable=W0104 self.bufs = [type(self.ret)(self.info.shape, hostbuf=self.ret)] + self.bufs # check valid AST kernel