mindspore.ops.eq

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

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

outi={True, if inputi=otheriFalse, if inputiotheri

说明

  • 支持隐式类型转换。

  • 输入必须是两个Tensor,或是一个Tensor和一个Scalar。

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

参数:
  • input (Union[Tensor, Number]) - 第一个输入。

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

返回:

Tensor

支持平台:

Ascend GPU CPU

样例:

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