Skip to content
Snippets Groups Projects
Commit d6ed3a82 authored by Olivier BICHLER's avatar Olivier BICHLER
Browse files

Improved error messages

parent 57dd2c6c
No related branches found
No related tags found
2 merge requests!105version 0.2.0,!77Support for recurrent networks
Pipeline #40503 passed
......@@ -187,8 +187,12 @@ void Aidge::Node::setInputId(const IOIndex_t inId, const IOIndex_t newNodeoutId)
void Aidge::Node::addChildOp(std::shared_ptr<Node> otherNode, const IOIndex_t outId,
const IOIndex_t otherInId) {
assert((otherInId < otherNode->nbInputs()) && "Input index out of bound.");
assert((outId < nbOutputs()) && "Output index out of bound.");
AIDGE_ASSERT(otherInId < otherNode->nbInputs(),
"Input index (#{}) of the node {} (of type {}) is out of bound (it has {} inputs), when trying to add it as a child of node {} (of type {})",
otherInId, otherNode->name(), otherNode->type(), otherNode->nbInputs(), name(), type());
AIDGE_ASSERT(outId < nbOutputs(),
"Output index (#{}) of the node {} (of type {}) is out of bound (it has {} outputs), when trying to add the child node {} (of type {})",
outId, name(), type(), nbOutputs(), otherNode->name(), otherNode->type());
if (otherNode->input(otherInId).second != gk_IODefaultIndex) {
fmt::print("Warning, the {}-th Parent of the child node already existed.\n", otherInId);
}
......@@ -203,18 +207,11 @@ void Aidge::Node::addChildOp(std::shared_ptr<Node> otherNode, const IOIndex_t ou
void Aidge::Node::addChildView(std::shared_ptr<GraphView> otherGraph, const IOIndex_t outId,
std::pair<std::shared_ptr<Node>, IOIndex_t> otherInId) {
assert((otherInId.second < otherInId.first->nbInputs()) &&
"Other graph input index out of bound.");
assert((outId < nbOutputs()) && "Output index out of bound.");
std::set<std::shared_ptr<Node>> inNodes = otherGraph->inputNodes();
if (inNodes.size() == std::size_t(0)) { // no input Node
fmt::print("Cannot add GraphView to the Node. No input node detected.\n");
} else // inNodes.size() >= 1
{
assert((inNodes.find(otherInId.first) !=
inNodes.end())); // assert it really is an input node
addChildOp(otherInId.first, outId, otherInId.second);
}
const auto inNodes = otherGraph->inputNodes();
AIDGE_ASSERT(otherInId.first != nullptr && inNodes.find(otherInId.first) != inNodes.end(),
"Node {} (of type {}) is not a valid input node of GraphView {}, when trying to add it as a child of node {} (of type {})",
(otherInId.first) ? otherInId.first->name() : "#nullptr", (otherInId.first) ? otherInId.first->type() : "", otherGraph->name(), name(), type());
addChildOp(otherInId.first, outId, otherInId.second);
}
void Aidge::Node::addChild(std::shared_ptr<Node> otherNode, const IOIndex_t outId,
......@@ -229,9 +226,9 @@ void Aidge::Node::addChild(std::shared_ptr<Node> otherNode, const IOIndex_t outI
void Aidge::Node::addChild(std::shared_ptr<GraphView> otherView, const IOIndex_t outId,
std::pair<std::shared_ptr<Node>, IOIndex_t> otherInId) {
if (!otherInId.first) {
assert((otherView->inputNodes().size() == 1U) &&
"Specify an input Node for the GraphView. More or less than one "
"Node is not explicit.");
AIDGE_ASSERT(otherView->inputNodes().size() == 1U,
"Input node of GraphView {} need to be specified, because it has more than one input ({} inputs), when trying to add it as a child of node {} (of type {})",
otherView->name(), otherView->inputNodes().size(), name(), type());
otherInId.first = *(otherView->inputNodes().begin());
}
otherInId.second = (otherInId.second != gk_IODefaultIndex)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment