megengine.functional.less#

less(x, y)[source]#

Element-wise less-than comparison.

Computes the truth value of \(x_i < y_i\) for each element \(x_i\) of the input tensor \(x\) with the respective element \(y_i\) of the input tensor \(y\).

Parameters:
  • x – first input tensor. May have any data type.

  • y – second input tensor. Must be compatible with \(x\) (see Broadcasting mechanism and rules ). May have any data type.

Returns:

a tensor containing the result of the element-wise results. The returned tensor must have a data type of bool.

Examples

Element-wise less-than comparison:

>>> x = Tensor([1, 2, 3])
>>> y = Tensor([1, 2, 4])
>>> F.less(x, y)
Tensor([False False  True], dtype=bool, device=xpux:0)

The < operator can be used as a shorthand for F.less on boolean tensors.

>>> x < y
Tensor([False False  True], dtype=bool, device=xpux:0)