Merged
fix: 修复 foreach_div_list_inplace 非规格数操作数除法被误算为 Inf 的问题 #14143
SunAdd on 11 days ago
fix: 修复 foreach_div_list_inplace 非规格数操作数除法被误算为 Inf 的问题 #14143
Merged
Merged fromLuckySun/ops-nndiv_assistintocann/ops-nnmaster
Total: 1 files changed+6-5
| @@ -23,11 +23,12 @@ using namespace AscendC; | |||
| 23 | // (实测 8.3% 的元素偏 1 ULP);竞品 fp32 除法是 0 ULP 正确舍入,cross_check 的 rmse | 23 | // (实测 8.3% 的元素偏 1 ULP);竞品 fp32 除法是 0 ULP 正确舍入,cross_check 的 rmse |
| 24 | // 比值因此在大量级输出上被抬高。显式选 0 ULP 档与竞品对齐。 | 24 | // 比值因此在大量级输出上被抬高。显式选 0 ULP 档与竞品对齐。 |
| 25 | // | 25 | // |
| 26 | -// 取 FTZ_TRUE 而非仓内他处常见的 FTZ_FALSE:两档精度实测完全相同(全泛化集 34/34 PASS, | 26 | +// 显式选 PRECISION_0ULP_FTZ_FALSE:完整 IEEE 语义,非规格数操作数与结果均正确处理。 |
| 27 | -// 网络级用例 3126 万元素均 100% 偏 0 ULP),但 FTZ_FALSE 的非规格数完整处理代价极大—— | 27 | +// 此前为性能取 FTZ_TRUE,但 FTZ_TRUE 会把 fp32 **非规格数操作数**冲零(正常/非规格 -> |
| 28 | -// 同条件 --run 12 实测 218.7us -> 2028.1us(9.3x)。本算子输入域内不产生 fp32 非规格数 | 28 | +// x/0 = ±inf);此时真商往往仍是 float32可表示的有限值(如 2.5e38), |
| 29 | -// (最小 |商| 远大于 1.18e-38),故取快档。若后续需覆盖非规格数商,再评估换 FTZ_FALSE。 | 29 | +// 却被算成 ±inf,cross_check 判 "NaN/Inf mismatch" |
| 30 | -static constexpr DivConfig DIV_PRECISE = {DivAlgo::PRECISION_0ULP_FTZ_TRUE}; | 30 | +// FTZ_FALSE 消除该偏差;代价是性能,属 IEEE 语义与性能的取舍。 |
| 31 | +static constexpr DivConfig DIV_PRECISE = {DivAlgo::PRECISION_0ULP_FTZ_FALSE}; | ||
| 31 | // In-place foreach div-list: y(=x1) = x1 * x2. Reuses the shared ForeachRegbaseBinary base | 32 | // In-place foreach div-list: y(=x1) = x1 * x2. Reuses the shared ForeachRegbaseBinary base |
| 32 | // (two input tensor lists); the apt entry feeds x1 as both the first input and the output. | 33 | // (two input tensor lists); the apt entry feeds x1 as both the first input and the output. |
| 33 | template <typename T, typename Tiling> | 34 | template <typename T, typename Tiling> |