Pull Request已成功合入, 合并人@CANN-robot
(感谢 Crrryyyy 的贡献)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 |
|---|---|---|
| repo-cann/cann-samples | ✅ 杨阳, 王林木 (2/2) | ✅ 王林木, 杨阳 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
Crrryyyy, thanks for your pull request. All authors of the commits have signed the CLA. 👍


变更摘要
此 PR 主要完成三项工作:将 AscendC Tensor API 的 Mmad 和 Copy 调用方式从"参数尾随"改为通过 .with() 链式传递参数的新 API 风格;全局将 GetTaskRation 重命名为 GetTaskRatio;将第三方依赖子模块从 third_party/tensor_api 迁移到 third_party/ops-tensor。此外,为 CopyL12L0MxScaleA3510 / CopyL12L0MxScaleB3510 这类 scale copy 原子添加了支持运行时坐标参数的 Copy 重载。
主要改动
-
Mmad / Copy API 调用风格变更:所有示例和 recipe 中的
AscendC::Te::Mmad(MadOp, dst, srcA, srcB, para)改为AscendC::Te::Mmad(MadOp.with(para), dst, srcA, srcB);AscendC::Te::Copy(copyOp, dst, src, fixpipeParams)改为AscendC::Te::Copy(copyOp.with(fixpipeParams), dst, src),参数通过.with()绑定到操作对象上。 -
GetTaskRation→GetTaskRatio全局重命名:在调度器、epilogue、kernel 和 streamk 相关文件中,AscendC::GetTaskRation()统一更名为AscendC::GetTaskRatio(),涉及 block scheduler、epilogue、kernel 入口等多处调用。 -
third_party/tensor_api→third_party/ops-tensor子模块迁移:CMake 配置tensor_api.cmake中所有路径和 submodule 初始化命令从third_party/tensor_api更新为third_party/ops-tensor,子模块 commit 也相应切换。 -
新增 scale copy 原子的
Copy重载:在多个copy_scale_l1_to_l0a.h/copy_scale_l1_to_l0b.h中,于namespace AscendC::Te内为CopyL12L0MxScaleA3510和CopyL12L0MxScaleB3510添加接受Coord参数的三参数Copy模板重载,使调用处可直接传入AscendC::Te::MakeCoord(...)而无需旧式包装。 -
MmadParams命名空间修正与 include 路径调整:部分文件将AscendC::MmadParams修正为AscendC::Te::MmadParams;kernel_universal.h中"blaze/utils/common_utils.h"改为"blaze/gemm/utils/common_utils.h";copy_scale_l1_to_l0b.h(grouped_matmul_recipes)移除了不再使用的LoadDataTrait/LoadData2BTrait定义。


