-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Enable GraphIterator interface by default #33400
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
mvafin
wants to merge
16
commits into
openvinotoolkit:master
Choose a base branch
from
mvafin:mvafin/onnx/gi_default
base: master
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.
+549
−190
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
966de3c
[ONNX] Enable GraphIterator interface by default
mvafin 6187ec5
Xfail python editor tests
mvafin 5272fa9
Fix OpExtension test
mvafin 15650de
Add tests for both paths
mvafin 295822c
Apply suggestions from code review
mvafin 6e2c172
Update src/frontends/onnx/frontend/src/frontend.cpp
mvafin 251772d
Resolve unicode paths issue
mvafin 6e06f28
Update src/frontends/onnx/frontend/src/core/graph_iterator_proto.hpp
mvafin a22acce
Do not use triangle braces for openvino includes
mvafin 703ea3e
Merge branch 'master' into mvafin/onnx/gi_default
mvafin 09c0fee
Disable windows specific editor test
mvafin 40f0e29
Apply suggestions from code review
mvafin 018b8b4
Apply review feedback
mvafin aae9faf
Add deprecation message
mvafin 7823973
Fix code style
mvafin 5b80a48
Merge branch 'master' into mvafin/onnx/gi_default
mvafin 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
Some comments aren't visible on the classic Files Changed page.
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 |
|---|---|---|
|
|
@@ -17,8 +17,12 @@ | |
| # include <google/protobuf/stubs/logging.h> | ||
| #endif | ||
|
|
||
| #include <algorithm> | ||
| #include <cctype> | ||
| #include <cstdlib> | ||
| #include <fstream> | ||
| #include <sstream> | ||
| #include <string> | ||
|
|
||
| #include "core/graph_iterator_proto.hpp" | ||
| #include "input_model.hpp" | ||
|
|
@@ -48,6 +52,54 @@ using ::ONNX_NAMESPACE::ModelProto; | |
| using ::ONNX_NAMESPACE::Version; | ||
|
|
||
| namespace { | ||
|
|
||
| bool is_graph_iterator_enabled() { | ||
| const char* env_value = std::getenv("ONNX_ITERATOR"); | ||
| if (env_value == nullptr) { | ||
| return true; // Enabled by default | ||
| } | ||
|
|
||
| std::string value(env_value); | ||
| // Remove whitespace | ||
| value.erase(std::remove_if(value.begin(), | ||
| value.end(), | ||
| [](unsigned char ch) { | ||
| return std::isspace(ch); | ||
| }), | ||
| value.end()); | ||
| // Convert to lowercase | ||
| std::transform(value.begin(), value.end(), value.begin(), [](unsigned char ch) { | ||
| return static_cast<char>(std::tolower(ch)); | ||
| }); | ||
|
|
||
| static const std::unordered_map<std::string, bool> valid_values = {{"1", true}, | ||
| {"true", true}, | ||
| {"on", true}, | ||
| {"enable", true}, | ||
| {"0", false}, | ||
| {"false", false}, | ||
| {"off", false}, | ||
| {"disable", false}}; | ||
|
|
||
| auto it = valid_values.find(value); | ||
| if (it != valid_values.end()) { | ||
| if (!it->second) { | ||
| OPENVINO_WARN( | ||
| "DEPRECATED: Disabling ONNX graph iterator via ONNX_ITERATOR environment variable is deprecated and " | ||
| "will be removed in a future release. The graph iterator will become mandatory."); | ||
| } | ||
| return it->second; | ||
| } | ||
|
|
||
| // Unknown value - print error and default to enabled | ||
| OPENVINO_WARN("Unknown value for ONNX_ITERATOR environment variable: '", | ||
|
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. I guess it might actually be better for the user if we exit here (instead of warning and continuing). Rationale: easy to miss a warning - especially if you don't know what to look for. |
||
| env_value, | ||
| "'. " | ||
| "Expected 1 (enable) or 0 (disable). " | ||
| "Defaulting to enabled."); | ||
| return true; | ||
| } | ||
|
|
||
| // !!! Experimental feature, it may be changed or removed in the future !!! | ||
| void enumerate_constants(const std::shared_ptr<ov::Model>& model) { | ||
| const auto& operations = model->get_ordered_ops(); | ||
|
|
@@ -84,7 +136,7 @@ ONNX_FRONTEND_C_API void* get_front_end_data() { | |
| } | ||
|
|
||
| ov::frontend::InputModel::Ptr FrontEnd::load_impl(const std::vector<ov::Any>& variants) const { | ||
| const bool gi_enabled = std::getenv("ONNX_ITERATOR") != nullptr; | ||
| const bool gi_enabled = is_graph_iterator_enabled(); | ||
| if (variants.empty()) { | ||
| return nullptr; | ||
| } | ||
|
|
||
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
Oops, something went wrong.
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.