Skip to content
Snippets Groups Projects
Commit 1e4532cd authored by Axel Farrugia's avatar Axel Farrugia
Browse files

Fixed UpdateNodeNamex

parent acd012c0
No related branches found
No related tags found
4 merge requests!279v0.4.0,!253v0.4.0,!210Fixed UpdateNodeName issue,!163Export refactor
Pipeline #55361 failed
...@@ -406,16 +406,19 @@ public: ...@@ -406,16 +406,19 @@ public:
addChild(toOtherNode, mNodeRegistry.at(fromOutNodeName), fromTensor, toTensor); addChild(toOtherNode, mNodeRegistry.at(fromOutNodeName), fromTensor, toTensor);
} }
inline void updateNodeName(NodePtr nodeToRename, const std::string& newName){ inline void updateNodeName(const std::shared_ptr<Node>& node, const std::string& newName){
const std::string& oldName = nodeToRename->name(); if (!newName.empty()) {
AIDGE_ASSERT(mNodeRegistry.find(newName) != mNodeRegistry.end(), "Name {} is already used in graph {}.", newName, name()); auto itNew = mNodeRegistry.insert(std::make_pair(newName, node));
if (!itNew.second) {
if (nodeToRename->name() != ""){ // Case node already had a name Log::notice("Replacing existing node name in graph node name registry: {}", newName);
AIDGE_ASSERT(mNodeRegistry.find(oldName) != mNodeRegistry.end(), "No node named {} in graph {}, the graph may be corrupted !", oldName, name()); (itNew.first)->second = node;
mNodeRegistry[newName] = mNodeRegistry[oldName]; }
mNodeRegistry.erase(oldName); }
}else{ // Case node did not had a name
mNodeRegistry[newName] = nodeToRename; if (!node->name().empty()) {
const auto it = mNodeRegistry.find(node->name());
AIDGE_ASSERT(it != mNodeRegistry.end(), "No node named {} in graph {}, the graph may be corrupted !", node->name(), name());
mNodeRegistry.erase(it);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment