Merged
add tensor api examples #6163
li-yuanjie-daAdd on Sep 17
add tensor api examples #6163
Merged
Merged fromli-yuanjie-da/asc-devkit_1masterintocann/asc-devkitmaster
Pull Request has been successfully merged by CANN-robot.
(Thank you for li-yuanjie-da's contribution.)Sep 17 Created pull request, commit 36c1e5fa
atomgit-bot
Sep 17 Comments:
Sep 17 Comments:
变更摘要
本 PR 为 SIMD C++ 示例集新增 Tensor API 的使用样例,目录位于 examples/01_simd_cpp_api/07_tensor_api/matmul_split_k/。样例以 Split-K 方式实现 half 输入的矩阵乘:将 K 维切分为 SPLIT_K 份,由多个 Cube 核各自计算一个 K 切片并通过原子累加写入同一输出矩阵。配套提供了数据读写工具、输入/金标准数据生成脚本以及结果校验脚本,形成从造数、执行到验证的完整示例闭环。
主要改动
- 新增 Split-K 矩阵乘 Kernel:
matmul_split_k.asc中定义matmul_split_k_kernel,通过block_idx确定 K 切片偏移,使用make_tensor、make_frame_layout、slice构建 GM/L1/L0 各级张量视图。 - 引入 Tensor API 的拷贝与矩阵乘接口: 样例使用
make_copy搭配copy_gm_to_l1、copy_l1_to_l0a、copy_l1_to_l0b、copy_l0c_to_gm完成数据搬运,并用make_mmad与mmad_params完成 L0 上的矩阵乘计算。 - 新增原子累加输出流程: 通过
asc_set_atomic_add_float()与asc_disable_dma_atomic()实现多核向同一gmC的累加写入,主机侧在启动前用aclrtMemset将输出清零。 - 新增数据读写工具:
data_utils.h提供ReadFile/WriteFile,对输入文件的存在性、是否为普通文件及大小进行校验,并在失败时输出错误信息。 - 新增造数与校验脚本:
scripts/gen_data.py以固定随机种子生成输入与golden.bin,scripts/verify_result.py按相对/绝对容差比较输出与金标准并报告最大绝对误差或首个不匹配位置。


Incorrect?
atomgit-bot
Sep 17 Comments:
Sep 17 Comments:
Sep 17 Added label: cann-cla/yes
CANN-robot
Sep 17 Comments:
Sep 17 Comments:
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 |
|---|---|---|
| examples | ✅ 诸葛洵, hyolee (2/2) | ✅ 诸葛洵 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
li-yuanjie-da, thanks for your pull request. All authors of the commits have signed the CLA. 👍


206 messages are collapsed here。 See more
Sep 24 Added label: ci-pipeline-passed
hyolee
Sep 24 Comments:
Sep 24 Comments:
/lgtm


zhugexun_sjtu
Sep 24 Comments:
Sep 24 Comments:
/lgtm
/approve


Sep 24 Added label: lgtmapproved
Sep 24 Merged pull request
描述
新增tensor api样例
关联的Issue
测试
文档更新
类型标签