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

Function Compare

tensorflow/core/grappler/optimizers/data/graph_utils.cc:201–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199}
200
201bool Compare(const GraphDef& g1, const GraphDef& g2) {
202 if (g1.node_size() != g2.node_size()) {
203 return false;
204 }
205 std::vector<int> name_index1 = CreateNameIndex(g1);
206 std::vector<int> name_index2 = CreateNameIndex(g2);
207 for (int i = 0; i < g1.node_size(); ++i) {
208 int idx1 = name_index1[i];
209 int idx2 = name_index2[i];
210 if (g1.node(idx1).op() != g2.node(idx2).op()) {
211 return false;
212 }
213 if (g1.node(idx1).name() != g2.node(idx2).name()) {
214 return false;
215 }
216 if (g1.node(idx1).input_size() != g2.node(idx2).input_size()) {
217 return false;
218 }
219 std::vector<int> input_index1 = CreateInputIndex(g1.node(idx1));
220 std::vector<int> input_index2 = CreateInputIndex(g2.node(idx2));
221 for (int j = 0; j < g1.node(idx1).input_size(); ++j) {
222 if (!IsSameInput(g1.node(idx1).input(input_index1[j]),
223 g2.node(idx2).input(input_index2[j]))) {
224 return false;
225 }
226 }
227 }
228 return true;
229}
230
231bool ContainsGraphFunctionWithName(StringPiece name,
232 const FunctionDefLibrary& library) {

Callers 5

TESTFunction · 0.70
TESTFunction · 0.70
TESTFunction · 0.70
SeekMethod · 0.50
TEST_FFunction · 0.50

Calls 8

CreateNameIndexFunction · 0.85
CreateInputIndexFunction · 0.85
IsSameInputFunction · 0.85
nameMethod · 0.65
opMethod · 0.45
nodeMethod · 0.45
input_sizeMethod · 0.45
inputMethod · 0.45

Tested by 4

TESTFunction · 0.56
TESTFunction · 0.56
TESTFunction · 0.56
TEST_FFunction · 0.40