[ONNX] Remove linking libonnx from unit-test (#4298)

* Remove linking libonnx from unit-test

* Consider all flavors of protobuf libraries

* Avoid passing on NOTFOUND properties

* Set system deps for mac

* Revert include dirs set up
This commit is contained in:
Tomasz Jankowski 2021-02-15 05:35:03 +01:00 committed by GitHub
parent 7c8b8e5dda
commit b800f08c0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 26 deletions

View File

@ -143,7 +143,7 @@ else()
message(FATAL_ERROR "Minimum supported version of protobuf library is 3.0.0")
endif()
set(Protobuf_INCLUDE_DIRS ${ext_protobuf_SOURCE_DIR})
set(Protobuf_INCLUDE_DIRS ${ext_protobuf_SOURCE_DIR}/src)
if(NGRAPH_USE_PROTOBUF_LITE)
set(Protobuf_LIBRARIES libprotobuf-lite)
else()

View File

@ -17,8 +17,6 @@
add_definitions("-DSERIALIZED_ZOO=\"${CMAKE_CURRENT_SOURCE_DIR}/models\"")
set(NGRAPH_ONNX_NAMESPACE ngraph_onnx)
set(ONNX_LIBRARIES onnx onnx_proto)
add_subdirectory(runtime)
if(NOT NGRAPH_UNIT_TEST_ENABLE)
@ -375,12 +373,6 @@ if (NGRAPH_ONNX_IMPORT_ENABLE AND NOT NGRAPH_USE_PROTOBUF_LITE)
endif()
foreach(BACKEND_NAME ${ACTIVE_BACKEND_LIST})
if(${BACKEND_NAME} MATCHES ^INTERPRETER$)
set(TEST_LOOPS 100)
else()
set(TEST_LOOPS 2)
endif()
string(TOLOWER ${BACKEND_NAME} BACKEND_DIR)
string(REGEX REPLACE "([a-z0-9]+):(.*)" "\\1" BACKEND_DIR ${BACKEND_DIR})
set(MANIFEST ${CMAKE_CURRENT_SOURCE_DIR}/runtime/${BACKEND_DIR}/unit_test.manifest)
@ -422,9 +414,15 @@ target_link_libraries(unit-test PRIVATE ngraph_test_util
# Protobuf-lite does not support parsing files from prototxt format
# Since most of the onnx models are stored in this format it have to be disabled
if (NGRAPH_ONNX_IMPORT_ENABLE AND NOT NGRAPH_USE_PROTOBUF_LITE)
# 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(unit-test
SYSTEM PRIVATE ${ONNX_INCLUDE_DIR} ${ONNX_PROTO_INCLUDE_DIR} ${Protobuf_INCLUDE_DIRS})
target_link_libraries(unit-test PRIVATE ${Protobuf_LIBRARIES} ${ONNX_LIBRARIES})
SYSTEM PRIVATE
$<TARGET_PROPERTY:onnx,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:onnx_proto,INTERFACE_INCLUDE_DIRECTORIES>
${Protobuf_INCLUDE_DIRS})
target_compile_definitions(unit-test
PRIVATE $<TARGET_PROPERTY:onnx,INTERFACE_COMPILE_DEFINITIONS>)
get_target_property(ONNX_IMPORTER_SRC_DIR onnx_importer SOURCE_DIR)
target_include_directories(unit-test PRIVATE ${ONNX_IMPORTER_SRC_DIR}/src)

View File

@ -39,7 +39,6 @@
#include "onnx_import/onnx.hpp"
#include "onnx_import/onnx_utils.hpp"
#include "default_opset.hpp"
#include "exceptions.hpp"
#include "ngraph/ngraph.hpp"
#include "ngraph/pass/manager.hpp"
#include "ngraph/pass/constant_folding.hpp"

View File

@ -15,8 +15,6 @@
//*****************************************************************************
#include <onnx/onnx_pb.h>
#include "onnx/defs/function.h"
#include "onnx/defs/schema.h"
#include "gtest/gtest.h"
#include "util/test_control.hpp"
@ -25,16 +23,6 @@ using namespace ngraph;
static std::string s_manifest = "${MANIFEST}";
NGRAPH_TEST(onnx, get_function_op_with_version)
{
const auto* schema =
ONNX_NAMESPACE::OpSchemaRegistry::Schema("MeanVarianceNormalization", 9, "");
EXPECT_TRUE(schema);
EXPECT_TRUE(schema->HasFunction());
auto func = schema->GetFunction();
EXPECT_EQ(func->name(), "MeanVarianceNormalization");
}
NGRAPH_TEST(onnx, check_ir_version_support)
{
// It appears you've changed the ONNX library version used by nGraph. Please update the value

View File

@ -39,7 +39,6 @@
#include "onnx_import/onnx.hpp"
#include "onnx_import/onnx_utils.hpp"
#include "default_opset.hpp"
#include "exceptions.hpp"
#include "ngraph/ngraph.hpp"
#include "ngraph/pass/manager.hpp"
#include "ngraph/pass/constant_folding.hpp"
@ -490,4 +489,4 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_model_experimental_detectron_topk_rios)
test_case.add_expected_output<float>(Shape{1, 4}, {1, 1, 3, 4});
test_case.run();
}
}