mindspore.ops.fmax

View Source On Gitee
mindspore.ops.fmax(input, other)[source]

Computes the maximum of input tensors element-wise.

\[output_i = \max(x1_i, x2_i)\]

Note

  • Inputs of input and other comply with the implicit type conversion rules to make the data types consistent.

  • Shapes of input and other should be able to broadcast.

  • If one of the elements to be compared is NaN, another element is returned.

Parameters
  • input (Tensor) – The first tensor. The supported dtypes are: float16, float32, float64, int32, int64.

  • other (Tensor) – The second tensor. The supported dtypes are: float16, float32, float64, int32, int64.

Returns

A Tensor, the shape is the same as the one after broadcasting, and the data type is the one with higher precision or higher digits among the two inputs.

Raises
  • TypeError – If input or other is not Tensor.

  • TypeError – If dtype of input or other is not one of: float16, float32, float64, int32, int64.

  • ValueError – If the shape of input and other can not broadcast.

Supported Platforms:

CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> x1 = Tensor(np.array([1.0, 5.0, 3.0]), mindspore.float32)
>>> x2 = Tensor(np.array([4.0, 2.0, 6.0]), mindspore.float32)
>>> output = ops.fmax(x1, x2)
>>> print(output)
[4. 5. 6.]