mindspore.ops.Size

class mindspore.ops.Size[source]

Returns a Scalar of type int that represents the size of the input Tensor and the total number of elements in the Tensor.

Refer to mindspore.ops.size() for more detail.

Supported Platforms:

Ascend GPU CPU

Examples

>>> input_x = Tensor(np.array([[2, 2], [2, 2]]), mindspore.float32)
>>> size = ops.Size()
>>> output = size(input_x)
>>> print(output)
4