Merged
修复950 Load2d接口 #4307
UFOunderAdd on Jul 13
修复950 Load2d接口 #4307
Merged
UFOunderAdd on Jul 13
UFOunderCollaborators
Jul 13

描述

修复950 Load2d接口L1 Buffer到L0B Buffer转置场景下的问题。

关联的Issue

测试

文档更新

类型标签

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for UFOunder's contribution.)
UUFOunderCollaborators
Jul 13 Created pull request, commit 0c3ffdc6
atomgit-bot
atomgit-bot
Jul 13 Comments:

变更摘要

本次 PR 修复了 LoadData2DL12L0BCal 函数中转置加载路径(ifTranspose 为 true 时)的 Load2D 接口问题。原实现将整个转置块作为一次批量加载调用,现改为逐列循环加载,每次通过 load_cbuf_to_cb 加载单列数据,并在目标地址上进行正确的列偏移计算。

主要改动

  • 转置加载逻辑修正:在 impl/basic_api/dav_3510/kernel_operator_mm_impl.h 的 LoadData2DL12L0BCal 函数中,将 ifTranspose 分支的单次 load_cbuf_to_cb 批量调用替换为 for 循环逐列加载,每次调用以 i 作为列偏移,kStep 步长参数改为 1,确保转置场景下每列数据分别加载到正确的目标位置。
  • 目标地址偏移计算:循环体内目标地址 dst + i * VALUE_512 / sizeof(T) * dstStride 根据列索引 i 计算列间偏移,结合 VALUE_512 和 sizeof(T) 确定每列在目标缓冲区中的实际跨度。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Jul 13 Comments:

代码审查

审查总结

审查文件:impl/basic_api/dav_3510/kernel_operator_mm_impl.h(已完整审查)

发现统计:

  • P0:0
  • P1:0
  • P2:1
  • P3:0

整体风险评估:低风险。该变更将 3510 架构上 L0B 的转置搬运从单次 load_cbuf_to_cb 多行调用改为逐行循环调用,以修复硬件限制导致的 Load2d 接口问题。唯一发现的问题是循环中忽略了 kStartPosition(即 loadDataParam.startIndex),但由于 B 矩阵 L1→L0B 转置搬运的典型用法中 startIndex 始终为 0,实际触发概率很低。建议在循环中使用 kStartPosition + i 作为 K 位置参数以保证接口契约完整性。

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

💬 仅评论

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Jul 13 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Jul 13 Comments:

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, bianque (2/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

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

likedislike
CANN-robotCANN-robotCollaborators
Jul 13 Set zengjuan,zhanghao_0689,suqwe,wulinyu,kong0808,dengjing_aoe,YeZZzzz1,bluesky901,yangbinhua,zhudi22,chenyiyuan,xun_zhuge,XuebinYang,sjtulxh,bianque,houyuyang,Lycheeeee,chentianyu19,shi_nanxiang,wuyang_hw,jiangxinyu3,munanhw,ai_xin,ascendhjh,hujiawen_kaven,wangxiaozhi,DragonBornHD84,jiangtao_rts,hyolee,yukangchen,hanxiaolong,gcw_kUomxQ2l,Andy-lb as approver
CANN-robotCANN-robotCollaborators
Jul 13 Set munanhw,ai_xin,jiangtao_rts,hanxiaolong,gcw_kUomxQ2l,Andy-lb as approver
gao_dafaCollaborators
Jul 13 Comments:

UFOunder,感谢您的提交,建议在完成PR充分自验证后,再触发线上构建任务。

若您的PR已具备检视条件,可根据下表的责任田,@对应的committer进行代码检视,我们会在第一时间对您的提交进行处理。

代码责任田:

module committer
adv_api chenyiyuan, wuyang_hw
basic_api chenyiyuan, wuyang_hw
c_api pangfd, haipingmao
cmake xun_zhuge, DragonBornHD84
docs munanhw, ai_xin
examples changxianyu, bianque
simt_api wulinyu, zhanghao_0689
scripts xun_zhuge, kevin365
tools YANXI_ZHAO, XuebinYang, sjtulxh

💡 如您不确定可以@谁,可以直接@我或者ascend-c sig的maintainer,xun_zhuge和ascendhjh,我们会为您分配合适的committer进行代码检视。

再次感谢您参与CANN的社区贡献。

likedislike
UUFOunderCollaborators
Jul 13 Modify description of pull request
UFOunderCollaborators
Jul 13 Comments:

compile

likedislike
UUFOunderCollaborators
Jul 13 Pre merge succeeded (commit_id: 5c3daaa30ae59b90343f0f87c1addcddbec2f8d3)
CANN-robotCANN-robotCollaborators
Jul 13 Added label: ci-pipeline-running
CANN-robot
CANN-robotCollaborators
Jul 13 Comments:

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

任务名称状态日志下载链接
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
codecheck ✅ SUCCESS >>>>>
codecheck_Pr ✅ SUCCESS
pre_comment ✅ 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-07-13 17:06:04]    CI执行结束

