Skip to content

Commit 0491b44

Browse files
committed
Scafold for implementing default CPU backed.
Related-To #137, #146
1 parent 6b227d1 commit 0491b44

12 files changed

Lines changed: 603 additions & 0 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
2+
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
3+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
4+
5+
plugins {
6+
alias(libs.plugins.kotlinMultiplatform)
7+
alias(libs.plugins.androidLibrary)
8+
alias(libs.plugins.vanniktech.mavenPublish)
9+
alias(libs.plugins.kover)
10+
alias(libs.plugins.binary.compatibility.validator)
11+
}
12+
13+
kotlin {
14+
explicitApi()
15+
16+
androidTarget {
17+
@OptIn(ExperimentalKotlinGradlePluginApi::class)
18+
compilerOptions {
19+
jvmTarget.set(JvmTarget.JVM_11)
20+
}
21+
}
22+
23+
iosArm64()
24+
iosSimulatorArm64()
25+
macosArm64 ()
26+
linuxX64 ()
27+
linuxArm64 ()
28+
29+
jvm()
30+
31+
@OptIn(ExperimentalWasmDsl::class)
32+
wasmJs {
33+
browser()
34+
binaries.executable()
35+
}
36+
37+
sourceSets {
38+
commonMain.dependencies {
39+
api(project(":skainet-lang:skainet-lang-core"))
40+
api(project(":skainet-compile:skainet-compile-core"))
41+
implementation(project(":skainet-compile:skainet-compile-dag"))
42+
}
43+
44+
commonTest.dependencies {
45+
implementation(libs.kotlin.test)
46+
}
47+
}
48+
}
49+
50+
android {
51+
namespace = "sk.ai.net.lang.api"
52+
compileSdk = libs.versions.android.compileSdk.get().toInt()
53+
54+
defaultConfig {
55+
minSdk = libs.versions.android.minSdk.get().toInt()
56+
}
57+
compileOptions {
58+
sourceCompatibility = JavaVersion.VERSION_11
59+
targetCompatibility = JavaVersion.VERSION_11
60+
}
61+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
POM_ARTIFACT_ID=skainet-backend-cpu
2+
POM_NAME=skainet neural network scripting API
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package sk.ainet.context
2+
3+
import sk.ainet.context.ExecutionContext
4+
import sk.ainet.lang.tensor.data.TensorDataFactory
5+
import sk.ainet.lang.tensor.ops.TensorOps
6+
import sk.ainet.sk.ainet.exec.tensor.ops.DefaultCpuOps
7+
8+
public class DirectCpuExecutionContext<V> : ExecutionContext<V> {
9+
override val ops: TensorOps<V>
10+
get() = DefaultCpuOps()
11+
override val tensorDataFactory: TensorDataFactory
12+
get() = TODO("Not yet implemented")
13+
}
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
package sk.ainet.sk.ainet.exec.tensor.ops
2+
3+
import sk.ainet.lang.tensor.Shape
4+
import sk.ainet.lang.tensor.Tensor
5+
import sk.ainet.lang.tensor.ops.TensorOps
6+
import sk.ainet.lang.types.DType
7+
8+
public class DefaultCpuOps<V> : TensorOps<V> {
9+
override fun <T : DType> add(
10+
a: Tensor<T, V>,
11+
b: Tensor<T, V>
12+
): Tensor<T, V> {
13+
TODO("Not yet implemented")
14+
}
15+
16+
override fun <T : DType> subtract(
17+
a: Tensor<T, V>,
18+
b: Tensor<T, V>
19+
): Tensor<T, V> {
20+
TODO("Not yet implemented")
21+
}
22+
23+
override fun <T : DType> multiply(
24+
a: Tensor<T, V>,
25+
b: Tensor<T, V>
26+
): Tensor<T, V> {
27+
TODO("Not yet implemented")
28+
}
29+
30+
override fun <T : DType> divide(
31+
a: Tensor<T, V>,
32+
b: Tensor<T, V>
33+
): Tensor<T, V> {
34+
TODO("Not yet implemented")
35+
}
36+
37+
override fun <T : DType> matmul(
38+
a: Tensor<T, V>,
39+
b: Tensor<T, V>
40+
): Tensor<T, V> {
41+
TODO("Not yet implemented")
42+
}
43+
44+
override fun <T : DType> transpose(tensor: Tensor<T, V>): Tensor<T, V> {
45+
TODO("Not yet implemented")
46+
}
47+
48+
override fun <T : DType> conv2d(
49+
input: Tensor<T, V>,
50+
weight: Tensor<T, V>,
51+
bias: Tensor<T, V>?,
52+
stride: Pair<Int, Int>,
53+
padding: Pair<Int, Int>,
54+
dilation: Pair<Int, Int>,
55+
groups: Int
56+
): Tensor<T, V> {
57+
TODO("Not yet implemented")
58+
}
59+
60+
override fun <T : DType> maxPool2d(
61+
input: Tensor<T, V>,
62+
kernelSize: Pair<Int, Int>,
63+
stride: Pair<Int, Int>,
64+
padding: Pair<Int, Int>
65+
): Tensor<T, V> {
66+
TODO("Not yet implemented")
67+
}
68+
69+
override fun <T : DType> reshape(
70+
tensor: Tensor<T, V>,
71+
newShape: Shape
72+
): Tensor<T, V> {
73+
TODO("Not yet implemented")
74+
}
75+
76+
override fun <T : DType> flatten(
77+
tensor: Tensor<T, V>,
78+
startDim: Int,
79+
endDim: Int
80+
): Tensor<T, V> {
81+
TODO("Not yet implemented")
82+
}
83+
84+
override fun <T : DType> concat(
85+
tensors: List<Tensor<T, V>>,
86+
dim: Int
87+
): Tensor<T, V> {
88+
TODO("Not yet implemented")
89+
}
90+
91+
override fun <T : DType> split(
92+
tensor: Tensor<T, V>,
93+
splitSize: Int,
94+
dim: Int
95+
): List<Tensor<T, V>> {
96+
TODO("Not yet implemented")
97+
}
98+
99+
override fun <T : DType> squeeze(
100+
tensor: Tensor<T, V>,
101+
dim: Int?
102+
): Tensor<T, V> {
103+
TODO("Not yet implemented")
104+
}
105+
106+
override fun <T : DType> unsqueeze(
107+
tensor: Tensor<T, V>,
108+
dim: Int
109+
): Tensor<T, V> {
110+
TODO("Not yet implemented")
111+
}
112+
113+
override fun <T : DType> relu(tensor: Tensor<T, V>): Tensor<T, V> {
114+
TODO("Not yet implemented")
115+
}
116+
117+
override fun <T : DType> softmax(
118+
tensor: Tensor<T, V>,
119+
dim: Int
120+
): Tensor<T, V> {
121+
TODO("Not yet implemented")
122+
}
123+
124+
override fun <T : DType> sigmoid(tensor: Tensor<T, V>): Tensor<T, V> {
125+
TODO("Not yet implemented")
126+
}
127+
128+
override fun <T : DType> silu(tensor: Tensor<T, V>): Tensor<T, V> {
129+
TODO("Not yet implemented")
130+
}
131+
132+
override fun <T : DType> gelu(tensor: Tensor<T, V>): Tensor<T, V> {
133+
TODO("Not yet implemented")
134+
}
135+
136+
override fun <T : DType> sum(
137+
tensor: Tensor<T, V>,
138+
dim: Int?
139+
): Tensor<T, V> {
140+
TODO("Not yet implemented")
141+
}
142+
143+
override fun <T : DType> mean(
144+
tensor: Tensor<T, V>,
145+
dim: Int?
146+
): Tensor<T, V> {
147+
TODO("Not yet implemented")
148+
}
149+
150+
override fun <T : DType> variance(
151+
tensor: Tensor<T, V>,
152+
dim: Int?
153+
): Tensor<T, V> {
154+
TODO("Not yet implemented")
155+
}
156+
157+
override fun <T : DType> sqrt(tensor: Tensor<T, V>): Tensor<T, V> {
158+
TODO("Not yet implemented")
159+
}
160+
161+
override fun <TFrom : DType, TTo : DType> convert(
162+
tensor: Tensor<TFrom, V>,
163+
targetType: TTo
164+
): Tensor<TTo, V> {
165+
TODO("Not yet implemented")
166+
}
167+
168+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
2+
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
3+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
4+
5+
plugins {
6+
alias(libs.plugins.kotlinMultiplatform)
7+
alias(libs.plugins.androidLibrary)
8+
alias(libs.plugins.vanniktech.mavenPublish)
9+
alias(libs.plugins.kover)
10+
alias(libs.plugins.binary.compatibility.validator)
11+
}
12+
13+
kotlin {
14+
explicitApi()
15+
16+
androidTarget {
17+
@OptIn(ExperimentalKotlinGradlePluginApi::class)
18+
compilerOptions {
19+
jvmTarget.set(JvmTarget.JVM_11)
20+
}
21+
}
22+
23+
iosArm64()
24+
iosSimulatorArm64()
25+
macosArm64 ()
26+
linuxX64 ()
27+
linuxArm64 ()
28+
29+
jvm()
30+
31+
@OptIn(ExperimentalWasmDsl::class)
32+
wasmJs {
33+
browser()
34+
binaries.executable()
35+
}
36+
37+
sourceSets {
38+
commonMain.dependencies {
39+
api(project(":skainet-lang:skainet-lang-core"))
40+
api(project(":skainet-compile:skainet-compile-core"))
41+
implementation(project(":skainet-compile:skainet-compile-core"))
42+
}
43+
44+
commonTest.dependencies {
45+
implementation(libs.kotlin.test)
46+
}
47+
}
48+
}
49+
50+
android {
51+
namespace = "sk.ai.net.lang.api"
52+
compileSdk = libs.versions.android.compileSdk.get().toInt()
53+
54+
defaultConfig {
55+
minSdk = libs.versions.android.minSdk.get().toInt()
56+
}
57+
compileOptions {
58+
sourceCompatibility = JavaVersion.VERSION_11
59+
targetCompatibility = JavaVersion.VERSION_11
60+
}
61+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
POM_ARTIFACT_ID=skainet-backends-core
2+
POM_NAME=skainet neural backends core
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
2+
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
3+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
4+
5+
plugins {
6+
alias(libs.plugins.kotlinMultiplatform)
7+
alias(libs.plugins.androidLibrary)
8+
alias(libs.plugins.vanniktech.mavenPublish)
9+
alias(libs.plugins.kover)
10+
alias(libs.plugins.binary.compatibility.validator)
11+
}
12+
13+
kotlin {
14+
explicitApi()
15+
16+
androidTarget {
17+
@OptIn(ExperimentalKotlinGradlePluginApi::class)
18+
compilerOptions {
19+
jvmTarget.set(JvmTarget.JVM_11)
20+
}
21+
}
22+
23+
iosArm64()
24+
iosSimulatorArm64()
25+
macosArm64()
26+
linuxX64()
27+
linuxArm64()
28+
29+
jvm()
30+
31+
@OptIn(ExperimentalWasmDsl::class)
32+
wasmJs {
33+
browser()
34+
binaries.executable()
35+
}
36+
37+
sourceSets {
38+
commonMain.dependencies {
39+
implementation(project(":skainet-lang:skainet-lang-core"))
40+
}
41+
42+
commonTest.dependencies {
43+
implementation(libs.kotlin.test)
44+
}
45+
}
46+
}
47+
48+
android {
49+
namespace = "sk.ainet.compilie.core"
50+
compileSdk = libs.versions.android.compileSdk.get().toInt()
51+
52+
defaultConfig {
53+
minSdk = libs.versions.android.minSdk.get().toInt()
54+
}
55+
compileOptions {
56+
sourceCompatibility = JavaVersion.VERSION_11
57+
targetCompatibility = JavaVersion.VERSION_11
58+
}
59+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
POM_ARTIFACT_ID=skainet-compile-core
2+
POM_NAME=skainet neural network compile core

skainet-lang/skainet-lang-core/src/commonMain/kotlin/sk/ainet/compile/nn/NeuralNetworkContext.kt renamed to skainet-compile/skainet-compile-core/src/commonMain/kotlin/sk/ainet/compile/nn/NeuralNetworkContext.kt

File renamed without changes.

0 commit comments

Comments
 (0)