-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[js/rn] Package dependency change to manage ort-extensions for react_native app #15641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
js/react_native/android/srcExt/main/java/ai/onnxruntime/reactnative/OnnxruntimeModule.java
Outdated
Show resolved
Hide resolved
| #import <onnxruntime/onnxruntime_cxx_api.h> | ||
|
|
||
| #ifdef ENABLE_ORT_EXT | ||
| #include <onnxruntime_extensions.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this include doesn't require any leading directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct, this one works fine. it's the <onnxruntime_c_api.h> this extensions header includes requires a leading directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update: actually looks like just getting rid of https://github.com/microsoft/onnxruntime-extensions/blob/0e2d6c03e4b87f49e6d35c1ca540e99317ac8bb9/includes/onnxruntime_extensions.h#L5
this line here would work with the project. (i.e. no "redefinition" error at compile stage for objects defined in onnxruntime_c_api.h)
I guess this c_api include in extensions header isn't really necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this require a change on the ort extensions side for it to work? If so are there any objections to that change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this require a change on the ort extensions side for it to work? If so are there any objections to that change?
yeah... hopefully we can just remove that line as Ed pined above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wenbingl what do you think? could we remove the onnxruntime_c_api.h include from here and just forward declare the ORT types?
onnxruntime_extensions.h is the only ABI head file for ort-extensions, and Register... function depends on some types defined c_api.h. Can we assume that every time the onnxruntime_extensions.h is included, onnxruntme_c_api.h already included before that?
I don't know what the issue is here? redefinition? Suppose there will be only one copy of onnxruntime_c_api.h in the whole build since ort-extensions can use onnxruntime_c_api.h from internal folder, if not, that's something should be fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what the issue is here? redefinition? Suppose there will be only one copy of onnxruntime_c_api.h in the whole build since ort-extensions can use onnxruntime_c_api.h from internal folder, if not, that's something should be fixed.
yea, I experienced a redefinition error when building a react native app on the ios side. I guess it duplicates with the onnxruntime_c_api.h header that already been included from the onnxruntime-c pod.
I will try to seek ways to not making changes on the ort-extensions side first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ort header file are setting here: https://github.com/microsoft/onnxruntime-
extensions/blob/f12270b06858b2a57c6fa5041c39d835a707060f/cmake/ext_ortlib.cmake#L2
You may make some change here if needed to make sure the right header file can be found.
js/react_native/android/srcExt/main/java/ai/onnxruntime/reactnative/OnnxruntimeModule.java
Outdated
Show resolved
Hide resolved
| import ai.onnxruntime.OrtSession.SessionOptions; | ||
| import ai.onnxruntime.extensions.OrtxPackage; | ||
|
|
||
| class OnnxruntimeExtensions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not specifying public here for this class as other wise compiler would complain about the class name not match the file name. but in our case, it should be fine as if not specified, will by default be package-specific. We only will call and use this class within the same package bundle ai.onnxruntime.reactnative
...t_native/android/src/main/java/ai/onnxruntime/reactnative/OnnxruntimeExtensionsDisabled.java
Outdated
Show resolved
Hide resolved
|
|
||
| class OnnxruntimeExtensions { | ||
| public void registerOrtExtensionsIfEnabled(SessionOptions sessionOptions) { | ||
| Log.d("Info", "ORT Extensions is not enabled."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Can we update the message to tell them how to enable it as clearly they're wanting to?
...t_native/android/src/main/java/ai/onnxruntime/reactnative/OnnxruntimeExtensionsDisabled.java
Outdated
Show resolved
Hide resolved
| public void registerOrtExtensionsIfEnabled(SessionOptions sessionOptions) { | ||
| Log.d( | ||
| "Info", | ||
| "ORT Extensions is not enabled in the current configuration. If you want to enable this support," |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add space
| "ORT Extensions is not enabled in the current configuration. If you want to enable this support," | |
| "ORT Extensions is not enabled in the current configuration. If you want to enable this support, " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also the first argument is a tag, maybe it should be something like "OnnxruntimeExtensions". if you want an info log instead of debug, use Log.i()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right got it. thanks!
…native app (microsoft#15641) ### Description <!-- Describe your changes. --> js/react_native package dependency change to manage ort-extensions for react-native app. Enable optional inclusion of ort-ext aar/ ort-ext pods for react-native extensions apps when specifiy `ortExtensionsEnabled` in user's package.json file ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> --------- Co-authored-by: rachguo <rachguo@rachguos-Mac-mini.local> Co-authored-by: rachguo <rachguo@rachguos-Mini.attlocal.net>
…native app (microsoft#15641) ### Description <!-- Describe your changes. --> js/react_native package dependency change to manage ort-extensions for react-native app. Enable optional inclusion of ort-ext aar/ ort-ext pods for react-native extensions apps when specifiy `ortExtensionsEnabled` in user's package.json file ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> --------- Co-authored-by: rachguo <rachguo@rachguos-Mac-mini.local> Co-authored-by: rachguo <rachguo@rachguos-Mini.attlocal.net>
Description
js/react_native package dependency change to manage ort-extensions for react-native app.
Enable optional inclusion of ort-ext aar/ ort-ext pods for react-native extensions apps when specifiy
ortExtensionsEnabledin user's package.json fileMotivation and Context