r"""Element-wise ``infinity`` check. Tests each element :math:`x_i` of the input tensor :math:`x` to determine whether the element is if equal to positive or negative infinity. Args: inp: input tensor. Should have a numeric data type. Returns: a tensor containi
(inp: Tensor)
| 88 | |
| 89 | |
| 90 | def isinf(inp: Tensor) -> Tensor: |
| 91 | r"""Element-wise ``infinity`` check. |
| 92 | |
| 93 | Tests each element :math:`x_i` of the input tensor :math:`x` to determine |
| 94 | whether the element is if equal to positive or negative infinity. |
| 95 | |
| 96 | Args: |
| 97 | inp: input tensor. Should have a numeric data type. |
| 98 | |
| 99 | Returns: |
| 100 | a tensor containing test results. |
| 101 | An element out is ``True`` if :math:`x_i` is either positive or negative infinity and ``False`` otherwise. |
| 102 | The returned array should have a data type of bool. |
| 103 | |
| 104 | Examples: |
| 105 | |
| 106 | >>> F.isinf(Tensor(1)) |
| 107 | Tensor(False, dtype=bool, device=xpux:0) |
| 108 | |
| 109 | .. TODO: Remove these comments when _elemwise_multi_type support scalar input |
| 110 | .. >>> F.isinf(Tensor(float("inf"))) |
| 111 | .. Tensor(True, dtype=bool, device=xpux:0) |
| 112 | |
| 113 | Element-wise isinf: |
| 114 | |
| 115 | >>> x = Tensor([1, float("inf"), 0]) |
| 116 | >>> F.isinf(x) |
| 117 | Tensor([False True False], dtype=bool, device=xpux:0) |
| 118 | """ |
| 119 | if not np.issubdtype(inp.dtype, np.floating): |
| 120 | return broadcast_to(Const(False, np.bool_, inp.device), inp.shape) |
| 121 | return _elemwise_multi_type(inp, mode="isinf", dtype="bool") |
| 122 | |
| 123 | |
| 124 | # TODO: Should be moved to elemwise - arithmetic operations |
nothing calls this directly
no test coverage detected