megengine.functional.floor¶
- floor(x)[source]¶
Element-wise \(\lfloor x \rfloor\) function.
Rounds each element \(x_i\) of the input tensor \(x\) to the greatest integer-valued number that is not greater than \(x_i\).
- Parameters
x – input tensor. Should have a numeric data type.
- Returns
a tensor containing the rounded result for each element in \(x\). The returned tensor must have the same data type as \(x\).
Special cases
If \(x_i\) is already integer-valued, the result is \(x_i\).
For floating-point operands,
If \(x_i\) is
+infinity
, the result is+infinity
.If \(x_i\) is
-infinity
, the result is-infinity
.If \(x_i\) is
+0
, the result is+0
.If \(x_i\) is
-0
, the result is-0
.If \(x_i\) is NaN, the result is NaN.
Examples
>>> F.floor(1.5) Tensor(1.0, device=xpux:0)
Element-wise flooring:
>>> x = Tensor([1.5, 2.5, 3.5, 4.5]) >>> F.floor(x) Tensor([1. 2. 3. 4.], device=xpux:0)