mindspore.Tensor.copy_

View Source On Gitee
Tensor.copy_(src, non_blocking=False)[source]

Copies the elements from src into self tensor and returns self.

Warning

This is an experimental API that is subject to change or deletion. The src tensor must be broadcastable with the self tensor. It may be of a different data type.

Parameters
  • src (Tensor) – the source tensor to copy from.

  • non_blocking (bool) – no effect currently.

Returns

Return self Tensor.

Supported Platforms:

Ascend

Examples

>>> import numpy as np
>>> from mindspore import Tensor
>>> a = Tensor(np.ones((3,3)).astype("float32"))
>>> b = Tensor(np.zeros((3,3)).astype("float32"))
>>> a.copy_(b)
>>> print(a)
[[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]