Skip to content

examples: legacy example/MnistExperiment.c no longer compiles (stale layer-init API, CI-invisible) #235

Description

@LeoBuron

Summary

example/MnistExperiment.c no longer compiles against the current layer-init API. It is added to the build unconditionally (add_subdirectory(example) in CMakeLists.txt), but no CI job ever builds it, so the breakage is invisible and can rot indefinitely.

Reproduce

cmake --preset examples
cmake --build --preset examples          # builds the default `all` target

Fails with:

example/MnistExperiment.c:134:48: error: too many arguments to function call, expected 2, have 6
example/MnistExperiment.c:137:33: error: too many arguments to function call, expected single argument 'lq', have 2 arguments
example/MnistExperiment.c:154:48: error: too many arguments to function call, expected 2, have 6
example/MnistExperiment.c:157:36: error: too many arguments to function call, expected single argument 'lq', have 2 arguments

Root cause

The layer constructors were refactored; the old names now take the new init/quant structs, and the previous signatures were renamed to *Legacy:

MnistExperiment.c calls Current API (src/userApi/layer/include/…)
linearLayerInit(weight0, bias0, q, q, q, q) linearLayerInit(linearInit_t*, layerQuant_t*) — old form is now linearLayerInitLegacy(...)
reluLayerInit(q, q) reluLayerInit(layerQuant_t*) — old form is now reluLayerInitLegacy(...)

MnistExperiment.c was never migrated (last touched 2026-05-06, d3d9615, predating the refactor). It also still uses the deprecated tensorInitWithDistribution / tensorInitInt32 family (see #182).

Why CI doesn't catch it

  • unit_test* build presets target all_unit_tests, not all → they never build example/.
  • The examples CI job builds only --target train_c_har_classifier_v2 and --target train_c_ecg_anomaly_ae_v2, never the default all.

So the only way to hit it is a local cmake --build --preset examples with no --target.

Disposition (needs a decision)

examples/ (plural) has HAR and ECG demos but no MNIST, so this is the only standalone MNIST training example — deleting it drops MNIST end-to-end example coverage (the UnitTestMnistSmoke unit test would remain).

Options:

  1. Migrate MnistExperiment.c to the current linearInit_t / layerQuant_t API (and the non-deprecated tensor-init calls), ideally folding it into the examples/ infra with a _shared-based harness like the HAR/ECG demos.
  2. Delete example/ (singular) — accept losing the MNIST example; rely on examples/ as the canonical example location.
  3. Stopgap: mark the target EXCLUDE_FROM_ALL (or gate add_subdirectory(example) behind a flag) so --build --preset examples stops failing, while leaving the migrate/delete decision for later.

Regardless of choice, consider having CI build the examples preset's default all (or whatever targets are meant to be supported) so a future example can't silently rot the same way.

Found while verifying the documented build presets.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions