mindspore.mint.gt

View Source On Gitee
mindspore.mint.gt(input, other)[source]

Compute the value of \(input > other\) element-wise.

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

Note

  • Support implicit type conversion.

  • The inputs must be two tensors or one tensor and one scalar.

  • When the inputs are two tensors, dtypes of them cannot be bool at the same time, and the shapes of them can be broadcast.

  • When the inputs are one tensor and one scalar, the scalar could only be a constant.

  • Broadcasting is supported.

  • If the input Tensor can be broadcast, the low dimension will be extended to the corresponding high dimension in another input by copying the value of the dimension.

Parameters
  • input (Union[Tensor, number.Number, bool]) – The first input.

  • other (Union[Tensor, number.Number, bool]) – The second input.

Returns

Tensor

Supported Platforms:

Ascend

Examples

>>> 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]