已合并
modify offsetElemCount logic & clang format update #3939
renshuojian创建于 7月9日
modify offsetElemCount logic & clang format update #3939
已合并
renshuojian创建于 7月9日
renshuojian
renshuojian
7月9日

描述

修改offsetElemCount 的默认值为0,因为offset是可选输入,在未提供offset的场景避免访问越界。

关联的Issue

https://gitcode.com/cann/ops-math/issues/2186

测试

david冒烟、obp冒烟

文档更新

类型标签

  • Bug修复
  • 新特性
  • 性能优化
  • 文档更新
  • 其他,请描述:
likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 renshuojian 的贡献)
renshuojianrenshuojian
7月9日 创建了 pull request,commit 92e2c80d
atomgit-bot
atomgit-bot
7月9日 评论:

变更摘要

该 PR 主要修正了 StatelessDropOutGenMask 算子中 offsetElemCount 的默认值逻辑,同时应用了 clang-format 代码格式化。核心改动是:当可选的 offset 输入不存在时,将 offsetElemCount 从原来错误的 2 改为正确的 0,并在内核侧增加相应的判空保护,避免对不存在的 offset 张量进行 GM 读取。

主要改动

  • offsetElemCount 默认值修正:在 stateless_drop_out_gen_mask_tiling_arch35.cppgetKeyAndCounter lambda 中,将 offsetElemCount 的默认值从 uint32_t offsetElemCount = 2; 改为 uint32_t offsetElemCount = 0;,使无可选 offset 输入时元数据传递正确。
  • 内核侧 offset 读取增加判空保护:在 stateless_drop_out_gen_mask_pt.hInit 方法中,对 counterGm_SetGlobalBuffer 和后续读取操作增加了 if (offsetElemCount > 0) 条件判断,当 offset 不可用时跳过 GM 访问,同时 counterVal0/counterVal1 保持初始值 0
  • 代码格式化(clang-format):对两个文件进行了统一的代码风格调整,包括 = 号两侧空格补充(如 CORE_ALIGN_SIZE =256CORE_ALIGN_SIZE = 256)、#include 多余空格去除、大括号换行对齐、lambda 参数列表换行、注释对齐、行尾多余空格清理以及文件末尾换行符修复。
likedislike
atomgit-bot
atomgit-bot
7月9日 评论:

代码审查

✅ 未发现问题

likedislike
CANN-robotCANN-robot成员
7月9日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
7月9日 评论:

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, 徐鲁威, 宋恺 (3/2) gcw_kUomxQ2l (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robot成员
7月9日 将zhou-qilong,wangrui_,rxtfeng,loov1,zhangzijie,jia0liang,songkai111,gitcode-chenjiao,llimwang,gubaocheng,andong_hw,zhanw_coding,gcw_kUomxQ2l,Andy-lb设为评审人
CANN-robotCANN-robot成员
7月9日 将gitcode-chenjiao,gcw_kUomxQ2l,Andy-lb设为审查人
renshuojian
renshuojian
7月9日 评论:

compile

likedislike
renshuojianrenshuojian
7月9日 update merge request[project id: 7649531, iid: 3939, commit_id: 00b0c710f11682efa96eb89ddf03d66f6e80e458] virtual merging success
CANN-robotCANN-robot成员
7月9日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
7月9日 评论:

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

任务名称状态日志下载链接
pre_comment ✅ SUCCESS >>>>>
Compile_harmony-infer ✅ SUCCESS >>>>>
Compile_X86_monitor_910b ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910c ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_950 ✅ SUCCESS >>>>> >>>>>
Compile_harmony-infer-chs-math ✅ SUCCESS >>>>>
Compile_kirin-harmony-infer-chs-math-1 ✅ SUCCESS >>>>>
UT_Test ✅ SUCCESS
UT_Test_experimental ✅ SUCCESS
UT_Test_kernel ✅ SUCCESS
PreSmoke_A900 ✅ SUCCESS >>>>>
PreSmoke_ATK_Test_A2 ✅ SUCCESS >>>>>

[2026-07-09 11:44:03]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
7月9日 评论:

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

任务名称状态日志下载链接
codecheck ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
codecheck_Pr ✅ SUCCESS
StaticCheck_codespell_check ✅ SUCCESS
StaticCheck_link_validity_check ✅ SUCCESS
StaticCheck_resource_existence_check ✅ SUCCESS
StaticCheck_tag_closed_check ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
codecheck_codestyle ⚠️ WARNING >>>>>
codecheck_precommit ⚠️ WARNING >>>>> >>>>>

[2026-07-09 11:40:33]    CI执行结束

likedislike
CANN-robotCANN-robot成员
7月9日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
7月9日 添加了label:ci-pipeline-passed
renshuojianrenshuojian
7月9日 修改了pull request 的描述
liulun0308成员
7月9日 评论:

/lgtm

likedislike
loov成员
7月9日 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
7月9日 添加了label:lgtm
RuiWang_成员
7月9日 评论:

/approve

likedislike
CANN-robot
CANN-robot成员
7月9日 评论:

The following users do not have permission to comment /lgtm or /approve on any module in this PR:
wangrui_

likedislike
songkai111成员
7月9日 评论:

/lgtm
/approve

likedislike
CANN-robot
CANN-robot成员
7月9日 评论:

The following users do not have permission to comment /lgtm or /approve on any module in this PR:
wangrui_

likedislike
songkai111成员
7月9日 评论:

/approve

likedislike
CANN-robot
CANN-robot成员
7月9日 评论:

The following users do not have permission to comment /lgtm or /approve on any module in this PR:
wangrui_

likedislike
liulun0308成员
7月9日 评论:

/approve

likedislike
CANN-robot
CANN-robot成员
7月9日 评论:

The following users do not have permission to comment /lgtm or /approve on any module in this PR:
wangrui_

likedislike
CANN-robotCANN-robot成员
7月9日 添加了label:approved
CANN-robotCANN-robot成员
7月9日 合入了pull request