mindspore.ops.numel
- mindspore.ops.numel(input)[source]
Returns a Scalar of type int that represents the total number of elements in the Tensor.
- Parameters
input (Tensor) – Input Tensor.
- Returns
int. A scalar representing the total of elements in the Tensor.
- Raises
TypeError – If input is not a Tensor.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> import numpy as np >>> from mindspore import Tensor, ops >>> input_x = Tensor(np.array([[2, 2], [2, 2]]), mindspore.float32) >>> print(ops.numel(input_x)) 4