| 1677 | namespace { |
| 1678 | |
| 1679 | void GetReadyNodes(std::unordered_set<Node*>& done, |
| 1680 | const std::string& loc, |
| 1681 | std::unordered_set<Node*>* node_set, |
| 1682 | std::unordered_map<std::string, std::unordered_set<Node*> >* ready_nodes) { |
| 1683 | bool exit = false; |
| 1684 | while (!exit && node_set->size() > 0) { |
| 1685 | exit = true; |
| 1686 | for (auto n : *node_set) { |
| 1687 | if (!n->IsOp()) { |
| 1688 | LOG(FATAL) << "There should be no _Source or _Sink here."; |
| 1689 | } |
| 1690 | |
| 1691 | bool ready = true; |
| 1692 | for (const Edge* in_edge : n->in_edges()) { |
| 1693 | Node* src = in_edge->src(); |
| 1694 | if (!src->IsOp()) continue; |
| 1695 | // NOTE(jiankeng.pt): skip NextIteration to make topological sort successful. |
| 1696 | if (n->IsMerge() && src->IsNextIteration()) { |
| 1697 | continue; |
| 1698 | } |
| 1699 | if (done.find(src) != done.end()) continue; |
| 1700 | // (*ready_nodes)[loc].find(src) != (*ready_nodes)[loc].end() |
| 1701 | ready = false; |
| 1702 | break; |
| 1703 | } |
| 1704 | if (ready) { |
| 1705 | exit = false; |
| 1706 | (*ready_nodes)[loc].insert(n); |
| 1707 | } |
| 1708 | } |
| 1709 | |
| 1710 | for (auto n : (*ready_nodes)[loc]) { |
| 1711 | node_set->erase(n); |
| 1712 | } |
| 1713 | } |
| 1714 | } |
| 1715 | |
| 1716 | } // namespace |
| 1717 |
no test coverage detected