r"""Element-wise :math:`\lceil x \rceil` function. Rounds each element :math:`x_i` of the input tensor :math:`x` to the smalles integer-valued number that is not less than :math:`x_i`. Args: x: input tensor. Should have a numeric data type. Returns: a tensor contai
(x)
| 888 | |
| 889 | |
| 890 | def ceil(x): |
| 891 | r"""Element-wise :math:`\lceil x \rceil` function. |
| 892 | |
| 893 | Rounds each element :math:`x_i` of the input tensor :math:`x` to the smalles integer-valued number that is not less than :math:`x_i`. |
| 894 | |
| 895 | Args: |
| 896 | x: input tensor. Should have a numeric data type. |
| 897 | |
| 898 | Returns: |
| 899 | a tensor containing the rounded result for each element in :math:`x`. |
| 900 | The returned tensor must have the same data type as :math:`x`. |
| 901 | |
| 902 | .. admonition:: Special cases |
| 903 | |
| 904 | If :math:`x_i` is already integer-valued, the result is :math:`x_i`. |
| 905 | |
| 906 | For floating-point operands, |
| 907 | |
| 908 | * If :math:`x_i` is ``+infinity``, the result is ``+infinity``. |
| 909 | * If :math:`x_i` is ``-infinity``, the result is ``-infinity``. |
| 910 | * If :math:`x_i` is ``+0``, the result is ``+0``. |
| 911 | * If :math:`x_i` is ``-0``, the result is ``-0``. |
| 912 | * If :math:`x_i` is NaN, the result is NaN. |
| 913 | |
| 914 | Examples: |
| 915 | >>> F.ceil(1.5) |
| 916 | Tensor(2.0, device=xpux:0) |
| 917 | |
| 918 | Element-wise ceiling: |
| 919 | |
| 920 | >>> x = Tensor([1.5, 2.5, 3.5, 4.5]) |
| 921 | >>> F.ceil(x) |
| 922 | Tensor([2. 3. 4. 5.], device=xpux:0) |
| 923 | |
| 924 | """ |
| 925 | return _elwise(x, mode=Elemwise.Mode.CEIL) |
| 926 | |
| 927 | |
| 928 | def floor(x): |