mindspore.mint.eq

查看源文件
mindspore.mint.eq(input, other) Tensor[源代码]

逐元素计算两个输入是否相等。

\[\begin{split}out_{i} =\begin{cases} & \text{True, if } input_{i} = other_{i} \\ & \text{False, if } input_{i} \ne other_{i} \end{cases}\end{split}\]

说明

  • 支持隐式类型转换。

  • 第一个输入必须是Tensor,第二个输入可以是Tensor或Scalar。

  • 两个输入的shape支持广播。

参数:
  • input (Tensor) - 第一个输入。

  • other (Union[Tensor, Number]) - 第二个输入。

返回:

Tensor,与广播后的 inputother 有相同的shape,元素类型为bool。

支持平台:

Ascend

样例:

>>> import mindspore
>>> # case 1: The shape of two inputs are different
>>> input = mindspore.tensor([1, 2, 3], mindspore.float32)
>>> output = mindspore.mint.eq(input, 2.0)
>>> print(output)
[False True False]
>>> # case 2: The shape of two inputs are the same
>>> input = mindspore.tensor([1, 2, 3], mindspore.int32)
>>> other = mindspore.tensor([1, 2, 4], mindspore.int32)
>>> output = mindspore.mint.eq(input, other)
>>> print(output)
[True True False]