r"""Copy self :class:`~.Tensor` to specified device. See :func:`~.copy`
(self, device, *, _borrow=False)
| 196 | self *= 0 |
| 197 | |
| 198 | def to(self, device, *, _borrow=False): |
| 199 | r"""Copy self :class:`~.Tensor` to specified device. See :func:`~.copy`""" |
| 200 | if isinstance(device, str) and not _valid_device(device): |
| 201 | raise ValueError( |
| 202 | "invalid device name {}. For the correct format of the device name, please refer to the instruction of megengine.device.set_default_device()".format( |
| 203 | device |
| 204 | ) |
| 205 | ) |
| 206 | cn = as_device(device).to_c() |
| 207 | op = Borrow(comp_node=cn) if _borrow else Copy(comp_node=cn) |
| 208 | return apply(op, self)[0] |
| 209 | |
| 210 | @property |
| 211 | def requires_grad(self): |