已合并
【质量加固】补充成员函数 const 修饰以符合编码规范(#517) #4608
【质量加固】补充成员函数 const 修饰以符合编码规范(#517) #4608
已合并
qoosong创建于 13 天前
qoosong
13 天前

描述

响应 #517 "质量加固" 社区活动,修复 ge 仓中不符合规则1(成员函数 const 修饰)的代码问题。

不会修改成员变量的成员函数应使用 const 修饰。本次共修复 15 处成员函数缺少 const 修饰的问题,涉及 10 个文件,与既有 PR(#4597/#4594/#4497/#4572/#4496)无重复或冲突。

涉及文件及修复点:

文件 修复的成员函数 说明
inc/graph_metadef/register/graph_optimizer/buffer_fusion/buffer_fusion_pass_base.h BufferFusionPassBase::GetName() 返回 name_,不修改状态
inc/graph_metadef/register/ffts_node_converter_registry.h SkipCtxRecord::GetCtxNum() 仅读取 ctx_id_v->size()
inc/framework/runtime/subscriber/global_profiler.h GlobalProfilingWrapper::GetRecordCount() 调用 const 的 GetCount()
inc/framework/runtime/subscriber/global_profiler.h GlobalProfilingWrapper::IsEnabled() 仅读取 atomic load()
inc/framework/runtime/subscriber/global_dumper.h GlobalDumper::GetHandleSize() 仅读取 size(),mutex 改为 mutable
inc/graph_metadef/common/blocking_queue.h BlockingQueue::GetRemainItems() / IsFull() / Size() 仅读取,mutex 改为 mutable
runtime/v1/graph/load/model_manager/data_inputer.h DataInputer::Size() 转调 const 的 queue_.Size()
runtime/v1/graph/load/model_manager/davinci_model.h DavinciModel::GetDataInputerSize() 转调 const 的 data_inputer_.Size()
compiler/analyzer/analyzer.h Analyzer::IsEnableNetAnalyzeDebug() 仅读取环境变量
compiler/engines/nn_engine/fusion/.../fusion_rule_parser_utils.h FusionRuleParserUtils::GetEngineName() 仅返回 engine_name_,mutex 改为 mutable
compiler/engines/nn_engine/fusion/.../fusion_rule_json_pattern.h FusionRuleJsonNode::GetName() / FusionRuleJsonAnchor::GetSrcNode() / FusionRuleJsonAnchor::GetName() 仅返回成员变量

对于需要加锁的只读访问(GlobalDumper::GetHandleSizeBlockingQueue::IsFull/Size/GetRemainItemsFusionRuleParserUtils::GetEngineName),将互斥量声明为 mutable,以支持 const 成员函数内部的加锁,与既有 PR #4597 中 NodeDoneManager::Cond/DeployPlan 的处理方式一致。

变更类型

关联的Issue

#517

如何测试

  1. 本地执行 pre-commit 检查(clang-format/codespell/end-of-file-fixer 等)全部 Passed
  2. 变更均为添加 const 修饰及 mutable 互斥量,不改变运行时行为,编译期即可验证

核对清单

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 qoosong 的贡献)
Qqoosong
13 天前 创建了 pull request,commit 9a65a040
Qqoosong
13 天前 关联了issue:GE定向“质量加固”社区有奖任务
atomgit-bot
atomgit-bot
13 天前 评论:

变更摘要

本 PR 响应 #517「质量加固」社区活动,为 ge 仓中不修改成员变量的成员函数补充 const 修饰,共修复 10 个文件、15 处缺失 const 的成员函数,使代码符合规则 1(成员函数 const 修饰)的编码规范。所有改动均为添加 const 限定符及将互斥量声明为 mutable,不改变运行时行为,可通过编译期验证。

主要改动

  • 为纯读取型 Getter 添加 const 修饰BufferFusionPassBase::GetName()SkipCtxRecord::GetCtxNum()FusionRuleJsonNode::GetName()FusionRuleJsonAnchor::GetSrcNode()/GetName()Analyzer::IsEnableNetAnalyzeDebug() 等仅返回成员变量或读取环境变量的函数改为 const 成员函数。
  • 为转调链上的查询函数添加 const 修饰DataInputer::Size()DavinciModel::GetDataInputerSize() 改为 const,以转调已是 constqueue_.Size()data_inputer_.Size()
  • 为带锁的只读访问函数添加 const 并声明 mutable 互斥量GlobalDumper::GetHandleSize()BlockingQueue::GetRemainItems()/IsFull()/Size()FusionRuleParserUtils::GetEngineName() 在加 const 的同时,将其内部 mutex_/parse_mutex_ 声明为 mutable,以支持 const 成员函数内部加锁,与既有 PR #4597 的处理方式保持一致。
  • 为原子状态读取函数添加 const 修饰GlobalProfilingWrapper::GetRecordCount()IsEnabled() 改为 const,仅通过 global_profiler_->GetCount()enable_flags_.load() 进行只读访问。
likedislike
不准确?
atomgit-bot
atomgit-bot
13 天前 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robot
CANN-robot成员
13 天前 评论:

Hi @qoosong, 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.

likedislike
CANN-robotCANN-robot成员
13 天前 添加了label:cann-cla/no
CANN-robot
CANN-robot成员
13 天前 评论:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


PR Approval Progress

Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
compiler/engines/nn_engine 张德鹏, Mexyy, zhanj (3/2) 张德鹏 (1/1)
repo-cann/ge 张德鹏, Mexyy, zhanj (3/2) 张德鹏 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

qoosong, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robotCANN-robot成员
13 天前 将yangyongqiang0606,kobemini,ClarkXie,tangqunzhang,xchu42,hugo111,lining23666,fu-jun2,depeng1994,wqtshg_wt,peiyang,shengnan666,zhangfan_hanq,arthur_morgan_hw,zhanj,zhujingjing,jason_yuan_ye,Mexyy,lijunyu_111,wangxiaotian995,stevenaw0,yuht9设为评审人
CANN-robotCANN-robot成员
13 天前 将yangyongqiang0606,kobemini,ClarkXie,tangqunzhang,xchu42,hugo111,lining23666,fu-jun2,depeng1994,wqtshg_wt,peiyang,shengnan666,zhangfan_hanq,arthur_morgan_hw,zhanj,zhujingjing,jason_yuan_ye,Mexyy,lijunyu_111,wangxiaotian995,stevenaw0,yuht9设为审查人
qoosong
13 天前 评论:

/check-cla

likedislike
CANN-robot
CANN-robot成员
13 天前 评论:

CLA检查未通过,详情可参考这里

likedislike
Qqoosong
13 天前 update merge request[project id: 8824148, iid: 4608, commit_id: 6604658f0bc2fb853fd0aeafe8786d2421bb7f51] virtual merging success
Qqoosong
13 天前 强制推送  1 个提交:01ddb3a6-fix: 补充成员函数 const 修饰以符合编码规范(#517)
Qqoosong
13 天前 update merge request[project id: 8824148, iid: 4608, commit_id: 09f20774915bb0328c8b0df042aae8c6cc3428f2] virtual merging success
CANN-robotCANN-robot成员
13 天前 删除了label:cann-cla/no
CANN-robotCANN-robot成员
13 天前 添加了label:cann-cla/yes
qoosong
13 天前 评论:

compile

likedislike
Qqoosong
13 天前 update merge request[project id: 8824148, iid: 4608, commit_id: 5085bc93f51b9658d7e72dbbca32863bd1f2cab6] virtual merging success
CANN-robotCANN-robot成员
13 天前 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
13 天前 评论:

流水线任务触发成功
任务链接 [d9849d49e4414876bcb84d97200672fd][流水线指导]

任务名称状态日志下载链接
pre_comment ✅ SUCCESS >>>>>
Compile_X86_compiler ✅ SUCCESS >>>>> >>>>>
Compile_X86_executor ✅ SUCCESS >>>>> >>>>>
Compile_X86_dflow ✅ SUCCESS >>>>> >>>>>
UT_Test_dflow ✅ SUCCESS
UT_Test_ge_common ✅ SUCCESS
UT_Test_parser ✅ SUCCESS
UT_Test_python ✅ SUCCESS >>>>>
UT_Test_rt ✅ SUCCESS
UT_Test_acl ✅ SUCCESS
UT_Test_autofuse ✅ SUCCESS
UT_Test_executor ✅ SUCCESS
UT_Test_autofuse_ascendc_api ✅ SUCCESS
ST_Test_dflow ✅ SUCCESS
ST_Test_ge_common ✅ SUCCESS
ST_Test_parser ✅ SUCCESS
ST_Test_python ✅ SUCCESS >>>>>
ST_Test_rt ✅ SUCCESS
ST_Test_autofuse ✅ SUCCESS
ST_Test_executor ✅ SUCCESS
ST_Test_hetero ✅ SUCCESS
ST_Test_autofuse_ascendc_api ✅ SUCCESS
ST_Test_autofuse_e2e ✅ SUCCESS
UT_Test_fe ✅ SUCCESS
UT_Test_tefusion ✅ SUCCESS
ST_Test_fe ✅ SUCCESS
ST_Test_tefusion ✅ SUCCESS
ST_Test_ge_common_atc ✅ SUCCESS
UT_Test_Report_graphengine ✅ SUCCESS >>>>>
UT_Test_Report_ge_executor_c ✅ SUCCESS >>>>>
UT_Test_Report_ge_autofuse ✅ SUCCESS >>>>>
ST_Test_Report_graphengine ✅ SUCCESS >>>>>
ST_Test_Report_ge_executor_c ✅ SUCCESS >>>>>
ST_Test_Report_ge_autofuse ✅ SUCCESS >>>>>
UT_Test_Report_fe ✅ SUCCESS >>>>>
ST_Test_Report_fe ✅ SUCCESS >>>>>

[2026-08-28 01:36:50]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
13 天前 评论:

流水线任务触发成功
任务链接 [9de97404f83b4b88b1b7bd2735d5fe53][流水线指导]

任务名称状态日志下载链接
pre_comment ✅ SUCCESS >>>>>
Compile_X86_compiler_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_X86_executor_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_X86_dflow_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_ARM_compiler_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_ARM_executor_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_ARM_dflow_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_ARM_compiler ✅ SUCCESS >>>>> >>>>>
Compile_ARM_executor ✅ SUCCESS >>>>> >>>>>
Compile_ARM_dflow ✅ SUCCESS >>>>> >>>>>
API_Check ✅ SUCCESS >>>>>
PreSmoke_A900_npupool ✅ SUCCESS >>>>>

[2026-08-28 01:32:31]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
13 天前 评论:

流水线任务触发成功
任务链接 [4412798fcba24a828920be2259ae0f63][流水线指导]

任务名称状态日志下载链接
codecheck_Pr ✅ SUCCESS
antipoison ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>
codecheck_dt ✅ SUCCESS >>>>>
codecheck_precommit ✅ SUCCESS >>>>>
StaticCheck_codespell ✅ SUCCESS
StaticCheck_link_validity ✅ SUCCESS
StaticCheck_resource_existence ✅ SUCCESS
StaticCheck_tag_closed ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS

[2026-08-28 01:19:24]    CI执行结束

likedislike
CANN-robotCANN-robot成员
13 天前 添加了label:api-check-pass
CANN-robotCANN-robot成员
13 天前 删除了label:api-check-pass
CANN-robotCANN-robot成员
13 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
13 天前 添加了label:ci-pipeline-passed
夏国正成员
12 天前 评论:

/lgtm

likedislike
zhanj
zhanj成员
12 天前 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
12 天前 添加了label:lgtm
张德鹏成员
11 天前 评论:

/approve

likedislike
CANN-robotCANN-robot成员
11 天前 添加了label:approved
CANN-robotCANN-robot成员
11 天前 合入了pull request