From f4e3787dd6c87e4faeea34043c605f8d6b96a7d2 Mon Sep 17 00:00:00 2001 From: cmoineau <cyril.moineau@cea.fr> Date: Wed, 22 Nov 2023 12:32:42 +0000 Subject: [PATCH] [FIX] MetaOperator output was badly linked to its children. --- include/aidge/operator/MetaOperator.hpp | 6 ------ src/operator/MetaOperator.cpp | 15 +++++++++------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/include/aidge/operator/MetaOperator.hpp b/include/aidge/operator/MetaOperator.hpp index 72058dfcb..baa7a486c 100644 --- a/include/aidge/operator/MetaOperator.hpp +++ b/include/aidge/operator/MetaOperator.hpp @@ -78,12 +78,6 @@ public: void computeOutputDims() override final { // Forward dims of micro-graph mGraph->forwardDims(); - - // Associate outputs to micro-graph outputs for custom implementation - for (size_t outputIdx = 0; outputIdx < mOutputOps.size(); ++outputIdx) { - const auto& outputOp = mOutputOps[outputIdx]; - mOutputs[outputIdx] = outputOp.first->getOutput(outputOp.second); - } } bool outputDimsForwarded() const override final { return !(mOutputs[0]->empty()); } diff --git a/src/operator/MetaOperator.cpp b/src/operator/MetaOperator.cpp index c1f58c686..23a98152a 100644 --- a/src/operator/MetaOperator.cpp +++ b/src/operator/MetaOperator.cpp @@ -22,10 +22,6 @@ Aidge::MetaOperator_Op::MetaOperator_Op(const char *type, const std::shared_ptr< for (std::size_t i = 0; i < mInputs.size(); ++i) { mInputs[i] = std::make_shared<Tensor>(); } - mOutputs = std::vector<std::shared_ptr<Tensor>>(mGraph->outputs().size()); - for (std::size_t i = 0; i < mOutputs.size(); ++i) { - mOutputs[i] = std::make_shared<Tensor>(); - } // Fill inputsNodes and outputsNodes when there is no ambiguity if (inputNodes.empty()) { @@ -46,7 +42,7 @@ Aidge::MetaOperator_Op::MetaOperator_Op(const char *type, const std::shared_ptr< AIDGE_ASSERT(mGraph->inView(inputNode), "input node must be in the graph"); const std::vector<std::pair<std::shared_ptr<Node>, IOIndex_t>> inputNodeinputs = inputNode->inputs(); - + int inputIdx = 0; // input idx relative to the current node for (const auto& in : inputNodeinputs) { if (in.first == nullptr || !mGraph->inView(in.first)) { @@ -71,8 +67,15 @@ Aidge::MetaOperator_Op::MetaOperator_Op(const char *type, const std::shared_ptr< } } + AIDGE_INTERNAL_ASSERT(mInputOps.size() == mGraph->inputs().size()); AIDGE_INTERNAL_ASSERT(mOutputOps.size() == mGraph->outputs().size()); + mOutputs = std::vector<std::shared_ptr<Tensor>>(mGraph->outputs().size()); + // Associate outputs to micro-graph outputs for custom implementation + for (size_t outputIdx = 0; outputIdx < mOutputOps.size(); ++outputIdx) { + const auto& outputOp = mOutputOps[outputIdx]; + mOutputs[outputIdx] = outputOp.first->getOutput(outputOp.second); + } } Aidge::NbElts_t Aidge::MetaOperator_Op::getNbRequiredData(const IOIndex_t inputIdx) const { @@ -114,7 +117,7 @@ void Aidge::MetaOperator_Op::updateConsummerProducer() { // Lazy initialization mScheduler = std::make_shared<SequentialScheduler>(mGraph); } - + // TODO: check that generateScheduling() can be called multiple time to iteratively update the schedule. // It could be a good idea to unify updateConsummerProducer() and generateScheduling() into a "updateScheduling()" mScheduler->generateScheduling(); -- GitLab