-
-
Notifications
You must be signed in to change notification settings - Fork 56.4k
Extending G-API onnx::Params to pass arbitrary session options #25791
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
asmorkalov
merged 8 commits into
opencv:4.x
from
ujjayant-kadian:uk/extend-gapi-onnx-params-arbitrary-session-options
Jun 21, 2024
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ce66849
Extend G-API onnx::Params to pass arbitrary session options
8ecb4da
Addressed comments and corrected build error
afcfba6
Corrected a formatting error
d03320b
Corrected a formatting error
3386df5
Addressed some docstring comments
d6801e9
Modified the docstring
51ecf1b
Reverted back to the train constructor
bb5d50e
Added cfgSessionOptions to generic Params and made python related
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -351,6 +351,7 @@ struct ParamDesc { | |
| std::unordered_map<std::string, std::pair<cv::Scalar, cv::Scalar> > generic_mstd; | ||
| std::unordered_map<std::string, bool> generic_norm; | ||
|
|
||
| std::map<std::string, std::string> session_options; | ||
| std::vector<cv::gapi::onnx::ep::EP> execution_providers; | ||
| bool disable_mem_pattern; | ||
| }; | ||
|
|
@@ -634,6 +635,19 @@ template<typename Net> class Params { | |
| return *this; | ||
| } | ||
|
|
||
| /** @brief Configures session options for ONNX Runtime. | ||
|
|
||
| This function is used to set various session options for the ONNX Runtime | ||
| session by accepting a map of key-value pairs. | ||
|
|
||
| @param options A map of session option to be applied to the ONNX Runtime session. | ||
| @return the reference on modified object. | ||
| */ | ||
| Params<Net>& cfgSessionOptions(const std::map<std::string, std::string>& options) { | ||
| desc.session_options.insert(options.begin(), options.end()); | ||
| return *this; | ||
| } | ||
|
|
||
| // BEGIN(G-API's network parametrization API) | ||
| GBackend backend() const { return cv::gapi::onnx::backend(); } | ||
| std::string tag() const { return Net::tag(); } | ||
|
|
@@ -661,7 +675,7 @@ class Params<cv::gapi::Generic> { | |
| @param model_path path to model file (.onnx file). | ||
| */ | ||
| Params(const std::string& tag, const std::string& model_path) | ||
| : desc{model_path, 0u, 0u, {}, {}, {}, {}, {}, {}, {}, {}, {}, true, {}, {}, {}, false }, m_tag(tag) {} | ||
| : desc{model_path, 0u, 0u, {}, {}, {}, {}, {}, {}, {}, {}, {}, true, {}, {}, {}, {}, false}, m_tag(tag) {} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚋🚋🚋 |
||
|
|
||
| /** @see onnx::Params::cfgMeanStdDev. */ | ||
| void cfgMeanStdDev(const std::string &layer, | ||
|
|
@@ -705,6 +719,11 @@ class Params<cv::gapi::Generic> { | |
| desc.disable_mem_pattern = true; | ||
| } | ||
|
|
||
| /** @see onnx::Params::cfgSessionOptions. */ | ||
| void cfgSessionOptions(const std::map<std::string, std::string>& options) { | ||
| desc.session_options.insert(options.begin(), options.end()); | ||
| } | ||
|
|
||
| // BEGIN(G-API's network parametrization API) | ||
| GBackend backend() const { return cv::gapi::onnx::backend(); } | ||
| std::string tag() const { return m_tag; } | ||
|
|
||
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
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.