File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments