已合并
【质量加固】显式声明部分 lambda 捕获列表 #1756
【质量加固】显式声明部分 lambda 捕获列表 #1756
已合并
小白学习者创建于 8月17日
小白学习者
8月17日

变更说明

本 PR 用于参与 issue #238 的“质量加固”活动。

本次在 autofuse 目录内对 10 处 C++ lambda 默认捕获进行显式捕获声明,避免使用 [&] 默认捕获模式。

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 小白学习者 的贡献)
小白学习者小白学习者
8月17日 添加了label:enhancement
小白学习者小白学习者
8月17日 创建了 pull request,commit 05a0d77d
小白学习者小白学习者
8月17日 关联了issue:【质量加固】AutoFusion定向“质量加固”社区有奖任务
atomgit-bot
atomgit-bot
8月17日 评论:

变更摘要

本 PR 属于 issue #238 “质量加固”活动的一部分,核心目标是在 autofuse 目录内消除 C++ lambda 的 [&] 默认捕获模式,改为显式声明捕获列表,使 lambda 对外部变量的依赖关系更加清晰、可读且更易于维护。改动涉及 arg_list_reorder.cpptiling_code_gen_impl.cppcodegen.cppstatic_ub_template_filter.cpprecompute_case_generator.cpp 共 5 个文件,均为捕获列表的显式化调整,不改变原有业务逻辑。

主要改动

  • arg_list_reorder.cpp 显式捕获成员与局部变量:将 IsReduceInputTensor 的 lambda 捕获改为 [this, reduce_axis, &reduce_axis_ori_axes_set]IsReduceTailTileAxis 改为 [tail_axis]MakeSureLoadStoreInnerestSameOrder 改为 [this],显式区分值捕获与引用捕获。

  • tiling_code_gen_impl.cpp 显式捕获比较参数与引用变量:将 TryGenPGOByCoreNumReuseTilingfind_if 的 lambda 捕获改为 [asc_graph_id, impl_graph_id, group_id],并将 GenConflictExprContextCodeemit_decl 的捕获改为 [&code, &declared_symbols]

  • codegen.cpp 显式捕获 this 与引用参数:将 GenerateForInductorgenerate_tiling_without_pgo lambda 的捕获改为 [this, &fused_schedule_result, &result],明确对成员及输出参数的引用依赖。

  • static_ub_template_filter.cpp 显式捕获可变状态与索引:将两处 remove_if lambda 分别改为 [&schedule_group, &impl_idx, &state, node_idx, result_idx, group_idx][&state, node_idx, &result_idx],明确其读写的外部状态。

  • recompute_case_generator.cpp 显式捕获检查函数:将 IsRecomputableNode 中两处 all_of lambda 分别改为 [&check_static_tensor][&check_dynamic_tensor],仅捕获实际使用的谓词函数。

likedislike
不准确?
CANN-robot
CANN-robot成员
8月17日 评论:

Hi @wzx_0826, 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
此处折叠了57条消息 查看更多
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