Skip to content

Commit 635ef2a

Browse files
author
peng.li24
committed
refactor: move internal headers to numpy/detail/
Create numpy/detail/ subdirectory so the directory layout itself enforces the public/internal API boundary — no navigating is needed to know what is off-limits to external callers. Files moved (git mv): numpy/npy_math_float.h → numpy/detail/npy_math_float.h numpy/svml_bridge.h → numpy/detail/svml_bridge.h numpy/blas_bridge.h → numpy/detail/blas_bridge.h numpy/avx512_loops.h → numpy/detail/avx512_loops.h Include paths updated: core.h: "svml_bridge.h" → "detail/svml_bridge.h" (and blas, avx512) svml_bridge.h: "npy_math_float.h" unchanged (same directory) Box-comment wrong-path examples updated to show new paths (e.g. ✗ #include "numpy/detail/svml_bridge.h" ← compile error) Installed layout (dpkg -L numpycpp-dev): /usr/include/numpycpp/numpy/core.h ← public /usr/include/numpycpp/numpy/linalg.h ← public /usr/include/numpycpp/numpy/einsum.h ← public /usr/include/numpycpp/numpy/detail/*.h ← all internal, locked 754 tests pass, 0 regressions.
1 parent aaa6322 commit 635ef2a

5 files changed

Lines changed: 12 additions & 12 deletions

File tree

numpy/core.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
//
1010
// The four internal headers pulled in below are LOCKED behind
1111
// NUMPYCPP_INTERNAL_INCLUDE and will cause a #error if included directly:
12-
// • svml_bridge.h — SVML/npy scalar bridge (x86_64 + Linux)
13-
// • blas_bridge.h — OpenBLAS ILP64 bridge (x86_64 + Linux)
14-
// • npy_math_float.h— float32 poly kernels (numpy internal constants)
15-
// • avx512_loops.h — AVX-512 specializations (requires AVX-512F CPU)
12+
//detail/svml_bridge.h — SVML/npy scalar bridge (x86_64 + Linux)
13+
//detail/blas_bridge.h — OpenBLAS ILP64 bridge (x86_64 + Linux)
14+
//detail/npy_math_float.h — float32 poly kernels (numpy internal constants)
15+
//detail/avx512_loops.h — AVX-512 specializations (requires AVX-512F CPU)
1616
//
1717
// All functions operate on raw pointers + sizes.
1818
// Each function is annotated with its Python numpy equivalent,
@@ -41,9 +41,9 @@
4141
// The macro below is the compile-time lock; it is #undef-ed at the end of this
4242
// file so it cannot "leak" into translation units that include core.h.
4343
#define NUMPYCPP_INTERNAL_INCLUDE
44-
#include "svml_bridge.h" // numpy::detail::{exp,log,sin,...}_f32/f64 — SVML/npy
45-
#include "blas_bridge.h" // numpy::detail::blas_ops<T> — OpenBLAS ILP64
46-
// avx512_loops.h included at namespace-close (line ~1004), also guarded.
44+
#include "detail/svml_bridge.h" // numpy::detail::{exp,log,sin,...}_f32/f64
45+
#include "detail/blas_bridge.h" // numpy::detail::blas_ops<T> — OpenBLAS ILP64
46+
// detail/avx512_loops.h included at namespace-close below, also guarded.
4747

4848
namespace numpy {
4949

@@ -1021,7 +1021,7 @@ inline void norm_axis(const T* src, T* dst, const ptrdiff_t* shape, int ndim, in
10211021
// AVX-512 wide-loop template specializations (0 ULP, ~8-16x faster than scalar)
10221022
// Must be included inside namespace numpy after all primary templates.
10231023
// ============================================================================
1024-
#include "avx512_loops.h"
1024+
#include "detail/avx512_loops.h"
10251025

10261026
// Release the internal-include lock so it does not pollute the includer's TU.
10271027
#undef NUMPYCPP_INTERNAL_INCLUDE
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// ║ generic loops in core.h. It is x86_64 + AVX-512F specific and must ║
66
// ║ be included INSIDE namespace numpy at the end of core.h — nowhere else.║
77
// ║ ║
8-
// ║ ✗ #include "numpy/avx512_loops.h" ← compile error ║
8+
// ║ ✗ #include "numpy/detail/avx512_loops.h" ← compile error ║
99
// ║ ✓ #include "numpy/core.h" ← only correct entry point ║
1010
// ╚══════════════════════════════════════════════════════════════════════════╝
1111
//
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// ║ All symbols live in numpy::detail — an implementation namespace that ║
66
// ║ external code must never reference. ║
77
// ║ ║
8-
// ║ ✗ #include "numpy/blas_bridge.h" ← compile error ║
8+
// ║ ✗ #include "numpy/detail/blas_bridge.h" ← compile error ║
99
// ║ ✗ numpy::detail::blas_sdot(...) ← undefined behaviour ║
1010
// ║ ✓ #include "numpy/core.h" ← only correct entry point ║
1111
// ║ ✓ numpy::dot(a, b, n) ← public API ║
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// ║ are tied to numpy's internal SIMD constants. The API is UNSTABLE and ║
66
// ║ subject to change without notice. ║
77
// ║ ║
8-
// ║ ✗ #include "numpy/npy_math_float.h" ← compile error ║
8+
// ║ ✗ #include "numpy/detail/npy_math_float.h" ← compile error ║
99
// ║ ✓ #include "numpy/core.h" ← only correct entry point ║
1010
// ╚══════════════════════════════════════════════════════════════════════════╝
1111

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// ║ All symbols live in numpy::detail — an implementation namespace that ║
77
// ║ external code must never reference. ║
88
// ║ ║
9-
// ║ ✗ #include "numpy/svml_bridge.h" ← compile error ║
9+
// ║ ✗ #include "numpy/detail/svml_bridge.h" ← compile error ║
1010
// ║ ✗ numpy::detail::exp_svml_f64(x) ← undefined behaviour ║
1111
// ║ ✓ #include "numpy/core.h" ← only correct entry point ║
1212
// ║ ✓ numpy::exp(src, dst, n) ← public API ║

0 commit comments

Comments
 (0)