From f1003ce4873cd89a847ecad3cf1bf1b724ef54d7 Mon Sep 17 00:00:00 2001 From: Ethan Ng Date: Mon, 17 Nov 2025 10:04:30 -0800 Subject: [PATCH] Update exir_deserialize logic (#15840) Summary: Pull Request resolved: https://github.com/pytorch/executorch/pull/15840 Reviewed By: mcremon-meta Differential Revision: D87112636 --- exir/serde/export_serialize.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/exir/serde/export_serialize.py b/exir/serde/export_serialize.py index caab322d27b..885f018a1f8 100644 --- a/exir/serde/export_serialize.py +++ b/exir/serde/export_serialize.py @@ -2143,17 +2143,23 @@ def deserialize_meta_func(serialized_target: str): def import_nn_module_stack(key, path, ty): return key, (path, ty) - # Helper function that splits strings by commas except for those - # encapsulated by parens, which are valid traces. - # TODO: Currently this is needed due to indexing Sequential - # layers introducing names in the form "layer.slice(1, None, None)". - # If that naming is improved, this fancier splitting can probably be - # reverted to a simple split by comma. + # Helper function to split string by commas, accounting for nested parentheses/brackets def metadata_split(metadata): - # Remove the parentheses and commas inside them - metadata = re.sub(r"\(.*?\)", "", metadata) - # Split the string by comma, except for those inside parentheses - return re.split(r"(?