From 470d5bed2375951c4bbcb61b902a6ff9627cbba2 Mon Sep 17 00:00:00 2001 From: cmoineau <cyril.moineau@cea.fr> Date: Fri, 28 Feb 2025 15:25:11 +0000 Subject: [PATCH] [Replace] Add case when replacing a graph by a Producer + add debug log. --- src/graph/GraphView.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/graph/GraphView.cpp b/src/graph/GraphView.cpp index 5d4df27a0..91cc0f889 100644 --- a/src/graph/GraphView.cpp +++ b/src/graph/GraphView.cpp @@ -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; } } -- GitLab