Pull Request has been successfully merged by CANN-robot.
(Thank you for gaoxingwang's contribution.)变更摘要
本 PR 将 #6028 同步到 9.2.0 发布分支,修复 ScatterUpdate 的原地语义与槽位符号保留问题:此前 ScatterUpdate 返回新张量而 dst 保持不变,且当 src 槽位(无名的 inplace-view SSA)接管 dst 注册时会在 codegen 中丢失 dst 的 ARG 符号。核心改动包括:将 ScatterUpdate 的 dst 参数改为可变引用并在调用后把结果写回 dst;新增 TensorSlotManager::UpdateInputSlot 并按索引更新输入槽位;在 RootFunctionBuilder::InitDynFunc 参数声明阶段即通过 MarkInput 登记输入名,并在 DyndevFunctionAttribute 中新增 startArgsInputSlotTensorList 持有共享所有权,确保槽位张量在 SetSameSlot 迁移后仍存活;同时在 _patch_methods 中注册 pypto.scatter_update 使原地槽位跟踪覆盖该算子。
主要改动
-
ScatterUpdate改为原地更新dst:ScatterUpdate的dst参数由const Tensor&改为可变引用Tensor&(涉及tilefwk_op.h、scatter_update.cpp及 Python 绑定operation.cpp),并在底层算子调用后执行dst = result;将结果赋回dst,使调用侧张量反映更新结果。 -
新增
UpdateInputSlot槽位管理接口: 在TensorSlotManager中新增UpdateInputSlot方法(tensor_slot.h声明、tensor_slot.cpp实现),按索引更新inputSlotList中的槽位并同步维护inputSlotDict;RootFunctionBuilder::BuildDynSlotScope中原先的MarkInput调用改为UpdateInputSlot(idx, *tensor),并相应按索引回填startArgsInputTensorList与startArgsInputSlotTensorList。 -
参数声明阶段登记输入以保留 ARG 符号:
RootFunctionBuilder::InitDynFunc遍历irFunc->params_时即调用slotManager->MarkInput(*tensor)登记输入,并在DyndevFunctionAttribute中新增startArgsInputSlotTensorList(std::vector<std::shared_ptr<Tensor>>),在SetSameSlot迁移槽位前持有共享所有权,使inputNameList保留原始 ARG 符号。 -
注册
pypto.scatter_update到_patch_methods: 在python/pypto/pil/ops.py的_patch_methods列表中加入(pypto, "scatter_update", 0),使原地槽位跟踪覆盖该算子。 -
更新原地写后读依赖的测试用例:
test_scatter_update_keeps_write_after_read_dependency.pypto中INDEX_OUTCAST的结果 SSA 由无名的%$1@5变为保留目标符号的%target_0@5,且return语句相应返回%target_0@5,验证dst槽位符号得以保留。


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.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| framework/include/tilefwk | ✅ tsungl4, 尹杰 (2/2) | ✅ tsungl4 (1/1) |
| framework/src/interface/function | ✅ tsungl4, 尹杰 (2/2) | ✅ tsungl4 (1/1) |
| framework/src/interface/operation | ✅ tsungl4, 尹杰 (2/2) | ✅ tsungl4 (1/1) |
| framework/src/interface/tensor | ✅ tsungl4, 尹杰 (2/2) | ✅ tsungl4 (1/1) |
| python/pypto/pil | ✅ tsungl4, 尹杰 (2/2) | ✅ tsungl4 (1/1) |
| python/src/bindings/operation.cpp | ✅ tsungl4, 尹杰 (2/2) | ✅ tsungl4 (1/1) |
| repo-cann/pypto | ✅ tsungl4, 尹杰 (2/2) | ✅ tsungl4 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
gaoxingwang, thanks for your pull request. All authors of the commits have signed the CLA. 👍


/compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


/lgtm


/approve


fix(operator): Make ScatterUpdate update dst inplace and preserve slot symbol
Sync of #6028 (merged to master) to release branch 9.2.0.
ScatterUpdate returned a new tensor while leaving dst unchanged, which
broke inplace semantics and lost dst ARG symbol in codegen when the
src slot (nameless inplace-view SSA) took over dst registration.
Changes:
Related Issues: #3260