From c2c77ae7cf988a49e020f6acf7d952439016b369 Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Thu, 1 Aug 2024 17:49:34 +0000 Subject: [PATCH 1/4] Fix --- onnxscript/ir/_core.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/onnxscript/ir/_core.py b/onnxscript/ir/_core.py index 7eeba0493..310f19420 100644 --- a/onnxscript/ir/_core.py +++ b/onnxscript/ir/_core.py @@ -1647,12 +1647,11 @@ def _check_node_safe_to_remove( raise ValueError( f"Node '{node!r}' is still an output of the graph and cannot be removed when safe=True." ) - for use, _ in output.uses(): - if use in to_remove: - continue + uses_not_to_remove = [use for use, _ in output.uses() if use not in to_remove] + if uses_not_to_remove: raise ValueError( - f"Node '{use!r}' is still being used by other nodes that are not to be " - f"removed. All of its uses: {list(output.uses())!r}" + f"Node '{output!r}' is still being used by other nodes that are not to be " + f"removed. All of its uses that is not being removed: {uses_not_to_remove!r}" ) From bea865cf4f3d57f5c5e669417f2fda4e02d64810 Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Thu, 1 Aug 2024 18:11:15 +0000 Subject: [PATCH 2/4] output --- onnxscript/ir/_core.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/onnxscript/ir/_core.py b/onnxscript/ir/_core.py index 310f19420..ccd7c306d 100644 --- a/onnxscript/ir/_core.py +++ b/onnxscript/ir/_core.py @@ -1650,8 +1650,9 @@ def _check_node_safe_to_remove( uses_not_to_remove = [use for use, _ in output.uses() if use not in to_remove] if uses_not_to_remove: raise ValueError( - f"Node '{output!r}' is still being used by other nodes that are not to be " - f"removed. All of its uses that is not being removed: {uses_not_to_remove!r}" + f"Output value '{output!r}' is still being used by other nodes that are not to be " + f"removed. All of its uses that is not being removed: {uses_not_to_remove!r}. " + "Please make sure these nodes are no longer using the output value." ) From 75cacc864064a243dca7f3f830694e51ff9b284b Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Thu, 1 Aug 2024 18:12:56 +0000 Subject: [PATCH 3/4] naming --- onnxscript/ir/_core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onnxscript/ir/_core.py b/onnxscript/ir/_core.py index ccd7c306d..b795d02e5 100644 --- a/onnxscript/ir/_core.py +++ b/onnxscript/ir/_core.py @@ -1647,7 +1647,7 @@ def _check_node_safe_to_remove( raise ValueError( f"Node '{node!r}' is still an output of the graph and cannot be removed when safe=True." ) - uses_not_to_remove = [use for use, _ in output.uses() if use not in to_remove] + uses_not_to_remove = [user for user, _ in output.uses() if user not in to_remove] if uses_not_to_remove: raise ValueError( f"Output value '{output!r}' is still being used by other nodes that are not to be " From 1f194b2e1a0eafd14bdd072c90f1c0bbf2720c24 Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Thu, 1 Aug 2024 18:13:27 +0000 Subject: [PATCH 4/4] user --- onnxscript/ir/_core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onnxscript/ir/_core.py b/onnxscript/ir/_core.py index b795d02e5..b5a29cdd4 100644 --- a/onnxscript/ir/_core.py +++ b/onnxscript/ir/_core.py @@ -1651,7 +1651,7 @@ def _check_node_safe_to_remove( if uses_not_to_remove: raise ValueError( f"Output value '{output!r}' is still being used by other nodes that are not to be " - f"removed. All of its uses that is not being removed: {uses_not_to_remove!r}. " + f"removed. All of its users that is not being removed: {uses_not_to_remove!r}. " "Please make sure these nodes are no longer using the output value." )