mindspore.Tensor.le
- Tensor.le(other) Tensor
Computes the boolean value of :math: self <= other element-wise.
\[\begin{split}out_{i} = \begin{cases} & \text{True, if } self_{i}<=other_{i} \\ & \text{False, if } self_{i}>other_{i} \end{cases}\end{split}\]Note
Inputs of self and other comply with the implicit type conversion rules to make the data types consistent.
The other must be tensor or scalar. When the other is scalar, the scalar could only be a constant.
- Parameters
other (Union[Tensor, number.Number, bool]) – The other should be a number.Number or bool value, or a Tensor whose data type is number or bool_.
- Returns
Tensor, the shape is the same as the one after broadcasting, and the data type is bool.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> import numpy as np >>> from mindspore import Tensor >>> x = Tensor(np.array([1, 2, 3]), mindspore.int32) >>> y = Tensor(np.array([1, 1, 4]), mindspore.int32) >>> output = x.le(y) >>> print(output) [ True False True]