mindspore.ops.Size
- class mindspore.ops.Size(*args, **kwargs)[source]
Returns the size of a tensor.
Returns an int scalar representing the elements size of input, the total number of elements in the tensor.
- Inputs:
input_x (Tensor) - The shape of tensor is \((x_1, x_2, ..., x_R)\).
- Outputs:
int, a scalar representing the elements size of input_x, tensor is the number of elements in a tensor, \(size=x_1*x_2*...x_R\).
- Raises
TypeError – If input_x is not a Tensor.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> input_tensor = Tensor(np.array([[2, 2], [2, 2]]), mindspore.float32) >>> size = ops.Size() >>> output = size(input_tensor) >>> print(output) 4