Commit 8e45c51
peng.li24
feat: add comprehensive special-value tests + fix NaN/signed-zero in all AVX-512 paths
- avx512_loops.h: add explicit NaN passthrough blend to exp<f32>, sin<f32>, cos<f32>
after polynomial computation, guaranteeing same NaN bit pattern as numpy's
scalar npy_expf / npy_sinf / npy_cosf (which return x unchanged for NaN input)
- svml_bridge.h: fix sin(±0)=±0 for both f32 and f64 scalar paths
* sin_f32(): npy_sinf polynomial fma(sp,r,r) with r=±0 gives +0 by IEEE 754 RN
* sin_f64(): SVML broadcast scalar path __svml_sin8(-0) returns +0
Both fixed with cheap branch: if (x==0 && r==0) return x
- test_all.py section 16 – 206 new bit-exact special-value tests:
* NaN passthrough: all 21 unary math functions × f32/f64 × sizes 1,16,17
* Mixed NaN/finite (17 elements): NaN must not corrupt neighbours in SIMD path
* Signed zero: sin(±0)=±0, cos(±0)=1, log(-0)=-inf, exp(±0)=1
* Infinity: exp(±inf), log(+inf), sqrt(+inf), sin/cos(±inf)→NaN
* Domain errors: log(neg), sqrt(neg), arcsin/arccos(|x|>1) → NaN bit-exact
* sign(NaN)=NaN, sign(±inf)=±1, sign(±0)=0
* unwrap NaN propagation (mid, leading, all-NaN)
* linalg: norm/dot with NaN or Inf inputs
* AVX-512 boundary sizes 15/16/17/32 for exp/log/sin/cos
- test_all.py check_bit_aligned: upgraded to uint-view bit comparison for float
arrays with matching dtype so NaN==NaN passes at bit level; dtype-mismatch
case (C++ returns float64 for float32 input) falls back to numeric equality1 parent 55fb054 commit 8e45c51
3 files changed
Lines changed: 370 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
203 | 208 | | |
204 | 209 | | |
205 | 210 | | |
| |||
366 | 371 | | |
367 | 372 | | |
368 | 373 | | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
369 | 378 | | |
370 | 379 | | |
371 | | - | |
| 380 | + | |
| 381 | + | |
372 | 382 | | |
373 | 383 | | |
374 | 384 | | |
| |||
434 | 444 | | |
435 | 445 | | |
436 | 446 | | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
437 | 450 | | |
438 | 451 | | |
439 | 452 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
277 | | - | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
278 | 284 | | |
279 | 285 | | |
280 | 286 | | |
| |||
301 | 307 | | |
302 | 308 | | |
303 | 309 | | |
304 | | - | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
305 | 317 | | |
306 | 318 | | |
307 | 319 | | |
| |||
0 commit comments