Pull Request已成功合入, 合并人@CANN-robot
(感谢 味蕾木柚 的贡献)变更摘要
本 PR 是针对编译与运行时模块的代码质量修复,共 16 处修改,覆盖 3 条编码规范规则,涉及 11 个文件:为只读 getter 与只读参数添加 const 修饰,并消除 lambda 的默认捕获模式,改用无捕获或显式捕获,以明确接口只读语义、提升代码规范性。
主要改动
- 成员函数添加
const修饰:为BaseNodePass的 6 个只读 getter(GetNodesNeedRePass、GetNodesNeedRePassImmediately、GetGlobalNodesNeedRePassImmediately、GetNodesDeleted、GetNodesSuspend、GetNodesResume)以及BaseCluster::GetPartitionedCallName()、Pass::GetName()添加const限定,明确这些方法不修改成员状态。 - 参数添加
const修饰:将omg.cc中的CheckDigitStr、StringToInt,acl_graph_parser_util.cc中的CheckDigitStr的std::string参数,以及TeFileUtils::IsFileUsed的filePath参数(te_file_utils.h/.cc)由非 const 引用改为const引用,声明参数只读语义。 call_oncelambda 去除默认捕获:AicpuKernelBuilder::Instance()、AicpuKernelInfo::Instance()、AicpuOptimizer::Instance()中std::call_once的 lambda 由[&]改为[],因仅操作静态成员instance_,无需捕获外部变量。- 线程 lambda 改为显式捕获:
TaskThread::Start中std::thread的 lambda 由[=]改为[runnable],仅显式捕获实际使用的Runnable对象,避免默认捕获整个作用域。


Hi @m0_63918125, welcome to submitting your first PR to ge!
PR Merge Steps
1. CLA Signing
If the current PR label includes cann-cla/yes, it means you have signed the CLA and can proceed to the next step. If the label includes cann-cla/no, please sign the CLA first. If you have any questions, please refer to the FAQ.
2. CI Check
Please comment /compile to trigger the CI pipeline check. If the CI run is successful, the PR will be tagged with ci-pipeline-passed and you can proceed to the next step. If the CI run fails, the PR will be tagged with ci-pipeline-failed, please check the CI logs to fix the issues in the PR. If you have any questions, please refer to the FAQ.
3. Code Review
After CI passes, please refer to the PR Approval Progress and proactively @ the committers in the table to review the code. After approval, committers will comment /lgtm and /approve. Once the lgtm and approved labels are successfully added, the PR will be merged automatically.


/approve


修改内容
共 16 处代码质量修复,覆盖 3 条编码规范规则,涉及 11 个文件。
规则1:成员函数 const 修饰(8处)
compiler/graph/passes/base_pass.h:6 个只读 getter 添加 constcompiler/graph/partition/base_cluster.h:GetPartitionedCallName() 添加 constinc/.../graph_fusion_pass.h:GetName() 添加 const规则2:参数 const 修饰(4处)
api/atc/omg.cc:CheckDigitStr/StringToInt 的 string 参数添加 constcompiler/.../te_file_utils.h/.cc:IsFileUsed 的 filePath 参数添加 constparser/.../acl_graph_parser_util.cc:CheckDigitStr 的 string 参数添加 const规则9:lambda 避免默认捕获模式(4处)