| 9 | import com.sun.jna.Native; |
| 10 | |
| 11 | @SuppressWarnings ("deprecation") |
| 12 | public class MLModel |
| 13 | { |
| 14 | private interface DllInterface extends Library |
| 15 | { |
| 16 | |
| 17 | int set_log_level_ml_module (int log_level); |
| 18 | |
| 19 | int set_log_file_ml_module (String log_file); |
| 20 | |
| 21 | int log_message_ml_module (int log_level, String message); |
| 22 | |
| 23 | int prepare (String params); |
| 24 | |
| 25 | int release (String params); |
| 26 | |
| 27 | int predict (double[] data, int data_len, double[] output, int[] output_len, String params); |
| 28 | |
| 29 | int release_all (); |
| 30 | |
| 31 | int get_version_ml_module (byte[] version, int[] len, int max_len); |
| 32 | } |
| 33 | |
| 34 | private static DllInterface instance; |
| 35 | |
| 36 | static |
| 37 | { |
| 38 | // SystemUtils doesnt have smth like IS_OS_ANDROID, need to check using |
| 39 | // properties |
| 40 | boolean is_os_android = "The Android Project".equals (System.getProperty ("java.specification.vendor")); |
| 41 | |
| 42 | String lib_name = "libMLModule.so"; |
| 43 | if (SystemUtils.IS_OS_WINDOWS) |
| 44 | { |
| 45 | lib_name = "MLModule.dll"; |
| 46 | String arch = System.getProperty ("os.arch"); |
| 47 | switch (arch) { |
| 48 | case "x86": |
| 49 | JarHelper.unpack_from_jar ("onnxruntime_x86.dll"); |
| 50 | break; |
| 51 | case "x86_64": |
| 52 | case "amd64": |
| 53 | JarHelper.unpack_from_jar ("onnxruntime_x64.dll"); |
| 54 | break; |
| 55 | case "arm": |
| 56 | JarHelper.unpack_from_jar ("onnxruntime_arm.dll"); |
| 57 | break; |
| 58 | case "arm64": |
| 59 | JarHelper.unpack_from_jar ("onnxruntime_arm64.dll"); |
| 60 | break; |
| 61 | default: |
| 62 | System.err.println("Unsupported Windows architecture: " + arch); |
| 63 | } |
| 64 | } else if (SystemUtils.IS_OS_MAC) |
| 65 | { |
| 66 | lib_name = "libMLModule.dylib"; |
| 67 | JarHelper.unpack_from_jar ("onnxruntime_x86.dll"); |
| 68 | JarHelper.unpack_from_jar ("onnxruntime_x86.dll"); |
nothing calls this directly
no test coverage detected