已合并
【质量加固】补充成员函数 const 修饰以符合编码规范(#517) #4608
qoosong创建于 22 天前
【质量加固】补充成员函数 const 修饰以符合编码规范(#517) #4608
已合并
共 10 个文件变更+18-18
| @@ -93,7 +93,7 @@ class Analyzer { | |||
| 93 | * @param [in]: None | 93 | * @param [in]: None |
| 94 | * @return: true: enable env false : disable env | 94 | * @return: true: enable env false : disable env |
| 95 | */ | 95 | */ |
| 96 | - bool IsEnableNetAnalyzeDebug() { | 96 | + bool IsEnableNetAnalyzeDebug() const { |
| 97 | const char_t *env = nullptr; | 97 | const char_t *env = nullptr; |
| 98 | MM_SYS_GET_ENV(MM_ENV_ENABLE_NETWORK_ANALYSIS_DEBUG, env); | 98 | MM_SYS_GET_ENV(MM_ENV_ENABLE_NETWORK_ANALYSIS_DEBUG, env); |
| 99 | return env != nullptr; | 99 | return env != nullptr; |
Mcompiler/engines/nn_engine/fusion/fusion_rule_manager/fusion_rule_parser/fusion_rule_json_pattern.h+3-3
| @@ -212,7 +212,7 @@ class FusionRuleJsonNode { | |||
| 212 | 212 | ||
| 213 | Status ParseJson(const nlohmann::json &json_object); | 213 | Status ParseJson(const nlohmann::json &json_object); |
| 214 | 214 | ||
| 215 | - std::string GetName() { | 215 | + std::string GetName() const { |
| 216 | return name_; | 216 | return name_; |
| 217 | } | 217 | } |
| 218 | 218 | ||
| @@ -288,11 +288,11 @@ class FusionRuleJsonAnchor { | |||
| 288 | return src_index_; | 288 | return src_index_; |
| 289 | } | 289 | } |
| 290 | 290 | ||
| 291 | - std::string GetSrcNode() { | 291 | + std::string GetSrcNode() const { |
| 292 | return src_node_; | 292 | return src_node_; |
| 293 | } | 293 | } |
| 294 | 294 | ||
| 295 | - std::string GetName() { | 295 | + std::string GetName() const { |
| 296 | return name_; | 296 | return name_; |
| 297 | } | 297 | } |
| 298 | 298 | ||
Mcompiler/engines/nn_engine/fusion/fusion_rule_manager/fusion_rule_parser/fusion_rule_parser_utils.h+2-2
| @@ -74,14 +74,14 @@ class FusionRuleParserUtils { | |||
| 74 | engine_name_ = name; | 74 | engine_name_ = name; |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | - std::string GetEngineName() { | 77 | + std::string GetEngineName() const { |
| 78 | std::lock_guard<std::mutex> lock_guard(parse_mutex_); | 78 | std::lock_guard<std::mutex> lock_guard(parse_mutex_); |
| 79 | return engine_name_; | 79 | return engine_name_; |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | private: | 82 | private: |
| 83 | std::string engine_name_; | 83 | std::string engine_name_; |
| 84 | - std::mutex parse_mutex_; | 84 | + mutable std::mutex parse_mutex_; |
| 85 | }; | 85 | }; |
| 86 | 86 | ||
| 87 | } // namespace fe | 87 | } // namespace fe |
| @@ -61,7 +61,7 @@ class VISIBILITY_EXPORT GlobalDumper { | |||
| 61 | (void)keys_to_handler_.erase(key); | 61 | (void)keys_to_handler_.erase(key); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | - size_t GetHandleSize() { | 64 | + size_t GetHandleSize() const { |
| 65 | std::lock_guard<std::mutex> lock(mutex_); | 65 | std::lock_guard<std::mutex> lock(mutex_); |
| 66 | return keys_to_handler_.size(); | 66 | return keys_to_handler_.size(); |
| 67 | } | 67 | } |
| @@ -103,7 +103,7 @@ class VISIBILITY_EXPORT GlobalDumper { | |||
| 103 | private: | 103 | private: |
| 104 | GlobalDumper(); | 104 | GlobalDumper(); |
| 105 | uint64_t enable_flags_{0UL}; | 105 | uint64_t enable_flags_{0UL}; |
| 106 | - std::mutex mutex_; | 106 | + mutable std::mutex mutex_; |
| 107 | // each davinci model has own exception dumper | 107 | // each davinci model has own exception dumper |
| 108 | std::set<ge::ExceptionDumper *> exception_dumpers_{}; | 108 | std::set<ge::ExceptionDumper *> exception_dumpers_{}; |
| 109 | std::map<const void *, GlobalDumperSwitchHandler> keys_to_handler_; | 109 | std::map<const void *, GlobalDumperSwitchHandler> keys_to_handler_; |
| @@ -135,7 +135,7 @@ class VISIBILITY_EXPORT GlobalProfilingWrapper { | |||
| 135 | enable_flags_.store(enable_flags); | 135 | enable_flags_.store(enable_flags); |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | - uint64_t GetRecordCount() { | 138 | + uint64_t GetRecordCount() const { |
| 139 | if (global_profiler_ == nullptr) { | 139 | if (global_profiler_ == nullptr) { |
| 140 | return 0UL; | 140 | return 0UL; |
| 141 | } | 141 | } |
| @@ -146,7 +146,7 @@ class VISIBILITY_EXPORT GlobalProfilingWrapper { | |||
| 146 | return enable_flags_.load(); | 146 | return enable_flags_.load(); |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | - bool IsEnabled(ProfilingType profiling_type) { | 149 | + bool IsEnabled(ProfilingType profiling_type) const { |
| 150 | return enable_flags_.load() & BuiltInSubscriberUtil::EnableBit<ProfilingType>(profiling_type); | 150 | return enable_flags_.load() & BuiltInSubscriberUtil::EnableBit<ProfilingType>(profiling_type); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| @@ -111,7 +111,7 @@ class BlockingQueue { | |||
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | // if the queue is stoped ,need call this function to release the unprocessed items | 113 | // if the queue is stoped ,need call this function to release the unprocessed items |
| 114 | - std::list<T> GetRemainItems() { | 114 | + std::list<T> GetRemainItems() const { |
| 115 | const std::unique_lock<std::mutex> lock(mutex_); | 115 | const std::unique_lock<std::mutex> lock(mutex_); |
| 116 | 116 | ||
| 117 | if (!is_stoped_) { | 117 | if (!is_stoped_) { |
| @@ -121,7 +121,7 @@ class BlockingQueue { | |||
| 121 | return queue_; | 121 | return queue_; |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | - bool IsFull() { | 124 | + bool IsFull() const { |
| 125 | const std::unique_lock<std::mutex> lock(mutex_); | 125 | const std::unique_lock<std::mutex> lock(mutex_); |
| 126 | return queue_.size() >= max_size_; | 126 | return queue_.size() >= max_size_; |
| 127 | } | 127 | } |
| @@ -140,14 +140,14 @@ class BlockingQueue { | |||
| 140 | max_size_ = size; | 140 | max_size_ = size; |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | - uint32_t Size() { | 143 | + uint32_t Size() const { |
| 144 | const std::unique_lock<std::mutex> lock(mutex_); | 144 | const std::unique_lock<std::mutex> lock(mutex_); |
| 145 | return static_cast<uint32_t>(queue_.size()); | 145 | return static_cast<uint32_t>(queue_.size()); |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | private: | 148 | private: |
| 149 | std::list<T> queue_; | 149 | std::list<T> queue_; |
| 150 | - std::mutex mutex_; | 150 | + mutable std::mutex mutex_; |
| 151 | std::condition_variable empty_cond_; | 151 | std::condition_variable empty_cond_; |
| 152 | std::condition_variable full_cond_; | 152 | std::condition_variable full_cond_; |
| 153 | uint32_t max_size_; | 153 | uint32_t max_size_; |
| @@ -40,7 +40,7 @@ struct SkipCtxRecord { | |||
| 40 | GE_ASSERT_NOTNULL(ctx_type_v); | 40 | GE_ASSERT_NOTNULL(ctx_type_v); |
| 41 | return true; | 41 | return true; |
| 42 | } | 42 | } |
| 43 | - size_t GetCtxNum() { | 43 | + size_t GetCtxNum() const { |
| 44 | if (ctx_id_v == nullptr) { | 44 | if (ctx_id_v == nullptr) { |
| 45 | return 0; | 45 | return 0; |
| 46 | } | 46 | } |
| @@ -53,7 +53,7 @@ class BufferFusionPassBase { | |||
| 53 | name_ = name; | 53 | name_ = name; |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | - std::string GetName() { | 56 | + std::string GetName() const { |
| 57 | return name_; | 57 | return name_; |
| 58 | } | 58 | } |
| 59 | 59 | ||
| @@ -55,7 +55,7 @@ class DataInputer { | |||
| 55 | queue_.Stop(); | 55 | queue_.Stop(); |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | - uint32_t Size() { | 58 | + uint32_t Size() const { |
| 59 | return queue_.Size(); | 59 | return queue_.Size(); |
| 60 | } | 60 | } |
| 61 | 61 | ||
| @@ -322,7 +322,7 @@ class DavinciModel { | |||
| 322 | return data_inputer_.Push(args); | 322 | return data_inputer_.Push(args); |
| 323 | } | 323 | } |
| 324 | 324 | ||
| 325 | - uint32_t GetDataInputerSize() { | 325 | + uint32_t GetDataInputerSize() const { |
| 326 | return data_inputer_.Size(); | 326 | return data_inputer_.Size(); |
| 327 | } | 327 | } |
| 328 | 328 | ||