Merged
Add data structure for HPC tutorial to master #353
Add data structure for HPC tutorial to master #353
Merged
zh1125Add on Jul 17
zh1125
Jul 17

描述

关联的Issue

测试

文档更新

类型标签

其他信息

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for zh1125's contribution.)
atomgit-bot
atomgit-bot
Jul 17 Comments:

变更摘要

此 PR 向 master 分支合入 HPC(高性能计算)教程的数据结构相关内容。主要新增了一个 Jupyter Notebook 教程文件,涵盖 AscendC 静态张量矩阵乘法在并行计算场景下的应用。该变更属于文档/教程类内容,无代码逻辑修改。

主要改动

  • 新增教程 Notebook:添加 contrib/tutorials/data_structure_for_hpc/02_parallel_computing/02.02_extra_ascendc_static_tensor_matmul.ipynb,共约 1994 行,内容聚焦于 AscendC 框架下的静态张量矩阵乘法(matmul)实现与讲解
  • 补充 HPC 数据结构教程体系:在 contrib/tutorials/data_structure_for_hpc/ 目录下扩展并行计算(02_parallel_computing)章节,填补 AscendC 静态张量算子相关的教学材料
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Jul 17 Comments:

代码审查

我已经仔细审查了本次 diff 中的两个文件。以下是逐文件的分析:


文件 1: contrib/tutorials/data_structure_for_hpc/02_parallel_computing/02.02_extra_ascendc_static_tensor_matmul.ipynb

这是一个约 1994 行的 Jupyter Notebook 教程,内容涵盖 Ascend C 矩阵乘法的三类实验方案(单核静态 Tensor 基线、单核 Matmul API、多核 Matmul API)。

我逐节审查了以下关键区域:

  • Shell 命令注入(第 105 行):source 命令使用了 shlex.quote() 正确转义路径,无注入风险。
  • chmod +x(第 1844 行):仅添加执行权限,非 chmod 777,安全。
  • C++ 核函数代码(第 227-299 行、第 322-526 行):逻辑正确,边界处理合理(如 GetBlockIdx() >= tiling.usedCoreNum 的越界保护、uint64_t 防止溢出等)。
  • float 到 half 转换(第 648-707 行):使用标准 memcpy 进行类型双关,符合 C++ 规范;IEEE 754 子规范数处理和舍入逻辑正确。
  • Host 侧内存管理(第 1412-1453 行):cleanup lambda 正确处理资源释放和双重释放防护。
  • 参数校验(第 926-1010 行):充分检查了输入约束(M/N 为 16 的倍数、K 为 64 的倍数等)。
  • run.sh 脚本(第 1696-1834 行):使用 set -euo pipefail、路径存在性检查,无安全问题。
  • CMake 配置(第 1557-1676 行):默认 BUILD_ASCEND=OFF,需显式开启构建,安全。

未发现需要报告的问题。


文件 2: contrib/tutorials/data_structure_for_hpc/README.md

这是一个 38 行的课程 README 文档。我审查了以下方面:

  • 危险操作指令:无 chmod 777、禁用 TLS、暴露 0.0.0.0、明文密钥等不安全配置。
  • 依赖与供应链:未推荐安装可疑依赖或过时版本。
  • 测试/部署步骤:文档仅描述环境和验证状态,未包含跳过测试或隐藏失败的指令。
  • 在线体验链接(第 38 行):URL 中 /user/username/username 为字面占位符,可能导致链接 404,但按照审查规则,纯粹的文档链接失效不构成安全风险、生产误用、测试失败或数据破坏,不予报告。

未发现需要报告的问题。


总结

文件 审查结果
02.02_extra_ascendc_static_tensor_matmul.ipynb 无问题
README.md 无问题
  • P0: 0
  • P1: 0
  • P2: 0
  • P3: 0

总体风险判断:此变更风险低,为教学材料新增,代码质量良好,安全实践到位,无阻塞性问题。

类型 数量
🔴 阻塞 0
🟡 建议 1

💬 仅评论

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Jul 17 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Jul 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


PR Approval Progress

Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-cann/cann-learning-hub waimaidaole, fuyangchenghu (2/2) waimaidaole (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

zh1125, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
memeCollaborators
Jul 17 Comments:

/lgtm
/approve

likedislike
CANN-robotCANN-robotCollaborators
Jul 17 Added label: approved
atomgit-bot
atomgit-botJul 17Start code review1
contrib/tutorials/data_structure_for_hpc/README.md
@@ -0,0 +35,4 @@
35+ 
36+| Notebook | Link | 状态 |
37+| -- | -- | -- |
38+| 02.02 矩阵乘法分块优化实验 | [在线体验](https://ai.gitcode.com/user/username/notebookcann?repoUrl=https://gitcode.com/cann/cann-learning-hub.git&ttl=120&diskSize=40Gi&path=contrib/tutorials/data_structure_for_hpc&scanFilePath=contrib/tutorials/data_structure_for_hpc/02_parallel_computing/02.02_extra_ascendc_static_tensor_matmul.ipynb) | ✅ 已发布 |
atomgit-bot
atomgit-botJul 17Comments:

🟡 Medium Priority

README.md 第 38 行的"在线体验"链接中包含了字面量 user/username 路径段:

https://ai.gitcode.com/user/username/notebookcann?...

username 明显是一个未替换的模板占位符,而非有效的 gitcode 用户名或服务端点。用户点击该链接将无法正常访问在线 Notebook 环境,会被导向 404 页面或错误页面。

该链接是课程章节目录中唯一的可交互入口,其不可用会直接阻断用户按照文档指引进行在线实验,属于文档正确性问题。

建议:将 user/username 替换为实际的 gitcode 用户名或有效的服务端点路径。如果该链接暂时无法确定正确的线上地址,建议先移除链接或将整行标记为"待上线",避免误导用户点击一个无法访问的链接。

likedislike
Incorrect?
fuyangchenghuCollaborators
Jul 18 Comments:

/lgtm

likedislike
CANN-robotCANN-robotCollaborators
Jul 18 Added label: lgtm
CANN-robotCANN-robotCollaborators
Jul 18 Resolved final issue
CANN-robotCANN-robotCollaborators
Jul 18 Merged pull request