mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-10 07:28:15 -05:00
remove r.lazydata.buf_uop_view [pr] (#8817)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user