diff --git a/src/operator/Shape.cpp b/src/operator/Shape.cpp index 6de0854e8cdc166a3f938a166348db481956e792..ecaa12191173ac74ace8d6d224ddfe08469eb521 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; }