已合并
【质量加固】补充 const 修饰、参数 const 修饰 #4611
cnsd_turtle创建于 6 天前
【质量加固】补充 const 修饰、参数 const 修饰 #4611
已合并
cnsd_turtle创建于 6 天前
8 个文件变更+20-18
@@ -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};
@@ -238,7 +238,7 @@ bool DependencyAnalyzer::CanReachAllSameBlockAnchor(const Node *const a, const u
238}238}
239 239 
240std::string DependencyAnalyzer::WhyACannotReuseB(const ge::Node *a, uint32_t a_output_index, const ge::Node *b,240std::string DependencyAnalyzer::WhyACannotReuseB(const ge::Node *a, uint32_t a_output_index, const ge::Node *b,
241- uint32_t b_output_index) {241+ uint32_t b_output_index) const {
242 if (!CheckParam(a, a_output_index, b, b_output_index)) {242 if (!CheckParam(a, a_output_index, b, b_output_index)) {
243 return "invalid param";243 return "invalid param";
244 }244 }
@@ -280,7 +280,8 @@ std::string DependencyAnalyzer::WhyACannotReuseB(const ge::Node *a, uint32_t a_o
280}280}
281 281 
282void DependencyAnalyzer::WhyACannotReuseBInner(const MemCheckParam &param,282void DependencyAnalyzer::WhyACannotReuseBInner(const MemCheckParam &param,
283- const std::list<const Node *> &b_output_nodes, std::stringstream &ss) {283+ const std::list<const Node *> &b_output_nodes,
284+ std::stringstream &ss) const {
284 const auto same_out_anchors = GetAllUseSameOutBlockAnchors(param.a, param.a_output_index);285 const auto same_out_anchors = GetAllUseSameOutBlockAnchors(param.a, param.a_output_index);
285 ErrorLogDependNodes(same_out_anchors);286 ErrorLogDependNodes(same_out_anchors);
286 for (const auto out_node : b_output_nodes) {287 for (const auto out_node : b_output_nodes) {
@@ -439,11 +440,12 @@ const std::list<NodeIndexIO> &DependencyAnalyzer::GetSymbolNodeIndexIOList(const
439}440}
440 441 
441// 获取所有以node的第out_index输出作为输入的节点442// 获取所有以node的第out_index输出作为输入的节点
442-std::list<const Node *> DependencyAnalyzer::GetAllUseSameInBlockNodes(const Node *node, uint32_t out_index) {443+std::list<const Node *> DependencyAnalyzer::GetAllUseSameInBlockNodes(const Node *node, uint32_t out_index) const {
443 return GetAllUseSameBlockNodesByType(node, out_index, kIn);444 return GetAllUseSameBlockNodesByType(node, out_index, kIn);
444}445}
445 446 
446-std::list<OutDataAnchorPtr> DependencyAnalyzer::GetAllUseSameOutBlockAnchors(const Node *node, uint32_t out_index) {447+std::list<OutDataAnchorPtr> DependencyAnalyzer::GetAllUseSameOutBlockAnchors(const Node *node,
448+ uint32_t out_index) const {
447 const auto cur_anchor = NodeIndexIO(node, out_index, kOut);449 const auto cur_anchor = NodeIndexIO(node, out_index, kOut);
448 const auto &symbol = anchor_to_symbol_[cur_anchor.ToString()];450 const auto &symbol = anchor_to_symbol_[cur_anchor.ToString()];
449 std::list<OutDataAnchorPtr> use_same_block_anchors;451 std::list<OutDataAnchorPtr> use_same_block_anchors;
@@ -457,7 +459,7 @@ std::list<OutDataAnchorPtr> DependencyAnalyzer::GetAllUseSameOutBlockAnchors(con
457}459}
458 460 
459std::list<const Node *> DependencyAnalyzer::GetAllUseSameBlockNodesByType(const Node *node, uint32_t out_index,461std::list<const Node *> DependencyAnalyzer::GetAllUseSameBlockNodesByType(const Node *node, uint32_t out_index,
460- IOType type) {462+ IOType type) const {
461 const auto cur_anchor = NodeIndexIO(node, out_index, kOut);463 const auto cur_anchor = NodeIndexIO(node, out_index, kOut);
462 const auto &symbol = anchor_to_symbol_[cur_anchor.ToString()];464 const auto &symbol = anchor_to_symbol_[cur_anchor.ToString()];
463 std::list<const Node *> use_same_block_nodes;465 std::list<const Node *> use_same_block_nodes;
@@ -74,7 +74,7 @@ class DependencyAnalyzer {
74 /// @param [in] b_output_index, output index of b74 /// @param [in] b_output_index, output index of b
75 /// @return td::string75 /// @return td::string
76 std::string WhyACannotReuseB(const Node *const a, uint32_t a_output_index, const Node *const b,76 std::string WhyACannotReuseB(const Node *const a, uint32_t a_output_index, const Node *const b,
77- uint32_t b_output_index);77+ uint32_t b_output_index) const;
78 78 
79 /// @ingroup GE79 /// @ingroup GE
80 /// @brief rebuild reach nodes table, and print log.80 /// @brief rebuild reach nodes table, and print log.
@@ -100,9 +100,9 @@ class DependencyAnalyzer {
100 100 
101 // init same_out_block_nodes_table_101 // init same_out_block_nodes_table_
102 void InitSameOutBlockNodesMap();102 void InitSameOutBlockNodesMap();
103- std::list<const Node *> GetAllUseSameBlockNodesByType(const Node *node, uint32_t out_index, IOType type);103+ std::list<const Node *> GetAllUseSameBlockNodesByType(const Node *node, uint32_t out_index, IOType type) const;
104- std::list<const Node *> GetAllUseSameInBlockNodes(const Node *node, uint32_t out_index);104+ std::list<const Node *> GetAllUseSameInBlockNodes(const Node *node, uint32_t out_index) const;
105- std::list<OutDataAnchorPtr> GetAllUseSameOutBlockAnchors(const Node *node, uint32_t out_index);105+ std::list<OutDataAnchorPtr> GetAllUseSameOutBlockAnchors(const Node *node, uint32_t out_index) const;
106 106 
107 const std::list<NodeIndexIO> &GetSymbolNodeIndexIOList(const Node *const node, const uint32_t output_index) const;107 const std::list<NodeIndexIO> &GetSymbolNodeIndexIOList(const Node *const node, const uint32_t output_index) const;
108 108 
@@ -140,7 +140,7 @@ class DependencyAnalyzer {
140 bool IsOutNodeSkip(const Node *const node, const Node *const origin_node) const;140 bool IsOutNodeSkip(const Node *const node, const Node *const origin_node) const;
141 void DebugWrapperInfo() const;141 void DebugWrapperInfo() const;
142 void WhyACannotReuseBInner(const MemCheckParam &param, const std::list<const Node *> &b_output_nodes,142 void WhyACannotReuseBInner(const MemCheckParam &param, const std::list<const Node *> &b_output_nodes,
143- std::stringstream &ss);143+ std::stringstream &ss) const;
144 144 
145 private:145 private:
146 ComputeGraphPtr compute_graph_;146 ComputeGraphPtr compute_graph_;
@@ -104,7 +104,7 @@ class StreamAllocator {
104 return notify_types_;104 return notify_types_;
105 }105 }
106 106 
107- std::map<int64_t, int64_t> GetSplitStreamToLogicStream() {107+ std::map<int64_t, int64_t> GetSplitStreamToLogicStream() const {
108 return split_stream_id_to_logic_stream_id_;108 return split_stream_id_to_logic_stream_id_;
109 }109 }
110 110 
@@ -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;
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