Files
whisper.cpp/examples/whisper.android.java/app
Spencer BryngelsonandDaniel Bevenius 4afa009405 whisper : optional ANEForge encoder backend (Apple Neural Engine) (#3905)
* whisper : optional ANEForge encoder backend (Apple Neural Engine)

Runs the Whisper encoder directly on the Apple Neural Engine via ANEForge, an
alternative to the CoreML encoder backend. About 2x faster than the CoreML encoder
and faster than the Metal GPU encoder on M-series, at ~5x lower energy, with the
same transcripts (cosine 0.999 vs the reference encoder).

Mirrors the existing CoreML/OpenVINO seam: fills embd_enc from the external aneforge
package via the same whisper_encode_external path, gated at runtime by the
ANEFORGE_ENCODER env var. With the variable unset the build behaves exactly like
stock whisper.cpp (the backend dlopens its dispatch dylib only when enabled, no new
link-time dependency). Encoder only; the decoder is untouched.

Adds src/aneforge/whisper-aneforge.{h,cpp}, one line to src/CMakeLists.txt, and ~30
lines to src/whisper.cpp (include, state field, encode branch, init, free).

* aneforge: one statement per line, align dlsym block (review)

* aneforge: guard the backend to Apple Silicon, stub elsewhere (fix non-Apple CI)

whisper-aneforge.cpp uses <dlfcn.h> and __fp16, which are unavailable on Windows
(MSVC) and non-ARM Linux, so the unconditional build broke those CI jobs. Wrap the
real implementation in #if defined(__APPLE__) && defined(__aarch64__) and provide
no-op stubs elsewhere; the encoder is Apple-Neural-Engine-only anyway, and the
library now links on every platform.

* examples : include whisper-aneforge.cpp in android examples

Refs: https://github.com/ggml-org/whisper.cpp/actions/runs/32758607709/job/97689705921?pr=3905#step:5:200

* ci : specify explicit packages (platform-tools)

This commit updates the android jobs to specify platform-tools as an
explicit package.

The motivation for this to try to fix the Setup Android SDK step which
is also trying to install an obolete tools package.

Refs: https://github.com/ggml-org/whisper.cpp/actions/runs/35215042978/job/105181619536?pr=3905

---------

Co-authored-by: Daniel Bevenius <daniel.bevenius@gmail.com>
2026-09-18 06:18:56 +02:00
..