mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-08-29 13:36:07 +00:00
delegate non Tensor src setitem to assign (#14647)
cannot do this for DISK in the unified path
This commit is contained in:
+4
-3
@@ -1286,9 +1286,10 @@ class Tensor(OpMixin):
|
||||
if is_advanced: raise RuntimeError("advanced setitem is not supported for DISK tensors")
|
||||
self.realize()._getitem(indices).assign(v)
|
||||
return
|
||||
if not isinstance(v, Tensor): v = Tensor(v, device=self.device, dtype=self.dtype)
|
||||
if self.requires_grad or v.requires_grad: raise NotImplementedError("setitem with requires_grad is not supported")
|
||||
if is_advanced: self.assign(self._getitem(indices, v)).realize()
|
||||
if self.requires_grad or (isinstance(v, Tensor) and v.requires_grad): raise NotImplementedError("setitem with requires_grad is not supported")
|
||||
if is_advanced:
|
||||
if not isinstance(v, Tensor): v = Tensor(v, device=self.device, dtype=self.dtype)
|
||||
self.assign(self._getitem(indices, v)).realize()
|
||||
else: # basic setitem
|
||||
self.realize()
|
||||
if not self.uop.is_writable_view(): raise RuntimeError("setitem target must be a writable view backed by a buffer")
|
||||
|
||||
Reference in New Issue
Block a user