Skip to content

Commit bc25e88

Browse files
mcr229facebook-github-bot
authored andcommitted
improve error messaging in to_edge_transform_and_lower (pytorch#7184)
Summary: when sanity checks fail, the error message isn't super useful because we don't know what node or what op target is the violating one. We improve the error message here so that we can see what it is. Reviewed By: tarun292 Differential Revision: D66787170
1 parent 8861b9a commit bc25e88

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

exir/program/_program.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -880,9 +880,10 @@ def _sanity_check_graph_for_non_decomp_ops(
880880
generate_error=False,
881881
partitioner_name=None,
882882
):
883-
warning_str = f"Found {ops_set_to_not_decompose} in edge dialect program {name}."
883+
warning_str_end = ""
884884
if partitioner_name is not None:
885-
warning_str += f" This op was registered by the partitioner {partitioner_name} to not be decomposed."
885+
warning_str_end += f"This op was registered by the partitioner {partitioner_name} to not be decomposed.\n"
886+
warning_str_end += f"The following ops: {ops_set_to_not_decompose} were specified to not be decomposed in {name}."
886887

887888
# Check that the ops that were registered to not be decomposed are not present in the
888889
# graph anymore as the transform passes and backends should have consumed them by now.
@@ -894,6 +895,10 @@ def _sanity_check_graph_for_non_decomp_ops(
894895
if (
895896
node.op == "call_function" and node.target in ops_set_to_not_decompose
896897
) and is_op_supported:
898+
warning_str = (
899+
f"Node {node} with op {node.target} was not decomposed or delegated.\n"
900+
+ warning_str_end
901+
)
897902
if generate_error:
898903
raise RuntimeError(warning_str)
899904
else:
@@ -904,6 +909,10 @@ def _sanity_check_graph_for_non_decomp_ops(
904909
if (
905910
node.op == "call_function" and node.target in ops_set_to_not_decompose
906911
) and is_op_supported:
912+
warning_str = (
913+
f"Node {node} with op {node.target} was not decomposed or delegated.\n"
914+
+ warning_str_end
915+
)
907916
if generate_error:
908917
raise RuntimeError(warning_str)
909918
else:

0 commit comments

Comments
 (0)