From 2659ce34bf0cac8816283329b87ce519b94f1ecd Mon Sep 17 00:00:00 2001
From: Olivier BICHLER <olivier.bichler@cea.fr>
Date: Fri, 30 Aug 2024 16:46:35 +0200
Subject: [PATCH] Fixed GraphMatching

---
 src/graph/Matching.cpp | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/graph/Matching.cpp b/src/graph/Matching.cpp
index 22be1347a..4a62019a7 100644
--- a/src/graph/Matching.cpp
+++ b/src/graph/Matching.cpp
@@ -642,6 +642,10 @@ bool Aidge::SinglePassGraphMatching::matchNode(Context& ctx, std::set<MatchingRe
 
                 for (const auto& output : outputs) {
                     for (const auto& node : output) {
+                        if (!node.first) {
+                            continue;
+                        }
+
                         if (newCtx.edgeRightIdx == gk_IODefaultIndex || node.second == newCtx.edgeRightIdx) {
                             if (mGraph->inView(node.first) && !it->graph->inView(node.first)) {
                                 found = true;
@@ -663,6 +667,10 @@ bool Aidge::SinglePassGraphMatching::matchNode(Context& ctx, std::set<MatchingRe
                     : it->startNode->inputs();
 
                 for (const auto& input : inputs) {
+                    if (!input.first) {
+                        continue;
+                    }
+
                     if (newCtx.edgeRightIdx == gk_IODefaultIndex || input.second == newCtx.edgeRightIdx) {
                         if (mGraph->inView(input.first) && !it->graph->inView(input.first)) {
                             found = true;
@@ -741,6 +749,10 @@ bool Aidge::SinglePassGraphMatching::matchNode(Context& ctx, std::set<MatchingRe
                     }
 
                     for (const auto& node : output) {
+                        if (!node.first) {
+                            continue;
+                        }
+
                         if ((type.empty() || node.first->type() == type)
                             && (lambda.empty() || mLambda.at(lambda)(node.first))
                             && (newCtx.edgeRightIdx == gk_IODefaultIndex || node.second == newCtx.edgeRightIdx))
@@ -775,6 +787,10 @@ bool Aidge::SinglePassGraphMatching::matchNode(Context& ctx, std::set<MatchingRe
                     : it->startNode->inputs();
 
                 for (const auto& input : inputs) {
+                    if (!input.first) {
+                        continue;
+                    }
+
                     if ((type.empty() || input.first->type() == type)
                         && (lambda.empty() || mLambda.at(lambda)(input.first))
                         && (newCtx.edgeRightIdx == gk_IODefaultIndex || input.second == newCtx.edgeRightIdx))
-- 
GitLab