Pull Request已成功合入, 合并人@CANN-robot
(感谢 yangzeheng 的贡献)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 |
|---|---|---|
| examples | ✅ wang-minbo, 刘丹 (2/2) | ✅ wang-minbo, 刘丹 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)


变更摘要
此 PR 主要针对 profiling(性能剖析)相关接口进行适配性修改。核心改动集中在共享头文件 mc2_profiling.h 中,对 profiling 宏定义和辅助函数进行了较大幅度的精简和重构(净减少约 28 行);同时在三个算子实现文件中进行了少量配套调整,以匹配更新后的 profiling 接口。
主要改动
mc2_profiling.h重构:对该 profiling 公共头文件进行了大幅精简(+4 -32),调整了INPUT、OUTPUT、INIT_ACL_PROF_TENSOR_INFO等 ACL profiling 宏的定义,以及GetFormat、ConvertType等辅助函数,以适配 profiling 接口的最新规范- IncreFlashAttention 算子 profiling 适配:
npu_fused_infer_attention_score.cpp中微调了 profiling 相关的调用代码(+2 -2),确保与更新后的mc2_profiling.h宏保持一致 - MoE Distribute Combine V2 算子 profiling 适配:
moe_distribute_combine_v2_torch.cpp中同步调整了aclprofTensorInfo/aclprofEventAttributes的使用方式(+1 -1) - MoE Distribute Dispatch V2 算子 profiling 适配:
moe_distribute_dispatch_v2_torch.cpp中进行了相同的 profiling 调用适配(+1 -1)


代码审查
审查总结
逐文件审查结果
| 文件 | 审查结论 |
|---|---|
examples/fast_kernel_launch_example/csrc/common/inc/kernel/mc2_profiling.h |
发现 1 个 P2 问题(struct 关键字不一致),1 个 P3 预存问题(C99 compound literal) |
examples/fast_kernel_launch_example/csrc/incre_flash_attention/ascend910_93/npu_fused_infer_attention_score.cpp |
无新增问题(仅类型重命名 aclProfTensorInfo → aclprofTensorInfo,aclProfTensor → aclprofTensor) |
examples/fast_kernel_launch_example/csrc/moe_distribute_combine_v2/ascend910_93/moe_distribute_combine_v2_torch.cpp |
无新增问题(仅类型重命名 aclProfTensorInfo → aclprofTensorInfo) |
examples/fast_kernel_launch_example/csrc/moe_distribute_dispatch_v2/ascend910_93/moe_distribute_dispatch_v2_torch.cpp |
无新增问题(仅类型重命名 aclProfTensorInfo → aclprofTensorInfo) |
问题统计
- P0: 0
- P1: 0
- P2: 1(
struct关键字不一致,可能导致编译失败) - P3: 1(C99 compound literal 预存问题,非本次引入)
整体风险评估
低风险。本次变更的核心目的是适配 profiling SDK 的类型命名变更,将本地自定义的 aclProfTensor/aclProfTensorInfo/aclprofEventAttributes 结构体定义移除,统一使用 SDK 提供的 aclprofTensor/aclprofTensorInfo/aclprofEventAttributes。三个 .cpp 文件的改动均为纯类型重命名,不涉及逻辑变更。
唯一的实际风险点在 mc2_profiling.h 第 102 行:INIT_ACL_PROF_TENSOR_INFO 宏中使用了 struct aclprofTensor(带 struct 关键字),而其他所有位置均直接使用 aclprofTensor(不带 struct)。若 SDK 将此类型定义为匿名 struct 的 typedef,将导致编译失败。建议移除多余的 struct 关键字以与代码库其余部分保持一致并消除该风险。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 0 |
| 🟡 建议 | 2 |
💬 仅评论


🔵 Low Priority
在 mc2_profiling.h 中,INPUT 宏(第 65 行)和 OUTPUT 宏(第 82 行)使用 compound literal 语法 aclprofTensor { ... }。此语法是 C99 的 compound literal 特性,在 C++ 中并非标准语法,仅在 GCC/Clang 中作为 GNU 扩展支持。
由于该头文件被 .cpp 文件包含(如 npu_fused_infer_attention_score.cpp、moe_distribute_combine_v2_torch.cpp、moe_distribute_dispatch_v2_torch.cpp),如果使用不同的编译器或禁用 GNU 扩展的编译选项,将导致编译失败。
注:此问题在本次 diff 前已存在(旧代码同样使用 aclProfTensor { ... } compound literal),本次 diff 未改变该语法模式,仅重命名了类型名。
建议:这是一个 C/C++ 兼容性问题但不是本次 diff 引入的。如果需要在纯 C++ 环境下编译,可以考虑:将 compound literal 替换为临时变量的显式构造,或为每个 tensor 定义一个具名初始化函数/宏。不过鉴于这是一个预存问题且项目已依赖 GNU 扩展,可在后续统一处理。


🟡 Medium Priority
在 mc2_profiling.h 第 102 行,INIT_ACL_PROF_TENSOR_INFO 宏使用了 struct aclprofTensor _macro_prof_tensors[],但同一文件中第 65 行的 INPUT 宏、第 82 行的 OUTPUT 宏以及第 103 行的 sizeof(aclprofTensor) 均直接使用 aclprofTensor(无 struct 关键字)。三个 .cpp 调用方文件中也都使用 aclprofTensor / aclprofTensorInfo 无 struct。
本次 diff 删除了本地 struct aclProfTensor / struct aclProfTensorInfo / struct aclprofEventAttributes 的定义,改为依赖 SDK 头文件 (acl/acl_prof.h) 提供的类型。如果 SDK 将 aclprofTensor 定义为匿名 struct 的 typedef(即 typedef struct { ... } aclprofTensor;),则第 102 行的 struct aclprofTensor 会因找不到对应的 struct tag 而导致编译失败。移除多余的 struct 关键字可消除此风险,并与代码库中所有其他引用保持一致。
建议:将第 102 行的 struct aclprofTensor 改为 aclprofTensor(去掉 struct 关键字),与其他所有使用处保持一致。
| 102
| - |
|
102 | + aclprofTensor _macro_prof_tensors[] = {__VA_ARGS__}; \ |


compile


流水线任务触发成功
任务链接 [5d23a39c23624b4b94b26eba95b88148][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Pre | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_X86_monitor_910b | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910c | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_experimental_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_experimental_950 | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test | ✅ SUCCESS | ||
| PreSmoke_A900 | ✅ SUCCESS | >>>>> | |
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> |
[2026-06-24 11:39:48] CI执行结束


流水线任务触发成功
任务链接 [afdfd4459380498da60b5f8647daf7c4][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| codecheck_style | ✅ SUCCESS | >>>>> | |
| StaticCheck_codespell_check | ✅ SUCCESS | ||
| StaticCheck_link_validity_check | ✅ SUCCESS | ||
| StaticCheck_resource_existence_check | ✅ SUCCESS | ||
| StaticCheck_tag_closed_check | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS | ||
| codecheck_checkpr | ✅ SUCCESS | ||
| codecheck_precommit | ⚠️ WARNING | >>>>> | >>>>> |
[2026-06-24 11:26:00] CI执行结束


/lgtm
/approve


/lgtm
/approve


描述
关联的Issue
测试
文档更新
类型标签