megengine.functional.minimum

minimum(x, y)[source]

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.

Parameters
  • x – input tensor. Should have a numeric data type.

  • y – input tensor. Should have the same data type as \(x\).

Returns

a tensor containing the element-wise minima. The returned tensor must have the same data type as \(x\).

Examples

>>> F.minimum(1, 2)
Tensor(1, dtype=int32, device=xpux:0)

Element-wise minimum:

>>> x = Tensor([1, 2, 3, 4])
>>> y = Tensor([4, 3, 2, 1])
>>> F.minimum(x, y)
Tensor([1 2 2 1], dtype=int32, device=xpux:0)

Broadcasting:

>>> x = Tensor([1, 2, 3, 4])
>>> F.minimum(x, 2)
Tensor([1 2 2 2], dtype=int32, device=xpux:0)