MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / InitInOutTopoStructs

Function InitInOutTopoStructs

oneflow/core/auto_parallel/auto_memory.cpp:264–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262}
263
264void InitInOutTopoStructs(std::vector<TopoStruct*>* topo_structs) {
265 // Generate the map from operator names to topological structure
266 HashMap<std::string, TopoStruct*> op_name2topo_structs;
267 for (auto& topo_struct : *topo_structs) {
268 op_name2topo_structs[topo_struct->op_node->op().op_name()] = topo_struct;
269 }
270
271 // Traverse the topological structures
272 for (auto& this_topo_struct : *topo_structs) {
273 auto& node = this_topo_struct->op_node;
274 // Initialize input nodes for edges with data
275 node->ForEachNodeOnInEdge([&](OpNode* in) {
276 // Since we might be looking at a sub-graph of the operator graph.
277 // We need to check if the op_node exists in the sub-graph.
278 auto it = op_name2topo_structs.find(in->op().op_name());
279 if (it != op_name2topo_structs.end()) {
280 this_topo_struct->in_topo_structs.insert(it->second);
281 it->second->out_topo_structs.insert(this_topo_struct);
282 }
283 });
284 // Initialize input nodes for control edges
285 for (const auto& ctrl_in_op_name : node->op().op_conf().ctrl_in_op_name()) {
286 auto it = op_name2topo_structs.find(ctrl_in_op_name);
287 if (it != op_name2topo_structs.end()) {
288 auto& ctrl_in_topo_struct = it->second;
289 this_topo_struct->in_topo_structs.insert(ctrl_in_topo_struct);
290 // Initialize output nodes for this control edge simultaneously
291 ctrl_in_topo_struct->out_topo_structs.insert(this_topo_struct);
292 }
293 }
294 }
295}
296
297void ComputeLayer(std::vector<TopoStruct*>* topo_structs) {
298 int32_t max_min_layer = -1;

Callers 1

InitAllParametersFunction · 0.85

Calls 5

ForEachNodeOnInEdgeMethod · 0.80
findMethod · 0.80
insertMethod · 0.80
opMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected