MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ExpectBefore

Function ExpectBefore

tensorflow/core/graph/algorithm_test.cc:50–78  ·  view source on GitHub ↗

Compares that the order of nodes in 'inputs' respects the pair orders described in 'ordered_pairs'.

Source from the content-addressed store, hash-verified

48// Compares that the order of nodes in 'inputs' respects the
49// pair orders described in 'ordered_pairs'.
50bool ExpectBefore(const std::vector<std::pair<string, string>>& ordered_pairs,
51 const std::vector<Node*>& inputs, string* error) {
52 for (const std::pair<string, string>& pair : ordered_pairs) {
53 const string& before_node = pair.first;
54 const string& after_node = pair.second;
55 bool seen_before = false;
56 bool seen_both = false;
57 for (const Node* node : inputs) {
58 if (!seen_before && after_node == node->name()) {
59 *error = strings::StrCat("Saw ", after_node, " before ", before_node);
60 return false;
61 }
62
63 if (before_node == node->name()) {
64 seen_before = true;
65 } else if (after_node == node->name()) {
66 seen_both = seen_before;
67 break;
68 }
69 }
70 if (!seen_both) {
71 *error = strings::StrCat("didn't see either ", before_node, " or ",
72 after_node);
73 return false;
74 }
75 }
76
77 return true;
78}
79
80TEST(AlgorithmTest, ReversePostOrder) {
81 GraphDefBuilder b(GraphDefBuilder::kFailImmediately);

Callers 1

TESTFunction · 0.85

Calls 2

nameMethod · 0.65
StrCatFunction · 0.50

Tested by

no test coverage detected