Skip to content

Commit 75d9471

Browse files
committed
Checking if value is graph input
Signed-off-by: Ganesan Ramalingam <[email protected]>
1 parent ee2fdfb commit 75d9471

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

onnxscript/_internal/converter.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,11 +1131,11 @@ def ret(exp, i, suffix):
11311131
preferred_name = f"return_val{suffix}"
11321132
return_var = self._translate_expr(exp, preferred_name) # TODO(rama)
11331133
val = self._lookup(return_var.name, self._source_of(exp), False)
1134-
# TODO(rama): Can we avoid using val.kind here? And rely on the ir.Value methods like is_graph_input()?
1135-
if val and val.kind == values.DynamicKind.Input:
1136-
# In ONNX, a graph-input cannot be an output of the graph.
1137-
# We need to insert a copy.
1138-
return_var = self._emit_copy(return_var, preferred_name)
1134+
if isinstance(val, values.SymbolValue) and isinstance(val.value, ir.Value):
1135+
if val.value.is_graph_input():
1136+
# In ONNX, a graph-input cannot be an output of the graph.
1137+
# We need to insert a copy.
1138+
return_var = self._emit_copy(return_var, preferred_name)
11391139
for prev_output in self._current_fn.outputs:
11401140
if prev_output.name == return_var.name:
11411141
# ONNX does not allow duplicate output names.

onnxscript/_internal/values.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,5 +903,5 @@ def __init__(
903903
assert isinstance(kind, DynamicKind)
904904
if not isinstance(ir_value, ir.Value):
905905
raise TypeError(f"ir_value must be of type ir.Value not {type(ir_value)!r}.")
906-
self.kind = kind
906+
# self.kind = kind
907907
self.typeinfo = typeinfo

0 commit comments

Comments
 (0)