

Pull Request已成功合入, 合并人@CANN-robot
(感谢 qq_51867290 的贡献)变更摘要
本次变更为 Samples/0_Introduction/vector_add 示例增加 msprof 性能分析工具的输入输出元信息上报能力。原始示例中 msprof 虽可采集 kernel 执行耗时等性能数据,但 op_summary 中 shape、dtype、format 字段均显示为 N/A。通过引入 aclprofTensor / aclprofTensorInfo 元信息结构,并在 add_kernel 调用前后使用 aclprofRangePushEx / aclprofRangePop 包裹,将向量输入 A、B 和输出 C 的元信息上报至 profiling 系统,使性能分析报告能够展示完整的算子张量信息。
主要改动
- 新增头文件引入:在
main.asc中新增#include "acl/acl_prof.h",引入 profiling 相关接口声明。 - 定义 profiling 元信息结构体:通过
#ifndef ACL_PROF_TENSOR_INFO_DEFINED条件编译块定义了aclprofTensor、aclprofTensorInfo和aclprofEventAttributes三个结构体,用于承载算子的 shape、dtype、format 等元信息。 - 新增
MakeVectorTensor辅助函数:封装aclprofTensor的构造逻辑,统一将向量张量设为ACL_FORMAT_ND格式和ACL_FLOAT数据类型,并填充numElements作为 shape 维度。 - 在 kernel 调用前后插入 profiling 标记:在
run_vector_add中构造三个张量的元信息数组(输入 A/B type=0,输出 C type=1),初始化aclprofTensorInfo和aclprofEventAttributes,在add_kernel执行前调用aclprofRangePushEx、执行后调用aclprofRangePop,完成算子输入输出元信息上报。 - CMakeLists.txt 链接 msprofiler 库:构建配置中新增对
msprofiler的链接依赖,确保 profiling 接口可正常解析。


代码审查
审查总结
本次审查覆盖了 2 个变更文件:
- Samples/0_Introduction/vector_add/CMakeLists.txt — 已审查,发现 1 个 P3 问题(宏内联展开与项目模式不一致)
- Samples/0_Introduction/vector_add/main.asc — 已审查,发现 4 个 P3 问题
按优先级统计:
| 优先级 | 数量 |
|---|---|
| P0 | 0 |
| P1 | 0 |
| P2 | 0 |
| P3 | 5 |
整体风险判定:低。 变更范围可控,核心计算逻辑未修改,profiling 元信息上报为纯增量功能(不影响原有计算正确性)。PR 作者已在 Ascend 950 环境完成编译与运行验证,profiling 输出符合预期。5 个 P3 发现均为代码质量 / 可维护性 / 前向兼容性方面的改进建议,不构成当前功能缺陷。
⚠️ 已识别出整体风险,但无法提取行内评论,请参考整体评估。


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


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.

