| 797 | } |
| 798 | |
| 799 | TEST(TopologicalSortNodesWithTimePriorityTest, NoDependencies) { |
| 800 | // Create placeholders, shuffle them so the order in the graph is not strictly |
| 801 | // increasing. |
| 802 | Scope root = Scope::NewRootScope().ExitOnError(); |
| 803 | std::vector<int> indexes; |
| 804 | for (int i = 0; i < 20; ++i) { |
| 805 | indexes.push_back((i + 2001) % 20); |
| 806 | } |
| 807 | std::vector<ops::Placeholder> placeholders; |
| 808 | for (int i : indexes) { |
| 809 | placeholders.emplace_back(root.WithOpName(strings::StrCat("p", i)), |
| 810 | DT_FLOAT); |
| 811 | placeholders.back().node()->AddAttr("_start_time", i + 1); |
| 812 | } |
| 813 | |
| 814 | GraphDef gdef; |
| 815 | TF_EXPECT_OK(root.ToGraphDef(&gdef)); |
| 816 | |
| 817 | std::vector<std::pair<const NodeDef*, int64>> nodes; |
| 818 | std::unordered_map<const NodeDef*, int64> node_to_start_time; |
| 819 | TF_CHECK_OK( |
| 820 | TopologicalSortNodesWithTimePriority(&gdef, &nodes, &node_to_start_time)); |
| 821 | ASSERT_EQ(nodes.size(), 20); |
| 822 | for (int i = 0; i < nodes.size(); ++i) { |
| 823 | EXPECT_EQ(strings::StrCat("p", i), nodes[i].first->name()); |
| 824 | EXPECT_EQ(i + 1, nodes[i].second); |
| 825 | } |
| 826 | } |
| 827 | |
| 828 | TEST(TopologicalSortNodesWithTimePriority, Dependencies) { |
| 829 | // Create placeholders, shuffle them so the order in the graph is not strictly |
nothing calls this directly
no test coverage detected