合并受阻
变更摘要
该 PR 为「代码侦探 Challenge05」新增 MulCustom 逐元素乘法算子(z[i] = x[i] * y[i]),完整实现了 AscendC 算子内核与 Host 侧调用流程,并新增独立目录 PPParticle/MulCustom,不修改官方 Template。核心是定义 KernelMul 类完成多核数据切分与 Global Memory 地址初始化,使用双缓冲(BUFFER_NUM = 2)管理输入/输出队列,按 CopyIn → Compute → CopyOut 流水处理并调用 AscendC::Mul 完成计算;Host 侧通过 kernel_mul 封装 ACL 初始化、内存申请、H2D/D2H 数据搬运、Kernel 启动与资源清理,最终由 VerifyResult 与 golden 结果比对完成精度校验。算子仅支持长度固定为 8 * 2048 的 float32 输入。
主要改动
- 内核类
KernelMul与数据切分: 在Init中基于AscendC::GetBlockNum()/AscendC::GetBlockIdx()计算每核blockLength和偏移,通过SetGlobalBuffer初始化xGm/yGm/zGm三个 Global Tensor,并配置 AIV-only 的mul_custom入口函数及MulCustomTilingData切分参数结构体。 - 双缓冲与处理流水线: 使用
TQue(inQueueX/inQueueY/outQueueZ,深度 2)实现 Double Buffer,Process按tileNum * BUFFER_NUM次循环依次执行CopyIn(DataCopy搬入)、Compute(AscendC::Mul逐元素相乘)、CopyOut(结果写回 Global Memory)并配对EnQue/DeQue/FreeTensor。 - Host 侧
kernel_mul流程: 完成aclInit、aclrtSetDevice、流创建、aclrtMalloc/aclrtMallocHost内存申请、H2D/D2HaclrtMemcpy搬运以及mul_custom<<<BLOCK_DIM, nullptr, stream>>>Kernel 启动,并以 lambdacleanup统一释放设备/主机内存并复位设备。 - 精度校验
VerifyResult与main:main以常量1.2f、2.3f构造长度为EXPECTED_TOTAL_LENGTH的输入和 golden 向量,VerifyResult通过std::equal逐元素比对输出与 golden,成功/失败时分别打印[Success]/[Failed]结果并返回退出码。 - 构建运行脚本
run.sh: 校验ASCEND_TOOLKIT_HOME/ASCEND_HOME_PATH环境变量并加载环境,随后调用cmake配置、并行编译并执行生成的mul_test可执行文件完成验证。


Hi @PPParticle, 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.


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: luzx66, 傅涛, Carolina_yuan, 王艳秋, shaoyf) | ❌ (0/1)(You can also ask: 傅涛, luzx66, li-shengxian3, Carolina_yuan, shaoyf) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
PPParticle, thanks for your pull request. All authors of the commits have signed the CLA. 👍


/check-cla


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


/check-cla


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


/check-cla


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


PR功能描述 / 为什么需要这个合入:
实现 Challenge05 MulCustom 逐元素乘法算子。
主要内容:
AscendC::Mul完成逐元素乘法计算PPParticle/MulCustom目录,不修改官方 Template该PR关联的issue
https://gitcode.com/cann/cann-learning-hub/issues/700
希望检视人员了解:
已在真实 Ascend NPU 环境完成编译运行和精度验证。
改动类型 / Change Type
测试信息 / Testing
测试环境:
bash run.sh[100%] Built target mul_test[Success] Case accuracy is verification passed.RUN_EXIT=0测试截图:
检查清单 / Checklist