

Pull Request已成功合入, 合并人@CANN-robot
(感谢 yulianjie 的贡献)变更摘要
此 PR 对 Selu 算子的 TilingKey 机制进行了重构,将原先由 TilingKey 编码 dtype 的方式改为由 def 文件驱动 dtype(通过 DTYPE_X 编译宏注入),TilingKey 仅保留单一的占位调度维度 schMode。同时补齐了两个 GEIR(Graph Engine IR)示例测试文件,用于验证 Selu 算子在 GE 图编排场景下的功能正确性。关联 issue 为 ops-nn#4108,类型标记为 Bug 修复。
主要改动
-
TilingKey 机制重构:
selu_tiling_key.h中原先按 dtype(float/float16/bfloat16/int32/int8)映射 TilingKey 0~4 的宏ASCENDC_TPL_DATATYPE_DECL和ASCENDC_TPL_DATATYPE_SEL被移除,替换为单一的schMode(SELU_SCH_MODE_0)占位调度维度,dtype 由 def 文件驱动、构建系统注入DTYPE_X宏。 -
Kernel 入口适配 def 驱动模式:
selu.cpp中模板参数由typename D_T_X改为uint32_t schMode,新增SeluTilingKey枚举,使用if constexpr编译期分发到NsSelu::Selu<DTYPE_X>,dtype 分支逻辑完全由 def 注入的DTYPE_X决定。 -
Tiling 函数对齐新的 TilingKey:
selu_tiling_arch35.cpp中SetEmptyTensorTiling移除了dataType参数,SeluTilingFunc中不再通过ASCENDC_TPL_SEL_PARAM传递 dtype 给 TilingKey,统一改为context->SetTilingKey(GET_TPL_TILING_KEY(SELU_SCH_MODE_0))。 -
Kernel 头文件注释更新:
selu.h中模板参数说明由原先 "mapped by TilingKey" 更新为 "由 kernel 入口绑定为 DTYPE_X(def 驱动 dtype)",反映 dtype 分发方式从 TilingKey 映射到if constexpr编译期分发的变更。 -
补齐 GEIR 示例:新增
examples/test_geir_selu.cpp和examples/arch35/test_geir_selu.cpp两个测试文件,提供通过 GE Graph API 构建 Selu 算子图并运行的完整示例,支持 dtype 参数化输入验证。


代码审查
审查总结
本 PR 将 Selu 算子的 TilingKey 从"dtype 驱动"重构为"def 驱动 dtype + TilingKey 仅编码 schMode 占位"的模式,这是 Ascend C 的标准做法,与其他算子(如 celu_v2)一致。核心算子代码(tiling、kernel)变更正确,无逻辑缺陷。
6 个变更文件的审查结果:
| 文件 | 结论 |
|---|---|
activation/selu/examples/arch35/test_geir_selu.cpp |
3 个 P2/P3 问题(缺少头文件、返回值未检查、截断) |
activation/selu/examples/test_geir_selu.cpp |
3 个 P2/P3 问题(同上,独立文件) |
activation/selu/op_host/arch35/selu_tiling_arch35.cpp |
无问题 |
activation/selu/op_kernel/arch35/selu.h |
无问题(仅注释和格式化变更) |
activation/selu/op_kernel/arch35/selu_tiling_key.h |
无问题 |
activation/selu/op_kernel/selu.cpp |
1 个 P3 建议(if constexpr 防御性守卫) |
共计 7 个发现:P2 × 2,P3 × 5。所有问题均位于新增的 GE IR 示例测试文件中,不影响算子运行时行为。核心 TilingKey 重构正确且与代码库中其他算子模式一致。
整体风险评估:低。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 0 |
| 🟡 建议 | 2 |
💬 仅评论


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


流水线任务触发成功
任务链接 [2de9aa5b244b4168a3d86d9ae393adda][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86_mobile_station | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Pre | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910b | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910c | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_950 | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test_ophost | ✅ SUCCESS | ||
| UT_Test_opapi | ✅ SUCCESS | ||
| UT_Test_kernel | ✅ SUCCESS | ||
| UT_Test_opgraph | ✅ SUCCESS | ||
| PreSmoke_A900 | ✅ SUCCESS | >>>>> | |
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> | |
| UT_Test_harmony-infer-chs-nn | ✅ SUCCESS |
[2026-07-16 15:20:00] CI执行结束


流水线任务触发成功
任务链接 [460c49a060c441818329dbfde5d629f3][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| codecheck_checkpr | ✅ SUCCESS | ||
| StaticCheck_codespell | ✅ SUCCESS | ||
| StaticCheck_link_validity | ✅ SUCCESS | ||
| StaticCheck_resource_existence | ✅ SUCCESS | ||
| StaticCheck_tag_closed | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS | ||
| codecheck_style | ✅ SUCCESS | >>>>> | |
| codecheck_precommit | ⚠️ WARNING | >>>>> | >>>>> |
| SCA | ✅ SUCCESS | >>>>> |
[2026-07-16 15:11:32] CI执行结束


/reject


🟡 Medium Priority
同 test_geir_selu.cpp,arch35 版本同样在 GetTime() 中使用了 time_t、time()、localtime()、strftime() 而未包含 <ctime>。该文件是新增独立文件,存在相同的编译失败风险。
建议:在 #include "assert.h" 之后添加 #include <ctime>。
| 20
| - #include "assert.h" |
|
20 | + #include "assert.h" |
|
21 | + #include <ctime> |


🟡 Medium Priority
两个示例文件 (test_geir_selu.cpp 和 arch35/test_geir_selu.cpp) 中的 GetTime() 函数使用了 time_t、time()、localtime()、strftime(),但未包含 <ctime> 或 <time.h> 头文件。当前包含列表为 <iostream>, <fstream>, <string.h>, <stdint.h>, <vector>, <string>, <map>, "assert.h",均不保证提供这些符号。在严格编译器或特定标准库版本下会导致编译失败("error: 'time_t' was not declared in this scope")。
建议:在 #include "assert.h" 之后添加 #include <ctime>。
| 20
| - #include "assert.h" |
|
20 | + #include "assert.h" |
|
21 | + #include <ctime> |


[编码规范] examples/arch35/test_geir_selu.cpp 与 examples/test_geir_selu.cpp 内容几乎完全相同(均 249 行),唯一差异是 #include 路径。建议合并为单文件通过条件编译处理,或补充说明 arch35 目录独立存在的必要性。


流水线任务触发成功
任务链接 [f9ccbf91874d4e81acbbb08ab80618ba][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86_mobile_station | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Pre | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910b | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910c | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_950 | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test_ophost | ✅ SUCCESS | ||
| UT_Test_opapi | ✅ SUCCESS | ||
| UT_Test_kernel | ✅ SUCCESS | ||
| UT_Test_opgraph | ✅ SUCCESS | ||
| PreSmoke_A900 | ✅ SUCCESS | >>>>> | |
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> | |
| UT_Test_harmony-infer-chs-nn | ✅ SUCCESS |
[2026-07-16 18:33:17] CI执行结束


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


/approve


The following users do not have permission to comment /lgtm or /approve on any module in this PR:
xxxzzzh


/lgtm
/approve


Pull Request 已合并或已关闭。
If you want to solve this problem, you can click here to do it in the FAQs.

