Skip to content
Snippets Groups Projects
Commit 470d5bed authored by Cyril Moineau's avatar Cyril Moineau
Browse files

[Replace] Add case when replacing a graph by a Producer + add debug log.

parent d73de808
No related branches found
No related tags found
3 merge requests!414Update version 0.5.1 -> 0.6.0,!408[Add] Dropout Operator,!297Reshape forward dims
......@@ -1256,6 +1256,7 @@ bool Aidge::GraphView::replace(const std::shared_ptr<GraphView>& oldGraph, const
for (const auto& nodePtr : newNodes) {
nodePtr->removeView(newGraph);
}
Log::warn("Discrepancy between the number of input/output of the graph to replace.\n\t- OLD NB INPUTS: {} - NEW NB INPUTS {}\n\t- OLD NB OUTPUTS: {} - NEW NB OUTPUTS {}", oldOIn.size(), newOIn.size(), oldOOut.size(), newOOut.size());
return false;
}
......@@ -1325,14 +1326,27 @@ bool Aidge::GraphView::replace(const std::shared_ptr<GraphView>& oldGraph, const
newOOut[o].first -> addChild(child.first, newOOut[o].second, child.second);
}
}
}
else {
} else if ( // for folding case
((newOIn.size() == 0)) &&
((oldOOut.size() == newOOut.size()) && (newOOut.size() == 1))
) {
// Case 4
// Replace any nodes by a Producer
// No need to remove old inputs it is removed later on ...
for (std::size_t o = 0; o < oldOOut.size(); ++o) {
for (const auto& child : outputChildren[o]) {
newOOut[o].first -> addChild(child.first, newOOut[o].second, child.second);
}
}
} else {
for (const auto& nodePtr : oldNodes) {
nodePtr->removeView(oldGraph);
}
for (const auto& nodePtr : newNodes) {
nodePtr->removeView(newGraph);
}
Log::warn("Could not replace");
return false;
}
}
......
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