MCPcopy Index your code
hub / github.com/tinygrad/tinygrad / replace

Method replace

tinygrad/tensor.py:247–254  ·  view source on GitHub ↗

Replaces the data of this tensor with the data of another tensor. Only the shape of the tensors must match.

(self, x:Tensor)

Source from the content-addressed store, hash-verified

245 return self
246
247 def replace(self, x:Tensor) -> Tensor:
248 """
249 Replaces the data of this tensor with the data of another tensor. Only the shape of the tensors must match.
250 """
251 # used for replacing a Tensor with a new version of it (potentially with a different device and dtype)
252 assert self.shape == x.shape, f"replace shape mismatch {self.shape} != {x.shape}"
253 self.uop = x.uop
254 return self
255
256 def assign(self, x:Tensor|PyConst|list|tuple) -> Tensor:
257 is_disk = isinstance(self.device, str) and self.device.startswith("DISK")

Callers 4

to_Method · 0.95
shard_Method · 0.95
__setitem__Method · 0.95
from_uopMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected