Commit 4042af0
Extract transformer-core: NN primitives reusable on all targets incl. androidNative
llm-core's transformer primitives (KV-cache family, MultiHeadAttention, Embedding,
RMSNormalization, RoPE, SwiGLU/GeGLU FFN, ResidualAdd, LinearProjection, …) only need
skainet-lang-core (which has androidNative), but were trapped in llm-core, whose other
deps (io-gguf/io-core/compile-*/backend-cpu) have no androidNative — so ARM-native
consumers (the Amlogic box) couldn't reuse them and had to reimplement.
Move the 15 lang-core-only NN files (transformer/, layers/, normalization/,
dsl/TransformerDsl.kt) into a new transformer-core module that depends ONLY on
skainet-lang-core and declares the full matrix INCLUDING androidNativeArm32/Arm64.
llm-core api-depends on transformer-core (re-exports), so existing consumers are
unaffected. dsl/decoder/* stays in llm-core (DecoderTransformerNetwork needs
apps.llm.HybridTransformerBlock, which is compile-opt-coupled).
Decoupled the one back-reference: MultiHeadAttention's diagnostic dumpStats call now
goes through a settable `mhaStatSink` (default no-op) that HybridTransformerBlock wires
to llm-core's platform dumpStats — no functionality lost.
Verified: transformer-core compiles for jvm + androidNativeArm32 + arm64; llm-core
builds + jvmTest green (5/5).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 9f4dde7 commit 4042af0
19 files changed
Lines changed: 58 additions & 3 deletions
File tree
- llm-core
- src/commonMain/kotlin/sk/ainet/apps/llm
- transformer-core
- src/commonMain/kotlin/sk/ainet/lang/nn
- dsl
- layers
- normalization
- transformer
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
171 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
172 | 176 | | |
173 | 177 | | |
174 | 178 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
0 commit comments