Pull Request已成功合入, 合并人@CANN-robot
(感谢 hzw_rpap 的贡献)变更摘要
本次 PR 提交了 aclnnBernoulli 算子的内存优化设计文档(design.md),属于 7 月社区任务中该算子开发的前期设计阶段。文档系统性地分析了原有小算子拼接路径导致的内存膨胀根因,并提出了基于 DSA packed mask 与连续输出同址复用的优化方案,涵盖从高地址到低地址的 wave 原地展开安全性设计、Host/Tiling/Kernel/UB 多层级预算规划,以及对非连续 Tensor、极小 Tensor 和 FP64 场景的 fallback 策略,最终给出了在 Atlas A2/A3 训练系列上的功能、内存与性能验证结论。
主要改动
- 内存膨胀根因分析:文档梳理了原小算子拼接路径的执行流程,定位了中间张量分配导致显存占用膨胀的关键环节,为后续优化提供了依据。
- DSA packed mask 同址复用方案:提出将 DSA packed mask 与连续输出 Tensor 复用同一块内存区域的设计,避免额外的显存分配,从源头压缩内存开销。
- Wave 原地展开安全性设计:设计了从高地址向低地址逐 wave 原地展开的策略,确保在复用内存的场景下数据写入不会覆盖尚未消费的源数据,保证计算正确性。
- 多层预算与 fallback 设计:分别对 Host 端、Tiling 策略、Kernel 实现和 UB(Unified Buffer)进行了资源预算规划,并针对非连续 Tensor、极小 Tensor 和 FP64 数据类型制定了 fallback 执行路径。
- A2/A3 验证结果汇总:文档中整理了在 Atlas A2/A3 训练系列硬件上的功能正确性、内存占用对比和性能测试数据,验证了设计方案的有效性。


CLA Signature Guide
@hzw_rpap , thanks for your pull request.
The following commit(s) have not signed Contributor License Agreement (CLA).
| Commit | Reason |
|---|---|
| e195b218 【社区任务】aclnnBernoulli... | the email used in the commit is platform default email: ***@noreply.gitcode.com! 使用了Gitcode平台系统默认邮箱,需要在平台个人设置里绑定个人邮箱. |
If you need to sign CLA, you can click here to sign the CLA.
If you need to check if the email is set up correctly, you can click here to do it in the FAQs.
After signing the CLA or updating the email, you must comment /check-cla to check the CLA status again.


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 |
|---|---|---|
| repo-cann/cann-ops-competitions | ✅ 傅涛, Carolina_yuan (2/2) | ✅ 傅涛, Carolina_yuan (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
hzw_rpap, thanks for your pull request. All authors of the commits have signed the CLA. 👍


/check-cla


流水线任务触发成功
任务链接 [93717eddd7544243ad2a163a315961ee][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| cocheck_codestyle | ✅ SUCCESS | ||
| anti_virus | ✅ SUCCESS | ||
| Check_Pr | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> |
[2026-07-25 16:51:29] CI执行结束


@condfuse_3 @fullt @Ascend-CANN 请检视,aclnnBernoulli 算子设计文档已提交,CLA 已通过。


流水线任务触发成功
任务链接 [6eaa5f6f1f494cab9e526d6ddbab3100][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| cocheck_codestyle | ✅ SUCCESS | ||
| anti_virus | ✅ SUCCESS | ||
| Check_Pr | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> |
[2026-07-25 23:46:44] CI执行结束


@condfuse_3 @fullt @Ascend-CANN 已更新最终 A2/A3 验证结果,补充了两平台 TTK、Sanitizer 及精度验证结论,请复核。


compile


/compile




流水线任务触发成功
任务链接 [696bb913a1fb45b681d19e1876c02b59][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| cocheck_codestyle | ✅ SUCCESS | ||
| anti_virus | ✅ SUCCESS | ||
| Check_Pr | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> |
[2026-07-26 09:56:17] CI执行结束


@condfuse_3 @fullt @Ascend-CANN 完成了算子设计,并且已更新最终 A2/A3 实际验证结果,补充了两平台 TTK、Sanitizer 及精度验证结论,请复核


流水线任务触发成功
任务链接 [461086b93eb847288817b54ae331b344][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| cocheck_codestyle | ✅ SUCCESS | ||
| anti_virus | ✅ SUCCESS | ||
| Check_Pr | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> |
[2026-07-26 11:04:45] CI执行结束


对应的算子代码 PR: https://gitcode.com/cann/ops-math/pull/4248


@condfuse_3 @fullt @Ascend-CANN
aclnnBernoulli 设计文档已同步至最终实现。代码 PR #4248 已提交,CLA、SCA、静态检查、编译、UT 和冒烟测试均已通过;A2/A3 自测与验收材料也已整理完成。
请协助完成设计文档评审;如无其他修改意见,烦请明确回复“评审通过”。


/approve


任务信息
本次提交
提交 aclnnBernoulli 算子内存优化设计文档,主要包括:
文件路径
04_tasks/01_community-task-2026/tasklist/07-24-aclnnBernoulli/hzw_rpap/docs/design.md