Print the graph with SBP in order
| 498 | |
| 499 | // Print the graph with SBP in order |
| 500 | void SbpConstructor::PrintSBPGraphDebugInfo() { |
| 501 | // sbp constructor information |
| 502 | std::cout << "cost_ratio_:" << cost_ratio_ << std::endl; |
| 503 | std::cout << "wait_time_:" << sbp_graph_.wait_time_ << std::endl; |
| 504 | std::cout << "use_sbp_collector_" << use_sbp_collector_ << std::endl; |
| 505 | std::cout << "Total auto parallel guessed memory: " << sbp_graph_.GetMemory() << std::endl; |
| 506 | std::cout << "Final memory ratio: " << kMemoryRatio << std::endl; |
| 507 | // test debug |
| 508 | std::cout << "Get Into Print Op Graph" << std::endl; |
| 509 | // Collect op_node |
| 510 | std::vector<OpNode*> node_list; |
| 511 | for (const auto& op_name_sbp_node : op_name2sbp_node_) { |
| 512 | auto* op_node_ = op_name_sbp_node.second->op_node_; |
| 513 | if (op_node_) { node_list.push_back(op_node_); } |
| 514 | } |
| 515 | |
| 516 | // test debug |
| 517 | std::cout << "Deciding order" << std::endl; |
| 518 | // Decide the order to visit the op |
| 519 | std::vector<int32_t> order; |
| 520 | auto_parallel::DecideOrder(node_list, order, [&](OpNode* a, OpNode* b) { |
| 521 | return a->op().op_name().compare(b->op().op_name()) > 0; |
| 522 | }); |
| 523 | std::vector<int32_t> str_order; |
| 524 | |
| 525 | // test debug |
| 526 | std::cout << "Finish deciding order" << std::endl; |
| 527 | |
| 528 | for (int32_t i = 0; i < node_list.size(); i++) { |
| 529 | OpNode* op_node = node_list[order[i]]; |
| 530 | std::cout << op_node->op().op_name() << " (^_^):" << std::endl; |
| 531 | // get corresponding sbp node |
| 532 | const auto& it = op_name2sbp_node_.find(op_node->op().op_name()); |
| 533 | // Print debug information for sbp graph |
| 534 | CHECK(it != op_name2sbp_node_.end()); |
| 535 | const SbpNode* sbp_node = it->second; |
| 536 | std::cout << "Computation Cost: " << sbp_node->weighted_cost_[sbp_node->final_sbp_sig_id_]; |
| 537 | std::cout << ", Min Layer: " << sbp_node->min_layer_ << ", Max Layer: " << sbp_node->max_layer_ |
| 538 | << ", Tributary Layer: " << sbp_node->tributary_layer_ |
| 539 | << ", in trunk: " << sbp_node->on_trunk_ |
| 540 | << ", Remain Cost: " << sbp_node->acc_trunk_cost_ << std::endl; |
| 541 | // Sort before printing |
| 542 | const auto& op_input_bns = op_node->op().input_bns(); |
| 543 | auto CompareString = [](const std::string& a, const std::string& b) { |
| 544 | return a.compare(b) > 0; |
| 545 | }; |
| 546 | auto_parallel::DecideOrder(op_input_bns, str_order, CompareString); |
| 547 | const NdSbpSignature& sbp_signature = sbp_node->FinalSbpSignature(); |
| 548 | // Print out SBP information for input operator |
| 549 | for (int32_t j : str_order) { |
| 550 | const auto& ibn = op_input_bns[j]; |
| 551 | const auto& producer_node = op_node->SrcNode4Ibn(ibn); |
| 552 | std::cout << "Pre Op:" << producer_node.op().op_name() << ": " << ibn; |
| 553 | const auto& this_sbp_parallel = sbp_signature.bn_in_op2nd_sbp().at(ibn); |
| 554 | std::cout << ", " << NdSbpToString(this_sbp_parallel); |
| 555 | if (RequireSameSbp(op_node, ibn)) { std::cout << ", require same SBP"; } |
| 556 | std::cout << ", " << op_node->LogicalBlobDesc4Lbi(op_node->op().BnInOp2Lbi(ibn)).shape(); |
| 557 | std::cout << std::endl; |
nothing calls this directly
no test coverage detected