已合并
Selu:TilingKey 改为 def 驱动 dtype,补齐 geir 示例 #7566
yulianjie创建于 7月16日
Selu:TilingKey 改为 def 驱动 dtype,补齐 geir 示例 #7566
已合并
yulianjie创建于 7月16日
yulianjie成员
7月16日
## 描述 Selu:TilingKey 改为 def 驱动 dtype,补齐 geir 示例 ## 关联的Issue https://gitcode.com/cann/ops-nn/issues/4108 ## 测试 ## 文档更新 ## 类型标签 - [x] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 - [ ] AI辅助编写
likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 yulianjie 的贡献)
Yyulianjie成员
7月16日 创建了 pull request,commit 01766596
Yyulianjie成员
7月16日 关联了issue:[Bug-Report|缺陷反馈]: TilingKey 改为 def 驱动 dtype,补齐 geir 示例
atomgit-bot
atomgit-bot
7月16日 评论:

变更摘要

此 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_DECLASCENDC_TPL_DATATYPE_SEL 被移除,替换为单一的 schModeSELU_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 函数对齐新的 TilingKeyselu_tiling_arch35.cppSetEmptyTensorTiling 移除了 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.cppexamples/arch35/test_geir_selu.cpp 两个测试文件,提供通过 GE Graph API 构建 Selu 算子图并运行的完整示例,支持 dtype 参数化输入验证。

likedislike
atomgit-bot
atomgit-bot
7月16日 评论:

代码审查

审查总结

本 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

💬 仅评论

likedislike
CANN-robotCANN-robot成员
7月16日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
7月16日 评论:

CLA Signature Pass

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

likedislike
CANN-robot
CANN-robot成员
7月16日 评论:

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 /approve or /lgtm
  • Commenting /approve implies 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. 👍

likedislike
CANN-robotCANN-robot成员
7月16日 将zengjuan,crystalhu,yangyang016,fanqirui,chenqi317,jiangtao_rts,liubo75,tangweiwei2,gitcode-chenjiao,hanxiaolong,gcw_kUomxQ2l,Andy-lb设为评审人
yulianjie成员
7月16日 评论:

compile

likedislike
CANN-robotCANN-robot成员
7月16日 将jiangtao_rts,gitcode-chenjiao,hanxiaolong,gcw_kUomxQ2l,Andy-lb设为审查人
Yyulianjie成员
7月16日 update merge request[project id: 7665709, iid: 7566, commit_id: 620846fc481981bd7748fc47b71a4454cee324d8] virtual merging success
CANN-robotCANN-robot成员
7月16日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
7月16日 评论:

