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

Added missing references to loop variables

parent 748aedd0
No related branches found
No related tags found
No related merge requests found
...@@ -127,13 +127,13 @@ Aidge::IOIndex_t Aidge::GraphView::getNbFreeDataInputs() const { ...@@ -127,13 +127,13 @@ Aidge::IOIndex_t Aidge::GraphView::getNbFreeDataInputs() const {
std::vector<std::pair<std::shared_ptr<Aidge::Node>, Aidge::IOIndex_t>> std::vector<std::pair<std::shared_ptr<Aidge::Node>, Aidge::IOIndex_t>>
Aidge::GraphView::dataInputs() const { Aidge::GraphView::dataInputs() const {
IOIndex_t nbDataIn = 0U; IOIndex_t nbDataIn = 0U;
for (const std::shared_ptr<Node> inputNode : mInputNodes) { for (const std::shared_ptr<Node>& inputNode : mInputNodes) {
nbDataIn += inputNode->nbDataInputs(); nbDataIn += inputNode->nbDataInputs();
} }
std::vector<std::pair<std::shared_ptr<Node>, IOIndex_t>> res = std::vector<std::pair<std::shared_ptr<Node>, IOIndex_t>> res =
std::vector<std::pair<std::shared_ptr<Node>, IOIndex_t>>(nbDataIn); std::vector<std::pair<std::shared_ptr<Node>, IOIndex_t>>(nbDataIn);
nbDataIn = 0U; nbDataIn = 0U;
for (const std::shared_ptr<Node> inputNode : mInputNodes) { for (const std::shared_ptr<Node>& inputNode : mInputNodes) {
std::vector<std::pair<std::shared_ptr<Node>, IOIndex_t>> inputNodeinputs = std::vector<std::pair<std::shared_ptr<Node>, IOIndex_t>> inputNodeinputs =
inputNode->dataInputs(); inputNode->dataInputs();
std::move(inputNodeinputs.begin(), inputNodeinputs.end(), std::move(inputNodeinputs.begin(), inputNodeinputs.end(),
...@@ -149,13 +149,13 @@ Aidge::GraphView::dataInputs() const { ...@@ -149,13 +149,13 @@ Aidge::GraphView::dataInputs() const {
std::vector<std::pair<std::shared_ptr<Aidge::Node>, Aidge::IOIndex_t>> std::vector<std::pair<std::shared_ptr<Aidge::Node>, Aidge::IOIndex_t>>
Aidge::GraphView::inputs() const { Aidge::GraphView::inputs() const {
std::size_t nbIn = 0U; std::size_t nbIn = 0U;
for (const std::shared_ptr<Node> inputNode : mInputNodes) { for (const std::shared_ptr<Node>& inputNode : mInputNodes) {
nbIn += inputNode->nbInputs(); nbIn += inputNode->nbInputs();
} }
std::vector<std::pair<std::shared_ptr<Node>, IOIndex_t>> res = std::vector<std::pair<std::shared_ptr<Node>, IOIndex_t>> res =
std::vector<std::pair<std::shared_ptr<Node>, IOIndex_t>>(nbIn); std::vector<std::pair<std::shared_ptr<Node>, IOIndex_t>>(nbIn);
nbIn = 0U; nbIn = 0U;
for (const std::shared_ptr<Node> inputNode : mInputNodes) { for (const std::shared_ptr<Node>& inputNode : mInputNodes) {
std::vector<std::pair<std::shared_ptr<Node>, IOIndex_t>> inputNodeinputs = std::vector<std::pair<std::shared_ptr<Node>, IOIndex_t>> inputNodeinputs =
inputNode->inputs(); inputNode->inputs();
std::move(inputNodeinputs.begin(), inputNodeinputs.end(), std::move(inputNodeinputs.begin(), inputNodeinputs.end(),
...@@ -242,13 +242,13 @@ void Aidge::GraphView::setDatatype(const DataType &datatype) { ...@@ -242,13 +242,13 @@ void Aidge::GraphView::setDatatype(const DataType &datatype) {
void Aidge::GraphView::updateOutputNodes() { void Aidge::GraphView::updateOutputNodes() {
mOutputNodes.clear(); mOutputNodes.clear();
for (const std::shared_ptr<Node> go_it : mNodes) { for (const std::shared_ptr<Node>& go_it : mNodes) {
if (go_it->nbOutputs() != if (go_it->nbOutputs() !=
go_it->nbValidOutputs()) { // an output linked to nothing go_it->nbValidOutputs()) { // an output linked to nothing
mOutputNodes.insert(go_it); mOutputNodes.insert(go_it);
continue; continue;
} }
for (const std::shared_ptr<Node> ch_ptr : go_it->getChildren()) { for (const std::shared_ptr<Node>& ch_ptr : go_it->getChildren()) {
if (mNodes.find(ch_ptr) == mNodes.end()) { // Child not in the graph if (mNodes.find(ch_ptr) == mNodes.end()) { // Child not in the graph
mOutputNodes.insert(go_it); mOutputNodes.insert(go_it);
break; break;
...@@ -277,7 +277,7 @@ void Aidge::GraphView::updateOutputNodes(std::shared_ptr<Node> node) { ...@@ -277,7 +277,7 @@ void Aidge::GraphView::updateOutputNodes(std::shared_ptr<Node> node) {
mOutputNodes.end())) { // it's a match! Must check if the outputNode mOutputNodes.end())) { // it's a match! Must check if the outputNode
// found is still an outputNode // found is still an outputNode
bool remove = (pa_ptr->nbOutputs() == pa_ptr->nbValidOutputs()); bool remove = (pa_ptr->nbOutputs() == pa_ptr->nbValidOutputs());
for (const std::shared_ptr<Node> ch_ptr : pa_ptr->getChildren()) { for (const std::shared_ptr<Node>& ch_ptr : pa_ptr->getChildren()) {
if (mNodes.find(ch_ptr) == mNodes.end()) { // Child not in the graph if (mNodes.find(ch_ptr) == mNodes.end()) { // Child not in the graph
remove = false; remove = false;
break; break;
...@@ -295,7 +295,7 @@ std::vector< ...@@ -295,7 +295,7 @@ std::vector<
Aidge::GraphView::outputs() const { Aidge::GraphView::outputs() const {
std::vector<std::vector<std::pair<std::shared_ptr<Node>, Aidge::IOIndex_t>>> std::vector<std::vector<std::pair<std::shared_ptr<Node>, Aidge::IOIndex_t>>>
outputTensors; outputTensors;
for (const std::shared_ptr<Node> outputNode : mOutputNodes) { for (const std::shared_ptr<Node>& outputNode : mOutputNodes) {
std::vector<std::vector<std::pair<std::shared_ptr<Node>, Aidge::IOIndex_t>>> std::vector<std::vector<std::pair<std::shared_ptr<Node>, Aidge::IOIndex_t>>>
tmpOutputs = (outputNode->outputs()); tmpOutputs = (outputNode->outputs());
outputTensors.insert(outputTensors.end(), tmpOutputs.begin(), outputTensors.insert(outputTensors.end(), tmpOutputs.begin(),
...@@ -404,7 +404,7 @@ void Aidge::GraphView::addChild( ...@@ -404,7 +404,7 @@ void Aidge::GraphView::addChild(
std::set<std::shared_ptr<Aidge::Node>> Aidge::GraphView::getParents() const { std::set<std::shared_ptr<Aidge::Node>> Aidge::GraphView::getParents() const {
// TODO: choose if we return a set or a vector // TODO: choose if we return a set or a vector
std::set<std::shared_ptr<Node>> parents; std::set<std::shared_ptr<Node>> parents;
for (const std::shared_ptr<Node> inputNode : mInputNodes) { for (const std::shared_ptr<Node>& inputNode : mInputNodes) {
parents.insert(inputNode->getParents().begin(), parents.insert(inputNode->getParents().begin(),
inputNode->getParents().end()); inputNode->getParents().end());
} }
...@@ -423,7 +423,7 @@ std::vector<std::shared_ptr<Aidge::Node>> Aidge::GraphView::getParents(const std ...@@ -423,7 +423,7 @@ std::vector<std::shared_ptr<Aidge::Node>> Aidge::GraphView::getParents(const std
std::vector<std::vector<std::shared_ptr<Aidge::Node>>> std::vector<std::vector<std::shared_ptr<Aidge::Node>>>
Aidge::GraphView::getOrderedParents() const { Aidge::GraphView::getOrderedParents() const {
std::vector<std::vector<std::shared_ptr<Node>>> parents; std::vector<std::vector<std::shared_ptr<Node>>> parents;
for (const std::shared_ptr<Node> inputNode : mInputNodes) { for (const std::shared_ptr<Node>& inputNode : mInputNodes) {
parents.push_back(inputNode->getParents()); parents.push_back(inputNode->getParents());
} }
return parents; return parents;
...@@ -431,7 +431,7 @@ Aidge::GraphView::getOrderedParents() const { ...@@ -431,7 +431,7 @@ Aidge::GraphView::getOrderedParents() const {
std::set<std::shared_ptr<Aidge::Node>> Aidge::GraphView::getChildren() const { std::set<std::shared_ptr<Aidge::Node>> Aidge::GraphView::getChildren() const {
std::set<std::shared_ptr<Node>> children; std::set<std::shared_ptr<Node>> children;
for (const std::shared_ptr<Node> outputNode : mOutputNodes) { for (const std::shared_ptr<Node>& outputNode : mOutputNodes) {
children.insert((outputNode->getChildren()).begin(), children.insert((outputNode->getChildren()).begin(),
(outputNode->getChildren()).end()); (outputNode->getChildren()).end());
} }
...@@ -597,8 +597,8 @@ bool Aidge::GraphView::replaceWith(std::set<std::shared_ptr<Node>> newNodes) { ...@@ -597,8 +597,8 @@ bool Aidge::GraphView::replaceWith(std::set<std::shared_ptr<Node>> newNodes) {
void Aidge::GraphView::updateInputNodes() { void Aidge::GraphView::updateInputNodes() {
mInputNodes.clear(); mInputNodes.clear();
for (const std::shared_ptr<Node> go_ptr : mNodes) { for (const std::shared_ptr<Node>& go_ptr : mNodes) {
for (const std::shared_ptr<Node> pa_ptr : go_ptr->getParents()) { for (const std::shared_ptr<Node>& pa_ptr : go_ptr->getParents()) {
if ((pa_ptr == nullptr) || if ((pa_ptr == nullptr) ||
(mNodes.find(pa_ptr) == (mNodes.find(pa_ptr) ==
mNodes.end())) { // Parent doesn't exist || Parent not in the graph mNodes.end())) { // Parent doesn't exist || Parent not in the graph
...@@ -613,7 +613,7 @@ void Aidge::GraphView::updateInputNodes(std::shared_ptr<Node> node) { ...@@ -613,7 +613,7 @@ void Aidge::GraphView::updateInputNodes(std::shared_ptr<Node> node) {
// add node_ptr to inputNode if it can // add node_ptr to inputNode if it can
std::size_t filledWithKnownInputs = 0U; std::size_t filledWithKnownInputs = 0U;
bool wasAdded = mInputNodes.find(node) != mInputNodes.end(); bool wasAdded = mInputNodes.find(node) != mInputNodes.end();
for (const std::shared_ptr<Node> pa_ptr : node->getParents()) { for (const std::shared_ptr<Node>& pa_ptr : node->getParents()) {
if ((pa_ptr == nullptr) || if ((pa_ptr == nullptr) ||
(mNodes.find(pa_ptr) == (mNodes.find(pa_ptr) ==
mNodes.end())) { // Parent doesn't exist || Parent not in the graph mNodes.end())) { // Parent doesn't exist || Parent not in the graph
...@@ -627,14 +627,14 @@ void Aidge::GraphView::updateInputNodes(std::shared_ptr<Node> node) { ...@@ -627,14 +627,14 @@ void Aidge::GraphView::updateInputNodes(std::shared_ptr<Node> node) {
mInputNodes.erase(node); mInputNodes.erase(node);
} }
// update other inputNodes // update other inputNodes
for (const std::shared_ptr<Node> ch_ptr : for (const std::shared_ptr<Node>& ch_ptr :
node->getChildren()) { // check if any child is in InputNodes too node->getChildren()) { // check if any child is in InputNodes too
if (mInputNodes.find(ch_ptr) != if (mInputNodes.find(ch_ptr) !=
mInputNodes.end()) { // it's a match! Must check if the inputNode found mInputNodes.end()) { // it's a match! Must check if the inputNode found
// is still an inputNode // is still an inputNode
// change here // change here
bool remove = true; bool remove = true;
for (const std::shared_ptr<Node> pa_ptr : ch_ptr->getParents()) { for (const std::shared_ptr<Node>& pa_ptr : ch_ptr->getParents()) {
if (pa_ptr == nullptr || if (pa_ptr == nullptr ||
mNodes.find(pa_ptr) == mNodes.find(pa_ptr) ==
mNodes mNodes
......
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