已合并
【质量加固】修改若干符合代码规范的问题 #4618
海洋504创建于 29 天前
【质量加固】修改若干符合代码规范的问题 #4618
已合并
海洋504创建于 29 天前
共 9 个文件变更+11-11
@@ -588,7 +588,7 @@ Status GraphBuilder::MarkFpBpProfilingTaskAttr(ComputeGraphPtr &com_graph) const
588 │ Data │ ───────> │ NetOutput │588 │ Data │ ───────> │ NetOutput │
589 └───────┘ └───────────┘589 └───────┘ └───────────┘
590*/590*/
591-bool GraphBuilder::IsDataDirectConnNetoutput(ComputeGraphPtr &comp_graph) {591+bool GraphBuilder::IsDataDirectConnNetoutput(const ComputeGraphPtr &comp_graph) {
592 const auto nodes = comp_graph->GetDirectNode();592 const auto nodes = comp_graph->GetDirectNode();
593 return ((nodes.size() == 2U) && (nodes.at(0)->GetType() == "Data") && (nodes.at(1)->GetType() == "NetOutput"));593 return ((nodes.size() == 2U) && (nodes.at(0)->GetType() == "Data") && (nodes.at(1)->GetType() == "NetOutput"));
594}594}
@@ -85,7 +85,7 @@ class GraphBuilder {
85 Status AddOutputMemTypeForNode(const NodePtr &node) const;85 Status AddOutputMemTypeForNode(const NodePtr &node) const;
86 Status CalcLogIdAndSetAttr(const OpDescPtr &op_desc, const std::vector<int64_t> &trace_nodes,86 Status CalcLogIdAndSetAttr(const OpDescPtr &op_desc, const std::vector<int64_t> &trace_nodes,
87 const int64_t node_index, const int64_t start_id) const;87 const int64_t node_index, const int64_t start_id) const;
88- static bool IsDataDirectConnNetoutput(ComputeGraphPtr &comp_graph);88+ static bool IsDataDirectConnNetoutput(const ComputeGraphPtr &comp_graph);
89 Status ReGetTaskInfo(const ComputeGraphPtr &comp_graph, uint64_t session_id, Model &model);89 Status ReGetTaskInfo(const ComputeGraphPtr &comp_graph, uint64_t session_id, Model &model);
90 90 
91 int32_t build_mode_;91 int32_t build_mode_;
@@ -58,13 +58,13 @@ class CompiledGraphSummary::SummaryData {
58 size_t GetEventNum() const {58 size_t GetEventNum() const {
59 return event_num_;59 return event_num_;
60 }60 }
61- std::shared_ptr<StreamAllocationSummary> GetStreamAllocationSummary() {61+ std::shared_ptr<StreamAllocationSummary> GetStreamAllocationSummary() const {
62 return stream_allocation_summary_;62 return stream_allocation_summary_;
63 }63 }
64- std::vector<ge::Shape> GetOutputShapes() {64+ std::vector<ge::Shape> GetOutputShapes() const {
65 return netoutput_shapes_;65 return netoutput_shapes_;
66 }66 }
67- std::vector<ge::DataType> GetOutputDtypes() {67+ std::vector<ge::DataType> GetOutputDtypes() const {
68 return netoutput_dtypes_;68 return netoutput_dtypes_;
69 }69 }
70 std::vector<std::pair<uint32_t, uint32_t>> GetIOIndexesWithSameAddr() const {70 std::vector<std::pair<uint32_t, uint32_t>> GetIOIndexesWithSameAddr() const {
@@ -64,7 +64,7 @@ Status LabelAllocator::AssignFunctionalLabels() {
64 return SUCCESS;64 return SUCCESS;
65}65}
66 66 
67-bool LabelAllocator::CollectFunctionalNode(ComputeGraphPtr &graph, std::set<NodePtr> &functional_nodes) const {67+bool LabelAllocator::CollectFunctionalNode(const ComputeGraphPtr &graph, std::set<NodePtr> &functional_nodes) const {
68 if (graph == nullptr) {68 if (graph == nullptr) {
69 REPORT_INNER_ERR_MSG("E19999", "check param compute_graph nullptr");69 REPORT_INNER_ERR_MSG("E19999", "check param compute_graph nullptr");
70 GELOGE(INTERNAL_ERROR, "[Check][Param] Sub ComputeGraph is null.");70 GELOGE(INTERNAL_ERROR, "[Check][Param] Sub ComputeGraph is null.");
@@ -25,7 +25,7 @@ class LabelAllocator {
25 Status AssignFunctionalLabels();25 Status AssignFunctionalLabels();
26 26 
27 private:27 private:
28- bool CollectFunctionalNode(ComputeGraphPtr &graph, std::set<NodePtr> &functional_nodes) const;28+ bool CollectFunctionalNode(const ComputeGraphPtr &graph, std::set<NodePtr> &functional_nodes) const;
29 29 
30 ComputeGraphPtr compute_graph_;30 ComputeGraphPtr compute_graph_;
31};31};
@@ -3968,7 +3968,7 @@ void GraphManager::ReturnError(RunAsyncCallbackV2 callback, Status ret, const st
3968 StopQueue();3968 StopQueue();
3969}3969}
3970 3970 
3971-bool GraphManager::IsGraphNeedRebuild(uint32_t graph_id) {3971+bool GraphManager::IsGraphNeedRebuild(uint32_t graph_id) const {
3972 // find graph3972 // find graph
3973 GraphNodePtr graph_node = nullptr;3973 GraphNodePtr graph_node = nullptr;
3974 Status ret = GetGraphNode(graph_id, graph_node);3974 Status ret = GetGraphNode(graph_id, graph_node);
@@ -176,7 +176,7 @@ class GraphManager {
176 return options_.train_graph_flag;176 return options_.train_graph_flag;
177 }177 }
178 178 
179- bool IsGraphNeedRebuild(uint32_t graph_id);179+ bool IsGraphNeedRebuild(uint32_t graph_id) const;
180 180 
181 Status GenerateInfershapeGraph(GraphId &graph_id);181 Status GenerateInfershapeGraph(GraphId &graph_id);
182 182 
@@ -65,7 +65,7 @@ void GraphRebuildStateCtrl::AddResourceName(uint32_t graph_id, const std::string
65 GELOGI("The resource %s of graph %u added to ctrl.", resource_name.c_str(), graph_id);65 GELOGI("The resource %s of graph %u added to ctrl.", resource_name.c_str(), graph_id);
66}66}
67 67 
68-bool GraphRebuildStateCtrl::IsVarPermitToChangeFormats(const std::string &var_name) {68+bool GraphRebuildStateCtrl::IsVarPermitToChangeFormats(const std::string &var_name) const {
69 std::lock_guard<std::mutex> lock(mutex_);69 std::lock_guard<std::mutex> lock(mutex_);
70 const std::map<std::string, int32_t>::const_iterator &iter = resource_names_to_change_times_.find(var_name);70 const std::map<std::string, int32_t>::const_iterator &iter = resource_names_to_change_times_.find(var_name);
71 if (iter == resource_names_to_change_times_.end()) {71 if (iter == resource_names_to_change_times_.end()) {
@@ -41,7 +41,7 @@ class GraphRebuildStateCtrl {
41 /// only one time of changing41 /// only one time of changing
42 /// \param var_name42 /// \param var_name
43 /// \return43 /// \return
44- bool IsVarPermitToChangeFormats(const std::string &var_name);44+ bool IsVarPermitToChangeFormats(const std::string &var_name) const;
atomgit-bot
atomgit-botatomgit-bot29 天前

🔴 Critical

变更行:graph_rebuild_state_ctrl.h:44 将 IsVarPermitToChangeFormats 的类内声明改为 bool IsVarPermitToChangeFormats(const std::string &var_name) const(新增 const 限定)。

受影响契约:C++ 中成员函数的 const 限定符属于函数签名的一部分,类外定义必须与类内声明签名完全一致(C++ 标准 [class.mfct])。该函数的唯一定义位于 graph_rebuild_state_ctrl.cc:68,仍为不带 const 的 bool GraphRebuildStateCtrl::IsVarPermitToChangeFormats(const std::string &var_name)。本 diff 只修改了头文件,未同步修改 .cc 中的定义。

失败模式:编译 graph_rebuild_state_ctrl.cc 时,编译器将该类外定义解析为与类内 const 声明不匹配的另一个成员函数,报错(GCC/Clang:out-of-line definition of 'IsVarPermitToChangeFormats' does not match any declaration in 'ge::GraphRebuildStateCtrl'),导致整个编译单元/工程构建失败(P0 级构建中断)。这是本 diff 单侧修改声明而未同步定义引入的新不一致。

likedislike
不准确?
45 45 
46 private:46 private:
47 /// The graph id of the graph to be rebuilt. When the format of a variable is47 /// The graph id of the graph to be rebuilt. When the format of a variable is