Kotlin / multik

Multidimensional array library for Kotlin
https://kotlin.github.io/multik/
Apache License 2.0
633 stars 38 forks source link

Error when running on older Android device - FilteAttribute not found #171

Closed GregCornis closed 11 months ago

GregCornis commented 1 year ago

Hi,

I've been using multik in an Android app without a problem for a while (amazing lib by the way!). However, it seems to crash on an older Android device, with a NoClassDefFoundError.
I have managed to fix the issue by replacing the multik-default dependency with multik-kotlin (the error pointed to openblas.JvmNativeEngine). However :

  1. I am not sure what the difference is. Is there any performance impact ?
  2. I am curious about the source of the error. Is it an android API which is missing, or something like that ?
java.util.ServiceConfigurationError: org.jetbrains.kotlinx.multik.api.Engine: Provider org.jetbrains.kotlinx.multik.openblas.JvmNativeEngine could not be instantiated: java.lang.NoClassDefFoundError: Failed resolution of: [Ljava/nio/file/attribute/FileAttribute;
at java.util.ServiceLoader.fail(ServiceLoader.java:225)
at java.util.ServiceLoader.-wrap1(ServiceLoader.java)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:380)
at java.util.ServiceLoader$1.next(ServiceLoader.java:448)
at kotlin.collections.CollectionsKt___CollectionsKt.toCollection(_Collections.kt:1295)
at kotlin.collections.CollectionsKt___CollectionsKt.toMutableList(_Collections.kt:1328)
at kotlin.collections.CollectionsKt___CollectionsKt.toList(_Collections.kt:1319)
at org.jetbrains.kotlinx.multik.api.EngineKt.enginesProvider(Engine.kt:9)
at org.jetbrains.kotlinx.multik.api.Engine.<clinit>(Engine.kt:68)
at org.jetbrains.kotlinx.multik.api.Multik.getMath(Multik.kt:48)
at org.jetbrains.kotlinx.multik.ndarray.operations.IteratingNDArrayKt.sum(IteratingNDArray.kt:1242)
devcrocod commented 11 months ago

Hey, Native code is used In multik-openblas. Currently, only the arm8 architecture is supported, so it may not work on older devices. I plan to stabilize the native code for Android in the future.

GregCornis commented 11 months ago

Nice, thanks :) and regarding the performance, is there a significant difference between multik-kotlin and multik-openblas ?

devcrocod commented 11 months ago

multik-kotlin and multik-openblas implement the Math, LinearAlgebra, and Statistics interfaces. Everything else is implemented in multik-core. multik-openblas provides significant performance improvement when using linear algebra methods such as dot or solve on medium to large arrays. However, the overall impact may vary depending on your project.

GregCornis commented 11 months ago

Alright thanks 👍