Remove ND4j

This commit is contained in:
Alexander Nozik 2025-03-07 21:03:57 +03:00
parent 656d874a65
commit e11968f8d2
5 changed files with 7 additions and 20 deletions
benchmarks
build.gradle.kts
src/jvmMain/kotlin/space/kscience/kmath/benchmarks
examples
build.gradle.kts
src/main/kotlin/space/kscience/kmath/structures
settings.gradle.kts

@ -60,13 +60,14 @@ kotlin {
dependencies {
implementation(projects.kmathCommons)
implementation(projects.kmathEjml)
implementation(projects.kmathNd4j)
implementation(projects.kmathKotlingrad)
implementation(projects.kmathViktor)
implementation(projects.kmathOjalgo)
implementation(projects.kmath.kmathTensorflow)
implementation(projects.kmathMultik)
implementation(libs.tensorflow.core.platform)
// implementation(projects.kmathNd4j)
// implementation(libs.nd4j.native.platform)
// uncomment if your system supports AVX2
// val os = System.getProperty("os.name")

@ -15,7 +15,6 @@ import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import space.kscience.kmath.UnsafeKMathAPI
import space.kscience.kmath.nd.*
import space.kscience.kmath.nd4j.nd4j
import space.kscience.kmath.operations.Float64Field
import space.kscience.kmath.structures.Float64
import space.kscience.kmath.tensors.core.DoubleTensor
@ -32,7 +31,6 @@ internal class NDFieldBenchmark {
private val shape = ShapeND(dim, dim)
private val specializedField = Float64Field.ndAlgebra
private val genericField = BufferedFieldOpsND(Float64Field)
private val nd4jField = Float64Field.nd4j
private val viktorField = Float64Field.viktorAlgebra
}

@ -23,7 +23,6 @@ dependencies {
implementation(project(":kmath-viktor"))
implementation(project(":kmath-dimensions"))
implementation(project(":kmath-ejml"))
implementation(project(":kmath-nd4j"))
implementation(project(":kmath-tensors"))
implementation(project(":kmath-symja"))
implementation(project(":kmath-for-real"))
@ -32,9 +31,10 @@ dependencies {
implementation(libs.multik.default)
//datetime
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0")
implementation(spclibs.kotlinx.datetime)
implementation("org.nd4j:nd4j-native:1.0.0-beta7")
// implementation(project(":kmath-nd4j"))
// implementation("org.nd4j:nd4j-native:1.0.0-beta7")
// uncomment if your system supports AVX2
// val os = System.getProperty("os.name")
@ -44,7 +44,7 @@ dependencies {
// os == "Linux" -> implementation("org.nd4j:nd4j-native:1.0.0-beta7:linux-x86_64-avx2")
// os == "Mac OS X" -> implementation("org.nd4j:nd4j-native:1.0.0-beta7:macosx-x86_64-avx2")
// } else
implementation("org.nd4j:nd4j-native-platform:1.0.0-beta7")
// implementation("org.nd4j:nd4j-native-platform:1.0.0-beta7")
implementation("org.slf4j:slf4j-simple:1.7.32")
// plotting

@ -7,9 +7,7 @@ package space.kscience.kmath.structures
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import org.nd4j.linalg.factory.Nd4j
import space.kscience.kmath.nd.*
import space.kscience.kmath.nd4j.nd4j
import space.kscience.kmath.operations.Float64Field
import space.kscience.kmath.operations.invoke
import space.kscience.kmath.viktor.ViktorFieldND
@ -26,7 +24,6 @@ internal inline fun measureAndPrint(title: String, block: () -> Unit) {
@OptIn(DelicateCoroutinesApi::class)
fun main() {
// initializing Nd4j
Nd4j.zeros(0)
val dim = 1000
val n = 1000
val shape = ShapeND(dim, dim)
@ -36,8 +33,6 @@ fun main() {
val doubleField = Float64Field.ndAlgebra
//A generic field. It should be used for objects, not primitives.
val genericField = BufferedFieldOpsND(Float64Field)
// Nd4j specialized field.
val nd4jField = Float64Field.nd4j
//viktor field
val viktorField = ViktorFieldND(dim, dim)
//parallel processing based on Java Streams
@ -57,13 +52,6 @@ fun main() {
}
}
measureAndPrint("Nd4j specialized addition") {
nd4jField {
var res: StructureND<Float64> = one(shape)
repeat(n) { res += 1.0 }
}
}
measureAndPrint("Viktor addition") {
viktorField {
var res: StructureND<Float64> = one

@ -50,7 +50,7 @@ include(
":kmath-tensorflow",
":kmath-optimization",
":kmath-stat",
":kmath-nd4j",
// ":kmath-nd4j",
":kmath-dimensions",
":kmath-for-real",
":kmath-geometry",