已开启
【代码侦探Challenge05】完成weixin_48384182的MulCustom逐元素乘法算子 #2452
【代码侦探Challenge05】完成weixin_48384182的MulCustom逐元素乘法算子 #2452
已开启
爱上纯净的蓝天创建于 16 天前
爱上纯净的蓝天
16 天前

当前PR是否有AI参与:

[x] 否

[ ] 是
__1. AI Agent 平台:
__2. AI 模型:
__3. Prompt上下文 :

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

MulCustom逐元素乘法算子

该PR关联的issue

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

希望检视人员了解:

改动类型 / Change Type

测试信息 / Testing

检查清单 / Checklist

测试:
image.png

likedislike
合并受阻
爱上纯净的蓝天爱上纯净的蓝天
16 天前 创建了 pull request,commit ff70dffe
爱上纯净的蓝天爱上纯净的蓝天
16 天前 关联了issue:代码侦探(第五期)|补全算子代码有奖,周周赢取定制礼品!
atomgit-bot
atomgit-bot
16 天前 评论:

变更摘要

该 PR 主要完成 CANN 代码侦探 Challenge05 的 MulCustom 逐元素乘法算子(关联 issue #700):新增 mul_custom.asc,实现基于 AscendC::Mul 的多核、Double Buffer 分块乘法 kernel KernelMul,并提供 host 侧 kernel_mul 驱动、结果校验函数以及一键编译运行的 run.sh 脚本。此外,本次改动文件同时包含了 Challenge02 的 div_bf16_custom.asc(bfloat16 除法算子)及其 run.sh,整体属于算子实现与本地验证代码的新增(共新增 464 行,无删除)。

主要改动

  • KernelMul 多核乘法算子实现: 在 mul_custom.asc 中新增 KernelMul 类,按核数切分数据(blockLength = totalLength / GetBlockNum()),并按 Double Buffer 计算每段搬运长度(tileLength = blockLength / tileNum / BUFFER_NUM,其中 BUFFER_NUM = 2),通过 CopyIn/Compute/CopyOut 流水处理,在 Compute 中调用 AscendC::Mul 完成 z = x * y 的逐元素乘法。
  • host 侧驱动与校验逻辑: 同文件新增 MulCustomTilingData 结构(含 totalLengthtileNum)与 kernel_mul 函数,通过 ACL 接口完成设备内存分配、数据搬运,并以 8 核(numBlocks = 8)启动 mul_custom kernel、回拷结果;VerifyResult 将输出与 golden 对比(如 1.2 × 2.3 = 2.76)并打印验证结论。
  • 新增编译运行脚本: 新增 MulCustom/run.sh,自动探测并激活 CANN 环境(ASCEND_TOOLKIT_HOME),以 dav-2201 架构通过 cmake 编译后运行 mul_test 进行算子验证。
  • 包含 Challenge02 的除法算子文件: 改动同时新增 div_bf16_custom.asc,实现 bfloat16 除法算子:将输入 bfloat16_t 通过 CastCAST_NONE)转为 float,调用 AscendC::Div 后以 CAST_RINT 转回 bfloat16_t,配套 run.sh 完成编译与结果校验。
likedislike
不准确?
atomgit-bot
atomgit-bot
16 天前 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
16 天前 添加了label:stat/needs-squash
CANN-robotCANN-robot成员
16 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
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.
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

⚠️ This PR does not yet meet the following requirements:lgtm (requires ≥ 2 person(s) per module)、approve (requires ≥ 1 person(s) per module)

Module Approval Details

module lgtm status approve status
repo-cann/cann-outreach ❌ (0/2)(You can also ask: li-shengxian3, Carolina_yuan, luzx66, 王艳秋, yanhf) ❌ (0/1)(You can also ask: 傅涛, Carolina_yuan, yanhf, 田晓亮, luzx66)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

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

likedislike