Skip to content

Conversation

tnybny
Copy link

@tnybny tnybny commented Sep 10, 2025

The multiplication trick for IsInf doesn't work because as per IEEE 754, Inf * 0 = NaN.

This causes the pattern tf.where(tf.math.is_inf(x), 0., false_val) to fail to produce equal results in Keras/TensorFlow and ONNX.

If x is set to tf.constant([np.inf]), Keras returns Tensor([0.]) correctly, but the ONNX graph execution returns np.ndarray([NaN]) since it tries to use the multiplication trick incorrectly and fails.

@tnybny tnybny force-pushed the fix/add-inf-handling-to-select branch from cfc15d0 to 617368a Compare September 10, 2025 19:25
@tnybny tnybny marked this pull request as ready for review September 10, 2025 19:29
@xadupre xadupre merged commit 4fed7de into onnx:main Sep 12, 2025
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants