Spread the minimum layer to compute the maximum layer of producers
| 544 | |
| 545 | // Spread the minimum layer to compute the maximum layer of producers |
| 546 | void SbpNode::SpreadMaxLayer( |
| 547 | const HashMap<std::string, SbpNode*>& op_name2sbp_node, |
| 548 | const HashMap<const OpNode*, HashSet<std::string>>& op_node2mutable_op_ctrl_deps) { |
| 549 | if (min_layer_ <= 0) { return; } |
| 550 | int32_t producer_max_lay = min_layer_ - 1; |
| 551 | for (SbpEdge* this_edge : edges_in_) { this_edge->start_node_->DropMaxLayer(producer_max_lay); } |
| 552 | for (const auto& ctrl_in_op_name : op_node_->op().op_conf().ctrl_in_op_name()) { |
| 553 | const auto& it = op_name2sbp_node.find(ctrl_in_op_name); |
| 554 | if (it != op_name2sbp_node.end()) { it->second->DropMaxLayer(producer_max_lay); } |
| 555 | } |
| 556 | if (op_node2mutable_op_ctrl_deps.find(op_node_) != op_node2mutable_op_ctrl_deps.end()) { |
| 557 | for (const auto& ctrl_in_op_name : op_node2mutable_op_ctrl_deps.at(op_node_)) { |
| 558 | const auto& it = op_name2sbp_node.find(ctrl_in_op_name); |
| 559 | if (it != op_name2sbp_node.end()) { it->second->DropMaxLayer(producer_max_lay); } |
| 560 | } |
| 561 | } |
| 562 | } |
| 563 | |
| 564 | // Drop down the maximum layer with the minimum layer form consumer |
| 565 | void SbpNode::DropMaxLayer(int32_t upper_bound) { |
no test coverage detected