Skip to content

Commit 23e1fcb

Browse files
authored
[IR] Fix error message with remove(..., safe=True) (#1768)
Previously the node printed was incorrect.
1 parent a7835f2 commit 23e1fcb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

onnxscript/ir/_core.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,12 +1647,12 @@ def _check_node_safe_to_remove(
16471647
raise ValueError(
16481648
f"Node '{node!r}' is still an output of the graph and cannot be removed when safe=True."
16491649
)
1650-
for use, _ in output.uses():
1651-
if use in to_remove:
1652-
continue
1650+
uses_not_to_remove = [user for user, _ in output.uses() if user not in to_remove]
1651+
if uses_not_to_remove:
16531652
raise ValueError(
1654-
f"Node '{use!r}' is still being used by other nodes that are not to be "
1655-
f"removed. All of its uses: {list(output.uses())!r}"
1653+
f"Output value '{output!r}' is still being used by other nodes that are not to be "
1654+
f"removed. All of its users that is not being removed: {uses_not_to_remove!r}. "
1655+
"Please make sure these nodes are no longer using the output value."
16561656
)
16571657

16581658

0 commit comments

Comments
 (0)