From 84fac59710ae9d8b1c0dba6b3edd9b786e6a9a76 Mon Sep 17 00:00:00 2001 From: Olivier BICHLER <olivier.bichler@cea.fr> Date: Wed, 29 Jan 2025 18:39:10 +0100 Subject: [PATCH] Fix ConstantFolding bug --- src/recipes/ConstantFolding.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/recipes/ConstantFolding.cpp b/src/recipes/ConstantFolding.cpp index 40b0bda76..613393756 100644 --- a/src/recipes/ConstantFolding.cpp +++ b/src/recipes/ConstantFolding.cpp @@ -36,6 +36,7 @@ void Aidge::constantFolding(std::shared_ptr<GraphView> graph) { for (const auto& node : candidates) { bool foldable = true; auto replaceGraph = std::make_shared<GraphView>(); + size_t i = 0; for (const auto& input : node->inputs()) { if (input.first) { if (input.first->type() != Producer_Op::Type) { @@ -53,6 +54,13 @@ void Aidge::constantFolding(std::shared_ptr<GraphView> graph) { replaceGraph->add(input.first, false); } + else if (node->inputCategory(i) != InputCategory::OptionalData + && node->inputCategory(i) != InputCategory::OptionalParam) + { + foldable = false; + break; + } + ++i; } if (foldable) { -- GitLab