remove r.lazydata.buf_uop_view [pr] (#8817)

This commit is contained in:
qazal
2025-01-30 16:14:36 -05:00
committed by GitHub
parent 530961f7d5
commit c8d878a5c1
3 changed files with 2 additions and 6 deletions

View File

@@ -84,8 +84,6 @@ a = UOp.metaop(Ops.EMPTY, (1,), dtypes.int32, DEVICE)
b = UOp.metaop(Ops.EMPTY, (1,), dtypes.int32, DEVICE)
a.buffer.allocate().copyin(memoryview(bytearray(struct.pack("I", 2))))
b.buffer.allocate().copyin(memoryview(bytearray(struct.pack("I", 3))))
a = a.buf_uop_view()
b = b.buf_uop_view()
# describe the computation
out = a.alu(Ops.ADD, b)

View File

@@ -532,7 +532,6 @@ class UOp(MathTrait, metaclass=UOpMetaClass):
if self.base.op is Ops.BUFFER: return self.base
assert self.base.op in {*GroupOp.Buffer, Ops.ASSIGN, Ops.VIEW}, f"buf_uop called on {self.op}"
return self.src[0].buf_uop
def buf_uop_view(self) -> UOp: return self.buf_uop.view(unwrap(self.st))
@property
def buffer(self) -> Buffer:
if self.op is Ops.VIEW:

View File

@@ -59,7 +59,7 @@ def _fromnp(x: 'np.ndarray') -> UOp: # type: ignore [name-defined] # noqa: F821
ret = UOp.metaop(Ops.EMPTY, x.shape, _from_np_dtype(x.dtype), "NPY")
# fake realize
ret.buffer.allocate(x)
return ret.buf_uop_view()
return ret
def get_shape(x) -> tuple[int, ...]:
# NOTE: str is special because __getitem__ on a str is still a str
@@ -76,7 +76,7 @@ def _frompy(x:Union[List, Tuple, bytes], dtype:DType) -> UOp:
data = struct.pack(f"@{ret.size}{dtype.fmt}", *[truncate_function(xi) for xi in fully_flatten(x)])
# fake realize
ret.buffer.allocate(memoryview(data if Device.DEFAULT != "PYTHON" else bytearray(data)))
return ret.buf_uop_view()
return ret
def _get_winograd_matcols(mat, dims:int, shp:tuple[sint, ...], device:Union[str, tuple[str, ...]], dtype:DType) -> list[list[Tensor]]:
return [[Tensor.cat(*[Tensor.full(shp[:dim] + (1,) + shp[dim+1:], float(m[k]), device=device, dtype=dtype) for m in mat], dim=dim)
@@ -449,7 +449,6 @@ class Tensor(SimpleMathTrait):
r = Tensor._metaop(Ops.EMPTY, shape, **kwargs)
r.lazydata.buffer.allocate(external_ptr=ptr)
r.lazydata.buf_uop_view()
return r
@staticmethod