Pull Request已成功合入, 合并人@CANN-robot
(感谢 m0_73979701 的贡献)变更摘要
本 PR 修复 Asinh 在中大数值区间的精度问题(math/asinh/op_kernel/arch35/asinh.h 中的 ComputeFp32Pipeline 实现)。原实现对所有非小值统一采用 log(u) * r / (u - 1) 补偿,会在中大数值区间额外引入约 1~2 ULP 误差;本次改动按输入绝对值 |x| 分段处理,并新增 CONST_DIRECT_LOG_THRESHOLD = 10.0f 与 CONST_ASYMPTOTIC_THRESHOLD = 268435456.0f(2^28)两个常量作为分段阈值,同时保留 NaN 传播语义。
主要改动
-
新增分段阈值常量:在
asinh.h中新增CONST_DIRECT_LOG_THRESHOLD = 10.0f(中大参数直接使用log(u))与CONST_ASYMPTOTIC_THRESHOLD = 268435456.0f(2^28,以上使用渐近式),用于区分三种处理区间。 -
Step 15 中值区间直接保留
log(u):对10 <= |x| < 2^28,通过CompareScalar+Select将分子r与分母b同时置为CONST_ONE,使Mul/Div退化为恒等操作,直接保留 Step 14 的log(u),避免额外乘除引入精度损失;|x| < 10仍走原有log(u) * r / (u - 1)补偿路径。 -
Step 16 分段选择 correction:
|x| < 10保持原有min(res, correction);10 <= |x| < 2^28将 correction 屏蔽为CONST_S_MAX(取min时自然失效);|x| >= 2^28通过Select恢复log(|x|) + ln(2) + 1/|x|^2渐近式,避免u ≈ 2|x|时溢出;correction 临时借用已结束生命周期的bBuf保存。 -
保留 NaN 传播语义:利用「NaN 与自身比较为 false」的特性,通过
Compare(absX, absX, EQ)+Select恢复 NaN 对应的 correction 分支,使 NaN 输入仍沿原有min路径传播。


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.
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 |
|---|---|---|
| math/asinh | ✅ 周奇龙, andong_hw (2/2) | ✅ 周奇龙 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
m0_73979701, thanks for your pull request. All authors of the commits have signed the CLA. 👍


compile


compile


流水线任务触发成功
任务链接 [edd67ab073aa40b199c60f7e666489ac][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_harmony-infer | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910b | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910c | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_A5_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A5_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station_9030_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test | ✅ SUCCESS | ||
| UT_Test_experimental | ✅ SUCCESS | ||
| UT_Test_kernel | ✅ SUCCESS | ||
| PreSmoke_A900 | ✅ SUCCESS | >>>>> | |
| API_Check | ✅ SUCCESS | >>>>> | |
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> |
[2026-08-18 16:51:32] CI执行结束


流水线任务触发成功
任务链接 [1564bd95ee3d4371bf64835c461dc315][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| codecheck_Pr | ✅ SUCCESS | ||
| StaticCheck_codespell | ✅ SUCCESS | ||
| StaticCheck_link_validity | ✅ SUCCESS | ||
| StaticCheck_resource_existence | ✅ SUCCESS | ||
| StaticCheck_tag_closed | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS | ||
| codecheck_precommit | ✅ SUCCESS | >>>>> |
[2026-08-18 16:47:50] CI执行结束


描述
修复 Asinh 在中大数值区间的精度问题。
原有实现对所有非小值统一使用
log(u) * r / (u - 1)补偿;该补偿在中大数值区间会额外引入约 1~2 ULP 误差。本次改动按输入绝对值进行分段处理:|x| < 10:保留原有log1p补偿路径,保证小值精度;10 <= |x| < 2^28:直接保留log(u),避免额外乘除带来的精度损失;|x| >= 2^28:使用log(|x|) + ln(2) + 1 / |x|^2渐近式,避免u ≈ 2|x|溢出;关联的Issue
https://gitcode.com/cann/ops-math/issues/2734
测试
文档更新
无文档更新。
类型标签