mindspore.Tensor.delete_

View Source On Gitee
Tensor.delete_(non_blocking=False)[source]

Actively releases the memory of the tensor on the device or host.

Warning

This is an experimental API that is subject to change or deletion.

Parameters

non_blocking (bool, optional) – Whether to release memory asynchronously. If True, the memory is released asynchronously; if False, the memory is released synchronously. Default: False.

Returns

Tensor, the modified self itself, with its data memory already released.

Examples

>>> import mindspore as ms
>>> x = ms.Tensor([1, 2, 3, 4])
>>> y = x.to(device="Ascend", non_blocking=True)
>>> x.delete_(non_blocking=True)
Tensor(shape=[4], dtype=Int64, value= [0, 0, 0, 0])
>>> x.data = y
>>> print(x.device)
"Ascend:0"