Add skainet-backend-api module (#468)#470
Merged
michalharakal merged 2 commits intodevelopfrom Apr 13, 2026
Merged
Conversation
Introduces a backend-neutral Gradle module under skainet-backends that `api`-re-exports the tensor op and storage interfaces already living in skainet-lang-core. No Kotlin implementation of its own — it's a re-export layer plus a marker object for tooling. First step in the P0-2 track: concrete backends (today's CPU, future IREE / Metal / NPU) should depend on this module rather than taking a transitive dependency on skainet-backend-cpu just to reach TensorOps / TensorDataFactory / TensorData. Consumer migration is out of scope for this PR and will follow per-module. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
skainet-backend-cpu now depends on the neutral backend-api module alongside its existing direct dependency on skainet-lang-core. Future backends (IREE, Metal, NPU) can follow the same pattern of depending only on backend-api without needing to pull in the CPU module. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
michalharakal
added a commit
that referenced
this pull request
Apr 13, 2026
Captures the goal, phases, non-goals, and risks of implementing a new `skainet-backend-nnapi` module that runs SKaiNET models on an Amlogic Android dev board's NPU via Android's NNAPI HAL. Important placement notes in the PRD itself: - The backend lives in a NEW sibling repo, not in mainline SKaiNET. Mainline stays general and IREE-focused. - The backend builds on top of the already-merged skainet-backend-api module (#470) and the TensorEncoding metadata flow (#471 / #475 / #478) — no mainline code changes are required to ship Phase 1-3. - Orthogonal to SKaiNET-transformers, which owns LLM modules. Phases: 0. Board bring-up + NNAPI device capability dump 1. FP32 dense matmul end-to-end 2. int8 quantization path hitting the NPU driver 3. Target model (MobileNetV3 int8 or TinyLlama candidate) 4. Optional production packaging Also documents the known deprecation risk (Android 15 marked NNAPI deprecated in favor of LiteRT) and captures this as accepted: ship the Amlogic use case now, plan a LiteRT successor later. This file is a planning artifact; it will be moved / referenced from the new backend repo once that repo exists. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
michalharakal
added a commit
that referenced
this pull request
Apr 13, 2026
The neutral backend api module landed in #470 as the integration seam for future backends (IREE, Metal, NPU, the NNAPI-Amlogic sibling repo) but it was never added to the BOM's version- alignment constraints. Java / JVM consumers that depend on the BOM were therefore not getting a pinned version for skainet-backend-api, so anyone referencing the module from a Maven / Gradle project had to either spell out the version manually or drop the BOM reliance for that coordinate. Adding the missing `api(project(":skainet-backends:skainet-backend-api"))` constraint groups it with skainet-backend-cpu under the backend section. BOM still builds clean. First of five commits polishing the Java / JVM consumption story for the upcoming 0.19.0 release. See #400. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Apr 13, 2026
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.
Closes #468.
Summary
Introduces
skainet-backends:skainet-backend-api, a new Gradle module thatapi-re-exports the tensor op and storage interfaces already living inskainet-lang-core(TensorOps,TensorDataFactory,TensorData, …). It owns no Kotlin implementation of its own — it's a re-export layer plus a markerobject BackendApiso tooling and IDE search land on a clear anchor.This is the first step of the P0-2 track in the NPU / IREE roadmap: concrete backends (today's CPU, future IREE / Metal / NPU) should depend on this neutral module rather than taking a transitive dependency on
skainet-backend-cpujust to reach the interfaces they implement.Scoping surfaced a useful fact:
TensorOpsis already correctly placed inskainet-lang-core— no source file moves were needed, so the first step is purely additive.Changes
settings.gradle.kts: includeskainet-backends:skainet-backend-apidirectly beforeskainet-backend-cpu.skainet-backends/skainet-backend-api/build.gradle.kts: new KMP module mirroringskainet-backend-cpu's target set (jvm / android / iosArm64 / iosSimulatorArm64 / macosArm64 / linuxX64 / linuxArm64 / js / wasmJs / wasmWasi) so every current consumer will be able to resolve it on every target once migration starts.skainet-backends/skainet-backend-api/src/commonMain/kotlin/sk/ainet/backend/api/BackendApi.kt: single marker object with a KDoc explaining the module's purpose.skainet-backends/skainet-backend-cpu/build.gradle.kts: adds the new module as a dependency.Out of scope
skainet-compile-*,skainet-io-*,skainet-test-*, apps, models) fromskainet-backend-cpu→skainet-backend-api. That's the follow-up step and will be split into bite-sized per-consumer PRs.TensorOpssource out ofskainet-lang-coreinto this module. Not needed — it's already neutral where it lives.Test plan
./gradlew :skainet-backends:skainet-backend-api:compileKotlinJvm— green./gradlew :skainet-backends:skainet-backend-cpu:compileKotlinJvm— green (cpu now pulls in backend-api transitively)./gradlew :skainet-compile:skainet-compile-hlo:compileKotlinJvm— green (representative downstream consumer; confirms the transitive dependency path still resolves)🤖 Generated with Claude Code