Repository navigation
examples/static_net: slots instead of Features/Slot<i>/Store<i>; compare_emlearn and the generators with it - #6
Merged
Merged
Conversation
…ompare_emlearn and the generators with it The values a net reads are the slots of a state (hapi/slots.h), read by tag: Field<Tag,&S::m> for a field, Elem<Tag,&S::arr,k> for an element of an array field. No hand-typed slot index is left: inputs are named (the Banknote features by their dataset names; a 60-band input is one array field), cells stay pure proc(in), and a value that survives a pass is a register, a layer of the state whose step evaluates cells on the previous state (registers.h). Two registers that read each other are now right. compare_emlearn/ and its generator follow in the same change (gen_models.py names the four features once, writes BNC_COL_* and typed sources), and so do train/bn2x.c and gen_lin_sonar.py, which emit the named forms directly. bnc_table.h and the emlearn models stay positional: they are the hand-indexed comparison points. Against this example as it was at 18b8d77: the 12 host programs of check/ print the same bytes, the flashed image of 21 AVR programs is byte-identical, src/main.cpp prints the same, compare_emlearn measures the same on the simulated ATmega328p. check/build.sh: 65 ok (61 as before, plus the register checks). tests/single_header/run.sh: 36 ok. From R&D/HAPI/typedState @ 2a40b60. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This was referenced Sep 30, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
examples/static_neton the slot core merged in #5 (hapi/slots.h). The values a net reads are now the slots of a state, read by tag:Field<Tag,&S::m>for a field,Elem<Tag,&S::arr,k>for an element of an array field. No hand-typed slot index is left (the oldFeatures<N>array and itsSlot<i>/Store<i>/x<i>/Wave<n>/In<n>/T<n>are gone): inputs are named (the Banknote features by their dataset names, a 60-band input is one array field), cells stay pureproc(in), and a value that survives a pass is a register, a layer of the state whose step evaluates cells on the previous state (include/registers.h, the example's own contract on the core;update/Store<i>wrote into the array being read, which cannot be right for two registers that read each other).The example uses the HAPI core alone: no names, no hash, no wire format, nothing from another library.
In the same change, so the example is never half-converted:
compare_emlearn/:gen_models.pynames the four features once and writesBNC_COL_*and typed sources; the committedbnc_rows.h,bnc_lin.h,bnc_wave.h,bnc.cppare what it writes.bnc_table.hand the emlearn models stay positional on purpose (they are the hand-indexed comparison points).train/bn2x.candgen_lin_sonar.pyemit the named forms directly, so a retraining cannot reintroduce a positional mapping.Checked, against the example as it is on
main(18b8d77, extracted withgit archive)check/print the same bytes (g++ and clang++, ASan+UBSan);src/main.cppprintsagree 274/274, correct 274/274..text+.data) of 21 AVR programs is byte-identical (27 372 bytes: mixed, refid, sugar, the Sonar cells, roll unrolled/rolled/sparse, the Banknote board program, the simavr bit-exact program, themeasure/programs).check/build.sh: 65 ok, 0 FAIL (the 61 checks it had, sizes unchanged, plus 4 for registers).tests/single_header/run.sh: 36 ok (the converted example's AVR programs and thebncmodels are identical built frominclude/and fromsingle/hapi.h).compare_emlearn:run.shover every model on the simulated ATmega328p regeneratesresults.mdidentical to the committed one;gen_models.py, run (numpy 2.5.3, scikit-learn 1.9.1, emlearn 0.23.2), writes all 22 generated files exactly as committed; the Sonar pipeline and the 8-minutebn2xretraining reproducemodels/sonar/andmodels/banknote/byte for byte.(a,b)' = (b, a+b)in place was wrong on 30 of 30 passes, on the previous state 0 of 30 (check/registers_check.cpp; the same step as a hand-indexed array is the same size,registers_avr.cpp).Not checked
platformio.ini's own environments were not run (thefile://../..dependency copies a whole tree);src/main.cppwas built with the same flags natively and compiled for the Uno against the Arduino core (syntax only). CI does not build this example (GCC/Clang, AVR), so its checks are the ones listed above.🤖 Generated with Claude Code