likedislike
CANN-robot
CANN-robotCollaborators
Jul 13 Comments:

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

任务名称状态日志下载链接
pre_comment ✅ SUCCESS >>>>>
UT_Test_adv_test_one ✅ SUCCESS
UT_Test_adv_test_two ✅ SUCCESS
UT_Test_basic_test_two ✅ SUCCESS
UT_Test_basic_test_three ✅ SUCCESS
UT_Test_basic_test_four ✅ SUCCESS
UT_Test_basic_test_five ✅ SUCCESS
UT_Test_arm ✅ SUCCESS
UT_Test_report ✅ SUCCESS >>>>>

[2026-07-13 17:16:58]    CI执行结束

likedislike
CANN-robot
CANN-robotCollaborators
Jul 13 Comments:

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

任务名称状态日志下载链接
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
PreSmoke_A900_npupool ✅ SUCCESS >>>>>

[2026-07-13 17:06:04]    CI执行结束

likedislike
CANN-robotCANN-robotCollaborators
Jul 13 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Jul 13 Added label: ci-pipeline-passed
atomgit-bot
atomgit-botJul 13Start code review1
impl/basic_api/dav_3510/kernel_operator_mm_impl.h
@@ -102,1 +102,3 @@
102- load_cbuf_to_cb(dst, src, mStartPosition, kStartPosition, 1, kStep, srcStride, dstStride, 1);
102+ for (uint8_t i = 0; i < kStep; i++) {
103+ load_cbuf_to_cb(
104+ dst + i * VALUE_512 / sizeof(T) * dstStride, src, mStartPosition, i, 1, 1, srcStride, dstStride, 1);
atomgit-bot
atomgit-botJul 13Comments:

🟡 Medium Priority

变更前,ifTranspose 分支调用 load_cbuf_to_cb(dst, src, mStartPosition, kStartPosition, 1, kStep, srcStride, dstStride, 1),源起始 K 位置为 kStartPosition(即 loadDataParam.startIndex)。

变更后,循环 for (uint8_t i = 0; i < kStep; i++) 以 i 作为每次调用的 k 位置参数(行104),始终从 0 开始,完全忽略 kStartPosition。

对比同一文件中未修改的 LoadData2DL12L0ACal(第79-80行),其 transpose 分支仍使用 kStartPosition;非 transpose 分支(第107行)也仍使用 kStartPosition。当调用方传入非零 startIndex 时,新的 transpose 路径将从错误的源分形矩阵位置加载数据,导致 L0B 搬入内容错误。

虽然典型 B 矩阵 L1→L0B 转置搬运中 startIndex 通常为 0(所有示例和默认值均为 0),但 LoadData2DParams.startIndex 的有效范围是 [0, 65535],接口契约上允许非零值。忽略该参数构成语义正确性问题。

修复方向:将行104的 i 改为 kStartPosition + i,使循环从正确的起始 K 位置开始加载。

建议:将 load_cbuf_to_cb 调用中的第4个参数 i 改为 kStartPosition + i,使循环从正确的起始 K 位置加载。同时需评估是否还需要 srcStride 参与 k 位置计算(即 kStartPosition + i * srcStride),具体取决于 3510 硬件对单次 load_cbuf_to_cb 调用中 srcStride 的语义。

likedislike
Incorrect?
UUFOunderCollaborators
Jul 13 Resolved final issue
liulun0308Collaborators
Jul 13 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Jul 13 Added label: approved
bianqueCollaborators
Jul 13 Comments:

/lgtm

likedislike
CANN-robotCANN-robotCollaborators
Jul 13 Added label: lgtm
CANN-robotCANN-robotCollaborators
Jul 13 Merged pull request