mindspore.Tensor.move_to

View Source On Gitee
Tensor.move_to(to, blocking=True)[source]

Copy Tensor to target device synchronously or asynchronously, default synchronously. only support PyNative mode.

Parameters
  • to (str) – a string type value, one of "Ascend", "GPU", "CPU".

  • blocking (bool) – a bool type value, using synchronous copy or asynchronous copy. Default: True , synchronous copy.

Returns

New Tensor, storged on target device which with the same type and shape as the "self Tensor".

Raises
  • ValueError – If the type of blocking is not bool type.

  • ValueError – If the value of to is not one of "Ascend", "GPU", "CPU".

  • ValueError – If the run mode is not PyNative mode.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore as ms
>>> from mindspore import Tensor
>>> x = ms.Tensor([1, 2, 3], ms.int64)
>>> new_tensor = x.move_to("CPU")