megengine.functional.ceil¶
- ceil(x)[source]¶
Element-wise \(\lceil x \rceil\) function.
Rounds each element \(x_i\) of the input tensor \(x\) to the smalles integer-valued number that is not less 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.ceil(1.5) Tensor(2.0, device=xpux:0)
Element-wise ceiling:
>>> x = Tensor([1.5, 2.5, 3.5, 4.5]) >>> F.ceil(x) Tensor([2. 3. 4. 5.], device=xpux:0)