diff --git a/src/graph/GraphView.cpp b/src/graph/GraphView.cpp index 7b2de9bd601ade18850f5c47c968f3a9cfeb49b5..7576d708ae635275747535772e09f8eb15748311 100644 --- a/src/graph/GraphView.cpp +++ b/src/graph/GraphView.cpp @@ -381,12 +381,14 @@ Aidge::GraphView::outputs() const { // Keep only the nodes connected at this output position that are outside the GraphView std::vector<std::pair<std::shared_ptr<Node>, Aidge::IOIndex_t>> outsideOutputPos; for (const auto& output : outputPos) { - if (mNodes.find(output.first) == mNodes.end()) { + if (output.first == nullptr || mNodes.find(output.first) == mNodes.end()) { outsideOutputPos.push_back(output); } } - outsideOutputs.push_back(outsideOutputPos); + if (outputPos.empty() || !outsideOutputPos.empty()) { + outsideOutputs.push_back(outsideOutputPos); + } } } return outsideOutputs; diff --git a/src/operator/Memorize.cpp b/src/operator/Memorize.cpp index 714bf97fc538e157b11a81a9deba87b5f5ef4b96..733d4d1456eb57a989a3e6a9f6972906e7e0c38c 100644 --- a/src/operator/Memorize.cpp +++ b/src/operator/Memorize.cpp @@ -15,15 +15,17 @@ const std::string Aidge::Memorize_Op::Type = "Memorize"; void Aidge::Memorize_Op::computeOutputDims() { - // Only require input #1 dims (initialization of the Memorize operator) - // Otherwise, forwardDims() won't converge! - bool associated = (nbInputs() > 0); // do not compute anything if no input - if (!getInput(1)) { - AIDGE_THROW_OR_ABORT(std::runtime_error, "Input #1 should be associated with a Tensor"); + if (!getInput(0) || !getInput(1)) { + AIDGE_THROW_OR_ABORT(std::runtime_error, "Every input should be associated with a Tensor"); } - associated &= !(getInput(1)->empty()); - if (associated) { + // Only require one of the input to have dims defined + // Otherwise, forwardDims() won't converge! + if (!(getInput(0)->empty())) { + const auto expectedDims = getInput(0)->dims(); + mOutputs[0]->resize(expectedDims); + } + else if (!(getInput(1)->empty())) { const auto expectedDims = getInput(1)->dims(); mOutputs[0]->resize(expectedDims); }