From 946406a450a32435a21b405c1280e26da76139fa Mon Sep 17 00:00:00 2001 From: Lucy Qiu Date: Thu, 21 Mar 2024 10:57:46 -0700 Subject: [PATCH] Fallback to deepcopy when fake program fails (#2564) Summary: Pull Request resolved: https://github.com/pytorch/executorch/pull/2564 Catch the general Exception case, not only AssertionError. Reviewed By: cccclai Differential Revision: D55204315 --- exir/backend/backend_api.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/exir/backend/backend_api.py b/exir/backend/backend_api.py index 8d6d30f7903..3d362505170 100644 --- a/exir/backend/backend_api.py +++ b/exir/backend/backend_api.py @@ -351,8 +351,10 @@ def to_backend( # Fall back to deepcopy if no fake mode is found. TODO(T182910699): Remove this fallback. try: fake_edge_program = get_fake_program(edge_program) - except AssertionError as e: - logging.warning(f"No fake mode found for {edge_program.graph_module}: {e}") + except Exception as e: + logging.warning( + f"Error in get_fake_program for graph {edge_program.graph_module}, fallback to deepcopy: {e}" + ) fake_edge_program = copy.deepcopy(edge_program) partitioner_result = partitioner_instance(fake_edge_program) tagged_exported_program = partitioner_result.tagged_exported_program