mindspore.mint.gt

mindspore.mint.gt(input, other)[源代码]

逐元素计算 input>other 的值。

outi={True, if inputi>otheriFalse, if inputi<=otheri

说明

  • 支持隐式类型转换。

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

  • 当输入是两个Tensor时,它们的数据类型不能同时是bool,并保证其shape可以广播。

  • 当输入是一个Tensor和一个Scalar时,Scalar只能是一个常数。

  • 支持广播。

  • 若输入的Tensor可以广播,则会把低维度通过复制该维度的值的方式扩展到另一个输入中对应的高维度。

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

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

返回:

Tensor

支持平台:

Ascend

样例:

>>> import mindspore
>>> # case 1: The shape of two inputs are different
>>> input = mindspore.tensor([1, 2, 3], mindspore.float32)
>>> output = mindspore.mint.gt(input, 2.0)
>>> print(output)
[False False True]
>>> # 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.gt(input, other)
>>> print(output)
[ False False False]