Pull Request已成功合入, 合并人@CANN-robot
(感谢 悠悠的云朵 的贡献)变更摘要
本 PR 新增 Challenge09-MatmulAddRelu 练习题,面向 CATLASS DSL,提供固定 256×256×256 的融合算子 MatmulAddRelu(即 A @ B + X 后取 ReLU)的核函数模板与验证脚本。模板 matmul_add_relu.py 给出了基于 tla 的 Cube/Vector 双流水骨架、多级存储分配与同步 flag 链路,并在关键位置留出五处 TODO 供学员补全;test_matmul_add_relu.py 提供在 Ascend 设备上编译执行并做容差校验的测试入口。按 PR 描述,还保留了 PR_code/ 目录供提交答案并附带环境准备与提交说明。
主要改动
- 核函数模板与固定尺寸常量: 新增
matmul_add_relu_kernel,定义M = N = K = 256、L0_K = 64、AIV_M、X_CHUNK_M、SIMD_LANES等常量,约定该题固定为 256 规模的矩阵乘加 ReLU 融合。 - 多级存储分配与 flag 同步链路: 通过
tla.allocate分配 L1、L0A、L0B、L0C 及 UB(ub_acc_ptr、ub_x_ptr),并用tla.flag/tla.cross_flag(如l1_ready、l0_ready、mmad_done、fix_done、x_ready、y_ready等)组织 MTE1/MTE2/MTE3、Cube、Vector 之间的异步读写顺序。 - 五处待补全 TODO: 模板在
GM→L1搬运、L1→L0搬运、tla.mmad矩阵乘累加(含init_c分片累加)、L0C→UB搬运(CopyL0C2DstParams的l0c2ub_mode = SPLIT_M)以及 Vector 的tla.add+tla.max加 ReLU 处各留一个TODO供学员实现。 - 验证脚本: 新增
test_matmul_add_relu.py,提供--device参数校验,使用torch/torch_npu构造随机输入与参考结果,经from_dlpack包装后调用tla.compile(--npu-arch 3510)编译并执行,最后按容差比较并输出PASS/FAIL。


Hi @weixin_42818618, welcome to submitting your first PR to cann-outreach!
PR Merge Steps
1. CLA Signing
If the current PR label includes cann-cla/yes, it means you have signed the CLA and can proceed to the next step. If the label includes cann-cla/no, please sign the CLA first. If you have any questions, please refer to the FAQ.
2. CI Check
Please comment /compile to trigger the CI pipeline check. If the CI run is successful, the PR will be tagged with ci-pipeline-passed and you can proceed to the next step. If the CI run fails, the PR will be tagged with ci-pipeline-failed, please check the CI logs to fix the issues in the PR. If you have any questions, please refer to the FAQ.
3. Code Review
After CI passes, please refer to the PR Approval Progress and proactively @ the committers in the table to review the code. After approval, committers will comment /lgtm and /approve. Once the lgtm and approved labels are successfully added, the PR will be merged automatically.


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


The following labels are not ready.
lgtm: Please wait for committers to review the code.
approved: Please wait for committers to review the code.


The MR can not be merged, because of CodeReview discussion not resolved
If you want to solve this problem, you can click here to do it in the FAQs.


当前PR是否有AI参与:
[x] 否
[ ] 是
__1. AI Agent 平台:
__2. AI 模型:
__3. Prompt上下文 :
PR功能描述 / 为什么需要这个合入**:
新增固定 256×256×256 的 MatmulAddRelu 题目,提供包含五处待补全代码的核函数模板、验证脚本,以及环境准备和提交说明。保留 PR_code/ 目录供学员提交答案。
该PR关联的issue
(格式为fixes #<issue号>, 或者resolves #<issue号>): fixes #
希望检视人员了解:
改动类型 / Change Type
测试信息 / Testing
检查清单 / Checklist