流水线任务触发成功
任务链接 [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执行结束

likedislike
CANN-robot
CANN-robot成员
7月16日 评论:

流水线任务触发成功
任务链接 [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执行结束

likedislike
CANN-robotCANN-robot成员
7月16日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
7月16日 添加了label:ci-pipeline-passed
lileizheng成员
7月16日 评论:

/reject

likedislike
conv2d_ci
7月16日 评论:
pipeline history
TimeNameResultLink
2026-07-16 15:20:50Start_PipelineMR_335
likedislike
conv2d_ci
7月16日 评论:
pipeline history
TimeNameResultLink
2026-07-16 15:22:24commit2026-07-16T14:52:28+08:00d066deb2
Compile_Result :x: NOT_RUN
SC_Result :x: NOT_RUN
RDV_Result:ALL :x: NOT_RUN
likedislike
atomgit-bot
atomgit-bot7月16日进行代码检视1
activation/selu/examples/arch35/test_geir_selu.cpp
@@ -0,0 +17,4 @@
17+#include <vector>
18+#include <string>
19+#include <map>
20+#include "assert.h"
atomgit-bot
atomgit-bot7月16日评论:

🟡 Medium Priority

test_geir_selu.cpp,arch35 版本同样在 GetTime() 中使用了 time_ttime()localtime()strftime() 而未包含 <ctime>。该文件是新增独立文件,存在相同的编译失败风险。

建议:在 #include "assert.h" 之后添加 #include <ctime>

改动建议
20
- #include "assert.h"
20
+ #include "assert.h"
21
+ #include <ctime>
应用建议
likedislike
atomgit-bot
atomgit-bot7月16日进行代码检视1
activation/selu/examples/test_geir_selu.cpp
@@ -0,0 +17,4 @@
17+#include <vector>
18+#include <string>
19+#include <map>
20+#include "assert.h"
atomgit-bot
atomgit-bot7月16日评论:

🟡 Medium Priority

两个示例文件 (test_geir_selu.cpparch35/test_geir_selu.cpp) 中的 GetTime() 函数使用了 time_ttime()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>
应用建议
likedislike
tangweiwei2成员7月16日进行代码检视1
activation/selu/examples/arch35/test_geir_selu.cpp
@@ -0,0 +1,0 @@
1+/**
tangweiwei27月16日评论:

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

likedislike
Yyulianjie成员
7月16日 update merge request[project id: 7665709, iid: 7566, commit_id: f3533efc40ed9c8ecb3867360a1fb80d5d39e413] virtual merging success
Yyulianjie成员
7月16日 推送  1 个提交:1ad71ab9-fix: 修复 selu geir 示例 fopen 二进制模式及 fwrite 返回值检查
Yyulianjie成员
7月16日 update merge request[project id: 7665709, iid: 7566, commit_id: a6fd9ebd6520ab5e739ec802af3d3ac34f54c5d4] virtual merging success
CANN-robotCANN-robot成员
7月16日 添加了label:stat/needs-squash
CANN-robotCANN-robot成员
7月16日 删除了label:ci-pipeline-passed
CANN-robot
CANN-robot成员
7月16日 评论:

Notification

This pull request has been changed(code update) or closed, so removes the following label(s): ci-pipeline-passed.

likedislike
yulianjie成员
7月16日 评论:

compile

likedislike
Yyulianjie成员
7月16日 update merge request[project id: 7665709, iid: 7566, commit_id: 938c7c1983266cde196b829c5588501895af11aa] virtual merging success
CANN-robotCANN-robot成员
7月16日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
7月16日 评论:

流水线任务触发成功
任务链接 [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执行结束

likedislike
Yyulianjie成员
7月16日 update merge request[project id: 7665709, iid: 7566, commit_id: 6dc16d904c259aca45c555dcf5b427654598828f] virtual merging success
Yyulianjie成员
7月16日 推送  1 个提交:762a0f0f-fix: 补充 ctime 头文件,修复 data_size 类型截断
Yyulianjie成员
7月16日 update merge request[project id: 7665709, iid: 7566, commit_id: a506e6583ec9274d6b7bad42966c881f0e9cf790] virtual merging success
CANN-robot
CANN-robot成员
7月16日 评论:

流水线任务触发成功
任务链接 [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执行结束

likedislike
CANN-robotCANN-robot成员
7月16日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
7月16日 添加了label:ci-pipeline-passed
conv2d_ci
7月16日 评论:
pipeline history
TimeNameResultLink
2026-07-16 18:33:43Start_PipelineMR_335
likedislike
conv2d_ci
7月16日 评论:
pipeline history
TimeNameResultLink
2026-07-16 18:35:50commit2026-07-16T18:23:06+08:00762a0f0f
Compile_Result :x: NOT_RUN
SC_Result :x: NOT_RUN
RDV_Result:ALL :x: NOT_RUN
likedislike
liulun0308成员
7月17日 评论:

/approve

likedislike
CANN-robotCANN-robot成员
7月17日 添加了label:approved
Yyulianjie成员
7月17日 将xxxzzzh设为审查人
Yyulianjie成员
7月17日 解决了最后一个问题
CANN-robot
CANN-robot成员
7月17日 评论:

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

likedislike
tangweiwei2成员
7月17日 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
7月17日 添加了label:lgtm
CANN-robotCANN-robot成员
7月17日 关闭了关联的issue
CANN-robotCANN-robot成员
7月17日 合入了pull request
CANN-robot
CANN-robot成员
7月17日 评论:

Pull Request 已合并或已关闭。

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike