Skip to content

Commit 617368a

Browse files
author
Tiny
committed
add the fix for avoiding the mul trick if Inf is involved.
Signed-off-by: Tiny Ramachandra <[email protected]>.
1 parent d70ee4c commit 617368a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tf2onnx/onnx_opset/controlflow.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ def version_9(cls, ctx, node, **kwargs):
195195
handles_nan = node.get_attr_value("handles_nan", False)
196196
if ctx.get_dtype(node.output[0]) in [TensorProto.FLOAT, TensorProto.DOUBLE]:
197197
cond_node = node.inputs[0]
198-
if cond_node.type == "IsNaN":
198+
if cond_node.type in {"IsNaN", "IsInf"}:
199+
# We can't use the mul trick if Inf is involved since Inf * 0 = NaN as per IEEE 754.
199200
handles_nan = True
200201
if cond_node.type == "NotEqual" and cond_node.input[0] == cond_node.input[1]:
201202
handles_nan = True

0 commit comments

Comments
 (0)