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

Method PrintSBPGraphDebugInfo

oneflow/core/graph/op_graph.cpp:598–651  ·  view source on GitHub ↗

Print the graph with SBP in order

Source from the content-addressed store, hash-verified

596
597// Print the graph with SBP in order
598void OpGraph::PrintSBPGraphDebugInfo() const {
599 // test debug
600 std::cout << "Get Into Print Op Graph" << std::endl;
601 // Collect op_node
602 std::vector<OpNode*> NodeList;
603 ForEachNode([&](OpNode* op_node) { NodeList.push_back(op_node); });
604
605 // test debug
606 std::cout << "Deciding order" << std::endl;
607 // Decide the order to vist the op
608 std::vector<int32_t> order;
609 auto_parallel::DecideOrder(NodeList, order, [&](OpNode* a, OpNode* b) {
610 return a->op().op_name().compare(b->op().op_name()) > 0;
611 });
612 std::vector<int32_t> str_order;
613
614 // test debug
615 std::cout << "Finish deciding order" << std::endl;
616
617 for (int32_t i = 0; i < NodeList.size(); i++) {
618 OpNode* op_node = NodeList[order[i]];
619 std::cout << op_node->op().op_name() << " (^_^):" << std::endl;
620 // Sort before printing
621 const auto& op_input_bns = op_node->op().input_bns();
622 auto comp = [](const std::string& a, const std::string& b) { return a.compare(b) > 0; };
623 auto_parallel::DecideOrder(op_input_bns, str_order, comp);
624 // Print out SBP information for input operator
625 for (int32_t j : str_order) {
626 const auto& ibn = op_input_bns[j];
627 auto producer_node = op_node->MutSrcNode4Ibn(ibn);
628 std::cout << "Pre Op:" << producer_node->op().op_name() << ": " << ibn;
629 const auto& this_sbp_parallel = op_node->NdSbp4BnInOp(ibn);
630 std::cout << ", " << NdSbpToString(this_sbp_parallel);
631 const auto input_blob_modifier_ = op_node->op().InputBlobModifier4Ibn(ibn);
632 bool is_same_sbp = input_blob_modifier_.has_is_mutable() && input_blob_modifier_.is_mutable();
633 if (is_same_sbp) std::cout << ", same SBP";
634 std::cout << ", " << op_node->LogicalBlobDesc4Lbi(op_node->op().BnInOp2Lbi(ibn)).shape();
635 std::cout << std::endl;
636 }
637 // Sort before printing
638 const auto& op_output_bns = op_node->op().output_bns();
639 auto_parallel::DecideOrder(op_output_bns, str_order, comp);
640 // Print out SBP information for output blobs
641 for (int32_t j : str_order) {
642 const auto& obn = op_output_bns[j];
643 std::cout << "Out Op:" << obn;
644 const auto& this_sbp_parallel = op_node->NdSbp4BnInOp(obn);
645 std::cout << ", " << NdSbpToString(this_sbp_parallel);
646 std::cout << ", " << op_node->LogicalBlobDesc4Lbi(op_node->op().BnInOp2Lbi(obn)).shape();
647 std::cout << std::endl;
648 }
649 std::cout << std::endl;
650 }
651}
652
653OpGraphSingletonGuard::OpGraphSingletonGuard(const Job& job) {
654 // new Singleton<OpGraph> and set log configs.

Callers

nothing calls this directly

Calls 8

DecideOrderFunction · 0.85
NdSbpToStringFunction · 0.85
push_backMethod · 0.80
MutSrcNode4IbnMethod · 0.80
NdSbp4BnInOpMethod · 0.80
opMethod · 0.45
sizeMethod · 0.45
shapeMethod · 0.45

Tested by

no test coverage detected