mindspore.Tensor.copy_
- 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
- 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.]]