diff --git a/build.bat b/build.bat index 1405ccd75cde4fd0c2274d2ca8d3823ac533af53..f810924462b4acbcae7137d70f8742e1605b9bbc 100644 --- a/build.bat +++ b/build.bat @@ -34,6 +34,9 @@ set ENABLE_FFMPEG=ON set ENABLE_FFMPEG_DOWNLOAD=OFF for /f "tokens=1" %%a in (version.txt) do (set VERSION_STR=%%a) git submodule update --init --remote mindspore +cd "%BASEPATH%\mindspore" && ( + git apply "%BASEPATH%\third_party\patch\mindspore\debug_string.patch" +) ECHO %2%|FINDSTR "^[0-9][0-9]*$" IF %errorlevel% == 0 ( SET threads=%2% diff --git a/build.sh b/build.sh index 80bbf0f1f7559a30616e853daaebc6ff34f491a5..c5048178dc17f75cad98d30df20879c98e527a1d 100755 --- a/build.sh +++ b/build.sh @@ -49,6 +49,7 @@ build_exit() } update_submodule +cd ${BASEPATH}/mindspore && git apply ${BASEPATH}/third_party/patch/mindspore/debug_string.patch && cd - echo "---------------- MindSpore-Lite: build start ----------------" init_default_options process_options "$@" diff --git a/third_party/patch/mindspore/debug_string.patch b/third_party/patch/mindspore/debug_string.patch new file mode 100644 index 0000000000000000000000000000000000000000..8d7d30698482a1f8ba8063acfbe518f48714a5cd --- /dev/null +++ b/third_party/patch/mindspore/debug_string.patch @@ -0,0 +1,2121 @@ +diff --git a/mindspore/ccsrc/backend/common/pass/insert_type_transform_op.cc b/mindspore/ccsrc/backend/common/pass/insert_type_transform_op.cc +index ac96172276d..178d7d1a63a 100644 +--- a/mindspore/ccsrc/backend/common/pass/insert_type_transform_op.cc ++++ b/mindspore/ccsrc/backend/common/pass/insert_type_transform_op.cc +@@ -1,5 +1,5 @@ + /** +- * Copyright 2022 Huawei Technologies Co., Ltd ++ * Copyright 2022-2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. +@@ -761,12 +761,12 @@ AnfNodePtrList InsertTypeTransformOp::ProcessTupleToTupleUnfoldForSkipOp(const F + auto new_get_item_inputs = + ProcessTupleToTupleUnfoldForTupleGetItem(func_graph, input, get_item, &new_get_item_prim); + constexpr size_t kIndex2 = 2; +- constexpr int kRecLevel = 2; + new_get_item_inputs.emplace_back(get_item->input(kIndex2)); + auto new_get_item = CreateNewNode(func_graph, new_get_item_inputs, get_item); + MS_LOG(DEBUG) << "Create new node " << new_get_item->fullname_with_scope() << " " +- << new_get_item->DebugString(kRecLevel) << " to replace " << get_item->fullname_with_scope() +- << " " << get_item->DebugString(kRecLevel) ++ << new_get_item->DebugString(AnfNode::DebugStringLevel::kLevel2) << " to replace " ++ << get_item->fullname_with_scope() << " " ++ << get_item->DebugString(AnfNode::DebugStringLevel::kLevel2) + << " build info:" << AnfAlgo::GetSelectKernelBuildInfo(new_get_item)->ToString(); + new_inputs.emplace_back(new_get_item); + } +diff --git a/mindspore/ccsrc/backend/ge_backend/runtime/actor/actor_dump.cc b/mindspore/ccsrc/backend/ge_backend/runtime/actor/actor_dump.cc +index a96f7af0b07..80819584949 100644 +--- a/mindspore/ccsrc/backend/ge_backend/runtime/actor/actor_dump.cc ++++ b/mindspore/ccsrc/backend/ge_backend/runtime/actor/actor_dump.cc +@@ -634,7 +634,7 @@ void FetchInputDeviceTensorStore(const AnfNodePtr &key, size_t index, const Abst + MS_EXCEPTION_IF_NULL(actor_inputs); + std::string input_name = "%"; + if (key->isa()) { +- input_name += key->DebugString(0); ++ input_name += key->DebugString(AnfNode::DebugStringLevel::kLevel0); + } else if (key->isa()) { + const auto &value_node = key->cast(); + MS_EXCEPTION_IF_NULL(value_node); +@@ -678,7 +678,7 @@ void FetchInputForHostQueueDSActor(AbstractActor *actor, ActorInputMap *actor_in + continue; + } + auto kernel_tensor = AnfAlgo::GetOutputKernelTensor(node_pair.first, node_pair.second, false); +- (*actor_inputs)[i] = {node_pair.first->DebugString(0), kernel_tensor}; ++ (*actor_inputs)[i] = {node_pair.first->DebugString(AnfNode::DebugStringLevel::kLevel0), kernel_tensor}; + } + } + +diff --git a/mindspore/ccsrc/backend/ge_backend/runtime/control_node_parser.cc b/mindspore/ccsrc/backend/ge_backend/runtime/control_node_parser.cc +index b01d081a3b1..34dacf2506f 100644 +--- a/mindspore/ccsrc/backend/ge_backend/runtime/control_node_parser.cc ++++ b/mindspore/ccsrc/backend/ge_backend/runtime/control_node_parser.cc +@@ -36,7 +36,6 @@ namespace mindspore { + namespace ge_backend { + namespace runtime { + namespace { +-constexpr auto kDebugStrDepthTwo = 2; + // Check if node is a value node need to create a device tensor. + bool IsFrontValueNode(const KernelWithIndex &node_with_index) { + const auto &node = node_with_index.first; +@@ -2571,7 +2570,7 @@ void ControlNodeParser::PrintParseInfo() { + if (input_pair.first != nullptr) { + MS_LOG(WARNING) << "Kernel graph group:" << group->group_name_ + << " input node:" << input_pair.first->fullname_with_scope() +- << " debug string:" << input_pair.first->DebugString(kDebugStrDepthTwo) ++ << " debug string:" << input_pair.first->DebugString(AnfNode::DebugStringLevel::kLevel2) + << " index:" << input_pair.second; + } + } +@@ -2579,10 +2578,10 @@ void ControlNodeParser::PrintParseInfo() { + if (output_pair.first.first != nullptr && output_pair.second.first != nullptr) { + MS_LOG(WARNING) << "Kernel graph group:" << group->group_name_ + << " output node:" << output_pair.first.first->fullname_with_scope() +- << " debug string:" << output_pair.first.first->DebugString(kDebugStrDepthTwo) ++ << " debug string:" << output_pair.first.first->DebugString(AnfNode::DebugStringLevel::kLevel2) + << " index:" << output_pair.first.second + << " backend node:" << output_pair.second.first->fullname_with_scope() +- << " debug string:" << output_pair.second.first->DebugString(kDebugStrDepthTwo) ++ << " debug string:" << output_pair.second.first->DebugString(AnfNode::DebugStringLevel::kLevel2) + << " index:" << output_pair.second.second; + } + } +@@ -2590,17 +2589,17 @@ void ControlNodeParser::PrintParseInfo() { + for (const auto &f_to_b : front_to_backend_kernels_) { + if (f_to_b.first.first != nullptr && f_to_b.second.first != nullptr) { + MS_LOG(WARNING) << "Front to backend map front node:" << f_to_b.first.first->fullname_with_scope() +- << " debug string:" << f_to_b.first.first->DebugString(kDebugStrDepthTwo) ++ << " debug string:" << f_to_b.first.first->DebugString(AnfNode::DebugStringLevel::kLevel2) + << " index:" << f_to_b.first.second + << " backend node:" << f_to_b.second.first->fullname_with_scope() +- << " debug string:" << f_to_b.second.first->DebugString(kDebugStrDepthTwo) ++ << " debug string:" << f_to_b.second.first->DebugString(AnfNode::DebugStringLevel::kLevel2) + << " index:" << f_to_b.second.second; + } + } + for (const auto &pair : front_node_to_kernel_graph_) { + if (pair.first != nullptr && pair.second != nullptr) { + MS_LOG(WARNING) << "Front node:" << pair.first->fullname_with_scope() +- << " debug string:" << pair.first->DebugString(kDebugStrDepthTwo) ++ << " debug string:" << pair.first->DebugString(AnfNode::DebugStringLevel::kLevel2) + << " to kernel graph:" << pair.second->ToString(); + } + } +diff --git a/mindspore/ccsrc/backend/ge_backend/runtime/control_node_scheduler.cc b/mindspore/ccsrc/backend/ge_backend/runtime/control_node_scheduler.cc +index 2d6fe692cf4..c1587eeec2d 100644 +--- a/mindspore/ccsrc/backend/ge_backend/runtime/control_node_scheduler.cc ++++ b/mindspore/ccsrc/backend/ge_backend/runtime/control_node_scheduler.cc +@@ -2088,7 +2088,7 @@ void GetInputNameForControlActor(AbstractActor *const actor, std::maplocal_kernel_tensors()) { + MS_EXCEPTION_IF_NULL(pair.second.second); +- std::string name = pair.second.second->DebugString(0); ++ std::string name = pair.second.second->DebugString(AnfNode::DebugStringLevel::kLevel0); + if (pair.second.second->isa()) { + name = GetValueNodeName(pair.second.second->cast()); + } +@@ -2139,7 +2139,8 @@ std::map GetInputName(AbstractActor *const actor, const Contr + for (size_t i = 0; i < entrance_actor->formal_parameters().size(); ++i) { + const auto &formal_parameter = entrance_actor->formal_parameters()[i]; + MS_EXCEPTION_IF_NULL(formal_parameter.first); +- input_aids[i] = {formal_parameter.first->DebugString(0), formal_parameter.second}; ++ input_aids[i] = {formal_parameter.first->DebugString(AnfNode::DebugStringLevel::kLevel0), ++ formal_parameter.second}; + } + return input_aids; + } +@@ -2149,7 +2150,7 @@ std::map GetInputName(AbstractActor *const actor, const Contr + // Get all inputs by device tensor store. + for (const auto &pair : actor->device_tensor_store_keys()) { + MS_EXCEPTION_IF_NULL(pair.second); +- std::string name = pair.second->DebugString(0); ++ std::string name = pair.second->DebugString(AnfNode::DebugStringLevel::kLevel0); + if (pair.second->isa()) { + name = GetValueNodeName(pair.second->cast()); + } +diff --git a/mindspore/ccsrc/frontend/ir/anf_py.cc b/mindspore/ccsrc/frontend/ir/anf_py.cc +index 1bbe20cfc7b..49d452eaf5e 100644 +--- a/mindspore/ccsrc/frontend/ir/anf_py.cc ++++ b/mindspore/ccsrc/frontend/ir/anf_py.cc +@@ -22,7 +22,15 @@ namespace mindspore { + // Define python 'CNode' class. + void RegCNode(const py::module *m) { + (void)py::class_(*m, "CNode") +- .def("expanded_str", (std::string(CNode::*)(int32_t) const) & CNode::DebugString, +- "Get CNode string representation with specified expansion level."); ++ .def( ++ "expanded_str", ++ [](const CNode &node, int level) { ++ constexpr int level_max = static_cast(AnfNode::DebugStringLevel::kLevelMax); ++ if (level < 0 || level >= level_max) { ++ throw std::runtime_error("Debug level out of range [0, " + std::to_string(level_max) + ")."); ++ } ++ return node.DebugString(static_cast(level)); ++ }, ++ "Get CNode string representation with specified expansion level."); + } + } // namespace mindspore +diff --git a/mindspore/ccsrc/frontend/operator/composite/do_signature.cc b/mindspore/ccsrc/frontend/operator/composite/do_signature.cc +index 843acd01346..a3417920d4b 100644 +--- a/mindspore/ccsrc/frontend/operator/composite/do_signature.cc ++++ b/mindspore/ccsrc/frontend/operator/composite/do_signature.cc +@@ -478,8 +478,9 @@ std::vector GetNewInputsBySignatures(const FuncGraphPtr &func_graph, + MS_EXCEPTION(TypeError) << "Function " << func_name << "'s input " << i << " should be a Parameter or a Tensor, " + << "but got " << type->ToString() << "."; + } +- MS_LOG(DEBUG) << "Function " << func_name << "'s input " << i << " " << param->DebugString(2) << " abs " +- << args_abs_list[i]->ToString() << " type " << type->ToString() << "."; ++ MS_LOG(DEBUG) << "Function " << func_name << "'s input " << i << " " ++ << param->DebugString(AnfNode::DebugStringLevel::kLevel2) << " abs " << args_abs_list[i]->ToString() ++ << " type " << type->ToString() << "."; + input_types.push_back(type); + op_inputs.push_back(param); + } +diff --git a/mindspore/ccsrc/frontend/optimizer/ad/dfunctor.cc b/mindspore/ccsrc/frontend/optimizer/ad/dfunctor.cc +index 58487f6dc2c..12414f61fb0 100644 +--- a/mindspore/ccsrc/frontend/optimizer/ad/dfunctor.cc ++++ b/mindspore/ccsrc/frontend/optimizer/ad/dfunctor.cc +@@ -606,8 +606,7 @@ void DFunctor::BackPropagate(const CNodePtr &cnode_morph, const AdjointPtr &node + + // Map a morphism. + AdjointPtr DFunctor::MapMorphism(const AnfNodePtr &morph) { +- constexpr int recursive_level = 4; +- MS_LOG(DEBUG) << "Start: " << morph->DebugString(recursive_level); ++ MS_LOG(DEBUG) << "Start: " << morph->DebugString(AnfNode::DebugStringLevel::kLevel4); + // MapMorphism All type except CNode should already be mapped by MapObject. + if (!morph->isa()) { + return nullptr; +@@ -677,7 +676,7 @@ AdjointPtr DFunctor::MapMorphism(const AnfNodePtr &morph) { + node_adjoint->set_side_effect_bprop_app_propagate(side_effect_bprop_app_propagate); + UpdateAdjoint(node_adjoint); + anfnode_to_adjoin_[morph] = node_adjoint; +- MS_LOG(DEBUG) << "End, node: " << morph->DebugString(recursive_level); ++ MS_LOG(DEBUG) << "End, node: " << morph->DebugString(AnfNode::DebugStringLevel::kLevel4); + + if (!is_view_inplace_) { + // Do sens backpropagation. +@@ -1222,11 +1221,10 @@ bool DFunctor::AllReferencesStopped(const CNodePtr &node) { + } + + CNodePtr GetJUser(const NodeUsersMap &node_user_map, const CNodePtr &cnode, int index) { +- constexpr auto recursive_level = 2; + auto it = node_user_map.find(cnode); + if (it == node_user_map.end()) { + MS_LOG_WITH_NODE(INTERNAL_EXCEPTION, cnode) +- << "J CNode not used {" << cnode->DebugString(recursive_level) << "/" << index << "}"; ++ << "J CNode not used {" << cnode->DebugString(AnfNode::DebugStringLevel::kLevel2) << "/" << index << "}"; + } + auto &j_users = it->second; + auto size = j_users.size(); +@@ -1253,8 +1251,8 @@ CNodePtr GetJUser(const NodeUsersMap &node_user_map, const CNodePtr &cnode, int + DumpIR("J_User_Ex_" + cnode->func_graph()->ToString() + ".ir", cnode->func_graph()); + #endif + MS_LOG_WITH_NODE(INTERNAL_EXCEPTION, cnode) +- << "Incorrect J CNode user size: " << size << ", of {" << cnode->DebugString(recursive_level) << "/" << index +- << "}\nUser Info:\n" ++ << "Incorrect J CNode user size: " << size << ", of {" << cnode->DebugString(AnfNode::DebugStringLevel::kLevel2) ++ << "/" << index << "}\nUser Info:\n" + << user_info.str(); + } else { + return j_call_user; +@@ -1286,7 +1284,8 @@ CNodePtr GetPrimalUser(const CNodePtr &j_user, const std::mapDebugString() << ", Primal call: "; + size_t count = 0; + for (const auto &user : primal_users) { +- MS_LOG(INFO) << "[ " << ++count << " ] : " << user->DebugString(2) << trace::DumpSourceLines(user, false); ++ MS_LOG(INFO) << "[ " << ++count << " ] : " << user->DebugString(AnfNode::DebugStringLevel::kLevel2) ++ << trace::DumpSourceLines(user, false); + } + return nullptr; + } +diff --git a/mindspore/ccsrc/frontend/optimizer/fallback_rewriter.cc b/mindspore/ccsrc/frontend/optimizer/fallback_rewriter.cc +index fa754f06f90..bcc77c56246 100644 +--- a/mindspore/ccsrc/frontend/optimizer/fallback_rewriter.cc ++++ b/mindspore/ccsrc/frontend/optimizer/fallback_rewriter.cc +@@ -1804,6 +1804,118 @@ class AfterOptARewriter : public BaseRewriter { + return pyexecute_node; + } + ++ bool CheckNeedConvertJoinedStrInputs(const AnfNodePtr &node) const { ++ if (!node->isa()) { ++ return false; ++ } ++ auto cnode = node->cast(); ++ const auto &inputs = cnode->inputs(); ++ return std::any_of(inputs.begin() + 1, inputs.end(), [this](const AnfNodePtr &e) { ++ auto abstract = e->abstract(); ++ if (abstract == nullptr) { ++ return false; ++ } ++ if (!abstract->isa() && !abstract->isa()) { ++ return false; ++ } ++ if (abstract->isa() && ++ abstract->cast()->dynamic_len()) { ++ return false; ++ } ++ return true; ++ }); ++ } ++ ++ AnfNodePtrList ConvertJoinedStrInput(const AnfNodePtr &node) const { ++ auto abstract = node->abstract(); ++ if (abstract == nullptr) { ++ return AnfNodePtrList{node}; ++ } ++ auto value = abstract->BuildValue(); ++ if (value != kValueAny) { ++ // Build constant string for input ++ const auto &new_str = (py::str(ValueToPyData(value))).cast(); ++ return AnfNodePtrList{NewValueNode(new_str)}; ++ } ++ if (!abstract->isa() && !abstract->isa()) { ++ return AnfNodePtrList{node}; ++ } ++ if (!node->isa()) { ++ return AnfNodePtrList{node}; ++ } ++ auto fg = node->func_graph(); ++ MS_EXCEPTION_IF_NULL(fg); ++ AnfNodePtrList new_inputs; ++ if (abstract->isa()) { ++ MS_LOG(EXCEPTION) << "Joined Str do not support dictionary input yet"; ++ } ++ std::string left = abstract->isa() ? "(" : "["; ++ std::string right = abstract->isa() ? ")" : "]"; ++ PrimitivePtr getitem_prim = ++ abstract->isa() ? prim::kPrimTupleGetItem : prim::kPrimListGetItem; ++ (void)new_inputs.emplace_back(NewValueNode(left)); ++ auto abstract_sequence = abstract->cast(); ++ MS_EXCEPTION_IF_NULL(abstract_sequence); ++ const auto &elements_abstract = abstract_sequence->elements(); ++ for (size_t i = 0; i < elements_abstract.size(); ++i) { ++ auto cur_node = fg->NewCNode({NewValueNode(getitem_prim), node, NewValueNode(int64_t(i))}); ++ cur_node->set_abstract(elements_abstract[i]); ++ auto cur_flattened_input = ConvertJoinedStrInput(cur_node); ++ new_inputs.insert(new_inputs.end(), std::make_move_iterator(cur_flattened_input.begin()), ++ std::make_move_iterator(cur_flattened_input.end())); ++ if (i != elements_abstract.size() - 1) { ++ (void)new_inputs.emplace_back(NewValueNode(", ")); ++ } ++ } ++ (void)new_inputs.emplace_back(NewValueNode(right)); ++ return new_inputs; ++ } ++ ++ AnfNodePtr BuildFlattenedInputJoinedStr(const CNodePtr &node) const { ++ if (!CheckNeedConvertJoinedStrInputs(node)) { ++ return nullptr; ++ } ++ MS_LOG(INFO) << "Start to flattened JoinedStr node: " << node->DebugString(AnfNode::DebugStringLevel::kLevel2); ++ const auto &inputs = node->inputs(); ++ AnfNodePtrList flattened_joined_str_inputs; ++ for (size_t i = 1; i < inputs.size(); ++i) { ++ const auto &new_cur_inputs = ConvertJoinedStrInput(inputs[i]); ++ flattened_joined_str_inputs.insert(flattened_joined_str_inputs.end(), ++ std::make_move_iterator(new_cur_inputs.begin()), ++ std::make_move_iterator(new_cur_inputs.end())); ++ } ++ ++ AnfNodePtrList compressed_joined_str_inputs{inputs[0]}; ++ std::string compressed_str = ""; ++ for (size_t i = 0; i < flattened_joined_str_inputs.size(); ++i) { ++ const auto &cur_input = flattened_joined_str_inputs[i]; ++ if (cur_input->isa()) { ++ const auto &cur_val = cur_input->cast()->value(); ++ const auto &cur_str = GetValue(cur_val); ++ compressed_str += cur_str; ++ continue; ++ } ++ if (compressed_str != "") { ++ ValueNodePtr compressed_node = NewValueNode(compressed_str); ++ compressed_node->set_abstract(compressed_node->value()->ToAbstract()); ++ compressed_str = ""; ++ (void)compressed_joined_str_inputs.emplace_back(compressed_node); ++ } ++ (void)compressed_joined_str_inputs.emplace_back(cur_input); ++ } ++ if (compressed_str != "") { ++ ValueNodePtr compressed_node = NewValueNode(compressed_str); ++ compressed_node->set_abstract(compressed_node->value()->ToAbstract()); ++ compressed_str = ""; ++ (void)compressed_joined_str_inputs.emplace_back(compressed_node); ++ } ++ auto fg = node->func_graph(); ++ MS_EXCEPTION_IF_NULL(fg); ++ auto ret = fg->NewCNode(compressed_joined_str_inputs); ++ MS_LOG(INFO) << "Result flattened JoinedStr node: " << ret->DebugString(AnfNode::DebugStringLevel::kLevel2); ++ return ret; ++ } ++ + // JoinedStr(XXXXXX) + // TO + // A = PyExecute("list(map(str, __inner_convert_object__), ("__inner_convert_object__",), ((XXXXXX,),)") +diff --git a/mindspore/ccsrc/frontend/optimizer/graph_transform.h b/mindspore/ccsrc/frontend/optimizer/graph_transform.h +index 4dabaf0a175..8ca72f976ee 100644 +--- a/mindspore/ccsrc/frontend/optimizer/graph_transform.h ++++ b/mindspore/ccsrc/frontend/optimizer/graph_transform.h +@@ -96,7 +96,7 @@ class GraphSequenceParamTransform { + bool ret = tr.Replace(item.first, item.second); + if (ret == false) { + MS_LOG(ERROR) << "replace failed" << item.first->DebugString() << " with__" +- << item.second->DebugString(SizeToInt(kIndex2)); ++ << item.second->DebugString(AnfNode::DebugStringLevel::kLevel2); + } + } + tr.SetParameters(new_fg, new_params); +diff --git a/mindspore/ccsrc/frontend/optimizer/irpass/branch_culling.cc b/mindspore/ccsrc/frontend/optimizer/irpass/branch_culling.cc +index 6c3d9bc0a37..fb9ab1f20ca 100644 +--- a/mindspore/ccsrc/frontend/optimizer/irpass/branch_culling.cc ++++ b/mindspore/ccsrc/frontend/optimizer/irpass/branch_culling.cc +@@ -149,10 +149,10 @@ void RunSwitchNodeReplace(const FuncGraphManagerPtr &manager, std::vectorset_output(item.second->cast()->input(1)); + } else if (!manager->Replace(item.first, item.second)) { +- constexpr auto kDebugStrDepth = 2; + MS_LOG_WITH_NODE(INTERNAL_EXCEPTION, item.first) +- << "TransformGraphDependNode replace node failed original:" << item.first->DebugString(kDebugStrDepth) +- << " to new: " << item.second->DebugString(kDebugStrDepth); ++ << "TransformGraphDependNode replace node failed original:" ++ << item.first->DebugString(AnfNode::DebugStringLevel::kLevel2) ++ << " to new: " << item.second->DebugString(AnfNode::DebugStringLevel::kLevel2); + } + } + } +diff --git a/mindspore/ccsrc/frontend/optimizer/irpass/incorporate_call.h b/mindspore/ccsrc/frontend/optimizer/irpass/incorporate_call.h +index 988730c34fa..96c394dcc69 100644 +--- a/mindspore/ccsrc/frontend/optimizer/irpass/incorporate_call.h ++++ b/mindspore/ccsrc/frontend/optimizer/irpass/incorporate_call.h +@@ -1,5 +1,5 @@ + /** +- * Copyright 2020-2023 Huawei Technologies Co., Ltd ++ * Copyright 2020-2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. +@@ -150,8 +150,8 @@ class IncorporateCall : public AnfVisitor { + // double check; + const size_t attach_index = 2; + if (update_state_cnode->input(attach_index) == fg_call_cnode_) { +- constexpr int recursive_level = 2; +- MS_LOG(DEBUG) << "Replace UpdateState node: " << update_state_cnode->DebugString(recursive_level) ++ MS_LOG(DEBUG) << "Replace UpdateState node: " ++ << update_state_cnode->DebugString(AnfNode::DebugStringLevel::kLevel2) + << ", input 2 with: " << new_node->DebugString(); + manager->SetEdge(update_state_cnode, attach_index, new_node); + } +diff --git a/mindspore/ccsrc/frontend/optimizer/irpass/inline.h b/mindspore/ccsrc/frontend/optimizer/irpass/inline.h +index a26b23f9f77..8a9b00c0957 100644 +--- a/mindspore/ccsrc/frontend/optimizer/irpass/inline.h ++++ b/mindspore/ccsrc/frontend/optimizer/irpass/inline.h +@@ -1,5 +1,5 @@ + /** +- * Copyright 2020-2024 Huawei Technologies Co., Ltd ++ * Copyright 2020-2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. +@@ -287,11 +287,11 @@ class InlinerBase : public AnfVisitor { + const FuncGraphPtr &fg) const { + auto params = fg->parameters(); + auto old_size = params.size(); +- constexpr auto print_deep = 10; + if (old_size != new_params.size()) { + MS_EXCEPTION_IF_NULL(fg->output()); +- MS_LOG_WITH_NODE(INTERNAL_EXCEPTION, fg->output()) << "Parameter size not match." << old_size << " new " +- << new_params.size() << fg->output()->DebugString(print_deep); ++ MS_LOG_WITH_NODE(INTERNAL_EXCEPTION, fg->output()) ++ << "Parameter size not match." << old_size << " new " << new_params.size() ++ << fg->output()->DebugString(AnfNode::DebugStringLevel::kLevel10); + } + for (size_t i = 0; i < old_size; i++) { + (void)mng->Replace(params[i], new_params[i]); +@@ -414,6 +414,35 @@ class InlinerBase : public AnfVisitor { + return has_branch; + } + ++ void SetAbstractForNewNode(const AnfNodePtr &old_node, const AnfNodePtr &new_node) { ++ const auto &old_abs = old_node->abstract(); ++ if (old_abs == nullptr) { ++ return; ++ } ++ ++ auto new_abs = new_node->abstract(); ++ if (new_abs == nullptr) { ++ new_node->set_abstract(old_abs); ++ return; ++ } ++ ++ if (new_abs->isa()) { ++ return; ++ } ++ ++ const auto &old_value = old_abs->BuildValue(); ++ const auto &new_value = new_abs->BuildValue(); ++ if (old_value == kValueAny && new_value != kValueAny) { ++ MS_LOG(DEBUG) << "Skip setting abstract for new node: Old node has ValueAny while new node has concrete value.\n" ++ << "Old node: " << old_node->DebugString() << ", New node: " << new_node->DebugString() << "\n" ++ << "Old abstract: " << old_abs->ToString() << ", New abstract: " << new_abs->ToString() << "\n" ++ << "Old value: " << old_value->ToString() << ", New value: " << new_value->ToString(); ++ return; ++ } ++ ++ new_node->set_abstract(old_abs); ++ } ++ + bool is_checked_{false}; + bool is_recursive_{false}; + // If the user guarantee that fg has no recursive. +diff --git a/mindspore/ccsrc/frontend/optimizer/irpass/parameter_eliminate.h b/mindspore/ccsrc/frontend/optimizer/irpass/parameter_eliminate.h +index 68ceed685e0..a17cb7c50e4 100644 +--- a/mindspore/ccsrc/frontend/optimizer/irpass/parameter_eliminate.h ++++ b/mindspore/ccsrc/frontend/optimizer/irpass/parameter_eliminate.h +@@ -1,5 +1,5 @@ + /** +- * Copyright 2021-2023 Huawei Technologies Co., Ltd ++ * Copyright 2021-2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. +@@ -37,10 +37,9 @@ static inline void CheckSwitchCallValid(const CNodePtr &switch_call) { + MS_EXCEPTION_IF_NULL(switch_call); + if (switch_call->size() > 1) { + // Means call switch(arg1, ...) has args. +- constexpr auto recursive_count = 2; + MS_LOG_WITH_NODE(INTERNAL_EXCEPTION, switch_call) + << "After switch_call_monad_eliminater pass, the call switch node should not has args." +- << " The call_switch_cnode is: " << switch_call->DebugString(recursive_count); ++ << " The call_switch_cnode is: " << switch_call->DebugString(AnfNode::DebugStringLevel::kLevel2); + } + } + +diff --git a/mindspore/ccsrc/frontend/optimizer/irpass/partial_eliminate.h b/mindspore/ccsrc/frontend/optimizer/irpass/partial_eliminate.h +index 67b0764fa9f..b8ba0363740 100644 +--- a/mindspore/ccsrc/frontend/optimizer/irpass/partial_eliminate.h ++++ b/mindspore/ccsrc/frontend/optimizer/irpass/partial_eliminate.h +@@ -1,5 +1,5 @@ + /** +- * Copyright 2020-2021 Huawei Technologies Co., Ltd ++ * Copyright 2020-2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. +@@ -67,9 +67,8 @@ class PartialEliminater : public AnfVisitor { + } + // {X, Ys, Xs} if Xs has monad + if (!IsValueNode(X_)) { +- constexpr auto recursive_level = 2; + MS_LOG_WITH_NODE(INTERNAL_EXCEPTION, node) +- << "Not support yet as X_ is not a funcgraph. node: " << node->DebugString(recursive_level); ++ << "Not support yet as X_ is not a funcgraph. node: " << node->DebugString(AnfNode::DebugStringLevel::kLevel2); + } + auto fg = GetValueNode(X_); + MS_EXCEPTION_IF_NULL(fg); +diff --git a/mindspore/ccsrc/frontend/optimizer/irpass/recompute.cc b/mindspore/ccsrc/frontend/optimizer/irpass/recompute.cc +index bc27a859aa2..1f3df45ef26 100644 +--- a/mindspore/ccsrc/frontend/optimizer/irpass/recompute.cc ++++ b/mindspore/ccsrc/frontend/optimizer/irpass/recompute.cc +@@ -1,5 +1,5 @@ + /** +- * Copyright 2023 Huawei Technologies Co., Ltd ++ * Copyright 2023-2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. +@@ -762,8 +762,8 @@ bool Recomputation::operator()(const FuncGraphPtr &root, const OptimizerPtr &opt + continue; + } + // Replace the forward getter with the origin primal. +- constexpr auto recursive_level = 2; +- MS_LOG(DEBUG) << "Handle recompute k graph forward getter: " << node->DebugString(recursive_level); ++ MS_LOG(DEBUG) << "Handle recompute k graph forward getter: " ++ << node->DebugString(AnfNode::DebugStringLevel::kLevel2); + std::vector inputs{primal}; + (void)inputs.insert(inputs.cend(), k_fg_caller_cnode->inputs().begin() + 1, k_fg_caller_cnode->inputs().end()); + auto fg = node->func_graph(); +diff --git a/mindspore/ccsrc/frontend/optimizer/irpass/special_op_eliminate.cc b/mindspore/ccsrc/frontend/optimizer/irpass/special_op_eliminate.cc +index 7c4bdd318e8..2eba9301df2 100644 +--- a/mindspore/ccsrc/frontend/optimizer/irpass/special_op_eliminate.cc ++++ b/mindspore/ccsrc/frontend/optimizer/irpass/special_op_eliminate.cc +@@ -1,5 +1,5 @@ + /** +- * Copyright 2020-2024 Huawei Technologies Co., Ltd ++ * Copyright 2020-2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. +@@ -442,7 +442,7 @@ AnfNodePtr PynativeEliminater::OperatorHandle1(const PatternNode &ar + auto value_node = rep->cast(); + auto new_value_node = NewValueNode(FillZero(value_node->value(), node)); + new_value_node->set_has_new_value(value_node->has_new_value()); +- MS_LOG(DEBUG) << "Zeros_like replace ok " << rep->DebugString(4); ++ MS_LOG(DEBUG) << "Zeros_like replace ok " << rep->DebugString(AnfNode::DebugStringLevel::kLevel4); + return new_value_node; + } + } +@@ -456,7 +456,7 @@ AnfNodePtr PynativeEliminater::OperatorHandle2(const PatternNode &ar + auto value_node = rep->cast(); + auto new_value_node = NewValueNode(FillZero(value_node->value(), node)); + new_value_node->set_has_new_value(value_node->has_new_value()); +- MS_LOG(DEBUG) << "Zeros_like replace ok 2 " << rep->DebugString(4); ++ MS_LOG(DEBUG) << "Zeros_like replace ok 2 " << rep->DebugString(AnfNode::DebugStringLevel::kLevel4); + return new_value_node; + } + } +@@ -489,7 +489,7 @@ AnfNodePtr PynativeEliminater::OperatorHandle4(const PatternNode &ar + auto rep = (arg).GetNode(node); + if (rep != nullptr) { + if (rep->isa()) { +- MS_LOG(DEBUG) << "Rep is " << rep->DebugString(4); ++ MS_LOG(DEBUG) << "Rep is " << rep->DebugString(AnfNode::DebugStringLevel::kLevel4); + ValueNodePtr new_node; + auto value_node = rep->cast(); + auto rep1 = (arg1).GetNode(node); +@@ -503,7 +503,7 @@ AnfNodePtr PynativeEliminater::OperatorHandle4(const PatternNode &ar + new_node->set_has_new_value(value_node->has_new_value()); + } + } +- MS_LOG(DEBUG) << "Fill getitem replace ok " << new_node->DebugString(4); ++ MS_LOG(DEBUG) << "Fill getitem replace ok " << new_node->DebugString(AnfNode::DebugStringLevel::kLevel4); + return new_node; + } + } +@@ -511,7 +511,7 @@ AnfNodePtr PynativeEliminater::OperatorHandle4(const PatternNode &ar + } + + AnfNodePtr PynativeEliminater::operator()(const OptimizerPtr &, const AnfNodePtr &node) { +- MS_LOG(DEBUG) << "Start replace node " << node->DebugString(4); ++ MS_LOG(DEBUG) << "Start replace node " << node->DebugString(AnfNode::DebugStringLevel::kLevel4); + PatternNode symbol_str_vnode; + PatternNode c_vnode; + PatternNode zeros_like_vnode; +@@ -528,7 +528,7 @@ AnfNodePtr PynativeEliminater::operator()(const OptimizerPtr &, const AnfNodePtr + return new_value_node; + } + } +- MS_LOG(DEBUG) << "End replace 1 " << node->DebugString(4); ++ MS_LOG(DEBUG) << "End replace 1 " << node->DebugString(AnfNode::DebugStringLevel::kLevel4); + // {prim:getattr, {prim::resolve, SymbolStr, zeros_like}, Xy} ->Tensor(0, shape(Xy)) + auto resolve1 = PPrimitive(prim::kPrimResolve, symbol_str_vnode, zeros_like_vnode); + auto pattern1 = PCNode(resolve1, arg); +@@ -563,7 +563,7 @@ AnfNodePtr PynativeEliminater::operator()(const OptimizerPtr &, const AnfNodePtr + } + } + +- MS_LOG(DEBUG) << "End Replace " << node->DebugString(4); ++ MS_LOG(DEBUG) << "End Replace " << node->DebugString(AnfNode::DebugStringLevel::kLevel4); + return nullptr; + } + +diff --git a/mindspore/ccsrc/frontend/optimizer/irpass/updatestate_eliminate.cc b/mindspore/ccsrc/frontend/optimizer/irpass/updatestate_eliminate.cc +index 1e1ed535b14..ab0cfb96474 100644 +--- a/mindspore/ccsrc/frontend/optimizer/irpass/updatestate_eliminate.cc ++++ b/mindspore/ccsrc/frontend/optimizer/irpass/updatestate_eliminate.cc +@@ -142,10 +142,10 @@ AnfNodePtr NewUpdateStateWithAttach(const CNodePtr &update_state, const AnfNodeP + + AnfNodePtr EliminateUpdateStateWithDepend(const CNodePtr &update_state) { + auto depend = update_state->input(kAttachIndex)->cast(); +- constexpr auto recur_2 = 2; + // If same Depend CNode is used by multiple UpdateState CNode, it may be replaced by previous elimination. + if (depend == nullptr) { +- MS_LOG(DEBUG) << "UpdateState's input 2 Depend had been replaced: " << update_state->DebugString(recur_2); ++ MS_LOG(DEBUG) << "UpdateState's input 2 Depend had been replaced: " ++ << update_state->DebugString(AnfNode::DebugStringLevel::kLevel2); + return nullptr; + } + auto input_monad = depend->inputs().back(); +@@ -165,7 +165,8 @@ AnfNodePtr EliminateUpdateStateWithDepend(const CNodePtr &update_state) { + // u3 and x1 should not match otherwise u1 will be lost; u2 and x1 can match. + if (IsPrimitiveCNode(update_monad, prim::kPrimUpdateState) && + update_monad->cast()->input(kAttachIndex) == depend) { +- MS_LOG(DEBUG) << "UpdateState should not be replaced. node: " << update_state->DebugString(recur_2); ++ MS_LOG(DEBUG) << "UpdateState should not be replaced. node: " ++ << update_state->DebugString(AnfNode::DebugStringLevel::kLevel2); + return nullptr; + } + // Check monad inputs. +@@ -528,7 +529,7 @@ AnfNodePtr EliminateUpdateStateForLoads(const CNodePtr &old_update_state, const + + if (make_tuple_inputs.size() == 1) { + // This should not happen. +- MS_LOG(WARNING) << "No loads for " << old_update_state->DebugString(2); ++ MS_LOG(WARNING) << "No loads for " << old_update_state->DebugString(AnfNode::DebugStringLevel::kLevel2); + return nullptr; + } + // Create the new UpdateState node with a MakeTuple, replace the old UpdateStateNode. +diff --git a/mindspore/ccsrc/kernel/framework_utils.cc b/mindspore/ccsrc/kernel/framework_utils.cc +index 5c9a52aaeb9..ae8748e88ad 100644 +--- a/mindspore/ccsrc/kernel/framework_utils.cc ++++ b/mindspore/ccsrc/kernel/framework_utils.cc +@@ -1,5 +1,5 @@ + /** +- * Copyright 2023 Huawei Technologies Co., Ltd ++ * Copyright 2023-2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. +@@ -584,8 +584,8 @@ std::vector> GetOutputIndex(const std::vectorDebugString(2) << "] of [" +- << output->func_graph()->ToString() << "] found no related kernel info."; ++ MS_EXCEPTION(ArgumentError) << "Output [" << i << "][" << output->DebugString(AnfNode::DebugStringLevel::kLevel2) ++ << "] of [" << output->func_graph()->ToString() << "] found no related kernel info."; + } + } + return output_index; +diff --git a/mindspore/ccsrc/kernel/graph_kernel/akg/akg_kernel_json_decoder.cc b/mindspore/ccsrc/kernel/graph_kernel/akg/akg_kernel_json_decoder.cc +index 0a4894ce751..e989789931b 100644 +--- a/mindspore/ccsrc/kernel/graph_kernel/akg/akg_kernel_json_decoder.cc ++++ b/mindspore/ccsrc/kernel/graph_kernel/akg/akg_kernel_json_decoder.cc +@@ -1,5 +1,5 @@ + /** +- * Copyright 2020-2022 Huawei Technologies Co., Ltd ++ * Copyright 2020-2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. +@@ -305,8 +305,7 @@ class CNodeDecoder { + builder->SetOutputsDeviceType(std::vector{StringToTypeId(value_json[kJsonKeyDataType])}); + AnfAlgo::SetSelectKernelBuildInfo(builder->Build(), value_node.get()); + func_graph->AddValueNode(value_node); +- const int kDebugLevel = 2; +- MS_LOG(DEBUG) << "decode value node success, " << value_node->DebugString(kDebugLevel); ++ MS_LOG(DEBUG) << "decode value node success, " << value_node->DebugString(AnfNode::DebugStringLevel::kLevel2); + return value_node; + } + +diff --git a/mindspore/ccsrc/kernel/graph_kernel/graph_kernel_json_generator.cc b/mindspore/ccsrc/kernel/graph_kernel/graph_kernel_json_generator.cc +index 3755c9e6616..f7fe210a5c3 100644 +--- a/mindspore/ccsrc/kernel/graph_kernel/graph_kernel_json_generator.cc ++++ b/mindspore/ccsrc/kernel/graph_kernel/graph_kernel_json_generator.cc +@@ -1,5 +1,5 @@ + /** +- * Copyright 2020-2023 Huawei Technologies Co., Ltd ++ * Copyright 2020-2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. +@@ -47,7 +47,6 @@ using kernel::OpIOInfo; + namespace { + constexpr int kCurrentInfoVersion = 2; + constexpr auto kAttrParallelDimInfoSize = 2; +-constexpr auto kDebugStrDepth = 2; + + std::vector GetDynInputSizes(const AnfNodePtr &anf_node) { + std::vector dyn_input_sizes; +@@ -86,8 +85,8 @@ std::vector>> GetInputIndex(cons + const NodeUsersMap &users = mng->node_users(); + auto input_users = users.find(input); + if (input_users == users.end() || input_users->second.empty()) { +- MS_EXCEPTION(ArgumentError) << "Input [" << i << "][" << input->DebugString(kDebugStrDepth) << "] of [" +- << input->func_graph()->ToString() << "] has no users."; ++ MS_EXCEPTION(ArgumentError) << "Input [" << i << "][" << input->DebugString(AnfNode::DebugStringLevel::kLevel2) ++ << "] of [" << input->func_graph()->ToString() << "] has no users."; + } + bool found = false; + for (auto const &input_user : input_users->second) { +@@ -124,8 +123,8 @@ std::vector>> GetInputIndex(cons + if (found) { + continue; + } +- MS_EXCEPTION(ArgumentError) << "Input [" << i << "][" << input->DebugString(kDebugStrDepth) << "] of [" +- << input->func_graph()->ToString() << "] found no related kernel info."; ++ MS_EXCEPTION(ArgumentError) << "Input [" << i << "][" << input->DebugString(AnfNode::DebugStringLevel::kLevel2) ++ << "] of [" << input->func_graph()->ToString() << "] found no related kernel info."; + } + return input_index; + } +@@ -150,8 +149,8 @@ std::vector> GetOutputIndex(const std::vectorDebugString(kDebugStrDepth) << "] of [" +- << output->func_graph()->ToString() << "] found no related kernel info."; ++ MS_EXCEPTION(ArgumentError) << "Output [" << i << "][" << output->DebugString(AnfNode::DebugStringLevel::kLevel2) ++ << "] of [" << output->func_graph()->ToString() << "] found no related kernel info."; + } + } + return output_index; +@@ -505,7 +504,7 @@ bool GraphKernelJsonGenerator::CreateInputDescJson(const AnfNodePtr &anf_node, c + auto input_shape = this->cb_->GetInputShape(anf_node, real_input_index); + if (!is_basic_op_ && GetInputTensorValue(anf_node, real_input_index, &input_shape, &input_desc_json)) { + MS_LOG(DEBUG) << "Pick value [" << input_desc_json[kJsonKeyValue] << "] from input[" << real_input_index +- << "] of node [" << anf_node->DebugString(kDebugStrDepth); ++ << "] of node [" << anf_node->DebugString(AnfNode::DebugStringLevel::kLevel2); + } + if (input_shape.empty()) { + input_shape.push_back(1); +diff --git a/mindspore/ccsrc/pipeline/jit/pi/graph_capture/graph.cc b/mindspore/ccsrc/pipeline/jit/pi/graph_capture/graph.cc +index 19a39df2d8c..434dfde08a8 100644 +--- a/mindspore/ccsrc/pipeline/jit/pi/graph_capture/graph.cc ++++ b/mindspore/ccsrc/pipeline/jit/pi/graph_capture/graph.cc +@@ -1,5 +1,5 @@ + /** +- * Copyright 2023 Huawei Technologies Co., Ltd ++ * Copyright 2023-2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. +@@ -768,7 +768,7 @@ bool Graph::GuardInlinedFunc(CallNode *call_node) { + static void PrintAnfNode(std::ostream *out, mindspore::AnfNode *anf_node, const std::string &prefix) { + auto &s = *out; + std::string str; +- str += anf_node->DebugString(1) + " "; ++ str += anf_node->DebugString(AnfNode::DebugStringLevel::kLevel1) + " "; + str += anf_node->abstract() == nullptr ? "" : anf_node->abstract()->ToString(); + std::replace(str.begin(), str.end(), '\n', ' '); + s << " AnfNode(" << anf_node << ") [" << str << "]"; +diff --git a/mindspore/ccsrc/pipeline/jit/ps/action.cc b/mindspore/ccsrc/pipeline/jit/ps/action.cc +index 9c3ee642fa1..d7607e783ac 100644 +--- a/mindspore/ccsrc/pipeline/jit/ps/action.cc ++++ b/mindspore/ccsrc/pipeline/jit/ps/action.cc +@@ -695,8 +695,7 @@ void BuildTopGraph(const FuncGraphPtr &func_graph, const py::object &input, + } + } + auto output = func_graph->NewCNodeInOrder(inputs); +- constexpr auto recursive_level = 2; +- MS_LOG(DEBUG) << "output: " << output->DebugString(recursive_level); ++ MS_LOG(DEBUG) << "output: " << output->DebugString(AnfNode::DebugStringLevel::kLevel2); + func_graph->set_output(output); + } + } // namespace +@@ -839,8 +838,7 @@ bool CombineLikeGraphs(const ResourcePtr &resource) { + (void)new_node_inputs.insert(new_node_inputs.end(), fvs.cbegin(), fvs.cend()); + AnfNodePtr out = g->NewCNodeBefore(g->get_return(), new_node_inputs); + g->set_output(out); +- const int recursive_level = 4; +- MS_LOG(DEBUG) << "Combine graph newout:" << out->DebugString(recursive_level); ++ MS_LOG(DEBUG) << "Combine graph newout:" << out->DebugString(AnfNode::DebugStringLevel::kLevel4); + } + MS_LOG(DEBUG) << "End combine graph:" << it->first; + } +diff --git a/mindspore/ccsrc/pipeline/jit/ps/fallback.cc b/mindspore/ccsrc/pipeline/jit/ps/fallback.cc +index 1cf563307e0..9182f6d20ca 100644 +--- a/mindspore/ccsrc/pipeline/jit/ps/fallback.cc ++++ b/mindspore/ccsrc/pipeline/jit/ps/fallback.cc +@@ -1,5 +1,5 @@ + /** +- * Copyright 2023-2024 Huawei Technologies Co., Ltd ++ * Copyright 2023-2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. +@@ -264,9 +264,8 @@ AnfNodePtr ConvertPyObjectToPyExecute(const FuncGraphPtr &fg, const std::string + const auto interpreted_cnode = + CreatePyExecuteCNode(fg, NewValueNode(script_str), NewValueNode(std::make_shared(keys)), + NewValueNode(std::make_shared(values)), node->debug_info()); +- constexpr auto debug_recursive_level = 2; +- MS_LOG(DEBUG) << "original node: " << node->DebugString(debug_recursive_level) +- << ", interpreted_cnode: " << interpreted_cnode->DebugString(debug_recursive_level); ++ MS_LOG(DEBUG) << "original node: " << node->DebugString(AnfNode::DebugStringLevel::kLevel2) ++ << ", interpreted_cnode: " << interpreted_cnode->DebugString(AnfNode::DebugStringLevel::kLevel2); + if (replace) { + fg->ReplaceInOrder(node, interpreted_cnode); + } +diff --git a/mindspore/ccsrc/pipeline/jit/ps/parse/function_block.cc b/mindspore/ccsrc/pipeline/jit/ps/parse/function_block.cc +index d855d6604d3..b824b7b0268 100644 +--- a/mindspore/ccsrc/pipeline/jit/ps/parse/function_block.cc ++++ b/mindspore/ccsrc/pipeline/jit/ps/parse/function_block.cc +@@ -1,7 +1,7 @@ + /** + * This is the C++ adaptation and derivative work of Myia (https://github.com/mila-iqia/myia/). + * +- * Copyright 2019-2023 Huawei Technologies Co., Ltd ++ * Copyright 2019-2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. +@@ -121,10 +121,9 @@ void FunctionBlock::WriteVariable(const std::string &var_name, const AnfNodePtr + MS_EXCEPTION_IF_NULL(node); + MS_LOG(DEBUG) << (func_graph_ ? func_graph_->ToString() : "FG(Null)") << " write var `" << var_name << "` with node " + << node->DebugString(); +- constexpr auto kRecursiveLevel = 2; + // a[::][::] = b will be translated to c = a[::] c[::] = b and the c is a no named variable. + if (var_name.empty()) { +- MS_LOG(DEBUG) << "The node is " << node->DebugString(kRecursiveLevel) ++ MS_LOG(DEBUG) << "The node is " << node->DebugString(AnfNode::DebugStringLevel::kLevel2) + << "added in the isolated list.\nBlock: " << this << "/" + << (func_graph_ ? func_graph_->ToString() : "FG(Null)") + << ", Line: " << trace::GetDebugInfoStr(node->debug_info(), "", kSourceLineTipDiscard); +@@ -144,8 +143,9 @@ void FunctionBlock::WriteVariable(const std::string &var_name, const AnfNodePtr + auto is_isolated = CanBeIsolatedNode(var_name, hidden_node); + if (!is_used && is_isolated) { + MS_EXCEPTION_IF_NULL(hidden_node); +- MS_LOG(INFO) << "Isolated node found(Hidden), hidden_node: " << hidden_node->DebugString(kRecursiveLevel) +- << " is hidden by " << node->DebugString(kRecursiveLevel) ++ MS_LOG(INFO) << "Isolated node found(Hidden), hidden_node: " ++ << hidden_node->DebugString(AnfNode::DebugStringLevel::kLevel2) << " is hidden by " ++ << node->DebugString(AnfNode::DebugStringLevel::kLevel2) + << " with the same name, var_name: " << var_name << ", block: " << this << "/" + << (func_graph_ ? func_graph_->ToString() : "FG(Null)") + << ", Line: " << trace::GetDebugInfoStr(hidden_node->debug_info(), "", kSourceLineTipDiscard); +@@ -835,9 +835,9 @@ void FunctionBlock::SetStateAssign(const AnfNodePtr &target, const AnfNodePtr &s + const std::string module_name("mindspore.ops.functional"); + ValueNodePtr assign_op = NewValueNode(prim::GetPythonOps(primitive_name, module_name, true)); + auto assign_node = func_graph_->NewCNodeInOrder({assign_op, target, source}); +- const int recursive_level = 2; +- MS_LOG(DEBUG) << "Isolated node found(Assign), assign_node: " << assign_node->DebugString(recursive_level) +- << ", block: " << this << "/" << func_graph_->ToString() ++ MS_LOG(DEBUG) << "Isolated node found(Assign), assign_node: " ++ << assign_node->DebugString(AnfNode::DebugStringLevel::kLevel2) << ", block: " << this << "/" ++ << func_graph_->ToString() + << ", Line: " << trace::GetDebugInfoStr(assign_node->debug_info(), "", kSourceLineTipDiscard); + AddIsolatedNode(assign_node); + } +@@ -847,8 +847,7 @@ void FunctionBlock::ConvertUnusedNodesToIsolated(const std::string &var_name, co + return; + } + if (CanBeIsolatedNode(var_name, node)) { +- const int recursive_level = 2; +- MS_LOG(INFO) << "Isolated node found(NoUse), node: " << node->DebugString(recursive_level) ++ MS_LOG(INFO) << "Isolated node found(NoUse), node: " << node->DebugString(AnfNode::DebugStringLevel::kLevel2) + << ", var_name: " << var_name << ", block: " << this << "/" + << (func_graph() ? func_graph()->ToString() : "FG(Null)") + << ", Line: " << trace::GetDebugInfoStr(node->debug_info(), "", kSourceLineTipDiscard); +diff --git a/mindspore/ccsrc/pipeline/jit/ps/parse/parse.cc b/mindspore/ccsrc/pipeline/jit/ps/parse/parse.cc +index a43343f7f97..a024f2273bd 100644 +--- a/mindspore/ccsrc/pipeline/jit/ps/parse/parse.cc ++++ b/mindspore/ccsrc/pipeline/jit/ps/parse/parse.cc +@@ -257,8 +257,7 @@ std::vector> GetFreeVariable(const FuncGraphPtr &fun + auto &input = cnode->input(i); + if (input->func_graph() != nullptr && input->func_graph() != func_graph) { + (void)free_variables.emplace_back(std::make_pair(cnode, i)); +- constexpr auto recur_2 = 2; +- MS_LOG(DEBUG) << "Found FV: input[" << i << "] of " << cnode->DebugString(recur_2); ++ MS_LOG(DEBUG) << "Found FV: input[" << i << "] of " << cnode->DebugString(AnfNode::DebugStringLevel::kLevel2); + } + } + } +@@ -280,8 +279,7 @@ void Parser::LiftRolledBodyGraphFV() { + // Change the free variable to the parameter. + auto parameter = rolled_graph->add_parameter(); + cnode->set_input(index, parameter); +- constexpr auto recur_2 = 2; +- MS_LOG(DEBUG) << "Change FV: " << cnode->DebugString(recur_2); ++ MS_LOG(DEBUG) << "Change FV: " << cnode->DebugString(AnfNode::DebugStringLevel::kLevel2); + } + } + } +@@ -308,8 +306,7 @@ void Parser::LiftIfBranchGraphFV() { + cnode->set_input(index, parameter); + // Add a unused parameter in other branch. + (void)false_branch_graph->add_parameter(); +- constexpr auto recur_2 = 2; +- MS_LOG(DEBUG) << "True branch, change FV: " << cnode->DebugString(recur_2); ++ MS_LOG(DEBUG) << "True branch, change FV: " << cnode->DebugString(AnfNode::DebugStringLevel::kLevel2); + } + // Handle false branch. + for (auto &free_node_pair : false_free_variables) { +@@ -324,8 +321,7 @@ void Parser::LiftIfBranchGraphFV() { + cnode->set_input(index, parameter); + // Add a unused parameter in other branch. + (void)true_branch_graph->add_parameter(); +- constexpr auto recur_2 = 2; +- MS_LOG(DEBUG) << "False branch, change FV: " << cnode->DebugString(recur_2); ++ MS_LOG(DEBUG) << "False branch, change FV: " << cnode->DebugString(AnfNode::DebugStringLevel::kLevel2); + } + } + } +@@ -446,19 +442,20 @@ bool CheckMiddleGraphOutputContainScalar( + if (middle_call_graph->get_return() == nullptr) { + continue; + } +- constexpr auto recur_2 = 2; + const auto &middle_graph_output_pair = GetRealOutputNodes(middle_call_graph); + const auto middle_graph_output_cnode = middle_graph_output_pair.first; + MS_EXCEPTION_IF_NULL(middle_graph_output_cnode); + auto middle_graph_output_cnode_size = middle_graph_output_cnode->size(); + if (middle_graph_output_cnode_size <= 1) { +- MS_LOG(DEBUG) << "CNode's inputs size should exceed 1, " << middle_graph_output_cnode->DebugString(recur_2); ++ MS_LOG(DEBUG) << "CNode's inputs size should exceed 1, " ++ << middle_graph_output_cnode->DebugString(AnfNode::DebugStringLevel::kLevel2); + return false; + } + + static const auto transform_if_const_scalar = (common::GetCompileConfig("IF_PARALLEL_CALL") == "2"); + if (!transform_if_const_scalar && IsOutputContainScalar(middle_graph_output_cnode)) { +- MS_LOG(DEBUG) << "CNode's inputs contain const scalar, " << middle_graph_output_cnode->DebugString(recur_2); ++ MS_LOG(DEBUG) << "CNode's inputs contain const scalar, " ++ << middle_graph_output_cnode->DebugString(AnfNode::DebugStringLevel::kLevel2); + contains_scalar.push_back(true); + } else { + contains_scalar.push_back(false); +@@ -478,13 +475,13 @@ bool CheckMiddleGraphOutputPyInterpret( + if (middle_call_graph->get_return() == nullptr) { + continue; + } +- constexpr auto recur_2 = 2; + const auto &middle_graph_output_pair = GetRealOutputNodes(middle_call_graph); + const auto middle_graph_output_cnode = middle_graph_output_pair.first; + MS_EXCEPTION_IF_NULL(middle_graph_output_cnode); + auto middle_graph_output_cnode_size = middle_graph_output_cnode->size(); + if (middle_graph_output_cnode_size <= 1) { +- MS_LOG(DEBUG) << "CNode's inputs size should exceed 1, " << middle_graph_output_cnode->DebugString(recur_2); ++ MS_LOG(DEBUG) << "CNode's inputs size should exceed 1, " ++ << middle_graph_output_cnode->DebugString(AnfNode::DebugStringLevel::kLevel2); + return false; + } + bool exist_interpret = std::any_of( +@@ -527,14 +524,15 @@ void Parser::TransformParallelCall() { + MS_LOG(INFO) << "middle_graph_return is null, middle_call_graph: " << middle_call_graph->ToString(); + continue; + } +- constexpr auto recur_3 = 3; +- constexpr auto recur_2 = 2; +- MS_LOG(DEBUG) << "Tail call graphs return: {former: " << former_call_graph->get_return()->DebugString(recur_3) +- << ", middle: " << middle_call_graph->get_return()->DebugString(recur_3) << "}"; ++ MS_LOG(DEBUG) << "Tail call graphs return: {former: " ++ << former_call_graph->get_return()->DebugString(AnfNode::DebugStringLevel::kLevel3) ++ << ", middle: " << middle_call_graph->get_return()->DebugString(AnfNode::DebugStringLevel::kLevel3) ++ << "}"; + const auto &[middle_graph_output_cnode, middle_graph_dependency_node] = GetRealOutputNodes(middle_call_graph); + auto middle_graph_output_cnode_size = middle_graph_output_cnode->size(); + if (middle_graph_output_cnode_size <= 1) { +- MS_LOG(DEBUG) << "CNode's inputs size should exceed 1, " << middle_graph_output_cnode->DebugString(recur_2); ++ MS_LOG(DEBUG) << "CNode's inputs size should exceed 1, " ++ << middle_graph_output_cnode->DebugString(AnfNode::DebugStringLevel::kLevel2); + continue; + } + +@@ -545,7 +543,8 @@ void Parser::TransformParallelCall() { + // Transform the call of {former_graph -> middle_graph}. + auto latter_call_graph = GetValueNode(latter_graph_node); + if (latter_call_graph == nullptr) { +- MS_LOG(ERROR) << "The latter graph node is not FuncGraph, " << latter_graph_node->DebugString(recur_2); ++ MS_LOG(ERROR) << "The latter graph node is not FuncGraph, " ++ << latter_graph_node->DebugString(AnfNode::DebugStringLevel::kLevel2); + continue; + } + if (latter_call_graphs_set.find(latter_call_graph) != latter_call_graphs_set.end()) { +@@ -556,8 +555,10 @@ void Parser::TransformParallelCall() { + TransformParallelCallFormerToMiddle(former_call_graph, latter_call_graph, middle_graph_output_cnode_size, + use_arguments_pack); + +- MS_LOG(DEBUG) << "Parallel call graphs return: {former: " << former_call_graph->get_return()->DebugString(recur_3) +- << ", middle: " << middle_call_graph->get_return()->DebugString(recur_3) << "}"; ++ MS_LOG(DEBUG) << "Parallel call graphs return: {former: " ++ << former_call_graph->get_return()->DebugString(AnfNode::DebugStringLevel::kLevel3) ++ << ", middle: " << middle_call_graph->get_return()->DebugString(AnfNode::DebugStringLevel::kLevel3) ++ << "}"; + } + } + +@@ -1041,10 +1042,9 @@ bool Parser::HandleSetAttrClassMemberForInplace(const FunctionBlockPtr &block, c + if (!IsPrimitiveCNode(call_node, prim::kPrimGetAttr)) { + return false; + } +- constexpr int recursive_level = 2; + // call_cnode: self.attr.func + auto call_cnode = call_node->cast(); +- MS_LOG(DEBUG) << "call cnode: " << call_cnode->DebugString(recursive_level); ++ MS_LOG(DEBUG) << "call cnode: " << call_cnode->DebugString(AnfNode::DebugStringLevel::kLevel2); + const auto &call_cnode_inputs = call_cnode->inputs(); + constexpr size_t attr_node_index = 1; + constexpr size_t func_str_index = 2; +@@ -1066,7 +1066,7 @@ bool Parser::HandleSetAttrClassMemberForInplace(const FunctionBlockPtr &block, c + // attr_cnode: self.attr + auto attr_cnode = attr_node->cast(); + MS_EXCEPTION_IF_NULL(attr_cnode); +- MS_LOG(DEBUG) << "attr cnode: " << attr_cnode->DebugString(recursive_level); ++ MS_LOG(DEBUG) << "attr cnode: " << attr_cnode->DebugString(AnfNode::DebugStringLevel::kLevel2); + const auto &attr_cnode_inputs = attr_cnode->inputs(); + constexpr size_t target_index = 1; + constexpr size_t attr_index = 2; +@@ -3381,8 +3381,8 @@ FunctionBlockPtr Parser::ParseForRepeat(const FunctionBlockPtr &block, const py: + // Record the rolled body function, for later lifting operation. + if (rolled_body_call != nullptr) { + (void)rolled_body_calls_.emplace_back(std::make_pair(rolled_body_call, rolled_body_block)); +- constexpr int recursive_level = 2; +- MS_LOG(DEBUG) << "Record rolled body call: {CNode: " << rolled_body_call->DebugString(recursive_level) ++ MS_LOG(DEBUG) << "Record rolled body call: {CNode: " ++ << rolled_body_call->DebugString(AnfNode::DebugStringLevel::kLevel2) + << ", rolled_graph: " << rolled_body_block->ToString() << "}"; + } + } +@@ -4345,14 +4345,13 @@ AnfNodePtr Parser::MakeInterpretNode(const FunctionBlockPtr &block, const AnfNod + + auto local_dict_node = ParseDictByKeysAndValues(block, filter_keys, filter_values); + // Update the valued node if it need interpreting. +- constexpr int recursive_level = 2; + MS_EXCEPTION_IF_NULL(block->func_graph()); + AnfNodePtr interpreted_node = block->MakeInterpret(new_script_text, global_dict_node, local_dict_node, value_node); + MS_LOG(INFO) << "[" << block->func_graph()->ToString() << "] script_text: `" << new_script_text +- << "`,\nvalue_node: " << value_node->DebugString(recursive_level) ++ << "`,\nvalue_node: " << value_node->DebugString(AnfNode::DebugStringLevel::kLevel2) + << ",\nglobal_dict_node: " << global_dict_node->ToString() +- << ",\nlocal_dict_node: " << local_dict_node->DebugString(recursive_level) +- << ",\ninterpreted_node: " << interpreted_node->DebugString(recursive_level); ++ << ",\nlocal_dict_node: " << local_dict_node->DebugString(AnfNode::DebugStringLevel::kLevel2) ++ << ",\ninterpreted_node: " << interpreted_node->DebugString(AnfNode::DebugStringLevel::kLevel2); + + // Print a hint for user. + auto line_info = trace::GetDebugInfoStr(value_node->debug_info()); +@@ -5093,15 +5092,14 @@ void AttachIsolatedNodes(const FuncGraphPtr &func_graph, const OrderedSet states; + (void)states.emplace_back(NewValueNode(prim::kPrimMakeTuple)); +- constexpr int recursive_level = 2; + for (const auto &node : isolated_nodes) { + MS_EXCEPTION_IF_NULL(node); +- MS_LOG(DEBUG) << "Adding dependency, node: " << node->DebugString(recursive_level) << " in " ++ MS_LOG(DEBUG) << "Adding dependency, node: " << node->DebugString(AnfNode::DebugStringLevel::kLevel2) << " in " + << func_graph->ToString(); + if (node->func_graph() == func_graph) { + (void)states.emplace_back(node); + } else { +- MS_LOG(INFO) << "Ignored FV dependency, node: " << node->DebugString(recursive_level) << " in " ++ MS_LOG(INFO) << "Ignored FV dependency, node: " << node->DebugString(AnfNode::DebugStringLevel::kLevel2) << " in " + << func_graph->ToString(); + } + } +@@ -5147,7 +5145,7 @@ void AttachIsolatedNodes(const FuncGraphPtr &func_graph, const OrderedSetAddAttr(kAttrTopoSortRhsFirst, MakeValue(true)); + MS_EXCEPTION_IF_NULL(state); + MS_LOG(INFO) << "Attached for side-effect nodes, depend_node: " << depend_node->DebugString() +- << ", state: " << state->DebugString(recursive_level); ++ << ", state: " << state->DebugString(AnfNode::DebugStringLevel::kLevel2); + func_graph->set_output(depend_node, true); + // Update new return node's debug_info with old one. + if (return_node != nullptr && return_node->debug_info() != nullptr) { +diff --git a/mindspore/ccsrc/pipeline/jit/ps/parse/resolve.cc b/mindspore/ccsrc/pipeline/jit/ps/parse/resolve.cc +index 6392cf9b12b..386ba8ea1b4 100644 +--- a/mindspore/ccsrc/pipeline/jit/ps/parse/resolve.cc ++++ b/mindspore/ccsrc/pipeline/jit/ps/parse/resolve.cc +@@ -225,8 +225,8 @@ bool HasVariableLenAttr(const py::object &obj) { + AnfNodePtr ConvertInterpretedObjForResolve(const AnfNodePtr &origin_node, const ValuePtr &convert_result, + const FuncGraphPtr &func_graph) { + if (convert_result->isa() && !origin_node->has_user_data("__py_interpret_local_value_flag__")) { +- constexpr auto recursive_level = 2; +- MS_LOG(DEBUG) << "Convert InterpretedObj for resolve, node: " << origin_node->DebugString(recursive_level); ++ MS_LOG(DEBUG) << "Convert InterpretedObj for resolve, node: " ++ << origin_node->DebugString(AnfNode::DebugStringLevel::kLevel2); + auto interpreted_value = dyn_cast(convert_result); + const auto &key = interpreted_value->name(); + if (interpreted_value->has_converted()) { +@@ -602,8 +602,8 @@ std::pair GetNamespaceAndSymbol(const AnfNodePtr &node) + auto symbol = GetValueNode(symbol_node); + return {name_space, symbol}; + } +- constexpr auto recursive_level = 2; +- MS_LOG(INTERNAL_EXCEPTION) << "It's not prim::Resolve CNode, node: " << node->DebugString(recursive_level); ++ MS_LOG(INTERNAL_EXCEPTION) << "It's not prim::Resolve CNode, node: " ++ << node->DebugString(AnfNode::DebugStringLevel::kLevel2); + } + + py::object GetSymbolObject(const NameSpacePtr &name_space, const SymbolPtr &symbol, const AnfNodePtr &node) { +diff --git a/mindspore/ccsrc/pipeline/jit/ps/static_analysis/auto_monad.cc b/mindspore/ccsrc/pipeline/jit/ps/static_analysis/auto_monad.cc +index 505b4e88f44..2105fd31999 100644 +--- a/mindspore/ccsrc/pipeline/jit/ps/static_analysis/auto_monad.cc ++++ b/mindspore/ccsrc/pipeline/jit/ps/static_analysis/auto_monad.cc +@@ -1,5 +1,5 @@ + /** +- * Copyright 2020-2024 Huawei Technologies Co., Ltd ++ * Copyright 2020-2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. +@@ -685,10 +685,10 @@ class SideEffectFinder { + FixSwitchBranch(caller, branch); + // The number of parameter should matched after fix. + if (caller_input_size + extra_input_size != branch->parameters().size()) { +- constexpr auto recursive_count = 2; + MS_LOG_WITH_NODE(INTERNAL_EXCEPTION, caller) +- << "Fix switch branch parameters failed! " << caller->DebugString(recursive_count) +- << ", branch: " << branch->ToString() << ", branch node: " << branch_node->DebugString(recursive_count) ++ << "Fix switch branch parameters failed! " << caller->DebugString(AnfNode::DebugStringLevel::kLevel2) ++ << ", branch: " << branch->ToString() ++ << ", branch node: " << branch_node->DebugString(AnfNode::DebugStringLevel::kLevel2) + << ", size: " << caller_input_size << " + " << extra_input_size << " not equal to " + << branch->parameters().size(); + } +diff --git a/mindspore/ccsrc/pipeline/jit/ps/static_analysis/prim.cc b/mindspore/ccsrc/pipeline/jit/ps/static_analysis/prim.cc +index 6e490441f18..9522acae9ec 100644 +--- a/mindspore/ccsrc/pipeline/jit/ps/static_analysis/prim.cc ++++ b/mindspore/ccsrc/pipeline/jit/ps/static_analysis/prim.cc +@@ -1262,15 +1262,14 @@ EvalResultPtr InterpretGetAttrNode(const AbstractBasePtrList &args_abs_list, con + CheckObjAttrValid(data_type, item_name, data_args); + } + +- constexpr auto debug_recursive_level = 2; + const auto &debug_info = trace::GetSourceCodeDebugInfo(out_node->debug_info()); + if (debug_info == nullptr || debug_info->location() == nullptr) { +- MS_LOG(WARNING) << "Location info is null, node: " << out_node->DebugString(debug_recursive_level); ++ MS_LOG(WARNING) << "Location info is null, node: " << out_node->DebugString(AnfNode::DebugStringLevel::kLevel2); + return nullptr; + } + const auto expr = debug_info->location()->expr_src(); + if (expr.empty()) { +- MS_LOG(WARNING) << "Location's expr is empty, node: " << out_node->DebugString(debug_recursive_level); ++ MS_LOG(WARNING) << "Location's expr is empty, node: " << out_node->DebugString(AnfNode::DebugStringLevel::kLevel2); + } + + constexpr auto item_index = 1; +@@ -1315,9 +1314,8 @@ EvalResultPtr InterpretSetAttrNode(const AbstractBasePtrList &args_abs_list, con + } + auto owner_value = owner_abs->BuildValue(); + auto owner_node = cnode->input(1); +- constexpr auto debug_recursive_level = 2; + MS_EXCEPTION_IF_NULL(owner_value); +- MS_LOG(DEBUG) << "node: " << out_conf->node()->DebugString(debug_recursive_level) ++ MS_LOG(DEBUG) << "node: " << out_conf->node()->DebugString(AnfNode::DebugStringLevel::kLevel2) + << ", owner_value: " << owner_value->ToString(); + if (owner_value->isa()) { + const auto &interpreted_value = dyn_cast(owner_value); +@@ -1356,7 +1354,7 @@ EvalResultPtr InterpretSetAttrNode(const AbstractBasePtrList &args_abs_list, con + + const auto setattr_node = + fallback::CreatePyExecuteCNode(cnode, NewValueNode(script_setattr_str), NewValueNode(key_tuple), value_tuple_node); +- MS_LOG(DEBUG) << "setattr_node: " << setattr_node->DebugString(debug_recursive_level); ++ MS_LOG(DEBUG) << "setattr_node: " << setattr_node->DebugString(AnfNode::DebugStringLevel::kLevel2); + + // Save abstract for getattr. + constexpr auto value_abs_index = 2; +@@ -1745,9 +1743,8 @@ EvalResultPtr GetEvaluatedValueForAttrOrMethodNotInMap(const AnalysisEnginePtr & + << trace::GetDebugInfoStr(out_conf->node()->debug_info()); + } + +- constexpr auto recursive_level = 3; + MS_LOG(DEBUG) << "Evaluate " << data_type->ToString() << " attribute: " << item_name +- << ".\nnode: " << out_conf->node()->DebugString(recursive_level) << "\n" ++ << ".\nnode: " << out_conf->node()->DebugString(AnfNode::DebugStringLevel::kLevel3) << "\n" + << trace::GetDebugInfoStr(out_conf->node()->debug_info()); + auto res = InterpretGetAttrNode(args_abs_list, out_conf); + if (res == nullptr) { +@@ -1964,9 +1961,8 @@ EvalResultPtr StaticGetter(const AnalysisEnginePtr &engine, const AbstractBasePt + MS_EXCEPTION_IF_NULL(item_args); + MS_EXCEPTION_IF_NULL(out_conf); + MS_EXCEPTION_IF_NULL(out_conf->node()); +- constexpr auto recursive_level = 2; + MS_LOG(DEBUG) << "StaticGetter, data: " << data_args->ToString() << ", item: " << item_args->ToString() +- << ", node: " << out_conf->node()->DebugString(recursive_level); ++ << ", node: " << out_conf->node()->DebugString(AnfNode::DebugStringLevel::kLevel2); + ScopePtr scope = out_conf->node()->scope(); + ScopeGuard scope_guard(scope); + ValuePtr item_value = item_args->BuildValue(); +@@ -2284,10 +2280,9 @@ EvalResultPtr PrimitiveArgsToInputsEvaluator::EvalPrim(const AnalysisEnginePtr & + std::back_inserter(getattr_inputs)); + new_node = ConvertArgsToInputs(prim_, getattr_inputs, fg, engine, out_conf); + } else { +- constexpr int recursive_level = 2; + new_node = ConvertArgsToInputs(prim_, cnode->weak_inputs(), fg, engine, out_conf); + MS_LOG(DEBUG) << "Convert args to inputs for Operator[" << prim_->name() +- << "], node: " << cnode->DebugString(recursive_level); ++ << "], node: " << cnode->DebugString(AnfNode::DebugStringLevel::kLevel2); + } + + new_node->set_debug_info(cnode->debug_info()); +@@ -2487,10 +2482,10 @@ EvalResultPtr PrimInstanceEvaluator::EvalPrim(const AnalysisEnginePtr &engine, c + + auto new_cnode = fg->NewCNodeInOrder(new_inputs); + auto new_conf = engine->MakeConfig(new_cnode, out_conf->context(), out_conf->func_graph()); +- constexpr auto recursive_level = 2; +- MS_LOG(DEBUG) << "For Primitive[" << prim_name_ << "], using old node " << cnode->DebugString(recursive_level) +- << " and instance node " << partial_cnode->DebugString(recursive_level) << "to create new node " +- << new_cnode->DebugString(recursive_level); ++ MS_LOG(DEBUG) << "For Primitive[" << prim_name_ << "], using old node " ++ << cnode->DebugString(AnfNode::DebugStringLevel::kLevel2) << " and instance node " ++ << partial_cnode->DebugString(AnfNode::DebugStringLevel::kLevel2) << "to create new node " ++ << new_cnode->DebugString(AnfNode::DebugStringLevel::kLevel2); + return engine->ForwardConfig(out_conf, new_conf); + } + +@@ -2538,9 +2533,9 @@ EvalResultPtr FunctionalEvaluator::EvalPrim(const AnalysisEnginePtr &engine, con + }; + new_cnode = prim::ConvertFunctionalToPrimitive(name_, inputs_list, args_abs_list, cnode, eval_func, is_method_); + } +- constexpr auto debug_recursive_level = 2; +- MS_LOG(DEBUG) << "Convert Functional[" << name_ << "]. Origin cnode: " << cnode->DebugString(debug_recursive_level) +- << ", new cnode: " << new_cnode->DebugString(debug_recursive_level); ++ MS_LOG(DEBUG) << "Convert Functional[" << name_ ++ << "]. Origin cnode: " << cnode->DebugString(AnfNode::DebugStringLevel::kLevel2) ++ << ", new cnode: " << new_cnode->DebugString(AnfNode::DebugStringLevel::kLevel2); + auto fn_conf = engine->MakeConfig(new_cnode, out_conf->context(), out_conf->func_graph()); + return engine->ForwardConfig(out_conf, fn_conf); + } +diff --git a/mindspore/ccsrc/pipeline/jit/ps/static_analysis/program_specialize.cc b/mindspore/ccsrc/pipeline/jit/ps/static_analysis/program_specialize.cc +index 88c70f6fc58..f8fc9caa7be 100644 +--- a/mindspore/ccsrc/pipeline/jit/ps/static_analysis/program_specialize.cc ++++ b/mindspore/ccsrc/pipeline/jit/ps/static_analysis/program_specialize.cc +@@ -118,10 +118,9 @@ EvalResultPtr GetEvalResult(const AnfNodeConfigPtr &conf) { + MS_EXCEPTION_IF_NULL(eval_result); + return eval_result; + } catch (const std::exception &e) { +- constexpr int recursive_level = 2; + static const bool enable_pre_lift = (common::GetCompileConfig("PRE_LIFT") == "1"); + if (enable_pre_lift && IsPrimitiveCNode(conf->node(), prim::kPrimPartial)) { +- MS_LOG(ERROR) << "node: " << conf->node()->DebugString(recursive_level); ++ MS_LOG(ERROR) << "node: " << conf->node()->DebugString(AnfNode::DebugStringLevel::kLevel2); + auto abs_res = std::make_shared(); + auto eval_result = std::make_shared(abs_res, std::make_shared()); + return eval_result; +@@ -187,17 +186,16 @@ bool CanSpecializeValueNode(const AnfNodePtr &node) { + + void PurifyAbstractOfSequence(ProgramSpecializer *const specializer) { + MS_EXCEPTION_IF_NULL(specializer); +- constexpr int recursive_level = 2; + for (auto &abstract_and_node : specializer->sequence_abstract_list()) { + auto &sequence_abs = abstract_and_node.first; + MS_EXCEPTION_IF_NULL(sequence_abs); + MS_EXCEPTION_IF_NULL(abstract_and_node.second); + if (!sequence_abs->PurifyElements()) { + MS_LOG(INFO) << "Purify elements failed, abstract: " << sequence_abs->ToString() +- << ", node: " << abstract_and_node.second->DebugString(recursive_level); ++ << ", node: " << abstract_and_node.second->DebugString(AnfNode::DebugStringLevel::kLevel2); + } else { + MS_LOG(DEBUG) << "Purify elements, abstract: " << sequence_abs->ToString() +- << ", node: " << abstract_and_node.second->DebugString(recursive_level); ++ << ", node: " << abstract_and_node.second->DebugString(AnfNode::DebugStringLevel::kLevel2); + } + } + } +@@ -233,8 +231,8 @@ void EliminateCollectedSequenceNodes(ProgramSpecializer *const specializer) { + continue; + } + +- constexpr int recursive_level = 2; +- MS_LOG(DEBUG) << "Erase elements[" << pos << "] DeadNode as zero for " << cnode->DebugString(recursive_level); ++ MS_LOG(DEBUG) << "Erase elements[" << pos << "] DeadNode as zero for " ++ << cnode->DebugString(AnfNode::DebugStringLevel::kLevel2); + // Change the node. + auto zero_value = NewValueNode(MakeValue(0)); + zero_value->set_abstract( +@@ -246,7 +244,7 @@ void EliminateCollectedSequenceNodes(ProgramSpecializer *const specializer) { + auto sequence_abs = dyn_cast_ptr(node->abstract()); + if (sequence_abs != nullptr && !sequence_abs->PurifyElements()) { + MS_LOG(ERROR) << "Purify elements failed, abstract: " << sequence_abs->ToString() +- << ", node: " << node->DebugString(recursive_level); ++ << ", node: " << node->DebugString(AnfNode::DebugStringLevel::kLevel2); + } + continue; + } +@@ -273,9 +271,8 @@ void EliminateCollectedSequenceNodes(ProgramSpecializer *const specializer) { + (*flags)[pos] = false; // Change the use flag as 0. + auto sequence_abs = dyn_cast_ptr(node->abstract()); + if (sequence_abs != nullptr && !sequence_abs->PurifyElements()) { +- constexpr int recursive_level = 2; + MS_LOG(ERROR) << "Purify elements failed, abstract: " << sequence_abs->ToString() +- << ", node: " << node->DebugString(recursive_level); ++ << ", node: " << node->DebugString(AnfNode::DebugStringLevel::kLevel2); + } + } + } +@@ -549,9 +546,8 @@ AnfNodePtr FuncGraphSpecializer::ReplicateDisconnectedNode(const AnfNodePtr &nod + } + std::shared_ptr specializer = GetTopSpecializer(node); + if (specializer == nullptr) { +- constexpr auto recursive_level = 2; +- MS_LOG(INTERNAL_EXCEPTION) << "Specializer should not be null, node: " << node->DebugString(recursive_level) +- << ", NodeInfo: \n" ++ MS_LOG(INTERNAL_EXCEPTION) << "Specializer should not be null, node: " ++ << node->DebugString(AnfNode::DebugStringLevel::kLevel2) << ", NodeInfo: \n" + << trace::GetDebugInfoStr(node->debug_info()) << "\n" + << (func_graph_ ? func_graph_->ToString() : "FG(Null)") << " has no parent context?"; + } +@@ -613,9 +609,8 @@ void FuncGraphSpecializer::UpdateNewCNodeInputs(const AnfNodePtr &node, const An + AnfNodePtr FuncGraphSpecializer::GetReplicatedNode(const AnfNodePtr &node) { + std::shared_ptr specializer = GetTopSpecializer(node); + if (specializer == nullptr) { +- constexpr auto recursive_level = 2; +- MS_LOG(INTERNAL_EXCEPTION) << "Specializer should not be null, node: " << node->DebugString(recursive_level) +- << ", NodeInfo: \n" ++ MS_LOG(INTERNAL_EXCEPTION) << "Specializer should not be null, node: " ++ << node->DebugString(AnfNode::DebugStringLevel::kLevel2) << ", NodeInfo: \n" + << trace::GetDebugInfoStr(node->debug_info()) << "\n" + << (func_graph_ ? func_graph_->ToString() : "FG(Null)") << " has no parent context?"; + } +@@ -648,8 +643,8 @@ std::shared_ptr FuncGraphSpecializer::GetTopSpecializer(co + << ", NodeInfo: " << trace::GetDebugInfoStr(node->debug_info()); + specializer = specializer_->GetFuncGraphSpecializer(top_context); + if (specializer == nullptr) { +- constexpr auto recursive_level = 2; +- MS_LOG(INTERNAL_EXCEPTION) << "Specializer must not be null, node: " << node->DebugString(recursive_level) ++ MS_LOG(INTERNAL_EXCEPTION) << "Specializer must not be null, node: " ++ << node->DebugString(AnfNode::DebugStringLevel::kLevel2) + << ", NodeInfo: " << trace::GetDebugInfoStr(node->debug_info()); + } + } else { +@@ -1058,12 +1053,11 @@ void FuncGraphSpecializer::EliminateUnusedSequenceItem(const CNodePtr &cnode) co + auto zero_value = NewValueNode(MakeValue(0)); + zero_value->set_abstract(std::make_shared(std::make_shared(0))); + (void)inputs.emplace_back(zero_value); +- constexpr int recursive_level = 2; +- MS_LOG(DEBUG) << "Erase elements[" << i << "] as zero for " << cnode->DebugString(recursive_level); ++ MS_LOG(DEBUG) << "Erase elements[" << i << "] as zero for " ++ << cnode->DebugString(AnfNode::DebugStringLevel::kLevel2); + } else if (IsDeadNode(old_input)) { +- constexpr int recursive_level = 2; + MS_LOG(DEBUG) << "Collect for erasing elements[" << i << "] DeadNode as zero for " << cnode << "/" +- << cnode->DebugString(recursive_level); ++ << cnode->DebugString(AnfNode::DebugStringLevel::kLevel2); + (void)specializer_->dead_node_list().emplace_back(std::pair(cnode, i)); + (void)inputs.emplace_back(old_input); + } else { +@@ -1293,14 +1287,14 @@ AnfNodePtr FuncGraphSpecializer::BuildSpecializedNode(const CNodePtr &cnode, con + const auto err_dead_value = std::make_shared(ValueProblemType::kDead); + const auto err_dead_abstract = std::make_shared(err_dead_value, func); + specialized_node = BuildValueNode(err_dead_value, cnode, err_dead_abstract); +- constexpr auto recursive_level = 2; +- MS_LOG(DEBUG) << "DEAD for func: " << func->DebugString(recursive_level) << ", abstract: " << abs->ToString(); ++ MS_LOG(DEBUG) << "DEAD for func: " << func->DebugString(AnfNode::DebugStringLevel::kLevel2) ++ << ", abstract: " << abs->ToString(); + } else if (errcode == kSpecializePoly) { + const auto error_poly_value = std::make_shared(ValueProblemType::kPoly); + const auto error_poly_abstract = std::make_shared(error_poly_value, func); + specialized_node = BuildValueNode(error_poly_value, cnode, error_poly_abstract); +- constexpr auto recursive_level = 2; +- MS_LOG(DEBUG) << "POLY for func: " << func->DebugString(recursive_level) << ", abstract: " << abs->ToString(); ++ MS_LOG(DEBUG) << "POLY for func: " << func->DebugString(AnfNode::DebugStringLevel::kLevel2) ++ << ", abstract: " << abs->ToString(); + } else { + MS_LOG(INTERNAL_EXCEPTION) << "Failed to build specialized func, func: " << func->DebugString() + << ", abstract: " << abs->ToString(); +@@ -1376,10 +1370,9 @@ AnfNodePtr FuncGraphSpecializer::BuildSpecializedNodeInner(const CNodePtr &cnode + } + } + +- constexpr auto recursive_level = 2; + MS_LOG(DEBUG) << "Specialize function graph: " << context->func_graph()->ToString() << ", args: " << args_abs_list +- << ", func: " << func->DebugString(recursive_level) << ", context: " << context.get() << ", " +- << context->ToString(); ++ << ", func: " << func->DebugString(AnfNode::DebugStringLevel::kLevel2) << ", context: " << context.get() ++ << ", " << context->ToString(); + MS_EXCEPTION_IF_NULL(context->func_graph()); + if (context->func_graph()->stub()) { + MS_EXCEPTION_IF_NULL(context->func_graph()->get_return()); +@@ -1677,9 +1670,8 @@ void FuncGraphSpecializer::ProcessCNodeEnd(const CNodePtr &cnode, const AnfNodeW + if (enable_eliminate_unused_element && !enable_only_mark_unused_element) { + EliminateUnusedSequenceItem(cnode); + } +- constexpr auto recursive_level = 2; + // Only success processed node can be added to seen. +- MS_LOG(DEBUG) << "New CNode: " << cnode->DebugString(recursive_level); ++ MS_LOG(DEBUG) << "New CNode: " << cnode->DebugString(AnfNode::DebugStringLevel::kLevel2); + specializer_->AddSeen(cnode); + } + +@@ -1802,8 +1794,7 @@ bool FuncGraphSpecializer::ProcessCNode(const CNodePtr &cnode) { + if (specializer_->seen().count(cnode) > 0) { + return true; + } +- constexpr auto recursive_level = 2; +- MS_LOG(DEBUG) << "Handle CNode: " << cnode->DebugString(recursive_level); ++ MS_LOG(DEBUG) << "Handle CNode: " << cnode->DebugString(AnfNode::DebugStringLevel::kLevel2); + auto new_inputs = GetCNodeRealInputs(cnode); + const AnfNodePtr &func = new_inputs[0].lock(); + +@@ -1833,7 +1824,7 @@ bool FuncGraphSpecializer::ProcessCNode(const CNodePtr &cnode) { + return false; + } + MS_LOG(DEBUG) << "Partial closure or parameter call is handled, wrapped_node: " +- << wrapped_node->DebugString(recursive_level); ++ << wrapped_node->DebugString(AnfNode::DebugStringLevel::kLevel2); + new_inputs[0] = wrapped_node; + cnode->func_graph()->AddOwnNode(wrapped_node); + } +@@ -1861,8 +1852,10 @@ bool FuncGraphSpecializer::ProcessCNode(const CNodePtr &cnode) { + + new_inputs[0] = specialized_func_node; + cnode->func_graph()->AddOwnNode(specialized_func_node); +- MS_LOG(DEBUG) << "Specalize func: " << func->type_name() << "/" << func->DebugString(recursive_level) +- << ", new_func: " << new_inputs[0].lock()->DebugString(recursive_level) << ", args: " << args; ++ MS_LOG(DEBUG) << "Specalize func: " << func->type_name() << "/" ++ << func->DebugString(AnfNode::DebugStringLevel::kLevel2) ++ << ", new_func: " << new_inputs[0].lock()->DebugString(AnfNode::DebugStringLevel::kLevel2) ++ << ", args: " << args; + } + } + +@@ -1875,8 +1868,8 @@ bool FuncGraphSpecializer::ProcessCNode(const CNodePtr &cnode) { + return false; + } + +- MS_LOG(DEBUG) << "Specalize arg[" << i << "]: " << old_node->DebugString(recursive_level) +- << ", new_node: " << new_node->DebugString(recursive_level); ++ MS_LOG(DEBUG) << "Specalize arg[" << i << "]: " << old_node->DebugString(AnfNode::DebugStringLevel::kLevel2) ++ << ", new_node: " << new_node->DebugString(AnfNode::DebugStringLevel::kLevel2); + new_inputs[i] = new_node; + cnode->func_graph()->AddOwnNode(new_node); + } +diff --git a/mindspore/ccsrc/pipeline/jit/ps/static_analysis/static_analysis.cc b/mindspore/ccsrc/pipeline/jit/ps/static_analysis/static_analysis.cc +index a28d65614bc..1edd77eb9d6 100644 +--- a/mindspore/ccsrc/pipeline/jit/ps/static_analysis/static_analysis.cc ++++ b/mindspore/ccsrc/pipeline/jit/ps/static_analysis/static_analysis.cc +@@ -1,7 +1,7 @@ + /** + * This is the C++ adaptation and derivative work of Myia (https://github.com/mila-iqia/myia/). + * +- * Copyright 2019-2024 Huawei Technologies Co., Ltd ++ * Copyright 2019-2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. +@@ -848,9 +848,8 @@ EvalResultPtr AnalysisEngine::InterpretedNodeCall(const CNodePtr &cnode, const A + // Check if the operator input is PyExecute CNode. + const auto &func_node = cnode->input(0); + MS_EXCEPTION_IF_NULL(func_node); +- constexpr auto recursive_level = 2; +- MS_LOG(DEBUG) << "Current CNode: " << cnode->DebugString(recursive_level) +- << ", func_node: " << func_node->DebugString(recursive_level); ++ MS_LOG(DEBUG) << "Current CNode: " << cnode->DebugString(AnfNode::DebugStringLevel::kLevel2) ++ << ", func_node: " << func_node->DebugString(AnfNode::DebugStringLevel::kLevel2); + auto prim = GetCNodePrimitiveWithoutDoSignature(func_node); + if (!IsPrimitiveEquals(prim, prim::kPrimResolve) && !IsPrimitiveEquals(prim, prim::kPrimGetAttr) && + !IsPrimitiveEquals(prim, prim::kPrimPyExecute) && !IsPrimitiveEquals(prim, prim::kPrimPyInterpret)) { +@@ -1586,14 +1585,13 @@ FuncGraphPtr GetFuncGraphFromBranchNode(const AnfNodePtr &branch_node) { + + std::string JoinBranchesFailedInfo(const AbstractBasePtr &abs, const AbstractBasePtr &last_out_abs, + const AnfNodePtr &node, const std::string &error_info) { +- constexpr int recursive_level = 2; + std::ostringstream buffer; + buffer << "Cannot join the return values of different branches, perhaps you need to make them equal.\n" + << error_info + << "#dmsg#Framework Error Message:#dmsg#The abstract type of the return value of the current branch is:\n" + << abs->ToString() << ",\n and that of the previous branch is:\n" + << last_out_abs->ToString() << ".\n" +- << "The node is " << node->DebugString(recursive_level); ++ << "The node is " << node->DebugString(AnfNode::DebugStringLevel::kLevel2); + if (!node->isa()) { + buffer << "\n"; + return buffer.str(); +diff --git a/mindspore/ccsrc/pipeline/jit/ps/static_analysis/static_analysis.h b/mindspore/ccsrc/pipeline/jit/ps/static_analysis/static_analysis.h +index 3d0de99a47c..ea67e2c2b31 100644 +--- a/mindspore/ccsrc/pipeline/jit/ps/static_analysis/static_analysis.h ++++ b/mindspore/ccsrc/pipeline/jit/ps/static_analysis/static_analysis.h +@@ -1,7 +1,7 @@ + /** + * This is the C++ adaptation and derivative work of Myia (https://github.com/mila-iqia/myia/). + * +- * Copyright 2019-2023 Huawei Technologies Co., Ltd ++ * Copyright 2019-2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. +@@ -147,11 +147,10 @@ class AnfNodeConfig final : public Config { + + std::string ToString() const override { + std::ostringstream buffer; +- constexpr int recursive_level = 2; + buffer << "Node: " << node_ << "/" +- << (node_ == nullptr +- ? "null" +- : node_->DebugString(recursive_level) + std::string("-uid(") + node_->UniqueId() + std::string(")")) ++ << (node_ == nullptr ? "null" ++ : node_->DebugString(AnfNode::DebugStringLevel::kLevel2) + std::string("-uid(") + ++ node_->UniqueId() + std::string(")")) + << ", Context: " << context_ << "/" << (context_ == nullptr ? "null" : context_->ToString()) + << ", FuncGraph: " << func_graph_ << "/" << (func_graph_ == nullptr ? "null" : func_graph_->ToString()); + return buffer.str(); +diff --git a/mindspore/ccsrc/pipeline/jit/ps/validator.cc b/mindspore/ccsrc/pipeline/jit/ps/validator.cc +index bc34dae6538..4120cbbebb6 100644 +--- a/mindspore/ccsrc/pipeline/jit/ps/validator.cc ++++ b/mindspore/ccsrc/pipeline/jit/ps/validator.cc +@@ -284,10 +284,12 @@ void ValidateScope(const AnfNodePtr &node, const std::string &pass_name) { + return; + } + if (node->scope() == nullptr || node->scope() == kDefaultScope) { +- MS_LOG(ERROR) << "In " << pass_name << ", failed to find scope for node " << node->DebugString(2); ++ MS_LOG(ERROR) << "In " << pass_name << ", failed to find scope for node " ++ << node->DebugString(AnfNode::DebugStringLevel::kLevel2); + } + if (node->scope() == kDefaultScopeUnderGuard) { +- MS_LOG(INFO) << "In " << pass_name << ", encounter kDefaultScopeUnderGuard for node: " << node->DebugString(2); ++ MS_LOG(INFO) << "In " << pass_name << ", encounter kDefaultScopeUnderGuard for node: " ++ << node->DebugString(AnfNode::DebugStringLevel::kLevel2); + } + } + +diff --git a/mindspore/ccsrc/plugin/device/cpu/hal/hardware/cpu_device_context.cc b/mindspore/ccsrc/plugin/device/cpu/hal/hardware/cpu_device_context.cc +index be599fecf41..a068c9a796b 100644 +--- a/mindspore/ccsrc/plugin/device/cpu/hal/hardware/cpu_device_context.cc ++++ b/mindspore/ccsrc/plugin/device/cpu/hal/hardware/cpu_device_context.cc +@@ -1,5 +1,5 @@ + /** +- * Copyright 2021-2023 Huawei Technologies Co., Ltd ++ * Copyright 2021-2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. +@@ -190,10 +190,9 @@ void SetCpuRefMapToKernelInfo(const CNodePtr &apply_kernel, const std::vectorfullname_with_scope() << " does not support this kernel data type: " << build_info->ToString() +- << ", node debug name: " << apply_kernel->DebugString(recursive_level); ++ << ", node debug name: " << apply_kernel->DebugString(AnfNode::DebugStringLevel::kLevel2); + } + + auto kernel_info = dynamic_cast(apply_kernel->kernel_info()); +@@ -512,9 +511,8 @@ void CPUKernelExecutor::SetOperatorInfo(const KernelGraphPtr &graph) const { + }; + auto expand_ret = expander::TryExpandCNode(node, f); + if (!expand_ret) { +- constexpr auto recursive_level = 2; + MS_EXCEPTION(etype) << "#umsg#Kernel select failed:#umsg#" << msg +- << "\nnode: " << node->DebugString(recursive_level); ++ << "\nnode: " << node->DebugString(AnfNode::DebugStringLevel::kLevel2); + } + MS_LOG(INFO) << msg << " but expand success."; + do_expand = true; +diff --git a/mindspore/ccsrc/runtime/graph_scheduler/actor/actor_dump.cc b/mindspore/ccsrc/runtime/graph_scheduler/actor/actor_dump.cc +index 4c1e02d09a4..cb20b5a50c1 100644 +--- a/mindspore/ccsrc/runtime/graph_scheduler/actor/actor_dump.cc ++++ b/mindspore/ccsrc/runtime/graph_scheduler/actor/actor_dump.cc +@@ -1,5 +1,5 @@ + /** +- * Copyright 2021-2022 Huawei Technologies Co., Ltd ++ * Copyright 2021-2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. +@@ -1288,7 +1288,7 @@ void FetchGraphParameterStore(const AbstractActor *const actor, ActorInputMap *a + for (const auto ¶meter_index : actor->parameter_indexs()) { + auto index = parameter_index.first; + auto parameter_info = parameter_index.second; +- input_name += parameter_info.first.first->DebugString(0); ++ input_name += parameter_info.first.first->DebugString(AnfNode::DebugStringLevel::kLevel0); + if (actor_inputs->find(index) != actor_inputs->end()) { + MS_LOG(INFO) << "Invalid index:" << index << " for actor:" << actor->GetAID() + << " input aid:" << parameter_info.first.first->DebugString() +@@ -1310,7 +1310,7 @@ void FetchInputDeviceTensorStore(const AnfNodePtr &key, size_t index, const Abst + MS_EXCEPTION_IF_NULL(actor_inputs); + std::string input_name = "%"; + if (key->isa()) { +- input_name += key->DebugString(0); ++ input_name += key->DebugString(AnfNode::DebugStringLevel::kLevel0); + } else if (key->isa()) { + const auto &value_node = key->cast(); + MS_EXCEPTION_IF_NULL(value_node); +@@ -1351,7 +1351,7 @@ void FetchInputForHostQueueDSActor(AbstractActor *actor, ActorInputMap *actor_in + continue; + } + auto kernel_tensor = AnfAlgo::GetOutputKernelTensor(node_pair.first, node_pair.second, false); +- (*actor_inputs)[i] = {node_pair.first->DebugString(0), kernel_tensor}; ++ (*actor_inputs)[i] = {node_pair.first->DebugString(AnfNode::DebugStringLevel::kLevel0), kernel_tensor}; + } + } + +diff --git a/mindspore/ccsrc/runtime/graph_scheduler/control_node_parser.cc b/mindspore/ccsrc/runtime/graph_scheduler/control_node_parser.cc +index 8f4185fc113..d0e97a064fc 100644 +--- a/mindspore/ccsrc/runtime/graph_scheduler/control_node_parser.cc ++++ b/mindspore/ccsrc/runtime/graph_scheduler/control_node_parser.cc +@@ -1,5 +1,5 @@ + /** +- * Copyright 2021 Huawei Technologies Co., Ltd ++ * Copyright 2021-2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. +@@ -45,7 +45,6 @@ + namespace mindspore { + namespace runtime { + namespace { +-constexpr auto kDebugStrDepthTwo = 2; + // Check if node is a value node need to create a device tensor. + bool IsFrontValueNode(const KernelWithIndex &node_with_index) { + const auto &node = node_with_index.first; +@@ -3051,7 +3050,7 @@ void ControlNodeParser::PrintParseInfo() { + if (input_pair.first.first != nullptr) { + MS_LOG(WARNING) << "Kernel graph group:" << group->group_name_ + << " input node:" << input_pair.first.first->fullname_with_scope() +- << " debug string:" << input_pair.first.first->DebugString(kDebugStrDepthTwo) ++ << " debug string:" << input_pair.first.first->DebugString(AnfNode::DebugStringLevel::kLevel2) + << " index:" << input_pair.first.second; + } + } +@@ -3059,10 +3058,10 @@ void ControlNodeParser::PrintParseInfo() { + if (output_pair.first.first != nullptr && output_pair.second.first.first != nullptr) { + MS_LOG(WARNING) << "Kernel graph group:" << group->group_name_ + << " output node:" << output_pair.first.first->fullname_with_scope() +- << " debug string:" << output_pair.first.first->DebugString(kDebugStrDepthTwo) ++ << " debug string:" << output_pair.first.first->DebugString(AnfNode::DebugStringLevel::kLevel2) + << " index:" << output_pair.first.second +- << " backend node:" << output_pair.second.first.first->fullname_with_scope() +- << " debug string:" << output_pair.second.first.first->DebugString(kDebugStrDepthTwo) ++ << " backend node:" << output_pair.second.first.first->fullname_with_scope() << " debug string:" ++ << output_pair.second.first.first->DebugString(AnfNode::DebugStringLevel::kLevel2) + << " index:" << output_pair.second.first.second; + } + } +@@ -3070,17 +3069,17 @@ void ControlNodeParser::PrintParseInfo() { + for (const auto &f_to_b : front_to_backend_kernels_) { + if (f_to_b.first.first != nullptr && f_to_b.second.first.first != nullptr) { + MS_LOG(WARNING) << "Front to backend map front node:" << f_to_b.first.first->fullname_with_scope() +- << " debug string:" << f_to_b.first.first->DebugString(kDebugStrDepthTwo) ++ << " debug string:" << f_to_b.first.first->DebugString(AnfNode::DebugStringLevel::kLevel2) + << " index:" << f_to_b.first.second + << " backend node:" << f_to_b.second.first.first->fullname_with_scope() +- << " debug string:" << f_to_b.second.first.first->DebugString(kDebugStrDepthTwo) ++ << " debug string:" << f_to_b.second.first.first->DebugString(AnfNode::DebugStringLevel::kLevel2) + << " index:" << f_to_b.second.first.second; + } + } + for (const auto &pair : front_node_to_kernel_graph_) { + if (pair.first != nullptr && pair.second != nullptr) { + MS_LOG(WARNING) << "Front node:" << pair.first->fullname_with_scope() +- << " debug string:" << pair.first->DebugString(kDebugStrDepthTwo) ++ << " debug string:" << pair.first->DebugString(AnfNode::DebugStringLevel::kLevel2) + << " to kernel graph:" << pair.second->ToString(); + } + } +diff --git a/mindspore/ccsrc/runtime/graph_scheduler/control_node_scheduler.cc b/mindspore/ccsrc/runtime/graph_scheduler/control_node_scheduler.cc +index 571db58b064..82aa0ef9834 100644 +--- a/mindspore/ccsrc/runtime/graph_scheduler/control_node_scheduler.cc ++++ b/mindspore/ccsrc/runtime/graph_scheduler/control_node_scheduler.cc +@@ -1,5 +1,5 @@ + /** +- * Copyright 2021 Huawei Technologies Co., Ltd ++ * Copyright 2021-2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. +@@ -2704,7 +2704,7 @@ void GetInputNameForControlActor(AbstractActor *const actor, std::maplocal_kernel_tensors()) { + MS_EXCEPTION_IF_NULL(pair.second.second); +- std::string name = pair.second.second->DebugString(0); ++ std::string name = pair.second.second->DebugString(AnfNode::DebugStringLevel::kLevel0); + if (pair.second.second->isa()) { + name = GetValueNodeName(pair.second.second->cast()); + } +@@ -2738,7 +2738,7 @@ void GetAllInputByArrow(AbstractActor *const actor, + name = input_actor->input_data_arrow_aids()[0].first.Name(); + } else if (input_actor->device_tensor_store_keys().size() == 1 && + input_actor->device_tensor_store_keys()[0].second != nullptr) { +- name = input_actor->device_tensor_store_keys()[0].second->DebugString(0); ++ name = input_actor->device_tensor_store_keys()[0].second->DebugString(AnfNode::DebugStringLevel::kLevel0); + } + } + GetNameForStubActor(actor, pair.second, &name, &index); +@@ -2755,7 +2755,7 @@ void GetAllInputByStore(AbstractActor *const actor, std::map + // Get all inputs by device tensor store. + for (const auto &pair : actor->device_tensor_store_keys()) { + MS_EXCEPTION_IF_NULL(pair.second); +- std::string name = pair.second->DebugString(0); ++ std::string name = pair.second->DebugString(AnfNode::DebugStringLevel::kLevel0); + if (pair.second->isa()) { + name = GetValueNodeName(pair.second->cast()); + } +@@ -2765,7 +2765,7 @@ void GetAllInputByStore(AbstractActor *const actor, std::map + // Get all inputs by parameter store. + for (const auto &pair : actor->parameter_indexs()) { + MS_EXCEPTION_IF_NULL(pair.second.first.first); +- std::string name = pair.second.first.first->DebugString(0); ++ std::string name = pair.second.first.first->DebugString(AnfNode::DebugStringLevel::kLevel0); + (*input_aids)[pair.first] = {name, 0}; + *max_index = (*max_index > pair.first ? *max_index : pair.first); + } +@@ -2785,7 +2785,8 @@ std::map GetInputName(AbstractActor *const actor, const Contr + for (size_t i = 0; i < entrance_actor->formal_parameters().size(); ++i) { + const auto &formal_parameter = entrance_actor->formal_parameters()[i]; + MS_EXCEPTION_IF_NULL(formal_parameter.first); +- input_aids[i] = {formal_parameter.first->DebugString(0), formal_parameter.second}; ++ input_aids[i] = {formal_parameter.first->DebugString(AnfNode::DebugStringLevel::kLevel0), ++ formal_parameter.second}; + } + return input_aids; + } +diff --git a/mindspore/ccsrc/utils/utils.cc b/mindspore/ccsrc/utils/utils.cc +index 9307047a50f..59e89344f5f 100644 +--- a/mindspore/ccsrc/utils/utils.cc ++++ b/mindspore/ccsrc/utils/utils.cc +@@ -332,9 +332,10 @@ bool IsMemoryPoolRecycle() { + static bool optimize_mem = !common::IsDisableAllocConfig(common::kAllocMemoryRecycle); + static bool disable_ge_kernel = IsDisableGeKernel(); + auto context_ptr = MsContext::GetInstance(); +- auto mode = context_ptr->get_param(MS_CTX_EXECUTION_MODE); ++ MS_EXCEPTION_IF_NULL(context_ptr); ++ auto is_ge = context_ptr->GetBackend() == kBackendGE; + auto task_sink = context_ptr->get_param(MS_CTX_ENABLE_TASK_SINK); +- return disable_ge_kernel && optimize_mem && mode == kGraphMode && task_sink; ++ return disable_ge_kernel && optimize_mem && is_ge && task_sink; + } + + bool IsEnableGraphPipeline() { +diff --git a/mindspore/core/include/ir/anf.h b/mindspore/core/include/ir/anf.h +index 2f0aa86070b..e6e72c98e64 100644 +--- a/mindspore/core/include/ir/anf.h ++++ b/mindspore/core/include/ir/anf.h +@@ -211,11 +211,34 @@ class MS_CORE_API AnfNode : public Base { + /// \return The unique name of this AnfNode. + std::string UniqueName(); + ++ enum class DebugStringLevel : int { ++ kLevel0 = 0, ++ kLevel1 = 1, ++ kLevel2 = 2, ++ kLevel3 = 3, ++ kLevel4 = 4, ++ kLevel5 = 5, ++ kLevel6 = 6, ++ kLevel7 = 7, ++ kLevel8 = 8, ++ kLevel9 = 9, ++ kLevel10 = 10, ++ kLevelMax ++ }; ++ ++ friend constexpr DebugStringLevel operator-(DebugStringLevel level, int value) { ++ int raw = static_cast(level) - value; ++ constexpr int level_max = static_cast(DebugStringLevel::kLevelMax); ++ MS_EXCEPTION_IF_CHECK_FAIL((raw >= 0 && raw < level_max), ++ "Debug level out of range [0, " + std::to_string(level_max) + ")."); ++ return static_cast(raw); ++ } ++ + /// \brief Obtain the display information of this AnfNode. + /// + /// \param[in] recursive_level Recursion level when displayed. + /// \return Information to be displayed. +- virtual std::string DebugString(int recursive_level = 1) const; ++ virtual std::string DebugString(DebugStringLevel recursive_level = DebugStringLevel::kLevel1) const; + + /// \brief Obtain the display information of this AnfNode. + /// +@@ -434,7 +457,8 @@ class MS_CORE_API CNode final : public AnfNode, public EffectInfoHolder { + /// \param[in] full_name The fullname_with_scope. + void set_fullname_with_scope(const std::string full_name); + +- std::string DebugString(int recursive_level = 1) const override; ++ std::string DebugString( ++ AnfNode::DebugStringLevel recursive_level = AnfNode::DebugStringLevel::kLevel1) const override; + std::string DebugString(bool recursive) const override; + + /// \brief Set in_forward_flag for this CNode. +@@ -672,7 +696,8 @@ class MS_CORE_API Parameter final : public ANode { + MS_DECLARE_PARENT(Parameter, ANode); + + void accept(AnfIrVisitor *v) override; +- std::string DebugString(int recursive_level = 1) const override; ++ std::string DebugString( ++ AnfNode::DebugStringLevel recursive_level = AnfNode::DebugStringLevel::kLevel1) const override; + + /// \brief Get the name of this Parameter. + /// +@@ -927,7 +952,8 @@ class MS_CORE_API ValueNode final : public ANode { + void set_used_graph_count(size_t used_graph_count); + + std::string ToString() const override; +- std::string DebugString(int recursive_level = 1) const override; ++ std::string DebugString( ++ AnfNode::DebugStringLevel recursive_level = AnfNode::DebugStringLevel::kLevel1) const override; + std::string DebugString(bool recursive) const override; + + bool operator==(const AnfNode &other) const override; +diff --git a/mindspore/core/include/utils/phase.h b/mindspore/core/include/utils/phase.h +index 7e04e619745..0fd02af7030 100644 +--- a/mindspore/core/include/utils/phase.h ++++ b/mindspore/core/include/utils/phase.h +@@ -20,6 +20,7 @@ + #include + #include + #include ++#include + #include "mindapi/base/macros.h" + + namespace mindspore { +@@ -51,22 +52,33 @@ class MS_CORE_API PhaseManager { + void ClearPhase() { phase_ = ""; } + + /// \brief Clear jit_config. +- void ClearJitConfig() { jit_config_.clear(); } ++ void ClearJitConfig(); + + /// \brief Set jit config. + /// + /// \param[in] The current jit config. +- void set_jit_config(const std::map &jit_config) { jit_config_ = jit_config; } ++ void set_jit_config(const std::map &jit_config); + + /// \brief Get the current jit config. + /// + /// \return The current jit config. +- const std::map &jit_config() const { return jit_config_; } ++ const std::map &jit_config() const; ++ ++ /// \brief Get the backend param in current jit config. ++ /// ++ /// \return The backend param in current jit config. ++ std::string GetJitBackend() const; ++ ++ /// \brief Get the jit_level param in current jit config. ++ /// ++ /// \return The jit_level param in current jit config. ++ std::string GetJitLevel() const; + + private: + PhaseManager() = default; + std::string phase_ = ""; + std::map jit_config_; ++ mutable std::shared_mutex rw_jit_mutex_; + }; + + inline bool IsTwoPhaseInfer() { +diff --git a/mindspore/core/ir/anf.cc b/mindspore/core/ir/anf.cc +index 7c44a54efc9..cb61d9c395e 100644 +--- a/mindspore/core/ir/anf.cc ++++ b/mindspore/core/ir/anf.cc +@@ -167,9 +167,11 @@ std::string AnfNode::fullname_with_scope() { return ""; } + + std::string AnfNode::UniqueName() { return fullname_with_scope() + "_" + UniqueId(); } + +-std::string AnfNode::DebugString(int recursive_level) const { return ToString(); } ++std::string AnfNode::DebugString(DebugStringLevel recursive_level) const { return ToString(); } + +-std::string AnfNode::DebugString(bool recursive) const { return DebugString(recursive ? 1 : 0); } ++std::string AnfNode::DebugString(bool recursive) const { ++ return DebugString(recursive ? AnfNode::DebugStringLevel::kLevel1 : AnfNode::DebugStringLevel::kLevel0); ++} + + void AnfNode::dump() const { std::cout << DebugString() << std::endl; } + +@@ -459,9 +461,9 @@ const AnfNodeWeakPtr &CNode::weak_input(size_t i) const { + return weak_inputs_.at(i); + } + +-std::string CNode::DebugString(int recursive_level) const { ++std::string CNode::DebugString(AnfNode::DebugStringLevel recursive_level) const { + std::ostringstream buffer; +- if (recursive_level > 0) { ++ if (recursive_level > AnfNode::DebugStringLevel::kLevel0) { + if (func_graph() != nullptr) { + buffer << "@" << func_graph()->ToString() << ":"; + } +@@ -558,7 +560,9 @@ void CNode::set_stop_gradient(bool stop_gradient) { flags_[kStopGradient] = stop + + void CNode::set_fullname_with_scope(const std::string full_name) { fullname_with_scope_ = full_name; } + +-std::string CNode::DebugString(bool recursive) const { return DebugString(recursive ? 1 : 0); } ++std::string CNode::DebugString(bool recursive) const { ++ return DebugString(recursive ? AnfNode::DebugStringLevel::kLevel1 : AnfNode::DebugStringLevel::kLevel0); ++} + + void CNode::set_in_forward_flag(bool flag) { flags_[kInForwardFlag] = flag; } + +@@ -726,9 +730,9 @@ void Parameter::set_hidden_size(int64_t hidden_size) { format_attrs_.hidden_size + + int64_t Parameter::hidden_size() const { return format_attrs_.hidden_size; } + +-std::string Parameter::DebugString(int recursive_level) const { ++std::string Parameter::DebugString(AnfNode::DebugStringLevel recursive_level) const { + std::ostringstream buffer; +- if (recursive_level > 0) { ++ if (recursive_level > AnfNode::DebugStringLevel::kLevel0) { + if (func_graph() != nullptr) { + buffer << "@" << func_graph()->ToString() << ":"; + } +@@ -841,7 +845,9 @@ int64_t ValueNode::fracz_group() const { return format_attr_.fracz_group; } + + void ValueNode::set_used_graph_count(size_t used_graph_count) { used_graph_count_ = used_graph_count; } + +-std::string ValueNode::DebugString(bool recursive) const { return DebugString(recursive ? 1 : 0); } ++std::string ValueNode::DebugString(bool recursive) const { ++ return DebugString(recursive ? AnfNode::DebugStringLevel::kLevel1 : AnfNode::DebugStringLevel::kLevel0); ++} + + bool ValueNode::operator==(const AnfNode &other) const { + if (!other.isa()) { +@@ -862,7 +868,7 @@ std::string ValueNode::ToString() const { + return buffer.str(); + } + +-std::string ValueNode::DebugString(int) const { ++std::string ValueNode::DebugString(AnfNode::DebugStringLevel) const { + MS_EXCEPTION_IF_NULL(value_); + std::ostringstream buffer; + buffer << "ValueNode<" << value_->type_name() << "> " << value_->ToString(); +diff --git a/mindspore/core/ir/func_graph_cloner.cc b/mindspore/core/ir/func_graph_cloner.cc +index a0fef3f6f40..2c5257b5994 100644 +--- a/mindspore/core/ir/func_graph_cloner.cc ++++ b/mindspore/core/ir/func_graph_cloner.cc +@@ -719,9 +719,8 @@ void Cloner::AddInputs(const FuncGraphPtr &func_graph_user, const FuncGraphPtr & + AnfNodeWeakPtrList inputs; + AnfNodeWeakPtrList add_params; + if (!FilterMonadInput(cnode->weak_inputs(), &inputs, &input_u_monad, &input_io_monad)) { +- constexpr auto recursive_level = 2; + MS_LOG(INTERNAL_EXCEPTION) << "Cannot have multiple U Monad or multiple IO Monad in one CNode, cnode: " +- << cnode->DebugString(recursive_level); ++ << cnode->DebugString(AnfNode::DebugStringLevel::kLevel2); + } + if (!FilterMonadInput(params, &add_params, ¶m_u_monad, ¶m_io_monad)) { + MS_LOG(INTERNAL_EXCEPTION) << "Cannot have multiple U Monad or multiple IO Monad in Parameters list, func_graph: " +diff --git a/mindspore/core/ir/graph_utils.cc b/mindspore/core/ir/graph_utils.cc +index 9a7d1d0b8d7..beffe9ede7e 100644 +--- a/mindspore/core/ir/graph_utils.cc ++++ b/mindspore/core/ir/graph_utils.cc +@@ -1,7 +1,7 @@ + /** + * This is the C++ adaptation and derivative work of Myia (https://github.com/mila-iqia/myia/). + * +- * Copyright 2019-2022 Huawei Technologies Co., Ltd ++ * Copyright 2019-2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. +@@ -135,17 +135,18 @@ AnfNodePtrList TopoSort(const AnfNodePtr &root, const SuccFunc &succ, const Incl + if (fg != nullptr && fg->return_node() == next) { + continue; + } +- constexpr auto recursive_level = 2; + if (exclude_circle_node) { +- MS_LOG(INFO) << "Graph cycle exists, exclude circle strike node: " << next->DebugString(recursive_level); ++ MS_LOG(INFO) << "Graph cycle exists, exclude circle strike node: " ++ << next->DebugString(AnfNode::DebugStringLevel::kLevel2); + continue; + } + // To dump all nodes in a circle. +- MS_LOG(ERROR) << "Graph cycle exists, strike node: " << next->DebugString(recursive_level) << "\nCircle is: "; ++ MS_LOG(ERROR) << "Graph cycle exists, strike node: " << next->DebugString(AnfNode::DebugStringLevel::kLevel2) ++ << "\nCircle is: "; + auto circle_len = DumpSortingCircleList(todo, next, seen); + DumpSortingCircleIr(todo, next, seen); + MS_LOG(INTERNAL_EXCEPTION) << "Graph cycle exists, size: " << circle_len +- << ", strike node: " << next->DebugString(recursive_level); ++ << ", strike node: " << next->DebugString(AnfNode::DebugStringLevel::kLevel2); + } + } else if (incl > EXCLUDE) { // Not NOFOLLOW or EXCLUDE + MS_LOG(INTERNAL_EXCEPTION) << "The result of include(node) must be one of: \"follow\", \"nofollow\", \"exclude\""; +diff --git a/mindspore/core/utils/phase.cc b/mindspore/core/utils/phase.cc +index 59e794f00c0..235203c7271 100644 +--- a/mindspore/core/utils/phase.cc ++++ b/mindspore/core/utils/phase.cc +@@ -21,4 +21,37 @@ PhaseManager &PhaseManager::GetInstance() noexcept { + static PhaseManager instance; + return instance; + } ++ ++void PhaseManager::ClearJitConfig() { ++ std::unique_lock lock(rw_jit_mutex_); ++ jit_config_.clear(); ++} ++ ++void PhaseManager::set_jit_config(const std::map &jit_config) { ++ std::unique_lock lock(rw_jit_mutex_); ++ jit_config_ = jit_config; ++} ++ ++const std::map &PhaseManager::jit_config() const { ++ std::shared_lock lock(rw_jit_mutex_); ++ return jit_config_; ++} ++ ++std::string PhaseManager::GetJitBackend() const { ++ std::shared_lock lock(rw_jit_mutex_); ++ auto iter = jit_config_.find("backend"); ++ if (iter == jit_config_.end()) { ++ return ""; ++ } ++ return iter->second; ++} ++ ++std::string PhaseManager::GetJitLevel() const { ++ std::shared_lock lock(rw_jit_mutex_); ++ auto iter = jit_config_.find("jit_level"); ++ if (iter == jit_config_.end()) { ++ return ""; ++ } ++ return iter->second; ++} + } // namespace mindspore +diff --git a/mindspore/python/mindspore/_extends/parse/parser.py b/mindspore/python/mindspore/_extends/parse/parser.py +index ed2ed3341f7..a344c5285b1 100644 +--- a/mindspore/python/mindspore/_extends/parse/parser.py ++++ b/mindspore/python/mindspore/_extends/parse/parser.py +@@ -911,6 +911,26 @@ def can_constant_fold(obj): + return obj in constant_fold_functions + + ++def hook_wrapper(hook_fn): ++ """ ++ Decorator wrapper for gradient hook functions. ++ Handles custom logic when the hook returns None to ensure execution dependencies. ++ ++ Args: ++ hook_fn (function): The original hook function to be wrapped. ++ ++ Returns: ++ function: Wrapped inner hook function with dependency handling logic. ++ """ ++ def inner(dout): ++ fdout = hook_fn(dout) ++ if fdout is None: ++ dout = ops.Depend()(dout, fdout) ++ return dout ++ return fdout ++ return inner ++ ++ + class Parser: + """ + Parser python code to ast tree. +diff --git a/mindspore/python/mindspore/common/api.py b/mindspore/python/mindspore/common/api.py +index 428800aa812..755b7056a75 100644 +--- a/mindspore/python/mindspore/common/api.py ++++ b/mindspore/python/mindspore/common/api.py +@@ -1895,6 +1895,7 @@ class _PyNativeExecutor: + return self._executor.constant_folding(*args) + + ++ + class _CellGraphExecutor: + """ + An executor used to compile/manage/run graph for a Cell. +diff --git a/mindspore/python/mindspore/nn/cell.py b/mindspore/python/mindspore/nn/cell.py +index 30e742e0208..7a947fd1871 100755 +--- a/mindspore/python/mindspore/nn/cell.py ++++ b/mindspore/python/mindspore/nn/cell.py +@@ -426,6 +426,13 @@ class Cell(Cell_): + """ + return self._bprop_debug + ++ @property ++ def compiled(self): ++ """ ++ Get whether cell is compiled. ++ """ ++ return self._compiled ++ + @bprop_debug.setter + def bprop_debug(self, value): + """ +diff --git a/mindspore/python/mindspore/ops/operations/_inner_ops.py b/mindspore/python/mindspore/ops/operations/_inner_ops.py +index 68d8eadf1da..2464825d9b8 100755 +--- a/mindspore/python/mindspore/ops/operations/_inner_ops.py ++++ b/mindspore/python/mindspore/ops/operations/_inner_ops.py +@@ -25,7 +25,7 @@ from mindspore.ops.operations._scalar_ops import bit_or, bit_and + from mindspore.ops import signature as sig + from mindspore.ops.operations.math_ops import _infer_shape_reduce + from mindspore.ops.primitive import PrimitiveWithCheck, PrimitiveWithInfer, prim_attr_register, Primitive, \ +- _run_op, _check_contains_variable ++ _check_contains_variable + from mindspore._c_expression import TensorPy as Tensor_ + from mindspore._c_expression import typing, HookType + from mindspore._c_expression import pyboost_generator +diff --git a/tests/ut/cpp/common/backend_common_test.cc b/tests/ut/cpp/common/backend_common_test.cc +index 367ee028cc9..1f0b4dd4ce9 100644 +--- a/tests/ut/cpp/common/backend_common_test.cc ++++ b/tests/ut/cpp/common/backend_common_test.cc +@@ -1,5 +1,5 @@ + /** +- * Copyright 2019 Huawei Technologies Co., Ltd ++ * Copyright 2019-2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. +@@ -40,10 +40,10 @@ std::vector GetCNodeList(const FuncGraphPtr &func_graph) { + std::vector nodes = TopoSort(func_graph->get_return()); + std::vector lst; + for (auto &node : nodes) { +- MS_LOG(INFO) << "nodes: " << node->DebugString(10); ++ MS_LOG(INFO) << "nodes: " << node->DebugString(AnfNode::DebugStringLevel::kLevel10); + if (node->isa() && IsValueNode(node->cast()->input(0)) && + !IsPrimitiveCNode(node, prim::kPrimReturn)) { +- MS_LOG(INFO) << "push in anf_node list: " << node->DebugString(10); ++ MS_LOG(INFO) << "push in anf_node list: " << node->DebugString(AnfNode::DebugStringLevel::kLevel10); + lst.push_back(node); + } + }