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
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+18Lines changed: 18 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -357,3 +357,21 @@ To add a new operation family, for example `foo`:
357
357
7.__Cross-platform tests__: add entries to `test/test_cross.hpp` and the relevant `test_cross_*.cpp` files.
358
358
8.__CMakeLists.txt__: wire the new source files into the `nk_test` and `nk_bench` targets.
359
359
9.__Language bindings__: update `python/numkong.c`, `javascript/numkong.c`, `rust/numkong.rs`, etc. as needed.
360
+
361
+
## Adding a Backend Kernel to an Existing Family
362
+
363
+
For primary kernels, every backend implementation should be wired in five places beyond the backend header itself:
364
+
365
+
1.__Forward declaration__: add the `NK_PUBLIC` declaration with the matching `@copydoc` in the first half of `include/numkong/<family>.h`.
366
+
2.__Compile-time dispatch__: add the `#if !NK_DYNAMIC_DISPATCH` branch in the second half of `include/numkong/<family>.h`.
367
+
3.__Run-time dispatch__: add the dtype-specific entry to the relevant `c/dispatch_*.c` table.
368
+
4.__Precision tests__: register the kernel in `nk_test`, usually in the existing `test/test_<family>.cpp` suite.
369
+
5.__Benchmarks__: register the kernel in `nk_bench`, usually in the existing `bench/bench_<family>.cpp` suite.
370
+
371
+
Use the existing family suite unless the kernel introduces a genuinely new test shape.
372
+
The rule is about coverage and reachability, not about creating a brand new source file for every symbol.
373
+
374
+
There are two intentional exceptions:
375
+
376
+
-`cast`: the family-level `nk_cast_*` kernels follow the same header/dispatch/test/bench rule, but scalar conversion helpers are wired through `c/dispatch_other.c` and are covered through `test/test_cast.cpp` and `bench/bench_cast.cpp`.
377
+
-`scalar`: scalar helpers are centrally declared in `include/numkong/scalar.h`, wired through `c/dispatch_other.c`, and currently do not follow the per-helper `nk_test` and `nk_bench` registration pattern.
0 commit comments