You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 49647b7
Browse filesBrowse the repository at this point in the historyBrowse files
peng.li24
committed
feat: add cbrt, expm1, log1p — bit-exact with numpy via SVML bridge
SVML bridge auto-dispatches __svml_cbrt8/__svml_expm18/__svml_log1p8
on AVX-512, or falls back to dlsym npy_* scalars otherwise. Same
pattern as exp/log/sin/cos/etc.
- svml_bridge.h: SVML + npy_* fallback + dispatchers + svml_impl
- core.h: cbrt/expm1/log1p array functions (NUMPY_UNROLL4)
- pycpp: DEF_ELEMWISE wrappers
- tests: 24 new tests (3 funcs × 4 sizes × 2 dtypes)
- test count: 476 → 500
- Makefile: -fno-builtin-cbrt -fno-builtin-expm1 -fno-builtin-log1p
Verified: 0/100000 random diffs for all 3 funcs in f64 and f32.
Copy file name to clipboardExpand all lines: README.md
+9-7Lines changed: 9 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ We created `numpycpp` to keep NumPy's familiar usage patterns while letting C++
15
15
16
16
`numpycpp` is a **header-only C++ library** implementing numpy's core API (`numpy.*`, `numpy.linalg.*`, `numpy.einsum`) with **bit-level precision alignment**. Raw pointer + size interface. Zero external dependencies — pure C++17 standard library.
17
17
18
-
All APIs are tested against Python numpy under strict bit-level comparison: every IEEE 754 float bit must match exactly (476 tests, float64 + float32).
18
+
All APIs are tested against Python numpy under strict bit-level comparison: every IEEE 754 float bit must match exactly (500 tests, float64 + float32).
19
19
20
20
**Bit-exact math** is achieved by resolving numpy's own math functions from `_multiarray_umath.so` at runtime. The SVML bridge auto-detects your CPU and selects the same path numpy uses: AVX‑512 SVML (`__svml_exp8`) when available, or scalar `npy_exp`/`npy_log`/etc. otherwise. AVX‑512 intrinsics are isolated behind `__attribute__((target))` — the binary is safe on any x86_64 CPU (no SIGILL). Every transcendental function produces the exact same IEEE 754 bits as numpy on **all architectures**.
21
21
@@ -89,12 +89,12 @@ Add `-Ipath/to/numpycpp` to your compiler flags and include the headers directly
89
89
### Testing
90
90
91
91
The test suite verifies **bit-level precision alignment** between every C++ function and Python numpy.
92
-
No tolerance, no `atol`/`rtol` — raw IEEE 754 bits must match exactly. 476 tests, float64 + float32.
92
+
No tolerance, no `atol`/`rtol` — raw IEEE 754 bits must match exactly. 500 tests, float64 + float32.
93
93
94
94
```bash
95
95
cd tests
96
96
make # compile C++ test module
97
-
make test# run all 476 tests (silent mode: only failures print)
97
+
make test# run all 500 tests (silent mode: only failures print)
0 commit comments