Merged
fix(scatter_nd_update): 修复非连续回退路径的原始视图回写 #12073
陈展熹Add on Oct 16
fix(scatter_nd_update): 修复非连续回退路径的原始视图回写 #12073
Merged
Pull Request has been successfully merged by CANN-robot.
(Thank you for 陈展熹's contribution.)Oct 16 Associated issue: [Bug-Report|缺陷反馈]: aclnnScatterNdUpdate 非连续回退路径丢失原始 varRef 回写目标
atomgit-bot
Oct 16 Comments:
Oct 16 Comments:
变更摘要
本次变更修复 aclnnScatterNdUpdate 在非连续 varRef 回退路径下的写回目标错误:当 varRef 非连续且未命中按 stride 直接更新的条件时,原实现只把连续副本传入公共执行函数,使末尾 ViewCopy 的写回目标变成 workspace 中的连续副本而非调用方原始 varRef。修复通过在 ExecuteScatterNdUpdate 中分别传递连续计算副本与原 varRef,用副本执行更新、再按原始视图 layout 写回,并新增直接调用 ACLNN 两阶段接口的回归脚本核对完整 backing storage。
主要改动
ExecuteScatterNdUpdate参数拆分: 函数签名新增varRefContiguous与varRef两个参数,区分连续计算副本与原始视图,使计算与写回目标得以分离。- L0 算子改用连续副本计算:
l0op::ScatterNdUpdate的输入由varRef改为varRefContiguous,更新在连续副本上完成。 ViewCopy按原始视图写回:needViewCopy分支注释与语义调整为按原始varRef的 stride 和 offset 写回连续副本的更新结果,修正了此前回写目标为 workspace 副本的问题。ProcessContiguousCase同步传入两个张量: 调用处改为传入varRefContiguous与varRef,将修复贯通到连续/回退处理路径。- 新增非连续回写回归脚本: 新增
index/scatter_nd_update/tests/st/aclnnScatterNdUpdate/test_noncontiguous_writeback.py,通过 ctypes 直接调用aclnnScatterNdUpdateGetWorkspaceSize/aclnnScatterNdUpdate两阶段接口,覆盖连续、直接 stride、转连续回退、转置回退等布局,并核对更新值、未更新行、间隙与视图边界及原始 layout 是否保持。
🧩 本次 Review 已使用自定义 Skill:


Incorrect?
atomgit-bot
Oct 16 Comments:
Oct 16 Comments:


Incorrect?
Oct 16 Added label: cann-cla/yes
107 messages are collapsed here。 See more
TangPC
16 days ago Comments:
16 days ago Comments:
/lgtm
/approve


16 days ago Added label: lgtm
16 days ago Closed associated issue
16 days ago Merged pull request
CANN-robot
16 days ago Comments:
16 days ago Comments:
Pull Request 已合并或已关闭。
If you want to solve this problem, you can click here to do it in the FAQs.


描述
当
varRef非连续且未命中直接按 stride 更新的条件时,aclnnScatterNdUpdate会先创建连续副本。原实现只把该副本传给公共执行函数,导致末尾ViewCopy的目标也成为 workspace 中的连续副本,而非调用方原始varRef;切片布局stride=[6,2]和转置布局stride=[1,2]均可在第一阶段复现561103 / ACLNN_ERR_INNER_NULLPTR。修复分别传递连续计算副本与原始
varRef,使用副本执行更新,再按原始视图的 stride 和 offset 写回。生产修复位于index/scatter_nd_update/op_api/aclnn_scatter_nd_update.cpp,并补充现有 CI 自动收集的 L2 UT。关联的Issue
Fixes #6747
https://gitcode.com/cann/ops-nn/issues/6747
测试
950 验证
以下为此前已完成的手工定向验证。环境:Ascend950PR_9579,CANN 9.2.0。
分别从修复前后源码编译 L2/L0 接口共享库,配合已安装算子包执行相同的 60 组回归:
stride=[3,1]stride=[6,1]stride=[6,2]stride=[1,2]2aa36b678ed6b1857eaadb4391240839ad916274c67fbdadecf570f3383bfb1e。git diff --check通过。文档更新
无接口文档变更,验证范围及结果见上文。
类型标签
AI/Agent生成声明