已合并
【代码侦探Challenge05】完成 zhaojianing2025 的 MulCustom 逐元素乘法算子 #3500
【代码侦探Challenge05】完成 zhaojianing2025 的 MulCustom 逐元素乘法算子 #3500
已合并
zhaojianing2025创建于 9月7日
zhaojianing2025
9月7日

当前PR是否有AI参与:

[ ] 否
[x] 是

__1. AI Agent 平台: OpenAI Codex
__2. AI 模型: GPT-5.6 Sol
__3. Prompt上下文: 阅读 Challenge05 任务书和多个已提交 PR,完成 MulCustom 的 Kernel、Host 侧实现、静态检查、提交规范核对及 PR 提交流程。

PR功能描述 / 为什么需要这个合入**:

完成 Challenge05 MulCustom float32 逐元素乘法算子,实现 z[i] = x[i] * y[i]。

主要实现:

  • 完成 KernelMul 的 Init、Process、CopyIn、Compute 和 CopyOut
  • 使用 AscendC::Mul 实现逐元素乘法
  • 实现 8 核数据切分、8 个 tile 和 Double Buffer
  • 完成 Host 侧 ACL 内存管理、Kernel 调用及结果验证

该PR关联的issue

References https://gitcode.com/cann/cann-learning-hub/issues/700

希望检视人员了解:

代码已通过 git diff --check、脚本语法和提交文件范围检查,并在 CANN 9.0.0、Ascend910B(dav-2201)Simulator 环境完成编译和运行验证。

验证结果:

Output: 2.76 2.76 2.76 2.76 2.76 ...
Golden: 2.76 2.76 2.76 2.76 2.76 ...
[Success] Case accuracy is verification passed.

验证截图:
MulCustom verification

改动类型 / Change Type

测试信息 / Testing

检查清单 / Checklist

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

变更摘要

本 PR 完成 Challenge05 的 MulCustom float32 逐元素乘法算子(z[i] = x[i] * y[i]),新增 mul_custom.asc 与 run.sh 两个文件。核心是实现了 KernelMul 的 Init、Process、CopyIn、Compute、CopyOut 全流程,使用 AscendC::Mul 完成计算,并配套 Host 侧 ACL 内存管理、Kernel 启动与结果校验逻辑。

主要改动

  • 算子 Kernel 实现: 新增 mul_custom.asc,定义 MulCustomTilingData(含 totalLength、tileNum)与 KernelMul 类,实现 Init、Process、CopyIn、Compute、CopyOut,其中 Compute 通过 AscendC::Mul(zLocal, xLocal, yLocal, tileLength) 完成逐元素乘法,Process 按 tileNum * BUFFER_NUM 循环调度拷贝与计算。
  • 数据切分与流水: Init 中按 AscendC::GetBlockNum()(8 核)切分 blockLength,并以 BUFFER_NUM = 2(Double Buffer)初始化 inQueueX、inQueueY、outQueueZ 三个队列,CopyIn/CopyOut 以 progress * tileLength 为偏移执行 DataCopy。
  • Host 侧封装与启动: 新增 kernel_mul 函数,通过 ACL 接口(aclInit、aclrtMalloc、aclrtMemcpy、aclrtSynchronizeStream 等)完成设备内存分配、数据搬运、以 mul_custom<<<blockDim, nullptr, stream>>> 启动 Kernel(blockDim = 8、tileNum = 8)并将结果回拷;main 中构造 totalLength = 8 * 2048 的输入并调用 VerifyResult 与 golden 结果比对。
  • 构建运行脚本: 新增 run.sh,通过 source "$ASCEND_TOOLKIT_HOME/set_env.sh" 激活 CANN 环境,并依次执行 cmake、make 及运行 ./mul_test,用于算子编译与运行验证。
likedislike
不准确?
CANN-robot
CANN-robot成员
9月7日 评论:

Hi @zhaojianing2025, 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
atomgit-bot
atomgit-bot
9月7日 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
9月7日 添加了label:cann-cla/no
CANN-robotCANN-robot成员
9月7日 添加了label:ai-co-authored
CANN-robot
CANN-robot成员
9月7日 评论:

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)

CLA Signature Pass

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

likedislike
zhaojianing2025
zhaojianing2025
9月7日 评论:

/compile

likedislike
zhaojianing2025
zhaojianing2025
9月7日 评论:

/check-cla

likedislike
zhaojianing2025
zhaojianing2025
9月7日 评论:

/compile

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

CLA检查未通过,详情可参考这里

likedislike
zhaojianing2025
zhaojianing2025
9月7日 评论:

/check-cla

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

CLA检查未通过,详情可参考这里

likedislike
zhaojianing2025
zhaojianing2025
9月7日 评论:

/check-cla

likedislike
zhaojianing2025
zhaojianing2025
9月7日 评论:

/compile

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

CLA检查已通过,详情可参考这里

likedislike
zhaojianing2025
zhaojianing2025
9月7日 评论:

/compile

likedislike
zhaojianing2025zhaojianing2025
9月7日 预合并成功(commit_id: 2fc5446f3bbcbaf94f50954675d23810a0de40fe)
zhaojianing2025zhaojianing2025
9月7日 强制推送  1 个提交:c529c74a-【代码侦探Challenge05】完成 zhaojianing2025 的 MulCustom 逐元素乘法算子 [GPT-5.6 Sol]
zhaojianing2025zhaojianing2025
9月7日 预合并成功(commit_id: 41447c8441e9aa2c48d3297a59df1ae60dd23ba2)
CANN-robotCANN-robot成员
9月7日 删除了label:cann-cla/yes
CANN-robotCANN-robot成员
9月7日 添加了label:cann-cla/yes
CANN-robotCANN-robot成员
9月7日 添加了label:ai-includes-code
zhaojianing2025
zhaojianing2025
9月7日 评论:

/check-cla

likedislike
zhaojianing2025
zhaojianing2025
9月7日 评论:

/compile

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

CLA检查已通过,详情可参考这里

likedislike
CANN-robotCANN-robot成员
9月7日 添加了label:ai-compliance-successful
zhaojianing2025zhaojianing2025
9月7日 预合并成功(commit_id: 29f23a25029992a722429c3dc2890ac15dce3faf)
zhaojianing2025zhaojianing2025
9月7日 强制推送  1 个提交:5598fb6f-【代码侦探Challenge05】完成 zhaojianing2025 的 MulCustom 逐元素乘法算子 [GPT-5.6 Sol]
zhaojianing2025zhaojianing2025
9月7日 预合并成功(commit_id: 0cb2267fec86559690a0b74c03547d1ad944fc8e)
CANN-robotCANN-robot成员
9月7日 删除了label:cann-cla/yes
CANN-robotCANN-robot成员
9月7日 添加了label:cann-cla/yes
zhaojianing2025
zhaojianing2025
9月7日 评论:

/check-cla

likedislike
zhaojianing2025
zhaojianing2025
9月7日 评论:

/compile

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

CLA检查已通过,详情可参考这里

likedislike
zhaojianing2025zhaojianing2025
9月7日 修改了pull request 的描述
shaoyf成员
9 天前 评论:

/approve
/lgtm

likedislike
fulltower成员
9 天前 评论:

/approve
/lgtm

likedislike
CANN-robotCANN-robot成员
9 天前 添加了label:lgtmapproved
CANN-robotCANN-robot成员
9 天前 合入了pull request