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

Function EqualRepeatedNodeDef

tensorflow/core/util/equal_graph_def.cc:43–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43bool EqualRepeatedNodeDef(const protobuf::RepeatedPtrField<NodeDef>& actual,
44 const protobuf::RepeatedPtrField<NodeDef>& expected,
45 string* diff, const EqualGraphDefOptions& options) {
46 std::unordered_map<string, const NodeDef*> actual_index;
47 for (const NodeDef& node : actual) {
48 actual_index[node.name()] = &node;
49 }
50
51 for (const NodeDef& expected_node : expected) {
52 auto actual_iter = actual_index.find(expected_node.name());
53 if (actual_iter == actual_index.end()) {
54 if (diff != nullptr) {
55 *diff = strings::StrCat("Did not find expected node '",
56 SummarizeNodeDef(expected_node), "'");
57 }
58 return false;
59 }
60
61 if (!EqualNodeDef(*actual_iter->second, expected_node, diff, options)) {
62 return false;
63 }
64
65 actual_index.erase(actual_iter);
66 }
67
68 if (!actual_index.empty()) {
69 if (diff != nullptr) {
70 *diff =
71 strings::StrCat("Found unexpected node '",
72 SummarizeNodeDef(*actual_index.begin()->second), "'");
73 }
74 return false;
75 }
76
77 return true;
78}
79
80uint64 RepeatedNodeDefHash(const protobuf::RepeatedPtrField<NodeDef>& ndefs,
81 const EqualGraphDefOptions& options) {

Callers 2

FunctionDefsEqualFunction · 0.85
EqualGraphDefFunction · 0.85

Calls 9

SummarizeNodeDefFunction · 0.85
EqualNodeDefFunction · 0.85
nameMethod · 0.65
StrCatFunction · 0.50
findMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected