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

Function EqualNodeDef

tensorflow/core/util/equal_graph_def.cc:108–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106} // namespace
107
108bool EqualNodeDef(const NodeDef& actual, const NodeDef& expected, string* diff,
109 const EqualGraphDefOptions& options) {
110 if (actual.name() != expected.name()) {
111 if (diff != nullptr) {
112 *diff = strings::StrCat("Actual node name '", actual.name(),
113 "' is not expected '", expected.name(), "'");
114 }
115 return false;
116 }
117
118 if (actual.op() != expected.op()) {
119 if (diff != nullptr) {
120 *diff = strings::StrCat("Node named '", actual.name(), "' has op '",
121 actual.op(), "' that is not expected '",
122 expected.op(), "'");
123 }
124 return false;
125 }
126
127 if (actual.device() != expected.device()) {
128 if (diff != nullptr) {
129 *diff = strings::StrCat("Node named '", actual.name(), "' has device '",
130 actual.device(), "' that is not expected '",
131 expected.device(), "'");
132 }
133 return false;
134 }
135
136 if (actual.input_size() != expected.input_size()) {
137 if (diff != nullptr) {
138 *diff = strings::StrCat("Node named '", actual.name(), "' has inputs '",
139 JoinStringField(actual.input()),
140 "' that don't match expected '",
141 JoinStringField(expected.input()), "'");
142 }
143 return false;
144 }
145
146 int first_control_input = actual.input_size();
147 for (int i = 0; i < actual.input_size(); ++i) {
148 if (absl::StartsWith(actual.input(i), "^")) {
149 first_control_input = i;
150 break;
151 }
152 // Special case for inputs: "tensor" is equivalent to "tensor:0"
153 if (actual.input(i) != expected.input(i) &&
154 actual.input(i) != strings::StrCat(expected.input(i), ":0") &&
155 strings::StrCat(actual.input(i), ":0") != expected.input(i)) {
156 if (diff != nullptr) {
157 *diff = strings::StrCat("Node named '", actual.name(), "' has input ",
158 i, " '", actual.input(i),
159 "' that doesn't match expected '",
160 expected.input(i), "'");
161 }
162 return false;
163 }
164 }
165

Callers 2

EqualRepeatedNodeDefFunction · 0.85
TEST_FFunction · 0.85

Calls 15

JoinStringFieldFunction · 0.85
StartsWithFunction · 0.85
SummarizeAttrValueFunction · 0.85
AreAttrValuesEqualFunction · 0.85
attrMethod · 0.80
nameMethod · 0.65
StrCatFunction · 0.50
opMethod · 0.45
deviceMethod · 0.45
input_sizeMethod · 0.45
inputMethod · 0.45
insertMethod · 0.45

Tested by 1

TEST_FFunction · 0.68