mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-06-24 02:14:17 +00:00
unique based on opaque in from_buffer (#16609)
This commit is contained in:
parent
c43091a464
commit
8efc8d064f
1 changed files with 2 additions and 1 deletions
|
|
@ -746,7 +746,8 @@ class UOp(RandMixin, metaclass=UOpMetaClass):
|
|||
return UOp(Ops.BUFFER, dtype, (UOp.unique(num), UOp(Ops.DEVICE, arg=device)), size)
|
||||
@staticmethod
|
||||
def from_buffer(opaque:Buffer, device:str|tuple[str, ...]|None=None):
|
||||
buffers[uop:=UOp.new_buffer(device or opaque.device, opaque.size, opaque.dtype)] = opaque.ref(1)
|
||||
if (uop:=UOp.new_buffer(device or opaque.device, opaque.size, opaque.dtype, num=-id(opaque))) not in buffers: buffers[uop] = opaque.ref(1)
|
||||
else: assert buffers[uop] is opaque
|
||||
return uop
|
||||
@staticmethod
|
||||
def empty(shape:tuple[sint, ...], dtype:DTypeLike|None=None, device:str|tuple[str, ...]|None=None, axis:int|None=None, num=None) -> UOp:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue