(l-onnx-doc-IsInf)= # IsInf (l-onnx-op-isinf-20)= ## IsInf - 20 ### Version - **name**: [IsInf (GitHub)](https://github.com/onnx/onnx/blob/main/docs/Operators.md#IsInf) - **domain**: `main` - **since_version**: `20` - **function**: `False` - **support_level**: `SupportType.COMMON` - **shape inference**: `True` This version of the operator has been available **since version 20**. ### Summary Map infinity to true and other values to false. ### Attributes * **detect_negative - INT** (default is `1`): (Optional) Whether map negative infinity to true. Default to 1 so that negative infinity induces true. Set this attribute to 0 if negative infinity should be mapped to false. * **detect_positive - INT** (default is `1`): (Optional) Whether map positive infinity to true. Default to 1 so that positive infinity induces true. Set this attribute to 0 if positive infinity should be mapped to false. ### Inputs - **X** (heterogeneous) - **T1**: input ### Outputs - **Y** (heterogeneous) - **T2**: output ### Type Constraints * **T1** in ( `tensor(bfloat16)`, `tensor(double)`, `tensor(float)`, `tensor(float16)`, `tensor(float8e4m3fn)`, `tensor(float8e4m3fnuz)`, `tensor(float8e5m2)`, `tensor(float8e5m2fnuz)` ): Constrain input types to float tensors. * **T2** in ( `tensor(bool)` ): Constrain output types to boolean tensors. ### Examples #### _infinity ```python import numpy as np import onnx node = onnx.helper.make_node( "IsInf", inputs=["x"], outputs=["y"], ) x = np.array([-1.2, np.nan, np.inf, 2.8, -np.inf, np.inf], dtype=np.float32) y = np.isinf(x) expect(node, inputs=[x], outputs=[y], name="test_isinf") ``` #### _positive_infinity_only ```python import numpy as np import onnx node = onnx.helper.make_node( "IsInf", inputs=["x"], outputs=["y"], detect_negative=0 ) x = np.array([-1.7, np.nan, np.inf, 3.6, -np.inf, np.inf], dtype=np.float32) y = np.isposinf(x) expect(node, inputs=[x], outputs=[y], name="test_isinf_positive") ``` #### _negative_infinity_only ```python import numpy as np import onnx node = onnx.helper.make_node( "IsInf", inputs=["x"], outputs=["y"], detect_positive=0 ) x = np.array([-1.7, np.nan, np.inf, -3.6, -np.inf, np.inf], dtype=np.float32) y = np.isneginf(x) expect(node, inputs=[x], outputs=[y], name="test_isinf_negative") ``` #### _infinity_float16 ```python import numpy as np import onnx node = onnx.helper.make_node( "IsInf", inputs=["x"], outputs=["y"], ) x = np.array([-1.2, np.nan, np.inf, 2.8, -np.inf, np.inf], dtype=np.float16) y = np.isinf(x) expect(node, inputs=[x], outputs=[y], name="test_isinf_float16") ``` ```{toctree} text_diff_IsInf_10_20 ``` (l-onnx-op-isinf-10)= ## IsInf - 10 ### Version - **name**: [IsInf (GitHub)](https://github.com/onnx/onnx/blob/main/docs/Operators.md#IsInf) - **domain**: `main` - **since_version**: `10` - **function**: `False` - **support_level**: `SupportType.COMMON` - **shape inference**: `True` This version of the operator has been available **since version 10**. ### Summary Map infinity to true and other values to false. ### Attributes * **detect_negative - INT** (default is `1`): (Optional) Whether map negative infinity to true. Default to 1 so that negative infinity induces true. Set this attribute to 0 if negative infinity should be mapped to false. * **detect_positive - INT** (default is `1`): (Optional) Whether map positive infinity to true. Default to 1 so that positive infinity induces true. Set this attribute to 0 if positive infinity should be mapped to false. ### Inputs - **X** (heterogeneous) - **T1**: input ### Outputs - **Y** (heterogeneous) - **T2**: output ### Type Constraints * **T1** in ( `tensor(double)`, `tensor(float)` ): Constrain input types to float tensors. * **T2** in ( `tensor(bool)` ): Constrain output types to boolean tensors.