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

Function CopyGraph

tensorflow/core/graph/graph_constructor.cc:1537–1560  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1535}
1536
1537void CopyGraph(const Graph& src, Graph* dest) {
1538 for (Node* n : dest->nodes()) {
1539 CHECK(n->IsSource() || n->IsSink()) << "*dest must be empty";
1540 }
1541
1542 // Copy GraphDef versions
1543 dest->set_versions(src.versions());
1544
1545 // Copy the nodes.
1546 // "Node in src" -> "Node in *dest"
1547 gtl::FlatMap<const Node*, Node*> node_map;
1548 node_map[src.source_node()] = dest->source_node();
1549 node_map[src.sink_node()] = dest->sink_node();
1550 for (Node* n : src.op_nodes()) {
1551 node_map[n] = dest->CopyNode(n);
1552 }
1553
1554 // Copy the edges
1555 for (const Edge* e : src.edges()) {
1556 Node* src_copy = node_map[e->src()];
1557 Node* dst_copy = node_map[e->dst()];
1558 dest->AddEdge(src_copy, e->src_output(), dst_copy, e->dst_input());
1559 }
1560}
1561
1562namespace {
1563Node* scalar_const_node(Graph* g, int64 val, const string& name,

Callers 15

SubgraphMethod · 0.70
BM_SubgraphHelperFunction · 0.70
TEST_FFunction · 0.70
RunMethod · 0.70
GetGraphMethod · 0.50
TEST_FFunction · 0.50
TESTFunction · 0.50
FunctionDefToGraphDefFunction · 0.50
RunMethod · 0.50
CreateGraphsMethod · 0.50

Calls 15

IsSourceMethod · 0.80
IsSinkMethod · 0.80
set_versionsMethod · 0.80
op_nodesMethod · 0.80
CopyNodeMethod · 0.80
edgesMethod · 0.80
nodesMethod · 0.45
versionsMethod · 0.45
source_nodeMethod · 0.45
sink_nodeMethod · 0.45
srcMethod · 0.45
dstMethod · 0.45

Tested by 8

SubgraphMethod · 0.56
BM_SubgraphHelperFunction · 0.56
TEST_FFunction · 0.56
TEST_FFunction · 0.40
TESTFunction · 0.40
GetFuncBodyMethod · 0.40
GetGradBodyMethod · 0.40
OptimizeFunction · 0.40