合并受阻
变更摘要
本 PR 在 Challenge09-MatmulAddRelu/PR_code/Student_ZZX/ 目录下新增两个文件,补全 Challenge 09 官方模板中五处 TODO,实现固定 256×256×256 的 MatmulAddRelu 融合算子及其验证脚本。算子基于 catlass.tla 构造成 cube 与 vector 两段执行流程:Cube 侧完成 GM→L1、L1→L0、四段 L0_K=64 的 tla.mmad 矩阵乘累加以及 L0C→UB 的 SPLIT_M 搬运,并借助 mutex 与 cross_flag/cross_core_wait_flag 管理缓冲访问与跨核同步;Vector 侧在 UB 上分块搬入 X 后执行 Vector Add 与 ReLU,再写回 GM 的 Y。验证脚本 test_matmul_add_relu.py 使用 torch/torch_npu 生成输入与参考结果,通过 tla.compile 与 from_dlpack 运行算子并比对容差。
主要改动
- 补全 GM→L1 与 L1→L0 搬运(TODO 1、TODO 2):在
mutex_l1、mutex_l0约束下按 A、B 顺序调用tla.copy,将gm_a/gm_b搬到 zN 布局的l1_a/l1_b,再将 K 分片l1_a_k/l1_b_k搬到l0_a(zN)与l0_b(nZ)。 - 补全四段 K 分片的矩阵乘累加(TODO 3):在
K // L0_K循环中以tla.mmad(l0_c, l0_a, l0_b, init_c=(k_tile == 0))将 FP16 输入累加为 L0C 中的 FP32 结果,仅首段初始化、后续保留累加值。 - 补全 L0C→UB 的跨核搬运与同步(TODO 4):用
tla.copy配合tla.params.CopyL0C2DstParams(l0c2ub_mode=tla.params.L0C2UBMode.SPLIT_M)将完整l0_c拆分到两侧 AIV 的 128×256 累加缓冲,并通过cross_core_set_flag/cross_core_wait_flag通知 Vector 侧。 - 补全 Vector Add + ReLU(TODO 5):在
simd模式下逐行按SIMD_LANES=64分块load累加值与X,以tla.max(tla.add(acc_value, x_value), 0.0)计算并store回ub_acc_chunk,随后由tla.copy写回 GM。 - 新增实机验证脚本:
test_matmul_add_relu.py定义--device参数(禁止负数),用torch.manual_seed(2026)生成输入并计算torch.relu(a @ b + x)参考值,经tla.compile(..., options="--npu-arch 3510")与block_num=1执行后按相对容差判定PASS/FAIL。


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
⚠️ This PR does not yet meet the following requirements:lgtm (requires ≥ 2 person(s) per module)、approve (requires ≥ 1 person(s) per module)
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/cann-outreach | ❌ (0/2)(You can also ask: shaoyf, 傅涛, yanhf, Carolina_yuan, luzx66) | ❌ (0/1)(You can also ask: 王艳秋, jxlang, yanhf, gcw_tgPdOLZT, luzx66) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
Student_ZZX, thanks for your pull request. All authors of the commits have signed the CLA. 👍


已完成提交整理:分支已同步最新 master 并压为单一提交 46800cff;commit 已补充 Assisted-by: Codex:GPT-6,PR 描述已补齐 AI 参与声明。HiDevLab 实机验证通过,Catlass 与 PyTorch 结果一致,输出包含 tensor、M/N/K 与 blocks 信息。


当前 PR 是否有 AI 参与
功能描述
在
2026/CANN-Code-Detective/Challenge09-MatmulAddRelu/PR_code/Student_ZZX/提交个人实现与原版验证脚本。完成 GM→L1、L1→L0、四段 K=64 的 Cube MMAD、L0C→双 AIV 的 SPLIT_M 搬运,以及 Vector Add→ReLU。活动 Issue:https://gitcode.com/cann/cann-learning-hub/issues/777
测试信息
检查清单