Skip to content

Commit 08ef68a

Browse files
authored
Remove duplicated return_var (#2776)
A duplicated ir.Value for return_var was unintentionally generated. Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
1 parent 697bce0 commit 08ef68a

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

onnxscript/_internal/converter.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,8 +1112,8 @@ def check_num_outputs(n):
11121112

11131113
def ret(exp, i, suffix):
11141114
preferred_name = f"return_val{suffix}"
1115-
return_var = self._translate_expr(exp, preferred_name) # TODO(rama)
1116-
val = self._lookup(return_var.name, self._source_of(exp), False)
1115+
return_var = self._translate_expr(exp, preferred_name)
1116+
val = self._lookup(return_var.name, self._source_of(exp), raise_exception=False)
11171117
if isinstance(val, values.SymbolValue) and isinstance(val.value, ir.Value):
11181118
if val.value.is_graph_input():
11191119
# In ONNX, a graph-input cannot be an output of the graph.
@@ -1124,13 +1124,9 @@ def ret(exp, i, suffix):
11241124
# ONNX does not allow duplicate output names.
11251125
return_var = self._emit_copy(return_var, f"{return_var}_copy")
11261126
break
1127-
if self.returntype is None:
1128-
t = None
1129-
else:
1130-
t = self.returntype[i]
1131-
self._current_fn.outputs.append(
1132-
make_value(return_var.name, t, self._source_of(stmt))
1133-
)
1127+
if self.returntype is not None:
1128+
set_type_info(return_var, self.returntype[i])
1129+
self._current_fn.outputs.append(return_var)
11341130
return return_var
11351131

11361132
val = stmt.value

0 commit comments

Comments
 (0)