mindspore.hal.memory_allocated

View Source On Gitee
mindspore.hal.memory_allocated(device_target=None)[source]

Returns the actual memory size currently occupied by Tensor, this api will be deprecated and removed in future versions, please use the api mindspore.runtime.memory_allocated() instead.

Note

  • For the CPU device, 0 is always returned.

Parameters

device_target (str, optional) – The target device specified, should be one of "CPU" , "GPU" and "Ascend" . Default None , represents the current device set by context.

Returns

int, in Byte.

Examples

>>> import mindspore
>>> a = mindspore.tensor(mindspore.ops.ones([1, 2]), mindspore.float32)
>>> b = mindspore.tensor(mindspore.ops.ones([1, 2]), mindspore.float32)
>>> c = mindspore.ops.add(a, b).asnumpy()
>>> print(mindspore.hal.memory_allocated())
1024