r"""Copies tensor to another device. Args: inp: input tensor. device: destination device. Examples: >>> import numpy as np >>> x = Tensor([1, 2, 3], np.int32) >>> F.copy(x, 'cpu1') Tensor([1 2 3], dtype=int32, device=cpu1:0) >>> F.
(inp, device=None)
| 1207 | |
| 1208 | |
| 1209 | def copy(inp, device=None): |
| 1210 | r"""Copies tensor to another device. |
| 1211 | |
| 1212 | Args: |
| 1213 | inp: input tensor. |
| 1214 | device: destination device. |
| 1215 | |
| 1216 | Examples: |
| 1217 | |
| 1218 | >>> import numpy as np |
| 1219 | >>> x = Tensor([1, 2, 3], np.int32) |
| 1220 | |
| 1221 | >>> F.copy(x, 'cpu1') |
| 1222 | Tensor([1 2 3], dtype=int32, device=cpu1:0) |
| 1223 | |
| 1224 | >>> F.copy(x, 'xpu0') |
| 1225 | Tensor([1 2 3], dtype=int32, device=xpu0:0) |
| 1226 | |
| 1227 | """ |
| 1228 | if device is None: |
| 1229 | return apply(Identity(), inp)[0] |
| 1230 | return apply(Copy(comp_node=as_device(device).to_c()), inp)[0] |
| 1231 | |
| 1232 | |
| 1233 | def roll( |