Skip to content

Commit

Permalink
Merge pull request #8 from nosovmik/mnosov/fixbuild3
Browse files Browse the repository at this point in the history
Fix build for unit tests
  • Loading branch information
slyalin authored Apr 6, 2021
2 parents 87e3994 + d450b4d commit cf0dad2
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ addIeTargetTest(
LINK_LIBRARIES
unitTestUtils
inference_engine_lp_transformations
frontend_manager
${OpenCV_LIBRARIES}
ADD_CPPLINT
DEPENDENCIES
Expand Down
1 change: 1 addition & 0 deletions inference-engine/tests_deprecated/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ target_link_libraries(${TARGET_NAME} PRIVATE
inference_engine_transformations
inference_engine_lp_transformations
inference_engine_snippets
frontend_manager
)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
Expand Down
4 changes: 4 additions & 0 deletions ngraph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ set(NGRAPH_INCLUDE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/core/include
)

set(FRONTEND_INCLUDE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/frontend/generic/include
)

if (APPLE)
# Enable MACOS_RPATH by default.
cmake_policy(SET CMP0042 NEW)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class NGRAPH_API Place

typedef std::shared_ptr<Place> Ptr;

virtual ~Place() = default;

/// \brief All associated names (synonyms) that identify this place in the graph in a framework specific way
/// \return A vector of strings each representing a name that identifies this place in the graph.
/// Can be empty if there are no names associated with this place or name cannot be attached.
Expand Down Expand Up @@ -158,6 +160,7 @@ class NGRAPH_API InputModel

typedef std::shared_ptr<InputModel> Ptr;

virtual ~InputModel() = default;

///// Searching for places /////

Expand Down Expand Up @@ -270,6 +273,7 @@ class NGRAPH_API FrontEnd
{
public:
typedef std::shared_ptr<FrontEnd> Ptr;
virtual ~FrontEnd() = default;

virtual InputModel::Ptr loadFromFile (const std::string& path) const;
virtual InputModel::Ptr loadFromFiles (const std::vector<std::string>& paths) const;
Expand Down
6 changes: 6 additions & 0 deletions ngraph/frontend/generic/src/frontend_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,12 @@ namespace ngraph
{
return m_impl->availableFrontEnds();
}

void FrontEndManager::registerFrontEnd(const std::string& name, FrontEndFactory creator)
{
m_impl->registerFrontEnd(name, creator);
}

} // namespace frontend

} // namespace ngraph
4 changes: 3 additions & 1 deletion ngraph/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ set(SRC
eval.cpp
file_util.cpp
float16.cpp
frontend/frontend_manager.cpp
graph_rewrite.cpp
includes.cpp
input_output_assign.cpp
Expand Down Expand Up @@ -443,6 +444,7 @@ add_executable(unit-test ${SRC})

target_include_directories(unit-test PRIVATE ".")
target_include_directories(unit-test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/runtime)
target_include_directories(unit-test PRIVATE ${FRONTEND_INCLUDE_PATH})

add_definitions("-DCURDIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"")
add_definitions("-DJSON_INCLUDES=\"${JSON_INCLUDE_DIR}\"")
Expand Down Expand Up @@ -492,7 +494,7 @@ if (MSVC)
target_compile_options(unit-test PRIVATE "/bigobj")
endif()

target_link_libraries(unit-test PRIVATE ie_backend)
target_link_libraries(unit-test PRIVATE ie_backend frontend_manager)

if (NGRAPH_ONNX_IMPORT_ENABLE)
target_link_libraries(unit-test PRIVATE onnx_importer onnx_editor)
Expand Down
31 changes: 31 additions & 0 deletions ngraph/test/frontend/frontend_manager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include <memory>
#include <frontend_manager/frontend_manager.hpp>

#include "gtest/gtest.h"
#include "gmock/gmock.h"

using namespace ngraph;
using namespace ngraph::frontend;

class FrontEndMock: public FrontEnd {
public:
FrontEndMock() = default;
~FrontEndMock() = default;

MOCK_CONST_METHOD1(loadFromFile, InputModel::Ptr(const std::string&));
MOCK_CONST_METHOD1(convert, std::shared_ptr<ngraph::Function>(InputModel::Ptr model));
};

TEST(FrontEndManagerTest, testAvailableFrontEnds)
{
FrontEndManager fem;
ASSERT_NO_THROW(fem.registerFrontEnd("mock", [](FrontEndCapabilities fec) {
return std::make_shared<FrontEndMock>();
}));
auto frontends = fem.availableFrontEnds();
ASSERT_NE(std::find(frontends.begin(), frontends.end(), "mock"), frontends.end());
}

0 comments on commit cf0dad2

Please sign in to comment.