microsoft / onnxruntime-extensions

onnxruntime-extensions: A specialized pre- and post- processing library for ONNX Runtime
MIT License
314 stars 81 forks source link

com.microsoft.onnxruntime:onnxruntime-extensions:0.11.0: missing RegisterCustomOps in onnxruntime_extensions4j_jni.dll #764

Open david-sitsky opened 1 month ago

david-sitsky commented 1 month ago

I am using OnnxRuntime extensions 0.11.0 in Java via DJL, and while this all works fine on Linux, the same code on Windows fails during initialisation on the OrtSession.SessionOptions.registerCustomOpLibrary() call:

Caused by: ai.onnxruntime.OrtException: Error code - ORT_FAIL - message: Failed to find symbol RegisterCustomOps in library, error code: 127 ""
    at ai.onnxruntime.OrtSession$SessionOptions.registerCustomOpLibrary(Native Method) ~[onnxruntime-1.17.3.jar:1.17.3]
    at ai.onnxruntime.OrtSession$SessionOptions.registerCustomOpLibrary(OrtSession.java:868) ~[onnxruntime-1.17.3.jar:1.17.3]

I have noticed the size of the embedded native libraries within com.microsoft.onnxruntime:onnxruntime-extensions:0.11.0 seems vastly different between Windows and Linux:

$ ls -lh
total 193M
-rw-rw-r-- 1 sits sits 8.8M May 24 23:32 libonnxruntime_extensions4j_jni.dylib
-rw-rw-r-- 1 sits sits 176M May 24 23:33 libonnxruntime_extensions4j_jni.so
-rw-rw-r-- 1 sits sits 8.1M May 24 23:33 onnxruntime_extensions4j_jni.dll

The Linux shared object file is almost 10x the size of the Windows (and macOS) libraries. Is something missing leading to this issue? I can see the .so file does have the symbol mentioned:

$ nm -gD libonnxruntime_extensions4j_jni.so | grep RegisterCustomOps
0000000000152bc0 T RegisterCustomOps

I opened the .dll with Ghidra and RegisterCustomOps seems to be missing.

Is there a build problem here, or have I missed something?

david-sitsky commented 1 month ago

As a point of comparison, from https://globalcdn.nuget.org/packages/microsoft.ml.onnxruntime.extensions.0.10.0.nupkg package, the linux-x86 .so file is only 5.1MB and the win-x64 ortextensions.dll file is 6.9MB.

So surely libonnxruntime_extensions4j_jni.so being 176MB for Linux is packaging up too much?

Anybody have any ideas what is going on here? I am hoping to use extensions in my project for both Windows and Linux, but this is currently a blocker.

david-sitsky commented 1 month ago

I can also see ortextensions.dll from the nupkg file does indeed export RegisterCustomOps, but onnxruntime_extensions4j_jni.dll does not.

wenbingl commented 1 month ago

@sayanshaw24 , can you follow up with these issues that @david-sitsky mentioned here?