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

Function Partition

tensorflow/core/graph/graph_partition_test.cc:86–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86void Partition(const GraphDef& graph_def,
87 std::unordered_map<string, GraphDef>* partitions) {
88 Graph g(OpRegistry::Global());
89 GraphConstructorOptions opts;
90 TF_CHECK_OK(ConvertGraphDefToGraph(opts, graph_def, &g));
91
92 // Assigns devices to each node. Uses 1st letter of the node name as the
93 // device index if no device is specified.
94 for (Node* node : g.nodes()) {
95 string device_name = !node->requested_device().empty()
96 ? node->requested_device()
97 : DeviceName(node);
98 node->set_assigned_device_name(device_name);
99 }
100
101 PartitionOptions popts;
102 popts.node_to_loc = SplitByDevice;
103 popts.new_name = [&g](const string& prefix) { return g.NewName(prefix); };
104 popts.get_incarnation = [](const string& name) {
105 return (name[0] - 'A') + 100;
106 };
107 Status s = Partition(popts, &g, partitions);
108 CHECK(s.ok()) << s;
109
110 // Check versions.
111 EXPECT_EQ(graph_def.versions().producer(), TF_GRAPH_DEF_VERSION);
112 // Partitions must inherit the versions of the original graph.
113 for (auto& it : *partitions) {
114 EXPECT_EQ(graph_def.versions().producer(), it.second.versions().producer());
115 EXPECT_EQ(graph_def.versions().min_consumer(),
116 it.second.versions().min_consumer());
117 }
118}
119
120void CheckLoopConstruction(const GraphDef& graph_def) {
121 std::unordered_map<string, GraphDef> partitions;

Callers 2

CheckLoopConstructionFunction · 0.70
TEST_FFunction · 0.70

Calls 8

ConvertGraphDefToGraphFunction · 0.85
DeviceNameFunction · 0.70
nodesMethod · 0.45
emptyMethod · 0.45
NewNameMethod · 0.45
okMethod · 0.45
versionsMethod · 0.45

Tested by

no test coverage detected