| 69 | } |
| 70 | |
| 71 | std::vector<Node *> input_nodes(const Graph *g) |
| 72 | { |
| 73 | std::map<GraphInputIndex, loco::Node *> table; |
| 74 | |
| 75 | for (uint32_t n = 0; n < g->nodes()->size(); ++n) |
| 76 | { |
| 77 | auto node = g->nodes()->at(n); |
| 78 | |
| 79 | if (auto service = node->dialect()->service<GraphInputIndexQueryService>()) |
| 80 | { |
| 81 | if (service->associated(node)) |
| 82 | { |
| 83 | auto input_index = service->index(node); |
| 84 | assert(table.find(input_index) == table.end()); |
| 85 | table[input_index] = node; |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | std::vector<loco::Node *> res; |
| 91 | |
| 92 | for (uint32_t n = 0; n < g->inputs()->size(); ++n) |
| 93 | { |
| 94 | auto it = table.find(n); |
| 95 | res.emplace_back(it == table.end() ? nullptr : it->second); |
| 96 | } |
| 97 | |
| 98 | return res; |
| 99 | } |
| 100 | |
| 101 | std::vector<loco::Node *> output_nodes(loco::Graph *g) |
| 102 | { |