From f030eb568e624ff4d02781acd76a156a4750e349 Mon Sep 17 00:00:00 2001
From: Olivier BICHLER <olivier.bichler@cea.fr>
Date: Thu, 16 May 2024 10:59:21 +0200
Subject: [PATCH] Added lambda test

---
 unit_tests/graph/Test_Matching.cpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/unit_tests/graph/Test_Matching.cpp b/unit_tests/graph/Test_Matching.cpp
index 6c5abcc47..d00b66537 100644
--- a/unit_tests/graph/Test_Matching.cpp
+++ b/unit_tests/graph/Test_Matching.cpp
@@ -205,4 +205,18 @@ TEST_CASE("[core/graph] Matching") {
             {"conv3_pad", {"conv3_conv", "conv3_pad", "relu3"}}
         });
     }
+
+    SECTION(".[test]->Pad") {
+        auto gm = GraphMatching(g1);
+        gm.addNodeLambda("test", [](const NodePtr& node) {
+            return (node->type() == "Add" || (node->type() == "ReLU" && node->name() == "relu1"));
+        });
+
+        const auto results = gm.match(".[test]->Pad");
+
+        checkMatches(results, {
+            {"add", {"add", "conv5_pad"}},
+            {"relu1", {"relu1", "conv2_pad"}}
+        });
+    }
 }
-- 
GitLab