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

Method SpreadMaxLayer

oneflow/core/auto_parallel/sbp_node.cpp:546–562  ·  view source on GitHub ↗

Spread the minimum layer to compute the maximum layer of producers

Source from the content-addressed store, hash-verified

544
545// Spread the minimum layer to compute the maximum layer of producers
546void 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
565void SbpNode::DropMaxLayer(int32_t upper_bound) {

Callers 1

ComputeLayerMethod · 0.80

Calls 5

DropMaxLayerMethod · 0.80
findMethod · 0.80
opMethod · 0.45
endMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected