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

Function minimum

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

r"""Element-wise minimum of tensor elements. Compare two tensors and returns a new tensor containing the element-wise minima. 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

1001
1002
1003def minimum(x, y):
1004 r"""Element-wise minimum of tensor elements.
1005
1006 Compare two tensors and returns a new tensor containing the element-wise minima.
1007 If one of the elements being compared is a ``NaN``, then that element is returned.
1008 If both elements are ``NaNs`` then the first is returned.
1009
1010 Args:
1011
1012 x: input tensor. Should have a numeric data type.
1013 y: input tensor. Should have the same data type as :math:`x`.
1014
1015 Returns:
1016
1017 a tensor containing the element-wise minima.
1018 The returned tensor must have the same data type as :math:`x`.
1019
1020 Examples:
1021 >>> F.minimum(1, 2)
1022 Tensor(1, dtype=int32, device=xpux:0)
1023
1024 Element-wise minimum:
1025
1026 >>> x = Tensor([1, 2, 3, 4])
1027 >>> y = Tensor([4, 3, 2, 1])
1028 >>> F.minimum(x, y)
1029 Tensor([1 2 2 1], dtype=int32, device=xpux:0)
1030
1031 Broadcasting:
1032
1033 >>> x = Tensor([1, 2, 3, 4])
1034 >>> F.minimum(x, 2)
1035 Tensor([1 2 2 2], dtype=int32, device=xpux:0)
1036
1037 """
1038 return _elwise(x, y, mode=Elemwise.Mode.MIN)
1039
1040
1041def clip(x: Tensor, lower=None, upper=None) -> Tensor:

Callers 10

log_add_expFunction · 0.85
hswishFunction · 0.85
resize_nearest_helperFunction · 0.85
fakequant_lowerFunction · 0.85
tqt_lowerFunction · 0.85
tqt_grad_ruleFunction · 0.85
lsq_lowerFunction · 0.85
clipFunction · 0.85
_assert_equalFunction · 0.85
clip_grad_normFunction · 0.85

Calls 1

_elwiseFunction · 0.50

Tested by

no test coverage detected