-
Notifications
You must be signed in to change notification settings - Fork 4.1k
[EP ABI] Add API to select the best compiled model compatibility info from candidate strings #28387
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a80c97b
update
chilo-ms 3fc4c52
update commnet
chilo-ms b4fa35e
revert
chilo-ms b58f0e3
move test to another file
chilo-ms ad43b3c
address reviewer's comment
chilo-ms 5a8a47c
address reviewer's comments
chilo-ms 6bdf709
address reviewer's comments
chilo-ms 6354b14
update api comment mentioning in ORT 1.28
chilo-ms 0b3c044
update api comment mentioning model package variant body fields
chilo-ms e8f3343
Update SelectBestModelCandidate doc comment for multi-model variant s…
chilo-ms f5c3d52
update API comment
chilo-ms 37abbe7
Update SelectBestModelCandidate doc: unified indexed format, clarify …
chilo-ms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| #include <limits> | ||
| #include <string> | ||
|
|
||
| #include "gtest/gtest.h" | ||
|
|
||
| #include "core/session/onnxruntime_c_api.h" | ||
| #include "core/session/onnxruntime_cxx_api.h" | ||
| #include "core/session/abi_devices.h" | ||
| #include "test/autoep/test_autoep_utils.h" | ||
|
|
||
| using namespace onnxruntime; | ||
|
|
||
| TEST(EpCompatibilitySelectBestTest, SelectBestModelCandidate_UsesHardwareDevices) { | ||
| Ort::Env env{ORT_LOGGING_LEVEL_WARNING, "EpCompatSelectBestExampleEp"}; | ||
|
|
||
| onnxruntime::test::RegisteredEpDeviceUniquePtr example_ep; | ||
| onnxruntime::test::Utils::RegisterAndGetExampleEp( | ||
| env, onnxruntime::test::Utils::example_ep_info, example_ep); | ||
|
|
||
| ASSERT_NE(example_ep.get(), nullptr); | ||
|
|
||
| const OrtEpDevice* ep_device = example_ep.get(); | ||
| OrtEpFactory* factory = ep_device->GetMutableFactory(); | ||
| ASSERT_NE(factory, nullptr); | ||
| ASSERT_NE(factory->SelectBestModelCandidate, nullptr); | ||
|
|
||
| const std::string ep_name = factory->GetName(factory); | ||
|
|
||
| const std::string optimal = | ||
| ep_name + ";version=0.1.0;ort_api_version=" + std::to_string(ORT_API_VERSION) + ";hardware_architecture=arch1"; | ||
|
|
||
| const std::string prefer_recompile = | ||
| ep_name + ";version=9.9.9;ort_api_version=" + std::to_string(ORT_API_VERSION) + ";hardware_architecture=arch1"; | ||
|
|
||
| const std::string unsupported = | ||
| "SomeOtherEp;version=0.1.0;ort_api_version=" + std::to_string(ORT_API_VERSION) + ";hardware_architecture=arch1"; | ||
|
|
||
| const OrtApi* api = OrtGetApiBase()->GetApi(ORT_API_VERSION); | ||
| ASSERT_NE(api, nullptr); | ||
|
|
||
| OrtKeyValuePairs* kvp0 = nullptr; | ||
| OrtKeyValuePairs* kvp1 = nullptr; | ||
| OrtKeyValuePairs* kvp2 = nullptr; | ||
| api->CreateKeyValuePairs(&kvp0); | ||
| api->CreateKeyValuePairs(&kvp1); | ||
| api->CreateKeyValuePairs(&kvp2); | ||
| api->AddKeyValuePair(kvp0, "ep_compatibility_info", unsupported.c_str()); | ||
| api->AddKeyValuePair(kvp1, "ep_compatibility_info", prefer_recompile.c_str()); | ||
| api->AddKeyValuePair(kvp2, "ep_compatibility_info", optimal.c_str()); | ||
|
|
||
| const OrtKeyValuePairs* candidates[] = {kvp0, kvp1, kvp2}; | ||
|
|
||
| size_t selected_index = std::numeric_limits<size_t>::max(); | ||
| OrtStatus* st = factory->SelectBestModelCandidate( | ||
| factory, ep_device->device, candidates, 3, nullptr, &selected_index); | ||
|
|
||
| ASSERT_EQ(st, nullptr) << (st ? api->GetErrorMessage(st) : ""); | ||
|
|
||
| EXPECT_EQ(selected_index, 2u); | ||
|
|
||
| api->ReleaseKeyValuePairs(kvp0); | ||
| api->ReleaseKeyValuePairs(kvp1); | ||
| api->ReleaseKeyValuePairs(kvp2); | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.