已合并
【质量加固】style: 补充 const 限定符与显式 lambda 捕获 #1797
【质量加固】style: 补充 const 限定符与显式 lambda 捕获 #1797
已合并
gcw_fHR9mxR5创建于 8月21日
gcw_fHR9mxR5
gcw_fHR9mxR5
8月21日

依据 Issue #238 质量加固活动规则,修复 autofuse 下 10 处代码规范问题,不改变运行时行为。

规则1 · 只读成员函数补充 const 限定符(7 处)

  1. micro_api_call.h: GetInputSize / GetInputTensorIdByIndex / GetOutputTensorIdByIndex / GetMicroApiName
  2. tuning_space.h: GetCoTensors
  3. lowering_global_data.h: GetHostResourceCenter
  4. node_impl.h: GetOrigNode

规则9 · lambda 默认捕获改为显式捕获(3 处)
5. codegen_api_param_dump.cpp:77 [&] -> [&ss, &indent]
6. tiling_code_gen_impl.cpp:5194/5208 两处 [&] -> [&name]
7. tiling_code_gen_impl.cpp:3945 [&] -> 显式列出所捕获的成员与 this

以上改动均为 const 正确性补充与 lambda 显式捕获,已通过 Git Hooks 检查。

实际改动对照(11 处 diff,描述中合并表述)

规则 文件 函数/位置 行
1 micro_api_call.h GetInputSize 86
1 micro_api_call.h GetInputTensorIdByIndex 95
1 micro_api_call.h GetOutputTensorIdByIndex 100
1 micro_api_call.h GetMicroApiName 104
1 tuning_space.h GetCoTensors 209
1 lowering_global_data.h GetHostResourceCenter 169
1 node_impl.h GetOrigNode 124
9 codegen_api_param_dump.cpp dump_expr_vec lambda 77
9 tiling_code_gen_impl.cpp find_if lambda 5194
9 tiling_code_gen_impl.cpp find_if lambda 5208
9 tiling_code_gen_impl.cpp emit_get_tiling lambda 3945
likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 gcw_fHR9mxR5 的贡献)
gcw_fHR9mxR5gcw_fHR9mxR5
8月21日 添加了label:enhancement
gcw_fHR9mxR5gcw_fHR9mxR5
8月21日 创建了 pull request,commit e26dc008
gcw_fHR9mxR5gcw_fHR9mxR5
8月21日 关联了issue:【质量加固】AutoFusion定向“质量加固”社区有奖任务
atomgit-bot
atomgit-bot
8月21日 评论:

变更摘要

本 PR 依据 Issue #238 质量加固活动规则,针对 autofuse 下 11 处代码规范问题做纯风格修复,不改变运行时行为:一方面为 7 个只读成员函数补充 const 限定符以完善 const 正确性,另一方面将 4 处 lambda 的默认捕获 [&] 改为显式捕获列表。所有改动均通过 Git Hooks 检查。

主要改动

  • 只读成员函数补充 const 限定符(micro_api_call.h): MicroApiCall 的 GetInputSize、GetInputTensorIdByIndex、GetOutputTensorIdByIndex、GetMicroApiName 四个访问器由非 const 改为 const 成员函数,使只读查询可作用于 const 对象。
  • 其余访问器补充 const 限定符: tuning_space.h 的 Container::GetCoTensors、lowering_global_data.h 的 LoweringGlobalData::GetHostResourceCenter、node_impl.h 的 Node::NodeImpl::GetOrigNode 均改为 const 成员函数,仅返回内部成员值、不改状态。
  • lambda 显式捕获(codegen_api_param_dump.cpp): DumpMergeAxesInfo 中 dump_expr_vec lambda 的捕获由 [&] 改为 [&ss, &indent],仅捕获实际使用的两个局部变量。
  • lambda 显式捕获(tiling_code_gen_impl.cpp): GenFillOtherGroupsGetTiling 中 emit_get_tiling lambda 由 [&] 改为显式列出所捕获的成员与 this;GenConflictExprContextCode 中两处 find_if/any_of 的 lambda 由 [&] 改为 [&name],仅捕获比较目标变量。
likedislike
不准确?
CANN-robot
CANN-robot成员
8月21日 评论:

Hi @gcw_fHR9mxR5, welcome to submitting your first PR to graph-autofusion!

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
此处折叠了199条消息 查看更多
xuyafei成员
29 天前 评论:

/lgtm

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

/approve

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