Skip to content

Commit

Permalink
[IE Myriad] Added MockICore to fix graph transformer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-kud committed Jul 21, 2020
1 parent 2c60d23 commit c829505
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp"
#include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iinfer_request_internal.hpp"
#include "unit_test_utils/mocks/cpp_interfaces/interface/mock_imemory_state_internal.hpp"
#include "unit_test_utils/mocks/cpp_interfaces/interface/mock_icore.hpp"

#include "unit_test_utils/mocks/shape_infer/mock_input_controller.hpp"
#include "unit_test_utils/mocks/shape_infer/mock_ishape_infer_impl.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (C) 2018-2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#pragma once

#include <gmock/gmock.h>
#include "ie_icore.hpp"

class MockICore : public InferenceEngine::ICore {
public:
MOCK_QUALIFIED_METHOD0(GetTaskExecutor, const, std::shared_ptr<InferenceEngine::ITaskExecutor>());

MOCK_QUALIFIED_METHOD2(ReadNetwork, const, InferenceEngine::CNNNetwork(const std::string&, const InferenceEngine::Blob::CPtr&));
MOCK_QUALIFIED_METHOD2(ReadNetwork, const, InferenceEngine::CNNNetwork(const std::string&, const std::string&));

MOCK_METHOD3(LoadNetwork, InferenceEngine::ExecutableNetwork(
const InferenceEngine::CNNNetwork&, const std::string&, const std::map<std::string, std::string>&));

MOCK_METHOD3(ImportNetwork, InferenceEngine::ExecutableNetwork(
std::istream&, const std::string&, const std::map<std::string, std::string>&));

MOCK_QUALIFIED_METHOD3(QueryNetwork, const, InferenceEngine::QueryNetworkResult(
const InferenceEngine::ICNNNetwork&, const std::string&, const std::map<std::string, std::string>&));

MOCK_QUALIFIED_METHOD2(GetMetric, const, InferenceEngine::Parameter(const std::string&, const std::string&));

~MockICore() = default;
};
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void GraphTransformerTest::SetUp() {
consoleOutput());

stageBuilder = std::make_shared<StageBuilder>();
frontEnd = std::make_shared<FrontEnd>(stageBuilder);
frontEnd = std::make_shared<FrontEnd>(stageBuilder, &_mockCore);
backEnd = std::make_shared<BackEnd>();
passManager = std::make_shared<PassManager>(stageBuilder, backEnd);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

#pragma once

#include <list>

#include <gtest/gtest.h>

#include <vpu/compile_env.hpp>
#include <vpu/model/stage.hpp>
#include <vpu/model/model.hpp>
Expand All @@ -12,9 +16,7 @@
#include <vpu/backend/backend.hpp>
#include <vpu/utils/ie_helpers.hpp>

#include <gtest/gtest.h>

#include <list>
#include <unit_test_utils/mocks/cpp_interfaces/interface/mock_icore.hpp>

