From daf3e51b3151f207b0c0d679fc83002d2c1a7c60 Mon Sep 17 00:00:00 2001
From: cmoineau <cyril.moineau@cea.fr>
Date: Thu, 27 Mar 2025 13:45:44 +0000
Subject: [PATCH] Update Reshape::forwardDType().

---
 include/aidge/operator/Reshape.hpp | 1 +
 src/operator/Reshape.cpp           | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/aidge/operator/Reshape.hpp b/include/aidge/operator/Reshape.hpp
index f8bfaf73b..4d0e21e27 100644
--- a/include/aidge/operator/Reshape.hpp
+++ b/include/aidge/operator/Reshape.hpp
@@ -122,6 +122,7 @@ public:
 
     /**
      * @brief Forward the data type.
+     * Output datatype is the same as input 0.
      * @return True if successful, false otherwise.
      */
     bool forwardDType() override final;
diff --git a/src/operator/Reshape.cpp b/src/operator/Reshape.cpp
index b4cd272a1..3df66f293 100644
--- a/src/operator/Reshape.cpp
+++ b/src/operator/Reshape.cpp
@@ -60,7 +60,10 @@ bool Aidge::Reshape_Op::dimsForwarded() const {
     return OperatorTensor::dimsForwarded();
 }
 bool Aidge::Reshape_Op::forwardDType(){
-    if (inputsAssociated()) {
+    // Note: Override required because shape input is an optional data.
+    // Meaning default implementation will fail since:
+    // input[0] dtype != input[1] dtype.
+    if (inputsAssociated(false)) {
         mOutputs[0]->setDataType(getInput(0)->dataType());
         return true;
     }
-- 
GitLab