mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-09 15:08:02 -05:00
can we unsupport this
This commit is contained in:
@@ -547,9 +547,6 @@ class UOp(MathTrait, metaclass=UOpMetaClass):
|
||||
return self.src[0].buf_uop
|
||||
@property
|
||||
def buffer(self) -> Buffer:
|
||||
if self is not self.base:
|
||||
assert unwrap(self.st).contiguous, "VIEW only works here if it's contiguous"
|
||||
return self.src[0].buffer
|
||||
assert self.op is Ops.BUFFER, f"must be BUFFER {self.op}"
|
||||
if (cret:=buffers.get(self)) is not None: return cret
|
||||
from tinygrad.device import Buffer
|
||||
|
||||
@@ -59,7 +59,7 @@ def _to_np_dtype(dtype:DType) -> Optional[type]:
|
||||
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)
|
||||
ret.base.buffer.allocate(x)
|
||||
return ret
|
||||
|
||||
def get_shape(x) -> tuple[int, ...]:
|
||||
@@ -76,7 +76,7 @@ def _frompy(x:Union[list, tuple, bytes], dtype:DType) -> UOp:
|
||||
truncate_function = truncate[dtype]
|
||||
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)))
|
||||
ret.base.buffer.allocate(memoryview(data if Device.DEFAULT != "PYTHON" else bytearray(data)))
|
||||
return ret
|
||||
|
||||
def _get_winograd_matcols(mat, dims:int, shp:tuple[sint, ...], device:Union[str, tuple[str, ...]], dtype:DType) -> list[list[Tensor]]:
|
||||
@@ -448,7 +448,7 @@ class Tensor(SimpleMathTrait):
|
||||
"""
|
||||
|
||||
r = Tensor._metaop(Ops.EMPTY, shape, **kwargs)
|
||||
r.lazydata.buffer.allocate(external_ptr=ptr)
|
||||
r.lazydata.base.buffer.allocate(external_ptr=ptr)
|
||||
return r
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user