Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

Enable GraphIterator interface by default (#33400)

Maxim Vafin69f44a80c06f
diff --git a/.github/workflows/job_cxx_unit_tests.yml b/.github/workflows/job_cxx_unit_tests.yml
index 0ff37ba0bc6..989c7d34137 100644
--- a/.github/workflows/job_cxx_unit_tests.yml
+++ b/.github/workflows/job_cxx_unit_tests.yml
@@ -140,11 +140,19 @@ jobs:
${{ env.SOURCE_COMMAND }} ${{ env.SETUPVARS }}
${{ env.INSTALL_TEST_DIR }}/paddle_tests --gtest_filter="PaddleFuzzyOpTest*" --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-PaddleFuzzyOpTests.xml
- - name: ONNX frontend tests
+ - name: ONNX frontend tests (GraphIterator default)
if: ${{ fromJSON(inputs.affected-components).ONNX_FE.test && runner.arch != 'ARM64' }} # Ticket for macOS ARM64: 122663, for Linux ARM64: 126280, 153161
run: |
${{ env.SOURCE_COMMAND }} ${{ env.SETUPVARS }}
- ${{ env.INSTALL_TEST_DIR }}/ov_onnx_frontend_tests --gtest_print_time=1 --gtest_filter=-*IE_GPU* --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-ONNXFrontend.xml
+ ${{ env.INSTALL_TEST_DIR }}/ov_onnx_frontend_tests --gtest_print_time=1 --gtest_filter=-*IE_GPU* --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-ONNXFrontend-GraphIteratorEnabled.xml
+
+ - name: ONNX frontend tests ONNX_ITERATOR=disabled (legacy implementation)
+ if: ${{ fromJSON(inputs.affected-components).ONNX_FE.test && runner.arch != 'ARM64' }} # Ticket for macOS ARM64: 122663, for Linux ARM64: 126280, 153161
+ env:
+ ONNX_ITERATOR: "0"
+ run: |
+ ${{ env.SOURCE_COMMAND }} ${{ env.SETUPVARS }}
+ ${{ env.INSTALL_TEST_DIR }}/ov_onnx_frontend_tests --gtest_print_time=1 --gtest_filter=-*IE_GPU* --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-ONNXFrontend-GraphIteratorDisabled.xml
- name: TensorFlow Common frontend tests
if: fromJSON(inputs.affected-components).TF_FE.test ||
diff --git a/.github/workflows/job_python_unit_tests.yml b/.github/workflows/job_python_unit_tests.yml
index 8d8b2644ea4..0dbadde38cd 100644
--- a/.github/workflows/job_python_unit_tests.yml
+++ b/.github/workflows/job_python_unit_tests.yml
@@ -118,7 +118,19 @@ jobs:
run: |
# Skip test_onnx/test_zoo_models and test_onnx/test_backend due to long execution time - ONNX Model Zoo tests are run separately
python3 -m pytest -sv ${INSTALL_TEST_DIR}/onnx -k 'not cuda' \
- --junitxml=${INSTALL_TEST_DIR}/TEST-onnx_frontend.xml \
+ --junitxml=${INSTALL_TEST_DIR}/TEST-onnx_frontend.graph_iterator_enabled.xml \
+ --ignore=${INSTALL_TEST_DIR}/onnx/test_python/test_zoo_models.py
+
+ - name: Python ONNX operators tests ONNX_ITERATOR=disabled (legacy implementation)
+ if: (fromJSON(inputs.affected-components).Python_API.test ||
+ fromJSON(inputs.affected-components).ONNX_FE.test) &&
+ runner.arch != 'ARM64' # Ticket: 123325
+ env:
+ ONNX_ITERATOR: "0"
+ run: |
+ # Skip test_onnx/test_zoo_models and test_onnx/test_backend due to long execution time - ONNX Model Zoo tests are run separately
+ python3 -m pytest -sv ${INSTALL_TEST_DIR}/onnx -k 'not cuda' \
+ --junitxml=${INSTALL_TEST_DIR}/TEST-onnx_frontend.graph_iterator_disabled.xml \
--ignore=${INSTALL_TEST_DIR}/onnx/test_python/test_zoo_models.py
- name: OVC unit tests
diff --git a/src/frontends/onnx/frontend/src/core/decoder_proto.cpp b/src/frontends/onnx/frontend/src/core/decoder_proto.cpp
index 25f2fde9116..6002dbc80fb 100644
--- a/src/frontends/onnx/frontend/src/core/decoder_proto.cpp
+++ b/src/frontends/onnx/frontend/src/core/decoder_proto.cpp
@@ -7,9 +7,9 @@
#include <onnx/onnx_pb.h>
#include <fstream>
-#include <openvino/frontend/graph_iterator.hpp>
#include "graph_iterator_proto.hpp"
+#include "openvino/frontend/graph_iterator.hpp"
#include "openvino/frontend/onnx/graph_iterator.hpp"
#include "openvino/util/wstring_convert_util.hpp"
diff --git a/src/frontends/onnx/frontend/src/core/decoder_proto.hpp b/src/frontends/onnx/frontend/src/core/decoder_proto.hpp
index 2003ad8463f..b23123cd6a9 100644
--- a/src/frontends/onnx/frontend/src/core/decoder_proto.hpp
+++ b/src/frontends/onnx/frontend/src/core/decoder_proto.hpp
@@ -4,9 +4,8 @@
#pragma once
#include <onnx/onnx_pb.h>
-#include <openvino/frontend/graph_iterator.hpp>
-
#include "graph_iterator_proto.hpp"
+#include "openvino/frontend/graph_iterator.hpp"
#include "openvino/frontend/onnx/decoder.hpp"
#include "openvino/frontend/onnx/graph_iterator.hpp"
#include "openvino/util/wstring_convert_util.hpp"
diff --git a/src/frontends/onnx/frontend/src/core/graph_iterator_proto.cpp b/src/frontends/onnx/frontend/src/core/graph_iterator_proto.cpp
index e69360fd0a4..788f4d3e72c 100644
--- a/src/frontends/onnx/frontend/src/core/graph_iterator_proto.cpp
+++ b/src/frontends/onnx/frontend/src/core/graph_iterator_proto.cpp
@@ -20,6 +20,7 @@
#include "openvino/frontend/onnx/graph_iterator.hpp"
#include "openvino/util/file_util.hpp"
#include "openvino/util/wstring_convert_util.hpp"
+#include "transform.hpp"
namespace {
// THis is copied from utils/common.hpp
@@ -66,6 +67,27 @@ const ov::element::Type& get_ov_element_type(int64_t onnx_type) {
}
throw std::runtime_error("Unsupported type");
}
+
+void fixup_legacy_nodes(::ONNX_NAMESPACE::ModelProto& model_proto) {
+ auto* graph_proto = model_proto.mutable_graph();
+ if (!graph_proto) {
+ return;
+ }
+ constexpr const char legacy_domain[] = "org.openvinotoolkit";
+
+ for (auto& node : *graph_proto->mutable_node()) {
+ const auto needs_fix = std::find(ov::frontend::onnx::transform::legacy_ops_to_fixup.begin(),
+ ov::frontend::onnx::transform::legacy_ops_to_fixup.end(),
+ node.op_type()) != ov::frontend::onnx::transform::legacy_ops_to_fixup.end();
+ if (!needs_fix) {
+ continue;
+ }
+
+ if (!node.has_domain() || node.domain().empty() || node.domain() == "ai.onnx") {
+ node.set_domain(legacy_domain);
+ }
+ }
+}
} // namespace
namespace ov {
@@ -314,16 +336,17 @@ GraphIteratorProto::GraphIteratorProto(GraphIteratorProto* parent, const GraphPr
}
void GraphIteratorProto::initialize(const std::filesystem::path& path) {
- const auto path_str = ov::util::path_to_string(path);
m_model_dir = ov::util::get_directory(path);
+ const auto path_string = ov::util::path_to_string(path);
try {
std::ifstream model_file(path, std::ios::binary | std::ios::in);
- FRONT_END_GENERAL_CHECK(model_file && model_file.is_open(), "Could not open the file: \"", path_str, "\"");
+ FRONT_END_GENERAL_CHECK(model_file && model_file.is_open(), "Could not open the file: \"", path_string, "\"");
m_model = std::make_shared<ModelProto>();
FRONT_END_GENERAL_CHECK(m_model->ParseFromIstream(&model_file), "Model can't be parsed");
model_file.close();
if (m_model->has_graph()) {
+ fixup_legacy_nodes(*m_model);
m_graph = &m_model->graph();
} else {
m_graph = nullptr;
@@ -338,7 +361,6 @@ void GraphIteratorProto::initialize(const std::filesystem::path& path) {
throw;
}
}
-
std::shared_ptr<DecoderProtoTensor> GraphIteratorProto::get_tensor(const std::string& name,
GraphIteratorProto** owner) {
if (m_tensors.count(name) == 0) {
diff --git a/src/frontends/onnx/frontend/src/core/graph_iterator_proto.hpp b/src/frontends/onnx/frontend/src/core/graph_iterator_proto.hpp
index 587e50c0ff4..1d07518a29a 100644
--- a/src/frontends/onnx/frontend/src/core/graph_iterator_proto.hpp
+++ b/src/frontends/onnx/frontend/src/core/graph_iterator_proto.hpp
@@ -148,6 +148,8 @@ protected:
/// \param name Name of tensor
/// \param owner Returns real owner of the tensor
std::shared_ptr<DecoderProtoTensor> get_tensor(const std::string& name, GraphIteratorProto** owner);
+
+private:
};
} // namespace onnx
diff --git a/src/frontends/onnx/frontend/src/core/node.cpp b/src/frontends/onnx/frontend/src/core/node.cpp
index 6e404ecb6bc..8c3a459a843 100644
--- a/src/frontends/onnx/frontend/src/core/node.cpp
+++ b/src/frontends/onnx/frontend/src/core/node.cpp
@@ -221,7 +221,32 @@ Subgraph Node::Impl::get_attribute_value(const std::string& name) const {
template <>
ov::Any Node::get_attribute_value(const std::string& name) const {
- return get_attribute(name).get_any();
+ if (m_pimpl != nullptr) {
+ return get_attribute(name).get_any();
+ } else if (m_decoder != nullptr) {
+ if (!m_decoder->has_attribute(name)) {
+ throw error::node::UnknownAttribute{this->get_name(), name};
+ }
+ auto attribute_value = m_decoder->get_attribute(name);
+ // We upcast decoder-provided floats here to align the behavior of OpExtension with the legacy approach and
+ // keep both code paths identical.
+ if (attribute_value.is<float>()) {
+ return static_cast<double>(attribute_value.as<float>());
+ } else if (attribute_value.is<std::vector<float>>()) {
+ const auto& float_values = attribute_value.as<std::vector<float>>();
+ std::vector<double> double_values;
+ double_values.reserve(float_values.size());
+ std::transform(float_values.begin(),
+ float_values.end(),
+ std::back_inserter(double_values),
+ [](float v) -> double {
+ return v;
+ });
+ return double_values;
+ }
+ return attribute_value;
+ }
+ FRONT_END_NOT_IMPLEMENTED(get_attribute_value);
}
template <>
diff --git a/src/frontends/onnx/frontend/src/frontend.cpp b/src/frontends/onnx/frontend/src/frontend.cpp
index 537e0e9a934..4bbd6e22758 100644
--- a/src/frontends/onnx/frontend/src/frontend.cpp
+++ b/src/frontends/onnx/frontend/src/frontend.cpp
@@ -17,9 +17,13 @@
# include <google/protobuf/stubs/logging.h>
#endif
+#include <algorithm>
+#include <cctype>
+#include <cstdlib>
#include <filesystem>
#include <fstream>
#include <sstream>
+#include <string>
#include "core/graph_iterator_proto.hpp"
#include "input_model.hpp"
@@ -49,6 +53,51 @@ 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;
+ }
+
+ OPENVINO_THROW("Unknown value for ONNX_ITERATOR environment variable: '",
+ env_value,
+ "'. "
+ "Expected 1 (enable) or 0 (disable).");
+}
+
// !!! 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();
@@ -85,7 +134,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;
}
diff --git a/src/frontends/onnx/frontend/src/input_model.hpp b/src/frontends/onnx/frontend/src/input_model.hpp
index 30dd36b55db..f62f7267947 100644
--- a/src/frontends/onnx/frontend/src/input_model.hpp
+++ b/src/frontends/onnx/frontend/src/input_model.hpp
@@ -7,11 +7,12 @@
#include <editor.hpp>
#include <filesystem>
#include <fstream>
-#include <openvino/frontend/input_model.hpp>
#include "core/place.hpp"
#include "core/tensor.hpp"
+#include "editor.hpp"
#include "openvino/frontend/extension/holder.hpp"
+#include "openvino/frontend/input_model.hpp"
#include "openvino/frontend/onnx/graph_iterator.hpp"
using ::ONNX_NAMESPACE::ModelProto;
diff --git a/src/frontends/onnx/frontend/src/node_context.cpp b/src/frontends/onnx/frontend/src/node_context.cpp
index dcdfae10d40..bc7f54c1a66 100644
--- a/src/frontends/onnx/frontend/src/node_context.cpp
+++ b/src/frontends/onnx/frontend/src/node_context.cpp
@@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
-#include <core/node.hpp>
-#include <openvino/frontend/onnx/node_context.hpp>
-#include <utils/common.hpp>
+#include "openvino/frontend/onnx/node_context.hpp"
+
+#include "core/node.hpp"
+#include "utils/common.hpp"
ov::frontend::onnx::NodeContext::NodeContext(const ov::frontend::onnx::Node& context)
: ov::frontend::NodeContext(context.op_type()),
diff --git a/src/frontends/onnx/frontend/src/place.cpp b/src/frontends/onnx/frontend/src/place.cpp
index a8c24d364ae..026e89558cc 100644
--- a/src/frontends/onnx/frontend/src/place.cpp
+++ b/src/frontends/onnx/frontend/src/place.cpp
@@ -4,7 +4,7 @@
#include "place.hpp"
-#include <openvino/frontend/exception.hpp>
+#include "openvino/frontend/exception.hpp"
using namespace ov;
using namespace ov::frontend::onnx;
diff --git a/src/frontends/onnx/frontend/src/place.hpp b/src/frontends/onnx/frontend/src/place.hpp
index 7bf215c2797..4e055bce7b5 100644
--- a/src/frontends/onnx/frontend/src/place.hpp
+++ b/src/frontends/onnx/frontend/src/place.hpp
@@ -4,11 +4,12 @@
#pragma once
-#include <editor.hpp>
#include <memory>
-#include <openvino/frontend/place.hpp>
#include <sstream>
+#include "editor.hpp"
+#include "openvino/frontend/place.hpp"
+
namespace ov {
namespace frontend {
namespace onnx {
diff --git a/src/frontends/onnx/tests/onnx_editor.cpp b/src/frontends/onnx/tests/onnx_editor.cpp
index 5ce236ffbe6..6b2f7bc78a7 100644
--- a/src/frontends/onnx/tests/onnx_editor.cpp
+++ b/src/frontends/onnx/tests/onnx_editor.cpp
@@ -10,6 +10,7 @@
#include "common_test_utils/test_case.hpp"
#include "common_test_utils/test_control.hpp"
#include "gtest/gtest.h"
+#include "onnx_editor_test_utils.hpp"
#include "onnx_utils.hpp"
#include "openvino/op/constant.hpp"
@@ -85,6 +86,7 @@ OPENVINO_TEST(onnx_editor, types__all_inputs_type_substitution) {
}
OPENVINO_TEST(onnx_editor, types__missing_type_in_input_descriptor) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
auto input_model = load_model("model_editor/invalid_input_no_type.onnx");
// input A doesn't have the "type" field in the model and so the data type cannot be modified
@@ -93,6 +95,7 @@ OPENVINO_TEST(onnx_editor, types__missing_type_in_input_descriptor) {
}
OPENVINO_TEST(onnx_editor, types__missing_tensor_type_in_input_descriptor) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
auto input_model = load_model("model_editor/invalid_input_no_tensor_type.onnx");
// input A doesn't have the "tensor_type" field in the model
@@ -101,6 +104,7 @@ OPENVINO_TEST(onnx_editor, types__missing_tensor_type_in_input_descriptor) {
}
OPENVINO_TEST(onnx_editor, types__unsupported_data_type_passed) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
auto input_model = load_model("model_editor/add_abc.onnx");
EXPECT_THROW(input_model->set_element_type(input_model->get_place_by_tensor_name("A"), ov::element::dynamic),
@@ -251,6 +255,7 @@ OPENVINO_TEST(onnx_editor, shapes__static_to_dynamic_rank_substitution) {
}
OPENVINO_TEST(onnx_editor, subgraph__linear_model_head_cut) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph__inception_head.onnx", &front_end);
@@ -266,6 +271,7 @@ OPENVINO_TEST(onnx_editor, subgraph__linear_model_head_cut) {
}
OPENVINO_TEST(onnx_editor, subgraph__linear_model_head_cut_ins_and_outs) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph__inception_head.onnx", &front_end);
@@ -281,6 +287,7 @@ OPENVINO_TEST(onnx_editor, subgraph__linear_model_head_cut_ins_and_outs) {
}
OPENVINO_TEST(onnx_editor, subgraph__linear_model_deeper_head_cut) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph__inception_head.onnx", &front_end);
@@ -296,6 +303,7 @@ OPENVINO_TEST(onnx_editor, subgraph__linear_model_deeper_head_cut) {
}
OPENVINO_TEST(onnx_editor, subgraph__linear_model_tail_cut) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph__inception_head.onnx", &front_end);
@@ -311,6 +319,7 @@ OPENVINO_TEST(onnx_editor, subgraph__linear_model_tail_cut) {
}
OPENVINO_TEST(onnx_editor, subgraph__linear_model_tail_cut_ins_and_outs) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph__inception_head.onnx", &front_end);
@@ -326,6 +335,7 @@ OPENVINO_TEST(onnx_editor, subgraph__linear_model_tail_cut_ins_and_outs) {
}
OPENVINO_TEST(onnx_editor, subgraph__linear_model_with_initializer_tail_cut) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph__inception_head_with_initializer.onnx", &front_end);
@@ -341,6 +351,7 @@ OPENVINO_TEST(onnx_editor, subgraph__linear_model_with_initializer_tail_cut) {
}
OPENVINO_TEST(onnx_editor, subgraph__initializer_without_matching_input_tail_cut) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph__initializer_without_matching_input.onnx", &front_end);
@@ -356,6 +367,7 @@ OPENVINO_TEST(onnx_editor, subgraph__initializer_without_matching_input_tail_cut
}
OPENVINO_TEST(onnx_editor, subgraph__linear_model_deeper_tail_cut) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph__inception_head.onnx", &front_end);
@@ -371,6 +383,7 @@ OPENVINO_TEST(onnx_editor, subgraph__linear_model_deeper_tail_cut) {
}
OPENVINO_TEST(onnx_editor, subgraph__no_input_params) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph__inception_head.onnx", &front_end);
@@ -386,6 +399,7 @@ OPENVINO_TEST(onnx_editor, subgraph__no_input_params) {
}
OPENVINO_TEST(onnx_editor, subgraph__initializer_to_input_replacement) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph__inception_head_with_initializer.onnx", &front_end);
@@ -402,6 +416,7 @@ OPENVINO_TEST(onnx_editor, subgraph__initializer_to_input_replacement) {
}
OPENVINO_TEST(onnx_editor, subgraph__initializer_to_input_replacement_2) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph__initializer_without_matching_input.onnx", &front_end);
@@ -418,6 +433,7 @@ OPENVINO_TEST(onnx_editor, subgraph__initializer_to_input_replacement_2) {
}
OPENVINO_TEST(onnx_editor, subgraph__multiout_op_output_edge) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph_extraction_tests.onnx", &front_end);
@@ -433,6 +449,7 @@ OPENVINO_TEST(onnx_editor, subgraph__multiout_op_output_edge) {
}
OPENVINO_TEST(onnx_editor, subgraph__existing_inputs_and_outputs_based_extraction) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph_extraction_tests.onnx", &front_end);
@@ -451,6 +468,7 @@ OPENVINO_TEST(onnx_editor, subgraph__existing_inputs_and_outputs_based_extractio
}
OPENVINO_TEST(onnx_editor, subgraph__twice_input_edge_from_tensor_with_single_consumer) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/add_ab.onnx", &front_end);
@@ -473,6 +491,7 @@ OPENVINO_TEST(onnx_editor, subgraph__twice_input_edge_from_tensor_with_single_co
}
OPENVINO_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumers) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph_extraction_tests.onnx", &front_end);
@@ -500,6 +519,7 @@ OPENVINO_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consum
}
OPENVINO_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumers_2) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph_extraction_tests.onnx", &front_end);
@@ -525,6 +545,7 @@ OPENVINO_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consum
}
OPENVINO_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumers_3) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph_extraction_tests.onnx", &front_end);
@@ -551,6 +572,7 @@ OPENVINO_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consum
}
OPENVINO_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumers_4) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph_extraction_tests.onnx", &front_end);
@@ -575,6 +597,7 @@ OPENVINO_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consum
}
OPENVINO_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumers_5) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph_extraction_tests.onnx", &front_end);
@@ -600,6 +623,7 @@ OPENVINO_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consum
}
OPENVINO_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumers_custom_names) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph_extraction_tests.onnx", &front_end);
@@ -633,6 +657,7 @@ OPENVINO_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consum
}
OPENVINO_TEST(onnx_editor, subgraph__multiple_consumers_of_graph_input_relu2) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph_extraction_tests_2.onnx", &front_end);
@@ -650,6 +675,7 @@ OPENVINO_TEST(onnx_editor, subgraph__multiple_consumers_of_graph_input_relu2) {
}
OPENVINO_TEST(onnx_editor, subgraph__multiple_consumers_of_graph_initializer) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph_extraction_tests_2.onnx", &front_end);
@@ -667,6 +693,7 @@ OPENVINO_TEST(onnx_editor, subgraph__multiple_consumers_of_graph_initializer) {
}
OPENVINO_TEST(onnx_editor, subgraph__multiple_consumers_of_graph_initializer_2) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph_extraction_tests_2.onnx", &front_end);
@@ -686,6 +713,7 @@ OPENVINO_TEST(onnx_editor, subgraph__multiple_consumers_of_graph_initializer_2)
}
OPENVINO_TEST(onnx_editor, subgraph__multiple_consumers_of_graph_initializer_relu2_and_init) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph_extraction_tests_2.onnx", &front_end);
@@ -713,6 +741,7 @@ OPENVINO_TEST(onnx_editor, subgraph__multiple_consumers_of_graph_initializer_rel
}
OPENVINO_TEST(onnx_editor, subgraph__inputs_getter) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph__inception_head.onnx", &front_end);
@@ -732,6 +761,7 @@ OPENVINO_TEST(onnx_editor, subgraph__inputs_getter) {
}
OPENVINO_TEST(onnx_editor, subgraph__custom_input_name_already_exist) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph__inception_head.onnx", &front_end);
try {
@@ -743,6 +773,7 @@ OPENVINO_TEST(onnx_editor, subgraph__custom_input_name_already_exist) {
}
OPENVINO_TEST(onnx_editor, values__append_one_initializer) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/add_1D.onnx", &front_end);
@@ -780,6 +811,7 @@ OPENVINO_TEST(onnx_editor, values__append_two_initializers_to_invalid) {
*/
OPENVINO_TEST(onnx_editor, values__modify_one_initializer) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/add_1D_with_initializers.onnx", &front_end);
@@ -793,6 +825,7 @@ OPENVINO_TEST(onnx_editor, values__modify_one_initializer) {
}
OPENVINO_TEST(onnx_editor, values__modify_two_initializers) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/add_1D_with_initializers.onnx", &front_end);
@@ -829,6 +862,7 @@ OPENVINO_TEST(onnx_editor, values__no_inputs_modify_two_initializers) {
*/
OPENVINO_TEST(onnx_editor, values__append_two_initializers_change_shape_type) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/add_1D.onnx", &front_end);
@@ -849,6 +883,7 @@ OPENVINO_TEST(onnx_editor, values__append_two_initializers_change_shape_type) {
}
OPENVINO_TEST(onnx_editor, values__append_two_initializers_mixed_types) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("gather_elements_float_3D_axis_2.onnx", &front_end);
auto place = input_model->get_place_by_tensor_name("data");
@@ -868,6 +903,7 @@ OPENVINO_TEST(onnx_editor, values__append_two_initializers_mixed_types) {
}
OPENVINO_TEST(onnx_editor, combined__cut_and_replace_shape) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/subgraph__inception_head.onnx", &front_end);
@@ -889,6 +925,7 @@ OPENVINO_TEST(onnx_editor, combined__cut_and_replace_shape) {
}
OPENVINO_TEST(onnx_editor, cut_operator_with_no_schema) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/unknown_input_value_info.onnx", &front_end);
input_model->extract_subgraph({input_model->get_place_by_tensor_name("X")}, {});
@@ -961,6 +998,7 @@ OPENVINO_TEST(onnx_editor, model_output) {
}
OPENVINO_TEST(onnx_editor, get_tensor_shape) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
auto input_model = load_model("model_editor/subgraph_extraction_tests.onnx");
EXPECT_EQ(input_model->get_partial_shape(input_model->get_place_by_tensor_name("mul2")),
(PartialShape{1, 1, 2, 2}));
@@ -979,6 +1017,7 @@ OPENVINO_TEST(onnx_editor, get_tensor_shape) {
}
OPENVINO_TEST(onnx_editor, get_tensor_shape_after_modification) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
auto input_model = load_model("model_editor/subgraph_extraction_tests.onnx");
EXPECT_EQ(input_model->get_partial_shape(input_model->get_place_by_tensor_name("in3")), (PartialShape{1, 1, 2, 2}));
EXPECT_EQ(input_model->get_partial_shape(input_model->get_place_by_tensor_name("conv1")),
@@ -1008,6 +1047,7 @@ OPENVINO_TEST(onnx_editor, is_correct_tensor_name) {
}
OPENVINO_TEST(onnx_editor, get_input_ports) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
auto input_model = load_model("model_editor/subgraph_extraction_tests.onnx");
const auto ports_1 = input_model->get_place_by_operation_name("relu1_name");
ASSERT_TRUE(ports_1 != nullptr) << "get_place_by_operation_name(\"relu1_name\") returned nullptr";
@@ -1027,6 +1067,7 @@ OPENVINO_TEST(onnx_editor, get_input_ports) {
}
OPENVINO_TEST(onnx_editor, get_output_ports) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
auto input_model = load_model("model_editor/subgraph_extraction_tests.onnx");
const auto ports_1 = input_model->get_place_by_operation_name("relu1_name");
ASSERT_TRUE(ports_1 != nullptr) << "get_place_by_operation_name(\"relu1_name\") returned nullptr";
@@ -1066,6 +1107,7 @@ OPENVINO_TEST(onnx_editor, get_output_ports) {
}
OPENVINO_TEST(onnx_editor, add_output) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
auto input_model = load_model("model_editor/add_abc.onnx");
auto add_node1_place = input_model->get_place_by_operation_name("add_node1");
@@ -1087,6 +1129,7 @@ OPENVINO_TEST(onnx_editor, get_tensor_element_type) {
}
OPENVINO_TEST(onnx_editor, subgraph__duplicated_output) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/add_ab_duplicated_output.onnx", &front_end);
const auto y_out = input_model->get_place_by_tensor_name("Y");
@@ -1104,6 +1147,7 @@ OPENVINO_TEST(onnx_editor, subgraph__duplicated_output) {
}
OPENVINO_TEST(onnx_editor, subgraph__duplicated_output_2) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/add_ab_duplicated_output.onnx", &front_end);
const auto y_out_1 = input_model->get_place_by_tensor_name("Y");
@@ -1123,6 +1167,7 @@ OPENVINO_TEST(onnx_editor, subgraph__duplicated_output_2) {
}
OPENVINO_TEST(onnx_editor, onnx_shape_infer_exception) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
auto input_model = load_model("model_editor/onnx_shape_infer_exception.onnx");
EXPECT_NO_THROW(input_model->extract_subgraph({input_model->get_place_by_operation_name("input_ReduceMin")}, {}));
diff --git a/src/frontends/onnx/tests/onnx_editor_test_utils.hpp b/src/frontends/onnx/tests/onnx_editor_test_utils.hpp
new file mode 100644
index 00000000000..69e7452825e
--- /dev/null
+++ b/src/frontends/onnx/tests/onnx_editor_test_utils.hpp
@@ -0,0 +1,29 @@
+// Copyright (C) 2018-2025 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include "gtest/gtest.h"
+#include "onnx_utils.hpp"
+
+namespace ov {
+namespace frontend {
+namespace onnx {
+namespace tests {
+
+inline const char* editor_skip_message() {
+ return "ONNX Editor functionality is not available when the GraphIterator is enabled. Set ONNX_ITERATOR=0 to run this test.";
+}
+
+} // namespace tests
+} // namespace onnx
+} // namespace frontend
+} // namespace ov
+
+#define SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED() \
+ do { \
+ if (::ov::frontend::onnx::tests::is_graph_iterator_enabled()) { \
+ GTEST_SKIP() << ::ov::frontend::onnx::tests::editor_skip_message(); \
+ } \
+ } while (0)
diff --git a/src/frontends/onnx/tests/onnx_editor_topological_sort.cpp b/src/frontends/onnx/tests/onnx_editor_topological_sort.cpp
index 4434d405917..e07421e5a41 100644
--- a/src/frontends/onnx/tests/onnx_editor_topological_sort.cpp
+++ b/src/frontends/onnx/tests/onnx_editor_topological_sort.cpp
@@ -8,6 +8,7 @@
#include "common_test_utils/test_case.hpp"
#include "common_test_utils/test_control.hpp"
#include "gtest/gtest.h"
+#include "onnx_editor_test_utils.hpp"
#include "onnx_utils.hpp"
using namespace ov;
@@ -17,18 +18,21 @@ using namespace ov::frontend::onnx::tests;
static std::string s_manifest = onnx_backend_manifest("${MANIFEST}");
OPENVINO_TEST(onnx_editor, topological_sort_two_nodes_swap) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/topological_sort/two_nodes_swap.onnx", &front_end);
OV_ASSERT_NO_THROW(front_end->convert(input_model));
}
OPENVINO_TEST(onnx_editor, topological_sort_completely_unsorted) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/topological_sort/completely_unsorted.onnx", &front_end);
OV_ASSERT_NO_THROW(front_end->convert(input_model));
}
OPENVINO_TEST(onnx_editor, topological_sort_completely_unsorted_2) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/topological_sort/completely_unsorted_2.onnx", &front_end);
OV_ASSERT_NO_THROW(front_end->convert(input_model));
@@ -36,6 +40,7 @@ OPENVINO_TEST(onnx_editor, topological_sort_completely_unsorted_2) {
#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
OPENVINO_TEST(onnx_editor, topological_sort_completely_unsorted_2_wstring) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
FrontEnd::Ptr front_end;
auto input_model = load_model(L"model_editor/topological_sort/completely_unsorted_2.onnx", &front_end);
OV_ASSERT_NO_THROW(front_end->convert(input_model));
@@ -43,6 +48,7 @@ OPENVINO_TEST(onnx_editor, topological_sort_completely_unsorted_2_wstring) {
#endif
OPENVINO_TEST(onnx_editor, topological_sort_constant_node_in_the_graph) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
const std::string rel_path_to_model = "model_editor/topological_sort/add_abc_const_node_unsorted.onnx";
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/topological_sort/completely_unsorted_2.onnx", &front_end);
@@ -51,6 +57,7 @@ OPENVINO_TEST(onnx_editor, topological_sort_constant_node_in_the_graph) {
}
OPENVINO_TEST(onnx_editor, topological_sort_multioutput_node) {
+ SKIP_ONNX_EDITOR_IF_GRAPH_ITERATOR_ENABLED();
const std::string rel_path_to_model = "model_editor/topological_sort/multioutput_split_unsorted.onnx";
FrontEnd::Ptr front_end;
auto input_model = load_model("model_editor/topological_sort/completely_unsorted_2.onnx", &front_end);
diff --git a/src/frontends/onnx/tests/onnx_import_org_openvino.in.cpp b/src/frontends/onnx/tests/onnx_import_org_openvino.in.cpp
index 6c13447da11..2a736960499 100644
--- a/src/frontends/onnx/tests/onnx_import_org_openvino.in.cpp
+++ b/src/frontends/onnx/tests/onnx_import_org_openvino.in.cpp
@@ -2,7 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
//
-#include <algorithm>
#include <cmath>
#include <cstdint>
#include <fstream>
@@ -420,7 +419,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_experimental_detectron_generate_propos
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_experimental_detectron_group_norm) {
- if (std::getenv("ONNX_ITERATOR")) {
+ if (is_graph_iterator_enabled()) {
GTEST_SKIP() << "Experimental ops are not supported when using GraphIterator.";
}
auto model = convert_model("org.openvinotoolkit/experimental_detectron/group_norm.onnx");
@@ -539,9 +538,6 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_experimental_detectron_topk_rios) {
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_deformable_conv_2d) {
- if (std::getenv("ONNX_ITERATOR")) {
- GTEST_SKIP() << "Experimental ops are not supported when using GraphIterator.";
- }
auto model = convert_model("org.openvinotoolkit/deformable_conv_2d.onnx");
auto test_case = ov::test::TestCase(model, s_device);
@@ -572,7 +568,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_deformable_conv_2d) {
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_deformable_conv_2d_with_mask) {
- if (std::getenv("ONNX_ITERATOR")) {
+ if (is_graph_iterator_enabled()) {
GTEST_SKIP() << "Experimental ops are not supported when using GraphIterator.";
}
auto model = convert_model("org.openvinotoolkit/deformable_conv_2d_with_mask.onnx");
diff --git a/src/frontends/onnx/tests/onnx_utils.cpp b/src/frontends/onnx/tests/onnx_utils.cpp
index 9893387f1aa..b06ce0741b6 100644
--- a/src/frontends/onnx/tests/onnx_utils.cpp
+++ b/src/frontends/onnx/tests/onnx_utils.cpp
@@ -4,9 +4,9 @@
#include "onnx_utils.hpp"
-#include <openvino/runtime/core.hpp>
#include <vector>
+#include "openvino/runtime/core.hpp"
#include "utils.hpp"
using namespace std;
diff --git a/src/frontends/onnx/tests/onnx_utils.hpp b/src/frontends/onnx/tests/onnx_utils.hpp
index d34813d2e55..639af66b284 100644
--- a/src/frontends/onnx/tests/onnx_utils.hpp
+++ b/src/frontends/onnx/tests/onnx_utils.hpp
@@ -4,12 +4,16 @@
#pragma once
-#include <stdlib.h>
-
+#include <algorithm>
+#include <cctype>
+#include <cstdlib>
+#include <iostream>
+#include <stdexcept>
#include <string>
+#include <unordered_map>
-#include "common_test_utils/test_constants.hpp"
#include "common_test_utils/test_assertions.hpp"
+#include "common_test_utils/test_constants.hpp"
#include "openvino/core/model.hpp"
#include "openvino/frontend/extension.hpp"
#include "openvino/frontend/manager.hpp"
@@ -46,6 +50,45 @@ InputModel::Ptr load_model(const std::string& model_path, ov::frontend::FrontEnd
InputModel::Ptr load_model(const std::wstring& model_path, ov::frontend::FrontEnd::Ptr* return_front_end = nullptr);
// Returns path to a manifest file
std::string onnx_backend_manifest(const std::string& manifest);
+
+// Duplicate implementation for tests - will be removed when ONNX_ITERATOR is removed
+inline 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()) {
+ return it->second;
+ }
+
+ throw std::runtime_error(std::string{"Unknown value for ONNX_ITERATOR environment variable: '"} + env_value +
+ "'. Expected 1 (enable) or 0 (disable).");
+}
+
} // namespace tests
} // namespace onnx
} // namespace frontend
diff --git a/src/frontends/onnx/tests/tests_python/test_frontend_onnx.py b/src/frontends/onnx/tests/tests_python/test_frontend_onnx.py
index aada9099ec1..edff367c969 100644
--- a/src/frontends/onnx/tests/tests_python/test_frontend_onnx.py
+++ b/src/frontends/onnx/tests/tests_python/test_frontend_onnx.py
@@ -17,6 +17,21 @@ from openvino.frontend import FrontEndManager
from tests.runtime import get_runtime
+def _is_graph_iterator_enabled():
+ env_value = os.environ.get("ONNX_ITERATOR")
+ if env_value is None:
+ return True
+ value = env_value.strip().lower()
+ return value not in {"", "0", "false", "off", "disable"}
+
+
+DECODE_AND_CONVERT_XFAIL = pytest.mark.xfail(
+ condition=_is_graph_iterator_enabled(),
+ reason="Decoding via GraphIterator is not supported yet",
+ strict=True,
+)
+
+
def create_onnx_model():
add = onnx.helper.make_node("Add", inputs=["x", "y"], outputs=["z"])
const_tensor = onnx.helper.make_tensor(
@@ -255,6 +270,7 @@ def test_convert():
run_model(converted_model, input_1, input_2, expected=[expected])
+@DECODE_AND_CONVERT_XFAIL
@pytest.mark.parametrize(
("model_filename", "inputs", "expected"),
[
diff --git a/src/frontends/onnx/tests/tests_python/test_frontend_onnx_editor.py b/src/frontends/onnx/tests/tests_python/test_frontend_onnx_editor.py
index 9c7b087dec5..04d26fee95f 100644
--- a/src/frontends/onnx/tests/tests_python/test_frontend_onnx_editor.py
+++ b/src/frontends/onnx/tests/tests_python/test_frontend_onnx_editor.py
@@ -370,6 +370,27 @@ def create_test_onnx_models():
fem = FrontEndManager()
test_models_names = []
ONNX_FRONTEND_NAME = "onnx"
+EDITOR_SKIP_MESSAGE = (
+ "ONNX Editor functionality is not available when the GraphIterator is enabled. "
+ "Set ONNX_ITERATOR=0 to run these tests."
+)
+
+
+def _is_graph_iterator_enabled():
+ value = os.environ.get("ONNX_ITERATOR")
+ if value is None:
+ return True
+
+ normalized = "".join(value.split()).lower()
+ return normalized not in ("", "0", "false", "off", "disable")
+
+
+ONNX_GRAPH_ITERATOR_ENABLED = _is_graph_iterator_enabled()
+EDITOR_XFAIL_MARK = pytest.mark.xfail(
+ ONNX_GRAPH_ITERATOR_ENABLED,
+ reason=EDITOR_SKIP_MESSAGE,
+ strict=True,
+)
def setup_module():
@@ -390,6 +411,62 @@ def skip_if_onnx_frontend_is_disabled():
pytest.skip()
+def _ensure_editor_place(place, description):
+ if place is None:
+ if ONNX_GRAPH_ITERATOR_ENABLED:
+ pytest.xfail(f"{EDITOR_SKIP_MESSAGE} Missing {description}.")
+ pytest.skip(f"{EDITOR_SKIP_MESSAGE} Missing {description}.")
+ return place
+
+
+def get_tensor_place(model, tensor_name, required=True):
+ place = model.get_place_by_tensor_name(tensor_name=tensor_name)
+ if not required:
+ return place
+ return _ensure_editor_place(place, f"tensor '{tensor_name}'")
+
+
+def get_operation_place(model, operation_name, required=True):
+ place = model.get_place_by_operation_name(operation_name=operation_name)
+ if not required:
+ return place
+ return _ensure_editor_place(place, f"operation '{operation_name}'")
+
+
+def get_operation_input_port_place(model, operation_name, input_port_index, required=True):
+ place = model.get_place_by_operation_name_and_input_port(operation_name=operation_name,
+ input_port_index=input_port_index)
+ if not required:
+ return place
+ return _ensure_editor_place(place,
+ f"input port {input_port_index} of operation '{operation_name}'")
+
+
+def get_operation_output_port_place(model,
+ operation_name,
+ output_port_index=None,
+ output_name=None,
+ required=True):
+ place = None
+ if output_name is not None:
+ operation = get_operation_place(model, operation_name, required=False)
+ if operation is not None:
+ place = operation.get_output_port(output_name=output_name)
+ else:
+ if output_port_index is None:
+ raise ValueError("output_port_index must be provided when output_name is None")
+ place = model.get_place_by_operation_name_and_output_port(operation_name,
+ output_port_index)
+ if not required:
+ return place
+ target = (
+ f"output port {output_port_index}"
+ if output_name is None
+ else f"output '{output_name}'"
+ )
+ return _ensure_editor_place(place, f"{target} of operation '{operation_name}'")
+
+
# Function to compare OV Models (ops names, types and shapes).
# Note that the functions uses get_ordered_ops, so the topological order of ops should be also preserved.
def compare_models(current, expected): # noqa: C901 the function is too complex
@@ -436,6 +513,7 @@ def compare_models(current, expected): # noqa: C901 the function is too complex
return result
+@EDITOR_XFAIL_MARK
def test_extract_subgraph():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
@@ -444,9 +522,9 @@ def test_extract_subgraph():
model = fe.load("input_model.onnx")
assert model
- place1 = model.get_place_by_tensor_name(tensor_name="add_out").get_input_port(input_port_index=0) # in1
- place2 = model.get_place_by_tensor_name(tensor_name="add_out").get_input_port(input_port_index=1) # in2
- place3 = model.get_place_by_tensor_name(tensor_name="add_out")
+ place1 = get_tensor_place(model, "add_out").get_input_port(input_port_index=0) # in1
+ place2 = get_tensor_place(model, "add_out").get_input_port(input_port_index=1) # in2
+ place3 = get_tensor_place(model, "add_out")
model.extract_subgraph(inputs=[place1, place2], outputs=[place3])
result_model = fe.convert(model)
@@ -456,6 +534,7 @@ def test_extract_subgraph():
assert res
+@EDITOR_XFAIL_MARK
def test_extract_subgraph_2():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
@@ -464,8 +543,8 @@ def test_extract_subgraph_2():
model = fe.load("input_model.onnx")
assert model
- place1 = model.get_place_by_tensor_name(tensor_name="out3")
- place2 = model.get_place_by_tensor_name(tensor_name="add_out")
+ place1 = get_tensor_place(model, "out3")
+ place2 = get_tensor_place(model, "add_out")
model.extract_subgraph(inputs=[], outputs=[place1, place2])
result_model = fe.convert(model)
@@ -483,9 +562,9 @@ def test_extract_subgraph_3():
model = fe.load("input_model.onnx")
assert model
- place1 = model.get_place_by_operation_name_and_input_port(operation_name="split1", input_port_index=0)
- place2 = model.get_place_by_tensor_name(tensor_name="out1")
- place3 = model.get_place_by_tensor_name(tensor_name="out2")
+ place1 = get_operation_input_port_place(model, operation_name="split1", input_port_index=0)
+ place2 = get_tensor_place(model, "out1")
+ place3 = get_tensor_place(model, "out2")
model.extract_subgraph(inputs=[place1], outputs=[place2, place3])
result_model = fe.convert(model)
@@ -503,13 +582,13 @@ def test_extract_subgraph_4():
model = fe.load("input_model.onnx")
assert model
- out4_tensor = model.get_place_by_tensor_name(tensor_name="out4")
- place1 = model.get_place_by_operation_name_and_input_port(operation_name="split1", input_port_index=0)
+ out4_tensor = get_tensor_place(model, "out4")
+ place1 = get_operation_input_port_place(model, operation_name="split1", input_port_index=0)
place2 = out4_tensor.get_producing_operation().get_input_port(input_port_index=0)
place3 = out4_tensor.get_producing_operation().get_input_port(input_port_index=1)
- place4 = model.get_place_by_tensor_name(tensor_name="out1")
- place5 = model.get_place_by_tensor_name(tensor_name="out2")
- place6 = model.get_place_by_tensor_name(tensor_name="out4")
+ place4 = get_tensor_place(model, "out1")
+ place5 = get_tensor_place(model, "out2")
+ place6 = get_tensor_place(model, "out4")
model.extract_subgraph(inputs=[place1, place2, place3], outputs=[place4, place5, place6])
result_func = fe.convert(model)
@@ -527,11 +606,11 @@ def test_extract_subgraph_by_op_place_as_input():
model = fe.load("input_model.onnx")
assert model
- split_op = model.get_place_by_operation_name(operation_name="split1")
- out4 = model.get_place_by_tensor_name(tensor_name="out4")
+ split_op = get_operation_place(model, "split1")
+ out4 = get_tensor_place(model, "out4")
mul_op = out4.get_producing_operation()
- out1 = model.get_place_by_tensor_name(tensor_name="out1")
- out2 = model.get_place_by_tensor_name(tensor_name="out2")
+ out1 = get_tensor_place(model, "out1")
+ out2 = get_tensor_place(model, "out2")
model.extract_subgraph(inputs=[split_op, mul_op], outputs=[out1, out2, out4])
result_model = fe.convert(model)
@@ -542,6 +621,7 @@ def test_extract_subgraph_by_op_place_as_input():
assert res
+@EDITOR_XFAIL_MARK
def test_extract_subgraph_by_op_place_as_output():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
@@ -550,9 +630,9 @@ def test_extract_subgraph_by_op_place_as_output():
model = fe.load("input_model.onnx")
assert model
- in1_tensor = model.get_place_by_tensor_name(tensor_name="in1")
- in2_tensor = model.get_place_by_tensor_name(tensor_name="in2")
- add_out_tensor = model.get_place_by_tensor_name(tensor_name="add_out")
+ in1_tensor = get_tensor_place(model, "in1")
+ in2_tensor = get_tensor_place(model, "in2")
+ add_out_tensor = get_tensor_place(model, "add_out")
add_op = add_out_tensor.get_producing_operation()
model.extract_subgraph(inputs=[in1_tensor, in2_tensor], outputs=[add_op])
@@ -572,8 +652,8 @@ def test_extract_subgraph_by_op_place_as_output_2():
model = fe.load("input_model.onnx")
assert model
- split_op = model.get_place_by_operation_name(operation_name="split1")
- out4 = model.get_place_by_tensor_name(tensor_name="out4")
+ split_op = get_operation_place(model, "split1")
+ out4 = get_tensor_place(model, "out4")
mul_op = out4.get_producing_operation()
model.extract_subgraph(inputs=[split_op, mul_op], outputs=[])
@@ -585,6 +665,7 @@ def test_extract_subgraph_by_op_place_as_output_2():
assert res
+@EDITOR_XFAIL_MARK
def test_extract_subgraph_by_port_place_as_output():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
@@ -593,11 +674,11 @@ def test_extract_subgraph_by_port_place_as_output():
model = fe.load("input_model.onnx")
assert model
- add_out_tensor = model.get_place_by_tensor_name(tensor_name="add_out")
+ add_out_tensor = get_tensor_place(model, "add_out")
add_op = add_out_tensor.get_producing_operation()
add_op_out_port = add_op.get_output_port(output_port_index=0)
- in1_tensor = model.get_place_by_tensor_name(tensor_name="in1")
- in2_tensor = model.get_place_by_tensor_name(tensor_name="in2")
+ in1_tensor = get_tensor_place(model, "in1")
+ in2_tensor = get_tensor_place(model, "in2")
model.extract_subgraph(inputs=[in1_tensor, in2_tensor], outputs=[add_op_out_port])
result_model = fe.convert(model)
@@ -608,6 +689,7 @@ def test_extract_subgraph_by_port_place_as_output():
assert res
+@EDITOR_XFAIL_MARK
def test_override_all_outputs():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
@@ -616,8 +698,8 @@ def test_override_all_outputs():
model = fe.load("input_model.onnx")
assert model
- place1 = model.get_place_by_tensor_name(tensor_name="out3")
- place2 = model.get_place_by_tensor_name(tensor_name="add_out")
+ place1 = get_tensor_place(model, "out3")
+ place2 = get_tensor_place(model, "add_out")
model.override_all_outputs(outputs=[place1, place2])
result_model = fe.convert(model)
@@ -627,6 +709,7 @@ def test_override_all_outputs():
assert res
+@EDITOR_XFAIL_MARK
def test_override_all_outputs_2():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
@@ -635,7 +718,7 @@ def test_override_all_outputs_2():
model = fe.load("input_model.onnx")
assert model
- place1 = model.get_place_by_tensor_name(tensor_name="out4")
+ place1 = get_tensor_place(model, "out4")
model.override_all_outputs(outputs=[place1])
result_model = fe.convert(model)
@@ -645,6 +728,7 @@ def test_override_all_outputs_2():
assert res
+@EDITOR_XFAIL_MARK
def test_override_all_outputs_3():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
@@ -653,8 +737,8 @@ def test_override_all_outputs_3():
model = fe.load("input_model_3.onnx")
assert model
- place1 = model.get_place_by_tensor_name(tensor_name="out1")
- place2 = model.get_place_by_tensor_name(tensor_name="out1")
+ place1 = get_tensor_place(model, "out1")
+ place2 = get_tensor_place(model, "out1")
model.override_all_outputs(outputs=[place1, place2])
result_model = fe.convert(model)
@@ -664,6 +748,7 @@ def test_override_all_outputs_3():
assert res
+@EDITOR_XFAIL_MARK
def test_override_all_outputs_invalid_place():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
@@ -674,10 +759,10 @@ def test_override_all_outputs_invalid_place():
model2 = fe.load("input_model.onnx")
assert model2
- invalid_place = model2.get_place_by_tensor_name(tensor_name="out3")
+ invalid_place = get_tensor_place(model2, "out3")
- place1 = model.get_place_by_tensor_name(tensor_name="out1")
- place2 = model.get_place_by_tensor_name(tensor_name="out1")
+ place1 = get_tensor_place(model, "out1")
+ place2 = get_tensor_place(model, "out1")
model.override_all_outputs(outputs=[place1, place2, invalid_place])
result_model = fe.convert(model)
@@ -695,12 +780,12 @@ def test_override_all_inputs():
model = fe.load("input_model.onnx")
assert model
- place1 = model.get_place_by_operation_name_and_input_port(
- operation_name="split1", input_port_index=0)
- out4_tensor = model.get_place_by_tensor_name(tensor_name="out4")
+ place1 = get_operation_input_port_place(
+ model, operation_name="split1", input_port_index=0)
+ out4_tensor = get_tensor_place(model, "out4")
place2 = out4_tensor.get_producing_operation().get_input_port(input_port_index=0)
place3 = out4_tensor.get_producing_operation().get_input_port(input_port_index=1)
- place4 = model.get_place_by_tensor_name(tensor_name="in3")
+ place4 = get_tensor_place(model, "in3")
model.override_all_inputs(inputs=[place1, place2, place3, place4])
result_model = fe.convert(model)
@@ -710,6 +795,7 @@ def test_override_all_inputs():
assert res
+@EDITOR_XFAIL_MARK
def test_override_all_inputs_invalid_place():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
@@ -721,10 +807,10 @@ def test_override_all_inputs_invalid_place():
model2 = fe.load("input_model.onnx")
assert model2
- out3_tensor = model2.get_place_by_tensor_name(tensor_name="out3")
+ out3_tensor = get_tensor_place(model2, "out3")
invalid_place = out3_tensor.get_producing_operation().get_input_port(input_port_index=0)
- out1_tensor = model.get_place_by_tensor_name(tensor_name="out1")
+ out1_tensor = get_tensor_place(model, "out1")
place1 = out1_tensor.get_producing_operation().get_input_port(input_port_index=0)
place2 = out1_tensor.get_producing_operation().get_input_port(input_port_index=1)
model.override_all_inputs(inputs=[place1, place2, invalid_place])
@@ -744,24 +830,24 @@ def test_is_input_output():
model = fe.load("input_model.onnx")
assert model
- place1 = model.get_place_by_tensor_name(tensor_name="in2")
+ place1 = get_tensor_place(model, "in2")
assert place1.is_input()
assert not place1.is_output()
- place2 = model.get_place_by_tensor_name(tensor_name="out2")
+ place2 = get_tensor_place(model, "out2")
assert not place2.is_input()
assert place2.is_output()
- place3 = model.get_place_by_tensor_name(tensor_name="add_out")
+ place3 = get_tensor_place(model, "add_out")
assert not place3.is_input()
assert not place3.is_output()
- place4 = model.get_place_by_operation_name_and_input_port(
- operation_name="split1", input_port_index=0)
+ place4 = get_operation_input_port_place(
+ model, operation_name="split1", input_port_index=0)
assert not place4.is_input()
assert not place4.is_output()
- place5 = model.get_place_by_operation_name(operation_name="split1")
+ place5 = get_operation_place(model, "split1")
assert not place5.is_input()
assert not place5.is_output()
@@ -774,11 +860,11 @@ def test_set_partial_shape():
model = fe.load("input_model.onnx")
assert model
- place1 = model.get_place_by_tensor_name(tensor_name="in1")
+ place1 = get_tensor_place(model, "in1")
model.set_partial_shape(place1, PartialShape([8, 16]))
- place2 = model.get_place_by_tensor_name(tensor_name="in2")
+ place2 = get_tensor_place(model, "in2")
model.set_partial_shape(place2, PartialShape([8, 16]))
- place3 = model.get_place_by_tensor_name(tensor_name="in3")
+ place3 = get_tensor_place(model, "in3")
model.set_partial_shape(place3, PartialShape([4, 6]))
result_model = fe.convert(model)
@@ -788,6 +874,7 @@ def test_set_partial_shape():
assert res
+@EDITOR_XFAIL_MARK
def test_get_partial_shape():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
@@ -796,16 +883,16 @@ def test_get_partial_shape():
model = fe.load("input_model.onnx")
assert model
- place1 = model.get_place_by_tensor_name(tensor_name="in1")
+ place1 = get_tensor_place(model, "in1")
assert model.get_partial_shape(place1) == PartialShape([2, 2])
- place2 = model.get_place_by_tensor_name(tensor_name="out1")
+ place2 = get_tensor_place(model, "out1")
assert model.get_partial_shape(place2) == PartialShape([1, 2])
- place3 = model.get_place_by_tensor_name(tensor_name="add_out")
+ place3 = get_tensor_place(model, "add_out")
assert model.get_partial_shape(place3) == PartialShape([2, 2])
- place4 = model.get_place_by_tensor_name(tensor_name="in3")
+ place4 = get_tensor_place(model, "in3")
model.set_partial_shape(place4, PartialShape([4, 6]))
assert model.get_partial_shape(place4) == PartialShape([4, 6])
assert model.get_partial_shape(place2) == PartialShape([1, 2])
@@ -841,37 +928,38 @@ def test_is_equal():
model = fe.load("input_model.onnx")
assert model
- place1 = model.get_place_by_tensor_name(tensor_name="in1")
+ place1 = get_tensor_place(model, "in1")
assert place1.is_equal(place1)
- place2 = model.get_place_by_tensor_name(tensor_name="out2")
+ place2 = get_tensor_place(model, "out2")
assert place2.is_equal(place2)
- out4_tensor = model.get_place_by_tensor_name(tensor_name="out4")
+ out4_tensor = get_tensor_place(model, "out4")
place3 = out4_tensor.get_producing_operation().get_input_port(input_port_index=0)
place4 = out4_tensor.get_producing_operation().get_input_port(input_port_index=0)
assert place3.is_equal(place4)
- out1_tensor = model.get_place_by_tensor_name(tensor_name="out1")
- place5 = model.get_place_by_operation_name_and_input_port(operation_name="split1", input_port_index=0)
+ out1_tensor = get_tensor_place(model, "out1")
+ place5 = get_operation_input_port_place(model, operation_name="split1", input_port_index=0)
place6 = out1_tensor.get_producing_operation().get_input_port(input_port_index=0)
assert place5.is_equal(place6)
- place7 = model.get_place_by_tensor_name(tensor_name="out4").get_producing_port()
+ place7 = get_tensor_place(model, "out4").get_producing_port()
assert place7.is_equal(place7)
- place8 = model.get_place_by_tensor_name(tensor_name="add_out")
+ place8 = get_tensor_place(model, "add_out")
assert place8.is_equal(place8)
assert not place1.is_equal(place2)
assert not place6.is_equal(place7)
assert not place8.is_equal(place2)
- place9 = model.get_place_by_operation_name(operation_name="split1")
+ place9 = get_operation_place(model, "split1")
assert place2.get_producing_operation().is_equal(place9)
assert not place9.is_equal(place2)
+@EDITOR_XFAIL_MARK
def test_is_equal_data():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
@@ -880,20 +968,20 @@ def test_is_equal_data():
model = fe.load("input_model.onnx")
assert model
- place1 = model.get_place_by_tensor_name(tensor_name="in1")
+ place1 = get_tensor_place(model, "in1")
assert place1.is_equal_data(place1)
- place2 = model.get_place_by_tensor_name(tensor_name="add_out")
+ place2 = get_tensor_place(model, "add_out")
assert place2.is_equal_data(place2)
- place3 = model.get_place_by_tensor_name(tensor_name="in2")
+ place3 = get_tensor_place(model, "in2")
assert not place1.is_equal_data(place3)
assert not place2.is_equal_data(place1)
place4 = place2.get_producing_port()
assert place2.is_equal_data(place4)
- out4_tensor = model.get_place_by_tensor_name(tensor_name="out4")
+ out4_tensor = get_tensor_place(model, "out4")
place5 = out4_tensor.get_producing_operation().get_input_port(input_port_index=0)
assert place2.is_equal_data(place5)
assert place4.is_equal_data(place5)
@@ -901,11 +989,11 @@ def test_is_equal_data():
place6 = out4_tensor.get_producing_operation().get_input_port(input_port_index=1)
assert place6.is_equal_data(place5)
- place7 = model.get_place_by_operation_name_and_input_port(operation_name="split1", input_port_index=0)
+ place7 = get_operation_input_port_place(model, operation_name="split1", input_port_index=0)
assert place7.is_equal_data(place7)
- place8 = model.get_place_by_tensor_name(tensor_name="out1")
- place9 = model.get_place_by_tensor_name(tensor_name="out2")
+ place8 = get_tensor_place(model, "out1")
+ place9 = get_tensor_place(model, "out2")
place10 = place8.get_producing_port()
assert not place8.is_equal_data(place9)
assert not place9.is_equal_data(place10)
@@ -920,16 +1008,16 @@ def test_get_place_by_tensor_name():
model = fe.load("input_model.onnx")
assert model
- place1 = model.get_place_by_tensor_name(tensor_name="out2")
+ place1 = get_tensor_place(model, "out2")
assert place1
- place2 = model.get_place_by_tensor_name(tensor_name="add_out")
+ place2 = get_tensor_place(model, "add_out")
assert place2
- place3 = model.get_place_by_tensor_name(tensor_name="in1")
+ place3 = get_tensor_place(model, "in1")
assert place3
- assert not model.get_place_by_tensor_name(tensor_name="0:add_out")
+ assert not get_tensor_place(model, "0:add_out", required=False)
def test_get_place_by_operation_name():
@@ -940,10 +1028,10 @@ def test_get_place_by_operation_name():
model = fe.load("input_model.onnx")
assert model
- place1 = model.get_place_by_operation_name(operation_name="split1")
+ place1 = get_operation_place(model, "split1")
assert place1
- place2 = model.get_place_by_operation_name(operation_name="not_existed")
+ place2 = get_operation_place(model, "not_existed", required=False)
assert not place2
@@ -954,7 +1042,7 @@ def test_get_output_port():
model = fe.load("input_model.onnx")
assert model
- split_op = model.get_place_by_operation_name(operation_name="split1")
+ split_op = get_operation_place(model, "split1")
place1 = split_op.get_output_port(output_port_index=0)
place2 = split_op.get_output_port(output_name="out2")
@@ -973,7 +1061,7 @@ def test_get_input_port():
model = fe.load("input_model.onnx")
assert model
- split_op = model.get_place_by_operation_name(operation_name="split1")
+ split_op = get_operation_place(model, "split1")
place1 = split_op.get_input_port(input_port_index=0)
assert place1.get_source_tensor().get_names()[0] == "add_out"
@@ -984,6 +1072,7 @@ def test_get_input_port():
assert not split_op.get_input_port(input_name="not_existed")
+@EDITOR_XFAIL_MARK
def test_add_output_place_is_not_output():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
@@ -992,13 +1081,14 @@ def test_add_output_place_is_not_output():
model = fe.load("input_model.onnx")
assert model
- place = model.get_place_by_tensor_name(tensor_name="add_out")
+ place = get_tensor_place(model, "add_out")
model.add_output(place)
out_names = [place.get_names()[0] for place in model.get_outputs()]
assert out_names == ["out1", "out2", "out3", "out4", "add_out"]
+@EDITOR_XFAIL_MARK
def test_add_output_place_is_output():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
@@ -1009,7 +1099,7 @@ def test_add_output_place_is_output():
orig_model = fe.convert(model)
- place = model.get_place_by_tensor_name(tensor_name="out1")
+ place = get_tensor_place(model, "out1")
model.add_output(place)
result_model = fe.convert(model)
@@ -1018,6 +1108,7 @@ def test_add_output_place_is_output():
assert res
+@EDITOR_XFAIL_MARK
def test_add_output_place_is_input():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
@@ -1028,7 +1119,7 @@ def test_add_output_place_is_input():
orig_model = fe.convert(model)
- place = model.get_place_by_tensor_name(tensor_name="in1")
+ place = get_tensor_place(model, "in1")
model.add_output(place)
result_model = fe.convert(model)
@@ -1043,12 +1134,12 @@ def test_get_consuming_ports():
model = fe.load("input_model.onnx")
assert model
- place1 = model.get_place_by_tensor_name(tensor_name="add_out")
+ place1 = get_tensor_place(model, "add_out")
add_tensor_consuming_ports = place1.get_consuming_ports()
assert len(add_tensor_consuming_ports) == 3
- place2 = model.get_place_by_operation_name_and_input_port(operation_name="split1", input_port_index=0)
+ place2 = get_operation_input_port_place(model, operation_name="split1", input_port_index=0)
assert add_tensor_consuming_ports[0].is_equal(place2)
- out4_tensor = model.get_place_by_tensor_name(tensor_name="out4")
+ out4_tensor = get_tensor_place(model, "out4")
place3 = out4_tensor.get_producing_operation().get_input_port(input_port_index=0)
assert add_tensor_consuming_ports[1].is_equal(place3)
place4 = out4_tensor.get_producing_operation().get_input_port(input_port_index=1)
@@ -1067,12 +1158,12 @@ def test_get_consuming_ports_2():
model = fe.load("input_model_2.onnx")
assert model
- split_op = model.get_place_by_operation_name(operation_name="split2")
+ split_op = get_operation_place(model, "split2")
split_op_consuming_ports = split_op.get_consuming_ports()
assert len(split_op_consuming_ports) == 2
- abs_input_port = model.get_place_by_operation_name(operation_name="abs1").get_input_port(input_port_index=0)
+ abs_input_port = get_operation_place(model, "abs1").get_input_port(input_port_index=0)
assert split_op_consuming_ports[0].is_equal(abs_input_port)
- out2_tensor = model.get_place_by_tensor_name(tensor_name="out2")
+ out2_tensor = get_tensor_place(model, "out2")
sin_input_port = out2_tensor.get_producing_operation().get_input_port(input_port_index=0)
assert split_op_consuming_ports[1].is_equal(sin_input_port)
@@ -1089,11 +1180,11 @@ def test_get_producing_operation():
model = fe.load("input_model_2.onnx")
assert model
- split_tensor_out_2 = model.get_place_by_tensor_name(tensor_name="sp_out2")
- split_op = model.get_place_by_operation_name(operation_name="split2")
+ split_tensor_out_2 = get_tensor_place(model, "sp_out2")
+ split_op = get_operation_place(model, "split2")
assert split_tensor_out_2.get_producing_operation().is_equal(split_op)
- split_op = model.get_place_by_operation_name(operation_name="split2")
+ split_op = get_operation_place(model, "split2")
split_out_port_2 = split_op.get_output_port(output_port_index=1)
assert split_out_port_2.get_producing_operation().is_equal(split_op)
@@ -1105,20 +1196,20 @@ def test_get_producing_operation_2():
model = fe.load("input_model_2.onnx")
assert model
- abs_op = model.get_place_by_operation_name(operation_name="abs1")
+ abs_op = get_operation_place(model, "abs1")
abs_port_0 = abs_op.get_input_port()
- split_op = model.get_place_by_operation_name(operation_name="split2")
+ split_op = get_operation_place(model, "split2")
assert abs_port_0.get_producing_operation().is_equal(split_op)
assert abs_op.get_producing_operation().is_equal(split_op)
- add_out_tensor = model.get_place_by_tensor_name(tensor_name="add_out")
+ add_out_tensor = get_tensor_place(model, "add_out")
add_op = add_out_tensor.get_producing_operation()
assert not add_op.get_producing_operation()
split_op_producing_op = split_op.get_producing_operation(input_name="add_out")
assert split_op_producing_op.is_equal(add_op)
- out2_tensor = model.get_place_by_tensor_name(tensor_name="out2")
+ out2_tensor = get_tensor_place(model, "out2")
sin_op = out2_tensor.get_producing_operation()
assert sin_op.get_producing_operation(input_port_index=0).is_equal(split_op)
@@ -1130,10 +1221,10 @@ def test_get_consuming_operations():
model = fe.load("input_model_2.onnx")
assert model
- split_op = model.get_place_by_operation_name(operation_name="split2")
+ split_op = get_operation_place(model, "split2")
split_op_consuming_ops = split_op.get_consuming_operations()
- abs_op = model.get_place_by_operation_name(operation_name="abs1")
- sin_op = model.get_place_by_tensor_name(tensor_name="out2").get_producing_operation()
+ abs_op = get_operation_place(model, "abs1")
+ sin_op = get_tensor_place(model, "out2").get_producing_operation()
assert len(split_op_consuming_ops) == 2
assert split_op_consuming_ops[0].is_equal(abs_op)
@@ -1145,17 +1236,17 @@ def test_get_consuming_operations():
assert len(split_op_port_consuming_ops) == 1
assert split_op_port_consuming_ops[0].is_equal(split_op)
- add_out_port = model.get_place_by_tensor_name(tensor_name="add_out").get_producing_port()
+ add_out_port = get_tensor_place(model, "add_out").get_producing_port()
add_out_port_consuming_ops = add_out_port.get_consuming_operations()
assert len(add_out_port_consuming_ops) == 1
assert add_out_port_consuming_ops[0].is_equal(split_op)
- sp_out2_tensor = model.get_place_by_tensor_name(tensor_name="sp_out2")
+ sp_out2_tensor = get_tensor_place(model, "sp_out2")
sp_out2_tensor_consuming_ops = sp_out2_tensor.get_consuming_operations()
assert len(sp_out2_tensor_consuming_ops) == 1
assert sp_out2_tensor_consuming_ops[0].is_equal(sin_op)
- out2_tensor = model.get_place_by_tensor_name(tensor_name="out2")
+ out2_tensor = get_tensor_place(model, "out2")
out2_tensor_consuming_ops = out2_tensor.get_consuming_operations()
assert len(out2_tensor_consuming_ops) == 0
out2_port_consuming_ops = out2_tensor.get_producing_port().get_consuming_operations()
@@ -1176,21 +1267,22 @@ def test_get_target_tensor():
model = fe.load("input_model_2.onnx")
assert model
- split_op = model.get_place_by_operation_name(operation_name="split2")
+ split_op = get_operation_place(model, "split2")
assert not split_op.get_target_tensor()
split_op_tensor_1 = split_op.get_target_tensor(output_port_index=1)
- sp_out2_tensor = model.get_place_by_tensor_name(tensor_name="sp_out2")
+ sp_out2_tensor = get_tensor_place(model, "sp_out2")
assert split_op_tensor_1.is_equal(sp_out2_tensor)
split_tensor_sp_out2 = split_op.get_target_tensor(output_name="sp_out2")
assert split_tensor_sp_out2.is_equal(split_op_tensor_1)
- abs_op = model.get_place_by_operation_name(operation_name="abs1")
- out1_tensor = model.get_place_by_tensor_name(tensor_name="out1")
+ abs_op = get_operation_place(model, "abs1")
+ out1_tensor = get_tensor_place(model, "out1")
assert abs_op.get_target_tensor().is_equal(out1_tensor)
+@EDITOR_XFAIL_MARK
def test_get_source_tensor():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
@@ -1198,18 +1290,18 @@ def test_get_source_tensor():
model = fe.load("input_model_2.onnx")
assert model
- add_out_tensor = model.get_place_by_tensor_name(tensor_name="add_out")
+ add_out_tensor = get_tensor_place(model, "add_out")
add_op = add_out_tensor.get_producing_operation()
assert not add_op.get_source_tensor()
add_op_in_tensor_1 = add_op.get_source_tensor(input_port_index=1)
- in2_tensor = model.get_place_by_tensor_name(tensor_name="in2")
+ in2_tensor = get_tensor_place(model, "in2")
assert add_op_in_tensor_1.is_equal(in2_tensor)
add_op_in_tensor_in2 = add_op.get_source_tensor(input_name="in2")
assert add_op_in_tensor_in2.is_equal(in2_tensor)
- split_op = model.get_place_by_operation_name(operation_name="split2")
+ split_op = get_operation_place(model, "split2")
assert split_op.get_source_tensor().is_equal(add_out_tensor)
@@ -1220,17 +1312,18 @@ def test_get_producing_port():
model = fe.load("input_model_2.onnx")
assert model
- split_op = model.get_place_by_operation_name(operation_name="split2")
+ split_op = get_operation_place(model, "split2")
split_op_in_port = split_op.get_input_port()
split_op_in_port_prod_port = split_op_in_port.get_producing_port()
- add_out_tensor = model.get_place_by_tensor_name(tensor_name="add_out")
+ add_out_tensor = get_tensor_place(model, "add_out")
add_op = add_out_tensor.get_producing_operation()
add_op_out_port = add_op.get_output_port()
assert split_op_in_port_prod_port.is_equal(add_op_out_port)
+@EDITOR_XFAIL_MARK
def test_remove_output():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
@@ -1239,7 +1332,7 @@ def test_remove_output():
model = fe.load("input_model.onnx")
assert model
- place = model.get_place_by_tensor_name(tensor_name="out4")
+ place = get_tensor_place(model, "out4")
model.remove_output(place)
expected_model = fe.convert(fe.load("remove_output.onnx"))
@@ -1249,6 +1342,7 @@ def test_remove_output():
assert res
+@EDITOR_XFAIL_MARK
def test_remove_output_when_place_is_input():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
@@ -1257,7 +1351,7 @@ def test_remove_output_when_place_is_input():
model = fe.load("input_model.onnx")
assert model
- place = model.get_place_by_tensor_name(tensor_name="in1")
+ place = get_tensor_place(model, "in1")
model.remove_output(place)
expected_model = fe.convert(fe.load("input_model.onnx"))
@@ -1275,13 +1369,14 @@ def test_get_place_by_operation_name_and_input_port():
model = fe.load("input_model.onnx")
assert model
- place1 = model.get_place_by_operation_name_and_input_port(operation_name="split1", input_port_index=0)
- sp_out1_tensor = model.get_place_by_tensor_name("out2")
+ place1 = get_operation_input_port_place(model, operation_name="split1", input_port_index=0)
+ sp_out1_tensor = get_tensor_place(model, "out2")
place2 = sp_out1_tensor.get_producing_operation().get_input_port(input_port_index=0)
assert place1.is_equal(place2)
+@EDITOR_XFAIL_MARK
def test_get_place_by_operation_name_and_output_port():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
@@ -1290,13 +1385,14 @@ def test_get_place_by_operation_name_and_output_port():
model = fe.load("input_model_2.onnx")
assert model
- place1 = model.get_place_by_operation_name_and_output_port(operation_name="split2", output_port_index=0)
- sp_out1_tensor = model.get_place_by_tensor_name("sp_out1")
+ place1 = get_operation_output_port_place(model, operation_name="split2", output_port_index=0)
+ sp_out1_tensor = get_tensor_place(model, "sp_out1")
place2 = sp_out1_tensor.get_producing_operation().get_output_port(output_port_index=0)
assert place1.is_equal(place2)
+@EDITOR_XFAIL_MARK
def test_cut_and_add_new_input_place():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
@@ -1305,7 +1401,7 @@ def test_cut_and_add_new_input_place():
model = fe.load("input_model.onnx")
assert model
- place = model.get_place_by_tensor_name(tensor_name="add_out")
+ place = get_tensor_place(model, "add_out")
model.cut_and_add_new_input(place, "new_input")
@@ -1316,6 +1412,7 @@ def test_cut_and_add_new_input_place():
assert res
+@EDITOR_XFAIL_MARK
def test_cut_and_add_new_input_edge():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
@@ -1324,7 +1421,7 @@ def test_cut_and_add_new_input_edge():
model = fe.load("input_model.onnx")
assert model
- out4 = model.get_place_by_tensor_name(tensor_name="out4")
+ out4 = get_tensor_place(model, "out4")
mul_op = out4.get_producing_operation()
edge_mul0 = mul_op.get_input_port(input_port_index=0)
@@ -1337,6 +1434,7 @@ def test_cut_and_add_new_input_edge():
assert res
+@EDITOR_XFAIL_MARK
def test_set_tensor_value():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
@@ -1347,7 +1445,7 @@ def test_set_tensor_value():
new_values = np.array([[1, 2], [3, 4]], dtype=np.float32)
- place1 = model.get_place_by_tensor_name(tensor_name="in1")
+ place1 = get_tensor_place(model, "in1")
model.set_tensor_value(place1, new_values)
model_converted = fe.convert(model)
@@ -1365,6 +1463,7 @@ def test_set_tensor_value():
assert np.allclose(new_values, retrieved_data)
+@EDITOR_XFAIL_MARK
def test_not_supported_methods():
skip_if_onnx_frontend_is_disabled()
@@ -1376,6 +1475,7 @@ def test_not_supported_methods():
assert "not applicable for ONNX model" in str(e.value)
+@EDITOR_XFAIL_MARK
def test_set_name_for_tensor():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
@@ -1383,7 +1483,7 @@ def test_set_name_for_tensor():
old_name = "add_out"
new_name = "add_out_new"
- tensor = model.get_place_by_tensor_name(tensor_name=old_name)
+ tensor = get_tensor_place(model, old_name)
# ignore rename to own name (expect no exception)
model.set_name_for_tensor(tensor=tensor, new_name=old_name)
@@ -1406,11 +1506,11 @@ def test_set_name_for_tensor():
# actual rename
model.set_name_for_tensor(tensor=tensor, new_name=new_name)
- new_tensor = model.get_place_by_tensor_name(tensor_name=new_name)
+ new_tensor = get_tensor_place(model, new_name)
assert new_tensor
assert new_tensor.is_equal(tensor) # previous Place object holds the handle
- old_tensor = model.get_place_by_tensor_name(tensor_name=old_name)
+ old_tensor = get_tensor_place(model, old_name)
assert old_tensor is None
@@ -1421,7 +1521,7 @@ def test_set_name_for_operation_with_name():
old_name = "split1"
new_name = "split1_new"
- operation = model.get_place_by_operation_name(operation_name=old_name)
+ operation = get_operation_place(model, old_name)
# ignore rename to own name (expect no exception)
model.set_name_for_operation(operation=operation, new_name=old_name)
@@ -1429,13 +1529,13 @@ def test_set_name_for_operation_with_name():
# actual rename
model.set_name_for_operation(operation=operation, new_name=new_name)
- new_operation = model.get_place_by_operation_name(operation_name=new_name)
+ new_operation = get_operation_place(model, new_name)
assert new_operation
assert new_operation.is_equal(operation) # previous Place object holds the handle
# Below test passes for models with unique operation names, what is not required by ONNX standard
# If there were more that one nodes with "split1" name, this test would fail.
- old_operation = model.get_place_by_operation_name(operation_name=old_name)
+ old_operation = get_operation_place(model, old_name)
assert old_operation is None
@@ -1446,18 +1546,19 @@ def test_set_name_for_operation_without_name():
output_name = "add_out"
new_name = "Add_new"
- operation = model.get_place_by_tensor_name(tensor_name=output_name).get_producing_operation()
+ operation = get_tensor_place(model, output_name).get_producing_operation()
# assure the test is performed on node with empty name
assert not operation.get_names() or len(operation.get_names()) == 0 or not operation.get_names()[0]
# actual rename
model.set_name_for_operation(operation=operation, new_name=new_name)
- new_operation = model.get_place_by_tensor_name(tensor_name=output_name).get_producing_operation()
+ new_operation = get_tensor_place(model, output_name).get_producing_operation()
assert new_operation
assert new_operation.is_equal(operation) # previous Place object holds the handle
+@EDITOR_XFAIL_MARK
def test_free_name_for_operation():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
@@ -1467,39 +1568,40 @@ def test_free_name_for_operation():
# assure non existent names are ignored (expect no exception)
model.free_name_for_operation("non existent name")
- split1 = model.get_place_by_operation_name(operation_name=name)
+ split1 = get_operation_place(model, name)
assert split1
model.free_name_for_operation(name)
- operation = model.get_place_by_operation_name(operation_name=name)
+ operation = get_operation_place(model, name)
assert not operation
- new_split1 = model.get_place_by_tensor_name(tensor_name="out1").get_producing_operation()
+ new_split1 = get_tensor_place(model, "out1").get_producing_operation()
assert split1.is_equal(new_split1)
+@EDITOR_XFAIL_MARK
def test_set_name_for_dimension():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
model = fe.load("test_place_names.onnx")
dim_name = "batch_size"
- input1 = model.get_place_by_tensor_name(tensor_name="in1")
+ input1 = get_tensor_place(model, "in1")
model.set_name_for_dimension(input1, 0, dim_name)
assert model.get_partial_shape(input1) == PartialShape([-1, 2])
- output1 = model.get_place_by_tensor_name(tensor_name="out1")
+ output1 = get_tensor_place(model, "out1")
model.set_name_for_dimension(output1, 1, dim_name)
assert model.get_partial_shape(output1) == PartialShape([1, -1])
# sub_output rank is 2 so setting dim_name at index 3 extends its rank to 4
- sub_output = model.get_place_by_tensor_name(tensor_name="sub_out")
+ sub_output = get_tensor_place(model, "sub_out")
model.set_name_for_dimension(sub_output, 3, dim_name)
assert model.get_partial_shape(sub_output) == PartialShape([2, 2, -1, -1])
with pytest.raises(RuntimeError) as e:
model.set_name_for_dimension(input1, 0, "")
assert "name must not be empty" in str(e.value)
- one_const = model.get_place_by_tensor_name(tensor_name="one_const")
+ one_const = get_tensor_place(model, "one_const")
with pytest.raises(RuntimeError) as e:
model.set_name_for_dimension(one_const, 0, dim_name)
assert "ONNX initializer shape dimension cannot be dynamic." in str(e.value)
@@ -1510,7 +1612,7 @@ def test_set_input_partial_shape_using_input_edge():
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
model = fe.load("input_model.onnx")
- add_operator = model.get_place_by_operation_name("onnx_add_op")
+ add_operator = get_operation_place(model, "onnx_add_op")
add_input_edge = add_operator.get_input_port(input_port_index=0)
model.set_partial_shape(add_input_edge, PartialShape([10, 10]))
add_input_edge = add_operator.get_input_port(input_port_index=1)
@@ -1528,7 +1630,7 @@ def test_set_partial_shape_with_range():
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
model = fe.load("input_model.onnx")
- input1 = model.get_place_by_tensor_name("in1")
+ input1 = get_tensor_place(model, "in1")
ranged_shape = PartialShape([Dimension(1, 4), Dimension(2)])
model.set_partial_shape(input1, ranged_shape)
@@ -1536,16 +1638,17 @@ def test_set_partial_shape_with_range():
assert ov_model.input("in1").get_partial_shape() == ranged_shape
+@EDITOR_XFAIL_MARK
def test_set_partial_shape_with_range_and_cut_it_off():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
model = fe.load("input_model.onnx")
- input1 = model.get_place_by_tensor_name("in1")
+ input1 = get_tensor_place(model, "in1")
ranged_shape = PartialShape([Dimension(1, 4), Dimension(2)])
model.set_partial_shape(input1, ranged_shape)
- add_out = model.get_place_by_tensor_name("add_out")
+ add_out = get_tensor_place(model, "add_out")
model.extract_subgraph(inputs=[add_out], outputs=[])
ov_model = fe.convert(model)
@@ -1558,7 +1661,7 @@ def test_set_partial_shape_with_range_and_rename_it():
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
model = fe.load("input_model.onnx")
- input1 = model.get_place_by_tensor_name("in1")
+ input1 = get_tensor_place(model, "in1")
ranged_shape = PartialShape([Dimension(1, 4), Dimension(2)])
model.set_partial_shape(input1, ranged_shape)
model.set_name_for_tensor(input1, "new_in1")
@@ -1572,7 +1675,7 @@ def test_get_partial_shape_using_input_edge():
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
model = fe.load("input_model.onnx")
- add_operator = model.get_place_by_operation_name("onnx_add_op")
+ add_operator = get_operation_place(model, "onnx_add_op")
add_input_edge = add_operator.get_input_port(input_port_index=0)
pshape = model.get_partial_shape(add_input_edge)
@@ -1584,22 +1687,23 @@ def test_get_partial_shape_using_output_edge():
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
model = fe.load("input_model.onnx")
- add_operator = model.get_place_by_operation_name("onnx_add_op")
+ add_operator = get_operation_place(model, "onnx_add_op")
add_output_edge = add_operator.get_output_port(output_port_index=0)
assert model.get_partial_shape(add_output_edge) == PartialShape([2, 2])
- split_operator = model.get_place_by_tensor_name("out1").get_producing_operation()
+ split_operator = get_tensor_place(model, "out1").get_producing_operation()
out2_edge = split_operator.get_output_port(output_port_index=1)
assert model.get_partial_shape(out2_edge) == PartialShape([1, 2])
+@EDITOR_XFAIL_MARK
def test_add_name_for_tensor():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
model = fe.load("input_model.onnx")
- tensor = model.get_place_by_tensor_name(tensor_name="in2")
+ tensor = get_tensor_place(model, "in2")
model.add_name_for_tensor(tensor, "extra_name")
ov_model = fe.convert(model)
@@ -1610,12 +1714,13 @@ def test_add_name_for_tensor():
assert "extra_name" in add_input_tensor_names
+@EDITOR_XFAIL_MARK
def test_add_two_names_for_tensor():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
model = fe.load("input_model.onnx")
- tensor = model.get_place_by_tensor_name(tensor_name="in2")
+ tensor = get_tensor_place(model, "in2")
model.add_name_for_tensor(tensor, "extra_name1")
model.add_name_for_tensor(tensor, "extra_name2")
@@ -1628,12 +1733,13 @@ def test_add_two_names_for_tensor():
assert "extra_name2" in add_input_tensor_names
+@EDITOR_XFAIL_MARK
def test_add_the_same_name_to_tensor_twice():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
model = fe.load("input_model.onnx")
- tensor = model.get_place_by_tensor_name(tensor_name="in2")
+ tensor = get_tensor_place(model, "in2")
model.add_name_for_tensor(tensor, "extra_name")
model.add_name_for_tensor(tensor, "extra_name")
@@ -1650,10 +1756,10 @@ def test_add_name_for_tensor_and_cut_it_off():
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
model = fe.load("input_model_2.onnx")
- tensor = model.get_place_by_tensor_name(tensor_name="in2")
+ tensor = get_tensor_place(model, "in2")
model.add_name_for_tensor(tensor, "extra_name")
- split_in = model.get_place_by_operation_name("split2").get_input_port(input_port_index=0)
+ split_in = get_operation_place(model, "split2").get_input_port(input_port_index=0)
model.extract_subgraph(inputs=[split_in], outputs=[])
ov_model = fe.convert(model)
@@ -1669,7 +1775,7 @@ def test_add_name_for_tensor_and_override_all_inputs():
model = fe.load("input_model_2.onnx")
# test with an InputEdge type of Place
- split_in = model.get_place_by_operation_name("split2").get_input_port(input_port_index=0)
+ split_in = get_operation_place(model, "split2").get_input_port(input_port_index=0)
model.add_name_for_tensor(split_in, "extra_name")
model.override_all_inputs([split_in])
@@ -1680,12 +1786,13 @@ def test_add_name_for_tensor_and_override_all_inputs():
assert "extra_name" in input_tensor_names
+@EDITOR_XFAIL_MARK
def test_add_name_for_tensor_and_rename_it():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
model = fe.load("input_model_2.onnx")
- tensor = model.get_place_by_tensor_name(tensor_name="in2")
+ tensor = get_tensor_place(model, "in2")
model.add_name_for_tensor(tensor, "extra_name")
model.set_name_for_tensor(tensor, "renamed_input")
@@ -1703,7 +1810,7 @@ def test_invalidate_input_place_after_extraction():
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
model = fe.load("input_model.onnx")
- split_op = model.get_place_by_operation_name(operation_name="split1")
+ split_op = get_operation_place(model, "split1")
place_to_cut = split_op.get_input_port(input_port_index=0)
model.extract_subgraph(inputs=[split_op], outputs=[])
@@ -1717,10 +1824,10 @@ def test_invalidate_output_place_after_extraction():
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
model = fe.load("input_model.onnx")
- split_op = model.get_place_by_operation_name(operation_name="split1")
- out1 = model.get_place_by_tensor_name(tensor_name="out1")
- out2 = model.get_place_by_tensor_name(tensor_name="out2")
- place_to_cut = model.get_place_by_tensor_name(tensor_name="out3").get_producing_port()
+ split_op = get_operation_place(model, "split1")
+ out1 = get_tensor_place(model, "out1")
+ out2 = get_tensor_place(model, "out2")
+ place_to_cut = get_tensor_place(model, "out3").get_producing_port()
model.extract_subgraph(inputs=[split_op], outputs=[out1, out2])
with pytest.raises(GeneralFailure) as e:
@@ -1733,8 +1840,8 @@ def test_invalidate_op_place_after_extraction():
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
model = fe.load("input_model.onnx")
- add_out_tensor = model.get_place_by_tensor_name(tensor_name="add_out")
- place_to_cut = model.get_place_by_operation_name(operation_name="split1")
+ add_out_tensor = get_tensor_place(model, "add_out")
+ place_to_cut = get_operation_place(model, "split1")
model.override_all_outputs(outputs=[add_out_tensor])
with pytest.raises(GeneralFailure) as e:
@@ -1742,13 +1849,14 @@ def test_invalidate_op_place_after_extraction():
assert "The place split1 is outdated" in str(e.value)
+@EDITOR_XFAIL_MARK
def test_override_cut_inputs():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
model = fe.load("input_model_2.onnx")
- split = model.get_place_by_tensor_name(tensor_name="sp_out1").get_producing_operation()
- place_to_cut = model.get_place_by_tensor_name(tensor_name="add_out").get_consuming_ports()[0]
+ split = get_tensor_place(model, "sp_out1").get_producing_operation()
+ place_to_cut = get_tensor_place(model, "add_out").get_consuming_ports()[0]
model.override_all_inputs(inputs=[split])
with pytest.raises(GeneralFailure) as e:
@@ -1756,13 +1864,14 @@ def test_override_cut_inputs():
assert "The place InputEdge{1, 0} is outdated" in str(e.value)
+@EDITOR_XFAIL_MARK
def test_override_cut_outputs():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
model = fe.load("input_model_2.onnx")
- add_out = model.get_place_by_tensor_name(tensor_name="add_out")
- place_to_cut = model.get_place_by_tensor_name(tensor_name="sp_out1").get_producing_port()
+ add_out = get_tensor_place(model, "add_out")
+ place_to_cut = get_tensor_place(model, "sp_out1").get_producing_port()
model.override_all_outputs(outputs=[add_out])
with pytest.raises(GeneralFailure) as e:
@@ -1770,24 +1879,26 @@ def test_override_cut_outputs():
assert "The place OutputEdge{1, 0} is outdated" in str(e.value)
+@EDITOR_XFAIL_MARK
def test_get_element_type():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
model = fe.load("input_model_2.onnx")
- in1 = model.get_place_by_tensor_name(tensor_name="in1")
+ in1 = get_tensor_place(model, "in1")
assert model.get_element_type(in1) == Type.f32
in1_output_edge = in1.get_consuming_ports()[0]
assert model.get_element_type(in1_output_edge) == Type.f32
+@EDITOR_XFAIL_MARK
def test_get_element_type_int32():
skip_if_onnx_frontend_is_disabled()
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
model = fe.load("input_model_int32.onnx")
- x_input = model.get_place_by_tensor_name(tensor_name="x")
+ x_input = get_tensor_place(model, "x")
assert model.get_element_type(x_input) == Type.i32
x_output_edge = x_input.get_consuming_ports()[0]
@@ -1795,5 +1906,5 @@ def test_get_element_type_int32():
# get_element_type can return the concrete element type only for model inputs
# for other places, it returns dynamic type
- const_node = model.get_place_by_tensor_name(tensor_name="const_node")
+ const_node = get_tensor_place(model, "const_node")
assert model.get_element_type(const_node) == Type.dynamic