Skip to content

Commit

Permalink
Supported dynamic protobuf in ONNX tests (openvinotoolkit#22272)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-lavrenov authored Jan 19, 2024
1 parent c8f9033 commit 3407706
Show file tree
Hide file tree
Showing 12 changed files with 8 additions and 339 deletions.
1 change: 0 additions & 1 deletion src/frontends/onnx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# SPDX-License-Identifier: Apache-2.0
#


add_subdirectory(onnx_common)
add_subdirectory(frontend)

Expand Down
21 changes: 4 additions & 17 deletions src/frontends/onnx/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ set(SRC
onnx_editor.cpp
onnx_editor_topological_sort.cpp
onnx_import_exceptions.cpp
onnx_import_library.cpp
onnx_importer_test.cpp
onnx_tensor_names.cpp
onnx_test_util.cpp
onnx_utils.cpp
onnx_transformations.cpp
op_extension.cpp
Expand Down Expand Up @@ -118,6 +116,8 @@ foreach(BACKEND_NAME IN LISTS ACTIVE_BACKEND_LIST)
message(STATUS "Adding unit test for backend ${BACKEND_NAME}")
endforeach()

# Create target

add_executable(ov_onnx_frontend_tests ${SRC})
add_test(NAME ov_onnx_frontend_tests COMMAND ov_onnx_frontend_tests --gtest_filter=-*IE_GPU*)
set_property(TEST ov_onnx_frontend_tests PROPERTY LABELS OV UNIT ONNX_FE)
Expand All @@ -141,27 +141,14 @@ endif()
target_link_libraries(ov_onnx_frontend_tests PRIVATE
gtest_main_manifest
frontend_shared_test_classes
openvino::runtime::dev
openvino_onnx_frontend
openvino_onnx_common
openvino::frontend::onnx
func_test_utils)

# It's needed by onnx_import_library.cpp and onnx_import_exceptions.cpp tests to include onnx_pb.h.
# Not linking statically to libprotobuf (linked into libonnx) avoids false-failing onnx_editor tests.
target_include_directories(ov_onnx_frontend_tests
SYSTEM PRIVATE
$<TARGET_PROPERTY:onnx,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:onnx_proto,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>)
target_compile_definitions(ov_onnx_frontend_tests PRIVATE $<TARGET_PROPERTY:onnx,INTERFACE_COMPILE_DEFINITIONS>)
target_compile_definitions(ov_onnx_frontend_tests PRIVATE ENABLE_OV_ONNX_FRONTEND)

if(OV_COMPILER_IS_CLANG)
target_compile_options(ov_onnx_frontend_tests PRIVATE -Wno-undef -Wno-reserved-id-macro)
endif()

target_include_directories(ov_onnx_frontend_tests PRIVATE
$<TARGET_PROPERTY:openvino_onnx_frontend,INCLUDE_DIRECTORIES>)
# Install rules

install(TARGETS ov_onnx_frontend_tests
RUNTIME DESTINATION tests COMPONENT tests EXCLUDE_FROM_ALL)
Expand Down
2 changes: 0 additions & 2 deletions src/frontends/onnx/tests/onnx_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
#include "common_test_utils/graph_comparator.hpp"
#include "common_test_utils/test_case.hpp"
#include "common_test_utils/test_control.hpp"
#include "editor.hpp"
#include "gtest/gtest.h"
#include "onnx_test_util.hpp"
#include "onnx_utils.hpp"
#include "openvino/op/constant.hpp"

Expand Down
2 changes: 0 additions & 2 deletions src/frontends/onnx/tests/onnx_editor_topological_sort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
#include "common_test_utils/file_utils.hpp"
#include "common_test_utils/test_case.hpp"
#include "common_test_utils/test_control.hpp"
#include "editor.hpp"
#include "gtest/gtest.h"
#include "onnx_test_util.hpp"
#include "onnx_utils.hpp"

using namespace ov;
Expand Down
5 changes: 2 additions & 3 deletions src/frontends/onnx/tests/onnx_import_exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include "common_test_utils/file_utils.hpp"
#include "common_test_utils/type_prop.hpp"
#include "exceptions.hpp"
#include "gtest/gtest.h"
#include "onnx_utils.hpp"

Expand Down Expand Up @@ -34,10 +33,10 @@ TEST(onnx_importer, exception_msg_onnx_node_validation_failure) {
convert_model("instance_norm_bad_scale_type.onnx");
// Should have thrown, so fail if it didn't
FAIL() << "ONNX Importer did not detected incorrect model!";
} catch (const ::ov::frontend::onnx_error::OnnxNodeValidationFailure& e) {
} catch (const ::ov::Exception& e) {
EXPECT_HAS_SUBSTRING(e.what(), std::string("While validating ONNX node '<Node(InstanceNormalization)"));
}
// On MacOS after we re-throw OnnxNodeValidationFailure exception, we couldn't catch it as is,
// On MacOS after we re-throw ov::Exception exception, we couldn't catch it as is,
// thus below workaround.
catch (const std::exception& e) {
EXPECT_HAS_SUBSTRING(e.what(), std::string("While validating ONNX node '<Node(InstanceNormalization)"));
Expand Down
29 changes: 0 additions & 29 deletions src/frontends/onnx/tests/onnx_import_library.cpp

This file was deleted.

4 changes: 2 additions & 2 deletions src/frontends/onnx/tests/onnx_import_org_openvino.in.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_priorbox_clustered_first_input_bad_shape) {
} catch (const ov::Exception& e) {
EXPECT_HAS_SUBSTRING(e.what(), std::string("Only 4D inputs are supported. First input rank: 5 (should be 4)"));
} catch (...) {
FAIL() << "Expected OnnxNodeValidationFailure exception was not thrown";
FAIL() << "Expected ov::Exception exception was not thrown";
}
}

Expand All @@ -128,7 +128,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_priorbox_clustered_second_input_bad_shape) {
} catch (const ov::Exception& e) {
EXPECT_HAS_SUBSTRING(e.what(), std::string("Only 4D inputs are supported. Second input rank: 5 (should be 4)"));
} catch (...) {
FAIL() << "Expected OnnxNodeValidationFailure exception was not thrown";
FAIL() << "Expected ov::Exception exception was not thrown";
}
}

Expand Down
1 change: 0 additions & 1 deletion src/frontends/onnx/tests/onnx_import_with_editor.in.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "common_test_utils/file_utils.hpp"
#include "common_test_utils/test_case.hpp"
#include "common_test_utils/test_control.hpp"
#include "editor.hpp"
#include "gtest/gtest.h"
#include "onnx_utils.hpp"
#include "openvino/op/constant.hpp"
Expand Down
3 changes: 0 additions & 3 deletions src/frontends/onnx/tests/onnx_ops_registration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@
#include "common_test_utils/file_utils.hpp"
#include "common_test_utils/test_case.hpp"
#include "common_test_utils/test_control.hpp"
#include "editor.hpp"
#include "gtest/gtest.h"
#include "onnx_test_util.hpp"
#include "onnx_utils.hpp"

using namespace ov;
using namespace ov::onnx_editor;
using namespace ov::frontend::onnx::tests;

static std::string s_manifest = onnx_backend_manifest("${MANIFEST}");
Expand Down
228 changes: 0 additions & 228 deletions src/frontends/onnx/tests/onnx_test_util.cpp

This file was deleted.

Loading

0 comments on commit 3407706

Please sign in to comment.