From 0001e9f0e3f10bec8b14b81432b2c909c7eebc76 Mon Sep 17 00:00:00 2001 From: Olivier BICHLER <olivier.bichler@cea.fr> Date: Tue, 6 May 2025 16:09:28 +0200 Subject: [PATCH] Also work with fewer new I/O --- src/graph/GraphView.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/graph/GraphView.cpp b/src/graph/GraphView.cpp index 931b11a0d..5cf92cb6e 100644 --- a/src/graph/GraphView.cpp +++ b/src/graph/GraphView.cpp @@ -1558,13 +1558,18 @@ bool Aidge::GraphView::replace(const std::shared_ptr<GraphView>& oldGraph, const } // Replace old inputs with new ones - if (oldOIn.size() == newOIn.size()) { + if (oldOIn.size() >= newOIn.size()) { for (const auto& g : commonGraphViews) { auto inputs = orderedInputs.at(g); for (std::size_t i = 0; i < oldOIn.size(); ++i) { auto it = std::find(inputs.begin(), inputs.end(), oldOIn[i]); if (it != inputs.end()) { - *it = newOIn[i]; + if (i < newOIn.size()) { + *it = newOIn[i]; + } + else { + inputs.erase(it); + } } } g->setOrderedInputs(inputs); @@ -1572,13 +1577,18 @@ bool Aidge::GraphView::replace(const std::shared_ptr<GraphView>& oldGraph, const } // Replace old outputs with new ones - if (oldOOut.size() == newOOut.size()) { + if (oldOOut.size() >= newOOut.size()) { for (const auto& g : commonGraphViews) { auto outputs = orderedOutputs.at(g); for (std::size_t i = 0; i < oldOOut.size(); ++i) { auto it = std::find(outputs.begin(), outputs.end(), oldOOut[i]); if (it != outputs.end()) { - *it = newOOut[i]; + if (i < newOOut.size()) { + *it = newOOut[i]; + } + else { + outputs.erase(it); + } } } g->setOrderedOutputs(outputs); -- GitLab