Merged
fix(math): preserve equal infinities in low precision logaddexp #6219
puppyAdd on Oct 11
fix(math): preserve equal infinities in low precision logaddexp #6219
Merged
Pull Request has been successfully merged by CANN-robot.
(Thank you for puppy's contribution.)Oct 11 Associated issue: [Bug-Report|缺陷反馈]: experimental LogAddExp 的 FP16/BF16 路径对同号无穷大返回 NaN
Oct 11 Added label: cann-cla/yes
CANN-robot
Oct 11 Comments:
Oct 11 Comments:
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 |
|---|---|---|
| experimental | ✅ 顾宝成, 周奇龙 (2/2) | ✅ 周奇龙 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
hanggongmao1, thanks for your pull request. All authors of the commits have signed the CLA. 👍


Oct 11 Set FelixTang7,yu-xinjie62,yue-ma,zhou-qilong,wangrui_,wei-peng-1991,renruhai,su-yueming,zhajianqing123,rxtfeng,luowen203_gg123,loov1,zhangzijie,jia0liang,chenqi317,zl_hw,liu-wei,LiuXinxin23,fullt,LiWei79,songkai111,chenxingyu18,demoauguste,pingchuantang,llimwang,gubaocheng,andong_hw,xuejinghui,zhanw_coding,clinglai0517 as approver
Oct 11 Set FelixTang7,yu-xinjie62,yue-ma,zhou-qilong,wangrui_,wei-peng-1991,renruhai,su-yueming,zhajianqing123,rxtfeng,luowen203_gg123,loov1,zhangzijie,jia0liang,chenqi317,zl_hw,liu-wei,LiuXinxin23,fullt,LiWei79,songkai111,chenxingyu18,demoauguste,pingchuantang,llimwang,gubaocheng,andong_hw,xuejinghui,zhanw_coding,clinglai0517 as approver
61 messages are collapsed here。 See more
12 days ago Added label: ci-pipeline-running
12 days ago Removed label: ci-pipeline-running
12 days ago Added label: ci-pipeline-passed
12 days ago Closed associated issue
12 days ago Merged pull request
描述
experimental LogAddExp 的 FP16/BF16 路径对同号 ±Inf 执行
Inf-Inf,最终返回 NaN,预期分别为 +Inf、−Inf。提升到 FP32 后使用 EQ 比较,再反转位图形成不相等掩码:相等输入选择零差值,有 NaN 的输入保留 NaN 差值。BF16 narrowing 后显式写回 ±Inf 与 quiet-NaN 编码,避免特殊值结果依赖 narrowing 行为。异号无穷和有限值仍使用原公式,FP32 分支不变。
比较位图复用输出缓冲;FP32 临时缓冲按 64 元素对齐,只初始化需要补齐的最后一个比较 repeat;特殊值位拷贝复用已经完成计算的临时缓冲,未新增缓冲区。新增 FP16/BF16 特殊值、短 tile、多 tile、比较 repeat 边界与默认 UB tile 加尾块回归,保留 NaN、Inf 与有限值断言。
关联的Issue
Fixes #3472
https://gitcode.com/cann/ops-math/issues/3472
测试
验证对应 HEAD
a43a21fab9c282a43fb9f6f79840c61623ffed52,环境为 CANNLab A3(dav-2201)、CANN 9.1.0:n/tile=48/16、65/32、65/48、65/80、257/80、4913/4912,另有 FP32 无穷对照;涵盖同号/异号无穷、NaN、有限值与尾块。git diff --check通过;最终 HEAD 的本地 pre-commit / OAT 检查日志已保留。本地 OAT hook 要求的 Invalid File Type / License Header Invalid 均为 0。独立重新扫描的原始 OAT 退出码为 1,另报版权规则告警:默认 policy 接受 Huawei Device,而本仓文件使用 Huawei Technologies;上游原文件也复现该告警。已保留完整报告,未修改版权归属或扫描规则;远端 OAT/SCA 结果仍由社区门禁确认。
上述 NPU 验证运行本 PR 的生产 kernel 头文件;尚未运行完整 ACLNN/C API 自定义算子包调度,也未声称完成全仓、全部广播形态或其他架构回归。此次 CPU/NPU 结果与社区 CI、CodeCheck、SCA 门禁相互独立,当前 HEAD 的远端门禁仍需检查和处理。
本轮原始退出码、完整日志、运行脚本与 source manifest 已归档;生产头文件 SHA256 为
00b728810eb8174b9eb9ed339ebd0b2e10b21fbae1c13582c50394c122879229。文档更新
无接口或 README 约束变更。
类型标签