From 0c2939262efdbf385ffa602527a8f45a161d2929 Mon Sep 17 00:00:00 2001 From: Richard Waltman Date: Fri, 13 Oct 2023 13:29:56 -0500 Subject: [PATCH 1/2] Add check for os.arch when unpacking MLModel .dlls on WIndows --- .../src/main/java/brainflow/MLModel.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/java_package/brainflow/src/main/java/brainflow/MLModel.java b/java_package/brainflow/src/main/java/brainflow/MLModel.java index b947e73b4..e28c3bf73 100644 --- a/java_package/brainflow/src/main/java/brainflow/MLModel.java +++ b/java_package/brainflow/src/main/java/brainflow/MLModel.java @@ -43,10 +43,24 @@ private interface DllInterface extends Library if (SystemUtils.IS_OS_WINDOWS) { lib_name = "MLModule.dll"; - JarHelper.unpack_from_jar ("onnxruntime_arm.dll"); - JarHelper.unpack_from_jar ("onnxruntime_arm64.dll"); - JarHelper.unpack_from_jar ("onnxruntime_x64.dll"); - JarHelper.unpack_from_jar ("onnxruntime_x86.dll"); + String arch = System.getProperty ("os.arch"); + switch (arch) { + case "x86": + JarHelper.unpack_from_jar ("onnxruntime_x86.dll"); + break; + case "x86_64": + case "amd64": + JarHelper.unpack_from_jar ("onnxruntime_x64.dll"); + break; + case "arm": + JarHelper.unpack_from_jar ("onnxruntime_arm.dll"); + break; + case "arm64": + JarHelper.unpack_from_jar ("onnxruntime_arm64.dll"); + break; + default: + throw new RuntimeException ("Unsupported Windows architecture: " + arch); + } } else if (SystemUtils.IS_OS_MAC) { lib_name = "libMLModule.dylib"; From d85ed2596863e801d9c760813c9ebe5e1e2680d1 Mon Sep 17 00:00:00 2001 From: Richard Waltman Date: Thu, 19 Oct 2023 12:07:49 -0500 Subject: [PATCH 2/2] Update error message when unpacking ONNX .dlls in Java on Windows machines --- java_package/brainflow/src/main/java/brainflow/MLModel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java_package/brainflow/src/main/java/brainflow/MLModel.java b/java_package/brainflow/src/main/java/brainflow/MLModel.java index e28c3bf73..dd43212cc 100644 --- a/java_package/brainflow/src/main/java/brainflow/MLModel.java +++ b/java_package/brainflow/src/main/java/brainflow/MLModel.java @@ -59,7 +59,7 @@ private interface DllInterface extends Library JarHelper.unpack_from_jar ("onnxruntime_arm64.dll"); break; default: - throw new RuntimeException ("Unsupported Windows architecture: " + arch); + System.err.println("Unsupported Windows architecture: " + arch); } } else if (SystemUtils.IS_OS_MAC) {