Unicity name error when fusing two graphs
Context
I encounter this error when fusing two graph in one via:
model0.add(model1)
Where model0
and model1
both contains a node with the same name (i.e. tensor_19
).
For ONNX export I needed name unicity and thus I created the function remove_duplicate_names().
Before this commit : 3d53ab30 the function setName
did not update the name of the node in every GraphView which contains this node.
But since this commit the function remove_duplicate_name raise an error. Indeed we change twice the same name.
Fix
To fix this, we need to update the function GraphView.add(GraphView)
to update nodes name when the name is already existing in the graph in which we append the other graph.
Specification
A discussion with @pineapple made us consider different behavior:
- Raise an error if the name already exist
- Automatically rename nodes and raise a warning message to indicate the new names
- Add a boolean argument to the add function to chose between behavior 1. and 2.
For a first fix I will go with the solution 2.
To rename the node, we need to check that the new name doesn't already exist in one of the graph which contains the node. To do this, I propose to use a recursive function.