namespace vpu {

Expand Down Expand Up @@ -144,6 +146,7 @@ class GraphTransformerTest : public ::testing::Test {
TestModel CreateTestModel();

private:
MockICore _mockCore;
Logger::Ptr _log;
std::list<ModelPtr> _models;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ addIeTarget(
IESharedTests
vpu_graph_transformer
vpu_custom_kernels
unitTestUtils
DEFINES
INSTANTIATE_TESTS=1
EXPORT_DEPENDENCIES
Expand All @@ -52,8 +53,10 @@ addIeTarget(
target_include_directories(VPUCommonTests INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/vpu_base
${CMAKE_CURRENT_SOURCE_DIR}/common/regression/helpers
$<TARGET_PROPERTY:vpu_graph_transformer,INTERFACE_INCLUDE_DIRECTORIES>
)
$<TARGET_PROPERTY:vpu_graph_transformer,INTERFACE_INCLUDE_DIRECTORIES>)

target_include_directories(VPUCommonTests SYSTEM PUBLIC
$<TARGET_PROPERTY:unitTestUtils,INTERFACE_INCLUDE_DIRECTORIES>)

ie_developer_export_targets(vpu_custom_kernels)
addIeTargetTest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <ngraph/op/util/attr_types.hpp>
#include <ngraph_functions/subgraph_builders.hpp>

#include <unit_test_utils/mocks/cpp_interfaces/interface/mock_icore.hpp>

using namespace ::testing;
using namespace vpu;
using namespace InferenceEngine;
Expand Down Expand Up @@ -50,11 +52,12 @@ class VPUBlobReaderHeaderTests: public TestsCommon, public testing::WithParamInt

CompilationConfig compileConfig;
auto log = std::make_shared<Logger>("GraphCompiler", LogLevel::None, consoleOutput());
_compiledGraph = compileNetwork(_network, Platform::MYRIAD_X, compileConfig, log);
_compiledGraph = compileNetwork(_network, Platform::MYRIAD_X, compileConfig, log, &_mockCore);
}

CNNNetwork _network;
CompiledGraph::Ptr _compiledGraph;
MockICore _mockCore;
};

TEST_P(VPUBlobReaderHeaderTests, canReadCorrectMagicNumber) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void graphTransformerFunctionalTests::SetUp() {
vpuLayersTests::SetUp();

_stageBuilder = std::make_shared<StageBuilder>();
_frontEnd = std::make_shared<FrontEnd>(_stageBuilder);
_frontEnd = std::make_shared<FrontEnd>(_stageBuilder, &_mockCore);
_backEnd = std::make_shared<BackEnd>();
_passManager = std::make_shared<PassManager>(_stageBuilder, _backEnd);
_platform = CheckMyriadX() ? Platform::MYRIAD_X : Platform::MYRIAD_2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <vpu/middleend/pass_manager.hpp>
#include <vpu/frontend/frontend.hpp>

#include <unit_test_utils/mocks/cpp_interfaces/interface/mock_icore.hpp>

class graphTransformerFunctionalTests : public vpuLayersTests {
protected:
void SetUp() override;
Expand All @@ -29,6 +31,7 @@ class graphTransformerFunctionalTests : public vpuLayersTests {
vpu::CompilationConfig _compilationConfig;
vpu::StageBuilder::Ptr _stageBuilder;
vpu::Data _dataIntermediate;
MockICore _mockCore;

private:
vpu::Platform _platform = vpu::Platform::MYRIAD_X;
Expand Down
4 changes: 2 additions & 2 deletions inference-engine/tests_deprecated/helpers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ endfunction()

add_helpers(${TARGET_NAME})

target_link_libraries(${TARGET_NAME} PUBLIC commonTestUtils)
target_link_libraries(${TARGET_NAME} PRIVATE commonTestUtils)

add_helpers(${TARGET_NAME}_s USE_STATIC_IE)

target_link_libraries(${TARGET_NAME}_s PUBLIC commonTestUtils_s)
target_link_libraries(${TARGET_NAME}_s PRIVATE commonTestUtils_s)

if (ENABLE_DATA)
add_dependencies(${TARGET_NAME} data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void GraphTransformerTest::SetUp() {
consoleOutput());

stageBuilder = std::make_shared<StageBuilder>();
frontEnd = std::make_shared<FrontEnd>(stageBuilder);
frontEnd = std::make_shared<FrontEnd>(stageBuilder, &_mockCore);
backEnd = std::make_shared<BackEnd>();
passManager = std::make_shared<PassManager>(stageBuilder, backEnd);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <vpu/middleend/pass_manager.hpp>
#include <vpu/backend/backend.hpp>

#include <unit_test_utils/mocks/cpp_interfaces/interface/mock_icore.hpp>

namespace vpu {

template <class Cont, class Cond>
Expand Down Expand Up @@ -196,6 +198,7 @@ class GraphTransformerTest : public TestsCommon {
TestModel CreateTestModel(const DataDesc& dataDesc);

private:
MockICore _mockCore;
Logger::Ptr _log;
std::list<ModelPtr> _models;
};
Expand Down

0 comments on commit c829505

Please sign in to comment.