合并受阻
变更摘要
本 PR 为 Challenge09-MatmulAddRelu(CATLASS DSL)提交个人答案,新增 matmul_add_relu.py 与 test_matmul_add_relu.py 两个文件,仅存在于 PR_code/JeffDing/ 个人目录下,补全模板中五处 TODO,实现固定 M=N=K=256 的 A @ B + X 后接 ReLU 的融合算子。实现按 Cube 与 Vector 两个核分工:Cube 侧完成 A/B 的 GM→L1→L0A/L0B 搬运、按 K=64 分片用 tla.mmad 累加到 L0C,再经 L0C→UB 将结果拆给两个 AIV;Vector 侧在 UB 中逐分片执行 Add→ReLU 并写回 Y。测试脚本在 Ascend 950 上通过 tla.compile 编译执行并与 PyTorch 参考结果比对。
主要改动
- 补全 GM→L1 的 A/B 搬运:用
tla.copy将行优先 FP16 的gm_a/gm_b搬入L1中zN布局的l1_a/l1_b,并以mutex_l1的 lock/unlock 约束MTE2的搬运顺序。 - 补全 L1→L0A/L0B 的分片搬运:在
k_tile循环内用tla.tile_view切出 K=64 分片,按 A、B 顺序将l1_a_k/l1_b_k分别搬入L0A(zN)与L0B(nZ),由mutex_l1/mutex_l0保证 Cube 读取前完成搬运。 - 补全矩阵乘累加:以
init_c = k_tile == 0控制tla.mmad,首次覆盖写入L0C、后续累加,将 K=256 的四个分片累加成 256×256 FP32 的l0_c,期间不提前启用 ReLU。 - 补全 L0C→UB 拆分搬运:调用
tla.copy并传入CopyL0C2DstParams(l0c2ub_mode=L0C2UBMode.SPLIT_M),使两个 AIV 各接收 128×256 的累加结果,并用cross_core_set_flag(fix_done)/cross_core_wait_flag做跨核同步。 - 补全 Vector Add+ReLU 与写回:在每个 AIV 的
simd函数内按行/列载入 FP32 向量,先后执行tla.add与tla.max(..., 0.0)并原位写回acc_reg,最后用tla.copy将处理结果写回Y;新增的test_matmul_add_relu.py负责构造输入、调用tla.compile/artifact并比对结果输出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, yanyawen, jxlang, luzx66) | ❌ (0/1)(You can also ask: yanhf, shaoyf, 田晓亮, jxlang, Carolina_yuan) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
JeffDing, thanks for your pull request. All authors of the commits have signed the CLA. 👍


/compile


当前PR是否有AI参与:
[x] 否
[ ] 是
__1. AI Agent 平台:
__2. AI 模型:
__3. Prompt上下文 :
PR功能描述 / 为什么需要这个合入**:
提交 Challenge09-MatmulAddRelu(CATLASS DSL)的个人答案。补全
PR_code/JeffDing/matmul_add_relu.py中五处 TODO:tla.copy将 GM 中行优先 FP16 的 A/B 搬入 L1 中 zN 布局的缓冲区;tla.mmad,首次init_c=True覆盖写入 L0C,后三次累加,最终在 L0C 得到 256×256 FP32 结果;CopyL0C2DstParams(l0c2ub_mode=L0C2UBMode.SPLIT_M)将 L0C 分给两个 AIV,各处理 128 行;tla.add加 X,再tla.max与 0.0 取最大),最后写回 GM 的 Y。该PR关联的issue
fixes #
希望检视人员了解:
PR_code/JeffDing/个人目录下的matmul_add_relu.py与test_matmul_add_relu.py,未改动题目Template/、PR_code/README.md及他人目录;tla.mutexlock/unlock 框架,未修改同步结构与提交框架;ReLU 严格在加 X 之后执行;python PR_code/JeffDing/test_matmul_add_relu.py --device 0,输出PASS: M=N=K=256, blocks=1。改动类型 / Change Type
测试信息 / Testing
检查清单 / Checklist