Skip to content

Commit c8d878a

Browse files
authored
remove r.lazydata.buf_uop_view [pr] (tinygrad#8817)
1 parent 530961f commit c8d878a

File tree

3 files changed

+2
-6
lines changed

3 files changed

+2
-6
lines changed

docs/abstractions2.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@
8484
b = UOp.metaop(Ops.EMPTY, (1,), dtypes.int32, DEVICE)
8585
a.buffer.allocate().copyin(memoryview(bytearray(struct.pack("I", 2))))
8686
b.buffer.allocate().copyin(memoryview(bytearray(struct.pack("I", 3))))
87-
a = a.buf_uop_view()
88-
b = b.buf_uop_view()
8987

9088
# describe the computation
9189
out = a.alu(Ops.ADD, b)

tinygrad/ops.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,6 @@ def buf_uop(self) -> UOp:
532532
if self.base.op is Ops.BUFFER: return self.base
533533
assert self.base.op in {*GroupOp.Buffer, Ops.ASSIGN, Ops.VIEW}, f"buf_uop called on {self.op}"
534534
return self.src[0].buf_uop
535-
def buf_uop_view(self) -> UOp: return self.buf_uop.view(unwrap(self.st))
536535
@property
537536
def buffer(self) -> Buffer:
538537
if self.op is Ops.VIEW:

tinygrad/tensor.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def _fromnp(x: 'np.ndarray') -> UOp: # type: ignore [name-defined] # noqa: F821
5959
ret = UOp.metaop(Ops.EMPTY, x.shape, _from_np_dtype(x.dtype), "NPY")
6060
# fake realize
6161
ret.buffer.allocate(x)
62-
return ret.buf_uop_view()
62+
return ret
6363

6464
def get_shape(x) -> tuple[int, ...]:
6565
# 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:
7676
data = struct.pack(f"@{ret.size}{dtype.fmt}", *[truncate_function(xi) for xi in fully_flatten(x)])
7777
# fake realize
7878
ret.buffer.allocate(memoryview(data if Device.DEFAULT != "PYTHON" else bytearray(data)))
79-
return ret.buf_uop_view()
79+
return ret
8080

8181
def _get_winograd_matcols(mat, dims:int, shp:tuple[sint, ...], device:Union[str, tuple[str, ...]], dtype:DType) -> list[list[Tensor]]:
8282
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 @@ def from_blob(ptr:int, shape:tuple[int, ...], **kwargs) -> Tensor:
449449

450450
r = Tensor._metaop(Ops.EMPTY, shape, **kwargs)
451451
r.lazydata.buffer.allocate(external_ptr=ptr)
452-
r.lazydata.buf_uop_view()
453452
return r
454453

455454
@staticmethod

0 commit comments

Comments
 (0)