Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions skainet-backends/skainet-backend-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ kotlin {
linuxX64()
linuxArm64()

// Android-native targets, for on-device consumers that link the engine directly
// (SKaiNET-transformers builds gemma-iree for androidNativeArm32). Unlike
// skainet-io-core this module has no posix-typed code, so arm32's Int-width
// ssize_t/size_t needs no separate 64-bit source set here.
androidNativeArm64()
androidNativeArm32()

jvm()

js {
Expand Down Expand Up @@ -102,5 +109,16 @@ kotlin {
val linuxArm64Main by getting {
dependsOn(linuxMain)
}

// Straight onto nativeMain rather than linuxMain: Android's native targets are
// Linux-based, but linuxMain is free to grow glibc-specific code that bionic would
// not carry. nativeMain holds what actually applies to both.
val androidNativeArm64Main by getting {
dependsOn(nativeMain)
}

val androidNativeArm32Main by getting {
dependsOn(nativeMain)
}
}
}
6 changes: 6 additions & 0 deletions skainet-backends/skainet-backend-cpu/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ kotlin {
linuxX64Main { dependsOn(linuxMain.get()) }
linuxArm64Main { dependsOn(linuxMain.get()) }

// See PlatformCpuOpsFactory.androidNative.kt for why these hang off nativeMain and
// not linuxMain.
androidNativeMain { dependsOn(nativeMain.get()) }
androidNativeArm32Main { dependsOn(androidNativeMain.get()) }
androidNativeArm64Main { dependsOn(androidNativeMain.get()) }

// Golden (bit-identical) regression tests for the packed encodings — SKEEP-003 gate.
// Shared by the JVM and Kotlin/Native test targets only: JS/Wasm compute Float in
// double precision and are not expected to be bit-identical (they are covered by the
Expand Down
6 changes: 5 additions & 1 deletion skainet-backends/skainet-backend-cpu/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
POM_ARTIFACT_ID=skainet-backend-cpu
POM_NAME=skainet neural network scripting API

kotlin.mpp.applyDefaultHierarchyTemplate=false
kotlin.mpp.applyDefaultHierarchyTemplate=false

# Adds androidNativeArm32/Arm64. On-device consumers link the eager CPU backend directly,
# so it has to publish the same targets skainet-lang-core and skainet-io-core already do.
skainet.targets=jvm,js,wasmJs,wasmWasi,apple,linux,androidNative
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package sk.ainet.exec.tensor.ops

import sk.ainet.backend.api.kernel.KernelRegistry
import sk.ainet.exec.kernel.ScalarKernelProvider
import sk.ainet.lang.tensor.data.TensorDataFactory
import sk.ainet.lang.tensor.ops.TensorOps

/**
* Android's native targets get the same portable factory the Linux one uses, and for the same
* reason: `DirectCpuExecutionContext` is pure Kotlin here, with no cinterop of its own.
*
* It is a copy rather than a `dependsOn(linuxMain)` on purpose. Android native is Linux-based,
* but it is bionic, not glibc — `linuxMain` is free to grow code that assumes the latter, and
* inheriting that silently is worse than the six duplicated lines below. The accelerated
* kernels for these targets live in `skainet-backend-native-cpu`, not here.
*/
internal actual fun platformDefaultCpuOpsFactory(): (TensorDataFactory) -> TensorOps {
// Non-JVM has no ServiceLoader; register the scalar packed-quant kernels
// (Q4_K/Q6_K/Q5_1/Q5_0/Q8_0/Q4_0) so DefaultCpuOpsBase can dispatch them.
KernelRegistry.register(ScalarKernelProvider)
return { factory -> DefaultCpuOps(factory) }
}
7 changes: 7 additions & 0 deletions skainet-compile/skainet-compile-dag/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ kotlin {
linuxX64 ()
linuxArm64 ()

// Android-native targets, for on-device consumers that link the engine directly
// (SKaiNET-transformers builds gemma-iree for androidNativeArm32). Unlike
// skainet-io-core this module has no posix-typed code, so arm32's Int-width
// ssize_t/size_t needs no separate 64-bit source set here.
androidNativeArm64()
androidNativeArm32()

jvm()

js {
Expand Down
5 changes: 5 additions & 0 deletions skainet-compile/skainet-compile-json/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ kotlin {
linuxX64()
linuxArm64()

// Android-native targets, to match the modules this one is compiled against: skainet-backend-cpu
// publishes them, and its commonTest depends on this module, so the target set has to close.
androidNativeArm64()
androidNativeArm32()

jvm()

js {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package sk.ainet.compile.json

import sk.ainet.compile.json.model.SkJsonExport

/**
* One file for both `androidNativeArm32` and `androidNativeArm64` — the default hierarchy
* template groups them under `androidNativeMain`, so this does not need the per-target
* duplication the other native actuals here carry.
*/
public actual suspend fun writeExportToFile(export: SkJsonExport, path: String, pretty: Boolean) {
throw NotImplementedError("writeExportToFile is not implemented for Android native in this module. Use toJsonString() and handle file I/O in the host app.")
}
7 changes: 7 additions & 0 deletions skainet-compile/skainet-compile-opt/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ kotlin {
linuxX64 ()
linuxArm64 ()

// Android-native targets, for on-device consumers that link the engine directly
// (SKaiNET-transformers builds gemma-iree for androidNativeArm32). Unlike
// skainet-io-core this module has no posix-typed code, so arm32's Int-width
// ssize_t/size_t needs no separate 64-bit source set here.
androidNativeArm64()
androidNativeArm32()

jvm()

js {
Expand Down
7 changes: 7 additions & 0 deletions skainet-io/skainet-io-gguf/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ kotlin {
linuxX64 ()
linuxArm64 ()

// Android-native targets, for on-device consumers that link the engine directly
// (SKaiNET-transformers builds gemma-iree for androidNativeArm32). Unlike
// skainet-io-core this module has no posix-typed code, so arm32's Int-width
// ssize_t/size_t needs no separate 64-bit source set here.
androidNativeArm64()
androidNativeArm32()

js {
browser()
}
Expand Down
7 changes: 7 additions & 0 deletions skainet-lang/skainet-lang-dag/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ kotlin {
linuxX64()
linuxArm64()

// Android-native targets, for on-device consumers that link the engine directly
// (SKaiNET-transformers builds gemma-iree for androidNativeArm32). Unlike
// skainet-io-core this module has no posix-typed code, so arm32's Int-width
// ssize_t/size_t needs no separate 64-bit source set here.
androidNativeArm64()
androidNativeArm32()

jvm()

js {
Expand Down
5 changes: 5 additions & 0 deletions skainet-lang/skainet-lang-models/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ kotlin {
linuxX64()
linuxArm64()

// Android-native targets, to match the modules this one is compiled against: skainet-backend-cpu
// publishes them, and its commonTest depends on this module, so the target set has to close.
androidNativeArm64()
androidNativeArm32()

jvm()

js {
Expand Down
Loading