Skip to content

Commit 4c952a5

Browse files
author
viv-eth
committed
[NetworkDeployer] Mangle these n...odes
1 parent 8530a25 commit 4c952a5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Deeploy/DeeployTypes.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3303,6 +3303,19 @@ def _mangleTensorNames(self):
33033303
for tensor in self.graph.tensors().values():
33043304
tensor.name = f"{tensor.name}_tensor"
33053305

3306+
# Don't override this
3307+
def _mangleNodeNames(self):
3308+
"""Mangle node names
3309+
3310+
This renames nodes based on their operation and uses an incrementing counter to ensure uniqueness.
3311+
"""
3312+
counter = {}
3313+
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
3318+
33063319
# Don't override this
33073320
def _removeIdentityNodes(self):
33083321
for node in filter(lambda x: x.op == "Identity", self.graph.nodes):
@@ -3316,6 +3329,8 @@ def frontEnd(self):
33163329

33173330
self._mangleTensorNames()
33183331

3332+
self._mangleNodeNames()
3333+
33193334
# Rename graph inputs and outputs:
33203335
for idx, inputNode in enumerate(self.graph.inputs):
33213336
inputNode.name = "input_" + str(idx)

0 commit comments

Comments
 (0)