已合并
【代码侦探Challenge07】SigmoidCustom 算子补全(个人开发者) #4202
【代码侦探Challenge07】SigmoidCustom 算子补全(个人开发者) #4202
已合并
tianjun创建于 9月23日
tianjun
9月23日

当前 PR 是否有 AI 参与

    1. AI Agent 平台:Codex,开发时使用 CANNBot skills。
    2. AI 模型:GPT-6。
    3. Prompt 上下文:按代码侦探 Challenge07 官方模板完成 SigmoidCustom 算子,并参考 CANNBot 的 Ascend C Tiling、API 和精度调试指导。

PR 功能描述

在 2026/CANN-Code-Detective/Challenge07-SigmoidCustom/PR_code/Ethan_Zou_07/ 提交完整算子工程,补全 Tiling、Kernel、算子注册与测试。

关联活动

cann-learning-hub issue #744。

参与信息

  • 渠道:公众号
  • 身份:个人开发者
  • 企业/单位:无
  • 课程学习:已完成

改动类型

测试信息

CANNJudge 提交 426729 通过 2/2,float16、float32 测试误差均为 0.00%。本地没有 CANN SDK,未运行本地构建与单元测试。

检查清单

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 tianjun 的贡献)
Ttianjun
9月23日 创建了 pull request,commit 79e8e788
Ttianjun
9月23日 关联了issue:代码侦探(第七期)|补全算子代码有奖,周周赢取定制礼品!
atomgit-bot
atomgit-bot
9月23日 评论:

变更摘要

本 PR 在 2026/CANN-Code-Detective/Challenge07-SigmoidCustom/PR_code/Ethan_Zou_07/ 下提交了一套完整的 Sigmoid 自定义算子工程,覆盖算子定义、形状推导、Tiling、Kernel 实现与测试用例。算子定义 Sigmoid 以 x 为输入、y 为输出,支持 DT_FLOAT 与 DT_FLOAT16、FORMAT_ND 格式,并注册到 ascend910b 的 AICore;Tiling 侧根据输入形状与数据类型计算 blockFactor、ubFactor 并设置 tiling key,Kernel 侧以模板类 NsSigmoid::Sigmoid 按 schMode 分派 half/float 实现。同时提供了 aclnn 调用示例、build.sh 构建脚本以及基于 gtest 的 op_host / op_kernel 单元测试与精度比对脚本。

主要改动

  • 算子定义与注册:新增 op_host/sigmoid_def.cpp,通过 OpDef 定义 Sigmoid 的输入 x、输出 y,数据类型为 {ge::DT_FLOAT, ge::DT_FLOAT16},格式为 FORMAT_ND 并启用 AutoContiguous,AICore 配置为 ascend910b。
  • 形状推导与 Tiling 计算:新增 op_host/sigmoid_infershape.cpp 实现 InferShapeSigmoid,将输出 shape 直接对齐输入 shape;op_host/sigmoid_tiling.cpp 的 SigmoidTilingFunc 读取平台信息与输入形状,计算 totalNum、blockFactor、ubFactor,并按数据类型设置 tiling key(float16 与 float32 分别对应不同模板模式)。
  • Kernel 实现:新增 op_kernel/sigmoid.h 中的模板类 NsSigmoid::Sigmoid,以 BUFFER_NUM=2 双缓冲、CopyIn/Compute/CopyOut 流程调用 AscendC::Sigmoid;op_kernel/sigmoid.cpp 按模板参数 schMode 分派 half 与 float 实例;并新增 sigmoid_tiling_data.h(SigmoidTilingData 结构)与 sigmoid_tiling_key.h(ASCENDC_TPL_ARGS_DECL 数据类型模板声明)。
  • Tiling 与形状推导单元测试:新增 tests/ut/common/ 下的 tiling_context_faker、infershape_context_faker、any_value 及对应 executor,并在 tests/ut/op_host/test_sigmoid_tiling.cpp 中定义 float32/float16 两组用例,校验 tiling key、tiling data 与 workspace。
  • Kernel 测试与构建、示例脚本:新增 tests/ut/op_kernel/test_sigmoid.cpp 直接构造 SigmoidTilingData 运行 kernel 并输出 bin,配合 sigmoid_data/gen_data.py 生成数据、compare_data.py 按阈值进行精度比对;tests/ut/run.sh、根目录 build.sh 与 examples/run.sh 提供构建、UT 与 aclnnSigmoid 示例的执行入口。
likedislike
不准确?
atomgit-bot
atomgit-bot
9月23日 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robot
CANN-robot成员
9月23日 评论:

Hi @Ethan_Zou, welcome to submitting your first PR to cann-outreach!

PR Merge Steps

1. CLA Signing

If the current PR label includes cann-cla/yes, it means you have signed the CLA and can proceed to the next step. If the label includes cann-cla/no, please sign the CLA first. If you have any questions, please refer to the FAQ.

2. CI Check

Please comment /compile to trigger the CI pipeline check. If the CI run is successful, the PR will be tagged with ci-pipeline-passed and you can proceed to the next step. If the CI run fails, the PR will be tagged with ci-pipeline-failed, please check the CI logs to fix the issues in the PR. If you have any questions, please refer to the FAQ.

3. Code Review

After CI passes, please refer to the PR Approval Progress and proactively @ the committers in the table to review the code. After approval, committers will comment /lgtm and /approve. Once the lgtm and approved labels are successfully added, the PR will be merged automatically.

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

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.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


PR Approval Progress

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

Module Approval Details

module lgtm status approve status
repo-cann/cann-outreach ✅ shaoyf, 傅涛 (2/2) ✅ shaoyf, 傅涛 (2/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)
likedislike
CANN-robot
CANN-robot成员
9月23日 评论:

CLA Signature Pass

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

likedislike
tianjun
9月23日 评论:

/compile

likedislike
tianjun
9月23日 评论:

compile

likedislike
shaoyf成员
12 天前 评论:

/approve
/lgtm

likedislike
fulltower成员
12 天前 评论:

/approve
/lgtm

likedislike
CANN-robotCANN-robot成员
12 天前 添加了label:lgtmapproved
CANN-robotCANN-robot成员
12 天前 关闭了关联的issue
CANN-robotCANN-robot成员
12 天前 合入了pull request