已合并
cunsum 算子修改不过的用例 #3460
wangweidong创建于 6月22日
cunsum 算子修改不过的用例 #3460
已合并
wangweidong创建于 6月22日
wangweidong
6月22日

描述

关联的Issue

测试

文档更新

类型标签

  • Bug修复
  • 新特性
  • 性能优化
  • 文档更新
  • 其他,请描述:
likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 wangweidong 的贡献)
Wwangweidong
6月22日 创建了 pull request,commit a4394d56
CANN-robotCANN-robot成员
6月22日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
6月22日 评论:

CLA Signature Pass

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

likedislike
CANN-robot
CANN-robot成员
6月22日 评论:

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
math/cumsum jia0liang, 周奇龙 (2/2) 周奇龙, jia0liang (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
wangweidong
6月22日 评论:

compile

likedislike
Wwangweidong
6月22日 update merge request[project id: 7649531, iid: 3460, commit_id: 1977690aefbb985144ffaabfec9564ea0104605f] virtual merging success
CANN-robotCANN-robot成员
6月22日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
6月22日 评论:

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

任务名称状态日志下载链接
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_A5 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_A5 ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
Compile_harmony-infer ✅ SUCCESS >>>>>
Compile_X86_monitor_910b ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910c ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_950 ✅ SUCCESS >>>>> >>>>>

[2026-06-22 12:46:35]    CI执行结束

likedislike
Wwangweidong
6月22日 update merge request[project id: 7649531, iid: 3460, commit_id: 6f37d9b831f5a69ba8467aec94e488e3d6c9a23e] virtual merging success
此处折叠了5条事件消息 查看更多
Wwangweidong
6月22日 update merge request[project id: 7649531, iid: 3460, commit_id: 78f5b1565f89a2099cfe7e6626832be8b5404913] virtual merging success
wangweidong
6月22日 评论:

compile

likedislike
Wwangweidong
6月22日 update merge request[project id: 7649531, iid: 3460, commit_id: 656bd0e67826223f67dba1fa45fe9e10d056d7b4] virtual merging success
CANN-robotCANN-robot成员
6月22日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
6月22日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
6月22日 评论:

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

任务名称状态日志下载链接
codecheck ❌ FAILED None
SCA ✅ SUCCESS >>>>>
antipoison ❌ FAILED
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_precommit ⚠️ WARNING >>>>> >>>>>
likedislike
CANN-robot
CANN-robot成员
6月22日 评论:

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

任务名称状态日志下载链接
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_A5 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_A5 ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
Compile_harmony-infer ✅ SUCCESS >>>>>
Compile_X86_monitor_910b ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910c ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_950 ✅ SUCCESS >>>>> >>>>>
UT_Test ✅ SUCCESS
UT_Test_experimental ✅ SUCCESS
UT_Test_kernel ✅ SUCCESS
PreSmoke_A900 ✅ SUCCESS >>>>>
PreSmoke_ATK_Test_A2 ✅ SUCCESS >>>>>

[2026-06-22 12:57:12]    CI执行结束

likedislike
atomgit-bot
atomgit-bot
6月22日 评论:

变更摘要

此 PR 针对 cumsum_twoway_sklansky.h 中双向折叠 cumsum 算子的非对齐数据拷出逻辑与 gather 偏移计算进行修复,主要解决 rFoldCount 为 1(无多次折叠场景)时因错误进入脏数据处理分支导致的测试用例失败问题。核心改动包括:引入折叠次数门控常量跳过不必要的非对齐处理、精确化非对齐拷贝长度、以及为 VfGatherBeforeSecondSkalansky 的偏移计算增加无符号下溢保护。

主要改动

  • 新增门控常量 kMinMultiFoldCount:值为 1,在 BaseCopyOut 中以 rFoldCount > kMinMultiFoldCount 条件控制 dirtyDataNum 的计算,仅在多次折叠(rFoldCount ≥ 2)时才进入脏数据对齐处理分支,避免单次折叠场景下的错误行为。
  • VfNoAlignCopyOut 签名扩展:新增 uint32_t actualNum 参数,内部 blockLen 由固定的 BLOCK_SIZE 改为 actualNum * sizeof(DataType),使 DataCopyPad 仅拷贝实际需要的补齐元素数而非整块,避免过拷贝导致的偏移错位。
  • BaseCopyOut 中变量作用域与计算顺序调整:将 dirtyDataNummixDataLen 提升到外层作用域并初始化零值;remainder 计算移至 VfNoAlignCopyOut 调用之前,确保传入的 actualNummixDataLen - remainder)正确反映对齐补齐量。
  • VfGatherBeforeSecondSkalansky 偏移安全计算:将原先 rFoldCount * foldOneElem_ - numAlignBlock_(可能无符号下溢)拆分为先判断 rFoldCount * foldOneElem_ < numAlignBlock_ 再决定 baseOffset 为 0 或差值,仅在 isReverse 时使用该偏移,防止因折叠元素数小于对齐块数导致的巨大偏移错误。
likedislike
CANN-robot
CANN-robot成员
6月22日 评论:

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

任务名称状态日志下载链接
codecheck ❌ FAILED None
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 None
codecheck_precommit ⚠️ WARNING >>>>> >>>>>
likedislike
CANN-robotCANN-robot成员
6月22日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
6月22日 添加了label:ci-pipeline-failed
atomgit-bot
atomgit-bot
6月22日 评论:

代码审查

审查总结

优先级 数量
P0 0
P1 0
P2 0
P3 1

已审查的文件:

  • math/cumsum/op_kernel/arch35/cumsum_base/cumsum_twoway_sklansky.h — 发现 1 个 P3 命名规范问题(常量 kMinMultiFoldCount 应改为 MIN_MULTI_FOLD_COUNT 以与文件中其他 UPPER_CASE 常量保持一致)。

整体风险评估:低。 此 diff 的核心逻辑变更(VfGatherBeforeSecondSkalansky 的无符号下溢保护、BaseCopyOutrFoldCount <= 1 时跳过非对齐拷贝、VfNoAlignCopyOut 中精确的 blockLen 计算)均为正确的边界情况修复,与 PR 描述"修改不过的用例"目标一致。未发现正确性、安全性或可靠性方面的回归问题。唯一报告的问题是常量命名的风格不一致,不影响运行时行为。

类型 数量
🔴 阻塞 0
🟡 建议 1

💬 仅评论

likedislike
atomgit-bot
atomgit-bot6月22日进行代码检视1
math/cumsum/op_kernel/arch35/cumsum_base/cumsum_twoway_sklansky.h
@@ -1,9 +1,9 @@
11/**
2-* Copyright (c) 2025 Huawei Technologies Co., Ltd.
2+ * Copyright (c) 2025 Huawei Technologies Co., Ltd.
33 * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
44 * CANN Open Software License Agreement Version 2.0 (the "License").
55 * Please refer to the License for details. You may not use this file except in compliance with the License.
@@ -57,6 +57,7 @@ public:
5757 constexpr static uint32_t MAX_REPEAT_TIME = 255;
5858 constexpr static uint32_t MAX_REPEAT_TIME_ELEM = MAX_REPEAT_TIME * VL_ELEM;
5959 constexpr static uint32_t MAX_FOLD = 8; // 双向折叠场景下,最大折叠次数为8
atomgit-bot
atomgit-bot6月22日评论:

🔵 Low Priority

该文件中所有其他类级常量均使用 UPPER_CASE 命名(如 BLOCK_SIZEMAX_NVL_SIZEMAX_FOLD 等),但新增的常量 kMinMultiFoldCount 使用了 k 前缀 + PascalCase 风格,与文件内一致的 UPPER_CASE 命名规范不符。根据该文件的审查规则"constants in UPPER_CASE",应统一命名风格。

建议:将常量重命名为 MIN_MULTI_FOLD_COUNT,与文件中其他常量(BLOCK_SIZE、MAX_N、VL_SIZE、MAX_FOLD 等)的 UPPER_CASE 风格保持一致。同时更新第 318 行引用处。

改动建议
59
- constexpr static uint32_t MAX_FOLD = 8; // 双向折叠场景下,最大折叠次数为8
59
+ constexpr static uint32_t MIN_MULTI_FOLD_COUNT = 1;
应用建议
likedislike
wangweidong
6月22日 评论:

compile

likedislike
Wwangweidong
6月22日 update merge request[project id: 7649531, iid: 3460, commit_id: 68a116a585f96b93a1426922a0a679424d51e12e] virtual merging success
CANN-robotCANN-robot成员
6月22日 删除了label:ci-pipeline-failed
CANN-robotCANN-robot成员
6月22日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
6月22日 评论:

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

任务名称状态日志下载链接
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_A5 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_A5 ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
Compile_harmony-infer ✅ SUCCESS >>>>>
Compile_X86_monitor_910b ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910c ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_950 ✅ SUCCESS >>>>> >>>>>
UT_Test ✅ SUCCESS
UT_Test_experimental ✅ SUCCESS
UT_Test_kernel ✅ SUCCESS
PreSmoke_A900 ✅ SUCCESS >>>>>
PreSmoke_ATK_Test_A2 ✅ SUCCESS >>>>>

[2026-06-22 14:54:19]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
6月22日 评论:

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

任务名称状态日志下载链接
codecheck ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>
antipoison ❌ FAILED >>>>>
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 ✅ SUCCESS >>>>>
codecheck_precommit ⚠️ WARNING >>>>> >>>>>
likedislike
CANN-robotCANN-robot成员
6月22日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
6月22日 添加了label:ci-pipeline-failed
wangweidong
6月22日 评论:

compile

likedislike
Wwangweidong
6月22日 update merge request[project id: 7649531, iid: 3460, commit_id: b1d43667a3f33b6ccf5d21baab8dd3cbe673439a] virtual merging success
CANN-robotCANN-robot成员
6月22日 删除了label:ci-pipeline-failed
CANN-robotCANN-robot成员
6月22日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
6月22日 评论:

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

任务名称状态日志下载链接
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_A5 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_A5 ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
Compile_harmony-infer ✅ SUCCESS >>>>>
Compile_X86_monitor_910b ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910c ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_950 ✅ SUCCESS >>>>> >>>>>
UT_Test ✅ SUCCESS
UT_Test_experimental ✅ SUCCESS
UT_Test_kernel ✅ SUCCESS
PreSmoke_A900 ✅ SUCCESS >>>>>
PreSmoke_ATK_Test_A2 ✅ SUCCESS >>>>>

[2026-06-22 19:46:46]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
6月22日 评论:

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

任务名称状态日志下载链接
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 ✅ SUCCESS >>>>>
codecheck_precommit ⚠️ WARNING >>>>> >>>>>

[2026-06-22 19:43:49]    CI执行结束

likedislike
CANN-robotCANN-robot成员
6月22日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
6月22日 添加了label:ci-pipeline-passed
sunday成员
6月24日 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
6月24日 添加了label:approved
Wwangweidong
6月24日 修改了pull request 的描述
NerdddddddddddNerddddddddddd成员
6月24日 解决了最后一个问题
陈佳良成员
6月24日 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
6月24日 添加了label:lgtm
CANN-robotCANN-robot成员
6月24日 合入了pull request