已合并
【质量加固】为只读成员函数补充 const 修饰 #4597
wxh456创建于 23 天前
【质量加固】为只读成员函数补充 const 修饰 #4597
已合并
共 19 个文件变更+26-26
| @@ -85,7 +85,7 @@ void EngineManager::GetGraphOptimizerObjs(const map<string, GraphOptimizerPtr> & | |||
| 85 | FFTS_LOGD("Get GraphOptimizer success."); | 85 | FFTS_LOGD("Get GraphOptimizer success."); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | -std::string EngineManager::GetSocVersion() { | 88 | +std::string EngineManager::GetSocVersion() const { |
| 89 | return soc_version_; | 89 | return soc_version_; |
| 90 | } | 90 | } |
| 91 | } // namespace ffts | 91 | } // namespace ffts |
| @@ -36,7 +36,7 @@ class EngineManager { | |||
| 36 | void GetGraphOptimizerObjs(const map<string, GraphOptimizerPtr> &graph_optimizers, | 36 | void GetGraphOptimizerObjs(const map<string, GraphOptimizerPtr> &graph_optimizers, |
| 37 | const std::string &engine_name) const; | 37 | const std::string &engine_name) const; |
| 38 | 38 | ||
| 39 | - std::string GetSocVersion(); | 39 | + std::string GetSocVersion() const; |
| 40 | 40 | ||
| 41 | private: | 41 | private: |
| 42 | EngineManager(); | 42 | EngineManager(); |
Mcompiler/engines/nn_engine/optimizer/adapter/tbe_adapter/kernel_launch/l2_cache_kernel_launch.cc+2-2
| @@ -24,11 +24,11 @@ const std::string ATTR_NAME_L2CACHE_GRAPH_READ_MODE = "_fe_l2cache_graph_read_mo | |||
| 24 | const std::set<std::string> LIFECYCLE_IS_END_OPS = {DATA, AIPPDATA, ANN_DATA, CONSTANT, CONSTANTOP}; | 24 | const std::set<std::string> LIFECYCLE_IS_END_OPS = {DATA, AIPPDATA, ANN_DATA, CONSTANT, CONSTANTOP}; |
| 25 | const std::set<std::string> LIFECYCLE_IS_NOT_END_OPS = {VARIABLE}; | 25 | const std::set<std::string> LIFECYCLE_IS_NOT_END_OPS = {VARIABLE}; |
| 26 | } // namespace | 26 | } // namespace |
| 27 | -size_t L2CacheKernelLaunch::GetAppendArgsSizeOf() { | 27 | +size_t L2CacheKernelLaunch::GetAppendArgsSizeOf() const { |
| 28 | return sizeof(uint64_t); // uinit64_t: 8 | 28 | return sizeof(uint64_t); // uinit64_t: 8 |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | -size_t L2CacheKernelLaunch::GetAppendArgsNum() { | 31 | +size_t L2CacheKernelLaunch::GetAppendArgsNum() const { |
| 32 | return input_num_; | 32 | return input_num_; |
| 33 | } | 33 | } |
| 34 | 34 | ||
Mcompiler/engines/nn_engine/optimizer/adapter/tbe_adapter/kernel_launch/l2_cache_kernel_launch.h+2-2
| @@ -24,8 +24,8 @@ class L2CacheKernelLaunch : public TbeKernelLaunch { | |||
| 24 | public: | 24 | public: |
| 25 | explicit L2CacheKernelLaunch(int32_t input_num) : TbeKernelLaunch(input_num) {}; | 25 | explicit L2CacheKernelLaunch(int32_t input_num) : TbeKernelLaunch(input_num) {}; |
| 26 | ~L2CacheKernelLaunch() override {}; | 26 | ~L2CacheKernelLaunch() override {}; |
| 27 | - size_t GetAppendArgsSizeOf() override; | 27 | + size_t GetAppendArgsSizeOf() const override; |
| 28 | - size_t GetAppendArgsNum() override; | 28 | + size_t GetAppendArgsNum() const override; |
| 29 | Status AddAppendArgs(const ge::Node &node, void *all_args_buff, const uint32_t &args_size) override; | 29 | Status AddAppendArgs(const ge::Node &node, void *all_args_buff, const uint32_t &args_size) override; |
| 30 | 30 | ||
| 31 | private: | 31 | private: |
| @@ -82,10 +82,10 @@ void TbeKernelLaunch::PrintAllArgs(const string &op_name, const string &op_type, | |||
| 82 | } | 82 | } |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | -size_t TbeKernelLaunch::GetAppendArgsSizeOf() { | 85 | +size_t TbeKernelLaunch::GetAppendArgsSizeOf() const { |
| 86 | return 0; | 86 | return 0; |
| 87 | } | 87 | } |
| 88 | -size_t TbeKernelLaunch::GetAppendArgsNum() { | 88 | +size_t TbeKernelLaunch::GetAppendArgsNum() const { |
| 89 | return 0; | 89 | return 0; |
| 90 | } | 90 | } |
| 91 | Status TbeKernelLaunch::AddAppendArgs(const ge::Node &node, void *all_args_buff, const uint32_t &args_size) { | 91 | Status TbeKernelLaunch::AddAppendArgs(const ge::Node &node, void *all_args_buff, const uint32_t &args_size) { |
| @@ -30,8 +30,8 @@ class TbeKernelLaunch { | |||
| 30 | Status DealKernelLaunch(const ge::Node &node, const void *args, const uint32_t &args_size, | 30 | Status DealKernelLaunch(const ge::Node &node, const void *args, const uint32_t &args_size, |
| 31 | const std::string &stub_func, const uint32_t &core_dim, domi::TaskDef &task_def); | 31 | const std::string &stub_func, const uint32_t &core_dim, domi::TaskDef &task_def); |
| 32 | 32 | ||
| 33 | - virtual size_t GetAppendArgsSizeOf(); | 33 | + virtual size_t GetAppendArgsSizeOf() const; |
| 34 | - virtual size_t GetAppendArgsNum(); | 34 | + virtual size_t GetAppendArgsNum() const; |
| 35 | virtual Status AddAppendArgs(const ge::Node &node, void *all_args_buff, const uint32_t &args_size); | 35 | virtual Status AddAppendArgs(const ge::Node &node, void *all_args_buff, const uint32_t &args_size); |
| 36 | 36 | ||
| 37 | static bool KernelLaunch(const std::string &stub_func, const uint32_t block_dim, const void *args, uint32_t args_size, | 37 | static bool KernelLaunch(const std::string &stub_func, const uint32_t block_dim, const void *args, uint32_t args_size, |
| @@ -769,7 +769,7 @@ Status TbeTaskBuilderAdapter::InitInput() { | |||
| 769 | return ret; | 769 | return ret; |
| 770 | } | 770 | } |
| 771 | 771 | ||
| 772 | -bool TbeTaskBuilderAdapter::GetUnknownShapeFlag() { | 772 | +bool TbeTaskBuilderAdapter::GetUnknownShapeFlag() const { |
| 773 | bool is_support_unknown_shape = false; | 773 | bool is_support_unknown_shape = false; |
| 774 | (void)ge::AttrUtils::GetBool(op_desc_, ATTR_NAME_SUPPORT_DYNAMIC_SHAPE, is_support_unknown_shape); | 774 | (void)ge::AttrUtils::GetBool(op_desc_, ATTR_NAME_SUPPORT_DYNAMIC_SHAPE, is_support_unknown_shape); |
| 775 | bool is_unknown_shape = UnknownShapeUtils::IsUnknownShapeOp(*node_.GetOpDesc()); | 775 | bool is_unknown_shape = UnknownShapeUtils::IsUnknownShapeOp(*node_.GetOpDesc()); |
| @@ -119,7 +119,7 @@ class TbeTaskBuilderAdapter : public TaskBuilderAdapter { | |||
| 119 | Status FeedInputAddrByAnchor(const ge::InDataAnchorPtr &anchor, InputIndexOffsetInfo &index_offset_info, | 119 | Status FeedInputAddrByAnchor(const ge::InDataAnchorPtr &anchor, InputIndexOffsetInfo &index_offset_info, |
| 120 | bool is_gen_place_holder = false); | 120 | bool is_gen_place_holder = false); |
| 121 | 121 | ||
| 122 | - bool GetUnknownShapeFlag(); | 122 | + bool GetUnknownShapeFlag() const; |
| 123 | 123 | ||
| 124 | void AppendArgsTilingData(vector<void *> &device_addrs); | 124 | void AppendArgsTilingData(vector<void *> &device_addrs); |
| 125 | 125 | ||
Mcompiler/engines/nn_engine/optimizer/ops_kernel_builder/task_builder/args_format_constructor.cc+1-1
| @@ -494,7 +494,7 @@ Status ArgsFormatConstructor::GetArgsSize(size_t &args_size) { | |||
| 494 | return SUCCESS; | 494 | return SUCCESS; |
| 495 | } | 495 | } |
| 496 | 496 | ||
| 497 | -std::string ArgsFormatConstructor::GetArgsFormatString() { | 497 | +std::string ArgsFormatConstructor::GetArgsFormatString() const { |
| 498 | return format_desc_.ToString(); | 498 | return format_desc_.ToString(); |
| 499 | } | 499 | } |
| 500 | } // namespace fe | 500 | } // namespace fe |
| @@ -28,7 +28,7 @@ class ArgsFormatConstructor { | |||
| 28 | ~ArgsFormatConstructor() {}; | 28 | ~ArgsFormatConstructor() {}; |
| 29 | Status ConstructNodeArgsDesc(); | 29 | Status ConstructNodeArgsDesc(); |
| 30 | Status GetArgsSize(size_t &args_size); | 30 | Status GetArgsSize(size_t &args_size); |
| 31 | - std::string GetArgsFormatString(); | 31 | + std::string GetArgsFormatString() const; |
| 32 | 32 | ||
| 33 | private: | 33 | private: |
| 34 | Status ConstructOutArgsDesc(); | 34 | Status ConstructOutArgsDesc(); |
| @@ -120,7 +120,7 @@ class DeployPlan { | |||
| 120 | using ModelDeployInfo = std::map<std::string, std::map<std::string, std::set<DeviceInfo>>>; | 120 | using ModelDeployInfo = std::map<std::string, std::map<std::string, std::set<DeviceInfo>>>; |
| 121 | using AbnormalStatusCallback = std::function<Status(uint32_t, RootModelId2SubmodelName &)>; | 121 | using AbnormalStatusCallback = std::function<Status(uint32_t, RootModelId2SubmodelName &)>; |
| 122 | struct AbnormalStatusCallbackInfo { | 122 | struct AbnormalStatusCallbackInfo { |
| 123 | - std::mutex mu; | 123 | + mutable std::mutex mu; |
| 124 | // key: root_model_id, data:callback | 124 | // key: root_model_id, data:callback |
| 125 | std::map<uint32_t, AbnormalStatusCallback> callback_list; | 125 | std::map<uint32_t, AbnormalStatusCallback> callback_list; |
| 126 | }; | 126 | }; |
| @@ -53,7 +53,7 @@ Status Configurations::GetWorkingDir(std::string &working_dir) const { | |||
| 53 | return SUCCESS; | 53 | return SUCCESS; |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | -std::string Configurations::GetDeployResDir() { | 56 | +std::string Configurations::GetDeployResDir() const { |
| 57 | return information_.working_dir + "/runtime/deploy_res/"; | 57 | return information_.working_dir + "/runtime/deploy_res/"; |
| 58 | } | 58 | } |
| 59 | 59 | ||
| @@ -91,7 +91,7 @@ class Configurations { | |||
| 91 | 91 | ||
| 92 | const NodeConfig &GetLocalNode() const; | 92 | const NodeConfig &GetLocalNode() const; |
| 93 | 93 | ||
| 94 | - std::string GetDeployResDir(); | 94 | + std::string GetDeployResDir() const; |
| 95 | 95 | ||
| 96 | static Status GetResourceConfigPath(std::string &config_dir); | 96 | static Status GetResourceConfigPath(std::string &config_dir); |
| 97 | 97 | ||
| @@ -689,11 +689,11 @@ void AbnormalStatusHandler::DecreaseDeployingRootModelNum() { | |||
| 689 | deploying_root_model_cnt_--; | 689 | deploying_root_model_cnt_--; |
| 690 | } | 690 | } |
| 691 | 691 | ||
| 692 | -bool AbnormalStatusHandler::IsDeployingRootModel() { | 692 | +bool AbnormalStatusHandler::IsDeployingRootModel() const { |
| 693 | return deploying_root_model_cnt_.load() != 0U; | 693 | return deploying_root_model_cnt_.load() != 0U; |
| 694 | } | 694 | } |
| 695 | 695 | ||
| 696 | -bool AbnormalStatusHandler::IsAllCallbackInitFinished() { | 696 | +bool AbnormalStatusHandler::IsAllCallbackInitFinished() const { |
| 697 | std::lock_guard<std::mutex> lk(abnormal_status_callback_info_.mu); | 697 | std::lock_guard<std::mutex> lk(abnormal_status_callback_info_.mu); |
| 698 | return abnormal_status_callback_info_.callback_list.size() == deployed_models_.size(); | 698 | return abnormal_status_callback_info_.callback_list.size() == deployed_models_.size(); |
| 699 | } | 699 | } |
| @@ -88,8 +88,8 @@ class AbnormalStatusHandler { | |||
| 88 | void MonitorFileAndHeartbeatProc(const std::string &file_path, const int32_t &fd); | 88 | void MonitorFileAndHeartbeatProc(const std::string &file_path, const int32_t &fd); |
| 89 | Status GetMonitorFilePath(std::string &file_path); | 89 | Status GetMonitorFilePath(std::string &file_path); |
| 90 | void AbnormalStatusMonitorRun(); | 90 | void AbnormalStatusMonitorRun(); |
| 91 | - bool IsDeployingRootModel(); | 91 | + bool IsDeployingRootModel() const; |
| 92 | - bool IsAllCallbackInitFinished(); | 92 | + bool IsAllCallbackInitFinished() const; |
| 93 | Status DynamicSchedRecoverProc(uint32_t root_model_id); | 93 | Status DynamicSchedRecoverProc(uint32_t root_model_id); |
| 94 | Status HeartbeatMonitorProc(); | 94 | Status HeartbeatMonitorProc(); |
| 95 | 95 | ||
| @@ -74,7 +74,7 @@ void NodeDoneManager::Cond::Cancel() { | |||
| 74 | cv_.notify_all(); | 74 | cv_.notify_all(); |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | -bool NodeDoneManager::Cond::IsRelease() { | 77 | +bool NodeDoneManager::Cond::IsRelease() const { |
| 78 | const std::unique_lock<std::mutex> lk(cond_mu_); | 78 | const std::unique_lock<std::mutex> lk(cond_mu_); |
| 79 | return is_released_; | 79 | return is_released_; |
| 80 | } | 80 | } |
| @@ -33,7 +33,7 @@ class NodeDoneManager { | |||
| 33 | private: | 33 | private: |
| 34 | class Cond { | 34 | class Cond { |
| 35 | public: | 35 | public: |
| 36 | - bool IsRelease(); | 36 | + bool IsRelease() const; |
| 37 | void Release(); | 37 | void Release(); |
| 38 | void Cancel(); | 38 | void Cancel(); |
| 39 | bool Await(); | 39 | bool Await(); |
| @@ -43,7 +43,7 @@ class NodeDoneManager { | |||
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | private: | 45 | private: |
| 46 | - std::mutex cond_mu_; | 46 | + mutable std::mutex cond_mu_; |
| 47 | std::condition_variable cv_; | 47 | std::condition_variable cv_; |
| 48 | bool is_released_ = false; | 48 | bool is_released_ = false; |
| 49 | bool is_cancelled_ = false; | 49 | bool is_cancelled_ = false; |
| @@ -332,7 +332,7 @@ void HybridDavinciModel::SetModelDescVersion(const bool is_new_model_desc) { | |||
| 332 | } | 332 | } |
| 333 | } | 333 | } |
| 334 | 334 | ||
| 335 | -uint64_t HybridDavinciModel::GetSessionId() { | 335 | +uint64_t HybridDavinciModel::GetSessionId() const { |
| 336 | GE_CHECK_NOTNULL(impl_); | 336 | GE_CHECK_NOTNULL(impl_); |
| 337 | return impl_->GetSessionId(); | 337 | return impl_->GetSessionId(); |
| 338 | } | 338 | } |
| @@ -62,7 +62,7 @@ class HybridDavinciModel { | |||
| 62 | 62 | ||
| 63 | void SetLoadStream(const aclrtStream stream); | 63 | void SetLoadStream(const aclrtStream stream); |
| 64 | 64 | ||
| 65 | - uint64_t GetSessionId(); | 65 | + uint64_t GetSessionId() const; |
| 66 | 66 | ||
| 67 | uint32_t GetDeviceId() const; | 67 | uint32_t GetDeviceId() const; |
| 68 | 68 | ||