mindspore.runtime.memory_allocated
- mindspore.runtime.memory_allocated()[source]
Returns the actual memory size currently occupied by Tensor.
Note
For the CPU backend, 0 is always returned.
- Returns
int, in Byte.
Examples
>>> import mindspore as ms >>> import numpy as np >>> from mindspore import Tensor, ops >>> ms.set_device("Ascend", 0) >>> a = Tensor(np.ones([1, 2]), ms.float32) >>> b = Tensor(np.ones([1, 2]), ms.float32) >>> c = ops.add(a, b).asnumpy() >>> print(ms.runtime.memory_allocated()) 1024