mindspore.ops.EqualCount

class mindspore.ops.EqualCount[source]

Computes the number of the same elements of two tensors.

The two input tensors must have the same data type and shape.

Inputs:
  • x (Tensor) - The first input tensor. If the data type and shape of y are determined, then x must be the same as y, and vice versa. \((N,*)\) where \(*\) means, any number of additional dimensions.

  • y (Tensor) - The second input tensor. If the data type and shape of x are determined, then y must be the same as x, and vice versa.

Outputs:

Tensor, with the type same as input tensor and size as (1,).

Raises
  • TypeError – If x or y is not a Tensor.

  • ValueError – If shape of x is not equal to shape of y.

Supported Platforms:

GPU CPU

Examples

>>> x = Tensor(np.array([1, 2, 3]), mindspore.int32)
>>> y = Tensor(np.array([1, 2, 4]), mindspore.int32)
>>> equal_count = ops.EqualCount()
>>> output = equal_count(x, y)
>>> print(output)
[2]