Pull Request已成功合入, 合并人@CANN-robot
(感谢 Chao-Wu 的贡献)变更摘要
本 PR 修复了 SyncBatchNormGatherStatsFused kernel 在 Tiling 阶段遗漏设置调度模式的 Bug。该 kernel 内部使用了 SyncAll 全核同步机制,但对应的 Tiling 实现未调用 SetScheduleMode 将其置为 BATCH_MODE,可能导致调度行为不符合预期。修复方式是在四个 Tiling 子类的 PostTiling() 方法中统一添加 context_->SetScheduleMode(1) 调用。
主要改动
SyncBatchNormGatherStatsFusedCommonTiling::PostTiling补充调度模式设置:在sync_batch_norm_gather_stats_fused_common_tiling.cpp中,SetBlockDim之后新增context_->SetScheduleMode(1),将调度模式显式设为BATCH_MODE,与 kernel 的SyncAll行为对齐。SyncBatchNormGatherStatsFusedFirstAxisCommonTiling::PostTiling补充调度模式设置:在sync_batch_norm_gather_stats_fused_first_axis_common_tiling.cpp中同步添加相同调用,覆盖 first-axis 分支的通用 Tiling 场景。SyncBatchNormGatherStatsFusedFirstAxisWorkspaceTiling::PostTiling补充调度模式设置:在sync_batch_norm_gather_stats_fused_first_axis_workspace_tiling.cpp中同步添加相同调用,覆盖 first-axis 分支的 Workspace Tiling 场景。SyncBatchNormGatherStatsFusedWorkspaceTiling::PostTiling补充调度模式设置:在sync_batch_norm_gather_stats_fused_workspace_tiling.cpp中同步添加相同调用,覆盖通用 Workspace Tiling 场景。


代码审查
审查总结
变更概述
本 PR 在 SyncBatchNormGatherStatsFused 算子的四个 tiling 变体的 PostTiling() 方法中分别添加了 context_->SetScheduleMode(1) 调用,将调度模式设置为 BatchMode,以确保 kernel 中的 SyncAll() 全核同步正确工作(所有核同时启动,避免死锁或归约结果错误)。
审查结论
| 文件 | 审查结果 |
|---|---|
sync_batch_norm_gather_stats_fused_common_tiling.cpp |
1 个 P3 建议 |
sync_batch_norm_gather_stats_fused_first_axis_common_tiling.cpp |
1 个 P3 建议 |
sync_batch_norm_gather_stats_fused_first_axis_workspace_tiling.cpp |
1 个 P3 建议 |
sync_batch_norm_gather_stats_fused_workspace_tiling.cpp |
1 个 P3 建议 |
- P0: 0
- P1: 0
- P2: 0
- P3: 4(均为同一建议:检查
SetScheduleMode返回值,避免静默失败)
整体风险评估:低风险
核心修复逻辑正确且完整——四个 tiling 变体与四个使用 SyncAll 的 kernel 变体一一对应,添加的 SetScheduleMode(1) 调用位置(PostTiling 中 SetBlockDim 之后)与仓库中大多数参考实现一致。唯一可改进之处是返回值未检查,多数同类代码也存在此模式,属于可选的健壮性增强。
⚠️ 已识别出整体风险,但无法提取行内评论,请参考整体评估。


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
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| ** | ✅ gcw_kUomxQ2l, 唐玮玮 (2/2) | ✅ gcw_kUomxQ2l (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)


compile


流水线任务触发成功
任务链接 [fc68dac933fc4d048475ff4beb6a7f69][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86_mobile_station | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Pre | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910b | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910c | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_harmony-infer-chs-nn | ✅ SUCCESS | >>>>> | |
| UT_Test_ophost | ✅ SUCCESS | ||
| UT_Test_opapi | ✅ SUCCESS | ||
| UT_Test_kernel | ✅ SUCCESS | ||
| UT_Test_opgraph | ✅ SUCCESS | ||
| PreSmoke_A900 | ✅ SUCCESS | >>>>> | |
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> |
[2026-07-07 10:15:07] CI执行结束


流水线任务触发成功
任务链接 [0aa07f16a06044e58891f6179f3cdecf][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| codecheck_checkpr | ✅ SUCCESS | ||
| StaticCheck_codespell_check | ✅ SUCCESS | ||
| StaticCheck_link_validity_check | ✅ SUCCESS | ||
| StaticCheck_resource_existence_check | ✅ SUCCESS | ||
| StaticCheck_tag_closed_check | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS | ||
| codecheck_style | ✅ SUCCESS | >>>>> | |
| codecheck_precommit | ⚠️ WARNING | >>>>> | >>>>> |
| SCA | ✅ SUCCESS | >>>>> |
[2026-07-07 10:10:46] CI执行结束


/approve


/lgtm
/approve


描述
SyncBatchNormGatherStatsFused kernel 使用 SyncAll 但 Tiling 并设置 SetScheduleMode(BATCH_MODE)
关联的Issue
https://gitcode.com/cann/ops-nn/issues/3872
测试
冒烟,测试均通过
文档更新
类型标签
AI/Agent生成声明