r"""Element-wise :math:`\operatorname{round}(x)` function. Rounds each element :math:`x_i` of the input tensor :math:`x` to the nearest integer-valued number. Args: x: input tensor. Should have a numeric data type. Returns: a tensor containing the rounded resul
(x)
| 850 | |
| 851 | |
| 852 | def round(x): |
| 853 | r"""Element-wise :math:`\operatorname{round}(x)` function. |
| 854 | |
| 855 | Rounds each element :math:`x_i` of the input tensor :math:`x` to the nearest integer-valued number. |
| 856 | |
| 857 | Args: |
| 858 | x: input tensor. Should have a numeric data type. |
| 859 | |
| 860 | Returns: |
| 861 | a tensor containing the rounded result for each element in :math:`x`. |
| 862 | The returned tensor must have the same data type as :math:`x`. |
| 863 | |
| 864 | .. admonition:: Special cases |
| 865 | |
| 866 | If :math:`x_i` is already integer-valued, the result is :math:`x_i`. |
| 867 | |
| 868 | For floating-point operands, |
| 869 | |
| 870 | * If :math:`x_i` is ``+infinity``, the result is ``+infinity``. |
| 871 | * If :math:`x_i` is ``-infinity``, the result is ``-infinity``. |
| 872 | * If :math:`x_i` is ``+0``, the result is ``+0``. |
| 873 | * If :math:`x_i` is ``-0``, the result is ``-0``. |
| 874 | * If :math:`x_i` is NaN, the result is NaN. |
| 875 | * If two integers are equally close to :math:`x_i`, the result is the even integer closest to :math:`x_i`. |
| 876 | |
| 877 | Examples: |
| 878 | >>> F.round(1.5) |
| 879 | Tensor(2.0, device=xpux:0) |
| 880 | |
| 881 | Element-wise rounding: |
| 882 | |
| 883 | >>> x = Tensor([1.5, 2.5, 3.5, 4.5]) |
| 884 | >>> F.round(x) |
| 885 | Tensor([2. 3. 4. 5.], device=xpux:0) |
| 886 | """ |
| 887 | return _elwise(x, mode=Elemwise.Mode.ROUND) |
| 888 | |
| 889 | |
| 890 | def ceil(x): |
no test coverage detected