Moves the tensor to the given device.
(self, device:str|tuple[str, ...]|None)
| 363 | return ret.is_param_(self.is_param) |
| 364 | |
| 365 | def to(self, device:str|tuple[str, ...]|None) -> Tensor: |
| 366 | """ |
| 367 | Moves the tensor to the given device. |
| 368 | """ |
| 369 | if self.uop.device is None: return self |
| 370 | if (device:=canonicalize_device(device)) == self.device: return self |
| 371 | ret = Tensor(self.uop.copy_to_device(device)) |
| 372 | if self.grad is not None: ret.grad = self.grad.to(device) |
| 373 | return ret.is_param_(self.is_param) |
| 374 | |
| 375 | def to_(self, device:str|tuple[str, ...]|None) -> Tensor: |
| 376 | """ |