Skip to content

Commit 59a80c5

Browse files
committed
restore init() method restore separate @platform -gpu extension, so we only try load onnxruntime_providers_cuda for CUDA-enabled builds
1 parent 2e75c6e commit 59a80c5

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

onnxruntime/cppbuild.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,18 @@ sedinplace 's/offsets = allocarray/offsets = (size_t*)allocarray/g' java/src/mai
200200
sedinplace 's/tempBuffer = realloc/tempBuffer = (char*)realloc/g' java/src/main/native/OrtJniUtil.cpp
201201
sedinplace 's/Throw(javaException)/Throw((jthrowable)javaException)/g' java/src/main/native/OrtJniUtil.cpp
202202
sedinplace '/jint JNI_OnLoad/,/}/d' java/src/main/native/OrtJniUtil.cpp
203+
sedinplace '/static synchronized void init() throws IOException {/a\
204+
loaded = org.bytedeco.javacpp.Loader.load(org.bytedeco.onnxruntime.presets.onnxruntime.class) != null;\
205+
ortApiHandle = initialiseAPIBase(ORT_API_VERSION_23);\
206+
if (ortApiHandle == 0L) {\
207+
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");\
208+
}\
209+
ortTrainingApiHandle = initialiseTrainingAPIBase(ortApiHandle, ORT_API_VERSION_23);\
210+
ortCompileApiHandle = initialiseCompileAPIBase(ortApiHandle);\
211+
trainingEnabled = ortTrainingApiHandle != 0L;\
212+
providers = initialiseProviders(ortApiHandle);\
213+
version = initialiseVersion();\
214+
' java/src/main/java/ai/onnxruntime/OnnxRuntime.java
203215
sedinplace 's/Names = malloc/Names = (const char**)malloc/g' java/src/main/native/ai_onnxruntime_OrtSession.cpp
204216
sedinplace 's/Strings = malloc/Strings = (jobject*)malloc/g' java/src/main/native/ai_onnxruntime_OrtSession.cpp
205217
sedinplace 's/inputValuePtrs = malloc/inputValuePtrs = (const OrtValue**)malloc/g' java/src/main/native/ai_onnxruntime_OrtSession.cpp

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@
6868
},
6969
exclude = {"CL/opencl.h", "CL/cl_version.h", "CL/cl_platform.h", "CL/cl.h"/*, "CL/cl_gl.h", "CL/cl_gl_ext.h", "CL/cl_ext.h"*/,
7070
"onnxruntime/core/session/onnxruntime_ep_c_api.h"},
71+
link = {"onnxruntime_providers_shared", "onnxruntime@.1", "onnxruntime_providers_dnnl", "onnxruntime_providers_openvino"}
72+
),
73+
@Platform(
74+
value = {"linux", "windows"},
75+
extension = "-gpu",
7176
link = {"onnxruntime_providers_shared", "onnxruntime@.1", "onnxruntime_providers_dnnl", "onnxruntime_providers_openvino", "onnxruntime_providers_cuda"}
7277
),
7378
},

0 commit comments

Comments
 (0)