MCPcopy
hub / github.com/tinygrad/tinygrad / clone

Method clone

tinygrad/tensor.py:356–363  ·  view source on GitHub ↗

Creates a clone of this tensor allocating a separate buffer for the data. If `device` is specified, the clone is placed on that device.

(self, device:str|tuple[str, ...]|None=None)

Source from the content-addressed store, hash-verified

354 return self._buffer().numpy().reshape(self.shape)
355
356 def clone(self, device:str|tuple[str, ...]|None=None) -> Tensor:
357 """
358 Creates a clone of this tensor allocating a separate buffer for the data.
359 If `device` is specified, the clone is placed on that device.
360 """
361 ret = Tensor(self.uop.clone(device=device))
362 if self.grad is not None: ret.grad = self.grad.clone(device=device)
363 return ret.is_param_(self.is_param)
364
365 def to(self, device:str|tuple[str, ...]|None) -> Tensor:
366 """

Callers 2

_bufferMethod · 0.45

Calls 2

is_param_Method · 0.95
TensorClass · 0.85