Commit 5dbf32b
peng.li24
fix: normalize log domain-error NaN to +qNaN; align einsum vs-matmul tests
Two remaining CI failures (numpy 1.26.4, non-AVX512 runner):
1. test_domain_log_neg [float64]
npy_log(-x) returns 0xfff8000000000000 (negative qNaN);
numpy 1.26.4 ufunc returns 0x7ff8000000000000 (positive qNaN).
Fix: add custom log_f64() in svml_bridge.h that normalises any
domain-error NaN (isnan(r) && !isnan(x)) to positive qNaN via memcpy,
matching numpy's canonical NaN convention.
2. test_vs_matmul / test_vs_batch_matmul
np.einsum('ij,jk->ik') uses numpy's SSE forward mul+add kernel;
numpy.matmul / a @ b uses BLAS (cblas_sgemm). They can differ by
±1 ULP for arbitrary inputs — the two tests were comparing against
the wrong reference (a @ b instead of np.einsum).
Fix: compare cpp.einsum result against np.einsum (same path as
test_random, which already passes), not against matmul.1 parent 1fbc40d commit 5dbf32b
2 files changed
Lines changed: 30 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
291 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
292 | 309 | | |
293 | 310 | | |
294 | 311 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1063 | 1063 | | |
1064 | 1064 | | |
1065 | 1065 | | |
1066 | | - | |
1067 | | - | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
1068 | 1072 | | |
1069 | 1073 | | |
1070 | 1074 | | |
| |||
1086 | 1090 | | |
1087 | 1091 | | |
1088 | 1092 | | |
1089 | | - | |
1090 | | - | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
1091 | 1099 | | |
1092 | 1100 | | |
1093 | 1101 | | |
| |||
0 commit comments