Running neural networks in a custom kernel
Context
I copied my neural network code into the nirOS directory.
Goal
- integrate the NN code into the kernel build
- remove userspace and STL dependencies that do not belong in a freestanding kernel context
- make math, allocation, randomness, and data loading work with kernel-safe paths
Environment
nirOSsource treeGNUmakefilebased build- freestanding C / C++ kernel build rules
- kernel libc support files and headers
- TarFS-backed file access for dataset loading
The Final State
The neural network sources now have kernel-oriented build and runtime shims in place instead of depending on ordinary userspace facilities.
What Changed
- copied NN code into the
nirOSdirectory - added
CPPFILESdiscovery and.cppobjects / deps inGNUmakefile - added NN include path to
CPPFLAGSinGNUmakefile - added or kept a kernel-safe
.cppcompile rule with-fno-exceptions -fno-rttiplus freestanding-safe extras - added a
math.cspecial compile path to avoid-mgeneral-regs-onlyfor floating-point code - added kernel libc support files
- added C++-safe
extern "C"guards in libc headers - updated the NN shim to use kernel libc math and allocation
- replaced STL RNG with
xorshift32plus Box-Muller - updated dense-layer init to use kernel-safe RNG and math with no
<random>or<cmath> - rewrote the CSV loader to use TarFS plus raw buffer parsing with no
std::string,ifstream, or STL - added
tarfs_open/tarfs_readAPI and used it in the CSV path
Verification
Current proof captured in this note is structural only:
- the build system changes are listed
- kernel-safe math, allocation, RNG, and file access replacements were added
- this note does not yet include a successful build log, boot log, or runtime inference output
Failure Modes Worth Caring About
- userspace or STL dependencies getting reintroduced into freestanding kernel code
- compile flags that silently break floating-point or C++ integration in kernel space
- TarFS parsing behaviour diverging from the original userspace CSV loader
- allocator or math shim behaviour differing enough to invalidate model assumptions