| 262 | } |
| 263 | |
| 264 | void 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 | |
| 297 | void ComputeLayer(std::vector<TopoStruct*>* topo_structs) { |
| 298 | int32_t max_min_layer = -1; |
no test coverage detected