代码审查
审查总结
共审查 67 个变更文件,发现 3 个问题:
| 优先级 | 数量 | 说明 |
|---|---|---|
| P2 | 1 | kernel_universal.h 中 include 路径从 blaze/utils/ 改为 blaze/gemm/utils/,无法确认新路径是否存在 |
| P3 | 2 | README 文档仍引用旧 API 名 GetTaskRation();simd_vf_story 被注释掉 |
| P0–P1 | 0 | 未发现高危问题 |
整体风险评估:低-中等。此 PR 主要完成三项工作:
- 子模块重命名:
third_party/tensor_api→third_party/ops-tensor(.gitmodules、README.md、cmake/tensor_api.cmake均已同步更新,CMake target 名cann_samples::tensor_api保持不变,正确) - API 迁移:Mmad/Copy 调用从旧式
Op(dst, src, params)迁移为新式Op.with(params)(dst, src),涉及约 50 个文件,迁移模式一致、参数顺序保留正确 - 拼写修正:
GetTaskRation()→GetTaskRatio()(约 15 处,均正确)
唯一需要关注的是 kernel_universal.h 中的 include 路径变更,建议在合并前验证新路径在更新后的依赖中存在。
各文件审查结果(均逐一审查):
.gitmodules— no issuesREADME.md— no issuesSamples/0_Introduction/matmul/main.asc— no issuesSamples/1_Features/instruction_optimization/mte2_preload/main.asc— no issuesSamples/1_Features/instruction_optimization/n_buffer/main.asc— no issuesSamples/1_Features/instruction_optimization/unit_flag/main.asc— no issuesSamples/1_Features/instruction_optimization/weightnz/main.asc— no issuesSamples/1_Features/memory_optimization/full_load/main.asc— no issuesSamples/1_Features/memory_optimization/l1_bank_conflict/main.asc— no issuesSamples/1_Features/memory_optimization/scale_cache/main.asc— no issuesSamples/1_Features/memory_optimization/slide_window_adaptive_template/main.asc— no issuesSamples/1_Features/system_optimization/streamk/main.asc— no issuesSamples/1_Features/system_optimization/streamk/README.md— P3: 残留GetTaskRation()引用Samples/1_Features/system_optimization/tail_rebalance/main.asc— no issuesSamples/2_Performance/CMakeLists.txt— P3:simd_vf_story被注释Samples/2_Performance/full_quant_fused_infer_attention_score_story/include/block/flash_attention_score_block_vec_infer.h— no issuesSamples/2_Performance/grouped_matmul_story/.../quant_grouped_matmul_hif8_block_mmad.h— no issuesSamples/2_Performance/grouped_matmul_story/.../quant_grouped_matmul_mx_block_mmad.h— no issuesSamples/2_Performance/grouped_matmul_story/.../quant_grouped_matmul_mx_block_scheduler_split_m.h— no issuesSamples/2_Performance/grouped_matmul_story/.../weight_quant_grouped_matmul_mxfp8fp4_block_mmad_split_m.h— no issuesSamples/2_Performance/grouped_matmul_story/.../quant_grouped_matmul_mx_kernel.h— no issuesSamples/2_Performance/grouped_matmul_story/.../copy_scale_l1_to_l0a.h— no issuesSamples/2_Performance/grouped_matmul_story/.../copy_scale_l1_to_l0b.h— no issuesSamples/2_Performance/matmul_story/matmul_recipes/include/block/matmul_block_mmad_streamk.h— no issuesSamples/2_Performance/matmul_story/matmul_recipes/include/block/matmul_block_mmad_swat.h— no issuesSamples/2_Performance/matmul_story/matmul_recipes/include/block/quant_matmul_hifp8_block_mmad_swat.h— no issuesSamples/2_Performance/matmul_story/matmul_recipes/include/block/quant_matmul_hifp8_block_scheduler_swat.h— no issuesSamples/2_Performance/matmul_story/matmul_recipes/include/block/quant_matmul_mx_block_mmad_a_full_load.h— no issuesSamples/2_Performance/matmul_story/matmul_recipes/include/block/quant_matmul_mx_block_mmad_swat.h— no issuesSamples/2_Performance/matmul_story/matmul_recipes/include/block/quant_matmul_mx_block_mmad_swat_4_buffer.h— no issuesSamples/2_Performance/matmul_story/matmul_recipes/include/block/quant_matmul_mx_block_scheduler_a_full_load.h— no issuesSamples/2_Performance/matmul_story/matmul_recipes/include/block/quant_matmul_mx_block_scheduler_swat.h— no issuesSamples/2_Performance/matmul_story/matmul_recipes/include/block/quant_matmul_mx_block_scheduler_swat_4_buffer.h— no issuesSamples/2_Performance/matmul_story/matmul_recipes/include/block/weight_quant_matmul_mxfp8fp4_block_mmad_swat.h— no issuesSamples/2_Performance/matmul_story/matmul_recipes/include/epilogue/matmul_block_epilogue_streamk.h— no issuesSamples/2_Performance/matmul_story/matmul_recipes/include/kernel/kernel_universal.h— P2: include 路径变更Samples/2_Performance/matmul_story/matmul_recipes/include/kernel/matmul_kernel_streamk.h— no issuesSamples/2_Performance/matmul_story/matmul_recipes/include/kernel/weight_quant_matmul_mxfp8fp4_kernel_swat.h— no issuesSamples/2_Performance/matmul_story/matmul_recipes/include/tile/copy_scale_l1_to_l0a.h— no issuesSamples/2_Performance/matmul_story/matmul_recipes/include/tile/copy_scale_l1_to_l0b.h— no issuesSamples/2_Performance/matmul_story/matmul_tutorials/0_naive/...(3 files) — no issuesSamples/2_Performance/matmul_story/matmul_tutorials/1_pingpong/...(3 files) — no issuesSamples/2_Performance/matmul_story/matmul_tutorials/2_block_swat/...(3 files) — no issuesSamples/2_Performance/matmul_story/matmul_tutorials/3_last_round_tile_balance/...(3 files) — no issuesSamples/2_Performance/matmul_story/matmul_tutorials/4_unit_flag/...(3 files) — no issuesSamples/2_Performance/matmul_story/matmul_tutorials/5_halfl1_ping_halfl1_pong/...(3 files) — no issuesSamples/2_Performance/matmul_story/matmul_tutorials/6_scale_memory_access_coalescing/...(3 files) — no issuesSamples/2_Performance/matmul_story/matmul_tutorials/7_fullload/...(3 files) — no issuescmake/tensor_api.cmake— no issuesthird_party/ops-tensor— no issues (submodule add)third_party/tensor_api— no issues (submodule delete)
⚠️ 已识别出整体风险,但无法提取行内评论,请参考整体评估。


描述
third_party/tensor_api子模块路径调整为third_party/ops-tensor,使third_party下目录结构与 ops-tensor 项目名称保持一致。.gitmodules、README 以及样例/CMake 中对旧tensor_api路径的引用。关联的Issue
https://gitcode.com/cann/cann-samples/issues/199
测试
cmake --build build --parallel编译无误,执行涉及修改目录下的用例无误
文档更新
README.md中第三方依赖目录相关说明。类型标签