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

Method VerifyFDefEdges

tensorflow/c/c_api_function_test.cc:299–351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297 }
298
299 void VerifyFDefEdges(
300 const tensorflow::FunctionDef& fdef,
301 const std::vector<EdgeSpec>& e_edges, // expected edges
302 const std::vector<EdgeSpec>& c_edges, // expected ctrl edges
303 bool is_exact_edges = true) {
304 // Build a set of edges from fdef
305 std::set<EdgeSpec> a_edges; // actual edges
306 // Get edges from inputs to body nodes and between body nodes
307 for (const NodeDef& node_def : fdef.node_def()) {
308 for (int i = 0; i < node_def.input_size(); ++i) {
309 const string& in = node_def.input(i);
310 const auto& v =
311 a_edges.insert({in, strings::StrCat(node_def.name(), ":", i)});
312 ASSERT_TRUE(v.second) << "Duplicate edge " << in << " -> "
313 << strings::StrCat(node_def.name(), ":", i)
314 << ". fdef: " << fdef.DebugString();
315 }
316 }
317 // Get edges from body nodes to outputs and from inputs to outputs
318 for (const OpDef::ArgDef& arg : fdef.signature().output_arg()) {
319 const auto& iter = fdef.ret().find(arg.name());
320 if (iter != fdef.ret().end()) {
321 const auto& v = a_edges.insert({iter->second, arg.name()});
322 ASSERT_TRUE(v.second) << "Duplicate edge " << iter->second << " -> "
323 << arg.name() << ". fdef: " << fdef.DebugString();
324 } else {
325 const auto& v = a_edges.insert({arg.name(), arg.name()});
326 ASSERT_TRUE(v.second) << "Duplicate edge " << arg.name() << " -> "
327 << arg.name() << ". fdef: " << fdef.DebugString();
328 }
329 }
330
331 // Verify edges
332 for (const EdgeSpec& e : e_edges) {
333 ASSERT_TRUE(a_edges.find(e) != a_edges.end())
334 << "Failed to find expected edge " << e.ToString()
335 << " in fdef: " << fdef.DebugString();
336 }
337 for (const EdgeSpec& e : c_edges) {
338 ASSERT_TRUE(a_edges.find(e) != a_edges.end())
339 << "Failed to find expected control edge " << e.ToString()
340 << " in fdef: " << fdef.DebugString();
341 }
342
343 // If caller specified all edges, check that we have seen all
344 if (is_exact_edges) {
345 ASSERT_EQ(e_edges.size() + c_edges.size(), a_edges.size())
346 << "Expected edges: " << ToString(e_edges)
347 << " Expected Control edges: " << ToString(c_edges)
348 << " Actual edges: " << ToString(a_edges)
349 << " in fdef: " << fdef.DebugString();
350 }
351 }
352
353 void VerifyFDef(const std::unordered_set<string>& nodes,
354 const std::vector<IOSpec>& inputs,

Callers

nothing calls this directly

Calls 13

signatureMethod · 0.80
nameMethod · 0.65
StrCatFunction · 0.50
ToStringFunction · 0.50
node_defMethod · 0.45
input_sizeMethod · 0.45
inputMethod · 0.45
insertMethod · 0.45
DebugStringMethod · 0.45
findMethod · 0.45
endMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected