Skip to content

Commit 7068eb3

Browse files
committed
Fix ONNX Runtime OpenVINO provider loading
1 parent 9c42bae commit 7068eb3

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

onnxruntime/cppbuild.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,15 @@ sedinplace 's/Throw(javaException)/Throw((jthrowable)javaException)/g' java/src/
183183
sedinplace '/jint JNI_OnLoad/,/}/d' java/src/main/native/OrtJniUtil.cpp
184184
sedinplace '/static synchronized void init() throws IOException {/a\
185185
loaded = org.bytedeco.javacpp.Loader.load(org.bytedeco.onnxruntime.presets.onnxruntime.class) != null;\
186-
ortApiHandle = initialiseAPIBase(ORT_API_VERSION_1);\
186+
ortApiHandle = initialiseAPIBase(ORT_API_VERSION_23);\
187+
if (ortApiHandle == 0L) {\
188+
throw new IllegalStateException("There is a mismatch between the ORT class files and the ORT native library, and the native library could not be loaded");\
189+
}\
190+
ortTrainingApiHandle = initialiseTrainingAPIBase(ortApiHandle, ORT_API_VERSION_23);\
191+
ortCompileApiHandle = initialiseCompileAPIBase(ortApiHandle);\
192+
trainingEnabled = ortTrainingApiHandle != 0L;\
193+
providers = initialiseProviders(ortApiHandle);\
194+
version = initialiseVersion();\
187195
' java/src/main/java/ai/onnxruntime/OnnxRuntime.java
188196
sedinplace 's/Names = malloc/Names = (const char**)malloc/g' java/src/main/native/ai_onnxruntime_OrtSession.cpp
189197
sedinplace 's/Strings = malloc/Strings = (jobject*)malloc/g' java/src/main/native/ai_onnxruntime_OrtSession.cpp

onnxruntime/src/main/java/org/bytedeco/onnxruntime/presets/onnxruntime.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
),
7373
@Platform(
7474
value = {"linux-x86_64", "windows-x86_64"},
75-
link = "onnxruntime_providers_openvino"
75+
link = {"onnxruntime_providers_shared", "onnxruntime@.1", "onnxruntime_providers_dnnl", "onnxruntime_providers_openvino"}
7676
),
7777
@Platform(
7878
value = {"linux", "macosx", "windows"},
@@ -166,6 +166,10 @@ public void map(InfoMap infoMap) {
166166
.put(new Info("Ort::detail::ValueImpl<OrtValue>::GetTensorMutableData<uint64_t>").javaNames("GetTensorMutableDataULong"))
167167
.put(new Info("Ort::detail::ValueImpl<OrtValue>::GetTensorMutableData<bool>").javaNames("GetTensorMutableDataBool"))
168168
.put(new Info("Ort::detail::Unowned<OrtAllocator>").pointerTypes("UnownedAllocator").purify())
169+
.put(new Info("Ort::detail::Base<OrtDeviceEpIncompatibilityDetails>").pointerTypes("BaseDeviceEpIncompatibilityDetails"))
170+
.put(new Info("DeviceEpIncompatibilityDetailsImpl<OrtDeviceEpIncompatibilityDetails>",
171+
"Ort::detail::DeviceEpIncompatibilityDetailsImpl<OrtDeviceEpIncompatibilityDetails>").pointerTypes("DeviceEpIncompatibilityDetailsImpl"))
172+
.put(new Info("DeviceEpIncompatibilityDetails", "Ort::DeviceEpIncompatibilityDetails").pointerTypes("DeviceEpIncompatibilityDetails"))
169173
.put(new Info("Ort::detail::Unowned<const OrtEpAssignedNode>").pointerTypes("ConstEpAssignedNode").purify())
170174
.put(new Info("Ort::detail::Unowned<const OrtEpAssignedSubgraph>").pointerTypes("ConstEpAssignedSubgraph").purify())
171175
.put(new Info("Ort::detail::Unowned<const Ort::MemoryInfo>").pointerTypes("UnownedMemoryInfo").purify())

0 commit comments

Comments
 (0)