MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / maximum

Function maximum

imperative/python/megengine/functional/elemwise.py:965–1000  ·  view source on GitHub ↗

r"""Element-wise maximum of tensor elements. Compare two tensors and returns a new tensor containing the element-wise maxima. If one of the elements being compared is a ``NaN``, then that element is returned. If both elements are ``NaNs`` then the first is returned. Args:

(x, y)

Source from the content-addressed store, hash-verified

963
964
965def maximum(x, y):
966 r"""Element-wise maximum of tensor elements.
967
968 Compare two tensors and returns a new tensor containing the element-wise maxima.
969 If one of the elements being compared is a ``NaN``, then that element is returned.
970 If both elements are ``NaNs`` then the first is returned.
971
972 Args:
973
974 x: input tensor. Should have a numeric data type.
975 y: input tensor. Should have the same data type as :math:`x`.
976
977 Returns:
978
979 a tensor containing the element-wise maxima.
980 The returned tensor must have the same data type as :math:`x`.
981
982 Examples:
983 >>> F.maximum(1, 2)
984 Tensor(2, dtype=int32, device=xpux:0)
985
986 Element-wise maximum:
987
988 >>> x = Tensor([1, 2, 3, 4])
989 >>> y = Tensor([4, 3, 2, 1])
990 >>> F.maximum(x, y)
991 Tensor([4 3 3 4], dtype=int32, device=xpux:0)
992
993 Broadcasting:
994
995 >>> x = Tensor([1, 2, 3, 4])
996 >>> F.maximum(x, 2)
997 Tensor([2 2 3 4], dtype=int32, device=xpux:0)
998
999 """
1000 return _elwise(x, y, mode=Elemwise.Mode.MAX)
1001
1002
1003def minimum(x, y):

Callers 9

log_add_expFunction · 0.85
hswishFunction · 0.85
fakequant_lowerFunction · 0.85
tqt_lowerFunction · 0.85
tqt_grad_ruleFunction · 0.85
lsq_lowerFunction · 0.85
_safelogFunction · 0.85
clipFunction · 0.85
_assert_equalFunction · 0.85

Calls 1

_elwiseFunction · 0.50

Tested by

no test coverage detected