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"(?