Skip to content

Commit 615fd47

Browse files
author
viv-eth
committed
[DeeployTypes] Only mangle on duplicates
1 parent 4c952a5 commit 615fd47

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

Deeploy/DeeployTypes.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3305,16 +3305,21 @@ def _mangleTensorNames(self):
33053305

33063306
# Don't override this
33073307
def _mangleNodeNames(self):
3308-
"""Mangle node names
3308+
"""Mangle node names only if duplicates exist. Unique names are preserved."""
3309+
# Count occurrences of each original name
3310+
counts: Dict[str, int] = {}
3311+
for node in self.graph.nodes:
3312+
counts[node.name] = counts.get(node.name, 0) + 1
33093313

3310-
This renames nodes based on their operation and uses an incrementing counter to ensure uniqueness.
3311-
"""
3312-
counter = {}
3314+
# For any name that appears more than once, append a counter suffix
3315+
seen: Dict[str, int] = {}
33133316
for node in self.graph.nodes:
3314-
op_name = node.op if isinstance(node.op, str) else str(node.op)
3315-
idx = counter.get(op_name, 0)
3316-
node.name = f"{op_name}_{idx}"
3317-
counter[op_name] = idx + 1
3317+
orig = node.name
3318+
if counts[orig] > 1:
3319+
idx = seen.get(orig, 0)
3320+
node.name = f"{orig}_{idx}"
3321+
seen[orig] = idx + 1
3322+
# else: unique name, leave it unchanged
33183323

33193324
# Don't override this
33203325
def _removeIdentityNodes(self):

0 commit comments

Comments
 (0)