-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add dedicated API to support extracting compatibility string from model metadata #27015
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
Open
adrastogi
wants to merge
6
commits into
main
Choose a base branch
from
adrastogi/compat-metadata-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+491
−1
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
skottmckay
reviewed
Jan 15, 2026
skottmckay
previously approved these changes
Jan 15, 2026
Contributor
skottmckay
left a comment
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.
![]()
adrianlizarraga
previously approved these changes
Jan 15, 2026
9e640cb
Contributor
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.
You can commit the suggested changes from lintrunner.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…#27032) ### Description Android CI failed due to `-Werror,-Wunused-result` treating ignored return values as errors. Fixed 7 instances in `ep_compatibility_test.cc` where C API functions marked with `warn_unused_result` were called without checking their `OrtStatus*` returns: - 6 calls to `GetAllocatorWithDefaultOptions` - 1 call to `AllocatorFree` Changed from: ```cpp api->GetAllocatorWithDefaultOptions(&allocator); api->AllocatorFree(allocator, compat_info); ``` To: ```cpp ASSERT_EQ(api->GetAllocatorWithDefaultOptions(&allocator), nullptr); ASSERT_EQ(api->AllocatorFree(allocator, compat_info), nullptr); ``` ### Motivation and Context The Android build uses Clang with strict warnings. These C API functions return `OrtStatus*` to indicate success/failure, and ignoring them violates the `warn_unused_result` attribute. The fix follows the pattern used in other test files (e.g., `test_inference.cc`) and improves test robustness by catching API errors. <!-- START COPILOT CODING AGENT SUFFIX --> <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > Fix the failing GitHub Actions workflow Android CI Pipeline > > Analyze the workflow logs, identify the root cause of the failure, and implement a fix. > > Job ID: 60532176150 > > Job URL: https://github.com/microsoft/onnxruntime/actions/runs/21049485371/job/60532176150 </details> <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/microsoft/onnxruntime/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: adrastogi <[email protected]>
# Conflicts: # include/onnxruntime/core/session/onnxruntime_cxx_api.h
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This change proposes a new helper ORT API for callers that need to extract the model compatibility string from a precompiled model.
Motivation and Context
See #25749 for more background on the model compatibility concept and infrastructure; #25841 provides a related helper API for an application to call to do a validation check using the compatibility info string. However, there is no direct way to get to the model metadata without creating a session (which some callers may prefer to avoid) or by taking a dependency on a separate library to parse the model's protobuf (which again callers may prefer to avoid).
This change proposes a separate helper API which can be used to retrieve the compatibility info string, thereby avoiding session creation or an external dependency. This does incur some amount of redundant work in that the model protobuf will be parsed again during session creation- but for some callers, this tradeoff may be acceptable.