mindspore.ops.greater

mindspore.ops.greater(input, other)[源代码]

按元素比较输入参数 \(input > other\) 的值,输出结果为bool值。

参数:
  • input (Union[Tensor, number.Number, bool]) - 第一个输入,是一个number.Number、bool值或数据类型为 numberbool_ 的Tensor。

  • other (Union[Tensor, number.Number, bool]) - 第二个输入,当第一个输入是Tensor时,第二个输入应该是一个number.Number或bool值,或数据类型为number或bool_的Tensor。当第一个输入是Scalar时,第二个输入必须是数据类型为number或bool_的Tensor。

返回:

Tensor,shape与广播后的shape相同,数据类型为bool。

支持平台:

Ascend CPU GPU

样例:

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