Pull Request has been successfully merged by CANN-robot.
(Thank you for liuxiao222's contribution.)变更摘要
本 PR 为 chunk_gated_delta_rule 算子新增对 initialState 输入在 0 轴和 1 轴上非连续存储的支持。此前算子强制将 initialState 转换为连续内存布局,现在通过获取并传递实际的 stride 信息,使得 kernel 计算时能够正确处理非连续的 initial state 张量,避免不必要的内存拷贝。
主要改动
-
新增
stateStride0/stateStride1tiling 字段:在chunk_gated_delta_rule_tiling_data.h中为 tiling 数据结构添加了stateStride0和stateStride1两个int64_t字段,用于记录 initial state 在 0 轴和 1 轴上的 stride。 -
实现
GetStrides()方法:在chunk_gated_delta_rule_tiling.cpp中新增GetStrides(),优先从 context 获取STATE_INDEX输入的实际 stride;若 stride 不存在则回退计算默认值(stateStride1 = dk * dv,stateStride0 = nv * stateStride1),并在GetShapeAttrsInfo流程中调用该方法。 -
Host 侧改用
CreateView保留 stride:在aclnn_chunk_gated_delta_rule.cpp中,将initialState的处理从直接调用l0op::Contiguous改为先判断连续性;若非连续则通过CreateView保留原始 stride 信息,避免强制内存拷贝。 -
Kernel 侧适配非连续 state 索引:在
chunk_gated_delta_rule.h和chunk_gated_delta_rule_stage2.h中,将 initial state 的内存偏移计算从固定nv * dv * dk改为使用stateStride0/stateStride1,并通过useInitialState标志区分初始 state 与后续 state 的 stride 选取逻辑。


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 |
|---|---|---|
| attention | ✅ zzy__, haijie_699874 (2/2) | ✅ zzy__, haijie_699874 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
liuxiao222, thanks for your pull request. All authors of the commits have signed the CLA. 👍


描述
chunk_gated_delta_rule 算子 Ascend950 支持前两轴非连续,后两轴连续。
改动
1.aclnn层,当满足Ascend950且2,3轴连续时,用CreateView接口创建和输入initial_state同地址的view类tensor,否则转为连续tensor。可以在tiling获取到stride信息。
2.tiling层,新增tilingData获取前两轴的stride信息。
3.kernel层,当stage2阶段每个batch首次访问initial_state时,采用tilingData->stride获取偏移。
关联的Issue
#3428
测试
测试红线用例38条,STC用例31条,均通过。
测试图模式aclgraph红线用例38条,均通过。
文档更新
不涉及
类型标签