From 3d9f77790d7b4f3929015b5832932808fa9f0ae9 Mon Sep 17 00:00:00 2001 From: Olivier BICHLER <olivier.bichler@cea.fr> Date: Fri, 29 Nov 2024 14:13:12 +0100 Subject: [PATCH] Make Shape working with forwardDims() --- src/operator/Shape.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/operator/Shape.cpp b/src/operator/Shape.cpp index 6de0854e8..ecaa12191 100644 --- a/src/operator/Shape.cpp +++ b/src/operator/Shape.cpp @@ -20,14 +20,8 @@ #include "aidge/utils/Types.h" void Aidge::Shape_OpImpl::forward() { - const Shape_Op& op = dynamic_cast<const Shape_Op&>(mOp); - const auto start = op.start(); - const auto end = op.end(); - - op.getOutput(0)->getImpl()->copyCast(std::next(op.getInput(0)->dims().data(), - start), - DataType::UInt64, - end - start + 1); + // Do nothing... + // Output is already valid after forwardDims() } /////////////////////////////////////////////// @@ -75,6 +69,11 @@ bool Aidge::Shape_Op::forwardDims(bool /*allowDataDependency*/) { AIDGE_ASSERT(roi> 1, "Invalid ROI for Shape"); mOutputs[0]->resize({roi}); + // Ensure the output of this operator is valid after forwardDims(): + mOutputs[0]->getImpl()->copyCast(std::next(getInput(0)->dims().data(), + start), + DataType::UInt64, + end - start + 1); return true; } -- GitLab