mindspore.ops.move_to
- mindspore.ops.move_to(input, to='CPU', blocking=True)[source]
Copy tensor to target device synchronously or asynchronously, default synchronously.
Warning
This interface is deprecated and will be removed after version 2.9.0.
Note
This interface currently only supports Graph mode with jit_level of O0 or O1.
- Parameters
input (Union[Tensor, list[int], tuple[int]]) – The input tensor. When the input is a list or a tuple, it will be converted to tensor before copying.
to (str, optional) – Specify the target device, with optional values of
"Ascend"and"CPU". Default"CPU".blocking (bool, optional) – Whether to use synchronous copying. Default
True.
- Returns
A new tensor on target device.
- Supported Platforms:
AscendCPU
Examples
>>> import mindspore >>> from mindspore import nn, ops, Tensor >>> mindspore.set_context(mode=mindspore.GRAPH_MODE) >>> class MoveToNet(nn.Cell): ... def __init__(self): ... super().__init__() ... ... def construct(self, x): ... cpu_x = ops.move_to(x, "CPU") ... npu_x = ops.move_to(cpu_x, "Ascend") ... return npu_x ... >>> net = MoveToNet() >>> x = Tensor([1, 2, 3], mindspore.int64) >>> y = net(x) >>> print(y) [1 2 3]