diff --git a/src/recipes/ConstantFolding.cpp b/src/recipes/ConstantFolding.cpp index 40b0bda766ab243805349b13e93391c5a60df63a..613393756f7f6b7104118ea97593e3130055ceeb 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) {