From a30d757cfd4ad217bad1f6b6bd9e405506e05fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ewa=20Tusie=C5=84?= Date: Mon, 7 Jun 2021 11:58:22 +0200 Subject: [PATCH 001/178] [IE CLDNN] Convert permutation order in MatMul (#6005) --- inference-engine/src/cldnn_engine/ops/matmul.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/inference-engine/src/cldnn_engine/ops/matmul.cpp b/inference-engine/src/cldnn_engine/ops/matmul.cpp index b18e199581cd15..5fe6f1432586c3 100644 --- a/inference-engine/src/cldnn_engine/ops/matmul.cpp +++ b/inference-engine/src/cldnn_engine/ops/matmul.cpp @@ -83,10 +83,11 @@ void CreateMatMulOp(Program& p, const std::shared_ptr& o for (auto o = transpose_order.size(); o < 4; o++) transpose_order.push_back((uint16_t)o); + std::vector cldnn_permute_order = ConvertPermuteOrder(transpose_order); auto permuteName = op->get_friendly_name() + "/transpose_b"; auto permutePrim = cldnn::permute(permuteName, weightsName, - transpose_order); + cldnn_permute_order); p.AddPrimitive(permutePrim); p.AddInnerPrimitiveToProfiler(permuteName, layerName, op); weightsName = permuteName; @@ -102,10 +103,11 @@ void CreateMatMulOp(Program& p, const std::shared_ptr& o for (auto o = transpose_order.size(); o < 4; o++) transpose_order.push_back((uint16_t)o); + std::vector cldnn_permute_order = ConvertPermuteOrder(transpose_order); auto permuteName = op->get_friendly_name() + "/transpose_a"; auto permutePrim = cldnn::permute(permuteName, inputName, - transpose_order); + cldnn_permute_order); p.AddPrimitive(permutePrim); p.AddInnerPrimitiveToProfiler(permuteName, layerName, op); inputName = permuteName; From 9fd73b4f1a72bc3910c0a300042ef5f1e52c2450 Mon Sep 17 00:00:00 2001 From: Mikhail Nosov Date: Mon, 7 Jun 2021 13:43:32 +0300 Subject: [PATCH 002/178] [nGraph] Enable 'clang' for frontend-related unit tests (#6024) * [nGraph] Enable 'clang' for frontend-related unit tests * Moved frontend sources and headers before 'clang' definitions --- ngraph/test/CMakeLists.txt | 17 +-- ngraph/test/frontend/frontend_manager.cpp | 28 ++-- .../frontend/shared/include/basic_api.hpp | 4 +- .../frontend/shared/include/partial_shape.hpp | 11 +- ngraph/test/frontend/shared/include/utils.hpp | 5 +- ngraph/test/frontend/shared/src/basic_api.cpp | 65 +++------- .../shared/src/cut_specific_model.cpp | 120 ++++++++++-------- .../frontend/shared/src/partial_shape.cpp | 27 ++-- 8 files changed, 132 insertions(+), 145 deletions(-) diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index c6ce9d629770b3..52148150e81562 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -468,7 +468,15 @@ if (NGRAPH_ONNX_EDITOR_ENABLE) onnx/onnx_import_with_editor.in.cpp) endif() -add_clang_format_target(unit-test_clang FOR_SOURCES ${SRC} ${MULTI_TEST_SRC}) +# SOURCE AND HEADERS FOR FRONTEND TESTING +file(GLOB FRONTEND_TESTS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/frontend/frontend_manager.cpp) +set(SRC ${FRONTEND_TESTS_SRC} ${SRC}) + +file(GLOB FRONTEND_SHARED_TESTS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/frontend/shared/src/*.cpp) +file(GLOB FRONTEND_SHARED_TESTS_HDR ${CMAKE_CURRENT_SOURCE_DIR}/frontend/shared/include/*.hpp) +set(SRC ${FRONTEND_SHARED_TESTS_SRC} ${SRC}) + +add_clang_format_target(unit-test_clang FOR_SOURCES ${SRC} ${MULTI_TEST_SRC} ${FRONTEND_SHARED_TESTS_HDR}) foreach(BACKEND_NAME ${ACTIVE_BACKEND_LIST}) string(TOLOWER ${BACKEND_NAME} BACKEND_DIR) @@ -485,13 +493,6 @@ foreach(BACKEND_NAME ${ACTIVE_BACKEND_LIST}) message(STATUS "Adding unit test for backend ${BACKEND_NAME}") endforeach() -# SOURCE FOR FRONTEND TESTING -file(GLOB FRONTEND_TESTS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/frontend/frontend_manager.cpp) -set(SRC ${FRONTEND_TESTS_SRC} ${SRC}) - -file(GLOB FRONTEND_SHARED_TESTS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/frontend/shared/src/*.cpp) -set(SRC ${FRONTEND_SHARED_TESTS_SRC} ${SRC}) - add_executable(unit-test ${SRC}) target_include_directories(unit-test PRIVATE ".") diff --git a/ngraph/test/frontend/frontend_manager.cpp b/ngraph/test/frontend/frontend_manager.cpp index 4500a2c509dfc6..10e8eac8e60001 100644 --- a/ngraph/test/frontend/frontend_manager.cpp +++ b/ngraph/test/frontend/frontend_manager.cpp @@ -2,11 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 // -#include #include +#include -#include "gtest/gtest.h" #include "gmock/gmock.h" +#include "gtest/gtest.h" #include "backend.hpp" #include "ngraph/file_util.hpp" @@ -33,10 +33,8 @@ static int set_test_env(const char* name, const char* value) TEST(FrontEndManagerTest, testAvailableFrontEnds) { FrontEndManager fem; - ASSERT_NO_THROW(fem.register_front_end("mock", [](FrontEndCapFlags fec) - { - return std::make_shared(); - })); + ASSERT_NO_THROW(fem.register_front_end( + "mock", [](FrontEndCapFlags fec) { return std::make_shared(); })); auto frontends = fem.get_available_front_ends(); ASSERT_NE(std::find(frontends.begin(), frontends.end(), "mock"), frontends.end()); FrontEnd::Ptr fe; @@ -53,13 +51,11 @@ TEST(FrontEndManagerTest, testAvailableFrontEnds) TEST(FrontEndManagerTest, testLoadWithFlags) { - int expFlags = FrontEndCapabilities::FEC_CUT | - FrontEndCapabilities::FEC_WILDCARDS | - FrontEndCapabilities::FEC_NAMES; + int expFlags = FrontEndCapabilities::FEC_CUT | FrontEndCapabilities::FEC_WILDCARDS | + FrontEndCapabilities::FEC_NAMES; int actualFlags = FrontEndCapabilities::FEC_DEFAULT; FrontEndManager fem; - ASSERT_NO_THROW(fem.register_front_end("mock", [&actualFlags](int fec) - { + ASSERT_NO_THROW(fem.register_front_end("mock", [&actualFlags](int fec) { actualFlags = fec; return std::make_shared(); })); @@ -75,8 +71,8 @@ TEST(FrontEndManagerTest, testLoadWithFlags) TEST(FrontEndManagerTest, testMockPluginFrontEnd) { - std::string fePath = - ngraph::file_util::get_directory(ngraph::runtime::Backend::get_backend_shared_library_search_directory()); + std::string fePath = ngraph::file_util::get_directory( + ngraph::runtime::Backend::get_backend_shared_library_search_directory()); fePath = fePath + FrontEndPathSeparator + "someInvalidPath"; set_test_env("OV_FRONTEND_PATH", fePath.c_str()); @@ -91,7 +87,7 @@ TEST(FrontEndManagerTest, testDefaultFrontEnd) FrontEndManager fem; ASSERT_ANY_THROW(fem.load_by_model("")); - std::unique_ptr fePtr (new FrontEnd()); // to verify base destructor + std::unique_ptr fePtr(new FrontEnd()); // to verify base destructor FrontEnd::Ptr fe = std::make_shared(); ASSERT_ANY_THROW(fe->load_from_file("")); ASSERT_ANY_THROW(fe->load_from_files({"", ""})); @@ -109,7 +105,7 @@ TEST(FrontEndManagerTest, testDefaultFrontEnd) TEST(FrontEndManagerTest, testDefaultInputModel) { - std::unique_ptr imPtr (new InputModel()); // to verify base destructor + std::unique_ptr imPtr(new InputModel()); // to verify base destructor InputModel::Ptr im = std::make_shared(); ASSERT_ANY_THROW(im->get_inputs()); ASSERT_ANY_THROW(im->get_outputs()); @@ -139,7 +135,7 @@ TEST(FrontEndManagerTest, testDefaultInputModel) TEST(FrontEndManagerTest, testDefaultPlace) { - std::unique_ptr placePtr (new Place()); // to verify base destructor + std::unique_ptr placePtr(new Place()); // to verify base destructor Place::Ptr place = std::make_shared(); ASSERT_ANY_THROW(place->get_names()); ASSERT_ANY_THROW(place->get_consuming_operations()); diff --git a/ngraph/test/frontend/shared/include/basic_api.hpp b/ngraph/test/frontend/shared/include/basic_api.hpp index cf2f37f13aa0cf..5aaf97a09d6801 100644 --- a/ngraph/test/frontend/shared/include/basic_api.hpp +++ b/ngraph/test/frontend/shared/include/basic_api.hpp @@ -9,8 +9,8 @@ #include using BasicTestParam = std::tuple; // Model name + std::string, // Base path to models + std::string>; // Model name class FrontEndBasicTest : public ::testing::TestWithParam { diff --git a/ngraph/test/frontend/shared/include/partial_shape.hpp b/ngraph/test/frontend/shared/include/partial_shape.hpp index f06f40cf576655..b3aff5aff5be64 100644 --- a/ngraph/test/frontend/shared/include/partial_shape.hpp +++ b/ngraph/test/frontend/shared/include/partial_shape.hpp @@ -10,12 +10,13 @@ struct BaseFEParam { - BaseFEParam() - {} + BaseFEParam() {} - BaseFEParam(const std::string& name, const std::string& path) : - m_frontEndName(name), m_modelsPath(path) - {} + BaseFEParam(const std::string& name, const std::string& path) + : m_frontEndName(name) + , m_modelsPath(path) + { + } std::string m_frontEndName; std::string m_modelsPath; diff --git a/ngraph/test/frontend/shared/include/utils.hpp b/ngraph/test/frontend/shared/include/utils.hpp index 6bb4106c02e042..4a594c480ff871 100644 --- a/ngraph/test/frontend/shared/include/utils.hpp +++ b/ngraph/test/frontend/shared/include/utils.hpp @@ -19,11 +19,12 @@ namespace FrontEndTestUtils if (c == '/') { c = '_'; - } else if (c == '.') + } + else if (c == '.') { c = '_'; } } return res; } -} \ No newline at end of file +} // namespace FrontEndTestUtils \ No newline at end of file diff --git a/ngraph/test/frontend/shared/src/basic_api.cpp b/ngraph/test/frontend/shared/src/basic_api.cpp index 1bce97cb6a6ef2..85688762893fb9 100644 --- a/ngraph/test/frontend/shared/src/basic_api.cpp +++ b/ngraph/test/frontend/shared/src/basic_api.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // -#include #include "../include/basic_api.hpp" #include "../include/utils.hpp" @@ -50,13 +49,11 @@ TEST_P(FrontEndBasicTest, testInputModel_getInputsOutputs) ASSERT_NO_THROW(doLoadFromFile()); using CustomCheck = std::function; - auto checkPlaces = [&](const std::vector& places, CustomCheck cb) - { + auto checkPlaces = [&](const std::vector& places, CustomCheck cb) { EXPECT_GT(places.size(), 0); std::set placesSet(places.begin(), places.end()); EXPECT_EQ(placesSet.size(), places.size()); - std::for_each(places.begin(), places.end(), [&](Place::Ptr place) - { + std::for_each(places.begin(), places.end(), [&](Place::Ptr place) { ASSERT_NE(place, nullptr); std::vector names; ASSERT_NO_THROW(names = place->get_names()); @@ -66,25 +63,18 @@ TEST_P(FrontEndBasicTest, testInputModel_getInputsOutputs) }; std::vector inputs; ASSERT_NO_THROW(inputs = m_inputModel->get_inputs()); - checkPlaces(inputs, [&](Place::Ptr place) - { - EXPECT_TRUE(place->is_input()); - }); + checkPlaces(inputs, [&](Place::Ptr place) { EXPECT_TRUE(place->is_input()); }); std::vector outputs; ASSERT_NO_THROW(outputs = m_inputModel->get_outputs()); - checkPlaces(outputs, [&](Place::Ptr place) - { - EXPECT_TRUE(place->is_output()); - }); + checkPlaces(outputs, [&](Place::Ptr place) { EXPECT_TRUE(place->is_output()); }); } TEST_P(FrontEndBasicTest, testInputModel_getPlaceByTensorName) { ASSERT_NO_THROW(doLoadFromFile()); - auto testGetPlaceByTensorName = [&](const std::vector& places) - { + auto testGetPlaceByTensorName = [&](const std::vector& places) { EXPECT_GT(places.size(), 0); for (auto place : places) { @@ -117,8 +107,7 @@ TEST_P(FrontEndBasicTest, testInputModel_overrideAll) using GetPlaces = std::function()>; using OverridePlaces = std::function&)>; - auto verifyOverride = [](GetPlaces getCB, OverridePlaces overrideCB) - { + auto verifyOverride = [](GetPlaces getCB, OverridePlaces overrideCB) { std::vector places; ASSERT_NO_THROW(places = getCB()); std::set placesSet(places.begin(), places.end()); @@ -130,20 +119,16 @@ TEST_P(FrontEndBasicTest, testInputModel_overrideAll) EXPECT_GT(places.size(), 0); std::set placesSetAfter(places.begin(), places.end()); EXPECT_EQ(placesSet.size(), placesSet.size()); - std::for_each(places.begin(), places.end(), [&](Place::Ptr place) - { + std::for_each(places.begin(), places.end(), [&](Place::Ptr place) { EXPECT_GT(placesSet.count(place), 0); }); }; - verifyOverride([&]() - { return m_inputModel->get_inputs(); }, - [&](const std::vector& p) - { m_inputModel->override_all_inputs(p); }); - - verifyOverride([&]() - { return m_inputModel->get_outputs(); }, - [&](const std::vector& p) - { m_inputModel->override_all_outputs(p); }); + verifyOverride([&]() { return m_inputModel->get_inputs(); }, + [&](const std::vector& p) { m_inputModel->override_all_inputs(p); }); + + verifyOverride( + [&]() { return m_inputModel->get_outputs(); }, + [&](const std::vector& p) { m_inputModel->override_all_outputs(p); }); } TEST_P(FrontEndBasicTest, testInputModel_overrideAll_empty) @@ -152,16 +137,14 @@ TEST_P(FrontEndBasicTest, testInputModel_overrideAll_empty) using GetPlaces = std::function()>; using OverrideEmpty = std::function; using CustomCheck = std::function; - auto verifyOverride = [](GetPlaces getCB, OverrideEmpty overrideCB, CustomCheck customCB) - { + auto verifyOverride = [](GetPlaces getCB, OverrideEmpty overrideCB, CustomCheck customCB) { std::vector places; std::vector newPlaces; ASSERT_NO_THROW(places = getCB()); ASSERT_NO_THROW(overrideCB()); ASSERT_NO_THROW(newPlaces = getCB()); ASSERT_EQ(newPlaces.size(), 0); - std::for_each(places.begin(), places.end(), [&](Place::Ptr place) - { + std::for_each(places.begin(), places.end(), [&](Place::Ptr place) { std::vector names; ASSERT_NO_THROW(names = place->get_names()); for (auto name : names) @@ -170,21 +153,15 @@ TEST_P(FrontEndBasicTest, testInputModel_overrideAll_empty) } }); }; - verifyOverride([&]() - { return m_inputModel->get_outputs(); }, - [&]() - { m_inputModel->override_all_outputs({}); }, - [&](const std::string& name) - { + verifyOverride([&]() { return m_inputModel->get_outputs(); }, + [&]() { m_inputModel->override_all_outputs({}); }, + [&](const std::string& name) { EXPECT_FALSE(m_inputModel->get_place_by_tensor_name(name)->is_output()); }); - verifyOverride([&]() - { return m_inputModel->get_inputs(); }, - [&]() - { m_inputModel->override_all_inputs({}); }, - [&](const std::string& name) - { + verifyOverride([&]() { return m_inputModel->get_inputs(); }, + [&]() { m_inputModel->override_all_inputs({}); }, + [&](const std::string& name) { EXPECT_FALSE(m_inputModel->get_place_by_tensor_name(name)->is_input()); }); } diff --git a/ngraph/test/frontend/shared/src/cut_specific_model.cpp b/ngraph/test/frontend/shared/src/cut_specific_model.cpp index d1ecbae8976705..d9fe9ce7e1b5f9 100644 --- a/ngraph/test/frontend/shared/src/cut_specific_model.cpp +++ b/ngraph/test/frontend/shared/src/cut_specific_model.cpp @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include #include "../include/cut_specific_model.hpp" #include "../include/utils.hpp" #include "ngraph/opsets/opset7.hpp" @@ -14,8 +12,7 @@ using namespace ngraph::frontend; static std::string joinStrings(const std::vector& strings) { std::ostringstream res; - std::copy(strings.begin(), strings.end(), - std::ostream_iterator(res, "_")); + std::copy(strings.begin(), strings.end(), std::ostream_iterator(res, "_")); return res.str(); } @@ -85,7 +82,7 @@ TEST_P(FrontEndCutModelTest, testOverrideInputs) std::vector names; ASSERT_NO_THROW(names = newInput->get_names()); bool found = false; - for (const auto& name: m_param.m_newInputs) + for (const auto& name : m_param.m_newInputs) { if (std::find(names.begin(), names.begin(), name) != names.end()) { @@ -110,7 +107,7 @@ TEST_P(FrontEndCutModelTest, testOverrideOutputs) std::vector names; ASSERT_NO_THROW(names = newOutput->get_names()); bool found = false; - for (const auto& name: m_param.m_newOutputs) + for (const auto& name : m_param.m_newOutputs) { if (std::find(names.begin(), names.begin(), name) != names.end()) { @@ -132,11 +129,13 @@ TEST_P(FrontEndCutModelTest, testOldInputs) // Ensure that it contains expected old inputs for (const auto& name : m_param.m_oldInputs) { - EXPECT_TRUE(std::find_if(ops.begin(), ops.end(), - [&](const std::shared_ptr& node) - { - return node->get_friendly_name().find(name) != std::string::npos; - }) != ops.end()) << "Name not found:" << name; + EXPECT_TRUE(std::find_if(ops.begin(), + ops.end(), + [&](const std::shared_ptr& node) { + return node->get_friendly_name().find(name) != + std::string::npos; + }) != ops.end()) + << "Name not found:" << name; } } @@ -149,11 +148,13 @@ TEST_P(FrontEndCutModelTest, testOldOutputs) // Ensure that it contains expected old outputs for (const auto& name : m_param.m_oldOutputs) { - EXPECT_TRUE(std::find_if(ops.begin(), ops.end(), - [&](const std::shared_ptr& node) - { - return node->get_friendly_name().find(name) != std::string::npos; - }) != ops.end()) << "Name not found:" << name; + EXPECT_TRUE(std::find_if(ops.begin(), + ops.end(), + [&](const std::shared_ptr& node) { + return node->get_friendly_name().find(name) != + std::string::npos; + }) != ops.end()) + << "Name not found:" << name; } } @@ -171,21 +172,25 @@ TEST_P(FrontEndCutModelTest, testNewInputs_func) // Ensure that it doesn't contain old inputs for (const auto& name : m_param.m_oldInputs) { - EXPECT_TRUE(std::find_if(ops.begin(), ops.end(), - [&](const std::shared_ptr& node) - { - return node->get_friendly_name().find(name) != std::string::npos; - }) == ops.end()) << "Name shall not exist:" << name; + EXPECT_TRUE(std::find_if(ops.begin(), + ops.end(), + [&](const std::shared_ptr& node) { + return node->get_friendly_name().find(name) != + std::string::npos; + }) == ops.end()) + << "Name shall not exist:" << name; } // Ensure that it contains expected new inputs for (const auto& name : m_param.m_newInputs) { - EXPECT_TRUE(std::find_if(ops.begin(), ops.end(), - [&](const std::shared_ptr& node) - { - return node->get_friendly_name().find(name) != std::string::npos; - }) != ops.end()) << "Name not found:" << name; + EXPECT_TRUE(std::find_if(ops.begin(), + ops.end(), + [&](const std::shared_ptr& node) { + return node->get_friendly_name().find(name) != + std::string::npos; + }) != ops.end()) + << "Name not found:" << name; } } @@ -203,21 +208,25 @@ TEST_P(FrontEndCutModelTest, testNewOutputs_func) // Ensure that it doesn't contain old outputs for (const auto& name : m_param.m_oldOutputs) { - EXPECT_TRUE(std::find_if(ops.begin(), ops.end(), - [&](const std::shared_ptr& node) - { - return node->get_friendly_name().find(name) != std::string::npos; - }) == ops.end()) << "Name shall not exist:" << name; + EXPECT_TRUE(std::find_if(ops.begin(), + ops.end(), + [&](const std::shared_ptr& node) { + return node->get_friendly_name().find(name) != + std::string::npos; + }) == ops.end()) + << "Name shall not exist:" << name; } // Ensure that it contains expected new outputs for (const auto& name : m_param.m_newOutputs) { - EXPECT_TRUE(std::find_if(ops.begin(), ops.end(), - [&](const std::shared_ptr& node) - { - return node->get_friendly_name().find(name) != std::string::npos; - }) != ops.end()) << "Name not found:" << name; + EXPECT_TRUE(std::find_if(ops.begin(), + ops.end(), + [&](const std::shared_ptr& node) { + return node->get_friendly_name().find(name) != + std::string::npos; + }) != ops.end()) + << "Name not found:" << name; } } @@ -236,21 +245,25 @@ TEST_P(FrontEndCutModelTest, testExtractSubgraph) // Ensure that it doesn't contain expected old outputs for (const auto& name : m_param.m_oldOutputs) { - EXPECT_TRUE(std::find_if(ops.begin(), ops.end(), - [&](const std::shared_ptr& node) - { - return node->get_friendly_name().find(name) != std::string::npos; - }) == ops.end()) << "Name shall not exist:" << name; + EXPECT_TRUE(std::find_if(ops.begin(), + ops.end(), + [&](const std::shared_ptr& node) { + return node->get_friendly_name().find(name) != + std::string::npos; + }) == ops.end()) + << "Name shall not exist:" << name; } // Ensure that it contains expected new outputs for (const auto& name : m_param.m_newOutputs) { - EXPECT_TRUE(std::find_if(ops.begin(), ops.end(), - [&](const std::shared_ptr& node) - { - return node->get_friendly_name().find(name) != std::string::npos; - }) != ops.end()) << "Name not found:" << name; + EXPECT_TRUE(std::find_if(ops.begin(), + ops.end(), + [&](const std::shared_ptr& node) { + return node->get_friendly_name().find(name) != + std::string::npos; + }) != ops.end()) + << "Name not found:" << name; } } @@ -266,13 +279,14 @@ TEST_P(FrontEndCutModelTest, testSetTensorValue) auto ops = function->get_ordered_ops(); auto const_name = m_param.m_tensorValueName; - auto const_node_it = std::find_if(ops.begin(), ops.end(), - [&](const std::shared_ptr& node) - { - return node->get_friendly_name().find(const_name) != std::string::npos; - }); + auto const_node_it = + std::find_if(ops.begin(), ops.end(), [&](const std::shared_ptr& node) { + return node->get_friendly_name().find(const_name) != std::string::npos; + }); ASSERT_TRUE(const_node_it != ops.end()) << "Name shall exist:" << const_name; auto data = std::dynamic_pointer_cast(*const_node_it)->get_vector(); - EXPECT_EQ(data.size(), m_param.m_tensorValue.size()) << "Data size must be equal to expected size"; - EXPECT_TRUE(std::equal(data.begin(), data.end(), m_param.m_tensorValue.begin())) << "Data must be equal"; + EXPECT_EQ(data.size(), m_param.m_tensorValue.size()) + << "Data size must be equal to expected size"; + EXPECT_TRUE(std::equal(data.begin(), data.end(), m_param.m_tensorValue.begin())) + << "Data must be equal"; } diff --git a/ngraph/test/frontend/shared/src/partial_shape.cpp b/ngraph/test/frontend/shared/src/partial_shape.cpp index e71368a487df55..9f8ce264ce9799 100644 --- a/ngraph/test/frontend/shared/src/partial_shape.cpp +++ b/ngraph/test/frontend/shared/src/partial_shape.cpp @@ -2,15 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include #include "../include/partial_shape.hpp" #include "../include/utils.hpp" using namespace ngraph; using namespace ngraph::frontend; -std::string FrontEndPartialShapeTest::getTestCaseName(const testing::TestParamInfo& obj) +std::string + FrontEndPartialShapeTest::getTestCaseName(const testing::TestParamInfo& obj) { BaseFEParam base; PartShape part; @@ -31,7 +30,8 @@ void FrontEndPartialShapeTest::SetUp() void FrontEndPartialShapeTest::initParamTest() { std::tie(m_baseParam, m_partShape) = GetParam(); - m_partShape.m_modelName = std::string(TEST_FILES) + m_baseParam.m_modelsPath + m_partShape.m_modelName; + m_partShape.m_modelName = + std::string(TEST_FILES) + m_baseParam.m_modelsPath + m_partShape.m_modelName; std::cout << "Model: " << m_partShape.m_modelName << std::endl; } @@ -55,11 +55,9 @@ TEST_P(FrontEndPartialShapeTest, testCheckOldPartialShape) std::shared_ptr function; ASSERT_NO_THROW(function = m_frontEnd->convert(m_inputModel)); auto ops = function->get_ordered_ops(); - auto it = std::find_if(ops.begin(), ops.end(), - [&](const std::shared_ptr& node) - { - return node->get_friendly_name().find(m_partShape.m_tensorName) != std::string::npos; - }); + auto it = std::find_if(ops.begin(), ops.end(), [&](const std::shared_ptr& node) { + return node->get_friendly_name().find(m_partShape.m_tensorName) != std::string::npos; + }); ASSERT_NE(it, ops.end()); auto shape = (*it)->get_output_partial_shape(0).get_shape(); ASSERT_EQ(shape.size(), m_partShape.m_oldPartialShape.size()); @@ -75,16 +73,15 @@ TEST_P(FrontEndPartialShapeTest, testSetNewPartialShape) Place::Ptr place; ASSERT_NO_THROW(place = m_inputModel->get_place_by_tensor_name(m_partShape.m_tensorName)); ASSERT_NE(place, nullptr); - ASSERT_NO_THROW(m_inputModel->set_partial_shape(place, PartialShape{m_partShape.m_newPartialShape})); + ASSERT_NO_THROW( + m_inputModel->set_partial_shape(place, PartialShape{m_partShape.m_newPartialShape})); std::shared_ptr function; ASSERT_NO_THROW(function = m_frontEnd->convert(m_inputModel)); auto ops = function->get_ordered_ops(); - auto it = std::find_if(ops.begin(), ops.end(), - [&](const std::shared_ptr& node) - { - return node->get_friendly_name().find(m_partShape.m_tensorName) != std::string::npos; - }); + auto it = std::find_if(ops.begin(), ops.end(), [&](const std::shared_ptr& node) { + return node->get_friendly_name().find(m_partShape.m_tensorName) != std::string::npos; + }); ASSERT_NE(it, ops.end()); auto shape = (*it)->get_output_partial_shape(0).get_shape(); ASSERT_EQ(shape.size(), m_partShape.m_newPartialShape.size()); From f9b27c3714ea987a5c8b8e5644f008496e1255cc Mon Sep 17 00:00:00 2001 From: Tomasz Socha Date: Mon, 7 Jun 2021 13:01:20 +0200 Subject: [PATCH 003/178] =?UTF-8?q?[ONNX]=20=F0=9F=9B=A0=EF=B8=8F?= =?UTF-8?q?=F0=9F=95=B8=EF=B8=8F=20Fix=20softmax=20opsets=20(#5959)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ngraph/frontend/onnx_import/src/op/softmax.cpp | 4 ++-- ngraph/frontend/onnx_import/src/op/softmax.hpp | 4 ++-- ngraph/frontend/onnx_import/src/ops_bridge.cpp | 4 +--- ngraph/python/tests/__init__.py | 2 +- ngraph/python/tests/test_onnx/test_zoo_models.py | 4 +++- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ngraph/frontend/onnx_import/src/op/softmax.cpp b/ngraph/frontend/onnx_import/src/op/softmax.cpp index 1827799b8e38cc..21b23783d19109 100644 --- a/ngraph/frontend/onnx_import/src/op/softmax.cpp +++ b/ngraph/frontend/onnx_import/src/op/softmax.cpp @@ -69,7 +69,7 @@ namespace ngraph return {result}; } } // namespace set_1 - namespace set_7 + namespace set_11 { OutputVector softmax(const Node& node) { @@ -109,7 +109,7 @@ namespace ngraph return {result}; } - } // namespace set_7 + } // namespace set_11 namespace set_13 { OutputVector softmax(const Node& node) diff --git a/ngraph/frontend/onnx_import/src/op/softmax.hpp b/ngraph/frontend/onnx_import/src/op/softmax.hpp index 5528f3dd259c8f..1878c2045fd412 100644 --- a/ngraph/frontend/onnx_import/src/op/softmax.hpp +++ b/ngraph/frontend/onnx_import/src/op/softmax.hpp @@ -19,11 +19,11 @@ namespace ngraph } // namespace set_1 - namespace set_7 + namespace set_11 { OutputVector softmax(const Node& node); - } // namespace set_7 + } // namespace set_11 namespace set_13 { diff --git a/ngraph/frontend/onnx_import/src/ops_bridge.cpp b/ngraph/frontend/onnx_import/src/ops_bridge.cpp index 511c059c61badd..b807a31212db64 100644 --- a/ngraph/frontend/onnx_import/src/ops_bridge.cpp +++ b/ngraph/frontend/onnx_import/src/ops_bridge.cpp @@ -437,9 +437,7 @@ namespace ngraph REGISTER_OPERATOR("Slice", 1, slice); REGISTER_OPERATOR("Slice", 10, slice); REGISTER_OPERATOR("Softmax", 1, softmax); - // Softmax v7 should be in the 11th opset but, - // other frameworks(mxnet and onnxruntime) already use for older models. - REGISTER_OPERATOR("Softmax", 7, softmax); + REGISTER_OPERATOR("Softmax", 11, softmax); REGISTER_OPERATOR("Softmax", 13, softmax); REGISTER_OPERATOR("Softplus", 1, softplus); REGISTER_OPERATOR("Softsign", 1, softsign); diff --git a/ngraph/python/tests/__init__.py b/ngraph/python/tests/__init__.py index 5ec9abe7a7bc5a..930be465a632d3 100644 --- a/ngraph/python/tests/__init__.py +++ b/ngraph/python/tests/__init__.py @@ -149,5 +149,5 @@ def xfail_test(reason="Mark the test as expected to fail", strict=True): xfail_issue_49754 = xfail_test(reason="RuntimeError: Unsupported dynamic ops: v1::TopKIE") xfail_issue_52463 = xfail_test(reason="test_operator_add_size1_singleton_broadcast_cpu - " "Not equal to tolerance") - xfail_issue_45432 = xfail_test(reason="Einsum is not implemented in CPU plugin.") +xfail_issue_onnx_models_140 = xfail_test(reason="https://github.com/onnx/models/issues/140") diff --git a/ngraph/python/tests/test_onnx/test_zoo_models.py b/ngraph/python/tests/test_onnx/test_zoo_models.py index 449ad50457aef0..1954b61e64661d 100644 --- a/ngraph/python/tests/test_onnx/test_zoo_models.py +++ b/ngraph/python/tests/test_onnx/test_zoo_models.py @@ -25,7 +25,8 @@ xfail_issue_47430, xfail_issue_47495, xfail_issue_48145, - xfail_issue_48190) + xfail_issue_48190, + xfail_issue_onnx_models_140) MODELS_ROOT_DIR = tests.MODEL_ZOO_DIR @@ -170,6 +171,7 @@ def tinyyolov3_post_processing(outputs : Sequence[Any]) -> Sequence[Any]: (xfail_issue_47430, "test_onnx_model_zoo_vision_object_detection_segmentation_fcn_model_fcn_resnet101_11_fcn_resnet101_11_model_cpu"), (xfail_issue_48145, "test_onnx_model_zoo_text_machine_comprehension_bert_squad_model_bertsquad_8_download_sample_8_bertsquad8_cpu"), (xfail_issue_48190, "test_onnx_model_zoo_text_machine_comprehension_roberta_model_roberta_base_11_roberta_base_11_roberta_base_11_cpu"), + (xfail_issue_onnx_models_140, "test_onnx_model_zoo_vision_object_detection_segmentation_duc_model_ResNet101_DUC_7_ResNet101_DUC_HDC_ResNet101_DUC_HDC_cpu"), # Model MSFT (xfail_issue_37973, "test_MSFT_opset7_tf_inception_v2_model_cpu"), From c1608628d42fbc0d70d94abb7c5cff27c5469a24 Mon Sep 17 00:00:00 2001 From: Ivan Tikhonov Date: Mon, 7 Jun 2021 15:13:41 +0300 Subject: [PATCH 004/178] LowLatency v2 ngraph transformation (#5160) * LowLatency 2.0: transformation and unit tests * low latency 2.0: unit tests * documentation and ngraph codestyle * update CNN Interface of LowLatency transformation * fix build on Windows * fix build on Windows * investigation of a failed build on Win OS * ngraph codestyle * fix build (werrors) * New unit tests, refactoring * update functional tests for Memory * update LowLatency functional tests * extend Memory tests to cover LowLatency v2 transformation * clean up, code style * fix unit tests * update and fix unit tests, add feature to apply LLTv2 after LLTv1 * update docs, refactoring * add several gna tests to skip config * fix python api tests * update python api, rename LowLatency_v2 to LowLatency2 * deprecate LowLatency v1 * Deprecate LowLatency v1 in IE * fix wrong merge, codestyle * resolve review comments * fix python test * update skip config * apply online review notes, fix unit tests * clean up, code style * fix docs * Use debug_messages instead of exceptions in llt v2 * fix unit tests * Resolve review remarks --- .../offline_transformations_api.pyx | 4 +- .../offline_transformations_api_impl.cpp | 11 +- .../offline_transformations_api_impl.hpp | 2 +- .../offline_transformations_api_impl_defs.pxd | 5 +- .../python/tests/test_offline_api.py | 2 +- .../include/ie_transformations.hpp | 36 + .../inference_engine/ie_transformations.cpp | 10 + .../transformations/low_latency_test.cpp | 10 + .../transformations/low_latency_v2_test.cpp | 829 ++++++++++++++++++ .../single_layer_tests/memory.cpp | 8 + .../subgraph_tests/memory_LSTMCell.cpp | 45 + .../subgraph_tests/multiple_LSTMCell.cpp | 10 + .../single_layer_tests/memory.cpp | 12 +- .../skip_tests_config.cpp | 8 + .../subgraph_tests/memory_LSTMCell.cpp | 9 + .../subgraph_tests/multiple_LSTMCell.cpp | 10 + .../include/subgraph_tests/basic_lstm.hpp | 2 +- .../subgraph_tests/memory_LSTMCell.hpp | 8 - .../subgraph_tests/multiple_LSTMCell.hpp | 8 - .../single_layer/memory.hpp | 9 + .../subgraph/memory_LSTMCell.hpp | 8 +- .../subgraph/multiple_LSTMCell.hpp | 8 +- .../src/single_layer/memory.cpp | 116 ++- .../src/subgraph/memory_LSTMCell.cpp | 281 +++--- .../src/subgraph/multiple_LSTMCell.cpp | 432 ++++----- .../ngraph_functions/utils/ngraph_helpers.hpp | 11 + .../src/utils/ngraph_helpers.cpp | 27 + .../mo/back/offline_transformations.py | 2 +- model-optimizer/mo/utils/cli_parser.py | 17 +- .../unit_tests/mo/utils/cli_parser_test.py | 45 +- .../core/include/ngraph/pass/low_latency.hpp | 44 +- ngraph/core/src/op/tensor_iterator.cpp | 1 - ngraph/core/src/pass/low_latency.cpp | 203 ++++- 33 files changed, 1806 insertions(+), 427 deletions(-) create mode 100644 inference-engine/tests/functional/inference_engine/transformations/low_latency_v2_test.cpp create mode 100644 inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/memory_LSTMCell.cpp diff --git a/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api.pyx b/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api.pyx index bd101280fcbb16..266c1dc94d9475 100644 --- a/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api.pyx +++ b/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api.pyx @@ -17,8 +17,8 @@ def ApplyPOTTransformations(IENetwork network, string device): C.ApplyPOTTransformations(network.impl, device) -def ApplyLowLatencyTransformation(IENetwork network, int64_t num_iterations=1): - C.ApplyLowLatencyTransformation(network.impl, num_iterations) +def ApplyLowLatencyTransformation(IENetwork network, bool use_const_initializer = True): + C.ApplyLowLatencyTransformation(network.impl, use_const_initializer) def ApplyPruningTransformation(IENetwork network): diff --git a/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl.cpp b/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl.cpp index b9ff879da8c843..183deaccfb388f 100644 --- a/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl.cpp +++ b/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl.cpp @@ -26,16 +26,9 @@ void InferenceEnginePython::ApplyPOTTransformations(InferenceEnginePython::IENet manager.run_passes(network.actual->getFunction()); } -void InferenceEnginePython::ApplyLowLatencyTransformation(InferenceEnginePython::IENetwork network, int64_t num_iterations) { +void InferenceEnginePython::ApplyLowLatencyTransformation(InferenceEnginePython::IENetwork network, bool use_const_initializer) { ngraph::pass::Manager manager; - // TODO: pass num_iterations to LowLatency - manager.register_pass(); - manager.register_pass(); - - auto pass_config = manager.get_pass_config(); - pass_config->set_callback([](const std::shared_ptr& node) -> bool { - return node->get_rt_info().count("UNROLL_TI") == 0; - }); + manager.register_pass(use_const_initializer); manager.run_passes(network.actual->getFunction()); } diff --git a/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl.hpp b/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl.hpp index 504388e4afc1ad..3941c48a50cfaa 100644 --- a/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl.hpp +++ b/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl.hpp @@ -15,7 +15,7 @@ void ApplyMOCTransformations(InferenceEnginePython::IENetwork network, bool cf); void ApplyPOTTransformations(InferenceEnginePython::IENetwork network, std::string device); -void ApplyLowLatencyTransformation(InferenceEnginePython::IENetwork network, int64_t num_iterations); +void ApplyLowLatencyTransformation(InferenceEnginePython::IENetwork network, bool use_const_initializer = true); void ApplyPruningTransformation(InferenceEnginePython::IENetwork network); diff --git a/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl_defs.pxd b/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl_defs.pxd index 726880e9353f37..551e56c27a8da0 100644 --- a/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl_defs.pxd +++ b/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl_defs.pxd @@ -3,7 +3,6 @@ from libcpp cimport bool from libcpp.string cimport string -from libc.stdint cimport int64_t from ..inference_engine.ie_api_impl_defs cimport IENetwork @@ -12,10 +11,10 @@ cdef extern from "offline_transformations_api_impl.hpp" namespace "InferenceEngi cdef void ApplyPOTTransformations(IENetwork network, string device) - cdef void ApplyLowLatencyTransformation(IENetwork network, int64_t num_iterations) + cdef void ApplyLowLatencyTransformation(IENetwork network, bool use_const_initializer) cdef void ApplyPruningTransformation(IENetwork network) cdef void GenerateMappingFile(IENetwork network, string path, bool extract_names) - cdef void CheckAPI() \ No newline at end of file + cdef void CheckAPI() diff --git a/inference-engine/ie_bridges/python/tests/test_offline_api.py b/inference-engine/ie_bridges/python/tests/test_offline_api.py index b5565c04bb4d66..0bba0951c27c87 100644 --- a/inference-engine/ie_bridges/python/tests/test_offline_api.py +++ b/inference-engine/ie_bridges/python/tests/test_offline_api.py @@ -49,4 +49,4 @@ def test_pruning_transformations(): f = ng.function_from_cnn(net) assert f != None - assert len(f.get_ops()) == 3 \ No newline at end of file + assert len(f.get_ops()) == 3 diff --git a/inference-engine/include/ie_transformations.hpp b/inference-engine/include/ie_transformations.hpp index 6691fa74daeedd..0867b02972c471 100644 --- a/inference-engine/include/ie_transformations.hpp +++ b/inference-engine/include/ie_transformations.hpp @@ -52,5 +52,41 @@ namespace InferenceEngine { * @param network A network to apply LowLatency transformation * * */ + +INFERENCE_ENGINE_DEPRECATED("This transformation will be removed in 2023.1. " + "Use InferenceEngine::lowLatency2 instead.") INFERENCE_ENGINE_API_CPP(void) LowLatency(InferenceEngine::CNNNetwork& network); + + +/** + * @brief The transformation finds all TensorIterator/Loop layers in the network, + * processes all back edges that describe a connection between Result and Parameter + * of the TensorIterator/Loop bodies,and inserts ReadValue and Assign layers at the + * input and output corresponding to this back edge. + * Supported platforms: CPU, GNA. + * + * The example below describes the changes made by the transformation + * [] - TensorIterator body + * () - new layer + * BE - back-edge + * + * before applying the transformation: + * -> input1[BE_1 -> Parameter -> Layers ... -> Result -> BE_1 ]output1-> + * + * after applying the transformation: + * ->(ReadValue)-> input1[BE_1 ->Parameter->Layers ...->Result->BE_1]output1 ->(Assign) + * \ + * ->... + * After applying the transformation, the resulting network can be inferred + * step by step, the states will store between inferences. + * @param network A network to apply LowLatency transformation + * @param use_const_initializer Changes the type of the initializing subgraph for ReadValue operations. + If "true", then the transformation inserts Constant before ReadValue operation. + If "false, then the transformation leaves existed initializing subgraph for ReadValue operation. + * Loop operation by a given number. Does not affect TensorIterators. + * * + */ +INFERENCE_ENGINE_API_CPP(void) lowLatency2(InferenceEngine::CNNNetwork& network, + bool use_const_initializer = true); + } // namespace InferenceEngine diff --git a/inference-engine/src/inference_engine/ie_transformations.cpp b/inference-engine/src/inference_engine/ie_transformations.cpp index 15360ae97ea09a..2a87671ce25d4f 100644 --- a/inference-engine/src/inference_engine/ie_transformations.cpp +++ b/inference-engine/src/inference_engine/ie_transformations.cpp @@ -11,6 +11,16 @@ using namespace InferenceEngine; void InferenceEngine::LowLatency(InferenceEngine::CNNNetwork &network) { auto function = network.getFunction(); ngraph::pass::Manager manager; + NGRAPH_SUPPRESS_DEPRECATED_START manager.register_pass(); + NGRAPH_SUPPRESS_DEPRECATED_END + manager.run_passes(function); +} + +void InferenceEngine::lowLatency2(InferenceEngine::CNNNetwork &network, + bool use_const_initializer) { + auto function = network.getFunction(); + ngraph::pass::Manager manager; + manager.register_pass(use_const_initializer); manager.run_passes(function); } diff --git a/inference-engine/tests/functional/inference_engine/transformations/low_latency_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/low_latency_test.cpp index 69cb89991a3ed7..2d1594d38411db 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/low_latency_test.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/low_latency_test.cpp @@ -68,7 +68,9 @@ TEST(TransformationTests, LowLatencyLSTM) { ngraph::pass::Manager manager; manager.register_pass(); + NGRAPH_SUPPRESS_DEPRECATED_START manager.register_pass(); + NGRAPH_SUPPRESS_DEPRECATED_END manager.register_pass(); manager.run_passes(f); } @@ -149,7 +151,9 @@ TEST(TransformationTests, LowLatencyGRU) { ngraph::pass::Manager manager; manager.register_pass(); + NGRAPH_SUPPRESS_DEPRECATED_START manager.register_pass(); + NGRAPH_SUPPRESS_DEPRECATED_END manager.register_pass(); manager.run_passes(f); @@ -227,7 +231,9 @@ TEST(TransformationTests, LowLatencyRNN) { ngraph::pass::Manager manager; manager.register_pass(); + NGRAPH_SUPPRESS_DEPRECATED_START manager.register_pass(); + NGRAPH_SUPPRESS_DEPRECATED_END manager.register_pass(); manager.run_passes(f); @@ -317,7 +323,9 @@ TEST(TransformationTests, LowLatencyLSTMReshape) { ngraph::pass::Manager manager; manager.register_pass(); + NGRAPH_SUPPRESS_DEPRECATED_START manager.register_pass(); + NGRAPH_SUPPRESS_DEPRECATED_END manager.register_pass(); manager.run_passes(f); } @@ -413,7 +421,9 @@ TEST(TransformationTests, LowLatencyLSTM_Loop) { ngraph::pass::Manager manager; manager.register_pass(); + NGRAPH_SUPPRESS_DEPRECATED_START manager.register_pass(); + NGRAPH_SUPPRESS_DEPRECATED_END manager.register_pass(); manager.run_passes(f); } diff --git a/inference-engine/tests/functional/inference_engine/transformations/low_latency_v2_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/low_latency_v2_test.cpp new file mode 100644 index 00000000000000..5c66e8109ef688 --- /dev/null +++ b/inference-engine/tests/functional/inference_engine/transformations/low_latency_v2_test.cpp @@ -0,0 +1,829 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include "common_test_utils/ngraph_test_utils.hpp" + +using namespace testing; +using namespace ngraph; +using namespace opset7; +using namespace std; + +Output create_init_subgraph(const Output& in_node) { + auto const_zero = make_shared(in_node.get_element_type(), Shape{1}, 0); + auto shape_of = make_shared(in_node); + auto broadcast = make_shared(const_zero, shape_of); + return broadcast->output(0); +} + +Output insert_identity(const Output& in_node) { + auto axis_1 = Constant::create(element::i64, Shape{1}, {1}); + auto identity_1 = std::make_shared(in_node, axis_1); + return std::make_shared(identity_1, axis_1); +} + +std::shared_ptr createLSTMBody(const std::shared_ptr& Xi, + const std::shared_ptr& H_t, + const std::shared_ptr& C_t, + bool is_loop = false) { + // Body + auto axis = Constant::create(element::i64, Shape{}, {0}); + auto squeeze = std::make_shared(Xi, axis); + + auto w_val = std::vector(512 * 16, 0); + auto r_val = std::vector(512 * 128, 0); + auto b_val = std::vector(512, 0); + auto W = Constant::create(element::f32, Shape{512, 16}, w_val); + auto R = Constant::create(element::f32, Shape{512, 128}, r_val); + auto B = Constant::create(element::f32, Shape{512}, b_val); + + auto lstm_cell = std::make_shared(squeeze, H_t, C_t, W, R, B, 128); + auto res_1 = std::make_shared(lstm_cell->output(0)); + auto unsqueeze = std::make_shared(lstm_cell->output(0), axis); + auto res_2 = std::make_shared(unsqueeze); + auto res_3 = std::make_shared(lstm_cell->output(1)); + + auto func = std::make_shared(OutputVector{res_1, res_2, res_3}, + ParameterVector{Xi, H_t, C_t}); + if (is_loop) { + auto body_condition = std::make_shared( + element::boolean, Shape{1}, true); + auto cond_res = std::make_shared(body_condition); + func->add_results({cond_res}); + } + return func; +} + +TEST(TransformationTests, LowLatency2_LSTM) { + std::shared_ptr f(nullptr), f_ref(nullptr); + { + auto X = std::make_shared(element::f32, Shape{1, 1, 16}); + auto H_init = std::make_shared(element::f32, Shape{1, 128}); + auto C_init = std::make_shared(element::f32, Shape{1, 128}); + + auto Xi = std::make_shared(element::f32, Shape{1, 1, 16}); + auto H_t = std::make_shared(element::f32, Shape{1, 128}); + auto C_t = std::make_shared(element::f32, Shape{1, 128}); + + // Body + auto body = createLSTMBody(Xi, H_t, C_t); + auto results = body->get_results(); + + auto tensor_iterator = std::make_shared(); + tensor_iterator->set_body(body); + tensor_iterator->set_friendly_name("LSTMTensorIterator"); + + tensor_iterator->set_merged_input(C_t, C_init, results[2]); + tensor_iterator->set_sliced_input(Xi, X, 0, 1, 1, -1, 0); + tensor_iterator->set_merged_input(H_t, H_init, results[0]); + + tensor_iterator->get_iter_value(results[0], -1); + tensor_iterator->get_concatenated_slices(results[1], 0, 1, 1, -1, 0); + + auto res_ti_1 = std::make_shared(tensor_iterator->output(1)); + auto res_ti_2 = std::make_shared(tensor_iterator->output(0)); + f = std::make_shared(NodeVector{res_ti_1, res_ti_2}, + ParameterVector{X, H_init, C_init}); + + pass::Manager manager; + manager.register_pass(); + manager.register_pass(); + manager.run_passes(f); + ASSERT_NO_THROW(check_rt_info(f)); + } + { + auto Xi = std::make_shared(element::f32, Shape{1, 1, 16}); + auto H_t = std::make_shared(element::f32, Shape{1, 128}); + auto C_t = std::make_shared(element::f32, Shape{1, 128}); + + const std::string variable_name_H("LSTMTensorIterator/variable0"); + const std::string variable_name_C("LSTMTensorIterator/variable1"); + auto variable_H = std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, variable_name_H}); + auto variable_C = std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, variable_name_C}); + auto read_value_H = std::make_shared(create_init_subgraph(H_t), variable_H); + auto read_value_C = std::make_shared(create_init_subgraph(C_t), variable_C); + // Body + auto axis = Constant::create(element::i64, Shape{}, {0}); + auto squeeze = std::make_shared(Xi, axis); + + auto w_val = std::vector(512 * 16, 0); + auto r_val = std::vector(512 * 128, 0); + auto b_val = std::vector(512, 0); + auto W = Constant::create(element::f32, Shape{512, 16}, w_val); + auto R = Constant::create(element::f32, Shape{512, 128}, r_val); + auto B = Constant::create(element::f32, Shape{512}, b_val); + + auto lstm_cell = std::make_shared(squeeze, read_value_H, read_value_C, W, R, B, 128); + auto assign_H = std::make_shared(lstm_cell->output(0), variable_H); + auto assign_C = std::make_shared(lstm_cell->output(1), variable_C); + auto unsqueeze = std::make_shared(lstm_cell->output(0), axis); + auto res_2 = std::make_shared(insert_identity(unsqueeze)); + auto res_1 = std::make_shared(insert_identity(lstm_cell->output(0))); + f_ref = std::make_shared(OutputVector{res_1, res_2}, ParameterVector{Xi, H_t, C_t}); + f_ref->add_sinks({assign_C, assign_H}); + assign_H->add_control_dependency(read_value_H); + assign_C->add_control_dependency(read_value_C); + } + auto res = compare_functions(f, f_ref); + ASSERT_TRUE(res.first) << res.second; +} + +TEST(TransformationTests, LowLatency2_GRU) { + std::shared_ptr f(nullptr), f_ref(nullptr); + { + auto X = std::make_shared(element::f32, Shape{1, 1, 16}); + auto Y = std::make_shared(element::f32, Shape{1, 128}); + + auto Xi = std::make_shared(element::f32, Shape{1, 1, 16}); + auto Yi = std::make_shared(element::f32, Shape{1, 128}); + + // Body + auto axis = Constant::create(element::i64, Shape{}, {0}); + auto squeeze = std::make_shared(Xi, axis); + + auto w_val = std::vector(384 * 16, 0); + auto r_val = std::vector(384 * 128, 0); + auto b_val = std::vector(384, 0); + auto W = Constant::create(element::f32, Shape{384, 16}, w_val); + auto R = Constant::create(element::f32, Shape{384, 128}, r_val); + auto B = Constant::create(element::f32, Shape{384}, b_val); + + auto gru_cell = std::make_shared(squeeze, Yi, W, R, B, 128); + auto res_1 = std::make_shared(gru_cell); + auto unsqueeze = std::make_shared(gru_cell, axis); + auto res_2 = std::make_shared(unsqueeze); + auto body = std::make_shared(OutputVector{res_1, res_2}, ParameterVector{Xi, Yi}); + + auto tensor_iterator = std::make_shared(); + tensor_iterator->set_body(body); + + tensor_iterator->set_sliced_input(Xi, X, 0, 1, 1, -1, 0); + tensor_iterator->set_merged_input(Yi, Y, res_1); + + auto out0 = tensor_iterator->get_iter_value(res_1, -1); + auto out1 = tensor_iterator->get_concatenated_slices(res_2, 0, 1, 1, -1, 0); + + auto res_ti_1 = std::make_shared(tensor_iterator->output(1)); + f = std::make_shared(NodeVector{res_ti_1}, ParameterVector{X, Y}); + + pass::Manager manager; + manager.register_pass(); + manager.register_pass(); + + manager.run_passes(f); + + ASSERT_NO_THROW(check_rt_info(f)); + } + { + auto Xi = std::make_shared(element::f32, Shape{1, 1, 16}); + auto H_t = std::make_shared(element::f32, Shape{1, 128}); + + const std::string variable_name_H("GRUTensorIterator/variable0"); + auto variable_H = std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, variable_name_H}); + auto read_value_H = std::make_shared(create_init_subgraph(H_t), variable_H); + // Body + auto axis = Constant::create(element::i64, Shape{}, {0}); + auto squeeze = std::make_shared(Xi, axis); + + auto w_val = std::vector(384 * 16, 0); + auto r_val = std::vector(384 * 128, 0); + auto b_val = std::vector(384, 0); + auto W = Constant::create(element::f32, Shape{384, 16}, w_val); + auto R = Constant::create(element::f32, Shape{384, 128}, r_val); + auto B = Constant::create(element::f32, Shape{384}, b_val); + + auto rnn_cell = std::make_shared(squeeze, read_value_H, W, R, B, 128); + auto assign_H = std::make_shared(rnn_cell->output(0), variable_H); + auto res_1 = std::make_shared(assign_H); + auto unsqueeze = std::make_shared(rnn_cell->output(0), axis); + auto res_2 = std::make_shared(insert_identity(unsqueeze)); + f_ref = std::make_shared(ResultVector {res_2}, ParameterVector{Xi, H_t}); + f_ref->add_sinks({assign_H}); + assign_H->add_control_dependency(read_value_H); + } + auto res = compare_functions(f, f_ref); + ASSERT_TRUE(res.first) << res.second; +} + +TEST(TransformationTests, LowLatency2_RNN) { + std::shared_ptr f(nullptr), f_ref(nullptr); + { + auto X = std::make_shared(element::f32, Shape{1, 1, 16}); + auto Y = std::make_shared(element::f32, Shape{1, 128}); + + auto Xi = std::make_shared(element::f32, Shape{1, 1, 16}); + auto Yi = std::make_shared(element::f32, Shape{1, 128}); + + // Body + auto axis = Constant::create(element::i64, Shape{}, {0}); + auto squeeze = std::make_shared(Xi, axis); + + auto w_val = std::vector(128 * 16, 0); + auto r_val = std::vector(128 * 128, 0); + auto b_val = std::vector(128, 0); + auto W = Constant::create(element::f32, Shape{128, 16}, w_val); + auto R = Constant::create(element::f32, Shape{128, 128}, r_val); + auto B = Constant::create(element::f32, Shape{128}, b_val); + + auto rnn_cell = std::make_shared(squeeze, Yi, W, R, B, 128); + auto res_1 = std::make_shared(rnn_cell); + auto unsqueeze = std::make_shared(rnn_cell, axis); + auto res_2 = std::make_shared(unsqueeze); + auto body = std::make_shared(OutputVector{res_1, res_2}, ParameterVector{Xi, + Yi}); + + auto tensor_iterator = std::make_shared(); + tensor_iterator->set_body(body); + + tensor_iterator->set_sliced_input(Xi, X, 0, 1, 1, -1, 0); + tensor_iterator->set_merged_input(Yi, Y, res_1); + + auto out0 = tensor_iterator->get_iter_value(res_1, -1); + auto out1 = tensor_iterator->get_concatenated_slices(res_2, 0, 1, 1, -1, 0); + + auto res_ti_1 = std::make_shared(tensor_iterator->output(1)); + f = std::make_shared(NodeVector{res_ti_1}, ParameterVector{X, Y}); + + pass::Manager manager; + manager.register_pass(); + manager.register_pass(); + + manager.run_passes(f); + + ASSERT_NO_THROW(check_rt_info(f)); + } + { + auto Xi = std::make_shared(element::f32, Shape{1, 1, 16}); + auto H_t = std::make_shared(element::f32, Shape{1, 128}); + + const std::string variable_name_H("RNNTensorIterator/variable0"); + auto variable_H = std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, variable_name_H}); + auto read_value_H = std::make_shared(create_init_subgraph(H_t), variable_H); + // Body + auto axis = Constant::create(element::i64, Shape{}, {0}); + auto squeeze = std::make_shared(Xi, axis); + + auto w_val = std::vector(128 * 16, 0); + auto r_val = std::vector(128 * 128, 0); + auto b_val = std::vector(128, 0); + auto W = Constant::create(element::f32, Shape{128, 16}, w_val); + auto R = Constant::create(element::f32, Shape{128, 128}, r_val); + auto B = Constant::create(element::f32, Shape{128}, b_val); + + auto rnn_cell = std::make_shared(squeeze, read_value_H, W, R, B, 128); + auto assign_H = std::make_shared(rnn_cell->output(0), variable_H); + auto res_1 = std::make_shared(assign_H); + auto unsqueeze = std::make_shared(rnn_cell->output(0), axis); + auto res_2 = std::make_shared(insert_identity(unsqueeze)); + f_ref = std::make_shared(ResultVector{res_2}, ParameterVector{Xi, H_t}); + f_ref->add_sinks({assign_H}); + assign_H->add_control_dependency(read_value_H); + } + auto res = compare_functions(f, f_ref); + ASSERT_TRUE(res.first) << res.second; +} + +TEST(TransformationTests, LowLatency2_LSTMReshape) { + std::shared_ptr f(nullptr), f_ref(nullptr); + { + auto X = std::make_shared(element::f32, Shape{2, 1, 16}); + auto H = std::make_shared(element::f32, Shape{1, 128}); + auto C = std::make_shared(element::f32, Shape{1, 128}); + + auto Xi = std::make_shared(element::f32, Shape{1, 1, 16}); + auto H_t = std::make_shared(element::f32, Shape{1, 128}); + auto C_t = std::make_shared(element::f32, Shape{1, 128}); + + // Body + auto body = createLSTMBody(Xi, H_t, C_t); + auto results = body->get_results(); + + auto tensor_iterator = std::make_shared(); + tensor_iterator->set_body(body); + + tensor_iterator->set_merged_input(C_t, C, results[2]); + tensor_iterator->set_sliced_input(Xi, X, 0, 1, 1, -1, 0); + tensor_iterator->set_merged_input(H_t, H, results[0]); + + auto out0 = tensor_iterator->get_iter_value(results[0], -1); + auto out1 = tensor_iterator->get_concatenated_slices(results[1], 0, 1, 1, -1, 0); + + auto res_ti_1 = std::make_shared(tensor_iterator->output(1)); + auto res_ti_2 = std::make_shared(tensor_iterator->output(0)); + f = std::make_shared(NodeVector{res_ti_1, res_ti_2}, ParameterVector{X, H, + C}); + + // Reshape + // change the number of iteration of TI. 2 -> 1 + auto new_X = std::make_shared(element::f32, Shape{1, 1, 16}); + f->replace_parameter(0, new_X); + f->validate_nodes_and_infer_types(); + + pass::Manager manager; + manager.register_pass(); + manager.register_pass(); + + manager.run_passes(f); + ASSERT_NO_THROW(check_rt_info(f)); + } + { + auto Xi = std::make_shared(element::f32, Shape{1, 1, 16}); + auto H_t = std::make_shared(element::f32, Shape{1, 128}); + auto C_t = std::make_shared(element::f32, Shape{1, 128}); + + const std::string variable_name_H("LSTMTensorIterator/variable0"); + const std::string variable_name_C("LSTMTensorIterator/variable1"); + auto variable_H = std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, variable_name_H}); + auto variable_C = std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, variable_name_C}); + auto read_value_H = std::make_shared(create_init_subgraph(H_t), variable_H); + auto read_value_C = std::make_shared(create_init_subgraph(C_t), variable_C); + // Body + auto axis = Constant::create(element::i64, Shape{}, {0}); + auto squeeze = std::make_shared(Xi, axis); + + auto w_val = std::vector(512 * 16, 0); + auto r_val = std::vector(512 * 128, 0); + auto b_val = std::vector(512, 0); + auto W = Constant::create(element::f32, Shape{512, 16}, w_val); + auto R = Constant::create(element::f32, Shape{512, 128}, r_val); + auto B = Constant::create(element::f32, Shape{512}, b_val); + + auto lstm_cell = std::make_shared(squeeze, read_value_H, read_value_C, W, R, B, 128); + auto assign_H = std::make_shared(lstm_cell->output(0), variable_H); + auto assign_C = std::make_shared(lstm_cell->output(1), variable_C); + auto unsqueeze = std::make_shared(lstm_cell->output(0), axis); + auto res_2 = std::make_shared(insert_identity(unsqueeze)); + auto res_1 = std::make_shared(insert_identity(lstm_cell->output(0))); + f_ref = std::make_shared(OutputVector{res_1, res_2}, ParameterVector{Xi, H_t, C_t}); + f_ref->add_sinks({assign_C, assign_H}); + assign_H->add_control_dependency(read_value_H); + assign_C->add_control_dependency(read_value_C); + } + auto res = compare_functions(f, f_ref); + ASSERT_TRUE(res.first) << res.second; +} + +TEST(TransformationTests, LowLatency2_LSTM_Loop) { + std::shared_ptr f(nullptr), f_ref(nullptr); + { + auto X = std::make_shared(element::f32, Shape{1, 1, 16}); + auto H_init = std::make_shared(element::f32, Shape{1, 128}); + auto C_init = std::make_shared(element::f32, Shape{1, 128}); + + auto Xi = std::make_shared(element::f32, Shape{1, 1, 16}); + auto H_t = std::make_shared(element::f32, Shape{1, 128}); + auto C_t = std::make_shared(element::f32, Shape{1, 128}); + + // Body + auto axis = Constant::create(element::i64, Shape{}, {0}); + auto squeeze = std::make_shared(Xi, axis); + + // Body + auto body = createLSTMBody(Xi, H_t, C_t, true); + auto results = body->get_results(); + + auto trip_count = + std::make_shared(element::i64, Shape{}, 1); + auto exec_condition = + std::make_shared(element::boolean, Shape{}, true); + auto loop = std::make_shared(trip_count, exec_condition); + loop->set_special_body_ports({-1, 3}); + loop->set_function(body); + loop->set_friendly_name("LSTMLoop"); + + loop->set_merged_input(C_t, C_init, results[2]); + loop->set_sliced_input(Xi, X, 0, 1, 1, -1, 0); + loop->set_merged_input(H_t, H_init, results[0]); + + auto out0 = loop->get_iter_value(results[0], -1); + auto out1 = loop->get_concatenated_slices(results[1], 0, 1, 1, -1, 0); + + auto res_ti_1 = std::make_shared(loop->output(1)); + auto res_ti_2 = std::make_shared(loop->output(0)); + f = std::make_shared(NodeVector{res_ti_1, res_ti_2}, + ParameterVector{X, H_init, C_init}); + + pass::Manager manager; + manager.register_pass(); + manager.register_pass(); + + manager.run_passes(f); + ASSERT_NO_THROW(check_rt_info(f)); + } + { + auto Xi = std::make_shared(element::f32, Shape{1, 1, 16}); + auto H_t = std::make_shared(element::f32, Shape{1, 128}); + auto C_t = std::make_shared(element::f32, Shape{1, 128}); + + const std::string variable_name_H("LSTMTensorIterator/variable0"); + const std::string variable_name_C("LSTMTensorIterator/variable1"); + auto variable_H = std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, variable_name_H}); + auto variable_C = std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, variable_name_C}); + auto read_value_H = std::make_shared(create_init_subgraph(H_t), variable_H); + auto read_value_C = std::make_shared(create_init_subgraph(C_t), variable_C); + // Body + auto axis = Constant::create(element::i64, Shape{}, {0}); + auto squeeze = std::make_shared(Xi, axis); + + auto w_val = std::vector(512 * 16, 0); + auto r_val = std::vector(512 * 128, 0); + auto b_val = std::vector(512, 0); + auto W = Constant::create(element::f32, Shape{512, 16}, w_val); + auto R = Constant::create(element::f32, Shape{512, 128}, r_val); + auto B = Constant::create(element::f32, Shape{512}, b_val); + + auto lstm_cell = std::make_shared(squeeze, read_value_H, read_value_C, W, R, B, 128); + auto assign_H = std::make_shared(lstm_cell->output(0), variable_H); + auto assign_C = std::make_shared(lstm_cell->output(1), variable_C); + auto unsqueeze = std::make_shared(lstm_cell->output(0), axis); + auto res_2 = std::make_shared(insert_identity(unsqueeze)); + auto res_1 = std::make_shared(insert_identity(lstm_cell->output(0))); + f_ref = std::make_shared(OutputVector{res_1, res_2}, ParameterVector{Xi, H_t, C_t}); + f_ref->add_sinks({assign_C, assign_H}); + assign_H->add_control_dependency(read_value_H); + assign_C->add_control_dependency(read_value_C); + } + auto res = compare_functions(f, f_ref); + ASSERT_TRUE(res.first) << res.second; +} + +TEST(TransformationTests, LowLatency2_LSTM_several_iterations) { + constexpr int ITER_CNT = 5; + std::shared_ptr f(nullptr), f_ref(nullptr); + { + auto X = std::make_shared(element::f32, Shape{ITER_CNT, 1, 16}); + auto H = std::make_shared(element::f32, Shape{1, 128}); + auto C = std::make_shared(element::f32, Shape{1, 128}); + + auto Xi = std::make_shared(element::f32, Shape{1, 1, 16}); + auto H_t = std::make_shared(element::f32, Shape{1, 128}); + auto C_t = std::make_shared(element::f32, Shape{1, 128}); + + // Body + auto body = createLSTMBody(Xi, H_t, C_t); + auto results = body->get_results(); + + auto tensor_iterator = std::make_shared(); + tensor_iterator->set_body(body); + + tensor_iterator->set_merged_input(C_t, C, results[2]); + tensor_iterator->set_sliced_input(Xi, X, 0, 1, 1, -1, 0); + tensor_iterator->set_merged_input(H_t, H, results[0]); + + auto out0 = tensor_iterator->get_iter_value(results[0], -1); + auto out1 = tensor_iterator->get_concatenated_slices(results[1], 0, 1, 1, -1, 0); + + auto res_ti_1 = std::make_shared(tensor_iterator->output(1)); + auto res_ti_2 = std::make_shared(tensor_iterator->output(0)); + f = std::make_shared(NodeVector{res_ti_1, res_ti_2}, ParameterVector{X, H, + C}); + + pass::Manager manager; + manager.register_pass(); + manager.register_pass(); + + manager.run_passes(f); + ASSERT_NO_THROW(check_rt_info(f)); + } + + // TensorIterator not unrolled. + { + auto X = std::make_shared(element::f32, Shape{ITER_CNT, 1, 16}); + auto H = std::make_shared(element::f32, Shape{1, 128}); + auto C = std::make_shared(element::f32, Shape{1, 128}); + + const std::string variable_name_H("LSTMTensorIterator/variable0"); + const std::string variable_name_C("LSTMTensorIterator/variable1"); + auto variable_H = std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, variable_name_H}); + auto variable_C = std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, variable_name_C}); + auto read_value_H = std::make_shared(create_init_subgraph(H), variable_H); + auto read_value_C = std::make_shared(create_init_subgraph(C), variable_C); + + // Body + + auto Xi = std::make_shared(element::f32, Shape{1, 1, 16}); + auto H_t = std::make_shared(element::f32, Shape{1, 128}); + auto C_t = std::make_shared(element::f32, Shape{1, 128}); + + // Body + auto axis = Constant::create(element::i64, Shape{}, {0}); + auto squeeze = std::make_shared(Xi, axis); + + auto w_val = std::vector(512 * 16, 0); + auto r_val = std::vector(512 * 128, 0); + auto b_val = std::vector(512, 0); + auto W = Constant::create(element::f32, Shape{512, 16}, w_val); + auto R = Constant::create(element::f32, Shape{512, 128}, r_val); + auto B = Constant::create(element::f32, Shape{512}, b_val); + + auto lstm_cell = std::make_shared(squeeze, H_t, C_t, W, R, B, 128); + auto res_1 = std::make_shared(lstm_cell->output(0)); + auto unsqueeze = std::make_shared(lstm_cell, axis); + auto res_2 = std::make_shared(unsqueeze); + auto res_3 = std::make_shared(lstm_cell->output(1)); + auto body = std::make_shared(OutputVector{res_1, res_2, res_3}, + ParameterVector{Xi, H_t, C_t}); + + auto tensor_iterator = std::make_shared(); + tensor_iterator->set_body(body); + + tensor_iterator->set_merged_input(C_t, read_value_C, res_3); + tensor_iterator->set_sliced_input(Xi, X, 0, 1, 1, -1, 0); + tensor_iterator->set_merged_input(H_t, read_value_H, res_1); + + auto out0 = tensor_iterator->get_iter_value(res_1, -1); + auto out1 = tensor_iterator->get_concatenated_slices(res_2, 0, 1, 1, -1, 0); + auto out2 = tensor_iterator->get_iter_value(res_3, -1); + + auto assign_H = std::make_shared(out0, variable_H); + auto assign_C = std::make_shared(out2, variable_C); + auto outer_res_2 = std::make_shared(out1); + auto outer_res_1 = std::make_shared(out0); + f_ref = std::make_shared(OutputVector{outer_res_1, outer_res_2}, ParameterVector{X, H, C}); + f_ref->add_sinks({assign_C, assign_H}); + assign_H->add_control_dependency(read_value_H); + assign_C->add_control_dependency(read_value_C); + } + auto res = compare_functions(f, f_ref); + ASSERT_TRUE(res.first) << res.second; +} + +TEST(TransformationTests, LowLatency2_LSTM_Loop_Reshape) { + std::shared_ptr f(nullptr), f_ref(nullptr); + { + auto X = std::make_shared(element::f32, Shape{10, 1, 16}); + auto H_init = std::make_shared(element::f32, Shape{1, 128}); + auto C_init = std::make_shared(element::f32, Shape{1, 128}); + + auto Xi = std::make_shared(element::f32, Shape{1, 1, 16}); + auto H_t = std::make_shared(element::f32, Shape{1, 128}); + auto C_t = std::make_shared(element::f32, Shape{1, 128}); + + // Body + auto body = createLSTMBody(Xi, H_t, C_t, true); + auto results = body->get_results(); + + auto shape_of = std::make_shared(X); + const auto trip_count = std::make_shared(shape_of, Constant::create(ngraph::element::i64, {1}, {0}), + Constant::create(ngraph::element::i64, {1}, {0})); + auto exec_condition = + std::make_shared(element::boolean, Shape{}, true); + auto loop = std::make_shared(trip_count, exec_condition); + loop->set_special_body_ports({-1, 3}); + loop->set_function(body); + loop->set_friendly_name("LSTMLoop"); + + loop->set_merged_input(C_t, C_init, results[2]); + loop->set_sliced_input(Xi, X, 0, 1, 1, -1, 0); + loop->set_merged_input(H_t, H_init, results[0]); + + auto out0 = loop->get_iter_value(results[0], -1); + auto out1 = loop->get_concatenated_slices(results[1], 0, 1, 1, -1, 0); + + auto res_ti_1 = std::make_shared(loop->output(1)); + auto res_ti_2 = std::make_shared(loop->output(0)); + f = std::make_shared(NodeVector{res_ti_1, res_ti_2}, + ParameterVector{X, H_init, C_init}); + + // Reshape + // change the number of iteration of Loop. 10 -> 1 + auto new_X = std::make_shared(element::f32, Shape{1, 1, 16}); + f->replace_parameter(0, new_X); + f->validate_nodes_and_infer_types(); + + pass::Manager manager; + manager.register_pass(); + manager.register_pass(); + + manager.run_passes(f); + ASSERT_NO_THROW(check_rt_info(f)); + } + { + auto Xi = std::make_shared(element::f32, Shape{1, 1, 16}); + auto H_t = std::make_shared(element::f32, Shape{1, 128}); + auto C_t = std::make_shared(element::f32, Shape{1, 128}); + + const std::string variable_name_H("LSTMTensorIterator/variable0"); + const std::string variable_name_C("LSTMTensorIterator/variable1"); + auto variable_H = std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, variable_name_H}); + auto variable_C = std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, variable_name_C}); + auto read_value_H = std::make_shared(create_init_subgraph(H_t), variable_H); + auto read_value_C = std::make_shared(create_init_subgraph(C_t), variable_C); + // Body + auto axis = Constant::create(element::i64, Shape{}, {0}); + auto squeeze = std::make_shared(Xi, axis); + + auto w_val = std::vector(512 * 16, 0); + auto r_val = std::vector(512 * 128, 0); + auto b_val = std::vector(512, 0); + auto W = Constant::create(element::f32, Shape{512, 16}, w_val); + auto R = Constant::create(element::f32, Shape{512, 128}, r_val); + auto B = Constant::create(element::f32, Shape{512}, b_val); + + auto lstm_cell = std::make_shared(squeeze, read_value_H, read_value_C, W, R, B, 128); + auto assign_H = std::make_shared(lstm_cell->output(0), variable_H); + auto assign_C = std::make_shared(lstm_cell->output(1), variable_C); + auto unsqueeze = std::make_shared(lstm_cell->output(0), axis); + auto res_2 = std::make_shared(insert_identity(unsqueeze)); + auto res_1 = std::make_shared(insert_identity(lstm_cell->output(0))); + f_ref = std::make_shared(OutputVector{res_1, res_2}, ParameterVector{Xi, H_t, C_t}); + f_ref->add_sinks({assign_C, assign_H}); + assign_H->add_control_dependency(read_value_H); + assign_C->add_control_dependency(read_value_C); + } + auto res = compare_functions(f, f_ref); + ASSERT_TRUE(res.first) << res.second; +} + + +TEST(TransformationTests, LowLatency2_LSTM_Loop_several_iterations) { + std::shared_ptr f(nullptr), f_ref(nullptr); + { + auto X = std::make_shared(element::f32, Shape{10, 1, 16}); + auto H_init = std::make_shared(element::f32, Shape{1, 128}); + auto C_init = std::make_shared(element::f32, Shape{1, 128}); + + auto Xi = std::make_shared(element::f32, Shape{1, 1, 16}); + auto H_t = std::make_shared(element::f32, Shape{1, 128}); + auto C_t = std::make_shared(element::f32, Shape{1, 128}); + + // Body + auto body = createLSTMBody(Xi, H_t, C_t, true); + auto results = body->get_results(); + + auto trip_count = + std::make_shared(element::i64, Shape{}, 10); + auto exec_condition = + std::make_shared(element::boolean, Shape{}, true); + auto loop = std::make_shared(trip_count, exec_condition); + loop->set_special_body_ports({-1, 3}); + loop->set_function(body); + loop->set_friendly_name("LSTMLoop"); + + loop->set_merged_input(C_t, C_init, results[2]); + loop->set_sliced_input(Xi, X, 0, 1, 1, -1, 0); + loop->set_merged_input(H_t, H_init, results[0]); + + auto out0 = loop->get_iter_value(results[0], -1); + auto out1 = loop->get_concatenated_slices(results[1], 0, 1, 1, -1, 0); + + auto res_ti_1 = std::make_shared(loop->output(1)); + auto res_ti_2 = std::make_shared(loop->output(0)); + f = std::make_shared(NodeVector{res_ti_1, res_ti_2}, + ParameterVector{X, H_init, C_init}); + + pass::Manager manager; + manager.register_pass(); + manager.register_pass(true); + + manager.run_passes(f); + ASSERT_NO_THROW(check_rt_info(f)); + } + { + auto X = std::make_shared(element::f32, Shape{10, 1, 16}); + auto H = std::make_shared(element::f32, Shape{1, 128}); + auto C = std::make_shared(element::f32, Shape{1, 128}); + + const std::string variable_name_H("LSTMTensorIterator/variable0"); + const std::string variable_name_C("LSTMTensorIterator/variable1"); + auto variable_H = std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, variable_name_H}); + auto variable_C = std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, variable_name_C}); + auto read_value_H = std::make_shared(create_init_subgraph(H), variable_H); + auto read_value_C = std::make_shared(create_init_subgraph(C), variable_C); + + // Body + auto Xi = std::make_shared(element::f32, Shape{1, 1, 16}); + auto H_t = std::make_shared(element::f32, Shape{1, 128}); + auto C_t = std::make_shared(element::f32, Shape{1, 128}); + + // Body + auto axis = Constant::create(element::i64, Shape{}, {0}); + auto squeeze = std::make_shared(Xi, axis); + + auto w_val = std::vector(512 * 16, 0); + auto r_val = std::vector(512 * 128, 0); + auto b_val = std::vector(512, 0); + auto W = Constant::create(element::f32, Shape{512, 16}, w_val); + auto R = Constant::create(element::f32, Shape{512, 128}, r_val); + auto B = Constant::create(element::f32, Shape{512}, b_val); + + auto lstm_cell = std::make_shared(squeeze, H_t, C_t, W, R, B, 128); + auto res_1 = std::make_shared(lstm_cell->output(0)); + auto unsqueeze = std::make_shared(lstm_cell->output(0), axis); + auto res_2 = std::make_shared(unsqueeze); + auto res_3 = std::make_shared(lstm_cell->output(1)); + auto body_condition = std::make_shared( + element::boolean, Shape{1}, true); + auto body = std::make_shared(OutputVector{res_1, res_2, res_3, body_condition}, + ParameterVector{Xi, H_t, C_t}); + + auto trip_count = + std::make_shared(element::i64, Shape{}, 10); + auto exec_condition = + std::make_shared(element::boolean, Shape{}, true); + auto loop = std::make_shared(trip_count, exec_condition); + loop->set_special_body_ports({-1, 3}); + loop->set_function(body); + loop->set_friendly_name("LSTMLoop"); + + loop->set_merged_input(C_t, read_value_C, res_3); + loop->set_sliced_input(Xi, X, 0, 1, 1, -1, 0); + loop->set_merged_input(H_t, read_value_H, res_1); + + auto out0 = loop->get_iter_value(res_1, -1); + auto out1 = loop->get_concatenated_slices(res_2, 0, 1, 1, -1, 0); + auto out3 = loop->get_iter_value(res_3, -1); + + auto assign_H = std::make_shared(out0, variable_H); + auto assign_C = std::make_shared(out3, variable_C); + auto outer_res_2 = std::make_shared(out1); + auto outer_res_1 = std::make_shared(out0); + f_ref = std::make_shared(OutputVector{outer_res_1, outer_res_2}, ParameterVector{X, H, C}); + f_ref->add_sinks({assign_C, assign_H}); + assign_H->add_control_dependency(read_value_H); + assign_C->add_control_dependency(read_value_C); + } + auto res = compare_functions(f, f_ref); + ASSERT_TRUE(res.first) << res.second; +} + +TEST(TransformationTests, LowLatencyLSTM_LLTv1_LLTv2) { + std::shared_ptr f(nullptr), f_ref(nullptr); + { + auto X = std::make_shared(element::f32, Shape{1, 1, 16}); + auto H_init = std::make_shared(element::f32, Shape{1, 128}); + auto C_init = std::make_shared(element::f32, Shape{1, 128}); + + auto Xi = std::make_shared(element::f32, Shape{1, 1, 16}); + auto H_t = std::make_shared(element::f32, Shape{1, 128}); + auto C_t = std::make_shared(element::f32, Shape{1, 128}); + + // Body + auto axis = Constant::create(element::i64, Shape{}, {0}); + auto squeeze = std::make_shared(Xi, axis); + + auto w_val = std::vector(512 * 16, 0); + auto r_val = std::vector(512 * 128, 0); + auto b_val = std::vector(512, 0); + auto W = Constant::create(element::f32, Shape{512, 16}, w_val); + auto R = Constant::create(element::f32, Shape{512, 128}, r_val); + auto B = Constant::create(element::f32, Shape{512}, b_val); + + auto lstm_cell = std::make_shared(squeeze, H_t, C_t, W, R, B, 128); + auto res_1 = std::make_shared(lstm_cell->output(0)); + auto unsqueeze = std::make_shared(lstm_cell->output(0), axis); + auto res_2 = std::make_shared(unsqueeze); + auto res_3 = std::make_shared(lstm_cell->output(1)); + auto body = std::make_shared(OutputVector{res_1, res_2, res_3}, ParameterVector{Xi, H_t, C_t}); + + auto tensor_iterator = std::make_shared(); + tensor_iterator->set_body(body); + tensor_iterator->set_friendly_name("LSTMTensorIterator"); + + tensor_iterator->set_merged_input(C_t, C_init, res_3); + tensor_iterator->set_sliced_input(Xi, X, 0, 1, 1, -1, 0); + tensor_iterator->set_merged_input(H_t, H_init, res_1); + + auto out0 = tensor_iterator->get_iter_value(res_1, -1); + auto out1 = tensor_iterator->get_concatenated_slices(res_2, 0, 1, 1, -1, 0); + + auto res_ti_1 = std::make_shared(tensor_iterator->output(1)); + auto res_ti_2 = std::make_shared(tensor_iterator->output(0)); + f = std::make_shared(NodeVector{res_ti_1, res_ti_2}, + ParameterVector{X, H_init, C_init}); + + auto f_2 = ngraph::clone_function(*f); + pass::Manager manager_2; + manager_2.register_pass(); + NGRAPH_SUPPRESS_DEPRECATED_START + manager_2.register_pass(); + NGRAPH_SUPPRESS_DEPRECATED_END + EXPECT_NO_THROW(manager_2.run_passes(f_2)); + + pass::Manager manager; + manager.register_pass(); + NGRAPH_SUPPRESS_DEPRECATED_START + manager.register_pass(); + NGRAPH_SUPPRESS_DEPRECATED_END + // LLT v2 doesn't insert Assign/ReadValue ops, they are already inserted + // but unrolls TI/Loop + manager.register_pass(); + + EXPECT_NO_THROW(manager.run_passes(f)); + } +} diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/memory.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/memory.cpp index 750a0e4af5e430..9ab20c3eda4cf7 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/memory.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/memory.cpp @@ -10,6 +10,13 @@ using namespace LayerTestsDefinitions; namespace { +std::vector transformation { + ngraph::helpers::MemoryTransformation::NONE, + ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2, + ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2_REGULAR_API, + ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2_ORIGINAL_INIT, +}; + const std::vector inShapes = { {3}, {100, 100}, @@ -27,6 +34,7 @@ const std::vector iterationCount { INSTANTIATE_TEST_CASE_P(smoke_MemoryTest, MemoryTest, ::testing::Combine( + ::testing::ValuesIn(transformation), ::testing::ValuesIn(iterationCount), ::testing::ValuesIn(inShapes), ::testing::ValuesIn(inputPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/memory_LSTMCell.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/memory_LSTMCell.cpp new file mode 100644 index 00000000000000..8e9754343474cb --- /dev/null +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/memory_LSTMCell.cpp @@ -0,0 +1,45 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include "common_test_utils/test_constants.hpp" + +namespace SubgraphTestsDefinitions { + std::vector transformation { + ngraph::helpers::MemoryTransformation::NONE, + ngraph::helpers::MemoryTransformation::LOW_LATENCY, + ngraph::helpers::MemoryTransformation::LOW_LATENCY_REGULAR_API, + ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2, + ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2_REGULAR_API + }; + + std::vector input_sizes = { + 80, + 32, + 64, + 100, + 25 + }; + + std::vector hidden_sizes = { + 128, + 200, + 300, + 24, + 32, + }; + + std::map additional_config = { + }; + + INSTANTIATE_TEST_CASE_P(smoke_MemoryLSTMCellTest, MemoryLSTMCellTest, + ::testing::Combine( + ::testing::ValuesIn(transformation), + ::testing::Values(CommonTestUtils::DEVICE_CPU), + ::testing::Values(InferenceEngine::Precision::FP32), + ::testing::ValuesIn(input_sizes), + ::testing::ValuesIn(hidden_sizes), + ::testing::Values(additional_config)), + MemoryLSTMCellTest::getTestCaseName); +} // namespace SubgraphTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/multiple_LSTMCell.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/multiple_LSTMCell.cpp index 3468d2b417f744..4c18ee6ea054bb 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/multiple_LSTMCell.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/multiple_LSTMCell.cpp @@ -7,6 +7,15 @@ namespace SubgraphTestsDefinitions { namespace { + +std::vector transformation { + ngraph::helpers::MemoryTransformation::NONE, + ngraph::helpers::MemoryTransformation::LOW_LATENCY, + ngraph::helpers::MemoryTransformation::LOW_LATENCY_REGULAR_API, + ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2, + ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2_REGULAR_API +}; + std::vector input_sizes = { 80, 32, @@ -28,6 +37,7 @@ std::map additional_config = { INSTANTIATE_TEST_CASE_P(MultipleLSTMCellTest, MultipleLSTMCellTest, ::testing::Combine( + ::testing::ValuesIn(transformation), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::Values(InferenceEngine::Precision::FP32), ::testing::ValuesIn(input_sizes), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/memory.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/memory.cpp index 2ab1357f6748e4..c04b76705ccac0 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/memory.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/memory.cpp @@ -10,9 +10,17 @@ using namespace LayerTestsDefinitions; namespace { +std::vector transformation { + ngraph::helpers::MemoryTransformation::NONE, + ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2, + ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2_REGULAR_API, + ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2_ORIGINAL_INIT +}; + const std::vector inShapes = { {1, 1}, - {1, 2} + {1, 2}, + {1, 10} }; const std::vector inputPrecisions = { @@ -22,11 +30,13 @@ const std::vector inputPrecisions = { const std::vector iterationCount { 1, 3, + 4, 10 }; INSTANTIATE_TEST_CASE_P(smoke_MemoryTest, MemoryTest, ::testing::Combine( + ::testing::ValuesIn(transformation), ::testing::ValuesIn(iterationCount), ::testing::ValuesIn(inShapes), ::testing::ValuesIn(inputPrecisions), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/skip_tests_config.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/skip_tests_config.cpp index 9f2c05ab6d1690..cb4cc459a95e28 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/skip_tests_config.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/skip_tests_config.cpp @@ -64,5 +64,13 @@ std::vector disabledTestPatterns() { R"(.*CachingSupport.*_batch2_.*)", // TODO: Issue 51525 R"(.*CachingSupport.*KSOFunction.*)", + // TODO: Issue 57363 (Param -> Result subgraphs) + R"(.*smoke_MemoryTest.*LOW_LATENCY.*iteration_count=1_.*)", + // TODO: Issue 57368 (accuracy) + R"(.*smoke_MemoryTest.*LOW_LATENCY.*IS=\(1.10\).*)", + R"(.*smoke_MemoryTest.*iteration_count=3.*IS=\(1.10\).*)", + R"(.*smoke_MemoryTest.*iteration_count=4.*IS=\(1.10\).*)", + R"(.*smoke_MemoryTest.*iteration_count=10.*IS=\(1.10\).*)", + R"(.*smoke_MemoryTest.*LOW_LATENCY.*iteration_count=10.*IS=\(1.2\).*)", }; } diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/memory_LSTMCell.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/memory_LSTMCell.cpp index a8d651f6c807f6..5818a40d4ecaa2 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/memory_LSTMCell.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/memory_LSTMCell.cpp @@ -6,6 +6,14 @@ #include "common_test_utils/test_constants.hpp" namespace SubgraphTestsDefinitions { + std::vector transformation { + ngraph::helpers::MemoryTransformation::NONE, + ngraph::helpers::MemoryTransformation::LOW_LATENCY, + ngraph::helpers::MemoryTransformation::LOW_LATENCY_REGULAR_API, + ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2, + ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2_REGULAR_API + }; + std::vector input_sizes = { 80, 32, @@ -30,6 +38,7 @@ namespace SubgraphTestsDefinitions { INSTANTIATE_TEST_CASE_P(smoke_MemoryLSTMCellTest, MemoryLSTMCellTest, ::testing::Combine( + ::testing::ValuesIn(transformation), ::testing::Values(CommonTestUtils::DEVICE_GNA), ::testing::Values(InferenceEngine::Precision::FP32), ::testing::ValuesIn(input_sizes), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/multiple_LSTMCell.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/multiple_LSTMCell.cpp index 2d94617991d3cd..d59c023773bb38 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/multiple_LSTMCell.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/multiple_LSTMCell.cpp @@ -7,6 +7,15 @@ namespace SubgraphTestsDefinitions { namespace { + +std::vector transformation { + ngraph::helpers::MemoryTransformation::NONE, + ngraph::helpers::MemoryTransformation::LOW_LATENCY, + ngraph::helpers::MemoryTransformation::LOW_LATENCY_REGULAR_API, + ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2, + ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2_REGULAR_API +}; + std::vector input_sizes = { 80, 32, @@ -31,6 +40,7 @@ std::map additional_config = { INSTANTIATE_TEST_CASE_P(MultipleLSTMCellTest, MultipleLSTMCellTest, ::testing::Combine( + ::testing::ValuesIn(transformation), ::testing::Values(CommonTestUtils::DEVICE_GNA), ::testing::Values(InferenceEngine::Precision::FP32), ::testing::ValuesIn(input_sizes), diff --git a/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/basic_lstm.hpp b/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/basic_lstm.hpp index 17bf8d31cf056f..7ae1d21a886e4f 100644 --- a/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/basic_lstm.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/basic_lstm.hpp @@ -39,7 +39,7 @@ TEST_P(Basic_LSTM_S, CompareWithRefImpl_LowLatencyTransformation) { // Apply LowLatency and UnrollTensorIterator transformations ngraph::pass::Manager manager; - manager.register_pass(); // LowLatency enables UnrollTI + manager.register_pass(); // LowLatency enables UnrollTI manager.run_passes(function); LoadNetwork(); IE_SUPPRESS_DEPRECATED_START diff --git a/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/memory_LSTMCell.hpp b/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/memory_LSTMCell.hpp index 947f0fa1e1a515..a6f250301b62a6 100644 --- a/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/memory_LSTMCell.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/memory_LSTMCell.hpp @@ -12,12 +12,4 @@ TEST_P(MemoryLSTMCellTest, CompareWithRefs) { Run(); }; -TEST_P(MemoryLSTMCellTest, CompareWithRefs_LowLatencyTransformation) { - RunLowLatency(); -}; - -TEST_P(MemoryLSTMCellTest, CompareWithRefs_LowLatencyRegularAPITransformation) { - RunLowLatency(true); -}; - } // namespace SubgraphTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/multiple_LSTMCell.hpp b/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/multiple_LSTMCell.hpp index 5dd18ff446381e..0135c09e17048d 100644 --- a/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/multiple_LSTMCell.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/multiple_LSTMCell.hpp @@ -12,12 +12,4 @@ TEST_P(MultipleLSTMCellTest, CompareWithRefs) { Run(); }; -TEST_P(MultipleLSTMCellTest, CompareWithRefs_LowLatencyTransformation) { - RunLowLatency(); -}; - -TEST_P(MultipleLSTMCellTest, CompareWithRefs_LowLatencyRegularAPITransformation) { - RunLowLatency(true); -}; - } // namespace SubgraphTestsDefinitions diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/memory.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/memory.hpp index ca16e30148e68f..59ad6c54e5a2fc 100644 --- a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/memory.hpp +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/memory.hpp @@ -14,6 +14,7 @@ namespace LayerTestsDefinitions { using MemoryTestParams = std::tuple< + ngraph::helpers::MemoryTransformation, // Apply Memory transformation int64_t, // iterationCount InferenceEngine::SizeVector, // inputShape InferenceEngine::Precision, // netPrecision @@ -28,9 +29,17 @@ class MemoryTest : public testing::WithParamInterface, virtual std::vector>> CalculateRefs() override; void SetUp() override; private: + void CreateTIFunc(); + void CreateCommonFunc(); + void ApplyLowLatency(); + InferenceEngine::Precision netPrecision; ngraph::EvaluationContext eval_context; + ngraph::helpers::MemoryTransformation transformation; + int64_t iteration_count; + ngraph::element::Type ngPrc; + InferenceEngine::SizeVector inputShape; }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/memory_LSTMCell.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/memory_LSTMCell.hpp index 489431e2a9b67b..cc0aeb26e2f02e 100644 --- a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/memory_LSTMCell.hpp +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/memory_LSTMCell.hpp @@ -10,6 +10,7 @@ namespace SubgraphTestsDefinitions { typedef std::tuple< + ngraph::helpers::MemoryTransformation, // Apply Memory transformation std::string, // Target device name InferenceEngine::Precision, // Network precision size_t, // Input size @@ -21,9 +22,13 @@ class MemoryLSTMCellTest : public LayerTestsUtils::LayerTestsCommon, public testing::WithParamInterface { private: // you have to Unroll TI manually and remove memory untill ngraph supports it + // since we switching models we need to generate and save weights biases and inputs in SetUp void switchToNgraphFriendlyModel(); void CreatePureTensorIteratorModel(); - // since we switching models we need to generate and save weights biases and inputs in SetUp + void InitMemory(); + void ApplyLowLatency(); + + ngraph::helpers::MemoryTransformation transformation; std::vector input_bias; std::vector input_weights; std::vector hidden_memory_init; @@ -34,7 +39,6 @@ class MemoryLSTMCellTest : public LayerTestsUtils::LayerTestsCommon, protected: void SetUp() override; void Run() override; - void RunLowLatency(bool regular_api = false); public: static std::string getTestCaseName(const testing::TestParamInfo &obj); }; diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/multiple_LSTMCell.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/multiple_LSTMCell.hpp index 7c1e72a7bb7644..7932ba39a07469 100644 --- a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/multiple_LSTMCell.hpp +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/multiple_LSTMCell.hpp @@ -10,6 +10,7 @@ namespace SubgraphTestsDefinitions { typedef std::tuple< + ngraph::helpers::MemoryTransformation, // Apply Memory transformation std::string, // Target device name InferenceEngine::Precision, // Network precision size_t, // Input size @@ -21,9 +22,12 @@ class MultipleLSTMCellTest : public LayerTestsUtils::LayerTestsCommon, public testing::WithParamInterface { private: // you have to Unroll TI manually and remove memory untill ngraph supports it + // since we switching models we need to generate and save weights biases and inputs in SetUp void switchToNgraphFriendlyModel(); void CreatePureTensorIteratorModel(); - // since we switching models we need to generate and save weights biases and inputs in SetUp + void InitMemory(); + void ApplyLowLatency(); + size_t hiddenSize; std::vector input_bias; std::vector input_weights; @@ -33,10 +37,10 @@ class MultipleLSTMCellTest : public LayerTestsUtils::LayerTestsCommon, std::vector weights_2_vals; std::vector reccurrenceWeights_vals; std::vector bias_vals; + ngraph::helpers::MemoryTransformation transformation; protected: void SetUp() override; void Run() override; - void RunLowLatency(bool regular_api = false); public: static std::string getTestCaseName(const testing::TestParamInfo &obj); }; diff --git a/inference-engine/tests/functional/shared_test_classes/src/single_layer/memory.cpp b/inference-engine/tests/functional/shared_test_classes/src/single_layer/memory.cpp index 0984a4dbeab07f..c059768c4a2ad9 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/single_layer/memory.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/single_layer/memory.cpp @@ -3,10 +3,18 @@ // #include +#include +#include +#include +#include #include "ngraph/opsets/opset7.hpp" #include "ngraph_functions/builders.hpp" +#include "ngraph/pass/low_latency.hpp" #include "shared_test_classes/single_layer/memory.hpp" +using namespace ngraph; +using namespace opset7; + namespace LayerTestsDefinitions { std::string MemoryTest::getTestCaseName(const testing::TestParamInfo &obj) { @@ -14,9 +22,11 @@ namespace LayerTestsDefinitions { InferenceEngine::Precision netPrecision; InferenceEngine::SizeVector inputShape; std::string targetDevice; - std::tie(iteration_count, inputShape, netPrecision, targetDevice) = obj.param; + ngraph::helpers::MemoryTransformation transformation; + std::tie(transformation, iteration_count, inputShape, netPrecision, targetDevice) = obj.param; std::ostringstream result; + result << "transformation=" << transformation << "_"; result << "iteration_count=" << iteration_count << "_"; result << "IS=" << CommonTestUtils::vec2str(inputShape) << "_"; result << "netPRC=" << netPrecision.name() << "_"; @@ -26,20 +36,17 @@ namespace LayerTestsDefinitions { } void MemoryTest::SetUp() { - using namespace ngraph; - InferenceEngine::SizeVector inputShape; - std::tie(iteration_count, inputShape, netPrecision, targetDevice) = this->GetParam(); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); + std::tie(transformation, iteration_count, inputShape, netPrecision, targetDevice) = this->GetParam(); + ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - auto param = ngraph::builder::makeParams(ngPrc, {inputShape}); - auto variable = std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, "v0"}); - auto read_value = std::make_shared(param.at(0), variable); - auto add = std::make_shared(read_value, param.at(0)); - auto assign = std::make_shared(add, variable); - auto res = std::make_shared(add); - function = std::make_shared(ResultVector{res}, SinkVector{assign}, param, "TestMemory"); + if (transformation == ngraph::helpers::MemoryTransformation::NONE) { + CreateCommonFunc(); + } else { + CreateTIFunc(); + ApplyLowLatency(); + } - auto hostTensor = std::make_shared(ngPrc, inputShape); + auto hostTensor = std::make_shared(ngPrc, inputShape); auto variable_context = std::make_shared>(VariableContext()); auto variable_value = std::make_shared(hostTensor); variable_context->get().set_variable_value(function->get_variable_by_id("v0"), variable_value); @@ -48,6 +55,7 @@ namespace LayerTestsDefinitions { void MemoryTest::Run() { + SKIP_IF_CURRENT_TEST_IS_DISABLED() using namespace LayerTestsUtils; auto crashHandler = [](int errCode) { auto &s = Summary::getInstance(); @@ -68,7 +76,13 @@ namespace LayerTestsDefinitions { } try { - LoadNetwork(); + if (transformation != ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2_REGULAR_API) { + LoadNetwork(); + } else { + CoreConfiguration(this); + ConfigureNetwork(); + executableNetwork = core->LoadNetwork(cnnNetwork, targetDevice, configuration); + } GenerateInputs(); for (int64_t i = 0; i < iteration_count; ++i) { Infer(); @@ -88,12 +102,12 @@ namespace LayerTestsDefinitions { } } - std::vector>> MemoryTest::CalculateRefs() { + std::vector>> MemoryTest::CalculateRefs() { using namespace ngraph; function->validate_nodes_and_infer_types(); auto referenceInputs = std::vector>(inputs.size()); - auto refInputsTypes = std::vector(inputs.size()); + auto refInputsTypes = std::vector(inputs.size()); HostTensorVector inputTensors; for (auto & input : inputs) { const auto &dataSize = input->byteSize(); @@ -104,17 +118,25 @@ namespace LayerTestsDefinitions { const auto lockedMemory = memory->wmap(); const auto buffer = lockedMemory.as(); - auto hostTensor = std::make_shared(FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(tensorDesc.getPrecision()), + auto hostTensor = std::make_shared(FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(tensorDesc.getPrecision()), tensorDesc.getDims()); hostTensor->write(buffer, dataSize); inputTensors.push_back(hostTensor); } + // evaluate method is not implemented for TI op. + ngraph::pass::Manager manager; + manager.register_pass(); + manager.run_passes(function); + const auto &outInfo = executableNetwork.GetOutputsInfo(); - HostTensorVector outputTensors(outInfo.size(), std::make_shared()); + HostTensorVector outputTensors(outInfo.size()); + for (auto& outTensor : outputTensors) { + outTensor = std::make_shared(); + } function->evaluate(outputTensors, inputTensors, eval_context); - std::vector>> outputs(outInfo.size()); + std::vector>> outputs(outInfo.size()); for (size_t idx = 0; idx < outInfo.size(); ++idx) { outputs[idx].first = outputTensors[idx]->get_element_type(); outputs[idx].second.resize(outputTensors[idx]->get_size_in_bytes()); @@ -123,5 +145,61 @@ namespace LayerTestsDefinitions { return outputs; } + void MemoryTest::CreateTIFunc() { + auto param = builder::makeParams(ngPrc, {inputShape}).at(0); + std::vector> shape = {{static_cast(iteration_count), 1}}; + auto iter_count = builder::makeParams(ngPrc, shape).at(0); + + // Body + auto X = builder::makeParams(ngPrc, {inputShape}).at(0); + auto Y = builder::makeParams(ngPrc, {inputShape}).at(0); + auto Iter = builder::makeParams(ngPrc, {Shape{1, 1}}).at(0); + auto add = std::make_shared(X, Y); + auto res = std::make_shared(add); + auto Iter_res = std::make_shared(Iter); + auto body = std::make_shared(OutputVector{res, Iter_res}, ParameterVector {X, Y, Iter}); + + // TI construction + auto tensor_iterator = std::make_shared(); + tensor_iterator->set_body(body); + + tensor_iterator->set_merged_input(X, param, res); + tensor_iterator->set_invariant_input(Y, param); + tensor_iterator->set_sliced_input(Iter, iter_count, 0, 1, 1, -1, 0); + + auto output = tensor_iterator->get_iter_value(res, -1); + auto output_iter = tensor_iterator->get_concatenated_slices(Iter_res, 0, 1, 1, -1, 0); + function = std::make_shared(OutputVector{output, output_iter}, + ParameterVector{param, iter_count}, + "PureTI"); + } + + void MemoryTest::CreateCommonFunc() { + auto param = builder::makeParams(ngPrc, {inputShape}); + auto variable = std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, "v0"}); + auto read_value = std::make_shared(param.at(0), variable); + auto add = std::make_shared(read_value, param.at(0)); + auto assign = std::make_shared(add, variable); + auto res = std::make_shared(add); + function = std::make_shared(ResultVector{res}, SinkVector{assign}, param, "TestMemory"); + } + + void MemoryTest::ApplyLowLatency() { + if (transformation == ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2) { + function->validate_nodes_and_infer_types(); + pass::Manager manager; + manager.register_pass(); + manager.run_passes(function); + } else if (transformation == ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2_ORIGINAL_INIT) { + function->validate_nodes_and_infer_types(); + pass::Manager manager; + manager.register_pass(false); + manager.run_passes(function); + } else if (transformation == ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2_REGULAR_API) { + cnnNetwork = InferenceEngine::CNNNetwork{function}; + InferenceEngine::lowLatency2(cnnNetwork, iteration_count); + } + } + } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/shared_test_classes/src/subgraph/memory_LSTMCell.cpp b/inference-engine/tests/functional/shared_test_classes/src/subgraph/memory_LSTMCell.cpp index a8d5c067334b53..bac0c293add651 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/subgraph/memory_LSTMCell.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/subgraph/memory_LSTMCell.cpp @@ -9,6 +9,9 @@ #include "ngraph_functions/builders.hpp" #include "shared_test_classes/subgraph/memory_LSTMCell.hpp" +using namespace ngraph; +using namespace opset7; + namespace SubgraphTestsDefinitions { std::string MemoryLSTMCellTest::getTestCaseName(const testing::TestParamInfo &obj) { @@ -17,9 +20,11 @@ namespace SubgraphTestsDefinitions { size_t inputSize; size_t hiddenSize; std::map config; - std::tie(targetDevice, netPrecision, inputSize, hiddenSize, config) = obj.param; + ngraph::helpers::MemoryTransformation transformation; + std::tie(transformation, targetDevice, netPrecision, inputSize, hiddenSize, config) = obj.param; std::ostringstream result; + result << "transformation=" << transformation << "_"; result << "netPrecision=" << netPrecision.name() << "_"; result << "IS=" << inputSize << "_"; result << "HS=" << hiddenSize << "_"; @@ -34,7 +39,7 @@ namespace SubgraphTestsDefinitions { InferenceEngine::Precision netPrecision; std::map config; size_t inputSize; - std::tie(targetDevice, netPrecision, inputSize, hiddenSize, config) = this->GetParam(); + std::tie(transformation, targetDevice, netPrecision, inputSize, hiddenSize, config) = this->GetParam(); configuration.insert(config.begin(), config.end()); auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); @@ -51,49 +56,53 @@ namespace SubgraphTestsDefinitions { reccurrenceWeights_vals = CommonTestUtils::generate_float_numbers(4 * hiddenSize * hiddenSize, -0.1f, 0.1f); bias_vals = CommonTestUtils::generate_float_numbers(4 * hiddenSize, -0.2f, 0.1f); - auto input_parameter = ngraph::builder::makeParams(ngPrc, {input_dims}); + auto input_parameter = builder::makeParams(ngPrc, {input_dims}); - auto input_add_const = ngraph::builder::makeConstant(ngPrc, input_dims, input_bias); - auto add = ngraph::builder::makeEltwise(input_parameter[0], input_add_const, ngraph::helpers::EltwiseTypes::ADD); + auto input_add_const = builder::makeConstant(ngPrc, input_dims, input_bias); + auto add = builder::makeEltwise(input_parameter[0], input_add_const, helpers::EltwiseTypes::ADD); - auto input_mul_const = ngraph::builder::makeConstant(ngPrc, input_dims, input_weights); - auto mul = ngraph::builder::makeEltwise(add, input_mul_const, ngraph::helpers::EltwiseTypes::MULTIPLY); + auto input_mul_const = builder::makeConstant(ngPrc, input_dims, input_weights); + auto mul = builder::makeEltwise(add, input_mul_const, helpers::EltwiseTypes::MULTIPLY); - auto unsqueeze_input_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto unsqueeze_input = std::make_shared(mul, unsqueeze_input_const); + auto unsqueeze_input_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto unsqueeze_input = std::make_shared(mul, unsqueeze_input_const); - auto permute_in_params = std::make_shared(ngraph::element::i64, ngraph::Shape{3}, ngraph::Shape{{1, 0, 2}}); - auto permute_in = std::make_shared(unsqueeze_input, permute_in_params); + auto permute_in_params = std::make_shared(element::i64, Shape{3}, Shape{{1, 0, 2}}); + auto permute_in = std::make_shared(unsqueeze_input, permute_in_params); - auto cell_memory_constant = ngraph::builder::makeConstant(ngPrc, cell_memory_dims, cell_memory_init); - auto cell_memory_read = std::make_shared(cell_memory_constant, "cell_memory"); + auto cell_memory_constant = builder::makeConstant(ngPrc, cell_memory_dims, cell_memory_init); + auto var_cell = + std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, "cell_state_1"}); + auto var_hidden = + std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, "hidden_state_1"}); + auto cell_memory_read = std::make_shared(cell_memory_constant, var_cell); - auto hidden_memory_constant = ngraph::builder::makeConstant(ngPrc, hidden_memory_dims, hidden_memory_init); - auto hidden_memory_read = std::make_shared(hidden_memory_constant, "hidden_memory"); + auto hidden_memory_constant = builder::makeConstant(ngPrc, hidden_memory_dims, hidden_memory_init); + auto hidden_memory_read = std::make_shared(hidden_memory_constant, var_hidden); // Body - inputs - auto X = std::make_shared(ngPrc, ngraph::Shape{1, 1, inputSize}); - auto H_t = std::make_shared(ngPrc, ngraph::Shape{1, hiddenSize}); - auto C_t = std::make_shared(ngPrc, ngraph::Shape{1, hiddenSize}); + auto X = std::make_shared(ngPrc, Shape{1, 1, inputSize}); + auto H_t = std::make_shared(ngPrc, Shape{1, hiddenSize}); + auto C_t = std::make_shared(ngPrc, Shape{1, hiddenSize}); // Body - layers - auto squeeze_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto squeeze = std::make_shared(X, squeeze_const); + auto squeeze_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto squeeze = std::make_shared(X, squeeze_const); - auto weightsNode = ngraph::builder::makeConstant(ngPrc, { 4 * hiddenSize, inputSize }, weights_vals); - auto reccurrenceWeightsNode = ngraph::builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, reccurrenceWeights_vals); - auto biasNode = ngraph::builder::makeConstant(ngPrc, {4 * hiddenSize}, bias_vals); - auto lstm = std::make_shared(squeeze, H_t, C_t, weightsNode, reccurrenceWeightsNode, biasNode, hiddenSize); + auto weightsNode = builder::makeConstant(ngPrc, { 4 * hiddenSize, inputSize }, weights_vals); + auto reccurrenceWeightsNode = builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, reccurrenceWeights_vals); + auto biasNode = builder::makeConstant(ngPrc, {4 * hiddenSize}, bias_vals); + auto lstm = std::make_shared(squeeze, H_t, C_t, weightsNode, reccurrenceWeightsNode, biasNode, hiddenSize); - auto unsqueeze_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto unsqueeze = std::make_shared(lstm->output(0), unsqueeze_const); + auto unsqueeze_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto unsqueeze = std::make_shared(lstm->output(0), unsqueeze_const); // body - outputs auto H_o = lstm->output(0); auto C_o = lstm->output(1); auto unsqueeze_o = unsqueeze->output(0); - auto body = std::make_shared(ngraph::OutputVector{unsqueeze_o, H_o, C_o}, ngraph::ParameterVector {X, H_t, C_t}); + auto body = std::make_shared(OutputVector{unsqueeze_o, H_o, C_o}, ParameterVector {X, H_t, C_t}); // TI construction - auto tensor_iterator = std::make_shared(); + auto tensor_iterator = std::make_shared(); tensor_iterator->set_body(body); tensor_iterator->set_invariant_input(X, permute_in); tensor_iterator->set_merged_input(H_t, hidden_memory_read, H_o); @@ -107,27 +116,27 @@ namespace SubgraphTestsDefinitions { out_hidden.get_tensor().set_element_type(ngPrc); out_cell.get_tensor().set_element_type(ngPrc); - auto cell_memory_write = std::make_shared(out_cell, "cell_memory"); - auto hidden_memory_write = std::make_shared(out_hidden, "hidden_memory"); + auto cell_memory_write = std::make_shared(out_cell, var_cell); + auto hidden_memory_write = std::make_shared(out_hidden, var_hidden); - auto final_reshape_pattern = std::make_shared(ngraph::element::i64, ngraph::Shape{4}, + auto final_reshape_pattern = std::make_shared(element::i64, Shape{4}, std::vector({1, 1, 1, hiddenSize})); - auto final_reshape = std::make_shared(out_unsqueeze, final_reshape_pattern, false); + auto final_reshape = std::make_shared(out_unsqueeze, final_reshape_pattern, false); cell_memory_write->add_control_dependency(cell_memory_read); - final_reshape->add_control_dependency(cell_memory_write); - hidden_memory_write->add_control_dependency(hidden_memory_read); - final_reshape->add_control_dependency(hidden_memory_write); - function = std::make_shared(final_reshape, input_parameter, "TI_with_memory"); + function = std::make_shared(OutputVector{final_reshape}, + SinkVector{cell_memory_write, hidden_memory_write}, + input_parameter, + "TI_with_memory"); } void MemoryLSTMCellTest::switchToNgraphFriendlyModel() { InferenceEngine::Precision netPrecision; std::map config; size_t inputSize; - std::tie(targetDevice, netPrecision, inputSize, hiddenSize, config) = this->GetParam(); + std::tie(transformation, targetDevice, netPrecision, inputSize, hiddenSize, config) = this->GetParam(); auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); std::vector input_dims { 1, inputSize }; @@ -135,46 +144,46 @@ namespace SubgraphTestsDefinitions { std::vector hidden_memory_dims {1, hiddenSize}; std::vector cell_memory_dims {1, hiddenSize}; - auto input_parameter = ngraph::builder::makeParams(ngPrc, {input_dims}); + auto input_parameter = builder::makeParams(ngPrc, {input_dims}); - auto input_add_const = ngraph::builder::makeConstant(ngPrc, input_dims, input_bias); - auto add = ngraph::builder::makeEltwise(input_parameter[0], input_add_const, ngraph::helpers::EltwiseTypes::ADD); + auto input_add_const = builder::makeConstant(ngPrc, input_dims, input_bias); + auto add = builder::makeEltwise(input_parameter[0], input_add_const, helpers::EltwiseTypes::ADD); - auto input_mul_const = ngraph::builder::makeConstant(ngPrc, input_dims, input_weights); - auto mul = ngraph::builder::makeEltwise(add, input_mul_const, ngraph::helpers::EltwiseTypes::MULTIPLY); + auto input_mul_const = builder::makeConstant(ngPrc, input_dims, input_weights); + auto mul = builder::makeEltwise(add, input_mul_const, helpers::EltwiseTypes::MULTIPLY); - auto unsqueeze_input_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto unsqueeze_input = std::make_shared(mul, unsqueeze_input_const); + auto unsqueeze_input_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto unsqueeze_input = std::make_shared(mul, unsqueeze_input_const); - auto cell_memory_constant = ngraph::builder::makeConstant(ngPrc, cell_memory_dims, cell_memory_init); + auto cell_memory_constant = builder::makeConstant(ngPrc, cell_memory_dims, cell_memory_init); - auto hidden_memory_constant = ngraph::builder::makeConstant(ngPrc, hidden_memory_dims, hidden_memory_init); + auto hidden_memory_constant = builder::makeConstant(ngPrc, hidden_memory_dims, hidden_memory_init); // Body - layers - auto squeeze_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto squeeze = std::make_shared(unsqueeze_input, squeeze_const); + auto squeeze_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto squeeze = std::make_shared(unsqueeze_input, squeeze_const); - auto weightsNode = ngraph::builder::makeConstant(ngPrc, { 4 * hiddenSize, inputSize }, weights_vals); - auto reccurrenceWeightsNode = ngraph::builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, reccurrenceWeights_vals); - auto biasNode = ngraph::builder::makeConstant(ngPrc, {4 * hiddenSize}, bias_vals); - auto lstm = std::make_shared(squeeze, hidden_memory_constant, cell_memory_constant, weightsNode, + auto weightsNode = builder::makeConstant(ngPrc, { 4 * hiddenSize, inputSize }, weights_vals); + auto reccurrenceWeightsNode = builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, reccurrenceWeights_vals); + auto biasNode = builder::makeConstant(ngPrc, {4 * hiddenSize}, bias_vals); + auto lstm = std::make_shared(squeeze, hidden_memory_constant, cell_memory_constant, weightsNode, reccurrenceWeightsNode, biasNode, hiddenSize); - auto unsqueeze_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto unsqueeze = std::make_shared(lstm->output(0), unsqueeze_const); + auto unsqueeze_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto unsqueeze = std::make_shared(lstm->output(0), unsqueeze_const); - auto final_reshape_pattern = std::make_shared(ngraph::element::i64, - ngraph::Shape{4}, std::vector({1, 1, 1, hiddenSize})); - auto final_reshape = std::make_shared(unsqueeze, final_reshape_pattern, false); + auto final_reshape_pattern = std::make_shared(element::i64, + Shape{4}, std::vector({1, 1, 1, hiddenSize})); + auto final_reshape = std::make_shared(unsqueeze, final_reshape_pattern, false); - function = std::make_shared(final_reshape, input_parameter, "TI_unrolled_without_memory"); + function = std::make_shared(final_reshape, input_parameter, "TI_unrolled_without_memory"); } void MemoryLSTMCellTest::CreatePureTensorIteratorModel() { InferenceEngine::Precision netPrecision; std::map config; size_t inputSize; - std::tie(targetDevice, netPrecision, inputSize, hiddenSize, config) = this->GetParam(); + std::tie(transformation, targetDevice, netPrecision, inputSize, hiddenSize, config) = this->GetParam(); auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); std::vector input_dims { 1, inputSize }; @@ -182,49 +191,49 @@ namespace SubgraphTestsDefinitions { std::vector hidden_memory_dims {1, hiddenSize}; std::vector cell_memory_dims {1, hiddenSize}; - auto input_parameter = ngraph::builder::makeParams(ngPrc, {input_dims}); + auto input_parameter = builder::makeParams(ngPrc, {input_dims}); - auto input_add_const = ngraph::builder::makeConstant(ngPrc, input_dims, input_bias); - auto add = ngraph::builder::makeEltwise(input_parameter[0], input_add_const, ngraph::helpers::EltwiseTypes::ADD); + auto input_add_const = builder::makeConstant(ngPrc, input_dims, input_bias); + auto add = builder::makeEltwise(input_parameter[0], input_add_const, helpers::EltwiseTypes::ADD); - auto input_mul_const = ngraph::builder::makeConstant(ngPrc, input_dims, input_weights); - auto mul = ngraph::builder::makeEltwise(add, input_mul_const, ngraph::helpers::EltwiseTypes::MULTIPLY); + auto input_mul_const = builder::makeConstant(ngPrc, input_dims, input_weights); + auto mul = builder::makeEltwise(add, input_mul_const, helpers::EltwiseTypes::MULTIPLY); - auto unsqueeze_input_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto unsqueeze_input = std::make_shared(mul, unsqueeze_input_const); + auto unsqueeze_input_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto unsqueeze_input = std::make_shared(mul, unsqueeze_input_const); - auto permute_in_params = std::make_shared(ngraph::element::i64, ngraph::Shape{3}, ngraph::Shape{{1, 0, 2}}); - auto permute_in = std::make_shared(unsqueeze_input, permute_in_params); + auto permute_in_params = std::make_shared(element::i64, Shape{3}, Shape{{1, 0, 2}}); + auto permute_in = std::make_shared(unsqueeze_input, permute_in_params); - auto cell_memory_constant = ngraph::builder::makeConstant(ngPrc, cell_memory_dims, cell_memory_init); + auto cell_memory_constant = builder::makeConstant(ngPrc, cell_memory_dims, cell_memory_init); - auto hidden_memory_constant = ngraph::builder::makeConstant(ngPrc, hidden_memory_dims, hidden_memory_init); + auto hidden_memory_constant = builder::makeConstant(ngPrc, hidden_memory_dims, hidden_memory_init); // Body - inputs - auto X = std::make_shared(ngPrc, ngraph::Shape{1, 1, inputSize}); - auto H_t = std::make_shared(ngPrc, ngraph::Shape{1, hiddenSize}); - auto C_t = std::make_shared(ngPrc, ngraph::Shape{1, hiddenSize}); + auto X = std::make_shared(ngPrc, Shape{1, 1, inputSize}); + auto H_t = std::make_shared(ngPrc, Shape{1, hiddenSize}); + auto C_t = std::make_shared(ngPrc, Shape{1, hiddenSize}); H_t->set_friendly_name("hidden_state_1"); C_t->set_friendly_name("cell_state_1"); // Body - layers - auto squeeze_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto squeeze = std::make_shared(X, squeeze_const); + auto squeeze_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto squeeze = std::make_shared(X, squeeze_const); - auto weightsNode = ngraph::builder::makeConstant(ngPrc, { 4 * hiddenSize, inputSize }, weights_vals); - auto reccurrenceWeightsNode = ngraph::builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, reccurrenceWeights_vals); - auto biasNode = ngraph::builder::makeConstant(ngPrc, {4 * hiddenSize}, bias_vals); - auto lstm = std::make_shared(squeeze, H_t, C_t, weightsNode, reccurrenceWeightsNode, biasNode, hiddenSize); + auto weightsNode = builder::makeConstant(ngPrc, { 4 * hiddenSize, inputSize }, weights_vals); + auto reccurrenceWeightsNode = builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, reccurrenceWeights_vals); + auto biasNode = builder::makeConstant(ngPrc, {4 * hiddenSize}, bias_vals); + auto lstm = std::make_shared(squeeze, H_t, C_t, weightsNode, reccurrenceWeightsNode, biasNode, hiddenSize); - auto unsqueeze_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto unsqueeze = std::make_shared(lstm->output(0), unsqueeze_const); + auto unsqueeze_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto unsqueeze = std::make_shared(lstm->output(0), unsqueeze_const); // body - outputs auto H_o = lstm->output(0); auto C_o = lstm->output(1); auto unsqueeze_o = unsqueeze->output(0); - auto body = std::make_shared(ngraph::OutputVector{unsqueeze_o, H_o, C_o}, ngraph::ParameterVector {X, H_t, C_t}); + auto body = std::make_shared(OutputVector{unsqueeze_o, H_o, C_o}, ParameterVector {X, H_t, C_t}); // TI construction - auto tensor_iterator = std::make_shared(); + auto tensor_iterator = std::make_shared(); tensor_iterator->set_body(body); tensor_iterator->set_sliced_input(X, permute_in, 0, 1, 1, -1, 0); tensor_iterator->set_merged_input(H_t, hidden_memory_constant, H_o); @@ -237,56 +246,35 @@ namespace SubgraphTestsDefinitions { out_hidden.get_tensor().set_element_type(ngPrc); out_cell.get_tensor().set_element_type(ngPrc); - auto final_reshape_pattern = std::make_shared(ngraph::element::i64, ngraph::Shape{4}, + auto final_reshape_pattern = std::make_shared(element::i64, Shape{4}, std::vector({1, 1, 1, hiddenSize})); - auto final_reshape = std::make_shared(out_unsqueeze, final_reshape_pattern, false); + auto final_reshape = std::make_shared(out_unsqueeze, final_reshape_pattern, false); - function = std::make_shared(final_reshape, input_parameter, "PureTI"); + function = std::make_shared(final_reshape, input_parameter, "PureTI"); } void MemoryLSTMCellTest::Run() { SKIP_IF_CURRENT_TEST_IS_DISABLED() - - IE_SUPPRESS_DEPRECATED_START - LoadNetwork(); - auto states = executableNetwork.QueryState(); - for (auto& state : states) { - auto name = state.GetName(); - if (name == "cell_memory") { - auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state.GetLastState()->getTensorDesc(), - cell_memory_init.data(), cell_memory_init.size()); - state.SetState(blob); - } else if (name == "hidden_memory") { - auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state.GetLastState()->getTensorDesc(), - hidden_memory_init.data(), hidden_memory_init.size()); - state.SetState(blob); - } else { - GTEST_FAIL() << "unknown memory state"; - } + if (transformation != ngraph::helpers::MemoryTransformation::NONE) { + ApplyLowLatency(); + } else { + LoadNetwork(); } - IE_SUPPRESS_DEPRECATED_END + + InitMemory(); GenerateInputs(); Infer(); - switchToNgraphFriendlyModel(); - Validate(); - } - - void MemoryLSTMCellTest::RunLowLatency(bool regular_api) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() - CreatePureTensorIteratorModel(); - if (regular_api) { - cnnNetwork = InferenceEngine::CNNNetwork{function}; - InferenceEngine::LowLatency(cnnNetwork); - ConfigureNetwork(); - executableNetwork = core->LoadNetwork(static_cast(cnnNetwork), targetDevice, configuration); + // Calculate ref values + if (transformation == ngraph::helpers::MemoryTransformation::NONE) { + switchToNgraphFriendlyModel(); } else { - // Apply LowLatency (insert Assigns/ReadValues) and UnrollTensorIterator - ngraph::pass::Manager manager; - manager.register_pass(); // LowLatency enables UnrollTI - manager.run_passes(function); - LoadNetwork(); + CreatePureTensorIteratorModel(); } + Validate(); + } + + void MemoryLSTMCellTest::InitMemory() { IE_SUPPRESS_DEPRECATED_START auto states = executableNetwork.QueryState(); for (auto& state : states) { @@ -304,13 +292,52 @@ namespace SubgraphTestsDefinitions { } } IE_SUPPRESS_DEPRECATED_END - GenerateInputs(); - Infer(); + } + void MemoryLSTMCellTest::ApplyLowLatency() { + // Calculate values after LowLatency transformation CreatePureTensorIteratorModel(); - ngraph::pass::Manager manager_2; - manager_2.register_pass(); - manager_2.run_passes(function); - Validate(); + if (transformation == ngraph::helpers::MemoryTransformation::LOW_LATENCY) { + function->validate_nodes_and_infer_types(); + // Apply LowLatency (insert Assigns/ReadValues) and UnrollTensorIterator + pass::Manager manager; + NGRAPH_SUPPRESS_DEPRECATED_START + manager.register_pass(); + NGRAPH_SUPPRESS_DEPRECATED_END // LowLatency enables UnrollTI + manager.run_passes(function); + bool ti_found = helpers::is_tensor_iterator_exist(function); + EXPECT_EQ(ti_found, true); + LoadNetwork(); + } else if (transformation == ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2) { + function->validate_nodes_and_infer_types(); + // Apply LowLatency (insert Assigns/ReadValues) and UnrollTensorIterator + + pass::Manager manager; + manager.register_pass(); + manager.run_passes(function); + bool ti_found = helpers::is_tensor_iterator_exist(function); + EXPECT_EQ(ti_found, false); + LoadNetwork(); + } else if (transformation == ngraph::helpers::MemoryTransformation::LOW_LATENCY_REGULAR_API) { + cnnNetwork = InferenceEngine::CNNNetwork{function}; + IE_SUPPRESS_DEPRECATED_START + InferenceEngine::LowLatency(cnnNetwork); + IE_SUPPRESS_DEPRECATED_END + + bool ti_found = helpers::is_tensor_iterator_exist(cnnNetwork.getFunction()); + EXPECT_EQ(ti_found, true); + + ConfigureNetwork(); + executableNetwork = core->LoadNetwork(cnnNetwork, targetDevice, configuration); + } else if (transformation == ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2_REGULAR_API) { + cnnNetwork = InferenceEngine::CNNNetwork{function}; + InferenceEngine::lowLatency2(cnnNetwork); + + bool ti_found = helpers::is_tensor_iterator_exist(cnnNetwork.getFunction()); + EXPECT_EQ(ti_found, false); + + ConfigureNetwork(); + executableNetwork = core->LoadNetwork(cnnNetwork, targetDevice, configuration); + } } } // namespace SubgraphTestsDefinitions diff --git a/inference-engine/tests/functional/shared_test_classes/src/subgraph/multiple_LSTMCell.cpp b/inference-engine/tests/functional/shared_test_classes/src/subgraph/multiple_LSTMCell.cpp index d854f7049302a4..09f8020df41220 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/subgraph/multiple_LSTMCell.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/subgraph/multiple_LSTMCell.cpp @@ -2,16 +2,19 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ngraph/opsets/opset5.hpp" -#include "ngraph/pass/low_latency.hpp" - #include "ie_transformations.hpp" -#include "transformations/control_flow/unroll_tensor_iterator.hpp" +#include "ngraph/opsets/opset7.hpp" +#include "ngraph/op/util/variable_context.hpp" +#include "ngraph/pass/low_latency.hpp" #include "ngraph_functions/builders.hpp" +#include "ngraph_functions/utils/ngraph_helpers.hpp" #include "shared_test_classes/subgraph/multiple_LSTMCell.hpp" +using namespace ngraph; +using namespace opset7; + namespace SubgraphTestsDefinitions { std::string MultipleLSTMCellTest::getTestCaseName(const testing::TestParamInfo &obj) { std::string targetDevice; @@ -19,9 +22,11 @@ std::string MultipleLSTMCellTest::getTestCaseName(const testing::TestParamInfo config; - std::tie(targetDevice, netPrecision, inputSize, hiddenSize, config) = obj.param; + ngraph::helpers::MemoryTransformation transformation; + std::tie(transformation, targetDevice, netPrecision, inputSize, hiddenSize, config) = obj.param; std::ostringstream result; + result << "transformation=" << transformation << "_"; result << "netPrecision=" << netPrecision.name() << "_"; result << "IS=" << inputSize << "_"; result << "HS=" << hiddenSize << "_"; @@ -33,7 +38,7 @@ void MultipleLSTMCellTest::SetUp() { InferenceEngine::Precision netPrecision; std::map config; size_t inputSize; - std::tie(targetDevice, netPrecision, inputSize, hiddenSize, config) = this->GetParam(); + std::tie(transformation, targetDevice, netPrecision, inputSize, hiddenSize, config) = this->GetParam(); configuration.insert(config.begin(), config.end()); auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); @@ -51,51 +56,55 @@ void MultipleLSTMCellTest::SetUp() { reccurrenceWeights_vals = CommonTestUtils::generate_float_numbers(4 * hiddenSize * hiddenSize, -0.1f, 0.1f); bias_vals = CommonTestUtils::generate_float_numbers(4 * hiddenSize, -0.25f, 0.15f); - auto input_parameter = ngraph::builder::makeParams(ngPrc, {input_dims}); + auto input_parameter = builder::makeParams(ngPrc, {input_dims}); - auto input_add_const = ngraph::builder::makeConstant(ngPrc, input_dims, input_bias); - auto add = ngraph::builder::makeEltwise(input_parameter[0], input_add_const, ngraph::helpers::EltwiseTypes::ADD); + auto input_add_const = builder::makeConstant(ngPrc, input_dims, input_bias); + auto add = builder::makeEltwise(input_parameter[0], input_add_const, helpers::EltwiseTypes::ADD); - auto input_mul_const = ngraph::builder::makeConstant(ngPrc, input_dims, input_weights); - auto mul = ngraph::builder::makeEltwise(add, input_mul_const, ngraph::helpers::EltwiseTypes::MULTIPLY); + auto input_mul_const = builder::makeConstant(ngPrc, input_dims, input_weights); + auto mul = builder::makeEltwise(add, input_mul_const, helpers::EltwiseTypes::MULTIPLY); - auto unsqueeze_input_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto unsqueeze_input = std::make_shared(mul, unsqueeze_input_const); + auto unsqueeze_input_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto unsqueeze_input = std::make_shared(mul, unsqueeze_input_const); - auto permute_in_params = std::make_shared(ngraph::element::i64, ngraph::Shape{3}, ngraph::Shape{{1, 0, 2}}); - auto permute_in = std::make_shared(unsqueeze_input, permute_in_params); + auto permute_in_params = std::make_shared(element::i64, Shape{3}, Shape{{1, 0, 2}}); + auto permute_in = std::make_shared(unsqueeze_input, permute_in_params); - auto cell_memory_constant = ngraph::builder::makeConstant(ngPrc, cell_memory_dims, cell_memory_init); - auto cell_memory_read = std::make_shared(cell_memory_constant, "cell_memory"); + auto cell_memory_constant = builder::makeConstant(ngPrc, cell_memory_dims, cell_memory_init); + auto var_cell = + std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, "cell_state_1"}); + auto var_hidden = + std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, "hidden_state_1"}); + auto cell_memory_read = std::make_shared(cell_memory_constant, var_cell); cell_memory_read->set_friendly_name("cell_memory"); - auto hidden_memory_constant = ngraph::builder::makeConstant(ngPrc, hidden_memory_dims, hidden_memory_init); - auto hidden_memory_read = std::make_shared(hidden_memory_constant, "hidden_memory"); + auto hidden_memory_constant = builder::makeConstant(ngPrc, hidden_memory_dims, hidden_memory_init); + auto hidden_memory_read = std::make_shared(hidden_memory_constant, var_hidden); hidden_memory_read->set_friendly_name("hidden_memory"); // Body - inputs - auto X = std::make_shared(ngPrc, ngraph::Shape{1, 1, inputSize}); - auto H_t = std::make_shared(ngPrc, ngraph::Shape{1, hiddenSize}); - auto C_t = std::make_shared(ngPrc, ngraph::Shape{1, hiddenSize}); + auto X = std::make_shared(ngPrc, Shape{1, 1, inputSize}); + auto H_t = std::make_shared(ngPrc, Shape{1, hiddenSize}); + auto C_t = std::make_shared(ngPrc, Shape{1, hiddenSize}); // Body - layers - auto squeeze_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto squeeze = std::make_shared(X, squeeze_const); + auto squeeze_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto squeeze = std::make_shared(X, squeeze_const); - auto weightsNode = ngraph::builder::makeConstant(ngPrc, { 4 * hiddenSize, inputSize }, weights_vals); - auto reccurrenceWeightsNode = ngraph::builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, reccurrenceWeights_vals); - auto biasNode = ngraph::builder::makeConstant(ngPrc, {4 * hiddenSize}, bias_vals); - auto lstm = std::make_shared(squeeze, H_t, C_t, weightsNode, reccurrenceWeightsNode, biasNode, hiddenSize); + auto weightsNode = builder::makeConstant(ngPrc, { 4 * hiddenSize, inputSize }, weights_vals); + auto reccurrenceWeightsNode = builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, reccurrenceWeights_vals); + auto biasNode = builder::makeConstant(ngPrc, {4 * hiddenSize}, bias_vals); + auto lstm = std::make_shared(squeeze, H_t, C_t, weightsNode, reccurrenceWeightsNode, biasNode, hiddenSize); - auto unsqueeze_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto unsqueeze = std::make_shared(lstm->output(0), unsqueeze_const); + auto unsqueeze_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto unsqueeze = std::make_shared(lstm->output(0), unsqueeze_const); // body - outputs auto H_o = lstm->output(0); auto C_o = lstm->output(1); auto unsqueeze_o = unsqueeze->output(0); - auto body = std::make_shared(ngraph::OutputVector{unsqueeze_o, H_o, C_o}, ngraph::ParameterVector {X, H_t, C_t}); + auto body = std::make_shared(OutputVector{unsqueeze_o, H_o, C_o}, ParameterVector {X, H_t, C_t}); // TI construction - auto tensor_iterator = std::make_shared(); + auto tensor_iterator = std::make_shared(); tensor_iterator->set_body(body); tensor_iterator->set_invariant_input(X, permute_in); tensor_iterator->set_merged_input(H_t, hidden_memory_read, H_o); @@ -108,49 +117,53 @@ void MultipleLSTMCellTest::SetUp() { out_hidden.get_tensor().set_element_type(ngPrc); out_cell.get_tensor().set_element_type(ngPrc); - auto cell_memory_write = std::make_shared(out_cell, "cell_memory"); - auto hidden_memory_write = std::make_shared(out_hidden, "hidden_memory"); + auto cell_memory_write = std::make_shared(out_cell, var_cell); + auto hidden_memory_write = std::make_shared(out_hidden, var_hidden); - auto first_reshape_pattern = std::make_shared(ngraph::element::i64, - ngraph::Shape{4}, std::vector({1, 1, 1, hiddenSize})); - auto first_reshape = std::make_shared(out_unsqueeze, first_reshape_pattern, false); + auto first_reshape_pattern = std::make_shared(element::i64, + Shape{4}, std::vector({1, 1, 1, hiddenSize})); + auto first_reshape = std::make_shared(out_unsqueeze, first_reshape_pattern, false); // End of TI 1 - auto inbetween_squeeze_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto inbetween_squeeze = std::make_shared(first_reshape, inbetween_squeeze_const); + auto inbetween_squeeze_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto inbetween_squeeze = std::make_shared(first_reshape, inbetween_squeeze_const); // Second TI - auto cell_memory_2_constant = ngraph::builder::makeConstant(ngPrc, cell_memory_dims, cell_memory_init); - auto cell_memory_2_read = std::make_shared(cell_memory_2_constant, "cell_memory_2"); + auto var_cell_2 = + std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, "cell_state_2"}); + auto var_hidden_2 = + std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, "hidden_state_2"}); + auto cell_memory_2_constant = builder::makeConstant(ngPrc, cell_memory_dims, cell_memory_init); + auto cell_memory_2_read = std::make_shared(cell_memory_2_constant, var_cell_2); cell_memory_2_read->set_friendly_name("cell_memory_2"); - auto hidden_memory_2_constant = ngraph::builder::makeConstant(ngPrc, hidden_memory_dims, hidden_memory_init); - auto hidden_memory_2_read = std::make_shared(hidden_memory_2_constant, "hidden_memory_2"); + auto hidden_memory_2_constant = builder::makeConstant(ngPrc, hidden_memory_dims, hidden_memory_init); + auto hidden_memory_2_read = std::make_shared(hidden_memory_2_constant, var_hidden_2); hidden_memory_2_read->set_friendly_name("hidden_memory_2"); // Body - inputs - auto X_2 = std::make_shared(ngPrc, ngraph::Shape{1, 1, hiddenSize}); - auto H_t_2 = std::make_shared(ngPrc, ngraph::Shape{1, hiddenSize}); - auto C_t_2 = std::make_shared(ngPrc, ngraph::Shape{1, hiddenSize}); + auto X_2 = std::make_shared(ngPrc, Shape{1, 1, hiddenSize}); + auto H_t_2 = std::make_shared(ngPrc, Shape{1, hiddenSize}); + auto C_t_2 = std::make_shared(ngPrc, Shape{1, hiddenSize}); // Body - layers - auto squeeze_2_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto squeeze_2 = std::make_shared(X_2, squeeze_2_const); + auto squeeze_2_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto squeeze_2 = std::make_shared(X_2, squeeze_2_const); - auto weightsNode_2 = ngraph::builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, weights_2_vals); - auto reccurrenceWeightsNode_2 = ngraph::builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, reccurrenceWeights_vals); - auto biasNode_2 = ngraph::builder::makeConstant(ngPrc, {4 * hiddenSize}, bias_vals); - auto lstm_2 = std::make_shared(squeeze_2, H_t_2, C_t_2, weightsNode_2, reccurrenceWeightsNode_2, biasNode_2, hiddenSize); + auto weightsNode_2 = builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, weights_2_vals); + auto reccurrenceWeightsNode_2 = builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, reccurrenceWeights_vals); + auto biasNode_2 = builder::makeConstant(ngPrc, {4 * hiddenSize}, bias_vals); + auto lstm_2 = std::make_shared(squeeze_2, H_t_2, C_t_2, weightsNode_2, reccurrenceWeightsNode_2, biasNode_2, hiddenSize); - auto unsqueeze_2_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto unsqueeze_2 = std::make_shared(lstm_2->output(0), unsqueeze_2_const); + auto unsqueeze_2_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto unsqueeze_2 = std::make_shared(lstm_2->output(0), unsqueeze_2_const); // body - outputs auto H_o_2 = lstm_2->output(0); auto C_o_2 = lstm_2->output(1); auto unsqueeze_o_2 = unsqueeze_2->output(0); - auto body_2 = std::make_shared(ngraph::OutputVector{unsqueeze_o_2, H_o_2, C_o_2}, ngraph::ParameterVector {X_2, H_t_2, C_t_2}); + auto body_2 = std::make_shared(OutputVector{unsqueeze_o_2, H_o_2, C_o_2}, ParameterVector {X_2, H_t_2, C_t_2}); // TI construction - auto tensor_iterator_2 = std::make_shared(); + auto tensor_iterator_2 = std::make_shared(); tensor_iterator_2->set_body(body_2); tensor_iterator_2->set_invariant_input(X_2, inbetween_squeeze); tensor_iterator_2->set_merged_input(H_t_2, hidden_memory_2_read, H_o_2); @@ -163,33 +176,28 @@ void MultipleLSTMCellTest::SetUp() { out_hidden_2.get_tensor().set_element_type(ngPrc); out_cell_2.get_tensor().set_element_type(ngPrc); - auto cell_memory_2_write = std::make_shared(out_cell_2, "cell_memory_2"); - auto hidden_memory_2_write = std::make_shared(out_hidden_2, "hidden_memory_2"); + auto cell_memory_2_write = std::make_shared(out_cell_2, var_cell_2); + auto hidden_memory_2_write = std::make_shared(out_hidden_2, var_hidden_2); - auto final_reshape_pattern = std::make_shared(ngraph::element::i64, - ngraph::Shape{4}, std::vector({1, 1, 1, hiddenSize})); - auto final_reshape = std::make_shared(out_unsqueeze_2, final_reshape_pattern, false); + auto final_reshape_pattern = std::make_shared(element::i64, Shape{4}, std::vector({1, 1, 1, hiddenSize})); + auto final_reshape = std::make_shared(out_unsqueeze_2, final_reshape_pattern, false); cell_memory_write->add_control_dependency(cell_memory_read); - final_reshape->add_control_dependency(cell_memory_write); - hidden_memory_write->add_control_dependency(hidden_memory_read); - final_reshape->add_control_dependency(hidden_memory_write); - cell_memory_2_write->add_control_dependency(cell_memory_2_read); - final_reshape->add_control_dependency(cell_memory_2_write); - hidden_memory_2_write->add_control_dependency(hidden_memory_2_read); - final_reshape->add_control_dependency(hidden_memory_2_write); - function = std::make_shared(final_reshape, input_parameter, "TI_with_memory"); + function = std::make_shared(OutputVector {final_reshape}, + SinkVector{cell_memory_write, hidden_memory_write, cell_memory_2_write, hidden_memory_2_write}, + input_parameter, + "TI_with_memory"); } void MultipleLSTMCellTest::switchToNgraphFriendlyModel() { InferenceEngine::Precision netPrecision; std::map config; size_t inputSize; - std::tie(targetDevice, netPrecision, inputSize, hiddenSize, config) = this->GetParam(); + std::tie(transformation, targetDevice, netPrecision, inputSize, hiddenSize, config) = this->GetParam(); auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); std::vector input_dims { 1, inputSize }; @@ -197,72 +205,72 @@ void MultipleLSTMCellTest::switchToNgraphFriendlyModel() { std::vector hidden_memory_dims {1, hiddenSize}; std::vector cell_memory_dims {1, hiddenSize}; - auto input_parameter = ngraph::builder::makeParams(ngPrc, {input_dims}); + auto input_parameter = builder::makeParams(ngPrc, {input_dims}); - auto input_add_const = ngraph::builder::makeConstant(ngPrc, input_dims, input_bias); - auto add = ngraph::builder::makeEltwise(input_parameter[0], input_add_const, ngraph::helpers::EltwiseTypes::ADD); + auto input_add_const = builder::makeConstant(ngPrc, input_dims, input_bias); + auto add = builder::makeEltwise(input_parameter[0], input_add_const, helpers::EltwiseTypes::ADD); - auto input_mul_const = ngraph::builder::makeConstant(ngPrc, input_dims, input_weights); - auto mul = ngraph::builder::makeEltwise(add, input_mul_const, ngraph::helpers::EltwiseTypes::MULTIPLY); + auto input_mul_const = builder::makeConstant(ngPrc, input_dims, input_weights); + auto mul = builder::makeEltwise(add, input_mul_const, helpers::EltwiseTypes::MULTIPLY); - auto unsqueeze_input_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto unsqueeze_input = std::make_shared(mul, unsqueeze_input_const); + auto unsqueeze_input_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto unsqueeze_input = std::make_shared(mul, unsqueeze_input_const); // Body 1 - layers - auto cell_memory_constant = ngraph::builder::makeConstant(ngPrc, cell_memory_dims, cell_memory_init); + auto cell_memory_constant = builder::makeConstant(ngPrc, cell_memory_dims, cell_memory_init); - auto hidden_memory_constant = ngraph::builder::makeConstant(ngPrc, hidden_memory_dims, hidden_memory_init); + auto hidden_memory_constant = builder::makeConstant(ngPrc, hidden_memory_dims, hidden_memory_init); - auto squeeze_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto squeeze = std::make_shared(unsqueeze_input, squeeze_const); + auto squeeze_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto squeeze = std::make_shared(unsqueeze_input, squeeze_const); - auto weightsNode = ngraph::builder::makeConstant(ngPrc, { 4 * hiddenSize, inputSize }, weights_vals); - auto reccurrenceWeightsNode = ngraph::builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, reccurrenceWeights_vals); - auto biasNode = ngraph::builder::makeConstant(ngPrc, {4 * hiddenSize}, bias_vals); - auto lstm = std::make_shared(squeeze, hidden_memory_constant, cell_memory_constant, weightsNode, + auto weightsNode = builder::makeConstant(ngPrc, { 4 * hiddenSize, inputSize }, weights_vals); + auto reccurrenceWeightsNode = builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, reccurrenceWeights_vals); + auto biasNode = builder::makeConstant(ngPrc, {4 * hiddenSize}, bias_vals); + auto lstm = std::make_shared(squeeze, hidden_memory_constant, cell_memory_constant, weightsNode, reccurrenceWeightsNode, biasNode, hiddenSize); - auto unsqueeze_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto unsqueeze = std::make_shared(lstm->output(0), unsqueeze_const); + auto unsqueeze_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto unsqueeze = std::make_shared(lstm->output(0), unsqueeze_const); - auto first_reshape_pattern = std::make_shared(ngraph::element::i64, - ngraph::Shape{4}, std::vector({1, 1, 1, hiddenSize})); - auto first_reshape = std::make_shared(unsqueeze, first_reshape_pattern, false); + auto first_reshape_pattern = std::make_shared(element::i64, + Shape{4}, std::vector({1, 1, 1, hiddenSize})); + auto first_reshape = std::make_shared(unsqueeze, first_reshape_pattern, false); // Body 1 - end - auto inbetween_squeeze_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto inbetween_squeeze = std::make_shared(first_reshape, inbetween_squeeze_const); + auto inbetween_squeeze_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto inbetween_squeeze = std::make_shared(first_reshape, inbetween_squeeze_const); // Body 2 - layers - auto cell_memory_2_constant = ngraph::builder::makeConstant(ngPrc, cell_memory_dims, cell_memory_init); + auto cell_memory_2_constant = builder::makeConstant(ngPrc, cell_memory_dims, cell_memory_init); - auto hidden_memory_2_constant = ngraph::builder::makeConstant(ngPrc, hidden_memory_dims, hidden_memory_init); + auto hidden_memory_2_constant = builder::makeConstant(ngPrc, hidden_memory_dims, hidden_memory_init); - auto squeeze_2_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto squeeze_2 = std::make_shared(inbetween_squeeze, squeeze_2_const); + auto squeeze_2_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto squeeze_2 = std::make_shared(inbetween_squeeze, squeeze_2_const); - auto weightsNode_2 = ngraph::builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, weights_2_vals); - auto reccurrenceWeightsNode_2 = ngraph::builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, reccurrenceWeights_vals); - auto biasNode_2 = ngraph::builder::makeConstant(ngPrc, {4 * hiddenSize}, bias_vals); - auto lstm_2 = std::make_shared(squeeze_2, hidden_memory_2_constant, cell_memory_2_constant, weightsNode_2, + auto weightsNode_2 = builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, weights_2_vals); + auto reccurrenceWeightsNode_2 = builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, reccurrenceWeights_vals); + auto biasNode_2 = builder::makeConstant(ngPrc, {4 * hiddenSize}, bias_vals); + auto lstm_2 = std::make_shared(squeeze_2, hidden_memory_2_constant, cell_memory_2_constant, weightsNode_2, reccurrenceWeightsNode_2, biasNode_2, hiddenSize); - auto unsqueeze_2_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto unsqueeze_2 = std::make_shared(lstm_2->output(0), unsqueeze_2_const); + auto unsqueeze_2_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto unsqueeze_2 = std::make_shared(lstm_2->output(0), unsqueeze_2_const); - auto final_reshape_pattern = std::make_shared(ngraph::element::i64, - ngraph::Shape{4}, std::vector({1, 1, 1, hiddenSize})); - auto final_reshape = std::make_shared(unsqueeze_2, final_reshape_pattern, false); + auto final_reshape_pattern = std::make_shared(element::i64, + Shape{4}, std::vector({1, 1, 1, hiddenSize})); + auto final_reshape = std::make_shared(unsqueeze_2, final_reshape_pattern, false); // Body 2 - end - function = std::make_shared(final_reshape, input_parameter, "TI_unrolled_without_memory"); + function = std::make_shared(final_reshape, input_parameter, "TI_unrolled_without_memory"); } void MultipleLSTMCellTest::CreatePureTensorIteratorModel() { InferenceEngine::Precision netPrecision; std::map config; size_t inputSize; - std::tie(targetDevice, netPrecision, inputSize, hiddenSize, config) = this->GetParam(); + std::tie(transformation, targetDevice, netPrecision, inputSize, hiddenSize, config) = this->GetParam(); auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); std::vector input_dims { 1, inputSize }; @@ -270,49 +278,49 @@ void MultipleLSTMCellTest::CreatePureTensorIteratorModel() { std::vector hidden_memory_dims {1, hiddenSize}; std::vector cell_memory_dims {1, hiddenSize}; - auto input_parameter = ngraph::builder::makeParams(ngPrc, {input_dims}); + auto input_parameter = builder::makeParams(ngPrc, {input_dims}); - auto input_add_const = ngraph::builder::makeConstant(ngPrc, input_dims, input_bias); - auto add = ngraph::builder::makeEltwise(input_parameter[0], input_add_const, ngraph::helpers::EltwiseTypes::ADD); + auto input_add_const = builder::makeConstant(ngPrc, input_dims, input_bias); + auto add = builder::makeEltwise(input_parameter[0], input_add_const, helpers::EltwiseTypes::ADD); - auto input_mul_const = ngraph::builder::makeConstant(ngPrc, input_dims, input_weights); - auto mul = ngraph::builder::makeEltwise(add, input_mul_const, ngraph::helpers::EltwiseTypes::MULTIPLY); + auto input_mul_const = builder::makeConstant(ngPrc, input_dims, input_weights); + auto mul = builder::makeEltwise(add, input_mul_const, helpers::EltwiseTypes::MULTIPLY); - auto unsqueeze_input_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto unsqueeze_input = std::make_shared(mul, unsqueeze_input_const); + auto unsqueeze_input_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto unsqueeze_input = std::make_shared(mul, unsqueeze_input_const); - auto permute_in_params = std::make_shared(ngraph::element::i64, ngraph::Shape{3}, ngraph::Shape{{1, 0, 2}}); - auto permute_in = std::make_shared(unsqueeze_input, permute_in_params); + auto permute_in_params = std::make_shared(element::i64, Shape{3}, Shape{{1, 0, 2}}); + auto permute_in = std::make_shared(unsqueeze_input, permute_in_params); - auto cell_memory_constant = ngraph::builder::makeConstant(ngPrc, cell_memory_dims, cell_memory_init); + auto cell_memory_constant = builder::makeConstant(ngPrc, cell_memory_dims, cell_memory_init); - auto hidden_memory_constant = ngraph::builder::makeConstant(ngPrc, hidden_memory_dims, hidden_memory_init); + auto hidden_memory_constant = builder::makeConstant(ngPrc, hidden_memory_dims, hidden_memory_init); // Body - inputs - auto X = std::make_shared(ngPrc, ngraph::Shape{1, 1, inputSize}); - auto H_t = std::make_shared(ngPrc, ngraph::Shape{1, hiddenSize}); - auto C_t = std::make_shared(ngPrc, ngraph::Shape{1, hiddenSize}); + auto X = std::make_shared(ngPrc, Shape{1, 1, inputSize}); + auto H_t = std::make_shared(ngPrc, Shape{1, hiddenSize}); + auto C_t = std::make_shared(ngPrc, Shape{1, hiddenSize}); H_t->set_friendly_name("hidden_state_1"); C_t->set_friendly_name("cell_state_1"); // Body - layers - auto squeeze_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto squeeze = std::make_shared(X, squeeze_const); + auto squeeze_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto squeeze = std::make_shared(X, squeeze_const); - auto weightsNode = ngraph::builder::makeConstant(ngPrc, { 4 * hiddenSize, inputSize }, weights_vals); - auto reccurrenceWeightsNode = ngraph::builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, reccurrenceWeights_vals); - auto biasNode = ngraph::builder::makeConstant(ngPrc, {4 * hiddenSize}, bias_vals); - auto lstm = std::make_shared(squeeze, H_t, C_t, weightsNode, reccurrenceWeightsNode, biasNode, hiddenSize); + auto weightsNode = builder::makeConstant(ngPrc, { 4 * hiddenSize, inputSize }, weights_vals); + auto reccurrenceWeightsNode = builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, reccurrenceWeights_vals); + auto biasNode = builder::makeConstant(ngPrc, {4 * hiddenSize}, bias_vals); + auto lstm = std::make_shared(squeeze, H_t, C_t, weightsNode, reccurrenceWeightsNode, biasNode, hiddenSize); - auto unsqueeze_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto unsqueeze = std::make_shared(lstm->output(0), unsqueeze_const); + auto unsqueeze_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto unsqueeze = std::make_shared(lstm->output(0), unsqueeze_const); // body - outputs auto H_o = lstm->output(0); auto C_o = lstm->output(1); auto unsqueeze_o = unsqueeze->output(0); - auto body = std::make_shared(ngraph::OutputVector{unsqueeze_o, H_o, C_o}, ngraph::ParameterVector {X, H_t, C_t}); + auto body = std::make_shared(OutputVector{unsqueeze_o, H_o, C_o}, ParameterVector {X, H_t, C_t}); // TI construction - auto tensor_iterator = std::make_shared(); + auto tensor_iterator = std::make_shared(); tensor_iterator->set_body(body); tensor_iterator->set_sliced_input(X, permute_in, 0, 1, 1, -1, 0); tensor_iterator->set_merged_input(H_t, hidden_memory_constant, H_o); @@ -326,44 +334,44 @@ void MultipleLSTMCellTest::CreatePureTensorIteratorModel() { out_cell.get_tensor().set_element_type(ngPrc); tensor_iterator->validate_and_infer_types(); - auto first_reshape_pattern = std::make_shared(ngraph::element::i64, - ngraph::Shape{4}, std::vector({1, 1, 1, hiddenSize})); - auto first_reshape = std::make_shared(out_unsqueeze, first_reshape_pattern, false); + auto first_reshape_pattern = std::make_shared(element::i64, + Shape{4}, std::vector({1, 1, 1, hiddenSize})); + auto first_reshape = std::make_shared(out_unsqueeze, first_reshape_pattern, false); // End of TI 1 - auto inbetween_squeeze_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto inbetween_squeeze = std::make_shared(first_reshape, inbetween_squeeze_const); + auto inbetween_squeeze_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto inbetween_squeeze = std::make_shared(first_reshape, inbetween_squeeze_const); // Second TI - auto cell_memory_2_constant = ngraph::builder::makeConstant(ngPrc, cell_memory_dims, cell_memory_init); + auto cell_memory_2_constant = builder::makeConstant(ngPrc, cell_memory_dims, cell_memory_init); - auto hidden_memory_2_constant = ngraph::builder::makeConstant(ngPrc, hidden_memory_dims, hidden_memory_init); + auto hidden_memory_2_constant = builder::makeConstant(ngPrc, hidden_memory_dims, hidden_memory_init); // Body - inputs - auto X_2 = std::make_shared(ngPrc, ngraph::Shape{1, 1, hiddenSize}); - auto H_t_2 = std::make_shared(ngPrc, ngraph::Shape{1, hiddenSize}); - auto C_t_2 = std::make_shared(ngPrc, ngraph::Shape{1, hiddenSize}); + auto X_2 = std::make_shared(ngPrc, Shape{1, 1, hiddenSize}); + auto H_t_2 = std::make_shared(ngPrc, Shape{1, hiddenSize}); + auto C_t_2 = std::make_shared(ngPrc, Shape{1, hiddenSize}); H_t_2->set_friendly_name("hidden_state_2"); C_t_2->set_friendly_name("cell_state_2"); // Body - layers - auto squeeze_2_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto squeeze_2 = std::make_shared(X_2, squeeze_2_const); + auto squeeze_2_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto squeeze_2 = std::make_shared(X_2, squeeze_2_const); - auto weightsNode_2 = ngraph::builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, weights_2_vals); - auto reccurrenceWeightsNode_2 = ngraph::builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, reccurrenceWeights_vals); - auto biasNode_2 = ngraph::builder::makeConstant(ngPrc, {4 * hiddenSize}, bias_vals); - auto lstm_2 = std::make_shared(squeeze_2, H_t_2, C_t_2, weightsNode_2, reccurrenceWeightsNode_2, biasNode_2, hiddenSize); + auto weightsNode_2 = builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, weights_2_vals); + auto reccurrenceWeightsNode_2 = builder::makeConstant(ngPrc, { 4 * hiddenSize, hiddenSize }, reccurrenceWeights_vals); + auto biasNode_2 = builder::makeConstant(ngPrc, {4 * hiddenSize}, bias_vals); + auto lstm_2 = std::make_shared(squeeze_2, H_t_2, C_t_2, weightsNode_2, reccurrenceWeightsNode_2, biasNode_2, hiddenSize); - auto unsqueeze_2_const = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, squeeze_axes); - auto unsqueeze_2 = std::make_shared(lstm_2->output(0), unsqueeze_2_const); + auto unsqueeze_2_const = std::make_shared(element::i64, Shape{1}, squeeze_axes); + auto unsqueeze_2 = std::make_shared(lstm_2->output(0), unsqueeze_2_const); // body - outputs auto H_o_2 = lstm_2->output(0); auto C_o_2 = lstm_2->output(1); auto unsqueeze_o_2 = unsqueeze_2->output(0); - auto body_2 = std::make_shared(ngraph::OutputVector{unsqueeze_o_2, H_o_2, C_o_2}, ngraph::ParameterVector {X_2, H_t_2, C_t_2}); + auto body_2 = std::make_shared(OutputVector{unsqueeze_o_2, H_o_2, C_o_2}, ParameterVector {X_2, H_t_2, C_t_2}); // TI construction - auto tensor_iterator_2 = std::make_shared(); + auto tensor_iterator_2 = std::make_shared(); tensor_iterator_2->set_body(body_2); tensor_iterator_2->set_sliced_input(X_2, inbetween_squeeze, 0, 1, 1, -1, 0); tensor_iterator_2->set_merged_input(H_t_2, hidden_memory_2_constant, H_o_2); @@ -376,103 +384,109 @@ void MultipleLSTMCellTest::CreatePureTensorIteratorModel() { out_hidden_2.get_tensor().set_element_type(ngPrc); out_cell_2.get_tensor().set_element_type(ngPrc); tensor_iterator_2->validate_and_infer_types(); - auto final_reshape_pattern = std::make_shared(ngraph::element::i64, - ngraph::Shape{4}, std::vector({1, 1, 1, hiddenSize})); - auto final_reshape = std::make_shared(out_unsqueeze_2, final_reshape_pattern, false); + auto final_reshape_pattern = std::make_shared(element::i64, + Shape{4}, std::vector({1, 1, 1, hiddenSize})); + auto final_reshape = std::make_shared(out_unsqueeze_2, final_reshape_pattern, false); - function = std::make_shared(final_reshape, input_parameter, "PureTI"); + function = std::make_shared(final_reshape, input_parameter, "PureTI"); } -void MultipleLSTMCellTest::Run() { - SKIP_IF_CURRENT_TEST_IS_DISABLED() +void MultipleLSTMCellTest::InitMemory() { InferenceEngine::TensorDesc state_description(InferenceEngine::Precision::FP32, InferenceEngine::SizeVector({1, hiddenSize}), InferenceEngine::Layout::NC); - LoadNetwork(); IE_SUPPRESS_DEPRECATED_START auto states = executableNetwork.QueryState(); for (auto& state : states) { auto name = state.GetName(); - if (name == "cell_memory") { + if (name.find("cell_state_1") != std::string::npos) { auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state_description, cell_memory_init.data(), cell_memory_init.size()); state.SetState(blob); - } else if (name == "hidden_memory") { + } else if (name.find("hidden_state_1") != std::string::npos) { auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state_description, hidden_memory_init.data(), hidden_memory_init.size()); state.SetState(blob); - } else if (name == "cell_memory_2") { + } else if (name.find("cell_state_2") != std::string::npos) { auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state_description, - cell_memory_init.data(), cell_memory_init.size()); + cell_memory_init.data(), cell_memory_init.size()); state.SetState(blob); - } else if (name == "hidden_memory_2") { + } else if (name.find("hidden_state_2") != std::string::npos) { auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state_description, - hidden_memory_init.data(), hidden_memory_init.size()); + hidden_memory_init.data(), hidden_memory_init.size()); state.SetState(blob); } else { GTEST_FAIL() << "unknown memory state"; } } IE_SUPPRESS_DEPRECATED_END - GenerateInputs(); - Infer(); - switchToNgraphFriendlyModel(); - Validate(); } -void MultipleLSTMCellTest::RunLowLatency(bool regular_api) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() - InferenceEngine::TensorDesc state_description(InferenceEngine::Precision::FP32, - InferenceEngine::SizeVector({1, hiddenSize}), - InferenceEngine::Layout::NC); +void MultipleLSTMCellTest::ApplyLowLatency() { // Calculate values after LowLatency transformation CreatePureTensorIteratorModel(); - if (regular_api) { + if (transformation == ngraph::helpers::MemoryTransformation::LOW_LATENCY) { + function->validate_nodes_and_infer_types(); + // Apply LowLatency (insert Assigns/ReadValues) and UnrollTensorIterator + pass::Manager manager; + NGRAPH_SUPPRESS_DEPRECATED_START + manager.register_pass(); + NGRAPH_SUPPRESS_DEPRECATED_END // LowLatency enables UnrollTI + manager.run_passes(function); + bool ti_found = helpers::is_tensor_iterator_exist(function); + EXPECT_EQ(ti_found, true); + LoadNetwork(); + } else if (transformation == ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2) { + function->validate_nodes_and_infer_types(); + // Apply LowLatency (insert Assigns/ReadValues) and UnrollTensorIterator + + pass::Manager manager; + manager.register_pass(); + manager.run_passes(function); + bool ti_found = helpers::is_tensor_iterator_exist(function); + EXPECT_EQ(ti_found, false); + LoadNetwork(); + } else if (transformation == ngraph::helpers::MemoryTransformation::LOW_LATENCY_REGULAR_API) { cnnNetwork = InferenceEngine::CNNNetwork{function}; + IE_SUPPRESS_DEPRECATED_START InferenceEngine::LowLatency(cnnNetwork); + IE_SUPPRESS_DEPRECATED_END + + bool ti_found = helpers::is_tensor_iterator_exist(cnnNetwork.getFunction()); + EXPECT_EQ(ti_found, true); + + ConfigureNetwork(); + executableNetwork = core->LoadNetwork(cnnNetwork, targetDevice, configuration); + } else if (transformation == ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2_REGULAR_API) { + cnnNetwork = InferenceEngine::CNNNetwork{function}; + InferenceEngine::lowLatency2(cnnNetwork); + + bool ti_found = helpers::is_tensor_iterator_exist(cnnNetwork.getFunction()); + EXPECT_EQ(ti_found, false); + ConfigureNetwork(); executableNetwork = core->LoadNetwork(cnnNetwork, targetDevice, configuration); + } +} + +void MultipleLSTMCellTest::Run() { + SKIP_IF_CURRENT_TEST_IS_DISABLED() + if (transformation != ngraph::helpers::MemoryTransformation::NONE) { + ApplyLowLatency(); } else { - function->validate_nodes_and_infer_types(); - // Apply LowLatency (insert Assigns/ReadValues) and UnrollTensorIterator - ngraph::pass::Manager manager; - manager.register_pass(); // LowLatency enables UnrollTI - manager.run_passes(function); LoadNetwork(); } - IE_SUPPRESS_DEPRECATED_START - auto states = executableNetwork.QueryState(); - for (auto& state : states) { - auto name = state.GetName(); - if (name.find("cell_state_1") != std::string::npos) { - auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state_description, - cell_memory_init.data(), cell_memory_init.size()); - state.SetState(blob); - } else if (name.find("hidden_state_1") != std::string::npos) { - auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state_description, - hidden_memory_init.data(), hidden_memory_init.size()); - state.SetState(blob); - } else if (name.find("cell_state_2") != std::string::npos) { - auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state_description, - cell_memory_init.data(), cell_memory_init.size()); - state.SetState(blob); - } else if (name.find("hidden_state_2") != std::string::npos) { - auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state_description, - hidden_memory_init.data(), hidden_memory_init.size()); - state.SetState(blob); - } else { - GTEST_FAIL() << "unknown memory state"; - } - } - IE_SUPPRESS_DEPRECATED_END + + InitMemory(); GenerateInputs(); Infer(); - // Calculate ref values for Unrolled TI - CreatePureTensorIteratorModel(); - ngraph::pass::Manager manager_2; - manager_2.register_pass(); - manager_2.run_passes(function); + // Calculate ref values + if (transformation == ngraph::helpers::MemoryTransformation::NONE) { + switchToNgraphFriendlyModel(); + } else { + CreatePureTensorIteratorModel(); + } Validate(); } } // namespace SubgraphTestsDefinitions diff --git a/inference-engine/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/utils/ngraph_helpers.hpp b/inference-engine/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/utils/ngraph_helpers.hpp index de015677b4a2b4..de2dbab061289d 100644 --- a/inference-engine/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/utils/ngraph_helpers.hpp +++ b/inference-engine/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/utils/ngraph_helpers.hpp @@ -214,6 +214,15 @@ enum class SequenceTestsMode { CONVERT_TO_TI_RAND_SEQ_LEN_PARAM, }; +enum class MemoryTransformation { + NONE, + LOW_LATENCY, + LOW_LATENCY_REGULAR_API, + LOW_LATENCY_V2, + LOW_LATENCY_V2_REGULAR_API, + LOW_LATENCY_V2_ORIGINAL_INIT +}; + std::ostream &operator<<(std::ostream &os, const ReductionType &m); std::ostream &operator<<(std::ostream &os, const PadMode &m); @@ -297,5 +306,7 @@ std::ostream& operator<<(std::ostream & os, TensorIteratorBody type); std::ostream& operator<<(std::ostream & os, SequenceTestsMode type); +std::ostream& operator<<(std::ostream & os, MemoryTransformation type); + } // namespace helpers } // namespace ngraph diff --git a/inference-engine/tests/ngraph_helpers/ngraph_functions/src/utils/ngraph_helpers.cpp b/inference-engine/tests/ngraph_helpers/ngraph_functions/src/utils/ngraph_helpers.cpp index 5de50203ba28b3..2c5a07540b044b 100644 --- a/inference-engine/tests/ngraph_helpers/ngraph_functions/src/utils/ngraph_helpers.cpp +++ b/inference-engine/tests/ngraph_helpers/ngraph_functions/src/utils/ngraph_helpers.cpp @@ -817,5 +817,32 @@ std::ostream& operator<<(std::ostream & os, SequenceTestsMode type) { } return os; } + +std::ostream& operator<<(std::ostream & os, MemoryTransformation type) { + switch (type) { + case MemoryTransformation::NONE: + os << "NONE"; + break; + case MemoryTransformation::LOW_LATENCY_V2: + os << "LOW_LATENCY_V2"; + break; + case MemoryTransformation::LOW_LATENCY: + os << "LOW_LATENCY"; + break; + case MemoryTransformation::LOW_LATENCY_V2_REGULAR_API: + os << "LOW_LATENCY_V2_REGULAR_API"; + break; + case MemoryTransformation::LOW_LATENCY_REGULAR_API: + os << "LOW_LATENCY_REGULAR_API"; + break; + case MemoryTransformation::LOW_LATENCY_V2_ORIGINAL_INIT: + os << "LOW_LATENCY_V2_ORIGINAL_INIT"; + break; + default: + throw std::runtime_error("NOT_SUPPORTED_TYPE"); + } + return os; +} + } // namespace helpers } // namespace ngraph diff --git a/model-optimizer/mo/back/offline_transformations.py b/model-optimizer/mo/back/offline_transformations.py index a363a1ca250756..1df5f6cb7a0adf 100644 --- a/model-optimizer/mo/back/offline_transformations.py +++ b/model-optimizer/mo/back/offline_transformations.py @@ -11,7 +11,7 @@ def get_available_transformations(): try: from openvino.offline_transformations import ApplyLowLatencyTransformation # pylint: disable=import-error,no-name-in-module return { - 'LowLatency': ApplyLowLatencyTransformation, + 'LowLatency2': ApplyLowLatencyTransformation, } except Exception as e: return {} diff --git a/model-optimizer/mo/utils/cli_parser.py b/model-optimizer/mo/utils/cli_parser.py index 21d2873b54ed2c..e6b2f2d2517f83 100644 --- a/model-optimizer/mo/utils/cli_parser.py +++ b/model-optimizer/mo/utils/cli_parser.py @@ -8,6 +8,7 @@ import re from collections import OrderedDict from itertools import zip_longest +from distutils.util import strtobool import numpy as np @@ -257,9 +258,9 @@ def get_common_cli_parser(parser: argparse.ArgumentParser = None): help='Apply additional transformations. ' + 'Usage: "--transform transformation_name1[args],transformation_name2..." ' + 'where [args] is key=value pairs separated by semicolon. ' + - 'Examples: "--transform LowLatency" or ' + - ' "--transform LowLatency[num_iterations=2]" ' + - 'Available transformations: "LowLatency"', + 'Examples: "--transform LowLatency2" or ' + + ' "--transform LowLatency2[use_const_initializer=False]" ' + + 'Available transformations: "LowLatency2"', default="") common_group.add_argument('--disable_fusing', help='Turn off fusing of linear operations to Convolution', @@ -1151,6 +1152,14 @@ def isfloat(value): return False +def isbool(value): + try: + strtobool(value) + return True + except ValueError: + return False + + def convert_string_to_real_type(value: str): values = value.split(',') for i in range(len(values)): @@ -1159,6 +1168,8 @@ def convert_string_to_real_type(value: str): values[i] = int(value) elif isfloat(value): values[i] = float(value) + elif isbool(value): + values[i] = strtobool(value) return values[0] if len(values) == 1 else values diff --git a/model-optimizer/unit_tests/mo/utils/cli_parser_test.py b/model-optimizer/unit_tests/mo/utils/cli_parser_test.py index 68a9994d2068c9..c6c1c96e46a66e 100644 --- a/model-optimizer/unit_tests/mo/utils/cli_parser_test.py +++ b/model-optimizer/unit_tests/mo/utils/cli_parser_test.py @@ -905,64 +905,65 @@ def test_empty(self): self.assertEqual(parse_transform(""), []) def test_single_pass(self): - self.assertEqual(parse_transform("LowLatency"), [("LowLatency", {})]) + self.assertEqual(parse_transform("LowLatency2"), [("LowLatency2", {})]) def test_single_pass_with_args(self): - self.assertEqual(parse_transform("LowLatency[num_iterations=2]"), - [("LowLatency", {"num_iterations": 2})]) + self.assertEqual(parse_transform("LowLatency2[use_const_initializer=True]"), + [("LowLatency2", {"use_const_initializer": True})]) def test_single_pass_with_multiple_args(self): - self.assertEqual(parse_transform("LowLatency[num_iterations=2;dummy_attr=3.14]"), - [("LowLatency", {"num_iterations": 2, "dummy_attr": 3.14})]) + self.assertEqual(parse_transform("LowLatency2[use_const_initializer=True;dummy_attr=3.14]"), + [("LowLatency2", {"use_const_initializer": True, "dummy_attr": 3.14})]) def test_multiple_passes_with_args(self): - self.assertEqual(parse_transform("LowLatency[num_iterations=2],DummyPass[type=ReLU]"), - [("LowLatency", {"num_iterations": 2}), + self.assertEqual(parse_transform("LowLatency2[use_const_initializer=True],DummyPass[type=ReLU]"), + [("LowLatency2", {"use_const_initializer": True}), ("DummyPass", {"type": "ReLU"})]) def test_multiple_passes_with_args2(self): - self.assertEqual(parse_transform("LowLatency[num_iterations=2,3,4.15],DummyPass1,DummyPass2[types=ReLU,PReLU;values=1,2,3]"), - [("LowLatency", {"num_iterations": [2,3,4.15]}), + self.assertEqual(parse_transform("LowLatency2[use_const_initializer=True,False],DummyPass1," + "DummyPass2[types=ReLU,PReLU;values=1,2,3]"), + [("LowLatency2", {"use_const_initializer": [True, False]}), ("DummyPass1", {}), ("DummyPass2", {"types": ["ReLU", "PReLU"], "values": [1,2,3]})]) def test_multiple_passes_no_args(self): - self.assertEqual(parse_transform("DummyPass,LowLatency2"), - [("DummyPass", {}), ("LowLatency2", {})]) + self.assertEqual(parse_transform("DummyPass,LowLatency22"), + [("DummyPass", {}), ("LowLatency22", {})]) def test_single_pass_neg(self): - self.assertRaises(Error, parse_transform, "LowLatency!") + self.assertRaises(Error, parse_transform, "LowLatency2!") def test_multiple_passes_neg(self): - self.assertRaises(Error, parse_transform, "LowLatency;DummyPass") + self.assertRaises(Error, parse_transform, "LowLatency2;DummyPass") def test_single_pass_with_args_neg1(self): - self.assertRaises(Error, parse_transform, "LowLatency[=2]") + self.assertRaises(Error, parse_transform, "LowLatency2[=2]") def test_single_pass_with_args_neg2(self): - self.assertRaises(Error, parse_transform, "LowLatency[key=]") + self.assertRaises(Error, parse_transform, "LowLatency2[key=]") def test_single_pass_with_args_neg3(self): - self.assertRaises(Error, parse_transform, "LowLatency[]") + self.assertRaises(Error, parse_transform, "LowLatency2[]") def test_single_pass_with_args_neg4(self): - self.assertRaises(Error, parse_transform, "LowLatency[key=value;]") + self.assertRaises(Error, parse_transform, "LowLatency2[key=value;]") def test_single_pass_with_args_neg5(self): - self.assertRaises(Error, parse_transform, "LowLatency[value]") + self.assertRaises(Error, parse_transform, "LowLatency2[value]") def test_single_pass_with_args_neg6(self): - self.assertRaises(Error, parse_transform, "LowLatency[key=value") + self.assertRaises(Error, parse_transform, "LowLatency2[key=value") @patch("mo.back.offline_transformations.get_available_transformations") def test_check_low_latency_is_available(self, available_transformations): - available_transformations.return_value = {"LowLatency": None} + available_transformations.return_value = {"LowLatency2": None} try: - check_available_transforms([("LowLatency" ,"")], True) + check_available_transforms([("LowLatency2", "")], True) except Error as e: self.assertTrue(False, "Exception \"{}\" is unexpected".format(e)) @patch("mo.back.offline_transformations.get_available_transformations") def test_check_dummy_pass_is_available(self, available_transformations): - available_transformations.return_value = {"LowLatency": None} + available_transformations.return_value = {"LowLatency2": None} self.assertRaises(Error, check_available_transforms, [("DummyPass", "")], True) diff --git a/ngraph/core/include/ngraph/pass/low_latency.hpp b/ngraph/core/include/ngraph/pass/low_latency.hpp index 86757edb800836..507ffe3a21b145 100644 --- a/ngraph/core/include/ngraph/pass/low_latency.hpp +++ b/ngraph/core/include/ngraph/pass/low_latency.hpp @@ -8,13 +8,14 @@ #include #include +#include namespace ngraph { namespace pass { /** - * @brief The transformation finds all TensorIterator layers in the network, + * @brief The transformation finds all TensorIterator/Loop layers in the network, * processes all back edges that describe a connection between Result and Parameter * of the TensorIterator body,and inserts ReadValue layer between Parameter * and the next layers after this Parameter, and Assign layer after the layers @@ -42,11 +43,50 @@ namespace ngraph * by step, the states will store between inferences. */ - class NGRAPH_API LowLatency : public ngraph::pass::MatcherPass + class NGRAPH_DEPRECATED("Use LowLatency2 instead.") NGRAPH_API LowLatency + : public ngraph::pass::MatcherPass { public: NGRAPH_RTTI_DECLARATION; LowLatency(); }; + + /** + * @brief The transformation finds all TensorIterator/Loop layers in the network, + * processes all back edges that describe a connection between Result and Parameter + * of the TensorIterator/Loop bodies,and inserts ReadValue and Assign layers at the + * input and output corresponding to this back edge. + * Supported platforms: CPU, GNA. + * + * The example below describes the changes made by the transformation + * [] - TensorIterator body + * () - new layer + * BE - back-edge + * + * before applying the transformation: + * -> input1[BE_1 -> Parameter -> Layers ... -> Result -> BE_1 ]output1-> + * + * after applying the transformation: + * ->(ReadValue)-> input1[BE_1 ->Parameter->Layers ...->Result->BE_1]output1 ->(Assign) + * \ + * ->... + * After applying the transformation, the resulting network can be inferred + * step by step, the states will store between inferences. + */ + class NGRAPH_API LowLatency2 : public ngraph::pass::FunctionPass + { + public: + NGRAPH_RTTI_DECLARATION; + + explicit LowLatency2(bool use_const_initializer = true) + : m_use_const_initializer(use_const_initializer) + { + } + + bool run_on_function(std::shared_ptr f) override; + + private: + bool m_use_const_initializer; + }; } // namespace pass } // namespace ngraph diff --git a/ngraph/core/src/op/tensor_iterator.cpp b/ngraph/core/src/op/tensor_iterator.cpp index 5252d2124f24c3..35162ef3cebbfa 100644 --- a/ngraph/core/src/op/tensor_iterator.cpp +++ b/ngraph/core/src/op/tensor_iterator.cpp @@ -129,7 +129,6 @@ void op::v0::TensorIterator::validate_and_infer_types() m_body->get_results().at(merged_input_description->m_body_value_index)->input(0); ends.push_back(body_value.get_node()->shared_from_this()); - auto body_value_partial_shape = body_value.get_partial_shape(); auto body_parameter = m_body->get_parameters().at(merged_input_description->m_body_parameter_index); diff --git a/ngraph/core/src/pass/low_latency.cpp b/ngraph/core/src/pass/low_latency.cpp index ea5effce4abdfb..d290eb14b7e4af 100644 --- a/ngraph/core/src/pass/low_latency.cpp +++ b/ngraph/core/src/pass/low_latency.cpp @@ -6,12 +6,29 @@ #include +#include #include +#include #include +#include #include +NGRAPH_RTTI_DEFINITION(ngraph::pass::LowLatency2, "LowLatency2", 0); + +NGRAPH_SUPPRESS_DEPRECATED_START NGRAPH_RTTI_DEFINITION(ngraph::pass::LowLatency, "LowLatency", 0); +using namespace std; +using namespace ngraph; + +namespace +{ + string generate_variable_name(const string& op_name, const string& param_name, int variable_idx) + { + return op_name + "/" + param_name + "/" + "variable_" + to_string(variable_idx); + } + +} // namespace ngraph::pass::LowLatency::LowLatency() { auto tensor_iterator = ngraph::pattern::wrap_type(); @@ -58,11 +75,12 @@ ngraph::pass::LowLatency::LowLatency() const auto& inputs_to = func->get_parameters() .at(merged_in->m_body_parameter_index) ->get_output_target_inputs(0); - const std::string variable_name(sub_graph_op->get_friendly_name() + "/" + - func->get_parameters() - .at(merged_in->m_body_parameter_index) - ->get_friendly_name() + - "/variable_" + std::to_string(variable_id)); + const std::string variable_name( + generate_variable_name(sub_graph_op->get_friendly_name(), + func->get_parameters() + .at(merged_in->m_body_parameter_index) + ->get_friendly_name(), + variable_id)); auto variable = std::make_shared( VariableInfo{PartialShape::dynamic(), element::dynamic, variable_name}); auto read_value = std::make_shared( @@ -90,3 +108,178 @@ ngraph::pass::LowLatency::LowLatency() auto m = std::make_shared(tensor_iterator, "LowLatency"); register_matcher(m, callback); } +NGRAPH_SUPPRESS_DEPRECATED_END + +void UnrollSingleIteration(const shared_ptr& sub_graph_op, + const shared_ptr& outer_f) +{ + using namespace opset7; + + const auto& params = sub_graph_op->get_function()->get_parameters(); + const auto& results = sub_graph_op->get_function()->get_results(); + + // before: Layer1 -> TI [input -> bodyParameter -> Layer2 -> ...] + // after: Layer1 -> Layer2 ->... + for (const auto& in : sub_graph_op->get_input_descriptions()) + { + const auto& connect_to = sub_graph_op->get_input_source_output(in->m_input_index); + for (auto& output : params.at(in->m_body_parameter_index)->outputs()) + { + output.replace(connect_to); + } + } + + // before: TI [...-> Layer1 -> Result -> output] -> Layer2 -> ... + // after: ...-> Layer1 -> Layer2 -> ... + NodeVector new_ops; + for (const auto& out : sub_graph_op->get_output_descriptions()) + { + const auto& connect_to = results.at(out->m_body_value_index)->get_input_source_output(0); + for (auto& input_to : sub_graph_op->output(out->m_output_index).get_target_inputs()) + { + // create IE output name + std::string out_name = sub_graph_op->get_friendly_name(); + if (sub_graph_op->get_output_size() != 1) + out_name += "." + std::to_string(out->m_output_index); + + // IECompatibility: insert identity (Unsqueeze + Squeeze) to store the TensorIterator + // output names + auto axis_1 = Constant::create(ngraph::element::i64, ngraph::Shape{1}, {1}); + auto identity_1 = std::make_shared(connect_to, axis_1); + auto identity_2 = std::make_shared(identity_1, axis_1); + identity_2->set_friendly_name(out_name); + new_ops.push_back(identity_1); + new_ops.push_back(identity_2); + + input_to.replace_source_output(identity_2); + } + } + outer_f->add_sinks(sub_graph_op->get_function()->get_sinks()); + ngraph::copy_runtime_info(sub_graph_op, sub_graph_op->get_function()->get_ops()); + ngraph::copy_runtime_info(sub_graph_op, new_ops); +} + +Output create_init_subgraph(const shared_ptr& sub_graph_op, + const Output& in_node) +{ + using namespace opset7; + + auto const_zero = make_shared(in_node.get_element_type(), Shape{1}, 0); + auto shape_of = make_shared(in_node); + auto broadcast = make_shared(const_zero, shape_of); + copy_runtime_info(sub_graph_op, {const_zero, shape_of, broadcast}); + return broadcast->output(0); +} + +bool pass::LowLatency2::run_on_function(shared_ptr f) +{ + using namespace opset7; + + SinkVector assigns; + for (const auto& op : f->get_ordered_ops()) + { + if (const auto& sub_graph_op = dynamic_pointer_cast(op)) + { + int64_t variable_id = 0; + const auto& func = sub_graph_op->get_function(); + const auto& params = func->get_parameters(); + for (const auto& in : sub_graph_op->get_input_descriptions()) + { + // Process all back edges + if (const auto& merged_in = + dynamic_pointer_cast(in)) + { + // create new Variable + const string& param_name = + params.at(merged_in->m_body_parameter_index)->get_friendly_name(); + const string& var_name = generate_variable_name( + sub_graph_op->get_friendly_name(), param_name, variable_id); + + const auto& input = sub_graph_op->input(merged_in->m_input_index); + if (std::dynamic_pointer_cast( + input.get_source_output().get_node_shared_ptr()) != nullptr) + { + NGRAPH_DEBUG + << "LowLatency2 transformation cannot be applied because the " + << "ReadValue node is already an input to the TensorIterator." + << "LowLatency2 transformation may have already been applied, please " + << "do not call it more then once."; + return false; + } + + const auto& param = sub_graph_op->get_function()->get_parameters().at( + merged_in->m_body_parameter_index); + for (const auto& in_to : param->output(0).get_target_inputs()) + { + if (dynamic_cast(in_to.get_node()) != nullptr) + { + NGRAPH_DEBUG + << "LowLatency2 transformation cannot be applied because the " + << "ReadValue node is already inside the TensorIterator. " + << "LowLatency transformation may have been applied, please do " + << "not call LowLatency2 after LowLatency."; + return false; + } + } + + VariableInfo var_info{PartialShape::dynamic(), element::dynamic, var_name}; + auto variable = make_shared(var_info); + + // insert ReadValue + // Layers -> [new op: ReadValue] -> Subgraph operation + Output read_value_in = input.get_source_output(); + if (m_use_const_initializer) + { + read_value_in = create_init_subgraph(sub_graph_op, read_value_in); + } + auto read_value = make_shared(read_value_in, variable); + input.replace_source_output(read_value->output(0)); + read_value->set_friendly_name(var_name); + ngraph::copy_runtime_info(sub_graph_op, read_value); + + /* insert Assign + // Subgraph operation -> [new op: Assign] + // \ + // ---> Layers -> ... + */ + const auto& out_desc = sub_graph_op->get_output_descriptions(); + bool is_output_exist = std::any_of( + out_desc.begin(), + out_desc.end(), + [&merged_in]( + const std::shared_ptr& out) { + return out->m_body_value_index == merged_in->m_body_value_index; + }); + // Create new output if it doesn't exist. + if (!is_output_exist) + { + sub_graph_op->get_iter_value( + func->get_results().at(merged_in->m_body_value_index)); + } + for (const auto& out : sub_graph_op->get_output_descriptions()) + { + if (out->m_body_value_index == merged_in->m_body_value_index) + { + auto assign = make_shared( + sub_graph_op->output(out->m_output_index), variable); + ngraph::copy_runtime_info(sub_graph_op, assign); + // control dependency so that ReadValue is processed before Assign + assign->add_control_dependency(read_value); + assigns.emplace_back(assign); + break; + } + } + } + + variable_id++; + } + + if (sub_graph_op->get_num_iterations() == 1) + { + UnrollSingleIteration(sub_graph_op, f); + } + } + } + f->add_sinks(assigns); + return true; +} From 6a18b45337bd64542155416415d53e46627d31b9 Mon Sep 17 00:00:00 2001 From: Yegor Kruglov Date: Mon, 7 Jun 2021 16:44:16 +0300 Subject: [PATCH 005/178] [MO] Implementation of names uniqueness check (#5651) * added new transformation to check the uniqueness of nodes names * added unittest * remove redundant line * conversation resolving * updated unittest * added new unittest, added check for uniqueness of new node name * added a description * added renaming of several results with the same name and unittest for this case * another implementation, updated unittests * added a comment * updated comments * added comment to the nodes_with_equal_names func * added a condition * added a result name check in unittests --- model-optimizer/automation/package_BOM.txt | 1 + .../extensions/back/names_uniqueness_check.py | 67 +++++++++++++++++ .../back/names_uniqueness_check_test.py | 71 +++++++++++++++++++ 3 files changed, 139 insertions(+) create mode 100644 model-optimizer/extensions/back/names_uniqueness_check.py create mode 100644 model-optimizer/unit_tests/extensions/back/names_uniqueness_check_test.py diff --git a/model-optimizer/automation/package_BOM.txt b/model-optimizer/automation/package_BOM.txt index 128c9c98117216..be0dc1c37e0dd5 100644 --- a/model-optimizer/automation/package_BOM.txt +++ b/model-optimizer/automation/package_BOM.txt @@ -37,6 +37,7 @@ extensions/back/LRNToNorm.py extensions/back/MarkNodesWithShapeValues.py extensions/back/MatMulNormalizer.py extensions/back/MaxPool.py +extensions/back/names_uniqueness_check.py extensions/back/NormalizeToNormalizeL2.py extensions/back/op_versioning.py extensions/back/OptimizeTransposeReshapeSequence.py diff --git a/model-optimizer/extensions/back/names_uniqueness_check.py b/model-optimizer/extensions/back/names_uniqueness_check.py new file mode 100644 index 00000000000000..188df9f4427fbd --- /dev/null +++ b/model-optimizer/extensions/back/names_uniqueness_check.py @@ -0,0 +1,67 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +from collections import defaultdict +from extensions.back.pass_separator import BackFinish +from mo.back.replacement import BackReplacementPattern +from mo.graph.graph import Graph, rename_node + + +def nodes_with_equal_names(graph: Graph): + """ + :param graph: Graph to operate on + :return: Dictionary with node names as keys and a list of their corresponding nodes as values + """ + names_dict = defaultdict(list) + for node in graph.get_op_nodes(): + node_name = node.soft_get('name', node.id) + names_dict[node_name].append(node) + return names_dict + + +def make_node_names_unique(nodes: list, node_names: set): + """ + :param nodes: List with nodes matching a specific name + :param node_names: Set with all node names contained in the graph + :return: None + + Result nodes will be renamed only when it is absolutely necessary(if there are several Result nodes with the same name). + Function finds a position of Result nodes in the "nodes" list, take the first and rename all other nodes. + If the "nodes" list does not contain Result nodes, then all nodes starting from the second one will be renamed. + All new names are added to the "node_names" set. + """ + results_pos = [idx for idx, node in enumerate(nodes) if node.op == 'Result'] + node_position_to_keep = 0 + if len(results_pos) != 0: + node_position_to_keep = results_pos[0] + for idx, node in enumerate(nodes): + if idx != node_position_to_keep: + new_node_name = node.soft_get('name', node.id) + '_' + str(idx) + # preparing a new unique name for the node + while new_node_name in node_names: + new_node_name += '_' + str(idx) + node_names.add(new_node_name) + rename_node(node, new_node_name) + + +class NamesUniquenessCheck(BackReplacementPattern): + """ + If there are several layers with the same name in the original model and they are saved in the IR, IE will fail with + the invalid IR error. IE checks the uniqueness of the names and, if it is not true, throws an exception. The way how + to fix it on the MO side is to rename this nodes (one node will remain with the original name). Since we prefer to + save framework names for the output nodes, nodes with op=Result will not be renamed, except the case when there are + several Result nodes with the same name. + """ + enabled = True + + def run_after(self): + return [BackFinish] + + def run_before(self): + return [] + + def find_and_replace_pattern(self, graph: Graph): + names_to_nodes = nodes_with_equal_names(graph) + node_names = set(names_to_nodes.keys()) + for nodes in names_to_nodes.values(): + if len(nodes) > 1: + make_node_names_unique(nodes, node_names) diff --git a/model-optimizer/unit_tests/extensions/back/names_uniqueness_check_test.py b/model-optimizer/unit_tests/extensions/back/names_uniqueness_check_test.py new file mode 100644 index 00000000000000..94f83af1a1b18c --- /dev/null +++ b/model-optimizer/unit_tests/extensions/back/names_uniqueness_check_test.py @@ -0,0 +1,71 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import unittest + +from extensions.back.names_uniqueness_check import NamesUniquenessCheck +from mo.graph.graph import Node +from unit_tests.utils.graph import build_graph + + +class TestNamesUniquenessCheck(unittest.TestCase): + + def test_1(self): + graph = build_graph( + nodes_attrs={ + 'input': {'kind': 'op', 'op': 'Parameter', 'name': 'node'}, + 'cast': {'kind': 'op', 'op': 'Cast', 'name': 'node'}, + 'result': {'kind': 'op', 'op': 'Result', 'name': 'node'} + }, + edges=[ + ('input', 'cast'), + ('cast', 'result') + ] + ) + + NamesUniquenessCheck().find_and_replace_pattern(graph) + names = [node.name for node in graph.get_op_nodes()] + result_name = Node(graph, 'result').name + + self.assertTrue(len(set(names)) == 3) + self.assertTrue(result_name == 'node') + + def test_2(self): + graph = build_graph( + nodes_attrs={ + 'input': {'kind': 'op', 'op': 'Parameter', 'name': 'node'}, + 'cast': {'kind': 'op', 'op': 'Cast', 'name': 'node_0'}, + 'result': {'kind': 'op', 'op': 'Result', 'name': 'node'} + }, + edges=[ + ('input', 'cast'), + ('cast', 'result') + ] + ) + + NamesUniquenessCheck().find_and_replace_pattern(graph) + names = [node.name for node in graph.get_op_nodes()] + result_name = Node(graph, 'result').name + + self.assertTrue(len(set(names)) == 3) + self.assertTrue(result_name == 'node') + + def test_3(self): + graph = build_graph( + nodes_attrs={ + 'input': {'kind': 'op', 'op': 'Parameter', 'name': 'node_0'}, + 'cast': {'kind': 'op', 'op': 'Cast', 'name': 'node_1'}, + 'result_1': {'kind': 'op', 'op': 'Result', 'name': 'node'}, + 'result_2': {'kind': 'op', 'op': 'Result', 'name': 'node'} + }, + edges=[ + ('input', 'cast'), + ('cast', 'result_1'), + ('cast', 'result_2'), + ] + ) + NamesUniquenessCheck().find_and_replace_pattern(graph) + names = [node.name for node in graph.get_op_nodes()] + + self.assertTrue('node' in names) + self.assertTrue(len(set(names)) == 4) From c80e939474e965437d68c082e2d13e8cb3f36dca Mon Sep 17 00:00:00 2001 From: Alexander Zhogov Date: Mon, 7 Jun 2021 17:53:06 +0300 Subject: [PATCH 006/178] GitHub CI: non PR author commits are allowed (#6064) --- .github/org_control/check_pr.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/org_control/check_pr.py b/.github/org_control/check_pr.py index 882854724ca646..e0b48832ead75c 100644 --- a/.github/org_control/check_pr.py +++ b/.github/org_control/check_pr.py @@ -139,14 +139,15 @@ def update_labels(gh_api, pull, non_org_intel_pr_users, non_org_pr_users): def get_wrong_commits(pull): """Returns commits with incorrect user and email""" - print("GitHub PR user email:", pull.user.email) + pr_author_email = pull.user.email.lower() + print("GitHub PR author email:", pr_author_email) print("Check commits:") wrong_commits = set() for commit in pull.get_commits(): # import pprint; pprint.pprint(commit.raw_data) print("Commit SHA:", commit.sha) # Use raw data because commit author can be non GitHub user - commit_email = commit.raw_data["commit"]["author"]["email"] + commit_email = commit.raw_data["commit"]["author"]["email"].lower() print(" Commit email:", commit_email) if not github_api.is_valid_user(commit.author): print( @@ -159,9 +160,8 @@ def get_wrong_commits(pull): " WARNING: The commit is not verified. Reason:", commit.raw_data["commit"]["verification"]["reason"], ) - if pull.user.email != commit_email: - print(" ERROR: Commit email and GitHub user public email are differnt") - wrong_commits.add(commit.sha) + if pr_author_email != commit_email: + print(" WARNING: Commit email and GitHub PR author public email are differnt") return wrong_commits From 56ada41bd05f47ceeddd86f1e99f61858e26a2ba Mon Sep 17 00:00:00 2001 From: Mikhail Treskin Date: Mon, 7 Jun 2021 18:19:52 +0300 Subject: [PATCH 007/178] Add get_constant_from_source capability to pyngraph (#6018) --- ngraph/python/src/pyngraph/util.cpp | 19 +++++++++++++ ngraph/python/tests/test_ngraph/test_utils.py | 28 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 ngraph/python/tests/test_ngraph/test_utils.py diff --git a/ngraph/python/src/pyngraph/util.cpp b/ngraph/python/src/pyngraph/util.cpp index a2eac625babb49..5178e84fe9081b 100644 --- a/ngraph/python/src/pyngraph/util.cpp +++ b/ngraph/python/src/pyngraph/util.cpp @@ -5,6 +5,7 @@ #include #include "pyngraph/util.hpp" +#include "ngraph/validation_util.hpp" namespace py = pybind11; @@ -18,4 +19,22 @@ void regmodule_pyngraph_util(py::module m) { py::module mod = m.def_submodule("util", "ngraph.impl.util"); mod.def("numpy_to_c", &numpy_to_c); + mod.def("get_constant_from_source", + &ngraph::get_constant_from_source, + py::arg("output"), + R"( + Runs an estimation of source tensor. + + Parameters + ---------- + output : Output + output node + + Returns + ---------- + get_constant_from_source : Constant or None + If it succeeded to calculate both bounds and + they are the same returns Constant operation + from the resulting bound, otherwise Null. + )"); } diff --git a/ngraph/python/tests/test_ngraph/test_utils.py b/ngraph/python/tests/test_ngraph/test_utils.py new file mode 100644 index 00000000000000..49b90017305356 --- /dev/null +++ b/ngraph/python/tests/test_ngraph/test_utils.py @@ -0,0 +1,28 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import ngraph as ng +from ngraph.impl import Shape + + +def test_get_constant_from_source_success(): + dtype = np.int + input1 = ng.parameter(Shape([5, 5]), dtype=dtype, name="input_1") + input2 = ng.parameter(Shape([25]), dtype=dtype, name="input_2") + shape_of = ng.shape_of(input2, name="shape_of") + reshape = ng.reshape(input1, shape_of, special_zero=True) + folded_const = ng.impl.util.get_constant_from_source(reshape.input(1).get_source_output()) + + assert folded_const is not None + assert folded_const.get_vector() == [25] + + +def test_get_constant_from_source_failed(): + dtype = np.int + input1 = ng.parameter(Shape([5, 5]), dtype=dtype, name="input_1") + input2 = ng.parameter(Shape([1]), dtype=dtype, name="input_2") + reshape = ng.reshape(input1, input2, special_zero=True) + folded_const = ng.impl.util.get_constant_from_source(reshape.input(1).get_source_output()) + + assert folded_const is None From 64d7a40ae4d783eda53a34d8201b928ebf4e3479 Mon Sep 17 00:00:00 2001 From: Andrei Gorbachev Date: Mon, 7 Jun 2021 18:36:38 +0300 Subject: [PATCH 008/178] [IE CLDNN] 54304 fix reduce ops (#5986) --- .../src/cldnn_engine/ops/reduce.cpp | 25 ++++++- .../subgraph_tests/reduce_eltwise.cpp | 47 +++++++++++++ .../include/subgraph_tests/reduce_eltwise.hpp | 15 +++++ .../subgraph/reduce_eltwise.hpp | 36 ++++++++++ .../src/subgraph/reduce_eltwise.cpp | 67 +++++++++++++++++++ 5 files changed, 189 insertions(+), 1 deletion(-) create mode 100644 inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/reduce_eltwise.cpp create mode 100644 inference-engine/tests/functional/plugin/shared/include/subgraph_tests/reduce_eltwise.hpp create mode 100644 inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/reduce_eltwise.hpp create mode 100644 inference-engine/tests/functional/shared_test_classes/src/subgraph/reduce_eltwise.cpp diff --git a/inference-engine/src/cldnn_engine/ops/reduce.cpp b/inference-engine/src/cldnn_engine/ops/reduce.cpp index 3331d581b86c3e..26343ffb813129 100644 --- a/inference-engine/src/cldnn_engine/ops/reduce.cpp +++ b/inference-engine/src/cldnn_engine/ops/reduce.cpp @@ -18,6 +18,7 @@ #include "api/reduce.hpp" #include "api/reorder.hpp" +#include "api/reshape.hpp" namespace CLDNNPlugin { @@ -78,6 +79,28 @@ void CreateReduceOp(Program& p, const std::shared_ptr& op, cldnn:: p.AddPrimitive(reducePrim); + auto resultLayerName = layerName; + auto out_dims = op->get_output_shape(0).size(); + if (out_dims == 3 && !keep_dims && rank >= 4) { + resultLayerName = layerName + "_reshape"; + auto out_shape = op->get_output_shape(0); + cldnn::tensor outTensor; + switch (rank) { + case 6: + outTensor = cldnn::tensor(TensorValue(out_shape[0]), TensorValue(out_shape[1]), + 1, TensorValue(out_shape[2]), 1, 1); + case 5: + outTensor = cldnn::tensor(TensorValue(out_shape[0]), TensorValue(out_shape[1]), + 1, TensorValue(out_shape[2]), 1); + case 4: + outTensor = cldnn::tensor(TensorValue(out_shape[0]), TensorValue(out_shape[1]), + 1, TensorValue(out_shape[2])); + } + auto reshape_prim = cldnn::reshape(resultLayerName, layerName, outTensor); + p.AddPrimitive(reshape_prim); + p.AddPrimitiveToProfiler(op, resultLayerName); + } + auto reorderLayerName = layerName + "_reorder"; cldnn::format out_format = cldnn::format::any; auto out_dt = DataTypeFromPrecision(op->get_output_element_type(0)); @@ -89,7 +112,7 @@ void CreateReduceOp(Program& p, const std::shared_ptr& op, cldnn:: else if (rank - rawAxes.size() <= 4) out_format = cldnn::format::bfyx; - auto reorder_prim = cldnn::reorder(reorderLayerName, layerName, out_format, out_dt); + auto reorder_prim = cldnn::reorder(reorderLayerName, resultLayerName, out_format, out_dt); p.AddPrimitive(reorder_prim); p.AddPrimitiveToProfiler(op, reorderLayerName); } else { diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/reduce_eltwise.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/reduce_eltwise.cpp new file mode 100644 index 00000000000000..04dbc6e800551e --- /dev/null +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/reduce_eltwise.cpp @@ -0,0 +1,47 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "subgraph_tests/reduce_eltwise.hpp" + +using namespace SubgraphTestsDefinitions; + +namespace { + +const std::vector netPrecisions = { + InferenceEngine::Precision::FP32, +}; + +INSTANTIATE_TEST_CASE_P(smoke_ReduceEltwise6D, ReduceEltwiseTest, + testing::Combine( + testing::Values(std::vector{2, 3, 4, 5, 6, 7}), + testing::Values(std::vector{2, 3, 4}), + testing::Values(CommonTestUtils::OpType::VECTOR), + testing::Values(false), + testing::ValuesIn(netPrecisions), + testing::Values(CommonTestUtils::DEVICE_GPU)), + ReduceEltwiseTest::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_ReduceEltwise5D, ReduceEltwiseTest, + testing::Combine( + testing::Values(std::vector{2, 3, 4, 5, 6}), + testing::Values(std::vector{2, 3}), + testing::Values(CommonTestUtils::OpType::VECTOR), + testing::Values(false), + testing::ValuesIn(netPrecisions), + testing::Values(CommonTestUtils::DEVICE_GPU)), + ReduceEltwiseTest::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_ReduceEltwise4D, ReduceEltwiseTest, + testing::Combine( + testing::Values(std::vector{2, 3, 4, 5}), + testing::Values(std::vector{2}), + testing::Values(CommonTestUtils::OpType::VECTOR), + testing::Values(false), + testing::ValuesIn(netPrecisions), + testing::Values(CommonTestUtils::DEVICE_GPU)), + ReduceEltwiseTest::getTestCaseName); + +} // namespace diff --git a/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/reduce_eltwise.hpp b/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/reduce_eltwise.hpp new file mode 100644 index 00000000000000..0b65a847820e5a --- /dev/null +++ b/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/reduce_eltwise.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/subgraph/reduce_eltwise.hpp" + +namespace SubgraphTestsDefinitions { + +TEST_P(ReduceEltwiseTest, CompareWithRefs) { + Run(); +}; + +} // namespace SubgraphTestsDefinitions diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/reduce_eltwise.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/reduce_eltwise.hpp new file mode 100644 index 00000000000000..df04891bf906eb --- /dev/null +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/reduce_eltwise.hpp @@ -0,0 +1,36 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include +#include "shared_test_classes/base/layer_test_utils.hpp" +#include "ngraph_functions/builders.hpp" +#include "ngraph_functions/utils/ngraph_helpers.hpp" +#include "common_test_utils/test_constants.hpp" + +namespace SubgraphTestsDefinitions { + +using ReduceEltwiseParamsTuple = typename std::tuple< + std::vector, // Input shapes + std::vector, // Axis to reduce order + CommonTestUtils::OpType, // Scalar or vector type axis + bool, // Keep dims + InferenceEngine::Precision, // Network precision + std::string>; // Device name + +class ReduceEltwiseTest: + public testing::WithParamInterface, + public LayerTestsUtils::LayerTestsCommon{ +public: + std::shared_ptr fn; + static std::string getTestCaseName(const testing::TestParamInfo &obj); +protected: + void SetUp() override; +}; + +} // namespace SubgraphTestsDefinitions diff --git a/inference-engine/tests/functional/shared_test_classes/src/subgraph/reduce_eltwise.cpp b/inference-engine/tests/functional/shared_test_classes/src/subgraph/reduce_eltwise.cpp new file mode 100644 index 00000000000000..b51ca490090767 --- /dev/null +++ b/inference-engine/tests/functional/shared_test_classes/src/subgraph/reduce_eltwise.cpp @@ -0,0 +1,67 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "ngraph_functions/builders.hpp" +#include "shared_test_classes/subgraph/reduce_eltwise.hpp" + +namespace SubgraphTestsDefinitions { +std::string ReduceEltwiseTest::getTestCaseName(const testing::TestParamInfo &obj) { + std::vector inputShapes; + std::vector axes; + CommonTestUtils::OpType opType; + bool keepDims; + InferenceEngine::Precision netPrecision; + std::string targetName; + std::tie(inputShapes, axes, opType, keepDims, netPrecision, targetName) = obj.param; + + std::ostringstream result; + result << "IS=" << CommonTestUtils::vec2str(inputShapes) << "_"; + result << "axes=" << CommonTestUtils::vec2str(axes) << "_"; + result << "opType=" << opType << "_"; + if (keepDims) result << "KeepDims_"; + result << "netPRC=" << netPrecision.name() << "_"; + result << "targetDevice=" << targetName; + return result.str(); +} + +void ReduceEltwiseTest::SetUp() { + std::vector inputShape; + std::vector axes; + CommonTestUtils::OpType opType; + bool keepDims; + InferenceEngine::Precision netPrecision; + std::string targetName; + std::tie(inputShape, axes, opType, keepDims, netPrecision, targetName) = this->GetParam(); + auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); + auto params = ngraph::builder::makeParams(ngPrc, {inputShape}); + auto paramOuts = ngraph::helpers::convert2OutputVector( + ngraph::helpers::castOps2Nodes(params)); + + std::vector shapeAxes; + switch (opType) { + case CommonTestUtils::OpType::SCALAR: { + if (axes.size() > 1) + FAIL() << "In reduce op if op type is scalar, 'axis' input's must contain 1 element"; + break; + } + case CommonTestUtils::OpType::VECTOR: { + shapeAxes.push_back(axes.size()); + break; + } + default: + FAIL() << "Reduce op doesn't support operation type: " << opType; + } + auto reductionAxesNode = std::dynamic_pointer_cast( + std::make_shared(ngraph::element::Type_t::i64, ngraph::Shape(shapeAxes), axes)); + + auto reduce = std::make_shared(paramOuts[0], reductionAxesNode, keepDims); + + std::vector constShape(reduce.get()->get_output_size(), 1); + constShape[2] = inputShape.back(); + auto constant = ngraph::builder::makeConstant(ngPrc, constShape, {}, true); + auto eltw = ngraph::builder::makeEltwise(reduce, constant, ngraph::helpers::EltwiseTypes::MULTIPLY); + ngraph::ResultVector results{std::make_shared(eltw)}; + function = std::make_shared(results, params, "ReduceEltwise"); +} +} // namespace SubgraphTestsDefinitions From 6a42b47c2f4bba88456fe39b8b203e6a33211293 Mon Sep 17 00:00:00 2001 From: Jozef Daniecki Date: Mon, 7 Jun 2021 19:12:57 +0200 Subject: [PATCH 009/178] RegionYolo operation specification refactoring. (#5926) * RegionYolo spec refactored against explicit type indication. * Improve readability. --- docs/ops/detection/RegionYolo_1.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/ops/detection/RegionYolo_1.md b/docs/ops/detection/RegionYolo_1.md index c4eece6ff8b419..ebcc79c23777cb 100644 --- a/docs/ops/detection/RegionYolo_1.md +++ b/docs/ops/detection/RegionYolo_1.md @@ -6,7 +6,7 @@ **Short description**: *RegionYolo* computes the coordinates of regions with probability for each class. -**Detailed description**: This operation is directly mapped to the original YOLO layer. [Reference](https://arxiv.org/pdf/1612.08242.pdf) +**Detailed description**: This operation is directly mapped to the [YOLO9000: Better, Faster, Stronger](https://arxiv.org/pdf/1612.08242.pdf) paper. **Attributes**: @@ -78,14 +78,17 @@ **Inputs**: -* **1**: `data` - 4D input tensor with floating point elements and shape `[N, C, H, W]`. Required. +* **1**: `data` - 4D tensor of type `T` and shape `[N, C, H, W]`. **Required.** **Outputs**: -* **1**: output tensor of rank 4 or less that codes detected regions. Refer to the original YOLO paper to decode the output as boxes. `anchors` should be used to decode real box coordinates. If `do_softmax` is set to 0, then the output shape is `[N, (classes + coords + 1)*len(mask), H, W]`. If `do_softmax` is set to 1, then output shape is partially flattened and defined in the following way: +* **1**: tensor of type `T` and rank 4 or less that codes detected regions. Refer to the [YOLO9000: Better, Faster, Stronger](https://arxiv.org/pdf/1612.08242.pdf) paper to decode the output as boxes. `anchors` should be used to decode real box coordinates. If `do_softmax` is set to `0`, then the output shape is `[N, (classes + coords + 1) * len(mask), H, W]`. If `do_softmax` is set to `1`, then output shape is partially flattened and defined in the following way: - flat_dim = data.shape[axis] * data.shape[axis+1] * ... * data.shape[end_axis] - output.shape = [data.shape[0], ..., data.shape[axis-1], flat_dim, data.shape[end_axis + 1], ...] + `flat_dim = data.shape[axis] * data.shape[axis+1] * ... * data.shape[end_axis]` + `output.shape = [data.shape[0], ..., data.shape[axis-1], flat_dim, data.shape[end_axis + 1], ...]` + +**Types** +* *T*: any supported floating point type. **Example** From 4d9fe14ec62641e7ab480d08cd70be0151aecd62 Mon Sep 17 00:00:00 2001 From: Yegor Kruglov Date: Mon, 7 Jun 2021 20:22:26 +0300 Subject: [PATCH 010/178] [MO] ConvolutionWithGroupResolver update to enable TF DepthwiseConv2dNative with in_channels=1 (#5528) * changed permutation attribute in conv extractor * changed conv get_group parameter * implemented a transformation * updated BOM * specified transformation for in_channels 1 * added unittest and comment string * updated convolution normalizer to convert depthwise convolution with group=1 to group convolution * renamed function * updated IR reader * conversations resolving * condition change --- .../extensions/back/ConvolutionNormalizer.py | 106 ++++++++---------- .../mo/utils/ir_reader/layer_to_class.py | 7 ++ .../back/ConvolutionNormalizer_test.py | 72 +++++++++++- 3 files changed, 123 insertions(+), 62 deletions(-) diff --git a/model-optimizer/extensions/back/ConvolutionNormalizer.py b/model-optimizer/extensions/back/ConvolutionNormalizer.py index 04da65631c53fa..0abfbec0e208e0 100644 --- a/model-optimizer/extensions/back/ConvolutionNormalizer.py +++ b/model-optimizer/extensions/back/ConvolutionNormalizer.py @@ -8,10 +8,43 @@ from mo.back.replacement import BackReplacementPattern from mo.front.common.partial_infer.utils import int64_array from mo.front.tf.graph_utils import create_op_node_with_second_input, create_op_with_const_inputs -from mo.graph.graph import Graph +from mo.graph.graph import Graph, Node from mo.ops.const import Const from mo.ops.reshape import Reshape from mo.ops.strided_slice import StridedSlice +from mo.utils.error import Error + + +def resolve_convolution_with_group(node: Node, group: int, ir_version: str): + input_shape = node.in_port(0).data.get_shape() + assert len(input_shape) in [3, 4, 5] + + weights_shape = node.in_port(1).data.get_shape() + assert weights_shape is not None + assert len(weights_shape) in [3, 4, 5] + assert weights_shape[0] % group == 0 + + assert int64_array(node.output).ndim == 0 + if ir_version == 'V7': + if weights_shape[0] == node.output: + # weights are already is in [G*O I X Y] format + return + new_shape = int64_array([node.output, -1, *weights_shape[2:]]) + + elif ir_version == 'V10': + I = input_shape[1] + new_shape = int64_array([group, node.output / group, I / group, *weights_shape[2:]]) + assert np.prod(weights_shape) == np.prod(new_shape), \ + 'Initial weights shape {}, grouped weights shape {}'.format(weights_shape, new_shape) + del node['group'] + node['type'] = 'GroupConvolution' + else: + raise Error("Unknown IR version: {}".format(ir_version)) + + reshape = create_op_node_with_second_input(node.graph, Reshape, int64_array(new_shape), + {'override_output_shape': True}) + + node.in_port(1).get_connection().insert_node(reshape) class ConvolutionNormalizer(BackReplacementPattern): @@ -37,33 +70,12 @@ class V7ConvolutionWithGroupsResolver(BackReplacementPattern): """ enabled = False - @staticmethod - def pattern(): - return dict( - nodes=[ - ('node', dict(type='Convolution', group=lambda g: g is not None and g != 1)) - ], - edges=[] - ) - - def replace_pattern(self, graph: Graph, match: dict): - node = match['node'] - - group = node.group - assert group > 1 - - weights_shape = node.in_port(1).data.get_shape() - assert weights_shape is not None - assert weights_shape[0] % group == 0 - - if weights_shape[0] == node.output: - # weights are already is in [G*O I X Y] format - return - - new_shape = int64_array([node.output, -1, *weights_shape[2:]]) - reshape = create_op_node_with_second_input(graph, Reshape, int64_array(new_shape), - {'override_output_shape': True}) - node.in_port(1).get_connection().insert_node(reshape) + def find_and_replace_pattern(self, graph: Graph): + for node in graph.get_op_nodes(type='Convolution'): + group = node.soft_get('group', None) + if group is not None: + if group != 1 or node.soft_get('op') == 'DepthwiseConv2dNative': + resolve_convolution_with_group(node, group, ir_version='V7') class V10ConvolutionWithGroupsResolver(BackReplacementPattern): @@ -73,38 +85,12 @@ class V10ConvolutionWithGroupsResolver(BackReplacementPattern): """ enabled = False - @staticmethod - def pattern(): - return dict( - nodes=[ - ('node', dict(type='Convolution', group=lambda g: g is not None and g != 1)) - ], - edges=[] - ) - - def replace_pattern(self, graph: Graph, match: dict): - node = match['node'] - - group = node.group - assert group > 1 - - weights_shape = node.in_port(1).data.get_shape() - assert weights_shape is not None - assert weights_shape[0] % group == 0 - I = node.in_port(0).data.get_shape()[1] - - new_shape = int64_array([group, node.output / group, I / group, *weights_shape[2:]]) - - assert np.prod(weights_shape) == np.prod(new_shape), \ - 'Initial weights shape {}, grouped weights shape {}'.format(weights_shape, new_shape) - - del node['group'] - node['type'] = 'GroupConvolution' - - reshape = create_op_node_with_second_input(graph, Reshape, int64_array(new_shape), - {'override_output_shape': True}) - - node.in_port(1).get_connection().insert_node(reshape) + def find_and_replace_pattern(self, graph: Graph): + for node in graph.get_op_nodes(type='Convolution'): + group = node.soft_get('group', None) + if group is not None: + if group != 1 or node.soft_get('op') == 'DepthwiseConv2dNative': + resolve_convolution_with_group(node, group, ir_version='V10') class ConvolutionWithGroupsResolver(BackReplacementPattern): diff --git a/model-optimizer/mo/utils/ir_reader/layer_to_class.py b/model-optimizer/mo/utils/ir_reader/layer_to_class.py index d1afed6918d7bf..f9f5fd9fb1db23 100644 --- a/model-optimizer/mo/utils/ir_reader/layer_to_class.py +++ b/model-optimizer/mo/utils/ir_reader/layer_to_class.py @@ -195,6 +195,13 @@ def groupconv_to_conv(op: Node): 'Weight shape and calculated shape mismatch in GroupConv node {}.'.format(op.name) # we need to set this attrs for correct shape infer as convolution op['group'] = group + # The only way GroupConvolution with 'group' = 1 appears in IR is by converting from TF DepthwiseConv2dNative. + # In this case we need to specify 'op' parameter for the + # extensions.back.ConvolutionNormalizer.ConvolutionWithGroupsResolver to work properly. + # Otherwise there will be 'Convolution' instead 'GroupConvolution' in restored IR, since 'GroupConvolution' is + # extended as node with 'type' = 'Convolution' by IR reader + if group == 1: + op['op'] = 'DepthwiseConv2dNative' op.type = 'Convolution' diff --git a/model-optimizer/unit_tests/extensions/back/ConvolutionNormalizer_test.py b/model-optimizer/unit_tests/extensions/back/ConvolutionNormalizer_test.py index d7a2f4809fcca2..47a7fc9ac283e2 100644 --- a/model-optimizer/unit_tests/extensions/back/ConvolutionNormalizer_test.py +++ b/model-optimizer/unit_tests/extensions/back/ConvolutionNormalizer_test.py @@ -102,7 +102,7 @@ def test_reshape_reducing_tensor_rank(self): class TestV7ConvolutionWithGroupsResolver(unittest.TestCase): def test_v7_group_convolution_resolver(self): nodes = { - **regular_op_with_shaped_data('input', None, {'type': 'Parameter'}), + **regular_op_with_shaped_data('input', [1, 3, 224, 224], {'type': 'Parameter'}), **valued_const_with_data('weights', np.ones([3, 8, 7, 7])), @@ -133,7 +133,7 @@ def test_v7_group_convolution_resolver(self): def test_v7_group_convolution_resolver_weight_are_in_the_right_layout(self): nodes = { - **regular_op_with_shaped_data('input', None, {'type': 'Parameter'}), + **regular_op_with_shaped_data('input', [1, 3, 224, 224], {'type': 'Parameter'}), **valued_const_with_data('weights', np.ones([24, 1, 7, 7])), **regular_op_with_shaped_data('convolution', None, {'type': 'Convolution', 'group': 3, 'output': 24}), **result(), @@ -149,6 +149,38 @@ def test_v7_group_convolution_resolver_weight_are_in_the_right_layout(self): (flag, resp) = compare_graphs(graph, graph_ref, last_node='output', check_op_attrs=True) self.assertTrue(flag, resp) + def test_v7_group_convolution_resolver_depthwise_conv2d(self): + nodes = { + **regular_op_with_shaped_data('input', [1, 1, 224, 224], {'type': 'Parameter'}), + + **valued_const_with_data('weights', np.ones([1, 8, 7, 7])), + + **valued_const_with_data('dim', int64_array([8, -1, 7, 7])), + **regular_op_with_empty_data('reshape', {'type': 'Reshape'}), + + **regular_op_with_shaped_data('convolution', None, {'type': 'Convolution', 'group': 1, 'output': 8, + 'op': 'DepthwiseConv2dNative'}), + + **result(), + } + graph = build_graph(nodes, [ + *connect('input', '0:convolution'), + *connect('weights', '1:convolution'), + *connect('convolution', 'output'), + ], nodes_with_edges_only=True) + + V7ConvolutionWithGroupsResolver().find_and_replace_pattern(graph) + graph_ref = build_graph(nodes, [ + *connect('input', '0:convolution'), + *connect('weights', '0:reshape'), + *connect('dim', '1:reshape'), + *connect('reshape', '1:convolution'), + *connect('convolution', 'output'), + ], nodes_with_edges_only=True) + + (flag, resp) = compare_graphs(graph, graph_ref, last_node='output', check_op_attrs=True) + self.assertTrue(flag, resp) + class TestV10ConvolutionWithGroupsResolver(unittest.TestCase): def test_v10_group_convolution_resolver(self): @@ -185,3 +217,39 @@ def test_v10_group_convolution_resolver(self): (flag, resp) = compare_graphs(graph, graph_ref, last_node='output', check_op_attrs=True) self.assertTrue(flag, resp) + + def test_v10_group_convolution_resolver_depthwise_conv2d(self): + nodes = { + **regular_op_with_shaped_data('input', [1, 1, 224, 224], {'type': 'Parameter'}), + + **valued_const_with_data('weights', np.ones([1, 8, 7, 7])), + + **valued_const_with_data('dim', int64_array([1, 8, 1, 7, 7])), + **regular_op_with_empty_data('reshape', {'type': 'Reshape'}), + + **regular_op_with_shaped_data('convolution', None, {'type': 'Convolution', 'group': 1, 'output': 8, + 'op': 'DepthwiseConv2dNative'}), + + **result(), + } + graph = build_graph(nodes, [ + *connect('input', '0:convolution'), + *connect('weights', '1:convolution'), + *connect('convolution', 'output'), + ], nodes_with_edges_only=True) + + V10ConvolutionWithGroupsResolver().find_and_replace_pattern(graph) + + nodes['convolution']['type'] = 'GroupConvolution' + del nodes['convolution']['group'] + + graph_ref = build_graph(nodes, [ + *connect('input', '0:convolution'), + *connect('weights', '0:reshape'), + *connect('dim', '1:reshape'), + *connect('reshape', '1:convolution'), + *connect('convolution', 'output'), + ], nodes_with_edges_only=True) + + (flag, resp) = compare_graphs(graph, graph_ref, last_node='output', check_op_attrs=True) + self.assertTrue(flag, resp) From bc7f61be241544c14d82d2b66c83174bf5a13281 Mon Sep 17 00:00:00 2001 From: Katarzyna Mitrus Date: Tue, 8 Jun 2021 05:51:41 +0200 Subject: [PATCH 011/178] PRelu reference implementation and ReshapePRelu transformation alignment (#5915) * Apply ReshapePRelu transformation only to const slope input * Remove xfail from onnx backend prelu_broadcast test * Fix and add Prelu SLT * Update PRelu mkldnn transformation to extend broadcast support * Fix and update PRelu reference implementation * ONNX Prelu tests * Add prelu backend tests * Update ie tests manifest * Comments clean up * Fix STL Fill leakyslope blob * Code refactor * Unify layer tests slope input values generation --- .../ngraph_transformations/reshape_prelu.cpp | 12 +- .../single_layer_tests/activation.cpp | 28 +- .../skip_tests_config.cpp | 2 - .../single_layer/activation.hpp | 4 +- .../src/single_layer/activation.cpp | 92 +- .../ngraph/runtime/reference/prelu.hpp | 17 +- ngraph/python/tests/__init__.py | 2 - ngraph/python/tests/test_onnx/test_backend.py | 5 +- ngraph/test/CMakeLists.txt | 1 + ngraph/test/backend/fused_op.in.cpp | 49 - ngraph/test/backend/prelu.in.cpp | 942 ++++++++++++++++++ ngraph/test/models/onnx/prelu_1d.prototxt | 72 ++ .../test/models/onnx/prelu_batch_nd.prototxt | 81 ++ ngraph/test/models/onnx/prelu_c_1_1.prototxt | 78 ++ ngraph/test/onnx/onnx_import.in.cpp | 125 ++- ngraph/test/runtime/ie/unit_test.manifest | 3 - 16 files changed, 1362 insertions(+), 151 deletions(-) create mode 100644 ngraph/test/backend/prelu.in.cpp create mode 100644 ngraph/test/models/onnx/prelu_1d.prototxt create mode 100644 ngraph/test/models/onnx/prelu_batch_nd.prototxt create mode 100644 ngraph/test/models/onnx/prelu_c_1_1.prototxt diff --git a/inference-engine/src/mkldnn_plugin/ngraph_transformations/reshape_prelu.cpp b/inference-engine/src/mkldnn_plugin/ngraph_transformations/reshape_prelu.cpp index 0cc1a33cbc3283..69fd75ea57a661 100644 --- a/inference-engine/src/mkldnn_plugin/ngraph_transformations/reshape_prelu.cpp +++ b/inference-engine/src/mkldnn_plugin/ngraph_transformations/reshape_prelu.cpp @@ -20,8 +20,16 @@ MKLDNNPlugin::ReshapePRelu::ReshapePRelu() { if (!prelu || ngraph::shape_size(prelu->get_input_shape(1)) == 1 || prelu->get_input_shape(1).size() != 1) { return false; } - ngraph::Shape new_shape(prelu->input_value(0).get_shape().size(), 1); - new_shape[new_shape.size() > 1 ? 1 : 0] = prelu->input_value(1).get_shape()[0]; + const auto prelu_shape = prelu->input_value(0).get_shape(); + const auto slope_shape = prelu->input_value(1).get_shape(); + ngraph::Shape new_shape(prelu_shape.size(), 1); + const auto slope_dim = slope_shape[0]; + const auto channel_dim_idx = prelu_shape.size() > 1 ? 1 : 0; + if (slope_dim != prelu_shape[channel_dim_idx]) { + return false; + } + new_shape[channel_dim_idx] = slope_dim; + auto slope = ngraph::op::util::reshapeTo(prelu->input_value(1), new_shape); auto new_prelu = std::make_shared(prelu->input(0).get_source_output(), slope); new_prelu->set_friendly_name(prelu->get_friendly_name()); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp index 76607e55f76b91..6e762ed562c004 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp @@ -69,8 +69,8 @@ const std::map>> intActivationTy }; const std::map>> activationParamTypes = { - {PReLu, {{-0.01f}}}, - {LeakyRelu, {{0.01f}}} + {PReLu, {{}}}, // Slope will be filled with increasing values from -10 to match slope input shape + {LeakyRelu, {{0.01f}}} }; std::map, std::vector>> basic = { @@ -81,16 +81,12 @@ std::map, std::vector>> basic = { std::map, std::vector>> preluBasic = { {{1, 50}, {{1}, {50}}}, {{1, 128}, {{1}, {128}}}, - {{20, 128}, {{128}}}, - {{1, 20, 128}, {{1}, {20}}}, - {{1, 20, 128, 128}, {{1}, {20}}}, - {{1, 20, 20, 128, 128}, {{1}, {20}}} - // according to spec second input for PRelu must be 1D and must be broadcastabe per channel - // at this moment these cases unsupported - // {{20, 128}, {{20}, {20, 128}}}, - // {{1, 20, 128}, {{128}, {20, 128}}}, - // {{1, 20, 128, 128}, {{128}, {128, 128}, {20, 128, 128}}}, - // {{1, 20, 20, 128, 128}, {{128}, {128, 128}, {20, 128, 128}, {20, 20, 128, 128}}}, + + // Broadcast check + {{3, 2}, {{1}, {2}, {3, 2}}}, + {{3, 2, 5}, {{1}, {2}, {5}, {2, 5}, {3, 1, 5}, {1, 2, 1}, {1, 1, 5}, {3, 1, 1}, {3, 2, 5}}}, + {{2, 1, 2}, {{2}, {2, 1, 1}}}, + {{3, 2, 5, 7}, {{1}, {7}, {2}, {5, 7}, {2, 5, 7}, {2, 1, 1}, {1, 2, 1, 1}, {3, 2, 1, 1}, {3, 2, 5, 7}}}, }; const auto basicCases = ::testing::Combine( @@ -127,11 +123,9 @@ const auto basicIntegerOperations = ::testing::Combine( ); INSTANTIATE_TEST_CASE_P(smoke_Activation_Basic, ActivationLayerTest, basicCases, ActivationLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Integer_Activation_Basic, ActivationLayerTest, basicIntegerOperations, ActivationLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Activation_Basic_Prelu, ActivationLayerTest, basicPreluCases, ActivationLayerTest::getTestCaseName); - -INSTANTIATE_TEST_CASE_P(smoke_Activation_Basic, ActivationParamLayerTest, basicPreluCases, ActivationLayerTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Activation_Basic, ActivationDynamicLayerTest, basicCases, ActivationLayerTest::getTestCaseName); +INSTANTIATE_TEST_CASE_P(smoke_Integer_Activation_Basic, ActivationLayerTest, basicIntegerOperations, ActivationLayerTest::getTestCaseName); +INSTANTIATE_TEST_CASE_P(smoke_Activation_Basic_Prelu_Const, ActivationLayerTest, basicPreluCases, ActivationLayerTest::getTestCaseName); +INSTANTIATE_TEST_CASE_P(smoke_Activation_Basic_Prelu_Param, ActivationParamLayerTest, basicPreluCases, ActivationLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp index f59f8d954e0f29..b3134e9953e9e5 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp @@ -35,8 +35,6 @@ std::vector disabledTestPatterns() { R"(.*ReluShapeOfSubgraphTest.*)", // TODO: Issue: 34805 R"(.*ActivationLayerTest.*Ceiling.*)", - // TODO: Issue: 32032 - R"(.*ActivationParamLayerTest.*)", // TODO: Issue: 43314 R"(.*Broadcast.*mode=BIDIRECTIONAL.*inNPrec=BOOL.*)", // TODO: Issue 43417 sporadic issue, looks like an issue in test, reproducible only on Windows platform diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/activation.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/activation.hpp index bdf996cd141065..684942ee184653 100644 --- a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/activation.hpp +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/activation.hpp @@ -96,13 +96,11 @@ class ActivationLayerTest : public testing::WithParamInterface }; class ActivationParamLayerTest : public ActivationLayerTest { -public: - void Infer() override; - protected: void SetUp() override; private: + InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override; void generateActivationBlob(std::vector constantsValue); ngraph::ParameterVector createActivationParams( ngraph::element::Type ngPrc, std::vector inShape = {}); diff --git a/inference-engine/tests/functional/shared_test_classes/src/single_layer/activation.cpp b/inference-engine/tests/functional/shared_test_classes/src/single_layer/activation.cpp index 3136c604e7d9ab..5b90cfc2079dd6 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/single_layer/activation.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/single_layer/activation.cpp @@ -41,6 +41,13 @@ void ActivationLayerTest::SetUp() { auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); auto params = ngraph::builder::makeParams(ngPrc, {shapes.first}); params[0]->set_friendly_name("Input"); + + if (activationType == ngraph::helpers::ActivationTypes::PReLu && constantsValue.empty()) { + const auto elemnts_count = ngraph::shape_size(shapes.second); + constantsValue.resize(elemnts_count); + std::iota(constantsValue.begin(), constantsValue.end(), -10); + } + auto activation = ngraph::builder::makeActivation(params[0], ngPrc, activationType, shapes.second, constantsValue); function = std::make_shared(ngraph::NodeVector{activation}, params); @@ -163,70 +170,26 @@ ngraph::ParameterVector ActivationParamLayerTest::createActivationParams(ngraph: } } -void ActivationParamLayerTest::generateActivationBlob(std::vector constantsValue) { - switch (activationType) { - case ngraph::helpers::ActivationTypes::PReLu: { - auto blobNegativeSlope = inferRequest.GetBlob("negativeSlope"); - float negativeSlope = constantsValue[0]; - blobNegativeSlope = FuncTestUtils::createAndFillBlobWithFloatArray(blobNegativeSlope->getTensorDesc(), &negativeSlope, 1); - inferRequest.SetBlob("negativeSlope", blobNegativeSlope); - inputs.push_back(blobNegativeSlope); - break; - } - case ngraph::helpers::ActivationTypes::LeakyRelu: { - auto blobLeakySlope = inferRequest.GetBlob("leakySlope"); - float leakySlope = constantsValue[0]; - blobLeakySlope = FuncTestUtils::createAndFillBlobWithFloatArray(blobLeakySlope->getTensorDesc(), &leakySlope, 1); - inferRequest.SetBlob("leakySlope", blobLeakySlope); - inputs.push_back(blobLeakySlope); - break; - } - case ngraph::helpers::ActivationTypes::HardSigmoid: { - auto blobHardSigmoidAlpha = inferRequest.GetBlob("alpha"); - auto blobHardSigmoidBeta = inferRequest.GetBlob("beta"); - float alpha = constantsValue[0], beta = constantsValue[1]; - blobHardSigmoidAlpha = FuncTestUtils::createAndFillBlobWithFloatArray(blobHardSigmoidAlpha->getTensorDesc(), &alpha, 1); - blobHardSigmoidBeta = FuncTestUtils::createAndFillBlobWithFloatArray(blobHardSigmoidBeta->getTensorDesc(), &beta, 1); - inferRequest.SetBlob("alpha", blobHardSigmoidAlpha); - inferRequest.SetBlob("beta", blobHardSigmoidBeta); - inputs.push_back(blobHardSigmoidAlpha); - inputs.push_back(blobHardSigmoidBeta); - break; - } - case ngraph::helpers::ActivationTypes::Selu: { - auto blobHardSigmoidAlpha = inferRequest.GetBlob("alpha"); - auto blobHardSigmoidLambda = inferRequest.GetBlob("lambda"); - float alpha = constantsValue[0], lambda = constantsValue[1]; - blobHardSigmoidAlpha = FuncTestUtils::createAndFillBlobWithFloatArray(blobHardSigmoidAlpha->getTensorDesc(), &alpha, 1); - blobHardSigmoidLambda = FuncTestUtils::createAndFillBlobWithFloatArray(blobHardSigmoidLambda->getTensorDesc(), &lambda, 1); - inferRequest.SetBlob("alpha", blobHardSigmoidAlpha); - inferRequest.SetBlob("lambda", blobHardSigmoidLambda); - inputs.push_back(blobHardSigmoidAlpha); - inputs.push_back(blobHardSigmoidLambda); - break; - } - default: - IE_THROW() << "Unsupported activation type for Params test type"; - } -} - -void ActivationParamLayerTest::Infer() { - inferRequest = executableNetwork.CreateInferRequest(); - - auto blobInput = inferRequest.GetBlob("Input"); - blobInput = FuncTestUtils::createAndFillBlobFloat(blobInput->getTensorDesc()); - inferRequest.SetBlob("Input", blobInput); - inputs.push_back(blobInput); - - generateActivationBlob(constantsValue); - - if (configuration.count(InferenceEngine::PluginConfigParams::KEY_DYN_BATCH_ENABLED) && - configuration.count(InferenceEngine::PluginConfigParams::YES)) { - auto batchSize = executableNetwork.GetInputsInfo().begin()->second->getTensorDesc().getDims()[0] / 2; - inferRequest.SetBatch(batchSize); +InferenceEngine::Blob::Ptr ActivationParamLayerTest::GenerateInput(const InferenceEngine::InputInfo &info) const { + InferenceEngine::Blob::Ptr blobPtr; + const std::string& name = info.name(); + if (name == "negativeSlope") { + const auto elemnts_count = ngraph::shape_size(function->get_parameters()[1]->get_shape()); + std::vector param_data(elemnts_count); + std::iota(param_data.begin(), param_data.end(), -10); + blobPtr = FuncTestUtils::createAndFillBlobWithFloatArray(info.getTensorDesc(), ¶m_data[0], elemnts_count); + } else if (name == "leakySlope") { + const auto elemnts_count = ngraph::shape_size(function->get_parameters()[1]->get_shape()); + std::vector param_data(elemnts_count, constantsValue[0]); + blobPtr = FuncTestUtils::createAndFillBlobWithFloatArray(info.getTensorDesc(), ¶m_data[0], elemnts_count); + } else if (name == "alpha") { + blobPtr = FuncTestUtils::createAndFillBlobWithFloatArray(info.getTensorDesc(), &constantsValue[0], 1); + } else if (name == "beta" || name == "lambda") { + blobPtr = FuncTestUtils::createAndFillBlobWithFloatArray(info.getTensorDesc(), &constantsValue[1], 1); + } else { + blobPtr = FuncTestUtils::createAndFillBlob(info.getTensorDesc(), 20, -10, 1); } - - inferRequest.Infer(); + return blobPtr; } void ActivationParamLayerTest::SetUp() { @@ -245,7 +208,8 @@ void ActivationParamLayerTest::SetUp() { params.insert(params.end(), activationParams.begin(), activationParams.end()); auto activation = ngraph::builder::makeActivation(params, ngPrc, activationType); - function = std::make_shared(ngraph::NodeVector{activation}, params); + ngraph::ResultVector results{std::make_shared(activation)}; + function = std::make_shared(results, params); } void ActivationDynamicLayerTest::Run() { diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/prelu.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/prelu.hpp index 34a420399ac620..d546bbd79af87e 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/prelu.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/prelu.hpp @@ -24,12 +24,21 @@ namespace ngraph const Shape& arg_shape, const Shape& slope_shape) { - int cnt = 0; - for (size_t i = 0; i < shape_size(arg_shape); ++i) + Shape slope_shape_tmp = slope_shape; + const auto channel_dim_idx = arg_shape.size() > 1 ? 1 : 0; + if (slope_shape.size() == 1 && arg_shape[channel_dim_idx] == slope_shape[0]) { - out[i] = - arg[i] < T(0) ? T(arg[i] * slope[cnt++ % shape_size(slope_shape)]) : arg[i]; + Shape channel_slope_shape(arg_shape.size(), 1); + channel_slope_shape[channel_dim_idx] = slope_shape[0]; + std::swap(slope_shape_tmp, channel_slope_shape); } + autobroadcast_binop(arg, + slope, + out, + arg_shape, + slope_shape_tmp, + ngraph::op::AutoBroadcastType::NUMPY, + [](T x, T y) -> T { return x < T(0) ? T(x * y) : x; }); } } // namespace reference } // namespace runtime diff --git a/ngraph/python/tests/__init__.py b/ngraph/python/tests/__init__.py index 930be465a632d3..c179f312f1e7e8 100644 --- a/ngraph/python/tests/__init__.py +++ b/ngraph/python/tests/__init__.py @@ -110,8 +110,6 @@ def xfail_test(reason="Mark the test as expected to fail", strict=True): xfail_issue_47323 = xfail_test(reason="RuntimeError: The plugin does not support FP64") xfail_issue_47337 = xfail_test(reason="RuntimeError: Unsupported dynamic ops: v1::OneHot") xfail_issue_33593 = xfail_test(reason="Current implementation of MaxPool doesn't support indices output") -xfail_issue_51993 = xfail_test(reason="PRelu supports only 1D tensor for 'slope' input broadcasted" - "by channel") xfail_issue_55760 = xfail_test(reason="RuntimeError: Reversed axis have axes above the source space shape") # Model MSFT issues: diff --git a/ngraph/python/tests/test_onnx/test_backend.py b/ngraph/python/tests/test_onnx/test_backend.py index d411919e97785e..a8ee1cbb065c6e 100644 --- a/ngraph/python/tests/test_onnx/test_backend.py +++ b/ngraph/python/tests/test_onnx/test_backend.py @@ -59,7 +59,6 @@ xfail_issue_49753, xfail_issue_49754, xfail_issue_52463, - xfail_issue_51993, xfail_issue_55760) @@ -369,9 +368,7 @@ def expect_fail(test_case_path, xfail): # type: (str) -> None "OnnxBackendNodeModelTest.test_quantizelinear_cpu"), (xfail_issue_33593, "OnnxBackendNodeModelTest.test_maxpool_with_argmax_2d_precomputed_strides_cpu", - "OnnxBackendNodeModelTest.test_maxpool_with_argmax_2d_precomputed_pads_cpu",), - (xfail_issue_51993, - "OnnxBackendNodeModelTest.test_prelu_broadcast_cpu",) + "OnnxBackendNodeModelTest.test_maxpool_with_argmax_2d_precomputed_pads_cpu",) ] for test_group in tests_expected_to_fail: diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index 52148150e81562..ba3c6a9d052b80 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -399,6 +399,7 @@ set(MULTI_TEST_SRC backend/pad.in.cpp backend/parameter_as_output.in.cpp backend/power.in.cpp + backend/prelu.in.cpp backend/proposal.in.cpp backend/psroi_pooling.in.cpp backend/range.in.cpp diff --git a/ngraph/test/backend/fused_op.in.cpp b/ngraph/test/backend/fused_op.in.cpp index 74117a7fb9f69b..4b6bb15cb5171f 100644 --- a/ngraph/test/backend/fused_op.in.cpp +++ b/ngraph/test/backend/fused_op.in.cpp @@ -41,22 +41,6 @@ static string s_manifest = "${MANIFEST}"; using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); -NGRAPH_TEST(${BACKEND_NAME}, prelu) -{ - Shape shape{3, 2}; - Shape rshape{3}; - auto A = make_shared(element::f32, shape); - auto B = make_shared(element::f32, rshape); - auto prelu = make_shared(A, B); - auto f = make_shared(NodeVector{prelu}, ParameterVector{A, B}); - std::vector a{-2, 3, -2, 1, -1, 0}; - std::vector b{0, 0.5, 1}; - - auto test_case = test::TestCase(f); - test_case.add_multiple_inputs({a, b}); - test_case.add_expected_output(vector{0, 3, -1, 1, -1, 0}); - test_case.run(); -} NGRAPH_TEST(${BACKEND_NAME}, hardsigmoid) { @@ -94,39 +78,6 @@ NGRAPH_TEST(${BACKEND_NAME}, hardsigmoid) test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, prelu_shared_slope) -{ - Shape shape{3, 2}; - Shape rshape{}; - auto A = make_shared(element::f32, shape); - auto B = make_shared(element::f32, rshape); - auto prelu = make_shared(A, B); - auto f = make_shared(NodeVector{prelu}, ParameterVector{A, B}); - std::vector a{-2, 3, -2, 1, -1, 0}; - std::vector b{0.5}; - - auto test_case = test::TestCase(f); - test_case.add_multiple_inputs({a, b}); - test_case.add_expected_output(vector{-1, 3, -1, 1, -0.5, 0}); - test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, prelu_negative_slope) -{ - Shape shape{3, 2}; - Shape rshape{}; - auto A = make_shared(element::f32, shape); - auto B = make_shared(element::f32, rshape); - auto prelu = make_shared(A, B); - auto f = make_shared(NodeVector{prelu}, ParameterVector{A, B}); - std::vector a{-2, 3, -2, 1, -1, 0}; - std::vector b{-0.5}; - - auto test_case = test::TestCase(f); - test_case.add_multiple_inputs({a, b}); - test_case.add_expected_output(vector{1, 3, 1, 1, 0.5, 0}); - test_case.run(); -} NGRAPH_TEST(${BACKEND_NAME}, space_to_depth_block_first) { diff --git a/ngraph/test/backend/prelu.in.cpp b/ngraph/test/backend/prelu.in.cpp new file mode 100644 index 00000000000000..8523aeb39c3568 --- /dev/null +++ b/ngraph/test/backend/prelu.in.cpp @@ -0,0 +1,942 @@ +// Co pyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "util/engine/test_engines.hpp" +#include "util/test_case.hpp" +#include "util/test_control.hpp" + +using namespace std; +using namespace ngraph; + +static string s_manifest = "${MANIFEST}"; +using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); + +NGRAPH_TEST(${BACKEND_NAME}, prelu_1d_1_param) +{ + Shape shape_a{6}; + Shape shape_slope{1}; + + std::vector a{1, 2, -3, -4, 5, 6}; + std::vector slope{2}; + std::vector out{1, 2, -6, -8, 5, 6}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A, SLOPE}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a, slope}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_1d_1_const) +{ + Shape shape_a{6}; + Shape shape_slope{1}; + + std::vector a{1, 2, -3, -4, 5, 6}; + std::vector slope{2}; + std::vector out{1, 2, -6, -8, 5, 6}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope, slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_1d_param) +{ + Shape shape_a{6}; + Shape shape_slope{6}; + + std::vector a{1, 2, -3, -4, 5, 6}; + std::vector slope{2, 3, 4, 5, 6, 7}; + std::vector out{1, 2, -12, -20, 5, 6}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A, SLOPE}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a, slope}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_1d_6_const) +{ + Shape shape_a{6}; + Shape shape_slope{6}; + + std::vector a{1, 2, -3, -4, 5, 6}; + std::vector slope{2, 3, 4, 5, 6, 7}; + std::vector out{1, 2, -12, -20, 5, 6}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope, slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_2d_2_W_param) +{ + Shape shape_a{3, 2}; + Shape shape_slope{2}; + + std::vector a{-2, 3, -2, 1, -1, 0}; + std::vector slope{0, 1}; + std::vector out{0, 3, 0, 1, 0, 0}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A, SLOPE}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a, slope}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_2d_2_W_const) +{ + Shape shape_a{3, 2}; + Shape shape_slope{2}; + + std::vector a{-2, 3, -2, 1, -1, 0}; + std::vector slope{0, 1}; + std::vector out{0, 3, 0, 1, 0, 0}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope, slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_2d_6_W_param) +{ + Shape shape_a{2, 6}; + Shape shape_slope{6}; + + std::vector a{1, 2, -3, -4, 5, 6, + 7, 8, -9, -10, 11, 12}; + std::vector slope{1, 2, 3, 4, 5, 6}; + std::vector out{1, 2, -9, -16, 5, 6, + 7, 8, -27, -40, 11, 12}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A, SLOPE}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a, slope}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_2d_6_W_const) +{ + Shape shape_a{2, 6}; + Shape shape_slope{6}; + + std::vector a{1, 2, -3, -4, 5, 6, + 7, 8, -9, -10, 11, 12}; + std::vector slope{1, 2, 3, 4, 5, 6}; + std::vector out{1, 2, -9, -16, 5, 6, + 7, 8, -27, -40, 11, 12}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope, slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_2d_C_2_param) +{ + Shape shape_a{3, 2}; + Shape shape_slope{2}; + + std::vector a{-1, -1, -1, -1, -1, -1}; + std::vector slope{2, 0.5}; + std::vector out{-2, -0.5, -2, -0.5, -2, -0.5}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A, SLOPE}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a, slope}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_2d_C_2_const) +{ + Shape shape_a{3, 2}; + Shape shape_slope{2}; + + std::vector a{-1, -1, -1, -1, -1, -1}; + std::vector slope{2, 0.5}; + std::vector out{-2, -0.5, -2, -0.5, -2, -0.5}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope, slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_negative_equal_dims_slope_param) +{ + Shape shape_a{2, 2, 2}; + Shape shape_slope{2}; + + std::vector a{-0.5, -2, -3, -4, -5, -6, -7, -8}; + std::vector slope{-0.5, -2}; + // std::vector out{0.25, 4, 1.5, 8, 2.5, 12, 3.5, 16}; // broadcast (1, 1, 2) + std::vector out{0.25, 1, 6, 8, 2.5, 3, 14, 16}; // broadcast (1, 2, 1) + // std::vector out{0.25, 1, 1.5, 2, 10, 12, 14, 16}; // broadcast (2, 1, 1) + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A, SLOPE}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a, slope}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_negative_equal_dims_slope_const) +{ + Shape shape_a{2, 2, 2}; + Shape shape_slope{2}; + + std::vector a{-0.5, -2, -3, -4, -5, -6, -7, -8}; + std::vector slope{-0.5, -2}; + // std::vector out{0.25, 4, 1.5, 8, 2.5, 12, 3.5, 16}; // broadcast (1, 1, 2) + std::vector out{0.25, 1, 6, 8, 2.5, 3, 14, 16}; // broadcast (1, 2, 1) + // std::vector out{0.25, 1, 1.5, 2, 10, 12, 14, 16}; // broadcast (2, 1, 1) + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope, slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_negative_slope_param) +{ + Shape shape_a{3, 2}; + Shape shape_slope{2}; + + std::vector a{-2, 3, -2, 1, -1, 0}; + std::vector slope{-0.5, -1}; + std::vector out{1, 3, 1, 1, 0.5, 0}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A, SLOPE}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a, slope}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_negative_slope_const) +{ + Shape shape_a{3, 2}; + Shape shape_slope{2}; + + std::vector a{-2, 3, -2, 1, -1, 0}; + std::vector slope{-0.5, -1}; + std::vector out{1, 3, 1, 1, 0.5, 0}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope, slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_2d_same_shape_param) +{ + Shape shape_a{2, 6}; + Shape shape_slope{2, 6}; + + std::vector a{1, 2, -3, -4, 5, 6, + 1, 2, -3, -4, 5, 6}; + std::vector slope{2, 2, 2, 2, 2, 2, + 1, 1, 4, 2, 1, 1}; + std::vector out{1, 2, -6, -8, 5, 6, 1, 2, -12, -8, 5, 6}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A, SLOPE}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a, slope}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_2d_same_shape_const) +{ + Shape shape_a{2, 6}; + Shape shape_slope{2, 6}; + + std::vector a{1, 2, -3, -4, 5, 6, + 1, 2, -3, -4, 5, 6}; + std::vector slope{2, 2, 2, 2, 2, 2, + 1, 1, 4, 2, 1, 1}; + std::vector out{1, 2, -6, -8, 5, 6, 1, 2, -12, -8, 5, 6}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope, slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_C_1_W_slope_param) +{ + Shape shape_a{2, 2, 2, 2}; + Shape shape_slope{2, 1, 2}; + + std::vector a{1, 2, -3, -4, 1, 2, -3, -4, 1, 2, -3, -4, 1, 2, -3, -4}; + std::vector slope{1, 2, 3, 4}; + std::vector out{1, 2, -3, -8, 1, 2, -9, -16, 1, 2, -3, -8, 1, 2, -9, -16}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A, SLOPE}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a, slope}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_C_1_W_slope_const) +{ + Shape shape_a{2, 2, 2, 2}; + Shape shape_slope{2, 1, 2}; + + std::vector a{1, 2, -3, -4, 1, 2, -3, -4, 1, 2, -3, -4, 1, 2, -3, -4}; + std::vector slope{1, 2, 3, 4}; + std::vector out{1, 2, -3, -8, 1, 2, -9, -16, 1, 2, -3, -8, 1, 2, -9, -16}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope, slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_4d_slope_1_C_1_W_param) +{ + Shape shape_a{2, 2, 2, 2}; + Shape shape_slope{1, 2, 1, 2}; + + std::vector a{1, 2, -3, -4, 1, 2, -3, -4, 1, 2, -3, -4, 1, 2, -3, -4}; + std::vector slope{1, 2, 3, 4}; + std::vector out{1, 2, -3, -8, 1, 2, -9, -16, 1, 2, -3, -8, 1, 2, -9, -16}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A, SLOPE}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a, slope}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_4d_slope_1_C_1_W_const) +{ + Shape shape_a{2, 2, 2, 2}; + Shape shape_slope{1, 2, 1, 2}; + + std::vector a{1, 2, -3, -4, 1, 2, -3, -4, 1, 2, -3, -4, 1, 2, -3, -4}; + std::vector slope{1, 2, 3, 4}; + std::vector out{1, 2, -3, -8, 1, 2, -9, -16, 1, 2, -3, -8, 1, 2, -9, -16}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope, slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_3d_W_param) +{ + Shape shape_a{2, 2, 6}; + Shape shape_slope{2, 1, 6}; + + + std::vector a{1, 2, -3, -4, -5, 6, + -1, -2, -3, -4, -5, -6, + 1, 2, -3, -4, 5, 6, + -2, 4, -6, -8, 10, 12}; + std::vector slope{2, 1, 3, 4, 1, 7, + 1, 2, 3, 4, 5, 6}; + std::vector out{1, 2, -9, -16, -5, 6, + -2, -2, -9, -16, -5, -42, + 1, 2, -9, -16, 5, 6, + -2, 4, -18, -32, 10, 12}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A, SLOPE}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a, slope}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_3d_W_const) +{ + Shape shape_a{2, 2, 6}; + Shape shape_slope{2, 1, 6}; + + std::vector a{1, 2, -3, -4, -5, 6, + -1, -2, -3, -4, -5, -6, + 1, 2, -3, -4, 5, 6, + -2, 4, -6, -8, 10, 12}; + std::vector slope{2, 1, 3, 4, 1, 7, + 1, 2, 3, 4, 5, 6}; + std::vector out{1, 2, -9, -16, -5, 6, + -2, -2, -9, -16, -5, -42, + 1, 2, -9, -16, 5, 6, + -2, 4, -18, -32, 10, 12}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope, slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_3d_same_shape_param) +{ + Shape shape_a{2, 3, 2}; + Shape shape_slope{2, 3, 2}; + + std::vector a{1, 2, -3, -4, -5, 6, + -1, -2, -3, -4,-5, -6,}; + std::vector slope{2, 1, 3, 4, 1, 7, + 1, 2, 3, 4, 5, 6}; + std::vector out{1, 2, -9, -16, -5, 6, + -1, -4, -9, -16, -25, -36}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A, SLOPE}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a, slope}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_3d_same_shape_const) +{ + Shape shape_a{2, 3, 2}; + Shape shape_slope{2, 3, 2}; + + std::vector a{1, 2, -3, -4, -5, 6, + -1, -2, -3, -4,-5, -6,}; + std::vector slope{2, 1, 3, 4, 1, 7, + 1, 2, 3, 4, 5, 6}; + std::vector out{1, 2, -9, -16, -5, 6, + -1, -4, -9, -16, -25, -36}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope, slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_3d_broadcast_C_W_slope_param) +{ + Shape shape_a{2, 1, 2}; + Shape shape_slope{2}; + + std::vector a{-10, -10, -10, -10}; + std::vector slope{0.1, 10}; + std::vector out{-1, -100, -1, -100}; // broadcast (1, 2, 1) + // std::vector out{-1, -1, -100, -100}; // broadcast (2, 1, 1) + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A, SLOPE}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a, slope}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + + +NGRAPH_TEST(${BACKEND_NAME}, prelu_3d_broadcast_C_W_slope_const) +{ + Shape shape_a{2, 1, 2}; + Shape shape_slope{2}; + + std::vector a{-10, -10, -10, -10}; + std::vector slope{0.1, 10}; + std::vector out{-1, -100, -1, -100}; // broadcast (1, 2, 1) + // std::vector out{-1, -1, -100, -100}; // broadcast (2, 1, 1) + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope, slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_4d_broadcast_C_W_slope_param) +{ + Shape shape_a{1, 2, 1, 2}; + Shape shape_slope{2}; + + std::vector a{-10, -10, -10, -10}; + std::vector slope{0.1, 10}; + // std::vector out{-1, -100, -1, -100}; // broadcast (1, 1, 1, 2) + std::vector out{-1, -1, -100, -100}; // broadcast (1, 2, 1, 1) + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A, SLOPE}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a, slope}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_4d_broadcast_C_W_slope_const) +{ + Shape shape_a{1, 2, 1, 2}; + Shape shape_slope{2}; + + std::vector a{-10, -10, -10, -10}; + std::vector slope{0.1, 10}; + // std::vector out{-1, -100, -1, -100}; // broadcast (1, 1, 1, 2) + std::vector out{-1, -1, -100, -100}; // broadcast (1, 2, 1, 1) + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope, slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_4d_broadcast_C_slope_param) +{ + Shape shape_a{1, 5, 1, 1}; + Shape shape_slope{5}; + + std::vector a{-1, 0, -1, -1, -1}; + std::vector slope{1, 2, 3, 4, 5}; + std::vector out{-1, 0, -3, -4, -5}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A, SLOPE}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a, slope}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_4d_broadcast_C_slope_const) +{ + Shape shape_a{1, 5, 1, 1}; + Shape shape_slope{5}; + + std::vector a{-1, 0, -1, -1, -1}; + std::vector slope{1, 2, 3, 4, 5}; + std::vector out{-1, 0, -3, -4, -5}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope, slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_batch_nd_elementwise_param) +{ + Shape shape_a{2, 3, 4, 5}; + Shape shape_slope{2, 3, 4, 5}; + + std::vector a{-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1.}; + std::vector slope(shape_size(shape_slope)); + std::iota(std::begin(slope), std::end(slope), 0); + + std::vector out{-0., -1., -2., -3., -4., -5., -6., -7., -8., + -9., -10., -11., -12., -13., -14., -15., -16., -17., + -18., -19., -20., -21., -22., -23., -24., -25., -26., + -27., -28., -29., -30., -31., -32., -33., -34., -35., + -36., -37., -38., -39., -40., -41., -42., -43., -44., + -45., -46., -47., -48., -49., -50., -51., -52., -53., + -54., -55., -56., -57., -58., -59., -60., -61., -62., + -63., -64., -65., -66., -67., -68., -69., -70., -71., + -72., -73., -74., -75., -76., -77., -78., -79., -80., + -81., -82., -83., -84., -85., -86., -87., -88., -89., + -90., -91., -92., -93., -94., -95., -96., -97., -98., + -99., -100., -101., -102., -103., -104., -105., -106., -107., + -108., -109., -110., -111., -112., -113., -114., -115., -116., + -117., -118., -119.}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A, SLOPE}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a, slope}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_batch_nd_elementwise_const) +{ + Shape shape_a{2, 3, 4, 5}; + Shape shape_slope{2, 3, 4, 5}; + + std::vector a{-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1.}; + std::vector slope(shape_size(shape_slope)); + std::iota(std::begin(slope), std::end(slope), 0); + + std::vector out{-0., -1., -2., -3., -4., -5., -6., -7., -8., + -9., -10., -11., -12., -13., -14., -15., -16., -17., + -18., -19., -20., -21., -22., -23., -24., -25., -26., + -27., -28., -29., -30., -31., -32., -33., -34., -35., + -36., -37., -38., -39., -40., -41., -42., -43., -44., + -45., -46., -47., -48., -49., -50., -51., -52., -53., + -54., -55., -56., -57., -58., -59., -60., -61., -62., + -63., -64., -65., -66., -67., -68., -69., -70., -71., + -72., -73., -74., -75., -76., -77., -78., -79., -80., + -81., -82., -83., -84., -85., -86., -87., -88., -89., + -90., -91., -92., -93., -94., -95., -96., -97., -98., + -99., -100., -101., -102., -103., -104., -105., -106., -107., + -108., -109., -110., -111., -112., -113., -114., -115., -116., + -117., -118., -119.}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope, slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_1d_W_slope_param) +{ + Shape shape_a{2, 3, 4, 5}; + Shape shape_slope{5}; + + std::vector a{-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1.}; + + std::vector slope{0, 1, 2, 3, 4}; + + std::vector out{-0., -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., -1., -2., + -3., -4., -0., -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., + -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., -1., -2., -3., + -4., -0., -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., -1., + -2., -3., -4., -0., -1., -2., -3., -4., -0., -1., -2., -3., -4., + -0., -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., -1., -2., + -3., -4., -0., -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., + -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., -1., -2., -3., + -4., -0., -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., -1., + -2., -3., -4.}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A, SLOPE}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a, slope}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_1d_W_slope_const) +{ + Shape shape_a{2, 3, 4, 5}; + Shape shape_slope{5}; + + std::vector a{-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1.}; + + std::vector slope{0, 1, 2, 3, 4}; + + std::vector out{-0., -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., -1., -2., + -3., -4., -0., -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., + -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., -1., -2., -3., + -4., -0., -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., -1., + -2., -3., -4., -0., -1., -2., -3., -4., -0., -1., -2., -3., -4., + -0., -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., -1., -2., + -3., -4., -0., -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., + -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., -1., -2., -3., + -4., -0., -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., -1., + -2., -3., -4.}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope, slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_1d_C_slope_param) +{ + Shape shape_a{2, 3, 4, 5}; + Shape shape_slope{3}; + + std::vector a{-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1.}; + + std::vector slope{0, 1, 2}; + + std::vector out{-0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., + -0., -0., -0., -0., -0., -0., -0., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., + -2., -2., -2., -2., -2., -2., -2., -2., -0., -0., -0., -0., -0., + -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., + -0., -0., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -2., -2., -2., -2., + -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., + -2., -2., -2.}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A, SLOPE}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a, slope}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_1d_C_slope_const) +{ + Shape shape_a{2, 3, 4, 5}; + Shape shape_slope{3}; + + std::vector a{-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1.}; + + std::vector slope{0, 1, 2}; + + std::vector out{-0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., + -0., -0., -0., -0., -0., -0., -0., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., + -2., -2., -2., -2., -2., -2., -2., -2., -0., -0., -0., -0., -0., + -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., + -0., -0., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -2., -2., -2., -2., + -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., + -2., -2., -2.}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope, slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_C_1_1_slope_param) +{ + Shape shape_a{2, 3, 4, 5}; + Shape shape_slope{3, 1, 1}; + + std::vector a{-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1.}; + + std::vector slope{0, 1, 2}; + + std::vector out{-0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., + -0., -0., -0., -0., -0., -0., -0., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., + -2., -2., -2., -2., -2., -2., -2., -2., -0., -0., -0., -0., -0., + -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., + -0., -0., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -2., -2., -2., -2., + -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., + -2., -2., -2.}; + + const auto A = make_shared(element::f32, shape_a); + const auto SLOPE = make_shared(element::f32, shape_slope); + const auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A, SLOPE}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a, slope}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, prelu_C_1_1_slope_const) +{ + Shape shape_a{2, 3, 4, 5}; + Shape shape_slope{3, 1, 1}; + + std::vector a{-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1.}; + + std::vector slope{0, 1, 2}; + + std::vector out{-0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., + -0., -0., -0., -0., -0., -0., -0., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., + -2., -2., -2., -2., -2., -2., -2., -2., -0., -0., -0., -0., -0., + -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., + -0., -0., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -2., -2., -2., -2., + -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., + -2., -2., -2.}; + + auto A = make_shared(element::f32, shape_a); + auto SLOPE = make_shared(element::f32, shape_slope, slope); + auto f = make_shared(make_shared(A, SLOPE), ParameterVector{A}); + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({a}); + test_case.add_expected_output(shape_a, out); + test_case.run(); +} diff --git a/ngraph/test/models/onnx/prelu_1d.prototxt b/ngraph/test/models/onnx/prelu_1d.prototxt new file mode 100644 index 00000000000000..9034d1d42f6137 --- /dev/null +++ b/ngraph/test/models/onnx/prelu_1d.prototxt @@ -0,0 +1,72 @@ +ir_version: 7 +producer_name: "onnx-importer-test" +graph { + node { + input: "X" + input: "SLOPE" + output: "Y" + op_type: "PRelu" + } + name: "test-model-prelu" + input { + name: "X" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 3 + } + dim { + dim_value: 4 + } + dim { + dim_value: 5 + } + } + } + } + } + input { + name: "SLOPE" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 5 + } + } + } + } + } + output { + name: "Y" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 3 + } + dim { + dim_value: 4 + } + dim { + dim_value: 5 + } + } + } + } + } +} +opset_import { + domain: "" + version: 12 +} diff --git a/ngraph/test/models/onnx/prelu_batch_nd.prototxt b/ngraph/test/models/onnx/prelu_batch_nd.prototxt new file mode 100644 index 00000000000000..cf693db83c379e --- /dev/null +++ b/ngraph/test/models/onnx/prelu_batch_nd.prototxt @@ -0,0 +1,81 @@ +ir_version: 7 +producer_name: "onnx-importer-test" +graph { + node { + input: "X" + input: "SLOPE" + output: "Y" + op_type: "PRelu" + } + name: "test-model-prelu" + input { + name: "X" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 3 + } + dim { + dim_value: 4 + } + dim { + dim_value: 5 + } + } + } + } + } + input { + name: "SLOPE" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 3 + } + dim { + dim_value: 4 + } + dim { + dim_value: 5 + } + } + } + } + } + output { + name: "Y" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 3 + } + dim { + dim_value: 4 + } + dim { + dim_value: 5 + } + } + } + } + } +} +opset_import { + domain: "" + version: 12 +} diff --git a/ngraph/test/models/onnx/prelu_c_1_1.prototxt b/ngraph/test/models/onnx/prelu_c_1_1.prototxt new file mode 100644 index 00000000000000..83f2a748860578 --- /dev/null +++ b/ngraph/test/models/onnx/prelu_c_1_1.prototxt @@ -0,0 +1,78 @@ +ir_version: 7 +producer_name: "onnx-importer-test" +graph { + node { + input: "X" + input: "SLOPE" + output: "Y" + op_type: "PRelu" + } + name: "test-model-prelu" + input { + name: "X" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 3 + } + dim { + dim_value: 4 + } + dim { + dim_value: 5 + } + } + } + } + } + input { + name: "SLOPE" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 3 + } + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + } + } + } + } + output { + name: "Y" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 3 + } + dim { + dim_value: 4 + } + dim { + dim_value: 5 + } + } + } + } + } +} +opset_import { + domain: "" + version: 12 +} diff --git a/ngraph/test/onnx/onnx_import.in.cpp b/ngraph/test/onnx/onnx_import.in.cpp index 6a5ecfdcdf8ef8..a8522c08fa1729 100644 --- a/ngraph/test/onnx/onnx_import.in.cpp +++ b/ngraph/test/onnx/onnx_import.in.cpp @@ -2101,7 +2101,7 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_model_leaky_relu) test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, onnx_model_prelu) +NGRAPH_TEST(${BACKEND_NAME}, onnx_model_prelu_nd) { auto function = onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/prelu.prototxt")); @@ -2133,6 +2133,129 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_model_prelu) test_case.run(); } +NGRAPH_TEST(${BACKEND_NAME}, onnx_model_prelu_batch_nd_elementwise) +{ + auto function = + onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/prelu_batch_nd.prototxt")); + + Inputs inputs; + // Shape{2, 3, 4, 5} + inputs.emplace_back(std::vector{-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1.}); + + // Shape{2, 3, 4, 5} + std::vector slope(shape_size(Shape{2, 3, 4, 5})); + std::iota(std::begin(slope), std::end(slope), 0); + inputs.emplace_back(slope); + + // Shape{2, 3, 4, 5} + auto expected_output = std::vector{-0., -1., -2., -3., -4., -5., -6., -7., -8., + -9., -10., -11., -12., -13., -14., -15., -16., -17., + -18., -19., -20., -21., -22., -23., -24., -25., -26., + -27., -28., -29., -30., -31., -32., -33., -34., -35., + -36., -37., -38., -39., -40., -41., -42., -43., -44., + -45., -46., -47., -48., -49., -50., -51., -52., -53., + -54., -55., -56., -57., -58., -59., -60., -61., -62., + -63., -64., -65., -66., -67., -68., -69., -70., -71., + -72., -73., -74., -75., -76., -77., -78., -79., -80., + -81., -82., -83., -84., -85., -86., -87., -88., -89., + -90., -91., -92., -93., -94., -95., -96., -97., -98., + -99., -100., -101., -102., -103., -104., -105., -106., -107., + -108., -109., -110., -111., -112., -113., -114., -115., -116., + -117., -118., -119.}; + + auto test_case = test::TestCase(function); + test_case.add_multiple_inputs(inputs); + test_case.add_expected_output(expected_output); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, onnx_model_prelu_1d) +{ + auto function = + onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/prelu_1d.prototxt")); + + Inputs inputs; + // Shape{2, 3, 4, 5} + inputs.emplace_back(std::vector{-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1.}); + + // Shape{5} + inputs.emplace_back(std::vector{0, 1, 2, 3, 4}); + + // Shape{2, 3, 4, 5} + auto expected_output = std::vector{-0., -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., -1., -2., + -3., -4., -0., -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., + -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., -1., -2., -3., + -4., -0., -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., -1., + -2., -3., -4., -0., -1., -2., -3., -4., -0., -1., -2., -3., -4., + -0., -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., -1., -2., + -3., -4., -0., -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., + -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., -1., -2., -3., + -4., -0., -1., -2., -3., -4., -0., -1., -2., -3., -4., -0., -1., + -2., -3., -4.}; + + auto test_case = test::TestCase(function); + test_case.add_multiple_inputs(inputs); + test_case.add_expected_output(expected_output); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, onnx_model_prelu_C_1_1) +{ + auto function = + onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/prelu_c_1_1.prototxt")); + + Inputs inputs; + // Shape{2, 3, 4, 5} + inputs.emplace_back(std::vector{-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1.}); + + // Shape{3, 1, 1} + inputs.emplace_back(std::vector{0, 1, 2}); + + // Shape{2, 3, 4, 5} + auto expected_output = std::vector{-0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., + -0., -0., -0., -0., -0., -0., -0., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., + -2., -2., -2., -2., -2., -2., -2., -2., -0., -0., -0., -0., -0., + -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., + -0., -0., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., + -1., -1., -1., -1., -1., -1., -1., -1., -1., -2., -2., -2., -2., + -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., + -2., -2., -2.}; + + auto test_case = test::TestCase(function); + test_case.add_multiple_inputs(inputs); + test_case.add_expected_output(expected_output); + test_case.run(); +} + NGRAPH_TEST(${BACKEND_NAME}, onnx_model_selu) { auto function = diff --git a/ngraph/test/runtime/ie/unit_test.manifest b/ngraph/test/runtime/ie/unit_test.manifest index 9d6ea205f82839..c476f2dfac3137 100644 --- a/ngraph/test/runtime/ie/unit_test.manifest +++ b/ngraph/test/runtime/ie/unit_test.manifest @@ -758,9 +758,6 @@ lrn_2d_across_outermost_axis dyn_group_convolution_backprop_filters # Layer input port 1 is not connected to any data -prelu -prelu_shared_slope -prelu_negative_slope convolution_simple_padding # Cannot cast ngraph node Stack to CNNLayer! From 6022df66877219abed3e6f0705055d2edb460d1a Mon Sep 17 00:00:00 2001 From: Maria Kaglinskaya Date: Tue, 8 Jun 2021 09:49:53 +0300 Subject: [PATCH 012/178] Pruning with FQ support (#5925) * Add FQ, Concat, exted Eltwise support * Fix tests after rebase + small refactoring * Added Reshape on GroupConv weights mask propagating * Added printing of reduced weights to test transformation * Turn off pruning for test * Fixed comments + revert transformation comment * Fixed last comments --- .../include/mask_attribute.hpp | 80 ++++ .../include/pruning.hpp | 11 + .../src/pruning/init_const_mask.cpp | 2 +- .../src/pruning/init_masks.cpp | 64 +++ .../src/pruning/propagate_masks.cpp | 411 +++++++++++++--- .../src/pruning/pruning.cpp | 5 + .../src/pruning/shrink_weights.cpp | 2 + .../transformations/pruning_test.cpp | 444 +++++++++++++++++- 8 files changed, 944 insertions(+), 75 deletions(-) create mode 100644 inference-engine/src/offline_transformations/src/pruning/init_masks.cpp diff --git a/inference-engine/src/offline_transformations/include/mask_attribute.hpp b/inference-engine/src/offline_transformations/include/mask_attribute.hpp index 70cce141567192..48c5b4ee9f0864 100644 --- a/inference-engine/src/offline_transformations/include/mask_attribute.hpp +++ b/inference-engine/src/offline_transformations/include/mask_attribute.hpp @@ -54,10 +54,90 @@ class Mask : public std::vector>, }); } + std::vector get_not_empty_dims() { + std::vector not_empty_dims; + for (size_t i = 0; i < this->size(); i++) { + if (!this->at(i).empty()) + not_empty_dims.push_back(i); + } + return not_empty_dims; + } + bool is_shape_like() const { return m_is_shape_like; } void set_shape_like(bool flag) { m_is_shape_like = flag; } + void copy_value_from_mask(Mask *const mask) { + auto cur_mask_iter = begin(); + auto mask_iter = mask->begin(); + while (cur_mask_iter != end() && mask_iter != mask->end()) { + *cur_mask_iter = *mask_iter; + + cur_mask_iter++; + mask_iter++; + } + } + + void copy_value_from_mask_reversed(Mask *const mask) { + auto cur_mask_iter = rbegin(); + auto mask_iter = mask->rbegin(); + while (cur_mask_iter != rend() && mask_iter != mask->rend()) { + *cur_mask_iter = *mask_iter; + + cur_mask_iter++; + mask_iter++; + } + } + + Mask::Ptr intersect_masks_reversed(Mask *const mask) { + auto result_mask = std::make_shared(std::max(size(), mask->size())); + auto result_iter = result_mask->rbegin(); + auto mask_1_iter = rbegin(); + auto mask_2_iter = mask->rbegin(); + + while (mask_1_iter != rend() && + mask_2_iter != mask->rend()) { + // Merge mask dimension values for both masks + // Example: (MaskValue[1,2,3,4], MaskValue[2,3]) -> MaskValue[2,3] + for (const auto & value : *mask_1_iter) { + if (mask_2_iter->count(value)) { + result_iter->insert(value); + } + } + + result_iter++; + mask_1_iter++; + mask_2_iter++; + } + return result_mask; + } + + Mask::Ptr union_masks_reversed(Mask *const mask) { + auto result_mask = std::make_shared(std::max(size(), mask->size())); + auto result_iter = result_mask->rbegin(); + auto mask_1_iter = rbegin(); + auto mask_2_iter = mask->rbegin(); + + while (mask_1_iter != rend() && + mask_2_iter != mask->rend()) { + // Union mask dimension values for both masks + // Example: (MaskValue[1,2,3,4], MaskValue[2, 5]) -> MaskValue[1, 2, 3, 4, 5] + for (const auto & value : *mask_1_iter) { + result_iter->insert(value); + } + for (const auto & value : *mask_2_iter) { + if (!result_iter->count(value)) { + result_iter->insert(value); + } + } + + result_iter++; + mask_1_iter++; + mask_2_iter++; + } + return result_mask; + } + void add_callback(const std::function & receive_callback, Mask::Ptr mask) { m_callbacks[mask.get()] = receive_callback; m_dependencies.push_back(mask.get()); diff --git a/inference-engine/src/offline_transformations/include/pruning.hpp b/inference-engine/src/offline_transformations/include/pruning.hpp index f398ab1713f588..7831ee1424678b 100644 --- a/inference-engine/src/offline_transformations/include/pruning.hpp +++ b/inference-engine/src/offline_transformations/include/pruning.hpp @@ -14,6 +14,7 @@ namespace ngraph { namespace pass { class InitConstMask; +class InitMasks; class PropagateMasks; class ShrinkWeights; @@ -22,6 +23,16 @@ class Pruning; } // namespace pass } // namespace ngraph +/** + * @ingroup ie_transformation_common_api + * @brief Initialising masks for pruned operations + */ +class ngraph::pass::InitMasks : public ngraph::pass::GraphRewrite { +public: + NGRAPH_RTTI_DECLARATION; + InitMasks(); +}; + /** * @ingroup ie_transformation_common_api * @brief Check Constant operation values by given dimensions and set diff --git a/inference-engine/src/offline_transformations/src/pruning/init_const_mask.cpp b/inference-engine/src/offline_transformations/src/pruning/init_const_mask.cpp index 73929487b80d18..01e9520082bbfb 100644 --- a/inference-engine/src/offline_transformations/src/pruning/init_const_mask.cpp +++ b/inference-engine/src/offline_transformations/src/pruning/init_const_mask.cpp @@ -17,7 +17,7 @@ NGRAPH_RTTI_DEFINITION(ngraph::pass::InitConstMask, "InitConstMask", 0); ngraph::pass::InitConstMask::InitConstMask(const ngraph::AxisSet & dims, const std::function & condition) { auto constant = pattern::wrap_type( - pattern::type_matches_any({element::f16, element::f32, element::f64})); + pattern::type_matches_any({element::i8, element::u8, element::f16, element::f32, element::f64})); matcher_pass_callback callback = [=](pattern::Matcher& m) { auto const_node = std::dynamic_pointer_cast(m.get_match_root()); diff --git a/inference-engine/src/offline_transformations/src/pruning/init_masks.cpp b/inference-engine/src/offline_transformations/src/pruning/init_masks.cpp new file mode 100644 index 00000000000000..2b4394b6c32055 --- /dev/null +++ b/inference-engine/src/offline_transformations/src/pruning/init_masks.cpp @@ -0,0 +1,64 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "pruning.hpp" +#include "mask_attribute.hpp" + +#include +#include +#include + +NGRAPH_RTTI_DEFINITION(ngraph::pass::InitMasks, "InitMasks", 0); + +namespace ngraph { +namespace pass { +namespace init_masks { + +class InitConvMask; + +} // namespace init_masks +} // namespace pass +} // namespace ngraph + +class ngraph::pass::init_masks::InitConvMask : public MatcherPass { +public: + InitConvMask() { + auto input = pattern::any_input(); + auto weights = pattern::any_input(); + auto conv = pattern::wrap_type({input, weights}); + + ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher& m) { + const auto & pattern_map = m.get_pattern_value_map(); + const auto & m_output = pattern_map.at(conv); + + // Initializing weights mask: + // 1. Looking for Const node with weights + NodeVector weights_calculation_nodes; + auto cur_node = m_output.get_node()->get_input_node_shared_ptr(1); + + while (!ngraph::is_type(cur_node) && cur_node->inputs().size()) { + weights_calculation_nodes.push_back(cur_node); + cur_node = cur_node->get_input_node_shared_ptr(0); + } + if (!ngraph::is_type(cur_node)) { + NGRAPH_DEBUG << "Can't find Constant weights for Convolution: " << + m_output.get_node()->get_friendly_name() << std::endl; + return false; + } + + // 2. Init mask for Const node + InitConstMask({0}/* check only output channels dim */).apply(cur_node); + return true; + }; + + auto m = std::make_shared(conv, "ConvolutionInitMask"); + register_matcher(m, callback); + } +}; + + +ngraph::pass::InitMasks::InitMasks() { + add_matcher(); +} + diff --git a/inference-engine/src/offline_transformations/src/pruning/propagate_masks.cpp b/inference-engine/src/offline_transformations/src/pruning/propagate_masks.cpp index ac7a8e8b6859c7..424b6ae958317d 100644 --- a/inference-engine/src/offline_transformations/src/pruning/propagate_masks.cpp +++ b/inference-engine/src/offline_transformations/src/pruning/propagate_masks.cpp @@ -7,7 +7,9 @@ #include #include +#include #include +#include NGRAPH_RTTI_DEFINITION(ngraph::pass::PropagateMasks, "PropagateMasks", 0); @@ -20,11 +22,23 @@ class GroupConvolution; class Elementwise; class PassThrough; class StopPropagation; +class FakeQuantize; +class Concat; +class Reshape; } // namespace mask_propagation } // namespace pass } // namespace ngraph +ngraph::Shape broadcast_shape_to_rank(ngraph::Shape shape_to_broadcast, int64_t dst_rank) { + auto initial_rank = static_cast(shape_to_broadcast.size()); + auto num_of_broadcased_dims = dst_rank - initial_rank; + std::vector dims(num_of_broadcased_dims, 1); + dims.insert(dims.end(), shape_to_broadcast.begin(), shape_to_broadcast.end()); + auto new_shape = ngraph::Shape(dims); + return new_shape; +} + class ngraph::pass::mask_propagation::Convolution : public MatcherPass { public: Convolution() { @@ -38,12 +52,15 @@ class ngraph::pass::mask_propagation::Convolution : public MatcherPass { const auto & m_output = pattern_map.at(conv); const auto & m_input = pattern_map.at(input); - // In case if weights are Constant we initialize Mask - InitConstMask({0}/* check only output channel */).apply(m_weights.get_node_shared_ptr()); - auto weights_mask = getMask(m_weights); - // If weights are not a Constant and we didn't set Mask value before we will get nullptr - if (!weights_mask) return false; + + // Nullptr in weights-mask means that mask for this node wasn't initialized earlier. + // Weights mask for convolution should be initialized in the InitMasks pass (and propagate after it). + // If mask isn't initialized - this weights (and hence all convolution) can't be pruned for some reason. + if (!weights_mask) { + NGRAPH_DEBUG << "No weights mask for " << m_output.get_node()->get_friendly_name() << "\n"; + return false; + } auto weights_mask_row = weights_mask.get(); if (auto input_mask = getMask(m_input)) { @@ -119,9 +136,15 @@ class ngraph::pass::mask_propagation::GroupConvolution : public MatcherPass { auto weights_mask = getMask(m_weights); if (!weights_mask) { - // TODO: only if weights are constant - weights_mask = std::make_shared(weights_shape.size()); - setMask(m_weights, weights_mask); + // Setting mask only if weights are constant + if (ngraph::is_type(m_output.get_node_shared_ptr())) { + weights_mask = std::make_shared(weights_shape.size()); + setMask(m_weights, weights_mask); + } else { + NGRAPH_DEBUG << "GroupConvolution: No weights mask and weights aren't constant for " << + *m_output.get_node() << "\n"; + return false; + } } auto weights_mask_row = weights_mask.get(); @@ -169,13 +192,85 @@ class ngraph::pass::mask_propagation::GroupConvolution : public MatcherPass { } }; +class ngraph::pass::mask_propagation::Reshape : public MatcherPass { +public: + Reshape() { + auto input = pattern::any_input(pattern::has_static_shape()); + auto shape = pattern::any_input(); + // Working only for Reshapes on Group Convolution weights + auto reshape = pattern::wrap_type({input, shape}, pattern::consumers_count(1)); + auto gconv = pattern::wrap_type({pattern::any_input(), reshape}, + pattern::has_static_shape()); + + ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher& m) { + const auto & pattern_map = m.get_pattern_value_map(); + const auto & m_shape = pattern_map.at(shape); + const auto & m_output = pattern_map.at(reshape); + const auto & m_input = pattern_map.at(input); + + auto shape_val = m_shape.get_node_shared_ptr(); + + // In Depthwise Convolutions Reshape on weights just add additional dimension for output channels count + // (1 in case of the depthwise) of kernel. + // Example: Reshape from [G, 1 (I), X, Y, Z] -> [G, 1 (O), 1 (I), X, Y, Z], where G - group numbers, + // X, Y, Z - spartial dimensions (can be only X or X, Y), I, O - number of input/output channels of kernel. + + // Checking that matched Reshape meets this conditions (add 1-d dim on 1 position of shape constant) + auto inp_shape = m_input.get_shape(); + auto out_shape = m_output.get_shape(); + inp_shape.insert(inp_shape.begin() + 1, 1); + if (inp_shape != out_shape) { + return false; + } + + auto input_mask = getMask(m_input); + if (!input_mask) { + return false; + } + auto input_mask_row = input_mask.get(); + auto output_mask = std::make_shared(m_output.get_partial_shape().rank().get_length()); + auto output_mask_row = output_mask.get(); + + // Depthwise Convolution pruned only by input channels (== groups) -> + // Propagating mask from Group (0) dim in Reshape input to Group (0) dim in Reshape output and back + input_mask->add_callback([output_mask_row](Mask::Ptr cur_mask) -> bool { + cur_mask->at(0) = output_mask_row->at(0); + return true; + }, output_mask); + output_mask->add_callback([input_mask_row](Mask::Ptr cur_mask) -> bool { + cur_mask->at(0) = input_mask_row->at(0); + return true; + }, input_mask); + input_mask->apply_callback(output_mask); + + // To allow pruning on weights (allow reshape input Group (0) dim changing) replace Reshape Shape constant + // [G, 1, 1, X, Y, Z] by [-1, 1, 1, X, Y, Z]. + auto old_shape_const = std::dynamic_pointer_cast(m_shape.get_node_shared_ptr()); + auto shape_value = old_shape_const.get()->cast_vector(); + shape_value[0] = -1; + auto new_const = opset6::Constant::create(old_shape_const->get_element_type(), + old_shape_const->get_shape(), shape_value); + new_const->set_friendly_name(old_shape_const->get_friendly_name()); + ngraph::copy_runtime_info(old_shape_const, new_const); + ngraph::replace_node(old_shape_const, new_const); + + setMask(m_output, output_mask); + return true; + }; + + auto m = std::make_shared(reshape, "ReshapeMaskPropagation"); + register_matcher(m, callback); + } +}; + class ngraph::pass::mask_propagation::Elementwise : public MatcherPass { public: Elementwise() { auto input = pattern::any_input(); auto weights = pattern::any_input(); - auto eltwise = pattern::wrap_type({input, weights}, - pattern::has_static_rank()); + auto eltwise = pattern::wrap_type({input, weights}, pattern::has_static_rank()); + // TODO: add Div, Power support ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher& m) { const auto & pattern_map = m.get_pattern_value_map(); @@ -183,82 +278,275 @@ class ngraph::pass::mask_propagation::Elementwise : public MatcherPass { const auto & m_output = pattern_map.at(eltwise); const auto & m_input = pattern_map.at(input); - // TODO: implement check that compares input shape ranks + // Case when input masks should be united instead of intersection + bool union_eltwise_type = ngraph::is_type(m_output.get_node_shared_ptr()); + const auto & input_rank = m_input.get_partial_shape().rank().get_length(); const auto & weights_rank = m_weights.get_partial_shape().rank().get_length(); + // Here assuming that masks can be propagated only through 3/4 dimensional tensors + // (since channel dim is necessary) if (weights_rank < 3 || input_rank < 3) return false; - // In case if one of the inputs is constant - // TODO: need to find channel dimension instead of hardcoded zero - const size_t & channel_dim = (input_rank == weights_rank ? 1 : 0); - InitConstMask({channel_dim}).apply(m_input.get_node_shared_ptr()); - InitConstMask({channel_dim}).apply(m_weights.get_node_shared_ptr()); + // In case if first of the inputs is constant + InitConstMask({0, 1/* potential output channel dim */}).apply(m_input.get_node_shared_ptr()); + auto input_mask = getMask(m_input); + if (!input_mask) { + NGRAPH_DEBUG << "No input mask for: " << m_output.get_node()->get_friendly_name() << std::endl; + return false; + } + + InitConstMask({0, 1}).apply(m_weights.get_node_shared_ptr()); auto weights_mask = getMask(m_weights); + if (!weights_mask) { + NGRAPH_DEBUG << "No weights mask for: " << m_output.get_node()->get_friendly_name() << std::endl; + return false; + } + auto input_mask_row = input_mask.get(); + auto weights_mask_row = weights_mask.get(); + + // Merging masks from two inputs + auto output_mask = std::make_shared(m_output.get_partial_shape().rank().get_length()); + auto output_mask_row = output_mask.get(); + + auto out_mask_callback = [input_mask_row, weights_mask_row, union_eltwise_type](Mask::Ptr cur_mask) -> bool { + Mask::Ptr result_mask; + if (union_eltwise_type) { + result_mask = input_mask_row->union_masks_reversed(weights_mask_row); + } else { + result_mask = input_mask_row->intersect_masks_reversed(weights_mask_row); + } + cur_mask->copy_value_from_mask_reversed(result_mask.get()); + return true; + }; + output_mask->add_callback(out_mask_callback, input_mask); + + input_mask->add_callback([weights_mask_row](Mask::Ptr cur_mask) -> bool { + cur_mask->copy_value_from_mask_reversed(weights_mask_row); + return true; + }, weights_mask); + input_mask->add_callback([output_mask_row](Mask::Ptr cur_mask) -> bool { + cur_mask->copy_value_from_mask_reversed(output_mask_row); + return true; + }, output_mask); + weights_mask->add_callback([input_mask_row](Mask::Ptr cur_mask) -> bool { + cur_mask->copy_value_from_mask_reversed(input_mask_row); + return true; + }, input_mask); + + output_mask->apply_callback(input_mask); + weights_mask->apply_callback(input_mask); + + setMask(m_output, output_mask); + return true; + }; + + auto m = std::make_shared(eltwise, "ElementwiseMaskPropagation"); + register_matcher(m, callback); + } +}; + +class ngraph::pass::mask_propagation::FakeQuantize : public MatcherPass{ +public: + FakeQuantize(){ + auto input = pattern::any_input(pattern::has_static_shape()); + auto input_low = pattern::any_input(pattern::has_static_shape()); + auto input_high = pattern::any_input(pattern::has_static_shape()); + auto output_low = pattern::any_input(pattern::has_static_shape()); + auto output_high = pattern::any_input(pattern::has_static_shape()); + auto fake_quantize = pattern::wrap_type({input, input_low, input_high, output_low, + output_high}); + ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher& m) { + const auto & pattern_map = m.get_pattern_value_map(); + const auto & m_input = pattern_map.at(input); + const auto & m_input_low = pattern_map.at(input_low); + const auto & m_input_high = pattern_map.at(input_high); + const auto & m_output_low = pattern_map.at(output_low); + const auto & m_output_high = pattern_map.at(output_high); + const auto & m_output = pattern_map.at(fake_quantize); + auto input_mask = getMask(m_input); - if (!weights_mask || !input_mask) { - NGRAPH_DEBUG << "No mask for: " << m_output.get_node()->get_friendly_name() << std::endl; + // Input mask is the only source of pruning in FQ + if (!input_mask) { + NGRAPH_DEBUG << "FakeQuantize: No input mask for " << *m_output.get_node() << "\n"; return false; } + auto input_mask_row = input_mask.get(); - auto weights_mask_row = weights_mask.get(); - // Merge masks from two inputs + // Propagate input mask to output mask and in the opposite direction auto output_mask = std::make_shared(m_output.get_partial_shape().rank().get_length()); auto output_mask_row = output_mask.get(); - auto out_mask_callback = [input_mask_row, weights_mask_row](Mask::Ptr cur_mask) -> bool { - auto omask_iter = cur_mask->rbegin(); - auto imask_iter = input_mask_row->rbegin(); - auto wmask_iter = weights_mask_row->rbegin(); + // Output mask is equal to input mask + auto output_mask_callback = [input_mask_row](Mask::Ptr cur_mask) -> bool { + cur_mask->copy_value_from_mask(input_mask_row); + return true; + }; - for (auto & item : *cur_mask) { - item.clear(); - } + auto input_mask_callback = [output_mask_row](Mask::Ptr cur_mask) -> bool { + cur_mask->copy_value_from_mask(output_mask_row); + return true; + }; - while (imask_iter != input_mask_row->rend() && - wmask_iter != weights_mask_row->rend()) { - // Merge mask dimension values for both masks - // Example: (MaskValue[1,2,3,4], MaskValue[2,3]) -> MaskValue[2,3] - for (const auto & value : *imask_iter) { - if (wmask_iter->count(value)) { - omask_iter->insert(value); - } - } + output_mask->add_callback(output_mask_callback, input_mask); + input_mask->add_callback(input_mask_callback, output_mask); - omask_iter++; - imask_iter++; - wmask_iter++; + // Calculate output mask + output_mask->apply_callback(input_mask); + setMask(m_output, output_mask); + + auto input_low_size = shape_size(m_input_low.get_shape()); + auto input_high_size = shape_size(m_input_high.get_shape()); + auto output_low_size = shape_size(m_output_low.get_shape()); + auto output_high_size = shape_size(m_output_high.get_shape()); + + // In the per-tensor case FQ params shouldn't be pruned + if (input_low_size == 1 && output_low_size == 1 && input_high_size == 1 && output_high_size == 1) { + return true; + } + + // If input/output ranges in FQ should be broadcasted to input shape -> broadcast this consant values + // for the convenience of working with the masks + NodeVector fq_params_nodes{m_input_low.get_node_shared_ptr(), + m_input_high.get_node_shared_ptr(), + m_output_low.get_node_shared_ptr(), + m_output_high.get_node_shared_ptr()}; + auto fq_node = std::dynamic_pointer_cast(m_output.get_node_shared_ptr()); + size_t idx = 0; + if (fq_node->get_auto_broadcast() != ngraph::op::AutoBroadcastType::NONE) { + for (auto const_node : fq_params_nodes) { + auto new_shape = broadcast_shape_to_rank(const_node->get_shape(), + m_input.get_partial_shape().rank().get_length()); + auto const_copy = const_node->clone_with_new_inputs(const_node->input_values()); + auto new_const = std::dynamic_pointer_cast(const_copy); + new_const->set_data_shape(new_shape); + new_const->validate_and_infer_types(); + new_const->set_friendly_name(const_node->get_friendly_name()); + ngraph::copy_runtime_info(const_node, new_const); + ngraph::replace_node(const_node, new_const); + fq_params_nodes[idx++] = new_const; } + } + + auto fq_params_mask_callback = [input_mask_row](Mask::Ptr cur_mask) -> bool { + cur_mask->at(1/* fq params have same shapes as input */) = input_mask_row->at(1 /* channel dim in data */); return true; }; - output_mask->add_callback(out_mask_callback, input_mask); - output_mask->add_callback(out_mask_callback, weights_mask); - - auto callback = [output_mask_row](Mask::Ptr cur_mask) -> bool { - auto omask_iter = output_mask_row->rbegin(); - auto cmask_iter = cur_mask->rbegin(); - while (omask_iter != output_mask_row->rend() && - cmask_iter != cur_mask->rend()) { - // TODO: check - *cmask_iter = *omask_iter; - - omask_iter++; - cmask_iter++; + + for (auto fq_param : fq_params_nodes) { + auto mask = std::make_shared(fq_param->get_shape().size()); + mask->add_callback(fq_params_mask_callback, input_mask); + input_mask->add_callback([mask](Mask::Ptr cur_mask) -> bool { + return true; + }, mask); + mask->apply_callback(input_mask); + setMask(fq_param->output(0), mask); + } + + return true; + }; + + auto m = std::make_shared(fake_quantize, "FakeQuantizeMaskPropagation"); + register_matcher(m, callback); + } +}; + +class ngraph::pass::mask_propagation::Concat : public MatcherPass{ +public: + Concat() { + auto concat = pattern::wrap_type(pattern::has_static_shape()); + + ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher &m) { + const auto & pattern_map = m.get_pattern_value_map(); + const auto & m_output = pattern_map.at(concat); + auto concat_ptr = std::dynamic_pointer_cast(m_output.get_node_shared_ptr()); + auto axis = concat_ptr->get_concatenation_axis(); + + auto inputs = concat_ptr->inputs(); + std::map input_masks; + std::map input_masks_row; + std::vector input_sizes; + + size_t first_input_idx = 0; + Mask::Ptr first_input_mask; + bool first_initialized = false; + for (size_t i=0; i < inputs.size(); i++) { + auto input = inputs[i]; + auto input_mask = getMask(input.get_source_output()); + if (input_mask) { + input_masks[i] = input_mask; + input_masks_row[i] = input_mask.get(); + + if (!first_initialized) { + first_input_idx = i; + first_input_mask = input_mask; + first_initialized = true; + } + } + input_sizes.push_back(input.get_shape().at(axis)); + } + + if (!first_initialized) { + return false; + } + + auto output_mask = std::make_shared(m_output.get_partial_shape().rank().get_length()); + auto output_mask_row = output_mask.get(); + + auto out_mask_callback = [input_masks_row, input_sizes, axis](Mask::Ptr cur_mask) -> bool { + int64_t cur_size = 0; + cur_mask->at(axis).clear(); + + for (size_t i=0; i < input_sizes.size(); ++i) { + if (input_masks_row.count(i)) { + for (auto idx : input_masks_row.at(i)->at(axis)) { + cur_mask->at(axis).insert(idx + cur_size); + } + } + cur_size += input_sizes[i]; } return true; }; - input_mask->add_callback(callback, output_mask); - weights_mask->add_callback(callback, output_mask); - // Init output mask - output_mask->apply_callback(input_mask); + auto create_input_mask_callback_for_idx = [output_mask_row, input_sizes, axis](size_t input_idx){ + auto input_mask_callback = [output_mask_row, input_sizes, axis, input_idx](Mask::Ptr cur_mask) -> bool { + cur_mask->clean_dim_values(); + uint64_t min_val = 0; + for (size_t i = 0; i < input_idx; i++) { + min_val += input_sizes[i]; + } + uint64_t max_val = min_val + input_sizes[input_idx]; + for (auto idx : output_mask_row->at(axis)) { + if (idx < max_val && idx >= min_val) { + cur_mask->at(axis).insert(idx - min_val); + } + } + return true; + }; + return input_mask_callback; + }; + output_mask->add_callback(out_mask_callback, first_input_mask); + + for (size_t i=0; i < inputs.size(); ++i) { + if (input_masks.count(i) && i != first_input_idx) { + auto input_mask = input_masks.at(i); + input_mask->add_callback(create_input_mask_callback_for_idx(i), + first_input_mask); + first_input_mask->add_callback([](Mask::Ptr cur_mask) -> bool { + return true; + }, input_mask); + } + } + first_input_mask->add_callback(create_input_mask_callback_for_idx(first_input_idx), + output_mask); + output_mask->apply_callback(first_input_mask); setMask(m_output, output_mask); + return true; }; - - auto m = std::make_shared(eltwise, "EltwiseMaskPropagation"); + auto m = std::make_shared(concat, "ConcatMaskPropagation"); register_matcher(m, callback); } }; @@ -266,7 +554,9 @@ class ngraph::pass::mask_propagation::Elementwise : public MatcherPass { class ngraph::pass::mask_propagation::PassThrough : public MatcherPass { public: PassThrough() { - auto unary_op = pattern::wrap_type(); + auto unary_op = pattern::wrap_type(); ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher& m) { const auto & pattern_map = m.get_pattern_value_map(); @@ -312,5 +602,8 @@ ngraph::pass::PropagateMasks::PropagateMasks() { add_matcher(); add_matcher(); add_matcher(); + add_matcher(); + add_matcher(); + add_matcher(); add_matcher(); } diff --git a/inference-engine/src/offline_transformations/src/pruning/pruning.cpp b/inference-engine/src/offline_transformations/src/pruning/pruning.cpp index 3159e3db7db166..ad7f410b8f356b 100644 --- a/inference-engine/src/offline_transformations/src/pruning/pruning.cpp +++ b/inference-engine/src/offline_transformations/src/pruning/pruning.cpp @@ -15,8 +15,13 @@ NGRAPH_RTTI_DEFINITION(ngraph::pass::Pruning, "Pruning", 0); bool ngraph::pass::Pruning::run_on_function(std::shared_ptr f) { Manager manager(get_pass_config()); + + // Initialize masks only for Convolutions/GroupConvolutions weights (needed to init mask in source Constant of + // weights-calculating subgraph). For other node types masks initialized in PropagateMasks pass. + manager.register_pass(); manager.register_pass(); + #ifdef NGRAPH_DEBUG_ENABLE // VisualizeTree modifier helps to print Masks and mark nodes with masks /* diff --git a/inference-engine/src/offline_transformations/src/pruning/shrink_weights.cpp b/inference-engine/src/offline_transformations/src/pruning/shrink_weights.cpp index 80c2abbb709eb8..08e7ef152c03cc 100644 --- a/inference-engine/src/offline_transformations/src/pruning/shrink_weights.cpp +++ b/inference-engine/src/offline_transformations/src/pruning/shrink_weights.cpp @@ -54,6 +54,8 @@ bool ngraph::pass::ShrinkWeights::run_on_function(std::shared_ptrsize(); ++dim) { const auto &dim_size = mask->at(dim).size(); if (dim_size == 0) continue; + // Broadcastable 1-size dimension shouldn't be shrank with mask + if (const_node->get_shape().at(dim) == 1 && dim_size > 1) continue; // Convert dims that we want remove to dims that we need to keep std::vector dims_to_keep; diff --git a/inference-engine/tests/functional/inference_engine/transformations/pruning_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/pruning_test.cpp index 0f46a853cef123..82c1fa6c9f2eab 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/pruning_test.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/pruning_test.cpp @@ -15,6 +15,7 @@ #include #include #include +#include using namespace testing; using namespace ngraph; @@ -67,6 +68,23 @@ TEST(TransformationTests, InitMasksOutputChannel) { compare_masks(*getMask(weights->output(0)), {{}, {1}, {}, {}}); } +// TODO: add test init masks with subgraph +TEST(TransformationTests, TestInitMasks) { + Shape weights_shape{6, 3, 3, 3}; + Shape input_shape{1, 3, 64, 64}; + auto input = std::make_shared(element::f32, input_shape); + auto weights = create_constant_with_zeros(weights_shape, {{1, 2, 3}, {}, {}, {}}); + auto conv = std::make_shared(input, weights, Strides(2, 1), + CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); + + auto f = std::make_shared(NodeVector{conv}, ParameterVector{input}); + pass::Manager m; + m.register_pass(); + m.run_passes(f); + + compare_masks(*getMask(weights.get_node_shared_ptr()->output(0)), {{1, 2, 3}, {}, {}, {}}); +} + TEST(TransformationTests, InitMasksNegative) { Shape weights_shape{6, 3, 3, 3}; auto weights = opset5::Constant::create(element::f32, weights_shape, {0.5}); @@ -85,6 +103,7 @@ TEST(TransformationTests, PropagateMasksNegative) { auto f = std::make_shared(NodeVector{conv}, ParameterVector{input}); pass::Manager m; + m.register_pass(); m.register_pass(); m.run_passes(f); @@ -102,27 +121,35 @@ TEST(TransformationTests, PropagateMasksBasic) { CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); auto relu = std::make_shared(conv); + auto add_const = create_constant_with_zeros(Shape{1, 6, 1, 1}, {{}, {1, 2, 3, 4, 5}, {}, {}}); + auto add = std::make_shared(relu, add_const); + auto sub_const = create_constant_with_zeros(Shape{6, 1, 1}, {{1, 2, 3}, {}, {}}); - auto sub = std::make_shared(relu, sub_const); + auto sub = std::make_shared(add, sub_const); - auto mul_const = create_constant_with_zeros(Shape{6, 1, 1}, {{2}, {}, {}}); - auto mul = std::make_shared(sub, mul_const); + auto mul_const = create_constant_with_zeros(Shape{1, 6, 1, 1}, {{}, {4}, {}, {}}); + auto mul = std::make_shared(sub, mul_const); - auto weights2 = opset5::Constant::create(element::f32, weights_shape2, {0}); + auto weights2 = create_constant_with_zeros(weights_shape2, {{1, 2}, {1, 2, 3}, {}, {}}); auto conv2 = std::make_shared(mul, weights2, Strides(2, 1), CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); auto f = std::make_shared(NodeVector{conv2}, ParameterVector{input}); pass::Manager m; + m.register_pass(); m.register_pass(); m.run_passes(f); - compare_masks(*getMask(weights->output(0)), Mask({{2}, {}, {}, {}})); - compare_masks(*getMask(conv->output(0)), Mask({{}, {2}, {}, {}})); - compare_masks(*getMask(relu->output(0)), Mask({{}, {2}, {}, {}})); - compare_masks(*getMask(sub_const), Mask({{2}, {}, {}})); - compare_masks(*getMask(mul_const), Mask({{2}, {}, {}})); - compare_masks(*getMask(weights2->output(0)), Mask({{}, {2}, {}, {}})); + compare_masks(*getMask(weights->output(0)), Mask({{1, 2, 3, 4}, {}, {}, {}})); + compare_masks(*getMask(conv->output(0)), Mask({{}, {1, 2, 3, 4}, {}, {}})); + compare_masks(*getMask(relu->output(0)), Mask({{}, {1, 2, 3, 4}, {}, {}})); + compare_masks(*getMask(add_const), Mask({{}, {1, 2, 3, 4}, {}, {}})); + compare_masks(*getMask(sub_const), Mask({{1, 2, 3, 4}, {}, {}})); + compare_masks(*getMask(mul_const), Mask({{}, {1, 2, 3, 4}, {}, {}})); + compare_masks(*getMask(add->output(0)), Mask({{}, {1, 2, 3, 4}, {}, {}})); + compare_masks(*getMask(sub->output(0)), Mask({{}, {1, 2, 3, 4}, {}, {}})); + compare_masks(*getMask(mul->output(0)), Mask({{}, {1, 2, 3, 4}, {}, {}})); + compare_masks(*getMask(weights2.get_node_shared_ptr()->output(0)), Mask({{}, {1, 2, 3, 4}, {}, {}})); compare_masks(*getMask(conv2->output(0)), Mask({{}, {}, {}, {}})); } @@ -148,6 +175,7 @@ TEST(TransformationTests, PropagateMasksDynamicConvolution) { auto f = std::make_shared(NodeVector{conv2}, ParameterVector{input}); pass::Manager m; + m.register_pass(); m.register_pass(); m.run_passes(f); @@ -182,6 +210,7 @@ TEST(TransformationTests, PropagateMasksDynamicGroupConvolution) { auto f = std::make_shared(NodeVector{conv2}, ParameterVector{input}); pass::Manager m; + m.register_pass(); m.register_pass(); m.run_passes(f); } @@ -199,15 +228,16 @@ TEST(TransformationTests, PropagateMasksEmpty) { auto sub_const = create_constant_with_zeros(Shape{6, 1, 1}, {{1, 2, 3}, {}, {}}); auto sub = std::make_shared(relu, sub_const); - auto mul_const = create_constant_with_zeros(Shape{6, 1, 1}, {{1, 2}, {}, {}}); - auto mul = std::make_shared(sub, mul_const); + auto add_const = create_constant_with_zeros(Shape{6, 1, 1}, {{1, 2}, {}, {}}); + auto add = std::make_shared(sub, add_const); auto weights2 = opset5::Constant::create(element::f32, weights_shape2, {0}); - auto conv2 = std::make_shared(mul, weights2, Strides(2, 1), + auto conv2 = std::make_shared(add, weights2, Strides(2, 1), CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); auto f = std::make_shared(NodeVector{conv2}, ParameterVector{input}); pass::Manager m; + m.register_pass(); m.register_pass(); m.run_passes(f); @@ -215,11 +245,55 @@ TEST(TransformationTests, PropagateMasksEmpty) { compare_masks(*getMask(conv->output(0)), Mask({{}, {}, {}, {}})); compare_masks(*getMask(relu->output(0)), Mask({{}, {}, {}, {}})); compare_masks(*getMask(sub_const), Mask({{}, {}, {}})); - compare_masks(*getMask(mul_const), Mask({{}, {}, {}})); + compare_masks(*getMask(add_const), Mask({{}, {}, {}})); compare_masks(*getMask(weights2->output(0)), Mask({{}, {}, {}, {}})); compare_masks(*getMask(conv2->output(0)), Mask({{}, {}, {}, {}})); } +TEST(TransformationTests, PropagateMaskPassThrough) { + Shape input_shape{1, 3, 64, 64}; + Shape weights_shape{8, 3, 3, 3}; + Shape weight_shape2{3, 8, 3, 3}; + auto input = std::make_shared(element::f32, input_shape); + input->set_friendly_name("input"); + auto weights_const_1 = create_constant_with_zeros(weights_shape, {{1, 2, 3}, {}, {}, {}}); + weights_const_1.get_node_shared_ptr()->set_friendly_name("weights_1"); + + auto conv_1 = std::make_shared(input, weights_const_1, Strides(2, 1), + CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); + conv_1->set_friendly_name("conv_1"); + + // Adding a couple of PassThrough operations + auto relu = std::make_shared(conv_1); + relu->set_friendly_name("relu"); + + auto clamp = std::make_shared(relu, 0, 6); + clamp->set_friendly_name("clamp"); + + auto pads_begin = opset5::Constant::create(element::i32, Shape{4}, {0, 0, 1, 1}); + auto pads_end = opset5::Constant::create(element::i32, Shape{4}, {0, 0, 2, 2}); + auto pad = std::make_shared(clamp, pads_begin, pads_end, op::PadMode::CONSTANT); + auto max_pool = std::make_shared(pad, Strides{1, 1}, + Shape{0, 0}, Shape{1, 1}, Shape{4, 4}); + max_pool->set_friendly_name("max_pool"); + + auto weights2 = opset5::Constant::create(element::f32, weight_shape2, {0}); + auto conv2 = std::make_shared(max_pool, weights2, Strides(2, 1), + CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); + auto f = std::make_shared(NodeVector{conv2}, ParameterVector{input}); + + pass::Manager m; + m.register_pass(); + m.register_pass(); + m.run_passes(f); + + compare_masks(*getMask(weights_const_1.get_node_shared_ptr()->output(0)), Mask({{1, 2, 3}, {}, {}, {}})); + compare_masks(*getMask(conv_1->output(0)), Mask({{}, {1, 2, 3}, {}, {}})); + compare_masks(*getMask(relu->output(0)), Mask({{}, {1, 2, 3}, {}, {}})); + compare_masks(*getMask(clamp->output(0)), Mask({{}, {1, 2, 3}, {}, {}})); + compare_masks(*getMask(max_pool->output(0)), Mask({{}, {1, 2, 3}, {}, {}})); +} + TEST(TransformationTests, PropagateMasksHardDependencies) { Shape input_shape{1, 3, 3, 3}; @@ -280,4 +354,344 @@ TEST(TransformationTests, PropagateMasksHardDependencies) { // compare_masks(*getMask(relu), Mask({{}, {0, 1, 2, 3, 4, 5}, {}, {}})); // compare_masks(*getMask(weights2), Mask({{}, {0, 1, 2, 3, 4, 5}, {}, {}})); // compare_masks(*getMask(conv2), Mask({{}, {}, {}, {}})); -} \ No newline at end of file +} + +TEST(TransformationTests, PropagateMasksQuantizedGroupConvolution) { + Shape input_shape{1, 3, 64, 64}; + Shape weights_shape{8, 3, 3, 3}; + Shape weights_group_shape{8, 1, 3, 3}; + Shape weight_shape2{3, 8, 3, 3}; + auto input = std::make_shared(element::f32, input_shape); + input->set_friendly_name("input"); + + auto weights1 = create_constant_with_zeros(weights_shape, {{0, 1, 2, 3}, {}, {}, {}}); + auto conv1 = std::make_shared(input, weights1, Strides(2, 1), + CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); + auto weights_group = opset5::Constant::create(element::i8, weights_group_shape, {0}); + weights_group->set_friendly_name("weights_group"); + + auto convert = std::make_shared(weights_group, element::f32); + convert->set_friendly_name("convert"); + + auto sub_const = create_constant_with_zeros(Shape{8, 1, 1, 1}, {{0, 1, 2, 3}, {}, {}, {}}); + + auto sub = std::make_shared(convert, sub_const); + sub->set_friendly_name("sub"); + + auto mul_const = create_constant_with_zeros(Shape{8, 1, 1, 1}, {{0, 1, 2, 3, 4}, {}, {}, {}}); + auto mul = std::make_shared(sub, mul_const); + mul->set_friendly_name("mul"); + + auto reshape = std::make_shared(mul, opset5::Constant::create(element::i64, Shape{5}, {8, 1, 1, 3, 3}), false); + + auto conv_group = std::make_shared(conv1, reshape, Strides(2, 1), + CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); + + auto add_const = create_constant_with_zeros(Shape{1, 8, 1, 1}, {{}, {0, 1, 2, 3, 4}, {}, {}});; + auto add = std::make_shared(conv_group, add_const); + add->set_friendly_name("add"); + + auto weights_2 = opset5::Constant::create(element::f32, weight_shape2, {0}); + auto conv2 = std::make_shared(add, weights_2, Strides(2, 1), + CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); + auto f = std::make_shared(NodeVector{conv2}, ParameterVector{input}); + + pass::Manager m; + m.register_pass(); + m.run_passes(f); + + compare_masks(*getMask(weights1.get_node_shared_ptr()->output(0)), Mask({{0 , 1, 2, 3}, {}, {}, {}})); + compare_masks(*getMask(conv1->output(0)), Mask({{}, {0 , 1, 2, 3}, {}, {}})); + + compare_masks(*getMask(weights_group->output(0)), Mask({{0 , 1, 2, 3}, {}, {}, {}})); + compare_masks(*getMask(sub->output(0)), Mask({{0 , 1, 2, 3}, {}, {}, {}})); + compare_masks(*getMask(sub_const.get_node_shared_ptr()->output(0)), Mask({{0 , 1, 2, 3}, {}, {}, {}})); + compare_masks(*getMask(mul->output(0)), Mask({{0 , 1, 2, 3}, {}, {}, {}})); + compare_masks(*getMask(mul_const.get_node_shared_ptr()->output(0)), Mask({{0 , 1, 2, 3}, {}, {}, {}})); + + compare_masks(*getMask(reshape->output(0)), Mask({{0 , 1, 2, 3}, {}, {}, {}, {}})); + + compare_masks(*getMask(conv_group->output(0)), Mask({{}, {0 , 1, 2, 3}, {}, {}})); + + compare_masks(*getMask(conv2->output(0)), Mask({{}, {}, {}, {}})); + compare_masks(*getMask(weights_2->output(0)), Mask({{}, {0, 1, 2, 3}, {}, {}})); +} + +TEST(TransformationTests, PropagateMasksFakeQuantizePerTensor) { + Shape input_shape{1, 3, 64, 64}; + Shape weights_shape{8, 3, 3, 3}; + Shape weight_shape2{3, 8, 3, 3}; + auto input = std::make_shared(element::f32, input_shape); + input->set_friendly_name("input"); + auto weights_1 = opset5::Constant::create(element::i8, weights_shape, {0}); + weights_1->set_friendly_name("weights_int8_const"); + + auto convert = std::make_shared(weights_1, element::f32); + convert->set_friendly_name("convert"); + + auto sub_const = create_constant_with_zeros(Shape{8, 1, 1, 1}, {{0, 1, 2, 3}, {}, {}, {}}); + + auto sub = std::make_shared(convert, sub_const); + sub->set_friendly_name("sub"); + + auto mul_const = create_constant_with_zeros(Shape{8, 1, 1, 1}, {{0, 1, 2, 3, 4}, {}, {}, {}}); + auto mul = std::make_shared(sub, mul_const); + mul->set_friendly_name("mul"); + + auto conv1 = std::make_shared(input, mul, Strides(2, 1), + CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); + conv1->set_friendly_name("conv1"); + + auto add_const = create_constant_with_zeros(Shape{1, 8, 1, 1}, {{}, {0, 1, 2, 3, 4}, {}, {}});; + auto add = std::make_shared(conv1, add_const); + add->set_friendly_name("add"); + + auto input_low = opset5::Constant::create(element::f32, Shape{1}, {0}); + auto input_high = opset5::Constant::create(element::f32, Shape{1, 1, 1, 1}, {20}); + auto output_low = opset5::Constant::create(element::f32, Shape{}, {1}); + auto output_high = opset5::Constant::create(element::f32, Shape{}, {10}); + auto fq = std::make_shared(add, input_low, input_high, output_low, output_high, 8); + + auto weights_2 = opset5::Constant::create(element::f32, weight_shape2, {0}); + auto conv2 = std::make_shared(fq, weights_2, Strides(2, 1), + CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); + auto f = std::make_shared(NodeVector{conv2}, ParameterVector{input}); + + pass::Manager m; + m.register_pass(); + m.run_passes(f); + + compare_masks(*getMask(weights_1->output(0)), Mask({{0 , 1, 2, 3, 4}, {}, {}, {}})); + compare_masks(*getMask(sub_const.get_node_shared_ptr()->output(0)), Mask({{0 , 1, 2, 3, 4}, {}, {}, {}})); + compare_masks(*getMask(sub->output(0)), Mask({{0 , 1, 2, 3, 4}, {}, {}, {}})); + + compare_masks(*getMask(mul_const.get_node_shared_ptr()->output(0)), Mask({{0 , 1, 2, 3, 4}, {}, {}, {}})); + compare_masks(*getMask(mul->output(0)), Mask({{0 , 1, 2, 3, 4}, {}, {}, {}})); + + compare_masks(*getMask(conv1->output(0)), Mask({{}, {0 , 1, 2, 3, 4}, {}, {}})); + + compare_masks(*getMask(add_const.get_node_shared_ptr()->output(0)), Mask({{}, {0 , 1, 2, 3, 4}, {}, {}})); + compare_masks(*getMask(add->output(0)), Mask({{}, {0 , 1, 2, 3, 4}, {}, {}})); + + compare_masks(*getMask(fq->output(0)), Mask({{}, {0 , 1, 2, 3, 4}, {}, {}})); + + compare_masks(*getMask(weights_2->output(0)), Mask({{}, {0 , 1, 2, 3, 4}, {}, {}})); + compare_masks(*getMask(conv2->output(0)), Mask({{}, {}, {}, {}})); +} + +TEST(TransformationTests, PropagateMasksFakeQuantizePerChannel) { + Shape input_shape{1, 3, 64, 64}; + Shape weights_shape{8, 3, 3, 3}; + Shape weight_shape2{3, 8, 3, 3}; + auto input = std::make_shared(element::f32, input_shape); + input->set_friendly_name("input"); + auto weights_1 = opset5::Constant::create(element::i8, weights_shape, {0}); + weights_1->set_friendly_name("weights_int8_const"); + + auto convert = std::make_shared(weights_1, element::f32); + convert->set_friendly_name("convert"); + + auto sub_const = create_constant_with_zeros(Shape{8, 1, 1, 1}, {{0, 1, 2, 3}, {}, {}, {}}); + + auto sub = std::make_shared(convert, sub_const); + sub->set_friendly_name("sub"); + + auto mul_const = create_constant_with_zeros(Shape{8, 1, 1, 1}, {{0, 1, 2, 3, 4}, {}, {}, {}}); + auto mul = std::make_shared(sub, mul_const); + mul->set_friendly_name("mul"); + + auto conv1 = std::make_shared(input, mul, Strides(2, 1), + CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); + conv1->set_friendly_name("conv1"); + + auto add_const = create_constant_with_zeros(Shape{1, 8, 1, 1}, {{}, {0, 1, 2, 3, 4}, {}, {}});; + auto add = std::make_shared(conv1, add_const); + add->set_friendly_name("add"); + + auto input_low = opset5::Constant::create(element::f32, Shape{1, 8, 1, 1}, {0}); + auto input_high = opset5::Constant::create(element::f32, Shape{1, 8, 1, 1}, {20}); + auto output_low = opset5::Constant::create(element::f32, Shape{8, 1, 1}, {1}); + auto output_high = opset5::Constant::create(element::f32, Shape{8, 1, 1}, {10}); + auto fq = std::make_shared(add, input_low, input_high, output_low, output_high, 8); + + auto weights_2 = opset5::Constant::create(element::f32, weight_shape2, {0}); + auto conv2 = std::make_shared(fq, weights_2, Strides(2, 1), + CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); + auto f = std::make_shared(NodeVector{conv2}, ParameterVector{input}); + + pass::Manager m; + m.register_pass(); + m.register_pass(); + m.run_passes(f); + + compare_masks(*getMask(weights_1->output(0)), Mask({{0 , 1, 2, 3, 4}, {}, {}, {}})); + compare_masks(*getMask(sub_const.get_node_shared_ptr()->output(0)), Mask({{0 , 1, 2, 3, 4}, {}, {}, {}})); + compare_masks(*getMask(sub->output(0)), Mask({{0 , 1, 2, 3, 4}, {}, {}, {}})); + + compare_masks(*getMask(mul_const.get_node_shared_ptr()->output(0)), Mask({{0 , 1, 2, 3, 4}, {}, {}, {}})); + compare_masks(*getMask(mul->output(0)), Mask({{0 , 1, 2, 3, 4}, {}, {}, {}})); + + compare_masks(*getMask(conv1->output(0)), Mask({{}, {0 , 1, 2, 3, 4}, {}, {}})); + + compare_masks(*getMask(add_const.get_node_shared_ptr()->output(0)), Mask({{}, {0 , 1, 2, 3, 4}, {}, {}})); + compare_masks(*getMask(add->output(0)), Mask({{}, {0 , 1, 2, 3, 4}, {}, {}})); + + compare_masks(*getMask(fq->output(0)), Mask({{}, {0 , 1, 2, 3, 4}, {}, {}})); + + compare_masks(*getMask(weights_2->output(0)), Mask({{}, {0 , 1, 2, 3, 4}, {}, {}})); + compare_masks(*getMask(conv2->output(0)), Mask({{}, {}, {}, {}})); + + compare_masks(*getMask(fq->input(1).get_source_output()), Mask({{}, {0 , 1, 2, 3, 4}, {}, {}})); + compare_masks(*getMask(fq->input(2).get_source_output()), Mask({{}, {0 , 1, 2, 3, 4}, {}, {}})); + compare_masks(*getMask(fq->input(3).get_source_output()), Mask({{}, {0 , 1, 2, 3, 4}, {}, {}})); + compare_masks(*getMask(fq->input(4).get_source_output()), Mask({{}, {0 , 1, 2, 3, 4}, {}, {}})); +} + +TEST(TransformationTests, TestConcatMaskPropagation) { + Shape input_shape{1, 3, 64, 64}; + Shape weights_shape1{8, 3, 3, 3}; + Shape weights_shape2{16, 3, 3, 3}; + Shape weights_shape3{8, 3, 3, 3}; + + Shape weight_shape_out_conv{3, 32, 3, 3}; + auto input = std::make_shared(element::f32, input_shape); + auto weights_1 = create_constant_with_zeros(weights_shape1, {{0, 1, 2, 3}, {}, {}, {}}); + auto conv1 = std::make_shared(input, weights_1, Strides(2, 1), + CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); + + auto weights_2 = create_constant_with_zeros(weights_shape2, {{7, 8, 9, 10}, {}, {}, {}}); + auto conv2 = std::make_shared(input, weights_2, Strides(2, 1), + CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); + + auto weights_3 = create_constant_with_zeros(weights_shape3, {{4, 5, 6, 7}, {}, {}, {}}); + auto conv3 = std::make_shared(input, weights_3, Strides(2, 1), + CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); + + auto concat = std::make_shared(OutputVector{conv1->output(0), conv2->output(0), conv3->output(0)}, 1); + + auto weights_out_conv = create_constant_with_zeros(weight_shape_out_conv, {{}, {}, {}, {}}); + auto conv_out = std::make_shared(concat, weights_out_conv, Strides(2, 1), + CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); + + auto f = std::make_shared(NodeVector{conv_out}, ParameterVector{input}); + + pass::Manager m; + m.register_pass(); + m.register_pass(); + m.run_passes(f); + + compare_masks(*getMask(weights_1.get_node_shared_ptr()->output(0)), Mask({{0, 1, 2, 3}, {}, {}, {}})); + compare_masks(*getMask(conv1->output(0)), Mask({{}, {0, 1, 2, 3}, {}, {}})); + + compare_masks(*getMask(weights_2.get_node_shared_ptr()->output(0)), Mask({{7, 8, 9, 10}, {}, {}, {}})); + compare_masks(*getMask(conv2->output(0)), Mask({{}, {7, 8, 9, 10}, {}, {}})); + + compare_masks(*getMask(weights_3.get_node_shared_ptr()->output(0)), Mask({{4, 5, 6, 7}, {}, {}, {}})); + compare_masks(*getMask(conv3->output(0)), Mask({{}, {4, 5, 6, 7}, {}, {}})); + + compare_masks(*getMask(concat->output(0)), Mask({{}, {0, 1, 2, 3, 15, 16, 17, 18, 28, 29, 30, 31}, {}, {}})); + compare_masks(*getMask(weights_out_conv.get_node_shared_ptr()->output(0)), Mask({{}, {0, 1, 2, 3, 15, 16, 17, 18, 28, 29, 30, 31}, {}, {}})); +} + + +TEST(TransformationTests, TestConcatMaskPropagationUp) { + Shape input_shape{1, 3, 64, 64}; + Shape weights_shape1{8, 3, 3, 3}; + Shape weights_shape2{16, 3, 3, 3}; + Shape weights_shape3{8, 3, 3, 3}; + + Shape weight_shape_out_conv{3, 32, 3, 3}; + auto input = std::make_shared(element::f32, input_shape); + auto weights_1 = create_constant_with_zeros(weights_shape1, {{0, 1, 2, 3, 4, 5}, {}, {}, {}}); + auto conv1 = std::make_shared(input, weights_1, Strides(2, 1), + CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); + + auto weights_2 = create_constant_with_zeros(weights_shape2, {{7, 8, 9, 10}, {}, {}, {}}); + auto conv2 = std::make_shared(input, weights_2, Strides(2, 1), + CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); + + auto weights_3 = create_constant_with_zeros(weights_shape3, {{2, 3, 4, 5, 6, 7}, {}, {}, {}}); + auto conv3 = std::make_shared(input, weights_3, Strides(2, 1), + CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); + + auto concat = std::make_shared(OutputVector{conv1->output(0), conv2->output(0), conv3->output(0)}, 1); + + auto add_const = create_constant_with_zeros(Shape{1, 32, 1, 1}, {{}, {0, 1, 2, 3, 15, 16, 17, 18, 28, 29, 30, 31}, {}, {}}); + auto add = std::make_shared(concat, add_const); + + auto weights_out_conv = create_constant_with_zeros(weight_shape_out_conv, {{}, {}, {}, {}}); + auto conv_out = std::make_shared(add, weights_out_conv, Strides(2, 1), + CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); + + auto f = std::make_shared(NodeVector{conv_out}, ParameterVector{input}); + + pass::Manager m; + m.register_pass(); + m.register_pass(); + m.run_passes(f); + + compare_masks(*getMask(weights_1.get_node_shared_ptr()->output(0)), Mask({{0, 1, 2, 3}, {}, {}, {}})); + compare_masks(*getMask(conv1->output(0)), Mask({{}, {0, 1, 2, 3}, {}, {}})); + + compare_masks(*getMask(weights_2.get_node_shared_ptr()->output(0)), Mask({{7, 8, 9, 10}, {}, {}, {}})); + compare_masks(*getMask(conv2->output(0)), Mask({{}, {7, 8, 9, 10}, {}, {}})); + + compare_masks(*getMask(weights_3.get_node_shared_ptr()->output(0)), Mask({{4, 5, 6, 7}, {}, {}, {}})); + compare_masks(*getMask(conv3->output(0)), Mask({{}, {4, 5, 6, 7}, {}, {}})); + + compare_masks(*getMask(add_const.get_node_shared_ptr()->output(0)), Mask({{}, {0, 1, 2, 3, 15, 16, 17, 18, 28, 29, 30, 31}, {}, {}})); + compare_masks(*getMask(add->output(0)), Mask({{}, {0, 1, 2, 3, 15, 16, 17, 18, 28, 29, 30, 31}, {}, {}})); + + + compare_masks(*getMask(concat->output(0)), Mask({{}, {0, 1, 2, 3, 15, 16, 17, 18, 28, 29, 30, 31}, {}, {}})); + compare_masks(*getMask(weights_out_conv.get_node_shared_ptr()->output(0)), Mask({{}, {0, 1, 2, 3, 15, 16, 17, 18, 28, 29, 30, 31}, {}, {}})); +} + + +TEST(TransformationTests, TestConcatMaskPropagationUpEmpty) { + Shape input_shape{1, 3, 64, 64}; + Shape weights_shape1{8, 3, 3, 3}; + Shape weights_shape2{16, 3, 3, 3}; + Shape weights_shape3{8, 3, 3, 3}; + + Shape weight_shape_out_conv{3, 32, 3, 3}; + auto input = std::make_shared(element::f32, input_shape); + auto weights_1 = create_constant_with_zeros(weights_shape1, {{0, 1, 2, 3, 4, 5}, {}, {}, {}}); + auto conv1 = std::make_shared(input, weights_1, Strides(2, 1), + CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); + + auto weights_2 = create_constant_with_zeros(weights_shape2, {{7, 8, 9, 10}, {}, {}, {}}); + auto conv2 = std::make_shared(input, weights_2, Strides(2, 1), + CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); + + auto weights_3 = create_constant_with_zeros(weights_shape3, {{2, 3, 4, 5, 6, 7}, {}, {}, {}}); + auto conv3 = std::make_shared(input, weights_3, Strides(2, 1), + CoordinateDiff(2, 0), CoordinateDiff(2, 0), Strides(2, 1)); + + auto concat = std::make_shared(OutputVector{conv1->output(0), conv2->output(0), conv3->output(0)}, 1); + + auto add_const = create_constant_with_zeros(Shape{1, 32, 1, 1}, {{}, {0, 1, 2, 3, 15, 16, 17, 18, 28, 29, 30, 31}, {}, {}}); + auto add = std::make_shared(concat, add_const); + + auto f = std::make_shared(NodeVector{add}, ParameterVector{input}); + + pass::Manager m; + m.register_pass(); + m.register_pass(); + m.run_passes(f); + + compare_masks(*getMask(weights_1.get_node_shared_ptr()->output(0)), Mask({{}, {}, {}, {}})); + compare_masks(*getMask(conv1->output(0)), Mask({{}, {}, {}, {}})); + + compare_masks(*getMask(weights_2.get_node_shared_ptr()->output(0)), Mask({{}, {}, {}, {}})); + compare_masks(*getMask(conv2->output(0)), Mask({{}, {}, {}, {}})); + + compare_masks(*getMask(weights_3.get_node_shared_ptr()->output(0)), Mask({{}, {}, {}, {}})); + compare_masks(*getMask(conv3->output(0)), Mask({{}, {}, {}, {}})); + + compare_masks(*getMask(add_const.get_node_shared_ptr()->output(0)), Mask({{}, {}, {}, {}})); + compare_masks(*getMask(add->output(0)), Mask({{}, {}, {}, {}})); + + + compare_masks(*getMask(concat->output(0)), Mask({{}, {}, {}, {}})); +} From 327c3149f62e3eb186d0550e9d558d694e4c7a25 Mon Sep 17 00:00:00 2001 From: Anastasia Popova Date: Tue, 8 Jun 2021 09:53:39 +0300 Subject: [PATCH 013/178] Fixed feature dimension calculation in grouped_convolutions_fusing(). (#6054) * Fixed feature dim calculation in concat_convolutions(). * Fixed feature dim calculation in concat_convolutions(). * Added comments, added unit test. --- .../middle/passes/fusing/fuse_grouped_conv.py | 5 +- .../passes/fusing/fuse_grouped_conv_test.py | 106 ++++++++++++++++++ 2 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 model-optimizer/unit_tests/mo/middle/passes/fusing/fuse_grouped_conv_test.py diff --git a/model-optimizer/mo/middle/passes/fusing/fuse_grouped_conv.py b/model-optimizer/mo/middle/passes/fusing/fuse_grouped_conv.py index afb3de7648f0d7..bc256ca49905f0 100644 --- a/model-optimizer/mo/middle/passes/fusing/fuse_grouped_conv.py +++ b/model-optimizer/mo/middle/passes/fusing/fuse_grouped_conv.py @@ -87,7 +87,10 @@ def concat_convolutions(graph: Graph, start_node: Node, last_node: Node): weights_value = np.array(weights_node.value) bias_value = np.array(bias_node.value) if has_biases else None - feature_dim = 3 if graph.graph['layout'] == 'NHWC' else 0 + # gconv.get_weights_permute.perm contains permutation indices + # where feature dimension is set to zero position, so 0 value + # in gconv.get_weights_permute.inv indicates original feature dimension index + feature_dim = np.where(gconv.get_weights_permute.inv == 0)[0][0] for conv in conv_nodes[1:]: weights_value = np.concatenate((weights_value, conv.in_node(1).value), axis=feature_dim) diff --git a/model-optimizer/unit_tests/mo/middle/passes/fusing/fuse_grouped_conv_test.py b/model-optimizer/unit_tests/mo/middle/passes/fusing/fuse_grouped_conv_test.py new file mode 100644 index 00000000000000..8e8bc61077a5bd --- /dev/null +++ b/model-optimizer/unit_tests/mo/middle/passes/fusing/fuse_grouped_conv_test.py @@ -0,0 +1,106 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import unittest + +import numpy as np + +from mo.front.common.partial_infer.utils import int64_array +from mo.graph.graph import Node +from mo.middle.passes.fusing.fuse_grouped_conv import grouped_convolutions_fusing +from mo.ops.op import PermuteAttrs +from mo.utils.ir_engine.compare_graphs import compare_graphs +from unit_tests.utils.graph import build_graph, result, connect, regular_op_with_shaped_data, regular_op, shaped_data, \ + valued_const_with_data, shaped_const_with_data, valued_data + +nodes = { + **regular_op_with_shaped_data('placeholder1', [1, 16, 10, 10], {'type': 'Parameter'}), + + **valued_const_with_data('split_1_axis', int64_array(1), {'type': 'Const'}), + **regular_op('split_1', {'type': 'Split', 'can_be_fused': True}), + **shaped_data('split_1_data1', [1, 4, 10, 10]), + **shaped_data('split_1_data2', [1, 4, 10, 10]), + **shaped_data('split_1_data3', [1, 4, 10, 10]), + **shaped_data('split_1_data4', [1, 4, 10, 10]), + + **shaped_const_with_data('split_2_in_const_weights', int64_array([3, 3, 4, 16]), {'type': 'Const'}), + **regular_op('split_2', {'type': 'Split'}), + **valued_data('split_2_data1', np.zeros([3, 3, 4, 4])), + **valued_data('split_2_data2', np.zeros([3, 3, 4, 4])), + **valued_data('split_2_data3', np.zeros([3, 3, 4, 4])), + **valued_data('split_2_data4', np.zeros([3, 3, 4, 4])), + + **regular_op_with_shaped_data('conv2d_1', [1, 4, 8, 8], + {'type': 'Convolution', 'channel_dims': np.array([1]), 'pad': np.array([2, 2]), + 'stride': np.array([2, 2]), + 'get_weights_permute': PermuteAttrs.Permutation(perm=int64_array([3, 2, 0, 1]), + inv=int64_array([2, 3, 1, 0])), + 'group': 1, 'output': 4, 'output_shape': [1, 4, 8, 8], 'can_be_fused': True}), + **regular_op_with_shaped_data('conv2d_2', [1, 4, 8, 8], + {'type': 'Convolution', 'pad': np.array([2, 2]), 'stride': np.array([2, 2]), + 'can_be_fused': True}), + **regular_op_with_shaped_data('conv2d_3', [1, 4, 8, 8], + {'type': 'Convolution', 'pad': np.array([2, 2]), 'stride': np.array([2, 2]), + 'can_be_fused': True}), + **regular_op_with_shaped_data('conv2d_4', [1, 4, 8, 8], + {'type': 'Convolution', 'pad': np.array([2, 2]), 'stride': np.array([2, 2]), + 'can_be_fused': True}), + + **regular_op_with_shaped_data('concat', [1, 16, 8, 8], {'type': 'Concat', 'axis': np.array(1)}), + + **regular_op_with_shaped_data('fused_group_conv', [1, 16, 8, 8], + {'type': 'Convolution', 'channel_dims': np.array([1]), 'pad': np.array([2, 2]), + 'stride': np.array([2, 2]), + 'get_weights_permute': PermuteAttrs.Permutation(perm=int64_array([3, 2, 0, 1]), + inv=int64_array([2, 3, 1, 0])), + 'group': 1, 'output': 4, 'output_shape': [1, 4, 8, 8], 'can_be_fused': True}), + **shaped_const_with_data('new_weights_const', int64_array([3, 3, 4, 16]), {'type': 'Const'}), + + **result('result') +} + + +class FuseGroupedConvTest(unittest.TestCase): + def test_fuse_grouped_conv(self): + graph = build_graph(nodes, [*connect('placeholder1', '0:split_1'), *connect('split_1_axis', '1:split_1'), + ('split_1', 'split_1_data1', {'out': 0}), + ('split_1', 'split_1_data2', {'out': 1}), + ('split_1', 'split_1_data3', {'out': 2}), + ('split_1', 'split_1_data4', {'out': 3}), + + *connect('split_2_in_const_weights', 'split_2'), + ('split_2', 'split_2_data1', {'out': 0}), + ('split_2', 'split_2_data2', {'out': 1}), + ('split_2', 'split_2_data3', {'out': 2}), + ('split_2', 'split_2_data4', {'out': 3}), + + ('split_1_data1', 'conv2d_1', {'in': 0}), + ('split_1_data2', 'conv2d_2', {'in': 0}), + ('split_1_data3', 'conv2d_3', {'in': 0}), + ('split_1_data4', 'conv2d_4', {'in': 0}), + + ('split_2_data1', 'conv2d_1', {'in': 1}), + ('split_2_data2', 'conv2d_2', {'in': 1}), + ('split_2_data3', 'conv2d_3', {'in': 1}), + ('split_2_data4', 'conv2d_4', {'in': 1}), + + *connect('conv2d_1', '0:concat'), + *connect('conv2d_2', '1:concat'), + *connect('conv2d_3', '2:concat'), + *connect('conv2d_4', '3:concat'), + + *connect('concat', 'result')]) + + graph_ref = build_graph(nodes, [*connect('placeholder1', '0:fused_group_conv'), + *connect('new_weights_const', '1:fused_group_conv'), + *connect('fused_group_conv', 'result')]) + + graph.graph['layout'] = 'NCHW' + grouped_convolutions_fusing(graph) + + (flag, resp) = compare_graphs(graph, graph_ref, 'result') + self.assertTrue(flag, resp) + + group_conv_node = Node(graph, 'conv2d_1') + group_conv_weights_shape = group_conv_node.in_node(1).shape + self.assertTrue((group_conv_weights_shape == int64_array([3, 3, 4, 16])).all()) From d3beab79b22b84268d489d727295641c0817f289 Mon Sep 17 00:00:00 2001 From: Pavel Esir Date: Tue, 8 Jun 2021 10:12:35 +0300 Subject: [PATCH 014/178] [nG] fix strided_slice_to_crop (#6032) --- .../convert_strided_slice_to_crop.cpp | 11 ++-- .../convert_strided_slice_to_crop_test.cpp | 52 ++++++++++++++++++- 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/inference-engine/src/legacy_api/src/transformations/convert_opset1_to_legacy/convert_strided_slice_to_crop.cpp b/inference-engine/src/legacy_api/src/transformations/convert_opset1_to_legacy/convert_strided_slice_to_crop.cpp index a3ec122b9c7ab3..cab07f54a762e6 100644 --- a/inference-engine/src/legacy_api/src/transformations/convert_opset1_to_legacy/convert_strided_slice_to_crop.cpp +++ b/inference-engine/src/legacy_api/src/transformations/convert_opset1_to_legacy/convert_strided_slice_to_crop.cpp @@ -9,7 +9,6 @@ #include #include - #include #include @@ -137,7 +136,6 @@ ngraph::pass::ConvertStridedSliceToCropMatcher::ConvertStridedSliceToCropMatcher lb = std::min(static_cast(input_shape[input_shape_idx]), lb); ub = std::min(static_cast(input_shape[input_shape_idx]), ub); - offset.emplace_back(lb); // set default value for stride or use given value int64_t stride = 1; @@ -153,6 +151,7 @@ ngraph::pass::ConvertStridedSliceToCropMatcher::ConvertStridedSliceToCropMatcher ub = -1; lb = std::min(lb, static_cast(input_shape[input_shape_idx]) - 1); + offset.emplace_back(lb); lb -= 1; // we always get 1st element, so we need decrease range if (ub <= lb) dimension = (ub - lb) / stride + 1; @@ -160,12 +159,16 @@ ngraph::pass::ConvertStridedSliceToCropMatcher::ConvertStridedSliceToCropMatcher // apply masks if (begin_mask.count(axis)) lb = 0; - if (end_mask.count(axis)) + offset.emplace_back(lb); + + if (end_mask.count(axis)) { ub = static_cast(input_shape[input_shape_idx]); + } lb += 1; // we always get 1st element, so we need decrease range - if (ub >= lb) + if (ub >= lb) { dimension = (ub - lb) / stride + 1; + } } dim.emplace_back(dimension); diff --git a/inference-engine/tests/functional/inference_engine/transformations/convert_strided_slice_to_crop_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/convert_strided_slice_to_crop_test.cpp index be5560f367ed94..731d96bbd3a2c9 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/convert_strided_slice_to_crop_test.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/convert_strided_slice_to_crop_test.cpp @@ -53,6 +53,7 @@ TEST(TransformationTests, ConvertStridedSliceToCropTests1) { manager.register_pass(); manager.register_pass(); manager.run_passes(f); + ASSERT_NO_THROW(check_rt_info(f)); } @@ -238,4 +239,53 @@ TEST(TransformationTests, ConvertStridedSliceToCropNegative2) { auto res = compare_functions(f, f_ref); ASSERT_TRUE(res.first) << res.second; -} \ No newline at end of file +} + + +TEST(TransformationTests, ConvertStridedSliceToCropNoneZeroBeginValuesWithMask) { + // when begin_mask/end_mask are present begin/end values should not affect output shape + std::shared_ptr f(nullptr), f_ref(nullptr); + { + auto input = std::make_shared(ngraph::element::f32, ngraph::Shape{1, 2, 4}); + auto slice_begin = ngraph::opset1::Constant::create(ngraph::element::i64, ngraph::Shape{4}, {0, 3, 2, 1}); + auto slice_end = ngraph::opset1::Constant::create(ngraph::element::i64, ngraph::Shape{4}, {0, 0, 0, 2}); + auto slice_stride = ngraph::opset1::Constant::create(ngraph::element::i64, ngraph::Shape{4}, {1, 1, 1, 1}); + + std::vector begin_mask = {1, 0, 1, 1}; + std::vector end_mask = {1, 0, 1, 0}; + std::vector new_axis_mask = {0, 1, 0, 0}; + std::vector shrink_axis_mask = {0, 0, 0, 0}; + std::vector ellipsis_mask = {0, 0, 0, 0}; + + auto sslice = std::make_shared(input, slice_begin, slice_end, slice_stride, + begin_mask, end_mask, + new_axis_mask, shrink_axis_mask, ellipsis_mask); + sslice->set_friendly_name("strided_slice"); + + f = std::make_shared(ngraph::NodeVector{sslice}, ngraph::ParameterVector{input}); + ngraph::pass::Manager manager; + manager.register_pass(); + manager.register_pass(); + manager.run_passes(f); + ASSERT_NO_THROW(check_rt_info(f)); + } + + { + auto input = std::make_shared(ngraph::element::f32, ngraph::Shape{1, 2, 4}); + + std::vector axes = {0, 1, 2, 3}; + std::vector dim = {1, 1, 2, 2}; + std::vector offset = {0, 0, 0, 0}; + + auto reshape = ngraph::op::util::reshapeTo(input, {1, 1, 2, 4}); + reshape->set_friendly_name("strided_slice/Reshape_for_Crop"); + + auto crop = std::make_shared(reshape, axes, dim, offset); + crop->set_friendly_name("strided_slice"); + + f_ref = std::make_shared(ngraph::NodeVector{crop}, ngraph::ParameterVector{input}); + } + + auto res = compare_functions(f, f_ref); + ASSERT_TRUE(res.first) << res.second; +} From 4409a74dcfd82af8b962d4e6b31f9b92934fff81 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Tue, 8 Jun 2021 10:16:37 +0300 Subject: [PATCH 015/178] samples: Fixed klocwork issues in speech (#6066) --- .../samples/speech_sample/fileutils.cpp | 41 +++++++++++-------- thirdparty/cnpy/cnpy.cpp | 12 +++--- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/inference-engine/samples/speech_sample/fileutils.cpp b/inference-engine/samples/speech_sample/fileutils.cpp index f3211a21a4b450..102cca25297444 100644 --- a/inference-engine/samples/speech_sample/fileutils.cpp +++ b/inference-engine/samples/speech_sample/fileutils.cpp @@ -108,15 +108,18 @@ void NumpyFile::GetFileInfo(const char* fileName, uint32_t numArrayToFindSize, u cnpy::npz_t my_npz1 = cnpy::npz_load(fileName); auto it = my_npz1.begin(); std::advance(it, numArrayToFindSize); - - numArrays = my_npz1.size(); - cnpy::NpyArray my_npy = it->second; - numMemoryBytes = my_npy.data_holder->size(); - - if (ptrNumArrays != NULL) - *ptrNumArrays = numArrays; - if (ptrNumMemoryBytes != NULL) - *ptrNumMemoryBytes = numMemoryBytes; + if (it != my_npz1.end()) { + numArrays = my_npz1.size(); + cnpy::NpyArray my_npy = it->second; + numMemoryBytes = my_npy.data_holder->size(); + + if (ptrNumArrays != NULL) + *ptrNumArrays = numArrays; + if (ptrNumMemoryBytes != NULL) + *ptrNumMemoryBytes = numMemoryBytes; + } else { + throw std::runtime_error(std::string("Failed to get info %s GetFileInfo()!\n") + fileName); + } } void NumpyFile::LoadFile(const char* fileName, uint32_t arrayIndex, std::string& ptrName, std::vector& memory, uint32_t* ptrNumRows, @@ -124,16 +127,20 @@ void NumpyFile::LoadFile(const char* fileName, uint32_t arrayIndex, std::string& cnpy::npz_t my_npz1 = cnpy::npz_load(fileName); auto it = my_npz1.begin(); std::advance(it, arrayIndex); - ptrName = it->first; - cnpy::NpyArray my_npy = it->second; - *ptrNumRows = my_npy.shape[0]; - *ptrNumColumns = my_npy.shape[1]; + if (it != my_npz1.end()) { + ptrName = it->first; + cnpy::NpyArray my_npy = it->second; + *ptrNumRows = my_npy.shape[0]; + *ptrNumColumns = my_npy.shape[1]; + + for (size_t i = 0; i < my_npy.data_holder->size(); i++) { + memory.at(i) = my_npy.data_holder->at(i); + } - for (size_t i = 0; i < my_npy.data_holder->size(); i++) { - memory.at(i) = my_npy.data_holder->at(i); + *ptrNumBytesPerElement = sizeof(float); + } else { + throw std::runtime_error(std::string("Failed to open %s for reading in LoadFile()!\n") + fileName); } - - *ptrNumBytesPerElement = sizeof(float); } void NumpyFile::SaveFile(const char* fileName, bool shouldAppend, std::string name, void* ptrMemory, uint32_t numRows, uint32_t numColumns) { diff --git a/thirdparty/cnpy/cnpy.cpp b/thirdparty/cnpy/cnpy.cpp index a3a3e0ef406660..26d0614bca1906 100644 --- a/thirdparty/cnpy/cnpy.cpp +++ b/thirdparty/cnpy/cnpy.cpp @@ -183,9 +183,9 @@ void cnpy::parse_zip_footer(FILE* fp, uint16_t& nrecs, size_t& global_header_siz } cnpy::NpyArray load_the_npy_file(FILE* fp) { - std::vector shape; - size_t word_size; - bool fortran_order; + std::vector shape(0); + size_t word_size = 0; + bool fortran_order = false; cnpy::parse_npy_header(fp,word_size,shape,fortran_order); if (word_size >= 0 && word_size < ULLONG_MAX) { cnpy::NpyArray arr(shape, word_size, fortran_order); @@ -225,9 +225,9 @@ cnpy::NpyArray load_the_npz_array(FILE* fp, uint32_t compr_bytes, uint32_t uncom err = inflate(&d_stream, Z_FINISH); err = inflateEnd(&d_stream); - std::vector shape; - size_t word_size; - bool fortran_order; + std::vector shape(0); + size_t word_size = 0; + bool fortran_order = false; cnpy::parse_npy_header(&buffer_uncompr[0],word_size,shape,fortran_order); if (word_size >= 0 && word_size < ULLONG_MAX) { cnpy::NpyArray array(shape, word_size, fortran_order); From 98f45ffbddc94ea480fa7e182345ba6dcaa7f680 Mon Sep 17 00:00:00 2001 From: Maxim Andronov Date: Tue, 8 Jun 2021 10:19:25 +0300 Subject: [PATCH 016/178] ConvertInterpolate1ToInterpolate4 fixes (#6019) * half_pixel -> asymmetric and round_prefer_floor -> simple in ConvertInterpolate1ToInterpolate4 * test fix --- .../convert_interpolate1_to_interpolate4.cpp | 10 ++++++++-- .../convert_interpolate1_to_interpolate4_test.cpp | 12 ++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/inference-engine/src/transformations/src/transformations/op_conversions/convert_interpolate1_to_interpolate4.cpp b/inference-engine/src/transformations/src/transformations/op_conversions/convert_interpolate1_to_interpolate4.cpp index 94173079c6203f..36a58551a68a03 100644 --- a/inference-engine/src/transformations/src/transformations/op_conversions/convert_interpolate1_to_interpolate4.cpp +++ b/inference-engine/src/transformations/src/transformations/op_conversions/convert_interpolate1_to_interpolate4.cpp @@ -68,14 +68,20 @@ ngraph::pass::ConvertInterpolate1ToInterpolate4::ConvertInterpolate1ToInterpolat return false; } attrsV4.shape_calculation_mode = ngraph::opset4::Interpolate::ShapeCalcMode::sizes; - attrsV4.nearest_mode = ngraph::opset4::Interpolate::NearestMode::round_prefer_floor; + attrsV4.nearest_mode = ngraph::opset4::Interpolate::NearestMode::simple; attrsV4.pads_begin = attrsV0.pads_begin; attrsV4.pads_end = attrsV0.pads_end; attrsV4.antialias = attrsV0.antialias; - attrsV4.coordinate_transformation_mode = ngraph::opset4::Interpolate::CoordinateTransformMode::half_pixel; + attrsV4.coordinate_transformation_mode = ngraph::opset4::Interpolate::CoordinateTransformMode::asymmetric; attrsV4.cube_coeff = -0.75f; if (attrsV0.align_corners) { attrsV4.coordinate_transformation_mode = ngraph::opset4::Interpolate::CoordinateTransformMode::align_corners; + } else if ((attrsV4.mode == ngraph::op::v4::Interpolate::InterpolateMode::linear_onnx || + attrsV4.mode == ngraph::op::v4::Interpolate::InterpolateMode::linear) && + std::all_of(attrsV4.pads_begin.begin(), attrsV4.pads_begin.end(), [](size_t i){return i == 0;}) && + std::all_of(attrsV4.pads_end.begin(), attrsV4.pads_end.end(), [](size_t i){return i == 0;}) && + !(input_shape_rank - 2 == 2 && attrsV0.axes == AxisSet{2, 3})) { + attrsV4.coordinate_transformation_mode = ngraph::opset4::Interpolate::CoordinateTransformMode::half_pixel; } auto interpolateV4 = std::make_shared(interpolationV0->input_value(0), interpolationV0->input_value(1), diff --git a/inference-engine/tests/functional/inference_engine/transformations/convert_interpolate1_to_interpolate4_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/convert_interpolate1_to_interpolate4_test.cpp index 9468db9287d855..12177f78cbcd4a 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/convert_interpolate1_to_interpolate4_test.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/convert_interpolate1_to_interpolate4_test.cpp @@ -54,7 +54,7 @@ TEST(TransformationTests, ConvertInterpolate1ToInterpolate4) { auto interpolate4_attr = opset4::Interpolate::InterpolateAttrs(opset4::Interpolate::InterpolateMode::nearest, opset4::Interpolate::ShapeCalcMode::sizes, std::vector{0, 0, 0, 0}, std::vector{0, 0, 0, 0}, - opset4::Interpolate::CoordinateTransformMode::asymmetric, opset4::Interpolate::NearestMode::floor, + opset4::Interpolate::CoordinateTransformMode::asymmetric, opset4::Interpolate::NearestMode::simple, false, -0.75); auto interpolate4 = std::make_shared(data_node, out_shape_node, default_scales_node, axes_node, interpolate4_attr); @@ -62,7 +62,7 @@ TEST(TransformationTests, ConvertInterpolate1ToInterpolate4) { f_ref = std::make_shared(NodeVector{interpolate4}, ParameterVector{data_node}); } - auto res = compare_functions(f, f_ref); + auto res = compare_functions(f, f_ref, true, false, false, true, true); ASSERT_TRUE(res.first) << res.second; } @@ -97,16 +97,16 @@ TEST(TransformationTests, ConvertInterpolate1ToInterpolate4_1) { auto default_scales_node = opset1::Constant::create(ngraph::element::f32, Shape{2}, {4.0f / 3.0f, 4.0f / 3.0f}); auto axes_node = opset1::Constant::create(ngraph::element::i64, Shape{2}, {2, 3}); - auto interpolate4_attr = opset4::Interpolate::InterpolateAttrs(opset4::Interpolate::InterpolateMode::linear, + auto interpolate4_attr = opset4::Interpolate::InterpolateAttrs(opset4::Interpolate::InterpolateMode::linear_onnx, opset4::Interpolate::ShapeCalcMode::sizes, std::vector{0, 0, 0, 0}, std::vector{0, 0, 0, 0}, - opset4::Interpolate::CoordinateTransformMode::align_corners, opset4::Interpolate::NearestMode::floor, - false, -0.75); + opset4::Interpolate::CoordinateTransformMode::asymmetric, opset4::Interpolate::NearestMode::simple, + true, -0.75); auto interpolate4 = std::make_shared(data_node, out_shape_node, default_scales_node, axes_node, interpolate4_attr); f_ref = std::make_shared(NodeVector{interpolate4}, ParameterVector{data_node}); } - auto res = compare_functions(f, f_ref); + auto res = compare_functions(f, f_ref, true, false, false, true, true); ASSERT_TRUE(res.first) << res.second; } From a99343f4ebd432324eb1e7262db1c77ad4fe7806 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Tue, 8 Jun 2021 11:00:02 +0300 Subject: [PATCH 017/178] Python tools (#6067) * Removed useless lines * Enable find PythonInterp only if we ENABLE_PYTHON * Enable docs only if python interp is found --- cmake/features.cmake | 5 +++-- .../conditional_compilation/CMakeLists.txt | 5 +---- tools/CMakeLists.txt | 19 ++++++++++--------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/cmake/features.cmake b/cmake/features.cmake index fe1b8919b51212..adb1fad25238da 100644 --- a/cmake/features.cmake +++ b/cmake/features.cmake @@ -18,8 +18,6 @@ Supported values:\ ie_option (ENABLE_PROFILING_FIRST_INFERENCE "Build with ITT tracing of first inference time." ON) -ie_option (ENABLE_DOCS "Build docs using Doxygen" OFF) - ie_option(ENABLE_TEMPLATE_PLUGIN "Register template plugin into plugins.xml" OFF) ie_option_enum(SELECTIVE_BUILD "Enable OpenVINO conditional compilation or statistics collection. \ @@ -33,6 +31,9 @@ ie_option(ENABLE_ERROR_HIGHLIGHT "Highlight errors and warnings during compile t find_package(PythonLibs 3 QUIET) ie_dependent_option (ENABLE_PYTHON "enables ie python bridge build" OFF "PYTHONLIBS_FOUND" OFF) +find_package(PythonInterp 3 QUIET) +ie_dependent_option (ENABLE_DOCS "Build docs using Doxygen" OFF "PYTHONINTERP_FOUND" OFF) + # # enable or disable output from NGRAPH_DEBUG statements # diff --git a/openvino/conditional_compilation/CMakeLists.txt b/openvino/conditional_compilation/CMakeLists.txt index 4a27ac50b7cb84..1db12d4eefbd0a 100644 --- a/openvino/conditional_compilation/CMakeLists.txt +++ b/openvino/conditional_compilation/CMakeLists.txt @@ -19,10 +19,7 @@ elseif(SELECTIVE_BUILD STREQUAL "ON") message(FATAL_ERROR "In case SELECTIVE_BUILD is enabled, the SELECTIVE_BUILD_STAT variable should contain the path to the collected InelSEAPI statistics.\ Usage: -DSELECTIVE_BUILD=ON -DSELECTIVE_BUILD_STAT=/path/*.csv") endif() - find_package (PythonInterp REQUIRED) - if(NOT PYTHON_VERSION_MAJOR EQUAL 3) - message(FATAL_ERROR " Python3 wasn't found!") - endif() + find_package (PythonInterp 3 REQUIRED) file(GLOB STAT_FILES ${SELECTIVE_BUILD_STAT}) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 0a09df95faa8bc..fdc6d9ef11a8f4 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,24 +1,25 @@ # Copyright (C) 2018-2021 Intel Corporation # SPDX-License-Identifier: Apache-2.0 cmake_minimum_required(VERSION 3.13) + project(python_tools) if(NOT DEFINED OpenVINO_MAIN_SOURCE_DIR) find_package(InferenceEngineDeveloperPackage QUIET) endif() -find_package(PythonInterp 3 REQUIRED) -set(PYTHON_VERSION python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) +if(ENABLE_PYTHON) + find_package(PythonInterp 3 REQUIRED) + set(PYTHON_VERSION python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) -set(TARGET_NAME "python_tools") + set(TARGET_NAME "python_tools") -if(WIN32) - set(PYTHON_BRIDGE_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$/python_api/${PYTHON_VERSION}/openvino) -else() - set(PYTHON_BRIDGE_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/python_api/${PYTHON_VERSION}/openvino) -endif() + if(WIN32) + set(PYTHON_BRIDGE_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$/python_api/${PYTHON_VERSION}/openvino) + else() + set(PYTHON_BRIDGE_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/python_api/${PYTHON_VERSION}/openvino) + endif() -if(ENABLE_PYTHON) # creates a copy inside bin directory for developers to have ability running python benchmark_app add_custom_target(${TARGET_NAME} ALL COMMAND ${CMAKE_COMMAND} -E make_directory ${PYTHON_BRIDGE_OUTPUT_DIRECTORY}/tools From 77d8973e91a91bbd3c92316b348599b444545839 Mon Sep 17 00:00:00 2001 From: Maxim Shevtsov Date: Tue, 8 Jun 2021 11:10:05 +0300 Subject: [PATCH 018/178] Perf Intro page brushing (#5861) * brushing * Update Intro_to_Performance.md --- docs/IE_DG/Intro_to_Performance.md | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/docs/IE_DG/Intro_to_Performance.md b/docs/IE_DG/Intro_to_Performance.md index 66fcf48c34f3c5..78d5c59c417d0f 100644 --- a/docs/IE_DG/Intro_to_Performance.md +++ b/docs/IE_DG/Intro_to_Performance.md @@ -1,24 +1,28 @@ # Introduction to the Performance Topics {#openvino_docs_IE_DG_Intro_to_Performance} This section is a shorter version of the -[Optimization Guide](supported_plugins/MULTI.md) for the Intel Deep Learning Deployment Toolkit. +[Optimization Guide](../optimization_guide/dldt_optimization_guide.md) for the Intel® Distribution of OpenVINO™ Toolkit. ## Precision Inference precision directly affects the performance. -Model Optimizer can produce an IR with different precision. For example, float16 IR initially targets VPU and GPU devices, while, for example, the CPU can also execute regular float32. -Also, further device-specific inference precision settings are available, for example, [8-bit integer](Int8Inference.md) or [bfloat16](Bfloat16Inference.md) inference on the CPU. -Note that for [MULTI device](supported_plugins/MULTI.md) that supports automatic inference on multiple devices in parallel, you can use the FP16 IR. +Model Optimizer can produce an IR with different precision. For example, an FP16 IR initially targets VPU and GPU devices, while, for example, for the CPU, an FP16 IR is typically up-scaled to the regular FP32 automatically upon loading. But notice that further device-specific inference precision settings are available, +for example, [8-bit integer](Int8Inference.md) or [bfloat16](Bfloat16Inference.md), which is specific to the CPU inference, below. +Note that for the [MULTI device](supported_plugins/MULTI.md) plugin that supports automatic inference on multiple devices in parallel, you can use an FP16 IR (no need for FP32). You can find more information, including preferred data types for specific devices, in the -[Supported Devices](supported_plugins/Supported_Devices.md) section. +[Supported Devices](supported_plugins/Supported_Devices.md) document. -## Lowering Inference Precision -Default optimization is used for CPU and implies that inference is made with lower precision if it is possible on a given platform to reach better performance with acceptable range of accuracy. -This approach can be used for CPU devices where the platform supports the AVX512_BF16 instruction. In this case, a regular float32 model is converted to [bfloat16](Bfloat16Inference.md) internal representation and inference is provided with bfloat16 layers usage. -Below is the example command line to disable this feature on the CPU device with the AVX512_BF16 instruction and execute regular float32. +## Automatic Lowering of the Inference Precision +By default, plugins enable the optimizations that allow lower precision if the acceptable range of accuracy is preserved. +For example, for the CPU that supports the AVX512_BF16 instructions, an FP16/FP32 model is converted to a [bfloat16](Bfloat16Inference.md) IR to accelerate inference. +To compare the associated speedup, run the example command below to disable this feature on the CPU device with the AVX512_BF16 support and get regular FP32 execution: ``` $ benchmark_app -m -enforcebf16=false ``` +Notice that for quantized (e.g. INT8) models the bfloat16 calculations (of the layers that remain in FP32) is disabled by default. +Refer to the [CPU Plugin documentation](supported_plugins/CPU.md) for more details. + +Similarly, the GPU device has a dedicated config key to enable FP16 execution of the layers that remain in FP32 in the quantized models (as the quantization is typically performed on the FP32 models), refer to the ENABLE_FP16_FOR_QUANTIZED_MODELS key in the [GPU Plugin documentation](supported_plugins/CL_DNN.md) ## Latency vs. Throughput One way to increase computational efficiency is batching, which combines many (potentially tens) of @@ -44,17 +48,17 @@ Below is the example command line that limits the execution to the single socket limited to the single socket). $ numactl -m 0 --physcpubind 0-27 benchmark_app -m -api sync -nthreads 28 ``` -Note that if you have more than one input, running as many inference requests as you have NUMA nodes (or sockets) +Note that if you have more than one input, running as many inference streams as you have NUMA nodes (or sockets) usually gives the same best latency as a single request on the single socket, but much higher throughput. Assuming two NUMA nodes machine: ``` $ benchmark_app -m -nstreams 2 ``` Number of NUMA nodes on the machine can be queried via 'lscpu'. -Please see more on the NUMA support in the [Optimization Guide](supported_plugins/MULTI.md). +Please see more on the NUMA support in the [Optimization Guide](../optimization_guide/dldt_optimization_guide.md). ## Throughput Mode for CPU Unlike most accelerators, CPU is perceived as an inherently latency-oriented device. -Since 2018 R5 release, the Inference Engine introduced the "throughput" mode, which allows the Inference Engine to efficiently run multiple inference requests on the CPU simultaneously, greatly improving the throughput. +OpenVINO™ toolkit provides a "throughput" mode that allows running multiple inference requests on the CPU simultaneously, which greatly improves the throughput. Internally, the execution resources are split/pinned into execution "streams". Using this feature gains much better performance for the networks that originally are not scaled well with a number of threads (for example, lightweight topologies). This is especially pronounced for the many-core server machines. @@ -62,8 +66,6 @@ Using this feature gains much better performance for the networks that originall Run the [Benchmark App](../../inference-engine/samples/benchmark_app/README.md) and play with number of infer requests running in parallel, next section. Try different values of the `-nstreams` argument from `1` to a number of CPU cores and find one that provides the best performance. -In addition to the number of streams, it is also possible to play with the batch size to find the throughput sweet-spot. - The throughput mode relaxes the requirement to saturate the CPU by using a large batch: running multiple independent inference requests in parallel often gives much better performance, than using a batch only. This allows you to simplify the app-logic, as you don't need to combine multiple inputs into a batch to achieve good CPU performance. Instead, it is possible to keep a separate infer request per camera or another source of input and process the requests in parallel using Async API. From 9049dee86243d7677eb00fd173a3860562516ad7 Mon Sep 17 00:00:00 2001 From: Maxim Andronov Date: Tue, 8 Jun 2021 11:10:56 +0300 Subject: [PATCH 019/178] klocwork 2021.4 (#6042) --- .../InferenceEngine_network_with_state_infer.cpp | 6 ++++++ .../src/convert_function_to_cnn_network.cpp | 3 +++ .../ngraph_transformations/reshape_fc_fusion.cpp | 6 ++++++ .../reshape_fully_connected.cpp | 2 ++ .../src/mkldnn_plugin/nodes/mkldnn_dft_node.cpp | 2 +- .../nodes/mkldnn_gather_elements_node.h | 2 +- .../nodes/mkldnn_strided_slice_node.cpp | 8 ++++++-- .../nodes/mkldnn_tensoriterator_node.cpp | 12 ++++++++++++ 8 files changed, 37 insertions(+), 4 deletions(-) diff --git a/docs/snippets/InferenceEngine_network_with_state_infer.cpp b/docs/snippets/InferenceEngine_network_with_state_infer.cpp index 81a3070ba3b319..7af9c076931169 100644 --- a/docs/snippets/InferenceEngine_network_with_state_infer.cpp +++ b/docs/snippets/InferenceEngine_network_with_state_infer.cpp @@ -64,7 +64,13 @@ int main(int argc, char *argv[]) { inferRequest.Infer(); // check states auto states = inferRequest.QueryState(); + if (states.empty()) { + throw std::runtime_error("Queried states are empty"); + } auto mstate = as(states[0].GetState()); + if (mstate == nullptr) { + throw std::runtime_error("Can't cast state to MemoryBlob"); + } auto state_buf = mstate->rmap(); float * state =state_buf.as(); std::cout << state[0] << "\n"; diff --git a/inference-engine/src/legacy_api/src/convert_function_to_cnn_network.cpp b/inference-engine/src/legacy_api/src/convert_function_to_cnn_network.cpp index 08b54640ee6e26..7d92c77219d834 100644 --- a/inference-engine/src/legacy_api/src/convert_function_to_cnn_network.cpp +++ b/inference-engine/src/legacy_api/src/convert_function_to_cnn_network.cpp @@ -244,6 +244,9 @@ CNNLayer::Ptr createSubGraphLayer(const std::shared_ptr& layer) { LayerParams params = {layer->get_friendly_name(), "TensorIterator", details::convertPrecision(layer->get_output_element_type(0))}; auto res = std::make_shared(params); + if (res == nullptr) { + IE_THROW() << "Can't create TensorIterator"; + } res->body = body; // Port map: outputs diff --git a/inference-engine/src/mkldnn_plugin/ngraph_transformations/reshape_fc_fusion.cpp b/inference-engine/src/mkldnn_plugin/ngraph_transformations/reshape_fc_fusion.cpp index 09d3e7e05540bd..b850bd98ae2979 100644 --- a/inference-engine/src/mkldnn_plugin/ngraph_transformations/reshape_fc_fusion.cpp +++ b/inference-engine/src/mkldnn_plugin/ngraph_transformations/reshape_fc_fusion.cpp @@ -22,7 +22,11 @@ MKLDNNPlugin::ReshapeFullyConnectedFusion::ReshapeFullyConnectedFusion() { ngraph::matcher_pass_callback callback = [this](ngraph::pattern::Matcher &m) { auto fc = std::dynamic_pointer_cast(m.get_match_root()); + if (!fc) + return false; auto reshape = std::dynamic_pointer_cast(fc->get_input_node_shared_ptr(0)); + if (!reshape) + return false; // Check that Reshape reshapes 4D tensor to 2D or input shape = output shape auto shape_in = reshape->input_value(0).get_shape(); @@ -67,6 +71,8 @@ MKLDNNPlugin::ReshapeFullyConnectedFusion::ReshapeFullyConnectedFusion() { fc->input_value(2), outShape, fc->output(0).get_element_type()); + } else { + return false; } new_ops.push_back(new_fc); new_fc->set_friendly_name(fc->get_friendly_name()); diff --git a/inference-engine/src/mkldnn_plugin/ngraph_transformations/reshape_fully_connected.cpp b/inference-engine/src/mkldnn_plugin/ngraph_transformations/reshape_fully_connected.cpp index 999d1b958d8d91..f140f44e74e701 100644 --- a/inference-engine/src/mkldnn_plugin/ngraph_transformations/reshape_fully_connected.cpp +++ b/inference-engine/src/mkldnn_plugin/ngraph_transformations/reshape_fully_connected.cpp @@ -60,6 +60,8 @@ MKLDNNPlugin::ReshapeFullyConnected::ReshapeFullyConnected() { fc->input_value(2), output_shape_new, fc->get_output_type()); + } else { + return false; } new_ops.push_back(fc_new); diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_dft_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_dft_node.cpp index 21fb93728c17fb..b9ef511d010fce 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_dft_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_dft_node.cpp @@ -49,7 +49,7 @@ MKLDNNDFTNode::MKLDNNDFTNode(const std::shared_ptr& op, const mkld /* Data */ inputShape = inDims[DATA_INDEX].ToSizeVector(); - if (inputShape.size() < 1) { + if (inputShape.size() < 2) { IE_THROW() << layerErrorPrefix << " has invalid 'data' input tensor with rank: " << inputShape.size(); } diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_gather_elements_node.h b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_gather_elements_node.h index 30d1fda9e9553d..bc19866768dfcf 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_gather_elements_node.h +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_gather_elements_node.h @@ -32,7 +32,7 @@ class MKLDNNGatherElementsNode : public MKLDNNNode { size_t dataTypeSize_; int strideAxDst_; int dstAxDim_; - int strideAx1Diff_; + int strideAx1Diff_ = 0; std::string errorPrefix_; template diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_strided_slice_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_strided_slice_node.cpp index 07cc72247a5eff..1b70de9f0f8341 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_strided_slice_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_strided_slice_node.cpp @@ -86,7 +86,7 @@ MKLDNNStridedSliceNode::MKLDNNStridedSliceNode(const std::shared_ptrisConstant() && node->getType() == Input; + return node->getType() == Input && node->isConstant(); }; params.parametersAreConstant = isConstantNode(getParentEdgesAtPort(BEGIN_ID)[0]->getParent()) && @@ -138,7 +138,11 @@ void MKLDNNStridedSliceNode::getSupportedDescriptors() { if (params.parametersAreConstant) { auto fillingInParameters = [&](std::vector ¶meter, const size_t type, const size_t size, const int value) { - auto blob = std::dynamic_pointer_cast(getParentEdgesAtPort(type)[0]->getParent())->getMemoryPtr(); + const auto constNode = std::dynamic_pointer_cast(getParentEdgesAtPort(type)[0]->getParent()); + if (!constNode) { + THROW_ERROR << "can't cast node on " << type << " port to MKLDNNInputNode"; + } + auto blob = constNode->getMemoryPtr(); if (blob->GetDataType() != mkldnn::memory::data_type::s32) THROW_ERROR << "supports only parameters input with precision I32"; const int *ptr = static_cast(blob->GetPtr()); diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_tensoriterator_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_tensoriterator_node.cpp index c9a53c79e07865..d1d80e1b7cba7b 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_tensoriterator_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_tensoriterator_node.cpp @@ -136,6 +136,9 @@ class IterCountPortHelper : public PortMapHelper { void execute(mkldnn::stream strm, int n_iter) override { auto mem = mem_holder_dst; auto data_ptr = static_cast(mem.get_data_handle()); + if (data_ptr == nullptr) { + IE_THROW() << "TensorIterator node has not allocated memory for IterCountPortHelper"; + } *data_ptr = n_iter; } }; @@ -150,6 +153,9 @@ class asBoolCheck : public PortChecker { int getStatus() override { auto data_ptr = static_cast(mem_holder.get_data_handle()); + if (data_ptr == nullptr) { + IE_THROW() << "TensorIterator node has not allocated memory for asBoolCheck"; + } return *data_ptr == static_cast(0) ? 0 : 1; } }; @@ -164,6 +170,9 @@ class asIntCheck : public PortChecker { int getStatus() override { auto data_ptr = static_cast(mem_holder.get_data_handle()); + if (data_ptr == nullptr) { + IE_THROW() << "TensorIterator node has not allocated memory for asIntCheck"; + } return *data_ptr; } }; @@ -283,6 +292,9 @@ MKLDNNTensorIteratorNode::MKLDNNTensorIteratorNode(const std::shared_ptr(ngraphOp); + if (tiOp == nullptr) { + IE_THROW() << "Can't cast TensorIterator node with name: " << getName() << " to ngraph::op::util::SubGraphOp"; + } const std::shared_ptr body = tiOp->get_function(); sub_graph.CreateGraph(body, ext_mng, weightCache); From 713e4e1ebe231821e5da6c3e5461d724cb7490c9 Mon Sep 17 00:00:00 2001 From: Mikhail Kozlov Date: Tue, 8 Jun 2021 11:17:04 +0300 Subject: [PATCH 020/178] Fix filling input blob for benchmark_app (#6055) * Fix filling input blob for benchmark_app * Fix clang format --- .../samples/benchmark_app/inputs_filling.cpp | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/inference-engine/samples/benchmark_app/inputs_filling.cpp b/inference-engine/samples/benchmark_app/inputs_filling.cpp index e12f7656f173c6..ef8a045279a57a 100644 --- a/inference-engine/samples/benchmark_app/inputs_filling.cpp +++ b/inference-engine/samples/benchmark_app/inputs_filling.cpp @@ -39,6 +39,7 @@ std::vector filterFilesByExtensions(const std::vector& return filtered; } +template void fillBlobImage(Blob::Ptr& inputBlob, const std::vector& filePaths, const size_t& batchSize, const benchmark_app::InputInfo& app_info, const size_t& requestId, const size_t& inputId, const size_t& inputSize) { MemoryBlob::Ptr minput = as(inputBlob); @@ -50,7 +51,7 @@ void fillBlobImage(Blob::Ptr& inputBlob, const std::vector& filePat // locked memory holder should be alive all time while access to its buffer // happens auto minputHolder = minput->wmap(); - auto inputBlobData = minputHolder.as(); + auto inputBlobData = minputHolder.as(); /** Collect images data ptrs **/ std::vector> vreader; @@ -90,7 +91,7 @@ void fillBlobImage(Blob::Ptr& inputBlob, const std::vector& filePat size_t offset = imageId * numChannels * width * height + (((app_info.layout == "NCHW") || (app_info.layout == "CHW")) ? (ch * width * height + h * width + w) : (h * width * numChannels + w * numChannels + ch)); - inputBlobData[offset] = vreader.at(imageId).get()[h * width * numChannels + w * numChannels + ch]; + inputBlobData[offset] = static_cast(vreader.at(imageId).get()[h * width * numChannels + w * numChannels + ch]); } } } @@ -142,7 +143,7 @@ using uniformDistribution = typename std::conditional::value, std::uniform_int_distribution, void>::type>::type; template -void fillBlobRandom(Blob::Ptr& inputBlob, T rand_min = std::numeric_limits::min(), T rand_max = std::numeric_limits::max()) { +void fillBlobRandom(Blob::Ptr& inputBlob, T rand_min = std::numeric_limits::min(), T rand_max = std::numeric_limits::max()) { MemoryBlob::Ptr minput = as(inputBlob); if (!minput) { IE_THROW() << "We expect inputBlob to be inherited from MemoryBlob in " @@ -270,7 +271,19 @@ void fillBlobs(const std::vector& inputFiles, const size_t& batchSi if (app_info.isImage()) { if (!imageFiles.empty()) { // Fill with Images - fillBlobImage(inputBlob, imageFiles, batchSize, app_info, requestId, imageInputId++, imageInputCount); + if (precision == InferenceEngine::Precision::FP32) { + fillBlobImage(inputBlob, imageFiles, batchSize, app_info, requestId, imageInputId++, imageInputCount); + } else if (precision == InferenceEngine::Precision::FP16) { + fillBlobImage(inputBlob, imageFiles, batchSize, app_info, requestId, imageInputId++, imageInputCount); + } else if (precision == InferenceEngine::Precision::I32) { + fillBlobImage(inputBlob, imageFiles, batchSize, app_info, requestId, imageInputId++, imageInputCount); + } else if (precision == InferenceEngine::Precision::I64) { + fillBlobImage(inputBlob, imageFiles, batchSize, app_info, requestId, imageInputId++, imageInputCount); + } else if (precision == InferenceEngine::Precision::U8) { + fillBlobImage(inputBlob, imageFiles, batchSize, app_info, requestId, imageInputId++, imageInputCount); + } else { + IE_THROW() << "Input precision is not supported for " << item.first; + } continue; } } else { From eadf2c4ce09d4bde216fee4ad48eac1c5162b35b Mon Sep 17 00:00:00 2001 From: Kate Generalova Date: Tue, 8 Jun 2021 12:03:25 +0300 Subject: [PATCH 021/178] samples: update ngraph README (#6070) --- .../ngraph_function_creation_sample/README.md | 16 ++++++++++------ .../ngraph_function_creation_sample/README.md | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/inference-engine/ie_bridges/python/sample/ngraph_function_creation_sample/README.md b/inference-engine/ie_bridges/python/sample/ngraph_function_creation_sample/README.md index c33d67103c6954..f0701f963aea20 100644 --- a/inference-engine/ie_bridges/python/sample/ngraph_function_creation_sample/README.md +++ b/inference-engine/ie_bridges/python/sample/ngraph_function_creation_sample/README.md @@ -1,7 +1,8 @@ # nGraph Function Creation Python* Sample {#openvino_inference_engine_ie_bridges_python_sample_ngraph_function_creation_sample_README} -This sample demonstrates how to execute an inference using [nGraph function feature](../../../../../docs/nGraph_DG/build_function.md) to create a network that uses weights from LeNet classification network. So you don't need an XML file, the model will be created from the source code on the fly. -In addition to regular images, the sample also supports single-channel ubyte images as an input. +This sample demonstrates how to execute an inference using [nGraph function feature](../../../../../docs/nGraph_DG/build_function.md) to create a network that uses weights from LeNet classification network, which is known to work well on digit classification tasks. So you don't need an XML file, the model will be created from the source code on the fly. + +In addition to regular grayscale images with a digit, the sample also supports single-channel `ubyte` images as an input. The following Inference Engine Python API is used in the application: @@ -14,6 +15,9 @@ Basic Inference Engine API is covered by [Hello Classification Python* Sample](. | Options | Values | | :------------------------- | :---------------------------------------------------------------------- | +| Validated Models | LeNet (image classification network) | +| Model Format | Network weights file (\*.bin) | +| Validated images | The sample uses OpenCV\* to [read input grayscale image](https://docs.opencv.org/master/d4/da8/group__imgcodecs.html#ga288b8b3da0892bd651fce07b3bbd3a56) (\*.bmp, \*.png) or single-channel `ubyte` image | | Supported devices | [All](../../../../../docs/IE_DG/supported_plugins/Supported_Devices.md) | | Other language realization | [C++](../../../../samples/ngraph_function_creation_sample) | @@ -72,7 +76,7 @@ To run the sample, you need specify a model weights and image: You can do inference of an image using a pre-trained model on a GPU using the following command: ```sh -python ngraph_function_creation_sample.py -m /lenet.bin -i /3.bmp -d GPU +python ngraph_function_creation_sample.py -m /lenet.bin -i /3.png -d GPU ``` ## Sample Output @@ -84,10 +88,10 @@ The sample application logs each step in a standard output stream and outputs to [ INFO ] Loading the network using ngraph function with weights from /lenet.bin [ INFO ] Configuring input and output blobs [ INFO ] Loading the model to the plugin -[ WARNING ] /3.bmp is inverted to white over black -[ WARNING ] /3.bmp is resized from (100, 100) to (28, 28) +[ WARNING ] /3.png is inverted to white over black +[ WARNING ] /3.png is is resized from (351, 353) to (28, 28) [ INFO ] Starting inference in synchronous mode -[ INFO ] Image path: /3.bmp +[ INFO ] Image path: /3.png [ INFO ] Top 10 results: [ INFO ] classid probability [ INFO ] ------------------- diff --git a/inference-engine/samples/ngraph_function_creation_sample/README.md b/inference-engine/samples/ngraph_function_creation_sample/README.md index 1410241c3a595b..9f7b4f8d4337ee 100644 --- a/inference-engine/samples/ngraph_function_creation_sample/README.md +++ b/inference-engine/samples/ngraph_function_creation_sample/README.md @@ -1,6 +1,6 @@ # nGraph Function Creation C++ Sample {#openvino_inference_engine_samples_ngraph_function_creation_sample_README} -This sample demonstrates how to execute an synchronous inference using [nGraph function feature](../../../docs/nGraph_DG/build_function.md) to create a network, which uses weights from LeNet classification network. +This sample demonstrates how to execute an synchronous inference using [nGraph function feature](../../../docs/nGraph_DG/build_function.md) to create a network, which uses weights from LeNet classification network, which is known to work well on digit classification tasks. The sample supports only single-channel `ubyte` images as an input. From dcf36565b0476a5ef45f678238f7359f41df081c Mon Sep 17 00:00:00 2001 From: Shoujiang Ma Date: Tue, 8 Jun 2021 17:11:58 +0800 Subject: [PATCH 022/178] [AUTO plugin] AUTO plugin will ignore other plugins' configuration (#5979) * AUTO plugin will ignore other plugins' configuration Signed-off-by: Shoujiang Ma * Update tests Signed-off-by: Shoujiang Ma * Support PER_COUNT config which is needed in benchmark_app Signed-off-by: Shoujiang Ma * Address reviewer comments: check config and throw exception for unsupported, but that begin with "AUTO_" will be ignored Signed-off-by: Shoujiang Ma * Fix CI tests issue Signed-off-by: Shoujiang Ma --- .../src/auto_plugin/auto_exec_network.cpp | 8 +- .../src/auto_plugin/auto_exec_network.hpp | 8 +- .../src/auto_plugin/auto_infer_request.cpp | 16 +++- .../src/auto_plugin/auto_infer_request.hpp | 4 +- .../src/auto_plugin/auto_plugin.cpp | 84 ++++++++++--------- .../src/auto_plugin/auto_plugin.hpp | 23 +++-- .../behavior/config.cpp | 44 ++-------- .../behavior/infer_request_config.cpp | 15 +--- .../behavior/infer_request_input.cpp | 4 +- .../behavior/infer_request_output.cpp | 4 +- .../behavior/perf_counters.cpp | 11 --- .../behavior/test_plugin.cpp | 4 +- .../skip_tests_config.cpp | 2 + .../behavior/config.cpp | 11 ++- .../behavior/infer_request_input.cpp | 4 +- .../behavior/infer_request_output.cpp | 3 +- .../behavior/perf_counters.cpp | 22 ----- .../behavior/test_plugin.cpp | 22 ++--- .../plugin/shared/include/behavior/config.hpp | 29 ++++--- .../include/behavior/infer_request_config.hpp | 12 ++- 20 files changed, 140 insertions(+), 190 deletions(-) diff --git a/inference-engine/src/auto_plugin/auto_exec_network.cpp b/inference-engine/src/auto_plugin/auto_exec_network.cpp index 353196a88d4a41..49b0963c04d35e 100644 --- a/inference-engine/src/auto_plugin/auto_exec_network.cpp +++ b/inference-engine/src/auto_plugin/auto_exec_network.cpp @@ -3,10 +3,8 @@ // #include -#include #include #include -#include #include "ie_metric_helpers.hpp" #include "auto_exec_network.hpp" @@ -15,8 +13,8 @@ namespace AutoPlugin { using namespace InferenceEngine; -AutoExecutableNetwork::AutoExecutableNetwork(const SoExecutableNetworkInternal& network) : - _network(network) { +AutoExecutableNetwork::AutoExecutableNetwork(const SoExecutableNetworkInternal& network, bool enablePerfCount) : + _network(network), _enablePerfCount(enablePerfCount) { } AutoExecutableNetwork::~AutoExecutableNetwork() = default; @@ -24,7 +22,7 @@ AutoExecutableNetwork::~AutoExecutableNetwork() = default; InferenceEngine::IInferRequestInternal::Ptr AutoExecutableNetwork::CreateInferRequestImpl(InputsDataMap networkInputs, OutputsDataMap networkOutputs) { SoIInferRequestInternal inferRequest = {_network, _network->CreateInferRequest()}; - return std::make_shared(_networkInputs, _networkOutputs, inferRequest); + return std::make_shared(_networkInputs, _networkOutputs, inferRequest, _enablePerfCount); } void AutoExecutableNetwork::Export(std::ostream& networkModel) { diff --git a/inference-engine/src/auto_plugin/auto_exec_network.hpp b/inference-engine/src/auto_plugin/auto_exec_network.hpp index a39478b19a753a..e29970711ebc15 100644 --- a/inference-engine/src/auto_plugin/auto_exec_network.hpp +++ b/inference-engine/src/auto_plugin/auto_exec_network.hpp @@ -19,16 +19,11 @@ namespace AutoPlugin { using DeviceName = std::string; -struct DeviceInformation { - DeviceName deviceName; - std::map config; -}; - class AutoExecutableNetwork : public InferenceEngine::IExecutableNetworkInternal { public: using Ptr = std::shared_ptr; - explicit AutoExecutableNetwork(const InferenceEngine::SoExecutableNetworkInternal& network); + explicit AutoExecutableNetwork(const InferenceEngine::SoExecutableNetworkInternal& network, bool enablePerfCount); void Export(std::ostream& networkModel) override; InferenceEngine::RemoteContext::Ptr GetContext() const override; @@ -43,6 +38,7 @@ class AutoExecutableNetwork : public InferenceEngine::IExecutableNetworkInternal private: InferenceEngine::SoExecutableNetworkInternal _network; + bool _enablePerfCount; }; } // namespace AutoPlugin diff --git a/inference-engine/src/auto_plugin/auto_infer_request.cpp b/inference-engine/src/auto_plugin/auto_infer_request.cpp index f0777409830d68..46d603187152f7 100644 --- a/inference-engine/src/auto_plugin/auto_infer_request.cpp +++ b/inference-engine/src/auto_plugin/auto_infer_request.cpp @@ -11,13 +11,23 @@ namespace AutoPlugin { AutoInferRequest::AutoInferRequest(const InputsDataMap& networkInputs, const OutputsDataMap& networkOutputs, - const SoIInferRequestInternal& inferRequest) + const SoIInferRequestInternal& inferRequest, + bool enablePerfCount) : IInferRequestInternal(networkInputs, networkOutputs) - , _inferRequest(inferRequest) { + , _inferRequest(inferRequest) + , _enablePerfCount(enablePerfCount) { } std::map AutoInferRequest::GetPerformanceCounts() const { - return _inferRequest->GetPerformanceCounts(); + if (_enablePerfCount) { + try { + return _inferRequest->GetPerformanceCounts(); + } catch (...) { + return {}; + } + } else { + return {}; + } } void AutoInferRequest::InferImpl() { diff --git a/inference-engine/src/auto_plugin/auto_infer_request.hpp b/inference-engine/src/auto_plugin/auto_infer_request.hpp index 1ccaf0093b27b3..c97b2fa5aedd49 100644 --- a/inference-engine/src/auto_plugin/auto_infer_request.hpp +++ b/inference-engine/src/auto_plugin/auto_infer_request.hpp @@ -24,7 +24,8 @@ class AutoInferRequest : public InferenceEngine::IInferRequestInternal { using Ptr = std::shared_ptr; explicit AutoInferRequest(const InferenceEngine::InputsDataMap& networkInputs, const InferenceEngine::OutputsDataMap& networkOutputs, - const InferenceEngine::SoIInferRequestInternal& inferRequest); + const InferenceEngine::SoIInferRequestInternal& inferRequest, + bool enablePerfCount); std::map GetPerformanceCounts() const override; void InferImpl() override; void SetBlob(const std::string& name, const InferenceEngine::Blob::Ptr& data) override; @@ -37,6 +38,7 @@ class AutoInferRequest : public InferenceEngine::IInferRequestInternal { private: InferenceEngine::SoIInferRequestInternal _inferRequest; + bool _enablePerfCount; }; } // namespace AutoPlugin diff --git a/inference-engine/src/auto_plugin/auto_plugin.cpp b/inference-engine/src/auto_plugin/auto_plugin.cpp index 1fc20063575c5c..274fa9d224f23f 100644 --- a/inference-engine/src/auto_plugin/auto_plugin.cpp +++ b/inference-engine/src/auto_plugin/auto_plugin.cpp @@ -75,11 +75,11 @@ IE::QueryNetworkResult AutoInferencePlugin::QueryNetwork(const IE::CNNNetwork& n } auto fullConfig = mergeConfigs(_config, config); - auto metaDevices = GetDeviceChoice(fullConfig); + auto metaDevices = GetDeviceList(fullConfig); std::unordered_set supportedLayers; for (auto&& value : metaDevices) { try { - auto deviceQr = GetCore()->QueryNetwork(network, value.deviceName, value.config); + auto deviceQr = GetCore()->QueryNetwork(network, value, {}); std::unordered_set deviceSupportedLayers; for (auto &&layerQr : deviceQr.supportedLayersMap) { deviceSupportedLayers.emplace(layerQr.first); @@ -111,7 +111,19 @@ IE::Parameter AutoInferencePlugin::GetConfig(const std::string& name, void AutoInferencePlugin::SetConfig(const ConfigType& config) { for (auto && kvp : config) { - _config[kvp.first] = kvp.second; + if (kvp.first.find("AUTO_") == 0) { + _config[kvp.first] = kvp.second; + } else if (kvp.first == IE::PluginConfigParams::KEY_PERF_COUNT) { + if (kvp.second == IE::PluginConfigParams::YES || + kvp.second == IE::PluginConfigParams::NO) { + _config[kvp.first] = kvp.second; + } else { + IE_THROW() << "Unsupported config value: " << kvp.second + << " for key: " << kvp.first; + } + } else { + IE_THROW() << "Unsupported config key: " << kvp.first; + } } } @@ -128,7 +140,10 @@ IE::Parameter AutoInferencePlugin::GetMetric(const std::string& name, std::string device_name = {"Inference Engine AUTO device"}; IE_SET_METRIC_RETURN(FULL_DEVICE_NAME, device_name); } else if (name == METRIC_KEY(SUPPORTED_CONFIG_KEYS)) { - std::vector configKeys; + std::vector configKeys = { + IE::KEY_AUTO_DEVICE_LIST, + IE::PluginConfigParams::KEY_PERF_COUNT + }; IE_SET_METRIC_RETURN(SUPPORTED_CONFIG_KEYS, configKeys); } else if (name == METRIC_KEY(OPTIMIZATION_CAPABILITIES)) { std::vector capabilities = GetOptimizationCapabilities(options); @@ -139,42 +154,21 @@ IE::Parameter AutoInferencePlugin::GetMetric(const std::string& name, } //////////////////////////////////// private & protected functions /////////////////// -std::vector AutoInferencePlugin::GetDeviceChoice(const ConfigType& config) const { - std::vector metaDevices; - std::vector availableDevices; +std::vector AutoInferencePlugin::GetDeviceList(const ConfigType& config) const { + std::vector deviceList; auto deviceListConfig = config.find(IE::KEY_AUTO_DEVICE_LIST); if (deviceListConfig == config.end()) { - availableDevices = GetCore()->GetAvailableDevices(); + deviceList = GetCore()->GetAvailableDevices(); } else { - availableDevices = IE::DeviceIDParser::getHeteroDevices(deviceListConfig->second); + deviceList = IE::DeviceIDParser::getHeteroDevices(deviceListConfig->second); } - auto getDeviceConfig = [&] (const DeviceName & deviceWithID) { - IE::DeviceIDParser deviceParser(deviceWithID); - std::string deviceName = deviceParser.getDeviceName(); - ConfigType tconfig = config; - - // set device ID if any - std::string deviceIDLocal = deviceParser.getDeviceID(); - if (!deviceIDLocal.empty()) { - tconfig[IE::PluginConfigParams::KEY_DEVICE_ID] = deviceIDLocal; - } - - return GetSupportedConfig(tconfig, deviceName); - }; - - for (auto && d : availableDevices) { - if (d != _pluginName) { - metaDevices.push_back({ d, getDeviceConfig(d)}); - } - } - - if (metaDevices.empty()) { + if (deviceList.empty()) { IE_THROW() << "Please, check environment due to no supported devices can be used"; } - return metaDevices; + return deviceList; } std::vector AutoInferencePlugin::GetOptimizationCapabilities(const std::map & options) const { @@ -215,7 +209,21 @@ ConfigType AutoInferencePlugin::GetSupportedConfig(const ConfigType& config, return supportedConfig; } -DeviceInformation AutoInferencePlugin::SelectDevice(const std::vector& metaDevices, const std::string& networkPrecision) { +void AutoInferencePlugin::CheckConfig(const ConfigType& config) { + std::vector supportedConfigKeys = GetMetric(METRIC_KEY(SUPPORTED_CONFIG_KEYS), {}); + for (auto&& c : config) { + auto itKey = std::find(supportedConfigKeys.begin(), supportedConfigKeys.end(), c.first); + if (supportedConfigKeys.end() == itKey) { + // CVS-57233 + if (c.first.find("AUTO_") == 0) { + continue; + } + IE_THROW() << "AUTO plugin doesn't support config key " << c.first; + } + } +} + +DeviceName AutoInferencePlugin::SelectDevice(const std::vector& metaDevices, const std::string& networkPrecision) { if (metaDevices.empty()) { IE_THROW(NotFound) << "No available device to select in AUTO plugin"; } @@ -223,15 +231,15 @@ DeviceInformation AutoInferencePlugin::SelectDevice(const std::vector CPU; - std::vector GPU; + std::vector CPU; + std::vector GPU; for (auto& item : metaDevices) { - if (item.deviceName.find("CPU") == 0) { + if (item.find("CPU") == 0) { CPU.push_back(item); continue; } - if (item.deviceName.find("GPU") == 0) { + if (item.find("GPU") == 0) { GPU.push_back(item); continue; } @@ -242,10 +250,10 @@ DeviceInformation AutoInferencePlugin::SelectDevice(const std::vector GPU.1 > GPU.0 > GPU, so we always choose the GPU[0] as best device - std::sort(GPU.begin(), GPU.end(), [](const DeviceInformation& a, const DeviceInformation& b)->bool{return b.deviceName < a.deviceName;}); + std::sort(GPU.begin(), GPU.end(), [](const DeviceName& a, const DeviceName& b)->bool{return b < a;}); for (auto&& item : GPU) { - std::vector capability = GetCore()->GetMetric(item.deviceName, METRIC_KEY(OPTIMIZATION_CAPABILITIES)); + std::vector capability = GetCore()->GetMetric(item, METRIC_KEY(OPTIMIZATION_CAPABILITIES)); auto res = std::find(capability.begin(), capability.end(), networkPrecision); if (res != capability.end()) { return item; diff --git a/inference-engine/src/auto_plugin/auto_plugin.hpp b/inference-engine/src/auto_plugin/auto_plugin.hpp index af42e9f0ef7c28..858ee2143fd06f 100644 --- a/inference-engine/src/auto_plugin/auto_plugin.hpp +++ b/inference-engine/src/auto_plugin/auto_plugin.hpp @@ -30,10 +30,11 @@ class AutoInferencePlugin : public IE::IInferencePlugin { void SetConfig(const ConfigType& config) override; private: - std::vector GetDeviceChoice(const ConfigType& config) const; + std::vector GetDeviceList(const ConfigType& config) const; std::vector GetOptimizationCapabilities(const std::map& options) const; - DeviceInformation SelectDevice(const std::vector& metaDevices, const std::string& networkPrecision = METRIC_VALUE(FP32)); - ConfigType GetSupportedConfig(const ConfigType& config, const AutoPlugin::DeviceName & deviceName) const; + DeviceName SelectDevice(const std::vector& metaDevices, const std::string& networkPrecision = METRIC_VALUE(FP32)); + ConfigType GetSupportedConfig(const ConfigType& config, const DeviceName & deviceName) const; + void CheckConfig(const ConfigType& config); static ConfigType mergeConfigs(ConfigType config, const ConfigType& local); template @@ -41,18 +42,21 @@ class AutoInferencePlugin : public IE::IInferencePlugin { if (GetCore() == nullptr) { IE_THROW() << "Please, work with AUTO device via InferencEngine::Core object"; } + + CheckConfig(config); + auto fullConfig = mergeConfigs(_config, config); - auto metaDevices = GetDeviceChoice(fullConfig); - DeviceInformation selectedDevice; + auto metaDevices = GetDeviceList(fullConfig); + DeviceName selectedDevice; IE::SoExecutableNetworkInternal executableNetwork; while (!metaDevices.empty()) { selectedDevice = SelectDevice(metaDevices, networkPrecision); try { - executableNetwork = GetCore()->LoadNetwork(param, selectedDevice.deviceName, selectedDevice.config); + executableNetwork = GetCore()->LoadNetwork(param, selectedDevice, {}); break; } catch (...) { auto eraseDevice = std::find_if(metaDevices.begin(), metaDevices.end(), - [=](const DeviceInformation& d)->bool{return d.deviceName == selectedDevice.deviceName;}); + [=](const DeviceName& d)->bool{return d == selectedDevice;}); if (eraseDevice == metaDevices.end()) { IE_THROW() << "Didn't find the selected device name"; } @@ -63,7 +67,10 @@ class AutoInferencePlugin : public IE::IInferencePlugin { if (!executableNetwork) { IE_THROW() << "Failed to load network by AUTO plugin"; } - auto impl = std::make_shared(executableNetwork); + + bool enablePerfCount = fullConfig.find(IE::PluginConfigParams::KEY_PERF_COUNT) != fullConfig.end(); + + auto impl = std::make_shared(executableNetwork, enablePerfCount); if (std::is_same::value) { SetExeNetworkInfo(impl, executableNetwork->GetInputsInfo(), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/config.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/config.cpp index 8dab56fdafa52a..e3f0adb1cb6117 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/config.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/config.cpp @@ -42,18 +42,7 @@ namespace { }; const std::vector> AutoConfigs = { - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}, - {InferenceEngine::PluginConfigParams::KEY_CPU_THROUGHPUT_STREAMS, InferenceEngine::PluginConfigParams::CPU_THROUGHPUT_AUTO}}, - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}, - {InferenceEngine::PluginConfigParams::KEY_CPU_THROUGHPUT_STREAMS, InferenceEngine::PluginConfigParams::CPU_THROUGHPUT_NUMA}}, - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}, - {InferenceEngine::PluginConfigParams::KEY_CPU_THROUGHPUT_STREAMS, "8"}}, - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}, - {InferenceEngine::PluginConfigParams::KEY_CPU_BIND_THREAD, InferenceEngine::PluginConfigParams::NO}}, - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}, - {InferenceEngine::PluginConfigParams::KEY_CPU_BIND_THREAD, InferenceEngine::PluginConfigParams::YES}}, - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}, - {InferenceEngine::PluginConfigParams::KEY_DYN_BATCH_LIMIT, "10"}} + {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}} }; INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectConfigTests, @@ -93,22 +82,14 @@ namespace { }; const std::vector> autoinconfigs = { - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}, - {InferenceEngine::PluginConfigParams::KEY_CPU_THROUGHPUT_STREAMS, "OFF"}}, - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}, - {InferenceEngine::PluginConfigParams::KEY_CPU_BIND_THREAD, "OFF"}}, - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}, - {InferenceEngine::PluginConfigParams::KEY_DYN_BATCH_LIMIT, "NAN"}} + {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}, + {InferenceEngine::PluginConfigParams::KEY_CPU_THROUGHPUT_STREAMS, "OFF"}} }; const std::vector> multiconf = { {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES , CommonTestUtils::DEVICE_CPU}} }; - const std::vector> autoconf = { - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}} - }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), @@ -127,7 +108,7 @@ namespace { ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), - ::testing::ValuesIn(autoconf)), + ::testing::ValuesIn(AutoConfigs)), CorrectConfigAPITests::getTestCaseName); INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigTests, @@ -144,13 +125,6 @@ namespace { ::testing::ValuesIn(multiinconfigs)), IncorrectConfigTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, IncorrectConfigTests, - ::testing::Combine( - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CommonTestUtils::DEVICE_AUTO), - ::testing::ValuesIn(autoinconfigs)), - IncorrectConfigTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), @@ -166,10 +140,10 @@ namespace { IncorrectConfigAPITests::getTestCaseName); INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, IncorrectConfigAPITests, - ::testing::Combine( - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CommonTestUtils::DEVICE_AUTO), - ::testing::ValuesIn(autoinconfigs)), - IncorrectConfigAPITests::getTestCaseName); + ::testing::Combine( + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CommonTestUtils::DEVICE_AUTO), + ::testing::ValuesIn(autoinconfigs)), + IncorrectConfigAPITests::getTestCaseName); } // namespace \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_config.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_config.cpp index 80914183c39e80..3db325234cf1a6 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_config.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_config.cpp @@ -51,20 +51,7 @@ namespace { }; const std::vector> AutoConfigs = { - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}, - {InferenceEngine::PluginConfigParams::KEY_CPU_THROUGHPUT_STREAMS, - InferenceEngine::PluginConfigParams::CPU_THROUGHPUT_AUTO}}, - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}, - {InferenceEngine::PluginConfigParams::KEY_CPU_THROUGHPUT_STREAMS, - InferenceEngine::PluginConfigParams::CPU_THROUGHPUT_NUMA}}, - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}, - {InferenceEngine::PluginConfigParams::KEY_CPU_THROUGHPUT_STREAMS, "8"}}, - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}, - {InferenceEngine::PluginConfigParams::KEY_CPU_BIND_THREAD, InferenceEngine::PluginConfigParams::NO}}, - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}, - {InferenceEngine::PluginConfigParams::KEY_CPU_BIND_THREAD, InferenceEngine::PluginConfigParams::YES}}, - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}, - {InferenceEngine::PluginConfigParams::KEY_DYN_BATCH_LIMIT, "10"}} + {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}} }; INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferConfigTests, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_input.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_input.cpp index 771794774a67c9..eb988c0043a289 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_input.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_input.cpp @@ -26,9 +26,7 @@ namespace { }; const std::vector> autoConfigs = { - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}}, - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}, - {InferenceEngine::PluginConfigParams::KEY_CPU_THROUGHPUT_STREAMS, InferenceEngine::PluginConfigParams::CPU_THROUGHPUT_AUTO}} + {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}} }; INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferRequestInputTests, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_output.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_output.cpp index 78be15133142a3..a77253f8900fa5 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_output.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_output.cpp @@ -22,9 +22,7 @@ namespace { }; const std::vector> autoConfigs = { - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}}, - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}, - {InferenceEngine::PluginConfigParams::KEY_CPU_THROUGHPUT_STREAMS, InferenceEngine::PluginConfigParams::CPU_THROUGHPUT_AUTO}} + {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}} }; INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferRequestOutputTests, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/perf_counters.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/perf_counters.cpp index 2e2aab976c6732..8bf1a8f95ba766 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/perf_counters.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/perf_counters.cpp @@ -14,10 +14,6 @@ namespace { {{ MULTI_CONFIG_KEY(DEVICE_PRIORITIES) , CommonTestUtils::DEVICE_CPU}} }; - const std::vector> Autoconfigs = { - {{ AUTO_CONFIG_KEY(DEVICE_LIST) , CommonTestUtils::DEVICE_CPU}} - }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, PerfCountersTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), @@ -32,11 +28,4 @@ namespace { ::testing::ValuesIn(Multiconfigs)), PerfCountersTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, PerfCountersTest, - ::testing::Combine( - ::testing::Values(InferenceEngine::Precision::FP32), - ::testing::Values(CommonTestUtils::DEVICE_AUTO), - ::testing::ValuesIn(Autoconfigs)), - PerfCountersTest::getTestCaseName); - } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/test_plugin.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/test_plugin.cpp index 95208f0a092c88..da76bc26498b1e 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/test_plugin.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/test_plugin.cpp @@ -37,9 +37,7 @@ namespace { }; const std::vector> AutoConfigsInputOutput = { - {{InferenceEngine::KEY_AUTO_DEVICE_LIST, CommonTestUtils::DEVICE_CPU}}, - {{InferenceEngine::KEY_AUTO_DEVICE_LIST, CommonTestUtils::DEVICE_CPU}, - {InferenceEngine::PluginConfigParams::KEY_CPU_THROUGHPUT_STREAMS, InferenceEngine::PluginConfigParams::CPU_THROUGHPUT_AUTO}} + {{InferenceEngine::KEY_AUTO_DEVICE_LIST, CommonTestUtils::DEVICE_CPU}} }; const std::vector> configsOutput = { diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp index b3134e9953e9e5..f013e544074644 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp @@ -67,6 +67,8 @@ std::vector disabledTestPatterns() { // TODO: 55656 AUTO plugin and QueryNetwork R"(.*CoreThreading.*smoke_QueryNetwork.*targetDevice=AUTO_config.*)", + // Unsupported config KEY_ENFORCE_BF16 for AUTO plugin + R"(.*smoke_SetBlobOfKindAUTO.*SetBlobOfKindTest.CompareWithRefs.*)", // reference doesn't cover I8, U8 cases. Issue: 55842 R"(.*Gather7LayerTest.*netPRC=I8.*)", }; diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/config.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/config.cpp index 0b550c568b64e1..e21d610db569cb 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/config.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/config.cpp @@ -106,6 +106,13 @@ namespace { ::testing::ValuesIn(autoconf)), CorrectConfigAPITests::getTestCaseName); + INSTANTIATE_TEST_CASE_P(smoke_AutoCG_BehaviorTests, CorrectConfigAPITests, + ::testing::Combine( + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CommonTestUtils::DEVICE_AUTO), + ::testing::ValuesIn(auto_cpu_gpu_conf)), + CorrectConfigAPITests::getTestCaseName); + INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), @@ -124,14 +131,14 @@ namespace { ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), - ::testing::ValuesIn(autoconf)), + ::testing::ValuesIn(autoinconfigs)), IncorrectConfigAPITests::getTestCaseName); INSTANTIATE_TEST_CASE_P(smoke_AutoCG_BehaviorTests, IncorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), - ::testing::ValuesIn(auto_cpu_gpu_conf)), + ::testing::ValuesIn(autoinconfigs)), IncorrectConfigAPITests::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_input.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_input.cpp index a9a07450f70ceb..e15ea827caa814 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_input.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_input.cpp @@ -26,9 +26,7 @@ namespace { }; const std::vector> autoConfigs = { - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_GPU}, - {InferenceEngine::PluginConfigParams::KEY_GPU_THROUGHPUT_STREAMS, - InferenceEngine::PluginConfigParams::GPU_THROUGHPUT_AUTO}} + {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_GPU}} }; const std::vector> auto_cpu_gpu_conf = { diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_output.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_output.cpp index 550572077c34ba..6c38f5c841c0b0 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_output.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_output.cpp @@ -22,8 +22,7 @@ namespace { }; const std::vector> autoConfigs = { - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_GPU}, - {InferenceEngine::PluginConfigParams::KEY_GPU_THROUGHPUT_STREAMS, InferenceEngine::PluginConfigParams::GPU_THROUGHPUT_AUTO}} + {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_GPU}} }; const std::vector> auto_cpu_gpu_conf = { diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/perf_counters.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/perf_counters.cpp index c5a5f695359496..d8a89ef317d425 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/perf_counters.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/perf_counters.cpp @@ -14,14 +14,6 @@ namespace { {{ MULTI_CONFIG_KEY(DEVICE_PRIORITIES) , CommonTestUtils::DEVICE_GPU}} }; - const std::vector> Autoconfigs = { - {{ AUTO_CONFIG_KEY(DEVICE_LIST) , CommonTestUtils::DEVICE_GPU}} - }; - - const std::vector> auto_cpu_gpu_conf = { - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , std::string(CommonTestUtils::DEVICE_CPU) + "," + CommonTestUtils::DEVICE_GPU}} - }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, PerfCountersTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), @@ -36,18 +28,4 @@ namespace { ::testing::ValuesIn(Multiconfigs)), PerfCountersTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, PerfCountersTest, - ::testing::Combine( - ::testing::Values(InferenceEngine::Precision::FP32), - ::testing::Values(CommonTestUtils::DEVICE_AUTO), - ::testing::ValuesIn(Autoconfigs)), - PerfCountersTest::getTestCaseName); - - INSTANTIATE_TEST_CASE_P(smoke_AutoCG_BehaviorTests, PerfCountersTest, - ::testing::Combine( - ::testing::Values(InferenceEngine::Precision::FP32), - ::testing::Values(CommonTestUtils::DEVICE_AUTO), - ::testing::ValuesIn(auto_cpu_gpu_conf)), - PerfCountersTest::getTestCaseName); - } // namespace diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/test_plugin.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/test_plugin.cpp index bc6507d7905fe4..51979116646939 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/test_plugin.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/test_plugin.cpp @@ -28,7 +28,7 @@ namespace { }; const std::vector> auto_cpu_gpu_conf = { - {{InferenceEngine::KEY_AUTO_DEVICE_LIST , std::string(CommonTestUtils::DEVICE_CPU) + "," + CommonTestUtils::DEVICE_GPU}} + {{InferenceEngine::KEY_AUTO_DEVICE_LIST , std::string(CommonTestUtils::DEVICE_CPU) + "," + CommonTestUtils::DEVICE_GPU}} }; const std::vector> configsInput = { @@ -42,18 +42,6 @@ namespace { {InferenceEngine::PluginConfigParams::KEY_GPU_THROUGHPUT_STREAMS, InferenceEngine::PluginConfigParams::GPU_THROUGHPUT_AUTO}} }; - const std::vector> AutoConfigsInputOutput = { - {{InferenceEngine::KEY_AUTO_DEVICE_LIST, CommonTestUtils::DEVICE_GPU}}, - {{InferenceEngine::KEY_AUTO_DEVICE_LIST, CommonTestUtils::DEVICE_GPU}, - {InferenceEngine::PluginConfigParams::KEY_GPU_THROUGHPUT_STREAMS, InferenceEngine::PluginConfigParams::GPU_THROUGHPUT_AUTO}} - }; - - const std::vector> AutoCGConfigsInputOutput = { - {{InferenceEngine::KEY_AUTO_DEVICE_LIST, std::string(CommonTestUtils::DEVICE_CPU) + "," + CommonTestUtils::DEVICE_GPU}}, - {{InferenceEngine::KEY_AUTO_DEVICE_LIST, std::string(CommonTestUtils::DEVICE_CPU) + "," + CommonTestUtils::DEVICE_GPU}, - {InferenceEngine::PluginConfigParams::KEY_GPU_THROUGHPUT_STREAMS, InferenceEngine::PluginConfigParams::GPU_THROUGHPUT_AUTO}} - }; - const std::vector> configsOutput = { {}, {{InferenceEngine::PluginConfigParams::KEY_GPU_THROUGHPUT_STREAMS, InferenceEngine::PluginConfigParams::GPU_THROUGHPUT_AUTO}} @@ -77,14 +65,14 @@ namespace { ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), - ::testing::ValuesIn(AutoConfigsInputOutput)), + ::testing::ValuesIn(AutoConfigs)), BehaviorTestOutput::getTestCaseName); INSTANTIATE_TEST_CASE_P(smoke_AutoCG_BehaviorTests, BehaviorTestOutput, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), - ::testing::ValuesIn(AutoCGConfigsInputOutput)), + ::testing::ValuesIn(auto_cpu_gpu_conf)), BehaviorTestOutput::getTestCaseName); INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, BehaviorTests, @@ -133,14 +121,14 @@ namespace { ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), - ::testing::ValuesIn(AutoConfigsInputOutput)), + ::testing::ValuesIn(AutoConfigs)), BehaviorTestInput::getTestCaseName); INSTANTIATE_TEST_CASE_P(smoke_AutoCG_BehaviorTests, BehaviorTestInput, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), - ::testing::ValuesIn(AutoCGConfigsInputOutput)), + ::testing::ValuesIn(auto_cpu_gpu_conf)), BehaviorTestInput::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/shared/include/behavior/config.hpp b/inference-engine/tests/functional/plugin/shared/include/behavior/config.hpp index b9caf6edacfddb..e13fe679b2a82c 100644 --- a/inference-engine/tests/functional/plugin/shared/include/behavior/config.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/behavior/config.hpp @@ -57,8 +57,7 @@ namespace BehaviorTestsDefinitions { // Create CNNNetwork from ngrpah::Function InferenceEngine::CNNNetwork cnnNet(function); if (targetDevice.find(CommonTestUtils::DEVICE_MULTI) == std::string::npos && - targetDevice.find(CommonTestUtils::DEVICE_HETERO) == std::string::npos && - targetDevice.find(CommonTestUtils::DEVICE_AUTO) == std::string::npos) { + targetDevice.find(CommonTestUtils::DEVICE_HETERO) == std::string::npos) { ASSERT_NO_THROW(ie->GetMetric(targetDevice, METRIC_KEY(SUPPORTED_CONFIG_KEYS))); ASSERT_THROW(ie->SetConfig(configuration, targetDevice), InferenceEngine::Exception); @@ -73,8 +72,12 @@ namespace BehaviorTestsDefinitions { SKIP_IF_CURRENT_TEST_IS_DISABLED() // Create CNNNetwork from ngrpah::Function InferenceEngine::CNNNetwork cnnNet(function); - ASSERT_THROW(auto execNet = ie->LoadNetwork(cnnNet, targetDevice, configuration), - InferenceEngine::Exception); + if (targetDevice.find(CommonTestUtils::DEVICE_AUTO) != std::string::npos) { + GTEST_SKIP(); + } else { + ASSERT_THROW(auto execNet = ie->LoadNetwork(cnnNet, targetDevice, configuration), + InferenceEngine::Exception); + } } using IncorrectConfigAPITests = BehaviorTestsUtils::BehaviorTestsBasic; @@ -110,8 +113,10 @@ namespace BehaviorTestsDefinitions { ASSERT_NO_THROW(ie->SetConfig(config, targetDevice)); } // Load CNNNetwork to target plugins - auto execNet = ie->LoadNetwork(cnnNet, targetDevice, config); - execNet.CreateInferRequest(); + if (targetDevice.find(CommonTestUtils::DEVICE_AUTO) == std::string::npos) { + auto execNet = ie->LoadNetwork(cnnNet, targetDevice, config); + execNet.CreateInferRequest(); + } if ((targetDevice == CommonTestUtils::DEVICE_HDDL) || (targetDevice == CommonTestUtils::DEVICE_GNA)) { ASSERT_EQ(0u, InferenceEngine::ExecutorManager::getInstance()->getExecutorsNumber()); @@ -139,8 +144,10 @@ namespace BehaviorTestsDefinitions { ASSERT_NO_THROW(ie->SetConfig(config, targetDevice)); } // Load CNNNetwork to target plugins - auto execNet = ie->LoadNetwork(cnnNet, targetDevice, config); - execNet.CreateInferRequest(); + if (targetDevice.find(CommonTestUtils::DEVICE_AUTO) == std::string::npos) { + auto execNet = ie->LoadNetwork(cnnNet, targetDevice, config); + execNet.CreateInferRequest(); + } if ((targetDevice == CommonTestUtils::DEVICE_MYRIAD) || (targetDevice == CommonTestUtils::DEVICE_KEEMBAY)) { @@ -170,8 +177,10 @@ namespace BehaviorTestsDefinitions { ASSERT_NO_THROW(ie->SetConfig(config, targetDevice)); } // Load CNNNetwork to target plugins - auto execNet = ie->LoadNetwork(cnnNet, targetDevice, config); - execNet.CreateInferRequest(); + if (targetDevice.find(CommonTestUtils::DEVICE_AUTO) == std::string::npos) { + auto execNet = ie->LoadNetwork(cnnNet, targetDevice, config); + execNet.CreateInferRequest(); + } if ((targetDevice == CommonTestUtils::DEVICE_MYRIAD) || (targetDevice == CommonTestUtils::DEVICE_KEEMBAY)) { diff --git a/inference-engine/tests/functional/plugin/shared/include/behavior/infer_request_config.hpp b/inference-engine/tests/functional/plugin/shared/include/behavior/infer_request_config.hpp index cb364c80f8cabf..c94694011238ab 100644 --- a/inference-engine/tests/functional/plugin/shared/include/behavior/infer_request_config.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/behavior/infer_request_config.hpp @@ -42,8 +42,10 @@ TEST_P(InferConfigTests, canSetExclusiveAsyncRequests) { ASSERT_NO_THROW(ie->SetConfig(config, targetDevice)); } // Load CNNNetwork to target plugins - auto execNet = ie->LoadNetwork(cnnNet, targetDevice, config); - execNet.CreateInferRequest(); + if (targetDevice.find(CommonTestUtils::DEVICE_AUTO) == std::string::npos) { + auto execNet = ie->LoadNetwork(cnnNet, targetDevice, config); + execNet.CreateInferRequest(); + } if ((targetDevice == CommonTestUtils::DEVICE_HDDL) || (targetDevice == CommonTestUtils::DEVICE_GNA)) { ASSERT_EQ(0u, InferenceEngine::ExecutorManager::getInstance()->getExecutorsNumber()); @@ -71,8 +73,10 @@ TEST_P(InferConfigTests, withoutExclusiveAsyncRequests) { ASSERT_NO_THROW(ie->SetConfig(config, targetDevice)); } // Load CNNNetwork to target plugins - auto execNet = ie->LoadNetwork(cnnNet, targetDevice, config); - execNet.CreateInferRequest(); + if (targetDevice.find(CommonTestUtils::DEVICE_AUTO) == std::string::npos) { + auto execNet = ie->LoadNetwork(cnnNet, targetDevice, config); + execNet.CreateInferRequest(); + } if ((targetDevice == CommonTestUtils::DEVICE_GNA) || (targetDevice == CommonTestUtils::DEVICE_HDDL)) { ASSERT_EQ(0u, InferenceEngine::ExecutorManager::getInstance()->getExecutorsNumber()); From 79e44292c5758b9e736c8440e7c0e9f2364991dc Mon Sep 17 00:00:00 2001 From: Michal Papaj Date: Tue, 8 Jun 2021 11:35:26 +0200 Subject: [PATCH 023/178] Update to speech recognition demo version. (#6060) The speech recognition demo packages were updated to align OV python packages requirements. This patch updates packages version and SHA. --- inference-engine/cmake/dependencies.cmake | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/inference-engine/cmake/dependencies.cmake b/inference-engine/cmake/dependencies.cmake index 4ce1ef3136550e..b270c46f2da7cc 100644 --- a/inference-engine/cmake/dependencies.cmake +++ b/inference-engine/cmake/dependencies.cmake @@ -295,25 +295,25 @@ if (ENABLE_SPEECH_DEMO) if(DEFINED IE_PATH_TO_DEPS) if (WIN32 AND X86_64) RESOLVE_DEPENDENCY(SPEECH_LIBS_AND_DEMOS - ARCHIVE_WIN "speech_demo_1.0.0.755_windows.zip" + ARCHIVE_WIN "speech_demo_1.0.0.774_windows.zip" VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+.[0-9]+).*" - TARGET_PATH "${TEMP}/speech_demo_1.0.0.755" - SHA256 "58adef14b8a749f70fa83888614cee34b941956e6e958e445e3f48885b3c20a0") + TARGET_PATH "${TEMP}/speech_demo_1.0.0.774" + SHA256 "67b25170be5e89a4f0e90e8b39623b60c9a15b965c30329385e295fcd2edc856") debug_message(STATUS "speech_libs_and_demos=" ${SPEECH_LIBS_AND_DEMOS}) elseif (LINUX AND X86_64) if (LINUX_OS_NAME STREQUAL "CentOS 7" OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9") RESOLVE_DEPENDENCY(SPEECH_LIBS_AND_DEMOS - ARCHIVE_LIN "speech_demo_1.0.0.755_centos.tgz" + ARCHIVE_LIN "speech_demo_1.0.0.774_centos.tgz" VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+.[0-9]+).*" - TARGET_PATH "${TEMP}/speech_demo_1.0.0.755" - SHA256 "716201e377714ac50f3909c445d36d47a089de50a557d8ef65232de040671188") + TARGET_PATH "${TEMP}/speech_demo_1.0.0.774" + SHA256 "5ec3b7be9ae05376aefae5bd5fd4a39b12c274e82817fd3218120b8e8fc8ff5a") debug_message(STATUS "speech_libs_and_demos=" ${SPEECH_LIBS_AND_DEMOS}) else() RESOLVE_DEPENDENCY(SPEECH_LIBS_AND_DEMOS - ARCHIVE_LIN "speech_demo_1.0.0.755_linux.tgz" + ARCHIVE_LIN "speech_demo_1.0.0.774_linux.tgz" VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+.[0-9]+).*" - TARGET_PATH "${TEMP}/speech_demo_1.0.0.755" - SHA256 "7714b8776ec0183ed73eed6d3d965ee6d5c15d2dc49ee5ae118cc368c89c7a9d") + TARGET_PATH "${TEMP}/speech_demo_1.0.0.774" + SHA256 "f0bbd0a6218b0365e7cfb1f860b34e4ace7e0d47dd60b369cdea8a480329810f") debug_message(STATUS "speech_libs_and_demos=" ${SPEECH_LIBS_AND_DEMOS}) endif() else() From 9aa338a0afcab0f1754e9cc1ec2e08d92adfdf5a Mon Sep 17 00:00:00 2001 From: Rafal Blaczkowski Date: Tue, 8 Jun 2021 11:37:20 +0200 Subject: [PATCH 024/178] OpenVINO ONNX CI - set more stable proxy (#5945) * Set more stable proxy * Update env * Add missing chars * Update proxy * Additonal try to overwrite proxy * update proxy * fix style --- .ci/openvino-onnx/Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci/openvino-onnx/Jenkinsfile b/.ci/openvino-onnx/Jenkinsfile index 48529879ef162e..5fe24928798f3d 100644 --- a/.ci/openvino-onnx/Jenkinsfile +++ b/.ci/openvino-onnx/Jenkinsfile @@ -113,8 +113,8 @@ def buildDockerImage(Map configuration, String workdir) { --build-arg BUILD_TYPE=${configuration.build_type} \ --build-arg PROTOBUF_LITE=${configuration.protobuf_lite} \ --file=.ci/openvino-onnx/Dockerfile \ - --build-arg http_proxy=http://proxy-chain.intel.com:911/ \ - --build-arg https_proxy=http://proxy-chain.intel.com:912/ . + --build-arg http_proxy=http://proxy-ir.intel.com:911/ \ + --build-arg https_proxy=http://proxy-ir.intel.com:911/ . """ } From 503d18c80f9f1291b5aa5a7456b074b30bac7fec Mon Sep 17 00:00:00 2001 From: Alexander Shchepetov Date: Tue, 8 Jun 2021 12:47:20 +0300 Subject: [PATCH 025/178] Enable MYRIAD in stress tests (#6026) --- .../myriad_references_config.xml | 20 +++ .../nightly_configs/myriad_test_config.xml | 115 ++++++++++++++++++ .../nightly_configs/myriad_test_config.xml | 19 +++ .../nightly_configs/myriad_test_config.xml | 20 +++ 4 files changed, 174 insertions(+) create mode 100644 tests/stress_tests/.automation/memcheck_tests/nightly_configs/myriad_references_config.xml create mode 100644 tests/stress_tests/.automation/memcheck_tests/nightly_configs/myriad_test_config.xml create mode 100644 tests/stress_tests/.automation/memleaks_tests/nightly_configs/myriad_test_config.xml create mode 100644 tests/stress_tests/.automation/unittests/nightly_configs/myriad_test_config.xml diff --git a/tests/stress_tests/.automation/memcheck_tests/nightly_configs/myriad_references_config.xml b/tests/stress_tests/.automation/memcheck_tests/nightly_configs/myriad_references_config.xml new file mode 100644 index 00000000000000..b4a8be108c386d --- /dev/null +++ b/tests/stress_tests/.automation/memcheck_tests/nightly_configs/myriad_references_config.xml @@ -0,0 +1,20 @@ + + + + # References were collected from DB with next query: {"commit_id": "aa2ae13c1ee6d700dd287ab809403e7de8c7c5e3", "commit_date": "2021-06-05 14:30:47+00:00"} + # and modified on FACTOR = 1.3 + + + + + + + + + + + + + + + diff --git a/tests/stress_tests/.automation/memcheck_tests/nightly_configs/myriad_test_config.xml b/tests/stress_tests/.automation/memcheck_tests/nightly_configs/myriad_test_config.xml new file mode 100644 index 00000000000000..7409c6287dae8d --- /dev/null +++ b/tests/stress_tests/.automation/memcheck_tests/nightly_configs/myriad_test_config.xml @@ -0,0 +1,115 @@ + + + MYRIAD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/stress_tests/.automation/memleaks_tests/nightly_configs/myriad_test_config.xml b/tests/stress_tests/.automation/memleaks_tests/nightly_configs/myriad_test_config.xml new file mode 100644 index 00000000000000..3718751b253d7d --- /dev/null +++ b/tests/stress_tests/.automation/memleaks_tests/nightly_configs/myriad_test_config.xml @@ -0,0 +1,19 @@ + + + 1 + + + 1 + + + 1000 + + + MYRIAD + + + + + + + \ No newline at end of file diff --git a/tests/stress_tests/.automation/unittests/nightly_configs/myriad_test_config.xml b/tests/stress_tests/.automation/unittests/nightly_configs/myriad_test_config.xml new file mode 100644 index 00000000000000..979194a991ac26 --- /dev/null +++ b/tests/stress_tests/.automation/unittests/nightly_configs/myriad_test_config.xml @@ -0,0 +1,20 @@ + + + 1 + + + 1 + 2 + + + 100 + + + MYRIAD + + + + + + + From ae5608534ed76572ed4fcaf412291656959091e2 Mon Sep 17 00:00:00 2001 From: iliya mironov Date: Tue, 8 Jun 2021 13:15:54 +0300 Subject: [PATCH 026/178] Add support resize with 2 inputs (#5927) * Add support resize with 2 inputs * Add unit tests * Hot fix * Change resize check from port count to connected num port conditions * Fix conditions * Refactoring code according to review * Fix according to review * Change onnresize11 input condition --- .../middle/ONNXResize11ToInterpolate.py | 13 ++-- .../extensions/ops/ONNXResize11.py | 13 ++-- .../extensions/ops/ONNXResize11_test.py | 68 ++++++++++++++++++- 3 files changed, 80 insertions(+), 14 deletions(-) diff --git a/model-optimizer/extensions/middle/ONNXResize11ToInterpolate.py b/model-optimizer/extensions/middle/ONNXResize11ToInterpolate.py index ffd3c27eebdba6..c462d45285faa5 100644 --- a/model-optimizer/extensions/middle/ONNXResize11ToInterpolate.py +++ b/model-optimizer/extensions/middle/ONNXResize11ToInterpolate.py @@ -34,12 +34,13 @@ def replace_resize(graph: Graph, resize: Node): log.warning('The input shape is not 4D or 5D for op with name {}'.format(resize_name)) return - num_of_inputs = len([port for port in resize.in_ports().values() if not port.disconnected()]) - assert num_of_inputs in {3, 4}, \ - "Number of inputs of ONNXResize (with name {}) should be equal to 3 or 4".format(resize_name) + assert (resize.is_in_port_connected(0) and (resize.is_in_port_connected(2) or resize.is_in_port_connected(3))), \ + "Scales or sizes inputs must be connected to Node {} with op {}.".format(resize.soft_get("name", resize.id), + resize.op) assert resize.soft_get('coordinate_transformation_mode') != 'tf_crop_and_resize', \ - 'Mode tf_crop_and_resize is not supported for op {} with name {}'.format(resize.op, resize_name) + 'Mode tf_crop_and_resize is not supported for op {} with name {}'.format(resize.op, + resize.soft_get("name", resize.id)) layout = graph.graph['layout'] @@ -74,7 +75,7 @@ def replace_resize(graph: Graph, resize: Node): {'name': resize_name + '/axis', 'value': int64_array(np.arange(begin_dim, end_dim))}).create_node() - shape_calculation_mode = 'scales' if num_of_inputs == 3 else 'sizes' + shape_calculation_mode = 'sizes' if resize.is_in_port_connected(3) else 'scales' interpolate_node = Interpolate(graph, {'version': 'opset4', 'mode': convert_mode(resize.mode), @@ -96,7 +97,7 @@ def replace_resize(graph: Graph, resize: Node): dst_dtype = np.float32 # even if data_type=FP16 use float32 for shape values - if num_of_inputs == 3: + if not resize.is_in_port_connected(3): cast_shape_to_float = Cast(graph, {'dst_type': dst_dtype}).create_node() mul_node = Mul(graph, {'name': resize_name + '/Mul'}).create_node() shape_of.out_port(0).connect(cast_shape_to_float.in_port(0)) diff --git a/model-optimizer/extensions/ops/ONNXResize11.py b/model-optimizer/extensions/ops/ONNXResize11.py index 5ef8d7f6ac88c2..5476087a3d404d 100644 --- a/model-optimizer/extensions/ops/ONNXResize11.py +++ b/model-optimizer/extensions/ops/ONNXResize11.py @@ -35,14 +35,15 @@ def onnx_resize_infer(node: Node): if input_shape is None: return - num_of_in_nodes = len(node.in_nodes()) - assert num_of_in_nodes in {3, 4}, \ - "Node {} with op {} number of inputs must be equal to 3 or 4.".format(node.name, node.op) + assert (node.is_in_port_connected(0) and (node.is_in_port_connected(2) or node.is_in_port_connected(3))), \ + "One of the scales or sizes inputs must be connected to Node {} with op {}.".format(node.soft_get("name", node.id), + node.op) assert node.coordinate_transformation_mode != 'tf_crop_and_resize', \ - 'Mode tf_crop_and_resize is not supported for op {} with name {}'.format(node.op, node.name) + 'Mode tf_crop_and_resize is not supported for op {} with name {}'.format(node.op, + node.soft_get("name", node.id)) - if num_of_in_nodes == 3: + if not node.is_in_port_connected(3): # i.e. input 'sizes' is not given input2_value = node.in_port(2).data.get_value() assert input2_value is not None, \ @@ -53,7 +54,7 @@ def onnx_resize_infer(node: Node): # i.e. input 'sizes' is given sizes = node.in_port(3).data.get_value() assert sizes is not None, \ - "Node {} with op {} has no value in input port 3".format(node.name, node.op) + "Node {} with op {} has no value in input port 3".format(node.soft_get("name", node.id), node.op) output_shape = input_shape.copy() spatial_dimension_indices = range(2, len(input_shape)) output_shape[spatial_dimension_indices] = int64_array(sizes)[2:] diff --git a/model-optimizer/unit_tests/extensions/ops/ONNXResize11_test.py b/model-optimizer/unit_tests/extensions/ops/ONNXResize11_test.py index b38773b82798c2..aac234c56ba50e 100644 --- a/model-optimizer/unit_tests/extensions/ops/ONNXResize11_test.py +++ b/model-optimizer/unit_tests/extensions/ops/ONNXResize11_test.py @@ -33,10 +33,8 @@ ('input', 'input_data'), ('roi', 'roi_data'), ('sizes', 'sizes_data'), - ('scales', 'scales_data'), ('input_data', 'onnx_resize11', {'in': 0}), ('roi_data', 'onnx_resize11', {'in': 1}), - ('scales_data', 'onnx_resize11', {'in': 2}), ('sizes_data', 'onnx_resize11', {'in': 3}), ('onnx_resize11', 'onnx_resize11_data'), ('onnx_resize11_data', 'op_output'), @@ -125,3 +123,69 @@ def test_onnx_resize_using_scales(self, input_shape, output_shape, scales): self.assertTrue(np.array_equal(graph.node['onnx_resize11_data']['shape'], int64_array(output_shape)), msg.format(scales, output_shape, graph.node['onnx_resize11_data']['shape'])) + + @generate(*[([1, 260, 100, 150], [1, 260, 200, 350], [1, 260, 200, 350], [1.0, 1.0, 1.0, 1.0]), + ([1, 260, 100, 150], [1, 260, 200, 350], [1, 1, 200, 350], [1.0, 1.0, 1.0, 1.0]), + ([5, 14, 300, 40], [5, 14, 140, 280], [1, 1, 140, 280], [1.0, 1.0, 1.0, 1.0]), + ([5, 14, 300, 40], [5, 14, 140, 280], [5, 14, 140, 280], [1.0, 1.0, 1.0, 1.0]), + ([1, 3, 260, 100, 150], [1, 3, 780, 200, 350], [1, 3, 780, 200, 350], [1.0, 1.0, 1.0, 1.0, 1.0]), + ([1, 3, 450, 100, 150], [1, 3, 260, 200, 350], [1, 3, 260, 200, 350], [1.0, 1.0, 1.0, 1.0, 1.0]), + ([5, 14, 1000, 300, 40], [5, 14, 500, 140, 280], [1, 1, 500, 140, 280], [1.0, 1.0, 1.0, 1.0, 1.0]), + ([5, 14, 1000, 300, 40], [5, 14, 500, 140, 280], [5, 14, 500, 140, 280], [1.0, 1.0, 1.0, 1.0, 1.0])]) + def test_onnx_resize11_using_sizes_without_roi_input(self, input_shape, output_shape, sizes, scales): + np_scales = np.array(scales) + np_sizes = int64_array(sizes) + graph = build_graph(nodes_attrs=graph_node_attrs_sizes, + edges=[('input', 'input_data'), + ('sizes', 'sizes_data'), + ('input_data', 'onnx_resize11', {'in': 0}), + ('sizes_data', 'onnx_resize11', {'in': 3}), + ('onnx_resize11', 'onnx_resize11_data'), + ('onnx_resize11_data', 'op_output'), + ], + update_attributes={ + 'input_data': {'shape': int64_array(input_shape)}, + 'scales': {'shape': int64_array(np_scales.shape), 'value': np_scales}, + 'scales_data': {'shape': int64_array(np_scales.shape), 'value': np_scales}, + 'sizes': {'shape': int64_array(np_sizes.shape), 'value': np_sizes}, + 'sizes_data': {'shape': int64_array(np_sizes.shape), 'value': np_sizes}, + }) + node = Node(graph, 'onnx_resize11') + ONNXResize11Op.onnx_resize_infer(node) + + msg = "ONNXResize11 infer failed for case: sizes={}, scales={}, expected_shape={}, actual_shape={}" + + self.assertTrue(np.array_equal(graph.node['onnx_resize11_data']['shape'], int64_array(output_shape)), + msg.format(sizes, scales, output_shape, graph.node['onnx_resize11_data']['shape'])) + + @generate(*[([1, 260, 100, 150], [1, 260, 200, 350], [1.0, 1.0, 2.0, 350 / 150]), + ([1, 3, 100, 200], [1, 3, 350, 150], [1.0, 1.0, 3.5, 150 / 200]), + ([5, 14, 300, 40], [5, 14, 140, 280], [1.0, 1.0, 140 / 300, 7.0]), + ([5, 14, 300, 40], [5, 14, 140, 560], [1.0, 1.0, 140 / 300, 14.0]), + ([1, 3, 260, 100, 150], [1, 3, 780, 200, 350], [1.0, 1.0, 3.0, 2.0, 350 / 150]), + ([1, 3, 450, 100, 150], [1, 3, 260, 200, 350], [1.0, 1.0, 260 / 450, 2.0, 350 / 150]), + ([5, 14, 1000, 300, 40], [5, 14, 500, 140, 280], [1.0, 1.0, 0.5, 140 / 300, 7.0]), + ([4, 3, 180, 1340], [4, 3, 60, 804], [1.0, 1.0, 0.33333334, 0.6]), + ([4, 3, 500, 180, 1340], [4, 3, 750, 60, 804], [1.0, 1.0, 1.5, 0.33333334, 0.6])]) + def test_onnx_resize_using_scales_without_roi(self, input_shape, output_shape, scales): + np_scales = np.array(scales) + graph = build_graph(nodes_attrs=graph_node_attrs_scales, + edges=[('input', 'input_data'), + ('scales', 'scales_data'), + ('input_data', 'onnx_resize11', {'in': 0}), + ('scales_data', 'onnx_resize11', {'in': 2}), + ('onnx_resize11', 'onnx_resize11_data'), + ('onnx_resize11_data', 'op_output'), + ], + update_attributes={ + 'input_data': {'shape': int64_array(input_shape)}, + 'scales': {'shape': int64_array(np_scales.shape), 'value': np_scales}, + 'scales_data': {'shape': int64_array(np_scales.shape), 'value': np_scales}, + }) + node = Node(graph, 'onnx_resize11') + ONNXResize11Op.onnx_resize_infer(node) + + msg = "ONNXResize11 infer failed for case: scales={}, expected_shape={}, actual_shape={}" + + self.assertTrue(np.array_equal(graph.node['onnx_resize11_data']['shape'], int64_array(output_shape)), + msg.format(scales, output_shape, graph.node['onnx_resize11_data']['shape'])) From 76313a0ffa2896e76d01180f0843e7c860d9a719 Mon Sep 17 00:00:00 2001 From: Andrey Zaytsev Date: Tue, 8 Jun 2021 13:39:35 +0300 Subject: [PATCH 027/178] Feature/azaytsev/update license aggrements link (#6068) * Added info on DockerHub CI Framework * Feature/azaytsev/change layout (#3295) * Changes according to feedback comments * Replaced @ref's with html links * Fixed links, added a title page for installing from repos and images, fixed formatting issues * Added links * minor fix * Added DL Streamer to the list of components installed by default * Link fixes * Link fixes * ovms doc fix (#2988) * added OpenVINO Model Server * ovms doc fixes Co-authored-by: Trawinski, Dariusz * Updated openvino_docs.xml * Updated the link to software license agreements * Revert "Updated the link to software license agreements" This reverts commit 706dac500e764bd7534f7005ac6197f827d68cb5. * Updated the link to software license agreements Co-authored-by: Trawinski, Dariusz --- docs/install_guides/installing-openvino-apt.md | 2 +- docs/install_guides/installing-openvino-yum.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/install_guides/installing-openvino-apt.md b/docs/install_guides/installing-openvino-apt.md index 665186969912da..1bd734bd856969 100644 --- a/docs/install_guides/installing-openvino-apt.md +++ b/docs/install_guides/installing-openvino-apt.md @@ -2,7 +2,7 @@ This guide provides installation steps for Intel® Distribution of OpenVINO™ toolkit for Linux* distributed through the APT repository. -> **IMPORTANT**: By downloading and using this container and the included software, you agree to the terms and conditions of the [software license agreements](https://software.intel.com/en-us/license/eula-for-intel-software-development-products). Please, review the content inside the `/licensing` folder for more details. +> **IMPORTANT**: By downloading and using this container and the included software, you agree to the terms and conditions of the [software license agreements](https://software.intel.com/content/dam/develop/external/us/en/documents/intel-openvino-license-agreements.pdf). Please, review the content inside the `/licensing` folder for more details. > **NOTE**: Intel® Graphics Compute Runtime for OpenCL™ is not a part of OpenVINO™ APT distribution. You can install it from the [Intel® Graphics Compute Runtime for OpenCL™ GitHub repo](https://github.com/intel/compute-runtime). diff --git a/docs/install_guides/installing-openvino-yum.md b/docs/install_guides/installing-openvino-yum.md index 27e464d1b84bd5..c326cb93a0f6c1 100644 --- a/docs/install_guides/installing-openvino-yum.md +++ b/docs/install_guides/installing-openvino-yum.md @@ -2,7 +2,7 @@ This guide provides installation steps for the Intel® Distribution of OpenVINO™ toolkit for Linux* distributed through the YUM repository. -> **IMPORTANT**: By downloading and using this container and the included software, you agree to the terms and conditions of the [software license agreements](https://software.intel.com/en-us/license/eula-for-intel-software-development-products). Please, review the content inside the `/licensing` folder for more details. +> **IMPORTANT**: By downloading and using this container and the included software, you agree to the terms and conditions of the [software license agreements](https://software.intel.com/content/dam/develop/external/us/en/documents/intel-openvino-license-agreements.pdf). Please, review the content inside the `/licensing` folder for more details. > **NOTE**: Intel® Graphics Compute Runtime for OpenCL™ is not a part of OpenVINO™ YUM distribution. You can install it from the [Intel® Graphics Compute Runtime for OpenCL™ GitHub repo](https://github.com/intel/compute-runtime). From 440d3ee0ba59700c9ced758877f4033e91c93b8c Mon Sep 17 00:00:00 2001 From: Andrey Zaytsev Date: Tue, 8 Jun 2021 13:49:01 +0300 Subject: [PATCH 028/178] Feature/azaytsev/update gpu driver link (#6062) * Added info on DockerHub CI Framework * Feature/azaytsev/change layout (#3295) * Changes according to feedback comments * Replaced @ref's with html links * Fixed links, added a title page for installing from repos and images, fixed formatting issues * Added links * minor fix * Added DL Streamer to the list of components installed by default * Link fixes * Link fixes * ovms doc fix (#2988) * added OpenVINO Model Server * ovms doc fixes Co-authored-by: Trawinski, Dariusz * Updated openvino_docs.xml * Updated link * Update installing-openvino-windows.md Co-authored-by: Trawinski, Dariusz --- docs/install_guides/installing-openvino-windows.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/install_guides/installing-openvino-windows.md b/docs/install_guides/installing-openvino-windows.md index 1a1a31a07c61fe..054950292b6337 100644 --- a/docs/install_guides/installing-openvino-windows.md +++ b/docs/install_guides/installing-openvino-windows.md @@ -248,8 +248,8 @@ Or proceed to the Get Started to get started with run > **NOTE**: These steps are required only if you want to use an Intel® integrated GPU. -If your applications offload computation to **Intel® Integrated Graphics**, you must have the latest version of Intel Graphics Driver for Windows installed for your hardware. -[Download and install a higher version](http://downloadcenter.intel.com/product/80939/Graphics-Drivers). +If your applications offload computation to **Intel® Integrated Graphics**, you must have the Intel Graphics Driver for Windows installed for your hardware. +[Download and install the recommended version](https://downloadcenter.intel.com/download/30079/Intel-Graphics-Windows-10-DCH-Drivers). To check if you have this driver installed: @@ -265,8 +265,6 @@ To check if you have this driver installed: ![](../img/DeviceDriverVersion.PNG) -> **NOTE**: To use the **Intel® Iris® Xe MAX Graphics**, see the [Drivers & Software](https://downloadcenter.intel.com/download/29993/Intel-Iris-Xe-MAX-Dedicated-Graphics-Drivers?product=80939) page for driver downloads and installation instructions. - You are done updating your device driver and are ready to use your GPU. Proceed to the Get Started to get started with running code samples and demo applications. ### Optional: Additional Installation Steps for the Intel® Vision Accelerator Design with Intel® Movidius™ VPUs From 9214fa72e2809cf7a353082a7107092f25770508 Mon Sep 17 00:00:00 2001 From: Alexandra Sidorova Date: Tue, 8 Jun 2021 14:04:31 +0300 Subject: [PATCH 029/178] [CPU] Fixed AvgPooling and FQ fusing (#5994) --- .../plugin/cpu/single_layer_tests/pooling.cpp | 82 ++++++++++++++++--- .../cpu/test_utils/fusing_test_utils.hpp | 7 ++ inference-engine/thirdparty/mkl-dnn | 2 +- 3 files changed, 80 insertions(+), 11 deletions(-) diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/pooling.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/pooling.cpp index 72dbe0d5e12e60..0df9c464c4f5fd 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/pooling.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/pooling.cpp @@ -5,6 +5,7 @@ #include "ngraph_functions/builders.hpp" #include "test_utils/cpu_test_utils.hpp" #include "shared_test_classes/single_layer/pooling.hpp" +#include "test_utils/fusing_test_utils.hpp" using namespace InferenceEngine; using namespace CPUTestUtils; @@ -13,21 +14,24 @@ using namespace LayerTestsDefinitions; namespace CPULayerTestsDefinitions { typedef std::tuple< poolLayerTestParamsSet, - CPUSpecificParams + CPUSpecificParams, + fusingSpecificParams > poolLayerCpuTestParamsSet; class PoolingLayerCPUTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon, public CPUTestsBase { + virtual public LayerTestsUtils::LayerTestsCommon, public CpuTestWithFusing { public: static std::string getTestCaseName(const testing::TestParamInfo& obj) { poolLayerTestParamsSet basicParamsSet; CPUSpecificParams cpuParams; - std::tie(basicParamsSet, cpuParams) = obj.param; + fusingSpecificParams fusingParams; + std::tie(basicParamsSet, cpuParams, fusingParams) = obj.param; std::ostringstream result; result << PoolingLayerTest::getTestCaseName(testing::TestParamInfo( basicParamsSet, 0)); result << CPUTestsBase::getTestCaseName(cpuParams); + result << CpuTestWithFusing::getTestCaseName(fusingParams); return result.str(); } @@ -36,7 +40,8 @@ class PoolingLayerCPUTest : public testing::WithParamInterfaceGetParam(); + fusingSpecificParams fusingParams; + std::tie(basicParamsSet, cpuParams, fusingParams) = this->GetParam(); poolSpecificParams poolParams; std::vector inputShape; @@ -48,6 +53,7 @@ class PoolingLayerCPUTest : public testing::WithParamInterface({1, 3, 64, 64})), ::testing::Values(CommonTestUtils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigs))), + ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigs)), + ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_4D, PoolingLayerCPUTest, @@ -147,7 +154,8 @@ INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_4D, PoolingLayerCPUTest, ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(std::vector({1, 4, 64, 64})), ::testing::Values(CommonTestUtils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigs))), + ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigs)), + ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_4D_NotOptimized, PoolingLayerCPUTest, @@ -161,7 +169,8 @@ INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_4D_NotOptimized, PoolingLayerCPUTest, ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(std::vector({1, 4, 64, 64})), ::testing::Values(CommonTestUtils::DEVICE_CPU)), - ::testing::Values(ref)), + ::testing::Values(ref), + ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); const std::vector paramsMax5D = { @@ -200,7 +209,8 @@ INSTANTIATE_TEST_CASE_P(smoke_MaxPool_CPU_5D, PoolingLayerCPUTest, ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(std::vector({1, 3, 16, 32, 32})), ::testing::Values(CommonTestUtils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigs))), + ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigs)), + ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_5D, PoolingLayerCPUTest, @@ -214,7 +224,8 @@ INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_5D, PoolingLayerCPUTest, ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(std::vector({1, 4, 32, 32, 32})), ::testing::Values(CommonTestUtils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigs))), + ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigs)), + ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_5D_NotOptimized, PoolingLayerCPUTest, @@ -228,7 +239,58 @@ INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_5D_NotOptimized, PoolingLayerCPUTest, ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(std::vector({1, 4, 16, 16, 16})), ::testing::Values(CommonTestUtils::DEVICE_CPU)), - ::testing::Values(ref)), + ::testing::Values(ref), + ::testing::Values(emptyFusingSpec)), + PoolingLayerCPUTest::getTestCaseName); + +/* === Fusing === */ + +const auto avx512_nhwc = CPUSpecificParams{{nhwc}, {nhwc}, {"jit_avx512"}, "jit_avx512"}; +const auto avx512_ndhwc = CPUSpecificParams{{ndhwc}, {ndhwc}, {"jit_avx512"}, "jit_avx512"}; + +const auto avx2_nhwc = CPUSpecificParams{{nhwc}, {nhwc}, {"jit_avx2"}, "jit_avx2"}; +const auto avx2_ndhwc = CPUSpecificParams{{ndhwc}, {ndhwc}, {"jit_avx2"}, "jit_avx2"}; + +const auto sse42_nhwc = CPUSpecificParams{{nhwc}, {nhwc}, {"jit_sse42"}, "jit_sse42"}; +const auto sse42_ndhwc = CPUSpecificParams{{ndhwc}, {ndhwc}, {"jit_sse42"}, "jit_sse42"}; + +const std::vector vecCpuConfigsFusing_4D = {sse42_nhwc, avx2_nhwc, avx512_nhwc}; +const std::vector vecCpuConfigsFusing_5D = {sse42_ndhwc, avx2_ndhwc, avx512_ndhwc}; + +std::vector fusingParamsSet { + emptyFusingSpec, + fusingFakeQuantizePerTensor, + fusingFakeQuantizePerChannel, +}; + +INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_4D_I8, PoolingLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + ::testing::ValuesIn(paramsAvg4D), + ::testing::Values(Precision::FP32), + ::testing::Values(Precision::I8), + ::testing::Values(Precision::FP32), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(std::vector({1, 4, 64, 64})), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_4D)), + ::testing::ValuesIn(fusingParamsSet)), + PoolingLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_5D_I8, PoolingLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + ::testing::ValuesIn(paramsAvg5D), + ::testing::Values(Precision::FP32), + ::testing::Values(Precision::I8), + ::testing::Values(Precision::FP32), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(std::vector({1, 4, 16, 16, 16})), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_5D)), + ::testing::ValuesIn(fusingParamsSet)), PoolingLayerCPUTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/test_utils/fusing_test_utils.hpp b/inference-engine/tests/functional/plugin/cpu/test_utils/fusing_test_utils.hpp index 0e5fc43d366f72..d55f2a988593b2 100644 --- a/inference-engine/tests/functional/plugin/cpu/test_utils/fusing_test_utils.hpp +++ b/inference-engine/tests/functional/plugin/cpu/test_utils/fusing_test_utils.hpp @@ -216,6 +216,13 @@ const auto fusingScaleShift = fusingSpecificParams{ std::make_shared(inpNode, constNode); }, "Add(PerChannel)"}}), {"Add"} }; +const auto fusingFakeQuantizePerTensor = fusingSpecificParams{ std::make_shared(std::vector{ + {[](std::shared_ptr inpNode, const ngraph::element::Type& ngPrc, ngraph::ParameterVector& params){ + auto localPrc = inpNode->get_element_type(); + ngraph::Shape newShape(inpNode->get_shape().size(), 1); + return ngraph::builder::makeFakeQuantize(inpNode, localPrc, 256, newShape); + }, "FakeQuantize(PerTensor)"}}), {"FakeQuantize"} }; + const auto fusingFakeQuantizePerChannel = fusingSpecificParams{std::make_shared(std::vector{ {[](std::shared_ptr inpNode, const ngraph::element::Type& ngPrc, ngraph::ParameterVector& params){ auto localPrc = inpNode->get_element_type(); diff --git a/inference-engine/thirdparty/mkl-dnn b/inference-engine/thirdparty/mkl-dnn index aa47fcd2a03ee5..1cb9d0615aaf51 160000 --- a/inference-engine/thirdparty/mkl-dnn +++ b/inference-engine/thirdparty/mkl-dnn @@ -1 +1 @@ -Subproject commit aa47fcd2a03ee5caac119b6417bc66abe3154aab +Subproject commit 1cb9d0615aaf511b51b8f8fc3c3ff8805ad9be6c From a7a9364b417b35464d352622254517f4ce602848 Mon Sep 17 00:00:00 2001 From: Irina Efode Date: Tue, 8 Jun 2021 14:23:45 +0300 Subject: [PATCH 030/178] [IE TESTS] Add local_cache arg to the subgraphDumper (#6063) --- .../conformance/subgraphs_dumper/README.md | 1 + .../subgraphs_dumper/include/gflag_config.hpp | 5 ++- .../conformance/subgraphs_dumper/src/main.cpp | 38 +++++++++++++------ 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/inference-engine/tests/functional/plugin/conformance/subgraphs_dumper/README.md b/inference-engine/tests/functional/plugin/conformance/subgraphs_dumper/README.md index 1f21dd1c07ff49..07b50de8409749 100644 --- a/inference-engine/tests/functional/plugin/conformance/subgraphs_dumper/README.md +++ b/inference-engine/tests/functional/plugin/conformance/subgraphs_dumper/README.md @@ -17,6 +17,7 @@ Outcome of a build is a `subgrpahsDumper` binary located in building artifacts f ## Running The tool takes two command line parameters: * `--input_folders` - Required. Comma separated paths to the input folders with IRs +* `--local_cache` - Optional. Comma separated paths to the local cache folders with IRs. * `--output_folder` - Required. Path to the output folders where to serialize IRs * `--path_regex` - Optional. regular expression to be applied in input folders recursive discovery * `--constants_size_threshold` - Optional. Maximum size of constant in megabytes to be serialized. diff --git a/inference-engine/tests/functional/plugin/conformance/subgraphs_dumper/include/gflag_config.hpp b/inference-engine/tests/functional/plugin/conformance/subgraphs_dumper/include/gflag_config.hpp index c37e45c445be24..13ad0007de73b5 100644 --- a/inference-engine/tests/functional/plugin/conformance/subgraphs_dumper/include/gflag_config.hpp +++ b/inference-engine/tests/functional/plugin/conformance/subgraphs_dumper/include/gflag_config.hpp @@ -9,6 +9,7 @@ static const char help_message[] = "Print a usage message."; static const char input_folders_message[] = "Required. Comma separated paths to the input folders with IRs"; +static const char local_cache_message[] = "Optional. Comma separated paths to the local cache folders with IRs"; static const char output_folder_message[] = "Required. Path to the output folders where to serialize IRs"; static const char path_regex_message[] = "Optional. regular expression to be applied in input " "folders recursive discovery"; @@ -21,7 +22,8 @@ static const char eliminate_dynamism_message[] = "Optional. If specified dynamic "and replaced by propagated upper bound values (if possible)"; DEFINE_bool(h, false, help_message); -DEFINE_string(input_folders, ".", input_folders_message); +DEFINE_string(input_folders, "", local_cache_message); +DEFINE_string(local_cache, ".", input_folders_message); DEFINE_string(output_folder, "output", output_folder_message); DEFINE_string(path_regex, ".*", output_folder_message); DEFINE_double(constants_size_threshold, 1., constants_size_threshold_message); @@ -37,6 +39,7 @@ static void showUsage() { std::cout << "\n"; std::cout << " -h " << help_message << "\n"; std::cout << " --input_folders \"\" " << input_folders_message << "\n"; + std::cout << " --local_cache \"\" " << input_folders_message << "\n"; std::cout << " --output_folder \"\" " << output_folder_message << "\n"; std::cout << " --path_regex \"\" " << path_regex_message << "\n"; std::cout << " --constants_size_threshold \"\" " << constants_size_threshold_message << "\n"; diff --git a/inference-engine/tests/functional/plugin/conformance/subgraphs_dumper/src/main.cpp b/inference-engine/tests/functional/plugin/conformance/subgraphs_dumper/src/main.cpp index 0bd42bf169df2b..16f8f55a98b4b6 100644 --- a/inference-engine/tests/functional/plugin/conformance/subgraphs_dumper/src/main.cpp +++ b/inference-engine/tests/functional/plugin/conformance/subgraphs_dumper/src/main.cpp @@ -19,17 +19,8 @@ #include #include -int main(int argc, char *argv[]) { - uint8_t ret_code = 0; - - gflags::ParseCommandLineNonHelpFlags(&argc, &argv, true); - if (FLAGS_h) { - showUsage(); - return 0; - } - SubgraphsDumper::ClonersMap::constant_size_threshold_mb = FLAGS_constants_size_threshold; +std::vector findModelsInDirs(const std::vector &dirs) { std::vector input_folder_content; - std::vector dirs = CommonTestUtils::splitStringByDelimiter(FLAGS_input_folders); for (const auto &dir : dirs) { if (!CommonTestUtils::directoryExists(dir)) { std::string msg = "Input directory (" + dir + ") doesn't not exist!"; @@ -51,9 +42,13 @@ int main(int argc, char *argv[]) { std::string msg = "Output directory (" + FLAGS_output_folder + ") doesn't not exist!"; throw std::runtime_error(msg); } + return models; +} +void cacheModels(std::unique_ptr &cache, + uint8_t& ret_code, + const std::vector& models) { auto ie = InferenceEngine::Core(); - auto cache = SubgraphsDumper::OPCache::make_cache(); time_t rawtime; struct tm *timeinfo; char buffer[20]; @@ -92,6 +87,27 @@ int main(int argc, char *argv[]) { } } } +} + + +int main(int argc, char *argv[]) { + uint8_t ret_code = 0; + + gflags::ParseCommandLineNonHelpFlags(&argc, &argv, true); + if (FLAGS_h) { + showUsage(); + return 0; + } + SubgraphsDumper::ClonersMap::constant_size_threshold_mb = FLAGS_constants_size_threshold; + + std::vector local_cache_dirs = CommonTestUtils::splitStringByDelimiter(FLAGS_local_cache); + std::vector dirs = CommonTestUtils::splitStringByDelimiter(FLAGS_input_folders); + auto cachedOps = findModelsInDirs(local_cache_dirs); + auto models = findModelsInDirs(dirs); + + auto cache = SubgraphsDumper::OPCache::make_cache(); + cacheModels(cache, ret_code, cachedOps); + cacheModels(cache, ret_code, models); cache->serialize_cached_ops(FLAGS_output_folder); return ret_code; From 9e34622ac1f899b3c6ddd151aadb3696ffc961eb Mon Sep 17 00:00:00 2001 From: Edward Shogulin Date: Tue, 8 Jun 2021 15:29:30 +0300 Subject: [PATCH 031/178] [LPT] Concat precision selection fix (#6069) --- .../src/concat.cpp | 38 ++- .../src/concat_multi_channels.cpp | 15 +- ...ate_precision_selection_transformation.cpp | 317 ++++++++++++++++++ .../simple_low_precision_transformer.cpp | 36 +- .../simple_low_precision_transformer.hpp | 16 +- .../lpt_ngraph_functions/concat_function.hpp | 19 ++ .../src/concat_function.cpp | 123 +++++++ 7 files changed, 541 insertions(+), 23 deletions(-) create mode 100644 inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_precision_selection_transformation.cpp diff --git a/inference-engine/src/low_precision_transformations/src/concat.cpp b/inference-engine/src/low_precision_transformations/src/concat.cpp index 4988e29b1e289a..f6d860ed17225c 100644 --- a/inference-engine/src/low_precision_transformations/src/concat.cpp +++ b/inference-engine/src/low_precision_transformations/src/concat.cpp @@ -43,19 +43,21 @@ bool ConcatTransformation::transform(TransformationContext& context, ngraph::pat return false; } - // precisions can be different + // Concat operations precision is defined: + // 1. consumers after Concat + // 2. FakeQuantize precisions without zero point ngraph::Node& quantizationLayer = *subgraph.quantizationLayers[0]; std::shared_ptr fq = ngraph::as_type_ptr(quantizationLayer.shared_from_this()); if (!NetworkHelper::isQuantizeSupported(fq)) { return false; } - - std::vector concatParentsChildrensPrecisions = precisionsOnActivations; - fillAvailablePrecisions(subgraph.quantizationLayers[0], concatParentsChildrensPrecisions); - if (concatParentsChildrensPrecisions.empty()) { + DataPrecision dataPrecision = getDataPrecision(fq, QuantizationDetails::getDetails(fq), false); + if (dataPrecision.precision == ngraph::element::undefined) { return false; } + std::vector concatChildrenPrecisions = precisionsOnActivations; + for (size_t i = 0; i < subgraph.quantizationLayers.size(); ++i) { fq = ngraph::as_type_ptr(subgraph.quantizationLayers[i]); if (fq == nullptr) { @@ -72,20 +74,28 @@ bool ConcatTransformation::transform(TransformationContext& context, ngraph::pat if (quantizationDetails.inputHighValues.size() != 1ul) { return false; } - std::vector fqChildrensPrecisions = precisionsOnActivations; - fillAvailablePrecisions(subgraph.quantizationLayers[i], fqChildrensPrecisions); - concatParentsChildrensPrecisions = NetworkHelper::precisionIntersection(concatParentsChildrensPrecisions, fqChildrensPrecisions); - if (concatParentsChildrensPrecisions.empty()) { + // define concatenation operation consumers precisions + std::vector fqChildrenPrecisions = precisionsOnActivations; + fillAvailablePrecisions(subgraph.quantizationLayers[i], fqChildrenPrecisions); + concatChildrenPrecisions = NetworkHelper::precisionIntersection(concatChildrenPrecisions, fqChildrenPrecisions); + if (concatChildrenPrecisions.empty()) { + return false; + } + + // define FakeQuantize precisions without zero point + const DataPrecision dataPrecision2 = getDataPrecision(subgraph.quantizationLayers[i]->shared_from_this(), quantizationDetails, false); + if (dataPrecision2.precision == ngraph::element::undefined) { return false; } + + if (dataPrecision.precision != dataPrecision2.precision) { + dataPrecision = dataPrecision.precision.is_signed() ? dataPrecision : dataPrecision2; + } } - DataPrecision dataPrecision; - if (std::find(concatParentsChildrensPrecisions.begin(), concatParentsChildrensPrecisions.end(), element::i8) != concatParentsChildrensPrecisions.end()) { - dataPrecision = DataPrecision(element::i8); - } else { - dataPrecision = DataPrecision(concatParentsChildrensPrecisions[0]); + if (std::find(concatChildrenPrecisions.begin(), concatChildrenPrecisions.end(), dataPrecision.precision) == concatChildrenPrecisions.end()) { + dataPrecision = DataPrecision(concatChildrenPrecisions[0]); } std::vector quantizationLayersDetails; diff --git a/inference-engine/src/low_precision_transformations/src/concat_multi_channels.cpp b/inference-engine/src/low_precision_transformations/src/concat_multi_channels.cpp index dc81d51cd717de..e36c2b5aa74528 100644 --- a/inference-engine/src/low_precision_transformations/src/concat_multi_channels.cpp +++ b/inference-engine/src/low_precision_transformations/src/concat_multi_channels.cpp @@ -64,14 +64,23 @@ bool ConcatMultiChannelsTransformation::transform(TransformationContext& context DataPrecision dataPrecision; { + std::vector concatChildrenPrecisions = precisionsOnActivations; for (auto quantizationLayer : subgraph.quantizationLayers) { std::shared_ptr fq = ngraph::as_type_ptr(quantizationLayer->shared_from_this()); if (!NetworkHelper::isQuantizeSupported(fq)) { return false; } - const DataPrecision tmp = getDataPrecision(fq, QuantizationDetails::getDetails(fq), false); + // define concatenation operation consumers precisions + std::vector fqChildrenPrecisions = precisionsOnActivations; + fillAvailablePrecisions(quantizationLayer, fqChildrenPrecisions); + concatChildrenPrecisions = NetworkHelper::precisionIntersection(concatChildrenPrecisions, fqChildrenPrecisions); + if (concatChildrenPrecisions.empty()) { + return false; + } + // define FakeQuantize precisions without zero point + const DataPrecision tmp = getDataPrecision(fq, QuantizationDetails::getDetails(fq), false); if (dataPrecision.precision == ngraph::element::undefined) { dataPrecision = tmp; continue; @@ -81,6 +90,10 @@ bool ConcatMultiChannelsTransformation::transform(TransformationContext& context dataPrecision = tmp; } } + + if (std::find(concatChildrenPrecisions.begin(), concatChildrenPrecisions.end(), dataPrecision.precision) == concatChildrenPrecisions.end()) { + dataPrecision = DataPrecision(concatChildrenPrecisions[0]); + } } for (size_t i = 0; i < subgraph.quantizationLayers.size(); ++i) { diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_precision_selection_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_precision_selection_transformation.cpp new file mode 100644 index 00000000000000..0d6b29d5fe55d4 --- /dev/null +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_precision_selection_transformation.cpp @@ -0,0 +1,317 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "layer_transformation.hpp" + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "common_test_utils/ngraph_test_utils.hpp" +#include "lpt_ngraph_functions/concat_function.hpp" +#include "lpt_ngraph_functions/common/fake_quantize_on_data.hpp" +#include "simple_low_precision_transformer.hpp" + +using namespace testing; +using namespace ngraph; +using namespace ngraph::pass; + +namespace { + +class ConcatTransformationActualValues { +public: + ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize1; + ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize2; +}; + +inline std::ostream& operator<<(std::ostream& out, const ConcatTransformationActualValues& values) { + return out << "_" << values.fakeQuantize1 << "_" << values.fakeQuantize2; +} + +class ConcatTransformationResultValues { +public: + ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize1; + ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize2; + ngraph::element::Type precisionBeforeOp; + ngraph::builder::subgraph::DequantizationOperations dequantizationBefore1; + ngraph::builder::subgraph::DequantizationOperations dequantizationBefore2; + ngraph::element::Type precisionAfterOperation; + ngraph::builder::subgraph::DequantizationOperations dequantizationAfter1; + ngraph::builder::subgraph::DequantizationOperations dequantizationAfter2; +}; + +inline std::ostream& operator<<(std::ostream& out, const ConcatTransformationResultValues& values) { + return out << "_" << + values.fakeQuantize1 << "_" << + values.fakeQuantize2 << "_" << + values.dequantizationAfter1 << "_" << + values.dequantizationAfter2; +} + +class ConcatTransformationTestValues { +public: + ngraph::pass::low_precision::LayerTransformation::Params params; + bool multiChannels; + ConcatTransformationActualValues actual; + ConcatTransformationResultValues result; +}; + +inline std::ostream& operator<<(std::ostream& out, const ConcatTransformationTestValues& values) { + return out << "_" << values.multiChannels << "_" << values.actual << "_" << values.result; +} + +typedef std::tuple < + ngraph::element::Type, + ngraph::Shape, + ConcatTransformationTestValues +> ConcatTransformationParams; + +class ConcatWithIntermediatePrecisionSelectionTransformation : public LayerTransformation, public testing::WithParamInterface { +public: + void SetUp() override { + const ngraph::element::Type precision = std::get<0>(GetParam()); + const ngraph::Shape shape = std::get<1>(GetParam()); + ConcatTransformationTestValues testValues = std::get<2>(GetParam()); + + actualFunction = ngraph::builder::subgraph::ConcatFunction::getOriginalWithIntermediateAvgPool( + precision, + shape, + testValues.actual.fakeQuantize1, + testValues.actual.fakeQuantize2); + + SimpleLowPrecisionTransformer transform; + if (testValues.multiChannels) { + transform.addBranchSpecific(testValues.params); + } else { + transform.addBranchSpecific(testValues.params); + } + transform.add(testValues.params); + transform.add(testValues.params); + transform.transform(actualFunction); + + referenceFunction = ngraph::builder::subgraph::ConcatFunction::getReferenceWithIntermediateAvgPool( + precision, + shape, + testValues.result.fakeQuantize1, + testValues.result.fakeQuantize2, + testValues.result.precisionBeforeOp, + testValues.result.dequantizationBefore1, + testValues.result.dequantizationBefore2, + testValues.result.precisionAfterOperation, + testValues.result.dequantizationAfter1, + testValues.result.dequantizationAfter2); + } + + static std::string getTestCaseName(testing::TestParamInfo obj) { + const ngraph::element::Type precision = std::get<0>(obj.param); + const ngraph::Shape shape = std::get<1>(obj.param); + const ConcatTransformationTestValues testValues = std::get<2>(obj.param); + + std::ostringstream result; + result << + LayerTransformation::getTestCaseNameByParams(precision, shape, testValues.params) << "_" << + (testValues.multiChannels ? "multiChannels_" : "notMultiChannels_") << + testValues.actual << "_" << + testValues.result << "_"; + return result.str(); + } +}; + +TEST_P(ConcatWithIntermediatePrecisionSelectionTransformation, CompareFunctions) { + actualFunction->validate_nodes_and_infer_types(); + auto res = compare_functions(referenceFunction, actualFunction, true, false, true); + ASSERT_TRUE(res.first) << res.second; +} + +const std::vector precisions = { + ngraph::element::f32, + // ngraph::element::f16 +}; + +const std::vector testValues = { + // Concat: FakeQuantize operations with signed intervals but consumer requires U8 + { + LayerTransformation::createParamsU8I8(), + false, + { + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-1.28f}, {1.27f} }, + { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-1.28f / 2.f}, {1.27f / 2.f} } + }, + { + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {0.f}, {255.f} }, + { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {64.f}, {192.f} }, + ngraph::element::u8, + {{}, {}, {}}, + {{}, {}, {}}, + ngraph::element::u8, + { ngraph::element::f32, { 128.f }, { 0.01f } }, + { {}, { 128.f }, { 0.01f } } + } + }, + + // Concat: FakeQuantize operations with unsigned intervals but consumer requires I8 + { + LayerTransformation::createParamsI8I8(), + false, + { + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, {2.55f / 2.f} } + }, + { + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {-128.f}, {127.f} }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {-128.f}, { -0.f} }, + ngraph::element::i8, + {{}, {}, {}}, + {{}, {}, {}}, + ngraph::element::i8, + { ngraph::element::f32, { -128.f }, { 0.01f } }, + { {}, { -128.f }, { 0.01f } } + } + }, + + // ConcatMultichannel: FakeQuantize operations with signed intervals but consumer requires U8 + { + LayerTransformation::createParamsU8I8(), + true, + { + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-1.28f}, {1.27f} }, + { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-1.28f / 2.f}, {1.27f / 2.f} } + }, + { + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {0.f}, {255.f} }, + { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {0.f}, { 255.f} }, + ngraph::element::u8, + {}, + {}, + ngraph::element::u8, + { ngraph::element::f32, { 128.f }, {{ 0.01f, 0.01f, 0.01f, 0.005f, 0.005f, 0.005f }} }, + { {}, { 128.f }, { 0.005f } } + } + }, + + // ConcatMultichannel: FakeQuantize operations with unsigned intervals but consumer requires I8 + { + LayerTransformation::createParamsI8I8(), + true, + { + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, {2.55f / 2.f} } + }, + { + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {-128.f}, {127.f} }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {-128.f}, { 127.f} }, + ngraph::element::i8, + {{}, {}, {}}, + {{}, {}, {}}, + ngraph::element::i8, + { ngraph::element::f32, { -128.f }, {{ 0.01f, 0.01f, 0.01f, 0.005f, 0.005f, 0.005f }} }, + { {}, { -128.f }, { 0.005f } } + } + }, + + // Concat: FakeQuantize operations with unsigned intervals, no consumer limitations: FQ were decomposed to U8 precision + { + LayerTransformation::createParamsU8I8AndI8(), + false, + { + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, {2.55f / 2.f} } + }, + { + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, { 128.f} }, + ngraph::element::u8, + {{}, {}, {}}, + {{}, {}, {}}, + ngraph::element::u8, + { ngraph::element::f32, {}, { 0.01f } }, + { {}, {}, { 0.01f } } + } + }, + + // Concat: FakeQuantize operations with signed intervals, no consumer limitations: FQ were decomposed to I8 precision + { + LayerTransformation::createParamsU8I8AndI8(), + false, + { + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-1.28f}, {1.27f} }, + { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-1.28f / 2.f}, {1.27f / 2.f} } + }, + { + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-128.f}, {127.f} }, + { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-64.f}, {64.f} }, + ngraph::element::i8, + {{}, {}, {}}, + {{}, {}, {}}, + ngraph::element::i8, + { ngraph::element::f32, {}, { 0.01f } }, + { {}, {}, { 0.01f } } + } + }, + + // ConcatMultichannel: FakeQuantize operations with unsigned intervals, no consumer limitations: FQ were decomposed to U8 precision + { + LayerTransformation::createParamsU8I8AndI8(), + true, + { + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, {2.55f / 2.f} } + }, + { + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, {255.f} }, + ngraph::element::u8, + {{}, {}, {}}, + {{}, {}, {}}, + ngraph::element::u8, + { ngraph::element::f32, {}, {{ 0.01f, 0.01f, 0.01f, 0.005f, 0.005f, 0.005f }} }, + { {}, {}, { 0.005f } } + } + }, + + // ConcatMultichannel: FakeQuantize operations with signed intervals, no consumer limitations: FQ were decomposed to I8 precision + { + LayerTransformation::createParamsU8I8AndI8(), + true, + { + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-1.28f}, {1.27f} }, + { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-1.28f / 2.f}, {1.27f / 2.f} } + }, + { + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-128.f}, {127.f} }, + { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-128.f}, {127.f} }, + ngraph::element::i8, + {{}, {}, {}}, + {{}, {}, {}}, + ngraph::element::i8, + { ngraph::element::f32, {}, {{ 0.01f, 0.01f, 0.01f, 0.005f, 0.005f, 0.005f }} }, + { {}, {}, { 0.005f } } + } + } +}; + +const std::vector shapes = { + { 1, 3, 9, 9 }, + { 4, 3, 9, 9 } +}; + +INSTANTIATE_TEST_CASE_P( + smoke_LPT, + ConcatWithIntermediatePrecisionSelectionTransformation, + ::testing::Combine( + ::testing::ValuesIn(precisions), + ::testing::ValuesIn(shapes), + ::testing::ValuesIn(testValues)), + ConcatWithIntermediatePrecisionSelectionTransformation::getTestCaseName); +} // namespace diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/simple_low_precision_transformer.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/simple_low_precision_transformer.cpp index 8ee17c8e39b966..3c48d56be5b099 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/simple_low_precision_transformer.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/simple_low_precision_transformer.cpp @@ -49,19 +49,41 @@ bool SimpleLowPrecisionTransformer::isPrecisionPreserved(const std::shared_ptr& function) { + // initialization + for (auto it : branchSpecificTransformations) { + ngraph::pass::low_precision::LayerTransformationPtr transformation = it.second; + transformation->setParamsManager(this); + transformation->setLayerTransformationsManager(this); + } + + for (auto it : transformations) { + ngraph::pass::low_precision::LayerTransformationPtr transformation = it.second; + transformation->setParamsManager(this); + transformation->setLayerTransformationsManager(this); + } + + // transformation { ngraph::pass::low_precision::TypeRelaxedReplacer pass; pass.run_on_function(function); } ngraph::pass::low_precision::TransformationContext context(function); - GraphRewrite pass; - for (auto it : transformations) { - ngraph::pass::low_precision::LayerTransformationPtr transformation = it.second; + { + GraphRewrite pass; + for (auto it : branchSpecificTransformations) { + ngraph::pass::low_precision::LayerTransformationPtr transformation = it.second; + transformation->registerMatcherIn(pass, context); + } + pass.run_on_function(function); + } - transformation->setParamsManager(this); - transformation->setLayerTransformationsManager(this); - transformation->registerMatcherIn(pass, context); + { + GraphRewrite pass; + for (auto it : transformations) { + ngraph::pass::low_precision::LayerTransformationPtr transformation = it.second; + transformation->registerMatcherIn(pass, context); + } + pass.run_on_function(function); } - pass.run_on_function(function); } diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/simple_low_precision_transformer.hpp b/inference-engine/tests/functional/inference_engine/lp_transformations/simple_low_precision_transformer.hpp index b4bf3a9c9787a7..c9582adf0f0115 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/simple_low_precision_transformer.hpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/simple_low_precision_transformer.hpp @@ -28,9 +28,22 @@ class SimpleLowPrecisionTransformer : public bool isQuantized(const std::shared_ptr& layer) const noexcept override; bool isPrecisionPreserved(const std::shared_ptr& layer) const noexcept override; + template + ngraph::pass::low_precision::LayerTransformationPtr addBranchSpecific(const ngraph::pass::low_precision::LayerTransformation::Params& params) { + const std::string typeName = ngraph::pass::low_precision::LowPrecisionTransformations::getType(); + + const auto it = branchSpecificTransformations.find(typeName); + if (it != branchSpecificTransformations.end()) { + branchSpecificTransformations.erase(it); + } + + auto transformation = std::make_shared(params); + branchSpecificTransformations.emplace(typeName, transformation); + return transformation; + } + template ngraph::pass::low_precision::LayerTransformationPtr add(const ngraph::pass::low_precision::LayerTransformation::Params& params) { - // const std::string typeName = typeid(ngraph::op::TypeRelaxed).name(); const std::string typeName = ngraph::pass::low_precision::LowPrecisionTransformations::getType(); const auto it = transformations.find(typeName); @@ -46,5 +59,6 @@ class SimpleLowPrecisionTransformer : public void transform(std::shared_ptr& function); private: + std::map branchSpecificTransformations; std::map transformations; }; diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/concat_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/concat_function.hpp index c0c1686ca5521c..f70f653efe2f8c 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/concat_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/concat_function.hpp @@ -51,6 +51,12 @@ class ConcatFunction { const FakeQuantizeOnData& fqOnData1, const FakeQuantizeOnData& fqOnData2); + static std::shared_ptr getOriginalWithIntermediateAvgPool( + const ngraph::element::Type precision, + const ngraph::Shape& inputShape, + const FakeQuantizeOnData& fqOnData1, + const FakeQuantizeOnData& fqOnData2); + static std::shared_ptr getOriginalWithSplitedIntermediate( const ngraph::element::Type precision, const ngraph::Shape& inputShape, @@ -134,6 +140,7 @@ class ConcatFunction { const std::string& neighborType, const std::string& additionalLayer); + // TODO: refactor: dequantizationBefore2 <=> dequantizationOperations2 static std::shared_ptr getReferenceWithIntermediate( const ngraph::element::Type precision, const ngraph::Shape& inputShape, @@ -142,6 +149,18 @@ class ConcatFunction { const FakeQuantizeOnData& fqOnData2, const ngraph::element::Type precisionBeforeOp, const DequantizationOperations& dequantizationBefore1, + const DequantizationOperations& dequantizationOperations2, + const ngraph::element::Type precisionAfterOperation, + const DequantizationOperations& dequantizationOperations1, + const DequantizationOperations& dequantizationBefore2); + + static std::shared_ptr getReferenceWithIntermediateAvgPool( + const ngraph::element::Type precision, + const ngraph::Shape& inputShape, + const FakeQuantizeOnData& fqOnData1, + const FakeQuantizeOnData& fqOnData2, + const ngraph::element::Type precisionBeforeOp, + const DequantizationOperations& dequantizationBefore1, const DequantizationOperations& dequantizationBefore2, const ngraph::element::Type precisionAfterOperation, const DequantizationOperations& dequantizationOperations1, diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/concat_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/concat_function.cpp index 15108abb73e3c8..37387977eb7308 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/concat_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/concat_function.cpp @@ -272,6 +272,58 @@ std::shared_ptr ConcatFunction::getOriginalWithIntermediate( return function; } +std::shared_ptr ConcatFunction::getOriginalWithIntermediateAvgPool( + const ngraph::element::Type precision, + const ngraph::Shape& inputShape, + const FakeQuantizeOnData& fqOnData1, + const FakeQuantizeOnData& fqOnData2) { + const std::vector inputShape1 = { inputShape[0], inputShape[1], inputShape[2] - 2, inputShape[3] - 2 }; + + const auto input1 = std::make_shared(precision, ngraph::Shape(inputShape1)); + input1->set_friendly_name("input1"); + const auto fakeQuantize1 = makeFakeQuantize(input1, precision, fqOnData1); + fakeQuantize1->set_friendly_name("fakeQuantize1"); + + const std::vector inputShape2 = { inputShape[0], inputShape[1], inputShape[2], inputShape[3] }; + const auto input2 = std::make_shared(precision, ngraph::Shape(inputShape2)); + input2->set_friendly_name("input2"); + + const auto fakeQuantize2 = makeFakeQuantize(input2, precision, fqOnData2); + fakeQuantize2->set_friendly_name("fakeQuantize2"); + + std::shared_ptr intermediateOp = makeMaxPool(fakeQuantize2->output(0), { 3, 3 }); + intermediateOp->set_friendly_name("intermediate"); + + const std::shared_ptr concat = std::make_shared( + ngraph::OutputVector{ fakeQuantize1->output(0), intermediateOp->output(0) }, 1); + concat->set_friendly_name("concat"); + + auto& rtInfo = concat->get_rt_info(); + rtInfo["Variant::std::string"] = std::make_shared>("concat"); + + std::shared_ptr parent2 = std::make_shared( + intermediateOp, + Strides{ 1, 1 }, + Shape{ 1, 1 }, + Shape{ 0, 0 }, + Shape{ 2, 2 }, + true, + op::RoundingType::FLOOR); + parent2->set_friendly_name("avgPool"); + + ngraph::ResultVector results { + std::make_shared(concat), + std::make_shared(parent2) + }; + + std::shared_ptr function = std::make_shared( + results, + ngraph::ParameterVector{ input1, input2 }, + "ConcatWithIntermediateTransformation"); + + return function; +} + std::shared_ptr ConcatFunction::getOriginalWithSplitedIntermediate( const ngraph::element::Type precision, const ngraph::Shape& inputShape, @@ -1056,6 +1108,77 @@ std::shared_ptr ConcatFunction::getReferenceWithIntermediate( return function; } +std::shared_ptr ConcatFunction::getReferenceWithIntermediateAvgPool( + const ngraph::element::Type precision, + const ngraph::Shape& inputShape, + const FakeQuantizeOnData& fqOnData1, + const FakeQuantizeOnData& fqOnData2, + const ngraph::element::Type precisionBeforeOp, + const DequantizationOperations& dequantizationBefore1, + const DequantizationOperations& dequantizationBefore2, + const ngraph::element::Type precisionAfterOperation, + const DequantizationOperations& dequantizationAfter1, + const DequantizationOperations& dequantizationAfter2) { + const std::vector inputShape1 = { inputShape[0], inputShape[1], inputShape[2] - 2, inputShape[3] - 2}; + const auto input1 = std::make_shared(precision, ngraph::Shape(inputShape1)); + input1->set_friendly_name("input1"); + + const auto fakeQuantize1 = makeFakeQuantizeTypeRelaxed(input1, precision, fqOnData1); + low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(fakeQuantize1, precisionBeforeOp); + fakeQuantize1->set_friendly_name("fakeQuantize1"); + const auto deqBefore1 = makeDequantization(fakeQuantize1, dequantizationBefore1); + + const std::vector inputShape2 = { inputShape[0], inputShape[1], inputShape[2], inputShape[3] }; + const auto input2 = std::make_shared(precision, ngraph::Shape(inputShape2)); + input2->set_friendly_name("input2"); + + const auto fakeQuantize2 = makeFakeQuantizeTypeRelaxed(input2, precision, fqOnData2); + low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(fakeQuantize2, precisionBeforeOp); + fakeQuantize2->set_friendly_name("fakeQuantize2"); + const auto deqBefore2 = makeDequantization(fakeQuantize2, dequantizationBefore2); + + std::shared_ptr intermediateOp = makeMaxPool(deqBefore2, { 3, 3 }); + intermediateOp->set_friendly_name("intermediate"); + + const std::shared_ptr concat = std::make_shared( + ngraph::OutputVector { deqBefore1, intermediateOp }, + 1); + concat->set_friendly_name("concat"); + low_precision::NetworkHelper::setOutDataPrecision(concat, precisionAfterOperation); + + auto& rtInfo = concat->get_rt_info(); + rtInfo["Variant::std::string"] = std::make_shared>("concat"); + + const std::shared_ptr parent1 = makeDequantization(concat, dequantizationAfter1); + parent1->set_friendly_name("concat"); + + std::shared_ptr parent2 = std::make_shared>( + std::vector{ element::f32, element::f32 }, + std::vector{ element::f32 }, + ngraph::op::TemporaryReplaceOutputType(intermediateOp, element::f32).get(), + Strides{ 1, 1 }, + Shape{ 1, 1 }, + Shape{ 0, 0 }, + Shape{ 2, 2 }, + true, + op::RoundingType::FLOOR); + parent2->set_friendly_name("avgPool"); + + parent2 = makeDequantization(parent2, dequantizationAfter2); + + ngraph::ResultVector results { + std::make_shared(parent1), + std::make_shared(parent2) + }; + + std::shared_ptr function = std::make_shared( + results, + ngraph::ParameterVector{ input1, input2 }, + "ConcatWithIntermediateTransformation"); + + return function; +} + std::shared_ptr ConcatFunction::getReferenceWithSplitedIntermediate( const ngraph::element::Type precision, const ngraph::Shape& inputShape, From de2a163363eb885dbfe7367d4c6349204d1641de Mon Sep 17 00:00:00 2001 From: Svetlana Dolinina Date: Tue, 8 Jun 2021 16:09:04 +0300 Subject: [PATCH 032/178] Error during Caffe model conversion with Python3.8 (#6056) * added one more possible reason for Caffe error during caffemodel parser in code + add error description to FAQ Also added MxNet error to FAQ based on Kate Generalova wording * review fixes * wording polishing * wording polishing * review fixes * review fixes * Update docs/MO_DG/prepare_model/Model_Optimizer_FAQ.md Co-authored-by: Tatiana Savina * Update docs/MO_DG/prepare_model/Model_Optimizer_FAQ.md Co-authored-by: Tatiana Savina * Update docs/MO_DG/prepare_model/Model_Optimizer_FAQ.md Co-authored-by: Tatiana Savina * Update docs/MO_DG/prepare_model/Model_Optimizer_FAQ.md Co-authored-by: Tatiana Savina * review fixes Co-authored-by: Tatiana Savina --- docs/MO_DG/prepare_model/Model_Optimizer_FAQ.md | 14 +++++++++++++- model-optimizer/mo/front/caffe/loader.py | 8 +++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/docs/MO_DG/prepare_model/Model_Optimizer_FAQ.md b/docs/MO_DG/prepare_model/Model_Optimizer_FAQ.md index f9aef04a0a9561..bb599cf93b5632 100644 --- a/docs/MO_DG/prepare_model/Model_Optimizer_FAQ.md +++ b/docs/MO_DG/prepare_model/Model_Optimizer_FAQ.md @@ -627,4 +627,16 @@ It means that you trying to convert the topology which contains '_contrib_box_nm }); -\endhtmlonly \ No newline at end of file +\endhtmlonly + +#### 103. What does the message "ModelOptimizer is not able to parse *.caffemodel" mean? + +If a '*.caffemodel' file exists and it is correct, the error possibly occured due to the use of Python protobuf implementation. In some cases, it shows error message during model parsing, for example: "'utf-8' codec can't decode byte 0xe0 in position 4: invalid continuation byte in field: mo_caffe.SpatialTransformerParameter.transform_type". You can either use Python 3.6/3.7 or build 'cpp' implementation of protobuf yourself for your version of Python. For the complete instructions about building `protobuf` from sources, see the appropriate section in [Converting a Model to Intermediate Representation](Config_Model_Optimizer.md). + +#### 104. What does the message "SyntaxError: 'yield' inside list comprehension" during MxNet\* model conversion mean? + +The issue "SyntaxError: 'yield' inside list comprehension" might occur during converting MXNet\* models (mobilefacedet-v1-mxnet, brain-tumor-segmentation-0001) on Windows* platform with Python* 3.8 environment. This issue is caused by API changes for `yield expression` in Python 3.8. +The following workarounds are suggested to resolve this issue: +1. Use Python 3.6/3.7 to convert MXNet\* models on Windows +2. Update MXNet: pip install mxnet=1.7.0.post2 +Note that you might have conflicts between previously installed PyPI dependencies. \ No newline at end of file diff --git a/model-optimizer/mo/front/caffe/loader.py b/model-optimizer/mo/front/caffe/loader.py index 2ffca364fb6213..14497c6108d9f7 100644 --- a/model-optimizer/mo/front/caffe/loader.py +++ b/model-optimizer/mo/front/caffe/loader.py @@ -130,10 +130,16 @@ def load_caffe_proto_model(caffe_pb2, proto_path: str, model_path: [str, None] = map = mmap.mmap(infile.fileno(), 0, access=mmap.ACCESS_READ) model.MergeFromString(map) except Exception as e: + third_point = '' + if api_implementation._implementation_type == 'python': + third_point = ' 3. Python protobuf implementation was used. Some models can\'t be converted ' + \ + ' in this configuration. Please, use Python version with existing cpp implementation of ' + \ + 'protobuf library or build it by yourself\n' + refer_to_faq_msg(103) log.error('Exception message: {}\n\n'.format(e) + ' Possible reasons:\n' + ' 1. {} does not exist\n'.format(model_path) + - ' 2. {} does not have a valid structure\n'.format(model_path), extra={'framework_error': True}) + ' 2. {} does not have a valid structure\n'.format(model_path) + third_point, + extra={'framework_error': True}) raise FrameworkError('Model Optimizer is not able to parse {}'.format(model_path)) from e return proto, model From a36d6a0f0678fd0c0d637df9ea3f1b34682643cc Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Tue, 8 Jun 2021 19:33:51 +0300 Subject: [PATCH 033/178] Used setMeanImageForChannel (#6076) --- .../src/readers/ir_reader/ie_ir_parser.cpp | 11 +++++------ .../plugin/shared/include/behavior/set_preprocess.hpp | 11 ++++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/inference-engine/src/readers/ir_reader/ie_ir_parser.cpp b/inference-engine/src/readers/ir_reader/ie_ir_parser.cpp index d26132abf2ea22..892c2e6bae4088 100644 --- a/inference-engine/src/readers/ir_reader/ie_ir_parser.cpp +++ b/inference-engine/src/readers/ir_reader/ie_ir_parser.cpp @@ -1011,8 +1011,6 @@ void V10Parser::parsePreProcess( if (!meanSegmentPrecision || meanSegmentPrecision == Precision::MIXED) IE_THROW() << "mean blob defined without specifying precision."; - InferenceEngine::PreProcessChannel::Ptr preProcessChannel; - int lastChanNo = -1; std::unordered_set idsForMeanImage; @@ -1022,7 +1020,6 @@ void V10Parser::parsePreProcess( IE_THROW() << "Pre-process channel id invalid: " << chanNo; } lastChanNo = chanNo; - preProcessChannel = pp[chanNo]; auto meanNode = chan.child("mean"); if (!meanNode.empty()) { @@ -1038,13 +1035,15 @@ void V10Parser::parsePreProcess( << " extpecting " << width << " x " << height << " x " << meanSegmentPrecision.size(); } - preProcessChannel->meanData = make_blob_with_precision( + auto meanData = make_blob_with_precision( TensorDesc(meanSegmentPrecision, {height, width}, Layout::HW)); - preProcessChannel->meanData->allocate(); - auto lockedMem = preProcessChannel->meanData->buffer(); + meanData->allocate(); + auto lockedMem = meanData->buffer(); char* data = lockedMem.as(); uint8_t* src_data = weights->cbuffer().as() + offset; memcpy(data, src_data, size); + + pp.setMeanImageForChannel(meanData, chanNo); } } } diff --git a/inference-engine/tests/functional/plugin/shared/include/behavior/set_preprocess.hpp b/inference-engine/tests/functional/plugin/shared/include/behavior/set_preprocess.hpp index de442f12c215a8..ff2948668588b4 100644 --- a/inference-engine/tests/functional/plugin/shared/include/behavior/set_preprocess.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/behavior/set_preprocess.hpp @@ -157,16 +157,17 @@ TEST_P(PreprocessTest, SetMeanImagePreProcessSetBlob) { auto &preProcess = cnnNet.getInputsInfo().begin()->second->getPreProcess(); preProcess.init(3); for (size_t i = 0; i < 3; i++) { - preProcess[i]->meanData = make_blob_with_precision(InferenceEngine::TensorDesc(InferenceEngine::Precision::FP32, - {10, 10}, - InferenceEngine::Layout::HW)); - preProcess[i]->meanData->allocate(); - auto lockedMem = preProcess[i]->meanData->buffer(); + auto meanData = make_blob_with_precision( + InferenceEngine::TensorDesc(InferenceEngine::Precision::FP32, {10, 10}, + InferenceEngine::Layout::HW)); + meanData->allocate(); + auto lockedMem = meanData->buffer(); auto* data = lockedMem.as(); for (size_t j = 0; j < 100; j++) { data[j] = 0; data[j] -= i * 100 + j; } + ASSERT_NO_THROW(preProcess.setMeanImageForChannel(meanData, i)); } preProcess.setVariant(InferenceEngine::MEAN_IMAGE); // Load CNNNetwork to target plugins From d171b5c4b76151b98d7935193e61549b75f4796b Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Tue, 8 Jun 2021 19:55:36 +0300 Subject: [PATCH 034/178] Removed version.in.hpp from nGraph package (#6081) --- ngraph/core/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/ngraph/core/CMakeLists.txt b/ngraph/core/CMakeLists.txt index fa3a91c34f8200..72272046b01e9d 100644 --- a/ngraph/core/CMakeLists.txt +++ b/ngraph/core/CMakeLists.txt @@ -105,6 +105,7 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h" + PATTERN "*version.in.hpp" EXCLUDE ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/ngraph/version.hpp DESTINATION ${NGRAPH_INSTALL_INCLUDE}/ngraph From 246932a5d358364104b934b8c07f7939407f5319 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Tue, 8 Jun 2021 20:24:11 +0300 Subject: [PATCH 035/178] Py code style (#6086) * GitHub CI: Enable Python for Code style * Update formatting * Fix * Add cython * Add upgrade pip * Update to src/requirements-dev.txt * Fixed clang code style Co-authored-by: azhogov --- .github/org_control/check_pr.py | 2 +- .github/workflows/code_style.yml | 5 ++++- .../python/src/openvino/inference_engine/CMakeLists.txt | 3 ++- .../src/openvino/offline_transformations/CMakeLists.txt | 3 ++- .../ie_bridges/python/src/openvino/test_utils/CMakeLists.txt | 3 ++- ngraph/python/src/pyngraph/util.cpp | 2 +- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/org_control/check_pr.py b/.github/org_control/check_pr.py index e0b48832ead75c..85e5b4e34c00f4 100644 --- a/.github/org_control/check_pr.py +++ b/.github/org_control/check_pr.py @@ -229,7 +229,7 @@ def main(): if wrong_pulls: for pull_number, wrong_commits in wrong_pulls.items(): print( - f"\nERROR: Remove or replace wrong commits in the PR {pull_number}:\n ", + f"\nERROR: Remove or replace wrong commits in the PR {pull_number}:\n ", "\n ".join(wrong_commits), ) print( diff --git a/.github/workflows/code_style.yml b/.github/workflows/code_style.yml index b538a1793397ef..607fe2cb64ae1a 100644 --- a/.github/workflows/code_style.yml +++ b/.github/workflows/code_style.yml @@ -15,14 +15,17 @@ jobs: - name: Install dependencies run: | sudo apt --assume-yes install libusb-1.0-0-dev + python3 -m pip install --upgrade pip python3 -m pip install -r ./inference-engine/ie_bridges/python/requirements.txt + # Add for -DENABLE_PYTHON=ON, no cython + python3 -m pip install -r ./inference-engine/ie_bridges/python/src/requirements-dev.txt # Run cmake with -DENABLE_PROFILING_ITT=ON -DSELECTIVE_BUILD=COLLECT in order to enable codestyle check for ITT collector - name: CMake run: | mkdir build cd build - cmake -DENABLE_PROFILING_ITT=ON -DSELECTIVE_BUILD=COLLECT .. + cmake -DENABLE_PYTHON=ON -DENABLE_PROFILING_ITT=ON -DSELECTIVE_BUILD=COLLECT .. - name: Check code style run: cmake --build build --target clang_format_check_all diff --git a/inference-engine/ie_bridges/python/src/openvino/inference_engine/CMakeLists.txt b/inference-engine/ie_bridges/python/src/openvino/inference_engine/CMakeLists.txt index 1f623fb48336c0..17b8bf5b9b513f 100644 --- a/inference-engine/ie_bridges/python/src/openvino/inference_engine/CMakeLists.txt +++ b/inference-engine/ie_bridges/python/src/openvino/inference_engine/CMakeLists.txt @@ -77,4 +77,5 @@ install(PROGRAMS __init__.py DESTINATION ${PYTHON_BRIDGE_CPACK_PATH}/${PYTHON_VERSION}/openvino/inference_engine COMPONENT ${PYTHON_VERSION}) -add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME}) \ No newline at end of file +add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME} + EXCLUDE_PATTERNS ".*\\.cxx;.*\\.pxd;.*\\.pyx") diff --git a/inference-engine/ie_bridges/python/src/openvino/offline_transformations/CMakeLists.txt b/inference-engine/ie_bridges/python/src/openvino/offline_transformations/CMakeLists.txt index c6315336ba2929..27c9e7bf898257 100644 --- a/inference-engine/ie_bridges/python/src/openvino/offline_transformations/CMakeLists.txt +++ b/inference-engine/ie_bridges/python/src/openvino/offline_transformations/CMakeLists.txt @@ -42,7 +42,8 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") target_compile_options(${TARGET_NAME} PRIVATE "-Wno-error=register") endif() -add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME}) +add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME} + EXCLUDE_PATTERNS ".*\\.cxx;.*\\.pxd;.*\\.pyx") # perform copy add_custom_command(TARGET ${TARGET_NAME} diff --git a/inference-engine/ie_bridges/python/src/openvino/test_utils/CMakeLists.txt b/inference-engine/ie_bridges/python/src/openvino/test_utils/CMakeLists.txt index 504125d9823c1a..8367f941d9f793 100644 --- a/inference-engine/ie_bridges/python/src/openvino/test_utils/CMakeLists.txt +++ b/inference-engine/ie_bridges/python/src/openvino/test_utils/CMakeLists.txt @@ -48,4 +48,5 @@ add_custom_command(TARGET ${TARGET_NAME} COMMAND ${CMAKE_COMMAND} -E copy ${PYTHON_BRIDGE_SRC_ROOT}/src/openvino/test_utils/__init__.py ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/__init__.py ) -add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME}) \ No newline at end of file +add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME} + EXCLUDE_PATTERNS ".*\\.cxx;.*\\.pxd;.*\\.pyx") \ No newline at end of file diff --git a/ngraph/python/src/pyngraph/util.cpp b/ngraph/python/src/pyngraph/util.cpp index 5178e84fe9081b..69c0df89dcd646 100644 --- a/ngraph/python/src/pyngraph/util.cpp +++ b/ngraph/python/src/pyngraph/util.cpp @@ -4,8 +4,8 @@ #include -#include "pyngraph/util.hpp" #include "ngraph/validation_util.hpp" +#include "pyngraph/util.hpp" namespace py = pybind11; From 57850f0a876a8dfdab0a1fec575c948ca4e3bf09 Mon Sep 17 00:00:00 2001 From: Egor Duplensky Date: Tue, 8 Jun 2021 22:39:08 +0300 Subject: [PATCH 036/178] [CPU] Allow exec graph serialization to cout or xml via env variable (#5967) --- inference-engine/src/mkldnn_plugin/config.h | 8 +++- .../src/mkldnn_plugin/mkldnn_edge.cpp | 14 ++++-- .../src/mkldnn_plugin/mkldnn_edge.h | 10 ++-- .../src/mkldnn_plugin/mkldnn_graph.cpp | 31 ++++-------- .../src/mkldnn_plugin/mkldnn_graph.h | 7 ++- .../src/mkldnn_plugin/mkldnn_graph_dumper.cpp | 47 +++++++++++++++++++ .../src/mkldnn_plugin/mkldnn_graph_dumper.h | 5 +- .../src/mkldnn_plugin/utils/README.md | 19 ++++++++ .../mkldnn_plugin/utils/debug_capabilities.h | 45 ++++++++++++++++-- .../src/mkldnn_plugin/utils/node_dumper.cpp | 34 +++++++------- .../src/mkldnn_plugin/utils/node_dumper.h | 7 ++- 11 files changed, 168 insertions(+), 59 deletions(-) diff --git a/inference-engine/src/mkldnn_plugin/config.h b/inference-engine/src/mkldnn_plugin/config.h index 01eb0e23c5ee1a..54336d58495276 100644 --- a/inference-engine/src/mkldnn_plugin/config.h +++ b/inference-engine/src/mkldnn_plugin/config.h @@ -4,9 +4,11 @@ #pragma once +#include +#include "utils/debug_capabilities.h" + #include #include -#include namespace MKLDNNPlugin { @@ -35,6 +37,10 @@ struct Config { bool manualEnforceBF16 = false; #endif +#ifdef CPU_DEBUG_CAPS + DebugCaps::Config debugCaps; +#endif + void readProperties(const std::map &config); void updateProperties(); std::map _config; diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_edge.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_edge.cpp index b5ff60efed0af9..1415dc1ae95e20 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_edge.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_edge.cpp @@ -32,7 +32,7 @@ bool MKLDNNEdge::isUseExternalMemory() const { return externalMemoryPtr; } -bool MKLDNNEdge::isDropped() { +bool MKLDNNEdge::isDropped() const { bool not_in_parent = true; bool not_in_child = true; @@ -124,6 +124,10 @@ void MKLDNNEdge::reuse(MKLDNNMemoryPtr ptr) { status = Status::Allocated; } +const InferenceEngine::TensorDesc& MKLDNNEdge::getInputDescRO() const { + return inputDesc; +} + InferenceEngine::TensorDesc MKLDNNEdge::getInputDesc() { if (inputDesc.getLayout() == InferenceEngine::Layout::ANY) { inputDesc = getSpecifiedInputDesc({}); @@ -131,6 +135,10 @@ InferenceEngine::TensorDesc MKLDNNEdge::getInputDesc() { return inputDesc; } +const InferenceEngine::TensorDesc& MKLDNNEdge::getOutputDescRO() const { + return outputDesc; +} + InferenceEngine::TensorDesc MKLDNNEdge::getOutputDesc() { if (outputDesc.getLayout() == InferenceEngine::Layout::ANY) { outputDesc = getSpecifiedOutputDesc({}); @@ -145,11 +153,11 @@ InferenceEngine::TensorDesc MKLDNNEdge::getDesc() { return getInputDesc(); } -int MKLDNNEdge::getInputNum() { +int MKLDNNEdge::getInputNum() const { return parent_port; } -int MKLDNNEdge::getOutputNum() { +int MKLDNNEdge::getOutputNum() const { return child_port; } diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_edge.h b/inference-engine/src/mkldnn_plugin/mkldnn_edge.h index c9884caf56e823..63e2a16414d94f 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_edge.h +++ b/inference-engine/src/mkldnn_plugin/mkldnn_edge.h @@ -61,11 +61,11 @@ class MKLDNNEdge { MKLDNNMemoryPtr& getMemoryPtr(); bool needReorder(); - bool isDropped(); + bool isDropped() const; bool isUseExternalMemory() const; - int getInputNum(); - int getOutputNum(); + int getInputNum() const; + int getOutputNum() const; void setChildPort(const size_t port) { child_port = port; } @@ -73,10 +73,12 @@ class MKLDNNEdge { MKLDNNEdgePtr getSharedEdge() const; MKLDNNEdgePtr getSharedEdge(std::nothrow_t) const; + const InferenceEngine::TensorDesc& getInputDescRO() const; + const InferenceEngine::TensorDesc& getOutputDescRO() const; + private: std::string name(); -private: std::weak_ptr parent; std::weak_ptr child; int parent_port; diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_graph.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_graph.cpp index b92afb8a9f0d4f..efc99bddb84ae3 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_graph.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_graph.cpp @@ -78,7 +78,10 @@ void MKLDNNGraph::CreateGraph(NET &net, const MKLDNNExtensionManager::Ptr& extMg Replicate(net, extMgr); InitGraph(); + status = Ready; + + ENABLE_CPU_DEBUG_CAP(serialize(*this)); } template void MKLDNNGraph::CreateGraph(const std::shared_ptr&, @@ -344,10 +347,6 @@ void MKLDNNGraph::InitGraph() { graphNode->cleanup(); } #endif - -#if !defined(NDEBUG) && defined(PRINT_GRAPH_INFO) - printGraphInfo(); -#endif ExecuteConstantNodesOnly(); } @@ -809,7 +808,7 @@ void MKLDNNGraph::Infer(MKLDNNInferRequest* request, int batch) { mkldnn::stream stream(eng); - ENABLE_CPU_DEBUG_CAP(NodeDumper nd(infer_count)); + ENABLE_CPU_DEBUG_CAP(NodeDumper nd(config.debugCaps, infer_count)); for (int i = 0; i < graphNodes.size(); i++) { if (request != nullptr) { @@ -954,6 +953,10 @@ void MKLDNNGraph::setConfig(const Config &cfg) { config = cfg; } +const Config& MKLDNNGraph::getConfig() const { + return config; +} + void MKLDNNGraph::setProperty(const std::map& properties) { config.readProperties(properties); } @@ -1217,21 +1220,3 @@ void MKLDNNGraph::EnforceBF16() { InferenceEngine::CNNNetwork MKLDNNGraph::dump() const { return dump_graph_as_ie_ngraph_net(*this); } - -void MKLDNNGraph::printGraphInfo() const { - for (auto &graphNode : graphNodes) { - std::cout << "name: " << graphNode->getName() << " [ "; - if (graphNode->parentEdges.size() > 0) { - auto prnt_out_desc = graphNode->parentEdges[0].lock()->getOutputDesc(); - std::cout << "in: " << prnt_out_desc.getPrecision().name() - << "/l=" << prnt_out_desc.getLayout() - << "; "; - } - if (graphNode->childEdges.size() > 0) { - auto chld_in_desc = graphNode->childEdges[0].lock()->getInputDesc(); - std::cout << "out: " << chld_in_desc.getPrecision().name() - << "/l=" << chld_in_desc.getLayout(); - } - std::cout << " ]" << std::endl; - } -} diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_graph.h b/inference-engine/src/mkldnn_plugin/mkldnn_graph.h index c3fcb0d5c9c635..1b54f71e88c1cd 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_graph.h +++ b/inference-engine/src/mkldnn_plugin/mkldnn_graph.h @@ -39,6 +39,8 @@ class MKLDNNGraph { } void setConfig(const Config &cfg); + const Config& getConfig() const; + void setProperty(const std::map &properties); Config getProperty() const; @@ -59,6 +61,10 @@ class MKLDNNGraph { void Infer(MKLDNNInferRequest* request = nullptr, int batch = -1); + const std::vector& GetNodes() const { + return graphNodes; + } + std::vector& GetNodes() { return graphNodes; } @@ -219,7 +225,6 @@ class MKLDNNGraph { private: void EnforceBF16(); - void printGraphInfo() const; }; } // namespace MKLDNNPlugin diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_graph_dumper.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_graph_dumper.cpp index 14d2f6a28ae7e8..ac4bfff6b6d2f0 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_graph_dumper.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_graph_dumper.cpp @@ -5,9 +5,11 @@ #include "mkldnn_graph_dumper.h" #include #include "exec_graph_info.hpp" +#include "ie_common.h" #include "mkldnn_debug.h" #include #include "ngraph/ngraph.hpp" +#include "utils/debug_capabilities.h" #include #include @@ -18,6 +20,9 @@ using namespace InferenceEngine; namespace MKLDNNPlugin { +void serializeToCout(const MKLDNNGraph &graph); +void serializeToXML(const MKLDNNGraph &graph, const std::string& path); + namespace { std::map extract_node_metadata(const MKLDNNNodePtr &node) { @@ -207,4 +212,46 @@ InferenceEngine::CNNNetwork dump_graph_as_ie_ngraph_net(const MKLDNNGraph &graph return net; } +#ifdef CPU_DEBUG_CAPS +void serialize(const MKLDNNGraph &graph) { + const std::string& path = graph.getConfig().debugCaps.execGraphPath; + + if (path.empty()) + return; + + if (path == "cout") + serializeToCout(graph); + else if (!path.compare(path.size() - 4, 4, ".xml")) + serializeToXML(graph, path); + else + IE_THROW() << "Unknown serialize format. Should be either 'cout' or '*.xml'. Got " << path; +} + +void serializeToXML(const MKLDNNGraph &graph, const std::string& path) { + if (path.empty()) + return; + + graph.dump().serialize(path); +} + +void serializeToCout(const MKLDNNGraph &graph) { + for (const auto& node : graph.GetNodes()) { + std::cout << "name: " << node->getName() << " [ "; + if (!node->getParentEdges().empty()) { + const auto& parentEdge = *(node->getParentEdges()[0].lock()); + const auto& prnt_out_desc = parentEdge.getOutputDescRO(); + std::cout << "in: " << prnt_out_desc.getPrecision().name() + << "/l=" << prnt_out_desc.getLayout() + << "; "; + } + if (!node->getChildEdges().empty()) { + const auto& childEdge = *(node->getChildEdges()[0].lock()); + const auto& chld_in_desc = childEdge.getInputDescRO(); + std::cout << "out: " << chld_in_desc.getPrecision().name() + << "/l=" << chld_in_desc.getLayout(); + } + std::cout << " ]" << std::endl; + } +} +#endif } // namespace MKLDNNPlugin diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_graph_dumper.h b/inference-engine/src/mkldnn_plugin/mkldnn_graph_dumper.h index d954695baaa050..597568224f38f0 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_graph_dumper.h +++ b/inference-engine/src/mkldnn_plugin/mkldnn_graph_dumper.h @@ -6,11 +6,14 @@ #include "cpp/ie_cnn_network.h" #include "mkldnn_graph.h" +#include "utils/debug_capabilities.h" #include namespace MKLDNNPlugin { InferenceEngine::CNNNetwork dump_graph_as_ie_ngraph_net(const MKLDNNGraph &graph); - +#ifdef CPU_DEBUG_CAPS +void serialize(const MKLDNNGraph &graph); +#endif // CPU_DEBUG_CAPS } // namespace MKLDNNPlugin diff --git a/inference-engine/src/mkldnn_plugin/utils/README.md b/inference-engine/src/mkldnn_plugin/utils/README.md index af50c8d5015fdc..d3b98f1cb48f2f 100644 --- a/inference-engine/src/mkldnn_plugin/utils/README.md +++ b/inference-engine/src/mkldnn_plugin/utils/README.md @@ -71,3 +71,22 @@ Example: ```sh OV_CPU_BLOB_DUMP_NODE_NAME=".+" binary ... ``` + +## Graph serialization +The functionality allows to serialize execution graph using environment variable: +```sh + OV_CPU_EXEC_GRAPH_PATH= binary ... +``` + +Possible serialization options: +* cout + + Serialize to console output +* \.xml + + Serialize graph into .xml and .bin files. Can be opened using, for example, *netron* app +* \.dot + + TBD. Serialize graph into .dot file. Can be inspected using, for example, *graphviz* tools. + + diff --git a/inference-engine/src/mkldnn_plugin/utils/debug_capabilities.h b/inference-engine/src/mkldnn_plugin/utils/debug_capabilities.h index 64af835064d8c7..be6e7a830c2c63 100644 --- a/inference-engine/src/mkldnn_plugin/utils/debug_capabilities.h +++ b/inference-engine/src/mkldnn_plugin/utils/debug_capabilities.h @@ -4,7 +4,44 @@ #pragma once #ifdef CPU_DEBUG_CAPS -# define ENABLE_CPU_DEBUG_CAP(_x) _x; -#else -# define ENABLE_CPU_DEBUG_CAP(_x) -#endif + +#include +#include +#include + +#define ENABLE_CPU_DEBUG_CAP(_x) _x; + +namespace MKLDNNPlugin { +namespace DebugCaps { + +class Config { +public: + Config() { + readParam(blobDumpDir, "OV_CPU_BLOB_DUMP_DIR"); + readParam(blobDumpFormat, "OV_CPU_BLOB_DUMP_FORMAT"); + readParam(blobDumpNodeExecId, "OV_CPU_BLOB_DUMP_NODE_EXEC_ID"); + readParam(blobDumpNodeType, "OV_CPU_BLOB_DUMP_NODE_TYPE"); + readParam(blobDumpNodeName, "OV_CPU_BLOB_DUMP_NODE_NAME"); + readParam(execGraphPath, "OV_CPU_EXEC_GRAPH_PATH"); + } + + std::string blobDumpDir; + std::string blobDumpFormat; + std::string blobDumpNodeExecId; + std::string blobDumpNodeType; + std::string blobDumpNodeName; + std::string execGraphPath; + +private: + void readParam(std::string& param, const char* envVar) { + if (const char* envValue = std::getenv(envVar)) + param = envValue; + } +}; + +} // namespace DebugCaps +} // namespace MKLDNNPlugin + +#else // !CPU_DEBUG_CAPS +#define ENABLE_CPU_DEBUG_CAP(_x) +#endif // CPU_DEBUG_CAPS diff --git a/inference-engine/src/mkldnn_plugin/utils/node_dumper.cpp b/inference-engine/src/mkldnn_plugin/utils/node_dumper.cpp index f69551159dc1ea..9f3af44a66a26a 100644 --- a/inference-engine/src/mkldnn_plugin/utils/node_dumper.cpp +++ b/inference-engine/src/mkldnn_plugin/utils/node_dumper.cpp @@ -6,9 +6,10 @@ #include "node_dumper.h" #include "mkldnn_node.h" +#include "ie_common.h" #include "utils/blob_dump.h" +#include "utils/debug_capabilities.h" -#include "ie_common.h" #include #include #include @@ -18,27 +19,24 @@ using namespace InferenceEngine; namespace MKLDNNPlugin { -NodeDumper::NodeDumper(int _count): - count(_count), dumpFormat(DUMP_FORMAT::BIN) { - const char* dumpDirEnv = std::getenv("OV_CPU_BLOB_DUMP_DIR"); - if (dumpDirEnv) - dumpDirName = dumpDirEnv; +NodeDumper::NodeDumper(const DebugCaps::Config& config, const int _count) + : dumpFormat(DUMP_FORMAT::BIN) + , dumpDirName("mkldnn_dump") + , count(_count) { + if (!config.blobDumpDir.empty()) + dumpDirName = config.blobDumpDir; - const char* dumpFormatEnv = std::getenv("OV_CPU_BLOB_DUMP_FORMAT"); - if (dumpFormatEnv) - dumpFormat = parseDumpFormat(dumpFormatEnv); + if (!config.blobDumpFormat.empty()) + dumpFormat = parseDumpFormat(config.blobDumpFormat); - const char* filter = std::getenv("OV_CPU_BLOB_DUMP_NODE_EXEC_ID"); - if (filter) - dumpFilters[FILTER::BY_EXEC_ID] = filter; + if (!config.blobDumpNodeExecId.empty()) + dumpFilters[FILTER::BY_EXEC_ID] = config.blobDumpNodeExecId; - filter = std::getenv("OV_CPU_BLOB_DUMP_NODE_TYPE"); - if (filter) - dumpFilters[FILTER::BY_TYPE] = filter; + if (!config.blobDumpNodeType.empty()) + dumpFilters[FILTER::BY_TYPE] = config.blobDumpNodeType; - filter = std::getenv("OV_CPU_BLOB_DUMP_NODE_NAME"); - if (filter) - dumpFilters[FILTER::BY_NAME] = filter; + if (!config.blobDumpNodeName.empty()) + dumpFilters[FILTER::BY_NAME] = config.blobDumpNodeName; } void NodeDumper::dumpInputBlobs(const MKLDNNNodePtr& node) const { diff --git a/inference-engine/src/mkldnn_plugin/utils/node_dumper.h b/inference-engine/src/mkldnn_plugin/utils/node_dumper.h index 7dd1ac1f0c651e..0580bee4731b91 100644 --- a/inference-engine/src/mkldnn_plugin/utils/node_dumper.h +++ b/inference-engine/src/mkldnn_plugin/utils/node_dumper.h @@ -6,6 +6,7 @@ #include "mkldnn_node.h" #include "utils/blob_dump.h" +#include "utils/debug_capabilities.h" #include #include @@ -22,7 +23,7 @@ namespace MKLDNNPlugin { */ class NodeDumper { public: - NodeDumper(int _count); + NodeDumper(const DebugCaps::Config& config, const int _count); void dumpInputBlobs(const MKLDNNNodePtr &node) const; void dumpOutputBlobs(const MKLDNNNodePtr &node) const; @@ -41,11 +42,9 @@ class NodeDumper { void formatNodeName(std::string& name) const; DUMP_FORMAT dumpFormat; - + std::string dumpDirName; int count; - std::string dumpDirName = "mkldnn_dump"; - enum FILTER { BY_EXEC_ID, BY_TYPE, From f0cf1dffa76dd7c93c2b7e8d8b4b5cf2c39c0f6a Mon Sep 17 00:00:00 2001 From: Andrey Somsikov Date: Wed, 9 Jun 2021 08:21:03 +0300 Subject: [PATCH 037/178] Add ENABLE_STRICT_DEPENDENCIES for faster parallel builds (#5473) --- cmake/features.cmake | 2 ++ ngraph/test/CMakeLists.txt | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cmake/features.cmake b/cmake/features.cmake index adb1fad25238da..7518c99c86838c 100644 --- a/cmake/features.cmake +++ b/cmake/features.cmake @@ -6,6 +6,8 @@ ie_dependent_option (ENABLE_MKL_DNN "MKL-DNN plugin for inference engine" ON "X8 ie_option (ENABLE_TESTS "unit, behavior and functional tests" OFF) +ie_option (ENABLE_STRICT_DEPENDENCIES "Skip configuring \"convinient\" dependencies for efficient parallel builds" OFF) + ie_dependent_option (ENABLE_CLDNN "clDnn based plugin for inference engine" ON "X86_64;NOT APPLE;NOT MINGW;NOT WINDOWS_STORE;NOT WINDOWS_PHONE" OFF) ie_option (ENABLE_PROFILING_ITT "Build with ITT tracing. Optionally configure pre-built ittnotify library though INTEL_VTUNE_DIR variable." OFF) diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index ba3c6a9d052b80..97f85a3128f926 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -286,13 +286,21 @@ set_source_files_properties(includes.cpp PROPERTIES COMPILE_DEFINITIONS if (ENABLE_MKL_DNN) message(STATUS "NGRAPH_TESTS: IE:CPU enabled") set(ACTIVE_BACKEND_LIST ${ACTIVE_BACKEND_LIST} "IE:CPU") - list(APPEND UNIT_TESTS_DEPENDENCIES MKLDNNPlugin) + if (NOT ENABLE_STRICT_DEPENDENCIES) + # For convinience add a runtime dependency to build along with this target. + # Warning: Parallel build with -GNinja may not be efficient. + list(APPEND UNIT_TESTS_DEPENDENCIES MKLDNNPlugin) + endif() endif() if (ENABLE_CLDNN) message(STATUS "NGRAPH_TESTS: IE:GPU enabled") set(ACTIVE_BACKEND_LIST ${ACTIVE_BACKEND_LIST} "IE:GPU") - list(APPEND UNIT_TESTS_DEPENDENCIES clDNNPlugin) + if (NOT ENABLE_STRICT_DEPENDENCIES) + # For convinience add a runtime dependency to build along with this target. + # Warning: Parallel build with -GNinja may not be efficient. + list(APPEND UNIT_TESTS_DEPENDENCIES clDNNPlugin) + endif() endif() if (NGRAPH_INTERPRETER_ENABLE) From aa4a18dda1ad0dfc55412dbe776be99dc0c0c964 Mon Sep 17 00:00:00 2001 From: Vladimir Paramuzov Date: Wed, 9 Jun 2021 09:02:25 +0300 Subject: [PATCH 038/178] [IE CLDNN] Updated GPU device config (#6040) --- docs/IE_DG/API_Changes.md | 15 ++- docs/IE_DG/Extensibility_DG/GPU_Kernel.md | 16 --- docs/IE_DG/GPU_Kernels_Tuning.md | 39 ------ docs/IE_DG/Intro_to_Performance.md | 20 +-- .../supported_plugins/{CL_DNN.md => GPU.md} | 45 +++---- .../supported_plugins/Supported_Devices.md | 10 +- docs/doxygen/ie_docs.xml | 3 +- docs/model_server/README.md | 46 +++---- .../dldt_optimization_guide.md | 62 ++++----- docs/snippets/GPU_Kernel.cpp | 5 - docs/snippets/GPU_Kernels_Tuning.cpp | 14 -- docs/snippets/GPU_RemoteBlob_API2.cpp | 4 +- .../include/cldnn/cldnn_config.hpp | 80 +++--------- inference-engine/include/gpu/gpu_config.hpp | 120 ++++++++++++++++++ .../samples/benchmark_app/main.cpp | 4 +- .../samples/hello_query_device/README.md | 6 +- .../src/cldnn_engine/cldnn_config.cpp | 29 +++-- .../src/cldnn_engine/cldnn_engine.cpp | 2 +- .../cldnn_engine/cldnn_executable_network.cpp | 1 - .../src/cldnn_engine/cldnn_graph.cpp | 1 - .../cldnn_remote_blob_tests.cpp | 4 +- .../behavior/config.cpp | 35 ++++- .../behavior/core_integration.cpp | 2 +- .../behavior/infer_request_input.cpp | 2 +- .../behavior/infer_request_output.cpp | 2 +- .../behavior/test_plugin.cpp | 2 +- .../multi/gpu_remote_blob_tests.cpp | 2 +- .../single_layer_tests/tensor_iterator.cpp | 6 +- tools/benchmark/main.py | 2 +- 29 files changed, 301 insertions(+), 278 deletions(-) delete mode 100644 docs/IE_DG/GPU_Kernels_Tuning.md rename docs/IE_DG/supported_plugins/{CL_DNN.md => GPU.md} (62%) delete mode 100644 docs/snippets/GPU_Kernels_Tuning.cpp create mode 100644 inference-engine/include/gpu/gpu_config.hpp diff --git a/docs/IE_DG/API_Changes.md b/docs/IE_DG/API_Changes.md index a234471c13e550..2534a4a6c3856a 100644 --- a/docs/IE_DG/API_Changes.md +++ b/docs/IE_DG/API_Changes.md @@ -14,6 +14,15 @@ The sections below contain detailed list of changes made to the Inference Engine * InferenceEngine::Parameter(std::shared_ptr& var) * std::shared_ptr InferenceEngine::Parameter::asVariant() const * InferenceEngine::Parameter::operator std::shared_ptr() const + * KEY_CLDNN_NV12_TWO_INPUTS GPU plugin option. Use KEY_GPU_NV12_TWO_INPUTS instead + * KEY_CLDNN_PLUGIN_PRIORITY GPU plugin option. Use KEY_GPU_PLUGIN_PRIORITY instead + * KEY_CLDNN_PLUGIN_THROTTLE GPU plugin option. Use KEY_GPU_PLUGIN_THROTTLE instead + * KEY_CLDNN_MEM_POOL GPU plugin option + * KEY_CLDNN_GRAPH_DUMPS_DIR GPU plugin option + * KEY_CLDNN_SOURCES_DUMPS_DIR GPU plugin option + * KEY_DUMP_KERNELS GPU plugin option + * KEY_TUNING_MODE GPU plugin option + * KEY_TUNING_FILE GPU plugin option ## 2021.3 @@ -528,7 +537,7 @@ The sections below contain detailed list of changes made to the Inference Engine * DLIA_CONFIG_KEY(ENABLE_STREAMING) config key ### Removed API - + * InferenceEngine::EltwiseLayer::Select from InferenceEngine::EltwiseLayer::eOperation enumeration ## 2019 R2 @@ -577,7 +586,7 @@ The sections below contain detailed list of changes made to the Inference Engine * DLIA_CONFIG_KEY(IO_TRANSFORMATIONS_NATIVE) config key * DLIA_CONFIG_KEY(DUMP_SUPPORTED_LAYERS_INFORMATION) config key * GNA_CONFIG_VALUE(SW_FP32) config value for GNA_CONFIG_KEY(DEVICE_MODE) key - * MULTI_CONFIG_KEY(DEVICE_PRIORITIES) config key for `MULTI` device + * MULTI_CONFIG_KEY(DEVICE_PRIORITIES) config key for `MULTI` device * InferenceEngine::CNNNetReader::ReadNetwork(const std::wstring &filepath) new method * InferenceEngine::CNNNetReader::ReadWeights(const std::wstring &filepath) new method * InferenceEngine::ExecutableNetwork::ExecutableNetwork(IExecutableNetwork::Ptr actual, InferenceEnginePluginPtr plg) constructor with additional `plg` parameter @@ -593,7 +602,7 @@ The sections below contain detailed list of changes made to the Inference Engine * InferenceEngine::EltwiseLayer::Logical_NOT, InferenceEngine::EltwiseLayer::Mean, InferenceEngine::EltwiseLayer::Select extensions to InferenceEngine::EltwiseLayer::eOperation enumeration * InferenceEngine::OneHotLayer new class * InferenceEngine::SelectLayer new class - * InferenceEngine::BroadcastLayer new class + * InferenceEngine::BroadcastLayer new class * InferenceEngine::MathLayer new class * InferenceEngine::ReduceLayer new class * InferenceEngine::TopKLayer new class diff --git a/docs/IE_DG/Extensibility_DG/GPU_Kernel.md b/docs/IE_DG/Extensibility_DG/GPU_Kernel.md index 09ace6f0a2942f..d9fd809f8e4227 100644 --- a/docs/IE_DG/Extensibility_DG/GPU_Kernel.md +++ b/docs/IE_DG/Extensibility_DG/GPU_Kernel.md @@ -219,22 +219,6 @@ __kernel void example_relu_kernel( ## Debugging Tips -* **Dumping the Resulting Kernels**. -It is recommended to get a dump of the kernel with all of -the values set by the Inference Engine, such as tensor sizes, -floating-point, and integer kernel parameters. To get the dump, add the -following line to your code that configures the GPU plugin to output the -custom kernels: - -@snippet snippets/GPU_Kernel.cpp part1 - -When the Inference Engine compiles the kernels for the specific network, -it also outputs the resulting code for the custom kernels. In the -directory of your executable, find files like -`clDNN_program0.cl`, `clDNN_program1.cl`. There are as many files as -distinct sets of parameters for your custom kernel: different input -tensor sizes and kernel parameters. - * **Using `printf` in the OpenCL™ Kernels**. To debug the specific values, you can use `printf` in your kernels. However, be careful: for instance, do not output excessively diff --git a/docs/IE_DG/GPU_Kernels_Tuning.md b/docs/IE_DG/GPU_Kernels_Tuning.md deleted file mode 100644 index 5bb6a8334b2372..00000000000000 --- a/docs/IE_DG/GPU_Kernels_Tuning.md +++ /dev/null @@ -1,39 +0,0 @@ -Using GPU Kernels Tuning {#openvino_docs_IE_DG_GPU_Kernels_Tuning} -====================== - -GPU Kernels Tuning allows you to tune models, so the heavy computational layers are configured to fit better into -hardware, which the tuning was done on. It is required to achieve best performance on GPU. -> **NOTE** Currently only convolution and fully connected layers undergo tuning process. It means that the performance boost depends on the amount of that layers in the model. - -OpenVINO™ releases include the `/inference_engine/bin/intel64/Release/cache.json` file with pretuned data for current state of the art models. It is highly recommended to do the -tuning for new kind of models, hardwares or drivers. - -## Tuned data - -GPU tuning data is saved in JSON format. The file is composed of 2 types of attributes and 1 type of value: -* Execution units number (attribute): splits the content into different EU sections -* Hash (attribute): hashed tuned kernel data -* Key (value): Array with kernel name and kernel's mode index - -## Usage - ---- - -You can activate Kernels Tuning process by setting `KEY_TUNING_MODE` flag to `TUNING_CREATE` and `KEY_TUNING_FILE` to `<"filename">` in a configuration map that is -passed to the plugin while loading a network. -This configuration modifies the behavior of the `ExecutableNetwork` object. Instead of standard network compilation, it will run the tuning process. -Please keep in mind that the tuning can be very time consuming. The bigger the network, the longer it will take. -File with tuned data is the result of this step. - -> **NOTE** If a filename passed to `KEY_TUNING_FILE` points to existing tuned data and you are tuning a new model, then this file will be extended by new data. This allows you to extend existing `cache.json` provided in the OpenVINO™ release package. - -The example below shows how to set and use the key files: - -@snippet snippets/GPU_Kernels_Tuning.cpp part0 - ---- - -You can activate the inference with tuned data by setting `KEY_TUNING_MODE` flag to `TUNING_USE_EXISTING` and -`KEY_TUNING_FILE` flag to `<"filename">`. - -GPU backend will process the content of the file during network compilation to configure the OpenCL kernels for the best performance. diff --git a/docs/IE_DG/Intro_to_Performance.md b/docs/IE_DG/Intro_to_Performance.md index 78d5c59c417d0f..94d0173dbbe2b4 100644 --- a/docs/IE_DG/Intro_to_Performance.md +++ b/docs/IE_DG/Intro_to_Performance.md @@ -22,7 +22,7 @@ $ benchmark_app -m -enforcebf16=false Notice that for quantized (e.g. INT8) models the bfloat16 calculations (of the layers that remain in FP32) is disabled by default. Refer to the [CPU Plugin documentation](supported_plugins/CPU.md) for more details. -Similarly, the GPU device has a dedicated config key to enable FP16 execution of the layers that remain in FP32 in the quantized models (as the quantization is typically performed on the FP32 models), refer to the ENABLE_FP16_FOR_QUANTIZED_MODELS key in the [GPU Plugin documentation](supported_plugins/CL_DNN.md) +Similarly, the GPU device has a dedicated config key to enable FP16 execution of the layers that remain in FP32 in the quantized models (as the quantization is typically performed on the FP32 models), refer to the ENABLE_FP16_FOR_QUANTIZED_MODELS key in the [GPU Plugin documentation](supported_plugins/GPU.md) ## Latency vs. Throughput One way to increase computational efficiency is batching, which combines many (potentially tens) of @@ -72,30 +72,20 @@ Instead, it is possible to keep a separate infer request per camera or another s ## Benchmark App [Benchmark App](../../inference-engine/samples/benchmark_app/README.md) sample is the best performance reference. -It has a lot of device-specific knobs, but the primary usage is as simple as: +It has a lot of device-specific knobs, but the primary usage is as simple as: ```bash $ ./benchmark_app –d GPU –m -i ``` -to measure the performance of the model on the GPU. +to measure the performance of the model on the GPU. Or ```bash $ ./benchmark_app –d CPU –m -i ``` to execute on the CPU instead. -For example, for the CPU throughput mode from the previous section, you can play with number of streams (`-nstreams` command-line param). -Try different values of the `-nstreams` argument from `1` to a number of CPU cores and find one that provides the best performance. For example, on a 8-core CPU, compare the `-nstreams 1` (which is a latency-oriented scenario) to the `2`, `4` and `8` streams. Notice that `benchmark_app` automatically queries/creates/runs number of requests required to saturate the given number of streams. +For example, for the CPU throughput mode from the previous section, you can play with number of streams (`-nstreams` command-line param). +Try different values of the `-nstreams` argument from `1` to a number of CPU cores and find one that provides the best performance. For example, on a 8-core CPU, compare the `-nstreams 1` (which is a latency-oriented scenario) to the `2`, `4` and `8` streams. Notice that `benchmark_app` automatically queries/creates/runs number of requests required to saturate the given number of streams. Finally, notice that when you don't specify number of streams with `-nstreams`, "AUTO" value for the streams is used, e.g. for the CPU this is [CPU_THROUGHPUT_AUTO](supported_plugins/CPU.md). You can spot the actual value behind "AUTO" for your machine in the application output. Notice that the "AUTO" number is not necessarily most optimal, so it is generally recommended to play either with the benchmark_app's "-nstreams" as described above, or via [new Workbench tool](@ref workbench_docs_Workbench_DG_Introduction).This allows you to simplify the app-logic, as you don't need to combine multiple inputs into a batch to achieve good CPU performance. Instead, it is possible to keep a separate infer request per camera or another source of input and process the requests in parallel using Async API. - -## Kernels Tuning for GPU - -GPU backend comes with a feature, that allows models tuning, so the workload is configured to fit better into hardware. - -Tuning is time consuming process, which internally execute every layer several (or even hundreds) times to find most performant configuration. - -This configuration is saved into json-formatted file, whose name can be passed as plugin param to network. GPU backend will process this data to configure kernels for the best performance. - -For more details about Kernels Tuning and How-To please refer to [GPU Kernels Tuning](GPU_Kernels_Tuning.md). diff --git a/docs/IE_DG/supported_plugins/CL_DNN.md b/docs/IE_DG/supported_plugins/GPU.md similarity index 62% rename from docs/IE_DG/supported_plugins/CL_DNN.md rename to docs/IE_DG/supported_plugins/GPU.md index 0216ae71d0dd36..cc12be98a121e1 100644 --- a/docs/IE_DG/supported_plugins/CL_DNN.md +++ b/docs/IE_DG/supported_plugins/GPU.md @@ -1,4 +1,4 @@ -GPU Plugin {#openvino_docs_IE_DG_supported_plugins_CL_DNN} +GPU Plugin {#openvino_docs_IE_DG_supported_plugins_GPU} ======= The GPU plugin uses the Intel® Compute Library for Deep Neural Networks (clDNN) to infer deep neural networks. @@ -89,13 +89,10 @@ Some layers are executed during the load time, not during the inference. One of The following layers are not accelerated on the GPU and executed on the host CPU instead: * Proposal -* SimplerNMS +* NonMaxSuppression * PriorBox * DetectionOutput -## Known Layers Limitations -* ROIPooling is supported for 'max' value of 'method' attribute. - ## Supported Configuration Parameters The plugin supports the configuration parameters listed below. @@ -107,31 +104,21 @@ When specifying key values as raw strings (that is, when using Python API), omit | `KEY_CACHE_DIR` | `""` | `""` | Specifies a directory where compiled OCL binaries can be cached. First model loading generates the cache, and all subsequent LoadNetwork calls use precompiled kernels which significantly improves load time. If empty - caching is disabled | | `KEY_PERF_COUNT` | `YES` / `NO` | `NO` | Collect performance counters during inference | | `KEY_CONFIG_FILE` | `" [ ...]"` | `""` | Load custom layer configuration files | -| `KEY_DUMP_KERNELS` | `YES` / `NO` | `NO` | Dump the final kernels used for custom layers | -| `KEY_TUNING_MODE` | `TUNING_DISABLED`
`TUNING_CREATE`
`TUNING_USE_EXISTING` | `TUNING_DISABLED` | Disable inference kernel tuning
Create tuning file (expect much longer runtime)
Use an existing tuning file | -| `KEY_TUNING_FILE` | `""` | `""` | Tuning file to create / use | -| `KEY_CLDNN_PLUGIN_PRIORITY` | `<0-3>` | `0` | OpenCL queue priority (before usage, make sure your OpenCL driver supports appropriate extension)
Higher value means higher priority for clDNN OpenCL queue. 0 disables the setting. | -| `KEY_CLDNN_PLUGIN_THROTTLE` | `<0-3>` | `0` | OpenCL queue throttling (before usage, make sure your OpenCL driver supports appropriate extension)
Lower value means lower driver thread priority and longer sleep time for it. 0 disables the setting. | -| `KEY_CLDNN_GRAPH_DUMPS_DIR` | `""` | `""` | clDNN graph optimizer stages dump output directory (in GraphViz format) | -| `KEY_CLDNN_SOURCES_DUMPS_DIR` | `""` | `""` | Final optimized clDNN OpenCL sources dump output directory | -| `KEY_GPU_THROUGHPUT_STREAMS` | `KEY_GPU_THROUGHPUT_AUTO`, or positive integer| 1 | Specifies a number of GPU "execution" streams for the throughput mode (upper bound for a number of inference requests that can be executed simultaneously).
This option is can be used to decrease GPU stall time by providing more effective load from several streams. Increasing the number of streams usually is more effective for smaller topologies or smaller input sizes. Note that your application should provide enough parallel slack (e.g. running many inference requests) to leverage full GPU bandwidth. Additional streams consume several times more GPU memory, so make sure the system has enough memory available to suit parallel stream execution. Multiple streams might also put additional load on CPU. If CPU load increases, it can be regulated by setting an appropriate `KEY_CLDNN_PLUGIN_THROTTLE` option value (see above). If your target system has relatively weak CPU, keep throttling low.
The default value is 1, which implies latency-oriented behavior.
`KEY_GPU_THROUGHPUT_AUTO` creates bare minimum of streams to improve the performance; this is the most portable option if you are not sure how many resources your target machine has (and what would be the optimal number of streams).
A positive integer value creates the requested number of streams. | +| `KEY_GPU_PLUGIN_PRIORITY` | `<0-3>` | `0` | OpenCL queue priority (before usage, make sure your OpenCL driver supports appropriate extension)
Higher value means higher priority for OpenCL queue. 0 disables the setting. | +| `KEY_GPU_PLUGIN_THROTTLE` | `<0-3>` | `0` | OpenCL queue throttling (before usage, make sure your OpenCL driver supports appropriate extension)
Lower value means lower driver thread priority and longer sleep time for it. 0 disables the setting. | +| `KEY_CLDNN_ENABLE_FP16_FOR_QUANTIZED_MODELS` | `YES` / `NO` | `YES` | Allows using FP16+INT8 mixed precision mode, so non-quantized parts of a model will be executed in FP16 precision for FP16 IR. Does not affect quantized FP32 IRs | +| `KEY_GPU_NV12_TWO_INPUTS` | `YES` / `NO` | `NO` | Controls preprocessing logic for nv12 input. If it's set to YES, then device graph will expect that user will set biplanar nv12 blob as input wich will be directly passed to device execution graph. Otherwise, preprocessing via GAPI is used to convert NV12->BGR, thus GPU graph have to expect single input | +| `KEY_GPU_THROUGHPUT_STREAMS` | `KEY_GPU_THROUGHPUT_AUTO`, or positive integer| 1 | Specifies a number of GPU "execution" streams for the throughput mode (upper bound for a number of inference requests that can be executed simultaneously).
This option is can be used to decrease GPU stall time by providing more effective load from several streams. Increasing the number of streams usually is more effective for smaller topologies or smaller input sizes. Note that your application should provide enough parallel slack (e.g. running many inference requests) to leverage full GPU bandwidth. Additional streams consume several times more GPU memory, so make sure the system has enough memory available to suit parallel stream execution. Multiple streams might also put additional load on CPU. If CPU load increases, it can be regulated by setting an appropriate `KEY_GPU_PLUGIN_THROTTLE` option value (see above). If your target system has relatively weak CPU, keep throttling low.
The default value is 1, which implies latency-oriented behavior.
`KEY_GPU_THROUGHPUT_AUTO` creates bare minimum of streams to improve the performance; this is the most portable option if you are not sure how many resources your target machine has (and what would be the optimal number of streams).
A positive integer value creates the requested number of streams. | | `KEY_EXCLUSIVE_ASYNC_REQUESTS` | `YES` / `NO` | `NO` | Forces async requests (also from different executable networks) to execute serially.| -| `KEY_CLDNN_MAX_NUM_THREADS` | `integer value` | `maximum # of HW threads available in host environment` | Specifies the number of CPU threads that can be used for clDNN engine, e.g, JIT compilation of clDNN kernels or clDNN cpu kernel processing. The default value is set as the number of maximum available threads in host environment to minimize the time for LoadNetwork, where the clDNN kernel build time occupies a large portion. Note that if the specified value is larger than the maximum available # of threads or less than zero, it is set as maximum available # of threads. It can be specified with a smaller number than the available HW threads according to the usage scenario, e.g., when the user wants to assign more CPU threads while clDNN plugin is running. Note that setting this value with lower number will affect not only the network loading time but also the cpu layers of clDNN networks that are optimized with multi-threading. | -| `KEY_CLDNN_ENABLE_LOOP_UNROLLING` | `YES` / `NO` | `YES` | Enables recurrent layers such as TensorIterator or Loop with fixed iteration count to be unrolled. It is turned on by default. Turning this key on will achieve better inference performance for loops with not too many iteration counts (less than 16, as a rule of thumb). Turning this key off will achieve better performance for both graph loading time and inference time with many iteration counts (greater than 16). Note that turning this key on will increase the graph loading time in proportion to the iteration counts. Thus, this key should be turned off if graph loading time is considered to be most important target to optimize. | - -## Note on Debug Capabilities of the GPU Plugin - -Inference Engine GPU plugin provides possibility to dump the user custom OpenCL™ kernels to a file to allow you to properly debug compilation issues in your custom kernels. - -The application can use the SetConfig() function with the key PluginConfigParams::KEY_DUMP_KERNELS and value: PluginConfigParams::YES. Then during network loading, all custom layers will print their OpenCL kernels with the JIT instrumentation added by the plugin. -The kernels will be stored in the working directory under files named the following way: clDNN_program0.cl, clDNN_program1.cl. - -This option is disabled by default. Additionally, the application can call the SetConfig() function with the key PluginConfigParams::KEY_DUMP_KERNELS and value: PluginConfigParams::NO before network loading. - -How to verify that this option is disabled: -1. Delete all clDNN_program*.cl files from the current directory -2. Run your application to load a network -3. Examine the working directory for the presence of any kernel file (for example, clDNN_program0.cl) +| `KEY_GPU_MAX_NUM_THREADS` | `integer value` | `maximum # of HW threads available in host environment` | Specifies the number of CPU threads that can be used for GPU engine, e.g, JIT compilation of GPU kernels or cpu kernel processing within GPU plugin. The default value is set as the number of maximum available threads in host environment to minimize the time for LoadNetwork, where the GPU kernel build time occupies a large portion. Note that if the specified value is larger than the maximum available # of threads or less than zero, it is set as maximum available # of threads. It can be specified with a smaller number than the available HW threads according to the usage scenario, e.g., when the user wants to assign more CPU threads while GPU plugin is running. Note that setting this value with lower number will affect not only the network loading time but also the cpu layers of GPU networks that are optimized with multi-threading. | +| `KEY_GPU_ENABLE_LOOP_UNROLLING` | `YES` / `NO` | `YES` | Enables recurrent layers such as TensorIterator or Loop with fixed iteration count to be unrolled. It is turned on by default. Turning this key on will achieve better inference performance for loops with not too many iteration counts (less than 16, as a rule of thumb). Turning this key off will achieve better performance for both graph loading time and inference time with many iteration counts (greater than 16). Note that turning this key on will increase the graph loading time in proportion to the iteration counts. Thus, this key should be turned off if graph loading time is considered to be most important target to optimize. | +| `KEY_CLDNN_PLUGIN_PRIORITY` | `<0-3>` | `0` | OpenCL queue priority (before usage, make sure your OpenCL driver supports appropriate extension)
Higher value means higher priority for OpenCL queue. 0 disables the setting. **Deprecated**. Please use KEY_GPU_PLUGIN_PRIORITY | +| `KEY_CLDNN_PLUGIN_THROTTLE` | `<0-3>` | `0` | OpenCL queue throttling (before usage, make sure your OpenCL driver supports appropriate extension)
Lower value means lower driver thread priority and longer sleep time for it. 0 disables the setting. **Deprecated**. Please use KEY_GPU_PLUGIN_THROTTLE | +| `KEY_CLDNN_GRAPH_DUMPS_DIR` | `""` | `""` | clDNN graph optimizer stages dump output directory (in GraphViz format) **Deprecated**. Will be removed in the next release | +| `KEY_CLDNN_SOURCES_DUMPS_DIR` | `""` | `""` | Final optimized clDNN OpenCL sources dump output directory. **Deprecated**. Will be removed in the next release | +| `KEY_DUMP_KERNELS` | `YES` / `NO` | `NO` | Dump the final kernels used for custom layers. **Deprecated**. Will be removed in the next release | +| `KEY_TUNING_MODE` | `TUNING_DISABLED`
`TUNING_CREATE`
`TUNING_USE_EXISTING` | `TUNING_DISABLED` | Disable inference kernel tuning
Create tuning file (expect much longer runtime)
Use an existing tuning file. **Deprecated**. Will be removed in the next release | +| `KEY_TUNING_FILE` | `""` | `""` | Tuning file to create / use. **Deprecated**. Will be removed in the next release | ## GPU Context and Video Memory Sharing RemoteBlob API diff --git a/docs/IE_DG/supported_plugins/Supported_Devices.md b/docs/IE_DG/supported_plugins/Supported_Devices.md index ed8cabec076f03..e1140ae4b74cae 100644 --- a/docs/IE_DG/supported_plugins/Supported_Devices.md +++ b/docs/IE_DG/supported_plugins/Supported_Devices.md @@ -9,11 +9,11 @@ The Inference Engine provides unique capabilities to infer deep learning models | Plugin | Device types | |------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------| -|[GPU plugin](CL_DNN.md) |Intel® Processor Graphics, including Intel® HD Graphics and Intel® Iris® Graphics | +|[GPU plugin](GPU.md) |Intel® Processor Graphics, including Intel® HD Graphics and Intel® Iris® Graphics | |[CPU plugin](CPU.md) |Intel® Xeon® with Intel® Advanced Vector Extensions 2 (Intel® AVX2), Intel® Advanced Vector Extensions 512 (Intel® AVX-512), and AVX512_BF16, Intel® Core™ Processors with Intel® AVX2, Intel® Atom® Processors with Intel® Streaming SIMD Extensions (Intel® SSE) | |[VPU plugins](VPU.md) (available in the Intel® Distribution of OpenVINO™ toolkit) |Intel® Neural Compute Stick 2 powered by the Intel® Movidius™ Myriad™ X, Intel® Vision Accelerator Design with Intel® Movidius™ VPUs | |[GNA plugin](GNA.md) (available in the Intel® Distribution of OpenVINO™ toolkit) |Intel® Speech Enabling Developer Kit, Amazon Alexa* Premium Far-Field Developer Kit, Intel® Pentium® Silver J5005 Processor, Intel® Pentium® Silver N5000 Processor, Intel® Celeron® J4005 Processor, Intel® Celeron® J4105 Processor, Intel® Celeron® Processor N4100, Intel® Celeron® Processor N4000, Intel® Core™ i3-8121U Processor, Intel® Core™ i7-1065G7 Processor, Intel® Core™ i7-1060G7 Processor, Intel® Core™ i5-1035G4 Processor, Intel® Core™ i5-1035G7 Processor, Intel® Core™ i5-1035G1 Processor, Intel® Core™ i5-1030G7 Processor, Intel® Core™ i5-1030G4 Processor, Intel® Core™ i3-1005G1 Processor, Intel® Core™ i3-1000G1 Processor, Intel® Core™ i3-1000G4 Processor| -|[Multi-Device plugin](MULTI.md) |Multi-Device plugin enables simultaneous inference of the same network on several Intel® devices in parallel | +|[Multi-Device plugin](MULTI.md) |Multi-Device plugin enables simultaneous inference of the same network on several Intel® devices in parallel | |[Heterogeneous plugin](HETERO.md) |Heterogeneous plugin enables automatic inference splitting between several Intel® devices (for example if a device doesn't [support certain layers](#supported-layers)). | Devices similar to the ones we have used for benchmarking can be accessed using [Intel® DevCloud for the Edge](https://devcloud.intel.com/edge/), a remote development environment with access to Intel® hardware and the latest versions of the Intel® Distribution of the OpenVINO™ Toolkit. [Learn more](https://devcloud.intel.com/edge/get_started/devcloud/) or [Register here](https://inteliot.force.com/DevcloudForEdge/s/). @@ -60,7 +60,7 @@ For example, the CHW value at index (c,h,w) is physically located at index (c\*H |GNA plugin |Supported |Supported |Not supported |
\* - currently, only limited set of topologies might benefit from enabling I8 model on GPU
For [Multi-Device](MULTI.md) and [Heterogeneous](HETERO.md) execution -the supported models formats depends on the actual underlying devices. _Generally, FP16 is preferable as it is most ubiquitous and performant_. +the supported models formats depends on the actual underlying devices. _Generally, FP16 is preferable as it is most ubiquitous and performant_. ### Supported Input Precision @@ -73,7 +73,7 @@ the supported models formats depends on the actual underlying devices. _Generall
\* - Supported via `SetBlob` only, `GetBlob` returns FP32
For [Multi-Device](MULTI.md) and [Heterogeneous](HETERO.md) execution -the supported input precision depends on the actual underlying devices. _Generally, U8 is preferable as it is most ubiquitous_. +the supported input precision depends on the actual underlying devices. _Generally, U8 is preferable as it is most ubiquitous_. ### Supported Output Precision @@ -84,7 +84,7 @@ the supported input precision depends on the actual underlying devices. _Genera |VPU plugins |Supported |Supported | |GNA plugin |Supported |Not supported | For [Multi-Device](MULTI.md) and [Heterogeneous](HETERO.md) execution -the supported output precision depends on the actual underlying devices. _Generally, FP32 is preferable as it is most ubiquitous_. +the supported output precision depends on the actual underlying devices. _Generally, FP32 is preferable as it is most ubiquitous_. ### Supported Input Layout diff --git a/docs/doxygen/ie_docs.xml b/docs/doxygen/ie_docs.xml index f287487913d56a..bb006c9f01c630 100644 --- a/docs/doxygen/ie_docs.xml +++ b/docs/doxygen/ie_docs.xml @@ -293,7 +293,6 @@ limitations under the License. - @@ -303,7 +302,7 @@ limitations under the License. - + diff --git a/docs/model_server/README.md b/docs/model_server/README.md index ae5d03914ab347..e6c7144f3cb6c9 100644 --- a/docs/model_server/README.md +++ b/docs/model_server/README.md @@ -1,29 +1,29 @@ # OpenVINO™ Model Server {#openvino_docs_ovms} -OpenVINO™ Model Server (OVMS) is a scalable, high-performance solution for serving machine learning models optimized for Intel® architectures. -The server provides an inference service via gRPC or REST API - making it easy to deploy new algorithms and AI experiments using the same -architecture as [TensorFlow* Serving](https://github.com/tensorflow/serving) for any models trained in a framework that is supported -by [OpenVINO](https://software.intel.com/en-us/openvino-toolkit). +OpenVINO™ Model Server (OVMS) is a scalable, high-performance solution for serving machine learning models optimized for Intel® architectures. +The server provides an inference service via gRPC or REST API - making it easy to deploy new algorithms and AI experiments using the same +architecture as [TensorFlow* Serving](https://github.com/tensorflow/serving) for any models trained in a framework that is supported +by [OpenVINO](https://software.intel.com/en-us/openvino-toolkit). The server implements gRPC and REST API framework with data serialization and deserialization using TensorFlow Serving API, and OpenVINO™ as the inference execution provider. Model repositories may reside on a locally accessible file system (for example, NFS), Google Cloud Storage\* (GCS), Amazon S3\*, MinIO\*, or Azure Blob Storage\*. - + OVMS is now implemented in C++ and provides much higher scalability compared to its predecessor in the Python version. You can take advantage of all the power of Xeon® CPU capabilities or AI accelerators and expose it over the network interface. Read the [release notes](https://github.com/openvinotoolkit/model_server/releases) to find out what's new in the C++ version. Review the [Architecture Concept](https://github.com/openvinotoolkit/model_server/blob/main/docs/architecture.md) document for more details. -A few key features: +A few key features: - Support for multiple frameworks. Serve models trained in popular formats such as Caffe\*, TensorFlow\*, MXNet\*, and ONNX*. - Deploy new [model versions](https://github.com/openvinotoolkit/model_server/blob/main/docs/docker_container.md#model-version-policy) without changing client code. -- Support for AI accelerators including [Intel Movidius Myriad VPUs](../IE_DG/supported_plugins/VPU), -[GPU](../IE_DG/supported_plugins/CL_DNN), and [HDDL](../IE_DG/supported_plugins/HDDL). +- Support for AI accelerators including [Intel Movidius Myriad VPUs](../IE_DG/supported_plugins/VPU.md), +[GPU](../IE_DG/supported_plugins/GPU.md), and [HDDL](../IE_DG/supported_plugins/HDDL.md). - The server can be enabled both on [Bare Metal Hosts](https://github.com/openvinotoolkit/model_server/blob/main/docs/host.md) or in [Docker* containers](https://github.com/openvinotoolkit/model_server/blob/main/docs/docker_container.md). -- [Kubernetes deployments](https://github.com/openvinotoolkit/model_server/blob/main/deploy). The server can be deployed in a Kubernetes cluster allowing the inference service to scale horizontally and ensure high availability. -- [Model reshaping](https://github.com/openvinotoolkit/model_server/blob/main/docs/docker_container.md#model-reshaping). The server supports reshaping models in runtime. +- [Kubernetes deployments](https://github.com/openvinotoolkit/model_server/blob/main/deploy). The server can be deployed in a Kubernetes cluster allowing the inference service to scale horizontally and ensure high availability. +- [Model reshaping](https://github.com/openvinotoolkit/model_server/blob/main/docs/docker_container.md#model-reshaping). The server supports reshaping models in runtime. - [Model ensemble](https://github.com/openvinotoolkit/model_server/blob/main/docs/ensemble_scheduler.md) (preview). Connect multiple models to deploy complex processing solutions and reduce overhead of sending data back and forth. > **NOTE**: OVMS has been tested on CentOS\* and Ubuntu\*. Publicly released [Docker images](https://hub.docker.com/r/openvino/model_server) are based on CentOS. @@ -68,30 +68,30 @@ For more detailed guides on using the Model Server in various scenarios, visit t ## API Documentation -### GRPC +### GRPC -OpenVINO™ Model Server gRPC API is documented in the proto buffer files in [tensorflow_serving_api](https://github.com/tensorflow/serving/tree/r2.2/tensorflow_serving/apis). +OpenVINO™ Model Server gRPC API is documented in the proto buffer files in [tensorflow_serving_api](https://github.com/tensorflow/serving/tree/r2.2/tensorflow_serving/apis). -> **NOTE:** The implementations for `Predict`, `GetModelMetadata`, and `GetModelStatus` function calls are currently available. +> **NOTE:** The implementations for `Predict`, `GetModelMetadata`, and `GetModelStatus` function calls are currently available. > These are the most generic function calls and should address most of the usage scenarios. -[Predict proto](https://github.com/tensorflow/serving/blob/r2.2/tensorflow_serving/apis/predict.proto) defines two message specifications: `PredictRequest` and `PredictResponse` used while calling Prediction endpoint. -* `PredictRequest` specifies information about the model spec, that is name and version, and a map of input data serialized via +[Predict proto](https://github.com/tensorflow/serving/blob/r2.2/tensorflow_serving/apis/predict.proto) defines two message specifications: `PredictRequest` and `PredictResponse` used while calling Prediction endpoint. +* `PredictRequest` specifies information about the model spec, that is name and version, and a map of input data serialized via [TensorProto](https://github.com/tensorflow/tensorflow/blob/r2.2/tensorflow/core/framework/tensor.proto) to a string format. -* `PredictResponse` includes a map of outputs serialized by +* `PredictResponse` includes a map of outputs serialized by [TensorProto](https://github.com/tensorflow/tensorflow/blob/r2.2/tensorflow/core/framework/tensor.proto) and information about the used model spec. - + [Get Model Metadata proto](https://github.com/tensorflow/serving/blob/r2.2/tensorflow_serving/apis/get_model_metadata.proto) defines three message definitions used while calling Metadata endpoint: `SignatureDefMap`, `GetModelMetadataRequest`, `GetModelMetadataResponse`. A function call `GetModelMetadata` accepts model spec information as input and returns Signature Definition content in the format similar to TensorFlow Serving. [Get Model Status proto](https://github.com/tensorflow/serving/blob/r2.2/tensorflow_serving/apis/get_model_status.proto) defines three message definitions used while calling Status endpoint: - `GetModelStatusRequest`, `ModelVersionStatus`, `GetModelStatusResponse` that report all exposed versions including their state in their lifecycle. + `GetModelStatusRequest`, `ModelVersionStatus`, `GetModelStatusResponse` that report all exposed versions including their state in their lifecycle. Refer to the [example client code](https://github.com/openvinotoolkit/model_server/blob/main/example_client) to learn how to use this API and submit the requests using the gRPC interface. -Using the gRPC interface is recommended for optimal performance due to its faster implementation of input data deserialization. It enables you to achieve lower latency, especially with larger input messages like images. +Using the gRPC interface is recommended for optimal performance due to its faster implementation of input data deserialization. It enables you to achieve lower latency, especially with larger input messages like images. ### REST @@ -99,9 +99,9 @@ OpenVINO™ Model Server RESTful API follows the documentation from the [Ten Both row and column format of the requests are implemented. -> **NOTE**: Just like with gRPC, only the implementations for `Predict`, `GetModelMetadata`, and `GetModelStatus` function calls are currently available. +> **NOTE**: Just like with gRPC, only the implementations for `Predict`, `GetModelMetadata`, and `GetModelStatus` function calls are currently available. -Only the numerical data types are supported. +Only the numerical data types are supported. Review the exemplary clients below to find out more how to connect and run inference requests. @@ -110,9 +110,9 @@ REST API is recommended when the primary goal is in reducing the number of clien ## Known Limitations -* Currently, `Predict`, `GetModelMetadata`, and `GetModelStatus` calls are implemented using the TensorFlow Serving API. +* Currently, `Predict`, `GetModelMetadata`, and `GetModelStatus` calls are implemented using the TensorFlow Serving API. * `Classify`, `Regress`, and `MultiInference` are not included. -* `Output_filter` is not effective in the `Predict` call. All outputs defined in the model are returned to the clients. +* `Output_filter` is not effective in the `Predict` call. All outputs defined in the model are returned to the clients. ## OpenVINO Model Server Contribution Policy diff --git a/docs/optimization_guide/dldt_optimization_guide.md b/docs/optimization_guide/dldt_optimization_guide.md index e70c0365a4165c..9ece7fec93a628 100644 --- a/docs/optimization_guide/dldt_optimization_guide.md +++ b/docs/optimization_guide/dldt_optimization_guide.md @@ -2,13 +2,13 @@ ## Introduction -The purpose of this document is to give you performance-related insights to every step of the network deployment process. +The purpose of this document is to give you performance-related insights to every step of the network deployment process. For information on the general workflow, refer to the documentation in See Also. For an example Inference Engine API snippet, see Request-Based API and “GetBlob” Idiom. ### Deep Learning Inference Engine Overview -Deep Learning Inference Engine is a part of Intel® Deep Learning Deployment Toolkit (Intel® DL Deployment Toolkit) and OpenVINO™ toolkit. Inference Engine facilitates deployment of deep learning solutions by delivering a unified, device-agnostic API. +Deep Learning Inference Engine is a part of Intel® Deep Learning Deployment Toolkit (Intel® DL Deployment Toolkit) and OpenVINO™ toolkit. Inference Engine facilitates deployment of deep learning solutions by delivering a unified, device-agnostic API. Below, there are the three main steps of the deployment process: @@ -50,7 +50,7 @@ When evaluating performance of your model with the Inference Engine, you must me ### Latency vs. Throughput -In the asynchronous case (see Request-Based API and “GetBlob” Idiom), the performance of an individual infer request is usually of less concern. Instead, you typically execute multiple requests asynchronously and measure the throughput in images per second by dividing the number of images that were processed by the processing time. +In the asynchronous case (see Request-Based API and “GetBlob” Idiom), the performance of an individual infer request is usually of less concern. Instead, you typically execute multiple requests asynchronously and measure the throughput in images per second by dividing the number of images that were processed by the processing time. In contrast, for the latency-oriented tasks, the time to a single frame is more important. Refer to the [Benchmark App](../../inference-engine/samples/benchmark_app/README.md) sample, which allows latency vs. throughput measuring. @@ -114,23 +114,23 @@ The resulting IR precision, for instance, `FP16` or `FP32`, directly affects per ## Multi-Device Execution OpenVINO™ toolkit supports automatic multi-device execution, please see [MULTI-Device plugin description](../IE_DG/supported_plugins/MULTI.md). -In the next chapter you can find the device-specific tips, while this section covers few recommendations +In the next chapter you can find the device-specific tips, while this section covers few recommendations for the multi-device execution: -- MULTI usually performs best when the fastest device is specified first in the list of the devices. - This is particularly important when the parallelism is not sufficient +- MULTI usually performs best when the fastest device is specified first in the list of the devices. + This is particularly important when the parallelism is not sufficient (e.g. the number of request in the flight is not enough to saturate all devices). -- It is highly recommended to query the optimal number of inference requests directly from the instance of the ExecutionNetwork - (resulted from the LoadNetwork call with the specific multi-device configuration as a parameter). -Please refer to the code of the [Benchmark App](../../inference-engine/samples/benchmark_app/README.md) sample for details. -- Notice that for example CPU+GPU execution performs better with certain knobs +- It is highly recommended to query the optimal number of inference requests directly from the instance of the ExecutionNetwork + (resulted from the LoadNetwork call with the specific multi-device configuration as a parameter). +Please refer to the code of the [Benchmark App](../../inference-engine/samples/benchmark_app/README.md) sample for details. +- Notice that for example CPU+GPU execution performs better with certain knobs which you can find in the code of the same [Benchmark App](../../inference-engine/samples/benchmark_app/README.md) sample. - One specific example is disabling GPU driver polling, which in turn requires multiple GPU streams (which is already a default for the GPU) to amortize slower + One specific example is disabling GPU driver polling, which in turn requires multiple GPU streams (which is already a default for the GPU) to amortize slower inference completion from the device to the host. -- Multi-device logic always attempts to save on the (e.g. inputs) data copies between device-agnostic, user-facing inference requests - and device-specific 'worker' requests that are being actually scheduled behind the scene. - To facilitate the copy savings, it is recommended to start the requests in the order that they were created +- Multi-device logic always attempts to save on the (e.g. inputs) data copies between device-agnostic, user-facing inference requests + and device-specific 'worker' requests that are being actually scheduled behind the scene. + To facilitate the copy savings, it is recommended to start the requests in the order that they were created (with ExecutableNetwork's CreateInferRequest). - + ## Device-Specific Optimizations @@ -171,7 +171,7 @@ Notice that on a multi-socket machine, the bare minimum of streams for a latency In addition, you can play with the batch size to find the throughput sweet spot. -If your application is hard or impossible to change in accordance with the multiple-requests logic, consider the "multiple-instance" trick to improve the throughput: +If your application is hard or impossible to change in accordance with the multiple-requests logic, consider the "multiple-instance" trick to improve the throughput: - For multi-socket execution, it is recommended to set [`KEY_CPU_THREADS_NUM`](../IE_DG/supported_plugins/CPU.md) to the number of cores per socket, and run as many instances of the application as you have sockets. - Similarly, for extremely lightweight networks (running faster than 1ms) and/or many-core machines (16+ cores), try limiting the number of CPU inference threads to just `#‍phys` cores and further, while trying to saturate the machine with running multiple instances of the application. @@ -186,15 +186,15 @@ Inference Engine relies on the [Compute Library for Deep Neural Networks (clDNN) - If your application is simultaneously using the inference on the CPU or otherwise loads the host heavily, make sure that the OpenCL driver threads do not starve. You can use [CPU configuration options](../IE_DG/supported_plugins/CPU.md) to limit number of inference threads for the CPU plugin. - In the GPU-only scenario, a GPU driver might occupy a CPU core with spin-looped polling for completion. If the _CPU_ utilization is a concern, consider the `KEY_CLDND_PLUGIN_THROTTLE` configuration option. -> **NOTE**: See the [Benchmark App Sample](../../inference-engine/samples/benchmark_app/README.md) code for a usage example. -Notice that while disabling the polling, this option might reduce the GPU performance, so usually this option is used with multiple [GPU streams](../IE_DG/supported_plugins/CL_DNN.md). +> **NOTE**: See the [Benchmark App Sample](../../inference-engine/samples/benchmark_app/README.md) code for a usage example. +Notice that while disabling the polling, this option might reduce the GPU performance, so usually this option is used with multiple [GPU streams](../IE_DG/supported_plugins/GPU.md). ### Intel® Movidius™ Myriad™ X Visual Processing Unit and Intel® Vision Accelerator Design with Intel® Movidius™ VPUs Since Intel® Movidius™ Myriad™ X Visual Processing Unit (Intel® Movidius™ Myriad™ 2 VPU) communicates with the host over USB, minimum four infer requests in flight are recommended to hide the data transfer costs. See Request-Based API and “GetBlob” Idiom and [Benchmark App Sample](../../inference-engine/samples/benchmark_app/README.md) for more information. -Intel® Vision Accelerator Design with Intel® Movidius™ VPUs requires to keep at least 32 inference requests in flight to fully saturate the device. +Intel® Vision Accelerator Design with Intel® Movidius™ VPUs requires to keep at least 32 inference requests in flight to fully saturate the device. ### FPGA @@ -274,7 +274,7 @@ The following tips are provided to give general guidance on optimizing execution - Generally, GPU performance is better on heavy kernels (like Convolutions) and large inputs. So if the network inference time is already too small (~1ms of execution time), using the GPU would unlikely give a boost. -- A typical strategy to start with is to test the CPU-only and GPU-only scenarios first (with samples this is plain `-d CPU` or `-d GPU`). If there are specific kernels that are not supported by the GPU, the best option to try is the `HETERO:GPU,CPU` that automatically applies default splitting (based on the plugins layers support). Then, you can play with the manual affinity settings (for example, to further minimize the number of subgraphs). +- A typical strategy to start with is to test the CPU-only and GPU-only scenarios first (with samples this is plain `-d CPU` or `-d GPU`). If there are specific kernels that are not supported by the GPU, the best option to try is the `HETERO:GPU,CPU` that automatically applies default splitting (based on the plugins layers support). Then, you can play with the manual affinity settings (for example, to further minimize the number of subgraphs). - The general affinity “rule of thumb” is to keep computationally-intensive kernels on the accelerator, and "glue" (or helper) kernels on the CPU. Notice that this includes the granularity considerations. For example, running some (custom) activation on the CPU would result in too many conversions. @@ -337,7 +337,7 @@ For inference on the CPU there are multiple threads binding options, see If you are building an app-level pipeline with third-party components like GStreamer*, the general guidance for NUMA machines is as follows: - Whenever possible, use at least one instance of the pipeline per NUMA node: - - Pin the _entire_ pipeline instance to the specific NUMA node at the outer-most level (for example, use Kubernetes* and/or `numactl` command with proper settings before actual GStreamer commands). + - Pin the _entire_ pipeline instance to the specific NUMA node at the outer-most level (for example, use Kubernetes* and/or `numactl` command with proper settings before actual GStreamer commands). - Disable any individual pinning by the pipeline components (e.g. set [CPU_BIND_THREADS to 'NO'](../IE_DG/supported_plugins/CPU.md)). - Limit each instance with respect to number of inference threads. Use [CPU_THREADS_NUM](../IE_DG/supported_plugins/CPU.md) or or other means (e.g. virtualization, Kubernetes*, etc), to avoid oversubscription. - If pinning instancing/pinning of the entire pipeline is not possible or desirable, relax the inference threads pinning to just 'NUMA'. @@ -416,7 +416,7 @@ If your application simultaneously executes multiple infer requests: - For FPGA and GPU, the actual work is serialized by a plugin and/or a driver anyway. -- Finally, for any VPU flavor, using multiple requests is a must for achieving good throughput. +- Finally, for any VPU flavor, using multiple requests is a must for achieving good throughput. In the Inference Engine, there is no notion of requests priorities. It is left to the user side (for example, not queuing the low priority infer request, until another higher priority is waiting). Notice that it would require additional logic to synchronize between executable networks (queues) in your application code. @@ -470,12 +470,12 @@ Example of Inference Engine calls: Notice that `Task_runNOThrow` is an Async API wrapper and it is executed in a different thread and triggers the Intel MKL-DNN execution: ![](../img/vtune_timeline.png) - + - In the Intel VTune Amplifier **Top-down view**, grouped by the **Task Domain**. Notice the `Task_runNoThrow` and `MKLDNN _INFER` that are bracketing the actual Intel MKL-DNN kernels execution: - + ![](../img/vtune_topdown_view.jpg) - + Similarly, you can use any GPU analysis in the Intel VTune Amplifier and get general correlation with Inference Engine API as well as the execution breakdown for OpenCL kernels. Just like with regular native application, further drill down in the counters is possible, however, this is mostly useful for optimizing custom kernels. Finally, with the Intel VTune Amplifier, the profiling is not limited to your user-level code (see the [corresponding section in the Intel® VTune™ Amplifier User's Guide](https://software.intel.com/en-us/vtune-amplifier-help-analyze-performance)). @@ -513,12 +513,12 @@ Since FPGA execution does not separate individual kernels, only bulk execution/d ``` subgraph1: 1. input preprocessing (mean data/FPGA):EXECUTED layerType: preprocessing realTime: 129 cpu: 129 -subgraph1: 2. input transfer to DDR:EXECUTED layerType: realTime: 201 cpu: 0 -subgraph1: 3. FPGA execute time:EXECUTED layerType: realTime: 3808 cpu: 0 subgraph1: 4. output transfer from DDR:EXECUTED layerType: realTime: 55 cpu: 0 -subgraph1: 5. FPGA output postprocessing:EXECUTED layerType: realTime: 7 cpu: 7 -subgraph1: 6. softmax/copy: EXECUTED layerType: realTime: 2 cpu: 2 -subgraph2: out_prob: NOT_RUN layerType: Output realTime: 0 cpu: 0 -subgraph2: prob: EXECUTED layerType: SoftMax realTime: 10 cpu: 10 +subgraph1: 2. input transfer to DDR:EXECUTED layerType: realTime: 201 cpu: 0 +subgraph1: 3. FPGA execute time:EXECUTED layerType: realTime: 3808 cpu: 0 subgraph1: 4. output transfer from DDR:EXECUTED layerType: realTime: 55 cpu: 0 +subgraph1: 5. FPGA output postprocessing:EXECUTED layerType: realTime: 7 cpu: 7 +subgraph1: 6. softmax/copy: EXECUTED layerType: realTime: 2 cpu: 2 +subgraph2: out_prob: NOT_RUN layerType: Output realTime: 0 cpu: 0 +subgraph2: prob: EXECUTED layerType: SoftMax realTime: 10 cpu: 10 Total time: 4212 microseconds ``` diff --git a/docs/snippets/GPU_Kernel.cpp b/docs/snippets/GPU_Kernel.cpp index 5f849eb6a6a6a9..8b21a79dfe27dd 100644 --- a/docs/snippets/GPU_Kernel.cpp +++ b/docs/snippets/GPU_Kernel.cpp @@ -1,5 +1,4 @@ #include -#include "cldnn/cldnn_config.hpp" int main() { using namespace InferenceEngine; @@ -9,9 +8,5 @@ InferenceEngine::Core core; core.SetConfig({ { InferenceEngine::PluginConfigParams::KEY_CONFIG_FILE, "" } }, "GPU"); //! [part0] -//! [part1] -core.SetConfig({ { PluginConfigParams::KEY_DUMP_KERNELS, PluginConfigParams::YES } }, "GPU"); -//! [part1] - return 0; } diff --git a/docs/snippets/GPU_Kernels_Tuning.cpp b/docs/snippets/GPU_Kernels_Tuning.cpp deleted file mode 100644 index 25daeec5e2a263..00000000000000 --- a/docs/snippets/GPU_Kernels_Tuning.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include "cldnn/cldnn_config.hpp" - -int main() { -using namespace InferenceEngine; -//! [part0] -Core ie; - ie.SetConfig({{ CONFIG_KEY(TUNING_MODE), CONFIG_VALUE(TUNING_CREATE) }}, "GPU"); - ie.SetConfig({{ CONFIG_KEY(TUNING_FILE), "/path/to/tuning/file.json" }}, "GPU"); - // Further LoadNetwork calls will use the specified tuning parameters -//! [part0] - -return 0; -} diff --git a/docs/snippets/GPU_RemoteBlob_API2.cpp b/docs/snippets/GPU_RemoteBlob_API2.cpp index 1bb00c17e03e94..13597ae45617ba 100644 --- a/docs/snippets/GPU_RemoteBlob_API2.cpp +++ b/docs/snippets/GPU_RemoteBlob_API2.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include int main() { @@ -28,7 +28,7 @@ auto shared_va_context = gpu::make_shared_context(ie, "GPU", disp); // compile network within a shared context ExecutableNetwork executable_network = ie.LoadNetwork(network, shared_va_context, - { { CLDNNConfigParams::KEY_CLDNN_NV12_TWO_INPUTS, + { { GPUConfigParams::KEY_GPU_NV12_TWO_INPUTS, PluginConfigParams::YES } }); diff --git a/inference-engine/include/cldnn/cldnn_config.hpp b/inference-engine/include/cldnn/cldnn_config.hpp index cbc2aef0242101..3e5dc4cfb126f6 100644 --- a/inference-engine/include/cldnn/cldnn_config.hpp +++ b/inference-engine/include/cldnn/cldnn_config.hpp @@ -11,47 +11,11 @@ #pragma once #include "ie_plugin_config.hpp" +#include "ie_api.h" +#include "gpu/gpu_config.hpp" namespace InferenceEngine { -namespace Metrics { - -/** - * @def GPU_METRIC_KEY(name) - * @brief shortcut for defining GPU plugin metrics - */ -#define GPU_METRIC_KEY(name) METRIC_KEY(GPU_##name) -#define DECLARE_GPU_METRIC_KEY(name, ...) DECLARE_METRIC_KEY(GPU_##name, __VA_ARGS__) - -/** - * @def DECLARE_GPU_METRIC_VALUE(name) - * @brief shortcut for defining gpu metric values - */ -#define DECLARE_GPU_METRIC_VALUE(name) DECLARE_METRIC_VALUE(GPU_##name) - -/** - * @brief Metric which defines size of memory in bytes available for the device. For iGPU it returns host memory size, for dGPU - dedicated gpu memory size - */ -DECLARE_GPU_METRIC_KEY(DEVICE_TOTAL_MEM_SIZE, uint64_t); - -/** - * @brief Metric to get microarchitecture identifier in major.minor.revision format - */ -DECLARE_GPU_METRIC_KEY(UARCH_VERSION, std::string); - -/** - * @brief Metric to get count of execution units for current GPU - */ -DECLARE_GPU_METRIC_KEY(EXECUTION_UNITS_COUNT, int); - -/** - * @brief Possible return value for OPTIMIZATION_CAPABILITIES metric - * - "HW_MATMUL" - Defines if device has hardware block for matrix multiplication - */ -DECLARE_GPU_METRIC_VALUE(HW_MATMUL); - -} // namespace Metrics - /** * @brief GPU plugin configuration */ @@ -70,6 +34,7 @@ namespace CLDNNConfigParams { * this option should be used with an unsigned integer value (1 is lowest priority) * 0 means no priority hint is set and default queue is created. */ +INFERENCE_ENGINE_DEPRECATED("Use InferenceEngine::GPUConfigParams::GPU_PLUGIN_PRIORITY instead") DECLARE_CLDNN_CONFIG_KEY(PLUGIN_PRIORITY); /** @@ -78,22 +43,26 @@ DECLARE_CLDNN_CONFIG_KEY(PLUGIN_PRIORITY); * chapter 9.19. This option should be used with an unsigned integer value (1 is lowest energy consumption) * 0 means no throttle hint is set and default queue created. */ +INFERENCE_ENGINE_DEPRECATED("Use InferenceEngine::GPUConfigParams::GPU_PLUGIN_THROTTLE instead") DECLARE_CLDNN_CONFIG_KEY(PLUGIN_THROTTLE); /** * @brief This key controls clDNN memory pool optimization. * Turned off by default. */ +INFERENCE_ENGINE_DEPRECATED("The config key will be removed") DECLARE_CLDNN_CONFIG_KEY(MEM_POOL); /** * @brief This key defines the directory name to which clDNN graph visualization will be dumped. */ +INFERENCE_ENGINE_DEPRECATED("The config key will be removed") DECLARE_CLDNN_CONFIG_KEY(GRAPH_DUMPS_DIR); /** * @brief This key defines the directory name to which full program sources will be dumped. */ +INFERENCE_ENGINE_DEPRECATED("The config key will be removed") DECLARE_CLDNN_CONFIG_KEY(SOURCES_DUMPS_DIR); /** @@ -108,43 +77,19 @@ DECLARE_CLDNN_CONFIG_KEY(ENABLE_FP16_FOR_QUANTIZED_MODELS); * @brief This key should be set to correctly handle NV12 input without pre-processing. * Turned off by default. */ +INFERENCE_ENGINE_DEPRECATED("Use InferenceEngine::GPUConfigParams::GPU_NV12_TWO_INPUTS instead") DECLARE_CLDNN_CONFIG_KEY(NV12_TWO_INPUTS); -/** - * @brief This key sets the max number of host threads that can be used by GPU plugin on model loading. - * Default value is maximum number of threads available in the environment. - */ -DECLARE_CLDNN_CONFIG_KEY(MAX_NUM_THREADS); - -/** - * @brief Turning on this key enables to unroll recurrent layers such as TensorIterator or Loop with fixed iteration count. - * This key is turned on by default. Turning this key on will achieve better inference performance for loops with not too many iteration counts (less than 16, as a rule of thumb). - * Turning this key off will achieve better performance for both graph loading time and inference time with many iteration counts (greater than 16). - * Note that turning this key on will increase the graph loading time in proportion to the iteration counts. - * Thus, this key should be turned off if graph loading time is considered to be most important target to optimize.*/ -DECLARE_CLDNN_CONFIG_KEY(ENABLE_LOOP_UNROLLING); - } // namespace CLDNNConfigParams namespace PluginConfigParams { -/** - * @brief Optimize GPU plugin execution to maximize throughput. - * - * It is passed to Core::SetConfig(), this option should be used with values: - * - KEY_GPU_THROUGHPUT_AUTO creates bare minimum of streams that might improve performance in some cases, - * this option allows to enable throttle hint for opencl queue thus reduce CPU load without significant performance - * drop - * - a positive integer value creates the requested number of streams - */ -DECLARE_CONFIG_VALUE(GPU_THROUGHPUT_AUTO); -DECLARE_CONFIG_KEY(GPU_THROUGHPUT_STREAMS); - /** * @brief This key enables dumping of the kernels used by the plugin for custom layers. * * This option should be used with values: PluginConfigParams::YES or PluginConfigParams::NO (default) */ +INFERENCE_ENGINE_DEPRECATED("The config key will be removed") DECLARE_CONFIG_KEY(DUMP_KERNELS); /** @@ -159,17 +104,24 @@ DECLARE_CONFIG_KEY(DUMP_KERNELS); * * For values TUNING_CREATE and TUNING_RETUNE the file will be created if it does not exist. */ +INFERENCE_ENGINE_DEPRECATED("The config key will be removed") DECLARE_CONFIG_KEY(TUNING_MODE); +INFERENCE_ENGINE_DEPRECATED("The config value will be removed") DECLARE_CONFIG_VALUE(TUNING_CREATE); +INFERENCE_ENGINE_DEPRECATED("The config value will be removed") DECLARE_CONFIG_VALUE(TUNING_USE_EXISTING); +INFERENCE_ENGINE_DEPRECATED("The config value will be removed") DECLARE_CONFIG_VALUE(TUNING_DISABLED); +INFERENCE_ENGINE_DEPRECATED("The config value will be removed") DECLARE_CONFIG_VALUE(TUNING_UPDATE); +INFERENCE_ENGINE_DEPRECATED("The config value will be removed") DECLARE_CONFIG_VALUE(TUNING_RETUNE); /** * @brief This key defines the tuning data filename to be created/used */ +INFERENCE_ENGINE_DEPRECATED("The config key will be removed") DECLARE_CONFIG_KEY(TUNING_FILE); } // namespace PluginConfigParams diff --git a/inference-engine/include/gpu/gpu_config.hpp b/inference-engine/include/gpu/gpu_config.hpp new file mode 100644 index 00000000000000..96f8754ac8660a --- /dev/null +++ b/inference-engine/include/gpu/gpu_config.hpp @@ -0,0 +1,120 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +/** + * @brief A header for advanced hardware related properties for GPU plugin + * To use in SetConfig() method of plugins + * + * @file gpu_config.hpp + */ +#pragma once + +#include "ie_plugin_config.hpp" + +namespace InferenceEngine { + +namespace Metrics { + +/** + * @def GPU_METRIC_KEY(name) + * @brief shortcut for defining GPU plugin metrics + */ +#define GPU_METRIC_KEY(name) METRIC_KEY(GPU_##name) +#define DECLARE_GPU_METRIC_KEY(name, ...) DECLARE_METRIC_KEY(GPU_##name, __VA_ARGS__) + +/** + * @def DECLARE_GPU_METRIC_VALUE(name) + * @brief shortcut for defining gpu metric values + */ +#define DECLARE_GPU_METRIC_VALUE(name) DECLARE_METRIC_VALUE(GPU_##name) + +/** + * @brief Metric which defines size of memory in bytes available for the device. For iGPU it returns host memory size, for dGPU - dedicated gpu memory size + */ +DECLARE_GPU_METRIC_KEY(DEVICE_TOTAL_MEM_SIZE, uint64_t); + +/** + * @brief Metric to get microarchitecture identifier in major.minor.revision format + */ +DECLARE_GPU_METRIC_KEY(UARCH_VERSION, std::string); + +/** + * @brief Metric to get count of execution units for current GPU + */ +DECLARE_GPU_METRIC_KEY(EXECUTION_UNITS_COUNT, int); + +/** + * @brief Possible return value for OPTIMIZATION_CAPABILITIES metric + * - "HW_MATMUL" - Defines if device has hardware block for matrix multiplication + */ +DECLARE_GPU_METRIC_VALUE(HW_MATMUL); + +} // namespace Metrics + +/** + * @brief GPU plugin configuration + */ +namespace GPUConfigParams { + +/** + * @brief shortcut for defining configuration keys + */ +#define GPU_CONFIG_KEY(name) InferenceEngine::GPUConfigParams::_CONFIG_KEY(GPU_##name) +#define DECLARE_GPU_CONFIG_KEY(name) DECLARE_CONFIG_KEY(GPU_##name) +#define DECLARE_GPU_CONFIG_VALUE(name) DECLARE_CONFIG_VALUE(GPU_##name) + +/** + * @brief This key instructs the GPU plugin to use the OpenCL queue priority hint + * as defined in https://www.khronos.org/registry/OpenCL/specs/opencl-2.1-extensions.pdf + * this option should be used with an unsigned integer value (1 is lowest priority) + * 0 means no priority hint is set and default queue is created. + */ +DECLARE_GPU_CONFIG_KEY(PLUGIN_PRIORITY); + +/** + * @brief This key instructs the GPU plugin to use throttle hints the OpenCL queue throttle hint + * as defined in https://www.khronos.org/registry/OpenCL/specs/opencl-2.1-extensions.pdf, + * chapter 9.19. This option should be used with an unsigned integer value (1 is lowest energy consumption) + * 0 means no throttle hint is set and default queue created. + */ +DECLARE_GPU_CONFIG_KEY(PLUGIN_THROTTLE); + +/** + * @brief This key should be set to correctly handle NV12 input without pre-processing. + * Turned off by default. + */ +DECLARE_GPU_CONFIG_KEY(NV12_TWO_INPUTS); + +/** + * @brief This key sets the max number of host threads that can be used by GPU plugin on model loading. + * Default value is maximum number of threads available in the environment. + */ +DECLARE_GPU_CONFIG_KEY(MAX_NUM_THREADS); + +/** + * @brief Turning on this key enables to unroll recurrent layers such as TensorIterator or Loop with fixed iteration count. + * This key is turned on by default. Turning this key on will achieve better inference performance for loops with not too many iteration counts (less than 16, as a rule of thumb). + * Turning this key off will achieve better performance for both graph loading time and inference time with many iteration counts (greater than 16). + * Note that turning this key on will increase the graph loading time in proportion to the iteration counts. + * Thus, this key should be turned off if graph loading time is considered to be most important target to optimize.*/ +DECLARE_GPU_CONFIG_KEY(ENABLE_LOOP_UNROLLING); + +} // namespace GPUConfigParams + +namespace PluginConfigParams { + +/** + * @brief Optimize GPU plugin execution to maximize throughput. + * + * It is passed to Core::SetConfig(), this option should be used with values: + * - KEY_GPU_THROUGHPUT_AUTO creates bare minimum of streams that might improve performance in some cases, + * this option allows to enable throttle hint for opencl queue thus reduce CPU load without significant performance + * drop + * - a positive integer value creates the requested number of streams + */ +DECLARE_CONFIG_VALUE(GPU_THROUGHPUT_AUTO); +DECLARE_CONFIG_KEY(GPU_THROUGHPUT_STREAMS); +} // namespace PluginConfigParams + +} // namespace InferenceEngine diff --git a/inference-engine/samples/benchmark_app/main.cpp b/inference-engine/samples/benchmark_app/main.cpp index 849dc05ad3344a..cd7ddc641dc256 100644 --- a/inference-engine/samples/benchmark_app/main.cpp +++ b/inference-engine/samples/benchmark_app/main.cpp @@ -4,8 +4,8 @@ #include #include -#include #include +#include #include #include #include @@ -282,7 +282,7 @@ int main(int argc, char* argv[]) { << "which releases another CPU thread (that is otherwise " "used by the GPU driver for active polling)" << slog::endl; - device_config[CLDNN_CONFIG_KEY(PLUGIN_THROTTLE)] = "1"; + device_config[GPU_CONFIG_KEY(PLUGIN_THROTTLE)] = "1"; } } else if (device == "MYRIAD") { device_config[CONFIG_KEY(LOG_LEVEL)] = CONFIG_VALUE(LOG_WARNING); diff --git a/inference-engine/samples/hello_query_device/README.md b/inference-engine/samples/hello_query_device/README.md index a185147f8ec50e..059077c48ad6b4 100644 --- a/inference-engine/samples/hello_query_device/README.md +++ b/inference-engine/samples/hello_query_device/README.md @@ -63,20 +63,20 @@ Available devices: SUPPORTED_METRICS : [ AVAILABLE_DEVICES SUPPORTED_METRICS FULL_DEVICE_NAME OPTIMIZATION_CAPABILITIES SUPPORTED_CONFIG_KEYS RANGE_FOR_ASYNC_INFER_REQUESTS RANGE_FOR_STREAMS ] FULL_DEVICE_NAME : Intel(R) UHD Graphics 620 (iGPU) OPTIMIZATION_CAPABILITIES : [ FP32 BIN FP16 ] - SUPPORTED_CONFIG_KEYS : [ CACHE_DIR CLDNN_ENABLE_FP16_FOR_QUANTIZED_MODELS CLDNN_GRAPH_DUMPS_DIR CLDNN_MAX_NUM_THREADS CLDNN_MEM_POOL CLDNN_NV12_TWO_INPUTS CLDNN_PLUGIN_PRIORITY CLDNN_PLUGIN_THROTTLE CLDNN_SOURCES_DUMPS_DIR CLDNN_ENABLE_LOOP_UNROLLING CONFIG_FILE DEVICE_ID DUMP_KERNELS DYN_BATCH_ENABLED EXCLUSIVE_ASYNC_REQUESTS GPU_THROUGHPUT_STREAMS PERF_COUNT TUNING_FILE TUNING_MODE ] + SUPPORTED_CONFIG_KEYS : [ CACHE_DIR CLDNN_ENABLE_FP16_FOR_QUANTIZED_MODELS CLDNN_GRAPH_DUMPS_DIR GPU_MAX_NUM_THREADS CLDNN_MEM_POOL CLDNN_NV12_TWO_INPUTS CLDNN_PLUGIN_PRIORITY CLDNN_PLUGIN_THROTTLE CLDNN_SOURCES_DUMPS_DIR GPU_ENABLE_LOOP_UNROLLING CONFIG_FILE DEVICE_ID DUMP_KERNELS DYN_BATCH_ENABLED EXCLUSIVE_ASYNC_REQUESTS GPU_THROUGHPUT_STREAMS PERF_COUNT TUNING_FILE TUNING_MODE ] RANGE_FOR_ASYNC_INFER_REQUESTS : { 1, 2, 1 } RANGE_FOR_STREAMS : { 1, 2 } Default values for device configuration keys: CACHE_DIR : "" CLDNN_ENABLE_FP16_FOR_QUANTIZED_MODELS : YES CLDNN_GRAPH_DUMPS_DIR : "" - CLDNN_MAX_NUM_THREADS : 8 CLDNN_MEM_POOL : YES CLDNN_NV12_TWO_INPUTS : NO CLDNN_PLUGIN_PRIORITY : 0 CLDNN_PLUGIN_THROTTLE : 0 CLDNN_SOURCES_DUMPS_DIR : "" - CLDNN_ENABLE_LOOP_UNROLLING : YES + GPU_MAX_NUM_THREADS : 8 + GPU_ENABLE_LOOP_UNROLLING : YES CONFIG_FILE : "" DEVICE_ID : "" DUMP_KERNELS : NO diff --git a/inference-engine/src/cldnn_engine/cldnn_config.cpp b/inference-engine/src/cldnn_engine/cldnn_config.cpp index ff5d96935224cb..3de19bdff87dcc 100644 --- a/inference-engine/src/cldnn_engine/cldnn_config.cpp +++ b/inference-engine/src/cldnn_engine/cldnn_config.cpp @@ -5,6 +5,7 @@ #include #include +#include #include "cldnn_config.h" #include "cpp_interfaces/interface/ie_internal_plugin_config.hpp" #include "ie_api.h" @@ -39,6 +40,7 @@ static void createDirectory(std::string _path) { } } +IE_SUPPRESS_DEPRECATED_START void Config::UpdateFromMap(const std::map& configMap) { OV_ITT_SCOPED_TASK(itt::domains::CLDNNPlugin, "Config::UpdateFromMap"); for (auto& kvp : configMap) { @@ -69,7 +71,8 @@ void Config::UpdateFromMap(const std::map& configMap) } else { IE_THROW(NotFound) << "Unsupported property value by plugin: " << val; } - } else if (key.compare(CLDNNConfigParams::KEY_CLDNN_PLUGIN_PRIORITY) == 0) { + } else if (key.compare(GPUConfigParams::KEY_GPU_PLUGIN_PRIORITY) == 0 || + key.compare(CLDNNConfigParams::KEY_CLDNN_PLUGIN_PRIORITY) == 0) { std::stringstream ss(val); uint32_t uVal(0); ss >> uVal; @@ -93,7 +96,8 @@ void Config::UpdateFromMap(const std::map& configMap) IE_THROW(ParameterMismatch) << "Unsupported queue priority value: " << uVal; } - } else if (key.compare(CLDNNConfigParams::KEY_CLDNN_PLUGIN_THROTTLE) == 0) { + } else if (key.compare(GPUConfigParams::KEY_GPU_PLUGIN_THROTTLE) == 0 || + key.compare(CLDNNConfigParams::KEY_CLDNN_PLUGIN_THROTTLE) == 0) { std::stringstream ss(val); uint32_t uVal(0); ss >> uVal; @@ -205,7 +209,8 @@ void Config::UpdateFromMap(const std::map& configMap) } else { IE_THROW(NotFound) << "Unsupported property value by plugin: " << val; } - } else if (key.compare(CLDNNConfigParams::KEY_CLDNN_NV12_TWO_INPUTS) == 0) { + } else if (key.compare(GPUConfigParams::KEY_GPU_NV12_TWO_INPUTS) == 0 || + key.compare(CLDNNConfigParams::KEY_CLDNN_NV12_TWO_INPUTS) == 0) { if (val.compare(PluginConfigParams::YES) == 0) { nv12_two_inputs = true; } else if (val.compare(PluginConfigParams::NO) == 0) { @@ -221,7 +226,7 @@ void Config::UpdateFromMap(const std::map& configMap) } else { IE_THROW(NotFound) << "Unsupported KEY_CLDNN_ENABLE_FP16_FOR_QUANTIZED_MODELS flag value: " << val; } - } else if (key.compare(CLDNNConfigParams::KEY_CLDNN_MAX_NUM_THREADS) == 0) { + } else if (key.compare(GPUConfigParams::KEY_GPU_MAX_NUM_THREADS) == 0) { int max_threads = std::max(1, static_cast(std::thread::hardware_concurrency())); try { int val_i = std::stoi(val); @@ -231,17 +236,17 @@ void Config::UpdateFromMap(const std::map& configMap) n_threads = val_i; } } catch (const std::exception&) { - IE_THROW() << "Wrong value for property key " << CLDNNConfigParams::KEY_CLDNN_MAX_NUM_THREADS << ": " << val + IE_THROW() << "Wrong value for property key " << GPUConfigParams::KEY_GPU_MAX_NUM_THREADS << ": " << val << "\nSpecify the number of threads use for build as an integer." << "\nOut of range value will be set as a default value, maximum concurrent threads."; } - } else if (key.compare(CLDNNConfigParams::KEY_CLDNN_ENABLE_LOOP_UNROLLING) == 0) { + } else if (key.compare(GPUConfigParams::KEY_GPU_ENABLE_LOOP_UNROLLING) == 0) { if (val.compare(PluginConfigParams::YES) == 0) { enable_loop_unrolling = true; } else if (val.compare(PluginConfigParams::NO) == 0) { enable_loop_unrolling = false; } else { - IE_THROW(ParameterMismatch) << "Unsupported KEY_CLDNN_ENABLE_LOOP_UNROLLING flag value: " << val; + IE_THROW(ParameterMismatch) << "Unsupported KEY_GPU_ENABLE_LOOP_UNROLLING flag value: " << val; } } else { IE_THROW(NotFound) << "Unsupported property key by plugin: " << key; @@ -297,6 +302,7 @@ void Config::adjustKeyMapValues() { default: break; } key_config_map[CLDNNConfigParams::KEY_CLDNN_PLUGIN_PRIORITY] = qp; + key_config_map[GPUConfigParams::KEY_GPU_PLUGIN_PRIORITY] = qp; } { std::string qt = "0"; @@ -307,6 +313,7 @@ void Config::adjustKeyMapValues() { default: break; } key_config_map[CLDNNConfigParams::KEY_CLDNN_PLUGIN_THROTTLE] = qt; + key_config_map[GPUConfigParams::KEY_GPU_PLUGIN_THROTTLE] = qt; } { std::string tm = PluginConfigParams::TUNING_DISABLED; @@ -328,11 +335,13 @@ void Config::adjustKeyMapValues() { key_config_map[PluginConfigParams::KEY_GPU_THROUGHPUT_STREAMS] = std::to_string(throughput_streams); key_config_map[PluginConfigParams::KEY_DEVICE_ID] = device_id; key_config_map[PluginConfigParams::KEY_CONFIG_FILE] = ""; - key_config_map[CLDNNConfigParams::KEY_CLDNN_MAX_NUM_THREADS] = std::to_string(n_threads); + key_config_map[GPUConfigParams::KEY_GPU_MAX_NUM_THREADS] = std::to_string(n_threads); if (enable_loop_unrolling) - key_config_map[CLDNNConfigParams::KEY_CLDNN_ENABLE_LOOP_UNROLLING] = PluginConfigParams::YES; + key_config_map[GPUConfigParams::KEY_GPU_ENABLE_LOOP_UNROLLING] = PluginConfigParams::YES; else - key_config_map[CLDNNConfigParams::KEY_CLDNN_ENABLE_LOOP_UNROLLING] = PluginConfigParams::NO; + key_config_map[GPUConfigParams::KEY_GPU_ENABLE_LOOP_UNROLLING] = PluginConfigParams::NO; } +IE_SUPPRESS_DEPRECATED_END + } // namespace CLDNNPlugin diff --git a/inference-engine/src/cldnn_engine/cldnn_engine.cpp b/inference-engine/src/cldnn_engine/cldnn_engine.cpp index 86b9f2e4b9526b..171919a80775d6 100644 --- a/inference-engine/src/cldnn_engine/cldnn_engine.cpp +++ b/inference-engine/src/cldnn_engine/cldnn_engine.cpp @@ -79,7 +79,7 @@ #include "cldnn_executable_network.h" #include "cldnn_custom_layer.h" #include "cldnn_itt.h" -#include "cldnn/cldnn_config.hpp" +#include "gpu/gpu_config.hpp" #ifdef __linux__ # include diff --git a/inference-engine/src/cldnn_engine/cldnn_executable_network.cpp b/inference-engine/src/cldnn_engine/cldnn_executable_network.cpp index c2289fa9fb0bde..5191da35c2e369 100644 --- a/inference-engine/src/cldnn_engine/cldnn_executable_network.cpp +++ b/inference-engine/src/cldnn_engine/cldnn_executable_network.cpp @@ -16,7 +16,6 @@ #include "cldnn_itt.h" #include -#include #include "cldnn_infer_request.h" #include #include "cldnn_async_infer_request.h" diff --git a/inference-engine/src/cldnn_engine/cldnn_graph.cpp b/inference-engine/src/cldnn_engine/cldnn_graph.cpp index 04d40c9815d00d..1f835d8ac2c991 100644 --- a/inference-engine/src/cldnn_engine/cldnn_graph.cpp +++ b/inference-engine/src/cldnn_engine/cldnn_graph.cpp @@ -16,7 +16,6 @@ #include "cldnn_graph.h" #include "simple_math.h" #include -#include #include "cldnn_infer_request.h" #include #include diff --git a/inference-engine/tests/functional/plugin/gpu/remote_blob_tests/cldnn_remote_blob_tests.cpp b/inference-engine/tests/functional/plugin/gpu/remote_blob_tests/cldnn_remote_blob_tests.cpp index e6415688de2484..6837c0b84c33a8 100644 --- a/inference-engine/tests/functional/plugin/gpu/remote_blob_tests/cldnn_remote_blob_tests.cpp +++ b/inference-engine/tests/functional/plugin/gpu/remote_blob_tests/cldnn_remote_blob_tests.cpp @@ -9,7 +9,7 @@ #include -#include +#include #include #include #include @@ -175,7 +175,7 @@ TEST_P(BatchedBlob_Test, canInputNV12) { /* XXX: is it correct to set KEY_CLDNN_NV12_TWO_INPUTS in case of remote blob? */ auto exec_net_b = ie.LoadNetwork(net_remote, CommonTestUtils::DEVICE_GPU, - { { CLDNNConfigParams::KEY_CLDNN_NV12_TWO_INPUTS, PluginConfigParams::YES} }); + { { GPUConfigParams::KEY_GPU_NV12_TWO_INPUTS, PluginConfigParams::YES} }); auto inf_req_remote = exec_net_b.CreateInferRequest(); auto cldnn_context = exec_net_b.GetContext(); cl_context ctx = std::dynamic_pointer_cast(cldnn_context)->get(); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/config.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/config.cpp index e21d610db569cb..a8c039e43915a4 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/config.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/config.cpp @@ -4,6 +4,7 @@ #include "behavior/config.hpp" #include "cldnn/cldnn_config.hpp" +#include "gpu/gpu_config.hpp" using namespace BehaviorTestsDefinitions; namespace { @@ -12,6 +13,7 @@ namespace { InferenceEngine::Precision::FP16 }; + IE_SUPPRESS_DEPRECATED_START const std::vector> inconfigs = { {{InferenceEngine::PluginConfigParams::KEY_GPU_THROUGHPUT_STREAMS, "OFF"}}, {{InferenceEngine::PluginConfigParams::KEY_PERF_COUNT, "ON"}}, @@ -46,6 +48,7 @@ namespace { {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_GPU}, {InferenceEngine::PluginConfigParams::KEY_DEVICE_ID, "DEVICE_UNKNOWN"}} }; + IE_SUPPRESS_DEPRECATED_END INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigTests, ::testing::Combine( @@ -73,6 +76,29 @@ namespace { {} }; + IE_SUPPRESS_DEPRECATED_START + const std::vector> conf_gpu = { + // Deprecated + {{InferenceEngine::CLDNNConfigParams::KEY_CLDNN_NV12_TWO_INPUTS, InferenceEngine::PluginConfigParams::YES}}, + {{InferenceEngine::CLDNNConfigParams::KEY_CLDNN_NV12_TWO_INPUTS, InferenceEngine::PluginConfigParams::NO}}, + {{InferenceEngine::CLDNNConfigParams::KEY_CLDNN_PLUGIN_THROTTLE, "0"}}, + {{InferenceEngine::CLDNNConfigParams::KEY_CLDNN_PLUGIN_THROTTLE, "1"}}, + {{InferenceEngine::CLDNNConfigParams::KEY_CLDNN_PLUGIN_PRIORITY, "0"}}, + {{InferenceEngine::CLDNNConfigParams::KEY_CLDNN_PLUGIN_PRIORITY, "1"}}, + + {{InferenceEngine::GPUConfigParams::KEY_GPU_NV12_TWO_INPUTS, InferenceEngine::PluginConfigParams::YES}}, + {{InferenceEngine::GPUConfigParams::KEY_GPU_NV12_TWO_INPUTS, InferenceEngine::PluginConfigParams::NO}}, + {{InferenceEngine::GPUConfigParams::KEY_GPU_PLUGIN_THROTTLE, "0"}}, + {{InferenceEngine::GPUConfigParams::KEY_GPU_PLUGIN_THROTTLE, "1"}}, + {{InferenceEngine::GPUConfigParams::KEY_GPU_PLUGIN_PRIORITY, "0"}}, + {{InferenceEngine::GPUConfigParams::KEY_GPU_PLUGIN_PRIORITY, "1"}}, + {{InferenceEngine::GPUConfigParams::KEY_GPU_MAX_NUM_THREADS, "1"}}, + {{InferenceEngine::GPUConfigParams::KEY_GPU_MAX_NUM_THREADS, "4"}}, + {{InferenceEngine::GPUConfigParams::KEY_GPU_ENABLE_LOOP_UNROLLING, InferenceEngine::PluginConfigParams::YES}}, + {{InferenceEngine::GPUConfigParams::KEY_GPU_ENABLE_LOOP_UNROLLING, InferenceEngine::PluginConfigParams::NO}}, + }; + IE_SUPPRESS_DEPRECATED_END + const std::vector> multiconf = { {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES , CommonTestUtils::DEVICE_GPU}} }; @@ -92,6 +118,13 @@ namespace { ::testing::ValuesIn(conf)), CorrectConfigAPITests::getTestCaseName); + INSTANTIATE_TEST_CASE_P(smoke_GPU_BehaviorTests, CorrectConfigAPITests, + ::testing::Combine( + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CommonTestUtils::DEVICE_GPU), + ::testing::ValuesIn(conf_gpu)), + CorrectConfigAPITests::getTestCaseName); + INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, CorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), @@ -142,4 +175,4 @@ namespace { IncorrectConfigAPITests::getTestCaseName); -} // namespace \ No newline at end of file +} // namespace diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/core_integration.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/core_integration.cpp index 3765c75864fa5f..68b23831e47944 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/core_integration.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/core_integration.cpp @@ -11,7 +11,7 @@ #endif #include "gpu/gpu_context_api_ocl.hpp" -#include "cldnn/cldnn_config.hpp" +#include "gpu/gpu_config.hpp" using namespace BehaviorTestsDefinitions; diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_input.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_input.cpp index e15ea827caa814..59f4dd21677c24 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_input.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_input.cpp @@ -3,7 +3,7 @@ // #include "behavior/infer_request_input.hpp" -#include "cldnn/cldnn_config.hpp" +#include "gpu/gpu_config.hpp" using namespace BehaviorTestsDefinitions; namespace { diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_output.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_output.cpp index 6c38f5c841c0b0..1135f6d9f7d8e4 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_output.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_output.cpp @@ -3,7 +3,7 @@ // #include "behavior/infer_request_output.hpp" -#include "cldnn/cldnn_config.hpp" +#include "gpu/gpu_config.hpp" using namespace BehaviorTestsDefinitions; namespace { diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/test_plugin.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/test_plugin.cpp index 51979116646939..729bf57c64ac8a 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/test_plugin.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/test_plugin.cpp @@ -3,7 +3,7 @@ // #include "behavior/test_plugin.hpp" -#include "cldnn/cldnn_config.hpp" +#include "gpu/gpu_config.hpp" using namespace BehaviorTestsDefinitions; namespace { diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/multi/gpu_remote_blob_tests.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/multi/gpu_remote_blob_tests.cpp index da308c032e258b..4fffb2cad6e157 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/multi/gpu_remote_blob_tests.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/multi/gpu_remote_blob_tests.cpp @@ -4,7 +4,7 @@ #include #include -#include "cldnn/cldnn_config.hpp" +#include "gpu/gpu_config.hpp" #include "multi/multi_remote_blob_tests.hpp" #include "common_test_utils/test_constants.hpp" diff --git a/inference-engine/tests/functional/plugin/gpu/single_layer_tests/tensor_iterator.cpp b/inference-engine/tests/functional/plugin/gpu/single_layer_tests/tensor_iterator.cpp index aae2e0db8fa3ac..bce1ef106917f2 100644 --- a/inference-engine/tests/functional/plugin/gpu/single_layer_tests/tensor_iterator.cpp +++ b/inference-engine/tests/functional/plugin/gpu/single_layer_tests/tensor_iterator.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include "common_test_utils/test_constants.hpp" #include "ie_api.h" @@ -289,8 +289,8 @@ namespace { InferenceEngine::Precision::FP16, }), // precision ::testing::ValuesIn(std::vector { - {CommonTestUtils::DEVICE_GPU, {{CLDNNConfigParams::KEY_CLDNN_ENABLE_LOOP_UNROLLING, PluginConfigParams::YES}}}, - {CommonTestUtils::DEVICE_GPU, {{CLDNNConfigParams::KEY_CLDNN_ENABLE_LOOP_UNROLLING, PluginConfigParams::NO}}} + {CommonTestUtils::DEVICE_GPU, {{GPUConfigParams::KEY_GPU_ENABLE_LOOP_UNROLLING, PluginConfigParams::YES}}}, + {CommonTestUtils::DEVICE_GPU, {{GPUConfigParams::KEY_GPU_ENABLE_LOOP_UNROLLING, PluginConfigParams::NO}}} })), // configuration TensorIteratorWithConfigTest::getTestCaseName); } // namespace diff --git a/tools/benchmark/main.py b/tools/benchmark/main.py index 29aff45742e8c1..26ef6246f0c9d5 100644 --- a/tools/benchmark/main.py +++ b/tools/benchmark/main.py @@ -152,7 +152,7 @@ def set_throughput_streams(): if MULTI_DEVICE_NAME in device_name and CPU_DEVICE_NAME in device_name: logger.warning("Turn on GPU trottling. Multi-device execution with the CPU + GPU performs best with GPU trottling hint, " + "which releases another CPU thread (that is otherwise used by the GPU driver for active polling)") - config[device]['CLDNN_PLUGIN_THROTTLE'] = '1' + config[device]['GPU_PLUGIN_THROTTLE'] = '1' elif device == MYRIAD_DEVICE_NAME: set_throughput_streams() config[device]['LOG_LEVEL'] = 'LOG_INFO' From 2c3abf8f42e9a47d9e701779d333a732bbb24f68 Mon Sep 17 00:00:00 2001 From: Roman Kazantsev Date: Wed, 9 Jun 2021 10:00:20 +0300 Subject: [PATCH 039/178] Use int64 for TopK indices output (#6085) Signed-off-by: Roman Kazantsev --- model-optimizer/extensions/front/onnx/top_k_ext.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/model-optimizer/extensions/front/onnx/top_k_ext.py b/model-optimizer/extensions/front/onnx/top_k_ext.py index bae2bec317686a..e073c593531eed 100644 --- a/model-optimizer/extensions/front/onnx/top_k_ext.py +++ b/model-optimizer/extensions/front/onnx/top_k_ext.py @@ -1,6 +1,8 @@ # Copyright (C) 2018-2021 Intel Corporation # SPDX-License-Identifier: Apache-2.0 +import numpy as np + from extensions.ops.topk import TopK from mo.front.extractor import FrontExtractorOp from mo.front.onnx.extractors.utils import onnx_attr, onnx_node_has_attr @@ -18,7 +20,8 @@ def extract(cls, node): TopK-11 (k as input, sorting manipulations through `sorted` and `largest` attrs) """ attrs = { - 'axis': onnx_attr(node, 'axis', 'i', default=-1) + 'axis': onnx_attr(node, 'axis', 'i', default=-1), + 'index_element_type': np.int64 } if onnx_node_has_attr(node, 'k'): attrs['k'] = onnx_attr(node, 'k', 'i') From 6e2d13937aea1b6a694767b49bb4ac8508f306e8 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Wed, 9 Jun 2021 10:09:25 +0300 Subject: [PATCH 040/178] ImportNetwork with explicit device name only (#5689) * Import with explicit name * Fixed LoadHetero_MultiArchs tests * Fixed MYRIAD tests on Windows * Fixed compilation in tests * Updated tesets * Fixed test * Removed useless lines * Removed custom VPU tests, replaced with common ones * Fixed Windows * Reverted SKIP_IF_NOT_IMPLEMENTED macro --- docs/IE_PLUGIN_DG/ExecutableNetwork.md | 11 +- docs/IE_PLUGIN_DG/Plugin.md | 10 +- .../src/template_executable_network.cpp | 8 +- .../src/template_executable_network.hpp | 2 +- docs/template_plugin/src/template_plugin.cpp | 8 +- docs/template_plugin/src/template_plugin.hpp | 2 +- inference-engine/include/ie_core.hpp | 11 +- .../hetero_executable_network.cpp | 2 +- .../hetero_executable_network.hpp | 2 +- .../src/hetero_plugin/hetero_plugin.cpp | 9 +- .../src/hetero_plugin/hetero_plugin.hpp | 5 +- .../ie_iexecutable_network_internal.cpp | 21 +- .../interface/ie_iplugin_internal.cpp | 43 +- .../src/inference_engine/ie_core.cpp | 52 +-- .../ie_iexecutable_network_internal.hpp | 8 - .../interface/ie_iplugin_internal.hpp | 27 +- inference-engine/src/plugin_api/ie_icore.hpp | 12 - .../myriad_plugin/myriad_executable_network.h | 10 - .../src/vpu/myriad_plugin/myriad_plugin.cpp | 14 - .../src/vpu/myriad_plugin/myriad_plugin.h | 4 - .../inference_engine/caching_test.cpp | 377 +++++++++--------- .../skip_tests_config.cpp | 2 + .../skip_tests_config.cpp | 2 + .../behavior/core_integration.cpp | 35 +- .../include/behavior/core_integration.hpp | 49 ++- .../impl/mock_inference_plugin_internal.hpp | 7 +- .../mock_iexecutable_network_internal.hpp | 4 - .../mocks/mock_engine/mock_plugin.cpp | 10 +- .../mocks/mock_engine/mock_plugin.hpp | 8 +- .../cpp_interfaces/ie_plugin_test.cpp | 23 -- 30 files changed, 316 insertions(+), 462 deletions(-) diff --git a/docs/IE_PLUGIN_DG/ExecutableNetwork.md b/docs/IE_PLUGIN_DG/ExecutableNetwork.md index c5bfd889857793..ae82b05e4edce3 100644 --- a/docs/IE_PLUGIN_DG/ExecutableNetwork.md +++ b/docs/IE_PLUGIN_DG/ExecutableNetwork.md @@ -49,20 +49,15 @@ The function accepts a const shared pointer to `ngraph::Function` object and per This constructor creates a backend specific graph by importing from a stream object: -> **NOTE**: The export of backend specific graph is done in the `ExportImpl` method, and data formats must be the same for both import and export. +> **NOTE**: The export of backend specific graph is done in the `Export` method, and data formats must be the same for both import and export. @snippet src/template_executable_network.cpp executable_network:ctor_import_stream -### `ExportImpl()` - -**Implementation details:** -Base InferenceEngine::ExecutableNetworkThreadSafeDefault class implements the public InferenceEngine::ExecutableNetworkThreadSafeDefault::Export method as following: -- Writes `_plugin->GetName()` to the `model` stream. -- Calls the `ExportImpl` method defined in a derived class to dump a backend specific graph. +### `Export()` The implementation of the method should write all data to the `model` stream, which is required to import a backend specific graph later in the `Plugin::Import` method: -@snippet src/template_executable_network.cpp executable_network:export_impl +@snippet src/template_executable_network.cpp executable_network:export ### `CreateInferRequest()` diff --git a/docs/IE_PLUGIN_DG/Plugin.md b/docs/IE_PLUGIN_DG/Plugin.md index cadc8660fd3c30..6003eb691fc059 100644 --- a/docs/IE_PLUGIN_DG/Plugin.md +++ b/docs/IE_PLUGIN_DG/Plugin.md @@ -159,21 +159,13 @@ The snippet below provides an example of the implementation for `GetMetric`: > **NOTE**: If an unsupported metric key is passed to the function, it must throw an exception. -### `ImportNetworkImpl()` +### `ImportNetwork()` The importing network mechanism allows to import a previously exported backend specific graph and wrap it using an [ExecutableNetwork](@ref executable_network) object. This functionality is useful if backend specific graph compilation takes significant time and/or cannot be done on a target host device due to other reasons. -**Implementation details:** The base plugin class InferenceEngine::IInferencePlugin implements InferenceEngine::IInferencePlugin::ImportNetwork -as follows: exports a device type (InferenceEngine::IInferencePlugin::_pluginName) and then calls `ImportNetworkImpl`, -which is implemented in a derived class. -If a plugin cannot use the base implementation InferenceEngine::IInferencePlugin::ImportNetwork, it can override base -implementation and define an output blob structure up to its needs. This -can be useful if a plugin exports a blob in a special format for integration with other frameworks -where a common Inference Engine header from a base class implementation is not appropriate. - During export of backend specific graph using `ExecutableNetwork::Export`, a plugin may export any type of information it needs to import a compiled graph properly and check its correctness. For example, the export information may include: diff --git a/docs/template_plugin/src/template_executable_network.cpp b/docs/template_plugin/src/template_executable_network.cpp index e46bd63e5a0faa..4aba4622e50428 100644 --- a/docs/template_plugin/src/template_executable_network.cpp +++ b/docs/template_plugin/src/template_executable_network.cpp @@ -175,9 +175,9 @@ InferenceEngine::Parameter TemplatePlugin::ExecutableNetwork::GetMetric(const st } // ! [executable_network:get_metric] -// ! [executable_network:export_impl] -void TemplatePlugin::ExecutableNetwork::ExportImpl(std::ostream& modelStream) { - OV_ITT_SCOPED_TASK(itt::domains::TemplatePlugin, "ExecutableNetwork::ExportImpl"); +// ! [executable_network:export] +void TemplatePlugin::ExecutableNetwork::Export(std::ostream& modelStream) { + OV_ITT_SCOPED_TASK(itt::domains::TemplatePlugin, "ExecutableNetwork::Export"); // Note: custom ngraph extensions are not supported std::map custom_opsets; @@ -198,4 +198,4 @@ void TemplatePlugin::ExecutableNetwork::ExportImpl(std::ostream& modelStream) { // TODO: implement network precision, layout, preprocessing info serialization } -// ! [executable_network:export_impl] +// ! [executable_network:export] diff --git a/docs/template_plugin/src/template_executable_network.hpp b/docs/template_plugin/src/template_executable_network.hpp index ca3bca11ba847f..a68df02f958934 100644 --- a/docs/template_plugin/src/template_executable_network.hpp +++ b/docs/template_plugin/src/template_executable_network.hpp @@ -30,7 +30,7 @@ class ExecutableNetwork : public InferenceEngine::ExecutableNetworkThreadSafeDef // Methods from a base class ExecutableNetworkThreadSafeDefault - void ExportImpl(std::ostream& model) override; + void Export(std::ostream& model) override; InferenceEngine::IInferRequestInternal::Ptr CreateInferRequestImpl(InferenceEngine::InputsDataMap networkInputs, InferenceEngine::OutputsDataMap networkOutputs) override; InferenceEngine::IInferRequestInternal::Ptr CreateInferRequest() override; diff --git a/docs/template_plugin/src/template_plugin.cpp b/docs/template_plugin/src/template_plugin.cpp index 87a509c8a77bee..a0f7a30ee171cf 100644 --- a/docs/template_plugin/src/template_plugin.cpp +++ b/docs/template_plugin/src/template_plugin.cpp @@ -95,14 +95,14 @@ InferenceEngine::IExecutableNetworkInternal::Ptr Plugin::LoadExeNetworkImpl(cons } // ! [plugin:load_exe_network_impl] -// ! [plugin:import_network_impl] -InferenceEngine::IExecutableNetworkInternal::Ptr Plugin::ImportNetworkImpl(std::istream& modelStream, const std::map& config) { - OV_ITT_SCOPED_TASK(itt::domains::TemplatePlugin, "Plugin::ImportNetworkImpl"); +// ! [plugin:import_network] +InferenceEngine::IExecutableNetworkInternal::Ptr Plugin::ImportNetwork(std::istream& modelStream, const std::map& config) { + OV_ITT_SCOPED_TASK(itt::domains::TemplatePlugin, "Plugin::ImportNetwork"); auto fullConfig = Configuration {config, _cfg}; return std::make_shared(modelStream, fullConfig, std::static_pointer_cast(shared_from_this())); } -// ! [plugin:import_network_impl] +// ! [plugin:import_network] // ! [plugin:query_network] InferenceEngine::QueryNetworkResult Plugin::QueryNetwork(const InferenceEngine::CNNNetwork& network, const ConfigMap& config) const { diff --git a/docs/template_plugin/src/template_plugin.hpp b/docs/template_plugin/src/template_plugin.hpp index ef2b506d497500..71c37410ea717e 100644 --- a/docs/template_plugin/src/template_plugin.hpp +++ b/docs/template_plugin/src/template_plugin.hpp @@ -28,7 +28,7 @@ class Plugin : public InferenceEngine::IInferencePlugin { void AddExtension(const std::shared_ptr& extension) override; InferenceEngine::Parameter GetConfig(const std::string& name, const std::map& options) const override; InferenceEngine::Parameter GetMetric(const std::string& name, const std::map& options) const override; - InferenceEngine::IExecutableNetworkInternal::Ptr ImportNetworkImpl(std::istream& model, const std::map& config) override; + InferenceEngine::IExecutableNetworkInternal::Ptr ImportNetwork(std::istream& model, const std::map& config) override; private: friend class ExecutableNetwork; diff --git a/inference-engine/include/ie_core.hpp b/inference-engine/include/ie_core.hpp index e87f8c65719085..96f8d6b58af0e0 100644 --- a/inference-engine/include/ie_core.hpp +++ b/inference-engine/include/ie_core.hpp @@ -174,9 +174,18 @@ class INFERENCE_ENGINE_API_CLASS(Core) { * operation* * @return An executable network reference */ - ExecutableNetwork ImportNetwork(std::istream& networkModel, const std::string& deviceName = {}, + ExecutableNetwork ImportNetwork(std::istream& networkModel, const std::string& deviceName, const std::map& config = {}); + /** + * @deprecated Use Core::ImportNetwork with explicit device name + * @brief Creates an executable network from a previously exported network + * @param networkModel network model stream + * @return An executable network reference + */ + INFERENCE_ENGINE_DEPRECATED("Use Core::ImportNetwork with explicit device name") + ExecutableNetwork ImportNetwork(std::istream& networkModel); + /** * @brief Creates an executable network from a previously exported network within a specified * remote context. diff --git a/inference-engine/src/hetero_plugin/hetero_executable_network.cpp b/inference-engine/src/hetero_plugin/hetero_executable_network.cpp index 58fb35111affab..9f0135aa25e357 100644 --- a/inference-engine/src/hetero_plugin/hetero_executable_network.cpp +++ b/inference-engine/src/hetero_plugin/hetero_executable_network.cpp @@ -550,7 +550,7 @@ HeteroExecutableNetwork::HeteroExecutableNetwork(std::istream& this->SetPointerToPlugin(_heteroPlugin->shared_from_this()); } -void HeteroExecutableNetwork::ExportImpl(std::ostream& heteroModel) { +void HeteroExecutableNetwork::Export(std::ostream& heteroModel) { pugi::xml_document doc; auto heteroNode = doc.append_child("hetero"); heteroNode.append_attribute("name").set_value(_name.c_str()); diff --git a/inference-engine/src/hetero_plugin/hetero_executable_network.hpp b/inference-engine/src/hetero_plugin/hetero_executable_network.hpp index 85fc8d9c19c9cd..59574ca2ce7a5f 100644 --- a/inference-engine/src/hetero_plugin/hetero_executable_network.hpp +++ b/inference-engine/src/hetero_plugin/hetero_executable_network.hpp @@ -56,7 +56,7 @@ class HeteroExecutableNetwork : public InferenceEngine::ExecutableNetworkThreadS InferenceEngine::Parameter GetMetric(const std::string &name) const override; - void ExportImpl(std::ostream& modelFile) override; + void Export(std::ostream& modelFile) override; private: void InitCNNImpl(const InferenceEngine::CNNNetwork& network); diff --git a/inference-engine/src/hetero_plugin/hetero_plugin.cpp b/inference-engine/src/hetero_plugin/hetero_plugin.cpp index 1d8647716af8bf..09986b1e48eca8 100644 --- a/inference-engine/src/hetero_plugin/hetero_plugin.cpp +++ b/inference-engine/src/hetero_plugin/hetero_plugin.cpp @@ -57,13 +57,8 @@ InferenceEngine::IExecutableNetworkInternal::Ptr Engine::LoadExeNetworkImpl(cons return std::make_shared(network, mergeConfigs(_config, config), this); } -InferenceEngine::IExecutableNetworkInternal::Ptr Engine::ImportNetworkImpl(std::istream& heteroModel, const Configs& config) { - if (GetCore() == nullptr) { - IE_THROW() << "Please, work with HETERO device via InferencEngine::Core object"; - } - - return std::make_shared(heteroModel, - mergeConfigs(_config, config), this); +InferenceEngine::IExecutableNetworkInternal::Ptr Engine::ImportNetwork(std::istream& heteroModel, const std::map& config) { + return std::make_shared(heteroModel, mergeConfigs(_config, config), this); } Engine::Configs Engine::GetSupportedConfig(const Engine::Configs& config, const std::string & deviceName) const { diff --git a/inference-engine/src/hetero_plugin/hetero_plugin.hpp b/inference-engine/src/hetero_plugin/hetero_plugin.hpp index 2b5a93b829b254..fbc602116d109e 100644 --- a/inference-engine/src/hetero_plugin/hetero_plugin.hpp +++ b/inference-engine/src/hetero_plugin/hetero_plugin.hpp @@ -37,10 +37,11 @@ class Engine : public InferenceEngine::IInferencePlugin { InferenceEngine::Parameter GetConfig(const std::string& name, const std::map & options) const override; - InferenceEngine::IExecutableNetworkInternal::Ptr ImportNetworkImpl(std::istream& heteroModel, const Configs& config) override; + InferenceEngine::IExecutableNetworkInternal::Ptr + ImportNetwork(std::istream& heteroModel, const std::map& config) override; DeviceMetaInformationMap GetDevicePlugins(const std::string& targetFallback, - const Configs & localConfig) const; + const Configs & localConfig) const; private: Configs GetSupportedConfig(const Configs& config, const std::string & deviceName) const; diff --git a/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_iexecutable_network_internal.cpp b/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_iexecutable_network_internal.cpp index bf3086551c15fa..6b5bb34c97074e 100644 --- a/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_iexecutable_network_internal.cpp +++ b/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_iexecutable_network_internal.cpp @@ -49,19 +49,17 @@ std::shared_ptr IExecutableNetworkInternal::CreateInferRe } void IExecutableNetworkInternal::Export(const std::string& modelFileName) { - // we need to write to stringstream first - // because in case of exception in ExportImpl the file is not created - std::stringstream strm; - ExportImpl(strm); - std::ofstream(modelFileName.c_str()) << strm.rdbuf(); + std::ofstream modelFile(modelFileName, std::ios::out | std::ios::binary); + + if (modelFile.is_open()) { + Export(modelFile); + } else { + IE_THROW() << "The " << modelFileName << " file can not be opened for Export"; + } } void IExecutableNetworkInternal::Export(std::ostream& networkModel) { - std::stringstream strm; - strm.write(exportMagic.data(), exportMagic.size()); - strm << _plugin->GetName() << std::endl; - ExportImpl(strm); - networkModel << strm.rdbuf(); + IE_THROW(NotImplemented); } CNNNetwork IExecutableNetworkInternal::GetExecGraphInfo() { @@ -97,7 +95,4 @@ std::shared_ptr IExecutableNetworkInternal::CreateInferRe IE_THROW(NotImplemented); } -void IExecutableNetworkInternal::ExportImpl(std::ostream&) { - IE_THROW(NotImplemented); -} } // namespace InferenceEngine diff --git a/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_iplugin_internal.cpp b/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_iplugin_internal.cpp index 5637701754e3f5..88599aa78b37d2 100644 --- a/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_iplugin_internal.cpp +++ b/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_iplugin_internal.cpp @@ -16,24 +16,12 @@ #include #include +#include #include #include #include namespace InferenceEngine { -namespace { -void parsePluginName(std::istream& networkModel) { - ExportMagic magic = {}; - auto currentPos = networkModel.tellg(); - networkModel.read(magic.data(), magic.size()); - auto exportedWithName = (exportMagic == magic); - if (exportedWithName) { - networkModel.ignore(std::numeric_limits::max(), '\n'); - } else { - networkModel.seekg(currentPos, networkModel.beg); - } -} -} // namespace PreProcessInfo copyPreProcess(const PreProcessInfo& from) { PreProcessInfo to = from; @@ -170,22 +158,26 @@ RemoteContext::Ptr IInferencePlugin::GetDefaultContext(const ParamMap&) { IE_THROW(NotImplemented); } -std::shared_ptr IInferencePlugin::ImportNetwork(const std::string&, - const std::map&) { - IE_THROW(NotImplemented); +std::shared_ptr IInferencePlugin::ImportNetwork(const std::string& modelFileName, + const std::map& config) { + std::ifstream blobFile(modelFileName, std::ios::binary); + + if (!blobFile.is_open()) { + IE_THROW(NetworkNotRead); + } + + return ImportNetwork(blobFile, config); } std::shared_ptr IInferencePlugin::ImportNetwork(std::istream& networkModel, const std::map& config) { - parsePluginName(networkModel); - return ImportNetworkImpl(networkModel, config); + IE_THROW(NotImplemented); } std::shared_ptr IInferencePlugin::ImportNetwork(std::istream& networkModel, const std::shared_ptr& context, const std::map& config) { - parsePluginName(networkModel); - return ImportNetworkImpl(networkModel, context, config); + IE_THROW(NotImplemented); } void IInferencePlugin::SetCore(ICore* core) { @@ -213,17 +205,6 @@ std::shared_ptr IInferencePlugin::LoadExeNetworkImpl IE_THROW(NotImplemented); } -std::shared_ptr IInferencePlugin::ImportNetworkImpl(std::istream&, - const std::map&) { - IE_THROW(NotImplemented); -} - -std::shared_ptr IInferencePlugin::ImportNetworkImpl(std::istream&, - const std::shared_ptr&, - const std::map&) { - IE_THROW(NotImplemented); -} - void IInferencePlugin::SetExeNetworkInfo(const std::shared_ptr& exeNetwork, const ConstInputsDataMap& inputs, const ConstOutputsDataMap& outputs) { diff --git a/inference-engine/src/inference_engine/ie_core.cpp b/inference-engine/src/inference_engine/ie_core.cpp index 28563a29b62d30..63814215037f16 100644 --- a/inference-engine/src/inference_engine/ie_core.cpp +++ b/inference-engine/src/inference_engine/ie_core.cpp @@ -395,6 +395,7 @@ class Core::Impl : public ICore { opsetNames.insert("opset4"); opsetNames.insert("opset5"); opsetNames.insert("opset6"); + opsetNames.insert("opset7"); } ~Impl() override = default; @@ -566,18 +567,6 @@ class Core::Impl : public ICore { SoExecutableNetworkInternal ImportNetwork(std::istream& networkModel, const std::string& deviceName, const std::map& config) override { auto parsed = parseDeviceNameIntoConfig(deviceName, config); - - if (parsed._deviceName.empty()) { - ExportMagic magic = {}; - auto currentPos = networkModel.tellg(); - networkModel.read(magic.data(), magic.size()); - auto exportedWithName = (exportMagic == magic); - if (exportedWithName) { - std::getline(networkModel, parsed._deviceName); - } - networkModel.seekg(currentPos, networkModel.beg); - } - return GetCPPPluginByName(parsed._deviceName).ImportNetwork(networkModel, parsed._config); } @@ -1022,18 +1011,6 @@ void Core::AddExtension(const IExtensionPtr& extension) { ExecutableNetwork Core::ImportNetwork(const std::string& modelFileName, const std::string& deviceName, const std::map& config) { OV_ITT_SCOPED_TASK(itt::domains::IE, "Core::ImportNetwork"); - - // TODO: remove once NotImplemented exception is deprecated and not used - if (deviceName.find("HETERO") == 0) { - IE_THROW() << "HETERO device does not support ImportNetwork"; - } - if (deviceName.find("MULTI") == 0) { - IE_THROW() << "MULTI device does not support ImportNetwork"; - } - if (deviceName.find("AUTO") == 0) { - IE_THROW() << "AUTO device does not support ImportNetwork"; - } - auto parsed = parseDeviceNameIntoConfig(deviceName, config); auto exec = _impl->GetCPPPluginByName(parsed._deviceName).ImportNetwork(modelFileName, parsed._config); return { exec, exec }; @@ -1041,10 +1018,33 @@ ExecutableNetwork Core::ImportNetwork(const std::string& modelFileName, const st ExecutableNetwork Core::ImportNetwork(std::istream& networkModel, const std::string& deviceName, const std::map& config) { + OV_ITT_SCOPED_TASK(itt::domains::IE, "Core::ImportNetwork"); auto exec = _impl->ImportNetwork(networkModel, deviceName, config); return { exec, exec }; } +ExecutableNetwork Core::ImportNetwork(std::istream& networkModel) { + OV_ITT_SCOPED_TASK(itt::domains::IE, "Core::ImportNetwork"); + + using ExportMagic = std::array; + constexpr static const ExportMagic exportMagic = {{0x1, 0xE, 0xE, 0x1}}; + + std::string deviceName; + ExportMagic magic = {}; + auto currentPos = networkModel.tellg(); + networkModel.read(magic.data(), magic.size()); + if (exportMagic == magic) { + std::getline(networkModel, deviceName); + } else { + IE_THROW() << "Passed compiled stream does not contain device name. " + "Please, provide device name manually"; + } + networkModel.seekg(currentPos, networkModel.beg); + + auto exec = _impl->GetCPPPluginByName(deviceName).ImportNetwork(networkModel, {}); + return { exec, exec }; +} + ExecutableNetwork Core::ImportNetwork(std::istream& networkModel, const RemoteContext::Ptr& context, const std::map& config) { @@ -1124,8 +1124,8 @@ Parameter Core::GetConfig(const std::string& deviceName, const std::string& name IE_THROW() << "You can only GetConfig of the AUTO itself (without devices). " "GetConfig is also possible for the individual devices before creating the AUTO on top."; - } - } + } + } auto parsed = parseDeviceNameIntoConfig(deviceName); diff --git a/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iexecutable_network_internal.hpp b/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iexecutable_network_internal.hpp index 589514103835c8..1f3eb681e4b897 100644 --- a/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iexecutable_network_internal.hpp +++ b/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iexecutable_network_internal.hpp @@ -140,14 +140,6 @@ class INFERENCE_ENGINE_API_CLASS(IExecutableNetworkInternal) : public std::enabl virtual std::shared_ptr CreateInferRequestImpl(InputsDataMap networkInputs, OutputsDataMap networkOutputs); - /** - * @brief Exports an internal hardware-dependent model to a stream. - * @note The function is called from IExecutableNetworkInternal::Export(std::ostream&), - * which performs common export first and calls this plugin-dependent implementation after. - * @param networkModel A stream to export network to. - */ - virtual void ExportImpl(std::ostream& networkModel); - InferenceEngine::InputsDataMap _networkInputs; //!< Holds information about network inputs info InferenceEngine::OutputsDataMap _networkOutputs; //!< Holds information about network outputs data diff --git a/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iplugin_internal.hpp b/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iplugin_internal.hpp index 22c2f7e1c08780..56e3e1cf5f7dc6 100644 --- a/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iplugin_internal.hpp +++ b/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iplugin_internal.hpp @@ -286,29 +286,12 @@ class INFERENCE_ENGINE_API_CLASS(IInferencePlugin) : public std::enable_shared_f const std::map& config); /** - * @brief Creates an executable network from an previously exported network - * @note The function is called from - * IInferencePlugin::ImportNetwork(std::istream&, const RemoteContext::Ptr&, const std::map&) - * performs common steps first and calls this plugin-dependent implementation after. - * @param networkModel Reference to network model output stream - * @param config A string -> string map of parameters - * @return An Executable network - */ - virtual std::shared_ptr ImportNetworkImpl(std::istream& networkModel, - const std::map& config); - - /** - * @brief Imports network wit RemoteContext - * @param networkModel Reference to network model output stream - * @param context - a pointer to plugin context derived from RemoteContext class used to - * execute the network - * @param config A string -> string map of parameters - * @return An Executable network + * @brief Set input and output information to executable network. This method is used to + * set addtional information to InferenceEngine::IExecutableNetworkInternal create by device plugin. + * @param exeNetwork An executable network object to set information to + * @param inputs An input information to set + * @param outputs An output information to set */ - virtual std::shared_ptr ImportNetworkImpl(std::istream& networkModel, - const std::shared_ptr& context, - const std::map& config); - void SetExeNetworkInfo(const std::shared_ptr& exeNetwork, const ConstInputsDataMap& inputs, const ConstOutputsDataMap& outputs); diff --git a/inference-engine/src/plugin_api/ie_icore.hpp b/inference-engine/src/plugin_api/ie_icore.hpp index 70d7aaff3a5e25..fb4ac0b3423ce6 100644 --- a/inference-engine/src/plugin_api/ie_icore.hpp +++ b/inference-engine/src/plugin_api/ie_icore.hpp @@ -141,18 +141,6 @@ class ICore { virtual ~ICore() = default; }; -/** - * @brief Type of magic value - * @ingroup ie_dev_api_plugin_api - */ -using ExportMagic = std::array; - -/** - * @brief Magic number used by ie core to identify exported network with plugin name - * @ingroup ie_dev_api_plugin_api - */ -constexpr static const ExportMagic exportMagic = {{0x1, 0xE, 0xE, 0x1}}; - /** * @private */ diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.h b/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.h index 8a6c42c4e97012..22824ee5ec1c47 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.h +++ b/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.h @@ -93,16 +93,6 @@ class ExecutableNetwork : public ie::ExecutableNetworkThreadSafeDefault { model.write(_graphBlob.data(), _graphBlob.size()); } - void Export(const std::string &modelFileName) override { - std::ofstream modelFile(modelFileName, std::ios::out | std::ios::binary); - - if (modelFile.is_open()) { - Export(modelFile); - } else { - IE_THROW() << "The " << modelFileName << " file can not be opened for export"; - } - } - ie::Parameter GetMetric(const std::string &name) const override; ie::CNNNetwork GetExecGraphInfo() override; diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_plugin.cpp b/inference-engine/src/vpu/myriad_plugin/myriad_plugin.cpp index f61b9fbf7fb9cb..75e7ef395d9266 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_plugin.cpp +++ b/inference-engine/src/vpu/myriad_plugin/myriad_plugin.cpp @@ -151,20 +151,6 @@ InferenceEngine::IExecutableNetworkInternal::Ptr Engine::ImportNetwork( return executableNetwork; } -InferenceEngine::IExecutableNetworkInternal::Ptr Engine::ImportNetwork( - const std::string& modelFileName, - const std::map& config) { - VPU_PROFILE(ImportNetwork); - - std::ifstream blobFile(modelFileName, std::ios::binary); - - if (!blobFile.is_open()) { - IE_THROW(NetworkNotRead); - } - - return ImportNetwork(blobFile, config); -} - InferenceEngine::Parameter Engine::GetMetric(const std::string& name, const std::map & options) const { const auto mvnc = _mvnc; diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_plugin.h b/inference-engine/src/vpu/myriad_plugin/myriad_plugin.h index 07349f637e27ad..9fb074b5ac174c 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_plugin.h +++ b/inference-engine/src/vpu/myriad_plugin/myriad_plugin.h @@ -37,10 +37,6 @@ class Engine : public ie::IInferencePlugin { using ie::IInferencePlugin::ImportNetwork; - ie::IExecutableNetworkInternal::Ptr ImportNetwork( - const std::string& modelFileName, - const std::map& config) override; - ie::IExecutableNetworkInternal::Ptr ImportNetwork( std::istream& model, const std::map& config) override; diff --git a/inference-engine/tests/functional/inference_engine/caching_test.cpp b/inference-engine/tests/functional/inference_engine/caching_test.cpp index dd19dd3815d70c..cad8bd4428e3ba 100644 --- a/inference-engine/tests/functional/inference_engine/caching_test.cpp +++ b/inference-engine/tests/functional/inference_engine/caching_test.cpp @@ -43,17 +43,18 @@ enum class TestLoadType { EContext, EModelName }; + using TestParam = std::tuple; // GCC4.8 limitation: have to specify type of each element in list static const std::vector loadVariants = { - TestParam { TestLoadType::ECNN, std::string("ByCNNNetwork"), false }, - TestParam { TestLoadType::EContext, std::string("ByRemoteContext"), true }, - TestParam { TestLoadType::EModelName, std::string("ByModelName"), false }, + TestParam { TestLoadType::ECNN, std::string("ByCNNNetwork"), false }, + TestParam { TestLoadType::EContext, std::string("ByRemoteContext"), true }, + TestParam { TestLoadType::EModelName, std::string("ByModelName"), false }, }; static const std::vector cacheFolders { - std::string("testCache"), + std::string("testCache"), }; std::string getTestCaseName(const testing::TestParamInfo> &obj) { @@ -100,12 +101,12 @@ class MockCachingInferencePlugin : public MockCachingInferencePluginBase { MOCK_CONST_METHOD0(OnLoadNetworkFromFile, void(void)); - MOCK_METHOD2(ImportNetworkImpl, std::shared_ptr(std::istream& networkModel, - const std::map& config)); + MOCK_METHOD2(ImportNetwork, IExecutableNetworkInternal::Ptr(std::istream& networkModel, + const std::map& config)); - MOCK_METHOD3(ImportNetworkImpl, std::shared_ptr(std::istream& networkModel, - const RemoteContext::Ptr& context, - const std::map& config)); + MOCK_METHOD3(ImportNetwork, IExecutableNetworkInternal::Ptr(std::istream& networkModel, + const RemoteContext::Ptr& context, + const std::map& config)); MOCK_CONST_METHOD2(QueryNetwork, QueryNetworkResult(const CNNNetwork& network, const std::map& config)); @@ -120,7 +121,7 @@ class MockExecutableNetwork : public IExecutableNetworkInternal { public: MockExecutableNetwork() {} - MOCK_METHOD1(ExportImpl, void(std::ostream& networkModel)); + MOCK_METHOD1(Export, void(std::ostream& networkModel)); MOCK_METHOD0(CreateInferRequest, IInferRequestInternal::Ptr()); MOCK_CONST_METHOD0(GetInputsInfo, ConstInputsDataMap()); MOCK_CONST_METHOD0(GetOutputsInfo, ConstOutputsDataMap()); @@ -130,10 +131,10 @@ class MockExecutableNetwork : public IExecutableNetworkInternal { MOCK_METHOD1(setNetworkInputs, void(const InputsDataMap& networkInputs)); MOCK_METHOD1(setNetworkOutputs, void(const OutputsDataMap& networkOutputs)); - void Export(std::ostream& networkModel) override { - std::lock_guard guard(m_pluginMutex); - IExecutableNetworkInternal::Export(networkModel); - } + // void Export(std::ostream& networkModel) override { + // std::lock_guard guard(m_pluginMutex); + // IExecutableNetworkInternal::Export(networkModel); + // } void SetPointerToPlugin(const IInferencePlugin::Ptr& plugin) override { std::lock_guard guard(m_pluginMutex); @@ -323,13 +324,13 @@ class CachingTest : public ::testing::TestWithParam &) { return createMockIExecutableNet(); })); - ON_CALL(plugin, ImportNetworkImpl(_, _)). + ON_CALL(plugin, ImportNetwork(_, _)). WillByDefault(Invoke([&](std::istream &istr, const std::map &) { return createMockIExecutableNet(); })); @@ -403,9 +404,9 @@ TEST_P(CachingTest, TestLoad) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); m_testFunction(ie); @@ -415,9 +416,9 @@ TEST_P(CachingTest, TestLoad) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*net, ExportImpl(_)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(m_remoteContext ? 1 : 0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(!m_remoteContext ? 1 : 0); + EXPECT_CALL(*net, Export(_)).Times(0); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); m_testFunction(ie); @@ -426,43 +427,43 @@ TEST_P(CachingTest, TestLoad) { } TEST_P(CachingTest, TestLoadCustomImportExport) { - const int customNumber = 1234; + const char customData[] = {1, 2, 3, 4, 5}; EXPECT_CALL(*mockPlugin, GetMetric(METRIC_KEY(SUPPORTED_METRICS), _)).Times(AnyNumber()); EXPECT_CALL(*mockPlugin, GetMetric(METRIC_KEY(IMPORT_EXPORT_SUPPORT), _)).Times(AnyNumber()); EXPECT_CALL(*mockPlugin, GetMetric(METRIC_KEY(DEVICE_ARCHITECTURE), _)).Times(AnyNumber()); - ON_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)). + ON_CALL(*mockPlugin, ImportNetwork(_, _, _)). WillByDefault(Invoke([&](std::istream& s, RemoteContext::Ptr, const std::map &) { - int a; - s >> a; - EXPECT_EQ(customNumber, a); + char a[sizeof(customData)]; + s.read(a, sizeof(customData)); + EXPECT_EQ(memcmp(a, customData, sizeof(customData)), 0); auto mock = std::make_shared(); EXPECT_CALL(*mock, GetInputsInfo()).Times(AnyNumber()).WillRepeatedly(Return(ConstInputsDataMap{})); EXPECT_CALL(*mock, GetOutputsInfo()).Times(AnyNumber()).WillRepeatedly(Return(ConstOutputsDataMap{})); return mock; })); - ON_CALL(*mockPlugin, ImportNetworkImpl(_, _)). + ON_CALL(*mockPlugin, ImportNetwork(_, _)). WillByDefault(Invoke([&](std::istream &s, const std::map &) { - int a; - s >> a; - EXPECT_EQ(customNumber, a); + char a[sizeof(customData)]; + s.read(a, sizeof(customData)); + EXPECT_EQ(memcmp(a, customData, sizeof(customData)), 0); auto mock = std::make_shared(); EXPECT_CALL(*mock, GetInputsInfo()).Times(AnyNumber()).WillRepeatedly(Return(ConstInputsDataMap{})); EXPECT_CALL(*mock, GetOutputsInfo()).Times(AnyNumber()).WillRepeatedly(Return(ConstOutputsDataMap{})); return mock; })); - ON_CALL(*net, ExportImpl(_)).WillByDefault(Invoke([&] (std::ostream& s) { - s << customNumber; + ON_CALL(*net, Export(_)).WillByDefault(Invoke([&] (std::ostream& s) { + s.write(customData, sizeof(customData)); })); { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); m_testFunction(ie); @@ -472,9 +473,9 @@ TEST_P(CachingTest, TestLoadCustomImportExport) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*net, ExportImpl(_)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(m_remoteContext ? 1 : 0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(!m_remoteContext ? 1 : 0); + EXPECT_CALL(*net, Export(_)).Times(0); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); m_testFunction(ie); @@ -497,9 +498,9 @@ TEST_P(CachingTest, TestChangeLoadConfig) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); m_testFunctionWithCfg(ie, {{CUSTOM_KEY, "0"}}); @@ -509,9 +510,9 @@ TEST_P(CachingTest, TestChangeLoadConfig) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); m_testFunctionWithCfg(ie, {{CUSTOM_KEY, "1"}}); @@ -526,9 +527,9 @@ TEST_P(CachingTest, TestNoCacheEnabled) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(0); testLoad([&](Core &ie) { m_testFunction(ie); }); @@ -544,9 +545,9 @@ TEST_P(CachingTest, TestNoCacheSupported) { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, OnLoadNetworkFromFile()).Times(m_type == TestLoadType::EModelName ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(0); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); m_testFunction(ie); @@ -563,9 +564,9 @@ TEST_P(CachingTest, TestNoCacheMetricSupported) { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, OnLoadNetworkFromFile()).Times(m_type == TestLoadType::EModelName ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(0); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); m_testFunction(ie); @@ -652,8 +653,8 @@ TEST_P(CachingTest, TestNoCacheEnabled_cacheDirConfig) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); testLoad([&](Core &ie) { m_testFunction(ie); }); @@ -667,9 +668,9 @@ TEST_P(CachingTest, TestLoadChangeCacheDir) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); m_testFunction(ie); @@ -681,9 +682,9 @@ TEST_P(CachingTest, TestLoadChangeCacheDir) { MkDirGuard dir(newCacheDir); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), newCacheDir}}); m_testFunction(ie); @@ -698,9 +699,9 @@ TEST_P(CachingTest, TestClearCacheDir) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(0); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); ie.SetConfig({{CONFIG_KEY(CACHE_DIR), ""}}); @@ -716,9 +717,9 @@ TEST_P(CachingTest, TestChangeOtherConfig) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); ie.SetConfig({{"someKey", "someValue"}}); @@ -735,9 +736,9 @@ TEST_P(CachingTest, TestChangeCacheDirFailure) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); m_testFunction(ie); @@ -747,9 +748,9 @@ TEST_P(CachingTest, TestChangeCacheDirFailure) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*net, ExportImpl(_)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(m_remoteContext ? 1 : 0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(!m_remoteContext ? 1 : 0); + EXPECT_CALL(*net, Export(_)).Times(0); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); EXPECT_ANY_THROW(ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir + "/" + longName}})); @@ -769,9 +770,9 @@ TEST_P(CachingTest, TestCacheDirCreateRecursive) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { EXPECT_NO_THROW(ie.SetConfig({{CONFIG_KEY(CACHE_DIR), newCacheDir3}})); EXPECT_NO_THROW(m_testFunction(ie)); @@ -797,9 +798,9 @@ TEST_P(CachingTest, TestDeviceArchitecture) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { deviceToLoad = "mock.0"; ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); @@ -810,9 +811,9 @@ TEST_P(CachingTest, TestDeviceArchitecture) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*net, ExportImpl(_)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(m_remoteContext ? 1 : 0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(!m_remoteContext ? 1 : 0); + EXPECT_CALL(*net, Export(_)).Times(0); testLoad([&](Core &ie) { deviceToLoad = "mock.1"; ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); @@ -822,9 +823,9 @@ TEST_P(CachingTest, TestDeviceArchitecture) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { deviceToLoad = "mock.50"; ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); @@ -835,9 +836,9 @@ TEST_P(CachingTest, TestDeviceArchitecture) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*net, ExportImpl(_)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(m_remoteContext ? 1 : 0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(!m_remoteContext ? 1 : 0); + EXPECT_CALL(*net, Export(_)).Times(0); testLoad([&](Core &ie) { deviceToLoad = "mock.51"; ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); @@ -856,9 +857,9 @@ TEST_P(CachingTest, TestNoDeviceArchitecture) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { deviceToLoad = "mock.0"; ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); @@ -869,9 +870,9 @@ TEST_P(CachingTest, TestNoDeviceArchitecture) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*net, ExportImpl(_)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(m_remoteContext ? 1 : 0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(!m_remoteContext ? 1 : 0); + EXPECT_CALL(*net, Export(_)).Times(0); testLoad([&](Core &ie) { deviceToLoad = "mock.50"; ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); @@ -887,9 +888,9 @@ TEST_P(CachingTest, TestThrowOnExport) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1).WillOnce(Throw(1)); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1).WillOnce(Throw(1)); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); EXPECT_ANY_THROW(m_testFunction(ie)); @@ -906,9 +907,9 @@ TEST_P(CachingTest, TestThrowOnImport) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); m_testFunction(ie); @@ -918,13 +919,13 @@ TEST_P(CachingTest, TestThrowOnImport) { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); if (m_remoteContext) { - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(1).WillOnce(Throw(1)); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(1).WillOnce(Throw(1)); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); } else { - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(1).WillOnce(Throw(1)); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(1).WillOnce(Throw(1)); } - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); EXPECT_NO_THROW(m_testFunction(ie)); @@ -933,9 +934,9 @@ TEST_P(CachingTest, TestThrowOnImport) { { // Step 3: same load, cache is re-created on export on step 2 and shall be successfully imported now EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*net, ExportImpl(_)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(m_remoteContext ? 1 : 0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(!m_remoteContext ? 1 : 0); + EXPECT_CALL(*net, Export(_)).Times(0); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); EXPECT_NO_THROW(m_testFunction(ie)); @@ -951,9 +952,9 @@ TEST_P(CachingTest, TestNetworkModified) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { EXPECT_NO_THROW(ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}})); EXPECT_NO_THROW(m_testFunction(ie)); @@ -974,9 +975,9 @@ TEST_P(CachingTest, TestNetworkModified) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { EXPECT_NO_THROW(ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}})); EXPECT_NO_THROW(m_testFunction(ie)); @@ -985,9 +986,9 @@ TEST_P(CachingTest, TestNetworkModified) { { // Step 3: same load, should be ok now EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*net, ExportImpl(_)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(m_remoteContext ? 1 : 0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(!m_remoteContext ? 1 : 0); + EXPECT_CALL(*net, Export(_)).Times(0); testLoad([&](Core &ie) { EXPECT_NO_THROW(ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}})); EXPECT_NO_THROW(m_testFunction(ie)); @@ -1003,9 +1004,9 @@ TEST_P(CachingTest, TestCacheFileCorrupted) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { EXPECT_NO_THROW(ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}})); EXPECT_NO_THROW(m_testFunction(ie)); @@ -1021,9 +1022,9 @@ TEST_P(CachingTest, TestCacheFileCorrupted) { { // Step 2. Cache is corrupted, will be silently removed EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { EXPECT_NO_THROW(ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}})); EXPECT_NO_THROW(m_testFunction(ie)); @@ -1032,9 +1033,9 @@ TEST_P(CachingTest, TestCacheFileCorrupted) { { // Step 3: same load, should be ok now due to re-creation of cache EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*net, ExportImpl(_)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(m_remoteContext ? 1 : 0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(!m_remoteContext ? 1 : 0); + EXPECT_CALL(*net, Export(_)).Times(0); testLoad([&](Core &ie) { EXPECT_NO_THROW(ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}})); EXPECT_NO_THROW(m_testFunction(ie)); @@ -1050,9 +1051,9 @@ TEST_P(CachingTest, TestCacheFileOldVersion) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { EXPECT_NO_THROW(ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}})); EXPECT_NO_THROW(m_testFunction(ie)); @@ -1083,9 +1084,9 @@ TEST_P(CachingTest, TestCacheFileOldVersion) { { // Step 2. Build number mismatch, cache will be silently removed EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { EXPECT_NO_THROW(ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}})); EXPECT_NO_THROW(m_testFunction(ie)); @@ -1094,9 +1095,9 @@ TEST_P(CachingTest, TestCacheFileOldVersion) { { // Step 3: same load, should be ok now due to re-creation of cache EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0); - EXPECT_CALL(*net, ExportImpl(_)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(m_remoteContext ? 1 : 0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(!m_remoteContext ? 1 : 0); + EXPECT_CALL(*net, Export(_)).Times(0); testLoad([&](Core &ie) { EXPECT_NO_THROW(ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}})); EXPECT_NO_THROW(m_testFunction(ie)); @@ -1118,9 +1119,9 @@ TEST_P(CachingTest, LoadHetero_NoCacheMetric) { for (int i = 0; i < 2; i++) { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(1); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(0); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); m_testFunction(ie); @@ -1138,9 +1139,9 @@ TEST_P(CachingTest, LoadHetero_OneDevice) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(1); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); m_testFunction(ie); @@ -1152,9 +1153,9 @@ TEST_P(CachingTest, LoadHetero_OneDevice) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(1); - EXPECT_CALL(*net, ExportImpl(_)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(1); + EXPECT_CALL(*net, Export(_)).Times(0); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); m_testFunction(ie); @@ -1172,9 +1173,9 @@ TEST_P(CachingTest, LoadHetero_TargetFallbackFromCore) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(1); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); ie.SetConfig({{"TARGET_FALLBACK", "mock"}}, CommonTestUtils::DEVICE_HETERO); @@ -1187,9 +1188,9 @@ TEST_P(CachingTest, LoadHetero_TargetFallbackFromCore) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(1); - EXPECT_CALL(*net, ExportImpl(_)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(1); + EXPECT_CALL(*net, Export(_)).Times(0); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); ie.SetConfig({{"TARGET_FALLBACK", "mock"}}, CommonTestUtils::DEVICE_HETERO); @@ -1200,20 +1201,20 @@ TEST_P(CachingTest, LoadHetero_TargetFallbackFromCore) { TEST_P(CachingTest, LoadHetero_MultiArchs) { EXPECT_CALL(*mockPlugin, GetMetric(_, _)).Times(AnyNumber()); - int customNumber = 1234; - ON_CALL(*mockPlugin, ImportNetworkImpl(_, _)). + const char customData[] = {1, 2, 3, 4, 5}; + ON_CALL(*mockPlugin, ImportNetwork(_, _)). WillByDefault(Invoke([&](std::istream &s, const std::map &) { - int a; - s >> a; - EXPECT_EQ(customNumber, a); + char a[sizeof(customData)]; + s.read(a, sizeof(customData)); + EXPECT_EQ(memcmp(a, customData, sizeof(customData)), 0); auto mock = std::make_shared(); EXPECT_CALL(*mock, GetInputsInfo()).Times(AnyNumber()).WillRepeatedly(Return(ConstInputsDataMap{})); EXPECT_CALL(*mock, GetOutputsInfo()).Times(AnyNumber()).WillRepeatedly(Return(ConstOutputsDataMap{})); return mock; })); - ON_CALL(*net, ExportImpl(_)).WillByDefault(Invoke([&] (std::ostream& s) { - s << customNumber; + ON_CALL(*net, Export(_)).WillByDefault(Invoke([&] (std::ostream& s) { + s.write(customData, sizeof(customData)); })); EXPECT_CALL(*mockPlugin, QueryNetwork(_, _)).Times(AnyNumber()).WillRepeatedly( Invoke([&](const CNNNetwork &network, const std::map &config) { @@ -1249,9 +1250,9 @@ TEST_P(CachingTest, LoadHetero_MultiArchs) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(AtLeast(2)); // for .1 and for .51 - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(AtLeast(2)); // for .1 and for .51 + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(AtLeast(2)); // for .1 and for .51 testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); m_testFunction(ie); @@ -1264,9 +1265,9 @@ TEST_P(CachingTest, LoadHetero_MultiArchs) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(AtLeast(2)); // for .2 and for .52 - EXPECT_CALL(*net, ExportImpl(_)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(AtLeast(2)); // for .2 and for .52 + EXPECT_CALL(*net, Export(_)).Times(0); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); m_testFunction(ie); @@ -1276,9 +1277,9 @@ TEST_P(CachingTest, LoadHetero_MultiArchs) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(AtLeast(1)); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(AtLeast(1)); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(AtLeast(1)); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); m_testFunction(ie); @@ -1305,9 +1306,9 @@ TEST_P(CachingTest, LoadHetero_MultiArchs_TargetFallback_FromCore) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(1); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); ie.SetConfig({{"TARGET_FALLBACK", "mock.1"}}, CommonTestUtils::DEVICE_HETERO); @@ -1318,9 +1319,9 @@ TEST_P(CachingTest, LoadHetero_MultiArchs_TargetFallback_FromCore) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(1); - EXPECT_CALL(*net, ExportImpl(_)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(1); + EXPECT_CALL(*net, Export(_)).Times(0); testLoad([&](Core &ie) { ie.SetConfig({{"TARGET_FALLBACK", "mock.1"}}, CommonTestUtils::DEVICE_HETERO); ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); @@ -1330,9 +1331,9 @@ TEST_P(CachingTest, LoadHetero_MultiArchs_TargetFallback_FromCore) { { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(1); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { ie.SetConfig({{"TARGET_FALLBACK", "mock.51"}}, CommonTestUtils::DEVICE_HETERO); ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); @@ -1366,9 +1367,9 @@ TEST_P(CachingTest, LoadMulti_race) { EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(1); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(devCount - 1); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(devCount - 1); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), cacheDir}}); ASSERT_NO_THROW(m_testFunction(ie)); @@ -1394,9 +1395,9 @@ TEST_P(CachingTest, Load_threads) { MkDirGuard guard(cacheDir); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0); EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(1); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(THREADS_COUNT - 1); - EXPECT_CALL(*net, ExportImpl(_)).Times(1); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(THREADS_COUNT - 1); + EXPECT_CALL(*net, Export(_)).Times(1); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), cacheDir}}); std::vector threads; @@ -1443,12 +1444,12 @@ TEST_P(CachingTest, LoadMulti_Archs) { // Load network from file shall not be called for plugins with caching supported EXPECT_CALL(*mockPlugin, OnLoadNetworkFromFile()).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(TEST_DEVICE_MAX_COUNT - 2) + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(TEST_DEVICE_MAX_COUNT - 2) .WillRepeatedly(Invoke([&](std::istream &, const std::map &) { return createMockIExecutableNet(); })); - EXPECT_CALL(*net, ExportImpl(_)).Times(2); + EXPECT_CALL(*net, Export(_)).Times(2); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); ASSERT_NO_THROW(m_testFunction(ie)); @@ -1490,9 +1491,9 @@ TEST_P(CachingTest, LoadMulti_NoCachingOnDevice) { // Load network from file shall not be called by Multi plugin for devices with caching supported EXPECT_CALL(*mockPlugin, OnLoadNetworkFromFile()).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(0); - EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(0); - EXPECT_CALL(*net, ExportImpl(_)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _, _)).Times(0); + EXPECT_CALL(*mockPlugin, ImportNetwork(_, _)).Times(0); + EXPECT_CALL(*net, Export(_)).Times(0); testLoad([&](Core &ie) { ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}}); ExecutableNetwork exeNet; diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp index f013e544074644..3d4678bf5892b4 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp @@ -71,6 +71,8 @@ std::vector disabledTestPatterns() { R"(.*smoke_SetBlobOfKindAUTO.*SetBlobOfKindTest.CompareWithRefs.*)", // reference doesn't cover I8, U8 cases. Issue: 55842 R"(.*Gather7LayerTest.*netPRC=I8.*)", + // need to implement Export / Import + R"(.*IEClassImportExportTestP.*)" }; #ifdef __APPLE__ // TODO: Issue 55717 diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp index 02889dd8ddef85..07bd2a260984aa 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp @@ -57,5 +57,7 @@ std::vector disabledTestPatterns() { R"(.*LSTMSequence.*CompareWithRefs.*mode=CONVERT_TO_TI_RAND_SEQ_LEN_PARAM_seq.*direction=bidirectional_clip=0.7_netPRC=FP32.*)", // TODO: Issue: 54194 R"(.*ActivationLayerTest.*SoftPlus.*)", + // need to implement Export / Import + R"(.*IEClassImportExportTestP.*)" }; } diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/core_integration.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/core_integration.cpp index 8edb52954a8295..2eaa15ec86612f 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/core_integration.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/core_integration.cpp @@ -38,36 +38,7 @@ INSTANTIATE_TEST_CASE_P( // IEClassNetworkTestP tests, customized to add SKIP_IF_CURRENT_TEST_IS_DISABLED() // -using IEClassNetworkTestP_VPU = IEClassNetworkTestP; - -TEST_P(IEClassNetworkTestP_VPU, smoke_ImportNetworkNoThrowWithDeviceName) { - SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; - std::stringstream strm; - ExecutableNetwork executableNetwork; - ASSERT_NO_THROW(executableNetwork = ie.LoadNetwork(actualNetwork, deviceName)); - ASSERT_NO_THROW(executableNetwork.Export(strm)); - ASSERT_NO_THROW(executableNetwork = ie.ImportNetwork(strm, deviceName)); - ASSERT_NO_THROW(executableNetwork.CreateInferRequest()); -} - -TEST_P(IEClassNetworkTestP_VPU, smoke_ExportUsingFileNameImportFromStreamNoThrowWithDeviceName) { - SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; - ExecutableNetwork executableNetwork; - std::string fileName{"ExportedNetwork"}; - { - ASSERT_NO_THROW(executableNetwork = ie.LoadNetwork(actualNetwork, deviceName)); - ASSERT_NO_THROW(executableNetwork.Export(fileName)); - } - { - std::ifstream strm(fileName); - ASSERT_NO_THROW(executableNetwork = ie.ImportNetwork(strm, deviceName)); - } - ASSERT_NO_THROW(executableNetwork.CreateInferRequest()); -} - -using IEClassNetworkTestP_VPU_GetMetric = IEClassNetworkTestP_VPU; +using IEClassNetworkTestP_VPU_GetMetric = IEClassNetworkTestP; TEST_P(IEClassNetworkTestP_VPU_GetMetric, smoke_OptimizationCapabilitiesReturnsFP16) { Core ie; @@ -86,13 +57,13 @@ INSTANTIATE_TEST_CASE_P( ::testing::ValuesIn(devices)); INSTANTIATE_TEST_CASE_P( - smoke_IEClassImportExportTestP, IEClassNetworkTestP_VPU, + smoke_IEClassImportExportTestP, IEClassImportExportTestP, ::testing::Values(std::string(CommonTestUtils::DEVICE_MYRIAD), "HETERO:" + std::string(CommonTestUtils::DEVICE_MYRIAD))); #if defined(ENABLE_MKL_DNN) && ENABLE_MKL_DNN INSTANTIATE_TEST_CASE_P( - smoke_IEClassImportExportTestP_HETERO_CPU, IEClassNetworkTestP_VPU, + smoke_IEClassImportExportTestP_HETERO_CPU, IEClassImportExportTestP, ::testing::Values("HETERO:" + std::string(CommonTestUtils::DEVICE_MYRIAD) + ",CPU")); #endif diff --git a/inference-engine/tests/functional/plugin/shared/include/behavior/core_integration.hpp b/inference-engine/tests/functional/plugin/shared/include/behavior/core_integration.hpp index 834db01006f008..adcd0e525b43bf 100644 --- a/inference-engine/tests/functional/plugin/shared/include/behavior/core_integration.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/behavior/core_integration.hpp @@ -61,6 +61,7 @@ namespace BehaviorTestsDefinitions { } \ } + class IEClassBasicTestP : public ::testing::Test, public WithParamInterface > { protected: std::string deviceName; @@ -424,7 +425,16 @@ TEST_P(IEClassBasicTestP, ImportNetworkThrows) { if (deviceName == CommonTestUtils::DEVICE_CPU || deviceName == CommonTestUtils::DEVICE_GPU) { - ASSERT_THROW(ie.ImportNetwork("model", deviceName), NotImplemented); + ASSERT_THROW(ie.ImportNetwork("model", deviceName), NetworkNotRead); + + const std::string modelName = "compiled_blob.blob"; + { + std::ofstream file(modelName); + file << "content"; + } + + EXPECT_THROW(ie.ImportNetwork(modelName, deviceName), NotImplemented); + ASSERT_EQ(0, std::remove(modelName.c_str())); } } @@ -432,13 +442,13 @@ TEST(IEClassBasicTest, smoke_ImportNetworkHeteroThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() Core ie; - ASSERT_THROW(ie.ImportNetwork("model", CommonTestUtils::DEVICE_HETERO), Exception); + ASSERT_THROW(ie.ImportNetwork("model", CommonTestUtils::DEVICE_HETERO), NetworkNotRead); } TEST(IEClassBasicTest, smoke_ImportNetworkMultiThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() InferenceEngine::Core ie; - ASSERT_THROW(ie.ImportNetwork("model", CommonTestUtils::DEVICE_MULTI), Exception); + ASSERT_THROW(ie.ImportNetwork("model", CommonTestUtils::DEVICE_MULTI), NetworkNotRead); } TEST_P(IEClassBasicTestP, ImportNetworkWithNullContextThrows) { @@ -474,19 +484,18 @@ TEST_P(IEClassNetworkTestP, LoadNetworkActualHeteroDevice2NoThrow) { // // ImportExportNetwork // -TEST_P(IEClassImportExportTestP, smoke_ImportNetworkNoThrowIfNoDeviceName) { + +TEST_P(IEClassImportExportTestP, smoke_ImportNetworkThrowsIfNoDeviceName) { SKIP_IF_CURRENT_TEST_IS_DISABLED() Core ie; std::stringstream strm; ExecutableNetwork executableNetwork; ASSERT_NO_THROW(executableNetwork = ie.LoadNetwork(actualNetwork, deviceName)); - SKIP_IF_NOT_IMPLEMENTED(executableNetwork.Export(strm)); - if (!strm.str().empty()) { - SKIP_IF_NOT_IMPLEMENTED(executableNetwork = ie.ImportNetwork(strm)); - } - if (executableNetwork) { - ASSERT_NO_THROW(executableNetwork.CreateInferRequest()); - } + ASSERT_NO_THROW(executableNetwork.Export(strm)); + + IE_SUPPRESS_DEPRECATED_START + ASSERT_THROW(executableNetwork = ie.ImportNetwork(strm), Exception); + IE_SUPPRESS_DEPRECATED_END } TEST_P(IEClassImportExportTestP, smoke_ImportNetworkNoThrowWithDeviceName) { @@ -495,11 +504,9 @@ TEST_P(IEClassImportExportTestP, smoke_ImportNetworkNoThrowWithDeviceName) { std::stringstream strm; ExecutableNetwork executableNetwork; ASSERT_NO_THROW(executableNetwork = ie.LoadNetwork(actualNetwork, deviceName)); - SKIP_IF_NOT_IMPLEMENTED(executableNetwork.Export(strm)); - SKIP_IF_NOT_IMPLEMENTED(executableNetwork = ie.ImportNetwork(strm, deviceName)); - if (executableNetwork) { - ASSERT_NO_THROW(executableNetwork.CreateInferRequest()); - } + ASSERT_NO_THROW(executableNetwork.Export(strm)); + ASSERT_NO_THROW(executableNetwork = ie.ImportNetwork(strm, deviceName)); + ASSERT_NO_THROW(executableNetwork.CreateInferRequest()); } TEST_P(IEClassImportExportTestP, smoke_ExportUsingFileNameImportFromStreamNoThrowWithDeviceName) { @@ -509,18 +516,16 @@ TEST_P(IEClassImportExportTestP, smoke_ExportUsingFileNameImportFromStreamNoThro std::string fileName{"ExportedNetwork"}; { ASSERT_NO_THROW(executableNetwork = ie.LoadNetwork(simpleNetwork, deviceName)); - SKIP_IF_NOT_IMPLEMENTED(executableNetwork.Export(fileName)); + ASSERT_NO_THROW(executableNetwork.Export(fileName)); } - if (CommonTestUtils::fileExists(fileName)) { + { { std::ifstream strm(fileName); - SKIP_IF_NOT_IMPLEMENTED(executableNetwork = ie.ImportNetwork(strm, deviceName)); + ASSERT_NO_THROW(executableNetwork = ie.ImportNetwork(strm, deviceName)); } ASSERT_EQ(0, remove(fileName.c_str())); } - if (executableNetwork) { - ASSERT_NO_THROW(executableNetwork.CreateInferRequest()); - } + ASSERT_NO_THROW(executableNetwork.CreateInferRequest()); } // diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp index 2a68e96c19e790..82e2ff61f335f1 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp @@ -32,11 +32,8 @@ class MockInferencePluginInternal : public InferenceEngine::IInferencePlugin { MOCK_METHOD1(AddExtension, void(InferenceEngine::IExtensionPtr ext_ptr)); MOCK_METHOD1(SetConfig, void(const std::map &)); - using InferenceEngine::IInferencePlugin::ImportNetwork; - - std::shared_ptr ImportNetworkImpl(std::istream& stream, - const std::map &) { - std::getline(stream, importedString); + std::shared_ptr + ImportNetwork(std::istream& stream, const std::map &) { return {}; } diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp index 4e221be90f7945..c1cc30a944b430 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp @@ -34,8 +34,4 @@ class MockIExecutableNetworkInternal : public IExecutableNetworkInternal { void WrapOstreamExport(std::ostream& networkModel) { IExecutableNetworkInternal::Export(networkModel); } - const std::string exportString = "MockExecutableNetworkInternal"; - void ExportImpl(std::ostream& networkModel) override { - networkModel << exportString << std::endl; - } }; diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp index cd2e7b95f469d8..4408614f61c907 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp @@ -70,8 +70,8 @@ MockPlugin::LoadExeNetworkImpl(const CNNNetwork& network, } std::shared_ptr -MockPlugin::ImportNetworkImpl(std::istream& networkModel, - const std::map& config) { +MockPlugin::ImportNetwork(std::istream& networkModel, + const std::map& config) { if (_target) { return _target->ImportNetwork(networkModel, config); } else { @@ -80,9 +80,9 @@ MockPlugin::ImportNetworkImpl(std::istream& networkModel, } std::shared_ptr -MockPlugin::ImportNetworkImpl(std::istream& networkModel, - const std::shared_ptr& context, - const std::map& config) { +MockPlugin::ImportNetwork(std::istream& networkModel, + const std::shared_ptr& context, + const std::map& config) { if (_target) { return _target->ImportNetwork(networkModel, context, config); } else { diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.hpp index c01a8a8d1750f0..c2654061abd1f8 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.hpp @@ -35,13 +35,13 @@ class MockPlugin : public InferenceEngine::IInferencePlugin { const std::map &config) override; std::shared_ptr - ImportNetworkImpl(std::istream& networkModel, + ImportNetwork(std::istream& networkModel, const std::map& config) override; std::shared_ptr - ImportNetworkImpl(std::istream& networkModel, - const std::shared_ptr& context, - const std::map& config) override; + ImportNetwork(std::istream& networkModel, + const std::shared_ptr& context, + const std::map& config) override; InferenceEngine::Parameter GetMetric(const std::string& name, const std::map& options) const override; diff --git a/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_plugin_test.cpp b/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_plugin_test.cpp index 0945510d7a00d0..2d26c7bd0e2a7f 100644 --- a/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_plugin_test.cpp +++ b/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_plugin_test.cpp @@ -149,29 +149,6 @@ TEST_F(InferenceEnginePluginInternalTest, failToSetNotAllocatedBlob) { } } -TEST_F(InferenceEnginePluginInternalTest, executableNetworkInternalExportsMagicAndName) { - std::stringstream strm; - ASSERT_NO_THROW(mockIExeNetworkInternal->WrapOstreamExport(strm)); - ExportMagic actualMagic = {}; - strm.read(actualMagic.data(), actualMagic.size()); - ASSERT_EQ(exportMagic, actualMagic); - std::string pluginName; - std::getline(strm, pluginName); - ASSERT_EQ(pluginId, pluginName); - std::string exportedString; - std::getline(strm, exportedString); - ASSERT_EQ(mockIExeNetworkInternal->exportString, exportedString); -} - -TEST_F(InferenceEnginePluginInternalTest, pluginInternalEraseMagicAndNameWhenImports) { - std::stringstream strm; - ASSERT_NO_THROW(mockIExeNetworkInternal->WrapOstreamExport(strm)); - ASSERT_NO_THROW(mock_plugin_impl->ImportNetwork(strm, {})); - ASSERT_EQ(mockIExeNetworkInternal->exportString, mock_plugin_impl->importedString); - mock_plugin_impl->importedString = {}; -} - - TEST(InferencePluginTests, throwsOnUninitializedGetVersion) { InferencePlugin plg; ASSERT_THROW(plg.GetVersion(), Exception); From cbd48cf15f7c5c0d1779a5e2c492007af318f888 Mon Sep 17 00:00:00 2001 From: Nikolay Shchegolev Date: Wed, 9 Jun 2021 10:12:58 +0300 Subject: [PATCH 041/178] [CPU] Statically found issues on Windows. (#6075) --- .../src/mkldnn_plugin/nodes/mkldnn_convert_node.cpp | 2 ++ .../src/mkldnn_plugin/nodes/mkldnn_depth_to_space_node.cpp | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_convert_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_convert_node.cpp index d226dd73890ec6..678922f3a4b5b1 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_convert_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_convert_node.cpp @@ -42,6 +42,8 @@ MKLDNNConvertNode::MKLDNNConvertNode(const InferenceEngine::SizeVector &dims, co addOriginalInputPrecision(inPrc); outDims.emplace_back(dims); addOriginalOutputPrecision(outPrc); + + errorPrefix = "Convert node with name '" + getName() + "'"; } void MKLDNNConvertNode::getSupportedDescriptors() { diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_depth_to_space_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_depth_to_space_node.cpp index 2f97bbd2f85bda..38bebcd5271072 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_depth_to_space_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_depth_to_space_node.cpp @@ -58,6 +58,8 @@ MKLDNNDepthToSpaceNode::MKLDNNDepthToSpaceNode(const std::shared_ptr(std::pow(blockSize, nSpatialDims)); } else { IE_THROW(NotImplemented) << errorMessage; } @@ -74,14 +76,13 @@ void MKLDNNDepthToSpaceNode::getSupportedDescriptors() { if (srcDims.size() != dstDims.size()) THROW_ERROR << "has incorrect number of input/output dimensions"; - size_t nSpatialDims = srcDims.size() - 2; - blockStep = static_cast(std::pow(blockSize, nSpatialDims)); if (srcDims[1] % blockStep) THROW_ERROR << "has block_size parameter which is incompatible with input tensor channels dimension size"; if (srcDims[1] / blockStep != dstDims[1]) THROW_ERROR << "has incompatible input/output channels"; + size_t nSpatialDims = srcDims.size() - 2; for (size_t i = 0; i < nSpatialDims; ++i) { if (srcDims[i + 2] * blockSize != dstDims[i + 2]) THROW_ERROR << "has incompatible spatial dims"; From 421465adc15521f91f6ea9dbbbb9e0bbeb0ea933 Mon Sep 17 00:00:00 2001 From: iliya mironov Date: Wed, 9 Jun 2021 12:14:39 +0300 Subject: [PATCH 042/178] Add ShapeOfConstFolding transform (#5858) * Add ShapeOfConstFolding transform * Add unit tests * Update bom file * Update transform file * Hot fix * Fix midle replaser * Update unit tests * Fix get value * Refactoring Const Folding transformation. Move to back * Update bom file * Remove unuse code * Add some unit tests * Refactoring unit test * Hot fix --- model-optimizer/automation/package_BOM.txt | 1 + .../extensions/back/ShapeOfConstFolding.py | 29 +++ .../back/ShapeOfConstFolding_test.py | 170 ++++++++++++++++++ 3 files changed, 200 insertions(+) create mode 100644 model-optimizer/extensions/back/ShapeOfConstFolding.py create mode 100644 model-optimizer/unit_tests/extensions/back/ShapeOfConstFolding_test.py diff --git a/model-optimizer/automation/package_BOM.txt b/model-optimizer/automation/package_BOM.txt index be0dc1c37e0dd5..e7c779543cdda8 100644 --- a/model-optimizer/automation/package_BOM.txt +++ b/model-optimizer/automation/package_BOM.txt @@ -57,6 +57,7 @@ extensions/back/ReverseInputChannels.py extensions/back/RNNSequenceTypeRename.py extensions/back/ScalarConstNormalize.py extensions/back/SelectBroadcast.py +extensions/back/ShapeOfConstFolding.py extensions/back/ShuffleChannelPatternOptimization.py extensions/back/ShufflenetReLUReorder.py extensions/back/SpecialNodesFinalization.py diff --git a/model-optimizer/extensions/back/ShapeOfConstFolding.py b/model-optimizer/extensions/back/ShapeOfConstFolding.py new file mode 100644 index 00000000000000..b97b46fc35dd09 --- /dev/null +++ b/model-optimizer/extensions/back/ShapeOfConstFolding.py @@ -0,0 +1,29 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +from mo.back.replacement import BackReplacementPattern +from mo.graph.graph import Graph, rename_nodes +from mo.ops.const import Const + + +class ShapeOfConstFolding(BackReplacementPattern): + """ + The transformation folds ShapeOf(Const) -> Const + """ + enabled = True + + def run_after(self): + from extensions.back.MatMulNormalizer import SmartReshape_HC_Reshape_MatMul + return [SmartReshape_HC_Reshape_MatMul] + + def find_and_replace_pattern(self, graph: Graph): + for shapeof_node in graph.get_op_nodes(op='ShapeOf'): + in_node = shapeof_node.in_port(0).get_source().node + if in_node.op == 'Const': + shapeof_node.in_port(0).disconnect() + shape_name = shapeof_node.soft_get('name', shapeof_node.id) + shape_value = shapeof_node.out_port(0).data.get_value() + shape_const_node = Const(graph, {'name': shape_name + '/ExecutionConstValue', + 'value': shape_value}).create_node() + shapeof_node.out_port(0).get_connection().set_source(shape_const_node.out_port(0)) + rename_nodes([(shapeof_node, shape_name + '/TBD'), (shape_const_node, shape_name)]) diff --git a/model-optimizer/unit_tests/extensions/back/ShapeOfConstFolding_test.py b/model-optimizer/unit_tests/extensions/back/ShapeOfConstFolding_test.py new file mode 100644 index 00000000000000..562c1416342b04 --- /dev/null +++ b/model-optimizer/unit_tests/extensions/back/ShapeOfConstFolding_test.py @@ -0,0 +1,170 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import unittest + +import numpy as np + +from extensions.back.ShapeOfConstFolding import ShapeOfConstFolding +from mo.front.common.partial_infer.eltwise import eltwise_infer +from mo.front.common.partial_infer.utils import int64_array +from mo.utils.ir_engine.compare_graphs import compare_graphs +from unit_tests.utils.graph import build_graph + +const_value = np.random.rand(1, 3, 30, 30) +nodes_attributes = {'input': {'shape': int64_array([1, 3, 30, 30]), 'type': 'Parameter', 'kind': 'op', + 'op': 'Parameter'}, + 'input_data': {'value': None, 'shape': int64_array([1, 3, 30, 30]), 'kind': 'data'}, + 'const': {'type': 'Const', 'kind': 'op', 'op': 'Const', 'value': const_value}, + 'const_data': {'kind': 'data', 'value': const_value}, + 'shapeof_input': {'kind': 'op', 'op': 'ShapeOf', 'value': int64_array([1, 3, 30, 30])}, + 'shapeof_input_data': {'value': None, 'shape': None, 'kind': 'data', + 'value': int64_array([1, 3, 30, 30])}, + + 'shapeof_const': {'kind': 'op', 'op': 'ShapeOf', 'value': int64_array([1, 3, 30, 30])}, + 'shapeof_const_data': {'value': None, 'shape': None, 'kind': 'data', + 'value': int64_array([1, 3, 30, 30])}, + + 'mul': {'kind': 'op', 'op': 'Mul', 'infer': lambda node: eltwise_infer(node, lambda a, b: a * b)}, + 'mul_data': {'kind': 'data', 'value': np.array([1, 9, 900, 900])}, + 'last': {'kind': 'op', 'op': 'Result'}, + + # new nodes + 'new_const_shapeof': {'type': 'Const', 'kind': 'op', 'op': 'Const', + 'value': int64_array([1, 3, 30, 30])} + } + +const_value2 = np.random.rand(30, 30) +nodes_attributes2 = {'input': {'shape': int64_array([1, 3, 30, 30]), 'type': 'Parameter', 'kind': 'op', + 'op': 'Parameter'}, + 'input_data': {'value': None, 'shape': int64_array([1, 3, 30, 30]), 'kind': 'data'}, + + 'const': {'type': 'Const', 'kind': 'op', 'op': 'Const', 'value': const_value2}, + 'const_data': {'kind': 'data', 'value': const_value2}, + + 'shapeof_const': {'kind': 'op', 'op': 'ShapeOf', 'value': int64_array([2700, 30])}, + 'shapeof_const_data': {'value': int64_array([2700, 30]), 'shape': None, 'kind': 'data'}, + + 'gather': {'kind': 'op', 'op': 'Gather', 'batch_dims': 0}, + 'gather_data': {'kind': 'data'}, + + 'const_concat': {'type': 'Const', 'kind': 'op', 'op': 'Const', 'value': [1]}, + 'const_concat_data': {'kind': 'data', 'value': [1]}, + 'concat': {'kind': 'op', 'op': 'Concat'}, + 'concat_data': {'kind': 'data'}, + + 'reshape': {'kind': 'op', 'op': 'Reshape'}, + 'reshape_data': {'kind': 'data'}, + + 'matmul': {'kind': 'op', 'op': 'MatMul'}, + 'matmul_data': {'kind': 'data'}, + 'last': {'kind': 'op', 'op': 'Result'}, + + # new nodes + 'new_const_shapeof': {'type': 'Const', 'kind': 'op', 'op': 'Const', + 'value': int64_array([2700, 30])}, + } + + +class ShapeOfConstFoldingTests(unittest.TestCase): + def test_const_with_one_output(self): + graph = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'shapeof_input'), + ('shapeof_input', 'shapeof_input_data'), + ('shapeof_input_data', 'mul'), + ('const', 'const_data'), + ('const_data', 'shapeof_const'), + ('shapeof_const', 'shapeof_const_data'), + ('shapeof_const_data', 'mul'), + ('mul', 'mul_data'), + ('mul_data', 'last')], + { + 'input': {'shape': int64_array([1, 3, 30, 30])}, + 'input_data': {'shape': int64_array([1, 3, 30, 30])}, + 'shapeof_input': {'value': int64_array([1, 3, 30, 30])}, + 'shapeof_input_data': {'value': int64_array([1, 3, 30, 30])}, + 'const': {'value': const_value}, + 'const_data': {'value': const_value}, + 'shapeof_const': {'value': int64_array([1, 3, 30, 30])}, + 'shapeof_const_data': {'value': int64_array([1, 3, 30, 30])}, + 'mul_data': {'value': int64_array([1, 9, 900, 900])}, + }, + nodes_with_edges_only=True) + + graph_ref = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'shapeof_input'), + ('shapeof_input', 'shapeof_input_data'), + ('shapeof_input_data', 'mul'), + ('new_const_shapeof', 'shapeof_const_data'), + ('shapeof_const_data', 'mul'), + ('mul', 'mul_data'), + ('mul_data', 'last')], + { + 'input': {'shape': int64_array([1, 3, 30, 30])}, + 'input_data': {'shape': int64_array([1, 3, 30, 30])}, + 'shapeof_input': {'value': int64_array([1, 3, 30, 30])}, + 'shapeof_input_data': {'value': int64_array([1, 3, 30, 30])}, + 'new_const_shapeof': {'value': int64_array([1, 3, 30, 30])}, + 'shapeof_const_data': {'value': int64_array([1, 3, 30, 30])}, + 'mul_data': {'value': int64_array([1, 9, 900, 900])}, + }, + nodes_with_edges_only=True) + ShapeOfConstFolding().find_and_replace_pattern(graph) + (flag, resp) = compare_graphs(graph, graph_ref, 'last') + self.assertTrue(flag, resp) + + def test_const_with_two_outputs(self): + graph = build_graph(nodes_attributes2, + [('input', 'input_data'), + ('input_data', 'reshape'), + ('const', 'const_data'), + ('const_data', 'shapeof_const'), + ('shapeof_const', 'shapeof_const_data'), + ('shapeof_const_data', 'gather'), + ('gather', 'gather_data'), + ('const_concat', 'const_concat_data'), + ('const_concat_data', 'concat'), + ('gather_data', 'concat'), + ('concat', 'reshape'), + ('reshape', 'reshape_data'), + ('reshape_data', 'matmul'), + ('const_data', 'matmul'), + ('matmul', 'matmul_data'), + ('matmul_data', 'last') + ], + { + 'input': {'shape': int64_array([1, 3, 30, 30])}, + 'input_data': {'shape': int64_array([1, 3, 30, 30])}, + 'shapeof_const': {'value': int64_array([2700, 30])}, + 'shapeof_const_data': {'value': int64_array([2700, 30])}, + }, + nodes_with_edges_only=True) + + graph_ref = build_graph(nodes_attributes2, + [('input', 'input_data'), + ('input_data', 'reshape'), + ('new_const_shapeof', 'shapeof_const_data'), + ('shapeof_const_data', 'gather'), + ('gather', 'gather_data'), + ('const_concat', 'const_concat_data'), + ('const_concat_data', 'concat'), + ('gather_data', 'concat'), + ('concat', 'reshape'), + ('reshape', 'reshape_data'), + ('reshape_data', 'matmul'), + ('const', 'const_data'), + ('const_data', 'matmul'), + ('matmul', 'matmul_data'), + ('matmul_data', 'last')], + { + 'input': {'shape': int64_array([1, 3, 30, 30])}, + 'input_data': {'shape': int64_array([1, 3, 30, 30])}, + 'new_const_shapeof': {'value': int64_array([2700, 30])}, + 'shapeof_const_data': {'value': int64_array([2700, 30])}, + }, + nodes_with_edges_only=True) + ShapeOfConstFolding().find_and_replace_pattern(graph) + (flag, resp) = compare_graphs(graph, graph_ref, 'last') + self.assertTrue(flag, resp) From aa0c93300cc3ddd00e0cdcf0d10e1c57b16247cf Mon Sep 17 00:00:00 2001 From: Ivan Tikhonov Date: Wed, 9 Jun 2021 12:19:36 +0300 Subject: [PATCH 043/178] Update for Python API to create networks with Memory layers (#6079) * Update python API for Memory * Run unit tests on CPU only * add missed import * Update tests * fix py tests --- .../src/openvino/inference_engine/ie_api.pxd | 2 +- .../python/tests/test_InferRequest.py | 80 ++++++++++++++----- ngraph/python/src/pyngraph/function.cpp | 38 +++++++++ ngraph/python/tests/test_ngraph/test_basic.py | 22 +++++ 4 files changed, 122 insertions(+), 20 deletions(-) diff --git a/inference-engine/ie_bridges/python/src/openvino/inference_engine/ie_api.pxd b/inference-engine/ie_bridges/python/src/openvino/inference_engine/ie_api.pxd index 5d942f93050246..efb389259d36f8 100644 --- a/inference-engine/ie_bridges/python/src/openvino/inference_engine/ie_api.pxd +++ b/inference-engine/ie_bridges/python/src/openvino/inference_engine/ie_api.pxd @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 from .cimport ie_api_impl_defs as C -from .ie_api_impl_defs cimport CBlob, CTensorDesc, InputInfo, CPreProcessChannel, CPreProcessInfo, CExecutableNetwork +from .ie_api_impl_defs cimport CBlob, CTensorDesc, InputInfo, CPreProcessChannel, CPreProcessInfo, CExecutableNetwork, CVariableState import os diff --git a/inference-engine/ie_bridges/python/tests/test_InferRequest.py b/inference-engine/ie_bridges/python/tests/test_InferRequest.py index 6928944139d722..af79c0ff155bf8 100644 --- a/inference-engine/ie_bridges/python/tests/test_InferRequest.py +++ b/inference-engine/ie_bridges/python/tests/test_InferRequest.py @@ -16,6 +16,20 @@ path_to_img = image_path() +def create_function_with_memory(input_shape, data_type): + import ngraph as ng + from ngraph.impl import Function, Type + + input_data = ng.parameter(input_shape, name="input_data", dtype=data_type) + rv = ng.read_value(input_data, "var_id_667") + add = ng.add(rv, input_data, name="MemoryAdd") + node = ng.assign(add, "var_id_667") + res = ng.result(add, "res") + func = Function(results=[res], sinks=[node], parameters=[input_data], name="name") + caps = Function.to_capsule(func) + return caps + + def read_image(): import cv2 n, c, h, w = (1, 3, 32, 32) @@ -525,28 +539,56 @@ def test_resize_algorithm_work(device): assert np.allclose(res_1, res_2, atol=1e-2, rtol=1e-2) -# issue 56653 -@pytest.mark.skip(reason="Test will enable when nGraph Python API allows to create network with memory") -def test_query_state(device): - import ngraph as ng - from ngraph.impl import Function - input_data = ng.parameter([5, 7], name="input_data", dtype=np.float32) - rv = ng.read_value(input_data, "var_id_667") - #a = ng.add(rv, input_data) - node = ng.assign(rv, "var_id_667") - res = ng.result(rv, "res") - func = Function([res], sinks=[node], parameters=[input_data], name='test') - caps = Function.to_capsule(func) +@pytest.mark.parametrize("mode", ["set_init_memory_state", "reset_memory_state", "normal"]) +@pytest.mark.parametrize("data_type", ["FP32", "FP16", "I32"]) +@pytest.mark.parametrize("input_shape", [[10], [10, 10], [10, 10, 10], [2, 10, 10, 10]]) +@pytest.mark.skipif(os.environ.get("TEST_DEVICE", "CPU") != "CPU", + reason=f"Can't run test on device {os.environ.get('TEST_DEVICE', 'CPU')}, " + "Memory layers fully supported only on CPU") +def test_query_state_write_buffer(device, input_shape, data_type, mode): + ie_core = ie.IECore() + if device == "CPU": + if ie_core.get_metric(device, "FULL_DEVICE_NAME") == "arm_compute::NEON": + pytest.skip("Can't run on ARM plugin") - net = ie.IENetwork(caps) + layout = ["C", "HW", "CHW", "NCHW"] + np_data_type = {"FP32": np.float32, "FP16": np.float16, "I32": np.int32} + + from openvino.inference_engine import TensorDesc, Blob + + net = ie.IENetwork(create_function_with_memory(input_shape, np_data_type[data_type])) ie_core = ie.IECore() exec_net = ie_core.load_network(network=net, device_name=device, num_requests=1) request = exec_net.requests[0] mem_states = request.query_state() mem_state = mem_states[0] - with pytest.raises(ValueError) as e: - ones_arr = np.ones(shape=(1, 800), dtype=np.float32) - mem_state.state.buffer[:] = ones_arr - assert "assignment destination is read-only" in str(e.value) - assert mem_state.name == 'id_1' - assert mem_state.state.tensor_desc.precision == 'FP32' + + assert mem_state.name == 'var_id_667' + # todo: Uncomment after fix 45611, + # CPU plugin returns outputs and memory state in FP32 in case of FP16 original precision + #assert mem_state.state.tensor_desc.precision == data_type + + for i in range(1, 10): + if mode == "set_init_memory_state": + # create initial value + const_init = 5 + init_array = np.full(input_shape, const_init, dtype=np_data_type[mem_state.state.tensor_desc.precision]) + tensor_desc = TensorDesc(mem_state.state.tensor_desc.precision, input_shape, layout[len(input_shape) - 1]) + blob = Blob(tensor_desc, init_array) + mem_state.state = blob + + res = exec_net.infer({"input_data": np.full(input_shape, 1, dtype=np_data_type[data_type])}) + expected_res = np.full(input_shape, 1 + const_init, dtype=np_data_type[data_type]) + elif mode == "reset_memory_state": + # reset initial state of ReadValue to zero + mem_state.reset() + res = exec_net.infer({"input_data": np.full(input_shape, 1, dtype=np_data_type[data_type])}) + + # always ones + expected_res = np.full(input_shape, 1, dtype=np_data_type[data_type]) + else: + res = exec_net.infer({"input_data": np.full(input_shape, 1, dtype=np_data_type[data_type])}) + expected_res = np.full(input_shape, i, dtype=np_data_type[data_type]) + + assert np.allclose(res['MemoryAdd'], expected_res, atol=1e-6), \ + "Expected values: {} \n Actual values: {} \n".format(expected_res, res) diff --git a/ngraph/python/src/pyngraph/function.cpp b/ngraph/python/src/pyngraph/function.cpp index 6b60372a85aff2..ed84d9c458c0a4 100644 --- a/ngraph/python/src/pyngraph/function.cpp +++ b/ngraph/python/src/pyngraph/function.cpp @@ -7,6 +7,7 @@ #include "ngraph/function.hpp" // ngraph::Function #include "ngraph/op/parameter.hpp" // ngraph::op::Parameter +#include "ngraph/op/sink.hpp" #include "pyngraph/function.hpp" namespace py = pybind11; @@ -17,6 +18,42 @@ void regclass_pyngraph_Function(py::module m) { py::class_> function(m, "Function"); function.doc() = "ngraph.impl.Function wraps ngraph::Function"; + + function.def(py::init([](const ngraph::ResultVector& res, + const std::vector>& nodes, + const ngraph::ParameterVector& params, + const std::string& name) { + ngraph::SinkVector sinks; + for (const auto& node : nodes) + { + auto sink = std::dynamic_pointer_cast(node); + NGRAPH_CHECK(sink != nullptr, "Node {} is not instance of Sink"); + sinks.push_back(sink); + } + return std::make_shared(res, sinks, params, name); + }), + py::arg("results"), + py::arg("sinks"), + py::arg("parameters"), + py::arg("name"), + R"( + Create user-defined Function which is a representation of a model. + + Parameters + ---------- + results : List[op.Result] + List of results. + + sinks : List[Node] + List of Nodes to be used as Sinks (e.g. Assign ops). + + parameters : List[op.Parameter] + List of parameters. + + name : str + String to set as function's friendly name. + )"); + function.def(py::init>&, const std::vector>&, const std::string&>(), @@ -37,6 +74,7 @@ void regclass_pyngraph_Function(py::module m) name : str String to set as function's friendly name. )"); + function.def(py::init&, const std::vector>&, const std::string&>(), diff --git a/ngraph/python/tests/test_ngraph/test_basic.py b/ngraph/python/tests/test_ngraph/test_basic.py index 210bcb99ae0921..da6cf993d3f4f1 100644 --- a/ngraph/python/tests/test_ngraph/test_basic.py +++ b/ngraph/python/tests/test_ngraph/test_basic.py @@ -403,3 +403,25 @@ def test_mutiple_outputs(): output = computation(input_data) assert np.equal(output, expected_output).all() + + +def test_sink_function_ctor(): + input_data = ng.parameter([2, 2], name="input_data", dtype=np.float32) + rv = ng.read_value(input_data, "var_id_667") + add = ng.add(rv, input_data, name="MemoryAdd") + node = ng.assign(add, "var_id_667") + res = ng.result(add, "res") + function = Function(results=[res], sinks=[node], parameters=[input_data], name="TestFunction") + + ordered_ops = function.get_ordered_ops() + op_types = [op.get_type_name() for op in ordered_ops] + assert op_types == ["Parameter", "ReadValue", "Add", "Assign", "Result"] + assert len(function.get_ops()) == 5 + assert function.get_output_size() == 1 + assert function.get_output_op(0).get_type_name() == "Result" + assert function.get_output_element_type(0) == input_data.get_element_type() + assert list(function.get_output_shape(0)) == [2, 2] + assert (function.get_parameters()[0].get_partial_shape()) == PartialShape([2, 2]) + assert len(function.get_parameters()) == 1 + assert len(function.get_results()) == 1 + assert function.get_friendly_name() == "TestFunction" From 8c74a0a52c1cfa4a74fa2539e0ba4d91d80f6145 Mon Sep 17 00:00:00 2001 From: Ivan Novoselov Date: Wed, 9 Jun 2021 14:27:43 +0300 Subject: [PATCH 044/178] [CPU] Fixed reorder for strided both inputs and outputs (#6082) --- inference-engine/thirdparty/mkl-dnn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inference-engine/thirdparty/mkl-dnn b/inference-engine/thirdparty/mkl-dnn index 1cb9d0615aaf51..87516e47dae71f 160000 --- a/inference-engine/thirdparty/mkl-dnn +++ b/inference-engine/thirdparty/mkl-dnn @@ -1 +1 @@ -Subproject commit 1cb9d0615aaf511b51b8f8fc3c3ff8805ad9be6c +Subproject commit 87516e47dae71fc9c326d0f3685c1572c740e127 From 8dd914477c9a377e914de0318ea698ed01edfa3b Mon Sep 17 00:00:00 2001 From: Evgeny Talanin Date: Wed, 9 Jun 2021 15:06:21 +0300 Subject: [PATCH 045/178] Pin mypy dependency (#6098) --- ngraph/python/tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ngraph/python/tox.ini b/ngraph/python/tox.ini index e0ccc85785ef60..de7bb8337b284b 100644 --- a/ngraph/python/tox.ini +++ b/ngraph/python/tox.ini @@ -7,7 +7,7 @@ skip_install=True deps = -rrequirements.txt -rrequirements_test.txt - mypy + mypy<0.900 flake8-bugbear pytest-xdist setenv = From 3bc2c46693de0e5d14666068b069d00a196e0786 Mon Sep 17 00:00:00 2001 From: Daria Mityagina Date: Wed, 9 Jun 2021 16:27:52 +0300 Subject: [PATCH 046/178] [IE][VPU] Yolo_v5 support (#5976) Changing the threshold for VPU scales --- .../src/middleend/passes/weights_analysis.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/weights_analysis.cpp b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/weights_analysis.cpp index 213e06ee1f57c7..27e703ec4f53cc 100644 --- a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/weights_analysis.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/weights_analysis.cpp @@ -92,7 +92,7 @@ bool checkGrowingOutput(const Model& model) { return false; } - static const float SCALE_THRESHOLD = 0.125f; + static const float SCALE_THRESHOLD = 0.1f; for (const auto& stage : model->getStages()) { if (stage->type() != StageType::Power && @@ -248,14 +248,13 @@ void PassImpl::run(const Model& model) { if (firstStage && shift < 4 && isGrowingOutput && weights->desc().dim(Dim::C) > 1) { normalVal = 5; } - shift = correctShift(shift, firstStage, stage->origLayer()->type); shift -= normalVal; } firstStage = false; scale = 1; - if (shift > scaleThreshold) { + if (shift >= scaleThreshold) { scale = static_cast(1ULL << static_cast(shift)); } From 6a5b6b8b30165c71cdb1eb160136ce429c0332f3 Mon Sep 17 00:00:00 2001 From: Anton Chetverikov Date: Wed, 9 Jun 2021 17:26:52 +0300 Subject: [PATCH 047/178] Add transformation to normalize negative indices in Gather (#6028) * Add transformation to normalize negative indices in Gather * Update transformation name and add constant indices input to the pattern * Apply comments * Fix copyright year * Add more tests * Update type logic * Add test with different types and update old ones * Update pattern and logic to check only axis dimension is static, add appropriate tests * Fix cdestyle * Add axis normalization * Fix wrong value in gather input * Add related tests * Add axis_constant to check * Remove ngraph_check --- .../gather_normalize_negative_indices.hpp | 29 ++ .../common_optimizations.cpp | 2 + .../gather_normalize_negative_indices.cpp | 77 +++++ ...gather_normalize_negative_indices_test.cpp | 306 ++++++++++++++++++ 4 files changed, 414 insertions(+) create mode 100644 inference-engine/src/transformations/include/transformations/op_conversions/gather_normalize_negative_indices.hpp create mode 100644 inference-engine/src/transformations/src/transformations/op_conversions/gather_normalize_negative_indices.cpp create mode 100644 inference-engine/tests/functional/inference_engine/transformations/gather_normalize_negative_indices_test.cpp diff --git a/inference-engine/src/transformations/include/transformations/op_conversions/gather_normalize_negative_indices.hpp b/inference-engine/src/transformations/include/transformations/op_conversions/gather_normalize_negative_indices.hpp new file mode 100644 index 00000000000000..1ec1ffe628ed1a --- /dev/null +++ b/inference-engine/src/transformations/include/transformations/op_conversions/gather_normalize_negative_indices.hpp @@ -0,0 +1,29 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +namespace ngraph { +namespace pass { + + class TRANSFORMATIONS_API GatherNegativeConstIndicesNormalize; + +} // namespace pass +} // namespace ngraph + +/** + * @ingroup ie_transformation_common_api + * @brief GatherNegativeConstIndicesNormalize checks if indices value is negative scalar and + * normalizes it using ShapeOf->Add->Cast subgraph. + * We need to remove this transformation after adding support of negative indices in + * future version of Gather operation. + */ +class ngraph::pass::GatherNegativeConstIndicesNormalize : public ngraph::pass::MatcherPass { +public: + NGRAPH_RTTI_DECLARATION; + GatherNegativeConstIndicesNormalize(); +}; diff --git a/inference-engine/src/transformations/src/transformations/common_optimizations/common_optimizations.cpp b/inference-engine/src/transformations/src/transformations/common_optimizations/common_optimizations.cpp index 79f1dee888256f..4ab5cf1e80dc53 100644 --- a/inference-engine/src/transformations/src/transformations/common_optimizations/common_optimizations.cpp +++ b/inference-engine/src/transformations/src/transformations/common_optimizations/common_optimizations.cpp @@ -70,6 +70,7 @@ #include "transformations/op_conversions/log_softmax_decomposition.hpp" #include "transformations/op_conversions/mvn6_decomposition.hpp" #include "transformations/op_conversions/simplify_ctc_greedy_decoder_seq_len.hpp" +#include "transformations/op_conversions/gather_normalize_negative_indices.hpp" #include #include @@ -157,6 +158,7 @@ bool ngraph::pass::CommonOptimizations::run_on_function(std::shared_ptradd_matcher(); decomp->add_matcher(); decomp->add_matcher(); + decomp->add_matcher(); decomp->set_name("ngraph::pass::CommonDecompositions"); // CF is required after all decompositions diff --git a/inference-engine/src/transformations/src/transformations/op_conversions/gather_normalize_negative_indices.cpp b/inference-engine/src/transformations/src/transformations/op_conversions/gather_normalize_negative_indices.cpp new file mode 100644 index 00000000000000..86713451869345 --- /dev/null +++ b/inference-engine/src/transformations/src/transformations/op_conversions/gather_normalize_negative_indices.cpp @@ -0,0 +1,77 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "transformations/op_conversions/gather_normalize_negative_indices.hpp" + +#include + +#include +#include +#include +#include "itt.hpp" + +NGRAPH_RTTI_DEFINITION(ngraph::pass::GatherNegativeConstIndicesNormalize, "GatherNegativeConstIndicesNormalize", 0); + +ngraph::pass::GatherNegativeConstIndicesNormalize::GatherNegativeConstIndicesNormalize() { + MATCHER_SCOPE(GatherNegativeConstIndicesNormalize); + auto data_input = ngraph::pattern::any_input(pattern::has_static_rank()); + auto axis_input = ngraph::pattern::wrap_type(); + auto indices_input = ngraph::pattern::wrap_type(); + auto gather_node = std::make_shared(data_input, indices_input, axis_input); + + ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher& m) { + auto& pattern_to_output = m.get_pattern_value_map(); + auto gather = std::dynamic_pointer_cast(pattern_to_output.at(gather_node).get_node_shared_ptr()); + auto data = pattern_to_output.at(data_input); + auto axis_constant = std::dynamic_pointer_cast(pattern_to_output.at(axis_input).get_node_shared_ptr()); + auto indices_constant = std::dynamic_pointer_cast(pattern_to_output.at(indices_input).get_node_shared_ptr()); + + if (!gather || !axis_constant || !indices_constant) { + return false; + } + + auto indices = indices_constant->cast_vector(); + if (indices.size() != 1 || indices[0] >= 0) { + return false; + } + + auto axis = axis_constant->cast_vector(); + if (axis.size() != 1) { + return false; + } + + auto axis_value = axis[0]; + + // normalize `axis` value if it is negative + if (axis_value < 0) { + axis_value = axis_value + data.get_partial_shape().rank().get_length(); + } + + if (data.get_partial_shape().rank().get_length() < axis_value) { + return false; + } + + // check `axis` dimension of data tensor is static + if (!data.get_partial_shape()[axis_value].is_static()) { + return false; + } + + auto input_type = indices_constant->get_element_type(); + auto shape_of = std::make_shared(data, input_type); + auto input_gather = std::make_shared(shape_of, + ngraph::opset7::Constant::create(input_type, Shape{}, {axis_value}), ngraph::opset7::Constant::create(input_type, Shape{}, {0})); + + auto add = std::make_shared(input_gather, indices_constant); + auto gather_new = gather_node->copy_with_new_inputs({data, add, axis_constant}); + gather_new->set_friendly_name(gather->get_friendly_name()); + + ngraph::copy_runtime_info(gather, {shape_of, input_gather, add, gather_new}); + ngraph::replace_node(gather, gather_new); + + return true; + }; + + auto m = std::make_shared(gather_node, matcher_name); + register_matcher(m, callback); +} diff --git a/inference-engine/tests/functional/inference_engine/transformations/gather_normalize_negative_indices_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/gather_normalize_negative_indices_test.cpp new file mode 100644 index 00000000000000..ec6c4204a9b8a0 --- /dev/null +++ b/inference-engine/tests/functional/inference_engine/transformations/gather_normalize_negative_indices_test.cpp @@ -0,0 +1,306 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include "common_test_utils/ngraph_test_utils.hpp" + +using namespace testing; + +TEST(TransformationTests, GatherNegativeIndicesNormalize) { + std::shared_ptr f(nullptr), f_ref(nullptr); + { + auto data = std::make_shared(ngraph::element::f32, ngraph::Shape{1, 15, 128}); + auto indices = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {-1}); + auto axis = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {1}); + + auto gather = std::make_shared(data, indices, axis, 0); + + f = std::make_shared(ngraph::NodeVector{gather}, ngraph::ParameterVector{data}); + + ngraph::pass::Manager manager; + manager.register_pass(); + manager.register_pass(); + manager.run_passes(f); + ASSERT_NO_THROW(check_rt_info(f)); + } + + { + auto indices_type = ngraph::element::i32; + + auto data = std::make_shared(ngraph::element::f32, ngraph::Shape{1, 15, 128}); + auto indices = ngraph::opset7::Constant::create(indices_type, ngraph::Shape{}, {-1}); + auto axis = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {1}); + + auto shape_of = std::make_shared(data, indices_type); + auto input_gather = std::make_shared(shape_of, + ngraph::opset7::Constant::create(indices_type, ngraph::Shape{}, {1}), ngraph::opset7::Constant::create(indices_type, ngraph::Shape{}, {0})); + auto add = std::make_shared(input_gather, indices); + auto gather = std::make_shared(data, add, axis); + + f_ref = std::make_shared(ngraph::NodeVector{gather}, ngraph::ParameterVector{data}); + } + + auto res = compare_functions(f, f_ref); + ASSERT_TRUE(res.first) << res.second; +} + +TEST(TransformationTests, GatherNegativeIndicesNormalize_neg_axis) { + std::shared_ptr f(nullptr), f_ref(nullptr); + { + auto data = std::make_shared(ngraph::element::f32, ngraph::Shape{1, 15, 128}); + auto indices = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {-1}); + auto axis = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {-2}); + + auto gather = std::make_shared(data, indices, axis, 0); + + f = std::make_shared(ngraph::NodeVector{gather}, ngraph::ParameterVector{data}); + + ngraph::pass::Manager manager; + manager.register_pass(); + manager.register_pass(); + manager.run_passes(f); + ASSERT_NO_THROW(check_rt_info(f)); + } + + { + auto indices_type = ngraph::element::i32; + + auto data = std::make_shared(ngraph::element::f32, ngraph::Shape{1, 15, 128}); + auto indices = ngraph::opset7::Constant::create(indices_type, ngraph::Shape{}, {-1}); + auto axis = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {-2}); + + auto shape_of = std::make_shared(data, indices_type); + auto input_gather = std::make_shared(shape_of, + ngraph::opset7::Constant::create(indices_type, ngraph::Shape{}, {1}), ngraph::opset7::Constant::create(indices_type, ngraph::Shape{}, {0})); + auto add = std::make_shared(input_gather, indices); + auto gather = std::make_shared(data, add, axis); + + f_ref = std::make_shared(ngraph::NodeVector{gather}, ngraph::ParameterVector{data}); + } + + auto res = compare_functions(f, f_ref); + ASSERT_TRUE(res.first) << res.second; +} + +TEST(TransformationTests, GatherNegativeIndicesNormalize_dif_input_types) { + std::shared_ptr f(nullptr), f_ref(nullptr); + { + auto data = std::make_shared(ngraph::element::f32, ngraph::Shape{1, 15, 128}); + auto indices = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {-1}); + auto axis = ngraph::opset7::Constant::create(ngraph::element::i64, ngraph::Shape{}, {1}); + + auto gather = std::make_shared(data, indices, axis, 0); + + f = std::make_shared(ngraph::NodeVector{gather}, ngraph::ParameterVector{data}); + + ngraph::pass::Manager manager; + manager.register_pass(); + manager.register_pass(); + manager.run_passes(f); + ASSERT_NO_THROW(check_rt_info(f)); + } + + { + auto indices_type = ngraph::element::i32; + + auto data = std::make_shared(ngraph::element::f32, ngraph::Shape{1, 15, 128}); + auto indices = ngraph::opset7::Constant::create(indices_type, ngraph::Shape{}, {-1}); + auto axis = ngraph::opset7::Constant::create(ngraph::element::i64, ngraph::Shape{}, {1}); + + auto shape_of = std::make_shared(data, indices_type); + auto input_gather = std::make_shared(shape_of, + ngraph::opset7::Constant::create(indices_type, ngraph::Shape{}, {1}), ngraph::opset7::Constant::create(indices_type, ngraph::Shape{}, {0})); + auto add = std::make_shared(input_gather, indices); + auto gather = std::make_shared(data, add, axis); + + f_ref = std::make_shared(ngraph::NodeVector{gather}, ngraph::ParameterVector{data}); + } + + auto res = compare_functions(f, f_ref); + ASSERT_TRUE(res.first) << res.second; +} + +TEST(TransformationTests, GatherNegativeIndicesNormalize_static_axis_dim) { + std::shared_ptr f(nullptr), f_ref(nullptr); + { + auto data = std::make_shared(ngraph::element::f32, ngraph::PartialShape{DYN, 15, DYN}); + auto indices = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {-1}); + auto axis = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {1}); + + auto gather = std::make_shared(data, indices, axis, 0); + + f = std::make_shared(ngraph::NodeVector{gather}, ngraph::ParameterVector{data}); + + ngraph::pass::Manager manager; + manager.register_pass(); + manager.register_pass(); + manager.run_passes(f); + ASSERT_NO_THROW(check_rt_info(f)); + } + + { + auto indices_type = ngraph::element::i32; + + auto data = std::make_shared(ngraph::element::f32, ngraph::PartialShape{DYN, 15, DYN}); + auto indices = ngraph::opset7::Constant::create(indices_type, ngraph::Shape{}, {-1}); + auto axis = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {1}); + + auto shape_of = std::make_shared(data, indices_type); + auto input_gather = std::make_shared(shape_of, + ngraph::opset7::Constant::create(indices_type, ngraph::Shape{}, {1}), ngraph::opset7::Constant::create(indices_type, ngraph::Shape{}, {0})); + auto add = std::make_shared(input_gather, indices); + auto gather = std::make_shared(data, add, axis); + + f_ref = std::make_shared(ngraph::NodeVector{gather}, ngraph::ParameterVector{data}); + } + + auto res = compare_functions(f, f_ref); + ASSERT_TRUE(res.first) << res.second; +} + +TEST(TransformationTests, GatherNegativeIndicesNormalize_static_axis_dim_neg_axis) { + std::shared_ptr f(nullptr), f_ref(nullptr); + { + auto data = std::make_shared(ngraph::element::f32, ngraph::PartialShape{DYN, 15, DYN}); + auto indices = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {-1}); + auto axis = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {-2}); + + auto gather = std::make_shared(data, indices, axis, 0); + + f = std::make_shared(ngraph::NodeVector{gather}, ngraph::ParameterVector{data}); + + ngraph::pass::Manager manager; + manager.register_pass(); + manager.register_pass(); + manager.run_passes(f); + ASSERT_NO_THROW(check_rt_info(f)); + } + + { + auto indices_type = ngraph::element::i32; + + auto data = std::make_shared(ngraph::element::f32, ngraph::PartialShape{DYN, 15, DYN}); + auto indices = ngraph::opset7::Constant::create(indices_type, ngraph::Shape{}, {-1}); + auto axis = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {-2}); + + auto shape_of = std::make_shared(data, indices_type); + auto input_gather = std::make_shared(shape_of, + ngraph::opset7::Constant::create(indices_type, ngraph::Shape{}, {1}), ngraph::opset7::Constant::create(indices_type, ngraph::Shape{}, {0})); + auto add = std::make_shared(input_gather, indices); + auto gather = std::make_shared(data, add, axis); + + f_ref = std::make_shared(ngraph::NodeVector{gather}, ngraph::ParameterVector{data}); + } + + auto res = compare_functions(f, f_ref); + ASSERT_TRUE(res.first) << res.second; +} + +TEST(TransformationTests, GatherNegativeIndicesNormalize_non_static_axis_dim) { + std::shared_ptr f(nullptr), f_ref(nullptr); + { + auto data = std::make_shared(ngraph::element::f32, ngraph::PartialShape{DYN, DYN, DYN}); + auto indices = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {-1}); + auto axis = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {1}); + + auto gather = std::make_shared(data, indices, axis, 0); + + f = std::make_shared(ngraph::NodeVector{gather}, ngraph::ParameterVector{data}); + + ngraph::pass::Manager manager; + manager.register_pass(); + manager.register_pass(); + manager.run_passes(f); + ASSERT_NO_THROW(check_rt_info(f)); + } + + { + auto indices_type = ngraph::element::i32; + + auto data = std::make_shared(ngraph::element::f32, ngraph::PartialShape{DYN, DYN, DYN}); + auto indices = ngraph::opset7::Constant::create(indices_type, ngraph::Shape{}, {-1}); + auto axis = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {1}); + + auto gather = std::make_shared(data, indices, axis); + + f_ref = std::make_shared(ngraph::NodeVector{gather}, ngraph::ParameterVector{data}); + } + + auto res = compare_functions(f, f_ref); + ASSERT_TRUE(res.first) << res.second; +} + +TEST(TransformationTests, GatherNegativeIndicesNormalize_positive_ind) { + std::shared_ptr f(nullptr), f_ref(nullptr); + { + auto data = std::make_shared(ngraph::element::f32, ngraph::Shape{2, 3}); + auto indices = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {1}); + auto axis = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {0}); + + auto gather = std::make_shared(data, indices, axis, 0); + + f = std::make_shared(ngraph::NodeVector{gather}, ngraph::ParameterVector{data}); + + ngraph::pass::Manager manager; + manager.register_pass(); + manager.register_pass(); + manager.run_passes(f); + ASSERT_NO_THROW(check_rt_info(f)); + } + + { + auto data = std::make_shared(ngraph::element::f32, ngraph::Shape{2, 3}); + auto indices = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {1}); + auto axis = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {0}); + + auto gather = std::make_shared(data, indices, axis); + + f_ref = std::make_shared(ngraph::NodeVector{gather}, ngraph::ParameterVector{data}); + } + + auto res = compare_functions(f, f_ref); + ASSERT_TRUE(res.first) << res.second; +} + +TEST(TransformationTests, GatherNegativeIndicesNormalize_non_static_rank) { + std::shared_ptr f(nullptr), f_ref(nullptr); + { + auto data = std::make_shared(ngraph::element::f32, ngraph::PartialShape::dynamic(ngraph::Rank::dynamic())); + auto indices = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {-1}); + auto axis = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {0}); + + auto gather = std::make_shared(data, indices, axis, 0); + + f = std::make_shared(ngraph::NodeVector{gather}, ngraph::ParameterVector{data}); + + ngraph::pass::Manager manager; + manager.register_pass(); + manager.register_pass(); + manager.run_passes(f); + ASSERT_NO_THROW(check_rt_info(f)); + } + + { + auto data = std::make_shared(ngraph::element::f32, ngraph::PartialShape::dynamic()); + auto indices = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {-1}); + auto axis = ngraph::opset7::Constant::create(ngraph::element::i32, ngraph::Shape{}, {0}); + + auto gather = std::make_shared(data, indices, axis); + + f_ref = std::make_shared(ngraph::NodeVector{gather}, ngraph::ParameterVector{data}); + } + + auto res = compare_functions(f, f_ref); + ASSERT_TRUE(res.first) << res.second; +} From f4ba0f28a94d4ab809b4ce9404fd0f5f7dc43c66 Mon Sep 17 00:00:00 2001 From: Elizaveta Lobanova Date: Wed, 9 Jun 2021 18:15:39 +0300 Subject: [PATCH 048/178] [GNA] Convert Matmul with batch size > 8 to pointwise convolution (#5991) * [GNA] Convert Matmul with batch size > 8 to pointwise convolution. Support Eltwise split to more than 2 parts. Fake Quantize support fixes. * Put convolution split into a separate transformation * Add separate transformations for cases with bias and fake quantize * Rollback restriction for diagonal layer reshape --- .../gna_plugin/backend/gna_limitations.hpp | 5 + .../gna_plugin/frontend/scale_factor_calc.hpp | 7 +- .../src/gna_plugin/gna_graph_compiler.cpp | 40 +-- .../src/gna_plugin/gna_graph_tools.hpp | 18 +- .../src/gna_plugin/gna_groups.hpp | 11 +- .../src/gna_plugin/gna_plugin.cpp | 28 ++- .../gna_plugin/optimizer/gna_pass_manager.cpp | 106 +++++--- ...onvert_matmul_to_pointwise_convolution.cpp | 180 ++++++++++++++ ...onvert_matmul_to_pointwise_convolution.hpp | 71 ++++++ ...lit_convolution_with_large_buffer_size.cpp | 131 ++++++++++ ...lit_convolution_with_large_buffer_size.hpp | 34 +++ .../convert_matmul_to_pointwise_conv.cpp | 230 ++++++++++++++++++ .../eltwise_split_over_channels_pass.cpp | 26 +- 13 files changed, 798 insertions(+), 89 deletions(-) create mode 100644 inference-engine/src/gna_plugin/transformations/convert_matmul_to_pointwise_convolution.cpp create mode 100644 inference-engine/src/gna_plugin/transformations/convert_matmul_to_pointwise_convolution.hpp create mode 100644 inference-engine/src/gna_plugin/transformations/split_convolution_with_large_buffer_size.cpp create mode 100644 inference-engine/src/gna_plugin/transformations/split_convolution_with_large_buffer_size.hpp create mode 100644 inference-engine/tests/functional/plugin/gna/pass_tests/convert_matmul_to_pointwise_conv.cpp diff --git a/inference-engine/src/gna_plugin/backend/gna_limitations.hpp b/inference-engine/src/gna_plugin/backend/gna_limitations.hpp index 9b0eccaea59714..3a283cae895d15 100644 --- a/inference-engine/src/gna_plugin/backend/gna_limitations.hpp +++ b/inference-engine/src/gna_plugin/backend/gna_limitations.hpp @@ -10,13 +10,18 @@ namespace GNAPluginNS { namespace GNALimitations { +constexpr uint32_t bufferMaxSize = 65528; + constexpr uint32_t convMinFiltersNum = 4; constexpr uint32_t convMaxFiltersNum = 65532; constexpr uint32_t convFiltersNumDivider = 4; +constexpr uint32_t convFilterMaxSize = 768; constexpr uint32_t convEachKernelByteAlignment = 16; constexpr uint32_t noOfInputsDivisor = 8; constexpr uint32_t noOfInputsLowPrecDivisor = 16; +constexpr uint32_t affineMaxBatchSize = 8; + namespace Cnn2D { struct RangeLimit { uint32_t min; diff --git a/inference-engine/src/gna_plugin/frontend/scale_factor_calc.hpp b/inference-engine/src/gna_plugin/frontend/scale_factor_calc.hpp index 3c1fdaac0e729b..11f13a7a9acad7 100644 --- a/inference-engine/src/gna_plugin/frontend/scale_factor_calc.hpp +++ b/inference-engine/src/gna_plugin/frontend/scale_factor_calc.hpp @@ -370,14 +370,8 @@ class ScaleFactorPerLayer { auto minOutValue = quantizedParams->_dst_quant.GetMinValues().front(); auto maxOutValue = quantizedParams->_dst_quant.GetMaxValues().front(); auto absMax = std::max(std::abs(minOutValue), std::abs(maxOutValue)); - auto absMin = std::min(std::abs(minOutValue), std::abs(maxOutValue)); result = (quantizedParams->_dst_quant.GetLevels() - 1) / (maxOutValue - minOutValue); - if (0 && fp32eq(absMin, 0.0f) && !fp32eq(absMax, 0.0f)) { - result = (quantizedParams->_dst_quant.GetLevels() - 1) / (2 * absMax); - } - // - //result = MAX_VAL_2B_FEAT / absMax; if (std::isinf(result) || fp32eq(absMax, 0.0f)) { result = max_activation_scale_factor; } @@ -401,6 +395,7 @@ class ScaleFactorPerLayer { (layer.isIdentity() || layer.isFakeQuantize()) && LayerInfo(prevLayer).isWeightableIdentity()) { auto prevLayerQuant = InferenceEngine::getInjectedData(*prevLayer); if (!fp32eq(prevLayerQuant->_src_quant.GetScale(), 1.0f) && + prevLayerQuant->_src_quant.IsStatsSet() && (prevLayer2 == nullptr || LayerInfo(prevLayer2).has8BOr16BOutput())) { result = prevLayerQuant->_src_quant.GetScale(); usePrevScaleFactor = true; diff --git a/inference-engine/src/gna_plugin/gna_graph_compiler.cpp b/inference-engine/src/gna_plugin/gna_graph_compiler.cpp index 23685b4734faf9..bf44e437af0e6a 100644 --- a/inference-engine/src/gna_plugin/gna_graph_compiler.cpp +++ b/inference-engine/src/gna_plugin/gna_graph_compiler.cpp @@ -158,25 +158,27 @@ void GNAGraphCompiler::fillSplitConnections(InferenceEngine::CNNLayerPtr layer) THROW_GNA_LAYER_EXCEPTION(layer) << " outData["<< i << "]" << " connected by " << j <<" connection doesnt connect to functional layer"; } - auto dataOutput = outFunctionalLayer.first->insData[outFunctionalLayer.second].lock(); - - padding = std::max(padding, LayerInfo(outFunctionalLayer.first).paddingSize()) - * dataOutput->getPrecision().size(); - output_layer_size = - InferenceEngine::details::product(begin(dataOutput->getDims()), - end(dataOutput->getDims())) * dataOutput->getPrecision().size(); - - if (LayerInfo(outFunctionalLayer.first).isAffineFilter()) { - size_t aligned64_offset = outFunctionalLayer.first->GetParamAsInt("offset"); - layerInfoItem.splitOutputLayers.emplace_back( - outFunctionalLayer.first, - outFunctionalLayer.second, - aligned64_offset * dataOutput->getPrecision().size(), - output_layer_size); - } else { - layerInfoItem.splitOutputLayers.emplace_back( - outFunctionalLayer.first, outFunctionalLayer.second, split_size, output_layer_size); - } + for (int idx : outFunctionalLayer.second) { + auto dataOutput = outFunctionalLayer.first->insData[idx].lock(); + + padding = std::max(padding, LayerInfo(outFunctionalLayer.first).paddingSize()) + * dataOutput->getPrecision().size(); + output_layer_size = + InferenceEngine::details::product(begin(dataOutput->getDims()), + end(dataOutput->getDims())) * dataOutput->getPrecision().size(); + + if (LayerInfo(outFunctionalLayer.first).isAffineFilter()) { + size_t aligned64_offset = outFunctionalLayer.first->GetParamAsInt("offset"); + layerInfoItem.splitOutputLayers.emplace_back( + outFunctionalLayer.first, + idx, + aligned64_offset * dataOutput->getPrecision().size(), + output_layer_size); + } else { + layerInfoItem.splitOutputLayers.emplace_back( + outFunctionalLayer.first, idx, split_size, output_layer_size); + } + } } // in case of unconnected split - we need properly increment size diff --git a/inference-engine/src/gna_plugin/gna_graph_tools.hpp b/inference-engine/src/gna_plugin/gna_graph_tools.hpp index e9cf70790acdb9..51701268209728 100644 --- a/inference-engine/src/gna_plugin/gna_graph_tools.hpp +++ b/inference-engine/src/gna_plugin/gna_graph_tools.hpp @@ -155,14 +155,14 @@ inline InferenceEngine::CNNLayerPtr CNNNetPrevLayerSkipCertain(Layer layer, int */ template -inline std::pair CNNNetCheckNextLayerSkipCertain(Layer layer, int oidx, int iidx, bool bOnlyCheck, +inline std::pair> CNNNetCheckNextLayerSkipCertain(Layer layer, int oidx, int iidx, bool bOnlyCheck, const std::function &shouldSkip) { if (oidx >= layer->outData.size()) { - if (bOnlyCheck) return {nullptr, 0}; + if (bOnlyCheck) return {nullptr, {}}; THROW_GNA_LAYER_EXCEPTION(layer) << " no next output layer for outdata: " << oidx; } if (getInputTo(layer->outData[oidx]).empty() || iidx >= getInputTo(layer->outData[oidx]).size()) { - if (bOnlyCheck) return {nullptr, 0}; + if (bOnlyCheck) return {nullptr, {}}; THROW_GNA_LAYER_EXCEPTION(layer) << " no next output layer for outdata: " << oidx << " and inputTo index: " << iidx; } @@ -174,12 +174,12 @@ inline std::pair CNNNetCheckNextLayerSkipCer while (shouldSkip(outLayer->second)) { if (outLayer->second->outData.size() <= new_oidx) { - if (bOnlyCheck) return { nullptr, 0 }; + if (bOnlyCheck) return { nullptr, {} }; THROW_GNA_LAYER_EXCEPTION(outLayer->second) << " no next output layer for outdata: " << new_oidx; } if (getInputTo(outLayer->second->outData[new_oidx]).size() <= new_iidx) { - if (bOnlyCheck) return { nullptr, 0 }; + if (bOnlyCheck) return { nullptr, {} }; THROW_GNA_LAYER_EXCEPTION(outLayer->second) << " no next output layer for outdata: " << new_oidx << " and inputTo index: " << new_iidx; } @@ -188,11 +188,7 @@ inline std::pair CNNNetCheckNextLayerSkipCer } auto insDataIdx = CNNLayerFindInsDataIdxes(layer->outData[new_oidx], outLayer->second); - if (insDataIdx.size() != 1) { - if (bOnlyCheck) return { nullptr, 0 }; - THROW_GNA_LAYER_EXCEPTION(layer) << " has multiple connection to " << new_oidx << " outData"; - } - return { outLayer->second, insDataIdx.front() }; + return { outLayer->second, insDataIdx }; } /** @@ -256,7 +252,7 @@ inline std::pair CNNNetCheckNextLayerSkipCer /// @brief alias for strict checkNextLayer (false) template -inline std::pair CNNNetGetNextLayerSkipCertain(Layer layer, int oidx, int iidx, +inline std::pair> CNNNetGetNextLayerSkipCertain(Layer layer, int oidx, int iidx, const std::function &shouldSkip) { return CNNNetCheckNextLayerSkipCertain(layer, oidx, iidx, false, shouldSkip); } diff --git a/inference-engine/src/gna_plugin/gna_groups.hpp b/inference-engine/src/gna_plugin/gna_groups.hpp index 21abe5d01246f4..2449338821c109 100644 --- a/inference-engine/src/gna_plugin/gna_groups.hpp +++ b/inference-engine/src/gna_plugin/gna_groups.hpp @@ -46,14 +46,10 @@ inline InferenceEngine::DataPtr Get2DReshapedData(InferenceEngine::DataPtr input * @param layer */ inline bool HasTo2DReshapeData(InferenceEngine::CNNLayerPtr layer) { - if (GNAPluginNS::LayerInfo(layer).isPower()) + if (GNAPluginNS::LayerInfo(layer).isPower() || GNAPluginNS::LayerInfo(layer).isCopy()) return true; - if (!GNAPluginNS::LayerInfo(layer).isScaleShift()) - return false; - - // Don't reshape user-defined ScaleShift layers - if (layer->name.rfind("SyntheticScaleShift", 0) == std::string::npos) + if (!GNAPluginNS::LayerInfo(layer).isSyntheticScaleShift()) return false; // Don't reshape the first dnn layer since it breaks groups recognition @@ -61,8 +57,7 @@ inline bool HasTo2DReshapeData(InferenceEngine::CNNLayerPtr layer) { return LayerInfo(ptr).isNonValuesChangable(); }); IE_ASSERT(prevLayer != nullptr); - if (LayerInfo(prevLayer).isInput()) - return false; + if (LayerInfo(prevLayer).isInput()) return false; // Don't reshape diagonallayers with bias connection return !GNAPluginNS::LayerInfo(getCreatorLayer(layer->insData.front().lock()).lock()).has32BOutput(); diff --git a/inference-engine/src/gna_plugin/gna_plugin.cpp b/inference-engine/src/gna_plugin/gna_plugin.cpp index e76eafa6d5372a..f49d543def1f37 100644 --- a/inference-engine/src/gna_plugin/gna_plugin.cpp +++ b/inference-engine/src/gna_plugin/gna_plugin.cpp @@ -54,12 +54,17 @@ #include #include #include +#include #include "transformations/remove_extra_reshapes.hpp" #include "transformations/insert_transpose_after_convolution_or_pooling.hpp" #include "transformations/insert_transpose_before_matmul.hpp" #include "transformations/reorder_activation_and_pooling.hpp" #include "transformations/swap_input_matmul_gna.hpp" +#include "transformations/convert_matmul_to_pointwise_convolution.hpp" +#include "transformations/split_convolution_with_large_buffer_size.hpp" + +#include #if GNA_LIB_VER == 2 #include @@ -667,6 +672,15 @@ void GNAPlugin::LoadNetwork(CNNNetwork & _network) { // WA: ConvertPriorBox must be executed before the 1st ConstantFolding pass manager.register_pass(); manager.register_pass(); + // TODO enable this transformation for networks with convolutions + if (!ngraph::op::util::has_op_with_type(graph)) { + manager.register_pass(); + manager.register_pass(); + manager.register_pass(); + } + manager.register_pass(); + manager.register_pass(); + manager.register_pass(); manager.register_pass(); manager.register_pass(); manager.register_pass(); @@ -735,6 +749,7 @@ void GNAPlugin::LoadNetwork(CNNNetwork & _network) { passes->registerPass(); passes->registerPass(); + passes->registerPass(); passes->registerPass(); passes->registerPass(); passes->registerPass(); @@ -753,7 +768,6 @@ void GNAPlugin::LoadNetwork(CNNNetwork & _network) { passes->registerPass(); passes->registerPass(); - passes->registerPass(); passes->registerPass(); passes->registerPass(); #if GNA_LIB_VER == 2 @@ -1465,7 +1479,11 @@ static InferenceEngine::Layout GetLayoutForDims(const InferenceEngine::SizeVecto Blob::Ptr GNAPlugin::GetOutputBlob(const std::string& name, InferenceEngine::Precision precision) { // need to have intermediate blob for interleave conversion InferenceEngine::Blob::Ptr outputBlob; - auto outputDims = outputsDataMap[name]->getTensorDesc().getDims(); + auto outputDataIt = outputsDataMap.find(name); + if (outputDataIt == std::end(outputsDataMap)) { + THROW_GNA_EXCEPTION << "Output " << name << " isn't found"; + } + auto outputDims = outputDataIt->second->getTensorDesc().getDims(); outputBlob = make_blob_with_precision(TensorDesc(precision, outputDims, GetLayoutForDims(outputDims))); outputBlob->allocate(); return outputBlob; @@ -1475,7 +1493,11 @@ Blob::Ptr GNAPlugin::GetInputBlob(const std::string& name, InferenceEngine::Prec InferenceEngine::Blob::Ptr inputBlob; // need to have intermediate blob for interleave conversion // TODO: NCHW format support is experimental = c++ MO did insert reshape, while TF mo - not - auto inputDims = inputsDataMap[name]->getTensorDesc().getDims(); + auto inputDataIt = inputsDataMap.find(name); + if (inputDataIt == std::end(inputsDataMap)) { + THROW_GNA_EXCEPTION << "Input " << name << " isn't found"; + } + auto inputDims = inputDataIt->second->getTensorDesc().getDims(); inputBlob = make_blob_with_precision(TensorDesc(precision, inputDims, GetLayoutForDims(inputDims))); inputBlob->allocate(); return inputBlob; diff --git a/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp b/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp index 4d3b71b9622237..b8962cebd36e23 100644 --- a/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp +++ b/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp @@ -86,7 +86,7 @@ static void insertDiagonalLayerBetween(InferenceEngine::CNNLayerPtr prevLayer, }); IE_ASSERT(inputLayer != nullptr); size_t weightsSize = (LayerInfo(prevLayer).has32BOutput() || LayerInfo(inputLayer).isInput()) ? - weightsSize = nextLayer->outData[0]->getDims().back() : + nextLayer->outData[0]->getDims().back() : Get2DReshapedData(nextLayer->outData[0], 8)->getDims()[1]; std::vector weightsValues(weightsSize, fillValue); IE_ASSERT(diagLayer != nullptr); @@ -314,6 +314,7 @@ void HandleMultipleActivationsForTheLayerPass::run() { LayerInfo info(inputTo.second); if (info.isActivation()) { + if (odata->getDims().empty()) continue; if (!activations.empty() && odata->getDims()[0] != 1) { THROW_GNA_EXCEPTION << "Unsupported batch size " << odata->getDims()[0] << " for diagonal layer insertion"; @@ -741,12 +742,17 @@ void RemovePermutationsNHWCToNCHWPass::run() { IE_ASSERT(!input_to.empty()); auto current_layer = input_to.begin()->second; setNHWCOrder(current_layer->input()); - while (current_layer != pattern_end) { - setNHWCOrder(current_layer->outData[0]); - input_to = getInputTo(current_layer->outData[0]); - IE_ASSERT(!input_to.empty()); - current_layer = input_to.begin()->second; - } + std::function propogateNHWCOrderRecursive = + [pattern_end, &propogateNHWCOrderRecursive, &setNHWCOrder](CNNLayerPtr current_layer) { + if (current_layer == pattern_end) return; + for (size_t i = 0; i < current_layer->outData.size(); ++i) { + setNHWCOrder(current_layer->outData[i]); + auto input_to = getInputTo(current_layer->outData[i]); + IE_ASSERT(!input_to.empty()); + propogateNHWCOrderRecursive(input_to.begin()->second); + } + }; + propogateNHWCOrderRecursive(current_layer); if (LayerInfo(pattern_start).isPermute() && !getInputTo(pattern_start->outData.front()).empty()) { auto layer_before_permute = CNNNetPrevLayer(pattern_start); @@ -1447,21 +1453,19 @@ void EltwiseSplitOverChannelsPass::run() { THROW_GNA_LAYER_EXCEPTION(l) << "number of outputs expected to be 1"; } auto oData = l->outData.front(); + auto out_width = GetDataDimSize(oData, DataDimName::W); auto totalElementsForOutput = details::product(oData->getDims().begin(), oData->getDims().end()); auto maxAffineElements = getPassManager()->getPolicy().GNAAffineDiagonalPolicy.limitedTo; if (totalElementsForOutput <= maxAffineElements) { continue; } - // TODO: for now lets put split of 2 elements as restrictions auto totalSplits = 1 + totalElementsForOutput / maxAffineElements; - if (totalSplits > 2) { - THROW_GNA_LAYER_EXCEPTION(l) << "split layer over output channels on more than 2 layers unsupported"; - } pass_trace() << "transforming " << LAYER_NAME(l) << " by splitting it to multiple eltwise operations\n"; auto quantized = InferenceEngine::getInjectedData(l); + bool sameInputs = l->insData[0].lock() == l->insData[1].lock(); std::vector splitLayers(2); for (size_t kThEltwiseInput = 0; kThEltwiseInput != 2; kThEltwiseInput++) { // create split layer @@ -1472,31 +1476,38 @@ void EltwiseSplitOverChannelsPass::run() { split->insData.push_back(l->insData[kThEltwiseInput]); auto inputDesc = l->insData[kThEltwiseInput].lock()->getTensorDesc(); - // need to split this desc - if (inputDesc.getLayout() != Layout::NC) { - THROW_GNA_LAYER_EXCEPTION(l) - << "cannot split over channel: input " << std::to_string(kThEltwiseInput) - << " layout need to be NC"; - } // create split layer outputs - for (size_t i = 0;; i++) { - auto elements_num = std::min(totalElementsForOutput - i * maxAffineElements, + size_t usedElements = 0; + for (size_t i = 0; i < totalSplits; i++) { + SizeVector newDims; + size_t elements_num = std::min(totalElementsForOutput - usedElements, static_cast(maxAffineElements)); + if (inputDesc.getDims().size() == 2) { + newDims = SizeVector{1, elements_num}; + } else { + elements_num = elements_num - elements_num % out_width; + newDims = SizeVector{1, elements_num / out_width, out_width}; + } - SizeVector newDims = {1, elements_num}; auto newDesc = TensorDesc(inputDesc.getPrecision(), newDims, inputDesc.getLayout()); auto data = std::make_shared(l->name + "/" + std::to_string(kThEltwiseInput) + "/1", newDesc); getCreatorLayer(data) = split; split->outData.push_back(data); - if (elements_num != maxAffineElements) { + usedElements += elements_num; + if (usedElements == totalElementsForOutput) { break; } } // replacing connection X->eltwise to X->split auto oData = CNNLayerFindOutData(l, kThEltwiseInput); oData.second->second = split; + + if (sameInputs) { + splitLayers[1] = splitLayers[0]; + break; + } } // create concatlayer @@ -1507,8 +1518,6 @@ void EltwiseSplitOverChannelsPass::run() { concat->outData.push_back(masterEltwise->outData.front()); getCreatorLayer(masterEltwise->outData.front()) = concat; - - // create new eltwise layers - here 2 hardcode for (size_t k = 0; k != totalSplits; k++) { auto eltwiseRaw = std::make_shared( LayerParams{l->name + "/eltwise/" + std::to_string(k), "Eltwise", Precision::FP32}); @@ -1517,7 +1526,6 @@ void EltwiseSplitOverChannelsPass::run() { eltwiseRaw->coeff = masterEltwise->coeff; auto eltwise = quantized ? InferenceEngine::injectData(eltwiseRaw) : eltwiseRaw; - eltwise->insData.push_back(splitLayers[0]->outData[k]); eltwise->insData.push_back(splitLayers[1]->outData[k]); getInputTo(splitLayers[0]->outData[k])[eltwise->name] = eltwise; @@ -1529,6 +1537,15 @@ void EltwiseSplitOverChannelsPass::run() { auto data = std::make_shared(l->name + "/elwise/out/" + std::to_string(k), newDesc); getCreatorLayer(data) = eltwise; eltwise->outData.push_back(data); + if (quantized) { + auto eltwiseQuant = InferenceEngine::getInjectedData(eltwise); + if (quantized->_src_quant.IsStatsSet()) { + eltwiseQuant->_src_quant.CopyStats(quantized->_src_quant); + } + if (quantized->_dst_quant.IsStatsSet()) { + eltwiseQuant->_dst_quant.CopyStats(quantized->_dst_quant); + } + } getInputTo(data)[concat->name] = concat; concat->insData.push_back(data); } @@ -1919,13 +1936,20 @@ void FuseFQIntoWeightsPass::run() { } GNAFakeQuantizeLayer gnaFakeQuantizeLayer(fqLayer); - size_t layers_connected_to_fq_count = getInputTo(fqLayer->outData[0]).size(); + auto inputTo = getInputTo(fqLayer->outData[0]); + size_t layers_connected_to_fq_count = inputTo.size(); + auto layerBeforeWeightable = fqLayer; + while (layers_connected_to_fq_count == 1 && LayerInfo(inputTo.begin()->second).isNonFunctional()) { + layerBeforeWeightable = inputTo.begin()->second; + inputTo = getInputTo(layerBeforeWeightable->outData[0]); + layers_connected_to_fq_count = inputTo.size(); + } for (int index = 0; index < layers_connected_to_fq_count; index++) { - auto weightableLayer = CNNNetGetNextLayerSkipCertain(fqLayer, 0, index, isNonFunctional).first; + auto weightableLayer = CNNNetGetNextLayerSkipCertain(layerBeforeWeightable, 0, index, isNonFunctional).first; if (!LayerInfo(weightableLayer).isWeightable()) { continue; } - if (weightableLayer->insData.size() != 3) { + if (weightableLayer->insData.size() < 2) { continue; } @@ -1942,7 +1966,8 @@ void FuseFQIntoWeightsPass::run() { pass_trace() << "found " << LAYER_NAME(fqLayer) << " that will be converted to weights of " << LAYER_NAME(weightableLayer) << "\n"; - auto biases = LayerUtils::getParamFromInputAsBlob(weightableLayer, biasesIdx); + auto biases = weightableLayer->insData.size() == 3 ? + LayerUtils::getParamFromInputAsBlob(weightableLayer, biasesIdx) : nullptr; auto quantizedWeights = gnaFakeQuantizeLayer.getConstInputData(); // 1. broke existing connections - by detaching fq subgraph from rest of graph @@ -2149,8 +2174,11 @@ void MoveFakeQuantizeLayerIntoQuantParamsPass :: run() { } GNAFakeQuantizeLayer fqLayer(l); auto prevLayer = CNNNetPrevLayerSkipCertain(*fqLayer, 0, donotSkip); - if (prevLayer->outData.size() != 1) { - THROW_GNA_LAYER_EXCEPTION(prevLayer) << " fake quantize input that connected to something else not supported"; + auto prevDataIt = std::find_if(std::begin(prevLayer->outData), std::end(prevLayer->outData), [l](DataPtr data) { + return getInputTo(data).find(l->name) != std::end(getInputTo(data)); + }); + if (prevDataIt == std::end(prevLayer->outData)) { + THROW_GNA_LAYER_EXCEPTION(fqLayer) << "Invalid connection between " << prevLayer->name << " and " << l->name; } auto inputRange = fqLayer.getInputRange(); @@ -2181,8 +2209,18 @@ void MoveFakeQuantizeLayerIntoQuantParamsPass :: run() { quantParamsPrevLayer->_dst_quant.SetMinValues({ outputRange.first[0] }, false); quantParamsPrevLayer->_dst_quant.SetMaxValues({ outputRange.second[0] }, false); + // Propogate destination statistics to multiply layer if it's set for the next sum/sub layer (is considered as bias) + if (LayerInfo(prevLayer).isEltwiseSum() || LayerInfo(prevLayer).isEltwiseSub()) { + auto eltwPrevLayer = CNNNetPrevLayerSkipCertain(prevLayer, 0, donotSkip); + auto constLayer = CNNNetPrevLayerSkipCertain(prevLayer, 1, donotSkip); + if (LayerInfo(eltwPrevLayer).isEltwise() && LayerInfo(constLayer).isConst()) { + auto quantParamsEltwLayer = InferenceEngine::getInjectedData(eltwPrevLayer); + quantParamsEltwLayer->_dst_quant.CopyStats(quantParamsPrevLayer->_dst_quant); + } + } + auto fqQauntParams = InferenceEngine::getInjectedData(l); - fqQauntParams->_dst_quant.SetLevels(fqLevels); + fqQauntParams->_dst_quant.SetLevels(UINT16_MAX); fqQauntParams->_dst_quant.SetMinValues({ inputRange.first[0] }, true); fqQauntParams->_dst_quant.SetMaxValues({ inputRange.second[0] }, true); fqQauntParams->_dst_quant.SetMinValues({ outputRange.first[0] }, false); @@ -2198,7 +2236,7 @@ void MoveFakeQuantizeLayerIntoQuantParamsPass :: run() { // FQ Layer is fused only when previous layer is const, memory or activation layer // or a next layer is activation layer. bool isFQFuseAllowed = allowFQFuse(l); - auto prevData = prevLayer->outData.front(); + auto prevData = *prevDataIt; // Find all output layers connected to FQ auto nextLayers = CNNNetGetAllNextLayersSkipCertain(*fqLayer, -1, donotSkip); @@ -2207,7 +2245,7 @@ void MoveFakeQuantizeLayerIntoQuantParamsPass :: run() { } if (isFQFuseAllowed) { - getInputTo(prevLayer->outData.front()).clear(); + getInputTo(prevData).clear(); } // Connect all next layers after FQ to the layer that is before FQ @@ -2222,7 +2260,7 @@ void MoveFakeQuantizeLayerIntoQuantParamsPass :: run() { for (int insDataIdx : insDatas) { nextLayers[i]->insData[insDataIdx] = prevData; } - getInputTo(prevLayer->outData.front())[nextLayers[i]->name] = nextLayers[i]; + getInputTo(prevData)[nextLayers[i]->name] = nextLayers[i]; } propagateStatistics(quantParamsPrevLayer, nextLayers[i]); diff --git a/inference-engine/src/gna_plugin/transformations/convert_matmul_to_pointwise_convolution.cpp b/inference-engine/src/gna_plugin/transformations/convert_matmul_to_pointwise_convolution.cpp new file mode 100644 index 00000000000000..da7e6279624c81 --- /dev/null +++ b/inference-engine/src/gna_plugin/transformations/convert_matmul_to_pointwise_convolution.cpp @@ -0,0 +1,180 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "transformations/convert_matmul_to_pointwise_convolution.hpp" + +#include +#include +#include + +#include "layers/gna_permute.hpp" +#include "backend/gna_limitations.hpp" + +using namespace GNAPluginNS; + +NGRAPH_RTTI_DEFINITION(ConvertMatmulToPointWiseConvolution, "ConvertMatmulToPointWiseConvolution", 0); +NGRAPH_RTTI_DEFINITION(ConvertMatmulWithBiasToPointWiseConvolution, "ConvertMatmulWithBiasToPointWiseConvolution", 0); +NGRAPH_RTTI_DEFINITION(ConvertMatmulWithFqToPointWiseConvolution, "ConvertMatmulWithFqToPointWiseConvolution", 0); + +static std::tuple VerifyAndGetConvParams(std::shared_ptr matmul_node) { + auto input1_shape = matmul_node->get_input_shape(0); + auto input2_shape = matmul_node->get_input_shape(1); + auto output_shape = matmul_node->get_output_shape(0); + if (input1_shape.size() == 3 && input1_shape.front() == 1) { + input1_shape.erase(std::begin(input1_shape)); + } + + if (input1_shape.size() != 2 || input2_shape.size() != 2 || output_shape.size() < 2) { + return std::make_tuple(false, 0, 0, 0); + } + + // Check if MatMul or corresponding pointwise convolution are supported by GNA + const uint32_t width = input1_shape.front(); + const uint32_t in_channels = input2_shape.back(); + const uint32_t out_channels = input2_shape.front(); + if (input1_shape.front() <= GNALimitations::affineMaxBatchSize || + out_channels % GNALimitations::convFiltersNumDivider != 0 || + out_channels > GNALimitations::convMaxFiltersNum || + in_channels > GNALimitations::convFilterMaxSize) { + return std::make_tuple(false, 0, 0, 0); + } + + return std::make_tuple(true, width, in_channels, out_channels); +} + +static bool Convert(std::shared_ptr matmul_node, + std::shared_ptr add, + std::shared_ptr bias, + std::shared_ptr fq) { + bool supported; + uint32_t width, in_channels, out_channels; + std::tie(supported, width, in_channels, out_channels) = VerifyAndGetConvParams(matmul_node); + if (!supported) return false; + + auto input_node = matmul_node->input_value(0).get_node_shared_ptr(); + auto weights_node = matmul_node->input_value(1).get_node_shared_ptr(); + auto base_name = matmul_node->get_friendly_name(); + + auto reshape_const_before = std::make_shared(ngraph::element::Type_t::i64, + ngraph::Shape{4}, + ngraph::Shape{1, 1, width, in_channels}); + auto reshape_before = std::make_shared(input_node, reshape_const_before, false); + reshape_before->set_friendly_name(base_name + "/reshape_in"); + + auto transpose_before = std::make_shared(reshape_before, + ngraph::opset7::Constant::create(ngraph::element::i64, ngraph::Shape{4}, + GetPermuteOrder(InferenceEngine::Layout::NHWC, InferenceEngine::Layout::NCHW))); + transpose_before->set_friendly_name(base_name + "/transpose_in"); + + auto weights_reshape_const = std::make_shared(ngraph::element::Type_t::i64, + ngraph::Shape{4}, ngraph::Shape{out_channels, in_channels, 1, 1}); + auto weights_reshaped = std::make_shared(weights_node, weights_reshape_const, false); + + std::shared_ptr conv_node = std::make_shared(transpose_before, weights_reshaped, + ngraph::Strides{1, 1}, ngraph::CoordinateDiff{0, 0}, ngraph::CoordinateDiff{0, 0}, + ngraph::Strides{1, 1}, ngraph::op::PadType::VALID); + conv_node->set_friendly_name(base_name + "/conv"); + + std::shared_ptr root_node = matmul_node; + if (bias != nullptr) { + conv_node = std::make_shared(conv_node, bias); + root_node = add; + } + + if (fq != nullptr) { + conv_node = fq->clone_with_new_inputs({conv_node, fq->input_value(1), fq->input_value(2), + fq->input_value(3), fq->input_value(4)}); + root_node = fq; + } + + auto transpose_after = std::make_shared(conv_node, + ngraph::opset7::Constant::create(ngraph::element::i64, ngraph::Shape{4}, + GetPermuteOrder(InferenceEngine::Layout::NCHW, InferenceEngine::Layout::NHWC))); + transpose_after->set_friendly_name(base_name + "/transpose_out"); + + auto output_shape = matmul_node->get_output_shape(0); + output_shape[output_shape.size() - 1] = out_channels; + output_shape[output_shape.size() - 2] = width; + auto reshape_const_after = std::make_shared(ngraph::element::Type_t::i64, + ngraph::Shape{output_shape.size()}, + output_shape); + auto reshape_after = std::make_shared(transpose_after, reshape_const_after, false); + reshape_after->set_friendly_name(base_name); + + ngraph::replace_node(root_node, reshape_after); + return true; +} + +ConvertMatmulToPointWiseConvolution::ConvertMatmulToPointWiseConvolution() { + auto const_input = ngraph::pattern::wrap_type(); + auto const_fq = ngraph::pattern::wrap_type({const_input, + ngraph::pattern::wrap_type(), + ngraph::pattern::wrap_type(), + ngraph::pattern::wrap_type(), + ngraph::pattern::wrap_type()}); + auto second_input = std::make_shared(ngraph::OutputVector{const_input, const_fq}); + auto matmul = ngraph::pattern::wrap_type({ngraph::pattern::any_input(), second_input}); + + ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher &m) { + const auto& pattern_map = m.get_pattern_value_map(); + return Convert(pattern_map.at(matmul).get_node_shared_ptr(), nullptr, nullptr, nullptr); + }; + + auto m = std::make_shared(matmul, "ConvertMatmulToPointWiseConvolution"); + this->register_matcher(m, callback); +} + +ConvertMatmulWithBiasToPointWiseConvolution::ConvertMatmulWithBiasToPointWiseConvolution() { + auto const_input = ngraph::pattern::wrap_type(); + auto const_fq = ngraph::pattern::wrap_type({const_input, + ngraph::pattern::wrap_type(), + ngraph::pattern::wrap_type(), + ngraph::pattern::wrap_type(), + ngraph::pattern::wrap_type()}); + auto second_input = std::make_shared(ngraph::OutputVector{const_input, const_fq}); + auto matmul = ngraph::pattern::wrap_type({ngraph::pattern::any_input(), second_input}); + auto bias = ngraph::pattern::wrap_type(); + auto add = ngraph::pattern::wrap_type({matmul, bias}); + + ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher &m) { + const auto& pattern_map = m.get_pattern_value_map(); + return Convert(pattern_map.at(matmul).get_node_shared_ptr(), pattern_map.at(add).get_node_shared_ptr(), + pattern_map.at(bias).get_node_shared_ptr(), nullptr); + }; + + auto m = std::make_shared(add, "ConvertMatmulWithBiasToPointWiseConvolution"); + this->register_matcher(m, callback); +} + +ConvertMatmulWithFqToPointWiseConvolution::ConvertMatmulWithFqToPointWiseConvolution() { + auto const_input = ngraph::pattern::wrap_type(); + auto const_fq = ngraph::pattern::wrap_type({const_input, + ngraph::pattern::wrap_type(), + ngraph::pattern::wrap_type(), + ngraph::pattern::wrap_type(), + ngraph::pattern::wrap_type()}); + auto second_input = std::make_shared(ngraph::OutputVector{const_input, const_fq}); + auto matmul = ngraph::pattern::wrap_type({ngraph::pattern::any_input(), second_input}); + auto bias = ngraph::pattern::wrap_type(); + auto add = ngraph::pattern::wrap_type({matmul, bias}); + auto matmul_out = std::make_shared(ngraph::OutputVector{add, matmul}); + auto out_fq = ngraph::pattern::wrap_type({matmul_out, + ngraph::pattern::wrap_type(), + ngraph::pattern::wrap_type(), + ngraph::pattern::wrap_type(), + ngraph::pattern::wrap_type()}); + + ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher &m) { + const auto& pattern_map = m.get_pattern_value_map(); + auto add_it = pattern_map.find(add); + auto add_node = (add_it == std::end(pattern_map) ? nullptr : add_it->second.get_node_shared_ptr()); + auto bias_it = pattern_map.find(bias); + auto bias_node = (bias_it == std::end(pattern_map) ? nullptr : bias_it->second.get_node_shared_ptr()); + return Convert(pattern_map.at(matmul).get_node_shared_ptr(), add_node, bias_node, + pattern_map.at(out_fq).get_node_shared_ptr()); + }; + + auto m = std::make_shared(out_fq, "ConvertMatmulWithFqToPointWiseConvolution"); + this->register_matcher(m, callback); +} \ No newline at end of file diff --git a/inference-engine/src/gna_plugin/transformations/convert_matmul_to_pointwise_convolution.hpp b/inference-engine/src/gna_plugin/transformations/convert_matmul_to_pointwise_convolution.hpp new file mode 100644 index 00000000000000..999b529194d860 --- /dev/null +++ b/inference-engine/src/gna_plugin/transformations/convert_matmul_to_pointwise_convolution.hpp @@ -0,0 +1,71 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +namespace GNAPluginNS { + +/** + * @brief Convert a MatMul with batch size unsupported by GNA to a point-wise convolution with NHWC layout + * with transposes around it: + * Transose (NHWC -> NCHW) + * | + * Matmul Convolution in NHWC layout + * Input1: [A, B] B > 8 -------> Input: [1, 1, A, B] + * Input2: [B, C] Kernel: [C, B, 1, 1] + * Output: [A, C] Output: [1, 1, A, C] + * | + * Transose (NCHW -> NHWC) + */ +class ConvertMatmulToPointWiseConvolution : public ngraph::pass::MatcherPass { +public: + NGRAPH_RTTI_DECLARATION; + ConvertMatmulToPointWiseConvolution(); +}; + +/** + * @brief Convert a MatMul with batch size unsupported by GNA to a point-wise convolution with NHWC layout + * with transposes around it, moved add with bias before the last transpose: + * Transose (NHWC -> NCHW) + * | + * Matmul Convolution in NHWC layout + * Input1: [A, B] B > 8 -------> Input: [1, 1, A, B] + * Input2: [B, C] Kernel: [C, B, 1, 1] + * Output: [A, C] Output: [1, 1, A, C] + * | | + * Add (const) Add (const) + * | + * Transose (NCHW -> NHWC) + */ +class ConvertMatmulWithBiasToPointWiseConvolution : public ngraph::pass::MatcherPass { +public: + NGRAPH_RTTI_DECLARATION; + ConvertMatmulWithBiasToPointWiseConvolution(); +}; + +/** + * @brief Convert a MatMul with batch size unsupported by GNA to a point-wise convolution with NHWC layout + * with transposes around it, moved add with bias and/or fake quantize before the last transpose: + * Transose (NHWC -> NCHW) + * | + * Matmul Convolution in NHWC layout + * Input1: [A, B] B > 8 -------> Input: [1, 1, A, B] + * Input2: [B, C] Kernel: [C, B, 1, 1] + * Output: [A, C] Output: [1, 1, A, C] + * | | + * Add (const) Add (const) + * | | + * FakeQuantize FakeQuantize + * | + * Transose (NCHW -> NHWC) + */ +class ConvertMatmulWithFqToPointWiseConvolution : public ngraph::pass::MatcherPass { +public: + NGRAPH_RTTI_DECLARATION; + ConvertMatmulWithFqToPointWiseConvolution(); +}; + +} // namespace GNAPluginNS \ No newline at end of file diff --git a/inference-engine/src/gna_plugin/transformations/split_convolution_with_large_buffer_size.cpp b/inference-engine/src/gna_plugin/transformations/split_convolution_with_large_buffer_size.cpp new file mode 100644 index 00000000000000..a9d79c831ab34d --- /dev/null +++ b/inference-engine/src/gna_plugin/transformations/split_convolution_with_large_buffer_size.cpp @@ -0,0 +1,131 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "transformations/split_convolution_with_large_buffer_size.hpp" + +#include + +#include +#include +#include + +#include "backend/gna_limitations.hpp" + +using namespace GNAPluginNS; + +NGRAPH_RTTI_DEFINITION(SplitConvolution, "SplitConvolution", 0); +NGRAPH_RTTI_DEFINITION(SplitConvolutionWithBias, "SplitConvolutionWithBias", 0); +NGRAPH_RTTI_DEFINITION(SplitConvolutionWithFq, "SplitConvolutionWithFq", 0); + +static std::vector GetConvSplitSizes(std::shared_ptr conv) { + uint32_t width = conv->get_input_shape(0).back(); + uint32_t in_channels = conv->get_input_shape(0).at(1); + uint32_t usedWidth = 0; + std::vector split_sizes; + uint32_t width_max_size = GNALimitations::bufferMaxSize / in_channels; + width_max_size = width_max_size - width_max_size % 64; + while (usedWidth < width) { + uint32_t width_part = std::min(width - usedWidth, width_max_size); + split_sizes.push_back(width_part); + usedWidth += width_part; + } + IE_ASSERT(usedWidth == width); + return split_sizes; +} + +static bool Convert(std::shared_ptr conv, + std::shared_ptr add, + std::shared_ptr bias, + std::shared_ptr fq) { + auto input_size = std::accumulate(std::begin(conv->get_input_shape(0)), + std::end(conv->get_input_shape(0)), 1, std::multiplies()); + if (input_size <= GNALimitations::bufferMaxSize) { + return false; + } + + auto split_sizes = GetConvSplitSizes(conv); + IE_ASSERT(split_sizes.size() > 1); + + /* TODO check if it's NHWC convolution wrapped with transposes or all input dimensions except of width == 1, + otherwise this split axis isn't supported */ + const int64_t width_axis = conv->get_input_shape(0).size() - 1; + auto split_node = std::make_shared(conv->input_value(0), + ngraph::opset7::Constant::create(ngraph::element::i64, ngraph::Shape({1}), std::vector{width_axis}), + ngraph::opset7::Constant::create(ngraph::element::i64, ngraph::Shape({split_sizes.size()}), split_sizes)); + split_node->set_friendly_name(conv->get_friendly_name() + "/split"); + ngraph::OutputVector convOutputs; + std::shared_ptr root_node = fq ? fq : (add ? add : conv); + for (int i = 0; i < split_sizes.size(); ++i) { + std::shared_ptr output = conv->clone_with_new_inputs({split_node->output(i), conv->input_value(1)}); + output->set_friendly_name(conv->get_friendly_name() + "_" + std::to_string(i)); + if (bias) { + output = std::make_shared(output, bias); + } + + if (fq) { + output = fq->clone_with_new_inputs({output, fq->input_value(1), fq->input_value(2), + fq->input_value(3), fq->input_value(4)}); + } + convOutputs.push_back(output); + } + + auto concat = std::make_shared(convOutputs, width_axis); + concat->set_friendly_name(conv->get_friendly_name()); + ngraph::replace_node(root_node, concat); + return true; +} + +SplitConvolution::SplitConvolution() { + auto conv = ngraph::pattern::wrap_type({ngraph::pattern::any_input(), + ngraph::pattern::any_input()}); + + ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher &m) { + const auto& pattern_map = m.get_pattern_value_map(); + return Convert(pattern_map.at(conv).get_node_shared_ptr(), nullptr, nullptr, nullptr); + }; + + auto m = std::make_shared(conv, "SplitConvolution"); + this->register_matcher(m, callback); +} + +SplitConvolutionWithBias::SplitConvolutionWithBias() { + auto conv = ngraph::pattern::wrap_type({ngraph::pattern::any_input(), + ngraph::pattern::any_input()}); + auto bias = ngraph::pattern::wrap_type(); + auto add = ngraph::pattern::wrap_type({conv, bias}); + + ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher &m) { + const auto& pattern_map = m.get_pattern_value_map(); + return Convert(pattern_map.at(conv).get_node_shared_ptr(), pattern_map.at(add).get_node_shared_ptr(), + pattern_map.at(bias).get_node_shared_ptr(), nullptr); + }; + + auto m = std::make_shared(add, "SplitConvolutionWithBias"); + this->register_matcher(m, callback); +} + +SplitConvolutionWithFq::SplitConvolutionWithFq() { + auto conv = ngraph::pattern::wrap_type({ngraph::pattern::any_input(), + ngraph::pattern::any_input()}); + auto bias = ngraph::pattern::wrap_type(); + auto add = ngraph::pattern::wrap_type({conv, bias}); + auto conv_output = std::make_shared(ngraph::OutputVector{conv, add}); + auto out_fq = ngraph::pattern::wrap_type({conv_output, + ngraph::pattern::wrap_type(), + ngraph::pattern::wrap_type(), + ngraph::pattern::wrap_type(), + ngraph::pattern::wrap_type()}); + + ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher &m) { + const auto& pattern_map = m.get_pattern_value_map(); + auto add_it = pattern_map.find(add); + auto add_node = (add_it == std::end(pattern_map) ? nullptr : add_it->second.get_node_shared_ptr()); + auto bias_it = pattern_map.find(bias); + auto bias_node = (bias_it == std::end(pattern_map) ? nullptr : bias_it->second.get_node_shared_ptr()); + return Convert(pattern_map.at(conv).get_node_shared_ptr(), add_node, bias_node, pattern_map.at(out_fq).get_node_shared_ptr()); + }; + + auto m = std::make_shared(out_fq, "SplitConvolutionWithFq"); + this->register_matcher(m, callback); +} \ No newline at end of file diff --git a/inference-engine/src/gna_plugin/transformations/split_convolution_with_large_buffer_size.hpp b/inference-engine/src/gna_plugin/transformations/split_convolution_with_large_buffer_size.hpp new file mode 100644 index 00000000000000..8667f4273bfaad --- /dev/null +++ b/inference-engine/src/gna_plugin/transformations/split_convolution_with_large_buffer_size.hpp @@ -0,0 +1,34 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +namespace GNAPluginNS { + +// @brief Splits convolution with large input buffer +class SplitConvolution : public ngraph::pass::MatcherPass { +public: + NGRAPH_RTTI_DECLARATION; + SplitConvolution(); +}; + +// @brief Splits convolution with large input buffer, move add with bias to each convolution before concat +class SplitConvolutionWithBias : public ngraph::pass::MatcherPass { +public: + NGRAPH_RTTI_DECLARATION; + SplitConvolutionWithBias(); +}; + +/* @brief Splits convolution with large input buffer, + * move add with bias and/or fake quantize to each convolution before concat + */ +class SplitConvolutionWithFq : public ngraph::pass::MatcherPass { +public: + NGRAPH_RTTI_DECLARATION; + SplitConvolutionWithFq(); +}; + +} // namespace GNAPluginNS \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/gna/pass_tests/convert_matmul_to_pointwise_conv.cpp b/inference-engine/tests/functional/plugin/gna/pass_tests/convert_matmul_to_pointwise_conv.cpp new file mode 100644 index 00000000000000..7e3d15174f3e5f --- /dev/null +++ b/inference-engine/tests/functional/plugin/gna/pass_tests/convert_matmul_to_pointwise_conv.cpp @@ -0,0 +1,230 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include +#include +#include +#include + +#include + +#include "common_test_utils/common_utils.hpp" +#include "functional_test_utils/plugin_cache.hpp" +#include "shared_test_classes/base/layer_test_utils.hpp" +#include "functional_test_utils/blob_utils.hpp" +#include "ngraph_functions/utils/ngraph_helpers.hpp" +#include "ngraph_functions/builders.hpp" + +#include "ngraph_functions/pass/convert_prc.hpp" + +typedef std::tuple< + InferenceEngine::Precision, // Network Precision + std::string, // Target Device + std::map, // Configuration + std::vector // Input Shape +> convertMatmulToPointwiseConvParams; + +typedef std::tuple< + InferenceEngine::Precision, // Network Precision + std::string, // Target Device + std::map, // Configuration + std::vector, // Input Shape + std::pair // Input Min and Max +> convertMatmulToPointwiseConvWithFqParams; + +namespace LayerTestsDefinitions { + +class ConvertMatmulToPointwiseConv : public testing::WithParamInterface, + public LayerTestsUtils::LayerTestsCommon { +public: + static std::string getTestCaseName(testing::TestParamInfo obj) { + InferenceEngine::Precision netPrecision; + std::string targetDevice; + std::map configuration; + std::vector inputShape; + std::tie(netPrecision, targetDevice, configuration, inputShape) = obj.param; + + std::ostringstream result; + result << "netPRC=" << netPrecision.name() << "_"; + result << "targetDevice=" << targetDevice << "_"; + for (auto const& configItem : configuration) { + result << "_configItem=" << configItem.first << "_" << configItem.second; + } + result << "_inputShape=" << CommonTestUtils::vec2str(inputShape); + return result.str(); + } + + InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo& info) const { + InferenceEngine::Blob::Ptr blob = make_blob_with_precision(info.getTensorDesc()); + blob->allocate(); + + auto* rawBlobDataPtr = blob->buffer().as(); + std::vector values = CommonTestUtils::generate_float_numbers(blob->size(), -0.2f, 0.2f); + for (size_t i = 0; i < blob->size(); i++) { + rawBlobDataPtr[i] = values[i]; + } + return blob; + } + +protected: + void SetUp() override { + InferenceEngine::Precision netPrecision; + std::vector inputShape; + std::tie(netPrecision, targetDevice, configuration, inputShape) = this->GetParam(); + auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); + + auto params = ngraph::builder::makeParams(ngPrc, {inputShape}); + + size_t batch = inputShape[inputShape.size() - 2]; + size_t elemNum = inputShape[inputShape.size() - 1]; + std::vector weights = CommonTestUtils::generate_float_numbers(elemNum * elemNum, -0.1f, 0.1f); + auto weightsNode = std::make_shared(ngPrc, ngraph::Shape{elemNum, elemNum}, weights); + auto matmul = ngraph::builder::makeMatMul(params[0], weightsNode, false, true); + + auto bias = ngraph::builder::makeConstant(ngPrc, std::vector{1, batch, 1}, std::vector{1.0f}); + auto add = ngraph::builder::makeEltwise(matmul, bias, ngraph::helpers::EltwiseTypes::ADD); + + auto pattern = std::make_shared(ngraph::element::Type_t::i64, + ngraph::Shape{ inputShape.size() }, inputShape); + auto reshape = std::make_shared(matmul, pattern, false); + auto relu = std::make_shared(reshape); + + ngraph::ResultVector results{ std::make_shared(relu)}; + function = std::make_shared(results, params, "ConvertMatmulToPointwiseConv"); + } +}; + +class ConvertMatmulToPointwiseConvWithFq : public testing::WithParamInterface, + public LayerTestsUtils::LayerTestsCommon { + float inputDataMin = -10.0f; + float inputDataMax = 10.0f; + float inputDataResolution = 1.0f; + +public: + static std::string getTestCaseName(testing::TestParamInfo obj) { + InferenceEngine::Precision netPrecision; + std::string targetDevice; + std::map configuration; + std::vector inputShape; + std::pair inputMinMax; + std::tie(netPrecision, targetDevice, configuration, inputShape, inputMinMax) = obj.param; + + std::ostringstream result; + result << "netPRC=" << netPrecision.name() << "_"; + result << "targetDevice=" << targetDevice << "_"; + for (auto const& configItem : configuration) { + result << "_configItem=" << configItem.first << "_" << configItem.second; + } + result << "_inputShape=" << CommonTestUtils::vec2str(inputShape); + result << "_inputMinMax=(" << inputMinMax.first << ".." << inputMinMax.second << ")"; + return result.str(); + } + + InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo& info) const { + return FuncTestUtils::createAndFillBlob(info.getTensorDesc(), inputDataMax - inputDataMin, inputDataMin, + 1 / inputDataResolution); + } + +protected: + void SetUp() override { + InferenceEngine::Precision netPrecision; + std::vector inputShape; + std::pair inputMinMax; + std::tie(netPrecision, targetDevice, configuration, inputShape, inputMinMax) = this->GetParam(); + std::tie(inputDataMin, inputDataMax) = inputMinMax; + auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); + + auto params = ngraph::builder::makeParams(ngPrc, {inputShape}); + + auto inputLowNode = ngraph::builder::makeConstant(ngPrc, std::vector{ 1 }, + std::vector{ inputDataMin }); + auto inputHighNode = ngraph::builder::makeConstant(ngPrc, std::vector{ 1 }, + std::vector{ inputDataMax }); + auto inputFQ = std::make_shared(params[0], + inputLowNode, inputHighNode, inputLowNode, inputHighNode, UINT16_MAX); + + size_t elemNum = inputShape[inputShape.size() - 1]; + + const float weightsMin = -0.2f; + const float weightsMax = 0.2f; + std::vector weights = CommonTestUtils::generate_float_numbers(elemNum * elemNum, weightsMin, weightsMax); + auto weightsNode = std::make_shared(ngPrc, ngraph::Shape{elemNum, elemNum}, weights); + auto weightsLowNode = ngraph::builder::makeConstant(ngPrc, std::vector{ 1 }, + std::vector{ weightsMin }); + auto weightsHighNode = ngraph::builder::makeConstant(ngPrc, std::vector{ 1 }, + std::vector{ weightsMax }); + auto weightsFQNode = std::make_shared(weightsNode, + weightsLowNode, weightsHighNode, weightsLowNode, weightsHighNode, UINT16_MAX); + auto matmul = ngraph::builder::makeMatMul(inputFQ, weightsFQNode, false, true); + + auto bias = ngraph::builder::makeConstant(ngPrc, std::vector{1, 1, 1}, std::vector{1.0f}); + auto add = ngraph::builder::makeEltwise(matmul, bias, ngraph::helpers::EltwiseTypes::ADD); + + auto outputLowNode = ngraph::builder::makeConstant(ngPrc, std::vector{ 1 }, + std::vector{ -inputDataMax * weightsMax * elemNum }); + auto outputHighNode = ngraph::builder::makeConstant(ngPrc, std::vector{ 1 }, + std::vector{ inputDataMax * weightsMax * elemNum }); + auto outputFQ = std::make_shared(add, + outputLowNode, outputHighNode, outputLowNode, outputHighNode, UINT16_MAX); + + auto pattern = std::make_shared(ngraph::element::Type_t::i64, + ngraph::Shape{ inputShape.size() }, inputShape); + auto reshape = std::make_shared(outputFQ, pattern, false); + + auto relu = std::make_shared(reshape); + + ngraph::ResultVector results{ std::make_shared(relu)}; + function = std::make_shared(results, params, "ConvertMatmulToPointwiseConv"); + } +}; + +TEST_P(ConvertMatmulToPointwiseConv, CompareWithRefImpl) { + Run(); +}; + +TEST_P(ConvertMatmulToPointwiseConvWithFq, CompareWithRefImpl) { + Run(); +}; + +const std::vector netPrecisions = { + InferenceEngine::Precision::FP32, + InferenceEngine::Precision::FP16 +}; + +const std::vector> configs = { + { + {"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, + } +}; + +const std::vector> inputShape = { + {1, 64, 64}, + {1, 256, 128}, + {1, 512, 128} +}; + +const std::vector> fqStats = { + {-0.5, 0.5} +}; + +INSTANTIATE_TEST_CASE_P(smoke_ConvertMatmulToPointwiseConvTest, ConvertMatmulToPointwiseConv, + ::testing::Combine( + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CommonTestUtils::DEVICE_GNA), + ::testing::ValuesIn(configs), + ::testing::ValuesIn(inputShape)), + ConvertMatmulToPointwiseConv::getTestCaseName); + +// Issue 55662 +INSTANTIATE_TEST_CASE_P(DISABLED_smoke_ConvertMatmulToPointwiseConvTest, ConvertMatmulToPointwiseConvWithFq, + ::testing::Combine( + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CommonTestUtils::DEVICE_GNA), + ::testing::ValuesIn(configs), + ::testing::ValuesIn(inputShape), + ::testing::ValuesIn(fqStats)), + ConvertMatmulToPointwiseConvWithFq::getTestCaseName); + +} // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/gna/pass_tests/eltwise_split_over_channels_pass.cpp b/inference-engine/tests/functional/plugin/gna/pass_tests/eltwise_split_over_channels_pass.cpp index 17da73dfc99e18..f4c6cc98d34136 100644 --- a/inference-engine/tests/functional/plugin/gna/pass_tests/eltwise_split_over_channels_pass.cpp +++ b/inference-engine/tests/functional/plugin/gna/pass_tests/eltwise_split_over_channels_pass.cpp @@ -18,19 +18,21 @@ typedef std::tuple< InferenceEngine::Precision, // Network Precision std::string, // Target Device - std::map //Configuration + std::map, // Configuration + std::vector // Input Shape > EltwiseSplitOverChannelsPassParams; namespace LayerTestsDefinitions { class EltwiseSplitOverChannelsPassTest : public testing::WithParamInterface, - public LayerTestsUtils::LayerTestsCommon { + public LayerTestsUtils::LayerTestsCommon { public: static std::string getTestCaseName(testing::TestParamInfo obj) { InferenceEngine::Precision netPrecision; std::string targetDevice; std::map configuration; - std::tie(netPrecision, targetDevice, configuration) = obj.param; + std::vector inputShape; + std::tie(netPrecision, targetDevice, configuration, inputShape) = obj.param; std::ostringstream result; result << "netPRC=" << netPrecision.name() << "_"; @@ -38,20 +40,22 @@ class EltwiseSplitOverChannelsPassTest : public testing::WithParamInterface(sum, params, "EltwiseSplitOverChannelsPassTest"); } }; @@ -71,11 +75,17 @@ const std::vector> configs = { } }; +const std::vector> inputShape = { + {1, 67000}, + {1, 500000} +}; + INSTANTIATE_TEST_CASE_P(smoke_EltwiseSplitOverChennels, EltwiseSplitOverChannelsPassTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), - ::testing::ValuesIn(configs)), + ::testing::ValuesIn(configs), + ::testing::ValuesIn(inputShape)), EltwiseSplitOverChannelsPassTest::getTestCaseName); } // namespace LayerTestsDefinitions From ec1134532a230020966d8e36a470d286859de503 Mon Sep 17 00:00:00 2001 From: Konstantin Satunin Date: Wed, 9 Jun 2021 18:52:44 +0300 Subject: [PATCH 049/178] Align logic and feature flag name (#6107) --- .ci/azure/linux.yml | 1 + .ci/azure/mac.yml | 2 +- .ci/azure/windows.yml | 2 +- cmake/features.cmake | 2 +- ngraph/test/CMakeLists.txt | 4 ++-- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.ci/azure/linux.yml b/.ci/azure/linux.yml index f45f4e410c67ba..146775f6189f02 100644 --- a/.ci/azure/linux.yml +++ b/.ci/azure/linux.yml @@ -112,6 +112,7 @@ jobs: -DNGRAPH_ONNX_IMPORT_ENABLE=ON -DNGRAPH_ONNX_EDITOR_ENABLE=ON -DENABLE_FASTER_BUILD=ON + -DENABLE_STRICT_DEPENDENCIES=OFF -DIE_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)/modules $(REPO_DIR) workingDirectory: $(BUILD_DIR) diff --git a/.ci/azure/mac.yml b/.ci/azure/mac.yml index 680ef281ac21fe..04d4c16ea23344 100644 --- a/.ci/azure/mac.yml +++ b/.ci/azure/mac.yml @@ -90,7 +90,7 @@ jobs: # Disable errors with Ninja export CXXFLAGS="-Wno-error=unused-command-line-argument" export CFLAGS="-Wno-error=unused-command-line-argument" - cmake -GNinja -DVERBOSE_BUILD=ON -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DENABLE_PYTHON=ON -DENABLE_TESTS=ON -DIE_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)/modules $(REPO_DIR) + cmake -GNinja -DVERBOSE_BUILD=ON -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DENABLE_PYTHON=ON -DENABLE_TESTS=ON -DENABLE_STRICT_DEPENDENCIES=OFF -DIE_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)/modules $(REPO_DIR) workingDirectory: $(BUILD_DIR) displayName: 'CMake' diff --git a/.ci/azure/windows.yml b/.ci/azure/windows.yml index 6b4e5203dd08f4..21a36392e33812 100644 --- a/.ci/azure/windows.yml +++ b/.ci/azure/windows.yml @@ -92,7 +92,7 @@ jobs: - script: | set PATH=$(WORK_DIR)\ninja-win;%PATH% - call "$(MSVS_VARS_PATH)" && cmake -GNinja -DENABLE_FASTER_BUILD=ON -DENABLE_TEMPLATE_PLUGIN=ON -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DENABLE_TESTS=ON -DIE_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)\modules -DCMAKE_C_COMPILER:PATH="$(MSVC_COMPILER_PATH)" -DCMAKE_CXX_COMPILER:PATH="$(MSVC_COMPILER_PATH)" $(REPO_DIR) + call "$(MSVS_VARS_PATH)" && cmake -GNinja -DENABLE_FASTER_BUILD=ON -DENABLE_TEMPLATE_PLUGIN=ON -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DENABLE_TESTS=ON -DENABLE_STRICT_DEPENDENCIES=OFF -DIE_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)\modules -DCMAKE_C_COMPILER:PATH="$(MSVC_COMPILER_PATH)" -DCMAKE_CXX_COMPILER:PATH="$(MSVC_COMPILER_PATH)" $(REPO_DIR) workingDirectory: $(BUILD_DIR) displayName: 'CMake' diff --git a/cmake/features.cmake b/cmake/features.cmake index 7518c99c86838c..aff805adb15a64 100644 --- a/cmake/features.cmake +++ b/cmake/features.cmake @@ -6,7 +6,7 @@ ie_dependent_option (ENABLE_MKL_DNN "MKL-DNN plugin for inference engine" ON "X8 ie_option (ENABLE_TESTS "unit, behavior and functional tests" OFF) -ie_option (ENABLE_STRICT_DEPENDENCIES "Skip configuring \"convinient\" dependencies for efficient parallel builds" OFF) +ie_option (ENABLE_STRICT_DEPENDENCIES "Skip configuring \"convinient\" dependencies for efficient parallel builds" ON) ie_dependent_option (ENABLE_CLDNN "clDnn based plugin for inference engine" ON "X86_64;NOT APPLE;NOT MINGW;NOT WINDOWS_STORE;NOT WINDOWS_PHONE" OFF) diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index 97f85a3128f926..7ee6b89580d0f6 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -286,7 +286,7 @@ set_source_files_properties(includes.cpp PROPERTIES COMPILE_DEFINITIONS if (ENABLE_MKL_DNN) message(STATUS "NGRAPH_TESTS: IE:CPU enabled") set(ACTIVE_BACKEND_LIST ${ACTIVE_BACKEND_LIST} "IE:CPU") - if (NOT ENABLE_STRICT_DEPENDENCIES) + if (ENABLE_STRICT_DEPENDENCIES) # For convinience add a runtime dependency to build along with this target. # Warning: Parallel build with -GNinja may not be efficient. list(APPEND UNIT_TESTS_DEPENDENCIES MKLDNNPlugin) @@ -296,7 +296,7 @@ endif() if (ENABLE_CLDNN) message(STATUS "NGRAPH_TESTS: IE:GPU enabled") set(ACTIVE_BACKEND_LIST ${ACTIVE_BACKEND_LIST} "IE:GPU") - if (NOT ENABLE_STRICT_DEPENDENCIES) + if (ENABLE_STRICT_DEPENDENCIES) # For convinience add a runtime dependency to build along with this target. # Warning: Parallel build with -GNinja may not be efficient. list(APPEND UNIT_TESTS_DEPENDENCIES clDNNPlugin) From 3bedd051dcf91389c957fdbca1ec4e8624a2f615 Mon Sep 17 00:00:00 2001 From: Ivan Tikhonov Date: Wed, 9 Jun 2021 19:03:38 +0300 Subject: [PATCH 050/178] processing sinks in hetero plugin, update single layer tests (#6090) --- .../src/hetero_plugin/hetero_executable_network.cpp | 6 +++++- .../shared_tests_instances/single_layer_tests/memory.cpp | 2 +- ngraph/core/include/ngraph/op/util/op_types.hpp | 4 ++++ ngraph/core/src/op/util/op_types.cpp | 9 +++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/inference-engine/src/hetero_plugin/hetero_executable_network.cpp b/inference-engine/src/hetero_plugin/hetero_executable_network.cpp index 9f0135aa25e357..994ba866f7a2e9 100644 --- a/inference-engine/src/hetero_plugin/hetero_executable_network.cpp +++ b/inference-engine/src/hetero_plugin/hetero_executable_network.cpp @@ -312,6 +312,7 @@ HeteroExecutableNetwork::HeteroExecutableNetwork(const InferenceEngine::CNNNetwo struct Subgraph { ngraph::ResultVector _results; ngraph::ParameterVector _parameters; + ngraph::SinkVector _sinks; std::string _affinity; }; std::unordered_map subgraphs; @@ -325,6 +326,9 @@ HeteroExecutableNetwork::HeteroExecutableNetwork(const InferenceEngine::CNNNetwo } else if (ngraph::op::is_parameter(node)) { subgraph._parameters.emplace_back( std::dynamic_pointer_cast(node->shared_from_this())); + } else if (ngraph::op::is_sink(node)) { + subgraph._sinks.emplace_back( + std::dynamic_pointer_cast(node->shared_from_this())); } auto itAffinity = affinities.find(node); if (itAffinity != affinities.end()) { @@ -373,7 +377,7 @@ HeteroExecutableNetwork::HeteroExecutableNetwork(const InferenceEngine::CNNNetwo for (auto&& subgraph : orderedSubgraphs) { _networks[id]._device = subgraph._affinity; subFunctions[id] = - std::make_shared(subgraph._results, subgraph._parameters, + std::make_shared(subgraph._results, subgraph._sinks, subgraph._parameters, _name + '_' + std::to_string(id)); _networks[id]._clonedNetwork = CNNNetwork{subFunctions[id]}; // update of pre-processing info diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/memory.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/memory.cpp index 9ab20c3eda4cf7..062ea0cad9194e 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/memory.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/memory.cpp @@ -38,7 +38,7 @@ INSTANTIATE_TEST_CASE_P(smoke_MemoryTest, MemoryTest, ::testing::ValuesIn(iterationCount), ::testing::ValuesIn(inShapes), ::testing::ValuesIn(inputPrecisions), - ::testing::Values(CommonTestUtils::DEVICE_CPU)), + ::testing::Values(CommonTestUtils::DEVICE_CPU, "HETERO:CPU")), MemoryTest::getTestCaseName); } // namespace diff --git a/ngraph/core/include/ngraph/op/util/op_types.hpp b/ngraph/core/include/ngraph/op/util/op_types.hpp index b672f5518c4086..6d162157ab581b 100644 --- a/ngraph/core/include/ngraph/op/util/op_types.hpp +++ b/ngraph/core/include/ngraph/op/util/op_types.hpp @@ -34,6 +34,8 @@ namespace ngraph NGRAPH_API bool is_output(const ngraph::Node* node); NGRAPH_API + bool is_sink(const ngraph::Node* node); + NGRAPH_API bool is_constant(const ngraph::Node* node); NGRAPH_API bool is_commutative(const ngraph::Node* node); @@ -60,6 +62,8 @@ namespace ngraph NGRAPH_API bool is_output(const std::shared_ptr& node); NGRAPH_API + bool is_sink(const std::shared_ptr& node); + NGRAPH_API bool is_constant(const std::shared_ptr& node); NGRAPH_API bool is_commutative(const std::shared_ptr& node); diff --git a/ngraph/core/src/op/util/op_types.cpp b/ngraph/core/src/op/util/op_types.cpp index f0852233ec754f..354c605ced17be 100644 --- a/ngraph/core/src/op/util/op_types.cpp +++ b/ngraph/core/src/op/util/op_types.cpp @@ -76,6 +76,11 @@ bool ngraph::op::is_output(const ngraph::Node* node) return dynamic_cast(node) != nullptr; } +bool ngraph::op::is_sink(const ngraph::Node* node) +{ + return dynamic_cast(node) != nullptr; +} + bool ngraph::op::is_constant(const ngraph::Node* node) { return dynamic_cast(node) != nullptr; @@ -134,6 +139,10 @@ bool ngraph::op::is_output(const std::shared_ptr& node) { return is_output(node.get()); } +bool ngraph::op::is_sink(const std::shared_ptr& node) +{ + return is_sink(node.get()); +} bool ngraph::op::is_constant(const std::shared_ptr& node) { return is_constant(node.get()); From 1a6392eb5335f64a053d6301099e30838a3a2aa4 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 9 Jun 2021 20:39:05 +0300 Subject: [PATCH 051/178] [GNA] Fixed export/import functionality (#5963) * Rebase master * [GNA] Fixed export/import functionality * Extended import log * Added logs * Fixed importing issue for the old models * Revert "Added logs" This reverts commit 39a3882d560b241018b1ad20aa5318b991951379. * Revert "Extended import log" This reverts commit 59eb9d6fba91ba2ca86da159f2d55fe37fba0320. * Reverted precision import * Extended tests * Enabled skipped tests * Included gna2-common-api header * Replaced included header * Centos7 build fix --- .../src/gna_plugin/gna_model_serial.cpp | 113 +++++++--- .../src/gna_plugin/gna_model_serial.hpp | 2 + .../serial/headers/2dot7/gna_model_header.hpp | 197 ++++++++++++++++++ .../headers/latest/gna_model_header.hpp | 6 +- .../skip_tests_config.cpp | 2 - .../import_export_base/import_export_base.cpp | 3 + .../base/layer_test_utils.hpp | 2 + .../src/base/layer_test_utils.cpp | 11 + 8 files changed, 301 insertions(+), 35 deletions(-) create mode 100644 inference-engine/src/gna_plugin/serial/headers/2dot7/gna_model_header.hpp diff --git a/inference-engine/src/gna_plugin/gna_model_serial.cpp b/inference-engine/src/gna_plugin/gna_model_serial.cpp index fdb99d7f273bc1..e32ded8a9e37ed 100644 --- a/inference-engine/src/gna_plugin/gna_model_serial.cpp +++ b/inference-engine/src/gna_plugin/gna_model_serial.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #endif @@ -133,10 +134,11 @@ GNAPluginNS::HeaderLatest::ModelHeader GNAModelSerial::ReadHeader(std::istream & } case 5: case 6: + case 7: readNBytes(&header, sizeof(HeaderLatest::ModelHeader), is); break; default: - THROW_GNA_EXCEPTION << "Imported file unsupported. minor version should have values in range 1 to 4 and is: " << header.version.minor; + THROW_GNA_EXCEPTION << "Imported file unsupported. minor version should have values in range 1 to 7 and is: " << header.version.minor; } break; default: @@ -154,6 +156,40 @@ GNAPluginNS::HeaderLatest::ModelHeader GNAModelSerial::ReadHeader(std::istream & return header; } +GNAPluginNS::HeaderLatest::RuntimeEndPoint GNAModelSerial::ReadEndPoint(std::istream &is) { + is.exceptions(std::istream::failbit); + + HeaderLatest::RuntimeEndPoint endPoint; + switch (modelHeader.version.major) { + case 2: + switch (modelHeader.version.minor) { + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + { + Header2dot6::RuntimeEndPoint tempEndPoint2dot6; + readBits(tempEndPoint2dot6, is); + endPoint = HeaderLatest::RuntimeEndPoint(tempEndPoint2dot6, modelHeader.nGroup); + break; + } + case 7: + readNBytes(&endPoint, sizeof(HeaderLatest::RuntimeEndPoint), is); + break; + default: + THROW_GNA_EXCEPTION << "Imported file unsupported. minor version should have values in range 1 to 7 and is: " << modelHeader.version.minor; + } + break; + default: + THROW_GNA_EXCEPTION << "Imported file unsupported. Import for files with major version equal to: " + << modelHeader.version.major << " is not implemented"; + } + + return endPoint; +} + #define offsetFromBase(field)\ getOffsetFromBase(field, #field) @@ -324,18 +360,6 @@ void GNAModelSerial::Import(void *basePointer, is.read(reinterpret_cast(basePointer), gnaGraphSize); } - -uint32_t guessGrouping(Gna2Model const& model) { - if (model.NumberOfOperations == 0 || - model.Operations == nullptr || - model.Operations[0].Operands == nullptr || - model.Operations[0].NumberOfOperands == 0 || - model.Operations[0].Operands[0]->Shape.NumberOfDimensions < 2) { - THROW_GNA_EXCEPTION << "Can not guess grouping"; - } - return (std::min)(model.Operations[0].Operands[0]->Shape.Dimensions[0], model.Operations[0].Operands[0]->Shape.Dimensions[1]); -} - void GNAModelSerial::Export(void * basePointer, size_t gnaGraphSize, std::ostream & os) const { os.exceptions(std::ostream::failbit); @@ -366,6 +390,9 @@ void GNAModelSerial::Export(void * basePointer, size_t gnaGraphSize, std::ostrea out.descriptor_offset = offsetFromBase(ep.descriptor_ptr); out.scaleFactor = ep.scaleFactor; out.element_size = ep.element_size; + out.shape = ep.shape; + out.layout = ep.layout; + out.precision = ep.precision; out.orientation = ep.orientation; return out; }; @@ -381,7 +408,7 @@ void GNAModelSerial::Export(void * basePointer, size_t gnaGraphSize, std::ostrea header.headerSize = sizeof(HeaderLatest::ModelHeader); header.gnaMemSize = gnaGraphSize; header.layersCount = layers.size(); - header.nGroup = guessGrouping(*gna2Model); + header.nGroup = 1; // just to support the old models header.nInputs = inputs.size(); header.nOutputs = outputs.size(); header.nTransposeInputs = transposeInputsInfo.size(); @@ -796,13 +823,22 @@ std::vector GNAModelSerial::serializeOutputs(cons std::size_t outputIndex = 0; for (auto const &output : outputsDataMap) { auto outputName = output.first; - auto inputDims = output.second->getTensorDesc().getDims(); - uint32_t elementsCount = static_cast(InferenceEngine::details::product(inputDims.begin(), inputDims.end())); - + auto outputDims = output.second->getTensorDesc().getDims(); + HeaderLatest::RuntimeEndPoint::Shape outputShape; + outputShape.NumberOfDimensions = outputDims.size(); + for (size_t i=0; i < outputShape.NumberOfDimensions; ++i) { + outputShape.Dimensions[i] = static_cast(outputDims[i]); + } + uint32_t elementsCount = static_cast(InferenceEngine::details::product(outputDims.begin(), outputDims.end())); + InferenceEngine::Layout outputLayout = output.second->getLayout(); + InferenceEngine::Precision::ePrecision outputPrecision = InferenceEngine::Precision::FP32; HeaderLatest::RuntimeEndPoint endPoint(outputsDesc[outputIndex].scale_factor, outputsDesc[outputIndex].ptrs[0], outputsDesc[outputIndex].num_bytes_per_element, elementsCount, + outputShape, + outputLayout, + outputPrecision, outputsDesc[outputIndex].orientation); endPoints.push_back(endPoint); outputIndex++; @@ -818,18 +854,26 @@ std::vector GNAModelSerial::serializeInputs(const for (auto const& input : inputsDataMap) { auto inputName = input.first; auto inputDims = input.second->getTensorDesc().getDims(); - + HeaderLatest::RuntimeEndPoint::Shape inputShape; + inputShape.NumberOfDimensions = inputDims.size(); + for (size_t i=0; i < inputShape.NumberOfDimensions; ++i) { + inputShape.Dimensions[i] = static_cast(inputDims[i]); + } double scaleFactor = inputDesc->getScaleFactor(inputIndex); std::vector descriptor_ptr = inputDesc->getPtrInputsGlobal(inputName); IE_ASSERT(descriptor_ptr.size() > 0); uint32_t element_size = 2u; uint32_t elementsCount = static_cast(InferenceEngine::details::product(inputDims.begin(), inputDims.end())); intel_dnn_orientation_t orientation = inputDesc->getOrientation(inputName); - + InferenceEngine::Layout inputLayout = input.second->getLayout(); + InferenceEngine::Precision::ePrecision inputPrecision = InferenceEngine::Precision::FP32; HeaderLatest::RuntimeEndPoint endPoint(scaleFactor, descriptor_ptr[0], element_size, elementsCount, + inputShape, + inputLayout, + inputPrecision, orientation); endPoints.push_back(endPoint); inputIndex++; @@ -846,20 +890,24 @@ void GNAModelSerial::ImportInputs(std::istream &is, for (uint32_t inputIndex = 0; inputIndex < modelHeader.nInputs; inputIndex++) { const std::string& name = (modelHeader.version.major == 2 && modelHeader.version.minor >= 3) ? inputNames.at(inputIndex) : std::string("input" + std::to_string(inputIndex)); - HeaderLatest::RuntimeEndPoint input; - is.read(reinterpret_cast(&input), sizeof(input)); + + HeaderLatest::RuntimeEndPoint input = ReadEndPoint(is); inputsDesc->getPtrInputsGlobal(name).push_back(reinterpret_cast(reinterpret_cast (basePtr) + input.descriptor_offset)); inputsDesc->orientation_in[name] = input.orientation; inputsDesc->bytes_allocated_for_input[name] = input.element_size * input.elements_count; - auto inputDims = InferenceEngine::SizeVector({modelHeader.nGroup, input.elements_count / modelHeader.nGroup}); - + auto inputDims = InferenceEngine::SizeVector(); + for (auto i = 0; i < input.shape.NumberOfDimensions; ++i) { + inputDims.push_back(input.shape.Dimensions[i]); + } + InferenceEngine::Layout inputLayout = static_cast(input.layout); + InferenceEngine::Precision inputPresicion = InferenceEngine::Precision(static_cast(input.precision)); dataMap[name] = std::make_shared(); dataMap[name]->setInputData(std::make_shared(name, InferenceEngine::TensorDesc( - InferenceEngine::Precision::FP32, + inputPresicion, inputDims, - InferenceEngine::Layout::NC))); + inputLayout))); inputsDesc->inputScaleFactors.push_back(input.scaleFactor); } } @@ -875,8 +923,8 @@ void GNAModelSerial::ImportOutputs(std::istream &is, for (uint32_t outputIndex = 0; outputIndex < modelHeader.nOutputs; outputIndex++) { const std::string& name = (modelHeader.version.major == 2 && modelHeader.version.minor >= 3) ? outputNames.at(outputIndex) : std::string("output" + std::to_string(outputIndex)); - HeaderLatest::RuntimeEndPoint output; - is.read(reinterpret_cast(&output), sizeof(output)); + + HeaderLatest::RuntimeEndPoint output = ReadEndPoint(is); OutputDesc description; description.ptrs.push_back(reinterpret_cast(reinterpret_cast (basePtr) + output.descriptor_offset)); description.orientation = kDnnInterleavedOrientation; @@ -884,12 +932,17 @@ void GNAModelSerial::ImportOutputs(std::istream &is, description.num_bytes_per_element = output.element_size; description.scale_factor = output.scaleFactor; - auto outputDims = InferenceEngine::SizeVector({modelHeader.nGroup, output.elements_count / modelHeader.nGroup}); + auto outputDims = InferenceEngine::SizeVector(); + for (auto i = 0; i < output.shape.NumberOfDimensions; ++i) { + outputDims.push_back(output.shape.Dimensions[i]); + } + InferenceEngine::Layout outputLayout = static_cast(output.layout); + InferenceEngine::Precision outputPresicion = InferenceEngine::Precision(static_cast(output.precision)); dataMap[name] = std::make_shared(name, InferenceEngine::TensorDesc( - InferenceEngine::Precision::FP32, + outputPresicion, outputDims, - InferenceEngine::Layout::NC)); + outputLayout)); desc.at(outputIndex) = description; } } diff --git a/inference-engine/src/gna_plugin/gna_model_serial.hpp b/inference-engine/src/gna_plugin/gna_model_serial.hpp index d756a23f9fc0ab..f5310d826c4c5f 100644 --- a/inference-engine/src/gna_plugin/gna_model_serial.hpp +++ b/inference-engine/src/gna_plugin/gna_model_serial.hpp @@ -138,6 +138,8 @@ class GNAModelSerial { */ static GNAPluginNS::HeaderLatest::ModelHeader ReadHeader(std::istream &is); + GNAPluginNS::HeaderLatest::RuntimeEndPoint ReadEndPoint(std::istream &is); + /** * @brief Import model from FS into preallocated buffer, * buffers for pLayers, and pStructs are allocated here and required manual deallocation using mm_free diff --git a/inference-engine/src/gna_plugin/serial/headers/2dot7/gna_model_header.hpp b/inference-engine/src/gna_plugin/serial/headers/2dot7/gna_model_header.hpp new file mode 100644 index 00000000000000..14badf3adcf032 --- /dev/null +++ b/inference-engine/src/gna_plugin/serial/headers/2dot7/gna_model_header.hpp @@ -0,0 +1,197 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include "backend/dnn_types.h" +#include "serial/headers/2dot4/gna_model_header.hpp" +#include "serial/headers/2dot6/gna_model_header.hpp" +#include "serial/headers/latest/gna_model_header.hpp" +#include "gna_data_types.hpp" + +#pragma pack(push, 1) + +namespace GNAPluginNS { +namespace Header2dot7 { + +/** + Maximal number of supported shape dimensions. + */ +#define GNA_SHAPE_MAXIMUM_NUMBER_OF_DIMENSIONS 8 + +/** + * @brief Header version 2.7 + */ +struct ModelHeader { + /** + *@brief MagicNumber – GNAM in ascii table, equals to hex 0x474e414d + */ + char gnam[4] = {}; + /** + * @brief if header size is not equal to sizeof ModelHeader - some reserved data append in the end of header + * usually it is an indicator of working with version of model different that is current export function produce + */ + uint32_t headerSize = 0u; + struct Version { + /** + * @details Version of format Major – unsigned int, ex: 0x0001 + * every change in the header or in the layers definition should be reflected in version change + * for backward compatibility new parsers can read old versions of model with certain restrictions + */ + uint16_t major = 2u; + /** + * @details Version of Format Minor – unsigned int, corresponding to build revision for example + * changes in minor version are not affected layout of model + */ + uint32_t minor = 7u; + } version; + /** + * @brief Memory required to be allocated using GNAAlloc() + */ + uint64_t gnaMemSize = 0ull; + /** + * @brief Number of GNA Layers + */ + uint64_t layersCount = 0ull; + /** + * @brief Grouping level + * This is depricted field and used for old models only (<=2.6) + */ + uint32_t nGroup = 0u; + + /** + * Convolution related setting - they are affecting input transformation + */ + uint32_t nRotateRows = 0u; + uint32_t nRotateColumns = 0u; + bool doRotateInput = false; + + uint32_t nInputs = 0u; + uint32_t nOutputs = 0u; + + /** + * Convolution related setting - they are affecting output transformation + */ + uint32_t nRotateOutputRows = 0u; + uint32_t nRotateOutputColumns = 0u; + bool doRotateOutput = false; + + uint32_t nTransposeInputs = 0u; + uint32_t nTransposeOutputs = 0u; + + /** + * Reserved Data might be here + */ + ModelHeader() = default; + ModelHeader(GNAPluginNS::Header2dot1::ModelHeader const &old) { + gnaMemSize = old.gnaMemSize; + layersCount = old.layersCount; + nGroup = old.nGroup; + nRotateRows = old.nRotateRows; + nRotateColumns = old.nRotateColumns; + nInputs = old.nInputs; + nOutputs = old.nOutputs; + version.minor = old.version.minor; + } + ModelHeader(GNAPluginNS::Header2dot4::ModelHeader const &old) { + gnaMemSize = old.gnaMemSize; + layersCount = old.layersCount; + nGroup = old.nGroup; + nRotateRows = old.nRotateRows; + nRotateColumns = old.nRotateColumns; + nInputs = old.nInputs; + nOutputs = old.nOutputs; + nRotateOutputRows = old.nRotateOutputRows; + nRotateOutputColumns = old.nRotateOutputColumns; + doRotateOutput = old.doRotateOutput; + version.minor = old.version.minor; + } +}; +#pragma pack(pop) + +/* + * In runtime endpoint mostly same as in serial version, except of descriptor field + */ +struct RuntimeEndPoint { + /** + * if scale factor is different then pased into infer , network might need to be requantized + */ + float scaleFactor = 0; + /** + * Pointer descriptor + */ + void* descriptor_ptr = nullptr; + /** + * Endpoint resolution in bytes. + */ + uint32_t element_size = 0; + /** + * Number of elements + */ + uint32_t elements_count = 0; + /** + * Offset in bytes of pointer descriptor + */ + uint64_t descriptor_offset = 0ull; + /** + Shape specifying dimension values. + */ + struct Shape { + /** + Number of dimensions or rank or order. + */ + uint32_t NumberOfDimensions = 0; + /** + array specifying value of each dimension. + Set all zeros for scalars. + */ + uint32_t Dimensions[GNA_SHAPE_MAXIMUM_NUMBER_OF_DIMENSIONS] = {0}; + } shape; + /** + * Blob layout + */ + uint8_t layout = InferenceEngine::Layout::NC; + /** + * Blob precision + */ + uint8_t precision = InferenceEngine::Precision::FP32; + + intel_dnn_orientation_t orientation = kDnnUnknownOrientation; + + RuntimeEndPoint() = default; + RuntimeEndPoint(const GNAPluginNS::Header2dot6::RuntimeEndPoint &old, uint32_t ngroup) { + scaleFactor = old.scaleFactor; + descriptor_ptr = old.descriptor_ptr; + element_size = old.element_size; + elements_count = old.elements_count; + orientation = old.orientation; + layout = InferenceEngine::Layout::NC; + precision = InferenceEngine::Precision::FP32; + descriptor_offset = old.descriptor_offset; + InferenceEngine::SizeVector dims = {ngroup, elements_count / ngroup}; + shape.NumberOfDimensions = static_cast(dims.size()); + for (auto i = 0; i < dims.size(); i++) { + shape.Dimensions[i] = dims[i]; + } + } + RuntimeEndPoint(double scaleFactor, + void* descriptor_ptr, + uint32_t element_size, + uint32_t elements_count, + Shape shape, + uint8_t layout, + uint8_t precision, + intel_dnn_orientation_t orientation) : scaleFactor(scaleFactor), + descriptor_ptr(descriptor_ptr), + element_size(element_size), + elements_count(elements_count), + shape(shape), + layout(layout), + precision(precision), + orientation(orientation) { } +}; +} // namespace Header2dot7 +} // namespace GNAPluginNS diff --git a/inference-engine/src/gna_plugin/serial/headers/latest/gna_model_header.hpp b/inference-engine/src/gna_plugin/serial/headers/latest/gna_model_header.hpp index 89292ab88afb17..7ec27b2caed386 100644 --- a/inference-engine/src/gna_plugin/serial/headers/latest/gna_model_header.hpp +++ b/inference-engine/src/gna_plugin/serial/headers/latest/gna_model_header.hpp @@ -4,11 +4,11 @@ #pragma once -#include "serial/headers/2dot6/gna_model_header.hpp" +#include "serial/headers/2dot7/gna_model_header.hpp" namespace GNAPluginNS { namespace HeaderLatest { -using ModelHeader = GNAPluginNS::Header2dot6::ModelHeader; -using RuntimeEndPoint = GNAPluginNS::Header2dot6::RuntimeEndPoint; +using ModelHeader = GNAPluginNS::Header2dot7::ModelHeader; +using RuntimeEndPoint = GNAPluginNS::Header2dot7::RuntimeEndPoint; } } diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/skip_tests_config.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/skip_tests_config.cpp index cb4cc459a95e28..a59ad83eaed76e 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/skip_tests_config.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/skip_tests_config.cpp @@ -60,8 +60,6 @@ std::vector disabledTestPatterns() { R"(.*ConstantResultSubgraphTest.*inPrc=(U8|I8|I32|U64|I64|BOOL).*)", // TODO: Issue 51528 R"(.*CachingSupport.*_(u8|i16)_.*)", - // TODO: Issue 51527 - R"(.*CachingSupport.*_batch2_.*)", // TODO: Issue 51525 R"(.*CachingSupport.*KSOFunction.*)", // TODO: Issue 57363 (Param -> Result subgraphs) diff --git a/inference-engine/tests/functional/plugin/shared/src/base/import_export_base/import_export_base.cpp b/inference-engine/tests/functional/plugin/shared/src/base/import_export_base/import_export_base.cpp index 0db7264cb74410..c30945dc914d83 100644 --- a/inference-engine/tests/functional/plugin/shared/src/base/import_export_base/import_export_base.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/base/import_export_base/import_export_base.cpp @@ -69,13 +69,16 @@ void ImportNetworkTestBase::Run() { for (const auto& next_input : importedExecNetwork.GetInputsInfo()) { ASSERT_NO_THROW(compiledExecNetwork.GetInputsInfo()[next_input.first]); + Compare(next_input.second->getTensorDesc(), compiledExecNetwork.GetInputsInfo()[next_input.first]->getTensorDesc()); } for (const auto& next_output : importedExecNetwork.GetOutputsInfo()) { ASSERT_NO_THROW(compiledExecNetwork.GetOutputsInfo()[next_output.first]); } auto importedOutputs = GetOutputs(); ASSERT_EQ(actualOutputs.size(), importedOutputs.size()); + for (size_t i = 0; i < actualOutputs.size(); i++) { + Compare(actualOutputs[i]->getTensorDesc(), importedOutputs[i]->getTensorDesc()); Compare(actualOutputs[i], importedOutputs[i]); } } diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/layer_test_utils.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/layer_test_utils.hpp index 9b8b78b6ef0912..9d13251574331f 100644 --- a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/layer_test_utils.hpp +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/layer_test_utils.hpp @@ -72,6 +72,8 @@ class LayerTestsCommon : public CommonTestUtils::TestsCommon { virtual void Compare(const InferenceEngine::Blob::Ptr &expected, const InferenceEngine::Blob::Ptr &actual); + virtual void Compare(const InferenceEngine::TensorDesc &actualDesc, const InferenceEngine::TensorDesc &expectedDesc); + virtual void SetRefMode(RefMode mode); std::shared_ptr GetFunction(); diff --git a/inference-engine/tests/functional/shared_test_classes/src/base/layer_test_utils.cpp b/inference-engine/tests/functional/shared_test_classes/src/base/layer_test_utils.cpp index cc3927b25c53b3..056826aff86a5f 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/base/layer_test_utils.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/base/layer_test_utils.cpp @@ -274,6 +274,17 @@ void LayerTestsCommon::Compare(const InferenceEngine::Blob::Ptr &expected, const } } +void LayerTestsCommon::Compare(const InferenceEngine::TensorDesc &actualDesc, const InferenceEngine::TensorDesc &expectedDesc) { + auto expectedDims = actualDesc.getDims(); + auto actualDims = expectedDesc.getDims(); + ASSERT_EQ(actualDims.size(), expectedDims.size()); + for (size_t j = 0; j < actualDims.size(); ++j) { + ASSERT_EQ(actualDims.at(j), expectedDims.at(j)); + } + ASSERT_EQ(actualDesc.getLayout(), expectedDesc.getLayout()); + ASSERT_EQ(actualDesc.getPrecision(), expectedDesc.getPrecision()); +} + void LayerTestsCommon::ConfigureNetwork() { for (const auto &in : cnnNetwork.getInputsInfo()) { if (inLayout != InferenceEngine::Layout::ANY) { From d4f323f3ddcafc6fbcb777c372a9222c437dd383 Mon Sep 17 00:00:00 2001 From: Maxim Shevtsov Date: Wed, 9 Jun 2021 22:22:47 +0300 Subject: [PATCH 052/178] fix wording (#6108) --- docs/IE_DG/Intro_to_Performance.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/IE_DG/Intro_to_Performance.md b/docs/IE_DG/Intro_to_Performance.md index 94d0173dbbe2b4..0c9457ed4bfd79 100644 --- a/docs/IE_DG/Intro_to_Performance.md +++ b/docs/IE_DG/Intro_to_Performance.md @@ -22,7 +22,8 @@ $ benchmark_app -m -enforcebf16=false Notice that for quantized (e.g. INT8) models the bfloat16 calculations (of the layers that remain in FP32) is disabled by default. Refer to the [CPU Plugin documentation](supported_plugins/CPU.md) for more details. -Similarly, the GPU device has a dedicated config key to enable FP16 execution of the layers that remain in FP32 in the quantized models (as the quantization is typically performed on the FP32 models), refer to the ENABLE_FP16_FOR_QUANTIZED_MODELS key in the [GPU Plugin documentation](supported_plugins/GPU.md) +Similarly, the GPU device automatically executes FP16 for the layers that remain in FP16 in the quantized models (assuming that the FP16 model was quantized). +Refer to the ENABLE_FP16_FOR_QUANTIZED_MODELS key in the [GPU Plugin documentation](supported_plugins/GPU.md). ## Latency vs. Throughput One way to increase computational efficiency is batching, which combines many (potentially tens) of From 6ec725baac0113570e34c955ca3dfff2ac14b13b Mon Sep 17 00:00:00 2001 From: Ilya Znamenskiy Date: Wed, 9 Jun 2021 23:39:51 +0300 Subject: [PATCH 053/178] Revert "[IE CLDNN] Use fsv4 when feature-depth is shallow (#4398)" (#6103) --- .../thirdparty/clDNN/src/program.cpp | 34 ------------------- 1 file changed, 34 deletions(-) diff --git a/inference-engine/thirdparty/clDNN/src/program.cpp b/inference-engine/thirdparty/clDNN/src/program.cpp index ef988cb12dac55..97eacdf9ae1122 100644 --- a/inference-engine/thirdparty/clDNN/src/program.cpp +++ b/inference-engine/thirdparty/clDNN/src/program.cpp @@ -1176,9 +1176,6 @@ void program_impl::set_layout_optimizer_attributes(layout_optimizer& lo) { size_t opt_deconv_layers_b_fs_zyx_fsv16 = 0; size_t total_crop_layers = 0; - size_t weighted_sum_feature_size = 0; - size_t weight_sum = 0; - for (auto& node : get_processing_order()) { auto &prim = *node; if (prim.type() == cldnn::convolution::type_id()) { @@ -1324,35 +1321,4 @@ void program_impl::set_layout_optimizer_attributes(layout_optimizer& lo) { if (should_use_bs_fs_yx_bsv16_fsv16) lo.set_optimization_attribute(layout_optimizer::optimization_attributes_type::bs_fs_yx_bsv16_fsv16_network, 1); - - - // This is to avoid using fsv16 for shallow-feature networks. - // This may not be exactly same as real execution graph as layer fusing is not done yet, - // but it is a reasonable approximation. - // Check the expected network efficiency after setting layer optimization attributes. - // If network depth is shallow, it is faster with fsv4. - for (auto& node : get_processing_order()) { - auto &prim = *node; - - if (prim.is_in_data_flow() && prim.type() == cldnn::convolution::type_id()) { - size_t num_feature = prim.get_output_layout().size.feature.vector()[0]; - size_t num_spatial = 1; - for (auto s : prim.get_output_layout().size.spatial.vector()) - num_spatial *= s; - - if (lo.get_preferred_format(prim) != format::b_fs_yx_fsv4) { - weight_sum += num_spatial; - weighted_sum_feature_size += num_spatial * num_feature; - } - } - } - - size_t weighted_average_feature_depth = weighted_sum_feature_size / std::max(weight_sum, static_cast(1)); - - // Need to confirm that weighted_average_feature_depth > 1 to keep unittest behavior. - if (is_quantized_int8_model && weighted_average_feature_depth < 8 && weighted_average_feature_depth > 1) { - lo.set_optimization_attribute(layout_optimizer::optimization_attributes_type::fs_b_yx_fsv32_network, 0); - lo.set_optimization_attribute(layout_optimizer::optimization_attributes_type::b_fs_yx_fsv16_network, 0); - lo.set_optimization_attribute(layout_optimizer::optimization_attributes_type::bs_fs_yx_bsv16_fsv16_network, 0); - } } From 17a899ed0c2eff8d6b289203dcb532e3f775a784 Mon Sep 17 00:00:00 2001 From: Alexander Zhogov Date: Thu, 10 Jun 2021 10:33:47 +0300 Subject: [PATCH 054/178] Change version to 2022.1 --- inference-engine/include/ie_version.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inference-engine/include/ie_version.hpp b/inference-engine/include/ie_version.hpp index 13215d0b68d253..10e649a09d32f8 100644 --- a/inference-engine/include/ie_version.hpp +++ b/inference-engine/include/ie_version.hpp @@ -20,8 +20,8 @@ * @brief Defines Inference Engine patch version */ -#define IE_VERSION_MAJOR 2021 -#define IE_VERSION_MINOR 4 +#define IE_VERSION_MAJOR 2022 +#define IE_VERSION_MINOR 1 #define IE_VERSION_PATCH 0 #include "ie_api.h" From 9f1720b0e4c73437818ed5c8ca0a827c42875eeb Mon Sep 17 00:00:00 2001 From: Tomasz Socha Date: Thu, 10 Jun 2021 10:54:42 +0200 Subject: [PATCH 055/178] [ONNX Importer] Remove quantized matmuls (#5043) --- ngraph/frontend/onnx_import/CMakeLists.txt | 4 -- .../onnx_import/src/op/matmul_integer.cpp | 41 ------------------- .../onnx_import/src/op/matmul_integer.hpp | 32 --------------- .../onnx_import/src/op/qlinear_matmul.cpp | 41 ------------------- .../onnx_import/src/op/qlinear_matmul.hpp | 25 ----------- .../frontend/onnx_import/src/ops_bridge.cpp | 4 -- 6 files changed, 147 deletions(-) delete mode 100644 ngraph/frontend/onnx_import/src/op/matmul_integer.cpp delete mode 100644 ngraph/frontend/onnx_import/src/op/matmul_integer.hpp delete mode 100644 ngraph/frontend/onnx_import/src/op/qlinear_matmul.cpp delete mode 100644 ngraph/frontend/onnx_import/src/op/qlinear_matmul.hpp diff --git a/ngraph/frontend/onnx_import/CMakeLists.txt b/ngraph/frontend/onnx_import/CMakeLists.txt index 9f728a3f7e808c..f3ef7b10fe799f 100644 --- a/ngraph/frontend/onnx_import/CMakeLists.txt +++ b/ngraph/frontend/onnx_import/CMakeLists.txt @@ -11,14 +11,10 @@ file(GLOB_RECURSE LIBRARY_PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h # Remove disabled ops list(REMOVE_ITEM LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/op/conv_integer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/op/matmul_integer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/op/qlinear_matmul.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/op/quant_conv.cpp ) list(REMOVE_ITEM LIBRARY_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/op/conv_integer.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/op/matmul_integer.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/op/qlinear_matmul.hpp ${CMAKE_CURRENT_SOURCE_DIR}/src/op/quant_conv.hpp ) diff --git a/ngraph/frontend/onnx_import/src/op/matmul_integer.cpp b/ngraph/frontend/onnx_import/src/op/matmul_integer.cpp deleted file mode 100644 index 231256950f9aba..00000000000000 --- a/ngraph/frontend/onnx_import/src/op/matmul_integer.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "op/matmul_integer.hpp" -#include "ngraph/builder/matmul_factory.hpp" -#include "ngraph/log.hpp" - -namespace ngraph -{ - namespace onnx_import - { - namespace op - { - namespace set_1 - { - OutputVector matmul_integer(const Node& node) - { - auto ng_inputs = node.get_ng_inputs(); - auto factory = builder::MatmulIntegerFactory( - OutputVector(std::begin(ng_inputs), std::end(ng_inputs))); - std::size_t left_rank{ng_inputs.at(0).get_shape().size()}; - std::size_t right_rank{ng_inputs.at(1).get_shape().size()}; - - if (left_rank == 0 || right_rank == 0) - { - NGRAPH_WARN - << (node) << " " - << "ONNX standard doesn't allow scalar operands, however nGraph " - "accepts them. Consider use of element-wise multiplication instead " - "to conform with ONNX standard."; - } - return factory.make_matmul_op(); - } - } // namespace set_1 - - } // namespace op - - } // namespace onnx_import - -} // namespace ngraph diff --git a/ngraph/frontend/onnx_import/src/op/matmul_integer.hpp b/ngraph/frontend/onnx_import/src/op/matmul_integer.hpp deleted file mode 100644 index 8e40e3b608b83b..00000000000000 --- a/ngraph/frontend/onnx_import/src/op/matmul_integer.hpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "ngraph/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph -{ - namespace onnx_import - { - namespace op - { - namespace set_1 - { - /// \brief Performs ONNX MatMulInteger operation. - /// - /// \param node The ONNX node object representing this operation. - /// - /// \return The vector containing Ngraph nodes producing output of quantized ONNX - /// matrix multiplication operation. - OutputVector matmul_integer(const Node& node); - - } // namespace set_1 - - } // namespace op - - } // namespace onnx_import - -} // namespace ngraph diff --git a/ngraph/frontend/onnx_import/src/op/qlinear_matmul.cpp b/ngraph/frontend/onnx_import/src/op/qlinear_matmul.cpp deleted file mode 100644 index 1baafa827ca1b2..00000000000000 --- a/ngraph/frontend/onnx_import/src/op/qlinear_matmul.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "op/qlinear_matmul.hpp" -#include "ngraph/builder/matmul_factory.hpp" -#include "ngraph/log.hpp" - -namespace ngraph -{ - namespace onnx_import - { - namespace op - { - namespace set_1 - { - OutputVector qlinear_matmul(const Node& node) - { - auto ng_inputs = node.get_ng_inputs(); - auto factory = builder::QLinearMatmulFactory( - (OutputVector(std::begin(ng_inputs), std::end(ng_inputs)))); - std::size_t left_rank{ng_inputs.at(0).get_shape().size()}; - std::size_t right_rank{ng_inputs.at(1).get_shape().size()}; - - if (left_rank == 0 || right_rank == 0) - { - NGRAPH_WARN - << (node) << " " - << "ONNX standard doesn't allow scalar operands, however nGraph " - "accepts them. Consider use of element-wise multiplication instead " - "to conform with ONNX standard."; - } - return factory.make_matmul_op(); - } - } // namespace set_1 - - } // namespace op - - } // namespace onnx_import - -} // namespace ngraph diff --git a/ngraph/frontend/onnx_import/src/op/qlinear_matmul.hpp b/ngraph/frontend/onnx_import/src/op/qlinear_matmul.hpp deleted file mode 100644 index 8e38f33683654b..00000000000000 --- a/ngraph/frontend/onnx_import/src/op/qlinear_matmul.hpp +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "ngraph/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph -{ - namespace onnx_import - { - namespace op - { - namespace set_1 - { - OutputVector qlinear_matmul(const Node& node); - } // namespace set_1 - - } // namespace op - - } // namespace onnx_import - -} // namespace ngraph diff --git a/ngraph/frontend/onnx_import/src/ops_bridge.cpp b/ngraph/frontend/onnx_import/src/ops_bridge.cpp index b807a31212db64..f7864360ba7b43 100644 --- a/ngraph/frontend/onnx_import/src/ops_bridge.cpp +++ b/ngraph/frontend/onnx_import/src/ops_bridge.cpp @@ -73,7 +73,6 @@ #include "op/lrn.hpp" #include "op/lstm.hpp" #include "op/matmul.hpp" -//#include "op/matmul_integer.hpp" #include "op/max.hpp" #include "op/max_pool.hpp" #include "op/mean.hpp" @@ -90,7 +89,6 @@ #include "op/pad.hpp" #include "op/pow.hpp" #include "op/prelu.hpp" -//#include "op/qlinear_matmul.hpp" // #include "op/quant_conv.hpp" #include "op/quantize_linear.hpp" #include "op/range.hpp" @@ -376,7 +374,6 @@ namespace ngraph REGISTER_OPERATOR("LRN", 1, lrn); REGISTER_OPERATOR("LSTM", 1, lstm); REGISTER_OPERATOR("MatMul", 1, matmul); - // REGISTER_OPERATOR("MatMulInteger", 1, matmul_integer); REGISTER_OPERATOR("MaxPool", 1, max_pool); REGISTER_OPERATOR("Max", 1, max); REGISTER_OPERATOR("Max", 8, max); @@ -399,7 +396,6 @@ namespace ngraph REGISTER_OPERATOR("Pow", 1, pow); REGISTER_OPERATOR("PRelu", 1, prelu); // REGISTER_OPERATOR("QLinearConv", 1, quant_conv); - // REGISTER_OPERATOR("QLinearMatMul", 1, qlinear_matmul); REGISTER_OPERATOR("QuantizeLinear", 1, quantize_linear); REGISTER_OPERATOR("QuantizeLinear", 13, quantize_linear); REGISTER_OPERATOR("Range", 1, range); From 6040d433d395ea3df5242fcef3e62f31136cbec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Do=C5=82bniak?= Date: Thu, 10 Jun 2021 11:06:30 +0200 Subject: [PATCH 056/178] Fix for the paddings attribute handling for ONNX Pad@1 (#6101) --- ngraph/frontend/onnx_import/src/utils/convpool.cpp | 5 +++++ ngraph/python/tests/__init__.py | 1 - ngraph/python/tests/test_onnx/test_ops_convpool.py | 5 ++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ngraph/frontend/onnx_import/src/utils/convpool.cpp b/ngraph/frontend/onnx_import/src/utils/convpool.cpp index 64644c5e11e96b..52924d78116334 100644 --- a/ngraph/frontend/onnx_import/src/utils/convpool.cpp +++ b/ngraph/frontend/onnx_import/src/utils/convpool.cpp @@ -130,6 +130,11 @@ namespace ngraph auto pads_int64 = node.get_attribute_value>("pads"); pads = CoordinateDiff{std::begin(pads_int64), std::end(pads_int64)}; } + else if (node.has_attribute("paddings")) + { + auto pads_int64 = node.get_attribute_value>("paddings"); + pads = CoordinateDiff{std::begin(pads_int64), std::end(pads_int64)}; + } if (pads.size() == kernel_rank * 2) { diff --git a/ngraph/python/tests/__init__.py b/ngraph/python/tests/__init__.py index c179f312f1e7e8..f54930f40d92e5 100644 --- a/ngraph/python/tests/__init__.py +++ b/ngraph/python/tests/__init__.py @@ -47,7 +47,6 @@ def xfail_test(reason="Mark the test as expected to fail", strict=True): xfail_issue_33581 = xfail_test(reason="RuntimeError: nGraph does not support the following ONNX operations:" "GatherElements") xfail_issue_33633 = xfail_test(reason="MaxPool: dilations unsupported") -xfail_issue_35911 = xfail_test(reason="Assertion error: Pad model mismatch error") xfail_issue_35923 = xfail_test(reason="RuntimeError: PReLU without weights is not supported") xfail_issue_35927 = xfail_test(reason="RuntimeError: B has zero dimension that is not allowable") xfail_issue_36486 = xfail_test(reason="RuntimeError: HardSigmoid operation should be converted " diff --git a/ngraph/python/tests/test_onnx/test_ops_convpool.py b/ngraph/python/tests/test_onnx/test_ops_convpool.py index 7a507a2b4e000e..6637a06463b19c 100644 --- a/ngraph/python/tests/test_onnx/test_ops_convpool.py +++ b/ngraph/python/tests/test_onnx/test_ops_convpool.py @@ -5,10 +5,10 @@ import onnx import pytest from onnx.helper import make_graph, make_model, make_node, make_tensor_value_info +from onnx.onnx_cpp2py_export.checker import ValidationError from tests.runtime import get_runtime from tests.test_onnx.utils import get_node_model, import_onnx_model, run_model, run_node -from tests import xfail_issue_35911 @pytest.fixture @@ -257,7 +257,6 @@ def test_2d_conv_transpose(): ) -@xfail_issue_35911 def test_pad_opset_1(): x = np.ones((2, 2), dtype=np.float32) y = np.pad(x, pad_width=1, mode="constant") @@ -281,7 +280,7 @@ def test_pad_opset_1(): # no paddings arttribute model = get_node_model("Pad", x) - with pytest.raises(RuntimeError): + with pytest.raises(ValidationError): import_onnx_model(model) From c7141973ece493f932c6b8f305372328d9be1aae Mon Sep 17 00:00:00 2001 From: Alexander Zhogov Date: Thu, 10 Jun 2021 12:46:24 +0300 Subject: [PATCH 057/178] GitHub CI: Fix checking commits in case of no email --- .github/org_control/check_pr.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/org_control/check_pr.py b/.github/org_control/check_pr.py index 85e5b4e34c00f4..7bb8f89dd602f4 100644 --- a/.github/org_control/check_pr.py +++ b/.github/org_control/check_pr.py @@ -139,7 +139,7 @@ def update_labels(gh_api, pull, non_org_intel_pr_users, non_org_pr_users): def get_wrong_commits(pull): """Returns commits with incorrect user and email""" - pr_author_email = pull.user.email.lower() + pr_author_email = (pull.user.email or "").lower() print("GitHub PR author email:", pr_author_email) print("Check commits:") wrong_commits = set() @@ -147,7 +147,7 @@ def get_wrong_commits(pull): # import pprint; pprint.pprint(commit.raw_data) print("Commit SHA:", commit.sha) # Use raw data because commit author can be non GitHub user - commit_email = commit.raw_data["commit"]["author"]["email"].lower() + commit_email = (commit.raw_data["commit"]["author"]["email"] or "").lower() print(" Commit email:", commit_email) if not github_api.is_valid_user(commit.author): print( From c3ad7dc2a44b571a4c75c3e8809a2b5b8a1c16b2 Mon Sep 17 00:00:00 2001 From: Maxim Vafin Date: Thu, 10 Jun 2021 18:09:35 +0300 Subject: [PATCH 058/178] Specify AdaptiveAvgPool-8 and AdaptiveMaxPool-8 (#5773) * Specify AdaptiveAvgPool-8 and AdaptiveMaxPool-8 * Apply review feedback * Describe indices output * Apply review feedback * Apply review feedback * Update AdaptiveMaxPool_8.md * Apply suggestions from code review Co-authored-by: Anastasiya Ageeva * Apply review feedback Co-authored-by: Anastasiya Ageeva --- docs/doxygen/ie_docs.xml | 3 + docs/ops/opset8.md | 169 ++++++++++++++++++++++++++ docs/ops/pooling/AdaptiveAvgPool_8.md | 70 +++++++++++ docs/ops/pooling/AdaptiveMaxPool_8.md | 87 +++++++++++++ 4 files changed, 329 insertions(+) create mode 100644 docs/ops/opset8.md create mode 100644 docs/ops/pooling/AdaptiveAvgPool_8.md create mode 100644 docs/ops/pooling/AdaptiveMaxPool_8.md diff --git a/docs/doxygen/ie_docs.xml b/docs/doxygen/ie_docs.xml index bb006c9f01c630..503f9f3898601b 100644 --- a/docs/doxygen/ie_docs.xml +++ b/docs/doxygen/ie_docs.xml @@ -88,6 +88,7 @@ limitations under the License. + @@ -100,6 +101,8 @@ limitations under the License. + + diff --git a/docs/ops/opset8.md b/docs/ops/opset8.md new file mode 100644 index 00000000000000..8f43927b5ec360 --- /dev/null +++ b/docs/ops/opset8.md @@ -0,0 +1,169 @@ +# Operation Set `opset8` Specification {#openvino_docs_ops_opset8} + +This specification document describes the `opset8` operation set supported in OpenVINO™. +Support for each particular operation from the list below depends on the capabilities of an inference plugin +and may vary among different hardware platforms and devices. Examples of operation instances are provided as IR V10 xml +snippets. Such IR is generated by the Model Optimizer. The semantics match corresponding nGraph operation classes +declared in `namespace opset8`. + + +## Table of Contents + +* [Abs](arithmetic/Abs_1.md) +* [Acos](arithmetic/Acos_1.md) +* [Acosh](arithmetic/Acosh_3.md) +* [AdaptiveAvgPool](pooling/AdaptiveAvgPool_8.md) +* [AdaptiveMaxPool](pooling/AdaptiveMaxPool_8.md) +* [Add](arithmetic/Add_1.md) +* [Asin](arithmetic/Asin_1.md) +* [Asinh](arithmetic/Asinh_3.md) +* [Assign](infrastructure/Assign_3.md) +* [Atan](arithmetic/Atan_1.md) +* [Atanh](arithmetic/Atanh_3.md) +* [AvgPool](pooling/AvgPool_1.md) +* [BatchNormInference](normalization/BatchNormInference_5.md) +* [BatchToSpace](movement/BatchToSpace_2.md) +* [BinaryConvolution](convolution/BinaryConvolution_1.md) +* [Broadcast](movement/Broadcast_3.md) +* [Bucketize](condition/Bucketize_3.md) +* [CTCGreedyDecoder](sequence/CTCGreedyDecoder_1.md) +* [CTCGreedyDecoderSeqLen](sequence/CTCGreedyDecoderSeqLen_6.md) +* [CTCLoss](sequence/CTCLoss_4.md) +* [Ceiling](arithmetic/Ceiling_1.md) +* [Clamp](activation/Clamp_1.md) +* [Concat](movement/Concat_1.md) +* [Constant](infrastructure/Constant_1.md) +* [Convert](type/Convert_1.md) +* [ConvertLike](type/ConvertLike_1.md) +* [Convolution](convolution/Convolution_1.md) +* [ConvolutionBackpropData](convolution/ConvolutionBackpropData_1.md) +* [Cos](arithmetic/Cos_1.md) +* [Cosh](arithmetic/Cosh_1.md) +* [CumSum](arithmetic/CumSum_3.md) +* [DeformableConvolution](convolution/DeformableConvolution_1.md) +* [DeformablePSROIPooling](detection/DeformablePSROIPooling_1.md) +* [DepthToSpace](movement/DepthToSpace_1.md) +* [DetectionOutput](detection/DetectionOutput_1.md) +* [DFT](signals/DFT_7.md) +* [Divide](arithmetic/Divide_1.md) +* [Einsum](matrix/Einsum_7.md) +* [Elu](activation/Elu_1.md) +* [EmbeddingBagOffsetsSum](sparse/EmbeddingBagOffsetsSum_3.md) +* [EmbeddingBagPackedSum](sparse/EmbeddingBagPackedSum_3.md) +* [EmbeddingSegmentsSum](sparse/EmbeddingSegmentsSum_3.md) +* [Equal](comparison/Equal_1.md) +* [Erf](arithmetic/Erf_1.md) +* [Exp](activation/Exp_1.md) +* [ExperimentalDetectronDetectionOutput_6](detection/ExperimentalDetectronDetectionOutput_6.md) +* [ExperimentalDetectronGenerateProposalsSingleImage_6](detection/ExperimentalDetectronGenerateProposalsSingleImage_6.md) +* [ExperimentalDetectronPriorGridGenerator_6](detection/ExperimentalDetectronPriorGridGenerator_6.md) +* [ExperimentalDetectronROIFeatureExtractor_6](detection/ExperimentalDetectronROIFeatureExtractor_6.md) +* [ExperimentalDetectronTopKROIs_6](sort/ExperimentalDetectronTopKROIs_6.md) +* [ExtractImagePatches](movement/ExtractImagePatches_3.md) +* [FakeQuantize](quantization/FakeQuantize_1.md) +* [Floor](arithmetic/Floor_1.md) +* [FloorMod](arithmetic/FloorMod_1.md) +* [Gather](movement/Gather_7.md) +* [GatherElements](movement/GatherElements_6.md) +* [GatherND_5](movement/GatherND_5.md) +* [GatherTree](movement/GatherTree_1.md) +* [Gelu](activation/GELU_7.md) +* [Greater](comparison/Greater_1.md) +* [GreaterEqual](comparison/GreaterEqual_1.md) +* [GRN](normalization/GRN_1.md) +* [GroupConvolution](convolution/GroupConvolution_1.md) +* [GroupConvolutionBackpropData](convolution/GroupConvolutionBackpropData_1.md) +* [GRUCell](sequence/GRUCell_3.md) +* [GRUSequence](sequence/GRUSequence_5.md) +* [HardSigmoid](activation/HardSigmoid_1.md) +* [HSigmoid](activation/HSigmoid_5.md) +* [HSwish](activation/HSwish_4.md) +* [IDFT](signals/IDFT_7.md) +* [Interpolate](image/Interpolate_4.md) +* [Less](comparison/Less_1.md) +* [LessEqual](comparison/LessEqual_1.md) +* [Log](arithmetic/Log_1.md) +* [LogicalAnd](logical/LogicalAnd_1.md) +* [LogicalNot](logical/LogicalNot_1.md) +* [LogicalOr](logical/LogicalOr_1.md) +* [LogicalXor](logical/LogicalXor_1.md) +* [LogSoftmax](activation/LogSoftmax_5.md) +* [Loop](infrastructure/Loop_5.md) +* [LRN](normalization/LRN_1.md) +* [LSTMCell](sequence/LSTMCell_1.md) +* [LSTMSequence](sequence/LSTMSequence_1.md) +* [MatMul](matrix/MatMul_1.md) +* [MaxPool](pooling/MaxPool_1.md) +* [Maximum](arithmetic/Maximum_1.md) +* [Minimum](arithmetic/Minimum_1.md) +* [Mish](activation/Mish_4.md) +* [Mod](arithmetic/Mod_1.md) +* [MVN](normalization/MVN_6.md) +* [Multiply](arithmetic/Multiply_1.md) +* [Negative](arithmetic/Negative_1.md) +* [NonMaxSuppression](sort/NonMaxSuppression_5.md) +* [NonZero](condition/NonZero_3.md) +* [NormalizeL2](normalization/NormalizeL2_1.md) +* [NotEqual](comparison/NotEqual_1.md) +* [OneHot](sequence/OneHot_1.md) +* [Pad](movement/Pad_1.md) +* [Parameter](infrastructure/Parameter_1.md) +* [Power](arithmetic/Power_1.md) +* [PReLU](activation/PReLU_1.md) +* [PriorBoxClustered](detection/PriorBoxClustered_1.md) +* [PriorBox](detection/PriorBox_1.md) +* [Proposal](detection/Proposal_4.md) +* [PSROIPooling](detection/PSROIPooling_1.md) +* [Range](generation/Range_4.md) +* [ReLU](activation/ReLU_1.md) +* [ReadValue](infrastructure/ReadValue_3.md) +* [ReduceL1](reduction/ReduceL1_4.md) +* [ReduceL2](reduction/ReduceL2_4.md) +* [ReduceLogicalAnd](reduction/ReduceLogicalAnd_1.md) +* [ReduceLogicalOr](reduction/ReduceLogicalOr_1.md) +* [ReduceMax](reduction/ReduceMax_1.md) +* [ReduceMean](reduction/ReduceMean_1.md) +* [ReduceMin](reduction/ReduceMin_1.md) +* [ReduceProd](reduction/ReduceProd_1.md) +* [ReduceSum](reduction/ReduceSum_1.md) +* [RegionYolo](detection/RegionYolo_1.md) +* [ReorgYolo](detection/ReorgYolo_1.md) +* [Reshape](shape/Reshape_1.md) +* [Result](infrastructure/Result_1.md) +* [ReverseSequence](movement/ReverseSequence_1.md) +* [RNNCell](sequence/RNNCell_3.md) +* [RNNSequence](sequence/RNNSequence_5.md) +* [ROIAlign](detection/ROIAlign_3.md) +* [ROIPooling](detection/ROIPooling_1.md) +* [Roll](movement/Roll_7.md) +* [Round](arithmetic/Round_5.md) +* [ScatterElementsUpdate](movement/ScatterElementsUpdate_3.md) +* [ScatterNDUpdate](movement/ScatterNDUpdate_3.md) +* [ScatterUpdate](movement/ScatterUpdate_3.md) +* [Select](condition/Select_1.md) +* [Selu](activation/Selu_1.md) +* [ShapeOf](shape/ShapeOf_3.md) +* [ShuffleChannels](movement/ShuffleChannels_1.md) +* [Sigmoid](activation/Sigmoid_1.md) +* [Sign](arithmetic/Sign_1.md) +* [Sin](arithmetic/Sin_1.md) +* [Sinh](arithmetic/Sinh_1.md) +* [SoftMax](activation/SoftMax_1.md) +* [SoftPlus](activation/SoftPlus_4.md) +* [SpaceToBatch](movement/SpaceToBatch_2.md) +* [SpaceToDepth](movement/SpaceToDepth_1.md) +* [Split](movement/Split_1.md) +* [Sqrt](arithmetic/Sqrt_1.md) +* [SquaredDifference](arithmetic/SquaredDifference_1.md) +* [Squeeze](shape/Squeeze_1.md) +* [StridedSlice](movement/StridedSlice_1.md) +* [Subtract](arithmetic/Subtract_1.md) +* [Swish](activation/Swish_4.md) +* [Tan](arithmetic/Tan_1.md) +* [Tanh](arithmetic/Tanh_1.md) +* [TensorIterator](infrastructure/TensorIterator_1.md) +* [Tile](movement/Tile_1.md) +* [TopK](sort/TopK_3.md) +* [Transpose](movement/Transpose_1.md) +* [Unsqueeze](shape/Unsqueeze_1.md) +* [VariadicSplit](movement/VariadicSplit_1.md) diff --git a/docs/ops/pooling/AdaptiveAvgPool_8.md b/docs/ops/pooling/AdaptiveAvgPool_8.md new file mode 100644 index 00000000000000..beb2ec30492d3e --- /dev/null +++ b/docs/ops/pooling/AdaptiveAvgPool_8.md @@ -0,0 +1,70 @@ +## AdaptiveAvgPool {#openvino_docs_ops_pooling_AdaptiveAvgPool_8} + +**Versioned name**: *AdaptiveAvgPool-8* + +**Category**: *Pooling* + +**Short description**: Applies average pooling with adaptive kernel size over the input. + +**Detailed description**: This operation calculates the output based on the first input and `output_size` determined by the second input. +The kernel dimensions are calculated using the following formulae for the `NCDHW` input case: + +\f[ +\begin{array}{lcl} +d_{start} &=& floor(i*D_{in}/D_{out})\\ +d_{end} &=& ceil((i+1)*D_{in}/D_{out})\\ +h_{start} &=& floor(j*H_{in}/H_{out})\\ +h_{end} &=& ceil((j+1)*H_{in}/H_{out})\\ +w_{start} &=& floor(k*W_{in}/W_{out})\\ +w_{end} &=& ceil((k+1)*W_{in}/W_{out}) +\end{array} +\f] + +The output is calculated with the following formula: + +\f[ +Output(i,j,k) = \frac{Input[d_{start}:d_{end}, h_{start}:h_{end}, w_{start}:w_{end}]}{(d_{end}-d_{start})*(h_{end}-h_{start})*(w_{end}-w_{start})} +\f] + +**Inputs**: + +* **1**: 3D, 4D, or 5D input tensor of shape `[N, C, H]`, `[N, C, H, W]` or `[N, C, D, H, W]` and type *T*. Required. +* **2**: 1D tensor describing output shape for spatial dimensions. Can be `[H_out]` for 3D input, `[H_out, W_out]` for 4D input, `[D_out, H_out, W_out]` for 5D input and of type *T_SHAPE*. Required. + +**Outputs**: + +* **1**: Output of type *T* and shape `[N, C, H_out]`, `[N, C, H_out, W_out]` or `[N, C, D_out, H_out, W_out]`. + +**Types** + +* *T*: floating-point type. +* *T_SHAPE*: `int32` or `int64`. + +**Examples** + +```xml + + + + + 1 + 3 + 32 + 32 + + + + + 2 + + + + + 1 + 3 + 16 + 16 + + + +``` diff --git a/docs/ops/pooling/AdaptiveMaxPool_8.md b/docs/ops/pooling/AdaptiveMaxPool_8.md new file mode 100644 index 00000000000000..d7ad9a42412bd9 --- /dev/null +++ b/docs/ops/pooling/AdaptiveMaxPool_8.md @@ -0,0 +1,87 @@ +## AdaptiveMaxPool {#openvino_docs_ops_pooling_AdaptiveMaxPool_8} + +**Versioned name**: *AdaptiveMaxPool-8* + +**Category**: *Pooling* + +**Short description**: Applies max pooling with adaptive kernel size over the input. + +**Detailed description**: This operation calculates the output based on the first input and `output_size` determined by the second input. +The kernel dimensions are calculated using the following formulae for the `NCDHW` input case: + +\f[ +\begin{array}{lcl} +d_{start} &=& floor(i*D_{in}/D_{out})\\ +d_{end} &=& ceil((i+1)*D_{in}/D_{out})\\ +h_{start} &=& floor(j*H_{in}/H_{out})\\ +h_{end} &=& ceil((j+1)*H_{in}/H_{out})\\ +w_{start} &=& floor(k*W_{in}/W_{out})\\ +w_{end} &=& ceil((k+1)*W_{in}/W_{out}) +\end{array} +\f] + +The output is calculated following this formula: + +\f[ +Output(i,j,k) = max(Input[d_{start}:d_{end}, h_{start}:h_{end}, w_{start}:w_{end}]) +\f] + +**Attributes**: + +* *index_element_type* + + * **Description**: the type of the second output containing indices + * **Range of values**: "i64" or "i32" + * **Type**: string + * **Default value**: "i64" + * **Required**: *No* + +**Inputs**: + +* **1**: 3D, 4D, or 5D input tensor of shape `[N, C, H]`, `[N, C, H, W]` or `[N, C, D, H, W]` and type *T*. Required. +* **2**: 1D tensor describing output shape for spatial dimensions. Can be `[H_out]` for 3D input, `[H_out, W_out]` for 4D input, `[D_out, H_out, W_out]` for 5D input and of type *T_SHAPE*. Required. + +**Outputs**: + +* **1**: Output of type *T* and shape `[N, C, H_out]`, `[N, C, H_out, W_out]` or `[N, C, D_out, H_out, W_out]`. +* **2**: Output of type specified by *index_element_type* and same shape as the first output containing indices of elements in the first output. The values of indices are computed as if input was flatten 1-D tensor, so the values are in the range `[0, N * C * H * W * D)`. + +**Types** + +* *T*: floating-point type. +* *T_SHAPE*: `int32` or `int64`. + +**Examples** + +```xml + + + + + 1 + 3 + 32 + 32 + + + + + 2 + + + + + 1 + 3 + 16 + 16 + + + 1 + 3 + 16 + 16 + + + +``` From 9e9e33e772602d76f2ad23ad0c1b07292f116990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Do=C5=82bniak?= Date: Thu, 10 Jun 2021 17:13:56 +0200 Subject: [PATCH 059/178] Axes input handling in ReduceSum evaluator (#5614) --- ngraph/core/src/op/reduce_sum.cpp | 12 ++++- ngraph/core/src/op/util/evaluate_helpers.hpp | 27 +++++++++++ .../onnx/reduce_sum_13_axes_as_input.prototxt | 15 +++--- ngraph/test/onnx/onnx_import.in.cpp | 47 +++++++------------ .../test/util/engine/interpreter_engine.cpp | 10 ++-- 5 files changed, 67 insertions(+), 44 deletions(-) create mode 100644 ngraph/core/src/op/util/evaluate_helpers.hpp diff --git a/ngraph/core/src/op/reduce_sum.cpp b/ngraph/core/src/op/reduce_sum.cpp index 1eab2dcefb86b0..70c2b39ddc064b 100644 --- a/ngraph/core/src/op/reduce_sum.cpp +++ b/ngraph/core/src/op/reduce_sum.cpp @@ -6,9 +6,11 @@ #include "itt.hpp" #include "ngraph/graph_util.hpp" #include "ngraph/op/broadcast.hpp" +#include "ngraph/op/util/op_types.hpp" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/runtime/reference/sum.hpp" #include "ngraph/shape_util.hpp" +#include "util/evaluate_helpers.hpp" using namespace std; using namespace ngraph; @@ -73,7 +75,15 @@ bool op::v1::ReduceSum::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { NGRAPH_OP_SCOPE(v1_ReduceSum_evaluate); - return reduce_sum::evaluate_sum(inputs[0], outputs[0], get_reduction_axes(), get_keep_dims()); + + NGRAPH_CHECK(inputs.size() == 2, + "The ReduceSum operation expects 2 input tensors. Got: ", + inputs.size()); + + const auto reduction_axes = get_normalized_axes_from_tensor( + inputs[1], get_input_partial_shape(0).rank(), get_friendly_name()); + + return reduce_sum::evaluate_sum(inputs[0], outputs[0], reduction_axes, get_keep_dims()); } bool op::v1::ReduceSum::has_evaluate() const diff --git a/ngraph/core/src/op/util/evaluate_helpers.hpp b/ngraph/core/src/op/util/evaluate_helpers.hpp new file mode 100644 index 00000000000000..d67a212f1574b6 --- /dev/null +++ b/ngraph/core/src/op/util/evaluate_helpers.hpp @@ -0,0 +1,27 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "ngraph/axis_set.hpp" +#include "ngraph/descriptor/tensor.hpp" +#include "ngraph/util.hpp" +#include "ngraph/validation_util.hpp" + +namespace ngraph +{ + /// \brief Extracts the tensor data and returns a set of normalized axes created out of it. + /// + /// \param tensor A pointer to a HostTensor object containing the raw axes data + /// \param rank Rank of an operator's input data tensor (used to normalize the axes) + /// \param node_description An identifier of the operator's node (used to report errors) + /// + /// \return Normalized (positive only) axes as an AxisSet object. + AxisSet get_normalized_axes_from_tensor(const HostTensorPtr tensor, + const ngraph::Rank& rank, + const std::string& node_description) + { + const auto axes_vector = host_tensor_2_vector(tensor); + const auto normalized_axes = ngraph::normalize_axes(node_description, axes_vector, rank); + return AxisSet{normalized_axes}; + } +} // namespace ngraph diff --git a/ngraph/test/models/onnx/reduce_sum_13_axes_as_input.prototxt b/ngraph/test/models/onnx/reduce_sum_13_axes_as_input.prototxt index 6a458e7439356d..273e436803a42a 100644 --- a/ngraph/test/models/onnx/reduce_sum_13_axes_as_input.prototxt +++ b/ngraph/test/models/onnx/reduce_sum_13_axes_as_input.prototxt @@ -15,16 +15,10 @@ graph { elem_type: 1 shape { dim { - dim_value: 1 + dim_value: 2 } dim { - dim_value: 1 - } - dim { - dim_value: 4 - } - dim { - dim_value: 4 + dim_value: 2 } } } @@ -37,7 +31,7 @@ graph { elem_type: 7 shape { dim { - dim_value: 4 + dim_value: 1 } } } @@ -50,6 +44,9 @@ graph { tensor_type { elem_type: 1 shape { + dim { + dim_value: 2 + } dim { dim_value: 1 } diff --git a/ngraph/test/onnx/onnx_import.in.cpp b/ngraph/test/onnx/onnx_import.in.cpp index a8522c08fa1729..849a015c4c3807 100644 --- a/ngraph/test/onnx/onnx_import.in.cpp +++ b/ngraph/test/onnx/onnx_import.in.cpp @@ -1238,25 +1238,10 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reduce_sum_13_axes_as_input) file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_sum_13_axes_as_input.prototxt")); auto test_case = test::TestCase(function); - test_case.add_input({1.0f, - 1.0f, - 1.0f, - 1.0f, - 1.0f, - 1.0f, - 1.0f, - 1.0f, - 1.0f, - 1.0f, - 1.0f, - 1.0f, - 1.0f, - 1.0f, - 1.0f, - 1.0f}); - test_case.add_input({0, 1, 2, 3}); + test_case.add_input({1.0f, 2.0f, 3.0f, 4.0f}); + test_case.add_input({1}); - test_case.add_expected_output(Shape{1, 1, 1, 1}, {16.0f}); + test_case.add_expected_output(Shape{2, 1}, {3.0f, 7.0f}); test_case.run(); } @@ -3123,7 +3108,7 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_model_mod_sign) test_case.add_input({-4, 7, 5, 4, -7, 8}); test_case.add_input({2, -3, 8, -2, 3, 5}); - test_case.add_expected_output(Shape{6}, {0, -2, 5, 0, 2, 3}); + test_case.add_expected_output(Shape{6}, {0, -2, 5, 0, 2, 3}); test_case.run(); } @@ -3136,7 +3121,7 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_model_mod_sign_i64) test_case.add_input({-4, 7, 5, 4, -7, 8}); test_case.add_input({2, -3, 8, -2, 3, 5}); - test_case.add_expected_output(Shape{6}, {0, -2, 5, 0, 2, 3}); + test_case.add_expected_output(Shape{6}, {0, -2, 5, 0, 2, 3}); test_case.run(); } @@ -3159,13 +3144,15 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_model_mod_sign_f32) try { const auto function = onnx_import::import_onnx_model( - file_util::path_join(SERIALIZED_ZOO, "onnx/mod_sign_f32.prototxt")); + file_util::path_join(SERIALIZED_ZOO, "onnx/mod_sign_f32.prototxt")); FAIL() << "Expected exception was not thrown"; } catch (const ngraph::ngraph_error& e) { - EXPECT_HAS_SUBSTRING(e.what(), - std::string("If the input type is floating point, then `fmod` attribute must be set to 1.")); + EXPECT_HAS_SUBSTRING( + e.what(), + std::string( + "If the input type is floating point, then `fmod` attribute must be set to 1.")); } catch (...) { @@ -3207,7 +3194,8 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_model_mod_sign_fmod_f32) test_case.add_input({-4.3, 7.2, 5.0, 4.3, -7.2, 8.0}); test_case.add_input({2.1, -3.4, 8.0, -2.1, 3.4, 5.0}); - test_case.add_expected_output(Shape{6}, {-0.10000038, 0.39999962, 5. , 0.10000038, -0.39999962, 3.}); + test_case.add_expected_output( + Shape{6}, {-0.10000038, 0.39999962, 5., 0.10000038, -0.39999962, 3.}); test_case.run(); } @@ -3217,13 +3205,13 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_model_mod_incorrect_fmod) try { const auto function = onnx_import::import_onnx_model( - file_util::path_join(SERIALIZED_ZOO, "onnx/mod_incorrect_fmod.prototxt")); + file_util::path_join(SERIALIZED_ZOO, "onnx/mod_incorrect_fmod.prototxt")); FAIL() << "Expected exception was not thrown"; } catch (const ngraph::ngraph_error& e) { - EXPECT_HAS_SUBSTRING(e.what(), - std::string("Unsupported value of 'fmod' attribute (should be: 0 or 1)")); + EXPECT_HAS_SUBSTRING( + e.what(), std::string("Unsupported value of 'fmod' attribute (should be: 0 or 1)")); } catch (...) { @@ -4364,8 +4352,8 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_negativelog_likelihood_loss) NGRAPH_TEST(${BACKEND_NAME}, onnx_constant_fill_input_as_shape_default_value) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(SERIALIZED_ZOO, "onnx/constant_fill_input_as_shape_default_value.prototxt")); + auto function = onnx_import::import_onnx_model(file_util::path_join( + SERIALIZED_ZOO, "onnx/constant_fill_input_as_shape_default_value.prototxt")); auto test_case = test::TestCase(function); test_case.add_expected_output(Shape{1, 2, 3}, {0.f, 0.f, 0.f, 0.f, 0.f, 0.f}); @@ -4422,7 +4410,6 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_constant_bfloat_tensor) test_case.run(); } - NGRAPH_TEST(${BACKEND_NAME}, onnx_constant_float_scalar) { auto function = onnx_import::import_onnx_model( diff --git a/ngraph/test/util/engine/interpreter_engine.cpp b/ngraph/test/util/engine/interpreter_engine.cpp index 3254f395f08242..876bd63d146d02 100644 --- a/ngraph/test/util/engine/interpreter_engine.cpp +++ b/ngraph/test/util/engine/interpreter_engine.cpp @@ -133,8 +133,9 @@ testing::AssertionResult if (expected_shape != result_shape) { comparison_result = testing::AssertionFailure(); - comparison_result << "Computed data shape does not match the expected shape for output " - << i << std::endl; + comparison_result << "Computed data shape(" << result_shape + << ") does not match the expected shape(" << expected_shape + << ") for output " << i << std::endl; break; } @@ -175,8 +176,9 @@ testing::AssertionResult test::INTERPRETER_Engine::compare_results(const size_t if (expected_shape != result_shape) { comparison_result = testing::AssertionFailure(); - comparison_result << "Computed data shape does not match the expected shape for output " - << i << std::endl; + comparison_result << "Computed data shape(" << result_shape + << ") does not match the expected shape(" << expected_shape + << ") for output " << i << std::endl; break; } From 084aa4e5916fa2ed3e353dcd45d081ab11d9c75a Mon Sep 17 00:00:00 2001 From: Bartek Szmelczynski Date: Thu, 10 Jun 2021 18:35:52 +0200 Subject: [PATCH 060/178] Revise log (#6061) * refactor ngraph log class, add type_prop tests * udpate inputs, outputs decscription in spec Co-authored-by: jdanieck --- docs/ops/arithmetic/Log_1.md | 16 +++++++-------- ngraph/core/include/ngraph/op/log.hpp | 3 +-- ngraph/core/src/op/log.cpp | 2 +- ngraph/test/CMakeLists.txt | 1 + ngraph/test/type_prop/unary_ops.cpp | 2 +- ngraph/test/visitors/op/log.cpp | 29 +++++++++++++++++++++++++++ 6 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 ngraph/test/visitors/op/log.cpp diff --git a/docs/ops/arithmetic/Log_1.md b/docs/ops/arithmetic/Log_1.md index 6f33b002b693b7..f13149198210a4 100644 --- a/docs/ops/arithmetic/Log_1.md +++ b/docs/ops/arithmetic/Log_1.md @@ -6,28 +6,28 @@ **Short description**: *Log* performs element-wise natural logarithm operation with given tensor. +**Detailed description**: *Log* does the following with the input tensor *a*: + +\f[ +a_{i} = log(a_{i}) +\f] + **Attributes**: No attributes available. **Inputs** -* **1**: An tensor of type T. **Required.** +* **1**: An tensor of type T and arbitrary shape. **Required.** **Outputs** -* **1**: The result of element-wise log operation. A tensor of type T. +* **1**: The result of element-wise log operation. A tensor of type T and the same shape as input. **Types** * *T*: any numeric type. -*Log* does the following with the input tensor *a*: - -\f[ -a_{i} = log(a_{i}) -\f] - **Examples** *Example 1* diff --git a/ngraph/core/include/ngraph/op/log.hpp b/ngraph/core/include/ngraph/op/log.hpp index 6c147d43314b03..997732b61161a3 100644 --- a/ngraph/core/include/ngraph/op/log.hpp +++ b/ngraph/core/include/ngraph/op/log.hpp @@ -16,8 +16,7 @@ namespace ngraph class NGRAPH_API Log : public util::UnaryElementwiseArithmetic { public: - static constexpr NodeTypeInfo type_info{"Log", 0}; - const NodeTypeInfo& get_type_info() const override { return type_info; } + NGRAPH_RTTI_DECLARATION; /// \brief Constructs a natural log operation. Log() = default; /// \brief Constructs a natural log operation. diff --git a/ngraph/core/src/op/log.cpp b/ngraph/core/src/op/log.cpp index 49a41c0d93108f..7743dbed6bdf2c 100644 --- a/ngraph/core/src/op/log.cpp +++ b/ngraph/core/src/op/log.cpp @@ -13,7 +13,7 @@ using namespace std; using namespace ngraph; -constexpr NodeTypeInfo op::Log::type_info; +NGRAPH_RTTI_DEFINITION(op::v0::Log, "Log", 0); op::Log::Log(const Output& arg) : UnaryElementwiseArithmetic(arg) diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index 7ee6b89580d0f6..e25a40de184b6e 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -232,6 +232,7 @@ set(SRC visitors/op/grn.cpp visitors/op/group_conv.cpp visitors/op/interpolate.cpp + visitors/op/log.cpp visitors/op/logical_xor.cpp visitors/op/lrn.cpp visitors/op/lstm_cell.cpp diff --git a/ngraph/test/type_prop/unary_ops.cpp b/ngraph/test/type_prop/unary_ops.cpp index 3859dd7369d490..788b50917fa6a2 100644 --- a/ngraph/test/type_prop/unary_ops.cpp +++ b/ngraph/test/type_prop/unary_ops.cpp @@ -96,6 +96,6 @@ REGISTER_TYPED_TEST_CASE_P(UnaryOperator, dynamic_rank_input_shape_3D, dynamic_rank_input_shape_full); -using Types = ::testing::Types; +using Types = ::testing::Types; INSTANTIATE_TYPED_TEST_CASE_P(type_prop, UnaryOperator, Types); diff --git a/ngraph/test/visitors/op/log.cpp b/ngraph/test/visitors/op/log.cpp new file mode 100644 index 00000000000000..02d6293871c028 --- /dev/null +++ b/ngraph/test/visitors/op/log.cpp @@ -0,0 +1,29 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" + +#include "ngraph/ngraph.hpp" +#include "ngraph/op/util/attr_types.hpp" +#include "ngraph/opsets/opset1.hpp" + +#include "util/visitor.hpp" + +using namespace std; +using namespace ngraph; +using ngraph::test::NodeBuilder; + +TEST(attributes, log_op) +{ + using namespace opset1; + + NodeBuilder::get_ops().register_factory(); + const auto data_input = make_shared(element::f32, Shape{1, 2, 3}); + const auto op = make_shared(data_input); + + NodeBuilder builder(op); + const auto expected_attr_count = 0; + + EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); +} \ No newline at end of file From d2adea950ff99b7d13cb6b6c33f1ac5e045af9fc Mon Sep 17 00:00:00 2001 From: Irina Burgun Date: Thu, 10 Jun 2021 22:23:01 +0300 Subject: [PATCH 061/178] Freeze summary header while scrolling (#6121) --- .../layer_tests_summary/template/report_template.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/template/report_template.html b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/template/report_template.html index 26f0923e144fb2..7d6f751f91701a 100644 --- a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/template/report_template.html +++ b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/template/report_template.html @@ -43,11 +43,11 @@

Operations coverage summary: {{report_tag}} {{ timestamp }}

- + - + {% for d in devices -%} - + {% endfor %} From 14e486b767dac559c6ade05544bc48ac0958ba3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Do=C5=82bniak?= Date: Thu, 10 Jun 2021 22:34:36 +0200 Subject: [PATCH 062/178] MVN test with opset6 version of the op (#6111) --- ngraph/python/tests/__init__.py | 1 - .../tests/test_ngraph/test_ops_fused.py | 29 +++++++++---------- ngraph/test/runtime/ie/unit_test.manifest | 8 ----- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/ngraph/python/tests/__init__.py b/ngraph/python/tests/__init__.py index f54930f40d92e5..817d4584534934 100644 --- a/ngraph/python/tests/__init__.py +++ b/ngraph/python/tests/__init__.py @@ -51,7 +51,6 @@ def xfail_test(reason="Mark the test as expected to fail", strict=True): xfail_issue_35927 = xfail_test(reason="RuntimeError: B has zero dimension that is not allowable") xfail_issue_36486 = xfail_test(reason="RuntimeError: HardSigmoid operation should be converted " "to HardSigmoid_IE") -xfail_issue_36487 = xfail_test(reason="Assertion error - mvn operator computation mismatch") xfail_issue_38084 = xfail_test(reason="RuntimeError: AssertionFailed: layer->get_output_partial_shape(i)" "is_static() nGraph operation with name: cannot be" "converted to layer with name: because output" diff --git a/ngraph/python/tests/test_ngraph/test_ops_fused.py b/ngraph/python/tests/test_ngraph/test_ops_fused.py index 48fff1623c5f61..d96f870f604bc0 100644 --- a/ngraph/python/tests/test_ngraph/test_ops_fused.py +++ b/ngraph/python/tests/test_ngraph/test_ops_fused.py @@ -6,9 +6,7 @@ import ngraph as ng from tests.runtime import get_runtime -from tests import (xfail_issue_36486, - xfail_issue_36487, - xfail_issue_44976) +from tests import (xfail_issue_36486, xfail_issue_44976) def test_elu_operator_with_scalar_and_array(): @@ -424,14 +422,14 @@ def test_hard_sigmoid_operator(): assert np.allclose(result, expected) -@xfail_issue_36487 def test_mvn_operator(): runtime = get_runtime() data_shape = [3, 3, 3, 1] - across_channels = True + axes = [0, 2, 3] normalize_variance = True eps = np.float32(1e-9) + eps_mode = "outside_sqrt" data_value = np.array( [ @@ -456,7 +454,7 @@ def test_mvn_operator(): parameter_data = ng.parameter(data_shape, name="Data", dtype=np.float32) - model = ng.mvn(parameter_data, across_channels, normalize_variance, eps) + model = ng.mvn(parameter_data, axes, normalize_variance, eps, eps_mode) computation = runtime.computation(model, parameter_data) result = computation(data_value) @@ -464,21 +462,22 @@ def test_mvn_operator(): expected = np.array( [ [ - [[0.9951074], [0.14548765], [-1.410561]], - [[-1.4999886], [-1.1923014], [-0.03975919]], - [[0.8463296], [1.2926502], [1.3340596]], + [[1.3546423], [0.33053496], [-1.5450814]], + [[-1.2106764], [-0.8925952], [0.29888135]], + [[0.38083088], [0.81808794], [0.85865635]], ], [ - [[-1.0463363], [-0.1747985], [-0.7784088]], - [[0.47672555], [-1.5383], [0.32375798]], - [[1.2404392], [1.3878832], [-1.2228798]], + [[-1.1060555], [-0.05552877], [-0.78310335]], + [[0.83281356], [-1.250282], [0.67467856]], + [[0.7669372], [0.9113869], [-1.6463585]], ], [ - [[-0.3228847], [1.2063044], [0.22751297]], - [[0.91956615], [0.81839436], [-1.2279599]], - [[0.5312334], [0.067952], [-1.3592235]], + [[-0.23402764], [1.6092131], [0.42940593]], + [[1.2906139], [1.1860244], [-0.92945826]], + [[0.0721334], [-0.38174], [-1.7799333]], ], ], + dtype=np.float32, ) assert np.allclose(result, expected) diff --git a/ngraph/test/runtime/ie/unit_test.manifest b/ngraph/test/runtime/ie/unit_test.manifest index c476f2dfac3137..f95ce0d951e162 100644 --- a/ngraph/test/runtime/ie/unit_test.manifest +++ b/ngraph/test/runtime/ie/unit_test.manifest @@ -1667,14 +1667,6 @@ IE_CPU.evaluate_ctc_greedy_decoder_seq_len_f16 minimum_u16 IE_CPU/ElemTypesTests/1.onnx_test_add_abc_set_precission -# not implemented in CPU and GPU -evaluate_mvn_6_no_variance -evaluate_mvn_6 -evaluate_mvn_6_inside_sqrt -evaluate_mvn_6_across_chanells -evaluate_mvn_6_across_batch -IE_CPU.onnx_mvn_v6 - # not yet implemented on CPU/GPU Gather 7 gather_v7_data_int32_2d_indices_axis_1_negative_batch_dims gather_v7_1d_int32 From 05469e95e99576f9fda84ae6f3ba8dc9d506d9a6 Mon Sep 17 00:00:00 2001 From: Mikhail Nosov Date: Fri, 11 Jun 2021 07:14:36 +0300 Subject: [PATCH 063/178] [NG Frontend] Frontend exceptions (#5993) * [NG Frontend] Introduce classes and macros for Frontend-specific exceptions * Add FrontEnd exception unit tests * resolve review comments * Import FE exception classes * code style Co-authored-by: Ivan Tikhonov --- .../frontend_manager/frontend_exceptions.hpp | 123 +++++++++++++++ .../frontend_manager/src/frontend_manager.cpp | 12 +- ngraph/test/frontend/frontend_manager.cpp | 148 ++++++++++++++++++ 3 files changed, 274 insertions(+), 9 deletions(-) create mode 100644 ngraph/frontend/frontend_manager/include/frontend_manager/frontend_exceptions.hpp diff --git a/ngraph/frontend/frontend_manager/include/frontend_manager/frontend_exceptions.hpp b/ngraph/frontend/frontend_manager/include/frontend_manager/frontend_exceptions.hpp new file mode 100644 index 00000000000000..46fa2be0888f70 --- /dev/null +++ b/ngraph/frontend/frontend_manager/include/frontend_manager/frontend_exceptions.hpp @@ -0,0 +1,123 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include "frontend_manager_defs.hpp" +#include "ngraph/check.hpp" + +namespace ngraph +{ + namespace frontend + { + class FRONTEND_API GeneralFailure : public CheckFailure + { + public: + GeneralFailure(const CheckLocInfo& check_loc_info, + const std::string& context, + const std::string& explanation) + : CheckFailure(check_loc_info, + "FrontEnd API failed with GeneralFailure: " + context, + explanation) + { + } + }; + + class FRONTEND_API InitializationFailure : public CheckFailure + { + public: + InitializationFailure(const CheckLocInfo& check_loc_info, + const std::string& context, + const std::string& explanation) + : CheckFailure(check_loc_info, + "FrontEnd API failed with InitializationFailure: " + context, + explanation) + { + } + }; + + class FRONTEND_API OpValidationFailure : public CheckFailure + { + public: + OpValidationFailure(const CheckLocInfo& check_loc_info, + const std::string& context, + const std::string& explanation) + : CheckFailure(check_loc_info, + "FrontEnd API failed with OpValidationFailure: " + context, + explanation) + { + } + }; + + class FRONTEND_API OpConversionFailure : public CheckFailure + { + public: + OpConversionFailure(const CheckLocInfo& check_loc_info, + const std::string& context, + const std::string& explanation) + : CheckFailure(check_loc_info, + "FrontEnd API failed with OpConversionFailure: " + context, + explanation) + { + } + }; + + class FRONTEND_API NotImplementedFailure : public CheckFailure + { + public: + NotImplementedFailure(const CheckLocInfo& check_loc_info, + const std::string& context, + const std::string& explanation) + : CheckFailure(check_loc_info, + "FrontEnd API failed with NotImplementedFailure: " + context, + explanation) + { + } + }; + +/// \brief Macro to check whether a boolean condition holds. +/// \param cond Condition to check +/// \param ... Additional error message info to be added to the error message via the `<<` +/// stream-insertion operator. Note that the expressions here will be evaluated lazily, +/// i.e., only if the `cond` evalutes to `false`. +/// \throws ::ngraph::frontend::GeneralFailure if `cond` is false. +#define FRONT_END_GENERAL_CHECK(...) \ + NGRAPH_CHECK_HELPER(::ngraph::frontend::GeneralFailure, "", __VA_ARGS__) + +/// \brief Macro to check whether a boolean condition holds. +/// \param cond Condition to check +/// \param ... Additional error message info to be added to the error message via the `<<` +/// stream-insertion operator. Note that the expressions here will be evaluated lazily, +/// i.e., only if the `cond` evalutes to `false`. +/// \throws ::ngraph::frontend::InitializationFailure if `cond` is false. +#define FRONT_END_INITIALIZATION_CHECK(...) \ + NGRAPH_CHECK_HELPER(::ngraph::frontend::InitializationFailure, "", __VA_ARGS__) + +/// \brief Macro to check whether a boolean condition holds. +/// \param cond Condition to check +/// \param ... Additional error message info to be added to the error message via the `<<` +/// stream-insertion operator. Note that the expressions here will be evaluated lazily, +/// i.e., only if the `cond` evalutes to `false`. +/// \throws ::ngraph::frontend::OpConversionFailure if `cond` is false. +#define FRONT_END_OP_CONVERSION_CHECK(...) \ + NGRAPH_CHECK_HELPER(::ngraph::frontend::OpConversionFailure, "", __VA_ARGS__) + +/// \brief Assert macro. +/// \param NAME Name of the function that is not implemented +/// \throws ::ngraph::frontend::NotImplementedFailure +#define FRONT_END_NOT_IMPLEMENTED(NAME) \ + NGRAPH_CHECK_HELPER(::ngraph::frontend::NotImplementedFailure, \ + "", \ + false, \ + #NAME " is not implemented for this FrontEnd class") + +/// \brief Assert macro. +/// \param MSG Error message +/// \throws ::ngraph::frontend::GeneralFailure +#define FRONT_END_THROW(MSG) FRONT_END_GENERAL_CHECK(false, MSG) + + } // namespace frontend +} // namespace ngraph \ No newline at end of file diff --git a/ngraph/frontend/frontend_manager/src/frontend_manager.cpp b/ngraph/frontend/frontend_manager/src/frontend_manager.cpp index c1a864ffd6e27d..037a2522523dc4 100644 --- a/ngraph/frontend/frontend_manager/src/frontend_manager.cpp +++ b/ngraph/frontend/frontend_manager/src/frontend_manager.cpp @@ -5,20 +5,13 @@ #include #include +#include "frontend_manager/frontend_exceptions.hpp" #include "frontend_manager/frontend_manager.hpp" #include "plugin_loader.hpp" using namespace ngraph; using namespace ngraph::frontend; -#define FRONT_END_NOT_IMPLEMENTED(NAME) \ - throw std::runtime_error(#NAME " is not implemented for this FrontEnd class") -#define FRONT_END_ASSERT(EXPRESSION) \ - { \ - if (!(EXPRESSION)) \ - throw "AssertionFailed"; \ - } - //----------- FrontEndManager --------------------------- class FrontEndManager::Impl { @@ -32,7 +25,8 @@ class FrontEndManager::Impl FrontEnd::Ptr loadByFramework(const std::string& framework, FrontEndCapFlags fec) { - FRONT_END_ASSERT(m_factories.count(framework)) + FRONT_END_INITIALIZATION_CHECK( + m_factories.count(framework), "FrontEnd for Framework ", framework, " is not found"); return m_factories[framework](fec); } diff --git a/ngraph/test/frontend/frontend_manager.cpp b/ngraph/test/frontend/frontend_manager.cpp index 10e8eac8e60001..af70885d237901 100644 --- a/ngraph/test/frontend/frontend_manager.cpp +++ b/ngraph/test/frontend/frontend_manager.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#include #include #include @@ -161,3 +162,150 @@ TEST(FrontEndManagerTest, testDefaultPlace) ASSERT_ANY_THROW(place->is_equal(nullptr)); ASSERT_ANY_THROW(place->is_equal_data(nullptr)); } + +TEST(FrontEndExceptionTest, frontend_general_error_no_throw) +{ + EXPECT_NO_THROW(FRONT_END_GENERAL_CHECK(true)); +} + +TEST(FrontEndExceptionTest, frontend_general_error_no_throw_info) +{ + EXPECT_NO_THROW(FRONT_END_GENERAL_CHECK(true, "msg example")); +} + +TEST(FrontEndExceptionTest, frontend_general_error_throw_no_info) +{ + EXPECT_THROW(FRONT_END_GENERAL_CHECK(false), ngraph::frontend::GeneralFailure); +} + +TEST(FrontEndExceptionTest, frontend_initialization_error_no_throw) +{ + EXPECT_NO_THROW(FRONT_END_INITIALIZATION_CHECK(true)); +} + +TEST(FrontEndExceptionTest, frontend_initialization_error_no_throw_info) +{ + EXPECT_NO_THROW(FRONT_END_INITIALIZATION_CHECK(true, "msg example")); +} + +TEST(FrontEndExceptionTest, frontend_initialization_error_throw_no_info) +{ + EXPECT_THROW(FRONT_END_INITIALIZATION_CHECK(false), ngraph::frontend::InitializationFailure); +} + +TEST(FrontEndExceptionTest, frontend_op_conversion_error_no_throw) +{ + EXPECT_NO_THROW(FRONT_END_OP_CONVERSION_CHECK(true)); +} + +TEST(FrontEndExceptionTest, frontend_op_conversion_error_no_throw_info) +{ + EXPECT_NO_THROW(FRONT_END_OP_CONVERSION_CHECK(true, "msg example")); +} + +TEST(FrontEndExceptionTest, frontend_op_conversion_error_throw_no_info) +{ + EXPECT_THROW(FRONT_END_OP_CONVERSION_CHECK(false), ngraph::frontend::OpConversionFailure); +} + +TEST(FrontEndExceptionTest, frontend_assert_throw_check_info) +{ + std::string msg("msg example"); + try + { + FRONT_END_THROW(msg); + } + catch (const ngraph::frontend::GeneralFailure& ex) + { + std::string caught_msg(ex.what()); + EXPECT_NE(caught_msg.find(msg), std::string::npos); + return; + } + catch (...) + { + FAIL() << "Not expected exception type."; + } + FAIL() << "Test is expected to throw an exception."; +} + +TEST(FrontEndExceptionTest, frontend_not_implemented_throw_check_info) +{ + struct TestClass + { + }; + try + { + FRONT_END_NOT_IMPLEMENTED(TestClass); + } + catch (const ngraph::frontend::NotImplementedFailure& ex) + { + std::string caught_msg(ex.what()); + EXPECT_NE(caught_msg.find("TestClass"), std::string::npos); + return; + } + catch (...) + { + FAIL() << "Not expected exception type."; + } + FAIL() << "Test is expected to throw an exception."; +} + +TEST(FrontEndExceptionTest, frontend_general_error_throw_info) +{ + std::string msg("msg example"); + try + { + FRONT_END_GENERAL_CHECK(false, msg); + } + catch (const ngraph::frontend::GeneralFailure& ex) + { + std::string caught_msg(ex.what()); + EXPECT_NE(caught_msg.find(msg), std::string::npos); + return; + } + catch (...) + { + FAIL() << "Not expected exception type."; + } + FAIL() << "Test is expected to throw an exception."; +} + +TEST(FrontEndExceptionTest, frontend_op_conversion_error_throw_info) +{ + std::string msg("msg example"); + try + { + FRONT_END_OP_CONVERSION_CHECK(false, msg); + } + catch (const ngraph::frontend::OpConversionFailure& ex) + { + std::string caught_msg(ex.what()); + EXPECT_NE(caught_msg.find(msg), std::string::npos); + return; + } + catch (...) + { + FAIL() << "Not expected exception type."; + } + FAIL() << "Test is expected to throw an exception."; +} + +TEST(FrontEndExceptionTest, frontend_initialization_error_throw_info) +{ + std::string msg("msg example"); + try + { + FRONT_END_INITIALIZATION_CHECK(false, msg); + } + catch (const ngraph::frontend::InitializationFailure& ex) + { + std::string caught_msg(ex.what()); + EXPECT_NE(caught_msg.find(msg), std::string::npos); + return; + } + catch (...) + { + FAIL() << "Not expected exception type."; + } + FAIL() << "Test is expected to throw an exception."; +} From ddc27d3513dc021bd833d600ca1323aa24b3cb04 Mon Sep 17 00:00:00 2001 From: Gabriele Galiero Casay Date: Fri, 11 Jun 2021 06:41:44 +0200 Subject: [PATCH 064/178] Revise reference implementation for ReduceSum operation (#5728) * Revise reference implementation for ReduceSum operation * Refactor backend unit tests * Move tests with zero dims and dynamic shapes to op_eval * Removed tests for f64 precision not supported * Add support for precisions bf16, i8 and u8 * Clean up interpreter manifest unit tests * Create ticket for result mismatch and accuracy failing tests * Disable back interpreter tests failing for ubuntu18 i386 for large tensors * Revert "Add support for precisions bf16, i8 and u8" This reverts commit 8f1bba0dff37e8131adc59351c65e65ba1103b9a. * Add to manifest tests with disable types of reference implementation * Address review comments * Use constexpr variable to set keep dims as false in reduction output shape * Replace CoordinateTransform with CoordinateTransformBasic * Fix typo in variable name * Remove keep_dims parameter from sum function call --- .../ngraph/runtime/reference/log_softmax.hpp | 2 +- .../ngraph/runtime/reference/normalize_l2.hpp | 2 +- .../ngraph/runtime/reference/softmax.hpp | 2 +- .../include/ngraph/runtime/reference/sum.hpp | 37 +- .../src/runtime/reference/einsum.cpp | 6 +- ngraph/core/src/op/reduce_sum.cpp | 9 +- ngraph/test/CMakeLists.txt | 1 + ngraph/test/backend/reduce_sum.in.cpp | 581 ------------------ ngraph/test/op_eval/reduce_sum.cpp | 395 ++++++++++++ ngraph/test/runtime/ie/unit_test.manifest | 28 +- .../runtime/interpreter/unit_test.manifest | 4 +- 11 files changed, 429 insertions(+), 638 deletions(-) create mode 100644 ngraph/test/op_eval/reduce_sum.cpp diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/log_softmax.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/log_softmax.hpp index 11b9092e6e6489..27198f465b30ff 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/log_softmax.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/log_softmax.hpp @@ -35,7 +35,7 @@ namespace ngraph arg[transform.index(coord)] - temp_max[temp_transform.index(temp_coord)]); } - sum(out, temp_sum.data(), shape, axes, true); + sum(out, temp_sum.data(), shape, axes); for (const Coordinate& coord : transform) { diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/normalize_l2.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/normalize_l2.hpp index 5da76763465b9d..c32ec70488ede3 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/normalize_l2.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/normalize_l2.hpp @@ -42,7 +42,7 @@ namespace ngraph } std::vector sum_data(shape_size(reduce_shape)); - sum(sqr_data.data(), sum_data.data(), data_shape, axes, true); + sum(sqr_data.data(), sum_data.data(), data_shape, axes); autobroadcast_binop(data, sum_data.data(), out, diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/softmax.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/softmax.hpp index c31c901012ce93..94cb0549b7310d 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/softmax.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/softmax.hpp @@ -34,7 +34,7 @@ namespace ngraph arg[transform.index(coord)] - temp_ptr[temp_transform.index(temp_coord)]); } - sum(out, temp_ptr, shape, axes, true); + sum(out, temp_ptr, shape, axes); for (const Coordinate& coord : transform) { diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/sum.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/sum.hpp index 0c20eaf431ab9f..2408e6f476d728 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/sum.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/sum.hpp @@ -5,6 +5,7 @@ #pragma once #include +#include #include "ngraph/coordinate_transform.hpp" #include "ngraph/shape_util.hpp" @@ -41,34 +42,34 @@ namespace ngraph } template - void sum(const T* arg, - T* out, - const Shape& in_shape, - const AxisSet& reduction_axes, - bool keep_dims) + void sum(const T* arg, T* out, const Shape& in_shape, const AxisSet& reduction_axes) { - auto out_shape = reduce(in_shape, reduction_axes, keep_dims); - CoordinateTransform output_transform(out_shape); - std::vector cs(shape_size(out_shape)); + constexpr bool dont_keep_dims_in_output = false; + auto out_shape = reduce(in_shape, reduction_axes, dont_keep_dims_in_output); - for (const Coordinate& output_coord : output_transform) - { - out[output_transform.index(output_coord)] = 0; - cs[output_transform.index(output_coord)] = 0; - } + std::vector cs(shape_size(out_shape), 0); + std::fill(out, out + shape_size(out_shape), 0); - CoordinateTransform input_transform(in_shape); + const auto in_strides = row_major_strides(in_shape); + const auto out_strides = row_major_strides(out_shape); + CoordinateTransformBasic input_transform(in_shape); for (const Coordinate& input_coord : input_transform) { - Coordinate output_coord = reduce(input_coord, reduction_axes, keep_dims); + Coordinate output_coord = + reduce(input_coord, reduction_axes, dont_keep_dims_in_output); + + size_t in_idx = std::inner_product( + input_coord.begin(), input_coord.end(), in_strides.begin(), 0); + size_t out_idx = std::inner_product( + output_coord.begin(), output_coord.end(), out_strides.begin(), 0); - T x = arg[input_transform.index(input_coord)]; - T& z = out[output_transform.index(output_coord)]; + T x = arg[in_idx]; + T& z = out[out_idx]; if (is_finite(x) && is_finite(z)) { - T& c = cs[output_transform.index(output_coord)]; + T& c = cs[out_idx]; T t = z + (x - c); c = (t - z) - (x - c); z = t; diff --git a/ngraph/core/reference/src/runtime/reference/einsum.cpp b/ngraph/core/reference/src/runtime/reference/einsum.cpp index e1356788c5ea8d..51352ddadac9db 100644 --- a/ngraph/core/reference/src/runtime/reference/einsum.cpp +++ b/ngraph/core/reference/src/runtime/reference/einsum.cpp @@ -436,8 +436,7 @@ namespace ngraph ngraph::runtime::reference::sum(input_ptr->get_data_ptr(), output_ptr->get_data_ptr(), input_shape, - reduced_axes, - false); + reduced_axes); // update a vector of inputs and input subscripts inputs[input_ind] = output_ptr; @@ -743,8 +742,7 @@ namespace ngraph ngraph::runtime::reference::sum(mul_output->get_data_ptr(), result->get_data_ptr(), mul_output->get_shape(), - reduced_axes, - false); + reduced_axes); inputs[input_ind] = result; input_subscripts[input_ind] = resultant_subscript; } diff --git a/ngraph/core/src/op/reduce_sum.cpp b/ngraph/core/src/op/reduce_sum.cpp index 70c2b39ddc064b..34262ec9efb32d 100644 --- a/ngraph/core/src/op/reduce_sum.cpp +++ b/ngraph/core/src/op/reduce_sum.cpp @@ -3,6 +3,7 @@ // #include "ngraph/op/reduce_sum.hpp" +#include #include "itt.hpp" #include "ngraph/graph_util.hpp" #include "ngraph/op/broadcast.hpp" @@ -47,7 +48,7 @@ namespace reduce_sum { out->set_shape(reduce(arg->get_shape(), axes, keep_dims)); runtime::reference::sum( - arg->get_data_ptr(), out->get_data_ptr(), arg->get_shape(), axes, keep_dims); + arg->get_data_ptr(), out->get_data_ptr(), arg->get_shape(), axes); return true; } @@ -75,10 +76,8 @@ bool op::v1::ReduceSum::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { NGRAPH_OP_SCOPE(v1_ReduceSum_evaluate); - - NGRAPH_CHECK(inputs.size() == 2, - "The ReduceSum operation expects 2 input tensors. Got: ", - inputs.size()); + NGRAPH_CHECK(validate_host_tensor_vector(inputs, 2)); + NGRAPH_CHECK(validate_host_tensor_vector(outputs, 1)); const auto reduction_axes = get_normalized_axes_from_tensor( inputs[1], get_input_partial_shape(0).rank(), get_friendly_name()); diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index e25a40de184b6e..c629111ca147c1 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -73,6 +73,7 @@ set(SRC op_eval/non_zero.cpp op_eval/reduce_l1.cpp op_eval/reduce_l2.cpp + op_eval/reduce_sum.cpp op_eval/roi_align.cpp op_eval/roi_pooling.cpp op_eval/round.cpp diff --git a/ngraph/test/backend/reduce_sum.in.cpp b/ngraph/test/backend/reduce_sum.in.cpp index 50560a07c6ee97..97bc81d98eb370 100644 --- a/ngraph/test/backend/reduce_sum.in.cpp +++ b/ngraph/test/backend/reduce_sum.in.cpp @@ -151,95 +151,6 @@ NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_matrix_rows) EXPECT_TRUE(test::all_close_f((vector{3, 7, 11}), read_vector(result))); } -NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_matrix_rows_zero) -{ - Shape shape_a{3, 0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{3}; - auto axes = make_shared(element::i32, Shape{}, 1); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3, 3, 3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{0, 0, 0}), read_vector(result))); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_matrix_cols_zero) -{ - // Now the reduction (g(x:float32[2,2],y:float32[]) = reduce(x,y,f,axes={})). - Shape shape_a{0, 2}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{2}; - auto axes = make_shared(element::i32, Shape{}, 0); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3, 3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{0, 0}), read_vector(result))); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_vector_zero) -{ - Shape shape_a{0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{}; - auto axes = make_shared(element::i32, Shape{}, 0); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{0}), read_vector(result))); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_matrix_to_scalar_zero_by_zero) -{ - Shape shape_a{0, 0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{}; - auto axes = make_shared(element::i32, Shape{2}, vector{0, 1}); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{0}), read_vector(result))); -} - NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_3d_to_matrix_most_sig) { Shape shape_a{3, 3, 3}; @@ -376,56 +287,6 @@ NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_3d_to_scalar_int32) read_vector(result)); } -NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_3d_eliminate_zero_dim) -{ - Shape shape_a{3, 0, 2}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{3, 2}; - auto axes = make_shared(element::i32, Shape{}, 1); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - - // Overwrite the initial result vector to make sure we're not just coincidentally getting the - // right value. - copy_data(result, vector{2112, 2112, 2112, 2112, 2112, 2112}); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{0, 0, 0, 0, 0, 0}), read_vector(result))); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_3d_eliminate_zero_dim_int32) -{ - Shape shape_a{3, 0, 2}; - auto A = make_shared(element::i32, shape_a); - Shape shape_rt{3, 2}; - auto axes = make_shared(element::i32, Shape{}, 1); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::i32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::i32, shape_rt); - - // Overwrite the initial result vector to make sure we're not just coincidentally getting the - // right value. - copy_data(result, vector{2112, 2112, 2112, 2112, 2112, 2112}); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_EQ((vector{0, 0, 0, 0, 0, 0}), read_vector(result)); -} - NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_5d_to_scalar) { Shape shape_a{3, 3, 3, 3, 3}; @@ -489,27 +350,6 @@ NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_2d_to_scalar_int8) EXPECT_EQ(std::vector{45}, read_vector(result)); } -NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_trivial_in_double) -{ - Shape shape{4, 3}; - Shape rshape{3}; - auto A = make_shared(element::f64, shape); - auto axes = make_shared(element::i32, Shape{}, 0); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f64, shape); - copy_data(a, vector{12, 2, 10, 9, 8, 4, 6, 1, 5, 3, 11, 7}); - auto result = backend->create_tensor(element::f64, rshape); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{30, 22, 26}), read_vector(result))); -} - #if NGRAPH_INTERPRETER_ENABLE #ifndef _WIN32 @@ -548,39 +388,6 @@ NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_stable_acc) } #endif -NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_stable_acc_double) -{ - std::string backend_name = "${BACKEND_NAME}"; - if (backend_name == "INTERPRETER") - { - return; - } - Shape shape_a{10, 10, 20, 300}; - auto A = make_shared(element::f64, shape_a); - - Shape shape_rt{10}; - auto axes = make_shared(element::i32, Shape{3}, vector{1, 2, 3}); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - test::Uniform rng(1000000000.0L, 1000000000.001L, 2112); - vector> args; - for (shared_ptr param : f->get_parameters()) - { - vector tensor_val(shape_size(param->get_shape())); - rng.initialize(tensor_val); - args.push_back(tensor_val); - } - - auto ref_func = clone_function(*f); - auto bk_func = clone_function(*f); - - auto ref_results = execute(ref_func, args, "INTERPRETER"); - auto bk_results = execute(bk_func, args, "${BACKEND_NAME}"); - - EXPECT_TRUE(test::all_close(ref_results.at(0), bk_results.at(0), 0.0, 1e-5)); -} - NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_stable_simple_float) { std::string backend_name = "${BACKEND_NAME}"; @@ -611,106 +418,8 @@ NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_stable_simple_float) test::all_close_f(ref_results.at(0), bk_results.at(0), DEFAULT_FLOAT_TOLERANCE_BITS - 1)); } -#ifndef _WIN32 -NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_stable_simple_double) -{ - std::string backend_name = "${BACKEND_NAME}"; - if (backend_name == "INTERPRETER") - { - return; - } - Shape shape_a{20}; - auto A = make_shared(element::f64, shape_a); - - Shape shape_rt{}; - auto axes = make_shared(element::i32, Shape{}, 0); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - vector> args; - args.push_back(vector{10000000000000000.0L, - 0.2L, - 0.3L, - 0.4L, - 0.5L, - 0.6L, - 0.7L, - 0.8L, - 0.9L, - 0.7L, - 0.9L, - 0.7L, - 0.3L, - 0.6L, - 0.8L, - 0.4L, - 0.6L, - 0.5L, - 0.8L, - 0.7L}); - - auto ref_func = clone_function(*f); - auto bk_func = clone_function(*f); - - auto ref_results = execute(ref_func, args, "INTERPRETER"); - auto bk_results = execute(bk_func, args, "${BACKEND_NAME}"); - - EXPECT_TRUE(test::all_close(ref_results.at(0), bk_results.at(0), 0.0, 2.0)); -} #endif -#endif - -NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_dynamic) -{ - // Create a graph for f(x,axes:int32) = Sum(x,Convert(axes)). - auto x = make_shared(element::f32, PartialShape::dynamic()); - auto axes = make_shared(element::i32, PartialShape{Dimension::dynamic()}); - auto axes_i64 = make_shared(axes, element::i64); - - auto sum = make_shared(x, axes_i64, false); - ASSERT_TRUE(sum->get_output_partial_shape(0).rank().is_dynamic()); - - auto f = make_shared(NodeVector{sum}, ParameterVector{x, axes}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}", true); - - auto ex = backend->compile(f); - - auto t_r = backend->create_dynamic_tensor(element::f32, PartialShape::dynamic()); - - std::vector x_shapes{ - Shape{2, 3}, Shape{2, 3}, Shape{2, 3}, Shape{2, 3}, Shape{5}, Shape{5}}; - std::vector> axeses{{}, {0}, {1}, {0, 1}, {}, {0}}; - std::vector> inputs{{1, 2, 3, 4, 5, 6}, - {1, 2, 3, 4, 5, 6}, - {1, 2, 3, 4, 5, 6}, - {1, 2, 3, 4, 5, 6}, - {1, 2, 3, 4, 5}, - {1, 2, 3, 4, 5}}; - std::vector expected_result_shapes{ - Shape{2, 3}, Shape{3}, Shape{2}, Shape{}, Shape{5}, Shape{}}; - std::vector> expected_results{ - {1, 2, 3, 4, 5, 6}, {5, 7, 9}, {6, 15}, {21}, {1, 2, 3, 4, 5}, {15}}; - - for (size_t i = 0; i < x_shapes.size(); i++) - { - auto t_x = backend->create_tensor(element::f32, x_shapes[i]); - auto t_axes = backend->create_tensor(element::i32, Shape{axeses[i].size()}); - - copy_data(t_x, inputs[i]); - copy_data(t_axes, axeses[i]); - - ex->call_with_validate({t_r}, {t_x, t_axes}); - - ASSERT_EQ(t_r->get_shape(), expected_result_shapes[i]); - - auto results = read_vector(t_r); - - ASSERT_TRUE(test::all_close_f(results, expected_results[i], MIN_FLOAT_TOLERANCE_BITS)); - } -} - NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_inf) { Shape shape{7, 4}; @@ -874,95 +583,6 @@ NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_keep_matrix_rows) EXPECT_TRUE(test::all_close_f((vector{3, 7, 11}), read_vector(result))); } -NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_keep_matrix_rows_zero) -{ - Shape shape_a{3, 0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{3, 1}; - auto axes = make_shared(element::i32, Shape{}, 1); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3, 3, 3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{0, 0, 0}), read_vector(result))); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_keep_matrix_cols_zero) -{ - // Now the reduction (g(x:float32[2,2],y:float32[]) = reduce(x,y,f,axes={})). - Shape shape_a{0, 2}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{1, 2}; - auto axes = make_shared(element::i32, Shape{}, 0); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3, 3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{0, 0}), read_vector(result))); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_keep_vector_zero) -{ - Shape shape_a{0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{1}; - auto axes = make_shared(element::i32, Shape{}, 0); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{0}), read_vector(result))); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_keep_matrix_to_scalar_zero_by_zero) -{ - Shape shape_a{0, 0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{1, 1}; - auto axes = make_shared(element::i32, Shape{2}, vector{0, 1}); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{0}), read_vector(result))); -} - NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_keep_3d_to_matrix_most_sig) { Shape shape_a{3, 3, 3}; @@ -1099,56 +719,6 @@ NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_keep_3d_to_scalar_int32) read_vector(result)); } -NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_keep_3d_eliminate_zero_dim) -{ - Shape shape_a{3, 0, 2}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{3, 1, 2}; - auto axes = make_shared(element::i32, Shape{}, 1); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - - // Overwrite the initial result vector to make sure we're not just coincidentally getting the - // right value. - copy_data(result, vector{2112, 2112, 2112, 2112, 2112, 2112}); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{0, 0, 0, 0, 0, 0}), read_vector(result))); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_keep_3d_eliminate_zero_dim_int32) -{ - Shape shape_a{3, 0, 2}; - auto A = make_shared(element::i32, shape_a); - Shape shape_rt{3, 1, 2}; - auto axes = make_shared(element::i32, Shape{}, 1); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::i32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::i32, shape_rt); - - // Overwrite the initial result vector to make sure we're not just coincidentally getting the - // right value. - copy_data(result, vector{2112, 2112, 2112, 2112, 2112, 2112}); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_EQ((vector{0, 0, 0, 0, 0, 0}), read_vector(result)); -} - NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_keep_5d_to_scalar) { Shape shape_a{3, 3, 3, 3, 3}; @@ -1212,27 +782,6 @@ NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_keep_2d_to_scalar_int8) EXPECT_EQ(std::vector{45}, read_vector(result)); } -NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_keep_trivial_in_double) -{ - Shape shape{4, 3}; - Shape rshape{1, 3}; - auto A = make_shared(element::f64, shape); - auto axes = make_shared(element::i32, Shape{}, 0); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f64, shape); - copy_data(a, vector{12, 2, 10, 9, 8, 4, 6, 1, 5, 3, 11, 7}); - auto result = backend->create_tensor(element::f64, rshape); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{30, 22, 26}), read_vector(result))); -} - #if NGRAPH_INTERPRETER_ENABLE #ifndef _WIN32 @@ -1271,38 +820,6 @@ NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_keep_stable_acc) } #endif -NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_keep_stable_acc_double) -{ - std::string backend_name = "${BACKEND_NAME}"; - if (backend_name == "INTERPRETER") - { - return; - } - Shape shape_a{10, 10, 20, 300}; - auto A = make_shared(element::f64, shape_a); - - Shape shape_rt{10, 1, 1, 1}; - auto axes = make_shared(element::i32, Shape{3}, vector{1, 2, 3}); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - test::Uniform rng(1000000000.0L, 1000000000.001L, 2112); - vector> args; - for (shared_ptr param : f->get_parameters()) - { - vector tensor_val(shape_size(param->get_shape())); - rng.initialize(tensor_val); - args.push_back(tensor_val); - } - - auto ref_func = clone_function(*f); - auto bk_func = clone_function(*f); - - auto ref_results = execute(ref_func, args, "INTERPRETER"); - auto bk_results = execute(bk_func, args, "${BACKEND_NAME}"); - - EXPECT_TRUE(test::all_close(ref_results.at(0), bk_results.at(0), 0.0, 1e-5)); -} NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_keep_stable_simple_float) { @@ -1334,106 +851,8 @@ NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_keep_stable_simple_float) test::all_close_f(ref_results.at(0), bk_results.at(0), DEFAULT_FLOAT_TOLERANCE_BITS - 1)); } -#ifndef _WIN32 -NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_keep_stable_simple_double) -{ - std::string backend_name = "${BACKEND_NAME}"; - if (backend_name == "INTERPRETER") - { - return; - } - Shape shape_a{20}; - auto A = make_shared(element::f64, shape_a); - - Shape shape_rt{1}; - auto axes = make_shared(element::i32, Shape{}, 0); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - vector> args; - args.push_back(vector{10000000000000000.0L, - 0.2L, - 0.3L, - 0.4L, - 0.5L, - 0.6L, - 0.7L, - 0.8L, - 0.9L, - 0.7L, - 0.9L, - 0.7L, - 0.3L, - 0.6L, - 0.8L, - 0.4L, - 0.6L, - 0.5L, - 0.8L, - 0.7L}); - - auto ref_func = clone_function(*f); - auto bk_func = clone_function(*f); - - auto ref_results = execute(ref_func, args, "INTERPRETER"); - auto bk_results = execute(bk_func, args, "${BACKEND_NAME}"); - - EXPECT_TRUE(test::all_close(ref_results.at(0), bk_results.at(0), 0.0, 2.0)); -} -#endif - #endif -NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_keep_dynamic) -{ - // Create a graph for f(x,axes:int32) = Sum(x,Convert(axes)). - auto x = make_shared(element::f32, PartialShape::dynamic()); - auto axes = make_shared(element::i32, PartialShape{Dimension::dynamic()}); - auto axes_i64 = make_shared(axes, element::i64); - - auto sum = make_shared(x, axes_i64, true); - ASSERT_TRUE(sum->get_output_partial_shape(0).rank().is_dynamic()); - - auto f = make_shared(NodeVector{sum}, ParameterVector{x, axes}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}", true); - - auto ex = backend->compile(f); - - auto t_r = backend->create_dynamic_tensor(element::f32, PartialShape::dynamic()); - - std::vector x_shapes{ - Shape{2, 3}, Shape{2, 3}, Shape{2, 3}, Shape{2, 3}, Shape{5}, Shape{5}}; - std::vector> axeses{{}, {0}, {1}, {0, 1}, {}, {0}}; - std::vector> inputs{{1, 2, 3, 4, 5, 6}, - {1, 2, 3, 4, 5, 6}, - {1, 2, 3, 4, 5, 6}, - {1, 2, 3, 4, 5, 6}, - {1, 2, 3, 4, 5}, - {1, 2, 3, 4, 5}}; - std::vector expected_result_shapes{ - Shape{2, 3}, Shape{1, 3}, Shape{2, 1}, Shape{1, 1}, Shape{5}, Shape{1}}; - std::vector> expected_results{ - {1, 2, 3, 4, 5, 6}, {5, 7, 9}, {6, 15}, {21}, {1, 2, 3, 4, 5}, {15}}; - - for (size_t i = 0; i < x_shapes.size(); i++) - { - auto t_x = backend->create_tensor(element::f32, x_shapes[i]); - auto t_axes = backend->create_tensor(element::i32, Shape{axeses[i].size()}); - - copy_data(t_x, inputs[i]); - copy_data(t_axes, axeses[i]); - - ex->call_with_validate({t_r}, {t_x, t_axes}); - - ASSERT_EQ(t_r->get_shape(), expected_result_shapes[i]); - - auto results = read_vector(t_r); - - ASSERT_TRUE(test::all_close_f(results, expected_results[i], MIN_FLOAT_TOLERANCE_BITS)); - } -} - NGRAPH_TEST(${BACKEND_NAME}, reduce_sum_keep_inf) { Shape shape{7, 4}; diff --git a/ngraph/test/op_eval/reduce_sum.cpp b/ngraph/test/op_eval/reduce_sum.cpp new file mode 100644 index 00000000000000..bad7aad21edf90 --- /dev/null +++ b/ngraph/test/op_eval/reduce_sum.cpp @@ -0,0 +1,395 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "util/test_control.hpp" +#include "util/all_close.hpp" +#include "util/all_close_f.hpp" +#include "util/ndarray.hpp" + + +using namespace std; +using namespace ngraph; + +static string s_manifest = "${MANIFEST}"; + +TEST(op_eval, reduce_sum_matrix_rows_zero) +{ + Shape shape_a{3, 0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{3}; + auto axes = make_shared(element::i32, Shape{}, 1); + auto f = + make_shared(make_shared(A, axes, false), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3, 3, 3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_TRUE(test::all_close_f((vector{0, 0, 0}), read_vector(result))); +} + +TEST(op_eval, reduce_sum_vector_zero) +{ + Shape shape_a{0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{}; + auto axes = make_shared(element::i32, Shape{}, 0); + auto f = + make_shared(make_shared(A, axes, false), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_TRUE(test::all_close_f((vector{0}), read_vector(result))); +} + + +TEST(op_eval, reduce_sum_matrix_cols_zero) +{ + // Now the reduction (g(x:float32[2,2],y:float32[]) = reduce(x,y,f,axes={})). + Shape shape_a{0, 2}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{2}; + auto axes = make_shared(element::i32, Shape{}, 0); + auto f = + make_shared(make_shared(A, axes, false), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3, 3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_TRUE(test::all_close_f((vector{0, 0}), read_vector(result))); +} + +TEST(op_eval, reduce_sum_matrix_to_scalar_zero_by_zero) +{ + Shape shape_a{0, 0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{}; + auto axes = make_shared(element::i32, Shape{2}, vector{0, 1}); + auto f = + make_shared(make_shared(A, axes, false), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_TRUE(test::all_close_f((vector{0}), read_vector(result))); +} + +TEST(op_eval, reduce_sum_3d_eliminate_zero_dim) +{ + Shape shape_a{3, 0, 2}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{3, 2}; + auto axes = make_shared(element::i32, Shape{}, 1); + auto f = + make_shared(make_shared(A, axes, false), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + + // Overwrite the initial result vector to make sure we're not just coincidentally getting the + // right value. + copy_data(result, vector{2112, 2112, 2112, 2112, 2112, 2112}); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_TRUE(test::all_close_f((vector{0, 0, 0, 0, 0, 0}), read_vector(result))); +} + +TEST(op_eval, reduce_sum_3d_eliminate_zero_dim_int32) +{ + Shape shape_a{3, 0, 2}; + auto A = make_shared(element::i32, shape_a); + Shape shape_rt{3, 2}; + auto axes = make_shared(element::i32, Shape{}, 1); + auto f = + make_shared(make_shared(A, axes, false), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::i32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::i32, shape_rt); + + // Overwrite the initial result vector to make sure we're not just coincidentally getting the + // right value. + copy_data(result, vector{2112, 2112, 2112, 2112, 2112, 2112}); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_EQ((vector{0, 0, 0, 0, 0, 0}), read_vector(result)); +} + +TEST(op_eval, reduce_sum_dynamic) +{ + // Create a graph for f(x,axes:int32) = Sum(x,Convert(axes)). + auto x = make_shared(element::f32, PartialShape::dynamic()); + auto axes = make_shared(element::i32, PartialShape{Dimension::dynamic()}); + auto axes_i64 = make_shared(axes, element::i64); + + auto sum = make_shared(x, axes_i64, false); + ASSERT_TRUE(sum->get_output_partial_shape(0).rank().is_dynamic()); + + auto f = make_shared(NodeVector{sum}, ParameterVector{x, axes}); + + auto backend = runtime::Backend::create("INTERPRETER", true); + + auto ex = backend->compile(f); + + auto t_r = backend->create_dynamic_tensor(element::f32, PartialShape::dynamic()); + + std::vector x_shapes{ + Shape{2, 3}, Shape{2, 3}, Shape{2, 3}, Shape{2, 3}, Shape{5}, Shape{5}}; + std::vector> axeses{{}, {0}, {1}, {0, 1}, {}, {0}}; + std::vector> inputs{{1, 2, 3, 4, 5, 6}, + {1, 2, 3, 4, 5, 6}, + {1, 2, 3, 4, 5, 6}, + {1, 2, 3, 4, 5, 6}, + {1, 2, 3, 4, 5}, + {1, 2, 3, 4, 5}}; + std::vector expected_result_shapes{ + Shape{2, 3}, Shape{3}, Shape{2}, Shape{}, Shape{5}, Shape{}}; + std::vector> expected_results{ + {1, 2, 3, 4, 5, 6}, {5, 7, 9}, {6, 15}, {21}, {1, 2, 3, 4, 5}, {15}}; + + for (size_t i = 0; i < x_shapes.size(); i++) + { + auto t_x = backend->create_tensor(element::f32, x_shapes[i]); + auto t_axes = backend->create_tensor(element::i32, Shape{axeses[i].size()}); + + copy_data(t_x, inputs[i]); + copy_data(t_axes, axeses[i]); + + ex->call_with_validate({t_r}, {t_x, t_axes}); + + ASSERT_EQ(t_r->get_shape(), expected_result_shapes[i]); + + auto results = read_vector(t_r); + + ASSERT_TRUE(test::all_close_f(results, expected_results[i], MIN_FLOAT_TOLERANCE_BITS)); + } +} + +TEST(op_eval, reduce_sum_keep_matrix_rows_zero) +{ + Shape shape_a{3, 0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{3, 1}; + auto axes = make_shared(element::i32, Shape{}, 1); + auto f = + make_shared(make_shared(A, axes, true), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3, 3, 3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_TRUE(test::all_close_f((vector{0, 0, 0}), read_vector(result))); +} + +TEST(op_eval, reduce_sum_keep_matrix_cols_zero) +{ + // Now the reduction (g(x:float32[2,2],y:float32[]) = reduce(x,y,f,axes={})). + Shape shape_a{0, 2}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{1, 2}; + auto axes = make_shared(element::i32, Shape{}, 0); + auto f = + make_shared(make_shared(A, axes, true), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3, 3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_TRUE(test::all_close_f((vector{0, 0}), read_vector(result))); +} + +TEST(op_eval, reduce_sum_keep_vector_zero) +{ + Shape shape_a{0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{1}; + auto axes = make_shared(element::i32, Shape{}, 0); + auto f = + make_shared(make_shared(A, axes, true), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_TRUE(test::all_close_f((vector{0}), read_vector(result))); +} + +TEST(op_eval, reduce_sum_keep_matrix_to_scalar_zero_by_zero) +{ + Shape shape_a{0, 0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{1, 1}; + auto axes = make_shared(element::i32, Shape{2}, vector{0, 1}); + auto f = + make_shared(make_shared(A, axes, true), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_TRUE(test::all_close_f((vector{0}), read_vector(result))); +} + +TEST(op_eval, reduce_sum_keep_3d_eliminate_zero_dim) +{ + Shape shape_a{3, 0, 2}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{3, 1, 2}; + auto axes = make_shared(element::i32, Shape{}, 1); + auto f = + make_shared(make_shared(A, axes, true), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + + // Overwrite the initial result vector to make sure we're not just coincidentally getting the + // right value. + copy_data(result, vector{2112, 2112, 2112, 2112, 2112, 2112}); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_TRUE(test::all_close_f((vector{0, 0, 0, 0, 0, 0}), read_vector(result))); +} + +TEST(op_eval, reduce_sum_keep_3d_eliminate_zero_dim_int32) +{ + Shape shape_a{3, 0, 2}; + auto A = make_shared(element::i32, shape_a); + Shape shape_rt{3, 1, 2}; + auto axes = make_shared(element::i32, Shape{}, 1); + auto f = + make_shared(make_shared(A, axes, true), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::i32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::i32, shape_rt); + + // Overwrite the initial result vector to make sure we're not just coincidentally getting the + // right value. + copy_data(result, vector{2112, 2112, 2112, 2112, 2112, 2112}); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_EQ((vector{0, 0, 0, 0, 0, 0}), read_vector(result)); +} + +TEST(op_eval, reduce_sum_keep_dynamic) +{ + // Create a graph for f(x,axes:int32) = Sum(x,Convert(axes)). + auto x = make_shared(element::f32, PartialShape::dynamic()); + auto axes = make_shared(element::i32, PartialShape{Dimension::dynamic()}); + auto axes_i64 = make_shared(axes, element::i64); + + auto sum = make_shared(x, axes_i64, true); + ASSERT_TRUE(sum->get_output_partial_shape(0).rank().is_dynamic()); + + auto f = make_shared(NodeVector{sum}, ParameterVector{x, axes}); + + auto backend = runtime::Backend::create("INTERPRETER", true); + + auto ex = backend->compile(f); + + auto t_r = backend->create_dynamic_tensor(element::f32, PartialShape::dynamic()); + + std::vector x_shapes{ + Shape{2, 3}, Shape{2, 3}, Shape{2, 3}, Shape{2, 3}, Shape{5}, Shape{5}}; + std::vector> axeses{{}, {0}, {1}, {0, 1}, {}, {0}}; + std::vector> inputs{{1, 2, 3, 4, 5, 6}, + {1, 2, 3, 4, 5, 6}, + {1, 2, 3, 4, 5, 6}, + {1, 2, 3, 4, 5, 6}, + {1, 2, 3, 4, 5}, + {1, 2, 3, 4, 5}}; + std::vector expected_result_shapes{ + Shape{2, 3}, Shape{1, 3}, Shape{2, 1}, Shape{1, 1}, Shape{5}, Shape{1}}; + std::vector> expected_results{ + {1, 2, 3, 4, 5, 6}, {5, 7, 9}, {6, 15}, {21}, {1, 2, 3, 4, 5}, {15}}; + + for (size_t i = 0; i < x_shapes.size(); i++) + { + auto t_x = backend->create_tensor(element::f32, x_shapes[i]); + auto t_axes = backend->create_tensor(element::i32, Shape{axeses[i].size()}); + + copy_data(t_x, inputs[i]); + copy_data(t_axes, axeses[i]); + + ex->call_with_validate({t_r}, {t_x, t_axes}); + + ASSERT_EQ(t_r->get_shape(), expected_result_shapes[i]); + + auto results = read_vector(t_r); + + ASSERT_TRUE(test::all_close_f(results, expected_results[i], MIN_FLOAT_TOLERANCE_BITS)); + } +} diff --git a/ngraph/test/runtime/ie/unit_test.manifest b/ngraph/test/runtime/ie/unit_test.manifest index f95ce0d951e162..425ec0cdf48e30 100644 --- a/ngraph/test/runtime/ie/unit_test.manifest +++ b/ngraph/test/runtime/ie/unit_test.manifest @@ -368,36 +368,16 @@ any_2x0_to_scalar all_trivial all_2x0_to_scalar all_dynamic -reduce_sum_keep_dynamic -reduce_sum_keep_stable_simple_double -reduce_sum_keep_stable_acc_double -reduce_sum_keep_stable_acc -reduce_sum_keep_3d_eliminate_zero_dim -reduce_sum_keep_vector_zero -reduce_sum_keep_matrix_rows_zero -reduce_sum_dynamic -reduce_sum_3d_eliminate_zero_dim_int32 -reduce_sum_keep_3d_eliminate_zero_dim_int32 -reduce_sum_keep_trivial_in_double -reduce_sum_3d_eliminate_zero_dim -reduce_sum_matrix_to_scalar_zero_by_zero -reduce_sum_vector_zero -reduce_sum_matrix_cols_zero -reduce_sum_matrix_rows_zero -reduce_sum_keep_matrix_to_scalar_zero_by_zero -reduce_sum_keep_matrix_cols_zero -reduce_product_matrix_columns +# Reduce ops disabled/accuracy: 56520 +# disabled reference implementation +reduce_sum_keep_2d_to_scalar_int8 +reduce_sum_2d_to_scalar_int8 # accuracy reduce_sum_keep_stable_acc -reduce_sum_keep_2d_to_scalar_int8 reduce_sum_keep_3d_to_scalar_int32 reduce_sum_keep_large_1d_to_scalar -reduce_sum_stable_simple_double -reduce_sum_stable_acc_double reduce_sum_stable_acc -reduce_sum_trivial_in_double -reduce_sum_2d_to_scalar_int8 reduce_sum_3d_to_scalar_int32 reduce_sum_large_1d_to_scalar diff --git a/ngraph/test/runtime/interpreter/unit_test.manifest b/ngraph/test/runtime/interpreter/unit_test.manifest index b5003831265c9b..9e1231491521e3 100644 --- a/ngraph/test/runtime/interpreter/unit_test.manifest +++ b/ngraph/test/runtime/interpreter/unit_test.manifest @@ -3,6 +3,7 @@ fake_quantize_pdpd INTERPRETER.onnx_model_quant_conv_linear INTERPRETER.onnx_top_k_opset_10 +# Failed in ubuntu18 i386 reduce_sum_large_1d_to_scalar reduce_sum_keep_large_1d_to_scalar @@ -31,11 +32,8 @@ INTERPRETER.onnx_model_matmul_integer_4d_no_zero_point # Disabled tests for disabled reference implementations INTERPRETER.onnx_dyn_shapes_expand_uint16_dyn_shape INTERPRETER.sum_2d_to_scalar_int8 -INTERPRETER.sum_trivial_in_double INTERPRETER.reduce_sum_2d_to_scalar_int8 -INTERPRETER.reduce_sum_trivial_in_double INTERPRETER.reduce_sum_keep_2d_to_scalar_int8 -INTERPRETER.reduce_sum_keep_trivial_in_double INTERPRETER.reduce_product_to_scalar_int8 INTERPRETER.reduce_product_keep_to_scalar_int8 INTERPRETER.reduce_min_to_scalar_int8 From c8af311774385b22949a208aa1713d50b23c2224 Mon Sep 17 00:00:00 2001 From: Gabriele Galiero Casay Date: Fri, 11 Jun 2021 09:23:08 +0200 Subject: [PATCH 065/178] Revise reduction operations base classes (#5609) * Revise reduction operations base class * Fix visitor tests for logical reduction ops * Remove node validation checks that break backward compatibility with tests * Check for integer element type of axes input * Check for unique elements provided in axes input * Set mvn fusion test to have axes input with element type integral for ReduceMean nodes * [LPT] Revise reduction operations base classes support in LPT * Add node validation checks for integer element type of axes input in reduction operations * Add end of line to files * Implement output shape inference of reduction ops as member function * Add ReduceBase class to have a common method to infer output shape Co-authored-by: Edward Shogulin --- .../src/normalize_l2.cpp | 4 +- .../transformations/mvn_fusion_test.cpp | 20 +- .../src/normalize_l2_function.cpp | 6 +- .../transformations_after_split_function.cpp | 2 +- .../ngraph/op/util/arithmetic_reduction.hpp | 3 +- .../ngraph/op/util/logical_reduction.hpp | 3 +- .../include/ngraph/op/util/reduction_base.hpp | 39 ++ .../core/src/op/util/arithmetic_reduction.cpp | 52 +-- .../util/arithmetic_reductions_keep_dims.cpp | 79 ++-- ngraph/core/src/op/util/logical_reduction.cpp | 71 +--- .../op/util/logical_reduction_keep_dims.cpp | 71 +--- ngraph/core/src/op/util/reduction_base.cpp | 74 ++++ ngraph/test/CMakeLists.txt | 10 +- ngraph/test/type_prop/reduce_l1.cpp | 47 +-- ngraph/test/type_prop/reduce_l2.cpp | 47 +-- ngraph/test/type_prop/reduce_logical_and.cpp | 9 + ngraph/test/type_prop/reduce_logical_or.cpp | 9 + ngraph/test/type_prop/reduce_max.cpp | 9 + ngraph/test/type_prop/reduce_mean.cpp | 71 +--- ngraph/test/type_prop/reduce_min.cpp | 9 + ngraph/test/type_prop/reduce_ops.hpp | 388 ++++++++++++++++++ ngraph/test/type_prop/reduce_prod.cpp | 48 +-- ngraph/test/type_prop/reduce_sum.cpp | 48 +-- ngraph/test/visitors/op/reduce_ops.hpp | 2 +- 24 files changed, 649 insertions(+), 472 deletions(-) create mode 100644 ngraph/core/include/ngraph/op/util/reduction_base.hpp create mode 100644 ngraph/core/src/op/util/reduction_base.cpp create mode 100644 ngraph/test/type_prop/reduce_logical_and.cpp create mode 100644 ngraph/test/type_prop/reduce_logical_or.cpp create mode 100644 ngraph/test/type_prop/reduce_max.cpp create mode 100644 ngraph/test/type_prop/reduce_min.cpp create mode 100644 ngraph/test/type_prop/reduce_ops.hpp diff --git a/inference-engine/src/low_precision_transformations/src/normalize_l2.cpp b/inference-engine/src/low_precision_transformations/src/normalize_l2.cpp index 4368a48075f324..93dcdf8afbe551 100644 --- a/inference-engine/src/low_precision_transformations/src/normalize_l2.cpp +++ b/inference-engine/src/low_precision_transformations/src/normalize_l2.cpp @@ -120,10 +120,10 @@ bool NormalizeL2Transformation::transform(TransformationContext &context, ngraph } auto newNormalize = std::make_shared>( - std::vector{ element::f32, element::f32 }, + std::vector{ element::f32, axes->output(0).get_element_type() }, std::vector{deqPrecision}, ngraph::op::TemporaryReplaceOutputType(dequantization.subtract == nullptr ? dequantization.data : dequantization.subtract, element::f32).get(), - ngraph::op::TemporaryReplaceOutputType(axes->clone_with_new_inputs({}), element::f32).get(), + axes, normalize->get_eps(), normalize->get_eps_mode()); NetworkHelper::copyInfo(normalize, newNormalize); diff --git a/inference-engine/tests/functional/inference_engine/transformations/mvn_fusion_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/mvn_fusion_test.cpp index e45258a63e67b3..ecad9adff3df5f 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/mvn_fusion_test.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/mvn_fusion_test.cpp @@ -30,7 +30,7 @@ TEST(TransformationTests, MVNFusionTestOutside) { auto sub2 = std::make_shared(input, mean2); auto const_2 = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{}, { 2 }); auto power_sqr = std::make_shared(sub2, const_2); - auto mean3_axes = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{ 3 }, { 1, 2, 3 }); + auto mean3_axes = ngraph::opset6::Constant::create(ngraph::element::i32, ngraph::Shape{ 3 }, { 1, 2, 3 }); auto mean3 = std::make_shared(power_sqr, mean3_axes); auto const_0_5 = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{}, { 0.5 }); auto power_sqrt = std::make_shared(mean3, const_0_5); @@ -70,7 +70,7 @@ TEST(TransformationTests, MVNFusionTestReuseSub) { auto sub1 = std::make_shared(input, mean1); auto const_2 = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{}, { 2 }); auto power_sqr = std::make_shared(sub1, const_2); - auto mean3_axes = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{ 3 }, { 1, 2, 3 }); + auto mean3_axes = ngraph::opset6::Constant::create(ngraph::element::i32, ngraph::Shape{ 3 }, { 1, 2, 3 }); auto mean3 = std::make_shared(power_sqr, mean3_axes); auto const_0_5 = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{}, { 0.5 }); auto power_sqrt = std::make_shared(mean3, const_0_5); @@ -111,7 +111,7 @@ TEST(TransformationTests, MVNFusionTestWithConvert) { auto cast = std::make_shared(sub1, ngraph::element::f32); auto const_2 = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{}, { 2 }); auto power_sqr = std::make_shared(cast, const_2); - auto mean3_axes = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{ 3 }, { 1, 2, 3 }); + auto mean3_axes = ngraph::opset6::Constant::create(ngraph::element::i32, ngraph::Shape{ 3 }, { 1, 2, 3 }); auto mean3 = std::make_shared(power_sqr, mean3_axes); auto const_0_5 = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{}, { 0.5 }); auto power_sqrt = std::make_shared(mean3, const_0_5); @@ -151,7 +151,7 @@ TEST(TransformationTests, MVNFusionTestSqrt) { auto sub1 = std::make_shared(input, mean1); auto const_2 = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{}, { 2 }); auto power_sqr = std::make_shared(sub1, const_2); - auto mean3_axes = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{ 3 }, { 1, 2, 3 }); + auto mean3_axes = ngraph::opset6::Constant::create(ngraph::element::i32, ngraph::Shape{ 3 }, { 1, 2, 3 }); auto mean3 = std::make_shared(power_sqr, mean3_axes); auto power_sqrt = std::make_shared(mean3); auto eps = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{}, { 1e-9 }); @@ -190,7 +190,7 @@ TEST(TransformationTests, MVNFusionTestAltDiv) { auto sub1 = std::make_shared(input, mean1); auto const_2 = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{}, { 2 }); auto power_sqr = std::make_shared(sub1, const_2); - auto mean3_axes = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{ 3 }, { 1, 2, 3 }); + auto mean3_axes = ngraph::opset6::Constant::create(ngraph::element::i32, ngraph::Shape{ 3 }, { 1, 2, 3 }); auto mean3 = std::make_shared(power_sqr, mean3_axes); auto const_0_5 = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{}, { 0.5 }); auto power_sqrt = std::make_shared(mean3, const_0_5); @@ -231,7 +231,7 @@ TEST(TransformationTests, MVNFusionTestInsideSqrt) { auto sub2 = std::make_shared(input, mean2); auto const_2 = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{}, { 2 }); auto power_sqr = std::make_shared(sub2, const_2); - auto mean3_axes = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{ 3 }, { 1, 2, 3 }); + auto mean3_axes = ngraph::opset6::Constant::create(ngraph::element::i32, ngraph::Shape{ 3 }, { 1, 2, 3 }); auto mean3 = std::make_shared(power_sqr, mean3_axes); auto eps = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{}, { 1e-9 }); auto add_eps = std::make_shared(mean3, eps); @@ -271,7 +271,7 @@ TEST(TransformationTests, MVNFusionTestReuseSubInsideSqrt) { auto sub1 = std::make_shared(input, mean1); auto const_2 = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{}, { 2 }); auto power_sqr = std::make_shared(sub1, const_2); - auto mean3_axes = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{ 3 }, { 1, 2, 3 }); + auto mean3_axes = ngraph::opset6::Constant::create(ngraph::element::i32, ngraph::Shape{ 3 }, { 1, 2, 3 }); auto mean3 = std::make_shared(power_sqr, mean3_axes); auto eps = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{}, { 1e-9 }); auto add_eps = std::make_shared(mean3, eps); @@ -312,7 +312,7 @@ TEST(TransformationTests, MVNFusionTestWithConvertInsideSqrt) { auto cast = std::make_shared(sub1, ngraph::element::f32); auto const_2 = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{}, { 2 }); auto power_sqr = std::make_shared(cast, const_2); - auto mean3_axes = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{ 3 }, { 1, 2, 3 }); + auto mean3_axes = ngraph::opset6::Constant::create(ngraph::element::i32, ngraph::Shape{ 3 }, { 1, 2, 3 }); auto mean3 = std::make_shared(power_sqr, mean3_axes); auto eps = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{}, { 1e-9 }); auto add_eps = std::make_shared(mean3, eps); @@ -352,7 +352,7 @@ TEST(TransformationTests, MVNFusionTestSqrtInsideSqrt) { auto sub1 = std::make_shared(input, mean1); auto const_2 = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{}, { 2 }); auto power_sqr = std::make_shared(sub1, const_2); - auto mean3_axes = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{ 3 }, { 1, 2, 3 }); + auto mean3_axes = ngraph::opset6::Constant::create(ngraph::element::i32, ngraph::Shape{ 3 }, { 1, 2, 3 }); auto mean3 = std::make_shared(power_sqr, mean3_axes); auto eps = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{}, { 1e-9 }); auto add_eps = std::make_shared(mean3, eps); @@ -391,7 +391,7 @@ TEST(TransformationTests, MVNFusionTestAltDivInsideSqrt) { auto sub1 = std::make_shared(input, mean1); auto const_2 = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{}, { 2 }); auto power_sqr = std::make_shared(sub1, const_2); - auto mean3_axes = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{ 3 }, { 1, 2, 3 }); + auto mean3_axes = ngraph::opset6::Constant::create(ngraph::element::i32, ngraph::Shape{ 3 }, { 1, 2, 3 }); auto mean3 = std::make_shared(power_sqr, mean3_axes); auto eps = ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape{}, { 1e-9 }); auto add_eps = std::make_shared(mean3, eps); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/normalize_l2_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/normalize_l2_function.cpp index 553ec6575ec5cd..4d1ef00a598fea 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/normalize_l2_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/normalize_l2_function.cpp @@ -36,7 +36,7 @@ std::shared_ptr NormalizeL2Function::getOriginal( fakeQuantize->set_friendly_name("fakeQuantize"); - const auto axesNode = std::make_shared(ngraph::element::u64, ngraph::Shape{ axes.size() }, axes); + const auto axesNode = std::make_shared(ngraph::element::i64, ngraph::Shape{ axes.size() }, axes); axesNode->set_friendly_name("axes"); const auto normalizeL2 = std::make_shared(fakeQuantize->output(0), axesNode, 1e-6, ngraph::op::EpsMode::ADD); normalizeL2->set_friendly_name("normalizeL2"); @@ -104,10 +104,10 @@ std::shared_ptr NormalizeL2Function::getReference( const auto axesNode = std::make_shared(ngraph::element::i64, ngraph::Shape{ axes.size() }, axes); const auto normalizeL2 = std::make_shared>( - std::vector{ element::f32, element::f32 }, + std::vector{ element::f32, axesNode->output(0).get_element_type() }, std::vector{dequantizationAfter.empty() ? precision : element::f32}, ngraph::op::TemporaryReplaceOutputType(deqBefore, element::f32).get(), - ngraph::op::TemporaryReplaceOutputType(axesNode, element::f32).get(), + axesNode, 1e-6, epsMode); auto& rtInfo = normalizeL2->get_rt_info(); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/transformations_after_split_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/transformations_after_split_function.cpp index 8b2010abb76a12..ad8fd6715925ee 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/transformations_after_split_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/transformations_after_split_function.cpp @@ -137,7 +137,7 @@ std::shared_ptr TransformationsAfterSplitFunction::getLayerByTransformatio } if (transformationName == "NormalizeL2Transformation") { const auto dequantization = makeDequantization(parent, { {element::f32}, {}, { 0.1f } }); - const auto axesNode = opset1::Constant::create(element::u64, ngraph::Shape{ 3 }, { 1, 2, 3 }); + const auto axesNode = opset1::Constant::create(element::i64, ngraph::Shape{ 3 }, { 1, 2, 3 }); return std::make_shared(dequantization, axesNode, 1e-6, ngraph::op::EpsMode::ADD); } if (transformationName == "PReluTransformation") { diff --git a/ngraph/core/include/ngraph/op/util/arithmetic_reduction.hpp b/ngraph/core/include/ngraph/op/util/arithmetic_reduction.hpp index 2d433e340d21de..6f9484ab340c05 100644 --- a/ngraph/core/include/ngraph/op/util/arithmetic_reduction.hpp +++ b/ngraph/core/include/ngraph/op/util/arithmetic_reduction.hpp @@ -5,6 +5,7 @@ #pragma once #include "ngraph/op/op.hpp" +#include "ngraph/op/util/reduction_base.hpp" namespace ngraph { @@ -15,7 +16,7 @@ namespace ngraph /// \brief Abstract base class for arithmetic reduction operations, i.e., operations /// where chosen axes of the input tensors are eliminated (reduced out) by /// repeated application of a particular binary arithmetic operation. - class NGRAPH_API ArithmeticReduction : public Op + class NGRAPH_API ArithmeticReduction : public ReductionBase { protected: /// \brief Constructs an arithmetic reduction operation. diff --git a/ngraph/core/include/ngraph/op/util/logical_reduction.hpp b/ngraph/core/include/ngraph/op/util/logical_reduction.hpp index 0fa85369b3187c..1c8953ba1fd9c1 100644 --- a/ngraph/core/include/ngraph/op/util/logical_reduction.hpp +++ b/ngraph/core/include/ngraph/op/util/logical_reduction.hpp @@ -5,6 +5,7 @@ #pragma once #include "ngraph/op/op.hpp" +#include "ngraph/op/util/reduction_base.hpp" namespace ngraph { @@ -15,7 +16,7 @@ namespace ngraph /// \brief Abstract base class for logical reduction operations, i.e., operations where /// chosen axes of the input tensors are eliminated (reduced out) by repeated /// application of a particular binary logical operation. - class NGRAPH_API LogicalReduction : public Op + class NGRAPH_API LogicalReduction : public ReductionBase { protected: /// \brief Constructs a logical reduction operation. diff --git a/ngraph/core/include/ngraph/op/util/reduction_base.hpp b/ngraph/core/include/ngraph/op/util/reduction_base.hpp new file mode 100644 index 00000000000000..5cc10b0be7e217 --- /dev/null +++ b/ngraph/core/include/ngraph/op/util/reduction_base.hpp @@ -0,0 +1,39 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "ngraph/op/op.hpp" + +namespace ngraph +{ + namespace op + { + namespace util + { + class NGRAPH_API ReductionBase : public Op + { + protected: + /// \brief Constructs a reduction operation. + ReductionBase(); + + /// \brief Constructs a reduction operation. + /// + /// \param arg Output that produces the first input tensor. + /// \param reduction_axes The axis positions (0-based) to be eliminated. + ReductionBase(const Output& arg, const Output& reduction_axes); + + /// \brief Infers reduction operations output shape. + /// + /// \param[in] keep_dims Reduction operation keeps dimensions. + /// + /// \return Partial shape of the output. + PartialShape infer_reduction_output_shape(const bool keep_dims); + + public: + NGRAPH_RTTI_DECLARATION; + }; + } // namespace util + } // namespace op +} // namespace ngraph \ No newline at end of file diff --git a/ngraph/core/src/op/util/arithmetic_reduction.cpp b/ngraph/core/src/op/util/arithmetic_reduction.cpp index beb40801ea9636..67b7abeaf20bbd 100644 --- a/ngraph/core/src/op/util/arithmetic_reduction.cpp +++ b/ngraph/core/src/op/util/arithmetic_reduction.cpp @@ -16,7 +16,7 @@ op::util::ArithmeticReduction::ArithmeticReduction() {} op::util::ArithmeticReduction::ArithmeticReduction(const Output& arg, const Output& reduction_axes) - : Op({arg, reduction_axes}) + : ReductionBase(arg, reduction_axes) { } @@ -49,51 +49,15 @@ void op::util::ArithmeticReduction::set_reduction_axes(const AxisSet& reduction_ void op::util::ArithmeticReduction::validate_and_infer_types() { NGRAPH_OP_SCOPE(util_ArithmeticReduction_validate_and_infer_types); - auto input_shape = get_input_partial_shape(0); - const auto input_rank = input_shape.rank(); - PartialShape result_shape{PartialShape::dynamic()}; - - auto axes = get_constant_from_source(input_value(1)); - if (input_rank.is_static() && axes) - { - AxisSet reduction_axes; - const auto reduction_axes_val = axes->cast_vector(); - for (auto axis : reduction_axes_val) - { - try - { - axis = normalize_axis(this, axis, input_rank); - } - catch (const ngraph_error&) - { - NODE_VALIDATION_CHECK(this, - false, - "Reduction axis (", - axis, - ") is out of bounds ", - "(argument shape: ", - input_shape, - ", reduction axes: ", - reduction_axes, - ")"); - } - reduction_axes.insert(axis); - } - - std::vector dims; - for (int64_t i = 0; i < input_rank.get_length(); i++) - { - if (reduction_axes.count(i) == 0) - { - dims.push_back(input_shape[i]); - } - } - - result_shape = PartialShape(dims); - } + const PartialShape& axes_shape = get_input_partial_shape(1); + const Rank axes_rank = axes_shape.rank(); + NODE_VALIDATION_CHECK(this, + axes_rank.compatible(0) || axes_rank.compatible(1), + "Axes input must be a scalar or 1D input. Got: ", + axes_shape); + PartialShape result_shape = infer_reduction_output_shape(false); set_input_is_relevant_to_shape(1); - set_output_type(0, get_input_element_type(0), result_shape); } diff --git a/ngraph/core/src/op/util/arithmetic_reductions_keep_dims.cpp b/ngraph/core/src/op/util/arithmetic_reductions_keep_dims.cpp index dcb420c083893b..0a7a5eeb792b8a 100644 --- a/ngraph/core/src/op/util/arithmetic_reductions_keep_dims.cpp +++ b/ngraph/core/src/op/util/arithmetic_reductions_keep_dims.cpp @@ -32,61 +32,28 @@ bool ngraph::op::util::ArithmeticReductionKeepDims::visit_attributes(AttributeVi void op::util::ArithmeticReductionKeepDims::validate_and_infer_types() { NGRAPH_OP_SCOPE(v0_util_ArithmeticReductionKeepDims_validate_and_infer_types); - if (m_keep_dims) - { - auto input_shape = get_input_partial_shape(0); - auto input_rank = input_shape.rank(); - PartialShape result_shape{PartialShape::dynamic()}; - if (input_rank.is_static()) - result_shape = PartialShape::dynamic(input_rank); - - const auto& axes = get_constant_from_source(input_value(1)); - if (input_rank.is_static() && axes) - { - AxisSet reduction_axes; - auto reduction_axes_val = axes->cast_vector(); - for (auto axis : reduction_axes_val) - { - try - { - axis = normalize_axis(this, axis, input_rank); - } - catch (const ngraph_error&) - { - NODE_VALIDATION_CHECK(this, - false, - "Reduction axis (", - axis, - ") is out of bounds ", - "(argument shape: ", - input_shape, - ", reduction axes: ", - reduction_axes, - ")"); - } - reduction_axes.insert(axis); - } - - std::vector dims; - for (int64_t i = 0; i < input_rank.get_length(); i++) - { - if (reduction_axes.count(i) == 0) - { - dims.push_back(input_shape[i]); - } - else - { - dims.emplace_back(Dimension{1}); - } - } - result_shape = PartialShape(dims); - } - set_input_is_relevant_to_shape(1); - set_output_type(0, get_input_element_type(0), result_shape); - } - else - { - ArithmeticReduction::validate_and_infer_types(); - } + const element::Type& data_et = get_input_element_type(0); + const PartialShape& axes_shape = get_input_partial_shape(1); + const element::Type& axes_et = get_input_element_type(1); + + NODE_VALIDATION_CHECK(this, + data_et.is_real() || data_et.is_integral_number(), + "Element type of data input must be numeric. Got: ", + data_et); + + NODE_VALIDATION_CHECK(this, + axes_et.is_integral_number(), + "Element type of axes input must be integer. Got: ", + axes_et); + + const Rank axes_rank = axes_shape.rank(); + NODE_VALIDATION_CHECK(this, + axes_rank.compatible(0) || axes_rank.compatible(1), + "Axes input must be a scalar or 1D input. Got: ", + axes_shape); + + PartialShape result_shape = infer_reduction_output_shape(m_keep_dims); + set_input_is_relevant_to_shape(1); + set_output_type(0, data_et, result_shape); } diff --git a/ngraph/core/src/op/util/logical_reduction.cpp b/ngraph/core/src/op/util/logical_reduction.cpp index bd3895834d8be4..5d5ad8222ea3b6 100644 --- a/ngraph/core/src/op/util/logical_reduction.cpp +++ b/ngraph/core/src/op/util/logical_reduction.cpp @@ -15,17 +15,17 @@ NGRAPH_RTTI_DEFINITION(op::util::LogicalReduction, "LogicalReduction", 1); op::util::LogicalReduction::LogicalReduction() {} op::util::LogicalReduction::LogicalReduction(const Output& arg, const AxisSet& reduction_axes) - : Op({arg, - op::Constant::create( - element::i64, Shape{reduction_axes.size()}, reduction_axes.to_vector()) - ->output(0)}) + : ReductionBase(arg, + op::Constant::create( + element::i64, Shape{reduction_axes.size()}, reduction_axes.to_vector()) + ->output(0)) { add_provenance_group_member(input_value(1).get_node_shared_ptr()); } op::util::LogicalReduction::LogicalReduction(const Output& arg, const Output& reduction_axes) - : Op({arg, reduction_axes}) + : ReductionBase(arg, reduction_axes) { } @@ -54,59 +54,20 @@ void op::util::LogicalReduction::set_reduction_axes(const AxisSet& reduction_axe void op::util::LogicalReduction::validate_and_infer_types() { NGRAPH_OP_SCOPE(util_LogicalReduction_validate_and_infer_types); - auto input_shape = get_input_partial_shape(0); - auto input_rank = input_shape.rank(); - PartialShape result_shape{PartialShape::dynamic()}; + const element::Type& data_et = get_input_element_type(0); + const PartialShape& axes_shape = get_input_partial_shape(1); - set_input_is_relevant_to_shape(1); + NODE_VALIDATION_CHECK( + this, data_et.compatible(element::boolean), "Element type of data input must be boolean."); + const Rank axes_rank = axes_shape.rank(); NODE_VALIDATION_CHECK(this, - get_input_element_type(0).compatible(element::boolean), - "Input element type must be boolean."); - - set_output_type(0, element::boolean, result_shape); - - if (input_rank.is_dynamic()) - return; - - if (const auto axes_const = get_constant_from_source(input_value(1))) - { - AxisSet reduction_axes; - auto reduction_axes_val = axes_const->cast_vector(); - for (auto axis : reduction_axes_val) - { - try - { - axis = normalize_axis(this, axis, input_rank); - } - catch (const ngraph_error&) - { - NODE_VALIDATION_CHECK(this, - false, - "Reduction axis (", - axis, - ") is out of bounds ", - "(argument shape: ", - input_shape, - ", reduction axes: ", - reduction_axes, - ")"); - } - reduction_axes.insert(axis); - } + axes_rank.compatible(0) || axes_rank.compatible(1), + "Axes input must be a scalar or 1D input. Got: ", + axes_shape); - std::vector dims; - for (int64_t i = 0; i < input_rank.get_length(); i++) - { - if (reduction_axes.count(i) == 0) - { - dims.push_back(input_shape[i]); - } - } - - result_shape = PartialShape(dims); - } - - set_output_type(0, element::boolean, result_shape); + PartialShape result_shape = infer_reduction_output_shape(false); + set_input_is_relevant_to_shape(1); + set_output_type(0, data_et, result_shape); } diff --git a/ngraph/core/src/op/util/logical_reduction_keep_dims.cpp b/ngraph/core/src/op/util/logical_reduction_keep_dims.cpp index ea7188eaa844af..f2d366e0a97ce8 100644 --- a/ngraph/core/src/op/util/logical_reduction_keep_dims.cpp +++ b/ngraph/core/src/op/util/logical_reduction_keep_dims.cpp @@ -32,63 +32,26 @@ bool ngraph::op::util::LogicalReductionKeepDims::visit_attributes(AttributeVisit void op::util::LogicalReductionKeepDims::validate_and_infer_types() { NGRAPH_OP_SCOPE(v0_util_LogicalReductionKeepDims_validate_and_infer_types); - if (m_keep_dims) - { - const auto input_shape = get_input_partial_shape(0); - const auto input_rank = input_shape.rank(); - PartialShape result_shape{PartialShape::dynamic(input_rank)}; - set_input_is_relevant_to_shape(1); - set_output_type(0, get_input_element_type(0), result_shape); + const element::Type& data_et = get_input_element_type(0); + const PartialShape& axes_shape = get_input_partial_shape(1); + const element::Type& axes_et = get_input_element_type(1); - if (input_shape.is_dynamic()) - return; + NODE_VALIDATION_CHECK( + this, data_et.compatible(element::boolean), "Element type of data input must be boolean."); - if (auto axes_const = get_constant_from_source(input_value(1))) - { - AxisSet reduction_axes; - auto reduction_axes_val = axes_const->cast_vector(); - for (auto axis : reduction_axes_val) - { - try - { - axis = normalize_axis(this, axis, input_rank); - } - catch (const ngraph_error&) - { - NODE_VALIDATION_CHECK(this, - false, - "Reduction axis (", - axis, - ") is out of bounds ", - "(argument shape: ", - input_shape, - ", reduction axes: ", - reduction_axes, - ")"); - } - reduction_axes.insert(axis); - } + NODE_VALIDATION_CHECK(this, + axes_et.is_integral_number(), + "Element type of axes input must be integer. Got: ", + axes_et); - std::vector dims; - for (int64_t i = 0; i < input_rank.get_length(); i++) - { - if (reduction_axes.count(i) == 0) - { - dims.push_back(input_shape[i]); - } - else - { - dims.emplace_back(Dimension{1}); - } - } - result_shape = PartialShape(dims); - } + const Rank axes_rank = axes_shape.rank(); + NODE_VALIDATION_CHECK(this, + axes_rank.compatible(0) || axes_rank.compatible(1), + "Axes input must be a scalar or 1D input. Got: ", + axes_shape); - set_output_type(0, get_input_element_type(0), result_shape); - } - else - { - LogicalReduction::validate_and_infer_types(); - } + PartialShape result_shape = infer_reduction_output_shape(m_keep_dims); + set_input_is_relevant_to_shape(1); + set_output_type(0, data_et, result_shape); } diff --git a/ngraph/core/src/op/util/reduction_base.cpp b/ngraph/core/src/op/util/reduction_base.cpp new file mode 100644 index 00000000000000..bdfead647fb888 --- /dev/null +++ b/ngraph/core/src/op/util/reduction_base.cpp @@ -0,0 +1,74 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "ngraph/op/util/reduction_base.hpp" +#include "itt.hpp" +#include "ngraph/op/constant.hpp" +#include "ngraph/validation_util.hpp" + +using namespace std; +using namespace ngraph; + +NGRAPH_RTTI_DEFINITION(op::util::ReductionBase, "ReductionBase", 0); + +op::util::ReductionBase::ReductionBase() {} + +op::util::ReductionBase::ReductionBase(const Output& arg, const Output& reduction_axes) + : Op({arg, reduction_axes}) +{ +} + +PartialShape op::util::ReductionBase::infer_reduction_output_shape(const bool keep_dims) +{ + const PartialShape& data_ps = get_input_partial_shape(0); + PartialShape result_ps{PartialShape::dynamic()}; + Rank data_rank = data_ps.rank(); + + if (data_rank.is_static() && keep_dims) + { + result_ps = PartialShape::dynamic(data_rank); + } + + const auto& axes = get_constant_from_source(input_value(1)); + if (data_rank.is_static() && axes) + { + AxisSet reduction_axes; + auto reduction_axes_val = axes->cast_vector(); + for (auto axis : reduction_axes_val) + { + try + { + axis = normalize_axis(this, axis, data_rank); + } + catch (const ngraph_error&) + { + NODE_VALIDATION_CHECK(this, + false, + "Reduction axis (", + axis, + ") is out of bounds ", + "(argument shape: ", + data_ps, + ", reduction axes: ", + reduction_axes, + ")"); + } + reduction_axes.insert(axis); + } + std::vector dims; + for (int64_t i = 0; i < data_rank.get_length(); i++) + { + if (reduction_axes.count(i) == 0) + { + dims.push_back(data_ps[i]); + } + else if (keep_dims) + { + dims.emplace_back(Dimension{1}); + } + } + result_ps = PartialShape(dims); + } + return result_ps; +} diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index c629111ca147c1..a2a619007b619f 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -173,6 +173,13 @@ set(SRC type_prop/read_value.cpp type_prop/reduce_l1.cpp type_prop/reduce_l2.cpp + type_prop/reduce_logical_and.cpp + type_prop/reduce_logical_or.cpp + type_prop/reduce_max.cpp + type_prop/reduce_mean.cpp + type_prop/reduce_min.cpp + type_prop/reduce_prod.cpp + type_prop/reduce_sum.cpp type_prop/reorg_yolo.cpp type_prop/reshape.cpp type_prop/result.cpp @@ -199,9 +206,6 @@ set(SRC type_prop/squared_difference.cpp type_prop/squeeze.cpp type_prop/swish.cpp - type_prop/reduce_mean.cpp - type_prop/reduce_prod.cpp - type_prop/reduce_sum.cpp type_prop/ti.cpp type_prop/tile.cpp type_prop/top_k.cpp diff --git a/ngraph/test/type_prop/reduce_l1.cpp b/ngraph/test/type_prop/reduce_l1.cpp index 07947615747da8..03f22e20f82bde 100644 --- a/ngraph/test/type_prop/reduce_l1.cpp +++ b/ngraph/test/type_prop/reduce_l1.cpp @@ -2,47 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" -#include "util/type_prop.hpp" +#include "reduce_ops.hpp" -using namespace std; -using namespace ngraph; - -TEST(type_prop, reduce_l1_v4_axis_out_of_range) -{ - auto arg = make_shared(element::f32, Shape{1, 2, 3}); - auto axes = make_shared(element::i64, Shape{2}, vector{2, 3}); - try - { - auto reduce_sum = make_shared(arg, axes); - // Should have thrown, so fail if it didn't - FAIL() << "Incorrect axes values exception not thrown"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), std::string("Reduction axis (")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, reduce_l1_v4_shape_if_keep_dims) -{ - auto arg = make_shared(element::f32, Shape{3, 4, 5}); - auto axes = make_shared(element::i64, Shape{2}, vector{1, 2}); - auto keep_dims = true; - auto reduce_prod = make_shared(arg, axes, keep_dims); - ASSERT_TRUE(reduce_prod->get_output_partial_shape(0).compatible(PartialShape{3, 1, 1})); -} - -TEST(type_prop, reduce_l1_v4_shape_if_not_keep_dims) -{ - auto arg = make_shared(element::f32, Shape{3, 4, 5}); - auto axes = make_shared(element::i64, Shape{2}, vector{1, 2}); - auto keep_dims = false; - auto reduce_prod = make_shared(arg, axes, keep_dims); - ASSERT_TRUE(reduce_prod->get_output_partial_shape(0).compatible(PartialShape{3})); -} +using Type = ::testing::Types; +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_reduce_l1, ReduceTest, Type); +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_reduce_l1_et, ReduceArithmeticTest, Type); diff --git a/ngraph/test/type_prop/reduce_l2.cpp b/ngraph/test/type_prop/reduce_l2.cpp index f2c2541b3852a4..64a9c02fb8751c 100644 --- a/ngraph/test/type_prop/reduce_l2.cpp +++ b/ngraph/test/type_prop/reduce_l2.cpp @@ -2,47 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" -#include "util/type_prop.hpp" +#include "reduce_ops.hpp" -using namespace std; -using namespace ngraph; - -TEST(type_prop, reduce_l2_v4_axis_out_of_range) -{ - auto arg = make_shared(element::f32, Shape{1, 2, 3}); - auto axes = make_shared(element::i64, Shape{2}, vector{2, 3}); - try - { - auto reduce_sum = make_shared(arg, axes); - // Should have thrown, so fail if it didn't - FAIL() << "Incorrect axes values exception not thrown"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), std::string("Reduction axis (")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, reduce_l2_v4_shape_if_keep_dims) -{ - auto arg = make_shared(element::f32, Shape{3, 4, 5}); - auto axes = make_shared(element::i64, Shape{2}, vector{1, 2}); - auto keep_dims = true; - auto reduce_prod = make_shared(arg, axes, keep_dims); - ASSERT_TRUE(reduce_prod->get_output_partial_shape(0).compatible(PartialShape{3, 1, 1})); -} - -TEST(type_prop, reduce_l2_v4_shape_if_not_keep_dims) -{ - auto arg = make_shared(element::f32, Shape{3, 4, 5}); - auto axes = make_shared(element::i64, Shape{2}, vector{1, 2}); - auto keep_dims = false; - auto reduce_prod = make_shared(arg, axes, keep_dims); - ASSERT_TRUE(reduce_prod->get_output_partial_shape(0).compatible(PartialShape{3})); -} +using Type = ::testing::Types; +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_reduce_l2, ReduceTest, Type); +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_reduce_l2_et, ReduceArithmeticTest, Type); diff --git a/ngraph/test/type_prop/reduce_logical_and.cpp b/ngraph/test/type_prop/reduce_logical_and.cpp new file mode 100644 index 00000000000000..f6e051bb50f12d --- /dev/null +++ b/ngraph/test/type_prop/reduce_logical_and.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "reduce_ops.hpp" + +using Type = ::testing::Types; +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_reduce_logical_and, ReduceTest, Type); +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_reduce_logical_and_et, ReduceLogicalTest, Type); diff --git a/ngraph/test/type_prop/reduce_logical_or.cpp b/ngraph/test/type_prop/reduce_logical_or.cpp new file mode 100644 index 00000000000000..b73d1789a20ebc --- /dev/null +++ b/ngraph/test/type_prop/reduce_logical_or.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "reduce_ops.hpp" + +using Type = ::testing::Types; +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_reduce_logical_or, ReduceTest, Type); +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_reduce_logical_or_et, ReduceLogicalTest, Type); diff --git a/ngraph/test/type_prop/reduce_max.cpp b/ngraph/test/type_prop/reduce_max.cpp new file mode 100644 index 00000000000000..d907d1066af086 --- /dev/null +++ b/ngraph/test/type_prop/reduce_max.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "reduce_ops.hpp" + +using Type = ::testing::Types; +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_reduce_max, ReduceTest, Type); +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_reduce_max_et, ReduceArithmeticTest, Type); diff --git a/ngraph/test/type_prop/reduce_mean.cpp b/ngraph/test/type_prop/reduce_mean.cpp index 5f184fab97dd4c..607e8392f1e37b 100644 --- a/ngraph/test/type_prop/reduce_mean.cpp +++ b/ngraph/test/type_prop/reduce_mean.cpp @@ -2,71 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" -#include "util/type_prop.hpp" +#include "reduce_ops.hpp" -using namespace std; -using namespace ngraph; - -TEST(type_prop, reduce_mean_v1_axis_out_of_range) -{ - auto arg = make_shared(element::f32, Shape{1, 2, 3}); - auto axes = make_shared(element::i64, Shape{2}, vector{2, 3}); - try - { - auto reduce_sum = make_shared(arg, axes); - - // Should have thrown, so fail if it didn't - FAIL() << "Incorrect axes values exception not thrown"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), std::string("Reduction axis (")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, reduce_mean_v1_shape_if_keep_dims) -{ - auto arg = make_shared(element::f32, Shape{3, 4, 5}); - auto axes = make_shared(element::i64, Shape{2}, vector{1, 2}); - auto keep_dims = true; - auto reduce_prod = make_shared(arg, axes, keep_dims); - ASSERT_TRUE(reduce_prod->get_output_partial_shape(0).compatible(PartialShape{3, 1, 1})); -} - -TEST(type_prop, reduce_mean_v1_shape_if_not_keep_dims) -{ - auto arg = make_shared(element::f32, Shape{3, 4, 5}); - auto axes = make_shared(element::i64, Shape{2}, vector{1, 2}); - auto keep_dims = false; - auto reduce_prod = make_shared(arg, axes, keep_dims); - ASSERT_TRUE(reduce_prod->get_output_partial_shape(0).compatible(PartialShape{3})); -} - -TEST(type_prop, reduce_mean_dynamic_shape) -{ - auto arg = - make_shared(element::f32, PartialShape{3, 4, 5, Dimension::dynamic()}); - auto axes = make_shared(element::i64, Shape{2}, vector{1, 2}); - auto keep_dims = true; - auto reduce_prod = make_shared(arg, axes, keep_dims); - ASSERT_TRUE(reduce_prod->get_output_partial_shape(0).compatible( - PartialShape{3, 1, 1, Dimension::dynamic()})); -} - -TEST(type_prop, reduce_mean_reduce_dynamic_shape) -{ - auto arg = - make_shared(element::f32, PartialShape{3, 4, 5, Dimension::dynamic()}); - auto axes = make_shared(element::i64, Shape{2}, vector{1, 3}); - auto keep_dims = true; - auto reduce_prod = make_shared(arg, axes, keep_dims); - - ASSERT_TRUE(reduce_prod->get_output_partial_shape(0).compatible( - PartialShape{3, 1, 5, Dimension::dynamic()})); -} +using Type = ::testing::Types; +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_reduce_mean, ReduceTest, Type); +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_reduce_mean_et, ReduceArithmeticTest, Type); diff --git a/ngraph/test/type_prop/reduce_min.cpp b/ngraph/test/type_prop/reduce_min.cpp new file mode 100644 index 00000000000000..d02f12f8a0a8f7 --- /dev/null +++ b/ngraph/test/type_prop/reduce_min.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "reduce_ops.hpp" + +using Type = ::testing::Types; +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_reduce_min, ReduceTest, Type); +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_reduce_min_et, ReduceArithmeticTest, Type); diff --git a/ngraph/test/type_prop/reduce_ops.hpp b/ngraph/test/type_prop/reduce_ops.hpp new file mode 100644 index 00000000000000..9aa7503e448bcd --- /dev/null +++ b/ngraph/test/type_prop/reduce_ops.hpp @@ -0,0 +1,388 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "util/type_prop.hpp" + +using namespace std; +using namespace ngraph; + +struct ReduceParams +{ + PartialShape data_ps; + element::Type data_et; + Shape axes_ps; + std::vector axes; + element::Type axes_et; + bool keep_dims; +}; + +template +static std::shared_ptr makeReduceOp(const ReduceParams& p, bool axes_as_param = false) +{ + auto in_data = make_shared(p.data_et, p.data_ps); + shared_ptr in_axes; + if (axes_as_param) + { + in_axes = make_shared(p.axes_et, p.axes_ps); + } + else + { + if (shape_size(p.axes_ps) != p.axes.size()) + { + throw ngraph_error("Axes shape does not match with axes elements"); + } + in_axes = make_shared(p.axes_et, p.axes_ps, p.axes); + } + return make_shared(in_data, in_axes, p.keep_dims); +} + +template +class ReduceTest : public testing::Test +{ +}; + +TYPED_TEST_CASE_P(ReduceTest); + +TYPED_TEST_P(ReduceTest, reduce_basic_shape_infer) +{ + PartialShape data_ps{3, 4, 5}; + element::Type data_et = element::dynamic; + + Shape axes_ps{2}; + element::Type axes_et = element::i64; + std::vector axes{1, 2}; + + bool keep_dims = false; + + PartialShape out_ps{3}; + + const ReduceParams params{data_ps, data_et, axes_ps, axes, axes_et, keep_dims}; + auto reduce_op = makeReduceOp(params); + ASSERT_TRUE(reduce_op->get_output_partial_shape(0).same_scheme(out_ps)); +} + +TYPED_TEST_P(ReduceTest, reduce_basic_shape_infer_keep_dims) +{ + PartialShape data_ps{3, 4, 5}; + element::Type data_et = element::dynamic; + + Shape axes_ps{2}; + element::Type axes_et = element::i64; + std::vector axes{1, 2}; + + bool keep_dims = true; + + PartialShape out_ps{3, 1, 1}; + + const ReduceParams params{data_ps, data_et, axes_ps, axes, axes_et, keep_dims}; + auto reduce_op = makeReduceOp(params); + ASSERT_TRUE(reduce_op->get_output_partial_shape(0).same_scheme(out_ps)); +} + +TYPED_TEST_P(ReduceTest, reduce_basic_shape_infer_scalar_axis) +{ + PartialShape data_ps{3, 4, 5}; + element::Type data_et = element::dynamic; + + Shape axes_ps{}; + element::Type axes_et = element::i64; + std::vector axes{1}; + + bool keep_dims = false; + + PartialShape out_ps{3, 5}; + + const ReduceParams params{data_ps, data_et, axes_ps, axes, axes_et, keep_dims}; + auto reduce_op = makeReduceOp(params); + ASSERT_TRUE(reduce_op->get_output_partial_shape(0).same_scheme(out_ps)); +} + +TYPED_TEST_P(ReduceTest, reduce_basic_shape_infer_axes_as_param) +{ + PartialShape data_ps{3, 4, 5}; + element::Type data_et = element::dynamic; + + Shape axes_ps{2}; + element::Type axes_et = element::i32; + std::vector axes; + + bool keep_dims = false; + + PartialShape out_ps{PartialShape::dynamic()}; + + const ReduceParams params{data_ps, data_et, axes_ps, axes, axes_et, keep_dims}; + bool axes_as_param = true; + auto reduce_op = makeReduceOp(params, axes_as_param); + ASSERT_TRUE(reduce_op->get_output_partial_shape(0).same_scheme(out_ps)); +} + +TYPED_TEST_P(ReduceTest, reduce_dynamic_shape_reduced_axes_static) +{ + PartialShape data_ps{3, 4, 5, Dimension::dynamic()}; + element::Type data_et = element::dynamic; + + Shape axes_ps{2}; + element::Type axes_et = element::i64; + std::vector axes{1, 2}; + + bool keep_dims = false; + + PartialShape out_ps{3, Dimension::dynamic()}; + + const ReduceParams params{data_ps, data_et, axes_ps, axes, axes_et, keep_dims}; + auto reduce_op = makeReduceOp(params); + ASSERT_TRUE(reduce_op->get_output_partial_shape(0).same_scheme(out_ps)); +} + +TYPED_TEST_P(ReduceTest, reduce_dynamic_shape_reduced_axes_static_keep_dims) +{ + PartialShape data_ps{3, 4, 5, Dimension::dynamic()}; + element::Type data_et = element::dynamic; + + Shape axes_ps{2}; + element::Type axes_et = element::i64; + std::vector axes{1, 2}; + + bool keep_dims = true; + + PartialShape out_ps{3, 1, 1, Dimension::dynamic()}; + + const ReduceParams params{data_ps, data_et, axes_ps, axes, axes_et, keep_dims}; + auto reduce_op = makeReduceOp(params); + ASSERT_TRUE(reduce_op->get_output_partial_shape(0).same_scheme(out_ps)); +} + +TYPED_TEST_P(ReduceTest, reduce_dynamic_shape_reduced_axes_not_static) +{ + PartialShape data_ps{Dimension::dynamic(), 4, 5, Dimension::dynamic()}; + element::Type data_et = element::dynamic; + + Shape axes_ps{2}; + element::Type axes_et = element::i64; + std::vector axes{2, 3}; + + bool keep_dims = false; + + PartialShape out_ps{Dimension::dynamic(), 4}; + + const ReduceParams params{data_ps, data_et, axes_ps, axes, axes_et, keep_dims}; + auto reduce_op = makeReduceOp(params); + ASSERT_TRUE(reduce_op->get_output_partial_shape(0).same_scheme(out_ps)); +} + +TYPED_TEST_P(ReduceTest, reduce_dynamic_shape_reduced_axes_not_static_keep_dims) +{ + PartialShape data_ps{Dimension::dynamic(), 4, 5, Dimension::dynamic()}; + element::Type data_et = element::dynamic; + + Shape axes_ps{2}; + element::Type axes_et = element::i64; + std::vector axes{2, 3}; + + bool keep_dims = true; + + PartialShape out_ps{Dimension::dynamic(), 4, 1, 1}; + + const ReduceParams params{data_ps, data_et, axes_ps, axes, axes_et, keep_dims}; + auto reduce_op = makeReduceOp(params); + ASSERT_TRUE(reduce_op->get_output_partial_shape(0).same_scheme(out_ps)); +} + +TYPED_TEST_P(ReduceTest, reduce_dynamic_shape_data) +{ + PartialShape data_ps{PartialShape::dynamic()}; + element::Type data_et = element::dynamic; + + Shape axes_ps{2}; + element::Type axes_et = element::i64; + std::vector axes{1, 2}; + + bool keep_dims = false; + + PartialShape out_ps{PartialShape::dynamic()}; + + const ReduceParams params{data_ps, data_et, axes_ps, axes, axes_et, keep_dims}; + auto reduce_op = makeReduceOp(params); + ASSERT_TRUE(reduce_op->get_output_partial_shape(0).same_scheme(out_ps)); +} + +TYPED_TEST_P(ReduceTest, reduce_invalid_axis_out_of_range) +{ + PartialShape data_ps{1, 2, 3}; + element::Type data_et = element::dynamic; + + Shape axes_ps{2}; + element::Type axes_et = element::i64; + std::vector axes{2, 3}; + + bool keep_dims = false; + + const ReduceParams params{data_ps, data_et, axes_ps, axes, axes_et, keep_dims}; + try + { + auto reduce_op = makeReduceOp(params); + FAIL() << "Invalid axes values not detected"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), "Reduction axis ("); + } + catch (...) + { + FAIL() << "Axes input values validation check failed for unexpected reason"; + } +} + +TYPED_TEST_P(ReduceTest, reduce_invalid_axes_shape) +{ + PartialShape data_ps{1, 2, 3}; + element::Type data_et = element::dynamic; + + Shape axes_ps{2, 1}; + element::Type axes_et = element::i64; + std::vector axes{0, 1}; + + bool keep_dims = true; + + const ReduceParams params{data_ps, data_et, axes_ps, axes, axes_et, keep_dims}; + try + { + auto reduce_op = makeReduceOp(params); + FAIL() << "Invalid shape of axes input not detected"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), "Axes input must be a scalar or 1D input."); + } + catch (...) + { + FAIL() << "Axes input shape validation check failed for unexpected reason"; + } +} + +TYPED_TEST_P(ReduceTest, reduce_invalid_axes_et) +{ + element::Type data_et = element::dynamic; + PartialShape data_ps{1, 2, 3}; + + element::Type axes_et = element::f32; + Shape axes_ps{2}; + std::vector axes{0, 1}; + + bool keep_dims = true; + + const ReduceParams params{data_ps, data_et, axes_ps, axes, axes_et, keep_dims}; + try + { + auto reduce_op = makeReduceOp(params); + FAIL() << "Invalid element type of axes input not detected"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), "Element type of axes input must be integer."); + } + catch (...) + { + FAIL() << "Axes input element type validation check failed for unexpected reason"; + } +} + +REGISTER_TYPED_TEST_CASE_P( + ReduceTest, + reduce_basic_shape_infer, + reduce_basic_shape_infer_keep_dims, + reduce_basic_shape_infer_scalar_axis, + reduce_basic_shape_infer_axes_as_param, + reduce_dynamic_shape_data, + reduce_dynamic_shape_reduced_axes_static, + reduce_dynamic_shape_reduced_axes_static_keep_dims, + reduce_dynamic_shape_reduced_axes_not_static, + reduce_dynamic_shape_reduced_axes_not_static_keep_dims, + reduce_invalid_axis_out_of_range, + reduce_invalid_axes_shape, + reduce_invalid_axes_et); + +template +class ReduceArithmeticTest : public testing::Test +{ +}; + +TYPED_TEST_CASE_P(ReduceArithmeticTest); + +TYPED_TEST_P(ReduceArithmeticTest, reduce_arithmetic_invalid_data_et) +{ + element::Type data_et = element::boolean; + PartialShape data_ps{1, 2, 3}; + + element::Type axes_et = element::i32; + Shape axes_ps{2}; + std::vector axes{0, 1}; + + bool keep_dims = true; + + const ReduceParams params{data_ps, data_et, axes_ps, axes, axes_et, keep_dims}; + try + { + auto reduce_op = makeReduceOp(params); + FAIL() << "Invalid element type of data input not detected"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), "Element type of data input must be numeric."); + } + catch (...) + { + FAIL() << "Data input element type validation check failed for unexpected reason"; + } +} + +REGISTER_TYPED_TEST_CASE_P( + ReduceArithmeticTest, + reduce_arithmetic_invalid_data_et); + +template +class ReduceLogicalTest : public testing::Test +{ +}; + +TYPED_TEST_CASE_P(ReduceLogicalTest); + +TYPED_TEST_P(ReduceLogicalTest, reduce_logical_invalid_data_et) +{ + std::vector element_types{ + element::f32, + element::i32, + element::u32}; + PartialShape data_ps{1, 2, 3}; + + element::Type axes_et = element::i32; + Shape axes_ps{2}; + std::vector axes{0, 1}; + + bool keep_dims = true; + + for (const auto& data_et : element_types) + { + const ReduceParams params{data_ps, data_et, axes_ps, axes, axes_et, keep_dims}; + try + { + auto reduce_op = makeReduceOp(params); + FAIL() << "Invalid element type of data input not detected"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), "Element type of data input must be boolean."); + } + catch (...) + { + FAIL() << "Data input element type validation check failed for unexpected reason"; + } + } +} + +REGISTER_TYPED_TEST_CASE_P( + ReduceLogicalTest, + reduce_logical_invalid_data_et); diff --git a/ngraph/test/type_prop/reduce_prod.cpp b/ngraph/test/type_prop/reduce_prod.cpp index 243f158d7e25a2..3a6ea0a9e89af2 100644 --- a/ngraph/test/type_prop/reduce_prod.cpp +++ b/ngraph/test/type_prop/reduce_prod.cpp @@ -2,48 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" -#include "util/type_prop.hpp" +#include "reduce_ops.hpp" -using namespace std; -using namespace ngraph; - -TEST(type_prop, reduce_prod_v1_axis_out_of_range) -{ - auto arg = make_shared(element::f32, Shape{1, 2, 3}); - auto axes = make_shared(element::i64, Shape{2}, vector{2, 3}); - try - { - auto reduce_prod = make_shared(arg, axes); - - // Should have thrown, so fail if it didn't - FAIL() << "Incorrect axes values exception not thrown"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), std::string("Reduction axis (")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, reduce_prod_v1_shape_if_keep_dims) -{ - auto arg = make_shared(element::f32, Shape{3, 4, 5}); - auto axes = make_shared(element::i64, Shape{2}, vector{1, 2}); - auto keep_dims = true; - auto reduce_prod = make_shared(arg, axes, keep_dims); - ASSERT_TRUE(reduce_prod->get_output_partial_shape(0).compatible(PartialShape{3, 1, 1})); -} - -TEST(type_prop, reduce_prod_v1_shape_if_not_keep_dims) -{ - auto arg = make_shared(element::f32, Shape{3, 4, 5}); - auto axes = make_shared(element::i64, Shape{2}, vector{1, 2}); - auto keep_dims = false; - auto reduce_prod = make_shared(arg, axes, keep_dims); - ASSERT_TRUE(reduce_prod->get_output_partial_shape(0).compatible(PartialShape{3})); -} +using Type = ::testing::Types; +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_reduce_prod, ReduceTest, Type); +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_reduce_prod_et, ReduceArithmeticTest, Type); diff --git a/ngraph/test/type_prop/reduce_sum.cpp b/ngraph/test/type_prop/reduce_sum.cpp index 0a1f0422a3ad64..7bfce1dfc708f0 100644 --- a/ngraph/test/type_prop/reduce_sum.cpp +++ b/ngraph/test/type_prop/reduce_sum.cpp @@ -2,48 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" -#include "util/type_prop.hpp" +#include "reduce_ops.hpp" -using namespace std; -using namespace ngraph; - -TEST(type_prop, reduce_sum_v1_axis_out_of_range) -{ - auto arg = make_shared(element::f32, Shape{1, 2, 3}); - auto axes = make_shared(element::i64, Shape{2}, vector{2, 3}); - try - { - auto reduce_sum = make_shared(arg, axes); - - // Should have thrown, so fail if it didn't - FAIL() << "Incorrect axes values exception not thrown"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), std::string("Reduction axis (")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, reduce_sum_v1_shape_if_keep_dims) -{ - auto arg = make_shared(element::f32, Shape{3, 4, 5}); - auto axes = make_shared(element::i64, Shape{2}, vector{1, 2}); - auto keep_dims = true; - auto reduce_prod = make_shared(arg, axes, keep_dims); - ASSERT_TRUE(reduce_prod->get_output_partial_shape(0).compatible(PartialShape{3, 1, 1})); -} - -TEST(type_prop, reduce_sum_v1_shape_if_not_keep_dims) -{ - auto arg = make_shared(element::f32, Shape{3, 4, 5}); - auto axes = make_shared(element::i64, Shape{2}, vector{1, 2}); - auto keep_dims = false; - auto reduce_prod = make_shared(arg, axes, keep_dims); - ASSERT_TRUE(reduce_prod->get_output_partial_shape(0).compatible(PartialShape{3})); -} +using Type = ::testing::Types; +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_reduce_sum, ReduceTest, Type); +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_reduce_sum_et, ReduceArithmeticTest, Type); diff --git a/ngraph/test/visitors/op/reduce_ops.hpp b/ngraph/test/visitors/op/reduce_ops.hpp index dfbf1b6eba8757..4c5a165b2bcac5 100644 --- a/ngraph/test/visitors/op/reduce_ops.hpp +++ b/ngraph/test/visitors/op/reduce_ops.hpp @@ -24,7 +24,7 @@ TYPED_TEST_CASE_P(ReduceOpsAttrTest); TYPED_TEST_P(ReduceOpsAttrTest, reduce_ops) { Shape in_shape{3, 4, 5}; - element::Type in_et = element::f32; + element::Type in_et = element::dynamic; Shape axes_shape{2}; element::Type axes_et = element::i64; From 8830dcabf3af456fa213594151abce6b118359b5 Mon Sep 17 00:00:00 2001 From: Alexander Zhogov Date: Fri, 11 Jun 2021 11:18:25 +0300 Subject: [PATCH 066/178] GitHub CI: Check committer email --- .github/org_control/check_pr.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/org_control/check_pr.py b/.github/org_control/check_pr.py index 7bb8f89dd602f4..0e23251e1571a4 100644 --- a/.github/org_control/check_pr.py +++ b/.github/org_control/check_pr.py @@ -147,21 +147,29 @@ def get_wrong_commits(pull): # import pprint; pprint.pprint(commit.raw_data) print("Commit SHA:", commit.sha) # Use raw data because commit author can be non GitHub user - commit_email = (commit.raw_data["commit"]["author"]["email"] or "").lower() - print(" Commit email:", commit_email) + commit_author_email = (commit.raw_data["commit"]["author"]["email"] or "").lower() + commit_committer_email = (commit.raw_data["commit"]["committer"]["email"] or "").lower() + print(" Commit author email:", commit_author_email) + print(" Commit committer email:", commit_committer_email) if not github_api.is_valid_user(commit.author): print( - " ERROR: User with the commit email is absent in GitHub:", + " ERROR: User with the commit author email is absent in GitHub:", commit.raw_data["commit"]["author"]["name"], ) wrong_commits.add(commit.sha) + if not github_api.is_valid_user(commit.committer): + print( + " ERROR: User with the commit committer email is absent in GitHub:", + commit.raw_data["commit"]["committer"]["name"], + ) + wrong_commits.add(commit.sha) if not commit.raw_data["commit"]["verification"]["verified"]: print( " WARNING: The commit is not verified. Reason:", commit.raw_data["commit"]["verification"]["reason"], ) - if pr_author_email != commit_email: - print(" WARNING: Commit email and GitHub PR author public email are differnt") + if pr_author_email != commit_author_email or pr_author_email != commit_committer_email: + print(" WARNING: Commit emails and GitHub PR author public email are differnt") return wrong_commits From 167a5519b170cfdb98f2d1e4ab7b897c4c72aeaf Mon Sep 17 00:00:00 2001 From: Tomasz Socha Date: Fri, 11 Jun 2021 11:27:58 +0200 Subject: [PATCH 067/178] =?UTF-8?q?[ONNX=20Importer]=20=F0=9F=95=B8?= =?UTF-8?q?=EF=B8=8F=20Make=20global=20pools=20more=20dynamic=20(#6122)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/op/global_average_pool.cpp | 34 +++++++++---------- .../onnx_import/src/op/global_max_pool.cpp | 34 +++++++++---------- 2 files changed, 32 insertions(+), 36 deletions(-) diff --git a/ngraph/frontend/onnx_import/src/op/global_average_pool.cpp b/ngraph/frontend/onnx_import/src/op/global_average_pool.cpp index 2d99e69da5dad5..d0a7ea4020f939 100644 --- a/ngraph/frontend/onnx_import/src/op/global_average_pool.cpp +++ b/ngraph/frontend/onnx_import/src/op/global_average_pool.cpp @@ -19,19 +19,6 @@ namespace ngraph { OutputVector global_average_pool(const Node& node) { - auto data = node.get_ng_inputs()[0]; - auto data_rank = data.get_partial_shape().rank(); - - NGRAPH_CHECK(data_rank.is_static(), - "The input data tensor's rank has to be known (static)"); - - auto data_rank_value = data_rank.get_length(); - - NGRAPH_CHECK(data_rank_value > 2, - "The input data tensor's rank has to be greater than 2." - "Provided data rank is: ", - data_rank_value); - // Generate axes for reduce operation which contain all spatial dims indexes. // Examples: // Input shape: [N, C, H, W] @@ -41,11 +28,22 @@ namespace ngraph // Input shape: [N, C, H, W, D] // Input spatial dimensions are H, W and D // Expected spatial dims indexes: [2, 3, 4] - size_t data_spatial_rank = data_rank_value - 2; - auto reduce_axes_vector = std::vector(data_spatial_rank); - std::iota(reduce_axes_vector.begin(), reduce_axes_vector.end(), 2); - auto reduce_axes = default_opset::Constant::create( - element::i64, Shape{data_spatial_rank}, reduce_axes_vector); + auto data = node.get_ng_inputs()[0]; + + const auto zero_node = + default_opset::Constant::create(element::i64, Shape{}, {0}); + const auto one_node = + default_opset::Constant::create(element::i64, Shape{}, {1}); + const auto two_node = + default_opset::Constant::create(element::i64, Shape{}, {2}); + + const auto data_shape = std::make_shared(data); + const auto data_rank = std::make_shared(data_shape); + const auto data_rank_as_scalar = + std::make_shared(data_rank); + + const auto reduce_axes = std::make_shared( + two_node, data_rank_as_scalar, one_node, element::i64); return {std::make_shared(data, reduce_axes, true)}; } diff --git a/ngraph/frontend/onnx_import/src/op/global_max_pool.cpp b/ngraph/frontend/onnx_import/src/op/global_max_pool.cpp index 866b7ac0201bd3..49fec836f21e53 100644 --- a/ngraph/frontend/onnx_import/src/op/global_max_pool.cpp +++ b/ngraph/frontend/onnx_import/src/op/global_max_pool.cpp @@ -19,19 +19,6 @@ namespace ngraph { OutputVector global_max_pool(const Node& node) { - auto data = node.get_ng_inputs()[0]; - auto data_rank = data.get_partial_shape().rank(); - - NGRAPH_CHECK(data_rank.is_static(), - "The input data tensor's rank has to be known (static)"); - - auto data_rank_value = data_rank.get_length(); - - NGRAPH_CHECK(data_rank_value > 2, - "The input data tensor's rank has to be greater than 2." - "Provided data rank is: ", - data_rank_value); - // Generate axes for reduce operation which contain all spatial dims indexes. // Examples: // Input shape: [N, C, H, W] @@ -41,11 +28,22 @@ namespace ngraph // Input shape: [N, C, H, W, D] // Input spatial dimensions are H, W and D // Expected spatial dims indexes: [2, 3, 4] - size_t data_spatial_rank = data_rank_value - 2; - auto reduce_axes_vector = std::vector(data_spatial_rank); - std::iota(reduce_axes_vector.begin(), reduce_axes_vector.end(), 2); - auto reduce_axes = default_opset::Constant::create( - element::i64, Shape{data_spatial_rank}, reduce_axes_vector); + auto data = node.get_ng_inputs()[0]; + + const auto zero_node = + default_opset::Constant::create(element::i64, Shape{}, {0}); + const auto one_node = + default_opset::Constant::create(element::i64, Shape{}, {1}); + const auto two_node = + default_opset::Constant::create(element::i64, Shape{}, {2}); + + const auto data_shape = std::make_shared(data); + const auto data_rank = std::make_shared(data_shape); + const auto data_rank_as_scalar = + std::make_shared(data_rank); + + const auto reduce_axes = std::make_shared( + two_node, data_rank_as_scalar, one_node, element::i64); return {std::make_shared(data, reduce_axes, true)}; } From 089f76cc7f599a719adef25bd6651fee25ea255a Mon Sep 17 00:00:00 2001 From: Victor Kuznetsov <32412802+just-sparta@users.noreply.github.com> Date: Fri, 11 Jun 2021 12:57:01 +0300 Subject: [PATCH 068/178] Add `branch` field to submit to DB in MemCheck/TimeTests (#6073) --- tests/stress_tests/scripts/memcheck_upload.py | 1 + tests/time_tests/test_runner/conftest.py | 3 ++- tests/time_tests/test_runner/utils.py | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/stress_tests/scripts/memcheck_upload.py b/tests/stress_tests/scripts/memcheck_upload.py index 663a513c8566bb..a3eeb3906b4968 100644 --- a/tests/stress_tests/scripts/memcheck_upload.py +++ b/tests/stress_tests/scripts/memcheck_upload.py @@ -67,6 +67,7 @@ def metadata_from_manifest(manifest): 'commit_sha': repo_trigger['revision'], 'commit_date': repo_trigger['commit_time'], 'repo_url': repo_trigger['url'], + 'branch': repo_trigger['branch'], 'target_branch': repo_trigger['target_branch'], 'event_type': manifest['components'][PRODUCT_NAME]['build_event'].lower(), f'{PRODUCT_NAME}_version': manifest['components'][PRODUCT_NAME]['version'], diff --git a/tests/time_tests/test_runner/conftest.py b/tests/time_tests/test_runner/conftest.py index d0cb928ce07411..f60be60d963238 100644 --- a/tests/time_tests/test_runner/conftest.py +++ b/tests/time_tests/test_runner/conftest.py @@ -325,10 +325,11 @@ def manifest_metadata(request): "repo_url": {"type": "string"}, "commit_sha": {"type": "string"}, "commit_date": {"type": "string"}, + "branch": {"type": "string"}, "target_branch": {"type": "string"}, "version": {"type": "string"} }, - "required": ["product_type", "repo_url", "commit_sha", "commit_date", "target_branch", "version"], + "required": ["product_type", "repo_url", "commit_sha", "commit_date", "branch", "target_branch", "version"], "additionalProperties": false } """ diff --git a/tests/time_tests/test_runner/utils.py b/tests/time_tests/test_runner/utils.py index 990af4c9b6b70e..c68cc4fd7c2295 100644 --- a/tests/time_tests/test_runner/utils.py +++ b/tests/time_tests/test_runner/utils.py @@ -57,7 +57,8 @@ def metadata_from_manifest(manifest: Path): 'commit_sha': repo_trigger['revision'], 'commit_date': repo_trigger['commit_time'], 'repo_url': repo_trigger['url'], - 'target_branch': repo_trigger['branch'], + 'branch': repo_trigger['branch'], + 'target_branch': repo_trigger['target_branch'], 'version': manifest['components'][PRODUCT_NAME]['version'] } From 458435ad753123ccaf33563aae977c3b29378814 Mon Sep 17 00:00:00 2001 From: Bartek Szmelczynski Date: Fri, 11 Jun 2021 17:01:52 +0200 Subject: [PATCH 069/178] Revise selu (#5513) * remove FusedOp from selu operator * add type_prop tests for selu op * add vistors test for selu op * update CMakeLists and fix wrong path to visitors test for selu * fix style * add backend tests for selu op * refactor validate_and_infer_types function for selu op * refactor type_prop tests for selu to catch particular errors Co-authored-by: jdanieck --- ngraph/core/include/ngraph/op/selu.hpp | 19 +-- ngraph/core/src/op/selu.cpp | 68 ++++------ ngraph/test/CMakeLists.txt | 3 + ngraph/test/backend/selu.in.cpp | 99 ++++++++++++++ ngraph/test/type_prop/selu.cpp | 171 +++++++++++++++++++++++++ ngraph/test/visitors/op/selu.cpp | 30 +++++ 6 files changed, 338 insertions(+), 52 deletions(-) create mode 100644 ngraph/test/backend/selu.in.cpp create mode 100644 ngraph/test/type_prop/selu.cpp create mode 100644 ngraph/test/visitors/op/selu.cpp diff --git a/ngraph/core/include/ngraph/op/selu.hpp b/ngraph/core/include/ngraph/op/selu.hpp index 9d71f71936b1fb..9bc1c71acd6937 100644 --- a/ngraph/core/include/ngraph/op/selu.hpp +++ b/ngraph/core/include/ngraph/op/selu.hpp @@ -6,10 +6,6 @@ #include "ngraph/node.hpp" #include "ngraph/op/op.hpp" -#include "ngraph/op/util/fused_op.hpp" - -NGRAPH_SUPPRESS_DEPRECATED_START - namespace ngraph { namespace op @@ -17,12 +13,12 @@ namespace ngraph namespace v0 { /// \brief Performs a SELU activation function on all elements of the input node - class NGRAPH_API Selu : public ngraph::op::util::FusedOp + class NGRAPH_API Selu : public ngraph::op::Op { public: - static constexpr NodeTypeInfo type_info{"Selu", 0}; - const NodeTypeInfo& get_type_info() const override { return type_info; } - Selu(); + NGRAPH_RTTI_DECLARATION; + + Selu() = default; /// \brief Constructs a Selu node. /// /// \param data - Node producing the input tensor @@ -31,9 +27,10 @@ namespace ngraph Selu(const Output& data, const Output& alpha, const Output& lambda); - virtual void pre_validate_and_infer_types() override; + + void validate_and_infer_types() override; + bool visit_attributes(AttributeVisitor& visitor) override; - virtual OutputVector decompose_op() const override; virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; @@ -42,5 +39,3 @@ namespace ngraph using v0::Selu; } // namespace op } // namespace ngraph - -NGRAPH_SUPPRESS_DEPRECATED_END diff --git a/ngraph/core/src/op/selu.cpp b/ngraph/core/src/op/selu.cpp index 680b67fc012462..fd9aae0182a06e 100644 --- a/ngraph/core/src/op/selu.cpp +++ b/ngraph/core/src/op/selu.cpp @@ -5,65 +5,53 @@ #include "ngraph/op/selu.hpp" #include "itt.hpp" -#include "ngraph/op/add.hpp" -#include "ngraph/op/constant.hpp" -#include "ngraph/op/exp.hpp" -#include "ngraph/op/maximum.hpp" -#include "ngraph/op/minimum.hpp" -#include "ngraph/op/multiply.hpp" -#include "ngraph/op/subtract.hpp" - using namespace std; using namespace ngraph; -NGRAPH_SUPPRESS_DEPRECATED_START - -constexpr NodeTypeInfo op::v0::Selu::type_info; - -op::v0::Selu::Selu() - : FusedOp() -{ -} +NGRAPH_RTTI_DEFINITION(op::v0::Selu, "Selu", 0); op::v0::Selu::Selu(const Output& data, const Output& alpha, const Output& lambda) - : FusedOp({data, alpha, lambda}) + : Op({data, alpha, lambda}) { constructor_validate_and_infer_types(); } -void ngraph::op::v0::Selu::pre_validate_and_infer_types() +void op::v0::Selu::validate_and_infer_types() { - set_output_type(0, get_input_element_type(0), get_input_partial_shape(0)); + NGRAPH_OP_SCOPE(v0_Selu_validate_and_infer_types); + auto data_et = get_input_element_type(0); + auto alpha_et = get_input_element_type(1); + auto lambda_et = get_input_element_type(2); + auto result_et = element::dynamic; + + NODE_VALIDATION_CHECK(this, + element::Type::merge(result_et, result_et, data_et) && + element::Type::merge(result_et, result_et, alpha_et) && + element::Type::merge(result_et, result_et, lambda_et), + "Input element types do not match : ", + data_et, + " and ", + alpha_et, + " and ", + lambda_et); + + NODE_VALIDATION_CHECK(this, + result_et.is_dynamic() || result_et.is_real(), + "Input element types must be floating-point. Got: ", + result_et); + + set_output_type(0, result_et, get_input_partial_shape(0)); } -bool ngraph::op::v0::Selu::visit_attributes(AttributeVisitor& visitor) +bool op::v0::Selu::visit_attributes(AttributeVisitor& visitor) { NGRAPH_OP_SCOPE(v0_Selu_visit_attributes); return true; } -OutputVector op::v0::Selu::decompose_op() const -{ - const auto data = input_value(0); - const auto alpha = input_value(1); - const auto lambda = input_value(2); - const auto zero_node = op::Constant::create(data.get_element_type(), Shape{1}, {0}); - - // lambda * ((max(data, 0) + (alpha * exp(min(data, 0)) - alpha)) - return {std::make_shared( - lambda, - std::make_shared( - std::make_shared(data, zero_node), - std::make_shared( - std::make_shared( - alpha, - std::make_shared(std::make_shared(data, zero_node))), - alpha)))}; -} - shared_ptr op::v0::Selu::clone_with_new_inputs(const OutputVector& new_args) const { NGRAPH_OP_SCOPE(v0_Selu_clone_with_new_inputs); check_new_args_count(this, new_args); - return make_shared(new_args.at(0), new_args.at(1), new_args.at(2)); + return make_shared(new_args.at(0), new_args.at(1), new_args.at(2)); } diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index a2a619007b619f..d04486563866ef 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -196,6 +196,7 @@ set(SRC type_prop/scatter_nd_update.cpp type_prop/scatter_update.cpp type_prop/select.cpp + type_prop/selu.cpp type_prop/shape_of.cpp type_prop/shuffle_channels.cpp type_prop/softmax.cpp @@ -270,6 +271,7 @@ set(SRC visitors/op/reverse_sequence.cpp visitors/op/rnn_cell.cpp visitors/op/roi_pooling.cpp + visitors/op/selu.cpp visitors/op/shuffle_channels.cpp visitors/op/softmax.cpp visitors/op/space_to_depth.cpp @@ -435,6 +437,7 @@ set(MULTI_TEST_SRC backend/round.in.cpp backend/scatter_nd_update.in.cpp backend/select.in.cpp + backend/selu.in.cpp backend/shape_of.in.cpp backend/sigmoid.in.cpp backend/sign.in.cpp diff --git a/ngraph/test/backend/selu.in.cpp b/ngraph/test/backend/selu.in.cpp new file mode 100644 index 00000000000000..2524ee045fda41 --- /dev/null +++ b/ngraph/test/backend/selu.in.cpp @@ -0,0 +1,99 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "util/engine/test_engines.hpp" +#include "util/test_case.hpp" +#include "util/test_control.hpp" + +using namespace std; +using namespace ngraph; + +static string s_manifest = "${MANIFEST}"; +using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); + +NGRAPH_TEST(${BACKEND_NAME}, selu_2Dfprop) +{ + Shape rt_shape{2}; + Shape c_shape{1}; + element::Type et = element::f32; + + auto input = make_shared(et, rt_shape); + auto alpha = op::Constant::create(et, c_shape, {1.67326324}); + auto lambda = op::Constant::create(et, c_shape, {1.05070098}); + auto selu = make_shared(input, alpha, lambda); + auto f = make_shared(selu, ParameterVector{input}); + + vector input_data{-1, 3}; + vector expected_out{-1.1113307, 3.152103}; + + auto test_case = test::TestCase(f); + test_case.add_input(rt_shape, input_data); + test_case.add_expected_output(rt_shape, expected_out); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, selu_4Dfprop) +{ + Shape in_shape{4}; + Shape c_shape{1}; + element::Type et = element::f32; + + auto input = make_shared(et, in_shape); + auto alpha = op::Constant::create(et, c_shape, {1.67326324}); + auto lambda = op::Constant::create(et, c_shape, {1.05070098}); + auto selu = make_shared(input, alpha, lambda); + auto f = make_shared(selu, ParameterVector{input}); + + vector in_vec{-1.0, 0.0, 1.0, 2.0}; + vector out_vec{-1.1113307, 0., 1.050701, 2.101402}; + + auto test_case = test::TestCase(f); + test_case.add_input(in_shape, in_vec); + test_case.add_expected_output(in_shape, out_vec); + test_case.run_with_tolerance_as_fp(1e-4f); +} + +NGRAPH_TEST(${BACKEND_NAME}, selu_1Dfprop) +{ + Shape in_shape{1}; + Shape c_shape{1}; + element::Type et = element::f32; + + auto input = make_shared(et, in_shape); + auto alpha = op::Constant::create(et, c_shape, {1.67326324}); + auto lambda = op::Constant::create(et, c_shape, {1.05070098}); + auto selu = make_shared(input, alpha, lambda); + auto f = make_shared(selu, ParameterVector{input}); + + vector in_vec{112.0}; + vector out_vec{117.67851}; + + auto test_case = test::TestCase(f); + test_case.add_input(in_shape, in_vec); + test_case.add_expected_output(in_shape, out_vec); + test_case.run_with_tolerance_as_fp(1e-4f); +} + +NGRAPH_TEST(${BACKEND_NAME}, selu_3Dfprop_negative) +{ + Shape in_shape{3}; + Shape c_shape{1}; + element::Type et = element::f32; + + auto input = make_shared(et, in_shape); + auto alpha = op::Constant::create(et, c_shape, {1.67326324}); + auto lambda = op::Constant::create(et, c_shape, {1.05070098}); + auto selu = make_shared(input, alpha, lambda); + auto f = make_shared(selu, ParameterVector{input}); + + vector in_vec{-3.0, -12.5, -7.0}; + vector out_vec{-1.6705687, -1.7580928, -1.7564961}; + + auto test_case = test::TestCase(f); + test_case.add_input(in_shape, in_vec); + test_case.add_expected_output(in_shape, out_vec); + test_case.run_with_tolerance_as_fp(1e-4f); +} diff --git a/ngraph/test/type_prop/selu.cpp b/ngraph/test/type_prop/selu.cpp new file mode 100644 index 00000000000000..66f89a84f11b15 --- /dev/null +++ b/ngraph/test/type_prop/selu.cpp @@ -0,0 +1,171 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "util/type_prop.hpp" + +using namespace std; +using namespace ngraph; + +TEST(type_prop, selu_basic_inference_f32_3D) +{ + const auto param = make_shared(element::f32, Shape{1, 32, 32}); + const auto alpha = make_shared(element::f32, Shape{1}); + const auto lambda = make_shared(element::f32, Shape{1}); + const auto selu = make_shared(param, alpha, lambda); + + ASSERT_EQ(selu->get_element_type(), element::f32); + ASSERT_EQ(selu->get_shape(), (Shape{1, 32, 32})); +} + +TEST(type_prop, selu_basic_inference_f16_3D) +{ + const auto param = make_shared(element::f16, Shape{1, 32, 32}); + const auto alpha = make_shared(element::f16, Shape{1}); + const auto lambda = make_shared(element::f16, Shape{1}); + const auto selu = make_shared(param, alpha, lambda); + + ASSERT_EQ(selu->get_element_type(), element::f16); + ASSERT_EQ(selu->get_shape(), (Shape{1, 32, 32})); +} + +TEST(type_prop, selu_basic_inference_f32_5D) +{ + const auto param = make_shared(element::f32, Shape{12, 135, 221, 31, 15}); + const auto alpha = make_shared(element::f32, Shape{1}); + const auto lambda = make_shared(element::f32, Shape{1}); + const auto selu = make_shared(param, alpha, lambda); + + ASSERT_EQ(selu->get_element_type(), element::f32); + ASSERT_EQ(selu->get_shape(), (Shape{12, 135, 221, 31, 15})); +} + +TEST(type_prop, selu_basic_inference_f16_5D) +{ + const auto param = make_shared(element::f16, Shape{12, 135, 221, 31, 15}); + const auto alpha = make_shared(element::f16, Shape{1}); + const auto lambda = make_shared(element::f16, Shape{1}); + const auto selu = make_shared(param, alpha, lambda); + + ASSERT_EQ(selu->get_element_type(), element::f16); + ASSERT_EQ(selu->get_shape(), (Shape{12, 135, 221, 31, 15})); +} + +TEST(type_prop, selu_incompatible_input_type_boolean) +{ + // Invalid data input element type + try + { + auto data = make_shared(element::boolean, Shape{1, 2, 3, 4}); + const auto alpha = make_shared(element::boolean, Shape{1}); + const auto lambda = make_shared(element::boolean, Shape{1}); + auto selu = make_shared(data, alpha, lambda); + // Data input expected to be of numeric type + FAIL() << "Invalid input type not detected"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), std::string("Input element types must be floating-point")); + } + catch (...) + { + FAIL() << "Input type check failed for unexpected reason"; + } +} + +TEST(type_prop, selu_incompatible_input_type_i32) +{ + // Invalid data input element type + try + { + auto data = make_shared(element::i32, Shape{1, 2, 3, 4}); + const auto alpha = make_shared(element::i32, Shape{1}); + const auto lambda = make_shared(element::i32, Shape{1}); + auto selu = make_shared(data, alpha, lambda); + // Data input expected to be of numeric type + FAIL() << "Invalid input type not detected"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), std::string("Input element types must be floating-point")); + } + catch (...) + { + FAIL() << "Input type check failed for unexpected reason"; + } +} + +TEST(type_prop, selu_incompatible_input_type_u16) +{ + // Invalid data input element type + try + { + auto data = make_shared(element::u16, Shape{1, 2, 3, 4}); + const auto alpha = make_shared(element::u16, Shape{1}); + const auto lambda = make_shared(element::u16, Shape{1}); + auto selu = make_shared(data, alpha, lambda); + // Data input expected to be of numeric type + FAIL() << "Invalid input type not detected"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), std::string("Input element types must be floating-point")); + } + catch (...) + { + FAIL() << "Input type check failed for unexpected reason"; + } +} + +TEST(type_prop, selu_incompatible_input_types) +{ + // Invalid data input element type + try + { + auto data = make_shared(element::f32, Shape{1, 2, 3, 4}); + const auto alpha = make_shared(element::f32, Shape{1}); + const auto lambda = make_shared(element::u16, Shape{1}); + auto selu = make_shared(data, alpha, lambda); + // Data input expected to be of numeric type + FAIL() << "Inavlid input types not detected"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), std::string("Input element types do not match")); + } + catch (...) + { + FAIL() << "Input type check failed for unexpected reason"; + } +} + +TEST(type_prop, selu_dynamic_rank_input_shape_2D) +{ + const PartialShape param_shape{Dimension::dynamic(), 10}; + const auto param = std::make_shared(element::f32, param_shape); + const auto alpha = make_shared(element::f32, Shape{2, 1}); + const auto lambda = make_shared(element::f32, Shape{1}); + const auto op = std::make_shared(param, alpha, lambda); + ASSERT_TRUE(op->get_output_partial_shape(0).same_scheme(PartialShape{Dimension(), 10})); +} + +TEST(type_prop, selu_dynamic_rank_input_shape_3D) +{ + const PartialShape param_shape{100, Dimension::dynamic(), 58}; + const auto param = std::make_shared(element::f32, param_shape); + const auto alpha = make_shared(element::f32, Shape{1}); + const auto lambda = make_shared(element::f32, Shape{1}); + const auto op = std::make_shared(param, alpha, lambda); + ASSERT_TRUE(op->get_output_partial_shape(0).same_scheme(PartialShape{100, Dimension(), 58})); +} + +TEST(type_prop, selu_dynamic_rank_input_shape_full) +{ + const auto param = std::make_shared(element::f32, PartialShape::dynamic()); + const auto alpha = make_shared(element::f32, Shape{1}); + const auto lambda = make_shared(element::f32, Shape{1}); + const auto op = std::make_shared(param, alpha, lambda); + ASSERT_TRUE(op->get_output_partial_shape(0).same_scheme(PartialShape::dynamic())); +} diff --git a/ngraph/test/visitors/op/selu.cpp b/ngraph/test/visitors/op/selu.cpp new file mode 100644 index 00000000000000..3a83deaea53086 --- /dev/null +++ b/ngraph/test/visitors/op/selu.cpp @@ -0,0 +1,30 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" + +#include "ngraph/ngraph.hpp" +#include "ngraph/op/util/attr_types.hpp" +#include "ngraph/opsets/opset1.hpp" + +#include "util/visitor.hpp" + +using namespace std; +using namespace ngraph; +using ngraph::test::NodeBuilder; + +TEST(attributes, selu_op) +{ + NodeBuilder::get_ops().register_factory(); + const auto data_input = make_shared(element::f32, Shape{1, 2, 3}); + const auto alpha = make_shared(element::f32, Shape{1}); + const auto lambda = make_shared(element::f32, Shape{1}); + + const auto op = make_shared(data_input, alpha, lambda); + + NodeBuilder builder(op); + const auto expected_attr_count = 0; + + EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); +} From dc415573d4b99e8510f38ba987ebbff19bd8b34e Mon Sep 17 00:00:00 2001 From: Gabriele Galiero Casay Date: Mon, 14 Jun 2021 11:29:33 +0200 Subject: [PATCH 070/178] Revise reference implementation for ReduceProd operation (#5774) --- .../ngraph}/op/util/evaluate_helpers.hpp | 9 +- .../ngraph/runtime/reference/product.hpp | 31 ++- .../include/ngraph/runtime/reference/sum.hpp | 8 +- ngraph/core/src/op/reduce_prod.cpp | 10 +- ngraph/core/src/op/reduce_sum.cpp | 4 +- ngraph/core/src/op/util/evaluate_helpers.cpp | 17 ++ ngraph/test/CMakeLists.txt | 1 + ngraph/test/backend/reduce_prod.in.cpp | 228 ---------------- ngraph/test/op_eval/reduce_prod.cpp | 244 ++++++++++++++++++ ngraph/test/runtime/ie/unit_test.manifest | 25 +- 10 files changed, 295 insertions(+), 282 deletions(-) rename ngraph/core/{src => include/ngraph}/op/util/evaluate_helpers.hpp (79%) create mode 100644 ngraph/core/src/op/util/evaluate_helpers.cpp create mode 100644 ngraph/test/op_eval/reduce_prod.cpp diff --git a/ngraph/core/src/op/util/evaluate_helpers.hpp b/ngraph/core/include/ngraph/op/util/evaluate_helpers.hpp similarity index 79% rename from ngraph/core/src/op/util/evaluate_helpers.hpp rename to ngraph/core/include/ngraph/op/util/evaluate_helpers.hpp index d67a212f1574b6..abcd8729a98d86 100644 --- a/ngraph/core/src/op/util/evaluate_helpers.hpp +++ b/ngraph/core/include/ngraph/op/util/evaluate_helpers.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + #include "ngraph/axis_set.hpp" #include "ngraph/descriptor/tensor.hpp" #include "ngraph/util.hpp" @@ -18,10 +20,5 @@ namespace ngraph /// \return Normalized (positive only) axes as an AxisSet object. AxisSet get_normalized_axes_from_tensor(const HostTensorPtr tensor, const ngraph::Rank& rank, - const std::string& node_description) - { - const auto axes_vector = host_tensor_2_vector(tensor); - const auto normalized_axes = ngraph::normalize_axes(node_description, axes_vector, rank); - return AxisSet{normalized_axes}; - } + const std::string& node_description); } // namespace ngraph diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/product.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/product.hpp index 14615dc8b7cf9d..addd17eb82a647 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/product.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/product.hpp @@ -5,6 +5,7 @@ #pragma once #include +#include #include "ngraph/coordinate_transform.hpp" #include "ngraph/shape_util.hpp" @@ -16,29 +17,27 @@ namespace ngraph namespace reference { template - void product(const T* arg, - T* out, - const Shape& in_shape, - const AxisSet& reduction_axes, - bool keep_dims) + void product(const T* arg, T* out, const Shape& in_shape, const AxisSet& reduction_axes) { - auto out_shape = reduce(in_shape, reduction_axes, keep_dims); - CoordinateTransform output_transform(out_shape); + constexpr bool dont_keep_dims_in_output = false; + const auto out_shape = reduce(in_shape, reduction_axes, dont_keep_dims_in_output); + std::fill(out, out + shape_size(out_shape), 1); - for (const Coordinate& output_coord : output_transform) - { - out[output_transform.index(output_coord)] = 1; - } - - CoordinateTransform input_transform(in_shape); + const auto in_strides = row_major_strides(in_shape); + const auto out_strides = row_major_strides(out_shape); + CoordinateTransformBasic input_transform(in_shape); for (const Coordinate& input_coord : input_transform) { - Coordinate output_coord = reduce(input_coord, reduction_axes, keep_dims); + const Coordinate output_coord = + reduce(input_coord, reduction_axes, dont_keep_dims_in_output); - size_t output_index = output_transform.index(output_coord); + const size_t in_idx = std::inner_product( + input_coord.begin(), input_coord.end(), in_strides.begin(), 0); + const size_t out_idx = std::inner_product( + output_coord.begin(), output_coord.end(), out_strides.begin(), 0); - out[output_index] = out[output_index] * arg[input_transform.index(input_coord)]; + out[out_idx] = out[out_idx] * arg[in_idx]; } } } // namespace reference diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/sum.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/sum.hpp index 2408e6f476d728..d73ec441f7b3a5 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/sum.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/sum.hpp @@ -45,7 +45,7 @@ namespace ngraph void sum(const T* arg, T* out, const Shape& in_shape, const AxisSet& reduction_axes) { constexpr bool dont_keep_dims_in_output = false; - auto out_shape = reduce(in_shape, reduction_axes, dont_keep_dims_in_output); + const auto out_shape = reduce(in_shape, reduction_axes, dont_keep_dims_in_output); std::vector cs(shape_size(out_shape), 0); std::fill(out, out + shape_size(out_shape), 0); @@ -56,12 +56,12 @@ namespace ngraph CoordinateTransformBasic input_transform(in_shape); for (const Coordinate& input_coord : input_transform) { - Coordinate output_coord = + const Coordinate output_coord = reduce(input_coord, reduction_axes, dont_keep_dims_in_output); - size_t in_idx = std::inner_product( + const size_t in_idx = std::inner_product( input_coord.begin(), input_coord.end(), in_strides.begin(), 0); - size_t out_idx = std::inner_product( + const size_t out_idx = std::inner_product( output_coord.begin(), output_coord.end(), out_strides.begin(), 0); T x = arg[in_idx]; diff --git a/ngraph/core/src/op/reduce_prod.cpp b/ngraph/core/src/op/reduce_prod.cpp index bbacf23cc7e4d4..c7a78beb51f30b 100644 --- a/ngraph/core/src/op/reduce_prod.cpp +++ b/ngraph/core/src/op/reduce_prod.cpp @@ -6,6 +6,7 @@ #include #include "itt.hpp" #include "ngraph/graph_util.hpp" +#include "ngraph/op/util/evaluate_helpers.hpp" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/runtime/reference/product.hpp" #include "ngraph/shape_util.hpp" @@ -45,7 +46,7 @@ namespace reduce_prod { out->set_shape(reduce(arg->get_shape(), axes, keep_dims)); runtime::reference::product( - arg->get_data_ptr(), out->get_data_ptr(), arg->get_shape(), axes, keep_dims); + arg->get_data_ptr(), out->get_data_ptr(), arg->get_shape(), axes); return true; } @@ -75,8 +76,11 @@ bool op::v1::ReduceProd::evaluate(const HostTensorVector& outputs, NGRAPH_OP_SCOPE(v1_ReduceProd_evaluate); NGRAPH_CHECK(validate_host_tensor_vector(inputs, 2)); NGRAPH_CHECK(validate_host_tensor_vector(outputs, 1)); - return reduce_prod::evaluate_product( - inputs[0], outputs[0], get_reduction_axes(), get_keep_dims()); + + const auto reduction_axes = get_normalized_axes_from_tensor( + inputs[1], inputs[0]->get_partial_shape().rank(), get_friendly_name()); + + return reduce_prod::evaluate_product(inputs[0], outputs[0], reduction_axes, get_keep_dims()); } bool op::v1::ReduceProd::has_evaluate() const diff --git a/ngraph/core/src/op/reduce_sum.cpp b/ngraph/core/src/op/reduce_sum.cpp index 34262ec9efb32d..50b87763e84c4d 100644 --- a/ngraph/core/src/op/reduce_sum.cpp +++ b/ngraph/core/src/op/reduce_sum.cpp @@ -7,11 +7,11 @@ #include "itt.hpp" #include "ngraph/graph_util.hpp" #include "ngraph/op/broadcast.hpp" +#include "ngraph/op/util/evaluate_helpers.hpp" #include "ngraph/op/util/op_types.hpp" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/runtime/reference/sum.hpp" #include "ngraph/shape_util.hpp" -#include "util/evaluate_helpers.hpp" using namespace std; using namespace ngraph; @@ -80,7 +80,7 @@ bool op::v1::ReduceSum::evaluate(const HostTensorVector& outputs, NGRAPH_CHECK(validate_host_tensor_vector(outputs, 1)); const auto reduction_axes = get_normalized_axes_from_tensor( - inputs[1], get_input_partial_shape(0).rank(), get_friendly_name()); + inputs[1], inputs[0]->get_partial_shape().rank(), get_friendly_name()); return reduce_sum::evaluate_sum(inputs[0], outputs[0], reduction_axes, get_keep_dims()); } diff --git a/ngraph/core/src/op/util/evaluate_helpers.cpp b/ngraph/core/src/op/util/evaluate_helpers.cpp new file mode 100644 index 00000000000000..ac55bb5fe21b3f --- /dev/null +++ b/ngraph/core/src/op/util/evaluate_helpers.cpp @@ -0,0 +1,17 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "ngraph/op/util/evaluate_helpers.hpp" + +namespace ngraph +{ + AxisSet get_normalized_axes_from_tensor(const HostTensorPtr tensor, + const ngraph::Rank& rank, + const std::string& node_description) + { + const auto axes_vector = host_tensor_2_vector(tensor); + const auto normalized_axes = ngraph::normalize_axes(node_description, axes_vector, rank); + return AxisSet{normalized_axes}; + } +} // namespace ngraph diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index d04486563866ef..97065dc966eb6a 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -73,6 +73,7 @@ set(SRC op_eval/non_zero.cpp op_eval/reduce_l1.cpp op_eval/reduce_l2.cpp + op_eval/reduce_prod.cpp op_eval/reduce_sum.cpp op_eval/roi_align.cpp op_eval/roi_pooling.cpp diff --git a/ngraph/test/backend/reduce_prod.in.cpp b/ngraph/test/backend/reduce_prod.in.cpp index 6f63089acaa6a9..dbd7d3c743bb78 100644 --- a/ngraph/test/backend/reduce_prod.in.cpp +++ b/ngraph/test/backend/reduce_prod.in.cpp @@ -80,95 +80,6 @@ NGRAPH_TEST(${BACKEND_NAME}, reduce_product_matrix_rows) EXPECT_TRUE(test::all_close_f((vector{2, 12, 30}), read_vector(result))); } -NGRAPH_TEST(${BACKEND_NAME}, reduce_product_matrix_rows_zero) -{ - Shape shape_a{3, 0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{3}; - auto axes = make_shared(element::i32, Shape{}, 1); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3, 3, 3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{1, 1, 1}), read_vector(result))); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_product_matrix_cols_zero) -{ - // Now the reduction (g(x:float32[2,2],y:float32[]) = reduce(x,y,f,axes={})). - Shape shape_a{0, 2}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{2}; - auto axes = make_shared(element::i32, Shape{}, 0); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3, 3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{1, 1}), read_vector(result))); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_product_vector_zero) -{ - Shape shape_a{0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{}; - auto axes = make_shared(element::i32, Shape{}, 0); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{1}), read_vector(result))); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_product_matrix_to_scalar_zero_by_zero) -{ - Shape shape_a{0, 0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{}; - auto axes = make_shared(element::i32, Shape{2}, vector{0, 1}); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{1}), read_vector(result))); -} - NGRAPH_TEST(${BACKEND_NAME}, reduce_product_3d_to_matrix_most_sig) { Shape shape_a{3, 3, 3}; @@ -283,31 +194,6 @@ NGRAPH_TEST(${BACKEND_NAME}, reduce_product_3d_to_scalar) read_vector(result))); } -NGRAPH_TEST(${BACKEND_NAME}, reduce_product_3d_eliminate_zero_dim) -{ - Shape shape_a{3, 0, 2}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{3, 2}; - auto axes = make_shared(element::i32, Shape{}, 1); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - - // Overwrite the initial result vector to make sure we're not just coincidentally getting the - // right value. - copy_data(result, vector{2112, 2112, 2112, 2112, 2112, 2112}); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{1, 1, 1, 1, 1, 1}), read_vector(result))); -} - NGRAPH_TEST(${BACKEND_NAME}, reduce_product_2d_to_scalar_int32) { Shape shape_a{3, 3}; @@ -433,95 +319,6 @@ NGRAPH_TEST(${BACKEND_NAME}, reduce_product_keep_matrix_rows) EXPECT_TRUE(test::all_close_f((vector{2, 12, 30}), read_vector(result))); } -NGRAPH_TEST(${BACKEND_NAME}, reduce_product_keep_matrix_rows_zero) -{ - Shape shape_a{3, 0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{3, 1}; - auto axes = make_shared(element::i32, Shape{}, 1); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3, 3, 3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{1, 1, 1}), read_vector(result))); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_product_keep_matrix_cols_zero) -{ - // Now the reduction (g(x:float32[2,2],y:float32[]) = reduce(x,y,f,axes={})). - Shape shape_a{0, 2}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{1, 2}; - auto axes = make_shared(element::i32, Shape{}, 0); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3, 3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{1, 1}), read_vector(result))); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_product_keep_vector_zero) -{ - Shape shape_a{0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{1}; - auto axes = make_shared(element::i32, Shape{}, 0); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{1}), read_vector(result))); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_product_keep_matrix_to_scalar_zero_by_zero) -{ - Shape shape_a{0, 0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{1, 1}; - auto axes = make_shared(element::i32, Shape{2}, vector{0, 1}); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{1}), read_vector(result))); -} - NGRAPH_TEST(${BACKEND_NAME}, reduce_product_keep_3d_to_matrix_most_sig) { Shape shape_a{3, 3, 3}; @@ -636,31 +433,6 @@ NGRAPH_TEST(${BACKEND_NAME}, reduce_product_keep_3d_to_scalar) read_vector(result))); } -NGRAPH_TEST(${BACKEND_NAME}, reduce_product_keep_3d_eliminate_zero_dim) -{ - Shape shape_a{3, 0, 2}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{3, 1, 2}; - auto axes = make_shared(element::i32, Shape{}, 1); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - - // Overwrite the initial result vector to make sure we're not just coincidentally getting the - // right value. - copy_data(result, vector{2112, 2112, 2112, 2112, 2112, 2112}); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{1, 1, 1, 1, 1, 1}), read_vector(result))); -} - NGRAPH_TEST(${BACKEND_NAME}, reduce_product_keep_2d_to_scalar_int32) { Shape shape_a{3, 3}; diff --git a/ngraph/test/op_eval/reduce_prod.cpp b/ngraph/test/op_eval/reduce_prod.cpp new file mode 100644 index 00000000000000..d2cd89888ea31e --- /dev/null +++ b/ngraph/test/op_eval/reduce_prod.cpp @@ -0,0 +1,244 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "util/test_control.hpp" +#include "util/all_close.hpp" +#include "util/all_close_f.hpp" +#include "util/ndarray.hpp" + + +using namespace std; +using namespace ngraph; + +static string s_manifest = "${MANIFEST}"; + +TEST(op_eval, reduce_product_matrix_rows_zero) +{ + Shape shape_a{3, 0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{3}; + auto axes = make_shared(element::i32, Shape{}, 1); + auto f = + make_shared(make_shared(A, axes, false), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3, 3, 3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_TRUE(test::all_close_f((vector{1, 1, 1}), read_vector(result))); +} + +TEST(op_eval, reduce_product_matrix_cols_zero) +{ + // Now the reduction (g(x:float32[2,2],y:float32[]) = reduce(x,y,f,axes={})). + Shape shape_a{0, 2}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{2}; + auto axes = make_shared(element::i32, Shape{}, 0); + auto f = + make_shared(make_shared(A, axes, false), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3, 3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_TRUE(test::all_close_f((vector{1, 1}), read_vector(result))); +} + +TEST(op_eval, reduce_product_vector_zero) +{ + Shape shape_a{0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{}; + auto axes = make_shared(element::i32, Shape{}, 0); + auto f = + make_shared(make_shared(A, axes, false), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_TRUE(test::all_close_f((vector{1}), read_vector(result))); +} + +TEST(op_eval, reduce_product_matrix_to_scalar_zero_by_zero) +{ + Shape shape_a{0, 0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{}; + auto axes = make_shared(element::i32, Shape{2}, vector{0, 1}); + auto f = + make_shared(make_shared(A, axes, false), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_TRUE(test::all_close_f((vector{1}), read_vector(result))); +} + +TEST(op_eval, reduce_product_3d_eliminate_zero_dim) +{ + Shape shape_a{3, 0, 2}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{3, 2}; + auto axes = make_shared(element::i32, Shape{}, 1); + auto f = + make_shared(make_shared(A, axes, false), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + + // Overwrite the initial result vector to make sure we're not just coincidentally getting the + // right value. + copy_data(result, vector{2112, 2112, 2112, 2112, 2112, 2112}); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_TRUE(test::all_close_f((vector{1, 1, 1, 1, 1, 1}), read_vector(result))); +} + +TEST(op_eval, reduce_product_keep_matrix_rows_zero) +{ + Shape shape_a{3, 0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{3, 1}; + auto axes = make_shared(element::i32, Shape{}, 1); + auto f = + make_shared(make_shared(A, axes, true), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3, 3, 3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_TRUE(test::all_close_f((vector{1, 1, 1}), read_vector(result))); +} + +TEST(op_eval, reduce_product_keep_matrix_cols_zero) +{ + // Now the reduction (g(x:float32[2,2],y:float32[]) = reduce(x,y,f,axes={})). + Shape shape_a{0, 2}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{1, 2}; + auto axes = make_shared(element::i32, Shape{}, 0); + auto f = + make_shared(make_shared(A, axes, true), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3, 3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_TRUE(test::all_close_f((vector{1, 1}), read_vector(result))); +} + +TEST(op_eval, reduce_product_keep_vector_zero) +{ + Shape shape_a{0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{1}; + auto axes = make_shared(element::i32, Shape{}, 0); + auto f = + make_shared(make_shared(A, axes, true), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_TRUE(test::all_close_f((vector{1}), read_vector(result))); +} + +TEST(op_eval, reduce_product_keep_matrix_to_scalar_zero_by_zero) +{ + Shape shape_a{0, 0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{1, 1}; + auto axes = make_shared(element::i32, Shape{2}, vector{0, 1}); + auto f = + make_shared(make_shared(A, axes, true), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_TRUE(test::all_close_f((vector{1}), read_vector(result))); +} + +TEST(op_eval, reduce_product_keep_3d_eliminate_zero_dim) +{ + Shape shape_a{3, 0, 2}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{3, 1, 2}; + auto axes = make_shared(element::i32, Shape{}, 1); + auto f = + make_shared(make_shared(A, axes, true), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + + // Overwrite the initial result vector to make sure we're not just coincidentally getting the + // right value. + copy_data(result, vector{2112, 2112, 2112, 2112, 2112, 2112}); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_TRUE(test::all_close_f((vector{1, 1, 1, 1, 1, 1}), read_vector(result))); +} diff --git a/ngraph/test/runtime/ie/unit_test.manifest b/ngraph/test/runtime/ie/unit_test.manifest index 425ec0cdf48e30..80f2421fb41d8f 100644 --- a/ngraph/test/runtime/ie/unit_test.manifest +++ b/ngraph/test/runtime/ie/unit_test.manifest @@ -373,6 +373,8 @@ all_dynamic # disabled reference implementation reduce_sum_keep_2d_to_scalar_int8 reduce_sum_2d_to_scalar_int8 +reduce_product_to_scalar_int8 +reduce_product_keep_to_scalar_int8 # accuracy reduce_sum_keep_stable_acc reduce_sum_keep_3d_to_scalar_int32 @@ -458,17 +460,6 @@ onnx_dyn_shapes_model_tile_static gather_4d_indices_axis_0_uint8 tensor_constant_with_op constant_equality_bool -reduce_product_matrix_rows -reduce_product_3d_to_matrix_most_sig -reduce_product_3d_to_matrix_least_sig -reduce_product_keep_matrix_columns -reduce_product_keep_matrix_rows -reduce_product_keep_3d_to_matrix_most_sig -reduce_product_keep_3d_to_matrix_least_sig -reduce_product_matrix_columns_dynamic -reduce_product_matrix_rows_dynamic -reduce_product_keep_matrix_columns_dynamic -reduce_product_keep_matrix_rows_dynamic reduce_min_matrix_columns reduce_min_matrix_rows reduce_min_matrix_rows_int32 @@ -485,18 +476,6 @@ reduce_min_keep_matrix_columns_dynamic reduce_min_keep_matrix_rows_dynamic # zero dimension / result mismatch -reduce_product_matrix_rows_zero -reduce_product_matrix_cols_zero -reduce_product_vector_zero -reduce_product_matrix_to_scalar_zero_by_zero -reduce_product_3d_eliminate_zero_dim -reduce_product_to_scalar_int8 -reduce_product_keep_matrix_rows_zero -reduce_product_keep_matrix_cols_zero -reduce_product_keep_vector_zero -reduce_product_keep_matrix_to_scalar_zero_by_zero -reduce_product_keep_3d_eliminate_zero_dim -reduce_product_keep_to_scalar_int8 reduce_min_to_scalar_int8 reduce_min_matrix_rows_zero reduce_min_matrix_cols_zero From 826638e52349992cc5c85ea41e95d5bd83a9bd83 Mon Sep 17 00:00:00 2001 From: Bartek Szmelczynski Date: Mon, 14 Jun 2021 12:18:22 +0200 Subject: [PATCH 071/178] Revise space_to_batch (#6034) --- .../single_layer/space_to_batch.cpp | 38 ++++++ .../single_layer_tests/space_to_batch.cpp | 91 ++++++++------ .../core/include/ngraph/op/space_to_batch.hpp | 7 +- ngraph/core/src/op/space_to_batch.cpp | 6 +- ngraph/test/CMakeLists.txt | 2 + ngraph/test/backend/space_to_batch.in.cpp | 115 ++++++++++++++++++ ngraph/test/type_prop/space_to_batch.cpp | 101 +++++++++++++++ ngraph/test/visitors/op/space_to_batch.cpp | 33 +++++ 8 files changed, 349 insertions(+), 44 deletions(-) create mode 100644 inference-engine/tests/functional/inference_engine/serialization/single_layer/space_to_batch.cpp create mode 100644 ngraph/test/backend/space_to_batch.in.cpp create mode 100644 ngraph/test/visitors/op/space_to_batch.cpp diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/space_to_batch.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/space_to_batch.cpp new file mode 100644 index 00000000000000..1b55e2fbac71f1 --- /dev/null +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/space_to_batch.cpp @@ -0,0 +1,38 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/single_layer/space_to_batch.hpp" + +#include + +using namespace LayerTestsDefinitions; + +namespace { + +TEST_P(SpaceToBatchLayerTest, Serialize) { + Serialize(); +} + +const std::vector> blockShapes4D{{1, 1, 2, 2}}; +const std::vector> padsBegins4D{{0, 0, 0, 0}, + {0, 0, 0, 2}}; +const std::vector> padsEnds4D{{0, 0, 0, 0}, {0, 0, 0, 2}}; +const std::vector> dataShapes4D{ + {1, 1, 2, 2}, {1, 3, 2, 2}, {1, 1, 4, 4}, {2, 1, 2, 4}}; + +const auto SpaceToBatch4D = ::testing::Combine( + ::testing::ValuesIn(blockShapes4D), ::testing::ValuesIn(padsBegins4D), + ::testing::ValuesIn(padsEnds4D), ::testing::ValuesIn(dataShapes4D), + ::testing::Values(InferenceEngine::Precision::FP32), + ::testing::Values(InferenceEngine::Precision::FP32), + ::testing::Values(InferenceEngine::Precision::FP32), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(CommonTestUtils::DEVICE_CPU)); + +INSTANTIATE_TEST_CASE_P(smoke_spacetobatch4D_Serialization, + SpaceToBatchLayerTest, SpaceToBatch4D, + SpaceToBatchLayerTest::getTestCaseName); + +} // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/space_to_batch.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/space_to_batch.cpp index ac4801df822a54..884440c7bdedbc 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/space_to_batch.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/space_to_batch.cpp @@ -11,47 +11,64 @@ using namespace LayerTestsDefinitions; namespace { -spaceToBatchParamsTuple stb_only_test_cases[] = { - spaceToBatchParamsTuple({1, 1, 2, 2}, {0, 0, 0, 0}, {0, 0, 0, 0}, {1, 1, 2, 2}, - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::UNSPECIFIED, - InferenceEngine::Precision::UNSPECIFIED, - InferenceEngine::Layout::ANY, - InferenceEngine::Layout::ANY, - CommonTestUtils::DEVICE_CPU), - spaceToBatchParamsTuple({1, 1, 2, 2}, {0, 0, 0, 0}, {0, 0, 0, 0}, {1, 3, 2, 2}, - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::UNSPECIFIED, - InferenceEngine::Precision::UNSPECIFIED, - InferenceEngine::Layout::ANY, - InferenceEngine::Layout::ANY, - CommonTestUtils::DEVICE_CPU), - spaceToBatchParamsTuple({1, 1, 2, 2}, {0, 0, 0, 0}, {0, 0, 0, 0}, {1, 1, 4, 4}, - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::UNSPECIFIED, - InferenceEngine::Precision::UNSPECIFIED, - InferenceEngine::Layout::ANY, - InferenceEngine::Layout::ANY, - CommonTestUtils::DEVICE_CPU), - spaceToBatchParamsTuple({1, 1, 2, 2}, {0, 0, 0, 2}, {0, 0, 0, 0}, {2, 1, 2, 4}, - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::UNSPECIFIED, - InferenceEngine::Precision::UNSPECIFIED, - InferenceEngine::Layout::ANY, - InferenceEngine::Layout::ANY, - CommonTestUtils::DEVICE_CPU), - spaceToBatchParamsTuple({1, 1, 3, 2, 2}, {0, 0, 1, 0, 3}, {0, 0, 2, 0, 0}, {1, 1, 3, 2, 1}, - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::UNSPECIFIED, - InferenceEngine::Precision::UNSPECIFIED, - InferenceEngine::Layout::ANY, - InferenceEngine::Layout::ANY, - CommonTestUtils::DEVICE_CPU), +const std::vector> blockShapes4D { + {1, 1, 2, 2} +}; +const std::vector> padsBegins4D { + {0, 0, 0, 0}, {0, 0, 0, 2} +}; +const std::vector> padsEnds4D { + {0, 0, 0, 0}, {0, 0, 0, 2} +}; +const std::vector> dataShapes4D { + {1, 1, 2, 2}, {1, 3, 2, 2}, {1, 1, 4, 4}, {2, 1, 2, 4} }; +const auto SpaceToBatch4D = ::testing::Combine( + ::testing::ValuesIn(blockShapes4D), + ::testing::ValuesIn(padsBegins4D), + ::testing::ValuesIn(padsEnds4D), + ::testing::ValuesIn(dataShapes4D), + ::testing::Values(InferenceEngine::Precision::FP32), + ::testing::Values(InferenceEngine::Precision::FP32), + ::testing::Values(InferenceEngine::Precision::FP32), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(CommonTestUtils::DEVICE_CPU) +); + INSTANTIATE_TEST_CASE_P( - smoke_MKLDNN, SpaceToBatchLayerTest, ::testing::ValuesIn(stb_only_test_cases), + smoke_spacetobatch4D, SpaceToBatchLayerTest, SpaceToBatch4D, SpaceToBatchLayerTest::getTestCaseName); +const std::vector> blockShapes5D { + {1, 1, 3, 2, 2} +}; +const std::vector> padsBegins5D { + {0, 0, 1, 0, 3} +}; +const std::vector> padsEnds5D { + {0, 0, 2, 0, 0} +}; +const std::vector> dataShapes5D { + {1, 1, 3, 2, 1} +}; + +const auto SpaceToBatch5D = ::testing::Combine( + ::testing::ValuesIn(blockShapes5D), + ::testing::ValuesIn(padsBegins5D), + ::testing::ValuesIn(padsEnds5D), + ::testing::ValuesIn(dataShapes5D), + ::testing::Values(InferenceEngine::Precision::FP32), + ::testing::Values(InferenceEngine::Precision::FP32), + ::testing::Values(InferenceEngine::Precision::FP32), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(CommonTestUtils::DEVICE_CPU) +); + +INSTANTIATE_TEST_CASE_P( + smoke_spacetobatch5D, SpaceToBatchLayerTest, SpaceToBatch5D, + SpaceToBatchLayerTest::getTestCaseName); } // namespace \ No newline at end of file diff --git a/ngraph/core/include/ngraph/op/space_to_batch.hpp b/ngraph/core/include/ngraph/op/space_to_batch.hpp index 35587652384100..9f6220b3293cbd 100644 --- a/ngraph/core/include/ngraph/op/space_to_batch.hpp +++ b/ngraph/core/include/ngraph/op/space_to_batch.hpp @@ -4,8 +4,7 @@ #pragma once -#include "ngraph/node.hpp" -#include "ngraph/op/util/fused_op.hpp" +#include "ngraph/op/op.hpp" namespace ngraph { @@ -27,8 +26,8 @@ namespace ngraph class NGRAPH_API SpaceToBatch : public Op { public: - static constexpr NodeTypeInfo type_info{"SpaceToBatch", 1}; - const NodeTypeInfo& get_type_info() const override { return type_info; } + NGRAPH_RTTI_DECLARATION; + SpaceToBatch() = default; /// \brief Constructs a SpaceToBatch operation. diff --git a/ngraph/core/src/op/space_to_batch.cpp b/ngraph/core/src/op/space_to_batch.cpp index 75c6ad435b050e..885228536529a6 100644 --- a/ngraph/core/src/op/space_to_batch.cpp +++ b/ngraph/core/src/op/space_to_batch.cpp @@ -21,7 +21,7 @@ using namespace std; using namespace ngraph; -constexpr NodeTypeInfo op::v1::SpaceToBatch::type_info; +NGRAPH_RTTI_DEFINITION(op::v1::SpaceToBatch, "SpaceToBatch", 1); ngraph::op::v1::SpaceToBatch::SpaceToBatch(const ngraph::Output& data, const ngraph::Output& block_shape, @@ -49,13 +49,13 @@ void op::v1::SpaceToBatch::validate_and_infer_types() NODE_VALIDATION_CHECK(this, pads_begin_type.is_integral_number(), - "crops_begin must be an integral number but got (", + "pads_begin must be an integral number but got (", pads_begin_type, ")."); NODE_VALIDATION_CHECK(this, pads_end_type.is_integral_number(), - "crops_end must be an integral number but got (", + "pads_end must be an integral number but got (", pads_end_type, ")."); diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index 97065dc966eb6a..5ca3049b6e2095 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -275,6 +275,7 @@ set(SRC visitors/op/selu.cpp visitors/op/shuffle_channels.cpp visitors/op/softmax.cpp + visitors/op/space_to_batch.cpp visitors/op/space_to_depth.cpp visitors/op/split.cpp visitors/op/squared_difference.cpp @@ -445,6 +446,7 @@ set(MULTI_TEST_SRC backend/sin.in.cpp backend/sinh.in.cpp backend/softmax.in.cpp + backend/space_to_batch.in.cpp backend/split.in.cpp backend/sqrt.in.cpp backend/squared_difference.in.cpp diff --git a/ngraph/test/backend/space_to_batch.in.cpp b/ngraph/test/backend/space_to_batch.in.cpp new file mode 100644 index 00000000000000..6e9f20804345bb --- /dev/null +++ b/ngraph/test/backend/space_to_batch.in.cpp @@ -0,0 +1,115 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "util/engine/test_engines.hpp" +#include "util/test_case.hpp" +#include "util/test_control.hpp" + +using namespace std; +using namespace ngraph; + +static string s_manifest = "${MANIFEST}"; +using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); + +static void SpaceToBatchTest(const std::vector& inputs, + const Shape inputs_shape, + const std::vector& block_shapes, + const Shape blocks_shape, + const std::vector& pads_begins, + const std::vector& pads_ends, + const Shape pads_shape, + const std::vector& outputs, + const Shape outputs_shape) +{ + auto inputs_param = make_shared(element::f32, inputs_shape); + auto block_shapes_param = make_shared(element::i64, blocks_shape, block_shapes); + auto pads_begins_param = make_shared(element::i64, pads_shape, pads_begins); + auto pads_ends_param = make_shared(element::i64, pads_shape, pads_ends); + + auto space_to_batch = make_shared( + inputs_param, block_shapes_param, pads_begins_param, pads_ends_param); + auto f = make_shared(space_to_batch, ParameterVector{inputs_param}); + + auto test_case = test::TestCase(f); + test_case.add_input(inputs); + test_case.add_expected_output(outputs_shape, outputs); + test_case.run(); +} + + +NGRAPH_TEST(${BACKEND_NAME}, space_to_batch_4D) +{ + const Shape inputs_shape{1, 1, 2, 2}; + const std::vector inputs{1.0f, 1.0f, + 1.0f, 1.0f}; + + const Shape blocks_shape{4}; + const std::vector block_shapes{1, 1, 1, 1}; + + const Shape pads_shape{4}; + const std::vector pads_begins{0, 0 ,0, 0}; + const std::vector pads_ends{0, 0, 0, 0}; + + const Shape outputs_shape{1, 1, 2, 2}; + const std::vector outputs{1.0f, 1.0f, + 1.0f, 1.0f}; + + + SpaceToBatchTest(inputs, inputs_shape, block_shapes, blocks_shape, pads_begins, + pads_ends, pads_shape, outputs, outputs_shape); +} + +NGRAPH_TEST(${BACKEND_NAME}, space_to_batch_5D) +{ + const Shape inputs_shape{1, 1, 3, 2, 1}; + const std::vector inputs{1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f}; + + const Shape blocks_shape{5}; + const std::vector block_shapes{1, 1, 3, 2, 2}; + + const Shape pads_shape{5}; + const std::vector pads_begins{0, 0 ,1, 0, 3}; + const std::vector pads_ends{0, 0, 2, 0, 0}; + + const Shape outputs_shape{12, 1, 2, 1, 2}; + const std::vector outputs{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f}; + + + SpaceToBatchTest(inputs, inputs_shape, block_shapes, blocks_shape, pads_begins, + pads_ends, pads_shape, outputs, outputs_shape); +} + +NGRAPH_TEST(${BACKEND_NAME}, space_to_batch_4x4) +{ + const Shape inputs_shape{1, 1, 4, 4}; + const std::vector inputs{1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + + const Shape blocks_shape{4}; + const std::vector block_shapes{1, 1, 1, 1}; + + const Shape pads_shape{4}; + const std::vector pads_begins{0, 0, 1, 0}; + const std::vector pads_ends{0, 0, 0, 0}; + + const Shape outputs_shape{1, 1, 5, 4}; + const std::vector outputs{0.0f, 0.0f, 0.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + + SpaceToBatchTest(inputs, inputs_shape, block_shapes, blocks_shape, pads_begins, + pads_ends, pads_shape, outputs, outputs_shape); +} diff --git a/ngraph/test/type_prop/space_to_batch.cpp b/ngraph/test/type_prop/space_to_batch.cpp index cf4b3ffdf7f9cd..18cce1d1648b49 100644 --- a/ngraph/test/type_prop/space_to_batch.cpp +++ b/ngraph/test/type_prop/space_to_batch.cpp @@ -110,3 +110,104 @@ TEST(type_prop, space_to_batch_dynamic_shape_dynamic_rank) ASSERT_EQ(space_to_batch->get_element_type(), element::f32); ASSERT_EQ(space_to_batch->get_output_partial_shape(0), PartialShape::dynamic()); } + +TEST(type_prop, space_to_batch_invalid_element_type_block_shape) +{ + auto data = make_shared(element::f32, Shape{2, 128}); + auto block_shape = make_shared(element::f32, Shape{2}, vector{1, 5}); + auto pads_begin = make_shared(element::i64, Shape{2}, vector{0, 2}); + auto pads_end = make_shared(element::i64, Shape{2}, vector{0, 0}); + + try + { + auto space_to_batch = + make_shared(data, block_shape, pads_begin, pads_end); + // Input element type is float32 + FAIL() << "Invalid f32 element type for block_shape not detected"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), "block_shape must be an integral number"); + } + catch(...) + { + FAIL() << "Integral element type node validation check failed for unexpected reason"; + } + +} + +TEST(type_prop, space_to_batch_invalid_element_type_pads_begin) +{ + auto data = make_shared(element::f32, Shape{2, 128}); + auto block_shape = make_shared(element::i64, Shape{2}, vector{1, 5}); + auto pads_begin = make_shared(element::f32, Shape{2}, vector{0, 2}); + auto pads_end = make_shared(element::i64, Shape{2}, vector{0, 0}); + + try + { + auto space_to_batch = + make_shared(data, block_shape, pads_begin, pads_end); + // Input element type is float32 + FAIL() << "Invalid f32 element type for pads_begin not detected"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), "pads_begin must be an integral number but got"); + } + catch(...) + { + FAIL() << "Integral element type node validation check failed for unexpected reason"; + } + +} + +TEST(type_prop, space_to_batch_invalid_element_type_pads_end) +{ + auto data = make_shared(element::f32, Shape{2, 128}); + auto block_shape = make_shared(element::i16, Shape{2}, vector{1, 5}); + auto pads_begin = make_shared(element::i64, Shape{2}, vector{0, 2}); + auto pads_end = make_shared(element::f32, Shape{2}, vector{0, 0}); + + try + { + auto space_to_batch = + make_shared(data, block_shape, pads_begin, pads_end); + // Input element type is float32 + FAIL() << "Invalid f32 element type for pads_end not detected"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), "pads_end must be an integral number but got"); + } + catch(...) + { + FAIL() << "Integral element type node validation check failed for unexpected reason"; + } + +} + +TEST(type_prop, space_to_batch_invalid_value_block_shape) +{ + auto data = make_shared(element::f32, Shape{2, 128}); + auto block_shape = make_shared(element::i64, Shape{2}, vector{-1, -5}); + auto pads_begin = make_shared(element::i64, Shape{2}, vector{0, 2}); + auto pads_end = make_shared(element::i64, Shape{2}, vector{0, 0}); + + try + { + auto space_to_batch = + make_shared(data, block_shape, pads_begin, pads_end); + // Input element type is float32 + FAIL() << "Invalid block_shape value not detected"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), "block_shape values must be greater than 0"); + } + catch(...) + { + FAIL() << "block_shape value node validation check failed for unexpected reason"; + } + +} + diff --git a/ngraph/test/visitors/op/space_to_batch.cpp b/ngraph/test/visitors/op/space_to_batch.cpp new file mode 100644 index 00000000000000..c105cd2a454ac1 --- /dev/null +++ b/ngraph/test/visitors/op/space_to_batch.cpp @@ -0,0 +1,33 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" + +#include "ngraph/ngraph.hpp" +#include "ngraph/op/util/attr_types.hpp" +#include "ngraph/opsets/opset2.hpp" + +#include "util/visitor.hpp" + +using namespace std; +using namespace ngraph; +using ngraph::test::NodeBuilder; + + +TEST(attributes, space_to_batch_op) +{ + using namespace opset2; + + NodeBuilder::get_ops().register_factory(); + auto data = make_shared(element::f32, Shape{2, 128}); + auto block_shape = make_shared(element::i64, Shape{2}, vector{1, 5}); + auto pads_begin = make_shared(element::i64, Shape{2}, vector{0, 2}); + auto pads_end = make_shared(element::i64, Shape{2}, vector{0, 0}); + auto op = make_shared(data, block_shape, pads_begin, pads_end); + + NodeBuilder builder(op); + const auto expected_attr_count = 0; + + EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); +} From 978121e91ed1a974b4576e78b7fea89186f39438 Mon Sep 17 00:00:00 2001 From: Szymon Durawa Date: Mon, 14 Jun 2021 13:28:32 +0200 Subject: [PATCH 072/178] Ref implementation transposed convolution revise (#4999) --- .../ngraph/runtime/reference/convolution.hpp | 23 +- .../reference/convolution_backprop_data.hpp | 589 +++++--- .../group_convolution_backprop_data.hpp | 25 +- ngraph/test/CMakeLists.txt | 1 + .../test/backend/convolution_backprop.in.cpp | 1221 +++++++++++++++++ .../runtime/interpreter/evaluates_map.cpp | 3 +- 6 files changed, 1615 insertions(+), 247 deletions(-) create mode 100644 ngraph/test/backend/convolution_backprop.in.cpp diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/convolution.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/convolution.hpp index e5e12bac9acbc9..adee512d975c2b 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/convolution.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/convolution.hpp @@ -18,8 +18,6 @@ #include "ngraph/runtime/reference/split.hpp" #include "ngraph/util.hpp" -// can't be removed currently due to arm-plugin dependency -#include "ngraph/runtime/reference/convolution_backprop_data.hpp" namespace ngraph { namespace runtime @@ -42,15 +40,18 @@ namespace ngraph std::vector dilation; std::vector pads_begin; std::vector pads_end; + std::vector output_padding; ConvolutionParams(const Strides& strides_, const Strides& dilation_, const CoordinateDiff& pads_begin_, - const CoordinateDiff& pads_end_) + const CoordinateDiff& pads_end_, + const CoordinateDiff& output_padding_ = {0, 0, 0}) : strides{strides_.begin(), strides_.end()} , dilation{dilation_.begin(), dilation_.end()} , pads_begin{pads_begin_.begin(), pads_begin_.end()} - , pads_end{pads_end_.begin(), pads_end_.end()} {}; + , pads_end{pads_end_.begin(), pads_end_.end()} + , output_padding{output_padding_.begin(), output_padding_.end()} {}; }; template @@ -86,15 +87,18 @@ namespace ngraph const size_t filter_channel_size = shape_size(filter_channel_shape); for (int i_z = -p.pads_begin[0]; - i_z <= (p.pads_end[0] + input_size_z - dilated_filter_size_z); + i_z <= (p.pads_end[0] + input_size_z - dilated_filter_size_z + + p.output_padding[0]); i_z += p.strides[0]) { for (int i_y = -p.pads_begin[1]; - i_y <= (p.pads_end[1] + input_size_y - dilated_filter_size_y); + i_y <= (p.pads_end[1] + input_size_y - dilated_filter_size_y + + p.output_padding[1]); i_y += p.strides[1]) { for (int i_x = -p.pads_begin[2]; - i_x <= (p.pads_end[2] + input_size_x - dilated_filter_size_x); + i_x <= (p.pads_end[2] + input_size_x - dilated_filter_size_x + + p.output_padding[2]); i_x += p.strides[2]) { auto input_channel = batch; @@ -154,6 +158,8 @@ namespace ngraph std::prev(p.pads_begin.end(), spatial_rank), missing_dims, 0); p.pads_end.insert( std::prev(p.pads_end.end(), spatial_rank), missing_dims, 0); + p.output_padding.insert( + std::prev(p.output_padding.end(), spatial_rank), missing_dims, 0); in_shape.insert(std::next(in_shape.end(), -spatial_rank), missing_dims, 1); filter_shape.insert( std::prev(filter_shape.end(), spatial_rank), missing_dims, 1); @@ -324,3 +330,6 @@ namespace ngraph } // namespace reference } // namespace runtime } // namespace ngraph + +// can't be removed currently due to arm-plugin dependency +#include "ngraph/runtime/reference/convolution_backprop_data.hpp" diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/convolution_backprop_data.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/convolution_backprop_data.hpp index 3fa325f7726e05..1c755198163a7a 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/convolution_backprop_data.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/convolution_backprop_data.hpp @@ -10,11 +10,7 @@ #include #include "ngraph/axis_vector.hpp" -#include "ngraph/coordinate_transform.hpp" -#include "ngraph/runtime/reference/concat.hpp" -#include "ngraph/runtime/reference/helpers.hpp" -#include "ngraph/runtime/reference/reverse.hpp" -#include "ngraph/runtime/reference/split.hpp" +#include "ngraph/runtime/reference/convolution.hpp" #include "ngraph/util.hpp" namespace ngraph @@ -23,217 +19,302 @@ namespace ngraph { namespace reference { - // in: NC_I... - // filter: C_OC_I... - // out: NC_O... - template ::type> - void convolution_backprop_impl(const INPUT* in, - const FILTER* filter, - OUTPUT* out, - const Shape& in_shape, - const Shape& filter_shape, - const Shape& out_shape, - const Strides& stride, - const Strides& filter_dilation, - const CoordinateDiff& in_pad_below, - const CoordinateDiff& in_pad_above, - const Strides& in_dilation, - size_t in_batch_axis, - size_t in_channel_axis, - size_t filter_out_channel_axis, - size_t filter_in_channel_axis, - size_t out_batch_axis, - size_t out_channel_axis) + namespace { - auto old_mode = std::fegetround(); - std::fesetround(FE_TONEAREST); - // Comments throughout assume without loss of generality that: - // - // * batch axes for both in and out are 0 - // * in channel axes for both in and filter are 1 - // * out channel axes for filter is 0 - // * out channel axis for out is 1 - - // At the outermost level we will walk over every out coordinate O. - CoordinateTransform out_transform(out_shape); - - for (const Coordinate& out_coord : out_transform) + constexpr size_t filter_input_ch_axis = 0; + + template + void extend_with_zeros(const Strides& strides, + const Shape& input_shape, + const T* in, + Shape& output_shape, + std::vector& input_zeros) { - // Our out coordinate O will have the form: - // - // (N,chan_out,i_1,...,i_n) - - size_t batch_index = out_coord[out_batch_axis]; - size_t out_channel = out_coord[out_channel_axis]; - - // For the in we need to iterate the coordinate: - // - // I: - // - // over the range (noninclusive on the right): - // - // (N,0,s_1*i_1,s_2*i_2,...,s_n*i_n) -> - // - // (N+1, - // chans_in_count, - // s_1*i_1+ l_1*filter_dims_1, - /// ..., - /// s_n*i_n +l_n*filter_dims_n) - // - // with strides: - // - // (1,l_1,...,l_n). - // - // Note that we are iterating within the *padded* and *dilated* in batch, so - // further down we must check the current coordinate is in the pad or dilation - // gap. - - size_t n_spatial_dimensions = in_shape.size() - 2; - size_t n_in_channels = in_shape[in_channel_axis]; - - Coordinate in_transform_start(2 + n_spatial_dimensions); - Coordinate in_transform_end(2 + n_spatial_dimensions); - Strides in_transform_movement_strides(2 + n_spatial_dimensions, 1); - CoordinateDiff in_transform_pad_below(2 + n_spatial_dimensions, 0); - CoordinateDiff in_transform_pad_above(2 + n_spatial_dimensions, 0); - Strides in_transform_dilation_strides(2 + n_spatial_dimensions, 1); - - in_transform_start[in_batch_axis] = batch_index; - in_transform_end[in_batch_axis] = batch_index + 1; - in_transform_start[in_channel_axis] = 0; - in_transform_end[in_channel_axis] = 1; - - for (size_t i = 2; i < n_spatial_dimensions + 2; i++) + std::vector input_3d(3, 1); + std::vector strides_3d(3, 1); + std::vector output_3d(3, 1); + + for (size_t i = 0; i < strides.size(); ++i) { - size_t filter_dilation_stride = filter_dilation[i - 2]; - size_t filter_movement_stride = stride[i - 2]; - std::ptrdiff_t below_pad = in_pad_below[i - 2]; - std::ptrdiff_t above_pad = in_pad_above[i - 2]; - size_t in_dilation_stride = in_dilation[i - 2]; - - in_transform_start[i] = filter_movement_stride * out_coord[i]; - in_transform_end[i] = in_transform_start[i] + - (filter_shape[i] - 1) * filter_dilation_stride + 1; - in_transform_movement_strides[i] = filter_dilation_stride; - in_transform_pad_below[i] = below_pad; - in_transform_pad_above[i] = above_pad; - in_transform_dilation_strides[i] = in_dilation_stride; + output_shape[i + 2] = + input_shape[i + 2] + (strides[i] - 1) * (input_shape[i + 2] - 1); + input_3d[input_3d.size() - strides.size() + i] = input_shape[i + 2]; + strides_3d[strides_3d.size() - strides.size() + i] = strides[i]; + output_3d[output_3d.size() - strides.size() + i] = output_shape[i + 2]; } - AxisVector in_transform_axis_order(2 + n_spatial_dimensions); - for (size_t i = 0; i < in_transform_axis_order.size(); i++) + const size_t input_size = shape_size(input_3d); + if (input_size == 1) { - in_transform_axis_order[i] = i; + for (size_t i = 0; i < shape_size(input_shape); ++i) + { + input_zeros.push_back(in[i]); + } } - CoordinateTransform in_transform(in_shape, - in_transform_start, - in_transform_end, - in_transform_movement_strides, - in_transform_axis_order, - in_transform_pad_below, - in_transform_pad_above, - in_transform_dilation_strides); - - // Simultaneously with iterating I, for the filter we need to iterate the - // coordinate: - // - // F - // - // over the range (noninclusive on the right): - // - // (chan_out,0,0,...,0) -> - // (chan_out+1, - // chans_in_count, - // filter_dims_1, - // ..., - // filter_dims_n) - // - // with unit stride. - - Shape filter_transform_start(2 + n_spatial_dimensions); - Shape filter_transform_end(2 + n_spatial_dimensions); - - filter_transform_start[filter_out_channel_axis] = out_channel; - filter_transform_end[filter_out_channel_axis] = out_channel + 1; - filter_transform_start[filter_in_channel_axis] = 0; - filter_transform_end[filter_in_channel_axis] = 1; - - for (size_t i = 2; i < n_spatial_dimensions + 2; i++) + else { - filter_transform_start[i] = 0; - filter_transform_end[i] = filter_shape[i]; + for (size_t batch = 0; batch < input_shape[0]; ++batch) + { + const auto offset_batch = batch * input_size * input_shape[1]; + for (size_t channel = 0; channel < input_shape[1]; ++channel) + { + const auto offset_channel = offset_batch + channel * input_size; + for (int i_z = 0; i_z < input_3d[0]; ++i_z) + { + const auto offset_i_z = i_z * input_3d[2] * input_3d[1]; + for (int i_y = 0; i_y < input_3d[1]; ++i_y) + { + const auto offset_i_y = i_y * input_3d[2]; + for (int i_x = 0; i_x < input_3d[2]; ++i_x) + { + input_zeros.push_back( + in[offset_channel + i_x + offset_i_y + offset_i_z]); + + if (i_x < input_3d[2] - 1) + { + for (int k = 0; k < strides_3d[2] - 1; k++) + { + input_zeros.push_back(0); + } + } + } + + if (i_y < input_3d[1] - 1) + { + const auto new_size = + output_3d[2] * (strides_3d[1] - 1); + input_zeros.insert(input_zeros.begin() + + input_zeros.size(), + new_size, + 0); + } + } + + if (i_z < input_3d[0] - 1) + { + const auto new_size = + output_3d[1] * output_3d[2] * (strides_3d[0] - 1); + input_zeros.insert( + input_zeros.begin() + input_zeros.size(), new_size, 0); + } + } + } + } } + } - CoordinateTransform filter_transform( - filter_shape, filter_transform_start, filter_transform_end); - - // As we go, we sum up: - // - // out[O] += in[I] * filter[F]. + void infer_forward_convbackprop_output_shape(const Shape& in_spatial_shape, + const Shape& f_spatial_shape, + const Shape& out_spatial_shape, + Shape& infer_spatial_shape, + const Strides& strides, + const Strides& dilations, + const CoordinateDiff& output_padding) + { + for (size_t idx = 0; idx < in_spatial_shape.size(); idx++) + { + int total_padding = strides[idx] * (in_spatial_shape[idx] - 1) + + dilations[idx] * (f_spatial_shape[idx] - 1) + 1 - + out_spatial_shape[idx] + output_padding[idx]; + size_t padded_dim = std::max(total_padding, 0); + size_t filter_dilated_dim = dilations[idx] * (f_spatial_shape[idx] - 1) + 1; + size_t out_spatial_dim = (in_spatial_shape[idx] - 1) * strides[idx] + + filter_dilated_dim - padded_dim + + output_padding[idx]; + infer_spatial_shape.push_back(out_spatial_dim); + } + } - ACCUMULATION result = 0; + void validate_convolution_backprop_parameters(const Shape& in_shape, + const Shape& f_shape, + const Shape& out_shape, + const Strides& strides, + const Strides& dilations, + const CoordinateDiff& pads_begin, + const CoordinateDiff& pads_end, + const CoordinateDiff& output_padding) + { + // this implementation supports 1D, 2D and 3D convolutions + NGRAPH_CHECK(in_shape.size() >= 3 && in_shape.size() <= 5, + "Unsupported input rank: ", + in_shape); + + NGRAPH_CHECK(in_shape.size() == f_shape.size(), + "Incompatible input ranks: ", + in_shape.size(), + " and ", + f_shape.size()); + + NGRAPH_CHECK(in_shape[in_channel_axis] == f_shape[filter_input_ch_axis], + "Incompatible input channels in data batch and filters shapes: ", + in_shape[in_channel_axis], + " and ", + f_shape[filter_input_ch_axis]); + + NGRAPH_CHECK(in_shape.size() == out_shape.size(), + "Incompatible input and output ranks: ", + in_shape.size(), + " and ", + out_shape.size()); + + const auto spatial_dims = in_shape.size() - 2; + NGRAPH_CHECK(strides.size() == spatial_dims, + "Strides not definied for all and only spatial dimensions."); + + NGRAPH_CHECK(dilations.size() == spatial_dims, + "Dilations not defined for all and only spatial dimensions."); + + NGRAPH_CHECK((pads_begin.size() == pads_end.size()) && + (pads_begin.size() == spatial_dims), + "Pads not defined for all and only spatial dimensions."); + + NGRAPH_CHECK(!output_padding.empty() && output_padding.size() == spatial_dims, + "Output padding not defined for all and only spatial dimensions."); + + Shape out_spatial_shape{std::next(out_shape.begin(), 2), std::end(out_shape)}; + Shape infered_out_spatial_shape{}; + infer_forward_convbackprop_output_shape( + Shape{std::next(in_shape.begin(), 2), std::end(in_shape)}, + Shape{std::next(f_shape.begin(), 2), std::end(f_shape)}, + Shape{std::next(out_shape.begin(), 2), std::end(out_shape)}, + infered_out_spatial_shape, + strides, + dilations, + output_padding); + NGRAPH_CHECK(out_spatial_shape == infered_out_spatial_shape, + "Incorrect output shape provided"); + } + } // namespace - CoordinateTransform::Iterator in_it = in_transform.begin(); - CoordinateTransform::Iterator filter_it = filter_transform.begin(); - CoordinateTransform::Iterator in_it_end = in_transform.end(); - CoordinateTransform::Iterator filter_it_end = filter_transform.end(); + template + void convolution_backprop_impl(const T* in, + const T* f, + T* out, + const Shape& in_shape, + const Shape& f_shape, + const Shape& out_shape, + const Strides& strides, + const Strides& dilation, + const CoordinateDiff& pads_begin, + const CoordinateDiff& pads_end, + const CoordinateDiff& output_padding) - size_t in_channel_stride = row_major_strides(in_shape).at(in_channel_axis); - size_t filter_in_channel_stride = - row_major_strides(filter_shape).at(filter_in_channel_axis); + { + // here we are converting all param types to int's to avoid arithmetic issues + // (e.g signed + unsigned) in indexes calculation later + ConvolutionParams params{strides, dilation, pads_begin, pads_end, output_padding}; + + // here we are extending spatial dimensions to 3D, because we are going to use 3D + // convolution implementation to convolve also in 1D & 2D case + Shape input_shape{in_shape}; + Shape filters_shape{f_shape}; + if (in_shape.size() < 5) + { + extend_to_3D(params, input_shape, filters_shape); + } - while (in_it != in_it_end && filter_it != filter_it_end) + for (size_t i = 0; i < input_shape.size() - 2; ++i) + { + if (input_shape[i + 2] > 1 || filters_shape[i + 2] > 1) { - const Coordinate& in_coord = *in_it; - if (in_transform.has_source_coordinate(in_coord)) - { - size_t in_idx = in_transform.index(in_coord); - const Coordinate& filter_coord = *filter_it; - size_t filter_idx = filter_transform.index(filter_coord); - for (size_t in_channel = 0; in_channel < n_in_channels; ++in_channel) - { - ACCUMULATION in_v = static_cast(in[in_idx]); - ACCUMULATION f_v = static_cast(filter[filter_idx]); + params.pads_begin[i] = filters_shape[i + 2] - params.pads_begin[i] - 1; + params.pads_end[i] = filters_shape[i + 2] - params.pads_end[i] - 1; + } + else + { + params.pads_begin[i] = 0; + params.pads_end[i] = 0; + } + } - result += in_v * f_v; - in_idx += in_channel_stride; - filter_idx += filter_in_channel_stride; - } - } - ++in_it; - ++filter_it; + // convert output shape to 3D, contains only dimensions + Shape out_shape_3d{out_shape.begin() + 2, out_shape.end()}; + + int out_shape_rank = out_shape.size() - 2; + if (out_shape_rank < 3) + { + int missing_dims = 3 - out_shape_rank; + out_shape_3d.insert( + std::prev(out_shape_3d.end(), out_shape_rank), missing_dims, 1); + } + + // modify params.pads_end when output_shape was provided in ctor in order to + // calculate expected number of output elements + for (size_t i = 0; i < out_shape_3d.size(); i++) + { + if (out_shape_3d[i] > 1) + { + // expected_dim = (in - 1)* strides + filter - 2*padding + out_padding + // strides is already applied (through 0's extension in input) + // padding = pads_begin + pads_end, formula below is using + // params.pad_begin/params.pads_end: + const size_t expected_dim = + out_shape_3d[i] - ((input_shape[i + 2] - 1) - filters_shape[i + 2] + + params.pads_begin[i] + params.pads_end[i] + 2 + + params.output_padding[i]); + params.pads_end[i] += expected_dim; } + } + + const size_t filters_count = filters_shape[filter_out_ch_axis]; + const Shape filter_shape(++filters_shape.begin(), filters_shape.end()); + const size_t filter_size = shape_size(filter_shape); + + const size_t batches_count = input_shape[in_batch_axis]; + Shape batch_shape(++input_shape.begin(), input_shape.end()); + const size_t batch_size = shape_size(batch_shape); + + auto batch = in; - out[out_transform.index(out_coord)] = result; + for (size_t batch_idx = 0; batch_idx < batches_count; ++batch_idx) + { + auto filter = f; + for (size_t f_idx = 0; f_idx < filters_count; ++f_idx) + { + convolve_3D_channels(params, batch, batch_shape, filter, filter_shape, out); + filter += filter_size; + } + batch += batch_size; } - std::fesetround(old_mode); } - template ::type> - void convolution_backprop_in(const OUTPUT* delta_out, - const FILTER* filter, - INPUT* delta_in, - const Shape& out_shape, - const Shape& filter_shape, + template + void convolution_backprop_in(const T* delta_in, + const T* filter, + T* delta_out, const Shape& in_shape, + const Shape& filter_shape, + const Shape& out_shape, const Strides& in_dilation, const Strides& filter_dilation, const CoordinateDiff& forward_in_pad_bellow, const CoordinateDiff& forward_in_pad_above, - const Strides& stride) + const Strides& stride, + const CoordinateDiff& output_padding) { + std::vector extended_input; + std::vector extended_filter; + AxisSet reverse_axes; + + Shape conv_input_shape = in_shape; + Shape conv_filter_shape = filter_shape; + Strides conv_stride = stride; + Strides conv_filter_dilation = filter_dilation; + auto conv_input_data = delta_in; + + validate_convolution_backprop_parameters(in_shape, + filter_shape, + out_shape, + stride, + filter_dilation, + forward_in_pad_bellow, + forward_in_pad_above, + output_padding); + // Note that we only reverse the spatial dimensions here (loop // starts at 2) - std::vector reversed(shape_size(filter_shape)); - AxisSet reverse_axes; - size_t reverse_axes_start = 2; - for (size_t i = reverse_axes_start; i < filter_shape.size(); ++i) + std::vector reversed(shape_size(filter_shape)); + for (size_t i = 2; i < filter_shape.size(); ++i) { reverse_axes.insert(i); } @@ -242,55 +323,109 @@ namespace ngraph filter_shape, filter_shape, reverse_axes, - sizeof(FILTER)); - size_t filter_out_channel_axis = 1; - size_t filter_in_channel_axis = 0; + sizeof(T)); - // Compute backward pad out pad bellow - size_t spatial_dim_count = in_shape.size() - 2; + auto conv_filter_data = &reversed[0]; - CoordinateDiff backward_delta_out_pad_below; - backward_delta_out_pad_below.resize(spatial_dim_count); + // if channel number for output is > 1 then reverse layout of filter coefficients as + // it is required by convolve_3D_channels() function. + // Current layout: + // batch0_ch0|batch0_ch1|...|batch0_chN|...|batch1_ch0|batch1_ch1|...|batch1_chN|... + // Expected layout: + // batch0_ch0|batch1_ch0|...|batchN_ch0|...|batch0_ch1|batch1_ch1|...|batch1_chN|... + if (filter_shape[1] > 1) + { + std::vector temp_reversed(reversed); + const Shape filter_dim_shape(filter_shape.begin() + 2, filter_shape.end()); + const size_t filter_size = shape_size(filter_dim_shape); - for (size_t i = 0; i < spatial_dim_count; i++) + for (size_t i = 0; i < filter_shape[1]; i++) + { + for (size_t j = 0; j < filter_shape[0]; j++) + { + const auto delta = temp_reversed.begin() + + j * filter_shape[1] * filter_size + i * filter_size; + const auto out = reversed.begin() + i * filter_shape[0] * filter_size + + j * filter_size; + std::copy(delta, delta + filter_size, out); + } + } + } + + // swap filter batch and channels + std::iter_swap(conv_filter_shape.begin(), conv_filter_shape.begin() + 1); + + // extend stride and filter inputs with zero padding for stride and filter_dilation + // > 1, after that set stride and filter params to 1. + const size_t stride_dim = + std::accumulate(stride.begin(), stride.end(), 1, std::multiplies()); + if (stride_dim >= 2) { - backward_delta_out_pad_below[i] = - (static_cast(filter_shape[i + 2]) - 1) * filter_dilation[i] - - forward_in_pad_bellow[i]; + extend_with_zeros(stride, in_shape, delta_in, conv_input_shape, extended_input); + std::fill(conv_stride.begin(), conv_stride.end(), 1); + conv_input_data = &extended_input[0]; } - // Compute backward pad out pad above - CoordinateDiff backward_delta_out_pad_above; - backward_delta_out_pad_above.resize(spatial_dim_count); - for (size_t i = 0; i < spatial_dim_count; i++) + const size_t dilation_dim = std::accumulate( + filter_dilation.begin(), filter_dilation.end(), 1, std::multiplies()); + if (dilation_dim >= 2) { - backward_delta_out_pad_above[i] = - (static_cast(filter_shape[i + 2]) - 1) * filter_dilation[i] + - ((forward_in_pad_bellow[i] + ((in_shape[i + 2]) - 1) * in_dilation[i] + - forward_in_pad_above[i] - - (static_cast(filter_shape[i + 2]) - 1) * filter_dilation[i]) % - stride[i]) - - forward_in_pad_above[i]; + extend_with_zeros(filter_dilation, + filter_shape, + reinterpret_cast(&reversed[0]), + conv_filter_shape, + extended_filter); + std::fill(conv_filter_dilation.begin(), conv_filter_dilation.end(), 1); + conv_filter_data = &extended_filter[0]; } - convolution_backprop_impl( - delta_out, - &reversed[0], - delta_in, - out_shape, - filter_shape, - in_shape, - in_dilation, - filter_dilation, - backward_delta_out_pad_below, - backward_delta_out_pad_above, - stride, - 0, - 1, - filter_out_channel_axis, - filter_in_channel_axis, - 0, - 1); + convolution_backprop_impl(conv_input_data, + conv_filter_data, + delta_out, + conv_input_shape, + conv_filter_shape, + out_shape, + conv_stride, + conv_filter_dilation, + forward_in_pad_bellow, + forward_in_pad_above, + output_padding); + } + + // DEPRECATED, can't be removed currently due to arm-plugin dependency + template ::type> + NGRAPH_DEPRECATED( + "convolution_backprop_in function with 4 template types is deprecated, use " + "function with 1 template and output_padding parameter.") + void convolution_backprop_in(const INPUT* delta_in, + const FILTER* filter, + OUTPUT* delta_out, + const Shape& in_shape, + const Shape& filter_shape, + const Shape& out_shape, + const Strides& in_dilation, + const Strides& filter_dilation, + const CoordinateDiff& forward_in_pad_bellow, + const CoordinateDiff& forward_in_pad_above, + const Strides& stride) + { + const ngraph::CoordinateDiff output_padding(in_shape.size() - 2, 0); + + convolution_backprop_in(delta_in, + filter, + delta_out, + in_shape, + filter_shape, + out_shape, + in_dilation, + filter_dilation, + forward_in_pad_bellow, + forward_in_pad_above, + stride, + output_padding); } } // namespace reference } // namespace runtime diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/group_convolution_backprop_data.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/group_convolution_backprop_data.hpp index b70c0d3ed9ab9d..306ddf047bfad6 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/group_convolution_backprop_data.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/group_convolution_backprop_data.hpp @@ -178,23 +178,24 @@ namespace ngraph const size_t group_out_size = shape_size(group_out_shape); Strides in_dilation(in_shape.size(), 1); + const ngraph::CoordinateDiff output_padding(in_shape.size() - 2, 0); for (size_t batch_idx = 0; batch_idx < in_shape[in_batch_axis]; ++batch_idx) { group_filter = f; for (size_t group_idx = 0; group_idx < group_count; ++group_idx) { - runtime::reference::convolution_backprop_in( - group_batch, - group_filter, - group_out, - group_batch_shape, - group_filter_shape, - group_out_shape, - in_dilation, - dilation, - pads_begin, - pads_end, - strides); + runtime::reference::convolution_backprop_in(group_batch, + group_filter, + group_out, + group_batch_shape, + group_filter_shape, + group_out_shape, + in_dilation, + dilation, + pads_begin, + pads_end, + strides, + output_padding); group_batch += group_batch_size; group_filter += group_filter_size; group_out += group_out_size; diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index 5ca3049b6e2095..c3c5ab80405e23 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -356,6 +356,7 @@ set(MULTI_TEST_SRC backend/constant.in.cpp backend/convert.in.cpp backend/convert_like.in.cpp + backend/convolution_backprop.in.cpp backend/convolution.in.cpp backend/binary_convolution.in.cpp backend/clamp.in.cpp diff --git a/ngraph/test/backend/convolution_backprop.in.cpp b/ngraph/test/backend/convolution_backprop.in.cpp new file mode 100644 index 00000000000000..0426999595656a --- /dev/null +++ b/ngraph/test/backend/convolution_backprop.in.cpp @@ -0,0 +1,1221 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "ngraph/runtime/tensor.hpp" +#include "runtime/backend.hpp" +#include "util/all_close.hpp" +#include "util/all_close_f.hpp" +#include "util/engine/test_engines.hpp" +#include "util/known_element_types.hpp" +#include "util/ndarray.hpp" +#include "util/test_case.hpp" +#include "util/test_control.hpp" +#include "util/test_tools.hpp" + +using namespace std; +using namespace ngraph; + +static string s_manifest = "${MANIFEST}"; +using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); + +static void ConvolutionBackpropTest(const std::vector& inputs, + const Shape inputs_shape, + const std::vector& filters, + const Shape filter_shape, + const std::vector& outputs, + const Shape outputs_shape, + const Strides& strides, + const CoordinateDiff& padding, + const Strides& dilations, + const CoordinateDiff& output_padding) +{ + const CoordinateDiff pads_begin{padding}; + const CoordinateDiff pads_end{padding}; + const op::PadType auto_pad{op::PadType::EXPLICIT}; + const CoordinateDiff out_padding{output_padding}; + + auto inputs_param = make_shared(element::f32, inputs_shape); + auto filters_param = make_shared(element::f32, filter_shape); + auto conv = make_shared(inputs_param, + filters_param, + strides, + pads_begin, + pads_end, + dilations, + auto_pad, + out_padding); + auto f = make_shared(conv, ParameterVector{inputs_param, filters_param}); + + auto test_case = test::TestCase(f); + test_case.add_input(inputs); + test_case.add_input(filters); + test_case.add_expected_output(outputs_shape, outputs); + test_case.run(); +} + +// --------------------- 1D convolution ------------------------------------------ +// clang-format off +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_1D_1batch_1channel) +{ + const Strides strides{1}; + const CoordinateDiff padding{0}; + const Strides dilations{1}; + const CoordinateDiff output_padding{0}; + + const Shape inputs_shape{1, 1, 4}; + const std::vector inputs{5.0f, 6.0f, 7.0f, 2.0f}; + + const Shape filter_shape{1, 1, 3}; + const std::vector filters{2.0f, 0.0f, 1.0f}; + + const Shape outputs_shape{1, 1, 6}; + const std::vector outputs{10.0f, 12.0f, 19.0f, 10.0f, 7.0f, 2.0f}; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_1D_1batch_1channel_padding) +{ + const Strides strides{1}; + const CoordinateDiff padding{1}; + const Strides dilations{1}; + const CoordinateDiff output_padding{0}; + + const Shape inputs_shape{1, 1, 4}; + const std::vector inputs{5.0f, 6.0f, 7.0f, 2.0f}; + + const Shape filter_shape{1, 1, 3}; + const std::vector filters{2.0f, 0.0f, 1.0f}; + + const Shape outputs_shape{1, 1, 4}; + const std::vector outputs{12.0f, 19.0f, 10.0f, 7.0f}; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_1D_1batch_1channel_stride) +{ + const Strides strides{2}; + const CoordinateDiff padding{0}; + const Strides dilations{1}; + const CoordinateDiff output_padding{0}; + + const Shape inputs_shape{1, 1, 2}; + const std::vector inputs{5.0f, 7.0f}; + + const Shape filter_shape{1, 1, 3}; + const std::vector filters{2.0f, 0.0f, 1.0f}; + + const Shape outputs_shape{1, 1, 5}; + const std::vector outputs{10.0f, 0.0f, 19.0f, 0.0f, 7.0f}; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_1D_1batch_1channel_output_padding) +{ + const Strides strides{1}; + const CoordinateDiff padding{1}; + const Strides dilations{1}; + const CoordinateDiff output_padding{1}; + + const Shape inputs_shape{1, 1, 4}; + const std::vector inputs{5.0f, 6.0f, 7.0f, 2.0f}; + + const Shape filter_shape{1, 1, 3}; + const std::vector filters{2.0f, 0.0f, 1.0f}; + + const Shape outputs_shape{1, 1, 5}; + const std::vector outputs{12.0f, 19.0f, 10.0f, 7.0f, 2.0f}; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_1D_1batch_1channel_dilation) +{ + const Strides strides{1}; + const CoordinateDiff padding{0}; + const Strides dilations{2}; + const CoordinateDiff output_padding{0}; + + const Shape inputs_shape{1, 1, 3}; + const std::vector inputs{8.0f, 5.0f, 1.0f}; + + const Shape filter_shape{1, 1, 3}; + const std::vector filters{2.0f, 0.0f, 1.0f}; + + const Shape outputs_shape{1, 1, 7}; + const std::vector outputs{16.0f, 10.0f, 2.0f, 0.0f, 8.0f, 5.0f, 1.0f}; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_1D_1batch_1channel_padding_stride_dilation) +{ + const Strides strides{2}; + const CoordinateDiff padding{2}; + const Strides dilations{2}; + const CoordinateDiff output_padding{0}; + + const Shape inputs_shape{1, 1, 4}; + const std::vector inputs{3.0f, 9.0f, 1.0f, 2.0f}; + + const Shape filter_shape{1, 1, 3}; + const std::vector filters{2.0f, 0.0f, 1.0f}; + + const Shape outputs_shape{1, 1, 7}; + const std::vector outputs{18.0f, 0.0f, 5.0f, 0.0f, 13.0f, 0.0f, 1.0f}; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_1D_1batch_2channel) +{ + const Strides strides{1}; + const CoordinateDiff padding{0}; + const Strides dilations{1}; + const CoordinateDiff output_padding{0}; + + const Shape inputs_shape{1, 1, 2}; + const std::vector inputs{10.0f, 3.0f}; + + const Shape filter_shape{1, 2, 3}; + const std::vector filters{ + // channel 1 + 2.0f, 0.0f, 1.0f, + // channel 2 + 1.0f, 0.0f, 2.0f}; + + const Shape outputs_shape{1, 2, 4}; + const std::vector outputs{ + // channel 1 + 20.0f, 6.0f, 10.0f, 3.0f, + // channel 2 + 10.0f, 3.0f, 20.0f, 6.0f}; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_1D_1batch_2filter) +{ + const Strides strides{1}; + const CoordinateDiff padding{0}; + const Strides dilations{1}; + const CoordinateDiff output_padding{0}; + + const Shape inputs_shape{1, 2, 2}; + const std::vector inputs{ + // channel 1 + 4.0f, 7.0f, + // channel 2 + 5.0f, 5.0f}; + + const Shape filter_shape{2, 1, 3}; + const std::vector filters{ + // filter 1 + 2.0f, 0.0f, 1.0f, + // filter 2 + 1.0f, 0.0f, 2.0f}; + + const Shape outputs_shape{1, 1, 4}; + const std::vector outputs{13.0f, 19.0f, 14.0f, 17.0f}; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_1D_2batch_1channel) +{ + const Strides strides{1}; + const CoordinateDiff padding{0}; + const Strides dilations{1}; + const CoordinateDiff output_padding{0}; + + const Shape inputs_shape{2, 1, 2}; + const std::vector inputs{ + // batch 1 + 1.0f, 3.0f, + // batch 2 + 2.0f, 2.0f}; + + const Shape filter_shape{1, 1, 3}; + const std::vector filters{2.0f, 0.0f, 1.0f}; + + const Shape outputs_shape{2, 1, 4}; + const std::vector outputs{ + // batch 1 + 2.0f, 6.0f, 1.0f, 3.0f, + // batch 2 + 4.0f, 4.0f, 2.0f, 2.0f}; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +// --------------------- 2D convolution ------------------------------------------ +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_2D_1batch_1channel) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const CoordinateDiff output_padding{0, 0}; + + const Shape inputs_shape{1, 1, 2, 2}; + const std::vector inputs{1.0f, 3.0f, + 7.0f, 5.0f}; + + const Shape filter_shape{1, 1, 3, 3}; + const std::vector filters{1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 3.0f, 2.0f, 1.0f}; + + const Shape outputs_shape{1, 1, 4, 4}; + const std::vector outputs{1.0f, 5.0f, 9.0f, 9.0f, + 7.0f, 20.0f, 34.0f, 15.0f, + 3.0f, 18.0f, 12.0f, 3.0f, + 21.0f, 29.0f, 17.0f, 5.0f}; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_2D_1batch_1channel_output_padding) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{1, 1}; + const Strides dilations{1, 1}; + const CoordinateDiff output_padding{1, 1}; + + const Shape inputs_shape{1, 1, 2, 2}; + const std::vector inputs{1.0f, 3.0f, + 7.0f, 5.0f}; + + const Shape filter_shape{1, 1, 3, 3}; + const std::vector filters{1.0f, 2.0f, 3.0f, + 1.0f, 1.0f, 1.0f, + 3.0f, 2.0f, 1.0f}; + + const Shape outputs_shape{1, 1, 3, 3}; + const std::vector outputs{23.0f, 35.0f, 18.0f, + 23.0f, 19.0f, 8.0f, + 29.0f, 17.0f, 5.0f}; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_2D_1batch_1channel_padding) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{1, 1}; + const Strides dilations{1, 1}; + const CoordinateDiff output_padding{0, 0}; + + const Shape inputs_shape{1, 1, 4, 4}; + const std::vector inputs{1.0f, 3.0f, 5.0f, 7.0f, + 7.0f, 5.0f, 3.0f, 1.0f, + 2.0f, 4.0f, 6.0f, 8.0f, + 8.0f, 6.0f, 4.0f, 2.0f}; + + const Shape filter_shape{1, 1, 3, 3}; + const std::vector filters{1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f}; + + const Shape outputs_shape{1, 1, 4, 4}; + const std::vector outputs{20.0f, 37.0f, 27.0f, 18.0f, + 22.0f, 40.0f, 60.0f, 52.0f, + 41.0f, 69.0f, 49.0f, 31.0f, + 18.0f, 26.0f, 34.0f, 22.0f}; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_2D_1batch_1channel_stride) +{ + const Strides strides{2, 2}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const CoordinateDiff output_padding{0, 0}; + + const Shape inputs_shape{1, 1, 2, 2}; + const std::vector inputs{2.0f, 5.0f, + 4.0f, 3.0f}; + + const Shape filter_shape{1, 1, 3, 3}; + const std::vector filters{1.0f, 2.0f, 3.0f, + 1.0f, 1.0f, 1.0f, + 3.0f, 2.0f, 1.0f}; + + const Shape outputs_shape{1, 1, 5, 5}; + const std::vector outputs{2.0f, 4.0f, 11.0f, 10.0f, 15.0f, + 2.0f, 2.0f, 7.0f, 5.0f, 5.0f, + 10.0f, 12.0f, 32.0f, 16.0f, 14.0f, + 4.0f, 4.0f, 7.0f, 3.0f, 3.0f, + 12.0f, 8.0f, 13.0f, 6.0f, 3.0f}; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_2D_1batch_1channel_dilation) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{2, 2}; + const CoordinateDiff output_padding{0, 0}; + + const Shape inputs_shape{1, 1, 2, 2}; + const std::vector inputs{2.0f, 3.0f, + 4.0f, 3.0f}; + + const Shape filter_shape{1, 1, 3, 3}; + const std::vector filters{1.0f, 2.0f, 3.0f, + 1.0f, 1.0f, 1.0f, + 3.0f, 2.0f, 1.0f}; + + const Shape outputs_shape{1, 1, 6, 6}; + const std::vector outputs{2.f, 3.f, 4.f, 6.f, 6.f, 9.f, + 4.f, 3.f, 8.f, 6.f, 12.f, 9.f, + 2.f, 3.f, 2.f, 3.f, 2.f, 3.f, + 4.f, 3.f, 4.f, 3.f, 4.f, 3.f, + 6.f, 9.f, 4.f, 6.f, 2.f, 3.f, + 12.f, 9.f, 8.f, 6.f, 4.f, 3.f}; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_2D_1batch_1channel_padding_strides_dilation) +{ + const Strides strides{2, 2}; + const CoordinateDiff padding{2, 2}; + const Strides dilations{2, 2}; + const CoordinateDiff output_padding{0, 0}; + + const Shape inputs_shape{1, 1, 3, 3}; + const std::vector inputs{1.0f, 3.0f, 5.0f, + 7.0f, 5.0f, 3.0f, + 2.0f, 4.0f, 6.0f}; + + const Shape filter_shape{1, 1, 3, 3}; + const std::vector filters{1.0f, 2.0f, 3.0f, + 1.0f, 1.0f, 1.0f, + 3.0f, 2.0f, 1.0f}; + + const Shape outputs_shape{1, 1, 5, 5}; + const std::vector outputs{23.0f, 0.0f, 43.0f, 0.0f, 29.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 31.0f, 0.0f, 57.0f, 0.0f, 45.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 35.0f, 0.0f, 38.0f, 0.0f, 21.0f}; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_2D_1batch_2channel) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const CoordinateDiff output_padding{0, 0}; + + const Shape inputs_shape{1, 1, 2, 2}; + const std::vector inputs{1.0f, 3.0f, + 7.0f, 5.0f}; + + const Shape filter_shape{1, 2, 3, 3}; + const std::vector filters{ + // channel 1 + 5.0f, 3.0f, 5.0f, + 1.0f, 3.0f, 1.0f, + 4.0f, 2.0f, 4.0f, + // channel 2 + -5.0f, 3.0f, 5.0f, + 1.0f, -3.0f, 1.0f, + 4.0f, 2.0f, -4.0f}; + + const Shape outputs_shape{1, 2, 4, 4}; + const std::vector outputs{ + // channel 1 + 5.0f, 18.0f, 14.0f, 15.0f, + 36.0f, 52.0f, 60.0f, 28.0f, + 11.0f, 40.0f, 32.0f, 17.0f, + 28.0f, 34.0f, 38.0f, 20.0f, + // channel 2 + -5.0f, -12.0f, 14.0f, 15.0f, + -34.0f, -4.0f, 42.0f, 28.0f, + 11.0f, -2.0f, -6.0f, -7.0f, + 28.0f, 34.0f, -18.0f, -20.0f}; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_2D_1batch_2filter) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const CoordinateDiff output_padding{0, 0}; + + const Shape inputs_shape{1, 2, 2, 2}; + const std::vector inputs{ + // channel 1 + 1.0f, 3.0f, + 7.0f, 5.0f, + // channel 2 + 2.0f, 4.0f, + 8.0f, 6.0f}; + + const Shape filter_shape{2, 1, 3, 3}; + const std::vector filters{ + // channel 1 + 5.0f, 3.0f, 5.0f, + 1.0f, 3.0f, 1.0f, + 4.0f, 2.0f, 4.0f, + // channel 2 + -5.0f, 3.0f, 5.0f, + 1.0f, -3.0f, 1.0f, + 4.0f, 2.0f, -4.0f}; + + const Shape outputs_shape{1, 1, 4, 4}; + const std::vector outputs{ + -5.0f, 4.0f, 36.0f, 35.0f, + -2.0f, 44.0f, 108.0f, 62.0f, + 27.0f, 42.0f, 22.0f, 7.0f, + 60.0f, 74.0f, 18.0f, -4.0f}; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_2D_2batch_2filter) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const CoordinateDiff output_padding{0, 0}; + + const Shape inputs_shape{1, 2, 1, 1}; + const std::vector inputs{ + // channel 1 + 2.0f, + // channel 2 + 3.0f}; + + const Shape filter_shape{2, 2, 2, 2}; + const std::vector filters{ + // batch 0 + // channel 1 + 5.0f, 3.0f, + 1.0f, 3.0f, + // channel 2 + -5.0f, 3.0f, + 1.0f, -3.0f, + // batch 1 + // channel 1 + 5.0f, 3.0f, + 1.0f, 3.0f, + // channel 2 + -5.0f, 3.0f, + 1.0f, -3.0f}; + + const Shape outputs_shape{1, 2, 2, 2}; + const std::vector outputs{ + 25.0f, 15.0f, 5.0f, 15.0f, -25.0f, 15.0f, 5.0f, -15.0f}; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_2D_2batch_1channel) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const CoordinateDiff output_padding{0, 0}; + + const Shape inputs_shape{2, 1, 2, 2}; + const std::vector inputs{ + // batch 1 + 1.0f, 3.0f, + 1.0f, 3.0f, + // batch 2 + -1.0f, 3.0f, + 1.0f, 3.0f}; + + const Shape filter_shape{1, 1, 3, 3}; + const std::vector filters{-5.0f, 3.0f, 5.0f, + 1.0f, -3.0f, 1.0f, + 4.0f, 2.0f, -4.0f}; + + const Shape outputs_shape{2, 1, 4, 4}; + const std::vector outputs{ + // batch 1 + -5.0f, -12.0f, 14.0f, 15.0f, + -4.0f, -12.0f, 6.0f, 18.0f, + 5.0f, 14.0f, -6.0f, -9.0f, + 4.0f, 14.0f, 2.0f, -12.0f, + // batch 2 + 5.0f, -18.0f, 4.0f, 15.0f, + -6.0f, -6.0f, 4.0f, 18.0f, + -3.0f, 10.0f, 2.0f, -9.0f, + 4.0f, 14.0f, 2.0f, -12.0f}; + + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +// --------------------- 3D convolution ------------------------------------------ +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_3D_1batch_1channel) +{ + const Strides strides{1, 1, 1}; + const CoordinateDiff padding{0, 0, 0}; + const Strides dilations{1, 1, 1}; + const CoordinateDiff output_padding{0, 0, 0}; + + const Shape inputs_shape{1, 1, 2, 2, 2}; + const std::vector inputs{ + // depth: 1 + 15.0f, 3.0f, + 21.0f, 10.0f, + // depth: 2 + 10.0f, 13.0f, + 11.0f, 17.0f}; + + const Shape filter_shape{1, 1, 3, 3, 3}; + const std::vector filters{ + // depth: 1 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f, + // depth: 2 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f, + // depth: 3 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f}; + + const Shape outputs_shape{1, 1, 4, 4, 4}; + const std::vector outputs{ + // depth: 1 + 15.0f, 33.0f, 51.0f, 9.0f, + 21.0f, 67.0f, 86.0f, 30.0f, + 30.0f, 42.0f, 43.0f, 6.0f, + 42.0f, 41.0f, 52.0f, 20.0f, + // depth: 2 + 25.0f, 66.0f, 107.0f, 48.0f, + 32.0f, 116.0f, 166.0f, 81.0f, + 50.0f, 89.0f, 93.0f, 32.0f, + 64.0f, 86.0f, 91.0f, 54.0f, + // depth: 3 + 25.0f, 66.0f, 107.0f, 48.0f, + 32.0f, 116.0f, 166.0f, 81.0f, + 50.0f, 89.0f, 93.0f, 32.0f, + 64.0f, 86.0f, 91.0f, 54.0f, + // depth: 4 + 10.0f, 33.0f, 56.0f, 39.0f, + 11.0f, 49.0f, 80.0f, 51.0f, + 20.0f, 47.0f, 50.0f, 26.0f, + 22.0f, 45.0f, 39.0f, 34.0f + }; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_3D_1batch_1channel_output_padding) +{ + const Strides strides{1, 1, 1}; + const CoordinateDiff padding{1, 1, 1}; + const Strides dilations{1, 1, 1}; + const CoordinateDiff output_padding{1, 1, 1}; + + const Shape inputs_shape{1, 1, 2, 2, 2}; + const std::vector inputs{ + // depth: 1 + 15.0f, 3.0f, + 21.0f, 10.0f, + // depth: 2 + 10.0f, 13.0f, + 11.0f, 17.0f}; + + const Shape filter_shape{1, 1, 3, 3, 3}; + const std::vector filters{ + // depth: 1 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f, + // depth: 2 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f, + // depth: 3 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f}; + + const Shape outputs_shape{1, 1, 3, 3, 3}; + const std::vector outputs{ + // depth: 1 + 116.0f, 166.0f, 81.0f, + 89.0f, 93.0f, 32.0f, + 86.0f, 91.0f, 54.0f, + // depth: 2 + 116.0f, 166.0f, 81.0f, + 89.0f, 93.0f, 32.0f, + 86.0f, 91.0f, 54.0f, + // depth: 3 + 49.0f, 80.0f, 51.0f, + 47.0f, 50.0f, 26.0f, + 45.0f, 39.0f, 34.0f + }; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_3D_1batch_1channel_padding) +{ + const Strides strides{1, 1, 1}; + const CoordinateDiff padding{1, 1, 1}; + const Strides dilations{1, 1, 1}; + const CoordinateDiff output_padding{0, 0, 0}; + + const Shape inputs_shape{1, 1, 4, 4, 4}; + const std::vector inputs{ + // depth: 1 + 1.0f, 3.0f, 2.0f, 1.0f, + 1.0f, 3.0f, 3.0f, 1.0f, + 2.0f, 1.0f, 1.0f, 3.0f, + 3.0f, 2.0f, 3.0f, 3.0f, + // depth: 2 + 1.0f, 3.0f, 2.0f, 1.0f, + 1.0f, 3.0f, 3.0f, 1.0f, + 2.0f, 1.0f, 1.0f, 3.0f, + 3.0f, 2.0f, 3.0f, 3.0f, + // depth: 3 + 1.0f, 3.0f, 2.0f, 1.0f, + 1.0f, 3.0f, 3.0f, 1.0f, + 2.0f, 1.0f, 1.0f, 3.0f, + 3.0f, 2.0f, 3.0f, 3.0f, + // depth: 4 + 1.0f, 3.0f, 2.0f, 1.0f, + 1.0f, 3.0f, 3.0f, 1.0f, + 2.0f, 1.0f, 1.0f, 3.0f, + 3.0f, 2.0f, 3.0f, 3.0f + }; + + const Shape filter_shape{1, 1, 3, 3, 3}; + const std::vector filters{ + // depth: 1 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f, + // depth: 2 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f, + // depth: 3 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f}; + + const Shape outputs_shape{1, 1, 4, 4, 4}; + const std::vector outputs{ + // depth: 1 + 12.0f, 30.0f, 36.0f, 24.0f, + 26.0f, 42.0f, 42.0f, 30.0f, + 34.0f, 56.0f, 54.0f, 50.0f, + 14.0f, 18.0f, 24.0f, 16.0f, + // depth: 2 + 18.0f, 45.0f, 54.0f, 36.0f, + 39.0f, 63.0f, 63.0f, 45.0f, + 51.0f, 84.0f, 81.0f, 75.0f, + 21.0f, 27.0f, 36.0f, 24.0f, + // depth: 3 + 18.0f, 45.0f, 54.0f, 36.0f, + 39.0f, 63.0f, 63.0f, 45.0f, + 51.0f, 84.0f, 81.0f, 75.0f, + 21.0f, 27.0f, 36.0f, 24.0f, + // depth: 4 + 12.0f, 30.0f, 36.0f, 24.0f, + 26.0f, 42.0f, 42.0f, 30.0f, + 34.0f, 56.0f, 54.0f, 50.0f, + 14.0f, 18.0f, 24.0f, 16.0f}; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_3D_1batch_1channel_stride) +{ + const Strides strides{2, 2, 2}; + const CoordinateDiff padding{0, 0, 0}; + const Strides dilations{1, 1, 1}; + const CoordinateDiff output_padding{0, 0, 0}; + + const Shape inputs_shape{1, 1, 2, 2, 2}; + const std::vector inputs{ + // depth: 1 + 15.0f, 3.0f, + 21.0f, 10.0f, + // depth: 2 + 10.0f, 13.0f, + 11.0f, 17.0f}; + + const Shape filter_shape{1, 1, 3, 3, 3}; + const std::vector filters{ + // depth: 1 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f, + // depth: 2 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f, + // depth: 3 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f}; + + const Shape outputs_shape{1, 1, 5, 5, 5}; + const std::vector outputs{ + // depth: 1 + 15.0f, 30.0f, 48.0f, 6.0f, 9.0f, + 0.0f, 15.0f, 0.0f, 3.0f, 0.0f, + 51.0f, 57.0f, 109.0f, 23.0f, 36.0f, + 0.0f, 21.0f, 0.0f, 10.0f, 0.0f, + 42.0f, 21.0f, 62.0f, 10.0f, 20.0f, + // depth: 2 + 15.0f, 30.0f, 48.0f, 6.0f, 9.0f, + 0.0f, 15.0f, 0.0f, 3.0f, 0.0f, + 51.0f, 57.0f, 109.0f, 23.0f, 36.0f, + 0.0f, 21.0f, 0.0f, 10.0f, 0.0f, + 42.0f, 21.0f, 62.0f, 10.0f, 20.0f, + // depth: 3 + 25.0f, 50.0f, 91.0f, 32.0f, 48.0f, + 0.0f, 25.0f, 0.0f, 16.0f, 0.0f, + 82.0f, 89.0f, 205.0f, 70.0f, 113.0f, + 0.0f, 32.0f, 0.0f, 27.0f, 0.0f, + 64.0f, 32.0f, 118.0f, 27.0f, 54.0f, + // depth: 4 + 10.0f, 20.0f, 43.0f, 26.0f, 39.0f, + 0.0f, 10.0f, 0.0f, 13.0f, 0.0f, + 31.0f, 32.0f, 96.0f, 47.0f, 77.0f, + 0.0f, 11.0f, 0.0f, 17.0f, 0.0f, + 22.0f, 11.0f, 56.0f, 17.0f, 34.0f, + // depth: 5 + 10.0f, 20.0f, 43.0f, 26.0f, 39.0f, + 0.0f, 10.0f, 0.0f, 13.0f, 0.0f, + 31.0f, 32.0f, 96.0f, 47.0f, 77.0f, + 0.0f, 11.0f, 0.0f, 17.0f, 0.0f, + 22.0f, 11.0f, 56.0f, 17.0f, 34.0f + }; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_3D_1batch_1channel_padding_strides_dilation) +{ + const Strides strides{2, 2, 2}; + const CoordinateDiff padding{2, 2, 2}; + const Strides dilations{2, 2, 2}; + const CoordinateDiff output_padding{0, 0, 0}; + + const Shape inputs_shape{1, 1, 4, 4, 4}; + const std::vector inputs{ + // depth: 1 + 1.0f, 3.0f, 2.0f, 1.0f, + 1.0f, 3.0f, 3.0f, 1.0f, + 2.0f, 1.0f, 1.0f, 3.0f, + 3.0f, 2.0f, 3.0f, 3.0f, + // depth: 2 + 1.0f, 3.0f, 2.0f, 1.0f, + 1.0f, 3.0f, 3.0f, 1.0f, + 2.0f, 1.0f, 1.0f, 3.0f, + 3.0f, 2.0f, 3.0f, 3.0f, + // depth: 3 + 1.0f, 3.0f, 2.0f, 1.0f, + 1.0f, 3.0f, 3.0f, 1.0f, + 2.0f, 1.0f, 1.0f, 3.0f, + 3.0f, 2.0f, 3.0f, 3.0f, + // depth: 4 + 1.0f, 3.0f, 2.0f, 1.0f, + 1.0f, 3.0f, 3.0f, 1.0f, + 2.0f, 1.0f, 1.0f, 3.0f, + 3.0f, 2.0f, 3.0f, 3.0f + }; + + const Shape filter_shape{1, 1, 3, 3, 3}; + const std::vector filters{ + // depth: 1 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f, + // depth: 2 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f, + // depth: 3 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f}; + + const Shape outputs_shape{1, 1, 7, 7, 7}; + const std::vector outputs{ + // depth: 1 + 12.0f, 0.0f, 30.0f, 0.0f, 36.0f, 0.0f, 24.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 26.0f, 0.0f, 42.0f, 0.0f, 42.0f, 0.0f, 30.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 34.0f, 0.0f, 56.0f, 0.0f, 54.0f, 0.0f, 50.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 14.0f, 0.0f, 18.0f, 0.0f, 24.0f, 0.0f, 16.0f, + // depth: 2 + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + // depth: 3 + 18.0f, 0.0f, 45.0f, 0.0f, 54.0f, 0.0f, 36.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 39.0f, 0.0f, 63.0f, 0.0f, 63.0f, 0.0f, 45.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 51.0f, 0.0f, 84.0f, 0.0f, 81.0f, 0.0f, 75.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 21.0f, 0.0f, 27.0f, 0.0f, 36.0f, 0.0f, 24.0f, + // depth: 4 + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + // depth: 5 + 18.0f, 0.0f, 45.0f, 0.0f, 54.0f, 0.0f, 36.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 39.0f, 0.0f, 63.0f, 0.0f, 63.0f, 0.0f, 45.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 51.0f, 0.0f, 84.0f, 0.0f, 81.0f, 0.0f, 75.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 21.0f, 0.0f, 27.0f, 0.0f, 36.0f, 0.0f, 24.0f, + // depth: 6 + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + // depth: 7 + 12.0f, 0.0f, 30.0f, 0.0f, 36.0f, 0.0f, 24.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 26.0f, 0.0f, 42.0f, 0.0f, 42.0f, 0.0f, 30.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 34.0f, 0.0f, 56.0f, 0.0f, 54.0f, 0.0f, 50.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 14.0f, 0.0f, 18.0f, 0.0f, 24.0f, 0.0f, 16.0f + }; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_3D_1batch_2channel) +{ + const Strides strides{1, 1, 1}; + const CoordinateDiff padding{0, 0, 0}; + const Strides dilations{1, 1, 1}; + const CoordinateDiff output_padding{0, 0, 0}; + + const Shape inputs_shape{1, 1, 2, 2, 2}; + const std::vector inputs{ + // depth: 1 + 1.0f, 8.0f, + 1.0f, 3.0f, + // depth: 2 + 1.0f, 7.0f, + 3.0f, 8.0f}; + + const Shape filter_shape{1, 2, 3, 3, 3}; + const std::vector filters{ + // -- channel 1 -- + // depth: 1 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f, + // depth: 2 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f, + // depth: 3 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f, + // -- channel 2 -- + // depth: 1 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f, + // depth: 2 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f, + // depth: 3 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f + }; + + const Shape outputs_shape{1, 2, 4, 4, 4}; + const std::vector outputs{ + // -- channel 1 -- + // depth: 1 + 1.0f, 10.0f, 19.0f, 24.0f, + 1.0f, 6.0f, 17.0f, 9.0f, + 2.0f, 18.0f, 13.0f, 16.0f, + 2.0f, 7.0f, 5.0f, 6.0f, + // depth: 2 + 2.0f, 19.0f, 36.0f, 45.0f, + 4.0f, 21.0f, 49.0f, 33.0f, + 4.0f, 36.0f, 30.0f, 30.0f, + 8.0f, 26.0f, 19.0f, 22.0f, + // depth: 3 + 2.0f, 19.0f, 36.0f, 45.0f, + 4.0f, 21.0f, 49.0f, 33.0f, + 4.0f, 36.0f, 30.0f, 30.0f, + 8.0f, 26.0f, 19.0f, 22.0f, + // depth: 4 + 1.0f, 9.0f, 17.0f, 21.0f, + 3.0f, 15.0f, 32.0f, 24.0f, + 2.0f, 18.0f, 17.0f, 14.0f, + 6.0f, 19.0f, 14.0f, 16.0f, + // -- channel 2 -- + // depth: 1 + 1.0f, 10.0f, 19.0f, 24.0f, + 1.0f, 6.0f, 17.0f, 9.0f, + 2.0f, 18.0f, 13.0f, 16.0f, + 2.0f, 7.0f, 5.0f, 6.0f, + // depth: 2 + 2.0f, 19.0f, 36.0f, 45.0f, + 4.0f, 21.0f, 49.0f, 33.0f, + 4.0f, 36.0f, 30.0f, 30.0f, + 8.0f, 26.0f, 19.0f, 22.0f, + // depth: 3 + 2.0f, 19.0f, 36.0f, 45.0f, + 4.0f, 21.0f, 49.0f, 33.0f, + 4.0f, 36.0f, 30.0f, 30.0f, + 8.0f, 26.0f, 19.0f, 22.0f, + // depth: 4 + 1.0f, 9.0f, 17.0f, 21.0f, + 3.0f, 15.0f, 32.0f, 24.0f, + 2.0f, 18.0f, 17.0f, 14.0f, + 6.0f, 19.0f, 14.0f, 16.0f + }; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_3D_1batch_2filter) +{ + const Strides strides{1, 1, 1}; + const CoordinateDiff padding{0, 0, 0}; + const Strides dilations{1, 1, 1}; + const CoordinateDiff output_padding{0, 0, 0}; + + const Shape inputs_shape{1, 2, 2, 2, 2}; + const std::vector inputs{ + // -- in 1 -- + // depth: 1 + 1.0f, 3.0f, + 2.0f, 5.0f, + // depth: 2 + 1.0f, 0.0f, + 3.0f, 6.0f, + // -- in 2 -- + // depth: 1 + 1.0f, 3.0f, + 2.0f, 5.0f, + // depth: 2 + 3.0f, 0.0f, + 1.0f, 8.0f}; + + const Shape filter_shape{2, 1, 3, 3, 3}; + const std::vector filters{ + // -- filter 1 -- + // depth: 1 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f, + // depth: 2 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f, + // depth: 3 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f, + // -- filter 2 -- + // depth: 1 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f, + // depth: 2 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f, + // depth: 3 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f + }; + + const Shape outputs_shape{1, 1, 4, 4, 4}; + const std::vector outputs{ + // depth: 1 + 2.0f, 10.0f, 18.0f, 18.0f, + 4.0f, 20.0f, 38.0f, 30.0f, + 4.0f, 18.0f, 20.0f, 12.0f, + 8.0f, 24.0f, 18.0f, 20.0f, + // depth: 2 + 6.0f, 18.0f, 30.0f, 18.0f, + 8.0f, 46.0f, 78.0f, 72.0f, + 12.0f, 26.0f, 42.0f, 12.0f, + 16.0f, 56.0f, 40.0f, 48.0f, + // depth: 3 + 6.0f, 18.0f, 30.0f, 18.0f, + 8.0f, 46.0f, 78.0f, 72.0f, + 12.0f, 26.0f, 42.0f, 12.0f, + 16.0f, 56.0f, 40.0f, 48.0f, + // depth: 4 + 4.0f, 8.0f, 12.0f, 0.0f, + 4.0f, 26.0f, 40.0f, 42.0f, + 8.0f, 8.0f, 22.0f, 0.0f, + 8.0f, 32.0f, 22.0f, 28.0f + }; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} + +NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_3D_2batch_1channel) +{ + const Strides strides{1, 1, 1}; + const CoordinateDiff padding{0, 0, 0}; + const Strides dilations{1, 1, 1}; + const CoordinateDiff output_padding{0, 0, 0}; + + const Shape inputs_shape{2, 1, 2, 2, 2}; + const std::vector inputs{ + // -- batch 1 -- + // depth: 1 + 1.0f, 3.0f, + 2.0f, 5.0f, + // depth: 2 + 1.0f, 0.0f, + 6.0f, 4.0f, + // -- batch 2 -- + // depth: 1 + 1.0f, 5.0f, + 2.0f, 8.0f, + // depth: 2 + 2.0f, 1.0f, + 0.0f, 5.0f}; + const Shape filter_shape{1, 1, 3, 3, 3}; + const std::vector filters{ + // depth: 1 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f, + // depth: 2 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f, + // depth: 3 + 1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 2.0f, 1.0f, 2.0f}; + + const Shape outputs_shape{2, 1, 4, 4, 4}; + const std::vector outputs{ + // -- batch 1 -- + // depth: 1 + 1.0f, 5.0f, 9.0f, 9.0f, + 2.0f, 10.0f, 19.0f, 15.0f, + 2.0f, 9.0f, 10.0f, 6.0f, + 4.0f, 12.0f, 9.0f, 10.0f, + // depth: 2 + 2.0f, 7.0f, 12.0f, 9.0f, + 8.0f, 27.0f, 45.0f, 27.0f, + 4.0f, 16.0f, 16.0f, 6.0f, + 16.0f, 26.0f, 25.0f, 18.0f, + // depth: 3 + 2.0f, 7.0f, 12.0f, 9.0f, + 8.0f, 27.0f, 45.0f, 27.0f, + 4.0f, 16.0f, 16.0f, 6.0f, + 16.0f, 26.0f, 25.0f, 18.0f, + // depth: 4 + 1.0f, 2.0f, 3.0f, 0.0f, + 6.0f, 17.0f, 26.0f, 12.0f, + 2.0f, 7.0f, 6.0f, 0.0f, + 12.0f, 14.0f, 16.0f, 8.0f, + // -- batch 2 -- + // depth: 1 + 1.0f, 7.0f, 13.0f, 15.0f, + 2.0f, 13.0f, 27.0f, 24.0f, + 2.0f, 13.0f, 15.0f, 10.0f, + 4.0f, 18.0f, 12.0f, 16.0f, + // depth: 2 + 3.0f, 12.0f, 21.0f, 18.0f, + 2.0f, 20.0f, 38.0f, 39.0f, + 6.0f, 17.0f, 25.0f, 12.0f, + 4.0f, 28.0f, 17.0f, 26.0f, + // depth: 3 + 3.0f, 12.0f, 21.0f, 18.0f, + 2.0f, 20.0f, 38.0f, 39.0f, + 6.0f, 17.0f, 25.0f, 12.0f, + 4.0f, 28.0f, 17.0f, 26.0f, + // depth: 4 + 2.0f, 5.0f, 8.0f, 3.0f, + 0.0f, 7.0f, 11.0f, 15.0f, + 4.0f, 4.0f, 10.0f, 2.0f, + 0.0f, 10.0f, 5.0f, 10.0f}; + + ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, + strides, padding, dilations, output_padding); +} diff --git a/ngraph/test/runtime/interpreter/evaluates_map.cpp b/ngraph/test/runtime/interpreter/evaluates_map.cpp index 610101177797fd..4446a4a24347de 100644 --- a/ngraph/test/runtime/interpreter/evaluates_map.cpp +++ b/ngraph/test/runtime/interpreter/evaluates_map.cpp @@ -283,7 +283,8 @@ namespace op->get_dilations(), op->get_pads_begin(), op->get_pads_end(), - op->get_strides()); + op->get_strides(), + op->get_output_padding()); return true; } From 17b5240065304a37fb35c9e8485983d84537a03e Mon Sep 17 00:00:00 2001 From: Mingyu Kim Date: Mon, 14 Jun 2021 22:47:59 +0900 Subject: [PATCH 073/178] Typo fix (#6144) --- inference-engine/samples/benchmark_app/main.cpp | 4 ++-- tools/benchmark/main.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/inference-engine/samples/benchmark_app/main.cpp b/inference-engine/samples/benchmark_app/main.cpp index cd7ddc641dc256..2a5252ba443a85 100644 --- a/inference-engine/samples/benchmark_app/main.cpp +++ b/inference-engine/samples/benchmark_app/main.cpp @@ -277,8 +277,8 @@ int main(int argc, char* argv[]) { setThroughputStreams(); if ((device_name.find("MULTI") != std::string::npos) && (device_name.find("CPU") != std::string::npos)) { - slog::warn << "Turn on GPU trottling. Multi-device execution with " - "the CPU + GPU performs best with GPU trottling hint," + slog::warn << "Turn on GPU throttling. Multi-device execution with " + "the CPU + GPU performs best with GPU throttling hint, " << "which releases another CPU thread (that is otherwise " "used by the GPU driver for active polling)" << slog::endl; diff --git a/tools/benchmark/main.py b/tools/benchmark/main.py index 26ef6246f0c9d5..0cc0a511848d65 100644 --- a/tools/benchmark/main.py +++ b/tools/benchmark/main.py @@ -150,7 +150,7 @@ def set_throughput_streams(): set_throughput_streams() if MULTI_DEVICE_NAME in device_name and CPU_DEVICE_NAME in device_name: - logger.warning("Turn on GPU trottling. Multi-device execution with the CPU + GPU performs best with GPU trottling hint, " + + logger.warning("Turn on GPU throttling. Multi-device execution with the CPU + GPU performs best with GPU throttling hint, " + "which releases another CPU thread (that is otherwise used by the GPU driver for active polling)") config[device]['GPU_PLUGIN_THROTTLE'] = '1' elif device == MYRIAD_DEVICE_NAME: From fb7435a64758d2b1bce56e78e31d99cab9742ba8 Mon Sep 17 00:00:00 2001 From: Andrey Somsikov Date: Mon, 14 Jun 2021 17:00:49 +0300 Subject: [PATCH 074/178] Add cnpy fuzz test and fix issues (#6109) --- tests/fuzz/README.md | 70 +++++++++++++++++++++-- tests/fuzz/fuzz-testhelper/CMakeLists.txt | 2 +- tests/fuzz/fuzz-testhelper/fuzz-utils.cc | 40 +++++++++++++ tests/fuzz/fuzz-testhelper/fuzz-utils.h | 19 ++++++ tests/fuzz/src/CMakeLists.txt | 5 +- tests/fuzz/src/cnpy_npy_load-fuzzer.cc | 21 +++++++ thirdparty/cnpy/cnpy.cpp | 8 ++- thirdparty/cnpy/cnpy.h | 5 ++ 8 files changed, 160 insertions(+), 10 deletions(-) create mode 100644 tests/fuzz/fuzz-testhelper/fuzz-utils.cc create mode 100644 tests/fuzz/fuzz-testhelper/fuzz-utils.h create mode 100644 tests/fuzz/src/cnpy_npy_load-fuzzer.cc diff --git a/tests/fuzz/README.md b/tests/fuzz/README.md index 5f16f9f9998775..19b34e80c1764d 100644 --- a/tests/fuzz/README.md +++ b/tests/fuzz/README.md @@ -18,14 +18,72 @@ To run fuzzing you will need [LLVM](https://apt.llvm.org/) components: - lld (linker) - libc++ -## Reproducing Failure Found by Fuzzing -1. Build `fuzz` test target: +## Building fuzz tests + +1. Build openvino + +Build openvino with options `ENABLE_FUZZING` and `ENABLE_SANITIZER` enabled. It +is recommended to use clang compiler. + +```bash +(\ +mkdir -p build && cd build && \ +CC=clang CXX=clang++ cmake .. -DENABLE_FUZZING=ON -DENABLE_SANITIZER=ON -DTREAT_WARNING_AS_ERROR=OFF && \ +cmake --build . \ +) +``` + +2. Build fuzz tests + +Build fuzz tests with options `ENABLE_FUZZING` and `ENABLE_SANITIZER` enabled. +You should use the same compiler as was used for the openvino build. + +```bash +(\ +mkdir -p tests/fuzz/build && cd tests/fuzz/build && \ +CC=clang CXX=clang++ cmake .. -DENABLE_FUZZING=ON -DENABLE_SANITIZER=ON -DTREAT_WARNING_AS_ERROR=OFF -DInferenceEngine_DIR=$(pwd)/../../../build && \ +cmake --build . \ +) +``` + +## Running fuzz tests + +1. Prepare fuzzing corpus + +Fuzzing engine needs a set of valid inputs to start fuzzing from. Those files +are called a fuzzing corpus. Place valid inputs for the fuzzing test into +directory. + +Intel employees can get the corpus as described here +https://wiki.ith.intel.com/x/2N42bg. + +2. Run fuzzing + ```bash -cmake -DENABLE_TESTS=ON .. && ninja fuzz +./read_network-fuzzer -max_total_time=600 ./read_network-corpus ``` +Consider adding those useful command line options: +- `-jobs=$(nproc)` runs multiple fuzzing jobs in parallel. +- `-rss_limit_mb=0` to ignore out-of-memory issues. + +## Analyzing fuzzing quality -2. Run fuzzing test passing a failure reproducer as a command-line argument: -``` bash -./read_network-fuzzer crash-reproducer +### Explore code coverage + +To build coverage report after fuzz test execution run: + +``` +llvm-profdata merge -sparse *.profraw -o default.profdata && \ +llvm-cov show ./read_network-fuzzer -instr-profile=default.profdata -format=html -output-dir=read_network-coverage ``` + +## Reproducing findings + +Fuzzing run halts on the first issue identified, prints issue details to stdout and save data to reproduce the issue as a file in the current folder. To debug the issue pass reproducer as command line argument to fuzz test + +```bash +./read_network-fuzzer crash-409b5eeed46a8445b7f7b7a2ce5b60a9ad895e3b +``` + +It is recommended but not required to use binaries built for fuzzing to debug the issues. A binaries built without `ENABLE_FUZZING` options can also be used to reproduce and debug the issues. \ No newline at end of file diff --git a/tests/fuzz/fuzz-testhelper/CMakeLists.txt b/tests/fuzz/fuzz-testhelper/CMakeLists.txt index 2c47dbd2d3f86a..52e92798d0c01e 100644 --- a/tests/fuzz/fuzz-testhelper/CMakeLists.txt +++ b/tests/fuzz/fuzz-testhelper/CMakeLists.txt @@ -6,7 +6,7 @@ set(TARGET_NAME fuzz-testhelper) file( GLOB SRC_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/*-testhelper.cc) + ${CMAKE_CURRENT_SOURCE_DIR}/*.cc) add_library( ${TARGET_NAME} STATIC diff --git a/tests/fuzz/fuzz-testhelper/fuzz-utils.cc b/tests/fuzz/fuzz-testhelper/fuzz-utils.cc new file mode 100644 index 00000000000000..16e63e6576dc12 --- /dev/null +++ b/tests/fuzz/fuzz-testhelper/fuzz-utils.cc @@ -0,0 +1,40 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "fuzz-utils.h" +#include +#include +#include +#include +#ifndef _WIN32 +#include +#endif // _WIN32 + +MemoryFile::MemoryFile(const void *data, size_t size) { +#ifdef _WIN32 + throw std::exception("MemoryFile is not implemented for Windows"); +#else // _WIN32 + m_name = strdup("/dev/shm/fuzz-XXXXXX"); + if (!m_name) + throw std::bad_alloc(); + int fd = mkstemp(m_name); + if (size) { + size_t nbytes = write(fd, data, size); + if (nbytes != size) { + free(m_name); + close(fd); + throw std::runtime_error("Failed to write " + std::to_string(size) + + " bytes to " + m_name); + } + } + close(fd); +#endif // _WIN32 +} + +MemoryFile::~MemoryFile() { +#ifndef _WIN32 + unlink(m_name); + free(m_name); +#endif // _WIN32 +} diff --git a/tests/fuzz/fuzz-testhelper/fuzz-utils.h b/tests/fuzz/fuzz-testhelper/fuzz-utils.h new file mode 100644 index 00000000000000..f167587eb65e9d --- /dev/null +++ b/tests/fuzz/fuzz-testhelper/fuzz-utils.h @@ -0,0 +1,19 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +class MemoryFile { + public: + /// Create a memory backed file + MemoryFile(const void *data, size_t size); + /// Delete memory backed file + ~MemoryFile(); + + /// Get path to a file. + const char *name() { return m_name; } + + private: + char *m_name; +}; diff --git a/tests/fuzz/src/CMakeLists.txt b/tests/fuzz/src/CMakeLists.txt index b58a2d018aae5a..b9400d9e7e1d7d 100644 --- a/tests/fuzz/src/CMakeLists.txt +++ b/tests/fuzz/src/CMakeLists.txt @@ -9,11 +9,14 @@ add_custom_target(fuzz) # Fuzz test target name is source file name without extension. FILE(GLOB tests "*-fuzzer.cc") +add_subdirectory(../../../thirdparty/cnpy ${CMAKE_CURRENT_BINARY_DIR}/cnpy) +add_subdirectory(../../../thirdparty/zlib ${CMAKE_CURRENT_BINARY_DIR}/zlib) + foreach(test_source ${tests}) get_filename_component(test_name ${test_source} NAME_WE) add_fuzzer(${test_name} ${test_source}) - target_link_libraries(${test_name} PRIVATE IE::inference_engine) + target_link_libraries(${test_name} PRIVATE IE::inference_engine cnpy zlib) add_dependencies(fuzz ${test_name}) endforeach() diff --git a/tests/fuzz/src/cnpy_npy_load-fuzzer.cc b/tests/fuzz/src/cnpy_npy_load-fuzzer.cc new file mode 100644 index 00000000000000..257dc22908b85d --- /dev/null +++ b/tests/fuzz/src/cnpy_npy_load-fuzzer.cc @@ -0,0 +1,21 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include +#include "fuzz-utils.h" + + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t * inputData, size_t inputSize) { + MemoryFile file(inputData, inputSize); + + try { + cnpy::NpyArray array = cnpy::npy_load(file.name()); + } + catch (const std::exception&) { + return 0; // fail gracefully on expected exceptions + } + + return 0; +} \ No newline at end of file diff --git a/thirdparty/cnpy/cnpy.cpp b/thirdparty/cnpy/cnpy.cpp index 26d0614bca1906..ed277deb5fec23 100644 --- a/thirdparty/cnpy/cnpy.cpp +++ b/thirdparty/cnpy/cnpy.cpp @@ -90,7 +90,9 @@ void cnpy::parse_npy_header(unsigned char* buffer,size_t& word_size, std::vector //byte order code | stands for not applicable. //not sure when this applies except for byte array loc1 = header.find("descr")+9; - bool littleEndian = (header[loc1] == '<' || header[loc1] == '|' ? true : false); + bool littleEndian = false; + if (loc1 < header.size()) + littleEndian = (header[loc1] == '<' || header[loc1] == '|' ? true : false); assert(littleEndian); //char type = header[loc1+1]; @@ -148,7 +150,9 @@ void cnpy::parse_npy_header(FILE* fp, size_t& word_size, std::vector& sh if (loc1 == std::string::npos) throw std::runtime_error("parse_npy_header: failed to find header keyword: 'descr'"); loc1 += 9; - bool littleEndian = (header[loc1] == '<' || header[loc1] == '|' ? true : false); + bool littleEndian = false; + if (loc1 < header.size()) + littleEndian = (header[loc1] == '<' || header[loc1] == '|' ? true : false); assert(littleEndian); //char type = header[loc1+1]; diff --git a/thirdparty/cnpy/cnpy.h b/thirdparty/cnpy/cnpy.h index 750251f480eaf4..e8935e8937e89c 100644 --- a/thirdparty/cnpy/cnpy.h +++ b/thirdparty/cnpy/cnpy.h @@ -27,6 +27,11 @@ namespace cnpy { { num_vals = 1; for(size_t i = 0;i < shape.size();i++) num_vals *= shape[i]; + if (word_size && + num_vals > std::vector().max_size() / word_size) + throw std::length_error("NpyArray of " + std::to_string(num_vals) + + "*" + std::to_string(word_size) + + " elements is too big."); data_holder = std::shared_ptr>( new std::vector(num_vals * word_size)); } From f8759e19821cbb61cf905fbc48e4e511d94939e3 Mon Sep 17 00:00:00 2001 From: Bartosz Lesniewski Date: Tue, 15 Jun 2021 05:55:48 +0200 Subject: [PATCH 075/178] Revise ExtractImagePatches op (#6104) * use ngraph rtti macros * Add attribute count check to visitor tests * Add sslt for ExtractImagePatches * refactoring variable names * remove whitespaces from empty line --- .../single_layer/extractimagepatches.cpp | 43 +++++++++++++++++++ .../include/ngraph/op/extractimagepatches.hpp | 4 +- ngraph/core/src/op/extractimagepatches.cpp | 36 ++++++++-------- .../test/visitors/op/extractimagepatches.cpp | 2 + 4 files changed, 65 insertions(+), 20 deletions(-) create mode 100644 inference-engine/tests/functional/inference_engine/serialization/single_layer/extractimagepatches.cpp diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/extractimagepatches.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/extractimagepatches.cpp new file mode 100644 index 00000000000000..7e48a0ad0e93a7 --- /dev/null +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/extractimagepatches.cpp @@ -0,0 +1,43 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include "shared_test_classes/single_layer/extract_image_patches.hpp" + +using namespace ngraph; +using namespace LayerTestsDefinitions; + +namespace { +TEST_P(ExtractImagePatchesTest, Serialize) { + Serialize(); +} + +const std::vector> inShapes = {{2, 3, 13, 37}}; +const std::vector> kSizes = {{1, 5}, {3, 4}, {3, 1}}; +const std::vector> strides = {{1, 2}, {2, 2}, {2, 1}}; +const std::vector> rates = {{1, 3}, {3, 3}, {3, 1}}; + +const std::vector autoPads = { + ngraph::op::PadType::VALID, ngraph::op::PadType::SAME_UPPER, + ngraph::op::PadType::SAME_LOWER +}; +const std::vector netPrecision = { + InferenceEngine::Precision::I8, InferenceEngine::Precision::BF16, + InferenceEngine::Precision::FP32 +}; + +INSTANTIATE_TEST_CASE_P(smoke_ExtractImagePatchesLayerTest, ExtractImagePatchesTest, + ::testing::Combine(::testing::ValuesIn(inShapes), + ::testing::ValuesIn(kSizes), + ::testing::ValuesIn(strides), + ::testing::ValuesIn(rates), + ::testing::ValuesIn(autoPads), + ::testing::ValuesIn(netPrecision), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + ExtractImagePatchesTest::getTestCaseName); + +} // namespace \ No newline at end of file diff --git a/ngraph/core/include/ngraph/op/extractimagepatches.hpp b/ngraph/core/include/ngraph/op/extractimagepatches.hpp index e9c89813d06497..2cd405618768ec 100644 --- a/ngraph/core/include/ngraph/op/extractimagepatches.hpp +++ b/ngraph/core/include/ngraph/op/extractimagepatches.hpp @@ -15,8 +15,8 @@ namespace ngraph class NGRAPH_API ExtractImagePatches : public Op { public: - static constexpr NodeTypeInfo type_info{"ExtractImagePatches", 3}; - const NodeTypeInfo& get_type_info() const override { return type_info; } + NGRAPH_RTTI_DECLARATION; + ExtractImagePatches() = default; /// \brief Constructs a ExtractImagePatches operation /// diff --git a/ngraph/core/src/op/extractimagepatches.cpp b/ngraph/core/src/op/extractimagepatches.cpp index 0eba4645db0778..eb66bbc384808c 100644 --- a/ngraph/core/src/op/extractimagepatches.cpp +++ b/ngraph/core/src/op/extractimagepatches.cpp @@ -11,7 +11,7 @@ using namespace ngraph; // ExtractImagePatches v3 -constexpr NodeTypeInfo op::v3::ExtractImagePatches::type_info; +NGRAPH_RTTI_DEFINITION(op::v3::ExtractImagePatches, "ExtractImagePatches", 3); op::v3::ExtractImagePatches::ExtractImagePatches(const Output& image, const Shape& sizes, @@ -30,9 +30,9 @@ op::v3::ExtractImagePatches::ExtractImagePatches(const Output& image, void op::v3::ExtractImagePatches::validate_and_infer_types() { NGRAPH_OP_SCOPE(v3_ExtractImagePatches_validate_and_infer_types); - const PartialShape input_Pshape = get_input_partial_shape(0); + const PartialShape input_pshape = get_input_partial_shape(0); - NODE_VALIDATION_CHECK(this, input_Pshape.rank() == 4, "input tensor must be 4D tensor."); + NODE_VALIDATION_CHECK(this, input_pshape.rank() == 4, "input tensor must be 4D tensor."); NODE_VALIDATION_CHECK(this, m_patch_sizes.size() == 2, @@ -60,18 +60,18 @@ void op::v3::ExtractImagePatches::validate_and_infer_types() m_padding == PadType::SAME_UPPER, "Attribute padding should be in either valid or same_lower or same_upper."); - if (input_Pshape[1].is_dynamic() || input_Pshape[2].is_dynamic() || - input_Pshape[3].is_dynamic()) + if (input_pshape[1].is_dynamic() || input_pshape[2].is_dynamic() || + input_pshape[3].is_dynamic()) { set_input_is_relevant_to_shape(0); - auto output_Pshape = PartialShape::dynamic(4); - set_output_type(0, get_input_element_type(0), output_Pshape); + auto output_pshape = PartialShape::dynamic(4); + set_output_type(0, get_input_element_type(0), output_pshape); } else { - int32_t input_depth = input_Pshape[1].get_length(); - int32_t input_rows = input_Pshape[2].get_length(); - int32_t input_cols = input_Pshape[3].get_length(); + int32_t input_depth = input_pshape[1].get_length(); + int32_t input_rows = input_pshape[2].get_length(); + int32_t input_cols = input_pshape[3].get_length(); int32_t out_rows(0); int32_t out_cols(0); @@ -113,26 +113,26 @@ void op::v3::ExtractImagePatches::validate_and_infer_types() ngraph::Dimension::value_type out_cols_cast = static_cast(out_cols); - PartialShape output_Pshape; - if (input_Pshape[0].is_dynamic()) + PartialShape output_pshape; + if (input_pshape[0].is_dynamic()) { - output_Pshape = - PartialShape{input_Pshape[0], out_depth_cast, out_rows_cast, out_cols_cast}; + output_pshape = + PartialShape{input_pshape[0], out_depth_cast, out_rows_cast, out_cols_cast}; } else { ngraph::Dimension::value_type input_batch_cast = - static_cast(input_Pshape[0].get_length()); - output_Pshape = + static_cast(input_pshape[0].get_length()); + output_pshape = PartialShape{input_batch_cast, out_depth_cast, out_rows_cast, out_cols_cast}; } if (input_rows == 0 || input_cols == 0) { - output_Pshape = input_Pshape; + output_pshape = input_pshape; } - set_output_type(0, get_input_element_type(0), output_Pshape); + set_output_type(0, get_input_element_type(0), output_pshape); } } diff --git a/ngraph/test/visitors/op/extractimagepatches.cpp b/ngraph/test/visitors/op/extractimagepatches.cpp index 6d5c99146eac10..a22b0a14b03433 100644 --- a/ngraph/test/visitors/op/extractimagepatches.cpp +++ b/ngraph/test/visitors/op/extractimagepatches.cpp @@ -33,6 +33,8 @@ TEST(attributes, extractimagepatches_op) NodeBuilder builder(extractimagepatches); auto g_extractimagepatches = as_type_ptr(builder.create()); + const auto expected_attr_count = 4; + EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); EXPECT_EQ(g_extractimagepatches->get_sizes(), sizes); EXPECT_EQ(g_extractimagepatches->get_strides(), strides); EXPECT_EQ(g_extractimagepatches->get_rates(), rates); From 8dff04df2882cf04a1ab984a17ae0a59a87e3a83 Mon Sep 17 00:00:00 2001 From: Katarzyna Mitrus Date: Tue, 15 Jun 2021 06:04:06 +0200 Subject: [PATCH 076/178] ShuffleChannels ng op and reference implementation revision (#5764) * Unblock shuffle channels tests from ie test manifest * Add more backend tests * ShiffleChannel reference impl update * Update attr visitor test * Remove unused get_pre_shuffle_shape helper function * Update class descriprion * Add type prop shape tests * Remove NGRAPH_SUPPRESS_DEPRECATED macro * Add single layer tests * Update layer tests * Remove unused header * Move implementation to cpp file --- .../single_layer_tests/shuffle_channels.cpp | 61 ++++++ .../single_layer_tests/shuffle_channels.cpp | 37 ++++ .../include/ngraph/op/shuffle_channels.hpp | 19 +- .../runtime/reference/shuffle_channels.hpp | 27 +++ .../runtime/reference/shuffle_channels.cpp | 60 ++++++ ngraph/core/src/op/shuffle_channels.cpp | 73 +------ ngraph/test/CMakeLists.txt | 1 + ngraph/test/backend/fused_op.in.cpp | 60 ------ ngraph/test/backend/shuffle_channels.in.cpp | 192 ++++++++++++++++++ ngraph/test/runtime/ie/unit_test.manifest | 5 - ngraph/test/type_prop/shuffle_channels.cpp | 112 +++++++++- ngraph/test/visitors/op/shuffle_channels.cpp | 16 +- 12 files changed, 508 insertions(+), 155 deletions(-) create mode 100644 ngraph/core/reference/include/ngraph/runtime/reference/shuffle_channels.hpp create mode 100644 ngraph/core/reference/src/runtime/reference/shuffle_channels.cpp create mode 100644 ngraph/test/backend/shuffle_channels.in.cpp diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/shuffle_channels.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/shuffle_channels.cpp index b36a9e0713b0b0..b338d02efc14bd 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/shuffle_channels.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/shuffle_channels.cpp @@ -36,4 +36,65 @@ INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels4D, ShuffleChannelsLayerTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), ShuffleChannelsLayerTest::getTestCaseName); +// ND support tests +INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels6D, ShuffleChannelsLayerTest, + ::testing::Combine( + ::testing::Values(std::tuple(2, 3)), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(std::vector({24, 6, 12, 18, 30, 36})), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + ShuffleChannelsLayerTest::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels5D, ShuffleChannelsLayerTest, + ::testing::Combine( + ::testing::Values(std::tuple(2, 3)), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(std::vector({6, 12, 18, 30, 36})), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + ShuffleChannelsLayerTest::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels3D, ShuffleChannelsLayerTest, + ::testing::Combine( + ::testing::Values(std::tuple(1, 3)), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(std::vector({18, 30, 36})), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + ShuffleChannelsLayerTest::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels2D, ShuffleChannelsLayerTest, + ::testing::Combine( + ::testing::Values(std::tuple(1, 3)), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(std::vector({18, 30})), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + ShuffleChannelsLayerTest::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels1D, ShuffleChannelsLayerTest, + ::testing::Combine( + ::testing::Values(std::tuple(0, 3)), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(std::vector({30})), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + ShuffleChannelsLayerTest::getTestCaseName); + } // namespace diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/shuffle_channels.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/shuffle_channels.cpp index 6f7bdc1fcf2225..0eb593e16f45e4 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/shuffle_channels.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/shuffle_channels.cpp @@ -35,3 +35,40 @@ const auto testCases = ::testing::Combine(::testing::ValuesIn(shuffleParameters) INSTANTIATE_TEST_CASE_P(smoke_GPU_ShuffleChannels, ShuffleChannelsLayerTest, testCases, ShuffleChannelsLayerTest::getTestCaseName); + +// ND support tests +INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels3D, ShuffleChannelsLayerTest, + ::testing::Combine( + ::testing::Values(std::tuple(1, 3)), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(std::vector({18, 30, 36})), + ::testing::Values(CommonTestUtils::DEVICE_GPU)), + ShuffleChannelsLayerTest::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels2D, ShuffleChannelsLayerTest, + ::testing::Combine( + ::testing::Values(std::tuple(1, 3)), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(std::vector({18, 30})), + ::testing::Values(CommonTestUtils::DEVICE_GPU)), + ShuffleChannelsLayerTest::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels1D, ShuffleChannelsLayerTest, + ::testing::Combine( + ::testing::Values(std::tuple(0, 3)), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(std::vector({30})), + ::testing::Values(CommonTestUtils::DEVICE_GPU)), + ShuffleChannelsLayerTest::getTestCaseName); diff --git a/ngraph/core/include/ngraph/op/shuffle_channels.hpp b/ngraph/core/include/ngraph/op/shuffle_channels.hpp index fd4539b0b3ac35..a09878c574f349 100644 --- a/ngraph/core/include/ngraph/op/shuffle_channels.hpp +++ b/ngraph/core/include/ngraph/op/shuffle_channels.hpp @@ -24,14 +24,12 @@ namespace ngraph ShuffleChannels() = default; /// \brief Constructs a ShuffleChannels node. /// - /// \param data - Node producing the input tensor - /// \param axis - channel dimension index in the data tensor. A negative value means - /// that the index should be calculated from the back of the input - /// data - /// shape. - /// \param group - number of group the channel dimension specified by axis should - /// be - /// split into + /// \param data Node producing the input tensor. + /// \param axis Channel dimension index in the data tensor. + /// A negative value means that the index should be + /// calculated from the back of the input data shape. + /// \param group Number of group the channel dimension should be split into. + /// ShuffleChannels(const Output& data, const int64_t axis = 1, const int64_t group = 1); @@ -51,11 +49,6 @@ namespace ngraph bool has_evaluate() const override; private: - /// \brief Generates a shape required to permute the data - /// - /// \param data_shape - Shape of the original input data tensor - /// \return A 4D tensor to be used to reshape the input data before shuffling it - Shape get_pre_shuffle_shape(const Shape& data_shape) const; bool evaluate_shuffle_channels(const HostTensorVector& outputs, const HostTensorVector& inputs) const; diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/shuffle_channels.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/shuffle_channels.hpp new file mode 100644 index 00000000000000..0d6fe7bed51cd9 --- /dev/null +++ b/ngraph/core/reference/include/ngraph/runtime/reference/shuffle_channels.hpp @@ -0,0 +1,27 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include + +#include "ngraph/shape.hpp" + +namespace ngraph +{ + namespace runtime + { + namespace reference + { + void shuffle_channels(const char* arg, + char* out, + const Shape& data_shape, + size_t elem_size, + const int64_t axis, + const int64_t group); + } // namespace reference + } // namespace runtime +} // namespace ngraph diff --git a/ngraph/core/reference/src/runtime/reference/shuffle_channels.cpp b/ngraph/core/reference/src/runtime/reference/shuffle_channels.cpp new file mode 100644 index 00000000000000..5a12f3787bf0e5 --- /dev/null +++ b/ngraph/core/reference/src/runtime/reference/shuffle_channels.cpp @@ -0,0 +1,60 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "ngraph/runtime/reference/shuffle_channels.hpp" +#include "ngraph/runtime/opt_kernel/reshape.hpp" + +namespace ngraph +{ + namespace runtime + { + namespace reference + { + void shuffle_channels(const char* arg, + char* out, + const Shape& data_shape, + size_t elem_size, + const int64_t axis, + const int64_t group) + { + // Input ND tensor of data_shape (ds) is always considered as 4D tensor with the + // following shape: + // dim 0: ds[0] * ds[1] * ... * ds[axis-1] (or 1 if axis == 0) + // dim 1: group + // dim 2: ds[axis] / group + // dim 3: ds[axis+1] * ds[axis+2] * ... * ds[ds.size()-1] + // (or 1 if axis points to last dimension) + + // The representation of ND tensor as 4D tensor doesn't affect flat data order + Shape reshaped_input_shape(4, 1); + const size_t axis_zb = + axis >= 0 ? axis : axis + data_shape.size(); // Allow negative indices + for (size_t i = 0; i < axis_zb; ++i) + { + // All dimensions before input channels dim axis + reshaped_input_shape[0] *= data_shape[i]; + } + reshaped_input_shape[1] = group; + reshaped_input_shape[2] = data_shape[axis_zb] / group; + for (size_t i = axis_zb + 1; i < data_shape.size(); ++i) + { + // All dimensions after input channels dim axis + reshaped_input_shape[3] *= data_shape[i]; + } + + // The two dimensions in the middle are swapped + const Shape transposed_shape{reshaped_input_shape[0], + reshaped_input_shape[2], + reshaped_input_shape[1], + reshaped_input_shape[3]}; + AxisVector axis_vector{0, 2, 1, 3}; + runtime::opt_kernel::reshape( + arg, out, reshaped_input_shape, axis_vector, transposed_shape, elem_size); + + // Reshaped 4D tensor is interpreted as ND output tensor with original shape of data + // input + } + } // namespace reference + } // namespace runtime +} // namespace ngraph diff --git a/ngraph/core/src/op/shuffle_channels.cpp b/ngraph/core/src/op/shuffle_channels.cpp index 03859b3cb606bd..71683af4030d61 100644 --- a/ngraph/core/src/op/shuffle_channels.cpp +++ b/ngraph/core/src/op/shuffle_channels.cpp @@ -10,14 +10,13 @@ #include "ngraph/op/shuffle_channels.hpp" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/runtime/opt_kernel/reshape.hpp" +#include "ngraph/runtime/reference/shuffle_channels.hpp" #include "ngraph/type/element_type.hpp" #include "ngraph/type/element_type_traits.hpp" using namespace std; using namespace ngraph; -NGRAPH_SUPPRESS_DEPRECATED_START - NGRAPH_RTTI_DEFINITION(op::v0::ShuffleChannels, "ShuffleChannels", 0); op::ShuffleChannels::ShuffleChannels(const Output& data, @@ -87,7 +86,8 @@ void op::ShuffleChannels::validate_and_infer_types() } else { - set_output_type(0, data_type, PartialShape::dynamic()); + const auto shape = get_input_partial_shape(0); + set_output_type(0, data_type, shape); } } @@ -103,76 +103,19 @@ shared_ptr op::ShuffleChannels::clone_with_new_inputs(const OutputVector& return make_shared(new_args.at(0), m_axis, m_group); } -Shape op::ShuffleChannels::get_pre_shuffle_shape(const Shape& data_shape) const -{ - const Shape& ds = data_shape; - - // in general the resulting shape should contain the following values: - // [0]: ds[0] * ds[1] * ... * ds[m_axis-1] (or 1 if m_axis == 0) - // [1]: m_group - // [2]: ds[axis] / m_group - // [3]: ds[axis+1] * ds[axis+2] * ... * ds[ds.size()-1] (or 1 if m_axis points to the last elem - // of ds) - Shape res(4, 1); - - size_t axis_zb = get_zero_based_axis(); - for (size_t i = 0; i < axis_zb; ++i) - { - res[0] *= ds[i]; - } - - res[1] = m_group; - res[2] = ds[axis_zb] / m_group; - - for (size_t i = axis_zb + 1; i < ds.size(); ++i) - { - res[3] *= ds[i]; - } - - return res; -} - bool op::ShuffleChannels::evaluate_shuffle_channels(const HostTensorVector& outputs, const HostTensorVector& inputs) const { const auto arg = inputs[0]->get_data_ptr(); auto out = outputs[0]->get_data_ptr(); - Shape data_shape = inputs[0]->get_shape(); - const Shape& ds = data_shape; - size_t elem_size = inputs[0]->get_element_type().size(); - - Shape reshaped_out_shape(4, 1); - size_t axis_zb = m_axis >= 0 ? m_axis : m_axis + data_shape.size(); - for (size_t i = 0; i < axis_zb; ++i) - { - reshaped_out_shape[0] *= ds[i]; - } + const auto data_shape = inputs[0]->get_shape(); + const size_t elem_size = inputs[0]->get_element_type().size(); - reshaped_out_shape[1] = m_group; - reshaped_out_shape[2] = ds[axis_zb] / m_group; + outputs[0]->set_element_type(inputs[0]->get_element_type()); + outputs[0]->set_shape(data_shape); - for (size_t i = axis_zb + 1; i < ds.size(); ++i) - { - reshaped_out_shape[3] *= ds[i]; - } - - // first reshape from data_shape to reshaped_out_shape is skipped since it doesn't affect - // out - // data - - Shape transpose_axes_order = {0, 2, 1, 3}; - Shape transposed_shape(transpose_axes_order.size()); - - for (size_t i = 0; i < transpose_axes_order.size(); ++i) - { - transposed_shape[i] = data_shape.at(transpose_axes_order.at(i)); - } - auto axis_vector = AxisVector{begin(transpose_axes_order), end(transpose_axes_order)}; - runtime::opt_kernel::reshape( - arg, out, reshaped_out_shape, axis_vector, transposed_shape, elem_size); + runtime::reference::shuffle_channels(arg, out, data_shape, elem_size, m_axis, m_group); - // last reshape from transposed_shape to data_shape is skipped since it doesn't affect out - // data return true; } bool op::ShuffleChannels::evaluate(const HostTensorVector& outputs, diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index c3c5ab80405e23..2f85b09fc606d3 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -442,6 +442,7 @@ set(MULTI_TEST_SRC backend/select.in.cpp backend/selu.in.cpp backend/shape_of.in.cpp + backend/shuffle_channels.in.cpp backend/sigmoid.in.cpp backend/sign.in.cpp backend/sin.in.cpp diff --git a/ngraph/test/backend/fused_op.in.cpp b/ngraph/test/backend/fused_op.in.cpp index 4b6bb15cb5171f..c5e89e84e40b0a 100644 --- a/ngraph/test/backend/fused_op.in.cpp +++ b/ngraph/test/backend/fused_op.in.cpp @@ -570,66 +570,6 @@ NGRAPH_TEST(${BACKEND_NAME}, DISABLED_grn_2d_with_bias) test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, shuffle_channels_simple) -{ - const auto data = make_shared(element::i32, Shape{1, 15, 2, 2}); - auto tested_op = make_shared(data, 1, 5); - auto function = make_shared(tested_op, ParameterVector{data}); - - auto test_case = test::TestCase(function); - - std::vector input_data(60); - std::iota(std::begin(input_data), std::end(input_data), 0); - test_case.add_input(input_data); - - test_case.add_expected_output( - Shape{1, 15, 2, 2}, - {0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51, - 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, - 8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59}); - - test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, shuffle_channels_negative_axis) -{ - // in this test the output is the same as in shuffle_channels_simple but - // the axis value is negative and the C(channels) value is in a different dimension(0) of the - // shape - const auto data = make_shared(element::i32, Shape{15, 2, 1, 2}); - auto tested_op = make_shared(data, -4, 5); - auto function = make_shared(tested_op, ParameterVector{data}); - - auto test_case = test::TestCase(function); - - std::vector input_data(60); - std::iota(std::begin(input_data), std::end(input_data), 0); - test_case.add_input(input_data); - - test_case.add_expected_output( - Shape{15, 2, 1, 2}, - {0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51, - 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, - 8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59}); - - test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, shuffle_channels_float) -{ - const auto data = make_shared(element::f32, Shape{6, 1, 1, 1}); - auto tested_op = make_shared(data, 0, 2); - auto function = make_shared(tested_op, ParameterVector{data}); - - auto test_case = test::TestCase(function); - - test_case.add_input({0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f}); - - test_case.add_expected_output(Shape{6, 1, 1, 1}, {0.0f, 3.0f, 1.0f, 4.0f, 2.0f, 5.0f}); - - test_case.run(); -} - // TODO: Issue: 37534 NGRAPH_TEST(${BACKEND_NAME}, DISABLED_squared_difference) { diff --git a/ngraph/test/backend/shuffle_channels.in.cpp b/ngraph/test/backend/shuffle_channels.in.cpp new file mode 100644 index 00000000000000..16e3afb108c503 --- /dev/null +++ b/ngraph/test/backend/shuffle_channels.in.cpp @@ -0,0 +1,192 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "runtime/backend.hpp" +#include "util/all_close.hpp" +#include "util/all_close_f.hpp" +#include "util/engine/test_engines.hpp" +#include "util/test_case.hpp" +#include "util/test_control.hpp" +#include "util/test_tools.hpp" + +using namespace std; +using namespace ngraph; + +static string s_manifest = "${MANIFEST}"; +using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); + + +NGRAPH_TEST(${BACKEND_NAME}, shuffle_channels_simple) +{ + const auto data = make_shared(element::i32, Shape{1, 15, 2, 2}); + auto tested_op = make_shared(data, 1, 5); + auto function = make_shared(tested_op, ParameterVector{data}); + auto test_case = test::TestCase(function); + + std::vector input_data(60); + std::iota(std::begin(input_data), std::end(input_data), 0); + test_case.add_input(input_data); + + test_case.add_expected_output( + Shape{1, 15, 2, 2}, + {0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51, + 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, + 8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, shuffle_channels_negative_axis) +{ + // In this test the output is the same as in shuffle_channels_simple but + // the axis value is negative and the C(channels) value is in a different dimension(0) of the + // shape + const auto data = make_shared(element::i32, Shape{15, 2, 1, 2}); + auto tested_op = make_shared(data, -4, 5); + auto function = make_shared(tested_op, ParameterVector{data}); + + auto test_case = test::TestCase(function); + + std::vector input_data(60); + std::iota(std::begin(input_data), std::end(input_data), 0); + test_case.add_input(input_data); + + test_case.add_expected_output( + Shape{15, 2, 1, 2}, + {0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51, + 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, + 8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, shuffle_channels_float) +{ + const auto data = make_shared(element::f32, Shape{6, 1, 1, 1}); + auto tested_op = make_shared(data, 0, 2); + auto function = make_shared(tested_op, ParameterVector{data}); + + auto test_case = test::TestCase(function); + + test_case.add_input({0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f}); + test_case.add_expected_output(Shape{6, 1, 1, 1}, {0.0f, 3.0f, 1.0f, 4.0f, 2.0f, 5.0f}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, shuffle_channels_1d) +{ + Shape data_shape{15}; + const auto data = make_shared(element::i32, data_shape); + auto tested_op = make_shared(data, 0, 5); + auto function = make_shared(tested_op, ParameterVector{data}); + auto test_case = test::TestCase(function); + + std::vector input_data{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}; + + test_case.add_input(input_data); + test_case.add_expected_output( + data_shape, + {0, 3, 6, 9, 12, + 1, 4, 7, 10, 13, + 2, 5, 8, 11, 14}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, shuffle_channels_2d) +{ + Shape data_shape{15, 4}; + const auto data = make_shared(element::i32, data_shape); + auto tested_op = make_shared(data, 0, 5); + auto function = make_shared(tested_op, ParameterVector{data}); + auto test_case = test::TestCase(function); + + std::vector input_data{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59}; + + test_case.add_input(input_data); + test_case.add_expected_output( + data_shape, + {0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51, + 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, + 8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, shuffle_channels_3d) +{ + Shape data_shape{15, 2, 2}; + const auto data = make_shared(element::i32, data_shape); + auto tested_op = make_shared(data, 0, 5); + auto function = make_shared(tested_op, ParameterVector{data}); + auto test_case = test::TestCase(function); + + + std::vector input_data{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59}; + + test_case.add_input(input_data); + test_case.add_expected_output( + data_shape, + {0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51, + 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, + 8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, shuffle_channels_5d) +{ + Shape data_shape{2, 2, 15, 2, 2}; + const auto data = make_shared(element::i32, data_shape); + auto tested_op = make_shared(data, 2, 5); + auto function = make_shared(tested_op, ParameterVector{data}); + auto test_case = test::TestCase(function); + + std::vector input_data{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59}; + + test_case.add_input(input_data); + test_case.add_expected_output( + data_shape, + {0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51, + 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, + 8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59, + + 0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51, + 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, + 8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59, + + 0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51, + 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, + 8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59, + + 0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51, + 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, + 8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59}); + + test_case.run(); +} diff --git a/ngraph/test/runtime/ie/unit_test.manifest b/ngraph/test/runtime/ie/unit_test.manifest index 80f2421fb41d8f..e76ac6f2b97d91 100644 --- a/ngraph/test/runtime/ie/unit_test.manifest +++ b/ngraph/test/runtime/ie/unit_test.manifest @@ -752,11 +752,6 @@ gemm_broadcast_axes_1_input_C scale_shift_no_broadcast scale_shift -# Cannot cast ngraph node ShuffleChannels to CNNLayer! -shuffle_channels_simple -shuffle_channels_negative_axis -shuffle_channels_float - # Detected op not belonging to opset1! onnx_model_quant_conv_linear onnx_model_quant_conv_linear_2d diff --git a/ngraph/test/type_prop/shuffle_channels.cpp b/ngraph/test/type_prop/shuffle_channels.cpp index 95cd2fd3cca804..3f18ba5023044f 100644 --- a/ngraph/test/type_prop/shuffle_channels.cpp +++ b/ngraph/test/type_prop/shuffle_channels.cpp @@ -9,12 +9,116 @@ using namespace std; using namespace ngraph; +TEST(type_prop, shuffle_channels_default_4D) +{ + const auto data_input_shape = Shape{3, 9, 4, 5}; + const auto data = make_shared(element::f32, data_input_shape); + const auto shuffle_channels = make_shared(data); + + EXPECT_EQ(shuffle_channels->get_element_type(), element::f32); + EXPECT_EQ(shuffle_channels->get_output_partial_shape(0), data_input_shape); +} + +TEST(type_prop, shuffle_channels_basic_4D) +{ + const auto data_input_shape = Shape{3, 9, 4, 5}; + const auto data = make_shared(element::f32, data_input_shape); + const auto axis = 1; + const auto group = 3; + const auto shuffle_channels = make_shared(data, axis, group); + + EXPECT_EQ(shuffle_channels->get_element_type(), element::f32); + EXPECT_EQ(shuffle_channels->get_output_partial_shape(0), data_input_shape); +} + +TEST(type_prop, shuffle_channels_dynamic_4D) +{ + const auto data_input_shape = PartialShape{Dimension::dynamic(), Dimension(3, 9), 4, Dimension(4, 15)}; + const auto data = make_shared(element::f32, data_input_shape); + const auto axis = 1; + const auto group = 3; + const auto shuffle_channels = make_shared(data, axis, group); + + EXPECT_EQ(shuffle_channels->get_element_type(), element::f32); + EXPECT_EQ(shuffle_channels->get_output_partial_shape(0), data_input_shape); +} + +TEST(type_prop, shuffle_channels_dynamic_fully) +{ + const auto data_input_shape = PartialShape::dynamic(); + const auto data = make_shared(element::f32, data_input_shape); + const auto axis = 1; + const auto group = 3; + const auto shuffle_channels = make_shared(data, axis, group); + + EXPECT_EQ(shuffle_channels->get_element_type(), element::f32); + EXPECT_EQ(shuffle_channels->get_output_partial_shape(0), data_input_shape); +} + +TEST(type_prop, shuffle_channels_ND_bigger) +{ + { + // 5D + const auto data_input_shape = Shape{2, 3, 9, 4, 5}; + const auto data = make_shared(element::f32, data_input_shape); + const auto axis = 2; + const auto group = 3; + const auto shuffle_channels = make_shared(data, axis, group); + + EXPECT_EQ(shuffle_channels->get_output_partial_shape(0), data_input_shape); + } + { + // 6D + const auto data_input_shape = Shape{6, 2, 3, 9, 4, 5}; + const auto data = make_shared(element::f32, data_input_shape); + const auto axis = 3; + const auto group = 3; + const auto shuffle_channels = make_shared(data, axis, group); + + EXPECT_EQ(shuffle_channels->get_output_partial_shape(0), data_input_shape); + } +} + +TEST(type_prop, shuffle_channels_ND_smaller) +{ + { + // 3D + const auto data_input_shape = Shape{5, 4, 9}; + const auto data = make_shared(element::f32, data_input_shape); + const auto axis = 2; + const auto group = 3; + const auto shuffle_channels = make_shared(data, axis, group); + + EXPECT_EQ(shuffle_channels->get_output_partial_shape(0), data_input_shape); + } + { + // 2D + const auto data_input_shape = Shape{9, 20}; + const auto data = make_shared(element::f32, data_input_shape); + const auto axis = 0; + const auto group = 3; + const auto shuffle_channels = make_shared(data, axis, group); + + EXPECT_EQ(shuffle_channels->get_output_partial_shape(0), data_input_shape); + } + { + // 1D + const auto data_input_shape = Shape{9}; + const auto data = make_shared(element::f32, data_input_shape); + const auto axis = 0; + const auto group = 3; + const auto shuffle_channels = make_shared(data, axis, group); + + EXPECT_EQ(shuffle_channels->get_output_partial_shape(0), data_input_shape); + } +} + TEST(type_prop, shuffle_channels_axis_validation) { try { const auto data = make_shared(element::f64, Shape{1, 2, 3, 4}); - const auto shuffle_channels = make_shared(data, -5, 5); + const auto shuffle_channels = make_shared(data, -5, 5); FAIL() << "ShuffleChannels validation did not work. Op node was created with incorrect " "params."; } @@ -30,7 +134,7 @@ TEST(type_prop, shuffle_channels_negative_axis_calculation) { const auto data = make_shared(element::f64, Shape{1, 2, 3, 4}); - const auto shuffle_channels = make_shared(data, -3, 2); + const auto shuffle_channels = make_shared(data, -3, 2); EXPECT_EQ(shuffle_channels->get_zero_based_axis(), 1); } @@ -40,7 +144,7 @@ TEST(type_prop, shuffle_channels_invalid_input_shape) try { const auto data = make_shared(element::f64, Shape{}); - const auto shuffle_channels = make_shared(data, 0, 1); + const auto shuffle_channels = make_shared(data, 0, 1); FAIL() << "ShuffleChannels validation did not work. Op node was created with incorrect " "params."; } @@ -56,7 +160,7 @@ TEST(type_prop, shuffle_channels_invalid_groups_value) try { const auto data = make_shared(element::f64, Shape{1, 2, 3, 15}); - const auto shuffle_channels = make_shared(data, -1, 2); + const auto shuffle_channels = make_shared(data, -1, 2); FAIL() << "ShuffleChannels validation did not work. Op node was created with incorrect " "params."; } diff --git a/ngraph/test/visitors/op/shuffle_channels.cpp b/ngraph/test/visitors/op/shuffle_channels.cpp index ae1a5867779350..b9b36ba6d736f5 100644 --- a/ngraph/test/visitors/op/shuffle_channels.cpp +++ b/ngraph/test/visitors/op/shuffle_channels.cpp @@ -5,28 +5,28 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "ngraph/op/util/attr_types.hpp" #include "ngraph/opsets/opset1.hpp" -#include "ngraph/opsets/opset3.hpp" -#include "ngraph/opsets/opset4.hpp" -#include "ngraph/opsets/opset5.hpp" #include "util/visitor.hpp" using namespace std; using namespace ngraph; using ngraph::test::NodeBuilder; -using ngraph::test::ValueMap; TEST(attributes, shuffle_channels_op) { - NodeBuilder::get_ops().register_factory(); + using ShuffleChannels = opset1::ShuffleChannels; + + NodeBuilder::get_ops().register_factory(); auto data = make_shared(element::i32, Shape{200}); auto axis = 0; auto groups = 2; - auto shuffle_channels = make_shared(data, axis, groups); + auto shuffle_channels = make_shared(data, axis, groups); NodeBuilder builder(shuffle_channels); - auto g_shuffle_channels = as_type_ptr(builder.create()); + auto g_shuffle_channels = as_type_ptr(builder.create()); + + const auto expected_attr_count = 2; + EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); EXPECT_EQ(g_shuffle_channels->get_axis(), shuffle_channels->get_axis()); EXPECT_EQ(g_shuffle_channels->get_group(), shuffle_channels->get_group()); From 6deec50b0b599568b93a8b725e2cef0fa292cd28 Mon Sep 17 00:00:00 2001 From: Patryk Elszkowski Date: Tue, 15 Jun 2021 06:07:18 +0200 Subject: [PATCH 077/178] Reshape OP: add SLT for special `-1` value in new shape dimensions (#5648) * add test for special `-1` value in new shape dimensions * add ticket with next steps --- .../single_layer_tests/reshape.cpp | 75 +++++++++++-------- .../serialization/single_layer/reshape.cpp | 8 +- .../single_layer_tests/reshape.cpp | 28 +++++-- .../single_layer_tests/reshape.cpp | 26 +++++-- .../single_layer/reshape.hpp | 64 +++++++++++----- .../src/single_layer/reshape.cpp | 47 +++++++++++- 6 files changed, 182 insertions(+), 66 deletions(-) diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/reshape.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/reshape.cpp index 85313f410d3606..e0c986ad8b52e5 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/reshape.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/reshape.cpp @@ -2,43 +2,58 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "single_layer_tests/reshape.hpp" + #include -#include "single_layer_tests/reshape.hpp" #include "common_test_utils/test_constants.hpp" using namespace LayerTestsDefinitions; namespace { const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, + InferenceEngine::Precision::FP32, }; -INSTANTIATE_TEST_CASE_P(smoke_ReshapeCheckDynBatch, ReshapeLayerTest, - ::testing::Combine( - ::testing::Values(true), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector({30, 30, 30, 30})), - ::testing::Values(std::vector({30, 30, 30, 30})), - ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), - ::testing::Values(std::map({}))), - ReshapeLayerTest::getTestCaseName); - -INSTANTIATE_TEST_CASE_P(smoke_ReshapeCheck, ReshapeLayerTest, - ::testing::Combine( - ::testing::Values(true), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector({10, 10, 10, 10})), - ::testing::Values(std::vector({10, 0, 100})), - ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), - ::testing::Values(std::map({}))), - ReshapeLayerTest::getTestCaseName); -} // namespace \ No newline at end of file +INSTANTIATE_TEST_CASE_P( + smoke_ReshapeCheckDynBatch, ReshapeLayerTestRevise, + ::testing::Combine( + ::testing::Values(true), ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(std::vector({30, 30, 30, 30})), + ::testing::Values(std::vector({30, 30, 30, 30})), + ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), + ::testing::Values(std::map({}))), + ReshapeLayerTestRevise::getTestCaseName); + +INSTANTIATE_TEST_CASE_P( + smoke_ReshapeCheck, ReshapeLayerTestRevise, + ::testing::Combine( + ::testing::Values(true), ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(std::vector({10, 10, 10, 10})), + ::testing::Values(std::vector({10, 0, 100})), + ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), + ::testing::Values(std::map({}))), + ReshapeLayerTestRevise::getTestCaseName); + +INSTANTIATE_TEST_CASE_P( + smoke_ReshapeCheckNegative, ReshapeLayerTestRevise, + ::testing::Combine( + ::testing::Values(true), ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(std::vector({10, 10, 10, 10})), + ::testing::Values(std::vector({10, -1, 100})), + ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), + ::testing::Values(std::map({}))), + ReshapeLayerTestRevise::getTestCaseName); +} // namespace diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/reshape.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/reshape.cpp index c7b60da690fcd5..9ba9aec704b19d 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/reshape.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/reshape.cpp @@ -10,7 +10,7 @@ using namespace LayerTestsDefinitions; namespace { - TEST_P(ReshapeLayerTest, Serialize) { + TEST_P(ReshapeLayerTestRevise, Serialize) { Serialize(); } @@ -19,7 +19,7 @@ namespace { InferenceEngine::Precision::FP16 }; - INSTANTIATE_TEST_CASE_P(smoke_ReshapeSerialization, ReshapeLayerTest, + INSTANTIATE_TEST_CASE_P(smoke_ReshapeSerialization, ReshapeLayerTestRevise, ::testing::Combine( ::testing::Values(true), ::testing::ValuesIn(netPrecisions), @@ -28,8 +28,8 @@ namespace { ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(std::vector({30, 30, 30, 30})), - ::testing::Values(std::vector({30, 30, 30, 30})), + ::testing::Values(std::vector({30, 30, 30, 30})), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::Values(std::map({{CONFIG_KEY(DYN_BATCH_ENABLED), CONFIG_VALUE(YES)}}))), - ReshapeLayerTest::getTestCaseName); + ReshapeLayerTestRevise::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reshape.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reshape.cpp index 0bdef6426580a1..28419ec971fca7 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reshape.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reshape.cpp @@ -15,7 +15,7 @@ const std::vector netPrecisions = { InferenceEngine::Precision::FP16 }; -INSTANTIATE_TEST_CASE_P(smoke_ReshapeCheckDynBatch, ReshapeLayerTest, +INSTANTIATE_TEST_CASE_P(smoke_ReshapeCheckDynBatch, ReshapeLayerTestRevise, ::testing::Combine( ::testing::Values(true), ::testing::ValuesIn(netPrecisions), @@ -24,12 +24,26 @@ INSTANTIATE_TEST_CASE_P(smoke_ReshapeCheckDynBatch, ReshapeLayerTest, ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(std::vector({30, 30, 30, 30})), - ::testing::Values(std::vector({30, 30, 30, 30})), + ::testing::Values(std::vector({30, 30, 30, 30})), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::Values(std::map({{CONFIG_KEY(DYN_BATCH_ENABLED), CONFIG_VALUE(YES)}}))), - ReshapeLayerTest::getTestCaseName); + ReshapeLayerTestRevise::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_ReshapeCheck, ReshapeLayerTestRevise, + ::testing::Combine( + ::testing::Values(true), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(std::vector({10, 10, 10, 10})), + ::testing::Values(std::vector({10, 0, 100})), + ::testing::Values(CommonTestUtils::DEVICE_CPU), + ::testing::Values(std::map({}))), + ReshapeLayerTestRevise::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ReshapeCheck, ReshapeLayerTest, +INSTANTIATE_TEST_CASE_P(smoke_ReshapeCheckNegative, ReshapeLayerTestRevise, ::testing::Combine( ::testing::Values(true), ::testing::ValuesIn(netPrecisions), @@ -38,8 +52,8 @@ INSTANTIATE_TEST_CASE_P(smoke_ReshapeCheck, ReshapeLayerTest, ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(std::vector({10, 10, 10, 10})), - ::testing::Values(std::vector({10, 0, 100})), + ::testing::Values(std::vector({10, -1, 100})), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::Values(std::map({}))), - ReshapeLayerTest::getTestCaseName); -} // namespace \ No newline at end of file + ReshapeLayerTestRevise::getTestCaseName); +} // namespace diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/reshape.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/reshape.cpp index a304c345776a06..84d30807341593 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/reshape.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/reshape.cpp @@ -16,7 +16,7 @@ const std::vector netPrecisions = { }; //TODO: Issue : - 28981 -INSTANTIATE_TEST_CASE_P(DISABLE_smoke_ReshapeCheckDynBatch, ReshapeLayerTest, +INSTANTIATE_TEST_CASE_P(DISABLE_smoke_ReshapeCheckDynBatch, ReshapeLayerTestRevise, ::testing::Combine( ::testing::Values(true), ::testing::ValuesIn(netPrecisions), @@ -25,12 +25,12 @@ INSTANTIATE_TEST_CASE_P(DISABLE_smoke_ReshapeCheckDynBatch, ReshapeLayerTest, ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(std::vector({1, 16, 16, 16})), - ::testing::Values(std::vector({1, 0, 256})), + ::testing::Values(std::vector({1, 0, 256})), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::Values(std::map({{CONFIG_KEY(DYN_BATCH_ENABLED), CONFIG_VALUE(YES)}}))), - ReshapeLayerTest::getTestCaseName); + ReshapeLayerTestRevise::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ReshapeCheck, ReshapeLayerTest, +INSTANTIATE_TEST_CASE_P(smoke_ReshapeCheck, ReshapeLayerTestRevise, ::testing::Combine( ::testing::Values(true), ::testing::ValuesIn(netPrecisions), @@ -39,8 +39,22 @@ INSTANTIATE_TEST_CASE_P(smoke_ReshapeCheck, ReshapeLayerTest, ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(std::vector({10, 10, 10, 10})), - ::testing::Values(std::vector({10, 0, 100})), + ::testing::Values(std::vector({10, 0, 100})), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::Values(std::map({}))), - ReshapeLayerTest::getTestCaseName); + ReshapeLayerTestRevise::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_ReshapeCheckNegative, ReshapeLayerTestRevise, + ::testing::Combine( + ::testing::Values(true), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(std::vector({10, 10, 10, 10})), + ::testing::Values(std::vector({10, -1, 100})), + ::testing::Values(CommonTestUtils::DEVICE_GPU), + ::testing::Values(std::map({}))), + ReshapeLayerTestRevise::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/reshape.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/reshape.hpp index d0acf57931dbfa..9ddeeed509aa48 100644 --- a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/reshape.hpp +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/reshape.hpp @@ -4,36 +4,66 @@ #pragma once -#include +#include #include +#include #include -#include + #include "ngraph_functions/builders.hpp" #include "ngraph_functions/utils/ngraph_helpers.hpp" - #include "shared_test_classes/base/layer_test_utils.hpp" namespace LayerTestsDefinitions { -typedef std::tuple< - bool, // SpecialZero - InferenceEngine::Precision, // Network precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - std::vector, // Input shapes - std::vector, // OutForm Shapes - std::string, // Device name - std::map // Config -> reshapeParams; +//TODO: remove this alias when ticket 57975 is done - ticket: 57976 +typedef std::tuple, // Input shapes + std::vector, // OutForm Shapes + std::string, // Device name + std::map // Config + > + reshapeParams; + +//TODO: remove this class when ticket 57975 is done - ticket: 57976 class ReshapeLayerTest : public testing::WithParamInterface, virtual public LayerTestsUtils::LayerTestsCommon { public: - static std::string getTestCaseName(testing::TestParamInfo obj); + static std::string getTestCaseName( + testing::TestParamInfo obj); protected: void SetUp() override; }; -} // namespace LayerTestsDefinitions \ No newline at end of file + +//TODO: use this alias in all dependencies - ticket: 57975 +typedef std::tuple, // Input shapes + std::vector, // OutForm Shapes + std::string, // Device name + std::map // Config + > + reshapeParamsRevise; + +//TODO: use this class in all dependencies - ticket: 57975 +class ReshapeLayerTestRevise + : public testing::WithParamInterface, + virtual public LayerTestsUtils::LayerTestsCommon { +public: + static std::string getTestCaseName( + testing::TestParamInfo obj); + +protected: + void SetUp() override; +}; +} // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/shared_test_classes/src/single_layer/reshape.cpp b/inference-engine/tests/functional/shared_test_classes/src/single_layer/reshape.cpp index 3063b01b27b1ea..708c40ebbe058d 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/single_layer/reshape.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/single_layer/reshape.cpp @@ -5,7 +5,7 @@ #include "shared_test_classes/single_layer/reshape.hpp" namespace LayerTestsDefinitions { - std::string ReshapeLayerTest::getTestCaseName(testing::TestParamInfo obj) { +std::string ReshapeLayerTest::getTestCaseName(testing::TestParamInfo obj) { InferenceEngine::Precision netPrecision; InferenceEngine::Precision inPrc, outPrc; InferenceEngine::Layout inLayout, outLayout; @@ -44,4 +44,47 @@ void ReshapeLayerTest::SetUp() { ngraph::ResultVector results{std::make_shared(reshape)}; function = std::make_shared(results, paramsIn, "Reshape"); } -} // namespace LayerTestsDefinitions \ No newline at end of file + +std::string ReshapeLayerTestRevise::getTestCaseName(testing::TestParamInfo obj) { + InferenceEngine::Precision netPrecision; + InferenceEngine::Precision inPrc, outPrc; + InferenceEngine::Layout inLayout, outLayout; + InferenceEngine::SizeVector inputShapes; + std::vector outFormShapes; + std::string targetDevice; + std::map config; + bool specialZero; + std::tie(specialZero, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, outFormShapes, targetDevice, config) = obj.param; + std::ostringstream result; + result << "IS=" << CommonTestUtils::vec2str(inputShapes) << "_"; + result << "OS=" << CommonTestUtils::vec2str(outFormShapes) << "_"; + result << "specialZero=" << specialZero << "_"; + result << "netPRC=" << netPrecision.name() << "_"; + result << "inPRC=" << inPrc.name() << "_"; + result << "outPRC=" << outPrc.name() << "_"; + result << "inL=" << inLayout << "_"; + result << "outL=" << outLayout << "_"; + result << "trgDev=" << targetDevice; + return result.str(); +} + +void ReshapeLayerTestRevise::SetUp() { + InferenceEngine::SizeVector inputShapes; + std::vector outFormShapes; + bool specialZero; + InferenceEngine::Precision netPrecision; + std::tie(specialZero, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, outFormShapes, targetDevice, configuration) = + this->GetParam(); + auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); + auto paramsIn = ngraph::builder::makeParams(ngPrc, {inputShapes}); + auto paramIn = ngraph::helpers::convert2OutputVector( + ngraph::helpers::castOps2Nodes(paramsIn)); + auto constNode = std::make_shared( + ngraph::element::Type_t::i64, ngraph::Shape{outFormShapes.size()}, outFormShapes); + auto reshape = std::dynamic_pointer_cast( + std::make_shared(paramIn[0], constNode, specialZero)); + ngraph::ResultVector results{std::make_shared(reshape)}; + function = std::make_shared(results, paramsIn, "Reshape"); +} + +} // namespace LayerTestsDefinitions From 772465da1ebd72f95298bf876e649e5057f4329d Mon Sep 17 00:00:00 2001 From: Szymon Durawa Date: Tue, 15 Jun 2021 06:08:10 +0200 Subject: [PATCH 078/178] Add output shape and output padding for Convolution Backprop SLTs. (#5576) * Create output shape for Convoution Backprop SLTs. * Add output_padding attribute to SLT scope. * Introduce SLT for Serializaton. * Introduce new test layer class ConvolutionBackpropLayerTest which contains output_padding attribute and output_shape input. Old one is deprecated, but cannot be removed due to kmb plugin dependency. * Add ConvolutionBackpropDataLayerTest into TEST_P. * ConvolutionBackpropDataLayerTest left as legacy class used by kmb_plugin. * Remove redundant variables. * Switch to new API for gpu SLTs. * Remove legacy API. * Introduce legacy API to match dependency for KMB and ARM plugins. * Create test cases for output_padding attribute. * Fixing smoke_Deconv tests. --- .../single_layer/convolution_backprop.cpp | 58 ++++++ .../convolution_backprop_data.cpp | 168 ++++++++++++++++-- .../convolution_backprop_data.cpp | 58 ++++-- .../convolution_backprop_data.cpp | 136 ++++++++++++-- .../convolution_backprop.hpp | 15 ++ .../convolution_backprop_data.hpp | 1 + .../single_layer/convolution_backprop.hpp | 49 +++++ .../convolution_backprop_data.hpp | 2 + .../src/single_layer/convolution_backprop.cpp | 71 ++++++++ .../convolution_backprop_data.cpp | 4 +- .../include/ngraph_functions/builders.hpp | 17 ++ .../src/convolution_backprop_data.cpp | 45 ++++- 12 files changed, 579 insertions(+), 45 deletions(-) create mode 100644 inference-engine/tests/functional/inference_engine/serialization/single_layer/convolution_backprop.cpp create mode 100644 inference-engine/tests/functional/plugin/shared/include/single_layer_tests/convolution_backprop.hpp create mode 100644 inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convolution_backprop.hpp create mode 100644 inference-engine/tests/functional/shared_test_classes/src/single_layer/convolution_backprop.cpp diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/convolution_backprop.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/convolution_backprop.cpp new file mode 100644 index 00000000000000..2f9383ad914475 --- /dev/null +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/convolution_backprop.cpp @@ -0,0 +1,58 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "shared_test_classes/single_layer/convolution_backprop.hpp" + +using namespace LayerTestsDefinitions; + +namespace { + +TEST_P(ConvolutionBackpropLayerTest, Serialize) { + Serialize(); +} + +const std::vector precisions = { + InferenceEngine::Precision::FP64, InferenceEngine::Precision::FP32, + InferenceEngine::Precision::FP16, InferenceEngine::Precision::BF16, + InferenceEngine::Precision::I8, InferenceEngine::Precision::I16, + InferenceEngine::Precision::I32, InferenceEngine::Precision::I64, + InferenceEngine::Precision::U8, InferenceEngine::Precision::U16, + InferenceEngine::Precision::U32, InferenceEngine::Precision::U64, +}; +const std::vector> kernels = {{3, 3}}; +const std::vector> strides = {{1, 1}}; +const std::vector> padBegins = {{0, 0}}; +const std::vector> padEnds = {{0, 0}}; +const std::vector> dilations = {{1, 1}}; +const std::vector> outPadding = {{}, {1, 1}}; +const std::vector numOutChannels = {8, 16}; +const std::vector pad_types = { + ngraph::op::PadType::EXPLICIT, ngraph::op::PadType::VALID, + ngraph::op::PadType::SAME_LOWER, ngraph::op::PadType::SAME_UPPER}; +const auto inputShapes = std::vector({1, 16, 20, 20}); +const std::vector> emptyOutputShape = {{}}; + +const auto convolutionBackpropData2DParams = ::testing::Combine( + ::testing::ValuesIn(kernels), ::testing::ValuesIn(strides), + ::testing::ValuesIn(padBegins), ::testing::ValuesIn(padEnds), + ::testing::ValuesIn(dilations), ::testing::ValuesIn(numOutChannels), + ::testing::ValuesIn(pad_types), ::testing::ValuesIn(outPadding)); + +INSTANTIATE_TEST_CASE_P( + smoke_convolutionBackpropData2D_Serialization, ConvolutionBackpropLayerTest, + ::testing::Combine( + convolutionBackpropData2DParams, + ::testing::ValuesIn(precisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(inputShapes), + ::testing::ValuesIn(emptyOutputShape), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + ConvolutionBackpropLayerTest::getTestCaseName); + +} // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convolution_backprop_data.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convolution_backprop_data.cpp index a8b4c01497fb81..1a5f3885c9364b 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convolution_backprop_data.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convolution_backprop_data.cpp @@ -4,7 +4,7 @@ #include -#include "single_layer_tests/convolution_backprop_data.hpp" +#include "single_layer_tests/convolution_backprop.hpp" #include "common_test_utils/test_constants.hpp" using namespace LayerTestsDefinitions; @@ -17,6 +17,8 @@ const std::vector netPrecisions = { }; const std::vector numOutChannels = {1, 5, 16}; +const std::vector> emptyOutputShape = {{}}; +const std::vector> emptyOutputPadding = {{}}; /* ============= 2D ConvolutionBackpropData ============= */ const std::vector> inputShapes2D = {{1, 3, 30, 30}, @@ -35,7 +37,8 @@ const auto conv2DParams_ExplicitPadding = ::testing::Combine( ::testing::ValuesIn(padEnds2D), ::testing::ValuesIn(dilations2D), ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::EXPLICIT) + ::testing::Values(ngraph::op::PadType::EXPLICIT), + ::testing::ValuesIn(emptyOutputPadding) ); const auto conv2DParams_AutoPadValid = ::testing::Combine( ::testing::ValuesIn(kernels2D), @@ -44,10 +47,11 @@ const auto conv2DParams_AutoPadValid = ::testing::Combine( ::testing::Values(std::vector({0, 0})), ::testing::ValuesIn(dilations2D), ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::VALID) + ::testing::Values(ngraph::op::PadType::VALID), + ::testing::ValuesIn(emptyOutputPadding) ); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_ExplicitPadding, ConvolutionBackpropDataLayerTest, +INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_ExplicitPadding, ConvolutionBackpropLayerTest, ::testing::Combine( conv2DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -56,10 +60,11 @@ INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_ExplicitPadding, Convolu ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::ValuesIn(inputShapes2D), + ::testing::ValuesIn(emptyOutputShape), ::testing::Values(CommonTestUtils::DEVICE_CPU)), - ConvolutionBackpropDataLayerTest::getTestCaseName); + ConvolutionBackpropLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_AutoPadValid, ConvolutionBackpropDataLayerTest, +INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_AutoPadValid, ConvolutionBackpropLayerTest, ::testing::Combine( conv2DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), @@ -68,8 +73,75 @@ INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_AutoPadValid, Convolutio ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::ValuesIn(inputShapes2D), + ::testing::ValuesIn(emptyOutputShape), ::testing::Values(CommonTestUtils::DEVICE_CPU)), - ConvolutionBackpropDataLayerTest::getTestCaseName); + ConvolutionBackpropLayerTest::getTestCaseName); + +const std::vector> inputShape2D = {{1, 3, 9, 12}}; +const std::vector> outputShapes2D = {{6, 6}, {4, 9}}; + +INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_OutputShapeDefined, ConvolutionBackpropLayerTest, + ::testing::Combine( + conv2DParams_AutoPadValid, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::ValuesIn(inputShape2D), + ::testing::ValuesIn(outputShapes2D), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + ConvolutionBackpropLayerTest::getTestCaseName); + +const std::vector> outputPadding2D = {{1, 1}, {2, 2}}; +const std::vector> testStrides2D = {{3, 3}}; + +const auto conv2DParams_ExplicitPadding_output_padding = ::testing::Combine( + ::testing::ValuesIn(kernels2D), + ::testing::ValuesIn(testStrides2D), + ::testing::ValuesIn(padBegins2D), + ::testing::ValuesIn(padEnds2D), + ::testing::ValuesIn(dilations2D), + ::testing::ValuesIn(numOutChannels), + ::testing::Values(ngraph::op::PadType::EXPLICIT), + ::testing::ValuesIn(outputPadding2D) +); +const auto conv2DParams_AutoPadValid_output_padding = ::testing::Combine( + ::testing::ValuesIn(kernels2D), + ::testing::ValuesIn(testStrides2D), + ::testing::Values(std::vector({0, 0})), + ::testing::Values(std::vector({0, 0})), + ::testing::ValuesIn(dilations2D), + ::testing::ValuesIn(numOutChannels), + ::testing::Values(ngraph::op::PadType::VALID), + ::testing::ValuesIn(outputPadding2D) +); + +INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_ExplicitPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, + ::testing::Combine( + conv2DParams_AutoPadValid_output_padding, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::ValuesIn(inputShapes2D), + ::testing::ValuesIn(emptyOutputShape), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + ConvolutionBackpropLayerTest::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_AutoPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, + ::testing::Combine( + conv2DParams_ExplicitPadding_output_padding, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::ValuesIn(inputShapes2D), + ::testing::ValuesIn(emptyOutputShape), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + ConvolutionBackpropLayerTest::getTestCaseName); /* ============= 3D ConvolutionBackpropData ============= */ const std::vector> inputShapes3D = {{1, 3, 10, 10, 10}, @@ -88,7 +160,8 @@ const auto conv3DParams_ExplicitPadding = ::testing::Combine( ::testing::ValuesIn(padEnds3D), ::testing::ValuesIn(dilations3D), ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::EXPLICIT) + ::testing::Values(ngraph::op::PadType::EXPLICIT), + ::testing::ValuesIn(emptyOutputPadding) ); const auto conv3DParams_AutoPadValid = ::testing::Combine( ::testing::ValuesIn(kernels3D), @@ -97,10 +170,11 @@ const auto conv3DParams_AutoPadValid = ::testing::Combine( ::testing::Values(std::vector({0, 0, 0})), ::testing::ValuesIn(dilations3D), ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::VALID) + ::testing::Values(ngraph::op::PadType::VALID), + ::testing::ValuesIn(emptyOutputPadding) ); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_ExplicitPadding, ConvolutionBackpropDataLayerTest, +INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_ExplicitPadding, ConvolutionBackpropLayerTest, ::testing::Combine( conv3DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -109,10 +183,11 @@ INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_ExplicitPadding, Convolu ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::ValuesIn(inputShapes3D), + ::testing::ValuesIn(emptyOutputShape), ::testing::Values(CommonTestUtils::DEVICE_CPU)), - ConvolutionBackpropDataLayerTest::getTestCaseName); + ConvolutionBackpropLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_AutoPadValid, ConvolutionBackpropDataLayerTest, +INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_AutoPadValid, ConvolutionBackpropLayerTest, ::testing::Combine( conv3DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), @@ -121,7 +196,74 @@ INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_AutoPadValid, Convolutio ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::ValuesIn(inputShapes3D), + ::testing::ValuesIn(emptyOutputShape), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + ConvolutionBackpropLayerTest::getTestCaseName); + +const std::vector> inputShape3D = {{1, 3, 10, 10, 10}}; +const std::vector> outputShapes3D = {{8, 8, 8}, {10, 10, 10}}; + +INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_OutputShapeDefined, ConvolutionBackpropLayerTest, + ::testing::Combine( + conv3DParams_AutoPadValid, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::ValuesIn(inputShape3D), + ::testing::ValuesIn(outputShapes3D), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + ConvolutionBackpropLayerTest::getTestCaseName); + +const std::vector> outputPadding3D = {{1, 1, 1}, {2, 2, 2}}; +const std::vector> testStrides3D = {{3, 3, 3}}; + +const auto conv3DParams_ExplicitPadding_output_padding = ::testing::Combine( + ::testing::ValuesIn(kernels3D), + ::testing::ValuesIn(testStrides3D), + ::testing::ValuesIn(padBegins3D), + ::testing::ValuesIn(padEnds3D), + ::testing::ValuesIn(dilations3D), + ::testing::ValuesIn(numOutChannels), + ::testing::Values(ngraph::op::PadType::EXPLICIT), + ::testing::ValuesIn(outputPadding3D) +); +const auto conv3DParams_AutoPadValid_output_padding = ::testing::Combine( + ::testing::ValuesIn(kernels3D), + ::testing::ValuesIn(testStrides3D), + ::testing::Values(std::vector({0, 0, 0})), + ::testing::Values(std::vector({0, 0, 0})), + ::testing::ValuesIn(dilations3D), + ::testing::ValuesIn(numOutChannels), + ::testing::Values(ngraph::op::PadType::VALID), + ::testing::ValuesIn(outputPadding3D) +); + +INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_ExplicitPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, + ::testing::Combine( + conv3DParams_AutoPadValid_output_padding, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::ValuesIn(inputShapes3D), + ::testing::ValuesIn(emptyOutputShape), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + ConvolutionBackpropLayerTest::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_AutoPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, + ::testing::Combine( + conv3DParams_ExplicitPadding_output_padding, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::ValuesIn(inputShapes3D), + ::testing::ValuesIn(emptyOutputShape), ::testing::Values(CommonTestUtils::DEVICE_CPU)), - ConvolutionBackpropDataLayerTest::getTestCaseName); + ConvolutionBackpropLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/convolution_backprop_data.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/convolution_backprop_data.cpp index 5fdcbef5747dad..f1d144f666ebf9 100755 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/convolution_backprop_data.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/convolution_backprop_data.cpp @@ -8,18 +8,18 @@ #include "shared_test_classes/base/layer_test_utils.hpp" #include "ngraph_functions/utils/ngraph_helpers.hpp" #include "ngraph_functions/builders.hpp" -#include +#include using namespace InferenceEngine; using namespace CPUTestUtils; namespace CPULayerTestsDefinitions { -using LayerTestsDefinitions::convBackpropDataSpecificParams; -using LayerTestsDefinitions::convBackpropDataLayerTestParamsSet; +using LayerTestsDefinitions::convBackpropSpecificParams; +using LayerTestsDefinitions::convBackpropLayerTestParamsSet; typedef std::tuple< - convBackpropDataLayerTestParamsSet, + convBackpropLayerTestParamsSet, CPUSpecificParams, fusingSpecificParams, std::map > deconvLayerCPUTestParamsSet; @@ -28,14 +28,14 @@ class DeconvolutionLayerCPUTest : public testing::WithParamInterface obj) { - convBackpropDataLayerTestParamsSet basicParamsSet; + convBackpropLayerTestParamsSet basicParamsSet; CPUSpecificParams cpuParams; fusingSpecificParams fusingParams; std::map additionalConfig; std::tie(basicParamsSet, cpuParams, fusingParams, additionalConfig) = obj.param; std::ostringstream result; - result << LayerTestsDefinitions::ConvolutionBackpropDataLayerTest::getTestCaseName(testing::TestParamInfo( + result << LayerTestsDefinitions::ConvolutionBackpropLayerTest::getTestCaseName(testing::TestParamInfo( basicParamsSet, 0)); result << CPUTestsBase::getTestCaseName(cpuParams); @@ -52,7 +52,7 @@ class DeconvolutionLayerCPUTest : public testing::WithParamInterface additionalConfig; @@ -63,10 +63,11 @@ class DeconvolutionLayerCPUTest : public testing::WithParamInterface inputShape; + std::vector outputShape; auto netPrecision = InferenceEngine::Precision::UNSPECIFIED; - std::tie(convParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetDevice) = basicParamsSet; + std::tie(convParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, outputShape, targetDevice) = basicParamsSet; if (inPrc == Precision::UNSPECIFIED) { selectedType += std::string("_") + Precision(Precision::FP32).name(); @@ -76,16 +77,22 @@ class DeconvolutionLayerCPUTest : public testing::WithParamInterface padBegin, padEnd; + std::vector padBegin, padEnd, outPadding; size_t convOutChannels; - std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, padType) = convParams; + std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, padType, outPadding) = convParams; auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); auto inputParams = ngraph::builder::makeParams(ngraph::element::f32, { inputShape }); auto paramOuts = ngraph::helpers::convert2OutputVector(ngraph::helpers::castOps2Nodes(inputParams)); auto deconvolutionNode = ngraph::builder::makeConvolutionBackpropData(paramOuts.front(), ngPrc, kernel, stride, padBegin, - padEnd, dilation, padType, convOutChannels); + padEnd, dilation, padType, convOutChannels, false, outPadding); + + if (!outputShape.empty()) { + auto outShape = ngraph::opset3::Constant::create(ngraph::element::i64, {outputShape.size()}, outputShape); + deconvolutionNode = ngraph::builder::makeConvolutionBackpropData(paramOuts.front(), outShape, ngPrc, kernel, stride, padBegin, + padEnd, dilation, padType, convOutChannels); + } function = makeNgraphFunction(ngPrc, inputParams, deconvolutionNode, "convolutionBackpropData"); } @@ -108,6 +115,8 @@ const std::vector fusingParamsSet{ const std::map cpuEmptyPluginConfig; const std::map cpuBF16PluginConfig = { { PluginConfigParams::KEY_ENFORCE_BF16, PluginConfigParams::YES } }; +const std::vector emptyOutputShape = { {} }; +const std::vector> emptyOutputPadding = { {} }; /* ============= Deconvolution params (planar layout) ============= */ const SizeVector numOutChannels_Planar = { 6 }; @@ -139,7 +148,8 @@ const auto convParams_ExplicitPadding_Planar_2D = ::testing::Combine( ::testing::ValuesIn(padEnds2d), ::testing::ValuesIn(dilations2d), ::testing::ValuesIn(numOutChannels_Planar), - ::testing::Values(ngraph::op::PadType::EXPLICIT) + ::testing::Values(ngraph::op::PadType::EXPLICIT), + ::testing::ValuesIn(emptyOutputPadding) ); INSTANTIATE_TEST_CASE_P(smoke_Deconv_2D_Planar_FP32, DeconvolutionLayerCPUTest, @@ -152,6 +162,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Deconv_2D_Planar_FP32, DeconvolutionLayerCPUTest, ::testing::Values(Layout::ANY), ::testing::Values(Layout::ANY), ::testing::Values(std::vector({ 2, 12, 7, 7 })), + ::testing::ValuesIn(emptyOutputShape), ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice({conv_gemm_2D})), ::testing::ValuesIn(fusingParamsSet), @@ -168,6 +179,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Deconv_2D_Planar_BF16, DeconvolutionLayerCPUTest, ::testing::Values(Layout::ANY), ::testing::Values(Layout::ANY), ::testing::Values(std::vector({ 2, 12, 7, 7 })), + ::testing::ValuesIn(emptyOutputShape), ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice({conv_gemm_2D})), ::testing::ValuesIn(fusingParamsSet), @@ -182,7 +194,8 @@ const auto convParams_ExplicitPadding_Planar_3D = ::testing::Combine( ::testing::ValuesIn(padEnds3d), ::testing::ValuesIn(dilations3d), ::testing::ValuesIn(numOutChannels_Planar), - ::testing::Values(ngraph::op::PadType::EXPLICIT) + ::testing::Values(ngraph::op::PadType::EXPLICIT), + ::testing::ValuesIn(emptyOutputPadding) ); INSTANTIATE_TEST_CASE_P(smoke_Deconv_3D_Planar_FP32, DeconvolutionLayerCPUTest, @@ -195,6 +208,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Deconv_3D_Planar_FP32, DeconvolutionLayerCPUTest, ::testing::Values(Layout::ANY), ::testing::Values(Layout::ANY), ::testing::Values(std::vector({ 2, 12, 7, 7, 7 })), + ::testing::ValuesIn(emptyOutputShape), ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice({conv_gemm_3D})), ::testing::ValuesIn(fusingParamsSet), @@ -211,6 +225,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Deconv_3D_Planar_BF16, DeconvolutionLayerCPUTest, ::testing::Values(Layout::ANY), ::testing::Values(Layout::ANY), ::testing::Values(std::vector({ 2, 12, 7, 7, 7 })), + ::testing::ValuesIn(emptyOutputShape), ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice({conv_gemm_3D})), ::testing::ValuesIn(fusingParamsSet), @@ -225,7 +240,8 @@ const auto convParams_ExplicitPadding_Blocked_2D = ::testing::Combine( ::testing::ValuesIn(padEnds2d), ::testing::ValuesIn(dilations2d), ::testing::ValuesIn(numOutChannels_Blocked), - ::testing::Values(ngraph::op::PadType::EXPLICIT) + ::testing::Values(ngraph::op::PadType::EXPLICIT), + ::testing::ValuesIn(emptyOutputPadding) ); INSTANTIATE_TEST_CASE_P(smoke_Deconv_2D_Blocked_FP32, DeconvolutionLayerCPUTest, @@ -238,6 +254,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Deconv_2D_Blocked_FP32, DeconvolutionLayerCPUTest, ::testing::Values(Layout::ANY), ::testing::Values(Layout::ANY), ::testing::Values(std::vector({ 2, 67, 7, 7 })), + ::testing::ValuesIn(emptyOutputShape), ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice({conv_avx512_2D})), ::testing::ValuesIn(fusingParamsSet), @@ -254,6 +271,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Deconv_2D_Blocked_BF16, DeconvolutionLayerCPUTest, ::testing::Values(Layout::ANY), ::testing::Values(Layout::ANY), ::testing::Values(std::vector({ 2, 67, 7, 7 })), + ::testing::ValuesIn(emptyOutputShape), ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice({conv_avx512_2D})), ::testing::ValuesIn(fusingParamsSet), @@ -268,7 +286,8 @@ const auto convParams_ExplicitPadding_Blocked_3D = ::testing::Combine( ::testing::ValuesIn(padEnds3d), ::testing::ValuesIn(dilations3d), ::testing::ValuesIn(numOutChannels_Blocked), - ::testing::Values(ngraph::op::PadType::EXPLICIT) + ::testing::Values(ngraph::op::PadType::EXPLICIT), + ::testing::ValuesIn(emptyOutputPadding) ); INSTANTIATE_TEST_CASE_P(smoke_Deconv_3D_Blocked_FP32, DeconvolutionLayerCPUTest, @@ -281,6 +300,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Deconv_3D_Blocked_FP32, DeconvolutionLayerCPUTest, ::testing::Values(Layout::ANY), ::testing::Values(Layout::ANY), ::testing::Values(std::vector({ 2, 67, 7, 7, 7 })), + ::testing::ValuesIn(emptyOutputShape), ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice({conv_avx512_3D})), ::testing::ValuesIn(fusingParamsSet), @@ -297,6 +317,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Deconv_3D_Blocked_BF16, DeconvolutionLayerCPUTest, ::testing::Values(Layout::ANY), ::testing::Values(Layout::ANY), ::testing::Values(std::vector({ 2, 67, 7, 7, 7 })), + ::testing::ValuesIn(emptyOutputShape), ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice({conv_avx512_3D})), ::testing::ValuesIn(fusingParamsSet), @@ -312,7 +333,8 @@ const auto convParams_ExplicitPadding_1x1_2D = ::testing::Combine( ::testing::Values(std::vector({0, 0})), ::testing::Values(SizeVector({1, 1})), ::testing::ValuesIn(numOutChannels_Blocked), - ::testing::Values(ngraph::op::PadType::EXPLICIT) + ::testing::Values(ngraph::op::PadType::EXPLICIT), + ::testing::ValuesIn(emptyOutputPadding) ); INSTANTIATE_TEST_CASE_P(smoke_Deconv_2D_1x1_FP32, DeconvolutionLayerCPUTest, @@ -325,6 +347,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Deconv_2D_1x1_FP32, DeconvolutionLayerCPUTest, ::testing::Values(Layout::ANY), ::testing::Values(Layout::ANY), ::testing::Values(std::vector({ 2, 67, 7, 7 })), + ::testing::ValuesIn(emptyOutputShape), ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice({conv_avx512_2D_1x1})), ::testing::ValuesIn(fusingParamsSet), @@ -341,6 +364,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Deconv_2D_1x1_BF16, DeconvolutionLayerCPUTest, ::testing::Values(Layout::ANY), ::testing::Values(Layout::ANY), ::testing::Values(std::vector({ 2, 67, 7, 7 })), + ::testing::ValuesIn(emptyOutputShape), ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice({conv_avx512_2D_1x1})), ::testing::ValuesIn(fusingParamsSet), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/convolution_backprop_data.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/convolution_backprop_data.cpp index f18346cde9fb10..f404d932bc86a0 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/convolution_backprop_data.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/convolution_backprop_data.cpp @@ -4,7 +4,7 @@ #include -#include "single_layer_tests/convolution_backprop_data.hpp" +#include "single_layer_tests/convolution_backprop.hpp" #include "common_test_utils/test_constants.hpp" using namespace LayerTestsDefinitions; @@ -17,6 +17,8 @@ const std::vector netPrecisions = { }; const std::vector numOutChannels = {1, 5, 16}; +const std::vector> emptyOutputShape = {{}}; +const std::vector> emptyOutputPadding = {{}}; /* ============= 2D ConvolutionBackpropData ============= */ const std::vector netPrecisions2D = { @@ -40,7 +42,8 @@ const auto conv2DParams_ExplicitPadding = ::testing::Combine( ::testing::ValuesIn(padEnds2D), ::testing::ValuesIn(dilations2D), ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::EXPLICIT) + ::testing::Values(ngraph::op::PadType::EXPLICIT), + ::testing::ValuesIn(emptyOutputPadding) ); const auto conv2DParams_AutoPadValid = ::testing::Combine( ::testing::ValuesIn(kernels2D), @@ -49,10 +52,11 @@ const auto conv2DParams_AutoPadValid = ::testing::Combine( ::testing::Values(std::vector({0, 0})), ::testing::ValuesIn(dilations2D), ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::VALID) + ::testing::Values(ngraph::op::PadType::VALID), + ::testing::ValuesIn(emptyOutputPadding) ); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_ExplicitPadding, ConvolutionBackpropDataLayerTest, +INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_ExplicitPadding, ConvolutionBackpropLayerTest, ::testing::Combine( conv2DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions2D), @@ -61,10 +65,11 @@ INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_ExplicitPadding, Convolu ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::ValuesIn(inputShapes2D), + ::testing::ValuesIn(emptyOutputShape), ::testing::Values(CommonTestUtils::DEVICE_GPU)), - ConvolutionBackpropDataLayerTest::getTestCaseName); + ConvolutionBackpropLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_AutoPadValid, ConvolutionBackpropDataLayerTest, +INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_AutoPadValid, ConvolutionBackpropLayerTest, ::testing::Combine( conv2DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions2D), @@ -73,8 +78,59 @@ INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_AutoPadValid, Convolutio ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::ValuesIn(inputShapes2D), + ::testing::ValuesIn(emptyOutputShape), ::testing::Values(CommonTestUtils::DEVICE_GPU)), - ConvolutionBackpropDataLayerTest::getTestCaseName); + ConvolutionBackpropLayerTest::getTestCaseName); + +const std::vector> outputPadding2D = {{1, 1}, {2, 2}}; +const std::vector> testStrides2D = {{3, 3}}; + +const auto conv2DParams_ExplicitPadding_output_padding = ::testing::Combine( + ::testing::ValuesIn(kernels2D), + ::testing::ValuesIn(testStrides2D), + ::testing::ValuesIn(padBegins2D), + ::testing::ValuesIn(padEnds2D), + ::testing::ValuesIn(dilations2D), + ::testing::ValuesIn(numOutChannels), + ::testing::Values(ngraph::op::PadType::EXPLICIT), + ::testing::ValuesIn(outputPadding2D) +); +const auto conv2DParams_AutoPadValid_output_padding = ::testing::Combine( + ::testing::ValuesIn(kernels2D), + ::testing::ValuesIn(testStrides2D), + ::testing::Values(std::vector({0, 0})), + ::testing::Values(std::vector({0, 0})), + ::testing::ValuesIn(dilations2D), + ::testing::ValuesIn(numOutChannels), + ::testing::Values(ngraph::op::PadType::VALID), + ::testing::ValuesIn(outputPadding2D) +); + +INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_ExplicitPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, + ::testing::Combine( + conv2DParams_AutoPadValid_output_padding, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::ValuesIn(inputShapes2D), + ::testing::ValuesIn(emptyOutputShape), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + ConvolutionBackpropLayerTest::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_AutoPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, + ::testing::Combine( + conv2DParams_ExplicitPadding_output_padding, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::ValuesIn(inputShapes2D), + ::testing::ValuesIn(emptyOutputShape), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + ConvolutionBackpropLayerTest::getTestCaseName); /* ============= 3D ConvolutionBackpropData ============= */ const std::vector netPrecisions3D = { @@ -96,7 +152,8 @@ const auto conv3DParams_ExplicitPadding = ::testing::Combine( ::testing::ValuesIn(padEnds3D), ::testing::ValuesIn(dilations3D), ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::EXPLICIT) + ::testing::Values(ngraph::op::PadType::EXPLICIT), + ::testing::ValuesIn(emptyOutputPadding) ); const auto conv3DParams_AutoPadValid = ::testing::Combine( ::testing::ValuesIn(kernels3D), @@ -105,10 +162,11 @@ const auto conv3DParams_AutoPadValid = ::testing::Combine( ::testing::Values(std::vector({0, 0, 0})), ::testing::ValuesIn(dilations3D), ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::VALID) + ::testing::Values(ngraph::op::PadType::VALID), + ::testing::ValuesIn(emptyOutputPadding) ); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_ExplicitPadding, ConvolutionBackpropDataLayerTest, +INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_ExplicitPadding, ConvolutionBackpropLayerTest, ::testing::Combine( conv3DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions3D), @@ -117,10 +175,11 @@ INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_ExplicitPadding, Convolu ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::ValuesIn(inputShapes3D), + ::testing::ValuesIn(emptyOutputShape), ::testing::Values(CommonTestUtils::DEVICE_GPU)), - ConvolutionBackpropDataLayerTest::getTestCaseName); + ConvolutionBackpropLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_AutoPadValid, ConvolutionBackpropDataLayerTest, +INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_AutoPadValid, ConvolutionBackpropLayerTest, ::testing::Combine( conv3DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions3D), @@ -129,7 +188,58 @@ INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_AutoPadValid, Convolutio ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::ValuesIn(inputShapes3D), + ::testing::ValuesIn(emptyOutputShape), ::testing::Values(CommonTestUtils::DEVICE_GPU)), - ConvolutionBackpropDataLayerTest::getTestCaseName); + ConvolutionBackpropLayerTest::getTestCaseName); + +const std::vector> outputPadding3D = {{1, 1, 1}, {2, 2, 2}}; +const std::vector> testStrides3D = {{3, 3, 3}}; + +const auto conv3DParams_ExplicitPadding_output_padding = ::testing::Combine( + ::testing::ValuesIn(kernels3D), + ::testing::ValuesIn(testStrides3D), + ::testing::ValuesIn(padBegins3D), + ::testing::ValuesIn(padEnds3D), + ::testing::ValuesIn(dilations3D), + ::testing::ValuesIn(numOutChannels), + ::testing::Values(ngraph::op::PadType::EXPLICIT), + ::testing::ValuesIn(outputPadding3D) +); +const auto conv3DParams_AutoPadValid_output_padding = ::testing::Combine( + ::testing::ValuesIn(kernels3D), + ::testing::ValuesIn(testStrides3D), + ::testing::Values(std::vector({0, 0, 0})), + ::testing::Values(std::vector({0, 0, 0})), + ::testing::ValuesIn(dilations3D), + ::testing::ValuesIn(numOutChannels), + ::testing::Values(ngraph::op::PadType::VALID), + ::testing::ValuesIn(outputPadding3D) +); + +INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_ExplicitPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, + ::testing::Combine( + conv3DParams_AutoPadValid_output_padding, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::ValuesIn(inputShapes3D), + ::testing::ValuesIn(emptyOutputShape), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + ConvolutionBackpropLayerTest::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_AutoPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, + ::testing::Combine( + conv3DParams_ExplicitPadding_output_padding, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::ValuesIn(inputShapes3D), + ::testing::ValuesIn(emptyOutputShape), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + ConvolutionBackpropLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/convolution_backprop.hpp b/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/convolution_backprop.hpp new file mode 100644 index 00000000000000..45563d86a34f43 --- /dev/null +++ b/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/convolution_backprop.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/single_layer/convolution_backprop.hpp" + +namespace LayerTestsDefinitions { + +TEST_P(ConvolutionBackpropLayerTest, CompareWithRefs) { + Run(); +} + +} diff --git a/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/convolution_backprop_data.hpp b/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/convolution_backprop_data.hpp index 67fb0c56efdc1b..3b2947db121cc5 100644 --- a/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/convolution_backprop_data.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/convolution_backprop_data.hpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // +// DEPRECATED, can't be removed currently due to arm and kmb-plugin dependency (#55568) #pragma once #include "shared_test_classes/single_layer/convolution_backprop_data.hpp" diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convolution_backprop.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convolution_backprop.hpp new file mode 100644 index 00000000000000..794782396da858 --- /dev/null +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convolution_backprop.hpp @@ -0,0 +1,49 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include + +#include "shared_test_classes/base/layer_test_utils.hpp" +#include "ngraph_functions/builders.hpp" +#include "ngraph_functions/utils/ngraph_helpers.hpp" + +namespace LayerTestsDefinitions { + +typedef std::tuple< + InferenceEngine::SizeVector, // Kernel size + InferenceEngine::SizeVector, // Strides + std::vector, // Pad begin + std::vector, // Pad end + InferenceEngine::SizeVector, // Dilation + size_t, // Num out channels + ngraph::op::PadType, // Padding type + std::vector // Output padding +> convBackpropSpecificParams; +typedef std::tuple< + convBackpropSpecificParams, + InferenceEngine::Precision, // Net precision + InferenceEngine::Precision, // Input precision + InferenceEngine::Precision, // Output precision + InferenceEngine::Layout, // Input layout + InferenceEngine::Layout, // Output layout + InferenceEngine::SizeVector, // Input shapes + InferenceEngine::SizeVector, // Output shapes + LayerTestsUtils::TargetDevice // Device name +> convBackpropLayerTestParamsSet; + +class ConvolutionBackpropLayerTest : public testing::WithParamInterface, + virtual public LayerTestsUtils::LayerTestsCommon { +public: + static std::string getTestCaseName(testing::TestParamInfo obj); + +protected: + void SetUp() override; +}; + +} // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convolution_backprop_data.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convolution_backprop_data.hpp index ecfd6e4f1f7769..9aeb9a1a2be72c 100644 --- a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convolution_backprop_data.hpp +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convolution_backprop_data.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +// DEPRECATED, can't be removed currently due to arm and kmb-plugin dependency (#55568) + #pragma once #include diff --git a/inference-engine/tests/functional/shared_test_classes/src/single_layer/convolution_backprop.cpp b/inference-engine/tests/functional/shared_test_classes/src/single_layer/convolution_backprop.cpp new file mode 100644 index 00000000000000..55aae5e0a215b3 --- /dev/null +++ b/inference-engine/tests/functional/shared_test_classes/src/single_layer/convolution_backprop.cpp @@ -0,0 +1,71 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/single_layer/convolution_backprop.hpp" + +namespace LayerTestsDefinitions { + +std::string ConvolutionBackpropLayerTest::getTestCaseName(testing::TestParamInfo obj) { + convBackpropSpecificParams convBackpropDataParams; + InferenceEngine::Precision netPrecision; + InferenceEngine::Precision inPrc, outPrc; + InferenceEngine::Layout inLayout, outLayout; + InferenceEngine::SizeVector inputShapes; + InferenceEngine::SizeVector outputShapes; + std::string targetDevice; + std::tie(convBackpropDataParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, outputShapes, targetDevice) = obj.param; + ngraph::op::PadType padType; + InferenceEngine::SizeVector kernel, stride, dilation; + std::vector padBegin, padEnd, outPadding; + size_t convOutChannels; + std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, padType, outPadding) = convBackpropDataParams; + + std::ostringstream result; + result << "IS=" << CommonTestUtils::vec2str(inputShapes) << "_"; + result << "OS=" << CommonTestUtils::vec2str(outputShapes) << "_"; + result << "K" << CommonTestUtils::vec2str(kernel) << "_"; + result << "S" << CommonTestUtils::vec2str(stride) << "_"; + result << "PB" << CommonTestUtils::vec2str(padBegin) << "_"; + result << "PE" << CommonTestUtils::vec2str(padEnd) << "_"; + result << "D=" << CommonTestUtils::vec2str(dilation) << "_"; + result << "OP=" << CommonTestUtils::vec2str(outPadding) << "_"; + result << "O=" << convOutChannels << "_"; + result << "AP=" << padType << "_"; + result << "netPRC=" << netPrecision.name() << "_"; + result << "inPRC=" << inPrc.name() << "_"; + result << "outPRC=" << outPrc.name() << "_"; + result << "inL=" << inLayout << "_"; + result << "outL=" << outLayout << "_"; + result << "trgDev=" << targetDevice; + return result.str(); +} + +void ConvolutionBackpropLayerTest::SetUp() { + convBackpropSpecificParams convBackpropDataParams; + std::vector inputShape; + std::vector outputShape; + auto netPrecision = InferenceEngine::Precision::UNSPECIFIED; + std::tie(convBackpropDataParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, outputShape, targetDevice) = this->GetParam(); + ngraph::op::PadType padType; + InferenceEngine::SizeVector kernel, stride, dilation; + std::vector padBegin, padEnd, outPadding; + size_t convOutChannels; + std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, padType, outPadding) = convBackpropDataParams; + auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); + auto params = ngraph::builder::makeParams(ngPrc, {inputShape}); + auto paramOuts = ngraph::helpers::convert2OutputVector( + ngraph::helpers::castOps2Nodes(params)); + auto convBackpropData = std::dynamic_pointer_cast( + ngraph::builder::makeConvolutionBackpropData(paramOuts[0], ngPrc, kernel, stride, padBegin, + padEnd, dilation, padType, convOutChannels, false, outPadding)); + if (!outputShape.empty()) { + auto outShape = ngraph::opset3::Constant::create(ngraph::element::i64, {outputShape.size()}, outputShape); + convBackpropData = std::dynamic_pointer_cast( + ngraph::builder::makeConvolutionBackpropData(paramOuts[0], outShape, ngPrc, kernel, stride, padBegin, + padEnd, dilation, padType, convOutChannels)); + } + ngraph::ResultVector results{std::make_shared(convBackpropData)}; + function = std::make_shared(results, params, "convolutionBackpropData"); +} +} // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/shared_test_classes/src/single_layer/convolution_backprop_data.cpp b/inference-engine/tests/functional/shared_test_classes/src/single_layer/convolution_backprop_data.cpp index c6730a3aaecf30..f2656a3c2ab581 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/single_layer/convolution_backprop_data.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/single_layer/convolution_backprop_data.cpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +// DEPRECATED, can't be removed currently due to arm and kmb-plugin dependency (#55568) + #include "shared_test_classes/single_layer/convolution_backprop_data.hpp" namespace LayerTestsDefinitions { @@ -54,7 +56,7 @@ void ConvolutionBackpropDataLayerTest::SetUp() { ngraph::helpers::castOps2Nodes(params)); auto convBackpropData = std::dynamic_pointer_cast( ngraph::builder::makeConvolutionBackpropData(paramOuts[0], ngPrc, kernel, stride, padBegin, - padEnd, dilation, padType, convOutChannels)); + padEnd, dilation, padType, convOutChannels)); ngraph::ResultVector results{std::make_shared(convBackpropData)}; function = std::make_shared(results, params, "convolutionBackpropData"); } diff --git a/inference-engine/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/builders.hpp b/inference-engine/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/builders.hpp index 802535430cd134..1643f31f761f28 100644 --- a/inference-engine/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/builders.hpp +++ b/inference-engine/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/builders.hpp @@ -125,6 +125,7 @@ std::shared_ptr makeConvolutionBackpropData(const ngraph::Output &outputPadding = {}, const std::vector &filterWeights = {}, const std::vector &biasesWeights = {}); @@ -137,6 +138,22 @@ std::shared_ptr makeConvolutionBackpropData(const ngraph::Output &dilations, const op::PadType &autoPad, bool addBiases = false, + const std::vector &outputPadding = {}, + const std::vector &biasesWeights = {}); + +std::shared_ptr makeConvolutionBackpropData(const ngraph::Output &in, + const ngraph::Output &outputShape, + const element::Type &type, + const std::vector &filterSize, + const std::vector &strides, + const std::vector &padsBegin, + const std::vector &padsEnd, + const std::vector &dilations, + const op::PadType &autoPad, + size_t numOutChannels, + bool addBiases = false, + const std::vector &outputPadding = {}, + const std::vector &filterWeights = {}, const std::vector &biasesWeights = {}); std::shared_ptr makeCTCGreedyDecoder( diff --git a/inference-engine/tests/ngraph_helpers/ngraph_functions/src/convolution_backprop_data.cpp b/inference-engine/tests/ngraph_helpers/ngraph_functions/src/convolution_backprop_data.cpp index 0edf339ce7f3da..91d6c0fc0852e6 100644 --- a/inference-engine/tests/ngraph_helpers/ngraph_functions/src/convolution_backprop_data.cpp +++ b/inference-engine/tests/ngraph_helpers/ngraph_functions/src/convolution_backprop_data.cpp @@ -20,6 +20,7 @@ std::shared_ptr makeConvolutionBackpropData(const ngraph::Output &in const op::PadType &autoPad, size_t numOutChannels, bool addBiases, + const std::vector &outputPadding, const std::vector &filterWeights, const std::vector &biasesWeights) { bool randomFilterWeights = filterWeights.empty(); @@ -28,7 +29,7 @@ std::shared_ptr makeConvolutionBackpropData(const ngraph::Output &in filterWeightsShape.insert(filterWeightsShape.end(), filterSize.begin(), filterSize.end()); auto filterWeightsNode = makeConstant(type, filterWeightsShape, filterWeights, randomFilterWeights); - return makeConvolutionBackpropData(in, filterWeightsNode, type, strides, padsBegin, padsEnd, dilations, autoPad, addBiases, biasesWeights); + return makeConvolutionBackpropData(in, filterWeightsNode, type, strides, padsBegin, padsEnd, dilations, autoPad, addBiases, outputPadding, biasesWeights); } std::shared_ptr makeConvolutionBackpropData(const ngraph::Output &in, @@ -40,9 +41,51 @@ std::shared_ptr makeConvolutionBackpropData(const ngraph::Output &in const std::vector &dilations, const op::PadType &autoPad, bool addBiases, + const std::vector &outputPadding, const std::vector &biasesWeights) { auto deconv = std::make_shared(in, weights, strides, padsBegin, padsEnd, dilations, autoPad); + if (!outputPadding.empty()) { + deconv = std::make_shared(in, weights, strides, padsBegin, padsEnd, dilations, autoPad, outputPadding); + } + + if (addBiases) { + bool randomBiases = biasesWeights.empty(); + auto biasesWeightsNode = makeConstant(type, {}, biasesWeights, randomBiases); + auto add = std::make_shared(deconv, biasesWeightsNode); + return add; + } else { + return deconv; + } +} + +std::shared_ptr makeConvolutionBackpropData(const ngraph::Output &in, + const ngraph::Output &outputShape, + const element::Type &type, + const std::vector &filterSize, + const std::vector &strides, + const std::vector &padsBegin, + const std::vector &padsEnd, + const std::vector &dilations, + const op::PadType &autoPad, + size_t numOutChannels, + bool addBiases, + const std::vector &outputPadding, + const std::vector &filterWeights, + const std::vector &biasesWeights) { + bool randomFilterWeights = filterWeights.empty(); + auto shape = in.get_shape(); + std::vector filterWeightsShape = {shape[1], numOutChannels}; + filterWeightsShape.insert(filterWeightsShape.end(), filterSize.begin(), filterSize.end()); + auto filterWeightsNode = makeConstant(type, filterWeightsShape, filterWeights, randomFilterWeights); + + auto deconv = std::make_shared(in, filterWeightsNode, outputShape, strides, padsBegin, padsEnd, dilations, autoPad); + + if (!outputPadding.empty()) { + deconv = std::make_shared(in, filterWeightsNode, outputShape, strides, padsBegin, + padsEnd, dilations, autoPad, outputPadding); + } + if (addBiases) { bool randomBiases = biasesWeights.empty(); auto biasesWeightsNode = makeConstant(type, {}, biasesWeights, randomBiases); From b4a4c9110c4c5e629277dae02d4ab8d41670edcc Mon Sep 17 00:00:00 2001 From: Gabriele Galiero Casay Date: Tue, 15 Jun 2021 06:18:57 +0200 Subject: [PATCH 079/178] Revise Reference Implementations ReduceLp operations (#6065) * Revise reference implementation for ReduceL1 operation * Revise reference implementation for ReduceL2 operation * Move op_eval tests to backend unit tests * Added minor changes * Replace CoordinateTransform for CoordinateTransformBasic * Added constant expression to set keep_dims as false * Add const qualifier to local variables * Use rank from host tensor to normalize axes --- .../ngraph/runtime/reference/reduce_l1.hpp | 29 ++++----- .../ngraph/runtime/reference/reduce_l2.hpp | 37 ++++++----- ngraph/core/src/op/reduce_l1.cpp | 12 +++- ngraph/core/src/op/reduce_l2.cpp | 13 +++- ngraph/test/CMakeLists.txt | 4 +- ngraph/test/backend/reduce_l1.in.cpp | 61 +++++++++++++++++++ ngraph/test/backend/reduce_l2.in.cpp | 61 +++++++++++++++++++ ngraph/test/op_eval/reduce_l1.cpp | 59 ------------------ ngraph/test/op_eval/reduce_l2.cpp | 61 ------------------- 9 files changed, 176 insertions(+), 161 deletions(-) create mode 100644 ngraph/test/backend/reduce_l1.in.cpp create mode 100644 ngraph/test/backend/reduce_l2.in.cpp delete mode 100644 ngraph/test/op_eval/reduce_l1.cpp delete mode 100644 ngraph/test/op_eval/reduce_l2.cpp diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/reduce_l1.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/reduce_l1.hpp index 86eac8ceb26183..83a3fbce98c721 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/reduce_l1.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/reduce_l1.hpp @@ -5,6 +5,7 @@ #pragma once #include +#include #include "ngraph/coordinate_transform.hpp" #include "ngraph/shape_util.hpp" @@ -19,27 +20,27 @@ namespace ngraph void reduce_l1(const T* arg, T* out, const Shape& in_shape, - const AxisSet& reduction_axes, - bool keep_dims) + const AxisSet& reduction_axes) { - auto out_shape = reduce(in_shape, reduction_axes, keep_dims); - CoordinateTransform output_transform(out_shape); + constexpr bool dont_keep_dims_in_output = false; + const auto out_shape = reduce(in_shape, reduction_axes, dont_keep_dims_in_output); + std::fill(out, out + shape_size(out_shape), 0); - for (const Coordinate& output_coord : output_transform) - { - out[output_transform.index(output_coord)] = 0; - } - - CoordinateTransform input_transform(in_shape); + const auto in_strides = row_major_strides(in_shape); + const auto out_strides = row_major_strides(out_shape); + CoordinateTransformBasic input_transform(in_shape); for (const Coordinate& input_coord : input_transform) { - Coordinate output_coord = reduce(input_coord, reduction_axes, keep_dims); + const Coordinate output_coord = + reduce(input_coord, reduction_axes, dont_keep_dims_in_output); - size_t output_index = output_transform.index(output_coord); + const size_t in_idx = std::inner_product( + input_coord.begin(), input_coord.end(), in_strides.begin(), 0); + const size_t out_idx = std::inner_product( + output_coord.begin(), output_coord.end(), out_strides.begin(), 0); - out[output_index] = - out[output_index] + std::abs(arg[input_transform.index(input_coord)]); + out[out_idx] = out[out_idx] + std::abs(arg[in_idx]); } } } // namespace reference diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/reduce_l2.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/reduce_l2.hpp index b7ae96586b2c08..aeb4eecbe0f97e 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/reduce_l2.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/reduce_l2.hpp @@ -5,6 +5,7 @@ #pragma once #include +#include #include "ngraph/coordinate_transform.hpp" #include "ngraph/shape_util.hpp" @@ -19,34 +20,30 @@ namespace ngraph void reduce_l2(const T* arg, T* out, const Shape& in_shape, - const AxisSet& reduction_axes, - bool keep_dims) + const AxisSet& reduction_axes) { - auto out_shape = reduce(in_shape, reduction_axes, keep_dims); - CoordinateTransform output_transform(out_shape); + constexpr bool dont_keep_dims_in_output = false; + const auto out_shape = reduce(in_shape, reduction_axes, dont_keep_dims_in_output); + std::fill(out, out + shape_size(out_shape), 0); - for (const Coordinate& output_coord : output_transform) - { - out[output_transform.index(output_coord)] = 0; - } - - CoordinateTransform input_transform(in_shape); + const auto in_strides = row_major_strides(in_shape); + const auto out_strides = row_major_strides(out_shape); + CoordinateTransformBasic input_transform(in_shape); for (const Coordinate& input_coord : input_transform) { - Coordinate output_coord = reduce(input_coord, reduction_axes, keep_dims); + const Coordinate output_coord = + reduce(input_coord, reduction_axes, dont_keep_dims_in_output); - size_t output_index = output_transform.index(output_coord); + const size_t in_idx = std::inner_product( + input_coord.begin(), input_coord.end(), in_strides.begin(), 0); + const size_t out_idx = std::inner_product( + output_coord.begin(), output_coord.end(), out_strides.begin(), 0); - out[output_index] = - out[output_index] + arg[input_transform.index(input_coord)] * - arg[input_transform.index(input_coord)]; - } - for (const Coordinate& output_coord : output_transform) - { - out[output_transform.index(output_coord)] = - sqrt(out[output_transform.index(output_coord)]); + out[out_idx] = out[out_idx] + arg[in_idx] * arg[in_idx]; } + std::transform( + out, out + shape_size(out_shape), out, [](T elem) { return sqrt(elem); }); } } // namespace reference } // namespace runtime diff --git a/ngraph/core/src/op/reduce_l1.cpp b/ngraph/core/src/op/reduce_l1.cpp index 29de7e4e03f09e..02a336ac60d661 100644 --- a/ngraph/core/src/op/reduce_l1.cpp +++ b/ngraph/core/src/op/reduce_l1.cpp @@ -3,8 +3,10 @@ // #include "ngraph/op/reduce_l1.hpp" +#include #include "itt.hpp" #include "ngraph/graph_util.hpp" +#include "ngraph/op/util/evaluate_helpers.hpp" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/runtime/reference/reduce_l1.hpp" #include "ngraph/shape_util.hpp" @@ -44,7 +46,7 @@ namespace reduce_l1 { out->set_shape(reduce(arg->get_shape(), axes, keep_dims)); runtime::reference::reduce_l1( - arg->get_data_ptr(), out->get_data_ptr(), arg->get_shape(), axes, keep_dims); + arg->get_data_ptr(), out->get_data_ptr(), arg->get_shape(), axes); return true; } @@ -71,7 +73,13 @@ bool op::v4::ReduceL1::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { NGRAPH_OP_SCOPE(v4_ReduceL1_evaluate); - return reduce_l1::evaluate_sum(inputs[0], outputs[0], get_reduction_axes(), get_keep_dims()); + NGRAPH_CHECK(validate_host_tensor_vector(inputs, 2)); + NGRAPH_CHECK(validate_host_tensor_vector(outputs, 1)); + + const auto reduction_axes = get_normalized_axes_from_tensor( + inputs[1], inputs[0]->get_partial_shape().rank(), get_friendly_name()); + + return reduce_l1::evaluate_sum(inputs[0], outputs[0], reduction_axes, get_keep_dims()); } bool op::v4::ReduceL1::has_evaluate() const diff --git a/ngraph/core/src/op/reduce_l2.cpp b/ngraph/core/src/op/reduce_l2.cpp index e3ee81b1875474..7ffecb90377735 100644 --- a/ngraph/core/src/op/reduce_l2.cpp +++ b/ngraph/core/src/op/reduce_l2.cpp @@ -3,8 +3,10 @@ // #include "ngraph/op/reduce_l2.hpp" +#include #include "itt.hpp" #include "ngraph/graph_util.hpp" +#include "ngraph/op/util/evaluate_helpers.hpp" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/runtime/reference/reduce_l2.hpp" #include "ngraph/shape_util.hpp" @@ -44,7 +46,7 @@ namespace reduce_l2 { out->set_shape(reduce(arg->get_shape(), axes, keep_dims)); runtime::reference::reduce_l2( - arg->get_data_ptr(), out->get_data_ptr(), arg->get_shape(), axes, keep_dims); + arg->get_data_ptr(), out->get_data_ptr(), arg->get_shape(), axes); return true; } @@ -69,8 +71,13 @@ bool op::v4::ReduceL2::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { NGRAPH_OP_SCOPE(v4_ReduceL2_evaluate); - return reduce_l2::evaluate_reduce_l2( - inputs[0], outputs[0], get_reduction_axes(), get_keep_dims()); + NGRAPH_CHECK(validate_host_tensor_vector(inputs, 2)); + NGRAPH_CHECK(validate_host_tensor_vector(outputs, 1)); + + const auto reduction_axes = get_normalized_axes_from_tensor( + inputs[1], inputs[0]->get_partial_shape().rank(), get_friendly_name()); + + return reduce_l2::evaluate_reduce_l2(inputs[0], outputs[0], reduction_axes, get_keep_dims()); } bool op::v4::ReduceL2::has_evaluate() const diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index 2f85b09fc606d3..77903f5fc254c2 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -71,8 +71,6 @@ set(SRC op_eval/memory.cpp op_eval/mish.cpp op_eval/non_zero.cpp - op_eval/reduce_l1.cpp - op_eval/reduce_l2.cpp op_eval/reduce_prod.cpp op_eval/reduce_sum.cpp op_eval/roi_align.cpp @@ -423,6 +421,8 @@ set(MULTI_TEST_SRC backend/psroi_pooling.in.cpp backend/range.in.cpp backend/recurrent_cells.in.cpp + backend/reduce_l1.in.cpp + backend/reduce_l2.in.cpp backend/reduce_max.in.cpp backend/reduce_mean.in.cpp backend/reduce_min.in.cpp diff --git a/ngraph/test/backend/reduce_l1.in.cpp b/ngraph/test/backend/reduce_l1.in.cpp new file mode 100644 index 00000000000000..d421ebc443dbc0 --- /dev/null +++ b/ngraph/test/backend/reduce_l1.in.cpp @@ -0,0 +1,61 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "util/all_close.hpp" +#include "util/all_close_f.hpp" +#include "util/test_control.hpp" +#include "util/test_tools.hpp" + +using namespace std; +using namespace ngraph; + +static string s_manifest = "${MANIFEST}"; + +NGRAPH_TEST(${BACKEND_NAME}, reduce_l1_one_axis_keep_dims) +{ + auto data = make_shared(element::f32, Shape{3, 2, 2}); + auto axes = op::Constant::create(element::i32, Shape{1}, {2}); + auto reduce_l1 = make_shared(data, axes, true); + auto f = make_shared(OutputVector{reduce_l1}, ParameterVector{data}); + + auto backend = runtime::Backend::create("${BACKEND_NAME}"); + + // Create tensors for input/output + std::vector input{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0}; + std::vector expected_result{3.0, 7.0, 11.0, 15.0, 19.0, 23.0}; + + auto data_tensor = backend->create_tensor(element::f32, Shape{3, 2, 2}); + copy_data(data_tensor, input); + + auto result_tensor = backend->create_tensor(element::f32, Shape{3, 2, 1}); + + auto handle = backend->compile(f); + handle->call_with_validate({result_tensor}, {data_tensor}); + EXPECT_TRUE(test::all_close_f((expected_result), read_vector(result_tensor))); +} + +NGRAPH_TEST(${BACKEND_NAME}, reduce_l1_one_axis_do_not_keep_dims) +{ + auto data = make_shared(element::f32, Shape{3, 2, 2}); + auto axes = op::Constant::create(element::i32, Shape{1}, {2}); + auto reduce_l1 = make_shared(data, axes, false); + auto f = make_shared(OutputVector{reduce_l1}, ParameterVector{data}); + + auto backend = runtime::Backend::create("${BACKEND_NAME}"); + + // Create tensors for input/output + std::vector input{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0}; + std::vector expected_result{3.0, 7.0, 11.0, 15.0, 19.0, 23.0}; + + auto data_tensor = backend->create_tensor(element::f32, Shape{3, 2, 2}); + copy_data(data_tensor, input); + + auto result_tensor = backend->create_tensor(element::f32, Shape{3, 2}); + + auto handle = backend->compile(f); + handle->call_with_validate({result_tensor}, {data_tensor}); + EXPECT_TRUE(test::all_close_f((expected_result), read_vector(result_tensor))); +} diff --git a/ngraph/test/backend/reduce_l2.in.cpp b/ngraph/test/backend/reduce_l2.in.cpp new file mode 100644 index 00000000000000..a1cd3eebab6cdd --- /dev/null +++ b/ngraph/test/backend/reduce_l2.in.cpp @@ -0,0 +1,61 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "util/all_close.hpp" +#include "util/all_close_f.hpp" +#include "util/test_control.hpp" +#include "util/test_tools.hpp" + +using namespace std; +using namespace ngraph; + +static string s_manifest = "${MANIFEST}"; + +NGRAPH_TEST(${BACKEND_NAME}, reduce_l2_one_axis_keep_dims) +{ + auto data = make_shared(element::f32, Shape{3, 2, 2}); + auto axes = op::Constant::create(element::i32, Shape{1}, {2}); + auto reduce_l2 = make_shared(data, axes, true); + auto f = make_shared(OutputVector{reduce_l2}, ParameterVector{data}); + + auto backend = runtime::Backend::create("${BACKEND_NAME}"); + + std::vector input{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0}; + std::vector expected_result{ + 2.23606798, 5.0, 7.81024968, 10.63014581, 13.45362405, 16.2788206}; + + auto data_tensor = backend->create_tensor(element::f32, Shape{3, 2, 2}); + copy_data(data_tensor, input); + + auto result_tensor = backend->create_tensor(element::f32, Shape{3, 2, 1}); + + auto handle = backend->compile(f); + handle->call_with_validate({result_tensor}, {data_tensor}); + EXPECT_TRUE(test::all_close_f((expected_result), read_vector(result_tensor))); +} + +NGRAPH_TEST(${BACKEND_NAME}, reduce_l2_one_axis_do_not_keep_dims) +{ + auto data = make_shared(element::f32, Shape{3, 2, 2}); + auto axes = op::Constant::create(element::i32, Shape{1}, {2}); + auto reduce_l2 = make_shared(data, axes, false); + auto f = make_shared(OutputVector{reduce_l2}, ParameterVector{data}); + + auto backend = runtime::Backend::create("${BACKEND_NAME}"); + + std::vector input{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0}; + std::vector expected_result{ + 2.23606798, 5.0, 7.81024968, 10.63014581, 13.45362405, 16.2788206}; + + auto data_tensor = backend->create_tensor(element::f32, Shape{3, 2, 2}); + copy_data(data_tensor, input); + + auto result_tensor = backend->create_tensor(element::f32, Shape{3, 2}); + + auto handle = backend->compile(f); + handle->call_with_validate({result_tensor}, {data_tensor}); + EXPECT_TRUE(test::all_close_f((expected_result), read_vector(result_tensor))); +} diff --git a/ngraph/test/op_eval/reduce_l1.cpp b/ngraph/test/op_eval/reduce_l1.cpp deleted file mode 100644 index 0f64ee495bffab..00000000000000 --- a/ngraph/test/op_eval/reduce_l1.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include - -#include "gtest/gtest.h" - -#include "ngraph/opsets/opset4.hpp" -#include "ngraph/runtime/host_tensor.hpp" -#include "ngraph/validation_util.hpp" -#include "runtime/backend.hpp" -#include "util/test_tools.hpp" - -using namespace std; -using namespace ngraph; - -TEST(op_eval, reduce_l1_one_axis_keep_dims) -{ - auto data = make_shared(element::f32, Shape{3, 2, 2}); - auto axes = opset4::Constant::create(element::i32, Shape{1}, {2}); - auto reduce = make_shared(data, axes, true); - auto fun = make_shared(OutputVector{reduce}, ParameterVector{data}); - - std::vector inputs{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0}; - std::vector expected_result{3.0, 7.0, 11.0, 15.0, 19.0, 23.0}; - - auto result = make_shared(); - ASSERT_TRUE(fun->evaluate({result}, - {make_host_tensor(Shape{3, 2, 2}, inputs), - make_host_tensor(Shape{1}, {2})})); - EXPECT_EQ(result->get_element_type(), element::f32); - EXPECT_EQ(result->get_shape(), Shape{std::vector({3, 2, 1})}); - auto result_data = read_vector(result); - for (size_t i = 0; i < expected_result.size(); i++) - EXPECT_NEAR(result_data[i], expected_result[i], 0.000001); -} - -TEST(op_eval, reduce_l1_one_axis_do_not_keep_dims) -{ - auto data = make_shared(element::f32, Shape{3, 2, 2}); - auto axes = opset4::Constant::create(element::i32, Shape{1}, {2}); - auto reduce = make_shared(data, axes, false); - auto fun = make_shared(OutputVector{reduce}, ParameterVector{data}); - - std::vector inputs{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0}; - std::vector expected_result{3.0, 7.0, 11.0, 15.0, 19.0, 23.0}; - - auto result = make_shared(); - ASSERT_TRUE(fun->evaluate({result}, - {make_host_tensor(Shape{3, 2, 2}, inputs), - make_host_tensor(Shape{1}, {2})})); - EXPECT_EQ(result->get_element_type(), element::f32); - EXPECT_EQ(result->get_shape(), Shape{std::vector({3, 2})}); - auto result_data = read_vector(result); - for (size_t i = 0; i < expected_result.size(); i++) - EXPECT_NEAR(result_data[i], expected_result[i], 0.000001); -} diff --git a/ngraph/test/op_eval/reduce_l2.cpp b/ngraph/test/op_eval/reduce_l2.cpp deleted file mode 100644 index 7aab1907c4aac0..00000000000000 --- a/ngraph/test/op_eval/reduce_l2.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include - -#include "gtest/gtest.h" - -#include "ngraph/opsets/opset4.hpp" -#include "ngraph/runtime/host_tensor.hpp" -#include "ngraph/validation_util.hpp" -#include "runtime/backend.hpp" -#include "util/test_tools.hpp" - -using namespace std; -using namespace ngraph; - -TEST(op_eval, reduce_l2_one_axis_keep_dims) -{ - auto data = make_shared(element::f32, Shape{3, 2, 2}); - auto axes = opset4::Constant::create(element::i32, Shape{1}, {2}); - auto reduce = make_shared(data, axes, true); - auto fun = make_shared(OutputVector{reduce}, ParameterVector{data}); - - std::vector inputs{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0}; - std::vector expected_result{ - 2.23606798, 5.0, 7.81024968, 10.63014581, 13.45362405, 16.2788206}; - - auto result = make_shared(); - ASSERT_TRUE(fun->evaluate({result}, - {make_host_tensor(Shape{3, 2, 2}, inputs), - make_host_tensor(Shape{1}, {2})})); - EXPECT_EQ(result->get_element_type(), element::f32); - EXPECT_EQ(result->get_shape(), Shape{std::vector({3, 2, 1})}); - auto result_data = read_vector(result); - for (size_t i = 0; i < expected_result.size(); i++) - EXPECT_NEAR(result_data[i], expected_result[i], 0.000001); -} - -TEST(op_eval, reduce_l2_one_axis_do_not_keep_dims) -{ - auto data = make_shared(element::f32, Shape{3, 2, 2}); - auto axes = opset4::Constant::create(element::i32, Shape{1}, {2}); - auto reduce = make_shared(data, axes, false); - auto fun = make_shared(OutputVector{reduce}, ParameterVector{data}); - - std::vector inputs{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0}; - std::vector expected_result{ - 2.23606798, 5.0, 7.81024968, 10.63014581, 13.45362405, 16.2788206}; - - auto result = make_shared(); - ASSERT_TRUE(fun->evaluate({result}, - {make_host_tensor(Shape{3, 2, 2}, inputs), - make_host_tensor(Shape{1}, {2})})); - EXPECT_EQ(result->get_element_type(), element::f32); - EXPECT_EQ(result->get_shape(), Shape{std::vector({3, 2})}); - auto result_data = read_vector(result); - for (size_t i = 0; i < expected_result.size(); i++) - EXPECT_NEAR(result_data[i], expected_result[i], 0.000001); -} From 766d011b06af935f5e2efcb5411bf848856e9029 Mon Sep 17 00:00:00 2001 From: Patryk Elszkowski Date: Tue, 15 Jun 2021 06:25:19 +0200 Subject: [PATCH 080/178] reshape reference implementation - new implementation (#5559) --- .../ngraph/runtime/opt_kernel/reshape.hpp | 1 - .../ngraph/runtime/reference/reshape.hpp | 6 +- .../src/runtime/opt_kernel/reshape.cpp | 18 +- .../src/runtime/reference/reshape.cpp | 91 ++++--- ngraph/test/CMakeLists.txt | 1 + ngraph/test/reshape_opt_kernel.cpp | 232 ++++++++++++++++++ ngraph/test/visitors/op/reshape.cpp | 4 + 7 files changed, 310 insertions(+), 43 deletions(-) create mode 100644 ngraph/test/reshape_opt_kernel.cpp diff --git a/ngraph/core/reference/include/ngraph/runtime/opt_kernel/reshape.hpp b/ngraph/core/reference/include/ngraph/runtime/opt_kernel/reshape.hpp index 30ba487ecc602d..27d960ee6db5fa 100644 --- a/ngraph/core/reference/include/ngraph/runtime/opt_kernel/reshape.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/opt_kernel/reshape.hpp @@ -5,7 +5,6 @@ #pragma once #include "ngraph/axis_vector.hpp" -#include "ngraph/runtime/reference/reshape.hpp" #include "ngraph/shape.hpp" namespace ngraph diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/reshape.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/reshape.hpp index d6696b8feeb024..ee1c2f998ed16f 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/reshape.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/reshape.hpp @@ -4,12 +4,8 @@ #pragma once -#include - #include "ngraph/axis_vector.hpp" -#include "ngraph/check.hpp" -#include "ngraph/coordinate_transform.hpp" -#include "ngraph/type/element_type.hpp" +#include "ngraph/shape.hpp" namespace ngraph { diff --git a/ngraph/core/reference/src/runtime/opt_kernel/reshape.cpp b/ngraph/core/reference/src/runtime/opt_kernel/reshape.cpp index f0d559f1847114..38c29f9387c60a 100644 --- a/ngraph/core/reference/src/runtime/opt_kernel/reshape.cpp +++ b/ngraph/core/reference/src/runtime/opt_kernel/reshape.cpp @@ -2,11 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include +#include +#include #include "ngraph/check.hpp" #include "ngraph/runtime/opt_kernel/reshape.hpp" +#include "ngraph/runtime/reference/reshape.hpp" using namespace ngraph; @@ -233,6 +234,13 @@ namespace } } } + bool no_axis_reordering(const AxisVector& axis_order) + { + auto tmp = axis_order; + std::sort(begin(tmp), end(tmp)); + tmp.erase(std::unique(begin(tmp), end(tmp)), end(tmp)); + return tmp == axis_order; + } } // namespace void runtime::opt_kernel::reshape(const char* in, char* out, @@ -241,6 +249,12 @@ void runtime::opt_kernel::reshape(const char* in, const Shape& out_shape, size_t elem_size) { + if (no_axis_reordering(in_axis_order)) + { + std::memcpy(out, in, shape_size(in_shape) * elem_size); + return; + } + switch (in_shape.size()) { case 0: reshape_in0(in, out, in_shape, in_axis_order, out_shape, elem_size); break; diff --git a/ngraph/core/reference/src/runtime/reference/reshape.cpp b/ngraph/core/reference/src/runtime/reference/reshape.cpp index f4c100b27fcabe..27ac18e0190e02 100644 --- a/ngraph/core/reference/src/runtime/reference/reshape.cpp +++ b/ngraph/core/reference/src/runtime/reference/reshape.cpp @@ -2,46 +2,67 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include +#include +#include #include "ngraph/check.hpp" +#include "ngraph/coordinate_range.hpp" +#include "ngraph/coordinate_transform.hpp" #include "ngraph/runtime/reference/reshape.hpp" -using namespace ngraph; - -void runtime::reference::reshape(const char* arg, - char* out, - const Shape& in_shape, - const AxisVector& in_axis_order, - const Shape& out_shape, - size_t elem_size) +namespace ngraph { - // Unfortunately we don't yet have a constructor for CoordinateTransform that lets - // us pass only source_space_shape - // and source_axis_order so we have to construct the defaults here. - Shape in_start_corner(in_shape.size(), 0); // (0,...0) - Strides in_strides(in_shape.size(), 1); // (1,...,1) - - CoordinateTransform input_transform( - in_shape, in_start_corner, in_shape, in_strides, in_axis_order); - CoordinateTransform output_transform(out_shape); - - NGRAPH_CHECK(shape_size(input_transform.get_target_shape()) == - shape_size(output_transform.get_target_shape())); - - CoordinateTransform::Iterator output_it = output_transform.begin(); - - for (const Coordinate& input_coord : input_transform) + namespace runtime { - if (output_it == output_transform.end()) - break; - const Coordinate& output_coord = *output_it; + namespace reference + { + namespace + { + std::vector reorder(const std::vector& origin, + const AxisVector& order) + { + std::vector reordered = origin; + auto out = begin(reordered); + NGRAPH_CHECK(origin.size() <= order.size()); + for (size_t i = 0; i < origin.size(); ++i) + { + *out = origin.at(order[i]); + ++out; + } + return reordered; + } + } // namespace - memcpy(out + output_transform.index(output_coord) * elem_size, - arg + input_transform.index(input_coord) * elem_size, - elem_size); + void reshape(const char* arg, + char* out, + const Shape& in_shape, + const AxisVector& in_axis_order, + const Shape& out_shape, + size_t elem_size) + { + if (shape_size(in_shape) == 1) + { + std::memcpy(out, arg, elem_size); + return; + } - ++output_it; - } -} + char* output = out; + const char* const output_end = out + shape_size(out_shape) * elem_size; + const auto axis_strides = reorder(row_major_strides(in_shape), in_axis_order); + for (const auto& coordinate : + CoordinateTransformBasic(reorder(in_shape, in_axis_order))) + { + if (output >= output_end) + { + break; + } + const auto elem_offset = std::inner_product( + begin(coordinate), end(coordinate), begin(axis_strides), 0ll); + const auto input = arg + elem_offset * elem_size; + std::memcpy(output, input, elem_size); + output += elem_size; + } + } + } // namespace reference + } // namespace runtime +} // namespace ngraph diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index 77903f5fc254c2..47dfbbd3e495b3 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -92,6 +92,7 @@ set(SRC pattern.cpp provenance.cpp replace_node.cpp + reshape_opt_kernel.cpp shape.cpp span.cpp specialize_function.cpp diff --git a/ngraph/test/reshape_opt_kernel.cpp b/ngraph/test/reshape_opt_kernel.cpp new file mode 100644 index 00000000000000..01a2358e29eac9 --- /dev/null +++ b/ngraph/test/reshape_opt_kernel.cpp @@ -0,0 +1,232 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include + +#include "gtest/gtest.h" + +#include "ngraph/axis_vector.hpp" +#include "ngraph/runtime/opt_kernel/reshape.hpp" +#include "ngraph/shape.hpp" + +#include "util/ndarray.hpp" + +using namespace ngraph; + +namespace +{ + using ElementValue = int32_t; + enum class AxisOrder + { + straight, + reverse, + }; + + AxisVector get_axis_order(AxisOrder order, size_t size) + { + AxisVector v(size); + std::iota(begin(v), end(v), 0); + if (order == AxisOrder::reverse) + { + std::reverse(begin(v), end(v)); + } + return v; + } + + struct TestParams + { + AxisOrder order; + test::NDArrayBase input; + test::NDArrayBase output; + }; + + struct ReshapeOptKernel : ::testing::TestWithParam + { + }; + +} // namespace + +TEST_P(ReshapeOptKernel, reshape_opt_kernel) +{ + const TestParams& p = GetParam(); + + const AxisVector axis_order = get_axis_order(p.order, p.input.get_shape().size()); + std::vector output_buff(p.input.get_vector().size()); + + runtime::opt_kernel::reshape((const char*)p.input.data(), + (char*)output_buff.data(), + p.input.get_shape(), + axis_order, + p.output.get_shape(), + sizeof(ElementValue)); + EXPECT_EQ(p.output.get_vector(), output_buff); +} + +INSTANTIATE_TEST_CASE_P(reshape_opt_kernel, + ReshapeOptKernel, + ::testing::Values(TestParams{AxisOrder::straight, + test::NDArray{ + {1, 2}, + {3, 4}, + {5, 6}, + }, + test::NDArray{ + {1, 2, 3}, + {4, 5, 6}, + }}, + TestParams{AxisOrder::straight, + test::NDArray{ + {1, 2}, + {3, 4}, + {5, 6}, + }, + test::NDArray{ + {1, 2, 3, 4, 5, 6}, + }}, + TestParams{AxisOrder::straight, + test::NDArray{ + { + {11, 12}, + {13, 14}, + {15, 16}, + }, + { + {21, 22}, + {23, 24}, + {25, 26}, + }, + }, + test::NDArray{ + {11, 12, 13, 14, 15, 16}, + {21, 22, 23, 24, 25, 26}, + }}, + TestParams{AxisOrder::straight, + test::NDArray{ + { + { + {11, 12}, + {13, 14}, + {15, 16}, + }, + { + {21, 22}, + {23, 24}, + {25, 26}, + }, + }, + }, + test::NDArray{ + {11, 12, 13, 14, 15, 16}, + {21, 22, 23, 24, 25, 26}, + }}, + TestParams{AxisOrder::reverse, + test::NDArray{ + {1, 2}, + {3, 4}, + {5, 6}, + }, + test::NDArray{ + {1, 3, 5}, + {2, 4, 6}, + }}, + TestParams{AxisOrder::reverse, + test::NDArray{ + {1, 2}, + {3, 4}, + {5, 6}, + }, + test::NDArray{ + {1, 3, 5, 2, 4, 6}, + }}, + TestParams{AxisOrder::reverse, + test::NDArray{ + { + {11, 12}, + {13, 14}, + {15, 16}, + }, + { + {21, 22}, + {23, 24}, + {25, 26}, + }, + }, + test::NDArray{ + {11, 21, 13, 23, 15, 25}, + {12, 22, 14, 24, 16, 26}, + }}, + TestParams{AxisOrder::reverse, + test::NDArray{ + { + { + {11, 12}, + {13, 14}, + {15, 16}, + }, + { + {21, 22}, + {23, 24}, + {25, 26}, + }, + }, + }, + test::NDArray{ + {11, 21, 13, 23, 15, 25}, + {12, 22, 14, 24, 16, 26}, + }})); + +// input shape with size > 6 should be covered by reference implementation: +INSTANTIATE_TEST_CASE_P(reshape_opt_kernel_ref_impl_fallback, + ReshapeOptKernel, + ::testing::Values(TestParams{AxisOrder::straight, + test::NDArray{ + { + { + { + { + { + {11, 12}, + {13, 14}, + {15, 16}, + }, + { + {21, 22}, + {23, 24}, + {25, 26}, + }, + }, + }, + }, + }, + }, + test::NDArray{ + {11, 12, 13, 14, 15, 16}, + {21, 22, 23, 24, 25, 26}, + }}, + TestParams{AxisOrder::reverse, + test::NDArray{ + { + { + { + { + { + {11, 12}, + {13, 14}, + {15, 16}, + }, + { + {21, 22}, + {23, 24}, + {25, 26}, + }, + }, + }, + }, + }, + }, + test::NDArray{ + {11, 21, 13, 23, 15, 25}, + {12, 22, 14, 24, 16, 26}, + }})); diff --git a/ngraph/test/visitors/op/reshape.cpp b/ngraph/test/visitors/op/reshape.cpp index 8acad56678edb3..7d48e11442f8ad 100644 --- a/ngraph/test/visitors/op/reshape.cpp +++ b/ngraph/test/visitors/op/reshape.cpp @@ -30,5 +30,9 @@ TEST(attributes, reshape_op) NodeBuilder builder(reshape); auto g_reshape = as_type_ptr(builder.create()); + const auto expected_attr_count = 1; + + EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); + EXPECT_EQ(g_reshape->get_special_zero(), reshape->get_special_zero()); } From 134c66a9339477f3ba1e271cac6a7d7de25c5689 Mon Sep 17 00:00:00 2001 From: Gabriele Galiero Casay Date: Tue, 15 Jun 2021 11:06:30 +0200 Subject: [PATCH 081/178] Reference Implementation of Logical Reduce Operations (#6004) * Remove CoordinateTransform call to index function to calculate tensor element indexes * Allow negative axis values in axes host tensor * Added constant expression to set keep_dims as false * Use rank from host tensor to normalize axes * Address minor comments * Add const qualifier to local variables * Add deprecated macro for arm plugin dependent function signatures * Remove duplicate helper functions --- .../ngraph/runtime/reference/eval_helpers.hpp | 15 ---- .../runtime/reference/logical_reduction.hpp | 83 ++++++++++++------- .../src/runtime/reference/eval_helpers.cpp | 33 -------- ngraph/core/src/op/reduce_logical_and.cpp | 32 +++---- ngraph/core/src/op/reduce_logical_or.cpp | 32 +++---- ngraph/test/eval.cpp | 22 ----- 6 files changed, 87 insertions(+), 130 deletions(-) delete mode 100644 ngraph/core/reference/include/ngraph/runtime/reference/eval_helpers.hpp delete mode 100644 ngraph/core/reference/src/runtime/reference/eval_helpers.cpp diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/eval_helpers.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/eval_helpers.hpp deleted file mode 100644 index 935237778d15f6..00000000000000 --- a/ngraph/core/reference/include/ngraph/runtime/reference/eval_helpers.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "ngraph/runtime/host_tensor.hpp" - -namespace ngraph -{ - namespace eval - { - AxisSet extract_reduction_axes(const HostTensorPtr& axes, const char* op_name); - } -} // namespace ngraph diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/logical_reduction.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/logical_reduction.hpp index f9e24d89292992..f2789da27ded86 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/logical_reduction.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/logical_reduction.hpp @@ -5,6 +5,7 @@ #pragma once #include +#include #include "ngraph/coordinate_transform.hpp" #include "ngraph/shape_util.hpp" @@ -17,53 +18,75 @@ namespace ngraph { static inline void reduce_logical_and(const char* arg, char* out, - const Shape& input_shape, - const AxisSet& reduction_axes, - bool keep_dims) + const Shape& in_shape, + const AxisSet& reduction_axes) { - CoordinateTransform output_transform( - reduce(input_shape, reduction_axes, keep_dims)); + constexpr bool dont_keep_dims_in_output = false; + const auto out_shape = reduce(in_shape, reduction_axes, dont_keep_dims_in_output); + std::fill(out, out + shape_size(out_shape), 1); - for (const Coordinate& output_coord : output_transform) - { - out[output_transform.index(output_coord)] = 1; - } - - CoordinateTransform input_transform(input_shape); + const auto in_strides = row_major_strides(in_shape); + const auto out_strides = row_major_strides(out_shape); + CoordinateTransformBasic input_transform(in_shape); for (const Coordinate& input_coord : input_transform) { - Coordinate output_coord = reduce(input_coord, reduction_axes, keep_dims); - out[output_transform.index(output_coord)] = - out[output_transform.index(output_coord)] && - arg[input_transform.index(input_coord)]; + const Coordinate output_coord = + reduce(input_coord, reduction_axes, dont_keep_dims_in_output); + + const size_t in_idx = std::inner_product( + input_coord.begin(), input_coord.end(), in_strides.begin(), 0); + const size_t out_idx = std::inner_product( + output_coord.begin(), output_coord.end(), out_strides.begin(), 0); + + out[out_idx] = out[out_idx] && arg[in_idx]; } } + NGRAPH_DEPRECATED("Remove when arm plugin supports the new signature") + static inline void reduce_logical_and(const char* arg, + char* out, + const Shape& input_shape, + const AxisSet& reduction_axes, + bool) + { + reduce_logical_and(arg, out, input_shape, reduction_axes); + } + static inline void reduce_logical_or(const char* arg, char* out, - const Shape& input_shape, - const AxisSet& reduction_axes, - bool keep_dims) + const Shape& in_shape, + const AxisSet& reduction_axes) { - CoordinateTransform output_transform( - reduce(input_shape, reduction_axes, keep_dims)); + const auto out_shape = reduce(in_shape, reduction_axes, false); + std::fill(out, out + shape_size(out_shape), 0); - for (const Coordinate& output_coord : output_transform) - { - out[output_transform.index(output_coord)] = 0; - } - - CoordinateTransform input_transform(input_shape); + const auto in_strides = row_major_strides(in_shape); + const auto out_strides = row_major_strides(out_shape); + CoordinateTransformBasic input_transform(in_shape); for (const Coordinate& input_coord : input_transform) { - Coordinate output_coord = reduce(input_coord, reduction_axes, keep_dims); - out[output_transform.index(output_coord)] = - out[output_transform.index(output_coord)] || - arg[input_transform.index(input_coord)]; + const Coordinate output_coord = reduce(input_coord, reduction_axes, false); + + const size_t in_idx = std::inner_product( + input_coord.begin(), input_coord.end(), in_strides.begin(), 0); + const size_t out_idx = std::inner_product( + output_coord.begin(), output_coord.end(), out_strides.begin(), 0); + + out[out_idx] = out[out_idx] || arg[in_idx]; } } + + NGRAPH_DEPRECATED("Remove when arm plugin supports the new signature") + static inline void reduce_logical_or(const char* arg, + char* out, + const Shape& input_shape, + const AxisSet& reduction_axes, + bool) + { + reduce_logical_or(arg, out, input_shape, reduction_axes); + } } // namespace reference } // namespace runtime } // namespace ngraph diff --git a/ngraph/core/reference/src/runtime/reference/eval_helpers.cpp b/ngraph/core/reference/src/runtime/reference/eval_helpers.cpp deleted file mode 100644 index 9aae80310a347f..00000000000000 --- a/ngraph/core/reference/src/runtime/reference/eval_helpers.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include "ngraph/check.hpp" -#include "ngraph/runtime/reference/eval_helpers.hpp" -#include "ngraph/util.hpp" - -namespace ngraph -{ - namespace eval - { - AxisSet extract_reduction_axes(const HostTensorPtr& axes, const char* op_name) - { - const auto axes_in_tensor = host_tensor_2_vector(axes); - - const bool negative_axis_received = - std::any_of(axes_in_tensor.begin(), axes_in_tensor.end(), [](const int64_t axis) { - return axis < 0; - }); - - NGRAPH_CHECK(!negative_axis_received, - "Negative axis value received in the ", - op_name, - " evaluation. This case is not supported."); - - return AxisSet( - std::vector(axes_in_tensor.begin(), axes_in_tensor.end())); - } - } // namespace eval -} // namespace ngraph diff --git a/ngraph/core/src/op/reduce_logical_and.cpp b/ngraph/core/src/op/reduce_logical_and.cpp index c75c244d59056b..6b578c894ac4ec 100644 --- a/ngraph/core/src/op/reduce_logical_and.cpp +++ b/ngraph/core/src/op/reduce_logical_and.cpp @@ -3,10 +3,11 @@ // #include "ngraph/op/reduce_logical_and.hpp" +#include #include "itt.hpp" #include "ngraph/log.hpp" +#include "ngraph/op/util/evaluate_helpers.hpp" #include "ngraph/runtime/host_tensor.hpp" -#include "ngraph/runtime/reference/eval_helpers.hpp" #include "ngraph/runtime/reference/logical_reduction.hpp" using namespace ngraph; @@ -32,28 +33,20 @@ shared_ptr op::v1::ReduceLogicalAnd::clone_with_new_inputs(const OutputVec return make_shared(new_args.at(0), new_args.at(1), get_keep_dims()); } -namespace +namespace reduce_and { bool evaluate_reduce_logical_and(const HostTensorPtr& data, - const HostTensorPtr& axes, const HostTensorPtr& out, + const AxisSet& reduction_axes, bool keep_dims) { - if (data->get_element_type() != element::boolean || - !axes->get_element_type().is_integral_number()) - { - return false; - } + out->set_shape(reduce(data->get_shape(), reduction_axes, keep_dims)); try { - const AxisSet reduction_axes = eval::extract_reduction_axes(axes, "ReduceLogicalAnd"); - runtime::reference::reduce_logical_and(data->get_data_ptr(), out->get_data_ptr(), data->get_shape(), - reduction_axes, - keep_dims); - + reduction_axes); return true; } catch (const ngraph_error& e) @@ -62,16 +55,25 @@ namespace return false; } } -} // namespace +} // namespace reduce_and bool op::v1::ReduceLogicalAnd::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { NGRAPH_OP_SCOPE(v1_ReduceLogicalAnd_evaluate); + NGRAPH_CHECK(validate_host_tensor_vector(inputs, 2)); + NGRAPH_CHECK(validate_host_tensor_vector(outputs, 1)); const auto& data = inputs[0]; const auto& axes = inputs[1]; const auto& out = outputs[0]; - return evaluate_reduce_logical_and(data, axes, out, get_keep_dims()); + if (data->get_element_type() != element::boolean || + !axes->get_element_type().is_integral_number()) + { + return false; + } + const auto reduction_axes = get_normalized_axes_from_tensor( + axes, data->get_partial_shape().rank(), get_friendly_name()); + return reduce_and::evaluate_reduce_logical_and(data, out, reduction_axes, get_keep_dims()); } bool op::v1::ReduceLogicalAnd::has_evaluate() const diff --git a/ngraph/core/src/op/reduce_logical_or.cpp b/ngraph/core/src/op/reduce_logical_or.cpp index a6afa5f77c8503..427b576bf9138e 100644 --- a/ngraph/core/src/op/reduce_logical_or.cpp +++ b/ngraph/core/src/op/reduce_logical_or.cpp @@ -3,10 +3,11 @@ // #include "ngraph/op/reduce_logical_or.hpp" +#include #include "itt.hpp" #include "ngraph/log.hpp" +#include "ngraph/op/util/evaluate_helpers.hpp" #include "ngraph/runtime/host_tensor.hpp" -#include "ngraph/runtime/reference/eval_helpers.hpp" #include "ngraph/runtime/reference/logical_reduction.hpp" using namespace ngraph; @@ -32,28 +33,20 @@ shared_ptr op::v1::ReduceLogicalOr::clone_with_new_inputs(const OutputVect return make_shared(new_args.at(0), new_args.at(1), get_keep_dims()); } -namespace +namespace reduce_or { bool evaluate_reduce_logical_or(const HostTensorPtr& data, - const HostTensorPtr& axes, const HostTensorPtr& out, + const AxisSet& reduction_axes, bool keep_dims) { - if (data->get_element_type() != element::boolean || - !axes->get_element_type().is_integral_number()) - { - return false; - } + out->set_shape(reduce(data->get_shape(), reduction_axes, keep_dims)); try { - const AxisSet reduction_axes = eval::extract_reduction_axes(axes, "ReduceLogicalOr"); - runtime::reference::reduce_logical_or(data->get_data_ptr(), out->get_data_ptr(), data->get_shape(), - reduction_axes, - keep_dims); - + reduction_axes); return true; } catch (const ngraph_error& e) @@ -62,16 +55,25 @@ namespace return false; } } -} // namespace +} // namespace reduce_or bool op::v1::ReduceLogicalOr::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { NGRAPH_OP_SCOPE(v1_ReduceLogicalOr_evaluate); + NGRAPH_CHECK(validate_host_tensor_vector(inputs, 2)); + NGRAPH_CHECK(validate_host_tensor_vector(outputs, 1)); const auto& data = inputs[0]; const auto& axes = inputs[1]; const auto& out = outputs[0]; - return evaluate_reduce_logical_or(data, axes, out, get_keep_dims()); + if (data->get_element_type() != element::boolean || + !axes->get_element_type().is_integral_number()) + { + return false; + } + const auto reduction_axes = get_normalized_axes_from_tensor( + axes, data->get_partial_shape().rank(), get_friendly_name()); + return reduce_or::evaluate_reduce_logical_or(data, out, reduction_axes, get_keep_dims()); } bool op::v1::ReduceLogicalOr::has_evaluate() const diff --git a/ngraph/test/eval.cpp b/ngraph/test/eval.cpp index f5602023c5c675..1ba827190ae0fb 100644 --- a/ngraph/test/eval.cpp +++ b/ngraph/test/eval.cpp @@ -1810,28 +1810,6 @@ TEST(eval, topk_v1_param_dyn_k0) ASSERT_EQ(result1_val, expec1); } -TEST(eval, reduce_logical_and__neg_axis) -{ - const auto data = make_shared(element::boolean, Shape{2, 2, 2}); - const auto axes = make_shared(element::i64, Shape{}); - - const auto op = make_shared(data, axes); - - auto fun = make_shared(op, ParameterVector{data, axes}); - - auto result = make_shared(); - - // when ReduceLogicalAnd node evaluator returns false -> the Function object throws - EXPECT_THROW( - fun->evaluate({result}, - { - make_host_tensor( - Shape{2, 2, 2}, {true, false, true, false, true, false, true, false}), - make_host_tensor(Shape{}, {-1}), - }), - ngraph::ngraph_error); -} - TEST(eval, evaluate_static_scatter_update_basic_axes_indices_i32) { const Shape data_shape{3, 3}; From d777679de94559f4f2626a5d27caecce18ec4dc3 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Tue, 15 Jun 2021 13:19:58 +0300 Subject: [PATCH 082/178] Added copyrights note into CMakeLists (#6155) --- thirdparty/zlib/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/thirdparty/zlib/CMakeLists.txt b/thirdparty/zlib/CMakeLists.txt index b24d4abf323cd0..33b9222ec53103 100644 --- a/thirdparty/zlib/CMakeLists.txt +++ b/thirdparty/zlib/CMakeLists.txt @@ -1,3 +1,7 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + PROJECT(zlib) if(NOT WIN32) From 67c93ec6fa0954a8d9977a93b7ab56edc73858b2 Mon Sep 17 00:00:00 2001 From: Alina Kladieva Date: Tue, 15 Jun 2021 13:47:06 +0300 Subject: [PATCH 083/178] Return sporadic GPU test cases (cannot reproduce 54436) (#6127) --- .../plugin/gpu/shared_tests_instances/skip_tests_config.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp index 07bd2a260984aa..5863309efe4fcf 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp @@ -52,9 +52,6 @@ std::vector disabledTestPatterns() { R"(.*(LPT/StridedSliceTransformation).*)", // TODO: Issue: 48106 R"(.*ConstantResultSubgraphTest.*inPrc=I16.*)", - // TODO: Issue: 54436 - R"(.*LSTMSequence.*CompareWithRefs.*mode=PURE_SEQ_RAND_SEQ_LEN_PARAM.*direction=bidirectional_clip=0.7_netPRC=FP32.*)", - R"(.*LSTMSequence.*CompareWithRefs.*mode=CONVERT_TO_TI_RAND_SEQ_LEN_PARAM_seq.*direction=bidirectional_clip=0.7_netPRC=FP32.*)", // TODO: Issue: 54194 R"(.*ActivationLayerTest.*SoftPlus.*)", // need to implement Export / Import From a248d84894ddf8681192c40dbfc2a9fa90b9d5f0 Mon Sep 17 00:00:00 2001 From: Katarzyna Mitrus Date: Tue, 15 Jun 2021 14:02:37 +0200 Subject: [PATCH 084/178] [Spec] ShuffleChannels spec update (#5813) --- docs/ops/movement/ShuffleChannels_1.md | 47 ++++++++++++++++++-------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/docs/ops/movement/ShuffleChannels_1.md b/docs/ops/movement/ShuffleChannels_1.md index ec7cfc75d9db6f..e97f3350d2a405 100644 --- a/docs/ops/movement/ShuffleChannels_1.md +++ b/docs/ops/movement/ShuffleChannels_1.md @@ -8,12 +8,37 @@ **Short description**: *ShuffleChannels* permutes data in the channel dimension of the input tensor. +**Detailed description**: + +Input tensor of `data_shape` is always interpreted as 4D tensor with the following shape: + + dim 0: data_shape[0] * data_shape[1] * ... * data_shape[axis-1] + (or 1 if axis == 0) + dim 1: group + dim 2: data_shape[axis] / group + dim 3: data_shape[axis+1] * data_shape[axis+2] * ... * data_shape[data_shape.size()-1] + (or 1 if axis points to last dimension) + + +Trailing and leading to `axis` dimensions are flattened and reshaped back to the original shape after channels shuffling. + + +The operation is equivalent to the following transformation of the input tensor `x` of shape `[N, C, H, W]` and `axis = 1`: + +\f[ +x' = reshape(x, [N, group, C / group, H * W])\\ +x'' = transpose(x', [0, 2, 1, 3])\\ +y = reshape(x'', [N, C, H, W])\\ +\f] + +where `group` is the layer attribute described below. + **Attributes**: * *axis* * **Description**: *axis* specifies the index of a channel dimension. - * **Range of values**: an integer number in the range [-4, 3] + * **Range of values**: an integer number in the range `[-rank(data_shape), rank(data_shape) - 1]` * **Type**: `int` * **Default value**: 1 * **Required**: *No* @@ -21,30 +46,22 @@ * *group* * **Description**: *group* specifies the number of groups to split the channel dimension into. This number must evenly divide the channel dimension size. - * **Range of values**: a positive integer + * **Range of values**: a positive integer in the range `[1, data_shape[axis]]` * **Type**: `int` * **Default value**: 1 * **Required**: *No* **Inputs**: -* **1**: 4D input tensor of any supported data type. Required. +* **1**: `data` input tensor of type *T* and rank greater or equal to 1. **Required.** **Outputs**: -* **1**: 4D input tensor with shape and element type as for the input tensor. +* **1**: Output tensor with element type *T* and same shape as the input tensor. -**Mathematical Formulation** +**Types** -The operation is the equivalent with the following transformation of the input tensor *x* of shape *[N, C, H, W]*: - -``` -x' = reshape(x, [N, group, C / group, H * W]) -x'' = transpose(x', [0, 2, 1, 3]) -y = reshape(x'', [N, C, H, W]) -``` - -where `group` is the layer parameter described above and the `axis = 1`. +* *T*: any supported numeric type. **Example** @@ -68,4 +85,4 @@ where `group` is the layer parameter described above and the `axis = 1`. -``` \ No newline at end of file +``` From d7b2e4e50ec4b7ee7a7b21aae36a7be853e3b349 Mon Sep 17 00:00:00 2001 From: Bartek Szmelczynski Date: Tue, 15 Jun 2021 14:24:40 +0200 Subject: [PATCH 085/178] revise space_to_batch spec (#5767) * refactor part of the docs file to use \dots * refector docs * add function enclosure for docs * split function enclosurs across lines * add latex operations to spec * fix style * fix missing index * remove link to tensorflow operation * Remove commas from formula. Co-authored-by: jdanieck --- docs/ops/movement/SpaceToBatch_2.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/ops/movement/SpaceToBatch_2.md b/docs/ops/movement/SpaceToBatch_2.md index 66c064e27bee35..eea9df8ced1acf 100644 --- a/docs/ops/movement/SpaceToBatch_2.md +++ b/docs/ops/movement/SpaceToBatch_2.md @@ -8,20 +8,20 @@ **Detailed description**: -The *SpaceToBatch* operation is similar to the TensorFlow* operation [SpaceToBatchND](https://www.tensorflow.org/api_docs/python/tf/space_to_batch_nd) - The operation is equivalent to the following transformation of the input tensor `data` of shape `[batch, D_1, D_2 ... D_{N - 1}]` and `block_shape`, `pads_begin`, `pads_end` of shapes `[N]` to *Y* output tensor. - Zero-pad the start and end of dimensions [D_0, ..., D_{N - 1}] of the input according to `pads_begin` and `pads_end`: - note: P_0 for batch dimension is expected to be 0 (no-padding). - x = [batch + P_0, D_1 + P_1, D_2 + P_2, ..., D_{N - 1} + P_{N - 1}], where P_i = pads_begin[i] + pads_end[i] - - note: B_0 for batch is ignored. - x' = reshape(x, [batch, (D_1 + P_1) / B_1, B_1, (D_2 + P_2) / B_2, B_2, ..., (D_{N - 1} + P_{N - 1}) / B_{N - 1}, B_{N - 1}]), where B_i = block_shape[i] +Zero-pad the start and end of dimensions \f$[D_0, \dots, D_{N - 1}]\f$ of the input according to `pads_begin` and `pads_end`: - x'' = transpose(x', [2, 4, ..., (N - 1) + (N - 1), 0, 1, 3, ..., N + (N - 1)]) +\f[x = [batch + P_0, D_1 + P_1, D_2 + P_2, \dots, D_{N - 1} + P_{N - 1}]\f] +\f[x' = reshape(x, [batch, \frac{D_1 + P_1}{B_1}, B_1, \frac{D_2 + P_2}{B_2}, B_2, \dots, \frac{D_{N - 1} + P_{N - 1}}{B_{N - 1}}, B_{N - 1}])\f] +\f[x'' = transpose(x', [2, 4, \dots, (N - 1) + (N - 1), 0, 1, 3, \dots, N + (N - 1)])\f] +\f[y = reshape(x'', [batch \times B_1 \times \dots \times B_{N - 1}, \frac{D_1 + P_1}{B_1}, \frac{D_2 + P_2}{B_2}, \dots, \frac{D_{N - 1} + P_{N - 1}}{B_{N - 1}}]\f] - y = reshape(x'', [batch * B_1 * ... * B_{N - 1}, (D_1 + P_1) / B_1, (D_2 + P_2) / B_2, ... , (D_{N - 1} + P_{N - 1}) / B_{N - 1}]) +where +- \f$P_i\f$ = pads_begin[i] + pads_end[i] +- \f$B_i\f$ = block_shape[i] +- \f$P_0\f$ for batch dimension is expected to be 0 (no-padding) +- \f$B_0\f$ for batch is ignored **Attributes** @@ -36,7 +36,7 @@ The operation is equivalent to the following transformation of the input tensor **Outputs** -* **1**: N-D tensor with shape `[batch * block_shape[0] * block_shape[1] * ... * block_shape[N - 1], (pads_begin[1] + D_1 + pads_end[1]) / block_shape[1], (pads_begin[2] + D_2 + pads_end[2]) / block_shape[2], ..., (pads_begin[N - 1] + D_{N - 1} + pads_end[N - 1]) / block_shape[N - 1]` of the same type as `data` input. +* **1**: N-D tensor with shape `[batch * block_shape[0] * block_shape[1] * ... * block_shape[N - 1], (D_1 + pads_begin[1] + pads_end[1]) / block_shape[1], (D_2 + pads_begin[2] + pads_end[2]) / block_shape[2], ..., (D_{N -1} + pads_begin[N - 1] + pads_end[N - 1]) / block_shape[N - 1]` of the same type as `data` input. **Types** From 5ebdcfe15b36d587e323da949f3deaaea21b78c4 Mon Sep 17 00:00:00 2001 From: Jozef Daniecki Date: Tue, 15 Jun 2021 14:35:47 +0200 Subject: [PATCH 086/178] StridedSlice operation specification refactoring (#5887) * StridedSlice spec refactored against explicit type indication. * Add name to data input. * Add new examples. * Changed T to 'any supported type'. * Remove mention about 'generalized python indexing' from short description. --- docs/ops/movement/StridedSlice_1.md | 97 +++++++++++++++++++++++------ 1 file changed, 79 insertions(+), 18 deletions(-) diff --git a/docs/ops/movement/StridedSlice_1.md b/docs/ops/movement/StridedSlice_1.md index 6c07665d8f930c..41742e20652b13 100644 --- a/docs/ops/movement/StridedSlice_1.md +++ b/docs/ops/movement/StridedSlice_1.md @@ -4,14 +4,13 @@ **Category**: Data movement operation -**Short description**: *StridedSlice* extracts a strided slice of a tensor. - It is similar to generalized array indexing in Python\*. +**Short description**: *StridedSlice* extracts a strided slice of a tensor. **Attributes** * *begin_mask* - * **Description**: *begin_mask* is a bit mask. *begin_mask[i]* equal to 1 means that the corresponding dimension of the `begin` input is ignored and the 'real' beginning of the tensor is used along corresponding dimension. + * **Description**: *begin_mask* is a bit mask. *begin_mask[i]* equal to `1` means that the corresponding dimension of the `begin` input is ignored and the 'real' beginning of the tensor is used along corresponding dimension. * **Range of values**: a list of `0`s and `1`s * **Type**: `int[]` * **Default value**: None @@ -19,7 +18,7 @@ * *end_mask* - * **Description**: *end_mask* is a bit mask. If *end_mask[i]* is 1, the corresponding dimension of the `end` input is ignored and the real 'end' of the tensor is used along corresponding dimension. + * **Description**: *end_mask* is a bit mask. If *end_mask[i]* is `1`, the corresponding dimension of the `end` input is ignored and the real 'end' of the tensor is used along corresponding dimension. * **Range of values**: a list of `0`s and `1`s * **Type**: `int[]` * **Default value**: None @@ -27,7 +26,7 @@ * *new_axis_mask* - * **Description**: *new_axis_mask* is a bit mask. If *new_axis_mask[i]* is 1, a length 1 dimension is inserted on the `i`-th position of input tensor. + * **Description**: *new_axis_mask* is a bit mask. If *new_axis_mask[i]* is `1`, a length 1 dimension is inserted on the `i`-th position of input tensor. * **Range of values**: a list of `0`s and `1`s * **Type**: `int[]` * **Default value**: `[0]` @@ -35,7 +34,7 @@ * *shrink_axis_mask* - * **Description**: *shrink_axis_mask* is a bit mask. If *shrink_axis_mask[i]* is 1, the dimension on the `i`-th position is deleted. + * **Description**: *shrink_axis_mask* is a bit mask. If *shrink_axis_mask[i]* is `1`, the dimension on the `i`-th position is deleted. * **Range of values**: a list of `0`s and `1`s * **Type**: `int[]` * **Default value**: `[0]` @@ -51,21 +50,83 @@ **Inputs**: -* **1**: Multidimensional input tensor to be sliced. Required. +* **1**: `data` - input tensor to be sliced of type `T` and arbitrary shape. **Required.** -* **2**: `begin` input - 1D input tensor with begin indexes for input tensor slicing. Required. - Out-of-bounds values are silently clamped. If `begin_mask[i]` is 1, the value of `begin[i]` is ignored - and the range of the appropriate dimension starts from 0. - Negative values mean indexing starts from the end. For example, if `foo=[1,2,3]`, `begin[0]=-1` means `begin[0]=3`. +* **2**: `begin` - 1D tensor of type `T_IND` with begin indexes for input tensor slicing. **Required.** + Out-of-bounds values are silently clamped. If `begin_mask[i]` is `1`, the value of `begin[i]` is ignored and the range of the appropriate dimension starts from `0`. Negative values mean indexing starts from the end. For example, if `data=[1,2,3]`, `begin[0]=-1` means `begin[0]=3`. -* **3**: `end` input - 1D input tensor with end indexes for input tensor slicing. Required. - Out-of-bounds values will be silently clamped. If `end_mask[i]` is 1, the value of `end[i]` is ignored - and the full range of the appropriate dimension is used instead. - Negative values mean indexing starts from the end. For example, if `foo=[1,2,3]`, `end[0]=-1` means `end[0]=3`. +* **3**: `end` - 1D tensor of type `T_IND` with end indexes for input tensor slicing. **Required.** + Out-of-bounds values will be silently clamped. If `end_mask[i]` is `1`, the value of `end[i]` is ignored and the full range of the appropriate dimension is used instead. Negative values mean indexing starts from the end. For example, if `data=[1,2,3]`, `end[0]=-1` means `end[0]=3`. -* **4**: `stride` input - 1D input tensor with strides. Optional. +* **4**: `stride` - 1D tensor of type `T_IND` with strides. **Optional.** -**Example** +**Types** +* *T*: any supported type. +* *T_IND*: any supported integer type. + +**Example** +Example of `begin_mask` & `end_mask` usage. +```xml + + + + + 2 + 3 + 4 + + + 2 + + + 2 + + + 2 + + + + + 1 + 3 + 2 + + + +``` + +Example of `new_axis_mask` usage. +```xml + + + + + 2 + 3 + 4 + + + 2 + + + 2 + + + 2 + + + + + 1 + 2 + 3 + 4 + + + +``` + +Example of `shrink_axis_mask` usage. ```xml @@ -96,4 +157,4 @@ -``` \ No newline at end of file +``` From db74707835cd2ed08e11dd38cbfac9c038b33def Mon Sep 17 00:00:00 2001 From: Patryk Elszkowski Date: Tue, 15 Jun 2021 15:08:36 +0200 Subject: [PATCH 087/178] Enable reshape test (#6161) --- ngraph/test/runtime/ie/unit_test.manifest | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/ngraph/test/runtime/ie/unit_test.manifest b/ngraph/test/runtime/ie/unit_test.manifest index e76ac6f2b97d91..1537b823c1795d 100644 --- a/ngraph/test/runtime/ie/unit_test.manifest +++ b/ngraph/test/runtime/ie/unit_test.manifest @@ -386,31 +386,12 @@ reduce_sum_large_1d_to_scalar # Doesn't throw expected exception type. unhandled_op -# Const layer Constant_6325 has incorrect dimensions in the output data 0 -reshape_t2s - # Expected equality of these values: # (vector{42}) # Which is: { '*' (42, 0x2A) } # read_vector(result) # Which is: { '\0' } reshape_s2t1 -reshape_v2m_col -reshape_v2m_row -reshape_v2t_middle -reshape_m2m_same -reshape_m2m_transpose -reshape_m2m_dim_change_transpose -reshape_3d_transpose_021 -reshape_3d_transpose_210 -reshape_3d_transpose_201 -reshape_3d_transpose_102 -reshape_3d_transpose_120 -reshape_4d_transpose -reshape_4d_no_transpose -reshape_transposed_shape_change -reshape_6d -reshape_shufflenet_5d dyn_group_convolution_backprop_data group_conv group_conv_striding From c3d1c2e420cd8f77b1e8a4946eedd1c1774c1287 Mon Sep 17 00:00:00 2001 From: Gabriele Galiero Casay Date: Tue, 15 Jun 2021 15:12:12 +0200 Subject: [PATCH 088/178] Revise reference implementation for ReduceMax operation (#5792) * Revise reference implementation for ReduceMax operation * Refactor backend unit tests * Move tests with zero dims to op_eval * Remove test with double elem type * Fix code style * Added minor changes * Replace CoordinateTransform for CoordinateTransformBasic * Added constant expression to set keep_dims as false * Add const qualifier to local variables * Use host tensor to retrieve and normalize axes --- .../ngraph/runtime/reference/log_softmax.hpp | 2 +- .../include/ngraph/runtime/reference/max.hpp | 35 +- .../ngraph/runtime/reference/softmax.hpp | 2 +- ngraph/core/src/op/max.cpp | 12 +- ngraph/test/CMakeLists.txt | 1 + ngraph/test/backend/reduce_max.in.cpp | 336 ------------------ ngraph/test/op_eval/reduce_max.cpp | 312 ++++++++++++++++ ngraph/test/runtime/ie/unit_test.manifest | 14 - .../runtime/interpreter/unit_test.manifest | 2 - 9 files changed, 343 insertions(+), 373 deletions(-) create mode 100644 ngraph/test/op_eval/reduce_max.cpp diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/log_softmax.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/log_softmax.hpp index 27198f465b30ff..2cf445ee54f367 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/log_softmax.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/log_softmax.hpp @@ -24,7 +24,7 @@ namespace ngraph auto temp_max = std::vector(temp_elements, 0); auto temp_sum = std::vector(temp_elements, 0); - max(arg, temp_max.data(), shape, axes, true); + max(arg, temp_max.data(), shape, axes); CoordinateTransform transform(shape); CoordinateTransform temp_transform(temp_shape); diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/max.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/max.hpp index d8e39fefd65aee..8bed66cdefbfe0 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/max.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/max.hpp @@ -6,6 +6,7 @@ #include #include +#include #include "ngraph/coordinate_transform.hpp" #include "ngraph/shape_util.hpp" @@ -17,35 +18,35 @@ namespace ngraph namespace reference { template - void max(const T* arg, - T* out, - const Shape& in_shape, - const AxisSet& reduction_axes, - bool keep_dims) + void max(const T* arg, T* out, const Shape& in_shape, const AxisSet& reduction_axes) { T minval = std::numeric_limits::has_infinity ? T(-std::numeric_limits::infinity()) : std::numeric_limits::min(); - auto out_shape = reduce(in_shape, reduction_axes, keep_dims); - CoordinateTransform output_transform(out_shape); + constexpr bool dont_keep_dims_in_output = false; + const auto out_shape = reduce(in_shape, reduction_axes, dont_keep_dims_in_output); + std::fill(out, out + shape_size(out_shape), minval); - for (const Coordinate& output_coord : output_transform) - { - out[output_transform.index(output_coord)] = minval; - } - - CoordinateTransform input_transform(in_shape); + const auto in_strides = row_major_strides(in_shape); + const auto out_strides = row_major_strides(out_shape); + CoordinateTransformBasic input_transform(in_shape); for (const Coordinate& input_coord : input_transform) { - Coordinate output_coord = reduce(input_coord, reduction_axes, keep_dims); + const Coordinate output_coord = + reduce(input_coord, reduction_axes, dont_keep_dims_in_output); + + const size_t in_idx = std::inner_product( + input_coord.begin(), input_coord.end(), in_strides.begin(), 0); + const size_t out_idx = std::inner_product( + output_coord.begin(), output_coord.end(), out_strides.begin(), 0); - T x = arg[input_transform.index(input_coord)]; - T max = out[output_transform.index(output_coord)]; + const T x = arg[in_idx]; + const T max = out[out_idx]; if (x > max) { - out[output_transform.index(output_coord)] = x; + out[out_idx] = x; } } } diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/softmax.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/softmax.hpp index 94cb0549b7310d..a8544177aec44e 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/softmax.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/softmax.hpp @@ -23,7 +23,7 @@ namespace ngraph auto temp_elements = shape_size(temp_shape); auto temp_ptr = new T[temp_elements]; - max(arg, temp_ptr, shape, axes, true); + max(arg, temp_ptr, shape, axes); CoordinateTransform transform(shape); CoordinateTransform temp_transform(temp_shape); diff --git a/ngraph/core/src/op/max.cpp b/ngraph/core/src/op/max.cpp index 318910aa70ce6c..f4332ef9317de7 100644 --- a/ngraph/core/src/op/max.cpp +++ b/ngraph/core/src/op/max.cpp @@ -3,8 +3,10 @@ // #include "ngraph/op/max.hpp" +#include #include "itt.hpp" #include "ngraph/graph_util.hpp" +#include "ngraph/op/util/evaluate_helpers.hpp" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/runtime/reference/max.hpp" #include "ngraph/shape_util.hpp" @@ -22,7 +24,7 @@ namespace maxop { out->set_shape(reduce(arg->get_shape(), axes, keep_dims)); runtime::reference::max( - arg->get_data_ptr(), out->get_data_ptr(), arg->get_shape(), axes, keep_dims); + arg->get_data_ptr(), out->get_data_ptr(), arg->get_shape(), axes); return true; } @@ -67,7 +69,13 @@ bool op::v1::ReduceMax::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { NGRAPH_OP_SCOPE(v1_ReduceMax_evaluate); - return maxop::evaluate_max(inputs[0], outputs[0], get_reduction_axes(), get_keep_dims()); + NGRAPH_CHECK(validate_host_tensor_vector(inputs, 2)); + NGRAPH_CHECK(validate_host_tensor_vector(outputs, 1)); + + const auto reduction_axes = get_normalized_axes_from_tensor( + inputs[1], inputs[0]->get_partial_shape().rank(), get_friendly_name()); + + return maxop::evaluate_max(inputs[0], outputs[0], reduction_axes, get_keep_dims()); } bool op::v1::ReduceMax::has_evaluate() const diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index 47dfbbd3e495b3..b9e65209bb8367 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -71,6 +71,7 @@ set(SRC op_eval/memory.cpp op_eval/mish.cpp op_eval/non_zero.cpp + op_eval/reduce_max.cpp op_eval/reduce_prod.cpp op_eval/reduce_sum.cpp op_eval/roi_align.cpp diff --git a/ngraph/test/backend/reduce_max.in.cpp b/ngraph/test/backend/reduce_max.in.cpp index a1288f416a8409..28c1a3b97cd343 100644 --- a/ngraph/test/backend/reduce_max.in.cpp +++ b/ngraph/test/backend/reduce_max.in.cpp @@ -104,123 +104,6 @@ NGRAPH_TEST(${BACKEND_NAME}, reduce_max_matrix_rows_int32) test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, reduce_max_matrix_rows_zero) -{ - Shape shape_a{3, 0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{3}; - auto axes = make_shared(element::i32, Shape{}, 1); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - // Create some tensors for input/output - std::vector a{}; - - auto test_case = test::TestCase(f); - test_case.add_input({a}); - test_case.add_expected_output(shape_rt, - {-std::numeric_limits::infinity(), - -std::numeric_limits::infinity(), - -std::numeric_limits::infinity()}); - test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_max_matrix_rows_zero_int32) -{ - Shape shape_a{3, 0}; - auto A = make_shared(element::i32, shape_a); - Shape shape_rt{3}; - auto axes = make_shared(element::i32, Shape{}, 1); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::i32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::i32, shape_rt); - copy_data(result, vector({3, 3, 3})); - - int32_t minval = std::numeric_limits::has_infinity - ? -std::numeric_limits::infinity() - : std::numeric_limits::min(); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_EQ((vector{minval, minval, minval}), read_vector(result)); - EXPECT_EQ((vector{}), read_vector(a)); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_max_matrix_cols_zero) -{ - // Now the reduction (g(x:float32[2,2],y:float32[]) = reduce(x,y,f,axes={})). - Shape shape_a{0, 2}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{2}; - auto axes = make_shared(element::i32, Shape{}, 0); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3, 3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_EQ((vector{-std::numeric_limits::infinity(), - -std::numeric_limits::infinity()}), - read_vector(result)); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_max_vector_zero) -{ - Shape shape_a{0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{}; - auto axes = make_shared(element::i32, Shape{}, 0); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_EQ((vector{-std::numeric_limits::infinity()}), read_vector(result)); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_max_matrix_to_scalar_zero_by_zero) -{ - Shape shape_a{0, 0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{}; - auto axes = make_shared(element::i32, Shape{2}, vector{0, 1}); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_EQ((vector{-std::numeric_limits::infinity()}), read_vector(result)); -} - NGRAPH_TEST(${BACKEND_NAME}, reduce_max_3d_to_matrix_most_sig) { Shape shape_a{3, 3, 3}; @@ -319,55 +202,6 @@ NGRAPH_TEST(${BACKEND_NAME}, reduce_max_3d_to_scalar_int32) EXPECT_EQ((vector{14}), read_vector(result)); } -NGRAPH_TEST(${BACKEND_NAME}, reduce_max_3d_to_scalar_double) -{ - Shape shape_a{3, 3, 3}; - auto A = make_shared(element::f64, shape_a); - Shape shape_rt{}; - auto axes = make_shared(element::i32, Shape{3}, vector{0, 1, 2}); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f64, shape_a); - copy_data(a, vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}); - auto result = backend->create_tensor(element::f64, shape_rt); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{14}), read_vector(result))); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_max_3d_eliminate_zero_dim) -{ - Shape shape_a{3, 0, 2}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{3, 2}; - auto axes = make_shared(element::i32, Shape{}, 1); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - - // Overwrite the initial result vector to make sure we're not just coincidentally getting the - // right value. - copy_data(result, vector{2112, 2112, 2112, 2112, 2112, 2112}); - - float mi = -std::numeric_limits::infinity(); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_EQ((vector{mi, mi, mi, mi, mi, mi}), read_vector(result)); -} - // ----------------------- keep dims = true ----------------------- // NGRAPH_TEST(${BACKEND_NAME}, reduce_max_keep_to_scalar) @@ -473,127 +307,6 @@ NGRAPH_TEST(${BACKEND_NAME}, reduce_max_keep_matrix_rows_int32) EXPECT_EQ((vector{2, 4, 6}), read_vector(result)); } -NGRAPH_TEST(${BACKEND_NAME}, reduce_max_keep_matrix_rows_zero) -{ - Shape shape_a{3, 0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{3, 1}; - auto axes = make_shared(element::i32, Shape{}, 1); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3, 3, 3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_EQ((vector{-std::numeric_limits::infinity(), - -std::numeric_limits::infinity(), - -std::numeric_limits::infinity()}), - read_vector(result)); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_max_keep_matrix_rows_zero_int32) -{ - Shape shape_a{3, 0}; - auto A = make_shared(element::i32, shape_a); - Shape shape_rt{3, 1}; - auto axes = make_shared(element::i32, Shape{}, 1); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::i32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::i32, shape_rt); - copy_data(result, vector({3, 3, 3})); - - int32_t minval = std::numeric_limits::has_infinity - ? -std::numeric_limits::infinity() - : std::numeric_limits::min(); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_EQ((vector{minval, minval, minval}), read_vector(result)); - EXPECT_EQ((vector{}), read_vector(a)); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_max_keep_matrix_cols_zero) -{ - // Now the reduction (g(x:float32[2,2],y:float32[]) = reduce(x,y,f,axes={})). - Shape shape_a{0, 2}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{1, 2}; - auto axes = make_shared(element::i32, Shape{}, 0); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3, 3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_EQ((vector{-std::numeric_limits::infinity(), - -std::numeric_limits::infinity()}), - read_vector(result)); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_max_keep_vector_zero) -{ - Shape shape_a{0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{1}; - auto axes = make_shared(element::i32, Shape{}, 0); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_EQ((vector{-std::numeric_limits::infinity()}), read_vector(result)); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_max_keep_matrix_to_scalar_zero_by_zero) -{ - Shape shape_a{0, 0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{1, 1}; - auto axes = make_shared(element::i32, Shape{2}, vector{0, 1}); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_EQ((vector{-std::numeric_limits::infinity()}), read_vector(result)); -} - NGRAPH_TEST(${BACKEND_NAME}, reduce_max_keep_3d_to_matrix_most_sig) { Shape shape_a{3, 3, 3}; @@ -711,55 +424,6 @@ NGRAPH_TEST(${BACKEND_NAME}, reduce_max_keep_3d_to_scalar_int32) EXPECT_EQ((vector{14}), read_vector(result)); } -NGRAPH_TEST(${BACKEND_NAME}, reduce_max_keep_3d_to_scalar_double) -{ - Shape shape_a{3, 3, 3}; - auto A = make_shared(element::f64, shape_a); - Shape shape_rt{1, 1, 1}; - auto axes = make_shared(element::i32, Shape{3}, vector{0, 1, 2}); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f64, shape_a); - copy_data(a, vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}); - auto result = backend->create_tensor(element::f64, shape_rt); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{14}), read_vector(result))); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_max_keep_3d_eliminate_zero_dim) -{ - Shape shape_a{3, 0, 2}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{3, 1, 2}; - auto axes = make_shared(element::i32, Shape{}, 1); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - - // Overwrite the initial result vector to make sure we're not just coincidentally getting the - // right value. - copy_data(result, vector{2112, 2112, 2112, 2112, 2112, 2112}); - - float mi = -std::numeric_limits::infinity(); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_EQ((vector{mi, mi, mi, mi, mi, mi}), read_vector(result)); -} - // Dynamic NGRAPH_TEST(${BACKEND_NAME}, reduce_max_matrix_columns_dynamic) diff --git a/ngraph/test/op_eval/reduce_max.cpp b/ngraph/test/op_eval/reduce_max.cpp new file mode 100644 index 00000000000000..2ce244f9eb204b --- /dev/null +++ b/ngraph/test/op_eval/reduce_max.cpp @@ -0,0 +1,312 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "util/test_control.hpp" +#include "util/all_close.hpp" +#include "util/all_close_f.hpp" +#include "util/ndarray.hpp" + + +using namespace std; +using namespace ngraph; + +static string s_manifest = "${MANIFEST}"; + +TEST(op_eval, reduce_max_matrix_rows_zero) +{ + Shape shape_a{3, 0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{3}; + auto axes = make_shared(element::i32, Shape{}, 1); + auto f = + make_shared(make_shared(A, axes, false), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3, 3, 3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + + EXPECT_EQ((vector{-std::numeric_limits::infinity(), + -std::numeric_limits::infinity(), + -std::numeric_limits::infinity()}), read_vector(result)); +} + +TEST(op_eval, reduce_max_matrix_rows_zero_int32) +{ + Shape shape_a{3, 0}; + auto A = make_shared(element::i32, shape_a); + Shape shape_rt{3}; + auto axes = make_shared(element::i32, Shape{}, 1); + auto f = + make_shared(make_shared(A, axes, false), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::i32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::i32, shape_rt); + copy_data(result, vector({3, 3, 3})); + + int32_t minval = std::numeric_limits::has_infinity + ? -std::numeric_limits::infinity() + : std::numeric_limits::min(); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_EQ((vector{minval, minval, minval}), read_vector(result)); + EXPECT_EQ((vector{}), read_vector(a)); +} + +TEST(op_eval, reduce_max_matrix_cols_zero) +{ + // Now the reduction (g(x:float32[2,2],y:float32[]) = reduce(x,y,f,axes={})). + Shape shape_a{0, 2}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{2}; + auto axes = make_shared(element::i32, Shape{}, 0); + auto f = + make_shared(make_shared(A, axes, false), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3, 3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_EQ((vector{-std::numeric_limits::infinity(), + -std::numeric_limits::infinity()}), + read_vector(result)); +} + +TEST(op_eval, reduce_max_vector_zero) +{ + Shape shape_a{0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{}; + auto axes = make_shared(element::i32, Shape{}, 0); + auto f = + make_shared(make_shared(A, axes, false), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_EQ((vector{-std::numeric_limits::infinity()}), read_vector(result)); +} + +TEST(op_eval, reduce_max_matrix_to_scalar_zero_by_zero) +{ + Shape shape_a{0, 0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{}; + auto axes = make_shared(element::i32, Shape{2}, vector{0, 1}); + auto f = + make_shared(make_shared(A, axes, false), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_EQ((vector{-std::numeric_limits::infinity()}), read_vector(result)); +} + +TEST(op_eval, reduce_max_3d_eliminate_zero_dim) +{ + Shape shape_a{3, 0, 2}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{3, 2}; + auto axes = make_shared(element::i32, Shape{}, 1); + auto f = + make_shared(make_shared(A, axes, false), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + + // Overwrite the initial result vector to make sure we're not just coincidentally getting the + // right value. + copy_data(result, vector{2112, 2112, 2112, 2112, 2112, 2112}); + + float mi = -std::numeric_limits::infinity(); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_EQ((vector{mi, mi, mi, mi, mi, mi}), read_vector(result)); +} + +TEST(op_eval, reduce_max_keep_matrix_rows_zero) +{ + Shape shape_a{3, 0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{3, 1}; + auto axes = make_shared(element::i32, Shape{}, 1); + auto f = + make_shared(make_shared(A, axes, true), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3, 3, 3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_EQ((vector{-std::numeric_limits::infinity(), + -std::numeric_limits::infinity(), + -std::numeric_limits::infinity()}), + read_vector(result)); +} + +TEST(op_eval, reduce_max_keep_matrix_rows_zero_int32) +{ + Shape shape_a{3, 0}; + auto A = make_shared(element::i32, shape_a); + Shape shape_rt{3, 1}; + auto axes = make_shared(element::i32, Shape{}, 1); + auto f = + make_shared(make_shared(A, axes, true), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::i32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::i32, shape_rt); + copy_data(result, vector({3, 3, 3})); + + int32_t minval = std::numeric_limits::has_infinity + ? -std::numeric_limits::infinity() + : std::numeric_limits::min(); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_EQ((vector{minval, minval, minval}), read_vector(result)); + EXPECT_EQ((vector{}), read_vector(a)); +} + +TEST(op_eval, reduce_max_keep_matrix_cols_zero) +{ + // Now the reduction (g(x:float32[2,2],y:float32[]) = reduce(x,y,f,axes={})). + Shape shape_a{0, 2}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{1, 2}; + auto axes = make_shared(element::i32, Shape{}, 0); + auto f = + make_shared(make_shared(A, axes, true), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3, 3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_EQ((vector{-std::numeric_limits::infinity(), + -std::numeric_limits::infinity()}), + read_vector(result)); +} + +TEST(op_eval, reduce_max_keep_vector_zero) +{ + Shape shape_a{0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{1}; + auto axes = make_shared(element::i32, Shape{}, 0); + auto f = + make_shared(make_shared(A, axes, true), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_EQ((vector{-std::numeric_limits::infinity()}), read_vector(result)); +} + +TEST(op_eval, reduce_max_keep_matrix_to_scalar_zero_by_zero) +{ + Shape shape_a{0, 0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{1, 1}; + auto axes = make_shared(element::i32, Shape{2}, vector{0, 1}); + auto f = + make_shared(make_shared(A, axes, true), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_EQ((vector{-std::numeric_limits::infinity()}), read_vector(result)); +} + +TEST(op_eval, reduce_max_keep_3d_eliminate_zero_dim) +{ + Shape shape_a{3, 0, 2}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{3, 1, 2}; + auto axes = make_shared(element::i32, Shape{}, 1); + auto f = + make_shared(make_shared(A, axes, true), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + + // Overwrite the initial result vector to make sure we're not just coincidentally getting the + // right value. + copy_data(result, vector{2112, 2112, 2112, 2112, 2112, 2112}); + + float mi = -std::numeric_limits::infinity(); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_EQ((vector{mi, mi, mi, mi, mi, mi}), read_vector(result)); +} \ No newline at end of file diff --git a/ngraph/test/runtime/ie/unit_test.manifest b/ngraph/test/runtime/ie/unit_test.manifest index 1537b823c1795d..a0a7c8735f58d3 100644 --- a/ngraph/test/runtime/ie/unit_test.manifest +++ b/ngraph/test/runtime/ie/unit_test.manifest @@ -474,21 +474,7 @@ reduce_mean_matrix_rows_int32 reduce_mean_keep_to_scalar_int8 reduce_mean_keep_matrix_rows_int32 reduce_max_to_scalar_int8 -reduce_max_matrix_rows_zero -reduce_max_matrix_rows_zero_int32 -reduce_max_matrix_cols_zero -reduce_max_vector_zero -reduce_max_matrix_to_scalar_zero_by_zero -reduce_max_3d_to_scalar_double -reduce_max_3d_eliminate_zero_dim reduce_max_keep_to_scalar_int8 -reduce_max_keep_matrix_rows_zero -reduce_max_keep_matrix_rows_zero_int32 -reduce_max_keep_matrix_cols_zero -reduce_max_keep_vector_zero -reduce_max_keep_matrix_to_scalar_zero_by_zero -reduce_max_keep_3d_to_scalar_double -reduce_max_keep_3d_eliminate_zero_dim # Incorrect precision f64! sum_trivial_in_double diff --git a/ngraph/test/runtime/interpreter/unit_test.manifest b/ngraph/test/runtime/interpreter/unit_test.manifest index 9e1231491521e3..799025f3b92752 100644 --- a/ngraph/test/runtime/interpreter/unit_test.manifest +++ b/ngraph/test/runtime/interpreter/unit_test.manifest @@ -41,9 +41,7 @@ INTERPRETER.reduce_min_keep_to_scalar_int8 INTERPRETER.reduce_mean_to_scalar_int8 INTERPRETER.reduce_mean_keep_to_scalar_int8 INTERPRETER.reduce_max_to_scalar_int8 -INTERPRETER.reduce_max_3d_to_scalar_double INTERPRETER.reduce_max_keep_to_scalar_int8 -INTERPRETER.reduce_max_keep_3d_to_scalar_double INTERPRETER.product_to_scalar_int8 INTERPRETER.max_pool_uint8 INTERPRETER.max_pool_int8 From b4e6028f8b4bdc8fca3bb646b31688bd0d894cf9 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Tue, 15 Jun 2021 16:29:26 +0300 Subject: [PATCH 089/178] Fixed shellcheck issues (#6141) --- CMakeLists.txt | 9 +++-- .../scripts/run_tests_myriad_multistick.sh | 2 +- scripts/demo/demo_benchmark_app.sh | 26 ++++++------- scripts/demo/demo_security_barrier_camera.sh | 20 +++++----- .../demo_squeezenet_download_convert_run.sh | 27 +++++++------ scripts/demo/utils.sh | 2 + .../install_4_14_kernel.sh | 38 +++++++++---------- .../install_NCS_udev_rules.sh | 2 - 8 files changed, 63 insertions(+), 63 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0706a72e87e74..3602750435c550 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -169,10 +169,11 @@ ie_shellcheck_process(DIRECTORY "${OpenVINO_MAIN_SOURCE_DIR}" "${IE_MAIN_SOURCE_DIR}/thirdparty" "${IE_MAIN_SOURCE_DIR}/temp" # TODO fix and enable back: - "${OpenVINO_MAIN_SOURCE_DIR}/scripts/install_dependencies" - "${OpenVINO_MAIN_SOURCE_DIR}/scripts/demo" - "${OpenVINO_MAIN_SOURCE_DIR}/ngraph" - "${IE_MAIN_SOURCE_DIR}/scripts") + "${OpenVINO_MAIN_SOURCE_DIR}/inference-engine/scripts/dependencies.sh" + "${OpenVINO_MAIN_SOURCE_DIR}/scripts/install_dependencies/install_NEO_OCL_driver.sh" + "${OpenVINO_MAIN_SOURCE_DIR}/scripts/install_dependencies/install_openvino_dependencies.sh" + "${OpenVINO_MAIN_SOURCE_DIR}/ngraph/python/tests/test_onnx/model_zoo_preprocess.sh" + ) # # cpack diff --git a/inference-engine/scripts/run_tests_myriad_multistick.sh b/inference-engine/scripts/run_tests_myriad_multistick.sh index 468817c6f75109..73befb9b366e2d 100755 --- a/inference-engine/scripts/run_tests_myriad_multistick.sh +++ b/inference-engine/scripts/run_tests_myriad_multistick.sh @@ -55,7 +55,7 @@ fi if [[ "${APPS_TO_RUN}" -ge 4 ]] ; then # For more then 4 multidevice testing - for (( VAR = 4; VAR <= ${APPS_TO_RUN}; ++VAR )); do + for (( VAR = 4; VAR <= APPS_TO_RUN; ++VAR )); do ./${APP_NAME} --gtest_filter=*VPURegTest*YOLO*myriad* & pids+=" $!" done diff --git a/scripts/demo/demo_benchmark_app.sh b/scripts/demo/demo_benchmark_app.sh index 8c84e8a724ef4c..25d1f94ae8eca7 100755 --- a/scripts/demo/demo_benchmark_app.sh +++ b/scripts/demo/demo_benchmark_app.sh @@ -50,7 +50,7 @@ fi target_precision="FP16" -printf "target_precision = ${target_precision}\n" +printf "target_precision = %s\n" ${target_precision} models_path="$HOME/openvino_models/models" models_cache="$HOME/openvino_models/cache" @@ -71,12 +71,12 @@ else fi if ! . "$setupvars_path" ; then - printf "Unable to run ./setupvars.sh. Please check its presence. ${run_again}" + printf "Unable to run ./setupvars.sh. Please check its presence. %s" "${run_again}" exit 1 fi # Step 1. Download the Caffe model and the prototxt of the model -printf "${dashes}" +printf "%s" "${dashes}" printf "\n\nDownloading the Caffe model and the prototxt" cur_path=$PWD @@ -119,7 +119,7 @@ elif [[ $DISTRO == "ubuntu" ]]; then python_binary=python3 pip_binary=pip3 - system_ver=`cat /etc/lsb-release | grep -i "DISTRIB_RELEASE" | cut -d "=" -f2` + system_ver=$(grep -i "DISTRIB_RELEASE" -f /etc/lsb-release | cut -d "=" -f2) if [ "$system_ver" = "16.04" ]; then sudo -E apt-get install -y libpng12-dev else @@ -143,7 +143,7 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then fi if ! command -v $python_binary &>/dev/null; then - printf "\n\nPython 3.5 (x64) or higher is not installed. It is required to run Model Optimizer, please install it. ${run_again}" + printf "\n\nPython 3.5 (x64) or higher is not installed. It is required to run Model Optimizer, please install it. %s" "${run_again}" exit 1 fi @@ -166,14 +166,14 @@ ir_dir="${irs_path}/${model_dir}/${target_precision}" if [ ! -e "$ir_dir" ]; then # Step 2. Configure Model Optimizer - printf "${dashes}" + printf "%s" "${dashes}" printf "Install Model Optimizer dependencies\n\n" cd "${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/install_prerequisites" . ./install_prerequisites.sh caffe cd "$cur_path" # Step 3. Convert a model with Model Optimizer - printf "${dashes}" + printf "%s" "${dashes}" printf "Convert a model with Model Optimizer\n\n" mo_path="${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/mo.py" @@ -181,12 +181,12 @@ if [ ! -e "$ir_dir" ]; then export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp print_and_run "$python_binary" "$downloader_dir/converter.py" --mo "$mo_path" --name "$model_name" -d "$models_path" -o "$irs_path" --precisions "$target_precision" else - printf "\n\nTarget folder ${ir_dir} already exists. Skipping IR generation with Model Optimizer." - printf "If you want to convert a model again, remove the entire ${ir_dir} folder. ${run_again}" + printf "\n\nTarget folder %s already exists. Skipping IR generation with Model Optimizer." "${ir_dir}" + printf "If you want to convert a model again, remove the entire %s folder. %s" "${ir_dir}" "${run_again}" fi # Step 4. Build samples -printf "${dashes}" +printf "%s" "${dashes}" printf "Build Inference Engine samples\n\n" OS_PATH=$(uname -m) @@ -211,15 +211,15 @@ cmake -DCMAKE_BUILD_TYPE=Release "$samples_path" make $NUM_THREADS benchmark_app # Step 5. Run samples -printf "${dashes}" +printf "%s" "${dashes}" printf "Run Inference Engine benchmark app\n\n" cd "$binaries_dir" cp -f "$ROOT_DIR/${model_name}.labels" "${ir_dir}/" -print_and_run ./benchmark_app -d "$target" -i "$target_image_path" -m "${ir_dir}/${model_name}.xml" -pc ${sampleoptions} +print_and_run ./benchmark_app -d "$target" -i "$target_image_path" -m "${ir_dir}/${model_name}.xml" -pc "${sampleoptions}" -printf "${dashes}" +printf "%s" "${dashes}" printf "Inference Engine benchmark app completed successfully.\n\n" diff --git a/scripts/demo/demo_security_barrier_camera.sh b/scripts/demo/demo_security_barrier_camera.sh index 4913aaf1d314ca..eaf6cd6784e094 100755 --- a/scripts/demo/demo_security_barrier_camera.sh +++ b/scripts/demo/demo_security_barrier_camera.sh @@ -88,7 +88,7 @@ elif [[ $DISTRO == "ubuntu" ]]; then python_binary=python3 pip_binary=pip3 - system_ver=`cat /etc/lsb-release | grep -i "DISTRIB_RELEASE" | cut -d "=" -f2` + system_ver=$(grep -i "DISTRIB_RELEASE" -f /etc/lsb-release | cut -d "=" -f2) if [ "$system_ver" = "16.04" ]; then sudo -E apt-get install -y libpng12-dev else @@ -112,7 +112,7 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then fi if ! command -v $python_binary &>/dev/null; then - printf "\n\nPython 3.5 (x64) or higher is not installed. It is required to run Model Optimizer, please install it. ${run_again}" + printf "\n\nPython 3.5 (x64) or higher is not installed. It is required to run Model Optimizer, please install it. %s" "${run_again}" exit 1 fi @@ -128,18 +128,18 @@ else printf "Error: setupvars.sh is not found\n" fi if ! . "$setupvars_path" ; then - printf "Unable to run ./setupvars.sh. Please check its presence. ${run_again}" + printf "Unable to run ./setupvars.sh. Please check its presence. %s" "${run_again}" exit 1 fi # Step 1. Downloading Intel models -printf "${dashes}" +printf "%s" "${dashes}" printf "Downloading Intel models\n\n" target_precision="FP16" -printf "target_precision = ${target_precision}\n" +printf "target_precision = %s\n" "${target_precision}" downloader_dir="${INTEL_OPENVINO_DIR}/deployment_tools/open_model_zoo/tools/downloader" @@ -161,13 +161,13 @@ while read -r model_opt model_name; do done < "$ROOT_DIR/demo_security_barrier_camera.conf" # Step 2. Build samples -printf "${dashes}" +printf "%s" "${dashes}" printf "Build Inference Engine demos\n\n" demos_path="${INTEL_OPENVINO_DIR}/deployment_tools/open_model_zoo/demos" if ! command -v cmake &>/dev/null; then - printf "\n\nCMAKE is not installed. It is required to build Inference Engine demos. Please install it. ${run_again}" + printf "\n\nCMAKE is not installed. It is required to build Inference Engine demos. Please install it. %s" "${run_again}" exit 1 fi @@ -189,13 +189,13 @@ cmake -DCMAKE_BUILD_TYPE=Release "$demos_path" make $NUM_THREADS security_barrier_camera_demo # Step 3. Run samples -printf "${dashes}" +printf "%s" "${dashes}" printf "Run Inference Engine security_barrier_camera demo\n\n" binaries_dir="${build_dir}/${OS_PATH}/Release" cd "$binaries_dir" -print_and_run ./security_barrier_camera_demo -d "$target" -d_va "$target" -d_lpr "$target" -i "$target_image_path" "${model_args[@]}" ${sampleoptions} +print_and_run ./security_barrier_camera_demo -d "$target" -d_va "$target" -d_lpr "$target" -i "$target_image_path" "${model_args[@]}" "${sampleoptions}" -printf "${dashes}" +printf "%s" "${dashes}" printf "Demo completed successfully.\n\n" diff --git a/scripts/demo/demo_squeezenet_download_convert_run.sh b/scripts/demo/demo_squeezenet_download_convert_run.sh index 00daead548e10c..91a9055375b7ef 100755 --- a/scripts/demo/demo_squeezenet_download_convert_run.sh +++ b/scripts/demo/demo_squeezenet_download_convert_run.sh @@ -46,7 +46,7 @@ done target_precision="FP16" -printf "target_precision = ${target_precision}\n" +printf "target_precision = %s\n" "${target_precision}" models_path="$HOME/openvino_models/models" models_cache="$HOME/openvino_models/cache" @@ -67,12 +67,12 @@ else fi if ! . "$setupvars_path" ; then - printf "Unable to run ./setupvars.sh. Please check its presence. ${run_again}" + printf "Unable to run ./setupvars.sh. Please check its presence. %s" "${run_again}" exit 1 fi # Step 1. Download the Caffe model and the prototxt of the model -printf "${dashes}" +printf "%s" "${dashes}" printf "\n\nDownloading the Caffe model and the prototxt" cur_path=$PWD @@ -115,7 +115,7 @@ elif [[ $DISTRO == "ubuntu" ]]; then python_binary=python3 pip_binary=pip3 - system_ver=`cat /etc/lsb-release | grep -i "DISTRIB_RELEASE" | cut -d "=" -f2` + system_ver=$(grep -i "DISTRIB_RELEASE" -f /etc/lsb-release | cut -d "=" -f2) if [ "$system_ver" = "16.04" ]; then sudo -E apt-get install -y libpng12-dev else @@ -139,7 +139,7 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then fi if ! command -v $python_binary &>/dev/null; then - printf "\n\nPython 3.5 (x64) or higher is not installed. It is required to run Model Optimizer, please install it. ${run_again}" + printf "\n\nPython 3.5 (x64) or higher is not installed. It is required to run Model Optimizer, please install it. %s" "${run_again}" exit 1 fi @@ -162,14 +162,14 @@ ir_dir="${irs_path}/${model_dir}/${target_precision}" if [ ! -e "$ir_dir" ]; then # Step 2. Configure Model Optimizer - printf "${dashes}" + printf "%s" "${dashes}" printf "Install Model Optimizer dependencies\n\n" cd "${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/install_prerequisites" . ./install_prerequisites.sh caffe cd "$cur_path" # Step 3. Convert a model with Model Optimizer - printf "${dashes}" + printf "%s" "${dashes}" printf "Convert a model with Model Optimizer\n\n" mo_path="${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/mo.py" @@ -177,12 +177,12 @@ if [ ! -e "$ir_dir" ]; then export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp print_and_run "$python_binary" "$downloader_dir/converter.py" --mo "$mo_path" --name "$model_name" -d "$models_path" -o "$irs_path" --precisions "$target_precision" else - printf "\n\nTarget folder ${ir_dir} already exists. Skipping IR generation with Model Optimizer." - printf "If you want to convert a model again, remove the entire ${ir_dir} folder. ${run_again}" + printf "\n\nTarget folder %s already exists. Skipping IR generation with Model Optimizer." "${ir_dir}" + printf "If you want to convert a model again, remove the entire %s folder. %s" "${ir_dir}" "${run_again}" fi # Step 4. Build samples -printf "${dashes}" +printf "%s" "${dashes}" printf "Build Inference Engine samples\n\n" OS_PATH=$(uname -m) @@ -207,15 +207,14 @@ cmake -DCMAKE_BUILD_TYPE=Release "$samples_path" make $NUM_THREADS classification_sample_async # Step 5. Run samples -printf "${dashes}" +printf "%s" "${dashes}" printf "Run Inference Engine classification sample\n\n" cd "$binaries_dir" cp -f "$ROOT_DIR/${model_name}.labels" "${ir_dir}/" -print_and_run ./classification_sample_async -d "$target" -i "$target_image_path" -m "${ir_dir}/${model_name}.xml" ${sampleoptions} - -printf "${dashes}" +print_and_run ./classification_sample_async -d "$target" -i "$target_image_path" -m "${ir_dir}/${model_name}.xml" "${sampleoptions}" +printf "%s" "${dashes}" printf "Demo completed successfully.\n\n" diff --git a/scripts/demo/utils.sh b/scripts/demo/utils.sh index 552ba20aefa99f..b7349e0e3a8492 100755 --- a/scripts/demo/utils.sh +++ b/scripts/demo/utils.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + # Copyright (C) 2018-2021 Intel Corporation # SPDX-License-Identifier: Apache-2.0 diff --git a/scripts/install_dependencies/install_4_14_kernel.sh b/scripts/install_dependencies/install_4_14_kernel.sh index a7e01309f19505..bcef687d7875b1 100755 --- a/scripts/install_dependencies/install_4_14_kernel.sh +++ b/scripts/install_dependencies/install_4_14_kernel.sh @@ -6,28 +6,28 @@ # This script installs Linux kernel 4.14 required for Intel NEO OpenCL driver on Ubuntu and CentOS if grep -i "rhel" /etc/os-release &>/dev/null; then - # Cent OS - echo "install kernel build dependencies" - sudo -E yum install -y git gcc gcc-c++ ncurses-devel openssl-devel bc xz elfutils-libelf-devel xorg-x11-drv-nouveau rpm-build + # Cent OS + echo "install kernel build dependencies" + sudo -E yum install -y git gcc gcc-c++ ncurses-devel openssl-devel bc xz elfutils-libelf-devel xorg-x11-drv-nouveau rpm-build - echo "download 4.14.20 kernel" - if [ ! -f ./linux-4.14.20.tar.xz ]; then - wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.14.20.tar.xz - fi + echo "download 4.14.20 kernel" + if [ ! -f ./linux-4.14.20.tar.xz ]; then + wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.14.20.tar.xz + fi - tar -xJf linux-4.14.20.tar.xz - cd linux-4.14.20 - echo "build 4.14.20 kernel" - make olddefconfig + tar -xJf linux-4.14.20.tar.xz + cd linux-4.14.20 + echo "build 4.14.20 kernel" + make olddefconfig - make -j 8 binrpm-pkg - cd ~/rpmbuild/RPMS/x86_64 - sudo -E yum -y localinstall *.rpm - sudo -E grub2-set-default 0 + make -j 8 binrpm-pkg + cd ~/rpmbuild/RPMS/x86_64 + sudo -E yum -y localinstall ./*.rpm + sudo -E grub2-set-default 0 elif grep -i "ubuntu" /etc/os-release &>/dev/null; then - # Ubuntu - sudo -E add-apt-repository ppa:teejee2008/ppa - sudo -E apt-get update && sudo apt-get install -y ukuu - sudo -E ukuu --install v4.14.20 + # Ubuntu + sudo -E add-apt-repository ppa:teejee2008/ppa + sudo -E apt-get update && sudo apt-get install -y ukuu + sudo -E ukuu --install v4.14.20 fi \ No newline at end of file diff --git a/scripts/install_dependencies/install_NCS_udev_rules.sh b/scripts/install_dependencies/install_NCS_udev_rules.sh index 3666b4502e9a44..7062e9d753db92 100755 --- a/scripts/install_dependencies/install_NCS_udev_rules.sh +++ b/scripts/install_dependencies/install_NCS_udev_rules.sh @@ -22,5 +22,3 @@ else echo "File '97-myriad-usbboot.rules' is missing. Please make sure you installed 'Inference Engine Runtime for Intel® Movidius™ VPU'." exit -1 fi - - From 58eef532e95bfc41149cb3b47cdb2b2f4fa66f2a Mon Sep 17 00:00:00 2001 From: Bartosz Lesniewski Date: Tue, 15 Jun 2021 15:54:00 +0200 Subject: [PATCH 090/178] Revise ExtractImagePatches op - specification (#6105) * Change example input matrices to tex * Remove leftover matrix template * Remove reference to TF operation --- docs/ops/movement/ExtractImagePatches_3.md | 165 +++++++++++---------- 1 file changed, 89 insertions(+), 76 deletions(-) diff --git a/docs/ops/movement/ExtractImagePatches_3.md b/docs/ops/movement/ExtractImagePatches_3.md index 3604d3b49ca19d..5046854ee22269 100644 --- a/docs/ops/movement/ExtractImagePatches_3.md +++ b/docs/ops/movement/ExtractImagePatches_3.md @@ -8,9 +8,7 @@ **Detailed description**: -The *ExtractImagePatches* operation is similar to the TensorFlow* operation [ExtractImagePatches](https://www.tensorflow.org/api_docs/python/tf/image/extract_patches). - -This op extracts patches of shape `sizes` which are `strides` apart in the input image. The output elements are taken from the input at intervals given by the `rate` argument, as in dilated convolutions. +The *ExtractImagePatches* operation extracts patches of shape `sizes` which are `strides` apart in the input image. The output elements are taken from the input at intervals given by the `rate` argument, as in dilated convolutions. The result is a 4D tensor containing image patches with size `size[0] * size[1] * depth` vectorized in the "depth" dimension. @@ -92,20 +90,23 @@ The "auto_pad" attribute has no effect on the size of each patch, it determines Image is a `1 x 1 x 10 x 10` array that contains the numbers 1 through 100. We use the symbol `x` to mark output patches. 1. `sizes="3,3", strides="5,5", rates="1,1", auto_pad="valid"` +\f[ + \begin{bmatrix} + x & x & x & 4 & 5 & x & x & x & 9 & 10 \\ + x & x & x & 14 & 15 & x & x & x & 19 & 20 \\ + x & x & x & 24 & 25 & x & x & x & 29 & 30 \\ + 31 & 32 & 33 & 34 & 35 & 36 & 37 & 38 & 39 & 40 \\ + 41 & 42 & 43 & 44 & 45 & 46 & 47 & 48 & 49 & 50 \\ + x & x & x & 54 & 55 & x & x & x & 59 & 60 \\ + x & x & x & 64 & 65 & x & x & x & 69 & 70 \\ + x & x & x & 74 & 75 & x & x & x & 79 & 80 \\ + 81 & 82 & 83 & 84 & 85 & 86 & 87 & 88 & 89 & 90 \\ + 91 & 92 & 93 & 94 & 95 & 96 & 79 & 98 & 99 & 100 + \end{bmatrix} +\f] -   x   x   x    4   5   x   x   x   9 10 -   x   x   x  14 15   x   x   x 19 20 -   x   x   x  24 25   x   x   x 29 30 - 31 32 33 34 35 36 37 38 39 40 - 41 42 43 44 45 46 47 48 49 50 -   x   x   x  54 55   x   x   x 59 60 -   x   x   x  64 65   x   x   x 69 70 -   x   x   x  74 75   x   x   x 79 80 - 81 82 83 84 85 86 87 88 89 90 - 91 92 93 94 95 96 97 98 99 100 - output: - +``` [[[[ 1 6] [51 56]] @@ -132,25 +133,28 @@ Image is a `1 x 1 x 10 x 10` array that contains the numbers 1 through 100. We u [[23 28] [73 78]]]] - +``` output shape: `[1, 9, 2, 2]` 2. `sizes="4,4", strides="8,8", rates="1,1", auto_pad="valid"` - -   x   x   x   x    5   6   7   8   9 10 -   x   x   x   x  15 16 17 18 19 20 -   x   x   x   x  25 26 27 28 29 30 -   x   x   x   x  35 36 37 38 39 40 - 41 42 43 44 45 46 47 48 49 50 - 51 52 53 54 55 56 57 58 59 60 - 61 62 63 64 65 66 67 68 69 70 - 71 72 73 74 75 76 77 78 79 80 - 81 82 83 84 85 86 87 88 89 90 - 91 92 93 94 95 96 97 98 99 100 +\f[ + \begin{bmatrix} + x & x & x & x & 5 & 6 & 7 & 8 & 9 & 10 \\ + x & x & x & x & 15 & 16 & 17 & 18 & 19 & 20 \\ + x & x & x & x & 25 & 26 & 27 & 28 & 29 & 30 \\ + x & x & x & x & 35 & 36 & 37 & 38 & 39 & 40 \\ + 41 & 42 & 43 & 44 & 45 & 46 & 47 & 48 & 49 & 50 \\ + 51 & 52 & 53 & 54 & 55 & 56 & 57 & 58 & 59 & 60 \\ + 61 & 62 & 63 & 64 & 65 & 66 & 67 & 68 & 69 & 70 \\ + 71 & 72 & 73 & 74 & 75 & 76 & 77 & 78 & 79 & 80 \\ + 81 & 82 & 83 & 84 & 85 & 86 & 87 & 88 & 89 & 90 \\ + 91 & 92 & 93 & 94 & 95 & 96 & 79 & 98 & 99 & 100 + \end{bmatrix} +\f] output: - - [[[[ 1]] +``` + [[[[ 1]] [[ 2]] @@ -180,28 +184,30 @@ Image is a `1 x 1 x 10 x 10` array that contains the numbers 1 through 100. We u [[33]] - [[34]]]] - + [[34]]]] +``` output shape: `[1, 16, 1, 1]` 3. `sizes="4,4", strides="9,9", rates="1,1", auto_pad="same_upper"` - -   x   x   x   x    0   0   0   0   0   x   x   x   x -   x   x   x   x    4   5   6   7   8   x   x   x   x -   x   x   x   x  14 15 16 17 18   x   x   x   x -   x   x   x   x  24 25 26 27 28   x   x   x   x -   0 31 32 33 34 35 36 37 38 39 40   0   0 -   0 41 42 43 44 45 46 47 48 49 50   0   0 -   0 51 52 53 54 55 56 57 58 59 60   0   0 -   0 61 62 63 64 65 66 67 68 69 70   0   0 -   0 71 72 73 74 75 76 77 78 79 80   0   0 -   x   x   x   x  84 85 86 87 88   x   x   x   x -   x   x   x   x  94 95 96 97 98   x   x   x   x -   x   x   x   x    0   0   0   0   0   x   x   x   x -   x   x   x   x    0   0   0   0   0   x   x   x   x - +\f[ + \begin{bmatrix} + x & x & x & x & 0 & 0 & 0 & 0 & 0 & x & x & x & x\\ + x & x & x & x & 4 & 5 & 6 & 7 & 8 & x & x & x & x\\ + x & x & x & x & 14 & 15 & 16 & 17 & 18 & x & x & x & x\\ + x & x & x & x & 24 & 25 & 26 & 27 & 28 & x & x & x & x\\ + 0 & 31 & 32 & 33 & 34 & 35 & 36 & 37 & 38 & 39 & 40 & 0 & 0\\ + 0 & 41 & 42 & 43 & 44 & 45 & 46 & 47 & 48 & 49 & 50 & 0 & 0\\ + 0 & 51 & 52 & 53 & 54 & 55 & 56 & 57 & 58 & 59 & 60 & 0 & 0\\ + 0 & 61 & 62 & 63 & 64 & 65 & 66 & 67 & 68 & 69 & 70 & 0 & 0\\ + 0 & 71 & 72 & 73 & 74 & 75 & 76 & 77 & 78 & 79 & 80 & 0 & 0\\ + x & x & x & x & 84 & 85 & 86 & 87 & 88 & x & x & x & x\\ + x & x & x & x & 94 & 95 & 96 & 79 & 98 & x & x & x & x\\ + x & x & x & x & 0 & 0 & 0 & 0 & 0 & x & x & x & x\\ + x & x & x & x & 0 & 0 & 0 & 0 & 0 & x & x & x & x + \end{bmatrix} +\f] output: - +``` [[[[ 0 0] [ 0 89]] @@ -249,25 +255,28 @@ Image is a `1 x 1 x 10 x 10` array that contains the numbers 1 through 100. We u [[ 23 0] [ 0 0]]]] - +``` output shape: `[1, 16, 2, 2]` 4. `sizes="3,3", strides="5,5", rates="2,2", auto_pad="valid"` This time we use the symbols `x`, `y`, `z` and `k` to distinguish the patches: - -   x   2   x   4   x   y   7   y   9   y - 11 12 13 14 15 16 17 18 19 20 -   x  22   x 24   x   y 27   y 29   y - 31 32 33 34 35 36 37 38 39 40 -   x  42   x 44   x   y 47   y 49   y -   z  52   z 54   z   k 57   k 59   k - 61 62 63 64 65 66 67 68 69 70 -   z  72   z 74   z   k 77   k 79   k - 81 82 83 84 85 86 87 88 89 90 -   z  92   z 94   z   k 97   k 99   k - - output: +\f[ + \begin{bmatrix} + x & 2 & x & 4 & x & y & 7 & y & 9 & y \\ + 11 & 12 & 13 & 14 & 15 & 16 & 17 & 18 & 19 & 20 \\ + x & 22 & x & 24 & x & y & 27 & y & 29 & y \\ + 31 & 32 & 33 & 34 & 35 & 36 & 37 & 38 & 39 & 40 \\ + x & 42 & x & 44 & x & y & 47 & y & 49 & y \\ + z & 52 & z & 54 & z & k & 57 & k & 59 & k \\ + 61 & 62 & 63 & 64 & 65 & 66 & 67 & 68 & 69 & 70 \\ + z & 72 & z & 74 & z & k & 77 & k & 79 & k \\ + 81 & 82 & 83 & 84 & 85 & 86 & 87 & 88 & 89 & 90 \\ + z & 92 & z & 94 & z & k & 79 & k & 99 & k + \end{bmatrix} +\f] + output: +``` [[[[ 1 6] [ 51 56]] @@ -294,26 +303,30 @@ This time we use the symbols `x`, `y`, `z` and `k` to distinguish the patches: [[ 45 50] [ 95 100]]]] - +``` output_shape: `[1, 9, 2, 2]` 5. `sizes="2,2", strides="3,3", rates="1,1", auto_pad="valid"` Image is a `1 x 2 x 5 x 5` array that contains two feature maps where feature map with coordinate 0 contains numbers in a range `[1, 25]` and feature map with coordinate 1 contains numbers in a range `[26, 50]` -   x   x   3   x   x -   6   7   8   x   x - 11 12 13 14 15 -   x   x  18   x   x -   x   x  23   x   x - -   x   x  28   x   x -   x   x  33   x   x - 36 37 38 39 40 -   x   x  43   x   x -   x   x  48   x   x - +\f[ + \begin{bmatrix} + x & x & 3 & x & x\\ + x & x & 8 & x & x\\ + 11 & 12 & 13 & 14 & 15\\ + x & x & 18 & x & x\\ + x & x & 23 & x & x + \end{bmatrix}\\ + \begin{bmatrix} + x & x & 28 & x & x\\ + x & x & 33 & x & x\\ + 36 & 37 & 38 & 39 & 40\\ + x & x & 43 & x & x\\ + x & x & 48 & x & x + \end{bmatrix} +\f] output: - +``` [[[[ 1 4] [16 19]] @@ -337,5 +350,5 @@ Image is a `1 x 2 x 5 x 5` array that contains two feature maps where feature ma [[32 35] [47 50]]]] - +``` output shape: `[1, 8, 2, 2]` From a16af0d2ea550c955a34659510831577e43d0b43 Mon Sep 17 00:00:00 2001 From: Edward Shogulin Date: Tue, 15 Jun 2021 16:59:10 +0300 Subject: [PATCH 091/178] [LPT] FakeQuantize folding fix to support ConvolutionBackpropData with FQ on weights (#6160) --- .../src/network_helper.cpp | 2 +- ...nvolution_backprop_data_transformation.cpp | 14 +++++++---- ...nvolution_backprop_data_transformation.cpp | 23 +++++++++++++++---- ...nvolution_backprop_data_transformation.hpp | 2 +- ...nvolution_backprop_data_transformation.cpp | 18 +++++++++------ .../convolution_backprop_data_function.cpp | 1 + 6 files changed, 42 insertions(+), 18 deletions(-) diff --git a/inference-engine/src/low_precision_transformations/src/network_helper.cpp b/inference-engine/src/low_precision_transformations/src/network_helper.cpp index 4a1e942e5753ba..90995bc0ffb22d 100644 --- a/inference-engine/src/low_precision_transformations/src/network_helper.cpp +++ b/inference-engine/src/low_precision_transformations/src/network_helper.cpp @@ -683,7 +683,7 @@ std::shared_ptr NetworkHelper::foldFakeQuantize( auto levels_1 = fq->get_levels() - 1.f; const size_t DHW = D * H * W; - const size_t IDHW = IC * D * H * W; + const size_t IDHW = outChannelsShapeIndex == 0 ? IC * D * H * W : OC * D * H * W; const auto values = constant->cast_vector(); std::vector quantizedValues(OC * IC * D * H * W); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp index 44d26d231b617a..a6e2e93a37ebb8 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp @@ -15,11 +15,17 @@ const std::vector netPrecisions = { }; const std::vector trasformationParamValues = { - LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams().setUpdatePrecisions(true), - LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams().setUpdatePrecisions(false) + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams().setUpdatePrecisions(true) }; const std::vector params = { + // FQ on weights + { + {256ul, ngraph::Shape{1, 1, 1, 1}, { 0.f }, { 25.5f }, { 0.f }, { 25.5f }}, + {255ul, ngraph::Shape{1, 1, 1, 1}, { -12.7f }, { 12.7f }, { -12.7f }, { 12.7f }}, + "convolutionBackpropData_original", + "U8" + }, // FQ on weights // with zero point { @@ -87,8 +93,8 @@ const std::vector inputShapes = { - { 1, 8, 16, 16 } +const std::vector> inputShapes = { + {{ 1, 8, 16, 16 }, true} }; const std::vector outputShapes = { diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp index d33e3c42f9e242..2cf625b58628a6 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp @@ -16,11 +16,24 @@ const std::vector netPrecisions = { }; const std::vector trasformationParamValues = { - LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams().setUpdatePrecisions(true), - LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams().setUpdatePrecisions(false) + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams().setUpdatePrecisions(true) }; const std::vector params = { + // FQ on weights + { + {256ul, ngraph::Shape{1, 1, 1, 1}, { 0.f }, { 25.5f }, { 0.f }, { 25.5f }}, + {255ul, ngraph::Shape{1, 1, 1, 1}, { -12.7f }, { 12.7f }, { -12.7f }, { 12.7f }}, + "convolutionBackpropData_original", + "U8" + }, + // FQ on weights + { + {256ul, ngraph::Shape{1, 1, 1, 1}, { -12.8f }, { 12.7f }, { -12.8f }, { 12.7f }}, + {255ul, ngraph::Shape{1, 1, 1, 1}, { -12.7f }, { 12.7f }, { -12.7f }, { 12.7f }}, + "convolutionBackpropData_original", + "I8" + }, // FQ on weights // with zero point { @@ -82,9 +95,9 @@ const std::vector inputShapes = { - { 1, 8, 16, 16 }, - { 1, 32, 16, 16 } +const std::vector> inputShapes = { + {{ 1, 8, 16, 16 }, false}, + {{ 1, 32, 16, 16 }, true} }; const std::vector outputShapes = { diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/convolution_backprop_data_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/convolution_backprop_data_transformation.hpp index 39d5ea583916e5..8b690e2df2eee3 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/convolution_backprop_data_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/convolution_backprop_data_transformation.hpp @@ -43,7 +43,7 @@ class ConvolutionBackpropDataTransformationParam { typedef std::tuple< ngraph::element::Type, // netPrecision - ngraph::Shape, // inputShape + std::pair, // input shape and shape support flag ngraph::Shape, // outputShape std::string, // targetDevice ngraph::pass::low_precision::LayerTransformation::Params, diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_backprop_data_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_backprop_data_transformation.cpp index 951af4fdd4e0e0..c8d15a5702e407 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_backprop_data_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_backprop_data_transformation.cpp @@ -14,7 +14,7 @@ namespace LayerTestsDefinitions { std::string ConvolutionBackpropDataTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + std::pair inputShape; ngraph::Shape outputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; @@ -22,7 +22,7 @@ std::string ConvolutionBackpropDataTransformation::getTestCaseName(testing::Test std::tie(netPrecision, inputShape, outputShape, targetDevice, params, param) = obj.param; std::ostringstream result; - result << getTestCaseNameByParams(netPrecision, inputShape, targetDevice, params) << "_" << + result << getTestCaseNameByParams(netPrecision, inputShape.first, targetDevice, params) << "_" << outputShape << "_" << param.fakeQuantizeOnData << "_" << param.fakeQuantizeOnWeights << "_" << @@ -34,14 +34,15 @@ void ConvolutionBackpropDataTransformation::SetUp() { threshold = 0.1f; ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + std::pair inputShapeAndHandling; ngraph::Shape outputShape; ngraph::pass::low_precision::LayerTransformation::Params params; ConvolutionBackpropDataTransformationParam param; - std::tie(netPrecision, inputShape, outputShape, targetDevice, params, param) = this->GetParam(); + std::tie(netPrecision, inputShapeAndHandling, outputShape, targetDevice, params, param) = this->GetParam(); std::shared_ptr weights; + const auto inputShape = inputShapeAndHandling.first; if (!param.fakeQuantizeOnWeights.empty()) { weights = ngraph::builder::subgraph::ConvolutionBackpropDataFunction::getWeights( ngraph::Shape{inputShape[1], inputShape[1] / 2, 1, 1}, @@ -65,9 +66,12 @@ void ConvolutionBackpropDataTransformation::SetUp() { void ConvolutionBackpropDataTransformation::Run() { LayerTestsCommon::Run(); - const auto params = std::get<5>(GetParam()); - const auto actualType = getRuntimePrecision(params.layerName); - EXPECT_EQ(actualType, params.expectedKernelType); + const auto inputShape = std::get<1>(GetParam()); + if (inputShape.second) { + const auto params = std::get<5>(GetParam()); + const auto actualType = getRuntimePrecision(params.layerName); + EXPECT_EQ(actualType, params.expectedKernelType); + } } TEST_P(ConvolutionBackpropDataTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/convolution_backprop_data_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/convolution_backprop_data_function.cpp index ae7d3847f69866..969e1394a0fb02 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/convolution_backprop_data_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/convolution_backprop_data_function.cpp @@ -38,6 +38,7 @@ std::shared_ptr ConvolutionBackpropDataFunction::get( CoordinateDiff{ 0, 0 }, CoordinateDiff{ 0, 0 }, Strides{ 1, 1 }); + convolutionBackpropData->set_friendly_name("convolutionBackpropData"); ngraph::ResultVector results{ std::make_shared(convolutionBackpropData) }; return std::make_shared(results, ParameterVector{ input }, "ConvolutionBackpropDataTransformation"); From 0981a1584677d447e6997a7d86694e599431ddff Mon Sep 17 00:00:00 2001 From: Mikhail Nosov Date: Tue, 15 Jun 2021 22:40:46 +0300 Subject: [PATCH 092/178] [Caching] Klocwork fixes (#6157) --- inference-engine/src/inference_engine/compilation_context.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inference-engine/src/inference_engine/compilation_context.cpp b/inference-engine/src/inference_engine/compilation_context.cpp index ae6aa698eafa48..1b656200996657 100644 --- a/inference-engine/src/inference_engine/compilation_context.cpp +++ b/inference-engine/src/inference_engine/compilation_context.cpp @@ -42,7 +42,7 @@ static int32_t as_int32_t(T v) { } class OstreamHashWrapper final: public std::streambuf { - std::size_t m_res = {}; + std::size_t m_res = 0; public: std::size_t getResult() const { return m_res; } std::streamsize xsputn(const char* s, std::streamsize n) override { @@ -65,7 +65,7 @@ class OstreamHashWrapper final: public std::streambuf { ////////////////////////////////////////////////// std::string NetworkCompilationContext::calculateFileInfo(const std::string& filePath) { - size_t seed {}; + size_t seed = 0; auto absPath = filePath; try { absPath = FileUtils::absoluteFilePath(filePath); From 613bb981ce67f8cbbdda816aa12500dd37243726 Mon Sep 17 00:00:00 2001 From: Szymon Durawa Date: Tue, 15 Jun 2021 23:44:34 +0200 Subject: [PATCH 093/178] external_port_id is calculated based on number of op inputs. (#6037) * External_port_id is calcultaed based on number of op inputs. * Add test for external_port_id serialization. * Restore data section appearance in xml file. --- .../src/transformations/serialize.cpp | 38 +++++++++++-------- .../ir_serialization/tensor_iterator.cpp | 38 +++++++++++++++++++ 2 files changed, 60 insertions(+), 16 deletions(-) diff --git a/inference-engine/src/transformations/src/transformations/serialize.cpp b/inference-engine/src/transformations/src/transformations/serialize.cpp index 5f5c8144f2098a..73b72313e5f48a 100644 --- a/inference-engine/src/transformations/src/transformations/serialize.cpp +++ b/inference-engine/src/transformations/src/transformations/serialize.cpp @@ -235,7 +235,7 @@ class XmlSerializer : public ngraph::AttributeVisitor { void output_descriptions_on_adapter(const std::vector>& output_descriptions, - const std::vector& parameter_mapping, + const uint32_t& input_count, const std::vector& result_mapping, pugi::xml_node& port_map) { NGRAPH_CHECK(!result_mapping.empty(), "No results found in body Function."); @@ -246,7 +246,7 @@ class XmlSerializer : public ngraph::AttributeVisitor { for (const auto& output_description : output_descriptions) { pugi::xml_node output = port_map.append_child("output"); - output.append_attribute("external_port_id").set_value(parameter_mapping.size() + output_description->m_output_index); + output.append_attribute("external_port_id").set_value(input_count + output_description->m_output_index); output.append_attribute("internal_layer_id").set_value(result_mapping[output_description->m_body_value_index].c_str()); if (auto concat_output = as_type_ptr(output_description)) { @@ -306,7 +306,11 @@ class XmlSerializer : public ngraph::AttributeVisitor { input_descriptions_on_adapter(a->get(), parameter_mapping, result_mapping, port_map); } else if (const auto& a = ngraph::as_type>>>(&adapter)) { - output_descriptions_on_adapter(a->get(), parameter_mapping, result_mapping, port_map); + uint32_t op_input_count = 0; + for (auto c = m_xml_node.parent().child("input").first_child(); !c.empty(); c = c.next_sibling()) { + op_input_count++; + } + output_descriptions_on_adapter(a->get(), op_input_count, result_mapping, port_map); } else if (const auto& a = ngraph::as_type>(&adapter)) { special_body_ports_on_adapter(a->get(), parameter_mapping, result_mapping, port_map); } @@ -700,19 +704,6 @@ void ngfunction_2_irv10(pugi::xml_node& netXml, // general attributes pugi::xml_node data = layer.append_child("data"); - XmlSerializer visitor(data, node_type_name, custom_opsets, constant_node_write_handler); - NGRAPH_CHECK(node->visit_attributes(visitor), "Visitor API is not supported in ", node); - rt_info::XmlSerializer{data}.serialize(node->get_rt_info()); - - if (exec_graph) { - visit_exec_graph_node(layer, node); - } - - const bool data_attr_size = - data.attributes().begin() == data.attributes().end(); - if (data_attr_size) { - layer.remove_child(data); - } int port_id = 0; // @@ -780,6 +771,21 @@ void ngfunction_2_irv10(pugi::xml_node& netXml, layer.insert_move_after(output, layer.first_child()); } } + + // fill general attributes + XmlSerializer visitor(data, node_type_name, custom_opsets, constant_node_write_handler); + NGRAPH_CHECK(node->visit_attributes(visitor), "Visitor API is not supported in ", node); + rt_info::XmlSerializer{data}.serialize(node->get_rt_info()); + + if (exec_graph) { + visit_exec_graph_node(layer, node); + } + + const bool data_attr_size = + data.attributes().begin() == data.attributes().end(); + if (data_attr_size) { + layer.remove_child(data); + } } // const std::vector edge_mapping = create_edge_mapping(layer_ids, f); diff --git a/inference-engine/tests/functional/inference_engine/ir_serialization/tensor_iterator.cpp b/inference-engine/tests/functional/inference_engine/ir_serialization/tensor_iterator.cpp index c63371baf89925..cccad0f70a5766 100644 --- a/inference-engine/tests/functional/inference_engine/ir_serialization/tensor_iterator.cpp +++ b/inference-engine/tests/functional/inference_engine/ir_serialization/tensor_iterator.cpp @@ -9,6 +9,7 @@ #include "ie_core.hpp" #include "ie_blob.h" #include "common_test_utils/data_utils.hpp" +#include "pugixml.hpp" #ifndef IR_SERIALIZATION_MODELS_PATH // should be already defined by cmake #define IR_SERIALIZATION_MODELS_PATH "" @@ -84,3 +85,40 @@ TEST_F(SerializationTensorIteratorTest, TiNegativeStride) { serialize_and_compare(model_path, weights); } + +TEST_F(SerializationTensorIteratorTest, SerializationExternalPortIdInXmlFile) { + const std::string model_path = IR_SERIALIZATION_MODELS_PATH "loop_2d_add.xml"; + const std::string binary_path = IR_SERIALIZATION_MODELS_PATH "loop_2d_add.bin"; + + InferenceEngine::Core ie; + InferenceEngine::CNNNetwork expected; + pugi::xml_document loop_orig; + pugi::xml_document loop_serialized; + + expected = ie.ReadNetwork(model_path, binary_path); + expected.serialize(m_out_xml_path, m_out_bin_path); + + pugi::xml_parse_result result = loop_orig.load_file(model_path.c_str()); + ASSERT_FALSE(result.status) << result.description(); + result = loop_serialized.load_file(m_out_xml_path.c_str()); + ASSERT_FALSE(result.status) << result.description(); + + auto node1 = loop_orig.child("net").child("layers").find_child_by_attribute("type", "Loop"); + auto node2 = loop_serialized.child("net").child("layers").find_child_by_attribute("type", "Loop"); + auto node2_port_map = node2.child("port_map").first_child(); + + for (auto ch = node1.child("port_map").first_child(); !ch.empty(); ch = ch.next_sibling()) { + auto node1_external_port_id = std::stoi(ch.attribute("external_port_id").value()); + auto node2_external_port_id = std::stoi(node2_port_map.attribute("external_port_id").value()); + + if (node1_external_port_id == -1) { + continue; + } + if (node2_external_port_id == -1) { + node2_external_port_id = std::stoi(node2_port_map.next_sibling().attribute("external_port_id").value()); + } + node2_port_map = node2_port_map.next_sibling(); + + EXPECT_EQ(node1_external_port_id, node2_external_port_id); + } +} From ad852f78b47e0580a7d6cefce43bcd1ff5019115 Mon Sep 17 00:00:00 2001 From: Marina Kolpakova Date: Wed, 16 Jun 2021 01:00:19 +0300 Subject: [PATCH 094/178] =?UTF-8?q?[=C2=A7]=20cleans=20snippets=20interfac?= =?UTF-8?q?e=20and=20adds=20subgraph=20tests=20(#6123)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/snippets/include/snippets/emitter.hpp | 56 ++++++++++++++ .../snippets/include/snippets/generator.hpp | 77 ++++++++++--------- .../snippets/include/snippets/op/kernel.hpp | 37 +++++++++ .../src/snippets/include/snippets/op/nop.hpp | 4 + .../snippets/include/snippets/op/subgraph.hpp | 47 ++++++++++- .../src/snippets/include/snippets/op/tile.hpp | 36 +++++++++ .../src/snippets/src/generator.cpp | 59 +++++++++++++- .../src/snippets/src/op/kernel.cpp | 14 ++++ .../src/snippets/src/op/subgraph.cpp | 20 ++++- inference-engine/src/snippets/src/op/tile.cpp | 14 ++++ .../snippets/src/pass/collapse_subgraph.cpp | 25 ++++-- .../subgraph_tests/codegen_add.cpp | 29 +++++++ .../subgraph_tests/codegen_bert.cpp | 26 +++++++ .../subgraph_tests/codegen_gelu.cpp | 26 +++++++ .../include/subgraph_tests/codegen_add.hpp | 34 ++++++++ .../include/subgraph_tests/codegen_bert.hpp | 34 ++++++++ .../include/subgraph_tests/codegen_gelu.hpp | 34 ++++++++ .../shared/src/subgraph_tests/codegen_add.cpp | 60 +++++++++++++++ .../src/subgraph_tests/codegen_bert.cpp | 76 ++++++++++++++++++ .../src/subgraph_tests/codegen_gelu.cpp | 74 ++++++++++++++++++ 20 files changed, 734 insertions(+), 48 deletions(-) create mode 100644 inference-engine/src/snippets/include/snippets/emitter.hpp create mode 100644 inference-engine/src/snippets/include/snippets/op/kernel.hpp create mode 100644 inference-engine/src/snippets/include/snippets/op/tile.hpp create mode 100644 inference-engine/src/snippets/src/op/kernel.cpp create mode 100644 inference-engine/src/snippets/src/op/tile.cpp create mode 100644 inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_add.cpp create mode 100644 inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_bert.cpp create mode 100644 inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_gelu.cpp create mode 100644 inference-engine/tests/functional/plugin/shared/include/subgraph_tests/codegen_add.hpp create mode 100644 inference-engine/tests/functional/plugin/shared/include/subgraph_tests/codegen_bert.hpp create mode 100644 inference-engine/tests/functional/plugin/shared/include/subgraph_tests/codegen_gelu.hpp create mode 100644 inference-engine/tests/functional/plugin/shared/src/subgraph_tests/codegen_add.cpp create mode 100644 inference-engine/tests/functional/plugin/shared/src/subgraph_tests/codegen_bert.cpp create mode 100644 inference-engine/tests/functional/plugin/shared/src/subgraph_tests/codegen_gelu.cpp diff --git a/inference-engine/src/snippets/include/snippets/emitter.hpp b/inference-engine/src/snippets/include/snippets/emitter.hpp new file mode 100644 index 00000000000000..78d54098324010 --- /dev/null +++ b/inference-engine/src/snippets/include/snippets/emitter.hpp @@ -0,0 +1,56 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +#include +#include + +namespace ngraph { +namespace snippets { + +using code = const uint8_t *; +using RegInfo = std::pair, std::vector>; + +/** + * @interface Emitter + * @brief Base class for all target specific code emitters used by generator. + * @ingroup snippets + */ +class TRANSFORMATIONS_API Emitter { +public: + /** + * @brief Default constructor + */ + Emitter(const std::shared_ptr& n) { + } + + Emitter(std::vector, RegInfo>>& region) { + } + + /** + * @brief called by generator to generate code to produce target code for a specific operation + * @param in vector of vector argument registers + * @param out vector of vector resulting registers + * @param pool optional vector of free vector registers which might be used inside method + * @param gpr vector of free generam puproce registers which might be used inside method + * @return void + */ + virtual void emit_code(const std::vector& in, + const std::vector& out, + const std::vector& pool = {}, + const std::vector& gpr = {}) const = 0; + + /** + * @brief called by generator to generate data section, if needed for a specific operation + * @return void + */ + virtual void emit_data() const { + } +}; + +} // namespace snippets +} // namespace ngraph \ No newline at end of file diff --git a/inference-engine/src/snippets/include/snippets/generator.hpp b/inference-engine/src/snippets/include/snippets/generator.hpp index a7408134c5e657..1a7ace69854f90 100644 --- a/inference-engine/src/snippets/include/snippets/generator.hpp +++ b/inference-engine/src/snippets/include/snippets/generator.hpp @@ -10,63 +10,60 @@ #include #include "snippets_isa.hpp" +#include "emitter.hpp" namespace ngraph { namespace snippets { -using code = const uint8_t *; -using RegInfo = std::pair, std::vector>; - TRANSFORMATIONS_API auto getRegisters(std::shared_ptr& n) -> ngraph::snippets::RegInfo; /** - * @interface Emitter - * @brief Base class for all target specific code emitters used by generator. + * @interface TargetMachine + * @brief Base class Target machine representation. Target derives from this class to provide generator information about supported emittors * @ingroup snippets */ -class TRANSFORMATIONS_API Emitter { +class TRANSFORMATIONS_API TargetMachine { public: /** - * @brief Default constructor + * @brief checks if target is natively supported + * @return true, if supported */ - Emitter(const std::shared_ptr& n) { - } + virtual bool is_supported() const = 0; /** - * @brief called by generator to generate code to produce target code for a specific operation - * @param in vector of vector argument registers - * @param out vector of vector resulting registers - * @param pool optional vector of free vector registers which might be used inside method - * @param gpr vector of free generam puproce registers which might be used inside method - * @return void + * @brief finalizes code generation + * @return generated kernel binary */ - virtual void emit_code(const std::vector& in, - const std::vector& out, - const std::vector& pool = {}, - const std::vector& gpr = {}) const = 0; + virtual code get_snippet() const = 0; /** - * @brief called by generator to generate data section, if needed for a specific operation - * @return void + * @brief gets number of lanes supported by target's vector ISA + * @return number of lanes */ - virtual void emit_data() const { - } -}; + virtual size_t get_lanes() const = 0; -/** - * @interface TargetMachine - * @brief Base class Target machine representation. Target derives from this class to provide generator information about supported emittors - * @ingroup snippets - */ -class TRANSFORMATIONS_API TargetMachine { -public: /** - * @brief called by generator to all the emittors available for a target machine + * @brief called by generator to all the emittor for a target machine * @return a map by node's type info with callbacks to create an instance of emmitter for corresponding operation type */ - virtual auto getJitters() -> std::map(std::shared_ptr)>>{ - return {}; + std::function(std::shared_ptr)> get(const ngraph::DiscreteTypeInfo type) const { + auto jitter = jitters.find(type); + if (jitter == jitters.end()) { + throw ngraph_error(std::string("Target code emitter is not available for ") + type.name + " operation."); + } + return jitter->second; + } + + /** + * @brief checks if emitter for a specific operation is supported + * @return true, if supported + */ + bool has(const ngraph::DiscreteTypeInfo type) const { + return jitters.find(type) != jitters.end(); } + +protected: + std::map(std::shared_ptr)>> jitters; }; /** @@ -87,6 +84,12 @@ class TRANSFORMATIONS_API Schedule { * @param p pointer to generated code */ Schedule(const Shape& ws, bool f, code p) : work_size(ws), is_flat(f), ptr(p) {} + /** + * @brief Returns callable instanse of code pointer + */ + template K get_callable() const { + return reinterpret_cast(const_cast(ptr)); + } Shape work_size {}; bool is_flat {false}; @@ -103,7 +106,7 @@ class TRANSFORMATIONS_API Generator { /** * @brief Default constructor */ - Generator() = default; + Generator(const std::shared_ptr& t) : target(t) {} /** * @brief Default destructor */ @@ -113,10 +116,10 @@ class TRANSFORMATIONS_API Generator { * @param f runction in canonical for for table-based code generation * @return pointer to generated code */ - virtual code generate(std::shared_ptr& f) const = 0; + code generate(std::shared_ptr& f) const; protected: - mutable std::map(std::shared_ptr)>> jitters; + std::shared_ptr target; }; } // namespace snippets diff --git a/inference-engine/src/snippets/include/snippets/op/kernel.hpp b/inference-engine/src/snippets/include/snippets/op/kernel.hpp new file mode 100644 index 00000000000000..f93b71096166b4 --- /dev/null +++ b/inference-engine/src/snippets/include/snippets/op/kernel.hpp @@ -0,0 +1,37 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +#include "ngraph/op/op.hpp" +#include "snippets/emitter.hpp" + +namespace ngraph { +namespace snippets { +namespace op { + +/** + * @interface Kernel + * @brief Generated by Canonicalization and represents compute kernel legal for sheduling + * @ingroup snippets + */ +class TRANSFORMATIONS_API Kernel : public ngraph::op::Op { +public: + NGRAPH_RTTI_DECLARATION; + + Kernel(const std::vector, ngraph::snippets::RegInfo>>& region); + Kernel() = default; + + std::vector, ngraph::snippets::RegInfo>> region; + + std::shared_ptr clone_with_new_inputs(const OutputVector& inputs) const override { + return std::make_shared(region); + } +}; + +} // namespace op +} // namespace snippets +} // namespace ngraph \ No newline at end of file diff --git a/inference-engine/src/snippets/include/snippets/op/nop.hpp b/inference-engine/src/snippets/include/snippets/op/nop.hpp index 8bf6b21a2b6b8e..815776d59a0326 100644 --- a/inference-engine/src/snippets/include/snippets/op/nop.hpp +++ b/inference-engine/src/snippets/include/snippets/op/nop.hpp @@ -23,6 +23,10 @@ class TRANSFORMATIONS_API Nop : public ngraph::op::Op { Nop(const OutputVector& arguments, const OutputVector& results); Nop() = default; + + std::shared_ptr clone_with_new_inputs(const OutputVector& inputs) const override { + return std::make_shared(); + } }; } // namespace op diff --git a/inference-engine/src/snippets/include/snippets/op/subgraph.hpp b/inference-engine/src/snippets/include/snippets/op/subgraph.hpp index b204fdd22fc795..4b00b2bb9a07c8 100644 --- a/inference-engine/src/snippets/include/snippets/op/subgraph.hpp +++ b/inference-engine/src/snippets/include/snippets/op/subgraph.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "snippets/generator.hpp" @@ -24,6 +25,47 @@ namespace op { */ class TRANSFORMATIONS_API Subgraph : public ngraph::op::Op { public: + // < 1, 42, 17, 15, 16> < 0, 1, 2, 3, 1> + // should be: + // A = < 1, 42, 17, 15> -> < 1, 3, 17, 15, 16> < 0, 1, 2, 3, 1> + // B = < 1, 1, 17, 15> -> < 1, 1, 17, 15, 16> < 0, 1, 2, 3, 1> + // D = < 1, 42, 1, 1 > -> < 1, 3, 1, 1, 16> < 0, 1, 2, 3, 1> ??? + // C = A + B + // C = < 1, 42, 17, 15> -> < 1, 3, 17, 15, 16> < 0, 1, 2, 3, 1> + // + // how it works now (multi-demention broadcast): + // [BroadcastLoad] doesn't perform post increment + // [Load] performs += vlan + // [ScalarLoad] performs += 1 + // A = < 1, 42, 17, 15> -> < 1, 3, 17, 15, 16> < 0, 1, 2, 3, 1> + // B = < 1, 1, 17, 15> -> < 1, 1, 17, 15, 1> < 0, 1, 2, 3, 1> + // [A] [B] + // [Load] [ScalarLoad] <- should consider AxisVector to choose right type of load + // [Broadcast] + // [Add] + // [Store] + // [C] + // C = A + B + // C = < 1, 42, 17, 15> -> < 1, 3, 17, 15, 16> < 0, 1, 2, 3, 1> + // + // Multiple-dimension broadcasts support? + // A = < 1, 42, 17, 15> -> < 1, 3, 17, 15, 16> < 0, 1, 2, 3, 4> + // B = < 1, 1, 17, 15> -> < 1, 1, 17, 15, 1> < 0, 1, 2, 3, 4> + // + // A = < 1, 42, 17, 15> -> < 1, 3, 17, 15, 16> < 0, 1, 2, 3, 4> + // B = < 1, 1, 17, 15> -> < 1, 3, 17, 15, 1> < 0, 1, 2, 3, 4> + // + // Collapse moat varying dimensions with broadcast + // A = < 1, 42, 17, 15> -> < 1, 3, 17, 15, 16> < 0, 1, 2, 3, 1> + // B = < 1, 1, 17, 15> -> < 1, 3, 17, 15, 1> < 0, 1, 2, 3, 1> + // + // Collapse for mixed broadcast + // A = < 1, 3, 17, 15, 32> < 0, 1, 2, 3, 4> + // B = < 1, 3, 17, 1, 32> < 0, 1, 2, 3, 4> + // C = < 1, 3, 1, 15, 32> < 0, 1, 2, 3, 4> + // + // D = < 1, 3, 17, 15, 32> < 0, 1, 2, 3, 4> + // E = < 1, 3, 17, 1, 32> < 0, 1, 2, 3, 4> using BlockedShape = std::tuple; using BlockedShapeVector = std::vector; @@ -49,7 +91,8 @@ class TRANSFORMATIONS_API Subgraph : public ngraph::op::Op { std::shared_ptr make_canonical_from_this(); - snippets::Schedule generate(const BlockedShapeVector& output_shapes, const BlockedShapeVector& input_shapes); + snippets::Schedule generate(const BlockedShapeVector& output_shapes, const BlockedShapeVector& input_shapes, + ngraph::pass::Manager opt = ngraph::pass::Manager()); bool evaluate(const HostTensorVector& output_values, const HostTensorVector& input_values) const override; /// Set a new body for the op; body needs to satisfy requirements on inputs/outputs @@ -62,6 +105,8 @@ class TRANSFORMATIONS_API Subgraph : public ngraph::op::Op { void print() const; void print_statistics(bool verbose); + void serialize() const; + static auto wrap_node_as_subgraph(const std::shared_ptr& node) -> std::shared_ptr; private: diff --git a/inference-engine/src/snippets/include/snippets/op/tile.hpp b/inference-engine/src/snippets/include/snippets/op/tile.hpp new file mode 100644 index 00000000000000..874e962ef09536 --- /dev/null +++ b/inference-engine/src/snippets/include/snippets/op/tile.hpp @@ -0,0 +1,36 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +#include "ngraph/op/op.hpp" +#include "snippets/emitter.hpp" + +namespace ngraph { +namespace snippets { +namespace op { + +/** + * @interface Tile + * @brief Generated by Canonicalization and represents Loop in affine notation + * @ingroup snippets + */ +class TRANSFORMATIONS_API Tile : public ngraph::op::Op { +public: + NGRAPH_RTTI_DECLARATION; + + Tile(const std::vector, ngraph::snippets::RegInfo>>& region); + Tile() = default; + std::vector, ngraph::snippets::RegInfo>> region; + + std::shared_ptr clone_with_new_inputs(const OutputVector& inputs) const override { + return std::make_shared(region); + } +}; + +} // namespace op +} // namespace snippets +} // namespace ngraph \ No newline at end of file diff --git a/inference-engine/src/snippets/src/generator.cpp b/inference-engine/src/snippets/src/generator.cpp index 650c91992343d0..23fb777d4de2d8 100644 --- a/inference-engine/src/snippets/src/generator.cpp +++ b/inference-engine/src/snippets/src/generator.cpp @@ -4,10 +4,18 @@ #include "snippets/generator.hpp" #include "snippets/register_info.hpp" +#include "snippets/pass/assign_registers.hpp" +#include "snippets/pass/vector_to_scalar.hpp" +#include "snippets/pass/insert_load_store.hpp" +#include "snippets/op/tile.hpp" +#include "snippets/op/kernel.hpp" + +#include auto ngraph::snippets::getRegisters(std::shared_ptr& n) -> ngraph::snippets::RegInfo { auto rt = n->get_rt_info(); + // ToDo: change to reg_t std::vector rout; if (auto rinfo = rt["reginfo"]) { auto reginfo = ngraph::as_type_ptr>>(rinfo)->get(); @@ -27,4 +35,53 @@ auto ngraph::snippets::getRegisters(std::shared_ptr& n) -> ngraph: } } return std::make_pair(rin, rout); -} \ No newline at end of file +} + +ngraph::snippets::code ngraph::snippets::Generator::generate(std::shared_ptr& f) const { + if (!target->is_supported()) + throw ngraph_error("unsupported architecture for code genration"); + + auto params = f->get_parameters(); + auto results = f->get_results(); + auto nptrs = results.size() + params.size(); + + if (nptrs > 7) { + throw ngraph_error("snippet signature should not exceed 7 arguments. got " + std::to_string(nptrs)); + } + + // vector tile + std::vector, ngraph::snippets::RegInfo>> lowered; + for (auto n : f->get_ordered_ops()) { + lowered.push_back(std::make_pair(target->get(n->get_type_info())(n), ngraph::snippets::getRegisters(n))); + } + + // scalar tile + auto f_scalar = ngraph::clone_function(*f.get()); + ngraph::pass::Manager m; + m.register_pass(); + m.register_pass(); + m.run_passes(f_scalar); + + std::vector, RegInfo>> scalar_lowered; + for (auto n : f_scalar->get_ordered_ops()) { + scalar_lowered.push_back(std::make_pair(target->get(n->get_type_info())(n), ngraph::snippets::getRegisters(n))); + } + + // wrapping into tiles + std::vector, RegInfo>> tiles; + tiles.push_back(std::make_pair(target->get(ngraph::snippets::op::Tile::type_info)(std::make_shared(lowered)), + std::make_pair(std::vector({target->get_lanes(), nptrs}), std::vector{}))); + tiles.push_back(std::make_pair(target->get(ngraph::snippets::op::Tile::type_info)(std::make_shared(scalar_lowered)), + std::make_pair(std::vector{{1, nptrs}}, std::vector{}))); + + // emission + std::shared_ptr kernel = target->get(ngraph::snippets::op::Kernel::type_info)(std::make_shared(tiles)); + kernel->emit_code({params.size(), results.size()}, {}); + + lowered.insert(lowered.end(), scalar_lowered.begin(), scalar_lowered.end()); + for (auto& op : lowered) { + op.first->emit_data(); + } + + return target->get_snippet(); +} diff --git a/inference-engine/src/snippets/src/op/kernel.cpp b/inference-engine/src/snippets/src/op/kernel.cpp new file mode 100644 index 00000000000000..381db1a5076f6a --- /dev/null +++ b/inference-engine/src/snippets/src/op/kernel.cpp @@ -0,0 +1,14 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "snippets/op/kernel.hpp" +#include "snippets/generator.hpp" + +using namespace std; +using namespace ngraph; + +NGRAPH_RTTI_DEFINITION(snippets::op::Kernel, "Kernel", 0); + +snippets::op::Kernel::Kernel(const std::vector, snippets::RegInfo>>& nested) : Op(), region(nested) { +} diff --git a/inference-engine/src/snippets/src/op/subgraph.cpp b/inference-engine/src/snippets/src/op/subgraph.cpp index 544f398c21ffc0..f58b1d383dceea 100644 --- a/inference-engine/src/snippets/src/op/subgraph.cpp +++ b/inference-engine/src/snippets/src/op/subgraph.cpp @@ -12,6 +12,7 @@ #include "snippets/pass/assign_registers.hpp" #include +#include #include #include @@ -176,9 +177,7 @@ void snippets::op::Subgraph::canonicalize(const BlockedShapeVector& output_shape if (param->get_element_type() != std::get<2>(input_shapes[i])) { throw ngraph::ngraph_error("changes in presision. Is it legal??"); } - if (param->get_shape().size() != std::get<0>(input_shapes[i]).size()) { - m_body->replace_parameter(i, std::make_shared(std::get<2>(input_shapes[i]), std::get<0>(input_shapes[i]))); - } + m_body->replace_parameter(i, std::make_shared(std::get<2>(input_shapes[i]), std::get<0>(input_shapes[i]))); } } @@ -204,16 +203,20 @@ void snippets::op::Subgraph::convert_to_snippet_dialect() { manager.run_passes(m_body); } -snippets::Schedule snippets::op::Subgraph::generate(const BlockedShapeVector& output_shapes, const BlockedShapeVector& input_shapes) { +snippets::Schedule snippets::op::Subgraph::generate(const BlockedShapeVector& output_shapes, const BlockedShapeVector& input_shapes, + ngraph::pass::Manager opt) { INTERNAL_OP_SCOPE(Subgraph); NGRAPH_CHECK(m_generator != nullptr, "generate is called while generator is not set"); canonicalize(output_shapes, input_shapes); convert_to_snippet_dialect(); + opt.run_passes(m_body); // generation flow snippets::pass::AssignRegisters().run_on_function(m_body); + // shedule generation should go here and be target agnostic + // actual code emission ngraph::snippets::code ptr = m_generator->generate(m_body); @@ -342,3 +345,12 @@ void snippets::op::Subgraph::print_statistics(bool verbose) { this->print(); } } + +void snippets::op::Subgraph::serialize() const { + std::stringstream xmlFile, binFile; + ngraph::pass::Serialize serializer(xmlFile, xmlFile, ngraph::pass::Serialize::Version::IR_V10); + serializer.run_on_function(get_body()); + auto m_constants = binFile.str(); + auto m_model = xmlFile.str(); + std::cout << m_model << std::endl; +} diff --git a/inference-engine/src/snippets/src/op/tile.cpp b/inference-engine/src/snippets/src/op/tile.cpp new file mode 100644 index 00000000000000..6e630585e6554d --- /dev/null +++ b/inference-engine/src/snippets/src/op/tile.cpp @@ -0,0 +1,14 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "snippets/op/tile.hpp" +#include "snippets/generator.hpp" + +using namespace std; +using namespace ngraph; + +NGRAPH_RTTI_DEFINITION(snippets::op::Tile, "Tile", 0); + +snippets::op::Tile::Tile(const std::vector, snippets::RegInfo>>& nested) : Op(), region(nested) { +} diff --git a/inference-engine/src/snippets/src/pass/collapse_subgraph.cpp b/inference-engine/src/snippets/src/pass/collapse_subgraph.cpp index 6c864ec5c4f03f..6f05719d9d5252 100644 --- a/inference-engine/src/snippets/src/pass/collapse_subgraph.cpp +++ b/inference-engine/src/snippets/src/pass/collapse_subgraph.cpp @@ -12,7 +12,6 @@ #include #include - #include #include #include @@ -66,10 +65,6 @@ auto has_cycles_of_dependencies(const std::vector n) -> bool { if (in.get_tensor().get_element_type() != ngraph::element::f32) { return false; } + + if (in.get_partial_shape().is_dynamic()) { + return false; + } + + if (in.get_partial_shape().is_static() && in.get_shape().size() > 6) { + return false; + } } for (auto out : n->outputs()) { @@ -196,10 +199,22 @@ auto has_supported_in_out(std::shared_ptr n) -> bool { return false; } + if (out.get_partial_shape().is_dynamic()) { + return false; + } + + if (out.get_partial_shape().is_static() && out.get_shape().size() > 6) { + return false; + } + for (auto in_out : out.get_target_inputs()) { if (!!as_type_ptr(in_out.get_node()->shared_from_this())) { return false; } + + if (!!as_type_ptr(in_out.get_node()->shared_from_this())) { + return false; + } } } diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_add.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_add.cpp new file mode 100644 index 00000000000000..72c50bce2a4f7f --- /dev/null +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_add.cpp @@ -0,0 +1,29 @@ + +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "subgraph_tests/codegen_add.hpp" +#include "common_test_utils/test_constants.hpp" + +using namespace LayerTestsDefinitions; + +namespace { + + const std::vector netPrecisions = { + InferenceEngine::Precision::FP32 + }; + + INSTANTIATE_TEST_CASE_P(NoReshape, CodegenAdd, + ::testing::Combine( + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::SizeVector({1, 42, 16, 64})), + ::testing::Values(InferenceEngine::SizeVector({1, 42, 16, 64}), + InferenceEngine::SizeVector({1, 42, 16, 1}), + InferenceEngine::SizeVector({1, 42, 1, 64}), + InferenceEngine::SizeVector({1, 1, 16, 64})), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + CodegenAdd::getTestCaseName); +} // namespace \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_bert.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_bert.cpp new file mode 100644 index 00000000000000..97b3737d69366d --- /dev/null +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_bert.cpp @@ -0,0 +1,26 @@ + +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "subgraph_tests/codegen_bert.hpp" +#include "common_test_utils/test_constants.hpp" + +using namespace LayerTestsDefinitions; + +namespace { + + const std::vector netPrecisions = { + InferenceEngine::Precision::FP32 + }; + + INSTANTIATE_TEST_CASE_P(NoReshape, CodegenBert, + ::testing::Combine( + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::SizeVector({1, 42, 16, 64})), + ::testing::Values(InferenceEngine::SizeVector({1, 42, 64, 64})), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + CodegenBert::getTestCaseName); +} // namespace \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_gelu.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_gelu.cpp new file mode 100644 index 00000000000000..81b03911dabe41 --- /dev/null +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_gelu.cpp @@ -0,0 +1,26 @@ + +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "subgraph_tests/codegen_gelu.hpp" +#include "common_test_utils/test_constants.hpp" + +using namespace LayerTestsDefinitions; + +namespace { + + const std::vector netPrecisions = { + InferenceEngine::Precision::FP32 + }; + + INSTANTIATE_TEST_CASE_P(NoReshape, CodegenGelu, + ::testing::Combine( + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::SizeVector({1, 384, 4096})), + ::testing::Values(true, false), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + CodegenGelu::getTestCaseName); +} // namespace \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/codegen_add.hpp b/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/codegen_add.hpp new file mode 100644 index 00000000000000..969f15c3c5103e --- /dev/null +++ b/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/codegen_add.hpp @@ -0,0 +1,34 @@ +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include + +#include "shared_test_classes/base/layer_test_utils.hpp" +#include "ngraph_functions/utils/ngraph_helpers.hpp" +#include "ngraph_functions/builders.hpp" + +namespace LayerTestsDefinitions { + +typedef std::tuple< + InferenceEngine::Precision, // Network Precision + InferenceEngine::SizeVector, // Input 0 Shape + InferenceEngine::SizeVector, // Input 1 Shape + std::string // Target Device +> multiInputParams; + +class CodegenAdd : public testing::WithParamInterface, +public LayerTestsUtils::LayerTestsCommon { +public: + static std::string getTestCaseName(testing::TestParamInfo obj); + +protected: + void SetUp() override; +}; + +} // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/codegen_bert.hpp b/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/codegen_bert.hpp new file mode 100644 index 00000000000000..449f259f34801e --- /dev/null +++ b/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/codegen_bert.hpp @@ -0,0 +1,34 @@ +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include + +#include "shared_test_classes/base/layer_test_utils.hpp" +#include "ngraph_functions/utils/ngraph_helpers.hpp" +#include "ngraph_functions/builders.hpp" + +namespace LayerTestsDefinitions { + +typedef std::tuple< + InferenceEngine::Precision, // Network Precision + InferenceEngine::SizeVector, // Input 0 Shape + InferenceEngine::SizeVector, // Input 1 Shape + std::string // Target Device +> multiInputParams; + +class CodegenBert : public testing::WithParamInterface, +public LayerTestsUtils::LayerTestsCommon { +public: + static std::string getTestCaseName(testing::TestParamInfo obj); + +protected: + void SetUp() override; +}; + +} // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/codegen_gelu.hpp b/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/codegen_gelu.hpp new file mode 100644 index 00000000000000..d4c90a036d4000 --- /dev/null +++ b/inference-engine/tests/functional/plugin/shared/include/subgraph_tests/codegen_gelu.hpp @@ -0,0 +1,34 @@ +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include + +#include "shared_test_classes/base/layer_test_utils.hpp" +#include "ngraph_functions/utils/ngraph_helpers.hpp" +#include "ngraph_functions/builders.hpp" + +namespace LayerTestsDefinitions { + +typedef std::tuple< + InferenceEngine::Precision, // Network Precision + InferenceEngine::SizeVector, // Input Shape, + bool, + std::string // Target Device +> multiInputParams; + +class CodegenGelu : public testing::WithParamInterface, +public LayerTestsUtils::LayerTestsCommon { +public: + static std::string getTestCaseName(testing::TestParamInfo obj); + +protected: + void SetUp() override; +}; + +} // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/src/subgraph_tests/codegen_add.cpp b/inference-engine/tests/functional/plugin/shared/src/subgraph_tests/codegen_add.cpp new file mode 100644 index 00000000000000..662ef3313b5cde --- /dev/null +++ b/inference-engine/tests/functional/plugin/shared/src/subgraph_tests/codegen_add.cpp @@ -0,0 +1,60 @@ + +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include +#include +#include + +#include + +#include "common_test_utils/common_utils.hpp" +#include "functional_test_utils/plugin_cache.hpp" +#include "shared_test_classes/base/layer_test_utils.hpp" +#include "functional_test_utils/blob_utils.hpp" + +#include "ngraph_functions/pass/convert_prc.hpp" + +#include "subgraph_tests/codegen_add.hpp" + +namespace LayerTestsDefinitions { + + std::string CodegenAdd::getTestCaseName(testing::TestParamInfo obj) { + InferenceEngine::Precision netPrecision; + InferenceEngine::SizeVector inputShapes0, inputShapes1, newInputShapes; + std::string targetDevice; + std::tie(netPrecision, inputShapes0, inputShapes1, targetDevice) = obj.param; + + std::ostringstream result; + result << "IS[0]=" << CommonTestUtils::vec2str(inputShapes0) << "_"; + result << "IS[1]=" << CommonTestUtils::vec2str(inputShapes1) << "_"; + result << "netPRC=" << netPrecision.name() << "_"; + result << "targetDevice=" << targetDevice; + return result.str(); + } + + void CodegenAdd::SetUp() { + std::vector inputShape0, inputShape1; + InferenceEngine::Precision netPrecision; + std::tie(netPrecision, inputShape0, inputShape1, targetDevice) = this->GetParam(); + + auto input0 = std::make_shared(ngraph::element::f32, ngraph::Shape{inputShape0}); + auto input1 = std::make_shared(ngraph::element::f32, ngraph::Shape{inputShape1}); + + auto add = std::make_shared(input0, input1); + auto neg = std::make_shared(add); + auto result = std::make_shared(neg); + + function = std::make_shared( + ngraph::ResultVector{result}, + ngraph::ParameterVector{input0, input1}, + "CodegenAdd"); + } + +TEST_P(CodegenAdd, CompareWithRefImpl) { + Run(); +}; + +} // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/src/subgraph_tests/codegen_bert.cpp b/inference-engine/tests/functional/plugin/shared/src/subgraph_tests/codegen_bert.cpp new file mode 100644 index 00000000000000..d4e328e19b8a95 --- /dev/null +++ b/inference-engine/tests/functional/plugin/shared/src/subgraph_tests/codegen_bert.cpp @@ -0,0 +1,76 @@ + +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include +#include +#include + +#include + +#include "common_test_utils/common_utils.hpp" +#include "functional_test_utils/plugin_cache.hpp" +#include "shared_test_classes/base/layer_test_utils.hpp" +#include "functional_test_utils/blob_utils.hpp" + +#include "ngraph_functions/pass/convert_prc.hpp" + +#include "subgraph_tests/codegen_bert.hpp" + +namespace LayerTestsDefinitions { + + std::string CodegenBert::getTestCaseName(testing::TestParamInfo obj) { + InferenceEngine::Precision netPrecision; + InferenceEngine::SizeVector inputShapes0, inputShapes1, newInputShapes; + std::string targetDevice; + std::tie(netPrecision, inputShapes0, inputShapes1, targetDevice) = obj.param; + + std::ostringstream result; + result << "IS[0]=" << CommonTestUtils::vec2str(inputShapes0) << "_"; + result << "IS[1]=" << CommonTestUtils::vec2str(inputShapes1) << "_"; + result << "netPRC=" << netPrecision.name() << "_"; + result << "targetDevice=" << targetDevice; + return result.str(); + } + + // the simplest possible eltwise operation with streaming access to the data + void CodegenBert::SetUp() { + std::vector inputShape0, inputShape1; + InferenceEngine::Precision netPrecision; + std::tie(netPrecision, inputShape0, inputShape1, targetDevice) = this->GetParam(); + + auto shape = ngraph::Shape{inputShape0}; + auto input1 = std::make_shared(ngraph::element::f32, shape); + auto input2 = std::make_shared(ngraph::element::f32, shape); + + auto shapeMM = ngraph::Shape{inputShape1}; + auto input3 = std::make_shared(ngraph::element::f32, shapeMM); + + auto add = std::make_shared(input1, input2); + auto mm = std::make_shared(add, input3); + + std::vector vals(ngraph::shape_size(shape)); + for (int i = 0; i < vals.size(); i++) { + vals[i] = static_cast(i)*vals.size(); + } + + auto c0 = std::make_shared(ngraph::element::f32, shape); + auto add2 = std::make_shared(mm, c0); + + auto add3 = std::make_shared(add, add2); + auto result = std::make_shared(add3); + + function = std::make_shared( + ngraph::ResultVector{result}, + // it should be some topological order to pass parameters for reference code to be executed correctly + ngraph::ParameterVector{input1, input2, c0, input3}, + "CodegenBert"); + } + +TEST_P(CodegenBert, CompareWithRefImpl) { + Run(); +}; + +} // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/src/subgraph_tests/codegen_gelu.cpp b/inference-engine/tests/functional/plugin/shared/src/subgraph_tests/codegen_gelu.cpp new file mode 100644 index 00000000000000..bbf7402d4fa6da --- /dev/null +++ b/inference-engine/tests/functional/plugin/shared/src/subgraph_tests/codegen_gelu.cpp @@ -0,0 +1,74 @@ + +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include +#include +#include + +#include + +#include "common_test_utils/common_utils.hpp" +#include "functional_test_utils/plugin_cache.hpp" +#include "shared_test_classes/base/layer_test_utils.hpp" +#include "functional_test_utils/blob_utils.hpp" + +#include "ngraph_functions/pass/convert_prc.hpp" + +#include "subgraph_tests/codegen_gelu.hpp" + +#include +#include + +#include +#include + +namespace LayerTestsDefinitions { + + std::string CodegenGelu::getTestCaseName(testing::TestParamInfo obj) { + InferenceEngine::Precision netPrecision; + InferenceEngine::SizeVector inputShapes0, newInputShapes; + bool useSubgraph; + std::string targetDevice; + std::tie(netPrecision, inputShapes0, useSubgraph, targetDevice) = obj.param; + + std::ostringstream result; + result << "IS[0]=" << CommonTestUtils::vec2str(inputShapes0) << "_"; + result << "netPRC=" << netPrecision.name() << "_"; + result << "overSnippet=" << (useSubgraph ? "yes" : "no") << "_"; + result << "targetDevice=" << targetDevice; + return result.str(); + } + + // Gelu from bert-large-uncased-whole-word-masking-squad-fp32-onnx-0001 + void CodegenGelu::SetUp() { + std::vector inputShape0; + InferenceEngine::Precision netPrecision; + bool useSubgraph; + std::tie(netPrecision, inputShape0, useSubgraph, targetDevice) = this->GetParam(); + + auto input0 = std::make_shared(ngraph::element::f32, ngraph::Shape{inputShape0}); + auto input1 = std::make_shared(ngraph::element::f32, ngraph::Shape{inputShape0}); + auto add = std::make_shared(input0, input1); + + auto gelu = std::make_shared(add); + auto result = std::make_shared(gelu); + + function = std::make_shared( + ngraph::ResultVector{result}, + ngraph::ParameterVector{input0, input1}, + "CodegenGelu"); + + if (useSubgraph) { + ngraph::pass::InitNodeInfo().run_on_function(function); + ngraph::pass::ConstantFolding().run_on_function(function); + } + } + +TEST_P(CodegenGelu, CompareWithRefImpl) { + Run(); +}; + +} // namespace LayerTestsDefinitions From ea3ed8af21b78da54e8e0d89b38cd236d3b6c7ba Mon Sep 17 00:00:00 2001 From: Gleb Kazantaev Date: Wed, 16 Jun 2021 03:12:24 +0300 Subject: [PATCH 095/178] Turn on IE and NG python APIs by default inside Model Optimizer (#5721) * Turn on IE and NG python APIs by default inside Model Optimizer * Remove fallback * Fix mo_ut * Remove MO wheel tests * Add model_optimizer custom target to gather all MO deps inside single traget * Fix PR comments --- .github/workflows/mo.yml | 38 ---------- .../ie_bridges/python/CMakeLists.txt | 4 ++ model-optimizer/CMakeLists.txt | 8 +++ model-optimizer/mo/main.py | 71 ++++++------------- model-optimizer/mo/utils/check_ie_bindings.py | 8 +++ model-optimizer/mo/utils/cli_parser.py | 9 +-- .../unit_tests/mo/utils/cli_parser_test.py | 4 +- 7 files changed, 47 insertions(+), 95 deletions(-) diff --git a/.github/workflows/mo.yml b/.github/workflows/mo.yml index eb2ea91484e7ca..ebc0827adb0622 100644 --- a/.github/workflows/mo.yml +++ b/.github/workflows/mo.yml @@ -62,42 +62,4 @@ jobs: mkdir ../mo-ut-logs python3 -m xmlrunner discover -p *_test.py --output=../mo-ut-logs working-directory: model-optimizer - - build_wheel: - name: Build Python wheel - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@v2 - - name: Install dependencies - run: | - python3 -m pip install --upgrade pip - python3 -m pip install wheel setuptools - python3 -m pip install tensorflow==2.3.0 - - - name: Build - run: | - python3 setup.py sdist bdist_wheel - working-directory: model-optimizer - - - name: Test package content - run: | - echo "src = open('openvino_mo.egg-info/SOURCES.txt', 'rt').read().split()" | tee -a test_wheel.py - echo "ref = open('automation/package_BOM.txt', 'rt').read().split()" | tee -a test_wheel.py - echo "for name in ref:" | tee -a test_wheel.py - echo " if name.endswith('.py'):" | tee -a test_wheel.py - echo " assert name in src or './' + name in src, name + ' file missed'" | tee -a test_wheel.py - python3 test_wheel.py - working-directory: model-optimizer - - - name: Test conversion - run: | - wget -q http://download.tensorflow.org/models/mobilenet_v1_2018_08_02/mobilenet_v1_1.0_224.tgz - tar -xf mobilenet_v1_1.0_224.tgz - python3 -m pip install model-optimizer/dist/*.whl - python3 -m mo --input_model mobilenet_v1_1.0_224_frozen.pb --input_shape "[1,224,224,3]" - - - uses: actions/upload-artifact@v2 - with: - name: mo_wheel - path: "model-optimizer/dist/*.whl" diff --git a/inference-engine/ie_bridges/python/CMakeLists.txt b/inference-engine/ie_bridges/python/CMakeLists.txt index 5c80af7f574f72..b8216b0cb3435a 100644 --- a/inference-engine/ie_bridges/python/CMakeLists.txt +++ b/inference-engine/ie_bridges/python/CMakeLists.txt @@ -68,6 +68,10 @@ if(ENABLE_WHEEL) add_subdirectory(wheel) endif() +if (NGRAPH_PYTHON_BUILD_ENABLE) + add_dependencies(ie_api _pyngraph) +endif() + # install ie_cpack_add_component(${PYTHON_VERSION}) diff --git a/model-optimizer/CMakeLists.txt b/model-optimizer/CMakeLists.txt index e9d54d6081867d..b0e75505cc2cd3 100644 --- a/model-optimizer/CMakeLists.txt +++ b/model-optimizer/CMakeLists.txt @@ -1,6 +1,14 @@ # Copyright (C) 2018-2021 Intel Corporation # SPDX-License-Identifier: Apache-2.0 +if (NOT NGRAPH_PYTHON_BUILD_ENABLE) + message(WARNING "Please enable nGraph Python API (_pyngraph) target to enable Model Optimizer target") +elseif(NOT ENABLE_PYTHON) + message(WARNING "Please enable IE Python API (ie_api and offline_transformations_api) targets to enable Model Optimizer target") +else() + add_custom_target(model_optimizer DEPENDS ie_api offline_transformations_api inference_engine_ir_reader) +endif() + # install ie_cpack_add_component(model_optimizer) diff --git a/model-optimizer/mo/main.py b/model-optimizer/mo/main.py index aa0eb628ad8095..b4b32fa786ecbc 100644 --- a/model-optimizer/mo/main.py +++ b/model-optimizer/mo/main.py @@ -144,20 +144,18 @@ def prepare_ir(argv: argparse.Namespace): # This try-except is additional reinsurance that the IE # dependency search does not break the MO pipeline - try: - argv.ie_is_available = find_ie_version(silent=argv.silent) - - if not argv.ie_is_available and not argv.silent: - print("[ WARNING ] Could not find the Inference Engine Python API. At this moment, the Inference Engine dependency is not required, but will be required in future releases.") - print("[ WARNING ] Consider building the Inference Engine Python API from sources or try to install OpenVINO (TM) Toolkit using \"install_prerequisites.{}\"".format( + def raise_ie_not_found(): + raise Error("Could not find the Inference Engine or nGraph Python API.\n" + "Consider building the Inference Engine and nGraph Python APIs from sources or try to install OpenVINO (TM) Toolkit using \"install_prerequisites.{}\"".format( "bat" if sys.platform == "windows" else "sh")) - # If the IE was not found, it will not print the MO version, so we have to print it manually - print("{}: \t{}".format("Model Optimizer version", get_version())) + try: + if not find_ie_version(silent=argv.silent): + raise_ie_not_found() except Exception as e: - argv.ie_is_available = False + raise_ie_not_found() # This is just to check that transform key is valid and transformations are available - check_available_transforms(parse_transform(argv.transform), argv.ie_is_available) + check_available_transforms(parse_transform(argv.transform)) if argv.legacy_ir_generation and len(argv.transform) != 0: raise Error("--legacy_ir_generation and --transform keys can not be used at the same time.") @@ -261,10 +259,6 @@ def emit_ir(graph: Graph, argv: argparse.Namespace): mean_data = deepcopy(graph.graph['mf']) if 'mf' in graph.graph else None input_names = deepcopy(graph.graph['input_names']) if 'input_names' in graph.graph else [] - # Remove temporary ie_is_available key from argv no to have it in IR - ie_is_available = argv.ie_is_available - del argv.ie_is_available - prepare_emit_ir(graph=graph, data_type=graph.graph['cmd_params'].data_type, output_dir=argv.output_dir, @@ -285,7 +279,7 @@ def emit_ir(graph: Graph, argv: argparse.Namespace): # This try-except is additional reinsurance that the IE # dependency search does not break the MO pipeline try: - if not argv.legacy_ir_generation and ie_is_available: + if not argv.legacy_ir_generation: path_to_offline_transformations = os.path.join(os.path.realpath(os.path.dirname(__file__)), 'back', 'offline_transformations.py') status = subprocess.run([sys.executable, path_to_offline_transformations, @@ -295,7 +289,7 @@ def emit_ir(graph: Graph, argv: argparse.Namespace): return_code = status.returncode except Exception as e: return_code = "failed" - log.error(e, extra={'is_warning': True}) + log.error(e) message = str(dict({ "platform": platform.system(), @@ -307,39 +301,20 @@ def emit_ir(graph: Graph, argv: argparse.Namespace): t = tm.Telemetry() t.send_event('mo', 'offline_transformations_status', message) - # if IR wasn't produced by offline_transformations step we need to fallback to IR - # produced by prepare_ir. This IR needs to be renamed from XXX_tmp.xml to XXX.xml - suffixes = [".xml", ".bin", ".mapping"] if return_code != 0: - if len(argv.transform) != 0: - # Remove temporary IR before throwing exception - for suf in suffixes: - path_to_file = orig_model_name + "_tmp" + suf - if os.path.exists(path_to_file): - os.remove(path_to_file) - raise Error("Failed to apply transformations: {}".format(argv.transform)) - - log.error("Using fallback to produce IR.", extra={'is_warning': True}) - for suf in suffixes: - # remove existing files - path_to_file = orig_model_name + suf - if os.path.exists(path_to_file): - os.remove(path_to_file) - - # rename tmp IR to original name - os.rename(orig_model_name + "_tmp" + suf, orig_model_name + suf) - else: - for suf in suffixes: - # remove existing files - path_to_file = orig_model_name + "_tmp" + suf - if os.path.exists(path_to_file): - os.remove(path_to_file) - - # add meta information to IR - append_ir_info(file=orig_model_name, - meta_info=get_meta_info(argv), - mean_data=mean_data, - input_names=input_names) + raise Error("offline transformations step has failed.") + + for suf in [".xml", ".bin", ".mapping"]: + # remove existing files + path_to_file = orig_model_name + "_tmp" + suf + if os.path.exists(path_to_file): + os.remove(path_to_file) + + # add meta information to IR + append_ir_info(file=orig_model_name, + meta_info=get_meta_info(argv), + mean_data=mean_data, + input_names=input_names) print('[ SUCCESS ] Generated IR version {} model.'.format(get_ir_version(argv))) print('[ SUCCESS ] XML file: {}.xml'.format(orig_model_name)) diff --git a/model-optimizer/mo/utils/check_ie_bindings.py b/model-optimizer/mo/utils/check_ie_bindings.py index fe03294bad149b..dae7aeb9958b12 100644 --- a/model-optimizer/mo/utils/check_ie_bindings.py +++ b/model-optimizer/mo/utils/check_ie_bindings.py @@ -51,7 +51,13 @@ def import_core_modules(silent: bool, path_to_module: str): from openvino.offline_transformations import ApplyMOCTransformations, ApplyLowLatencyTransformation, \ GenerateMappingFile # pylint: disable=import-error,no-name-in-module + # TODO: it is temporary import to check that nGraph python API is available. But in future + # we need to replace it with Frontend imports + from ngraph.impl.op import Parameter # pylint: disable=import-error,no-name-in-module + from _pyngraph import PartialShape, Dimension # pylint: disable=import-error,no-name-in-module + import openvino # pylint: disable=import-error,no-name-in-module + import ngraph # pylint: disable=import-error,no-name-in-module if silent: return True @@ -60,6 +66,8 @@ def import_core_modules(silent: bool, path_to_module: str): mo_version = str(v.get_version()) # pylint: disable=no-member,no-name-in-module print("\t- {}: \t{}".format("Inference Engine found in", os.path.dirname(openvino.__file__))) + # TODO: when nGraph version will be available we need to start compare it to IE and MO versions. Ticket: 58091 + print("\t- {}: \t{}".format("nGraph found in", os.path.dirname(ngraph.__file__))) print("{}: \t{}".format("Inference Engine version", ie_version)) print("{}: \t{}".format("Model Optimizer version", mo_version)) diff --git a/model-optimizer/mo/utils/cli_parser.py b/model-optimizer/mo/utils/cli_parser.py index e6b2f2d2517f83..a7dd5df023b995 100644 --- a/model-optimizer/mo/utils/cli_parser.py +++ b/model-optimizer/mo/utils/cli_parser.py @@ -1217,17 +1217,12 @@ def parse_transform(transform: str) -> list: return transforms -def check_available_transforms(transforms: list, ie_is_available: bool): +def check_available_transforms(transforms: list): """ This function check that transformations specified by user are available. :param transforms: list of user specified transformations - :param ie_is_available: True if IE Python API is available and False if it is not - :return: raises an Error if IE or transformation is not available + :return: raises an Error if transformation is not available """ - if not ie_is_available and len(transforms) != 0: - raise Error('Can not apply {} transformations due to missing Inference Engine Python API'.format( - ','.join([name for name, _ in transforms]))) - from mo.back.offline_transformations import get_available_transformations available_transforms = get_available_transformations() diff --git a/model-optimizer/unit_tests/mo/utils/cli_parser_test.py b/model-optimizer/unit_tests/mo/utils/cli_parser_test.py index c6c1c96e46a66e..c4d36780a686ca 100644 --- a/model-optimizer/unit_tests/mo/utils/cli_parser_test.py +++ b/model-optimizer/unit_tests/mo/utils/cli_parser_test.py @@ -959,11 +959,11 @@ def test_single_pass_with_args_neg6(self): def test_check_low_latency_is_available(self, available_transformations): available_transformations.return_value = {"LowLatency2": None} try: - check_available_transforms([("LowLatency2", "")], True) + check_available_transforms([("LowLatency2", "")]) except Error as e: self.assertTrue(False, "Exception \"{}\" is unexpected".format(e)) @patch("mo.back.offline_transformations.get_available_transformations") def test_check_dummy_pass_is_available(self, available_transformations): available_transformations.return_value = {"LowLatency2": None} - self.assertRaises(Error, check_available_transforms, [("DummyPass", "")], True) + self.assertRaises(Error, check_available_transforms, [("DummyPass", "")]) From 3292543252c657d49de03f2d006920e217bfad0d Mon Sep 17 00:00:00 2001 From: Roman Kazantsev Date: Wed, 16 Jun 2021 06:43:12 +0300 Subject: [PATCH 096/178] Fix recovery of output subscript in Einsum implicit mode (#6131) * Fix recovery of output subscript in Einsum implicit mode Signed-off-by: Roman Kazantsev * Fix code style Signed-off-by: Roman Kazantsev --- model-optimizer/extensions/ops/einsum.py | 23 ++++++++++- .../unit_tests/extensions/ops/einsum_test.py | 5 +++ ngraph/core/src/op/einsum.cpp | 39 +++++++++++++++++-- ngraph/test/type_prop/einsum.cpp | 28 +++++++++++++ 4 files changed, 90 insertions(+), 5 deletions(-) diff --git a/model-optimizer/extensions/ops/einsum.py b/model-optimizer/extensions/ops/einsum.py index 907989216acf46..a30bb96bdfcb89 100644 --- a/model-optimizer/extensions/ops/einsum.py +++ b/model-optimizer/extensions/ops/einsum.py @@ -28,6 +28,22 @@ def __init__(self, graph: Graph, attrs: dict): def backend_attrs(self): return ['equation'] + @staticmethod + def is_label_elsewhere(input_subscripts: list, label_to_check: str, excluded_subscript_inds: list) -> bool: + """ + Check if the given label is met in input subscripts excluding ones specified by a list of indices + excluded_subscript_inds + + :param input_subscripts: input subscripts among which to check if the label is met + :param label_to_check: a label to check + :param excluded_subscript_inds: indices of input subscripts to be excluded for this check + :return: True - met, False - otherwise + """ + for ind, input_subscript in enumerate(input_subscripts): + if ind not in excluded_subscript_inds and label_to_check in input_subscript: + return True + return False + @staticmethod def parse_equation(node_name: str, equation: str) -> (list, str): """ @@ -70,7 +86,12 @@ def parse_equation(node_name: str, equation: str) -> (list, str): "The output subscript of Einsum node {} must contain ellipsis".format(node_name) elif len(splitted_equation) == 1: # recover output subscript in case implicit mode - output_subscript = ''.join(input_subscripts_list) + output_subscript = "" + for ind, input_subscript in enumerate(input_subscripts_list): + labels = Einsum.extract_subscript_labels(node_name, input_subscript) + for label in labels: + if Einsum.is_label_elsewhere(input_subscripts_list, label, [ind]) is False: + output_subscript += label output_subscript = ''.join(sorted(list(set(output_subscript) - {'.'}))) if is_ellipsis_met: output_subscript = "..." + output_subscript diff --git a/model-optimizer/unit_tests/extensions/ops/einsum_test.py b/model-optimizer/unit_tests/extensions/ops/einsum_test.py index 9407fe63d5f488..960db04310dea9 100644 --- a/model-optimizer/unit_tests/extensions/ops/einsum_test.py +++ b/model-optimizer/unit_tests/extensions/ops/einsum_test.py @@ -60,6 +60,11 @@ class TestEinsum(unittest.TestCase): ([int64_array([1, 3, 5])], "AbC", int64_array([1, 5, 3])), # mixed case letters and equation in implicit mode ([int64_array([3, 11, 1, 5]), int64_array([1, 3, 1, 7])], "a...b,B...", int64_array([3, 11, 7, 1, 3, 5])), + # inner product in implicit mode + ([int64_array([3]), int64_array([3])], "i,i", int64_array([])), + # equation with ellipsis and repeated labels in implicit mode + # "a...b,b..." is equivalent to "a...b,b...->...a" + ([int64_array([9, 1, 4, 3]), int64_array([3, 11, 7, 1])], "a...b,b...", int64_array([11, 7, 4, 9])), ]) def test_einsum(self, input_shapes, equation, ref_output_shape): graph = create_einsum_graph(input_shapes, equation) diff --git a/ngraph/core/src/op/einsum.cpp b/ngraph/core/src/op/einsum.cpp index fbf52ef888b7b3..721a8e0211e9de 100644 --- a/ngraph/core/src/op/einsum.cpp +++ b/ngraph/core/src/op/einsum.cpp @@ -60,11 +60,40 @@ bool is_subscript_correct(const std::string& subscript, bool& is_ellipsis_met) return true; } +/// \brief Check if the given label is met in input subscripts excluding ones +/// specified by a vector excluded_indices +/// +/// \param input_subscripts The vector of the input subscripts +/// \param label_to_check A label to check +/// \param excluded_indices A vector of input subscript indices to be excluded +/// +/// \return true - met, false - otherwise +/// +bool is_label_elsewhere(const std::vector& input_subscripts, + const std::string& label_to_check, + const std::vector& excluded_indices) +{ + for (size_t input_ind = 0; input_ind < input_subscripts.size(); ++input_ind) + { + const auto& input_subscript = input_subscripts[input_ind]; + // the subscript is checked only if its index is not in excluded indices list + bool check_subscript = + (std::find(excluded_indices.begin(), excluded_indices.end(), input_ind) == + excluded_indices.end()); + if (check_subscript && input_subscript.find(label_to_check) != std::string::npos) + { + return true; + } + } + return false; +} + void op::v7::Einsum::parse_equation(const std::string& equation, std::vector& input_subscripts, std::string& output_subscript) { NGRAPH_OP_SCOPE(v7_Einsum_parse_equation); + constexpr char ellipsis[] = "..."; // split equation to input subscripts and an output subscript auto pos_output_delimeter = equation.find("->"); @@ -93,13 +122,15 @@ void op::v7::Einsum::parse_equation(const std::string& equation, if (pos_output_delimeter == std::string::npos) { - // recover output subscript + // equation is in implicit mode so recover output subscript output_subscript = ""; - for (auto const& input_subscript : input_subscripts) + for (size_t ind = 0; ind < input_subscripts.size(); ++ind) { - for (auto const& label : input_subscript) + auto const& input_subscript = input_subscripts[ind]; + for (auto const& label : extract_labels(input_subscript)) { - if (std::isalpha(label) && output_subscript.find(label) == std::string::npos) + if (label != ellipsis && + (is_label_elsewhere(input_subscripts, label, {ind}) == false)) { output_subscript += label; } diff --git a/ngraph/test/type_prop/einsum.cpp b/ngraph/test/type_prop/einsum.cpp index a65fb0677f4ad9..cea89ea7076416 100644 --- a/ngraph/test/type_prop/einsum.cpp +++ b/ngraph/test/type_prop/einsum.cpp @@ -186,6 +186,34 @@ TEST(type_prop, einsum_implicitmode_mixedcaseletters2) ASSERT_TRUE(O->get_output_partial_shape(0).same_scheme(out_shape)); } +TEST(type_prop, einsum_implicitmode_repeatedlabels) +{ + // the following equation is equivalent to "a...b,b...->...a" + std::string equation = "a...b,b..."; + const auto input1_shape = PartialShape{Dimension(3, 5), 11, 1, 3}; + const auto input2_shape = PartialShape{Dimension(1, 3), 3, 1, 7}; + const auto out_shape = PartialShape{3, 11, 7, Dimension(3, 5)}; + auto I1 = make_shared(element::f32, input1_shape); + auto I2 = make_shared(element::f32, input2_shape); + auto O = make_shared(OutputVector{I1, I2}, equation); + ASSERT_EQ(O->get_element_type(), element::f32); + ASSERT_TRUE(O->get_output_partial_shape(0).same_scheme(out_shape)); +} + +TEST(type_prop, einsum_implicitmode_innerprod) +{ + // the following equation is equivalent to "i,i->" + std::string equation = "i,i"; + const auto input1_shape = PartialShape{11}; + const auto input2_shape = PartialShape{Dimension(1, 20)}; + const auto out_shape = PartialShape{}; + auto I1 = make_shared(element::f32, input1_shape); + auto I2 = make_shared(element::f32, input2_shape); + auto O = make_shared(OutputVector{I1, I2}, equation); + ASSERT_EQ(O->get_element_type(), element::f32); + ASSERT_TRUE(O->get_output_partial_shape(0).same_scheme(out_shape)); +} + TEST(type_prop, einsum_dynamicrank_multimatmul) { std::string equation = "ab,bcd,bc->ca"; From 4fb2d83db9b4bd524498800e50de9cb9bc3e669e Mon Sep 17 00:00:00 2001 From: Patryk Elszkowski Date: Wed, 16 Jun 2021 06:09:57 +0200 Subject: [PATCH 097/178] use RTTI declaration macro and add visitor API test (#6147) --- ngraph/core/include/ngraph/op/parameter.hpp | 5 ++-- ngraph/core/src/op/parameter.cpp | 2 +- ngraph/test/CMakeLists.txt | 3 +- ngraph/test/visitors/op/parameter.cpp | 33 +++++++++++++++++++++ 4 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 ngraph/test/visitors/op/parameter.cpp diff --git a/ngraph/core/include/ngraph/op/parameter.hpp b/ngraph/core/include/ngraph/op/parameter.hpp index 50de93b529b7a3..01b57f5b80f37c 100644 --- a/ngraph/core/include/ngraph/op/parameter.hpp +++ b/ngraph/core/include/ngraph/op/parameter.hpp @@ -21,8 +21,7 @@ namespace ngraph class NGRAPH_API Parameter : public op::Op { public: - static constexpr NodeTypeInfo type_info{"Parameter", 0}; - const NodeTypeInfo& get_type_info() const override { return type_info; } + NGRAPH_RTTI_DECLARATION; /// \brief Constructions a tensor-typed parameter node. Parameter() = default; /// \brief Constructions a tensor-typed parameter node. @@ -56,7 +55,7 @@ namespace ngraph protected: PartialShape m_partial_shape; element::Type m_element_type; - bool m_is_relevant_to_shapes; + bool m_is_relevant_to_shapes{false}; }; } // namespace v0 using v0::Parameter; diff --git a/ngraph/core/src/op/parameter.cpp b/ngraph/core/src/op/parameter.cpp index c8d33c49db966e..ef979410a864a7 100644 --- a/ngraph/core/src/op/parameter.cpp +++ b/ngraph/core/src/op/parameter.cpp @@ -11,7 +11,7 @@ using namespace std; using namespace ngraph; -constexpr NodeTypeInfo op::Parameter::type_info; +NGRAPH_RTTI_DEFINITION(op::v0::Parameter, "Parameter", 0); op::Parameter::Parameter(const element::Type& element_type, const PartialShape& pshape) : m_partial_shape(pshape) diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index b9e65209bb8367..2850bd9d2e6508 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -252,6 +252,7 @@ set(SRC visitors/op/normalize_l2.cpp visitors/op/one_hot.cpp visitors/op/pad.cpp + visitors/op/parameter.cpp visitors/op/prior_box.cpp visitors/op/proposal.cpp visitors/op/psroi_pooling.cpp @@ -595,4 +596,4 @@ target_include_directories(unit-test PRIVATE ${FRONTEND_INCLUDE_PATH}) target_link_libraries(unit-test PRIVATE frontend_manager) add_subdirectory(frontend) -### END FRONTEND ### \ No newline at end of file +### END FRONTEND ### diff --git a/ngraph/test/visitors/op/parameter.cpp b/ngraph/test/visitors/op/parameter.cpp new file mode 100644 index 00000000000000..991bf6a3e9e5d5 --- /dev/null +++ b/ngraph/test/visitors/op/parameter.cpp @@ -0,0 +1,33 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" + +#include "ngraph/ngraph.hpp" +#include "ngraph/op/util/attr_types.hpp" +#include "ngraph/opsets/opset1.hpp" +#include "ngraph/opsets/opset3.hpp" +#include "ngraph/opsets/opset4.hpp" +#include "ngraph/opsets/opset5.hpp" + +#include "util/visitor.hpp" + +using namespace ngraph; +using ngraph::test::NodeBuilder; + +TEST(attributes, parameter_op) +{ + NodeBuilder::get_ops().register_factory(); + auto parameter = + std::make_shared(element::f32, PartialShape{Dimension{1}, Dimension{4}}); + + NodeBuilder builder(parameter); + auto g_parameter = as_type_ptr(builder.create()); + + const auto expected_attr_count = 2; + EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); + + EXPECT_EQ(g_parameter->get_partial_shape(), parameter->get_partial_shape()); + EXPECT_EQ(g_parameter->get_element_type(), parameter->get_element_type()); +} From c4274d4c32def52189ee8fd5f92d663c9fa00321 Mon Sep 17 00:00:00 2001 From: Jan Iwaszkiewicz Date: Wed, 16 Jun 2021 06:36:06 +0200 Subject: [PATCH 098/178] Change version of pybind (#6145) --- ngraph/python/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ngraph/python/CMakeLists.txt b/ngraph/python/CMakeLists.txt index 501bfffb4b2feb..58d30c300fdf3b 100644 --- a/ngraph/python/CMakeLists.txt +++ b/ngraph/python/CMakeLists.txt @@ -20,7 +20,7 @@ include(FetchContent) FetchContent_Declare( pybind11 GIT_REPOSITORY "https://github.com/pybind/pybind11.git" - GIT_TAG "v2.5.0" + GIT_TAG "v2.6.2" ) FetchContent_GetProperties(pybind11) From 59fd456ba2b7dc9e2d5bc8bdf72e891ec811dc3f Mon Sep 17 00:00:00 2001 From: Patryk Elszkowski Date: Wed, 16 Jun 2021 06:37:37 +0200 Subject: [PATCH 099/178] minor fixes in Parameter spec (#6146) * minor fixes in Parameter spec * expand supported type list and add output shape info --- docs/ops/infrastructure/Parameter_1.md | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/docs/ops/infrastructure/Parameter_1.md b/docs/ops/infrastructure/Parameter_1.md index 807a606a375036..879880002e6319 100644 --- a/docs/ops/infrastructure/Parameter_1.md +++ b/docs/ops/infrastructure/Parameter_1.md @@ -11,18 +11,27 @@ * *element_type* * **Description**: the type of element of output tensor - * **Range of values**: u8, u16, u32, u64, i8, i16, i32, i64, f16, f32, boolean, bf16 - * **Type**: string + * **Range of values**: u1, u4, u8, u16, u32, u64, i4, i8, i16, i32, i64, f16, f32, boolean, bf16 + * **Type**: `string` * **Default value**: None - * **Required**: *Yes* + * **Required**: *yes* * *shape* * **Description**: the shape of the output tensor - * **Range of values**: list of non-negative integers, empty list is allowed that means 0D or scalar tensor - * **Type**: int[] + * **Range of values**: list of non-negative integers, empty list is allowed, which means 0D or scalar tensor + * **Type**: `int[]` * **Default value**: None - * **Required**: *Yes* + * **Required**: *yes* + + +**Outputs** + +* **1**: Output tensor of type *T* and shape equal to *shape* attribute. + +**Types** + +* *T*: any type from *element type* values. **Example** @@ -38,4 +47,4 @@ -``` \ No newline at end of file +``` From 8c68f8b43c1cc0d56f767446550d032033edf79a Mon Sep 17 00:00:00 2001 From: Gabriele Galiero Casay Date: Wed, 16 Jun 2021 08:01:57 +0200 Subject: [PATCH 100/178] Revise reference implementation for ReduceMin operation (#5797) * Revise reference implementation for ReduceMin operation * Refactor backend unit tests * Move tests with zero dims to op_eval * Fix code style * Added minor changes * Replace CoordinateTransform for CoordinateTransformBasic * Added constant expression to set keep_dims as false * Add const qualifier to local variables * Use host tensor to retrieve and normalize axes * Re-arrange unit tests in manifest --- .../include/ngraph/runtime/reference/min.hpp | 35 +-- ngraph/core/src/op/min.cpp | 9 +- ngraph/test/CMakeLists.txt | 1 + ngraph/test/backend/reduce_min.in.cpp | 241 ---------------- ngraph/test/op_eval/reduce_min.cpp | 258 ++++++++++++++++++ ngraph/test/runtime/ie/unit_test.manifest | 28 +- 6 files changed, 286 insertions(+), 286 deletions(-) create mode 100644 ngraph/test/op_eval/reduce_min.cpp diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/min.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/min.hpp index 9cfa7c16c4d2c9..ada3198834503d 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/min.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/min.hpp @@ -6,6 +6,7 @@ #include #include +#include #include "ngraph/coordinate_transform.hpp" #include "ngraph/shape_util.hpp" @@ -21,34 +22,34 @@ namespace ngraph namespace reference { template - void min(const T* arg, - T* out, - const Shape& in_shape, - const AxisSet& reduction_axes, - const bool keep_dims) + void min(const T* arg, T* out, const Shape& in_shape, const AxisSet& reduction_axes) { T minval = std::numeric_limits::has_infinity ? std::numeric_limits::infinity() : std::numeric_limits::max(); - const auto out_shape = reduce(in_shape, reduction_axes, keep_dims); - CoordinateTransform output_transform(out_shape); + constexpr bool dont_keep_dims_in_output = false; + const auto out_shape = reduce(in_shape, reduction_axes, dont_keep_dims_in_output); + std::fill(out, out + shape_size(out_shape), minval); - for (const Coordinate& output_coord : output_transform) - { - out[output_transform.index(output_coord)] = minval; - } - - CoordinateTransform input_transform(in_shape); + const auto in_strides = row_major_strides(in_shape); + const auto out_strides = row_major_strides(out_shape); + CoordinateTransformBasic input_transform(in_shape); for (const Coordinate& input_coord : input_transform) { - Coordinate output_coord = reduce(input_coord, reduction_axes, keep_dims); + const Coordinate output_coord = + reduce(input_coord, reduction_axes, dont_keep_dims_in_output); + + const size_t in_idx = std::inner_product( + input_coord.begin(), input_coord.end(), in_strides.begin(), 0); + const size_t out_idx = std::inner_product( + output_coord.begin(), output_coord.end(), out_strides.begin(), 0); - T x = arg[input_transform.index(input_coord)]; - T min = out[output_transform.index(output_coord)]; + const T x = arg[in_idx]; + const T min = out[out_idx]; if (x < min) { - out[output_transform.index(output_coord)] = x; + out[out_idx] = x; } } } diff --git a/ngraph/core/src/op/min.cpp b/ngraph/core/src/op/min.cpp index 37f3512413b53e..36b248ed69b47e 100644 --- a/ngraph/core/src/op/min.cpp +++ b/ngraph/core/src/op/min.cpp @@ -5,6 +5,7 @@ #include "ngraph/op/min.hpp" #include #include "itt.hpp" +#include "ngraph/op/util/evaluate_helpers.hpp" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/runtime/reference/min.hpp" #include "ngraph/shape_util.hpp" @@ -22,7 +23,7 @@ namespace minop { out->set_shape(reduce(arg->get_shape(), axes, keep_dims)); runtime::reference::min( - arg->get_data_ptr(), out->get_data_ptr(), arg->get_shape(), axes, keep_dims); + arg->get_data_ptr(), out->get_data_ptr(), arg->get_shape(), axes); return true; } @@ -69,7 +70,11 @@ bool op::v1::ReduceMin::evaluate(const HostTensorVector& outputs, NGRAPH_OP_SCOPE(v1_ReduceMin_evaluate); NGRAPH_CHECK(validate_host_tensor_vector(inputs, 2)); NGRAPH_CHECK(validate_host_tensor_vector(outputs, 1)); - return minop::evaluate_min(inputs[0], outputs[0], get_reduction_axes(), get_keep_dims()); + + const auto reduction_axes = get_normalized_axes_from_tensor( + inputs[1], inputs[0]->get_partial_shape().rank(), get_friendly_name()); + + return minop::evaluate_min(inputs[0], outputs[0], reduction_axes, get_keep_dims()); } bool op::v1::ReduceMin::has_evaluate() const diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index 2850bd9d2e6508..ca45c965c9ffa3 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -72,6 +72,7 @@ set(SRC op_eval/mish.cpp op_eval/non_zero.cpp op_eval/reduce_max.cpp + op_eval/reduce_min.cpp op_eval/reduce_prod.cpp op_eval/reduce_sum.cpp op_eval/roi_align.cpp diff --git a/ngraph/test/backend/reduce_min.in.cpp b/ngraph/test/backend/reduce_min.in.cpp index 21565248d08098..d43c96b17f7dc4 100644 --- a/ngraph/test/backend/reduce_min.in.cpp +++ b/ngraph/test/backend/reduce_min.in.cpp @@ -124,100 +124,6 @@ NGRAPH_TEST(${BACKEND_NAME}, reduce_min_matrix_rows_int32) EXPECT_EQ((vector{1, 3, 5}), read_vector(result)); } -NGRAPH_TEST(${BACKEND_NAME}, reduce_min_matrix_rows_zero) -{ - Shape shape_a{3, 0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{3}; - auto axes = make_shared(element::i32, Shape{}, 1); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3, 3, 3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_EQ((vector{std::numeric_limits::infinity(), - std::numeric_limits::infinity(), - std::numeric_limits::infinity()}), - read_vector(result)); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_min_matrix_cols_zero) -{ - // Now the reduction (g(x:float32[2,2],y:float32[]) = reduce(x,y,f,axes={})). - Shape shape_a{0, 2}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{2}; - auto axes = make_shared(element::i32, Shape{}, 0); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3, 3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_EQ((vector{std::numeric_limits::infinity(), - std::numeric_limits::infinity()}), - read_vector(result)); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_min_vector_zero) -{ - Shape shape_a{0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{}; - auto axes = make_shared(element::i32, Shape{}, 0); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_EQ((vector{std::numeric_limits::infinity()}), read_vector(result)); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_min_matrix_to_scalar_zero_by_zero) -{ - Shape shape_a{0, 0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{}; - auto axes = make_shared(element::i32, Shape{2}, vector{0, 1}); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_EQ((vector{std::numeric_limits::infinity()}), read_vector(result)); -} - NGRAPH_TEST(${BACKEND_NAME}, reduce_min_3d_to_matrix_most_sig) { Shape shape_a{3, 3, 3}; @@ -334,33 +240,6 @@ NGRAPH_TEST(${BACKEND_NAME}, reduce_min_3d_to_scalar_int32) EXPECT_EQ((vector{1}), read_vector(result)); } -NGRAPH_TEST(${BACKEND_NAME}, reduce_min_3d_eliminate_zero_dim) -{ - Shape shape_a{3, 0, 2}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{3, 2}; - auto axes = make_shared(element::i32, Shape{}, 1); - auto f = - make_shared(make_shared(A, axes, false), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - - // Overwrite the initial result vector to make sure we're not just coincidentally getting the - // right value. - copy_data(result, vector{2112, 2112, 2112, 2112, 2112, 2112}); - - float inf = std::numeric_limits::infinity(); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_EQ((vector{inf, inf, inf, inf, inf, inf}), read_vector(result)); -} - // ----------------------- keep dims = true ----------------------- // NGRAPH_TEST(${BACKEND_NAME}, reduce_min_keep_to_scalar) @@ -469,99 +348,6 @@ NGRAPH_TEST(${BACKEND_NAME}, reduce_min_keep_matrix_rows_int32) EXPECT_EQ((vector{1, 3, 5}), read_vector(result)); } -NGRAPH_TEST(${BACKEND_NAME}, reduce_min_keep_matrix_rows_zero) -{ - Shape shape_a{3, 0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{3, 1}; - auto axes = make_shared(element::i32, Shape{}, 1); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3, 3, 3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_EQ((vector{std::numeric_limits::infinity(), - std::numeric_limits::infinity(), - std::numeric_limits::infinity()}), - read_vector(result)); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_min_keep_matrix_cols_zero) -{ - // Now the reduction (g(x:float32[2,2],y:float32[]) = reduce(x,y,f,axes={})). - Shape shape_a{0, 2}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{1, 2}; - auto axes = make_shared(element::i32, Shape{}, 0); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3, 3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_EQ((vector{std::numeric_limits::infinity(), - std::numeric_limits::infinity()}), - read_vector(result)); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_min_keep_vector_zero) -{ - Shape shape_a{0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{1}; - auto axes = make_shared(element::i32, Shape{}, 0); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_EQ((vector{std::numeric_limits::infinity()}), read_vector(result)); -} - -NGRAPH_TEST(${BACKEND_NAME}, reduce_min_keep_matrix_to_scalar_zero_by_zero) -{ - Shape shape_a{0, 0}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{1, 1}; - auto axes = make_shared(element::i32, Shape{2}, vector{0, 1}); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - copy_data(result, vector({3})); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_EQ((vector{std::numeric_limits::infinity()}), read_vector(result)); -} NGRAPH_TEST(${BACKEND_NAME}, reduce_min_keep_3d_to_matrix_most_sig) { @@ -679,33 +465,6 @@ NGRAPH_TEST(${BACKEND_NAME}, reduce_min_keep_3d_to_scalar_int32) EXPECT_EQ((vector{1}), read_vector(result)); } -NGRAPH_TEST(${BACKEND_NAME}, reduce_min_keep_3d_eliminate_zero_dim) -{ - Shape shape_a{3, 0, 2}; - auto A = make_shared(element::f32, shape_a); - Shape shape_rt{3, 1, 2}; - auto axes = make_shared(element::i32, Shape{}, 1); - auto f = - make_shared(make_shared(A, axes, true), ParameterVector{A}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, vector{}); - auto result = backend->create_tensor(element::f32, shape_rt); - - // Overwrite the initial result vector to make sure we're not just coincidentally getting the - // right value. - copy_data(result, vector{2112, 2112, 2112, 2112, 2112, 2112}); - - float inf = std::numeric_limits::infinity(); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_EQ((vector{inf, inf, inf, inf, inf, inf}), read_vector(result)); -} - // Dynamic NGRAPH_TEST(${BACKEND_NAME}, reduce_min_matrix_columns_dynamic) diff --git a/ngraph/test/op_eval/reduce_min.cpp b/ngraph/test/op_eval/reduce_min.cpp new file mode 100644 index 00000000000000..cc74b0b6f591e8 --- /dev/null +++ b/ngraph/test/op_eval/reduce_min.cpp @@ -0,0 +1,258 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "util/test_control.hpp" +#include "util/all_close.hpp" +#include "util/all_close_f.hpp" +#include "util/ndarray.hpp" + + +using namespace std; +using namespace ngraph; + +static string s_manifest = "${MANIFEST}"; + +TEST(op_eval, reduce_min_matrix_rows_zero) +{ + Shape shape_a{3, 0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{3}; + auto axes = make_shared(element::i32, Shape{}, 1); + auto f = + make_shared(make_shared(A, axes, false), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3, 3, 3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_EQ((vector{std::numeric_limits::infinity(), + std::numeric_limits::infinity(), + std::numeric_limits::infinity()}), + read_vector(result)); +} + +TEST(op_eval, reduce_min_matrix_cols_zero) +{ + // Now the reduction (g(x:float32[2,2],y:float32[]) = reduce(x,y,f,axes={})). + Shape shape_a{0, 2}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{2}; + auto axes = make_shared(element::i32, Shape{}, 0); + auto f = + make_shared(make_shared(A, axes, false), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3, 3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_EQ((vector{std::numeric_limits::infinity(), + std::numeric_limits::infinity()}), + read_vector(result)); +} + +TEST(op_eval, reduce_min_vector_zero) +{ + Shape shape_a{0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{}; + auto axes = make_shared(element::i32, Shape{}, 0); + auto f = + make_shared(make_shared(A, axes, false), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_EQ((vector{std::numeric_limits::infinity()}), read_vector(result)); +} + +TEST(op_eval, reduce_min_matrix_to_scalar_zero_by_zero) +{ + Shape shape_a{0, 0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{}; + auto axes = make_shared(element::i32, Shape{2}, vector{0, 1}); + auto f = + make_shared(make_shared(A, axes, false), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_EQ((vector{std::numeric_limits::infinity()}), read_vector(result)); +} + +TEST(op_eval, reduce_min_3d_eliminate_zero_dim) +{ + Shape shape_a{3, 0, 2}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{3, 2}; + auto axes = make_shared(element::i32, Shape{}, 1); + auto f = + make_shared(make_shared(A, axes, false), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + + // Overwrite the initial result vector to make sure we're not just coincidentally getting the + // right value. + copy_data(result, vector{2112, 2112, 2112, 2112, 2112, 2112}); + + float inf = std::numeric_limits::infinity(); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_EQ((vector{inf, inf, inf, inf, inf, inf}), read_vector(result)); +} + +TEST(op_eval, reduce_min_keep_matrix_rows_zero) +{ + Shape shape_a{3, 0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{3, 1}; + auto axes = make_shared(element::i32, Shape{}, 1); + auto f = + make_shared(make_shared(A, axes, true), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3, 3, 3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_EQ((vector{std::numeric_limits::infinity(), + std::numeric_limits::infinity(), + std::numeric_limits::infinity()}), + read_vector(result)); +} + +TEST(op_eval, reduce_min_keep_matrix_cols_zero) +{ + // Now the reduction (g(x:float32[2,2],y:float32[]) = reduce(x,y,f,axes={})). + Shape shape_a{0, 2}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{1, 2}; + auto axes = make_shared(element::i32, Shape{}, 0); + auto f = + make_shared(make_shared(A, axes, true), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3, 3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_EQ((vector{std::numeric_limits::infinity(), + std::numeric_limits::infinity()}), + read_vector(result)); +} + +TEST(op_eval, reduce_min_keep_vector_zero) +{ + Shape shape_a{0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{1}; + auto axes = make_shared(element::i32, Shape{}, 0); + auto f = + make_shared(make_shared(A, axes, true), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_EQ((vector{std::numeric_limits::infinity()}), read_vector(result)); +} + +TEST(op_eval, reduce_min_keep_matrix_to_scalar_zero_by_zero) +{ + Shape shape_a{0, 0}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{1, 1}; + auto axes = make_shared(element::i32, Shape{2}, vector{0, 1}); + auto f = + make_shared(make_shared(A, axes, true), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + copy_data(result, vector({3})); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_EQ((vector{std::numeric_limits::infinity()}), read_vector(result)); +} + +TEST(op_eval, reduce_min_keep_3d_eliminate_zero_dim) +{ + Shape shape_a{3, 0, 2}; + auto A = make_shared(element::f32, shape_a); + Shape shape_rt{3, 1, 2}; + auto axes = make_shared(element::i32, Shape{}, 1); + auto f = + make_shared(make_shared(A, axes, true), ParameterVector{A}); + + auto backend = runtime::Backend::create("INTERPRETER"); + + // Create some tensors for input/output + auto a = backend->create_tensor(element::f32, shape_a); + copy_data(a, vector{}); + auto result = backend->create_tensor(element::f32, shape_rt); + + // Overwrite the initial result vector to make sure we're not just coincidentally getting the + // right value. + copy_data(result, vector{2112, 2112, 2112, 2112, 2112, 2112}); + + float inf = std::numeric_limits::infinity(); + + auto handle = backend->compile(f); + handle->call_with_validate({result}, {a}); + EXPECT_EQ((vector{inf, inf, inf, inf, inf, inf}), read_vector(result)); +} diff --git a/ngraph/test/runtime/ie/unit_test.manifest b/ngraph/test/runtime/ie/unit_test.manifest index a0a7c8735f58d3..adfebe2b57aac4 100644 --- a/ngraph/test/runtime/ie/unit_test.manifest +++ b/ngraph/test/runtime/ie/unit_test.manifest @@ -375,6 +375,8 @@ reduce_sum_keep_2d_to_scalar_int8 reduce_sum_2d_to_scalar_int8 reduce_product_to_scalar_int8 reduce_product_keep_to_scalar_int8 +reduce_min_to_scalar_int8 +reduce_min_keep_to_scalar_int8 # accuracy reduce_sum_keep_stable_acc reduce_sum_keep_3d_to_scalar_int32 @@ -441,34 +443,8 @@ onnx_dyn_shapes_model_tile_static gather_4d_indices_axis_0_uint8 tensor_constant_with_op constant_equality_bool -reduce_min_matrix_columns -reduce_min_matrix_rows -reduce_min_matrix_rows_int32 -reduce_min_3d_to_matrix_most_sig -reduce_min_3d_to_matrix_least_sig -reduce_min_keep_matrix_columns -reduce_min_keep_matrix_rows -reduce_min_keep_matrix_rows_int32 -reduce_min_keep_3d_to_matrix_most_sig -reduce_min_keep_3d_to_matrix_least_sig -reduce_min_matrix_columns_dynamic -reduce_min_matrix_rows_dynamic -reduce_min_keep_matrix_columns_dynamic -reduce_min_keep_matrix_rows_dynamic # zero dimension / result mismatch -reduce_min_to_scalar_int8 -reduce_min_matrix_rows_zero -reduce_min_matrix_cols_zero -reduce_min_vector_zero -reduce_min_matrix_to_scalar_zero_by_zero -reduce_min_3d_eliminate_zero_dim -reduce_min_keep_to_scalar_int8 -reduce_min_keep_matrix_rows_zero -reduce_min_keep_matrix_cols_zero -reduce_min_keep_vector_zero -reduce_min_keep_matrix_to_scalar_zero_by_zero -reduce_min_keep_3d_eliminate_zero_dim reduce_mean_to_scalar_int8 reduce_mean_matrix_rows_int32 reduce_mean_keep_to_scalar_int8 From b36c7736da8fd4f08cdc3f4d6d81af653622cf31 Mon Sep 17 00:00:00 2001 From: Evgenya Stepyreva Date: Wed, 16 Jun 2021 09:06:19 +0300 Subject: [PATCH 101/178] Deprecated legacy maximum_value method (#6178) * Deprecated legacy maximum_value method since it is less reliable than the existing one * Style and doxygen \deprecated comment --- .../common/src/ngraph/operations/static_shape_broadcast.cpp | 1 - inference-engine/src/vpu/common/src/ngraph/utilities.cpp | 1 - ngraph/core/include/ngraph/validation_util.hpp | 3 +++ 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/inference-engine/src/vpu/common/src/ngraph/operations/static_shape_broadcast.cpp b/inference-engine/src/vpu/common/src/ngraph/operations/static_shape_broadcast.cpp index a52bf97e707dd4..1490bd408e116d 100644 --- a/inference-engine/src/vpu/common/src/ngraph/operations/static_shape_broadcast.cpp +++ b/inference-engine/src/vpu/common/src/ngraph/operations/static_shape_broadcast.cpp @@ -8,7 +8,6 @@ #include "vpu/utils/error.hpp" #include "ngraph/opsets/opset3.hpp" -#include "ngraph/evaluator.hpp" #include namespace ngraph { namespace vpu { namespace op { diff --git a/inference-engine/src/vpu/common/src/ngraph/utilities.cpp b/inference-engine/src/vpu/common/src/ngraph/utilities.cpp index 47afb6a83a6a58..23576617f67994 100644 --- a/inference-engine/src/vpu/common/src/ngraph/utilities.cpp +++ b/inference-engine/src/vpu/common/src/ngraph/utilities.cpp @@ -6,7 +6,6 @@ #include "ngraph/opsets/opset3.hpp" #include "ngraph/opsets/opset5.hpp" -#include "ngraph/evaluator.hpp" #include diff --git a/ngraph/core/include/ngraph/validation_util.hpp b/ngraph/core/include/ngraph/validation_util.hpp index d8922f132a9cc6..de81ebfd171bb8 100644 --- a/ngraph/core/include/ngraph/validation_util.hpp +++ b/ngraph/core/include/ngraph/validation_util.hpp @@ -234,6 +234,9 @@ namespace ngraph /// \brief Try to compute the maximum value of value /// \return (true, max_value) if can be determined, or (false, numeric_limits::max()) /// if not. + /// \deprecated Use evaluate_upper_bound instead + NGRAPH_DEPRECATED( + "Use evaluate_upper_bound: it would return HostTensorPtr to the value instead of a pair") NGRAPH_API std::pair maximum_value(const Output& value); /// \brief Evaluates outputs, treating values in value_map as already computed. value_map is From 2f81968a3106dbd8f4adaa7bcf8bec778c84ce1c Mon Sep 17 00:00:00 2001 From: Vladimir Paramuzov Date: Wed, 16 Jun 2021 09:27:16 +0300 Subject: [PATCH 102/178] [IE CLDNN] Introduced new runtime API (#5417) --- .../src/cldnn_engine/CMakeLists.txt | 2 +- .../src/cldnn_engine/cldnn_common_utils.h | 2 +- .../src/cldnn_engine/cldnn_config.h | 2 +- .../src/cldnn_engine/cldnn_custom_layer.h | 2 +- .../src/cldnn_engine/cldnn_engine.cpp | 19 +- .../src/cldnn_engine/cldnn_engine.h | 4 +- .../cldnn_engine/cldnn_executable_network.cpp | 11 +- .../src/cldnn_engine/cldnn_graph.cpp | 34 +- .../src/cldnn_engine/cldnn_graph.h | 6 +- .../src/cldnn_engine/cldnn_infer_request.cpp | 225 +- .../src/cldnn_engine/cldnn_infer_request.h | 9 +- .../src/cldnn_engine/cldnn_program.cpp | 4 +- .../src/cldnn_engine/cldnn_program.h | 14 +- .../src/cldnn_engine/cldnn_remote_context.cpp | 109 +- .../src/cldnn_engine/cldnn_remote_context.h | 39 +- .../src/cldnn_engine/ops/batch_to_space.cpp | 2 +- .../src/cldnn_engine/ops/broadcast.cpp | 6 +- .../src/cldnn_engine/ops/concat.cpp | 2 +- .../src/cldnn_engine/ops/constant.cpp | 9 +- .../src/cldnn_engine/ops/convert.cpp | 2 +- .../src/cldnn_engine/ops/convolution.cpp | 10 +- .../cldnn_engine/ops/ctc_greedy_decoder.cpp | 10 +- .../src/cldnn_engine/ops/cum_sum.cpp | 2 +- .../src/cldnn_engine/ops/custom.cpp | 4 +- .../src/cldnn_engine/ops/depth_to_space.cpp | 2 +- .../src/cldnn_engine/ops/detection_output.cpp | 2 +- .../src/cldnn_engine/ops/eltwise.cpp | 8 +- .../src/cldnn_engine/ops/embedding_bag.cpp | 4 +- .../ops/extract_image_patches.cpp | 2 +- .../src/cldnn_engine/ops/fake_quantize.cpp | 2 +- .../src/cldnn_engine/ops/gather tree.cpp | 4 +- .../src/cldnn_engine/ops/gather.cpp | 4 +- .../src/cldnn_engine/ops/gather_nd.cpp | 2 +- inference-engine/src/cldnn_engine/ops/grn.cpp | 2 +- .../src/cldnn_engine/ops/interpolate.cpp | 2 +- inference-engine/src/cldnn_engine/ops/lrn.cpp | 2 +- .../src/cldnn_engine/ops/matmul.cpp | 10 +- inference-engine/src/cldnn_engine/ops/mvn.cpp | 3 +- .../cldnn_engine/ops/non_max_suppression.cpp | 12 +- .../src/cldnn_engine/ops/normalize_l2.cpp | 8 +- .../src/cldnn_engine/ops/one_hot.cpp | 2 +- inference-engine/src/cldnn_engine/ops/pad.cpp | 2 +- .../src/cldnn_engine/ops/parameter.cpp | 12 +- .../src/cldnn_engine/ops/pooling.cpp | 2 +- .../src/cldnn_engine/ops/prior_box.cpp | 2 +- .../src/cldnn_engine/ops/proposal.cpp | 6 +- .../src/cldnn_engine/ops/reduce.cpp | 6 +- .../src/cldnn_engine/ops/region_yolo.cpp | 2 +- .../src/cldnn_engine/ops/reorg_yolo.cpp | 2 +- .../src/cldnn_engine/ops/reshape.cpp | 4 +- .../src/cldnn_engine/ops/result.cpp | 2 +- .../src/cldnn_engine/ops/reverse_sequence.cpp | 2 +- inference-engine/src/cldnn_engine/ops/rnn.cpp | 12 +- .../src/cldnn_engine/ops/roi_pooling.cpp | 2 +- .../ops/scatter_elements_update.cpp | 2 +- .../cldnn_engine/ops/scatter_nd_update.cpp | 2 +- .../src/cldnn_engine/ops/scatter_update.cpp | 2 +- .../src/cldnn_engine/ops/select.cpp | 6 +- .../src/cldnn_engine/ops/shuffle_channels.cpp | 2 +- .../src/cldnn_engine/ops/softmax.cpp | 4 +- .../src/cldnn_engine/ops/space_to_batch.cpp | 2 +- .../src/cldnn_engine/ops/space_to_depth.cpp | 2 +- .../src/cldnn_engine/ops/split.cpp | 2 +- .../src/cldnn_engine/ops/strided_slice.cpp | 6 +- .../src/cldnn_engine/ops/tensor_iterator.cpp | 17 +- .../src/cldnn_engine/ops/tile.cpp | 2 +- .../src/cldnn_engine/ops/topk.cpp | 6 +- .../src/cldnn_engine/ops/transpose.cpp | 2 +- .../src/cldnn_engine/ops/unary.cpp | 2 +- .../functional/plugin/gpu/CMakeLists.txt | 2 +- .../thirdparty/clDNN/CMakeLists.txt | 58 +- .../thirdparty/clDNN/api/cldnn.hpp | 244 -- .../clDNN/api/{ => cldnn/graph}/network.hpp | 67 +- .../clDNN/api/{ => cldnn/graph}/program.hpp | 25 +- .../clDNN/api/{ => cldnn/graph}/topology.hpp | 25 +- .../api/{ => cldnn/primitives}/activation.hpp | 0 .../{ => cldnn/primitives}/arg_max_min.hpp | 0 .../primitives}/average_unpooling.hpp | 0 .../{ => cldnn/primitives}/batch_to_space.hpp | 0 .../primitives}/binary_convolution.hpp | 0 .../api/{ => cldnn/primitives}/border.hpp | 0 .../api/{ => cldnn/primitives}/broadcast.hpp | 0 .../{ => cldnn/primitives}/concatenation.hpp | 0 .../api/{ => cldnn/primitives}/condition.hpp | 2 +- .../{ => cldnn/primitives}/convolution.hpp | 0 .../clDNN/api/{ => cldnn/primitives}/crop.hpp | 0 .../primitives}/ctc_greedy_decoder.hpp | 0 .../api/{ => cldnn/primitives}/cum_sum.hpp | 0 .../primitives}/custom_gpu_primitive.hpp | 2 +- .../clDNN/api/{ => cldnn/primitives}/data.hpp | 6 +- .../{ => cldnn/primitives}/deconvolution.hpp | 0 .../{ => cldnn/primitives}/depth_to_space.hpp | 0 .../primitives}/detection_output.hpp | 0 .../api/{ => cldnn/primitives}/eltwise.hpp | 0 .../{ => cldnn/primitives}/embedding_bag.hpp | 0 .../primitives}/extract_image_patches.hpp | 0 .../primitives}/fully_connected.hpp | 0 .../cldnn/primitives}/fused_conv_eltwise.hpp | 4 +- .../api/{ => cldnn/primitives}/gather.hpp | 0 .../api/{ => cldnn/primitives}/gather_nd.hpp | 17 +- .../{ => cldnn/primitives}/gather_tree.hpp | 0 .../clDNN/api/{ => cldnn/primitives}/gemm.hpp | 0 .../clDNN/api/{ => cldnn/primitives}/grn.hpp | 0 .../{ => cldnn/primitives}/input_layout.hpp | 2 +- .../clDNN/api/{ => cldnn/primitives}/loop.hpp | 2 +- .../clDNN/api/{ => cldnn/primitives}/lrn.hpp | 0 .../clDNN/api/{ => cldnn/primitives}/lstm.hpp | 0 .../{ => cldnn/primitives}/lstm_dynamic.hpp | 0 .../cldnn/primitives}/lstm_dynamic_input.hpp | 2 +- .../primitives}/lstm_dynamic_timeloop.hpp | 2 +- .../{ => cldnn/primitives}/max_unpooling.hpp | 0 .../{ => cldnn/primitives}/mutable_data.hpp | 8 +- .../clDNN/api/{ => cldnn/primitives}/mvn.hpp | 0 .../primitives}/non_max_suppression.hpp | 0 .../api/{ => cldnn/primitives}/normalize.hpp | 0 .../api/{ => cldnn/primitives}/one_hot.hpp | 0 .../api/{ => cldnn/primitives}/permute.hpp | 0 .../api/{ => cldnn/primitives}/pooling.hpp | 0 .../api/{ => cldnn/primitives}/primitive.hpp | 6 +- .../api/{ => cldnn/primitives}/prior_box.hpp | 0 .../api/{ => cldnn/primitives}/proposal.hpp | 0 .../primitives}/pyramid_roi_align.hpp | 0 .../api/{ => cldnn/primitives}/quantize.hpp | 0 .../api/{ => cldnn/primitives}/reduce.hpp | 0 .../{ => cldnn/primitives}/region_yolo.hpp | 0 .../api/{ => cldnn/primitives}/reorder.hpp | 2 +- .../api/{ => cldnn/primitives}/reorg_yolo.hpp | 0 .../api/{ => cldnn/primitives}/resample.hpp | 0 .../api/{ => cldnn/primitives}/reshape.hpp | 0 .../primitives}/reverse_sequence.hpp | 0 .../{ => cldnn/primitives}/roi_pooling.hpp | 0 .../api/{ => cldnn/primitives}/scale.hpp | 0 .../primitives}/scatter_elements_update.hpp | 0 .../primitives}/scatter_nd_update.hpp | 0 .../{ => cldnn/primitives}/scatter_update.hpp | 0 .../api/{ => cldnn/primitives}/select.hpp | 0 .../primitives}/shuffle_channels.hpp | 0 .../api/{ => cldnn/primitives}/softmax.hpp | 0 .../{ => cldnn/primitives}/space_to_batch.hpp | 0 .../{ => cldnn/primitives}/space_to_depth.hpp | 0 .../api/{ => cldnn/primitives}/split.hpp | 0 .../{ => cldnn/primitives}/strided_slice.hpp | 0 .../clDNN/api/{ => cldnn/primitives}/tile.hpp | 0 .../runtime/compounds.hpp} | 3 +- .../clDNN/api/cldnn/runtime/device.hpp | 24 + .../clDNN/api/cldnn/runtime/device_info.hpp | 76 + .../clDNN/api/cldnn/runtime/device_query.hpp | 29 + .../clDNN/api/cldnn/runtime/engine.hpp | 150 ++ .../cldnn/runtime/engine_configuration.hpp | 110 + .../cldnn/runtime/error_handler.hpp} | 5 +- .../cldnn/runtime/event.hpp} | 20 +- .../clDNN/api/cldnn/runtime/half.hpp | 55 + .../clDNN/api/cldnn/runtime/kernel.hpp | 24 + .../clDNN/api/cldnn/runtime/kernel_args.hpp | 133 ++ .../clDNN/api/{ => cldnn/runtime}/layout.hpp | 4 +- .../clDNN/api/cldnn/runtime/memory.hpp | 150 ++ .../clDNN/api/cldnn/runtime/memory_caps.hpp | 84 + .../cldnn/runtime/memory_pool.hpp} | 81 +- .../api/{ => cldnn/runtime}/profiling.hpp | 1 + .../clDNN/api/cldnn/runtime/stream.hpp | 46 + .../clDNN/api/{ => cldnn/runtime}/tensor.hpp | 7 +- .../clDNN/api/cldnn/runtime/utils.hpp | 144 ++ .../thirdparty/clDNN/api/device.hpp | 161 -- .../thirdparty/clDNN/api/engine.hpp | 189 -- .../thirdparty/clDNN/api/event.hpp | 83 - .../thirdparty/clDNN/api/memory.hpp | 278 --- .../thirdparty/clDNN/api/meta_utils.hpp | 43 - .../clDNN/api_test_builds/CMakeLists.txt | 38 +- .../clDNN/kernel_selector/CMakeLists.txt | 1 + .../kernel_selector/common/tensor_type.h | 2 + .../activation/activation_kernel_base.cpp | 2 +- .../arg_max_min/arg_max_min_kernel_axis.cpp | 2 +- .../binary_convolution_kernel_base.cpp | 4 +- .../concatenation_kernel_base.cpp | 14 +- .../concatenation_kernel_fs_b_yx_fsv32.cpp | 14 +- .../concatenation_kernel_ref.cpp | 6 +- .../convolution/convolution_kernel_base.cpp | 12 +- .../ctc_greedy_decoder_kernel_base.cpp | 2 +- .../cum_sum/cum_sum_kernel_partial_sum.cpp | 12 +- .../deconvolution_kernel_base.cpp | 2 +- .../eltwise/eltwise_kernel_b_fs_yx_fsv16.cpp | 8 +- .../eltwise/eltwise_kernel_b_fs_yx_fsv4.cpp | 8 +- .../eltwise/eltwise_kernel_base.cpp | 8 +- .../eltwise/eltwise_kernel_fs_b_yx_fsv32.cpp | 9 +- ...se_kernel_mixed_byxf_and_fs_b_yx_fsv32.cpp | 8 +- .../eltwise/eltwise_kernel_vload8.cpp | 8 +- .../fused_conv_eltwise_kernel_base.cpp | 6 +- .../gather/gather_nd_kernel_ref.cpp | 16 +- .../gather/gather_nd_kernel_ref.h | 16 +- .../gather/gather_nd_kernel_selector.cpp | 16 +- .../gather/gather_nd_kernel_selector.h | 16 +- .../lstm/lstm_elt_kernel_base.cpp | 10 +- .../lstm/lstm_gemm_kernel_base.cpp | 16 +- ...m_gemv_gpu_subgroup1x64_bfyx_ff_simd16.cpp | 2 +- ...m_gemv_gpu_subgroup1x64_bfyx_hh_simd16.cpp | 2 +- .../lstm_dynamic_input_bfyx_opt.cpp | 6 +- .../lstm_dynamic_input_kernel_base.cpp | 14 +- .../lstm_dynamic_timeloop_kernel_base.cpp | 22 +- .../max_unpooling_kernel_base.cpp | 2 +- .../mvn/mvn_kernel_b_fs_yx_fsv16_imad.cpp | 30 +- .../normalize/normalize_kernel_base.cpp | 2 +- .../pooling/pooling_kernel_base.cpp | 2 +- .../quantize/quantize_kernel_base.cpp | 8 +- .../reorder/reorder_biplanar_nv12.cpp | 2 +- .../reorder/reorder_kernel_base.cpp | 6 +- .../reshape/reshape_kernel_ref.cpp | 8 +- .../roi_pooling/roi_pooling_kernel_base.cpp | 4 +- .../select/select_kernel_base.cpp | 8 +- .../clDNN/kernel_selector/core/auto_tuner.cpp | 4 +- .../clDNN/kernel_selector/core/auto_tuner.h | 2 +- .../core/cl_kernels/gather_nd_ref.cl | 14 +- .../core/cl_kernels/max_unpooling_gpu_ref.cl | 4 +- .../core/common/kernel_base_opencl.cpp | 8 +- .../core}/device_cache_reader.cpp | 27 +- .../core/device_cache_reader.h | 14 + .../kernel_selector/core/kernel_selector.cpp | 9 +- .../core/kernel_selector_common.h | 115 +- .../thirdparty/clDNN/runtime/CMakeLists.txt | 79 + .../cldnn_itt.h => runtime/cldnn_itt.hpp} | 2 +- .../thirdparty/clDNN/runtime/device_query.cpp | 30 + .../thirdparty/clDNN/runtime/engine.cpp | 160 ++ .../thirdparty/clDNN/runtime/event.cpp | 69 + .../{src/gpu => runtime}/kernels_cache.cpp | 109 +- .../kernels_cache.hpp} | 55 +- .../clDNN/runtime/kernels_factory.cpp | 22 + .../clDNN/runtime/kernels_factory.hpp | 22 + .../thirdparty/clDNN/runtime/memory.cpp | 36 + .../clDNN/{src => runtime}/memory_pool.cpp | 221 +- .../gpu => runtime/ocl}/ocl_base_event.cpp | 14 +- .../ocl/ocl_base_event.hpp} | 33 +- .../ocl/ocl_command_queues_builder.cpp} | 35 +- .../ocl/ocl_command_queues_builder.hpp} | 21 +- .../clDNN/runtime/ocl/ocl_common.hpp | 30 + .../ocl/ocl_device.cpp} | 144 +- .../clDNN/runtime/ocl/ocl_device.hpp | 42 + .../ocl/ocl_device_detector.cpp} | 106 +- .../clDNN/runtime/ocl/ocl_device_detector.hpp | 30 + .../clDNN/runtime/ocl/ocl_engine.cpp | 204 ++ .../clDNN/runtime/ocl/ocl_engine.hpp | 51 + .../clDNN/runtime/ocl/ocl_engine_factory.hpp | 19 + .../ocl/ocl_events_pool.hpp} | 39 +- .../cl2_ext.hpp => runtime/ocl/ocl_ext.hpp} | 41 +- .../clDNN/runtime/ocl/ocl_kernel.hpp | 33 + .../clDNN/runtime/ocl/ocl_kernels_factory.cpp | 21 + .../clDNN/runtime/ocl/ocl_memory.cpp | 373 +++ .../clDNN/runtime/ocl/ocl_memory.hpp | 128 ++ .../clDNN/runtime/ocl/ocl_stream.cpp | 428 ++++ .../clDNN/runtime/ocl/ocl_stream.hpp | 99 + .../gpu => runtime/ocl}/ocl_user_event.cpp | 4 +- .../ocl/ocl_user_event.hpp} | 14 +- .../ocl/ocl_wrapper.hpp} | 7 +- .../thirdparty/clDNN/src/CMakeLists.txt | 13 +- .../thirdparty/clDNN/src/activation.cpp | 2 +- .../thirdparty/clDNN/src/arg_max_min.cpp | 3 +- .../clDNN/src/average_unpooling.cpp | 2 +- .../thirdparty/clDNN/src/batch_to_space.cpp | 2 +- .../clDNN/src/binary_convolution.cpp | 2 +- .../thirdparty/clDNN/src/border.cpp | 2 +- .../thirdparty/clDNN/src/broadcast.cpp | 2 +- .../thirdparty/clDNN/src/concatenation.cpp | 2 +- .../thirdparty/clDNN/src/condition.cpp | 8 +- .../thirdparty/clDNN/src/convolution.cpp | 2 +- .../thirdparty/clDNN/src/crop.cpp | 4 +- .../thirdparty/clDNN/src/cum_sum.cpp | 2 +- .../thirdparty/clDNN/src/data.cpp | 22 +- .../thirdparty/clDNN/src/deconvolution.cpp | 2 +- .../clDNN/src/deformable_convolution.cpp | 2 +- .../thirdparty/clDNN/src/depth_to_space.cpp | 2 +- .../thirdparty/clDNN/src/detection_output.cpp | 2 +- .../thirdparty/clDNN/src/device.cpp | 58 - .../thirdparty/clDNN/src/eltwise.cpp | 2 +- .../thirdparty/clDNN/src/embedding_bag.cpp | 2 +- .../thirdparty/clDNN/src/engine.cpp | 298 --- .../thirdparty/clDNN/src/error_handler.cpp | 2 +- .../thirdparty/clDNN/src/event.cpp | 102 - .../clDNN/src/extract_image_patches.cpp | 2 +- .../thirdparty/clDNN/src/fully_connected.cpp | 2 +- .../clDNN/src/fused_conv_eltwise.cpp | 2 +- .../thirdparty/clDNN/src/gather.cpp | 2 +- .../thirdparty/clDNN/src/gather_nd.cpp | 18 +- .../thirdparty/clDNN/src/gather_tree.cpp | 2 +- .../thirdparty/clDNN/src/gemm.cpp | 2 +- .../clDNN/src/gpu/activation_gpu.cpp | 14 +- .../clDNN/src/gpu/arg_max_min_gpu.cpp | 11 +- .../clDNN/src/gpu/average_unpooling_gpu.cpp | 11 +- .../clDNN/src/gpu/batch_to_space_gpu.cpp | 6 +- .../clDNN/src/gpu/binary_convolution_gpu.cpp | 19 +- .../thirdparty/clDNN/src/gpu/border_gpu.cpp | 6 +- .../clDNN/src/gpu/broadcast_gpu.cpp | 6 +- .../clDNN/src/gpu/concatenation_gpu.cpp | 7 +- .../clDNN/src/gpu/condition_gpu.cpp | 32 +- .../clDNN/src/gpu/configuration.cpp | 29 - .../thirdparty/clDNN/src/gpu/configuration.h | 37 - .../clDNN/src/gpu/convolution_gpu.cpp | 30 +- .../thirdparty/clDNN/src/gpu/crop_gpu.cpp | 6 +- .../clDNN/src/gpu/ctc_greedy_decoder_gpu.cpp | 6 +- .../thirdparty/clDNN/src/gpu/cum_sum_gpu.cpp | 6 +- .../src/gpu/custom_gpu_primitive_gpu.cpp | 78 +- .../clDNN/src/gpu/deconvolution_gpu.cpp | 15 +- .../src/gpu/deformable_convolution_gpu.cpp | 19 +- .../clDNN/src/gpu/depth_to_space_gpu.cpp | 6 +- .../clDNN/src/gpu/detection_output_cpu.cpp | 92 +- .../clDNN/src/gpu/device_cache_reader.h | 27 - .../thirdparty/clDNN/src/gpu/device_info.h | 58 - .../thirdparty/clDNN/src/gpu/eltwise_gpu.cpp | 11 +- .../clDNN/src/gpu/embedding_bag_gpu.cpp | 6 +- .../thirdparty/clDNN/src/gpu/events_waiter.h | 26 - .../src/gpu/extract_image_patches_gpu.cpp | 6 +- .../clDNN/src/gpu/fully_connected_gpu.cpp | 19 +- .../clDNN/src/gpu/fused_conv_eltwise_gpu.cpp | 15 +- .../thirdparty/clDNN/src/gpu/gather_gpu.cpp | 6 +- .../clDNN/src/gpu/gather_nd_gpu.cpp | 22 +- .../clDNN/src/gpu/gather_tree_gpu.cpp | 7 +- .../thirdparty/clDNN/src/gpu/gemm_gpu.cpp | 6 +- .../clDNN/src/gpu/generic_layer_gpu.cpp | 88 +- .../thirdparty/clDNN/src/gpu/grn_gpu.cpp | 6 +- .../thirdparty/clDNN/src/gpu/kernel.cpp | 275 --- .../thirdparty/clDNN/src/gpu/kernel.h | 96 - .../clDNN/src/gpu/kernel_runner.cpp | 90 +- .../thirdparty/clDNN/src/gpu/kernel_runner.h | 26 +- .../thirdparty/clDNN/src/gpu/loop_gpu.cpp | 77 +- .../thirdparty/clDNN/src/gpu/lrn_gpu.cpp | 6 +- .../clDNN/src/gpu/lstm_dynamic_input_gpu.cpp | 19 +- .../src/gpu/lstm_dynamic_timeloop_gpu.cpp | 25 +- .../thirdparty/clDNN/src/gpu/lstm_elt_gpu.cpp | 15 +- .../clDNN/src/gpu/lstm_gemm_gpu.cpp | 23 +- .../clDNN/src/gpu/max_unpooling_gpu.cpp | 21 +- .../thirdparty/clDNN/src/gpu/memory_gpu.cpp | 310 --- .../thirdparty/clDNN/src/gpu/memory_gpu.h | 176 -- .../clDNN/src/gpu/mutable_data_gpu.cpp | 12 +- .../thirdparty/clDNN/src/gpu/mvn_gpu.cpp | 6 +- .../clDNN/src/gpu/non_max_suppression_cpu.cpp | 126 +- .../clDNN/src/gpu/normalize_gpu.cpp | 13 +- .../thirdparty/clDNN/src/gpu/ocl_builder.h | 38 - .../clDNN/src/gpu/ocl_queue_wrapper.cpp | 158 -- .../clDNN/src/gpu/ocl_queue_wrapper.h | 96 - .../thirdparty/clDNN/src/gpu/ocl_toolkit.cpp | 236 -- .../thirdparty/clDNN/src/gpu/ocl_toolkit.h | 147 -- .../thirdparty/clDNN/src/gpu/one_hot_gpu.cpp | 6 +- .../thirdparty/clDNN/src/gpu/permute_gpu.cpp | 6 +- .../thirdparty/clDNN/src/gpu/pooling_gpu.cpp | 13 +- .../clDNN/src/gpu/primitive_gpu_base.h | 133 +- .../thirdparty/clDNN/src/gpu/proposal_gpu.cpp | 59 +- .../thirdparty/clDNN/src/gpu/push_pop_map.h | 47 - .../clDNN/src/gpu/pyramid_roi_align_gpu.cpp | 6 +- .../thirdparty/clDNN/src/gpu/quantize_gpu.cpp | 23 +- .../thirdparty/clDNN/src/gpu/reduce_gpu.cpp | 6 +- .../clDNN/src/gpu/region_yolo_gpu.cpp | 6 +- .../thirdparty/clDNN/src/gpu/register_gpu.hpp | 124 +- .../thirdparty/clDNN/src/gpu/reorder_gpu.cpp | 14 +- .../clDNN/src/gpu/reorg_yolo_gpu.cpp | 6 +- .../thirdparty/clDNN/src/gpu/resample_gpu.cpp | 6 +- .../thirdparty/clDNN/src/gpu/reshape_gpu.cpp | 6 +- .../clDNN/src/gpu/reverse_sequence_gpu.cpp | 6 +- .../clDNN/src/gpu/roi_pooling_gpu.cpp | 21 +- .../thirdparty/clDNN/src/gpu/scale_gpu.cpp | 16 +- .../src/gpu/scatter_elements_update_gpu.cpp | 6 +- .../clDNN/src/gpu/scatter_nd_update_gpu.cpp | 6 +- .../clDNN/src/gpu/scatter_update_gpu.cpp | 6 +- .../thirdparty/clDNN/src/gpu/select_gpu.cpp | 6 +- .../clDNN/src/gpu/shuffle_channels_gpu.cpp | 6 +- .../thirdparty/clDNN/src/gpu/softmax_gpu.cpp | 6 +- .../clDNN/src/gpu/space_to_batch_gpu.cpp | 6 +- .../clDNN/src/gpu/space_to_depth_gpu.cpp | 6 +- .../clDNN/src/gpu/strided_slice_gpu.cpp | 15 +- .../thirdparty/clDNN/src/gpu/tile_gpu.cpp | 6 +- .../clDNN/src/gpu/wait_for_events_gpu.cpp | 14 +- .../graph_optimizer/add_required_reorders.cpp | 2 +- .../basic_memory_dependencies.cpp | 2 +- .../graph_optimizer/calculate_prior_boxes.cpp | 3 +- .../src/graph_optimizer/compile_graph.cpp | 7 +- .../graph_optimizer/concat_input_order.cpp | 35 +- .../graph_optimizer/eltwise_remove_stride.cpp | 2 +- .../graph_optimizer/handle_input_padding.cpp | 4 +- .../oooq_memory_dependencies.cpp | 2 +- .../graph_optimizer/post_input_reorder.cpp | 5 +- .../graph_optimizer/post_optimize_weights.cpp | 4 +- .../graph_optimizer/pre_replace_deconv.cpp | 22 +- .../graph_optimizer/prepare_buffer_fusing.cpp | 3 +- .../prepare_primitive_fusing.cpp | 23 +- .../graph_optimizer/prepare_quantization.cpp | 243 +- .../graph_optimizer/propagate_constants.cpp | 19 +- .../src/graph_optimizer/reorder_inputs.cpp | 3 +- .../skipped_branch_memory_dependencies.cpp | 2 +- .../strided_slice_optimize.cpp | 2 +- .../clDNN/src/include/activation_inst.h | 5 +- .../clDNN/src/include/arg_max_min_inst.h | 2 +- .../src/include/average_unpooling_inst.h | 3 +- .../clDNN/src/include/batch_to_space_inst.h | 3 +- .../src/include/binary_convolution_inst.h | 6 +- .../clDNN/src/include/border_inst.h | 5 +- .../clDNN/src/include/broadcast_inst.h | 2 +- .../clDNN/src/include/concatenation_inst.h | 3 +- .../clDNN/src/include/condition_inst.h | 17 +- .../clDNN/src/include/convolution_inst.h | 30 +- .../thirdparty/clDNN/src/include/crop_inst.h | 3 +- .../src/include/ctc_greedy_decoder_inst.h | 3 +- .../clDNN/src/include/cum_sum_inst.h | 3 +- .../src/include/custom_gpu_primitive_inst.h | 3 +- .../thirdparty/clDNN/src/include/data_inst.h | 10 +- .../clDNN/src/include/deconvolution_inst.h | 16 +- .../src/include/deformable_convolution_inst.h | 16 +- .../clDNN/src/include/depth_to_space_inst.h | 3 +- .../clDNN/src/include/detection_output_inst.h | 9 +- .../clDNN/src/include/device_impl.h | 105 - .../clDNN/src/include/eltwise_inst.h | 5 +- .../clDNN/src/include/embedding_bag_inst.h | 4 +- .../clDNN/src/include/engine_impl.h | 131 -- .../src/include/extract_image_patches_inst.h | 3 +- .../clDNN/src/include/fully_connected_inst.h | 7 +- .../src/include/fused_conv_eltwise_inst.h | 10 +- .../clDNN/src/include/gather_inst.h | 3 +- .../clDNN/src/include/gather_nd_inst.h | 21 +- .../clDNN/src/include/gather_tree_inst.h | 5 +- .../thirdparty/clDNN/src/include/gemm_inst.h | 3 +- .../clDNN/src/include/generic_layer.hpp | 5 +- .../clDNN/src/include/generic_layer_inst.h | 1 + .../thirdparty/clDNN/src/include/grn_inst.h | 3 +- .../clDNN/src/include/implementation_map.h | 2 + .../clDNN/src/include/input_layout_inst.h | 7 +- .../clDNN/src/include/internal_primitive.h | 36 - .../include/internal_primitive_type_base.h | 69 - .../src/include/kernel_selector_helper.h | 14 +- .../clDNN/src/include/layout_optimizer.h | 6 +- .../thirdparty/clDNN/src/include/loop_inst.h | 89 +- .../thirdparty/clDNN/src/include/lrn_inst.h | 3 +- .../src/include/lstm_dynamic_input_inst.h | 12 +- .../clDNN/src/include/lstm_dynamic_inst.h | 4 +- .../src/include/lstm_dynamic_timeloop_inst.h | 18 +- .../clDNN/src/include/lstm_elt_inst.h | 5 +- .../clDNN/src/include/lstm_gemm_inst.h | 11 +- .../thirdparty/clDNN/src/include/lstm_inst.h | 15 +- .../clDNN/src/include/max_unpooling_inst.h | 3 +- .../clDNN/src/include/memory_impl.h | 115 - .../thirdparty/clDNN/src/include/meta_utils.h | 32 +- .../clDNN/src/include/mutable_data_inst.h | 16 +- .../thirdparty/clDNN/src/include/mvn_inst.h | 3 +- .../clDNN/src/include/network_impl.h | 68 +- .../src/include/non_max_suppression_inst.h | 34 +- .../clDNN/src/include/normalize_inst.h | 5 +- .../clDNN/src/include/one_hot_inst.h | 5 +- .../clDNN/src/include/pass_manager.h | 2 +- .../clDNN/src/include/permute_inst.h | 3 +- .../clDNN/src/include/pooling_inst.h | 3 +- .../clDNN/src/include/primitive_inst.h | 140 +- .../clDNN/src/include/primitive_type.h | 17 +- .../clDNN/src/include/primitive_type_base.h | 24 +- .../clDNN/src/include/prior_box_inst.h | 9 +- .../clDNN/src/include/program_dump_graph.h | 3 +- .../clDNN/src/include/program_helpers.h | 6 +- .../clDNN/src/include/program_impl.h | 55 +- .../clDNN/src/include/program_node.h | 88 +- .../clDNN/src/include/proposal_inst.h | 3 +- .../src/include/pyramid_roi_align_inst.h | 12 +- .../clDNN/src/include/quantize_inst.h | 2 +- .../clDNN/src/include/reduce_inst.h | 3 +- .../clDNN/src/include/refcounted_obj.h | 135 -- .../clDNN/src/include/region_yolo_inst.h | 3 +- .../clDNN/src/include/reorder_inst.h | 8 +- .../clDNN/src/include/reorg_yolo_inst.h | 3 +- .../clDNN/src/include/resample_inst.h | 5 +- .../clDNN/src/include/reshape_inst.h | 5 +- .../clDNN/src/include/reverse_sequence_inst.h | 3 +- .../clDNN/src/include/roi_pooling_inst.h | 7 +- .../thirdparty/clDNN/src/include/scale_inst.h | 9 +- .../include/scatter_elements_update_inst.h | 2 +- .../src/include/scatter_nd_update_inst.h | 2 +- .../clDNN/src/include/scatter_update_inst.h | 3 +- .../clDNN/src/include/select_inst.h | 4 +- .../clDNN/src/include/shuffle_channels_inst.h | 3 +- .../clDNN/src/include/sliding_window_utils.h | 8 +- .../clDNN/src/include/softmax_inst.h | 3 +- .../clDNN/src/include/space_to_batch_inst.h | 4 +- .../clDNN/src/include/space_to_depth_inst.h | 4 +- .../thirdparty/clDNN/src/include/split_inst.h | 4 +- .../clDNN/src/include/strided_slice_inst.h | 6 +- .../thirdparty/clDNN/src/include/tile_inst.h | 4 +- .../clDNN/src/include/to_string_utils.h | 11 +- .../clDNN/src/include/topology_impl.h | 9 +- .../thirdparty/clDNN/src/input_layout.cpp | 16 +- .../clDNN/src/kernel_selector_helper.cpp | 26 +- .../thirdparty/clDNN/src/layout_optimizer.cpp | 2 +- .../thirdparty/clDNN/src/loop.cpp | 57 +- inference-engine/thirdparty/clDNN/src/lrn.cpp | 2 +- .../thirdparty/clDNN/src/lstm.cpp | 2 +- .../thirdparty/clDNN/src/lstm_dynamic.cpp | 2 +- .../clDNN/src/lstm_dynamic_input.cpp | 2 +- .../clDNN/src/lstm_dynamic_timeloop.cpp | 2 +- .../thirdparty/clDNN/src/lstm_elt.cpp | 2 +- .../thirdparty/clDNN/src/lstm_gemm.cpp | 2 +- .../thirdparty/clDNN/src/max_unpooling.cpp | 2 +- .../thirdparty/clDNN/src/memory.cpp | 149 -- .../thirdparty/clDNN/src/mutable_data.cpp | 77 +- .../thirdparty/clDNN/src/network.cpp | 298 +-- .../thirdparty/clDNN/src/nodes_ordering.cpp | 2 +- .../thirdparty/clDNN/src/normalize.cpp | 2 +- .../thirdparty/clDNN/src/one_hot.cpp | 2 +- .../thirdparty/clDNN/src/permute.cpp | 2 +- .../thirdparty/clDNN/src/pooling.cpp | 2 +- .../thirdparty/clDNN/src/primitive_inst.cpp | 64 +- .../thirdparty/clDNN/src/prior_box.cpp | 20 +- .../thirdparty/clDNN/src/program.cpp | 171 +- .../clDNN/src/program_dump_graph.cpp | 7 +- .../thirdparty/clDNN/src/program_helpers.cpp | 11 +- .../thirdparty/clDNN/src/program_node.cpp | 18 +- .../clDNN/src/pyramid_roi_align.cpp | 2 +- .../thirdparty/clDNN/src/quantize.cpp | 4 +- .../thirdparty/clDNN/src/reduce.cpp | 2 +- .../thirdparty/clDNN/src/reorder.cpp | 4 +- .../thirdparty/clDNN/src/resample.cpp | 2 +- .../thirdparty/clDNN/src/reshape.cpp | 4 +- .../thirdparty/clDNN/src/reverse_sequence.cpp | 2 +- .../thirdparty/clDNN/src/roi_pooling.cpp | 2 +- .../thirdparty/clDNN/src/scale.cpp | 2 +- .../clDNN/src/scatter_elements_update.cpp | 2 +- .../clDNN/src/scatter_nd_update.cpp | 2 +- .../thirdparty/clDNN/src/scatter_update.cpp | 2 +- .../thirdparty/clDNN/src/select.cpp | 2 +- .../thirdparty/clDNN/src/shuffle_channels.cpp | 2 +- .../thirdparty/clDNN/src/space_to_batch.cpp | 2 +- .../thirdparty/clDNN/src/space_to_depth.cpp | 2 +- .../thirdparty/clDNN/src/split.cpp | 4 +- .../thirdparty/clDNN/src/strided_slice.cpp | 2 +- .../thirdparty/clDNN/src/tile.cpp | 4 +- .../thirdparty/clDNN/src/topology.cpp | 11 +- .../thirdparty/clDNN/tests/CMakeLists.txt | 21 +- .../tests/module_tests/events_pool_test.cpp | 17 +- .../tests/module_tests/gpu_toolkit_test.cpp | 225 -- .../graph_manipulation_gpu_test.cpp | 77 +- .../prepare_conv_eltw_fusing.cpp | 33 +- .../module_tests}/program_impl_wrapper.h | 16 + .../module_tests}/reorder_inputs_test.cpp | 56 +- .../module_tests/test_uqr_distribution.cpp | 8 +- .../module_tests}/usm_memory_test.cpp | 104 +- .../test_cases/activation_simple_gpu_test.cpp | 304 ++- .../test_cases/add_reorders_gpu_test.cpp | 85 +- .../tests/test_cases/arg_max_gpu_test.cpp | 282 +-- .../test_cases/average_unpooling_gpu_test.cpp | 68 +- .../clDNN/tests/test_cases/barriers_test.cpp | 51 +- .../test_cases/batch_to_space_gpu_test.cpp | 125 +- .../binary_convolution_gpu_test.cpp | 128 +- .../tests/test_cases/border_gpu_test.cpp | 150 +- .../tests/test_cases/broadcast_gpu_test.cpp | 75 +- .../clDNN/tests/test_cases/cache_test.cpp | 33 +- .../tests/test_cases/cl_mem_input_test.cpp | 92 +- .../tests/test_cases/command_queue_test.cpp | 62 +- .../test_cases/concatenation_gpu_test.cpp | 180 +- .../tests/test_cases/condition_gpu_test.cpp | 195 +- .../tests/test_cases/convolution_gpu_test.cpp | 1458 ++++++------ .../clDNN/tests/test_cases/crop_gpu_test.cpp | 204 +- .../tests/test_cases/cum_sum_gpu_test.cpp | 91 +- .../test_cases/custom_gpu_primitive_test.cpp | 197 +- .../test_cases/deconvolution_gpu_test.cpp | 478 ++-- .../test_cases/depth_concatenate_gpu_test.cpp | 300 ++- .../test_cases/depth_to_space_gpu_test.cpp | 87 +- .../test_cases/detection_output_test.cpp | 311 ++- .../tests/test_cases/eltwise_gpu_test.cpp | 765 +++---- .../test_cases/embedding_bag_gpu_test.cpp | 287 ++- .../extract_image_patches_gpu_test.cpp | 71 +- .../test_cases/fully_connected_gpu_test.cpp | 246 +- .../fused_conv_eltwise_gpu_test.cpp | 91 +- .../tests/test_cases/fusings_gpu_test.cpp | 109 +- .../tests/test_cases/gather_gpu_test.cpp | 367 ++- .../tests/test_cases/gather_nd_gpu_test.cpp | 141 +- .../clDNN/tests/test_cases/gemm_gpu_test.cpp | 216 +- .../clDNN/tests/test_cases/loop_gpu_test.cpp | 117 +- .../clDNN/tests/test_cases/lrn_gpu_test.cpp | 44 +- .../test_cases/lstm_dynamic_gpu_test.cpp | 181 +- .../clDNN/tests/test_cases/lstm_gpu_test.cpp | 301 ++- .../test_cases/max_unpooling_gpu_test.cpp | 88 +- .../clDNN/tests/test_cases/memory_test.cpp | 213 +- .../clDNN/tests/test_cases/mvn_gpu_test.cpp | 176 +- .../test_cases/non_max_suppression_test.cpp | 59 +- .../tests/test_cases/normalizel2_gpu_test.cpp | 53 +- .../tests/test_cases/one_hot_gpu_test.cpp | 154 +- .../tests/test_cases/permute_gpu_test.cpp | 303 ++- .../tests/test_cases/pooling_gpu_test.cpp | 587 +++-- .../propagate_constants_gpu_test.cpp | 39 +- .../tests/test_cases/proposal_cpu_test.cpp | 72 +- .../test_cases/pyramid_roi_align_gpu_test.cpp | 30 +- .../tests/test_cases/quantize_gpu_test.cpp | 164 +- .../tests/test_cases/reduce_gpu_test.cpp | 278 ++- .../tests/test_cases/region_yolo_gpu_test.cpp | 26 +- .../test_cases/removing_output_node_test.cpp | 52 +- .../tests/test_cases/reorder_gpu_test.cpp | 434 ++-- .../tests/test_cases/resample_gpu_test.cpp | 311 ++- .../tests/test_cases/reshape_gpu_test.cpp | 106 +- .../test_cases/reverse_sequence_gpu_test.cpp | 189 +- .../clDNN/tests/test_cases/scale_gpu_test.cpp | 1994 ----------------- .../scatter_elements_update_gpu_test.cpp | 30 +- .../test_cases/scatter_nd_update_gpu_test.cpp | 544 +++-- .../test_cases/scatter_update_gpu_test.cpp | 507 +++-- .../tests/test_cases/select_gpu_test.cpp | 641 +++--- .../test_cases/shuffle_channels_test.cpp | 83 +- .../tests/test_cases/softmax_gpu_test.cpp | 187 +- .../test_cases/space_to_batch_gpu_test.cpp | 125 +- .../test_cases/space_to_depth_gpu_test.cpp | 155 +- .../spatial_concatenate_gpu_test.cpp | 322 ++- .../clDNN/tests/test_cases/split_gpu_test.cpp | 125 +- .../clDNN/tests/test_cases/streams_test.cpp | 145 +- .../test_cases/strided_slice_gpu_test.cpp | 352 ++- .../clDNN/tests/test_cases/tensor_test.cpp | 3 +- .../clDNN/tests/test_cases/tile_gpu_test.cpp | 107 +- .../clDNN/tests/test_cases/topology_test.cpp | 43 +- .../test_cases/trim_to_outputs_gpu_test.cpp | 61 +- .../tests/test_utils/instrumentation.cpp | 386 ---- .../clDNN/tests/test_utils/instrumentation.h | 39 - .../clDNN/tests/test_utils/network_test.h | 67 +- .../clDNN/tests/test_utils/test_utils.cpp | 611 +++-- .../clDNN/tests/test_utils/test_utils.h | 439 ++-- .../uniform_quantized_real_distribution.hpp | 7 +- .../clDNN/tests_core_internal/CMakeLists.txt | 137 -- .../clDNN/tests_core_internal/main.cpp | 11 - 613 files changed, 13711 insertions(+), 18482 deletions(-) delete mode 100644 inference-engine/thirdparty/clDNN/api/cldnn.hpp rename inference-engine/thirdparty/clDNN/api/{ => cldnn/graph}/network.hpp (79%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/graph}/program.hpp (97%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/graph}/topology.hpp (84%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/activation.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/arg_max_min.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/average_unpooling.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/batch_to_space.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/binary_convolution.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/border.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/broadcast.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/concatenation.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/condition.hpp (98%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/convolution.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/crop.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/ctc_greedy_decoder.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/cum_sum.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/custom_gpu_primitive.hpp (98%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/data.hpp (92%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/deconvolution.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/depth_to_space.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/detection_output.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/eltwise.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/embedding_bag.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/extract_image_patches.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/fully_connected.hpp (100%) rename inference-engine/thirdparty/clDNN/{api_extension => api/cldnn/primitives}/fused_conv_eltwise.hpp (98%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/gather.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/gather_nd.hpp (63%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/gather_tree.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/gemm.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/grn.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/input_layout.hpp (97%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/loop.hpp (99%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/lrn.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/lstm.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/lstm_dynamic.hpp (100%) rename inference-engine/thirdparty/clDNN/{api_extension => api/cldnn/primitives}/lstm_dynamic_input.hpp (98%) rename inference-engine/thirdparty/clDNN/{api_extension => api/cldnn/primitives}/lstm_dynamic_timeloop.hpp (99%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/max_unpooling.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/mutable_data.hpp (92%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/mvn.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/non_max_suppression.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/normalize.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/one_hot.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/permute.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/pooling.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/primitive.hpp (98%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/prior_box.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/proposal.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/pyramid_roi_align.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/quantize.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/reduce.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/region_yolo.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/reorder.hpp (99%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/reorg_yolo.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/resample.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/reshape.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/reverse_sequence.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/roi_pooling.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/scale.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/scatter_elements_update.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/scatter_nd_update.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/scatter_update.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/select.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/shuffle_channels.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/softmax.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/space_to_batch.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/space_to_depth.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/split.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/strided_slice.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/primitives}/tile.hpp (100%) rename inference-engine/thirdparty/clDNN/api/{compounds.h => cldnn/runtime/compounds.hpp} (98%) create mode 100644 inference-engine/thirdparty/clDNN/api/cldnn/runtime/device.hpp create mode 100644 inference-engine/thirdparty/clDNN/api/cldnn/runtime/device_info.hpp create mode 100644 inference-engine/thirdparty/clDNN/api/cldnn/runtime/device_query.hpp create mode 100644 inference-engine/thirdparty/clDNN/api/cldnn/runtime/engine.hpp create mode 100644 inference-engine/thirdparty/clDNN/api/cldnn/runtime/engine_configuration.hpp rename inference-engine/thirdparty/clDNN/{src/include/error_handler.h => api/cldnn/runtime/error_handler.hpp} (99%) rename inference-engine/thirdparty/clDNN/{src/include/event_impl.h => api/cldnn/runtime/event.hpp} (82%) create mode 100644 inference-engine/thirdparty/clDNN/api/cldnn/runtime/half.hpp create mode 100644 inference-engine/thirdparty/clDNN/api/cldnn/runtime/kernel.hpp create mode 100644 inference-engine/thirdparty/clDNN/api/cldnn/runtime/kernel_args.hpp rename inference-engine/thirdparty/clDNN/api/{ => cldnn/runtime}/layout.hpp (99%) create mode 100644 inference-engine/thirdparty/clDNN/api/cldnn/runtime/memory.hpp create mode 100644 inference-engine/thirdparty/clDNN/api/cldnn/runtime/memory_caps.hpp rename inference-engine/thirdparty/clDNN/{src/include/memory_pool.h => api/cldnn/runtime/memory_pool.hpp} (52%) rename inference-engine/thirdparty/clDNN/api/{ => cldnn/runtime}/profiling.hpp (99%) create mode 100644 inference-engine/thirdparty/clDNN/api/cldnn/runtime/stream.hpp rename inference-engine/thirdparty/clDNN/api/{ => cldnn/runtime}/tensor.hpp (99%) create mode 100644 inference-engine/thirdparty/clDNN/api/cldnn/runtime/utils.hpp delete mode 100644 inference-engine/thirdparty/clDNN/api/device.hpp delete mode 100644 inference-engine/thirdparty/clDNN/api/engine.hpp delete mode 100644 inference-engine/thirdparty/clDNN/api/event.hpp delete mode 100644 inference-engine/thirdparty/clDNN/api/memory.hpp delete mode 100644 inference-engine/thirdparty/clDNN/api/meta_utils.hpp rename inference-engine/thirdparty/clDNN/{src/gpu => kernel_selector/core}/device_cache_reader.cpp (65%) create mode 100644 inference-engine/thirdparty/clDNN/kernel_selector/core/device_cache_reader.h create mode 100644 inference-engine/thirdparty/clDNN/runtime/CMakeLists.txt rename inference-engine/thirdparty/clDNN/{src/include/cldnn_itt.h => runtime/cldnn_itt.hpp} (92%) create mode 100644 inference-engine/thirdparty/clDNN/runtime/device_query.cpp create mode 100644 inference-engine/thirdparty/clDNN/runtime/engine.cpp create mode 100644 inference-engine/thirdparty/clDNN/runtime/event.cpp rename inference-engine/thirdparty/clDNN/{src/gpu => runtime}/kernels_cache.cpp (82%) rename inference-engine/thirdparty/clDNN/{src/gpu/kernels_cache.h => runtime/kernels_cache.hpp} (70%) create mode 100644 inference-engine/thirdparty/clDNN/runtime/kernels_factory.cpp create mode 100644 inference-engine/thirdparty/clDNN/runtime/kernels_factory.hpp create mode 100644 inference-engine/thirdparty/clDNN/runtime/memory.cpp rename inference-engine/thirdparty/clDNN/{src => runtime}/memory_pool.cpp (55%) rename inference-engine/thirdparty/clDNN/{src/gpu => runtime/ocl}/ocl_base_event.cpp (93%) rename inference-engine/thirdparty/clDNN/{src/gpu/ocl_base_event.h => runtime/ocl/ocl_base_event.hpp} (76%) rename inference-engine/thirdparty/clDNN/{src/gpu/command_queues_builder.cpp => runtime/ocl/ocl_command_queues_builder.cpp} (80%) rename inference-engine/thirdparty/clDNN/{src/gpu/command_queues_builder.h => runtime/ocl/ocl_command_queues_builder.hpp} (57%) create mode 100644 inference-engine/thirdparty/clDNN/runtime/ocl/ocl_common.hpp rename inference-engine/thirdparty/clDNN/{src/gpu/device_info.cpp => runtime/ocl/ocl_device.cpp} (54%) create mode 100644 inference-engine/thirdparty/clDNN/runtime/ocl/ocl_device.hpp rename inference-engine/thirdparty/clDNN/{src/gpu/ocl_builder.cpp => runtime/ocl/ocl_device_detector.cpp} (68%) create mode 100644 inference-engine/thirdparty/clDNN/runtime/ocl/ocl_device_detector.hpp create mode 100644 inference-engine/thirdparty/clDNN/runtime/ocl/ocl_engine.cpp create mode 100644 inference-engine/thirdparty/clDNN/runtime/ocl/ocl_engine.hpp create mode 100644 inference-engine/thirdparty/clDNN/runtime/ocl/ocl_engine_factory.hpp rename inference-engine/thirdparty/clDNN/{src/gpu/events_pool.h => runtime/ocl/ocl_events_pool.hpp} (57%) rename inference-engine/thirdparty/clDNN/{common/include/cl2_ext.hpp => runtime/ocl/ocl_ext.hpp} (97%) create mode 100644 inference-engine/thirdparty/clDNN/runtime/ocl/ocl_kernel.hpp create mode 100644 inference-engine/thirdparty/clDNN/runtime/ocl/ocl_kernels_factory.cpp create mode 100644 inference-engine/thirdparty/clDNN/runtime/ocl/ocl_memory.cpp create mode 100644 inference-engine/thirdparty/clDNN/runtime/ocl/ocl_memory.hpp create mode 100644 inference-engine/thirdparty/clDNN/runtime/ocl/ocl_stream.cpp create mode 100644 inference-engine/thirdparty/clDNN/runtime/ocl/ocl_stream.hpp rename inference-engine/thirdparty/clDNN/{src/gpu => runtime/ocl}/ocl_user_event.cpp (94%) rename inference-engine/thirdparty/clDNN/{src/gpu/ocl_user_event.h => runtime/ocl/ocl_user_event.hpp} (71%) rename inference-engine/thirdparty/clDNN/{common/include/cl2_wrapper.h => runtime/ocl/ocl_wrapper.hpp} (95%) delete mode 100644 inference-engine/thirdparty/clDNN/src/device.cpp delete mode 100644 inference-engine/thirdparty/clDNN/src/engine.cpp delete mode 100644 inference-engine/thirdparty/clDNN/src/event.cpp delete mode 100644 inference-engine/thirdparty/clDNN/src/gpu/configuration.cpp delete mode 100644 inference-engine/thirdparty/clDNN/src/gpu/configuration.h delete mode 100644 inference-engine/thirdparty/clDNN/src/gpu/device_cache_reader.h delete mode 100644 inference-engine/thirdparty/clDNN/src/gpu/device_info.h delete mode 100644 inference-engine/thirdparty/clDNN/src/gpu/events_waiter.h delete mode 100644 inference-engine/thirdparty/clDNN/src/gpu/kernel.cpp delete mode 100644 inference-engine/thirdparty/clDNN/src/gpu/kernel.h delete mode 100644 inference-engine/thirdparty/clDNN/src/gpu/memory_gpu.cpp delete mode 100644 inference-engine/thirdparty/clDNN/src/gpu/memory_gpu.h delete mode 100644 inference-engine/thirdparty/clDNN/src/gpu/ocl_builder.h delete mode 100644 inference-engine/thirdparty/clDNN/src/gpu/ocl_queue_wrapper.cpp delete mode 100644 inference-engine/thirdparty/clDNN/src/gpu/ocl_queue_wrapper.h delete mode 100644 inference-engine/thirdparty/clDNN/src/gpu/ocl_toolkit.cpp delete mode 100644 inference-engine/thirdparty/clDNN/src/gpu/ocl_toolkit.h delete mode 100644 inference-engine/thirdparty/clDNN/src/gpu/push_pop_map.h delete mode 100644 inference-engine/thirdparty/clDNN/src/include/device_impl.h delete mode 100644 inference-engine/thirdparty/clDNN/src/include/engine_impl.h delete mode 100644 inference-engine/thirdparty/clDNN/src/include/internal_primitive.h delete mode 100644 inference-engine/thirdparty/clDNN/src/include/internal_primitive_type_base.h delete mode 100644 inference-engine/thirdparty/clDNN/src/include/memory_impl.h delete mode 100644 inference-engine/thirdparty/clDNN/src/include/refcounted_obj.h delete mode 100644 inference-engine/thirdparty/clDNN/src/memory.cpp delete mode 100644 inference-engine/thirdparty/clDNN/tests/module_tests/gpu_toolkit_test.cpp rename inference-engine/thirdparty/clDNN/{tests_core_internal/test_cases => tests/module_tests}/graph_manipulation_gpu_test.cpp (67%) rename inference-engine/thirdparty/clDNN/{tests_core_internal/test_cases => tests/module_tests}/prepare_conv_eltw_fusing.cpp (78%) rename inference-engine/thirdparty/clDNN/{tests_core_internal => tests/module_tests}/program_impl_wrapper.h (70%) rename inference-engine/thirdparty/clDNN/{tests_core_internal/test_cases => tests/module_tests}/reorder_inputs_test.cpp (79%) rename inference-engine/thirdparty/clDNN/{tests_core_internal/test_cases => tests/module_tests}/usm_memory_test.cpp (68%) delete mode 100644 inference-engine/thirdparty/clDNN/tests/test_cases/scale_gpu_test.cpp delete mode 100644 inference-engine/thirdparty/clDNN/tests/test_utils/instrumentation.cpp delete mode 100644 inference-engine/thirdparty/clDNN/tests/test_utils/instrumentation.h delete mode 100644 inference-engine/thirdparty/clDNN/tests_core_internal/CMakeLists.txt delete mode 100644 inference-engine/thirdparty/clDNN/tests_core_internal/main.cpp diff --git a/inference-engine/src/cldnn_engine/CMakeLists.txt b/inference-engine/src/cldnn_engine/CMakeLists.txt index ff138843dc45a6..161d6f16a8d2c8 100644 --- a/inference-engine/src/cldnn_engine/CMakeLists.txt +++ b/inference-engine/src/cldnn_engine/CMakeLists.txt @@ -33,7 +33,7 @@ target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} $ ${CLDNN__OCL_ICD_INCDIRS} - ${CLDNN_TOP_FOLDER}) + ${CLDNN_TOP_FOLDER}/api) set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO}) diff --git a/inference-engine/src/cldnn_engine/cldnn_common_utils.h b/inference-engine/src/cldnn_engine/cldnn_common_utils.h index c374a71a4653f3..f41f2d8e134b1c 100644 --- a/inference-engine/src/cldnn_engine/cldnn_common_utils.h +++ b/inference-engine/src/cldnn_engine/cldnn_common_utils.h @@ -5,7 +5,7 @@ #pragma once #include -#include +#include #include "ngraph/type/element_type.hpp" diff --git a/inference-engine/src/cldnn_engine/cldnn_config.h b/inference-engine/src/cldnn_engine/cldnn_config.h index 8c6d5d6c921da8..873c01e2188445 100644 --- a/inference-engine/src/cldnn_engine/cldnn_config.h +++ b/inference-engine/src/cldnn_engine/cldnn_config.h @@ -9,7 +9,7 @@ #include "cldnn_custom_layer.h" -#include +#include namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/cldnn_custom_layer.h b/inference-engine/src/cldnn_engine/cldnn_custom_layer.h index 95a6ff4c5c9f82..cbe41f8831b3f8 100644 --- a/inference-engine/src/cldnn_engine/cldnn_custom_layer.h +++ b/inference-engine/src/cldnn_engine/cldnn_custom_layer.h @@ -10,7 +10,7 @@ #include #include #include "pugixml.hpp" -#include "api/tensor.hpp" +#include "cldnn/runtime/tensor.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/cldnn_engine.cpp b/inference-engine/src/cldnn_engine/cldnn_engine.cpp index 171919a80775d6..e3e67d95f152f1 100644 --- a/inference-engine/src/cldnn_engine/cldnn_engine.cpp +++ b/inference-engine/src/cldnn_engine/cldnn_engine.cpp @@ -81,6 +81,8 @@ #include "cldnn_itt.h" #include "gpu/gpu_config.hpp" +#include "cldnn/runtime/device_query.hpp" + #ifdef __linux__ # include #endif @@ -117,13 +119,13 @@ struct clDNNEngine::impl { }; cldnn::device_info clDNNEngine::GetDeviceInfo(const std::map &config) const { - auto device_info = device_map.begin()->second.get_info(); + auto device_info = device_map.begin()->second->get_info(); if (config.find(PluginConfigParams::KEY_DEVICE_ID) != config.end()) { auto val = config.at(PluginConfigParams::KEY_DEVICE_ID); if (device_map.find(val) == device_map.end()) { IE_THROW() << "Invalid device ID: " << val; } - device_info = device_map.at(val).get_info(); + device_info = device_map.at(val)->get_info(); } return device_info; @@ -445,7 +447,8 @@ clDNNEngine::clDNNEngine() : m_defaultContext(nullptr) { RegisterPrimitives(); // try loading clDNN engine and get info from it { - cldnn::device_query device_query; + // Set OCL runtime which should be always available + cldnn::device_query device_query(cldnn::engine_types::ocl, cldnn::runtime_types::ocl); device_map = device_query.get_available_devices(); } // locate global custom kernel config @@ -851,8 +854,8 @@ auto StringRightTrim = [](std::string string, std::string substring, bool case_s }; static float GetGOPS(cldnn::device_info info, cldnn::data_types dt) { - auto freqGHz = info.core_frequency / 1000.f; - auto numEUs = info.cores_count; + auto freqGHz = info.gpu_frequency / 1000.f; + auto numEUs = info.execution_units_count; auto opsPerComputeBlock = 0; auto computeBlockIPC = 1.0f; switch (dt) { @@ -894,8 +897,8 @@ Parameter clDNNEngine::GetMetric(const std::string& name, const std::mapsecond.get_info() : - device_map.begin()->second.get_info(); + iter->second->get_info() : + device_map.begin()->second->get_info(); if (name == METRIC_KEY(SUPPORTED_METRICS)) { std::vector metrics; @@ -931,7 +934,7 @@ Parameter clDNNEngine::GetMetric(const std::string& name, const std::map #include #include -#include +#include #include #include #include "cldnn_remote_context.h" @@ -22,7 +22,7 @@ class clDNNEngine : public InferenceEngine::IInferencePlugin, std::shared_ptr _impl; // key: device_id, value: cldnn device - std::map device_map; + std::map device_map; std::mutex engine_mutex; mutable CLDNNRemoteCLContext::Ptr m_defaultContext; diff --git a/inference-engine/src/cldnn_engine/cldnn_executable_network.cpp b/inference-engine/src/cldnn_engine/cldnn_executable_network.cpp index 5191da35c2e369..94245c1d3b6bee 100644 --- a/inference-engine/src/cldnn_engine/cldnn_executable_network.cpp +++ b/inference-engine/src/cldnn_engine/cldnn_executable_network.cpp @@ -2,13 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include #include "ie_metric_helpers.hpp" -#include -#include +#include +#include +#include + +#include "ie_metric_helpers.hpp" #include #include #include @@ -27,7 +27,6 @@ #include "threading/ie_cpu_streams_executor.hpp" #include "cpp_interfaces/interface/ie_iinfer_request_internal.hpp" - using namespace InferenceEngine; using namespace InferenceEngine::details; diff --git a/inference-engine/src/cldnn_engine/cldnn_graph.cpp b/inference-engine/src/cldnn_engine/cldnn_graph.cpp index 1f835d8ac2c991..2b333a38ee9d20 100644 --- a/inference-engine/src/cldnn_engine/cldnn_graph.cpp +++ b/inference-engine/src/cldnn_engine/cldnn_graph.cpp @@ -2,22 +2,28 @@ // SPDX-License-Identifier: Apache-2.0 // +#include +#include + +#include "cldnn_graph.h" +#include "simple_math.h" +#include +#include "cldnn_infer_request.h" + +#include +#include +#include + +#include +#include + #include #include #include #include -#include -#include -#include -#include #include #include #include -#include "cldnn_graph.h" -#include "simple_math.h" -#include -#include "cldnn_infer_request.h" -#include #include #include #include @@ -71,12 +77,10 @@ void CLDNNGraph::Build() { for (int b = m_bv_sz - 1; b >= 0; b--) { auto network = BuildNetwork(m_program->GetCompiledProgram(b)); m_networks.insert(m_networks.begin(), network); - GetEngine()->release_pending_memory(network->get_id()); } } else { auto network = BuildNetwork(m_program->GetCompiledProgram()); m_networks.emplace_back(network); - GetEngine()->release_pending_memory(network->get_id()); } UpdateImplementationsMap(); @@ -499,7 +503,7 @@ void CLDNNGraph::UpdatePerfStatistics() { } }; - std::map executedPrimitives = GetNetwork()->get_executed_primitives(); + std::map executedPrimitives = GetNetwork()->get_executed_primitives(); auto allPrimitives = GetNetwork()->get_all_primitives(); // Get profiling info for all layers @@ -521,7 +525,7 @@ void CLDNNGraph::UpdatePerfStatistics() { auto event = execIter->second; executedPrimitives.erase(execIter); - cldnn::instrumentation::profiling_info cldnnInfo{profiledID, event.get_profiling_info()}; + cldnn::instrumentation::profiling_info cldnnInfo{profiledID, event->get_profiling_info()}; collectTimings(cldnnInfo, perfCount); perfCount.num++; @@ -534,7 +538,7 @@ void CLDNNGraph::UpdatePerfStatistics() { pcIter = perfMap.find(executedID.first); auto& perfCount = pcIter->second.second; - cldnn::instrumentation::profiling_info cldnnInfo{executedID.first, executedID.second.get_profiling_info()}; + cldnn::instrumentation::profiling_info cldnnInfo{executedID.first, executedID.second->get_profiling_info()}; collectTimings(cldnnInfo, perfCount); perfCount.num++; @@ -675,7 +679,7 @@ std::map CLDNNGraph::G executedPrimitives.find(primId) != executedPrimitives.end()) { auto event = executedPrimitives.at(primId); - cldnn::instrumentation::profiling_info cldnnInfo{primId, event.get_profiling_info()}; + cldnn::instrumentation::profiling_info cldnnInfo{primId, event->get_profiling_info()}; // Collect timings long long cpuTime = 0; diff --git a/inference-engine/src/cldnn_engine/cldnn_graph.h b/inference-engine/src/cldnn_engine/cldnn_graph.h index 774b159a16c2b9..5ce64712fefa9b 100644 --- a/inference-engine/src/cldnn_engine/cldnn_graph.h +++ b/inference-engine/src/cldnn_engine/cldnn_graph.h @@ -17,8 +17,8 @@ #include "ie_blob.h" #include "cpp/ie_cnn_network.h" -#include -#include +#include +#include #include #include "cldnn_custom_layer.h" @@ -43,7 +43,7 @@ class CLDNNGraph { const Config& getConfig() const { return m_config; } InferenceEngine::gpu::ClContext::Ptr GetContext() { return m_context; } - std::shared_ptr GetEngine() const { return getContextImpl(m_context)->GetEngine(); } + std::shared_ptr GetEngine() const { return getContextImpl(m_context)->GetEngine(); } int GetMaxDynamicBatchSize() const { return getConfig().max_dynamic_batch; } const std::map& GetInputLayouts() const { return m_program->GetInputLayouts(); } size_t GetNetworksCount() const { return m_networks.size(); } diff --git a/inference-engine/src/cldnn_engine/cldnn_infer_request.cpp b/inference-engine/src/cldnn_engine/cldnn_infer_request.cpp index 23f9895970ddf1..bb923f373b9e14 100644 --- a/inference-engine/src/cldnn_engine/cldnn_infer_request.cpp +++ b/inference-engine/src/cldnn_engine/cldnn_infer_request.cpp @@ -19,7 +19,7 @@ using namespace InferenceEngine; namespace CLDNNPlugin { -const char CLDNNInferRequest::fp32_suffix[] = "_fp32"; +const char fp32_suffix[] = "_fp32"; const char str_not_allocated[] = "Input data was not allocated."; const char cannot_set_compound[] = "cannot set compound blob: supported only for input pre-processing"; const char wrong_nv12_blob[] = "NV12 input blob is expected for input with NV12 color format"; @@ -110,7 +110,7 @@ Blob::Ptr CLDNNInferRequest::createOutputBlob(const TensorDesc& desc, uint8_t* m } } -void CLDNNInferRequest::input_attach(cldnn::primitive_id name, cldnn::memory& inputMem) { +void CLDNNInferRequest::input_attach(cldnn::primitive_id name, cldnn::memory::ptr inputMem) { OV_ITT_SCOPED_TASK(itt::domains::CLDNNPlugin, "CLDNNInferRequest::input_attach"); auto impl = getContextImpl(m_graph->GetContext()); impl->acquire_lock(); @@ -127,159 +127,66 @@ void CLDNNInferRequest::input_attach(cldnn::primitive_id name, cldnn::memory& in void CLDNNInferRequest::input_alloc(cldnn::primitive_id name, const cldnn::layout& layout) { OV_ITT_SCOPED_TASK(itt::domains::CLDNNPlugin, "CLDNNInferRequest::input_alloc"); - cldnn::memory input_mem = cldnn::memory::allocate(*(m_graph->GetEngine()), layout); + cldnn::memory::ptr input_mem = m_graph->GetEngine()->allocate_memory(layout); input_attach(name, input_mem); } -void CLDNNInferRequest::copyOutputData(const cldnn::memory& outputMemory, - Blob::Ptr bptr, - buf_info* bi) { - OV_ITT_SCOPED_TASK(itt::domains::CLDNNPlugin, "CLDNNInferRequest::copyOutputData"); - size_t n = (bi == nullptr) ? bptr->size() : bi->buf_size; +template +void copyResultToOutputBlob(cldnn::memory::ptr src, Blob::Ptr dst, buf_info* bi, cldnn::stream& stream) { + size_t n = (bi == nullptr) ? dst->size() : bi->buf_size; size_t offset = (bi == nullptr) ? 0 : bi->buf_offset; - auto layout = outputMemory.get_layout(); + auto layout = src->get_layout(); auto size = layout.size; - auto l_padd = layout.data_padding.lower_size(); - auto u_padd = layout.data_padding.upper_size(); - - auto h_padding = u_padd.spatial[0] + l_padd.spatial[0]; - auto v_padding_l = (h_padding + size.spatial[0]) * u_padd.spatial[1]; - auto v_padding_u = (h_padding + size.spatial[0]) * l_padd.spatial[1]; - auto locked = bptr->buffer(); - switch (bptr->getTensorDesc().getPrecision()) { - case Precision::FP32: { - auto out_f = locked.as(); - if (out_f == nullptr) { - IE_THROW() << "Invalid output blob"; - } - auto resPtr = outputMemory.pointer(); - float *resVec = out_f + offset; - - if (h_padding || v_padding_l || v_padding_u) { - size_t i = 0; - for (size_t b = 0; b < size.batch[0]; b++) { - for (size_t f = 0; f < size.feature[0]; f++) { - i += v_padding_l; - for (size_t y = 0; y < size.spatial[1]; y++) { - i += l_padd.spatial[0]; - for (size_t x = 0; x < size.spatial[0]; x++, i++) { - *resVec++ = resPtr[i]; - } - i += u_padd.spatial[0]; - } - i += v_padding_u; - } - } - } else { - for (size_t i = 0; i < n; i++) { - resVec[i] = resPtr[i]; - } - } - } - break; - case Precision::FP16: { - auto out_f = locked.as(); - if (out_f == nullptr) { - IE_THROW() << "Invalid output blob"; - } - auto resPtr = outputMemory.pointer(); - uint16_t* resVec = out_f + offset; - - if (h_padding || v_padding_l || v_padding_u) { - size_t i = 0; - for (size_t b = 0; b < size.batch[0]; b++) { - for (size_t f = 0; f < size.feature[0]; f++) { - i += v_padding_l; - for (size_t y = 0; y < size.spatial[1]; y++) { - i += l_padd.spatial[0]; - for (size_t x = 0; x < size.spatial[0]; x++, i++) { - *resVec++ = resPtr[i]; - } - i += u_padd.spatial[0]; - } - i += v_padding_u; - } - } - } else { - for (size_t i = 0; i < n; i++) { - resVec[i] = resPtr[i]; - } - } - } - break; - case Precision::I32: { - auto out_f = locked.as(); - if (out_f == nullptr) { - IE_THROW() << "Invalid output blob"; - } - auto resPtr = outputMemory.pointer(); - int32_t* resVec = out_f + offset; - - if (h_padding || v_padding_l || v_padding_u) { - size_t i = 0; - for (size_t b = 0; b < size.batch[0]; b++) { - for (size_t f = 0; f < size.feature[0]; f++) { - i += v_padding_l; - for (size_t y = 0; y < size.spatial[1]; y++) { - i += l_padd.spatial[0]; - for (size_t x = 0; x < size.spatial[0]; x++, i++) { - *resVec++ = resPtr[i]; + auto locked_dst = dst->buffer(); + auto dst_ptr = locked_dst.as(); + if (dst_ptr == nullptr) { + IE_THROW() << "Invalid output blob"; + } + cldnn::mem_lock src_lock{ src, stream }; + T* src_ptr = src_lock.data(); + dst_ptr += offset; + + if (layout.data_padding) { + for (size_t b = 0; b < size.batch[0]; b++) { + for (size_t f = 0; f < size.feature[0]; f++) { + for (size_t w = 0; w < size.spatial[3]; w++) { + for (size_t z = 0; z < size.spatial[2]; z++) { + for (size_t y = 0; y < size.spatial[1]; y++) { + for (size_t x = 0; x < size.spatial[0]; x++) { + *dst_ptr++ = src_ptr[layout.get_linear_offset(cldnn::tensor(b, f, x, y, z, w))]; + } } - i += u_padd.spatial[0]; } - i += v_padding_u; } } - } else { - for (size_t i = 0; i < n; i++) { - resVec[i] = resPtr[i]; - } } - } - break; - case Precision::I64: { - auto out_f = locked.as(); - if (out_f == nullptr) { - IE_THROW() << "Invalid output blob"; - } - auto resPtr = outputMemory.pointer(); - int64_t* resVec = out_f + offset; - - if (h_padding || v_padding_l || v_padding_u) { - size_t i = 0; - for (size_t b = 0; b < size.batch[0]; b++) { - for (size_t f = 0; f < size.feature[0]; f++) { - i += v_padding_l; - for (size_t y = 0; y < size.spatial[1]; y++) { - i += l_padd.spatial[0]; - for (size_t x = 0; x < size.spatial[0]; x++, i++) { - *resVec++ = resPtr[i]; - } - i += u_padd.spatial[0]; - } - i += v_padding_u; - } - } - } else { - for (size_t i = 0; i < n; i++) { - resVec[i] = resPtr[i]; - } + } else { + for (size_t i = 0; i < n; i++) { + dst_ptr[i] = src_ptr[i]; } } - break; - default: - IE_THROW() << "The plugin does not support output " << bptr->getTensorDesc().getPrecision() << " precision"; +} + +void CLDNNInferRequest::copyOutputData(cldnn::memory::ptr src, Blob::Ptr dst, buf_info* bi) { + OV_ITT_SCOPED_TASK(itt::domains::CLDNNPlugin, "CLDNNInferRequest::copyOutputData"); + auto& stream = m_graph->GetNetwork()->get_stream(); + switch (dst->getTensorDesc().getPrecision()) { + case Precision::FP32: copyResultToOutputBlob(src, dst, bi, stream); break; + case Precision::FP16: copyResultToOutputBlob(src, dst, bi, stream); break; + case Precision::I32: copyResultToOutputBlob(src, dst, bi, stream); break; + case Precision::I64: copyResultToOutputBlob(src, dst, bi, stream); break; + default: IE_THROW(NotImplemented) << "The plugin does not support output " << dst->getTensorDesc().getPrecision() << " precision"; } } void CLDNNInferRequest::copyInputData(std::shared_ptr network, - const cldnn::primitive_id &inputName, - const cldnn::layout& inputLayout, - const Blob &inputBlob, buf_info* bi) { + const cldnn::primitive_id &inputName, + const cldnn::layout& inputLayout, + const Blob &inputBlob, buf_info* bi) { OV_ITT_SCOPED_TASK(itt::domains::CLDNNPlugin, "CLDNNInferRequest::copyInputData"); - size_t n = (bi == nullptr) ? inputBlob.size() : bi->buf_size; + size_t offset = (bi == nullptr) ? 0 : bi->buf_offset; cldnn::primitive_id internalName = "parameter:" + inputName; @@ -287,37 +194,37 @@ void CLDNNInferRequest::copyInputData(std::shared_ptr network, switch (inputBlob.getTensorDesc().getPrecision()) { case Precision::FP32: { float* blob_ptr = const_cast(locked.as()) + offset; - network->set_input_data(internalName, cldnn::memory::attach(inputLayout, blob_ptr, n)); + network->set_input_data(internalName, network->get_engine().attach_memory(inputLayout, blob_ptr)); break; } case Precision::I32: { int32_t* blob_ptr = const_cast(locked.as()) + offset; - network->set_input_data(internalName, cldnn::memory::attach(inputLayout, blob_ptr, n)); + network->set_input_data(internalName, network->get_engine().attach_memory(inputLayout, blob_ptr)); break; } case Precision::I64: { int64_t* blob_ptr = const_cast(locked.as()) + offset; - network->set_input_data(internalName, cldnn::memory::attach(inputLayout, blob_ptr, n)); + network->set_input_data(internalName, network->get_engine().attach_memory(inputLayout, blob_ptr)); break; } case Precision::FP16: { uint16_t* blob_ptr = const_cast(locked.as()) + offset; - network->set_input_data(internalName, cldnn::memory::attach(inputLayout, blob_ptr, n)); + network->set_input_data(internalName, network->get_engine().attach_memory(inputLayout, blob_ptr)); break; } case Precision::I8: { int8_t* blob_ptr = const_cast(locked.as()) + offset; - network->set_input_data(internalName, cldnn::memory::attach(inputLayout, blob_ptr, n)); + network->set_input_data(internalName, network->get_engine().attach_memory(inputLayout, blob_ptr)); break; } case Precision::U8: { uint8_t* blob_ptr = const_cast(locked.as()) + offset; - network->set_input_data(internalName, cldnn::memory::attach(inputLayout, blob_ptr, n)); + network->set_input_data(internalName, network->get_engine().attach_memory(inputLayout, blob_ptr)); break; } case Precision::BOOL: { uint8_t* blob_ptr = const_cast(locked.as()) + offset; - network->set_input_data(internalName, cldnn::memory::attach(inputLayout, blob_ptr, n)); + network->set_input_data(internalName, network->get_engine().attach_memory(inputLayout, blob_ptr)); break; } default: @@ -601,6 +508,7 @@ void CLDNNInferRequest::SetBlob(const std::string& name, const Blob::Ptr &data) void CLDNNInferRequest::AllocateInputs() { OV_ITT_SCOPED_TASK(itt::domains::CLDNNPlugin, "CLDNNInferRequest::AllocateInputs"); auto inputLayouts = m_graph->GetInputLayouts(); + auto& stream = m_graph->GetNetwork()->get_stream(); // allocate inputs for (auto& ni : _networkInputs) { std::string name = ni.first; @@ -623,25 +531,24 @@ void CLDNNInferRequest::AllocateInputs() { input_alloc(UVName, inputLayouts.at(UVName)); size_t height = desc.getDims()[2], width = desc.getDims()[3]; - cldnn::pointer input_mem_ptr_Y = inputsMemory.at(YName).pointer(); + cldnn::mem_lock input_mem_ptr_Y{inputsMemory.at(YName), stream}; TensorDesc ydesc(Precision::U8, { 1, 1, height, width }, Layout::NHWC); auto blobY = createInputBlob(ydesc, input_mem_ptr_Y.data()); - cldnn::pointer input_mem_ptr_UV = inputsMemory.at(UVName).pointer(); + cldnn::mem_lock input_mem_ptr_UV{ inputsMemory.at(UVName), stream }; TensorDesc uvdesc(Precision::U8, { 1, 2, height / 2, width / 2 }, Layout::NHWC); auto blobUV = createInputBlob(uvdesc, input_mem_ptr_UV.data()); blobs.push_back(make_shared_blob(blobY, blobUV)); } _inputs[name] = desc.getDims()[0] == 1 ? blobs[0] : make_shared_blob(blobs); - } else { if (inputLayouts.find(name) == inputLayouts.end()) { IE_THROW() << "Input layout for " << name << " is not found"; } cldnn::layout layout = inputLayouts.at(name); input_alloc(name, layout); - cldnn::pointer mem_ptr = inputsMemory.at(name).pointer(); + cldnn::mem_lock mem_ptr{inputsMemory.at(name), stream}; _inputs[name] = createInputBlob(desc, mem_ptr.data()); if (desc.getPrecision() == Precision::I16 || desc.getPrecision() == Precision::U16) { @@ -685,8 +592,8 @@ void CLDNNInferRequest::AllocateOutputs() { bool can_reuse_internal_mem = !m_useStreams; for (auto& no : _networkOutputs) { std::string outputID = m_graph->MapOutputName(no.first); - cldnn::memory output_mem = m_graph->GetNetwork()->get_output_memory(outputID); - cldnn::pointer output_mem_ptr = output_mem.pointer(); + cldnn::memory::ptr output_mem = m_graph->GetNetwork()->get_output_memory(outputID); + cldnn::mem_lock output_mem_ptr{output_mem, m_graph->GetNetwork()->get_stream()}; if (output_mem_ptr.data() == nullptr) { IE_THROW() << "Empty output memory for primitive " << outputID; } @@ -824,6 +731,7 @@ CLDNNInferRequest::CLDNNInferRequest(InputsDataMap networkInputs, OutputsDataMap void CLDNNInferRequest::execAndParse() { OV_ITT_SCOPED_TASK(itt::domains::CLDNNPlugin, "CLDNNInferRequest::execAndParse"); auto networkOutputs = m_graph->GetNetwork()->execute(); + auto& stream = m_graph->GetNetwork()->get_stream(); // Collect outputs as requested by the model for (auto& no : _networkOutputs) { @@ -835,12 +743,12 @@ void CLDNNInferRequest::execAndParse() { // mapping remote blobs not needed - // let the user take care of them explicitly if (!bptr->is()) { - auto out_ptr = outputMemory.pointer(); + cldnn::mem_lock out_ptr{outputMemory, stream}; auto blob_ptr = bptr->buffer().as(); // If Async API is used, copy of output blobs is not needed, unless SetBlob function was called. // But in the case when old API is used we have to copy data to memory provided by user. - if (blob_ptr != &out_ptr[0]) { + if (blob_ptr != out_ptr.data()) { copyOutputData(outputMemory, bptr); } } @@ -965,19 +873,20 @@ void CLDNNInferRequest::PrepareInput(const cldnn::primitive_id &inputName, const IE_THROW() << "Input name mismatch."; } auto inputLayout = m_graph->GetInputLayouts().at(inputName); - auto is_same_buffer = [](const Blob& blob, const cldnn::memory& memory) -> bool { + auto is_same_buffer = [&](const Blob& blob, cldnn::memory::ptr memory) -> bool { const std::string str_not_allocated("Input data was not allocated."); - cldnn::pointer ptr = memory.pointer(); + cldnn::mem_lock ptr{memory, m_graph->GetNetwork()->get_stream()}; const uint8_t* blob_ptr = blob.cbuffer().as(); const uint8_t* mem_ptr = ptr.data(); if (blob_ptr == nullptr || mem_ptr == nullptr) { IE_THROW() << str_not_allocated; } - return (blob_ptr == mem_ptr) && (blob.byteSize() == memory.size()); + return (blob_ptr == mem_ptr) && (blob.byteSize() == memory->size()); }; cldnn::primitive_id internalName = "parameter:" + inputName; - const cldnn::memory& memory = inputsMemory.at(inputName); + cldnn::memory::ptr memory = inputsMemory.at(inputName); + auto& stream = m_graph->GetNetwork()->get_stream(); auto _nw_ptr = m_graph->GetNetwork(); auto prec = inputBlob.getTensorDesc().getPrecision(); @@ -986,8 +895,8 @@ void CLDNNInferRequest::PrepareInput(const cldnn::primitive_id &inputName, const _nw_ptr->set_input_data(internalName, memory); } else if (prec == Precision::I16 || prec == Precision::U16) { // clDNN doesn't support I16 input precision, so we always have to convert input data to fp32 precision - const cldnn::memory& fp32_mem = inputsMemory.at(inputName+fp32_suffix); - cldnn::pointer ptr = fp32_mem.pointer(); + cldnn::memory::ptr fp32_mem = inputsMemory.at(inputName+fp32_suffix); + cldnn::mem_lock ptr {fp32_mem, stream}; if (prec == Precision::I16) { copyToFloat(ptr.data(), &inputBlob); } else { @@ -1031,4 +940,4 @@ void CLDNNInferRequest::PrepareInputDyn(const cldnn::primitive_id &inputName, co } } -}; // namespace CLDNNPlugin +} // namespace CLDNNPlugin diff --git a/inference-engine/src/cldnn_engine/cldnn_infer_request.h b/inference-engine/src/cldnn_engine/cldnn_infer_request.h index f9ec4d94db54f5..a988438e8d6657 100644 --- a/inference-engine/src/cldnn_engine/cldnn_infer_request.h +++ b/inference-engine/src/cldnn_engine/cldnn_infer_request.h @@ -46,7 +46,7 @@ class CLDNNInferRequest : public InferenceEngine::IInferRequestInternal { void EnableStreams() { m_useStreams = true; } protected: - std::map inputsMemory; + std::map inputsMemory; std::map outputsMap; bool m_useProfiling; @@ -60,12 +60,12 @@ class CLDNNInferRequest : public InferenceEngine::IInferRequestInternal { InferenceEngine::Blob::Ptr createInputBlob(const InferenceEngine::TensorDesc& desc, uint8_t* mem_ptr = nullptr); InferenceEngine::Blob::Ptr createOutputBlob(const InferenceEngine::TensorDesc& desc, uint8_t* mem_ptr = nullptr); - void copyOutputData(const cldnn::memory& outputMemory, InferenceEngine::Blob::Ptr bptr, buf_info* bi = nullptr); + void copyOutputData(cldnn::memory::ptr outputMemory, InferenceEngine::Blob::Ptr bptr, buf_info* bi = nullptr); void copyInputData(std::shared_ptr network, const cldnn::primitive_id &inputName, const cldnn::layout& inputLayout, const InferenceEngine::Blob &inputBlob, buf_info* bi = nullptr); - void input_attach(cldnn::primitive_id name, cldnn::memory& inputMem); + void input_attach(cldnn::primitive_id name, cldnn::memory::ptr inputMem); void input_alloc(cldnn::primitive_id name, const cldnn::layout& layout); void AllocateInputs(); void AllocateOutputs(); @@ -76,9 +76,6 @@ class CLDNNInferRequest : public InferenceEngine::IInferRequestInternal { void PrepareInput(const cldnn::primitive_id &inputName, const InferenceEngine::Blob &inputBlob); void PrepareInputDyn(const cldnn::primitive_id &inputName, const InferenceEngine::Blob &inputBlob); - -private: - static const char fp32_suffix[]; }; }; // namespace CLDNNPlugin diff --git a/inference-engine/src/cldnn_engine/cldnn_program.cpp b/inference-engine/src/cldnn_engine/cldnn_program.cpp index d30434397fdedc..6ff0d4ecef3169 100644 --- a/inference-engine/src/cldnn_engine/cldnn_program.cpp +++ b/inference-engine/src/cldnn_engine/cldnn_program.cpp @@ -92,7 +92,7 @@ bool Program::CanProcessDynBatch(std::vector> ops, return true; } -Program::Program(InferenceEngine::CNNNetwork& network, std::shared_ptr engine, const Config& config, bool createTopologyOnly) +Program::Program(InferenceEngine::CNNNetwork& network, std::shared_ptr engine, const Config& config, bool createTopologyOnly) : m_config(config) , m_engine(engine) , m_curBatch(-1) @@ -128,11 +128,9 @@ Program::Program(InferenceEngine::CNNNetwork& network, std::shared_ptr(b)); m_programs.insert(m_programs.begin(), BuildProgram(ops, networkInputs, networkOutputs, createTopologyOnly)); - m_engine->release_pending_memory(0); } } else { m_programs.emplace_back(BuildProgram(ops, networkInputs, networkOutputs, createTopologyOnly)); - m_engine->release_pending_memory(0); } } diff --git a/inference-engine/src/cldnn_engine/cldnn_program.h b/inference-engine/src/cldnn_engine/cldnn_program.h index a5299d810f9a03..8f90b4fabb7712 100644 --- a/inference-engine/src/cldnn_engine/cldnn_program.h +++ b/inference-engine/src/cldnn_engine/cldnn_program.h @@ -15,8 +15,8 @@ #include "cldnn_config.h" -#include -#include +#include +#include // Forward declarations for cldnn part namespace cldnn { @@ -69,8 +69,8 @@ struct PerfCounter { class Program { public: - Program(InferenceEngine::CNNNetwork& network, std::shared_ptr engine, const Config& config, bool createTopologyOnly = false); - Program(std::shared_ptr engine, const Config& config) : m_config(config), m_engine(engine), + Program(InferenceEngine::CNNNetwork& network, std::shared_ptr engine, const Config& config, bool createTopologyOnly = false); + Program(std::shared_ptr engine, const Config& config) : m_config(config), m_engine(engine), m_curBatch(-1), queryMode(false), m_max_batch(1) {} Program() : m_config({}), m_engine(nullptr), m_curBatch(-1), queryMode(false), m_max_batch(1) {} @@ -100,8 +100,8 @@ class Program { const std::map& GetInputLayouts() const { return inputLayouts; } InferenceEngine::InputsDataMap GetNetworkInputs() const { return m_networkInputs; } InferenceEngine::OutputsDataMap GetNetworkOutputs() const { return m_networkOutputs; } - const cldnn::engine& GetEngine() const { return *m_engine; } - std::shared_ptr GetEnginePtr() const { return m_engine; } + cldnn::engine& GetEngine() const { return *m_engine; } + std::shared_ptr GetEnginePtr() const { return m_engine; } const Config& GetConfig() const { return m_config; } int GetMaxBatchSizeForSingleProgram(); @@ -150,7 +150,7 @@ class Program { private: static factories_map_t factories_map; std::vector> m_programs; - std::shared_ptr m_engine; + std::shared_ptr m_engine; Config m_config; std::shared_ptr m_topology; diff --git a/inference-engine/src/cldnn_engine/cldnn_remote_context.cpp b/inference-engine/src/cldnn_engine/cldnn_remote_context.cpp index f03db1c4834e0d..ce52a5eea074bd 100644 --- a/inference-engine/src/cldnn_engine/cldnn_remote_context.cpp +++ b/inference-engine/src/cldnn_engine/cldnn_remote_context.cpp @@ -6,21 +6,23 @@ #include "cldnn_remote_context.h" #include "cldnn_itt.h" +#include "cldnn/runtime/device_query.hpp" + using namespace InferenceEngine; using namespace InferenceEngine::gpu; using namespace InferenceEngine::details; namespace CLDNNPlugin { -static const char unsupported_str[] = "Unsupported shared object type "; CLDNNRemoteAllocator CLDNNRemoteBlobImpl::m_allocator; CLDNNRemoteBlobImpl::CLDNNRemoteBlobImpl(ClContext::Ptr context, + cldnn::stream& stream, const cldnn::layout& layout, cldnn::shared_handle mem, cldnn::shared_surface surf, uint32_t plane, BlobType mem_type) : - m_context(context), m_layout(layout), m_mem_type(mem_type), m_mem(mem), m_surf(surf), m_plane(plane), + m_context(context), m_stream(stream), m_layout(layout), m_mem_type(mem_type), m_mem(mem), m_surf(surf), m_plane(plane), _handle(nullptr), _allocator(nullptr), m_memObject(nullptr), lockedHolder(nullptr) { } @@ -67,8 +69,7 @@ ParamMap CLDNNRemoteBlobImpl::getParams() const { } bool CLDNNRemoteBlobImpl::deallocate() noexcept { - if (m_memObject != nullptr) - m_memObject.reset(); + m_memObject.reset(); return m_memObject == nullptr; } @@ -86,32 +87,7 @@ void CLDNNRemoteBlobImpl::allocate_if_needed() { _impl->acquire_lock(); if (m_memObject == nullptr) { - auto eng = _impl->GetEngine(); - switch (m_mem_type) { - case BlobType::BT_BUF_INTERNAL: - m_memObject = std::unique_ptr(new cldnn::memory(cldnn::memory::allocate(*eng, m_layout))); - break; - case BlobType::BT_BUF_SHARED: - m_memObject = std::unique_ptr(new cldnn::memory(cldnn::memory::share_buffer(*eng, m_layout, m_mem))); - break; -#ifdef _WIN32 - case BlobType::BT_SURF_SHARED: - m_memObject = std::unique_ptr(new cldnn::memory(cldnn::memory::share_surface(*eng, m_layout, m_mem, m_plane))); - break; - case BlobType::BT_DX_BUF_SHARED: - m_memObject = std::unique_ptr(new cldnn::memory(cldnn::memory::share_dx_buffer(*eng, m_layout, m_mem))); - break; -#else - case BlobType::BT_SURF_SHARED: - m_memObject = std::unique_ptr(new cldnn::memory(cldnn::memory::share_surface(*eng, m_layout, m_surf, m_plane))); - break; -#endif - case BlobType::BT_IMG_SHARED: - m_memObject = std::unique_ptr(new cldnn::memory(cldnn::memory::share_image(*eng, m_layout, m_mem))); - break; - default: - IE_THROW() << unsupported_str << m_mem_type; - } + allocate(); } _impl->release_lock(); @@ -120,32 +96,38 @@ void CLDNNRemoteBlobImpl::allocate_if_needed() { void CLDNNRemoteBlobImpl::allocate() noexcept { assert(m_memObject == nullptr); - std::shared_ptr eng = getContextImpl(m_context.lock())->GetEngine(); + std::shared_ptr eng = getContextImpl(m_context.lock())->GetEngine(); switch (m_mem_type) { - case BlobType::BT_BUF_INTERNAL: - m_memObject = std::unique_ptr(new cldnn::memory(cldnn::memory::allocate(*eng, m_layout))); + case BlobType::BT_BUF_INTERNAL: { + m_memObject = eng->allocate_memory(m_layout); break; - case BlobType::BT_BUF_SHARED: - m_memObject = std::unique_ptr(new cldnn::memory(cldnn::memory::share_buffer(*eng, m_layout, m_mem))); + } + case BlobType::BT_BUF_SHARED: { + m_memObject = eng->share_buffer(m_layout, m_mem); break; + } #ifdef _WIN32 - case BlobType::BT_SURF_SHARED: - m_memObject = std::unique_ptr(new cldnn::memory(cldnn::memory::share_surface(*eng, m_layout, m_mem, m_plane))); + case BlobType::BT_SURF_SHARED: { + m_memObject = eng->share_surface(m_layout, m_mem, m_plane); break; - case BlobType::BT_DX_BUF_SHARED: - m_memObject = std::unique_ptr(new cldnn::memory(cldnn::memory::share_dx_buffer(*eng, m_layout, m_mem))); + } + case BlobType::BT_DX_BUF_SHARED: { + m_memObject = eng->share_dx_buffer(m_layout, m_mem); break; + } #else - case BlobType::BT_SURF_SHARED: - m_memObject = std::unique_ptr(new cldnn::memory(cldnn::memory::share_surface(*eng, m_layout, m_surf, m_plane))); + case BlobType::BT_SURF_SHARED: { + m_memObject = eng->share_surface(m_layout, m_surf, m_plane); break; + } #endif - case BlobType::BT_IMG_SHARED: - m_memObject = std::unique_ptr(new cldnn::memory(cldnn::memory::share_image(*eng, m_layout, m_mem))); + case BlobType::BT_IMG_SHARED: { + m_memObject = eng->share_image(m_layout, m_mem); break; + } default: - m_memObject = nullptr; + m_memObject.reset(); } } @@ -165,7 +147,7 @@ std::shared_ptr CLDNNRemoteBlobImpl::getContext() const noexcept } void CLDNNRemoteBlobImpl::lock() const { - lockedHolder = std::unique_ptr>(new cldnn::pointer(m_memObject->pointer())); + lockedHolder = std::unique_ptr>(new cldnn::mem_lock(m_memObject, m_stream)); auto ptr = lockedHolder->data(); _handle = reinterpret_cast(ptr); m_allocator.regLockedBlob(_handle, this); @@ -244,7 +226,11 @@ CLDNNExecutionContextImpl::CLDNNExecutionContextImpl(const std::shared_ptr(dev, - cldnn::engine_configuration((m_config.useProfiling || + bool enable_profiling = (m_config.useProfiling || (m_config.tuningConfig.mode == cldnn::tuning_mode::tuning_tune_and_cache) || - (m_config.tuningConfig.mode == cldnn::tuning_mode::tuning_retune_and_cache)), - false, - m_config.dumpCustomKernels, - std::string(), - std::string(), - true, - std::string(), - m_config.sources_dumps_dir, - m_config.queuePriority, - m_config.queueThrottle, - m_config.memory_pool_on, - m_config.throughput_streams, - m_config.kernels_cache_dir, - m_config.n_threads)); + (m_config.tuningConfig.mode == cldnn::tuning_mode::tuning_retune_and_cache)); + cldnn::queue_types queue_type = cldnn::queue_types::out_of_order; + bool use_unified_shared_memory = true; + m_engine = cldnn::engine::create(engine_type, runtime_type, dev, cldnn::engine_configuration(enable_profiling, + queue_type, + m_config.sources_dumps_dir, + m_config.queuePriority, + m_config.queueThrottle, + m_config.memory_pool_on, + use_unified_shared_memory, + m_config.kernels_cache_dir, + m_config.n_threads)); } } ParamMap CLDNNExecutionContextImpl::getParams() const { - ParamMap ret = { { GPU_PARAM_KEY(OCL_CONTEXT), m_engine->get_context() } }; + ParamMap ret = { { GPU_PARAM_KEY(OCL_CONTEXT), m_engine->get_user_context() } }; switch (m_type) { case OCL: diff --git a/inference-engine/src/cldnn_engine/cldnn_remote_context.h b/inference-engine/src/cldnn_engine/cldnn_remote_context.h index a2ce1729bd10fc..f6a92e82c48764 100644 --- a/inference-engine/src/cldnn_engine/cldnn_remote_context.h +++ b/inference-engine/src/cldnn_engine/cldnn_remote_context.h @@ -4,15 +4,11 @@ #pragma once -#include -#include -#include -#include +#include +#include #include #include #include "cldnn_config.h" -#include -#include #include "cldnn_common_utils.h" #ifndef NOMINMAX @@ -25,6 +21,11 @@ # include #endif +#include +#include +#include +#include + namespace CLDNNPlugin { class CLDNNRemoteAllocator; @@ -41,6 +42,7 @@ class CLDNNRemoteBlobImpl : public InferenceEngine::gpu::details::param_map_obj_ }; explicit CLDNNRemoteBlobImpl(InferenceEngine::gpu::ClContext::Ptr context, + cldnn::stream& stream, const cldnn::layout& layout, cldnn::shared_handle mem, cldnn::shared_surface surf, @@ -63,11 +65,12 @@ class CLDNNRemoteBlobImpl : public InferenceEngine::gpu::details::param_map_obj_ bool is_allocated() const noexcept; bool is_locked() const noexcept; void allocate_if_needed(); - cldnn::memory& getMemory() { return *m_memObject; } + cldnn::memory::ptr getMemory() { return m_memObject; } protected: static CLDNNRemoteAllocator m_allocator; std::weak_ptr m_context; + cldnn::stream& m_stream; // constructor stuff cldnn::shared_handle m_mem; @@ -77,9 +80,9 @@ class CLDNNRemoteBlobImpl : public InferenceEngine::gpu::details::param_map_obj_ cldnn::layout m_layout; BlobType m_mem_type; - std::unique_ptr m_memObject; + cldnn::memory::ptr m_memObject; - mutable std::unique_ptr> lockedHolder; + mutable std::unique_ptr> lockedHolder; mutable void* _handle; mutable std::shared_ptr _allocator; @@ -93,13 +96,14 @@ class typedCLDNNRemoteBlob : public TpublicAPI { using Ptr = std::shared_ptr; explicit typedCLDNNRemoteBlob(InferenceEngine::gpu::ClContext::Ptr context, + cldnn::stream& stream, const InferenceEngine::TensorDesc& desc, const cldnn::layout& layout, cldnn::shared_handle mem, cldnn::shared_surface surf, uint32_t plane, CLDNNRemoteBlobImpl::BlobType mem_type) - : _impl(context, layout, mem, surf, plane, mem_type) + : _impl(context, stream, layout, mem, surf, plane, mem_type) , TpublicAPI(desc) {} void allocate() noexcept override { _impl.allocate(); } @@ -231,6 +235,7 @@ class CLDNNExecutionContextImpl : public InferenceEngine::gpu::details::param_ma } protected: + // TODO: refactor to unique_ptr std::shared_ptr m_engine; InferenceEngine::gpu_handle_param m_va_display; Config m_config; @@ -267,6 +272,7 @@ class typedCLDNNExecutionContext : public TpublicContextAPI, using namespace InferenceEngine; using InferenceEngine::gpu::details::param_map_obj_getter; InferenceEngine::RemoteBlob::Ptr ret = nullptr; + auto& stream = _impl.GetEngine()->get_program_stream(); uint32_t plane = param_map_obj_getter::_ObjFromParamSimple(params, GPU_PARAM_KEY(VA_PLANE)); #ifdef _WIN32 cldnn::shared_handle mem = param_map_obj_getter::_ObjFromParamSimple(params, GPU_PARAM_KEY(DEV_OBJECT_HANDLE)); @@ -290,11 +296,11 @@ class typedCLDNNExecutionContext : public TpublicContextAPI, std::dynamic_pointer_cast (std::enable_shared_from_this>::shared_from_this()); #ifdef _WIN32 - ret = std::make_shared(smart_this, + ret = std::make_shared(smart_this, stream, tensorDesc, layout, mem, 0, plane, CLDNNRemoteBlobImpl::BlobType::BT_SURF_SHARED); #else - ret = std::make_shared(smart_this, + ret = std::make_shared(smart_this, stream, tensorDesc, layout, nullptr, surf, plane, CLDNNRemoteBlobImpl::BlobType::BT_SURF_SHARED); #endif @@ -311,6 +317,7 @@ class typedCLDNNExecutionContext : public TpublicContextAPI, InferenceEngine::RemoteBlob::Ptr ret = nullptr; _impl.acquire_lock(); + auto& stream = _impl.GetEngine()->get_program_stream(); // try to locate previously shared object auto itr = shared_obj_reg.find(mem); @@ -327,15 +334,15 @@ class typedCLDNNExecutionContext : public TpublicContextAPI, switch (blob_type) { case CLDNNRemoteBlobImpl::BlobType::BT_BUF_SHARED: - ret = std::make_shared(smart_this, tensorDesc, layout, mem, 0, 0, blob_type); + ret = std::make_shared(smart_this, stream, tensorDesc, layout, mem, 0, 0, blob_type); break; case CLDNNRemoteBlobImpl::BlobType::BT_IMG_SHARED: layout.format = ImageFormatFromLayout(tensorDesc.getLayout()); - ret = std::make_shared(smart_this, tensorDesc, layout, mem, 0, 0, blob_type); + ret = std::make_shared(smart_this, stream, tensorDesc, layout, mem, 0, 0, blob_type); break; #ifdef _WIN32 case CLDNNRemoteBlobImpl::BlobType::BT_DX_BUF_SHARED: - ret = std::make_shared(smart_this, tensorDesc, layout, mem, 0, 0, blob_type); + ret = std::make_shared(smart_this, stream, tensorDesc, layout, mem, 0, 0, blob_type); break; #endif default: @@ -354,7 +361,9 @@ class typedCLDNNExecutionContext : public TpublicContextAPI, CldnnTensorFromIEDims(tensorDesc.getDims())); auto smart_this = std::dynamic_pointer_cast (std::enable_shared_from_this>::shared_from_this()); + auto& stream = _impl.GetEngine()->get_program_stream(); return std::make_shared(smart_this, + stream, tensorDesc, layout, nullptr, 0, 0, diff --git a/inference-engine/src/cldnn_engine/ops/batch_to_space.cpp b/inference-engine/src/cldnn_engine/ops/batch_to_space.cpp index 51d70e05f1a525..e46643f0617ca9 100644 --- a/inference-engine/src/cldnn_engine/ops/batch_to_space.cpp +++ b/inference-engine/src/cldnn_engine/ops/batch_to_space.cpp @@ -8,7 +8,7 @@ #include "ngraph/op/batch_to_space.hpp" #include "ngraph/op/constant.hpp" -#include "api/batch_to_space.hpp" +#include "cldnn/primitives/batch_to_space.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/broadcast.cpp b/inference-engine/src/cldnn_engine/ops/broadcast.cpp index af0ed9b7b751da..6d6e63032005c3 100644 --- a/inference-engine/src/cldnn_engine/ops/broadcast.cpp +++ b/inference-engine/src/cldnn_engine/ops/broadcast.cpp @@ -8,9 +8,9 @@ #include "ngraph/op/broadcast.hpp" #include "ngraph/op/constant.hpp" -#include "api/broadcast.hpp" -#include "api/reorder.hpp" -#include "api/reshape.hpp" +#include "cldnn/primitives/broadcast.hpp" +#include "cldnn/primitives/reorder.hpp" +#include "cldnn/primitives/reshape.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/concat.cpp b/inference-engine/src/cldnn_engine/ops/concat.cpp index 5a300c3dc8f394..9d37f959f03fb7 100644 --- a/inference-engine/src/cldnn_engine/ops/concat.cpp +++ b/inference-engine/src/cldnn_engine/ops/concat.cpp @@ -7,7 +7,7 @@ #include "ngraph/op/concat.hpp" -#include "api/concatenation.hpp" +#include "cldnn/primitives/concatenation.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/constant.cpp b/inference-engine/src/cldnn_engine/ops/constant.cpp index e8630f67a6bc31..fea42f31d98227 100644 --- a/inference-engine/src/cldnn_engine/ops/constant.cpp +++ b/inference-engine/src/cldnn_engine/ops/constant.cpp @@ -17,7 +17,7 @@ #include "ngraph/op/variadic_split.hpp" #include "ngraph/op/util/op_types.hpp" -#include "api/data.hpp" +#include "cldnn/primitives/data.hpp" namespace CLDNNPlugin { @@ -169,9 +169,10 @@ void CreateConstantOp(Program& p, const std::shared_ptrsecond; } else { - auto mem = cldnn::memory::allocate(p.GetEngine(), constLayout, 0, false); - auto tmpPointer = mem.pointer(); // implicitly maps buffer - unmap in destructor - auto buf = tmpPointer.data(); + cldnn::memory::ptr mem = p.GetEngine().allocate_memory(constLayout, false); + auto& stream = p.GetEngine().get_program_stream(); + cldnn::mem_lock lock{mem, stream}; + auto buf = lock.data(); auto bufSize = constLayout.bytes_count(); // Do actual weights reorder and change O and I channels order diff --git a/inference-engine/src/cldnn_engine/ops/convert.cpp b/inference-engine/src/cldnn_engine/ops/convert.cpp index 29fb037258f092..6af5bee759d683 100644 --- a/inference-engine/src/cldnn_engine/ops/convert.cpp +++ b/inference-engine/src/cldnn_engine/ops/convert.cpp @@ -8,7 +8,7 @@ #include "ngraph/op/convert.hpp" #include "ngraph/op/convert_like.hpp" -#include "api/reorder.hpp" +#include "cldnn/primitives/reorder.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/convolution.cpp b/inference-engine/src/cldnn_engine/ops/convolution.cpp index 3207dab623aefa..83f536a68b72fb 100644 --- a/inference-engine/src/cldnn_engine/ops/convolution.cpp +++ b/inference-engine/src/cldnn_engine/ops/convolution.cpp @@ -13,11 +13,11 @@ #include "ngraph/op/fake_quantize.hpp" #include "ngraph/op/util/op_types.hpp" -#include "api/convolution.hpp" -#include "api/deconvolution.hpp" -#include "api/binary_convolution.hpp" -#include "api/permute.hpp" -#include "api/reorder.hpp" +#include "cldnn/primitives/convolution.hpp" +#include "cldnn/primitives/deconvolution.hpp" +#include "cldnn/primitives/binary_convolution.hpp" +#include "cldnn/primitives/permute.hpp" +#include "cldnn/primitives/reorder.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/ctc_greedy_decoder.cpp b/inference-engine/src/cldnn_engine/ops/ctc_greedy_decoder.cpp index 2887360724535e..c8bd8d54e078ea 100644 --- a/inference-engine/src/cldnn_engine/ops/ctc_greedy_decoder.cpp +++ b/inference-engine/src/cldnn_engine/ops/ctc_greedy_decoder.cpp @@ -8,9 +8,9 @@ #include "ngraph/op/ctc_greedy_decoder.hpp" #include "ngraph/op/ctc_greedy_decoder_seq_len.hpp" -#include "api/ctc_greedy_decoder.hpp" -#include "api/reorder.hpp" -#include "api/mutable_data.hpp" +#include "cldnn/primitives/ctc_greedy_decoder.hpp" +#include "cldnn/primitives/reorder.hpp" +#include "cldnn/primitives/mutable_data.hpp" #include "transformations/utils/utils.hpp" @@ -58,7 +58,7 @@ void CreateCommonCTCGreedyDecoderOp(Program& p, const std::shared_ptrget_output_size(); - std::vector shared_memory; + std::vector shared_memory; if (num_output == 2) { auto mutable_precision = op->get_output_element_type(1); if (mutable_precision == ngraph::element::i64) { @@ -70,7 +70,7 @@ void CreateCommonCTCGreedyDecoderOp(Program& p, const std::shared_ptrget_output_shape(1).size()), CldnnTensorFromIEDims(op->get_output_shape(1))); - shared_memory.emplace_back(cldnn::memory::allocate(p.GetEngine(), mutableLayout)); + shared_memory.emplace_back(p.GetEngine().allocate_memory(mutableLayout)); cldnn::primitive_id ctc_gd_mutable_id_w = layer_type_name_ID(op) + "_md_write"; auto ctc_gd_mutable_prim = cldnn::mutable_data(ctc_gd_mutable_id_w, shared_memory[0]); diff --git a/inference-engine/src/cldnn_engine/ops/cum_sum.cpp b/inference-engine/src/cldnn_engine/ops/cum_sum.cpp index 6252a258269899..1bdcec2957eda5 100644 --- a/inference-engine/src/cldnn_engine/ops/cum_sum.cpp +++ b/inference-engine/src/cldnn_engine/ops/cum_sum.cpp @@ -8,7 +8,7 @@ #include "ngraph/op/cum_sum.hpp" #include "ngraph/op/constant.hpp" -#include "api/cum_sum.hpp" +#include "cldnn/primitives/cum_sum.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/custom.cpp b/inference-engine/src/cldnn_engine/ops/custom.cpp index 5211fc94efd3aa..85945bfbdb9698 100644 --- a/inference-engine/src/cldnn_engine/ops/custom.cpp +++ b/inference-engine/src/cldnn_engine/ops/custom.cpp @@ -9,8 +9,8 @@ #include "ngraph/attribute_visitor.hpp" #include "ngraph/node.hpp" -#include "api/custom_gpu_primitive.hpp" -#include "api/reorder.hpp" +#include "cldnn/primitives/custom_gpu_primitive.hpp" +#include "cldnn/primitives/reorder.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/depth_to_space.cpp b/inference-engine/src/cldnn_engine/ops/depth_to_space.cpp index 4c407a126d50e0..b53262ab23dec7 100644 --- a/inference-engine/src/cldnn_engine/ops/depth_to_space.cpp +++ b/inference-engine/src/cldnn_engine/ops/depth_to_space.cpp @@ -7,7 +7,7 @@ #include "ngraph/op/depth_to_space.hpp" -#include "api/depth_to_space.hpp" +#include "cldnn/primitives/depth_to_space.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/detection_output.cpp b/inference-engine/src/cldnn_engine/ops/detection_output.cpp index 8bbe102bcfd05d..aa2b505f0e76df 100644 --- a/inference-engine/src/cldnn_engine/ops/detection_output.cpp +++ b/inference-engine/src/cldnn_engine/ops/detection_output.cpp @@ -7,7 +7,7 @@ #include "ngraph/op/detection_output.hpp" -#include "api/detection_output.hpp" +#include "cldnn/primitives/detection_output.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/eltwise.cpp b/inference-engine/src/cldnn_engine/ops/eltwise.cpp index 66dcca7b459c47..817512d5bf92ec 100644 --- a/inference-engine/src/cldnn_engine/ops/eltwise.cpp +++ b/inference-engine/src/cldnn_engine/ops/eltwise.cpp @@ -25,10 +25,10 @@ #include "ngraph/op/power.hpp" #include "ngraph/op/floor_mod.hpp" -#include "api/activation.hpp" -#include "api/eltwise.hpp" -#include "api/reorder.hpp" -#include "api/reshape.hpp" +#include "cldnn/primitives/activation.hpp" +#include "cldnn/primitives/eltwise.hpp" +#include "cldnn/primitives/reorder.hpp" +#include "cldnn/primitives/reshape.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/embedding_bag.cpp b/inference-engine/src/cldnn_engine/ops/embedding_bag.cpp index 35b9f00096d009..2e97a60aebf8be 100644 --- a/inference-engine/src/cldnn_engine/ops/embedding_bag.cpp +++ b/inference-engine/src/cldnn_engine/ops/embedding_bag.cpp @@ -9,8 +9,8 @@ #include "ngraph/op/embeddingbag_offsets_sum.hpp" #include "ngraph/op/embeddingbag_packedsum.hpp" -#include "api/embedding_bag.hpp" -#include "api/reorder.hpp" +#include "cldnn/primitives/embedding_bag.hpp" +#include "cldnn/primitives/reorder.hpp" #include "transformations/utils/utils.hpp" diff --git a/inference-engine/src/cldnn_engine/ops/extract_image_patches.cpp b/inference-engine/src/cldnn_engine/ops/extract_image_patches.cpp index 42f7c4e8e99666..23b5f01432001a 100644 --- a/inference-engine/src/cldnn_engine/ops/extract_image_patches.cpp +++ b/inference-engine/src/cldnn_engine/ops/extract_image_patches.cpp @@ -7,7 +7,7 @@ #include "ngraph/op/extractimagepatches.hpp" -#include "api/extract_image_patches.hpp" +#include "cldnn/primitives/extract_image_patches.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/fake_quantize.cpp b/inference-engine/src/cldnn_engine/ops/fake_quantize.cpp index ca3d950694c4f3..345a70f34bbce3 100644 --- a/inference-engine/src/cldnn_engine/ops/fake_quantize.cpp +++ b/inference-engine/src/cldnn_engine/ops/fake_quantize.cpp @@ -7,7 +7,7 @@ #include "ngraph/op/fake_quantize.hpp" -#include "api/quantize.hpp" +#include "cldnn/primitives/quantize.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/gather tree.cpp b/inference-engine/src/cldnn_engine/ops/gather tree.cpp index a6c806bcbe8c1b..6b73131fd29d84 100644 --- a/inference-engine/src/cldnn_engine/ops/gather tree.cpp +++ b/inference-engine/src/cldnn_engine/ops/gather tree.cpp @@ -7,8 +7,8 @@ #include "ngraph/op/gather_tree.hpp" -#include "api/gather_tree.hpp" -#include "api/reorder.hpp" +#include "cldnn/primitives/gather_tree.hpp" +#include "cldnn/primitives/reorder.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/gather.cpp b/inference-engine/src/cldnn_engine/ops/gather.cpp index b80e26661e5353..362854cc32aaeb 100644 --- a/inference-engine/src/cldnn_engine/ops/gather.cpp +++ b/inference-engine/src/cldnn_engine/ops/gather.cpp @@ -7,8 +7,8 @@ #include "ngraph/op/gather.hpp" -#include "api/gather.hpp" -#include "api/reorder.hpp" +#include "cldnn/primitives/gather.hpp" +#include "cldnn/primitives/reorder.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/gather_nd.cpp b/inference-engine/src/cldnn_engine/ops/gather_nd.cpp index 6a1cd65132928e..cbdc5659bb3197 100644 --- a/inference-engine/src/cldnn_engine/ops/gather_nd.cpp +++ b/inference-engine/src/cldnn_engine/ops/gather_nd.cpp @@ -8,7 +8,7 @@ #include "ngraph/op/gather_nd.hpp" #include "ngraph/op/constant.hpp" -#include "api/gather_nd.hpp" +#include "cldnn/primitives/gather_nd.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/grn.cpp b/inference-engine/src/cldnn_engine/ops/grn.cpp index 3eb750f85a920c..960dd03494735d 100644 --- a/inference-engine/src/cldnn_engine/ops/grn.cpp +++ b/inference-engine/src/cldnn_engine/ops/grn.cpp @@ -7,7 +7,7 @@ #include "ngraph/op/grn.hpp" -#include "api/grn.hpp" +#include "cldnn/primitives/grn.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/interpolate.cpp b/inference-engine/src/cldnn_engine/ops/interpolate.cpp index f9241b8ca0fd75..b77999289c631b 100644 --- a/inference-engine/src/cldnn_engine/ops/interpolate.cpp +++ b/inference-engine/src/cldnn_engine/ops/interpolate.cpp @@ -9,7 +9,7 @@ #include "ngraph/op/interpolate.hpp" #include "ngraph/op/constant.hpp" -#include "api/resample.hpp" +#include "cldnn/primitives/resample.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/lrn.cpp b/inference-engine/src/cldnn_engine/ops/lrn.cpp index f8e7c601645cec..c13c17daaeb13d 100644 --- a/inference-engine/src/cldnn_engine/ops/lrn.cpp +++ b/inference-engine/src/cldnn_engine/ops/lrn.cpp @@ -8,7 +8,7 @@ #include "ngraph/op/lrn.hpp" #include "ngraph/op/constant.hpp" -#include "api/lrn.hpp" +#include "cldnn/primitives/lrn.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/matmul.cpp b/inference-engine/src/cldnn_engine/ops/matmul.cpp index 5fe6f1432586c3..a8818c9e6f67ee 100644 --- a/inference-engine/src/cldnn_engine/ops/matmul.cpp +++ b/inference-engine/src/cldnn_engine/ops/matmul.cpp @@ -9,11 +9,11 @@ #include "ngraph/op/constant.hpp" #include "ngraph/op/fake_quantize.hpp" -#include "api/gemm.hpp" -#include "api/fully_connected.hpp" -#include "api/reshape.hpp" -#include "api/reorder.hpp" -#include "api/permute.hpp" +#include "cldnn/primitives/gemm.hpp" +#include "cldnn/primitives/fully_connected.hpp" +#include "cldnn/primitives/reshape.hpp" +#include "cldnn/primitives/reorder.hpp" +#include "cldnn/primitives/permute.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/mvn.cpp b/inference-engine/src/cldnn_engine/ops/mvn.cpp index 79001b812e1854..b9cb376a24e34e 100644 --- a/inference-engine/src/cldnn_engine/ops/mvn.cpp +++ b/inference-engine/src/cldnn_engine/ops/mvn.cpp @@ -8,7 +8,8 @@ #include "ngraph/op/mvn.hpp" #include "ngraph/op/constant.hpp" -#include "api/mvn.hpp" +#include "cldnn/primitives/mvn.hpp" + #include namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/non_max_suppression.cpp b/inference-engine/src/cldnn_engine/ops/non_max_suppression.cpp index 8b124309467e10..a3d4834c51eed1 100644 --- a/inference-engine/src/cldnn_engine/ops/non_max_suppression.cpp +++ b/inference-engine/src/cldnn_engine/ops/non_max_suppression.cpp @@ -9,9 +9,9 @@ #include #include -#include "api/reorder.hpp" -#include "api/mutable_data.hpp" -#include "api/non_max_suppression.hpp" +#include "cldnn/primitives/reorder.hpp" +#include "cldnn/primitives/mutable_data.hpp" +#include "cldnn/primitives/non_max_suppression.hpp" namespace CLDNNPlugin { @@ -62,7 +62,7 @@ void CreateNonMaxSuppressionIEInternalOp(Program& p, const std::shared_ptrget_output_size(); - std::vector shared_memory; + std::vector shared_memory; switch (num_output) { case 3: { auto mutable_precision_second = op->get_output_element_type(2); @@ -74,7 +74,7 @@ void CreateNonMaxSuppressionIEInternalOp(Program& p, const std::shared_ptrget_output_shape(2).size()), CldnnTensorFromIEDims(op->get_output_shape(2))); - shared_memory.emplace_back(cldnn::memory::allocate(p.GetEngine(), mutableLayoutSecond)); + shared_memory.emplace_back(p.GetEngine().allocate_memory(mutableLayoutSecond)); cldnn::primitive_id non_max_supression_mutable_id_w_second = layer_type_name_ID(op) + "_md_write_second"; auto nms_mutable_prim_second = cldnn::mutable_data(non_max_supression_mutable_id_w_second, shared_memory.back()); @@ -91,7 +91,7 @@ void CreateNonMaxSuppressionIEInternalOp(Program& p, const std::shared_ptr(op->get_output_element_type(0), ngraph::Shape{1}, std::vector{1.0}); cldnn::layout constLayout = cldnn::layout(DataTypeFromPrecision(op->get_output_element_type(0)), cldnn::format::bfyx, cldnn::tensor{1}); - auto mem = cldnn::memory::allocate(p.GetEngine(), constLayout, 0, false); - auto tmpPointer = mem.pointer(); // implicitly maps buffer - unmap in destructor + auto mem = p.GetEngine().allocate_memory(constLayout, false); + cldnn::mem_lock tmpPointer{mem, p.GetEngine().get_program_stream()}; auto buf = tmpPointer.data(); auto bufSize = scale->get_output_tensor(0).size(); diff --git a/inference-engine/src/cldnn_engine/ops/one_hot.cpp b/inference-engine/src/cldnn_engine/ops/one_hot.cpp index 1076bf595efb0f..3d792bda8aee0e 100644 --- a/inference-engine/src/cldnn_engine/ops/one_hot.cpp +++ b/inference-engine/src/cldnn_engine/ops/one_hot.cpp @@ -8,7 +8,7 @@ #include "ngraph/op/one_hot.hpp" -#include "api/one_hot.hpp" +#include "cldnn/primitives/one_hot.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/pad.cpp b/inference-engine/src/cldnn_engine/ops/pad.cpp index a3503318a77f79..0d409414b58776 100644 --- a/inference-engine/src/cldnn_engine/ops/pad.cpp +++ b/inference-engine/src/cldnn_engine/ops/pad.cpp @@ -8,7 +8,7 @@ #include "ngraph/op/pad.hpp" -#include "api/border.hpp" +#include "cldnn/primitives/border.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/parameter.cpp b/inference-engine/src/cldnn_engine/ops/parameter.cpp index 7c61d8261d7881..b68593dd0a5b0f 100644 --- a/inference-engine/src/cldnn_engine/ops/parameter.cpp +++ b/inference-engine/src/cldnn_engine/ops/parameter.cpp @@ -7,10 +7,10 @@ #include "ngraph/op/parameter.hpp" -#include "api/input_layout.hpp" -#include "api/reorder.hpp" -#include "api/data.hpp" -#include "api/concatenation.hpp" +#include "cldnn/primitives/input_layout.hpp" +#include "cldnn/primitives/reorder.hpp" +#include "cldnn/primitives/data.hpp" +#include "cldnn/primitives/concatenation.hpp" using namespace InferenceEngine; @@ -158,8 +158,8 @@ void CreateParameterOp(Program& p, const std::shared_ptrsecond; } else { - auto mem = cldnn::memory::allocate(p.GetEngine(), meanBlobLayout, 0, false); - auto tmpPointer = mem.pointer(); // implicitly maps buffer - unmap in destructor + auto mem = p.GetEngine().allocate_memory(meanBlobLayout, false); + cldnn::mem_lock tmpPointer{ mem, p.GetEngine().get_program_stream() }; auto buf = tmpPointer.data(); auto bufSize = meanBlobLayout.bytes_count(); diff --git a/inference-engine/src/cldnn_engine/ops/pooling.cpp b/inference-engine/src/cldnn_engine/ops/pooling.cpp index 16ca93a6879d3c..f1bf6952292056 100644 --- a/inference-engine/src/cldnn_engine/ops/pooling.cpp +++ b/inference-engine/src/cldnn_engine/ops/pooling.cpp @@ -8,7 +8,7 @@ #include "ngraph/op/max_pool.hpp" #include "ngraph/op/avg_pool.hpp" -#include "api/pooling.hpp" +#include "cldnn/primitives/pooling.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/prior_box.cpp b/inference-engine/src/cldnn_engine/ops/prior_box.cpp index 07c6a4ca3ee240..6cf0aaa65355d3 100644 --- a/inference-engine/src/cldnn_engine/ops/prior_box.cpp +++ b/inference-engine/src/cldnn_engine/ops/prior_box.cpp @@ -8,7 +8,7 @@ #include "ngraph/op/prior_box.hpp" #include "ngraph/op/prior_box_clustered.hpp" -#include "api/prior_box.hpp" +#include "cldnn/primitives/prior_box.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/proposal.cpp b/inference-engine/src/cldnn_engine/ops/proposal.cpp index 70ff3d154f107d..d5b906e5e6e057 100644 --- a/inference-engine/src/cldnn_engine/ops/proposal.cpp +++ b/inference-engine/src/cldnn_engine/ops/proposal.cpp @@ -7,8 +7,8 @@ #include "ngraph/op/proposal.hpp" -#include "api/proposal.hpp" -#include "api/mutable_data.hpp" +#include "cldnn/primitives/proposal.hpp" +#include "cldnn/primitives/mutable_data.hpp" namespace CLDNNPlugin { @@ -62,7 +62,7 @@ void CreateProposalOp(Program& p, const std::shared_ptrget_output_shape(1).size()), CldnnTensorFromIEDims(op->get_output_shape(1))); - auto shared_memory = cldnn::memory::allocate(p.GetEngine(), mutableLayout); + auto shared_memory = p.GetEngine().allocate_memory(mutableLayout); cldnn::primitive_id proposal_mutable_id_w = layer_type_name_ID(op) + "_md_write"; auto argmax_mutable_prim = cldnn::mutable_data(proposal_mutable_id_w, shared_memory); diff --git a/inference-engine/src/cldnn_engine/ops/reduce.cpp b/inference-engine/src/cldnn_engine/ops/reduce.cpp index 26343ffb813129..b336a2e78faaf5 100644 --- a/inference-engine/src/cldnn_engine/ops/reduce.cpp +++ b/inference-engine/src/cldnn_engine/ops/reduce.cpp @@ -16,9 +16,9 @@ #include "ngraph/op/max.hpp" #include "ngraph/op/constant.hpp" -#include "api/reduce.hpp" -#include "api/reorder.hpp" -#include "api/reshape.hpp" +#include "cldnn/primitives/reduce.hpp" +#include "cldnn/primitives/reorder.hpp" +#include "cldnn/primitives/reshape.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/region_yolo.cpp b/inference-engine/src/cldnn_engine/ops/region_yolo.cpp index 6e5fd660e3fa91..348dd0f7eeb581 100644 --- a/inference-engine/src/cldnn_engine/ops/region_yolo.cpp +++ b/inference-engine/src/cldnn_engine/ops/region_yolo.cpp @@ -7,7 +7,7 @@ #include "ngraph/op/region_yolo.hpp" -#include "api/region_yolo.hpp" +#include "cldnn/primitives/region_yolo.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/reorg_yolo.cpp b/inference-engine/src/cldnn_engine/ops/reorg_yolo.cpp index 7ddc45221a6cfb..4a7f54cf810bc2 100644 --- a/inference-engine/src/cldnn_engine/ops/reorg_yolo.cpp +++ b/inference-engine/src/cldnn_engine/ops/reorg_yolo.cpp @@ -7,7 +7,7 @@ #include "ngraph/op/reorg_yolo.hpp" -#include "api/reorg_yolo.hpp" +#include "cldnn/primitives/reorg_yolo.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/reshape.cpp b/inference-engine/src/cldnn_engine/ops/reshape.cpp index b2111e77f64aa7..f0084bb6a1cb21 100644 --- a/inference-engine/src/cldnn_engine/ops/reshape.cpp +++ b/inference-engine/src/cldnn_engine/ops/reshape.cpp @@ -9,8 +9,8 @@ #include "ngraph/op/squeeze.hpp" #include "ngraph/op/unsqueeze.hpp" -#include "api/reshape.hpp" -#include "api/reorder.hpp" +#include "cldnn/primitives/reshape.hpp" +#include "cldnn/primitives/reorder.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/result.cpp b/inference-engine/src/cldnn_engine/ops/result.cpp index 4974f1ec56cdc7..fe0d0f05658018 100644 --- a/inference-engine/src/cldnn_engine/ops/result.cpp +++ b/inference-engine/src/cldnn_engine/ops/result.cpp @@ -7,7 +7,7 @@ #include "ngraph/op/result.hpp" -#include "api/reorder.hpp" +#include "cldnn/primitives/reorder.hpp" using namespace InferenceEngine; diff --git a/inference-engine/src/cldnn_engine/ops/reverse_sequence.cpp b/inference-engine/src/cldnn_engine/ops/reverse_sequence.cpp index 4537d3d34b7f0a..766bbc89a31d57 100644 --- a/inference-engine/src/cldnn_engine/ops/reverse_sequence.cpp +++ b/inference-engine/src/cldnn_engine/ops/reverse_sequence.cpp @@ -7,7 +7,7 @@ #include "ngraph/op/reverse_sequence.hpp" -#include "api/reverse_sequence.hpp" +#include "cldnn/primitives/reverse_sequence.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/rnn.cpp b/inference-engine/src/cldnn_engine/ops/rnn.cpp index a1bab946db42ec..2d4705f1a910fa 100644 --- a/inference-engine/src/cldnn_engine/ops/rnn.cpp +++ b/inference-engine/src/cldnn_engine/ops/rnn.cpp @@ -8,12 +8,12 @@ #include "ngraph/op/lstm_cell.hpp" #include "ngraph/op/lstm_sequence.hpp" -#include "api/reshape.hpp" -#include "api/reorder.hpp" -#include "api/fully_connected.hpp" -#include "api/lstm.hpp" -#include "api/crop.hpp" -#include "api/concatenation.hpp" +#include "cldnn/primitives/reshape.hpp" +#include "cldnn/primitives/reorder.hpp" +#include "cldnn/primitives/fully_connected.hpp" +#include "cldnn/primitives/lstm.hpp" +#include "cldnn/primitives/crop.hpp" +#include "cldnn/primitives/concatenation.hpp" namespace CLDNNPlugin { cldnn::activation_func GetActivationFunc(std::string name) { diff --git a/inference-engine/src/cldnn_engine/ops/roi_pooling.cpp b/inference-engine/src/cldnn_engine/ops/roi_pooling.cpp index 8dc57e3a5c63ff..f2087756405404 100644 --- a/inference-engine/src/cldnn_engine/ops/roi_pooling.cpp +++ b/inference-engine/src/cldnn_engine/ops/roi_pooling.cpp @@ -9,7 +9,7 @@ #include "ngraph/op/psroi_pooling.hpp" #include "ngraph/op/deformable_psroi_pooling.hpp" -#include "api/roi_pooling.hpp" +#include "cldnn/primitives/roi_pooling.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/scatter_elements_update.cpp b/inference-engine/src/cldnn_engine/ops/scatter_elements_update.cpp index 98c22e2a19966e..19f63dbf3a3986 100644 --- a/inference-engine/src/cldnn_engine/ops/scatter_elements_update.cpp +++ b/inference-engine/src/cldnn_engine/ops/scatter_elements_update.cpp @@ -8,7 +8,7 @@ #include "ngraph/op/scatter_elements_update.hpp" #include "ngraph/op/constant.hpp" -#include "api/scatter_elements_update.hpp" +#include "cldnn/primitives/scatter_elements_update.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/scatter_nd_update.cpp b/inference-engine/src/cldnn_engine/ops/scatter_nd_update.cpp index 1b422736575054..cf5d059772a245 100644 --- a/inference-engine/src/cldnn_engine/ops/scatter_nd_update.cpp +++ b/inference-engine/src/cldnn_engine/ops/scatter_nd_update.cpp @@ -8,7 +8,7 @@ #include "ngraph/op/scatter_nd_update.hpp" #include "ngraph/op/constant.hpp" -#include "api/scatter_nd_update.hpp" +#include "cldnn/primitives/scatter_nd_update.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/scatter_update.cpp b/inference-engine/src/cldnn_engine/ops/scatter_update.cpp index 85388032de8690..c6fb4e9c0aa003 100644 --- a/inference-engine/src/cldnn_engine/ops/scatter_update.cpp +++ b/inference-engine/src/cldnn_engine/ops/scatter_update.cpp @@ -8,7 +8,7 @@ #include "ngraph/op/scatter_update.hpp" #include "ngraph/op/constant.hpp" -#include "api/scatter_update.hpp" +#include "cldnn/primitives/scatter_update.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/select.cpp b/inference-engine/src/cldnn_engine/ops/select.cpp index 0d3ae8e182c901..6b3866ac5dbaa9 100644 --- a/inference-engine/src/cldnn_engine/ops/select.cpp +++ b/inference-engine/src/cldnn_engine/ops/select.cpp @@ -7,9 +7,9 @@ #include "ngraph/op/select.hpp" -#include "api/select.hpp" -#include "api/reorder.hpp" -#include "api/reshape.hpp" +#include "cldnn/primitives/select.hpp" +#include "cldnn/primitives/reorder.hpp" +#include "cldnn/primitives/reshape.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/shuffle_channels.cpp b/inference-engine/src/cldnn_engine/ops/shuffle_channels.cpp index 0c0cafd03ef633..f3066ace26acc4 100644 --- a/inference-engine/src/cldnn_engine/ops/shuffle_channels.cpp +++ b/inference-engine/src/cldnn_engine/ops/shuffle_channels.cpp @@ -7,7 +7,7 @@ #include "ngraph/op/shuffle_channels.hpp" -#include "api/shuffle_channels.hpp" +#include "cldnn/primitives/shuffle_channels.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/softmax.cpp b/inference-engine/src/cldnn_engine/ops/softmax.cpp index 566aca800ea398..cbaffc04accd49 100644 --- a/inference-engine/src/cldnn_engine/ops/softmax.cpp +++ b/inference-engine/src/cldnn_engine/ops/softmax.cpp @@ -8,8 +8,8 @@ #include "ngraph/op/softmax.hpp" #include "ngraph/op/log_softmax.hpp" -#include "api/softmax.hpp" -#include "api/activation.hpp" +#include "cldnn/primitives/softmax.hpp" +#include "cldnn/primitives/activation.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/space_to_batch.cpp b/inference-engine/src/cldnn_engine/ops/space_to_batch.cpp index 7846375dff700c..fa57d178038882 100644 --- a/inference-engine/src/cldnn_engine/ops/space_to_batch.cpp +++ b/inference-engine/src/cldnn_engine/ops/space_to_batch.cpp @@ -8,7 +8,7 @@ #include "ngraph/op/space_to_batch.hpp" #include "ngraph/op/constant.hpp" -#include "api/space_to_batch.hpp" +#include "cldnn/primitives/space_to_batch.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/space_to_depth.cpp b/inference-engine/src/cldnn_engine/ops/space_to_depth.cpp index a8d73eea79d545..df4a25b469811a 100644 --- a/inference-engine/src/cldnn_engine/ops/space_to_depth.cpp +++ b/inference-engine/src/cldnn_engine/ops/space_to_depth.cpp @@ -7,7 +7,7 @@ #include "ngraph/op/space_to_depth.hpp" -#include "api/space_to_depth.hpp" +#include "cldnn/primitives/space_to_depth.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/split.cpp b/inference-engine/src/cldnn_engine/ops/split.cpp index 6706ccebd8b88c..33b48c6d17fb2a 100644 --- a/inference-engine/src/cldnn_engine/ops/split.cpp +++ b/inference-engine/src/cldnn_engine/ops/split.cpp @@ -8,7 +8,7 @@ #include "ngraph/op/split.hpp" #include "ngraph/op/variadic_split.hpp" -#include "api/crop.hpp" +#include "cldnn/primitives/crop.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/strided_slice.cpp b/inference-engine/src/cldnn_engine/ops/strided_slice.cpp index 0bf5adb74e22e4..8c796290a747da 100644 --- a/inference-engine/src/cldnn_engine/ops/strided_slice.cpp +++ b/inference-engine/src/cldnn_engine/ops/strided_slice.cpp @@ -8,9 +8,9 @@ #include "ngraph/op/strided_slice.hpp" #include "ngraph/op/constant.hpp" -#include "api/strided_slice.hpp" -#include "api/reshape.hpp" -#include "api/crop.hpp" +#include "cldnn/primitives/strided_slice.hpp" +#include "cldnn/primitives/reshape.hpp" +#include "cldnn/primitives/crop.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/tensor_iterator.cpp b/inference-engine/src/cldnn_engine/ops/tensor_iterator.cpp index e4e78208c0297e..d9843481979f23 100644 --- a/inference-engine/src/cldnn_engine/ops/tensor_iterator.cpp +++ b/inference-engine/src/cldnn_engine/ops/tensor_iterator.cpp @@ -13,11 +13,11 @@ #include "ngraph/op/constant.hpp" #include "ngraph/op/util/sub_graph_base.hpp" -#include "api/loop.hpp" -#include "api/mutable_data.hpp" -#include "api/data.hpp" -#include "api/reorder.hpp" -#include "api/topology.hpp" +#include "cldnn/primitives/loop.hpp" +#include "cldnn/primitives/mutable_data.hpp" +#include "cldnn/primitives/data.hpp" +#include "cldnn/primitives/reorder.hpp" +#include "cldnn/graph/topology.hpp" #include #include @@ -28,9 +28,8 @@ namespace CLDNNPlugin { template static DATA_TYPE CreateScalarData(Program &p, const cldnn::primitive_id& id, int64_t num) { - auto mem = cldnn::memory::allocate(p.GetEngine(), - { cldnn::data_types::i64, cldnn::format::bfyx, { 1, 1, 1, 1 } }); - auto ptr = mem.pointer(); + auto mem = p.GetEngine().allocate_memory({ cldnn::data_types::i64, cldnn::format::bfyx, { 1, 1, 1, 1 } }); + cldnn::mem_lock ptr{mem, p.GetEngine().get_program_stream()}; *ptr.begin() = num; return {id, mem}; } @@ -42,7 +41,7 @@ static cldnn::mutable_data CreateAdditionalOutputData(Program &p, const std::sha const auto format = DefaultFormatForDims(op->get_output_shape(output_idx).size()); const auto tensor = CldnnTensorFromIEDims(op->get_output_shape(output_idx)); cldnn::layout output_layout = cldnn::layout(precision, format, tensor); - auto mem = cldnn::memory::allocate(p.GetEngine(), output_layout); + auto mem = p.GetEngine().allocate_memory(output_layout); auto md = cldnn::mutable_data(id, {input}, mem); // cldnn::data cannot set dependency return md; } diff --git a/inference-engine/src/cldnn_engine/ops/tile.cpp b/inference-engine/src/cldnn_engine/ops/tile.cpp index a4856ad80dc210..aa91fbd3d5a410 100644 --- a/inference-engine/src/cldnn_engine/ops/tile.cpp +++ b/inference-engine/src/cldnn_engine/ops/tile.cpp @@ -7,7 +7,7 @@ #include "ngraph/op/tile.hpp" -#include "api/tile.hpp" +#include "cldnn/primitives/tile.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/topk.cpp b/inference-engine/src/cldnn_engine/ops/topk.cpp index d527aee1d61b6e..3d8f7e6521a112 100644 --- a/inference-engine/src/cldnn_engine/ops/topk.cpp +++ b/inference-engine/src/cldnn_engine/ops/topk.cpp @@ -7,8 +7,8 @@ #include "ngraph/op/topk.hpp" -#include "api/arg_max_min.hpp" -#include "api/mutable_data.hpp" +#include "cldnn/primitives/arg_max_min.hpp" +#include "cldnn/primitives/mutable_data.hpp" namespace CLDNNPlugin { @@ -71,7 +71,7 @@ void CreateTopKOp(Program& p, const std::shared_ptr& op) { DefaultFormatForDims(op->get_output_shape(1).size()), CldnnTensorFromIEDims(op->get_output_shape(1))); - auto shared_memory = cldnn::memory::allocate(p.GetEngine(), mutableLayout); + auto shared_memory = p.GetEngine().allocate_memory(mutableLayout); cldnn::primitive_id argmax_mutable_id_w = layer_type_name_ID(op) + "_md_write"; auto argmax_mutable_prim = cldnn::mutable_data(argmax_mutable_id_w, shared_memory); diff --git a/inference-engine/src/cldnn_engine/ops/transpose.cpp b/inference-engine/src/cldnn_engine/ops/transpose.cpp index a1c8ce63caef6f..f5de62923a2c3b 100644 --- a/inference-engine/src/cldnn_engine/ops/transpose.cpp +++ b/inference-engine/src/cldnn_engine/ops/transpose.cpp @@ -8,7 +8,7 @@ #include "ngraph/op/transpose.hpp" #include "ngraph/op/constant.hpp" -#include "api/permute.hpp" +#include "cldnn/primitives/permute.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/src/cldnn_engine/ops/unary.cpp b/inference-engine/src/cldnn_engine/ops/unary.cpp index 334d68c5f2379f..9a277a8be2aa04 100644 --- a/inference-engine/src/cldnn_engine/ops/unary.cpp +++ b/inference-engine/src/cldnn_engine/ops/unary.cpp @@ -41,7 +41,7 @@ #include "ngraph/op/hsigmoid.hpp" #include "ngraph/op/round.hpp" -#include "api/activation.hpp" +#include "cldnn/primitives/activation.hpp" namespace CLDNNPlugin { diff --git a/inference-engine/tests/functional/plugin/gpu/CMakeLists.txt b/inference-engine/tests/functional/plugin/gpu/CMakeLists.txt index d96dd234c1fdf2..f175b4c1a1f5e3 100644 --- a/inference-engine/tests/functional/plugin/gpu/CMakeLists.txt +++ b/inference-engine/tests/functional/plugin/gpu/CMakeLists.txt @@ -17,7 +17,7 @@ addIeTargetTest( AutoPlugin LINK_LIBRARIES funcSharedTests - ${CLDNN__OCL_ICD_LIBPATH} + ${OpenCL_LIBRARY} ADD_CPPLINT LABELS GPU diff --git a/inference-engine/thirdparty/clDNN/CMakeLists.txt b/inference-engine/thirdparty/clDNN/CMakeLists.txt index d14da47860cbeb..41833b58dc58f2 100644 --- a/inference-engine/thirdparty/clDNN/CMakeLists.txt +++ b/inference-engine/thirdparty/clDNN/CMakeLists.txt @@ -83,6 +83,9 @@ set(CLDNN__API_EXTENSION_DIR "${CMAKE_CURRENT_SOURCE_DIR}/api_extension") # Path which points to directory with interface for framework. set(CLDNN__KERNEL_SELECTOR_DIR "${CMAKE_CURRENT_SOURCE_DIR}/kernel_selector") +# Path which points to directory with runtime +set(CLDNN__RUNTIME_DIR "${CMAKE_CURRENT_SOURCE_DIR}/runtime") + # Path which points to directory with binaries for Khronos OpenCL ICD Loader (Installable Client Driver). set(CLDNN__OCL_ICD_DIR "${CLDNN__COMMON_DIR}/khronos_ocl_icd") @@ -270,12 +273,6 @@ mark_as_advanced(CLDNN__INCLUDE_TESTS) # ====================================================================================================== -# Include and build: Core Internal Tests (unit tests and small acceptance tests) for core internal clDNN framework mechanisms. -set(CLDNN__INCLUDE_CORE_INTERNAL_TESTS ON CACHE BOOL "Include and build: clDNN framework's core internal tests.") -mark_as_advanced(CLDNN__INCLUDE_CORE_INTERNAL_TESTS) - -# ====================================================================================================== - # Include and build: clDNN tutorial. set(CLDNN__INCLUDE_TUTORIAL ON CACHE BOOL "Include and build: clDNN Tutorial.") @@ -289,12 +286,6 @@ mark_as_advanced(CLDNN__RUN_TESTS) # ====================================================================================================== -# Run (requires CLDNN__INCLUDE_CORE_INTERNAL_TESTS to be true): Tests (unit tests and small acceptance core internal tests) for clDNN framework. -set(CLDNN__RUN_CORE_INTERNAL_TESTS OFF CACHE BOOL "Run: clDNN framework's core internal tests.") -mark_as_advanced(CLDNN__RUN_CORE_INTERNAL_TESTS) - -# ====================================================================================================== - # Compile / Link: Use static C++ Runtime library. set(CLDNN__COMPILE_LINK_USE_STATIC_RUNTIME OFF CACHE BOOL "Compile / Link: Use static version of C++ Runtime library instead of shared one.") mark_as_advanced(CLDNN__COMPILE_LINK_USE_STATIC_RUNTIME) @@ -330,14 +321,6 @@ endif() # ====================================================================================================== -# Checking whether tests can be run. -if((NOT CLDNN__INCLUDE_CORE_INTERNAL_TESTS) AND CLDNN__RUN_CORE_INTERNAL_TESTS) - message(WARNING "[clDNN] CLDNN__INCLUDE_CORE_INTERNAL_TESTS: Selected running of core internal tests, but test are not built. Option will be disabled.") - set(CLDNN__RUN_CORE_INTERNAL_TESTS OFF) -endif() - -# ====================================================================================================== - # Check for python 3 interpreter (required tool). find_package(PythonInterp 3 QUIET) if(NOT PYTHONINTERP_FOUND) @@ -375,19 +358,26 @@ set(CLDNN__OCL_ICD_ROOT "${CLDNN__OCL_ICD_DIR}" CACHE INTERNAL "Path to Khronos set(CLDNN__OCL_ICD_INCDIRS "${CLDNN__KHR_CLHPP_DIR}" CACHE INTERNAL "Paths to interface headers for OpenCL.") set(CLDNN__OCL_ICD_STLDIRS "${CLDNN__OCL_ICD_ROOT}/${__CLDNN_TargetOs}/${CLDNN__TARGET_CFG_VAR}/lib/${__CLDNN_TargetCpuDir}" CACHE INTERNAL "Paths to static libraries for OpenCL ICD Loader.") set(CLDNN__OCL_ICD_SHLDIRS "${CLDNN__OCL_ICD_ROOT}/${__CLDNN_TargetOs}/${CLDNN__TARGET_CFG_VAR}/bin/${__CLDNN_TargetCpuDir}" CACHE INTERNAL "Paths to shared libraries for OpenCL ICD Loader.") +include_directories(SYSTEM "${CLDNN__KHR_CLHPP_DIR}") # Select link directory based on targeted OS. # - on Windows: static libraries directory. # - on others: shared libraries directory. if(__CLDNN_TargetOs MATCHES "^windows$") - set(CLDNN__OCL_ICD_LIBDIRS ${CLDNN__OCL_ICD_STLDIRS} CACHE INTERNAL "Paths to libraries to link for OpenCL ICD Loader.") - set(CLDNN__OCL_ICD_LIBPATH ${CLDNN__OCL_ICD_LIBDIRS}/${CMAKE_STATIC_LIBRARY_PREFIX}OpenCL${CMAKE_STATIC_LIBRARY_SUFFIX} CACHE INTERNAL "") +set(CLDNN__OCL_ICD_LIBDIRS ${CLDNN__OCL_ICD_STLDIRS} CACHE INTERNAL "Paths to libraries to link for OpenCL ICD Loader.") +set(CLDNN__OCL_ICD_LIBPATH ${CLDNN__OCL_ICD_LIBDIRS}/${CMAKE_STATIC_LIBRARY_PREFIX}OpenCL${CMAKE_STATIC_LIBRARY_SUFFIX} CACHE INTERNAL "") else() - set(CLDNN__OCL_ICD_LIBDIRS ${CLDNN__OCL_ICD_SHLDIRS} CACHE INTERNAL "Paths to libraries to link for OpenCL ICD Loader.") - set(CLDNN__OCL_ICD_LIBPATH ${CLDNN__OCL_ICD_LIBDIRS}/${CMAKE_SHARED_LIBRARY_PREFIX}OpenCL${CMAKE_SHARED_LIBRARY_SUFFIX} CACHE INTERNAL "") +set(CLDNN__OCL_ICD_LIBDIRS ${CLDNN__OCL_ICD_SHLDIRS} CACHE INTERNAL "Paths to libraries to link for OpenCL ICD Loader.") +set(CLDNN__OCL_ICD_LIBPATH ${CLDNN__OCL_ICD_LIBDIRS}/${CMAKE_SHARED_LIBRARY_PREFIX}OpenCL${CMAKE_SHARED_LIBRARY_SUFFIX} CACHE INTERNAL "") endif() - +set(OpenCL_LIBRARY "${CLDNN__OCL_ICD_LIBPATH}" CACHE INTERNAL "Paths to shared libraries for OpenCL ICD Loader.") +set(OpenCL_INCLUDE_DIR "${CLDNN__OCL_ICD_INCDIRS}" CACHE INTERNAL "Paths to interface headers for OpenCL.") +add_library(clDNN_OpenCL UNKNOWN IMPORTED) +set_target_properties(clDNN_OpenCL + PROPERTIES + IMPORTED_LOCATION ${CLDNN__OCL_ICD_LIBPATH} + ) # ====================================================================================================== set(CLDNN_UTILS__RAPIDJSON_INCDIRS "utils/rapidjson" CACHE INTERNAL "Paths to interface headers for rapidjson.") # ====================================== Version Calculation =========================================== @@ -414,11 +404,9 @@ message(STATUS "[clDNN]") message(STATUS "[clDNN] - Include/Build cldnn core: ${CLDNN__INCLUDE_CORE}") message(STATUS "[clDNN] - Include/Build kernel selector: ${CLDNN__INCLUDE_KERNEL_SELECTOR}") message(STATUS "[clDNN] - Include/Build tests: ${CLDNN__INCLUDE_TESTS}") -message(STATUS "[clDNN] - Include/Build core internal tests: ${CLDNN__INCLUDE_CORE_INTERNAL_TESTS}") message(STATUS "[clDNN] - Include/Build tutorial: ${CLDNN__INCLUDE_TUTORIAL}") message(STATUS "[clDNN]") message(STATUS "[clDNN] - Run tests: ${CLDNN__RUN_TESTS}") -message(STATUS "[clDNN] - Run core internal tests: ${CLDNN__RUN_CORE_INTERNAL_TESTS}") message(STATUS "[clDNN]") message(STATUS "[clDNN] - Use static C++ Runtime: ${CLDNN__COMPILE_LINK_USE_STATIC_RUNTIME}") message(STATUS "[clDNN] - Allow unsafe size opts: ${CLDNN__COMPILE_LINK_ALLOW_UNSAFE_SIZE_OPT}") @@ -781,30 +769,18 @@ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS include_directories( ${CLDNN_UTILS__RAPIDJSON_INCDIRS} "${CLDNN__CODEGEN_INCDIR}" + "${CLDNN__API_DIR}" ) -include_directories(SYSTEM - "${CLDNN__KHR_CLHPP_DIR}" - ) - -add_library(clDNN_OpenCL UNKNOWN IMPORTED) -set_target_properties(clDNN_OpenCL - PROPERTIES - IMPORTED_LOCATION ${CLDNN__OCL_ICD_LIBPATH} - ) - - # =================================== Link targets and dependencies ==================================== if(CLDNN__INCLUDE_CORE) add_subdirectory(src) + add_subdirectory(runtime) add_subdirectory(api_test_builds) endif() if(CLDNN__INCLUDE_TESTS) add_subdirectory(tests) endif() -if(CLDNN__INCLUDE_CORE_INTERNAL_TESTS) - add_subdirectory(tests_core_internal) -endif() if(CLDNN__INCLUDE_KERNEL_SELECTOR) add_subdirectory(kernel_selector) endif() diff --git a/inference-engine/thirdparty/clDNN/api/cldnn.hpp b/inference-engine/thirdparty/clDNN/api/cldnn.hpp deleted file mode 100644 index 4b531ab050bb45..00000000000000 --- a/inference-engine/thirdparty/clDNN/api/cldnn.hpp +++ /dev/null @@ -1,244 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/*! @mainpage clDNN Documentation -* @section intro Introduction -* Compute Library for Deep Neural Networks (clDNN) is a middle-ware software -* for accelerating DNN inference on Intel® HD and Iris™ Pro Graphics. -* This project includes CNN primitives implementations on Intel GPUs with C and C++ interfaces. -* -* clDNN Library implements set of primitives: -* - Convolution -* - Fully connected (inner product) -* - Pooling -* * average -* * maximum -* - Normalization -* * across channel -* * within channel -* * batch -* - Activation -* * logistic -* * tanh -* * rectified linear unit (ReLU) -* * softplus (softReLU) -* * abs -* * square -* * sqrt -* * linear -* - Softmax -* - Crop -* - Deconvolution -* - Depth concatenation -* - Eltwise -* - ROI pooling -* - Simpler NMS -* - Prior box -* - Detection output -* -* With this primitive set, user can build and execute most common image recognition, semantic segmentation and object detection networks topologies like: -* - Alexnet -* - Googlenet(v1-v3) -* - ResNet -* - VGG -* - faster-rCNN -* and other. -* -* -* @section model Programming Model -* Intel® clDNN is graph oriented library. To execute CNN you have to build, compile graph/topology and run to get results. -* -* Terminology: -* - Primitive - dnn base functionality i.e. convolution, pooling, softmax. -* - Data - special primitive type representing primitive parameters (weights and biases), inputs and outputs -* - Engine - type of accelerator that is executing network. Currently ocl engine is the only available. -* - Topology - container of primitives, data, and relations between them. Topology represents graph. -* - Program - optional step between Topology and Network. It is compiled Topology without memory allocation. -* - Network - compiled Topology with memory allocation. Ready to be executed. During compilation, buidling parameters trigger special optimizations like fusing, data reordering. -* -* Execution Steps: -* -* \image html workflow.jpg -* -# Create Engine -* -# Declare or define primitives parameters (weights and biases) if needed. -* -# Create primitives. It is required to provide name for each primitive. This is a name of primitive which output will be input to current one. Name can be used before primitive definition. -* -# Create topology -* -# Add primitives to topology -* -# Build Network from topology -* -# Set Inputs data -* -# Execute Network -* -* -* @section graph_compilation Graph compilation -* -* If user choose build option optimize_data when program is being created - explicit or implicit over network creation, clDNN perform some graph optimizations as follows: -* * Stage 0: Graph initiation: -* * build nodes from primitives -* * node replacement: -* * replace each split node with series of crop nodes. Name of crop primitive will be concatenation of split + port names. -* * replace upsampling node with deconvolution node if upsampling mode is bilinear. -* * set outputs - mark nodes that are defined by user as output (blocks fusing etc) or have no users (leafs). -* * calculate processing order - using dfs on graph to establish processing order -* * Stage 1: Priorboxes: -* * priorbox is primitive that is executed during network compilation. Node is removed from a network execution. -* * Stage 2: Graph analysis: -* * mark constatns -* * mark data flow -* * Stage 3: Trimming: -* * apply backward bfs on each output to find unnecessary nodes/branches, then remove those. -* * Stage 4: Inputs and biases: -* * reorder input - format of convolution's input/output is being selected. -* * reorder biases for conv,fc and deconv nodes -* * Stage 5: Redundant reorders: -* * previous stages can provide additional reorders due to format changes per primitive. This stage removes redundant and fuses series of reorders into one. -* * Stage 6: Constant propagation: -* * prepare padding - goes thrugh all primitves and checks if its user requires padding, if so, set output padding. -* * prepare depthwise separable opt - if split param is greater than 16 and number of IFM <= 8*split in conv or deconv, this stage changes execution from multi kernels into one. -* * constant propagation - replace constant nodes, that are not outputs with data type nodes. Constant primitive is the primitive that doesn't depend on any non-constant primitive and doesn't have to be executed: priorbox, data. -* * Stage 7: Fusing: -* * buffer fusing -* * concat - if concatenation is the only user of its dependencies then remove concat node and setting proper output paddings in every dependencies. -* * crop - if crop has only one dependecy, and its users doesn't require padding, remove crop and set proper output padding in its dependecy. -* * reorder - if primitive before reorder supports different input vs output type reorder can be fused with previous node. -* * primitive fusing - right now this stage fuses activation node with previous node only, only if previous node supports activation fusing. -* * Stage 8: Compile graph: -* * at this stage using kernel selector, graph chooses the best kernel implementation for each node. -* * Stage 9: reorder weights: -* * at this stage weights are converted into format suitable for selected kernel implementation. -* * Stage 10 & 11: Redundant reorders and constant propagation: -* * check again if whole graph compilation didn't provide any redundant reorders and constants. -* * Stage 12: Compile program: -* * at this stage engine compiles cl_kernels. -* -* @section example C++ API Example MNIST network -* @include example_cldnn.cpp -*/ - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma once - -#include -#include -#include -#include -#include -#include - -namespace cldnn { - -/// @addtogroup cpp_api C++ API -/// @{ - -float half_to_float(uint16_t value); -uint16_t float_to_half(float value); - -// There is no portable half precision floating point support. -// Using wrapped integral type with the same size and alignment restrictions. -class half_impl { -public: - half_impl() = default; - - template ::value>::type> - explicit half_impl(T data, int /*direct_creation_tag*/) : _data(data) {} - - operator uint16_t() const { return _data; } - operator float() const { - return half_to_float(_data); - } - - explicit half_impl(float value) - : _data(float_to_half(value)) - {} - - template ::value>::type> - explicit half_impl(T value) - : half_impl(static_cast(value)) - {} - -private: - uint16_t _data; -}; - -// Use complete implementation if necessary. -#if defined HALF_HALF_HPP -using half_t = half; -#else -using half_t = half_impl; -#endif - -/// @cond CPP_HELPERS - -/// @defgroup cpp_helpers Helpers -/// @{ - -#define CLDNN_API_CLASS(the_class) static_assert(std::is_standard_layout::value, #the_class " has to be 'standard layout' class"); - -template -typename std::enable_if::value, T>::type align_to(T size, size_t align) { - return static_cast((size % align == 0) ? size : size - size % align + align); -} - -template -typename std::enable_if::value, T>::type pad_to(T size, size_t align) { - return static_cast((size % align == 0) ? 0 : align - size % align); -} - -template -typename std::enable_if::value, bool>::type is_aligned_to(T size, size_t align) { - return !(size % align); -} - -/// Computes ceil(@p val / @p divider) on unsigned integral numbers. -/// -/// Computes division of unsigned integral numbers and rounds result up to full number (ceiling). -/// The function works for unsigned integrals only. Signed integrals are converted to corresponding -/// unsigned ones. -/// -/// @tparam T1 Type of @p val. Type must be integral (SFINAE). -/// @tparam T2 Type of @p divider. Type must be integral (SFINAE). -/// -/// @param val Divided value. If value is signed, it will be converted to corresponding unsigned type. -/// @param divider Divider value. If value is signed, it will be converted to corresponding unsigned type. -/// -/// @return Result of ceil(@p val / @p divider). The type of result is determined as if in normal integral -/// division, except each operand is converted to unsigned type if necessary. -template -constexpr auto ceil_div(T1 val, T2 divider) --> typename std::enable_if::value && std::is_integral::value, - decltype(std::declval::type>() / std::declval::type>())>::type { - typedef typename std::make_unsigned::type UT1; - typedef typename std::make_unsigned::type UT2; - typedef decltype(std::declval() / std::declval()) RetT; - - return static_cast((static_cast(val) + static_cast(divider) - 1U) / static_cast(divider)); -} - -/// Rounds @p val to nearest multiply of @p rounding that is greater or equal to @p val. -/// -/// The function works for unsigned integrals only. Signed integrals are converted to corresponding -/// unsigned ones. -/// -/// @tparam T1 Type of @p val. Type must be integral (SFINAE). -/// @tparam T2 Type of @p rounding. Type must be integral (SFINAE). -/// -/// @param val Value to round up. If value is signed, it will be converted to corresponding unsigned type. -/// @param rounding Rounding value. If value is signed, it will be converted to corresponding unsigned type. -/// -/// @return @p val rounded up to nearest multiply of @p rounding. The type of result is determined as if in normal integral -/// division, except each operand is converted to unsigned type if necessary. -template -constexpr auto round_up_to(T1 val, T2 rounding) --> typename std::enable_if::value && std::is_integral::value, - decltype(std::declval::type>() / std::declval::type>())>::type { - typedef typename std::make_unsigned::type UT1; - typedef typename std::make_unsigned::type UT2; - typedef decltype(std::declval() / std::declval()) RetT; - - return static_cast(ceil_div(val, rounding) * static_cast(rounding)); -} - -/// @} -/// @endcond -/// @} -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/api/network.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/graph/network.hpp similarity index 79% rename from inference-engine/thirdparty/clDNN/api/network.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/graph/network.hpp index ee089e7e42f4d1..a6829259d79aba 100644 --- a/inference-engine/thirdparty/clDNN/api/network.hpp +++ b/inference-engine/thirdparty/clDNN/api/cldnn/graph/network.hpp @@ -3,12 +3,14 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// + #pragma once -#include "cldnn.hpp" -#include "compounds.h" -#include "memory.hpp" + +#include "cldnn/runtime/compounds.hpp" +#include "cldnn/runtime/memory.hpp" +#include "cldnn/runtime/event.hpp" +#include "cldnn/runtime/stream.hpp" #include "program.hpp" -#include "event.hpp" #include #include @@ -28,18 +30,25 @@ namespace cldnn { /// @brief Represents network output returned by @ref network::get_output(). struct network_output { /// @brief Returns @ref event associated with the output. - event get_event() const { return _event; } + event::ptr get_event() const { return _event; } /// @brief Returns @ref memory object of the output. Blocked until associated @ref event is not complete. - memory get_memory() const { - _event.wait(); + memory::ptr get_memory() const { + // TODO: in_order queue doesn't create proper output event in some cases which leads to syncronization issues with user app + // So call finish for associated stream to enusre that the output data is ready. + if (_stream.get_queue_type() == queue_types::in_order) { + _stream.finish(); + } else { + _event->wait(); + } return _result; } private: - event _event; - memory _result; - network_output(event evt, memory mem) : _event(evt), _result(mem) {} + event::ptr _event; + memory::ptr _result; + stream& _stream; + network_output(event::ptr evt, memory::ptr mem, stream& stream) : _event(evt), _result(mem), _stream(stream) {} friend struct network; }; @@ -58,52 +67,49 @@ struct network { /// @param topology /// @param options /// @param options - network(const engine& engine, + network(engine& engine, const topology& topology, const build_options& options = build_options(), uint16_t stream_id = 0) : network(program(engine, topology, options), stream_id) {} /// @brief Constructs network object from C API @ref cldnn_network. - explicit network(network_impl* impl) : _impl(impl) { + explicit network(std::shared_ptr impl) : _impl(impl) { if (_impl == nullptr) throw std::invalid_argument("implementation pointer should not be null"); } /// @brief Copy construction. - network(const network& other) : _impl(other._impl) { retain(); } + network(const network& other) : _impl(other._impl) { } /// @brief Copy assignment. network& operator=(const network& other) { if (_impl == other._impl) return *this; - release(); _impl = other._impl; - retain(); return *this; } - /// @brief Releases wrapped C API @ref cldnn_network. - ~network() { release(); } - friend bool operator==(const network& lhs, const network& rhs) { return lhs._impl == rhs._impl; } friend bool operator!=(const network& lhs, const network& rhs) { return !(lhs == rhs); } /// @brief Returns @ref engine by which network was built. - engine get_engine() const; + engine& get_engine() const; /// @brief Returns network internal @ref program. program get_program() const; /// @brief Provides @ref memory for @ref input_layout primitives defined by user in source @ref topology. - void set_input_data(const primitive_id& id, const memory& mem) const; + void set_input_data(const primitive_id& id, memory::ptr mem) const; /// @brief Provides user-supplied @ref memory for output primitives defined by user in source @ref topology. - void set_output_memory(const primitive_id& id, const memory& mem) const; + void set_output_memory(const primitive_id& id, memory::ptr mem) const; /// @brief Return stream id. uint16_t get_stream_id(); + stream& get_stream() const; + /// @brief Return internal network id. uint32_t get_id(); @@ -131,18 +137,18 @@ struct network { std::vector get_output_ids() const; /// @brief Returns @ref memory object for particular @p output. Can be called before network execution - memory get_output_memory(const primitive_id& output_id) const; + memory::ptr get_output_memory(const primitive_id& output_id) const; /// @brief Returns @ref event object for particular @p primitive. Can't be called before network execution - event get_primitive_event(const primitive_id& output_id) const; + event::ptr get_primitive_event(const primitive_id& output_id) const; /// @brief Returns @ref network_output object for particular @p output. Can't be called before network execution network_output get_output(const primitive_id& output_id) const { - return network_output(get_primitive_event(output_id), get_output_memory(output_id)); + return network_output(get_primitive_event(output_id), get_output_memory(output_id), get_stream()); } /// @brief Returns the list of @ref event for the primitives that were executed in network. - std::map get_executed_primitives() const { + std::map get_executed_primitives() const { auto primitive_ids = get_executed_primitive_ids(); auto all_primitive_ids = get_all_primitive_ids(); auto all_primitive_org_ids = get_all_primitive_org_ids(); @@ -152,7 +158,7 @@ struct network { if (all_primitive_ids[i] == "_optimized_") optimized_primitives.push_back(all_primitive_org_ids[i]); } - std::map result; + std::map result; for (auto& id : primitive_ids) { if (std::find(optimized_primitives.begin(), optimized_primitives.end(), id) == optimized_primitives.end()) result.emplace(id, get_primitive_event(id)); @@ -177,16 +183,13 @@ struct network { /// @param dependencies List of @ref event objects to be waited before network execution. /// @note User should call set_input_data() for every @ref input_layout defined in source @ref topology /// before network execution. - std::map execute(const std::vector& dependencies = {}) const; + std::map execute(const std::vector& dependencies = {}) const; /// @brief Returns wrapped C API @ref cldnn_network handler. - network_impl* get() const { return _impl; } + network_impl* get() const { return _impl.get(); } private: - network_impl* _impl; - - void retain(); - void release(); + std::shared_ptr _impl; }; CLDNN_API_CLASS(network) /// @} diff --git a/inference-engine/thirdparty/clDNN/api/program.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/graph/program.hpp similarity index 97% rename from inference-engine/thirdparty/clDNN/api/program.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/graph/program.hpp index b50754e1fd07b9..95dfca9fc14bb9 100644 --- a/inference-engine/thirdparty/clDNN/api/program.hpp +++ b/inference-engine/thirdparty/clDNN/api/cldnn/graph/program.hpp @@ -3,11 +3,12 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// + #pragma once -#include "cldnn.hpp" + +#include "cldnn/runtime/engine.hpp" + #include "topology.hpp" -#include "engine.hpp" -#include #include #include @@ -477,21 +478,19 @@ struct program { /// @param[in] engine The engine which will be used to build the program. /// @param[in] topology The user-defined topology on which the network will be based. /// @param[in] options Program build options. See @ref build_option and @ref build_options for details. - program(engine const& engine, topology const& topology, build_options const& options = build_options()); + program(engine& engine, const topology& topology, const build_options& options = build_options()); /// @brief Copy constructor. - program(program const& other) : _impl(other._impl) { retain(); } + program(const program& other) : _impl(other._impl) { } /// @brief Dereferences the counter of the underlying C API @ref cldnn_program handler. - ~program() { release(); } + ~program() { } /// @brief Assigns new value by releasing previously referenced C API @ref cldnn_program handler and retaining the one referenced by @p other. program& operator=(const program& other) { if (_impl == other._impl) return *this; - release(); _impl = other._impl; - retain(); return *this; } @@ -500,19 +499,15 @@ struct program { /// @brief Checks whether @p lhs and @p rhs reference different C API @ref cldnn_program handlers friend bool operator!=(const program& lhs, const program& rhs) { return !(lhs == rhs); } - /// @brief Returns wrapped C API @ref cldnn_program handler. - program_impl* get() const { return _impl; } + std::shared_ptr get() const { return _impl; } private: - program_impl* _impl; + std::shared_ptr _impl; - explicit program(program_impl* impl) : _impl(impl) { + explicit program(std::shared_ptr impl) : _impl(impl) { if (_impl == nullptr) throw std::invalid_argument("implementation pointer should not be null"); } - - void retain(); - void release(); }; /// @} /// @} diff --git a/inference-engine/thirdparty/clDNN/api/topology.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/graph/topology.hpp similarity index 84% rename from inference-engine/thirdparty/clDNN/api/topology.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/graph/topology.hpp index 78e4fc875cf757..4155c7ac529e8b 100644 --- a/inference-engine/thirdparty/clDNN/api/topology.hpp +++ b/inference-engine/thirdparty/clDNN/api/cldnn/graph/topology.hpp @@ -3,11 +3,13 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// + #pragma once + +#include "cldnn/runtime/compounds.hpp" +#include "cldnn/primitives/primitive.hpp" + #include -#include "cldnn.hpp" -#include "compounds.h" -#include "primitive.hpp" #include #include @@ -33,26 +35,24 @@ struct topology { } /// @brief Copy construction. - topology(const topology& other) : _impl(other._impl) { retain(); } + topology(const topology& other) : _impl(other._impl) { } /// @brief Copy assignment. topology& operator=(const topology& other) { if (_impl == other._impl) return *this; - release(); _impl = other._impl; - retain(); return *this; } /// Construct C++ topology based on C API @p cldnn_topology - explicit topology(topology_impl* other) : _impl(other) { + explicit topology(std::shared_ptr other) : _impl(other) { if (_impl == nullptr) throw std::invalid_argument("implementation pointer should not be null"); } /// @brief Releases wrapped C API @ref cldnn_topology. - ~topology() { release(); } + ~topology() { } friend bool operator==(const topology& lhs, const topology& rhs) { return lhs._impl == rhs._impl; } friend bool operator!=(const topology& lhs, const topology& rhs) { return !(lhs == rhs); } @@ -73,7 +73,7 @@ struct topology { } /// @brief Returns wrapped implementation pointer. - topology_impl* get() const { return _impl; } + std::shared_ptr get() const { return _impl; } const std::vector get_primitive_ids() const; @@ -82,12 +82,9 @@ struct topology { const std::shared_ptr& at(const primitive_id& id) const; private: - friend struct engine; + friend class engine; friend struct network; - topology_impl* _impl; - - void retain(); - void release(); + std::shared_ptr _impl; }; CLDNN_API_CLASS(topology) diff --git a/inference-engine/thirdparty/clDNN/api/activation.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/activation.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/activation.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/activation.hpp diff --git a/inference-engine/thirdparty/clDNN/api/arg_max_min.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/arg_max_min.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/arg_max_min.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/arg_max_min.hpp diff --git a/inference-engine/thirdparty/clDNN/api/average_unpooling.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/average_unpooling.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/average_unpooling.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/average_unpooling.hpp diff --git a/inference-engine/thirdparty/clDNN/api/batch_to_space.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/batch_to_space.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/batch_to_space.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/batch_to_space.hpp diff --git a/inference-engine/thirdparty/clDNN/api/binary_convolution.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/binary_convolution.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/binary_convolution.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/binary_convolution.hpp diff --git a/inference-engine/thirdparty/clDNN/api/border.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/border.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/border.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/border.hpp diff --git a/inference-engine/thirdparty/clDNN/api/broadcast.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/broadcast.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/broadcast.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/broadcast.hpp diff --git a/inference-engine/thirdparty/clDNN/api/concatenation.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/concatenation.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/concatenation.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/concatenation.hpp diff --git a/inference-engine/thirdparty/clDNN/api/condition.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/condition.hpp similarity index 98% rename from inference-engine/thirdparty/clDNN/api/condition.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/condition.hpp index 1becbc1aff54f2..aa63586c4a3157 100644 --- a/inference-engine/thirdparty/clDNN/api/condition.hpp +++ b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/condition.hpp @@ -5,7 +5,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once #include "primitive.hpp" -#include "topology.hpp" +#include "cldnn/graph/topology.hpp" #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/api/convolution.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/convolution.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/convolution.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/convolution.hpp diff --git a/inference-engine/thirdparty/clDNN/api/crop.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/crop.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/crop.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/crop.hpp diff --git a/inference-engine/thirdparty/clDNN/api/ctc_greedy_decoder.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/ctc_greedy_decoder.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/ctc_greedy_decoder.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/ctc_greedy_decoder.hpp diff --git a/inference-engine/thirdparty/clDNN/api/cum_sum.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/cum_sum.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/cum_sum.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/cum_sum.hpp diff --git a/inference-engine/thirdparty/clDNN/api/custom_gpu_primitive.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/custom_gpu_primitive.hpp similarity index 98% rename from inference-engine/thirdparty/clDNN/api/custom_gpu_primitive.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/custom_gpu_primitive.hpp index 22b43fedd3c01f..25da079a5de315 100644 --- a/inference-engine/thirdparty/clDNN/api/custom_gpu_primitive.hpp +++ b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/custom_gpu_primitive.hpp @@ -5,7 +5,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once #include "primitive.hpp" -#include "memory.hpp" +#include "cldnn/runtime/memory.hpp" #include #include diff --git a/inference-engine/thirdparty/clDNN/api/data.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/data.hpp similarity index 92% rename from inference-engine/thirdparty/clDNN/api/data.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/data.hpp index 68e43ee1abd773..e7fe1f889fc619 100644 --- a/inference-engine/thirdparty/clDNN/api/data.hpp +++ b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/data.hpp @@ -5,7 +5,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once #include "primitive.hpp" -#include "memory.hpp" +#include "cldnn/runtime/memory.hpp" namespace cldnn { /// @addtogroup cpp_api C++ API @@ -26,12 +26,12 @@ struct data : public primitive_base { /// @param id This primitive id. /// @param mem @ref memory object which contains data. /// @note If memory is attached by memory::attach(), the attached buffer should be valid till network build. - data(const primitive_id& id, const memory& mem) + data(const primitive_id& id, memory::ptr mem) : primitive_base(id, {}, padding()), mem(mem) {} /// @brief @ref memory object which contains data. /// @note If memory is attached by memory::attach(), the attached buffer should be valid till network build. - memory mem; + memory::ptr mem; }; /// @} /// @} diff --git a/inference-engine/thirdparty/clDNN/api/deconvolution.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/deconvolution.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/deconvolution.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/deconvolution.hpp diff --git a/inference-engine/thirdparty/clDNN/api/depth_to_space.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/depth_to_space.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/depth_to_space.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/depth_to_space.hpp diff --git a/inference-engine/thirdparty/clDNN/api/detection_output.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/detection_output.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/detection_output.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/detection_output.hpp diff --git a/inference-engine/thirdparty/clDNN/api/eltwise.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/eltwise.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/eltwise.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/eltwise.hpp diff --git a/inference-engine/thirdparty/clDNN/api/embedding_bag.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/embedding_bag.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/embedding_bag.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/embedding_bag.hpp diff --git a/inference-engine/thirdparty/clDNN/api/extract_image_patches.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/extract_image_patches.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/extract_image_patches.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/extract_image_patches.hpp diff --git a/inference-engine/thirdparty/clDNN/api/fully_connected.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/fully_connected.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/fully_connected.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/fully_connected.hpp diff --git a/inference-engine/thirdparty/clDNN/api_extension/fused_conv_eltwise.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/fused_conv_eltwise.hpp similarity index 98% rename from inference-engine/thirdparty/clDNN/api_extension/fused_conv_eltwise.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/fused_conv_eltwise.hpp index ff1c274fb1c945..6aed6cf6a7568a 100644 --- a/inference-engine/thirdparty/clDNN/api_extension/fused_conv_eltwise.hpp +++ b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/fused_conv_eltwise.hpp @@ -4,8 +4,8 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/primitive.hpp" -#include "api/eltwise.hpp" +#include "cldnn/primitives/primitive.hpp" +#include "cldnn/primitives/eltwise.hpp" #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/api/gather.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/gather.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/gather.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/gather.hpp diff --git a/inference-engine/thirdparty/clDNN/api/gather_nd.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/gather_nd.hpp similarity index 63% rename from inference-engine/thirdparty/clDNN/api/gather_nd.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/gather_nd.hpp index ebf3953cf7fd65..885f7297510f11 100644 --- a/inference-engine/thirdparty/clDNN/api/gather_nd.hpp +++ b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/gather_nd.hpp @@ -1,20 +1,7 @@ -/* -// Copyright (c) 2021 Intel Corporation +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -*/ -/////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once #include "primitive.hpp" diff --git a/inference-engine/thirdparty/clDNN/api/gather_tree.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/gather_tree.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/gather_tree.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/gather_tree.hpp diff --git a/inference-engine/thirdparty/clDNN/api/gemm.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/gemm.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/gemm.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/gemm.hpp diff --git a/inference-engine/thirdparty/clDNN/api/grn.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/grn.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/grn.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/grn.hpp diff --git a/inference-engine/thirdparty/clDNN/api/input_layout.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/input_layout.hpp similarity index 97% rename from inference-engine/thirdparty/clDNN/api/input_layout.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/input_layout.hpp index 61cc5544e7acb6..c6be1bf5b39de6 100644 --- a/inference-engine/thirdparty/clDNN/api/input_layout.hpp +++ b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/input_layout.hpp @@ -5,7 +5,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once #include "primitive.hpp" -#include "memory.hpp" +#include "cldnn/runtime/memory.hpp" namespace cldnn { /// @addtogroup cpp_api C++ API diff --git a/inference-engine/thirdparty/clDNN/api/loop.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/loop.hpp similarity index 99% rename from inference-engine/thirdparty/clDNN/api/loop.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/loop.hpp index 8268b728e12467..63215f3ad980b5 100644 --- a/inference-engine/thirdparty/clDNN/api/loop.hpp +++ b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/loop.hpp @@ -7,7 +7,7 @@ #include #include #include "primitive.hpp" -#include "topology.hpp" +#include "cldnn/graph/topology.hpp" #define DEFAULT_MAX_NUM_ITERATION 256 namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/api/lrn.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/lrn.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/lrn.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/lrn.hpp diff --git a/inference-engine/thirdparty/clDNN/api/lstm.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/lstm.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/lstm.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/lstm.hpp diff --git a/inference-engine/thirdparty/clDNN/api/lstm_dynamic.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/lstm_dynamic.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/lstm_dynamic.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/lstm_dynamic.hpp diff --git a/inference-engine/thirdparty/clDNN/api_extension/lstm_dynamic_input.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/lstm_dynamic_input.hpp similarity index 98% rename from inference-engine/thirdparty/clDNN/api_extension/lstm_dynamic_input.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/lstm_dynamic_input.hpp index 1a3d0fb7bff92d..3733a989fe68d4 100644 --- a/inference-engine/thirdparty/clDNN/api_extension/lstm_dynamic_input.hpp +++ b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/lstm_dynamic_input.hpp @@ -4,7 +4,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/primitive.hpp" +#include "cldnn/primitives/primitive.hpp" #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/api_extension/lstm_dynamic_timeloop.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/lstm_dynamic_timeloop.hpp similarity index 99% rename from inference-engine/thirdparty/clDNN/api_extension/lstm_dynamic_timeloop.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/lstm_dynamic_timeloop.hpp index 5449c95b01b8d9..c7b77fb1afe064 100644 --- a/inference-engine/thirdparty/clDNN/api_extension/lstm_dynamic_timeloop.hpp +++ b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/lstm_dynamic_timeloop.hpp @@ -4,7 +4,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/primitive.hpp" +#include "cldnn/primitives/primitive.hpp" #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/api/max_unpooling.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/max_unpooling.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/max_unpooling.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/max_unpooling.hpp diff --git a/inference-engine/thirdparty/clDNN/api/mutable_data.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/mutable_data.hpp similarity index 92% rename from inference-engine/thirdparty/clDNN/api/mutable_data.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/mutable_data.hpp index 6a8acc0770a1bc..a5aca1f4392063 100644 --- a/inference-engine/thirdparty/clDNN/api/mutable_data.hpp +++ b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/mutable_data.hpp @@ -5,7 +5,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once #include "primitive.hpp" -#include "memory.hpp" +#include "cldnn/runtime/memory.hpp" #include namespace cldnn { @@ -31,7 +31,7 @@ struct mutable_data : public primitive_base { /// @param mem @ref memory object which contains data. /// @param filler_type @ref data filling function, default is zero /// @note If memory is attached by memory::attach(), the attached buffer should be valid till network build. - mutable_data(const primitive_id& id, const memory& mem, filler_type fill_type = filler_type::no_fill) + mutable_data(const primitive_id& id, memory::ptr mem, filler_type fill_type = filler_type::no_fill) : primitive_base(id, {}, padding()), mem(mem), fill_type(fill_type) {} /// @brief Constructs mutable_data primitive with inputs. @@ -42,13 +42,13 @@ struct mutable_data : public primitive_base { /// @param filler_type @ref data filling function, default is zero mutable_data(const primitive_id& id, const std::vector& input, - const memory& mem, + memory::ptr mem, filler_type fill_type = filler_type::no_fill) : primitive_base(id, {input}, padding()), mem(mem), fill_type(fill_type) {} /// @brief @ref memory object which contains data. /// @note If memory is attached by memory::attach(), the attached buffer should be valid till network build. - memory mem; + memory::ptr mem; /// @brief Specifies function which will be used to fill weights. filler_type fill_type; diff --git a/inference-engine/thirdparty/clDNN/api/mvn.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/mvn.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/mvn.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/mvn.hpp diff --git a/inference-engine/thirdparty/clDNN/api/non_max_suppression.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/non_max_suppression.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/non_max_suppression.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/non_max_suppression.hpp diff --git a/inference-engine/thirdparty/clDNN/api/normalize.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/normalize.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/normalize.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/normalize.hpp diff --git a/inference-engine/thirdparty/clDNN/api/one_hot.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/one_hot.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/one_hot.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/one_hot.hpp diff --git a/inference-engine/thirdparty/clDNN/api/permute.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/permute.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/permute.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/permute.hpp diff --git a/inference-engine/thirdparty/clDNN/api/pooling.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/pooling.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/pooling.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/pooling.hpp diff --git a/inference-engine/thirdparty/clDNN/api/primitive.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/primitive.hpp similarity index 98% rename from inference-engine/thirdparty/clDNN/api/primitive.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/primitive.hpp index 1c8ac408493c0b..856df2e56496af 100644 --- a/inference-engine/thirdparty/clDNN/api/primitive.hpp +++ b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/primitive.hpp @@ -3,11 +3,11 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// + #pragma once -#include "cldnn.hpp" -#include "compounds.h" -#include "layout.hpp" +#include "cldnn/runtime/compounds.hpp" +#include "cldnn/runtime/layout.hpp" #include #include diff --git a/inference-engine/thirdparty/clDNN/api/prior_box.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/prior_box.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/prior_box.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/prior_box.hpp diff --git a/inference-engine/thirdparty/clDNN/api/proposal.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/proposal.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/proposal.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/proposal.hpp diff --git a/inference-engine/thirdparty/clDNN/api/pyramid_roi_align.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/pyramid_roi_align.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/pyramid_roi_align.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/pyramid_roi_align.hpp diff --git a/inference-engine/thirdparty/clDNN/api/quantize.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/quantize.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/quantize.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/quantize.hpp diff --git a/inference-engine/thirdparty/clDNN/api/reduce.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/reduce.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/reduce.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/reduce.hpp diff --git a/inference-engine/thirdparty/clDNN/api/region_yolo.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/region_yolo.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/region_yolo.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/region_yolo.hpp diff --git a/inference-engine/thirdparty/clDNN/api/reorder.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/reorder.hpp similarity index 99% rename from inference-engine/thirdparty/clDNN/api/reorder.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/reorder.hpp index ab597d7de189ca..c980c34f0d4216 100644 --- a/inference-engine/thirdparty/clDNN/api/reorder.hpp +++ b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/reorder.hpp @@ -5,7 +5,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once #include "primitive.hpp" -#include "memory.hpp" +#include "cldnn/runtime/memory.hpp" #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/api/reorg_yolo.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/reorg_yolo.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/reorg_yolo.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/reorg_yolo.hpp diff --git a/inference-engine/thirdparty/clDNN/api/resample.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/resample.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/resample.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/resample.hpp diff --git a/inference-engine/thirdparty/clDNN/api/reshape.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/reshape.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/reshape.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/reshape.hpp diff --git a/inference-engine/thirdparty/clDNN/api/reverse_sequence.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/reverse_sequence.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/reverse_sequence.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/reverse_sequence.hpp diff --git a/inference-engine/thirdparty/clDNN/api/roi_pooling.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/roi_pooling.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/roi_pooling.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/roi_pooling.hpp diff --git a/inference-engine/thirdparty/clDNN/api/scale.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/scale.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/scale.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/scale.hpp diff --git a/inference-engine/thirdparty/clDNN/api/scatter_elements_update.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/scatter_elements_update.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/scatter_elements_update.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/scatter_elements_update.hpp diff --git a/inference-engine/thirdparty/clDNN/api/scatter_nd_update.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/scatter_nd_update.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/scatter_nd_update.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/scatter_nd_update.hpp diff --git a/inference-engine/thirdparty/clDNN/api/scatter_update.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/scatter_update.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/scatter_update.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/scatter_update.hpp diff --git a/inference-engine/thirdparty/clDNN/api/select.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/select.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/select.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/select.hpp diff --git a/inference-engine/thirdparty/clDNN/api/shuffle_channels.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/shuffle_channels.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/shuffle_channels.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/shuffle_channels.hpp diff --git a/inference-engine/thirdparty/clDNN/api/softmax.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/softmax.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/softmax.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/softmax.hpp diff --git a/inference-engine/thirdparty/clDNN/api/space_to_batch.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/space_to_batch.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/space_to_batch.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/space_to_batch.hpp diff --git a/inference-engine/thirdparty/clDNN/api/space_to_depth.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/space_to_depth.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/space_to_depth.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/space_to_depth.hpp diff --git a/inference-engine/thirdparty/clDNN/api/split.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/split.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/split.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/split.hpp diff --git a/inference-engine/thirdparty/clDNN/api/strided_slice.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/strided_slice.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/strided_slice.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/strided_slice.hpp diff --git a/inference-engine/thirdparty/clDNN/api/tile.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/tile.hpp similarity index 100% rename from inference-engine/thirdparty/clDNN/api/tile.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/primitives/tile.hpp diff --git a/inference-engine/thirdparty/clDNN/api/compounds.h b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/compounds.hpp similarity index 98% rename from inference-engine/thirdparty/clDNN/api/compounds.h rename to inference-engine/thirdparty/clDNN/api/cldnn/runtime/compounds.hpp index 45429e584f9b46..ade492705a5c19 100644 --- a/inference-engine/thirdparty/clDNN/api/compounds.h +++ b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/compounds.hpp @@ -4,6 +4,8 @@ #pragma once +#include "utils.hpp" + #include #include #include @@ -11,7 +13,6 @@ #include #include -#include "meta_utils.hpp" namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/api/cldnn/runtime/device.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/device.hpp new file mode 100644 index 00000000000000..7f5e1f13d7d1e7 --- /dev/null +++ b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/device.hpp @@ -0,0 +1,24 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "device_info.hpp" +#include "memory_caps.hpp" + +#include + +namespace cldnn { + +/// @brief Represents detected GPU device object. Use device_query to get list of available objects. +struct device { +public: + using ptr = std::shared_ptr; + virtual device_info get_info() const = 0; + virtual memory_capabilities get_mem_caps() const = 0; + + virtual ~device() = default; +}; + +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/api/cldnn/runtime/device_info.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/device_info.hpp new file mode 100644 index 00000000000000..60ac318340d241 --- /dev/null +++ b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/device_info.hpp @@ -0,0 +1,76 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +namespace cldnn { +/// @addtogroup cpp_api C++ API +/// @{ + +/// @defgroup cpp_device GPU Device +/// @{ + +/// @brief Enumeration of supported device types +enum class device_type { + integrated_gpu = 0, + discrete_gpu = 1 +}; + +/// @brief Defines version of GFX IP +struct gfx_version { + uint16_t major; + uint8_t minor; + uint8_t revision; +}; + +/// @brief Information about the device properties and capabilities. +struct device_info { + uint32_t execution_units_count; ///< Number of available execution units. + uint32_t gpu_frequency; ///< Clock frequency in MHz. + uint32_t max_threads_per_execution_unit; ///< Number of available HW threads on EU. + uint32_t max_threads_per_device; ///< Maximum number of HW threads on device. + + uint64_t max_work_group_size; ///< Maximum number of work-items in a work-group executing a kernel using the data parallel execution model. + uint64_t max_local_mem_size; ///< Maximum size of local memory arena in bytes. + uint64_t max_global_mem_size; ///< Maximum size of global device memory in bytes. + uint64_t max_alloc_mem_size; ///< Maximum size of memory object allocation in bytes. + + uint64_t max_image2d_width; ///< Maximum image 2d width supported by the device. + uint64_t max_image2d_height; ///< Maximum image 2d height supported by the device. + + bool supports_fp16; ///< Does engine support FP16. + bool supports_fp64; ///< Does engine support FP64. + bool supports_fp16_denorms; ///< Does engine support denormalized FP16. + bool supports_subgroups; ///< Does engine support cl_intel_subgroups extension. + bool supports_subgroups_short; ///< Does engine support cl_intel_subgroups_short extension. + bool supports_subgroups_char; ///< Does engine support cl_intel_subgroups_char extension. + bool supports_local_block_io; ///< Does engine support cl_intel_subgroup_local_block_io extension. + bool supports_image; ///< Does engine support images (CL_DEVICE_IMAGE_SUPPORT cap). + + bool supports_imad; ///< Does engine support int8 mad. + bool supports_immad; ///< Does engine support int8 multi mad. + + bool supports_usm; ///< Does engine support unified shared memory. + + uint32_t vendor_id; ///< Vendor ID + std::string dev_name; ///< Device ID string + std::string driver_version; ///< Version of OpenCL driver + + device_type dev_type; ///< Defines type of current GPU device (integrated or discrete) + + gfx_version gfx_ver; ///< Defines GFX IP version + uint32_t device_id; ///< ID of current GPU + uint32_t num_slices; ///< Number of slices + uint32_t num_sub_slices_per_slice; ///< Number of subslices in a slice + uint32_t num_eus_per_sub_slice; ///< Number of execution units per subslice + uint32_t num_threads_per_eu; ///< Number of hardware threads per execution unit +}; + +/// @} + +/// @} + +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/api/cldnn/runtime/device_query.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/device_query.hpp new file mode 100644 index 00000000000000..af458360288641 --- /dev/null +++ b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/device_query.hpp @@ -0,0 +1,29 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "device.hpp" +#include "engine_configuration.hpp" + +#include +#include +#include + +namespace cldnn { + +// Fetches all available gpu devices with specific runtime and engine types and (optionally) user context/device handles +struct device_query { +public: + explicit device_query(engine_types engine_type, runtime_types runtime_type, void* user_context = nullptr, void* user_device = nullptr); + + std::map get_available_devices() const { + return _available_devices; + } + + ~device_query() = default; +private: + std::map _available_devices; +}; +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/api/cldnn/runtime/engine.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/engine.hpp new file mode 100644 index 00000000000000..b81f626c5e64f4 --- /dev/null +++ b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/engine.hpp @@ -0,0 +1,150 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "device.hpp" +#include "engine_configuration.hpp" +#include "event.hpp" +#include "memory_caps.hpp" +#include "memory_pool.hpp" +#include "layout.hpp" + +#include +#include +#include +#include + +namespace cldnn { + +class stream; + +using memory_ptr = std::shared_ptr; +using stream_ptr = std::shared_ptr; + +using primitive_id = std::string; + +class engine { +public: + /// Default destructor + virtual ~engine() = default; + + /// Returns type of the engine + virtual engine_types type() const = 0; + /// Returns runtime type used in the engine + virtual runtime_types runtime_type() const = 0; + + /// Create memory object with specified @p layout and allocation @p type for primitive with @p id + /// Underlying memory handle can be reused with other primitives from memory pool based on @p dependencies + memory_ptr get_memory_from_pool(const layout& layout, + primitive_id id, + uint32_t network_id, + std::set dependencies, + allocation_type type, + bool reusable = true); + + /// Create memory object attached to the buffer allocated by user. + /// @param ptr The pointer to user allocated buffer. + /// @note Size (in bytes) of the buffer should be equal to @p layout.bytes_count() + /// User is responsible for buffer deallocation. Buffer lifetime should be bigger than lifetime of the memory object. + memory_ptr attach_memory(const layout& layout, void* ptr); + + /// Allocate gpu memory using specified @p layout and alloation @p type + virtual memory_ptr allocate_memory(const layout& layout, allocation_type type, bool reset = true) = 0; + + /// Allocate gpu memory using specified @p layout. Allocation type is selected automatically based on engine/device configuration + memory_ptr allocate_memory(const layout& layout, bool reset = true); + + /// Created memory object from memory @p params and reinterpred the data using specified @p layout + virtual memory_ptr reinterpret_handle(const layout& new_layout, shared_mem_params params) = 0; + + /// Created memory object from the other @p memory and reinterpred the data using specified @p new_layout + virtual memory_ptr reinterpret_buffer(const memory& memory, const layout& new_layout) = 0; + + /// Create shared memory object using user-supplied memory buffer @p buf using specified @p layout + memory_ptr share_buffer(const layout& layout, shared_handle buf); + + /// Create shared memory object using user-supplied 2D image @p img using specified @p layout + memory_ptr share_image(const layout& layout, shared_handle img); + + /// Create shared memory object over specified @p plane of video decoder surface @p surf using specified @p layout +#ifdef _WIN32 + memory_ptr share_surface(const layout& layout, shared_handle surf, uint32_t plane); + memory_ptr share_dx_buffer(const layout& layout, shared_handle res); +#else + memory_ptr share_surface(const layout& layout, shared_surface surf, uint32_t plane); +#endif + + /// Checks whether two memory objects represents the same physical memory + virtual bool is_the_same_buffer(const memory& mem1, const memory& mem2) = 0; + + /// Returns basic allocation type which will be used as a fallback when allocation type is not specified or device doesn't support some features. + virtual allocation_type get_default_allocation_type() const = 0; + + /// Returns preferred allocation type which can be mapped to host ptr + allocation_type get_lockable_preffered_memory_allocation_type(bool is_image_layout = false) const; + + /// Checks if the current engine supports speicied allocation @p type + bool supports_allocation(allocation_type type) const; + + /// Returns configuration of current engine + const engine_configuration& configuration() const { return _configuration; } + + /// Returns device structure which represents stores device capabilities + device_info get_device_info() const; + + /// Returns device object associated with the engine + const device::ptr get_device() const; + + /// Returns memory pool for the engine + memory_pool& get_memory_pool(); + + /// Returns user context handle which was used to create the engine + virtual void* get_user_context() const = 0; + + /// Returns the maximum amount of GPU memory that engine allocated in current process + uint64_t get_max_used_device_memory() const; + + /// Returns the amount of GPU memory currently used by the engine + uint64_t get_used_device_memory() const; + + /// Returns true if USM is enabled in engine config and device/driver supports required features + bool use_unified_shared_memory() const; + + /// Create stream object for current engine + virtual stream_ptr create_stream() const = 0; + + /// Returns service stream which can be used during program build and optimizations + virtual stream& get_program_stream() const = 0; + + /// Factory method which creates engine object with impl configured by @p engine_type + /// @param engine_type requested engine type + /// @param runtime_type requested execution runtime for the engine. @note some runtime/engine types configurations might be unsupported + /// @param device specifies the device which the engine is created for + /// @param configuration options for the engine + static std::shared_ptr create(engine_types engine_type, + runtime_types runtime_type, + const device::ptr device, + const engine_configuration& configuration = engine_configuration()); + + /// Factory method which creates engine object with impl configured by @p engine_type + /// @param engine_type requested engine type + /// @param runtime_type requested execution runtime for the engine. @note some runtime/engine types configurations might be unsupported + /// @param configuration options for the engine + /// @note engine is created for the first device returned by devices query + static std::shared_ptr create(engine_types engine_type, + runtime_types runtime_type, + const engine_configuration& configuration = engine_configuration()); + +protected: + /// Create engine for given @p device and @p configuration + engine(const device::ptr device, const engine_configuration& configuration); + + // TODO: Consider moving memory pool to cldnn::network + std::unique_ptr _memory_pool; + const device::ptr _device; + engine_configuration _configuration; +}; + +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/api/cldnn/runtime/engine_configuration.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/engine_configuration.hpp new file mode 100644 index 00000000000000..2cbaca414ab594 --- /dev/null +++ b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/engine_configuration.hpp @@ -0,0 +1,110 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "utils.hpp" + +#include +#include +#include + +namespace cldnn { + +/// @addtogroup cpp_api C++ API +/// @{ + +/// @defgroup cpp_engine Execution Engine +/// @{ + +/// @brief Defines available engine types +enum class engine_types : int32_t { + ocl, +}; + +/// @brief Defines available runtime types +enum class runtime_types : int32_t { + ocl, +}; + +/// @brief Defines available priority mode types +enum class priority_mode_types : int16_t { + disabled, + low, + med, + high +}; + +/// @brief Defines available throttle mode types +enum class throttle_mode_types : int16_t { + disabled, + low, + med, + high +}; + +/// @brief Defines supported queue types +enum class queue_types : int16_t { + in_order, + out_of_order +}; + +/// @brief Configuration parameters for created engine. +struct engine_configuration { + const bool enable_profiling; ///< Enable per-primitive profiling. + const queue_types queue_type; ///< Specifies type of queue used by the runtime + const std::string sources_dumps_dir; ///< Specifies a directory where sources of cldnn::program objects should be dumped. + ///< Empty by default (means no dumping). + const priority_mode_types priority_mode; ///< Priority mode (support of priority hints in command queue). If cl_khr_priority_hints extension + ///< is not supported by current OpenCL implementation, the value must be set to cldnn_priority_disabled. + + const throttle_mode_types throttle_mode; ///< Throttle mode (support of throttle hints in command queue). If cl_khr_throttle_hints extension + ///< is not supported by current OpenCL implementation, the value must be set to cldnn_throttle_disabled. + + bool use_memory_pool; ///< Enables memory usage optimization. memory objects will be reused when possible + ///< (switched off for older drivers then NEO). + bool use_unified_shared_memory; ///< Enables USM usage + const std::string kernels_cache_path; ///< Path to compiled kernels cache + uint16_t n_threads; ///< Max number of host threads used in gpu plugin + const std::string tuning_cache_path; ///< Path to tuning kernel cache + + /// @brief Constructs engine configuration with specified options. + /// @param enable_profiling Enable per-primitive profiling. + /// @param queue_type Specifies type of queue used by the runtime + /// @param sources_dumps_dir Specifies a directory where sources of cldnn::program objects should be dumped + /// @param priority_mode Priority mode for all streams created within the engine + /// @param throttle_mode Throttle mode for all streams created within the engine + /// @param use_memory_pool Controls whether engine is allowed to reuse intermediate memory buffers whithin a network + /// @param use_unified_shared_memory If this option it true and device supports USM, then engine will use USM for all memory allocations + /// @param kernels_cache_path Path to existing directory where plugin can cache compiled kernels + /// @param n_threads Max number of host threads used in gpu plugin + /// @param tuning_cache_path Path to tuning kernel cache + engine_configuration( + bool enable_profiling = false, + queue_types queue_type = queue_types::out_of_order, + const std::string& sources_dumps_dir = std::string(), + priority_mode_types priority_mode = priority_mode_types::disabled, + throttle_mode_types throttle_mode = throttle_mode_types::disabled, + bool use_memory_pool = true, + bool use_unified_shared_memory = true, + const std::string& kernels_cache_path = "", + uint16_t n_threads = std::max(static_cast(std::thread::hardware_concurrency()), static_cast(1)), + const std::string& tuning_cache_path = "cache.json") + : enable_profiling(enable_profiling) + , queue_type(queue_type) + , sources_dumps_dir(sources_dumps_dir) + , priority_mode(priority_mode) + , throttle_mode(throttle_mode) + , use_memory_pool(use_memory_pool) + , use_unified_shared_memory(use_unified_shared_memory) + , kernels_cache_path(kernels_cache_path) + , n_threads(n_threads) + , tuning_cache_path(tuning_cache_path) { } +}; + +/// @} + +/// @} + +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/include/error_handler.h b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/error_handler.hpp similarity index 99% rename from inference-engine/thirdparty/clDNN/src/include/error_handler.h rename to inference-engine/thirdparty/clDNN/api/cldnn/runtime/error_handler.hpp index 1ce66e39c9f134..7f57d64861c413 100644 --- a/inference-engine/thirdparty/clDNN/src/include/error_handler.h +++ b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/error_handler.hpp @@ -2,14 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once + +#include "layout.hpp" + #include #include #include #include #include -#include "api/layout.hpp" #include #include diff --git a/inference-engine/thirdparty/clDNN/src/include/event_impl.h b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/event.hpp similarity index 82% rename from inference-engine/thirdparty/clDNN/src/include/event_impl.h rename to inference-engine/thirdparty/clDNN/api/cldnn/runtime/event.hpp index c87e34a3f84507..db2eda1a501bae 100644 --- a/inference-engine/thirdparty/clDNN/src/include/event_impl.h +++ b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/event.hpp @@ -2,21 +2,26 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/event.hpp" -#include "refcounted_obj.h" + +#include "profiling.hpp" #include #include #include +#include +#include namespace cldnn { struct user_event; -struct event_impl : public refcounted_obj { +/// @brief user-defined event handler callback. +using event_handler = std::function; + +struct event { public: - event_impl() = default; + using ptr = std::shared_ptr; + event() = default; void wait(); bool is_set(); @@ -27,10 +32,11 @@ struct event_impl : public refcounted_obj { _profiling_captured = false; _profiling_info.clear(); } + // returns true if handler has been successfully added bool add_event_handler(event_handler handler, void* data); - const std::list& get_profiling_info(); + std::vector get_profiling_info(); private: std::mutex _handlers_mutex; @@ -54,7 +60,7 @@ struct event_impl : public refcounted_obj { virtual bool get_profiling_info_impl(std::list&) { return true; } }; -struct user_event : virtual public event_impl { +struct user_event : virtual public event { public: explicit user_event(bool set = false) { _set = set; } diff --git a/inference-engine/thirdparty/clDNN/api/cldnn/runtime/half.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/half.hpp new file mode 100644 index 00000000000000..785cc711d8f977 --- /dev/null +++ b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/half.hpp @@ -0,0 +1,55 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include +#include + +namespace cldnn { + +/// @addtogroup cpp_api C++ API +/// @{ + +float half_to_float(uint16_t value); +uint16_t float_to_half(float value); + +// There is no portable half precision floating point support. +// Using wrapped integral type with the same size and alignment restrictions. +class half_impl { +public: + half_impl() = default; + + template ::value>::type> + explicit half_impl(T data, int /*direct_creation_tag*/) : _data(data) {} + + operator uint16_t() const { return _data; } + operator float() const { + return half_to_float(_data); + } + + explicit half_impl(float value) + : _data(float_to_half(value)) + {} + + template ::value>::type> + explicit half_impl(T value) + : half_impl(static_cast(value)) + {} + +private: + uint16_t _data; +}; + +// Use complete implementation if necessary. +#if defined HALF_HALF_HPP +using half_t = half; +#else +using half_t = half_impl; +#endif + +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/api/cldnn/runtime/kernel.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/kernel.hpp new file mode 100644 index 00000000000000..0d75173e7723d9 --- /dev/null +++ b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/kernel.hpp @@ -0,0 +1,24 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "kernel_args.hpp" +#include "event.hpp" + +#include +#include + +namespace cldnn { + +using kernel_id = std::string; + +class kernel { +public: + using ptr = std::shared_ptr; + virtual std::shared_ptr clone() const = 0; + virtual ~kernel() = default; +}; + +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/api/cldnn/runtime/kernel_args.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/kernel_args.hpp new file mode 100644 index 00000000000000..f70d04ee33a771 --- /dev/null +++ b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/kernel_args.hpp @@ -0,0 +1,133 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "memory.hpp" + +#include +#include + +namespace cldnn { + +struct work_group_sizes { + std::vector global; + std::vector local; +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Scalar +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +struct scalar_desc { + union ValueT { + uint8_t u8; + uint16_t u16; + uint32_t u32; + uint64_t u64; + int8_t s8; + int16_t s16; + int32_t s32; + int64_t s64; + float f32; + double f64; + }; + + enum class Types { + UINT8, + UINT16, + UINT32, + UINT64, + INT8, + INT16, + INT32, + INT64, + FLOAT32, + FLOAT64, + }; + + Types t; + ValueT v; +}; + +using scalars_desc = std::vector; + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// ArgumentDescpirtor +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +struct argument_desc { + enum class Types { + INPUT, + OUTPUT, + WEIGHTS, + BIAS, + SCALE_TABLE, + SLOPE, + SPLIT, + INTERNAL_BUFFER, + SCALAR, + RECURRENT, // RNN/LSTM/GRU recurrent weights + HIDDEN, // RNN/LSTM/GRU hidden input + CELL, // LSTM cell input + LSTM_PACK, // LSTM packed output + WEIGHTS_ZERO_POINTS, + ACTIVATIONS_ZERO_POINTS, + COMPENSATION, + INPUT_OF_FUSED_PRIMITIVE + }; + + Types t; + uint32_t index; +}; + +using arguments_desc = std::vector; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// KernelParams +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +struct kernel_arguments_desc { + work_group_sizes workGroups; + arguments_desc arguments; + scalars_desc scalars; + std::string layerID; +}; + +struct kernel_arguments_data { + std::vector inputs; + std::vector intermediates; + memory::cptr output; + memory::cptr weights; + memory::cptr recurrent; + memory::cptr hidden; + memory::cptr cell; + memory::cptr bias; + memory::cptr weights_zero_points; + memory::cptr activations_zero_points; + memory::cptr compensation; + memory::cptr lookup_table; + memory::cptr scale_table; + memory::cptr slope; + + std::vector fused_op_inputs; + int32_t split = 0; + const scalars_desc* scalars = nullptr; +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// KernelString +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +struct kernel_string { + std::string str; + std::string jit; + std::string undefs; + std::string options; + std::string entry_point; + bool batch_compilation; + + kernel_string() : str(""), jit(""), undefs(""), options(""), entry_point(""), batch_compilation(false) {} + + std::string get_hash() { return str + jit + undefs + options + entry_point; } +}; + +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/api/layout.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/layout.hpp similarity index 99% rename from inference-engine/thirdparty/clDNN/api/layout.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/runtime/layout.hpp index ab4b17f03c9efb..4962cd009639cc 100644 --- a/inference-engine/thirdparty/clDNN/api/layout.hpp +++ b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/layout.hpp @@ -2,9 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once + #include "tensor.hpp" +#include "half.hpp" + #include #include #include diff --git a/inference-engine/thirdparty/clDNN/api/cldnn/runtime/memory.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/memory.hpp new file mode 100644 index 00000000000000..e054e90a477bd9 --- /dev/null +++ b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/memory.hpp @@ -0,0 +1,150 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "layout.hpp" +#include "memory_caps.hpp" +#include "event.hpp" +#include "engine_configuration.hpp" + +namespace cldnn { + +class engine; +class stream; + +struct memory { + using ptr = std::shared_ptr; + using cptr = std::shared_ptr; + memory(engine* engine, const layout& layout, allocation_type type, bool reused = false); + + virtual ~memory(); + virtual void* lock(const stream& stream) = 0; + virtual void unlock(const stream& stream) = 0; + virtual event::ptr fill(stream& stream, unsigned char pattern) = 0; + virtual event::ptr fill(stream& stream) = 0; + + size_t size() const { return _bytes_count; } + size_t count() const { return _layout.count(); } + virtual shared_mem_params get_internal_params() const = 0; + virtual bool is_allocated_by(const engine& engine) const { return &engine == _engine; } + engine* get_engine() const { return _engine; } + const layout& get_layout() const { return _layout; } + allocation_type get_allocation_type() const { return _type; } + // TODO: must be moved outside memory class + virtual bool is_memory_reset_needed(layout l) { + // To avoid memory reset, output memory must meet the following requirements: + // - To be Weights format (Data memory can be reused by memory_pool, which can lead to errors) + // - To have zero paddings + // - To be completely filled with data + if ((!format::is_weights_format(l.format) && !format::is_simple_data_format(l.format)) || + format::is_winograd(l.format) || format::is_image_2d(l.format)) { + return true; + } + + if (l.data_padding.lower_size() != tensor(0) || l.data_padding.upper_size() != tensor(0)) { + return true; + } + + if (_bytes_count == (l.data_type == data_types::bin ? ceil_div(l.count(), 32) : l.count()) * data_type_traits::size_of(l.data_type)) { + return false; + } + + return true; + } + + virtual event::ptr copy_from(stream& /* stream */, const memory& /* other */) = 0; + virtual event::ptr copy_from(stream& /* stream */, const void* /* host_ptr */) = 0; + +protected: + engine* _engine; + const layout _layout; + // layout bytes count, needed because of traits static map destruction + // before run of memory destructor, when engine is static + size_t _bytes_count; + +private: + allocation_type _type; + bool _reused; +}; + +struct simple_attached_memory : memory { + simple_attached_memory(const layout& layout, void* pointer) + : memory(nullptr, layout, allocation_type::unknown), _pointer(pointer) {} + + void* lock(const stream& /* stream */) override { return _pointer; } + void unlock(const stream& /* stream */) override {} + event::ptr fill(stream& /* stream */, unsigned char) override { return nullptr; } + event::ptr fill(stream& /* stream */) override { return nullptr; } + shared_mem_params get_internal_params() const override { return { shared_mem_type::shared_mem_empty, nullptr, nullptr, nullptr, +#ifdef _WIN32 + nullptr, +#else + 0, +#endif + 0}; }; + + event::ptr copy_from(stream& /* stream */, const memory& /* other */) override { return nullptr; }; + event::ptr copy_from(stream& /* stream */, const void* /* host_ptr */) override { return nullptr; } + +private: + void* _pointer; +}; + +template +struct mem_lock { + explicit mem_lock(memory::ptr mem, const stream& stream) : _mem(mem), _stream(stream), _ptr(reinterpret_cast(_mem->lock(_stream))) {} + + ~mem_lock() { + _ptr = nullptr; + _mem->unlock(_stream); + } + + size_t size() const { return _mem->size() / sizeof(T); } + + mem_lock(const mem_lock& other) = delete; + mem_lock& operator=(const mem_lock& other) = delete; + +#if defined(_SECURE_SCL) && (_SECURE_SCL > 0) + auto begin() & { return stdext::make_checked_array_iterator(_ptr, size()); } + auto end() & { return stdext::make_checked_array_iterator(_ptr, size(), size()); } +#else + T* begin() & { return _ptr; } + T* end() & { return _ptr + size(); } +#endif + + /// @brief Provides indexed access to pointed memory. + T& operator[](size_t idx) const& { + assert(idx < size()); + return _ptr[idx]; + } + + T* data() const & { return _ptr; } + + /// Prevents to use mem_lock as temporary object + T* data() && = delete; + /// Prevents to use mem_lock as temporary object + T* begin() && = delete; + /// Prevents to use mem_lock as temporary object + T* end() && = delete; + /// Prevents to use mem_lock as temporary object + T& operator[](size_t idx) && = delete; + +private: + memory::ptr _mem; + const stream& _stream; + T* _ptr; +}; + +struct surfaces_lock { + surfaces_lock() = default; + virtual ~surfaces_lock() = default; + + surfaces_lock(const surfaces_lock& other) = delete; + surfaces_lock& operator=(const surfaces_lock& other) = delete; + + static std::unique_ptr create(engine_types engine_type, std::vector mem, const stream& stream); +}; + +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/api/cldnn/runtime/memory_caps.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/memory_caps.hpp new file mode 100644 index 00000000000000..98f9eee658103f --- /dev/null +++ b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/memory_caps.hpp @@ -0,0 +1,84 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include + +namespace cldnn { + +enum class allocation_type { + unknown, // Not specified (i.e simple_attached_memory class). + cl_mem, // Use standard OpenCL cl_mem allocations. + usm_host, // Accessible by host and device. Not Migratable + usm_shared, // Accessible by host and device. Migrtable. + usm_device, // Accessible only by device. Not migratable. +}; + +class memory_capabilities { +public: + memory_capabilities(std::vector supported_allocation_types) : _caps(supported_allocation_types) {} + bool supports_usm() const { + return find_in_caps(allocation_type::usm_host) || + find_in_caps(allocation_type::usm_shared) || + find_in_caps(allocation_type::usm_device); + } + bool support_allocation_type(allocation_type type) const { return find_in_caps(type); } + + static bool is_usm_type(allocation_type type) { + if (type == allocation_type::usm_host || + type == allocation_type::usm_shared || + type == allocation_type::usm_device) + return true; + return false; + } + +private: + std::vector _caps; + + bool find_in_caps(const allocation_type& type) const { + return std::find_if(_caps.begin(), _caps.end(), [&](const allocation_type& t) { return t == type; }) != _caps.end(); + } +}; + + +/// @brief Shared memory descriptor type. +enum class shared_mem_type { + /// @brief Structure unitialized or contains no information. + shared_mem_empty, + + /// @brief Structure describes shared CL buffer. + shared_mem_buffer, + + /// @brief Structure describes shared CL image. + shared_mem_image, + + /// @brief Structure describes shared VA/DXVA surface + shared_mem_vasurface, + + /// @brief Structure describes shared D3D11 buffer + shared_mem_dxbuffer +}; + +using shared_handle = void*; +using shared_surface = uint32_t; + +/// @brief Low-level API handles required for using cldnn memory objects in external API calls. +struct shared_mem_params { + shared_mem_type mem_type; ///< shared buffer type + shared_handle context; ///< OpenCL context for external operations + shared_handle user_device; ///< DX/VA device for external operations + shared_handle mem; ///< memory object handle +#ifdef _WIN32 + shared_handle surface; ///< VA/DXVA surface handle +#else + shared_surface surface; +#endif + uint32_t plane; ///< shared surface plane +}; + +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/include/memory_pool.h b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/memory_pool.hpp similarity index 52% rename from inference-engine/thirdparty/clDNN/src/include/memory_pool.h rename to inference-engine/thirdparty/clDNN/api/cldnn/runtime/memory_pool.hpp index 739cf23515a9f0..6c3d5d4d7660ef 100644 --- a/inference-engine/thirdparty/clDNN/src/include/memory_pool.h +++ b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/memory_pool.hpp @@ -2,28 +2,29 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/layout.hpp" -#include "api/primitive.hpp" -#include "device_impl.h" -#include "refcounted_obj.h" + +#include "layout.hpp" +#include "memory_caps.hpp" #include #include #include #include #include +#include namespace cldnn { -struct memory_impl; +struct memory; struct shared_mem_params; -struct engine_impl; -struct program_impl; +class engine; struct memory_user; struct memory_user_comparer; using memory_set = std::set; +using primitive_id = std::string; + +using memory_ptr = std::shared_ptr; struct memory_user { primitive_id _id; @@ -48,10 +49,10 @@ struct memory_user_comparer { struct memory_record { memory_set _users; // list of primitives that already use this memory object - refcounted_obj_ptr _memory; + memory_ptr _memory; uint32_t _network_id; allocation_type _type; - memory_record(memory_set users, refcounted_obj_ptr& memory, uint32_t net_id, allocation_type type); + memory_record(memory_set users, memory_ptr& memory, uint32_t net_id, allocation_type type); }; struct padded_pool_comparer { @@ -83,55 +84,49 @@ struct padded_pool_comparer { // - immutable - if user request for non reusable resource don't use pool, return // TODO list: -// - resolve engine <--> memory_pool circular dependency -// - add padded buffers pool -// - add decreasing memory limit in gpu_buffer/image dctor -// - add support for multi networks reuse +// - Move from runtime to graph part +// - Improve memory consumption class memory_pool { memory_pool(); - refcounted_obj_ptr alloc_memory(const layout& layout, allocation_type type, uint32_t network_id, bool reset = true); + memory_ptr alloc_memory(const layout& layout, allocation_type type); static bool has_conflict(const memory_set&, const std::set&, uint32_t network_id); std::multimap _non_padded_pool; std::map, padded_pool_comparer> _padded_pool; std::multimap _no_reusable_pool; - engine_impl* _engine; + engine* _engine; std::atomic _temp_memory_used; std::atomic _max_peak_memory_used; public: - explicit memory_pool(engine_impl& engine); + explicit memory_pool(engine& engine); ~memory_pool(); - refcounted_obj_ptr get_memory(const layout& layout, - const primitive_id& id, - uint32_t network_id, - const std::set& restrictions, - allocation_type type, - bool reusable = true); // get from pool or create memory allocation - refcounted_obj_ptr get_memory(const layout& layout, allocation_type type, uint32_t network_id, bool reset = true); - refcounted_obj_ptr get_memory(const layout& layout, const shared_mem_params* params, uint32_t network_id); - refcounted_obj_ptr get_from_non_padded_pool(const layout& layout, - const primitive_id& id, - uint32_t network_id, - const std::set&, - allocation_type type); - refcounted_obj_ptr get_from_padded_pool(const layout& layout, - const primitive_id& id, - uint32_t network_id, - const std::set& restrictions, - allocation_type type); - refcounted_obj_ptr get_from_across_networks_pool(const layout& layout, - const primitive_id& id, - uint32_t network_id, - allocation_type type); + memory_ptr get_memory(const layout& layout, + const primitive_id& id, + uint32_t network_id, + const std::set& restrictions, + allocation_type type, + bool reusable = true); // get from pool or create memory allocation + memory_ptr get_memory(const layout& layout, allocation_type type); + memory_ptr get_from_non_padded_pool(const layout& layout, + const primitive_id& id, + uint32_t network_id, + const std::set&, + allocation_type type); + memory_ptr get_from_padded_pool(const layout& layout, + const primitive_id& id, + uint32_t network_id, + const std::set& restrictions, + allocation_type type); + memory_ptr get_from_across_networks_pool(const layout& layout, + const primitive_id& id, + uint32_t network_id, + allocation_type type); void clear_pool(); void clear_pool_for_network(uint32_t network_id); - void release_memory(memory_impl* memory, - const primitive_id& id); - void color_graph(const program_impl&); - void dump_memory_pool(const program_impl&, std::string&, std::string&); + void release_memory(memory* memory, const primitive_id& id, uint32_t network_id); uint64_t get_temp_memory_used() const { return _temp_memory_used; } uint64_t get_max_peak_device_memory_used() const { return _max_peak_memory_used; } diff --git a/inference-engine/thirdparty/clDNN/api/profiling.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/profiling.hpp similarity index 99% rename from inference-engine/thirdparty/clDNN/api/profiling.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/runtime/profiling.hpp index 575fb06defa69c..98c18a483f9fe4 100644 --- a/inference-engine/thirdparty/clDNN/api/profiling.hpp +++ b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/profiling.hpp @@ -3,6 +3,7 @@ // #pragma once + #include #include #include diff --git a/inference-engine/thirdparty/clDNN/api/cldnn/runtime/stream.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/stream.hpp new file mode 100644 index 00000000000000..10575a9d6c4c05 --- /dev/null +++ b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/stream.hpp @@ -0,0 +1,46 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "event.hpp" +#include "kernel.hpp" +#include "kernel_args.hpp" + +#include +#include + +namespace cldnn { + +class stream { +public: + using ptr = std::shared_ptr; + explicit stream(queue_types queue_type) : queue_type(queue_type) {} + virtual ~stream() = default; + + virtual void flush() const = 0; + virtual void finish() const = 0; + + virtual void set_arguments(kernel& kernel, const kernel_arguments_desc& args_desc, const kernel_arguments_data& args) = 0; + virtual event::ptr enqueue_kernel(kernel& kernel, + const kernel_arguments_desc& args_desc, + const kernel_arguments_data& args, + std::vector const& deps, + bool is_output_event = false) = 0; + virtual event::ptr enqueue_marker(std::vector const& deps, bool is_output_event = false) = 0; + virtual void enqueue_barrier() = 0; + virtual event::ptr group_events(std::vector const& deps) = 0; + virtual void wait_for_events(const std::vector& events) = 0; + virtual void reset_events() = 0; + virtual event::ptr create_user_event(bool set) = 0; + virtual event::ptr create_base_event() = 0; + virtual void release_events_pool() = 0; + + queue_types get_queue_type() const { return queue_type; } + +protected: + queue_types queue_type; +}; + +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/api/tensor.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/tensor.hpp similarity index 99% rename from inference-engine/thirdparty/clDNN/api/tensor.hpp rename to inference-engine/thirdparty/clDNN/api/cldnn/runtime/tensor.hpp index 4bed1bcdb3a5d6..9c6a02d9e2e044 100644 --- a/inference-engine/thirdparty/clDNN/api/tensor.hpp +++ b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/tensor.hpp @@ -2,11 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "cldnn.hpp" -#include "compounds.h" -#include "meta_utils.hpp" + +#include "compounds.hpp" +#include "utils.hpp" #include #include diff --git a/inference-engine/thirdparty/clDNN/api/cldnn/runtime/utils.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/utils.hpp new file mode 100644 index 00000000000000..7b66ff43a7bc22 --- /dev/null +++ b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/utils.hpp @@ -0,0 +1,144 @@ +// Copyright (C) 2017-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include + +namespace cldnn { + +struct primitive; + +namespace meta { + +// helper struct to tell wheter type T is any of given types U... +// termination case when U... is empty -> return std::false_type +template +struct is_any_of : public std::false_type {}; + +// helper struct to tell whether type is any of given types (U, Rest...) +// recurrence case when at least one type U is present -> returns std::true_type if std::same::value is true, +// otherwise call is_any_of recurrently +template +struct is_any_of + : public std::conditional::value, std::true_type, is_any_of>::type {}; + +template +struct always_false : public std::false_type {}; + +template +struct always_false_ty_val : public std::false_type {}; + +template +struct val_tuple {}; + +template +struct all : public std::true_type {}; + +template +struct all : public std::integral_constant::value> {}; + +} // namespace meta + +/// @cond CPP_HELPERS + +/// @defgroup cpp_helpers Helpers +/// @{ + +#define CLDNN_API_CLASS(the_class) static_assert(std::is_standard_layout::value, #the_class " has to be 'standard layout' class"); + +template +typename std::enable_if::value, T>::type align_to(T size, size_t align) { + return static_cast((size % align == 0) ? size : size - size % align + align); +} + +template +typename std::enable_if::value, T>::type pad_to(T size, size_t align) { + return static_cast((size % align == 0) ? 0 : align - size % align); +} + +template +typename std::enable_if::value, bool>::type is_aligned_to(T size, size_t align) { + return !(size % align); +} + +/// Computes ceil(@p val / @p divider) on unsigned integral numbers. +/// +/// Computes division of unsigned integral numbers and rounds result up to full number (ceiling). +/// The function works for unsigned integrals only. Signed integrals are converted to corresponding +/// unsigned ones. +/// +/// @tparam T1 Type of @p val. Type must be integral (SFINAE). +/// @tparam T2 Type of @p divider. Type must be integral (SFINAE). +/// +/// @param val Divided value. If value is signed, it will be converted to corresponding unsigned type. +/// @param divider Divider value. If value is signed, it will be converted to corresponding unsigned type. +/// +/// @return Result of ceil(@p val / @p divider). The type of result is determined as if in normal integral +/// division, except each operand is converted to unsigned type if necessary. +template +constexpr auto ceil_div(T1 val, T2 divider) +-> typename std::enable_if::value && std::is_integral::value, + decltype(std::declval::type>() / std::declval::type>())>::type { + typedef typename std::make_unsigned::type UT1; + typedef typename std::make_unsigned::type UT2; + typedef decltype(std::declval() / std::declval()) RetT; + + return static_cast((static_cast(val) + static_cast(divider) - 1U) / static_cast(divider)); +} + +/// Rounds @p val to nearest multiply of @p rounding that is greater or equal to @p val. +/// +/// The function works for unsigned integrals only. Signed integrals are converted to corresponding +/// unsigned ones. +/// +/// @tparam T1 Type of @p val. Type must be integral (SFINAE). +/// @tparam T2 Type of @p rounding. Type must be integral (SFINAE). +/// +/// @param val Value to round up. If value is signed, it will be converted to corresponding unsigned type. +/// @param rounding Rounding value. If value is signed, it will be converted to corresponding unsigned type. +/// +/// @return @p val rounded up to nearest multiply of @p rounding. The type of result is determined as if in normal integral +/// division, except each operand is converted to unsigned type if necessary. +template +constexpr auto round_up_to(T1 val, T2 rounding) +-> typename std::enable_if::value && std::is_integral::value, + decltype(std::declval::type>() / std::declval::type>())>::type { + typedef typename std::make_unsigned::type UT1; + typedef typename std::make_unsigned::type UT2; + typedef decltype(std::declval() / std::declval()) RetT; + + return static_cast(ceil_div(val, rounding) * static_cast(rounding)); +} + +template +std::unique_ptr make_unique(Args&& ... args) { + return std::unique_ptr( new T(std::forward(args)...) ); +} + +template ::value, int>::type = 0> +inline derived_type* downcast(base_type* base) { + if (auto casted = dynamic_cast(base)) + return casted; + + throw std::runtime_error("Unable to cast pointer from base to derived type"); +} + +template ::value, int>::type = 0> +inline derived_type& downcast(base_type& base) { + try { + return dynamic_cast(base); + } catch (std::bad_cast& /* ex */) { + throw std::runtime_error("Unable to cast reference from base to derived type"); + } + throw std::runtime_error("downcast failed with unhadnled exception"); +} + +/// @} +/// @endcond +/// @} +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/api/device.hpp b/inference-engine/thirdparty/clDNN/api/device.hpp deleted file mode 100644 index e8889d5e86dfd8..00000000000000 --- a/inference-engine/thirdparty/clDNN/api/device.hpp +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma once -#include "cldnn.hpp" -#include -#include -#include -#include - -namespace cldnn { -/// @addtogroup cpp_api C++ API -/// @{ - -/// @defgroup cpp_device GPU Device -/// @{ - -/// @brief Enumeration of supported device types -enum class device_type { - integrated_gpu = 0, - discrete_gpu = 1 -}; - -struct gfx_version { - uint16_t major; - uint8_t minor; - uint8_t revision; -}; - -/// @brief Information about the device properties and capabilities. -struct device_info { - uint32_t cores_count; ///< Number of available HW cores. - uint32_t core_frequency; ///< Clock frequency in MHz. - uint32_t max_threads_per_execution_unit; ///< Number of available HW threads on EU. - uint32_t max_threads_per_device; ///< Maximum number of HW threads on device. - - uint64_t max_work_group_size; ///< Maximum number of work-items in a work-group executing a kernel using the data parallel execution model. - uint64_t max_local_mem_size; ///< Maximum size of local memory arena in bytes. - uint64_t max_global_mem_size; ///< Maximum size of global device memory in bytes. - uint64_t max_alloc_mem_size; ///< Maximum size of memory object allocation in bytes. - - uint64_t max_image2d_width; ///< Maximum image 2d width supported by the device. - uint64_t max_image2d_height; ///< Maximum image 2d height supported by the device. - - // Flags (for layout compatibility fixed size types are used). - uint8_t supports_fp16; ///< Does engine support FP16. - uint8_t supports_fp16_denorms; ///< Does engine support denormalized FP16. - uint8_t supports_subgroups_short; ///< Does engine support cl_intel_subgroups_short. - uint8_t supports_image; ///< Does engine support images (CL_DEVICE_IMAGE_SUPPORT cap). - - uint8_t supports_imad; ///< Does engine support int8 mad. - uint8_t supports_immad; ///< Does engine support int8 multi mad. - - uint8_t supports_usm; ///< Does engine support unified shared memory. - - std::string dev_name; ///< Device ID string - std::string driver_version; ///< Version of OpenCL driver - - device_type dev_type; ///< Defines type of current GPU device (integrated or discrete) - - gfx_version gfx_ver; - uint32_t device_id; - uint32_t num_slices; - uint32_t num_sub_slices_per_slice; - uint32_t num_eus_per_sub_slice; - uint32_t num_threads_per_eu; -}; - -struct device_impl; - -/// @brief Represents clDNN detected device object. Use device_query to get list of available objects. -struct device { - static device create_default(); - - explicit device(device_impl* data) - : _impl(data) { - if (_impl == nullptr) - throw std::invalid_argument("implementation pointer should not be null"); - } - - /// @brief Returns information about properties and capabilities of the device. - device_info get_info() const; - - // TODO add move construction/assignment - device(const device& other) : _impl(other._impl) { - retain(); - } - - device& operator=(const device& other) { - if (_impl == other._impl) return *this; - release(); - _impl = other._impl; - retain(); - return *this; - } - - ~device() { - release(); - } - - friend bool operator==(const device& lhs, const device& rhs) { return lhs._impl == rhs._impl; } - friend bool operator!=(const device& lhs, const device& rhs) { return !(lhs == rhs); } - - device_impl* get() const { return _impl; } - -private: - device_impl* _impl; - - void retain(); - void release(); -}; - -struct device_query_impl; - -/// @brief Represents clDNN object, which allows to query for list of devices. -struct device_query { - /// @brief Constructs engine configuration with specified options. - /// @param Query only for devices, which supports out of order execution (default in cldnn). - /// @param Query for devices in user provided opencl context. - explicit device_query(void* clcontext = nullptr, void* user_device = nullptr); - // TODO add move construction/assignment - device_query(const device_query& other) : _impl(other._impl) { - retain(); - } - - /// Returns map of {device_id, device object} of available devices on system. - /// Device_id is string. First device will have id: "0", second "1" etc. - std::map get_available_devices() const; - - device_query& operator=(const device_query& other) { - if (_impl == other._impl) return *this; - release(); - _impl = other._impl; - retain(); - return *this; - } - - ~device_query() { - release(); - } - - friend bool operator==(const device_query& lhs, const device_query& rhs) { return lhs._impl == rhs._impl; } - friend bool operator!=(const device_query& lhs, const device_query& rhs) { return !(lhs == rhs); } - - device_query_impl* get() const { return _impl; } - -private: - device_query_impl* _impl; - - void retain(); - void release(); -}; -CLDNN_API_CLASS(device_query) - -/// @} - -/// @} - -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/api/engine.hpp b/inference-engine/thirdparty/clDNN/api/engine.hpp deleted file mode 100644 index c65d89df60196d..00000000000000 --- a/inference-engine/thirdparty/clDNN/api/engine.hpp +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma once -#include "cldnn.hpp" -#include "device.hpp" -#include -#include -#include -#include -#include - -namespace cldnn { - -/// @addtogroup cpp_api C++ API -/// @{ - -/// @defgroup cpp_engine Execution Engine -/// @{ - -/// @brief Defines available engine types -enum class engine_types : int32_t { - ocl -}; - -/// @brief Defines available priority mode types -enum class priority_mode_types : int16_t { - disabled, - low, - med, - high -}; - -/// @brief Defines available priority mode types -enum class throttle_mode_types : int16_t { - disabled, - low, - med, - high -}; - -/// @brief Configuration parameters for created engine. -struct engine_configuration { - const bool enable_profiling; ///< Enable per-primitive profiling. - const bool meaningful_kernels_names; ///< Generate meaniful names fo OpenCL kernels. - const bool dump_custom_program; ///< Dump the user OpenCL programs to files - const std::string compiler_options; ///< OpenCL compiler options string. - const std::string single_kernel_name; ///< If provided, runs specific layer. - const bool enable_parallelisation; ///< Enables parallel execution of primitives which don't depend on each other. Disabled by default. - const std::string engine_log; ///< Specifies a file to which engine log should be dumped. Empty by default (means no logging). - const std::string sources_dumps_dir; ///< Specifies a directory where sources of cldnn::program objects should be dumped. - ///< Empty by default (means no dumping). - const priority_mode_types priority_mode; ///< Priority mode (support of priority hints in command queue). If cl_khr_priority_hints extension - ///< is not supported by current OpenCL implementation, the value must be set to cldnn_priority_disabled. - - const throttle_mode_types throttle_mode; ///< Throttle mode (support of throttle hints in command queue). If cl_khr_throttle_hints extension - ///< is not supported by current OpenCL implementation, the value must be set to cldnn_throttle_disabled. - - bool enable_memory_pool; ///< Enables memory usage optimization. memory objects will be reused when possible - ///< (switched off for older drivers then NEO). - uint16_t n_streams; ///< Number of queues executed in parallel - const std::string kernels_cache_path; ///< Path to compiled kernels cache - uint16_t n_threads; ///< Number of threads - const std::string tuning_cache_path; ///< Path to tuning kernel cache - - /// @brief Constructs engine configuration with specified options. - /// @param profiling Enable per-primitive profiling. - /// @param decorate_kernel_names Generate meaniful names fo OpenCL kernels. - /// @param dump_custom_program Dump the custom OpenCL programs to files - /// @param options OpenCL compiler options string. - /// @param single_kernel If provided, runs specific layer. - engine_configuration( - bool profiling = false, - bool decorate_kernel_names = false, - bool dump_custom_program = false, - const std::string& options = std::string(), - const std::string& single_kernel = std::string(), - bool primitives_parallelisation = true, - const std::string& engine_log = std::string(), - const std::string& sources_dumps_dir = std::string(), - priority_mode_types priority_mode = priority_mode_types::disabled, - throttle_mode_types throttle_mode = throttle_mode_types::disabled, - bool memory_pool = true, - uint16_t n_streams = 1, - const std::string& kernels_cache_path = "", - uint16_t n_threads = std::max(static_cast(std::thread::hardware_concurrency()), static_cast(1)), - const std::string& tuning_cache_path = "cache.json") - : enable_profiling(profiling) - , meaningful_kernels_names(decorate_kernel_names) - , dump_custom_program(dump_custom_program) - , compiler_options(options) - , single_kernel_name(single_kernel) - , enable_parallelisation(primitives_parallelisation) - , engine_log(engine_log) - , sources_dumps_dir(sources_dumps_dir) - , priority_mode(priority_mode) - , throttle_mode(throttle_mode) - , enable_memory_pool(memory_pool) - , n_streams(n_streams) - , kernels_cache_path(kernels_cache_path) - , n_threads(n_threads) - , tuning_cache_path(tuning_cache_path) { - if (n_streams == 0) { - throw std::invalid_argument("Invalid streams count set in engine config"); - } - } -}; - -struct engine_impl; - -/// @brief Represents clDNN engine object. -struct engine { - /// @brief Constructs @p OpenCL engine - explicit engine(const engine_configuration& configuration = engine_configuration()) - : engine(engine_types::ocl, device::create_default(), configuration) {} - - /// @brief Constructs @p OpenCL engine - explicit engine(const device& device, const engine_configuration& configuration = engine_configuration()) - : engine(engine_types::ocl, device, configuration) {} - - /// @brief Construct engine of the specified @p type, @p engine_num, and @p configuration options. - /// @param[in] type Engine type @ref cldnn_engine_type. Only OCL engine is supported. - /// @param[in] engine_num Engine index. Should be 0. - /// @param[in] configuration Engine configuration options. - engine(engine_types type, const device& device, const engine_configuration& configuration = engine_configuration()); - - // TODO add move construction/assignment - engine(const engine& other) : _impl(other._impl) { - retain(); - } - - engine& operator=(const engine& other) { - if (_impl == other._impl) return *this; - release(); - _impl = other._impl; - retain(); - return *this; - } - - ~engine() { - release(); - } - - friend bool operator==(const engine& lhs, const engine& rhs) { return lhs._impl == rhs._impl; } - friend bool operator!=(const engine& lhs, const engine& rhs) { return !(lhs == rhs); } - - /// @brief Returns number of available engines of the particular @p type. - static uint32_t engine_count(engine_types type); - - /// @brief Release pending memory allocated in OpenCL context. - void release_pending_memory(uint32_t net_id) const; - - /// @brief Returns information about properties and capabilities of the device used for allocation of the engine. - device_info get_info() const; - - /// @brief Returns OpenCL context handle of the engine. - void* get_context() const; - - /// @brief Returns total size of all resources allocated using given engine - uint64_t get_max_used_device_memory_size() const; - - /// @brief Returns total size of currently resources allocated using given engine - uint64_t get_temp_used_device_memory_size() const; - - /// @brief Returns type of the engine. - engine_types get_type() const; - - /// @brief get C API engine handler. - engine_impl* get() const { return _impl; } - -private: - friend struct network; - friend struct memory; - friend struct event; - - engine_impl* _impl; - - void retain(); - void release(); -}; -CLDNN_API_CLASS(engine) - -/// @} - -/// @} - -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/api/event.hpp b/inference-engine/thirdparty/clDNN/api/event.hpp deleted file mode 100644 index 3b54171d74549d..00000000000000 --- a/inference-engine/thirdparty/clDNN/api/event.hpp +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma once -#include "cldnn.hpp" -#include "engine.hpp" -#include "profiling.hpp" -#include -#include -#include -#include -#include -#include - -namespace cldnn { - -/// @addtogroup cpp_api C++ API -/// @{ - -/// @addtogroup cpp_event Events Support -/// @{ - -struct event_impl; - -/// @brief user-defined event handler callback. -using event_handler = std::function; - -/// @brief Represents an clDNN Event object -struct event { - /// @brief Create an event which can be set to 'completed' by user. - static event create_user_event(const engine& engine, uint32_t net_id); - - /// @brief Construct from C API handler @ref ::cldnn_event. - explicit event(event_impl* impl) : _impl(impl) { - if (_impl == nullptr) throw std::invalid_argument("implementation pointer should not be null"); - } - - event(const event& other) : _impl(other._impl) { - retain(); - } - - event& operator=(const event& other) { - if (_impl == other._impl) return *this; - release(); - _impl = other._impl; - retain(); - return *this; - } - - ~event() { - release(); - } - - friend bool operator==(const event& lhs, const event& rhs) { return lhs._impl == rhs._impl; } - friend bool operator!=(const event& lhs, const event& rhs) { return !(lhs == rhs); } - - /// @brief Wait for event completion. - void wait() const; - - /// @brief Set event status to 'completed'. - void set() const; - - /// @brief Register call back to be called on event completion. - void set_event_handler(event_handler handler, void* param) const; - - /// @brief Get profiling info for the event associated with network output. - std::vector get_profiling_info() const; - - /// @brief Returns C API event handler. - event_impl* get() const { return _impl; } - -private: - event_impl* _impl; - void retain(); - void release(); -}; -CLDNN_API_CLASS(event) - -/// @} -/// @} -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/api/memory.hpp b/inference-engine/thirdparty/clDNN/api/memory.hpp deleted file mode 100644 index 30dfd5c7eef0e9..00000000000000 --- a/inference-engine/thirdparty/clDNN/api/memory.hpp +++ /dev/null @@ -1,278 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma once -#include -#include "cldnn.hpp" -#include "compounds.h" -#include "layout.hpp" -#include "engine.hpp" -#include -#include -#include - -namespace cldnn { - -/// @addtogroup cpp_api C++ API -/// @{ - -/// @defgroup cpp_memory Memory description and management -/// @{ - -template -struct pointer; - -struct memory_impl; - -/// @brief Shared memory descriptor type. -enum class shared_mem_type { - /// @brief Structure unitialized or contains no information. - shared_mem_empty, - - /// @brief Structure describes shared CL buffer. - shared_mem_buffer, - - /// @brief Structure describes shared CL image. - shared_mem_image, - - /// @brief Structure describes shared VA/DXVA surface - shared_mem_vasurface, - - /// @brief Structure describes shared D3D11 buffer - shared_mem_dxbuffer -}; - -using shared_handle = void*; -using shared_surface = uint32_t; - -/// @brief Low-level API handles required for using cldnn memory objects in external API calls. -struct shared_mem_params { - shared_mem_type mem_type; ///< shared buffer type - shared_handle context; ///< OpenCL context for external operations - shared_handle user_device; ///< DX/VA device for external operations - shared_handle mem; ///< memory object handle -#ifdef _WIN32 - shared_handle surface; ///< VA/DXVA surface handle -#else - shared_surface surface; -#endif - uint32_t plane; ///< shared surface plane -}; -/// @brief Represents buffer with particular @ref layout. -/// @details Usually allocated by @ref engine except cases when attached to user-allocated buffer. -struct memory { - friend struct data; - friend struct mutable_data; - friend struct network; - friend struct network_output; - - /// Allocate memory on @p engine using specified @p layout - static memory allocate(const engine& engine, const layout& layout, uint32_t net_id = 0, bool reset = true); - - /// Create shared memory object on @p engine using user-supplied memory buffer @p buf using specified @p layout - static memory share_buffer(const engine& engine, const layout& layout, shared_handle buf, uint32_t net_id = 0); - - /// Create shared memory object on @p engine using user-supplied 2D image @p img using specified @p layout - static memory share_image(const engine& engine, const layout& layout, shared_handle img, uint32_t net_id = 0); - - /// Create shared memory object on @p engine over specified @p plane of video decoder surface @p surf using specified @p layout -#ifdef _WIN32 - static memory share_surface(const engine& engine, const layout& layout, shared_handle surf, uint32_t plane, - uint32_t net_id = 0); - static memory share_dx_buffer(const engine& engine, const layout& layout, shared_handle res, uint32_t net_id = 0); -#else - static memory share_surface(const engine& engine, const layout& layout, shared_surface surf, uint32_t plane, - uint32_t net_id = 0); -#endif - - /// Create memory object attached to the buffer allocated by user. - /// @param ptr The pointer to user allocated buffer. - /// @param size Size (in bytes) of the buffer. Should be equal to @p layout.data_size() - /// @note User is responsible for buffer deallocation. Buffer lifetime should be bigger than lifetime of the memory object. - template - static memory attach(const cldnn::layout& layout, T* ptr, size_t size, uint32_t net_id = 0) { - if (!ptr) - throw std::invalid_argument("pointer should not be null"); - size_t data_size = size * sizeof(T); - if (data_size != layout.bytes_count()) { - std::string err_str("buffer size mismatch - input size " + std::to_string(data_size) + " layout size " + - std::to_string(layout.bytes_count())); - throw std::invalid_argument(err_str); - } - - return attach_impl(layout, static_cast(ptr), net_id); - } - - explicit memory(memory_impl* data) - : _impl(data) { - if (_impl == nullptr) - throw std::invalid_argument("implementation pointer should not be null"); - } - - memory(const memory& other) : _impl(other._impl) { - retain(); - } - - memory& operator=(const memory& other) { - if (_impl == other._impl) - return *this; - release(); - _impl = other._impl; - retain(); - return *this; - } - - ~memory() { release(); } - - friend bool operator==(const memory& lhs, const memory& rhs) { return lhs._impl == rhs._impl; } - friend bool operator!=(const memory& lhs, const memory& rhs) { return !(lhs == rhs); } - - /// number of elements of _layout.data_type stored in memory - size_t count() const; - - /// number of bytes used by memory - size_t size() const; - - /// Associated @ref layout - const layout& get_layout() const; - int get_net_id() const; - - /// Test if memory is allocated by @p engine - bool is_allocated_by(const engine& engine) const; - - bool is_the_same_buffer(const memory& other) const; - - shared_mem_params get_internal_params() const; - - /// Creates the @ref pointer object to get an access memory data - template - friend struct cldnn::pointer; - template - cldnn::pointer pointer() const; - - /// C API memory handle - memory_impl* get() const { return _impl; } - - void reset(); - -private: - friend struct engine; - memory_impl* _impl; - - template - T* lock() const { - if (data_type_traits::align_of(get_layout().data_type) % alignof(T) != 0) { - throw std::logic_error("memory data type alignment do not match"); - } - return static_cast(lock_impl()); - } - - void unlock() const; - - void* lock_impl() const; - static memory attach_impl(const cldnn::layout& layout, void* ptr, uint32_t net_id); - - void retain(); - void release(); -}; - -/// @brief Helper class to get an access @ref memory data -/// @details -/// This class provides an access to @ref memory data following RAII idiom and exposes basic C++ collection members. -/// @ref memory object is locked on construction of pointer and "unlocked" on descruction. -/// Objects of this class could be used in many STL utility functions like copy(), transform(), etc. -/// As well as in range-for loops. -template -struct pointer { - /// @brief Constructs pointer from @ref memory and locks @c (pin) ref@ memory object. - explicit pointer(const memory& mem) : _mem(mem), _size(_mem.size() / sizeof(T)), _ptr(_mem.lock()) {} - - /// @brief Unlocks @ref memory - ~pointer() { _mem.unlock(); } - - /// @brief Copy construction. - pointer(const pointer& other) : pointer(other._mem) {} - - /// @brief Copy assignment. - pointer& operator=(const pointer& other) { - if (this->_mem != other._mem) - do_copy(other._mem); - return *this; - } - - /// @brief Returns the number of elements (of type T) stored in memory - size_t size() const { return _size; } - -#if defined(_SECURE_SCL) && (_SECURE_SCL > 0) - typedef stdext::checked_array_iterator iterator; - typedef stdext::checked_array_iterator const_iterator; - - iterator begin() & { return stdext::make_checked_array_iterator(_ptr, size()); } - iterator end() & { return stdext::make_checked_array_iterator(_ptr, size(), size()); } - - const_iterator begin() const& { return stdext::make_checked_array_iterator(_ptr, size()); } - const_iterator end() const& { return stdext::make_checked_array_iterator(_ptr, size(), size()); } -#else - typedef T* iterator; - typedef const T* const_iterator; - iterator begin() & { return _ptr; } - iterator end() & { return _ptr + size(); } - const_iterator begin() const& { return _ptr; } - const_iterator end() const& { return _ptr + size(); } -#endif - - /// @brief Provides indexed access to pointed memory. - T& operator[](size_t idx) const& { - assert(idx < _size); - return _ptr[idx]; - } - - /// @brief Returns the raw pointer to pointed memory. - T* data() & { return _ptr; } - /// @brief Returns the constant raw pointer to pointed memory - const T* data() const& { return _ptr; } - - friend bool operator==(const pointer& lhs, const pointer& rhs) { return lhs._mem == rhs._mem; } - friend bool operator!=(const pointer& lhs, const pointer& rhs) { return !(lhs == rhs); } - - // do not use this class as temporary object - // ReSharper disable CppMemberFunctionMayBeStatic, CppMemberFunctionMayBeConst - /// Prevents to use pointer as temporary object - void data() && {} - /// Prevents to use pointer as temporary object - void begin() && {} - /// Prevents to use pointer as temporary object - void end() && {} - /// Prevents to use pointer as temporary object - void operator[](size_t idx) && {} - // ReSharper restore CppMemberFunctionMayBeConst, CppMemberFunctionMayBeStatic - -private: - memory _mem; - size_t _size; - T* _ptr; - - // TODO implement exception safe code. - void do_copy(const memory& mem) { - auto ptr = mem.lock(); - _mem.unlock(); - _mem = mem; - _size = _mem.size() / sizeof(T); - _ptr = ptr; - } -}; - -#ifndef DOXYGEN_SHOULD_SKIP_THIS -template -pointer memory::pointer() const { - return cldnn::pointer(*this); -} -#endif - -/// @} - -/// @} - -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/api/meta_utils.hpp b/inference-engine/thirdparty/clDNN/api/meta_utils.hpp deleted file mode 100644 index c71073a8dfd0fa..00000000000000 --- a/inference-engine/thirdparty/clDNN/api/meta_utils.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -namespace cldnn { - -struct primitive; - -namespace meta { - -// helper struct to tell wheter type T is any of given types U... -// termination case when U... is empty -> return std::false_type -template -struct is_any_of : public std::false_type {}; - -// helper struct to tell whether type is any of given types (U, Rest...) -// recurrence case when at least one type U is present -> returns std::true_type if std::same::value is true, -// otherwise call is_any_of recurrently -template -struct is_any_of - : public std::conditional::value, std::true_type, is_any_of>::type {}; - -template -struct always_false : public std::false_type {}; - -template -struct always_false_ty_val : public std::false_type {}; - -template -struct val_tuple {}; - -template -struct all : public std::true_type {}; - -template -struct all : public std::integral_constant::value> {}; - -} // namespace meta -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/api_test_builds/CMakeLists.txt b/inference-engine/thirdparty/clDNN/api_test_builds/CMakeLists.txt index 38772c1e8941c2..9e08c013ca1dce 100644 --- a/inference-engine/thirdparty/clDNN/api_test_builds/CMakeLists.txt +++ b/inference-engine/thirdparty/clDNN/api_test_builds/CMakeLists.txt @@ -30,28 +30,20 @@ intel_config_flag_apply_settings(CompilerOptions CMAKE_C_FLAGS ALL_PATTERN "" # ========================================= Source/Header files ======================================== set(__CLDNN_Label__api "api") -file(GLOB __CLDNN_Headers__api +file(GLOB_RECURSE __CLDNN_Headers__api "${CLDNN__API_DIR}/*.hpp" ) -set(__CLDNN_Directory__api__cpp "${CLDNN__API_DIR}/CPP") -set(__CLDNN_Label__api__cpp "${__CLDNN_Label__api}\\CPP") -file(GLOB __CLDNN_Headers__api__cpp - "${__CLDNN_Directory__api__cpp}/*.hpp" - ) - set(__CLDNN_Directory__test_builds "${CLDNN__CODEGEN_DIR}/test_builds") set(__CLDNN_CGDirectory__test_builds "${CLDNN__CODEGEN_BASEDIR}/test_builds") set(__CLDNN_Label__test_builds "test builds\\codegen") -set(__CLDNN_File__test_builds__api__cpp "api_cpp_test.cpp") +set(__CLDNN_File__test_builds__api "api_cpp_test.cpp") set(__CLDNN_Sources__test_builds - "${__CLDNN_Directory__test_builds}/${__CLDNN_File__test_builds__api__cpp}" + "${__CLDNN_Directory__test_builds}/${__CLDNN_File__test_builds__api}" ) set(__CLDNN_AllSources ${__CLDNN_Headers__api} - ${__CLDNN_Headers__api__cpp} - ${__CLDNN_Headers__api__c} ${__CLDNN_Sources__test_builds} ) @@ -63,9 +55,9 @@ set_property(SOURCE ${__CLDNN_Sources__test_builds} PROPERTY GENERATED TRUE) file(MAKE_DIRECTORY "${__CLDNN_CGDirectory__test_builds}") # C++ API testing (C++11 compatibility). -set(__CLDNN_CGFile__api__cpp "${__CLDNN_CGDirectory__test_builds}/${__CLDNN_File__test_builds__api__cpp}") +set(__CLDNN_CGFile__api__cpp "${__CLDNN_CGDirectory__test_builds}/${__CLDNN_File__test_builds__api}") file(WRITE "${__CLDNN_CGFile__api__cpp}" "// This file is auto-generated. Please, do not modify it directly.\n\n") -foreach(__CLDNN_Header ${__CLDNN_Headers__api} ${__CLDNN_Headers__api__cpp}) +foreach(__CLDNN_Header ${__CLDNN_Headers__api}) string(REPLACE ";" "\;" __CLDNN_Header "${__CLDNN_Header}") # [WA#1] Must escape ; again if occurred in item. file(APPEND "${__CLDNN_CGFile__api__cpp}" "#include \"${__CLDNN_Header}\"\n") endforeach() @@ -74,21 +66,17 @@ file(APPEND "${__CLDNN_CGFile__api__cpp}" "\n") # =============================================== Filters ============================================== source_group("${__CLDNN_Label__api}" FILES ${__CLDNN_Headers__api}) -source_group("${__CLDNN_Label__api__cpp}" FILES ${__CLDNN_Headers__api__cpp}) source_group("${__CLDNN_Label__test_builds}" FILES ${__CLDNN_Sources__test_builds}) # ===================================== Include/Link directories ======================================= -include_directories( - "${CLDNN__MAIN_DIR}" - ) +include_directories("${CLDNN__MAIN_DIR}") # =================================== Link targets and dependencies ==================================== # Test static library. -add_library("${CLDNN_BUILD__PROJ}" STATIC - ${__CLDNN_AllSources} - ) +add_library("${CLDNN_BUILD__PROJ}" STATIC ${__CLDNN_AllSources}) + set_property(TARGET "${CLDNN_BUILD__PROJ}" PROPERTY PROJECT_LABEL "${CLDNN_BUILD__PROJ_LABEL}") set_property(TARGET "${CLDNN_BUILD__PROJ}" PROPERTY ARCHIVE_OUTPUT_DIRECTORY "${CLDNN_BUILD__PROJ_OUTPUT_DIR}") set_property(TARGET "${CLDNN_BUILD__PROJ}" PROPERTY OUTPUT_NAME "${CLDNN_BUILD__PROJ_OUTPUT_NAME}") @@ -96,16 +84,14 @@ set_property(TARGET "${CLDNN_BUILD__PROJ}" PROPERTY OUTPUT_NAME "${ target_link_libraries("${CLDNN_BUILD__PROJ}" ${CLDNN__SYSTEM_LINK_LIBRARIES}) -add_dependencies("${CLDNN_BUILD__PROJ__clDNN}" - "${CLDNN_BUILD__PROJ}" - ) +add_dependencies("${CLDNN_BUILD__PROJ__clDNN}" "${CLDNN_BUILD__PROJ}") # =================================== Custom pre- and post-steps ======================================= -add_custom_command(OUTPUT "${__CLDNN_Directory__test_builds}/${__CLDNN_File__test_builds__api__cpp}" - COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${__CLDNN_CGFile__api__cpp}" "${__CLDNN_Directory__test_builds}/${__CLDNN_File__test_builds__api__cpp}" +add_custom_command(OUTPUT "${__CLDNN_Directory__test_builds}/${__CLDNN_File__test_builds__api}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${__CLDNN_CGFile__api__cpp}" "${__CLDNN_Directory__test_builds}/${__CLDNN_File__test_builds__api}" DEPENDS "${__CLDNN_CGFile__api__cpp}" ${__CLDNN_Headers__api} ${__CLDNN_Headers__api__cpp} - COMMENT "Updating file if the file changed (${__CLDNN_File__test_builds__api__cpp}) ..." + COMMENT "Updating file if the file changed (${__CLDNN_File__test_builds__api}) ..." ) # ====================================================================================================== diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/CMakeLists.txt b/inference-engine/thirdparty/clDNN/kernel_selector/CMakeLists.txt index da5dd9b2333d8a..2f8271441bd28d 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/CMakeLists.txt +++ b/inference-engine/thirdparty/clDNN/kernel_selector/CMakeLists.txt @@ -124,6 +124,7 @@ source_group("${__CLDNN_Label__cg_cache}" FILES ${__CLDNN_Sources__cg_ca # ===================================== Include/Link directories ======================================= include_directories( + "${CLDNN__MAIN_DIR}" "${__CLDNN_Directory__main}" "${__CLDNN_Directory__core}" "${__CLDNN_Directory__core}/common" diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/common/tensor_type.h b/inference-engine/thirdparty/clDNN/kernel_selector/common/tensor_type.h index 19dbc972aba8b6..f9c9b622e48e69 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/common/tensor_type.h +++ b/inference-engine/thirdparty/clDNN/kernel_selector/common/tensor_type.h @@ -385,6 +385,8 @@ struct TensorBase { return differ; } + + virtual ~TensorBase() = default; }; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/activation/activation_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/activation/activation_kernel_base.cpp index 0b31d6ce496cb3..2a24a9f18dfb53 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/activation/activation_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/activation/activation_kernel_base.cpp @@ -81,7 +81,7 @@ KernelsData ActivationKernelBase::GetCommonKernelsData(const Params& params, con DEFAULT, false, false, 1, GetFusedPrimitiveInputsCount(params)); if (!newParams.inputActivationParams.empty()) { - kernel.arguments.push_back({ArgumentDescriptor::Types::SLOPE, 0}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::SLOPE, 0}); } return {kd}; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/arg_max_min/arg_max_min_kernel_axis.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/arg_max_min/arg_max_min_kernel_axis.cpp index ab4e2068371679..734dd1c9ebb8cb 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/arg_max_min/arg_max_min_kernel_axis.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/arg_max_min/arg_max_min_kernel_axis.cpp @@ -93,7 +93,7 @@ KernelsData ArgMaxMinKernelAxis::GetKernelsData(const Params& params, const opti FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point); if (orgParams.outputs_num == 2) { - kernel.arguments.push_back({ArgumentDescriptor::Types::INPUT, 1}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 1}); } return {kd}; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/binary_convolution/binary_convolution_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/binary_convolution/binary_convolution_kernel_base.cpp index 6747a78d418955..d7a7ba3ec37800 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/binary_convolution/binary_convolution_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/binary_convolution/binary_convolution_kernel_base.cpp @@ -137,7 +137,7 @@ KernelsData BinaryConvolutionKernelBase::GetCommonKernelsData(const Params& para uint32_t fused_deps_total = 0; for (auto& fused_dep : newParams.fused_ops) { for (int i = 0; i < static_cast(fused_dep.dep_size); i++) { - kernel.arguments.push_back({ArgumentDescriptor::Types::INPUT_OF_FUSED_PRIMITIVE, fused_deps_total}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT_OF_FUSED_PRIMITIVE, fused_deps_total}); fused_deps_total++; } } @@ -153,7 +153,7 @@ KernelsData BinaryConvolutionKernelBase::GetCommonKernelsData(const Params& para !newParams.bias.empty(), 1, fused_deps_total); - kernel.arguments.push_back({ArgumentDescriptor::Types::SPLIT, 0}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::SPLIT, 0}); kd.autoTuneIndex = autoTuneIndex; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/concatenation/concatenation_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/concatenation/concatenation_kernel_base.cpp index 649afada9992b3..f1c20f88767c33 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/concatenation/concatenation_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/concatenation/concatenation_kernel_base.cpp @@ -111,17 +111,17 @@ KernelsData ConcatenationKernelBase::GetCommonKernelsData(const Params& params, auto entryPoint = GetEntryPoint(kernelName, newParams.layerID, options); auto jit = CreateJit(kernelName, cldnnJit, entryPoint); - kernel.workGroups.global = dispatchData.gws; - kernel.workGroups.local = dispatchData.lws; - kernel.kernelString = GetKernelString(kernelName, jit, entryPoint, params.engineInfo); - kernel.arguments.push_back({ArgumentDescriptor::Types::INPUT, (uint32_t)i }); - kernel.arguments.push_back({ArgumentDescriptor::Types::OUTPUT, 0}); + kernel.code.kernelString = GetKernelString(kernelName, jit, entryPoint, params.engineInfo); + kernel.params.workGroups.global = dispatchData.gws; + kernel.params.workGroups.local = dispatchData.lws; + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, (uint32_t)i }); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::OUTPUT, 0}); ScalarDescriptor s; s.t = ScalarDescriptor::Types::UINT32; s.v.u32 = lastOffset; - kernel.scalars.push_back(s); - kernel.arguments.push_back({ArgumentDescriptor::Types::SCALAR, 0}); + kernel.params.scalars.push_back(s); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::SCALAR, 0}); lastOffset += (uint32_t)input.GetDims()[concatChannelIndex].v; } diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/concatenation/concatenation_kernel_fs_b_yx_fsv32.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/concatenation/concatenation_kernel_fs_b_yx_fsv32.cpp index 07912f47634e5e..26397613b41245 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/concatenation/concatenation_kernel_fs_b_yx_fsv32.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/concatenation/concatenation_kernel_fs_b_yx_fsv32.cpp @@ -108,17 +108,17 @@ KernelsData ConcatenationKernel_fs_b_yx_fsv32::GetKernelsData(const Params& para auto entryPoint = GetEntryPoint(kernelName, newParams.layerID, optParams); auto jit = CreateJit(kernelName, cldnnJit, entryPoint); - kernel.workGroups.global = dispatchData.gws; - kernel.workGroups.local = dispatchData.lws; - kernel.kernelString = GetKernelString(kernelName, jit, entryPoint, params.engineInfo); - kernel.arguments.push_back({ArgumentDescriptor::Types::INPUT, (uint32_t)i}); - kernel.arguments.push_back({ArgumentDescriptor::Types::OUTPUT, 0}); + kernel.code.kernelString = GetKernelString(kernelName, jit, entryPoint, params.engineInfo); + kernel.params.workGroups.global = dispatchData.gws; + kernel.params.workGroups.local = dispatchData.lws; + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, (uint32_t)i}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::OUTPUT, 0}); ScalarDescriptor s; s.t = ScalarDescriptor::Types::UINT32; s.v.u32 = lastOffset; - kernel.scalars.push_back(s); - kernel.arguments.push_back({ArgumentDescriptor::Types::SCALAR, 0}); + kernel.params.scalars.push_back(s); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::SCALAR, 0}); lastOffset += (uint32_t)input.GetDims()[concatChannelIndex].v; } diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/concatenation/concatenation_kernel_ref.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/concatenation/concatenation_kernel_ref.cpp index d9f630b9a57520..618043fb52e609 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/concatenation/concatenation_kernel_ref.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/concatenation/concatenation_kernel_ref.cpp @@ -100,9 +100,9 @@ KernelsData ConcatenationKernelRef::GetKernelsData(const Params& params, const o auto& kernel = kd[0].kernels[i]; // to avoid cases when we execute with local work sizes 1x1x1 - if (kernel.workGroups.local[0] == 1 && kernel.workGroups.global[1] != 1) { - kernel.workGroups.global[1] = Align(kernel.workGroups.global[1], 32); - kernel.workGroups.local[1] = 32; + if (kernel.params.workGroups.local[0] == 1 && kernel.params.workGroups.global[1] != 1) { + kernel.params.workGroups.global[1] = Align(kernel.params.workGroups.global[1], 32); + kernel.params.workGroups.local[1] = 32; } } } diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/convolution/convolution_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/convolution/convolution_kernel_base.cpp index bcc7bbd29e7c9b..a5674f56f55167 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/convolution/convolution_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/convolution/convolution_kernel_base.cpp @@ -230,24 +230,24 @@ KernelsData ConvolutionKernelBase::GetCommonKernelsData(const Params& params, 1); if (newParams.deformable_mode) { - kernel.arguments.push_back({ArgumentDescriptor::Types::INPUT, 1}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 1}); } if (!newParams.weights_zero_points.empty()) - kernel.arguments.push_back({ArgumentDescriptor::Types::WEIGHTS_ZERO_POINTS, 1}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::WEIGHTS_ZERO_POINTS, 1}); if (!newParams.activations_zero_points.empty()) - kernel.arguments.push_back({ArgumentDescriptor::Types::ACTIVATIONS_ZERO_POINTS, 1}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::ACTIVATIONS_ZERO_POINTS, 1}); if (!newParams.compensation.empty()) - kernel.arguments.push_back({ArgumentDescriptor::Types::COMPENSATION, 1}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::COMPENSATION, 1}); uint32_t fused_deps_total = 0; for (auto& fused_dep : newParams.fused_ops) { for (int i = 0; i < static_cast(fused_dep.dep_size); i++) { - kernel.arguments.push_back({ ArgumentDescriptor::Types::INPUT_OF_FUSED_PRIMITIVE, fused_deps_total }); + kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INPUT_OF_FUSED_PRIMITIVE, fused_deps_total }); fused_deps_total++; } } - kernel.arguments.push_back({ArgumentDescriptor::Types::SPLIT, 0}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::SPLIT, 0}); kd.autoTuneIndex = autoTuneIndex; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/ctc_greedy_decoder/ctc_greedy_decoder_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/ctc_greedy_decoder/ctc_greedy_decoder_kernel_base.cpp index db690ef39a4131..664ed70fabc64b 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/ctc_greedy_decoder/ctc_greedy_decoder_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/ctc_greedy_decoder/ctc_greedy_decoder_kernel_base.cpp @@ -73,7 +73,7 @@ KernelsData CTCGreedyDecoderKernelBase::GetCommonKernelsData(const Params& param GetFusedPrimitiveInputsCount(params)); if (orgParams.outputs_num == 2) { - kernel.arguments.push_back({ArgumentDescriptor::Types::INPUT, 2}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 2}); } return {kd}; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/cum_sum/cum_sum_kernel_partial_sum.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/cum_sum/cum_sum_kernel_partial_sum.cpp index 085ce54e7a0944..87d2a3cedccc5c 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/cum_sum/cum_sum_kernel_partial_sum.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/cum_sum/cum_sum_kernel_partial_sum.cpp @@ -44,9 +44,9 @@ KernelsData CumSumKernelPartialSum::GetMultiStageKernelsData(const Params& param auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; FillCLKernelData(kernel, dispatchData.stage_1, params.engineInfo, kernelName, jit, entry_point); - kernel.arguments.clear(); // Clear original output argument - kernel.arguments.push_back({ArgumentDescriptor::Types::INPUT, 0}); - kernel.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0}); + kernel.params.arguments.clear(); // Clear original output argument + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 0}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0}); kd.internalBufferSizes.push_back(newParams.output.PhysicalSizeInBytes()); } { @@ -59,9 +59,9 @@ KernelsData CumSumKernelPartialSum::GetMultiStageKernelsData(const Params& param FillCLKernelData(kernel, dispatchData.stage_final, params.engineInfo, kernelName, jit, entry_point); - kernel.arguments.clear(); // Clear original output argument - kernel.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0}); - kernel.arguments.push_back({ArgumentDescriptor::Types::OUTPUT, 0}); + kernel.params.arguments.clear(); // Clear original output argument + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::OUTPUT, 0}); } kd.internalBufferDataType = Datatype::F32; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/deconvolution/deconvolution_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/deconvolution/deconvolution_kernel_base.cpp index 5ec4e19da1e8a4..383427b6075ebd 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/deconvolution/deconvolution_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/deconvolution/deconvolution_kernel_base.cpp @@ -137,7 +137,7 @@ KernelsData DeconvolutionKernelBase::GetKernelsData(const Params& params, const !newParams.bias.empty(), 1, GetFusedPrimitiveInputsCount(params)); - kernel.arguments.push_back({ArgumentDescriptor::Types::SPLIT, 0}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::SPLIT, 0}); return {kd}; } diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_b_fs_yx_fsv16.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_b_fs_yx_fsv16.cpp index afaa202ffe002c..73b404f89e97e5 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_b_fs_yx_fsv16.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_b_fs_yx_fsv16.cpp @@ -334,11 +334,11 @@ KernelsData EltwiseKernel_b_fs_yx_fsv16::GetKernelsData(const Params& params, co auto& kernel = kd.kernels[0]; - kernel.workGroups.global = dispatchData.gws; - kernel.workGroups.local = dispatchData.lws; + kernel.code.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo, DEFAULT); - kernel.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo, DEFAULT); - kernel.arguments = GetArgsDesc((uint32_t)newParams.inputs.size(), + kernel.params.workGroups.global = dispatchData.gws; + kernel.params.workGroups.local = dispatchData.lws; + kernel.params.arguments = GetArgsDesc((uint32_t)newParams.inputs.size(), false, false, GetFusedPrimitiveInputsCount(params)); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_b_fs_yx_fsv4.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_b_fs_yx_fsv4.cpp index 3f136eaf35b9ee..451145b63265ac 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_b_fs_yx_fsv4.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_b_fs_yx_fsv4.cpp @@ -47,11 +47,11 @@ KernelsData EltwiseKernel_b_fs_yx_fsv4::GetKernelsData(const Params& params, con auto& kernel = kd.kernels[0]; - kernel.workGroups.global = dispatchData.gws; - kernel.workGroups.local = dispatchData.lws; + kernel.params.workGroups.global = dispatchData.gws; + kernel.params.workGroups.local = dispatchData.lws; - kernel.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo, DEFAULT); - kernel.arguments = GetArgsDesc((uint32_t)newParams.inputs.size(), + kernel.code.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo, DEFAULT); + kernel.params.arguments = GetArgsDesc((uint32_t)newParams.inputs.size(), false, false, GetFusedPrimitiveInputsCount(params)); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_base.cpp index 6a40df57a68691..370efc6f969bd5 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_base.cpp @@ -621,11 +621,11 @@ KernelsData EltwiseKernelBase::GetCommonKernelsData(const Params& params, const auto& kernel = kd.kernels[0]; - kernel.workGroups.global = dispatchData.gws; - kernel.workGroups.local = dispatchData.lws; + kernel.code.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo, DEFAULT); - kernel.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo, DEFAULT); - kernel.arguments = GetArgsDesc((uint32_t)newParams.inputs.size(), + kernel.params.workGroups.global = dispatchData.gws; + kernel.params.workGroups.local = dispatchData.lws; + kernel.params.arguments = GetArgsDesc((uint32_t)newParams.inputs.size(), false, false, GetFusedPrimitiveInputsCount(params)); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_fs_b_yx_fsv32.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_fs_b_yx_fsv32.cpp index f8b43ea01a987f..91975fde6f1a09 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_fs_b_yx_fsv32.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_fs_b_yx_fsv32.cpp @@ -97,11 +97,12 @@ KernelsData EltwiseKernel_fs_b_yx_fsv32::GetKernelsData(const Params& params, co size_t x = input.X().v; size_t global_size = featuresRoundedUp * batches * x * y; - kernel.workGroups.global = {std::max(global_size / 8, (size_t)1), 1, 1}; - kernel.workGroups.local = GetOptimalLocalWorkGroupSizes(kernel.workGroups.global, params.engineInfo); + kernel.code.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo, DEFAULT); - kernel.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo, DEFAULT); - kernel.arguments = GetArgsDesc((uint32_t)newParams.inputs.size(), false, false); + kernel.params.workGroups.global = {std::max(global_size / 8, (size_t)1), 1, 1}; + kernel.params.workGroups.local = GetOptimalLocalWorkGroupSizes(kernel.params.workGroups.global, params.engineInfo); + + kernel.params.arguments = GetArgsDesc((uint32_t)newParams.inputs.size(), false, false); return {kd}; } diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_mixed_byxf_and_fs_b_yx_fsv32.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_mixed_byxf_and_fs_b_yx_fsv32.cpp index 288453139ccd8b..bf2ee1076120a3 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_mixed_byxf_and_fs_b_yx_fsv32.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_mixed_byxf_and_fs_b_yx_fsv32.cpp @@ -131,12 +131,12 @@ KernelsData EltwiseKernel_mixed_byxf_and_fs_b_yx_fsv32::GetKernelsData(const Par // in fs_b_yx_fsv32 format we will process 2 features per work item, so reads/writes are done in full writes for // fp16 - kernel.workGroups.global = {x, y, (featuresRoundedUp * batches) / 2}; + kernel.params.workGroups.global = {x, y, (featuresRoundedUp * batches) / 2}; - kernel.workGroups.local = {1, 1, 16}; + kernel.params.workGroups.local = {1, 1, 16}; - kernel.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo, DEFAULT); - kernel.arguments = GetArgsDesc((uint32_t)newParams.inputs.size(), false, false); + kernel.code.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo, DEFAULT); + kernel.params.arguments = GetArgsDesc((uint32_t)newParams.inputs.size(), false, false); return {kd}; } diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_vload8.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_vload8.cpp index 05910383aaee5c..a9470fbb0b7b42 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_vload8.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_vload8.cpp @@ -105,10 +105,10 @@ KernelsData EltwiseKernel_vload8::GetKernelsData(const Params& params, const opt } auto& kernel = kd.kernels[0]; - kernel.workGroups.global = {std::max(newParams.inputs[0].LogicalSize() / 8, (size_t)1), 1, 1}; - kernel.workGroups.local = GetOptimalLocalWorkGroupSizes(kernel.workGroups.global, params.engineInfo); - kernel.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo, DEFAULT); - kernel.arguments = GetArgsDesc((uint32_t)newParams.inputs.size(), false, false); + kernel.params.workGroups.global = {std::max(newParams.inputs[0].LogicalSize() / 8, (size_t)1), 1, 1}; + kernel.params.workGroups.local = GetOptimalLocalWorkGroupSizes(kernel.params.workGroups.global, params.engineInfo); + kernel.code.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo, DEFAULT); + kernel.params.arguments = GetArgsDesc((uint32_t)newParams.inputs.size(), false, false); return {kd}; } diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/fused_conv_eltwise/fused_conv_eltwise_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/fused_conv_eltwise/fused_conv_eltwise_kernel_base.cpp index ee6087e5417429..a1d86baf9a22c3 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/fused_conv_eltwise/fused_conv_eltwise_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/fused_conv_eltwise/fused_conv_eltwise_kernel_base.cpp @@ -282,12 +282,12 @@ KernelsData fused_conv_eltwise_kernel_base::GetCommonKernelsData(const Params& p true, !newParams.bias.empty(), 1); - kernel.arguments.push_back({ArgumentDescriptor::Types::SPLIT, 0}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::SPLIT, 0}); // eltwise's second input if (newParams.second_input_in_output) { - kernel.arguments.push_back({ArgumentDescriptor::Types::OUTPUT, 0}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::OUTPUT, 0}); } else { - kernel.arguments.push_back({ArgumentDescriptor::Types::INPUT, 1}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 1}); } kd.autoTuneIndex = autoTuneIndex; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_nd_kernel_ref.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_nd_kernel_ref.cpp index 3da6f44337bd3c..fa523d35ef97e7 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_nd_kernel_ref.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_nd_kernel_ref.cpp @@ -1,18 +1,6 @@ -/* -// Copyright (c) 2021 Intel Corporation +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -*/ #include "gather_nd_kernel_ref.h" #include "kernel_selector_utils.h" diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_nd_kernel_ref.h b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_nd_kernel_ref.h index 82fa0913413f34..ce449e229cbe0a 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_nd_kernel_ref.h +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_nd_kernel_ref.h @@ -1,18 +1,6 @@ -/* -// Copyright (c) 2021 Intel Corporation +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -*/ #pragma once diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_nd_kernel_selector.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_nd_kernel_selector.cpp index 82c938d08c9871..306f2b1a730342 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_nd_kernel_selector.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_nd_kernel_selector.cpp @@ -1,18 +1,6 @@ -/* -// Copyright (c) 2021 Intel Corporation +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -*/ #include "gather_nd_kernel_selector.h" #include "gather_nd_kernel_ref.h" diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_nd_kernel_selector.h b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_nd_kernel_selector.h index e4d2ca1edb4149..e97add6ee369e8 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_nd_kernel_selector.h +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_nd_kernel_selector.h @@ -1,18 +1,6 @@ -/* -// Copyright (c) 2021 Intel Corporation +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -*/ #pragma once diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_elt_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_elt_kernel_base.cpp index d91ff0926bb3fc..587832da828038 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_elt_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_elt_kernel_base.cpp @@ -80,12 +80,12 @@ KernelsData LSTMEltKernelBase::GetCommonKernelsData(const Params& params, const auto entryPoint = GetEntryPoint(kernelName, newParams.layerID, options); auto jit = CreateJit(kernelName, cldnnJit, entryPoint); - kernel.workGroups.global = {out.X().v, out.Batch().v, 1}; - kernel.kernelString = GetKernelString(kernelName, jit, entryPoint, params.engineInfo); - kernel.arguments.push_back({ArgumentDescriptor::Types::INPUT, 0}); - kernel.arguments.push_back({ArgumentDescriptor::Types::OUTPUT, 0}); + kernel.params.workGroups.global = {out.X().v, out.Batch().v, 1}; + kernel.code.kernelString = GetKernelString(kernelName, jit, entryPoint, params.engineInfo); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 0}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::OUTPUT, 0}); if (orgParams.has_cell) { - kernel.arguments.push_back({ArgumentDescriptor::Types::CELL, 0}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::CELL, 0}); } return {kd}; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_gemm_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_gemm_kernel_base.cpp index b7b4d4b0113be3..e4b547deacbcc5 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_gemm_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_gemm_kernel_base.cpp @@ -50,17 +50,17 @@ KernelsData LSTMGemmKernelBase::GetCommonKernelsData(const Params& params, const auto entryPoint = GetEntryPoint(kernelName, newParams.layerID, options); auto jit = CreateJit(kernelName, cldnnJit, entryPoint); - kernel.workGroups.global = {out.X().v, out.Batch().v, 1}; - kernel.kernelString = GetKernelString(kernelName, jit, entryPoint, params.engineInfo); - kernel.arguments.push_back({ArgumentDescriptor::Types::INPUT, 0}); - kernel.arguments.push_back({ArgumentDescriptor::Types::OUTPUT, 0}); - kernel.arguments.push_back({ArgumentDescriptor::Types::WEIGHTS, 0}); + kernel.params.workGroups.global = {out.X().v, out.Batch().v, 1}; + kernel.code.kernelString = GetKernelString(kernelName, jit, entryPoint, params.engineInfo); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 0}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::OUTPUT, 0}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::WEIGHTS, 0}); if (orgParams.hasHidden) { - kernel.arguments.push_back({ArgumentDescriptor::Types::HIDDEN, 0}); - kernel.arguments.push_back({ArgumentDescriptor::Types::RECURRENT, 0}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::HIDDEN, 0}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::RECURRENT, 0}); } if (orgParams.hasBias) { - kernel.arguments.push_back({ArgumentDescriptor::Types::BIAS, 0}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::BIAS, 0}); } return {kd}; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_gemv_gpu_subgroup1x64_bfyx_ff_simd16.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_gemv_gpu_subgroup1x64_bfyx_ff_simd16.cpp index b5c2d1a482a787..f94f1c6bb418d0 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_gemv_gpu_subgroup1x64_bfyx_ff_simd16.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_gemv_gpu_subgroup1x64_bfyx_ff_simd16.cpp @@ -36,7 +36,7 @@ KernelsData LSTMGemvKernel_subgroup1x64_bfyx_ff_SIMD16::GetKernelsData(const Par const auto& out = orgParams.output; if ((input.Batch().v == 1) && (input.X().v >= 64) && (input.Y().v == 1)) - kernel.workGroups.global = {16, out.X().v, out.Batch().v}; + kernel.params.workGroups.global = {16, out.X().v, out.Batch().v}; return kernelsData; } diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_gemv_gpu_subgroup1x64_bfyx_hh_simd16.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_gemv_gpu_subgroup1x64_bfyx_hh_simd16.cpp index 437fc621fbc320..437dc458c265c7 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_gemv_gpu_subgroup1x64_bfyx_hh_simd16.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_gemv_gpu_subgroup1x64_bfyx_hh_simd16.cpp @@ -36,7 +36,7 @@ KernelsData LSTMGemvKernel_subgroup1x64_bfyx_hh_SIMD16::GetKernelsData(const Par const auto& out = orgParams.output; if ((input.Batch().v == 1) && (input.X().v >= 64) && (input.Y().v == 1)) - kernel.workGroups.global = {16, out.X().v, out.Batch().v}; + kernel.params.workGroups.global = {16, out.X().v, out.Batch().v}; return kernelsData; } diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_input_bfyx_opt.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_input_bfyx_opt.cpp index 16271d23130e47..dfd13d8ce5bc83 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_input_bfyx_opt.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_input_bfyx_opt.cpp @@ -89,9 +89,9 @@ KernelsData LSTM_DynamicInputKernelBfyxOpt::GetKernelsData(const Params& params, auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; - kernel.workGroups.global = dispatchData.gws; - kernel.workGroups.local = dispatchData.lws; - kernel.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo); + kernel.params.workGroups.global = dispatchData.gws; + kernel.params.workGroups.local = dispatchData.lws; + kernel.code.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo); SetKernelArguments(dlstm_params, kernel); return { kd }; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_input_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_input_kernel_base.cpp index 8066bf61831f32..2a1491fb41b583 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_input_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_input_kernel_base.cpp @@ -36,12 +36,12 @@ LSTM_DynamicInputKernelBase::DispatchData LSTM_DynamicInputKernelBase::SetDefaul } void kernel_selector::LSTM_DynamicInputKernelBase::SetKernelArguments(const lstm_dynamic_input_params& params, clKernelData& kernel) const { - kernel.arguments.push_back({ ArgumentDescriptor::Types::INPUT, 0 }); - kernel.arguments.push_back({ ArgumentDescriptor::Types::INPUT, 1 }); - kernel.arguments.push_back({ ArgumentDescriptor::Types::OUTPUT, 0 }); - kernel.arguments.push_back({ ArgumentDescriptor::Types::WEIGHTS, 0 }); + kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INPUT, 0 }); + kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INPUT, 1 }); + kernel.params.arguments.push_back({ ArgumentDescriptor::Types::OUTPUT, 0 }); + kernel.params.arguments.push_back({ ArgumentDescriptor::Types::WEIGHTS, 0 }); if (!params.bias.empty()) { - kernel.arguments.push_back({ ArgumentDescriptor::Types::BIAS, 0 }); + kernel.params.arguments.push_back({ ArgumentDescriptor::Types::BIAS, 0 }); } } @@ -61,8 +61,8 @@ KernelsData LSTM_DynamicInputKernelBase::GetCommonKernelsData(const Params& para auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = k_data.kernels[0]; - kernel.workGroups.global = dispatchData.gws; - kernel.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo); + kernel.params.workGroups.global = dispatchData.gws; + kernel.code.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo); SetKernelArguments(orgParams, kernel); return {k_data}; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_timeloop_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_timeloop_kernel_base.cpp index a39c724c92751f..8327a025c8e985 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_timeloop_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_timeloop_kernel_base.cpp @@ -87,21 +87,21 @@ LSTM_DynamicTimeloopKernelBase::DispatchData LSTM_DynamicTimeloopKernelBase::Set void kernel_selector::LSTM_DynamicTimeloopKernelBase::SetKernelArguments(const lstm_dynamic_timeloop_params& params, clKernelData& kernel) const { uint32_t input_idx = 0; - kernel.arguments.push_back({ ArgumentDescriptor::Types::INPUT, input_idx++ }); - kernel.arguments.push_back({ ArgumentDescriptor::Types::INPUT, input_idx++ }); - kernel.arguments.push_back({ ArgumentDescriptor::Types::OUTPUT, 0 }); - kernel.arguments.push_back({ ArgumentDescriptor::Types::RECURRENT, 0 }); + kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INPUT, input_idx++ }); + kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INPUT, input_idx++ }); + kernel.params.arguments.push_back({ ArgumentDescriptor::Types::OUTPUT, 0 }); + kernel.params.arguments.push_back({ ArgumentDescriptor::Types::RECURRENT, 0 }); if (params.has_hidden) { - kernel.arguments.push_back({ ArgumentDescriptor::Types::HIDDEN, 0 }); + kernel.params.arguments.push_back({ ArgumentDescriptor::Types::HIDDEN, 0 }); } if (params.has_cell) { - kernel.arguments.push_back({ ArgumentDescriptor::Types::CELL, 0 }); + kernel.params.arguments.push_back({ ArgumentDescriptor::Types::CELL, 0 }); } if (params.has_last_hidden_output) { - kernel.arguments.push_back({ ArgumentDescriptor::Types::INPUT, input_idx++ }); + kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INPUT, input_idx++ }); } if (params.has_last_cell_output) { - kernel.arguments.push_back({ ArgumentDescriptor::Types::INPUT, input_idx++ }); + kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INPUT, input_idx++ }); } } @@ -122,9 +122,9 @@ KernelsData LSTM_DynamicTimeloopKernelBase::GetCommonKernelsData(const Params& p auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = k_data.kernels[0]; - kernel.workGroups.global = dispatchData.gws; - kernel.workGroups.local = dispatchData.lws; - kernel.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo); + kernel.params.workGroups.global = dispatchData.gws; + kernel.params.workGroups.local = dispatchData.lws; + kernel.code.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo); SetKernelArguments(org_params, kernel); return {k_data}; } diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/max_unpooling/max_unpooling_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/max_unpooling/max_unpooling_kernel_base.cpp index b34c674a75500c..5534217a9ce900 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/max_unpooling/max_unpooling_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/max_unpooling/max_unpooling_kernel_base.cpp @@ -70,7 +70,7 @@ KernelsData MaxUnpoolingKernelBase::GetCommonKernelsData(const Params& params, auto& kernel = kd.kernels[0]; FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point); - kernel.arguments.push_back({ArgumentDescriptor::Types::INPUT, 1}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 1}); return {kd}; } diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/mvn/mvn_kernel_b_fs_yx_fsv16_imad.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/mvn/mvn_kernel_b_fs_yx_fsv16_imad.cpp index 670f831594d51c..32fd8e5744cc4c 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/mvn/mvn_kernel_b_fs_yx_fsv16_imad.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/mvn/mvn_kernel_b_fs_yx_fsv16_imad.cpp @@ -200,9 +200,9 @@ KernelsData MVNKernel_b_fs_yx_fsv16_imad::GetMultiStageKernelsData(const mvn_par false, 0, 0); - kernel.arguments.clear(); // Clear original output argument - kernel.arguments.push_back({ArgumentDescriptor::Types::INPUT, 0}); - kernel.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0}); + kernel.params.arguments.clear(); // Clear original output argument + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 0}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0}); kd.internalBufferSizes.push_back(params.output.Batch().v * Align(params.output.Feature().v, fsv) * dispatchData.item_groups * intermidiate_bytes); } @@ -224,9 +224,9 @@ KernelsData MVNKernel_b_fs_yx_fsv16_imad::GetMultiStageKernelsData(const mvn_par false, 0, 0); - kernel.arguments.clear(); // Clear original output argument - kernel.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0}); - kernel.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 1}); + kernel.params.arguments.clear(); // Clear original output argument + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 1}); kd.internalBufferSizes.push_back(params.output.Batch().v * Align(params.output.Feature().v, fsv) * intermidiate_bytes); } @@ -248,10 +248,10 @@ KernelsData MVNKernel_b_fs_yx_fsv16_imad::GetMultiStageKernelsData(const mvn_par false, 0, 0); - kernel.arguments.clear(); // Clear original output argument - kernel.arguments.push_back({ArgumentDescriptor::Types::INPUT, 0}); - kernel.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 1}); - kernel.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0}); + kernel.params.arguments.clear(); // Clear original output argument + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 0}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 1}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0}); } if (params.mvnNormalizeVariance) { // Variance second stage @@ -271,9 +271,9 @@ KernelsData MVNKernel_b_fs_yx_fsv16_imad::GetMultiStageKernelsData(const mvn_par false, 0, 0); - kernel.arguments.clear(); // Clear original output argument - kernel.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0}); - kernel.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 2}); + kernel.params.arguments.clear(); // Clear original output argument + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 2}); kd.internalBufferSizes.push_back(params.output.Batch().v * Align(params.output.Feature().v, fsv) * intermidiate_bytes); } @@ -296,9 +296,9 @@ KernelsData MVNKernel_b_fs_yx_fsv16_imad::GetMultiStageKernelsData(const mvn_par false, 1, GetFusedPrimitiveInputsCount(params)); - kernel.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 1}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 1}); if (params.mvnNormalizeVariance) { - kernel.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 2}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 2}); } } kd.internalBufferDataType = Datatype::F32; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/normalize/normalize_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/normalize/normalize_kernel_base.cpp index 2e36b028e28b15..a5c6dde629d8c7 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/normalize/normalize_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/normalize/normalize_kernel_base.cpp @@ -72,7 +72,7 @@ KernelsData NormalizeKernelBase::GetCommonKernelsData(const Params& params, 1, GetFusedPrimitiveInputsCount(params)); - kernel.arguments.push_back({ArgumentDescriptor::Types::SCALE_TABLE, 0}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::SCALE_TABLE, 0}); return {kd}; } diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/pooling/pooling_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/pooling/pooling_kernel_base.cpp index eb4313f39bc71d..eb42f283703225 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/pooling/pooling_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/pooling/pooling_kernel_base.cpp @@ -182,7 +182,7 @@ KernelsData PoolingKernelBase::GetCommonKernelsData(const Params& params, FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point, DEFAULT, false, false, 1, GetFusedPrimitiveInputsCount(params)); if (orgParams.poolType == PoolType::MAX_WITH_ARGMAX) - kernel.arguments.push_back({ArgumentDescriptor::Types::INPUT, 1}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 1}); return {kd}; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/quantize/quantize_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/quantize/quantize_kernel_base.cpp index 457e90ba97e0fa..b6a6a6a71dba8b 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/quantize/quantize_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/quantize/quantize_kernel_base.cpp @@ -68,10 +68,10 @@ KernelsData QuantizeKernelBase::GetKernelsData(const Params& params, const optio auto& kernel = kd.kernels[0]; - kernel.workGroups.global = dispatchData.gws; - kernel.workGroups.local = dispatchData.lws; - kernel.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo, DEFAULT); - kernel.arguments = GetArgsDesc(static_cast(newParams.inputs.size()), false, false); + kernel.params.workGroups.global = dispatchData.gws; + kernel.params.workGroups.local = dispatchData.lws; + kernel.code.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo, DEFAULT); + kernel.params.arguments = GetArgsDesc(static_cast(newParams.inputs.size()), false, false); return {kd}; } diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reorder/reorder_biplanar_nv12.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reorder/reorder_biplanar_nv12.cpp index e88e3bb10195f3..2e8c89238eb2cf 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reorder/reorder_biplanar_nv12.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reorder/reorder_biplanar_nv12.cpp @@ -33,7 +33,7 @@ KernelsData reorder_biplanar_nv12::GetKernelsData(const Params& params, const op return {}; } KernelsData kd = GetCommonKernelsData(orgParams, options); - kd[0].kernels[0].arguments = GetArgsDesc(2, false, false); + kd[0].kernels[0].params.arguments = GetArgsDesc(2, false, false); return kd; } diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reorder/reorder_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reorder/reorder_kernel_base.cpp index cf227d83504e4d..9629aa2dbc1039 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reorder/reorder_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reorder/reorder_kernel_base.cpp @@ -206,7 +206,7 @@ KernelsData ReorderKernelBase::GetCommonKernelsData(const reorder_weights_params FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point); - kernel.arguments = GetArgsDesc(1, false, false); + kernel.params.arguments = GetArgsDesc(1, false, false); return {kd}; } @@ -230,9 +230,9 @@ KernelsData ReorderKernelBase::GetCommonKernelsData(const reorder_params& params FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point); - kernel.arguments = GetArgsDesc(1, false, false); + kernel.params.arguments = GetArgsDesc(1, false, false); if (newParams.mode == MeanSubtractMode::IN_BUFFER) { - kernel.arguments.push_back({ArgumentDescriptor::Types::BIAS, 0}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::BIAS, 0}); } return {kd}; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reshape/reshape_kernel_ref.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reshape/reshape_kernel_ref.cpp index 0a76fed62c7a47..401ffc73d9cf89 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reshape/reshape_kernel_ref.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reshape/reshape_kernel_ref.cpp @@ -56,10 +56,10 @@ KernelsData ReshapeKernelRef::GetKernelsData(const Params& params, const optiona gws2 *= in_dims[i].v; } - kernel.workGroups.global = {gws0, gws1, gws2}; - kernel.workGroups.local = GetOptimalLocalWorkGroupSizes(kernel.workGroups.global, params.engineInfo); - kernel.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo, DEFAULT); - kernel.arguments = GetArgsDesc(1, false, false); + kernel.params.workGroups.global = {gws0, gws1, gws2}; + kernel.params.workGroups.local = GetOptimalLocalWorkGroupSizes(kernel.params.workGroups.global, params.engineInfo); + kernel.code.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo, DEFAULT); + kernel.params.arguments = GetArgsDesc(1, false, false); return {kd}; } diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/roi_pooling/roi_pooling_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/roi_pooling/roi_pooling_kernel_base.cpp index 147c2551b281be..271929559c42cc 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/roi_pooling/roi_pooling_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/roi_pooling/roi_pooling_kernel_base.cpp @@ -55,9 +55,9 @@ KernelsData ROIPoolingKernelBase::GetCommonKernelsData(const Params& params, auto& kernel = kd.kernels[0]; FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point); - kernel.arguments.push_back({ArgumentDescriptor::Types::INPUT, 1}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 1}); if (orgParams.mode == PoolType::DEFORMABLE_BILINEAR && !orgParams.no_trans) - kernel.arguments.push_back({ArgumentDescriptor::Types::INPUT, 2}); + kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 2}); return {kd}; } diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/select/select_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/select/select_kernel_base.cpp index b827527d22af58..4228d9fabfba36 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/select/select_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/select/select_kernel_base.cpp @@ -131,11 +131,11 @@ KernelsData SelectKernelBase::GetCommonKernelsData(const Params& params, const o auto& kernel = kd.kernels[0]; - kernel.workGroups.global = dispatchData.gws; - kernel.workGroups.local = dispatchData.lws; + kernel.params.workGroups.global = dispatchData.gws; + kernel.params.workGroups.local = dispatchData.lws; - kernel.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo, DEFAULT); - kernel.arguments = GetArgsDesc((uint32_t)newParams.inputs.size(), false, false); + kernel.code.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo, DEFAULT); + kernel.params.arguments = GetArgsDesc((uint32_t)newParams.inputs.size(), false, false); return {kd}; } diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/auto_tuner.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/auto_tuner.cpp index bdef07b6f2964e..0c39d4e69231cd 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/auto_tuner.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/auto_tuner.cpp @@ -315,9 +315,11 @@ void AutoTuner::RemoveKernel(const std::string& cacheFilePath, } } -std::tuple AutoTuner::LoadKernelOffline(std::shared_ptr deviceCache, +std::tuple AutoTuner::LoadKernelOffline(TuningCache* deviceCache, const Params& params) { static const uint32_t defaultComputeUnits = 24; + if (!deviceCache) + return {}; auto result = deviceCache->LoadKernel(params, false); if (std::get<0>(result).empty() && params.engineInfo.computeUnitsCount != defaultComputeUnits) { result = deviceCache->LoadKernel(params, defaultComputeUnits); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/auto_tuner.h b/inference-engine/thirdparty/clDNN/kernel_selector/core/auto_tuner.h index 709f2955b6e657..22284622c3bf69 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/auto_tuner.h +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/auto_tuner.h @@ -74,7 +74,7 @@ class AutoTuner { const int tuneIndex); void RemoveKernel(const std::string& cacheFilePath, const Params& params); - std::tuple LoadKernelOffline(std::shared_ptr cache, + std::tuple LoadKernelOffline(TuningCache* cache, const Params& params); private: diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/cl_kernels/gather_nd_ref.cl b/inference-engine/thirdparty/clDNN/kernel_selector/core/cl_kernels/gather_nd_ref.cl index 91cb7d9be773e9..d59d93fec17326 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/cl_kernels/gather_nd_ref.cl +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/cl_kernels/gather_nd_ref.cl @@ -1,16 +1,6 @@ -// Copyright (c) 2021 Intel Corporation +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. #include "include/fetch.cl" diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/cl_kernels/max_unpooling_gpu_ref.cl b/inference-engine/thirdparty/clDNN/kernel_selector/core/cl_kernels/max_unpooling_gpu_ref.cl index 94e77fa113fb09..d8ad1abfd7a692 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/cl_kernels/max_unpooling_gpu_ref.cl +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/cl_kernels/max_unpooling_gpu_ref.cl @@ -4,7 +4,7 @@ #include "include/include_all.cl" -KERNEL(pooling_gpu)(const __global UNIT_TYPE* input, __global UNIT_TYPE* output, const __global float* arg_max) +KERNEL(pooling_gpu)(const __global INPUT0_TYPE* input, __global OUTPUT_TYPE* output, const __global float* arg_max) { #if OUTPUT_LAYOUT_BFYX || OUTPUT_LAYOUT_BYXF const uint x = (uint)get_global_id(0); @@ -12,7 +12,7 @@ KERNEL(pooling_gpu)(const __global UNIT_TYPE* input, __global UNIT_TYPE* output, const uint bf = (uint)get_global_id(2); const uint f = bf % INPUT0_FEATURE_NUM; const uint b = bf / INPUT0_FEATURE_NUM; - + if (x >= INPUT0_SIZE_X) { return; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/common/kernel_base_opencl.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/common/kernel_base_opencl.cpp index 392d0ed2bc2bb2..aae0e195279f8f 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/common/kernel_base_opencl.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/common/kernel_base_opencl.cpp @@ -182,9 +182,9 @@ void KernelBaseOpenCL::FillCLKernelData(clKernelData& kernel, int number_of_inputs, uint32_t number_of_inputs_for_fused_prims) const { KernelBase::CheckDispatchData(kernelMapName, dispatchData); - kernel.workGroups.global = dispatchData.gws; - kernel.workGroups.local = dispatchData.lws; - kernel.kernelString = GetKernelString(kernelMapName, jit, entryPoint, engine_info, exeMode); - kernel.arguments = GetArgsDesc(number_of_inputs, weights, bias, number_of_inputs_for_fused_prims); + kernel.code.kernelString = GetKernelString(kernelMapName, jit, entryPoint, engine_info, exeMode); + kernel.params.workGroups.global = dispatchData.gws; + kernel.params.workGroups.local = dispatchData.lws; + kernel.params.arguments = GetArgsDesc(number_of_inputs, weights, bias, number_of_inputs_for_fused_prims); } } // namespace kernel_selector diff --git a/inference-engine/thirdparty/clDNN/src/gpu/device_cache_reader.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/device_cache_reader.cpp similarity index 65% rename from inference-engine/thirdparty/clDNN/src/gpu/device_cache_reader.cpp rename to inference-engine/thirdparty/clDNN/kernel_selector/core/device_cache_reader.cpp index 0d0b310a1793a3..5a61c3c3131820 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/device_cache_reader.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/device_cache_reader.cpp @@ -3,13 +3,13 @@ // #include "device_cache_reader.h" -#include "include/to_string_utils.h" #include "auto_tuner.h" #include #include "istreamwrapper.h" #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN +#define NOMINMAX #include #include #include @@ -25,17 +25,15 @@ #include #include -namespace cldnn { -namespace gpu { -namespace { +namespace kernel_selector { -std::shared_ptr get_cache_from_file(std::string tuning_cache_path) { +std::shared_ptr CreateTuningCacheFromFile(std::string tuning_cache_path) { if (tuning_cache_path.compare("cache.json") == 0) { #ifdef _WIN32 char path[MAX_PATH]; HMODULE hm = NULL; GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, - (LPCSTR)&get_cache_from_file, + (LPCSTR)&CreateTuningCacheFromFile, &hm); GetModuleFileName(hm, path, sizeof(path)); std::string bin_path(path); @@ -51,19 +49,4 @@ std::shared_ptr get_cache_from_file(std::string tu return std::make_shared(tuning_cache_path, false); } -} // namespace - -device_cache_reader::device_cache_reader(const std::string tuning_file_path) { - { - try { - _dev_cache = get_cache_from_file(tuning_file_path); - } - catch (...) { - std::cout << "[WARNING] error during parsing cache file, tuning data won't be used" << std::endl; - _dev_cache = std::make_shared(); - } - } -} - -} // namespace gpu -} // namespace cldnn +} // namespace kernel_selector diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/device_cache_reader.h b/inference-engine/thirdparty/clDNN/kernel_selector/core/device_cache_reader.h new file mode 100644 index 00000000000000..9621296ddae07c --- /dev/null +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/device_cache_reader.h @@ -0,0 +1,14 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once +#include +#include + +namespace kernel_selector { +class TuningCache; + +std::shared_ptr CreateTuningCacheFromFile(std::string tuning_cache_path); + +} // namespace kernel_selector diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/kernel_selector.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/kernel_selector.cpp index 4d4a06b53fe8e9..2105b0436589b1 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/kernel_selector.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/kernel_selector.cpp @@ -13,6 +13,7 @@ #include #include #include +#include // #define ENABLE_ENV // #define ENABLE_ENV_PRINT @@ -105,7 +106,7 @@ KernelsData kernel_selector_base::GetNaiveBestKernel(const Params& params, // TODO: find a better place to located this assignment if (kernelsData.size()) { kernelsData[0].kernelName = kernelName; - kernelsData[0].kernels[0].layerID = params.layerID; + kernelsData[0].kernels[0].params.layerID = params.layerID; } return kernelsData; @@ -123,7 +124,7 @@ KernelsData kernel_selector_base::GetAutoTuneBestKernel(const Params& params, std::tuple cachedKernelConfig; if (options.tuningParams.mode == TuningMode::TUNING_DISABLED && !int8_kernel) { // Try to load kernel/config from offline cache #if ENABLE_OFFLINE_TUNING_CACHE - cachedKernelConfig = autoTuner.LoadKernelOffline(params.engineInfo.deviceCache, params); + cachedKernelConfig = autoTuner.LoadKernelOffline(params.engineInfo.deviceCache.get(), params); #else return GetNaiveBestKernel(params, options, kType); #endif @@ -145,7 +146,7 @@ KernelsData kernel_selector_base::GetAutoTuneBestKernel(const Params& params, if (kds.size() && kds[0].kernels.size()) { kernelsData = kds; kernelsData[0].kernelName = cachedkernelName; - kernelsData[0].kernels[0].layerID = params.layerID; + kernelsData[0].kernels[0].params.layerID = params.layerID; } break; } @@ -218,7 +219,7 @@ KernelsData kernel_selector_base::GetAutoTuneBestKernel(const Params& params, if (kernelsData.size()) { kernelsData[0].kernelName = kernelName; - kernelsData[0].kernels[0].layerID = params.layerID; + kernelsData[0].kernels[0].params.layerID = params.layerID; autoTuner.StoreKernel(options.tuningParams.cacheFilePath, params, kernelName, diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/kernel_selector_common.h b/inference-engine/thirdparty/clDNN/kernel_selector/core/kernel_selector_common.h index 5a0d62336cbd60..d0b0054f1b2dda 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/kernel_selector_common.h +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/kernel_selector_common.h @@ -5,6 +5,7 @@ #pragma once #include "kernel_selector_params.h" +#include "cldnn/runtime/kernel_args.hpp" #include #include @@ -41,118 +42,28 @@ namespace kernel_selector { std::string GetStringEnv(const char* varName); -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// KernelString -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -struct KernelString { - std::string str; - std::string jit; - std::string undefs; - std::string options; - std::string entry_point; - bool batch_compilation; - - KernelString() : str(""), jit(""), undefs(""), options(""), entry_point(""), batch_compilation(false) {} - - std::string get_hash() { return str + jit + undefs + options + entry_point; } -}; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// WorkGroupSizes -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -struct WorkGroupSizes { - std::vector global; - std::vector local; -}; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Scalar -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -struct ScalarDescriptor { - union ValueT { - uint8_t u8; - uint16_t u16; - uint32_t u32; - uint64_t u64; - int8_t s8; - int16_t s16; - int32_t s32; - int64_t s64; - float f32; - double f64; - }; - - enum class Types { - UINT8, - UINT16, - UINT32, - UINT64, - INT8, - INT16, - INT32, - INT64, - FLOAT32, - FLOAT64, - }; - - Types t; - ValueT v; -}; +using KernelString = cldnn::kernel_string; +using WorkGroupSizes = cldnn::work_group_sizes; +using ScalarDescriptor = cldnn::scalar_desc; +using Scalars = cldnn::scalars_desc; +using ArgumentDescriptor = cldnn::argument_desc; +using Arguments = cldnn::arguments_desc; +using KernelParams = cldnn::kernel_arguments_desc; -using Scalars = std::vector; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// ArgumentDescpirtor +// KernelCode //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -struct ArgumentDescriptor { - enum class Types { - INPUT, - OUTPUT, - WEIGHTS, - BIAS, - SCALE_TABLE, - SLOPE, - SPLIT, - INTERNAL_BUFFER, - SCALAR, - RECURRENT, // RNN/LSTM/GRU recurrent weights - HIDDEN, // RNN/LSTM/GRU hidden input - CELL, // LSTM cell input - LSTM_PACK, // LSTM packed output - WEIGHTS_ZERO_POINTS, - ACTIVATIONS_ZERO_POINTS, - COMPENSATION, - INPUT_OF_FUSED_PRIMITIVE - }; - - enum class ScalarTypes { - UINT8, - UINT16, - UINT32, - UINT64, - INT8, - INT16, - INT32, - INT64, - FLOAT32, - FLOAT64, - }; - - Types t; - uint32_t index; +struct KernelCode { + std::shared_ptr kernelString; }; -using Arguments = std::vector; - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // clKernelData //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// struct clKernelData { - std::shared_ptr kernelString; - WorkGroupSizes workGroups; - Arguments arguments; - Scalars scalars; - std::string layerID; // TODO: in order to support run single layer. think about more appropriate place + KernelCode code; + KernelParams params; }; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/inference-engine/thirdparty/clDNN/runtime/CMakeLists.txt b/inference-engine/thirdparty/clDNN/runtime/CMakeLists.txt new file mode 100644 index 00000000000000..1089d3f9baddf5 --- /dev/null +++ b/inference-engine/thirdparty/clDNN/runtime/CMakeLists.txt @@ -0,0 +1,79 @@ +# Copyright (C) 2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + +# =================================== Name / Output settings from parent =============================== + +set(CLDNN_BUILD__PROJ "cldnn_runtime") +set(CLDNN_BUILD__PROJ_LABEL "${CLDNN_BUILD__PROJ}") +set(CLDNN_BUILD__PROJ_OUTPUT_NAME "${CLDNN_BUILD__PROJ}${CLDNN__OUT_CPU_SUFFIX}") + +# ========================================== Compiler options ========================================== + +intel_config_flag_apply_settings( + CompilerOptions + CMAKE_CXX_FLAGS + ALL_PATTERN "" + SET + RttiEnabled + ) + +# ========================================= Source/Header files ======================================== + +set(__CLDNN_Directory__main "${CMAKE_CURRENT_SOURCE_DIR}") +set(__CLDNN_Label__main "") +file(GLOB __CLDNN_Sources__main + "${__CLDNN_Directory__main}/*.h" + "${__CLDNN_Directory__main}/*.hpp" + "${__CLDNN_Directory__main}/*.cpp" + ) + +file(GLOB __CLDNN_Sources__ocl + "${__CLDNN_Directory__main}/ocl/*.h" + "${__CLDNN_Directory__main}/ocl/*.hpp" + "${__CLDNN_Directory__main}/ocl/*.cpp" +) + +set(__CLDNN_AllSources + ${__CLDNN_Sources__main} + ${__CLDNN_Sources__ocl} + ) + +# =============================================== Filters ============================================== + +source_group("${__CLDNN_Label__main}" FILES ${__CLDNN_Sources__main}) + +# ===================================== Include/Link directories ======================================= + +include_directories( + "${CMAKE_CURRENT_SOURCE_DIR}/include" + "${__CLDNN_Directory__main}" + ) + +# =================================== Link targets and dependencies ==================================== + +# Main static library. +add_library("${CLDNN_BUILD__PROJ}" STATIC + ${__CLDNN_AllSources} + ) + +set_property(TARGET "${CLDNN_BUILD__PROJ}" PROPERTY PROJECT_LABEL "${CLDNN_BUILD__PROJ_LABEL}") +set_property(TARGET "${CLDNN_BUILD__PROJ}" PROPERTY OUTPUT_NAME "${CLDNN_BUILD__PROJ_OUTPUT_NAME}") + +if(COMMAND set_ie_threading_interface_for) + set_ie_threading_interface_for("${CLDNN_BUILD__PROJ}") +endif() + +target_link_libraries("${CLDNN_BUILD__PROJ}" PRIVATE + clDNN_OpenCL + openvino::itt + ) + +if(WIN32) + target_link_libraries("${CLDNN_BUILD__PROJ}" PRIVATE setupapi) +elseif((NOT ANDROID) AND (UNIX)) + target_link_libraries("${CLDNN_BUILD__PROJ}" PRIVATE pthread) +endif() +target_link_libraries("${CLDNN_BUILD__PROJ}" PRIVATE ${CLDNN__SYSTEM_LINK_LIBRARIES}) + +# ====================================================================================================== diff --git a/inference-engine/thirdparty/clDNN/src/include/cldnn_itt.h b/inference-engine/thirdparty/clDNN/runtime/cldnn_itt.hpp similarity index 92% rename from inference-engine/thirdparty/clDNN/src/include/cldnn_itt.h rename to inference-engine/thirdparty/clDNN/runtime/cldnn_itt.hpp index b28db96f29567f..e3ab2d3ddb49fd 100644 --- a/inference-engine/thirdparty/clDNN/src/include/cldnn_itt.h +++ b/inference-engine/thirdparty/clDNN/runtime/cldnn_itt.hpp @@ -4,7 +4,7 @@ /** * @brief Defines openvino domains for tracing - * @file cldnn_itt.h + * @file cldnn_itt.hpp */ #pragma once diff --git a/inference-engine/thirdparty/clDNN/runtime/device_query.cpp b/inference-engine/thirdparty/clDNN/runtime/device_query.cpp new file mode 100644 index 00000000000000..46f2de82c8c800 --- /dev/null +++ b/inference-engine/thirdparty/clDNN/runtime/device_query.cpp @@ -0,0 +1,30 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "cldnn/runtime/device_query.hpp" +#include "ocl/ocl_device_detector.hpp" + +#include +#include + +namespace cldnn { + +device_query::device_query(engine_types engine_type, runtime_types runtime_type, void* user_context, void* user_device) { + switch (engine_type) { + case engine_types::ocl: { + if (runtime_type != runtime_types::ocl) + throw std::runtime_error("Unsupported runtime type for ocl engine"); + + ocl::ocl_device_detector ocl_detector; + _available_devices = ocl_detector.get_available_devices(user_context, user_device); + break; + } + default: throw std::runtime_error("Unsupported engine type in device_query"); + } + + if (_available_devices.empty()) { + throw std::runtime_error("No suitable devices found for requested engine and runtime types"); + } +} +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/runtime/engine.cpp b/inference-engine/thirdparty/clDNN/runtime/engine.cpp new file mode 100644 index 00000000000000..561f38f00f4231 --- /dev/null +++ b/inference-engine/thirdparty/clDNN/runtime/engine.cpp @@ -0,0 +1,160 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "cldnn/runtime/engine.hpp" +#include "cldnn/runtime/event.hpp" +#include "cldnn/runtime/memory.hpp" +#include "cldnn/runtime/stream.hpp" +#include "cldnn/runtime/device_query.hpp" + +#include "ocl/ocl_engine_factory.hpp" + +#include +#include +#include +#include +#include + +namespace cldnn { + +engine::engine(const device::ptr device, const engine_configuration& configuration) +: _memory_pool(new memory_pool(*this)) +, _device(device) +, _configuration(configuration) {} + +device_info engine::get_device_info() const { + return _device->get_info(); +} + +const device::ptr engine::get_device() const { + return _device; +} + +bool engine::use_unified_shared_memory() const { + if (_device->get_mem_caps().supports_usm() && _configuration.use_unified_shared_memory) { + return true; + } + return false; +} + +bool engine::supports_allocation(allocation_type type) const { + if (memory_capabilities::is_usm_type(type) && !use_unified_shared_memory()) + return false; + if (allocation_type::usm_shared == type) + return false; + return _device->get_mem_caps().support_allocation_type(type); +} + +allocation_type engine::get_lockable_preffered_memory_allocation_type(bool is_image_layout) const { + if (!use_unified_shared_memory() || is_image_layout) + return get_default_allocation_type(); + + /* + We do not check device allocation here. + Device allocation is reserved for buffers of hidden layers. + Const buffers are propagated to device if possible. + */ + + bool support_usm_host = supports_allocation(allocation_type::usm_host); + bool support_usm_shared = supports_allocation(allocation_type::usm_shared); + + if (support_usm_shared) + return allocation_type::usm_shared; + if (support_usm_host) + return allocation_type::usm_host; + + throw std::runtime_error("[clDNN internal error] Could not find proper allocation type!"); +} + +memory::ptr engine::get_memory_from_pool(const layout& layout, + primitive_id id, + uint32_t network_id, + std::set dependencies, + allocation_type type, + bool reusable) { + if (_configuration.use_memory_pool) + return _memory_pool->get_memory(layout, id, network_id, dependencies, type, reusable); + return _memory_pool->get_memory(layout, type); +} + +memory::ptr engine::attach_memory(const layout& layout, void* ptr) { + return std::make_shared(layout, ptr); +} + +memory::ptr engine::allocate_memory(const layout& layout, bool reset) { + allocation_type type = get_lockable_preffered_memory_allocation_type(layout.format.is_image_2d()); + return allocate_memory(layout, type, reset); +} + +memory_ptr engine::share_buffer(const layout& layout, shared_handle buf) { + shared_mem_params params = { shared_mem_type::shared_mem_buffer, nullptr, nullptr, buf, +#ifdef _WIN32 + nullptr, +#else + 0, +#endif + 0 }; + return reinterpret_handle(layout, params); +} + +memory::ptr engine::share_image(const layout& layout, shared_handle img) { + shared_mem_params params = { shared_mem_type::shared_mem_image, nullptr, nullptr, img, +#ifdef _WIN32 + nullptr, +#else + 0, +#endif + 0 }; + return reinterpret_handle(layout, params); +} + +#ifdef _WIN32 +memory_ptr engine::share_surface(const layout& layout, shared_handle surf, uint32_t plane) { + shared_mem_params params = { shared_mem_type::shared_mem_vasurface, nullptr, nullptr, nullptr, surf, plane }; + return reinterpret_handle(layout, params); +} + +memory_ptr engine::share_dx_buffer(const layout& layout, shared_handle res) { + shared_mem_params params = { shared_mem_type::shared_mem_dxbuffer, nullptr, nullptr, res, nullptr, 0 }; + return reinterpret_handle(layout, params); +} +#else +memory_ptr engine::share_surface(const layout& layout, shared_surface surf, uint32_t plane) { + shared_mem_params params = { shared_mem_type::shared_mem_vasurface, nullptr, nullptr, nullptr, surf, plane }; + return reinterpret_handle(layout, params); +} +#endif // _WIN32 + +memory_pool& engine::get_memory_pool() { + return *_memory_pool.get(); +} + +uint64_t engine::get_max_used_device_memory() const { + return _memory_pool->get_max_peak_device_memory_used(); +} + +uint64_t engine::get_used_device_memory() const { + return _memory_pool->get_temp_memory_used(); +} + +std::shared_ptr engine::create(engine_types engine_type, + runtime_types runtime_type, + const device::ptr device, + const engine_configuration& configuration) { + switch (engine_type) { + case engine_types::ocl: return ocl::create_ocl_engine(device, runtime_type, configuration); + default: throw std::runtime_error("Invalid engine type"); + } +} + +std::shared_ptr engine::create(engine_types engine_type, + runtime_types runtime_type, + const engine_configuration& configuration) { + device_query query(engine_type, runtime_type); + device::ptr default_device = query.get_available_devices().begin()->second; + + return engine::create(engine_type, runtime_type, default_device, configuration); +} + +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/runtime/event.cpp b/inference-engine/thirdparty/clDNN/runtime/event.cpp new file mode 100644 index 00000000000000..b9a61138cf12bf --- /dev/null +++ b/inference-engine/thirdparty/clDNN/runtime/event.cpp @@ -0,0 +1,69 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "cldnn/runtime/event.hpp" +#include "cldnn/runtime/engine.hpp" + +#include +#include +#include + +namespace cldnn { + +void event::wait() { + if (_set) + return; + + // TODO: refactor in context of multiple simultaneous calls (for generic engine) + wait_impl(); + _set = true; + return; +} + +bool event::is_set() { + if (_set) + return true; + + // TODO: refactor in context of multiple simultaneous calls (for generic engine) + _set = is_set_impl(); + return _set; +} + +bool event::add_event_handler(event_handler handler, void* data) { + if (is_set()) { + handler(data); + return true; + } + + std::lock_guard lock(_handlers_mutex); + auto itr = _handlers.insert(_handlers.end(), {handler, data}); + auto ret = add_event_handler_impl(handler, data); + if (!ret) + _handlers.erase(itr); + + return ret; +} + +std::vector event::get_profiling_info() { + if (!_profiling_captured) { + _profiling_captured = get_profiling_info_impl(_profiling_info); + } + + std::vector result(_profiling_info.size()); + std::copy(_profiling_info.begin(), _profiling_info.end(), result.begin()); + return result; +} + +void event::call_handlers() { + std::lock_guard lock(_handlers_mutex); + for (auto& pair : _handlers) { + try { + pair.first(pair.second); + } catch (...) { + } + } + _handlers.clear(); +} + +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/kernels_cache.cpp b/inference-engine/thirdparty/clDNN/runtime/kernels_cache.cpp similarity index 82% rename from inference-engine/thirdparty/clDNN/src/gpu/kernels_cache.cpp rename to inference-engine/thirdparty/clDNN/runtime/kernels_cache.cpp index 1451d68de5f402..014486841f04bc 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/kernels_cache.cpp +++ b/inference-engine/thirdparty/clDNN/runtime/kernels_cache.cpp @@ -2,9 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include "kernels_cache.h" -#include "ocl_toolkit.h" +#include "kernels_factory.hpp" +#include "kernels_cache.hpp" +#include "ocl/ocl_engine.hpp" + #include #include #include @@ -13,8 +14,8 @@ #include #include #include -#include "kernel_selector_helper.h" -#include "cldnn_itt.h" + +#include "cldnn_itt.hpp" #if (CLDNN_THREADING == CLDNN_THREADING_TBB) #include #include @@ -137,10 +138,11 @@ inline bool does_options_support_batch_compilation(const std::string& options) { } // namespace namespace cldnn { -namespace gpu { + +std::mutex kernels_cache::_mutex; std::string kernels_cache::get_cache_path() const { - auto path = _context.get_configuration().kernels_cache_path; + auto path = _engine.configuration().kernels_cache_path; if (path.empty()) { return {}; } @@ -152,7 +154,7 @@ std::string kernels_cache::get_cache_path() const { } bool kernels_cache::is_cache_enabled() const { - return !_context.get_configuration().kernels_cache_path.empty(); + return !_engine.configuration().kernels_cache_path.empty(); } size_t kernels_cache::get_max_kernels_per_batch() const { @@ -171,7 +173,6 @@ void kernels_cache::get_program_source(const kernels_code& kernels_source_code, std::string options = code.kernel_strings->options; bool batch_compilation = code.kernel_strings->batch_compilation; bool dump_custom_program = code.dump_custom_program; - bool one_time_kernel = code.one_time_kernel; batch_compilation &= does_options_support_batch_compilation(options); @@ -189,9 +190,6 @@ void kernels_cache::get_program_source(const kernels_code& kernels_source_code, key += " __DUMP_CUSTOM_PROGRAM__"; // Adding label to key so it would be separated from other programs } - if (one_time_kernel) { - key += " __ONE_TIME__"; - } auto& current_bucket = program_buckets[key]; if (current_bucket.empty()) { // new bucket const auto& bucket_id = program_buckets.size() - 1; @@ -212,7 +210,6 @@ void kernels_cache::get_program_source(const kernels_code& kernels_source_code, auto& current_batch = current_bucket.back(); current_batch.dump_custom_program = dump_custom_program; - current_batch.one_time = one_time_kernel; current_batch.entry_point_to_id[entry_point] = code.id; assert(org_source_code.size() == 1); @@ -230,7 +227,7 @@ void kernels_cache::get_program_source(const kernels_code& kernels_source_code, auto options = c.first; auto& batches = c.second; for (auto& b : batches) { - std::string full_code = options + " " + _context.get_device_info().driver_version; + std::string full_code = options + " " + _engine.get_device_info().driver_version; for (auto& ss : b.source) full_code += ss; b.hash_value = std::hash()(full_code); @@ -239,20 +236,17 @@ void kernels_cache::get_program_source(const kernels_code& kernels_source_code, } } -kernels_cache::kernels_cache(gpu_toolkit& context, uint32_t prog_id) : _context(context), _prog_id(prog_id) { -} +kernels_cache::kernels_cache(engine& engine) : _engine(engine) { } -kernels_cache::kernel_id kernels_cache::set_kernel_source( - const std::shared_ptr& kernel_string, - bool dump_custom_program, - bool one_time_kernel) { - std::lock_guard lock(_context.get_cache_mutex()); +kernel_id kernels_cache::set_kernel_source( + const std::shared_ptr& kernel_string, + bool dump_custom_program) { // we need unique id in order to avoid conflict across topologies. const auto kernel_num = _kernels.size() + _kernels_code.size(); - kernels_cache::kernel_id id = kernel_string->entry_point + "_" + std::to_string(kernel_num); + kernel_id id = kernel_string->entry_point + "_" + std::to_string(kernel_num); - auto res = _kernels_code.emplace(kernel_string, id, dump_custom_program, one_time_kernel); + auto res = _kernels_code.emplace(kernel_string, id, dump_custom_program); assert(_kernels.find(id) == _kernels.end()); if (res.second) { @@ -277,16 +271,19 @@ static std::vector getProgramBinaries(cl::Program program) { return program.getInfo().front(); } -void kernels_cache::build_batch(const batch_program& batch) { - OV_ITT_SCOPED_TASK(itt::domains::CLDNN, "KernelsCache::BuildProgram"); +// TODO: This build_batch method should be backend specific +void kernels_cache::build_batch(const engine& build_engine, const batch_program& batch) { + OV_ITT_SCOPED_TASK(itt::domains::CLDNN, "KernelsCache::build_batch"); - bool dump_sources = !_context.get_configuration().ocl_sources_dumps_dir.empty() || batch.dump_custom_program; + auto& cl_build_engine = dynamic_cast(build_engine); + + bool dump_sources = !_engine.configuration().sources_dumps_dir.empty() || batch.dump_custom_program; std::string err_log; // accumulated build log from all program's parts (only contains messages from parts which std::string current_dump_file_name = ""; if (dump_sources) { - current_dump_file_name = _context.get_configuration().ocl_sources_dumps_dir; + current_dump_file_name = _engine.configuration().sources_dumps_dir; if (!current_dump_file_name.empty() && current_dump_file_name.back() != '/') current_dump_file_name += '/'; @@ -318,10 +315,10 @@ void kernels_cache::build_batch(const batch_program& batch) { // Run compilation if (precompiled_kernels.empty()) { - cl::Program program(_context.context(), batch.source); + cl::Program program(cl_build_engine.get_cl_context(), batch.source); { OV_ITT_SCOPED_TASK(itt::domains::CLDNN, "KernelsCache::BuildProgram::RunCompilation"); - program.build(_context.device(), batch.options.c_str()); + program.build(cl_build_engine.get_cl_device(), batch.options.c_str()); } if (dump_sources && dump_file.good()) { @@ -342,23 +339,21 @@ void kernels_cache::build_batch(const batch_program& batch) { saveBinaryToFile(cached_bin_name, getProgramBinaries(program)); } } else { - cl::Program program(_context.context(), {_context.device()}, precompiled_kernels); - program.build(_context.device(), batch.options.c_str()); + cl::Program program(cl_build_engine.get_cl_context(), {cl_build_engine.get_cl_device()}, precompiled_kernels); + program.build(cl_build_engine.get_cl_device(), batch.options.c_str()); program.createKernels(&kernels); } { - std::lock_guard lock(_context.get_cache_mutex()); + std::lock_guard lock(_mutex); for (auto& k : kernels) { const auto& entry_point = k.getInfo(); const auto& k_id = batch.entry_point_to_id.find(entry_point); - const auto& k_type = kernel_type(k, _context.get_device_info().supports_usm); if (k_id != batch.entry_point_to_id.end()) { - const auto& kmap = std::make_pair(k_id->second, k_type); - if (batch.one_time) { - _one_time_kernels.insert(kmap); - } else { - _kernels.insert(kmap); - } + cl_kernel kern = k.get(); + cl_context context = cl_build_engine.get_cl_context().get(); + kernel::ptr kernel = kernels_factory::create(_engine, context, kern, entry_point); + const auto& kmap = std::make_pair(k_id->second, kernel); + _kernels.insert(kmap); } else { throw std::runtime_error("Could not find entry point"); } @@ -381,13 +376,12 @@ void kernels_cache::build_batch(const batch_program& batch) { } } -kernels_cache::kernel_type kernels_cache::get_kernel(kernel_id id, bool one_time_kernel) const { +kernel::ptr kernels_cache::get_kernel(kernel_id id) const { if (_pending_compilation) throw std::runtime_error("Kernel cache is not compiled, call build_all() first!"); - const auto& kernels = one_time_kernel ? _one_time_kernels : _kernels; - auto res = kernels.find(id); - if (kernels.end() == res) + auto res = _kernels.find(id); + if (_kernels.end() == res) throw std::runtime_error("Kernel " + id + " not found in the kernel cache!"); return res->second; } @@ -396,46 +390,50 @@ void kernels_cache::build_all() { OV_ITT_SCOPED_TASK(itt::domains::CLDNN, "KernelsCache::BuildAll"); if (!_pending_compilation) return; + + std::unique_ptr _build_engine = nullptr; + if (_engine.type() == engine_types::ocl) { + _build_engine = std::unique_ptr(new ocl::ocl_engine(_engine.get_device(), runtime_types::ocl, _engine.configuration())); + } std::vector batches; { - std::lock_guard lock(_context.get_cache_mutex()); + std::lock_guard lock(_mutex); get_program_source(_kernels_code, &batches); - _one_time_kernels.clear(); #if (CLDNN_THREADING == CLDNN_THREADING_TBB) - int n_threads = _context.get_configuration().n_threads; + int n_threads = _engine.configuration().n_threads; arena = std::unique_ptr(new tbb::task_arena()); arena->initialize(n_threads); #elif(CLDNN_THREADING == CLDNN_THREADING_THREADPOOL) - int n_threads = _context.get_configuration().n_threads; + int n_threads = _engine.configuration().n_threads; pool = std::unique_ptr(new thread_pool(n_threads)); #endif } #if (CLDNN_THREADING == CLDNN_THREADING_TBB) - arena->execute([this, &batches] { - tbb::parallel_for(tbb::blocked_range(0, batches.size()), [this, &batches](const tbb::blocked_range& r) { + arena->execute([this, &_build_engine, &batches] { + tbb::parallel_for(tbb::blocked_range(0, batches.size()), [this, &_build_engine, &batches](const tbb::blocked_range& r) { for (auto i = r.begin(); i != r.end(); ++i) { - build_batch(batches[i]); + build_batch(*_build_engine, batches[i]); } }); }); #elif(CLDNN_THREADING == CLDNN_THREADING_THREADPOOL) std::vector> builds; for (size_t i = 0; i < batches.size(); ++i) { - builds.push_back(pool->enqueue([this, &batches, i] () { - build_batch(batches[i]); + builds.push_back(pool->enqueue([this, &_build_engine, &batches, i] () { + build_batch(*_build_engine, batches[i]); })); } std::for_each(builds.begin(), builds.end(), [] (std::future& f) { f.wait(); }); #else // no parallel build for (const auto& batch : batches) { - build_batch(batch); + build_batch(*_build_engine, batch); } #endif { - std::lock_guard lock(_context.get_cache_mutex()); + std::lock_guard lock(_mutex); _kernels_code.clear(); _pending_compilation = false; #if (CLDNN_THREADING == CLDNN_THREADING_TBB) @@ -459,9 +457,8 @@ void kernels_cache::build_all() { void kernels_cache::reset() { _kernels.clear(); - _one_time_kernels.clear(); _kernels_code.clear(); _pending_compilation = false; } -} // namespace gpu + } // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/kernels_cache.h b/inference-engine/thirdparty/clDNN/runtime/kernels_cache.hpp similarity index 70% rename from inference-engine/thirdparty/clDNN/src/gpu/kernels_cache.h rename to inference-engine/thirdparty/clDNN/runtime/kernels_cache.hpp index 7cf31598bbf01a..931d267e955513 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/kernels_cache.h +++ b/inference-engine/thirdparty/clDNN/runtime/kernels_cache.hpp @@ -2,8 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once + +#include "cldnn/runtime/engine.hpp" +#include "cldnn/runtime/kernel.hpp" + #include #include #include @@ -11,7 +14,6 @@ #include #include #include -#include #define CLDNN_THREADING_SEQ 0 #define CLDNN_THREADING_TBB 1 @@ -26,19 +28,8 @@ #include #endif -namespace cl { -class Kernel; -class KernelIntel; -} - -namespace kernel_selector { -using kernel_string = kernel_selector::KernelString; -} - namespace cldnn { -namespace gpu { -class gpu_toolkit; #if (CLDNN_THREADING == CLDNN_THREADING_THREADPOOL) class thread_pool { public: @@ -101,6 +92,7 @@ class thread_pool { } }; #endif + class kernels_cache { public: using source_code = std::vector; @@ -112,24 +104,20 @@ class kernels_cache { uint32_t kernels_counter = 0; std::string options; bool dump_custom_program = false; - bool one_time = false; std::map entry_point_to_id; }; struct kernel_code { - std::shared_ptr kernel_strings; + std::shared_ptr kernel_strings; std::string id; bool dump_custom_program; - bool one_time_kernel; - kernel_code(const std::shared_ptr& _kernel_strings, + kernel_code(const std::shared_ptr& _kernel_strings, const std::string& _id, - bool _dump_custom_program, - bool _one_time_kernel) + bool _dump_custom_program) : kernel_strings(_kernel_strings), id(_id), - dump_custom_program(_dump_custom_program), - one_time_kernel(_one_time_kernel) {} + dump_custom_program(_dump_custom_program) {} bool operator == (const kernel_code& c2) const { return kernel_strings->get_hash() == c2.kernel_strings->get_hash(); @@ -142,44 +130,35 @@ class kernels_cache { } }; - typedef std::string kernel_id; - typedef cl::KernelIntel kernel_type; - using kernels_map = std::map; using kernels_code = std::unordered_set; private: - gpu_toolkit& _context; + static std::mutex _mutex; + engine& _engine; kernels_code _kernels_code; std::atomic _pending_compilation{false}; - std::map _kernels; - std::map _one_time_kernels; // These kernels are intended to be executed only once (can - // be removed later from the cache). - uint32_t _prog_id; + std::map _kernels; #if (CLDNN_THREADING == CLDNN_THREADING_TBB) std::unique_ptr arena; #elif(CLDNN_THREADING == CLDNN_THREADING_THREADPOOL) std::unique_ptr pool; #endif - void get_program_source(const kernels_code& kernels_source_code, std::vector*) const; - void build_batch(const batch_program& batch); + void build_batch(const engine& build_engine, const batch_program& batch); std::string get_cache_path() const; bool is_cache_enabled() const; size_t get_max_kernels_per_batch() const; public: - explicit kernels_cache(gpu_toolkit& context, uint32_t prog_id); - kernel_id set_kernel_source(const std::shared_ptr& kernel_string, - bool dump_custom_program, - bool one_time_kernel); - kernel_type get_kernel(kernel_id id, bool one_time_kernel) const; - gpu_toolkit& get_context() { return _context; } + explicit kernels_cache(engine& engine); + kernel_id set_kernel_source(const std::shared_ptr& kernel_string, + bool dump_custom_program); + kernel::ptr get_kernel(kernel_id id) const; // forces compilation of all pending kernels/programs void build_all(); void reset(); }; -} // namespace gpu } // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/runtime/kernels_factory.cpp b/inference-engine/thirdparty/clDNN/runtime/kernels_factory.cpp new file mode 100644 index 00000000000000..1cb366518a43aa --- /dev/null +++ b/inference-engine/thirdparty/clDNN/runtime/kernels_factory.cpp @@ -0,0 +1,22 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "kernels_factory.hpp" + +namespace cldnn { +namespace ocl { +std::shared_ptr create_ocl_kernel(engine& engine, cl_context context, cl_kernel kernel, std::string entry_point); +} // namespace ocl + +namespace kernels_factory { + +std::shared_ptr create(engine& engine, cl_context context, cl_kernel kernel, std::string entry_point) { + switch (engine.type()) { + case engine_types::ocl: return ocl::create_ocl_kernel(engine, context, kernel, entry_point); + default: throw std::runtime_error("Unsupported engine type in kernels_factory::create"); + } +} + +} // namespace kernels_factory +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/runtime/kernels_factory.hpp b/inference-engine/thirdparty/clDNN/runtime/kernels_factory.hpp new file mode 100644 index 00000000000000..b3d03defcb285b --- /dev/null +++ b/inference-engine/thirdparty/clDNN/runtime/kernels_factory.hpp @@ -0,0 +1,22 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "cldnn/runtime/kernel.hpp" +#include "cldnn/runtime/engine.hpp" +#include "ocl/ocl_common.hpp" + +#include + +namespace cldnn { + +namespace kernels_factory { + +// Creates instance of kernel for selected engine type. +// For ocl engine it creates a copy of kernel object +std::shared_ptr create(engine& engine, cl_context context, cl_kernel kernel, kernel_id kernel_id); + +} // namespace kernels_factory +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/runtime/memory.cpp b/inference-engine/thirdparty/clDNN/runtime/memory.cpp new file mode 100644 index 00000000000000..1a6ff65795b461 --- /dev/null +++ b/inference-engine/thirdparty/clDNN/runtime/memory.cpp @@ -0,0 +1,36 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "cldnn/runtime/memory.hpp" +#include "cldnn/runtime/engine.hpp" +#include "cldnn/runtime/stream.hpp" + +#include "ocl/ocl_memory.hpp" + +#include +#include +#include +#include +#include + +namespace cldnn { + +memory::memory(engine* engine, const layout& layout, allocation_type type, bool reused) + : _engine(engine), _layout(layout), _bytes_count(_layout.bytes_count()), _type(type), _reused(reused) {} + +memory::~memory() { + if (!_reused && _engine) { + // TODO: Make memory usage tracker static in memory class + _engine->get_memory_pool().subtract_memory_used(_bytes_count); + } +} + +std::unique_ptr surfaces_lock::create(engine_types engine_type, std::vector mem, const stream& stream) { + switch (engine_type) { + case engine_types::ocl: return std::unique_ptr(new ocl::ocl_surfaces_lock(mem, stream)); + default: throw std::runtime_error("Unsupported engine type in surfaces_lock::create"); + } +} + +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/memory_pool.cpp b/inference-engine/thirdparty/clDNN/runtime/memory_pool.cpp similarity index 55% rename from inference-engine/thirdparty/clDNN/src/memory_pool.cpp rename to inference-engine/thirdparty/clDNN/runtime/memory_pool.cpp index f80e8e9cd986bb..85091ccdd18e88 100644 --- a/inference-engine/thirdparty/clDNN/src/memory_pool.cpp +++ b/inference-engine/thirdparty/clDNN/runtime/memory_pool.cpp @@ -2,20 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// - #include #include #include -#include "memory_impl.h" -#include "memory_pool.h" -#include "engine_impl.h" -#include "program_impl.h" - -#include "program_node.h" +#include "cldnn/runtime/memory.hpp" +#include "cldnn/runtime/engine.hpp" +#include "cldnn/runtime/memory_pool.hpp" -#include "gpu/memory_gpu.h" #include #include #include @@ -24,88 +18,17 @@ namespace cldnn { memory_record::memory_record(memory_set users, - refcounted_obj_ptr& memory, + std::shared_ptr& memory, uint32_t net_id, allocation_type type) : _users(users), _memory(memory), _network_id(net_id), _type(type) {} -memory_impl::ptr memory_pool::alloc_memory(const layout& layout, allocation_type type, uint32_t net_id, bool reset) { - auto context = _engine->get_context(); - if (layout.bytes_count() > context->get_device_info().max_alloc_mem_size) { - throw std::runtime_error("exceeded max size of memory object allocation"); - } - - add_memory_used(layout.bytes_count()); - - if (_max_peak_memory_used > context->get_device_info().max_global_mem_size) { +memory::ptr memory_pool::alloc_memory(const layout& layout, allocation_type type) { + if (_max_peak_memory_used > _engine->get_device_info().max_global_mem_size) { throw std::runtime_error("exceeded global device memory"); } - try { - if (layout.format.is_image_2d()) { - memory_impl::ptr mem_impl {new gpu::gpu_image2d(engine_impl::ptr(_engine), layout, net_id, reset), false}; - return mem_impl; - } else if (type == allocation_type::cl_mem) { - memory_impl::ptr mem_impl{ new gpu::gpu_buffer(engine_impl::ptr(_engine), layout, net_id, reset), false }; - return mem_impl; - } else { - memory_impl::ptr mem_impl{ new gpu::gpu_usm(engine_impl::ptr(_engine), layout, net_id, type, reset), false }; - return mem_impl; - } - } catch (const cl::Error& clErr) { - switch (clErr.err()) { - case CL_MEM_OBJECT_ALLOCATION_FAILURE: - case CL_OUT_OF_RESOURCES: - case CL_OUT_OF_HOST_MEMORY: - case CL_INVALID_BUFFER_SIZE: - throw std::runtime_error("out of GPU resources"); - default: - throw std::runtime_error("GPU buffer allocation failed"); - } - } -} - -memory_impl::ptr memory_pool::get_memory(const layout& layout, const shared_mem_params* params, uint32_t net_id) { - try { - if (layout.format.is_image_2d() && params->mem_type == shared_mem_type::shared_mem_image) { - cl::Image2D img(static_cast(params->mem), true); - memory_impl::ptr mem_impl{ new gpu::gpu_image2d(engine_impl::ptr(_engine), layout, - img, - net_id), false }; - return mem_impl; - } else if (layout.format.is_image_2d() && params->mem_type == shared_mem_type::shared_mem_vasurface) { - memory_impl::ptr mem_impl{ new gpu::gpu_media_buffer(engine_impl::ptr(_engine), layout, - params, - net_id), false }; - return mem_impl; -#ifdef _WIN32 - } else if (params->mem_type == shared_mem_type::shared_mem_dxbuffer) { - memory_impl::ptr mem_impl{ new gpu::gpu_dx_buffer(engine_impl::ptr(_engine), layout, - params, - net_id), false }; - return mem_impl; -#endif - } else if (params->mem_type == shared_mem_type::shared_mem_buffer) { - cl::Buffer buf(static_cast(params->mem), true); - memory_impl::ptr mem_impl{ new gpu::gpu_buffer(engine_impl::ptr(_engine), layout, - buf, - net_id), false }; - return mem_impl; - } else { - throw std::runtime_error("unknown shared object fromat or type"); - } - } - catch (const cl::Error& clErr) { - switch (clErr.err()) { - case CL_MEM_OBJECT_ALLOCATION_FAILURE: - case CL_OUT_OF_RESOURCES: - case CL_OUT_OF_HOST_MEMORY: - case CL_INVALID_BUFFER_SIZE: - throw std::runtime_error("out of GPU resources"); - default: - throw std::runtime_error("GPU buffer allocation failed"); - } - } + return _engine->allocate_memory(layout, type); } memory_pool::~memory_pool() {} @@ -129,12 +52,10 @@ bool memory_pool::has_conflict(const memory_set& a, return !intersection.empty(); } -void memory_pool::release_memory(memory_impl* mem, - const primitive_id& id) { +void memory_pool::release_memory(memory* mem, const primitive_id& id, uint32_t network_id) { // check nonpadded pool first auto _layout = mem->get_layout(); auto type = mem->get_allocation_type(); - auto network_id = mem->get_net_id(); { auto range = _non_padded_pool.equal_range(_layout.bytes_count()); @@ -198,11 +119,11 @@ void memory_pool::release_memory(memory_impl* mem, } } -memory_impl::ptr memory_pool::get_from_non_padded_pool(const layout& layout, - const primitive_id& id, - uint32_t network_id, - const std::set& restrictions, - allocation_type type) { +memory::ptr memory_pool::get_from_non_padded_pool(const layout& layout, + const primitive_id& id, + uint32_t network_id, + const std::set& restrictions, + allocation_type type) { auto it = _non_padded_pool.lower_bound(layout.bytes_count()); while (it != _non_padded_pool.end()) { if (it->second._network_id == network_id && @@ -220,7 +141,7 @@ memory_impl::ptr memory_pool::get_from_non_padded_pool(const layout& layout, } } // didn't find anything for you? create new resource - auto mem = alloc_memory(layout, type, network_id); + auto mem = alloc_memory(layout, type); { _non_padded_pool.emplace(layout.bytes_count(), memory_record({{id, network_id}}, mem, network_id, type)); @@ -228,11 +149,11 @@ memory_impl::ptr memory_pool::get_from_non_padded_pool(const layout& layout, return mem; } -memory_impl::ptr memory_pool::get_from_padded_pool(const layout& layout, - const primitive_id& id, - uint32_t network_id, - const std::set& restrictions, - allocation_type type) { +memory::ptr memory_pool::get_from_padded_pool(const layout& layout, + const primitive_id& id, + uint32_t network_id, + const std::set& restrictions, + allocation_type type) { auto first_level_cache = _padded_pool.find(layout); if (first_level_cache != _padded_pool.end()) { @@ -252,12 +173,12 @@ memory_impl::ptr memory_pool::get_from_padded_pool(const layout& layout, return ret_mem; } } - auto mem = alloc_memory(layout, type, network_id); + auto mem = alloc_memory(layout, type); first_level_cache->second.emplace_back( memory_record({{id, network_id}}, mem, network_id, type)); return mem; } - auto mem = alloc_memory(layout, type, network_id); + auto mem = alloc_memory(layout, type); std::list list = {memory_record({{id, network_id}}, mem, network_id, type)}; _padded_pool.emplace(layout, std::move(list)); return mem; @@ -267,10 +188,10 @@ memory_impl::ptr memory_pool::get_from_padded_pool(const layout& layout, This is not reusable within one network or it's internal micronetworks. But we can use this memory records between networks. */ -memory_impl::ptr memory_pool::get_from_across_networks_pool(const layout& layout, - const primitive_id& id, - uint32_t network_id, - allocation_type type) { +memory::ptr memory_pool::get_from_across_networks_pool(const layout& layout, + const primitive_id& id, + uint32_t network_id, + allocation_type type) { auto it = _no_reusable_pool.lower_bound(layout.bytes_count()); while (it != _no_reusable_pool.end()) { @@ -284,7 +205,7 @@ memory_impl::ptr memory_pool::get_from_across_networks_pool(const layout& layout } ++it; } - auto mem = alloc_memory(layout, type, network_id); + auto mem = alloc_memory(layout, type); { _no_reusable_pool.emplace(layout.bytes_count(), memory_record({{id, network_id}}, mem, network_id, type)); @@ -292,16 +213,16 @@ memory_impl::ptr memory_pool::get_from_across_networks_pool(const layout& layout return mem; } -memory_impl::ptr memory_pool::get_memory(const layout& layout, allocation_type type, uint32_t net_id, bool reset) { - return alloc_memory(layout, type, net_id, reset); +memory::ptr memory_pool::get_memory(const layout& layout, allocation_type type) { + return alloc_memory(layout, type); } -memory_impl::ptr memory_pool::get_memory(const layout& layout, - const primitive_id& id, - uint32_t network_id, - const std::set& restrictions, - allocation_type type, - bool reusable_across_network) { +memory::ptr memory_pool::get_memory(const layout& layout, + const primitive_id& id, + uint32_t network_id, + const std::set& restrictions, + allocation_type type, + bool reusable_across_network) { if (reusable_across_network) { // reusable within the same network if (!layout.format.is_image() && layout.data_padding == padding{{0, 0, 0, 0}, 0}) { @@ -312,10 +233,10 @@ memory_impl::ptr memory_pool::get_memory(const layout& layout, return get_from_padded_pool(layout, id, network_id, restrictions, type); } else { // images (reuse not yet implemented) - return alloc_memory(layout, type, network_id); + return alloc_memory(layout, type); } } else { - return alloc_memory(layout, type, network_id); + return alloc_memory(layout, type); } } @@ -329,8 +250,7 @@ void memory_pool::clear_pool_for_network(uint32_t network_id) { while (itr != _non_padded_pool.end()) { auto& record = itr->second; - if (record._memory->get_net_id() == network_id && - record._network_id == network_id) { + if (record._network_id == network_id) { itr = _non_padded_pool.erase(itr); } else { itr++; @@ -347,8 +267,7 @@ void memory_pool::clear_pool_for_network(uint32_t network_id) { auto list_itr = list.begin(); while (list_itr != list.end()) { - if (list_itr->_memory->get_net_id() == network_id && - list_itr->_network_id == network_id) { + if (list_itr->_network_id == network_id) { list_itr = list.erase(list_itr); } else { list_itr++; @@ -370,8 +289,7 @@ void memory_pool::clear_pool_for_network(uint32_t network_id) { while (itr != _no_reusable_pool.end()) { auto& record = itr->second; - if (record._memory->get_net_id() == network_id && - record._network_id == network_id) { + if (record._network_id == network_id) { itr = _no_reusable_pool.erase(itr); } else { itr++; @@ -380,59 +298,14 @@ void memory_pool::clear_pool_for_network(uint32_t network_id) { } } -memory_pool::memory_pool(engine_impl& engine) : _engine(&engine), _temp_memory_used(0), _max_peak_memory_used(0) { -} - -void memory_pool::dump_memory_pool(const program_impl& program, std::string& path, std::string& dep) { - using namespace std; - ofstream log(path); - - log << "\nNon-padded pool:" << endl; - log << "Size\tUsers:" << endl; - for (const auto& record : _non_padded_pool) { - log << record.first; - for (const auto& usr : record.second._users) log << ", " << usr; - log << endl; - } - - log << "\n--- Padded pool: ---" << endl; - log << "Size\tUsers:" << endl; - for (const auto& record : _padded_pool) { - for (const auto& mem : record.second) { - log << mem._memory->size(); - for (const auto& usr : mem._users) log << ", " << usr; - log << endl; - } - } - log << dep; - log.close(); - color_graph(program); -} - -void memory_pool::color_graph(const program_impl& program) { - uint32_t color = 0; - for (const auto& record : _non_padded_pool) { - for (const auto& usr : record.second._users) { - if (program.has_node(usr._id)) - program.get_node(usr._id).set_reused_memory_color(color); - } - ++color; - } - - for (const auto& list : _padded_pool) { - for (const auto& record : list.second) { - if (record._users.size() > 1) { // one user doesn't mean reusing - for (const auto& usr : record._users) { - if (program.has_node(usr._id)) - program.get_node(usr._id).set_reused_memory_color(color); - } - } - ++color; - } - } -} +memory_pool::memory_pool(engine& engine) : _engine(&engine), _temp_memory_used(0), _max_peak_memory_used(0) { } void memory_pool::add_memory_used(size_t value) { + // std::cerr << "ADD MEM: " << value + // << " max: " << _engine->get_device_info().max_global_mem_size + // << " peak: " << _max_peak_memory_used + // << " tmp: " << _temp_memory_used << std::endl; + _temp_memory_used += value; if (_temp_memory_used > _max_peak_memory_used) { _max_peak_memory_used = _temp_memory_used.load(); @@ -441,6 +314,10 @@ void memory_pool::add_memory_used(size_t value) { void memory_pool::subtract_memory_used(size_t value) { _temp_memory_used -= value; + // std::cerr << "FREE MEM: " << value + // << " max: " << _engine->get_device_info().max_global_mem_size + // << " peak: " << _max_peak_memory_used + // << " tmp: " << _temp_memory_used << std::endl; } } // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/ocl_base_event.cpp b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_base_event.cpp similarity index 93% rename from inference-engine/thirdparty/clDNN/src/gpu/ocl_base_event.cpp rename to inference-engine/thirdparty/clDNN/runtime/ocl/ocl_base_event.cpp index 09e2cfda0b9254..e08cfd6fa553e0 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/ocl_base_event.cpp +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_base_event.cpp @@ -2,14 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ocl_base_event.h" +#include "ocl_base_event.hpp" #include #include #include #include +#include + using namespace cldnn; -using namespace gpu; +using namespace ocl; namespace { bool is_event_profiled(const cl::Event& event) { @@ -48,9 +50,6 @@ void base_event::set_ocl_callback() { void base_event::wait_impl() { if (_event.get() != nullptr) { _event.wait(); - if (get_context()->logging_enabled()) { - get_context()->log(0, "Wait for event: " + std::to_string(_queue_stamp)); - } } } @@ -92,9 +91,6 @@ bool base_event::get_profiling_info_impl(std::listlogging_enabled()) { - get_context()->log(0, "Wait for event: " + std::to_string(_queue_stamp)); - } } } @@ -112,7 +108,7 @@ bool base_events::get_profiling_info_impl(std::list>> all_durations; for (size_t i = 0; i < _events.size(); i++) { - auto be = dynamic_cast(_events[i].get()); + auto be = downcast(_events[i].get()); if (!is_event_profiled(be->_event)) continue; diff --git a/inference-engine/thirdparty/clDNN/src/gpu/ocl_base_event.h b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_base_event.hpp similarity index 76% rename from inference-engine/thirdparty/clDNN/src/gpu/ocl_base_event.h rename to inference-engine/thirdparty/clDNN/runtime/ocl/ocl_base_event.hpp index 988628497dad1a..85f32c0b0b6def 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/ocl_base_event.h +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_base_event.hpp @@ -4,13 +4,16 @@ #pragma once -#include "ocl_toolkit.h" +#include "ocl_common.hpp" +#include "cldnn/runtime/event.hpp" +#include "cldnn/runtime/utils.hpp" + #include #include #include namespace cldnn { -namespace gpu { +namespace ocl { struct profiling_period_ocl_start_stop { const char* name; @@ -18,7 +21,7 @@ struct profiling_period_ocl_start_stop { cl_profiling_info stop; }; -struct ocl_base_event : virtual public event_impl { +struct ocl_base_event : virtual public event { public: explicit ocl_base_event(uint64_t queue_stamp = 0, bool valid = false) : _queue_stamp(queue_stamp) { _attached = valid; } uint64_t get_queue_stamp() const { return _queue_stamp; } @@ -30,10 +33,10 @@ struct ocl_base_event : virtual public event_impl { struct base_event : virtual public ocl_base_event { public: - base_event(std::shared_ptr ctx, cl::Event const& ev, uint64_t queue_stamp = 0) - : ocl_base_event(queue_stamp, true), _ctx(ctx), _event(ev) {} + base_event(const cl::Context& /* ctx */, cl::Event const& ev, uint64_t queue_stamp = 0) + : ocl_base_event(queue_stamp, true), _event(ev) {} - explicit base_event(std::shared_ptr ctx) : ocl_base_event(0, false), _ctx(ctx) {} + base_event(const cl::Context& /* ctx */) : ocl_base_event(0, false) {} void attach_ocl_event(const cl::Event& ev, const uint64_t q_stamp) { _event = ev; @@ -42,11 +45,9 @@ struct base_event : virtual public ocl_base_event { _set = false; } - std::shared_ptr get_context() const { return _ctx; } cl::Event get() override { return _event; } private: - std::shared_ptr _ctx; bool _callback_set = false; void set_ocl_callback(); static void CL_CALLBACK ocl_event_completion_callback(cl_event, cl_int, void* me); @@ -65,14 +66,14 @@ struct base_event : virtual public ocl_base_event { struct base_events : virtual public ocl_base_event { public: - base_events(std::shared_ptr ctx, std::vector const& ev) - : ocl_base_event(0, true), _ctx(ctx) { + base_events(const cl::Context& /* ctx */, std::vector const& ev) + : ocl_base_event(0, true) { process_events(ev); } - explicit base_events(std::shared_ptr ctx) : ocl_base_event(0, false), _ctx(ctx) {} + base_events(const cl::Context& /* ctx */) : ocl_base_event(0, false) {} - void attach_events(const std::vector& ev) { + void attach_events(const std::vector& ev) { if (_attached) throw std::runtime_error("Trying to attach events to valid event object."); process_events(ev); @@ -80,7 +81,6 @@ struct base_events : virtual public ocl_base_event { } cl::Event get() override { return _last_ocl_event; } - std::shared_ptr get_context() const { return _ctx; } void reset() override { ocl_base_event::reset(); @@ -91,7 +91,7 @@ struct base_events : virtual public ocl_base_event { void wait_impl() override; bool is_set_impl() override; - void process_events(const std::vector& ev) { + void process_events(const std::vector& ev) { for (size_t i = 0; i < ev.size(); i++) { auto multiple_events = dynamic_cast(ev[i].get()); if (multiple_events) { @@ -121,9 +121,8 @@ struct base_events : virtual public ocl_base_event { bool get_profiling_info_impl(std::list& info) override; cl::Event _last_ocl_event; - std::shared_ptr _ctx; - std::vector _events; + std::vector _events; }; -} // namespace gpu +} // namespace ocl } // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/command_queues_builder.cpp b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_command_queues_builder.cpp similarity index 80% rename from inference-engine/thirdparty/clDNN/src/gpu/command_queues_builder.cpp rename to inference-engine/thirdparty/clDNN/runtime/ocl/ocl_command_queues_builder.cpp index 25f842cd4c07d2..c2772434304ccb 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/command_queues_builder.cpp +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_command_queues_builder.cpp @@ -2,21 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include "command_queues_builder.h" -#include "error_handler.h" +#include "ocl_command_queues_builder.hpp" +#include "cldnn/runtime/error_handler.hpp" #include namespace cldnn { -namespace gpu { - -command_queues_builder::command_queues_builder(const cl::Context& context, - const cl::Device& device, - const cl_platform_id& platform_id) - : _context(context), - _device(device), - _platform_id(platform_id), - _profiling(false), +namespace ocl { + +command_queues_builder::command_queues_builder() + : _profiling(false), _out_of_order(false), _priority_mode(priority_mode_types::disabled), _throttle_mode(throttle_mode_types::disabled) {} @@ -27,12 +21,13 @@ cl_command_queue_properties command_queues_builder::get_properties() { return ret; } -void command_queues_builder::build() { +ocl_queue_type command_queues_builder::build(const cl::Context& context, const cl::Device& device) { auto properties = get_properties(); + ocl_queue_type queue; + if (_priority_mode == priority_mode_types::disabled && _throttle_mode == throttle_mode_types::disabled) { - _queue = queue_type(_context, _device, properties); - return; + queue = ocl_queue_type(context, device, properties); } unsigned cl_queue_priority_value = CL_QUEUE_PRIORITY_MED_KHR; @@ -72,7 +67,7 @@ void command_queues_builder::build() { properties, 0}; - _queue = queue_type(clCreateCommandQueueWithProperties(_context.get(), _device.get(), properties_low, &error_code)); + queue = ocl_queue_type(clCreateCommandQueueWithProperties(context.get(), device.get(), properties_low, &error_code)); } else if (_priority_mode != priority_mode_types::disabled) { cl_queue_properties properties_low[] = {CL_QUEUE_PRIORITY_KHR, cl_queue_priority_value, @@ -80,7 +75,7 @@ void command_queues_builder::build() { properties, 0}; - _queue = queue_type(clCreateCommandQueueWithProperties(_context.get(), _device.get(), properties_low, &error_code)); + queue = ocl_queue_type(clCreateCommandQueueWithProperties(context.get(), device.get(), properties_low, &error_code)); } else if (_throttle_mode != throttle_mode_types::disabled) { cl_queue_properties properties_low[] = {CL_QUEUE_THROTTLE_KHR, cl_queue_throttle_value, @@ -88,13 +83,15 @@ void command_queues_builder::build() { properties, 0}; - _queue = queue_type(clCreateCommandQueueWithProperties(_context.get(), _device.get(), properties_low, &error_code)); + queue = ocl_queue_type(clCreateCommandQueueWithProperties(context.get(), device.get(), properties_low, &error_code)); } if (error_code != CL_SUCCESS) { CLDNN_ERROR_MESSAGE("Command queues builders", "clCreateCommandQueueWithPropertiesINTEL error " + std::to_string(error_code)); } + + return queue; } void command_queues_builder::set_priority_mode(priority_mode_types priority, bool extension_support) { @@ -115,5 +112,5 @@ void command_queues_builder::set_throttle_mode(throttle_mode_types throttle, boo } _throttle_mode = throttle; } -} // namespace gpu +} // namespace ocl } // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/command_queues_builder.h b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_command_queues_builder.hpp similarity index 57% rename from inference-engine/thirdparty/clDNN/src/gpu/command_queues_builder.h rename to inference-engine/thirdparty/clDNN/runtime/ocl/ocl_command_queues_builder.hpp index 7d99bcccbd2ecd..cddd350760034b 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/command_queues_builder.h +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_command_queues_builder.hpp @@ -2,28 +2,24 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "ocl_toolkit.h" + +#include "ocl_common.hpp" +#include "cldnn/runtime/engine.hpp" namespace cldnn { -namespace gpu { +namespace ocl { + class command_queues_builder { public: - command_queues_builder(const cl::Context& context, const cl::Device& device, const cl_platform_id& platform_id); - void build(); + command_queues_builder(); + ocl_queue_type build(const cl::Context& context, const cl::Device& device); void set_throttle_mode(throttle_mode_types throttle, bool extension_support); void set_priority_mode(priority_mode_types priority, bool extension_support); void set_profiling(bool flag) { _profiling = flag; } void set_out_of_order(bool flag) { _out_of_order = flag; } - queue_type& queue() { return _queue; } - queue_type queue() const { return _queue; } private: - queue_type _queue; - cl::Context _context; - cl::Device _device; - cl_platform_id _platform_id; bool _profiling; bool _out_of_order; priority_mode_types _priority_mode; @@ -31,5 +27,6 @@ class command_queues_builder { cl_command_queue_properties get_properties(); }; -} // namespace gpu + +} // namespace ocl } // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_common.hpp b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_common.hpp new file mode 100644 index 00000000000000..07be51ff38c7d1 --- /dev/null +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_common.hpp @@ -0,0 +1,30 @@ +// Copyright (C) 2020-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// +#pragma once + +#include "ocl_wrapper.hpp" + +#include + +namespace cldnn { +namespace ocl { + +typedef cl::vector> kernels_binaries_vector; +typedef cl::vector kernels_binaries_container; +typedef CL_API_ENTRY cl_command_queue(CL_API_CALL* pfn_clCreateCommandQueueWithPropertiesINTEL)( + cl_context context, + cl_device_id device, + const cl_queue_properties* properties, + cl_int* errcodeRet); + +using ocl_queue_type = cl::CommandQueueIntel; +using ocl_kernel_type = cl::KernelIntel; + +class ocl_error : public std::runtime_error { +public: + explicit ocl_error(cl::Error const& err); +}; + +} // namespace ocl +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/device_info.cpp b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_device.cpp similarity index 54% rename from inference-engine/thirdparty/clDNN/src/gpu/device_info.cpp rename to inference-engine/thirdparty/clDNN/runtime/ocl/ocl_device.cpp index 09e069dda3f776..e1ba4bb5a5ceb7 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/device_info.cpp +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_device.cpp @@ -2,16 +2,19 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "device_info.h" -#include "include/to_string_utils.h" +#include "ocl_device.hpp" +#include "ocl_common.hpp" + +#include +#include +#include +#include #include #include #include #include #include #include -#include "ocl_builder.h" - #include #include #include @@ -30,7 +33,7 @@ #endif namespace cldnn { -namespace gpu { +namespace ocl { namespace { int driver_dev_id() { @@ -103,7 +106,7 @@ int driver_dev_id() { return result.back(); } -static device_type get_device_type(const cl::Device& device) { +device_type get_device_type(const cl::Device& device) { auto unified_mem = device.getInfo(); return unified_mem ? device_type::integrated_gpu : device_type::discrete_gpu; @@ -117,7 +120,7 @@ gfx_version parse_version(cl_uint ver) { return {major, minor, revision}; } -static bool get_imad_support(const cl::Device& device) { +bool get_imad_support(const cl::Device& device) { std::string dev_name = device.getInfo(); if (dev_name.find("Gen12") != std::string::npos || @@ -183,74 +186,111 @@ bool is_local_block_io_supported(const cl::Device& device) { } } -} // namespace - -device_info_internal::device_info_internal(const cl::Device& device) { - dev_name = device.getInfo(); - driver_version = device.getInfo(); - dev_type = get_device_type(device); +device_info init_device_info(const cl::Device& device) { + device_info info; + info.vendor_id = static_cast(device.getInfo()); + info.dev_name = device.getInfo(); + info.driver_version = device.getInfo(); + info.dev_type = get_device_type(device); - compute_units_count = device.getInfo(); + info.execution_units_count = device.getInfo(); - cores_count = static_cast(device.getInfo()); - core_frequency = static_cast(device.getInfo()); + info.gpu_frequency = static_cast(device.getInfo()); - max_work_group_size = static_cast(device.getInfo()); + info.max_work_group_size = static_cast(device.getInfo()); - if (max_work_group_size > 256) - max_work_group_size = 256; + // looks like WA. Do we still need it? + if (info.max_work_group_size > 256) + info.max_work_group_size = 256; - max_local_mem_size = static_cast(device.getInfo()); - max_global_mem_size = static_cast(device.getInfo()); - max_alloc_mem_size = static_cast(device.getInfo()); + info.max_local_mem_size = static_cast(device.getInfo()); + info.max_global_mem_size = static_cast(device.getInfo()); + info.max_alloc_mem_size = static_cast(device.getInfo()); - supports_image = static_cast(device.getInfo()); - max_image2d_width = static_cast(device.getInfo()); - max_image2d_height = static_cast(device.getInfo()); + info.supports_image = static_cast(device.getInfo()); + info.max_image2d_width = static_cast(device.getInfo()); + info.max_image2d_height = static_cast(device.getInfo()); // Check for supported features. auto extensions = device.getInfo(); extensions.push_back(' '); // Add trailing space to ease searching (search with keyword with trailing space). - supports_fp16 = extensions.find("cl_khr_fp16 ") != std::string::npos; - supports_fp16_denorms = supports_fp16 && (device.getInfo() & CL_FP_DENORM) != 0; - - supports_subgroups_short = extensions.find("cl_intel_subgroups_short") != std::string::npos; + info.supports_fp16 = extensions.find("cl_khr_fp16 ") != std::string::npos; + info.supports_fp64 = extensions.find("cl_khr_fp64 ") != std::string::npos; + info.supports_fp16_denorms = info.supports_fp16 && (device.getInfo() & CL_FP_DENORM) != 0; - supports_imad = get_imad_support(device); - supports_immad = false; + info.supports_subgroups = extensions.find("cl_intel_subgroups") != std::string::npos; + info.supports_subgroups_short = extensions.find("cl_intel_subgroups_short") != std::string::npos; + info.supports_subgroups_char = extensions.find("cl_intel_subgroups_char") != std::string::npos; - max_threads_per_execution_unit = 7; - max_threads_per_device = static_cast(cores_count * max_threads_per_execution_unit); + info.supports_imad = get_imad_support(device); + info.supports_immad = false; - vendor_id = static_cast(device.getInfo()); + info.max_threads_per_execution_unit = 7; + info.max_threads_per_device = static_cast(info.execution_units_count * info.max_threads_per_execution_unit); - supports_usm = extensions.find("cl_intel_unified_shared_memory") != std::string::npos; + info.supports_usm = extensions.find("cl_intel_unified_shared_memory") != std::string::npos; - supports_optimization_hints = false; - supports_local_block_io = extensions.find("cl_intel_subgroup_local_block_io") != std::string::npos && - is_local_block_io_supported(device); + info.supports_local_block_io = extensions.find("cl_intel_subgroup_local_block_io") != std::string::npos && + is_local_block_io_supported(device); bool device_attr_supported = extensions.find("cl_intel_device_attribute_query") != std::string::npos; if (device_attr_supported) { - gfx_ver = parse_version(device.getInfo()); - device_id = device.getInfo(); - num_slices = device.getInfo(); - num_sub_slices_per_slice = device.getInfo(); - num_eus_per_sub_slice = device.getInfo(); - num_threads_per_eu = device.getInfo(); + info.gfx_ver = parse_version(device.getInfo()); + info.device_id = device.getInfo(); + info.num_slices = device.getInfo(); + info.num_sub_slices_per_slice = device.getInfo(); + info.num_eus_per_sub_slice = device.getInfo(); + info.num_threads_per_eu = device.getInfo(); auto features = device.getInfo(); - supports_imad = supports_imad || (features & CL_DEVICE_FEATURE_FLAG_DP4A_INTEL); + info.supports_imad = info.supports_imad || (features & CL_DEVICE_FEATURE_FLAG_DP4A_INTEL); } else { - gfx_ver = {0, 0, 0}; - device_id = driver_dev_id(); - num_slices = 0; - num_sub_slices_per_slice = 0; - num_eus_per_sub_slice = 0; - num_threads_per_eu = 0; + info.gfx_ver = {0, 0, 0}; + info.device_id = driver_dev_id(); + info.num_slices = 0; + info.num_sub_slices_per_slice = 0; + info.num_eus_per_sub_slice = 0; + info.num_threads_per_eu = 0; } + + return info; +} + +bool does_device_support(int32_t param, const cl::Device& device) { + cl_device_unified_shared_memory_capabilities_intel capabilities; + auto err = clGetDeviceInfo(device.get(), param, sizeof(cl_device_unified_shared_memory_capabilities_intel), &capabilities, NULL); + if (err) throw std::runtime_error("[CLDNN ERROR]. clGetDeviceInfo error " + std::to_string(err)); + return !((capabilities & CL_UNIFIED_SHARED_MEMORY_ACCESS_INTEL) == 0u); } -} // namespace gpu + +memory_capabilities init_memory_caps(const cl::Device& device, const device_info& info) { + std::vector memory_caps; + if (info.supports_usm) { + if (does_device_support(CL_DEVICE_HOST_MEM_CAPABILITIES_INTEL, device)) { + memory_caps.push_back(allocation_type::usm_host); + } + if (does_device_support(CL_DEVICE_SINGLE_DEVICE_SHARED_MEM_CAPABILITIES_INTEL, device)) { + memory_caps.push_back(allocation_type::usm_shared); + } + if (does_device_support(CL_DEVICE_DEVICE_MEM_CAPABILITIES_INTEL, device)) { + memory_caps.push_back(allocation_type::usm_device); + } + } + + return memory_capabilities(memory_caps); +} + +} // namespace + + +ocl_device::ocl_device(const cl::Device dev, const cl::Context& ctx, const cl_platform_id platform) +: _context(ctx) +, _device(dev) +, _platform(platform) +, _info(init_device_info(dev)) +, _mem_caps(init_memory_caps(dev, _info)) { } + +} // namespace ocl } // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_device.hpp b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_device.hpp new file mode 100644 index 00000000000000..ecb3498e4886b1 --- /dev/null +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_device.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "cldnn/runtime/engine.hpp" +#include "cldnn/runtime/device.hpp" +#include "ocl_common.hpp" + +#include +#include +#include +#include + +namespace cldnn { +namespace ocl { + +struct ocl_device : public device { +public: + ocl_device(const cl::Device dev, const cl::Context& ctx, const cl_platform_id platform); + + device_info get_info() const override { return _info; } + memory_capabilities get_mem_caps() const override { return _mem_caps; } + + const cl::Device& get_device() const { return _device; } + cl::Device& get_device() { return _device; } + const cl::Context& get_context() const { return _context; } + cl_platform_id get_platform() const { return _platform; } + + ~ocl_device() = default; + +private: + cl::Context _context; + cl::Device _device; + cl_platform_id _platform; + device_info _info; + memory_capabilities _mem_caps; +}; + +} // namespace ocl +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/ocl_builder.cpp b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_device_detector.cpp similarity index 68% rename from inference-engine/thirdparty/clDNN/src/gpu/ocl_builder.cpp rename to inference-engine/thirdparty/clDNN/runtime/ocl/ocl_device_detector.cpp index 60fcc9b043542e..1ba46d836d4579 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/ocl_builder.cpp +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_device_detector.cpp @@ -2,11 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include "ocl_builder.h" -#include "configuration.h" -#include "include/to_string_utils.h" -#include "api/device.hpp" +#include "ocl_device_detector.hpp" +#include "ocl_device.hpp" +#include "ocl_common.hpp" + #include #include #include @@ -21,8 +20,29 @@ #pragma GCC diagnostic ignored "-Wignored-attributes" #endif +namespace { +bool does_device_match_config(bool out_of_order, const cl::Device& device) { +// Is it intel gpu +if (device.getInfo() != CL_DEVICE_TYPE_GPU || + device.getInfo() != 0x8086) { + return false; +} + +// Does device support OOOQ? +if (out_of_order) { + auto queue_properties = device.getInfo(); + using cmp_t = std::common_type::type>::type; + if (!(static_cast(queue_properties) & static_cast(cl::QueueProperties::OutOfOrder))) { + return false; + } +} + +return true; +} +} // namespace namespace cldnn { -namespace gpu { +namespace ocl { static constexpr auto INTEL_PLATFORM_VENDOR = "Intel(R) Corporation"; static std::vector getSubDevices(cl::Device& rootDevice) { @@ -68,18 +88,18 @@ static std::vector getSubDevices(cl::Device& rootDevice) { return subDevices; } -std::map ocl_builder::get_available_devices(void* user_context, void* user_device) const { +std::map ocl_device_detector::get_available_devices(void* user_context, void* user_device) const { bool host_out_of_order = true; // Change to false, if debug requires in-order queue. - std::vector dev_orig, dev_sorted; + std::vector dev_orig, dev_sorted; if (user_context != nullptr) { - dev_orig = build_device_list_from_user_context(host_out_of_order, user_context); + dev_orig = create_device_list_from_user_context(host_out_of_order, user_context); } else if (user_device != nullptr) { - dev_orig = build_device_list_from_user_device(host_out_of_order, user_device); + dev_orig = create_device_list_from_user_device(host_out_of_order, user_device); } else { - dev_orig = build_device_list(host_out_of_order); + dev_orig = create_device_list(host_out_of_order); } - std::map ret; + std::map ret; for (auto& dptr : dev_orig) { if (dptr->get_info().dev_type == cldnn::device_type::integrated_gpu) dev_sorted.insert(dev_sorted.begin(), dptr); @@ -91,14 +111,16 @@ std::map ocl_builder::get_available_devices(void* auto map_id = std::to_string(idx++); ret[map_id] = dptr; - auto rootDevice = dptr->get_device(); - auto subDevices = getSubDevices(rootDevice); + auto rootDevice = std::dynamic_pointer_cast(dptr); + if (!rootDevice) { + throw std::runtime_error("Invalid device type created in ocl_device_detector"); + } + + auto subDevices = getSubDevices(rootDevice->get_device()); if (!subDevices.empty()) { uint32_t sub_idx = 0; for (auto& subdevice : subDevices) { - auto subdPtr = device_impl::ptr(new device_impl(subdevice, cl::Context(subdevice), - dptr->get_platform(), - device_info_internal(subdevice)), false); + auto subdPtr = std::make_shared(subdevice, cl::Context(subdevice), rootDevice->get_platform()); ret[map_id+"."+std::to_string(sub_idx++)] = subdPtr; } } @@ -106,7 +128,7 @@ std::map ocl_builder::get_available_devices(void* return ret; } -std::vector ocl_builder::build_device_list(bool out_out_order) const { +std::vector ocl_device_detector::create_device_list(bool out_out_order) const { cl_uint n = 0; // Get number of platforms availible cl_int err = clGetPlatformIDs(0, NULL, &n); @@ -121,7 +143,7 @@ std::vector ocl_builder::build_device_list(bool out_out_order) throw std::runtime_error("[CLDNN ERROR]. clGetPlatformIDs error " + std::to_string(err)); } - std::vector ret; + std::vector ret; for (auto& id : platform_ids) { cl::Platform platform = cl::Platform(id); @@ -131,9 +153,9 @@ std::vector ocl_builder::build_device_list(bool out_out_order) std::vector devices; platform.getDevices(CL_DEVICE_TYPE_ALL, &devices); for (auto& device : devices) { - if (!does_device_match_config(out_out_order, device)) continue; - ret.emplace_back(device_impl::ptr{ new device_impl(device, cl::Context(device), - id, device_info_internal(device)), false}); + if (!does_device_match_config(out_out_order, device)) + continue; + ret.emplace_back(std::make_shared(device, cl::Context(device), id)); } } if (ret.empty()) { @@ -142,16 +164,15 @@ std::vector ocl_builder::build_device_list(bool out_out_order) return ret; } -std::vector ocl_builder::build_device_list_from_user_context(bool out_out_order, void* user_context) const { +std::vector ocl_device_detector::create_device_list_from_user_context(bool out_out_order, void* user_context) const { cl::Context ctx = cl::Context(static_cast(user_context), true); auto all_devices = ctx.getInfo(); - std::vector ret; + std::vector ret; for (auto& device : all_devices) { - if (!does_device_match_config(out_out_order, device)) continue; - ret.emplace_back(device_impl::ptr{ new device_impl(device, cl::Context(device), - device.getInfo(), - device_info_internal(device)), false}); + if (!does_device_match_config(out_out_order, device)) + continue; + ret.emplace_back(std::make_shared(device, cl::Context(device), device.getInfo())); } if (ret.empty()) { @@ -160,7 +181,7 @@ std::vector ocl_builder::build_device_list_from_user_context( return ret; } -std::vector ocl_builder::build_device_list_from_user_device(bool out_out_order, void* user_device) const { +std::vector ocl_device_detector::create_device_list_from_user_device(bool out_out_order, void* user_device) const { cl_uint n = 0; // Get number of platforms availible cl_int err = clGetPlatformIDs(0, NULL, &n); @@ -175,7 +196,7 @@ std::vector ocl_builder::build_device_list_from_user_device(b throw std::runtime_error("[CLDNN ERROR]. clGetPlatformIDs error " + std::to_string(err)); } - std::vector ret; + std::vector ret; for (auto& id : platform_ids) { cl::PlatformVA platform = cl::PlatformVA(id); @@ -206,8 +227,7 @@ std::vector ocl_builder::build_device_list_from_user_device(b CL_CONTEXT_INTEROP_USER_SYNC, CL_FALSE, CL_CONTEXT_PLATFORM, (cl_context_properties)id, 0 }; - ret.emplace_back(device_impl::ptr{ new device_impl(device, cl::Context(device, props), - id, device_info_internal(device)), false }); + ret.emplace_back(std::make_shared(device, cl::Context(device, props), id)); } } if (ret.empty()) { @@ -216,25 +236,5 @@ std::vector ocl_builder::build_device_list_from_user_device(b return ret; } -bool ocl_builder::does_device_match_config(bool out_of_order, const cl::Device& device) const { - // Is it intel gpu - if (device.getInfo() != device_type || - device.getInfo() != device_vendor) { - return false; - } - - // Does device support OOOQ? - if (out_of_order) { - auto queue_properties = device.getInfo(); - using cmp_t = std::common_type::type>::type; - if (!(static_cast(queue_properties) & static_cast(cl::QueueProperties::OutOfOrder))) { - return false; - } - } - - return true; -} - -} // namespace gpu +} // namespace ocl } // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_device_detector.hpp b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_device_detector.hpp new file mode 100644 index 00000000000000..d738285989c5ca --- /dev/null +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_device_detector.hpp @@ -0,0 +1,30 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "cldnn/runtime/device.hpp" + +#include +#include +#include +#include +#include + +namespace cldnn { +namespace ocl { + +class ocl_device_detector { +public: + ocl_device_detector() = default; + + std::map get_available_devices(void* user_context, void* user_device) const; +private: + std::vector create_device_list(bool out_out_order) const; + std::vector create_device_list_from_user_context(bool out_out_order, void* user_context) const; + std::vector create_device_list_from_user_device(bool out_out_order, void* user_device) const; +}; + +} // namespace ocl +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_engine.cpp b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_engine.cpp new file mode 100644 index 00000000000000..95b2950ec61537 --- /dev/null +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_engine.cpp @@ -0,0 +1,204 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "ocl_engine.hpp" +#include "ocl_common.hpp" +#include "ocl_memory.hpp" +#include "ocl_stream.hpp" +#include +#include +#include +#include +#include + +// NOTE: Due to buggy scope transition of warnings we need to disable warning in place of use/instantation +// of some types (even though we already disabled them in scope of definition of these types). +// Moreover this warning is pretty much now only for annoyance: it is generated due to lack +// of proper support for mangling of custom GCC attributes into type name (usually when used +// with templates, even from standard library). +#if defined __GNUC__ && __GNUC__ >= 6 +#pragma GCC diagnostic ignored "-Wignored-attributes" +#endif + +// static class memebers - pointers to dynamically obtained OpenCL extension functions +cl::PFN_clEnqueueAcquireMediaSurfacesINTEL cl::SharedSurfLock::pfn_acquire = NULL; +cl::PFN_clEnqueueReleaseMediaSurfacesINTEL cl::SharedSurfLock::pfn_release = NULL; +cl::PFN_clCreateFromMediaSurfaceINTEL cl::ImageVA::pfn_clCreateFromMediaSurfaceINTEL = NULL; +#ifdef _WIN32 +cl::PFN_clCreateFromD3D11Buffer cl::BufferDX::pfn_clCreateFromD3D11Buffer = NULL; +#endif + +namespace cldnn { +namespace ocl { + +ocl_error::ocl_error(cl::Error const& err) + : std::runtime_error(err.what() + std::string(", error code: ") + std::to_string(err.err())) {} + +ocl_engine::ocl_engine(const device::ptr dev, runtime_types runtime_type, const engine_configuration& conf) + : engine(dev, conf) { + if (runtime_type != runtime_types::ocl) { + throw std::runtime_error("Invalid runtime type specified for OCL engine. Only OCL runtime is supported"); + } + + auto casted = dynamic_cast(dev.get()); + if (!casted) + throw std::runtime_error("[CLDNN] Invalid device type passed to ocl engine"); + casted->get_device().getInfo(CL_DEVICE_EXTENSIONS, &_extensions); + + _program_stream.reset(new ocl_stream(*this)); +} + +const cl::Context& ocl_engine::get_cl_context() const { + auto cl_device = std::dynamic_pointer_cast(_device); + if (!cl_device) + throw std::runtime_error("Invalid device type for ocl_engine"); + return cl_device->get_context(); +} + +const cl::Device& ocl_engine::get_cl_device() const { + auto cl_device = std::dynamic_pointer_cast(_device); + if (!cl_device) + throw std::runtime_error("Invalid device type for ocl_engine"); + return cl_device->get_device(); +} + +memory::ptr ocl_engine::allocate_memory(const layout& layout, allocation_type type, bool reset) { + if (layout.bytes_count() > get_device_info().max_alloc_mem_size) { + throw std::runtime_error("exceeded max size of memory object allocation"); + } + + _memory_pool->add_memory_used(layout.bytes_count()); + + try { + memory::ptr res = nullptr; + if (layout.format.is_image_2d()) { + res = std::make_shared(this, layout); + } else if (type == allocation_type::cl_mem) { + res = std::make_shared(this, layout); + } else { + res = std::make_shared(this, layout, type); + } + + if (reset || res->is_memory_reset_needed(layout)) { + res->fill(get_program_stream()); + } + + return res; + } catch (const cl::Error& clErr) { + switch (clErr.err()) { + case CL_MEM_OBJECT_ALLOCATION_FAILURE: + case CL_OUT_OF_RESOURCES: + case CL_OUT_OF_HOST_MEMORY: + case CL_INVALID_BUFFER_SIZE: + throw std::runtime_error("out of GPU resources"); + default: + throw std::runtime_error("GPU buffer allocation failed"); + } + } +} + +memory::ptr ocl_engine::reinterpret_buffer(const memory& memory, const layout& new_layout) { + if (memory.get_engine() != this) + throw std::runtime_error("trying to reinterpret buffer allocated by a different engine"); + + if (new_layout.format.is_image() && !memory.get_layout().format.is_image()) + throw std::runtime_error("trying to reinterpret non-image buffer as image"); + + if (!new_layout.format.is_image() && memory.get_layout().format.is_image()) + throw std::runtime_error("trying to reinterpret image buffer as non-image buffer"); + + try { + if (new_layout.format.is_image_2d()) { + return std::make_shared(this, + new_layout, + reinterpret_cast(memory).get_buffer()); + } else if (memory_capabilities::is_usm_type(memory.get_allocation_type())) { + return std::make_shared(this, + new_layout, + reinterpret_cast(memory).get_buffer(), + memory.get_allocation_type()); + } else { + return std::make_shared(this, + new_layout, + reinterpret_cast(memory).get_buffer()); + } + } catch (cl::Error const& err) { + throw ocl::ocl_error(err); + } +} + +memory::ptr ocl_engine::reinterpret_handle(const layout& new_layout, shared_mem_params params) { + try { + if (new_layout.format.is_image_2d() && params.mem_type == shared_mem_type::shared_mem_image) { + cl::Image2D img(static_cast(params.mem), true); + return std::make_shared(this, new_layout, img); + } else if (new_layout.format.is_image_2d() && params.mem_type == shared_mem_type::shared_mem_vasurface) { + return std::make_shared(this, new_layout, params); +#ifdef _WIN32 + } else if (params.mem_type == shared_mem_type::shared_mem_dxbuffer) { + return std::make_shared(this, new_layout, params); +#endif + } else if (params.mem_type == shared_mem_type::shared_mem_buffer) { + cl::Buffer buf(static_cast(params.mem), true); + return std::make_shared(this, new_layout, buf); + } else { + throw std::runtime_error("unknown shared object fromat or type"); + } + } + catch (const cl::Error& clErr) { + switch (clErr.err()) { + case CL_MEM_OBJECT_ALLOCATION_FAILURE: + case CL_OUT_OF_RESOURCES: + case CL_OUT_OF_HOST_MEMORY: + case CL_INVALID_BUFFER_SIZE: + throw std::runtime_error("out of GPU resources"); + default: + throw std::runtime_error("GPU buffer allocation failed"); + } + } +} + +bool ocl_engine::is_the_same_buffer(const memory& mem1, const memory& mem2) { + if (mem1.get_engine() != this || mem2.get_engine() != this) + return false; + if (mem1.get_allocation_type() != mem2.get_allocation_type()) + return false; + if (&mem1 == &mem2) + return true; + + if (!memory_capabilities::is_usm_type(mem1.get_allocation_type())) + return (reinterpret_cast(mem1).get_buffer() == + reinterpret_cast(mem2).get_buffer()); + else + return (reinterpret_cast(mem1).get_buffer() == + reinterpret_cast(mem2).get_buffer()); +} + +void* ocl_engine::get_user_context() const { + auto& cl_device = downcast(*_device); + return static_cast(cl_device.get_context().get()); +} + +bool ocl_engine::extension_supported(std::string extension) const { + return _extensions.find(extension) != std::string::npos; +} + +stream::ptr ocl_engine::create_stream() const { + return std::make_shared(*this); +} + +stream& ocl_engine::get_program_stream() const { + return *_program_stream; +} + +std::shared_ptr ocl_engine::create(const device::ptr device, runtime_types runtime_type, const engine_configuration& configuration) { + return std::make_shared(device, runtime_type, configuration); +} + +std::shared_ptr create_ocl_engine(const device::ptr device, runtime_types runtime_type, const engine_configuration& configuration) { + return ocl_engine::create(device, runtime_type, configuration); +} + +} // namespace ocl +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_engine.hpp b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_engine.hpp new file mode 100644 index 00000000000000..d0916fcc6458f7 --- /dev/null +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_engine.hpp @@ -0,0 +1,51 @@ +// Copyright (C) 2016-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "cldnn/runtime/memory.hpp" +#include "cldnn/runtime/engine.hpp" +#include "cldnn/runtime/stream.hpp" +#include "ocl_device.hpp" + +#include +#include +#include +#include +#include + +namespace cldnn { +namespace ocl { + +class ocl_engine : public engine { +public: + ocl_engine(const device::ptr dev, runtime_types runtime_type, const engine_configuration& conf); + engine_types type() const override { return engine_types::ocl; }; + runtime_types runtime_type() const override { return runtime_types::ocl; }; + + memory_ptr allocate_memory(const layout& layout, allocation_type type, bool reset = true) override; + memory_ptr reinterpret_handle(const layout& new_layout, shared_mem_params params) override; + memory_ptr reinterpret_buffer(const memory& memory, const layout& new_layout) override; + bool is_the_same_buffer(const memory& mem1, const memory& mem2) override; + + void* get_user_context() const override; + + allocation_type get_default_allocation_type() const override { return allocation_type::cl_mem; } + + const cl::Context& get_cl_context() const; + const cl::Device& get_cl_device() const; + + bool extension_supported(std::string extension) const; + + stream_ptr create_stream() const override; + stream& get_program_stream() const override; + + static std::shared_ptr create(const device::ptr device, runtime_types runtime_type, const engine_configuration& configuration); +private: + std::string _extensions; + std::unique_ptr _program_stream; +}; + +} // namespace ocl +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_engine_factory.hpp b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_engine_factory.hpp new file mode 100644 index 00000000000000..3d2530c234281f --- /dev/null +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_engine_factory.hpp @@ -0,0 +1,19 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "cldnn/runtime/device.hpp" +#include "cldnn/runtime/engine.hpp" +#include "cldnn/runtime/stream.hpp" + +namespace cldnn { +namespace ocl { + +// Factory for ocl_engine creation. It's moved outside of ocl_engine class to avoid possible CL includes conflict +// between different engines in engine.cpp file +std::shared_ptr create_ocl_engine(const device::ptr device, runtime_types runtime_type, const engine_configuration& configuration); + +} // namespace ocl +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/events_pool.h b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_events_pool.hpp similarity index 57% rename from inference-engine/thirdparty/clDNN/src/gpu/events_pool.h rename to inference-engine/thirdparty/clDNN/runtime/ocl/ocl_events_pool.hpp index 9fdf0a23fabe44..d8fde6242b5bcc 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/events_pool.h +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_events_pool.hpp @@ -2,18 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include "refcounted_obj.h" -#include "event_impl.h" -#include "meta_utils.h" +#include "cldnn/runtime/utils.hpp" +#include "cldnn/runtime/event.hpp" + #include #include #include namespace cldnn { -namespace gpu { - -class gpu_toolkit; +namespace ocl { template ::value>::type> @@ -23,14 +20,14 @@ class event_pool_impl { using type = Type; - event_impl::ptr get_from_pool(std::shared_ptr& ctx) { + event::ptr get_from_pool(const cl::Context& ctx) { for (auto& ev : _events) { if (!ev->is_valid()) { ev->reset(); return ev; } } - const event_impl::ptr ev_impl { new Type(ctx), false }; + auto ev_impl = std::make_shared(ctx); return allocate(ev_impl); } @@ -39,36 +36,36 @@ class event_pool_impl { } private: - std::vector _events; + std::vector _events; - event_impl::ptr allocate(const event_impl::ptr& obj) { + event::ptr allocate(const event::ptr& obj) { _events.emplace_back(obj); return _events.back(); } }; struct base_event_pool : event_pool_impl { - event_impl::ptr get(std::shared_ptr& ctx, const cl::Event& ev, const uint64_t q_stamp) { + event::ptr get(const cl::Context& ctx, const cl::Event& ev, const uint64_t q_stamp) { auto ret = get_from_pool(ctx); - dynamic_cast(ret.get())->attach_ocl_event(ev, q_stamp); + std::dynamic_pointer_cast(ret)->attach_ocl_event(ev, q_stamp); return ret; } void reset() { reset_events(); } }; struct user_event_pool : event_pool_impl { - event_impl::ptr get(std::shared_ptr& ctx, bool set = false) { + event::ptr get(const cl::Context& ctx, bool set = false) { auto ret = get_from_pool(ctx); - dynamic_cast(ret.get())->attach_event(set); + downcast(ret.get())->attach_event(set); return ret; } void reset() { reset_events(); } }; struct group_event_pool : event_pool_impl { - event_impl::ptr get(std::shared_ptr& ctx, const std::vector& deps) { + event::ptr get(const cl::Context& ctx, const std::vector& deps) { auto ret_ev = get_from_pool(ctx); - dynamic_cast(ret_ev.get())->attach_events(deps); + downcast(ret_ev.get())->attach_events(deps); return ret_ev; } void reset() { reset_events(); } @@ -78,15 +75,15 @@ class events_pool { public: events_pool() = default; - event_impl::ptr get_from_base_pool(std::shared_ptr ctx, const cl::Event& ev, const uint64_t q_stamp) { + event::ptr get_from_base_pool(const cl::Context& ctx, const cl::Event& ev, const uint64_t q_stamp) { return _base_pool.get(ctx, ev, q_stamp); } - event_impl::ptr get_from_user_pool(std::shared_ptr ctx, bool set = false) { + event::ptr get_from_user_pool(const cl::Context& ctx, bool set = false) { return _user_pool.get(ctx, set); } - event_impl::ptr get_from_group_pool(std::shared_ptr ctx, const std::vector& deps) { + event::ptr get_from_group_pool(const cl::Context& ctx, const std::vector& deps) { return _group_pool.get(ctx, deps); } @@ -101,5 +98,5 @@ class events_pool { user_event_pool _user_pool; group_event_pool _group_pool; }; -} // namespace gpu +} // namespace ocl } // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/common/include/cl2_ext.hpp b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_ext.hpp similarity index 97% rename from inference-engine/thirdparty/clDNN/common/include/cl2_ext.hpp rename to inference-engine/thirdparty/clDNN/runtime/ocl/ocl_ext.hpp index 8af34068af8d99..bacaeb03b008df 100644 --- a/inference-engine/thirdparty/clDNN/common/include/cl2_ext.hpp +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_ext.hpp @@ -52,11 +52,9 @@ CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_FEATURE_CAPABILITIES_INTE namespace { template T load_entrypoint(const cl_platform_id platform, const std::string name) { - T p = reinterpret_cast( - clGetExtensionFunctionAddressForPlatform(platform, name.c_str())); + T p = reinterpret_cast(clGetExtensionFunctionAddressForPlatform(platform, name.c_str())); if (!p) { - throw std::runtime_error("clGetExtensionFunctionAddressForPlatform(" + - name + ") returned NULL."); + throw std::runtime_error("clGetExtensionFunctionAddressForPlatform(" + name + ") returned NULL."); } return p; } @@ -64,11 +62,9 @@ T load_entrypoint(const cl_platform_id platform, const std::string name) { template T load_entrypoint(const cl_device_id device, const std::string name) { cl_platform_id platform; - cl_int error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform), - &platform, nullptr); + cl_int error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform), &platform, nullptr); if (error) { - throw std::runtime_error("Failed to retrieve CL_DEVICE_PLATFORM: " + - std::to_string(error)); + throw std::runtime_error("Failed to retrieve CL_DEVICE_PLATFORM: " + std::to_string(error)); } return load_entrypoint(platform, name); } @@ -78,20 +74,16 @@ T load_entrypoint(const cl_device_id device, const std::string name) { template T load_entrypoint(const cl_context context, const std::string name) { size_t size = 0; - cl_int error = - clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, nullptr, &size); + cl_int error = clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, nullptr, &size); if (error) { - throw std::runtime_error("Failed to retrieve CL_CONTEXT_DEVICES size: " + - std::to_string(error)); + throw std::runtime_error("Failed to retrieve CL_CONTEXT_DEVICES size: " + std::to_string(error)); } std::vector devices(size / sizeof(cl_device_id)); - error = clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices.data(), - nullptr); + error = clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices.data(), nullptr); if (error) { - throw std::runtime_error("Failed to retrieve CL_CONTEXT_DEVICES: " + - std::to_string(error)); + throw std::runtime_error("Failed to retrieve CL_CONTEXT_DEVICES: " + std::to_string(error)); } return load_entrypoint(devices.front(), name); @@ -148,11 +140,6 @@ inline void* deviceMemAlloc(const cl::Device& cpp_device, const cl::Context& cpp return fn(cpp_context.get(), cpp_device.get(), properties, size, alignment, err_code_ret); } -inline cl_int memFree(const cl::Context& cpp_context, void* ptr) { - clMemFreeINTEL_fn fn = load_entrypoint(cpp_context.get(), "clMemFreeINTEL"); - return fn(cpp_context.get(), ptr); -} - inline cl_int set_kernel_arg_mem_pointer(const cl::Kernel& kernel, uint32_t index, const void* ptr, clSetKernelArgMemPointerINTEL_fn fn) { return fn(kernel.get(), index, ptr); } @@ -605,12 +592,20 @@ typedef CL_API_ENTRY cl_mem(CL_API_CALL * PFN_clCreateFromMediaSurfaceINTEL)( */ class UsmHolder { public: - explicit UsmHolder(Context& ctx, void* ptr) : _ctx(ctx), _ptr(ptr) {} + explicit UsmHolder(Context& ctx, void* ptr) : _ctx(ctx), _ptr(ptr), deleter(nullptr) { + deleter = load_entrypoint(_ctx.get(), "clMemFreeINTEL"); + if (!deleter) { + throw std::runtime_error("clMemFreeINTEL is nullptr in UsmHolder"); + } + } void* ptr() { return _ptr; } - ~UsmHolder() { usm::memFree(_ctx, _ptr); } + ~UsmHolder() { + deleter(_ctx.get(), _ptr); + } private: Context _ctx; void* _ptr; + clMemFreeINTEL_fn deleter; }; /* diff --git a/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_kernel.hpp b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_kernel.hpp new file mode 100644 index 00000000000000..4bda3ef8f31608 --- /dev/null +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_kernel.hpp @@ -0,0 +1,33 @@ +// Copyright (C) 2016-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "ocl_common.hpp" +#include "ocl_memory.hpp" +#include "cldnn/runtime/kernel_args.hpp" +#include "cldnn/runtime/kernel.hpp" + +#include +#include + +namespace cldnn { +namespace ocl { + +class ocl_kernel : public kernel { + ocl_kernel_type _compiled_kernel; + std::string _kernel_id; + +public: + ocl_kernel(ocl_kernel_type compiled_kernel, const std::string& kernel_id) + : _compiled_kernel(compiled_kernel) + , _kernel_id(kernel_id) { } + + const ocl_kernel_type& get_handle() const { return _compiled_kernel; } + ocl_kernel_type& get_handle() { return _compiled_kernel; } + std::shared_ptr clone() const override { return std::make_shared(get_handle().clone(), _kernel_id); } +}; + +} // namespace ocl +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_kernels_factory.cpp b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_kernels_factory.cpp new file mode 100644 index 00000000000000..29a431442616ab --- /dev/null +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_kernels_factory.cpp @@ -0,0 +1,21 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "ocl_kernel.hpp" +#include "kernels_factory.hpp" + +#include +#include + +namespace cldnn { +namespace ocl { + +std::shared_ptr create_ocl_kernel(engine& engine, cl_context /* context */, cl_kernel kernel, std::string entry_point) { + // Retain kernel to keep it valid + cl::Kernel k(kernel, true); + return std::make_shared(ocl::ocl_kernel_type(k, engine.use_unified_shared_memory()), entry_point); +} + +} // namespace kernels_factory +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_memory.cpp b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_memory.cpp new file mode 100644 index 00000000000000..9a5c2b3aa52ab0 --- /dev/null +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_memory.cpp @@ -0,0 +1,373 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "cldnn/runtime/error_handler.hpp" +#include "cldnn/runtime/utils.hpp" +#include "ocl_memory.hpp" +#include "ocl_engine.hpp" +#include "ocl_stream.hpp" +#include "ocl_base_event.hpp" +#include +#include + +namespace cldnn { +namespace ocl { + +gpu_buffer::gpu_buffer(ocl_engine* engine, + const layout& layout) + : lockable_gpu_mem(), memory(engine, layout, allocation_type::cl_mem, false) + , _buffer(engine->get_cl_context(), CL_MEM_READ_WRITE, size()) { } + +gpu_buffer::gpu_buffer(ocl_engine* engine, + const layout& new_layout, + const cl::Buffer& buffer) + : lockable_gpu_mem(), memory(engine, new_layout, allocation_type::cl_mem, true) + , _buffer(buffer) {} + +void* gpu_buffer::lock(const stream& stream) { + auto& cl_stream = downcast(stream); + std::lock_guard locker(_mutex); + if (0 == _lock_count) { + _mapped_ptr = cl_stream.get_cl_queue().enqueueMapBuffer(_buffer, CL_TRUE, CL_MAP_WRITE, 0, size()); + } + _lock_count++; + return _mapped_ptr; +} + +void gpu_buffer::unlock(const stream& stream) { + auto& cl_stream = downcast(stream); + std::lock_guard locker(_mutex); + _lock_count--; + if (0 == _lock_count) { + cl_stream.get_cl_queue().enqueueUnmapMemObject(_buffer, _mapped_ptr); + _mapped_ptr = nullptr; + } +} + +event::ptr gpu_buffer::fill(stream& stream) { + return fill(stream, 0); +} + +event::ptr gpu_buffer::fill(stream& stream, unsigned char pattern) { + auto& cl_stream = downcast(stream); + auto ev = stream.create_base_event(); + cl::Event ev_ocl = std::dynamic_pointer_cast(ev)->get(); + cl_stream.get_cl_queue().enqueueFillBuffer(_buffer, pattern, 0, size(), nullptr, &ev_ocl); + + // TODO: do we need sync here? + cl_stream.finish(); + + return ev; +} + +shared_mem_params gpu_buffer::get_internal_params() const { + auto cl_engine = downcast(_engine); + return {shared_mem_type::shared_mem_buffer, static_cast(cl_engine->get_cl_context().get()), nullptr, + static_cast(_buffer.get()), +#ifdef _WIN32 + nullptr, +#else + 0, +#endif + 0}; +} + +event::ptr gpu_buffer::copy_from(stream& /* stream */, const memory& /* other */) { + throw std::runtime_error("[clDNN] copy_from is not implemented for gpu_buffer"); +} + +event::ptr gpu_buffer::copy_from(stream& stream, const void* host_ptr) { + auto& cl_stream = downcast(stream); + auto ev = stream.create_base_event(); + cl::Event ev_ocl = std::dynamic_pointer_cast(ev)->get(); + cl_stream.get_cl_queue().enqueueWriteBuffer(_buffer, false, 0, size(), host_ptr, nullptr, &ev_ocl); + + return ev; +} + +gpu_image2d::gpu_image2d(ocl_engine* engine, const layout& layout) + : lockable_gpu_mem(), memory(engine, layout, allocation_type::cl_mem, false), _row_pitch(0), _slice_pitch(0) { + cl_channel_type type = layout.data_type == data_types::f16 ? CL_HALF_FLOAT : CL_FLOAT; + cl_channel_order order = CL_R; + switch (layout.format) { + case format::image_2d_weights_c1_b_fyx: + _width = layout.size.batch[0]; + _height = layout.size.spatial[0] * layout.size.feature[0] * layout.size.spatial[1]; + break; + case format::image_2d_weights_winograd_6x3_s1_fbxyb: + _height = layout.size.feature[0]; + _width = layout.size.spatial[0] * layout.size.batch[0] * layout.size.spatial[1] * 8 / 3; + break; + case format::image_2d_weights_winograd_6x3_s1_xfbyb: + _height = layout.size.feature[0] * layout.size.spatial[0] * 8 / 3; + _width = layout.size.batch[0] * layout.size.spatial[1]; + break; + case format::image_2d_weights_c4_fyx_b: + _width = layout.size.batch[0]; + _height = layout.size.spatial[0] * layout.size.feature[0] * layout.size.spatial[1]; + order = CL_RGBA; + break; + case format::image_2d_rgba: + _width = layout.size.spatial[0]; + _height = layout.size.spatial[1]; + order = CL_RGBA; + if (layout.size.feature[0] != 3 && layout.size.feature[0] != 4) { + CLDNN_ERROR_MESSAGE("2D image allocation", "invalid number of channels in image_2d_rgba input image (should be 3 or 4)!"); + } + type = CL_UNORM_INT8; + break; + case format::nv12: + _width = layout.size.spatial[1]; + _height = layout.size.spatial[0]; + if (layout.size.feature[0] == 2) { + order = CL_RG; + } else if (layout.size.feature[0] > 2) { + CLDNN_ERROR_MESSAGE("2D image allocation", "invalid number of channels in NV12 input image!"); + } + type = CL_UNORM_INT8; + break; + default: + CLDNN_ERROR_MESSAGE("2D image allocation", "unsupported image type!"); + } + + cl::ImageFormat imageFormat(order, type); + _buffer = cl::Image2D(engine->get_cl_context(), CL_MEM_READ_WRITE, imageFormat, _width, _height, 0); +} + +gpu_image2d::gpu_image2d(ocl_engine* engine, + const layout& new_layout, + const cl::Image2D& buffer) + : lockable_gpu_mem(), memory(engine, new_layout, allocation_type::cl_mem, true), + _buffer(buffer) { + _width = _buffer.getImageInfo(); + _height = _buffer.getImageInfo(); + _row_pitch = _buffer.getImageInfo(); + _slice_pitch = _buffer.getImageInfo(); +} + +event::ptr gpu_image2d::fill(stream& stream) { + return fill(stream, 0); +} + +event::ptr gpu_image2d::fill(stream& stream, unsigned char pattern) { + auto& cl_stream = downcast(stream); + auto ev = stream.create_base_event(); + cl::Event ev_ocl = downcast(ev.get())->get(); + cl_uint4 pattern_uint4 = {pattern, pattern, pattern, pattern}; + cl_stream.get_cl_queue().enqueueFillImage(_buffer, pattern_uint4, {0, 0, 0}, {_width, _height, 1}, 0, &ev_ocl); + + // TODO: do we need sync here? + cl_stream.finish(); + + return ev; +} + +void* gpu_image2d::lock(const stream& stream) { + auto& cl_stream = downcast(stream); + std::lock_guard locker(_mutex); + if (0 == _lock_count) { + _mapped_ptr = cl_stream.get_cl_queue() + .enqueueMapImage(_buffer, + CL_TRUE, + CL_MAP_WRITE, + {0, 0, 0}, + {_width, _height, 1}, + &_row_pitch, + &_slice_pitch); + } + _lock_count++; + return _mapped_ptr; +} + +void gpu_image2d::unlock(const stream& stream) { + auto& cl_stream = downcast(stream); + std::lock_guard locker(_mutex); + _lock_count--; + if (0 == _lock_count) { + cl_stream.get_cl_queue().enqueueUnmapMemObject(_buffer, _mapped_ptr); + _mapped_ptr = nullptr; + } +} + + +shared_mem_params gpu_image2d::get_internal_params() const { + auto cl_engine = downcast(_engine); + return {shared_mem_type::shared_mem_image, static_cast(cl_engine->get_cl_context().get()), nullptr, + static_cast(_buffer.get()), +#ifdef _WIN32 + nullptr, +#else + 0, +#endif + 0}; +} + +event::ptr gpu_image2d::copy_from(stream& /* stream */, const memory& /* other */) { + throw std::runtime_error("[clDNN] copy_from is not implemented for gpu_image2d"); +} + +event::ptr gpu_image2d::copy_from(stream& /* stream */, const void* /* host_ptr */) { + throw std::runtime_error("[clDNN] copy_from is not implemented for gpu_image2d"); +} + +gpu_media_buffer::gpu_media_buffer(ocl_engine* engine, + const layout& new_layout, + shared_mem_params params) + : gpu_image2d(engine, new_layout, cl::ImageVA(engine->get_cl_context(), CL_MEM_READ_WRITE, params.surface, params.plane)), + device(params.user_device), + surface(params.surface), + plane(params.plane) { } + +shared_mem_params gpu_media_buffer::get_internal_params() const { + auto cl_engine = downcast(_engine); + return {shared_mem_type::shared_mem_vasurface, static_cast(cl_engine->get_cl_context().get()), device, + static_cast(_buffer.get()), surface, plane }; +} + +#ifdef _WIN32 +gpu_dx_buffer::gpu_dx_buffer(ocl_engine* engine, + const layout& new_layout, + shared_mem_params params) + : gpu_buffer(engine, new_layout, + cl::BufferDX(engine->get_cl_context(), CL_MEM_READ_WRITE, params.mem)), + device(params.user_device), + resource(params.mem) { } + +shared_mem_params gpu_dx_buffer::get_internal_params() const { + auto cl_engine = downcast(_engine); + return {shared_mem_type::shared_mem_dxbuffer, static_cast(cl_engine->get_cl_context().get()), device, + static_cast(_buffer.get()), resource, 0 }; +} +#endif + +gpu_usm::gpu_usm(ocl_engine* engine, + const layout& new_layout, const cl::UsmMemory& buffer, + allocation_type type) + : lockable_gpu_mem() + , memory(engine, new_layout, type, true) + , _buffer(buffer) { +} + +gpu_usm::gpu_usm(ocl_engine* engine, const layout& layout, allocation_type type) + : lockable_gpu_mem() + , memory(engine, layout, type, false) + , _buffer(engine->get_cl_context()) { + auto device = engine->get_cl_device(); + switch (get_allocation_type()) { + case allocation_type::usm_host: + _buffer.allocateHost(_bytes_count); + break; + case allocation_type::usm_shared: + _buffer.allocateShared(device, _bytes_count); + break; + case allocation_type::usm_device: + _buffer.allocateDevice(device, _bytes_count); + break; + default: + CLDNN_ERROR_MESSAGE("gpu_usm allocation type", + "Unknown unified shared memory type!"); + } +} + +void* gpu_usm::lock(const stream& stream) { + assert(get_allocation_type() != allocation_type::usm_device && "Can't lock usm device memory!"); + std::lock_guard locker(_mutex); + if (0 == _lock_count) { + stream.finish(); // Synchronization needed for OOOQ. + _mapped_ptr = _buffer.get(); + } + _lock_count++; + return _mapped_ptr; +} + +void gpu_usm::unlock(const stream& /* stream */) { + std::lock_guard locker(_mutex); + _lock_count--; + if (0 == _lock_count) { + _mapped_ptr = nullptr; + } +} + +event::ptr gpu_usm::fill(stream& stream, unsigned char pattern) { + auto& cl_stream = downcast(stream); + auto ev = stream.create_base_event(); + cl::Event ev_ocl = downcast(ev.get())->get(); + // enqueueFillUsm call will never finish. Driver bug? Uncomment when fixed. Some older drivers doesn't support enqueueFillUsm call at all. + // cl_stream.get_cl_queue().enqueueFillUsm(_buffer, pattern, _bytes_count, nullptr, &ev_ocl) + // Workarounded with enqeue_memcopy. ToDo: Remove below code. Uncomment above. + std::vector temp_buffer(_bytes_count, pattern); + // TODO: Do we really need blocking call here? Non-blocking one causes accuracy issues right now, but hopefully it can be fixed in more performant way. + const bool blocking = true; + cl::usm::enqueue_memcpy(cl_stream.get_cl_queue(), _buffer.get(), temp_buffer.data(), _bytes_count, blocking, nullptr, &ev_ocl); + + return ev; +} + +event::ptr gpu_usm::fill(stream& stream) { + // event::ptr ev{ new base_event(_context), false }; + // cl::Event ev_ocl = downcast(ev.get())->get(); + // cl::usm::enqueue_set_mem(cl_stream.get_cl_queue(), _buffer.get(), 0, _bytes_count, nullptr, &ev_ocl); + // ev->wait(); + + // [WA] + return fill(stream, 0); +} + +event::ptr gpu_usm::copy_from(stream& stream, const memory& other) { + auto& cl_stream = downcast(stream); + auto& casted = downcast(other); + cl_stream.get_cl_queue().enqueueCopyUsm(casted.get_buffer(), get_buffer(), _bytes_count, true); + return stream.create_user_event(true); +} + +event::ptr gpu_usm::copy_from(stream& /* stream */, const void* /* host_ptr */) { + throw std::runtime_error("[clDNN] copy_from is not implemented for gpu_usm"); +} + +shared_mem_params gpu_usm::get_internal_params() const { + auto cl_engine = downcast(_engine); + return { + shared_mem_type::shared_mem_empty, // shared_mem_type + static_cast(cl_engine->get_cl_context().get()), // context handle + nullptr, // user_device handle + nullptr, // mem handle +#ifdef _WIN32 + nullptr, // surface handle +#else + 0, // surface handle +#endif + 0 // plane + }; +} + +std::vector ocl_surfaces_lock::get_handles(std::vector mem) const { + std::vector res; + for (auto& m : mem) { + auto mem_type = m->get_internal_params().mem_type; + if (mem_type == shared_mem_type::shared_mem_vasurface || mem_type == shared_mem_type::shared_mem_dxbuffer) { + res.push_back(static_cast(m->get_internal_params().mem)); + } + } + + return res; +} + +ocl_surfaces_lock::ocl_surfaces_lock(std::vector mem, const stream& stream) + : surfaces_lock() + , _stream(stream) + , _handles(get_handles(mem)) + , _lock(nullptr) { + cl_int err = CL_SUCCESS; + + auto& cl_stream = downcast(stream); + auto queue = cl_stream.get_cl_queue(); + _lock.reset(new cl::SharedSurfLock(queue.get(), _handles, &err)); + // TODO: err code for some reason is 32766 + if (/* err != CL_SUCCESS || */ !_lock) { + throw std::runtime_error("Unable to lock shared surface (" + std::to_string(err) + ")"); + } +} + +} // namespace ocl +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_memory.hpp b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_memory.hpp new file mode 100644 index 00000000000000..f7590e366b880e --- /dev/null +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_memory.hpp @@ -0,0 +1,128 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "ocl_common.hpp" +#include "ocl_engine.hpp" +#include "ocl_stream.hpp" +#include "cldnn/runtime/memory.hpp" + +#include +#include +#include +#include + +namespace cldnn { +namespace ocl { +struct lockable_gpu_mem { + lockable_gpu_mem() : + _lock_count(0), + _mapped_ptr(nullptr) {} + + std::mutex _mutex; + unsigned _lock_count; + void* _mapped_ptr; +}; + +struct gpu_buffer : public lockable_gpu_mem, public memory { + gpu_buffer(ocl_engine* engine, const layout& new_layout, const cl::Buffer& buffer); + gpu_buffer(ocl_engine* engine, const layout& layout); + + void* lock(const stream& stream) override; + void unlock(const stream& stream) override; + event::ptr fill(stream& stream, unsigned char pattern) override; + event::ptr fill(stream& stream) override; + shared_mem_params get_internal_params() const override; + const cl::Buffer& get_buffer() const { + assert(0 == _lock_count); + return _buffer; + } + + event::ptr copy_from(stream& stream, const memory& other) override; + event::ptr copy_from(stream& stream, const void* host_ptr) override; + +protected: + cl::Buffer _buffer; +}; + +struct gpu_image2d : public lockable_gpu_mem, public memory { + gpu_image2d(ocl_engine* engine, const layout& new_layout, const cl::Image2D& buffer); + gpu_image2d(ocl_engine* engine, const layout& layout); + + void* lock(const stream& stream) override; + void unlock(const stream& stream) override; + event::ptr fill(stream& stream, unsigned char pattern) override; + event::ptr fill(stream& stream) override; + shared_mem_params get_internal_params() const override; + const cl::Image2D& get_buffer() const { + assert(0 == _lock_count); + return _buffer; + } + + event::ptr copy_from(stream& /* stream */, const memory& /* other */) override; + event::ptr copy_from(stream& /* stream */, const void* /* other */) override; + +protected: + cl::Image2D _buffer; + size_t _width; + size_t _height; + size_t _row_pitch; + size_t _slice_pitch; +}; + +struct gpu_media_buffer : public gpu_image2d { + gpu_media_buffer(ocl_engine* engine, const layout& new_layout, shared_mem_params params); + shared_mem_params get_internal_params() const override; +private: + void* device; +#ifdef _WIN32 + void* surface; +#else + uint32_t surface; +#endif + uint32_t plane; +}; + +#ifdef _WIN32 +struct gpu_dx_buffer : public gpu_buffer { + gpu_dx_buffer(ocl_engine* engine, const layout& new_layout, shared_mem_params VAEncMiscParameterTypeSubMbPartPel); + shared_mem_params get_internal_params() const override; +private: + void* device; + void* resource; +}; +#endif + +struct gpu_usm : public lockable_gpu_mem, public memory { + gpu_usm(ocl_engine* engine, const layout& new_layout, const cl::UsmMemory& usm_buffer, allocation_type type); + gpu_usm(ocl_engine* engine, const layout& layout, allocation_type type); + + void* lock(const stream& stream) override; + void unlock(const stream& stream) override; + const cl::UsmMemory& get_buffer() const { return _buffer; } + cl::UsmMemory& get_buffer() { return _buffer; } + + event::ptr fill(stream& stream, unsigned char pattern) override; + event::ptr fill(stream& stream) override; + shared_mem_params get_internal_params() const override; + + event::ptr copy_from(stream& stream, const memory& other) override; + event::ptr copy_from(stream& stream, const void* host_ptr) override; +protected: + cl::UsmMemory _buffer; +}; + +struct ocl_surfaces_lock : public surfaces_lock { + ocl_surfaces_lock(std::vector mem, const stream& stream); + + ~ocl_surfaces_lock() = default; +private: + std::vector get_handles(std::vector mem) const; + const stream& _stream; + std::vector _handles; + std::unique_ptr _lock; +}; +} // namespace ocl +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_stream.cpp b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_stream.cpp new file mode 100644 index 00000000000000..508f2114214a2f --- /dev/null +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_stream.cpp @@ -0,0 +1,428 @@ +// Copyright (C) 2019-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "ocl_stream.hpp" +#include "ocl_base_event.hpp" +#include "ocl_user_event.hpp" +#include "ocl_command_queues_builder.hpp" +#include "ocl_events_pool.hpp" +#include "ocl_kernel.hpp" +#include "ocl_common.hpp" + +#include +#include +#include + +#include +#include +#include +#include +#include + +// NOTE: Due to buggy scope transition of warnings we need to disable warning in place of use/instantation +// of some types (even though we already disabled them in scope of definition of these types). +// Moreover this warning is pretty much now only for annoyance: it is generated due to lack +// of proper support for mangling of custom GCC attributes into type name (usually when used +// with templates, even from standard library). +#if defined __GNUC__ && __GNUC__ >= 6 +#pragma GCC diagnostic ignored "-Wignored-attributes" +#endif + +namespace cldnn { +namespace ocl { + +namespace { +inline cl::NDRange toNDRange(const std::vector& v) { + switch (v.size()) { + case 1: + return cl::NDRange(v[0]); + case 2: + return cl::NDRange(v[0], v[1]); + case 3: + return cl::NDRange(v[0], v[1], v[2]); + default: + return cl::NullRange; + } +} + +void set_arguments_impl(ocl_kernel_type& kernel, + const arguments_desc& args, + const kernel_arguments_data& data) { + using args_t = argument_desc::Types; + using scalar_t = scalar_desc::Types; + for (uint32_t i = 0; i < static_cast(args.size()); i++) { + cl_int status = CL_INVALID_ARG_VALUE; + switch (args[i].t) { + case args_t::INPUT: + if (args[i].index < data.inputs.size() && data.inputs[args[i].index]) { + const auto& input_mem = data.inputs[args[i].index]; + if (input_mem) { + if (input_mem->get_layout().format.is_image_2d()) + status = kernel.setArg(i, std::dynamic_pointer_cast(input_mem)->get_buffer()); + else if (memory_capabilities::is_usm_type(input_mem->get_allocation_type())) + status = kernel.setArgUsm(i, std::dynamic_pointer_cast(input_mem)->get_buffer()); + else + status = kernel.setArg(i, std::dynamic_pointer_cast(input_mem)->get_buffer()); + } + } + break; + case args_t::INPUT_OF_FUSED_PRIMITIVE: + if (args[i].index < data.fused_op_inputs.size() && data.fused_op_inputs[args[i].index]) { + const auto& input_mem = data.fused_op_inputs[args[i].index]; + if (input_mem) { + if (memory_capabilities::is_usm_type(input_mem->get_allocation_type())) + status = kernel.setArgUsm(i, std::dynamic_pointer_cast(input_mem)->get_buffer()); + else + status = kernel.setArg(i, std::dynamic_pointer_cast(input_mem)->get_buffer()); + } + } + break; + case args_t::INTERNAL_BUFFER: + if (args[i].index < data.intermediates.size() && data.intermediates[args[i].index]) { + const auto& input_mem = data.intermediates[args[i].index]; + if (input_mem) { + if (memory_capabilities::is_usm_type(input_mem->get_allocation_type())) + status = kernel.setArgUsm(i, std::dynamic_pointer_cast(input_mem)->get_buffer()); + else + status = kernel.setArg(i, std::dynamic_pointer_cast(input_mem)->get_buffer()); + } + } + break; + case args_t::OUTPUT: + if (data.output) { + if (data.output->get_layout().format.is_image_2d()) + status = kernel.setArg(i, std::dynamic_pointer_cast(data.output)->get_buffer()); + else if (memory_capabilities::is_usm_type(data.output->get_allocation_type())) + status = kernel.setArgUsm(i, std::dynamic_pointer_cast(data.output)->get_buffer()); + else + status = kernel.setArg(i, std::dynamic_pointer_cast(data.output)->get_buffer()); + } + break; + case args_t::WEIGHTS: + if (data.weights) { + if (data.weights->get_layout().format.is_image_2d()) + status = kernel.setArg(i, std::dynamic_pointer_cast(data.weights)->get_buffer()); + else if (memory_capabilities::is_usm_type(data.weights->get_allocation_type())) + status = kernel.setArgUsm(i, std::dynamic_pointer_cast(data.weights)->get_buffer()); + else + status = kernel.setArg(i, std::dynamic_pointer_cast(data.weights)->get_buffer()); + } + break; + case args_t::BIAS: + if (data.bias) { + if (memory_capabilities::is_usm_type(data.bias->get_allocation_type())) + status = kernel.setArgUsm(i, std::dynamic_pointer_cast(data.bias)->get_buffer()); + else + status = kernel.setArg(i, std::dynamic_pointer_cast(data.bias)->get_buffer()); + } + break; + case args_t::WEIGHTS_ZERO_POINTS: + if (data.weights_zero_points) { + if (memory_capabilities::is_usm_type(data.weights_zero_points->get_allocation_type())) + status = kernel.setArgUsm( + i, + std::dynamic_pointer_cast(data.weights_zero_points)->get_buffer()); + else + status = kernel.setArg( + i, + std::dynamic_pointer_cast(data.weights_zero_points)->get_buffer()); + } + break; + case args_t::ACTIVATIONS_ZERO_POINTS: + if (data.activations_zero_points) { + if (memory_capabilities::is_usm_type(data.activations_zero_points->get_allocation_type())) + status = kernel.setArgUsm( + i, + std::dynamic_pointer_cast(data.activations_zero_points)->get_buffer()); + else + status = kernel.setArg( + i, + std::dynamic_pointer_cast(data.activations_zero_points)->get_buffer()); + } + break; + case args_t::COMPENSATION: + if (data.compensation) { + if (memory_capabilities::is_usm_type(data.compensation->get_allocation_type())) + status = kernel.setArgUsm( + i, + std::dynamic_pointer_cast(data.compensation)->get_buffer()); + else + status = kernel.setArg( + i, + std::dynamic_pointer_cast(data.compensation)->get_buffer()); + } + break; + case args_t::SCALE_TABLE: + if (data.scale_table) { + if (memory_capabilities::is_usm_type(data.scale_table->get_allocation_type())) + status = kernel.setArgUsm(i, std::dynamic_pointer_cast(data.scale_table)->get_buffer()); + else + status = kernel.setArg(i, std::dynamic_pointer_cast(data.scale_table)->get_buffer()); + } + break; + case args_t::SLOPE: + if (data.slope) { + if (memory_capabilities::is_usm_type(data.slope->get_allocation_type())) + status = kernel.setArgUsm(i, std::dynamic_pointer_cast(data.slope)->get_buffer()); + else + status = kernel.setArg(i, std::dynamic_pointer_cast(data.slope)->get_buffer()); + } + break; + case args_t::SPLIT: + status = kernel.setArg(i, data.split); + break; + case args_t::SCALAR: + if (data.scalars && args[i].index < data.scalars->size()) { + const auto& scalar = (*data.scalars)[args[i].index]; + switch (scalar.t) { + case scalar_t::UINT8: + status = kernel.setArg(i, scalar.v.u8); + break; + case scalar_t::UINT16: + status = kernel.setArg(i, scalar.v.u16); + break; + case scalar_t::UINT32: + status = kernel.setArg(i, scalar.v.u32); + break; + case scalar_t::UINT64: + status = kernel.setArg(i, scalar.v.u64); + break; + case scalar_t::INT8: + status = kernel.setArg(i, scalar.v.s8); + break; + case scalar_t::INT16: + status = kernel.setArg(i, scalar.v.s16); + break; + case scalar_t::INT32: + status = kernel.setArg(i, scalar.v.s32); + break; + case scalar_t::INT64: + status = kernel.setArg(i, scalar.v.s64); + break; + case scalar_t::FLOAT32: + status = kernel.setArg(i, scalar.v.f32); + break; + case scalar_t::FLOAT64: + status = kernel.setArg(i, scalar.v.f64); + break; + default: + break; + } + } + break; + case args_t::RECURRENT: // RNN/LSTM/GRU layers + if (data.recurrent) { + if (data.recurrent->get_layout().format.is_image_2d()) + status = kernel.setArg(i, dynamic_cast(*data.recurrent).get_buffer()); + else if (memory_capabilities::is_usm_type(data.recurrent->get_allocation_type())) + status = kernel.setArgUsm(i, dynamic_cast(*data.recurrent).get_buffer()); + else + status = kernel.setArg(i, dynamic_cast(*data.recurrent).get_buffer()); + } + break; + case args_t::HIDDEN: // RNN/LSTM/GRU layers + if (data.hidden) { + if (data.hidden->get_layout().format.is_image_2d()) + status = kernel.setArg(i, dynamic_cast(*data.hidden).get_buffer()); + else if (memory_capabilities::is_usm_type(data.hidden->get_allocation_type())) + status = kernel.setArgUsm(i, dynamic_cast(*data.hidden).get_buffer()); + else + status = kernel.setArg(i, dynamic_cast(*data.hidden).get_buffer()); + } + break; + case args_t::CELL: // LSTMlayers + if (data.cell) { + if (data.cell->get_layout().format.is_image_2d()) + status = kernel.setArg(i, dynamic_cast(*data.cell).get_buffer()); + else if (memory_capabilities::is_usm_type(data.cell->get_allocation_type())) + status = kernel.setArgUsm(i, dynamic_cast(*data.cell).get_buffer()); + else + status = kernel.setArg(i, dynamic_cast(*data.cell).get_buffer()); + } + break; + default: + break; + } + + if (status != CL_SUCCESS) { + throw std::runtime_error("Error set arg " + std::to_string(i) + ", error code: " + std::to_string(status) + "\n"); + } + } +} +} // namespace + +ocl_stream::ocl_stream(const ocl_engine& engine) : stream(engine.configuration().queue_type), _engine(engine) { + auto context = engine.get_cl_context(); + auto device = engine.get_cl_device(); + auto config = engine.configuration(); + ocl::command_queues_builder queue_builder; + queue_builder.set_profiling(config.enable_profiling); + queue_builder.set_out_of_order((config.queue_type == queue_types::out_of_order)); + + sync_method = _engine.configuration().enable_profiling ? sync_methods::events : + config.queue_type == queue_types::out_of_order ? sync_methods::barriers : sync_methods::none; + + if (sync_method == sync_methods::none && config.queue_type == queue_types::out_of_order) { + throw std::runtime_error("[CLDNN] Unexpected sync method (none) is specified for out_of_order queue"); + } + + bool priorty_extensions = engine.extension_supported("cl_khr_priority_hints") && engine.extension_supported("cl_khr_create_command_queue"); + queue_builder.set_priority_mode(config.priority_mode, priorty_extensions); + + bool throttle_extensions = engine.extension_supported("cl_khr_throttle_hints") && engine.extension_supported("cl_khr_create_command_queue"); + queue_builder.set_throttle_mode(config.throttle_mode, throttle_extensions); + + _command_queue = queue_builder.build(context, device); + _events_pool.reset(new events_pool()); +} + +void ocl_stream::set_arguments(kernel& kernel, const kernel_arguments_desc& args_desc, const kernel_arguments_data& args) { + static std::mutex m; + std::lock_guard guard(m); + + auto& ocl_kernel = downcast(kernel); + + auto& kern = ocl_kernel.get_handle(); + + try { + set_arguments_impl(kern, args_desc.arguments, args); + } catch (cl::Error const& err) { + throw ocl_error(err); + } +} + +event::ptr ocl_stream::enqueue_kernel(kernel& kernel, + const kernel_arguments_desc& args_desc, + const kernel_arguments_data& /* args */, + std::vector const& deps, + bool is_output) { + auto& ocl_kernel = downcast(kernel); + + auto& kern = ocl_kernel.get_handle(); + auto global = toNDRange(args_desc.workGroups.global); + auto local = toNDRange(args_desc.workGroups.local); + std::vector dep_events; + std::vector* dep_events_ptr = nullptr; + if (sync_method == sync_methods::events) { + for (auto& dep : deps) { + if (auto ocl_base_ev = std::dynamic_pointer_cast(dep)) { + if (ocl_base_ev->get().get() != nullptr) + dep_events.push_back(ocl_base_ev->get()); + } + } + dep_events_ptr = &dep_events; + } else if (sync_method == sync_methods::barriers) { + sync_events(deps, is_output); + } + + cl::Event ret_ev; + + bool set_output_event = sync_method == sync_methods::events || is_output; + + try { + _command_queue.enqueueNDRangeKernel(kern, cl::NullRange, global, local, dep_events_ptr, set_output_event ? &ret_ev : nullptr); + } catch (cl::Error const& err) { + throw ocl_error(err); + } + + return _events_pool->get_from_base_pool(_engine.get_cl_context(), ret_ev, ++_queue_counter); +} + +void ocl_stream::enqueue_barrier() { + _command_queue.enqueueBarrierWithWaitList(nullptr, nullptr); +} + +event::ptr ocl_stream::enqueue_marker(std::vector const& deps, bool is_output) { + if (deps.empty()) + return _events_pool->get_from_user_pool(_engine.get_cl_context(), true); + + if (sync_method == sync_methods::events) { + cl::Event ret_ev; + std::vector dep_events; + for (auto& dep : deps) { + if (auto ocl_base_ev = dynamic_cast(dep.get())) + if (ocl_base_ev->get().get() != nullptr) + dep_events.push_back(ocl_base_ev->get()); + } + + try { + if (dep_events.empty()) { + return create_user_event(true); + } + _command_queue.enqueueMarkerWithWaitList(&dep_events, &ret_ev); + } catch (cl::Error const& err) { + throw ocl_error(err); + } + + return _events_pool->get_from_base_pool(_engine.get_cl_context(), ret_ev, ++_queue_counter); + } else if (sync_method == sync_methods::barriers) { + sync_events(deps, is_output); + return _events_pool->get_from_base_pool(_engine.get_cl_context(), _last_barrier_ev, _last_barrier); + } else { + return _events_pool->get_from_user_pool(_engine.get_cl_context(), true); + } +} + +event::ptr ocl_stream::group_events(std::vector const& deps) { + return _events_pool->get_from_group_pool(_engine.get_cl_context(), deps); +} + +event::ptr ocl_stream::create_user_event(bool set) { + return _events_pool->get_from_user_pool(_engine.get_cl_context(), set); +} + +event::ptr ocl_stream::create_base_event() { + cl::Event ret_ev; + return _events_pool->get_from_base_pool(_engine.get_cl_context(), ret_ev, ++_queue_counter); +} + +void ocl_stream::reset_events() { _events_pool->reset_events(); } + +void ocl_stream::release_events_pool() { _events_pool.reset(); } + +void ocl_stream::flush() const { get_cl_queue().flush(); } +void ocl_stream::finish() const { get_cl_queue().finish(); } + +void ocl_stream::wait_for_events(const std::vector& events) { + if (events.empty()) + return; + + std::vector clevents; + for (auto& ev : events) { + if (auto ocl_base_ev = dynamic_cast(ev.get())) + clevents.push_back(ocl_base_ev->get()); + } + + try { + cl::WaitForEvents(clevents); + } catch (cl::Error const& err) { + throw ocl_error(err); + } +} + +void ocl_stream::sync_events(std::vector const& deps, bool is_output) { + bool needs_barrier = false; + for (auto& dep : deps) { + auto* ocl_base_ev = dynamic_cast(dep.get()); + if (ocl_base_ev->get_queue_stamp() > _last_barrier) { + needs_barrier = true; + } + } + + if (needs_barrier) { + try { + if (is_output) + _command_queue.enqueueBarrierWithWaitList(nullptr, &_last_barrier_ev); + else + _command_queue.enqueueBarrierWithWaitList(nullptr, nullptr); + } catch (cl::Error const& err) { + throw ocl_error(err); + } + + _last_barrier = ++_queue_counter; + } +} + +} // namespace ocl +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_stream.hpp b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_stream.hpp new file mode 100644 index 00000000000000..3545d6d17e5b55 --- /dev/null +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_stream.hpp @@ -0,0 +1,99 @@ +// Copyright (C) 2019-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "cldnn/runtime/event.hpp" +#include "cldnn/runtime/stream.hpp" +#include "ocl_common.hpp" +#include "ocl_engine.hpp" + +#include +#include +#include +#include +#include +#include +#include + +namespace cldnn { +namespace ocl { + +class events_pool; + +// Possible sync methods for kernels in stream +enum class sync_methods { + /* Build dependency graph using events. Each kernel creates proper cl_event which is set as dependency of users + At this moment it requires multiple retain/release calls for cl_event after each enqueueNDRange + which is less performant comparing to the barriers version + */ + events = 0, + /* Enqueue barriers between dependent kernels. For example consider the following dimond dependency graph: + kernel_0 + / \ + kernel_1 kernel_2 + \ / + kernel_3 + In that case we do the following: + 1. Enqueue kernel_0 + 2. Enqueue barrier (ensures kernel_0 is completed) + 3. Enqueue kernel_1 + 4. Enqueue kernel_2 (doesn't depend on kernel_1) + 5. Enqueue barrier (ensures kernel_1 and kernel_2 are completed) + 6. Enqueue kernel_3 + */ + barriers = 1, + /* No explicit syncronization is needed. Applicable for in-order queue only */ + none = 2 +}; +class ocl_stream : public stream { +public: + const ocl_queue_type& get_cl_queue() const { return _command_queue; } + + explicit ocl_stream(const ocl_engine& engine); + ocl_stream(ocl_stream&& other) + : stream(other._engine.configuration().queue_type) + , _engine(other._engine) + , _command_queue(other._command_queue) + , _queue_counter(other._queue_counter.load()) + , _last_barrier(other._last_barrier.load()) + , _events_pool(std::move(other._events_pool)) + , _last_barrier_ev(other._last_barrier_ev) + , sync_method(other.sync_method) {} + + ~ocl_stream() = default; + + void flush() const override; + void finish() const override; + + void set_arguments(kernel& kernel, const kernel_arguments_desc& args_desc, const kernel_arguments_data& args) override; + event::ptr enqueue_kernel(kernel& kernel, + const kernel_arguments_desc& args_desc, + const kernel_arguments_data& args, + std::vector const& deps, + bool is_output = false) override; + event::ptr enqueue_marker(std::vector const& deps, bool is_output) override; + event::ptr group_events(std::vector const& deps) override; + void wait_for_events(const std::vector& events) override; + void enqueue_barrier() override; + void reset_events() override; + event::ptr create_user_event(bool set) override; + event::ptr create_base_event() override; + void release_events_pool() override; + +private: + void sync_events(std::vector const& deps, bool is_output = false); + + const ocl_engine& _engine; + ocl_queue_type _command_queue; + std::atomic _queue_counter{0}; + std::atomic _last_barrier{0}; + std::shared_ptr _events_pool; + cl::Event _last_barrier_ev; + + sync_methods sync_method; +}; + +} // namespace ocl +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/ocl_user_event.cpp b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_user_event.cpp similarity index 94% rename from inference-engine/thirdparty/clDNN/src/gpu/ocl_user_event.cpp rename to inference-engine/thirdparty/clDNN/runtime/ocl/ocl_user_event.cpp index c5663fb549d696..86da8d90bbe3ea 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/ocl_user_event.cpp +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_user_event.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ocl_user_event.h" +#include "ocl_user_event.hpp" #include -using namespace cldnn::gpu; +using namespace cldnn::ocl; void user_event::set_impl() { // we simulate "wrapper_cast" here to cast from cl::Event to cl::UserEvent which both wrap the same cl_event diff --git a/inference-engine/thirdparty/clDNN/src/gpu/ocl_user_event.h b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_user_event.hpp similarity index 71% rename from inference-engine/thirdparty/clDNN/src/gpu/ocl_user_event.h rename to inference-engine/thirdparty/clDNN/runtime/ocl/ocl_user_event.hpp index 45e44509face3a..199a8a8a26010f 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/ocl_user_event.h +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_user_event.hpp @@ -4,8 +4,8 @@ #pragma once -#include "ocl_base_event.h" -#include "api/profiling.hpp" +#include "cldnn/runtime/profiling.hpp" +#include "ocl_base_event.hpp" #include #include @@ -16,14 +16,15 @@ #endif namespace cldnn { -namespace gpu { +namespace ocl { struct user_event : public base_event, public cldnn::user_event { - explicit user_event(std::shared_ptr ctx) : base_event(ctx), cldnn::user_event(false) {} + explicit user_event(const cl::Context& ctx) : base_event(ctx, cl::UserEvent(ctx)), cldnn::user_event(false), _ctx(ctx) {} void set_impl() override; void attach_event(bool set) { - _event = cl::UserEvent(get_context()->context()); + // Event handle must be created again as clSetUserEventStatus can't be called twice for the same object + _event = cl::UserEvent(_ctx); // we need to reset the timer(since attach_ocl_event is called only when this object is being reused) _timer = cldnn::instrumentation::timer<>(); if (set) { @@ -36,11 +37,12 @@ struct user_event : public base_event, public cldnn::user_event { protected: cldnn::instrumentation::timer<> _timer; std::unique_ptr _duration; + const cl::Context& _ctx; }; #ifdef _WIN32 #pragma warning(pop) #endif -} // namespace gpu +} // namespace ocl } // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/common/include/cl2_wrapper.h b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_wrapper.hpp similarity index 95% rename from inference-engine/thirdparty/clDNN/common/include/cl2_wrapper.h rename to inference-engine/thirdparty/clDNN/runtime/ocl/ocl_wrapper.hpp index 3beb802304cafc..f75779075ff5f4 100644 --- a/inference-engine/thirdparty/clDNN/common/include/cl2_wrapper.h +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_wrapper.hpp @@ -6,8 +6,7 @@ /// \file This file wraps cl2.hpp and disables temporary some warnings that this header can emit. /// -#ifndef CL2_WRAPPER_H_ -#define CL2_WRAPPER_H_ +#pragma once // Check for C++. #ifndef __cplusplus @@ -58,7 +57,7 @@ #endif -#include "cl2_ext.hpp" +#include "ocl_ext.hpp" namespace cl { namespace detail { @@ -76,5 +75,3 @@ CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_) #elif defined __GNUC__ #pragma GCC diagnostic pop #endif - -#endif // CL2_WRAPPER_H_ diff --git a/inference-engine/thirdparty/clDNN/src/CMakeLists.txt b/inference-engine/thirdparty/clDNN/src/CMakeLists.txt index 0e4bcb0c5d9022..de841fe48bebb1 100644 --- a/inference-engine/thirdparty/clDNN/src/CMakeLists.txt +++ b/inference-engine/thirdparty/clDNN/src/CMakeLists.txt @@ -38,16 +38,11 @@ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS # ========================================= Source/Header files ======================================== set(__CLDNN_Label__api "api") -file(GLOB __CLDNN_Headers__api +file(GLOB_RECURSE __CLDNN_Headers__api "${CLDNN__API_DIR}/*.h" "${CLDNN__API_DIR}/*.hpp" ) -set(__CLDNN_Label__api_extension "api_extension") -file(GLOB __CLDNN_Headers__api_extension - "${CLDNN__API_EXTENSION_DIR}/*.hpp" - ) - set(__CLDNN_Label__main "") file(GLOB __CLDNN_Sources__main "${CMAKE_CURRENT_SOURCE_DIR}/*.h" @@ -108,7 +103,6 @@ set(__CLDNN_AllSources ${__CLDNN_Headers__api} ${__CLDNN_Sources__graph_opt} ${__CLDNN_Headers__include} - ${__CLDNN_Headers__api_extension} ${__CLDNN_Sources__main} ${__CLDNN_Sources__gpu} ${__CLDNN_Sources__cache} @@ -121,7 +115,6 @@ set_property(SOURCE ${__CLDNN_Sources__cg_cache} PROPERTY GENERATED TRUE) # =============================================== Filters ============================================== source_group("${__CLDNN_Label__api}" FILES ${__CLDNN_Headers__api}) -source_group("${__CLDNN_Label__api_extension}" FILES ${__CLDNN_Headers__api_extension}) source_group("${__CLDNN_Label__include}" FILES ${__CLDNN_Headers__include}) source_group("${__CLDNN_Label__graph_opt}" FILES ${__CLDNN_Sources__graph_opt}) source_group("${__CLDNN_Label__main}" FILES ${__CLDNN_Sources__main}) @@ -135,6 +128,7 @@ source_group("${__CLDNN_Label__cg_cache}" FILES ${__CLDNN_Sources__c include_directories( "${CLDNN__MAIN_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" + "${CLDNN__RUNTIME_DIR}" "${__CLDNN_Directory__include}" "${__CLDNN_Directory__ks_core}" "${__CLDNN_Directory__ks_core}/common" @@ -155,6 +149,7 @@ target_link_libraries("${CLDNN_BUILD__PROJ}" PRIVATE clDNN_OpenCL cldnn_kernel_selector openvino::itt + cldnn_runtime ) if(COMMAND add_cpplint_target) @@ -171,3 +166,5 @@ elseif((NOT ANDROID) AND (UNIX)) target_link_libraries("${CLDNN_BUILD__PROJ}" PRIVATE pthread) endif() target_link_libraries("${CLDNN_BUILD__PROJ}" PRIVATE ${CLDNN__SYSTEM_LINK_LIBRARIES}) + +# ====================================================================================================== diff --git a/inference-engine/thirdparty/clDNN/src/activation.cpp b/inference-engine/thirdparty/clDNN/src/activation.cpp index dba83df3583043..0987286ab4e51b 100644 --- a/inference-engine/thirdparty/clDNN/src/activation.cpp +++ b/inference-engine/thirdparty/clDNN/src/activation.cpp @@ -4,7 +4,7 @@ #include "activation_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include #include diff --git a/inference-engine/thirdparty/clDNN/src/arg_max_min.cpp b/inference-engine/thirdparty/clDNN/src/arg_max_min.cpp index f4a5a188e61e58..0d2f1f4beae215 100644 --- a/inference-engine/thirdparty/clDNN/src/arg_max_min.cpp +++ b/inference-engine/thirdparty/clDNN/src/arg_max_min.cpp @@ -2,11 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// #include "arg_max_min_inst.h" #include "primitive_type_base.h" #include "sliding_window_utils.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include #include diff --git a/inference-engine/thirdparty/clDNN/src/average_unpooling.cpp b/inference-engine/thirdparty/clDNN/src/average_unpooling.cpp index c4ba3ac8418e19..3082862f302e74 100644 --- a/inference-engine/thirdparty/clDNN/src/average_unpooling.cpp +++ b/inference-engine/thirdparty/clDNN/src/average_unpooling.cpp @@ -5,7 +5,7 @@ #include "average_unpooling_inst.h" #include "primitive_type_base.h" #include "sliding_window_utils.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/batch_to_space.cpp b/inference-engine/thirdparty/clDNN/src/batch_to_space.cpp index 7540b49e754652..aa34ab8da536ff 100644 --- a/inference-engine/thirdparty/clDNN/src/batch_to_space.cpp +++ b/inference-engine/thirdparty/clDNN/src/batch_to_space.cpp @@ -5,7 +5,7 @@ #include "batch_to_space_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include "data_inst.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/binary_convolution.cpp b/inference-engine/thirdparty/clDNN/src/binary_convolution.cpp index ece928a51d0d87..a2ffcdc02ca996 100644 --- a/inference-engine/thirdparty/clDNN/src/binary_convolution.cpp +++ b/inference-engine/thirdparty/clDNN/src/binary_convolution.cpp @@ -8,7 +8,7 @@ #include "reorder_inst.h" #include "primitive_type_base.h" #include "sliding_window_utils.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/border.cpp b/inference-engine/thirdparty/clDNN/src/border.cpp index 810027192e0494..cdeca46d8b1e35 100644 --- a/inference-engine/thirdparty/clDNN/src/border.cpp +++ b/inference-engine/thirdparty/clDNN/src/border.cpp @@ -4,7 +4,7 @@ #include "border_inst.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include "primitive_type_base.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/broadcast.cpp b/inference-engine/thirdparty/clDNN/src/broadcast.cpp index 790a1222fba116..d6cc15067075e1 100644 --- a/inference-engine/thirdparty/clDNN/src/broadcast.cpp +++ b/inference-engine/thirdparty/clDNN/src/broadcast.cpp @@ -4,7 +4,7 @@ #include "broadcast_inst.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include "primitive_type_base.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/concatenation.cpp b/inference-engine/thirdparty/clDNN/src/concatenation.cpp index e6e622a93e9f6b..d341566679ee22 100644 --- a/inference-engine/thirdparty/clDNN/src/concatenation.cpp +++ b/inference-engine/thirdparty/clDNN/src/concatenation.cpp @@ -4,7 +4,7 @@ #include "concatenation_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include #include diff --git a/inference-engine/thirdparty/clDNN/src/condition.cpp b/inference-engine/thirdparty/clDNN/src/condition.cpp index f6b2d237392309..c31e6cb80e780a 100644 --- a/inference-engine/thirdparty/clDNN/src/condition.cpp +++ b/inference-engine/thirdparty/clDNN/src/condition.cpp @@ -4,7 +4,7 @@ #include "condition_inst.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include "primitive_type_base.h" #include @@ -71,10 +71,8 @@ Condition primitive is resuing memory with the input. */ condition_inst::typed_primitive_inst(network_impl& network, condition_node const& node) : parent(network, node), - _net_true( - node.get_program().get_engine().allocate_network(*node.get_branch_true(), true)), - _net_false( - node.get_program().get_engine().allocate_network(*node.get_branch_false(), true)) { + _net_true(network_impl::allocate_network(node.get_program().get_engine(), node.get_branch_true(), true)), + _net_false(network_impl::allocate_network(node.get_program().get_engine(), node.get_branch_false(), true)) { auto compare_tensor = node.compare().get_output_layout().size; auto input_tensor = node.input().get_output_layout().size; CLDNN_ERROR_TENSOR_SIZES_GREATER_THAN(node.id(), diff --git a/inference-engine/thirdparty/clDNN/src/convolution.cpp b/inference-engine/thirdparty/clDNN/src/convolution.cpp index 5b49b614f67117..c145dfc339cec9 100644 --- a/inference-engine/thirdparty/clDNN/src/convolution.cpp +++ b/inference-engine/thirdparty/clDNN/src/convolution.cpp @@ -7,7 +7,7 @@ #include "convolution_inst.h" #include "primitive_type_base.h" #include "sliding_window_utils.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/crop.cpp b/inference-engine/thirdparty/clDNN/src/crop.cpp index 4dbcc9ce24727b..7d35ad1e04f3a0 100644 --- a/inference-engine/thirdparty/clDNN/src/crop.cpp +++ b/inference-engine/thirdparty/clDNN/src/crop.cpp @@ -4,8 +4,8 @@ #include "crop_inst.h" #include "primitive_type_base.h" -#include "memory_impl.h" -#include "error_handler.h" +#include "cldnn/runtime/memory.hpp" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/cum_sum.cpp b/inference-engine/thirdparty/clDNN/src/cum_sum.cpp index ebb176ec74591c..b7e0b144b90e44 100644 --- a/inference-engine/thirdparty/clDNN/src/cum_sum.cpp +++ b/inference-engine/thirdparty/clDNN/src/cum_sum.cpp @@ -5,7 +5,7 @@ #include "cum_sum_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/data.cpp b/inference-engine/thirdparty/clDNN/src/data.cpp index 7d0d89ea3d9603..c08b6a28ce394c 100644 --- a/inference-engine/thirdparty/clDNN/src/data.cpp +++ b/inference-engine/thirdparty/clDNN/src/data.cpp @@ -5,7 +5,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include "data_inst.h" #include "primitive_type_base.h" -#include "memory_impl.h" +#include "cldnn/runtime/memory.hpp" #include "json_object.h" #include @@ -19,28 +19,28 @@ primitive_type_id data::type_id() { } namespace { -memory_impl::ptr attach_or_copy_data(network_impl& network, memory_impl& mem) { +memory::ptr attach_or_copy_data(network_impl& network, memory::ptr mem) { auto& engine = network.get_engine(); - if (mem.is_allocated_by(engine)) - return (memory_impl::ptr) &mem; + if (mem->is_allocated_by(engine)) + return mem; - memory_impl::ptr result = engine.allocate_memory(mem.get_layout(), network.get_id(), false); - mem_lock src(mem); - mem_lock dst(result); + memory::ptr result = engine.allocate_memory(mem->get_layout(), false); + mem_lock src(mem, network.get_stream()); + mem_lock dst(result, network.get_stream()); std::copy(src.begin(), src.end(), dst.begin()); return result; } } // namespace data_node::typed_program_node(const std::shared_ptr dprim, program_impl& prog) - : parent(dprim, prog), mem(dprim->mem.get()) { + : parent(dprim, prog), mem(dprim->mem) { constant = true; can_share_buffer(false); recalc_output_layout(false); } -void data_node::attach_memory(memory_impl& new_mem, bool invalidate_users_if_changed) { - mem = (memory_impl::ptr) &new_mem; +void data_node::attach_memory(memory::ptr new_mem, bool invalidate_users_if_changed) { + mem = new_mem; recalc_output_layout(invalidate_users_if_changed); } @@ -54,6 +54,6 @@ std::string data_inst::to_string(data_node const& node) { } data_inst::typed_primitive_inst(network_impl& network, data_node const& node) - : parent(network, node, *attach_or_copy_data(network, node.get_attached_memory())) {} + : parent(network, node, attach_or_copy_data(network, node.get_attached_memory_ptr())) {} } // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/deconvolution.cpp b/inference-engine/thirdparty/clDNN/src/deconvolution.cpp index 9642e3e3289939..6ddc0373f5f376 100644 --- a/inference-engine/thirdparty/clDNN/src/deconvolution.cpp +++ b/inference-engine/thirdparty/clDNN/src/deconvolution.cpp @@ -6,7 +6,7 @@ #include "deconvolution_inst.h" #include "primitive_type_base.h" #include "sliding_window_utils.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/deformable_convolution.cpp b/inference-engine/thirdparty/clDNN/src/deformable_convolution.cpp index d3e04b2e1c8833..237ed6929f67da 100644 --- a/inference-engine/thirdparty/clDNN/src/deformable_convolution.cpp +++ b/inference-engine/thirdparty/clDNN/src/deformable_convolution.cpp @@ -6,7 +6,7 @@ #include "deformable_convolution_inst.h" #include "primitive_type_base.h" #include "sliding_window_utils.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/depth_to_space.cpp b/inference-engine/thirdparty/clDNN/src/depth_to_space.cpp index 3c8622f6b8ae42..09f16b6f7c6877 100644 --- a/inference-engine/thirdparty/clDNN/src/depth_to_space.cpp +++ b/inference-engine/thirdparty/clDNN/src/depth_to_space.cpp @@ -5,7 +5,7 @@ #include "depth_to_space_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/detection_output.cpp b/inference-engine/thirdparty/clDNN/src/detection_output.cpp index 78a770caa54b51..c4e0fa86e2b810 100644 --- a/inference-engine/thirdparty/clDNN/src/detection_output.cpp +++ b/inference-engine/thirdparty/clDNN/src/detection_output.cpp @@ -5,7 +5,7 @@ #include "detection_output_inst.h" #include "primitive_type_base.h" #include "network_impl.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/device.cpp b/inference-engine/thirdparty/clDNN/src/device.cpp deleted file mode 100644 index b3470db4ff93bd..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/device.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include "device_impl.h" -#include "gpu/ocl_builder.h" - -#include -#include - -namespace cldnn { - -device device::create_default() { - device_query query; - auto devices = query.get_available_devices(); - // ToDo Maybe some heuristic should be added to decide what device is the default? (i.e number of EUs) - return devices.begin()->second; -} - -device_info device::get_info() const { - return _impl->get_info().convert_to_api(); -} - -void device::retain() { - _impl->add_ref(); -} -void device::release() { - _impl->release(); -} - -// --- device query --- -device_query::device_query(void* clcontext, void* user_device) - : _impl(new device_query_impl(clcontext, user_device)) { -} - -std::map device_query::get_available_devices() const { - std::map ret; - auto device_list = _impl->get_available_devices(); - for (auto dev : device_list) { - ret.insert({ dev.first, device(dev.second.detach())}); - } - return ret; -} - -void device_query::retain() { - _impl->add_ref(); -} -void device_query::release() { - _impl->release(); -} - -// --- device query impl --- -device_query_impl::device_query_impl(void* user_context, void* user_device) { - gpu::ocl_builder builder; - _available_devices = builder.get_available_devices(user_context, user_device); -} -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/eltwise.cpp b/inference-engine/thirdparty/clDNN/src/eltwise.cpp index 760b504a013e89..a7f544a3a75af8 100644 --- a/inference-engine/thirdparty/clDNN/src/eltwise.cpp +++ b/inference-engine/thirdparty/clDNN/src/eltwise.cpp @@ -5,7 +5,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include "eltwise_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include #include diff --git a/inference-engine/thirdparty/clDNN/src/embedding_bag.cpp b/inference-engine/thirdparty/clDNN/src/embedding_bag.cpp index 951ff190049b68..84e5483dff0d6c 100644 --- a/inference-engine/thirdparty/clDNN/src/embedding_bag.cpp +++ b/inference-engine/thirdparty/clDNN/src/embedding_bag.cpp @@ -5,7 +5,7 @@ #include "embedding_bag_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/engine.cpp b/inference-engine/thirdparty/clDNN/src/engine.cpp deleted file mode 100644 index e64c0051827714..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/engine.cpp +++ /dev/null @@ -1,298 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include "engine_impl.h" -#include "event_impl.h" -#include "program_impl.h" -#include "network_impl.h" -#include "gpu/ocl_toolkit.h" -#include "gpu/memory_gpu.h" -#include "gpu/ocl_user_event.h" -#include "gpu/register_gpu.hpp" -#include -#include -#include -#include -#include - -namespace cldnn { - -engine::engine(engine_types type, const device& dev, const engine_configuration& configuration) - : _impl(new engine_impl(*dev.get(), configuration)) { - if (type != engine_types::ocl) - throw std::invalid_argument("Invalid engine type, should be ocl."); -} - -uint32_t engine::engine_count(engine_types type) { - if (type == engine_types::ocl) { - return 1; - } else { - return 0; - } -} - -void engine::release_pending_memory(uint32_t net_id) const { - _impl->release_pending_memory(net_id); -} - -device_info engine::get_info() const { - auto info = _impl->get_device_info(); - return info.convert_to_api(); -} - -void* engine::get_context() const { - return _impl->get_user_context(); -} - -uint64_t engine::get_max_used_device_memory_size() const { - return _impl->get_max_used_device_memory(); -} - -uint64_t engine::get_temp_used_device_memory_size() const { - return _impl->get_used_device_memory(); -} - -engine_types engine::get_type() const { - return _impl->type(); -} - -void engine::retain() { - _impl->add_ref(); -} -void engine::release() { - _impl->release(); -} - -using gpu_toolkit_config = gpu::configuration; - -gpu_toolkit_config convert_configuration(const engine_configuration conf) { - gpu_toolkit_config result; - result.compiler_options = conf.compiler_options; - result.enable_profiling = conf.enable_profiling != 0; - result.meaningful_kernels_names = conf.meaningful_kernels_names != 0; - result.dump_custom_program = conf.dump_custom_program != 0; - result.single_kernel_name = conf.single_kernel_name; - result.host_out_of_order = true; - result.use_unifed_shared_memory = true; // Switch on/off USM. - result.log = conf.engine_log; - result.ocl_sources_dumps_dir = conf.sources_dumps_dir; - result.priority_mode = conf.priority_mode; - result.throttle_mode = conf.throttle_mode; - result.queues_num = conf.n_streams; - result.kernels_cache_path = conf.kernels_cache_path; - result.tuning_cache_path = conf.tuning_cache_path; - result.n_threads = conf.n_threads; - return result; -} - -engine_impl::engine_impl(const device_impl& dev, const engine_configuration& conf) - : _configuration(conf), _context(gpu_toolkit::create(dev, convert_configuration(conf))), _memory_pool(*this) { - gpu::register_implementations_gpu(); -} - -engine_impl::~engine_impl() { - /* - Engine, which is main owner of context deallocate events pool manually, because - of the event_impl <-> gpu_toolkit dependencies. - */ - _context->release_all_events_pools(); -} - -memory_impl::ptr engine_impl::allocate_memory(const layout& layout, uint32_t net_id, bool reset) { - allocation_type type = get_lockable_preffered_memory_allocation_type(layout.format.is_image_2d()); - return _memory_pool.get_memory(layout, type, net_id, reset); -} - -memory_impl::ptr engine_impl::allocate_memory(const layout& layout, allocation_type type, uint32_t net_id, bool reset) { - return _memory_pool.get_memory(layout, type, net_id, reset); -} - -memory_impl::ptr engine_impl::allocate_memory(const layout& layout, - primitive_id id, - uint32_t network_id, - std::set dependencies, - allocation_type type, - bool reusable) { - if (use_memory_pool()) - return _memory_pool.get_memory(layout, id, network_id, dependencies, type, reusable); - return _memory_pool.get_memory(layout, type, network_id); -} - -memory_impl::ptr engine_impl::reinterpret_buffer(const memory_impl& memory, const layout& new_layout) { - if (memory.get_engine() != (const refcounted_obj_ptr) this) - throw std::runtime_error("trying to reinterpret buffer allocated by a different engine"); - - if (new_layout.format.is_image() && !memory.get_layout().format.is_image()) - throw std::runtime_error("trying to reinterpret non-image buffer as image"); - - if (!new_layout.format.is_image() && memory.get_layout().format.is_image()) - throw std::runtime_error("trying to reinterpret image buffer as non-image buffer"); - - try { - if (new_layout.format.is_image_2d()) { - memory_impl::ptr mem_impl { - new gpu::gpu_image2d((refcounted_obj_ptr) this, - new_layout, - reinterpret_cast(memory).get_buffer(), - memory.get_net_id()), - false }; - return mem_impl; - } else if (memory_capabilities::is_usm_type(memory.get_allocation_type())) { - memory_impl::ptr mem_impl{ - new gpu::gpu_usm((refcounted_obj_ptr) this, - new_layout, - reinterpret_cast(memory).get_buffer(), - memory.get_allocation_type(), - memory.get_net_id()), - false }; - return mem_impl; - } else { - memory_impl::ptr mem_impl { - new gpu::gpu_buffer((refcounted_obj_ptr) this, - new_layout, - reinterpret_cast(memory).get_buffer(), - memory.get_net_id()), - false}; - return mem_impl; - } - } catch (cl::Error const& err) { - throw gpu::ocl_error(err); - } -} - -memory_impl::ptr engine_impl::reinterpret_handle(const layout& new_layout, - const shared_mem_params* params, - uint32_t net_id) { - return _memory_pool.get_memory(new_layout, params, net_id); -} - - -bool engine_impl::is_the_same_buffer(const memory_impl& mem1, const memory_impl& mem2) { - if (mem1.get_engine() != (refcounted_obj_ptr)this || mem2.get_engine() != (refcounted_obj_ptr) this) - return false; - if (mem1.get_net_id() != mem2.get_net_id()) - return false; - if (mem1.get_allocation_type() != mem2.get_allocation_type()) - return false; - if (&mem1 == &mem2) - return true; - - if (!memory_capabilities::is_usm_type(mem1.get_allocation_type())) - return (reinterpret_cast(mem1).get_buffer() == - reinterpret_cast(mem2).get_buffer()); - else - return (reinterpret_cast(mem1).get_buffer() == - reinterpret_cast(mem2).get_buffer()); -} - -event_impl::ptr engine_impl::create_user_event(uint32_t net_id, bool set) { - try { - return _context->create_user_event(net_id, set); - } catch (cl::Error const& err) { - throw gpu::ocl_error(err); - } -} - -void engine_impl::flush_network(uint32_t net_id) { get_context()->flush(net_id); } - -void engine_impl::release_pending_memory(uint32_t net_id) { get_context()->release_pending_memory(net_id); } - -program_impl::ptr engine_impl::build_program(const topology_impl& topology, - const build_options& options, - bool is_internal, - bool no_optimizations) { - program_impl::ptr progr_impl{ new program_impl(*this, topology, options, is_internal, no_optimizations), false }; - return progr_impl; -} - -program_impl::ptr engine_impl::build_program(const std::set>& nodes, - const build_options& options, - bool is_internal) { - program_impl::ptr progr_impl{ new program_impl(*this, nodes, options, is_internal), false }; - return progr_impl; -} - -network_impl::ptr engine_impl::build_network(const topology_impl& topology, - const build_options& options, - uint16_t stream_id, - bool is_internal) { - network_impl::ptr netw_impl{ new network_impl(*this, topology, options, stream_id, is_internal), false }; - return netw_impl; -} - -network_impl::ptr engine_impl::build_network(const std::set>& nodes, - const build_options& options, - bool is_internal) { - network_impl::ptr netw_impl{ new network_impl(*this, nodes, options, is_internal), false }; - return netw_impl; -} - -network_impl::ptr engine_impl::allocate_network(const program_impl& program, uint16_t stream_id, bool is_internal) { - if (stream_id >= _configuration.n_streams) - throw std::invalid_argument("Unable to create network with stream_id=" + std::to_string(stream_id)); - network_impl::ptr netw_impl{ new network_impl(program, stream_id, is_internal), false }; - return netw_impl; -} - -void engine_impl::wait_for_events(std::vector const& events) { - if (!events.empty()) - _context->wait_for_events(events); -} - -gpu::device_info_internal engine_impl::get_device_info() const { return _context->get_device_info(); } - -void* engine_impl::get_user_context() const { return static_cast(_context->context().get()); } - -void engine_impl::compile_program(program_impl& program) { - auto& cache = _context->get_kernels_cache(program.get_id()); - if (!program.get_options().get()->serialization_network_name.empty()) - cache.get_context().set_serialization_flag(true); - // TODO: better compilation logic instead of a simple 'compile all'? - cache.build_all(); -} - -bool engine_impl::use_memory_pool() const { - if (configuration().enable_memory_pool && get_context()->is_neo_driver()) { - return true; - } - return false; -} - -bool engine_impl::use_unified_shared_memory() const { - if (get_context()->memory_caps().supports_usm() && get_context()->get_configuration().use_unifed_shared_memory) { - return true; - } - return false; -} - -bool engine_impl::supports_allocation(allocation_type type) const { - if (memory_capabilities::is_usm_type(type) && !use_unified_shared_memory()) - return false; - if (allocation_type::usm_shared == type) - return false; - return get_context()->memory_caps().support_allocation_type(type); -} - -allocation_type engine_impl::get_lockable_preffered_memory_allocation_type(bool is_image_layout) const { - if (!use_unified_shared_memory() || is_image_layout) - return allocation_type::cl_mem; - - /* - We do not check device allocation here. - Device allocation is reserved for buffers of hidden layers. - Const buffers are propagated to device if possible. - */ - - bool support_usm_host = supports_allocation(allocation_type::usm_host); - bool support_usm_shared = supports_allocation(allocation_type::usm_shared); - - if (support_usm_shared) - return allocation_type::usm_shared; - if (support_usm_host) - return allocation_type::usm_host; - - throw std::runtime_error("[clDNN internal error] Could not find proper allocation type!"); -} -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/error_handler.cpp b/inference-engine/thirdparty/clDNN/src/error_handler.cpp index 1e41407b27d82b..bb7ce5224128f3 100644 --- a/inference-engine/thirdparty/clDNN/src/error_handler.cpp +++ b/inference-engine/thirdparty/clDNN/src/error_handler.cpp @@ -3,7 +3,7 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include #include diff --git a/inference-engine/thirdparty/clDNN/src/event.cpp b/inference-engine/thirdparty/clDNN/src/event.cpp deleted file mode 100644 index 48b6dfaff31175..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/event.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include "api/event.hpp" -#include "event_impl.h" -#include "engine_impl.h" -#include -#include -#include - -namespace cldnn { - -event event::create_user_event(const engine& engine, uint32_t net_id) { - return event(engine.get()->create_user_event(net_id).detach()); -} - -void event::wait() const { - _impl->wait(); -} - -void event::set() const { - if (auto user_ev = dynamic_cast(_impl)) - user_ev->set(); - else - throw std::invalid_argument("Event passed to cldnn_set_event should be an user event"); -} - -void event::set_event_handler(event_handler handler, void* param) const { - _impl->add_event_handler(handler, param); -} - -std::vector event::get_profiling_info() const { - auto interval_list = _impl->get_profiling_info(); - std::vector result(interval_list.size()); - std::copy(interval_list.begin(), interval_list.end(), result.begin()); - return result; -} - -void event::retain() { - _impl->add_ref(); -} - -void event::release() { - _impl->release(); -} - -void event_impl::wait() { - if (_set) - return; - - // TODO: refactor in context of multiple simultaneous calls (for generic engine) - wait_impl(); - _set = true; - return; -} - -bool event_impl::is_set() { - if (_set) - return true; - - // TODO: refactor in context of multiple simultaneous calls (for generic engine) - _set = is_set_impl(); - return _set; -} - -bool event_impl::add_event_handler(event_handler handler, void* data) { - if (is_set()) { - handler(data); - return true; - } - - std::lock_guard lock(_handlers_mutex); - auto itr = _handlers.insert(_handlers.end(), {handler, data}); - auto ret = add_event_handler_impl(handler, data); - if (!ret) - _handlers.erase(itr); - - return ret; -} - -const std::list& event_impl::get_profiling_info() { - if (_profiling_captured) - return _profiling_info; - - _profiling_captured = get_profiling_info_impl(_profiling_info); - return _profiling_info; -} - -void event_impl::call_handlers() { - std::lock_guard lock(_handlers_mutex); - for (auto& pair : _handlers) { - try { - pair.first(pair.second); - } catch (...) { - } - } - _handlers.clear(); -} - -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/extract_image_patches.cpp b/inference-engine/thirdparty/clDNN/src/extract_image_patches.cpp index a4cc4ff1fe65a0..fffa064d13b236 100644 --- a/inference-engine/thirdparty/clDNN/src/extract_image_patches.cpp +++ b/inference-engine/thirdparty/clDNN/src/extract_image_patches.cpp @@ -5,7 +5,7 @@ #include "extract_image_patches_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/fully_connected.cpp b/inference-engine/thirdparty/clDNN/src/fully_connected.cpp index 4c6aeabe80eaae..71130b19a188cd 100644 --- a/inference-engine/thirdparty/clDNN/src/fully_connected.cpp +++ b/inference-engine/thirdparty/clDNN/src/fully_connected.cpp @@ -5,7 +5,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include "fully_connected_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/fused_conv_eltwise.cpp b/inference-engine/thirdparty/clDNN/src/fused_conv_eltwise.cpp index dc4db14393b499..9d11b1ad4c5056 100644 --- a/inference-engine/thirdparty/clDNN/src/fused_conv_eltwise.cpp +++ b/inference-engine/thirdparty/clDNN/src/fused_conv_eltwise.cpp @@ -6,7 +6,7 @@ #include "fused_conv_eltwise_inst.h" #include "primitive_type_base.h" #include "sliding_window_utils.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/gather.cpp b/inference-engine/thirdparty/clDNN/src/gather.cpp index c688ea19823615..5a264d2505b448 100644 --- a/inference-engine/thirdparty/clDNN/src/gather.cpp +++ b/inference-engine/thirdparty/clDNN/src/gather.cpp @@ -5,7 +5,7 @@ #include "gather_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/gather_nd.cpp b/inference-engine/thirdparty/clDNN/src/gather_nd.cpp index f01d82dffa3ea8..998df5a76b2198 100644 --- a/inference-engine/thirdparty/clDNN/src/gather_nd.cpp +++ b/inference-engine/thirdparty/clDNN/src/gather_nd.cpp @@ -1,23 +1,11 @@ -/* -// Copyright (c) 2021 Intel Corporation +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -*/ #include "gather_nd_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/gather_tree.cpp b/inference-engine/thirdparty/clDNN/src/gather_tree.cpp index 98b687be5b7013..6610df3523c777 100644 --- a/inference-engine/thirdparty/clDNN/src/gather_tree.cpp +++ b/inference-engine/thirdparty/clDNN/src/gather_tree.cpp @@ -4,7 +4,7 @@ #include "gather_tree_inst.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include "primitive_type_base.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/gemm.cpp b/inference-engine/thirdparty/clDNN/src/gemm.cpp index 1c3191b87d9184..2652116b90a7c3 100644 --- a/inference-engine/thirdparty/clDNN/src/gemm.cpp +++ b/inference-engine/thirdparty/clDNN/src/gemm.cpp @@ -5,7 +5,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include "gemm_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include #include diff --git a/inference-engine/thirdparty/clDNN/src/gpu/activation_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/activation_gpu.cpp index 7ea703cab3bc87..9a90f972752dec 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/activation_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/activation_gpu.cpp @@ -5,11 +5,10 @@ #include "activation_inst.h" #include "primitive_gpu_base.h" #include "implementation_map.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_selector_helper.h" #include "activation/activation_kernel_selector.h" #include "activation/activation_kernel_base.h" -#include "api/activation.hpp" #include "register_gpu.hpp" namespace cldnn { @@ -19,12 +18,15 @@ struct activation_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; - kernel::kernel_arguments_data get_arguments(typed_primitive_inst& instance, - int32_t split) const override { - kernel::kernel_arguments_data args = parent::get_arguments(instance, split); + std::unique_ptr clone() const override { + return make_unique(*this); + } + + kernel_arguments_data get_arguments(typed_primitive_inst& instance, int32_t split) const override { + kernel_arguments_data args = parent::get_arguments(instance, split); if (_outer.is_parameterized()) { - args.slope = (memory_impl::cptr) &instance.slope_memory(); + args.slope = instance.slope_memory(); } return args; diff --git a/inference-engine/thirdparty/clDNN/src/gpu/arg_max_min_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/arg_max_min_gpu.cpp index 3b898761653687..7717ea901ded89 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/arg_max_min_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/arg_max_min_gpu.cpp @@ -5,7 +5,7 @@ #include "arg_max_min_inst.h" #include "primitive_gpu_base.h" #include "implementation_map.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_selector_helper.h" #include "arg_max_min/arg_max_min_kernel_selector.h" #include "arg_max_min/arg_max_min_kernel_base.h" @@ -18,10 +18,13 @@ struct arg_max_min_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + protected: - kernel::kernel_arguments_data get_arguments(typed_primitive_inst& instance, - int32_t) const override { - kernel::kernel_arguments_data args = parent::get_arguments(instance, 0); + kernel_arguments_data get_arguments(typed_primitive_inst& instance, int32_t) const override { + kernel_arguments_data args = parent::get_arguments(instance, 0); if (args.inputs.size() == 3) { args.inputs.erase(args.inputs.begin() + 1); // erase constant input in case of TOP_K diff --git a/inference-engine/thirdparty/clDNN/src/gpu/average_unpooling_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/average_unpooling_gpu.cpp index 4ed6597d63ab30..55ad712d4d8a7e 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/average_unpooling_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/average_unpooling_gpu.cpp @@ -5,7 +5,7 @@ #include "average_unpooling_inst.h" #include "primitive_gpu_base.h" #include "implementation_map.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_selector_helper.h" #include "average_unpooling/average_unpooling_kernel_selector.h" #include "average_unpooling/average_unpooling_kernel_base.h" @@ -17,10 +17,13 @@ struct average_unpooling_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + protected: - kernel::kernel_arguments_data get_arguments(typed_primitive_inst& instance, - int32_t split) const override { - kernel::kernel_arguments_data args = parent::get_arguments(instance, split); + kernel_arguments_data get_arguments(typed_primitive_inst& instance, int32_t split) const override { + kernel_arguments_data args = parent::get_arguments(instance, split); return args; } diff --git a/inference-engine/thirdparty/clDNN/src/gpu/batch_to_space_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/batch_to_space_gpu.cpp index 820e62561670ea..d2ef8e70df9f5c 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/batch_to_space_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/batch_to_space_gpu.cpp @@ -8,7 +8,7 @@ #include "kernel_selector_helper.h" #include "batch_to_space/batch_to_space_kernel_selector.h" #include "batch_to_space/batch_to_space_kernel_ref.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "data_inst.h" #include @@ -20,6 +20,10 @@ struct batch_to_space_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + public: static primitive_impl* create(const batch_to_space_node& arg) { auto batch_to_space_params = get_default_params(arg); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/binary_convolution_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/binary_convolution_gpu.cpp index 8800cc2c5ad111..c9b4c78eee552f 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/binary_convolution_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/binary_convolution_gpu.cpp @@ -2,12 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include +#include "cldnn/primitives/scale.hpp" +#include "cldnn/primitives/quantize.hpp" #include "binary_convolution_inst.h" #include "primitive_gpu_base.h" #include "implementation_map.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_selector_helper.h" #include "kernel_runner.h" #include "kernel_selector/core/actual_kernels/binary_convolution/binary_convolution_kernel_selector.h" @@ -22,6 +22,10 @@ struct binary_convolution_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + protected: bool validate_impl(const typed_primitive_inst& instance) const override { bool res = true; @@ -40,17 +44,16 @@ struct binary_convolution_gpu : typed_primitive_gpu_impl { "Input memory", data_type, "filter memory", - instance.weights_memory(0).get_layout().data_type, + instance.weights_memory(0)->get_layout().data_type, ""); return res; } - kernel::kernel_arguments_data get_arguments(typed_primitive_inst& instance, - int32_t split) const override { - kernel::kernel_arguments_data args = parent::get_arguments(instance, split); + kernel_arguments_data get_arguments(typed_primitive_inst& instance, int32_t split) const override { + kernel_arguments_data args = parent::get_arguments(instance, split); - args.weights = (memory_impl::cptr) &instance.weights_memory(split); + args.weights = instance.weights_memory(split); return args; } diff --git a/inference-engine/thirdparty/clDNN/src/gpu/border_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/border_gpu.cpp index 33985b48c9736b..01c1d54ad1099a 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/border_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/border_gpu.cpp @@ -9,7 +9,7 @@ #include "kernel_selector_helper.h" #include "border/border_kernel_selector.h" #include "border/border_kernel_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" namespace cldnn { namespace gpu { @@ -18,6 +18,10 @@ struct border_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + static primitive_impl* create(const border_node& arg) { auto b_params = get_default_params(arg, 1); auto b_optional_params = diff --git a/inference-engine/thirdparty/clDNN/src/gpu/broadcast_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/broadcast_gpu.cpp index a3fa9715eb90e8..1c07420d7a9365 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/broadcast_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/broadcast_gpu.cpp @@ -9,7 +9,7 @@ #include "kernel_selector_helper.h" #include "broadcast/broadcast_kernel_selector.h" #include "broadcast/broadcast_kernel_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" namespace cldnn { namespace gpu { @@ -18,6 +18,10 @@ struct broadcast_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + static primitive_impl* create(const broadcast_node& arg) { auto bc_params = get_default_params(arg, 1); auto bc_optional_params = diff --git a/inference-engine/thirdparty/clDNN/src/gpu/concatenation_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/concatenation_gpu.cpp index b2abee8ab58ccf..590e97a2a8d274 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/concatenation_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/concatenation_gpu.cpp @@ -5,8 +5,7 @@ #include "concatenation_inst.h" #include "primitive_gpu_base.h" #include "implementation_map.h" -#include "events_waiter.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_selector_helper.h" #include "concatenation/concatenation_kernel_selector.h" #include "concatenation/concatenation_kernel_base.h" @@ -40,6 +39,10 @@ kernel_selector::concat_axis convert_axis(concatenation::concatenation_axis axis struct concatenation_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; + std::unique_ptr clone() const override { + return make_unique(*this); + } + concatenation_gpu(const concatenation_node& arg, const kernel_selector::kernel_data& kd) : parent(arg, kd) { if (!_outer.can_be_optimized()) { CLDNN_ERROR_NOT_EQUAL(_outer.id(), diff --git a/inference-engine/thirdparty/clDNN/src/gpu/condition_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/condition_gpu.cpp index e3df38f722980f..2f84605cc19c24 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/condition_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/condition_gpu.cpp @@ -17,23 +17,27 @@ namespace gpu { struct condition_gpu : typed_primitive_impl { const condition_node& outer; + std::unique_ptr clone() const override { + return make_unique(*this); + } + explicit condition_gpu(const condition_node& outer) : outer(outer) {} - event_impl::ptr execute_impl(const std::vector& events, condition_inst& instance) override { + event::ptr execute_impl(const std::vector& events, condition_inst& instance) override { for (auto& a : events) { a->wait(); } - auto ev = instance.get_network().get_engine().create_user_event(instance.get_network().get_id(), false); + auto ev = instance.get_network().get_stream().create_user_event(false); bool exec_branch = choose_branch_to_exec(instance); - memory_impl::ptr memory_to_copy; + memory::ptr memory_to_copy; if (exec_branch) - memory_to_copy = (memory_impl::ptr) &execute_branch(instance.get_net_true(), instance.result_id(), instance.input_memory()); + memory_to_copy = execute_branch(instance.get_net_true(), instance.result_id(), instance.input_memory_ptr()); else - memory_to_copy = (memory_impl::ptr) &execute_branch(instance.get_net_false(), instance.result_id(), instance.input_memory()); + memory_to_copy = execute_branch(instance.get_net_false(), instance.result_id(), instance.input_memory_ptr()); // just copy memory - mem_lock inp_ptr{memory_to_copy}; - mem_lock out_ptr{instance.output_memory()}; + mem_lock inp_ptr{memory_to_copy, instance.get_network().get_stream()}; + mem_lock out_ptr{instance.output_memory_ptr(), instance.get_network().get_stream()}; std::copy(inp_ptr.begin(), inp_ptr.end(), out_ptr.begin()); dynamic_cast(ev.get())->set(); // set as complete return ev; @@ -41,6 +45,8 @@ struct condition_gpu : typed_primitive_impl { static primitive_impl* create(const condition_node& arg) { return new condition_gpu(arg); } + void init_kernels() override {} + private: /* Add functions here. @@ -67,11 +73,11 @@ struct condition_gpu : typed_primitive_impl { Returns boolean flag, which says what branch should be executed. */ bool choose_branch_to_exec(condition_inst& instance) const { - mem_lock lock_compare_data{instance.compare_memory()}; + mem_lock lock_compare_data{instance.compare_memory_ptr(), instance.get_network().get_stream()}; auto compare_layout = instance.compare_memory().get_layout(); auto compare_ptr = lock_compare_data.begin(); - mem_lock lock_input{instance.input_memory()}; + mem_lock lock_input{instance.input_memory_ptr(), instance.get_network().get_stream()}; auto input_layout = instance.input_memory().get_layout(); auto input_ptr = lock_input.begin(); @@ -101,12 +107,12 @@ struct condition_gpu : typed_primitive_impl { return true; } - memory_impl& execute_branch(network_impl::ptr branch, - const primitive_id& input_id, - memory_impl& input_memory) const { + memory::ptr execute_branch(network_impl::ptr branch, + const primitive_id& input_id, + memory::ptr input_memory) const { branch->set_input_data(input_id, input_memory); branch->execute({}); - return branch->get_outputs().at(0)->output_memory(); + return branch->get_outputs().at(0)->output_memory_ptr(); } }; diff --git a/inference-engine/thirdparty/clDNN/src/gpu/configuration.cpp b/inference-engine/thirdparty/clDNN/src/gpu/configuration.cpp deleted file mode 100644 index 2536bf0b0c1d10..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/gpu/configuration.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include "configuration.h" -#include - -namespace cldnn { -namespace gpu { - -configuration::configuration() - : enable_profiling(false), - meaningful_kernels_names(false), - dump_custom_program(false), - host_out_of_order(true), - use_unifed_shared_memory(false), - compiler_options(""), - single_kernel_name(""), - log(""), - ocl_sources_dumps_dir(""), - priority_mode(priority_mode_types::disabled), - throttle_mode(throttle_mode_types::disabled), - queues_num(0), - tuning_cache_path("cache.json"), - kernels_cache_path(""), - n_threads(std::max(static_cast(std::thread::hardware_concurrency()), static_cast(1))) {} -} // namespace gpu -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/configuration.h b/inference-engine/thirdparty/clDNN/src/gpu/configuration.h deleted file mode 100644 index f0792ad8dac0d2..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/gpu/configuration.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma once -#include -#include "api/cldnn.hpp" -#include "api/engine.hpp" - -namespace cl { -class Context; -} -namespace cldnn { -namespace gpu { - -struct configuration { - configuration(); - - bool enable_profiling; - bool meaningful_kernels_names; - bool dump_custom_program; - bool host_out_of_order; - bool use_unifed_shared_memory; - std::string compiler_options; - std::string single_kernel_name; - std::string log; - std::string ocl_sources_dumps_dir; - priority_mode_types priority_mode; - throttle_mode_types throttle_mode; - uint16_t queues_num; - std::string tuning_cache_path; - std::string kernels_cache_path; - uint16_t n_threads; -}; -} // namespace gpu -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/convolution_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/convolution_gpu.cpp index 1c37c2073032c5..63065d8be870a6 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/convolution_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/convolution_gpu.cpp @@ -6,7 +6,7 @@ #include "eltwise_inst.h" #include "primitive_gpu_base.h" #include "implementation_map.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_selector_helper.h" #include "kernel_runner.h" #include "convolution/convolution_kernel_selector.h" @@ -21,6 +21,10 @@ struct convolution_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + protected: bool validate_impl(const typed_primitive_inst& instance) const override { bool res = true; @@ -33,26 +37,20 @@ struct convolution_gpu : typed_primitive_gpu_impl { "Input memory", data_type, "filter memory", - instance.weights_memory(0).get_layout().data_type, + instance.weights_memory(0)->get_layout().data_type, ""); return res; } - kernel::kernel_arguments_data get_arguments(typed_primitive_inst& instance, - int32_t split) const override { - kernel::kernel_arguments_data args = parent::get_arguments(instance, split); - - args.weights = (memory_impl::cptr) &instance.weights_memory(split); - args.bias = (memory_impl::cptr) (instance.bias_term() ? &instance.bias_memory(split) : nullptr); - args.weights_zero_points = (memory_impl::cptr) (instance.weights_zero_points_term() ? &instance.weights_zero_points_memory(split) - : nullptr); - args.activations_zero_points = (memory_impl::cptr) (instance.activations_zero_points_term() - ? &instance.activations_zero_points_memory(split) - : nullptr); - args.compensation = (memory_impl::cptr) (instance.compensation_term() - ? &instance.compensation_memory(split) - : nullptr); + kernel_arguments_data get_arguments(typed_primitive_inst& instance, int32_t split) const override { + kernel_arguments_data args = parent::get_arguments(instance, split); + + args.weights = instance.weights_memory(split); + args.bias = instance.bias_term() ? instance.bias_memory(split) : nullptr; + args.weights_zero_points = instance.weights_zero_points_term() ? instance.weights_zero_points_memory(split) : nullptr; + args.activations_zero_points = instance.activations_zero_points_term() ? instance.activations_zero_points_memory(split) : nullptr; + args.compensation = instance.compensation_term() ? instance.compensation_memory(split) : nullptr; return args; } diff --git a/inference-engine/thirdparty/clDNN/src/gpu/crop_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/crop_gpu.cpp index 0a4498973d52a5..07244dde5aeb0c 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/crop_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/crop_gpu.cpp @@ -8,7 +8,7 @@ #include "kernel_selector_helper.h" #include "eltwise/eltwise_kernel_selector.h" #include "eltwise/eltwise_kernel_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" namespace cldnn { namespace gpu { @@ -17,6 +17,10 @@ struct crop_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + protected: bool optimized_out(crop_inst& instance) const override { return parent::optimized_out(instance) || _outer.can_be_optimized(); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/ctc_greedy_decoder_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/ctc_greedy_decoder_gpu.cpp index 1161e4aee482ae..4c6c7f39c3c0dc 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/ctc_greedy_decoder_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/ctc_greedy_decoder_gpu.cpp @@ -5,7 +5,7 @@ #include "ctc_greedy_decoder_inst.h" #include "primitive_gpu_base.h" #include "implementation_map.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_selector_helper.h" #include "ctc_greedy_decoder/ctc_greedy_decoder_kernel_selector.h" #include "ctc_greedy_decoder/ctc_greedy_decoder_kernel_base.h" @@ -21,6 +21,10 @@ struct ctc_greedy_decoder_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + public: static primitive_impl* create(const ctc_greedy_decoder_node& arg) { auto ctc_gd_params = get_default_params(arg); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/cum_sum_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/cum_sum_gpu.cpp index d6d82ae2055dec..82e44cf07a3395 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/cum_sum_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/cum_sum_gpu.cpp @@ -8,7 +8,7 @@ #include "kernel_selector_helper.h" #include "cum_sum/cum_sum_kernel_selector.h" #include "cum_sum/cum_sum_kernel_ref.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" using namespace cldnn; @@ -40,6 +40,10 @@ struct cum_sum_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + public: static primitive_impl* create(const cum_sum_node& arg) { auto cum_sum_params = get_default_params(arg); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/custom_gpu_primitive_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/custom_gpu_primitive_gpu.cpp index 493f40203cdc52..eaecee357b685e 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/custom_gpu_primitive_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/custom_gpu_primitive_gpu.cpp @@ -3,13 +3,12 @@ // #include "custom_gpu_primitive_inst.h" -#include "kernel.h" +#include "cldnn/runtime/engine.hpp" #include "implementation_map.h" #include "kernel_selector_helper.h" #include "network_impl.h" -#include "engine_impl.h" #include "jitter.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "register_gpu.hpp" #include @@ -28,37 +27,52 @@ namespace neural { struct custom_gpu_primitive_gpu : typed_primitive_impl { const custom_gpu_primitive_node& outer; std::shared_ptr cl_kernel; - gpu::kernel _kernel; + std::vector _kernels; + kernel_id _kernel_id; + + std::unique_ptr clone() const override { + return make_unique(*this); + } + + custom_gpu_primitive_gpu(const custom_gpu_primitive_gpu& other) + : outer(other.outer) + , cl_kernel(other.cl_kernel) + , _kernels({}) + , _kernel_id(other._kernel_id) { + _kernels.emplace_back(std::move(outer.get_program().get_kernel(_kernel_id)->clone())); + } custom_gpu_primitive_gpu(const custom_gpu_primitive_node& arg, std::shared_ptr& cl_kernel) - : outer(arg), - cl_kernel(cl_kernel), - _kernel(arg.get_program().get_engine().get_context(), - cl_kernel->kernelString, - arg.get_program().get_id(), - arg.get_program().get_engine().get_context()->get_configuration().dump_custom_program) {} + : outer(arg) + , cl_kernel(cl_kernel) + , _kernels() { + _kernel_id = outer.get_program().add_kernel(cl_kernel->code.kernelString); + } + + void init_kernels() override { + _kernels.emplace_back(std::move(outer.get_program().get_kernel(_kernel_id))); + } void set_arguments_impl(custom_gpu_primitive_inst& instance) override { - auto net_id = instance.get_network().get_id(); - gpu::kernel::kernel_arguments_data args; + auto& stream = instance.get_network().get_stream(); + kernel_arguments_data args; for (auto& dep : instance.dependencies()) { - args.inputs.push_back((memory_impl::cptr) &(dep->output_memory())); + args.inputs.push_back(dep->output_memory_ptr()); } - args.output = (memory_impl::cptr) &instance.output_memory(); - _kernel.set_arguments(net_id, *cl_kernel.get(), args); - } - - void cleanup_impl(custom_gpu_primitive_inst& instance) override { - auto net_id = instance.get_network().get_id(); - _kernel.cleanup(net_id); + args.output = instance.output_memory_ptr(); + stream.set_arguments(*_kernels.front(), cl_kernel.get()->params, args); } - event_impl::ptr execute_impl(const std::vector& events, + event::ptr execute_impl(const std::vector& events, custom_gpu_primitive_inst& instance) override { - auto net_id = instance.get_network().get_id(); - _kernel.set_output_event(net_id, instance.node.is_output()); - return _kernel.run(net_id, *cl_kernel.get(), events); + auto& stream = instance.get_network().get_stream(); + kernel_arguments_data args; + for (auto& dep : instance.dependencies()) { + args.inputs.push_back(dep->output_memory_ptr()); + } + args.output = instance.output_memory_ptr(); + return stream.enqueue_kernel(*_kernels.front(), cl_kernel.get()->params, args, events, instance.node.is_output()); } }; @@ -195,19 +209,19 @@ static primitive_impl* create(const custom_gpu_primitive_node& arg) { const auto primitive = arg.get_primitive().get(); auto cl_kernel = std::make_shared(); - cl_kernel->kernelString = std::make_shared(); - cl_kernel->kernelString->entry_point = primitive->kernel_entry_point; - cl_kernel->kernelString->options = primitive->build_options; - cl_kernel->kernelString->jit = get_jit_constant(arg); + cl_kernel->code.kernelString = std::make_shared(); + cl_kernel->code.kernelString->entry_point = primitive->kernel_entry_point; + cl_kernel->code.kernelString->options = primitive->build_options; + cl_kernel->code.kernelString->jit = get_jit_constant(arg); for (const auto& s : primitive->kernels_code) { - cl_kernel->kernelString->str += s + "\n"; + cl_kernel->code.kernelString->str += s + "\n"; } - cl_kernel->workGroups.global = primitive->gws; - cl_kernel->workGroups.local = primitive->lws; + cl_kernel->params.workGroups.global = primitive->gws; + cl_kernel->params.workGroups.local = primitive->lws; for (const auto& p : primitive->kernel_arguments) { - cl_kernel->arguments.push_back(get_arg(p)); + cl_kernel->params.arguments.push_back(get_arg(p)); } return new custom_gpu_primitive_gpu(arg, cl_kernel); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/deconvolution_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/deconvolution_gpu.cpp index 352bdf00d5d0de..9c1532ecfd45a7 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/deconvolution_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/deconvolution_gpu.cpp @@ -5,7 +5,7 @@ #include "deconvolution_inst.h" #include "primitive_gpu_base.h" #include "implementation_map.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_selector_helper.h" #include "deconvolution/deconvolution_kernel_selector.h" #include "deconvolution/deconvolution_kernel_base.h" @@ -18,6 +18,10 @@ struct deconvolution_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + protected: // TODO: share it with convolution and fully connected bool validate_impl(const typed_primitive_inst&) const override { @@ -33,12 +37,11 @@ struct deconvolution_gpu : typed_primitive_gpu_impl { return res; } - kernel::kernel_arguments_data get_arguments(typed_primitive_inst& instance, - int32_t split) const override { - kernel::kernel_arguments_data args = parent::get_arguments(instance, split); + kernel_arguments_data get_arguments(typed_primitive_inst& instance, int32_t split) const override { + kernel_arguments_data args = parent::get_arguments(instance, split); - args.weights = (memory_impl::cptr) &instance.weights_memory(split); - args.bias = (memory_impl::cptr) (instance.bias_term() ? &instance.bias_memory(split) : nullptr); + args.weights = instance.weights_memory(split); + args.bias = instance.bias_term() ? instance.bias_memory(split) : nullptr; return args; } diff --git a/inference-engine/thirdparty/clDNN/src/gpu/deformable_convolution_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/deformable_convolution_gpu.cpp index 897f1a07a763f7..f2b61a505e27b1 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/deformable_convolution_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/deformable_convolution_gpu.cpp @@ -5,7 +5,7 @@ #include "deformable_convolution_inst.h" #include "primitive_gpu_base.h" #include "implementation_map.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_selector_helper.h" #include "kernel_runner.h" #include "convolution/convolution_kernel_selector.h" @@ -19,13 +19,16 @@ struct deformable_conv_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + protected: - kernel::kernel_arguments_data get_arguments(typed_primitive_inst& instance, - int32_t split) const override { - kernel::kernel_arguments_data args = parent::get_arguments(instance, split); + kernel_arguments_data get_arguments(typed_primitive_inst& instance, int32_t split) const override { + kernel_arguments_data args = parent::get_arguments(instance, split); - args.weights = (memory_impl::cptr) &instance.weights_memory(split); - args.bias = memory_impl::cptr(instance.bias_term() ? &instance.bias_memory(split) : nullptr); + args.weights = instance.weights_memory(split); + args.bias = instance.bias_term() ? instance.bias_memory(split) : nullptr; return args; } @@ -78,6 +81,10 @@ struct deformable_interp_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + protected: int32_t get_split() const override { return 1; } diff --git a/inference-engine/thirdparty/clDNN/src/gpu/depth_to_space_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/depth_to_space_gpu.cpp index fc3c5dd9f56279..3a62c9e0a9c810 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/depth_to_space_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/depth_to_space_gpu.cpp @@ -8,7 +8,7 @@ #include "kernel_selector_helper.h" #include "depth_to_space/depth_to_space_kernel_selector.h" #include "depth_to_space/depth_to_space_kernel_ref.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "common_types.h" using namespace cldnn; @@ -19,6 +19,10 @@ struct depth_to_space_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + public: static primitive_impl* create(const depth_to_space_node& arg) { auto depth_to_space_params = get_default_params(arg); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/detection_output_cpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/detection_output_cpu.cpp index dfe22f193d6a1b..9673270ab264dc 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/detection_output_cpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/detection_output_cpu.cpp @@ -3,7 +3,6 @@ // #include "detection_output_inst.h" -#include "kernel.h" #include "network_impl.h" #include "implementation_map.h" #include "math_utils.h" @@ -37,6 +36,9 @@ struct detection_output_cpu : typed_primitive_impl { const detection_output_node& outer; NMSType nms_type; + std::unique_ptr clone() const override { + return make_unique(*this); + } explicit detection_output_cpu(const detection_output_node& outer) : outer(outer) , nms_type(outer.get_primitive()->decrease_label_id ? MXNET : CAFFE) {} @@ -249,12 +251,12 @@ struct detection_output_cpu : typed_primitive_impl { } template - void generate_detections(const detection_output_inst& instance, + void generate_detections(stream& stream, const detection_output_inst& instance, const int num_of_images, const std::vector>>& all_bboxes, std::vector>>>& confidences, std::vector>>>& scoreIndexPairs) { - mem_lock lock{instance.output_memory()}; + mem_lock lock{instance.output_memory_ptr(), stream}; auto out_ptr = lock.begin(); const auto& args = instance.argument; @@ -405,22 +407,23 @@ struct detection_output_cpu : typed_primitive_impl { } template - void extract_locations_per_image(const detection_output_inst& instance, + void extract_locations_per_image(stream& stream, const detection_output_inst& instance, std::vector>>& locations, const int num_of_priors, const int num_loc_classes) { const bool share_location = instance.argument.share_location; - auto& input_location = instance.location_memory(); + auto input_location = instance.location_memory(); + auto location_layout = input_location->get_layout(); const int num_of_images = static_cast(locations.size()); - mem_lock lock{input_location}; + mem_lock lock{input_location, stream}; auto location_data = lock.begin(); - assert(num_of_priors * num_loc_classes * PRIOR_BOX_SIZE == input_location.get_layout().size.feature[0]); + assert(num_of_priors * num_loc_classes * PRIOR_BOX_SIZE == input_location->get_layout().size.feature[0]); - const auto& input_buffer_size = input_location.get_layout().get_buffer_size(); + const auto& input_buffer_size = location_layout.get_buffer_size(); const int input_buffer_size_x = input_buffer_size.spatial[0]; const int input_buffer_size_y = input_buffer_size.spatial[1]; const int input_buffer_size_f = input_buffer_size.feature[0]; - const auto& input_padding = input_location.get_layout().data_padding; + const auto& input_padding = location_layout.data_padding; const int input_padding_lower_x = input_padding.lower_size().spatial[0]; const int input_padding_lower_y = input_padding.lower_size().spatial[1]; @@ -467,16 +470,16 @@ struct detection_output_cpu : typed_primitive_impl { } template - void extract_prior_boxes_and_variances(const detection_output_inst& instance, + void extract_prior_boxes_and_variances(stream& stream, const detection_output_inst& instance, const bool variance_encoded_in_target, const int32_t prior_info_size, const int32_t prior_coordinates_offset, const int32_t images_count, std::vector& prior_bboxes, std::vector>& prior_variances) { - auto& input_prior_box = instance.prior_box_memory(); + auto input_prior_box = instance.prior_box_memory(); const int num_of_priors = static_cast(prior_bboxes.size()) / images_count; - mem_lock lock{input_prior_box}; + mem_lock lock{input_prior_box, stream}; for (int i = 0; i < images_count; i++) { auto prior_box_data = lock.begin() + i * num_of_priors * prior_info_size * (variance_encoded_in_target ? 1 : 2); @@ -503,25 +506,25 @@ struct detection_output_cpu : typed_primitive_impl { } template - void extract_confidences_per_image_caffe(const detection_output_inst& instance, + void extract_confidences_per_image_caffe(stream& stream, const detection_output_inst& instance, std::vector>>>& confidences, const int num_of_priors) { const int num_classes = instance.argument.num_classes; const int num_of_images = static_cast(confidences.size()); - auto& input_confidence = instance.confidence_memory(); + auto input_confidence = instance.confidence_memory(); const float confidence_threshold = instance.argument.confidence_threshold; - mem_lock lock{(memory_impl::ptr) &input_confidence}; + mem_lock lock{input_confidence, stream}; auto confidence_data = lock.begin(); - assert(num_of_priors * num_classes == input_confidence.get_layout().size.feature[0]); + assert(num_of_priors * num_classes == input_confidence->get_layout().size.feature[0]); - const auto& input_buffer_size = input_confidence.get_layout().get_buffer_size(); + const auto& input_buffer_size = input_confidence->get_layout().get_buffer_size(); const int input_buffer_size_x = input_buffer_size.spatial[0]; const int input_buffer_size_y = input_buffer_size.spatial[1]; const int input_buffer_size_f = input_buffer_size.feature[0]; - const auto& input_padding = input_confidence.get_layout().data_padding; + const auto& input_padding = input_confidence->get_layout().data_padding; const int input_padding_lower_x = input_padding.lower_size().spatial[0]; const int input_padding_lower_y = input_padding.lower_size().spatial[1]; const int stride = input_buffer_size_y * input_buffer_size_x; @@ -593,26 +596,27 @@ struct detection_output_cpu : typed_primitive_impl { } template - void extract_confidences_per_image_mxnet(const detection_output_inst& instance, + void extract_confidences_per_image_mxnet(stream& stream, const detection_output_inst& instance, std::vector>>>& confidences, const int num_of_priors, std::vector>>>& scoreIndexPairs) { const int num_classes = instance.argument.num_classes; const int num_of_images = static_cast(confidences.size()); - auto& input_confidence = instance.confidence_memory(); + auto input_confidence = instance.confidence_memory(); const float confidence_threshold = instance.argument.confidence_threshold; + auto confidence_layout = input_confidence->get_layout(); - mem_lock lock{(memory_impl::ptr) &input_confidence}; + mem_lock lock{input_confidence, stream}; auto confidence_data = lock.begin(); - assert(num_of_priors * num_classes == input_confidence.get_layout().size.feature[0]); + assert(num_of_priors * num_classes == confidence_layout.size.feature[0]); - const auto& input_buffer_size = input_confidence.get_layout().get_buffer_size(); + const auto& input_buffer_size = confidence_layout.get_buffer_size(); const int input_buffer_size_x = input_buffer_size.spatial[0]; const int input_buffer_size_y = input_buffer_size.spatial[1]; const int input_buffer_size_f = input_buffer_size.feature[0]; - const auto& input_padding = input_confidence.get_layout().data_padding; + const auto& input_padding = confidence_layout.data_padding; const int input_padding_lower_x = input_padding.lower_size().spatial[0]; const int input_padding_lower_y = input_padding.lower_size().spatial[1]; const int stride = input_buffer_size_y * input_buffer_size_x; @@ -703,7 +707,7 @@ struct detection_output_cpu : typed_primitive_impl { } template - void prepare_data(const detection_output_inst& instance, + void prepare_data(stream& stream, const detection_output_inst& instance, std::vector>>& bboxes, std::vector>>>& confidences, std::vector>>>& scoreIndexPairs) { @@ -711,23 +715,26 @@ struct detection_output_cpu : typed_primitive_impl { const auto& args = instance.argument; + auto priors_layout = instance.prior_box_memory()->get_layout(); + const int num_of_images = static_cast(bboxes.size()); - const int num_of_priors = instance.prior_box_memory().get_layout().size.spatial[1] / args.prior_info_size; + const int num_of_priors = priors_layout.size.spatial[1] / args.prior_info_size; const int num_loc_classes = args.share_location ? 1 : args.num_classes; // Extract locations per image. std::vector>> locations( num_of_images); // Per image : label -> bounding boxes. - extract_locations_per_image(instance, locations, num_of_priors, num_loc_classes); + extract_locations_per_image(stream, instance, locations, num_of_priors, num_loc_classes); - int32_t batches_in_prior_boxes = instance.prior_box_memory().get_layout().size.batch[0]; + int32_t batches_in_prior_boxes = priors_layout.size.batch[0]; std::vector prior_bboxes(batches_in_prior_boxes * num_of_priors); // Prior-Boxes (identical for all images since we assume // all images in a batch are of same dimension). std::vector> prior_variances( batches_in_prior_boxes * num_of_priors); // Variances per prior-box (identical for all images since we // assume all images in a batch are of same dimension). - extract_prior_boxes_and_variances(instance, + extract_prior_boxes_and_variances(stream, + instance, args.variance_encoded_in_target, args.prior_info_size, args.prior_coordinates_offset, @@ -770,38 +777,39 @@ struct detection_output_cpu : typed_primitive_impl { } // Extract confidences per image. if (nms_type == CAFFE) { - extract_confidences_per_image_caffe(instance, confidences, num_of_priors); + extract_confidences_per_image_caffe(stream, instance, confidences, num_of_priors); } else { - extract_confidences_per_image_mxnet(instance, confidences, num_of_priors, scoreIndexPairs); + extract_confidences_per_image_mxnet(stream, instance, confidences, num_of_priors, scoreIndexPairs); } } - event_impl::ptr execute_impl(const std::vector& events, detection_output_inst& instance) override { + event::ptr execute_impl(const std::vector& events, detection_output_inst& instance) override { for (auto& a : events) { a->wait(); } - auto ev = instance.get_network().get_engine().create_user_event(instance.get_network().get_id(), false); + auto& stream = instance.get_network().get_stream(); - const int num_of_images = instance.location_memory().get_layout().size.batch[0]; // batch size + const int num_of_images = instance.location_memory()->get_layout().size.batch[0]; // batch size // Per image : label -> decoded bounding boxes. std::vector>> bboxes(num_of_images); // Per image : class -> confidences per bounding box. std::vector>>> confidences(num_of_images); + std::vector>>> scoreIndexPairs; - if (instance.location_memory().get_layout().data_type == data_types::f32) { - prepare_data::type>(instance, bboxes, confidences, scoreIndexPairs); - generate_detections::type>(instance, num_of_images, bboxes, confidences, scoreIndexPairs); + if (instance.location_memory()->get_layout().data_type == data_types::f32) { + prepare_data::type>(stream, instance, bboxes, confidences, scoreIndexPairs); + generate_detections::type>(stream, instance, num_of_images, bboxes, confidences, scoreIndexPairs); } else { - prepare_data::type>(instance, bboxes, confidences, scoreIndexPairs); - generate_detections::type>(instance, num_of_images, bboxes, confidences, scoreIndexPairs); + prepare_data::type>(stream, instance, bboxes, confidences, scoreIndexPairs); + generate_detections::type>(stream, instance, num_of_images, bboxes, confidences, scoreIndexPairs); } - dynamic_cast(ev.get())->set(); // set as complete - // TODO: consider refactoring create_user_event() to return cldnn::user_event* - return ev; + return stream.create_user_event(true); } + void init_kernels() override {} + static primitive_impl* create(const detection_output_node& arg) { return new detection_output_cpu(arg); } }; diff --git a/inference-engine/thirdparty/clDNN/src/gpu/device_cache_reader.h b/inference-engine/thirdparty/clDNN/src/gpu/device_cache_reader.h deleted file mode 100644 index 51c50b0df774fb..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/gpu/device_cache_reader.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once -#include -#include "document.h" -#include - -namespace kernel_selector { -class TuningCache; -} - -namespace cldnn { -namespace gpu { - -class device_cache_reader { -public: - explicit device_cache_reader(const std::string tuning_file_path); - std::shared_ptr get() { return _dev_cache; } - -private: - std::shared_ptr _dev_cache; -}; - -} // namespace gpu -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/device_info.h b/inference-engine/thirdparty/clDNN/src/gpu/device_info.h deleted file mode 100644 index 225ed453c2b890..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/gpu/device_info.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once -#include -#include -#include "api/device.hpp" -#include - -namespace cl { -class Device; -} -namespace cldnn { -namespace gpu { - -struct device_info_internal : cldnn::device_info { - std::uint32_t compute_units_count; - uint32_t vendor_id; - uint8_t supports_usm; - bool supports_optimization_hints; - bool supports_local_block_io; - - explicit device_info_internal(const cl::Device& device); - - device_info convert_to_api() { - return { cores_count, - core_frequency, - max_threads_per_execution_unit, - max_threads_per_device, - max_work_group_size, - max_local_mem_size, - max_global_mem_size, - max_alloc_mem_size, - max_image2d_width, - max_image2d_height, - supports_fp16, - supports_fp16_denorms, - supports_subgroups_short, - supports_image, - supports_imad, - supports_immad, - supports_usm, - dev_name, - driver_version, - dev_type, - gfx_ver, - device_id, - num_slices, - num_sub_slices_per_slice, - num_eus_per_sub_slice, - num_threads_per_eu, - }; - } -}; - -} // namespace gpu -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/eltwise_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/eltwise_gpu.cpp index 5ff1be35b761da..8ffc149e160609 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/eltwise_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/eltwise_gpu.cpp @@ -5,7 +5,7 @@ #include "eltwise_inst.h" #include "primitive_gpu_base.h" #include "implementation_map.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_selector_helper.h" #include "eltwise/eltwise_kernel_selector.h" #include "eltwise/eltwise_kernel_base.h" @@ -18,10 +18,13 @@ struct eltwise_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + protected: - kernel::kernel_arguments_data get_arguments(typed_primitive_inst& instance, - int32_t split) const override { - kernel::kernel_arguments_data args = parent::get_arguments(instance, split); + kernel_arguments_data get_arguments(typed_primitive_inst& instance, int32_t split) const override { + kernel_arguments_data args = parent::get_arguments(instance, split); return args; } diff --git a/inference-engine/thirdparty/clDNN/src/gpu/embedding_bag_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/embedding_bag_gpu.cpp index 4de2c9cda6db33..9e705b8bcb5433 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/embedding_bag_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/embedding_bag_gpu.cpp @@ -8,7 +8,7 @@ #include "kernel_selector_helper.h" #include "embedding_bag/embedding_bag_kernel_selector.h" #include "embedding_bag/embedding_bag_kernel_ref.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "data_inst.h" using namespace cldnn; @@ -19,6 +19,10 @@ struct embedding_bag_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + public: static primitive_impl* create(const embedding_bag_node& arg) { auto embedding_bag_params = get_default_params(arg); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/events_waiter.h b/inference-engine/thirdparty/clDNN/src/gpu/events_waiter.h deleted file mode 100644 index 55be7d2e092e73..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/gpu/events_waiter.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma once -#include "ocl_toolkit.h" -#include "event_impl.h" -#include -#include - -namespace cldnn { -namespace gpu { -class events_waiter : public context_holder { -public: - explicit events_waiter(std::shared_ptr context) : context_holder(context) {} - - event_impl::ptr run(uint32_t queue_id, const std::vector& dependencies) { - if (dependencies.size() == 1) - return dependencies[0]; - - return context()->enqueue_marker(queue_id, dependencies); - } -}; -} // namespace gpu -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/extract_image_patches_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/extract_image_patches_gpu.cpp index bff7dafc638d6f..c696821b727583 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/extract_image_patches_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/extract_image_patches_gpu.cpp @@ -5,7 +5,7 @@ #include "extract_image_patches_inst.h" #include "primitive_gpu_base.h" #include "implementation_map.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_selector_helper.h" #include "extract_image_patches/extract_image_patches_kernel_selector.h" @@ -18,6 +18,10 @@ struct extract_image_patches_gpu : typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + public: static primitive_impl* create(const extract_image_patches_node& arg) { auto params = get_default_params(arg); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/fully_connected_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/fully_connected_gpu.cpp index 05cdc2eb3e1d82..2f4a6b48f7ee97 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/fully_connected_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/fully_connected_gpu.cpp @@ -12,11 +12,11 @@ #include "fully_connected/fully_connected_params.h" #include "network_impl.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_runner.h" -#include "api/reorder.hpp" -#include "api/input_layout.hpp" +#include "cldnn/primitives/reorder.hpp" +#include "cldnn/primitives/input_layout.hpp" #include namespace cldnn { @@ -26,13 +26,16 @@ struct fully_connected_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + protected: - kernel::kernel_arguments_data get_arguments(typed_primitive_inst& instance, - int32_t split) const override { - kernel::kernel_arguments_data args = parent::get_arguments(instance, split); + kernel_arguments_data get_arguments(typed_primitive_inst& instance, int32_t split) const override { + kernel_arguments_data args = parent::get_arguments(instance, split); - args.weights = (memory_impl::cptr) &instance.weights_memory(); - args.bias = (memory_impl::cptr) (instance.bias_term() ? &instance.bias_memory() : nullptr); + args.weights = instance.weights_memory(); + args.bias = instance.bias_term() ? instance.bias_memory() : nullptr; return args; } diff --git a/inference-engine/thirdparty/clDNN/src/gpu/fused_conv_eltwise_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/fused_conv_eltwise_gpu.cpp index 28d8990c9eaa23..9e608af17b13c7 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/fused_conv_eltwise_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/fused_conv_eltwise_gpu.cpp @@ -5,7 +5,7 @@ #include "fused_conv_eltwise_inst.h" #include "primitive_gpu_base.h" #include "implementation_map.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_selector_helper.h" #include "kernel_runner.h" #include "fused_conv_eltwise/fused_conv_eltwise_kernel_selector.h" @@ -20,6 +20,10 @@ struct fused_conv_eltwise_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + protected: bool validate_impl(const typed_primitive_inst& instance) const override { (void)instance; @@ -36,12 +40,11 @@ struct fused_conv_eltwise_gpu : typed_primitive_gpu_impl { return res; } - kernel::kernel_arguments_data get_arguments(typed_primitive_inst& instance, - int32_t split) const override { - kernel::kernel_arguments_data args = parent::get_arguments(instance, split); + kernel_arguments_data get_arguments(typed_primitive_inst& instance, int32_t split) const override { + kernel_arguments_data args = parent::get_arguments(instance, split); - args.weights = (memory_impl::cptr) &instance.weights_memory(split); - args.bias = (memory_impl::cptr) (instance.bias_term() ? &instance.bias_memory(split) : nullptr); + args.weights = instance.weights_memory(split); + args.bias = instance.bias_term() ? instance.bias_memory(split) : nullptr; return args; } diff --git a/inference-engine/thirdparty/clDNN/src/gpu/gather_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/gather_gpu.cpp index c596bbef83fde1..e0d51b3f0009ba 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/gather_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/gather_gpu.cpp @@ -8,7 +8,7 @@ #include "kernel_selector_helper.h" #include "gather/gather_kernel_selector.h" #include "gather/gather_kernel_ref.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" using namespace cldnn; @@ -37,6 +37,10 @@ struct gather_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + public: static primitive_impl* create(const gather_node& arg) { auto gather_params = get_default_params(arg); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/gather_nd_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/gather_nd_gpu.cpp index dc05203f37981e..cf7d692651a413 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/gather_nd_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/gather_nd_gpu.cpp @@ -1,18 +1,6 @@ -/* -// Copyright (c) 2021 Intel Corporation +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -*/ #include "gather_nd_inst.h" #include "primitive_gpu_base.h" @@ -20,7 +8,6 @@ #include "kernel_selector_helper.h" #include "gather/gather_nd_kernel_selector.h" #include "gather/gather_nd_kernel_ref.h" -#include "error_handler.h" using namespace cldnn; @@ -31,7 +18,10 @@ struct gather_nd_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; -public: + std::unique_ptr clone() const override { + return make_unique(*this); + } + static primitive_impl* create(const gather_nd_node& arg) { auto gather_nd_params = get_default_params(arg); auto gather_nd_optional_params = diff --git a/inference-engine/thirdparty/clDNN/src/gpu/gather_tree_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/gather_tree_gpu.cpp index db98e0b543c67d..f0ae5fcdbc6617 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/gather_tree_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/gather_tree_gpu.cpp @@ -9,7 +9,8 @@ #include "kernel_selector_helper.h" #include "gather_tree/gather_tree_kernel_selector.h" #include "gather_tree/gather_tree_kernel_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" + namespace cldnn { namespace gpu { @@ -17,6 +18,10 @@ struct gather_tree_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + static primitive_impl* create(const gather_tree_node& arg) { auto b_params = get_default_params(arg, 1); auto b_optional_params = get_default_optional_params(arg.get_program()); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/gemm_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/gemm_gpu.cpp index bc475596c7ccc8..9a6a76802dcf90 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/gemm_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/gemm_gpu.cpp @@ -9,7 +9,7 @@ #include "kernel_selector_helper.h" #include "gemm/gemm_kernel_selector.h" #include "gemm/gemm_kernel_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" namespace cldnn { namespace gpu { @@ -18,6 +18,10 @@ struct gemm_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + public: static primitive_impl* create(const gemm_node& arg) { auto gemm_params = get_default_params(arg, 1); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/generic_layer_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/generic_layer_gpu.cpp index c6643ed65beb95..a7d3d610b31081 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/generic_layer_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/generic_layer_gpu.cpp @@ -3,11 +3,10 @@ // #include "generic_layer_inst.h" -#include "kernel.h" +#include "cldnn/runtime/engine.hpp" #include "implementation_map.h" #include "kernel_selector_helper.h" #include "network_impl.h" -#include "engine_impl.h" #include "register_gpu.hpp" #include @@ -18,36 +17,57 @@ namespace neural { struct generic_layer_gpu : typed_primitive_impl { const generic_layer_node& outer; const kernel_selector::cl_kernel_data& _cl_kernel_data; - gpu::kernel _kernel; + std::vector _kernels; + kernel_id _kernel_id; - explicit generic_layer_gpu(const generic_layer_node& arg) - : outer(arg), - _cl_kernel_data(*outer.get_primitive()->generic_params.clKernel.get()), - _kernel(arg.get_program().get_engine().get_context(), - outer.get_primitive()->generic_params.clKernel->kernelString, - arg.get_program().get_id()) {} + std::unique_ptr clone() const override { + return make_unique(*this); + } + + generic_layer_gpu(const generic_layer_gpu& other) + : outer(other.outer) + , _cl_kernel_data(other._cl_kernel_data) + , _kernels({}) + , _kernel_id(other._kernel_id) { + if (other._kernels.empty()) { + throw std::runtime_error("Can't copy generic_layer_gpu node: kernels vector is empty"); + } + _kernels.push_back(other._kernels.front()->clone()); + } + + generic_layer_gpu(const generic_layer_node& arg) + : outer(arg) + , _cl_kernel_data(*outer.get_primitive()->generic_params.clKernel.get()) + , _kernels() { + _kernel_id = outer.get_program().add_kernel(outer.get_primitive()->generic_params.clKernel->code.kernelString); + } + + void init_kernels() override { + _kernels.push_back(outer.get_program().get_kernel(_kernel_id)); + } void set_arguments_impl(generic_layer_inst& instance) override { - auto net_id = instance.get_network().get_id(); - gpu::kernel::kernel_arguments_data args; - args.scalars = &_cl_kernel_data.scalars; + stream& stream = instance.get_network().get_stream(); + kernel_arguments_data args; + args.scalars = &_cl_kernel_data.params.scalars; for (size_t i = 0; i < instance.inputs_memory_count(); i++) { - args.inputs.push_back((memory_impl::cptr) &instance.input_memory(i)); + args.inputs.push_back(instance.input_memory_ptr(i)); } - args.output = (memory_impl::cptr) &instance.output_memory(); - _kernel.set_arguments(net_id, _cl_kernel_data, args); + args.output = instance.output_memory_ptr(); + stream.set_arguments(*_kernels.front(), _cl_kernel_data.params, args); } - void cleanup_impl(generic_layer_inst& instance) override { - auto net_id = instance.get_network().get_id(); - _kernel.cleanup(net_id); - } + event::ptr execute_impl(const std::vector& events, generic_layer_inst& instance) override { + stream& stream = instance.get_network().get_stream(); + kernel_arguments_data args; + args.scalars = &_cl_kernel_data.params.scalars; - event_impl::ptr execute_impl(const std::vector& events, generic_layer_inst& instance) override { - uint32_t net_id = instance.get_network().get_id(); - _kernel.set_output_event(net_id, instance.node.is_output()); - return _kernel.run(net_id, _cl_kernel_data, events); + for (size_t i = 0; i < instance.inputs_memory_count(); i++) { + args.inputs.push_back(instance.input_memory_ptr(i)); + } + args.output = instance.output_memory_ptr(); + return stream.enqueue_kernel(*_kernels.front(), _cl_kernel_data.params, args, events, true); } }; @@ -55,28 +75,34 @@ struct generic_layer_gpu : typed_primitive_impl { struct generic_layer_cpu : typed_primitive_impl { const generic_layer_node& outer; + std::unique_ptr clone() const override { + return make_unique(*this); + } + explicit generic_layer_cpu(const generic_layer_node& arg) : outer(arg) {} - event_impl::ptr execute_impl(const std::vector& events, generic_layer_inst& instance) override { - uint32_t net_id = instance.get_network().get_id(); - auto& input_mem = instance.input_memory(); - auto& output_mem = instance.output_memory(); + event::ptr execute_impl(const std::vector& events, generic_layer_inst& instance) override { + stream& stream = instance.get_network().get_stream(); + auto input_mem = instance.input_memory_ptr(); + auto output_mem = instance.output_memory_ptr(); - std::vector tmp_events(events); + std::vector tmp_events(events); for (auto& a : events) { a->wait(); } - mem_lock old_pointer(input_mem); - mem_lock new_pointer(output_mem); + mem_lock old_pointer(input_mem, stream); + mem_lock new_pointer(output_mem, stream); const auto& cpu_kernel = *outer.get_primitive()->generic_params.cpuKernel.get(); cpu_kernel.Execute(old_pointer.data(), old_pointer.size(), new_pointer.data(), new_pointer.size()); - return instance.get_network().get_engine().create_user_event(net_id, true); + return stream.create_user_event(true); } + + void init_kernels() override {} }; static primitive_impl* create(const generic_layer_node& arg) { diff --git a/inference-engine/thirdparty/clDNN/src/gpu/grn_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/grn_gpu.cpp index 7612be5ccffc37..5b9d8c9145ca55 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/grn_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/grn_gpu.cpp @@ -5,7 +5,7 @@ #include "grn_inst.h" #include "primitive_gpu_base.h" #include "implementation_map.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_selector_helper.h" #include "grn/grn_kernel_selector.h" #include "grn/grn_kernel_base.h" @@ -21,6 +21,10 @@ struct grn_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + public: static primitive_impl* create(const grn_node& arg) { auto grn_params = get_default_params(arg); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/kernel.cpp b/inference-engine/thirdparty/clDNN/src/gpu/kernel.cpp deleted file mode 100644 index 0ba0ece0443359..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/gpu/kernel.cpp +++ /dev/null @@ -1,275 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#include -#include "kernel.h" -#include "memory_gpu.h" -#include "memory_impl.h" -#include "refcounted_obj.h" -#include - -namespace cldnn { -namespace gpu { - -namespace { -inline cl::NDRange toNDRange(const std::vector& v) { - switch (v.size()) { - case 1: - return cl::NDRange(v[0]); - case 2: - return cl::NDRange(v[0], v[1]); - case 3: - return cl::NDRange(v[0], v[1], v[2]); - default: - return cl::NullRange; - } -} - -void set_arguments_impl(kernels_cache::kernel_type& kernel, - const kernel_selector::kernel_arguments& args, - const kernel::kernel_arguments_data& data) { - for (uint32_t i = 0; i < static_cast(args.size()); i++) { - cl_int status = CL_INVALID_ARG_VALUE; - switch (args[i].t) { - case kernel_selector::kernel_argument_types::INPUT: - if (args[i].index < data.inputs.size() && data.inputs[args[i].index]) { - const auto& input_mem = data.inputs[args[i].index]; - if (input_mem) { - if (input_mem->get_layout().format.is_image_2d()) - status = kernel.setArg(i, dynamic_cast(*input_mem).get_buffer()); - else if (memory_capabilities::is_usm_type(input_mem->get_allocation_type())) - status = kernel.setArgUsm(i, dynamic_cast(*input_mem).get_buffer()); - else - status = kernel.setArg(i, dynamic_cast(*input_mem).get_buffer()); - } - } - break; - case kernel_selector::kernel_argument_types::INPUT_OF_FUSED_PRIMITIVE: - if (args[i].index < data.fused_op_inputs.size() && data.fused_op_inputs[args[i].index]) { - const auto& input_mem = data.fused_op_inputs[args[i].index]; - if (input_mem) { - if (memory_capabilities::is_usm_type(input_mem->get_allocation_type())) - status = kernel.setArgUsm(i, dynamic_cast(*input_mem).get_buffer()); - else - status = kernel.setArg(i, dynamic_cast(*input_mem).get_buffer()); - } - } - break; - case kernel_selector::kernel_argument_types::INTERNAL_BUFFER: - if (args[i].index < data.intermediates.size() && data.intermediates[args[i].index]) { - const auto& input_mem = data.intermediates[args[i].index]; - if (input_mem) { - if (memory_capabilities::is_usm_type(input_mem->get_allocation_type())) - status = kernel.setArgUsm(i, dynamic_cast(*input_mem).get_buffer()); - else - status = kernel.setArg(i, dynamic_cast(*input_mem).get_buffer()); - } - } - break; - case kernel_selector::kernel_argument_types::OUTPUT: - if (data.output) { - if (data.output->get_layout().format.is_image_2d()) - status = kernel.setArg(i, dynamic_cast(*data.output).get_buffer()); - else if (memory_capabilities::is_usm_type(data.output->get_allocation_type())) - status = kernel.setArgUsm(i, dynamic_cast(*data.output).get_buffer()); - else - status = kernel.setArg(i, dynamic_cast(*data.output).get_buffer()); - } - break; - case kernel_selector::kernel_argument_types::WEIGHTS: - if (data.weights) { - if (data.weights->get_layout().format.is_image_2d()) - status = kernel.setArg(i, dynamic_cast(*data.weights).get_buffer()); - else if (memory_capabilities::is_usm_type(data.weights->get_allocation_type())) - status = kernel.setArgUsm(i, dynamic_cast(*data.weights).get_buffer()); - else - status = kernel.setArg(i, dynamic_cast(*data.weights).get_buffer()); - } - break; - case kernel_selector::kernel_argument_types::BIAS: - if (data.bias) { - if (memory_capabilities::is_usm_type(data.bias->get_allocation_type())) - status = kernel.setArgUsm(i, dynamic_cast(*data.bias).get_buffer()); - else - status = kernel.setArg(i, dynamic_cast(*data.bias).get_buffer()); - } - break; - case kernel_selector::kernel_argument_types::WEIGHTS_ZERO_POINTS: - if (data.weights_zero_points) { - if (memory_capabilities::is_usm_type(data.weights_zero_points->get_allocation_type())) - status = kernel.setArgUsm( - i, - dynamic_cast(*data.weights_zero_points).get_buffer()); - else - status = kernel.setArg( - i, - dynamic_cast(*data.weights_zero_points).get_buffer()); - } - break; - case kernel_selector::kernel_argument_types::ACTIVATIONS_ZERO_POINTS: - if (data.activations_zero_points) { - if (memory_capabilities::is_usm_type(data.activations_zero_points->get_allocation_type())) - status = kernel.setArgUsm( - i, - dynamic_cast(*data.activations_zero_points).get_buffer()); - else - status = kernel.setArg( - i, - dynamic_cast(*data.activations_zero_points).get_buffer()); - } - break; - case kernel_selector::kernel_argument_types::COMPENSATION: - if (data.compensation) { - if (memory_capabilities::is_usm_type(data.compensation->get_allocation_type())) - status = kernel.setArgUsm( - i, - dynamic_cast(*data.compensation).get_buffer()); - else - status = kernel.setArg( - i, - dynamic_cast(*data.compensation).get_buffer()); - } - break; - case kernel_selector::kernel_argument_types::SCALE_TABLE: - if (data.scale_table) { - if (memory_capabilities::is_usm_type(data.scale_table->get_allocation_type())) - status = kernel.setArgUsm(i, dynamic_cast(*data.scale_table).get_buffer()); - else - status = kernel.setArg(i, dynamic_cast(*data.scale_table).get_buffer()); - } - break; - case kernel_selector::kernel_argument_types::SLOPE: - if (data.slope) { - if (memory_capabilities::is_usm_type(data.slope->get_allocation_type())) - status = kernel.setArgUsm(i, dynamic_cast(*data.slope).get_buffer()); - else - status = kernel.setArg(i, dynamic_cast(*data.slope).get_buffer()); - } - break; - case kernel_selector::kernel_argument_types::SPLIT: - status = kernel.setArg(i, data.split); - break; - case kernel_selector::kernel_argument_types::SCALAR: - if (data.scalars && args[i].index < data.scalars->size()) { - const auto& scalar = (*data.scalars)[args[i].index]; - switch (scalar.t) { - case kernel_selector::kernel_scalar_argument_types::UINT8: - status = kernel.setArg(i, scalar.v.u8); - break; - case kernel_selector::kernel_scalar_argument_types::UINT16: - status = kernel.setArg(i, scalar.v.u16); - break; - case kernel_selector::kernel_scalar_argument_types::UINT32: - status = kernel.setArg(i, scalar.v.u32); - break; - case kernel_selector::kernel_scalar_argument_types::UINT64: - status = kernel.setArg(i, scalar.v.u64); - break; - case kernel_selector::kernel_scalar_argument_types::INT8: - status = kernel.setArg(i, scalar.v.s8); - break; - case kernel_selector::kernel_scalar_argument_types::INT16: - status = kernel.setArg(i, scalar.v.s16); - break; - case kernel_selector::kernel_scalar_argument_types::INT32: - status = kernel.setArg(i, scalar.v.s32); - break; - case kernel_selector::kernel_scalar_argument_types::INT64: - status = kernel.setArg(i, scalar.v.s64); - break; - case kernel_selector::kernel_scalar_argument_types::FLOAT32: - status = kernel.setArg(i, scalar.v.f32); - break; - case kernel_selector::kernel_scalar_argument_types::FLOAT64: - status = kernel.setArg(i, scalar.v.f64); - break; - default: - break; - } - } - break; - case kernel_selector::kernel_argument_types::RECURRENT: // RNN/LSTM/GRU layers - if (data.recurrent) { - if (data.recurrent->get_layout().format.is_image_2d()) - status = kernel.setArg(i, dynamic_cast(*data.recurrent).get_buffer()); - else if (memory_capabilities::is_usm_type(data.recurrent->get_allocation_type())) - status = kernel.setArgUsm(i, dynamic_cast(*data.recurrent).get_buffer()); - else - status = kernel.setArg(i, dynamic_cast(*data.recurrent).get_buffer()); - } - break; - case kernel_selector::kernel_argument_types::HIDDEN: // RNN/LSTM/GRU layers - if (data.hidden) { - if (data.hidden->get_layout().format.is_image_2d()) - status = kernel.setArg(i, dynamic_cast(*data.hidden).get_buffer()); - else if (memory_capabilities::is_usm_type(data.hidden->get_allocation_type())) - status = kernel.setArgUsm(i, dynamic_cast(*data.hidden).get_buffer()); - else - status = kernel.setArg(i, dynamic_cast(*data.hidden).get_buffer()); - } - break; - case kernel_selector::kernel_argument_types::CELL: // LSTMlayers - if (data.cell) { - if (data.cell->get_layout().format.is_image_2d()) - status = kernel.setArg(i, dynamic_cast(*data.cell).get_buffer()); - else if (memory_capabilities::is_usm_type(data.cell->get_allocation_type())) - status = kernel.setArgUsm(i, dynamic_cast(*data.cell).get_buffer()); - else - status = kernel.setArg(i, dynamic_cast(*data.cell).get_buffer()); - } - break; - default: - break; - } - - if (status != CL_SUCCESS) { - throw std::runtime_error("Error set arg " + std::to_string(i) + ", error code: " + std::to_string(status) + "\n"); - } - } -} -} // namespace - -void kernel::set_arguments(uint32_t queue_id, - const kernel_selector::cl_kernel_data& kernel_data, - const kernel_arguments_data& args) { - static std::mutex m; - std::lock_guard guard(m); - auto compiled_kernel = context()->get_kernels_cache(_prog_id).get_kernel(_kernel_id, _one_time_kernel); - - // Create a copy of cl kernel for each stream if it doesn't exist - // Copy is needed to avoid data races between streams, but we create it only once for each stream - // because the cloning is quite expensive. - // Mutex is still needed to ensure that insert operation into the map is thread safe - if (_cl_kernels.find(queue_id) == _cl_kernels.end()) - _cl_kernels[queue_id] = compiled_kernel.clone(); - - try { - set_arguments_impl(_cl_kernels.at(queue_id), kernel_data.arguments, args); - } catch (cl::Error const& err) { - throw ocl_error(err); - } -} - -void kernel::cleanup(uint32_t queue_id) { - _cl_kernels.erase(queue_id); -} - -event_impl::ptr kernel::run(uint32_t queue_id, - const kernel_selector::cl_kernel_data& kernel_data, - const std::vector& dependencies) const { - if (_cl_kernels.find(queue_id) == _cl_kernels.end() || _cl_kernels.at(queue_id).get() == NULL) { - throw std::runtime_error("[clDNN] Kernel for layer " + kernel_data.layerID + " is not found for stream " + std::to_string(queue_id)); - } - - return context()->enqueue_kernel(queue_id, - _cl_kernels.at(queue_id), - toNDRange(kernel_data.workGroups.global), - toNDRange(kernel_data.workGroups.local), - dependencies); -} - -} // namespace gpu -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/kernel.h b/inference-engine/thirdparty/clDNN/src/gpu/kernel.h deleted file mode 100644 index c55f2ca615b3ef..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/gpu/kernel.h +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma once - -#include "ocl_toolkit.h" -#include "memory_impl.h" -#include "kernels_cache.h" -#include "event_impl.h" - -#include "kernel_selector_helper.h" -#include -#include - -namespace cldnn { -namespace gpu { - -class kernel : public context_holder { - uint32_t _prog_id; - kernels_cache::kernel_id _kernel_id; - bool _one_time_kernel; // If this flag is true, the kernel is intended to be executed only once (can be removed - // later from the cache). - - std::map _cl_kernels; - -public: - explicit kernel(std::shared_ptr context, - const std::shared_ptr& kernel_string, - uint32_t prog_id, - bool dump_custom_program = false, - bool one_time_kernel = false) - : context_holder(context) - , _prog_id(prog_id) - , _kernel_id(context->get_kernels_cache(prog_id).set_kernel_source(kernel_string, dump_custom_program, one_time_kernel)) - , _one_time_kernel(one_time_kernel) - , _cl_kernels({}) {} - - kernel(const kernel& other) - : context_holder(other.context()) - , _prog_id(other._prog_id) - , _kernel_id(other._kernel_id) - , _one_time_kernel(other._one_time_kernel) - , _cl_kernels(other._cl_kernels) {} - - kernel& operator=(const kernel& other) { - if (this == &other) { - return *this; - } - - _kernel_id = other._kernel_id; - _prog_id = other._prog_id; - _one_time_kernel = other._one_time_kernel; - _cl_kernels = other._cl_kernels; - - return *this; - } - - struct kernel_arguments_data { - std::vector inputs; - std::vector intermediates; - memory_impl::cptr output; - memory_impl::cptr weights; - memory_impl::cptr recurrent; - memory_impl::cptr hidden; - memory_impl::cptr cell; - memory_impl::cptr bias; - memory_impl::cptr weights_zero_points; - memory_impl::cptr activations_zero_points; - memory_impl::cptr compensation; - memory_impl::cptr lookup_table; - memory_impl::cptr scale_table; - memory_impl::cptr slope; - // used for fused primitives - std::vector fused_op_inputs; - int32_t split = 0; - float lr; - const kernel_selector::kernel_scalar_arguments* scalars = nullptr; - }; - - void set_output_event(uint32_t net_id, bool is_out_event) { - context()->set_output_event(net_id, is_out_event); - } - - void cleanup(uint32_t queue_id); - void set_arguments(uint32_t queue_id, - const kernel_selector::cl_kernel_data& kernel_data, - const kernel_arguments_data& args); - event_impl::ptr run(uint32_t queue_id, - const kernel_selector::cl_kernel_data& kernel_data, - const std::vector& dependencies) const; -}; - -} // namespace gpu -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/kernel_runner.cpp b/inference-engine/thirdparty/clDNN/src/gpu/kernel_runner.cpp index 2faddb64a6ac5d..8f937863b52685 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/kernel_runner.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/kernel_runner.cpp @@ -5,8 +5,10 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include "kernel_runner.h" -#include "kernel.h" +#include "runtime/kernels_cache.hpp" +#include "cldnn/runtime/stream.hpp" #include "weight_bias_params.h" +#include "kernel_selector_helper.h" #include #include #include @@ -15,19 +17,18 @@ namespace cldnn { namespace gpu { -kernel_runner::kernel_runner(engine_impl& engine_ref, uint32_t program_id, bool weights_and_bias_exist, bool zero_points_exist) - : engine(&engine_ref), program_id(program_id), weights_and_bias_exist(weights_and_bias_exist), zero_points_exist(zero_points_exist) {} +kernel_runner::kernel_runner(engine& engine_ref, uint32_t program_id, bool weights_and_bias_exist, bool zero_points_exist) + : _engine(engine_ref), program_id(program_id), weights_and_bias_exist(weights_and_bias_exist), zero_points_exist(zero_points_exist) {} void kernel_runner::prepare_kernel_args(const kernel_selector::KernelsData& kernels_data, - gpu::kernel::kernel_arguments_data& args) { + kernel_arguments_data& args) { const auto& base_params = *static_cast(kernels_data[0].params.get()); // Prepare input buffers if (input_buffers.empty()) { for (const auto& input : base_params.inputs) { int num_of_input_elements = static_cast(input.PhysicalSize()); - input_buffers.push_back(engine->allocate_memory( - {from_data_type(input.GetDType()), format::bfyx, tensor(1, 1, num_of_input_elements, 1)}, - 0)); + input_buffers.push_back(_engine.allocate_memory( + {from_data_type(input.GetDType()), format::bfyx, tensor(1, 1, num_of_input_elements, 1)})); } } for (const auto& input : input_buffers) { @@ -38,9 +39,8 @@ void kernel_runner::prepare_kernel_args(const kernel_selector::KernelsData& kern for (auto& fused_op : base_params.fused_ops) { for (auto& fused_ops_input : fused_op.tensors) { auto num_of_elements = static_cast(fused_ops_input.PhysicalSize()); - fused_ops_buffers.push_back(engine->allocate_memory( - { from_data_type(fused_ops_input.GetDType()), format::bfyx, tensor(1, 1, num_of_elements, 1) }, - 0)); + fused_ops_buffers.push_back(_engine.allocate_memory( + { from_data_type(fused_ops_input.GetDType()), format::bfyx, tensor(1, 1, num_of_elements, 1) })); } } } @@ -50,9 +50,8 @@ void kernel_runner::prepare_kernel_args(const kernel_selector::KernelsData& kern // Prepare output buffer if (output_buffers.empty()) { int num_of_output_elements = static_cast(base_params.output.PhysicalSize()); - output_buffers.push_back(engine->allocate_memory( - {from_data_type(base_params.output.GetDType()), format::bfyx, tensor(1, 1, num_of_output_elements, 1)}, - 0)); + output_buffers.push_back(_engine.allocate_memory( + {from_data_type(base_params.output.GetDType()), format::bfyx, tensor(1, 1, num_of_output_elements, 1)})); } args.output = output_buffers[0]; @@ -72,17 +71,15 @@ void kernel_runner::prepare_kernel_args(const kernel_selector::KernelsData& kern if (!cldnn::format::is_image_2d(from_weights_layout(weights_bias_params.weights.GetLayout()))) { if (weight_buffers.empty()) weight_buffers.push_back( - engine->allocate_memory({from_weights_type(weights_bias_params.weights.GetDType()), + _engine.allocate_memory({from_weights_type(weights_bias_params.weights.GetDType()), fmt, - tensor(num_of_weight_elements_ofm, 1, num_of_weight_elements_spatial, 1)}, - 0)); + tensor(num_of_weight_elements_ofm, 1, num_of_weight_elements_spatial, 1)})); if (weight_buffers[0]->get_layout().format != fmt) weight_buffers[0] = - engine->allocate_memory({from_weights_type(weights_bias_params.weights.GetDType()), + _engine.allocate_memory({from_weights_type(weights_bias_params.weights.GetDType()), fmt, - tensor(num_of_weight_elements_ofm, 1, num_of_weight_elements_spatial, 1)}, - 0); + tensor(num_of_weight_elements_ofm, 1, num_of_weight_elements_spatial, 1)}); while (weight_buffers[0]->get_layout().bytes_count() < weights_bias_params.weights.PhysicalSizeInBytes()) { // Weights layout depends on the kernel. Multiply the buffer size by 2 until it is big enough @@ -90,22 +87,20 @@ void kernel_runner::prepare_kernel_args(const kernel_selector::KernelsData& kern weight_buffers.clear(); num_of_weight_elements_spatial *= 2; weight_buffers.push_back( - engine->allocate_memory({from_weights_type(weights_bias_params.weights.GetDType()), + _engine.allocate_memory({from_weights_type(weights_bias_params.weights.GetDType()), fmt, - tensor(num_of_weight_elements_ofm, 1, num_of_weight_elements_spatial, 1)}, - 0)); + tensor(num_of_weight_elements_ofm, 1, num_of_weight_elements_spatial, 1)})); } } else { weight_buffers.clear(); fmt = from_weights_layout(weights_bias_params.weights.GetLayout()); num_of_weight_elements_ofm = static_cast(weights_bias_params.weights.OFM().v); - weight_buffers.push_back(engine->allocate_memory({from_weights_type(weights_bias_params.weights.GetDType()), + weight_buffers.push_back(_engine.allocate_memory({from_weights_type(weights_bias_params.weights.GetDType()), fmt, tensor(num_of_weight_elements_ofm, num_of_weight_elements_ifm, num_of_weight_elements_spatial_x, - num_of_weight_elements_spatial_y)}, - 0)); + num_of_weight_elements_spatial_y)})); } args.weights = weight_buffers[0]; @@ -113,10 +108,9 @@ void kernel_runner::prepare_kernel_args(const kernel_selector::KernelsData& kern if (!weights_bias_params.bias.empty()) { if (bias_buffers.empty()) { int num_of_bias_elements = static_cast(weights_bias_params.bias[0].PhysicalSize()); - bias_buffers.push_back(engine->allocate_memory({from_data_type(weights_bias_params.bias[0].GetDType()), + bias_buffers.push_back(_engine.allocate_memory({from_data_type(weights_bias_params.bias[0].GetDType()), format::bfyx, - tensor(1, num_of_bias_elements, 1, 1)}, - 0)); + tensor(1, num_of_bias_elements, 1, 1)})); } args.bias = bias_buffers[0]; } @@ -128,11 +122,10 @@ void kernel_runner::prepare_kernel_args(const kernel_selector::KernelsData& kern auto& weight_zero_point = zero_point_params.weights_zero_points[0]; auto num_of_elements = static_cast(weight_zero_point.PhysicalSize()); weight_zero_point_buffers.push_back( - engine->allocate_memory({ + _engine.allocate_memory({ from_data_type(weight_zero_point.GetDType()), format::bfyx, - tensor(1, num_of_elements, 1, 1) }, - 0)); + tensor(1, num_of_elements, 1, 1) })); } args.weights_zero_points = weight_zero_point_buffers[0]; } @@ -141,11 +134,10 @@ void kernel_runner::prepare_kernel_args(const kernel_selector::KernelsData& kern auto& activation_zero_point = zero_point_params.activations_zero_points[0]; auto num_of_elements = static_cast(activation_zero_point.PhysicalSize()); activation_zero_point_buffers.push_back( - engine->allocate_memory({ + _engine.allocate_memory({ from_data_type(activation_zero_point.GetDType()), format::bfyx, - tensor(1, num_of_elements, 1, 1) }, - 0)); + tensor(1, num_of_elements, 1, 1) })); } args.activations_zero_points = activation_zero_point_buffers[0]; } @@ -154,11 +146,10 @@ void kernel_runner::prepare_kernel_args(const kernel_selector::KernelsData& kern auto& compensation = zero_point_params.compensation[0]; auto num_of_elements = static_cast(compensation.PhysicalSize()); compensation_buffers.push_back( - engine->allocate_memory({ + _engine.allocate_memory({ from_data_type(compensation.GetDType()), format::bfyx, - tensor(1, num_of_elements, 1, 1) }, - 0)); + tensor(1, num_of_elements, 1, 1) })); } args.compensation = compensation_buffers[0]; } @@ -169,10 +160,10 @@ void kernel_runner::prepare_kernel_args(const kernel_selector::KernelsData& kern } std::vector kernel_runner::run_kernels(const kernel_selector::KernelsData& kernels_data) { - auto context = engine->get_context(); - std::vector run_times; + stream::ptr stream = _engine.create_stream(); + int num_of_kernels_to_run = static_cast(kernels_data.size()); int num_of_kernels_run = 0; @@ -182,28 +173,31 @@ std::vector kernel_runner::run_kernels(const kernel_se int current_compilation_batch = std::min(num_of_kernels_to_run, compilation_batch_size); batch_end = batch_start + current_compilation_batch; - std::vector kernels; + std::vector kernels; + kernels_cache cache(_engine); for (auto it = batch_start; it < batch_end; it++) { - kernels.push_back(kernel(context, it->kernels[0].kernelString, program_id, false, true)); + auto kernel_id = cache.set_kernel_source(it->kernels[0].code.kernelString, false); + + kernels.push_back(cache.get_kernel(kernel_id)); } - gpu::kernel::kernel_arguments_data args; + kernel_arguments_data args; prepare_kernel_args(kernels_data, args); - context->queue(0).finish(); + stream->finish(); int i = 0; for (auto it = batch_start; it < batch_end; it++) { - std::vector events; + std::vector events; auto kernel_run_time = std::chrono::nanoseconds::max(); int num_of_runs = 0; for (int iteration = 0; iteration < runs_per_kernel; iteration++) { - event_impl::ptr event; + event::ptr event; try { - kernels[i].set_arguments(0, it->kernels[0], args); - event = kernels[i].run(0, it->kernels[0], {}); + stream->set_arguments(*kernels[i], it->kernels[0].params, args); + event = stream->enqueue_kernel(*kernels[i], it->kernels[0].params, args, {}); } catch (std::exception& e) { std::cout << "[clDNN] Could not run kernel for auto-tune: " << it->kernelName << " with auto-tune index " << it->autoTuneIndex << std::endl @@ -215,7 +209,7 @@ std::vector kernel_runner::run_kernels(const kernel_se } events.push_back(event); } - context->queue(0).finish(); + stream->finish(); for (auto& event : events) { if (event.get() != NULL) { diff --git a/inference-engine/thirdparty/clDNN/src/gpu/kernel_runner.h b/inference-engine/thirdparty/clDNN/src/gpu/kernel_runner.h index 6e257fef15f8d3..53eadc9095696f 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/kernel_runner.h +++ b/inference-engine/thirdparty/clDNN/src/gpu/kernel_runner.h @@ -5,10 +5,10 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "engine_impl.h" +#include "cldnn/runtime/engine.hpp" #include "kernel_selector_common.h" +#include "kernel_selector_helper.h" #include "kernel_runner_interface.h" -#include "kernel.h" #include namespace cldnn { @@ -16,7 +16,7 @@ namespace gpu { class kernel_runner : public kernel_selector::KernelRunnerInterface { public: - kernel_runner(engine_impl& engine_ref, uint32_t program_id, bool weights_and_bias_exist = false, bool zero_points_exist = false); + kernel_runner(engine& engine_ref, uint32_t program_id, bool weights_and_bias_exist = false, bool zero_points_exist = false); std::vector run_kernels(const kernel_selector::KernelsData& kernelsData) override; @@ -25,20 +25,20 @@ class kernel_runner : public kernel_selector::KernelRunnerInterface { const int runs_per_kernel = 15; void prepare_kernel_args(const kernel_selector::KernelsData& kernels_data, - gpu::kernel::kernel_arguments_data& args); + kernel_arguments_data& args); - engine_impl::ptr engine; + engine& _engine; uint32_t program_id; bool weights_and_bias_exist; bool zero_points_exist; - std::vector input_buffers; - std::vector fused_ops_buffers; - std::vector output_buffers; - std::vector weight_buffers; - std::vector bias_buffers; - std::vector weight_zero_point_buffers; - std::vector activation_zero_point_buffers; - std::vector compensation_buffers; + std::vector input_buffers; + std::vector fused_ops_buffers; + std::vector output_buffers; + std::vector weight_buffers; + std::vector bias_buffers; + std::vector weight_zero_point_buffers; + std::vector activation_zero_point_buffers; + std::vector compensation_buffers; }; ////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/inference-engine/thirdparty/clDNN/src/gpu/loop_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/loop_gpu.cpp index ea8965ec427c41..828fb6ca3d1b31 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/loop_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/loop_gpu.cpp @@ -10,7 +10,6 @@ #include "register_gpu.hpp" #include "mutable_data_inst.h" #include "input_layout_inst.h" -#include "memory_impl.h" #include #include @@ -18,32 +17,38 @@ namespace cldnn { namespace gpu { struct loop_gpu : typed_primitive_impl { const loop_node& node; + std::unique_ptr clone() const override { + return make_unique(*this); + } + + void init_kernels() override {} + loop_gpu(const loop_gpu& other) : typed_primitive_impl(other), node(other.node) {} explicit loop_gpu(const loop_node& node) : node(node) {} // read scala value from data primitive - static int64_t read_scalar_value(memory_impl& mem) { + static int64_t read_scalar_value(memory::ptr mem, stream& stream) { int64_t trip_count = 0; - const layout& prim_layout = mem.get_layout(); + const layout& prim_layout = mem->get_layout(); switch (prim_layout.data_type) { case data_types::u8: { - mem_lock lock_prim_output{mem}; + mem_lock lock_prim_output{mem, stream}; trip_count = *lock_prim_output.data(); break; } case data_types::i8: { - mem_lock lock_prim_output{mem}; + mem_lock lock_prim_output{mem, stream}; trip_count = *lock_prim_output.data(); break; } case data_types::i32: { - mem_lock lock_prim_output{mem}; + mem_lock lock_prim_output{mem, stream}; trip_count = *lock_prim_output.data(); break; } case data_types::i64: { - mem_lock lock_prim_output{mem}; + mem_lock lock_prim_output{mem, stream}; trip_count = *lock_prim_output.data(); break; } @@ -53,33 +58,33 @@ struct loop_gpu : typed_primitive_impl { return trip_count; } - static void write_scalar_value(memory_impl& mem, int64_t input) { - const layout& prim_layout = mem.get_layout(); + static void write_scalar_value(memory::ptr mem, stream& stream, int64_t input) { + const layout& prim_layout = mem->get_layout(); switch (prim_layout.data_type) { case data_types::u8: { assert(input >= std::numeric_limits::min() && input <= std::numeric_limits::max()); - mem_lock lock_prim_output{mem}; + mem_lock lock_prim_output{mem, stream}; *lock_prim_output.data() = static_cast(input); break; } case data_types::i8: { assert(input >= std::numeric_limits::min() && input <= std::numeric_limits::max()); - mem_lock lock_prim_output{mem}; + mem_lock lock_prim_output{mem, stream}; *lock_prim_output.data() = static_cast(input); break; } case data_types::i32: { assert(input >= std::numeric_limits::min() && input <= std::numeric_limits::max()); - mem_lock lock_prim_output{mem}; + mem_lock lock_prim_output{mem, stream}; *lock_prim_output.data() = static_cast(input); break; } case data_types::i64: { - mem_lock lock_prim_output{mem}; + mem_lock lock_prim_output{mem, stream}; *lock_prim_output.data() = input; break; } @@ -88,10 +93,9 @@ struct loop_gpu : typed_primitive_impl { } } - event_impl::ptr execute_impl(const std::vector& events, loop_inst& instance) override { + event::ptr execute_impl(const std::vector& events, loop_inst& instance) override { auto& outer_network = instance.get_network(); - const uint32_t& net_id = instance.get_network().get_id(); - auto ev = outer_network.get_engine().create_user_event(net_id, false); + auto& stream = outer_network.get_stream(); auto body_network = instance.get_body_network(); @@ -104,8 +108,8 @@ struct loop_gpu : typed_primitive_impl { // read trip_count from outer network const primitive_id& trip_count_id = node.get_trip_count_id(); - memory_impl& trip_count_mem = outer_network.get_primitive(trip_count_id)->output_memory(); - int64_t trip_count = read_scalar_value(trip_count_mem); + memory::ptr trip_count_mem = outer_network.get_primitive(trip_count_id)->output_memory_ptr(); + int64_t trip_count = read_scalar_value(trip_count_mem, stream); if (trip_count < 0) { const int64_t max_iteration = node.get_max_iteration(); trip_count = max_iteration; @@ -113,26 +117,26 @@ struct loop_gpu : typed_primitive_impl { // read initial execution condition from outer network const primitive_id& initial_execution_id = node.get_initial_execution_id(); - memory_impl& initial_execution_mem = outer_network.get_primitive(initial_execution_id)->output_memory(); - int64_t execution_condition = read_scalar_value(initial_execution_mem); + memory::ptr initial_execution_mem = outer_network.get_primitive(initial_execution_id)->output_memory_ptr(); + int64_t execution_condition = read_scalar_value(initial_execution_mem, stream); // shortcut of current_iteration memory in body network (slice of input) - memory_impl* current_iteration_mem = nullptr; + memory::ptr current_iteration_mem = nullptr; if (node.is_current_iteration_used()) { const primitive_id& current_iteration_id = node.get_current_iteration_id(); - current_iteration_mem = &body_network->get_primitive(current_iteration_id)->output_memory(); + current_iteration_mem = body_network->get_primitive(current_iteration_id)->output_memory_ptr(); } // shortcut of execution_condition memory in body network - memory_impl* execution_condition_mem = nullptr; + memory::ptr execution_condition_mem = nullptr; if (node.is_execution_condition_used()) { const primitive_id& condition_id = node.get_condition_id(); - execution_condition_mem = &body_network->get_primitive(condition_id)->output_memory(); + execution_condition_mem = body_network->get_primitive(condition_id)->output_memory_ptr(); } int64_t current_iteration = 0; if (node.is_current_iteration_used()) { - write_scalar_value(*current_iteration_mem, current_iteration); + write_scalar_value(current_iteration_mem, stream, current_iteration); } const auto& concatenated_input_mem_mappings = instance.concatenated_input_mem_mappings; @@ -141,23 +145,23 @@ struct loop_gpu : typed_primitive_impl { // Set sliced input data for (size_t i = 0; i < concatenated_input_mem_mappings.size(); ++i) { const auto& concatenated_input = concatenated_input_mem_mappings.at(i); - memory_impl::ptr mem = concatenated_input.get_sliced_mem(0); + memory::ptr mem = concatenated_input.get_sliced_mem(0); if (mem) { - body_network->set_input_data(concatenated_input.sliced_data_prim->id(), *mem); + body_network->set_input_data(concatenated_input.sliced_data_prim->id(), mem); } else { CLDNN_ERROR_MESSAGE(node.id(), "sliced input memory of loop is not allocated properly"); } } - std::vector loop_carried_dep(events.begin(), events.end()); + std::vector loop_carried_dep(events.begin(), events.end()); while (current_iteration < trip_count && execution_condition) { // Copy & Set sliced input memory for (size_t i = 0; i < concatenated_input_mem_mappings.size(); ++i) { const auto& concatenated_input = concatenated_input_mem_mappings.at(i); - memory_impl::ptr mem = concatenated_input.get_sliced_mem(current_iteration); + memory::ptr mem = concatenated_input.get_sliced_mem(current_iteration); if (mem) { - concatenated_input.sliced_data_prim->set_output_memory(*mem); + concatenated_input.sliced_data_prim->set_output_memory(mem); } else { CLDNN_ERROR_MESSAGE(node.id(), "sliced input memory of loop is not allocated properly"); } @@ -178,7 +182,7 @@ struct loop_gpu : typed_primitive_impl { loop_carried_dep.clear(); for (const auto& backedge : node.get_back_edges()) { - event_impl::ptr body_event = body_network->get_primitive_event(backedge.from); + event::ptr body_event = body_network->get_primitive_event(backedge.from); loop_carried_dep.emplace_back(body_event); } @@ -186,10 +190,10 @@ struct loop_gpu : typed_primitive_impl { //as they are presented in the ngraph opset document for loop operation. //However they are not being used yet and only TensorIterator which has fixed sequence length is being validated. if (node.is_current_iteration_used()) { - write_scalar_value(*current_iteration_mem, current_iteration); + write_scalar_value(current_iteration_mem, stream, current_iteration); } if (node.is_execution_condition_used()) { - execution_condition = read_scalar_value(*execution_condition_mem); + execution_condition = read_scalar_value(execution_condition_mem, stream); } // update index & execution condition for the next iteration ++current_iteration; @@ -204,11 +208,10 @@ struct loop_gpu : typed_primitive_impl { } const primitive_id& num_iteration_id = node.get_num_iteration_id(); - memory_impl& num_actual_iterations_mem = outer_network.get_primitive(num_iteration_id)->output_memory(); - write_scalar_value(num_actual_iterations_mem, current_iteration); + memory::ptr num_actual_iterations_mem = outer_network.get_primitive(num_iteration_id)->output_memory_ptr(); + write_scalar_value(num_actual_iterations_mem, stream, current_iteration); - dynamic_cast(ev.get())->set(); - return ev; + return stream.create_user_event(true); } static primitive_impl* create(const loop_node& arg) { return new loop_gpu(arg); } diff --git a/inference-engine/thirdparty/clDNN/src/gpu/lrn_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/lrn_gpu.cpp index c12c07aad6753d..b829688a736e8d 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/lrn_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/lrn_gpu.cpp @@ -5,7 +5,7 @@ #include "lrn_inst.h" #include "primitive_gpu_base.h" #include "implementation_map.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_selector_helper.h" #include "lrn/lrn_kernel_selector.h" #include "lrn/lrn_kernel_base.h" @@ -17,6 +17,10 @@ struct lrn_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + static primitive_impl* create(const lrn_node& arg) { auto lrn_params = get_default_params(arg); auto lrn_optional_params = get_default_optional_params(arg.get_program()); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/lstm_dynamic_input_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/lstm_dynamic_input_gpu.cpp index 30640edd24e06a..4a8a4ee5d75b94 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/lstm_dynamic_input_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/lstm_dynamic_input_gpu.cpp @@ -11,7 +11,7 @@ #include "lstm_dynamic/lstm_dynamic_input_kernel_selector.h" #include "lstm_dynamic/lstm_dynamic_input_kernel_base.h" #include "network_impl.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" namespace cldnn { namespace gpu { @@ -20,14 +20,17 @@ struct lstm_dynamic_input_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + protected: - kernel::kernel_arguments_data get_arguments(typed_primitive_inst& instance, - int32_t) const override { - kernel::kernel_arguments_data args; - args.inputs = { (memory_impl::cptr) &instance.input_memory(), (memory_impl::cptr) &instance.dyn_length_memory()}; - args.output = (memory_impl::cptr) &instance.output_memory(); - args.weights = (memory_impl::cptr) &instance.weights_memory(); - args.bias = (memory_impl::cptr) (instance.bias_term() ? &instance.bias_memory() : nullptr); + kernel_arguments_data get_arguments(typed_primitive_inst& instance, int32_t) const override { + kernel_arguments_data args; + args.inputs = { instance.input_memory_ptr(), instance.dyn_length_memory()}; + args.output = instance.output_memory_ptr(); + args.weights = instance.weights_memory(); + args.bias = instance.bias_term() ? instance.bias_memory() : nullptr; return args; } diff --git a/inference-engine/thirdparty/clDNN/src/gpu/lstm_dynamic_timeloop_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/lstm_dynamic_timeloop_gpu.cpp index bbacc878735fa9..9c367d5d994a5d 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/lstm_dynamic_timeloop_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/lstm_dynamic_timeloop_gpu.cpp @@ -11,7 +11,7 @@ #include "lstm_dynamic/lstm_dynamic_timeloop_kernel_selector.h" #include "lstm_dynamic/lstm_dynamic_timeloop_kernel_base.h" #include "network_impl.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" namespace cldnn { namespace gpu { @@ -20,19 +20,22 @@ struct lstm_dynamic_timeloop_gpu : typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + protected: - kernel::kernel_arguments_data get_arguments(typed_primitive_inst& instance, - int32_t) const override { - kernel::kernel_arguments_data args; - args.inputs = {(memory_impl::cptr) &instance.input_memory(), (memory_impl::cptr) &instance.dyn_length_memory()}; + kernel_arguments_data get_arguments(typed_primitive_inst& instance, int32_t) const override { + kernel_arguments_data args; + args.inputs = {instance.input_memory_ptr(), instance.dyn_length_memory()}; if (instance.last_hidden_output_term()) - args.inputs.push_back((memory_impl::cptr) &instance.last_hidden_output_memory()); + args.inputs.push_back(instance.last_hidden_output_memory()); if (instance.last_cell_output_term()) - args.inputs.push_back((memory_impl::cptr) &instance.last_cell_output_memory()); - args.output = (memory_impl::cptr) &instance.output_memory(); - args.recurrent = (memory_impl::cptr) &instance.recurrent_memory(); - args.hidden = (memory_impl::cptr) (instance.initial_hidden_term() ? &instance.initial_hidden_memory() : nullptr); - args.cell = (memory_impl::cptr) (instance.initial_cell_term() ? &instance.initial_cell_memory() : nullptr); + args.inputs.push_back(instance.last_cell_output_memory()); + args.output = instance.output_memory_ptr(); + args.recurrent = instance.recurrent_memory(); + args.hidden = instance.initial_hidden_term() ? instance.initial_hidden_memory() : nullptr; + args.cell = instance.initial_cell_term() ? instance.initial_cell_memory() : nullptr; return args; } diff --git a/inference-engine/thirdparty/clDNN/src/gpu/lstm_elt_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/lstm_elt_gpu.cpp index b4a45bfe41500c..ed558133306753 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/lstm_elt_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/lstm_elt_gpu.cpp @@ -11,7 +11,7 @@ #include "lstm/lstm_elt_kernel_selector.h" #include "lstm/lstm_elt_kernel_base.h" #include "network_impl.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" namespace cldnn { namespace gpu { @@ -20,13 +20,16 @@ struct lstm_elt_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + protected: - kernel::kernel_arguments_data get_arguments(typed_primitive_inst& instance, - int32_t) const override { - kernel::kernel_arguments_data args = parent::get_arguments(instance, 0); + kernel_arguments_data get_arguments(typed_primitive_inst& instance, int32_t) const override { + kernel_arguments_data args = parent::get_arguments(instance, 0); - args.cell = (memory_impl::cptr) (instance.cell_term() ? &instance.cell_memory() : nullptr); - args.output = (memory_impl::cptr) &instance.output_memory(); + args.cell = instance.cell_term() ? instance.cell_memory() : nullptr; + args.output = instance.output_memory_ptr(); return args; } diff --git a/inference-engine/thirdparty/clDNN/src/gpu/lstm_gemm_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/lstm_gemm_gpu.cpp index 2b27aee688ee99..f6c532decd08c6 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/lstm_gemm_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/lstm_gemm_gpu.cpp @@ -11,7 +11,7 @@ #include "lstm/lstm_gemm_kernel_selector.h" #include "lstm/lstm_gemm_kernel_base.h" #include "network_impl.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" namespace cldnn { namespace gpu { @@ -20,16 +20,19 @@ struct lstm_gemm_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + protected: - kernel::kernel_arguments_data get_arguments(typed_primitive_inst& instance, - int32_t) const override { - kernel::kernel_arguments_data args = parent::get_arguments(instance, 0); - - args.output = (memory_impl::cptr) &instance.output_memory(); - args.weights = (memory_impl::cptr) &instance.weights_memory(); - args.recurrent = (memory_impl::cptr) &instance.recurrent_memory(); - args.bias = (memory_impl::cptr) (instance.bias_term() ? &instance.bias_memory() : nullptr); - args.hidden = (memory_impl::cptr) (instance.hidden_term() ? &instance.hidden_memory() : nullptr); + kernel_arguments_data get_arguments(typed_primitive_inst& instance, int32_t) const override { + kernel_arguments_data args = parent::get_arguments(instance, 0); + + args.output = instance.output_memory_ptr(); + args.weights = instance.weights_memory(); + args.recurrent = instance.recurrent_memory(); + args.bias = instance.bias_term() ? instance.bias_memory() : nullptr; + args.hidden = instance.hidden_term() ? instance.hidden_memory() : nullptr; return args; } diff --git a/inference-engine/thirdparty/clDNN/src/gpu/max_unpooling_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/max_unpooling_gpu.cpp index 7e903fc65b0fdd..2daaaa0ddc2579 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/max_unpooling_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/max_unpooling_gpu.cpp @@ -5,7 +5,7 @@ #include "max_unpooling_inst.h" #include "primitive_gpu_base.h" #include "implementation_map.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "network_impl.h" #include "kernel_selector_helper.h" #include "max_unpooling/max_unpooling_kernel_selector.h" @@ -19,20 +19,23 @@ struct max_unpooling_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + protected: - kernel::kernel_arguments_data get_arguments(typed_primitive_inst& instance, - int32_t split) const override { - kernel::kernel_arguments_data args = parent::get_arguments(instance, split); - args.inputs.push_back((memory_impl::cptr) &instance.dep_memory(1)); + kernel_arguments_data get_arguments(typed_primitive_inst& instance, int32_t split) const override { + kernel_arguments_data args = parent::get_arguments(instance, split); + args.inputs.push_back(instance.dep_memory_ptr(1)); return args; } public: - event_impl::ptr execute_impl(const std::vector& events, max_unpooling_inst& instance) override { + event::ptr execute_impl(const std::vector& events, max_unpooling_inst& instance) override { // clear output buffer - std::vector tmp_events(events); - auto ev = instance.get_network().get_engine().create_user_event(instance.get_network().get_id(), false); - instance.output_memory().fill(0, ev); + std::vector tmp_events(events); + auto& stream = instance.get_network().get_stream(); + auto ev = instance.output_memory().fill(stream); tmp_events.push_back(ev); return parent::execute_impl(tmp_events, instance); } diff --git a/inference-engine/thirdparty/clDNN/src/gpu/memory_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/memory_gpu.cpp deleted file mode 100644 index 5a839905ac38c3..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/gpu/memory_gpu.cpp +++ /dev/null @@ -1,310 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include "error_handler.h" -#include "memory_gpu.h" -#include "engine_impl.h" -#include "ocl_base_event.h" -#include -#include - -namespace cldnn { -namespace gpu { - -gpu_buffer::gpu_buffer(const refcounted_obj_ptr& engine, - const layout& layout, - uint32_t net_id, - bool reset) - : lockable_gpu_mem(engine), memory_impl(engine, layout, net_id, allocation_type::cl_mem, false), - _buffer(_context->context(), CL_MEM_READ_WRITE, size()) { - if (reset || is_memory_reset_needed(_layout)) zero_buffer(); -} - -gpu_buffer::gpu_buffer(const refcounted_obj_ptr& engine, - const layout& new_layout, - const cl::Buffer& buffer, - uint32_t net_id) - : lockable_gpu_mem(engine), memory_impl(engine, new_layout, net_id, allocation_type::cl_mem, true), - _buffer(buffer) {} - -void* gpu_buffer::lock() { - std::lock_guard locker(_mutex); - if (0 == _lock_count) { - _mapped_ptr = _context->queue(_net_id).enqueueMapBuffer(_buffer, CL_TRUE, CL_MAP_WRITE, 0, size()); - } - _lock_count++; - return _mapped_ptr; -} - -void gpu_buffer::unlock() { - std::lock_guard locker(_mutex); - _lock_count--; - if (0 == _lock_count) { - _context->queue(_net_id).enqueueUnmapMemObject(_buffer, _mapped_ptr); - _mapped_ptr = nullptr; - } -} - -void gpu_buffer::zero_buffer() { - _context->queue(_net_id).enqueueFillBuffer(_buffer, 0, 0, size()); - _context->queue(_net_id).flush(); -} - -void gpu_buffer::fill(unsigned char pattern, event_impl::ptr ev) { - cl::Event ev_ocl = dynamic_cast(ev.get())->get(); - _context->queue(_net_id).enqueueFillBuffer(_buffer, pattern, 0, size(), 0, &ev_ocl); -} - -shared_mem_params gpu_buffer::get_internal_params() const { - return {shared_mem_type::shared_mem_buffer, static_cast(_context->context().get()), nullptr, - static_cast(_buffer.get()), -#ifdef _WIN32 - nullptr, -#else - 0, -#endif - 0}; -} - -gpu_image2d::gpu_image2d(const refcounted_obj_ptr& engine, const layout& layout, uint32_t net_id, - bool reset) - : lockable_gpu_mem(engine), memory_impl(engine, layout, net_id, allocation_type::cl_mem, false), - _row_pitch(0), _slice_pitch(0) { - cl_channel_type type = layout.data_type == data_types::f16 ? CL_HALF_FLOAT : CL_FLOAT; - cl_channel_order order = CL_R; - switch (layout.format) { - case format::image_2d_weights_c1_b_fyx: - _width = layout.size.batch[0]; - _height = layout.size.spatial[0] * layout.size.feature[0] * layout.size.spatial[1]; - break; - case format::image_2d_weights_winograd_6x3_s1_fbxyb: - _height = layout.size.feature[0]; - _width = layout.size.spatial[0] * layout.size.batch[0] * layout.size.spatial[1] * 8 / 3; - break; - case format::image_2d_weights_winograd_6x3_s1_xfbyb: - _height = layout.size.feature[0] * layout.size.spatial[0] * 8 / 3; - _width = layout.size.batch[0] * layout.size.spatial[1]; - break; - case format::image_2d_weights_c4_fyx_b: - _width = layout.size.batch[0]; - _height = layout.size.spatial[0] * layout.size.feature[0] * layout.size.spatial[1]; - order = CL_RGBA; - break; - case format::image_2d_rgba: - _width = layout.size.spatial[0]; - _height = layout.size.spatial[1]; - order = CL_RGBA; - if (layout.size.feature[0] != 3 && layout.size.feature[0] != 4) { - CLDNN_ERROR_MESSAGE("2D image allocation", "invalid number of channels in image_2d_rgba input image (should be 3 or 4)!"); - } - type = CL_UNORM_INT8; - break; - case format::nv12: - _width = layout.size.spatial[1]; - _height = layout.size.spatial[0]; - if (layout.size.feature[0] == 2) { - order = CL_RG; - } else if (layout.size.feature[0] > 2) { - CLDNN_ERROR_MESSAGE("2D image allocation", "invalid number of channels in NV12 input image!"); - } - type = CL_UNORM_INT8; - break; - default: - CLDNN_ERROR_MESSAGE("2D image allocation", "unsupported image type!"); - } - - cl::ImageFormat imageFormat(order, type); - _buffer = cl::Image2D(_context->context(), CL_MEM_READ_WRITE, imageFormat, _width, _height, 0); - - if (reset) zero_image(); -} - -gpu_image2d::gpu_image2d(const refcounted_obj_ptr& engine, - const layout& new_layout, - const cl::Image2D& buffer, - uint32_t net_id) - : lockable_gpu_mem(engine), memory_impl(engine, new_layout, net_id, allocation_type::cl_mem, true), - _buffer(buffer) { - _width = _buffer.getImageInfo(); - _height = _buffer.getImageInfo(); - _row_pitch = _buffer.getImageInfo(); - _slice_pitch = _buffer.getImageInfo(); -} - -void gpu_image2d::zero_image() { - cl_uint4 pattern_uint4 = { 0, 0, 0, 0 }; - _context->queue(_net_id).enqueueFillImage(_buffer, pattern_uint4, { 0, 0, 0 }, { _width, _height, 1 }); - _context->queue(_net_id).flush(); -} - -void* gpu_image2d::lock() { - std::lock_guard locker(_mutex); - if (0 == _lock_count) { - _mapped_ptr = _context->queue(_net_id) - .enqueueMapImage(_buffer, - CL_TRUE, - CL_MAP_WRITE, - {0, 0, 0}, - {_width, _height, 1}, - &_row_pitch, - &_slice_pitch); - } - _lock_count++; - return _mapped_ptr; -} - -void gpu_image2d::unlock() { - std::lock_guard locker(_mutex); - _lock_count--; - if (0 == _lock_count) { - _context->queue(_net_id).enqueueUnmapMemObject(_buffer, _mapped_ptr); - _mapped_ptr = nullptr; - } -} - -void gpu_image2d::fill(unsigned char pattern, event_impl::ptr ev) { - cl::Event ev_ocl = dynamic_cast(ev.get())->get(); - cl_uint4 pattern_uint4 = {pattern, pattern, pattern, pattern}; - _context->queue(_net_id).enqueueFillImage(_buffer, pattern_uint4, {0, 0, 0}, {_width, _height, 1}, 0, &ev_ocl); -} - -shared_mem_params gpu_image2d::get_internal_params() const { - return {shared_mem_type::shared_mem_image, static_cast(_context->context().get()), nullptr, - static_cast(_buffer.get()), -#ifdef _WIN32 - nullptr, -#else - 0, -#endif - 0}; -} - -gpu_media_buffer::gpu_media_buffer(const refcounted_obj_ptr& engine, - const layout& new_layout, - const shared_mem_params* params, - uint32_t net_id) - : gpu_image2d(engine, new_layout, - cl::ImageVA(engine->get_context()->context(), CL_MEM_READ_WRITE, - params->surface, params->plane), - net_id), - device(params->user_device), - surface(params->surface), - plane(params->plane) { -} - -shared_mem_params gpu_media_buffer::get_internal_params() const { - return {shared_mem_type::shared_mem_vasurface, static_cast(_context->context().get()), device, - static_cast(_buffer.get()), surface, plane }; -} - -#ifdef _WIN32 -gpu_dx_buffer::gpu_dx_buffer(const refcounted_obj_ptr& engine, - const layout& new_layout, - const shared_mem_params* params, - uint32_t net_id) - : gpu_buffer(engine, new_layout, - cl::BufferDX(engine->get_context()->context(), CL_MEM_READ_WRITE, params->mem), - net_id), - device(params->user_device), - resource(params->mem) { } - -shared_mem_params gpu_dx_buffer::get_internal_params() const { - return {shared_mem_type::shared_mem_dxbuffer, static_cast(_context->context().get()), device, - static_cast(_buffer.get()), resource, 0 }; -} -#endif - -gpu_usm::gpu_usm(const refcounted_obj_ptr& engine, - const layout& new_layout, const cl::UsmMemory& buffer, - allocation_type type, uint32_t net_id) - : lockable_gpu_mem(engine) - , memory_impl(engine, new_layout, net_id, type, true) - , _buffer(buffer) { -} - -gpu_usm::gpu_usm(const refcounted_obj_ptr& engine, const layout& layout, uint32_t net_id, allocation_type type, bool reset) - : lockable_gpu_mem(engine) - , memory_impl(engine, layout, net_id, type, false) - , _buffer(_engine->get_context()->context()) { - auto device = _engine->get_context()->device(); - switch (get_allocation_type()) { - case allocation_type::usm_host: - _buffer.allocateHost(_bytes_count); - break; - case allocation_type::usm_shared: - _buffer.allocateShared(device, _bytes_count); - break; - case allocation_type::usm_device: - _buffer.allocateDevice(device, _bytes_count); - break; - default: - CLDNN_ERROR_MESSAGE("gpu_usm allocation type", - "Unknown unified shared memory type!"); - } - - if (reset || is_memory_reset_needed(_layout)) zero_buffer(); -} - -void* gpu_usm::lock() { - assert(get_allocation_type() != allocation_type::usm_device && "Can't lock usm device memory!"); - std::lock_guard locker(_mutex); - if (0 == _lock_count) { - _engine->get_context()->queue(_net_id).finish(); // Synchronization needed for OOOQ. - _mapped_ptr = _buffer.get(); - } - _lock_count++; - return _mapped_ptr; -} - -void gpu_usm::unlock() { - std::lock_guard locker(_mutex); - _lock_count--; - if (0 == _lock_count) { - _mapped_ptr = nullptr; - } -} - -void gpu_usm::fill(unsigned char pattern, event_impl::ptr ev) { - cl::Event ev_ocl = dynamic_cast(ev.get())->get(); - // enqueueFillUsm call will never finish. Driver bug? Uncomment when fixed. Some older drivers doesn't support enqueueFillUsm call at all. - // _engine->get_context()->queue(_net_id).enqueueFillUsm(_buffer, pattern, _bytes_count, nullptr, &ev_ocl) - // Workarounded with enqeue_memcopy. ToDo: Remove below code. Uncomment above. - std::vector temp_buffer(_bytes_count, pattern); - cl::usm::enqueue_memcpy(_engine->get_context()->queue(_net_id), _buffer.get(), temp_buffer.data(), _bytes_count, true, nullptr, &ev_ocl); -} - -void gpu_usm::zero_buffer() { - // event_impl::ptr ev{ new base_event(_engine->get_context()), false }; - // cl::Event ev_ocl = dynamic_cast(ev.get())->get(); - // cl::usm::enqueue_set_mem(_engine->get_context()->queue(_net_id), _buffer.get(), 0, _bytes_count, nullptr, &ev_ocl); - // ev->wait(); - - // [WA] - event_impl::ptr ev{ new base_event(_engine->get_context()), false }; - fill(0, ev); - ev->wait(); -} - -void gpu_usm::copy_from_other(const gpu_usm& other) { - _engine->get_context()->queue(_net_id).enqueueCopyUsm(other.get_buffer(), get_buffer(), _bytes_count, true); -} - -shared_mem_params gpu_usm::get_internal_params() const { - return { - shared_mem_type::shared_mem_empty, // shared_mem_type - static_cast(_engine->get_context()->context().get()), // context handle - nullptr, // user_device handle - nullptr, // mem handle -#ifdef _WIN32 - nullptr, // surface handle -#else - 0, // surface handle -#endif - 0 // plane - }; -} - -} // namespace gpu -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/memory_gpu.h b/inference-engine/thirdparty/clDNN/src/gpu/memory_gpu.h deleted file mode 100644 index e1ac301f997c55..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/gpu/memory_gpu.h +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma once -#include "ocl_toolkit.h" -#include "memory_impl.h" -#include -#include -#include -#include - -#define BUFFER_ALIGNMENT 4096 -#define CACHE_ALIGNMENT 64 - -namespace cldnn { -namespace gpu { - -template -T* allocate_aligned(size_t size, size_t align) { - assert(sizeof(T) <= size); - assert(alignof(T) <= align); - return reinterpret_cast(_mm_malloc(align_to(size, align), align)); -} - -template -void deallocate_aligned(T* ptr) { - _mm_free(ptr); -} - -#if defined(_SECURE_SCL) && (_SECURE_SCL > 0) -template -stdext::checked_array_iterator arr_begin(T* buf, size_t count) { - return stdext::make_checked_array_iterator(buf, count); -} - -template -stdext::checked_array_iterator arr_end(T* buf, size_t count) { - return stdext::make_checked_array_iterator(buf, count, count); -} - -#else -template -T* arr_begin(T* buf, size_t) { - return buf; -} - -template -T* arr_end(T* buf, size_t count) { - return buf + count; -} -#endif - -struct lockable_gpu_mem { - explicit lockable_gpu_mem(const refcounted_obj_ptr& engine) : _context(engine->get_context()), - _lock_count(0), - _mapped_ptr(nullptr) {} - - std::shared_ptr _context; - std::mutex _mutex; - unsigned _lock_count; - void* _mapped_ptr; -}; - -struct gpu_buffer : public lockable_gpu_mem, public memory_impl { - friend cldnn::memory_pool; - - gpu_buffer(const refcounted_obj_ptr& engine, - const layout& new_layout, - const cl::Buffer& buffer, - uint32_t net_id); - - void* lock() override; - void unlock() override; - void fill(unsigned char pattern, event_impl::ptr ev) override; - shared_mem_params get_internal_params() const override; - const cl::Buffer& get_buffer() const { - assert(0 == _lock_count); - return _buffer; - } - - void zero_buffer(); - -protected: - gpu_buffer(const refcounted_obj_ptr& engine, const layout& layout, uint32_t net_id, - bool reset = true); - cl::Buffer _buffer; -}; - -struct gpu_image2d : public lockable_gpu_mem, public memory_impl { - friend cldnn::memory_pool; - - gpu_image2d(const refcounted_obj_ptr& engine, - const layout& new_layout, - const cl::Image2D& buffer, - uint32_t net_id); - void* lock() override; - void unlock() override; - void fill(unsigned char pattern, event_impl::ptr ev) override; - shared_mem_params get_internal_params() const override; - const cl::Image2D& get_buffer() const { - assert(0 == _lock_count); - return _buffer; - } - - void zero_image(); - -protected: - gpu_image2d(const refcounted_obj_ptr& engine, const layout& layout, uint32_t net_id, - bool reset = true); - - cl::Image2D _buffer; - size_t _width; - size_t _height; - size_t _row_pitch; - size_t _slice_pitch; -}; - -struct gpu_media_buffer : public gpu_image2d { - friend cldnn::memory_pool; - - gpu_media_buffer(const refcounted_obj_ptr& engine, - const layout& new_layout, - const shared_mem_params* params, - uint32_t net_id); - shared_mem_params get_internal_params() const override; -private: - void* device; -#ifdef _WIN32 - void* surface; -#else - uint32_t surface; -#endif - uint32_t plane; -}; - -#ifdef _WIN32 -struct gpu_dx_buffer : public gpu_buffer { - friend cldnn::memory_pool; - - gpu_dx_buffer(const refcounted_obj_ptr& engine, - const layout& new_layout, - const shared_mem_params* params, - uint32_t net_id); - shared_mem_params get_internal_params() const override; -private: - void* device; - void* resource; -}; -#endif - -struct gpu_usm : public lockable_gpu_mem, public memory_impl { - friend cldnn::memory_pool; - - gpu_usm(const refcounted_obj_ptr& engine, - const layout& new_layout, - const cl::UsmMemory& usm_buffer, - allocation_type type, - uint32_t net_id); - - void* lock() override; - void unlock() override; - const cl::UsmMemory& get_buffer() const { return _buffer; } - cl::UsmMemory& get_buffer() { return _buffer; } - - void fill(unsigned char pattern, event_impl::ptr ev) override; - void zero_buffer(); - void copy_from_other(const gpu_usm& other); - shared_mem_params get_internal_params() const override; -protected: - gpu_usm(const refcounted_obj_ptr& engine, const layout& layout, uint32_t net_id, allocation_type type, bool reset = true); - cl::UsmMemory _buffer; -}; -} // namespace gpu -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/mutable_data_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/mutable_data_gpu.cpp index 0b2285af85915d..24a716b5dbe0b2 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/mutable_data_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/mutable_data_gpu.cpp @@ -13,17 +13,11 @@ struct mutable_data_gpu : public typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; -public: - bool validate_impl(const typed_primitive_inst& instance) const override { - bool is_primary = instance.get_network().is_primary_stream(); - - auto net_id = instance.get_network().get_id(); - auto mem_net_id = instance.output_memory().get_net_id(); - - bool res = is_primary || net_id == mem_net_id; - return res; + std::unique_ptr clone() const override { + return make_unique(*this); } +public: static primitive_impl* create(mutable_data_node const& arg) { return new mutable_data_gpu(arg, {}); } }; diff --git a/inference-engine/thirdparty/clDNN/src/gpu/mvn_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/mvn_gpu.cpp index d2b839e7a9de6a..fc06edd6312db5 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/mvn_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/mvn_gpu.cpp @@ -5,7 +5,7 @@ #include "mvn_inst.h" #include "primitive_gpu_base.h" #include "implementation_map.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_selector_helper.h" #include "mvn/mvn_kernel_selector.h" #include "mvn/mvn_kernel_base.h" @@ -21,6 +21,10 @@ struct mvn_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + public: static primitive_impl* create(const mvn_node& arg) { auto mvn_params = get_default_params(arg); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/non_max_suppression_cpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/non_max_suppression_cpu.cpp index bcb8f006c3a565..55004113150bd6 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/non_max_suppression_cpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/non_max_suppression_cpu.cpp @@ -110,14 +110,14 @@ std::vector run_nms( } template -vector2D load_boxes_impl(memory_impl& mem, bool center_point) { +vector2D load_boxes_impl(stream& stream, memory::ptr mem, bool center_point) { vector2D result; - auto lay = mem.get_layout(); + auto lay = mem->get_layout(); auto batch_size = lay.size.batch[0]; auto boxes_num = lay.size.feature[0]; result.resize(batch_size); - mem_lock boxes_lock(mem); + mem_lock boxes_lock(mem, stream); auto ptr = boxes_lock.data(); for (int bi = 0; bi < batch_size; ++bi) { @@ -145,28 +145,28 @@ vector2D load_boxes_impl(memory_impl& mem, bool center_point) { return result; } -vector2D load_boxes(memory_impl& mem, bool center_point) { - auto data_type = mem.get_layout().data_type; +vector2D load_boxes(stream& stream, memory::ptr mem, bool center_point) { + auto data_type = mem->get_layout().data_type; switch (data_type) { case cldnn::data_types::f16: - return load_boxes_impl::type>(mem, center_point); + return load_boxes_impl::type>(stream, mem, center_point); case cldnn::data_types::f32: - return load_boxes_impl::type>(mem, center_point); + return load_boxes_impl::type>(stream, mem, center_point); default: throw std::runtime_error("Non max supression - unsupported boxes data type"); } } template -vector3D load_scores_impl(memory_impl& mem) { - auto lay = mem.get_layout(); +vector3D load_scores_impl(stream& stream, memory::ptr mem) { + auto lay = mem->get_layout(); auto batch_size = lay.size.batch[0]; auto classes_num = lay.size.feature[0]; auto boxes_num = lay.size.spatial[1]; vector3D result(batch_size, vector2D(classes_num)); - mem_lock lock(mem); + mem_lock lock(mem, stream); auto ptr = lock.data(); for (int bi = 0; bi < batch_size; ++bi) { @@ -182,47 +182,47 @@ vector3D load_scores_impl(memory_impl& mem) { return result; } -vector3D load_scores(memory_impl& mem) { - auto data_type = mem.get_layout().data_type; +vector3D load_scores(stream& stream, memory::ptr mem) { + auto data_type = mem->get_layout().data_type; switch (data_type) { case cldnn::data_types::f16: - return load_scores_impl::type>(mem); + return load_scores_impl::type>(stream, mem); case cldnn::data_types::f32: - return load_scores_impl::type>(mem); + return load_scores_impl::type>(stream, mem); default: throw std::runtime_error("Non max supression - unsupported scores data type"); } } template -T load_scalar_impl(memory_impl& mem) { - mem_lock lock(mem); +T load_scalar_impl(stream& stream, memory::ptr mem) { + mem_lock lock(mem, stream); auto ptr = lock.data(); return static_cast(ptr[0]); } template -T load_scalar(memory_impl& mem) { - auto data_type = mem.get_layout().data_type; +T load_scalar(stream& stream, memory::ptr mem) { + auto data_type = mem->get_layout().data_type; switch (data_type) { case cldnn::data_types::i32: - return load_scalar_impl::type>(mem); + return load_scalar_impl::type>(stream, mem); case cldnn::data_types::f16: - return load_scalar_impl::type>(mem); + return load_scalar_impl::type>(stream, mem); case cldnn::data_types::f32: - return load_scalar_impl::type>(mem); + return load_scalar_impl::type>(stream, mem); default: throw std::runtime_error("Non max supression - unsupported data type"); } } template -void store_result_impl(memory_impl& mem, const std::vector& result) { - mem_lock lock(mem); +void store_result_impl(stream& stream, memory::ptr mem, const std::vector& result) { + mem_lock lock(mem, stream); auto ptr = lock.data(); - auto output_size = static_cast(mem.get_layout().size.batch[0]); + auto output_size = static_cast(mem->get_layout().size.batch[0]); auto results_size = result.size(); size_t si = 0; @@ -240,31 +240,31 @@ void store_result_impl(memory_impl& mem, const std::vector& resu } } -void store_result(memory_impl& mem, const std::vector& result) { - auto data_type = mem.get_layout().data_type; +void store_result(stream& stream, memory::ptr mem, const std::vector& result) { + auto data_type = mem->get_layout().data_type; switch (data_type) { case cldnn::data_types::i32: - store_result_impl::type>(mem, result); + store_result_impl::type>(stream, mem, result); break; case cldnn::data_types::f16: - store_result_impl::type>(mem, result); + store_result_impl::type>(stream, mem, result); break; case cldnn::data_types::f32: - store_result_impl::type>(mem, result); + store_result_impl::type>(stream, mem, result); break; default: throw std::runtime_error("Non max supression - unsupported output data type"); } } -void store_first_output(memory_impl& mem, const std::vector& result) { - auto data_type = mem.get_layout().data_type; +void store_first_output(stream& stream, memory::ptr mem, const std::vector& result) { + auto data_type = mem->get_layout().data_type; switch (data_type) { case cldnn::data_types::i32: - store_result_impl::type>(mem, result); + store_result_impl::type>(stream, mem, result); break; case cldnn::data_types::i64: - store_result_impl::type>(mem, result); + store_result_impl::type>(stream, mem, result); break; default: throw std::runtime_error("Non max supression - unsupported output data type"); @@ -272,11 +272,11 @@ void store_first_output(memory_impl& mem, const std::vector& res } template -void store_second_output_impl(memory_impl& mem, const std::vector& result) { - mem_lock lock(mem); +void store_second_output_impl(stream& stream, memory::ptr mem, const std::vector& result) { + mem_lock lock(mem, stream); auto ptr = lock.data(); - auto output_size = static_cast(mem.get_layout().size.batch[0]); + auto output_size = static_cast(mem->get_layout().size.batch[0]); auto results_size = result.size(); size_t si = 0; @@ -294,14 +294,14 @@ void store_second_output_impl(memory_impl& mem, const std::vector& result) { - auto data_type = mem.get_layout().data_type; +void store_second_output(stream& stream, memory::ptr mem, const std::vector& result) { + auto data_type = mem->get_layout().data_type; switch (data_type) { case cldnn::data_types::f16: - store_second_output_impl::type>(mem, result); + store_second_output_impl::type>(stream, mem, result); break; case cldnn::data_types::f32: - store_second_output_impl::type>(mem, result); + store_second_output_impl::type>(stream, mem, result); break; default: throw std::runtime_error("Non max supression - unsupported second output data type"); @@ -309,20 +309,20 @@ void store_second_output(memory_impl& mem, const std::vector& re } template -void store_third_output_impl(memory_impl& mem, const std::vector& result) { - mem_lock lock(mem); +void store_third_output_impl(stream& stream, memory::ptr mem, const std::vector& result) { + mem_lock lock(mem, stream); auto ptr = lock.data(); ptr[0] = static_cast(result.size()); } -void store_third_output(memory_impl& mem, const std::vector& result) { - auto data_type = mem.get_layout().data_type; +void store_third_output(stream& stream, memory::ptr mem, const std::vector& result) { + auto data_type = mem->get_layout().data_type; switch (data_type) { case cldnn::data_types::i32: - store_third_output_impl::type>(mem, result); + store_third_output_impl::type>(stream, mem, result); break; case cldnn::data_types::i64: - store_third_output_impl::type>(mem, result); + store_third_output_impl::type>(stream, mem, result); break; default: throw std::runtime_error("Non max supression - unsupported third output data type"); @@ -331,9 +331,10 @@ void store_third_output(memory_impl& mem, const std::vector& res void run(non_max_suppression_inst& instance) { auto prim = instance.node.get_primitive(); + auto& stream = instance.get_network().get_stream(); - auto boxes = load_boxes(instance.input_boxes_mem(), prim->center_point_box); - auto scores = load_scores(instance.input_scores_mem()); + auto boxes = load_boxes(stream, instance.input_boxes_mem(), prim->center_point_box); + auto scores = load_scores(stream, instance.input_scores_mem()); int num_select_per_class = 0; float iou_threshold = 1.f; @@ -341,58 +342,61 @@ void run(non_max_suppression_inst& instance) { float soft_nms_sigma = 0.f; if (instance.has_num_select_per_class()) { - num_select_per_class = load_scalar(instance.num_select_per_class_mem()); + num_select_per_class = load_scalar(stream, instance.num_select_per_class_mem()); } if (instance.has_iou_threshold()) { - iou_threshold = load_scalar(instance.iou_threshold_mem()); + iou_threshold = load_scalar(stream, instance.iou_threshold_mem()); } if (instance.has_score_threshold()) { - score_threshold = load_scalar(instance.score_threshold_mem()); + score_threshold = load_scalar(stream, instance.score_threshold_mem()); } if (instance.has_soft_nms_sigma()) { - soft_nms_sigma = load_scalar(instance.soft_nms_sigma_mem()); + soft_nms_sigma = load_scalar(stream, instance.soft_nms_sigma_mem()); } auto result = run_nms(boxes, scores, num_select_per_class, score_threshold, iou_threshold, soft_nms_sigma, prim->sort_result_descending); if (instance.has_third_output()) { - store_third_output(instance.third_output_mem(), result); + store_third_output(stream, instance.third_output_mem(), result); } if (instance.has_second_output()) { - store_second_output(instance.second_output_mem(), result); - store_first_output(instance.output_memory(), result); + store_second_output(stream, instance.second_output_mem(), result); + store_first_output(stream, instance.output_memory_ptr(), result); return; } - store_result(instance.output_memory(), result); + store_result(stream, instance.output_memory_ptr(), result); } struct non_max_suppression_cpu : typed_primitive_impl { using parent = typed_primitive_impl; + std::unique_ptr clone() const override { + return make_unique(*this); + } + non_max_suppression_cpu() : parent(kernel_selector::weights_reorder_params(), "non_max_suppression_cpu") {} - virtual event_impl::ptr execute_impl(const std::vector& event, - typed_primitive_inst& instance) { + virtual event::ptr execute_impl(const std::vector& event, typed_primitive_inst& instance) { for (auto e : event) { e->wait(); } - auto ev = instance.get_network().get_engine().create_user_event(instance.get_network().get_id(), false); + auto& stream = instance.get_network().get_stream(); run(instance); - dynamic_cast(ev.get())->set(); // set as complete - return ev; + return stream.create_user_event(true); } static primitive_impl* create(const non_max_suppression_node&) { return new non_max_suppression_cpu(); } + void init_kernels() override {} }; } // namespace diff --git a/inference-engine/thirdparty/clDNN/src/gpu/normalize_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/normalize_gpu.cpp index 9a8a025ffb78bb..7ed0653035fc53 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/normalize_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/normalize_gpu.cpp @@ -5,7 +5,7 @@ #include "normalize_inst.h" #include "primitive_gpu_base.h" #include "implementation_map.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_selector_helper.h" #include "normalize/normalize_kernel_selector.h" #include "normalize/normalize_kernel_base.h" @@ -21,11 +21,14 @@ struct normalize_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + protected: - kernel::kernel_arguments_data get_arguments(typed_primitive_inst& instance, - int32_t split) const override { - kernel::kernel_arguments_data args = parent::get_arguments(instance, split); - args.scale_table = (memory_impl::cptr) &instance.scale_memory(); + kernel_arguments_data get_arguments(typed_primitive_inst& instance, int32_t split) const override { + kernel_arguments_data args = parent::get_arguments(instance, split); + args.scale_table = instance.scale_memory(); return args; } diff --git a/inference-engine/thirdparty/clDNN/src/gpu/ocl_builder.h b/inference-engine/thirdparty/clDNN/src/gpu/ocl_builder.h deleted file mode 100644 index 5f426c9042f27d..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/gpu/ocl_builder.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma once - -#include -#include -#include -#include -#include -#include -#include "device_impl.h" - -namespace cldnn { -namespace gpu { -struct configuration; - -class ocl_builder { -private: - const uint32_t device_type = CL_DEVICE_TYPE_GPU; // cldnn supports only gpu devices - const uint32_t device_vendor = 0x8086; // Intel vendor -public: - ocl_builder() = default; - - std::map get_available_devices(void* user_context, void* user_device) const; - uint32_t get_device_type() const { return device_type; } - uint32_t get_device_vendor() const { return device_vendor; } -private: - bool does_device_match_config(bool out_of_order, const cl::Device& device) const; - std::vector build_device_list(bool out_out_order) const; - std::vector build_device_list_from_user_context(bool out_out_order, void* user_context) const; - std::vector build_device_list_from_user_device(bool out_out_order, void* user_device) const; -}; - -} // namespace gpu -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/ocl_queue_wrapper.cpp b/inference-engine/thirdparty/clDNN/src/gpu/ocl_queue_wrapper.cpp deleted file mode 100644 index 60298e65a8547f..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/gpu/ocl_queue_wrapper.cpp +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include "ocl_queue_wrapper.h" -#include "ocl_base_event.h" -#include "ocl_user_event.h" -#include "command_queues_builder.h" -#include "events_pool.h" - -#include -#include -#include - -#include -#include -#include -#include -#include - -// NOTE: Due to buggy scope transition of warnings we need to disable warning in place of use/instantation -// of some types (even though we already disabled them in scope of definition of these types). -// Moreover this warning is pretty much now only for annoyance: it is generated due to lack -// of proper support for mangling of custom GCC attributes into type name (usually when used -// with templates, even from standard library). -#if defined __GNUC__ && __GNUC__ >= 6 -#pragma GCC diagnostic ignored "-Wignored-attributes" -#endif - -namespace cldnn { -namespace gpu { - -gpu_queue::gpu_queue(uint32_t id, queue_type queue, std::shared_ptr context) - : id(id), _context(context), _command_queue(queue), _events_pool(new events_pool()) {} - -event_impl::ptr gpu_queue::enqueue_kernel(kernels_cache::kernel_type const& kern, - cl::NDRange const& global, - cl::NDRange const& local, - std::vector const& deps) { - std::vector dep_events; - auto dep_events_ptr = &dep_events; - if (!context()->get_configuration().host_out_of_order) { - for (auto& dep : deps) { - if (auto ocl_base_ev = dynamic_cast(dep.get())) { - dep_events.push_back(ocl_base_ev->get()); - } - } - } else { - dep_events_ptr = nullptr; - - sync_events(deps); - } - - cl::Event ret_ev; - - try { - if (!context()->get_configuration().host_out_of_order || _output_event || - context()->get_configuration().enable_profiling) { - _command_queue.enqueueNDRangeKernel(kern, cl::NullRange, global, local, dep_events_ptr, &ret_ev); - } else { - _command_queue.enqueueNDRangeKernel(kern, cl::NullRange, global, local, dep_events_ptr, nullptr); - } - } catch (cl::Error const& err) { - throw ocl_error(err); - } - - return _events_pool->get_from_base_pool(context(), ret_ev, ++_queue_counter); -} - -event_impl::ptr gpu_queue::enqueue_marker(std::vector const& deps) { - if (deps.empty()) - return _events_pool->get_from_user_pool(context(), true); - - bool enabled_single_kernel = context()->get_configuration().single_kernel_name == "" ? false : true; - if (!context()->get_configuration().host_out_of_order) { - cl::Event ret_ev; - if (!enabled_single_kernel) { - std::vector dep_events; - for (auto& dep : deps) { - if (auto ocl_base_ev = dynamic_cast(dep.get())) - dep_events.push_back(ocl_base_ev->get()); - } - - try { - _command_queue.enqueueMarkerWithWaitList(&dep_events, &ret_ev); - } catch (cl::Error const& err) { - throw ocl_error(err); - } - } else { - try { - _command_queue.enqueueMarkerWithWaitList(nullptr, &ret_ev); - } catch (cl::Error const& err) { - throw ocl_error(err); - } - } - - return _events_pool->get_from_base_pool(context(), ret_ev, ++_queue_counter); - } else { - sync_events(deps); - return _events_pool->get_from_base_pool(context(), _last_barrier_ev, _last_barrier); - } -} - -event_impl::ptr gpu_queue::group_events(std::vector const& deps) { - return _events_pool->get_from_group_pool(context(), deps); -} - -event_impl::ptr gpu_queue::create_user_event(bool set) { return _events_pool->get_from_user_pool(context(), set); } - -void gpu_queue::reset_events() { _events_pool->reset_events(); } - -void gpu_queue::release_events_pool() { _events_pool.reset(); } - -void gpu_queue::flush() { queue().flush(); } - -void gpu_queue::release_pending_memory() { - /* - TODO: Temp. solution, untill proper API calls from OpenCL are released. - */ - void* ptr = nullptr; - ptr = _mm_malloc(4096, 4096); - queue().finish(); - try { - cl::Buffer flusher(context()->context(), CL_MEM_USE_HOST_PTR, (size_t)4096, ptr); - flusher = (cl_mem) nullptr; // clear buffer - } catch (...) { - _mm_free(ptr); - throw; - } - _mm_free(ptr); -} - -void gpu_queue::sync_events(std::vector const& deps) { - bool needs_barrier = false; - for (auto& dep : deps) { - auto* ocl_base_ev = dynamic_cast(dep.get()); - if (ocl_base_ev->get_queue_stamp() > _last_barrier) { - needs_barrier = true; - } - } - - if (needs_barrier) { - try { - if (_output_event) - _command_queue.enqueueBarrierWithWaitList(nullptr, &_last_barrier_ev); - else - _command_queue.enqueueBarrierWithWaitList(nullptr, nullptr); - } catch (cl::Error const& err) { - throw ocl_error(err); - } - - _last_barrier = ++_queue_counter; - } -} - -} // namespace gpu -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/ocl_queue_wrapper.h b/inference-engine/thirdparty/clDNN/src/gpu/ocl_queue_wrapper.h deleted file mode 100644 index 55dabcdcfd04db..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/gpu/ocl_queue_wrapper.h +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma once - -#include "ocl_builder.h" - -#include "kernels_cache.h" -#include "device_info.h" -#include "event_impl.h" -#include "configuration.h" - -#include -#include -#include -#include -#include -#include -#include - -namespace cldnn { -typedef cl::vector> kernels_binaries_vector; -typedef cl::vector kernels_binaries_container; -using queue_type = cl::CommandQueueIntel; -namespace gpu { -typedef CL_API_ENTRY cl_command_queue(CL_API_CALL* pfn_clCreateCommandQueueWithPropertiesINTEL)( - cl_context context, - cl_device_id device, - const cl_queue_properties_khr* properties, - cl_int* errcodeRet); - -class gpu_toolkit; -class events_pool; - -class gpu_queue { -public: - const queue_type& queue() const { return _command_queue; } - gpu_queue(uint32_t id, queue_type queue, std::shared_ptr context); - gpu_queue(gpu_queue&& other) - : id(other.id), - _context(other._context), - _command_queue(other._command_queue), - _queue_counter(other._queue_counter.load()), - _last_barrier(other._last_barrier.load()), - _events_pool(std::move(other._events_pool)), - _last_barrier_ev(other._last_barrier_ev), - _output_event(other._output_event) {} - - gpu_queue& operator=(gpu_queue&& other) { - if (this != &other) { - id = other.id; - _context = std::move(other._context); - _command_queue = std::move(other._command_queue); - _queue_counter = std::move(other._queue_counter.load()); - _last_barrier = std::move(other._last_barrier.load()); - _events_pool = std::move(std::move(other._events_pool)); - _last_barrier_ev = std::move(other._last_barrier_ev); - _output_event = std::move(other._output_event); - } - return *this; - } - - ~gpu_queue() = default; - - void sync_events(std::vector const& deps); - void release_pending_memory(); - void flush(); - - void set_output_event(bool out_event) { _output_event = out_event; } - - event_impl::ptr enqueue_kernel(kernels_cache::kernel_type const& kern, - cl::NDRange const& global, - cl::NDRange const& local, - std::vector const& deps); - event_impl::ptr enqueue_marker(std::vector const& deps); - event_impl::ptr group_events(std::vector const& deps); - void reset_events(); - event_impl::ptr create_user_event(bool set); - void release_events_pool(); - std::shared_ptr context() { return _context.lock(); } - -private: - uint32_t id; - std::weak_ptr _context; - queue_type _command_queue; - std::atomic _queue_counter{0}; - std::atomic _last_barrier{0}; - std::shared_ptr _events_pool; - cl::Event _last_barrier_ev; - bool _output_event = false; -}; - -} // namespace gpu -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/ocl_toolkit.cpp b/inference-engine/thirdparty/clDNN/src/gpu/ocl_toolkit.cpp deleted file mode 100644 index 3ee0842eb26f95..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/gpu/ocl_toolkit.cpp +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include "ocl_toolkit.h" -#include "ocl_base_event.h" -#include "ocl_user_event.h" -#include "command_queues_builder.h" -#include "events_pool.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -// NOTE: Due to buggy scope transition of warnings we need to disable warning in place of use/instantation -// of some types (even though we already disabled them in scope of definition of these types). -// Moreover this warning is pretty much now only for annoyance: it is generated due to lack -// of proper support for mangling of custom GCC attributes into type name (usually when used -// with templates, even from standard library). -#if defined __GNUC__ && __GNUC__ >= 6 -#pragma GCC diagnostic ignored "-Wignored-attributes" -#endif - -// static class memebers - pointers to dynamically obtained OpenCL extension functions -cl::PFN_clEnqueueAcquireMediaSurfacesINTEL cl::SharedSurfLock::pfn_acquire = NULL; -cl::PFN_clEnqueueReleaseMediaSurfacesINTEL cl::SharedSurfLock::pfn_release = NULL; -cl::PFN_clCreateFromMediaSurfaceINTEL cl::ImageVA::pfn_clCreateFromMediaSurfaceINTEL = NULL; -#ifdef _WIN32 -cl::PFN_clCreateFromD3D11Buffer cl::BufferDX::pfn_clCreateFromD3D11Buffer = NULL; -#endif - -namespace cldnn { -namespace gpu { - -ocl_error::ocl_error(cl::Error const& err) - : std::runtime_error(err.what() + std::string(", error code: ") + std::to_string(err.err())) {} - -std::mutex gpu_toolkit::cache_mutex; - -std::shared_ptr gpu_toolkit::create(const device_impl& device, const configuration& cfg) { - struct make_shared_wa : public gpu_toolkit { - explicit make_shared_wa(const device_impl& device, const configuration& cfg) - : gpu_toolkit(device, cfg) {} - }; - try { - auto ctx = std::make_shared(device, cfg); - ctx->add_network(0); - return ctx; - } catch (cl::Error const& err) { - throw ocl_error(err); - } -} - -struct gpu_toolkit::ocl_logger { - std::ofstream _log_file; -}; - -gpu_toolkit::gpu_toolkit(const device_impl& device_impl, const configuration& config) - : _configuration(config), - _device(&device_impl), - _neo_driver(strstr(get_device_version().c_str(), "NEO") ? true : false) { - device().getInfo(CL_DEVICE_EXTENSIONS, &_extensions); - - device_cache_reader dc_reader(_configuration.tuning_cache_path); - _device_cache = dc_reader.get(); - - _logger = std::unique_ptr(new ocl_logger()); - if (logging_enabled()) { - auto device_info = get_device_info(); - open_log() << "Engine configuration:\n" - << " profiling: " << std::boolalpha << _configuration.enable_profiling << "\n" - << " meaningful names: " << std::boolalpha << _configuration.meaningful_kernels_names << "\n" - << " dump custom program: " << std::boolalpha << _configuration.dump_custom_program << "\n" - << " vendor type: " << std::hex << std::setfill('0') << std::setw(4) << std::right - << std::to_string(device_info.vendor_id) << "\n" - << std::dec << std::setfill(' ') << std::right - << " compiler options: " << _configuration.compiler_options << "\n" - << " single kernel name: " << _configuration.single_kernel_name << "\n" - << " out-of-order: " << std::boolalpha << config.host_out_of_order << "\n" - << " engine log: " << _configuration.log << "\n" - << " sources dumps: " << _configuration.ocl_sources_dumps_dir << "\n" - << "\nEngine info:\n" - << " cores count: " << device_info.cores_count << "\n" - << " core frequencey: " << device_info.core_frequency << "\n" - << " max work group size: " << device_info.max_work_group_size << "\n" - << " local memory size: " << device_info.max_local_mem_size << "\n" - << " fp16: " << std::boolalpha << (device_info.supports_fp16 != 0) << "\n" - << " fp16 denorms: " << std::boolalpha << (device_info.supports_fp16_denorms != 0) << "\n" - << " subgroups short: " << std::boolalpha << (device_info.supports_subgroups_short != 0) << "\n" - << " local block io: " << std::boolalpha << device_info.supports_local_block_io << "\n" - << " optimization hints: " << std::boolalpha << device_info.supports_optimization_hints << std::endl; - } -} - -gpu_queue& gpu_toolkit::get_command_queue(uint32_t id) { - return _command_queues_w.at(id); -} - -gpu_program_state& gpu_toolkit::get_program_state(uint32_t id) { - std::lock_guard lock(toolkit_mutex); - return *_program_states.at(id); -} - -void gpu_toolkit::add_program(uint32_t prog_id) { - std::lock_guard lock(toolkit_mutex); - _program_states.emplace(std::make_pair(prog_id, std::make_shared(*this, prog_id))); -} - -void gpu_toolkit::remove_program(uint32_t prog_id) { - std::lock_guard lock(toolkit_mutex); - auto state_iter = _program_states.find(prog_id); - - if (state_iter != _program_states.end()) { - _program_states.erase(state_iter); - } -} - -kernels_cache& gpu_toolkit::get_kernels_cache(uint32_t prog_id) { - return get_program_state(prog_id)._kernels_cache; -} - -void gpu_toolkit::add_network(uint32_t net_id) { - std::lock_guard lock(toolkit_mutex); - command_queues_builder queue_builder(context(), device(), _device->get_platform()); - queue_builder.set_profiling(_configuration.enable_profiling); - queue_builder.set_out_of_order((_configuration.host_out_of_order && _neo_driver)); - - bool priorty_extensions = - extension_supported("cl_khr_priority_hints") && extension_supported("cl_khr_create_command_queue"); - queue_builder.set_priority_mode(_configuration.priority_mode, priorty_extensions); - - bool throttle_extensions = - extension_supported("cl_khr_throttle_hints") && extension_supported("cl_khr_create_command_queue"); - queue_builder.set_throttle_mode(_configuration.throttle_mode, throttle_extensions); - - queue_builder.build(); - _command_queues_w.emplace(std::make_pair(net_id, - gpu_queue(net_id, queue_builder.queue(), shared_from_this()))); -} - -void gpu_toolkit::remove_network(uint32_t net_id) { - std::lock_guard lock(toolkit_mutex); - auto net_iter = _command_queues_w.find(net_id); - if (net_iter != _command_queues_w.end()) { - // net_iter->second.release_pending_memory(); - _command_queues_w.erase(net_iter); - } -} - -event_impl::ptr gpu_toolkit::enqueue_kernel(uint32_t queue_id, - kernels_cache::kernel_type const& kern, - cl::NDRange const& global, - cl::NDRange const& local, - std::vector const& deps) { - return get_command_queue(queue_id).enqueue_kernel(kern, global, local, deps); -} - -event_impl::ptr gpu_toolkit::enqueue_marker(uint32_t queue_id, std::vector const& deps) { - return get_command_queue(queue_id).enqueue_marker(deps); -} - -event_impl::ptr gpu_toolkit::group_events(uint32_t queue_id, std::vector const& deps) { - return get_command_queue(queue_id).group_events(deps); -} - -event_impl::ptr gpu_toolkit::create_user_event(uint32_t queue_id, bool set) { - return get_command_queue(queue_id).create_user_event(set); -} - -void gpu_toolkit::reset_events(uint32_t queue_id) { get_command_queue(queue_id).reset_events(); } - -void gpu_toolkit::release_events_pool(uint32_t queue_id) { get_command_queue(queue_id).release_events_pool(); } - -void gpu_toolkit::release_all_events_pools() { - for (auto& queue : _command_queues_w) { - queue.second.release_events_pool(); - } -} - -void gpu_toolkit::flush(uint32_t queue_id) { get_command_queue(queue_id).flush(); } - -void gpu_toolkit::release_pending_memory(uint32_t queue_id) { get_command_queue(queue_id).release_pending_memory(); } - -void gpu_toolkit::wait_for_events(std::vector const& events) { - std::vector clevents; - for (auto& ev : events) { - if (auto ocl_base_ev = dynamic_cast(ev.get())) - clevents.push_back(ocl_base_ev->get()); - } - - try { - cl::WaitForEvents(clevents); - } catch (cl::Error const& err) { - throw ocl_error(err); - } -} - -void gpu_toolkit::log(uint64_t id, std::string const& msg) { - if (_configuration.log.empty()) - return; - - open_log() << "[" << id << "] " << msg << std::endl; -} - -void gpu_toolkit::set_output_event(uint32_t queue_id, bool out_event) { - get_command_queue(queue_id).set_output_event(out_event); -} - -std::ofstream& gpu_toolkit::open_log() { - if (!_logger->_log_file.is_open()) { - _logger->_log_file.open(_configuration.log, std::ios::out | std::ios::trunc); - if (!_logger->_log_file.good()) { - _logger->_log_file.close(); - throw std::runtime_error("Could not initialize ocl_toolkit log file"); - } - - if (!_logger->_log_file.is_open()) { - _logger->_log_file.close(); - throw std::runtime_error("Could not open ocl_toolkit log file '" + _configuration.log + "' for writing"); - } - } - - return _logger->_log_file; -} - -} // namespace gpu - -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/ocl_toolkit.h b/inference-engine/thirdparty/clDNN/src/gpu/ocl_toolkit.h deleted file mode 100644 index ba8a3cb8d26e1e..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/gpu/ocl_toolkit.h +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma once -#include "device_info.h" -#include "device_impl.h" -#include "kernels_cache.h" -#include "event_impl.h" -#include "configuration.h" -#include "ocl_queue_wrapper.h" -#include "device_cache_reader.h" - -#include -#include -#include -#include -#include -#include - -namespace cldnn { -typedef cl::vector> kernels_binaries_vector; -typedef cl::vector kernels_binaries_container; -using queue_type = cl::CommandQueueIntel; -namespace gpu { -typedef CL_API_ENTRY cl_command_queue(CL_API_CALL* pfn_clCreateCommandQueueWithPropertiesINTEL)( - cl_context context, - cl_device_id device, - const cl_queue_properties_khr* properties, - cl_int* errcodeRet); - -class ocl_error : public std::runtime_error { -public: - explicit ocl_error(cl::Error const& err); -}; - -class events_pool; -class gpu_toolkit; - -class context_holder { -protected: - explicit context_holder(std::shared_ptr context) : _context(context) {} - virtual ~context_holder() = default; - - const std::shared_ptr& context() const { return _context; } - - std::shared_ptr _context; -}; - -struct gpu_program_state { - kernels_cache _kernels_cache; - - gpu_program_state(gpu_toolkit& context, uint32_t prog_id) : - _kernels_cache(context, prog_id) {} -}; - -class gpu_toolkit : public std::enable_shared_from_this { - friend class context_holder; - -protected: - explicit gpu_toolkit(const device_impl& device_impl, - const configuration& aconfiguration = configuration()); - -public: - static std::shared_ptr create(const device_impl& device_impl, - const configuration& cfg = configuration()); - const cl::Context context() const { return _device->get_context(); } - const cl::Device device() const { return _device->get_device(); } - const memory_capabilities memory_caps() const { return _device->mem_caps(); } - const queue_type& queue(uint32_t id) { return get_command_queue(id).queue(); } - - const configuration& get_configuration() const { return _configuration; } - device_info_internal get_device_info() const { return _device->get_info(); } - std::shared_ptr get_device_cache() const { return _device_cache; } - kernels_cache& get_kernels_cache(uint32_t prog_id); - bool get_serialization_flag() { return _serialize; } - void set_serialization_flag(bool serialization_flag) { _serialize = serialization_flag; } - - inline bool extension_supported(const std::string ext) { return _extensions.find(ext) != std::string::npos; } - - gpu_toolkit(const gpu_toolkit& other) = delete; - gpu_toolkit(gpu_toolkit&& other) = delete; - gpu_toolkit& operator=(const gpu_toolkit& other) = delete; - gpu_toolkit& operator=(gpu_toolkit&& other) = delete; - std::string single_kernel_name() const { return _configuration.single_kernel_name; } - bool enabled_single_kernel() const { return single_kernel_name() == "" ? false : true; } - - void set_output_event(uint32_t queue_id, bool out_event); - - event_impl::ptr enqueue_kernel(uint32_t queue_id, - kernels_cache::kernel_type const& kern, - cl::NDRange const& global, - cl::NDRange const& local, - std::vector const& deps); - event_impl::ptr enqueue_marker(uint32_t queue_id, std::vector const& deps); - event_impl::ptr group_events(uint32_t queue_id, std::vector const& deps); - void reset_events(uint32_t queue_id); - event_impl::ptr create_user_event(uint32_t queue_id, bool set); - void release_events_pool(uint32_t queue_id); - void release_all_events_pools(); - - void flush(uint32_t queue_id); - void release_pending_memory(uint32_t queue_id); - void wait_for_events(std::vector const& events); - - void log(uint64_t id, std::string const& msg); - bool logging_enabled() const { return !_configuration.log.empty(); } - bool is_neo_driver() { return _neo_driver; } - void add_network(uint32_t net_id); - void remove_network(uint32_t net_id); - - void add_program(uint32_t prog_id); - void remove_program(uint32_t prog_id); - - std::mutex& get_cache_mutex() { return cache_mutex; } - -private: - configuration _configuration; - device_impl::cptr _device; - bool _neo_driver = false; - std::map> _program_states; - std::map _command_queues_w; - std::shared_ptr _device_cache; - bool _serialize = false; - - std::string _extensions; - - struct ocl_logger; - std::unique_ptr _logger; - - // returns whether a barrier has been added - std::ofstream& open_log(); - - std::string get_device_version() { return device().getInfo(); } - - gpu_queue& get_command_queue(uint32_t id); - gpu_program_state& get_program_state(uint32_t id); - - std::mutex toolkit_mutex; - // mutex for kernels_cache must be static to ensure that all threads run program build in a thread-safe fashion - // including the case when multiple IE cores are created. - static std::mutex cache_mutex; -}; - -} // namespace gpu -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/one_hot_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/one_hot_gpu.cpp index 1c2704a5b26c15..218e50f018d571 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/one_hot_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/one_hot_gpu.cpp @@ -9,7 +9,7 @@ #include "kernel_selector_helper.h" #include "one_hot/one_hot_kernel_selector.h" #include "one_hot/one_hot_kernel_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include namespace cldnn { @@ -19,6 +19,10 @@ struct one_hot_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + static primitive_impl* create(const one_hot_node& arg) { auto oh_params = get_default_params(arg, 1); auto oh_optional_params = diff --git a/inference-engine/thirdparty/clDNN/src/gpu/permute_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/permute_gpu.cpp index 31bc335b90470d..4c8e1f549752c4 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/permute_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/permute_gpu.cpp @@ -5,7 +5,7 @@ #include "permute_inst.h" #include "primitive_gpu_base.h" #include "implementation_map.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_selector_helper.h" #include "permute/permute_kernel_selector.h" #include "permute/permute_kernel_ref.h" @@ -19,6 +19,10 @@ struct permute_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + static primitive_impl* create(const permute_node& arg) { auto permute_params = get_default_params(arg); auto permute_optional_params = diff --git a/inference-engine/thirdparty/clDNN/src/gpu/pooling_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/pooling_gpu.cpp index 138a235d6ce76a..a10439bb1c92cf 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/pooling_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/pooling_gpu.cpp @@ -5,7 +5,7 @@ #include "pooling_inst.h" #include "primitive_gpu_base.h" #include "implementation_map.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_selector_helper.h" #include "pooling/pooling_kernel_selector.h" #include "pooling/pooling_kernel_base.h" @@ -68,12 +68,15 @@ struct pooling_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + protected: - kernel::kernel_arguments_data get_arguments(typed_primitive_inst& instance, - int32_t split) const override { - kernel::kernel_arguments_data args = parent::get_arguments(instance, split); + kernel_arguments_data get_arguments(typed_primitive_inst& instance, int32_t split) const override { + kernel_arguments_data args = parent::get_arguments(instance, split); if (!instance.argument.argmax.empty()) - args.inputs.push_back((memory_impl::cptr) &instance.dep_memory(1)); + args.inputs.push_back(instance.dep_memory_ptr(1)); return args; } diff --git a/inference-engine/thirdparty/clDNN/src/gpu/primitive_gpu_base.h b/inference-engine/thirdparty/clDNN/src/gpu/primitive_gpu_base.h index c08058d9c67950..9cd55a0f9f46e6 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/primitive_gpu_base.h +++ b/inference-engine/thirdparty/clDNN/src/gpu/primitive_gpu_base.h @@ -8,9 +8,7 @@ #include #include "primitive_inst.h" #include "program_impl.h" -#include "kernel.h" -#include "events_waiter.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_selector_helper.h" #include "network_impl.h" #include "register_gpu.hpp" @@ -31,27 +29,42 @@ For example, all gpu convolution implementations should derive from typed_primit template struct typed_primitive_gpu_impl : public typed_primitive_impl { const typed_program_node& _outer; - device_info_internal _device_info; kernel_selector::kernel_data _kernel_data; - std::vector _kernels; - std::vector _intermediates_memory; + std::vector _kernel_ids; + std::vector _kernels; + std::vector _intermediates_memory; + + typed_primitive_gpu_impl(const typed_primitive_gpu_impl& other) + : typed_primitive_impl(other._weights_reorder_params, other._kernel_name) + , _outer(other._outer) + , _kernel_data(other._kernel_data) + , _kernel_ids(other._kernel_ids) + , _kernels({}) + , _intermediates_memory({}) { + _kernels.reserve(other._kernels.size()); + for (size_t k = 0; k < other._kernels.size(); ++k) { + _kernels.emplace_back(other._kernels[k]->clone()); + } + for (auto& mem : other._intermediates_memory) { + auto& engine = _outer.get_program().get_engine(); + auto new_mem = engine.allocate_memory(mem->get_layout(), mem->get_allocation_type()); + _intermediates_memory.push_back(new_mem); + } + } typed_primitive_gpu_impl(const typed_program_node& arg, const kernel_selector::kernel_data& kd) : typed_primitive_impl(kd.weightsReorderParams, kd.kernelName), _outer(arg), - _device_info(arg.get_program().get_engine().get_context()->get_device_info()), _kernel_data(kd) { // weights reorder params got copied to parent, clear in _kernel_data to release shared ptr _kernel_data.weightsReorderParams.engine = kernel_selector::generic_kernel_params::Engine::NONE; _kernel_data.weightsReorderParams.cpuKernel = nullptr; _kernel_data.weightsReorderParams.clKernel = nullptr; - _kernels.reserve(kd.kernels.size()); + _kernel_ids.reserve(kd.kernels.size()); + // Add selected kernels to kernels_cache for the following compilation and save output ids for (size_t i = 0; i < kd.kernels.size(); ++i) { - gpu::kernel kernel(_outer.get_program().get_engine().get_context(), - kd.kernels[i].kernelString, - _outer.get_program().get_id()); - _kernels.emplace_back(std::move(kernel)); + _kernel_ids.emplace_back(_outer.get_program().add_kernel(kd.kernels[i].code.kernelString)); } for (auto size : kd.internalBufferSizes) { @@ -62,7 +75,7 @@ struct typed_primitive_gpu_impl : public typed_primitive_impl { {1, 1, 1, (tensor::value_type)(size / bpp)}}; auto& eimpl = arg.get_program().get_engine(); - _intermediates_memory.push_back(eimpl.allocate_memory(expected_layout, 0)); + _intermediates_memory.push_back(eimpl.allocate_memory(expected_layout)); } } bool is_cpu() const override { return false; } @@ -70,22 +83,21 @@ struct typed_primitive_gpu_impl : public typed_primitive_impl { protected: virtual bool optimized_out(typed_primitive_inst&) const { return false; } - virtual kernel::kernel_arguments_data get_arguments(typed_primitive_inst& instance, - int32_t /*split*/) const { - kernel::kernel_arguments_data args; + virtual kernel_arguments_data get_arguments(typed_primitive_inst& instance, int32_t /*split*/) const { + kernel_arguments_data args; for (size_t i = 0; i < instance.inputs_memory_count(); i++) { - args.inputs.push_back((memory_impl::cptr)&instance.input_memory(i)); + args.inputs.push_back(instance.input_memory_ptr(i)); } if (instance.has_fused_primitives()) { size_t count = instance.get_fused_mem_count(); for (size_t i = 0; i < count; i++) { - args.fused_op_inputs.push_back((memory_impl::cptr) &instance.fused_memory(i)); + args.fused_op_inputs.push_back(instance.fused_memory(i)); } } - args.output = (memory_impl::cptr) &instance.output_memory(); + args.output = instance.output_memory_ptr(); return args; } @@ -94,93 +106,96 @@ struct typed_primitive_gpu_impl : public typed_primitive_impl { virtual uint32_t get_groups() const { return 1; } virtual bool get_depthwise_sep_opt() const { return false; } - event_impl::ptr aggregate_events(const std::vector& events, - uint32_t net_id, - bool group = false) const { - if (events.size() == 1) + event::ptr aggregate_events(const std::vector& events, stream& stream, bool group = false, bool is_output = false) const { + if (events.size() == 1 && !is_output) return events[0]; - if (group) - return _outer.get_program().get_engine().get_context()->group_events(net_id, events); + if (group && !is_output) + return stream.group_events(events); - return events_waiter(_outer.get_program().get_engine().get_context()).run(net_id, events); + return stream.enqueue_marker(events, is_output); + } + + void init_kernels() override { + if (is_cpu()) { + return; + } + _kernels.clear(); + + _kernels.reserve(_kernel_ids.size()); + for (size_t k = 0; k < _kernel_ids.size(); ++k) { + _kernels.emplace_back(std::move(_outer.get_program().get_kernel(_kernel_ids[k]))); + } } void set_arguments_impl(typed_primitive_inst& instance) override { - uint32_t net_id = instance.get_network().get_id(); if (optimized_out(instance) || is_cpu()) { return; } auto split = get_split(); + stream& stream = instance.get_network().get_stream(); + // we iterate over split first in order to be able parallelism with OOOQ mechanism. for (size_t k = 0; k < _kernels.size(); ++k) { for (decltype(split) i = 0; i < split; i++) { auto args = get_arguments(instance, i); - args.scalars = &_kernel_data.kernels[k].scalars; + args.scalars = &_kernel_data.kernels[k].params.scalars; args.split = i; for (const auto& m : _intermediates_memory) { args.intermediates.push_back(m); } - _kernels[k].set_arguments(net_id, _kernel_data.kernels[k], args); - } - } - } - void cleanup_impl(typed_primitive_inst& instance) override { - uint32_t net_id = instance.get_network().get_id(); - if (optimized_out(instance) || is_cpu()) { - return; - } - - for (size_t k = 0; k < _kernels.size(); ++k) { - _kernels[k].cleanup(net_id); + stream.set_arguments(*_kernels[k], _kernel_data.kernels[k].params, args); + } } } - event_impl::ptr execute_impl(const std::vector& events, - typed_primitive_inst& instance) override { - uint32_t net_id = instance.get_network().get_id(); + event::ptr execute_impl(const std::vector& events, + typed_primitive_inst& instance) override { + stream& stream = instance.get_network().get_stream(); if (optimized_out(instance)) { - return aggregate_events(events, net_id); + return aggregate_events(events, stream, false, instance.is_output()); } - std::vector tmp_events(events); - std::vector all_events; + std::vector tmp_events(events); + std::vector all_events; // TODO - split should be handle in kernel selector by providing multiple kernels. auto split = get_split(); // we iterate over split first in order to be able parallelism with OOOQ mechanism. for (size_t k = 0; k < _kernels.size(); ++k) { - std::vector new_events; + std::vector new_events; for (decltype(split) i = 0; i < split; i++) { - // is any user of the prim's users is an detecion output, set prim as a output event (event won't be - // nullptr) + // is any user of the prim's users is an detecion output, set prim as a output event (event won't be nullptr) auto users = instance.node.get_users(); - bool next_prim_is_cpu = is_any_user_cpu(users); - if (next_prim_is_cpu) { - _kernels[k].set_output_event(net_id, true); - } else { - _kernels[k].set_output_event(net_id, instance.node.is_output()); + bool is_output_event = is_any_user_cpu(users) || instance.node.is_output(); + + auto args = get_arguments(instance, i); + args.scalars = &_kernel_data.kernels[k].params.scalars; + args.split = i; + + for (const auto& m : _intermediates_memory) { + args.intermediates.push_back(m); } - auto event = _kernels[k].run(net_id, _kernel_data.kernels[k], tmp_events); - new_events.push_back(event); - all_events.push_back(event); + auto ev = stream.enqueue_kernel(*_kernels[k], _kernel_data.kernels[k].params, args, tmp_events, is_output_event); + new_events.push_back(ev); + all_events.push_back(ev); } tmp_events = new_events; } if ((all_events.size() == 0) && (tmp_events.size() > 0)) - return aggregate_events(tmp_events, net_id); + return aggregate_events(tmp_events, stream); bool group_events = (all_events.size() > 1); - return aggregate_events(all_events, net_id, group_events); + return aggregate_events(all_events, stream, group_events); } }; diff --git a/inference-engine/thirdparty/clDNN/src/gpu/proposal_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/proposal_gpu.cpp index 889703234673a1..3bcc61c5ad06ff 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/proposal_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/proposal_gpu.cpp @@ -3,12 +3,11 @@ // #include "proposal_inst.h" -#include "kernel.h" +#include "cldnn/runtime/engine.hpp" #include "implementation_map.h" #include "network_impl.h" -#include "engine_impl.h" #include "math_utils.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "register_gpu.hpp" #include @@ -197,10 +196,14 @@ struct proposal_gpu : typed_primitive_impl { explicit proposal_gpu(const proposal_node& arg) : outer(arg) {} + std::unique_ptr clone() const override { + return make_unique(*this); + } + template - void read_image_info(proposal_inst& instance, im_info_t& im_info) { - auto& image_info = instance.dep_memory(proposal_inst::image_info_index); - mem_lock image_info_ptr{image_info}; + void read_image_info(stream& stream, proposal_inst& instance, im_info_t& im_info) { + auto image_info = instance.dep_memory_ptr(proposal_inst::image_info_index); + mem_lock image_info_ptr{image_info, stream}; const dtype* image_info_mem = image_info_ptr.data(); bool swap_xy = instance.argument.swap_xy; @@ -212,7 +215,7 @@ struct proposal_gpu : typed_primitive_impl { int min_bbox_x = 1; int min_bbox_y = 1; - auto image_info_size = image_info.get_layout().size; + auto image_info_size = image_info->get_layout().size; auto image_info_count = image_info_size.feature[0] == 1 ? image_info_size.batch[0] : image_info_size.feature[0]; int scaled_min_bbox_size = instance.argument.min_bbox_size; @@ -259,13 +262,13 @@ struct proposal_gpu : typed_primitive_impl { } template - void execute(proposal_inst& instance, im_info_t im_info, dtype* proposal_prob_ptr = nullptr) { + void execute(stream& stream, proposal_inst& instance, im_info_t im_info, dtype* proposal_prob_ptr = nullptr) { const std::vector& anchors = instance.get_anchors(); size_t anchors_num = anchors.size(); - auto& cls_scores = instance.dep_memory(proposal_inst::cls_scores_index); - auto& bbox_pred = instance.dep_memory(proposal_inst::bbox_pred_index); + auto cls_scores = instance.dep_memory_ptr(proposal_inst::cls_scores_index); + auto bbox_pred = instance.dep_memory_ptr(proposal_inst::bbox_pred_index); bool swap_xy = instance.argument.swap_xy; bool initial_clip = instance.argument.initial_clip; @@ -277,14 +280,14 @@ struct proposal_gpu : typed_primitive_impl { bool for_deformable = instance.argument.for_deformable; // feat map sizes - const auto& score_size = cls_scores.get_layout().size; + const auto& score_size = cls_scores->get_layout().size; int fm_h = score_size.spatial[1]; int fm_w = score_size.spatial[0]; int fm_sz = fm_w * fm_h; - mem_lock cls_scores_ptr{cls_scores}; - mem_lock bbox_pred_ptr{bbox_pred}; + mem_lock cls_scores_ptr{cls_scores, stream}; + mem_lock bbox_pred_ptr{bbox_pred, stream}; const dtype* cls_scores_mem = cls_scores_ptr.data(); const dtype* bbox_pred_mem = bbox_pred_ptr.data(); @@ -347,9 +350,9 @@ struct proposal_gpu : typed_primitive_impl { instance.argument.post_nms_topn, coordinates_offset); - auto& output = instance.output_memory(); + auto output = instance.output_memory_ptr(); - mem_lock output_ptr{output}; + mem_lock output_ptr{output, stream}; dtype* top_data = output_ptr.data() + n * instance.argument.post_nms_topn * 5; dtype* top_data_prob = proposal_prob_ptr == nullptr ? nullptr : proposal_prob_ptr + n * instance.argument.post_nms_topn; @@ -386,17 +389,19 @@ struct proposal_gpu : typed_primitive_impl { } } - event_impl::ptr execute_impl(const std::vector& events, proposal_inst& instance) override { + event::ptr execute_impl(const std::vector& events, proposal_inst& instance) override { for (auto& a : events) { a->wait(); } - auto ev = instance.get_network().get_engine().create_user_event(instance.get_network().get_id(), false); + auto& stream = instance.get_network().get_stream(); + + auto ev = instance.get_network().get_stream().create_user_event(false); im_info_t im_info; if (instance.dep_memory(proposal_inst::image_info_index).get_layout().data_type == data_types::f16) { - read_image_info::type>(instance, im_info); + read_image_info::type>(stream, instance, im_info); } else { - read_image_info::type>(instance, im_info); + read_image_info::type>(stream, instance, im_info); } if (instance.dep_memory(proposal_inst::cls_scores_index).get_layout().data_type != @@ -404,19 +409,19 @@ struct proposal_gpu : typed_primitive_impl { throw std::runtime_error("clDNN: proposal primitive doesn't support mixed bbox and scores types"); if (instance.dependencies().size() == 4) { - auto &proposal_probabilities = instance.dep_memory(proposal_inst::proposal_probabilities_out); + auto proposal_probabilities = instance.dep_memory_ptr(proposal_inst::proposal_probabilities_out); if (instance.dep_memory(proposal_inst::cls_scores_index).get_layout().data_type == data_types::f16) { - mem_lock::type> proposal_prob_ptr{proposal_probabilities}; - execute::type>(instance, im_info, proposal_prob_ptr.data()); + mem_lock::type> proposal_prob_ptr{proposal_probabilities, stream}; + execute::type>(stream, instance, im_info, proposal_prob_ptr.data()); } else { - mem_lock::type> proposal_prob_ptr{proposal_probabilities}; - execute::type>(instance, im_info, proposal_prob_ptr.data()); + mem_lock::type> proposal_prob_ptr{proposal_probabilities, stream}; + execute::type>(stream, instance, im_info, proposal_prob_ptr.data()); } } else { if (instance.dep_memory(proposal_inst::cls_scores_index).get_layout().data_type == data_types::f16) { - execute::type>(instance, im_info); + execute::type>(stream, instance, im_info); } else { - execute::type>(instance, im_info); + execute::type>(stream, instance, im_info); } } @@ -424,6 +429,8 @@ struct proposal_gpu : typed_primitive_impl { return ev; } + void init_kernels() override {} + static primitive_impl* create(const proposal_node& arg) { const layout& l = arg.image_info().get_output_layout(); const size_t count = l.size.feature[0] == 1 ? static_cast(l.size.batch[0]) : static_cast(l.size.feature[0]); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/push_pop_map.h b/inference-engine/thirdparty/clDNN/src/gpu/push_pop_map.h deleted file mode 100644 index c4fc57ed14c1c9..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/gpu/push_pop_map.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma once -#include -#include -#include -#include -#include - -namespace cldnn { -namespace gpu { - -template , - class Allocator = std::allocator>> -class push_pop_map { - std::mutex _mutex; - std::map _map; - -public: - void push(const Key& key, Type value) { - std::lock_guard lock{_mutex}; - _map.insert({key, std::move(value)}); - } - - Type pop(const Key& key) { - std::lock_guard lock{_mutex}; - auto it = _map.find(key); - if (it == _map.end()) - throw std::out_of_range("Invalud push_pop_map key"); - auto x = std::move(it->second); - _map.erase(it); - return std::move(x); - } - - bool empty() { - std::lock_guard lock{_mutex}; - return _map.empty(); - } -}; - -} // namespace gpu -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/gpu/pyramid_roi_align_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/pyramid_roi_align_gpu.cpp index 3b16e678c2ceb0..8259257d92c9aa 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/pyramid_roi_align_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/pyramid_roi_align_gpu.cpp @@ -7,7 +7,7 @@ #include "kernel_selector_helper.h" #include "pyramid_roi_align/pyramid_roi_align_kernel_selector.h" #include "pyramid_roi_align/pyramid_roi_align_kernel_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "pyramid_roi_align_inst.h" #include "network_impl.h" @@ -20,6 +20,10 @@ struct pyramid_roi_align_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + static primitive_impl* create(const pyramid_roi_align_node& arg) { auto prim = arg.get_primitive(); auto params = get_default_params(arg, 1); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/quantize_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/quantize_gpu.cpp index aefaa20eb8cc06..627a2e1799ac0d 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/quantize_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/quantize_gpu.cpp @@ -8,7 +8,7 @@ #include "kernel_selector_helper.h" #include "quantize/quantize_kernel_selector.h" #include "quantize/quantize_kernel_ref.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" using namespace cldnn; @@ -19,23 +19,26 @@ struct quantize_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + protected: - kernel::kernel_arguments_data get_arguments(typed_primitive_inst& instance, - int32_t) const override { - kernel::kernel_arguments_data args; + kernel_arguments_data get_arguments(typed_primitive_inst& instance, int32_t) const override { + kernel_arguments_data args; for (size_t i = 0; i < instance.inputs_memory_count(); i++) { - args.inputs.push_back((memory_impl::cptr) &instance.input_memory(i)); + args.inputs.push_back(instance.input_memory_ptr(i)); } if (instance.node.get_scale_shift_opt()) { if (instance.node.get_dependencies().size() == 9) { - args.inputs.push_back((memory_impl::cptr) &instance.dep_memory(5)); - args.inputs.push_back((memory_impl::cptr) &instance.dep_memory(6)); - args.inputs.push_back((memory_impl::cptr) &instance.dep_memory(7)); - args.inputs.push_back((memory_impl::cptr) &instance.dep_memory(8)); + args.inputs.push_back(instance.dep_memory_ptr(5)); + args.inputs.push_back(instance.dep_memory_ptr(6)); + args.inputs.push_back(instance.dep_memory_ptr(7)); + args.inputs.push_back(instance.dep_memory_ptr(8)); } } - args.output = (memory_impl::cptr) &instance.output_memory(); + args.output = instance.output_memory_ptr(); return args; } diff --git a/inference-engine/thirdparty/clDNN/src/gpu/reduce_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/reduce_gpu.cpp index 2bf2f7535b2e1e..5ad63259500d3f 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/reduce_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/reduce_gpu.cpp @@ -9,7 +9,7 @@ #include "reduce/reduce_kernel_selector.h" #include "reduce/reduce_kernel_ref.h" #include "reduce/reduce_kernel_b_fs_yx_fsv16.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "data_inst.h" using namespace cldnn; @@ -53,6 +53,10 @@ struct reduce_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + public: static primitive_impl* create(const reduce_node& arg) { auto reduce_params = get_default_params(arg); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/region_yolo_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/region_yolo_gpu.cpp index 5bbe70ce8ed00e..e5518f66cb8911 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/region_yolo_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/region_yolo_gpu.cpp @@ -8,7 +8,7 @@ #include "kernel_selector_helper.h" #include "region_yolo/region_yolo_kernel_selector.h" #include "region_yolo/region_yolo_kernel_ref.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" namespace cldnn { namespace gpu { @@ -17,6 +17,10 @@ struct region_yolo_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + static primitive_impl* create(const region_yolo_node& arg) { auto ry_params = get_default_params(arg); auto ry_optional_params = diff --git a/inference-engine/thirdparty/clDNN/src/gpu/register_gpu.hpp b/inference-engine/thirdparty/clDNN/src/gpu/register_gpu.hpp index 6bba0170822970..d6d2db15d6b617 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/register_gpu.hpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/register_gpu.hpp @@ -5,69 +5,69 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/activation.hpp" -#include "api/arg_max_min.hpp" -#include "api/average_unpooling.hpp" -#include "api/batch_to_space.hpp" -#include "api/binary_convolution.hpp" -#include "api/border.hpp" -#include "api/broadcast.hpp" -#include "api/concatenation.hpp" -#include "api/condition.hpp" -#include "api/convolution.hpp" -#include "api/crop.hpp" -#include "api/custom_gpu_primitive.hpp" -#include "api/data.hpp" -#include "api/deconvolution.hpp" -#include "api/depth_to_space.hpp" -#include "api/detection_output.hpp" -#include "api/eltwise.hpp" -#include "api/fully_connected.hpp" -#include "api/gather.hpp" -#include "api/gather_nd.hpp" -#include "api/gemm.hpp" -#include "api/input_layout.hpp" -#include "api/lrn.hpp" -#include "api/lstm.hpp" -#include "api/lstm_dynamic.hpp" -#include "api/max_unpooling.hpp" -#include "api/mutable_data.hpp" -#include "api/mvn.hpp" -#include "api/normalize.hpp" -#include "api/one_hot.hpp" -#include "api/permute.hpp" -#include "api/pooling.hpp" -#include "api/prior_box.hpp" -#include "api/proposal.hpp" -#include "api/pyramid_roi_align.hpp" -#include "api/quantize.hpp" -#include "api/reduce.hpp" -#include "api/region_yolo.hpp" -#include "api/reorder.hpp" -#include "api/reorg_yolo.hpp" -#include "api/reshape.hpp" -#include "api/reverse_sequence.hpp" -#include "api/roi_pooling.hpp" -#include "api/scale.hpp" -#include "api/scatter_update.hpp" -#include "api/scatter_elements_update.hpp" -#include "api/scatter_nd_update.hpp" -#include "api/select.hpp" -#include "api/shuffle_channels.hpp" -#include "api/softmax.hpp" -#include "api/space_to_batch.hpp" -#include "api/strided_slice.hpp" -#include "api/tile.hpp" -#include "api/resample.hpp" -#include "api/gather_tree.hpp" -#include "api_extension/fused_conv_eltwise.hpp" -#include "api_extension/lstm_dynamic_input.hpp" -#include "api_extension/lstm_dynamic_timeloop.hpp" +#include "cldnn/primitives/activation.hpp" +#include "cldnn/primitives/arg_max_min.hpp" +#include "cldnn/primitives/average_unpooling.hpp" +#include "cldnn/primitives/batch_to_space.hpp" +#include "cldnn/primitives/binary_convolution.hpp" +#include "cldnn/primitives/border.hpp" +#include "cldnn/primitives/broadcast.hpp" +#include "cldnn/primitives/concatenation.hpp" +#include "cldnn/primitives/condition.hpp" +#include "cldnn/primitives/convolution.hpp" +#include "cldnn/primitives/crop.hpp" +#include "cldnn/primitives/custom_gpu_primitive.hpp" +#include "cldnn/primitives/data.hpp" +#include "cldnn/primitives/deconvolution.hpp" +#include "cldnn/primitives/depth_to_space.hpp" +#include "cldnn/primitives/detection_output.hpp" +#include "cldnn/primitives/eltwise.hpp" +#include "cldnn/primitives/fully_connected.hpp" +#include "cldnn/primitives/gather.hpp" +#include "cldnn/primitives/gather_nd.hpp" +#include "cldnn/primitives/gemm.hpp" +#include "cldnn/primitives/input_layout.hpp" +#include "cldnn/primitives/lrn.hpp" +#include "cldnn/primitives/lstm.hpp" +#include "cldnn/primitives/lstm_dynamic.hpp" +#include "cldnn/primitives/max_unpooling.hpp" +#include "cldnn/primitives/mutable_data.hpp" +#include "cldnn/primitives/mvn.hpp" +#include "cldnn/primitives/normalize.hpp" +#include "cldnn/primitives/one_hot.hpp" +#include "cldnn/primitives/permute.hpp" +#include "cldnn/primitives/pooling.hpp" +#include "cldnn/primitives/prior_box.hpp" +#include "cldnn/primitives/proposal.hpp" +#include "cldnn/primitives/pyramid_roi_align.hpp" +#include "cldnn/primitives/quantize.hpp" +#include "cldnn/primitives/reduce.hpp" +#include "cldnn/primitives/region_yolo.hpp" +#include "cldnn/primitives/reorder.hpp" +#include "cldnn/primitives/reorg_yolo.hpp" +#include "cldnn/primitives/reshape.hpp" +#include "cldnn/primitives/reverse_sequence.hpp" +#include "cldnn/primitives/roi_pooling.hpp" +#include "cldnn/primitives/scale.hpp" +#include "cldnn/primitives/scatter_update.hpp" +#include "cldnn/primitives/scatter_elements_update.hpp" +#include "cldnn/primitives/scatter_nd_update.hpp" +#include "cldnn/primitives/select.hpp" +#include "cldnn/primitives/shuffle_channels.hpp" +#include "cldnn/primitives/softmax.hpp" +#include "cldnn/primitives/space_to_batch.hpp" +#include "cldnn/primitives/strided_slice.hpp" +#include "cldnn/primitives/tile.hpp" +#include "cldnn/primitives/resample.hpp" +#include "cldnn/primitives/gather_tree.hpp" +#include "cldnn/primitives/fused_conv_eltwise.hpp" +#include "cldnn/primitives/lstm_dynamic_input.hpp" +#include "cldnn/primitives/lstm_dynamic_timeloop.hpp" +#include "cldnn/primitives/non_max_suppression.hpp" +#include "cldnn/primitives/grn.hpp" +#include "cldnn/primitives/ctc_greedy_decoder.hpp" +#include "cldnn/primitives/loop.hpp" #include "generic_layer.hpp" -#include "api/non_max_suppression.hpp" -#include "api/grn.hpp" -#include "api/ctc_greedy_decoder.hpp" -#include "api/loop.hpp" namespace cldnn { namespace gpu { diff --git a/inference-engine/thirdparty/clDNN/src/gpu/reorder_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/reorder_gpu.cpp index e3961faaa000dc..93fafb1d14cb1d 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/reorder_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/reorder_gpu.cpp @@ -8,7 +8,7 @@ #include "kernel_selector_helper.h" #include "reorder/reorder_kernel_selector.h" #include "reorder/reorder_kernel_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" namespace cldnn { namespace gpu { @@ -17,20 +17,24 @@ struct reorder_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + protected: bool optimized_out(reorder_inst& instance) const override { return parent::optimized_out(instance) || _outer.can_be_optimized(); } - kernel::kernel_arguments_data get_arguments(reorder_inst& instance, int32_t split) const override { - kernel::kernel_arguments_data args = parent::get_arguments(instance, split); + kernel_arguments_data get_arguments(reorder_inst& instance, int32_t split) const override { + kernel_arguments_data args = parent::get_arguments(instance, split); auto input = &instance.input_memory(); auto input_layout = input->get_layout(); if (_outer.has_mean()) { if (input_layout.format == cldnn::format::nv12) { - args.bias = (memory_impl::cptr) &instance.mean_nv12_memory(); + args.bias = instance.mean_nv12_memory(); } else { - args.bias = (memory_impl::cptr) &instance.mean_memory(); + args.bias = instance.mean_memory(); } } return args; diff --git a/inference-engine/thirdparty/clDNN/src/gpu/reorg_yolo_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/reorg_yolo_gpu.cpp index b8badf3584e524..5cc78810ad4c8a 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/reorg_yolo_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/reorg_yolo_gpu.cpp @@ -8,7 +8,7 @@ #include "kernel_selector_helper.h" #include "reorg_yolo/reorg_yolo_kernel_selector.h" #include "reorg_yolo/reorg_yolo_kernel_ref.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" namespace cldnn { namespace gpu { @@ -17,6 +17,10 @@ struct reorg_yolo_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + static primitive_impl* create(const reorg_yolo_node& arg) { auto ry_params = get_default_params(arg); auto ry_optional_params = diff --git a/inference-engine/thirdparty/clDNN/src/gpu/resample_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/resample_gpu.cpp index 18697841ac478d..1ec432673ee4b0 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/resample_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/resample_gpu.cpp @@ -5,7 +5,7 @@ #include "resample_inst.h" #include "primitive_gpu_base.h" #include "implementation_map.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_selector_helper.h" #include "kernel_selector/core/actual_kernels/resample/resample_kernel_selector.h" #include "kernel_selector/core/actual_kernels/resample/resample_kernel_base.h" @@ -100,6 +100,10 @@ struct resample_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + static primitive_impl* create(const resample_node& arg) { auto us_params = get_default_params(arg); auto us_optional_params = diff --git a/inference-engine/thirdparty/clDNN/src/gpu/reshape_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/reshape_gpu.cpp index 04a89b42002b03..5a78f82cca122e 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/reshape_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/reshape_gpu.cpp @@ -8,7 +8,7 @@ #include "kernel_selector_helper.h" #include "reshape/reshape_kernel_ref.h" #include "reshape/reshape_kernel_selector.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" namespace cldnn { namespace gpu { @@ -17,6 +17,10 @@ struct reshape_gpu : public typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + public: static primitive_impl* create(reshape_node const& arg) { if (arg.can_be_optimized()) { diff --git a/inference-engine/thirdparty/clDNN/src/gpu/reverse_sequence_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/reverse_sequence_gpu.cpp index 01a03b9a251460..01d6aaf89334dd 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/reverse_sequence_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/reverse_sequence_gpu.cpp @@ -8,7 +8,7 @@ #include "kernel_selector_helper.h" #include "reverse_sequence/reverse_sequence_kernel_selector.h" #include "reverse_sequence/reverse_sequence_kernel_ref.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" using namespace cldnn; @@ -18,6 +18,10 @@ struct reverse_sequence_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + public: static primitive_impl* create(const reverse_sequence_node& arg) { auto reverse_sequence_params = get_default_params(arg); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/roi_pooling_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/roi_pooling_gpu.cpp index c8f1fde2290976..fef441b15b8ce1 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/roi_pooling_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/roi_pooling_gpu.cpp @@ -5,7 +5,7 @@ #include "roi_pooling_inst.h" #include "primitive_gpu_base.h" #include "implementation_map.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_selector_helper.h" #include "roi_pooling/roi_pooling_kernel_selector.h" #include "roi_pooling/roi_pooling_kernel_ref.h" @@ -37,20 +37,23 @@ struct roi_pooling_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + protected: - kernel::kernel_arguments_data get_arguments(typed_primitive_inst& instance, - int32_t) const override { - kernel::kernel_arguments_data args; + kernel_arguments_data get_arguments(typed_primitive_inst& instance, int32_t) const override { + kernel_arguments_data args; if (instance.argument.mode == pooling_mode::deformable_bilinear && !instance.argument.no_trans) args.inputs = { - (memory_impl::cptr) &instance.input_memory(), - (memory_impl::cptr) &instance.rois_memory(), - (memory_impl::cptr) &instance.trans_memory()}; + instance.input_memory_ptr(), + instance.rois_memory(), + instance.trans_memory()}; else - args.inputs = {(memory_impl::cptr) &instance.input_memory(), (memory_impl::cptr) &instance.rois_memory()}; + args.inputs = {instance.input_memory_ptr(), instance.rois_memory()}; - args.output = (memory_impl::cptr) &instance.output_memory(); + args.output = instance.output_memory_ptr(); return args; } diff --git a/inference-engine/thirdparty/clDNN/src/gpu/scale_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/scale_gpu.cpp index 0f6a91b3f546b8..cfdf1a3085cc41 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/scale_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/scale_gpu.cpp @@ -8,7 +8,7 @@ #include "kernel_selector_helper.h" #include "eltwise/eltwise_kernel_selector.h" #include "eltwise/eltwise_kernel_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" using namespace cldnn; @@ -19,14 +19,18 @@ struct scale_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + protected: - kernel::kernel_arguments_data get_arguments(typed_primitive_inst& instance, int32_t split) const override { - kernel::kernel_arguments_data args = parent::get_arguments(instance, split); - args.inputs = {(memory_impl::cptr) &instance.input_memory(), (memory_impl::cptr) &instance.scale_memory()}; - args.output = (memory_impl::cptr) &instance.output_memory(); + kernel_arguments_data get_arguments(typed_primitive_inst& instance, int32_t split) const override { + kernel_arguments_data args = parent::get_arguments(instance, split); + args.inputs = {instance.input_memory_ptr(), instance.scale_memory()}; + args.output = instance.output_memory_ptr(); if (_outer.bias_term()) { - args.inputs.push_back((memory_impl::cptr) &instance.bias_memory()); + args.inputs.push_back(instance.bias_memory()); } return args; } diff --git a/inference-engine/thirdparty/clDNN/src/gpu/scatter_elements_update_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/scatter_elements_update_gpu.cpp index 00d756142fddf5..85e482e02e0dff 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/scatter_elements_update_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/scatter_elements_update_gpu.cpp @@ -8,7 +8,7 @@ #include "kernel_selector_helper.h" #include "scatter_update/scatter_elements_update_kernel_selector.h" #include "scatter_update/scatter_elements_update_kernel_ref.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" using namespace cldnn; @@ -38,6 +38,10 @@ struct scatter_elements_update_gpu : typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + public: static primitive_impl* create(const scatter_elements_update_node& arg) { auto scatter_elements_update_params = get_default_params(arg); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/scatter_nd_update_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/scatter_nd_update_gpu.cpp index c9014120b51d65..445361bf5b85b7 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/scatter_nd_update_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/scatter_nd_update_gpu.cpp @@ -8,7 +8,7 @@ #include "kernel_selector_helper.h" #include "scatter_update/scatter_nd_update_kernel_selector.h" #include "scatter_update/scatter_nd_update_kernel_ref.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" using namespace cldnn; @@ -19,6 +19,10 @@ struct scatter_nd_update_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + public: static primitive_impl* create(const scatter_nd_update_node& arg) { auto scatter_nd_update_params = get_default_params(arg); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/scatter_update_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/scatter_update_gpu.cpp index 8bf3e7122a270a..10629a080909eb 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/scatter_update_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/scatter_update_gpu.cpp @@ -8,7 +8,7 @@ #include "kernel_selector_helper.h" #include "scatter_update/scatter_update_kernel_selector.h" #include "scatter_update/scatter_update_kernel_ref.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" using namespace cldnn; @@ -38,6 +38,10 @@ struct scatter_update_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + public: static primitive_impl* create(const scatter_update_node& arg) { auto scatter_update_params = get_default_params(arg); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/select_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/select_gpu.cpp index 88d088113054ac..09572da455a535 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/select_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/select_gpu.cpp @@ -5,7 +5,7 @@ #include "select_inst.h" #include "primitive_gpu_base.h" #include "implementation_map.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_selector_helper.h" #include "select/select_kernel_selector.h" #include "select/select_kernel_base.h" @@ -17,6 +17,10 @@ struct select_gpu : typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + public: static primitive_impl* create(const select_node& arg) { auto select_params = get_default_params(arg); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/shuffle_channels_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/shuffle_channels_gpu.cpp index 95a7705aa3a61f..b7a29684772e9b 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/shuffle_channels_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/shuffle_channels_gpu.cpp @@ -8,7 +8,7 @@ #include "kernel_selector_helper.h" #include "shuffle_channels/shuffle_channels_kernel_selector.h" #include "shuffle_channels/shuffle_channels_kernel_ref.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" using namespace cldnn; @@ -19,6 +19,10 @@ struct shuffle_channels_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + public: static primitive_impl* create(const shuffle_channels_node& arg) { auto shuffle_channels_params = get_default_params(arg); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/softmax_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/softmax_gpu.cpp index 70cdf63d3cff4d..868ca8913dde97 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/softmax_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/softmax_gpu.cpp @@ -8,7 +8,7 @@ #include "kernel_selector_helper.h" #include "softmax/softmax_kernel_selector.h" #include "softmax/softmax_kernel_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" namespace cldnn { namespace gpu { @@ -17,6 +17,10 @@ struct softmax_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + static primitive_impl* create(const softmax_node& arg) { auto sm_params = get_default_params(arg); auto sm_optional_params = diff --git a/inference-engine/thirdparty/clDNN/src/gpu/space_to_batch_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/space_to_batch_gpu.cpp index 5961ee1858cb5f..ebc97b591f28ea 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/space_to_batch_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/space_to_batch_gpu.cpp @@ -8,7 +8,7 @@ #include "kernel_selector_helper.h" #include "space_to_batch/space_to_batch_kernel_selector.h" #include "space_to_batch/space_to_batch_kernel_ref.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "data_inst.h" #include @@ -20,6 +20,10 @@ struct space_to_batch_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + public: static primitive_impl* create(const space_to_batch_node& arg) { auto space_to_batch_params = get_default_params(arg); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/space_to_depth_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/space_to_depth_gpu.cpp index 0866cebd143b0f..bf92acea8b4211 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/space_to_depth_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/space_to_depth_gpu.cpp @@ -8,7 +8,7 @@ #include "kernel_selector_helper.h" #include "space_to_depth/space_to_depth_kernel_selector.h" #include "space_to_depth/space_to_depth_kernel_ref.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" using namespace cldnn; @@ -18,6 +18,10 @@ struct space_to_depth_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + public: static primitive_impl* create(const space_to_depth_node& arg) { auto space_to_depth_params = get_default_params(arg); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/strided_slice_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/strided_slice_gpu.cpp index d78a08eef69fd5..d1ddf2d4d69db2 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/strided_slice_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/strided_slice_gpu.cpp @@ -8,7 +8,7 @@ #include "kernel_selector_helper.h" #include "strided_slice/strided_slice_kernel_ref.h" #include "strided_slice/strided_slice_kernel_selector.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "data_inst.h" #include @@ -21,6 +21,10 @@ struct strided_slice_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + public: static primitive_impl* create(const strided_slice_node& arg) { auto params = get_default_params(arg); @@ -30,21 +34,22 @@ struct strided_slice_gpu : typed_primitive_gpu_impl { // Getting data from constant inputs. There are 3 args: Begin, End, Stride for (size_t i = 1; i < arg.get_dependencies().size(); ++i) { auto& input = arg.get_dependency(i).as(); - auto& mem = input.get_attached_memory(); + auto mem = input.get_attached_memory_ptr(); std::vector sizes; if (input.get_output_layout().data_type == cldnn::data_types::i64) { - int64_t* data = static_cast(mem.lock()); + mem_lock lock{mem, arg.get_program().get_stream()}; + int64_t* data = lock.data(); std::vector sizes_i64 = std::vector(data, data + input.get_output_layout().count()); sizes.resize(sizes_i64.size()); for (size_t j = 0; j < sizes.size(); j++) sizes[j] = static_cast(sizes_i64[j]); } else { - int32_t* data = static_cast(mem.lock()); + mem_lock lock{mem, arg.get_program().get_stream()}; + int32_t* data = lock.data(); sizes = std::vector(data, data + input.get_output_layout().count()); } pad_vector_to_size(sizes, dims_num, i != 1); // for "begin" completion used 0 value, for other - 1 params.striding_params.push_back(sizes); - mem.unlock(); } params.end_mask = arg.get_primitive()->end_mask; diff --git a/inference-engine/thirdparty/clDNN/src/gpu/tile_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/tile_gpu.cpp index 02f95954f58e79..d508e2bea312dd 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/tile_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/tile_gpu.cpp @@ -8,7 +8,7 @@ #include "kernel_selector_helper.h" #include "tile/tile_kernel_selector.h" #include "tile/tile_kernel_ref.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" using namespace cldnn; @@ -19,6 +19,10 @@ struct tile_gpu : typed_primitive_gpu_impl { using parent = typed_primitive_gpu_impl; using parent::parent; + std::unique_ptr clone() const override { + return make_unique(*this); + } + public: static primitive_impl* create(const tile_node& arg) { auto tile_params = get_default_params(arg); diff --git a/inference-engine/thirdparty/clDNN/src/gpu/wait_for_events_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/wait_for_events_gpu.cpp index 38a822dca525d8..00c74080a38400 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/wait_for_events_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/wait_for_events_gpu.cpp @@ -10,7 +10,6 @@ #include "register_gpu.hpp" #include "network_impl.h" -#include "events_waiter.h" #include namespace cldnn { @@ -20,13 +19,16 @@ class wait_for_events_gpu : public primitive_impl { public: explicit wait_for_events_gpu(const program_node& /*node*/) {} + std::unique_ptr clone() const override { + return make_unique(*this); + } + + void init_kernels() override {} void set_arguments(primitive_inst& /*instance*/) override {} - void cleanup(primitive_inst& /*instance*/) override {} - event_impl::ptr execute(const std::vector& events, primitive_inst& instance) override { - uint32_t net_id = instance.get_network().get_id(); - events_waiter events_waiter(instance.get_network().get_engine().get_context()); - return events_waiter.run(net_id, events); + event::ptr execute(const std::vector& events, primitive_inst& instance) override { + auto& stream = instance.get_network().get_stream(); + return stream.enqueue_marker(events); } bool validate(const primitive_inst&) const override { return true; } diff --git a/inference-engine/thirdparty/clDNN/src/graph_optimizer/add_required_reorders.cpp b/inference-engine/thirdparty/clDNN/src/graph_optimizer/add_required_reorders.cpp index 7d61c77158d9d0..249325eaaccf75 100644 --- a/inference-engine/thirdparty/clDNN/src/graph_optimizer/add_required_reorders.cpp +++ b/inference-engine/thirdparty/clDNN/src/graph_optimizer/add_required_reorders.cpp @@ -49,7 +49,7 @@ void add_required_reorders::run(program_impl& p) { auto& usr = *usr_itr++; if (usr->get_dependencies().size() == 0) continue; // only nodes with dependencies - if (usr->is_type() || usr->is_type()) + if (usr->is_type()) continue; if (usr->type()->does_an_implementation_exist(p.get_engine(), *usr)) continue; diff --git a/inference-engine/thirdparty/clDNN/src/graph_optimizer/basic_memory_dependencies.cpp b/inference-engine/thirdparty/clDNN/src/graph_optimizer/basic_memory_dependencies.cpp index 540a81707aae69..1dd8b0af12adc1 100644 --- a/inference-engine/thirdparty/clDNN/src/graph_optimizer/basic_memory_dependencies.cpp +++ b/inference-engine/thirdparty/clDNN/src/graph_optimizer/basic_memory_dependencies.cpp @@ -9,7 +9,7 @@ #include "layout_optimizer.h" #include "program_impl.h" #include "program_helpers.h" -#include "cldnn_itt.h" +#include "runtime/cldnn_itt.hpp" #include #include #include diff --git a/inference-engine/thirdparty/clDNN/src/graph_optimizer/calculate_prior_boxes.cpp b/inference-engine/thirdparty/clDNN/src/graph_optimizer/calculate_prior_boxes.cpp index 387512cae04c2f..00f74be859345a 100644 --- a/inference-engine/thirdparty/clDNN/src/graph_optimizer/calculate_prior_boxes.cpp +++ b/inference-engine/thirdparty/clDNN/src/graph_optimizer/calculate_prior_boxes.cpp @@ -25,9 +25,8 @@ void calculate_prior_boxes::run(program_impl& p) { p.remove_connection(pb_node.input(), pb_node); auto result = pb_node.get_result_buffer(); - auto cpp_mem = memory(result.detach()); - auto& data_node = p.get_or_create(std::make_shared("_cldnn_tmp_" + pb_node.id() + "_result", cpp_mem)); + auto& data_node = p.get_or_create(std::make_shared("_cldnn_tmp_" + pb_node.id() + "_result", result)); p.replace(pb_node, data_node); } } diff --git a/inference-engine/thirdparty/clDNN/src/graph_optimizer/compile_graph.cpp b/inference-engine/thirdparty/clDNN/src/graph_optimizer/compile_graph.cpp index fe236c180d8c41..8c3335aecbb5bb 100644 --- a/inference-engine/thirdparty/clDNN/src/graph_optimizer/compile_graph.cpp +++ b/inference-engine/thirdparty/clDNN/src/graph_optimizer/compile_graph.cpp @@ -5,19 +5,18 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include "pass_manager.h" -#include "internal_primitive.h" #include "data_inst.h" #include "mutable_data_inst.h" #include "program_node.h" -#include "engine_impl.h" -#include "cldnn_itt.h" +#include "cldnn/runtime/engine.hpp" +#include "runtime/cldnn_itt.hpp" using namespace cldnn; void compile_graph::run(program_impl& p) { OV_ITT_SCOPED_TASK(itt::domains::CLDNN, "CLDNN::pass::CompileGraph"); for (auto& node : p.get_processing_order()) { - if (!node->is_type() && !node->is_type()) { + if (!node->is_type()) { node->get_output_layout(); if (!node->is_type() && !(node->is_type() && node->get_dependencies().empty())) { node->selected_impl = node->type()->choose_impl(p.get_engine(), *node); diff --git a/inference-engine/thirdparty/clDNN/src/graph_optimizer/concat_input_order.cpp b/inference-engine/thirdparty/clDNN/src/graph_optimizer/concat_input_order.cpp index 2e949169e3d35b..9acd92fc7266bb 100644 --- a/inference-engine/thirdparty/clDNN/src/graph_optimizer/concat_input_order.cpp +++ b/inference-engine/thirdparty/clDNN/src/graph_optimizer/concat_input_order.cpp @@ -9,7 +9,7 @@ #include "convolution_inst.h" #include "fully_connected_inst.h" #include "data_inst.h" -#include "memory_impl.h" +#include "cldnn/runtime/memory.hpp" #include "program_impl.h" #include @@ -21,7 +21,7 @@ namespace { using shuffle_range = std::pair; -bool can_shuffle_features(program_node& node) { +bool can_shuffle_features(program_node& node, stream& stream) { if (node.is_type()) { auto& conv_node = node.as(); auto& wei_node = conv_node.weights(); @@ -46,7 +46,7 @@ bool can_shuffle_features(program_node& node) { if (pass_through) { // Primitives that are feature order invariant, pass-through shuffled features to users for (auto& user : node.get_users()) { - if (!can_shuffle_features(*user)) + if (!can_shuffle_features(*user, stream)) return false; } return true; @@ -55,17 +55,19 @@ bool can_shuffle_features(program_node& node) { return false; } -void shuffle_weights(data_node& node, const std::vector& ranges) { +void shuffle_weights(data_node& node, const std::vector& ranges, stream& stream) { // Correct for shuffled features by shuffling input feature dimension in weights. // This allows to restore correct feature order on output and only changes calculation order. auto wei_layout = node.get_output_layout(); - auto& old_weights_memory = node.get_attached_memory(); + auto old_weights_memory = node.get_attached_memory_ptr(); bool need_reset = static_cast(wei_layout.data_padding) || wei_layout.format.is_blocked(); - auto new_weights_memory = old_weights_memory.get_engine()->allocate_memory(wei_layout, old_weights_memory.get_net_id(), need_reset); + auto new_weights_memory = old_weights_memory->get_engine()->allocate_memory(wei_layout, old_weights_memory->get_allocation_type(), need_reset); auto bytes_per_elem = data_type_traits::size_of(wei_layout.data_type); - auto old_ptr = static_cast(old_weights_memory.lock()); - auto new_ptr = static_cast(new_weights_memory->lock()); + mem_lock old_weights_memory_lock{old_weights_memory, stream}; + mem_lock new_weights_memory_lock{new_weights_memory, stream}; + auto old_ptr = old_weights_memory_lock.data(); + auto new_ptr = new_weights_memory_lock.data(); for (int32_t ofi = 0; ofi < wei_layout.size.batch[0]; ++ofi) { int32_t new_ifi = 0; for (auto& range : ranges) { @@ -88,23 +90,21 @@ void shuffle_weights(data_node& node, const std::vector& ranges) } } } - old_weights_memory.unlock(); - new_weights_memory->unlock(); - node.attach_memory(*new_weights_memory, false); + node.attach_memory(new_weights_memory, false); } -void shuffle_features(program_node& node, const std::vector& ranges) { +void shuffle_features(program_node& node, const std::vector& ranges, stream& stream) { if (node.is_type()) { auto& conv = node.as(); - shuffle_weights(conv.weights().as(), ranges); + shuffle_weights(conv.weights().as(), ranges, stream); } else if (node.is_type()) { auto& fc = node.as(); - shuffle_weights(fc.weights().as(), ranges); + shuffle_weights(fc.weights().as(), ranges, stream); } else { // General case for pass-through layers for (auto& user : node.get_users()) { - shuffle_features(*user, ranges); + shuffle_features(*user, ranges, stream); } } } @@ -155,7 +155,7 @@ void concat_input_order::run(program_impl& p) { // Check that we can fuse shuffling to users bool can_shuffle_users = true; for (auto user : concat_node.get_users()) { - can_shuffle_users &= can_shuffle_features(*user); + can_shuffle_users &= can_shuffle_features(*user, p.get_stream()); } if (!along_f || !no_fusing || !correct_format || !single_format || already_aligned || !can_shuffle_users) @@ -207,8 +207,7 @@ void concat_input_order::run(program_impl& p) { mutable_prim->input = new_input_ids; // Correct users for shuffled features for (auto& user : concat_node.get_users()) { - shuffle_features(*user, shuffled_ranges); + shuffle_features(*user, shuffled_ranges, p.get_stream()); } } } - diff --git a/inference-engine/thirdparty/clDNN/src/graph_optimizer/eltwise_remove_stride.cpp b/inference-engine/thirdparty/clDNN/src/graph_optimizer/eltwise_remove_stride.cpp index c30a3348548f5c..b0c28bd93a60d0 100644 --- a/inference-engine/thirdparty/clDNN/src/graph_optimizer/eltwise_remove_stride.cpp +++ b/inference-engine/thirdparty/clDNN/src/graph_optimizer/eltwise_remove_stride.cpp @@ -4,7 +4,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// -#include "api/tensor.hpp" +#include "cldnn/runtime/tensor.hpp" #include "pass_manager.h" diff --git a/inference-engine/thirdparty/clDNN/src/graph_optimizer/handle_input_padding.cpp b/inference-engine/thirdparty/clDNN/src/graph_optimizer/handle_input_padding.cpp index 137ced81fc25aa..84496690536dca 100644 --- a/inference-engine/thirdparty/clDNN/src/graph_optimizer/handle_input_padding.cpp +++ b/inference-engine/thirdparty/clDNN/src/graph_optimizer/handle_input_padding.cpp @@ -7,7 +7,7 @@ #include "pass_manager.h" #include "border_inst.h" #include "convolution_inst.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include using namespace cldnn; @@ -113,4 +113,4 @@ void handle_input_padding::run(program_impl& p) { } } } -} \ No newline at end of file +} diff --git a/inference-engine/thirdparty/clDNN/src/graph_optimizer/oooq_memory_dependencies.cpp b/inference-engine/thirdparty/clDNN/src/graph_optimizer/oooq_memory_dependencies.cpp index 380b18b951f66a..ccf9903701a897 100644 --- a/inference-engine/thirdparty/clDNN/src/graph_optimizer/oooq_memory_dependencies.cpp +++ b/inference-engine/thirdparty/clDNN/src/graph_optimizer/oooq_memory_dependencies.cpp @@ -9,7 +9,7 @@ #include "layout_optimizer.h" #include "program_impl.h" #include "program_helpers.h" -#include "cldnn_itt.h" +#include "runtime/cldnn_itt.hpp" #include #include #include diff --git a/inference-engine/thirdparty/clDNN/src/graph_optimizer/post_input_reorder.cpp b/inference-engine/thirdparty/clDNN/src/graph_optimizer/post_input_reorder.cpp index f98eabd2cf6514..b4371112d11767 100644 --- a/inference-engine/thirdparty/clDNN/src/graph_optimizer/post_input_reorder.cpp +++ b/inference-engine/thirdparty/clDNN/src/graph_optimizer/post_input_reorder.cpp @@ -45,9 +45,8 @@ void post_input_reorder::run(program_impl& p) { const auto impl = node->get_selected_impl(); // add a reorder if primitive's input format doesn't match implementation's input format if (node->is_type()) { - const auto& fc_impl = dynamic_cast&>(*impl); - const auto& fc_params = - *static_cast(fc_impl._kernel_data.params.get()); + const auto& fc_impl = dynamic_cast&>(*impl); + const auto& fc_params = *static_cast(fc_impl._kernel_data.params.get()); auto layout_format = from_data_layout(fc_params.inputs[0].GetLayout()); auto& input = node->get_dependencies()[0]; diff --git a/inference-engine/thirdparty/clDNN/src/graph_optimizer/post_optimize_weights.cpp b/inference-engine/thirdparty/clDNN/src/graph_optimizer/post_optimize_weights.cpp index 271293e4dc43ea..85ea94cd476c8b 100644 --- a/inference-engine/thirdparty/clDNN/src/graph_optimizer/post_optimize_weights.cpp +++ b/inference-engine/thirdparty/clDNN/src/graph_optimizer/post_optimize_weights.cpp @@ -6,7 +6,7 @@ #include "pass_manager.h" #include "program_helpers.h" -#include "api_extension/fused_conv_eltwise.hpp" +#include "cldnn/primitives/fused_conv_eltwise.hpp" #include "include/fused_conv_eltwise_inst.h" #include "include/binary_convolution_inst.h" #include "include/deformable_convolution_inst.h" @@ -36,7 +36,7 @@ post_optimize_weights::weights_bias_offset post_optimize_weights::get_weights_bi template void post_optimize_weights::optimize_weights(T& node, program_impl& p) { auto offsets = get_weights_bias_offset(node); - auto* impl = node.get_selected_impl().get(); + auto impl = node.get_selected_impl(); auto output_layout = node.get_output_layout(); auto& weights_reorder_params = impl->_weights_reorder_params; diff --git a/inference-engine/thirdparty/clDNN/src/graph_optimizer/pre_replace_deconv.cpp b/inference-engine/thirdparty/clDNN/src/graph_optimizer/pre_replace_deconv.cpp index 874eedb91ce759..ccb00d3726e5b6 100644 --- a/inference-engine/thirdparty/clDNN/src/graph_optimizer/pre_replace_deconv.cpp +++ b/inference-engine/thirdparty/clDNN/src/graph_optimizer/pre_replace_deconv.cpp @@ -16,10 +16,13 @@ #include #include #include -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" void pre_replace_deconv::run(program_impl& p) { bool update_processing_order = false; + + auto& stream = p.get_stream(); + auto itr = p.nodes_map.begin(); while (itr != p.nodes_map.end()) { auto node_itr = itr++; @@ -242,16 +245,16 @@ void pre_replace_deconv::run(program_impl& p) { auto target_weights_layout = layout{ weights_layout.data_type, weights_layout.format, target_weights_size }; { - memory_impl::ptr data_to_allocate = p.get_engine().allocate_memory(target_weights_layout, 0); + memory::ptr data_to_allocate = p.get_engine().allocate_memory(target_weights_layout); std::vector weights_vec_float; if (weights_data_type == data_types::f16) { - mem_lock src{ cur_weights_node_ptr->as().get_attached_memory() }; + mem_lock src{ cur_weights_node_ptr->as().get_attached_memory_ptr(), stream }; for (uint32_t i = 0; i < weights_layout.size.count(); i++) weights_vec_float.push_back(static_cast(src.data()[i])); } else { - mem_lock src{ cur_weights_node_ptr->as().get_attached_memory() }; + mem_lock src{ cur_weights_node_ptr->as().get_attached_memory_ptr(), stream }; for (uint32_t i = 0; i < weights_layout.size.count(); i++) weights_vec_float.push_back(src.data()[i]); } @@ -266,17 +269,16 @@ void pre_replace_deconv::run(program_impl& p) { subpixel_weights); if (weights_data_type == data_types::f16) { - mem_lock dst{ data_to_allocate }; + mem_lock dst{ data_to_allocate, stream}; program_helpers::set_weights_values(dst.data(), subpixel_weights); } else if (weights_data_type == data_types::f32) { - mem_lock dst{ data_to_allocate }; + mem_lock dst{ data_to_allocate, stream }; program_helpers::set_weights_values(dst.data(), subpixel_weights); } else { throw std::logic_error("Not supported data type."); } - memory api_memory = memory(data_to_allocate.detach()); - auto data_node_weights_replace = std::make_shared(weights_vec[0] + "_conv_rpl", api_memory); + auto data_node_weights_replace = std::make_shared(weights_vec[0] + "_conv_rpl", data_to_allocate); p.get_or_create(data_node_weights_replace); auto data_node_weights_replace_node_ptr = p.nodes_map.find(weights_vec[0] + "_conv_rpl")->second; auto& data_node = data_node_weights_replace_node_ptr->as(); @@ -285,10 +287,10 @@ void pre_replace_deconv::run(program_impl& p) { float bias = 0; if (bias_data_type == data_types::f16) { - mem_lock src{ bias_id_node_ptr->as().get_attached_memory() }; + mem_lock src{ bias_id_node_ptr->as().get_attached_memory_ptr(), stream }; bias = static_cast(src.data()[0]); } else { - mem_lock src{ bias_id_node_ptr->as().get_attached_memory() }; + mem_lock src{ bias_id_node_ptr->as().get_attached_memory_ptr(), stream }; bias = src.data()[0]; } diff --git a/inference-engine/thirdparty/clDNN/src/graph_optimizer/prepare_buffer_fusing.cpp b/inference-engine/thirdparty/clDNN/src/graph_optimizer/prepare_buffer_fusing.cpp index abd9985cb72292..eebd65149ad27a 100644 --- a/inference-engine/thirdparty/clDNN/src/graph_optimizer/prepare_buffer_fusing.cpp +++ b/inference-engine/thirdparty/clDNN/src/graph_optimizer/prepare_buffer_fusing.cpp @@ -4,8 +4,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// -#include "api/eltwise.hpp" -#include "api/pooling.hpp" +#include "pooling_inst.h" #include "fused_conv_eltwise_inst.h" #include "primitive_inst.h" #include "activation_inst.h" diff --git a/inference-engine/thirdparty/clDNN/src/graph_optimizer/prepare_primitive_fusing.cpp b/inference-engine/thirdparty/clDNN/src/graph_optimizer/prepare_primitive_fusing.cpp index 8dc449053ce22a..ffabb96f2e40bf 100644 --- a/inference-engine/thirdparty/clDNN/src/graph_optimizer/prepare_primitive_fusing.cpp +++ b/inference-engine/thirdparty/clDNN/src/graph_optimizer/prepare_primitive_fusing.cpp @@ -4,13 +4,12 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// -#include "api/pooling.hpp" -#include "api/proposal.hpp" -#include "api/roi_pooling.hpp" - #include "program_helpers.h" #include "pass_manager.h" +#include "pooling_inst.h" +#include "proposal_inst.h" +#include "roi_pooling_inst.h" #include "quantize_inst.h" #include "binary_convolution_inst.h" #include "activation_inst.h" @@ -51,7 +50,7 @@ #include #include #include -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" void prepare_primitive_fusing::run(program_impl& p) { fuse_reorders(p); @@ -1334,24 +1333,16 @@ void prepare_conv_eltw_read_write_opt::conv_eltwise_read_write_opt(program_impl& // buffer shared between primitives, if second input is mutable data, then we can reuse this memory auto shared_buffer_mem = second_input_node->is_type() ? second_input_node->as().get_attached_memory_ptr() - : p.get_engine().allocate_memory(node->get_output_layout(), 0); - - float zero = 0.0f; - layout dummy_layout(data_types::f32, format::bfyx, tensor(1, 1, 1, 1)); + : p.get_engine().allocate_memory(node->get_output_layout()); // this one is the first one to write data to - auto rw_output_prim0 = std::make_shared(fused_conv_eltw_node->id() + "_RW_OPT_use", - memory::attach(dummy_layout, &zero, 1)); + auto rw_output_prim0 = std::make_shared(fused_conv_eltw_node->id() + "_RW_OPT_use", shared_buffer_mem); // this one already expects data to be inside - auto rw_output_prim1 = std::make_shared(fused_conv_eltw_node->id() + "_RW_OPT_reuse", - memory::attach(dummy_layout, &zero, 1)); + auto rw_output_prim1 = std::make_shared(fused_conv_eltw_node->id() + "_RW_OPT_reuse", shared_buffer_mem); auto& rw_output_node0 = p.get_or_create(rw_output_prim0); auto& rw_output_node1 = p.get_or_create(rw_output_prim1); - rw_output_node0.as().attach_memory(*shared_buffer_mem, false); - rw_output_node1.as().attach_memory(*shared_buffer_mem, false); - // add connection between second input node -> rw_output_node0 -> node p.add_intermediate(rw_output_node0, *node, 1, true); // replace other connections with rw_output_node0 diff --git a/inference-engine/thirdparty/clDNN/src/graph_optimizer/prepare_quantization.cpp b/inference-engine/thirdparty/clDNN/src/graph_optimizer/prepare_quantization.cpp index 134494d2ba7f2e..35d31d3a71d211 100644 --- a/inference-engine/thirdparty/clDNN/src/graph_optimizer/prepare_quantization.cpp +++ b/inference-engine/thirdparty/clDNN/src/graph_optimizer/prepare_quantization.cpp @@ -4,11 +4,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// -#include "api/quantize.hpp" -#include "api/binary_convolution.hpp" -#include "api/scale.hpp" -#include "api/pooling.hpp" - +#include "pooling_inst.h" #include "quantize_inst.h" #include "binary_convolution_inst.h" #include "scale_inst.h" @@ -16,10 +12,10 @@ #include "data_inst.h" #include "pass_manager.h" #include "program_helpers.h" -#include #include "to_string_utils.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" +#include #include #include #include @@ -46,19 +42,23 @@ void prepare_quantization::prepare_packed_quantize(program_impl& p) { auto &input_low = input_low_node.as(); auto &input_high = input_high_node.as(); - auto &mem_input_low = input_low.get_attached_memory(); - auto &mem_input_high = input_high.get_attached_memory(); + auto mem_input_low = input_low.get_attached_memory_ptr(); + auto mem_input_high = input_high.get_attached_memory_ptr(); auto output_dt = quantize_node.get_output_layout().data_type; + auto& stream = p.get_stream(); + if (levels == 2) { bool is_binarization = true; - switch (mem_input_high.get_layout().data_type) { + switch (mem_input_high->get_layout().data_type) { case data_types::f32: { - auto data_input_low = static_cast(mem_input_low.lock()); - auto data_input_high = static_cast(mem_input_high.lock()); + mem_lock data_input_low_lock{mem_input_low, stream}; + mem_lock data_input_high_lock{mem_input_high, stream}; + auto data_input_low = data_input_low_lock.data(); + auto data_input_high = data_input_high_lock.data(); - for (size_t i = 0; i < mem_input_high.get_layout().count(); i++) { + for (size_t i = 0; i < mem_input_high->get_layout().count(); i++) { if (data_input_high[i] != data_input_low[i]) { is_binarization = false; break; @@ -67,10 +67,12 @@ void prepare_quantization::prepare_packed_quantize(program_impl& p) { break; } case data_types::f16: { - auto data_input_low = static_cast(mem_input_low.lock()); - auto data_input_high = static_cast(mem_input_high.lock()); + mem_lock data_input_low_lock{mem_input_low, stream}; + mem_lock data_input_high_lock{mem_input_high, stream}; + auto data_input_low = data_input_low_lock.data(); + auto data_input_high = data_input_high_lock.data(); - for (size_t i = 0; i < mem_input_high.get_layout().count(); i++) { + for (size_t i = 0; i < mem_input_high->get_layout().count(); i++) { if (data_input_high[i] != data_input_low[i]) { is_binarization = false; break; @@ -81,8 +83,6 @@ void prepare_quantization::prepare_packed_quantize(program_impl& p) { default: CLDNN_ERROR_MESSAGE(node->id(), "prepare_quantization: Unsupported precision of quantize inputs"); } - mem_input_low.unlock(); - mem_input_high.unlock(); if (is_binarization) { output_dt = data_types::bin; @@ -106,6 +106,8 @@ void prepare_quantization::prepare_scale_shift_opt(program_impl &p) { if (levels == 2 || levels > 256 || quantize_node.get_scale_shift_opt() || quantize_node.is_constant()) return; + auto& stream = p.get_stream(); + program_node &input_low_node = quantize_node.get_dependency(1); program_node &input_high_node = quantize_node.get_dependency(2); program_node &output_low_node = quantize_node.get_dependency(3); @@ -121,20 +123,20 @@ void prepare_quantization::prepare_scale_shift_opt(program_impl &p) { auto &output_low = output_low_node.as(); auto &output_high = output_high_node.as(); - auto &mem_input_low = input_low.get_attached_memory(); - auto &mem_input_high = input_high.get_attached_memory(); - auto &mem_output_low = output_low.get_attached_memory(); - auto &mem_output_high = output_high.get_attached_memory(); + auto mem_input_low = input_low.get_attached_memory_ptr(); + auto mem_input_high = input_high.get_attached_memory_ptr(); + auto mem_output_low = output_low.get_attached_memory_ptr(); + auto mem_output_high = output_high.get_attached_memory_ptr(); - auto scales_layout = mem_input_low.get_layout(); - scales_layout.size = tensor::max(scales_layout.size, mem_input_high.get_layout().size); - scales_layout.size = tensor::max(scales_layout.size, mem_output_low.get_layout().size); - scales_layout.size = tensor::max(scales_layout.size, mem_output_high.get_layout().size); + auto scales_layout = mem_input_low->get_layout(); + scales_layout.size = tensor::max(scales_layout.size, mem_input_high->get_layout().size); + scales_layout.size = tensor::max(scales_layout.size, mem_output_low->get_layout().size); + scales_layout.size = tensor::max(scales_layout.size, mem_output_high->get_layout().size); - auto mem_input_scale = p.get_engine().allocate_memory(scales_layout, mem_input_low.get_net_id(), false); - auto mem_input_shift = p.get_engine().allocate_memory(scales_layout, mem_input_high.get_net_id(), false); - auto mem_output_scale = p.get_engine().allocate_memory(scales_layout, mem_output_low.get_net_id(), false); - auto mem_output_shift = p.get_engine().allocate_memory(scales_layout, mem_output_high.get_net_id(), false); + auto mem_input_scale = p.get_engine().allocate_memory(scales_layout, false); + auto mem_input_shift = p.get_engine().allocate_memory(scales_layout, false); + auto mem_output_scale = p.get_engine().allocate_memory(scales_layout, false); + auto mem_output_shift = p.get_engine().allocate_memory(scales_layout, false); auto get_offset_safe = [](layout l, tensor idx) -> int { auto sizes = l.size; @@ -164,17 +166,26 @@ void prepare_quantization::prepare_scale_shift_opt(program_impl &p) { float out_shift_val = 0.0f; float in_lo_val = 0.0f; float in_hi_val = 0.0f; - switch (mem_output_high.get_layout().data_type) { + switch (mem_output_high->get_layout().data_type) { case data_types::f32: { // TODO [LOW PRECISION]: Output low/high values can be removed. - auto data_input_low = static_cast(mem_input_low.lock()); - auto data_input_high = static_cast(mem_input_high.lock()); - auto data_output_low = static_cast(mem_output_low.lock()); - auto data_output_high = static_cast(mem_output_high.lock()); - auto data_input_scale = static_cast(mem_input_scale->lock()); - auto data_input_shift = static_cast(mem_input_shift->lock()); - auto data_output_scale = static_cast(mem_output_scale->lock()); - auto data_output_shift = static_cast(mem_output_shift->lock()); + mem_lock data_input_low_lock{mem_input_low, stream}; + mem_lock data_input_high_lock{mem_input_high, stream}; + mem_lock data_output_low_lock{mem_output_low, stream}; + mem_lock data_output_high_lock{mem_output_high, stream}; + mem_lock data_input_scale_lock{mem_input_scale, stream}; + mem_lock data_input_shift_lock{mem_input_shift, stream}; + mem_lock data_output_scale_lock{mem_output_scale, stream}; + mem_lock data_output_shift_lock{mem_output_shift, stream}; + + auto data_input_low = data_input_low_lock.data(); + auto data_input_high = data_input_high_lock.data(); + auto data_output_low = data_output_low_lock.data(); + auto data_output_high = data_output_high_lock.data(); + auto data_input_scale = data_input_scale_lock.data(); + auto data_input_shift = data_input_shift_lock.data(); + auto data_output_scale = data_output_scale_lock.data(); + auto data_output_shift = data_output_shift_lock.data(); for (int b = 0; b < scales_layout.size.batch[0]; b++) { for (int f = 0; f < scales_layout.size.feature[0]; f++) { @@ -182,11 +193,11 @@ void prepare_quantization::prepare_scale_shift_opt(program_impl &p) { for (int x = 0; x < scales_layout.size.spatial[0]; x++) { auto idx = cldnn::tensor(format::bfyx, {b, f, y, x}, 0); auto s_offset = scales_layout.get_linear_offset(idx); - auto in_lo = data_input_low[get_offset_safe(mem_input_low.get_layout(), idx)]; - auto in_hi = data_input_high[get_offset_safe(mem_input_high.get_layout(), idx)]; + auto in_lo = data_input_low[get_offset_safe(mem_input_low->get_layout(), idx)]; + auto in_hi = data_input_high[get_offset_safe(mem_input_high->get_layout(), idx)]; - auto out_lo = data_output_low[get_offset_safe(mem_output_low.get_layout(), idx)]; - auto out_hi = data_output_high[get_offset_safe(mem_output_high.get_layout(), idx)]; + auto out_lo = data_output_low[get_offset_safe(mem_output_low->get_layout(), idx)]; + auto out_hi = data_output_high[get_offset_safe(mem_output_high->get_layout(), idx)]; data_input_scale[s_offset] = (static_cast(levels) - 1) / (in_hi - in_lo); data_input_shift[s_offset] = - in_lo * (static_cast(levels) - 1) / (in_hi - in_lo); data_output_scale[s_offset] = (out_hi - out_lo) / (static_cast(levels) - 1); @@ -225,21 +236,30 @@ void prepare_quantization::prepare_scale_shift_opt(program_impl &p) { if (data_input_shift[i] != 0.0f) need_pre_shift = true; - if (in_lo_val != data_input_low[i % mem_input_low.get_layout().count()] || - in_hi_val != data_input_high[i % mem_input_high.get_layout().count()]) + if (in_lo_val != data_input_low[i % mem_input_low->get_layout().count()] || + in_hi_val != data_input_high[i % mem_input_high->get_layout().count()]) per_tensor_in_range = false; } break; } case data_types::f16: { - auto data_input_low = static_cast(mem_input_low.lock()); - auto data_input_high = static_cast(mem_input_high.lock()); - auto data_output_low = static_cast(mem_output_low.lock()); - auto data_output_high = static_cast(mem_output_high.lock()); - auto data_input_scale = static_cast(mem_input_scale->lock()); - auto data_input_shift = static_cast(mem_input_shift->lock()); - auto data_output_scale = static_cast(mem_output_scale->lock()); - auto data_output_shift = static_cast(mem_output_shift->lock()); + mem_lock data_input_low_lock{mem_input_low, stream}; + mem_lock data_input_high_lock{mem_input_high, stream}; + mem_lock data_output_low_lock{mem_output_low, stream}; + mem_lock data_output_high_lock{mem_output_high, stream}; + mem_lock data_input_scale_lock{mem_input_scale, stream}; + mem_lock data_input_shift_lock{mem_input_shift, stream}; + mem_lock data_output_scale_lock{mem_output_scale, stream}; + mem_lock data_output_shift_lock{mem_output_shift, stream}; + + auto data_input_low = data_input_low_lock.data(); + auto data_input_high = data_input_high_lock.data(); + auto data_output_low = data_output_low_lock.data(); + auto data_output_high = data_output_high_lock.data(); + auto data_input_scale = data_input_scale_lock.data(); + auto data_input_shift = data_input_shift_lock.data(); + auto data_output_scale = data_output_scale_lock.data(); + auto data_output_shift = data_output_shift_lock.data(); for (int b = 0; b < scales_layout.size.batch[0]; b++) { for (int f = 0; f < scales_layout.size.feature[0]; f++) { @@ -247,11 +267,11 @@ void prepare_quantization::prepare_scale_shift_opt(program_impl &p) { for (int x = 0; x < scales_layout.size.spatial[0]; x++) { auto idx = cldnn::tensor(format::bfyx, {b, f, y, x}, 0); auto s_offset = scales_layout.get_linear_offset(idx); - auto in_lo = half_to_float(data_input_low[get_offset_safe(mem_input_low.get_layout(), idx)]); - auto in_hi = half_to_float(data_input_high[get_offset_safe(mem_input_high.get_layout(), idx)]); + auto in_lo = half_to_float(data_input_low[get_offset_safe(mem_input_low->get_layout(), idx)]); + auto in_hi = half_to_float(data_input_high[get_offset_safe(mem_input_high->get_layout(), idx)]); - auto out_lo = half_to_float(data_output_low[get_offset_safe(mem_output_low.get_layout(), idx)]); - auto out_hi = half_to_float(data_output_high[get_offset_safe(mem_output_high.get_layout(), idx)]); + auto out_lo = half_to_float(data_output_low[get_offset_safe(mem_output_low->get_layout(), idx)]); + auto out_hi = half_to_float(data_output_high[get_offset_safe(mem_output_high->get_layout(), idx)]); data_input_scale[s_offset] = float_to_half((static_cast(levels) - 1) / (in_hi - in_lo)); data_input_shift[s_offset] = float_to_half(- in_lo * (static_cast(levels) - 1) / (in_hi - in_lo)); data_output_scale[s_offset] = float_to_half((out_hi - out_lo) / (static_cast(levels) - 1)); @@ -289,8 +309,8 @@ void prepare_quantization::prepare_scale_shift_opt(program_impl &p) { if (half_to_float(data_input_shift[i]) != 0.0f) need_pre_shift = true; - if (in_lo_val != half_to_float(data_input_low[i % mem_input_low.get_layout().count()]) || - in_hi_val != half_to_float(data_input_high[i % mem_input_high.get_layout().count()])) + if (in_lo_val != half_to_float(data_input_low[i % mem_input_low->get_layout().count()]) || + in_hi_val != half_to_float(data_input_high[i % mem_input_high->get_layout().count()])) per_tensor_in_range = false; } break; @@ -303,22 +323,15 @@ void prepare_quantization::prepare_scale_shift_opt(program_impl &p) { return; } - layout dummy_layout(data_types::f32, format::bfyx, tensor(1, 1, 1, 1)); - float zero = 0.f; - auto in_scale_prim = std::make_shared(quantize_node.id() + "_in_scale", memory::attach(dummy_layout, &zero, 1)); - auto in_shift_prim = std::make_shared(quantize_node.id() + "_in_shift", memory::attach(dummy_layout, &zero, 1)); - auto out_scale_prim = std::make_shared(quantize_node.id() + "_output_scale", memory::attach(dummy_layout, &zero, 1)); - auto out_shift_prim = std::make_shared(quantize_node.id() + "_output_shift", memory::attach(dummy_layout, &zero, 1)); + auto in_scale_prim = std::make_shared(quantize_node.id() + "_in_scale", mem_input_scale); + auto in_shift_prim = std::make_shared(quantize_node.id() + "_in_shift", mem_input_shift); + auto out_scale_prim = std::make_shared(quantize_node.id() + "_output_scale", mem_output_scale); + auto out_shift_prim = std::make_shared(quantize_node.id() + "_output_shift", mem_output_shift); auto& in_scale_node = p.get_or_create(in_scale_prim); auto& in_shift_node = p.get_or_create(in_shift_prim); auto& out_scale_node = p.get_or_create(out_scale_prim); auto& out_shift_node = p.get_or_create(out_shift_prim); - in_scale_node.as().attach_memory(*mem_input_scale); - in_shift_node.as().attach_memory(*mem_input_shift); - out_scale_node.as().attach_memory(*mem_output_scale); - out_shift_node.as().attach_memory(*mem_output_shift); - auto& inputs = p.get_inputs(); inputs.push_back(&in_scale_node); @@ -381,15 +394,6 @@ void prepare_quantization::prepare_scale_shift_opt(program_impl &p) { quantize_node.set_per_tensor_output_shift(); quantize_node.set_output_shift_val(out_shift_val); } - - mem_input_low.unlock(); - mem_input_high.unlock(); - mem_output_low.unlock(); - mem_output_high.unlock(); - mem_input_scale->unlock(); - mem_input_shift->unlock(); - mem_output_scale->unlock(); - mem_output_shift->unlock(); }); } } @@ -453,6 +457,8 @@ void prepare_quantization::prepare_asymmetric_quantization(program_impl &p) { auto node_itr = itr++; auto& node = (*node_itr); + auto& stream = p.get_stream(); + // Detects if given eltwise node performs zero point subtraction auto is_zero_point_node = [](eltwise_node& node) -> bool { auto prim = node.get_primitive(); @@ -480,8 +486,7 @@ void prepare_quantization::prepare_asymmetric_quantization(program_impl &p) { return true; }; - auto fill_compensation = [&](int groups, memory_impl* w, memory_impl* azp, memory_impl* wzp, - memory_impl::ptr compensation) { + auto fill_compensation = [&](int groups, const memory::ptr w, const memory::ptr azp, const memory::ptr wzp, memory::ptr compensation) { auto wl = w->get_layout(); int GS = groups; @@ -492,40 +497,40 @@ void prepare_quantization::prepare_asymmetric_quantization(program_impl &p) { auto w_dt = wl.data_type; auto azp_dt = azp->get_layout().data_type; - mem_lock comp_lock{compensation}; + mem_lock comp_lock{compensation, stream}; if (w_dt == data_types::u8 && azp_dt == data_types::u8) { - mem_lock w_lock(*w); - mem_lock azp_lock(*azp); + mem_lock w_lock(w, stream); + mem_lock azp_lock(azp, stream); if (wzp) { - mem_lock wzp_lock(*wzp); + mem_lock wzp_lock(wzp, stream); fill_compensation_typed(w_lock.data(), azp_lock.data(), wzp_lock.data(), comp_lock.data(), GS, OC, IC, KS); } else { fill_compensation_typed(w_lock.data(), azp_lock.data(), static_cast(nullptr), comp_lock.data(), GS, OC, IC, KS); } } else if (w_dt == data_types::i8 && azp_dt == data_types::u8) { - mem_lock w_lock(*w); - mem_lock azp_lock(*azp); + mem_lock w_lock(w, stream); + mem_lock azp_lock(azp, stream); if (wzp) { - mem_lock wzp_lock(*wzp); + mem_lock wzp_lock(wzp, stream); fill_compensation_typed(w_lock.data(), azp_lock.data(), wzp_lock.data(), comp_lock.data(), GS, OC, IC, KS); } else { fill_compensation_typed(w_lock.data(), azp_lock.data(), static_cast(nullptr), comp_lock.data(), GS, OC, IC, KS); } } else if (w_dt == data_types::i8 && azp_dt == data_types::i8) { - mem_lock w_lock(*w); - mem_lock azp_lock(*azp); + mem_lock w_lock(w, stream); + mem_lock azp_lock(azp, stream); if (wzp) { - mem_lock wzp_lock(*wzp); + mem_lock wzp_lock(wzp, stream); fill_compensation_typed(w_lock.data(), azp_lock.data(), wzp_lock.data(), comp_lock.data(), GS, OC, IC, KS); } else { fill_compensation_typed(w_lock.data(), azp_lock.data(), static_cast(nullptr), comp_lock.data(), GS, OC, IC, KS); } } else if (w_dt == data_types::u8 && azp_dt == data_types::i8) { - mem_lock w_lock(*w); - mem_lock azp_lock(*azp); + mem_lock w_lock(w, stream); + mem_lock azp_lock(azp, stream); if (wzp) { - mem_lock wzp_lock(*wzp); + mem_lock wzp_lock(wzp, stream); fill_compensation_typed(w_lock.data(), azp_lock.data(), wzp_lock.data(), comp_lock.data(), GS, OC, IC, KS); } else { fill_compensation_typed(w_lock.data(), azp_lock.data(), static_cast(nullptr), comp_lock.data(), GS, OC, IC, KS); @@ -590,13 +595,14 @@ void prepare_quantization::prepare_asymmetric_quantization(program_impl &p) { auto l = layout{new_a_zp->get_output_layout().data_type, format::bfyx, tensor{1, ifm_aligned, 1, 1}}; int s = new_a_zp->get_output_layout().size.feature[0]; - auto azp_aligned = p.get_engine().allocate_memory(l, 0, false); - mem_lock new_data{azp_aligned}; - mem_lock old_data{new_a_zp->as().get_attached_memory()}; + auto azp_aligned = p.get_engine().allocate_memory(l); + auto old_ptr = new_a_zp->as().get_attached_memory_ptr(); + mem_lock new_data{azp_aligned, stream}; + mem_lock old_data{old_ptr, stream}; for (int i = 0; i < ifm_aligned; i++) { new_data.data()[i] = old_data.data()[i % s]; } - new_a_zp->as().attach_memory(*azp_aligned); + new_a_zp->as().attach_memory(azp_aligned); input = new_input->id(); a_zero_points.push_back(new_a_zp->id()); @@ -609,13 +615,14 @@ void prepare_quantization::prepare_asymmetric_quantization(program_impl &p) { auto l = layout{new_w_zp->get_output_layout().data_type, format::bfyx, tensor{ofm_aligned, 1, 1, 1}}; int s = new_w_zp->get_output_layout().size.batch[0]; - auto wzp_aligned = p.get_engine().allocate_memory(l, 0, false); - mem_lock new_data{wzp_aligned}; - mem_lock old_data{new_w_zp->as().get_attached_memory()}; + auto wzp_aligned = p.get_engine().allocate_memory(l); + auto old_ptr = new_w_zp->as().get_attached_memory_ptr(); + mem_lock new_data{wzp_aligned, stream}; + mem_lock old_data{old_ptr, stream}; for (int i = 0; i < ofm_aligned; i++) { new_data.data()[i] = old_data.data()[i % s]; } - new_w_zp->as().attach_memory(*wzp_aligned); + new_w_zp->as().attach_memory(wzp_aligned); weights = { new_weights->id() }; w_zero_points.push_back(new_w_zp->id()); @@ -623,19 +630,16 @@ void prepare_quantization::prepare_asymmetric_quantization(program_impl &p) { if (need_compensation) { auto l = layout{data_types::f32, format::bfyx, tensor{1, ofm_aligned, 1, 1}}; - auto data_to_allocate = p.get_engine().allocate_memory(l, 0, false); - auto w = &new_weights->as().get_attached_memory(); - auto azp = asymmetric_data ? &new_a_zp->as().get_attached_memory() : nullptr; - auto wzp = asymmetric_weights ? &new_w_zp->as().get_attached_memory() : nullptr; + auto data_to_allocate = p.get_engine().allocate_memory(l); + auto w = new_weights->as().get_attached_memory_ptr(); + auto azp = asymmetric_data ? new_a_zp->as().get_attached_memory_ptr() : nullptr; + auto wzp = asymmetric_weights ? new_w_zp->as().get_attached_memory_ptr() : nullptr; fill_compensation(groups, w, azp, wzp, data_to_allocate); - layout dummy_layout(data_types::f32, format::bfyx, tensor(1, 1, 1, 1)); - float zero = 0.f; - auto compensation_prim = std::make_shared(convolution_node.id() + "_compensation", memory::attach(dummy_layout, &zero, 1)); + auto compensation_prim = std::make_shared(convolution_node.id() + "_compensation", data_to_allocate); new_compenstation = &p.get_or_create(compensation_prim); p.get_inputs().push_back(new_compenstation); compensation.push_back(new_compenstation->id()); - new_compenstation->as().attach_memory(*data_to_allocate); } // Collect dependencies of a new convolution node @@ -745,11 +749,11 @@ void prepare_quantization::prepare_dequantize_merge(program_impl &p) { } } - auto get_scale_shift_mem = [](const eltwise_node& eltw, size_t dep_id) -> memory_impl& { + auto get_scale_shift_mem = [](const eltwise_node& eltw, size_t dep_id) -> memory::ptr { if (dep_id >= eltw.get_dependencies().size()) CLDNN_ERROR_MESSAGE(eltw.id(), "Invalid dependency id in dequantize optimization"); - return eltw.get_dependency(dep_id).as().get_attached_memory(); + return eltw.get_dependency(dep_id).as().get_attached_memory_ptr(); }; auto eltw_mode = node.get_primitive()->mode; @@ -757,6 +761,7 @@ void prepare_quantization::prepare_dequantize_merge(program_impl &p) { return; auto& input = node.input(); + auto& stream = p.get_stream(); for (auto& user : input.get_users()) { if (user == &node) @@ -781,20 +786,20 @@ void prepare_quantization::prepare_dequantize_merge(program_impl &p) { bool same_params = true; for (size_t i = 1; i < node.get_dependencies().size(); i++) { - auto& mem0 = get_scale_shift_mem(eltwise_dep, i); - auto& mem1 = get_scale_shift_mem(node, i); + auto mem0 = get_scale_shift_mem(eltwise_dep, i); + auto mem1 = get_scale_shift_mem(node, i); - auto ptr0 = static_cast(mem0.lock()); - auto ptr1 = static_cast(mem1.lock()); + mem_lock mem0_lock{mem0, stream}; + mem_lock mem1_lock{mem1, stream}; + auto ptr0 = mem0_lock.data(); + auto ptr1 = mem1_lock.data(); - for (size_t j = 0; j < mem0.get_layout().bytes_count(); j++) { + for (size_t j = 0; j < mem0->get_layout().bytes_count(); j++) { if (ptr0[j] != ptr1[j]) { same_params = false; break; } } - mem0.unlock(); - mem1.unlock(); } if (same_params) { diff --git a/inference-engine/thirdparty/clDNN/src/graph_optimizer/propagate_constants.cpp b/inference-engine/thirdparty/clDNN/src/graph_optimizer/propagate_constants.cpp index 0229027776ca20..83e2742063f713 100644 --- a/inference-engine/thirdparty/clDNN/src/graph_optimizer/propagate_constants.cpp +++ b/inference-engine/thirdparty/clDNN/src/graph_optimizer/propagate_constants.cpp @@ -6,11 +6,11 @@ #include "pass_manager.h" #include "program_node.h" -#include "engine_impl.h" +#include "cldnn/runtime/engine.hpp" #include "program_impl.h" #include "network_impl.h" #include "data_inst.h" -#include "cldnn_itt.h" +#include "runtime/cldnn_itt.hpp" #include #include #include @@ -71,10 +71,8 @@ void propagate_constants::run(program_impl& p) { auto& id_to_replace = cout.first; auto mem_impl = cout.second; - memory api_memory = memory(mem_impl.detach()); - auto const_data = - std::make_shared("_cldnn_const_prop_" + id_to_replace, api_memory /* <<< REMOVE ME WHEN POSSIBLE */); + std::make_shared("_cldnn_const_prop_" + id_to_replace, mem_impl /* <<< REMOVE ME WHEN POSSIBLE */); auto& new_node = p.get_or_create(const_data); auto& curr_node = p.get_node(id_to_replace); @@ -109,21 +107,22 @@ bool propagate_constants::has_non_const_user(program_node& node) const { return false; } -std::list> propagate_constants::calculate(engine_impl& engine, build_options bo) { +std::list> propagate_constants::calculate(engine& engine, build_options bo) { if (!has_non_trivial_constants) return {}; bo.set_option(build_option::optimize_data(false)); bo.set_option(build_option::outputs(const_outputs)); - network_impl::ptr net = engine.build_network(nodes, bo, true); - for (auto& cin : const_inputs) net->set_input_data(cin->id(), cin->get_attached_memory()); + network_impl::ptr net = network_impl::build_network(engine, nodes, bo, true); + for (auto& cin : const_inputs) + net->set_input_data(cin->id(), cin->get_attached_memory_ptr()); net->execute({}); net->reset_execution(true); // wait for computations to complete auto outputs = net->get_outputs(); - std::list> ret; - for (auto& out : outputs) ret.push_back({out->id(), (memory_impl::ptr) &out->output_memory()}); + std::list> ret; + for (auto& out : outputs) ret.push_back({out->id(), out->output_memory_ptr()}); return ret; } diff --git a/inference-engine/thirdparty/clDNN/src/graph_optimizer/reorder_inputs.cpp b/inference-engine/thirdparty/clDNN/src/graph_optimizer/reorder_inputs.cpp index 689157262ccc08..15257fe0e95c90 100644 --- a/inference-engine/thirdparty/clDNN/src/graph_optimizer/reorder_inputs.cpp +++ b/inference-engine/thirdparty/clDNN/src/graph_optimizer/reorder_inputs.cpp @@ -4,13 +4,14 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// -#include "api/binary_convolution.hpp" #include "pass_manager.h" #include "program_node.h" #include "layout_optimizer.h" #include "program_impl.h" #include "program_helpers.h" +#include "binary_convolution_inst.h" #include "mvn_inst.h" + #include #include #include diff --git a/inference-engine/thirdparty/clDNN/src/graph_optimizer/skipped_branch_memory_dependencies.cpp b/inference-engine/thirdparty/clDNN/src/graph_optimizer/skipped_branch_memory_dependencies.cpp index bb9578142b203a..a3ac6478673d13 100644 --- a/inference-engine/thirdparty/clDNN/src/graph_optimizer/skipped_branch_memory_dependencies.cpp +++ b/inference-engine/thirdparty/clDNN/src/graph_optimizer/skipped_branch_memory_dependencies.cpp @@ -9,7 +9,7 @@ #include "layout_optimizer.h" #include "program_impl.h" #include "program_helpers.h" -#include "cldnn_itt.h" +#include "runtime/cldnn_itt.hpp" #include #include #include diff --git a/inference-engine/thirdparty/clDNN/src/graph_optimizer/strided_slice_optimize.cpp b/inference-engine/thirdparty/clDNN/src/graph_optimizer/strided_slice_optimize.cpp index 50ddea1771a183..3546a7d427cab4 100644 --- a/inference-engine/thirdparty/clDNN/src/graph_optimizer/strided_slice_optimize.cpp +++ b/inference-engine/thirdparty/clDNN/src/graph_optimizer/strided_slice_optimize.cpp @@ -4,7 +4,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// -#include +#include "cldnn/runtime/error_handler.hpp" #include "pass_manager.h" #include "program_helpers.h" #include "strided_slice_inst.h" diff --git a/inference-engine/thirdparty/clDNN/src/include/activation_inst.h b/inference-engine/thirdparty/clDNN/src/include/activation_inst.h index f5c66dac45dbc7..989b2b557242a2 100644 --- a/inference-engine/thirdparty/clDNN/src/include/activation_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/activation_inst.h @@ -4,9 +4,10 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/activation.hpp" +#include "cldnn/primitives/activation.hpp" #include "primitive_inst.h" #include "kernel_selector/core/actual_kernels/activation/activation_kernel_base.h" + #include #include @@ -49,7 +50,7 @@ class typed_primitive_inst : public typed_primitive_inst_base diff --git a/inference-engine/thirdparty/clDNN/src/include/average_unpooling_inst.h b/inference-engine/thirdparty/clDNN/src/include/average_unpooling_inst.h index e20df8e759750a..0eef5fe75e221d 100644 --- a/inference-engine/thirdparty/clDNN/src/include/average_unpooling_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/average_unpooling_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/average_unpooling.hpp" +#include "cldnn/primitives/average_unpooling.hpp" #include "primitive_inst.h" + #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/batch_to_space_inst.h b/inference-engine/thirdparty/clDNN/src/include/batch_to_space_inst.h index 930db1ae93f0f2..1b0feedd2f3dcd 100644 --- a/inference-engine/thirdparty/clDNN/src/include/batch_to_space_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/batch_to_space_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/batch_to_space.hpp" +#include "cldnn/primitives/batch_to_space.hpp" #include "primitive_inst.h" + #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/binary_convolution_inst.h b/inference-engine/thirdparty/clDNN/src/include/binary_convolution_inst.h index f4ce140d4f804a..ef7f7afb2a854c 100644 --- a/inference-engine/thirdparty/clDNN/src/include/binary_convolution_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/binary_convolution_inst.h @@ -4,7 +4,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/binary_convolution.hpp" +#include "cldnn/primitives/binary_convolution.hpp" #include "primitive_inst.h" #include @@ -62,11 +62,11 @@ class typed_primitive_inst : public typed_primitive_inst_bas public: typed_primitive_inst(network_impl& network, binary_convolution_node const& node); - memory_impl& weights_memory(size_t index) const { + memory::ptr weights_memory(size_t index) const { if (static_cast(index) >= node.get_split()) throw std::range_error("weights offset too big"); - return dep_memory(1 + index); + return dep_memory_ptr(1 + index); } }; diff --git a/inference-engine/thirdparty/clDNN/src/include/border_inst.h b/inference-engine/thirdparty/clDNN/src/include/border_inst.h index d724b426891787..ed181ed0b16c3f 100644 --- a/inference-engine/thirdparty/clDNN/src/include/border_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/border_inst.h @@ -4,10 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once - -#include - +#include "cldnn/primitives/border.hpp" #include "primitive_inst.h" + #include #include diff --git a/inference-engine/thirdparty/clDNN/src/include/broadcast_inst.h b/inference-engine/thirdparty/clDNN/src/include/broadcast_inst.h index 9b8471d44db2ee..75be67373c787e 100644 --- a/inference-engine/thirdparty/clDNN/src/include/broadcast_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/broadcast_inst.h @@ -5,7 +5,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include +#include "cldnn/primitives/broadcast.hpp" #include "primitive_inst.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/include/concatenation_inst.h b/inference-engine/thirdparty/clDNN/src/include/concatenation_inst.h index ffdb51a63de9e3..82d3d39676f9ff 100644 --- a/inference-engine/thirdparty/clDNN/src/include/concatenation_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/concatenation_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/concatenation.hpp" +#include "cldnn/primitives/concatenation.hpp" #include "primitive_inst.h" + #include #include diff --git a/inference-engine/thirdparty/clDNN/src/include/condition_inst.h b/inference-engine/thirdparty/clDNN/src/include/condition_inst.h index 8a8859b55b6f88..4bff69b6e4953b 100644 --- a/inference-engine/thirdparty/clDNN/src/include/condition_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/condition_inst.h @@ -5,10 +5,10 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include - +#include #include "network_impl.h" #include "primitive_inst.h" + #include #include @@ -26,9 +26,10 @@ struct typed_program_node : public typed_program_node_base void set(const program_node& node) { add_or_change_input_layout(node); - _program = node.get_program().get_engine().build_program(_topology, - node.get_program().get_options(), - true); // rebuild program + _program = program_impl::build_program(node.get_program().get_engine(), + _topology, + node.get_program().get_options(), + true); // rebuild program } program_impl::ptr get() const { return _program; } @@ -89,8 +90,10 @@ class typed_primitive_inst : public typed_primitive_inst_base @@ -120,48 +120,48 @@ class typed_primitive_inst : public typed_primitive_inst_base(index) >= node.get_split()) throw std::range_error("weights offset too big"); - return dep_memory(1 + index + node.get_trans_dep_offset()); + return dep_memory_ptr(1 + index + node.get_trans_dep_offset()); } else { // all weights are in one buffer - return dep_memory(1 + node.get_trans_dep_offset()); + return dep_memory_ptr(1 + node.get_trans_dep_offset()); } } - memory_impl& bias_memory(size_t index) const { + memory::ptr bias_memory(size_t index) const { if (node.get_groups() == 1) { if (static_cast(index) >= node.get_split()) throw std::range_error("bias offset too big"); - return dep_memory(1 + node.get_split() + index + node.get_trans_dep_offset()); + return dep_memory_ptr(1 + node.get_split() + index + node.get_trans_dep_offset()); } else { // all bias are in one buffer - return dep_memory(2 + node.get_trans_dep_offset()); + return dep_memory_ptr(2 + node.get_trans_dep_offset()); } } - memory_impl& weights_zero_points_memory(size_t) const { + memory::ptr weights_zero_points_memory(size_t) const { if (node.get_split() > 1) throw std::range_error("Split is unsupported for quantized convolutions"); - return dep_memory(2 + 1 * bias_term() + node.get_trans_dep_offset()); + return dep_memory_ptr(2 + 1 * bias_term() + node.get_trans_dep_offset()); } - memory_impl& trans_memory() const { + memory::ptr trans_memory() const { if (!node.get_trans_dep_offset()) throw std::range_error("trans input exists only in deformable mode"); - return dep_memory(1); + return dep_memory_ptr(1); } - memory_impl& activations_zero_points_memory(size_t) const { + memory::ptr activations_zero_points_memory(size_t) const { if (node.get_split() > 1) throw std::range_error("Split is unsupported for quantized convolutions"); - return dep_memory(2 + 1 * bias_term() + 1 * weights_zero_points_term() + node.get_trans_dep_offset()); + return dep_memory_ptr(2 + 1 * bias_term() + 1 * weights_zero_points_term() + node.get_trans_dep_offset()); } - memory_impl& compensation_memory(size_t) const { + memory::ptr compensation_memory(size_t) const { if (node.get_split() > 1) throw std::range_error("Split is unsupported for quantized convolutions"); - return dep_memory(2 + 1 * bias_term() + 1 * weights_zero_points_term() + 1*activations_zero_points_term() + node.get_trans_dep_offset()); + return dep_memory_ptr(2 + 1 * bias_term() + 1 * weights_zero_points_term() + 1*activations_zero_points_term() + node.get_trans_dep_offset()); } bool bias_term() const { return node.bias_term(); } diff --git a/inference-engine/thirdparty/clDNN/src/include/crop_inst.h b/inference-engine/thirdparty/clDNN/src/include/crop_inst.h index 4ae7a095f0b495..e8842e5bed9ebf 100644 --- a/inference-engine/thirdparty/clDNN/src/include/crop_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/crop_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/crop.hpp" +#include "cldnn/primitives/crop.hpp" #include "primitive_inst.h" + #include #include diff --git a/inference-engine/thirdparty/clDNN/src/include/ctc_greedy_decoder_inst.h b/inference-engine/thirdparty/clDNN/src/include/ctc_greedy_decoder_inst.h index 7e856ff2e0cd9f..ea5d2bcda58359 100644 --- a/inference-engine/thirdparty/clDNN/src/include/ctc_greedy_decoder_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/ctc_greedy_decoder_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/ctc_greedy_decoder.hpp" +#include "cldnn/primitives/ctc_greedy_decoder.hpp" #include "primitive_inst.h" + #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/cum_sum_inst.h b/inference-engine/thirdparty/clDNN/src/include/cum_sum_inst.h index 452076299e8b7e..fb9cecf7fc5caa 100644 --- a/inference-engine/thirdparty/clDNN/src/include/cum_sum_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/cum_sum_inst.h @@ -4,8 +4,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/cum_sum.hpp" - +#include "cldnn/primitives/cum_sum.hpp" #include "primitive_inst.h" namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/custom_gpu_primitive_inst.h b/inference-engine/thirdparty/clDNN/src/include/custom_gpu_primitive_inst.h index 125dbcfc2b65b3..20c40ecdf741c6 100644 --- a/inference-engine/thirdparty/clDNN/src/include/custom_gpu_primitive_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/custom_gpu_primitive_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/custom_gpu_primitive.hpp" +#include "cldnn/primitives/custom_gpu_primitive.hpp" #include "primitive_inst.h" + #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/data_inst.h b/inference-engine/thirdparty/clDNN/src/include/data_inst.h index 311257992c9f51..e1cafad9c726ad 100644 --- a/inference-engine/thirdparty/clDNN/src/include/data_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/data_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/data.hpp" +#include "cldnn/primitives/data.hpp" #include "primitive_inst.h" + #include #include @@ -17,11 +18,12 @@ struct typed_program_node : public typed_program_node_base { typed_program_node(const std::shared_ptr prim, program_impl& prog); - memory_impl& get_attached_memory() const { return *mem; } - void attach_memory(memory_impl& new_mem, bool invalidate_users_if_changed = true); + memory& get_attached_memory() const { return *mem; } + memory::ptr get_attached_memory_ptr() const { return mem; } + void attach_memory(memory::ptr new_mem, bool invalidate_users_if_changed = true); private: - memory_impl::ptr mem; + memory::ptr mem; }; using data_node = typed_program_node; diff --git a/inference-engine/thirdparty/clDNN/src/include/deconvolution_inst.h b/inference-engine/thirdparty/clDNN/src/include/deconvolution_inst.h index c96d179aa9800f..f8d933002440a4 100644 --- a/inference-engine/thirdparty/clDNN/src/include/deconvolution_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/deconvolution_inst.h @@ -4,8 +4,10 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/deconvolution.hpp" + +#include "cldnn/primitives/deconvolution.hpp" #include "primitive_inst.h" + #include #include @@ -90,25 +92,25 @@ class typed_primitive_inst : public typed_primitive_inst_base(index) >= node.get_split()) throw std::range_error("weights offset too big"); - return dep_memory(1 + index); + return dep_memory_ptr(1 + index); } else { // all weights are in one buffer - return dep_memory(1); + return dep_memory_ptr(1); } } - memory_impl& bias_memory(size_t index) const { + memory::ptr bias_memory(size_t index) const { if (node.get_groups() == 1) { if (argument.bias.size() == 0 && static_cast(index) >= node.get_split()) throw std::range_error("no bias data"); if (static_cast(index) > node.get_split()) throw std::range_error("bias offset too big"); - return dep_memory(1 + node.get_split() + index); + return dep_memory_ptr(1 + node.get_split() + index); } else { // all bias are in one buffer - return dep_memory(2); + return dep_memory_ptr(2); } } diff --git a/inference-engine/thirdparty/clDNN/src/include/deformable_convolution_inst.h b/inference-engine/thirdparty/clDNN/src/include/deformable_convolution_inst.h index 63c4556b65fa32..c7889f7860016e 100644 --- a/inference-engine/thirdparty/clDNN/src/include/deformable_convolution_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/deformable_convolution_inst.h @@ -4,7 +4,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/convolution.hpp" +#include "cldnn/primitives/convolution.hpp" #include "primitive_inst.h" #include @@ -75,23 +75,23 @@ class typed_primitive_inst : public typed_primitive_inst_base(index) >= node.get_split()) throw std::range_error("weights offset too big"); - return dep_memory(1 + index); + return dep_memory_ptr(1 + index); } else { // all weights are in one buffer - return dep_memory(1); + return dep_memory_ptr(1); } } - memory_impl& bias_memory(size_t index) const { + memory::ptr bias_memory(size_t index) const { if (node.get_groups() == 1) { if (static_cast(index) >= node.get_split()) throw std::range_error("bias offset too big"); - return dep_memory(1 + node.get_split()); + return dep_memory_ptr(1 + node.get_split()); } else { // all bias are in one buffer - return dep_memory(2); + return dep_memory_ptr(2); } } @@ -154,7 +154,7 @@ class typed_primitive_inst : public typed_primitive_inst_base public: typed_primitive_inst(network_impl& network, deformable_interp_node const& node); - memory_impl& trans_memory() const { return dep_memory(1); } + memory& trans_memory() const { return dep_memory(1); } }; using deformable_interp_inst = typed_primitive_inst; diff --git a/inference-engine/thirdparty/clDNN/src/include/depth_to_space_inst.h b/inference-engine/thirdparty/clDNN/src/include/depth_to_space_inst.h index 0d85e72663b30f..f551ee7ae341c5 100644 --- a/inference-engine/thirdparty/clDNN/src/include/depth_to_space_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/depth_to_space_inst.h @@ -4,9 +4,10 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/depth_to_space.hpp" +#include "cldnn/primitives/depth_to_space.hpp" #include "primitive_inst.h" #include "kernel_selector/core/actual_kernels/depth_to_space/depth_to_space_kernel_base.h" + #include #include diff --git a/inference-engine/thirdparty/clDNN/src/include/detection_output_inst.h b/inference-engine/thirdparty/clDNN/src/include/detection_output_inst.h index 398767ed581b1d..6ce0a82eb4b9b7 100644 --- a/inference-engine/thirdparty/clDNN/src/include/detection_output_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/detection_output_inst.h @@ -4,9 +4,10 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/detection_output.hpp" +#include "cldnn/primitives/detection_output.hpp" #include "primitive_inst.h" #include "topology_impl.h" + #include #define PRIOR_BOX_SIZE 4 // Each prior-box consists of [xmin, ymin, xmax, ymax]. @@ -41,9 +42,9 @@ class typed_primitive_inst : public typed_primitive_inst_base< public: typed_primitive_inst(network_impl& network, detection_output_node const& node); - memory_impl& location_memory() const { return dep_memory(0); } - memory_impl& confidence_memory() const { return dep_memory(1); } - memory_impl& prior_box_memory() const { return dep_memory(2); } + memory::ptr location_memory() const { return dep_memory_ptr(0); } + memory::ptr confidence_memory() const { return dep_memory_ptr(1); } + memory::ptr prior_box_memory() const { return dep_memory_ptr(2); } }; using detection_output_inst = typed_primitive_inst; diff --git a/inference-engine/thirdparty/clDNN/src/include/device_impl.h b/inference-engine/thirdparty/clDNN/src/include/device_impl.h deleted file mode 100644 index 9c692ae49bc110..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/include/device_impl.h +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma once -#include -#include "gpu/device_info.h" -#include "api/device.hpp" -#include "refcounted_obj.h" -#include "gpu/configuration.h" - -#include -#include -#include -#include - -namespace cldnn { -enum class allocation_type { - unknown, // Not specified (i.e simple_attached_memory class). - cl_mem, // Use standard OpenCL cl_mem allocations. - usm_host, // Accessible only by host. Not Migratable - usm_shared, // Accessible by host and device. Migrtable. - usm_device, // Accessible only by device. Not migratable. -}; - -struct device_impl; - -class memory_capabilities { -public: - memory_capabilities(bool support_usm, const cl::Device& cl_dev) : _caps({ allocation_type::cl_mem }) { - if (support_usm) { - if (does_device_support(CL_DEVICE_HOST_MEM_CAPABILITIES_INTEL, cl_dev)) { - _caps.push_back(allocation_type::usm_host); - } - if (does_device_support(CL_DEVICE_SINGLE_DEVICE_SHARED_MEM_CAPABILITIES_INTEL, cl_dev)) { - _caps.push_back(allocation_type::usm_shared); - } - if (does_device_support(CL_DEVICE_DEVICE_MEM_CAPABILITIES_INTEL, cl_dev)) { - _caps.push_back(allocation_type::usm_device); - } - } - } - - bool supports_usm() const { return find_in_caps(allocation_type::cl_mem) && _caps.size() > 1; } - bool support_allocation_type(allocation_type type) const { return find_in_caps(type); } - - static bool is_usm_type(allocation_type type) { - if (type == allocation_type::usm_host || - type == allocation_type::usm_shared || - type == allocation_type::usm_device) - return true; - return false; - } - -private: - std::vector _caps; - - bool does_device_support(int32_t param, const cl::Device& device) { - cl_device_unified_shared_memory_capabilities_intel capabilities; - auto err = clGetDeviceInfo(device.get(), param, sizeof(cl_device_unified_shared_memory_capabilities_intel), &capabilities, NULL); - if (err) throw std::runtime_error("[CLDNN ERROR]. clGetDeviceInfo error " + std::to_string(err)); - return !((capabilities & CL_UNIFIED_SHARED_MEMORY_ACCESS_INTEL) == 0u); - } - - bool find_in_caps(const allocation_type& type) const { - return std::find_if(_caps.begin(), _caps.end(), [&](const allocation_type& t) { return t == type; }) != _caps.end(); - } -}; - - -struct device_impl : public refcounted_obj { -public: - explicit device_impl(const cl::Device dev, const cl::Context& ctx, const cl_platform_id platform, const gpu::device_info_internal& info) - : _context(ctx), _device(dev), _platform(platform), _info(info), _mem_caps(_info.supports_usm, _device) { } - - gpu::device_info_internal get_info() const { return _info; } - cl::Device get_device() const { return _device; } - cl::Context get_context() const { return _context; } - cl_platform_id get_platform() const { return _platform; } - memory_capabilities mem_caps() const { return _mem_caps; } - - ~device_impl() = default; - -private: - cl::Context _context; - cl::Device _device; - cl_platform_id _platform; - gpu::device_info_internal _info; - memory_capabilities _mem_caps; -}; - -struct device_query_impl : public refcounted_obj { -public: - explicit device_query_impl(void* user_context = nullptr, void* user_device = nullptr); - - std::map get_available_devices() const { - return _available_devices; - } - - ~device_query_impl() = default; -private: - std::map _available_devices; -}; -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/include/eltwise_inst.h b/inference-engine/thirdparty/clDNN/src/include/eltwise_inst.h index f1c72138fad089..9b62e0b73b2f64 100644 --- a/inference-engine/thirdparty/clDNN/src/include/eltwise_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/eltwise_inst.h @@ -4,11 +4,12 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/eltwise.hpp" +#include "cldnn/primitives/eltwise.hpp" #include "primitive_inst.h" -#include #include "topology_impl.h" #include "kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_base.h" + +#include #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/embedding_bag_inst.h b/inference-engine/thirdparty/clDNN/src/include/embedding_bag_inst.h index 1b5982083ffa6a..79151251ce97cb 100644 --- a/inference-engine/thirdparty/clDNN/src/include/embedding_bag_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/embedding_bag_inst.h @@ -4,9 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/embedding_bag.hpp" - +#include "cldnn/primitives/embedding_bag.hpp" #include "primitive_inst.h" + #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/engine_impl.h b/inference-engine/thirdparty/clDNN/src/include/engine_impl.h deleted file mode 100644 index addc1e1daf0542..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/include/engine_impl.h +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma once -#include "api/memory.hpp" -#include "event_impl.h" -#include "refcounted_obj.h" -#include "implementation_map.h" -#include "memory_pool.h" -#include "device_impl.h" - -#include -#include -#include -#include -#include - -namespace cldnn { -namespace gpu { -class gpu_toolkit; -} - -class build_options; -using gpu_toolkit = gpu::gpu_toolkit; - -struct memory_impl; -struct event_impl; -struct topology_impl; -struct program_impl; -struct network_impl; -struct program_node; - -template -struct typed_program_node; - -struct engine_impl : public refcounted_obj { -public: - explicit engine_impl(const device_impl& dev, const engine_configuration& conf); - ~engine_impl(); - engine_types type() const { return engine_types::ocl; } - refcounted_obj_ptr allocate_memory(const layout& layout, uint32_t net_id, bool reset = true); - refcounted_obj_ptr allocate_memory(const layout& layout, allocation_type type, uint32_t net_id = 0, bool reset = true); - refcounted_obj_ptr allocate_memory(const layout& layout, - primitive_id, - uint32_t network_id, - std::set, - allocation_type type, - bool reusable = true); - refcounted_obj_ptr reinterpret_buffer(const memory_impl& memory, const layout& new_layout); - refcounted_obj_ptr reinterpret_handle(const layout& new_layout, - const shared_mem_params* params, - uint32_t net_id); - bool is_the_same_buffer(const memory_impl& mem1, const memory_impl& mem2); - - refcounted_obj_ptr create_user_event(uint32_t net_id, bool set = false); - void wait_for_events(std::vector const& events); - - refcounted_obj_ptr build_program(const topology_impl& topology, - const build_options& options, - bool is_internal = false, - bool no_optimizations = false); - refcounted_obj_ptr build_program(const std::set>& nodes, - const build_options& options, - bool is_internal); - void compile_program(program_impl& prog); - - refcounted_obj_ptr allocate_network(const program_impl& program, - uint16_t stream_id, - bool is_internal = false); - refcounted_obj_ptr build_network(const topology_impl& topology, - const build_options& options, - uint16_t stream_id, - bool is_internal = false); - refcounted_obj_ptr build_network(const std::set>& nodes, - const build_options& options, - bool is_internal); - void flush_network(uint32_t net_id); - void release_pending_memory(uint32_t net_id); - - template - std::unique_ptr create_primitive_impl(typed_program_node const& node) { - if (&node.get_program().get_engine() != this) - throw std::invalid_argument( - "engine_impl::create_primitive_impl: program's engine does not match called engine"); - - auto factory = implementation_map::get(type(), node); - return std::move(std::unique_ptr(factory(node))); - } - - template - bool does_an_implementation_exist(typed_program_node const& node) { - if (&node.get_program().get_engine() != this) - throw std::invalid_argument( - "engine_impl::create_primitive_impl: program's engine does not match called engine"); - return implementation_map::check(type(), node); - } - - template - bool does_possible_implementation_exist(typed_program_node const& node) { - if (&node.get_program().get_engine() != this) - throw std::invalid_argument( - "engine_impl::create_primitive_impl: program's engine does not match called engine"); - return implementation_map::check_io_eq(type(), node); - } - - const engine_configuration& configuration() const { return _configuration; } - void set_mem_pool(bool flag) { _configuration.enable_memory_pool = flag; } - std::shared_ptr get_context() const { return _context; } - gpu::device_info_internal get_device_info() const; - void* get_user_context() const; - memory_pool& get_memory_pool() { return _memory_pool; } - - uint64_t get_max_used_device_memory() const { return _memory_pool.get_max_peak_device_memory_used(); } - uint64_t get_used_device_memory() const { return _memory_pool.get_temp_memory_used(); } - - void dump_memory_pool(const program_impl& program, std::string& path, std::string& dependencies) { - _memory_pool.dump_memory_pool(program, path, dependencies); - } - bool use_memory_pool() const; - bool use_unified_shared_memory() const; - bool supports_allocation(allocation_type type) const; - allocation_type get_lockable_preffered_memory_allocation_type(bool is_image_layout = false) const; - -private: - engine_configuration _configuration; - std::shared_ptr _context; - memory_pool _memory_pool; -}; -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/include/extract_image_patches_inst.h b/inference-engine/thirdparty/clDNN/src/include/extract_image_patches_inst.h index 00ec93d57dbe6d..2eb4dd7f7926bd 100644 --- a/inference-engine/thirdparty/clDNN/src/include/extract_image_patches_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/extract_image_patches_inst.h @@ -4,8 +4,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once - -#include "api/extract_image_patches.hpp" +#include "cldnn/primitives/extract_image_patches.hpp" #include "primitive_inst.h" namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/fully_connected_inst.h b/inference-engine/thirdparty/clDNN/src/include/fully_connected_inst.h index 75e00f7dd92015..db3a156dec5aae 100644 --- a/inference-engine/thirdparty/clDNN/src/include/fully_connected_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/fully_connected_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/fully_connected.hpp" +#include "cldnn/primitives/fully_connected.hpp" #include "primitive_inst.h" + #include #include @@ -37,8 +38,8 @@ class typed_primitive_inst : public typed_primitive_inst_base @@ -83,18 +83,18 @@ class typed_primitive_inst : public typed_primitive_inst_bas public: typed_primitive_inst(network_impl& network, fused_conv_eltwise_node const& node); - memory_impl& weights_memory(size_t index) const { + memory::ptr weights_memory(size_t index) const { if (static_cast(index) >= node.get_split()) throw std::range_error("weights offset too big"); - return dep_memory(2 + index); + return dep_memory_ptr(2 + index); } - memory_impl& bias_memory(size_t index) const { + memory::ptr bias_memory(size_t index) const { if (static_cast(index) >= node.get_split()) throw std::range_error("bias offset too big"); - return dep_memory(2 + node.get_split() + index); + return dep_memory_ptr(2 + node.get_split() + index); } bool bias_term() const { return node.bias_term(); } diff --git a/inference-engine/thirdparty/clDNN/src/include/gather_inst.h b/inference-engine/thirdparty/clDNN/src/include/gather_inst.h index f8e2c924cea462..9acd82a499c303 100644 --- a/inference-engine/thirdparty/clDNN/src/include/gather_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/gather_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/gather.hpp" +#include "cldnn/primitives/gather.hpp" #include "primitive_inst.h" + #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/gather_nd_inst.h b/inference-engine/thirdparty/clDNN/src/include/gather_nd_inst.h index b8732f7171c635..86a3b0b4cec956 100644 --- a/inference-engine/thirdparty/clDNN/src/include/gather_nd_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/gather_nd_inst.h @@ -1,22 +1,9 @@ -/* -// Copyright (c) 2021 Intel Corporation +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -*/ - -/////////////////////////////////////////////////////////////////////////////////////////////////// + #pragma once -#include "api/gather_nd.hpp" +#include "cldnn/primitives/gather_nd.hpp" #include "primitive_inst.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/include/gather_tree_inst.h b/inference-engine/thirdparty/clDNN/src/include/gather_tree_inst.h index cb18b6e713391e..589c004af1a095 100644 --- a/inference-engine/thirdparty/clDNN/src/include/gather_tree_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/gather_tree_inst.h @@ -3,10 +3,9 @@ // #pragma once - -#include - +#include "cldnn/primitives/gather_tree.hpp" #include "primitive_inst.h" + #include #include diff --git a/inference-engine/thirdparty/clDNN/src/include/gemm_inst.h b/inference-engine/thirdparty/clDNN/src/include/gemm_inst.h index 501f3029c566c6..670edf130639cf 100644 --- a/inference-engine/thirdparty/clDNN/src/include/gemm_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/gemm_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/gemm.hpp" +#include "cldnn/primitives/gemm.hpp" #include "primitive_inst.h" + #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/generic_layer.hpp b/inference-engine/thirdparty/clDNN/src/include/generic_layer.hpp index 7809c2d58f3722..79f0616b9161e1 100644 --- a/inference-engine/thirdparty/clDNN/src/include/generic_layer.hpp +++ b/inference-engine/thirdparty/clDNN/src/include/generic_layer.hpp @@ -4,9 +4,10 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/primitive.hpp" -#include "api/memory.hpp" +#include "cldnn/primitives/primitive.hpp" +#include "cldnn/runtime/memory.hpp" #include "kernel_selector_helper.h" + #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/generic_layer_inst.h b/inference-engine/thirdparty/clDNN/src/include/generic_layer_inst.h index e04fa801f3ed47..32c90371abb0d4 100644 --- a/inference-engine/thirdparty/clDNN/src/include/generic_layer_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/generic_layer_inst.h @@ -6,6 +6,7 @@ #pragma once #include "generic_layer.hpp" #include "primitive_inst.h" + #include #include diff --git a/inference-engine/thirdparty/clDNN/src/include/grn_inst.h b/inference-engine/thirdparty/clDNN/src/include/grn_inst.h index 1023d3ba4fa7bd..c470a44d9dd9a9 100644 --- a/inference-engine/thirdparty/clDNN/src/include/grn_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/grn_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/grn.hpp" +#include "cldnn/primitives/grn.hpp" #include "primitive_inst.h" + #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/implementation_map.h b/inference-engine/thirdparty/clDNN/src/include/implementation_map.h index 44b36bc94781ba..1a6bb51600682f 100644 --- a/inference-engine/thirdparty/clDNN/src/include/implementation_map.h +++ b/inference-engine/thirdparty/clDNN/src/include/implementation_map.h @@ -132,6 +132,8 @@ class implementation_map { using factory_type = std::function&)>; using map_type = singleton_map; + // TODO: Replace enigne_type here with impl_type + // And add a check that engine do support specific impl_type static factory_type get(engine_types engine_type, const typed_program_node& primitive) { // lookup in database; throw if not found auto key = key_builder()(engine_type, primitive); diff --git a/inference-engine/thirdparty/clDNN/src/include/input_layout_inst.h b/inference-engine/thirdparty/clDNN/src/include/input_layout_inst.h index 3db3e7db12a19a..c6199634634a01 100644 --- a/inference-engine/thirdparty/clDNN/src/include/input_layout_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/input_layout_inst.h @@ -4,13 +4,14 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/input_layout.hpp" +#include "cldnn/primitives/input_layout.hpp" #include "primitive_inst.h" + #include #include namespace cldnn { -struct memory_impl; +struct memory; template <> struct typed_program_node : public typed_program_node_base { @@ -33,7 +34,7 @@ class typed_primitive_inst : public typed_primitive_inst_base; diff --git a/inference-engine/thirdparty/clDNN/src/include/internal_primitive.h b/inference-engine/thirdparty/clDNN/src/include/internal_primitive.h deleted file mode 100644 index 927871b63d6b72..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/include/internal_primitive.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "api/primitive.hpp" - -#include "primitive_type.h" - -namespace cldnn { - -struct internal_primitive : public primitive { -public: - // a helper structure which returns true when compared with any primitive_type which is internal - struct internal_primitive_generic_type { - friend bool operator==(internal_primitive_generic_type, primitive_type_id type) { - return type->is_internal_type(); - } - - friend bool operator==(primitive_type_id type, internal_primitive_generic_type) { - return type->is_internal_type(); - } - - friend bool operator==(internal_primitive_generic_type, internal_primitive_generic_type) { return true; } - }; - - static internal_primitive_generic_type type_id() { return {}; } - -private: - internal_primitive() = delete; - internal_primitive(internal_primitive const&) = delete; - internal_primitive(internal_primitive&&) = delete; -}; - -} // namespace cldnn \ No newline at end of file diff --git a/inference-engine/thirdparty/clDNN/src/include/internal_primitive_type_base.h b/inference-engine/thirdparty/clDNN/src/include/internal_primitive_type_base.h deleted file mode 100644 index 64aa1342a1fa93..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/include/internal_primitive_type_base.h +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "meta_utils.h" -#include "primitive_type.h" -#include "internal_primitive.h" -#include "program_node.h" -#include "primitive_inst.h" -#include -#include - -namespace cldnn { - -template -struct internal_primitive_type_base : public primitive_type { - static_assert(meta::is_internal_primitive::value, - "Primitive type passed to internal_primitive_type_base should derive from internal_primitive"); - - [[noreturn]] std::shared_ptr create_node(program_impl&, - const std::shared_ptr) const override { - throw std::runtime_error( - "Trying to create generic program_node for an internal primitive - internal primitives' nodes should be " - "created manually"); - } - - std::shared_ptr create_instance(network_impl& network, - const cldnn::program_node& node) const override { - if (node.type() != this) - throw std::invalid_argument("internal_primitive_type_base::create_instance: primitive type mismatch"); - - return std::make_shared>(network, node); - } - - [[noreturn]] std::unique_ptr choose_impl(cldnn::engine_impl&, - const cldnn::program_node&) const override { - throw std::runtime_error( - "primitive_type_id::choose_impl called for internal primitive - internal primitives should have manually " - "attached executable"); - } - - [[noreturn]] cldnn::layout calc_output_layout(const cldnn::program_node&) const override { - throw std::runtime_error( - "primitive_type_id::calc_output_layout called for internal primitive - internal primitives should have " - "output layouts precalculated"); - } - - std::string to_string(const cldnn::program_node& node) const override { - if (node.type() != this) - throw std::invalid_argument("primitive_type_base::to_string: primitive type mismatch"); - - return typed_primitive_inst::to_string(node); - } - - bool is_internal_type() const override { return true; } -}; - -#define CLDNN_DEFINE_INTERNAL_PRIM(PType) \ - struct PType : public internal_primitive { \ - static primitive_type_id type_id() { \ - static internal_primitive_type_base instance; \ - return &instance; \ - } \ - }; \ - using PType##_node = typed_program_node; - -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/include/kernel_selector_helper.h b/inference-engine/thirdparty/clDNN/src/include/kernel_selector_helper.h index 46926eecbca919..f97f74ebbbcda8 100644 --- a/inference-engine/thirdparty/clDNN/src/include/kernel_selector_helper.h +++ b/inference-engine/thirdparty/clDNN/src/include/kernel_selector_helper.h @@ -4,17 +4,17 @@ #pragma once -#include "api/cldnn.hpp" -#include "api/tensor.hpp" -#include "api/eltwise.hpp" -#include "api/scale.hpp" -#include "api/quantize.hpp" -#include "api/activation.hpp" +#include "cldnn/runtime/utils.hpp" +#include "cldnn/runtime/tensor.hpp" +#include "cldnn/runtime/error_handler.hpp" +#include "cldnn/primitives/eltwise.hpp" +#include "cldnn/primitives/scale.hpp" +#include "cldnn/primitives/quantize.hpp" +#include "cldnn/primitives/activation.hpp" #include "kernel_selector_params.h" #include "kernel_selector_common.h" #include "tensor_type.h" -#include "error_handler.h" #include #include diff --git a/inference-engine/thirdparty/clDNN/src/include/layout_optimizer.h b/inference-engine/thirdparty/clDNN/src/include/layout_optimizer.h index 8bd0da81f09763..ab15eed29beafa 100644 --- a/inference-engine/thirdparty/clDNN/src/include/layout_optimizer.h +++ b/inference-engine/thirdparty/clDNN/src/include/layout_optimizer.h @@ -4,9 +4,9 @@ #pragma once -#include "memory_impl.h" -#include "engine_impl.h" -#include "meta_utils.h" +#include "cldnn/runtime/memory.hpp" +#include "cldnn/runtime/engine.hpp" +#include "cldnn/runtime/utils.hpp" #include "data_inst.h" #include "reorder_inst.h" diff --git a/inference-engine/thirdparty/clDNN/src/include/loop_inst.h b/inference-engine/thirdparty/clDNN/src/include/loop_inst.h index b555f37e716175..e39bb90f43185a 100644 --- a/inference-engine/thirdparty/clDNN/src/include/loop_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/loop_inst.h @@ -5,17 +5,17 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/loop.hpp" -#include "api/mutable_data.hpp" -#include "api/input_layout.hpp" -#include "api/memory.hpp" +#include "cldnn/primitives/loop.hpp" +#include "cldnn/primitives/mutable_data.hpp" +#include "cldnn/primitives/input_layout.hpp" +#include "cldnn/runtime/memory.hpp" +#include "cldnn/runtime/error_handler.hpp" #include "network_impl.h" #include "primitive_inst.h" #include #include #include -#include "error_handler.h" namespace cldnn { template<> @@ -31,7 +31,7 @@ struct typed_program_node : public typed_program_node_base { bool use_current_iteration; bool use_execution_condition; mutable program_impl::ptr body_program; - mutable std::map backedge_mem_impls; + mutable std::map backedge_mem_impls; mutable std::map> backedge_layers; mutable std::map> backedge_mem; @@ -40,8 +40,8 @@ struct typed_program_node : public typed_program_node_base { void setup_internal_mutabledata_node(primitive_id md_id, layout md_layout, std::vector md_inputs_id = {}, uint32_t net_id = 0) const { if (body.get_primitives().count(md_id) == 0) { backedge_mem_impls[md_id] = get_program().get_engine().allocate_memory(md_layout, net_id); - backedge_mem[md_id] = std::make_shared(backedge_mem_impls[md_id].get()); - backedge_layers[md_id] = std::make_shared(md_id, md_inputs_id, *backedge_mem[md_id]); + backedge_mem[md_id] = backedge_mem_impls[md_id]; + backedge_layers[md_id] = std::make_shared(md_id, md_inputs_id, backedge_mem[md_id]); body.add(backedge_layers[md_id]); } } @@ -266,7 +266,7 @@ struct typed_program_node : public typed_program_node_base { auto opts = get_program().get_options(); std::vector output_names_vec(output_names.begin(), output_names.end()); opts.set_option(build_option::outputs(output_names_vec)); - body_program = get_program().get_engine().build_program(body, opts, false); + body_program = program_impl::build_program(get_program().get_engine(), body, opts, false); } const primitive_id& get_trip_count_id() const { return get_primitive()->trip_count_id; } @@ -298,17 +298,19 @@ class typed_primitive_inst : public typed_primitive_inst_base { }; std::shared_ptr from_primitive; std::shared_ptr to_primitive; - std::vector from_mems; - memory_impl::ptr initial_mem; + std::vector from_mems; + memory::ptr initial_mem; + cldnn::stream& stream; backedge_type type; size_t total_bytes; backedge_memory_mapping( std::shared_ptr from_primitive, std::shared_ptr to_primitive, - std::vector from_mems, memory_impl::ptr initial_mem, backedge_type type = CONCAT_OUTPUT): + std::vector from_mems, memory::ptr initial_mem, cldnn::stream& stream, backedge_type type = CONCAT_OUTPUT): from_primitive(from_primitive), to_primitive(to_primitive), from_mems(from_mems), + stream(stream), type(type), total_bytes(initial_mem->get_layout().bytes_count()) { validate_backedge_memory(); @@ -316,11 +318,12 @@ class typed_primitive_inst : public typed_primitive_inst_base { backedge_memory_mapping( std::shared_ptr from_primitive, std::shared_ptr to_primitive, - memory_impl::ptr from_mem, memory_impl::ptr initial_mem, backedge_type type = SINGLE_SHARED): + memory::ptr from_mem, memory::ptr initial_mem, cldnn::stream& stream, backedge_type type = SINGLE_SHARED): from_primitive(from_primitive), to_primitive(to_primitive), from_mems{from_mem}, initial_mem(initial_mem), + stream(stream), type(type), total_bytes(initial_mem->get_layout().bytes_count()) { validate_backedge_memory(); @@ -328,10 +331,11 @@ class typed_primitive_inst : public typed_primitive_inst_base { backedge_memory_mapping( std::shared_ptr from_primitive, std::shared_ptr to_primitive, - memory_impl::ptr initial_mem, backedge_type type = SINGLE): + memory::ptr initial_mem, cldnn::stream& stream, backedge_type type = SINGLE): from_primitive(from_primitive), to_primitive(to_primitive), initial_mem(initial_mem), + stream(stream), type(type), total_bytes(initial_mem->get_layout().bytes_count()) { validate_backedge_memory(); @@ -340,22 +344,22 @@ class typed_primitive_inst : public typed_primitive_inst_base { void setup_iteration(int64_t iter) const { if (type == CONCAT_OUTPUT) { if (iter == 0) { - to_primitive->set_output_memory(*initial_mem); + to_primitive->set_output_memory(initial_mem); } else if (iter > 0) { - to_primitive->set_output_memory(*from_mems.at(iter - 1)); + to_primitive->set_output_memory(from_mems.at(iter - 1)); } else { throw std::runtime_error("Invalid iteraton count" + std::to_string(iter)); } } else if (type == SINGLE_SHARED && iter == 0) { - copy_data(initial_mem, from_mems.front()); + from_mems.front()->copy_from(stream, *initial_mem); } else if (type == SINGLE) { - memory_impl::ptr mem1 = (memory_impl::ptr)&to_primitive->output_memory(); + memory::ptr mem1 = to_primitive->output_memory_ptr(); if (iter == 0) { - copy_data(initial_mem, mem1); + mem1->copy_from(stream, *initial_mem); } else { - memory_impl::ptr mem2 = (memory_impl::ptr)&from_primitive->output_memory(); - to_primitive->set_output_memory(*mem2); - from_primitive->set_output_memory(*mem1); + memory::ptr mem2 = from_primitive->output_memory_ptr(); + to_primitive->set_output_memory(mem2); + from_primitive->set_output_memory(mem1); } } } @@ -370,26 +374,20 @@ class typed_primitive_inst : public typed_primitive_inst_base { } } } - - void copy_data(cldnn::memory_impl::ptr src_mem, cldnn::memory_impl::ptr dst_mem) const { - mem_lock from_lock {src_mem}; - mem_lock to_lock {dst_mem}; - const auto src = from_lock.begin(); - const auto dst = to_lock.begin(); - std::copy(src, src + total_bytes, dst); - } }; struct concatenated_memory_mapping { concatenated_memory_mapping(int64_t axis, - memory_impl::ptr concatenated_mem, - std::vector sliced_mems, - int64_t iteration_elements = 0, - int64_t stride = 0, - int64_t initial_offset = 0) : + memory::ptr concatenated_mem, + std::vector sliced_mems, + stream& stream, + int64_t iteration_elements = 0, + int64_t stride = 0, + int64_t initial_offset = 0) : axis(axis), concatenated_mem(concatenated_mem), sliced_mems(sliced_mems), + stream(stream), bytes_per_element(data_type_traits::size_of(concatenated_mem->get_layout().data_type)), batch_size(get_batch_size(concatenated_mem->get_layout(), axis)), bytes_batch_stride((static_cast(concatenated_mem->get_layout().count()) / batch_size) * bytes_per_element), @@ -410,13 +408,13 @@ class typed_primitive_inst : public typed_primitive_inst_base { } void restore_concatenated_mem() const { - mem_lock concat_mem_lock{ concatenated_mem }; + mem_lock concat_mem_lock{ concatenated_mem, stream }; int64_t iteration_offset = bytes_iteration_initial_offset; for (const auto& sliced_mem : sliced_mems) { for (int64_t batch = 0; batch < batch_size; ++batch) { const int64_t src_offset = batch * bytes_iteration; const int64_t dst_offset = batch * bytes_batch_stride + iteration_offset; - mem_lock sliced_mem_lock{ sliced_mem }; + mem_lock sliced_mem_lock{ sliced_mem, stream }; uint8_t* src = sliced_mem_lock.data() + src_offset; uint8_t* dst = concat_mem_lock.data() + dst_offset; std::copy(src, src + bytes_iteration, dst); @@ -427,18 +425,18 @@ class typed_primitive_inst : public typed_primitive_inst_base { void setup_concatenated_output_memory(uint64_t iteration) const { const auto& sliced_output_mem = sliced_mems.at(iteration); - concat_data_prim->set_output_memory(*sliced_output_mem); + concat_data_prim->set_output_memory(sliced_output_mem); } - memory_impl::ptr get_sliced_mem(int64_t iteration) const { - mem_lock from_lock{ concatenated_mem }; + memory::ptr get_sliced_mem(int64_t iteration) const { + mem_lock from_lock{ concatenated_mem, stream }; int64_t batch_offset = 0; const int64_t iteration_offset = bytes_iteration_initial_offset + bytes_iteration_stride * iteration; for (int64_t batch = 0; batch < batch_size; ++batch) { const int64_t src_offset = batch_offset + iteration_offset; const int64_t dst_offset = batch * bytes_iteration; - mem_lock to_lock{ sliced_mems.at(iteration) }; + mem_lock to_lock{ sliced_mems.at(iteration), stream }; const auto src = from_lock.begin() + src_offset; const auto dst = to_lock.begin() + dst_offset; std::copy(src, src + bytes_iteration, dst); @@ -450,8 +448,9 @@ class typed_primitive_inst : public typed_primitive_inst_base { const int64_t axis; std::shared_ptr concat_data_prim; std::shared_ptr sliced_data_prim; - memory_impl::ptr concatenated_mem; - std::vector sliced_mems; + memory::ptr concatenated_mem; + std::vector sliced_mems; + cldnn::stream& stream; // element size const int64_t bytes_per_element; // number of higher level of dimension of slicing axis @@ -483,8 +482,8 @@ class typed_primitive_inst : public typed_primitive_inst_base { private: network_impl::ptr body_network; - memory_impl::ptr get_external_memory(const primitive_id& external_id) const; - std::vector get_sliced_mem(const primitive_id& internal_id) const; + memory::ptr get_external_memory(const primitive_id& external_id) const; + std::vector get_sliced_mem(const primitive_id& internal_id) const; }; using loop_inst = typed_primitive_inst; diff --git a/inference-engine/thirdparty/clDNN/src/include/lrn_inst.h b/inference-engine/thirdparty/clDNN/src/include/lrn_inst.h index 47df087be8f6e5..a7bcd3f33c0744 100644 --- a/inference-engine/thirdparty/clDNN/src/include/lrn_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/lrn_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/lrn.hpp" +#include "cldnn/primitives/lrn.hpp" #include "primitive_inst.h" + #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/lstm_dynamic_input_inst.h b/inference-engine/thirdparty/clDNN/src/include/lstm_dynamic_input_inst.h index 5676fe49914ba8..9ad70dffef0681 100644 --- a/inference-engine/thirdparty/clDNN/src/include/lstm_dynamic_input_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/lstm_dynamic_input_inst.h @@ -4,9 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api_extension/lstm_dynamic_input.hpp" +#include "cldnn/primitives/lstm_dynamic_input.hpp" #include "primitive_inst.h" -#include "error_handler.h" + #include #include @@ -47,11 +47,11 @@ class typed_primitive_inst : public typed_primitive_inst_bas public: typed_primitive_inst(network_impl& network, lstm_dynamic_input_node const& node); - memory_impl& dyn_length_memory() const { return dep_memory(1); } - memory_impl& weights_memory() const { return dep_memory(2); } - memory_impl& bias_memory() const { + memory::ptr dyn_length_memory() const { return dep_memory_ptr(1); } + memory::ptr weights_memory() const { return dep_memory_ptr(2); } + memory::ptr bias_memory() const { CLDNN_ERROR_BOOL(id(), "Bias term", !bias_term(), "Trying to get non existing bias memory."); - return dep_memory(3); + return dep_memory_ptr(3); } int32_t direction() const { return node.direction(); } bool bias_term() const { return node.bias_term(); } diff --git a/inference-engine/thirdparty/clDNN/src/include/lstm_dynamic_inst.h b/inference-engine/thirdparty/clDNN/src/include/lstm_dynamic_inst.h index c64530ffae9840..fe281d35ff4ba7 100644 --- a/inference-engine/thirdparty/clDNN/src/include/lstm_dynamic_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/lstm_dynamic_inst.h @@ -4,9 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/lstm_dynamic.hpp" +#include "cldnn/primitives/lstm_dynamic.hpp" #include "primitive_inst.h" -#include "error_handler.h" + #include #include diff --git a/inference-engine/thirdparty/clDNN/src/include/lstm_dynamic_timeloop_inst.h b/inference-engine/thirdparty/clDNN/src/include/lstm_dynamic_timeloop_inst.h index 6330abb5efcfec..b7ded70f51bf5e 100644 --- a/inference-engine/thirdparty/clDNN/src/include/lstm_dynamic_timeloop_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/lstm_dynamic_timeloop_inst.h @@ -4,9 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api_extension/lstm_dynamic_timeloop.hpp" +#include "cldnn/primitives/lstm_dynamic_timeloop.hpp" #include "primitive_inst.h" -#include "error_handler.h" + #include #include #include @@ -68,12 +68,12 @@ class typed_primitive_inst : public typed_primitive_inst_ public: typed_primitive_inst(network_impl& network, lstm_dynamic_timeloop_node const& node); - memory_impl& dyn_length_memory() const { return get_dependency_memory("dyn_length"); } - memory_impl& recurrent_memory() const { return get_dependency_memory("recurrent"); } - memory_impl& last_hidden_output_memory() const { return get_dependency_memory("last_hidden_output"); } - memory_impl& last_cell_output_memory() const { return get_dependency_memory("last_cell_output"); } - memory_impl& initial_hidden_memory() const { return get_dependency_memory("initial_hidden"); } - memory_impl& initial_cell_memory() const { return get_dependency_memory("initial_cell"); } + memory::ptr dyn_length_memory() const { return get_dependency_memory("dyn_length"); } + memory::ptr recurrent_memory() const { return get_dependency_memory("recurrent"); } + memory::ptr last_hidden_output_memory() const { return get_dependency_memory("last_hidden_output"); } + memory::ptr last_cell_output_memory() const { return get_dependency_memory("last_cell_output"); } + memory::ptr initial_hidden_memory() const { return get_dependency_memory("initial_hidden"); } + memory::ptr initial_cell_memory() const { return get_dependency_memory("initial_cell"); } bool dyn_length_term() const { return node.dyn_length_term(); } bool initial_hidden_term() const { return node.initial_hidden_term(); } @@ -82,7 +82,7 @@ class typed_primitive_inst : public typed_primitive_inst_ bool last_cell_output_term() const { return node.last_cell_output_term(); } private: - memory_impl& get_dependency_memory(std::string val) const { return dep_memory(node.get_dependency_idx(val)); } + memory::ptr get_dependency_memory(std::string val) const { return dep_memory_ptr(node.get_dependency_idx(val)); } }; using lstm_dynamic_timeloop_inst = typed_primitive_inst; diff --git a/inference-engine/thirdparty/clDNN/src/include/lstm_elt_inst.h b/inference-engine/thirdparty/clDNN/src/include/lstm_elt_inst.h index 7cdb1483f4d300..e87d75dba08ecc 100644 --- a/inference-engine/thirdparty/clDNN/src/include/lstm_elt_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/lstm_elt_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/lstm.hpp" +#include "cldnn/primitives/lstm.hpp" #include "primitive_inst.h" + #include namespace cldnn { @@ -43,7 +44,7 @@ class typed_primitive_inst : public typed_primitive_inst_base namespace cldnn { @@ -39,10 +40,10 @@ class typed_primitive_inst : public typed_primitive_inst_base #include @@ -51,14 +52,14 @@ class typed_primitive_inst : public typed_primitive_inst_base { public: typed_primitive_inst(network_impl& network, lstm_node const& node); - memory_impl& weights_memory() const { return dep_memory(1); } - memory_impl& recurrent_memory() const { return dep_memory(2); } - memory_impl& bias_memory() const { return dep_memory(3); } - memory_impl& initial_hidden_memory() const { return dep_memory(bias_term() ? 4 : 3); } - memory_impl& initial_cell_memory() const { + memory& weights_memory() const { return dep_memory(1); } + memory& recurrent_memory() const { return dep_memory(2); } + memory& bias_memory() const { return dep_memory(3); } + memory& initial_hidden_memory() const { return dep_memory(bias_term() ? 4 : 3); } + memory& initial_cell_memory() const { return dep_memory(bias_term() ? (initial_hidden_term() ? 5 : 4) : (initial_hidden_term() ? 4 : 2)); } - memory_impl& peepholes_memory() const { return dep_memory(6); } + memory& peepholes_memory() const { return dep_memory(6); } bool bias_term() const { return !argument.bias.empty(); } bool peepholes_term() const { return !argument.peepholes.empty(); } bool initial_hidden_term() const { return !argument.initial_hidden.empty(); } diff --git a/inference-engine/thirdparty/clDNN/src/include/max_unpooling_inst.h b/inference-engine/thirdparty/clDNN/src/include/max_unpooling_inst.h index 85079daf5b087b..543344011de040 100644 --- a/inference-engine/thirdparty/clDNN/src/include/max_unpooling_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/max_unpooling_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/max_unpooling.hpp" +#include "cldnn/primitives/max_unpooling.hpp" #include "primitive_inst.h" + #include #include diff --git a/inference-engine/thirdparty/clDNN/src/include/memory_impl.h b/inference-engine/thirdparty/clDNN/src/include/memory_impl.h deleted file mode 100644 index a0353637b3306d..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/include/memory_impl.h +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma once -#include "api/memory.hpp" - -#include "engine_impl.h" -#include "refcounted_obj.h" - -namespace cldnn { - -struct memory_impl : refcounted_obj { - memory_impl(const engine_impl::ptr& engine, const layout& layout, uint32_t net_id, allocation_type type, bool reused = false) - : _engine(engine.get()), _layout(layout), _net_id(net_id), _bytes_count(_layout.bytes_count()), _type(type), _reused(reused) {} - - virtual ~memory_impl() { - if (_engine != nullptr && !_reused) { - _engine->get_memory_pool().subtract_memory_used(_bytes_count); - } - } - virtual void* lock() = 0; - virtual void unlock() = 0; - virtual void fill(unsigned char pattern, event_impl::ptr ev) = 0; - size_t size() const { return _bytes_count; } - virtual shared_mem_params get_internal_params() const = 0; - virtual bool is_allocated_by(const engine_impl& engine) const { return &engine == _engine; } - refcounted_obj_ptr get_engine() const { return engine_impl::ptr(_engine); } - const layout& get_layout() const { return _layout; } - uint32_t get_net_id() const { return _net_id; } - void set_net(uint32_t id) { _net_id = id; } - allocation_type get_allocation_type() const { return _type; } - virtual bool is_memory_reset_needed(layout l) { - // To avoid memory reset, output memory must meet the following requirements: - // - To be Weights format (Data memory can be reused by memory_pool, which can lead to errors) - // - To have zero paddings - // - To be completely filled with data - if ((!format::is_weights_format(l.format) && !format::is_simple_data_format(l.format)) || - format::is_winograd(l.format) || format::is_image_2d(l.format)) { - return true; - } - - if (l.data_padding.lower_size() != tensor(0) || l.data_padding.upper_size() != tensor(0)) { - return true; - } - - if (_bytes_count == (l.data_type == data_types::bin ? ceil_div(l.count(), 32) : l.count()) * data_type_traits::size_of(l.data_type)) { - return false; - } - - return true; - } - -protected: - engine_impl *const _engine; - const layout _layout; - uint32_t _net_id; - size_t _bytes_count; - -private: - // layout bytes count, needed because of traits static map destruction - // before run of memory_impl destructor, when engine is static - allocation_type _type; - bool _reused; -}; - -struct simple_attached_memory : memory_impl { - simple_attached_memory(const layout& layout, void* pointer, uint32_t net_id) - : memory_impl((engine_impl::ptr) nullptr, layout, net_id, allocation_type::unknown), _pointer(pointer) {} - - void* lock() override { return _pointer; } - void unlock() override {} - void fill(unsigned char, event_impl::ptr) override {} - shared_mem_params get_internal_params() const override { return { shared_mem_type::shared_mem_empty, nullptr, nullptr, nullptr, -#ifdef _WIN32 - nullptr, -#else - 0, -#endif - 0}; }; - -private: - void* _pointer; -}; - -template -struct mem_lock { - explicit mem_lock(memory_impl::ptr mem) : mem(mem), ptr(reinterpret_cast(mem->lock())) {} - - explicit mem_lock(memory_impl& mem) : mem_lock((memory_impl::ptr) &mem) {} - - ~mem_lock() { - ptr = nullptr; - mem->unlock(); - } - - size_t size() const { return mem->size() / sizeof(T); } - -#if defined(_SECURE_SCL) && (_SECURE_SCL > 0) - auto begin() & { return stdext::make_checked_array_iterator(ptr, size()); } - auto end() & { return stdext::make_checked_array_iterator(ptr, size(), size()); } -#else - T* begin() & { return ptr; } - T* end() & { return ptr + size(); } -#endif - - T* data() const { return ptr; } - -private: - memory_impl::ptr mem; - T* ptr; -}; - -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/include/meta_utils.h b/inference-engine/thirdparty/clDNN/src/include/meta_utils.h index ac412a5ac0e058..7c523ef23599e3 100644 --- a/inference-engine/thirdparty/clDNN/src/include/meta_utils.h +++ b/inference-engine/thirdparty/clDNN/src/include/meta_utils.h @@ -4,9 +4,9 @@ #pragma once +#include "cldnn/runtime/utils.hpp" + #include -#include "api/meta_utils.hpp" -#include "internal_primitive.h" namespace cldnn { @@ -14,22 +14,6 @@ struct primitive; namespace meta { -template -struct pack {}; - -// helper type for deducing return type from member function pointer -// doesn't require passing arguments like std::result_of -template -struct deduce_ret_type; - -template -struct deduce_ret_type { - using type = Ret; -}; - -template -using deduce_ret_type_t = typename deduce_ret_type::type; - template struct is_primitive : public std::integral_constant::type>::value && std::is_same::type>::value> {}; -template -struct is_api_primitive - : public std::integral_constant::value && !std::is_base_of::value> {}; - -template -struct is_internal_primitive - : public std::integral_constant::value && - !std::is_same::type>::value && - std::is_same::type>::value> {}; } // namespace meta -} // namespace cldnn \ No newline at end of file +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/include/mutable_data_inst.h b/inference-engine/thirdparty/clDNN/src/include/mutable_data_inst.h index 02ed1f1ff3b160..311873fb01556d 100644 --- a/inference-engine/thirdparty/clDNN/src/include/mutable_data_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/mutable_data_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/mutable_data.hpp" +#include "cldnn/primitives/mutable_data.hpp" #include "primitive_inst.h" + #include #include @@ -17,18 +18,14 @@ struct typed_program_node : public typed_program_node_base prim, program_impl& prog); - memory_impl& get_attached_memory() const { return *mem; } - memory_impl::ptr get_attached_memory_ptr() const { return mem; } - void attach_memory(memory_impl& new_mem, bool invalidate_users_if_changed = true); + memory& get_attached_memory() const { return *mem; } + memory::ptr get_attached_memory_ptr() const { return mem; } + void attach_memory(memory::ptr new_mem, bool invalidate_users_if_changed = true); program_node& input(size_t idx = 0) const { return get_dependency(idx); } private: - memory_impl::ptr mem; - - void fill_memory(); - void fill_memory_xavier(); - void fill_memory_constant(float value); + memory::ptr mem; }; using mutable_data_node = typed_program_node; @@ -41,7 +38,6 @@ class typed_primitive_inst : public typed_primitive_inst_base namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/network_impl.h b/inference-engine/thirdparty/clDNN/src/include/network_impl.h index a4bfcf1b26d91e..8c5c570cbd4942 100644 --- a/inference-engine/thirdparty/clDNN/src/include/network_impl.h +++ b/inference-engine/thirdparty/clDNN/src/include/network_impl.h @@ -5,12 +5,12 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/network.hpp" - -#include "engine_impl.h" -#include "event_impl.h" +#include "cldnn/graph/network.hpp" +#include "cldnn/runtime/engine.hpp" +#include "cldnn/runtime/event.hpp" +#include "cldnn/runtime/stream.hpp" #include "program_impl.h" -#include "refcounted_obj.h" +#include "implementation_map.h" #include #include @@ -24,30 +24,49 @@ namespace cldnn { class primitive_inst; -struct network_impl : public refcounted_obj { +struct network_impl { public: - explicit network_impl(const program_impl& program, uint16_t stream_id, bool is_internal = false); - network_impl(engine_impl& engine, + using ptr = std::shared_ptr; + explicit network_impl(program_impl::ptr program, stream::ptr stream, bool is_internal = false, bool is_primary_stream = false); + network_impl(engine& engine, const topology_impl& topo, const build_options& options = build_options(), - uint16_t stream_id = 0, bool is_internal = false); - network_impl(engine_impl& engine, + network_impl(engine& engine, const std::set>& nodes, const build_options& options, bool is_internal); ~network_impl(); - const program_impl& get_program() const { return *_program; } - engine_impl& get_engine() const { return _program->get_engine(); } + + static ptr build_network(engine& engine, + const topology_impl& topology, + const build_options& options, + bool is_internal = false); + static ptr build_network(engine& engine, + const std::set>& nodes, + const build_options& options, + bool is_internal); + + static ptr allocate_network(stream::ptr stream, + program_impl::ptr program, + bool is_internal = false, + bool is_primary_stream = false); + + static ptr allocate_network(engine& engine, + program_impl::ptr program, + bool is_internal = false, + bool is_primary_stream = false); + program_impl::cptr get_program() const { return _program; } + program_impl::ptr get_program() { return _program; } + engine& get_engine() const { return _program->get_engine(); } void reset_execution(bool wait = true); - void set_input_data(const primitive_id& id, memory_impl& data); - void set_output_memory(const primitive_id& id, memory_impl& mem); + void set_input_data(const primitive_id& id, memory::ptr data); + void set_output_memory(const primitive_id& id, memory::ptr mem); void set_learning_rate(const float lr); float get_learning_rate(); - uint16_t get_stream_id() const { return _stream_id; } std::vector> const& get_outputs() { return _outputs; } @@ -62,31 +81,33 @@ struct network_impl : public refcounted_obj { std::vector get_all_primitive_org_ids() const; const program_impl::primitives_info& get_primitives_info() const; const program_impl::graph_optimizer_info& get_optimizer_passes_info() const; - void execute(const std::vector& events); + void execute(const std::vector& events); void validate_primitives(); void set_arguments(); // Implementation specific calls std::shared_ptr get_primitive(const primitive_id& id); std::string get_primitive_info(const primitive_id& id) const; - const event_impl::ptr& get_primitive_event(const primitive_id& id) const { return _events.at(id); } + const event::ptr& get_primitive_event(const primitive_id& id) const { return _events.at(id); } bool has_event(const primitive_id& id) const { return _events.count(id); } std::vector> get_primitives(const std::vector& ids); std::vector> get_primitives(const std::vector& nodes); void execute_primitive(const std::shared_ptr& primitive, - const std::vector& events); + const std::vector& events); void allocate_primitives(); void build_insts_deps(); uint32_t get_id() const { return net_id; } + stream& get_stream() const { return *_stream; } + stream::ptr get_stream_ptr() const { return _stream; } void build_exec_order(); bool is_internal() const { return _internal; } - bool is_primary_stream(); - bool is_secondary_stream(); + bool is_primary_stream() { return _is_primary_stream; } private: uint32_t net_id = 0; - const program_impl::cptr _program; - uint16_t _stream_id; + program_impl::ptr _program; + stream::ptr _stream; bool _internal; + bool _is_primary_stream; bool _reset_arguments; float _learning_rate = static_cast(0.00001); @@ -96,11 +117,10 @@ struct network_impl : public refcounted_obj { std::list> _exec_order; std::list> _data_outputs; - std::unordered_map _events; + std::unordered_map _events; void allocate_primitive_instance(program_node const& node); void transfer_memory_to_device(std::shared_ptr instance, program_node const& node); - void allocate_mutable_data_for_streams(std::vector>& mutable_data_nodes); void add_to_exec_order(const primitive_id& id); std::shared_ptr find_in_internal_networks(const primitive_id& id); std::shared_ptr find_primitive(const primitive_id& id); diff --git a/inference-engine/thirdparty/clDNN/src/include/non_max_suppression_inst.h b/inference-engine/thirdparty/clDNN/src/include/non_max_suppression_inst.h index b4ff4c3e4812ac..11e3151ec6bc09 100644 --- a/inference-engine/thirdparty/clDNN/src/include/non_max_suppression_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/non_max_suppression_inst.h @@ -4,7 +4,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/non_max_suppression.hpp" +#include "cldnn/primitives/non_max_suppression.hpp" #include "primitive_inst.h" #include @@ -94,62 +94,62 @@ class typed_primitive_inst : public typed_primitive_inst_ba static layout calc_output_layout(non_max_suppression_node const& node); static std::string to_string(non_max_suppression_node const& node); - memory_impl& input_boxes_mem() const { - return dep_memory(0); + memory::ptr input_boxes_mem() const { + return dep_memory_ptr(0); } - memory_impl& input_scores_mem() const { - return dep_memory(1); + memory::ptr input_scores_mem() const { + return dep_memory_ptr(1); } bool has_num_select_per_class() const { return node.has_num_select_per_class(); } - memory_impl& num_select_per_class_mem() const { - return dep_memory(2); + memory::ptr num_select_per_class_mem() const { + return dep_memory_ptr(2); } bool has_iou_threshold() const { return node.has_iou_threshold(); } - memory_impl& iou_threshold_mem() const { + memory::ptr iou_threshold_mem() const { size_t offset = 2; offset += has_num_select_per_class(); - return dep_memory(offset); + return dep_memory_ptr(offset); } bool has_score_threshold() const { return node.has_score_threshold(); } - memory_impl& score_threshold_mem() const { + memory::ptr score_threshold_mem() const { size_t offset = 2; offset += has_num_select_per_class(); offset += has_iou_threshold(); - return dep_memory(offset); + return dep_memory_ptr(offset); } bool has_soft_nms_sigma() const { return node.has_soft_nms_sigma(); } - memory_impl& soft_nms_sigma_mem() const { + memory::ptr soft_nms_sigma_mem() const { size_t offset = 2; offset += has_num_select_per_class(); offset += has_iou_threshold(); offset += has_score_threshold(); - return dep_memory(offset); + return dep_memory_ptr(offset); } bool has_second_output() const { return node.has_second_output(); } - memory_impl& second_output_mem() const { + memory::ptr second_output_mem() const { size_t offset = 2; offset += has_num_select_per_class(); offset += has_iou_threshold(); offset += has_score_threshold(); offset += has_soft_nms_sigma(); - return dep_memory(offset); + return dep_memory_ptr(offset); } bool has_third_output() const { return node.has_third_output(); } - memory_impl& third_output_mem() const { + memory::ptr third_output_mem() const { size_t offset = 2; offset += has_num_select_per_class(); offset += has_iou_threshold(); offset += has_score_threshold(); offset += has_soft_nms_sigma(); offset += has_second_output(); - return dep_memory(offset); + return dep_memory_ptr(offset); } }; diff --git a/inference-engine/thirdparty/clDNN/src/include/normalize_inst.h b/inference-engine/thirdparty/clDNN/src/include/normalize_inst.h index 7d93b24cd78fec..4f14fe2f3e88a2 100644 --- a/inference-engine/thirdparty/clDNN/src/include/normalize_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/normalize_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/normalize.hpp" +#include "cldnn/primitives/normalize.hpp" #include "primitive_inst.h" + #include namespace cldnn { @@ -34,7 +35,7 @@ class typed_primitive_inst : public typed_primitive_inst_base; diff --git a/inference-engine/thirdparty/clDNN/src/include/one_hot_inst.h b/inference-engine/thirdparty/clDNN/src/include/one_hot_inst.h index 13477f9f3969f4..0db8759d4762f8 100644 --- a/inference-engine/thirdparty/clDNN/src/include/one_hot_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/one_hot_inst.h @@ -4,10 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once - -#include - +#include "cldnn/primitives/one_hot.hpp" #include "primitive_inst.h" + #include #include diff --git a/inference-engine/thirdparty/clDNN/src/include/pass_manager.h b/inference-engine/thirdparty/clDNN/src/include/pass_manager.h index 3faf9d996ce7e7..0047c7bec52347 100644 --- a/inference-engine/thirdparty/clDNN/src/include/pass_manager.h +++ b/inference-engine/thirdparty/clDNN/src/include/pass_manager.h @@ -265,7 +265,7 @@ class propagate_constants : public base_pass { private: void run(program_impl& p) override; - std::list> calculate(engine_impl& engine, build_options bo); + std::list> calculate(engine& engine, build_options bo); bool has_non_const_user(program_node& node) const; void handle_constant(program_impl& prog, program_node& node); void add_constant(program_impl& prog, program_node& node); diff --git a/inference-engine/thirdparty/clDNN/src/include/permute_inst.h b/inference-engine/thirdparty/clDNN/src/include/permute_inst.h index be8b8d8049ccd6..b6250a2b54dc58 100644 --- a/inference-engine/thirdparty/clDNN/src/include/permute_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/permute_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/permute.hpp" +#include "cldnn/primitives/permute.hpp" #include "primitive_inst.h" + #include #include diff --git a/inference-engine/thirdparty/clDNN/src/include/pooling_inst.h b/inference-engine/thirdparty/clDNN/src/include/pooling_inst.h index 5fc2f05b4bd21a..6bcc208cefbd13 100644 --- a/inference-engine/thirdparty/clDNN/src/include/pooling_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/pooling_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/pooling.hpp" +#include "cldnn/primitives/pooling.hpp" #include "primitive_inst.h" + #include #include diff --git a/inference-engine/thirdparty/clDNN/src/include/primitive_inst.h b/inference-engine/thirdparty/clDNN/src/include/primitive_inst.h index 5796620722489c..80987966343c6f 100644 --- a/inference-engine/thirdparty/clDNN/src/include/primitive_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/primitive_inst.h @@ -4,15 +4,15 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once - -#include "api/primitive.hpp" -#include "api/concatenation.hpp" - -#include "event_impl.h" -#include "memory_impl.h" -#include "meta_utils.h" +#include "cldnn/primitives/primitive.hpp" +#include "cldnn/primitives/concatenation.hpp" +#include "cldnn/runtime/error_handler.hpp" +#include "cldnn/runtime/event.hpp" +#include "cldnn/runtime/memory.hpp" #include "kernel_selector_helper.h" +#include "meta_utils.h" #include "program_node.h" +#include "primitive_type.h" #include #include @@ -44,16 +44,17 @@ struct primitive_impl { virtual ~primitive_impl() = default; virtual void set_arguments(primitive_inst& instance) = 0; - virtual void cleanup(primitive_inst& instance) = 0; - virtual event_impl::ptr execute(const std::vector& events, primitive_inst& instance) = 0; + virtual event::ptr execute(const std::vector& events, primitive_inst& instance) = 0; virtual bool validate(const primitive_inst& instance) const = 0; std::string get_kernel_name() const { return _kernel_name; } // TODO: added a derived class for weights reordering (maybe for all static data reordering) kernel_selector::weights_reorder_params _weights_reorder_params; // class typed_primitive_gpu_impl override this with return false; virtual bool is_cpu() const { return true; } + virtual void init_kernels() = 0; + virtual std::unique_ptr clone() const = 0; -private: +protected: std::string _kernel_name; }; @@ -74,8 +75,10 @@ class primitive_inst { return reinterpret_cast> const&>(_deps); } - memory_impl& dep_memory(size_t index) const { return dependencies().at(index)->output_memory(); } - memory_impl& output_memory() const { return *_output; } + memory& dep_memory(size_t index) const { return dependencies().at(index)->output_memory(); } + memory::ptr dep_memory_ptr(size_t index) const { return dependencies().at(index)->output_memory_ptr(); } + memory& output_memory() const { return *_output; } + memory::ptr output_memory_ptr() const { return _output; } size_t inputs_memory_count() const { return _node.get_primitive()->input_size(); } primitive_type_id type() const { return _node.type(); } primitive_id id() const { return _node.id(); } @@ -84,22 +87,28 @@ class primitive_inst { std::shared_ptr desc() const { return _node.get_primitive(); } network_impl& get_network() const { return _network; } uint32_t get_network_id() const; - void set_output_memory(memory_impl& mem); - void check_memory_to_set(const memory_impl& mem, const layout& layout) const; + void set_output_memory(memory::ptr mem); + void check_memory_to_set(const memory& mem, const layout& layout) const; const std::list& get_users() const { return _node.get_users(); } // return pointer to const to prevent arbitrary 'execute' call -> use primitive_inst.execute() instead - primitive_impl* get_impl() const { return _impl.get(); } + const primitive_impl* get_impl() const { return _impl.get(); } - memory_impl& input_memory(size_t index = 0) const { + memory& input_memory(size_t index = 0) const { if (index >= inputs_memory_count()) throw std::range_error("input offset too big"); return dep_memory(index); } - event_impl::ptr execute(const std::vector& events); + memory::ptr input_memory_ptr(size_t index = 0) const { + if (index >= inputs_memory_count()) + throw std::range_error("input offset too big"); + return dep_memory_ptr(index); + } + + event::ptr execute(const std::vector& events); + void init_kernels(); void set_arguments(); - void cleanup(); bool validate() const { if (_impl == nullptr) throw std::invalid_argument("[Internal cldnn error]. Validation method for nullptr impl is not allowed."); @@ -110,8 +119,8 @@ class primitive_inst { void build_deps(); - memory_impl& fused_memory(size_t dep_id) const { - return dep_memory(get_fused_mem_offset() + dep_id); + memory::ptr fused_memory(size_t dep_id) const { + return dep_memory_ptr(get_fused_mem_offset() + dep_id); } bool has_fused_primitives() const { return !_node.get_fused_primitives().empty(); } @@ -136,7 +145,7 @@ class primitive_inst { network_impl& _network; program_node const& _node; - std::shared_ptr _impl; + std::unique_ptr _impl; // this is a set of dependencies in terms of memory, if execution of this primitive requires data from another one, // it should be added to this set @@ -154,14 +163,14 @@ class primitive_inst { // _output is optional because its initialization might be postponed (reshape_inst may either allocate it's own // buffer or attach input as output // depending on reshape_node.is_in_place()) - memory_impl::ptr _output; + memory::ptr _output; bool _output_changed; // todo: implement output reuse if neither of inputs has changed bool _has_valid_input = true; // by default all primitives has valid inputs, exception is input_layout (see input_layout_inst) bool _has_mutable_input = false; - memory_impl::ptr allocate_output(); + memory::ptr allocate_output(); static std::vector> build_exec_deps( std::vector> const& mem_deps); @@ -185,7 +194,7 @@ struct typed_primitive_impl : public primitive_impl { using primitive_impl::primitive_impl; private: - event_impl::ptr execute(const std::vector>& event, + event::ptr execute(const std::vector& event, primitive_inst& instance) override { if (instance.type() != PType::type_id()) throw std::invalid_argument("Implementation type does not match primitive type"); @@ -206,19 +215,9 @@ struct typed_primitive_impl : public primitive_impl { return set_arguments_impl(reinterpret_cast&>(instance)); } - void cleanup(primitive_inst& instance) override { - if (instance.type() != PType::type_id()) - throw std::invalid_argument("Implementation type does not match primitive type"); - if (instance.get_impl() != this) - throw std::invalid_argument( - "Trying to cleanup primitive implementation with mismatching primitive instance"); - - return cleanup_impl(reinterpret_cast&>(instance)); - } virtual void set_arguments_impl(typed_primitive_inst& /*instance*/) {} - virtual void cleanup_impl(typed_primitive_inst& /*instance*/) {} - virtual event_impl::ptr execute_impl(const std::vector& event, + virtual event::ptr execute_impl(const std::vector& event, typed_primitive_inst& instance) = 0; bool validate(const primitive_inst& instance) const override { @@ -233,13 +232,8 @@ struct typed_primitive_impl : public primitive_impl { virtual bool validate_impl(const typed_primitive_inst&) const { return true; } }; -namespace details { template -class api_typed_primitive_inst_base : public primitive_inst { - static_assert(meta::is_api_primitive::value, - "PType should name a non-const, non-volatile type derived from cldnn::primitive but not from " - "cldnn::internal_primitive"); - +class typed_primitive_inst_base : public primitive_inst { public: using typed_node = typed_program_node; using typed_impl = typed_primitive_impl; @@ -247,16 +241,16 @@ class api_typed_primitive_inst_base : public primitive_inst { const typed_node& node; const PType& argument; - api_typed_primitive_inst_base(network_impl& network, typed_node const& node) - : api_typed_primitive_inst_base(network, node, do_allocate_memory(node)) {} + typed_primitive_inst_base(network_impl& network, typed_node const& node) + : typed_primitive_inst_base(network, node, do_allocate_memory(node)) {} protected: - api_typed_primitive_inst_base(network_impl& network, typed_node const& node, bool allocate_memory) + typed_primitive_inst_base(network_impl& network, typed_node const& node, bool allocate_memory) : primitive_inst(network, node, allocate_memory), node(_node), argument(*node.get_primitive()) {} - api_typed_primitive_inst_base(network_impl& network, typed_node const& node, memory_impl& buffer) - : api_typed_primitive_inst_base(network, node, false) { - _output = (memory_impl::ptr) &buffer; + typed_primitive_inst_base(network_impl& network, typed_node const& node, memory::ptr buffer) + : typed_primitive_inst_base(network, node, false) { + _output = buffer; } private: @@ -269,48 +263,6 @@ class api_typed_primitive_inst_base : public primitive_inst { } }; -template -class internal_typed_primitive_inst_base : public primitive_inst { - static_assert(meta::is_internal_primitive::value, - "PType should name a non-const, non-volatile type derived from cldnn::internal_primitive"); - -public: - using typed_node = typed_program_node; - using typed_impl = typed_primitive_impl; - - const typed_node& node; - - internal_typed_primitive_inst_base(network_impl& network, typed_node const& node) - : internal_typed_primitive_inst_base( - network, - node, - false) // by default, do not allocate output buffer automatically for internal primitives - {} - - template - [[noreturn]] void desc(Guard&&...) const { - static_assert(meta::always_false>::value, "Trying to get primitive from internal node"); - } - -protected: - internal_typed_primitive_inst_base(network_impl& network, typed_node const& node, bool allocate_memory) - : primitive_inst(network, node, allocate_memory), node(_node) {} - - internal_typed_primitive_inst_base(network_impl& network, typed_node const& node, memory_impl::ptr buffer) - : internal_typed_primitive_inst_base(network, node, false) { - _output = buffer; - } -}; -} // namespace details - -/* - Base class for all concrete primitive instances. -*/ -template -using typed_primitive_inst_base = typename std::conditional::value, - details::api_typed_primitive_inst_base, - details::internal_typed_primitive_inst_base>::type; - /* Template class which represents instance of primitive 'PType'. Each new primitive should explicitly specialize this class. @@ -330,14 +282,4 @@ class typed_primitive_inst : public typed_primitive_inst_base { static_assert(meta::always_false::value, "Missing typed_primitive_inst specialization"); }; -#define CLDNN_DEFINE_SIMPLE_PRIM_INST(PType) \ - template <> \ - struct typed_primitive_inst : public typed_primitive_inst_base { \ - using typed_primitive_inst_base::typed_primitive_inst_base; \ - static std::string to_string(PType##_node const& arg) { \ - return primitive_inst::generic_to_string(arg, #PType); \ - } \ - }; \ - using PType##_inst = typed_primitive_inst; - } // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/include/primitive_type.h b/inference-engine/thirdparty/clDNN/src/include/primitive_type.h index b608dff853615e..8ccd776183c436 100644 --- a/inference-engine/thirdparty/clDNN/src/include/primitive_type.h +++ b/inference-engine/thirdparty/clDNN/src/include/primitive_type.h @@ -4,10 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/memory.hpp" -#include "api/primitive.hpp" -#include "api/program.hpp" - +#include "cldnn/runtime/memory.hpp" +#include "cldnn/primitives/primitive.hpp" +#include "cldnn/graph/program.hpp" #include "topology_impl.h" #include @@ -15,7 +14,7 @@ namespace cldnn { struct network_impl; -struct engine_impl; +class engine; struct program_node; struct primitive_impl; class primitive_inst; @@ -28,14 +27,12 @@ struct primitive_type { const std::shared_ptr prim) const = 0; virtual std::shared_ptr create_instance(network_impl& network, const program_node& node) const = 0; - virtual std::unique_ptr choose_impl(engine_impl& engine, + virtual std::unique_ptr choose_impl(const engine& engine, const program_node& node) const = 0; - virtual bool does_an_implementation_exist(engine_impl& engine, const program_node& node) const = 0; - virtual bool does_possible_implementation_exist(engine_impl& engine, + virtual bool does_an_implementation_exist(const engine& engine, const program_node& node) const = 0; + virtual bool does_possible_implementation_exist(const engine& engine, const program_node& node) const = 0; virtual layout calc_output_layout(const program_node& node) const = 0; virtual std::string to_string(const program_node& node) const = 0; - - virtual bool is_internal_type() const { return false; } }; } // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/include/primitive_type_base.h b/inference-engine/thirdparty/clDNN/src/include/primitive_type_base.h index faffe78c4ea420..3dc14aa77d286d 100644 --- a/inference-engine/thirdparty/clDNN/src/include/primitive_type_base.h +++ b/inference-engine/thirdparty/clDNN/src/include/primitive_type_base.h @@ -4,21 +4,22 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once + +#include "cldnn/runtime/engine.hpp" + #include "meta_utils.h" #include "primitive_type.h" #include "program_node.h" #include "primitive_inst.h" #include "network_impl.h" -#include "engine_impl.h" +#include "implementation_map.h" + #include #include namespace cldnn { template struct primitive_type_base : primitive_type { - static_assert(meta::is_api_primitive::value, - "Primitive type passed to primitive_type_base should derive from cldnn::primitive"); - std::shared_ptr create_node(program_impl& program, const std::shared_ptr prim) const override { if (prim->type != this) @@ -35,23 +36,26 @@ struct primitive_type_base : primitive_type { return std::make_shared>(network, node); } - std::unique_ptr choose_impl(engine_impl& engine, const cldnn::program_node& node) const override { + // TODO: Should we get rid of engine type in impl map? Or we must pass internal build engine to get real ocl type? + std::unique_ptr choose_impl(const engine& /* engine */, const cldnn::program_node& node) const override { if (node.type() != this) throw std::invalid_argument("primitive_type_base::choose_impl: primitive type mismatch"); - return engine.create_primitive_impl(node.as()); + auto factory = implementation_map::get(engine_types::ocl, node); + return std::move(std::unique_ptr(factory(node))); } - bool does_an_implementation_exist(engine_impl& engine, const cldnn::program_node& node) const override { + bool does_an_implementation_exist(const engine& /* engine */, const cldnn::program_node& node) const override { if (node.type() != this) throw std::invalid_argument("primitive_type_base::choose_impl: primitive type mismatch"); - return engine.does_an_implementation_exist(node.as()); + + return implementation_map::check(engine_types::ocl, node); } - bool does_possible_implementation_exist(engine_impl& engine, const cldnn::program_node& node) const override { + bool does_possible_implementation_exist(const engine& /* engine */, const cldnn::program_node& node) const override { if (node.type() != this) throw std::invalid_argument("primitive_type_base::choose_impl: primitive type mismatch"); - return engine.does_possible_implementation_exist(node.as()); + return implementation_map::check_io_eq(engine_types::ocl, node); } cldnn::layout calc_output_layout(const cldnn::program_node& node) const override { diff --git a/inference-engine/thirdparty/clDNN/src/include/prior_box_inst.h b/inference-engine/thirdparty/clDNN/src/include/prior_box_inst.h index 8aba188276dda2..16c6681509fa1a 100644 --- a/inference-engine/thirdparty/clDNN/src/include/prior_box_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/prior_box_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/prior_box.hpp" +#include "cldnn/primitives/prior_box.hpp" #include "primitive_inst.h" + #include #include @@ -21,10 +22,10 @@ struct typed_program_node : typed_program_node_base { bool is_clustered() const { return get_primitive()->is_clustered(); } void calc_result(); - memory_impl::ptr get_result_buffer() const { return result; } + memory::ptr get_result_buffer() const { return result; } private: - memory_impl::ptr result; + memory::ptr result; }; using prior_box_node = typed_program_node; @@ -40,7 +41,7 @@ class typed_primitive_inst : public typed_primitive_inst_base; diff --git a/inference-engine/thirdparty/clDNN/src/include/program_dump_graph.h b/inference-engine/thirdparty/clDNN/src/include/program_dump_graph.h index 5f8e687cd9089f..381b1ea9cdf1bd 100644 --- a/inference-engine/thirdparty/clDNN/src/include/program_dump_graph.h +++ b/inference-engine/thirdparty/clDNN/src/include/program_dump_graph.h @@ -6,7 +6,6 @@ #include "program_impl.h" #include "program_node.h" -#include "gpu/ocl_toolkit.h" #include #include @@ -18,4 +17,4 @@ void dump_graph_optimized(std::ofstream&, const program_impl&); void dump_graph_processing_order(std::ofstream&, const program_impl&); void dump_graph_init(std::ofstream&, const program_impl&, std::function const&); void dump_graph_info(std::ofstream&, const program_impl&, std::function const&); -} // namespace cldnn \ No newline at end of file +} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/include/program_helpers.h b/inference-engine/thirdparty/clDNN/src/include/program_helpers.h index cdef2a3b18d663..60291deb1e7557 100644 --- a/inference-engine/thirdparty/clDNN/src/include/program_helpers.h +++ b/inference-engine/thirdparty/clDNN/src/include/program_helpers.h @@ -7,8 +7,10 @@ #pragma once #include "program_node.h" -#include "engine_impl.h" +#include "cldnn/runtime/engine.hpp" #include "program_impl.h" +#include "data_inst.h" + #include #include #include @@ -95,7 +97,7 @@ struct program_helpers { else do_for_types(node, rest...); } - static void merge_buffers(engine_impl& engine, + static void merge_buffers(engine& engine, program_node& node, const layout& target_layout, size_t begin_offset, diff --git a/inference-engine/thirdparty/clDNN/src/include/program_impl.h b/inference-engine/thirdparty/clDNN/src/include/program_impl.h index 4588ec4ec801fc..fe8c8cb55f2795 100644 --- a/inference-engine/thirdparty/clDNN/src/include/program_impl.h +++ b/inference-engine/thirdparty/clDNN/src/include/program_impl.h @@ -6,10 +6,10 @@ #pragma once -#include "api/program.hpp" - -#include "refcounted_obj.h" -#include "engine_impl.h" +#include "cldnn/graph/program.hpp" +#include "cldnn/runtime/engine.hpp" +#include "cldnn/runtime/stream.hpp" +#include "runtime/kernels_cache.hpp" #include #include @@ -19,6 +19,10 @@ #include #include +namespace kernel_selector { +class TuningCache; +} // namespace kernel_selector + namespace cldnn { struct topology_impl; @@ -28,10 +32,19 @@ class layout_optimizer; class pass_manager; class base_pass; class program_impl_wrapper; + +struct gpu_program_state { + kernels_cache _kernels_cache; + + gpu_program_state(engine& engine) : _kernels_cache(engine) {} +}; + /* cldnn_program implementation */ -struct program_impl : public refcounted_obj { +struct program_impl { + using ptr = std::shared_ptr; + using cptr = std::shared_ptr; friend class calculate_prior_boxes; // to be removed when possible friend class graph_initializations; // to be removed when possible friend class prepare_padding; // to be removed when possible @@ -121,18 +134,18 @@ struct program_impl : public refcounted_obj { typedef std::vector> graph_optimizer_info; typedef std::pair> optimized_info; - program_impl(engine_impl& engine_ref, + program_impl(engine& engine_ref, topology_impl const& topology, build_options const& options, bool is_internal, bool no_optimizations = false); /* constructor used to build a program from subset of nodes of other program (used in propagate_constants) */ - program_impl(engine_impl& engine_ref, + program_impl(engine& engine_ref, std::set> const& nodes, build_options const& options, bool is_internal); ~program_impl(); - engine_impl& get_engine() const { return *engine; } + engine& get_engine() const { return _engine; } const build_options& get_options() const { return options; } std::list& get_inputs() { return inputs; @@ -144,6 +157,7 @@ struct program_impl : public refcounted_obj { const nodes_ordering& get_processing_order() const; nodes_ordering& get_processing_order(); uint32_t get_prog_id() { return prog_id; } + stream& get_stream() { return *_stream; } const std::list& get_optimized_out() const { return optimized_out; } const std::list& get_optimized() const { return optimized; } bool has_node(const primitive_id& prim) const { return nodes_map.count(prim) > 0; } @@ -151,7 +165,6 @@ struct program_impl : public refcounted_obj { program_node const& get_node(primitive_id const& id) const; std::shared_ptr get_node_ptr(const primitive_id& prim) { return nodes_map.at(prim); } std::shared_ptr get_node_ptr(const primitive_id& prim) const { return nodes_map.at(prim); } - void dump_memory_pool() const; // returns already existing program_node for given primitive 'prim' (lookup in 'nodes_map') // if it was previously created, otherwise creates and then returns program_node @@ -211,14 +224,36 @@ struct program_impl : public refcounted_obj { void reset_program(); uint32_t get_id() const { return prog_id; } + static ptr build_program(engine& engine, + const topology_impl& topology, + const build_options& options, + bool is_internal = false, + bool no_optimizations = false); + static ptr build_program(engine& engine, + const std::set>& nodes, + const build_options& options, + bool is_internal); + static void init_primitives(); + void compile(); + void init_kernels(); + kernel_id add_kernel(const std::shared_ptr kernel_sring); + kernel::ptr get_kernel(kernel_id id); + + void load_tuning_cache(); + std::shared_ptr get_tuning_cache() const { return tuning_cache; } + private: uint32_t prog_id = 0; - engine_impl::ptr engine; + engine& _engine; + stream::ptr _stream; + gpu_program_state program_state; build_options options; std::list inputs; std::vector outputs; nodes_ordering processing_order; std::unique_ptr pm; + std::shared_ptr tuning_cache; + std::map> nodes_map; std::list optimized_out; diff --git a/inference-engine/thirdparty/clDNN/src/include/program_node.h b/inference-engine/thirdparty/clDNN/src/include/program_node.h index 3e8711d8625034..d0e904d3c56379 100644 --- a/inference-engine/thirdparty/clDNN/src/include/program_node.h +++ b/inference-engine/thirdparty/clDNN/src/include/program_node.h @@ -4,15 +4,14 @@ #pragma once -#include -#include +#include "cldnn/primitives/primitive.hpp" +#include "cldnn/primitives/activation.hpp" -#include "api/primitive.hpp" -#include "api/activation.hpp" -#include "internal_primitive.h" #include "kernel_selector_helper.h" - #include "meta_utils.h" + +#include +#include #include #include #include @@ -21,6 +20,7 @@ namespace cldnn { struct program_impl; +struct primitive_impl; class reorder_inputs; class graph_initializations; class prepare_quantization; @@ -29,9 +29,6 @@ class pre_replace_deconv; template struct typed_program_node; -template -struct internal_primitive_type_base; - class json_composite; class xml_composite; @@ -92,10 +89,10 @@ struct program_node { } program_impl& get_program() { return myprog; } - program_impl const& get_program() const { return myprog; } + program_impl& get_program() const { return myprog; } - std::shared_ptr get_selected_impl() const { return selected_impl; } - void set_selected_impl(std::shared_ptr impl) { selected_impl = impl; } + primitive_impl* get_selected_impl() const { return selected_impl.get(); } + void set_selected_impl(std::unique_ptr impl); std::vector const& get_dependencies() const { return dependencies; } program_node& get_dependency(size_t idx) const { return *dependencies.at(idx); } @@ -312,7 +309,7 @@ struct program_node { std::shared_ptr desc; program_impl& myprog; - std::shared_ptr selected_impl; + std::unique_ptr selected_impl; bool valid_output_layout = false; layout output_layout = layout(data_types::f32, format::bfyx, tensor()); @@ -353,12 +350,16 @@ struct program_node { void invalidate_users() const; }; -namespace details { +/* +Template class used to indicate that usage context requires 'program_node' to wrap primitive +of type 'PType'. Successful conversion from 'program_node' to 'typed_program_node' means +that this restriction in fact holds and functions/method/etc. may saftly use uderlaying primitive. + +This class shadows 'get_primitive' method from base class which now returns pointer to more specific +type. +*/ template -struct api_typed_program_node_base : public program_node { - static_assert(meta::is_api_primitive::value, - "PType should name a non-const, non-volatile type derived from cldnn::primitive but not from " - "cldnn::internal_primitive"); +struct typed_program_node_base : public program_node { friend class cldnn::graph_initializations; friend class cldnn::pre_replace_deconv; friend class cldnn::prepare_quantization; @@ -376,57 +377,6 @@ struct api_typed_program_node_base : public program_node { std::shared_ptr typed_desc() const { return std::static_pointer_cast(desc); } }; -struct internal_program_node_base : public program_node { - friend struct cldnn::program_impl; - - explicit internal_program_node_base(program_impl& prog); - - const primitive_id& id() const override { return internal_id; } - - void set_implementation(std::unique_ptr&& impl); - -private: - primitive_id internal_id; - - static primitive_id get_next_internal_id(); -}; - -template -struct internal_typed_program_node_base : public internal_program_node_base { - static_assert(meta::is_internal_primitive::value, - "PType should name a non-const, non-volatile type derived from cldnn::internal_primitive"); - -public: - using internal_program_node_base::internal_program_node_base; - - primitive_type_id type() const override { return PType::type_id(); } - - template - [[noreturn]] void get_primitive(Guard&&...) { - static_assert(meta::always_false>::value, "Trying to get primitive from internal node"); - } - -protected: - template - [[noreturn]] void typed_desc(Guard&&...) { - static_assert(meta::always_false>::value, "Trying to get primitive from internal node"); - } -}; -} // namespace details - -/* -Template class used to indicate that usage context requires 'program_node' to wrap primitive -of type 'PType'. Successful conversion from 'program_node' to 'typed_program_node' means -that this restriction in fact holds and functions/method/etc. may saftly use uderlaying primitive. - -This class shadows 'get_primitive' method from base class which now returns pointer to more specific -type. -*/ -template -using typed_program_node_base = typename std::conditional::value, - details::api_typed_program_node_base, - details::internal_typed_program_node_base>::type; - /* Actual template class used in context which requires 'program_node' to wrap primitive of type 'PType'. This class is introduced to provide possibility of explicit specialization. diff --git a/inference-engine/thirdparty/clDNN/src/include/proposal_inst.h b/inference-engine/thirdparty/clDNN/src/include/proposal_inst.h index d1fa03f8d9e58e..3c67afe4003cfa 100644 --- a/inference-engine/thirdparty/clDNN/src/include/proposal_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/proposal_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/proposal.hpp" +#include "cldnn/primitives/proposal.hpp" #include "primitive_inst.h" + #include #include diff --git a/inference-engine/thirdparty/clDNN/src/include/pyramid_roi_align_inst.h b/inference-engine/thirdparty/clDNN/src/include/pyramid_roi_align_inst.h index 45cd6638f741ab..829f5228f61897 100644 --- a/inference-engine/thirdparty/clDNN/src/include/pyramid_roi_align_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/pyramid_roi_align_inst.h @@ -3,7 +3,7 @@ // #pragma once -#include "api/pyramid_roi_align.hpp" +#include "cldnn/primitives/pyramid_roi_align.hpp" #include "primitive_inst.h" #include @@ -36,11 +36,11 @@ class typed_primitive_inst : public typed_primitive_inst_base static std::string to_string(pyramid_roi_align_node const& node); typed_primitive_inst(network_impl& network, pyramid_roi_align_node const& node); - memory_impl& input() const { return dep_memory(0); } - memory_impl& P2() const { return dep_memory(1); } - memory_impl& P3() const { return dep_memory(2); } - memory_impl& P4() const { return dep_memory(3); } - memory_impl& P5() const { return dep_memory(4); } + memory& input() const { return dep_memory(0); } + memory& P2() const { return dep_memory(1); } + memory& P3() const { return dep_memory(2); } + memory& P4() const { return dep_memory(3); } + memory& P5() const { return dep_memory(4); } }; using pyramid_roi_align_inst = typed_primitive_inst; diff --git a/inference-engine/thirdparty/clDNN/src/include/quantize_inst.h b/inference-engine/thirdparty/clDNN/src/include/quantize_inst.h index 0cf0b30e81c0cc..1d680ecb3cce20 100644 --- a/inference-engine/thirdparty/clDNN/src/include/quantize_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/quantize_inst.h @@ -4,7 +4,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/quantize.hpp" +#include "cldnn/primitives/quantize.hpp" #include "primitive_inst.h" #include "data_inst.h" #include "kernel_selector/core/actual_kernels/quantize/quantize_kernel_params.h" diff --git a/inference-engine/thirdparty/clDNN/src/include/reduce_inst.h b/inference-engine/thirdparty/clDNN/src/include/reduce_inst.h index 6574ce8de21a97..678f861a2a8694 100644 --- a/inference-engine/thirdparty/clDNN/src/include/reduce_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/reduce_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/reduce.hpp" +#include "cldnn/primitives/reduce.hpp" #include "primitive_inst.h" + #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/refcounted_obj.h b/inference-engine/thirdparty/clDNN/src/include/refcounted_obj.h deleted file mode 100644 index 82b931f65da3c2..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/include/refcounted_obj.h +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma once -#include -#include - -namespace cldnn { - -template -struct refcounted_obj_ptr; - -/** - * \brief Base class for all reference counted pointers aka PIMPL implementations - */ -// TODO refine this code for multithreading support -template -class refcounted_obj { -public: - using ptr = refcounted_obj_ptr::type>; - using cptr = refcounted_obj_ptr::type>; - - refcounted_obj() : _ref_count(1) {} - - virtual ~refcounted_obj() = default; - - void add_ref() const { ++_ref_count; } - - void release() const { - if ((--_ref_count) == 0) - delete static_cast(this); - } - - int get_ref_count() const { return _ref_count; } - -private: - mutable std::atomic_int _ref_count; -}; - -template -struct refcounted_obj_ptr { - template - explicit refcounted_obj_ptr(T* ptr, bool add_ref = true) : _ptr(ptr) { - static_assert(std::is_base_of::type>, U>::value, - "Object handled with refcounted_obj_ptr should derive from refcounted_obj"); - if (add_ref) - ptr_add_ref(); - } - - // for refcounted_obj_ptr, allow contruction from T* - template ::value>::type> - explicit refcounted_obj_ptr(typename std::remove_const::type* ptr, bool add_ref = true) : _ptr(ptr) { - static_assert(std::is_base_of::type>, U>::value, - "Object handled with refcounted_obj_ptr should derive from refcounted_obj"); - if (add_ref) - ptr_add_ref(); - } - - constexpr refcounted_obj_ptr() : _ptr(nullptr) {} - - refcounted_obj_ptr(const refcounted_obj_ptr& other) : _ptr(other._ptr) { ptr_add_ref(); } - - refcounted_obj_ptr& operator=(const refcounted_obj_ptr& other) { - if (this == &other) - return *this; - ptr_release(); - _ptr = other._ptr; - ptr_add_ref(); - return *this; - } - - refcounted_obj_ptr(refcounted_obj_ptr&& other) noexcept { - _ptr = other._ptr; - other._ptr = nullptr; - } - - refcounted_obj_ptr& operator=(refcounted_obj_ptr&& other) { - if (this == &other) - return *this; - ptr_release(); - _ptr = other._ptr; - other._ptr = nullptr; - return *this; - } - - ~refcounted_obj_ptr() { - ptr_release(); - _ptr = nullptr; - } - - T* detach() { - T* result = _ptr; - _ptr = nullptr; - return result; - } - - void reset(T* ptr, bool add_ref = true) { - ptr_release(); - _ptr = ptr; - if (add_ref) - ptr_add_ref(); - } - - operator bool() const { return _ptr != nullptr; } - T* get() const { return _ptr; } - T& operator*() const { return *get(); } - T* operator->() const { return get(); } - - friend bool operator==(const refcounted_obj_ptr& lhs, const refcounted_obj_ptr& rhs) { - return lhs._ptr == rhs._ptr; - } - - friend bool operator!=(const refcounted_obj_ptr& lhs, const refcounted_obj_ptr& rhs) { return !(lhs == rhs); } - - // for refcounted_obj_ptr, allow conversion to refcounted_obj_ptr - template - operator refcounted_obj_ptr() const { - return refcounted_obj_ptr(_ptr); - } - -private: - T* _ptr; - void ptr_add_ref() { - if (_ptr) - _ptr->add_ref(); - } - void ptr_release() { - if (_ptr) - _ptr->release(); - } -}; - -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/include/region_yolo_inst.h b/inference-engine/thirdparty/clDNN/src/include/region_yolo_inst.h index 26553e215cecc9..0b6a24068cccc8 100644 --- a/inference-engine/thirdparty/clDNN/src/include/region_yolo_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/region_yolo_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/region_yolo.hpp" +#include "cldnn/primitives/region_yolo.hpp" #include "primitive_inst.h" + #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/reorder_inst.h b/inference-engine/thirdparty/clDNN/src/include/reorder_inst.h index c9fccb0d7c7106..ce851e482aebb5 100644 --- a/inference-engine/thirdparty/clDNN/src/include/reorder_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/reorder_inst.h @@ -4,8 +4,10 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/reorder.hpp" + +#include "cldnn/primitives/reorder.hpp" #include "primitive_inst.h" + #include #include @@ -50,8 +52,8 @@ class typed_primitive_inst : public typed_primitive_inst_base public: typed_primitive_inst(network_impl& network, reorder_node const& node); - memory_impl& mean_nv12_memory() const { return dep_memory(2); } - memory_impl& mean_memory() const { return dep_memory(1); } + memory::ptr mean_nv12_memory() const { return dep_memory_ptr(2); } + memory::ptr mean_memory() const { return dep_memory_ptr(1); } bool has_mean() const { return !argument.mean.empty(); } diff --git a/inference-engine/thirdparty/clDNN/src/include/reorg_yolo_inst.h b/inference-engine/thirdparty/clDNN/src/include/reorg_yolo_inst.h index 43361d31760ef9..43efd38a9b5180 100644 --- a/inference-engine/thirdparty/clDNN/src/include/reorg_yolo_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/reorg_yolo_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/reorg_yolo.hpp" +#include "cldnn/primitives/reorg_yolo.hpp" #include "primitive_inst.h" + #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/resample_inst.h b/inference-engine/thirdparty/clDNN/src/include/resample_inst.h index 33bf98f2ddaf63..6bb8de03b27351 100644 --- a/inference-engine/thirdparty/clDNN/src/include/resample_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/resample_inst.h @@ -4,10 +4,11 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/resample.hpp" +#include "cldnn/primitives/resample.hpp" #include "primitive_inst.h" -#include #include "topology_impl.h" + +#include #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/reshape_inst.h b/inference-engine/thirdparty/clDNN/src/include/reshape_inst.h index 3c640441bad3f3..32adce5518613a 100644 --- a/inference-engine/thirdparty/clDNN/src/include/reshape_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/reshape_inst.h @@ -4,9 +4,10 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/reshape.hpp" +#include "cldnn/primitives/reshape.hpp" #include "primitive_inst.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" + #include #include diff --git a/inference-engine/thirdparty/clDNN/src/include/reverse_sequence_inst.h b/inference-engine/thirdparty/clDNN/src/include/reverse_sequence_inst.h index 51f4a24a8cbb6c..60ba5b3dd4e297 100644 --- a/inference-engine/thirdparty/clDNN/src/include/reverse_sequence_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/reverse_sequence_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/reverse_sequence.hpp" +#include "cldnn/primitives/reverse_sequence.hpp" #include "primitive_inst.h" + #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/roi_pooling_inst.h b/inference-engine/thirdparty/clDNN/src/include/roi_pooling_inst.h index f9c3dc3b069f46..6d3cfcf9f38355 100644 --- a/inference-engine/thirdparty/clDNN/src/include/roi_pooling_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/roi_pooling_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/roi_pooling.hpp" +#include "cldnn/primitives/roi_pooling.hpp" #include "primitive_inst.h" + #include namespace cldnn { @@ -34,8 +35,8 @@ class typed_primitive_inst : public typed_primitive_inst_base; diff --git a/inference-engine/thirdparty/clDNN/src/include/scale_inst.h b/inference-engine/thirdparty/clDNN/src/include/scale_inst.h index 018daad2a8cfd3..a25fb49be994e7 100644 --- a/inference-engine/thirdparty/clDNN/src/include/scale_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/scale_inst.h @@ -4,11 +4,12 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/scale.hpp" +#include "cldnn/primitives/scale.hpp" #include "primitive_inst.h" +#include "kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_base.h" + #include #include -#include "kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_base.h" namespace cldnn { @@ -47,8 +48,8 @@ class typed_primitive_inst : public typed_primitive_inst_base { public: typed_primitive_inst(network_impl& network, scale_node const& desc); - memory_impl& scale_memory() const { return dep_memory(1); } - memory_impl& bias_memory() const { return dep_memory(2); } + memory::ptr scale_memory() const { return dep_memory_ptr(1); } + memory::ptr bias_memory() const { return dep_memory_ptr(2); } bool bias_term() const { return _node.as().bias_term(); } }; diff --git a/inference-engine/thirdparty/clDNN/src/include/scatter_elements_update_inst.h b/inference-engine/thirdparty/clDNN/src/include/scatter_elements_update_inst.h index dd87a7facce92d..f70bed68bee509 100644 --- a/inference-engine/thirdparty/clDNN/src/include/scatter_elements_update_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/scatter_elements_update_inst.h @@ -4,7 +4,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/scatter_elements_update.hpp" +#include "cldnn/primitives/scatter_elements_update.hpp" #include "primitive_inst.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/include/scatter_nd_update_inst.h b/inference-engine/thirdparty/clDNN/src/include/scatter_nd_update_inst.h index 1da6e21445ccf9..acf3ee9c6c010d 100644 --- a/inference-engine/thirdparty/clDNN/src/include/scatter_nd_update_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/scatter_nd_update_inst.h @@ -4,7 +4,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/scatter_nd_update.hpp" +#include "cldnn/primitives/scatter_nd_update.hpp" #include "primitive_inst.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/include/scatter_update_inst.h b/inference-engine/thirdparty/clDNN/src/include/scatter_update_inst.h index 54fa0fae09dc52..1c9b7934f25aa1 100644 --- a/inference-engine/thirdparty/clDNN/src/include/scatter_update_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/scatter_update_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/scatter_update.hpp" +#include "cldnn/primitives/scatter_update.hpp" #include "primitive_inst.h" + #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/select_inst.h b/inference-engine/thirdparty/clDNN/src/include/select_inst.h index bd59f29062db5f..4adde4e8c604e5 100644 --- a/inference-engine/thirdparty/clDNN/src/include/select_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/select_inst.h @@ -4,9 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include - +#include "cldnn/primitives/select.hpp" #include "primitive_inst.h" + #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/shuffle_channels_inst.h b/inference-engine/thirdparty/clDNN/src/include/shuffle_channels_inst.h index 585d7440ba7a78..278f9c56fab065 100644 --- a/inference-engine/thirdparty/clDNN/src/include/shuffle_channels_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/shuffle_channels_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/shuffle_channels.hpp" +#include "cldnn/primitives/shuffle_channels.hpp" #include "primitive_inst.h" + #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/sliding_window_utils.h b/inference-engine/thirdparty/clDNN/src/include/sliding_window_utils.h index b832c49979fe06..369b78f4a8bd44 100644 --- a/inference-engine/thirdparty/clDNN/src/include/sliding_window_utils.h +++ b/inference-engine/thirdparty/clDNN/src/include/sliding_window_utils.h @@ -4,15 +4,15 @@ #pragma once -#include -#include +#include "cldnn/runtime/layout.hpp" +#include "cldnn/runtime/tensor.hpp" + +#include "meta_utils.h" #include #include #include -#include "meta_utils.h" - namespace cldnn { /// @brief Sliding window output range computation mode. diff --git a/inference-engine/thirdparty/clDNN/src/include/softmax_inst.h b/inference-engine/thirdparty/clDNN/src/include/softmax_inst.h index 1fc97c3288c8ce..8bf45e7392446f 100644 --- a/inference-engine/thirdparty/clDNN/src/include/softmax_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/softmax_inst.h @@ -4,8 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/softmax.hpp" +#include "cldnn/primitives/softmax.hpp" #include "primitive_inst.h" + #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/space_to_batch_inst.h b/inference-engine/thirdparty/clDNN/src/include/space_to_batch_inst.h index 3fed298e57fbdb..db2f69719d9499 100644 --- a/inference-engine/thirdparty/clDNN/src/include/space_to_batch_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/space_to_batch_inst.h @@ -4,8 +4,10 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/space_to_batch.hpp" + +#include "cldnn/primitives/space_to_batch.hpp" #include "primitive_inst.h" + #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/space_to_depth_inst.h b/inference-engine/thirdparty/clDNN/src/include/space_to_depth_inst.h index 527c17e9b85427..2cebeb7cdf8127 100644 --- a/inference-engine/thirdparty/clDNN/src/include/space_to_depth_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/space_to_depth_inst.h @@ -4,8 +4,10 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/space_to_depth.hpp" + +#include "cldnn/primitives/space_to_depth.hpp" #include "primitive_inst.h" + #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/split_inst.h b/inference-engine/thirdparty/clDNN/src/include/split_inst.h index 16f74d64e4a0e7..af9a8e402eb08b 100644 --- a/inference-engine/thirdparty/clDNN/src/include/split_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/split_inst.h @@ -4,8 +4,10 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/split.hpp" + +#include "cldnn/primitives/split.hpp" #include "primitive_inst.h" + #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/strided_slice_inst.h b/inference-engine/thirdparty/clDNN/src/include/strided_slice_inst.h index 812cd2137612d3..406d46b44effc7 100644 --- a/inference-engine/thirdparty/clDNN/src/include/strided_slice_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/strided_slice_inst.h @@ -4,9 +4,11 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/strided_slice.hpp" + +#include "cldnn/primitives/strided_slice.hpp" #include "primitive_inst.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" + #include #include diff --git a/inference-engine/thirdparty/clDNN/src/include/tile_inst.h b/inference-engine/thirdparty/clDNN/src/include/tile_inst.h index ea3966c5ee5a9d..4569201f79caad 100644 --- a/inference-engine/thirdparty/clDNN/src/include/tile_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/tile_inst.h @@ -4,8 +4,10 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/tile.hpp" + +#include "cldnn/primitives/tile.hpp" #include "primitive_inst.h" + #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/to_string_utils.h b/inference-engine/thirdparty/clDNN/src/include/to_string_utils.h index ae48ecd853a29f..299675318879e5 100644 --- a/inference-engine/thirdparty/clDNN/src/include/to_string_utils.h +++ b/inference-engine/thirdparty/clDNN/src/include/to_string_utils.h @@ -3,12 +3,15 @@ // #pragma once + +#include "cldnn/runtime/tensor.hpp" +#include "cldnn/runtime/layout.hpp" +#include "cldnn/runtime/device.hpp" +#include "cldnn/primitives/primitive.hpp" + + #include #include -#include "api/tensor.hpp" -#include "api/layout.hpp" -#include "api/primitive.hpp" -#include "device_impl.h" #include namespace cldnn { diff --git a/inference-engine/thirdparty/clDNN/src/include/topology_impl.h b/inference-engine/thirdparty/clDNN/src/include/topology_impl.h index 2e9b943ca146f8..bb1df4fc4b7ddb 100644 --- a/inference-engine/thirdparty/clDNN/src/include/topology_impl.h +++ b/inference-engine/thirdparty/clDNN/src/include/topology_impl.h @@ -4,9 +4,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once -#include "api/primitive.hpp" -#include "api/input_layout.hpp" -#include "refcounted_obj.h" + +#include "cldnn/primitives/primitive.hpp" +#include "cldnn/primitives/input_layout.hpp" #include #include @@ -16,8 +16,9 @@ namespace cldnn { typedef std::map> topology_map; -struct topology_impl : public refcounted_obj { +struct topology_impl { public: + using ptr = std::shared_ptr; explicit topology_impl(const topology_map& map = topology_map()) : _primitives(map) {} void add(std::shared_ptr desc) { diff --git a/inference-engine/thirdparty/clDNN/src/input_layout.cpp b/inference-engine/thirdparty/clDNN/src/input_layout.cpp index b4df10dd23a66f..6aaefe16e65296 100644 --- a/inference-engine/thirdparty/clDNN/src/input_layout.cpp +++ b/inference-engine/thirdparty/clDNN/src/input_layout.cpp @@ -5,8 +5,8 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include "input_layout_inst.h" #include "primitive_type_base.h" -#include "memory_impl.h" -#include "error_handler.h" +#include "cldnn/runtime/memory.hpp" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include #include @@ -27,16 +27,16 @@ input_layout_inst::typed_primitive_inst(network_impl& network, input_layout_node _has_valid_input = false; // by default input for 'input_layout' is invalid as long as user doesn't call set_data } -void input_layout_inst::set_data(memory_impl& mem) { +void input_layout_inst::set_data(memory::ptr mem) { auto ol = node.get_output_layout(); - check_memory_to_set(mem, ol); + check_memory_to_set(*mem, ol); - if (mem.is_allocated_by(get_network().get_engine())) { - _output = (memory_impl::ptr) &mem; + if (mem->is_allocated_by(get_network().get_engine())) { + _output = mem; } else { - mem_lock src((memory_impl::ptr) &mem); - mem_lock dst(_output); + mem_lock src(mem, get_network().get_stream()); + mem_lock dst(_output, get_network().get_stream()); std::copy(src.begin(), src.end(), dst.begin()); } diff --git a/inference-engine/thirdparty/clDNN/src/kernel_selector_helper.cpp b/inference-engine/thirdparty/clDNN/src/kernel_selector_helper.cpp index 7ba2a515120ae4..716b5fa49eb494 100644 --- a/inference-engine/thirdparty/clDNN/src/kernel_selector_helper.cpp +++ b/inference-engine/thirdparty/clDNN/src/kernel_selector_helper.cpp @@ -6,7 +6,6 @@ #include "kernel_selector_params.h" #include "to_string_utils.h" -#include "gpu/ocl_toolkit.h" #include "program_node.h" #include "program_impl.h" @@ -733,28 +732,27 @@ kernel_selector::activation_function get_kernel_selector_activation_param(activa void set_params(const program_node& node, kernel_selector::params& params) { const auto& program = node.get_program(); - const auto& context = program.get_engine().get_context(); - const auto& device_info = context->get_device_info(); - - params.engineInfo.bSubGroupSupport = context->extension_supported("cl_intel_subgroups"); - params.engineInfo.bSubGroupShortSupport = context->extension_supported("cl_intel_subgroups_short"); - params.engineInfo.bSubGroupCharSupport = context->extension_supported("cl_intel_subgroups_char"); - params.engineInfo.bFP16Support = context->extension_supported("cl_khr_fp16"); - params.engineInfo.bFP64Support = context->extension_supported("cl_khr_fp64"); + const auto& device_info = program.get_engine().get_device_info(); + + params.engineInfo.bSubGroupSupport = device_info.supports_subgroups; + params.engineInfo.bSubGroupShortSupport = device_info.supports_subgroups_short; + params.engineInfo.bSubGroupCharSupport = device_info.supports_subgroups_char; + params.engineInfo.bFP16Support = device_info.supports_fp16; + params.engineInfo.bFP64Support = device_info.supports_fp64; params.engineInfo.bIMADSupport = device_info.supports_imad != 0; params.engineInfo.bIMMADSupport = device_info.supports_immad != 0; params.engineInfo.bImageSupport = device_info.supports_image != 0; - params.engineInfo.bOptHintsSupport = device_info.supports_optimization_hints; + params.engineInfo.bOptHintsSupport = false; params.engineInfo.bLocalBlockIOSupport = device_info.supports_local_block_io; params.engineInfo.deviceType = get_device_type(device_info.dev_type); params.engineInfo.maxWorkGroupSize = device_info.max_work_group_size; params.engineInfo.maxLocalMemSize = device_info.max_local_mem_size; params.engineInfo.maxImage2dWidth = device_info.max_image2d_width; params.engineInfo.maxImage2dHeight = device_info.max_image2d_height; - params.engineInfo.computeUnitsCount = device_info.compute_units_count; + params.engineInfo.computeUnitsCount = device_info.execution_units_count; params.engineInfo.maxThreadsPerExecutionUnit = device_info.max_threads_per_execution_unit; params.engineInfo.maxThreadsPerDevice = device_info.max_threads_per_device; - params.engineInfo.deviceCache = context->get_device_cache(); + params.engineInfo.deviceCache = program.get_tuning_cache(); params.engineInfo.driverVersion = device_info.driver_version; auto impl_forcing_bo = program.get_options().get(); @@ -766,9 +764,7 @@ void set_params(const program_node& node, kernel_selector::params& params) { } void set_optional_params(const program_impl& program, kernel_selector::optional_params& params) { - const auto& context = program.get_engine().get_context(); - - params.meaningfulKernelsNames = context->get_configuration().meaningful_kernels_names; + params.meaningfulKernelsNames = false; params.allowStaticInputReordering = program.get_options().get()->enabled() || program.get_options().get()->enabled(); params.allowInputReordering = false; diff --git a/inference-engine/thirdparty/clDNN/src/layout_optimizer.cpp b/inference-engine/thirdparty/clDNN/src/layout_optimizer.cpp index 6540c4f79625ee..9c26b09cf27dc3 100644 --- a/inference-engine/thirdparty/clDNN/src/layout_optimizer.cpp +++ b/inference-engine/thirdparty/clDNN/src/layout_optimizer.cpp @@ -6,7 +6,7 @@ #include "topology_impl.h" #include "network_impl.h" #include "primitive_inst.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "data_inst.h" #include "reorder_inst.h" diff --git a/inference-engine/thirdparty/clDNN/src/loop.cpp b/inference-engine/thirdparty/clDNN/src/loop.cpp index da79292fdaaf58..9399dfdfa6a144 100644 --- a/inference-engine/thirdparty/clDNN/src/loop.cpp +++ b/inference-engine/thirdparty/clDNN/src/loop.cpp @@ -5,11 +5,10 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include "loop_inst.h" -#include "error_handler.h" #include "json_object.h" #include "primitive_type_base.h" -#include "api/data.hpp" -#include "api/mutable_data.hpp" +#include "cldnn/primitives/data.hpp" +#include "cldnn/primitives/mutable_data.hpp" #include #include #include @@ -199,18 +198,18 @@ void loop_inst::preprocess_output_memory() { const primitive_id& external_id = output_mapping.external_id; const primitive_id& internal_id = output_mapping.internal_id; if (output_mapping.axis < 0) { - memory_impl::ptr memory = get_external_memory(external_id); - body_network->get_primitive(internal_id)->set_output_memory(*memory); + memory::ptr memory = get_external_memory(external_id); + body_network->get_primitive(internal_id)->set_output_memory(memory); } else { - memory_impl::ptr to_mem = get_external_memory(external_id); + memory::ptr to_mem = get_external_memory(external_id); auto output_prim = body_network->get_primitive(internal_id); layout sliced_layout = output_prim->output_memory().get_layout(); const int64_t max_iteration = node.get_max_iteration(); - std::vector sliced_mems; + std::vector sliced_mems; sliced_mems.reserve(max_iteration); for (int j=0; j < max_iteration; ++j) { - memory_impl::ptr sliced_mem = engine.allocate_memory(sliced_layout, 0); + memory::ptr sliced_mem = engine.allocate_memory(sliced_layout, 0); sliced_mems.push_back(sliced_mem); } @@ -219,7 +218,7 @@ void loop_inst::preprocess_output_memory() { const int64_t num_elements_iteration = sliced_layout.count() / num_elements_batch; const int64_t start = output_mapping.start < 0? node.get_max_iteration() - 1: output_mapping.start; concatenated_memory_mapping memory_mapping_info( - output_mapping.axis, to_mem, sliced_mems, + output_mapping.axis, to_mem, sliced_mems, _network.get_stream(), num_elements_iteration, output_mapping.stride, start); memory_mapping_info.concat_data_prim = body_network->get_primitive(internal_id); concatenated_output_mem_mappings.push_back(memory_mapping_info); @@ -241,7 +240,7 @@ void loop_inst::preprocess_input_memory() { CLDNN_ERROR_MESSAGE(id(), "loop primitive_map is incomplete"); } - memory_impl& memory = input_memory(memory_num); + auto memory = input_memory_ptr(memory_num); for (size_t i = 0; i < input_map_ptrs.size(); ++i) { const auto input_map = input_map_ptrs.at(i); bool is_concatenated_input = (input_map->axis >= 0); @@ -249,10 +248,10 @@ void loop_inst::preprocess_input_memory() { layout sliced_layout = body_network->get_primitive(input_map->internal_id)->output_memory().get_layout(); const int64_t max_iteration = node.get_max_iteration(); - std::vector sliced_mems; + std::vector sliced_mems; sliced_mems.reserve(max_iteration); for (int j=0; j < max_iteration; ++j) { - memory_impl::ptr sliced_mem = engine.allocate_memory(sliced_layout, 0); + memory::ptr sliced_mem = engine.allocate_memory(sliced_layout, 0); sliced_mems.push_back(sliced_mem); } const int64_t num_elements_batch = concatenated_memory_mapping::get_batch_size( @@ -260,12 +259,12 @@ void loop_inst::preprocess_input_memory() { const int64_t num_elements_iteration = sliced_layout.count() / num_elements_batch; const int64_t start = input_map->start < 0? node.get_max_iteration() - 1: input_map->start; concatenated_memory_mapping concatenated_input_mem_mapping_info( - input_map->axis, (memory_impl::ptr)&memory, sliced_mems, + input_map->axis, memory, sliced_mems, _network.get_stream(), num_elements_iteration, input_map->stride, start); concatenated_input_mem_mapping_info.sliced_data_prim = body_network->get_primitive(input_map->internal_id); iteration_mem.push_back(concatenated_input_mem_mapping_info); } else { - if (memory.get_layout().data_type != body_network->get_primitive(input_map->internal_id)->output_memory().get_layout().data_type) { + if (memory->get_layout().data_type != body_network->get_primitive(input_map->internal_id)->output_memory().get_layout().data_type) { CLDNN_ERROR_MESSAGE(id(), "incompatible datatypes"); } body_network->set_input_data(input_map->internal_id, memory); @@ -285,17 +284,17 @@ void loop_inst::preprocess_backedge_memory() { auto backedged_sliced_output_mems = get_sliced_mem(back_edge.from); const auto backedge_to_prim = body_network->get_primitive(back_edge.to); const auto backedge_from_prim = body_network->get_primitive(back_edge.from); - memory_impl::ptr initial_mem = get_external_memory(input_map->external_id); + memory::ptr initial_mem = get_external_memory(input_map->external_id); if (backedged_sliced_output_mems.empty()) { // backedge output which does not need concatenation // input memory = output memory = loop output memory const auto output_mapping = node.find_io_primitive_maps(back_edge.from, false); - memory_impl::ptr backedge_mem; + memory::ptr backedge_mem; if (output_mapping.empty()) { // from and to primitives in backedge are connected directly if (backedge_to_prim == backedge_from_prim->dependencies().front()) { backedge_memory_mappings.emplace_back( - backedge_from_prim, backedge_to_prim, initial_mem); + backedge_from_prim, backedge_to_prim, initial_mem, body_network->get_stream()); continue; } else { auto output_prim = body_network->get_primitive(back_edge.from); @@ -305,19 +304,19 @@ void loop_inst::preprocess_backedge_memory() { } else { backedge_mem = get_external_memory(output_mapping.front()->external_id); } - body_network->set_input_data(back_edge.to, *backedge_mem); - body_network->set_output_memory(back_edge.from, *backedge_mem); + body_network->set_input_data(back_edge.to, backedge_mem); + body_network->set_output_memory(back_edge.from, backedge_mem); backedge_memory_mappings.emplace_back( - backedge_from_prim, backedge_to_prim, backedge_mem, initial_mem); + backedge_from_prim, backedge_to_prim, backedge_mem, initial_mem, body_network->get_stream()); } else { // backedge output which needs concatenation backedge_memory_mappings.emplace_back( - backedge_from_prim, backedge_to_prim, backedged_sliced_output_mems, initial_mem); + backedge_from_prim, backedge_to_prim, backedged_sliced_output_mems, initial_mem, body_network->get_stream()); } } } -std::vector loop_inst::get_sliced_mem(const primitive_id& internal_id) const { +std::vector loop_inst::get_sliced_mem(const primitive_id& internal_id) const { for (const auto& mem_mapping : concatenated_input_mem_mappings) { if (mem_mapping.sliced_data_prim->id() == internal_id) { return mem_mapping.sliced_mems; @@ -331,20 +330,18 @@ std::vector loop_inst::get_sliced_mem(const primitive_id& inte return {}; // not found } -memory_impl::ptr loop_inst::get_external_memory(const primitive_id& external_id) const { +memory::ptr loop_inst::get_external_memory(const primitive_id& external_id) const { const auto outputPrim = _network.get_primitive(external_id); - memory_impl& memory = outputPrim->output_memory(); - return (memory_impl::ptr) &memory; + return outputPrim->output_memory_ptr(); } loop_inst::typed_primitive_inst(network_impl & network, loop_node const & node) : parent(network, node), preproc_memories_done(false), - body_network(node.get_program() - .get_engine() - .allocate_network(*node.get_body_program(), - network.get_stream_id(), - false)) { + body_network(network_impl::allocate_network(network.get_stream_ptr(), + node.get_body_program(), + false, + network.is_primary_stream())) { if (!check_if_axis_is_set_properly(node)) CLDNN_ERROR_MESSAGE(node.id(), "axis is not set properly"); diff --git a/inference-engine/thirdparty/clDNN/src/lrn.cpp b/inference-engine/thirdparty/clDNN/src/lrn.cpp index c1f0c1b3e1b4e7..2f84b0fad131ee 100644 --- a/inference-engine/thirdparty/clDNN/src/lrn.cpp +++ b/inference-engine/thirdparty/clDNN/src/lrn.cpp @@ -4,7 +4,7 @@ #include "lrn_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/lstm.cpp b/inference-engine/thirdparty/clDNN/src/lstm.cpp index 5c0d4c25ee38fa..c04b686e297577 100644 --- a/inference-engine/thirdparty/clDNN/src/lstm.cpp +++ b/inference-engine/thirdparty/clDNN/src/lstm.cpp @@ -5,7 +5,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include "lstm_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/lstm_dynamic.cpp b/inference-engine/thirdparty/clDNN/src/lstm_dynamic.cpp index 2e60fff1285998..4d26546e99556f 100644 --- a/inference-engine/thirdparty/clDNN/src/lstm_dynamic.cpp +++ b/inference-engine/thirdparty/clDNN/src/lstm_dynamic.cpp @@ -5,7 +5,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include "lstm_dynamic_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/lstm_dynamic_input.cpp b/inference-engine/thirdparty/clDNN/src/lstm_dynamic_input.cpp index 72e0967007249e..36b346c2f19851 100644 --- a/inference-engine/thirdparty/clDNN/src/lstm_dynamic_input.cpp +++ b/inference-engine/thirdparty/clDNN/src/lstm_dynamic_input.cpp @@ -6,7 +6,7 @@ #include "lstm_dynamic_input_inst.h" #include "lstm_dynamic_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/lstm_dynamic_timeloop.cpp b/inference-engine/thirdparty/clDNN/src/lstm_dynamic_timeloop.cpp index 6db06934be112b..44db5f6ff28a5d 100644 --- a/inference-engine/thirdparty/clDNN/src/lstm_dynamic_timeloop.cpp +++ b/inference-engine/thirdparty/clDNN/src/lstm_dynamic_timeloop.cpp @@ -6,7 +6,7 @@ #include "lstm_dynamic_timeloop_inst.h" #include "lstm_dynamic_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/lstm_elt.cpp b/inference-engine/thirdparty/clDNN/src/lstm_elt.cpp index 2c8346accbc4f8..3e66d985f6dd65 100644 --- a/inference-engine/thirdparty/clDNN/src/lstm_elt.cpp +++ b/inference-engine/thirdparty/clDNN/src/lstm_elt.cpp @@ -5,7 +5,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include "lstm_elt_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/lstm_gemm.cpp b/inference-engine/thirdparty/clDNN/src/lstm_gemm.cpp index 4456e29675a042..77f2b62452905d 100644 --- a/inference-engine/thirdparty/clDNN/src/lstm_gemm.cpp +++ b/inference-engine/thirdparty/clDNN/src/lstm_gemm.cpp @@ -5,7 +5,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include "lstm_gemm_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/max_unpooling.cpp b/inference-engine/thirdparty/clDNN/src/max_unpooling.cpp index 3e95bd95eb4e3d..b43b72ca084b1b 100644 --- a/inference-engine/thirdparty/clDNN/src/max_unpooling.cpp +++ b/inference-engine/thirdparty/clDNN/src/max_unpooling.cpp @@ -5,7 +5,7 @@ #include "max_unpooling_inst.h" #include "primitive_type_base.h" #include "sliding_window_utils.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include #include diff --git a/inference-engine/thirdparty/clDNN/src/memory.cpp b/inference-engine/thirdparty/clDNN/src/memory.cpp deleted file mode 100644 index 9cf892500f0bc8..00000000000000 --- a/inference-engine/thirdparty/clDNN/src/memory.cpp +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include "api/memory.hpp" -#include "memory_impl.h" -#include "engine_impl.h" - -namespace cldnn { - -memory memory::allocate(const engine& engine, const layout& layout, uint32_t net_id, bool reset) { - size_t size = layout.bytes_count(); - if (size == 0) - throw std::invalid_argument("size should be more than 0"); - - allocation_type type = engine.get()->get_lockable_preffered_memory_allocation_type(layout.format.is_image_2d()); - return memory(engine.get()->allocate_memory(layout, type, net_id, reset).detach()); -} - -memory memory::share_buffer(const engine& engine, const layout& layout, shared_handle buf, uint32_t net_id) { - shared_mem_params params = { shared_mem_type::shared_mem_buffer, nullptr, nullptr, buf, -#ifdef _WIN32 - nullptr, -#else - 0, -#endif - 0 }; - return memory(engine.get()->reinterpret_handle(layout, ¶ms, net_id).detach()); -} - -memory memory::share_image(const engine& engine, const layout& layout, shared_handle img, uint32_t net_id) { - shared_mem_params params = { shared_mem_type::shared_mem_image, nullptr, nullptr, img, -#ifdef _WIN32 - nullptr, -#else - 0, -#endif - 0 }; - return memory(engine.get()->reinterpret_handle(layout, ¶ms, net_id).detach()); -} - -#ifdef _WIN32 -memory memory::share_surface(const engine& engine, const layout& layout, shared_handle surf, uint32_t plane, - uint32_t net_id) { - shared_mem_params params = { shared_mem_type::shared_mem_vasurface, nullptr, nullptr, nullptr, surf, plane }; - return memory(engine.get()->reinterpret_handle(layout, ¶ms, net_id).detach()); -} - -memory memory::share_dx_buffer(const engine& engine, const layout& layout, shared_handle res, uint32_t net_id) { - shared_mem_params params = { shared_mem_type::shared_mem_dxbuffer, nullptr, nullptr, res, nullptr, 0 }; - return memory(engine.get()->reinterpret_handle(layout, ¶ms, net_id).detach()); -} -#else -memory memory::share_surface(const engine& engine, const layout& layout, shared_surface surf, uint32_t plane, - uint32_t net_id) { - shared_mem_params params = { shared_mem_type::shared_mem_vasurface, nullptr, nullptr, nullptr, surf, plane }; - return memory(engine.get()->reinterpret_handle(layout, ¶ms, net_id).detach()); -} -#endif - -size_t memory::count() const { - if (_impl) - return get_layout().count(); - else - return 0; -} - -size_t memory::size() const { - if (_impl) - return _impl->size(); - else - return 0; -} - -const layout& memory::get_layout() const { - if (_impl) - return _impl->get_layout(); - else - throw std::runtime_error("empty memory object"); -} - -int memory::get_net_id() const { - if (_impl) - return _impl->get_net_id(); - else - throw std::runtime_error("empty memory object"); -} - -bool memory::is_allocated_by(const engine& engine) const { - if (_impl) - return _impl->is_allocated_by(*engine.get()); - else - return false; -} - -bool memory::is_the_same_buffer(const memory& other) const { - if (_impl == nullptr) - return false; - - if (_impl == other.get()) - return true; - - if (_impl->get_engine() != other.get()->get_engine()) - return false; - - // User memory, check te pointers - if (!_impl->get_engine()) - return lock_impl() == other.lock_impl(); - - // Engine memory, let it decide - return _impl->get_engine()->is_the_same_buffer(*_impl, *other.get()); -} - -shared_mem_params memory::get_internal_params() const { - if (_impl) - return _impl->get_internal_params(); - else - throw std::runtime_error("empty memory object"); -} - -memory memory::attach_impl(const cldnn::layout& layout, void* ptr, uint32_t net_id) { - return memory(new simple_attached_memory(layout, ptr, net_id)); -} - -void* memory::lock_impl() const { - if (_impl) - return _impl->lock(); - else - return nullptr; -} - -void memory::unlock() const { - if (_impl) _impl->unlock(); -} - -void memory::retain() { - if (_impl) _impl->add_ref(); -} -void memory::release() { - if (_impl) _impl->release(); -} - -void memory::reset() { - release(); - _impl = nullptr; -} - -} // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/mutable_data.cpp b/inference-engine/thirdparty/clDNN/src/mutable_data.cpp index 85f73d89c8ade1..7ba0640d9c192c 100644 --- a/inference-engine/thirdparty/clDNN/src/mutable_data.cpp +++ b/inference-engine/thirdparty/clDNN/src/mutable_data.cpp @@ -5,9 +5,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include "mutable_data_inst.h" #include "primitive_type_base.h" -#include "memory_impl.h" +#include "cldnn/runtime/memory.hpp" #include -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include #include @@ -20,19 +20,17 @@ primitive_type_id mutable_data::type_id() { } namespace { -memory_impl::ptr attach_or_copy_data(network_impl& network, memory_impl& mem) { +memory::ptr attach_or_copy_data(network_impl& network, memory::ptr mem, bool reuse) { auto& engine = network.get_engine(); - auto own_id = network.get_id(); + auto& stream = network.get_stream(); - if (mem.is_allocated_by(engine) && - (own_id == mem.get_net_id() || network.is_primary_stream())) { - mem.set_net(own_id); - return (memory_impl::ptr) & mem; + if (mem->is_allocated_by(engine) && reuse) { + return mem; } - memory_impl::ptr result = engine.allocate_memory(mem.get_layout(), network.get_id(), false); - mem_lock src(mem); - mem_lock dst(result); + memory::ptr result = engine.allocate_memory(mem->get_layout(), false); + mem_lock src(mem, stream); + mem_lock dst(result, stream); std::copy(src.begin(), src.end(), dst.begin()); return result; @@ -40,65 +38,16 @@ memory_impl::ptr attach_or_copy_data(network_impl& network, memory_impl& mem) { } // namespace mutable_data_node::typed_program_node(const std::shared_ptr dprim, program_impl& prog) - : parent(dprim, prog), mem(dprim->mem.get()) { + : parent(dprim, prog), mem(dprim->mem) { recalc_output_layout(false); can_share_buffer(false); - fill_memory(); } -void mutable_data_node::attach_memory(memory_impl& new_mem, bool invalidate_users_if_changed) { - mem = (memory_impl::ptr) &new_mem; +void mutable_data_node::attach_memory(memory::ptr new_mem, bool invalidate_users_if_changed) { + mem = new_mem; recalc_output_layout(invalidate_users_if_changed); } -void mutable_data_node::fill_memory() { - auto prim = get_primitive(); - - if (prim->fill_type == mutable_data::filler_type::no_fill) - return; - - auto memory = mem.get(); - auto layout = memory->get_layout(); - if (layout.data_type != data_types::f32) - CLDNN_ERROR_MESSAGE(id(), "only f32 data types can be filled"); - - switch (prim->fill_type) { - case mutable_data::filler_type::zero: - fill_memory_constant(0.f); - break; - case mutable_data::filler_type::one: - fill_memory_constant(1.f); - break; - case mutable_data::filler_type::xavier: - fill_memory_xavier(); - break; - default: - break; - } -} - -void mutable_data_node::fill_memory_xavier() { - auto memory = mem.get(); - auto layout = memory->get_layout(); - auto n = layout.count() / layout.size.batch[0]; - float scale = static_cast(sqrt(3.0f / static_cast(n))); - std::default_random_engine generator(0); - - mem_lock lock(mem); - auto out_ptr = lock.begin(); - std::uniform_real_distribution distribution(-scale, scale); - for (uint32_t i = 0; i < (uint32_t)layout.count(); i++) out_ptr[i] = distribution(generator); -} - -void mutable_data_node::fill_memory_constant(float value) { - auto memory = mem.get(); - auto layout = memory->get_layout(); - mem_lock lock(mem); - auto out_ptr = lock.begin(); - - for (uint32_t i = 0; i < (uint32_t)layout.count(); i++) out_ptr[i] = value; -} - std::string mutable_data_inst::to_string(mutable_data_node const& node) { auto node_info = node.desc_to_json(); @@ -109,6 +58,6 @@ std::string mutable_data_inst::to_string(mutable_data_node const& node) { } mutable_data_inst::typed_primitive_inst(network_impl& network, mutable_data_node const& node) - : parent(network, node, *attach_or_copy_data(network, node.get_attached_memory())) {} + : parent(network, node, attach_or_copy_data(network, node.get_attached_memory_ptr(), network.is_primary_stream())) {} } // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/network.cpp b/inference-engine/thirdparty/clDNN/src/network.cpp index 2ce1c58a1ffcce..14cfd2791a50de 100644 --- a/inference-engine/thirdparty/clDNN/src/network.cpp +++ b/inference-engine/thirdparty/clDNN/src/network.cpp @@ -3,26 +3,28 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "cldnn/primitives/data.hpp" +#include "cldnn/primitives/mutable_data.hpp" +#include "cldnn/primitives/input_layout.hpp" + +#include "cldnn/runtime/error_handler.hpp" +#include "cldnn/runtime/memory.hpp" +#include "cldnn/runtime/engine.hpp" +#include "cldnn/runtime/event.hpp" +#include "cldnn/runtime/stream.hpp" + #include "network_impl.h" -#include "engine_impl.h" -#include "event_impl.h" #include "program_impl.h" -#include "api/data.hpp" -#include "api/mutable_data.hpp" -#include "api/input_layout.hpp" -#include -#include "cldnn_itt.h" - -#include "error_handler.h" +#include "to_string_utils.h" #include "primitive_inst.h" #include "input_layout_inst.h" #include "mutable_data_inst.h" #include "condition_inst.h" #include "kernel_selector_helper.h" -#include "gpu/memory_gpu.h" -#include +#include "runtime/cldnn_itt.hpp" -#include "gpu/ocl_toolkit.h" +#include #include #include #include @@ -44,24 +46,27 @@ namespace cldnn { network::network(program const& program, uint16_t stream_id) - : _impl(program.get()->get_engine().allocate_network(*program.get(), stream_id).detach()) {} + : _impl(network_impl::allocate_network(program.get()->get_engine(), program.get(), false, stream_id == 0)) {} -engine network::get_engine() const { - auto impl = engine_impl::ptr(&_impl->get_engine()); - return engine(impl.detach()); +engine& network::get_engine() const { + return _impl->get_engine(); } program network::get_program() const { - auto impl = program_impl::cptr(&_impl->get_program()); - return program(const_cast(impl.detach())); + auto impl = std::const_pointer_cast(_impl->get_program()); + return program(impl); } -void network::set_input_data(const primitive_id& id, const memory& mem) const { - _impl->set_input_data(id, *mem.get()); +void network::set_input_data(const primitive_id& id, memory::ptr mem) const { + _impl->set_input_data(id, mem); } -void network::set_output_memory(const primitive_id& id, const memory& mem) const { - _impl->set_output_memory(id, *mem.get()); +void network::set_output_memory(const primitive_id& id, memory::ptr mem) const { + _impl->set_output_memory(id, mem); +} + +stream& network::get_stream() const { + return _impl->get_stream(); } uint32_t network::get_id() { @@ -100,28 +105,18 @@ std::vector network::get_output_ids() const { return _impl->get_output_ids(); } -memory network::get_output_memory(const primitive_id& output_id) const { - auto out_mem = memory_impl::ptr(&_impl->get_primitive(output_id)->output_memory()); - return memory(out_mem.detach()); +memory::ptr network::get_output_memory(const primitive_id& output_id) const { + return _impl->get_primitive(output_id)->output_memory_ptr(); } -event network::get_primitive_event(const primitive_id& output_id) const { - auto out_event = _impl->get_primitive_event(output_id); - return event(out_event.detach()); +event::ptr network::get_primitive_event(const primitive_id& output_id) const { + return _impl->get_primitive_event(output_id); } -std::map network::execute(const std::vector& dependencies) const { - std::vector> dep_impls(dependencies.size()); - - std::transform( - dependencies.begin(), - dependencies.end(), - dep_impls.begin(), - [](const event& ev) { - return event_impl::ptr(ev.get()); - }); +std::map network::execute(const std::vector& dependencies) const { + std::vector dep_impls(dependencies.size()); - _impl->execute(dep_impls); + _impl->execute(dependencies); auto output_ids = get_output_ids(); std::map result; @@ -131,14 +126,6 @@ std::map network::execute(const std::vector return result; } -void network::retain() { - _impl->add_ref(); -} - -void network::release() { - _impl->release(); -} - #ifdef DEBUG_DUMP_PATH static float convert_half_to_float(half_t val, bool flush_denorm_to_zero = false) { #if defined HALF_HALF_HPP @@ -189,13 +176,14 @@ float convert_element(float f) { return f; } float convert_element(half_t h) { return convert_half_to_float(h); } template -static void dump(memory_impl& mem, std::ofstream& file_stream) { - auto&& size = mem.get_layout().size; +static void dump(memory::ptr mem, stream& stream, std::ofstream& file_stream) { + auto&& size = mem->get_layout().size; file_stream << "shape: " << size.to_string() << " "; - file_stream << "(count: " << size.count() << ", original format: " << cldnn::fmt_to_str(mem.get_layout().format) << ")" << std::endl; + file_stream << "(count: " << size.count() << ", original format: " << cldnn::fmt_to_str(mem->get_layout().format) << ")" << std::endl; - auto mem_ptr = static_cast(mem.lock()); + mem_lock lock(mem, stream); + auto mem_ptr = lock.data(); for (cldnn::tensor::value_type g = 0; g < size.group[0]; ++g) { for (cldnn::tensor::value_type b = 0; b < size.batch[0]; ++b) { @@ -205,7 +193,7 @@ static void dump(memory_impl& mem, std::ofstream& file_stream) { for (cldnn::tensor::value_type y = 0; y < size.spatial[1]; ++y) { for (cldnn::tensor::value_type x = 0; x < size.spatial[0]; ++x) { cldnn::tensor t(cldnn::group(g), cldnn::batch(b), cldnn::feature(f), cldnn::spatial(x, y, z, w)); - size_t input_it = mem.get_layout().get_linear_offset(t); + size_t input_it = mem->get_layout().get_linear_offset(t); file_stream << std::fixed << std::setprecision(6) << convert_element(mem_ptr[input_it]) << std::endl; } } @@ -214,12 +202,10 @@ static void dump(memory_impl& mem, std::ofstream& file_stream) { } } } - - mem.unlock(); } template <> -void dump(memory_impl& mem, std::ofstream& file_stream) { - auto&& size = mem.get_layout().size; +void dump(memory::ptr mem, stream& stream, std::ofstream& file_stream) { + auto&& size = mem->get_layout().size; file_stream << "shape: "; file_stream << size.batch[0] << " "; @@ -228,7 +214,8 @@ void dump(memory_impl& mem, std::ofstream& file_stream) { file_stream << size.spatial[0] << " "; file_stream << "(" << size.batch[0] * size.feature[0] * size.spatial[1] * size.spatial[0] << ")" << std::endl; - auto mem_ptr = static_cast(mem.lock()); + mem_lock lock(mem, stream); + auto mem_ptr = lock.data(); for (cldnn::tensor::value_type b = 0; b < size.batch[0]; ++b) { for (cldnn::tensor::value_type f = 0; f < (cldnn::tensor::value_type)ceil_div(size.feature[0], 32); ++f) { @@ -236,87 +223,95 @@ void dump(memory_impl& mem, std::ofstream& file_stream) { for (cldnn::tensor::value_type y = 0; y < size.spatial[1]; ++y) { for (cldnn::tensor::value_type x = 0; x < size.spatial[0]; ++x) { cldnn::tensor t(cldnn::batch(b), cldnn::feature(f), cldnn::spatial(x, y, z, 0)); - size_t input_it = mem.get_layout().get_linear_offset(t); + size_t input_it = mem->get_layout().get_linear_offset(t); file_stream << mem_ptr[input_it] << std::endl; } } } } } - - mem.unlock(); } -static void log_memory_to_file(memory_impl& mem, std::string layerName) { +static void log_memory_to_file(memory::ptr mem, stream& stream, std::string layerName) { std::string filename = layerName; std::replace(filename.begin(), filename.end(), '\\', '_'); std::replace(filename.begin(), filename.end(), '/', '_'); std::replace(filename.begin(), filename.end(), ' ', '_'); std::replace(filename.begin(), filename.end(), ':', '_'); - filename = DEBUG_DUMP_PATH + filename + ".txt"; + filename = DEBUG_DUMP_PATH + filename + ".txt"; std::ofstream file_stream(filename); - if (mem.get_layout().data_type == cldnn::data_types::f32) - dump(mem, file_stream); - else if (mem.get_layout().data_type == cldnn::data_types::f16) - dump(mem, file_stream); - else if (mem.get_layout().data_type == cldnn::data_types::bin) - dump(mem, file_stream); - else if (mem.get_layout().data_type == cldnn::data_types::i32) - dump(mem, file_stream); - else if (mem.get_layout().data_type == cldnn::data_types::i8) - dump(mem, file_stream); - else if (mem.get_layout().data_type == cldnn::data_types::u8) - dump(mem, file_stream); + auto mem_dt = mem->get_layout().data_type; + if (mem_dt == cldnn::data_types::f32) + dump(mem, stream, file_stream); + else if (mem_dt == cldnn::data_types::f16) + dump(mem, stream, file_stream); + else if (mem_dt == cldnn::data_types::bin) + dump(mem, stream, file_stream); + else if (mem_dt == cldnn::data_types::i32) + dump(mem, stream, file_stream); + else if (mem_dt == cldnn::data_types::i8) + dump(mem, stream, file_stream); + else if (mem_dt == cldnn::data_types::u8) + dump(mem, stream, file_stream); } #endif /* Network_impl will always have net_id = 0 when it will be cldnn internal micronetwork (created i.e by propagate_constants opt pass). */ -network_impl::network_impl(const program_impl& program, uint16_t stream_id, bool is_internal) - : _program(&program), _stream_id(stream_id), _internal(is_internal), _reset_arguments(true) { +network_impl::network_impl(program_impl::ptr program, stream::ptr stream, bool is_internal, bool is_primary_stream) + : _program(program), _stream(stream), _internal(is_internal), _is_primary_stream(is_primary_stream), _reset_arguments(true) { static std::atomic id_gen{0}; if (!_internal) { net_id = ++id_gen; } - if (net_id) { - get_engine().get_context()->add_network(net_id); - } allocate_primitives(); check_names(); build_insts_deps(); build_exec_order(); validate_primitives(); - _program->dump_memory_pool(); } network_impl::~network_impl() { - for (auto const& prim : _exec_order) { - prim->cleanup(); - } - - auto toolkit = get_engine().get_context(); get_engine().get_memory_pool().clear_pool_for_network(net_id); - toolkit->release_pending_memory(net_id); - if (net_id) { - toolkit->remove_network(net_id); - } } -network_impl::network_impl(engine_impl& engine, +network_impl::ptr network_impl::allocate_network(stream::ptr stream, program_impl::ptr program, bool is_internal, bool is_primary_stream) { + return std::make_shared(program, stream, is_internal, is_primary_stream); +} + +network_impl::ptr network_impl::allocate_network(engine& engine, program_impl::ptr program, bool is_internal, bool is_primary_stream) { + auto stream = engine.create_stream(); + return std::make_shared(program, stream, is_internal, is_primary_stream); +} + +network_impl::ptr network_impl::build_network(engine& engine, + const topology_impl& topology, + const build_options& options, + bool is_internal) { + return std::make_shared(engine, topology, options, is_internal); +} + +network_impl::ptr network_impl::build_network(engine& engine, + const std::set>& nodes, + const build_options& options, + bool is_internal) { + return std::make_shared(engine, nodes, options, is_internal); +} + +network_impl::network_impl(engine& engine, const topology_impl& topo, const build_options& options, - uint16_t stream_id, bool is_internal) - : network_impl(*engine.build_program(topo, options, is_internal), stream_id, is_internal) {} + : network_impl(program_impl::build_program(engine, topo, options, is_internal), engine.create_stream(), is_internal) {} -network_impl::network_impl(engine_impl& engine, +network_impl::network_impl(engine& engine, const std::set>& nodes, const build_options& options, bool is_internal) - : network_impl(*engine.build_program(nodes, options, is_internal), 0, is_internal) {} + : network_impl(program_impl::build_program(engine, nodes, options, is_internal), engine.create_stream(), is_internal) {} void network_impl::validate_primitives() { for (auto const& prim : _exec_order) { @@ -337,7 +332,7 @@ void network_impl::set_arguments() { void network_impl::reset_execution(bool wait) { if (wait && _events.size() > 0) { - std::vector events; + std::vector events; for (auto& pair : _events) { auto& ev = pair.second; if (ev->is_set()) @@ -346,12 +341,12 @@ void network_impl::reset_execution(bool wait) { events.push_back(ev); } - get_engine().wait_for_events(events); + get_stream().wait_for_events(events); } _events.clear(); } -void network_impl::set_input_data(const primitive_id& id, memory_impl& data) { +void network_impl::set_input_data(const primitive_id& id, memory::ptr data) { std::shared_ptr primitive_inst; primitive_inst = find_primitive(id); @@ -370,7 +365,7 @@ void network_impl::set_input_data(const primitive_id& id, memory_impl& data) { input->set_data(data); } -void network_impl::set_output_memory(const primitive_id& id, memory_impl& mem) { +void network_impl::set_output_memory(const primitive_id& id, memory::ptr mem) { std::shared_ptr primitive_inst; primitive_inst = find_primitive(id); @@ -426,16 +421,6 @@ void network_impl::set_learning_rate(const float lr) { _learning_rate = lr; } float network_impl::get_learning_rate() { return _learning_rate; } -bool network_impl::is_primary_stream() { - auto _nstreams = get_engine().configuration().n_streams; - return _nstreams == 1 || (_nstreams > 1 && _stream_id > 0); -} - -bool network_impl::is_secondary_stream() { - auto _nstreams = get_engine().configuration().n_streams; - return _nstreams > 1 && _stream_id > 0; -} - std::string network_impl::get_primitive_info(const primitive_id& id) const { const auto& node = _program->get_node(id); return node.type()->to_string(node); @@ -452,14 +437,6 @@ void network_impl::allocate_primitives() { return (lhs->get_output_layout().bytes_count() > rhs->get_output_layout().bytes_count()); }); - std::vector> mutable_data_nodes; - for (auto const& node : nodes_to_allocate) { - if (node->is_type()) - mutable_data_nodes.push_back(node); - } - - allocate_mutable_data_for_streams(mutable_data_nodes); - for (auto const& node : nodes_to_allocate) { allocate_primitive_instance(*node); } @@ -483,30 +460,21 @@ void network_impl::add_to_exec_order(const primitive_id& id) { _exec_order.push_back(inst); } -void network_impl::execute(const std::vector>& events) { +void network_impl::execute(const std::vector& events) { OV_ITT_SCOPED_TASK(itt::domains::CLDNN, "NetworkImpl::Execute"); // Wait for previous execution completion reset_execution(false); - // collect all shared media surfaces and enqueue acquire/relese - auto check_and_add_to_return_vec = [](std::shared_ptr prim, std::vector& return_vec) { - const auto& mem = prim->output_memory().get_internal_params(); - if (mem.mem_type == shared_mem_type::shared_mem_vasurface || - mem.mem_type == shared_mem_type::shared_mem_dxbuffer) { - return_vec.push_back(static_cast(mem.mem)); - } - }; - std::vector surfaces; - + std::vector in_out_mem; for (auto& inst : _inputs) { - check_and_add_to_return_vec(inst, surfaces); + in_out_mem.push_back(inst->output_memory_ptr()); } for (auto& inst : _outputs) { - check_and_add_to_return_vec(inst, surfaces); + in_out_mem.push_back(inst->output_memory_ptr()); } - cl_int err; - cl::SharedSurfLock lock(get_engine().get_context()->queue(get_id()).get(), surfaces, &err); + + auto surf_lock = surfaces_lock::create(get_engine().type(), in_out_mem, get_stream()); set_arguments(); @@ -523,7 +491,7 @@ void network_impl::execute(const std::vector>& ev #endif std::cerr << "Dump " << layer_name << " layer" << std::endl; for (size_t i = 0; i < get_primitive(inst->id())->dependencies().size(); i++) { - log_memory_to_file(get_primitive(inst->id())->dep_memory(i), + log_memory_to_file(get_primitive(inst->id())->dep_memory_ptr(i), get_stream(), layer_name + "_src_" + std::to_string(i)); } #if DUMP_SINGLE_LAYER @@ -537,15 +505,16 @@ void network_impl::execute(const std::vector>& ev inst->set_arguments(); } execute_primitive(inst, events); + #ifdef DEBUG_DUMP_PATH + get_stream().finish(); #if DUMP_SINGLE_LAYER if (layer_name == DUMP_LAYER_NAME) #endif { - log_memory_to_file(get_primitive(inst->id())->output_memory(), layer_name + "_dst_0"); + log_memory_to_file(get_primitive(inst->id())->output_memory_ptr(), get_stream(), layer_name + "_dst_0"); } - get_engine().flush_network(get_id()); #endif } @@ -576,19 +545,19 @@ void network_impl::execute(const std::vector>& ev for (auto& dout : _data_outputs) { // data primitives are not executed so if they are marked as output we need to add // them valid events manually - _events[dout->id()] = get_engine().create_user_event(get_id(), true); + _events[dout->id()] = get_stream().create_user_event(true); } for (auto& prim : _primitives) { prim.second->reset_output_change(); } - get_engine().get_context()->reset_events(get_id()); + get_stream().reset_events(); - // Using output of previouse network as input to another one may cause hazard (in OOOQ mode) if user would not + // Using output of previous network as input to another one may cause hazard (in OOOQ mode) if user would not // provide proper event to execution. Flushing pipeline should prevent this kind of issues. // In scenarios with a big number of very small networks it can provide performance drop. - get_engine().flush_network(get_id()); + get_stream().flush(); } std::vector network_impl::get_input_ids() const { @@ -664,7 +633,7 @@ std::vector> network_impl::get_primitives(const } void network_impl::execute_primitive(const std::shared_ptr& primitive, - const std::vector>& events) { + const std::vector& events) { auto id = primitive->id(); auto it = _events.find(id); bool found = (it != _events.end()); @@ -673,45 +642,10 @@ void network_impl::execute_primitive(const std::shared_ptr& prim found, "Primitive " + id + " is tried to be executed for the second time"); - event_impl::ptr ev; - if (!get_engine().get_context()->enabled_single_kernel() || get_engine().get_context()->single_kernel_name() == id) - ev = primitive->execute(events); - else - ev = get_engine().create_user_event(get_id(), true); + event::ptr ev = primitive->execute(events); _events.insert({id, ev}); } -void network_impl::allocate_mutable_data_for_streams(std::vector>& mutable_data_nodes) { - // When multiple streams are used, mutable_data should be duplicated for each stream. - while (!mutable_data_nodes.empty()) { - auto it = mutable_data_nodes.begin(); - mutable_data_node& node = (*it)->as(); - auto mem = node.get_attached_memory_ptr(); - - if (is_secondary_stream()) { - // Alloc new buffer for this stream and copy data to have valid initial state - memory_impl::ptr result = get_engine().allocate_memory(mem->get_layout(), get_id(), false); - { - mem_lock src(mem); - mem_lock dst(result); - std::copy(src.begin(), src.end(), dst.begin()); - } - - // It's possible that several mutable_data nodes use the same memory buffer, so replace all usages - for (auto it1 = it; it1 != mutable_data_nodes.end();) { - if (get_engine().is_the_same_buffer((*it1)->as().get_attached_memory(), *mem)) { - (*it1)->as().attach_memory(*result, false); - it1 = mutable_data_nodes.erase(it1); - } else { - ++it1; - } - } - } else { - mutable_data_nodes.erase(it); - } - } -} - void network_impl::allocate_primitive_instance(program_node const& node) { if (_primitives.count(node.id())) return; @@ -746,16 +680,16 @@ void network_impl::transfer_memory_to_device(std::shared_ptr ins if (node.need_lockable_memory()) return; + if (!get_engine().supports_allocation(allocation_type::usm_device)) + return; + if (alloc_type == allocation_type::usm_host || alloc_type == allocation_type::usm_shared) { // Allocate and transfer memory auto& mem_pool = inst_mem.get_engine()->get_memory_pool(); - auto device_mem = inst_mem.get_engine()->allocate_memory( - inst_mem.get_layout(), - allocation_type::usm_device, - inst_mem.get_net_id()); - dynamic_cast(*device_mem).copy_from_other(dynamic_cast(inst_mem)); - mem_pool.release_memory(&inst_mem, node.id()); - instance->set_output_memory(*device_mem); + auto device_mem = inst_mem.get_engine()->allocate_memory(inst_mem.get_layout(), allocation_type::usm_device, false); + device_mem->copy_from(get_stream(), inst_mem); + mem_pool.release_memory(&inst_mem, node.id(), get_id()); + instance->set_output_memory(device_mem); } } } // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/src/nodes_ordering.cpp b/inference-engine/thirdparty/clDNN/src/nodes_ordering.cpp index a776234eae66cc..54fb3046ddbe4e 100644 --- a/inference-engine/thirdparty/clDNN/src/nodes_ordering.cpp +++ b/inference-engine/thirdparty/clDNN/src/nodes_ordering.cpp @@ -6,7 +6,7 @@ #include "program_impl.h" #include "program_node.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include #include #include diff --git a/inference-engine/thirdparty/clDNN/src/normalize.cpp b/inference-engine/thirdparty/clDNN/src/normalize.cpp index 4bafd2263eed20..d342e958b1eea1 100644 --- a/inference-engine/thirdparty/clDNN/src/normalize.cpp +++ b/inference-engine/thirdparty/clDNN/src/normalize.cpp @@ -4,7 +4,7 @@ #include "normalize_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/one_hot.cpp b/inference-engine/thirdparty/clDNN/src/one_hot.cpp index 3b985254018826..d3a02ec58c4f17 100644 --- a/inference-engine/thirdparty/clDNN/src/one_hot.cpp +++ b/inference-engine/thirdparty/clDNN/src/one_hot.cpp @@ -4,7 +4,7 @@ #include "one_hot_inst.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include "primitive_type_base.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/permute.cpp b/inference-engine/thirdparty/clDNN/src/permute.cpp index c820de4e4255b5..3d6671f923ab93 100644 --- a/inference-engine/thirdparty/clDNN/src/permute.cpp +++ b/inference-engine/thirdparty/clDNN/src/permute.cpp @@ -5,7 +5,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include "permute_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/pooling.cpp b/inference-engine/thirdparty/clDNN/src/pooling.cpp index 8376b7404f1a61..73801ffa2b91d1 100644 --- a/inference-engine/thirdparty/clDNN/src/pooling.cpp +++ b/inference-engine/thirdparty/clDNN/src/pooling.cpp @@ -5,7 +5,7 @@ #include "pooling_inst.h" #include "primitive_type_base.h" #include "sliding_window_utils.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/primitive_inst.cpp b/inference-engine/thirdparty/clDNN/src/primitive_inst.cpp index 43ec27e3e1e200..9e1ad0902ce7f8 100644 --- a/inference-engine/thirdparty/clDNN/src/primitive_inst.cpp +++ b/inference-engine/thirdparty/clDNN/src/primitive_inst.cpp @@ -2,21 +2,19 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// #include "primitive_inst.h" #include "data_inst.h" #include "mutable_data_inst.h" #include "generic_layer_inst.h" #include "input_layout_inst.h" -#include "max_unpooling_inst.h" #include "arg_max_min_inst.h" #include "fused_conv_eltwise_inst.h" #include "network_impl.h" -#include "engine_impl.h" -#include "memory_impl.h" +#include "cldnn/runtime/engine.hpp" +#include "cldnn/runtime/memory.hpp" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include #include @@ -27,7 +25,7 @@ namespace cldnn { uint32_t primitive_inst::get_network_id() const { return _network.get_id(); } -void primitive_inst::check_memory_to_set(const memory_impl& mem, const layout& layout) const { +void primitive_inst::check_memory_to_set(const memory& mem, const layout& layout) const { CLDNN_ERROR_LAYOUT_MISMATCH("network layout", "set memory layout", mem.get_layout(), @@ -60,15 +58,15 @@ void primitive_inst::check_memory_to_set(const memory_impl& mem, const layout& l } } -void primitive_inst::set_output_memory(memory_impl& mem) { +void primitive_inst::set_output_memory(memory::ptr mem) { auto ol = _node.get_output_layout(); - check_memory_to_set(mem, ol); + check_memory_to_set(*mem, ol); - _output = (memory_impl::ptr) &mem; + _output = mem; } -event_impl::ptr primitive_inst::execute(const std::vector& events) { +event::ptr primitive_inst::execute(const std::vector& events) { const auto primitive_id = id(); CLDNN_ERROR_BOOL(primitive_id, "Invalid/unset input", @@ -79,12 +77,12 @@ event_impl::ptr primitive_inst::execute(const std::vector& even if (_exec_deps.empty()) return _impl->execute(events, *this); - std::vector dependencies; + std::vector dependencies; dependencies.reserve(_exec_deps.size()); for (auto& input : _exec_deps) { auto id = input->id(); try { - // if the requested event deos not exits it means that it has not been executed, so the processing_order is + // if the requested event does not exits it means that it has not been executed, so the processing_order is // wrong or synchronization failed. auto ev = get_network().get_primitive_event(id); dependencies.emplace_back(ev); @@ -107,10 +105,6 @@ void primitive_inst::set_arguments() { _impl->set_arguments(*this); } -void primitive_inst::cleanup() { - _impl->cleanup(*this); -} - void primitive_inst::build_deps() { if (_deps.empty() && !_node.get_dependencies().empty()) { _deps = _network.get_primitives(_node.get_dependencies()); @@ -119,7 +113,7 @@ void primitive_inst::build_deps() { } primitive_inst::primitive_inst(network_impl& network, program_node const& node, bool allocate_memory) - : _network(network), _node(node), _impl(node.get_selected_impl()), _output(), _output_changed(false) { + : _network(network), _node(node), _impl(node.get_selected_impl() ? node.get_selected_impl()->clone() : nullptr), _output(), _output_changed(false) { if (allocate_memory) { // In case when output is mutable_data primitive, and other users dependencies are only used for // suychronization, The output memory of such primitive will be fused with mutable_data @@ -153,7 +147,7 @@ primitive_inst::primitive_inst(network_impl& network, program_node const& node, } } -memory_impl::ptr primitive_inst::allocate_output() { +memory::ptr primitive_inst::allocate_output() { auto layout = _node.get_output_layout(); auto net_id = get_network_id(); auto& engine = get_network().get_engine(); @@ -163,33 +157,35 @@ memory_impl::ptr primitive_inst::allocate_output() { auto use_lockable_memory = _node.is_output() || _node.get_selected_impl()->is_cpu() || std::any_of(_node.get_users().begin(), _node.get_users().end(), [](const program_node* n) {return n->get_selected_impl()->is_cpu() || n->can_be_optimized(); }) - || engine.supports_allocation(allocation_type::usm_device) == false; + || !engine.supports_allocation(allocation_type::usm_device); allocation_type alloc_type = use_lockable_memory ? engine.get_lockable_preffered_memory_allocation_type(layout.format.is_image_2d()) : allocation_type::usm_device; + if (!_network.is_internal() && (_node.can_be_optimized() || _node.is_type())) { - return engine.allocate_memory(layout, - _node.id(), - net_id, - _node.get_memory_dependencies(), - alloc_type, - false); + return engine.get_memory_from_pool(layout, + _node.id(), + net_id, + _node.get_memory_dependencies(), + alloc_type, + false); } else if (_network.is_internal() && _node.is_output() && _node.is_type() && engine.supports_allocation(allocation_type::usm_device)) { - return engine.allocate_memory(layout, allocation_type::usm_device, net_id, false); + return engine.allocate_memory(layout, allocation_type::usm_device, false); } else if (_network.is_internal() && !_node.is_output() && _node.is_type()) { // Skip memory reset for input_layout primitives, since data will be copied from cldnn::data primitive // or just reuse primitive's memory - return engine.allocate_memory(layout, alloc_type, net_id, false); + return engine.allocate_memory(layout, alloc_type, false); } else if (_network.is_internal() || (!_node.can_share_buffer()) || _node.can_be_optimized() || _node.is_output()) { - return engine.allocate_memory(layout, alloc_type, net_id); + return engine.allocate_memory(layout, alloc_type); + } else { + return engine.get_memory_from_pool(layout, + _node.id(), + net_id, + _node.get_memory_dependencies(), + alloc_type, + true); } - return engine.allocate_memory(layout, - _node.id(), - net_id, - _node.get_memory_dependencies(), - alloc_type, - true); } std::vector> primitive_inst::build_exec_deps( diff --git a/inference-engine/thirdparty/clDNN/src/prior_box.cpp b/inference-engine/thirdparty/clDNN/src/prior_box.cpp index a85691bb9c6fc1..8d536ac6561d18 100644 --- a/inference-engine/thirdparty/clDNN/src/prior_box.cpp +++ b/inference-engine/thirdparty/clDNN/src/prior_box.cpp @@ -4,7 +4,7 @@ #include "prior_box_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include @@ -21,7 +21,7 @@ primitive_type_id prior_box::type_id() { namespace { template -void calculate_prior_box_output(memory_impl& output_mem, layout const& input_layout, prior_box& argument) { +void calculate_prior_box_output(memory::ptr output_mem, stream& stream, layout const& input_layout, prior_box& argument) { // Calculate output. // All the inputs for this layer are known at this point, // so the output buffer is written here and not in execute(). @@ -39,10 +39,10 @@ void calculate_prior_box_output(memory_impl& output_mem, layout const& input_lay const float offset = argument.offset; int num_priors = argument.is_clustered() ? static_cast(argument.widths.size()) : - output_mem.get_layout().size.spatial[1] / 4 / layer_width / layer_height; + output_mem->get_layout().size.spatial[1] / 4 / layer_width / layer_height; int var_size = static_cast(argument.variance.size()); - mem_lock lock{output_mem}; + mem_lock lock{output_mem, stream}; auto out_ptr = lock.begin(); int dim = layer_height * layer_width * num_priors * 4; @@ -204,7 +204,7 @@ void calculate_prior_box_output(memory_impl& output_mem, layout const& input_lay } // set the variance. - int count = output_mem.get_layout().size.spatial[0] * output_mem.get_layout().size.spatial[1]; + int count = output_mem->get_layout().size.spatial[0] * output_mem->get_layout().size.spatial[1]; int var_loop_count = argument.is_clustered() ? var_size : 4; for (int h = 0; h < layer_height; ++h) { for (int w = 0; w < layer_width; ++w) { @@ -224,7 +224,7 @@ prior_box_node::typed_program_node(std::shared_ptr prim, program_impl } void prior_box_node::calc_result() { - if (result != (memory_impl::ptr) nullptr) + if (result != nullptr) return; auto& argument = *typed_desc(); @@ -340,15 +340,17 @@ void prior_box_node::calc_result() { CLDNN_ERROR_BOOL(id(), "Prior box padding", is_padded(), "Prior-box layer doesn't support output padding."); // allocate storage - result = get_program().get_engine().allocate_memory(get_output_layout(), 0, false); + result = get_program().get_engine().allocate_memory(get_output_layout()); // perform calculations if (get_output_layout().data_type == data_types::f16) - calculate_prior_box_output::type>(*result, + calculate_prior_box_output::type>(result, + get_program().get_stream(), input().get_output_layout(), *typed_desc()); else - calculate_prior_box_output::type>(*result, + calculate_prior_box_output::type>(result, + get_program().get_stream(), input().get_output_layout(), *typed_desc()); } diff --git a/inference-engine/thirdparty/clDNN/src/program.cpp b/inference-engine/thirdparty/clDNN/src/program.cpp index 97eacdf9ae1122..ec59a526be0ac8 100644 --- a/inference-engine/thirdparty/clDNN/src/program.cpp +++ b/inference-engine/thirdparty/clDNN/src/program.cpp @@ -4,10 +4,10 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "kernel_selector_helper.h" -#include "internal_primitive.h" -#include "internal_primitive_type_base.h" +#include "device_cache_reader.h" +#include "auto_tuner.h" #include "layout_optimizer.h" #include "pass_manager.h" #include "primitive_type.h" @@ -53,12 +53,13 @@ #include "reduce_inst.h" #include "region_yolo_inst.h" #include "strided_slice_inst.h" -#include "to_string_utils.h" -#include "gpu/memory_gpu.h" -#include "cldnn_itt.h" #include "loop_inst.h" +#include "to_string_utils.h" +#include "gpu/register_gpu.hpp" +#include "runtime/cldnn_itt.hpp" -#include "gpu/ocl_toolkit.h" +#include "cldnn/runtime/memory.hpp" +#include "cldnn/runtime/engine.hpp" #include "kernel_base.h" @@ -76,25 +77,21 @@ #include #include -program::program(engine const& engine, topology const& topology, build_options const& options) - : _impl(engine.get()->build_program(*topology.get(), options).detach()) {} - -void program::retain() { - _impl->add_ref(); -} - -void program::release() { - _impl->release(); -} +program::program(engine& engine, const topology& topology, const build_options& options) + : _impl(program_impl::build_program(engine, *topology.get(), options)) {} -program_impl::program_impl(engine_impl& engine_ref, +program_impl::program_impl(engine& engine_ref, topology_impl const& topology, build_options const& options, bool is_internal, bool no_optimizations) - : engine(&engine_ref), + : _engine(engine_ref), + _stream(_engine.create_stream()), + program_state(_engine), options(options), - processing_order() { + processing_order(), + tuning_cache(nullptr) { + init_primitives(); kernel_selector::KernelBase::ResetCounter(); set_options(); pm = std::unique_ptr(new pass_manager(*this)); @@ -106,13 +103,16 @@ program_impl::program_impl(engine_impl& engine_ref, } } -program_impl::program_impl(engine_impl& engine_ref, +program_impl::program_impl(engine& engine_ref, std::set> const& nodes, build_options const& options, bool is_internal) - : engine(&engine_ref), + : _engine(engine_ref), + program_state(_engine), options(options), - processing_order() { + processing_order(), + tuning_cache(nullptr) { + init_primitives(); set_options(); pm = std::unique_ptr(new pass_manager(*this)); prepare_nodes(nodes); @@ -120,7 +120,58 @@ program_impl::program_impl(engine_impl& engine_ref, } program_impl::~program_impl() { - engine->get_context()->remove_program(prog_id); +} + +void program_impl::init_primitives() { + static bool is_initialized = false; + if (!is_initialized) { + gpu::register_implementations_gpu(); + is_initialized = true; + } +} + +void program_impl::compile() { + auto& cache = program_state._kernels_cache; + cache.build_all(); +} + +void program_impl::init_kernels() { + for (auto& n : get_processing_order()) { + if (n->get_selected_impl()) + n->get_selected_impl()->init_kernels(); + } +} + +void program_impl::load_tuning_cache() { + OV_ITT_SCOPED_TASK(itt::domains::CLDNN, "ProgramImpl::LoadTuningCache"); + try { + tuning_cache = kernel_selector::CreateTuningCacheFromFile(get_engine().configuration().tuning_cache_path); + } catch (...) { + tuning_cache = std::make_shared(); + } +} + +kernel_id program_impl::add_kernel(const std::shared_ptr kernelSring) { + return program_state._kernels_cache.set_kernel_source(kernelSring, false); +} + +kernel::ptr program_impl::get_kernel(kernel_id id) { + return program_state._kernels_cache.get_kernel(id); +} + +program_impl::ptr program_impl::build_program(engine& engine, + const topology_impl& topology, + const build_options& options, + bool is_internal, + bool no_optimizations) { + return std::make_shared(engine, topology, options, is_internal, no_optimizations); +} + +program_impl::ptr program_impl::build_program(engine& engine, + const std::set>& nodes, + const build_options& options, + bool is_internal) { + return std::make_shared(engine, nodes, options, is_internal); } program_node& program_impl::get_node(primitive_id const& id) { @@ -248,7 +299,7 @@ void program_impl::prepare_nodes(std::set> const& for (const auto& itr : nodes) { if (itr.get()->is_type()) { get_or_create(std::make_shared(itr.get()->id(), - itr.get()->as().get_primitive()->mem.get_layout())); + itr.get()->as().get_primitive()->mem->get_layout())); } else { get_or_create(itr->desc); } @@ -341,11 +392,9 @@ void program_impl::set_options() { prog_id = ++id_gen; assert(prog_id != 0); - get_engine().get_context()->add_program(prog_id); - if ((options.get()->config.mode == tuning_mode::tuning_tune_and_cache || options.get()->config.mode == tuning_mode::tuning_retune_and_cache) && - !engine->configuration().enable_profiling) { + !_engine.configuration().enable_profiling) { throw std::invalid_argument("Engine must be created with profiling enabled in tune_and_cache mode!"); } @@ -360,13 +409,13 @@ void program_impl::build_program(bool is_internal) { run_graph_compilation(); { post_optimize_graph(is_internal); } prepare_memory_dependencies(); - engine->compile_program(*this); + compile(); + init_kernels(); - if (!is_internal) + if (!is_internal) { prim_info = get_current_stage_info(); - - if (!is_internal) transfer_memory_to_device(); + } cleanup(); } @@ -376,7 +425,7 @@ void program_impl::init_graph() { apply_opt_pass(); for (auto& node : processing_order) { - if (!node->is_type() && !node->is_type()) + if (!node->is_type()) node->get_output_layout(); } @@ -389,6 +438,10 @@ void program_impl::run_graph_compilation() { apply_opt_pass(); } void program_impl::pre_optimize_graph(bool is_internal) { OV_ITT_SCOPED_TASK(itt::domains::CLDNN, "ProgramImpl::PreOptimizeGraph"); + + if (!is_internal) + load_tuning_cache(); + // trim to outputs apply_opt_pass(); // ToDo remove hidden dependencies from trimm pass @@ -401,7 +454,7 @@ void program_impl::pre_optimize_graph(bool is_internal) { bool output_size_handling_enabled = analyze_output_size_handling_need(); for (auto& node : processing_order) { - if (!node->is_type() && !node->is_type()) + if (!node->is_type()) node->get_output_layout(); } @@ -522,6 +575,9 @@ void program_impl::mark_if_data_flow(program_node& node) { void program_impl::transfer_memory_to_device() { OV_ITT_SCOPED_TASK(itt::domains::CLDNN, "ProgramImpl::TransferMemory"); + if (!get_engine().supports_allocation(allocation_type::usm_device)) + return; + for (auto& node : processing_order) { if (node->is_type() && !node->need_lockable_memory()) { auto& data_node = node->as(); @@ -535,15 +591,15 @@ void program_impl::transfer_memory_to_device() { throw std::invalid_argument(err_str); } + if (alloc_type == allocation_type::usm_host || alloc_type == allocation_type::usm_shared) { // Allocate and transfer memory - auto device_mem = mem.get_engine()->allocate_memory(data_node_layout, - allocation_type::usm_device, - mem.get_net_id(), - false); - dynamic_cast(*device_mem).copy_from_other(dynamic_cast(mem)); - data_node.attach_memory(*device_mem); - const_cast(data_node.get_primitive()->mem).reset(); + auto device_mem = mem.get_engine()->allocate_memory(data_node_layout, allocation_type::usm_device, false); + device_mem->copy_from(get_stream(), mem); + data_node.attach_memory(device_mem); + const_cast(data_node.get_primitive()->mem).reset(); + // TODO: Do we need finish call here? Maybe call it in network::execute() ? + get_stream().finish(); } } } @@ -551,8 +607,7 @@ void program_impl::transfer_memory_to_device() { void program_impl::cleanup() { for (auto& node : processing_order) - if (!node->is_type()) - node->get_output_layout(); + node->get_output_layout(); // in debug build, at the end, mark all nodes as outputs so user can query for buffers of all not-optimized nodes, // including internal ones etc. @@ -595,7 +650,7 @@ program_impl::nodes_ordering& program_impl::get_processing_order() { return proc const program_impl::nodes_ordering& program_impl::get_processing_order() const { return processing_order; } void program_impl::prepare_memory_dependencies() { - if (!get_engine().configuration().enable_memory_pool) + if (!get_engine().configuration().use_memory_pool) return; apply_opt_pass(); @@ -760,18 +815,12 @@ void program_impl::rename(program_node& node, primitive_id const& new_id) { nodes_map.emplace(new_id, node_ptr); nodes_map.erase(node.id()); - if (!node.is_type()) - const_cast(node.desc->id) = new_id; - else - reinterpret_cast(node).internal_id = new_id; + const_cast(node.desc->id) = new_id; } void program_impl::swap_names(program_node& node1, program_node& node2) { const auto _extract_id = [](program_node& node) -> primitive_id& { - if (!node.is_type()) - return const_cast(node.desc->id); - else - return reinterpret_cast(node).internal_id; + return const_cast(node.desc->id); }; nodes_map.at(node1.id()).swap(nodes_map.at(node2.id())); @@ -1011,24 +1060,6 @@ void program_impl::remove_nodes(std::vector& to_remove) { } } -void program_impl::dump_memory_pool() const { - if (!get_engine().configuration().enable_memory_pool) - return; - auto path = get_dir_path(options); - if (path.empty()) { - return; - } - path += "cldnn_memory_pool.log"; - auto dep = get_memory_dependencies_string(); - get_engine().dump_memory_pool(*this, path, dep); - std::string dump_file_name; - if (pm->get_pass_count() < 10) - dump_file_name += "0"; - dump_file_name += std::to_string(pm->get_pass_count()) + "_memory_pool"; - pm->inc_pass_count(); - dump_program(dump_file_name.c_str(), true); -} - // TODO: break this function into number of smaller ones + add per-primitive fields (possibly use // primitive_inst::to_string?) void program_impl::dump_program(const char* stage, diff --git a/inference-engine/thirdparty/clDNN/src/program_dump_graph.cpp b/inference-engine/thirdparty/clDNN/src/program_dump_graph.cpp index 938c888d08939d..12e1abb4f34928 100644 --- a/inference-engine/thirdparty/clDNN/src/program_dump_graph.cpp +++ b/inference-engine/thirdparty/clDNN/src/program_dump_graph.cpp @@ -9,8 +9,6 @@ #include "data_inst.h" #include "condition_inst.h" -#include "gpu/ocl_toolkit.h" - #include #include #include @@ -213,7 +211,7 @@ void dump_graph_init(std::ofstream& graph, !node->can_be_optimized()) { graph << "\\n Selected kernel: " << (node->get_selected_impl() == nullptr ? "none" - : node->get_selected_impl().get()->get_kernel_name()) + + : node->get_selected_impl()->get_kernel_name()) + "\n" + dump_mem_info(node); } graph << "\""; @@ -227,9 +225,6 @@ void dump_graph_init(std::ofstream& graph, if (node->is_type() || node->is_constant()) { graph << ", shape=box"; } - if (node->is_type()) { - graph << ", color=blue"; - } if (node->is_reusing_memory()) { graph << ", fillcolor=\"" << colors[node->get_reused_memory_color() % colors.size()] << "\" "; diff --git a/inference-engine/thirdparty/clDNN/src/program_helpers.cpp b/inference-engine/thirdparty/clDNN/src/program_helpers.cpp index 27c67c032116ea..ccd099c2d4a6a7 100644 --- a/inference-engine/thirdparty/clDNN/src/program_helpers.cpp +++ b/inference-engine/thirdparty/clDNN/src/program_helpers.cpp @@ -13,24 +13,25 @@ namespace cldnn { // helper function for merging the weights/biases buffers on cpu side for depthwise separable convolution optimization -void program_helpers::merge_buffers(engine_impl& engine, +void program_helpers::merge_buffers(engine& engine, program_node& node, const layout& target_layout, size_t begin_offset, size_t end_offset) { - memory_impl::ptr data_to_allocate = engine.allocate_memory(target_layout, 0, false); + memory::ptr data_to_allocate = engine.allocate_memory(target_layout, false); + auto& stream = node.get_program().get_stream(); for (size_t i = begin_offset; i < end_offset; i++) { auto& weights = node.get_dependency(i).as(); - mem_lock src{weights.get_attached_memory()}; - mem_lock dst{data_to_allocate}; + mem_lock src{weights.get_attached_memory_ptr(), stream}; + mem_lock dst{data_to_allocate, stream}; std::copy(src.begin(), src.end(), dst.begin() + (i - begin_offset) * src.size()); } for (size_t i = 0; i < end_offset - begin_offset - 1; i++) node.remove_dependency(begin_offset + 1); auto& data_node = node.get_dependency(begin_offset).as(); - data_node.attach_memory(*data_to_allocate, false); + data_node.attach_memory(data_to_allocate, false); } void program_helpers::reshape_deconvolution_weights(const std::vector &deconv_weights, diff --git a/inference-engine/thirdparty/clDNN/src/program_node.cpp b/inference-engine/thirdparty/clDNN/src/program_node.cpp index 63bdc8f58eb135..4e24eacf25a23b 100644 --- a/inference-engine/thirdparty/clDNN/src/program_node.cpp +++ b/inference-engine/thirdparty/clDNN/src/program_node.cpp @@ -71,7 +71,6 @@ std::unique_ptr program_node::desc_to_json() const { node_info->add("ptr", "node_" + std::to_string(reinterpret_cast(this))); node_info->add("id", id()); node_info->add("type", desc->type_string()); - node_info->add("internal", bool_to_str(this->is_type())); node_info->add("valid output layout", bool_to_str(valid_output_layout)); json_composite output_layout_info; @@ -267,6 +266,10 @@ bool program_node::is_padding_supported(int axis, int padding) const { return true; } + void program_node::set_selected_impl(std::unique_ptr impl) { + selected_impl = std::move(impl); +} + bool program_node::need_lockable_memory() const { bool need_lockable_mem = get_users().empty() || std::any_of(get_users().begin(), get_users().end(), [](const program_node* n) { return n->get_selected_impl()->is_cpu(); @@ -274,16 +277,3 @@ bool program_node::need_lockable_memory() const { return need_lockable_mem; } - -primitive_id details::internal_program_node_base::get_next_internal_id() { - static std::atomic counter{0}; - auto idx = counter++; - return primitive_id("_cldnn_internal_") + std::to_string(idx); -} - -details::internal_program_node_base::internal_program_node_base(program_impl& prog) - : program_node(nullptr, prog), internal_id(get_next_internal_id()) {} - -void details::internal_program_node_base::set_implementation(std::unique_ptr&& impl) { - selected_impl = std::move(impl); -} diff --git a/inference-engine/thirdparty/clDNN/src/pyramid_roi_align.cpp b/inference-engine/thirdparty/clDNN/src/pyramid_roi_align.cpp index bc2bbbc095d96c..37eb2bc16501a8 100644 --- a/inference-engine/thirdparty/clDNN/src/pyramid_roi_align.cpp +++ b/inference-engine/thirdparty/clDNN/src/pyramid_roi_align.cpp @@ -5,7 +5,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include "pyramid_roi_align_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/quantize.cpp b/inference-engine/thirdparty/clDNN/src/quantize.cpp index 95f4e5c6be321d..6d26b7fdbdba5b 100644 --- a/inference-engine/thirdparty/clDNN/src/quantize.cpp +++ b/inference-engine/thirdparty/clDNN/src/quantize.cpp @@ -5,8 +5,8 @@ #include "quantize_inst.h" #include "binary_convolution_inst.h" #include "primitive_type_base.h" -#include "memory_impl.h" -#include "error_handler.h" +#include "cldnn/runtime/memory.hpp" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include "data_inst.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/reduce.cpp b/inference-engine/thirdparty/clDNN/src/reduce.cpp index d1d66553e9c6f0..e4f4634f062b71 100644 --- a/inference-engine/thirdparty/clDNN/src/reduce.cpp +++ b/inference-engine/thirdparty/clDNN/src/reduce.cpp @@ -5,7 +5,7 @@ #include "reduce_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include "data_inst.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/reorder.cpp b/inference-engine/thirdparty/clDNN/src/reorder.cpp index bbe1f897c4e8ce..7300a83e3a4e6a 100644 --- a/inference-engine/thirdparty/clDNN/src/reorder.cpp +++ b/inference-engine/thirdparty/clDNN/src/reorder.cpp @@ -5,7 +5,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include "reorder_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include @@ -235,7 +235,7 @@ void reorder_inst::reuse_input() { if (node.requires_reinterpret()) { _output = _network.get_engine().reinterpret_buffer(input_memory(), node.get_output_layout()); } else { - _output = (memory_impl::ptr) &input_memory(); + _output = input_memory_ptr(); } } diff --git a/inference-engine/thirdparty/clDNN/src/resample.cpp b/inference-engine/thirdparty/clDNN/src/resample.cpp index 882a2361d3e83d..187dbdfc8e46bb 100644 --- a/inference-engine/thirdparty/clDNN/src/resample.cpp +++ b/inference-engine/thirdparty/clDNN/src/resample.cpp @@ -5,7 +5,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include "resample_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include #include diff --git a/inference-engine/thirdparty/clDNN/src/reshape.cpp b/inference-engine/thirdparty/clDNN/src/reshape.cpp index ecdbeb289a9f48..e6fc316cc539f7 100644 --- a/inference-engine/thirdparty/clDNN/src/reshape.cpp +++ b/inference-engine/thirdparty/clDNN/src/reshape.cpp @@ -5,8 +5,8 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include "reshape_inst.h" #include "primitive_type_base.h" -#include "memory_impl.h" -#include "error_handler.h" +#include "cldnn/runtime/memory.hpp" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/reverse_sequence.cpp b/inference-engine/thirdparty/clDNN/src/reverse_sequence.cpp index 77f650a8e19ad1..c0c2f1fb51f744 100644 --- a/inference-engine/thirdparty/clDNN/src/reverse_sequence.cpp +++ b/inference-engine/thirdparty/clDNN/src/reverse_sequence.cpp @@ -5,7 +5,7 @@ #include "reverse_sequence_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/roi_pooling.cpp b/inference-engine/thirdparty/clDNN/src/roi_pooling.cpp index 4c291ec1329fe7..caa6dca083d2dd 100644 --- a/inference-engine/thirdparty/clDNN/src/roi_pooling.cpp +++ b/inference-engine/thirdparty/clDNN/src/roi_pooling.cpp @@ -4,7 +4,7 @@ #include "roi_pooling_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/scale.cpp b/inference-engine/thirdparty/clDNN/src/scale.cpp index 1e881122bdb9c8..52916cf1699bbb 100644 --- a/inference-engine/thirdparty/clDNN/src/scale.cpp +++ b/inference-engine/thirdparty/clDNN/src/scale.cpp @@ -4,7 +4,7 @@ #include "scale_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/scatter_elements_update.cpp b/inference-engine/thirdparty/clDNN/src/scatter_elements_update.cpp index 11165e1b547c27..ccfb299221ea69 100644 --- a/inference-engine/thirdparty/clDNN/src/scatter_elements_update.cpp +++ b/inference-engine/thirdparty/clDNN/src/scatter_elements_update.cpp @@ -5,7 +5,7 @@ #include "scatter_elements_update_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/scatter_nd_update.cpp b/inference-engine/thirdparty/clDNN/src/scatter_nd_update.cpp index e2935e530f2ef8..435650c28f6d68 100644 --- a/inference-engine/thirdparty/clDNN/src/scatter_nd_update.cpp +++ b/inference-engine/thirdparty/clDNN/src/scatter_nd_update.cpp @@ -5,7 +5,7 @@ #include "scatter_nd_update_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/scatter_update.cpp b/inference-engine/thirdparty/clDNN/src/scatter_update.cpp index 2359494f4d9f24..cba37e0a4cbdff 100644 --- a/inference-engine/thirdparty/clDNN/src/scatter_update.cpp +++ b/inference-engine/thirdparty/clDNN/src/scatter_update.cpp @@ -5,7 +5,7 @@ #include "scatter_update_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/select.cpp b/inference-engine/thirdparty/clDNN/src/select.cpp index 5494449d3849df..433e8ba04d2565 100644 --- a/inference-engine/thirdparty/clDNN/src/select.cpp +++ b/inference-engine/thirdparty/clDNN/src/select.cpp @@ -5,7 +5,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include "select_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/shuffle_channels.cpp b/inference-engine/thirdparty/clDNN/src/shuffle_channels.cpp index 530202d3fc1901..61e5578a8e97b8 100644 --- a/inference-engine/thirdparty/clDNN/src/shuffle_channels.cpp +++ b/inference-engine/thirdparty/clDNN/src/shuffle_channels.cpp @@ -5,7 +5,7 @@ #include "shuffle_channels_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/space_to_batch.cpp b/inference-engine/thirdparty/clDNN/src/space_to_batch.cpp index 98712851ae3ffb..9de115c3650477 100644 --- a/inference-engine/thirdparty/clDNN/src/space_to_batch.cpp +++ b/inference-engine/thirdparty/clDNN/src/space_to_batch.cpp @@ -5,7 +5,7 @@ #include "space_to_batch_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include "data_inst.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/space_to_depth.cpp b/inference-engine/thirdparty/clDNN/src/space_to_depth.cpp index c3283b32265af6..3fc1f16c3ef116 100644 --- a/inference-engine/thirdparty/clDNN/src/space_to_depth.cpp +++ b/inference-engine/thirdparty/clDNN/src/space_to_depth.cpp @@ -5,7 +5,7 @@ #include "space_to_depth_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/split.cpp b/inference-engine/thirdparty/clDNN/src/split.cpp index 80ee4aac11a753..182fe49f0b083b 100644 --- a/inference-engine/thirdparty/clDNN/src/split.cpp +++ b/inference-engine/thirdparty/clDNN/src/split.cpp @@ -4,8 +4,8 @@ #include "split_inst.h" #include "primitive_type_base.h" -#include "memory_impl.h" -#include "error_handler.h" +#include "cldnn/runtime/memory.hpp" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/strided_slice.cpp b/inference-engine/thirdparty/clDNN/src/strided_slice.cpp index eb409b3572c454..8faf64a3626a64 100644 --- a/inference-engine/thirdparty/clDNN/src/strided_slice.cpp +++ b/inference-engine/thirdparty/clDNN/src/strided_slice.cpp @@ -4,7 +4,7 @@ #include "strided_slice_inst.h" #include "primitive_type_base.h" -#include "error_handler.h" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include "data_inst.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/tile.cpp b/inference-engine/thirdparty/clDNN/src/tile.cpp index c6661655d926f5..798a835af45fe4 100644 --- a/inference-engine/thirdparty/clDNN/src/tile.cpp +++ b/inference-engine/thirdparty/clDNN/src/tile.cpp @@ -4,8 +4,8 @@ #include "tile_inst.h" #include "primitive_type_base.h" -#include "memory_impl.h" -#include "error_handler.h" +#include "cldnn/runtime/memory.hpp" +#include "cldnn/runtime/error_handler.hpp" #include "json_object.h" #include diff --git a/inference-engine/thirdparty/clDNN/src/topology.cpp b/inference-engine/thirdparty/clDNN/src/topology.cpp index 7d0708669fd0db..4ba2c86a151197 100644 --- a/inference-engine/thirdparty/clDNN/src/topology.cpp +++ b/inference-engine/thirdparty/clDNN/src/topology.cpp @@ -3,7 +3,8 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include "api/topology.hpp" + +#include "cldnn/graph/topology.hpp" #include "topology_impl.h" #include #include @@ -33,14 +34,6 @@ void topology::add_primitive(std::shared_ptr desc) { _impl->add(desc); } -void topology::retain() { - _impl->add_ref(); -} - -void topology::release() { - _impl->release(); -} - const std::shared_ptr& topology::at(const primitive_id& id) const { return _impl->at(id); } diff --git a/inference-engine/thirdparty/clDNN/tests/CMakeLists.txt b/inference-engine/thirdparty/clDNN/tests/CMakeLists.txt index f1107dba4317df..00011e54075fa6 100644 --- a/inference-engine/thirdparty/clDNN/tests/CMakeLists.txt +++ b/inference-engine/thirdparty/clDNN/tests/CMakeLists.txt @@ -65,7 +65,7 @@ if(UNIX) set_source_files_properties(${__CLDNN_Sources__gtest} PROPERTIES COMPILE_FLAGS "-Wno-undef") endif() - + if (MSVC) file(GLOB __CLDNN_Sources__natvis "${CMAKE_CURRENT_SOURCE_DIR}/float16.natvis" @@ -76,7 +76,7 @@ set(__CLDNN_Directory__ks_main "${CLDNN__KERNEL_SELECTOR_DIR}") set(__CLDNN_Directory__ks_core "${CLDNN__KERNEL_SELECTOR_DIR}/core") set(__CLDNN_Directory__ks_common "${CLDNN__KERNEL_SELECTOR_DIR}/common") set(__CLDNN_Directory__ks_core_common "${__CLDNN_Directory__ks_core}/common") -set(__CLDNN_Directory__ks_actual_kernels "${__CLDNN_Directory__ks_core}/actual_kernels") +set(__CLDNN_Directory__ks_actual_kernels "${__CLDNN_Directory__ks_core}/actual_kernels") set(__CLDNN_Directory__ks_cache "${__CLDNN_Directory__ks_core}/cache") set(__CLDNN_AllSources @@ -101,7 +101,9 @@ source_group("${__CLDNN_Label__gtest}" FILES ${__CLDNN_Sources__gtest}) include_directories( "${CLDNN__MAIN_DIR}" "${CLDNN__MAIN_DIR}/src" + "${CLDNN__MAIN_DIR}/src/include/" "${CMAKE_CURRENT_SOURCE_DIR}" + "${CLDNN__RUNTIME_DIR}" "${__CLDNN_Directory__test_utils}" "${__CLDNN_Directory__ks_core}" "${__CLDNN_Directory__ks_core}/common" @@ -118,20 +120,23 @@ include_directories(SYSTEM add_executable("${CLDNN_BUILD__PROJ}" ${__CLDNN_AllSources} ) + +if(COMMAND set_ie_threading_interface_for) + set_ie_threading_interface_for("${CLDNN_BUILD__PROJ}") +endif() + set_property(TARGET "${CLDNN_BUILD__PROJ}" PROPERTY PROJECT_LABEL "${CLDNN_BUILD__PROJ_LABEL}") set_property(TARGET "${CLDNN_BUILD__PROJ}" PROPERTY OUTPUT_NAME "${CLDNN_BUILD__PROJ_OUTPUT_NAME}") # Set library dependencies -target_link_libraries("${CLDNN_BUILD__PROJ}" - "${CLDNN_BUILD__PROJ__clDNN}" - ) +target_link_libraries("${CLDNN_BUILD__PROJ}" PRIVATE "${CLDNN_BUILD__PROJ__clDNN}") if(WIN32) - target_link_libraries("${CLDNN_BUILD__PROJ}" setupapi) + target_link_libraries("${CLDNN_BUILD__PROJ}" PRIVATE setupapi) elseif((NOT ANDROID) AND (UNIX)) - target_link_libraries("${CLDNN_BUILD__PROJ}" pthread) + target_link_libraries("${CLDNN_BUILD__PROJ}" PRIVATE pthread) endif() -target_link_libraries("${CLDNN_BUILD__PROJ}" ${CLDNN__SYSTEM_LINK_LIBRARIES}) +target_link_libraries("${CLDNN_BUILD__PROJ}" PRIVATE ${CLDNN__SYSTEM_LINK_LIBRARIES}) # =================================== Custom pre- and post-steps ======================================= diff --git a/inference-engine/thirdparty/clDNN/tests/module_tests/events_pool_test.cpp b/inference-engine/thirdparty/clDNN/tests/module_tests/events_pool_test.cpp index 8dc4d57f426be7..b318e806d08f4a 100644 --- a/inference-engine/thirdparty/clDNN/tests/module_tests/events_pool_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/module_tests/events_pool_test.cpp @@ -2,11 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include "api/engine.hpp" -#include "test_utils/test_utils.h" -#include "api/input_layout.hpp" -#include "api/network.hpp" +#include "test_utils.h" using namespace tests; using namespace cldnn; @@ -35,17 +31,16 @@ TEST(events_pool, DISABLED_basic_test) for (int i = 0; i < 20; i++) { - engine eng;// here we build new engine i times - auto input = memory::allocate(eng, { data_types::f32, format::bfyx,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); + auto eng = engine::create(engine_types::ocl, runtime_types::ocl);// here we build new engine i times + auto input = eng->allocate_memory({ data_types::f32, format::bfyx,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); std::vector input_vec = { -1.f, 2.f, -3.f, 4.f }; for (int j = 0; j < 20; j++) //then we build network j times { - network network(eng, topology, bo); + network network(*eng, topology, bo); network.set_input_data("input", input); for(int k = 0; k < 20; k++) //and execute that network k times - network.execute(); + network.execute(); } - EXPECT_EQ(eng.get_max_used_device_memory_size(), (uint64_t)80); - eng.~engine(); + EXPECT_EQ(eng->get_max_used_device_memory(), (uint64_t)80); } } diff --git a/inference-engine/thirdparty/clDNN/tests/module_tests/gpu_toolkit_test.cpp b/inference-engine/thirdparty/clDNN/tests/module_tests/gpu_toolkit_test.cpp deleted file mode 100644 index d7efdc350450c7..00000000000000 --- a/inference-engine/thirdparty/clDNN/tests/module_tests/gpu_toolkit_test.cpp +++ /dev/null @@ -1,225 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include "api/engine.hpp" -#include "test_utils/test_utils.h" -#include "api/network.hpp" -#include "api/topology.hpp" -#include "api/input_layout.hpp" -#include "api/activation.hpp" -#include "api/cldnn.hpp" - -#include "test_utils.h" - -#if defined __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wmissing-braces" -#elif defined __GNUC__ && __GNUC__ >= 6 -#pragma GCC diagnostic ignored "-Wignored-attributes" -#endif - -#include - -using namespace cldnn; - -class user_gpu_toolkit -{ -public: - user_gpu_toolkit() - { - get_platform_and_device(get_plaftorm()); - create_context_from_one_device(); - } - - cl_context get_gpu_context() const { return _gpu_context; } - -private: - cl_platform_id _platform_id; - cl_device_id _gpu_device; - cl_context _gpu_context; - - void create_context_from_one_device() - { - cl_int error = 0; - _gpu_context = clCreateContext(0, 1, &_gpu_device, 0, 0, &error); - if (error != CL_SUCCESS) - { - throw std::runtime_error("error creating context"); - } - } - - cl_platform_id get_plaftorm() - { - static constexpr auto INTEL_PLATFORM_VENDOR = "Intel(R) Corporation"; - cl_uint n = 0; - cl_int err = clGetPlatformIDs(0, NULL, &n); - if (err != CL_SUCCESS) { - throw std::runtime_error("clGetPlatformIDs error " + std::to_string(err)); - } - - // Get platform list - std::vector platform_ids(n); - err = clGetPlatformIDs(n, platform_ids.data(), NULL); - if (err != CL_SUCCESS) { - throw std::runtime_error("clGetPlatformIDs error " + std::to_string(err)); - } - - // find Intel platform - for (auto& id : platform_ids) { - size_t infoSize; - err = clGetPlatformInfo(id, CL_PLATFORM_VENDOR, 0, NULL, &infoSize); - if (err != CL_SUCCESS) { - throw std::runtime_error("clGetPlatformInfo error " + std::to_string(err)); - } - - std::vector tmp(infoSize); - - err = clGetPlatformInfo(id, CL_PLATFORM_VENDOR, infoSize, tmp.data(), NULL); - if (err != CL_SUCCESS) { - throw std::runtime_error("clGetPlatformInfo error " + std::to_string(err)); - } - - std::string vendor_id(tmp.data()); - if (vendor_id == std::string(INTEL_PLATFORM_VENDOR)) - return id; - } - return static_cast(nullptr); - } - - void get_platform_and_device(cl_platform_id platform_id) - { - _platform_id = platform_id; - cl_int err = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_GPU, 1, &_gpu_device, 0); - if (err != CL_SUCCESS) { - throw std::runtime_error("clGetDeviceIDs error " + std::to_string(err)); - } - } -}; - -TEST(gpu_engine, DISABLED_user_context) -{ - user_gpu_toolkit gpu_toolkit; - cl_context user_context = gpu_toolkit.get_gpu_context(); - - device_query query(static_cast(user_context)); - auto devices = query.get_available_devices(); - - //[0] Check if the user engine config works. - auto engine_config = cldnn::engine_configuration(false, false, false, "", "", true, "", "", cldnn::priority_mode_types::disabled, cldnn::throttle_mode_types::disabled, true, 1); - - //[1]Check if the engine creation works. - engine engine(devices.begin()->second, engine_config); - auto info = engine.get_info(); - EXPECT_GT(info.cores_count, 0u); - EXPECT_GT(info.core_frequency, 0u); - - //[2]Now check if the queues works (run simple network). - topology topo; - auto inp_lay = cldnn::layout(cldnn::data_types::f32, cldnn::format::bfyx, { 1,1,2,2 }); - auto input_mem = cldnn::memory::allocate(engine, inp_lay); - tests::set_values(input_mem, { 1.0f, 2.0f, 3.0f, 4.0f }); - auto inp = input_layout("input", inp_lay); - auto activ = activation("this_needs_queue", "input", activation_func::abs); - topo.add(inp, activ); - network net(engine, topo); - - net.set_input_data("input", input_mem); - auto out = net.execute(); - auto out_ptr = out.at("this_needs_queue").get_memory().pointer(); - EXPECT_EQ(out.size(), size_t(1)); - for (uint32_t i = 0; i < 4; i++) - EXPECT_EQ(out_ptr[i], float(i + 1)); -} - -void execute_simple_topology(cldnn::engine& engine) { - auto batch_num = 1; - auto feature_num = 4; - auto x_size = 1; - auto y_size = 1; - auto input_tensor = cldnn::tensor(cldnn::spatial(x_size, y_size), cldnn::feature(feature_num), cldnn::batch(batch_num)); - auto topo = cldnn::topology( - cldnn::input_layout("input", { cldnn::data_types::f32, cldnn::format::bfyx, input_tensor }), - cldnn::activation("relu", "input", cldnn::activation_func::relu)); - - cldnn::network net(engine, topo); - auto input_mem = memory::allocate(engine, { data_types::f32, format::bfyx, input_tensor }); - tests::set_values(input_mem, { -1.f, 2.f, -3.f, 4.f }); - net.set_input_data("input", input_mem); - auto outs = net.execute(); - auto output = outs.at("relu"); - auto out_ptr = output.get_memory().pointer(); - ASSERT_EQ(out_ptr[0], 0.0f); - ASSERT_EQ(out_ptr[1], 2.0f); - ASSERT_EQ(out_ptr[2], 0.0f); - ASSERT_EQ(out_ptr[3], 4.0f); -} - - -TEST(gpu_device_query, get_device_info) -{ - cldnn::device_query query; - auto devices = query.get_available_devices(); - auto device_id = devices.begin()->first; - auto device = devices.begin()->second; - auto device_info = device.get_info(); - - //check key and few members, so we know that device info was returned properly - ASSERT_EQ(device_id, "0"); - ASSERT_GT(device_info.cores_count, 0u); - ASSERT_GT(device_info.core_frequency, 0u); - ASSERT_NE(device_info.dev_name, ""); - ASSERT_NE(device_info.driver_version, ""); -} - - -TEST(gpu_device_query, get_engine_info) -{ - const auto& engine = tests::get_test_engine(); - auto info = engine.get_info(); - EXPECT_GT(info.cores_count, 0u); - EXPECT_GT(info.core_frequency, 0u); -} - - -TEST(gpu_device_query, simple) -{ - cldnn::device_query query; - auto devices = query.get_available_devices(); - auto device = devices.begin()->second; - - cldnn::engine eng(device); - //check if simple execution was finished correctly - execute_simple_topology(eng); -} - -TEST(gpu_device_query, DISABLED_release_query) -{ - cldnn::device_query query; - auto devices = query.get_available_devices(); - auto device = devices.begin()->second; - - //destroy query - query.~device_query(); - //create engine - cldnn::engine eng(device); - //check if simple execution was finished correctly - execute_simple_topology(eng); -} - -TEST(gpu_device_query, DISABLED_release_device) -{ - cldnn::device_query query; - auto devices = query.get_available_devices(); - auto device = devices.begin()->second; - - //destroy query - query.~device_query(); - //create engine - cldnn::engine eng(device); - //destroy device - device.~device(); - //check if simple execution was finished correctly - execute_simple_topology(eng); -} diff --git a/inference-engine/thirdparty/clDNN/tests_core_internal/test_cases/graph_manipulation_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/module_tests/graph_manipulation_gpu_test.cpp similarity index 67% rename from inference-engine/thirdparty/clDNN/tests_core_internal/test_cases/graph_manipulation_gpu_test.cpp rename to inference-engine/thirdparty/clDNN/tests/module_tests/graph_manipulation_gpu_test.cpp index 81e4665287533c..25e6260ea1236a 100644 --- a/inference-engine/thirdparty/clDNN/tests_core_internal/test_cases/graph_manipulation_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/module_tests/graph_manipulation_gpu_test.cpp @@ -2,14 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "test_utils.h" -#include +#include "cldnn/runtime/engine.hpp" +#include "cldnn/runtime/memory.hpp" #include "program_impl.h" #include "topology_impl.h" -#include "engine_impl.h" -#include "memory_impl.h" #include "data_inst.h" #include "activation_inst.h" #include "convolution_inst.h" @@ -18,29 +17,30 @@ #include "reshape_inst.h" #include "pass_manager.h" -#include "test_utils.h" #include "program_impl_wrapper.h" +#include + using namespace cldnn; using namespace ::tests; /* Basic test to show how the program can be build and run within internal tests in similar way as it is done in tests utilizing clDNN API */ TEST(basic, test1) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); build_options build_opt; build_opt.set_option(build_option::optimize_data(true)); - auto input = memory::allocate(engine, { data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); - auto weights1 = memory::allocate(engine, { data_types::f16, format::yxfb,{ 1, 1, 2, 1 } }); - auto weights2 = memory::allocate(engine, { data_types::f32, format::byxf,{ 1, 1, 1, 2 } }); + auto input = engine.allocate_memory({ data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); + auto weights1 = engine.allocate_memory({ data_types::f16, format::yxfb,{ 1, 1, 2, 1 } }); + auto weights2 = engine.allocate_memory({ data_types::f32, format::byxf,{ 1, 1, 1, 2 } }); set_values(input, { FLOAT16(1.1f), FLOAT16(1.2f), FLOAT16(1.3f), FLOAT16(1.4f) }); set_values(weights1, { FLOAT16(2.1f), FLOAT16(3.1f) }); set_values(weights2, { 1.1f, 0.1f }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("weights1", weights1)); topology.add(data("weights2", weights2)); topology.add(reshape("reshape1", "weights1", tensor(spatial(1, 2)))); @@ -49,9 +49,9 @@ TEST(basic, test1) { topology.add(concatenation("concat", { "reorder1", "weights2" }, concatenation::along_x)); topology.add(convolution("conv2", { "reorder2" }, { "concat" })); - program_impl::ptr prog = engine.get()->build_program(*topology.get(), build_opt, false); - cldnn::refcounted_obj_ptr net = engine.get()->allocate_network(*prog, 0); - network network = (cldnn::network) net.get(); + program_impl::ptr prog = program_impl::build_program(engine, *topology.get(), build_opt, false); + std::shared_ptr net = network_impl::allocate_network(engine, prog); + network network(net); network.set_input_data("input", input); @@ -60,24 +60,22 @@ TEST(basic, test1) { float epsilon = 1e-2f; for (auto& it : outputs) { - auto output = it.second.get_memory().pointer(); + cldnn::mem_lock output(it.second.get_memory(), get_test_stream()); EXPECT_NEAR(7.8f, output[0], epsilon); } } -/* - This test creates a program without optimization passes, even the compilation is being run manualy. - Thus, a single method from program_impl like add_intermediate might be tested separately. -*/ +// This test creates a program without optimization passes, even the compilation is being run manualy. +// Thus, a single method from program_impl like add_intermediate might be tested separately. TEST(add_intermediate_gpu, test1) { build_options build_opt; topology topology; - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, {2, 2, 2, 2} }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, {2, 2, 2, 2} }); - auto weights2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, {2, 2, 2, 2} }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, {2, 2, 2, 2} }); + auto weights2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 1, 1 } }); set_values(input, { (1.1f), (1.2f), (1.3f), (1.4f), (2.1f), (2.2f), (2.3f), (2.4f), @@ -89,21 +87,21 @@ TEST(add_intermediate_gpu, test1) (4.5f), (4.6f), (4.7f), (4.8f) }); set_values(weights2, { (5.5f), (5.6f), (5.7f), (5.8f) }); - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("weights", weights)); topology.add(data("weights2", weights2)); topology.add(cldnn::convolution("conv1a", { "input" }, { "weights" })); topology.add(cldnn::convolution("conv1b", { "input" }, { "weights" })); topology.add(cldnn::convolution("conv2a", { "conv1a" }, { "weights2" })); - auto new_reorder = std::make_shared("reorder","nothing", input.get_layout()); - program_impl::ptr prog = engine.get()->build_program(*topology.get(), build_opt, false, true); + auto new_reorder = std::make_shared("reorder","nothing", input->get_layout()); + program_impl::ptr prog = program_impl::build_program(engine, *topology.get(), build_opt, false, true); prog->add_intermediate(new_reorder, prog->get_node("conv1a"), 0); prog->dump_program("custom_dump", true); - program_impl_wrapper::run_graph_compilation(*prog); + program_impl_wrapper::build(*prog); - cldnn::refcounted_obj_ptr net = engine.get()->allocate_network(*prog, 0); - network network = (cldnn::network) net.get(); + std::shared_ptr net = network_impl::allocate_network(engine, prog); + network network(net); network.set_input_data("input", input); auto outputs = network.execute(); @@ -116,7 +114,7 @@ TEST(add_intermediate_gpu, test1) uint32_t output_index = 0; for (auto& it : outputs) { - auto output = it.second.get_memory().pointer(); + cldnn::mem_lock output(it.second.get_memory(), get_test_stream()); for (uint32_t x = 0; x < output_size; x++) { EXPECT_FLOAT_EQ(expected_output_vec[x+output_size*output_index], output[x]); @@ -126,15 +124,16 @@ TEST(add_intermediate_gpu, test1) } /* This test shows how to use private members (here: add_connection) of program_impl using program_impl_wraper */ +// Disabled for now as it produces wrong results TEST(add_intermediate_gpu, test2) { build_options build_opt; topology topology; - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); - auto weights2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); + auto weights2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 1, 1 } }); set_values(input, { (1.1f), (1.2f), (1.3f), (1.4f), (2.1f), (2.2f), (2.3f), (2.4f), @@ -147,7 +146,7 @@ TEST(add_intermediate_gpu, test2) set_values(weights2, { (5.5f), (5.6f), (5.7f), (5.8f) }); - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("weights2", weights2)); topology.add(cldnn::convolution("conv2a", { "input" }, { "weights2" })); @@ -157,16 +156,16 @@ TEST(add_intermediate_gpu, test2) w_vec.push_back("weights"); auto new_conv = std::make_shared("conv1a", "input", w_vec); auto weights_node = std::make_shared("weights", weights); - program_impl::ptr prog = engine.get()->build_program(*topology.get(), build_opt, false, true); + program_impl::ptr prog = program_impl::build_program(engine, *topology.get(), build_opt, false, true); prog->add_intermediate(new_conv, prog->get_node("conv2a"), 0, true, true); program_impl_wrapper::add_connection(*prog, prog->get_or_create(weights_node), prog->get_or_create(new_conv)); prog->dump_program("custom_dump", true); - program_impl_wrapper::run_graph_compilation(*prog); + program_impl_wrapper::build(*prog); - cldnn::refcounted_obj_ptr net = engine.get()->allocate_network(*prog, 0); - network network = (cldnn::network) net.get(); + std::shared_ptr net = network_impl::allocate_network(engine, prog); + network network(net); network.set_input_data("input", input); auto outputs = network.execute(); @@ -177,7 +176,7 @@ TEST(add_intermediate_gpu, test2) uint32_t output_size = 4; for (auto& it : outputs) { - auto output = it.second.get_memory().pointer(); + cldnn::mem_lock output(it.second.get_memory(), get_test_stream()); for (uint32_t x = 0; x < output_size; x++) { EXPECT_FLOAT_EQ(expected_output_vec[x], output[x]); diff --git a/inference-engine/thirdparty/clDNN/tests_core_internal/test_cases/prepare_conv_eltw_fusing.cpp b/inference-engine/thirdparty/clDNN/tests/module_tests/prepare_conv_eltw_fusing.cpp similarity index 78% rename from inference-engine/thirdparty/clDNN/tests_core_internal/test_cases/prepare_conv_eltw_fusing.cpp rename to inference-engine/thirdparty/clDNN/tests/module_tests/prepare_conv_eltw_fusing.cpp index 1e6037fd98a773..1ca951b244d6ce 100644 --- a/inference-engine/thirdparty/clDNN/tests_core_internal/test_cases/prepare_conv_eltw_fusing.cpp +++ b/inference-engine/thirdparty/clDNN/tests/module_tests/prepare_conv_eltw_fusing.cpp @@ -2,20 +2,20 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "test_utils.h" -#include +#include "cldnn/runtime/engine.hpp" #include "program_impl.h" #include "data_inst.h" -#include "engine_impl.h" #include "eltwise_inst.h" #include "network_impl.h" #include "pass_manager.h" -#include "test_utils.h" #include "program_impl_wrapper.h" +#include + using namespace cldnn; using namespace ::tests; @@ -23,20 +23,19 @@ using namespace ::tests; std::map test_prepare_conv_eltw_fusing(bool eltw1, bool eltw2) { build_options build_opt; - build_opt.set_option(build_option::graph_dumps_dir("dumps")); build_opt.set_option(build_option::optimize_data(true)); - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 2, 2 } }); - auto weights1 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); - auto weights2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 2, 2 } }); + auto weights1 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto weights2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); set_values(input, { 1.1f, 1.2f, 1.3f, 1.4f }); set_values(weights1, { 2.1f}); set_values(weights2, { -1.5f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("weights1", weights1)); topology.add(data("weights2", weights2)); topology.add(convolution("conv1", { "input" }, { "weights1" })); @@ -67,15 +66,17 @@ std::map test_prepare_conv_eltw_fusing(bool eltw1, { topology.add(eltwise("eltw3", "conv1", "conv2", cldnn::eltwise_mode::sum)); } - program_impl::ptr prog = engine.get()->build_program(*topology.get(), build_opt, false, true); + program_impl::ptr prog = program_impl::build_program(engine, *topology.get(), build_opt, false, true); layout_optimizer lo; program_impl_wrapper::apply_opt_pass(*prog, lo); program_impl_wrapper::run_graph_compilation(*prog); program_impl_wrapper::prepare_memory_dependencies(*prog); - cldnn::refcounted_obj_ptr net = engine.get()->allocate_network(*prog, 0); - network network = (cldnn::network) net.get(); + program_impl_wrapper::compile(*prog); + program_impl_wrapper::init_kernels(*prog); + std::shared_ptr net = network_impl::allocate_network(engine, prog); + network network(net); network.set_input_data("input", input); return network.execute(); @@ -94,7 +95,7 @@ TEST(prepare_conv_eltw_fusing, testlp) float epsilon = 1e-3f; for (auto& it : outputs) { - auto output = it.second.get_memory().pointer(); + cldnn::mem_lock output(it.second.get_memory(), get_test_stream()); for (int i = 0; i < 4; i++) EXPECT_NEAR(ref_out[i], output[i], epsilon); } @@ -114,7 +115,7 @@ TEST(prepare_conv_eltw_fusing, testl) float epsilon = 1e-3f; for (auto& it : outputs) { - auto output = it.second.get_memory().pointer(); + cldnn::mem_lock output(it.second.get_memory(), get_test_stream()); for (int i = 0; i < 4; i++) EXPECT_NEAR(ref_out[i], output[i], epsilon); } @@ -135,7 +136,7 @@ TEST(prepare_conv_eltw_fusing, testp) float epsilon = 1e-3f; for (auto& it : outputs) { - auto output = it.second.get_memory().pointer(); + cldnn::mem_lock output(it.second.get_memory(), get_test_stream()); for (int i = 0; i < 4; i++) EXPECT_NEAR(ref_out[i], output[i], epsilon); } diff --git a/inference-engine/thirdparty/clDNN/tests_core_internal/program_impl_wrapper.h b/inference-engine/thirdparty/clDNN/tests/module_tests/program_impl_wrapper.h similarity index 70% rename from inference-engine/thirdparty/clDNN/tests_core_internal/program_impl_wrapper.h rename to inference-engine/thirdparty/clDNN/tests/module_tests/program_impl_wrapper.h index 855f3f050db4d9..03b7bd279703e6 100644 --- a/inference-engine/thirdparty/clDNN/tests_core_internal/program_impl_wrapper.h +++ b/inference-engine/thirdparty/clDNN/tests/module_tests/program_impl_wrapper.h @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + namespace cldnn { struct program_node; @@ -24,6 +26,20 @@ namespace cldnn { p.run_graph_compilation(); } + static void compile(program_impl& p) + { + p.compile(); + } + static void build(program_impl& p) + { + program_impl_wrapper::run_graph_compilation(p); + program_impl_wrapper::compile(p); + program_impl_wrapper::init_kernels(p); + } + static void init_kernels(program_impl& p) + { + p.init_kernels(); + } static void prepare_memory_dependencies(program_impl& p) { p.prepare_memory_dependencies(); diff --git a/inference-engine/thirdparty/clDNN/tests_core_internal/test_cases/reorder_inputs_test.cpp b/inference-engine/thirdparty/clDNN/tests/module_tests/reorder_inputs_test.cpp similarity index 79% rename from inference-engine/thirdparty/clDNN/tests_core_internal/test_cases/reorder_inputs_test.cpp rename to inference-engine/thirdparty/clDNN/tests/module_tests/reorder_inputs_test.cpp index fb21acf2396ef4..f67512fc3a4ecf 100644 --- a/inference-engine/thirdparty/clDNN/tests_core_internal/test_cases/reorder_inputs_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/module_tests/reorder_inputs_test.cpp @@ -2,21 +2,21 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "test_utils.h" -#include +#include "cldnn/runtime/engine.hpp" #include "program_impl.h" #include "data_inst.h" -#include "engine_impl.h" #include "eltwise_inst.h" #include "network_impl.h" #include "pass_manager.h" #include "to_string_utils.h" -#include "test_utils.h" #include "program_impl_wrapper.h" +#include + using namespace cldnn; using namespace ::tests; @@ -31,13 +31,13 @@ TEST(reorder_inputs, propagation) { // Format of convolutions should be propagated through pooling. // At most single reorder should be inserted before first convolution. - auto engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f16, format::yxfb, { 2, 32, 1, 1 } }); - auto weights = memory::allocate(engine, { data_types::f16, format::bfyx, { 32, 32, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f16, format::yxfb, { 2, 32, 1, 1 } }); + auto weights = engine.allocate_memory({ data_types::f16, format::bfyx, { 32, 32, 1, 1 } }); topology topology; topology.add(data("weights", weights)); - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(convolution("conv1", "input", { "weights" })); topology.add(pooling("pool", "conv1", pooling_mode::max, { 1, 1, 1, 1 }, { 1, 1, 1, 1 })); topology.add(convolution("conv2", "pool", { "weights" })); @@ -70,11 +70,11 @@ TEST(reorder_inputs, propagation) { } TEST(reorder_inputs, impl_forcing_basic_format) { - auto engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 4, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 4, 1 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(pooling("pool", "input", pooling_mode::max, { 1, 1, 2, 1 }, { 1, 1, 2, 1 })); implementation_desc pool_impl = { format::yxfb, "" }; @@ -91,14 +91,14 @@ TEST(reorder_inputs, impl_forcing_basic_format) { network.execute(); auto network_impl = network.get(); - auto& prog = network_impl->get_program(); - auto& pool_node = prog.get_node("pool"); + const auto& prog = network_impl->get_program(); + auto& pool_node = prog->get_node("pool"); auto pool_layout = pool_node.get_output_layout(); EXPECT_EQ(pool_layout.format.value, format::yxfb); auto out_mem = network.get_output("pool").get_memory(); - auto out_mem_ptr = out_mem.pointer(); + cldnn::mem_lock out_mem_ptr(out_mem, get_test_stream()); ASSERT_EQ(out_mem_ptr.size(), 4u); @@ -109,11 +109,11 @@ TEST(reorder_inputs, impl_forcing_basic_format) { } TEST(reorder_inputs, impl_forcing_not_existing) { - auto engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 4, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 4, 1 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(pooling("pool", "input", pooling_mode::max, { 1, 1, 2, 1 }, { 1, 1, 2, 1 })); implementation_desc pool_impl = { format::any, "NOT_EXISTING" }; @@ -125,11 +125,11 @@ TEST(reorder_inputs, impl_forcing_not_existing) { } TEST(reorder_inputs, impl_forcing_basic_format_kernel) { - auto engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 4, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 4, 1 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(activation("actv", "input", activation_func::relu)); implementation_desc actv_impl = { format::yxfb, "activation_ref" }; @@ -146,8 +146,8 @@ TEST(reorder_inputs, impl_forcing_basic_format_kernel) { network.execute(); auto network_impl = network.get(); - auto& prog = network_impl->get_program(); - auto& node = prog.get_node("actv"); + auto prog = network_impl->get_program(); + auto& node = prog->get_node("actv"); auto actv_layout = node.get_output_layout(); auto kernel_name = node.get_selected_impl()->get_kernel_name(); @@ -155,7 +155,7 @@ TEST(reorder_inputs, impl_forcing_basic_format_kernel) { EXPECT_EQ(kernel_name, actv_impl.kernel_name); auto out_mem = network.get_output("actv").get_memory(); - auto out_mem_ptr = out_mem.pointer(); + cldnn::mem_lock out_mem_ptr(out_mem, get_test_stream()); ASSERT_EQ(out_mem_ptr.size(), 8u); @@ -171,13 +171,13 @@ TEST(reorder_inputs, impl_forcing_basic_format_kernel) { // TODO Not yet implemented //TEST(reorder_inputs, impl_forcing_conv_format_kernel) { -// auto engine = get_test_engine(); -// auto input = memory::allocate(engine, { data_types::f32, format::bfyx, {1, 2, 2, 2} }); -// auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, {2, 2, 1, 1} }); +// auto& engine = get_test_engine(); +// auto input = engine.allocate_memory({ data_types::f32, format::bfyx, {1, 2, 2, 2} }); +// auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, {2, 2, 1, 1} }); // // topology topology; // topology.add(data("weights", weights)); -// topology.add(input_layout("input", input.get_layout())); +// topology.add(input_layout("input", input->get_layout())); // topology.add(convolution("conv", "input", { "weights" })); // topology.add(reorder("output", "conv", format::bfyx, data_types::f32)); // @@ -209,7 +209,7 @@ TEST(reorder_inputs, impl_forcing_basic_format_kernel) { // EXPECT_EQ(conv_sel_impl->get_kernel_name(), impl.kernel); // // auto out_mem = network.get_output("output").get_memory(); -// auto out_mem_ptr = out_mem.pointer(); +// cldnn::mem_lock out_mem_ptr(out_mem, get_test_stream()); // // EXPECT_EQ(out_mem_ptr.size(), 8); // diff --git a/inference-engine/thirdparty/clDNN/tests/module_tests/test_uqr_distribution.cpp b/inference-engine/thirdparty/clDNN/tests/module_tests/test_uqr_distribution.cpp index 88ecd67818bb34..0b85f0b1c1c973 100644 --- a/inference-engine/thirdparty/clDNN/tests/module_tests/test_uqr_distribution.cpp +++ b/inference-engine/thirdparty/clDNN/tests/module_tests/test_uqr_distribution.cpp @@ -2,9 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include - -#include "test_utils/uniform_quantized_real_distribution.hpp" +#include "test_utils.h" #include #include @@ -17,7 +15,7 @@ #include #include -namespace cldnn { namespace tests { +namespace tests { template struct uniform_quantized_real_distribution_test : ::testing::Test @@ -1137,4 +1135,4 @@ TYPED_TEST(uniform_quantized_real_distribution_test, DISABLED_generate_random_eq } } -}} // namespace cldnn { namespace tests { +} // namespace tests diff --git a/inference-engine/thirdparty/clDNN/tests_core_internal/test_cases/usm_memory_test.cpp b/inference-engine/thirdparty/clDNN/tests/module_tests/usm_memory_test.cpp similarity index 68% rename from inference-engine/thirdparty/clDNN/tests_core_internal/test_cases/usm_memory_test.cpp rename to inference-engine/thirdparty/clDNN/tests/module_tests/usm_memory_test.cpp index d1b35dc774c91b..c67b2516fc78bf 100644 --- a/inference-engine/thirdparty/clDNN/tests_core_internal/test_cases/usm_memory_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/module_tests/usm_memory_test.cpp @@ -2,14 +2,18 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "test_utils.h" -#include +#include "cldnn/runtime/engine.hpp" +#include "cldnn/runtime/memory.hpp" +#include "cldnn/runtime/device_query.hpp" +#include "runtime/ocl/ocl_stream.hpp" +#include "runtime/ocl/ocl_memory.hpp" +#include "runtime/ocl/ocl_common.hpp" +#include "runtime/ocl/ocl_base_event.hpp" #include "program_impl.h" #include "topology_impl.h" -#include "engine_impl.h" -#include "memory_impl.h" #include "data_inst.h" #include "activation_inst.h" #include "convolution_inst.h" @@ -17,14 +21,9 @@ #include "network_impl.h" #include "reshape_inst.h" #include "pass_manager.h" -#include "api/engine.hpp" -#include "test_utils.h" #include "program_impl_wrapper.h" -#include "gpu/ocl_queue_wrapper.h" -#include "gpu/memory_gpu.h" -#include "gpu/ocl_toolkit.h" -#include "gpu/command_queues_builder.h" -#include "gpu/ocl_base_event.h" + +#include using namespace cldnn; using namespace ::tests; @@ -36,7 +35,7 @@ using namespace ::tests; #pragma GCC diagnostic ignored "-Wignored-attributes" #endif -#include +#include using namespace cldnn; using namespace ::tests; @@ -47,21 +46,24 @@ struct usm_test_params{ class BaseUSMTest : public ::testing::TestWithParam { protected: - std::shared_ptr _device = nullptr; - std::shared_ptr _engine = nullptr; + std::shared_ptr _device = nullptr; + std::shared_ptr _engine = nullptr; bool _supports_usm = false; public: void SetUp() override { // Find device, which supports USMs. - device_query query; + device_query query(engine_types::ocl, runtime_types::ocl); auto devices = query.get_available_devices(); for (const auto& d : devices) { - if (d.second.get()->mem_caps().supports_usm()) { - _device = std::make_shared(d.second); + if (d.second->get_mem_caps().supports_usm()) { + _device = std::dynamic_pointer_cast(d.second); break; } } - _engine = std::make_shared(_device->get()); + if (!_device) { + GTEST_SUCCEED(); + } + _engine = std::dynamic_pointer_cast(engine::create(engine_types::ocl, runtime_types::ocl, _device)); _supports_usm = true; } @@ -76,8 +78,8 @@ TEST_P(ctor_test, basic) { return; } try { - cl::UsmMemory mem(_device->get()->get_context()); - auto cl_dev = _device->get()->get_device(); + cl::UsmMemory mem(_device->get_context()); + auto cl_dev = _device->get_device(); switch (p.type) { case allocation_type::usm_host: { mem.allocateHost(1); @@ -115,35 +117,31 @@ TEST_P(copy_and_read_buffer, basic) { return; } try { - gpu::command_queues_builder q_builder(_device->get()->get_context(), _device->get()->get_device(), _device->get()->get_platform()); - q_builder.build(); - auto queue = cl::CommandQueueIntel(q_builder.queue()); + ocl::ocl_stream stream(*_engine); size_t values_count = 100; size_t values_bytes_count = values_count * sizeof(float); std::vector src_buffer(values_count); std::iota(src_buffer.begin(), src_buffer.end(), 0.0f); cldnn::layout linear_layout = cldnn::layout(cldnn::data_types::f32, cldnn::format::bfyx, cldnn::tensor(1, 1, int32_t(values_count), 1)); - auto cldnn_mem_src = _engine->get()->allocate_memory(linear_layout, p.type); - auto ptr_to_fill = cldnn_mem_src->lock(); + auto cldnn_mem_src = _engine->allocate_memory(linear_layout, p.type); + // Fill src buffer switch (p.type) { case allocation_type::usm_host: case allocation_type::usm_shared: { - std::copy(src_buffer.begin(), src_buffer.end(), static_cast(ptr_to_fill)); - cldnn_mem_src->unlock(); + cldnn::mem_lock lock(cldnn_mem_src, stream); + std::copy(src_buffer.begin(), src_buffer.end(), lock.data()); break; } case allocation_type::usm_device: { - auto host_buf = _engine->get()->allocate_memory(linear_layout, allocation_type::usm_host); - std::copy(src_buffer.begin(), src_buffer.end(), static_cast(host_buf->lock())); - host_buf->unlock(); - queue.enqueueCopyUsm( - dynamic_cast(*host_buf).get_buffer(), - dynamic_cast(*cldnn_mem_src).get_buffer(), - values_bytes_count, - true - ); + auto casted = std::dynamic_pointer_cast(cldnn_mem_src); + auto host_buf = _engine->allocate_memory(linear_layout, allocation_type::usm_host); + { + cldnn::mem_lock lock(host_buf, stream); + std::copy(src_buffer.begin(), src_buffer.end(), lock.data()); + } + casted->copy_from(stream, *host_buf); break; } default: @@ -155,22 +153,17 @@ TEST_P(copy_and_read_buffer, basic) { switch (p.type) { case allocation_type::usm_host: case allocation_type::usm_shared: { - auto values_ptr = cldnn_mem_src->lock(); - std::memcpy(dst_buffer.data(), values_ptr, values_bytes_count); - cldnn_mem_src->unlock(); + cldnn::mem_lock lock(cldnn_mem_src, stream); + std::memcpy(dst_buffer.data(), lock.data(), values_bytes_count); break; } case allocation_type::usm_device: { - auto host_buf = _engine->get()->allocate_memory(linear_layout, allocation_type::usm_host); - queue.enqueueCopyUsm( - dynamic_cast(*cldnn_mem_src).get_buffer(), - dynamic_cast(*host_buf).get_buffer(), - values_bytes_count, - true - ); - auto values_ptr = host_buf->lock(); - std::memcpy(dst_buffer.data(), values_ptr, values_bytes_count); - host_buf->unlock(); + auto host_buf = _engine->allocate_memory(linear_layout, allocation_type::usm_host); + host_buf->copy_from(stream, *cldnn_mem_src); + { + cldnn::mem_lock lock(host_buf, stream); + std::memcpy(dst_buffer.data(), lock.data(), values_bytes_count); + } break; } default: @@ -197,22 +190,21 @@ TEST_P(fill_buffer, DISABLED_basic) { return; } try { - gpu::command_queues_builder q_builder(_device->get()->get_context(), _device->get()->get_device(), _device->get()->get_platform()); - q_builder.build(); - auto queue = cl::CommandQueueIntel(q_builder.queue()); + ocl::ocl_stream stream(*_engine); + auto queue = stream.get_cl_queue(); size_t values_count = 100; size_t values_bytes_count = values_count * sizeof(float); - cl::UsmMemory mem(_device->get()->get_context()); + cl::UsmMemory mem(_device->get_context()); switch (p.type) { case allocation_type::usm_host: mem.allocateHost(values_bytes_count); break; case allocation_type::usm_shared: - mem.allocateShared(_device->get()->get_device(), values_bytes_count); + mem.allocateShared(_device->get_device(), values_bytes_count); break; case allocation_type::usm_device: - mem.allocateDevice(_device->get()->get_device(), values_bytes_count); + mem.allocateDevice(_device->get_device(), values_bytes_count); break; default: FAIL() << "Not supported allocation type!"; @@ -240,7 +232,7 @@ TEST_P(fill_buffer, DISABLED_basic) { break; } case allocation_type::usm_device: { - cl::UsmMemory host_mem(_device->get()->get_context()); + cl::UsmMemory host_mem(_device->get_context()); host_mem.allocateHost(values_bytes_count); queue.enqueueCopyUsm( mem, diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/activation_simple_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/activation_simple_gpu_test.cpp index 77546a65f4d635..1760a85fdf641b 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/activation_simple_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/activation_simple_gpu_test.cpp @@ -2,24 +2,18 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// +#include "test_utils.h" + +#include +#include +#include +#include #include -#include #include -#include "api/memory.hpp" -#include -#include "api/activation.hpp" -#include -#include -#include -#include -#include "test_utils/test_utils.h" -#include "test_utils/float16.h" -#include "api/reorder.hpp" using namespace cldnn; -using namespace tests; +using namespace ::tests; TEST(activation_f32_fw_gpu, not_basic_yxfb) { // Input: @@ -34,9 +28,9 @@ TEST(activation_f32_fw_gpu, not_basic_yxfb) { // 0, 0, 0, 1, 0, // 0, 0, 0, 0, 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); set_values(input, { 1.0f, 0.0f, -3.0f, 4.0f, 5.0f, 0.0f, 2.0f, 3.0f, 4.0f, -6.0f, @@ -49,7 +43,7 @@ TEST(activation_f32_fw_gpu, not_basic_yxfb) { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), activation("not", "input", activation_func::negation)); network network(engine, topology); network.set_input_data("input", input); @@ -58,8 +52,8 @@ TEST(activation_f32_fw_gpu, not_basic_yxfb) { EXPECT_EQ(outputs.begin()->first, "not"); auto output_memory = outputs.at("not").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -83,9 +77,9 @@ TEST(activation_f32_fw_gpu, erf_basic_yxfb) { // 3 -3 3 0 1 // 1 1 1 -1 0 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); set_values(input, { 1.0f, 0.0f, -3.0f, 4.0f, 5.0f, 0.0f, 2.0f, 3.0f, 4.0f, -6.0f, @@ -93,7 +87,7 @@ TEST(activation_f32_fw_gpu, erf_basic_yxfb) { 1.0f, 1.0f, 1.0f, -1.0f, 0.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), activation("not", "input", activation_func::erf)); network network(engine, topology); network.set_input_data("input", input); @@ -102,9 +96,9 @@ TEST(activation_f32_fw_gpu, erf_basic_yxfb) { EXPECT_EQ(outputs.begin()->first, "not"); auto output_memory = outputs.at("not").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); - auto input_ptr = input.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); + cldnn::mem_lock input_ptr(input, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -128,9 +122,9 @@ TEST(activation_f32_fw_gpu, hard_sigmoid_basic_yxfb) { // 3 -3 3 0 1 // 1 1 1 -1 0 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); activation_additional_params params = { 1.0f, 0.5f }; set_values(input, { 1.0f, 0.0f, -3.0f, 4.0f, 5.0f, @@ -139,7 +133,7 @@ TEST(activation_f32_fw_gpu, hard_sigmoid_basic_yxfb) { 1.0f, 1.0f, 1.0f, -1.0f, 0.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), activation("not", "input", activation_func::hard_sigmoid, params)); network network(engine, topology); network.set_input_data("input", input); @@ -148,9 +142,9 @@ TEST(activation_f32_fw_gpu, hard_sigmoid_basic_yxfb) { EXPECT_EQ(outputs.begin()->first, "not"); auto output_memory = outputs.at("not").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); - auto input_ptr = input.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); + cldnn::mem_lock input_ptr(input, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -175,9 +169,9 @@ TEST(activation_f32_fw_gpu, reciprocal_basic_yxfb) { // 3 -3 3 0 1 // 1 1 1 -1 0 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); set_values(input, { 1.0f, 0.3f, -3.0f, 4.0f, 5.0f, 21.0f, 2.0f, 3.0f, 4.0f, -6.0f, @@ -185,7 +179,7 @@ TEST(activation_f32_fw_gpu, reciprocal_basic_yxfb) { 1.0f, 1.0f, 1.0f, -1.0f, 0.1f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), activation("not", "input", activation_func::reciprocal)); network network(engine, topology); network.set_input_data("input", input); @@ -194,9 +188,9 @@ TEST(activation_f32_fw_gpu, reciprocal_basic_yxfb) { EXPECT_EQ(outputs.begin()->first, "not"); auto output_memory = outputs.at("not").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); - auto input_ptr = input.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); + cldnn::mem_lock input_ptr(input, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -221,9 +215,9 @@ TEST(activation_f32_fw_gpu, selu_basic_yxfb) { // 3 -3 3 0 1 // 1 1 1 -1 0 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); activation_additional_params params = { 1.0f, 0.5f }; set_values(input, { 1.0f, 0.3f, -3.0f, 4.0f, 5.0f, @@ -232,7 +226,7 @@ TEST(activation_f32_fw_gpu, selu_basic_yxfb) { 1.0f, 1.0f, 1.0f, -1.0f, 0.1f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), activation("not", "input", activation_func::selu, params)); network network(engine, topology); network.set_input_data("input", input); @@ -241,9 +235,9 @@ TEST(activation_f32_fw_gpu, selu_basic_yxfb) { EXPECT_EQ(outputs.begin()->first, "not"); auto output_memory = outputs.at("not").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); - auto input_ptr = input.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); + cldnn::mem_lock input_ptr(input, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -269,9 +263,9 @@ TEST(activation_f32_fw_gpu, softplus_basic_yxfb) { // 3 -3 3 0 1 // 1 1 1 -1 0 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); set_values(input, { 1.0f, 0.3f, -3.0f, 4.0f, 5.0f, 21.0f, 2.0f, 3.0f, 4.0f, -6.0f, @@ -279,7 +273,7 @@ TEST(activation_f32_fw_gpu, softplus_basic_yxfb) { 1.0f, 1.0f, 1.0f, -1.0f, 0.1f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), activation("not", "input", activation_func::softplus)); network network(engine, topology); network.set_input_data("input", input); @@ -288,9 +282,9 @@ TEST(activation_f32_fw_gpu, softplus_basic_yxfb) { EXPECT_EQ(outputs.begin()->first, "not"); auto output_memory = outputs.at("not").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); - auto input_ptr = input.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); + cldnn::mem_lock input_ptr(input, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -315,9 +309,9 @@ TEST(activation_f32_fw_gpu, softsign_basic_yxfb) { // 3 -3 3 0 1 // 1 1 1 -1 0 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); set_values(input, { 1.0f, 0.3f, -3.0f, 4.0f, 5.0f, 21.0f, 2.0f, 3.0f, 4.0f, -6.0f, @@ -325,7 +319,7 @@ TEST(activation_f32_fw_gpu, softsign_basic_yxfb) { 1.0f, 1.0f, 1.0f, -1.0f, 0.1f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), activation("not", "input", activation_func::softsign)); network network(engine, topology); network.set_input_data("input", input); @@ -334,9 +328,9 @@ TEST(activation_f32_fw_gpu, softsign_basic_yxfb) { EXPECT_EQ(outputs.begin()->first, "not"); auto output_memory = outputs.at("not").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); - auto input_ptr = input.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); + cldnn::mem_lock input_ptr(input, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -361,9 +355,9 @@ TEST(activation_f32_fw_gpu, sign_basic_yxfb) { // 3 -3 3 0 1 // 1 1 1 -1 0 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); set_values(input, { 1.0f, 0.0f, -3.0f, 4.0f, 5.0f, 21.0f, 2.0f, 3.0f, 4.0f, -6.0f, @@ -371,7 +365,7 @@ TEST(activation_f32_fw_gpu, sign_basic_yxfb) { 1.0f, 1.0f, 1.0f, -1.0f, 0.1f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), activation("not", "input", activation_func::sign)); network network(engine, topology); network.set_input_data("input", input); @@ -380,9 +374,9 @@ TEST(activation_f32_fw_gpu, sign_basic_yxfb) { EXPECT_EQ(outputs.begin()->first, "not"); auto output_memory = outputs.at("not").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); - auto input_ptr = input.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); + cldnn::mem_lock input_ptr(input, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -401,15 +395,15 @@ TEST(activation_f32_fw_gpu, sign_basic_yxfb) { } TEST(activation_f32_fw_gpu, pow_basic_yxfb) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); set_values(input, { 1.0f, 2.0f, 3.0f, 4.0f }); VF output_vec = { 1.0f, 4.0f, 9.0f, 16.0f }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), activation("pow", "input", activation_func::pow, { 2.0f, 0.0f })); network network(engine, topology); network.set_input_data("input", input); @@ -418,8 +412,8 @@ TEST(activation_f32_fw_gpu, pow_basic_yxfb) { EXPECT_EQ(outputs.begin()->first, "pow"); auto output_memory = outputs.at("pow").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -437,15 +431,15 @@ TEST(activation_f32_fw_gpu, pow_basic_yxfb) { } TEST(activation_f16_fw_gpu, pow_basic_yxfb) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f16, format::yxfb, { 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f16, format::yxfb, { 1, 1, 2, 2 } }); set_values(input, { FLOAT16(1.0f), FLOAT16(2.0f), FLOAT16(3.0f), FLOAT16(4.5f) }); VF output_vec = { FLOAT16(1.0f), FLOAT16(8.0f), FLOAT16(27.0f), FLOAT16(91.125f) }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), activation("pow", "input", activation_func::pow, { FLOAT16(3.0f), FLOAT16(0.0f) })); network network(engine, topology); network.set_input_data("input", input); @@ -454,8 +448,8 @@ TEST(activation_f16_fw_gpu, pow_basic_yxfb) { EXPECT_EQ(outputs.begin()->first, "pow"); auto output_memory = outputs.at("pow").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -487,9 +481,9 @@ TEST(activation_f32_fw_gpu, relu_basic_yxfb) { // 3 -1.5 3 5 1 // 1 1 1 -0.5 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); set_values(input, { 1.0f, -2.0f, -3.0f, 4.0f, 5.0f, 2.0f, 2.0f, 3.0f, 4.0f, -6.0f, @@ -502,7 +496,7 @@ TEST(activation_f32_fw_gpu, relu_basic_yxfb) { 1.0f, 1.0f, 1.0f, -0.5f, 1.0f }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), activation("relu", "input", activation_func::relu_negative_slope, { 0.5f, 0.f }, padding{ { 0, 0, 0, 0 }, 0 })); network network(engine, topology); network.set_input_data("input", input); @@ -511,8 +505,8 @@ TEST(activation_f32_fw_gpu, relu_basic_yxfb) { EXPECT_EQ(outputs.begin()->first, "relu"); auto output_memory = outputs.at("relu").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -555,9 +549,9 @@ TEST(activation_f32_fw_gpu, relu_basic_bfzyx) { // 1 2 1 -1 2 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 1, 1, 5, 4, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 1, 1, 5, 4, 2 } }); set_values(input, { 1.0f, -2.0f, -3.0f, 4.0f, 5.0f, 2.0f, 2.0f, 3.0f, 4.0f, -6.0f, @@ -578,7 +572,7 @@ TEST(activation_f32_fw_gpu, relu_basic_bfzyx) { 1.0f, 2.0f, 1.0f, -1.0f, 2.0f }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), activation("relu", "input", activation_func::relu_negative_slope, { 0.5f, 0.f }, padding{ { 0, 0, 0, 0, 0 }, 0 })); network network(engine, topology); network.set_input_data("input", input); @@ -587,8 +581,8 @@ TEST(activation_f32_fw_gpu, relu_basic_bfzyx) { EXPECT_EQ(outputs.begin()->first, "relu"); auto output_memory = outputs.at("relu").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int z_size = output_layout.size.spatial[2]; int y_size = output_layout.size.spatial[1]; @@ -618,10 +612,10 @@ TEST(activation_f32_fw_gpu, basic_yxfb_all_functions) // a: 0.5, b: 2.5 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 1, 5, 4 } }); - auto input_params = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 1, 5, 4 } }); + auto input_params = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 2, 1, 1 } }); set_values(input, { 0.0f, -2.0f, -3.0f, 4.0f, 5.0f, 2.0f, 2.0f, 3.0f, 4.0f, -6.0f, @@ -665,7 +659,7 @@ TEST(activation_f32_fw_gpu, basic_yxfb_all_functions) { for (auto func : funcs) { - topology topology(input_layout("input", input.get_layout())); + topology topology(input_layout("input", input->get_layout())); if (i == 0) { @@ -684,9 +678,9 @@ TEST(activation_f32_fw_gpu, basic_yxfb_all_functions) EXPECT_EQ(outputs.begin()->first, "activation"); auto output_memory = outputs.at("activation").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); - auto input_ptr = input.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); + cldnn::mem_lock input_ptr(input, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -796,10 +790,10 @@ TEST(activation_f32_fw_gpu, basic_yxfb_all_functions) TEST(activation_f16_fw_gpu, basic_bfyx_all_functions) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 1, 2, 4 } }); - auto input_params = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 1, 2, 4 } }); + auto input_params = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 2, 1, 1 } }); set_values(input, { FLOAT16(-4.5f), FLOAT16(-2.5f), FLOAT16(-1.5f), FLOAT16(0.5f), FLOAT16(0.9f), FLOAT16(1.5f), FLOAT16(2.0f), FLOAT16(2.5f) }); @@ -818,7 +812,7 @@ TEST(activation_f16_fw_gpu, basic_bfyx_all_functions) for (uint8_t i = 0 ; i < 2 ; i++) { for (auto func : funcs) { - topology topology(input_layout("input", input.get_layout())); + topology topology(input_layout("input", input->get_layout())); if (i == 0) { topology.add(activation("activation", "input", func, params)); @@ -834,9 +828,9 @@ TEST(activation_f16_fw_gpu, basic_bfyx_all_functions) EXPECT_EQ(outputs.begin()->first, "activation"); auto output_memory = outputs.at("activation").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); - auto input_ptr = input.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); + cldnn::mem_lock input_ptr(input, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -884,9 +878,9 @@ TEST(activation_f16_fw_gpu, basic_bfyx_all_functions) TEST(activation_f32_fw_gpu, basic_yxfb_asin_acos_log_atan) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 1, 2, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 1, 2, 4 } }); set_values(input, { 0.12f, 0.56f, 0.45f, 0.789f, 0.546f, 0.999f, 0.7899f, 0.6677f}); std::vector funcs = { @@ -902,7 +896,7 @@ TEST(activation_f32_fw_gpu, basic_yxfb_asin_acos_log_atan) for (auto func : funcs) { - topology topology(input_layout("input", input.get_layout())); + topology topology(input_layout("input", input->get_layout())); topology.add(activation("activation", "input", func)); network network(engine, topology); @@ -912,9 +906,9 @@ TEST(activation_f32_fw_gpu, basic_yxfb_asin_acos_log_atan) EXPECT_EQ(outputs.begin()->first, "activation"); auto output_memory = outputs.at("activation").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); - auto input_ptr = input.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); + cldnn::mem_lock input_ptr(input, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -977,9 +971,9 @@ TEST(activation_f32_fw_gpu, relu_basic_acosh_yxfb) { // // Slope: 0.5 - const auto &engine = get_test_engine(); + auto &engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::yxfb, {1, 1, 5, 4}}); + auto input = engine.allocate_memory({data_types::f32, format::yxfb, {1, 1, 5, 4}}); set_values(input, {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, @@ -988,8 +982,8 @@ TEST(activation_f32_fw_gpu, relu_basic_acosh_yxfb) { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f}); topology topology( - input_layout("input", input.get_layout()), - reorder("reorder", "input", input.get_layout().with_padding(padding{{0, 0, 2, 1}, 0})), + input_layout("input", input->get_layout()), + reorder("reorder", "input", input->get_layout().with_padding(padding{{0, 0, 2, 1}, 0})), activation("relu", "reorder", activation_func::acosh, {0.5f, 0.f}, padding{{0, 0, 0, 0}, 0})); network network(engine, topology); network.set_input_data("input", input); @@ -997,9 +991,9 @@ TEST(activation_f32_fw_gpu, relu_basic_acosh_yxfb) { EXPECT_EQ(outputs.begin()->first, "relu"); auto output_memory = outputs.at("relu").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); - auto input_ptr = input.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); + cldnn::mem_lock input_ptr(input, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -1038,9 +1032,9 @@ TEST(activation_f32_fw_gpu, relu_basic_input_padding_yxfb) { // 3 -1.5 3 5 1 // 1 1 1 -0.5 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); set_values(input, { 1.0f, -2.0f, -3.0f, 4.0f, 5.0f, @@ -1054,8 +1048,8 @@ TEST(activation_f32_fw_gpu, relu_basic_input_padding_yxfb) { 1.0f, 1.0f, 1.0f, -0.5f, 1.0f}; topology topology( - input_layout("input", input.get_layout()), - reorder("reorder", "input", input.get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 })), + input_layout("input", input->get_layout()), + reorder("reorder", "input", input->get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 })), activation("relu", "reorder", activation_func::relu_negative_slope, { 0.5f, 0.f }, padding{ { 0, 0, 0, 0 }, 0 })); network network(engine, topology); network.set_input_data("input", input); @@ -1063,8 +1057,8 @@ TEST(activation_f32_fw_gpu, relu_basic_input_padding_yxfb) { EXPECT_EQ(outputs.begin()->first, "relu"); auto output_memory = outputs.at("relu").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -1116,9 +1110,9 @@ TEST(activation_f32_fw_gpu, relu_basic_input_padding_bfzyx) { // 3 -1.5 3 5 1 // 1 1 1 -0.5 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 1, 1, 5, 4, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 1, 1, 5, 4, 2 } }); set_values(input, { 1.0f, -2.0f, -3.0f, 4.0f, 5.0f, @@ -1141,8 +1135,8 @@ TEST(activation_f32_fw_gpu, relu_basic_input_padding_bfzyx) { 1.0f, 1.0f, 1.0f, -0.5f, 1.0f }; topology topology( - input_layout("input", input.get_layout()), - reorder("reorder", "input", input.get_layout().with_padding(padding{ { 0, 0, 2, 1, 0 }, 0 })), + input_layout("input", input->get_layout()), + reorder("reorder", "input", input->get_layout().with_padding(padding{ { 0, 0, 2, 1, 0 }, 0 })), activation("relu", "reorder", activation_func::relu_negative_slope, { 0.5f, 0.f }, padding{ { 0, 0, 0, 0, 0 }, 0 })); network network(engine, topology); network.set_input_data("input", input); @@ -1151,8 +1145,8 @@ TEST(activation_f32_fw_gpu, relu_basic_input_padding_bfzyx) { auto output_memory = outputs.at("relu").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int z_size = output_layout.size.spatial[2]; int y_size = output_layout.size.spatial[1]; @@ -1194,9 +1188,9 @@ TEST(activation_f32_fw_gpu, relu_basic_output_padding_yxfb) { // 0 0 0 0 0 0 0 0 0 0 0 // 0 0 0 0 0 0 0 0 0 0 0 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); set_values(input, { 1.0f, -2.0f, -3.0f, 4.0f, 5.0f, 2.0f, 2.0f, 3.0f, 4.0f, -6.0f, @@ -1215,7 +1209,7 @@ TEST(activation_f32_fw_gpu, relu_basic_output_padding_yxfb) { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), activation("relu", "input", activation_func::relu_negative_slope, { 0.5f, 0.f }, padding{ { 0, 0, 3, 3 }, 0 })); network network(engine, topology); network.set_input_data("input", input); @@ -1224,9 +1218,9 @@ TEST(activation_f32_fw_gpu, relu_basic_output_padding_yxfb) { EXPECT_EQ(outputs.begin()->first, "relu"); auto output_memory = outputs.at("relu").get_memory(); - auto output_layout = output_memory.get_layout(); + auto output_layout = output_memory->get_layout(); auto output_size = output_layout.get_buffer_size(); - auto output_ptr = output_memory.pointer(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_size.spatial[1]; int x_size = output_size.spatial[0]; @@ -1245,9 +1239,9 @@ TEST(activation_f32_fw_gpu, relu_basic_output_padding_yxfb) { TEST(activation_f32_fw_gpu, basic_yxfb_floor_ceil) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 1, 2, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 1, 2, 4 } }); set_values(input, { 0.01f, 0.99f, -0.01f, -0.99f, 1.1f, 1.0f, 0.0f, -1.1f }); std::vector funcs = { @@ -1257,7 +1251,7 @@ TEST(activation_f32_fw_gpu, basic_yxfb_floor_ceil) for (auto func : funcs) { - topology topology(input_layout("input", input.get_layout())); + topology topology(input_layout("input", input->get_layout())); topology.add(activation("activation", "input", func)); network network(engine, topology); @@ -1267,9 +1261,9 @@ TEST(activation_f32_fw_gpu, basic_yxfb_floor_ceil) EXPECT_EQ(outputs.begin()->first, "activation"); auto output_memory = outputs.at("activation").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); - auto input_ptr = input.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); + cldnn::mem_lock input_ptr(input, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -1300,8 +1294,8 @@ TEST(activation_f32_fw_gpu, basic_yxfb_floor_ceil) TEST(activation_i8_fw_gpu, basic_yxfb_all_funcs) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::i8, format::yxfb,{ 2, 2, 2, 2 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::i8, format::yxfb,{ 2, 2, 2, 2 } }); std::vector input_vec = { 1, 0, 5, 1, @@ -1321,7 +1315,7 @@ TEST(activation_i8_fw_gpu, basic_yxfb_all_funcs) for (auto func : funcs) { topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(activation("activation", "input", func)); network network(engine, topology); @@ -1332,14 +1326,12 @@ TEST(activation_i8_fw_gpu, basic_yxfb_all_funcs) EXPECT_EQ(outputs.begin()->first, "activation"); auto output_memory = outputs.at("activation").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); - auto input_ptr = input.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); + cldnn::mem_lock input_ptr(input, get_test_stream()); - for (size_t i = 0; i < output_layout.get_linear_size(); ++i) - { - switch (func) - { + for (size_t i = 0; i < output_layout.get_linear_size(); ++i) { + switch (func) { case activation_func::none: EXPECT_EQ((int8_t)input_ptr[i], output_ptr[i]); break; @@ -1356,10 +1348,9 @@ TEST(activation_i8_fw_gpu, basic_yxfb_all_funcs) } } -TEST(activation_i32_fw_gpu, basic_yxfb_i32_funcs) -{ - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::i32, format::yxfb,{ 2, 2, 2, 2 } }); +TEST(activation_i32_fw_gpu, basic_yxfb_i32_funcs) { + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::i32, format::yxfb,{ 2, 2, 2, 2 } }); std::vector input_vec = { 1, 0, 5, 1, @@ -1378,11 +1369,10 @@ TEST(activation_i32_fw_gpu, basic_yxfb_i32_funcs) activation_func::clamp }; - for (auto func : funcs) - { + for (auto func : funcs) { topology topology; activation_additional_params params = {0.0, 1.0}; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(activation("activation", "input", func, params)); network network(engine, topology); @@ -1393,14 +1383,12 @@ TEST(activation_i32_fw_gpu, basic_yxfb_i32_funcs) EXPECT_EQ(outputs.begin()->first, "activation"); auto output_memory = outputs.at("activation").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); - auto input_ptr = input.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); + cldnn::mem_lock input_ptr(input, get_test_stream()); - for (size_t i = 0; i < output_layout.get_linear_size(); ++i) - { - switch (func) - { + for (size_t i = 0; i < output_layout.get_linear_size(); ++i) { + switch (func) { case activation_func::none: EXPECT_EQ((int32_t)input_ptr[i], output_ptr[i]); break; @@ -1429,13 +1417,13 @@ TEST(activation_f32_fw_gpu, b_fs_yx_fsv16_prelu) { constexpr int x = 2; constexpr int y = 2; - auto eng = get_test_engine(); + auto& eng = get_test_engine(); auto in_lay = cldnn::layout(cldnn::data_types::f32, cldnn::format::bfyx, cldnn::tensor(b, f, x, y)); auto params_lay = cldnn::layout(cldnn::data_types::f32, cldnn::format::bfyx, cldnn::tensor(1, f, 1, 1)); - auto in_mem = cldnn::memory::allocate(eng, in_lay); - auto params_mem = cldnn::memory::allocate(eng, params_lay); + auto in_mem = eng.allocate_memory(in_lay); + auto params_mem = eng.allocate_memory(params_lay); auto in_data = generate_random_4d(b, f, y, x, -1, 1); auto params_data = generate_random_1d(f, -1, 1); @@ -1464,7 +1452,7 @@ TEST(activation_f32_fw_gpu, b_fs_yx_fsv16_prelu) { } } - auto out_ptr = out_mem.pointer(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); ASSERT_EQ(expected.size(), out_ptr.size()); for (size_t i = 0; i < expected.size(); ++i) { diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/add_reorders_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/add_reorders_gpu_test.cpp index b9e26b77b94eb1..e8c18919b8428e 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/add_reorders_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/add_reorders_gpu_test.cpp @@ -2,26 +2,19 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include -#include -#include -#include "test_utils/test_utils.h" -#include -#include -#include -#include -#include -#include -#include - -#include +#include "test_utils.h" + +#include +#include +#include +#include +#include +#include +#include +#include using namespace cldnn; -using namespace tests; +using namespace ::tests; /* These tests are inteded to check if additional reorders are being added properly during @@ -30,20 +23,20 @@ add_reorders optimization pass. //concatenation of incompatible convolutions TEST(add_reorders_gpu, two_convolutions_and_concatenation) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); build_options build_opt; build_opt.set_option(build_option::optimize_data(false)); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 1, 2, 2 } }); - auto weights1 = memory::allocate(engine, { data_types::f32, format::yxio,{ 1, 1, 1, 2 } }); - auto weights2 = memory::allocate(engine, { data_types::f32, format::oiyx,{ 1, 1, 1, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 1, 2, 2 } }); + auto weights1 = engine.allocate_memory({ data_types::f32, format::yxio,{ 1, 1, 1, 2 } }); + auto weights2 = engine.allocate_memory({ data_types::f32, format::oiyx,{ 1, 1, 1, 2 } }); set_values(input, { 1.1f, 1.2f, 1.3f, 1.4f }); set_values(weights1, { 2.1f, 3.1f}); set_values(weights2, { 1.1f, 0.1f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("weights1", weights1)); topology.add(data("weights2", weights2)); @@ -63,23 +56,18 @@ TEST(add_reorders_gpu, two_convolutions_and_concatenation) { float expected_out[] = { 6.34f, 1.34f, 6.86f, 1.46f }; float epsilon = 1e-3f; - for (auto& it : outputs) - { - auto output = it.second.get_memory().pointer(); - for (size_t cntr = 0; cntr < 2 * 2; cntr++) - { + for (auto& it : outputs) { + cldnn::mem_lock output(it.second.get_memory(), get_test_stream()); + for (size_t cntr = 0; cntr < 2 * 2; cntr++) { EXPECT_NEAR(expected_out[cntr], output[cntr], epsilon); } } } template -void tile_ref(const memory& input, memory& output, tile::tile_axis axis, int num_tiles) -{ - auto get_sizes = [](const tensor& size, tile::tile_axis axis) -> std::pair - { - switch (axis) - { +void tile_ref(const memory::ptr input, memory::ptr output, tile::tile_axis axis, int num_tiles) { + auto get_sizes = [](const tensor& size, tile::tile_axis axis) -> std::pair { + switch (axis) { case tile::along_b: return std::make_pair(1, size.batch[0] * size.feature[0] * size.spatial[2] * size.spatial[1] * size.spatial[0]); case tile::along_f: return std::make_pair(size.batch[0], size.feature[0] * size.spatial[2] * size.spatial[1] * size.spatial[0]); case tile::along_z: return std::make_pair(size.batch[0] * size.feature[0], size.spatial[2] * size.spatial[1] * size.spatial[0]); @@ -89,22 +77,19 @@ void tile_ref(const memory& input, memory& output, tile::tile_axis axis, int num } }; - const pointer src = input.pointer(); - pointer dst = output.pointer(); + cldnn::mem_lock src(input, get_test_stream()); + cldnn::mem_lock dst(output, get_test_stream()); const data_t* psrc = src.data(); data_t* pdst = dst.data(); - auto sizes = get_sizes(input.get_layout().size, axis); + auto sizes = get_sizes(input->get_layout().size, axis); int outer_dim = sizes.first; int inner_dim = sizes.second; - for (int i = 0; i < outer_dim; i++) - { - for (int t = 0; t < num_tiles; t++) - { - for (int j = 0; j < inner_dim; j++) - { + for (int i = 0; i < outer_dim; i++) { + for (int t = 0; t < num_tiles; t++) { + for (int j = 0; j < inner_dim; j++) { pdst[j] = psrc[j]; } pdst += inner_dim; @@ -114,13 +99,13 @@ void tile_ref(const memory& input, memory& output, tile::tile_axis axis, int num } TEST(add_reorders_gpu, basic_reshape_and_tile) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::byxf,{ 1, 2, 2, 1 } }); - auto output_ref = memory::allocate(engine, { data_types::f32, format::byxf,{ 2, 1, 4, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::byxf,{ 1, 2, 2, 1 } }); + auto output_ref = engine.allocate_memory({ data_types::f32, format::byxf,{ 2, 1, 4, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reshape("reshape", "input", tensor(2, 1, 2, 1))); topology.add(tile("tile", "reshape", tensor(2, 1, 2, 4))); @@ -136,10 +121,10 @@ TEST(add_reorders_gpu, basic_reshape_and_tile) { auto outputs = network.execute(); auto output = outputs.at("tile").get_memory(); - auto output_ptr = output.pointer(); - auto output_ref_ptr = output_ref.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + cldnn::mem_lock output_ref_ptr(output_ref, get_test_stream()); - for (unsigned int i = 0; i < output_ref.count(); ++i) { + for (unsigned int i = 0; i < output_ref->count(); ++i) { EXPECT_EQ(output_ptr[i], output_ref_ptr[i]); } } diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/arg_max_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/arg_max_gpu_test.cpp index ac1dacfe4e325a..d7b4b630201304 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/arg_max_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/arg_max_gpu_test.cpp @@ -2,32 +2,27 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include "api/memory.hpp" -#include -#include "api/arg_max_min.hpp" -#include -#include -#include -#include -#include -#include "test_utils/test_utils.h" +#include "test_utils.h" + +#include +#include +#include +#include using namespace cldnn; -using namespace tests; +using namespace ::tests; template -void generic_arg_max_test_xyf(int input_b, int input_f, int input_y, int input_x, arg_max_min::out_type mode, bool expect_throw = false) -{ +void generic_arg_max_test_xyf(int input_b, int input_f, int input_y, int input_x, arg_max_min::out_type mode, bool expect_throw = false) { auto axis = arg_max_min::axis_name::xyf; auto sort_type = arg_max_min::sort_type::sort_by_values; auto test_input_fmt = format::bfyx; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); tensor input_tensor(input_b, input_f, input_x, input_y); - auto input = memory::allocate(engine, { type_to_data_type::value, test_input_fmt, input_tensor }); + auto input = engine.allocate_memory({ type_to_data_type::value, test_input_fmt, input_tensor }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(arg_max_min("arg_max", { "input" }, mode, 1U, axis, sort_type, false, padding(), type_to_data_type::value)); int min_random = -2, max_random = 2; @@ -51,12 +46,12 @@ void generic_arg_max_test_xyf(int input_b, int input_f, int input_y, int input_x int out_size = input_x * input_y * input_f; auto output = outputs.at("arg_max").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); Tout index; Tin value; for (auto i = 0; i < input_b; i++) { - index = get_value(output_ptr, i); + index = get_value(output_ptr.data(), i); EXPECT_GE(index, (Tout)0); EXPECT_LT(index, (Tout)out_size); value = input_rnd_vec[i*out_size + (int)index]; @@ -74,11 +69,11 @@ void generic_arg_max_test_xyf(int input_b, int input_f, int input_y, int input_x TEST(arg_max_gpu_batch_one, base) { // Input : 2x3x2x2 static const int32_t x_size = 2, y_size = 2, feature_num = 5, batch_num = 1, top_k = 8; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ batch_num, feature_num, x_size , y_size } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ batch_num, feature_num, x_size , y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(arg_max_min("arg_max", { "input" }, arg_max_min::max, top_k)); std::vector input_vec = { @@ -100,11 +95,10 @@ TEST(arg_max_gpu_batch_one, base) { EXPECT_EQ(outputs.begin()->first, "arg_max"); auto output = outputs.at("arg_max").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float out_buffer[batch_num * top_k]; - for (uint32_t i = 0; i < batch_num * top_k; i++) - { - out_buffer[i] = get_value(output_ptr, i); + for (uint32_t i = 0; i < batch_num * top_k; i++) { + out_buffer[i] = get_value(output_ptr.data(), i); } int size = x_size * y_size * feature_num; int index; @@ -123,8 +117,7 @@ TEST(arg_max_gpu_batch_one, base) { } else amount += same_values * (j - same_values + 1); - } - else if (input_vec[i*size + (int)out_buffer[i*top_k + j]] != input_vec[i*size + (int)out_buffer[i*top_k + j + 1]]) { + } else if (input_vec[i*size + (int)out_buffer[i*top_k + j]] != input_vec[i*size + (int)out_buffer[i*top_k + j + 1]]) { if (same_values != j + 1) { amount += same_values * (j - same_values + 1); same_values = 1; @@ -135,12 +128,10 @@ TEST(arg_max_gpu_batch_one, base) { } EXPECT_GE(out_buffer[i*top_k + top_k - 1], 0); EXPECT_LT(out_buffer[i*top_k + top_k - 1], size); - for (int j = 0; j < top_k; j++) - { + for (int j = 0; j < top_k; j++) { index = (int)out_buffer[i*top_k + j]; value = input_vec[i*size + index]; - for (int k = 0; k < size; k++) - { + for (int k = 0; k < size; k++) { if (input_vec[i*size + k] > value) count++; } @@ -152,11 +143,11 @@ TEST(arg_max_gpu_batch_one, base) { TEST(arg_max_gpu_top_k, base) { // Input : 2x3x2x2 static const int32_t x_size = 2, y_size = 2, feature_num = 5, batch_num = 2; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int top_k = 8; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ batch_num, feature_num, x_size , y_size } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ batch_num, feature_num, x_size , y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(arg_max_min("arg_max", { "input" }, arg_max_min::max, top_k)); std::vector input_vec = { @@ -184,11 +175,10 @@ TEST(arg_max_gpu_top_k, base) { EXPECT_EQ(outputs.begin()->first, "arg_max"); auto output = outputs.at("arg_max").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float out_buffer[batch_num * top_k]; - for (uint32_t i = 0; i < batch_num * top_k; i++) - { - out_buffer[i] = get_value(output_ptr, i); + for (uint32_t i = 0; i < batch_num * top_k; i++) { + out_buffer[i] = get_value(output_ptr.data(), i); } int size = x_size * y_size * feature_num; int index; @@ -207,24 +197,21 @@ TEST(arg_max_gpu_top_k, base) { } else amount += same_values * (j - same_values + 1); - } - else if (input_vec[i*size + (int)(int)out_buffer[i*top_k + j]] != input_vec[i*size + (int)(int)out_buffer[i*top_k + j + 1]]) { + } else if (input_vec[i*size + (int)(int)out_buffer[i*top_k + j]] != input_vec[i*size + (int)(int)out_buffer[i*top_k + j + 1]]) { if (same_values != j+1) { amount += same_values * (j - same_values + 1); same_values = 1; } - } - else + } else { same_values++; + } } EXPECT_GE(out_buffer[i*top_k + top_k - 1], 0); EXPECT_LT(out_buffer[i*top_k + top_k - 1], size); - for (int j = 0; j < top_k; j++) - { + for (int j = 0; j < top_k; j++) { index = (int)out_buffer[i*top_k + j]; value = input_vec[i*size + index]; - for (int k = 0; k < size; k++) - { + for (int k = 0; k < size; k++) { if (input_vec[i*size + k] > value) count++; } @@ -236,11 +223,11 @@ TEST(arg_max_gpu_top_k, base) { TEST(arg_max_gpu_min_top_k, base) { // Input : 2x3x2x2 static const int32_t x_size = 2, y_size = 2, feature_num = 4, batch_num = 2; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int top_k = 3; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ batch_num, feature_num, x_size , y_size } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ batch_num, feature_num, x_size , y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(arg_max_min("arg_max", { "input" }, arg_max_min::min, top_k)); std::vector input_vec = { @@ -266,11 +253,10 @@ TEST(arg_max_gpu_min_top_k, base) { EXPECT_EQ(outputs.begin()->first, "arg_max"); auto output = outputs.at("arg_max").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float out_buffer[batch_num * top_k]; - for (uint32_t i = 0; i < batch_num * top_k; i++) - { - out_buffer[i] = get_value(output_ptr, i); + for (uint32_t i = 0; i < batch_num * top_k; i++) { + out_buffer[i] = get_value(output_ptr.data(), i); } int size = x_size * y_size * feature_num; int index; @@ -289,24 +275,21 @@ TEST(arg_max_gpu_min_top_k, base) { } else amount += same_values * (j - same_values + 1); - } - else if (input_vec[i*size + (int)out_buffer[i*top_k + j]] != input_vec[i*size + (int)out_buffer[i*top_k + j + 1]]) { + } else if (input_vec[i*size + (int)out_buffer[i*top_k + j]] != input_vec[i*size + (int)out_buffer[i*top_k + j + 1]]) { if (same_values != j + 1) { amount += same_values * (j - same_values + 1); same_values = 1; } - } - else + } else { same_values++; + } } EXPECT_GE(out_buffer[i*top_k + top_k - 1], 0); EXPECT_LT(out_buffer[i*top_k + top_k - 1], size); - for (int j = 0; j < top_k; j++) - { + for (int j = 0; j < top_k; j++) { index = (int)out_buffer[i*top_k + j]; value = input_vec[i*size + index]; - for (int k = 0; k < size; k++) - { + for (int k = 0; k < size; k++) { if (input_vec[i*size + k] < value) count++; } @@ -318,11 +301,11 @@ TEST(arg_max_gpu_min_top_k, base) { TEST(arg_max_gpu_min_axis_batch, base) { // Input : 2x3x2x2 static const int32_t x_size = 2, y_size = 2, feature_num = 4, batch_num = 2; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int top_k = 2; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ batch_num, feature_num, x_size , y_size } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ batch_num, feature_num, x_size , y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(arg_max_min("arg_max", { "input" }, arg_max_min::min, top_k, arg_max_min::batch)); std::vector input_vec = { @@ -348,14 +331,12 @@ TEST(arg_max_gpu_min_axis_batch, base) { EXPECT_EQ(outputs.begin()->first, "arg_max"); const int out_size = y_size * feature_num * x_size * top_k; auto output = outputs.at("arg_max").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float out_buffer[out_size]; - for (uint32_t i = 0; i < out_size; i++) - { - out_buffer[i] = get_value(output_ptr, i); + for (uint32_t i = 0; i < out_size; i++) { + out_buffer[i] = get_value(output_ptr.data(), i); } - for (int i = 0; i < out_size; i++) - { + for (int i = 0; i < out_size; i++) { EXPECT_EQ(out_buffer[i], i < (out_size / 2) ? 0 : 1); } } @@ -407,11 +388,11 @@ TEST(arg_max_gpu_min, i64) { TEST(arg_max_gpu_min_axis_batch, i32) { // Input : 2x3x2x2 static const int32_t x_size = 2, y_size = 2, feature_num = 4, batch_num = 2; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int top_k = 2; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ batch_num, feature_num, x_size , y_size } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ batch_num, feature_num, x_size , y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(arg_max_min("arg_max", { "input" }, arg_max_min::min, top_k, arg_max_min::batch, arg_max_min::sort_by_values, false, padding(), data_types::i32)); std::vector input_vec = { @@ -437,14 +418,12 @@ TEST(arg_max_gpu_min_axis_batch, i32) { EXPECT_EQ(outputs.begin()->first, "arg_max"); const int out_size = y_size * feature_num * x_size * top_k; auto output = outputs.at("arg_max").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); int32_t out_buffer[out_size]; - for (uint32_t i = 0; i < out_size; i++) - { - out_buffer[i] = get_value(output_ptr, i); + for (uint32_t i = 0; i < out_size; i++) { + out_buffer[i] = get_value(output_ptr.data(), i); } - for (int i = 0; i < out_size; i++) - { + for (int i = 0; i < out_size; i++) { EXPECT_EQ(out_buffer[i], i < (out_size / 2) ? 0 : 1); } } @@ -452,11 +431,11 @@ TEST(arg_max_gpu_min_axis_batch, i32) { TEST(arg_max_gpu_min_axis_batch_bfzyx, i32) { // Input : 2x3x2x2 static const int32_t x_size = 2, y_size = 2, z_size = 1, feature_num = 4, batch_num = 2; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int top_k = 2; - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ batch_num, feature_num, x_size , y_size, z_size } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx,{ batch_num, feature_num, x_size , y_size, z_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(arg_max_min("arg_max", { "input" }, arg_max_min::min, top_k, arg_max_min::batch, arg_max_min::sort_by_values, false, padding(), data_types::i32)); std::vector input_vec = { @@ -482,25 +461,23 @@ TEST(arg_max_gpu_min_axis_batch_bfzyx, i32) { EXPECT_EQ(outputs.begin()->first, "arg_max"); const int out_size = y_size * feature_num * x_size * top_k; auto output = outputs.at("arg_max").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); int32_t out_buffer[out_size]; - for (uint32_t i = 0; i < out_size; i++) - { - out_buffer[i] = get_value(output_ptr, i); + for (uint32_t i = 0; i < out_size; i++) { + out_buffer[i] = get_value(output_ptr.data(), i); } - for (int i = 0; i < out_size; i++) - { + for (int i = 0; i < out_size; i++) { EXPECT_EQ(out_buffer[i], i < (out_size / 2) ? 0 : 1); } } TEST(arg_max_gpu_min_axis_y_yxfb, f32) { static const int32_t x_size = 2, y_size = 2, feature_num = 4, batch_num = 2; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int top_k = 1; - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ batch_num, feature_num, x_size , y_size } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ batch_num, feature_num, x_size , y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(arg_max_min("arg_max", { "input" }, arg_max_min::max, top_k, arg_max_min::y, arg_max_min::sort_by_values, false, padding(), data_types::f32)); std::vector input_vec = { @@ -548,25 +525,23 @@ TEST(arg_max_gpu_min_axis_y_yxfb, f32) { EXPECT_EQ(outputs.begin()->first, "arg_max"); const int out_size = y_size * feature_num * x_size * top_k; auto output = outputs.at("arg_max").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float out_buffer[out_size]; - for (uint32_t i = 0; i < out_size; i++) - { - out_buffer[i] = get_value(output_ptr, i); + for (uint32_t i = 0; i < out_size; i++) { + out_buffer[i] = get_value(output_ptr.data(), i); } - for (int i = 0; i < out_size; i++) - { + for (int i = 0; i < out_size; i++) { EXPECT_EQ(out_buffer[i], ref_vec[i]); } } TEST(arg_max_gpu_min_axis_batch_yxfb, f32) { static const int32_t x_size = 2, y_size = 2, feature_num = 4, batch_num = 2; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int top_k = 1; - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ batch_num, feature_num, x_size , y_size } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ batch_num, feature_num, x_size , y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(arg_max_min("arg_max", { "input" }, arg_max_min::max, top_k, arg_max_min::batch, arg_max_min::sort_by_values, false, padding(), data_types::f32)); std::vector input_vec = { @@ -614,25 +589,23 @@ TEST(arg_max_gpu_min_axis_batch_yxfb, f32) { EXPECT_EQ(outputs.begin()->first, "arg_max"); const int out_size = y_size * feature_num * x_size * top_k; auto output = outputs.at("arg_max").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float out_buffer[out_size]; - for (uint32_t i = 0; i < out_size; i++) - { - out_buffer[i] = get_value(output_ptr, i); + for (uint32_t i = 0; i < out_size; i++) { + out_buffer[i] = get_value(output_ptr.data(), i); } - for (int i = 0; i < out_size; i++) - { + for (int i = 0; i < out_size; i++) { EXPECT_EQ(out_buffer[i], ref_vec[i]); } } TEST(arg_max_gpu_min_axis_y_yxfb_topk_2, f32) { static const int32_t x_size = 2, y_size = 2, feature_num = 4, batch_num = 2; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int top_k = 2; - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ batch_num, feature_num, x_size , y_size } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ batch_num, feature_num, x_size , y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(arg_max_min("arg_max", { "input" }, arg_max_min::max, top_k, arg_max_min::y, arg_max_min::sort_by_values, false, padding(), data_types::f32)); std::vector input_vec = { @@ -690,27 +663,25 @@ TEST(arg_max_gpu_min_axis_y_yxfb_topk_2, f32) { EXPECT_EQ(outputs.begin()->first, "arg_max"); const int out_size = y_size * feature_num * x_size * top_k; auto output = outputs.at("arg_max").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float out_buffer[out_size]; - for (uint32_t i = 0; i < out_size; i++) - { - out_buffer[i] = get_value(output_ptr, i); + for (uint32_t i = 0; i < out_size; i++) { + out_buffer[i] = get_value(output_ptr.data(), i); } - for (int i = 0; i < out_size; i++) - { + for (int i = 0; i < out_size; i++) { EXPECT_EQ(out_buffer[i], ref_vec[i]); } } TEST(top_k_layer_tests, second_output) { static const int32_t x_size = 2, y_size = 2, feature_num = 4, batch_num = 2; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int top_k = 2; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ batch_num, feature_num, x_size , y_size } }); - auto top_k_input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1 , 1 } }); - auto second_output = memory::allocate(engine, { data_types::f32, format::bfyx, { top_k, feature_num, x_size , y_size } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ batch_num, feature_num, x_size , y_size } }); + auto top_k_input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1 , 1 } }); + auto second_output = engine.allocate_memory({ data_types::f32, format::bfyx, { top_k, feature_num, x_size , y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(cldnn::data("const", top_k_input)); topology.add(mutable_data("second_output", second_output)); topology.add(arg_max_min("arg_max", { "input", "const", "second_output" }, arg_max_min::min, top_k, arg_max_min::batch)); @@ -738,17 +709,16 @@ TEST(top_k_layer_tests, second_output) { EXPECT_EQ(outputs.begin()->first, "arg_max"); const int out_size = y_size * feature_num * x_size * top_k; auto output = outputs.at("arg_max").get_memory(); - auto output_ptr = output.pointer(); - auto second_output_ptr = second_output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + cldnn::mem_lock second_output_ptr(second_output, get_test_stream()); + float out_buffer[out_size]; float second_out_buffer[out_size]; - for (uint32_t i = 0; i < out_size; i++) - { - out_buffer[i] = get_value(output_ptr, i); - second_out_buffer[i] = get_value(second_output_ptr, i); + for (uint32_t i = 0; i < out_size; i++) { + out_buffer[i] = get_value(output_ptr.data(), i); + second_out_buffer[i] = get_value(second_output_ptr.data(), i); } - for (int i = 0; i < out_size; i++) - { + for (int i = 0; i < out_size; i++) { EXPECT_EQ(out_buffer[i], i < (out_size / 2) ? 0 : 1); EXPECT_EQ(second_out_buffer[i], input_vec[i]); } @@ -756,13 +726,13 @@ TEST(top_k_layer_tests, second_output) { TEST(top_k_layer_tests, second_output2) { static const int32_t x_size = 2, y_size = 2, feature_num = 4, batch_num = 2; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int top_k = 1; - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ batch_num, feature_num, x_size , y_size } }); - auto top_k_input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1 , 1 } }); - auto second_output = memory::allocate(engine, { data_types::f32, format::yxfb, { top_k, feature_num, x_size , y_size } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ batch_num, feature_num, x_size , y_size } }); + auto top_k_input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1 , 1 } }); + auto second_output = engine.allocate_memory({ data_types::f32, format::yxfb, { top_k, feature_num, x_size , y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(cldnn::data("const", top_k_input)); topology.add(mutable_data("second_output", second_output)); topology.add(arg_max_min("arg_max", { "input", "const", "second_output" }, arg_max_min::max, top_k, arg_max_min::batch, arg_max_min::sort_by_values, false, padding(), data_types::f32)); @@ -834,17 +804,15 @@ TEST(top_k_layer_tests, second_output2) { EXPECT_EQ(outputs.begin()->first, "arg_max"); const int out_size = y_size * feature_num * x_size * top_k; auto output = outputs.at("arg_max").get_memory(); - auto output_ptr = output.pointer(); - auto second_output_ptr = second_output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + cldnn::mem_lock second_output_ptr(second_output, get_test_stream()); float out_buffer[out_size]; float second_out_buffer[out_size]; - for (uint32_t i = 0; i < out_size; i++) - { - out_buffer[i] = get_value(output_ptr, i); - second_out_buffer[i] = get_value(second_output_ptr, i); + for (uint32_t i = 0; i < out_size; i++) { + out_buffer[i] = get_value(output_ptr.data(), i); + second_out_buffer[i] = get_value(second_output_ptr.data(), i); } - for (int i = 0; i < out_size; i++) - { + for (int i = 0; i < out_size; i++) { EXPECT_EQ(out_buffer[i], ref_vec[i]); EXPECT_EQ(second_out_buffer[i], second_ref_vec[i]); } @@ -852,11 +820,11 @@ TEST(top_k_layer_tests, second_output2) { TEST(arg_max_gpu_min_axis_y_yxfb_topk_2, sort_by_values) { static const int32_t x_size = 2, y_size = 2, feature_num = 4, batch_num = 2; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int top_k = 2; - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ batch_num, feature_num, x_size , y_size } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ batch_num, feature_num, x_size , y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(arg_max_min("arg_max", { "input" }, arg_max_min::max, top_k, arg_max_min::y, arg_max_min::sort_by_values, false, padding(), data_types::f32)); std::vector input_vec = { @@ -914,25 +882,23 @@ TEST(arg_max_gpu_min_axis_y_yxfb_topk_2, sort_by_values) { EXPECT_EQ(outputs.begin()->first, "arg_max"); const int out_size = y_size * feature_num * x_size * top_k; auto output = outputs.at("arg_max").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float out_buffer[out_size]; - for (uint32_t i = 0; i < out_size; i++) - { - out_buffer[i] = get_value(output_ptr, i); + for (uint32_t i = 0; i < out_size; i++) { + out_buffer[i] = get_value(output_ptr.data(), i); } - for (int i = 0; i < out_size; i++) - { + for (int i = 0; i < out_size; i++) { EXPECT_EQ(out_buffer[i], ref_vec[i]); } } TEST(arg_max_gpu_min_axis_y_yxfb_topk_2, sort_by_indices) { static const int32_t x_size = 2, y_size = 2, feature_num = 4, batch_num = 2; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int top_k = 2; - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ batch_num, feature_num, x_size , y_size } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ batch_num, feature_num, x_size , y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(arg_max_min("arg_max", { "input" }, arg_max_min::max, top_k, arg_max_min::y, arg_max_min::sort_by_indices, false, padding(), data_types::f32)); std::vector input_vec = { @@ -990,14 +956,12 @@ TEST(arg_max_gpu_min_axis_y_yxfb_topk_2, sort_by_indices) { EXPECT_EQ(outputs.begin()->first, "arg_max"); const int out_size = y_size * feature_num * x_size * top_k; auto output = outputs.at("arg_max").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float out_buffer[out_size]; - for (uint32_t i = 0; i < out_size; i++) - { - out_buffer[i] = get_value(output_ptr, i); + for (uint32_t i = 0; i < out_size; i++) { + out_buffer[i] = get_value(output_ptr.data(), i); } - for (int i = 0; i < out_size; i++) - { + for (int i = 0; i < out_size; i++) { EXPECT_EQ(out_buffer[i], ref_vec[i]); } } diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/average_unpooling_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/average_unpooling_gpu_test.cpp index 01eafbde391ca0..7674100106094d 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/average_unpooling_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/average_unpooling_gpu_test.cpp @@ -2,23 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include "api/average_unpooling.hpp" -#include -#include -#include -#include "test_utils/test_utils.h" -#include -#include -#include -#include -#include "test_utils/float16.h" +#include "test_utils.h" + +#include +#include +#include +#include +#include +#include using namespace cldnn; -using namespace tests; +using namespace ::tests; TEST(average_unpooling_gpu, basic_in2x2x2x1) { // Input : 2x2x2x1 @@ -40,9 +34,9 @@ TEST(average_unpooling_gpu, basic_in2x2x2x1) { // f1: b0: 1.5 2.5 1 b1: 1.75 2.9375 1.1875 // f1: b0: 1.5 2.5 1 b1: 1.75 2.9375 1.1875 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 1 } }); set_values(input, { 2.5f, -4.5f, @@ -52,7 +46,7 @@ TEST(average_unpooling_gpu, basic_in2x2x2x1) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(average_unpooling("average_unpooling", "input", { 2, 2, 3, 2 }, { 1, 1, 2, 2 }, { 1, 1, 1, 1 })); network network(engine, topology); @@ -62,8 +56,8 @@ TEST(average_unpooling_gpu, basic_in2x2x2x1) { auto outputs = network.execute(); auto output = outputs.at("average_unpooling").get_memory(); - auto output_ptr = output.pointer(); - auto output_layout = output.get_layout(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + auto output_layout = output->get_layout(); EXPECT_EQ(output_layout.format, format::bfyx); EXPECT_EQ(output_layout.size.spatial[1], 2); @@ -107,9 +101,9 @@ TEST(average_unpooling_gpu, basic_in2x2x3x2_with_average_pooling_unpooling) { // f1: b0: 1.5 1.5 0.5 b1: 1.75 1.75 1 // f1: b0: 1.5 1.5 0.5 b1: 1.75 1.75 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 3, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 3, 2 } }); set_values(input, { 1.f, 2.f, -10.f, @@ -123,9 +117,9 @@ TEST(average_unpooling_gpu, basic_in2x2x3x2_with_average_pooling_unpooling) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(pooling("pooling", "input", pooling_mode::average_no_padding, { 1, 1, 2, 2 }, { 1, 1, 2, 2 })); - topology.add(average_unpooling("average_unpooling", "pooling", input.get_layout().size, { 1, 1, 2, 2 }, { 1, 1, 2, 2 })); + topology.add(average_unpooling("average_unpooling", "pooling", input->get_layout().size, { 1, 1, 2, 2 }, { 1, 1, 2, 2 })); network network(engine, topology); @@ -134,8 +128,8 @@ TEST(average_unpooling_gpu, basic_in2x2x3x2_with_average_pooling_unpooling) { auto outputs = network.execute(); auto output = outputs.at("average_unpooling").get_memory(); - auto output_ptr = output.pointer(); - auto output_layout = output.get_layout(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + auto output_layout = output->get_layout(); EXPECT_EQ(output_layout.format, format::bfyx); EXPECT_EQ(output_layout.size.spatial[1], 2); @@ -179,9 +173,9 @@ TEST(average_unpooling_gpu, basic_in2x2x2x1_output_padding) { // f0: b0: 0.625 -0.5 -1.125 b1: 0 -1.6875 -1.6875 // f1: b0: 1.5 2.5 1 b1: 1.75 2.9375 1.1875 // f1: b0: 1.5 2.5 1 b1: 1.75 2.9375 1.1875 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); set_values(input, { 2.5f, -4.5f, @@ -191,7 +185,7 @@ TEST(average_unpooling_gpu, basic_in2x2x2x1_output_padding) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(average_unpooling("average_unpooling", "input", { 2, 2, 3, 2 }, { 1, 1, 2, 2 }, { 1, 1, 1, 1 }, padding({ 0, 0, 1, 1 }, 0))); network network(engine, topology); @@ -201,8 +195,8 @@ TEST(average_unpooling_gpu, basic_in2x2x2x1_output_padding) { auto outputs = network.execute(); auto output = outputs.at("average_unpooling").get_memory(); - auto output_ptr = output.pointer(); - auto output_layout = output.get_layout(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + auto output_layout = output->get_layout(); EXPECT_EQ(output_layout.format, format::bfyx); EXPECT_EQ(output_layout.size.spatial[1], 2); @@ -260,9 +254,9 @@ TEST(average_unpooling_gpu, basic_in2x2x2x1_fp16) { // f1: b0: 1.5 2.5 1 b1: 1.75 2.9375 1.1875 // f1: b0: 1.5 2.5 1 b1: 1.75 2.9375 1.1875 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f16, format::bfyx,{ 2, 2, 2, 1 } }); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx,{ 2, 2, 2, 1 } }); set_values(input, { FLOAT16(2.5f), FLOAT16(-4.5f), @@ -272,7 +266,7 @@ TEST(average_unpooling_gpu, basic_in2x2x2x1_fp16) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(average_unpooling("average_unpooling", "input", { 2, 2, 3, 2 }, { 1, 1, 2, 2 }, { 1, 1, 1, 1 })); network network(engine, topology); @@ -282,8 +276,8 @@ TEST(average_unpooling_gpu, basic_in2x2x2x1_fp16) { auto outputs = network.execute(); auto output = outputs.at("average_unpooling").get_memory(); - auto output_ptr = output.pointer(); - auto output_layout = output.get_layout(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + auto output_layout = output->get_layout(); EXPECT_EQ(output_layout.format, format::bfyx); EXPECT_EQ(output_layout.size.spatial[1], 2); @@ -304,4 +298,4 @@ TEST(average_unpooling_gpu, basic_in2x2x2x1_fp16) { for (size_t i = 0; i < expected_output_vec.size(); ++i) { EXPECT_EQ(expected_output_vec[i], float16_to_float32(output_ptr[i])); } -} \ No newline at end of file +} diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/barriers_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/barriers_test.cpp index 2b15da70ed271c..2b72881c6180d3 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/barriers_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/barriers_test.cpp @@ -2,28 +2,21 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// +#include "test_utils.h" -#include -#include -#include -#include -#include -#include -#include -#include - -#include "test_utils/test_utils.h" +#include +#include +#include using namespace cldnn; -using namespace tests; +using namespace ::tests; TEST(DISABLED_oooq_test, simple) { - engine_configuration cfg{ false, false, false, std::string(), std::string(), true }; - engine eng{ cfg }; + engine_configuration cfg{ false, queue_types::out_of_order }; + auto eng = engine::create(engine_types::ocl, runtime_types::ocl, cfg); - memory input_mem = memory::allocate(eng, layout{ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto input_mem = eng->allocate_memory(layout{ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input_mem, { 50 }); /* ---- r1 ---- r3 ---- -- r7 -- @@ -34,16 +27,16 @@ TEST(DISABLED_oooq_test, simple) */ topology tpl; - tpl.add(input_layout("in", input_mem.get_layout())); - tpl.add(reorder("r0", "in", input_mem.get_layout(), std::vector{ 0 })); - tpl.add(reorder("r1", "r0", input_mem.get_layout(), std::vector{ 1 })); - tpl.add(reorder("r2", "r0", input_mem.get_layout(), std::vector{ 2 })); - tpl.add(reorder("r3", "r1", input_mem.get_layout(), std::vector{ 3 })); - tpl.add(reorder("r4", "r2", input_mem.get_layout(), std::vector{ 4 })); - tpl.add(reorder("r5", "r4", input_mem.get_layout(), std::vector{ 5 })); + tpl.add(input_layout("in", input_mem->get_layout())); + tpl.add(reorder("r0", "in", input_mem->get_layout(), std::vector{ 0 })); + tpl.add(reorder("r1", "r0", input_mem->get_layout(), std::vector{ 1 })); + tpl.add(reorder("r2", "r0", input_mem->get_layout(), std::vector{ 2 })); + tpl.add(reorder("r3", "r1", input_mem->get_layout(), std::vector{ 3 })); + tpl.add(reorder("r4", "r2", input_mem->get_layout(), std::vector{ 4 })); + tpl.add(reorder("r5", "r4", input_mem->get_layout(), std::vector{ 5 })); tpl.add(concatenation("c6", { "r3", "r5" }, concatenation::along_x)); - layout concat_lay = input_mem.get_layout(); + layout concat_lay = input_mem->get_layout(); concat_lay.size.spatial[0] *= 2; tpl.add(reorder("r7", "c6", concat_lay, std::vector{ 7 })); @@ -52,13 +45,13 @@ TEST(DISABLED_oooq_test, simple) concat_lay.size.spatial[1] *= 2; build_options options; - network net{ eng, tpl, options }; + network net{ *eng, tpl, options }; net.set_input_data("in", input_mem); auto output = net.execute().at("c9").get_memory(); - EXPECT_TRUE(output.get_layout().size.spatial[0] == 2); - EXPECT_TRUE(output.get_layout().size.spatial[1] == 2); - EXPECT_TRUE(output.get_layout().size.feature[0] == 1); - EXPECT_TRUE(output.get_layout().size.batch[0] == 1); -} \ No newline at end of file + EXPECT_TRUE(output->get_layout().size.spatial[0] == 2); + EXPECT_TRUE(output->get_layout().size.spatial[1] == 2); + EXPECT_TRUE(output->get_layout().size.feature[0] == 1); + EXPECT_TRUE(output->get_layout().size.batch[0] == 1); +} diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/batch_to_space_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/batch_to_space_gpu_test.cpp index 9299820f8ce448..e3d33ad250765f 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/batch_to_space_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/batch_to_space_gpu_test.cpp @@ -2,18 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include +#include "test_utils.h" -#include -#include -#include -#include -#include -#include +#include +#include +#include #include -#include using namespace cldnn; using namespace ::tests; @@ -26,9 +21,9 @@ TEST(batch_to_space_fp16_gpu, i8111_bs1222_cb0000_ce0000) { // Output : 1x2x2x2 // Input values in fp16 - engine engine; + auto& engine = get_test_engine(); tensor input_shape = tensor{batch(8), feature(1), spatial(1, 1)}; - auto input = memory::allocate(engine, { data_types::f16, format::bfyx, input_shape }); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx, input_shape }); set_values(input, { FLOAT16(0.0f), FLOAT16(1.0f), @@ -38,7 +33,7 @@ TEST(batch_to_space_fp16_gpu, i8111_bs1222_cb0000_ce0000) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(batch_to_space("batch_to_space", "Input", tensor(format::bfyx, {1,2,2,2}, 1), tensor(format::bfyx, {0,0,0,0}, 0), tensor(format::bfyx, {0,0,0,0}, 0), @@ -50,7 +45,7 @@ TEST(batch_to_space_fp16_gpu, i8111_bs1222_cb0000_ce0000) { auto outputs = network.execute(); auto output = outputs.at("batch_to_space").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f @@ -71,9 +66,9 @@ TEST(batch_to_space_fp16_gpu, i4321_bs1212_cb0000_ce0000) { // Output : 1x6x2x2 // Input values in fp16 - engine engine; + auto& engine = get_test_engine(); tensor input_shape = tensor{batch(4), feature(3), spatial(1, 2)}; - auto input = memory::allocate(engine, { data_types::f16, format::bfyx, input_shape }); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx, input_shape }); set_values(input, { FLOAT16(0.0f), FLOAT16(1.0f), FLOAT16(2.0f), FLOAT16(3.0f), @@ -85,7 +80,7 @@ TEST(batch_to_space_fp16_gpu, i4321_bs1212_cb0000_ce0000) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(batch_to_space("batch_to_space", "Input", tensor(format::bfyx, {1,2,1,2}, 1), tensor(format::bfyx, {0,0,0,0}, 0), tensor(format::bfyx, {0,0,0,0}, 0), @@ -97,7 +92,7 @@ TEST(batch_to_space_fp16_gpu, i4321_bs1212_cb0000_ce0000) { auto outputs = network.execute(); auto output = outputs.at("batch_to_space").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 6.f, 1.f, 7.f, 12.f, 18.f, @@ -121,9 +116,9 @@ TEST(batch_to_space_fp16_gpu, i4321_bs1212_cb0010_ce0101) { // Output : 1x5x1x1 // Input values in fp16 - engine engine; + auto& engine = get_test_engine(); tensor input_shape = tensor{batch(4), feature(3), spatial(1, 2)}; - auto input = memory::allocate(engine, { data_types::f16, format::bfyx, input_shape }); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx, input_shape }); set_values(input, { FLOAT16(0.0f), FLOAT16(1.0f), FLOAT16(2.0f), FLOAT16(3.0f), @@ -135,7 +130,7 @@ TEST(batch_to_space_fp16_gpu, i4321_bs1212_cb0010_ce0101) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(batch_to_space("batch_to_space", "Input", tensor(format::bfyx, {1,2,1,2}, 1), tensor(format::bfyx, {0,0,1,0}, 0), tensor(format::bfyx, {0,1,0,1}, 0), @@ -147,7 +142,7 @@ TEST(batch_to_space_fp16_gpu, i4321_bs1212_cb0010_ce0101) { auto outputs = network.execute(); auto output = outputs.at("batch_to_space").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 1.f, 13.f, 3.f, 15.f, 5.f @@ -168,9 +163,9 @@ TEST(batch_to_space_fp16_gpu, i62121_bs12311_cb02000_ce00110) { // Output : 1x2x2x1x1 // Input values in fp16 - engine engine; + auto& engine = get_test_engine(); tensor input_shape = tensor{batch(6), feature(2), spatial(1, 2, 1)}; - auto input = memory::allocate(engine, { data_types::f16, format::bfzyx, input_shape }); + auto input = engine.allocate_memory({ data_types::f16, format::bfzyx, input_shape }); set_values(input, { FLOAT16(0.0f), FLOAT16(1.0f), FLOAT16(2.0f), FLOAT16(3.0f), @@ -182,7 +177,7 @@ TEST(batch_to_space_fp16_gpu, i62121_bs12311_cb02000_ce00110) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(batch_to_space("batch_to_space", "Input", tensor(format::bfzyx, {1,2,3,1,1}, 1), tensor(format::bfzyx, {0,2,0,0,0}, 0), tensor(format::bfzyx, {0,0,1,1,0}, 0), @@ -194,7 +189,7 @@ TEST(batch_to_space_fp16_gpu, i62121_bs12311_cb02000_ce00110) { auto outputs = network.execute(); auto output = outputs.at("batch_to_space").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 2.f, 6.f, 14.f, 18.f @@ -215,9 +210,9 @@ TEST(batch_to_space_fp16_gpu, i1212112_bs112321_cb02000_ce00110) { // Output : 1x1x3x1x2x2 // Input values in fp16 - engine engine; + auto& engine = get_test_engine(); tensor input_shape = tensor{batch(12), feature(1), spatial(2, 1, 1, 2)}; - auto input = memory::allocate(engine, { data_types::f16, format::bfwzyx, input_shape }); + auto input = engine.allocate_memory({ data_types::f16, format::bfwzyx, input_shape }); set_values(input, { FLOAT16(0.0f), FLOAT16(1.0f), FLOAT16(2.0f), FLOAT16(3.0f), @@ -231,7 +226,7 @@ TEST(batch_to_space_fp16_gpu, i1212112_bs112321_cb02000_ce00110) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(batch_to_space("batch_to_space", "Input", tensor(format::bfwzyx, {1,1,2,3,2,1}, 1), tensor(format::bfwzyx, {0,0,1,0,0,0}, 0), tensor(format::bfwzyx, {0,0,0,2,0,0}, 0), @@ -243,7 +238,7 @@ TEST(batch_to_space_fp16_gpu, i1212112_bs112321_cb02000_ce00110) { auto outputs = network.execute(); auto output = outputs.at("batch_to_space").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 24.f, 25.f, 28.f, 29.f, @@ -266,9 +261,9 @@ TEST(batch_to_space_fp16_gpu, i21611_bs1112_cb0000_ce0000_b_fs_yx_fsv16) { // Output : 1x16x1x2 // Input values in fp16 - engine engine; + auto& engine = get_test_engine(); tensor input_shape = tensor{batch(2), feature(16), spatial(1, 1)}; - auto input = memory::allocate(engine, { data_types::f16, format::bfyx, input_shape }); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx, input_shape }); set_values(input, { FLOAT16(0.0f), FLOAT16(1.0f), FLOAT16(2.0f), FLOAT16(3.0f), FLOAT16(4.0f), FLOAT16(5.0f), FLOAT16(6.0f), FLOAT16(7.0f), @@ -278,7 +273,7 @@ TEST(batch_to_space_fp16_gpu, i21611_bs1112_cb0000_ce0000_b_fs_yx_fsv16) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(reorder("input_fsv", "Input", format::b_fs_yx_fsv16, data_types::f16)); topology.add(batch_to_space("batch_to_space", "input_fsv", tensor(format::bfyx, {1,1,1,2}, 1), tensor(format::bfyx, {0,0,0,0}, 0), @@ -293,7 +288,7 @@ TEST(batch_to_space_fp16_gpu, i21611_bs1112_cb0000_ce0000_b_fs_yx_fsv16) { auto outputs = network.execute(); auto output = outputs.at("bts_to_bfyx").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 16.f, 1.f, 17.f, 2.f, 18.f, 3.f, 19.f, @@ -317,9 +312,9 @@ TEST(batch_to_space_fp16_gpu, i2812_bs1112_cb0000_ce0000_b_fs_yx_fsv16) { // Output : 1x6x1x4 // Input values in fp16 - engine engine; + auto& engine = get_test_engine(); tensor input_shape = tensor{batch(2), feature(8), spatial(2, 1)}; - auto input = memory::allocate(engine, { data_types::f16, format::bfyx, input_shape }); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx, input_shape }); set_values(input, { FLOAT16(0.0f), FLOAT16(1.0f), FLOAT16(2.0f), FLOAT16(3.0f), FLOAT16(4.0f), FLOAT16(5.0f), FLOAT16(6.0f), FLOAT16(7.0f), @@ -329,7 +324,7 @@ TEST(batch_to_space_fp16_gpu, i2812_bs1112_cb0000_ce0000_b_fs_yx_fsv16) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(reorder("input_fsv", "Input", format::b_fs_yx_fsv16, data_types::f16)); topology.add(batch_to_space("batch_to_space", "input_fsv", tensor(format::bfyx, {1,1,1,2}, 1), tensor(format::bfyx, {0,2,0,0}, 0), @@ -344,7 +339,7 @@ TEST(batch_to_space_fp16_gpu, i2812_bs1112_cb0000_ce0000_b_fs_yx_fsv16) { auto outputs = network.execute(); auto output = outputs.at("bts_to_bfyx").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 4.f, 20.f, 5.f, 21.f, 6.f, 22.f, 7.f, 23.f, @@ -367,9 +362,9 @@ TEST(batch_to_space_fp32_gpu, i8111_bs1222_cb0000_ce0000) { // Output : 1x2x2x2 // Input values in fp32 - engine engine; + auto& engine = get_test_engine(); tensor input_shape = tensor{batch(8), feature(1), spatial(1, 1)}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, input_shape }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, input_shape }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, @@ -377,7 +372,7 @@ TEST(batch_to_space_fp32_gpu, i8111_bs1222_cb0000_ce0000) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(batch_to_space("batch_to_space", "Input", tensor(format::bfyx, {1,2,2,2}, 1), tensor(format::bfyx, {0,0,0,0}, 0), tensor(format::bfyx, {0,0,0,0}, 0), @@ -389,7 +384,7 @@ TEST(batch_to_space_fp32_gpu, i8111_bs1222_cb0000_ce0000) { auto outputs = network.execute(); auto output = outputs.at("batch_to_space").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f @@ -410,9 +405,9 @@ TEST(batch_to_space_fp32_gpu, i4321_bs1212_cb0000_ce0000) { // Output : 1x6x2x2 // Input values in fp32 - engine engine; + auto& engine = get_test_engine(); tensor input_shape = tensor{batch(4), feature(3), spatial(1, 2)}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, input_shape }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, input_shape }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, @@ -424,7 +419,7 @@ TEST(batch_to_space_fp32_gpu, i4321_bs1212_cb0000_ce0000) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(batch_to_space("batch_to_space", "Input", tensor(format::bfyx, {1,2,1,2}, 1), tensor(format::bfyx, {0,0,0,0}, 0), tensor(format::bfyx, {0,0,0,0}, 0), @@ -436,7 +431,7 @@ TEST(batch_to_space_fp32_gpu, i4321_bs1212_cb0000_ce0000) { auto outputs = network.execute(); auto output = outputs.at("batch_to_space").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 6.f, 1.f, 7.f, 12.f, 18.f, @@ -460,9 +455,9 @@ TEST(batch_to_space_fp32_gpu, i4321_bs1212_cb0010_ce0101) { // Output : 1x5x1x1 // Input values in fp32 - engine engine; + auto& engine = get_test_engine(); tensor input_shape = tensor{batch(4), feature(3), spatial(1, 2)}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, input_shape }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, input_shape }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, @@ -474,7 +469,7 @@ TEST(batch_to_space_fp32_gpu, i4321_bs1212_cb0010_ce0101) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(batch_to_space("batch_to_space", "Input", tensor(format::bfyx, {1,2,1,2}, 1), tensor(format::bfyx, {0,0,1,0}, 0), tensor(format::bfyx, {0,1,0,1}, 0), @@ -486,7 +481,7 @@ TEST(batch_to_space_fp32_gpu, i4321_bs1212_cb0010_ce0101) { auto outputs = network.execute(); auto output = outputs.at("batch_to_space").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 1.f, 13.f, 3.f, 15.f, 5.f @@ -507,9 +502,9 @@ TEST(batch_to_space_fp32_gpu, i62121_bs12311_cb02000_ce00110) { // Output : 1x2x2x1x1 // Input values in fp32 - engine engine; + auto& engine = get_test_engine(); tensor input_shape = tensor{batch(6), feature(2), spatial(1, 2, 1)}; - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx, input_shape }); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx, input_shape }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, @@ -521,7 +516,7 @@ TEST(batch_to_space_fp32_gpu, i62121_bs12311_cb02000_ce00110) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(batch_to_space("batch_to_space", "Input", tensor(format::bfzyx, {1,2,3,1,1}, 1), tensor(format::bfzyx, {0,2,0,0,0}, 0), tensor(format::bfzyx, {0,0,1,1,0}, 0), @@ -533,7 +528,7 @@ TEST(batch_to_space_fp32_gpu, i62121_bs12311_cb02000_ce00110) { auto outputs = network.execute(); auto output = outputs.at("batch_to_space").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 2.f, 6.f, 14.f, 18.f @@ -554,9 +549,9 @@ TEST(batch_to_space_fp32_gpu, i1212112_bs112321_cb02000_ce00110) { // Output : 1x1x3x1x2x2 // Input values in fp32 - engine engine; + auto& engine = get_test_engine(); tensor input_shape = tensor{batch(12), feature(1), spatial(2, 1, 1, 2)}; - auto input = memory::allocate(engine, { data_types::f32, format::bfwzyx, input_shape }); + auto input = engine.allocate_memory({ data_types::f32, format::bfwzyx, input_shape }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, @@ -570,7 +565,7 @@ TEST(batch_to_space_fp32_gpu, i1212112_bs112321_cb02000_ce00110) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(batch_to_space("batch_to_space", "Input", tensor(format::bfwzyx, {1,1,2,3,2,1}, 1), tensor(format::bfwzyx, {0,0,1,0,0,0}, 0), tensor(format::bfwzyx, {0,0,0,2,0,0}, 0), @@ -582,7 +577,7 @@ TEST(batch_to_space_fp32_gpu, i1212112_bs112321_cb02000_ce00110) { auto outputs = network.execute(); auto output = outputs.at("batch_to_space").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 24.f, 25.f, 28.f, 29.f, @@ -605,9 +600,9 @@ TEST(batch_to_space_fp32_gpu, i21621_bs1112_cb0201_ce0810_b_fs_yx_fsv16) { // Output : 1x6x1x1 // Input values in fp32 - engine engine; + auto& engine = get_test_engine(); tensor input_shape = tensor{batch(2), feature(16), spatial(1, 2)}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, input_shape }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, input_shape }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, @@ -621,7 +616,7 @@ TEST(batch_to_space_fp32_gpu, i21621_bs1112_cb0201_ce0810_b_fs_yx_fsv16) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(reorder("input_fsv", "Input", format::b_fs_yx_fsv16, data_types::f32)); topology.add(batch_to_space("batch_to_space", "input_fsv", tensor(format::bfyx, {1,1,1,2}, 1), tensor(format::bfyx, {0,2,0,1}, 0), @@ -636,7 +631,7 @@ TEST(batch_to_space_fp32_gpu, i21621_bs1112_cb0201_ce0810_b_fs_yx_fsv16) { auto outputs = network.execute(); auto output = outputs.at("bts_to_bfyx").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 36.0f, 38.0f, 40.0f, 42.0f, 44.0f, 46.0f @@ -657,9 +652,9 @@ TEST(batch_to_space_fp32_gpu, i41021_bs1221_cb0201_ce0810_b_fs_yx_fsv16) { // Output : 1x8x3x1 // Input values in fp32 - engine engine; + auto& engine = get_test_engine(); tensor input_shape = tensor{batch(4), feature(10), spatial(1, 2)}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, input_shape }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, input_shape }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, @@ -673,7 +668,7 @@ TEST(batch_to_space_fp32_gpu, i41021_bs1221_cb0201_ce0810_b_fs_yx_fsv16) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(reorder("input_fsv", "Input", format::b_fs_yx_fsv16, data_types::f32)); topology.add(batch_to_space("batch_to_space", "input_fsv", tensor(format::bfyx, {1,2,2,1}, 1), tensor(format::bfyx, {0,8,1,0}, 0), @@ -688,7 +683,7 @@ TEST(batch_to_space_fp32_gpu, i41021_bs1221_cb0201_ce0810_b_fs_yx_fsv16) { auto outputs = network.execute(); auto output = outputs.at("bts_to_bfyx").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 28.0f, 9.0f, 29.0f, 68.0f, 49.0f, 69.0f, diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/binary_convolution_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/binary_convolution_gpu_test.cpp index a5535f3239fc77..e0ac110a817a8b 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/binary_convolution_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/binary_convolution_gpu_test.cpp @@ -1,26 +1,18 @@ -// Copyright (C) 2018-2021 Intel Corporation +// Copyright (C) 2018-2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include "api/binary_convolution.hpp" -#include "api/reorder.hpp" -#include -#include -#include -#include "test_utils/test_utils.h" -#include -#include -#include -#include "float16.h" #include "test_utils.h" +#include +#include +#include +#include + +#include + using namespace cldnn; -using namespace tests; +using namespace ::tests; // Batch, groups, IC, IW, IH, OC, OW, OH, KH, KW, SH, SW, PH, PW struct TestParams { @@ -74,23 +66,23 @@ struct TestParams { } }; -static void fill(cldnn::memory& mem) { - auto ptr = mem.pointer(); - for (size_t i = 0; i < div_up(mem.get_layout().count(), 32); i++) { +static void fill(cldnn::memory::ptr mem) { + cldnn::mem_lock ptr(mem, get_test_stream()); + for (size_t i = 0; i < div_up(mem->get_layout().count(), 32); i++) { ptr[i] = (uint32_t)rand() % (1 << 31); } } template -void compute_ref_conv_bin(const cldnn::memory &src, - const cldnn::memory &weights, - cldnn::memory &dst, - TestParams &p) -{ - auto src_data = src.pointer(); - auto weights_data = weights.pointer(); - auto dst_data = dst.pointer(); +void compute_ref_conv_bin(const cldnn::memory::ptr src, + const cldnn::memory::ptr weights, + cldnn::memory::ptr dst, + TestParams &p) { + + cldnn::mem_lock src_data(src, get_test_stream()); + cldnn::mem_lock weights_data(weights, get_test_stream()); + cldnn::mem_lock dst_data(dst, get_test_stream()); int pack_size = sizeof(data_t_src) * 8; @@ -117,7 +109,7 @@ void compute_ref_conv_bin(const cldnn::memory &src, return (data_t_src)((val >> bit) & 0x1); }; - auto ker = [=](data_t_acc &d, int g, int mb, int oc,int oh, int ow, int& ks) { + auto ker = [&](data_t_acc &d, int g, int mb, int oc,int oh, int ow, int& ks) { for (int ic = 0; ic < IC / NG; ++ic) { for (int kh = 0; kh < KH; ++kh) for (int kw = 0; kw < KW; ++kw) { @@ -133,15 +125,12 @@ void compute_ref_conv_bin(const cldnn::memory &src, uint8_t w = extract_bit(weights_data[widx / pack_size], widx % pack_size); uint8_t s = 0; - if ((ih < 0 || ih >= IH || iw < 0 || iw >= IW)) - { + if ((ih < 0 || ih >= IH || iw < 0 || iw >= IW)) { if (p.pad_value == 0.0f) continue; else s = (p.pad_value == -1.0f) ? 0 : 1; - } - else - { + } else { if (ic == 0) ks++; iidx = mb * div_up(IC, pack_size) * IH * IW + g * div_up(IC, pack_size) / NG * IH * IW @@ -180,18 +169,15 @@ void compute_ref_conv_bin(const cldnn::memory &src, } } -class binary_convolution_test : public ::testing::TestWithParam -{ - void SetUp() - { +class binary_convolution_test : public ::testing::TestWithParam { + void SetUp() { std::cout << GetParam() << std::endl; ASSERT_TRUE(GetParam().isConsistent()); } }; -TEST_P(binary_convolution_test, conv) -{ - const auto& engine = get_test_engine(); +TEST_P(binary_convolution_test, conv) { + auto& engine = get_test_engine(); cldnn::build_options options; options.set_option(cldnn::build_option::optimize_data(true)); topology topology_bin; @@ -217,9 +203,9 @@ TEST_P(binary_convolution_test, conv) cldnn::feature(p.oc), cldnn::spatial(p.ow, p.oh)}; - auto input = memory::allocate(engine, { cldnn::data_types::bin, cldnn::format::b_fs_yx_32fp, is_size }); - auto weights = memory::allocate(engine, { cldnn::data_types::bin, cldnn::format::bfyx, wei_size }); - auto output_ref = memory::allocate(engine, { cldnn::data_types::f32, cldnn::format::bfyx, os_size }); + auto input = engine.allocate_memory({ cldnn::data_types::bin, cldnn::format::b_fs_yx_32fp, is_size }); + auto weights = engine.allocate_memory({ cldnn::data_types::bin, cldnn::format::bfyx, wei_size }); + auto output_ref = engine.allocate_memory({ cldnn::data_types::f32, cldnn::format::bfyx, os_size }); fill(input); fill(weights); @@ -231,7 +217,7 @@ TEST_P(binary_convolution_test, conv) // print_bin_blob(weights, "weights"); // print_blob(output_ref, "ref_out"); - topology_bin.add(input_layout(input_name, input.get_layout())); + topology_bin.add(input_layout(input_name, input->get_layout())); topology_bin.add(data(output_name + weights_suffix, weights)); topology_bin.add(binary_convolution(output_name, input_name, {output_name + weights_suffix}, @@ -243,18 +229,15 @@ TEST_P(binary_convolution_test, conv) std::map outputs = network_bin.execute(); auto outputMemory = outputs.at(output_name).get_memory(); - for (size_t i = 0; i < output_ref.count(); i++) { - if (p.dt == data_types::f32) - { - auto ref = output_ref.pointer(); - auto opt = outputMemory.pointer(); + for (size_t i = 0; i < output_ref->count(); i++) { + if (p.dt == data_types::f32) { + cldnn::mem_lock ref(output_ref, get_test_stream()); + cldnn::mem_lock opt(outputMemory, get_test_stream()); ASSERT_EQ(ref[i], opt[i]) << i; - } - else if (p.dt == data_types::f16) - { - auto ref = output_ref.pointer(); - auto opt = outputMemory.pointer(); + } else if (p.dt == data_types::f16) { + cldnn::mem_lock ref(output_ref, get_test_stream()); + cldnn::mem_lock opt(outputMemory, get_test_stream()); ASSERT_EQ(ref[i], float16_to_float32(opt[i])) << i; } @@ -320,20 +303,19 @@ INSTANTIATE_TEST_CASE_P(BinaryConvTest, binary_convolution_test, ::testing::Valu ),); template -static void set_binary_values(const cldnn::memory& mem, std::vector args) { - auto ptr = mem.pointer(); +static void set_binary_values(cldnn::memory::ptr mem, std::vector args) { + cldnn::mem_lock ptr(mem, get_test_stream()); auto it = ptr.begin(); for (auto x : args) *it++ = x; } -TEST(binary_convolution, basic_convolution_1x1_single_packed_channel) -{ - const auto& engine = get_test_engine(); +TEST(binary_convolution, basic_convolution_1x1_single_packed_channel) { + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::bin, format::b_fs_yx_32fp, { 1, 16, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::bin, format::bfyx, { 4, 16, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::bin, format::b_fs_yx_32fp, { 1, 16, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::bin, format::bfyx, { 4, 16, 1, 1 } }); // 0 0 1 0 0 1 0 0 1 0 1 0 1 0 1 0 // 1 0 0 0 0 1 1 0 0 1 1 0 1 0 1 0 @@ -373,7 +355,7 @@ TEST(binary_convolution, basic_convolution_1x1_single_packed_channel) 4.0f, 2.0f, -6.0f, 14.0f }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), binary_convolution("binary_conv", "input", { "weights" }, { 1,1,1,1 }, @@ -396,8 +378,8 @@ TEST(binary_convolution, basic_convolution_1x1_single_packed_channel) EXPECT_EQ(outputs.begin()->first, "binary_conv"); auto output_memory = outputs.at("binary_conv").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); EXPECT_EQ(output_layout.format, format::bfyx); EXPECT_EQ(output_layout.data_type, data_types::f32); @@ -413,10 +395,10 @@ TEST(binary_convolution, basic_convolution_1x1_single_packed_channel) } TEST(binary_convolution, basic_convolution_1x1_single_packed_channel_fp16) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::bin, format::b_fs_yx_32fp, { 1, 16, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::bin, format::bfyx, { 4, 16, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::bin, format::b_fs_yx_32fp, { 1, 16, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::bin, format::bfyx, { 4, 16, 1, 1 } }); // 0 0 1 0 0 1 0 0 1 0 1 0 1 0 1 0 // 1 0 0 0 0 1 1 0 0 1 1 0 1 0 1 0 @@ -456,7 +438,7 @@ TEST(binary_convolution, basic_convolution_1x1_single_packed_channel_fp16) { 4.0f, 2.0f, -6.0f, 14.0f }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), binary_convolution("binary_conv", "input", { "weights" }, { 1,1,1,1 }, @@ -479,8 +461,8 @@ TEST(binary_convolution, basic_convolution_1x1_single_packed_channel_fp16) { EXPECT_EQ(outputs.begin()->first, "binary_conv"); auto output_memory = outputs.at("binary_conv").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); EXPECT_EQ(output_layout.format, format::bfyx); EXPECT_EQ(output_layout.data_type, data_types::f16); @@ -489,9 +471,7 @@ TEST(binary_convolution, basic_convolution_1x1_single_packed_channel_fp16) { EXPECT_EQ(output_layout.size.spatial[1], 2); EXPECT_EQ(output_layout.size.spatial[0], 2); - for (size_t i = 0; i < output_layout.count(); i++) - { + for (size_t i = 0; i < output_layout.count(); i++) { EXPECT_EQ(float16_to_float32(output_ptr[i]), output_vec[i]) << "index="<< i; } } - diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/border_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/border_gpu_test.cpp index 1e206a2876cb39..df8a8d47c203a3 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/border_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/border_gpu_test.cpp @@ -2,18 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include +#include "test_utils.h" -#include -#include -#include -#include -#include -#include - -#include "test_utils/test_utils.h" -#include "test_utils/uniform_quantized_real_distribution.hpp" +#include +#include #include @@ -26,7 +18,7 @@ static std::vector generate_rnd_real_input( const T min = static_cast(0), const T max = static_cast(1), const unsigned rnd_bits = 9) { static std::default_random_engine rnd_gen(random_seed); - cldnn::tests::distributions::uniform_quantized_real_distribution rnd_dist(min, max, rnd_bits); + tests::distributions::uniform_quantized_real_distribution rnd_dist(min, max, rnd_bits); auto acum = std::accumulate(sizes.begin(), sizes.end(), static_cast(1), std::multiplies()); @@ -62,12 +54,12 @@ TEST(border_gpu, basic_yxfb_0x0x1x2_0x0x3x4_border_constant) { constexpr auto out_size_y = in_size_y + blt_size_y + brb_size_y; constexpr auto out_size_x = in_size_x + blt_size_x + brb_size_x; - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::yxfb, {in_size_b, in_size_f, in_size_x, in_size_y}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::yxfb, {in_size_b, in_size_f, in_size_x, in_size_y}}); topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( border("output", "input", @@ -97,7 +89,7 @@ TEST(border_gpu, basic_yxfb_0x0x1x2_0x0x3x4_border_constant) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(out_data.size(), static_cast(out_size_b * out_size_f * out_size_y * out_size_x)); @@ -140,12 +132,12 @@ TEST(border_gpu, basic_bfzyx_0x0x1x01_0x0x0x0x3_border_constant) { constexpr auto out_size_x = in_size_x + blt_size_x + brb_size_x; constexpr auto out_size_z = in_size_z + blt_size_z + brb_size_z; - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ in_size_b, in_size_f, in_size_x, in_size_y, in_size_z } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx,{ in_size_b, in_size_f, in_size_x, in_size_y, in_size_z } }); topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( border("output", "input", @@ -200,7 +192,7 @@ TEST(border_gpu, basic_bfzyx_0x0x1x01_0x0x0x0x3_border_constant) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(out_data.size(), static_cast(out_size_b * out_size_f * out_size_y * out_size_x * out_size_z)); @@ -249,12 +241,12 @@ TEST(border_gpu, basic_bfwzyx_0x0x0x1x0x1_0x0x0x1x0x1_border_constant) { constexpr auto out_size_z = in_size_z + blt_size_z + brb_size_z; constexpr auto out_size_w = in_size_w + blt_size_w + brb_size_w; - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfwzyx, tensor{ batch(in_size_b), feature(in_size_f), spatial(in_size_x, in_size_y, in_size_z, in_size_w) } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfwzyx, tensor{ batch(in_size_b), feature(in_size_f), spatial(in_size_x, in_size_y, in_size_z, in_size_w) } }); topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( border("output", "input", @@ -308,7 +300,7 @@ TEST(border_gpu, basic_bfwzyx_0x0x0x1x0x1_0x0x0x1x0x1_border_constant) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(out_data.size(), static_cast(out_size_b * out_size_f * out_size_y * out_size_x * out_size_z * out_size_w)); @@ -353,12 +345,12 @@ TEST(border_gpu, basic_yxfb_0x0x1x2_0x0x3x4_border_constant_non_constant) { constexpr auto out_size_y = in_size_y + blt_size_y + brb_size_y; constexpr auto out_size_x = in_size_x + blt_size_x + brb_size_x; - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::yxfb, {in_size_b, in_size_f, in_size_x, in_size_y}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::yxfb, {in_size_b, in_size_f, in_size_x, in_size_y}}); topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( border("output", "input", @@ -388,7 +380,7 @@ TEST(border_gpu, basic_yxfb_0x0x1x2_0x0x3x4_border_constant_non_constant) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(out_data.size(), static_cast(out_size_b * out_size_f * out_size_y * out_size_x)); @@ -429,12 +421,12 @@ TEST(border_gpu, basic_yxfb_0x0x1x2_0x0x3x4_border_mirror) { constexpr auto out_size_y = in_size_y + blt_size_y + brb_size_y; constexpr auto out_size_x = in_size_x + blt_size_x + brb_size_x; - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::yxfb, {in_size_b, in_size_f, in_size_x, in_size_y}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::yxfb, {in_size_b, in_size_f, in_size_x, in_size_y}}); topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( border("output", "input", @@ -464,7 +456,7 @@ TEST(border_gpu, basic_yxfb_0x0x1x2_0x0x3x4_border_mirror) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(out_data.size(), static_cast(out_size_b * out_size_f * out_size_y * out_size_x)); @@ -507,12 +499,12 @@ TEST(border_gpu, basic_bfzyx_0x0x0x0x1_0x0x0x0x1_border_mirror) { constexpr auto out_size_x = in_size_x + blt_size_x + brb_size_x; constexpr auto out_size_z = in_size_z + blt_size_z + brb_size_z; - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ in_size_b, in_size_f, in_size_x, in_size_y, in_size_z } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx,{ in_size_b, in_size_f, in_size_x, in_size_y, in_size_z } }); topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( border("output", "input", @@ -532,7 +524,7 @@ TEST(border_gpu, basic_bfzyx_0x0x0x0x1_0x0x0x0x1_border_mirror) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (auto b = 0; b < out_size_b; ++b) { // B for (auto f = 0; f < out_size_f; ++f) { // F @@ -587,12 +579,12 @@ TEST(border_gpu, basic_bfzyxw_0x0x0x0x1_0x0x0x0x1_border_mirror) { constexpr auto out_size_z = in_size_z + blt_size_z + brb_size_z; constexpr auto out_size_w = in_size_w + blt_size_w + brb_size_w; - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfwzyx, tensor{ batch(in_size_b), feature(in_size_f), spatial(in_size_x, in_size_y, in_size_z, in_size_w) } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfwzyx, tensor{ batch(in_size_b), feature(in_size_f), spatial(in_size_x, in_size_y, in_size_z, in_size_w) } }); topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( border("output", "input", @@ -612,7 +604,7 @@ TEST(border_gpu, basic_bfzyxw_0x0x0x0x1_0x0x0x0x1_border_mirror) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (auto b = 0; b < out_size_b; ++b) { // B for (auto f = 0; f < out_size_f; ++f) { // F @@ -664,12 +656,12 @@ TEST(border_gpu, basic_yxfb_0x0x1x2_0x0x3x4_border_mirror_101) { constexpr auto out_size_y = in_size_y + blt_size_y + brb_size_y; constexpr auto out_size_x = in_size_x + blt_size_x + brb_size_x; - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::yxfb, tensor{in_size_b, in_size_f, in_size_x, in_size_y}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::yxfb, tensor{in_size_b, in_size_f, in_size_x, in_size_y}}); topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( border("output", "input", @@ -701,7 +693,7 @@ TEST(border_gpu, basic_yxfb_0x0x1x2_0x0x3x4_border_mirror_101) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(out_data.size(), static_cast(out_size_b * out_size_f * out_size_y * out_size_x)); @@ -743,12 +735,12 @@ TEST(border_gpu, basic_bfzyx_0x0x0x0x1_0x0x0x0x1_border_mirror_101) { constexpr auto out_size_x = in_size_x + blt_size_x + brb_size_x; constexpr auto out_size_z = in_size_z + blt_size_z + brb_size_z; - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx, tensor{ in_size_b, in_size_f, in_size_x, in_size_y, in_size_z } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx, tensor{ in_size_b, in_size_f, in_size_x, in_size_y, in_size_z } }); topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( border("output", "input", @@ -781,7 +773,7 @@ TEST(border_gpu, basic_bfzyx_0x0x0x0x1_0x0x0x0x1_border_mirror_101) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(out_data.size(), static_cast(out_size_b * out_size_f * out_size_y * out_size_x * out_size_z)); @@ -829,12 +821,12 @@ TEST(border_gpu, basic_bfwzyx_0x0x0x0x1x1_0x0x0x0x1x1_border_mirror_101) { constexpr auto out_size_z = in_size_z + blt_size_z + brb_size_z; constexpr auto out_size_w = in_size_w + blt_size_w + brb_size_w; - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfwzyx, tensor{ batch(in_size_b), feature(in_size_f), spatial(in_size_x, in_size_y, in_size_z, in_size_w) } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfwzyx, tensor{ batch(in_size_b), feature(in_size_f), spatial(in_size_x, in_size_y, in_size_z, in_size_w) } }); topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( border("output", "input", @@ -847,26 +839,26 @@ TEST(border_gpu, basic_bfwzyx_0x0x0x0x1x1_0x0x0x0x1x1_border_mirror_101) { 1, -2, 3, -4, 5, 6, 7, 8, - 2, -3, 4, -5, + 2, -3, 4, -5, 15, 4, 4, 4, 2, -6, 13, -14, - 3, 7, 7, 7, + 3, 7, 7, 7, }; std::vector out_data = { - 2, -3, 4, -5, + 2, -3, 4, -5, 15, 4, 4, 4, 1, -2, 3, -4, 5, 6, 7, 8, - 2, -3, 4, -5, - 15, 4, 4, 4, + 2, -3, 4, -5, + 15, 4, 4, 4, - 2, -6, 13, -14, + 2, -6, 13, -14, 3, 7, 7, 7, - 2, -3, 4, -5, + 2, -3, 4, -5, 15, 4, 4, 4, }; set_values(input, input_data); @@ -876,7 +868,7 @@ TEST(border_gpu, basic_bfwzyx_0x0x0x0x1x1_0x0x0x0x1x1_border_mirror_101) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(out_data.size(), static_cast(out_size_b * out_size_f * out_size_y * out_size_x * out_size_z * out_size_w)); @@ -921,12 +913,12 @@ TEST(border_gpu, basic_yxfb_0x0x1x2_0x0x3x4_border_edge) { constexpr auto out_size_y = in_size_y + blt_size_y + brb_size_y; constexpr auto out_size_x = in_size_x + blt_size_x + brb_size_x; - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::yxfb, tensor{in_size_b, in_size_f, in_size_x, in_size_y}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::yxfb, tensor{in_size_b, in_size_f, in_size_x, in_size_y}}); topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( border("output", "input", @@ -958,7 +950,7 @@ TEST(border_gpu, basic_yxfb_0x0x1x2_0x0x3x4_border_edge) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(out_data.size(), static_cast(out_size_b * out_size_f * out_size_y * out_size_x)); @@ -996,12 +988,12 @@ TEST(border_gpu, basic_bfyx_2x1x2x3_1x2x3x4_border_constant) { constexpr auto out_size_y = in_size_y + blt_size_y + brb_size_y; constexpr auto out_size_x = in_size_x + blt_size_x + brb_size_x; - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, tensor{in_size_b, in_size_f, in_size_x, in_size_y}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, tensor{in_size_b, in_size_f, in_size_x, in_size_y}}); topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( border("output", "input", @@ -1021,7 +1013,7 @@ TEST(border_gpu, basic_bfyx_2x1x2x3_1x2x3x4_border_constant) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (auto b = 0; b < out_size_b; ++b) { // B for (auto f = 0; f < out_size_f; ++f) { // F @@ -1068,12 +1060,12 @@ TEST(border_gpu, basic_bfyx_2x1x2x3_1x2x3x4_border_mirror) { constexpr auto out_size_y = in_size_y + blt_size_y + brb_size_y; constexpr auto out_size_x = in_size_x + blt_size_x + brb_size_x; - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, tensor{in_size_b, in_size_f, in_size_x, in_size_y}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, tensor{in_size_b, in_size_f, in_size_x, in_size_y}}); topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( border("output", "input", @@ -1092,7 +1084,7 @@ TEST(border_gpu, basic_bfyx_2x1x2x3_1x2x3x4_border_mirror) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (auto b = 0; b < out_size_b; ++b) { // B for (auto f = 0; f < out_size_f; ++f) { // F @@ -1135,12 +1127,12 @@ TEST(border_gpu, basic_bfyx_2x1x2x3_1x2x3x4_border_mirror_101) { constexpr auto out_size_y = in_size_y + blt_size_y + brb_size_y; constexpr auto out_size_x = in_size_x + blt_size_x + brb_size_x; - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, tensor{in_size_b, in_size_f, in_size_x, in_size_y}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, tensor{in_size_b, in_size_f, in_size_x, in_size_y}}); topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( border("output", "input", @@ -1158,7 +1150,7 @@ TEST(border_gpu, basic_bfyx_2x1x2x3_1x2x3x4_border_mirror_101) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (auto b = 0; b < out_size_b; ++b) { // B for (auto f = 0; f < out_size_f; ++f) { // F @@ -1201,12 +1193,12 @@ TEST(border_gpu, basic_bfyx_2x1x2x3_1x2x3x4_border_edge) { constexpr auto out_size_y = in_size_y + blt_size_y + brb_size_y; constexpr auto out_size_x = in_size_x + blt_size_x + brb_size_x; - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, tensor{in_size_b, in_size_f, in_size_x, in_size_y}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, tensor{in_size_b, in_size_f, in_size_x, in_size_y}}); topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( border("output", "input", @@ -1224,7 +1216,7 @@ TEST(border_gpu, basic_bfyx_2x1x2x3_1x2x3x4_border_edge) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (auto b = 0; b < out_size_b; ++b) { // B for (auto f = 0; f < out_size_f; ++f) { // F diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/broadcast_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/broadcast_gpu_test.cpp index 9784a70a916b8d..8ae447221ed9c1 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/broadcast_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/broadcast_gpu_test.cpp @@ -2,18 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include +#include "test_utils.h" -#include -#include -#include -#include -#include -#include - -#include "test_utils/test_utils.h" -#include "test_utils/uniform_quantized_real_distribution.hpp" +#include +#include #include @@ -23,8 +15,7 @@ using namespace ::tests; template void start_broadcast_test(data_types cldnn_data_type, std::vector output_shape, std::vector input_shape, std::vector broadcast_axes, - std::vector golden_data) -{ + std::vector golden_data) { size_t input_data_size = accumulate(input_shape.rbegin(), input_shape.rend(), (size_t)1, std::multiplies()); EXPECT_GE(input_data_size, (size_t)1); std::vector input_data = {}; @@ -51,11 +42,11 @@ void start_broadcast_test(data_types cldnn_data_type, std::vector output fixed_b_axes.push_back((uint16_t) (broadcast_axes.at(i) + shift)); } - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {cldnn_data_type, format::bfyx, {input_4d.at(0), input_4d.at(1), input_4d.at(3), input_4d.at(2)}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({cldnn_data_type, format::bfyx, {input_4d.at(0), input_4d.at(1), input_4d.at(3), input_4d.at(2)}}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(broadcast("output", "input", {output_4d.at(0), output_4d.at(1), output_4d.at(3), output_4d.at(2)}, fixed_b_axes)); set_values(input, input_data); @@ -65,7 +56,7 @@ void start_broadcast_test(data_types cldnn_data_type, std::vector output auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (tensor::value_type b = 0; b < output_4d.at(0); ++b) { for (tensor::value_type f = 0; f < output_4d.at(1); ++f) { @@ -110,11 +101,11 @@ void start_broadcast_test_5d(data_types cldnn_data_type, std::vector out fixed_b_axes.push_back((uint16_t)(broadcast_axes.at(i) + shift)); } - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { cldnn_data_type, format::bfzyx,{ input_5d.at(0), input_5d.at(1), input_5d.at(4), input_5d.at(3), input_5d.at(2) } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ cldnn_data_type, format::bfzyx,{ input_5d.at(0), input_5d.at(1), input_5d.at(4), input_5d.at(3), input_5d.at(2) } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(broadcast("output", "input", { output_5d.at(0), output_5d.at(1), output_5d.at(4), output_5d.at(3), output_5d.at(2) }, fixed_b_axes)); set_values(input, input_data); @@ -124,7 +115,7 @@ void start_broadcast_test_5d(data_types cldnn_data_type, std::vector out auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (tensor::value_type b = 0; b < output_5d.at(0); ++b) { for (tensor::value_type f = 0; f < output_5d.at(1); ++f) { @@ -1438,11 +1429,11 @@ TEST(broadcast_gpu_int64_t, bfyx_2_to_2x3x4x5_w_b_axes_1_2_3) { TEST(broadcast_gpu, basic_error_wrong_b_axes_size) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {1, 1, 1, 1}}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(broadcast("output", "input", {2, 3, 4, 5}, {0, 1, 2, 3, 4})); std::string msg_to_find = "Incorrect parameters configuration: broadcast_axes size should be less or equal 4."; @@ -1451,11 +1442,11 @@ TEST(broadcast_gpu, basic_error_wrong_b_axes_size) { TEST(broadcast_gpu, basic_error_wrong_b_axis_value) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {1, 1, 1, 1}}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(broadcast("output", "input", {2, 3, 4, 5}, {0, 4})); std::string msg_to_find = "Incorrect parameters configuration: broadcast_axes index should be within broadcast_sizes range."; @@ -1464,11 +1455,11 @@ TEST(broadcast_gpu, basic_error_wrong_b_axis_value) { TEST(broadcast_gpu, basic_error_duplicate_b_axis_values) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {1, 1, 1, 1}}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(broadcast("output", "input", {2, 3, 4, 5}, {0, 1, 1})); std::string msg_to_find = "Incorrect parameters configuration: Duplicate axes numbers was found in broadcast_axes."; @@ -1477,11 +1468,11 @@ TEST(broadcast_gpu, basic_error_duplicate_b_axis_values) { TEST(broadcast_gpu, basic_error_wrong_input_dimension_0) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {2, 3, 4, 5}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {2, 3, 4, 5}}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(broadcast("output", "input", {2, 3, 4, 5}, {1})); std::string msg_to_find = "Input size on dimension number 0(=2) is not equal to: (=1)"; @@ -1490,11 +1481,11 @@ TEST(broadcast_gpu, basic_error_wrong_input_dimension_0) { TEST(broadcast_gpu, basic_error_not_dividable_2x3x4x5_to_3x3x4x5) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {2, 3, 4, 5}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {2, 3, 4, 5}}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(broadcast("output", "input", {3, 3, 4, 5}, {})); std::string msg_to_find = "Invalid broadcast size: not dividable by input size"; @@ -1503,11 +1494,11 @@ TEST(broadcast_gpu, basic_error_not_dividable_2x3x4x5_to_3x3x4x5) { TEST(broadcast_gpu, basic_error_not_dividable_3_to_2x3x4x5_w_b_axes_0x1x3) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {1, 1, 3, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {1, 1, 3, 1}}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(broadcast("output", "input", {2, 3, 4, 5}, {0, 1, 3})); std::string msg_to_find = "Invalid broadcast size: not dividable by input size"; @@ -1516,11 +1507,11 @@ TEST(broadcast_gpu, basic_error_not_dividable_3_to_2x3x4x5_w_b_axes_0x1x3) { TEST(broadcast_gpu, basic_error_not_dividable_4x5_to_3x4x5_w_b_axes_1) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {1, 3, 5, 4}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {1, 3, 5, 4}}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(broadcast("output", "input", {2, 3, 4, 5}, {1})); std::string msg_to_find = "Invalid broadcast size: not dividable by input size"; diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/cache_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/cache_test.cpp index 89935b79549406..469d0b3103f1f8 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/cache_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/cache_test.cpp @@ -2,18 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include - #include "test_utils.h" -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include #include #include @@ -172,13 +165,13 @@ void remove(const std::string& filename) { class cache_test_helper { public: - cache_test_helper(cldnn::engine engine, cache_version v) + cache_test_helper(cldnn::engine& engine, cache_version v) : _engine(engine) , _mode(cldnn::tuning_mode::tuning_disabled) , cache_filename(get_temporary_cache_file()) { auto cache = get_cache_version(v); - auto eus = engine.get_info().cores_count; + auto eus = engine.get_device_info().execution_units_count; replace(cache, eus_marker, eus); write(cache_filename, cache); @@ -210,7 +203,7 @@ class cache_test_helper { } void test() { - auto w_mem = cldnn::memory::allocate(_engine, cldnn::layout(cldnn::data_types::f32, cldnn::format::bfyx, { 16, 16, 1, 1 })); + auto w_mem = _engine.allocate_memory(cldnn::layout(cldnn::data_types::f32, cldnn::format::bfyx, { 16, 16, 1, 1 })); auto topology = cldnn::topology( cldnn::input_layout("input", cldnn::layout(cldnn::data_types::f32, cldnn::format::bfyx, { 1, 16, 3, 3 })), cldnn::data("weights", w_mem), @@ -225,7 +218,7 @@ class cache_test_helper { cldnn::build_option::optimize_data(true) ); auto network = cldnn::network(_engine, topology, build_opts); - auto in_mem = cldnn::memory::allocate(_engine, cldnn::layout(cldnn::data_types::f32, cldnn::format::bfyx, { 1, 16, 3, 3 })); + auto in_mem = _engine.allocate_memory(cldnn::layout(cldnn::data_types::f32, cldnn::format::bfyx, { 1, 16, 3, 3 })); network.set_input_data("input", in_mem); network.execute(); @@ -247,7 +240,7 @@ class cache_test_helper { if (compare_cache.compare) { auto cache = read(cache_filename); auto expected_cache = get_cache_version(compare_cache.value); - auto eus = _engine.get_info().cores_count; + auto eus = _engine.get_device_info().execution_units_count; replace(expected_cache, eus_marker, eus); EXPECT_EQ(cache, expected_cache); @@ -266,7 +259,7 @@ class cache_test_helper { optional_compare(T v, bool neq) : compare(true), not_equal(neq), value(v) {} }; - cldnn::engine _engine; + cldnn::engine& _engine; cldnn::tuning_mode _mode; @@ -311,7 +304,7 @@ class cache_version_test : public testing::TestWithParam { TEST(cache_test, no_cache_baseline) { SCOPED_TRACE("default implementation same as reference, cache tests may provide invalid pass"); - auto engine = tests::get_test_engine(); + auto& engine = tests::get_test_engine(); auto helper = cache_test_helper(engine, cache_version::version_2); helper.with_mode(cldnn::tuning_mode::tuning_disabled) @@ -321,7 +314,7 @@ TEST(cache_test, no_cache_baseline) { TEST_P(cache_version_test, use_only) { auto version = GetParam(); - auto engine = tests::get_test_engine(); + auto& engine = tests::get_test_engine(); cache_test_helper helper(engine, version); helper.with_mode(cldnn::tuning_mode::tuning_use_cache) @@ -337,7 +330,7 @@ TEST_P(cache_version_test, update) { ex_version = cache_version::version_2_from_1; } - auto engine = tests::get_test_engine(); + auto& engine = tests::get_test_engine(); cache_test_helper helper(engine, version); helper.with_mode(cldnn::tuning_mode::tuning_use_and_update) @@ -353,7 +346,7 @@ INSTANTIATE_TEST_CASE_P( cache_version_test::to_string); TEST(cache_test, remove_invalid) { - auto engine = tests::get_test_engine(); + auto& engine = tests::get_test_engine(); cache_test_helper helper(engine, cache_version::version_2_invalid); helper.with_mode(cldnn::tuning_mode::tuning_use_and_update) diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/cl_mem_input_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/cl_mem_input_test.cpp index 2ff579ca8ffcd6..bf5d79b74fa86c 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/cl_mem_input_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/cl_mem_input_test.cpp @@ -2,23 +2,18 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include "api/activation.hpp" -#include -#include -#include -#include -#include -#include "test_utils/test_utils.h" +#include "test_utils.h" +#include +#include +#include +#include -#include + +#include using namespace cldnn; -using namespace tests; +using namespace ::tests; typedef std::chrono::high_resolution_clock Time; typedef std::chrono::nanoseconds ns; @@ -26,10 +21,8 @@ typedef std::chrono::duration> ms; typedef std::chrono::duration fsec; -void checkStatus(int status, const char *message) -{ - if (status != 0) - { +void checkStatus(int status, const char *message) { + if (status != 0) { std::string str_message(message + std::string(": ")); std::string str_number(std::to_string(status)); @@ -37,8 +30,7 @@ void checkStatus(int status, const char *message) } } -std::vector createSampleData(int width, int height) -{ +std::vector createSampleData(int width, int height) { int data_size = width * (height + height / 2); auto data = std::vector(data_size); srand((unsigned)time(0)); @@ -57,8 +49,7 @@ std::vector createSampleData(int width, int height) return data; } -std::vector createReferenceData(std::vector data, int width, int height, cldnn::format format) -{ +std::vector createReferenceData(std::vector data, int width, int height, cldnn::format format) { auto img = std::vector(width * height * 3); for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { @@ -78,8 +69,7 @@ std::vector createReferenceData(std::vector data, int widt img[j + width * i] = R; img[j + width * i + width * height] = G; img[j + width * i + width * height * 2] = B; - } - else { //byxf + } else { //byxf img[3* width*i + 3 * j] = R; img[3 * width * i + 3 * j + 1] = G; img[3 * width*i + 3 * j + 2] = B; @@ -90,14 +80,12 @@ std::vector createReferenceData(std::vector data, int widt return img; } -struct OpenCL -{ +struct OpenCL { cl::Context _context; cl::Device _device; cl::CommandQueue _queue; - OpenCL() - { + OpenCL() { // get Intel iGPU OCL device, create context and queue { static constexpr auto INTEL_PLATFORM_VENDOR = "Intel(R) Corporation"; @@ -136,8 +124,7 @@ struct OpenCL _queue = cl::CommandQueue(_context, _device, props); } } - void releaseOclImage(std::shared_ptr image) - { + void releaseOclImage(std::shared_ptr image) { checkStatus(clReleaseMemObject(*image), "clReleaseMemObject"); } }; @@ -153,9 +140,9 @@ TEST(cl_mem_check, check_2_inputs) { image_format.image_channel_order = CL_R; image_format.image_channel_data_type = CL_UNORM_INT8; cl_image_desc image_desc = { CL_MEM_OBJECT_IMAGE2D, (size_t)width, (size_t)height, 0, - 0, 0, 0, 0, 0, NULL }; + 0, 0, 0, 0, 0, { nullptr } }; - cl_mem nv12_image_plane_y = clCreateImage(ocl_instance->_context.get(), CL_MEM_READ_WRITE, &image_format, &image_desc, NULL, &err); + cl_mem nv12_image_plane_y = clCreateImage(ocl_instance->_context.get(), CL_MEM_READ_WRITE, &image_format, &image_desc, nullptr, &err); checkStatus(err, "Creating nv12 image plane_y failed"); image_format.image_channel_order = CL_RG; @@ -163,38 +150,38 @@ TEST(cl_mem_check, check_2_inputs) { image_desc.image_height = height / 2; image_desc.image_depth = 1; - cl_mem nv12_image_plane_uv = clCreateImage(ocl_instance->_context.get(), CL_MEM_READ_WRITE, &image_format, &image_desc, NULL, &err); + cl_mem nv12_image_plane_uv = clCreateImage(ocl_instance->_context.get(), CL_MEM_READ_WRITE, &image_format, &image_desc, nullptr, &err); checkStatus(err, "Creating nv12 image plane_uv failed"); size_t origin[3] = { 0, 0, 0 }; size_t y_region[3] = { (size_t)width, (size_t)height, 1 }; size_t uv_region[3] = { (size_t)width / 2, (size_t)height / 2, 1 }; - err = clEnqueueWriteImage(ocl_instance->_queue.get(), nv12_image_plane_y, true, origin, y_region, 0, 0, &data[0], 0, NULL, NULL); + err = clEnqueueWriteImage(ocl_instance->_queue.get(), nv12_image_plane_y, true, origin, y_region, 0, 0, &data[0], 0, nullptr, nullptr); checkStatus(err, "Writing nv12 image plane_y failed"); - err = clEnqueueWriteImage(ocl_instance->_queue.get(), nv12_image_plane_uv, true, origin, uv_region, 0, 0, &data[width * height], 0, NULL, NULL); + err = clEnqueueWriteImage(ocl_instance->_queue.get(), nv12_image_plane_uv, true, origin, uv_region, 0, 0, &data[width * height], 0, nullptr, nullptr); checkStatus(err, "Writing nv12 image plane_uv failed"); - device_query query(static_cast(ocl_instance->_context.get())); + device_query query(engine_types::ocl, runtime_types::ocl, static_cast(ocl_instance->_context.get())); auto devices = query.get_available_devices(); auto engine_config = cldnn::engine_configuration(); - engine engine(devices.begin()->second, engine_config); + auto engine = engine::create(engine_types::ocl, runtime_types::ocl, devices.begin()->second, engine_config); auto input = input_layout("input", { data_types::i8, format::nv12, {1,1,height,width} }); auto input2 = input_layout("input2", { data_types::i8, format::nv12, {1,1,height / 2,width / 2} }); auto output_format = cldnn::format::byxf; layout output_layout(data_types::f32, output_format, { 1,3,height,width }); - auto input_memory = cldnn::memory::share_image(engine, input.layout, nv12_image_plane_y, 0); - auto input_memory2 = cldnn::memory::share_image(engine, input2.layout, nv12_image_plane_uv, 0); + auto input_memory = engine->share_image(input.layout, nv12_image_plane_y); + auto input_memory2 = engine->share_image(input2.layout, nv12_image_plane_uv); topology topology; topology.add(input); topology.add(input2); topology.add(reorder("reorder", "input", "input2", output_layout)); - network network(engine, topology); + network network(*engine, topology); network.set_input_data("input", input_memory); network.set_input_data("input2", input_memory2); @@ -202,7 +189,7 @@ TEST(cl_mem_check, check_2_inputs) { std::vector reference_results = createReferenceData(data, width, height, output_format); auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); int size = width * height * 3; for (auto i = 0; i < size; i++) { EXPECT_NEAR(reference_results[i], output_ptr[i], 1.001f); @@ -222,26 +209,26 @@ TEST(cl_mem_check, check_input) { image_format.image_channel_order = CL_R; image_format.image_channel_data_type = CL_UNORM_INT8; cl_image_desc image_desc = { CL_MEM_OBJECT_IMAGE2D, (size_t)width, (size_t)height, 0, - 0, 0, 0, 0, 0, NULL }; + 0, 0, 0, 0, 0, { nullptr } }; - cl_mem nv12_image_plane_y = clCreateImage(ocl_instance->_context.get(), CL_MEM_READ_WRITE, &image_format, &image_desc, NULL, &err); + cl_mem nv12_image_plane_y = clCreateImage(ocl_instance->_context.get(), CL_MEM_READ_WRITE, &image_format, &image_desc, nullptr, &err); checkStatus(err, "Creating nv12 image plane_y failed"); image_format.image_channel_order = CL_RG; image_desc.image_width = width / 2; image_desc.image_height = height / 2; - cl_mem nv12_image_plane_uv = clCreateImage(ocl_instance->_context.get(), CL_MEM_READ_WRITE, &image_format, &image_desc, NULL, &err); + cl_mem nv12_image_plane_uv = clCreateImage(ocl_instance->_context.get(), CL_MEM_READ_WRITE, &image_format, &image_desc, nullptr, &err); checkStatus(err, "Creating nv12 image plane_uv failed"); size_t origin[3] = { 0, 0, 0 }; size_t y_region[3] = { (size_t)width, (size_t)height, 1 }; size_t uv_region[3] = { (size_t)width / 2, (size_t)height / 2, 1 }; - err = clEnqueueWriteImage(ocl_instance->_queue.get(), nv12_image_plane_y, true, origin, y_region, 0, 0, &data[0], 0, NULL, NULL); + err = clEnqueueWriteImage(ocl_instance->_queue.get(), nv12_image_plane_y, true, origin, y_region, 0, 0, &data[0], 0, nullptr, nullptr); checkStatus(err, "Writing nv12 image plane_y failed"); - err = clEnqueueWriteImage(ocl_instance->_queue.get(), nv12_image_plane_uv, true, origin, uv_region, 0, 0, &data[width * height], 0, NULL, NULL); + err = clEnqueueWriteImage(ocl_instance->_queue.get(), nv12_image_plane_uv, true, origin, uv_region, 0, 0, &data[width * height], 0, nullptr, nullptr); checkStatus(err, "Writing nv12 image plane_uv failed"); image_format.image_channel_order = CL_NV12_INTEL; @@ -267,12 +254,12 @@ TEST(cl_mem_check, check_input) { image_desc.image_depth = 0; image_format.image_channel_order = CL_R; - cl_mem img_y = clCreateImage(ocl_instance->_context.get(), CL_MEM_READ_WRITE, &image_format, &image_desc, NULL, &err); + cl_mem img_y = clCreateImage(ocl_instance->_context.get(), CL_MEM_READ_WRITE, &image_format, &image_desc, nullptr, &err); checkStatus(err, "Creating nv12 image plane_y failed"); image_desc.image_depth = 1; image_format.image_channel_order = CL_RG; - cl_mem img_uv = clCreateImage(ocl_instance->_context.get(), CL_MEM_READ_WRITE, &image_format, &image_desc, NULL, &err); + cl_mem img_uv = clCreateImage(ocl_instance->_context.get(), CL_MEM_READ_WRITE, &image_format, &image_desc, nullptr, &err); checkStatus(err, "Creating nv12 image plane_uv failed"); size_t regionY[] = { (size_t)width, (size_t)height, 1 }; @@ -288,30 +275,29 @@ TEST(cl_mem_check, check_input) { checkStatus(clReleaseMemObject(nv12_image_plane_uv), "clReleaseMemObject"); checkStatus(clReleaseMemObject(nv12_image_plane_y), "clReleaseMemObject"); - device_query query(static_cast(ocl_instance->_context.get())); + device_query query(engine_types::ocl, runtime_types::ocl, static_cast(ocl_instance->_context.get())); auto devices = query.get_available_devices(); - auto engine_config = cldnn::engine_configuration(); - engine engine(devices.begin()->second, engine_config); + auto engine = engine::create(engine_types::ocl, runtime_types::ocl, devices.begin()->second); auto input = input_layout("input", { data_types::i8, format::nv12, {1,1,height,width} }); auto output_format = cldnn::format::byxf; layout output_layout(data_types::f32, output_format, { 1,3,height,width }); - auto input_memory = cldnn::memory::share_image(engine, input.layout, img, 0); + auto input_memory = engine->share_image(input.layout, img); topology topology; topology.add(input); topology.add(reorder("reorder", "input", output_layout)); - network network(engine, topology); + network network(*engine, topology); network.set_input_data("input", input_memory); auto outputs = network.execute(); std::vector reference_results = createReferenceData(data, width, height, output_format); auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); int size = width * height * 3; for (auto i = 0; i < size; i++) { EXPECT_NEAR(reference_results[i], output_ptr[i], 1.001f); diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/command_queue_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/command_queue_test.cpp index a07688ee671a6e..0fed8ea95e4c08 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/command_queue_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/command_queue_test.cpp @@ -3,27 +3,24 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include #include "test_utils/test_utils.h" -#include "api/arg_max_min.hpp" + +#include +#include using namespace cldnn; -using namespace tests; +using namespace ::tests; using namespace std; // Run some topology too see if command queue does work correctly // Coppied from arg_max_gpu.base test. -void exexute_network(cldnn::engine engine) -{ +void exexute_network(cldnn::engine& engine) { // Input : 2x3x2x2 static const int32_t x_size = 2, y_size = 2, feature_num = 3, batch_num = 2; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ batch_num, feature_num, x_size , y_size } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ batch_num, feature_num, x_size , y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(arg_max_min("arg_max", { "input" }, arg_max_min::max)); vector input_vec = { @@ -48,11 +45,10 @@ void exexute_network(cldnn::engine engine) EXPECT_EQ(outputs.begin()->first, "arg_max"); auto output = outputs.at("arg_max").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float out_buffer[batch_num]; - for (uint32_t i = 0; i < batch_num; i++) - { - out_buffer[i] = get_value(output_ptr, i); + for (uint32_t i = 0; i < batch_num; i++) { + out_buffer[i] = get_value(output_ptr.data(), i); } int size = x_size * y_size * feature_num; int index; @@ -62,8 +58,7 @@ void exexute_network(cldnn::engine engine) EXPECT_LT(out_buffer[i], size); index = (int)out_buffer[i]; value = input_vec[i*size + (int)index]; - for (int j = 0; j < size; j++) - { + for (int j = 0; j < size; j++) { EXPECT_LE(input_vec[i*size + j], value); } } @@ -73,49 +68,34 @@ TEST(command_queue_test, test_priority_hints) { engine_configuration configuration = engine_configuration( false, // profiling - false, // decorate_kernel_names - false, // dump_custom_program - "", // options - "", // single_kernel - true, // primitives_parallelisation - "", // engine_log + queue_types::out_of_order, "", // sources_dumps_dir priority_mode_types::low, throttle_mode_types::disabled); - cldnn::engine engine(configuration); - exexute_network(engine); + auto engine = engine::create(engine_types::ocl, runtime_types::ocl, configuration); + exexute_network(*engine); } TEST(command_queue_test, test_throttle_hints) { engine_configuration configuration = engine_configuration( false, // profiling - false, // decorate_kernel_names - false, // dump_custom_program - "", // options - "", // single_kernel - true, // primitives_parallelisation - "", // engine_log + queue_types::out_of_order, "", // sources_dumps_dir priority_mode_types::disabled, throttle_mode_types::high); - cldnn::engine engine(configuration); - exexute_network(engine); + auto engine = engine::create(engine_types::ocl, runtime_types::ocl, configuration); + exexute_network(*engine); } TEST(command_queue_test, test_priority_and_throttle_hints) { engine_configuration configuration = engine_configuration( false, // profiling - false, // decorate_kernel_names - false, // dump_custom_program - "", // options - "", // single_kernel - true, // primitives_parallelisation - "", // engine_log + queue_types::out_of_order, "", // sources_dumps_dir priority_mode_types::high, throttle_mode_types::low); - cldnn::engine engine(configuration); - exexute_network(engine); -} \ No newline at end of file + auto engine = engine::create(engine_types::ocl, runtime_types::ocl, configuration); + exexute_network(*engine); +} diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/concatenation_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/concatenation_gpu_test.cpp index 9294d5e5d7cbbe..10f051b9ff435c 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/concatenation_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/concatenation_gpu_test.cpp @@ -4,17 +4,13 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include "api/memory.hpp" -#include -#include "api/convolution.hpp" -#include -#include -#include -#include "test_utils/test_utils.h" -#include "test_utils/float16.h" -#include +#include "test_utils.h" + +#include +#include +#include +#include + #include #include #include @@ -22,10 +18,9 @@ #include #include #include -#include using namespace cldnn; -using namespace tests; +using namespace ::tests; namespace cldnn { @@ -34,13 +29,13 @@ namespace cldnn TEST(concat_gpu, mixed_input_types) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input0 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 4, 3 } }); - auto input1 = memory::allocate(engine, { data_types::i32, format::bfyx, { 1, 1, 4, 3 } }); - auto input2 = memory::allocate(engine, { data_types::i8, format::bfyx, { 1, 1, 4, 3 } }); - auto input3 = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 1, 4, 3 } }); - auto input4 = memory::allocate(engine, { data_types::i64, format::bfyx, { 1, 1, 4, 3 } }); + auto input0 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 4, 3 } }); + auto input1 = engine.allocate_memory({ data_types::i32, format::bfyx, { 1, 1, 4, 3 } }); + auto input2 = engine.allocate_memory({ data_types::i8, format::bfyx, { 1, 1, 4, 3 } }); + auto input3 = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 1, 4, 3 } }); + auto input4 = engine.allocate_memory({ data_types::i64, format::bfyx, { 1, 1, 4, 3 } }); set_values(input0, { 1.0f, 2.0f, 3.0f, 4.0f, 2.0f, 2.0f, 3.0f, 4.0f, 3.0f, 3.0f, 3.0f, 5.0f }); set_values(input1, { 11, 12, 13, 14, 12, 12, 13, 14, 13, 13, 13, 15 }); @@ -59,11 +54,11 @@ TEST(concat_gpu, mixed_input_types) { 41.0f, 42.0f, 43.0f, 44.0f, 42.0f, 42.0f, 43.0f, 44.0f, 43.0f, 43.0f, 43.0f, 45.0f }; topology topology( - input_layout("input0", input0.get_layout()), - input_layout("input1", input1.get_layout()), - input_layout("input2", input2.get_layout()), - input_layout("input3", input3.get_layout()), - input_layout("input4", input4.get_layout()), + input_layout("input0", input0->get_layout()), + input_layout("input1", input1->get_layout()), + input_layout("input2", input2->get_layout()), + input_layout("input3", input3->get_layout()), + input_layout("input4", input4->get_layout()), concatenation("concat", { "input0", "input1", "input2", "input3", "input4" }, concatenation::concatenation_axis::along_f, @@ -83,8 +78,8 @@ TEST(concat_gpu, mixed_input_types) { EXPECT_EQ(outputs.begin()->first, "concat"); auto output_memory = outputs.at("concat").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -102,12 +97,12 @@ TEST(concat_gpu, mixed_input_types) { } TEST(concat_gpu, mixed_input_types_5d) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input0 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 1, 1, 1, 4, 3 } }); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 1, 1, 1, 4, 3 } }); - auto input2 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 1, 1, 1, 4, 3 } }); - auto input3 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 1, 1, 1, 4, 3 } }); + auto input0 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 1, 1, 1, 4, 3 } }); + auto input1 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 1, 1, 1, 4, 3 } }); + auto input2 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 1, 1, 1, 4, 3 } }); + auto input3 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 1, 1, 1, 4, 3 } }); set_values(input0, { half_t(1.0f), half_t(2.0f), half_t(3.0f), half_t(4.0f), half_t(2.0f), half_t(2.0f), @@ -133,10 +128,10 @@ TEST(concat_gpu, mixed_input_types_5d) { 31.0f, 32.0f, 33.0f, 34.0f, 32.0f, 32.0f, 33.0f, 34.0f, 33.0f, 33.0f, 33.0f, 35.0f }; topology topology( - input_layout("input0", input0.get_layout()), - input_layout("input1", input1.get_layout()), - input_layout("input2", input2.get_layout()), - input_layout("input3", input3.get_layout()), + input_layout("input0", input0->get_layout()), + input_layout("input1", input1->get_layout()), + input_layout("input2", input2->get_layout()), + input_layout("input3", input3->get_layout()), concatenation("concat", { "input0", "input1", "input2", "input3" }, concatenation::concatenation_axis::along_f, @@ -155,8 +150,8 @@ TEST(concat_gpu, mixed_input_types_5d) { EXPECT_EQ(outputs.begin()->first, "concat"); auto output_memory = outputs.at("concat").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int z_size = output_layout.size.spatial[2]; int y_size = output_layout.size.spatial[1]; @@ -176,10 +171,10 @@ TEST(concat_gpu, mixed_input_types_5d) { } TEST(concat_gpu, i8_optimization_with_pool) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input0 = memory::allocate(engine, {data_types::i8, format::bfyx, {1, 1, 8, 3}}); - auto input1 = memory::allocate(engine, {data_types::i8, format::bfyx, {1, 1, 8, 3}}); + auto input0 = engine.allocate_memory({data_types::i8, format::bfyx, {1, 1, 8, 3}}); + auto input1 = engine.allocate_memory({data_types::i8, format::bfyx, {1, 1, 8, 3}}); set_values(input0, { 11, 12, 13, @@ -207,8 +202,8 @@ TEST(concat_gpu, i8_optimization_with_pool) { 18, 14, -13, 15}; layout reorder_layout(data_types::i8, format::yxfb, {7, 2, 2, 1}); - topology topology(input_layout("input0", input0.get_layout()), - input_layout("input1", input1.get_layout()), + topology topology(input_layout("input0", input0->get_layout()), + input_layout("input1", input1->get_layout()), pooling("pool0", "input0", pooling_mode::max, {1, 1, 2, 2}, {1, 1, 1, 1}), pooling("pool1", "input1", pooling_mode::max, {1, 1, 2, 2}, {1, 1, 1, 1}), concatenation("concat", @@ -228,8 +223,8 @@ TEST(concat_gpu, i8_optimization_with_pool) { EXPECT_EQ(outputs.begin()->first, "reorder"); auto output_memory = outputs.at("reorder").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[0]; int x_size = output_layout.size.spatial[1]; @@ -279,12 +274,12 @@ TEST(concat_gpu, i8_optimization_with_conv) { // Output: // 53 54 30 // 52 47 37 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input0 = memory::allocate(engine, {data_types::i8, format::bfyx, {1, 1, 5, 4}}); - auto input1 = memory::allocate(engine, {data_types::i8, format::bfyx, {1, 1, 5, 4}}); - auto input2 = memory::allocate(engine, {data_types::i8, format::bfyx, {1, 1, 5, 4}}); - auto weights = memory::allocate(engine, { data_types::i8, format::bfyx, { 1, 3, 3, 2 } }); + auto input0 = engine.allocate_memory({data_types::i8, format::bfyx, {1, 1, 5, 4}}); + auto input1 = engine.allocate_memory({data_types::i8, format::bfyx, {1, 1, 5, 4}}); + auto input2 = engine.allocate_memory({data_types::i8, format::bfyx, {1, 1, 5, 4}}); + auto weights = engine.allocate_memory({ data_types::i8, format::bfyx, { 1, 3, 3, 2 } }); set_values(weights, { 1, 2, 1, 2, 1, 2, 1, 2, 1, @@ -303,14 +298,14 @@ TEST(concat_gpu, i8_optimization_with_conv) { 1, 2, -2, 4, 2, 3, 5, 3, -3, 1, 5, 4, 3, 2, 1 }); - + VF output_vec = { 53, 54, 30, 52, 47, 37 }; - + layout reorder_layout(data_types::i8, format::bfyx, {1, 1, 2, 3}); - topology topology(input_layout("input0", input0.get_layout()), - input_layout("input1", input1.get_layout()), - input_layout("input2", input2.get_layout()), + topology topology(input_layout("input0", input0->get_layout()), + input_layout("input1", input1->get_layout()), + input_layout("input2", input2->get_layout()), concatenation("concat", {"input0", "input1", "input2"}, concatenation::concatenation_axis::along_f, @@ -331,8 +326,8 @@ TEST(concat_gpu, i8_optimization_with_conv) { EXPECT_EQ(outputs.begin()->first, "output"); auto output_memory = outputs.at("output").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -358,20 +353,20 @@ TEST(concat_gpu, i8_optimization_with_pool_conv) { // Output : 1x1x3 // // Input0: - // -3 6 0 2 -1 -1 6 0 5 4 1 6 2 4 0 5 - // -2 -1 1 0 2 3 3 3 6 2 4 7 3 6 7 -1 - // 7 7 5 -3 1 -1 5 4 0 3 -2 6 2 5 2 4 - // 5 -1 3 6 2 0 -3 -1 0 3 0 -1 1 6 1 6 - // 5 -2 2 -1 5 6 3 4 1 0 6 6 7 2 6 3 - // 6 7 -1 5 5 6 -1 0 -1 5 5 2 3 -1 -3 4 + // -3 6 0 2 -1 -1 6 0 5 4 1 6 2 4 0 5 + // -2 -1 1 0 2 3 3 3 6 2 4 7 3 6 7 -1 + // 7 7 5 -3 1 -1 5 4 0 3 -2 6 2 5 2 4 + // 5 -1 3 6 2 0 -3 -1 0 3 0 -1 1 6 1 6 + // 5 -2 2 -1 5 6 3 4 1 0 6 6 7 2 6 3 + // 6 7 -1 5 5 6 -1 0 -1 5 5 2 3 -1 -3 4 // // Input1: - // 4 -2 0 0 6 2 0 4 6 4 4 4 -3 -1 4 -3 - // 1 0 -1 5 -1 1 4 2 7 7 0 2 3 4 -1 3 - // 7 7 2 -3 -1 5 -2 2 6 -3 0 7 0 3 3 3 - // -1 0 -2 -2 7 -3 -3 -1 5 0 3 4 0 -1 2 5 - // 2 -1 2 -3 0 -3 -3 2 4 3 3 5 5 7 5 1 - // 2 2 -3 6 6 7 1 -1 -2 5 1 -1 4 5 -3 -2 + // 4 -2 0 0 6 2 0 4 6 4 4 4 -3 -1 4 -3 + // 1 0 -1 5 -1 1 4 2 7 7 0 2 3 4 -1 3 + // 7 7 2 -3 -1 5 -2 2 6 -3 0 7 0 3 3 3 + // -1 0 -2 -2 7 -3 -3 -1 5 0 3 4 0 -1 2 5 + // 2 -1 2 -3 0 -3 -3 2 4 3 3 5 5 7 5 1 + // 2 2 -3 6 6 7 1 -1 -2 5 1 -1 4 5 -3 -2 // // Filters: // -1, 2, -2, 2, -2, 1, 1, 0, -1, 1, 2, -2, 2, 1, -2, 0, @@ -382,11 +377,11 @@ TEST(concat_gpu, i8_optimization_with_pool_conv) { // Output: // -14, -35, -10 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input0 = memory::allocate(engine, {data_types::i8, format::bfyx, {1, 16, 3, 2}}); - auto input1 = memory::allocate(engine, {data_types::i8, format::bfyx, {1, 16, 3, 2}}); - auto weights = memory::allocate(engine, {data_types::i8, format::bfyx, {1, 32, 2, 1}}); + auto input0 = engine.allocate_memory({data_types::i8, format::bfyx, {1, 16, 3, 2}}); + auto input1 = engine.allocate_memory({data_types::i8, format::bfyx, {1, 16, 3, 2}}); + auto weights = engine.allocate_memory({data_types::i8, format::bfyx, {1, 32, 2, 1}}); set_values(weights, {-1, 2, -2, 2, -2, 1, 1, 0, -1, 1, 2, -2, 2, 1, -2, 0, 0, -2, -2, -2, -2, -1, 2, 1, 2, -1, -1, 0, 2, -2, -2, 1, 0, -2, 0, 1, -2, -1, -2, 0, -1, -1, -2, 1, -2, 0, 1, 2, 2, 2, 2, -2, 0, 2, 1, -2, -1, -1, 0, -2, 2, -1, 2, -1}); @@ -394,7 +389,7 @@ TEST(concat_gpu, i8_optimization_with_pool_conv) { set_values(input0, {-3, 6, 0, 2, -1, -1, 6, 0, 5, 4, 1, 6, 2, 4, 0, 5, -2, -1, 1, 0, 2, 3, 3, 3, 6, 2, 4, 7, 3, 6, 7, -1, 7, 7, 5, -3, 1, -1, 5, 4, 0, 3, -2, 6, 2, 5, 2, 4, - 5, -1, 3, 6, 2, 0, -3, -1, 0, 3, 0, -1, 1, 6, 1, 6, + 5, -1, 3, 6, 2, 0, -3, -1, 0, 3, 0, -1, 1, 6, 1, 6, 5, -2, 2, -1, 5, 6, 3, 4, 1, 0, 6, 6, 7, 2, 6, 3, 6, 7, -1, 5, 5, 6, -1, 0, -1, 5, 5, 2, 3, -1, -3, 4 }); @@ -404,12 +399,12 @@ TEST(concat_gpu, i8_optimization_with_pool_conv) { -1, 0, -2, -2, 7, -3, -3, -1, 5, 0, 3, 4, 0, -1, 2, 5, 2, -1, 2, -3, 0, -3, -3, 2, 4, 3, 3, 5, 5, 7, 5, 1, 2, 2, -3, 6, 6, 7, 1, -1, -2, 5, 1, -1, 4, 5, -3, -2}); - + VF output_vec = { -14, -35, -10 }; layout reorder_layout(data_types::i8, format::bfyx, {1, 1, 3, 1}); - topology topology(input_layout("input0", input0.get_layout()), - input_layout("input1", input1.get_layout()), + topology topology(input_layout("input0", input0->get_layout()), + input_layout("input1", input1->get_layout()), pooling("pool0", "input0", pooling_mode::max, {1, 1, 2, 2}, {1, 1, 1, 1}), pooling("pool1", "input1", pooling_mode::max, {1, 1, 2, 2}, {1, 1, 1, 1}), concatenation("concat", @@ -431,8 +426,8 @@ TEST(concat_gpu, i8_optimization_with_pool_conv) { EXPECT_EQ(outputs.begin()->first, "output"); auto output_memory = outputs.at("output").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[0]; int x_size = output_layout.size.spatial[1]; @@ -527,7 +522,7 @@ struct concat_gpu_4d : public concat_gpu { void test(format::type fmt) { auto data_type = type_to_data_type::value; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const size_t batch_num = testing::get<0>(GetParam()); const std::vector in_features = testing::get<1>(GetParam()); const size_t input_y = testing::get<2>(GetParam()); @@ -539,7 +534,7 @@ struct concat_gpu_4d : public concat_gpu { topology topology; std::vector> in_data; - std::vector in_memory; + std::vector in_memory; std::vector input_ids; for (size_t i = 0; i < in_features.size(); i++) { auto size = tensor(static_cast(batch_num), @@ -563,7 +558,7 @@ struct concat_gpu_4d : public concat_gpu { } } - auto in_mem = memory::allocate(engine, in_lay); + auto in_mem = engine.allocate_memory(in_lay); set_values(in_mem, data_flat); in_memory.push_back(in_mem); @@ -585,7 +580,7 @@ struct concat_gpu_4d : public concat_gpu { network.execute(); auto out_mem = network.get_output("concat").get_memory(); - auto out_ptr = out_mem.pointer(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); for (size_t bi = 0; bi < batch_num; bi++) { size_t f_sum = 0; @@ -594,7 +589,7 @@ struct concat_gpu_4d : public concat_gpu { for (size_t yi = 0; yi < input_y; yi++) { for (size_t xi = 0; xi < input_x; xi++) { auto output_coords = tensor(batch(bi), feature(f_sum + fi), spatial(xi, yi, 0, 0)); - auto output_offset = out_mem.get_layout().get_linear_offset(output_coords); + auto output_offset = out_mem->get_layout().get_linear_offset(output_coords); auto ref_val = in_data[in_i][bi][fi][yi][xi]; auto actual_val = out_ptr[output_offset]; @@ -651,7 +646,7 @@ struct concat_id_conv_gpu_4d : public concat_gpu { void test(format::type fmt) { auto data_type = type_to_data_type::value; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const size_t batch_num = testing::get<0>(GetParam()); const std::vector in_features = testing::get<1>(GetParam()); const size_t input_y = testing::get<2>(GetParam()); @@ -663,7 +658,7 @@ struct concat_id_conv_gpu_4d : public concat_gpu { topology topology; std::vector> in_data; - std::vector in_memory; + std::vector in_memory; std::vector input_ids; for (size_t i = 0; i < in_features.size(); i++) { auto size = tensor(static_cast(batch_num), @@ -687,7 +682,7 @@ struct concat_id_conv_gpu_4d : public concat_gpu { } } - auto in_mem = memory::allocate(engine, in_lay); + auto in_mem = engine.allocate_memory(in_lay); set_values(in_mem, data_flat); in_memory.push_back(in_mem); @@ -699,9 +694,11 @@ struct concat_id_conv_gpu_4d : public concat_gpu { topology.add(concatenation("concat", input_ids, concatenation::concatenation_axis::along_f)); // Add identity convolution auto weights_lay = cldnn::layout(data_type, cldnn::format::bfyx, tensor(batch(output_f), feature(output_f))); - auto weights_mem = cldnn::memory::allocate(engine, weights_lay); + auto weights_mem = engine.allocate_memory(weights_lay); + weights_mem->fill(get_test_stream()); + get_test_stream().finish(); { - auto weights_ptr = weights_mem.pointer(); + cldnn::mem_lock weights_ptr(weights_mem, get_test_stream()); for (size_t fi = 0; fi < output_f; ++fi) { auto coords = tensor(batch(fi), feature(fi), spatial(0, 0, 0, 0)); auto offset = weights_lay.get_linear_offset(coords); @@ -724,7 +721,8 @@ struct concat_id_conv_gpu_4d : public concat_gpu { network.execute(); auto out_mem = network.get_output("conv").get_memory(); - auto out_ptr = out_mem.pointer(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); + ASSERT_EQ(out_mem->get_layout().format, fmt); for (size_t bi = 0; bi < batch_num; bi++) { size_t f_sum = 0; @@ -733,11 +731,11 @@ struct concat_id_conv_gpu_4d : public concat_gpu { for (size_t yi = 0; yi < input_y; yi++) { for (size_t xi = 0; xi < input_x; xi++) { auto output_coords = tensor(batch(bi), feature(f_sum + fi), spatial(xi, yi, 0, 0)); - auto output_offset = out_mem.get_layout().get_linear_offset(output_coords); + auto output_offset = out_mem->get_layout().get_linear_offset(output_coords); auto ref_val = in_data[in_i][bi][fi][yi][xi]; auto actual_val = static_cast(out_ptr[output_offset]); - EXPECT_EQ(ref_val, actual_val) + ASSERT_EQ(ref_val, actual_val) << " b=" << bi << ", f=" << f_sum + fi << "(input " << in_i << "), y=" << yi << ", x=" << xi; } } diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/condition_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/condition_gpu_test.cpp index 34a7c99dfb349c..c8c066e4948754 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/condition_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/condition_gpu_test.cpp @@ -3,31 +3,26 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "test_utils/test_utils.h" + +#include "test_utils.h" + +#include +#include +#include +#include +#include +#include +#include #include using namespace cldnn; using namespace ::tests; -bool is_output_equal(const cldnn::memory& mem, const std::vector& ref) +bool is_output_equal(const cldnn::memory::ptr mem, const std::vector& ref) { - auto ptr = mem.pointer(); - for (size_t i = 0; i < mem.get_layout().count(); i++) - { + cldnn::mem_lock ptr(mem, get_test_stream()); + for (size_t i = 0; i < mem->get_layout().count(); i++) { if (!are_equal(ptr[i], ref[i])) return false; } return true; @@ -36,14 +31,11 @@ bool is_output_equal(const cldnn::memory& mem, const std::vector& ref) topology generate_simple_branch (bool branch_true_false, const primitive_id& input_id) { topology branch; - if (branch_true_false) - { + if (branch_true_false) { branch.add( pooling(input_id + "_when_true", input_id, cldnn::pooling_mode::max, { 0, 0, 2, 1 }, { 0, 0, 2, 1 }) ); - } - else - { + } else { branch.add( pooling(input_id + "_when_false", input_id, cldnn::pooling_mode::average, { 0, 0, 2, 1 }, { 0, 0, 2, 1 }) ); @@ -52,29 +44,29 @@ topology generate_simple_branch (bool branch_true_false, const primitive_id& inp } TEST(DISABLED_condition_gpu, basic_equal_comp) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); build_options bs; bs.set_option(build_option::optimize_data(true)); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 4, 1 } }); - auto compare = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); - auto scale_mem = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); - + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 4, 1 } }); + auto compare = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto scale_mem = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + topology branch_true = generate_simple_branch(true, "condi"); topology branch_false = generate_simple_branch(false, "condi"); topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( - input_layout("compare", compare.get_layout()) - ); + input_layout("compare", compare->get_layout()) + ); topology.add( - input_layout("scale_data", scale_mem.get_layout()) + input_layout("scale_data", scale_mem->get_layout()) ); topology.add( condition("condi", "input", branch_true, branch_false, "compare", cond_functions::EQUAL) - ); + ); topology.add( scale("output", "condi", "scale_data") ); @@ -104,32 +96,31 @@ TEST(DISABLED_condition_gpu, basic_equal_comp) { } TEST(DISABLED_condition_gpu, basic_range_equal_comp) { - - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); build_options bs; bs.set_option(build_option::optimize_data(true)); - auto input0 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 4, 1 } }); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 4, 1 } }); + auto input0 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 4, 1 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 4, 1 } }); - auto compare = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 3, 1 } }); + auto compare = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 3, 1 } }); topology branch_true = generate_simple_branch(true, "condi"); topology branch_false = generate_simple_branch(false, "condi"); topology topology; topology.add( - input_layout("input0", input0.get_layout()) + input_layout("input0", input0->get_layout()) ); topology.add( - input_layout("input1", input1.get_layout()) + input_layout("input1", input1->get_layout()) ); topology.add( - input_layout("compare", compare.get_layout()) + input_layout("compare", compare->get_layout()) ); topology.add( concatenation("concat", { "input0", "input1" }, concatenation::along_x) ); - topology.add( + topology.add( condition("condi", "concat", branch_true, branch_false, "compare", cond_functions::EQUAL) ); @@ -182,14 +173,10 @@ std::pair, std::vector> get_values_to_compare(const cl std::vector ret_true; std::vector ret_false; auto mem_desc = generic_test::get_linear_memory_desc(input_lay); - for (int32_t b = 0; b < range.batch[0]; b++) - { - for (int32_t f = 0; f < range.feature[0]; f++) - { - for (int32_t y = 0; y < range.spatial[1]; y++) - { - for (int32_t x = 0; x < range.spatial[0]; x++) - { + for (int32_t b = 0; b < range.batch[0]; b++) { + for (int32_t f = 0; f < range.feature[0]; f++) { + for (int32_t y = 0; y < range.spatial[1]; y++) { + for (int32_t x = 0; x < range.spatial[0]; x++) { auto linear_idx = generic_test::get_linear_index( input_lay, offset.batch[0] + b, @@ -198,17 +185,16 @@ std::pair, std::vector> get_values_to_compare(const cl offset.spatial[0] + x, mem_desc); - switch (func) - { + switch (func) { case cond_functions::EQUAL: ret_true.push_back(values.at(linear_idx)); ret_false.push_back(-1.0f); break; - case cond_functions::GREATER: + case cond_functions::GREATER: ret_true.push_back(values.at(linear_idx) - 1.0f); ret_false.push_back(99.0f); break; - case cond_functions::LESS: + case cond_functions::LESS: ret_true.push_back(values.at(linear_idx) + 1.0f); ret_false.push_back(-1.0f); break; @@ -222,10 +208,10 @@ std::pair, std::vector> get_values_to_compare(const cl TEST(DISABLED_condition_gpu, generic_test_true_false) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); build_options bs; bs.set_option(build_option::optimize_data(true)); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 5, 2, 5, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 5, 2, 5, 1 } }); std::vector input_data(50); std::iota(input_data.begin(), input_data.end(), 0.0f); @@ -263,17 +249,14 @@ TEST(DISABLED_condition_gpu, generic_test_true_false) { 33, 36, 38, 41, 43, 46, 48 }; - for (auto const& func : functions) - { - for (auto const& range : ranges) - { - for (auto const& offset : offsets) - { - auto comp_values = get_values_to_compare(offset, range, input_data, input.get_layout(), func); + for (auto const& func : functions) { + for (auto const& range : ranges) { + for (auto const& offset : offsets) { + auto comp_values = get_values_to_compare(offset, range, input_data, input->get_layout(), func); auto comp_values_true = comp_values.first; auto comp_values_false = comp_values.second; - auto compare = memory::allocate(engine, { data_types::f32, format::bfyx, range }); + auto compare = engine.allocate_memory({ data_types::f32, format::bfyx, range }); topology branch_true; topology branch_false; @@ -286,10 +269,10 @@ TEST(DISABLED_condition_gpu, generic_test_true_false) { topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( - input_layout("compare", compare.get_layout()) + input_layout("compare", compare->get_layout()) ); topology.add( condition("condi", "input", branch_true, branch_false, "compare", func, offset) @@ -324,7 +307,7 @@ TEST(DISABLED_condition_gpu, generic_test_true_false) { TEST(DISABLED_condition_gpu, basic_stacked_ifs) { - /* + /* <...> @@ -333,14 +316,14 @@ TEST(DISABLED_condition_gpu, basic_stacked_ifs) { <...> - + */ - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); build_options bs; bs.set_option(build_option::optimize_data(true)); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 4, 1 } }); - auto compare = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); - auto compare2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 2, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 4, 1 } }); + auto compare = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto compare2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 2, 1 } }); topology condi_1_true = generate_simple_branch(true, "condi"); topology condi_1_false = generate_simple_branch(false, "condi"); @@ -355,16 +338,16 @@ TEST(DISABLED_condition_gpu, basic_stacked_ifs) { topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( - input_layout("compare", compare.get_layout()) + input_layout("compare", compare->get_layout()) ); topology.add( condition("condi", "input", condi_1_true, condi_1_false, "compare", cond_functions::EQUAL) ); topology.add( - input_layout("compare2", compare2.get_layout()) + input_layout("compare2", compare2->get_layout()) ); topology.add( condition("condi2", "condi", condi_2_true, condi_2_false, "compare2", cond_functions::GREATER) @@ -406,15 +389,15 @@ TEST(DISABLED_condition_gpu, basic_nested_ifs) { */ - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); build_options bs; bs.set_option(build_option::optimize_data(true)); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 4, 1 } }); - auto compare = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); - auto compare2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 2, 1 } }); - auto scale_5_mem = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 4, 1 } }); + auto compare = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto compare2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 2, 1 } }); + auto scale_5_mem = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); set_values(scale_5_mem, { 5.0f }); - auto scale_10_mem = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto scale_10_mem = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); set_values(scale_10_mem, { 10.0f }); topology nested_true; @@ -433,7 +416,7 @@ TEST(DISABLED_condition_gpu, basic_nested_ifs) { pooling("pooling_when_true", "condi", cldnn::pooling_mode::max, { 0, 0, 2, 1 }, { 0, 0, 2, 1 }) ); branch_true.add( - input_layout("compare2", compare2.get_layout()) + input_layout("compare2", compare2->get_layout()) ); branch_true.add( @@ -453,11 +436,11 @@ TEST(DISABLED_condition_gpu, basic_nested_ifs) { topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( - input_layout("compare", compare.get_layout()) + input_layout("compare", compare->get_layout()) ); topology.add( @@ -488,21 +471,21 @@ TEST(DISABLED_condition_gpu, basic_nested_ifs) { } TEST(DISABLED_condition_gpu, negative_compare_wrong_layout) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); build_options bs; bs.set_option(build_option::optimize_data(true)); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 4, 1 } }); - auto compare = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 5, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 4, 1 } }); + auto compare = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 5, 1 } }); topology branch_true = generate_simple_branch(true, "condi"); topology branch_false = generate_simple_branch(false, "condi"); topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( - input_layout("compare", compare.get_layout()) + input_layout("compare", compare->get_layout()) ); topology.add( condition("condi", "input", branch_true, branch_false, "compare", cond_functions::EQUAL) @@ -512,21 +495,21 @@ TEST(DISABLED_condition_gpu, negative_compare_wrong_layout) { } TEST(DISABLED_condition_gpu, negative_too_big_offset) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); build_options bs; bs.set_option(build_option::optimize_data(true)); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 4, 1 } }); - auto compare = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 3, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 4, 1 } }); + auto compare = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 3, 1 } }); topology branch_true = generate_simple_branch(true, "condi"); topology branch_false = generate_simple_branch(false, "condi"); topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( - input_layout("compare", compare.get_layout()) + input_layout("compare", compare->get_layout()) ); topology.add( condition("condi", "input", branch_true, branch_false, "compare", cond_functions::EQUAL, {1, 1, 2, 1}) @@ -536,12 +519,12 @@ TEST(DISABLED_condition_gpu, negative_too_big_offset) { } TEST(DISABLED_condition_gpu, negative_not_same_layouts) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); build_options bs; bs.set_option(build_option::optimize_data(true)); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 4, 1 } }); - auto compare = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); - + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 4, 1 } }); + auto compare = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + topology branch_true; branch_true.add( pooling("pooling_when_true", "condi", cldnn::pooling_mode::max, { 0, 0, 2, 1 }, { 0, 0, 2, 1 }) @@ -554,10 +537,10 @@ TEST(DISABLED_condition_gpu, negative_not_same_layouts) { topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( - input_layout("compare", compare.get_layout()) + input_layout("compare", compare->get_layout()) ); topology.add( condition("condi", "input", branch_true, branch_false, "compare", cond_functions::EQUAL) @@ -567,11 +550,11 @@ TEST(DISABLED_condition_gpu, negative_not_same_layouts) { } TEST(DISABLED_condition_gpu, negative_same_names_within_different_networks) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); build_options bs; bs.set_option(build_option::optimize_data(true)); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 4, 1 } }); - auto compare = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 4, 1 } }); + auto compare = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); topology branch_true; branch_true.add( @@ -585,10 +568,10 @@ TEST(DISABLED_condition_gpu, negative_same_names_within_different_networks) { topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( - input_layout("compare", compare.get_layout()) + input_layout("compare", compare->get_layout()) ); topology.add( condition("condi", "input", branch_true, branch_false, "compare", cond_functions::EQUAL) @@ -596,6 +579,6 @@ TEST(DISABLED_condition_gpu, negative_same_names_within_different_networks) { topology.add( pooling("pooling_check_name", "condi", cldnn::pooling_mode::max, { 0, 0, 2, 1 }, { 0, 0, 2, 1 }) ); - + EXPECT_ANY_THROW(network net(engine, topology, bs);); } diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/convolution_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/convolution_gpu_test.cpp index 66855dba938b0e..658bd6625f3403 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/convolution_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/convolution_gpu_test.cpp @@ -4,18 +4,15 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include "api/memory.hpp" -#include -#include "api/convolution.hpp" -#include "api/eltwise.hpp" -#include -#include -#include -#include "test_utils/test_utils.h" -#include "test_utils/float16.h" -#include +#include "test_utils.h" + +#include +#include +#include +#include +#include +#include + #include #include #include @@ -25,12 +22,9 @@ #include #include #include -#include -#include -#include using namespace cldnn; -using namespace tests; +using namespace ::tests; namespace cldnn { @@ -226,29 +220,23 @@ VVF reference_scale_post_op(const VVF& input, const T& scale, const T& shi return output_shrinked; } -void dump_buffer(memory const& mem, std::string const& name) -{ +void dump_buffer(memory::ptr mem, std::string const& name) { std::ofstream out(name); - auto size = mem.get_layout().get_buffer_size(); - auto ptr = mem.pointer(); - auto pitches = mem.get_layout().get_pitches(); - out << "Data size: " << mem.get_layout().size << "\n"; - out << "Lower padding: " << mem.get_layout().data_padding.lower_size() << "\n"; - out << "Upper padding: " << mem.get_layout().data_padding.upper_size() << "\n"; + auto size = mem->get_layout().get_buffer_size(); + cldnn::mem_lock ptr(mem, get_test_stream()); + auto pitches = mem->get_layout().get_pitches(); + out << "Data size: " << mem->get_layout().size << "\n"; + out << "Lower padding: " << mem->get_layout().data_padding.lower_size() << "\n"; + out << "Upper padding: " << mem->get_layout().data_padding.upper_size() << "\n"; out << "\n"; - for (int b = 0; b < size.batch[0]; ++b) - { + for (int b = 0; b < size.batch[0]; ++b) { out << " ================ BATCH " << b << " =================\n\n"; - for (int f = 0; f < size.feature[0]; ++f) - { + for (int f = 0; f < size.feature[0]; ++f) { out << "feature " << f << ":\n"; - for (int z = 0; z < size.spatial[2]; ++z) - { - for (int y = 0; y < size.spatial[1]; ++y) - { - for (int x = 0; x < size.spatial[0]; ++x) - { + for (int z = 0; z < size.spatial[2]; ++z) { + for (int y = 0; y < size.spatial[1]; ++y) { + for (int x = 0; x < size.spatial[0]; ++x) { size_t idx = b * pitches.batch[0] + f * pitches.feature[0] + z * pitches.spatial[2] + y * pitches.spatial[1] + x * pitches.spatial[0]; out << ptr[idx] << " "; } @@ -274,12 +262,12 @@ TEST(deformable_convolution_f32_fw_gpu, basic_deformable_convolution_def_group1_ // Group : 1 // Def_group: 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 4, 4, 4 } }); - auto trans = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 18, 4, 4 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 4, 4, 3, 3 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 4, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 4, 4, 4 } }); + auto trans = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 18, 4, 4 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 4, 4, 3, 3 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 4, 1, 1 } }); set_values(input, { 0.680375f, -0.211234f, 0.566198f, 0.59688f, 0.823295f, -0.604897f, -0.329554f, 0.536459f, -0.444451f, 0.10794f, -0.0452059f, 0.257742f, -0.270431f, 0.0268018f, 0.904459f, 0.83239f, @@ -350,8 +338,8 @@ TEST(deformable_convolution_f32_fw_gpu, basic_deformable_convolution_def_group1_ -2.6067f, 0.562893f, 0.671884f, 0.404735f, 1.45044f, 0.950113f }; topology topology( - input_layout("input", input.get_layout()), - input_layout("trans", trans.get_layout()), + input_layout("input", input->get_layout()), + input_layout("trans", trans->get_layout()), data("weights", weights), data("biases", biases), convolution( @@ -377,8 +365,8 @@ TEST(deformable_convolution_f32_fw_gpu, basic_deformable_convolution_def_group1_ EXPECT_EQ(outputs.begin()->first, "conv"); auto output_memory = outputs.at("conv").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -406,12 +394,12 @@ TEST(deformable_convolution_f32_fw_gpu, basic_deformable_convolution_def_group1) // Group : 1 // Def_group: 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 4, 4, 4 } }); - auto trans = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 18, 4, 4 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 4, 4, 3, 3 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 4, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 4, 4, 4 } }); + auto trans = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 18, 4, 4 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 4, 4, 3, 3 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 4, 1, 1 } }); set_values(input, { 0.680375f, -0.211234f, 0.566198f, 0.59688f, 0.823295f, -0.604897f, -0.329554f, 0.536459f, -0.444451f, 0.10794f, -0.0452059f, 0.257742f, -0.270431f, 0.0268018f, 0.904459f, 0.83239f, @@ -482,8 +470,8 @@ TEST(deformable_convolution_f32_fw_gpu, basic_deformable_convolution_def_group1) -0.210789f, -0.973089f, -0.407542f, 1.11818f, 0.843776f, 0.628229f, 1.29095f, 1.18637f, 0.808982f, 1.43841f }; topology topology( - input_layout("input", input.get_layout()), - input_layout("trans", trans.get_layout()), + input_layout("input", input->get_layout()), + input_layout("trans", trans->get_layout()), data("weights", weights), data("biases", biases), convolution( @@ -509,8 +497,8 @@ TEST(deformable_convolution_f32_fw_gpu, basic_deformable_convolution_def_group1) EXPECT_EQ(outputs.begin()->first, "conv"); auto output_memory = outputs.at("conv").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -538,12 +526,12 @@ TEST(deformable_convolution_f32_fw_gpu, basic_deformable_convolution) { // Group : 1 // Def_group: 2 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 4, 4, 4 } }); - auto trans = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 36, 4, 4 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 4, 4, 3, 3 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 4, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 4, 4, 4 } }); + auto trans = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 36, 4, 4 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 4, 4, 3, 3 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 4, 1, 1 } }); set_values(input, { 0.680375f, -0.211234f, 0.566198f, 0.59688f, 0.823295f, -0.604897f, -0.329554f, 0.536459f, -0.444451f, 0.10794f, -0.0452059f, 0.257742f, -0.270431f, 0.0268018f, 0.904459f, 0.83239f, @@ -646,8 +634,8 @@ TEST(deformable_convolution_f32_fw_gpu, basic_deformable_convolution) { 1.18929f, 0.382556f, 0.499048f, 1.16212f, 1.62688f, 1.31246f, 1.82684f }; topology topology( - input_layout("input", input.get_layout()), - input_layout("trans", trans.get_layout()), + input_layout("input", input->get_layout()), + input_layout("trans", trans->get_layout()), data("weights", weights), data("biases", biases), convolution( @@ -673,8 +661,8 @@ TEST(deformable_convolution_f32_fw_gpu, basic_deformable_convolution) { EXPECT_EQ(outputs.begin()->first, "conv"); auto output_memory = outputs.at("conv").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -711,10 +699,10 @@ TEST(convolution_f32_fw_gpu, basic_convolution_no_bias) { // 21 28 39 // 18 20 20 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32,format::yxfb,{ 1, 1, 5, 4 } }); - auto weights = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 1, 3, 2 } }); + auto input = engine.allocate_memory({ data_types::f32,format::yxfb,{ 1, 1, 5, 4 } }); + auto weights = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 1, 3, 2 } }); set_values(input, { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 2.0f, 2.0f, 3.0f, 4.0f, 6.0f, 3.0f, 3.0f, 3.0f, 5.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }); set_values(weights, { 1.0f, 2.0f, 1.0f, 2.0f, 1.0f, 2.0f }); @@ -723,7 +711,7 @@ TEST(convolution_f32_fw_gpu, basic_convolution_no_bias) { { 17.0f, 19.0f, 19.0f } }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), convolution("conv", "input", { "weights" }, { 1,1,1,2 })); @@ -735,8 +723,8 @@ TEST(convolution_f32_fw_gpu, basic_convolution_no_bias) { EXPECT_EQ(outputs.begin()->first, "conv"); auto output_memory = outputs.at("conv").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -782,10 +770,10 @@ TEST(convolution_f32_fw_gpu, basic_convolution_int8_no_bias) { // 21 28 39 // 18 20 20 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 1, 5, 4 } }); - auto weights = memory::allocate(engine, { data_types::i8,format::bfyx,{ 1, 1, 3, 2 } }); + auto input = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 1, 5, 4 } }); + auto weights = engine.allocate_memory({ data_types::i8,format::bfyx,{ 1, 1, 3, 2 } }); set_values(input, { 1.1f, 2.4f, 3.5f, 4.5f, 5.8f, 2.9f, 2.3f, 3.5f, 4.4f, 6.6f, @@ -798,7 +786,7 @@ TEST(convolution_f32_fw_gpu, basic_convolution_int8_no_bias) { { 22.0f, 20.0f, 21.0f } }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("to_int","input", { data_types::i8,format::bfyx,{ 1, 1, 5, 4 } }), data("weights", weights), convolution("conv", "to_int", { "weights" }, { 1,1,1,2 }), @@ -812,8 +800,8 @@ TEST(convolution_f32_fw_gpu, basic_convolution_int8_no_bias) { EXPECT_EQ(outputs.begin()->first, "output"); auto output_memory = outputs.at("output").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -839,10 +827,10 @@ TEST(convolution_f32_fw_gpu, basic_convolution3D_no_bias) { // Input : 4x5x1 // Output : 2x3x1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 5, 4 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 3, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 5, 4 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 3, 2 } }); set_values(input, { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 2.0f, 2.0f, 3.0f, 4.0f, 6.0f, 3.0f, 3.0f, 3.0f, 5.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }); set_values(weights, { 1.0f, 2.0f, 1.0f, 2.0f, 1.0f, 2.0f }); @@ -852,7 +840,7 @@ TEST(convolution_f32_fw_gpu, basic_convolution3D_no_bias) { { 17.0f, 19.0f, 19.0f } }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), convolution("conv", "input", { "weights" }, { 1,1,1,2 })); @@ -864,8 +852,8 @@ TEST(convolution_f32_fw_gpu, basic_convolution3D_no_bias) { EXPECT_EQ(outputs.begin()->first, "conv"); auto output_memory = outputs.at("conv").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int z_size = output_layout.size.spatial[2]; int y_size = output_layout.size.spatial[1]; @@ -934,11 +922,11 @@ TEST(convolution_f32_fw_gpu, basic_convolution3D) { // Bias: // 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 1, 1, 4, 4, 4 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 1, 1, 2, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 1, 1, 4, 4, 4 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 1, 1, 2, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1, 1 } }); set_values(input, { 1.0f, 0.0f, 1.0f, 0.0f, @@ -987,7 +975,7 @@ TEST(convolution_f32_fw_gpu, basic_convolution3D) { }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution("conv", "input", { "weights" }, { "biases" })); @@ -1000,8 +988,8 @@ TEST(convolution_f32_fw_gpu, basic_convolution3D) { EXPECT_EQ(outputs.begin()->first, "conv"); auto output_memory = outputs.at("conv").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int z_size = output_layout.size.spatial[2]; int y_size = output_layout.size.spatial[1]; @@ -1026,10 +1014,10 @@ TEST(convolution_f32_fw_gpu, basic_convolution3D) { TEST(convolution_f32_fw_gpu, basic_convolution3D_split2) { // data is similar as in basic_convolution3D - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 1, 2, 4, 4, 4 } }); - auto weights_1 = memory::allocate(engine, { data_types::f32, format::goizyx, tensor(cldnn::group(2), cldnn::batch(1), cldnn::feature(1), cldnn::spatial(2, 2, 2))}); - auto biases_1 = memory::allocate(engine, { data_types::f32, format::bfyx, tensor(feature(2)) }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 1, 2, 4, 4, 4 } }); + auto weights_1 = engine.allocate_memory({ data_types::f32, format::goizyx, tensor(cldnn::group(2), cldnn::batch(1), cldnn::feature(1), cldnn::spatial(2, 2, 2))}); + auto biases_1 = engine.allocate_memory({ data_types::f32, format::bfyx, tensor(feature(2)) }); set_values(input, { 1.0f, 0.0f, 1.0f, 0.0f, @@ -1117,7 +1105,7 @@ TEST(convolution_f32_fw_gpu, basic_convolution3D_split2) { }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights_1", weights_1), data("biases_1", biases_1), convolution("conv", "input", { "weights_1" }, { "biases_1" }, 2, tensor(1), tensor(0), tensor(1), tensor{1, 2, 3, 3, 3}, data_types::f32, true)); @@ -1130,8 +1118,8 @@ TEST(convolution_f32_fw_gpu, basic_convolution3D_split2) { EXPECT_EQ(outputs.begin()->first, "conv"); auto output_memory = outputs.at("conv").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int z_size = output_layout.size.spatial[2]; int y_size = output_layout.size.spatial[1]; @@ -1158,10 +1146,10 @@ TEST(convolution_f32_fw_gpu, basic_convolution3D_split2) { TEST(convolution_f32_fw_gpu, basic_convolution3D_group2) { // data is similar as in basic_convolution3D_split2 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 1, 2, 4, 4, 4 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 2, 1, 2, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 2, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 1, 2, 4, 4, 4 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 2, 1, 2, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 2, 1, 1, 1 } }); set_values(input, { 1.0f, 0.0f, 1.0f, 0.0f, @@ -1249,7 +1237,7 @@ TEST(convolution_f32_fw_gpu, basic_convolution3D_group2) { }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution("conv", "input", { "weights" }, { "biases" })); @@ -1262,8 +1250,8 @@ TEST(convolution_f32_fw_gpu, basic_convolution3D_group2) { EXPECT_EQ(outputs.begin()->first, "conv"); auto output_memory = outputs.at("conv").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int z_size = output_layout.size.spatial[2]; int y_size = output_layout.size.spatial[1]; @@ -1289,15 +1277,14 @@ TEST(convolution_f32_fw_gpu, basic_convolution3D_group2) { } TEST(convolution_f32_fw_gpu, with_output_size_same_input) { + auto& engine = get_test_engine(); - const auto& engine = get_test_engine(); - - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 4, 320, 320 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 64, 4, 7, 7 } }); - auto weights2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 64, 4, 7, 7 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 4, 320, 320 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 64, 4, 7, 7 } }); + auto weights2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 64, 4, 7, 7 } }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("weights2", weights2), convolution::create_with_output_size("conv1", "input", { "weights" }, {1, 64, 160, 160}, {1, 1, 2, 2}, {0, 0, -3, -3}), @@ -1329,16 +1316,16 @@ TEST(convolution_f32_fw_gpu, three_convolutions_same_weights) { // 8 8 8 8 // 8 8 8 8 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, {1,2,2,2} }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 2,2,1,1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, {1,2,2,2} }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 2,2,1,1 } }); set_values(input, { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }); set_values(weights, { 1.0f, 1.0f, 1.0f, 1.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), convolution("conv1", "input", { "weights" }), convolution("conv2", "conv1", { "weights" }), @@ -1353,8 +1340,8 @@ TEST(convolution_f32_fw_gpu, three_convolutions_same_weights) { auto outputs = network.execute(); auto output_memory = outputs.at("conv3").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -1397,11 +1384,11 @@ TEST(convolution_f32_fw_gpu, basic_convolution) { // Bias: // 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 3, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 3, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 2.0f, 2.0f, 3.0f, 4.0f, 6.0f, 3.0f, 3.0f, 3.0f, 5.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }); set_values(weights, { 1.0f, 2.0f, 1.0f, 2.0f, 1.0f, 2.0f }); @@ -1411,7 +1398,7 @@ TEST(convolution_f32_fw_gpu, basic_convolution) { { 18.0f, 20.0f, 20.0f } }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution( "conv", "input", { "weights" }, { "biases" }, { 0,0,1,2 })); @@ -1424,8 +1411,8 @@ TEST(convolution_f32_fw_gpu, basic_convolution) { EXPECT_EQ(outputs.begin()->first, "conv"); auto output_memory = outputs.at("conv").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -1445,14 +1432,14 @@ TEST(convolution_f32_fw_gpu, basic_convolution) { TEST(convolution_f32_fw_gpu, basic_convolution_bfyx_weights_as_input_layout) { //Same params as convolution_f32_fw_gpu, basic_convolution but with bfyx optimized data and weights set as input_layout - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 5, 4 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 3, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, @@ -1470,9 +1457,9 @@ TEST(convolution_f32_fw_gpu, basic_convolution_bfyx_weights_as_input_layout) { { 18.0f, 20.0f, 20.0f } }; topology topology( - input_layout("input", input.get_layout()), - input_layout("weights", weights.get_layout()), - input_layout("biases", biases.get_layout()), + input_layout("input", input->get_layout()), + input_layout("weights", weights->get_layout()), + input_layout("biases", biases->get_layout()), convolution("conv", "input", { "weights" } , @@ -1491,8 +1478,8 @@ TEST(convolution_f32_fw_gpu, basic_convolution_bfyx_weights_as_input_layout) { EXPECT_EQ(outputs.begin()->first, "conv"); auto output_memory = outputs.at("conv").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -1542,11 +1529,11 @@ TEST(convolution_f32_fw_gpu, basic_convolution_input_padding) { // Bias: // 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 4, 3 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 4, 3 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, { 1.0f, 2.0f, 3.0f, 4.0f, 2.0f, 2.0f, 3.0f, 4.0f, 3.0f, 3.0f, 3.0f, 5.0f }); set_values(weights, { 1.0f, 1.0f, 1.0f, 1.0f }); @@ -1560,7 +1547,7 @@ TEST(convolution_f32_fw_gpu, basic_convolution_input_padding) { { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f } }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution( @@ -1582,8 +1569,8 @@ TEST(convolution_f32_fw_gpu, basic_convolution_input_padding) { EXPECT_EQ(outputs.begin()->first, "conv"); auto output_memory = outputs.at("conv").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -1642,11 +1629,11 @@ TEST(convolution_f32_fw_gpu, basic_convolution_sym_input_padding) { // Bias: // 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 1, 4, 3 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 1, 4, 3 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); set_values(input, { 1.0f, 2.0f, 3.0f, 4.0f, 2.0f, 2.0f, 3.0f, 4.0f, 3.0f, 3.0f, 3.0f, 5.0f }); set_values(weights, { 1.0f, 1.0f, 1.0f, 1.0f }); @@ -1660,7 +1647,7 @@ TEST(convolution_f32_fw_gpu, basic_convolution_sym_input_padding) { { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f } }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution( @@ -1684,8 +1671,8 @@ TEST(convolution_f32_fw_gpu, basic_convolution_sym_input_padding) { EXPECT_EQ(outputs.begin()->first, "conv"); auto output_memory = outputs.at("conv").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -1738,11 +1725,11 @@ TEST(convolution_f32_fw_gpu, basic_convolution_asym_input_padding) { // Bias: // 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 1, 4, 3 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 1, 4, 3 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); set_values(input, { 1.0f, 2.0f, 3.0f, 4.0f, 2.0f, 2.0f, 3.0f, 4.0f, 3.0f, 3.0f, 3.0f, 5.0f }); set_values(weights, { 1.0f, 1.0f, 1.0f, 1.0f }); @@ -1757,7 +1744,7 @@ TEST(convolution_f32_fw_gpu, basic_convolution_asym_input_padding) { { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f } }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution( @@ -1781,8 +1768,8 @@ TEST(convolution_f32_fw_gpu, basic_convolution_asym_input_padding) { EXPECT_EQ(outputs.begin()->first, "conv"); auto output_memory = outputs.at("conv").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -1842,11 +1829,11 @@ TEST(convolution_f32_fw_gpu, basic_convolution_sym_input_padding_with_input_offs // Bias: // 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 1, 4, 3 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 1, 4, 3 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); set_values(input, { 1.0f, 2.0f, 3.0f, 4.0f, 2.0f, 2.0f, 3.0f, 4.0f, 3.0f, 3.0f, 3.0f, 5.0f }); set_values(weights, { 1.0f, 1.0f, 1.0f, 1.0f }); @@ -1864,7 +1851,7 @@ TEST(convolution_f32_fw_gpu, basic_convolution_sym_input_padding_with_input_offs { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f } }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution( @@ -1888,8 +1875,8 @@ TEST(convolution_f32_fw_gpu, basic_convolution_sym_input_padding_with_input_offs EXPECT_EQ(outputs.begin()->first, "conv"); auto output_memory = outputs.at("conv").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -1951,11 +1938,11 @@ TEST(convolution_f32_fw_gpu, basic_convolution_asym_input_padding_with_input_off // Bias: // 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 1, 4, 3 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 1, 4, 3 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); set_values(input, { 1.0f, 2.0f, 3.0f, 4.0f, 2.0f, 2.0f, 3.0f, 4.0f, 3.0f, 3.0f, 3.0f, 5.0f }); set_values(weights, { 1.0f, 1.0f, 1.0f, 1.0f }); @@ -1974,7 +1961,7 @@ TEST(convolution_f32_fw_gpu, basic_convolution_asym_input_padding_with_input_off { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f } }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution( @@ -1998,8 +1985,8 @@ TEST(convolution_f32_fw_gpu, basic_convolution_asym_input_padding_with_input_off EXPECT_EQ(outputs.begin()->first, "conv"); auto output_memory = outputs.at("conv").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -2052,11 +2039,11 @@ TEST(convolution_f32_fw_gpu, basic_convolution_input_and_output_padding) { // Bias: // 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 4, 3 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 4, 3 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, { 1.0f, 2.0f, 3.0f, 4.0f, 2.0f, 2.0f, 3.0f, 4.0f, 3.0f, 3.0f, 3.0f, 5.0f }); set_values(weights, { 1.0f, 1.0f, 1.0f, 1.0f }); @@ -2074,7 +2061,7 @@ TEST(convolution_f32_fw_gpu, basic_convolution_input_and_output_padding) { const int x_pad = 2; const int y_pad = 1; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution( @@ -2096,9 +2083,9 @@ TEST(convolution_f32_fw_gpu, basic_convolution_input_and_output_padding) { EXPECT_EQ(outputs.begin()->first, "conv"); auto output_memory = outputs.at("conv").get_memory(); - auto output_layout = output_memory.get_layout(); + auto output_layout = output_memory->get_layout(); auto output_size = output_layout.get_buffer_size(); - auto output_ptr = output_memory.pointer(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_size.spatial[1]; int x_size = output_size.spatial[0]; @@ -2165,19 +2152,19 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x1x1_nopad_random) { } VF output_rnd_vec = flatten_4d(format::yxfb, output_rnd); - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 4, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 4, 4 } }); //auto output = memory::allocate({ memory::format::yxfb_f32,{ 1,{ 2, 2 }, 1 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, input_rnd_vec); set_values(weights, filter_rnd_vec); set_values(biases, bias_rnd); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution("conv", "input", {"weights"}, {"biases"}, {1,1,2,2}) @@ -2192,7 +2179,7 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x1x1_nopad_random) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); for (size_t i = 0; i < output_rnd.size(); ++i) { float x = float_round(output_rnd_vec[i]), y = float_round(output_ptr[i]); @@ -2235,19 +2222,19 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in2x2x1x2_nopad_random) { } VF output_rnd_vec = flatten_4d(format::yxfb, output_rnd); - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 1, 2, 2 } }); //auto output = memory::allocate({ memory::format::yxfb_f32,{ 2,{ 1, 1 }, 1 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, input_rnd_vec); set_values(weights, filter_rnd_vec); set_values(biases, bias_rnd); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution("conv", "input", { "weights" }, { "biases" }, { 1,1,2,2 }) @@ -2262,7 +2249,7 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in2x2x1x2_nopad_random) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); for (size_t i = 0; i < output_rnd.size(); ++i) { float x = float_round(output_rnd_vec[i]), y = float_round(output_ptr[i]); @@ -2293,19 +2280,19 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x1x1_nopad) { // 8 0.5 // 6 9 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 4, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 4, 4 } }); //auto output = memory::allocate({ memory::format::yxfb_f32,{ 1,{ 2, 2 }, 1 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, { -0.5f, 1.0f, 0.5f, 2.0f, 1.5f, -0.5f, 0.0f, -1.0f, 0.5f, 0.5f, -1.0f, 1.0f, 0.5f, 2.0f, 1.5f, -0.5f }); set_values(weights, { -2.0f, 0.5f, 3.5f, 1.5f }); set_values(biases, { 2.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution("conv", "input", { "weights" }, { "biases" }, { 1,1,2,2 }) @@ -2320,7 +2307,7 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x1x1_nopad) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); EXPECT_FLOAT_EQ(8.0f, output_ptr[0]); EXPECT_FLOAT_EQ(0.5f, output_ptr[1]); @@ -2347,19 +2334,19 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in2x2x1x2_nopad) { // // Output: // 3.65 -5.36 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 1, 2, 2 } }); //auto output = memory::allocate({ memory::format::yxfb_f32,{ 2,{ 1, 1 }, 1 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, { 0.5f, 2.3f, 1.5f, -0.4f, 2.0f, 1.0f, -4.0f, 3.0f }); set_values(weights, { -1.2f, 1.5f, 0.5f, -0.5f }); set_values(biases, { -1.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution("conv", "input", { "weights" }, { "biases" }, { 1,1,2,2 } ) @@ -2374,7 +2361,7 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in2x2x1x2_nopad) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); EXPECT_FLOAT_EQ(3.65f, output_ptr[0]); EXPECT_FLOAT_EQ(-5.36f, output_ptr[1]); @@ -2399,19 +2386,19 @@ TEST(convolution_f32_fw_gpu, basic_ofm_wsiz2x1x2x1_in1x2x1_nopad) { // 5.1 f=0 // -5.2 f=1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 1, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 1, 2 } }); //auto output = memory::allocate({ memory::format::yxfb_f32,{ 1 ,{ 1, 1 }, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 1, 1, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 1, 1, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); set_values(input, { 1.0f, 2.0f }); set_values(weights, { 1.0f, 2.0f, -1.0f, -2.0f }); set_values(biases, { 0.1f, -0.2f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution("conv", "input", { "weights" }, { "biases" }, { 1,1,5,5 }) @@ -2426,7 +2413,7 @@ TEST(convolution_f32_fw_gpu, basic_ofm_wsiz2x1x2x1_in1x2x1_nopad) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); EXPECT_FLOAT_EQ(5.1f, output_ptr[0]); EXPECT_FLOAT_EQ(-5.2f, output_ptr[1]); @@ -2458,19 +2445,19 @@ TEST(convolution_f32_fw_gpu, basic_ofm_wsiz3x2x2x1_in2x2x1_nopad) { // 64,0 f=1 // 103.0 f=2 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 2, 1, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 2, 1, 2 } }); //auto output = memory::allocate({ memory::format::yxfb_f32,{ 1 ,{ 1, 1 }, 3 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 3, 2, 1, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 3, 1, 1 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 3, 2, 1, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 3, 1, 1 } }); set_values(input, { 1.0f, 3.0f, 2.0f, 4.0f }); set_values(weights, { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f }); set_values(biases, { -5.0f, -6.0f, -7.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution("conv", "input", { "weights" }, { "biases" }, { 1,1,5,5 }) @@ -2485,7 +2472,7 @@ TEST(convolution_f32_fw_gpu, basic_ofm_wsiz3x2x2x1_in2x2x1_nopad) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); EXPECT_FLOAT_EQ(25.0f, output_ptr[0]); EXPECT_FLOAT_EQ(64.0f, output_ptr[1]); @@ -2514,19 +2501,19 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2x1x3_wstr2x2_in2x2x1x1_nopad) { // 2.12 // 3.08 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); //auto output = memory::allocate({ memory::format::yxfb_f32,{ 1 ,{ 1, 1 }, 3 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 3, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 3, 1, 1 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 3, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 3, 1, 1 } }); set_values(input, { -2.3f, -0.1f, 3.1f, 1.9f }); set_values(weights, { -1.1f, 1.5f, 0.5f, -0.5f, 0.1f, 0.2f, 0.4f, 0.7f, 2.0f, -1.0f, 2.5f, -1.5f }); set_values(biases, { 0.1f, -0.2f, 0.3f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution("conv", "input", { "weights" }, { "biases" }, { 1,1,2,2 }) @@ -2541,7 +2528,7 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2x1x3_wstr2x2_in2x2x1x1_nopad) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); EXPECT_TRUE(are_equal(3.08f, output_ptr[0])); EXPECT_TRUE(are_equal(2.12f, output_ptr[1])); @@ -2570,19 +2557,19 @@ TEST(convolution_f32_fw_gpu, wsiz3x3_wstr2x2_in2x2x1x1_zeropad) { // // Output: // 12.25 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); //auto output = memory::allocate({ memory::format::yxfb_f32,{ 1,{ 1, 1 }, 1 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 3, 3 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 3, 3 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, { -0.5f, 1.0f, 0.5f, 2.0f }); set_values(weights, { -2.0f, 0.5f, 3.5f, 1.5f, 4.0f, -5.0f, 0.5f, 1.5f, -1.5f }); set_values(biases, { 2.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution("conv", "input", { "weights" }, { "biases" }, { 1,1,2,2 }) @@ -2597,7 +2584,7 @@ TEST(convolution_f32_fw_gpu, wsiz3x3_wstr2x2_in2x2x1x1_zeropad) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); EXPECT_FLOAT_EQ(12.25f, output_ptr[0]); } @@ -2627,19 +2614,19 @@ TEST(convolution_f32_fw_gpu, offsets_wsiz3x3_wstr2x2_in2x2x1x1_zeropad) { // Output: // rnd rnd // rnd 2.0 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); //auto output = memory::allocate({ memory::format::yxfb_f32,{ 1 ,{ 2, 2 }, 1 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 3, 3 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 3, 3 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, { -0.5f, 1.0f, 0.5f, 2.0f }); set_values(weights, { -2.0f, 0.5f, 3.5f, 1.5f, 4.0f, -5.0f, 0.5f, 1.5f, -1.5f }); set_values(biases, { 2.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution( @@ -2662,7 +2649,7 @@ TEST(convolution_f32_fw_gpu, offsets_wsiz3x3_wstr2x2_in2x2x1x1_zeropad) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); EXPECT_FLOAT_EQ(-7.25f, output_ptr[4]); } @@ -2702,12 +2689,12 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x1_nopad_split2) { // 8 3.65 0.5 -5.36 // 6 3.65 9 -5.36 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 2, 4, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 2, 4, 4 } }); //auto output = memory::allocate({ memory::format::yxfb_f32,{ 1,{ 2, 2 }, 2 } }); - auto weights1 = memory::allocate(engine, { data_types::f32, format::goiyx, tensor(group(2), batch(1), feature(1), spatial(2,2))}); - auto biases1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); + auto weights1 = engine.allocate_memory({ data_types::f32, format::goiyx, tensor(group(2), batch(1), feature(1), spatial(2,2))}); + auto biases1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); set_values(input, { -0.5f, 0.5f, 1.0f, 1.5f, 0.5f, 2.3f, 2.0f, -0.4f, @@ -2719,7 +2706,7 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x1_nopad_split2) { set_values(biases1, { 2.0f, -1.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights1", weights1), data("biases1", biases1), convolution( @@ -2742,16 +2729,16 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x1_nopad_split2) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); - EXPECT_FLOAT_EQ(8.0f, get_value(output_ptr, 0)); - EXPECT_FLOAT_EQ(3.65f, get_value(output_ptr, 1)); - EXPECT_FLOAT_EQ(0.5f, get_value(output_ptr, 2)); - EXPECT_FLOAT_EQ(-5.36f, get_value(output_ptr, 3)); - EXPECT_FLOAT_EQ(6.0f, get_value(output_ptr, 4)); - EXPECT_FLOAT_EQ(3.65f, get_value(output_ptr, 5)); - EXPECT_FLOAT_EQ(9.0f, get_value(output_ptr, 6)); - EXPECT_FLOAT_EQ(-5.36f, get_value(output_ptr, 7)); + EXPECT_FLOAT_EQ(8.0f, output_ptr[0]); + EXPECT_FLOAT_EQ(3.65f, output_ptr[1]); + EXPECT_FLOAT_EQ(0.5f, output_ptr[2]); + EXPECT_FLOAT_EQ(-5.36f, output_ptr[3]); + EXPECT_FLOAT_EQ(6.0f, output_ptr[4]); + EXPECT_FLOAT_EQ(3.65f, output_ptr[5]); + EXPECT_FLOAT_EQ(9.0f, output_ptr[6]); + EXPECT_FLOAT_EQ(-5.36f, output_ptr[7]); } TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_split2) { @@ -2800,12 +2787,12 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_split2) { // 8 8 3.65 3.65 0.5 0.5 -5.36 -5.36 // 6 6 3.65 3.65 9 9 -5.36 -5.36 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 4, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 4, 4 } }); //auto output = memory::allocate({ memory::format::yxfb_f32,{ 2,{ 2, 2 }, 2 } }); - auto weights1 = memory::allocate(engine, { data_types::f32, format::goiyx, tensor(group(2), batch(1), feature(1), spatial(2,2)) }); - auto biases1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); + auto weights1 = engine.allocate_memory({ data_types::f32, format::goiyx, tensor(group(2), batch(1), feature(1), spatial(2,2)) }); + auto biases1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); set_values(input, { -0.5f, -0.5f, 0.5f, 0.5f, 1.0f, 1.0f, 1.5f, 1.5f, 0.5f, 0.5f, 2.3f, 2.3f, 2.0f, 2.0f, -0.4f, -0.4f, @@ -2817,7 +2804,7 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_split2) { set_values(biases1, { 2.0f, -1.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights1", weights1), data("biases1", biases1), convolution( @@ -2840,33 +2827,33 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_split2) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); - - EXPECT_FLOAT_EQ(8.0f, get_value(output_ptr, 0)); - EXPECT_FLOAT_EQ(8.0f, get_value(output_ptr, 1)); - EXPECT_FLOAT_EQ(3.65f, get_value(output_ptr, 2)); - EXPECT_FLOAT_EQ(3.65f, get_value(output_ptr, 3)); - EXPECT_FLOAT_EQ(0.5f, get_value(output_ptr, 4)); - EXPECT_FLOAT_EQ(0.5f, get_value(output_ptr, 5)); - EXPECT_FLOAT_EQ(-5.36f, get_value(output_ptr, 6)); - EXPECT_FLOAT_EQ(-5.36f, get_value(output_ptr, 7)); - EXPECT_FLOAT_EQ(6.0f, get_value(output_ptr, 8)); - EXPECT_FLOAT_EQ(6.0f, get_value(output_ptr, 9)); - EXPECT_FLOAT_EQ(3.65f, get_value(output_ptr, 10)); - EXPECT_FLOAT_EQ(3.65f, get_value(output_ptr, 11)); - EXPECT_FLOAT_EQ(9.0f, get_value(output_ptr, 12)); - EXPECT_FLOAT_EQ(9.0f, get_value(output_ptr, 13)); - EXPECT_FLOAT_EQ(-5.36f, get_value(output_ptr, 14)); - EXPECT_FLOAT_EQ(-5.36f, get_value(output_ptr, 15)); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); + + EXPECT_FLOAT_EQ(8.0f, output_ptr[0]); + EXPECT_FLOAT_EQ(8.0f, output_ptr[1]); + EXPECT_FLOAT_EQ(3.65f, output_ptr[2]); + EXPECT_FLOAT_EQ(3.65f, output_ptr[3]); + EXPECT_FLOAT_EQ(0.5f, output_ptr[4]); + EXPECT_FLOAT_EQ(0.5f, output_ptr[5]); + EXPECT_FLOAT_EQ(-5.36f, output_ptr[6]); + EXPECT_FLOAT_EQ(-5.36f, output_ptr[7]); + EXPECT_FLOAT_EQ(6.0f, output_ptr[8]); + EXPECT_FLOAT_EQ(6.0f, output_ptr[9]); + EXPECT_FLOAT_EQ(3.65f, output_ptr[10]); + EXPECT_FLOAT_EQ(3.65f, output_ptr[11]); + EXPECT_FLOAT_EQ(9.0f, output_ptr[12]); + EXPECT_FLOAT_EQ(9.0f, output_ptr[13]); + EXPECT_FLOAT_EQ(-5.36f, output_ptr[14]); + EXPECT_FLOAT_EQ(-5.36f, output_ptr[15]); } TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x1_nopad_group2) { // data is similar as in basic_wsiz2x2_wstr2x2_in4x4x2x1_nopad_split2 - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 2, 4, 4 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::goiyx ,tensor(group(2), batch(1), feature(1), spatial(2,2)) }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 2, 4, 4 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::goiyx ,tensor(group(2), batch(1), feature(1), spatial(2,2)) }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); set_values(input, { -0.5f, 0.5f, 1.0f, 1.5f, 0.5f, 2.3f, 2.0f, -0.4f, @@ -2881,7 +2868,7 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x1_nopad_group2) { set_values(biases, { 2.0f, -1.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution( @@ -2904,26 +2891,26 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x1_nopad_group2) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); - EXPECT_FLOAT_EQ(8.0f, get_value(output_ptr, 0)); - EXPECT_FLOAT_EQ(3.65f, get_value(output_ptr, 1)); - EXPECT_FLOAT_EQ(0.5f, get_value(output_ptr, 2)); - EXPECT_FLOAT_EQ(-5.36f, get_value(output_ptr, 3)); - EXPECT_FLOAT_EQ(6.0f, get_value(output_ptr, 4)); - EXPECT_FLOAT_EQ(3.65f, get_value(output_ptr, 5)); - EXPECT_FLOAT_EQ(9.0f, get_value(output_ptr, 6)); - EXPECT_FLOAT_EQ(-5.36f, get_value(output_ptr, 7)); + EXPECT_FLOAT_EQ(8.0f, output_ptr[0]); + EXPECT_FLOAT_EQ(3.65f, output_ptr[1]); + EXPECT_FLOAT_EQ(0.5f, output_ptr[2]); + EXPECT_FLOAT_EQ(-5.36f, output_ptr[3]); + EXPECT_FLOAT_EQ(6.0f, output_ptr[4]); + EXPECT_FLOAT_EQ(3.65f, output_ptr[5]); + EXPECT_FLOAT_EQ(9.0f, output_ptr[6]); + EXPECT_FLOAT_EQ(-5.36f, output_ptr[7]); } TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x1_nopad_group2_bfyx) { // data is similar as in basic_wsiz2x2_wstr2x2_in4x4x2x1_nopad_split2 - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 2, 4, 4 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::goiyx ,tensor(group(2), batch(1), feature(1), spatial(2,2)) }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 2, 4, 4 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::goiyx ,tensor(group(2), batch(1), feature(1), spatial(2,2)) }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); set_values(input, { -0.5f, 0.5f, 1.0f, 1.5f, 0.5f, 2.3f, 2.0f, -0.4f, @@ -2938,7 +2925,7 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x1_nopad_group2_bfyx) set_values(biases, { 2.0f, -1.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("input_1", "input", { data_types::f32,format::bfyx,{ 1, 2, 4, 4 } }), data("weights", weights), data("biases", biases), @@ -2962,26 +2949,26 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x1_nopad_group2_bfyx) auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); - EXPECT_FLOAT_EQ(8.0f, get_value(output_ptr, 0)); - EXPECT_FLOAT_EQ(0.5f, get_value(output_ptr, 1)); - EXPECT_FLOAT_EQ(6.0f, get_value(output_ptr, 2)); - EXPECT_FLOAT_EQ(9.0f, get_value(output_ptr, 3)); - EXPECT_FLOAT_EQ(3.65f, get_value(output_ptr, 4)); - EXPECT_FLOAT_EQ(-5.36f, get_value(output_ptr, 5)); - EXPECT_FLOAT_EQ(3.65f, get_value(output_ptr, 6)); - EXPECT_FLOAT_EQ(-5.36f, get_value(output_ptr, 7)); + EXPECT_FLOAT_EQ(8.0f, output_ptr[0]); + EXPECT_FLOAT_EQ(0.5f, output_ptr[1]); + EXPECT_FLOAT_EQ(6.0f, output_ptr[2]); + EXPECT_FLOAT_EQ(9.0f, output_ptr[3]); + EXPECT_FLOAT_EQ(3.65f, output_ptr[4]); + EXPECT_FLOAT_EQ(-5.36f, output_ptr[5]); + EXPECT_FLOAT_EQ(3.65f, output_ptr[6]); + EXPECT_FLOAT_EQ(-5.36f, output_ptr[7]); } TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_group2) { // data is similar as in basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_split2 - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 4, 4 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::goiyx ,tensor(group(2), batch(1), feature(1), spatial(2,2)) }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 4, 4 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::goiyx ,tensor(group(2), batch(1), feature(1), spatial(2,2)) }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); set_values(input, { -0.5f, -0.5f, 0.5f, 0.5f, 1.0f, 1.0f, 1.5f, 1.5f, 0.5f, 0.5f, 2.3f, 2.3f, 2.0f, 2.0f, -0.4f, -0.4f, @@ -2996,7 +2983,7 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_group2) { set_values(biases, { 2.0f, -1.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution( @@ -3019,33 +3006,33 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_group2) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); - - EXPECT_FLOAT_EQ(8.0f, get_value(output_ptr, 0)); - EXPECT_FLOAT_EQ(8.0f, get_value(output_ptr, 1)); - EXPECT_FLOAT_EQ(3.65f, get_value(output_ptr, 2)); - EXPECT_FLOAT_EQ(3.65f, get_value(output_ptr, 3)); - EXPECT_FLOAT_EQ(0.5f, get_value(output_ptr, 4)); - EXPECT_FLOAT_EQ(0.5f, get_value(output_ptr, 5)); - EXPECT_FLOAT_EQ(-5.36f, get_value(output_ptr, 6)); - EXPECT_FLOAT_EQ(-5.36f, get_value(output_ptr, 7)); - EXPECT_FLOAT_EQ(6.0f, get_value(output_ptr, 8)); - EXPECT_FLOAT_EQ(6.0f, get_value(output_ptr, 9)); - EXPECT_FLOAT_EQ(3.65f, get_value(output_ptr, 10)); - EXPECT_FLOAT_EQ(3.65f, get_value(output_ptr, 11)); - EXPECT_FLOAT_EQ(9.0f, get_value(output_ptr, 12)); - EXPECT_FLOAT_EQ(9.0f, get_value(output_ptr, 13)); - EXPECT_FLOAT_EQ(-5.36f, get_value(output_ptr, 14)); - EXPECT_FLOAT_EQ(-5.36f, get_value(output_ptr, 15)); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); + + EXPECT_FLOAT_EQ(8.0f, output_ptr[0]); + EXPECT_FLOAT_EQ(8.0f, output_ptr[1]); + EXPECT_FLOAT_EQ(3.65f, output_ptr[2]); + EXPECT_FLOAT_EQ(3.65f, output_ptr[3]); + EXPECT_FLOAT_EQ(0.5f, output_ptr[4]); + EXPECT_FLOAT_EQ(0.5f, output_ptr[5]); + EXPECT_FLOAT_EQ(-5.36f, output_ptr[6]); + EXPECT_FLOAT_EQ(-5.36f, output_ptr[7]); + EXPECT_FLOAT_EQ(6.0f, output_ptr[8]); + EXPECT_FLOAT_EQ(6.0f, output_ptr[9]); + EXPECT_FLOAT_EQ(3.65f, output_ptr[10]); + EXPECT_FLOAT_EQ(3.65f, output_ptr[11]); + EXPECT_FLOAT_EQ(9.0f, output_ptr[12]); + EXPECT_FLOAT_EQ(9.0f, output_ptr[13]); + EXPECT_FLOAT_EQ(-5.36f, output_ptr[14]); + EXPECT_FLOAT_EQ(-5.36f, output_ptr[15]); } TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_split2_depthwise_sep_opt) { // Test for depthwise separable optimization, there are 16 weights and biases (split 16) // data is similar as in basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_split2 but with batch 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 16, 4, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 16, 4, 4 } }); set_values(input, { -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, @@ -3066,8 +3053,8 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_split2_depthw -0.5f, -0.5f, 3.0f, 3.0f, -0.5f, -0.5f, 3.0f, 3.0f, -0.5f, -0.5f, 3.0f, 3.0f, -0.5f, -0.5f, 3.0f, 3.0f, -0.5f, -0.5f, 3.0f, 3.0f, -0.5f, -0.5f, 3.0f, 3.0f, -0.5f, -0.5f, 3.0f, 3.0f, -0.5f, -0.5f, 3.0f, 3.0f, }); - auto weights1 = memory::allocate(engine, { data_types::f32, format::goiyx ,tensor(group(16), batch(1), feature(1), spatial(2,2)) }); - auto biases1 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 16, 1, 1 } }); + auto weights1 = engine.allocate_memory({ data_types::f32, format::goiyx ,tensor(group(16), batch(1), feature(1), spatial(2,2)) }); + auto biases1 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 16, 1, 1 } }); set_values(weights1, { -2.0f, 0.5f, 3.5f, 1.5f, -1.2f, 1.5f, 0.5f, -0.5f, -2.0f, 0.5f, 3.5f, 1.5f, -1.2f, 1.5f, 0.5f, -0.5f, @@ -3091,7 +3078,7 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_split2_depthw primitive_id bias_id = "biases1"; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data(weights_id, weights1), data(bias_id, biases1), convolution( @@ -3114,7 +3101,7 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_split2_depthw auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); std::vector expected_output_vec = { 8.0f, 8.0f, 3.65f, 3.65f, 8.0f, 8.0f, 3.65f, 3.65f, 8.0f, 8.0f, 3.65f, 3.65f, 8.0f, 8.0f, 3.65f, 3.65f, 8.0f, 8.0f, 3.65f, 3.65f, 8.0f, 8.0f, 3.65f, 3.65f, 8.0f, 8.0f, 3.65f, 3.65f, 8.0f, 8.0f, 3.65f, 3.65f, @@ -3132,9 +3119,9 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_split2_depthw TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_split2_depthwise_sep_opt_bfyx) { // Test for depthwise separable optimization, there are 16 weights and biases (split 16) // data is similar as in basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_split2 but with batch 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 16, 4, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 16, 4, 4 } }); set_values(input, { -0.5f, 1.0f, 0.5f, 2.0f, 1.5f, -0.5f, 0.0f, -1.0f, 0.5f, 0.5f, -1.0f, 1.0f, 0.5f, 2.0f, 1.5f, -0.5f, @@ -3155,8 +3142,8 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_split2_depthw 0.5f, 1.5f, 2.3f, -0.4f, 2.0f, -4.0f, 1.0f, 3.0f, 0.5f, 1.5f, 2.3f, -0.4f, 2.0f, -4.0f, 1.0f, 3.0f, }); - auto weights1 = memory::allocate(engine, { data_types::f32, format::goiyx ,tensor(group(16), batch(1), feature(1), spatial(2,2)) }); - auto biases1 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 16, 1, 1 } }); + auto weights1 = engine.allocate_memory({ data_types::f32, format::goiyx ,tensor(group(16), batch(1), feature(1), spatial(2,2)) }); + auto biases1 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 16, 1, 1 } }); set_values(weights1, { -2.0f, 0.5f, 3.5f, 1.5f, -1.2f, 1.5f, 0.5f, -0.5f, -2.0f, 0.5f, 3.5f, 1.5f, -1.2f, 1.5f, 0.5f, -0.5f, @@ -3180,7 +3167,7 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_split2_depthw primitive_id bias_id = "biases1"; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data(weights_id, weights1), data(bias_id, biases1), convolution( @@ -3203,7 +3190,7 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_split2_depthw auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); std::vector expected_output_vec = { 8.0f, 0.5f, 6.0f, 9.0f, 3.65f,-5.36f, 3.65f, -5.36f, @@ -3226,9 +3213,9 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_group16) { // Test for grouped convolution, there are 16 joined weights and biases (group 16) // data is similar as in basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_split2_depthwise_sep_opt - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 16, 4, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 16, 4, 4 } }); set_values(input, { -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, @@ -3249,10 +3236,10 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_group16) { -0.5f, -0.5f, 3.0f, 3.0f, -0.5f, -0.5f, 3.0f, 3.0f, -0.5f, -0.5f, 3.0f, 3.0f, -0.5f, -0.5f, 3.0f, 3.0f, -0.5f, -0.5f, 3.0f, 3.0f, -0.5f, -0.5f, 3.0f, 3.0f, -0.5f, -0.5f, 3.0f, 3.0f, -0.5f, -0.5f, 3.0f, 3.0f, }); - topology topology(input_layout("input", input.get_layout())); + topology topology(input_layout("input", input->get_layout())); - auto weights = memory::allocate(engine, { data_types::f32, format::goiyx ,tensor(group(16), batch(1), feature(1), spatial(2,2)) }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 16, 1, 1 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::goiyx ,tensor(group(16), batch(1), feature(1), spatial(2,2)) }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 16, 1, 1 } }); set_values(weights, { @@ -3302,7 +3289,7 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_group16) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); std::vector expected_output_vec = { 8.0f, 8.0f, 3.65f, 3.65f, 8.0f, 8.0f, 3.65f, 3.65f, 8.0f, 8.0f, 3.65f, 3.65f, 8.0f, 8.0f, 3.65f, 3.65f, 8.0f, 8.0f, 3.65f, 3.65f, 8.0f, 8.0f, 3.65f, 3.65f, 8.0f, 8.0f, 3.65f, 3.65f, 8.0f, 8.0f, 3.65f, 3.65f, @@ -3320,9 +3307,9 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_group16) { TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_group16_bfyx) { // Test for grouped convolution, there are 16 joined weights and biases (group 16) // data is similar as in basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_split2_depthwise_sep_opt_bfyx - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 16, 4, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 16, 4, 4 } }); set_values(input, { -0.5f, 1.0f, 0.5f, 2.0f, 1.5f, -0.5f, 0.0f, -1.0f, 0.5f, 0.5f, -1.0f, 1.0f, 0.5f, 2.0f, 1.5f, -0.5f, @@ -3343,10 +3330,10 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_group16_bfyx) 0.5f, 1.5f, 2.3f, -0.4f, 2.0f, -4.0f, 1.0f, 3.0f, 0.5f, 1.5f, 2.3f, -0.4f, 2.0f, -4.0f, 1.0f, 3.0f, }); - topology topology(input_layout("input", input.get_layout())); + topology topology(input_layout("input", input->get_layout())); - auto weights = memory::allocate(engine, { data_types::f32, format::goiyx ,tensor(group(16), batch(1), feature(1), spatial(2,2)) }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 16, 1, 1 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::goiyx ,tensor(group(16), batch(1), feature(1), spatial(2,2)) }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 16, 1, 1 } }); set_values(weights, { @@ -3397,7 +3384,7 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_group16_bfyx) auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); std::vector expected_output_vec = { 8.0f, 0.5f, 6.0f, 9.0f, 3.65f,-5.36f, 3.65f, -5.36f, @@ -3450,14 +3437,14 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_group16_bfyx) // -1.75 // 2.25 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 4, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 4, 1, 1 } }); //auto output = memory::allocate({ memory::format::yxfb_f32,{ 1,{ 1, 1 }, 4 } }); - auto weights1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); - auto biases1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); - auto weights2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); - auto biases2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); + auto weights1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); + auto biases1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); + auto weights2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); + auto biases2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); set_values(input, { 1.5f, 0.5f, 0.0f, -0.5f @@ -3468,7 +3455,7 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_group16_bfyx) set_values(biases2, { -1.0f, 2.5f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights1", weights1), data("biases1", biases1), data("weights2", weights2), @@ -3492,12 +3479,12 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x2x2_nopad_group16_bfyx) auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); - EXPECT_FLOAT_EQ(-2.25f, get_value(output_ptr, 0)); - EXPECT_FLOAT_EQ(7.5f, get_value(output_ptr, 1)); - EXPECT_FLOAT_EQ(-1.75f, get_value(output_ptr, 2)); - EXPECT_FLOAT_EQ(2.25f, get_value(output_ptr, 3)); + EXPECT_FLOAT_EQ(-2.25f, output_ptr[0]); + EXPECT_FLOAT_EQ(7.5f, output_ptr[1]); + EXPECT_FLOAT_EQ(-1.75f, output_ptr[2]); + EXPECT_FLOAT_EQ(2.25f, output_ptr[3]); } TEST(convolution_f32_fw_gpu, basic_wsiz1x1_wstr2x2_in1x1x2x1_nopad_split2) { @@ -3531,14 +3518,14 @@ TEST(convolution_f32_fw_gpu, basic_wsiz1x1_wstr2x2_in1x1x2x1_nopad_split2) { // 1 // 3.5 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 2, 1, 1 } }); //auto output = memory::allocate({ memory::format::yxfb_f32,{ 1,{ 1, 1 }, 4 } }); - auto weights1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 1, 1, 1 } }); - auto biases1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); - auto weights2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 1, 1, 1 } }); - auto biases2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); + auto weights1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 1, 1, 1 } }); + auto biases1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); + auto weights2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 1, 1, 1 } }); + auto biases2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); set_values(input, { 1.5f, 0.5f @@ -3549,7 +3536,7 @@ TEST(convolution_f32_fw_gpu, basic_wsiz1x1_wstr2x2_in1x1x2x1_nopad_split2) { set_values(biases2, { -1.0f, 2.5f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights1", weights1), data("biases1", biases1), data("weights2", weights2), @@ -3573,12 +3560,12 @@ TEST(convolution_f32_fw_gpu, basic_wsiz1x1_wstr2x2_in1x1x2x1_nopad_split2) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); - EXPECT_FLOAT_EQ(-2.0f, get_value(output_ptr, 0)); - EXPECT_FLOAT_EQ(6.5f, get_value(output_ptr, 1)); - EXPECT_FLOAT_EQ(1.0f, get_value(output_ptr, 2)); - EXPECT_FLOAT_EQ(3.5f, get_value(output_ptr, 3)); + EXPECT_FLOAT_EQ(-2.0f, output_ptr[0]); + EXPECT_FLOAT_EQ(6.5f, output_ptr[1]); + EXPECT_FLOAT_EQ(1.0f, output_ptr[2]); + EXPECT_FLOAT_EQ(3.5f, output_ptr[3]); } TEST(convolution_f32_fw_gpu, basic_wsiz1x1_wstr2x2_in1x1x4x1_filter_1x3x2x1x1_nopad_split2) { @@ -3618,14 +3605,14 @@ TEST(convolution_f32_fw_gpu, basic_wsiz1x1_wstr2x2_in1x1x4x1_filter_1x3x2x1x1_no // 6 // -2 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 4, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 4, 1, 1 } }); //auto output = memory::allocate({ memory::format::yxfb_f32,{ 1,{ 1, 1 }, 6 } }); - auto weights1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 3, 2, 1, 1 } }); - auto biases1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 3, 1, 1 } }); - auto weights2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 3, 2, 1, 1 } }); - auto biases2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 3, 1, 1 } }); + auto weights1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 3, 2, 1, 1 } }); + auto biases1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 3, 1, 1 } }); + auto weights2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 3, 2, 1, 1 } }); + auto biases2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 3, 1, 1 } }); set_values(input, { 1.5f, 0.5f, 2.0f, -1.0f @@ -3636,7 +3623,7 @@ TEST(convolution_f32_fw_gpu, basic_wsiz1x1_wstr2x2_in1x1x4x1_filter_1x3x2x1x1_no set_values(biases2, { -1.0f, 2.5f, 2.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights1", weights1), data("biases1", biases1), data("weights2", weights2), @@ -3660,14 +3647,14 @@ TEST(convolution_f32_fw_gpu, basic_wsiz1x1_wstr2x2_in1x1x4x1_filter_1x3x2x1x1_no auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); - EXPECT_FLOAT_EQ(-1.5f, get_value(output_ptr, 0)); - EXPECT_FLOAT_EQ(8.0f, get_value(output_ptr, 1)); - EXPECT_FLOAT_EQ(7.75f, get_value(output_ptr, 2)); - EXPECT_FLOAT_EQ(11.0f, get_value(output_ptr, 3)); - EXPECT_FLOAT_EQ(6.0f, get_value(output_ptr, 4)); - EXPECT_FLOAT_EQ(-2.0f, get_value(output_ptr, 5)); + EXPECT_FLOAT_EQ(-1.5f, output_ptr[0]); + EXPECT_FLOAT_EQ(8.0f, output_ptr[1]); + EXPECT_FLOAT_EQ(7.75f, output_ptr[2]); + EXPECT_FLOAT_EQ(11.0f, output_ptr[3]); + EXPECT_FLOAT_EQ(6.0f, output_ptr[4]); + EXPECT_FLOAT_EQ(-2.0f, output_ptr[5]); }*/ @@ -3695,12 +3682,12 @@ TEST(convolution_gpu, trivial_convolution_relu) { // 4 0.0 // 2 5 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 4, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 4, 4 } }); //auto output = memory::allocate({ memory::format::yxfb_f32,{ 1 ,{ 2, 2 }, 1 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, { -0.5f, 1.0f, 0.5f, 2.0f, @@ -3712,7 +3699,7 @@ TEST(convolution_gpu, trivial_convolution_relu) { set_values(biases, { -2.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution( @@ -3739,12 +3726,12 @@ TEST(convolution_gpu, trivial_convolution_relu) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); - EXPECT_FLOAT_EQ(4.0f, get_value(output_ptr, 0)); - EXPECT_FLOAT_EQ(0.0f, get_value(output_ptr, 1)); - EXPECT_FLOAT_EQ(2.0f, get_value(output_ptr, 2)); - EXPECT_FLOAT_EQ(5.0f, get_value(output_ptr, 3)); + EXPECT_FLOAT_EQ(4.0f, output_ptr[0]); + EXPECT_FLOAT_EQ(0.0f, output_ptr[1]); + EXPECT_FLOAT_EQ(2.0f, output_ptr[2]); + EXPECT_FLOAT_EQ(5.0f, output_ptr[3]); } TEST(convolution_gpu, relu_with_negative_slope) { @@ -3772,12 +3759,12 @@ TEST(convolution_gpu, relu_with_negative_slope) { // 4 -0.35 // 2 5 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 4, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 4, 4 } }); //auto output = memory::allocate({ memory::format::yxfb_f32,{ 1 ,{ 2, 2 }, 1 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, { -0.5f, 1.0f, 0.5f, 2.0f, @@ -3789,7 +3776,7 @@ TEST(convolution_gpu, relu_with_negative_slope) { set_values(biases, { -2.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution( @@ -3817,29 +3804,29 @@ TEST(convolution_gpu, relu_with_negative_slope) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); - EXPECT_FLOAT_EQ(4.0f, get_value(output_ptr, 0)); - EXPECT_FLOAT_EQ(-0.35f, get_value(output_ptr, 1)); - EXPECT_FLOAT_EQ(2.0f, get_value(output_ptr, 2)); - EXPECT_FLOAT_EQ(5.0f, get_value(output_ptr, 3)); + EXPECT_FLOAT_EQ(4.0f, output_ptr[0]); + EXPECT_FLOAT_EQ(-0.35f, output_ptr[1]); + EXPECT_FLOAT_EQ(2.0f, output_ptr[2]); + EXPECT_FLOAT_EQ(5.0f, output_ptr[3]); } TEST(convolution_gpu, DISABLED_two_1x1_kernels_after_each_other) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); extern const std::vector conv_1x1_output; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 16, 8, 16, 16 } }); - auto weights_conv_1 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 8, 8, 1, 1 } }); - auto weights_conv_2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 8, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 16, 8, 16, 16 } }); + auto weights_conv_1 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 8, 8, 1, 1 } }); + auto weights_conv_2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 8, 1, 1 } }); set_random_values(input); set_random_values(weights_conv_1); set_random_values(weights_conv_2); - auto inp_lay = input_layout("input", input.get_layout()); + auto inp_lay = input_layout("input", input->get_layout()); auto conv_1 = convolution( "conv_1", "input", @@ -3867,8 +3854,8 @@ TEST(convolution_gpu, DISABLED_two_1x1_kernels_after_each_other) { auto output_prim = outputs.at("conv_2").get_memory(); - auto output_ptr = output_prim.pointer(); - auto output_layout = output_prim.get_layout(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); + auto output_layout = output_prim->get_layout(); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -3876,16 +3863,12 @@ TEST(convolution_gpu, DISABLED_two_1x1_kernels_after_each_other) { int b_size = output_layout.size.batch[0]; int f_offset = y_size * x_size; int b_offset = f_size * f_offset; - for (int b = 0; b < b_size; ++b) - { - for (int f = 0; f < f_size; ++f) - { - for (int y = 0; y < y_size; ++y) - { - for (int x = 0; x < x_size; ++x) - { + for (int b = 0; b < b_size; ++b) { + for (int f = 0; f < f_size; ++f) { + for (int y = 0; y < y_size; ++y) { + for (int x = 0; x < x_size; ++x) { int idx = b * b_offset + f * f_offset + y * x_size + x; - EXPECT_TRUE(are_equal(conv_1x1_output[idx], get_value(output_ptr, idx))); + EXPECT_TRUE(are_equal(conv_1x1_output[idx], output_ptr[idx])); } } } @@ -3918,13 +3901,13 @@ TEST(convolution_gpu, basic_yxfb_4_4_yxfb_2_2_b16_if2_of16_st2_2_p0_sp1_fp32) const int32_t output_x = (input_x - weights_x) / stride_x + 1; const int32_t output_y = (input_y - weights_y) / stride_y + 1; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto input_size = tensor( batch_size, input_feature_count, input_x, input_y ); - auto input = memory::allocate(engine, { data_types::f32, input_format, input_size }); + auto input = engine.allocate_memory({ data_types::f32, input_format, input_size }); auto weights_size = tensor( output_feature_count, input_feature_count, weights_x, weights_y ); - auto weights = memory::allocate(engine, { data_types::f32, weights_format, weights_size }); - auto biases = memory::allocate(engine, { data_types::f32, biases_format, {1,output_feature_count,1,1}}); + auto weights = engine.allocate_memory({ data_types::f32, weights_format, weights_size }); + auto biases = engine.allocate_memory({ data_types::f32, biases_format, {1,output_feature_count,1,1}}); //auto output = memory::allocate({output_format, {batch_size, {output_x, output_y}, output_feature_count}}); @@ -4021,7 +4004,7 @@ TEST(convolution_gpu, basic_yxfb_4_4_yxfb_2_2_b16_if2_of16_st2_2_p0_sp1_fp32) // Computing convolution. topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution( @@ -4049,7 +4032,7 @@ TEST(convolution_gpu, basic_yxfb_4_4_yxfb_2_2_b16_if2_of16_st2_2_p0_sp1_fp32) auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); // Checking result. uint32_t i = 0; @@ -4059,12 +4042,12 @@ TEST(convolution_gpu, basic_yxfb_4_4_yxfb_2_2_b16_if2_of16_st2_2_p0_sp1_fp32) { for (uint32_t bi = 0; bi < batch_size; ++bi, ++i) { - auto equal = are_equal(output_vals[i], get_value(output_ptr, i)); + auto equal = are_equal(output_vals[i], output_ptr[i]); EXPECT_TRUE(equal); if (!equal) { std::cout << "Failed at position (" << yxi << ", output feature = " << ofi << ", batch = " << bi << "): " - << output_vals[i] << " != " << get_value(output_ptr, i) << std::endl; + << output_vals[i] << " != " << output_ptr[i] << std::endl; return; } } @@ -4074,9 +4057,8 @@ TEST(convolution_gpu, basic_yxfb_4_4_yxfb_2_2_b16_if2_of16_st2_2_p0_sp1_fp32) #undef USE_OLD_WEIGHTS_FORMAT } -void add_primitives(const engine& engine, topology& topology) -{ - auto weights = memory::allocate(engine, { data_types::i8, format::bfyx,{ 2, 1, 3, 2 } }); +void add_primitives(engine& engine, topology& topology) { + auto weights = engine.allocate_memory({ data_types::i8, format::bfyx,{ 2, 1, 3, 2 } }); std::vector weights_values = { 1, 2, 1, 2, 1, 2, @@ -4084,7 +4066,7 @@ void add_primitives(const engine& engine, topology& topology) 19, 17, -1, -10, 32, 23 }; set_values(weights, weights_values); - cldnn::memory biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); set_values(biases, { 1.0f, -8.0f }); topology.add( @@ -4123,9 +4105,8 @@ TEST(convolution_f32_fw_gpu, byte_activation) { // // Bias: // 1 -8 - auto eng_conf = get_test_engine(); - engine engine{ eng_conf }; - auto input = memory::allocate(engine, { data_types::i8, format::bfyx,{ 1, 1, 5, 4 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::i8, format::bfyx,{ 1, 1, 5, 4 } }); VVVF output_vec = { { @@ -4146,7 +4127,7 @@ TEST(convolution_f32_fw_gpu, byte_activation) { -1, -1, -1, -1, -1 }); topology topology( - input_layout("input", input.get_layout())); + input_layout("input", input->get_layout())); add_primitives(engine, topology); network network(engine, topology, opts); network.set_input_data("input", input); @@ -4155,8 +4136,8 @@ TEST(convolution_f32_fw_gpu, byte_activation) { EXPECT_EQ(outputs.begin()->first, "out"); auto output_memory = outputs.at("out").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -4176,11 +4157,11 @@ TEST(convolution_f32_fw_gpu, byte_activation) { } TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_symmetric) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::u8, format::bfyx,{ 1, 1, 5, 4 } }); - auto weights = memory::allocate(engine, { data_types::i8, format::bfyx,{ 2, 1, 3, 3 } }); - cldnn::memory biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::u8, format::bfyx,{ 1, 1, 5, 4 } }); + auto weights = engine.allocate_memory({ data_types::i8, format::bfyx,{ 2, 1, 3, 3 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); set_values(input, { 1, 2, 3, 4, 5, 2, 2, 3, 4, 6, @@ -4206,7 +4187,7 @@ TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_symmetric) { } }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), convolution("conv", "input", { "weights" }, { "biases" }, tensor{ 0, 0, 2, 2 }, tensor(0), tensor{1, 1, 1, 1}, tensor{1, 2, 3, 2}), @@ -4221,9 +4202,9 @@ TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_symmetric) { EXPECT_EQ(outputs.begin()->first, "out"); auto output_memory = outputs.at("out").get_memory(); - auto output_ptr = output_memory.pointer(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); - auto output_layout = output_memory.get_layout(); + auto output_layout = output_memory->get_layout(); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; int f_size = output_layout.size.feature[0]; @@ -4243,13 +4224,13 @@ TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_symmetric) { } TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_asymmetric_weight_and_activations) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::u8, format::bfyx,{ 1, 1, 5, 4 } }); - auto weights = memory::allocate(engine, { data_types::i8, format::bfyx,{ 2, 1, 3, 3 } }); - cldnn::memory biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); - auto w_zp = memory::allocate(engine, { data_types::i8, format::bfyx,{ 2, 1, 1, 1 } }); - auto a_zp = memory::allocate(engine, { data_types::u8, format::bfyx,{ 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::u8, format::bfyx,{ 1, 1, 5, 4 } }); + auto weights = engine.allocate_memory({ data_types::i8, format::bfyx,{ 2, 1, 3, 3 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); + auto w_zp = engine.allocate_memory({ data_types::i8, format::bfyx,{ 2, 1, 1, 1 } }); + auto a_zp = engine.allocate_memory({ data_types::u8, format::bfyx,{ 1, 1, 1, 1 } }); set_values(input, { 1, 2, 3, 4, 5, 2, 2, 3, 4, 6, @@ -4277,7 +4258,7 @@ TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_asymmetric_weight_an } }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), data("a_zp", a_zp), @@ -4295,9 +4276,9 @@ TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_asymmetric_weight_an EXPECT_EQ(outputs.begin()->first, "out"); auto output_memory = outputs.at("out").get_memory(); - auto output_ptr = output_memory.pointer(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); - auto output_layout = output_memory.get_layout(); + auto output_layout = output_memory->get_layout(); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; int f_size = output_layout.size.feature[0]; @@ -4317,12 +4298,12 @@ TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_asymmetric_weight_an } TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_asymmetric_activations_per_tensor) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::u8, format::bfyx,{ 1, 1, 5, 4 } }); - auto weights = memory::allocate(engine, { data_types::i8, format::bfyx,{ 2, 1, 3, 3 } }); - cldnn::memory biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); - auto a_zp = memory::allocate(engine, { data_types::u8, format::bfyx,{ 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::u8, format::bfyx,{ 1, 1, 5, 4 } }); + auto weights = engine.allocate_memory({ data_types::i8, format::bfyx,{ 2, 1, 3, 3 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); + auto a_zp = engine.allocate_memory({ data_types::u8, format::bfyx,{ 1, 1, 1, 1 } }); set_values(input, { 1, 2, 3, 4, 5, 2, 2, 3, 4, 6, @@ -4349,7 +4330,7 @@ TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_asymmetric_activatio } }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), data("a_zp", a_zp), @@ -4366,9 +4347,9 @@ TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_asymmetric_activatio EXPECT_EQ(outputs.begin()->first, "out"); auto output_memory = outputs.at("out").get_memory(); - auto output_ptr = output_memory.pointer(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); - auto output_layout = output_memory.get_layout(); + auto output_layout = output_memory->get_layout(); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; int f_size = output_layout.size.feature[0]; @@ -4388,12 +4369,12 @@ TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_asymmetric_activatio } TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_asymmetric_activations_per_channel) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::u8, format::bfyx,{ 1, 2, 5, 4 } }); - auto weights = memory::allocate(engine, { data_types::i8, format::bfyx,{ 2, 2, 3, 3 } }); - cldnn::memory biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); - auto a_zp = memory::allocate(engine, { data_types::u8, format::bfyx,{ 1, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::u8, format::bfyx,{ 1, 2, 5, 4 } }); + auto weights = engine.allocate_memory({ data_types::i8, format::bfyx,{ 2, 2, 3, 3 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); + auto a_zp = engine.allocate_memory({ data_types::u8, format::bfyx,{ 1, 2, 1, 1 } }); set_values(input, { 1, 2, 3, 4, 5, 2, 2, 3, 4, 6, @@ -4434,7 +4415,7 @@ TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_asymmetric_activatio } }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), data("a_zp", a_zp), @@ -4451,9 +4432,9 @@ TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_asymmetric_activatio EXPECT_EQ(outputs.begin()->first, "out"); auto output_memory = outputs.at("out").get_memory(); - auto output_ptr = output_memory.pointer(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); - auto output_layout = output_memory.get_layout(); + auto output_layout = output_memory->get_layout(); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; int f_size = output_layout.size.feature[0]; @@ -4473,12 +4454,12 @@ TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_asymmetric_activatio } TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_asymmetric_activations_per_channel_3ic_with_sub) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::u8, format::bfyx,{ 1, 3, 5, 4 } }); - auto weights = memory::allocate(engine, { data_types::i8, format::bfyx,{ 2, 3, 3, 3 } }); - cldnn::memory biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); - auto a_zp = memory::allocate(engine, { data_types::u8, format::bfyx,{ 1, 3, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::u8, format::bfyx,{ 1, 3, 5, 4 } }); + auto weights = engine.allocate_memory({ data_types::i8, format::bfyx,{ 2, 3, 3, 3 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); + auto a_zp = engine.allocate_memory({ data_types::u8, format::bfyx,{ 1, 3, 1, 1 } }); set_values(input, { 1, 2, 3, 4, 5, 2, 2, 3, 4, 6, @@ -4533,7 +4514,7 @@ TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_asymmetric_activatio } }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), data("a_zp", a_zp), @@ -4552,9 +4533,9 @@ TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_asymmetric_activatio EXPECT_EQ(outputs.begin()->first, "out"); auto output_memory = outputs.at("out").get_memory(); - auto output_ptr = output_memory.pointer(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); - auto output_layout = output_memory.get_layout(); + auto output_layout = output_memory->get_layout(); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; int f_size = output_layout.size.feature[0]; @@ -4574,12 +4555,12 @@ TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_asymmetric_activatio } TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_asymmetric_weights_per_channel) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::u8, format::bfyx,{ 1, 1, 5, 4 } }); - auto weights = memory::allocate(engine, { data_types::i8, format::bfyx,{ 2, 1, 3, 3 } }); - cldnn::memory biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); - auto w_zp = memory::allocate(engine, { data_types::i8, format::bfyx,{ 2, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::u8, format::bfyx,{ 1, 1, 5, 4 } }); + auto weights = engine.allocate_memory({ data_types::i8, format::bfyx,{ 2, 1, 3, 3 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); + auto w_zp = engine.allocate_memory({ data_types::i8, format::bfyx,{ 2, 1, 1, 1 } }); set_values(input, { 1, 2, 3, 4, 5, 2, 2, 3, 4, 6, @@ -4606,7 +4587,7 @@ TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_asymmetric_weights_p } }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), data("w_zp", w_zp), @@ -4623,9 +4604,9 @@ TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_asymmetric_weights_p EXPECT_EQ(outputs.begin()->first, "out"); auto output_memory = outputs.at("out").get_memory(); - auto output_ptr = output_memory.pointer(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); - auto output_layout = output_memory.get_layout(); + auto output_layout = output_memory->get_layout(); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; int f_size = output_layout.size.feature[0]; @@ -4648,10 +4629,9 @@ TEST(convolution_gpu, basic_yxfb_4_4_yxfb_2_2_b16_if2_of16_st2_2_p0_sp1_fp16) { #define USE_OLD_WEIGHTS_FORMAT 0 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - if (!engine.get_info().supports_fp16) - { + if (!engine.get_device_info().supports_fp16) { std::cout << "[ SKIPPED ] The test is skipped (cl_khr_fp16 is not supported)." << std::endl; EXPECT_EQ(1, 1); return; @@ -4681,17 +4661,17 @@ TEST(convolution_gpu, basic_yxfb_4_4_yxfb_2_2_b16_if2_of16_st2_2_p0_sp1_fp16) const int32_t output_y = (input_y - weights_y) / stride_y + 1; auto input_size = tensor( batch_size, input_feature_count, input_x, input_y ); - auto input = memory::allocate(engine, { data_types::f32, input_format, input_size }); + auto input = engine.allocate_memory({ data_types::f32, input_format, input_size }); auto weights_size = tensor( output_feature_count, input_feature_count, weights_x, weights_y ); - auto weights = memory::allocate(engine, { data_types::f32, weights_format, weights_size }); + auto weights = engine.allocate_memory({ data_types::f32, weights_format, weights_size }); auto biases_size = tensor( 1,output_feature_count,1,1 ); - auto biases = memory::allocate(engine, { data_types::f32, biases_format, biases_size }); + auto biases = engine.allocate_memory({ data_types::f32, biases_format, biases_size }); auto output_size = tensor( batch_size, output_feature_count, output_x, output_y ); //auto output = memory::allocate({output_format, {batch_size, {output_x, output_y}, output_feature_count}}); - //auto input_cvtd = memory::allocate(engine, { data_types::f16, input_size }); - //auto weights_cvtd = memory::allocate(engine, { data_types::f16, weights_size }); - //auto biases_cvtd = memory::allocate(engine, { data_types::f16, biases_size }); + //auto input_cvtd = engine.allocate_memory({ data_types::f16, input_size }); + //auto weights_cvtd = engine.allocate_memory({ data_types::f16, weights_size }); + //auto biases_cvtd = engine.allocate_memory({ data_types::f16, biases_size }); //auto output_cvtd = memory::allocate({output_cvt_format, {batch_size, {output_x, output_y}, output_feature_count}}); // input: @@ -4785,9 +4765,9 @@ TEST(convolution_gpu, basic_yxfb_4_4_yxfb_2_2_b16_if2_of16_st2_2_p0_sp1_fp16) } } - //auto expected_float = memory::allocate(engine, { data_types::f32,{ format::x,{ static_cast(output_vals.size()) } } }); - //auto expected_half = memory::allocate(engine, { data_types::f16,{ format::x,{ static_cast(output_vals.size()) } } }); - //auto expected = memory::allocate(engine, { data_types::f32,{ format::x,{ static_cast(output_vals.size()) } } }); + //auto expected_float = engine.allocate_memory({ data_types::f32,{ format::x,{ static_cast(output_vals.size()) } } }); + //auto expected_half = engine.allocate_memory({ data_types::f16,{ format::x,{ static_cast(output_vals.size()) } } }); + //auto expected = engine.allocate_memory({ data_types::f32,{ format::x,{ static_cast(output_vals.size()) } } }); // set_values(expected_float, output_vals); // auto cvt_expected_f32_f16 = reorder::create({expected_float, expected_half}); @@ -4798,7 +4778,7 @@ TEST(convolution_gpu, basic_yxfb_4_4_yxfb_2_2_b16_if2_of16_st2_2_p0_sp1_fp16) // Computing convolution. topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("cvt_input", "input", {data_types::f16, input_format, input_size}), data("weights", weights), reorder("cvt_weights", "weights", {data_types::f16, weights_format, weights_size}), @@ -4822,7 +4802,7 @@ TEST(convolution_gpu, basic_yxfb_4_4_yxfb_2_2_b16_if2_of16_st2_2_p0_sp1_fp16) auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); // Checking result. uint32_t i = 0; @@ -5042,10 +5022,9 @@ INSTANTIATE_TEST_CASE_P(convolution_gpu_test, TEST_P(convolution_gpu_fs_byx_fsv32, fs_byx_fsv32) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - if (!engine.get_info().supports_fp16) - { + if (!engine.get_device_info().supports_fp16) { std::cout << "[ SKIPPED ] The test is skipped (cl_khr_fp16 is not supported)." << std::endl; EXPECT_EQ(1, 1); return; @@ -5066,20 +5045,20 @@ TEST_P(convolution_gpu_fs_byx_fsv32, fs_byx_fsv32) auto input_size = tensor(batch_num, input_f, input_xy, input_xy); auto input_data = generate_random_4d(batch_num, input_f, input_xy, input_xy, -1, 1); auto input_data_bfyx = flatten_4d(format::bfyx, input_data); - auto input_mem = memory::allocate(engine, { data_types::f16, format::bfyx, input_size }); + auto input_mem = engine.allocate_memory({ data_types::f16, format::bfyx, input_size }); set_values(input_mem, input_data_bfyx); auto weights_size = tensor(output_f, input_f, filter_xy, filter_xy); auto weights_data = generate_random_4d(output_f, input_f, filter_xy, filter_xy, -1, 1); auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data); - auto weights_mem = memory::allocate(engine, { data_types::f16, format::bfyx, weights_size }); + auto weights_mem = engine.allocate_memory({ data_types::f16, format::bfyx, weights_size }); set_values(weights_mem, weights_data_bfyx); // Will be used to store reference values calculated in branches depending on bias auto reference_result = VVVVF(batch_num, VVVF(output_f)); topology topology( - input_layout("input", input_mem.get_layout()), + input_layout("input", input_mem->get_layout()), data("weights_fsv", weights_mem)); // Reorder input to fs_byx_fsv32 @@ -5090,7 +5069,7 @@ TEST_P(convolution_gpu_fs_byx_fsv32, fs_byx_fsv32) // Generate bias data auto biases_size = tensor(1, output_f, 1, 1); auto biases_data = generate_random_1d(output_f, -1, 1); - auto biases_mem = memory::allocate(engine, { data_types::f16, format::bfyx, biases_size }); + auto biases_mem = engine.allocate_memory({ data_types::f16, format::bfyx, biases_size }); set_values(biases_mem, biases_data); // Calculate reference values with bias @@ -5152,9 +5131,9 @@ TEST_P(convolution_gpu_fs_byx_fsv32, fs_byx_fsv32) network.execute(); auto out_mem = network.get_output("conv_fsv").get_memory(); - auto out_ptr = out_mem.pointer(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); - ASSERT_EQ(out_mem.get_layout().format, format::fs_b_yx_fsv32); + ASSERT_EQ(out_mem->get_layout().format, format::fs_b_yx_fsv32); for (int bi = 0; bi < batch_num; ++bi) for (int fi = 0; fi < output_f; ++fi) @@ -5177,10 +5156,9 @@ TEST_P(convolution_gpu_fs_byx_fsv32, fs_byx_fsv32) } TEST(convolution_f16_fsv_gpu, convolution_f16_fsv_gpu_padding) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - if (!engine.get_info().supports_fp16) - { + if (!engine.get_device_info().supports_fp16) { std::cout << "[ SKIPPED ] The test is skipped (cl_khr_fp16 is not supported)." << std::endl; EXPECT_EQ(1, 1); return; @@ -5197,20 +5175,20 @@ TEST(convolution_f16_fsv_gpu, convolution_f16_fsv_gpu_padding) { auto input_size = tensor(batch_num, input_f, input_xy, input_xy); auto input_data = generate_random_4d(batch_num, input_f, input_xy, input_xy, -1, 1); auto input_data_bfyx = flatten_4d(format::bfyx, input_data); - auto input_mem = memory::allocate(engine, { data_types::f16, format::bfyx, input_size }); + auto input_mem = engine.allocate_memory({ data_types::f16, format::bfyx, input_size }); set_values(input_mem, input_data_bfyx); auto weights_size = tensor(output_f, input_f, filter_xy, filter_xy); auto weights_data = generate_random_4d(output_f, input_f, filter_xy, filter_xy, -1, 1); auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data); - auto weights_mem = memory::allocate(engine, { data_types::f16, format::bfyx, weights_size }); + auto weights_mem = engine.allocate_memory({ data_types::f16, format::bfyx, weights_size }); set_values(weights_mem, weights_data_bfyx); // Will be used to store reference values calculated in branches depending on bias auto reference_result = VVVVF(batch_num, VVVF(output_f)); topology topology( - input_layout("input", input_mem.get_layout()), + input_layout("input", input_mem->get_layout()), data("weights_fsv", weights_mem)); // add input padding by X and Y @@ -5220,7 +5198,7 @@ TEST(convolution_f16_fsv_gpu, convolution_f16_fsv_gpu_padding) { // Generate bias data auto biases_size = tensor(1, output_f, 1, 1); auto biases_data = generate_random_1d(output_f, -1, 1); - auto biases_mem = memory::allocate(engine, { data_types::f16, format::bfyx, biases_size }); + auto biases_mem = engine.allocate_memory({ data_types::f16, format::bfyx, biases_size }); set_values(biases_mem, biases_data); // Calculate reference values @@ -5254,9 +5232,9 @@ TEST(convolution_f16_fsv_gpu, convolution_f16_fsv_gpu_padding) { network.execute(); auto out_mem = network.get_output("conv_fsv").get_memory(); - auto out_ptr = out_mem.pointer(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); - ASSERT_EQ(out_mem.get_layout().format, format::fs_b_yx_fsv32); + ASSERT_EQ(out_mem->get_layout().format, format::fs_b_yx_fsv32); for (int bi = 0; bi < batch_num; ++bi) for (int fi = 0; fi < output_f; ++fi) @@ -5309,10 +5287,9 @@ INSTANTIATE_TEST_CASE_P(convolution_gpu_with_crop, TEST_P(convolution_gpu_fs_byx_fsv32_crop, fs_byx_fsv32_crop) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - if (!engine.get_info().supports_fp16) - { + if (!engine.get_device_info().supports_fp16) { std::cout << "[ SKIPPED ] The test is skipped (cl_khr_fp16 is not supported)." << std::endl; EXPECT_EQ(1, 1); return; @@ -5333,7 +5310,7 @@ TEST_P(convolution_gpu_fs_byx_fsv32_crop, fs_byx_fsv32_crop) auto weights_size = tensor(output_f, input_f, filter_xy, filter_xy); auto weights_data = generate_random_4d(output_f, input_f, filter_xy, filter_xy, -1, 1); auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data); - auto weights_mem = memory::allocate(engine, { data_types::f16, format::bfyx, weights_size }); + auto weights_mem = engine.allocate_memory({ data_types::f16, format::bfyx, weights_size }); set_values(weights_mem, weights_data_bfyx); // ref input @@ -5357,11 +5334,11 @@ TEST_P(convolution_gpu_fs_byx_fsv32_crop, fs_byx_fsv32_crop) auto input_data_bfyx = flatten_4d(format::bfyx, input_data); auto input_size = tensor(batch_num, input_f * 2, input_xy, input_xy); - auto input_mem = memory::allocate(engine, { data_types::f16, format::bfyx, input_size }); + auto input_mem = engine.allocate_memory({ data_types::f16, format::bfyx, input_size }); set_values(input_mem, input_data_bfyx); topology topology( - input_layout("input", input_mem.get_layout()), + input_layout("input", input_mem->get_layout()), data("weights_fsv", weights_mem)); auto crop_batch_num = batch_num; @@ -5383,7 +5360,7 @@ TEST_P(convolution_gpu_fs_byx_fsv32_crop, fs_byx_fsv32_crop) // Generate bias data auto biases_size = tensor(1, output_f, 1, 1); auto biases_data = generate_random_1d(output_f, -1, 1); - auto biases_mem = memory::allocate(engine, { data_types::f16, format::bfyx, biases_size }); + auto biases_mem = engine.allocate_memory({ data_types::f16, format::bfyx, biases_size }); set_values(biases_mem, biases_data); // Calculate reference values with bias @@ -5462,9 +5439,9 @@ TEST_P(convolution_gpu_fs_byx_fsv32_crop, fs_byx_fsv32_crop) network.execute(); auto out_mem = network.get_output("concat").get_memory(); - auto out_ptr = out_mem.pointer(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); - ASSERT_EQ(out_mem.get_layout().format, format::bfyx); + ASSERT_EQ(out_mem->get_layout().format, format::bfyx); for (int bi = 0; bi < batch_num; ++bi) for (int fi = 0; fi < output_f * 2; ++fi) @@ -5495,29 +5472,29 @@ TEST(convolution_f32_fw_gpu, convolution_int8_b_fs_yx_fsv4_to_bfyx) { const int input_size_x = 1280; const int input_size_y = 720; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto input_size = tensor(batch_num, input_f, input_size_x, input_size_y); auto input_data = generate_random_4d(batch_num, input_f, input_size_y, input_size_x, -10, 10); auto input_data_bfyx = flatten_4d(format::bfyx, input_data); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, input_size }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, input_size }); set_values(input, input_data_bfyx); auto weights_size = tensor(output_f, input_f, filter_xy, filter_xy); auto weights_data = generate_random_4d(output_f, input_f, filter_xy, filter_xy, -10, 10); auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data); - auto weights = memory::allocate(engine, { data_types::i8, format::bfyx, weights_size }); + auto weights = engine.allocate_memory({ data_types::i8, format::bfyx, weights_size }); set_values(weights, weights_data_bfyx); auto biases_size = tensor(1, output_f, 1, 1); auto biases_data = generate_random_4d(1, output_f, 1, 1, -10, 10); auto biases_data_bfyx = flatten_4d(format::bfyx, biases_data); - auto biases = memory::allocate(engine, { data_types::i8, format::bfyx, biases_size }); + auto biases = engine.allocate_memory({ data_types::i8, format::bfyx, biases_size }); set_values(biases, biases_data_bfyx); topology topology_ref( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("to_int", "input", { data_types::i8,format::bfyx,{ batch_num, input_f, input_size_x, input_size_y } }), data("weights", weights), data("biases", biases), @@ -5535,11 +5512,11 @@ TEST(convolution_f32_fw_gpu, convolution_int8_b_fs_yx_fsv4_to_bfyx) { EXPECT_EQ(outputs.begin()->first, "output"); auto output_memory = outputs.at("output").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); topology topology_act( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("to_int", "input", { data_types::i8,format::b_fs_yx_fsv4,{ batch_num, input_f, input_size_x, input_size_y } }), data("weights", weights), data("biases", biases), @@ -5559,7 +5536,7 @@ TEST(convolution_f32_fw_gpu, convolution_int8_b_fs_yx_fsv4_to_bfyx) { EXPECT_EQ(outputs_act.begin()->first, "output"); auto output_memory_act = outputs_act.at("output").get_memory(); - auto output_act_ptr = output_memory_act.pointer(); + cldnn::mem_lock output_act_ptr(output_memory_act, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -5582,10 +5559,9 @@ TEST(convolution_f32_fw_gpu, convolution_int8_b_fs_yx_fsv4_to_bfyx) { TEST(convolution_gpu, bfyx_iyxo_5x5_fp16) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - if (!engine.get_info().supports_fp16) - { + if (!engine.get_device_info().supports_fp16) { std::cout << "[ SKIPPED ] The test is skipped (cl_khr_fp16 is not supported)." << std::endl; EXPECT_EQ(1, 1); return; @@ -5613,13 +5589,13 @@ TEST(convolution_gpu, bfyx_iyxo_5x5_fp16) auto input_data = generate_random_4d(batch_num, input_f, input_size_y, input_size_x, -1, 1); auto input_data_bfyx = flatten_4d(format::bfyx, input_data); - auto input_mem = memory::allocate(engine, { data_types::f16, format::bfyx, input_size }); + auto input_mem = engine.allocate_memory({ data_types::f16, format::bfyx, input_size }); set_values(input_mem, input_data_bfyx); auto weights_size = tensor(output_f, input_f, filter_xy, filter_xy); auto weights_data = generate_random_4d(output_f, input_f, filter_xy, filter_xy, -1, 1); auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data); - auto weights_mem = memory::allocate(engine, { data_types::f16, format::bfyx, weights_size }); + auto weights_mem = engine.allocate_memory({ data_types::f16, format::bfyx, weights_size }); set_values(weights_mem, weights_data_bfyx); @@ -5627,7 +5603,7 @@ TEST(convolution_gpu, bfyx_iyxo_5x5_fp16) auto reference_result = VVVVF(batch_num, VVVF(output_f)); topology topology( - input_layout("input", input_mem.get_layout()), + input_layout("input", input_mem->get_layout()), data("weights_fsv", weights_mem) ); @@ -5636,7 +5612,7 @@ TEST(convolution_gpu, bfyx_iyxo_5x5_fp16) // Generate bias data auto biases_size = tensor(1, output_f, 1, 1); auto biases_data = generate_random_1d(output_f, -1, 1); - auto biases_mem = memory::allocate(engine, { data_types::f16, format::bfyx, biases_size }); + auto biases_mem = engine.allocate_memory({ data_types::f16, format::bfyx, biases_size }); set_values(biases_mem, biases_data); // Calculate reference values with bias @@ -5698,7 +5674,7 @@ TEST(convolution_gpu, bfyx_iyxo_5x5_fp16) network.execute(); auto out_mem = network.get_output("conv_fsv").get_memory(); - auto out_ptr = out_mem.pointer(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); for (int bi = 0; bi < batch_num; ++bi) for (int fi = 0; fi < output_f; ++fi) @@ -5721,16 +5697,16 @@ TEST(convolution_gpu, bfyx_iyxo_5x5_fp16) } template -void blockedFormatZeroCheck(cldnn::memory out_mem) { - auto out_ptr = out_mem.pointer(); +void blockedFormatZeroCheck(cldnn::memory::ptr out_mem) { + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); bool batch_blocked = false; - if (out_mem.get_layout().format == format::bs_fs_zyx_bsv16_fsv16 || - out_mem.get_layout().format == format::bs_fs_yx_bsv16_fsv16) + if (out_mem->get_layout().format == format::bs_fs_zyx_bsv16_fsv16 || + out_mem->get_layout().format == format::bs_fs_yx_bsv16_fsv16) batch_blocked = true; const int block_size = 16; - auto output_tensor = out_mem.get_layout().get_buffer_size(); + auto output_tensor = out_mem->get_layout().get_buffer_size(); const int b = output_tensor.batch[0]; const int f = output_tensor.feature[0]; const int spatials = std::accumulate(output_tensor.spatial.begin(), output_tensor.spatial.end(), 1, std::multiplies()); @@ -5820,7 +5796,7 @@ INSTANTIATE_TEST_CASE_P(convolution_gpu_block3D, TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp32) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int batch_num = testing::get<0>(GetParam()); const int input_f = testing::get<1>(GetParam()); @@ -5838,7 +5814,7 @@ TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp32) auto input_size = tensor(batch_num, input_f, input_xy, input_xy, 1); auto input_data = generate_random_4d(batch_num, input_f, input_xy, input_xy, 1, 10); auto input_data_bfyx = flatten_4d(format::bfyx, input_data); - auto input_mem = memory::allocate(engine, { data_types::f32, format::bfzyx, input_size }); + auto input_mem = engine.allocate_memory({ data_types::f32, format::bfzyx, input_size }); set_values(input_mem, input_data_bfyx); auto weights_size = tensor(output_f, input_f, filter_xy, filter_xy, 1); @@ -5846,14 +5822,14 @@ TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp32) auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data); - auto weights_mem = memory::allocate(engine, { data_types::f32, format::bfzyx, weights_size }); + auto weights_mem = engine.allocate_memory({ data_types::f32, format::bfzyx, weights_size }); set_values(weights_mem, weights_data_bfyx); // Will be used to store reference values calculated in branches depending on bias auto reference_result = VVVVF(batch_num, VVVF(output_f)); topology topology( - input_layout("input", input_mem.get_layout()), + input_layout("input", input_mem->get_layout()), data("weights", weights_mem)); // Reorder input to correct format @@ -5864,7 +5840,7 @@ TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp32) // Generate bias data auto biases_size = tensor(1, output_f, 1, 1, 1); auto biases_data = generate_random_1d(output_f, -1, 1); - auto biases_mem = memory::allocate(engine, { data_types::f32, format::bfzyx, biases_size }); + auto biases_mem = engine.allocate_memory({ data_types::f32, format::bfzyx, biases_size }); set_values(biases_mem, biases_data); // Calculate reference values with bias @@ -5925,14 +5901,14 @@ TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp32) network.execute(); auto out_mem = network.get_output("conv_bsv16_fsv16").get_memory(); - auto out_ptr = out_mem.pointer(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); auto out_mem_bfyx = network.get_output("reorder_bfzyx").get_memory(); - auto out_ptr_bfyx = out_mem_bfyx.pointer(); + cldnn::mem_lock out_ptr_bfyx(out_mem_bfyx, get_test_stream()); blockedFormatZeroCheck(out_mem); - ASSERT_EQ(out_mem.get_layout().format, input_format); + ASSERT_EQ(out_mem->get_layout().format, input_format); auto flatten_ref = flatten_4d(format::bfyx, reference_result); @@ -5950,10 +5926,9 @@ TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp32) TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp16) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - if (!engine.get_info().supports_fp16) - { + if (!engine.get_device_info().supports_fp16) { std::cout << "[ SKIPPED ] The test is skipped (cl_khr_fp16 is not supported)." << std::endl; EXPECT_EQ(1, 1); return; @@ -5976,7 +5951,7 @@ TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp16) auto input_data = generate_random_4d(batch_num, input_f, input_xy, input_xy, 0, 1); auto input_data_bfyx = flatten_4d(format::bfyx, input_data); - auto input_mem = memory::allocate(engine, { data_types::f16, format::bfzyx, input_size }); + auto input_mem = engine.allocate_memory({ data_types::f16, format::bfzyx, input_size }); set_values(input_mem, input_data_bfyx); auto weights_size = tensor(output_f, input_f, filter_xy, filter_xy, 1); @@ -5984,14 +5959,14 @@ TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp16) auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data); - auto weights_mem = memory::allocate(engine, { data_types::f16, format::bfzyx, weights_size }); + auto weights_mem = engine.allocate_memory({ data_types::f16, format::bfzyx, weights_size }); set_values(weights_mem, weights_data_bfyx); // Will be used to store reference values calculated in branches depending on bias auto reference_result = VVVVF(batch_num, VVVF(output_f)); topology topology( - input_layout("input", input_mem.get_layout()), + input_layout("input", input_mem->get_layout()), data("weights", weights_mem)); // Reorder input to correct format @@ -6002,7 +5977,7 @@ TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp16) // Generate bias data auto biases_size = tensor(1, output_f, 1, 1, 1); auto biases_data = generate_random_1d(output_f, -1, 1); - auto biases_mem = memory::allocate(engine, { data_types::f16, format::bfzyx, biases_size }); + auto biases_mem = engine.allocate_memory({ data_types::f16, format::bfzyx, biases_size }); set_values(biases_mem, biases_data); // Calculate reference values with bias @@ -6063,14 +6038,14 @@ TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp16) network.execute(); auto out_mem = network.get_output("conv_bsv16_fsv16").get_memory(); - auto out_ptr = out_mem.pointer(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); auto out_mem_bfyx = network.get_output("reorder_bfzyx").get_memory(); - auto out_ptr_bfyx = out_mem_bfyx.pointer(); + cldnn::mem_lock out_ptr_bfyx(out_mem_bfyx, get_test_stream()); blockedFormatZeroCheck(out_mem); - ASSERT_EQ(out_mem.get_layout().format, input_format); + ASSERT_EQ(out_mem->get_layout().format, input_format); auto flatten_ref = flatten_4d(format::bfyx, reference_result); @@ -6087,7 +6062,7 @@ TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp16) TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp32_fused_ops) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int batch_num = testing::get<0>(GetParam()); const int input_f = testing::get<1>(GetParam()); @@ -6105,7 +6080,7 @@ TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp32_fused_ops) auto input_size = tensor(batch_num, input_f, input_xy, input_xy, 1); auto input_data = generate_random_4d(batch_num, input_f, input_xy, input_xy, 1, 10); auto input_data_bfyx = flatten_4d(format::bfyx, input_data); - auto input_mem = memory::allocate(engine, { data_types::f32, format::bfzyx, input_size }); + auto input_mem = engine.allocate_memory({ data_types::f32, format::bfzyx, input_size }); set_values(input_mem, input_data_bfyx); auto weights_size = tensor(output_f, input_f, filter_xy, filter_xy, 1); @@ -6113,14 +6088,14 @@ TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp32_fused_ops) auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data); - auto weights_mem = memory::allocate(engine, { data_types::f32, format::bfzyx, weights_size }); + auto weights_mem = engine.allocate_memory({ data_types::f32, format::bfzyx, weights_size }); set_values(weights_mem, weights_data_bfyx); // Will be used to store reference values calculated in branches depending on bias auto reference_result = VVVVF(batch_num, VVVF(output_f)); topology topology( - input_layout("input", input_mem.get_layout()), + input_layout("input", input_mem->get_layout()), data("weights", weights_mem)); // Reorder input to correct format @@ -6131,7 +6106,7 @@ TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp32_fused_ops) // Generate bias data auto biases_size = tensor(1, output_f, 1, 1, 1); auto biases_data = generate_random_1d(output_f, -1, 1); - auto biases_mem = memory::allocate(engine, { data_types::f32, format::bfzyx, biases_size }); + auto biases_mem = engine.allocate_memory({ data_types::f32, format::bfzyx, biases_size }); set_values(biases_mem, biases_data); // Calculate reference values with bias @@ -6181,7 +6156,7 @@ TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp32_fused_ops) } const float scalar = 5.5f; - auto scale_mem = memory::allocate(engine, { data_types::f32, format::bfzyx, {1, 1, 1, 1, 1} }); + auto scale_mem = engine.allocate_memory({ data_types::f32, format::bfzyx, {1, 1, 1, 1, 1} }); set_values(scale_mem, {scalar}); topology.add(data("scalar", scale_mem)); @@ -6199,14 +6174,14 @@ TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp32_fused_ops) network.execute(); auto out_mem = network.get_output("conv_bsv16_fsv16").get_memory(); - auto out_ptr = out_mem.pointer(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); auto out_mem_bfyx = network.get_output("reorder_bfzyx").get_memory(); - auto out_ptr_bfyx = out_mem_bfyx.pointer(); + cldnn::mem_lock out_ptr_bfyx(out_mem_bfyx, get_test_stream()); blockedFormatZeroCheck(out_mem); - ASSERT_EQ(out_mem.get_layout().format, input_format); + ASSERT_EQ(out_mem->get_layout().format, input_format); auto flatten_ref = flatten_4d(format::bfyx, reference_result); @@ -6251,7 +6226,7 @@ INSTANTIATE_TEST_CASE_P(convolution_gpu_block, TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp32) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int batch_num = testing::get<0>(GetParam()); const int input_xy = 5; @@ -6273,7 +6248,7 @@ TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp32) auto input_size = tensor(batch_num, input_f, input_xy, input_xy); auto input_data = generate_random_4d(batch_num, input_f, input_xy, input_xy, 1, 10); auto input_data_bfyx = flatten_4d(format::bfyx, input_data); - auto input_mem = memory::allocate(engine, { data_types::f32, format::bfyx, input_size }); + auto input_mem = engine.allocate_memory({ data_types::f32, format::bfyx, input_size }); set_values(input_mem, input_data_bfyx); auto weights_size = tensor(output_f, input_f, filter_xy, filter_xy); @@ -6281,14 +6256,14 @@ TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp32) auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data); - auto weights_mem = memory::allocate(engine, { data_types::f32, format::bfyx, weights_size }); + auto weights_mem = engine.allocate_memory({ data_types::f32, format::bfyx, weights_size }); set_values(weights_mem, weights_data_bfyx); // Will be used to store reference values calculated in branches depending on bias auto reference_result = VVVVF(batch_num, VVVF(output_f)); topology topology( - input_layout("input", input_mem.get_layout()), + input_layout("input", input_mem->get_layout()), data("weights", weights_mem)); // Reorder input to bs_fs_yx_bsv16_fsv16 @@ -6299,7 +6274,7 @@ TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp32) // Generate bias data auto biases_size = tensor(1, output_f, 1, 1); auto biases_data = generate_random_1d(output_f, -1, 1); - auto biases_mem = memory::allocate(engine, { data_types::f32, format::bfyx, biases_size }); + auto biases_mem = engine.allocate_memory({ data_types::f32, format::bfyx, biases_size }); set_values(biases_mem, biases_data); // Calculate reference values with bias @@ -6362,12 +6337,12 @@ TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp32) network.execute(); auto out_mem = network.get_output("conv_bsv16_fsv16").get_memory(); - auto out_ptr = out_mem.pointer(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); auto out_mem_bfyx = network.get_output("reorder_bfyx").get_memory(); - auto out_ptr_bfyx = out_mem_bfyx.pointer(); + cldnn::mem_lock out_ptr_bfyx(out_mem_bfyx, get_test_stream()); - ASSERT_EQ(out_mem.get_layout().format, format::bs_fs_yx_bsv16_fsv16); + ASSERT_EQ(out_mem->get_layout().format, format::bs_fs_yx_bsv16_fsv16); auto flatten_ref = flatten_4d(format::bfyx, reference_result); @@ -6384,10 +6359,9 @@ TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp32) TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp16) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - if (!engine.get_info().supports_fp16) - { + if (!engine.get_device_info().supports_fp16) { std::cout << "[ SKIPPED ] The test is skipped (cl_khr_fp16 is not supported)." << std::endl; EXPECT_EQ(1, 1); return; @@ -6414,7 +6388,7 @@ TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp16) auto input_data = generate_random_4d(batch_num, input_f, input_xy, input_xy, 0, 1); auto input_data_bfyx = flatten_4d(format::bfyx, input_data); - auto input_mem = memory::allocate(engine, { data_types::f16, format::bfyx, input_size }); + auto input_mem = engine.allocate_memory({ data_types::f16, format::bfyx, input_size }); set_values(input_mem, input_data_bfyx); auto weights_size = tensor(output_f, input_f, filter_xy, filter_xy); @@ -6422,14 +6396,14 @@ TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp16) auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data); - auto weights_mem = memory::allocate(engine, { data_types::f16, format::bfyx, weights_size }); + auto weights_mem = engine.allocate_memory({ data_types::f16, format::bfyx, weights_size }); set_values(weights_mem, weights_data_bfyx); // Will be used to store reference values calculated in branches depending on bias auto reference_result = VVVVF(batch_num, VVVF(output_f)); topology topology( - input_layout("input", input_mem.get_layout()), + input_layout("input", input_mem->get_layout()), data("weights", weights_mem)); // Reorder input to bs_fs_yx_bsv16_fsv16 @@ -6440,7 +6414,7 @@ TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp16) // Generate bias data auto biases_size = tensor(1, output_f, 1, 1); auto biases_data = generate_random_1d(output_f, -1, 1); - auto biases_mem = memory::allocate(engine, { data_types::f16, format::bfyx, biases_size }); + auto biases_mem = engine.allocate_memory({ data_types::f16, format::bfyx, biases_size }); set_values(biases_mem, biases_data); // Calculate reference values with bias @@ -6503,20 +6477,19 @@ TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp16) network.execute(); auto out_mem = network.get_output("conv_bsv16_fsv16").get_memory(); - auto out_ptr = out_mem.pointer(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); auto out_mem_bfyx = network.get_output("reorder_bfyx").get_memory(); - auto out_ptr_bfyx = out_mem_bfyx.pointer(); + cldnn::mem_lock out_ptr_bfyx(out_mem_bfyx, get_test_stream()); - ASSERT_EQ(out_mem.get_layout().format, format::bs_fs_yx_bsv16_fsv16); + ASSERT_EQ(out_mem->get_layout().format, format::bs_fs_yx_bsv16_fsv16); auto flatten_ref = flatten_4d(format::bfyx, reference_result); for (size_t i = 0; i < out_ptr_bfyx.size(); i++) { auto equal = are_equal(flatten_ref[i], out_ptr_bfyx[i], 1); EXPECT_TRUE(equal); - if (!equal) - { + if (!equal) { std::cout << "Difference at idx = " << i << std::endl; return; } @@ -6525,10 +6498,9 @@ TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp16) TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp32_fused_ops) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - if (!engine.get_info().supports_fp16) - { + if (!engine.get_device_info().supports_fp16) { std::cout << "[ SKIPPED ] The test is skipped (cl_khr_fp16 is not supported)." << std::endl; EXPECT_EQ(1, 1); return; @@ -6547,7 +6519,7 @@ TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp32_fused_ops) auto input_size = tensor(batch_num, input_f, input_xy, input_xy); auto input_data = generate_random_4d(batch_num, input_f, input_xy, input_xy, 1, 10); auto input_data_bfyx = flatten_4d(format::bfyx, input_data); - auto input_mem = memory::allocate(engine, { data_types::f32, format::bfyx, input_size }); + auto input_mem = engine.allocate_memory({ data_types::f32, format::bfyx, input_size }); set_values(input_mem, input_data_bfyx); auto weights_size = tensor(output_f, input_f, filter_xy, filter_xy, 1); @@ -6555,14 +6527,14 @@ TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp32_fused_ops) auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data); - auto weights_mem = memory::allocate(engine, { data_types::f32, format::bfyx, weights_size }); + auto weights_mem = engine.allocate_memory({ data_types::f32, format::bfyx, weights_size }); set_values(weights_mem, weights_data_bfyx); // Will be used to store reference values calculated in branches depending on bias auto reference_result = VVVVF(batch_num, VVVF(output_f)); topology topology( - input_layout("input", input_mem.get_layout()), + input_layout("input", input_mem->get_layout()), data("weights", weights_mem)); // Reorder input to bs_fs_yx_bsv16_fsv16 @@ -6573,7 +6545,7 @@ TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp32_fused_ops) // Generate bias data auto biases_size = tensor(1, output_f, 1, 1, 1); auto biases_data = generate_random_1d(output_f, -1, 1); - auto biases_mem = memory::allocate(engine, { data_types::f32, format::bfyx, biases_size }); + auto biases_mem = engine.allocate_memory({ data_types::f32, format::bfyx, biases_size }); set_values(biases_mem, biases_data); // Calculate reference values with bias @@ -6623,7 +6595,7 @@ TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp32_fused_ops) } const float scalar = 5.5f; - auto scale_mem = memory::allocate(engine, { data_types::f32, format::bfyx, {1, 1, 1, 1} }); + auto scale_mem = engine.allocate_memory({ data_types::f32, format::bfyx, {1, 1, 1, 1} }); set_values(scale_mem, {scalar}); topology.add(data("scalar", scale_mem)); @@ -6643,12 +6615,12 @@ TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp32_fused_ops) network.execute(); auto out_mem = network.get_output("conv_bsv16_fsv16").get_memory(); - auto out_ptr = out_mem.pointer(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); auto out_mem_bfyx = network.get_output("reorder_bfyx").get_memory(); - auto out_ptr_bfyx = out_mem_bfyx.pointer(); + cldnn::mem_lock out_ptr_bfyx(out_mem_bfyx, get_test_stream()); - ASSERT_EQ(out_mem.get_layout().format, format::bs_fs_yx_bsv16_fsv16); + ASSERT_EQ(out_mem->get_layout().format, format::bs_fs_yx_bsv16_fsv16); auto flatten_ref = flatten_4d(format::bfyx, reference_result); @@ -6701,10 +6673,9 @@ INSTANTIATE_TEST_CASE_P(convolution_depthwise_gpu_fs_b_yx_fsv32, TEST_P(convolution_depthwise_gpu, depthwise_conv_fs_b_yx_fsv32) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - if (!engine.get_info().supports_fp16) - { + if (!engine.get_device_info().supports_fp16) { std::cout << "[ SKIPPED ] The test is skipped (cl_khr_fp16 is not supported)." << std::endl; EXPECT_EQ(1, 1); return; @@ -6729,20 +6700,20 @@ TEST_P(convolution_depthwise_gpu, depthwise_conv_fs_b_yx_fsv32) auto input_size = tensor(batch_num, input_f, input_xy, input_xy); auto input_data = generate_random_4d(batch_num, input_f, input_xy, input_xy, -1, 1); auto input_data_bfyx = flatten_4d(format::bfyx, input_data); - auto input_mem = memory::allocate(engine, { data_types::f16, format::bfyx, input_size }); + auto input_mem = engine.allocate_memory({ data_types::f16, format::bfyx, input_size }); set_values(input_mem, input_data_bfyx); auto weights_size = tensor(group(groups), batch(1), feature(1), spatial(filter_x, filter_y)); auto weights_data = generate_random_4d(output_f, 1, filter_y, filter_x, -1, 1); auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data); - auto weights_mem = memory::allocate(engine, { data_types::f16, format::goiyx, weights_size }); + auto weights_mem = engine.allocate_memory({ data_types::f16, format::goiyx, weights_size }); set_values(weights_mem, weights_data_bfyx); // Will be used to store reference values calculated in branches depending on bias auto reference_result = VVVVF(batch_num, VVVF(output_f)); topology topology( - input_layout("input", input_mem.get_layout()), + input_layout("input", input_mem->get_layout()), data("weights_fsv", weights_mem)); // Reorder input to fs_byx_fsv32 @@ -6782,9 +6753,9 @@ TEST_P(convolution_depthwise_gpu, depthwise_conv_fs_b_yx_fsv32) network.execute(); auto out_mem = network.get_output("conv_fsv").get_memory(); - auto out_ptr = out_mem.pointer(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); - ASSERT_EQ(out_mem.get_layout().format, format::fs_b_yx_fsv32); + ASSERT_EQ(out_mem->get_layout().format, format::fs_b_yx_fsv32); for (int bi = 0; bi < batch_num; ++bi) for (int fi = 0; fi < output_f; ++fi) @@ -6844,10 +6815,9 @@ INSTANTIATE_TEST_CASE_P(convolution_depthwise_gpu_b_fs_yx_fsv16, TEST_P(convolution_depthwise_gpu_fsv16, depthwise_conv_b_fs_yx_fsv16) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - if (!engine.get_info().supports_fp16) - { + if (!engine.get_device_info().supports_fp16) { std::cout << "[ SKIPPED ] The test is skipped (cl_khr_fp16 is not supported)." << std::endl; EXPECT_EQ(1, 1); return; @@ -6873,20 +6843,20 @@ TEST_P(convolution_depthwise_gpu_fsv16, depthwise_conv_b_fs_yx_fsv16) auto input_size = tensor(batch_num, input_f, input_xy, input_xy); auto input_data = generate_random_4d(batch_num, input_f, input_xy, input_xy, -1, 1); auto input_data_bfyx = flatten_4d(format::bfyx, input_data); - auto input_mem = memory::allocate(engine, { data_types::f16, format::bfyx, input_size }); + auto input_mem = engine.allocate_memory({ data_types::f16, format::bfyx, input_size }); set_values(input_mem, input_data_bfyx); auto weights_size = tensor(group(output_f), batch(1), feature(1), spatial(filter_x, filter_y)); auto weights_data = generate_random_4d(output_f, 1, filter_y, filter_x, -1, 1); auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data); - auto weights_mem = memory::allocate(engine, { data_types::f16, format::goiyx, weights_size }); + auto weights_mem = engine.allocate_memory({ data_types::f16, format::goiyx, weights_size }); set_values(weights_mem, weights_data_bfyx); // Will be used to store reference values calculated in branches depending on bias auto reference_result = VVVVF(batch_num, VVVF(output_f)); topology topology( - input_layout("input", input_mem.get_layout()), + input_layout("input", input_mem->get_layout()), data("weights_fsv", weights_mem)); // Reorder input to b_fs_yx_fsv16 @@ -6926,9 +6896,9 @@ TEST_P(convolution_depthwise_gpu_fsv16, depthwise_conv_b_fs_yx_fsv16) network.execute(); auto out_mem = network.get_output("conv_fsv").get_memory(); - auto out_ptr = out_mem.pointer(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); - ASSERT_EQ(out_mem.get_layout().format, format::b_fs_yx_fsv16); + ASSERT_EQ(out_mem->get_layout().format, format::b_fs_yx_fsv16); for (int bi = 0; bi < batch_num; ++bi) for (int fi = 0; fi < output_f; ++fi) @@ -6970,11 +6940,11 @@ TEST(convolution_depthwise_gpu_fsv16, depthwise_conv_b_fs_yx_fsv16_in_feature_pa auto input_lower_sizes = { 0, 16, 0, 0 }; auto input_upper_sizes = { 0, 64, 0, 0 }; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, input_size }); - auto weights = memory::allocate(engine, { data_types::f32, format::goiyx, weights_size}); - auto bias = memory::allocate(engine, { data_types::f32, format::bfyx, bias_size}); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, input_size }); + auto weights = engine.allocate_memory({ data_types::f32, format::goiyx, weights_size}); + auto bias = engine.allocate_memory({ data_types::f32, format::bfyx, bias_size}); set_values(input, { 3, -1, -1, -1, 2, -2, 2, 2, 0, 1, -5, 4, -1, 4, 1, 0, @@ -7002,7 +6972,7 @@ TEST(convolution_depthwise_gpu_fsv16, depthwise_conv_b_fs_yx_fsv16_in_feature_pa layout reordered_input_layout = layout(data_types::f32, format::b_fs_yx_fsv16, input_size, input_padding); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("input_reordered", "input", reordered_input_layout), data("weights", weights), data("bias", bias), @@ -7022,8 +6992,8 @@ TEST(convolution_depthwise_gpu_fsv16, depthwise_conv_b_fs_yx_fsv16_in_feature_pa EXPECT_EQ(outputs.begin()->first, "out"); auto output_memory = outputs.at("out").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -7055,10 +7025,9 @@ struct convolution_depthwise_gpu_bfyx : public convolution_depthwise_gpu {}; TEST_P(convolution_depthwise_gpu_bfyx, depthwise_conv_bfyx) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - if (!engine.get_info().supports_fp16) - { + if (!engine.get_device_info().supports_fp16) { std::cout << "[ SKIPPED ] The test is skipped (cl_khr_fp16 is not supported)." << std::endl; EXPECT_EQ(1, 1); return; @@ -7084,20 +7053,20 @@ TEST_P(convolution_depthwise_gpu_bfyx, depthwise_conv_bfyx) auto input_size = tensor(batch_num, input_f, input_xy, input_xy); auto input_data = generate_random_4d(batch_num, input_f, input_xy, input_xy, -1, 1); auto input_data_bfyx = flatten_4d(format::bfyx, input_data); - auto input_mem = memory::allocate(engine, { data_types::f16, format::bfyx, input_size }); + auto input_mem = engine.allocate_memory({ data_types::f16, format::bfyx, input_size }); set_values(input_mem, input_data_bfyx); auto weights_size = tensor(group(output_f), batch(1), feature(1), spatial(filter_x, filter_y)); auto weights_data = generate_random_4d(output_f, 1, filter_y, filter_x, -1, 1); auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data); - auto weights_mem = memory::allocate(engine, { data_types::f16, format::goiyx, weights_size }); + auto weights_mem = engine.allocate_memory({ data_types::f16, format::goiyx, weights_size }); set_values(weights_mem, weights_data_bfyx); // Will be used to store reference values calculated in branches depending on bias auto reference_result = VVVVF(batch_num, VVVF(output_f)); topology topology( - input_layout("input", input_mem.get_layout()), + input_layout("input", input_mem->get_layout()), data("weights", weights_mem)); // Calculate reference values without bias @@ -7134,9 +7103,9 @@ TEST_P(convolution_depthwise_gpu_bfyx, depthwise_conv_bfyx) network.execute(); auto out_mem = network.get_output("conv").get_memory(); - auto out_ptr = out_mem.pointer(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); - ASSERT_EQ(out_mem.get_layout().format, format::bfyx); + ASSERT_EQ(out_mem->get_layout().format, format::bfyx); for (int bi = 0; bi < batch_num; ++bi) for (int fi = 0; fi < output_f; ++fi) @@ -7260,7 +7229,7 @@ INSTANTIATE_TEST_CASE_P(convolution_grouped_fsv4_fsv16, convolution_grouped_gpu::PrintToStringParamName); TEST_P(convolution_grouped_gpu, base) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int input_x = testing::get<0>(GetParam()), input_y = testing::get<1>(GetParam()), @@ -7304,7 +7273,7 @@ TEST_P(convolution_grouped_gpu, base) { size_t offset = input_lay.get_linear_offset(coords); input_flat[offset] = input_rnd[b][f][z][y][x]; } - auto input = memory::allocate(engine, input_lay); + auto input = engine.allocate_memory(input_lay); set_values(input, input_flat); auto input_zp_rnd = std::vector(input_f); @@ -7314,7 +7283,7 @@ TEST_P(convolution_grouped_gpu, base) { input_zp_prim_name = { "input_zp" }; } auto input_zp_lay = layout(data_types::i8, format::bfyx, tensor(feature(input_f))); - auto input_zp = memory::allocate(engine, input_zp_lay); + auto input_zp = engine.allocate_memory(input_zp_lay); set_values(input_zp, input_zp_rnd); auto weights_size = tensor(group(groups), batch(output_f / groups), feature(input_f / groups), spatial(filter_x, filter_y, filter_z)); @@ -7335,7 +7304,7 @@ TEST_P(convolution_grouped_gpu, base) { size_t offset = weights_lay.get_linear_offset(coords); weights_flat[offset] = weights_rnd[gi][ofi][ifi][kzi][kyi][kxi]; } - auto weights = memory::allocate(engine, weights_lay); + auto weights = engine.allocate_memory(weights_lay); set_values(weights, weights_flat); auto weights_zp_rnd = std::vector(output_f); @@ -7345,7 +7314,7 @@ TEST_P(convolution_grouped_gpu, base) { weights_zp_prim_name = { "weights_zp" }; } auto weights_zp_lay = layout(data_types::i8, format::bfyx, tensor(batch(output_f))); - auto weights_zp = memory::allocate(engine, weights_zp_lay); + auto weights_zp = engine.allocate_memory(weights_zp_lay); set_values(weights_zp, weights_zp_rnd); VVVVVF expected_result(batch_num, VVVVF(output_f)); @@ -7405,7 +7374,7 @@ TEST_P(convolution_grouped_gpu, base) { comp_prim_name = { "compensation" }; } auto comp_lay = layout(data_types::f32, format::bfyx, tensor(batch(output_f))); - auto comp = memory::allocate(engine, comp_lay); + auto comp = engine.allocate_memory(comp_lay); set_values(comp, comp_val); auto stride_tensor = tensor(batch(1), feature(1), spatial(stride, stride, stride, 1)); @@ -7413,7 +7382,7 @@ TEST_P(convolution_grouped_gpu, base) { stride_tensor = tensor(batch(1), feature(1), spatial(stride, stride, 1, 1)); } - topology topology(input_layout("input", input.get_layout()), + topology topology(input_layout("input", input->get_layout()), data("weights", weights), reorder("input_fsv", "input", {data_types::i8, input_data_format, input_size}), convolution("conv", @@ -7443,6 +7412,7 @@ TEST_P(convolution_grouped_gpu, base) { build_options options; options.set_option(build_option::optimize_data(true)); + options.set_option(build_option::outputs({"conv", "out"})); implementation_desc conv_impl = {input_data_format, impl_name}; options.set_option(build_option::force_implementations({{"conv", conv_impl}})); @@ -7451,10 +7421,10 @@ TEST_P(convolution_grouped_gpu, base) { network.execute(); auto out_mem = network.get_output("conv").get_memory(); - auto out_ptr = out_mem.pointer(); - auto out_lay = out_mem.get_layout(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); + auto out_lay = out_mem->get_layout(); - ASSERT_EQ(out_mem.get_layout().format, input_data_format); + ASSERT_EQ(out_mem->get_layout().format, input_data_format); ASSERT_EQ(out_lay.size.batch[0], expected_result.size()); ASSERT_EQ(out_lay.size.feature[0], expected_result[0].size()); ASSERT_EQ(out_lay.size.spatial[2], expected_result[0][0].size()); @@ -7501,10 +7471,9 @@ INSTANTIATE_TEST_CASE_P(conv_fp16_cases, convolution_general_gpu::PrintToStringParamName); TEST_P(convolution_general_gpu, conv_fp16_cases) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - if (!engine.get_info().supports_fp16) - { + if (!engine.get_device_info().supports_fp16) { std::cout << "[ SKIPPED ] The test is skipped (cl_khr_fp16 is not supported)." << std::endl; EXPECT_EQ(1, 1); return; @@ -7529,13 +7498,13 @@ TEST_P(convolution_general_gpu, conv_fp16_cases) { auto input_size = tensor(batch_num, input_f, input_x, input_y); auto input_data = generate_random_4d(batch_num, input_f, input_y, input_x, -1, 1); auto input_data_bfyx = flatten_4d(format::bfyx, input_data); - auto input_mem = memory::allocate(engine, { data_types::f16, format::bfyx, input_size }); + auto input_mem = engine.allocate_memory({ data_types::f16, format::bfyx, input_size }); set_values(input_mem, input_data_bfyx); auto weights_size = tensor(output_f, input_f, filter_y, filter_x, 1); auto weights_data = generate_random_4d(output_f, input_f, filter_y, filter_x, -1, 1); auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data); - auto weights_mem = memory::allocate(engine, {data_types::f16, format::bfyx, weights_size}); + auto weights_mem = engine.allocate_memory({data_types::f16, format::bfyx, weights_size}); set_values(weights_mem, weights_data_bfyx); // Will be used to store reference values calculated in branches depending on bias @@ -7546,7 +7515,7 @@ TEST_P(convolution_general_gpu, conv_fp16_cases) { if (with_bias) { auto biases_size = tensor(1, output_f, 1, 1); auto biases_data = generate_random_1d(output_f, -1, 1); - auto biases_mem = memory::allocate(engine, {data_types::f16, format::bfyx, biases_size}); + auto biases_mem = engine.allocate_memory({data_types::f16, format::bfyx, biases_size}); set_values(biases_mem, biases_data); for (auto bi = 0; bi < batch_num; ++bi) { @@ -7561,7 +7530,7 @@ TEST_P(convolution_general_gpu, conv_fp16_cases) { } } - topology.add(input_layout("input", input_mem.get_layout()), + topology.add(input_layout("input", input_mem->get_layout()), data("weights_fsv", weights_mem), data("bias", biases_mem), reorder("input_fsv", "input", {data_types::f16, input_data_format, input_size})); @@ -7589,7 +7558,7 @@ TEST_P(convolution_general_gpu, conv_fp16_cases) { } } - topology.add(input_layout("input", input_mem.get_layout()), + topology.add(input_layout("input", input_mem->get_layout()), data("weights_fsv", weights_mem), reorder("input_fsv", "input", {data_types::f16, input_data_format, input_size})); @@ -7612,10 +7581,10 @@ TEST_P(convolution_general_gpu, conv_fp16_cases) { network.execute(); auto out_mem = network.get_output("conv_fsv").get_memory(); - auto out_ptr = out_mem.pointer(); - auto out_lay = out_mem.get_layout(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); + auto out_lay = out_mem->get_layout(); - ASSERT_EQ(out_mem.get_layout().format, input_data_format); + ASSERT_EQ(out_mem->get_layout().format, input_data_format); ASSERT_EQ(out_lay.size.batch[0], expected_result.size()); ASSERT_EQ(out_lay.size.feature[0], expected_result[0].size()); ASSERT_EQ(out_lay.size.spatial[1], expected_result[0][0].size()); @@ -7643,11 +7612,11 @@ TEST_P(convolution_general_gpu, conv_fp16_cases) { template class convolution_test_base { public: - virtual topology build_topology(const cldnn::engine& engine) { + virtual topology build_topology(cldnn::engine& engine) { auto input_lay = layout(input_type(), format::bfyx, input_size(), padding_size()); auto wei_lay = layout(weights_type(), format::bfyx, weights_size()); - auto wei_mem = memory::allocate(engine, wei_lay); + auto wei_mem = engine.allocate_memory(wei_lay); auto weights_flat = flatten_4d(format::bfyx, _weights); set_values(wei_mem, weights_flat); layout reordered_layout = layout{input_type(), input_format(), input_size(), padding_size()}; @@ -7657,7 +7626,7 @@ class convolution_test_base { std::string input_id = "input_reorder"; if (has_input_zp()) { auto input_zp_lay = layout(input_type(), format::bfyx, tensor(feature(input_features()))); - auto input_zp_mem = memory::allocate(engine, input_zp_lay); + auto input_zp_mem = engine.allocate_memory(input_zp_lay); set_values(input_zp_mem, _input_zp); topo.add(data("input_zp", input_zp_mem)); topo.add(eltwise("input_asymm", { "input_reorder", "input_zp" }, eltwise_mode::sub)); @@ -7667,7 +7636,7 @@ class convolution_test_base { std::string weights_id = "weights"; if (has_weights_zp()) { auto weights_zp_lay = layout(weights_type(), format::bfyx, tensor(batch(output_features()))); - auto weights_zp_mem = memory::allocate(engine, weights_zp_lay); + auto weights_zp_mem = engine.allocate_memory(weights_zp_lay); set_values(weights_zp_mem, _weights_zp); topo.add(data("weights_zp", weights_zp_mem)); topo.add(eltwise("weights_asymm", { "weights", "weights_zp" }, eltwise_mode::sub)); @@ -7686,7 +7655,7 @@ class convolution_test_base { topo.add(conv_prim); } else { auto bias_lay = layout(output_type(), format::bfyx, tensor(feature(output_features()))); - auto bias_mem = memory::allocate(engine, bias_lay); + auto bias_mem = engine.allocate_memory(bias_lay); set_values(bias_mem, _bias); topo.add(data("bias", bias_mem)); auto conv_prim = convolution( @@ -7710,7 +7679,7 @@ class convolution_test_base { } virtual void run_expect(const VVVVF& expected) { - auto engine = get_test_engine(); + auto& engine = get_test_engine(); auto topo = build_topology(engine); @@ -7723,7 +7692,7 @@ class convolution_test_base { auto net = network(prog, 0); auto input_lay = layout(input_type(), format::bfyx, input_size(), padding_size()); - auto input_mem = memory::allocate(engine, input_lay); + auto input_mem = engine.allocate_memory(input_lay); std::vector input_flat(input_lay.get_linear_size(), static_cast(0)); for (size_t bi = 0; bi < batch_num(); ++bi) for (size_t fi = 0; fi < input_features(); ++fi) @@ -7738,8 +7707,8 @@ class convolution_test_base { net.set_input_data("input", input_mem); auto result = net.execute(); auto out_mem = result.at(output_primitive_id()).get_memory(); - auto out_lay = out_mem.get_layout(); - auto out_ptr = out_mem.cldnn::memory::template pointer(); + auto out_lay = out_mem->get_layout(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); std::stringstream description; for (auto i : net.get_primitives_info()) { @@ -8008,11 +7977,11 @@ template class convolution_random_test_fsv4_input : public convolution_random_test_base { public: using parent = convolution_random_test_base; - topology build_topology(const cldnn::engine& engine) override { + topology build_topology(cldnn::engine& engine) override { auto input_lay = layout(this->input_type(), format::b_fs_yx_fsv4, this->input_size(), this->padding_size()); auto wei_lay = layout(this->weights_type(), format::bfyx, this->weights_size()); - auto wei_mem = memory::allocate(engine, wei_lay); + auto wei_mem = engine.allocate_memory(wei_lay); auto wei_flat = flatten_4d(format::bfyx, this->_weights); set_values(wei_mem, wei_flat); layout reordered_layout = layout{this->input_type(), this->input_format(), this->input_size(), this->padding_size()}; @@ -8022,7 +7991,7 @@ class convolution_random_test_fsv4_input : public convolution_random_test_basehas_input_zp()) { auto input_zp_lay = layout(this->input_type(), format::bfyx, tensor(feature(this->input_features()))); - auto input_zp_mem = memory::allocate(engine, input_zp_lay); + auto input_zp_mem = engine.allocate_memory(input_zp_lay); set_values(input_zp_mem, this->_input_zp); topo.add(data("input_zp", input_zp_mem)); topo.add(eltwise("input_asymm", { "input_reorder", "input_zp" }, eltwise_mode::sub)); @@ -8032,7 +8001,7 @@ class convolution_random_test_fsv4_input : public convolution_random_test_basehas_weights_zp()) { auto weights_zp_lay = layout(this->weights_type(), format::bfyx, tensor(batch(this->output_features()))); - auto weights_zp_mem = memory::allocate(engine, weights_zp_lay); + auto weights_zp_mem = engine.allocate_memory(weights_zp_lay); set_values(weights_zp_mem, this->_weights_zp); topo.add(data("weights_zp", weights_zp_mem)); topo.add(eltwise("weights_asymm", { "weights", "weights_zp" }, eltwise_mode::sub)); @@ -8051,7 +8020,7 @@ class convolution_random_test_fsv4_input : public convolution_random_test_baseoutput_type(), format::bfyx, tensor(feature(this->output_features()))); - auto bias_mem = memory::allocate(engine, bias_lay); + auto bias_mem = engine.allocate_memory(bias_lay); set_values(bias_mem, this->_bias); topo.add(data("bias", bias_mem)); auto conv_prim = convolution( @@ -8070,7 +8039,7 @@ class convolution_random_test_fsv4_input : public convolution_random_test_base& expected) override { - auto engine = get_test_engine(); + auto& engine = get_test_engine(); auto topo = this->build_topology(engine); @@ -8083,7 +8052,7 @@ class convolution_random_test_fsv4_input : public convolution_random_test_baseinput_type(), format::b_fs_yx_fsv4, this->input_size(), this->padding_size()); - auto input_mem = memory::allocate(engine, input_lay); + auto input_mem = engine.allocate_memory(input_lay); std::vector input_flat(input_lay.get_linear_size(), static_cast(0)); for (size_t bi = 0; bi < this->batch_num(); ++bi) for (size_t fi = 0; fi < this->input_features(); ++fi) @@ -8098,8 +8067,8 @@ class convolution_random_test_fsv4_input : public convolution_random_test_baseoutput_primitive_id()).get_memory(); - auto out_lay = out_mem.get_layout(); - auto out_ptr = out_mem.cldnn::memory::template pointer(); + auto out_lay = out_mem->get_layout(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); std::stringstream description; for (auto i : net.get_primitives_info()) { @@ -8142,14 +8111,14 @@ class convolution_scale_random_test : public convolution_random_test_baseoutput_type(), format::bfyx, tensor(batch(1), feature(this->output_features()))); auto shift_lay = layout(this->output_type(), format::bfyx, tensor(batch(1), feature(this->output_features()))); - auto scale_mem = memory::allocate(engine, scale_lay); - auto shift_mem = memory::allocate(engine, shift_lay); + auto scale_mem = engine.allocate_memory(scale_lay); + auto shift_mem = engine.allocate_memory(shift_lay); set_values(scale_mem, _scale); set_values(shift_mem, _shift); @@ -8397,20 +8366,17 @@ INSTANTIATE_TEST_CASE_P( to_string_convolution_all_params ); -class convolution_test : public tests::generic_test -{ +class convolution_test : public tests::generic_test { public: - static void TearDownTestCase() - { + static void TearDownTestCase() { all_generic_params.clear(); all_layer_params.clear(); all_test_params.clear(); } - static std::vector> generate_specific_test_params() - { + static std::vector> generate_specific_test_params() { // TODO: check split // TODO: check convolution without bias @@ -8443,8 +8409,7 @@ class convolution_test : public tests::generic_test return all_layer_params; } - static std::vector, std::shared_ptr>> generate_all_test_params() - { + static std::vector, std::shared_ptr>> generate_all_test_params() { generate_specific_test_params(); std::vector input_formats = { cldnn::format::bfyx, cldnn::format::yxfb }; @@ -8457,23 +8422,16 @@ class convolution_test : public tests::generic_test auto data_types = test_data_types(); - for (cldnn::data_types data_type : data_types) - { - for (cldnn::format input_format : input_formats) - { - for (cldnn::format weights_format : weights_formats) - { + for (cldnn::data_types data_type : data_types) { + for (cldnn::format input_format : input_formats) { + for (cldnn::format weights_format : weights_formats) { cldnn::build_options network_build_options; - if (input_format == cldnn::format::bfyx) - { + if (input_format == cldnn::format::bfyx) { network_build_options.set_option(cldnn::build_option::optimize_data(true)); } - for (cldnn::tensor input_size : input_tensor_size) - { - for (cldnn::tensor kernel_size : kernel_sizes) - { - for (auto output_features : output_features_sizes) - { + for (cldnn::tensor input_size : input_tensor_size) { + for (cldnn::tensor kernel_size : kernel_sizes) { + for (auto output_features : output_features_sizes) { std::shared_ptr params = std::make_shared(data_type, input_format, input_size.batch[0], input_size.feature[0], tensor(1, 1, input_size.spatial[0], input_size.spatial[1]), network_build_options); int input_features = params->input_layouts[0].size.feature[0]; params->input_layouts.push_back(cldnn::layout(params->data_type, weights_format, cldnn::tensor(output_features, input_features, kernel_size.spatial[0], kernel_size.spatial[1]))); // weights @@ -8487,10 +8445,8 @@ class convolution_test : public tests::generic_test } // Create all the combinations for the test. - for (const auto& layer_param : all_layer_params) - { - for (auto test_param : all_generic_params) - { + for (const auto& layer_param : all_layer_params) { + for (auto test_param : all_generic_params) { all_test_params.push_back(std::make_tuple(test_param, layer_param)); } } @@ -8498,13 +8454,11 @@ class convolution_test : public tests::generic_test return all_test_params; } - virtual bool is_format_supported(cldnn::format format) - { + virtual bool is_format_supported(cldnn::format format) { return ((format == cldnn::format::bfyx) || (format == cldnn::format::yxfb)); } - virtual cldnn::tensor get_expected_output_tensor() - { + virtual cldnn::tensor get_expected_output_tensor() { auto convolution = std::static_pointer_cast(layer_params); tensor input_size = generic_params->input_layouts[0].size; tensor dilation = convolution->dilation; @@ -8523,58 +8477,52 @@ class convolution_test : public tests::generic_test return cldnn::tensor(input_size.batch[0], output_features, output_size_x, output_size_y); } - virtual void prepare_input_for_test(std::vector& inputs) - { - if (generic_params->data_type == data_types::f32) - { + virtual void prepare_input_for_test(std::vector& inputs) { + if (generic_params->data_type == data_types::f32) { prepare_input_for_test_typed(inputs); - } - else - { + } else { prepare_input_for_test_typed(inputs); } } template - void prepare_input_for_test_typed(std::vector& inputs) - { + void prepare_input_for_test_typed(std::vector& inputs) { int k = (generic_params->data_type == data_types::f32) ? 8 : 4; // Update inputs. auto input = inputs[0]; - auto input_size = inputs[0].get_layout().size; + auto input_size = inputs[0]->get_layout().size; VVVVF input_rnd = generate_random_4d(input_size.batch[0], input_size.feature[0], input_size.spatial[1], input_size.spatial[0], -2, 2, k); - VF input_rnd_vec = flatten_4d(input.get_layout().format, input_rnd); + VF input_rnd_vec = flatten_4d(input->get_layout().format, input_rnd); set_values(input, input_rnd_vec); // Update weights. auto weight_input = inputs[1]; - auto weight_size = inputs[1].get_layout().size; + auto weight_size = inputs[1]->get_layout().size; VVVVF weight_rnd = generate_random_4d(weight_size.batch[0], weight_size.feature[0], weight_size.spatial[1], weight_size.spatial[0], -2, 2, k); - VF weight_rnd_vec = flatten_4d(weight_input.get_layout().format, weight_rnd); + VF weight_rnd_vec = flatten_4d(weight_input->get_layout().format, weight_rnd); set_values(weight_input, weight_rnd_vec); // Update biases. auto bias_input = inputs[2]; - auto bias_size = inputs[2].get_layout().size; + auto bias_size = inputs[2]->get_layout().size; VF bias_rnd = generate_random_1d(bias_size.spatial[0], -2, 2, k); set_values(bias_input, bias_rnd); } template - memory generate_reference_typed(const std::vector& inputs) - { + memory::ptr generate_reference_typed(const std::vector& inputs) { // Output reference is always bfyx. auto convolution = std::static_pointer_cast(layer_params); - data_types dt = inputs[0].get_layout().data_type; + data_types dt = inputs[0]->get_layout().data_type; - tensor input_size = inputs[0].get_layout().size; + tensor input_size = inputs[0]->get_layout().size; tensor dilation = convolution->dilation; tensor stride = convolution->stride; tensor input_offset = convolution->input_offset; - tensor weights_size = inputs[1].get_layout().size; + tensor weights_size = inputs[1]->get_layout().size; padding output_padding = convolution->output_padding; tensor output_size = get_expected_output_tensor(); @@ -8585,27 +8533,23 @@ class convolution_test : public tests::generic_test int output_features = weights_size.batch[0]; int input_features = weights_size.feature[0]; - auto output = memory::allocate( engine, cldnn::layout(dt, cldnn::format::bfyx, output_size, output_padding) ); + auto output = engine.allocate_memory(cldnn::layout(dt, cldnn::format::bfyx, output_size, output_padding)); - auto input_mem = inputs[0].pointer(); - auto weights_mem = inputs[1].pointer(); - auto bias_mem = inputs[2].pointer(); - auto output_mem = output.pointer(); + cldnn::mem_lock input_mem(inputs[0], get_test_stream()); + cldnn::mem_lock weights_mem(inputs[1], get_test_stream()); + cldnn::mem_lock bias_mem(inputs[2], get_test_stream()); + cldnn::mem_lock output_mem(output, get_test_stream()); - tensor output_buffer_size = output.get_layout().get_buffer_size(); + tensor output_buffer_size = output->get_layout().get_buffer_size(); // Initialized output with zeros. std::fill(output_mem.begin(), output_mem.end(), static_cast(0)); // Add the bias - for (int b = 0; b < input_size.batch[0]; b++) - { - for (int out_f = 0; out_f < output_features; out_f++) - { - for (int y = 0; y < output_size_y; y++) - { - for (int x = 0; x < output_size_x; x++) - { + for (int b = 0; b < input_size.batch[0]; b++) { + for (int out_f = 0; out_f < output_features; out_f++) { + for (int y = 0; y < output_size_y; y++) { + for (int x = 0; x < output_size_x; x++) { int output_index = (b * output_buffer_size.feature[0] + out_f) * output_buffer_size.spatial[1] * output_buffer_size.spatial[0]; tensor lower_output_padding = convolution->output_padding.lower_size(); output_index += (lower_output_padding.spatial[1] + y) * output_buffer_size.spatial[0] + lower_output_padding.spatial[0] + x; @@ -8616,22 +8560,17 @@ class convolution_test : public tests::generic_test } } - const auto input0_desc = get_linear_memory_desc(inputs[0].get_layout()); - const auto input1_desc = get_linear_memory_desc(inputs[1].get_layout()); + const auto input0_desc = get_linear_memory_desc(inputs[0]->get_layout()); + const auto input1_desc = get_linear_memory_desc(inputs[1]->get_layout()); // Convolve with weights - for (int b = 0; b < input_size.batch[0]; b++) - { + for (int b = 0; b < input_size.batch[0]; b++) { int input_bi = b; - for (int out_f = 0; out_f < output_features; out_f++) - { - for (int in_f = 0; in_f < input_features; in_f++) - { + for (int out_f = 0; out_f < output_features; out_f++) { + for (int in_f = 0; in_f < input_features; in_f++) { int input_fi = in_f; - for (int y = 0; y < output_size_y; y++) - { - for (int x = 0; x < output_size_x; x++) - { + for (int y = 0; y < output_size_y; y++) { + for (int x = 0; x < output_size_x; x++) { int output_bi = b; int output_fi = out_f; int output_yi = y; @@ -8640,29 +8579,25 @@ class convolution_test : public tests::generic_test tensor lower_output_padding = convolution->output_padding.lower_size(); output_index += (lower_output_padding.spatial[1] + output_yi) * output_buffer_size.spatial[0] + lower_output_padding.spatial[0] + output_xi; - for (int kernel_y = 0; kernel_y < weights_size.spatial[1]; kernel_y++) - { + for (int kernel_y = 0; kernel_y < weights_size.spatial[1]; kernel_y++) { int input_yi = y * stride.spatial[1] + input_offset.spatial[1] + kernel_y * dilation.spatial[1]; - if ((input_yi < 0) || (input_yi >= input_size.spatial[1])) - { + if ((input_yi < 0) || (input_yi >= input_size.spatial[1])) { continue; } - for (int kernel_x = 0; kernel_x < weights_size.spatial[0]; kernel_x++) - { + for (int kernel_x = 0; kernel_x < weights_size.spatial[0]; kernel_x++) { int input_xi = x * stride.spatial[0] + input_offset.spatial[0] + kernel_x * dilation.spatial[0]; - if ((input_xi < 0) || (input_xi >= input_size.spatial[0])) - { + if ((input_xi < 0) || (input_xi >= input_size.spatial[0])) { continue; } - size_t input_index = get_linear_index(inputs[0].get_layout(), input_bi, input_fi, input_yi, input_xi, input0_desc); + size_t input_index = get_linear_index(inputs[0]->get_layout(), input_bi, input_fi, input_yi, input_xi, input0_desc); int weight_bi = out_f; int weight_fi = in_f; int weight_yi = kernel_y; int weight_xi = kernel_x; - size_t weight_index = get_linear_index(inputs[1].get_layout(), weight_bi, weight_fi, weight_yi, weight_xi, input1_desc); + size_t weight_index = get_linear_index(inputs[1]->get_layout(), weight_bi, weight_fi, weight_yi, weight_xi, input1_desc); output_mem[output_index] += input_mem[input_index] * weights_mem[weight_index]; } } @@ -8675,14 +8610,10 @@ class convolution_test : public tests::generic_test return output; } - virtual memory generate_reference(const std::vector& inputs) - { - if (generic_params->data_type == data_types::f32) - { + virtual memory::ptr generate_reference(const std::vector& inputs) { + if (generic_params->data_type == data_types::f32) { return generate_reference_typed(inputs); - } - else - { + } else { return generate_reference_typed(inputs); } } @@ -8698,8 +8629,7 @@ std::vector> convolution_test::all_generic_p std::vector> convolution_test::all_layer_params = {}; std::vector, std::shared_ptr>> convolution_test::all_test_params = {}; -TEST_P(convolution_test, CONVOLUTION) -{ +TEST_P(convolution_test, CONVOLUTION) { run_single_test(); } diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/crop_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/crop_gpu_test.cpp index da96bcab6f490c..e5b6ed490a9e3c 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/crop_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/crop_gpu_test.cpp @@ -3,19 +3,15 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include "api/crop.hpp" -#include -#include -#include -#include -#include -#include "test_utils/test_utils.h" +#include "test_utils.h" + +#include +#include +#include +#include using namespace cldnn; -using namespace tests; +using namespace ::tests; template std::vector generate_random_input(size_t b, size_t f, size_t z, size_t y, size_t x, int min, int max) { @@ -40,7 +36,7 @@ TEST(crop_gpu, basic_in2x3x2x2_crop_all) { // Input : 2x3x4x5 // Output : 1x2x2x3 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 2; auto feature_num = 3; @@ -52,10 +48,10 @@ TEST(crop_gpu, basic_in2x3x2x2_crop_all) { auto crop_x_size = x_size - 2; auto crop_y_size = y_size - 2; - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ batch_num, feature_num, x_size, y_size } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ batch_num, feature_num, x_size, y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(crop("crop", "input", { crop_batch_num, crop_feature_num, crop_x_size, crop_y_size }, { 0, 0, 0, 0 })); std::vector input_vec = generate_random_input(batch_num, feature_num, y_size, x_size, -10, 10); @@ -68,7 +64,7 @@ TEST(crop_gpu, basic_in2x3x2x2_crop_all) { auto outputs = network.execute(); auto output = outputs.at("crop").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int b = 0; b < crop_batch_num; ++b) { //B for (int f = 0; f < crop_feature_num; ++f) { //F @@ -84,7 +80,7 @@ TEST(crop_gpu, basic_in2x3x2x2_crop_all) { } TEST(crop_gpu, basic_in2x2x2x3_crop_all) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 2; auto feature_num = 2; @@ -96,10 +92,10 @@ TEST(crop_gpu, basic_in2x2x2x3_crop_all) { auto crop_x_size = x_size - 1; auto crop_y_size = y_size - 1; - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ batch_num, feature_num, x_size, y_size } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ batch_num, feature_num, x_size, y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(crop("crop", "input", { crop_batch_num, crop_feature_num, crop_x_size, crop_y_size }, { 0, 0, 0, 0 })); std::vector input_vec; @@ -114,7 +110,7 @@ TEST(crop_gpu, basic_in2x2x2x3_crop_all) { auto outputs = network.execute(); auto output = outputs.at("crop").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); printf("Results:\n"); for (int b = 0; b < crop_batch_num; ++b) { //B @@ -135,7 +131,7 @@ TEST(crop_gpu, basic_i32_in2x3x2x2_crop_all) { // Input : 2x3x4x5 // Output : 1x2x2x3 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 2; auto feature_num = 3; @@ -147,10 +143,10 @@ TEST(crop_gpu, basic_i32_in2x3x2x2_crop_all) { auto crop_x_size = x_size - 2; auto crop_y_size = y_size - 2; - auto input = memory::allocate(engine, { data_types::i32, format::yxfb,{ batch_num, feature_num, x_size, y_size } }); + auto input = engine.allocate_memory({ data_types::i32, format::yxfb,{ batch_num, feature_num, x_size, y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(crop("crop", "input", { crop_batch_num, crop_feature_num, crop_x_size, crop_y_size }, { 0, 0, 0, 0 })); std::vector input_vec = generate_random_input(batch_num, feature_num, y_size, x_size, -10, 10); @@ -163,7 +159,7 @@ TEST(crop_gpu, basic_i32_in2x3x2x2_crop_all) { auto outputs = network.execute(); auto output = outputs.at("crop").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int b = 0; b < crop_batch_num; ++b) { //B for (int f = 0; f < crop_feature_num; ++f) { //F @@ -183,7 +179,7 @@ TEST(crop_gpu, basic_i64_in2x3x2x2_crop_all) { // Input : 2x3x4x5 // Output : 1x2x2x3 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 2; auto feature_num = 3; @@ -195,10 +191,10 @@ TEST(crop_gpu, basic_i64_in2x3x2x2_crop_all) { auto crop_x_size = x_size - 2; auto crop_y_size = y_size - 2; - auto input = memory::allocate(engine, { data_types::i64, format::yxfb,{ batch_num, feature_num, x_size, y_size } }); + auto input = engine.allocate_memory({ data_types::i64, format::yxfb,{ batch_num, feature_num, x_size, y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(crop("crop", "input", { crop_batch_num, crop_feature_num, crop_x_size, crop_y_size }, { 0, 0, 0, 0 })); std::vector input_vec = generate_random_input(batch_num, feature_num, y_size, x_size, -10, 10); @@ -211,7 +207,7 @@ TEST(crop_gpu, basic_i64_in2x3x2x2_crop_all) { auto outputs = network.execute(); auto output = outputs.at("crop").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int b = 0; b < crop_batch_num; ++b) { //B for (int f = 0; f < crop_feature_num; ++f) { //F @@ -231,7 +227,7 @@ TEST(crop_gpu, basic_in2x3x2x2_crop_all_bfyx) { // Input : 6x2x4x3 // Output : 3x1x2x2 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 6; auto feature_num = 2; @@ -243,10 +239,10 @@ TEST(crop_gpu, basic_in2x3x2x2_crop_all_bfyx) { auto crop_x_size = x_size - 2; auto crop_y_size = y_size - 1; - auto input = memory::allocate(engine, { data_types::f32,format::bfyx,{ batch_num, feature_num, x_size, y_size } }); + auto input = engine.allocate_memory({ data_types::f32,format::bfyx,{ batch_num, feature_num, x_size, y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(crop("crop", "input", { crop_batch_num, crop_feature_num, crop_x_size, crop_y_size }, {0, 0, 0, 0} )); std::vector input_vec = generate_random_input(batch_num, feature_num, y_size, x_size, -10, 10); @@ -259,7 +255,7 @@ TEST(crop_gpu, basic_in2x3x2x2_crop_all_bfyx) { auto outputs = network.execute(); auto output = outputs.at("crop").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector a; for (int b = 0; b < crop_batch_num; ++b) { //B for (int f = 0; f < crop_feature_num; ++f) { //F @@ -280,7 +276,7 @@ TEST(crop_gpu, basic_i32_in2x3x2x2_crop_all_bfyx) { // Input : 6x2x4x3 // Output : 3x1x2x2 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 6; auto feature_num = 2; @@ -292,10 +288,10 @@ TEST(crop_gpu, basic_i32_in2x3x2x2_crop_all_bfyx) { auto crop_x_size = x_size - 2; auto crop_y_size = y_size - 1; - auto input = memory::allocate(engine, { data_types::i32,format::bfyx,{ batch_num, feature_num, x_size, y_size } }); + auto input = engine.allocate_memory({ data_types::i32,format::bfyx,{ batch_num, feature_num, x_size, y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(crop("crop", "input", { crop_batch_num, crop_feature_num, crop_x_size, crop_y_size }, { 0, 0, 0, 0 })); std::vector input_vec = generate_random_input(batch_num, feature_num, y_size, x_size, -10, 10); @@ -308,7 +304,7 @@ TEST(crop_gpu, basic_i32_in2x3x2x2_crop_all_bfyx) { auto outputs = network.execute(); auto output = outputs.at("crop").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector a; for (int b = 0; b < crop_batch_num; ++b) { //B for (int f = 0; f < crop_feature_num; ++f) { //F @@ -329,7 +325,7 @@ TEST(crop_gpu, basic_i64_in2x3x2x2_crop_all_bfyx) { // Input : 6x2x4x3 // Output : 3x1x2x2 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 6; auto feature_num = 2; @@ -341,10 +337,10 @@ TEST(crop_gpu, basic_i64_in2x3x2x2_crop_all_bfyx) { auto crop_x_size = x_size - 2; auto crop_y_size = y_size - 1; - auto input = memory::allocate(engine, { data_types::i64,format::bfyx,{ batch_num, feature_num, x_size, y_size } }); + auto input = engine.allocate_memory({ data_types::i64,format::bfyx,{ batch_num, feature_num, x_size, y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(crop("crop", "input", { crop_batch_num, crop_feature_num, crop_x_size, crop_y_size }, { 0, 0, 0, 0 })); std::vector input_vec = generate_random_input(batch_num, feature_num, y_size, x_size, -10, 10); @@ -357,7 +353,7 @@ TEST(crop_gpu, basic_i64_in2x3x2x2_crop_all_bfyx) { auto outputs = network.execute(); auto output = outputs.at("crop").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector a; for (int b = 0; b < crop_batch_num; ++b) { //B for (int f = 0; f < crop_feature_num; ++f) { //F @@ -378,7 +374,7 @@ TEST(crop_gpu, basic_in2x3x2x2_crop_all_fyxb) { // Input : 6x2x4x3 // Output : 3x1x2x2 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 6; auto feature_num = 2; @@ -390,10 +386,10 @@ TEST(crop_gpu, basic_in2x3x2x2_crop_all_fyxb) { auto crop_x_size = x_size - 2; auto crop_y_size = y_size - 1; - auto input = memory::allocate(engine, { data_types::f32,format::fyxb,{ batch_num, feature_num, x_size, y_size } }); + auto input = engine.allocate_memory({ data_types::f32,format::fyxb,{ batch_num, feature_num, x_size, y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(crop("crop", "input", { crop_batch_num, crop_feature_num, crop_x_size, crop_y_size }, {0, 0, 0, 0} )); std::vector input_vec = generate_random_input(batch_num, feature_num, y_size, x_size, -10, 10); @@ -406,7 +402,7 @@ TEST(crop_gpu, basic_in2x3x2x2_crop_all_fyxb) { auto outputs = network.execute(); auto output = outputs.at("crop").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int b = 0; b < crop_batch_num; ++b) { //B for (int f = 0; f < crop_feature_num; ++f) { //F for (int y = 0; y < crop_y_size; ++y) { //Y @@ -425,7 +421,7 @@ TEST(crop_gpu, basic_i32_in2x3x2x2_crop_all_fyxb) { // Input : 6x2x4x3 // Output : 3x1x2x2 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 6; auto feature_num = 2; @@ -437,10 +433,10 @@ TEST(crop_gpu, basic_i32_in2x3x2x2_crop_all_fyxb) { auto crop_x_size = x_size - 2; auto crop_y_size = y_size - 1; - auto input = memory::allocate(engine, { data_types::i32,format::fyxb,{ batch_num, feature_num, x_size, y_size } }); + auto input = engine.allocate_memory({ data_types::i32,format::fyxb,{ batch_num, feature_num, x_size, y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(crop("crop", "input", { crop_batch_num, crop_feature_num, crop_x_size, crop_y_size }, { 0, 0, 0, 0 })); std::vector input_vec = generate_random_input(batch_num, feature_num, y_size, x_size, -10, 10); @@ -453,7 +449,7 @@ TEST(crop_gpu, basic_i32_in2x3x2x2_crop_all_fyxb) { auto outputs = network.execute(); auto output = outputs.at("crop").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int b = 0; b < crop_batch_num; ++b) { //B for (int f = 0; f < crop_feature_num; ++f) { //F for (int y = 0; y < crop_y_size; ++y) { //Y @@ -472,7 +468,7 @@ TEST(crop_gpu, basic_i64_in2x3x2x2_crop_all_fyxb) { // Input : 6x2x4x3 // Output : 3x1x2x2 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 6; auto feature_num = 2; @@ -484,10 +480,10 @@ TEST(crop_gpu, basic_i64_in2x3x2x2_crop_all_fyxb) { auto crop_x_size = x_size - 2; auto crop_y_size = y_size - 1; - auto input = memory::allocate(engine, { data_types::i64,format::fyxb,{ batch_num, feature_num, x_size, y_size } }); + auto input = engine.allocate_memory({ data_types::i64,format::fyxb,{ batch_num, feature_num, x_size, y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(crop("crop", "input", { crop_batch_num, crop_feature_num, crop_x_size, crop_y_size }, { 0, 0, 0, 0 })); std::vector input_vec = generate_random_input(batch_num, feature_num, y_size, x_size, -10, 10); @@ -500,7 +496,7 @@ TEST(crop_gpu, basic_i64_in2x3x2x2_crop_all_fyxb) { auto outputs = network.execute(); auto output = outputs.at("crop").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int b = 0; b < crop_batch_num; ++b) { //B for (int f = 0; f < crop_feature_num; ++f) { //F for (int y = 0; y < crop_y_size; ++y) { //Y @@ -526,7 +522,7 @@ TEST(crop_gpu, basic_in2x3x2x2_crop_offsets) { // f1: b0: 5 6 -12 b1: 1.5 5.2 -13 // f1: b0: 7 8 -16 b1: 12 8 -17 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 2; auto feature_num = 2; @@ -543,10 +539,10 @@ TEST(crop_gpu, basic_in2x3x2x2_crop_offsets) { auto x_offset = 1; auto y_offset = 1; - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(crop("crop", "input", tensor(batch(crop_batch_num), spatial(crop_x_size, crop_y_size), feature(crop_feature_num)), { tensor(feature(0)) })); std::vector input_vec = { 1.f, 0.f, 5.f, 1.5f, @@ -564,7 +560,7 @@ TEST(crop_gpu, basic_in2x3x2x2_crop_offsets) { auto outputs = network.execute(); auto output = outputs.at("crop").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int b = 0; b < crop_batch_num; ++b) { //B for (int f = 0; f < crop_feature_num; ++f) { //F @@ -591,7 +587,7 @@ TEST(crop_gpu, basic_i32_in2x3x2x2_crop_offsets) { // f1: b0: 5 6 -12 b1: 15 52 -13 // f1: b0: 7 8 -16 b1: 12 8 -17 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 2; auto feature_num = 2; @@ -608,10 +604,10 @@ TEST(crop_gpu, basic_i32_in2x3x2x2_crop_offsets) { auto x_offset = 1; auto y_offset = 1; - auto input = memory::allocate(engine, { data_types::i32, format::yxfb,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); + auto input = engine.allocate_memory({ data_types::i32, format::yxfb,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(crop("crop", "input", tensor(batch(crop_batch_num), spatial(crop_x_size, crop_y_size), feature(crop_feature_num)), { tensor(feature(0)) })); std::vector input_vec = { 1, 0, 5, 15, @@ -629,7 +625,7 @@ TEST(crop_gpu, basic_i32_in2x3x2x2_crop_offsets) { auto outputs = network.execute(); auto output = outputs.at("crop").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int b = 0; b < crop_batch_num; ++b) { //B for (int f = 0; f < crop_feature_num; ++f) { //F @@ -656,7 +652,7 @@ TEST(crop_gpu, basic_i64_in2x3x2x2_crop_offsets) { // f1: b0: 5 6 -12 b1: 15 52 -13 // f1: b0: 7 8 -16 b1: 12 8 -17 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 2; auto feature_num = 2; @@ -673,10 +669,10 @@ TEST(crop_gpu, basic_i64_in2x3x2x2_crop_offsets) { auto x_offset = 1; auto y_offset = 1; - auto input = memory::allocate(engine, { data_types::i64, format::yxfb,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); + auto input = engine.allocate_memory({ data_types::i64, format::yxfb,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(crop("crop", "input", tensor(batch(crop_batch_num), spatial(crop_x_size, crop_y_size), feature(crop_feature_num)), { tensor(feature(0)) })); std::vector input_vec = { 1, 0, 5, 15, @@ -694,7 +690,7 @@ TEST(crop_gpu, basic_i64_in2x3x2x2_crop_offsets) { auto outputs = network.execute(); auto output = outputs.at("crop").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int b = 0; b < crop_batch_num; ++b) { //B for (int f = 0; f < crop_feature_num; ++f) { //F @@ -738,7 +734,7 @@ TEST(crop_gpu, basic_in1x4x1x1_split) { // Out2: // f0: 4.0 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 1; auto feature_num = 4; @@ -752,10 +748,10 @@ TEST(crop_gpu, basic_in1x4x1x1_split) { auto crop_y_size = 1; auto feature_offset_1 = 0; auto feature_offset_2 = 3; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(crop("crop1", "input", tensor(batch(crop_batch_num), spatial(crop_x_size, crop_y_size), feature(crop_feature_num_1)), { tensor(feature(feature_offset_1), spatial(0,0),batch(0)) })); topology.add(crop("crop2", "input", tensor(batch(crop_batch_num), spatial(crop_x_size, crop_y_size), feature(crop_feature_num_2)), { tensor(feature(feature_offset_2), spatial(0,0),batch(0)) })); @@ -772,21 +768,21 @@ TEST(crop_gpu, basic_in1x4x1x1_split) { auto outputs = network.execute(); auto output = outputs.at("crop1").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < out1.size();i++) EXPECT_EQ(output_ptr[i], out1[i]); std::cout << std::endl; auto output_2 = outputs.at("crop2").get_memory(); - auto output_ptr_2 = output_2.pointer(); + cldnn::mem_lock output_ptr_2(output_2, get_test_stream()); for (size_t i = 0; i < out2.size();i++) EXPECT_EQ(output_ptr_2[i], out2[i]); } TEST(crop_gpu, basic_in1x4x1x1_crop_pad) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 1; auto feature_num = 4; @@ -798,12 +794,12 @@ TEST(crop_gpu, basic_in1x4x1x1_crop_pad) { auto crop_x_size = 1; auto crop_y_size = 1; auto feature_offset_1 = 0; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); padding in_pad({0, 0, 1, 1}, {0, 0, 1, 1}); - auto padded_layout = input.get_layout().with_padding(in_pad); + auto padded_layout = input->get_layout().with_padding(in_pad); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reorder("input_reorder", "input", padded_layout)); topology.add(crop("crop1", "input_reorder", tensor(batch(crop_batch_num), spatial(crop_x_size, crop_y_size), feature(crop_feature_num_1)), { tensor(feature(feature_offset_1), spatial(0,0),batch(0)) })); topology.add(reorder("out_reorder", "crop1", format::bfyx, data_types::f32)); @@ -819,7 +815,7 @@ TEST(crop_gpu, basic_in1x4x1x1_crop_pad) { auto outputs = network.execute(); auto output = outputs.at("out_reorder").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < out1.size();i++) EXPECT_EQ(output_ptr[i], out1[i]); @@ -854,7 +850,7 @@ TEST(crop_gpu, basic_i32_in1x4x1x1_split) { // Out2: // f0: 4 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 1; auto feature_num = 4; @@ -868,10 +864,10 @@ TEST(crop_gpu, basic_i32_in1x4x1x1_split) { auto crop_y_size = 1; auto feature_offset_1 = 0; auto feature_offset_2 = 3; - auto input = memory::allocate(engine, { data_types::i32, format::bfyx,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); + auto input = engine.allocate_memory({ data_types::i32, format::bfyx,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(crop("crop1", "input", tensor(batch(crop_batch_num), spatial(crop_x_size, crop_y_size), feature(crop_feature_num_1)), { tensor(feature(feature_offset_1), spatial(0,0),batch(0)) })); topology.add(crop("crop2", "input", tensor(batch(crop_batch_num), spatial(crop_x_size, crop_y_size), feature(crop_feature_num_2)), { tensor(feature(feature_offset_2), spatial(0,0),batch(0)) })); @@ -888,14 +884,13 @@ TEST(crop_gpu, basic_i32_in1x4x1x1_split) { auto outputs = network.execute(); auto output = outputs.at("crop1").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < out1.size(); i++) EXPECT_EQ(output_ptr[i], out1[i]); - std::cout << std::endl; auto output_2 = outputs.at("crop2").get_memory(); - auto output_ptr_2 = output_2.pointer(); + cldnn::mem_lock output_ptr_2(output_2, get_test_stream()); for (size_t i = 0; i < out2.size(); i++) EXPECT_EQ(output_ptr_2[i], out2[i]); @@ -930,7 +925,7 @@ TEST(crop_gpu, basic_i64_in1x4x1x1_split) { // Out2: // f0: 4 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 1; auto feature_num = 4; @@ -944,10 +939,10 @@ TEST(crop_gpu, basic_i64_in1x4x1x1_split) { auto crop_y_size = 1; auto feature_offset_1 = 0; auto feature_offset_2 = 3; - auto input = memory::allocate(engine, { data_types::i64, format::bfyx,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); + auto input = engine.allocate_memory({ data_types::i64, format::bfyx,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(crop("crop1", "input", tensor(batch(crop_batch_num), spatial(crop_x_size, crop_y_size), feature(crop_feature_num_1)), { tensor(feature(feature_offset_1), spatial(0,0),batch(0)) })); topology.add(crop("crop2", "input", tensor(batch(crop_batch_num), spatial(crop_x_size, crop_y_size), feature(crop_feature_num_2)), { tensor(feature(feature_offset_2), spatial(0,0),batch(0)) })); @@ -964,14 +959,13 @@ TEST(crop_gpu, basic_i64_in1x4x1x1_split) { auto outputs = network.execute(); auto output = outputs.at("crop1").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < out1.size(); i++) EXPECT_EQ(output_ptr[i], out1[i]); - std::cout << std::endl; auto output_2 = outputs.at("crop2").get_memory(); - auto output_ptr_2 = output_2.pointer(); + cldnn::mem_lock output_ptr_2(output_2, get_test_stream()); for (size_t i = 0; i < out2.size(); i++) EXPECT_EQ(output_ptr_2[i], out2[i]); @@ -1007,8 +1001,8 @@ TEST(crop_gpu, basic_in1x4x1x1_split_w_relu) { // Out2: // f0: 4.0 // disable memory pool when we want to check optimized out internal results - engine_configuration cfg{ false, false, false, std::string(), std::string(), true /*oooq*/, std::string(),std::string(), priority_mode_types::disabled, throttle_mode_types::disabled, false /*mem_pool*/ }; - engine engine{ cfg }; + engine_configuration cfg{ false, queue_types::out_of_order, std::string(), priority_mode_types::disabled, throttle_mode_types::disabled, false /*mem_pool*/ }; + auto engine = engine::create(engine_types::ocl, runtime_types::ocl, cfg); auto batch_num = 1; auto feature_num = 4; auto x_size = 1; @@ -1020,10 +1014,10 @@ TEST(crop_gpu, basic_in1x4x1x1_split_w_relu) { auto crop_y_size = 1; auto feature_offset_1 = 0; auto feature_offset_2 = 3; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); + auto input = engine->allocate_memory({ data_types::f32, format::bfyx,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(activation("relu", "input", activation_func::relu)); topology.add(crop("crop1", "relu", tensor(batch(crop_batch_num), spatial(crop_x_size, crop_y_size), feature(crop_feature_num_1)), { tensor(feature(feature_offset_1), spatial(0,0),batch(0)) })); topology.add(crop("crop2", "relu", tensor(batch(crop_batch_num), spatial(crop_x_size, crop_y_size), feature(crop_feature_num_2)), { tensor(feature(feature_offset_2), spatial(0,0),batch(0)) })); @@ -1038,22 +1032,22 @@ TEST(crop_gpu, basic_in1x4x1x1_split_w_relu) { bo.set_option(build_option::optimize_data(true)); bo.set_option(build_option::debug(true)); //required to have optimized crop despite the fact that it's specified as an output - network network(engine, topology, bo); + network network(*engine, topology, bo); network.set_input_data("input", input); auto outputs = network.execute(); auto output = outputs.at("relu1").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); // check if crop has been executed in place - auto in_place = outputs.at("crop1").get_memory().is_the_same_buffer(outputs.at("relu").get_memory()); + auto in_place = engine->is_the_same_buffer(*outputs.at("crop1").get_memory(), *outputs.at("relu").get_memory()); EXPECT_TRUE(in_place); for (size_t i = 0; i < out1.size();i++) EXPECT_EQ(output_ptr[i], out1[i]); auto output_2 = outputs.at("relu2").get_memory(); - auto output_ptr_2 = output_2.pointer(); + cldnn::mem_lock output_ptr_2(output_2, get_test_stream()); for (size_t i = 0; i < out2.size();i++) EXPECT_EQ(output_ptr_2[i], out2[i]); @@ -1064,7 +1058,7 @@ TEST(crop_gpu, basic_in3x1x2x2x1_crop_all_bfzyx) { // Input : 6x2x4x3x2 // Output : 3x1x2x2x1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 6; auto feature_num = 2; @@ -1078,10 +1072,10 @@ TEST(crop_gpu, basic_in3x1x2x2x1_crop_all_bfzyx) { auto crop_y_size = y_size - 1; auto crop_z_size = z_size - 1; - auto input = memory::allocate(engine, { data_types::f32,format::bfzyx,{ batch_num, feature_num, x_size, y_size, z_size } }); + auto input = engine.allocate_memory({ data_types::f32,format::bfzyx,{ batch_num, feature_num, x_size, y_size, z_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(crop("crop", "input", { crop_batch_num, crop_feature_num, crop_x_size, crop_y_size, crop_z_size }, { 0, 0, 0, 0, 0 })); std::vector input_vec = generate_random_input(batch_num, feature_num, y_size, x_size, -10, 10); @@ -1094,7 +1088,7 @@ TEST(crop_gpu, basic_in3x1x2x2x1_crop_all_bfzyx) { auto outputs = network.execute(); auto output = outputs.at("crop").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int b = 0; b < crop_batch_num; ++b) { //B for (int f = 0; f < crop_feature_num; ++f) { //F for (int z = 0; z < crop_z_size; ++z) { //Z @@ -1115,7 +1109,7 @@ TEST(crop_gpu, basic_in3x1x3x2x2x1_crop_all_bfwzyx) { // Input : 6x2x6x4x3x2 // Output : 3x1x3x2x2x1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 6; auto feature_num = 2; @@ -1133,10 +1127,10 @@ TEST(crop_gpu, basic_in3x1x3x2x2x1_crop_all_bfwzyx) { tensor in_size = tensor(format::bfwzyx, { batch_num, feature_num, w_size, z_size, y_size, x_size }); tensor crop_size = tensor(format::bfwzyx, { crop_batch_num, crop_feature_num, crop_w_size, crop_z_size, crop_y_size, crop_x_size }); - auto input = memory::allocate(engine, { data_types::f32,format::bfwzyx, in_size }); + auto input = engine.allocate_memory({ data_types::f32,format::bfwzyx, in_size }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(crop("crop", "input", crop_size, tensor{ 0 })); VVVVVVF input_rnd = generate_random_6d(batch_num, feature_num, w_size, z_size, y_size, x_size, -10, 10); @@ -1150,7 +1144,7 @@ TEST(crop_gpu, basic_in3x1x3x2x2x1_crop_all_bfwzyx) { auto outputs = network.execute(); auto output = outputs.at("crop").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int b = 0; b < crop_batch_num; ++b) { //B for (int f = 0; f < crop_feature_num; ++f) { //F for (int w = 0; w < crop_w_size; ++w) { //W @@ -1176,7 +1170,7 @@ class crop_gpu : public ::testing::TestWithParam {}; TEST_P(crop_gpu, pad_test) { auto p = GetParam(); - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = std::get<0>(p); auto feature_num = std::get<1>(p); @@ -1194,10 +1188,10 @@ TEST_P(crop_gpu, pad_test) { auto in_out_format = std::get<3>(p).first; auto crop_format = std::get<3>(p).second; - auto input = memory::allocate(engine, { data_types::f32, in_out_format, { tensor(spatial(x_size, y_size, z_size), feature(feature_num), batch(batch_num)) } }); + auto input = engine.allocate_memory({ data_types::f32, in_out_format, { tensor(spatial(x_size, y_size, z_size), feature(feature_num), batch(batch_num)) } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reorder("reorder", "input", crop_format, data_types::f32)); topology.add(crop("crop1", "reorder", tensor(batch(crop_batch_num), spatial(crop_x_size, crop_y_size, crop_z_size), feature(crop_feature_num_1)), { tensor(feature(feature_offset_1), spatial(0,0,0), batch(0)) })); topology.add(reorder("out", "crop1", in_out_format, data_types::f32)); @@ -1225,7 +1219,7 @@ TEST_P(crop_gpu, pad_test) { auto outputs = network.execute(); auto output = outputs.at("out").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < res.size(); i++) EXPECT_EQ(output_ptr[i], res[i]); diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/cum_sum_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/cum_sum_gpu_test.cpp index bb40415d16aed1..0020c53076a293 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/cum_sum_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/cum_sum_gpu_test.cpp @@ -3,21 +3,18 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include "api/cum_sum.hpp" -#include -#include -#include -#include "test_utils/test_utils.h" -#include +#include "test_utils.h" + +#include +#include +#include #include #include using namespace cldnn; -using namespace tests; +using namespace ::tests; template static std::vector cumsum(const std::vector& input, @@ -150,7 +147,7 @@ class cum_sum_gpu : public ::testing::TestWithParam {}; TEST_P(cum_sum_gpu, basic_test) { auto p = GetParam(); - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto b = std::get<0>(p); auto f = std::get<1>(p); @@ -169,14 +166,14 @@ TEST_P(cum_sum_gpu, basic_test) { else if (in_out_format == format::bfzyx) size = 5; - auto input = memory::allocate(engine, { data_types::f32, in_out_format, shape }); + auto input = engine.allocate_memory({ data_types::f32, in_out_format, shape }); const int inputSize = b * f * w * z * y * x; auto inputVals = generateVector(inputSize); set_values(input, inputVals); topology topology; - topology.add(input_layout("Input0", input.get_layout())); + topology.add(input_layout("Input0", input->get_layout())); topology.add(cum_sum("cum_sum", "Input0", getCumSumAxis(axis, size), exclusive, reverse)); network network(engine, topology); @@ -189,7 +186,7 @@ TEST_P(cum_sum_gpu, basic_test) { EXPECT_EQ(outputs.begin()->first, "cum_sum"); auto output = outputs.at("cum_sum").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); auto answers = cumsum(inputVals, in_out_format, { b, f, w, z, y, x }, axis, exclusive, reverse); ASSERT_EQ(output_ptr.size(), answers.size()); @@ -306,21 +303,22 @@ INSTANTIATE_TEST_CASE_P( ::testing::ValuesIn(variants) ), ); -TEST(cum_sum_gpu_f16, basic_1d) { +// FIXME: This test fails on some driver versions. Looks like UB in impl or driver issue +TEST(cum_sum_gpu_f16, DISABLED_basic_1d) { // Input : 5x1x1x1 // Output : 5x1x1x1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); tensor shape = { 5, 1, 1, 1 }; std::vector inputVals = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f }; - auto input = memory::allocate(engine, { data_types::f16, format::bfyx, shape }); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx, shape }); set_values(input, vectorCast(inputVals)); topology topology; - topology.add(input_layout("Input0", input.get_layout())); + topology.add(input_layout("Input0", input->get_layout())); topology.add(cum_sum("cum_sum", "Input0")); network network(engine, topology); @@ -333,65 +331,12 @@ TEST(cum_sum_gpu_f16, basic_1d) { EXPECT_EQ(outputs.begin()->first, "cum_sum"); auto output = outputs.at("cum_sum").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); auto answers = cumsum(inputVals, format::bfyx, { 5, 1, 1, 1, 1, 1 }); - ASSERT_EQ(output_ptr.size(), answers.size()); - for (size_t i = 0; i < answers.size(); ++i) - { + ASSERT_EQ(output->count(), answers.size()); + for (size_t i = 0; i < answers.size(); ++i) { EXPECT_TRUE(are_equal(answers[i], float16_to_float32(output_ptr[i]))) << i; } } - -TEST(cum_sum_gpu_f32, perf) { - // Input : 384x160x160x1 - // Output : 384x160x160x1 - - constexpr int batch = 384; - constexpr int features = 160; - constexpr int y = 160; - constexpr int x = 1; - engine_configuration configuration(true); - engine engine(configuration); - tensor shape = { batch, features, y, x }; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, shape }); - constexpr int inputSize = batch * features * y * x; - auto inputVals = generateVector(inputSize); - - set_values(input, inputVals); - - topology topology; - topology.add(input_layout("Input0", input.get_layout())); - topology.add(cum_sum("cum_sum", "Input0")); - - network network(engine, topology); - - network.set_input_data("Input0", input); - - auto outputs = network.execute(); - - EXPECT_EQ(outputs.size(), size_t(1)); - EXPECT_EQ(outputs.begin()->first, "cum_sum"); - - auto output = outputs.at("cum_sum").get_memory(); - auto output_ptr = output.pointer(); - - auto profilingTime = [](const primitive_id& id, const event& ev) { - cldnn::instrumentation::profiling_info cldnnInfo{id, ev.get_profiling_info()}; - long long time = 0; - for (auto &interval : cldnnInfo.intervals) { - using duration_t = std::chrono::duration; - time += std::chrono::duration_cast(interval.value->value()).count(); - } - return time; - }; - - - auto ep = network.get_executed_primitives(); - auto cumSumEP = ep.find("cum_sum"); - ASSERT_NE(cumSumEP, ep.end()) << "Cannot find 'cum_sum' id in executed primitives"; - - auto time = profilingTime(cumSumEP->first, cumSumEP->second); - std::cout << "Time, id: " << cumSumEP->first << ", time: " << time << std::endl; -} diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/custom_gpu_primitive_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/custom_gpu_primitive_test.cpp index a484f20291a126..f93009ee6397be 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/custom_gpu_primitive_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/custom_gpu_primitive_test.cpp @@ -2,18 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include "api/eltwise.hpp" -#include "api/reorder.hpp" -#include "api/custom_gpu_primitive.hpp" -#include -#include -#include -#include -#include "test_utils/test_utils.h" +#include "test_utils.h" + +#include +#include +#include +#include namespace cldnn { @@ -21,7 +15,7 @@ namespace cldnn } using namespace cldnn; -using namespace tests; +using namespace ::tests; TEST(custom_gpu_primitive_f32, add_basic_in2x2x2x2) { // Input2 : 2x2x2 @@ -29,28 +23,28 @@ TEST(custom_gpu_primitive_f32, add_basic_in2x2x2x2) { // Output : 2x2x2x2 // Input: - // f0: b0: 1 2 b1: 0 0 - // f0: b0: 3 4 b1: 0.5 -0.5 - // f1: b0: 5 6 b1: 1.5 5.2 - // f1: b0: 7 8 b1: 12 8 + // f0: b0: 1 2 b1: 0 0 + // f0: b0: 3 4 b1: 0.5 -0.5 + // f1: b0: 5 6 b1: 1.5 5.2 + // f1: b0: 7 8 b1: 12 8 // // Input2 - // f0: b0: 0.5 5 b1: 2.5 7 + // f0: b0: 0.5 5 b1: 2.5 7 // f0: b0: 15 -2 b1: 17 6.5 // f1: b0: 0.5 2 b1: 2.5 4 // f1: b0: 8 -0.5 b1: 10 -2.5 // // Output: - // f0: b0: 1.5 7 b1: 2.5 7 - // f0: b0: 18 2 b1: 17.5 6 - // f1: b0: 5.5 8 b1: 4 9.2 - // f1: b0: 15 16.5 b1: 22 16.5 + // f0: b0: 1.5 7 b1: 2.5 7 + // f0: b0: 18 2 b1: 17.5 6 + // f1: b0: 5.5 8 b1: 4 9.2 + // f1: b0: 15 16.5 b1: 22 16.5 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); std::string kernel_code = R"__krnl( @@ -68,10 +62,10 @@ TEST(custom_gpu_primitive_f32, add_basic_in2x2x2x2) { layout output_layout = { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }; std::vector gws = { output_layout.count() }; topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(custom_gpu_primitive( - "user_kernel", + "user_kernel", { "input", "input2" }, { kernel_code }, entry_point, @@ -109,10 +103,9 @@ TEST(custom_gpu_primitive_f32, add_basic_in2x2x2x2) { 18.f,17.5f, 15.f, 22.f, 2.f, 6.f, 7.5f, 5.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); - for (int i = 0; i < 16; i++) - { + for (int i = 0; i < 16; i++) { EXPECT_TRUE(are_equal(answers[i], output_ptr[i])); } } @@ -125,28 +118,28 @@ void add_basic_in2x2x2x2_with_reorder() // Output : 2x2x2x2 // Input: - // f0: b0: 1 2 b1: 0 0 - // f0: b0: 3 4 b1: 0.5 -0.5 - // f1: b0: 5 6 b1: 1.5 5.2 - // f1: b0: 7 8 b1: 12 8 + // f0: b0: 1 2 b1: 0 0 + // f0: b0: 3 4 b1: 0.5 -0.5 + // f1: b0: 5 6 b1: 1.5 5.2 + // f1: b0: 7 8 b1: 12 8 // // Input2 - // f0: b0: 0.5 5 b1: 2.5 7 + // f0: b0: 0.5 5 b1: 2.5 7 // f0: b0: 15 -2 b1: 17 6.5 // f1: b0: 0.5 2 b1: 2.5 4 // f1: b0: 8 -0.5 b1: 10 -2.5 // // Output: - // f0: b0: 1.5 7 b1: 2.5 7 - // f0: b0: 18 2 b1: 17.5 6 - // f1: b0: 5.5 8 b1: 4 9.2 - // f1: b0: 15 16.5 b1: 22 16.5 + // f0: b0: 1.5 7 b1: 2.5 7 + // f0: b0: 18 2 b1: 17.5 6 + // f1: b0: 5.5 8 b1: 4 9.2 + // f1: b0: 15 16.5 b1: 22 16.5 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); std::string data_type_string = "float"; switch (DType) @@ -172,8 +165,8 @@ void add_basic_in2x2x2x2_with_reorder() layout output_layout = { DType, format::yxfb,{ 2, 2, 2, 2 } }; std::vector gws = { output_layout.count() }; topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(reorder("to_int1", "input", { DType, format::yxfb,{ 2,2,2,2 } })); topology.add(reorder("to_int2", "input2", { DType, format::yxfb,{ 2,2,2,2 } })); topology.add(custom_gpu_primitive( @@ -216,7 +209,7 @@ void add_basic_in2x2x2x2_with_reorder() 18.f,17.f, 15.f, 22.f, 2.f, 6.f, 8.f, 6.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -238,28 +231,28 @@ TEST(custom_gpu_primitive_f32, eltwise_add_basic_in2x2x2x2) { // Output : 2x2x2x2 // Input: - // f0: b0: 1 2 b1: 0 0 - // f0: b0: 3 4 b1: 0.5 -0.5 - // f1: b0: 5 6 b1: 1.5 5.2 - // f1: b0: 7 8 b1: 12 8 + // f0: b0: 1 2 b1: 0 0 + // f0: b0: 3 4 b1: 0.5 -0.5 + // f1: b0: 5 6 b1: 1.5 5.2 + // f1: b0: 7 8 b1: 12 8 // // Input2 - // f0: b0: 0.5 5 b1: 2.5 7 + // f0: b0: 0.5 5 b1: 2.5 7 // f0: b0: 15 -2 b1: 17 6.5 // f1: b0: 0.5 2 b1: 2.5 4 // f1: b0: 8 -0.5 b1: 10 -2.5 // // Output: - // f0: b0: 1.5 7 b1: 2.5 7 - // f0: b0: 18 2 b1: 17.5 6 - // f1: b0: 5.5 8 b1: 4 9.2 - // f1: b0: 15 16.5 b1: 22 16.5 + // f0: b0: 1.5 7 b1: 2.5 7 + // f0: b0: 18 2 b1: 17.5 6 + // f1: b0: 5.5 8 b1: 4 9.2 + // f1: b0: 15 16.5 b1: 22 16.5 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); std::string kernel_code = R"__krnl( @@ -274,8 +267,8 @@ TEST(custom_gpu_primitive_f32, eltwise_add_basic_in2x2x2x2) { layout output_layout = { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }; std::vector gws = { output_layout.count() }; topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", {"input", "input2"}, eltwise_mode::sum)); topology.add(custom_gpu_primitive( "user_kernel", @@ -311,13 +304,13 @@ TEST(custom_gpu_primitive_f32, eltwise_add_basic_in2x2x2x2) { auto output = outputs.at("user_kernel").get_memory(); - float answers[16] = + float answers[16] = { 2.5f, 3.5f, 6.5f, 5.f, 8.f, 8.f, 9.f, 10.2f, 19.f, 18.5f, 16.f, 23.f, 3.f, 7.f, 8.5f, 6.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -331,28 +324,28 @@ TEST(custom_gpu_primitive_f32, add_eltwise_basic_in2x2x2x2) { // Output : 2x2x2x2 // Input: - // f0: b0: 1 2 b1: 0 0 - // f0: b0: 3 4 b1: 0.5 -0.5 - // f1: b0: 5 6 b1: 1.5 5.2 - // f1: b0: 7 8 b1: 12 8 + // f0: b0: 1 2 b1: 0 0 + // f0: b0: 3 4 b1: 0.5 -0.5 + // f1: b0: 5 6 b1: 1.5 5.2 + // f1: b0: 7 8 b1: 12 8 // // Input2 - // f0: b0: 0.5 5 b1: 2.5 7 + // f0: b0: 0.5 5 b1: 2.5 7 // f0: b0: 15 -2 b1: 17 6.5 // f1: b0: 0.5 2 b1: 2.5 4 // f1: b0: 8 -0.5 b1: 10 -2.5 // // Output: - // f0: b0: 1.5 7 b1: 2.5 7 - // f0: b0: 18 2 b1: 17.5 6 - // f1: b0: 5.5 8 b1: 4 9.2 - // f1: b0: 15 16.5 b1: 22 16.5 + // f0: b0: 1.5 7 b1: 2.5 7 + // f0: b0: 18 2 b1: 17.5 6 + // f1: b0: 5.5 8 b1: 4 9.2 + // f1: b0: 15 16.5 b1: 22 16.5 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); std::string kernel_code = R"__krnl( @@ -367,8 +360,8 @@ TEST(custom_gpu_primitive_f32, add_eltwise_basic_in2x2x2x2) { layout output_layout = { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }; std::vector gws = { output_layout.count() }; topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(custom_gpu_primitive( "user_kernel", { "input" }, @@ -410,7 +403,7 @@ TEST(custom_gpu_primitive_f32, add_eltwise_basic_in2x2x2x2) { 19.f, 18.5f, 16.f, 23.f, 3.f, 7.f, 8.5f, 6.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -424,27 +417,27 @@ TEST(custom_gpu_primitive_f32, two_kernels_with_same_entry_point_basic_in2x2x2x2 // Output : 2x2x2x2 // Input: - // f0: b0: 1 2 b1: 0 0 - // f0: b0: 3 4 b1: 0.5 -0.5 - // f1: b0: 5 6 b1: 1.5 5.2 - // f1: b0: 7 8 b1: 12 8 + // f0: b0: 1 2 b1: 0 0 + // f0: b0: 3 4 b1: 0.5 -0.5 + // f1: b0: 5 6 b1: 1.5 5.2 + // f1: b0: 7 8 b1: 12 8 // // Input2 - // f0: b0: 0.5 5 b1: 2.5 7 + // f0: b0: 0.5 5 b1: 2.5 7 // f0: b0: 15 -2 b1: 17 6.5 // f1: b0: 0.5 2 b1: 2.5 4 // f1: b0: 8 -0.5 b1: 10 -2.5 // // Output: - // f0: b0: 1.5 7 b1: 2.5 7 - // f0: b0: 18 2 b1: 17.5 6 - // f1: b0: 5.5 8 b1: 4 9.2 - // f1: b0: 15 16.5 b1: 22 16.5 + // f0: b0: 1.5 7 b1: 2.5 7 + // f0: b0: 18 2 b1: 17.5 6 + // f1: b0: 5.5 8 b1: 4 9.2 + // f1: b0: 15 16.5 b1: 22 16.5 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); std::string kernel_code1 = R"__krnl( @@ -454,7 +447,7 @@ TEST(custom_gpu_primitive_f32, two_kernels_with_same_entry_point_basic_in2x2x2x2 output[idx] = input0[idx] + SCALAR; } )__krnl"; - + std::string kernel_code2 = R"__krnl( __kernel void add_kernel(const __global float* input0, __global float* output) @@ -468,7 +461,7 @@ TEST(custom_gpu_primitive_f32, two_kernels_with_same_entry_point_basic_in2x2x2x2 layout output_layout = { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }; std::vector gws = { output_layout.count() }; topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(custom_gpu_primitive( "user_kernel1", { "input" }, @@ -505,20 +498,19 @@ TEST(custom_gpu_primitive_f32, two_kernels_with_same_entry_point_basic_in2x2x2x2 auto output = outputs.at("user_kernel2").get_memory(); - auto output_ptr = output.pointer(); - auto input_ptr = input.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + cldnn::mem_lock input_ptr(input, get_test_stream()); - for (int i = 0; i < 16; i++) - { + for (int i = 0; i < 16; i++) { EXPECT_TRUE(are_equal(input_ptr[i] + 7, output_ptr[i])); } } TEST(custom_gpu_primitive_u8, add_basic_in2x2x2x2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::u8, format::yxfb,{ 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::u8, format::yxfb,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::u8, format::yxfb,{ 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::u8, format::yxfb,{ 2, 2, 2, 2 } }); std::string kernel_code = R"__krnl( @@ -533,8 +525,8 @@ TEST(custom_gpu_primitive_u8, add_basic_in2x2x2x2) { layout output_layout = { data_types::u8, format::yxfb,{ 2, 2, 2, 2 } }; std::vector gws = { output_layout.count() }; topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(custom_gpu_primitive( "user_kernel", { "input", "input2" }, @@ -556,7 +548,7 @@ TEST(custom_gpu_primitive_u8, add_basic_in2x2x2x2) { 0, 2, 0, 2, 55, 75, 20, 4, 15, 17, 80, 10, - 2, 60, 0, 20 + 2, 60, 0, 20 }); network network(engine, topology); @@ -577,10 +569,9 @@ TEST(custom_gpu_primitive_u8, add_basic_in2x2x2x2) { 6, 160, 8, 200 }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); - for (int i = 0; i < 16; i++) - { + for (int i = 0; i < 16; i++) { EXPECT_TRUE(are_equal(answers[i], output_ptr[i])); } } diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/deconvolution_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/deconvolution_gpu_test.cpp index a5789188fbf506..eb82022c8b389e 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/deconvolution_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/deconvolution_gpu_test.cpp @@ -4,26 +4,20 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include "api/deconvolution.hpp" -#include "api/crop.hpp" -#include -#include -#include -#include #include "test_utils/test_utils.h" -#include "test_utils/float16.h" -#include "api/reorder.hpp" -#include "src/include/to_string_utils.h" + +#include +#include +#include +#include +#include namespace cldnn { template<> struct type_to_data_type { static const data_types value = data_types::f16; }; } using namespace cldnn; -using namespace tests; +using namespace ::tests; template struct deconvolution_traits { @@ -147,18 +141,18 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_nopad) { // 18 0.75 7.25 // 23 42.5 15.5 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::oiyx, { 1, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::oiyx, { 1, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f }); set_values(weights, { -2.0f, 0.5f, 3.5f, 1.5f }); set_values(biases, { 2.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), deconvolution("deconv", "input", { "weights" }, { "biases" }, { 1,1,1,1 }) @@ -173,7 +167,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_nopad) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -14.f, 5.f, 2.25f, @@ -208,16 +202,16 @@ TEST(deconvolution_f32_fw_gpu, no_bias_basic_wsiz2x2_in2x2x1x1_nopad) { // 18 0.75 7.25 // 23 42.5 15.5 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 1, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::oiyx,{ 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 1, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::oiyx,{ 1, 1, 2, 2 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f }); set_values(weights, { -2.0f, 0.5f, 3.5f, 1.5f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), deconvolution("deconv", "input", { "weights" }) ); @@ -231,7 +225,7 @@ TEST(deconvolution_f32_fw_gpu, no_bias_basic_wsiz2x2_in2x2x1x1_nopad) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -16.f, 3.f, 0.25f, @@ -265,18 +259,18 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_nopad_bfyx) { // Filt // 18 0.75 7.25 // 23 42.5 15.5 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::oiyx, { 1, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::oiyx, { 1, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f }); set_values(weights, { -2.0f, 0.5f, 3.5f, 1.5f }); set_values(biases, { 2.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), deconvolution("deconv", "input", { "weights" }, { "biases" }, { 1,1,1,1 }) @@ -291,7 +285,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_nopad_bfyx) { // Filt auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -14.f, 5.f, 2.25f, @@ -325,18 +319,18 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_pad1) { // Output: // 0.75 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::oiyx, { 1, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::oiyx, { 1, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f }); set_values(weights, { -2.0f, 0.5f, 3.5f, 1.5f }); set_values(biases, { 2.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), deconvolution("deconv", "input", { "weights" }, { "biases" }, { 1, 1, 1, 1 }, { 0, 0, -1, -1 }) @@ -351,7 +345,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_pad1) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); EXPECT_FLOAT_EQ(0.75f, output_ptr[0]); } @@ -376,18 +370,18 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_stride2_nopad) { // Output: // 0.75 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::oiyx, { 1, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::oiyx, { 1, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f }); set_values(weights, { -2.0f, 0.5f, 3.5f, 1.5f }); set_values(biases, { 1.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), deconvolution("deconv", "input", { "weights" }, { "biases" }, { 1,1,2,2 }) @@ -402,7 +396,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_stride2_nopad) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -15.f, 5.f, 0.f, 1.25f, @@ -441,18 +435,18 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_stride4_pad2) { // 0 0 0 // 6 0 -18 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::oiyx, { 1, 1, 3, 3 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::oiyx, { 1, 1, 3, 3 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f }); set_values(weights, { -2.0f, 0.5f, 1.f, 3.5f, 1.5f, 2.f, 3.f, 4.f, 5.f }); set_values(biases, { 0.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), deconvolution("deconv", "input", { "weights" }, { "biases" }, { 1, 1, 4, 4 }, { 0, 0, -2, -2 }) @@ -467,7 +461,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_stride4_pad2) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { 40.f, 0.f, 1.5f, @@ -503,18 +497,18 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x2_stride2_pad1) { // -3 4.5 0.5 22 // 13 -17 5 -7 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 1, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::oiyx, { 1, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 1, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::oiyx, { 1, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, { 8.f, 1.f, 0.5f, 3.f, 6.f, 2.f, 9.f, 4.f }); set_values(weights, { -2.f, 2.f, 7.f, -0.5f }); set_values(biases, { 1.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), deconvolution("deconv", "input", { "weights" }, { "biases" }, { 1, 1, 2, 2 }, { 0, 0, -1, -1 }) @@ -529,7 +523,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x2_stride2_pad1) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -3.f, 0.5f, 4.5f, 22.f, @@ -568,20 +562,20 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2x2_in2x2x1x1_stride2_pad1) { // f1: 1 8.5 // f1: 17 - 13 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); cldnn::build_options options; options.set_option(cldnn::build_option::optimize_data(true)); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::yxio, { 2, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::yxio, { 2, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f }); set_values(weights, { -2.f, -2.f, 2.f, 2.f, 7.f, 7.f, -0.5f, -0.5f }); set_values(biases, { 1.0f, 5.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), deconvolution("deconv", "input", { "weights" }, { "biases" }, { 1, 1, 2, 2 }, { 0, 0, -1, -1 }) @@ -596,7 +590,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2x2_in2x2x1x1_stride2_pad1) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -3.f, 1.f, 4.5f, 8.5f, @@ -631,18 +625,18 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x2_bfyx_stride2_pad1) { // -3 4.5 0.5 22 // 13 -17 5 -7 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 1, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::oiyx, { 1, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 1, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::oiyx, { 1, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f, 1.f, 3.f, 2.f, 4.f }); set_values(weights, { -2.f, 2.f, 7.f, -0.5f }); set_values(biases, { 1.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), deconvolution("deconv", "input", { "weights" }, { "biases" }, { 1, 1, 2, 2 }, { 0, 0, -1, -1 }) @@ -657,7 +651,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x2_bfyx_stride2_pad1) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -3.f, 4.5f, 13.f, -17.f, @@ -693,19 +687,19 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x2_bfyx_stride2_pad1_input_p // -3 4.5 0.5 22 // 13 -17 5 -7 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 1, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::oiyx,{ 1, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 1, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::oiyx,{ 1, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f, 1.f, 3.f, 2.f, 4.f }); set_values(weights, { -2.f, 2.f, 7.f, -0.5f }); set_values(biases, { 1.0f }); topology topology( - input_layout("input", input.get_layout()), - reorder("reorder", "input", input.get_layout().with_padding(padding{ { 0, 0, 1, 2 }, 0 })), + input_layout("input", input->get_layout()), + reorder("reorder", "input", input->get_layout().with_padding(padding{ { 0, 0, 1, 2 }, 0 })), data("weights", weights), data("biases", biases), deconvolution("deconv", "reorder", { "weights" }, { "biases" }, { 1, 1, 2, 2 }, { 0, 0, -1, -1 }) @@ -720,7 +714,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x2_bfyx_stride2_pad1_input_p auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -3.f, 4.5f, 13.f, -17.f, @@ -760,21 +754,21 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2x2_in2x2x1x1_stride2_pad1_input_padd // f1: 1 8.5 // f1: 17 - 13 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); cldnn::build_options options; options.set_option(cldnn::build_option::optimize_data(true)); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 1, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::yxio,{ 2, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 1, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::yxio,{ 2, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f }); set_values(weights, { -2.f, -2.f, 2.f, 2.f, 7.f, 7.f, -0.5f, -0.5f }); set_values(biases, { 1.0f, 5.0f }); topology topology( - input_layout("input", input.get_layout()), - reorder("reorder", "input", input.get_layout().with_padding(padding{ { 0, 0, 1, 2 }, 0 })), + input_layout("input", input->get_layout()), + reorder("reorder", "input", input->get_layout().with_padding(padding{ { 0, 0, 1, 2 }, 0 })), data("weights", weights), data("biases", biases), deconvolution("deconv", "reorder", { "weights" }, { "biases" }, { 1, 1, 2, 2 }, { 0, 0, -1, -1 }) @@ -789,7 +783,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2x2_in2x2x1x1_stride2_pad1_input_padd auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -3.f, 1.f, 4.5f, 8.5f, @@ -824,18 +818,18 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x2_bfyx_yxfb_stride2_pad1) { // -3 4.5 0.5 22 // 13 -17 5 -7 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 1, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::oiyx, { 1, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 1, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::oiyx, { 1, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f, 1.f, 3.f, 2.f, 4.f }); set_values(weights, { -2.f, 2.f, 7.f, -0.5f }); set_values(biases, { 1.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), deconvolution("deconv", "input", { "weights" }, { "biases" }, { 1, 1, 2, 2 }, { 0, 0, -1, -1 }) @@ -850,7 +844,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x2_bfyx_yxfb_stride2_pad1) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -3.f, 4.5f, 13.f, -17.f, @@ -885,11 +879,11 @@ TEST(deconvolution_f16_fw_gpu, basic_wsiz2x2_in2x2x1x2_bfyx_yxfb_stride2_pad1) { // -3 4.5 0.5 22 // 13 -17 5 -7 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f16, format::bfyx,{ 2, 1, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::oiyx,{ 1, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx,{ 2, 1, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::oiyx,{ 1, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); cldnn::build_options options; options.set_option(cldnn::build_option::optimize_data(true)); @@ -904,7 +898,7 @@ TEST(deconvolution_f16_fw_gpu, basic_wsiz2x2_in2x2x1x2_bfyx_yxfb_stride2_pad1) { set_values(biases, { 1.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), deconvolution("deconv", "input", { "weights" }, { "biases" }, { 1, 1, 2, 2 }, { 0, 0, -1, -1 }) @@ -919,7 +913,7 @@ TEST(deconvolution_f16_fw_gpu, basic_wsiz2x2_in2x2x1x2_bfyx_yxfb_stride2_pad1) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -3.f, 4.5f, 13.f, -17.f, @@ -961,18 +955,18 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x2x2x2_bfyx_stride2_pad1_split2) // -3 4.5 -8 -28 // 13 -17 1 -17 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 2, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::goiyx, tensor(group(2), batch(1), feature(1), spatial(2, 2)) }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 2, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::goiyx, tensor(group(2), batch(1), feature(1), spatial(2, 2)) }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f, 1.f, 3.f, 2.f, 4.f }); set_values(weights, { -2.f, 2.f, 7.f, -0.5f, -4.f, 1.f, -9.f, -7.f }); set_values(biases, { 1.0f, -1.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), deconvolution("deconv", "input", { "weights" }, { "biases" }, 2, { 1, 1, 2, 2 }, { 0, 0, -1, -1 }) @@ -987,7 +981,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x2x2x2_bfyx_stride2_pad1_split2) auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -3.f, 4.5f, 13.f, -17.f, @@ -1003,11 +997,11 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x2x2x2_bfyx_stride2_pad1_split2) TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x2x2x2_bfyx_stride2_pad1_group2) { // data is similar as in basic_wsiz2x2_in1x2x2x2_bfyx_stride2_pad1_split2 - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 2, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::goiyx, tensor(group(2), batch(1), feature(1), spatial(2, 2)) }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 2, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::goiyx, tensor(group(2), batch(1), feature(1), spatial(2, 2)) }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f, 1.f, 3.f, 2.f, 4.f }); set_values(weights, { @@ -1017,7 +1011,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x2x2x2_bfyx_stride2_pad1_group2) set_values(biases, { 1.0f, -1.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), deconvolution("deconv", "input", { "weights" }, { "biases" }, 2, { 1, 1, 2, 2 }, { 0, 0, -1, -1 }) @@ -1032,7 +1026,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x2x2x2_bfyx_stride2_pad1_group2) auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -3.f, 4.5f, 13.f, -17.f, @@ -1049,9 +1043,9 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x2x2x2_bfyx_stride2_pad1_group16 // Test for depthwise separable optimization, there are 16 joined weights and biases (group 16) // data is similar as in basic_wsiz2x2_in1x2x2x2_bfyx_stride2_pad1_split2_depthwise_sep_opt - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 16, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 16, 2, 2 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f, 1.f, 3.f, 2.f, 4.f, 8.f, 0.5f, 6.f, 9.f, 1.f, 3.f, 2.f, 4.f, @@ -1063,13 +1057,13 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x2x2x2_bfyx_stride2_pad1_group16 8.f, 0.5f, 6.f, 9.f, 1.f, 3.f, 2.f, 4.f }); - topology topology(input_layout("input", input.get_layout())); + topology topology(input_layout("input", input->get_layout())); std::vector weights_vec; std::vector bias_vec; - auto weights = memory::allocate(engine, { data_types::f32, format::goiyx, tensor(group(16), batch(1), feature(1), spatial(2, 2)) }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 16, 1, 1 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::goiyx, tensor(group(16), batch(1), feature(1), spatial(2, 2)) }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 16, 1, 1 } }); set_values(weights, { @@ -1108,7 +1102,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x2x2x2_bfyx_stride2_pad1_group16 auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -3.f, 4.5f, 13.f, -17.f, -8.f, -28.f, 1.f, -17.f, @@ -1131,9 +1125,9 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x2x2x2_bfyx_stride2_pad1_group16 // Test for depthwise separable optimization, there are 16 joined weights and biases (group 16) // data is similar as in basic_wsiz2x2_in1x2x2x2_bfyx_stride2_pad1_split2_depthwise_sep_opt_ofm2 - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 16, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 16, 2, 2 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f, 1.f, 3.f, 2.f, 4.f, 8.f, 0.5f, 6.f, 9.f, 1.f, 3.f, 2.f, 4.f, @@ -1145,13 +1139,13 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x2x2x2_bfyx_stride2_pad1_group16 8.f, 0.5f, 6.f, 9.f, 1.f, 3.f, 2.f, 4.f }); - topology topology(input_layout("input", input.get_layout())); + topology topology(input_layout("input", input->get_layout())); std::vector weights_vec; std::vector bias_vec; - auto weights = memory::allocate(engine, { data_types::f32, format::goiyx, tensor(group(16), batch(2), feature(1), spatial(2, 2)) }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 32, 1, 1 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::goiyx, tensor(group(16), batch(2), feature(1), spatial(2, 2)) }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 32, 1, 1 } }); set_values(weights, { @@ -1197,7 +1191,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x2x2x2_bfyx_stride2_pad1_group16 auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -3.f, 4.5f, 13.f, -17.f,-3.f, 4.5f, 13.f, -17.f, -8.f, -28.f, 1.f, -17.f, -8.f, -28.f, 1.f, -17.f, @@ -1219,11 +1213,11 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x2x2x2_bfyx_stride2_pad1_group16 TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x6x1x1_bfyx_stride2_pad1_group2_ofm3) { // data is similar as in basic_wsiz2x2_in1x6x1x1_bfyx_stride2_pad1_split2_ofm3 - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 4, 1, 1 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::goiyx, tensor(group(2), batch(3), feature(2), spatial(1, 1)) }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 6, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 4, 1, 1 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::goiyx, tensor(group(2), batch(3), feature(2), spatial(1, 1)) }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 6, 1, 1 } }); set_values(input, { 1.5f, 0.5f, 2.0f, -1.0f @@ -1238,7 +1232,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x6x1x1_bfyx_stride2_pad1_group2_ }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), deconvolution("deconv", "input", { "weights" }, { "biases" }, 2, { 1, 1, 1, 1 }, { 0, 0, 0, 0 }) @@ -1253,7 +1247,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x6x1x1_bfyx_stride2_pad1_group2_ auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -1.5f, 8.0f, 7.75f, 11.0f, 6.0f, -2.0f @@ -1284,18 +1278,18 @@ TEST(deconvolution_f32_fw_gpu, basic3D_wsiz2x2x1_in1x1x2x2x1_nopad) { // 18 0.75 7.25 // 23 42.5 15.5 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 1, 1, 2, 2, 1 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::oizyx,{ 1, 1, 2, 2, 1 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 1, 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 1, 1, 2, 2, 1 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::oizyx,{ 1, 1, 2, 2, 1 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 1, 1, 1, 1, 1 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f }); set_values(weights, { -2.0f, 0.5f, 3.5f, 1.5f }); set_values(biases, { 2.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), deconvolution("deconv", "input", { "weights" }, { "biases" }, { 1,1,1,1,1 }) @@ -1310,7 +1304,7 @@ TEST(deconvolution_f32_fw_gpu, basic3D_wsiz2x2x1_in1x1x2x2x1_nopad) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -14.f, 5.f, 2.25f, @@ -1410,10 +1404,10 @@ TEST(deconvolution_f32_fw_gpu, basic3D_wsiz3x3x3_in1x1x4x4x4_nopad) { // 1 2 3 3 2 1 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 1, 1, 4, 4, 4 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::oizyx,{ 1, 1, 3, 3, 3 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 1, 1, 4, 4, 4 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::oizyx,{ 1, 1, 3, 3, 3 } }); set_values(input, { @@ -1447,7 +1441,7 @@ TEST(deconvolution_f32_fw_gpu, basic3D_wsiz3x3x3_in1x1x4x4x4_nopad) { }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), deconvolution("deconv", "input", { "weights" }) ); @@ -1461,7 +1455,7 @@ TEST(deconvolution_f32_fw_gpu, basic3D_wsiz3x3x3_in1x1x4x4x4_nopad) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { 1.0f, 2.0f, 3.0f, 3.0f, 2.0f, 1.0f, @@ -1532,10 +1526,10 @@ TEST(deconvolution_f32_fw_gpu, basic3D_wsiz2x2x2_in1x1x2x2x2_stride2_nopad) { // 3.5 1.5 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 1, 1, 2, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::oizyx,{ 1, 1, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 1, 1, 2, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::oizyx,{ 1, 1, 2, 2, 2 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f, 8.f, 0.5f, 6.f, 9.f }); set_values(weights, { -2.0f, 0.5f, 3.5f, 1.5f, -2.0f, 0.5f, 3.5f, 1.5f }); @@ -1543,7 +1537,7 @@ TEST(deconvolution_f32_fw_gpu, basic3D_wsiz2x2x2_in1x1x2x2x2_stride2_nopad) { //set_values(weights, { 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), deconvolution("deconv", "input", { "weights" }, { 1,1,2,2,2 }) ); @@ -1556,7 +1550,7 @@ TEST(deconvolution_f32_fw_gpu, basic3D_wsiz2x2x2_in1x1x2x2x2_stride2_nopad) { EXPECT_EQ(outputs.begin()->first, "deconv"); auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -16.f, 4.f, -1.f, 0.25f, @@ -1607,16 +1601,16 @@ TEST(deconvolution_f32_fw_gpu, basic3D_wsiz2x2x2_in1x1x2x2x2_stride2_pad1) { // 12 1.75 // 3 -18 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 1, 1, 2, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::oizyx,{ 1, 1, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 1, 1, 2, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::oizyx,{ 1, 1, 2, 2, 2 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f, 8.f, 0.5f, 6.f, 9.f }); set_values(weights, { -2.0f, 0.5f, 3.5f, 1.5f, -2.0f, 0.5f, 3.5f, 1.5f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), deconvolution("deconv", "input", { "weights" }, { 1,1,2,2,2 }, { 0, 0, -1, -1, -1 }) ); @@ -1629,7 +1623,7 @@ TEST(deconvolution_f32_fw_gpu, basic3D_wsiz2x2x2_in1x1x2x2x2_stride2_pad1) { EXPECT_EQ(outputs.begin()->first, "deconv"); auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { 12.f, 1.75f, 3.f, -18.f, @@ -1649,8 +1643,8 @@ TEST(deconvolution_f16_gpu, basic_k9x9_s2x2_pad4x4) { // Stride : 2x2 // Pad : 4x4 - //const auto& engine = get_test_engine(); - engine engine; + //auto& engine = get_test_engine(); + auto& engine = get_test_engine(); VVVVF input_rnd = generate_random_4d(1, 32, 16, 16, -2, 2); VF input_rnd_vec = flatten_4d(format::bfyx, input_rnd); @@ -1665,11 +1659,11 @@ TEST(deconvolution_f16_gpu, basic_k9x9_s2x2_pad4x4) { for (unsigned int i = 0; i < bias_rnd.size(); i++) bias_f32_rnd.push_back(float(bias_rnd[i])); - auto input = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 32, 16, 16 } }); - auto weights = memory::allocate(engine, { data_types::f16, format::oiyx, { 1, 32, 9, 9 } }); - auto biases = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 1, 1, 1 } }); - auto weights_f32 = memory::allocate(engine, { data_types::f32, format::oiyx, { 1, 32, 9, 9 } }); - auto biases_f32 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 32, 16, 16 } }); + auto weights = engine.allocate_memory({ data_types::f16, format::oiyx, { 1, 32, 9, 9 } }); + auto biases = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 1, 1, 1 } }); + auto weights_f32 = engine.allocate_memory({ data_types::f32, format::oiyx, { 1, 32, 9, 9 } }); + auto biases_f32 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, input_rnd_vec); set_values(weights, filter_rnd_vec); @@ -1678,7 +1672,7 @@ TEST(deconvolution_f16_gpu, basic_k9x9_s2x2_pad4x4) { set_values(biases_f32, bias_f32_rnd); topology topology_ref( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), deconvolution("deconv", "input", { "weights" }, { "biases" }, { 1, 1, 2, 2 }, { 0, 0, -4, -4 }, tensor{ 1, 1, 32, 32 }) @@ -1691,16 +1685,15 @@ TEST(deconvolution_f16_gpu, basic_k9x9_s2x2_pad4x4) { EXPECT_EQ(outputs_ref.size(), size_t(1)); EXPECT_EQ(outputs_ref.begin()->first, "deconv"); auto output_ref_prim = outputs_ref.begin()->second.get_memory(); - auto output_ref_ptr = output_ref_prim.pointer(); + cldnn::mem_lock output_ref_ptr(output_ref_prim, get_test_stream()); std::vector output_vec_ref; - for (unsigned int i = 0; i < output_ref_prim.get_layout().count(); i++) - { + for (unsigned int i = 0; i < output_ref_prim->get_layout().count(); i++) { output_vec_ref.push_back(output_ref_ptr[i]); } topology topology_act( - input_layout("input_act", input.get_layout()), + input_layout("input_act", input->get_layout()), data("weights_f32", weights_f32), data("biases_f32", biases_f32), deconvolution("deconv_act", "input_act", { "weights_f32" }, { "biases_f32" }, { 1, 1, 2, 2 }, { 0, 0, -4, -4 }), @@ -1716,11 +1709,10 @@ TEST(deconvolution_f16_gpu, basic_k9x9_s2x2_pad4x4) { EXPECT_EQ(outputs_act.size(), size_t(1)); EXPECT_EQ(outputs_act.begin()->first, "out"); auto output_act_prim = outputs_act.begin()->second.get_memory(); - auto output_act_ptr = output_act_prim.pointer(); + cldnn::mem_lock output_act_ptr(output_act_prim, get_test_stream()); std::vector output_vec; - for (unsigned int i = 0; i < output_act_prim.get_layout().count(); i++) - { + for (unsigned int i = 0; i < output_act_prim->get_layout().count(); i++) { float x = float_round(output_act_ptr[i]), y = float_round(output_vec_ref[i]); EXPECT_NEAR(x, y, 1e-0f); } @@ -1748,18 +1740,18 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x2_b_fs_yx_fsv16_stride2_pad // -3 4.5 0.5 22 // 13 -17 5 -7 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 1, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::yxio, { 1, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 1, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::yxio, { 1, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f, 1.f, 3.f, 2.f, 4.f }); set_values(weights, { -2.f, 2.f, 7.f, -0.5f }); set_values(biases, { 1.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), deconvolution("deconv", "input", { "weights" }, { "biases" }, { 1, 1, 2, 2 }, { 0, 0, -1, -1 }), @@ -1780,7 +1772,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x2_b_fs_yx_fsv16_stride2_pad auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -3.f, 4.5f, 13.f, -17.f, @@ -1814,11 +1806,11 @@ TEST(deconvolution_f16_fw_gpu, basic_wsiz2x2_in2x2x1x2_b_fs_yx_fsv16_stride2_pad // -3 4.5 0.5 22 // 13 -17 5 -7 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f16, format::bfyx,{ 2, 1, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f16, format::oiyx,{ 1, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f16, format::bfyx,{ 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx,{ 2, 1, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f16, format::oiyx,{ 1, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f16, format::bfyx,{ 1, 1, 1, 1 } }); set_values(input, { FLOAT16(8.f), FLOAT16(0.5f), FLOAT16(6.f), FLOAT16(9.f), @@ -1830,7 +1822,7 @@ TEST(deconvolution_f16_fw_gpu, basic_wsiz2x2_in2x2x1x2_b_fs_yx_fsv16_stride2_pad set_values(biases, { FLOAT16(1.0f) }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), deconvolution("deconv", "input", { "weights" }, { "biases" }, { 1, 1, 2, 2 }, { 0, 0, -1, -1 }), @@ -1851,7 +1843,7 @@ TEST(deconvolution_f16_fw_gpu, basic_wsiz2x2_in2x2x1x2_b_fs_yx_fsv16_stride2_pad auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -3.f, 4.5f, 13.f, -17.f, @@ -1865,11 +1857,11 @@ TEST(deconvolution_f16_fw_gpu, basic_wsiz2x2_in2x2x1x2_b_fs_yx_fsv16_stride2_pad TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x2x2x2_b_fs_yx_fsv16_stride2_pad1_group2) { // data is similar as in basic_wsiz2x2_in1x2x2x2_bfyx_stride2_pad1_split2 - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 2, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::goiyx, tensor(group(2), batch(1), feature(1), spatial(2, 2)) }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 2, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::goiyx, tensor(group(2), batch(1), feature(1), spatial(2, 2)) }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f, 1.f, 3.f, 2.f, 4.f }); set_values(weights, { @@ -1879,7 +1871,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x2x2x2_b_fs_yx_fsv16_stride2_pad set_values(biases, { 1.0f, -1.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), deconvolution("deconv", "input", { "weights" }, { "biases" }, 2, { 1, 1, 2, 2 }, { 0, 0, -1, -1 }), @@ -1900,7 +1892,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x2x2x2_b_fs_yx_fsv16_stride2_pad auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -3.f, 4.5f, 13.f, -17.f, @@ -1913,11 +1905,11 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x2x2x2_b_fs_yx_fsv16_stride2_pad } TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x2x2x2_b_fs_yx_fsv16_stride2_pad1_b_fs_yx_fsv16_dw) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 2, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::goiyx, tensor(group(2), batch(1), feature(1), spatial(2, 2)) }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 2, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::goiyx, tensor(group(2), batch(1), feature(1), spatial(2, 2)) }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f, 1.f, 3.f, 2.f, 4.f }); set_values(weights, { @@ -1927,7 +1919,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x2x2x2_b_fs_yx_fsv16_stride2_pad set_values(biases, { 0.0f, 0.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), deconvolution("deconv", "input", { "weights" }, { "biases" }, 2, { 1, 1, 2, 2 }, { 0, 0, -1, -1 }), @@ -1948,7 +1940,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x2x2x2_b_fs_yx_fsv16_stride2_pad auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -4.f, 3.5f, 12.f, -18.f, @@ -1961,18 +1953,18 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in1x2x2x2_b_fs_yx_fsv16_stride2_pad } TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_nopad_b_fs_yx_fsv16_dw) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 2, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::goiyx, tensor(group(2), batch(1), feature(1), spatial(2, 2)) }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 2, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::goiyx, tensor(group(2), batch(1), feature(1), spatial(2, 2)) }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 2, 1, 1 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f, 8.f, 0.5f, 6.f, 9.f }); set_values(weights, { -2.0f, 0.5f, 3.5f, 1.5f, -2.0f, 0.5f, 3.5f, 1.5f }); set_values(biases, { 2.0f, 2.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), reorder("input_fsv16", "input", format::b_fs_yx_fsv16, data_types::f32), @@ -1994,7 +1986,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_nopad_b_fs_yx_fsv16_dw) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -14.f, 5.f, 2.25f, @@ -2013,11 +2005,11 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_nopad_b_fs_yx_fsv16_dw) { } TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_pad1_b_fs_yx_fsv16_dw) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::goiyx, tensor(group(2), batch(1), feature(1), spatial(2, 2)) }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::goiyx, tensor(group(2), batch(1), feature(1), spatial(2, 2)) }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f, 8.f, 0.5f, 6.f, 9.f}); @@ -2026,7 +2018,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_pad1_b_fs_yx_fsv16_dw) { set_values(biases, { 2.0f, 2.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), reorder("input_fsv16", "input", format::b_fs_yx_fsv16, data_types::f32), @@ -2048,7 +2040,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_pad1_b_fs_yx_fsv16_dw) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); EXPECT_FLOAT_EQ(0.75f, output_ptr[0]); EXPECT_FLOAT_EQ(0.75f, output_ptr[1]); @@ -2056,11 +2048,11 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_pad1_b_fs_yx_fsv16_dw) { TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_stride2_nopad_b_fs_yx_fsv16_dw) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::goiyx, tensor(group(2), batch(1), feature(1), spatial(2, 2)) }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::goiyx, tensor(group(2), batch(1), feature(1), spatial(2, 2)) }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f, 8.f, 0.5f, 6.f, 9.f}); @@ -2069,7 +2061,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_stride2_nopad_b_fs_yx_fsv set_values(biases, { 1.0f, 1.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), deconvolution("deconv", "input", { "weights" }, { "biases" }, 2, { 1,1,2,2 }), @@ -2090,7 +2082,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_stride2_nopad_b_fs_yx_fsv auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -15.f, 5.f, 0.f, 1.25f, @@ -2112,11 +2104,11 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_stride2_nopad_b_fs_yx_fsv } TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_stride4_pad2_b_fs_yx_fsv16_dw) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::goiyx, tensor(group(2), batch(1), feature(1), spatial(3, 3)) }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::goiyx, tensor(group(2), batch(1), feature(1), spatial(3, 3)) }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f, 8.f, 0.5f, 6.f, 9.f}); @@ -2125,7 +2117,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_stride4_pad2_b_fs_yx_fsv1 set_values(biases, { 0.0f, 0.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), deconvolution("deconv", "input", { "weights" }, { "biases" }, 2, { 1, 1, 4, 4 }, { 0, 0, -2, -2 }), @@ -2146,7 +2138,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_stride4_pad2_b_fs_yx_fsv1 auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { 40.f, 0.f, 1.5f, @@ -2165,11 +2157,11 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_stride4_pad2_b_fs_yx_fsv1 } TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_stride4_pad2_b_fs_yx_fsv16_dw_batch2) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::goiyx, tensor(group(2), batch(1), feature(1), spatial(3, 3)) }); - auto biases = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::goiyx, tensor(group(2), batch(1), feature(1), spatial(3, 3)) }); + auto biases = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); set_values(input, { 8.f, 0.5f, 6.f, 9.f, 8.f, 0.5f, 6.f, 9.f, @@ -2181,7 +2173,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_stride4_pad2_b_fs_yx_fsv1 set_values(biases, { 0.0f, 0.0f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("biases", biases), deconvolution("deconv", "input", { "weights" }, { "biases" }, 2, { 1, 1, 4, 4 }, { 0, 0, -2, -2 }), @@ -2202,7 +2194,7 @@ TEST(deconvolution_f32_fw_gpu, basic_wsiz2x2_in2x2x1x1_stride4_pad2_b_fs_yx_fsv1 auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { 40.f, 0.f, 1.5f, @@ -2250,10 +2242,10 @@ TEST(deconvolution_f32_fw_gpu, bs_fs_zyx_bsv16_fsv16_wsiz2x2x2_in1x1x2x2x2_strid // 3.5 1.5 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 32, 1, 2, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::oizyx,{ 1, 1, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 32, 1, 2, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::oizyx,{ 1, 1, 2, 2, 2 } }); std::vector input_single_batch = { 8.f, 0.5f, 6.f, 9.f, 8.f, 0.5f, 6.f, 9.f }; std::vector input_batched; @@ -2267,7 +2259,7 @@ TEST(deconvolution_f32_fw_gpu, bs_fs_zyx_bsv16_fsv16_wsiz2x2x2_in1x1x2x2x2_strid set_values(weights, { -2.0f, 0.5f, 3.5f, 1.5f, -2.0f, 0.5f, 3.5f, 1.5f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), deconvolution("deconv", "input", { "weights" }, { 1,1,2,2,2 }, { 0, 0, -1, -1, -1 }), reorder("out", "deconv", format::bfzyx, data_types::f32) @@ -2286,7 +2278,7 @@ TEST(deconvolution_f32_fw_gpu, bs_fs_zyx_bsv16_fsv16_wsiz2x2x2_in1x1x2x2x2_strid EXPECT_EQ(outputs.begin()->first, "out"); auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { 12.f, 1.75f, 3.f, -18.f, @@ -2301,11 +2293,11 @@ TEST(deconvolution_f32_fw_gpu, bs_fs_zyx_bsv16_fsv16_wsiz2x2x2_in1x1x2x2x2_strid } TEST(deconvolution_f16_fw_gpu, basic_wsiz2x2_in1x2x2x2_fs_b_yx_fsv32_stride1_pad1_replace_to_conv) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f16, format::bfyx,{ 2, 1, 2, 2 } }); - auto weights = memory::allocate(engine, { data_types::f16, format::bfyx,{ 2, 1, 2, 2 } }); - auto biases = memory::allocate(engine, { data_types::f16, format::bfyx,{ 1, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx,{ 2, 1, 2, 2 } }); + auto weights = engine.allocate_memory({ data_types::f16, format::bfyx,{ 2, 1, 2, 2 } }); + auto biases = engine.allocate_memory({ data_types::f16, format::bfyx,{ 1, 2, 1, 1 } }); set_values(input, { FLOAT16(8.f), FLOAT16(0.5f), FLOAT16(6.f), FLOAT16(9.f), FLOAT16(1.f), FLOAT16(3.f), FLOAT16(2.f), FLOAT16(4.f) @@ -2317,7 +2309,7 @@ TEST(deconvolution_f16_fw_gpu, basic_wsiz2x2_in1x2x2x2_fs_b_yx_fsv32_stride1_pad set_values(biases, { FLOAT16(1.0f), FLOAT16(-1.0f) }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("reorder", "input", format::fs_b_yx_fsv32, data_types::f16), data("weights", weights), data("biases", biases), @@ -2337,7 +2329,7 @@ TEST(deconvolution_f16_fw_gpu, basic_wsiz2x2_in1x2x2x2_fs_b_yx_fsv32_stride1_pad auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); std::vector expected_output_vec = { -15.f, 16.f, 2.f, 45.f, -5.5f, 18.75f, 43.f, 61.f, -3.5f, @@ -2345,7 +2337,7 @@ TEST(deconvolution_f16_fw_gpu, basic_wsiz2x2_in1x2x2x2_fs_b_yx_fsv32_stride1_pad -1.f, -3.f, 7.f, 4.f, 17.5f, 7.5f, 15.f, 28.f, -1.f, -5.f, -12.f, 2.f, -18.f, -49.f, -18.f, -19.f, -51.f, -29.f, }; - ASSERT_EQ(expected_output_vec.size(), output_prim.count()); + ASSERT_EQ(expected_output_vec.size(), output_prim->count()); for (size_t i = 0; i < expected_output_vec.size(); i++) { EXPECT_FLOAT_EQ(expected_output_vec[i], output_ptr[i]) << " index=" << i; @@ -2449,8 +2441,8 @@ template class deconvolution_random_test_base { public: template - void set_memory(cldnn::memory& mem, const VVVVVF& data) { - auto ptr = mem.pointer(); + void set_memory(cldnn::memory::ptr mem, const VVVVVF& data) { + cldnn::mem_lock ptr(mem, get_test_stream()); auto b = data.size(); auto f = data[0].size(); @@ -2464,7 +2456,7 @@ class deconvolution_random_test_base { for (size_t yi = 0; yi < y; ++yi) { for (size_t xi = 0; xi < x; ++xi) { auto coords = cldnn::tensor(batch(bi), feature(fi), spatial(xi, yi, zi, 0)); - auto offset = mem.get_layout().get_linear_offset(coords); + auto offset = mem->get_layout().get_linear_offset(coords); ptr[offset] = data[bi][fi][zi][yi][xi]; } } @@ -2474,8 +2466,8 @@ class deconvolution_random_test_base { } template - void set_memory_weights(cldnn::memory& mem, const VVVVVVF& data) { - auto ptr = mem.pointer(); + void set_memory_weights(cldnn::memory::ptr mem, const VVVVVVF& data) { + cldnn::mem_lock ptr(mem, get_test_stream()); auto g = data.size(); auto b = data[0].size(); @@ -2491,7 +2483,7 @@ class deconvolution_random_test_base { for (size_t yi = 0; yi < y; ++yi) { for (size_t xi = 0; xi < x; ++xi) { auto coords = cldnn::tensor(group(gi), batch(bi), feature(fi), spatial(xi, yi, zi, 0)); - auto offset = mem.get_layout().get_linear_offset(coords); + auto offset = mem->get_layout().get_linear_offset(coords); ptr[offset] = data[gi][bi][fi][zi][yi][xi]; } } @@ -2526,7 +2518,7 @@ class deconvolution_random_test_base { type_test_ranges::max); } - void run(cldnn::engine eng, const deconvolution_random_test_params& params, cldnn::build_options build_opts) { + void run(cldnn::engine& eng, const deconvolution_random_test_params& params, cldnn::build_options build_opts) { uint32_t groups = params.weights_size.group[0]; size_t ifm = params.weights_size.feature[0]; size_t ofm = params.weights_size.batch[0]; @@ -2537,8 +2529,8 @@ class deconvolution_random_test_base { auto in_layout = cldnn::layout(cldnn::type_to_data_type::value, params.input_format, params.input_size); auto wei_layout = cldnn::layout(cldnn::type_to_data_type::value, params.weights_format, params.weights_size); - auto wei_mem = cldnn::memory::allocate(eng, wei_layout); - auto in_mem = cldnn::memory::allocate(eng, in_layout); + auto wei_mem = eng.allocate_memory(wei_layout); + auto in_mem = eng.allocate_memory(in_layout); this->set_memory_weights(wei_mem, weights_data); this->set_memory(in_mem, input_data); @@ -2553,7 +2545,7 @@ class deconvolution_random_test_base { if (params.with_bias) { auto bias_size = cldnn::tensor(feature(params.weights_size.batch[0] * params.weights_size.group[0])); auto bias_lay = cldnn::layout(cldnn::type_to_data_type::value, cldnn::format::bfyx, bias_size); - auto bias_mem = cldnn::memory::allocate(eng, bias_lay); + auto bias_mem = eng.allocate_memory(bias_lay); bias_data = generate_random_1d(bias_lay.size.feature[0], -1, 1); set_values(bias_mem, bias_data); topo.add(cldnn::data("bias", bias_mem)); @@ -2581,10 +2573,10 @@ class deconvolution_random_test_base { // Compare results { - auto ptr = out_mem.pointer(); + cldnn::mem_lock ptr(out_mem, get_test_stream()); - auto b = static_cast(out_mem.get_layout().size.batch[0]); - auto of = static_cast(out_mem.get_layout().size.feature[0]); + auto b = static_cast(out_mem->get_layout().size.batch[0]); + auto of = static_cast(out_mem->get_layout().size.feature[0]); for (size_t bi = 0; bi < b; ++bi) { for (size_t fi = 0; fi < of; ++fi) { @@ -2597,16 +2589,16 @@ class deconvolution_random_test_base { params.input_offset, group * ifm); - ASSERT_EQ(reference.size(), out_mem.get_layout().size.spatial[2]); - ASSERT_EQ(reference[0].size(), out_mem.get_layout().size.spatial[1]); - ASSERT_EQ(reference[0][0].size(), out_mem.get_layout().size.spatial[0]); + ASSERT_EQ(reference.size(), out_mem->get_layout().size.spatial[2]); + ASSERT_EQ(reference[0].size(), out_mem->get_layout().size.spatial[1]); + ASSERT_EQ(reference[0][0].size(), out_mem->get_layout().size.spatial[0]); for (size_t zi = 0; zi < reference.size(); zi++) { for (size_t yi = 0; yi < reference[0].size(); yi++) { for (size_t xi = 0; xi < reference[0][0].size(); xi++) { auto ref_val = reference[zi][yi][xi]; auto out_coords = cldnn::tensor(batch(bi), feature(fi), spatial(xi, yi, zi, 0)); - auto out_offset = out_mem.get_layout().get_linear_offset(out_coords); + auto out_offset = out_mem->get_layout().get_linear_offset(out_coords); auto out_val = ptr[out_offset]; TYPED_ASSERT_EQ(ref_val, out_val) << "at b=" << bi << ", f=" << fi << ", z=" << zi << ", y=" << yi << ", x=" << xi << std::endl @@ -2626,7 +2618,6 @@ class deconvolution_random_test_base { class deconvolution_random_test : public testing::TestWithParam { protected: void SetUp() override { - eng = get_test_engine(); build_opts.set_option(cldnn::build_option::optimize_data(true)); } @@ -2650,7 +2641,6 @@ class deconvolution_random_test : public testing::TestWithParam test; - test.run(eng, params, build_opts); + test.run(get_test_engine(), params, build_opts); } template diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/depth_concatenate_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/depth_concatenate_gpu_test.cpp index 6af2651aa2fc1b..116d6ba21f4d2b 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/depth_concatenate_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/depth_concatenate_gpu_test.cpp @@ -4,23 +4,19 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include "api/concatenation.hpp" -#include "api/convolution.hpp" -#include "api/data.hpp" -#include "api/eltwise.hpp" -#include "api/fully_connected.hpp" -#include "api/pooling.hpp" -#include "api/crop.hpp" -#include "api/resample.hpp" -#include "api/reshape.hpp" -#include -#include -#include #include "test_utils/test_utils.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + using namespace cldnn; using namespace tests; @@ -59,16 +55,16 @@ TEST(depth_concatenate_f32_gpu, test01) { // 0 -0.2 :f4 // - const auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, {data_types::f32, format::yxfb, {2, 2, 1, 1}}); - auto input2 = memory::allocate(engine, {data_types::f32, format::yxfb, {2, 3, 1, 1}}); + auto& engine = get_test_engine(); + auto input1 = engine.allocate_memory({data_types::f32, format::yxfb, {2, 2, 1, 1}}); + auto input2 = engine.allocate_memory({data_types::f32, format::yxfb, {2, 3, 1, 1}}); set_values(input1, {0.5f, 0.7f, 0.2f, 0.4f}); set_values(input2, {1.0f, 0.1f, 0.3f, -0.5f, 0.0f, -0.2f}); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(concatenation("depth1", {"input1", "input2"}, concatenation::along_f)); network network(engine, topology); @@ -82,7 +78,7 @@ TEST(depth_concatenate_f32_gpu, test01) { auto output = outputs.at("depth1").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); EXPECT_FLOAT_EQ(0.5f, output_ptr[0]); EXPECT_FLOAT_EQ(0.7f, output_ptr[1]); EXPECT_FLOAT_EQ(0.2f, output_ptr[2]); @@ -118,16 +114,16 @@ void concat_basic_with_reorder() { // 0 0 :f4 // - const auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, {data_types::f32, format::yxfb, {2, 2, 1, 1}}); - auto input2 = memory::allocate(engine, {data_types::f32, format::yxfb, {2, 3, 1, 1}}); + auto& engine = get_test_engine(); + auto input1 = engine.allocate_memory({data_types::f32, format::yxfb, {2, 2, 1, 1}}); + auto input2 = engine.allocate_memory({data_types::f32, format::yxfb, {2, 3, 1, 1}}); auto outs = {3.0f, 4.0f, 0.0f, 1.0f, 1.0f, 4.0f, -4.0f, -8.0f, 0.0f, 0.0f}; set_values(input1, {2.5f, 3.7f, 0.2f, 1.4f}); set_values(input2, {1.0f, 4.1f, -4.3f, -7.5f, 0.0f, -0.2f}); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(reorder("to_int1", "input1", {DType, format::yxfb, {2, 2, 1, 1}})); topology.add(reorder("to_int2", "input2", {DType, format::yxfb, {2, 3, 1, 1}})); topology.add(concatenation("depth1", {"to_int1", "to_int2"}, concatenation::along_f)); @@ -144,7 +140,7 @@ void concat_basic_with_reorder() { auto output = outputs.at("to_float").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); int ptr_cntr = 0; for (const auto& ref : outs) { EXPECT_FLOAT_EQ(ref, output_ptr[ptr_cntr++]); @@ -194,19 +190,19 @@ TEST(depth_concatenate_f32_gpu, test02) { // 0 -0.2 :f7 // - const auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, {data_types::f32, format::yxfb, {2, 2, 1, 1}}); - auto input2 = memory::allocate(engine, {data_types::f32, format::yxfb, {2, 3, 1, 1}}); - auto input3 = memory::allocate(engine, {data_types::f32, format::bfyx, {2, 3, 1, 1}}); + auto& engine = get_test_engine(); + auto input1 = engine.allocate_memory({data_types::f32, format::yxfb, {2, 2, 1, 1}}); + auto input2 = engine.allocate_memory({data_types::f32, format::yxfb, {2, 3, 1, 1}}); + auto input3 = engine.allocate_memory({data_types::f32, format::bfyx, {2, 3, 1, 1}}); set_values(input1, {0.5f, 0.7f, 0.2f, 0.4f}); set_values(input2, {1.0f, 0.1f, 0.3f, -0.5f, 0.0f, -0.2f}); set_values(input3, {1.0f, 0.3f, 0.0f, 0.1f, -0.5f, -0.2f}); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("input3", input3.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("input3", input3->get_layout())); topology.add(concatenation("depth1", {"input1", "input2", "input3"}, concatenation::along_f)); network network(engine, topology); @@ -221,7 +217,7 @@ TEST(depth_concatenate_f32_gpu, test02) { auto output = outputs.at("depth1").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); EXPECT_FLOAT_EQ(0.5f, output_ptr[0]); EXPECT_FLOAT_EQ(0.7f, output_ptr[1]); EXPECT_FLOAT_EQ(0.2f, output_ptr[2]); @@ -241,14 +237,14 @@ TEST(depth_concatenate_f32_gpu, test02) { } TEST(concatenate_f32_gpu, test_concatenation_of_pool_and_unpool) { - engine engine; - auto input1 = memory::allocate(engine, {data_types::f32, format::bfyx, {1, 1, 2, 2}}); - auto weights = memory::allocate(engine, {data_types::f32, format::bfyx, {1, 1, 2, 1}}); + auto& engine = get_test_engine(); + auto input1 = engine.allocate_memory({data_types::f32, format::bfyx, {1, 1, 2, 2}}); + auto weights = engine.allocate_memory({data_types::f32, format::bfyx, {1, 1, 2, 1}}); set_values(input1, {16.0f, 32.0f, 128.0f, 256.0f}); set_values(weights, {.1f, .2f}); topology topology; - topology.add(input_layout("input1", input1.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); topology.add(pooling("pool1", "input1", cldnn::pooling_mode::max, {1, 1, 2, 1}, /*kernel*/ @@ -267,7 +263,7 @@ TEST(concatenate_f32_gpu, test_concatenation_of_pool_and_unpool) { auto outputs = network.execute({}); auto output = outputs.at("conv").get_memory(); std::vector out_ref = {6.4f, 8.f, 51.2f, 64.f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 4; i++) { EXPECT_NEAR(output_ptr[i], out_ref[i], 1e-3); } @@ -278,13 +274,13 @@ TEST(depth_concatenate_f32_gpu, test03_cascade_concat_opt) { // Despite having concatenations one after another and connected to different non padded activation primitives, // graph should remove all concatenations from execution. - const auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, {data_types::f32, format::bfyx, {1, 2, 2, 1}}); + auto& engine = get_test_engine(); + auto input1 = engine.allocate_memory({data_types::f32, format::bfyx, {1, 2, 2, 1}}); set_values(input1, {16.0f, 32.0f, 128.0f, 256.0f}); topology topology; - topology.add(input_layout("input1", input1.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); topology.add(activation("relu1", "input1", activation_func::relu)); topology.add(activation("relu2", "relu1", activation_func::sqrt)); topology.add(concatenation("depth1", {"relu2", "relu1"}, concatenation::along_f)); @@ -303,7 +299,7 @@ TEST(depth_concatenate_f32_gpu, test03_cascade_concat_opt) { auto outputs = network.execute({}); auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); auto executed_primitives = network.get_executed_primitives(); EXPECT_TRUE(executed_primitives.count("depth1") == 0); @@ -331,9 +327,9 @@ TEST(depth_concatenate_f32_gpu, test03_cascade_concat_opt) { TEST(depth_concatenate_f32_gpu, test04_fused_relu) { // 2 inputs of size 3x10x10 concatenated on f axis with fused relu - const auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, {data_types::f32, format::bfyx, {1, 3, 10, 10}}); - auto input2 = memory::allocate(engine, {data_types::f32, format::bfyx, {1, 3, 10, 10}}); + auto& engine = get_test_engine(); + auto input1 = engine.allocate_memory({data_types::f32, format::bfyx, {1, 3, 10, 10}}); + auto input2 = engine.allocate_memory({data_types::f32, format::bfyx, {1, 3, 10, 10}}); std::vector input1_vec = generate_random_input(1, 3, 10, 10, -10, 10); set_values(input1, input1_vec); @@ -341,8 +337,8 @@ TEST(depth_concatenate_f32_gpu, test04_fused_relu) { set_values(input2, input2_vec); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(concatenation("depth1", {"input1", "input2"}, concatenation::along_f)); topology.add(activation("relu1", "depth1", activation_func::relu)); @@ -359,7 +355,7 @@ TEST(depth_concatenate_f32_gpu, test04_fused_relu) { auto output = outputs.at("relu1").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); unsigned int input_element_count = 300; for (unsigned int i = 0; i < 600; i++) { if (i < input_element_count) @@ -372,9 +368,9 @@ TEST(depth_concatenate_f32_gpu, test04_fused_relu) { TEST(depth_concatenate_f32_gpu, test05_different_formats) { // 2 inputs of size 3x2x2 concatenated on f axis - const auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, {data_types::f32, format::bfyx, {1, 3, 2, 2}}); - auto input2 = memory::allocate(engine, {data_types::f32, format::yxfb, {1, 3, 2, 2}}); + auto& engine = get_test_engine(); + auto input1 = engine.allocate_memory({data_types::f32, format::bfyx, {1, 3, 2, 2}}); + auto input2 = engine.allocate_memory({data_types::f32, format::yxfb, {1, 3, 2, 2}}); set_values(input1, {1.0f, 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f, 2.0f, @@ -393,8 +389,8 @@ TEST(depth_concatenate_f32_gpu, test05_different_formats) { -3.0f, -3.0f, -3.0f, -3.0f}; topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(reshape("reshape1", "input1", {1, 3, 2, 2})); topology.add(reshape("reshape2", "input2", {1, 3, 2, 2})); topology.add(concatenation("depth1", {"reshape1", "reshape2"}, concatenation::along_f)); @@ -412,7 +408,7 @@ TEST(depth_concatenate_f32_gpu, test05_different_formats) { EXPECT_EQ(outputs.begin()->first, "output"); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); int cntr = 0; for (float val : output_ptr) { EXPECT_EQ(val, out_ref[cntr++]); @@ -429,16 +425,16 @@ TEST(depth_concatenate_f32_gpu, test06_padded_input) { const int32_t input_f = 32; const int32_t output_f = 3 * input_f; - const auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::fs_b_yx_fsv32, {1, input_f, 1, 1} }); - auto input2 = memory::allocate(engine, { data_types::f16, format::fs_b_yx_fsv32, {1, input_f, 1, 1} }); + auto& engine = get_test_engine(); + auto input1 = engine.allocate_memory({ data_types::f16, format::fs_b_yx_fsv32, {1, input_f, 1, 1} }); + auto input2 = engine.allocate_memory({ data_types::f16, format::fs_b_yx_fsv32, {1, input_f, 1, 1} }); auto input1_data = generate_random_4d(1, input_f, 1, 1, -1, 1); auto input2_data = generate_random_4d(1, input_f, 1, 1, -1, 1); set_values(input1, flatten_4d(format::bfyx, input1_data)); set_values(input2, flatten_4d(format::bfyx, input2_data)); - auto weights = memory::allocate(engine, { data_types::f16, format::oiyx, {input_f, input_f, 3, 3} }); + auto weights = engine.allocate_memory({ data_types::f16, format::oiyx, {input_f, input_f, 3, 3} }); // Construct weights for convolution that just double input values. VVVVF weights_data; weights_data.resize(input_f); @@ -449,8 +445,8 @@ TEST(depth_concatenate_f32_gpu, test06_padded_input) { set_values(weights, flatten_4d(format::bfyx, weights_data)); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(activation("actv1", "input1", activation_func::linear, { 0.75f, 0.0f })); topology.add(activation("actv2", "input2", activation_func::linear, { 0.5f, 0.0f })); topology.add(data("weights", weights)); @@ -482,8 +478,8 @@ TEST(depth_concatenate_f32_gpu, test06_padded_input) { } auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); - ASSERT_EQ(output.count(), output_f); + cldnn::mem_lock output_ptr(output, get_test_stream()); + ASSERT_EQ(output->count(), output_f); for (size_t i = 0; i < output_f; ++i) { auto& val = output_ptr[i]; float ref; @@ -506,16 +502,16 @@ TEST(depth_concatenate_f32_gpu, test07_padded_output) { const int32_t input_f = 32; const int32_t output_f = 2 * input_f; - const auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::fs_b_yx_fsv32, {1, input_f, 1, 1} }); - auto input2 = memory::allocate(engine, { data_types::f16, format::fs_b_yx_fsv32, {1, input_f, 1, 1} }); + auto& engine = get_test_engine(); + auto input1 = engine.allocate_memory({ data_types::f16, format::fs_b_yx_fsv32, {1, input_f, 1, 1} }); + auto input2 = engine.allocate_memory({ data_types::f16, format::fs_b_yx_fsv32, {1, input_f, 1, 1} }); auto input1_data = generate_random_4d(1, input_f, 1, 1, -1, 1); auto input2_data = generate_random_4d(1, input_f, 1, 1, -1, 1); set_values(input1, flatten_4d(format::bfyx, input1_data)); set_values(input2, flatten_4d(format::bfyx, input2_data)); - auto weights = memory::allocate(engine, { data_types::f16, format::oiyx, {output_f, output_f, 3, 3} }); + auto weights = engine.allocate_memory({ data_types::f16, format::oiyx, {output_f, output_f, 3, 3} }); // Construct weights for convolution that just double input values. VVVVF weights_data; weights_data.resize(output_f); @@ -526,8 +522,8 @@ TEST(depth_concatenate_f32_gpu, test07_padded_output) { set_values(weights, flatten_4d(format::bfyx, weights_data)); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(activation("actv1", "input1", activation_func::linear, { 0.75f, 0.0f })); topology.add(activation("actv2", "input2", activation_func::linear, { 0.5f, 0.0f })); topology.add(concatenation("depth1", { "actv1", "actv2" }, concatenation::along_f)); @@ -557,8 +553,8 @@ TEST(depth_concatenate_f32_gpu, test07_padded_output) { } auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); - ASSERT_EQ(output.count(), output_f); + cldnn::mem_lock output_ptr(output, get_test_stream()); + ASSERT_EQ(output->count(), output_f); for (size_t i = 0; i < output_f; ++i) { auto& val = output_ptr[i]; float ref; @@ -579,9 +575,9 @@ TEST(depth_concatenate_f32_gpu, test07_concat_is_output) { const int32_t input_f = 16; const int32_t output_f = 2 * input_f; - const auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, {1, input_f, 1, 1} }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, {1, input_f, 1, 1} }); + auto& engine = get_test_engine(); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, {1, input_f, 1, 1} }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, {1, input_f, 1, 1} }); auto input1_data = generate_random_4d(1, input_f, 1, 1, -1, 1); auto input2_data = generate_random_4d(1, input_f, 1, 1, -1, 1); @@ -589,8 +585,8 @@ TEST(depth_concatenate_f32_gpu, test07_concat_is_output) { set_values(input2, flatten_4d(format::bfyx, input2_data)); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(activation("actv1", "input1", activation_func::linear, { 0.75f, 0.0f })); topology.add(activation("actv2", "input2", activation_func::linear, { 0.5f, 0.0f })); topology.add(concatenation("depth1", { "actv1", "actv2" }, concatenation::along_f)); @@ -610,8 +606,8 @@ TEST(depth_concatenate_f32_gpu, test07_concat_is_output) { EXPECT_TRUE(executed_primitives.count("depth1") == 1); auto output = outputs.at("depth1").get_memory(); - auto output_ptr = output.pointer(); - ASSERT_EQ(output.count(), output_f); + cldnn::mem_lock output_ptr(output, get_test_stream()); + ASSERT_EQ(output->count(), output_f); for (size_t i = 0; i < output_f; ++i) { auto& val = output_ptr[i]; float ref; @@ -625,23 +621,23 @@ TEST(depth_concatenate_f32_gpu, test07_concat_is_output) { } TEST(depth_concatenate_f32_gpu, concat_with_different_format_inputs) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); build_options build_opt; const int in1_f = 2, in2_f = 1; const int b = 2, x = 2, y = 4; - auto input1 = memory::allocate(engine, { data_types::f32, format::yxfb,{ b, in1_f, y, x } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ b, in2_f, y, x } }); - unsigned input2_start_value = (unsigned)input1.count() + 1; + auto input1 = engine.allocate_memory({ data_types::f32, format::yxfb,{ b, in1_f, y, x } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ b, in2_f, y, x } }); + unsigned input2_start_value = (unsigned)input1->count() + 1; - std::vector in1(input1.count()); - std::vector in2(input2.count()); + std::vector in1(input1->count()); + std::vector in2(input2->count()); - for (unsigned i = 0; i < input1.count(); i++) + for (unsigned i = 0; i < input1->count(); i++) { in1[i] = (float)(i + 1); } - for (unsigned i = 0; i < input2.count(); i++) + for (unsigned i = 0; i < input2->count(); i++) { in2[i] = (float)(i + input2_start_value); } @@ -652,8 +648,8 @@ TEST(depth_concatenate_f32_gpu, concat_with_different_format_inputs) { // Special constrution of topology to run buffer fusing optimization // for concatenation with different format inputs topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(concatenation("depth1", { "input1" }, concatenation::along_f)); topology.add(concatenation("depth2", { "input2" }, concatenation::along_f)); // In the step below there will be run of buffer fusing optimization for concatenation with @@ -672,7 +668,7 @@ TEST(depth_concatenate_f32_gpu, concat_with_different_format_inputs) { EXPECT_EQ(outputs.begin()->first, "depth4"); auto output = outputs.at("depth4").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); int input1_values_count = in1_f * x; int input2_values_count = in2_f * x; @@ -680,7 +676,7 @@ TEST(depth_concatenate_f32_gpu, concat_with_different_format_inputs) { int input2_batch_offset = x * y; int out_offset = 0; - for (unsigned i = 0; i < input1.count(); i++) + for (unsigned i = 0; i < input1->count(); i++) { int value = i + 1; EXPECT_FLOAT_EQ(float(value), output_ptr[out_offset++]); @@ -692,7 +688,7 @@ TEST(depth_concatenate_f32_gpu, concat_with_different_format_inputs) { } out_offset = input1_values_count; - for (unsigned i = 0; i < input2.count() / b; i++) + for (unsigned i = 0; i < input2->count() / b; i++) { for (unsigned j = 0; j < b; j++) { @@ -709,9 +705,9 @@ TEST(depth_concatenate_f32_gpu, concat_with_different_format_inputs) { TEST(depth_concatenate_f32_gpu, concat_with_reshape_input) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); build_options build_opt; - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2,4,1,2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2,4,1,2 } }); std::vector values = { 0.1f, 0.2f, 0.3f, 0.4f, @@ -722,7 +718,7 @@ TEST(depth_concatenate_f32_gpu, concat_with_reshape_input) { set_values(input1, values); topology topology; - topology.add(input_layout("input1", input1.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); topology.add(reshape("reshape", "input1", tensor(2, 1, 4, 2))); topology.add(concatenation("depth1", { "reshape" }, concatenation::along_f)); topology.add(concatenation("depth2", { "depth1" }, concatenation::along_f)); @@ -738,7 +734,7 @@ TEST(depth_concatenate_f32_gpu, concat_with_reshape_input) { auto output = outputs.at("depth2").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -747,13 +743,13 @@ TEST(depth_concatenate_f32_gpu, concat_with_reshape_input) { } TEST(depth_concatenate_i32_gpu, optimize_data01) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); build_options build_opt; - auto input = memory::allocate(engine, {data_types::i32, format::bfyx, {1, 1, 1, 1}}); + auto input = engine.allocate_memory({data_types::i32, format::bfyx, {1, 1, 1, 1}}); topology topology; topology.add( - input_layout("input", input.get_layout())); + input_layout("input", input->get_layout())); topology.add(cldnn::concatenation("int1", {"input"}, cldnn::concatenation::along_f)); topology.add(cldnn::concatenation("result1", {"int1"}, cldnn::concatenation::along_f)); topology.add(cldnn::concatenation("result2", {"int1"}, cldnn::concatenation::along_f)); @@ -768,28 +764,28 @@ TEST(depth_concatenate_i32_gpu, optimize_data01) { auto outputs = network.execute(); for (auto& it : outputs) { - auto output_ptr = it.second.get_memory().pointer(); + cldnn::mem_lock output_ptr(it.second.get_memory(), get_test_stream()); EXPECT_EQ(output_ptr[0], out_data[0]); } } TEST(depth_concatenate_i32_gpu, optimize_data02) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); build_options build_opt; - auto input1 = memory::allocate(engine, {data_types::i32, format::bfyx, {1, 1, 2, 2}}); - auto input2 = memory::allocate(engine, {data_types::i32, format::bfyx, {1, 1, 2, 2}}); - auto input3 = memory::allocate(engine, {data_types::i32, format::bfyx, {1, 1, 2, 2}}); - auto input4 = memory::allocate(engine, {data_types::i32, format::bfyx, {1, 1, 2, 2}}); + auto input1 = engine.allocate_memory({data_types::i32, format::bfyx, {1, 1, 2, 2}}); + auto input2 = engine.allocate_memory({data_types::i32, format::bfyx, {1, 1, 2, 2}}); + auto input3 = engine.allocate_memory({data_types::i32, format::bfyx, {1, 1, 2, 2}}); + auto input4 = engine.allocate_memory({data_types::i32, format::bfyx, {1, 1, 2, 2}}); topology topology; topology.add( - input_layout("input1", input1.get_layout())); + input_layout("input1", input1->get_layout())); topology.add( - input_layout("input2", input2.get_layout())); + input_layout("input2", input2->get_layout())); topology.add( - input_layout("input3", input3.get_layout())); + input_layout("input3", input3->get_layout())); topology.add( - input_layout("input4", input4.get_layout())); + input_layout("input4", input4->get_layout())); topology.add(cldnn::concatenation("concat1", {"input1", "input2"}, cldnn::concatenation::along_x)); topology.add(cldnn::concatenation("concat2", {"input3", "input4"}, cldnn::concatenation::along_x)); @@ -833,7 +829,7 @@ TEST(depth_concatenate_i32_gpu, optimize_data02) { network.set_input_data("input4", input4); auto outputs = network.execute(); - auto output_concat6 = outputs.at("concat6").get_memory().pointer(); + cldnn::mem_lock output_concat6(outputs.at("concat6").get_memory(), get_test_stream()); for (size_t i = 0; i < output_concat6.size(); i++) { EXPECT_EQ(output_concat6[i], c6_data[i]); @@ -841,13 +837,13 @@ TEST(depth_concatenate_i32_gpu, optimize_data02) { } TEST(depth_concatenate_i32_gpu, optimize_data03) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); build_options build_opt; - auto input1 = memory::allocate(engine, {data_types::i32, format::bfyx, {1, 1, 2, 2}}); + auto input1 = engine.allocate_memory({data_types::i32, format::bfyx, {1, 1, 2, 2}}); topology topology; topology.add( - input_layout("input1", input1.get_layout())); + input_layout("input1", input1->get_layout())); topology.add(cldnn::concatenation("concat1", {"input1"}, cldnn::concatenation::along_x)); @@ -873,7 +869,7 @@ TEST(depth_concatenate_i32_gpu, optimize_data03) { auto outputs = network.execute(); for (auto& it : outputs) { - auto output_ptr = it.second.get_memory().pointer(); + cldnn::mem_lock output_ptr(it.second.get_memory(), get_test_stream()); for (size_t i = 0; i < output_ptr.size(); i++) { EXPECT_EQ(output_ptr[i], output_data[i]); } @@ -881,13 +877,13 @@ TEST(depth_concatenate_i32_gpu, optimize_data03) { } TEST(depth_concatenate_i32_gpu, optimize_data04) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); build_options build_opt; - auto input1 = memory::allocate(engine, {data_types::i32, format::bfyx, {1, 1, 2, 2}}); + auto input1 = engine.allocate_memory({data_types::i32, format::bfyx, {1, 1, 2, 2}}); topology topology; topology.add( - input_layout("input1", input1.get_layout())); + input_layout("input1", input1->get_layout())); topology.add(cldnn::concatenation("concat1", {"input1"}, cldnn::concatenation::along_x)); @@ -913,7 +909,7 @@ TEST(depth_concatenate_i32_gpu, optimize_data04) { auto outputs = network.execute(); for (auto& it : outputs) { - auto output_ptr = it.second.get_memory().pointer(); + cldnn::mem_lock output_ptr(it.second.get_memory(), get_test_stream()); for (size_t i = 0; i < output_ptr.size(); i++) { EXPECT_EQ(output_ptr[i], output_data[i]); } @@ -921,13 +917,13 @@ TEST(depth_concatenate_i32_gpu, optimize_data04) { } TEST(depth_concatenate_i32_gpu, optimize_data05) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); build_options build_opt; - auto input1 = memory::allocate(engine, {data_types::i32, format::bfyx, {1, 1, 2, 2}}); + auto input1 = engine.allocate_memory({data_types::i32, format::bfyx, {1, 1, 2, 2}}); topology topology; topology.add( - input_layout("input1", input1.get_layout())); + input_layout("input1", input1->get_layout())); topology.add(cldnn::concatenation("concat1", {"input1"}, cldnn::concatenation::along_x)); @@ -953,7 +949,7 @@ TEST(depth_concatenate_i32_gpu, optimize_data05) { auto outputs = network.execute(); - auto output_concat5 = outputs.at("concat5").get_memory().pointer(); + cldnn::mem_lock output_concat5(outputs.at("concat5").get_memory(), get_test_stream()); for (size_t i = 0; i < output_concat5.size(); i++) { EXPECT_EQ(output_concat5[i], c5_data[i]); @@ -961,7 +957,7 @@ TEST(depth_concatenate_i32_gpu, optimize_data05) { } TEST(depth_concatenate_f32_gpu, basic_bfwzyx_along_w) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int b = 2; const int f = 3; const int x = 2; @@ -970,16 +966,16 @@ TEST(depth_concatenate_f32_gpu, basic_bfwzyx_along_w) { const int w = 9; auto input1_layout = layout(data_types::f32, format::bfwzyx, tensor{batch(b), feature(f), spatial(x, y, z, w)}); - auto input1 = memory::allocate(engine, input1_layout); + auto input1 = engine.allocate_memory(input1_layout); auto output_layout = layout(data_types::f32, format::bfwzyx, tensor{batch(b), feature(f), spatial(x, y, z, w * 2)}); topology topology; - topology.add(input_layout("input1", input1.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); topology.add(concatenation("concat", {"input1", "input1"}, concatenation::along_w)); - auto input_data = generate_random_1d(input1.count(), -1, 1); + auto input_data = generate_random_1d(input1->count(), -1, 1); - auto expected_output = std::vector(input1.count() * 2); + auto expected_output = std::vector(input1->count() * 2); for (int bi = 0; bi < b; bi++) for (int fi = 0; fi < f; fi++) @@ -1002,7 +998,7 @@ TEST(depth_concatenate_f32_gpu, basic_bfwzyx_along_w) { auto outputs = network.execute(); - auto output_concat = outputs.at("concat").get_memory().pointer(); + cldnn::mem_lock output_concat(outputs.at("concat").get_memory(), get_test_stream()); ASSERT_EQ(output_concat.size(), expected_output.size()); for (size_t i = 0; i < output_concat.size(); i++) { @@ -1021,19 +1017,19 @@ static network setup_depth_concatatenate_network(const std::vector d assert(dts.size() == ts.size()); const size_t sz = ts.size(); - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); topology topology; std::vector input_names; input_names.resize(sz); for (size_t i = 0; i < sz; ++i) { - auto input = memory::allocate(engine, {dts[i], fmt[i], ts[i]}); + auto input = engine.allocate_memory({dts[i], fmt[i], ts[i]}); input_names[i] = "input"; input_names[i] += std::to_string(i); - topology.add(input_layout(input_names[i], input.get_layout())); + topology.add(input_layout(input_names[i], input->get_layout())); } //TODO: ask Uzi if something tests cases where there's missing input_names (nodes not present in the topology, etc.) topology.add(concatenation("depth_concat_node", input_names, concatenation::along_f)); @@ -1194,44 +1190,44 @@ class depth_concatenate_test : public tests::generic_test { } template - memory generate_reference_typed(const std::vector& inputs) { + memory::ptr generate_reference_typed(const std::vector& inputs) { assert(!inputs.empty()); - const int in_b = inputs[0].get_layout().size.batch[0]; - const int in_h = inputs[0].get_layout().size.spatial[1]; - const int in_w = inputs[0].get_layout().size.spatial[0]; + const int in_b = inputs[0]->get_layout().size.batch[0]; + const int in_h = inputs[0]->get_layout().size.spatial[1]; + const int in_w = inputs[0]->get_layout().size.spatial[0]; int out_f = 0; - for (const memory& input : inputs) { - assert(input.get_layout().size.batch[0] == in_b); - assert(input.get_layout().size.spatial[1] == in_h); - assert(input.get_layout().size.spatial[0] == in_w); + for (const memory::ptr& input : inputs) { + assert(input->get_layout().size.batch[0] == in_b); + assert(input->get_layout().size.spatial[1] == in_h); + assert(input->get_layout().size.spatial[0] == in_w); - out_f += input.get_layout().size.feature[0]; + out_f += input->get_layout().size.feature[0]; - assert(input.get_layout().data_type == inputs[0].get_layout().data_type); - assert(input.get_layout().format.value == inputs[0].get_layout().format.value); + assert(input->get_layout().data_type == inputs[0]->get_layout().data_type); + assert(input->get_layout().format.value == inputs[0]->get_layout().format.value); } //Output is bfyx - auto output = memory::allocate(engine, cldnn::layout(inputs[0].get_layout().data_type, cldnn::format::bfyx, tensor(in_b, out_f, in_w, in_h))); - auto out_mem = output.pointer(); + auto output = engine.allocate_memory(cldnn::layout(inputs[0]->get_layout().data_type, cldnn::format::bfyx, tensor(in_b, out_f, in_w, in_h))); + cldnn::mem_lock out_mem(output, get_test_stream()); int out_f_off = 0; - for (const memory& input : inputs) { - const auto input_desc = get_linear_memory_desc(input.get_layout()); - const auto output_desc = get_linear_memory_desc(output.get_layout()); + for (const memory::ptr& input : inputs) { + const auto input_desc = get_linear_memory_desc(input->get_layout()); + const auto output_desc = get_linear_memory_desc(output->get_layout()); - const int in_f = input.get_layout().size.feature[0]; - const auto in_mem = input.pointer(); + const int in_f = input->get_layout().size.feature[0]; + cldnn::mem_lock in_mem(input, get_test_stream()); for (int n = 0; n < in_b; ++n) for (int f = 0; f < in_f; ++f) for (int y = 0; y < in_h; ++y) for (int x = 0; x < in_w; ++x) { - const size_t in_idx = get_linear_index(input.get_layout(), n, f, y, x, input_desc); - const size_t out_idx = get_linear_index(output.get_layout(), n, out_f_off + f, y, x, output_desc); + const size_t in_idx = get_linear_index(input->get_layout(), n, f, y, x, input_desc); + const size_t out_idx = get_linear_index(output->get_layout(), n, out_f_off + f, y, x, output_desc); out_mem[out_idx] = in_mem[in_idx]; } @@ -1242,7 +1238,7 @@ class depth_concatenate_test : public tests::generic_test { return output; } - virtual memory generate_reference(const std::vector& inputs) override { + virtual memory::ptr generate_reference(const std::vector& inputs) override { if (generic_params->data_type == data_types::f32) { return generate_reference_typed(inputs); } else { diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/depth_to_space_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/depth_to_space_gpu_test.cpp index 6f608e9efe5bf8..8e67dfbb4eb8cd 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/depth_to_space_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/depth_to_space_gpu_test.cpp @@ -3,19 +3,16 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include -#include -#include -#include -#include "api/permute.hpp" -#include "api/reorder.hpp" +#include "test_utils.h" + +#include +#include +#include +#include +#include #include -#include using namespace cldnn; using namespace ::tests; @@ -26,9 +23,9 @@ TEST(depth_to_space_fp16_gpu, d1411_bs2) { // Output : 1x1x2x2 // Input values in fp16 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 4, 1, 1 } }); + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 4, 1, 1 } }); size_t block_size = 2; set_values(input1, { @@ -37,7 +34,7 @@ TEST(depth_to_space_fp16_gpu, d1411_bs2) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add( depth_to_space("depth_to_space", "Input0", block_size, depth_to_space_mode::blocks_first) ); @@ -49,7 +46,7 @@ TEST(depth_to_space_fp16_gpu, d1411_bs2) { auto outputs = network.execute(); auto output = outputs.at("depth_to_space").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 1.f, 2.f, 3.f @@ -66,9 +63,9 @@ TEST(depth_to_space_fp16_gpu, d1421_bs2) { // Output : 1x1x4x2 // Input values in fp16 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 4, 1, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 4, 1, 2 } }); size_t block_size = 2; set_values(input1, { @@ -79,7 +76,7 @@ TEST(depth_to_space_fp16_gpu, d1421_bs2) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add( depth_to_space("depth_to_space", "Input0", block_size, depth_to_space_mode::blocks_first) ); @@ -91,7 +88,7 @@ TEST(depth_to_space_fp16_gpu, d1421_bs2) { auto outputs = network.execute(); auto output = outputs.at("depth_to_space").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 2.0f, 4.0f, 6.0f, 1.0f, 3.0f, 5.0f, 7.0f @@ -108,9 +105,9 @@ TEST(depth_to_space_fp16_gpu, d1933_bs3) { // Output : 1x1x9x9 // Input values in fp16 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 9, 3, 3 } }); + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 9, 3, 3 } }); size_t block_size = 3; set_values(input1, { @@ -134,7 +131,7 @@ TEST(depth_to_space_fp16_gpu, d1933_bs3) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add( depth_to_space("depth_to_space", "Input0", block_size, depth_to_space_mode::blocks_first) ); @@ -146,7 +143,7 @@ TEST(depth_to_space_fp16_gpu, d1933_bs3) { auto outputs = network.execute(); auto output = outputs.at("depth_to_space").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 9.0f, 18.0f, 1.0f, 10.0f, 19.0f, 2.0f, 11.0f, 20.0f, 27.0f, @@ -171,9 +168,9 @@ TEST(depth_to_space_fp32_gpu, d1411_bs2) { // Output : 1x1x2x2 // Input values in fp32 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 4, 1, 1 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 4, 1, 1 } }); size_t block_size = 2; set_values(input1, { @@ -181,7 +178,7 @@ TEST(depth_to_space_fp32_gpu, d1411_bs2) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add( depth_to_space("depth_to_space", "Input0", block_size, depth_to_space_mode::blocks_first) ); @@ -193,7 +190,7 @@ TEST(depth_to_space_fp32_gpu, d1411_bs2) { auto outputs = network.execute(); auto output = outputs.at("depth_to_space").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 1.f, 2.f, 3.f @@ -210,9 +207,9 @@ TEST(depth_to_space_fp32_gpu, d112960540_bs2) { // Output : 1x3x1920x1080 // Input values in fp16 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 12, 960, 540 } }); + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 12, 960, 540 } }); size_t block_size = 2; auto random_input = generate_random_4d(1, 12, 540, 960, -1, 1); @@ -220,7 +217,7 @@ TEST(depth_to_space_fp32_gpu, d112960540_bs2) { set_values(input1, input_rnd_vec); topology topology_act; - topology_act.add(input_layout("Input0", input1.get_layout())); + topology_act.add(input_layout("Input0", input1->get_layout())); topology_act.add( depth_to_space("depth_to_space", "Input0", block_size, depth_to_space_mode::blocks_first) ); @@ -232,12 +229,12 @@ TEST(depth_to_space_fp32_gpu, d112960540_bs2) { auto outputs = network_act.execute(); auto output = outputs.at("depth_to_space").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr (output, get_test_stream()); std::vector perm = { 0,4,5,2,1,3 }; topology topology_ref; - topology_ref.add(input_layout("Input0", input1.get_layout())); + topology_ref.add(input_layout("Input0", input1->get_layout())); topology_ref.add(reorder("reorder1", "Input0", { data_types::f16, format::bfwzyx, tensor{ batch(1), feature(12), spatial(1, 1, 960, 540) } })); topology_ref.add( @@ -259,9 +256,9 @@ TEST(depth_to_space_fp32_gpu, d112960540_bs2) { auto outputs_ref = network_ref.execute(); auto output_ref = outputs_ref.at("reshape2").get_memory(); - auto output_ptr_ref = output_ref.pointer(); + cldnn::mem_lock output_ptr_ref(output_ref, get_test_stream()); - for (size_t i = 0; i < output.get_layout().count(); ++i) { + for (size_t i = 0; i < output->get_layout().count(); ++i) { EXPECT_EQ(output_ptr_ref[i], output_ptr[i]); } } @@ -272,9 +269,9 @@ TEST(depth_to_space_fp32_gpu, d1933_bs3) { // Output : 1x1x9x9 // Input values in fp32 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 9, 3, 3 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 9, 3, 3 } }); size_t block_size = 3; set_values(input1, { @@ -290,7 +287,7 @@ TEST(depth_to_space_fp32_gpu, d1933_bs3) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add( depth_to_space("depth_to_space", "Input0", block_size, depth_to_space_mode::blocks_first) ); @@ -302,7 +299,7 @@ TEST(depth_to_space_fp32_gpu, d1933_bs3) { auto outputs = network.execute(); auto output = outputs.at("depth_to_space").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 9.0f, 18.0f, 1.0f, 10.0f, 19.0f, 2.0f, 11.0f, 20.0f, 27.0f, @@ -328,9 +325,9 @@ TEST(depth_to_space_fp32_gpu, d1822_bs2_blocks_first) { // Output : 1x2x4x4 // Input values in fp32 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 8, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 8, 2, 2 } }); size_t block_size = 2; set_values(input1, { @@ -345,7 +342,7 @@ TEST(depth_to_space_fp32_gpu, d1822_bs2_blocks_first) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add( depth_to_space("depth_to_space", "Input0", block_size, depth_to_space_mode::blocks_first) ); @@ -357,7 +354,7 @@ TEST(depth_to_space_fp32_gpu, d1822_bs2_blocks_first) { auto outputs = network.execute(); auto output = outputs.at("depth_to_space").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 8.0f, 1.0f, 9.0f, 16.0f, 24.0f, 17.0f, 25.0f, @@ -378,9 +375,9 @@ TEST(depth_to_space_fp32_gpu, d1822_bs2_depth_first) { // Output : 1x2x4x4 // Input values in fp32 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 8, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 8, 2, 2 } }); size_t block_size = 2; set_values(input1, { @@ -395,7 +392,7 @@ TEST(depth_to_space_fp32_gpu, d1822_bs2_depth_first) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add( depth_to_space("depth_to_space", "Input0", block_size, depth_to_space_mode::depth_first) ); @@ -407,7 +404,7 @@ TEST(depth_to_space_fp32_gpu, d1822_bs2_depth_first) { auto outputs = network.execute(); auto output = outputs.at("depth_to_space").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 4.0f, 1.0f, 5.0f, 8.0f, 12.0f, 9.0f, 13.0f, diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/detection_output_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/detection_output_test.cpp index 2112f227ca29fb..5d85613c1c5025 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/detection_output_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/detection_output_test.cpp @@ -3,21 +3,18 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include "api/detection_output.hpp" -#include -#include -#include -#include "test_utils/test_utils.h" + +#include "test_utils.h" + +#include +#include namespace cldnn { template<> struct type_to_data_type { static const data_types value = data_types::f16; }; } using namespace cldnn; -using namespace tests; +using namespace ::tests; template class detection_output_test : public ::testing::Test { @@ -26,12 +23,12 @@ class detection_output_test : public ::testing::Test { detection_output_test() : nms_threshold(0.1f) {} - void init_buffers(cldnn::memory prior_memory, cldnn::memory confidence_memory, cldnn::memory location_memory, + void init_buffers(cldnn::memory::ptr prior_memory, cldnn::memory::ptr confidence_memory, cldnn::memory::ptr location_memory, bool share_location, bool variance_encoded_in_target = false, int prior_info_size = 4, int prior_coordinates_offset = 0, bool prior_is_normalized = true) { - auto location_ptr = location_memory.pointer(); - auto confidence_ptr = confidence_memory.pointer(); - auto prior_box_ptr = prior_memory.pointer(); + cldnn::mem_lock location_ptr(location_memory, get_test_stream()); + cldnn::mem_lock confidence_ptr(confidence_memory, get_test_stream()); + cldnn::mem_lock prior_box_ptr(prior_memory, get_test_stream()); T* prior_data = prior_box_ptr.data(); T* confidence_data = confidence_ptr.data(); @@ -93,10 +90,10 @@ class detection_output_test : public ::testing::Test { } } - void init_buffer_sort(cldnn::memory input_buff) { - auto input_data_ptr = input_buff.pointer(); + void init_buffer_sort(cldnn::memory::ptr input_buff) { + cldnn::mem_lock input_data_ptr(input_buff, get_test_stream()); - EXPECT_EQ((int)input_buff.count(), 128); + EXPECT_EQ((int)input_buff->count(), 128); T* input_data = input_data_ptr.data(); input_data[0] = 8; @@ -119,8 +116,8 @@ class detection_output_test : public ::testing::Test { input_data[121] = -1; input_data[122] = 0; input_data[123] = 0; input_data[124] = 0; input_data[125] = 0; input_data[126] = 0; input_data[127] = 0; } - void check_results(const memory& output, const int num, const std::string values) { - assert(num < output.get_layout().size.spatial[1]); + void check_results(const memory::ptr output, const int num, const std::string values) { + assert(num < output->get_layout().size.spatial[1]); // Split values to vector of items. std::vector items; @@ -129,13 +126,13 @@ class detection_output_test : public ::testing::Test { EXPECT_EQ((int)items.size(), 7); // Check data. - auto out_ptr = output.pointer(); + cldnn::mem_lock out_ptr(output, get_test_stream()); const T* data = out_ptr.data(); for (int i = 0; i < 2; ++i) { - EXPECT_EQ(static_cast((float)data[num * output.get_layout().size.spatial[0] + i]), atoi(items[i].c_str())); + EXPECT_EQ(static_cast((float)data[num * output->get_layout().size.spatial[0] + i]), atoi(items[i].c_str())); } for (int i = 2; i < 7; ++i) { - EXPECT_TRUE(floating_point_equal(data[num * output.get_layout().size.spatial[0] + i], (T)(float)atof(items[i].c_str()))); + EXPECT_TRUE(floating_point_equal(data[num * output->get_layout().size.spatial[0] + i], (T)(float)atof(items[i].c_str()))); } } @@ -144,15 +141,15 @@ class detection_output_test : public ::testing::Test { const int num_loc_classes = share_location ? 1 : this->num_classes; const int keep_top_k = 150; - const auto& engine = get_test_engine(); - cldnn::memory input_location = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); - cldnn::memory input_confidence = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); - cldnn::memory input_prior_box = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ 1, 2, 1, this->num_priors * 4 } }); + auto& engine = get_test_engine(); + cldnn::memory::ptr input_location = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); + cldnn::memory::ptr input_confidence = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); + cldnn::memory::ptr input_prior_box = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ 1, 2, 1, this->num_priors * 4 } }); topology topology; - topology.add(input_layout("input_location", input_location.get_layout())); - topology.add(input_layout("input_confidence", input_confidence.get_layout())); - topology.add(input_layout("input_prior_box", input_prior_box.get_layout())); + topology.add(input_layout("input_location", input_location->get_layout())); + topology.add(input_layout("input_confidence", input_confidence->get_layout())); + topology.add(input_layout("input_prior_box", input_prior_box->get_layout())); topology.add(detection_output("detection_output", "input_location", "input_confidence", "input_prior_box", this->num_classes, keep_top_k)); @@ -167,10 +164,10 @@ class detection_output_test : public ::testing::Test { EXPECT_EQ(outputs.size(), size_t(1)); EXPECT_EQ(outputs.begin()->first, "detection_output"); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.batch[0], 1); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.feature[0], 1); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.spatial[1], keep_top_k * this->num_of_images); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.spatial[0], 7); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.batch[0], 1); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.feature[0], 1); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.spatial[1], keep_top_k * this->num_of_images); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.spatial[0], 7); } void setup_two_layers() { @@ -178,15 +175,15 @@ class detection_output_test : public ::testing::Test { const int num_loc_classes = share_location ? 1 : this->num_classes; const int keep_top_k = 150; - const auto& engine = get_test_engine(); - cldnn::memory input_location = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); - cldnn::memory input_confidence = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); - cldnn::memory input_prior_box = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ 1, 2, 1, this->num_priors * 4 } }); + auto& engine = get_test_engine(); + cldnn::memory::ptr input_location = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); + cldnn::memory::ptr input_confidence = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); + cldnn::memory::ptr input_prior_box = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ 1, 2, 1, this->num_priors * 4 } }); topology topology; - topology.add(input_layout("input_location", input_location.get_layout())); - topology.add(input_layout("input_confidence", input_confidence.get_layout())); - topology.add(input_layout("input_prior_box", input_prior_box.get_layout())); + topology.add(input_layout("input_location", input_location->get_layout())); + topology.add(input_layout("input_confidence", input_confidence->get_layout())); + topology.add(input_layout("input_prior_box", input_prior_box->get_layout())); topology.add(detection_output("detection_output_1", "input_location", "input_confidence", "input_prior_box", this->num_classes, keep_top_k)); topology.add(detection_output("detection_output_2", "input_location", "input_confidence", "input_prior_box", this->num_classes, keep_top_k)); @@ -205,10 +202,10 @@ class detection_output_test : public ::testing::Test { EXPECT_EQ(it->first, "detection_output_" + std::to_string(i)); - EXPECT_EQ(it->second.get_memory().get_layout().size.batch[0], 1); - EXPECT_EQ(it->second.get_memory().get_layout().size.feature[0], 1); - EXPECT_EQ(it->second.get_memory().get_layout().size.spatial[1], keep_top_k * this->num_of_images); - EXPECT_EQ(it->second.get_memory().get_layout().size.spatial[0], 7); + EXPECT_EQ(it->second.get_memory()->get_layout().size.batch[0], 1); + EXPECT_EQ(it->second.get_memory()->get_layout().size.feature[0], 1); + EXPECT_EQ(it->second.get_memory()->get_layout().size.spatial[1], keep_top_k * this->num_of_images); + EXPECT_EQ(it->second.get_memory()->get_layout().size.spatial[0], 7); i++; } } @@ -219,17 +216,17 @@ class detection_output_test : public ::testing::Test { const int keep_top_k = 4; const int background_label_id = 0; - const auto& engine = get_test_engine(); - cldnn::memory input_location = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); - cldnn::memory input_confidence = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); - cldnn::memory input_prior_box = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ 1, 2, 1, this->num_priors * 4 } }); + auto& engine = get_test_engine(); + cldnn::memory::ptr input_location = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); + cldnn::memory::ptr input_confidence = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); + cldnn::memory::ptr input_prior_box = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ 1, 2, 1, this->num_priors * 4 } }); this->init_buffers(input_prior_box, input_confidence, input_location, share_location); topology topology; - topology.add(input_layout("input_location", input_location.get_layout())); - topology.add(input_layout("input_confidence", input_confidence.get_layout())); - topology.add(input_layout("input_prior_box", input_prior_box.get_layout())); + topology.add(input_layout("input_location", input_location->get_layout())); + topology.add(input_layout("input_confidence", input_confidence->get_layout())); + topology.add(input_layout("input_prior_box", input_prior_box->get_layout())); topology.add(detection_output("detection_output", "input_location", "input_confidence", "input_prior_box", this->num_classes, keep_top_k, share_location, background_label_id, this->nms_threshold)); @@ -244,10 +241,10 @@ class detection_output_test : public ::testing::Test { EXPECT_EQ(outputs.size(), size_t(1)); EXPECT_EQ(outputs.begin()->first, "detection_output"); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.batch[0], 1); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.feature[0], 1); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.spatial[1], keep_top_k * this->num_of_images); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.spatial[0], 7); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.batch[0], 1); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.feature[0], 1); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.spatial[1], keep_top_k * this->num_of_images); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.spatial[0], 7); auto output_prim = outputs.begin()->second.get_memory(); @@ -267,17 +264,17 @@ class detection_output_test : public ::testing::Test { const int keep_top_k = 1; const int background_label_id = 0; - const auto& engine = get_test_engine(); - cldnn::memory input_location = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); - cldnn::memory input_confidence = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); - cldnn::memory input_prior_box = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ 1, 2, 1, this->num_priors * 4 } }); + auto& engine = get_test_engine(); + cldnn::memory::ptr input_location = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); + cldnn::memory::ptr input_confidence = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); + cldnn::memory::ptr input_prior_box = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ 1, 2, 1, this->num_priors * 4 } }); this->init_buffers(input_prior_box, input_confidence, input_location, share_location); topology topology; - topology.add(input_layout("input_location", input_location.get_layout())); - topology.add(input_layout("input_confidence", input_confidence.get_layout())); - topology.add(input_layout("input_prior_box", input_prior_box.get_layout())); + topology.add(input_layout("input_location", input_location->get_layout())); + topology.add(input_layout("input_confidence", input_confidence->get_layout())); + topology.add(input_layout("input_prior_box", input_prior_box->get_layout())); topology.add(detection_output("detection_output", "input_location", "input_confidence", "input_prior_box", this->num_classes, keep_top_k, share_location, background_label_id, this->nms_threshold)); @@ -292,10 +289,10 @@ class detection_output_test : public ::testing::Test { EXPECT_EQ(outputs.size(), size_t(1)); EXPECT_EQ(outputs.begin()->first, "detection_output"); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.batch[0], 1); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.feature[0], 1); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.spatial[1], keep_top_k * this->num_of_images); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.spatial[0], 7); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.batch[0], 1); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.feature[0], 1); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.spatial[1], keep_top_k * this->num_of_images); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.spatial[0], 7); auto output_prim = outputs.begin()->second.get_memory(); @@ -309,17 +306,17 @@ class detection_output_test : public ::testing::Test { const int keep_top_k = 6; const int background_label_id = 0; - const auto& engine = get_test_engine(); - cldnn::memory input_location = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); - cldnn::memory input_confidence = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); - cldnn::memory input_prior_box = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ 1, 2, 1, this->num_priors * 4 } }); + auto& engine = get_test_engine(); + cldnn::memory::ptr input_location = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); + cldnn::memory::ptr input_confidence = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); + cldnn::memory::ptr input_prior_box = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ 1, 2, 1, this->num_priors * 4 } }); this->init_buffers(input_prior_box, input_confidence, input_location, share_location); topology topology; - topology.add(input_layout("input_location", input_location.get_layout())); - topology.add(input_layout("input_confidence", input_confidence.get_layout())); - topology.add(input_layout("input_prior_box", input_prior_box.get_layout())); + topology.add(input_layout("input_location", input_location->get_layout())); + topology.add(input_layout("input_confidence", input_confidence->get_layout())); + topology.add(input_layout("input_prior_box", input_prior_box->get_layout())); topology.add(detection_output("detection_output", "input_location", "input_confidence", "input_prior_box", this->num_classes, keep_top_k, share_location, background_label_id, this->nms_threshold)); @@ -334,10 +331,10 @@ class detection_output_test : public ::testing::Test { EXPECT_EQ(outputs.size(), size_t(1)); EXPECT_EQ(outputs.begin()->first, "detection_output"); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.batch[0], 1); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.feature[0], 1); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.spatial[1], keep_top_k * this->num_of_images); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.spatial[0], 7); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.batch[0], 1); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.feature[0], 1); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.spatial[1], keep_top_k * this->num_of_images); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.spatial[0], 7); auto output_prim = outputs.begin()->second.get_memory(); @@ -362,17 +359,17 @@ class detection_output_test : public ::testing::Test { const int top_k = 2; const int background_label_id = 0; - const auto& engine = get_test_engine(); - cldnn::memory input_location = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); - cldnn::memory input_confidence = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); - cldnn::memory input_prior_box = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ 1, 2, 1, this->num_priors * 4 } }); + auto& engine = get_test_engine(); + cldnn::memory::ptr input_location = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); + cldnn::memory::ptr input_confidence = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); + cldnn::memory::ptr input_prior_box = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ 1, 2, 1, this->num_priors * 4 } }); this->init_buffers(input_prior_box, input_confidence, input_location, share_location); topology topology; - topology.add(input_layout("input_location", input_location.get_layout())); - topology.add(input_layout("input_confidence", input_confidence.get_layout())); - topology.add(input_layout("input_prior_box", input_prior_box.get_layout())); + topology.add(input_layout("input_location", input_location->get_layout())); + topology.add(input_layout("input_confidence", input_confidence->get_layout())); + topology.add(input_layout("input_prior_box", input_prior_box->get_layout())); topology.add(detection_output("detection_output", "input_location", "input_confidence", "input_prior_box", this->num_classes, keep_top_k, share_location, background_label_id, this->nms_threshold, top_k)); @@ -387,10 +384,10 @@ class detection_output_test : public ::testing::Test { EXPECT_EQ(outputs.size(), size_t(1)); EXPECT_EQ(outputs.begin()->first, "detection_output"); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.batch[0], 1); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.feature[0], 1); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.spatial[1], keep_top_k * this->num_of_images); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.spatial[0], 7); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.batch[0], 1); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.feature[0], 1); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.spatial[1], keep_top_k * this->num_of_images); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.spatial[0], 7); auto output_prim = outputs.begin()->second.get_memory(); @@ -406,17 +403,17 @@ class detection_output_test : public ::testing::Test { const int keep_top_k = 10; const int background_label_id = -1; - const auto& engine = get_test_engine(); - cldnn::memory input_location = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); - cldnn::memory input_confidence = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); - cldnn::memory input_prior_box = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ 1, 2, 1, this->num_priors * 4 } }); + auto& engine = get_test_engine(); + cldnn::memory::ptr input_location = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); + cldnn::memory::ptr input_confidence = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); + cldnn::memory::ptr input_prior_box = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ 1, 2, 1, this->num_priors * 4 } }); this->init_buffers(input_prior_box, input_confidence, input_location, share_location); topology topology; - topology.add(input_layout("input_location", input_location.get_layout())); - topology.add(input_layout("input_confidence", input_confidence.get_layout())); - topology.add(input_layout("input_prior_box", input_prior_box.get_layout())); + topology.add(input_layout("input_location", input_location->get_layout())); + topology.add(input_layout("input_confidence", input_confidence->get_layout())); + topology.add(input_layout("input_prior_box", input_prior_box->get_layout())); topology.add(detection_output("detection_output", "input_location", "input_confidence", "input_prior_box", this->num_classes, keep_top_k, share_location, background_label_id, this->nms_threshold)); @@ -431,10 +428,10 @@ class detection_output_test : public ::testing::Test { EXPECT_EQ(outputs.size(), size_t(1)); EXPECT_EQ(outputs.begin()->first, "detection_output"); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.batch[0], 1); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.feature[0], 1); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.spatial[1], keep_top_k * this->num_of_images); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.spatial[0], 7); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.batch[0], 1); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.feature[0], 1); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.spatial[1], keep_top_k * this->num_of_images); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.spatial[0], 7); auto output_prim = outputs.begin()->second.get_memory(); @@ -467,17 +464,17 @@ class detection_output_test : public ::testing::Test { const int background_label_id = -1; const int top_k = 2; - const auto& engine = get_test_engine(); - cldnn::memory input_location = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); - cldnn::memory input_confidence = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); - cldnn::memory input_prior_box = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ 1, 2, 1, this->num_priors * 4 } }); + auto& engine = get_test_engine(); + cldnn::memory::ptr input_location = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); + cldnn::memory::ptr input_confidence = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); + cldnn::memory::ptr input_prior_box = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ 1, 2, 1, this->num_priors * 4 } }); this->init_buffers(input_prior_box, input_confidence, input_location, share_location); topology topology; - topology.add(input_layout("input_location", input_location.get_layout())); - topology.add(input_layout("input_confidence", input_confidence.get_layout())); - topology.add(input_layout("input_prior_box", input_prior_box.get_layout())); + topology.add(input_layout("input_location", input_location->get_layout())); + topology.add(input_layout("input_confidence", input_confidence->get_layout())); + topology.add(input_layout("input_prior_box", input_prior_box->get_layout())); topology.add(detection_output("detection_output", "input_location", "input_confidence", "input_prior_box", this->num_classes, keep_top_k, share_location, background_label_id, this->nms_threshold, top_k)); @@ -492,10 +489,10 @@ class detection_output_test : public ::testing::Test { EXPECT_EQ(outputs.size(), size_t(1)); EXPECT_EQ(outputs.begin()->first, "detection_output"); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.batch[0], 1); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.feature[0], 1); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.spatial[1], keep_top_k * this->num_of_images); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.spatial[0], 7); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.batch[0], 1); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.feature[0], 1); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.spatial[1], keep_top_k * this->num_of_images); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.spatial[0], 7); auto output_prim = outputs.begin()->second.get_memory(); @@ -515,17 +512,17 @@ class detection_output_test : public ::testing::Test { const int keep_top_k = 5; const int background_label_id = 0; - const auto& engine = get_test_engine(); - cldnn::memory input_location = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); - cldnn::memory input_confidence = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); - cldnn::memory input_prior_box = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ 1, 2, 1, this->num_priors * 4 } }); + auto& engine = get_test_engine(); + cldnn::memory::ptr input_location = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); + cldnn::memory::ptr input_confidence = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); + cldnn::memory::ptr input_prior_box = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ 1, 2, 1, this->num_priors * 4 } }); this->init_buffers(input_prior_box, input_confidence, input_location, share_location); topology topology; - topology.add(input_layout("input_location", input_location.get_layout())); - topology.add(input_layout("input_confidence", input_confidence.get_layout())); - topology.add(input_layout("input_prior_box", input_prior_box.get_layout())); + topology.add(input_layout("input_location", input_location->get_layout())); + topology.add(input_layout("input_confidence", input_confidence->get_layout())); + topology.add(input_layout("input_prior_box", input_prior_box->get_layout())); topology.add(detection_output("detection_output", "input_location", "input_confidence", "input_prior_box", this->num_classes, keep_top_k, share_location, background_label_id, this->nms_threshold)); @@ -540,10 +537,10 @@ class detection_output_test : public ::testing::Test { EXPECT_EQ(outputs.size(), size_t(1)); EXPECT_EQ(outputs.begin()->first, "detection_output"); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.batch[0], 1); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.feature[0], 1); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.spatial[1], keep_top_k * this->num_of_images); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.spatial[0], 7); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.batch[0], 1); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.feature[0], 1); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.spatial[1], keep_top_k * this->num_of_images); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.spatial[0], 7); auto output_prim = outputs.begin()->second.get_memory(); @@ -566,17 +563,17 @@ class detection_output_test : public ::testing::Test { const int background_label_id = 0; const int top_k = 2; - const auto& engine = get_test_engine(); - cldnn::memory input_location = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); - cldnn::memory input_confidence = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); - cldnn::memory input_prior_box = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ 1, 2, 1, this->num_priors * 4 } }); + auto& engine = get_test_engine(); + cldnn::memory::ptr input_location = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); + cldnn::memory::ptr input_confidence = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); + cldnn::memory::ptr input_prior_box = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ 1, 2, 1, this->num_priors * 4 } }); this->init_buffers(input_prior_box, input_confidence, input_location, share_location); topology topology; - topology.add(input_layout("input_location", input_location.get_layout())); - topology.add(input_layout("input_confidence", input_confidence.get_layout())); - topology.add(input_layout("input_prior_box", input_prior_box.get_layout())); + topology.add(input_layout("input_location", input_location->get_layout())); + topology.add(input_layout("input_confidence", input_confidence->get_layout())); + topology.add(input_layout("input_prior_box", input_prior_box->get_layout())); topology.add(detection_output("detection_output", "input_location", "input_confidence", "input_prior_box", this->num_classes, keep_top_k, share_location, background_label_id, this->nms_threshold, top_k)); @@ -591,10 +588,10 @@ class detection_output_test : public ::testing::Test { EXPECT_EQ(outputs.size(), size_t(1)); EXPECT_EQ(outputs.begin()->first, "detection_output"); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.batch[0], 1); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.feature[0], 1); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.spatial[1], keep_top_k * this->num_of_images); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.spatial[0], 7); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.batch[0], 1); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.feature[0], 1); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.spatial[1], keep_top_k * this->num_of_images); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.spatial[0], 7); auto output_prim = outputs.begin()->second.get_memory(); @@ -611,18 +608,18 @@ class detection_output_test : public ::testing::Test { const int background_label_id = -1; const int top_k = 2; - const auto& engine = get_test_engine(); - cldnn::memory input_location = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); - cldnn::memory input_confidence = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); - cldnn::memory input_prior_box = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ 1, 2, 1, this->num_priors * 4 } }); + auto& engine = get_test_engine(); + cldnn::memory::ptr input_location = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); + cldnn::memory::ptr input_confidence = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); + cldnn::memory::ptr input_prior_box = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ 1, 2, 1, this->num_priors * 4 } }); this->init_buffers(input_prior_box, input_confidence, input_location, share_location); topology topology; - topology.add(input_layout("input_location", input_location.get_layout())); - topology.add(input_layout("input_confidence", input_confidence.get_layout())); - topology.add(input_layout("input_prior_box", input_prior_box.get_layout())); - topology.add(reorder("input_location_padded", "input_location", input_location.get_layout().with_padding(padding{ { 0, 0, 12, 3 },{ 0, 0, 5, 11 } }))); - topology.add(reorder("input_confidence_padded", "input_confidence", input_location.get_layout().with_padding(padding{ { 0, 0, 2, 7 },{ 0, 0, 13, 1 } }))); + topology.add(input_layout("input_location", input_location->get_layout())); + topology.add(input_layout("input_confidence", input_confidence->get_layout())); + topology.add(input_layout("input_prior_box", input_prior_box->get_layout())); + topology.add(reorder("input_location_padded", "input_location", input_location->get_layout().with_padding(padding{ { 0, 0, 12, 3 },{ 0, 0, 5, 11 } }))); + topology.add(reorder("input_confidence_padded", "input_confidence", input_location->get_layout().with_padding(padding{ { 0, 0, 2, 7 },{ 0, 0, 13, 1 } }))); topology.add(detection_output("detection_output", "input_location_padded", "input_confidence_padded", "input_prior_box", this->num_classes, keep_top_k, share_location, background_label_id, this->nms_threshold, top_k)); @@ -637,10 +634,10 @@ class detection_output_test : public ::testing::Test { EXPECT_EQ(outputs.size(), size_t(1)); EXPECT_EQ(outputs.begin()->first, "detection_output"); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.batch[0], 1); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.feature[0], 1); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.spatial[1], keep_top_k * this->num_of_images); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.spatial[0], 7); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.batch[0], 1); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.feature[0], 1); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.spatial[1], keep_top_k * this->num_of_images); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.spatial[0], 7); auto output_prim = outputs.begin()->second.get_memory(); @@ -668,20 +665,20 @@ class detection_output_test : public ::testing::Test { const int32_t prior_coordinates_offset = 1; const bool prior_is_normalized = true; - const auto& engine = get_test_engine(); - cldnn::memory input_location = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); - cldnn::memory input_confidence = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); - cldnn::memory input_prior_box = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ 1, 1, 1, this->num_priors * prior_info_size } }); + auto& engine = get_test_engine(); + cldnn::memory::ptr input_location = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * num_loc_classes * 4, 1, 1 } }); + cldnn::memory::ptr input_confidence = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ this->num_of_images, this->num_priors * this->num_classes, 1, 1 } }); + cldnn::memory::ptr input_prior_box = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ 1, 1, 1, this->num_priors * prior_info_size } }); this->init_buffers(input_prior_box, input_confidence, input_location, share_location, variance_encoded_in_target, prior_info_size, prior_coordinates_offset, prior_is_normalized); topology topology; - topology.add(input_layout("input_location", input_location.get_layout())); - topology.add(input_layout("input_confidence", input_confidence.get_layout())); - topology.add(input_layout("input_prior_box", input_prior_box.get_layout())); - topology.add(reorder("input_location_padded", "input_location", input_location.get_layout().with_padding(padding{ { 0, 0, 12, 3 },{ 0, 0, 5, 11 } }))); - topology.add(reorder("input_confidence_padded", "input_confidence", input_location.get_layout().with_padding(padding{ { 0, 0, 2, 7 },{ 0, 0, 13, 1 } }))); + topology.add(input_layout("input_location", input_location->get_layout())); + topology.add(input_layout("input_confidence", input_confidence->get_layout())); + topology.add(input_layout("input_prior_box", input_prior_box->get_layout())); + topology.add(reorder("input_location_padded", "input_location", input_location->get_layout().with_padding(padding{ { 0, 0, 12, 3 },{ 0, 0, 5, 11 } }))); + topology.add(reorder("input_confidence_padded", "input_confidence", input_location->get_layout().with_padding(padding{ { 0, 0, 2, 7 },{ 0, 0, 13, 1 } }))); topology.add(detection_output("detection_output", "input_location_padded", "input_confidence_padded", "input_prior_box", this->num_classes, keep_top_k, share_location, background_label_id, this->nms_threshold, top_k, @@ -700,10 +697,10 @@ class detection_output_test : public ::testing::Test { EXPECT_EQ(outputs.size(), size_t(1)); EXPECT_EQ(outputs.begin()->first, "detection_output"); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.batch[0], 1); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.feature[0], 1); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.spatial[1], keep_top_k * this->num_of_images); - EXPECT_EQ(outputs.begin()->second.get_memory().get_layout().size.spatial[0], 7); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.batch[0], 1); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.feature[0], 1); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.spatial[1], keep_top_k * this->num_of_images); + EXPECT_EQ(outputs.begin()->second.get_memory()->get_layout().size.spatial[0], 7); auto output_prim = outputs.begin()->second.get_memory(); diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/eltwise_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/eltwise_gpu_test.cpp index 32456c52da362b..016f4b98c69bbc 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/eltwise_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/eltwise_gpu_test.cpp @@ -3,16 +3,13 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include "api/eltwise.hpp" -#include -#include -#include -#include -#include -#include "test_utils/test_utils.h" + +#include "test_utils.h" + +#include +#include +#include +#include namespace cldnn { @@ -20,7 +17,7 @@ namespace cldnn } using namespace cldnn; -using namespace tests; +using namespace ::tests; template T eltwise_execute(cldnn::eltwise_mode mode, T x, T y) { @@ -88,17 +85,17 @@ void generic_eltwise_test(cldnn::format test_input_fmt, int input_b, int input_f VF input1_rnd_vec = flatten_4d(test_input_fmt, input1_rnd); VF input2_rnd_vec = flatten_4d(test_input_fmt, input2_rnd); - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); tensor input_tensor( input_b, input_f, input_x, input_y ); - auto input1 = memory::allocate(engine, { type_to_data_type::value, test_input_fmt, input_tensor }); - auto input2 = memory::allocate(engine, { type_to_data_type::value, test_input_fmt, input_tensor }); + auto input1 = engine.allocate_memory({ type_to_data_type::value, test_input_fmt, input_tensor }); + auto input2 = engine.allocate_memory({ type_to_data_type::value, test_input_fmt, input_tensor }); set_values(input1, input1_rnd_vec); set_values(input2, input2_rnd_vec); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(reorder("reorder1", "input1", input1.get_layout().with_padding(padding{{ 0, 0, input_padding_x, input_padding_y }, 0 }))); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(reorder("reorder1", "input1", input1->get_layout().with_padding(padding{{ 0, 0, input_padding_x, input_padding_y }, 0 }))); topology.add(eltwise("eltwise", {"reorder1", "input2"}, mode, padding{ { 0, 0, output_padding_x, output_padding_y }, 0 })); primitive_id out_id = "eltwise"; if (relu) @@ -114,8 +111,8 @@ void generic_eltwise_test(cldnn::format test_input_fmt, int input_b, int input_f EXPECT_EQ(outputs.begin()->first, out_id); auto output_memory = outputs.at(out_id).get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); VVVVF output_cpu = eltwise_reference(input1_rnd, input2_rnd, mode, relu, slope, input_padding_y, input_padding_x, output_padding_y, output_padding_x); EXPECT_EQ(output_layout.format.value, test_input_fmt.value); @@ -176,10 +173,10 @@ TEST(eltwise_gpu_f32, equal_in2_float_out1_int) { // 0, 0, 0, 0, // 0, 1, 0, 0 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); set_values(input1, { 1.f, 2.5f, 5.f, 1.5f, @@ -196,8 +193,8 @@ TEST(eltwise_gpu_f32, equal_in2_float_out1_int) { }); topology topology; - topology.add(input_layout("input", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", {"input", "input2"}, eltwise_mode::eq)); network network(engine, topology); @@ -211,7 +208,7 @@ TEST(eltwise_gpu_f32, equal_in2_float_out1_int) { EXPECT_EQ(outputs.begin()->first, "eltwise"); auto output = outputs.at("eltwise").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 0, 1, 0, 1, 0, 0, 1, 0, @@ -246,10 +243,10 @@ TEST(eltwise_gpu_f32, not_equal_in2_float_out1_int) { // 1, 1, 1, 1, // 1, 0, 1, 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); set_values(input1, { 1.f, 2.5f, 5.f, 1.5f, @@ -266,8 +263,8 @@ TEST(eltwise_gpu_f32, not_equal_in2_float_out1_int) { }); topology topology; - topology.add(input_layout("input", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", {"input", "input2"}, eltwise_mode::ne)); network network(engine, topology); @@ -281,7 +278,7 @@ TEST(eltwise_gpu_f32, not_equal_in2_float_out1_int) { EXPECT_EQ(outputs.begin()->first, "eltwise"); auto output = outputs.at("eltwise").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 1, 0, 1, 0, 1, 1, 0, 1, @@ -316,10 +313,10 @@ TEST(eltwise_gpu_f32, less_in2_float_out1_int) { // 1, 1, 1, 0, // 0, 0, 0, 0 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); set_values(input1, { 1.f, 2.5f, 5.f, 1.5f, @@ -336,8 +333,8 @@ TEST(eltwise_gpu_f32, less_in2_float_out1_int) { }); topology topology; - topology.add(input_layout("input", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", {"input", "input2"}, eltwise_mode::lt)); network network(engine, topology); @@ -351,7 +348,7 @@ TEST(eltwise_gpu_f32, less_in2_float_out1_int) { EXPECT_EQ(outputs.begin()->first, "eltwise"); auto output = outputs.at("eltwise").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 0, 0, 0, 0, 1, 1, 0, 0, @@ -386,10 +383,10 @@ TEST(eltwise_gpu_f32, less_equal_in2_float_out1_int) { // 1, 1, 1, 0, // 0, 1, 0, 0 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); set_values(input1, { 1.f, 2.5f, 5.f, 1.5f, @@ -406,8 +403,8 @@ TEST(eltwise_gpu_f32, less_equal_in2_float_out1_int) { }); topology topology; - topology.add(input_layout("input", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", {"input", "input2"}, eltwise_mode::le)); network network(engine, topology); @@ -421,7 +418,7 @@ TEST(eltwise_gpu_f32, less_equal_in2_float_out1_int) { EXPECT_EQ(outputs.begin()->first, "eltwise"); auto output = outputs.at("eltwise").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 0, 1, 0, 1, 1, 1, 1, 0, @@ -456,10 +453,10 @@ TEST(eltwise_gpu_f32, greater_in2_float_out1_int) { // 0, 0, 0, 1, // 1, 0, 1, 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); set_values(input1, { 1.f, 2.5f, 5.f, 1.5f, @@ -476,8 +473,8 @@ TEST(eltwise_gpu_f32, greater_in2_float_out1_int) { }); topology topology; - topology.add(input_layout("input", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", {"input", "input2"}, eltwise_mode::gt)); network network(engine, topology); @@ -491,7 +488,7 @@ TEST(eltwise_gpu_f32, greater_in2_float_out1_int) { EXPECT_EQ(outputs.begin()->first, "eltwise"); auto output = outputs.at("eltwise").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 1, 0, 1, 0, 0, 0, 0, 1, @@ -526,10 +523,10 @@ TEST(eltwise_gpu_f32, greater_equal_in2_float_out1_int) { // 0, 0, 0, 1, // 1, 1, 1, 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); set_values(input1, { 1.f, 2.5f, 5.f, 1.5f, @@ -546,8 +543,8 @@ TEST(eltwise_gpu_f32, greater_equal_in2_float_out1_int) { }); topology topology; - topology.add(input_layout("input", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", {"input", "input2"}, eltwise_mode::ge)); network network(engine, topology); @@ -561,7 +558,7 @@ TEST(eltwise_gpu_f32, greater_equal_in2_float_out1_int) { EXPECT_EQ(outputs.begin()->first, "eltwise"); auto output = outputs.at("eltwise").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 1, 1, 1, 1, 0, 0, 1, 1, @@ -596,10 +593,10 @@ TEST(eltwise_gpu_f32, logicalAND_in2_float_out1_int) { // 1, 1, 1, 1, // 1, 0, 1, 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); set_values(input1, { 1.f, 2.5f, 5.f, 1.5f, @@ -616,8 +613,8 @@ TEST(eltwise_gpu_f32, logicalAND_in2_float_out1_int) { }); topology topology; - topology.add(input_layout("input", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", {"input", "input2"}, eltwise_mode::logic_and)); network network(engine, topology); @@ -631,7 +628,7 @@ TEST(eltwise_gpu_f32, logicalAND_in2_float_out1_int) { EXPECT_EQ(outputs.begin()->first, "eltwise"); auto output = outputs.at("eltwise").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 1, 1, 1, 1, 1, 0, 1, 1, @@ -673,11 +670,11 @@ TEST(eltwise_gpu_f32, logicalAND_in3_float_out1_int) { // 1, 1, 1, 1, // 1, 0, 1, 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input3 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input3 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); set_values(input1, { 1.f, 2.5f, 5.f, 1.5f, @@ -701,9 +698,9 @@ TEST(eltwise_gpu_f32, logicalAND_in3_float_out1_int) { }); topology topology; - topology.add(input_layout("input", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("input3", input2.get_layout())); + topology.add(input_layout("input", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("input3", input2->get_layout())); topology.add(eltwise("eltwise", {"input", "input2", "input3"}, eltwise_mode::logic_and)); network network(engine, topology); @@ -718,7 +715,7 @@ TEST(eltwise_gpu_f32, logicalAND_in3_float_out1_int) { EXPECT_EQ(outputs.begin()->first, "eltwise"); auto output = outputs.at("eltwise").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 0, 0, 0, 0, 0, 0, 0, 0, @@ -753,10 +750,10 @@ TEST(eltwise_gpu_f32, logicalOR_in2_float_out1_int) { // 1, 1, 1, 1, // 1, 0, 1, 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); set_values(input1, { 1.f, 2.5f, 5.f, 1.5f, @@ -773,8 +770,8 @@ TEST(eltwise_gpu_f32, logicalOR_in2_float_out1_int) { }); topology topology; - topology.add(input_layout("input", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", {"input", "input2"}, eltwise_mode::logic_or)); network network(engine, topology); @@ -788,7 +785,7 @@ TEST(eltwise_gpu_f32, logicalOR_in2_float_out1_int) { EXPECT_EQ(outputs.begin()->first, "eltwise"); auto output = outputs.at("eltwise").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 1, 1, 1, 1, 1, 1, 1, 1, @@ -830,11 +827,11 @@ TEST(eltwise_gpu_f32, logicalOR_in3_float_out1_int) { // 1, 1, 1, 1, // 1, 1, 1, 1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input3 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input3 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); set_values(input1, { 1.f, 2.5f, 5.f, 1.5f, @@ -858,9 +855,9 @@ TEST(eltwise_gpu_f32, logicalOR_in3_float_out1_int) { }); topology topology; - topology.add(input_layout("input", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("input3", input2.get_layout())); + topology.add(input_layout("input", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("input3", input2->get_layout())); topology.add(eltwise("eltwise", {"input", "input2", "input3"}, eltwise_mode::logic_or)); network network(engine, topology); @@ -875,7 +872,7 @@ TEST(eltwise_gpu_f32, logicalOR_in3_float_out1_int) { EXPECT_EQ(outputs.begin()->first, "eltwise"); auto output = outputs.at("eltwise").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 1, 1, 1, 1, 1, 1, 1, 1, @@ -910,10 +907,10 @@ TEST(eltwise_gpu_f32, logicalXOR_in2_float_out1_int) { // 0, 0, 0, 0, // 0, 0, 0, 0 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); set_values(input1, { 1.f, 2.5f, 5.f, 1.5f, @@ -930,8 +927,8 @@ TEST(eltwise_gpu_f32, logicalXOR_in2_float_out1_int) { }); topology topology; - topology.add(input_layout("input", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", {"input", "input2"}, eltwise_mode::logic_xor)); network network(engine, topology); @@ -945,7 +942,7 @@ TEST(eltwise_gpu_f32, logicalXOR_in2_float_out1_int) { EXPECT_EQ(outputs.begin()->first, "eltwise"); auto output = outputs.at("eltwise").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 0, 0, 0, 0, 0, 1, 0, 0, @@ -981,14 +978,14 @@ TEST(eltwise_gpu_f32, add_basic_in4x4x2x2) { // f1: b0: 15 16.5 b1: 22 16.5 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", {"input", "input2"}, eltwise_mode::sum)); set_values(input, { @@ -1020,7 +1017,7 @@ TEST(eltwise_gpu_f32, add_basic_in4x4x2x2) { 18.f,17.5f, 15.f, 22.f, 2.f, 6.f, 7.5f, 5.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -1029,14 +1026,14 @@ TEST(eltwise_gpu_f32, add_basic_in4x4x2x2) { } TEST(eltwise_gpu_f32, add_in2x2x2x2_broadcast_channel) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 1, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 1, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", {"input", "input2"}, eltwise_mode::sum)); set_values(input, { @@ -1083,7 +1080,7 @@ TEST(eltwise_gpu_f32, add_in2x2x2x2_broadcast_channel) { 1.f, 7.f, 3.5f, -3.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -1092,14 +1089,14 @@ TEST(eltwise_gpu_f32, add_in2x2x2x2_broadcast_channel) { } TEST(eltwise_gpu_f32, add_in2x2x2x2_broadcast_x) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", {"input", "input2"}, eltwise_mode::sum)); set_values(input, { @@ -1152,7 +1149,7 @@ TEST(eltwise_gpu_f32, add_in2x2x2x2_broadcast_x) { 2.f, 10.5f, -1.f, -3.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -1161,14 +1158,14 @@ TEST(eltwise_gpu_f32, add_in2x2x2x2_broadcast_x) { } TEST(eltwise_gpu_f32, add_in2x2x2x2_broadcast_y) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", {"input", "input2"}, eltwise_mode::sum)); set_values(input, { @@ -1215,7 +1212,7 @@ TEST(eltwise_gpu_f32, add_in2x2x2x2_broadcast_y) { 1.f, 7.f, 3.5f, -3.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -1224,14 +1221,14 @@ TEST(eltwise_gpu_f32, add_in2x2x2x2_broadcast_y) { } TEST(eltwise_gpu_f32, add_in2x2x2x2_broadcast_batch) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 1 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", {"input", "input2"}, eltwise_mode::sum)); set_values(input, { @@ -1280,7 +1277,7 @@ TEST(eltwise_gpu_f32, add_in2x2x2x2_broadcast_batch) { 2.f, 6.f, 3.5f, -3.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -1289,14 +1286,14 @@ TEST(eltwise_gpu_f32, add_in2x2x2x2_broadcast_batch) { } TEST(eltwise_gpu_f32, add_in2x2x2x2_broadcast_multiple_dims) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", {"input", "input2"}, eltwise_mode::sum)); set_values(input, { @@ -1339,7 +1336,7 @@ TEST(eltwise_gpu_f32, add_in2x2x2x2_broadcast_multiple_dims) { 0.f, 8.5f, 1.5f, -0.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -1348,14 +1345,14 @@ TEST(eltwise_gpu_f32, add_in2x2x2x2_broadcast_multiple_dims) { } TEST(eltwise_gpu_f32, pow_in2x2x2x2_broadcast_all) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", {"input", "input2"}, eltwise_mode::pow)); set_values(input, { @@ -1396,7 +1393,7 @@ TEST(eltwise_gpu_f32, pow_in2x2x2x2_broadcast_all) { 169.f, 196.f, 225.f, 256.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -1405,16 +1402,16 @@ TEST(eltwise_gpu_f32, pow_in2x2x2x2_broadcast_all) { } TEST(eltwise_gpu_f32, add_basic_in2x2x2x2_broadcast_2_inputs_same_dim) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 1 } }); - auto input3 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 1 } }); + auto input3 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 1 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("input3", input3.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("input3", input3->get_layout())); topology.add(eltwise("eltwise", {"input", "input2", "input3"}, eltwise_mode::sum)); set_values(input, { @@ -1474,7 +1471,7 @@ TEST(eltwise_gpu_f32, add_basic_in2x2x2x2_broadcast_2_inputs_same_dim) { -2.f, 6.5f, -0.5f, -2.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -1483,16 +1480,16 @@ TEST(eltwise_gpu_f32, add_basic_in2x2x2x2_broadcast_2_inputs_same_dim) { } TEST(eltwise_gpu_f32, add_basic_in2x2x2x2_broadcast_2_inputs_diff_dim) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 1 } }); - auto input3 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 1 } }); + auto input3 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 1, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("input3", input3.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("input3", input3->get_layout())); topology.add(eltwise("eltwise", {"input", "input2", "input3"}, eltwise_mode::sum)); set_values(input, { @@ -1550,7 +1547,7 @@ TEST(eltwise_gpu_f32, add_basic_in2x2x2x2_broadcast_2_inputs_diff_dim) { 0.f, 7.5f, -0.5f, -2.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -1581,14 +1578,14 @@ TEST(eltwise_gpu_f32, max_basic_in4x4x4x4) { // f1: b0: 5 6 b1: 2.5 5.2 // f1: b0: 8 8 b1: 12 8 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", {"input", "input2"}, eltwise_mode::max)); set_values(input, { @@ -1621,7 +1618,7 @@ TEST(eltwise_gpu_f32, max_basic_in4x4x4x4) { 15.f, 17.f, 8.f, 12.f, 6.f, 8.f, 8.f, 8.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -1653,13 +1650,13 @@ TEST(eltwise_gpu_f32, sub_basic_in4x4x4x4) { // f1: b0: -1 8.5 b1: 3.5 -2.5 // - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", {"input", "input2"}, eltwise_mode::sub)); set_values(input, { @@ -1692,7 +1689,7 @@ TEST(eltwise_gpu_f32, sub_basic_in4x4x4x4) { -12.f, -16.5f, -1.f, 3.5f, -2.f, -8.5f, 8.5f, -2.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -1710,13 +1707,13 @@ TEST(eltwise_gpu_int, basic_in4x4x4x4) { { for (auto& mode : eltwise_ops_to_test) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(reorder("input_reorder", "input", { data_type, format::yxfb,{ 2, 2, 2, 2 } })); topology.add(reorder("input2_reorder", "input2", { data_type, format::yxfb,{ 2, 2, 2, 2 } })); topology.add(eltwise("eltwise", { "input_reorder", "input2_reorder" }, mode)); @@ -1747,7 +1744,7 @@ TEST(eltwise_gpu_int, basic_in4x4x4x4) { auto output = outputs.at("eltwise_reorder").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -1786,13 +1783,13 @@ TEST(eltwise_gpu_f32_int, basic_in4x4x4x4) { { for (auto& mode : eltwise_ops_to_test) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(reorder("input_reorder", "input", { data_type, format::yxfb,{ 2, 2, 2, 2 } })); topology.add(eltwise("eltwise", { "input_reorder", "input2" }, mode)); topology.add(reorder("eltwise_reorder", "eltwise", { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } })); @@ -1822,7 +1819,7 @@ TEST(eltwise_gpu_f32_int, basic_in4x4x4x4) { auto output = outputs.at("eltwise_reorder").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -1872,12 +1869,12 @@ TEST(eltwise_gpu_f32, prod_basic_in4x4x4x4) { // f1: b0: 119 80 b1: 96 -18.75 // - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", {"input", "input2"}, eltwise_mode::prod)); set_values(input, { @@ -1910,7 +1907,7 @@ TEST(eltwise_gpu_f32, prod_basic_in4x4x4x4) { 7.5f, 3.5f, 119.f, 96.0f, 10.0f, -2.0f, 80.f, -18.75f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -1942,16 +1939,16 @@ TEST(eltwise_gpu_f32, max_basic_in4x4x4x4_input_padding) { // f1: b0: 5 6 b1: 2.5 5.2 // f1: b0: 8 8 b1: 12 8 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(reorder("reorder", "input", input.get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 }))); - topology.add(reorder("reorder2", "input2", input.get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 }))); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(reorder("reorder", "input", input->get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 }))); + topology.add(reorder("reorder2", "input2", input->get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 }))); topology.add(eltwise("eltwise", {"reorder", "reorder2"}, eltwise_mode::max)); set_values(input, { @@ -1984,7 +1981,7 @@ TEST(eltwise_gpu_f32, max_basic_in4x4x4x4_input_padding) { 15.f, 17.f, 8.f, 12.f, 6.f, 8.f, 8.f, 8.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -2016,14 +2013,14 @@ TEST(eltwise_gpu_f32, add_basic_in4x4x2x2_with_coefficients) { // f1: b0: 7.5 8.25 b1: 11 8.25 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", {"input", "input2"}, eltwise_mode::sum, {0.5f, 0.5f}, data_types::f32)); set_values(input, { @@ -2055,7 +2052,7 @@ TEST(eltwise_gpu_f32, add_basic_in4x4x2x2_with_coefficients) { 9.f, 8.75f, 7.5f, 11.f, 1.f, 3.f, 3.75f, 2.75f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -2064,16 +2061,16 @@ TEST(eltwise_gpu_f32, add_basic_in4x4x2x2_with_coefficients) { } TEST(eltwise_gpu_f32, coefficients_count_check) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); - auto input3 = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); + auto input3 = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("input3", input3.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("input3", input3->get_layout())); std::vector coeffs0 = {}; std::vector coeffs1 = {0.5f}; @@ -2124,16 +2121,16 @@ TEST(eltwise_gpu_f32, add_basic_in4x4x2x2_with_coefficients_3inputs) { // f1: b0: 8.5 8.75 b1: 11 8.75 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); - auto input3 = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); + auto input3 = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("input3", input3.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("input3", input3->get_layout())); topology.add(eltwise("eltwise", {"input", "input2", "input3"}, eltwise_mode::sum, {0.5f, 0.5f, 0.5f}, data_types::f32)); set_values(input, { @@ -2172,7 +2169,7 @@ TEST(eltwise_gpu_f32, add_basic_in4x4x2x2_with_coefficients_3inputs) { 12.f, 8.75f, 8.5f, 11.f, 3.5f, 3.5f, 4.25f, 3.25f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -2211,19 +2208,19 @@ TEST(eltwise_gpu_f32, max_3inputs_in4x4x4x4_input_padding) { // f1: b0: 5 6 b1: 2.5 7 // f1: b0: 9 8 b1: 12 8 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); - auto input3 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); + auto input3 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("input3", input3.get_layout())); - topology.add(reorder("reorder", "input", input.get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 }))); - topology.add(reorder("reorder2", "input2", input.get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 }))); - topology.add(reorder("reorder3", "input3", input.get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 }))); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("input3", input3->get_layout())); + topology.add(reorder("reorder", "input", input->get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 }))); + topology.add(reorder("reorder2", "input2", input->get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 }))); + topology.add(reorder("reorder3", "input3", input->get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 }))); topology.add(eltwise("eltwise", {"reorder", "reorder2", "reorder3"}, eltwise_mode::max)); set_values(input, { @@ -2263,7 +2260,7 @@ TEST(eltwise_gpu_f32, max_3inputs_in4x4x4x4_input_padding) { 15.f, 17.f, 9.f, 12.f, 6.f, 8.f, 8.f, 8.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -2300,14 +2297,14 @@ TEST(eltwise_gpu_f32, stride_test_2x2) { // f1: b0: 33 35 b1: 49 51 // f1: b0: 41 43 b1: 57 59 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 4, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 4, 4 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", "input", "input2", { {0,0,1,1}, {0,0,2,2} }, eltwise_mode::max)); set_values(input, { @@ -2352,7 +2349,7 @@ TEST(eltwise_gpu_f32, stride_test_2x2) { 9, 25, 41, 57, 11, 27, 43, 59 }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -2382,14 +2379,14 @@ TEST(eltwise_gpu_f32, broadcast_test_in4x4x2x2) { // f1: b0: 15 16.5 b1: 22 16.5 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 1, 1 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", { "input", "input2" }, eltwise_mode::sum)); set_values(input, { @@ -2420,7 +2417,7 @@ TEST(eltwise_gpu_f32, broadcast_test_in4x4x2x2) { 3.5f, 3.f, 7.5f, 14.5f, 4.5f, 2.f, 8.5f, 10.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -2452,23 +2449,23 @@ TEST(eltwise_gpu_f16, fs_b_yx_fsv32_basic) FLOAT16(2211),FLOAT16(2212),FLOAT16(2221),FLOAT16(2222) }; - const auto& engine = get_test_engine(); - bool f16_supported = !!engine.get_info().supports_fp16; + auto& engine = get_test_engine(); + bool f16_supported = engine.get_device_info().supports_fp16; if (!f16_supported) { std::cout << "[ SKIPPED ] float16 combinations are skipped (cl_khr_fp16 is not supported)." << std::endl; return; } - auto input1 = memory::allocate(engine, { data_types::f16,format::bfyx, input_tensor }); - auto input2 = memory::allocate(engine, { data_types::f16,format::bfyx, input_tensor }); + auto input1 = engine.allocate_memory({ data_types::f16,format::bfyx, input_tensor }); + auto input2 = engine.allocate_memory({ data_types::f16,format::bfyx, input_tensor }); set_values(input1, fp16_bfyx_2x2x2x2_input); set_values(input2, fp16_bfyx_2x2x2x2_input); // GOLDEN BFYX ELTWISE topology golden_topology; - golden_topology.add(input_layout("input1", input1.get_layout())); - golden_topology.add(input_layout("input2", input2.get_layout())); + golden_topology.add(input_layout("input1", input1->get_layout())); + golden_topology.add(input_layout("input2", input2->get_layout())); golden_topology.add(eltwise("eltwise", "input1", "input2", eltwise_mode::sum)); network golden_network(engine, golden_topology); @@ -2477,12 +2474,12 @@ TEST(eltwise_gpu_f16, fs_b_yx_fsv32_basic) auto golden_outputs = golden_network.execute(); auto golden_output = golden_outputs.at("eltwise").get_memory(); - auto golden_ptr = golden_output.pointer(); + cldnn::mem_lock golden_ptr(golden_output, get_test_stream()); // GOLDEN BFYX ELTWISE - END // FS_B_YX_FSV32 ELTWISE topology FSV32_topology; - FSV32_topology.add(input_layout("input1", input1.get_layout())); - FSV32_topology.add(input_layout("input2", input2.get_layout())); + FSV32_topology.add(input_layout("input1", input1->get_layout())); + FSV32_topology.add(input_layout("input2", input2->get_layout())); FSV32_topology.add(reorder("reorder1", "input1", layout(data_types::f16, format::fs_b_yx_fsv32, input_tensor))); FSV32_topology.add(reorder("reorder2", "input2", layout(data_types::f16, format::fs_b_yx_fsv32, input_tensor))); FSV32_topology.add(eltwise("eltwise", "reorder1", "reorder2", eltwise_mode::sum)); @@ -2494,13 +2491,12 @@ TEST(eltwise_gpu_f16, fs_b_yx_fsv32_basic) auto FSV32_outputs = FSV32_network.execute(); auto FSV32_output = FSV32_outputs.at("reorderOutput").get_memory(); - auto FSV32_ptr = FSV32_output.pointer(); + cldnn::mem_lock FSV32_ptr(FSV32_output, get_test_stream()); // FS_B_YX_FSV32 ELTWISE - END ASSERT_EQ(golden_ptr.size(), FSV32_ptr.size()); - for (size_t i = 0; i < golden_ptr.size(); i++) - { + for (size_t i = 0; i < golden_ptr.size(); i++) { EXPECT_EQ(float(golden_ptr[i]), float(FSV32_ptr[i])); } } @@ -2510,14 +2506,14 @@ TEST(eltwise_gpu_f32, broadcast_test_in4x4x2x2x2) { // Input2 : 2x2x1x1x2 // Output : 2x2x2x2x2 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 2, 2, 2, 2, 1 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 2, 2, 1, 1, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 2, 2, 2, 2, 1 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 2, 2, 1, 1, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(eltwise("eltwise", { "input", "input2" }, eltwise_mode::sum)); set_values(input, { @@ -2551,7 +2547,7 @@ TEST(eltwise_gpu_f32, broadcast_test_in4x4x2x2x2) { 8.f, 3.5f, 12.f, 12.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 32; i++) { @@ -2567,23 +2563,23 @@ TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_basic) VVVVF input_rnd = generate_random_4d(32, 96, 20, 20, 1, 3); VF fp16_bfyx_32x96x2x2_input = flatten_4d(format::bfyx, input_rnd); - const auto& engine = get_test_engine(); - bool f16_supported = !!engine.get_info().supports_fp16; + auto& engine = get_test_engine(); + bool f16_supported = engine.get_device_info().supports_fp16; if (!f16_supported) { std::cout << "[ SKIPPED ] float16 combinations are skipped (cl_khr_fp16 is not supported)." << std::endl; return; } - auto input1 = memory::allocate(engine, { data_types::f16,format::bfyx, input_tensor }); - auto input2 = memory::allocate(engine, { data_types::f16,format::bfyx, input_tensor }); + auto input1 = engine.allocate_memory({ data_types::f16,format::bfyx, input_tensor }); + auto input2 = engine.allocate_memory({ data_types::f16,format::bfyx, input_tensor }); set_values(input1, fp16_bfyx_32x96x2x2_input); set_values(input2, fp16_bfyx_32x96x2x2_input); // GOLDEN BFYX ELTWISE topology golden_topology; - golden_topology.add(input_layout("input1", input1.get_layout())); - golden_topology.add(input_layout("input2", input2.get_layout())); + golden_topology.add(input_layout("input1", input1->get_layout())); + golden_topology.add(input_layout("input2", input2->get_layout())); golden_topology.add(eltwise("eltwise", "input1", "input2", eltwise_mode::sum)); network golden_network(engine, golden_topology); @@ -2592,12 +2588,12 @@ TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_basic) auto golden_outputs = golden_network.execute(); auto golden_output = golden_outputs.at("eltwise").get_memory(); - auto golden_ptr = golden_output.pointer(); + cldnn::mem_lock golden_ptr(golden_output, get_test_stream()); // GOLDEN BFYX ELTWISE - END // MIXED INPUT, FS_B_YX_FSV32 OUTPUT topology FS_B_YX_FSV32_OUTPUT_topology; - FS_B_YX_FSV32_OUTPUT_topology.add(input_layout("input1", input1.get_layout())); - FS_B_YX_FSV32_OUTPUT_topology.add(input_layout("input2", input2.get_layout())); + FS_B_YX_FSV32_OUTPUT_topology.add(input_layout("input1", input1->get_layout())); + FS_B_YX_FSV32_OUTPUT_topology.add(input_layout("input2", input2->get_layout())); FS_B_YX_FSV32_OUTPUT_topology.add(reorder("reorder1", "input1", layout(data_types::f16, format::fs_b_yx_fsv32, input_tensor))); FS_B_YX_FSV32_OUTPUT_topology.add(reorder("reorder2", "input2", layout(data_types::f16, format::byxf, input_tensor))); FS_B_YX_FSV32_OUTPUT_topology.add(eltwise("eltwise", "reorder1", "reorder2", eltwise_mode::sum)); @@ -2609,12 +2605,12 @@ TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_basic) auto FS_B_YX_FSV32_OUTPUT_outputs = FS_B_YX_FSV32_OUTPUT_network.execute(); auto FS_B_YX_FSV32_OUTPUT_output = FS_B_YX_FSV32_OUTPUT_outputs.at("reorderOutput").get_memory(); - auto FS_B_YX_FSV32_OUTPUT_ptr = FS_B_YX_FSV32_OUTPUT_output.pointer(); + cldnn::mem_lock FS_B_YX_FSV32_OUTPUT_ptr(FS_B_YX_FSV32_OUTPUT_output, get_test_stream()); // MIXED INPUT, FS_B_YX_FSV32 OUTPUT - END // MIXED INPUT, BYXF OUTPUT topology BYXF_OUTPUT_topology; - BYXF_OUTPUT_topology.add(input_layout("input1", input1.get_layout())); - BYXF_OUTPUT_topology.add(input_layout("input2", input2.get_layout())); + BYXF_OUTPUT_topology.add(input_layout("input1", input1->get_layout())); + BYXF_OUTPUT_topology.add(input_layout("input2", input2->get_layout())); BYXF_OUTPUT_topology.add(reorder("reorder1", "input1", layout(data_types::f16, format::byxf, input_tensor))); BYXF_OUTPUT_topology.add(reorder("reorder2", "input2", layout(data_types::f16, format::fs_b_yx_fsv32, input_tensor))); BYXF_OUTPUT_topology.add(eltwise("eltwise", "reorder1", "reorder2", eltwise_mode::sum)); @@ -2626,47 +2622,44 @@ TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_basic) auto BYXF_OUTPUT_outputs = BYXF_OUTPUT_network.execute(); auto BYXF_OUTPUT_output = BYXF_OUTPUT_outputs.at("reorderOutput").get_memory(); - auto BYXF_OUTPUT_ptr = BYXF_OUTPUT_output.pointer(); + cldnn::mem_lock BYXF_OUTPUT_ptr(BYXF_OUTPUT_output, get_test_stream()); // MIXED INPUT, BYXF OUTPUT - END ASSERT_EQ(golden_ptr.size(), FS_B_YX_FSV32_OUTPUT_ptr.size()); ASSERT_EQ(golden_ptr.size(), BYXF_OUTPUT_ptr.size()); - for (size_t i = 0; i < golden_ptr.size(); i++) - { + for (size_t i = 0; i < golden_ptr.size(); i++) { EXPECT_EQ(float(golden_ptr[i]), float(FS_B_YX_FSV32_OUTPUT_ptr[i])); } - for (size_t i = 0; i < golden_ptr.size(); i++) - { + for (size_t i = 0; i < golden_ptr.size(); i++) { EXPECT_EQ(float(golden_ptr[i]), float(BYXF_OUTPUT_ptr[i])); } } -TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_output_padding) -{ +TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_output_padding) { // Inputs are 32x96x2x2 tensor input_tensor(32, 96, 20, 20); VVVVF input_rnd = generate_random_4d(32, 96, 20, 20, 1, 3); VF fp16_bfyx_32x96x2x2_input = flatten_4d(format::bfyx, input_rnd); - const auto& engine = get_test_engine(); - bool f16_supported = !!engine.get_info().supports_fp16; + auto& engine = get_test_engine(); + bool f16_supported = engine.get_device_info().supports_fp16; if (!f16_supported) { std::cout << "[ SKIPPED ] float16 combinations are skipped (cl_khr_fp16 is not supported)." << std::endl; return; } - auto input1 = memory::allocate(engine, { data_types::f16,format::bfyx, input_tensor }); - auto input2 = memory::allocate(engine, { data_types::f16,format::bfyx, input_tensor }); + auto input1 = engine.allocate_memory({ data_types::f16,format::bfyx, input_tensor }); + auto input2 = engine.allocate_memory({ data_types::f16,format::bfyx, input_tensor }); set_values(input1, fp16_bfyx_32x96x2x2_input); set_values(input2, fp16_bfyx_32x96x2x2_input); // GOLDEN BFYX ELTWISE topology golden_topology; - golden_topology.add(input_layout("input1", input1.get_layout())); - golden_topology.add(input_layout("input2", input2.get_layout())); + golden_topology.add(input_layout("input1", input1->get_layout())); + golden_topology.add(input_layout("input2", input2->get_layout())); golden_topology.add(eltwise("eltwise", "input1", "input2", eltwise_mode::sum, padding{ {0,0,5,10} , 0 })); network golden_network(engine, golden_topology); @@ -2675,12 +2668,12 @@ TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_output_padding) auto golden_outputs = golden_network.execute(); auto golden_output = golden_outputs.at("eltwise").get_memory(); - auto golden_ptr = golden_output.pointer(); + cldnn::mem_lock golden_ptr(golden_output, get_test_stream()); // GOLDEN BFYX ELTWISE - END // MIXED INPUT, FS_B_YX_FSV32 OUTPUT topology FS_B_YX_FSV32_OUTPUT_topology; - FS_B_YX_FSV32_OUTPUT_topology.add(input_layout("input1", input1.get_layout())); - FS_B_YX_FSV32_OUTPUT_topology.add(input_layout("input2", input2.get_layout())); + FS_B_YX_FSV32_OUTPUT_topology.add(input_layout("input1", input1->get_layout())); + FS_B_YX_FSV32_OUTPUT_topology.add(input_layout("input2", input2->get_layout())); FS_B_YX_FSV32_OUTPUT_topology.add(reorder("reorder1", "input1", layout(data_types::f16, format::fs_b_yx_fsv32, input_tensor))); FS_B_YX_FSV32_OUTPUT_topology.add(reorder("reorder2", "input2", layout(data_types::f16, format::byxf, input_tensor))); FS_B_YX_FSV32_OUTPUT_topology.add(eltwise("eltwise", "reorder1", "reorder2", eltwise_mode::sum, padding{ {0,0,5,10} , 0 })); @@ -2693,12 +2686,12 @@ TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_output_padding) auto FS_B_YX_FSV32_OUTPUT_outputs = FS_B_YX_FSV32_OUTPUT_network.execute(); auto FS_B_YX_FSV32_OUTPUT_output = FS_B_YX_FSV32_OUTPUT_outputs.at("reorderOutput").get_memory(); - auto FS_B_YX_FSV32_OUTPUT_ptr = FS_B_YX_FSV32_OUTPUT_output.pointer(); + cldnn::mem_lock FS_B_YX_FSV32_OUTPUT_ptr(FS_B_YX_FSV32_OUTPUT_output, get_test_stream()); // MIXED INPUT, FS_B_YX_FSV32 OUTPUT - END // MIXED INPUT, BYXF OUTPUT topology BYXF_OUTPUT_topology; - BYXF_OUTPUT_topology.add(input_layout("input1", input1.get_layout())); - BYXF_OUTPUT_topology.add(input_layout("input2", input2.get_layout())); + BYXF_OUTPUT_topology.add(input_layout("input1", input1->get_layout())); + BYXF_OUTPUT_topology.add(input_layout("input2", input2->get_layout())); BYXF_OUTPUT_topology.add(reorder("reorder1", "input1", layout(data_types::f16, format::byxf, input_tensor))); BYXF_OUTPUT_topology.add(reorder("reorder2", "input2", layout(data_types::f16, format::fs_b_yx_fsv32, input_tensor))); BYXF_OUTPUT_topology.add(eltwise("eltwise", "reorder1", "reorder2", eltwise_mode::sum, padding{ {0,0,5,10} , 0 })); @@ -2711,18 +2704,16 @@ TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_output_padding) auto BYXF_OUTPUT_outputs = BYXF_OUTPUT_network.execute(); auto BYXF_OUTPUT_output = BYXF_OUTPUT_outputs.at("reorderOutput").get_memory(); - auto BYXF_OUTPUT_ptr = BYXF_OUTPUT_output.pointer(); + cldnn::mem_lock BYXF_OUTPUT_ptr(BYXF_OUTPUT_output, get_test_stream()); // MIXED INPUT, BYXF OUTPUT - END ASSERT_EQ(golden_ptr.size(), FS_B_YX_FSV32_OUTPUT_ptr.size()); ASSERT_EQ(golden_ptr.size(), BYXF_OUTPUT_ptr.size()); - for (size_t i = 0; i < golden_ptr.size(); i++) - { + for (size_t i = 0; i < golden_ptr.size(); i++) { EXPECT_EQ(float(golden_ptr[i]), float(FS_B_YX_FSV32_OUTPUT_ptr[i])); } - for (size_t i = 0; i < golden_ptr.size(); i++) - { + for (size_t i = 0; i < golden_ptr.size(); i++) { EXPECT_EQ(float(golden_ptr[i]), float(BYXF_OUTPUT_ptr[i])); } } @@ -2735,23 +2726,23 @@ TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_input_padding) VVVVF input_rnd = generate_random_4d(32, 96, 20, 20, 1, 3); VF fp16_bfyx_32x96x2x2_input = flatten_4d(format::bfyx, input_rnd); - const auto& engine = get_test_engine(); - bool f16_supported = !!engine.get_info().supports_fp16; + auto& engine = get_test_engine(); + bool f16_supported = engine.get_device_info().supports_fp16; if (!f16_supported) { std::cout << "[ SKIPPED ] float16 combinations are skipped (cl_khr_fp16 is not supported)." << std::endl; return; } - auto input1 = memory::allocate(engine, { data_types::f16,format::bfyx, input_tensor }); - auto input2 = memory::allocate(engine, { data_types::f16,format::bfyx, input_tensor }); + auto input1 = engine.allocate_memory({ data_types::f16,format::bfyx, input_tensor }); + auto input2 = engine.allocate_memory({ data_types::f16,format::bfyx, input_tensor }); set_values(input1, fp16_bfyx_32x96x2x2_input); set_values(input2, fp16_bfyx_32x96x2x2_input); // GOLDEN BFYX ELTWISE topology golden_topology; - golden_topology.add(input_layout("input1", input1.get_layout())); - golden_topology.add(input_layout("input2", input2.get_layout())); + golden_topology.add(input_layout("input1", input1->get_layout())); + golden_topology.add(input_layout("input2", input2->get_layout())); golden_topology.add(reorder("reorder1", "input1", layout(data_types::f16, format::bfyx, input_tensor, padding{ {0,0,10,15},0.0f }))); golden_topology.add(reorder("reorder2", "input2", layout(data_types::f16, format::bfyx, input_tensor, padding{ {0,0,5,7},0.0f }))); golden_topology.add(eltwise("eltwise", "input1", "input2", eltwise_mode::sum)); @@ -2762,12 +2753,12 @@ TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_input_padding) auto golden_outputs = golden_network.execute(); auto golden_output = golden_outputs.at("eltwise").get_memory(); - auto golden_ptr = golden_output.pointer(); + cldnn::mem_lock golden_ptr(golden_output, get_test_stream()); // GOLDEN BFYX ELTWISE - END // MIXED INPUT, FS_B_YX_FSV32 OUTPUT topology FS_B_YX_FSV32_OUTPUT_topology; - FS_B_YX_FSV32_OUTPUT_topology.add(input_layout("input1", input1.get_layout())); - FS_B_YX_FSV32_OUTPUT_topology.add(input_layout("input2", input2.get_layout())); + FS_B_YX_FSV32_OUTPUT_topology.add(input_layout("input1", input1->get_layout())); + FS_B_YX_FSV32_OUTPUT_topology.add(input_layout("input2", input2->get_layout())); FS_B_YX_FSV32_OUTPUT_topology.add(reorder("reorder1", "input1", layout(data_types::f16, format::fs_b_yx_fsv32, input_tensor, padding{ {0,0,10,15},0.0f }))); FS_B_YX_FSV32_OUTPUT_topology.add(reorder("reorder2", "input2", layout(data_types::f16, format::byxf, input_tensor, padding{ {0,0,5,7},0.0f }))); FS_B_YX_FSV32_OUTPUT_topology.add(eltwise("eltwise", "reorder1", "reorder2", eltwise_mode::sum)); @@ -2779,12 +2770,12 @@ TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_input_padding) auto FS_B_YX_FSV32_OUTPUT_outputs = FS_B_YX_FSV32_OUTPUT_network.execute(); auto FS_B_YX_FSV32_OUTPUT_output = FS_B_YX_FSV32_OUTPUT_outputs.at("reorderOutput").get_memory(); - auto FS_B_YX_FSV32_OUTPUT_ptr = FS_B_YX_FSV32_OUTPUT_output.pointer(); + cldnn::mem_lock FS_B_YX_FSV32_OUTPUT_ptr(FS_B_YX_FSV32_OUTPUT_output, get_test_stream()); // MIXED INPUT, FS_B_YX_FSV32 OUTPUT - END // MIXED INPUT, BYXF OUTPUT topology BYXF_OUTPUT_topology; - BYXF_OUTPUT_topology.add(input_layout("input1", input1.get_layout())); - BYXF_OUTPUT_topology.add(input_layout("input2", input2.get_layout())); + BYXF_OUTPUT_topology.add(input_layout("input1", input1->get_layout())); + BYXF_OUTPUT_topology.add(input_layout("input2", input2->get_layout())); BYXF_OUTPUT_topology.add(reorder("reorder1", "input1", layout(data_types::f16, format::byxf, input_tensor, padding{ {0,0,10,15},0.0f }))); BYXF_OUTPUT_topology.add(reorder("reorder2", "input2", layout(data_types::f16, format::fs_b_yx_fsv32, input_tensor, padding{ {0,0,5,7},0.0f }))); BYXF_OUTPUT_topology.add(eltwise("eltwise", "reorder1", "reorder2", eltwise_mode::sum)); @@ -2796,7 +2787,7 @@ TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_input_padding) auto BYXF_OUTPUT_outputs = BYXF_OUTPUT_network.execute(); auto BYXF_OUTPUT_output = BYXF_OUTPUT_outputs.at("reorderOutput").get_memory(); - auto BYXF_OUTPUT_ptr = BYXF_OUTPUT_output.pointer(); + cldnn::mem_lock BYXF_OUTPUT_ptr(BYXF_OUTPUT_output, get_test_stream()); // MIXED INPUT, BYXF OUTPUT - END ASSERT_EQ(golden_ptr.size(), FS_B_YX_FSV32_OUTPUT_ptr.size()); @@ -2874,17 +2865,17 @@ void generic_eltwise_bool_test(cldnn::format test_input_fmt, int input_b, int in VF input1_rnd_vec = flatten_4d(test_input_fmt, input1_rnd); VF input2_rnd_vec = flatten_4d(test_input_fmt, input2_rnd); - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); tensor input_tensor( input_b, input_f, input_x, input_y ); - auto input1 = memory::allocate(engine, { type_to_data_type::value, test_input_fmt, input_tensor }); - auto input2 = memory::allocate(engine, { type_to_data_type::value, test_input_fmt, input_tensor }); + auto input1 = engine.allocate_memory({ type_to_data_type::value, test_input_fmt, input_tensor }); + auto input2 = engine.allocate_memory({ type_to_data_type::value, test_input_fmt, input_tensor }); set_values(input1, input1_rnd_vec); set_values(input2, input2_rnd_vec); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(reorder("reorder1", "input1", input1.get_layout().with_padding(padding{{ 0, 0, input_padding_x, input_padding_y }, 0 }))); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(reorder("reorder1", "input1", input1->get_layout().with_padding(padding{{ 0, 0, input_padding_x, input_padding_y }, 0 }))); topology.add(eltwise("eltwise", {"reorder1", "input2"}, mode, padding{ { 0, 0, output_padding_x, output_padding_y }, 0 })); network network(engine, topology); @@ -2895,8 +2886,8 @@ void generic_eltwise_bool_test(cldnn::format test_input_fmt, int input_b, int in EXPECT_EQ(outputs.begin()->first, "eltwise"); auto output_memory = outputs.at("eltwise").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); VVVVF output_cpu = eltwise_bool_reference(input1_rnd, input2_rnd, mode, input_padding_y, input_padding_x, output_padding_y, output_padding_x); EXPECT_EQ(output_layout.format.value, test_input_fmt.value); @@ -2978,8 +2969,8 @@ void run_eltwise_generic_test(cldnn::eltwise_mode mode) cldnn::format test_inputs_fmt = cldnn::format::bfyx; std::pair input_size = { 227, 227 }; - const auto& engine = get_test_engine(); - bool f16_supported = !!engine.get_info().supports_fp16; + auto& engine = get_test_engine(); + bool f16_supported = engine.get_device_info().supports_fp16; if (!f16_supported) { std::cout << "[ SKIPPED ] float16 combinations are skipped (cl_khr_fp16 is not supported)." << std::endl; } @@ -3012,7 +3003,7 @@ TEST(eltwise_gpu, b_fs_yx_fsv4_wo_callib) { const int BATCH = 1; const int in_B = BATCH; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); int in_F = 256; @@ -3027,26 +3018,17 @@ TEST(eltwise_gpu, b_fs_yx_fsv4_wo_callib) { // Mem initialization // This is user data, no kernels here - auto input1 = memory::allocate(engine, - { data_types::i8, - format::bfyx, - { in_B, in_F, in_X, in_Y } }); + auto input1 = engine.allocate_memory({ data_types::i8, format::bfyx, { in_B, in_F, in_X, in_Y } }); std::vector data_i1(DataGold); for (size_t i = 0; i < data_i1.size(); i++) data_i1[i] = data_i1[i] + 1; set_values(input1, std::move(data_i1)); - auto input2 = memory::allocate(engine, - { data_types::i8, - format::bfyx, - { in_B, in_F, in_X, in_Y } }); + auto input2 = engine.allocate_memory({ data_types::i8, format::bfyx, { in_B, in_F, in_X, in_Y } }); std::vector data_i2(DataGold); for (size_t i = 0; i < data_i2.size(); i++) data_i2[i] = data_i2[i] + 2; set_values(input2, std::move(data_i2)); - auto input3 = memory::allocate(engine, - { data_types::i8, - format::bfyx, - { in_B, in_F, in_X, in_Y } }); + auto input3 = engine.allocate_memory({ data_types::i8, format::bfyx, { in_B, in_F, in_X, in_Y } }); std::vector data_i3(DataGold); for (size_t i = 0; i < data_i3.size(); i++) data_i3[i] = data_i3[i] + 3; set_values(input3, std::move(data_i3)); @@ -3070,9 +3052,9 @@ TEST(eltwise_gpu, b_fs_yx_fsv4_wo_callib) { auto actv = activation("eltw_GOLD", eltw, activation_func::relu); // Create a topology - topology.add(input_layout("input1", input1.get_layout()), - input_layout("input2", input2.get_layout()), - input_layout("input3", input3.get_layout()), + topology.add(input_layout("input1", input1->get_layout()), + input_layout("input2", input2->get_layout()), + input_layout("input3", input3->get_layout()), eltw, actv); // Network processing @@ -3086,7 +3068,7 @@ TEST(eltwise_gpu, b_fs_yx_fsv4_wo_callib) { auto searchC = outputs.find("eltw_GOLD"); EXPECT_NE(searchC, outputs.end()); auto output = outputs.begin()->second.get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); vGoldOutput.reserve(output_ptr.size()); for (size_t i = 0; i < output_ptr.size(); i++) vGoldOutput.push_back(output_ptr[i]); @@ -3119,9 +3101,9 @@ TEST(eltwise_gpu, b_fs_yx_fsv4_wo_callib) { "reorder3_Swizzelled" }, mode[i]); auto actv = activation("eltw_IMAD", eltw, activation_func::relu); - topology.add(input_layout("input1", input1.get_layout()), - input_layout("input2", input2.get_layout()), - input_layout("input3", input3.get_layout()), + topology.add(input_layout("input1", input1->get_layout()), + input_layout("input2", input2->get_layout()), + input_layout("input3", input3->get_layout()), eltw, actv); // Back reordering (a-ka unswizzelling) output from MMAD/IMAD pooling @@ -3142,7 +3124,7 @@ TEST(eltwise_gpu, b_fs_yx_fsv4_wo_callib) { auto searchC = outputs.find("reorder_UnSwizzelled"); EXPECT_NE(searchC, outputs.end()); auto output = outputs.begin()->second.get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); vTestOutput.reserve(output_ptr.size()); for (size_t i = 0; i < output_ptr.size(); i++) vTestOutput.push_back(output_ptr[i]); @@ -3162,8 +3144,8 @@ TEST(DISABLED_eltwise_gpu, generic_random) { VF slopes = { 0.0f, -0.0f, -17.19f, 1028.8f, std::numeric_limits::infinity(), -std::numeric_limits::infinity() }; std::vector> input_sizes = { { 100, 100 },{ 227, 227 },{ 400, 600 } }; - const auto& engine = get_test_engine(); - bool f16_supported = !!engine.get_info().supports_fp16; + auto& engine = get_test_engine(); + bool f16_supported = engine.get_device_info().supports_fp16; if (!f16_supported) { std::cout << "[ SKIPPED ] float16 combinations are skipped (cl_khr_fp16 is not supported)." << std::endl; } @@ -3207,21 +3189,21 @@ struct eltwise_same_input_test_params { struct eltwise_same_input_test : testing::TestWithParam { template - void fill_random_typed(memory& mem, int min, int max, int k) { - auto size = mem.get_layout().size; + void fill_random_typed(memory::ptr mem, int min, int max, int k) { + auto size = mem->get_layout().size; size_t b = size.batch[0]; size_t f = size.feature[0]; size_t x = size.spatial[0]; size_t y = size.spatial[1]; auto data = generate_random_4d(b, f, y, x, min, max, k); - auto ptr = mem.pointer(); + mem_lock ptr{mem, get_test_stream()}; for (size_t bi = 0; bi < b; ++bi) { for (size_t fi = 0; fi < f; ++fi) { for (size_t yi = 0; yi < y; ++yi) { for (size_t xi = 0; xi < x; ++xi) { auto coords = tensor(batch(bi), feature(fi), spatial(xi, yi, 0, 0)); - auto offset = mem.get_layout().get_linear_offset(coords); + auto offset = mem->get_layout().get_linear_offset(coords); ptr[offset] = data[bi][fi][yi][xi]; } } @@ -3229,8 +3211,8 @@ struct eltwise_same_input_test : testing::TestWithParamget_layout().data_type; switch (dt) { case data_types::f32: fill_random_typed(mem, -127, 127, 2); @@ -3250,16 +3232,16 @@ struct eltwise_same_input_test : testing::TestWithParam - bool compare_outputs(const memory& out_ref, const memory& input_ref) { - auto output_lay = out_ref.get_layout(); - auto opt_output_lay = input_ref.get_layout(); + bool compare_outputs(const memory::ptr out_ref, const memory::ptr input_ref) { + auto output_lay = out_ref->get_layout(); + auto opt_output_lay = input_ref->get_layout(); size_t b = output_lay.size.batch[0]; size_t f = output_lay.size.feature[0]; size_t x = output_lay.size.spatial[0]; size_t y = output_lay.size.spatial[1]; - auto ref_ptr = out_ref.pointer(); - auto input_ptr = input_ref.pointer(); + mem_lock ref_ptr{out_ref, get_test_stream()}; + mem_lock input_ptr{input_ref, get_test_stream()}; for (size_t bi = 0; bi < b; ++bi) { for (size_t fi = 0; fi < f; ++fi) { for (size_t yi = 0; yi < y; ++yi) { @@ -3282,22 +3264,22 @@ struct eltwise_same_input_test : testing::TestWithParamget_layout())); + topo.add(input_layout("input2", input->get_layout())); auto prim = eltwise("eltwise", {"input1", "input2"}, eltwise_mode::sum); topo.add(prim); auto build_ops = build_options(); build_ops.set_option(build_option::outputs({"eltwise"})); - auto net = network(eng, topo, build_ops); + auto net = network(engine, topo, build_ops); net.set_input_data("input1", input); net.set_input_data("input2", input); @@ -3437,21 +3419,21 @@ TEST_P(eltwise_test, fsv16) { VF input1_rnd_vec = flatten_6d(format::bfwzyx, input1_rnd); VF input2_rnd_vec = flatten_6d(format::bfwzyx, input2_rnd); - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto fmt_pln = input0_size.size() == 4 ? format::bfyx : format::bfzyx; auto fmt_fsv16 = input0_size.size() == 4 ? format::b_fs_yx_fsv16 : format::b_fs_zyx_fsv16; auto in0_size = tensor(fmt_pln, input0_size); auto in1_size = tensor(fmt_pln, input1_size); - auto input1 = memory::allocate(engine, { data_types::f32, fmt_pln, in0_size }); - auto input2 = memory::allocate(engine, { data_types::f32, fmt_pln, in1_size }); + auto input1 = engine.allocate_memory({ data_types::f32, fmt_pln, in0_size }); + auto input2 = engine.allocate_memory({ data_types::f32, fmt_pln, in1_size }); set_values(input1, input1_rnd_vec); set_values(input2, input2_rnd_vec); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(reorder("reorder1", "input1", fmt_fsv16, dt)); topology.add(reorder("reorder2", "input2", fmt_fsv16, dt)); topology.add(eltwise("eltwise", {"reorder1", "reorder2"}, mode)); @@ -3469,7 +3451,7 @@ TEST_P(eltwise_test, fsv16) { EXPECT_EQ(outputs.begin()->first, out_id); auto output_memory = outputs.at(out_id).get_memory(); - auto output_ptr = output_memory.pointer(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); VF output_cpu_vec = eltwise_ref(input1_rnd, input2_rnd, in0_size, in1_size, mode); for (size_t i = 0; i < output_cpu_vec.size(); ++i) { @@ -3549,15 +3531,15 @@ TEST_P(eltwise_test_6d, bfwzyx) { auto in0_size = tensor(format::bfwzyx, input0_size); auto in1_size = tensor(format::bfwzyx, input1_size); - const auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfwzyx, in0_size }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfwzyx, in1_size }); + auto& engine = get_test_engine(); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfwzyx, in0_size }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfwzyx, in1_size }); set_values(input1, input1_rnd_vec); set_values(input2, input2_rnd_vec); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(reorder("reorder1", "input1", format::bfwzyx, dt)); topology.add(reorder("reorder2", "input2", format::bfwzyx, dt)); topology.add(eltwise("eltwise", {"reorder1", "reorder2"}, mode)); @@ -3575,7 +3557,7 @@ TEST_P(eltwise_test_6d, bfwzyx) { EXPECT_EQ(outputs.begin()->first, out_id); auto output_memory = outputs.at(out_id).get_memory(); - auto output_ptr = output_memory.pointer(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); VF output_cpu_vec = eltwise_ref(input1_rnd, input2_rnd, in0_size, in1_size, mode); for (size_t i = 0; i < output_cpu_vec.size(); ++i) { @@ -3628,21 +3610,21 @@ TEST_P(eltwise_test_mixed_precision, fsv16) { VF input1_rnd_vec = flatten_6d(format::bfwzyx, input1_rnd); VF input2_rnd_vec = flatten_6d(format::bfwzyx, input2_rnd); - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto fmt_pln = input0_size.size() == 4 ? format::bfyx : format::bfzyx; auto fmt_fsv16 = input0_size.size() == 4 ? format::b_fs_yx_fsv16 : format::b_fs_zyx_fsv16; auto in0_size = tensor(fmt_pln, input0_size); auto in1_size = tensor(fmt_pln, input1_size); - auto input1 = memory::allocate(engine, { data_types::f32, fmt_pln, in0_size }); - auto input2 = memory::allocate(engine, { data_types::i32, fmt_pln, in1_size }); + auto input1 = engine.allocate_memory({ data_types::f32, fmt_pln, in0_size }); + auto input2 = engine.allocate_memory({ data_types::i32, fmt_pln, in1_size }); set_values(input1, input1_rnd_vec); set_values(input2, input2_rnd_vec); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(reorder("reorder1", "input1", fmt_fsv16, input0_dt)); topology.add(reorder("reorder2", "input2", fmt_fsv16, input1_dt)); topology.add(eltwise("eltwise", {"reorder1", "reorder2"}, mode)); @@ -3660,7 +3642,7 @@ TEST_P(eltwise_test_mixed_precision, fsv16) { EXPECT_EQ(outputs.begin()->first, out_id); auto output_memory = outputs.at(out_id).get_memory(); - auto output_ptr = output_memory.pointer(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); VF output_cpu_vec = eltwise_ref(input1_rnd, input2_rnd, in0_size, in1_size, mode); for (size_t i = 0; i < output_cpu_vec.size(); ++i) { @@ -3728,18 +3710,18 @@ TEST_P(eltwise_test_mixed_layout, mixed_layout) { VF input1_rnd_vec = flatten_6d(format::bfwzyx, input1_rnd); VF input2_rnd_vec = flatten_6d(format::bfwzyx, input2_rnd); - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto in0_size = tensor(format::bfyx, input0_size); auto in1_size = tensor(format::bfyx, input1_size); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, in0_size }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, in1_size }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, in0_size }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, in1_size }); set_values(input1, input1_rnd_vec); set_values(input2, input2_rnd_vec); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); topology.add(reorder("reorder1", "input1", format0, data_types::f32)); topology.add(reorder("reorder2", "input2", format1, data_types::f32)); topology.add(eltwise("eltwise", {"reorder1", "reorder2"}, mode)); @@ -3757,7 +3739,7 @@ TEST_P(eltwise_test_mixed_layout, mixed_layout) { EXPECT_TRUE(network.get_primitive_info("eltwise").find(selected_kernel) != std::string::npos); auto output_memory = outputs.at(out_id).get_memory(); - auto output_ptr = output_memory.pointer(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); VF output_cpu_vec = eltwise_ref(input1_rnd, input2_rnd, in0_size, in1_size, mode); for (size_t i = 0; i < output_cpu_vec.size(); ++i) { @@ -3794,21 +3776,21 @@ struct eltwise_random_test_params { struct eltwise_random_test : testing::TestWithParam { template - void fill_random_typed(memory& mem, int min, int max, int k) { - auto size = mem.get_layout().size; + void fill_random_typed(memory::ptr mem, int min, int max, int k) { + auto size = mem->get_layout().size; size_t b = size.batch[0]; size_t f = size.feature[0]; size_t x = size.spatial[0]; size_t y = size.spatial[1]; auto data = generate_random_4d(b, f, y, x, min, max, k); - auto ptr = mem.pointer(); + mem_lock ptr{mem, get_test_stream()}; for (size_t bi = 0; bi < b; ++bi) { for (size_t fi = 0; fi < f; ++fi) { for (size_t yi = 0; yi < y; ++yi) { for (size_t xi = 0; xi < x; ++xi) { auto coords = tensor(batch(bi), feature(fi), spatial(xi, yi, 0, 0)); - auto offset = mem.get_layout().get_linear_offset(coords); + auto offset = mem->get_layout().get_linear_offset(coords); ptr[offset] = data[bi][fi][yi][xi]; } } @@ -3816,8 +3798,8 @@ struct eltwise_random_test : testing::TestWithParam } } - void fill_random(memory& mem) { - auto dt = mem.get_layout().data_type; + void fill_random(memory::ptr mem) { + auto dt = mem->get_layout().data_type; switch (dt) { case data_types::f32: fill_random_typed(mem, -127, 127, 2); @@ -3837,16 +3819,16 @@ struct eltwise_random_test : testing::TestWithParam } template - bool compare_outputs(const memory& out_ref, const memory& out_opt) { - auto output_lay = out_ref.get_layout(); - auto opt_output_lay = out_opt.get_layout(); + bool compare_outputs(const memory::ptr out_ref, const memory::ptr out_opt) { + auto output_lay = out_ref->get_layout(); + auto opt_output_lay = out_opt->get_layout(); size_t b = output_lay.size.batch[0]; size_t f = output_lay.size.feature[0]; size_t x = output_lay.size.spatial[0]; size_t y = output_lay.size.spatial[1]; - auto ref_ptr = out_ref.pointer(); - auto opt_ptr = out_opt.pointer(); + mem_lock ref_ptr{out_ref, get_test_stream()}; + mem_lock opt_ptr{out_opt, get_test_stream()}; for (size_t bi = 0; bi < b; ++bi) { for (size_t fi = 0; fi < f; ++fi) { for (size_t yi = 0; yi < y; ++yi) { @@ -3869,18 +3851,18 @@ struct eltwise_random_test : testing::TestWithParam } void execute_compare(const eltwise_random_test_params& params, bool check_result) { - auto eng = cldnn::engine(); + auto& engine = get_test_engine(); auto in_layout1 = layout(params.input_type, params.in_format, params.first_input_size); auto in_layout2 = layout(params.input_type, params.in_format_second, params.second_input_size); - auto input1 = memory::allocate(eng, in_layout1); - auto input2 = memory::allocate(eng, in_layout2); + auto input1 = engine.allocate_memory(in_layout1); + auto input2 = engine.allocate_memory(in_layout2); fill_random(input1); fill_random(input2); cldnn::topology topo; - topo.add(input_layout("input1", input1.get_layout())); - topo.add(input_layout("input2", input2.get_layout())); + topo.add(input_layout("input1", input1->get_layout())); + topo.add(input_layout("input2", input2->get_layout())); auto prim = eltwise("eltwise", {"input1", "input2"}, params.mode); topo.add(prim); @@ -3888,26 +3870,23 @@ struct eltwise_random_test : testing::TestWithParam build_ops.set_option(build_option::outputs({"eltwise"})); build_ops.set_option(build_option::force_implementations({ {"eltwise", {params.in_format, "generic_eltwise_ref"}} })); - auto net = network(eng, topo, build_ops); + auto net = network(engine, topo, build_ops); net.set_input_data("input1", input1); net.set_input_data("input2", input2); auto result = net.execute(); auto output = result.at("eltwise").get_memory(); - // Execute optimized eltwise 'eltwise_opt' - auto eng_opt = cldnn::engine(); - cldnn::topology topo_opt; - topo_opt.add(input_layout("input1", input1.get_layout())); - topo_opt.add(input_layout("input2", input2.get_layout())); + topo_opt.add(input_layout("input1", input1->get_layout())); + topo_opt.add(input_layout("input2", input2->get_layout())); auto prim_opt = eltwise("eltwise_opt", {"input1", "input2"}, params.mode); topo_opt.add(prim_opt); auto buildops_opt = build_options(); buildops_opt.set_option(build_option::outputs({"eltwise_opt"})); - auto net_opt = network(eng_opt, topo_opt, buildops_opt); + auto net_opt = network(engine, topo_opt, buildops_opt); net_opt.set_input_data("input1", input1); net_opt.set_input_data("input2", input2); @@ -3970,4 +3949,4 @@ INSTANTIATE_TEST_CASE_P(eltwise_smoke_fsv4, .simple_params(data_types::f16, format::b_fs_yx_fsv4, format::b_fs_yx_fsv4) .simple_params(data_types::i8, format::b_fs_yx_fsv4, format::b_fs_yx_fsv4) .simple_params(data_types::u8, format::b_fs_yx_fsv4, format::b_fs_yx_fsv4) - ), ); \ No newline at end of file + ), ); diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/embedding_bag_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/embedding_bag_gpu_test.cpp index 531e290461dce5..b5be9527e6010d 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/embedding_bag_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/embedding_bag_gpu_test.cpp @@ -3,17 +3,14 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include -#include -#include -#include +#include "test_utils.h" + +#include +#include +#include #include -#include using namespace cldnn; using namespace ::tests; @@ -24,11 +21,11 @@ TEST(embedding_bag_fp16_gpu, packed_sum_basic) { // per_sample_weights : 3x2 // Output : 3x2 // Input values in fp16 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto emb_table = memory::allocate(engine, { data_types::f16, format::bfyx, { 5, 2, 1, 1 } }); - auto indices = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 2, 1, 1 } }); - auto per_sample_weights = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 2, 1, 1 } }); + auto emb_table = engine.allocate_memory({ data_types::f16, format::bfyx, { 5, 2, 1, 1 } }); + auto indices = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 2, 1, 1 } }); + auto per_sample_weights = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 2, 1, 1 } }); tensor output_shape = {3, 2, 1, 1}; set_values(emb_table, { @@ -51,8 +48,8 @@ TEST(embedding_bag_fp16_gpu, packed_sum_basic) { auto type = embedding_bag::packed_sum; topology topology; - topology.add(input_layout("Input0", emb_table.get_layout())); - topology.add(input_layout("Input1", indices.get_layout())); + topology.add(input_layout("Input0", emb_table->get_layout())); + topology.add(input_layout("Input1", indices->get_layout())); topology.add(data("Input2", per_sample_weights)); topology.add( embedding_bag("embedding_bag", {"Input0", "Input1", "Input2"}, type, output_shape) @@ -66,7 +63,7 @@ TEST(embedding_bag_fp16_gpu, packed_sum_basic) { auto outputs = network.execute(); auto output = outputs.at("embedding_bag").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { -1.05f, -1.2f, @@ -84,10 +81,10 @@ TEST(embedding_bag_fp16_gpu, packed_sum_basic_without_weights) { // indices : 3x2 // Output : 3x2 // Input values in fp16 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto emb_table = memory::allocate(engine, { data_types::f16, format::bfyx, { 5, 2, 1, 1 } }); - auto indices = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 2, 1, 1 } }); + auto emb_table = engine.allocate_memory({ data_types::f16, format::bfyx, { 5, 2, 1, 1 } }); + auto indices = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 2, 1, 1 } }); tensor output_shape = {3, 2, 1, 1}; set_values(emb_table, { @@ -105,8 +102,8 @@ TEST(embedding_bag_fp16_gpu, packed_sum_basic_without_weights) { auto type = embedding_bag::packed_sum; topology topology; - topology.add(input_layout("Input0", emb_table.get_layout())); - topology.add(input_layout("Input1", indices.get_layout())); + topology.add(input_layout("Input0", emb_table->get_layout())); + topology.add(input_layout("Input1", indices->get_layout())); topology.add( embedding_bag("embedding_bag", {"Input0", "Input1"}, type, output_shape) ); @@ -119,7 +116,7 @@ TEST(embedding_bag_fp16_gpu, packed_sum_basic_without_weights) { auto outputs = network.execute(); auto output = outputs.at("embedding_bag").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { -2.1f, -2.4f, @@ -139,11 +136,11 @@ TEST(embedding_bag_fp16_gpu, packed_sum_dim2) { // Output : 3x2x2 // Input values in fp16 // Input values in fp16 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto emb_table = memory::allocate(engine, { data_types::f16, format::bfyx, { 5, 2, 2, 1 } }); - auto indices = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 2, 1, 1 } }); - auto per_sample_weights = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 2, 1, 1 } }); + auto emb_table = engine.allocate_memory({ data_types::f16, format::bfyx, { 5, 2, 2, 1 } }); + auto indices = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 2, 1, 1 } }); + auto per_sample_weights = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 2, 1, 1 } }); tensor output_shape = {3, 2, 2, 1}; /* @@ -185,8 +182,8 @@ TEST(embedding_bag_fp16_gpu, packed_sum_dim2) { auto type = embedding_bag::packed_sum; topology topology; - topology.add(input_layout("Input0", emb_table.get_layout())); - topology.add(input_layout("Input1", indices.get_layout())); + topology.add(input_layout("Input0", emb_table->get_layout())); + topology.add(input_layout("Input1", indices->get_layout())); topology.add(data("Input2", per_sample_weights)); topology.add( embedding_bag("embedding_bag", {"Input0", "Input1", "Input2"}, type, output_shape) @@ -200,7 +197,7 @@ TEST(embedding_bag_fp16_gpu, packed_sum_dim2) { auto outputs = network.execute(); auto output = outputs.at("embedding_bag").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); /* * [ 3 @@ -232,11 +229,11 @@ TEST(embedding_bag_fp16_gpu, packed_sum_dim3) { // per_sample_weights : 3x2 // Output : 3x2x3x2 // Input values in fp16 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto emb_table = memory::allocate(engine, { data_types::f16, format::bfyx, { 5, 2, 3, 2 } }); - auto indices = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 2, 1, 1 } }); - auto per_sample_weights = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 2, 1, 1 } }); + auto emb_table = engine.allocate_memory({ data_types::f16, format::bfyx, { 5, 2, 3, 2 } }); + auto indices = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 2, 1, 1 } }); + auto per_sample_weights = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 2, 1, 1 } }); tensor output_shape = {3, 2, 3, 2}; /* @@ -308,8 +305,8 @@ TEST(embedding_bag_fp16_gpu, packed_sum_dim3) { auto type = embedding_bag::packed_sum; topology topology; - topology.add(input_layout("Input0", emb_table.get_layout())); - topology.add(input_layout("Input1", indices.get_layout())); + topology.add(input_layout("Input0", emb_table->get_layout())); + topology.add(input_layout("Input1", indices->get_layout())); topology.add(data("Input2", per_sample_weights)); topology.add( embedding_bag("embedding_bag", {"Input0", "Input1", "Input2"}, type, output_shape) @@ -323,7 +320,7 @@ TEST(embedding_bag_fp16_gpu, packed_sum_dim3) { auto outputs = network.execute(); auto output = outputs.at("embedding_bag").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); /* * [ 3 @@ -375,12 +372,12 @@ TEST(embedding_bag_fp16_gpu, offsets_sum_basic) { // default_index : 1x1 // Output : 3x2 // Input values in fp16 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto emb_table = memory::allocate(engine, { data_types::f16, format::bfyx, { 5, 2, 1, 1 } }); - auto indices = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto offsets = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); - auto per_sample_weights = memory::allocate(engine, { data_types::f16, format::bfyx, { 4, 1, 1, 1 } }); + auto emb_table = engine.allocate_memory({ data_types::f16, format::bfyx, { 5, 2, 1, 1 } }); + auto indices = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto offsets = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); + auto per_sample_weights = engine.allocate_memory({ data_types::f16, format::bfyx, { 4, 1, 1, 1 } }); tensor output_shape = {3, 2, 1, 1}; set_values(emb_table, { @@ -402,9 +399,9 @@ TEST(embedding_bag_fp16_gpu, offsets_sum_basic) { auto type = embedding_bag::offsets_sum; topology topology; - topology.add(input_layout("Input0", emb_table.get_layout())); - topology.add(input_layout("Input1", indices.get_layout())); - topology.add(input_layout("Input2", offsets.get_layout())); + topology.add(input_layout("Input0", emb_table->get_layout())); + topology.add(input_layout("Input1", indices->get_layout())); + topology.add(input_layout("Input2", offsets->get_layout())); topology.add(data("Input3", per_sample_weights)); topology.add( embedding_bag("embedding_bag", {"Input0", "Input1", "Input2", "Input3"}, type, output_shape, 0) @@ -418,7 +415,7 @@ TEST(embedding_bag_fp16_gpu, offsets_sum_basic) { auto outputs = network.execute(); auto output = outputs.at("embedding_bag").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { -1.05f, -1.2f, @@ -439,12 +436,12 @@ TEST(embedding_bag_fp16_gpu, offsets_sum_basic_first_empty) { // default_index : 1x1 // Output : 3x2 // Input values in fp16 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto emb_table = memory::allocate(engine, { data_types::f16, format::bfyx, { 5, 2, 1, 1 } }); - auto indices = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto offsets = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); - auto per_sample_weights = memory::allocate(engine, { data_types::f16, format::bfyx, { 4, 1, 1, 1 } }); + auto emb_table = engine.allocate_memory({ data_types::f16, format::bfyx, { 5, 2, 1, 1 } }); + auto indices = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto offsets = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); + auto per_sample_weights = engine.allocate_memory({ data_types::f16, format::bfyx, { 4, 1, 1, 1 } }); tensor output_shape = {3, 2, 1, 1}; set_values(emb_table, { @@ -466,9 +463,9 @@ TEST(embedding_bag_fp16_gpu, offsets_sum_basic_first_empty) { auto type = embedding_bag::offsets_sum; topology topology; - topology.add(input_layout("Input0", emb_table.get_layout())); - topology.add(input_layout("Input1", indices.get_layout())); - topology.add(input_layout("Input2", offsets.get_layout())); + topology.add(input_layout("Input0", emb_table->get_layout())); + topology.add(input_layout("Input1", indices->get_layout())); + topology.add(input_layout("Input2", offsets->get_layout())); topology.add(data("Input3", per_sample_weights)); topology.add( embedding_bag("embedding_bag", {"Input0", "Input1", "Input2", "Input3"}, type, output_shape, 2) @@ -483,7 +480,7 @@ TEST(embedding_bag_fp16_gpu, offsets_sum_basic_first_empty) { auto outputs = network.execute(); auto output = outputs.at("embedding_bag").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { -1.9f, -1.8f, @@ -504,12 +501,12 @@ TEST(embedding_bag_fp16_gpu, offsets_sum_basic_last_empty) { // default_index : 1x1 // Output : 3x2 // Input values in fp16 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto emb_table = memory::allocate(engine, { data_types::f16, format::bfyx, { 5, 2, 1, 1 } }); - auto indices = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto offsets = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); - auto per_sample_weights = memory::allocate(engine, { data_types::f16, format::bfyx, { 4, 1, 1, 1 } }); + auto emb_table = engine.allocate_memory({ data_types::f16, format::bfyx, { 5, 2, 1, 1 } }); + auto indices = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto offsets = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); + auto per_sample_weights = engine.allocate_memory({ data_types::f16, format::bfyx, { 4, 1, 1, 1 } }); tensor output_shape = {3, 2, 1, 1}; set_values(emb_table, { @@ -531,9 +528,9 @@ TEST(embedding_bag_fp16_gpu, offsets_sum_basic_last_empty) { auto type = embedding_bag::offsets_sum; topology topology; - topology.add(input_layout("Input0", emb_table.get_layout())); - topology.add(input_layout("Input1", indices.get_layout())); - topology.add(input_layout("Input2", offsets.get_layout())); + topology.add(input_layout("Input0", emb_table->get_layout())); + topology.add(input_layout("Input1", indices->get_layout())); + topology.add(input_layout("Input2", offsets->get_layout())); topology.add(data("Input3", per_sample_weights)); topology.add( embedding_bag("embedding_bag", {"Input0", "Input1", "Input2", "Input3"}, type, output_shape, 2) @@ -548,7 +545,7 @@ TEST(embedding_bag_fp16_gpu, offsets_sum_basic_last_empty) { auto outputs = network.execute(); auto output = outputs.at("embedding_bag").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { -1.05f, -1.2f, @@ -567,11 +564,11 @@ TEST(embedding_bag_fp16_gpu, offsets_sum_without_weights_and_def_index) { // offsets : 3x1 // Output : 3x2 // Input values in fp16 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto emb_table = memory::allocate(engine, { data_types::f16, format::bfyx, { 5, 2, 1, 1 } }); - auto indices = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto offsets = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); + auto emb_table = engine.allocate_memory({ data_types::f16, format::bfyx, { 5, 2, 1, 1 } }); + auto indices = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto offsets = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); tensor output_shape = {3, 2, 1, 1}; set_values(emb_table, { @@ -590,9 +587,9 @@ TEST(embedding_bag_fp16_gpu, offsets_sum_without_weights_and_def_index) { auto type = embedding_bag::offsets_sum; topology topology; - topology.add(input_layout("Input0", emb_table.get_layout())); - topology.add(input_layout("Input1", indices.get_layout())); - topology.add(input_layout("Input2", offsets.get_layout())); + topology.add(input_layout("Input0", emb_table->get_layout())); + topology.add(input_layout("Input1", indices->get_layout())); + topology.add(input_layout("Input2", offsets->get_layout())); topology.add( embedding_bag("embedding_bag", {"Input0", "Input1", "Input2"}, type, output_shape) ); @@ -606,7 +603,7 @@ TEST(embedding_bag_fp16_gpu, offsets_sum_without_weights_and_def_index) { auto outputs = network.execute(); auto output = outputs.at("embedding_bag").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { -2.1f, -2.4f, @@ -627,12 +624,12 @@ TEST(embedding_bag_fp16_gpu, offsets_sum_dim3) { // default_index : 1x1 // Output : 3x2x3x2 // Input values in fp16 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto emb_table = memory::allocate(engine, { data_types::f16, format::bfyx, { 5, 2, 3, 2 } }); - auto indices = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto offsets = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); - auto per_sample_weights = memory::allocate(engine, { data_types::f16, format::bfyx, { 4, 1, 1, 1 } }); + auto emb_table = engine.allocate_memory({ data_types::f16, format::bfyx, { 5, 2, 3, 2 } }); + auto indices = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto offsets = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); + auto per_sample_weights = engine.allocate_memory({ data_types::f16, format::bfyx, { 4, 1, 1, 1 } }); tensor output_shape = {3, 2, 3, 2}; /* @@ -704,9 +701,9 @@ TEST(embedding_bag_fp16_gpu, offsets_sum_dim3) { auto type = embedding_bag::offsets_sum; topology topology; - topology.add(input_layout("Input0", emb_table.get_layout())); - topology.add(input_layout("Input1", indices.get_layout())); - topology.add(input_layout("Input2", offsets.get_layout())); + topology.add(input_layout("Input0", emb_table->get_layout())); + topology.add(input_layout("Input1", indices->get_layout())); + topology.add(input_layout("Input2", offsets->get_layout())); topology.add(data("Input3", per_sample_weights)); topology.add( embedding_bag("embedding_bag", {"Input0", "Input1", "Input2", "Input3"}, type, output_shape, 0) @@ -721,7 +718,7 @@ TEST(embedding_bag_fp16_gpu, offsets_sum_dim3) { auto outputs = network.execute(); auto output = outputs.at("embedding_bag").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); /* * [ 3 @@ -773,12 +770,12 @@ TEST(embedding_bag_fp16_gpu, segments_sum_basic) { // default_index : 1x1 // Output : 3x2 // Input values in fp16 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto emb_table = memory::allocate(engine, { data_types::f16, format::bfyx, { 5, 2, 1, 1 } }); - auto indices = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto segment_ids = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto per_sample_weights = memory::allocate(engine, { data_types::f16, format::bfyx, { 4, 1, 1, 1 } }); + auto emb_table = engine.allocate_memory({ data_types::f16, format::bfyx, { 5, 2, 1, 1 } }); + auto indices = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto segment_ids = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto per_sample_weights = engine.allocate_memory({ data_types::f16, format::bfyx, { 4, 1, 1, 1 } }); tensor output_shape = {3, 2, 1, 1}; set_values(emb_table, { @@ -800,9 +797,9 @@ TEST(embedding_bag_fp16_gpu, segments_sum_basic) { auto type = embedding_bag::segments_sum; topology topology; - topology.add(input_layout("Input0", emb_table.get_layout())); - topology.add(input_layout("Input1", indices.get_layout())); - topology.add(input_layout("Input2", segment_ids.get_layout())); + topology.add(input_layout("Input0", emb_table->get_layout())); + topology.add(input_layout("Input1", indices->get_layout())); + topology.add(input_layout("Input2", segment_ids->get_layout())); topology.add(data("Input3", per_sample_weights)); topology.add( embedding_bag("embedding_bag", {"Input0", "Input1", "Input2", "Input3"}, type, output_shape, 0) @@ -817,7 +814,7 @@ TEST(embedding_bag_fp16_gpu, segments_sum_basic) { auto outputs = network.execute(); auto output = outputs.at("embedding_bag").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { -1.05f, -1.2f, @@ -838,12 +835,12 @@ TEST(embedding_bag_fp16_gpu, segments_sum_basic_first_empty) { // default_index : 1x1 // Output : 3x2 // Input values in fp16 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto emb_table = memory::allocate(engine, { data_types::f16, format::bfyx, { 5, 2, 1, 1 } }); - auto indices = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto segment_ids = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto per_sample_weights = memory::allocate(engine, { data_types::f16, format::bfyx, { 4, 1, 1, 1 } }); + auto emb_table = engine.allocate_memory({ data_types::f16, format::bfyx, { 5, 2, 1, 1 } }); + auto indices = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto segment_ids = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto per_sample_weights = engine.allocate_memory({ data_types::f16, format::bfyx, { 4, 1, 1, 1 } }); tensor output_shape = {3, 2, 1, 1}; set_values(emb_table, { @@ -865,9 +862,9 @@ TEST(embedding_bag_fp16_gpu, segments_sum_basic_first_empty) { auto type = embedding_bag::segments_sum; topology topology; - topology.add(input_layout("Input0", emb_table.get_layout())); - topology.add(input_layout("Input1", indices.get_layout())); - topology.add(input_layout("Input2", segment_ids.get_layout())); + topology.add(input_layout("Input0", emb_table->get_layout())); + topology.add(input_layout("Input1", indices->get_layout())); + topology.add(input_layout("Input2", segment_ids->get_layout())); topology.add(data("Input3", per_sample_weights)); topology.add( embedding_bag("embedding_bag", {"Input0", "Input1", "Input2", "Input3"}, type, output_shape, 2) @@ -882,7 +879,7 @@ TEST(embedding_bag_fp16_gpu, segments_sum_basic_first_empty) { auto outputs = network.execute(); auto output = outputs.at("embedding_bag").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { -1.9f, -1.8f, @@ -903,12 +900,12 @@ TEST(embedding_bag_fp16_gpu, segments_sum_basic_last_empty) { // default_index : 1x1 // Output : 3x2 // Input values in fp16 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto emb_table = memory::allocate(engine, { data_types::f16, format::bfyx, { 5, 2, 1, 1 } }); - auto indices = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto segment_ids = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto per_sample_weights = memory::allocate(engine, { data_types::f16, format::bfyx, { 4, 1, 1, 1 } }); + auto emb_table = engine.allocate_memory({ data_types::f16, format::bfyx, { 5, 2, 1, 1 } }); + auto indices = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto segment_ids = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto per_sample_weights = engine.allocate_memory({ data_types::f16, format::bfyx, { 4, 1, 1, 1 } }); tensor output_shape = {3, 2, 1, 1}; set_values(emb_table, { @@ -930,9 +927,9 @@ TEST(embedding_bag_fp16_gpu, segments_sum_basic_last_empty) { auto type = embedding_bag::segments_sum; topology topology; - topology.add(input_layout("Input0", emb_table.get_layout())); - topology.add(input_layout("Input1", indices.get_layout())); - topology.add(input_layout("Input2", segment_ids.get_layout())); + topology.add(input_layout("Input0", emb_table->get_layout())); + topology.add(input_layout("Input1", indices->get_layout())); + topology.add(input_layout("Input2", segment_ids->get_layout())); topology.add(data("Input3", per_sample_weights)); topology.add( embedding_bag("embedding_bag", {"Input0", "Input1", "Input2", "Input3"}, type, output_shape, 2) @@ -947,7 +944,7 @@ TEST(embedding_bag_fp16_gpu, segments_sum_basic_last_empty) { auto outputs = network.execute(); auto output = outputs.at("embedding_bag").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { -1.05f, -1.2f, @@ -966,11 +963,11 @@ TEST(embedding_bag_fp16_gpu, segments_sum_without_weights_and_def_index) { // segment_ids : 4x1 // Output : 3x2 // Input values in fp16 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto emb_table = memory::allocate(engine, { data_types::f16, format::bfyx, { 5, 2, 1, 1 } }); - auto indices = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto segment_ids = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto emb_table = engine.allocate_memory({ data_types::f16, format::bfyx, { 5, 2, 1, 1 } }); + auto indices = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto segment_ids = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); tensor output_shape = {3, 2, 1, 1}; set_values(emb_table, { @@ -989,9 +986,9 @@ TEST(embedding_bag_fp16_gpu, segments_sum_without_weights_and_def_index) { auto type = embedding_bag::segments_sum; topology topology; - topology.add(input_layout("Input0", emb_table.get_layout())); - topology.add(input_layout("Input1", indices.get_layout())); - topology.add(input_layout("Input2", segment_ids.get_layout())); + topology.add(input_layout("Input0", emb_table->get_layout())); + topology.add(input_layout("Input1", indices->get_layout())); + topology.add(input_layout("Input2", segment_ids->get_layout())); topology.add( embedding_bag("embedding_bag", {"Input0", "Input1", "Input2"}, type, output_shape) ); @@ -1005,7 +1002,7 @@ TEST(embedding_bag_fp16_gpu, segments_sum_without_weights_and_def_index) { auto outputs = network.execute(); auto output = outputs.at("embedding_bag").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { -2.1f, -2.4f, @@ -1026,12 +1023,12 @@ TEST(embedding_bag_fp16_gpu, segments_sum_dim3) { // default_index : 1x1 // Output : 3x2x3x2 // Input values in fp16 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto emb_table = memory::allocate(engine, { data_types::f16, format::bfyx, { 5, 2, 3, 2 } }); - auto indices = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto segment_ids = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto per_sample_weights = memory::allocate(engine, { data_types::f16, format::bfyx, { 4, 1, 1, 1 } }); + auto emb_table = engine.allocate_memory({ data_types::f16, format::bfyx, { 5, 2, 3, 2 } }); + auto indices = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto segment_ids = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto per_sample_weights = engine.allocate_memory({ data_types::f16, format::bfyx, { 4, 1, 1, 1 } }); tensor output_shape = {3, 2, 3, 2}; /* @@ -1103,9 +1100,9 @@ TEST(embedding_bag_fp16_gpu, segments_sum_dim3) { auto type = embedding_bag::segments_sum; topology topology; - topology.add(input_layout("Input0", emb_table.get_layout())); - topology.add(input_layout("Input1", indices.get_layout())); - topology.add(input_layout("Input2", segment_ids.get_layout())); + topology.add(input_layout("Input0", emb_table->get_layout())); + topology.add(input_layout("Input1", indices->get_layout())); + topology.add(input_layout("Input2", segment_ids->get_layout())); topology.add(data("Input3", per_sample_weights)); topology.add( embedding_bag("embedding_bag", {"Input0", "Input1", "Input2", "Input3"}, type, output_shape, 0) @@ -1120,7 +1117,7 @@ TEST(embedding_bag_fp16_gpu, segments_sum_dim3) { auto outputs = network.execute(); auto output = outputs.at("embedding_bag").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); /* * [ 3 @@ -1170,11 +1167,11 @@ TEST(embedding_bag_fp32_gpu, packed_sum_basic) { // per_sample_weights : 3x2 // Output : 3x2 // Input values in fp16 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto emb_table = memory::allocate(engine, { data_types::f32, format::bfyx, { 5, 2, 1, 1 } }); - auto indices = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 2, 1, 1 } }); - auto per_sample_weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 3, 2, 1, 1 } }); + auto emb_table = engine.allocate_memory({ data_types::f32, format::bfyx, { 5, 2, 1, 1 } }); + auto indices = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 2, 1, 1 } }); + auto per_sample_weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 3, 2, 1, 1 } }); tensor output_shape = {3, 2, 1, 1}; set_values(emb_table, { @@ -1197,8 +1194,8 @@ TEST(embedding_bag_fp32_gpu, packed_sum_basic) { auto type = embedding_bag::packed_sum; topology topology; - topology.add(input_layout("Input0", emb_table.get_layout())); - topology.add(input_layout("Input1", indices.get_layout())); + topology.add(input_layout("Input0", emb_table->get_layout())); + topology.add(input_layout("Input1", indices->get_layout())); topology.add(data("Input2", per_sample_weights)); topology.add( embedding_bag("embedding_bag", {"Input0", "Input1", "Input2"}, type, output_shape) @@ -1212,7 +1209,7 @@ TEST(embedding_bag_fp32_gpu, packed_sum_basic) { auto outputs = network.execute(); auto output = outputs.at("embedding_bag").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { -1.05f, -1.2f, @@ -1231,11 +1228,11 @@ TEST(embedding_bag_fp32_gpu, packed_sum_dim3) { // per_sample_weights : 3x2 // Output : 3x2x3x2 // Input values in fp16 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto emb_table = memory::allocate(engine, { data_types::f32, format::bfyx, { 5, 2, 3, 2 } }); - auto indices = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 2, 1, 1 } }); - auto per_sample_weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 3, 2, 1, 1 } }); + auto emb_table = engine.allocate_memory({ data_types::f32, format::bfyx, { 5, 2, 3, 2 } }); + auto indices = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 2, 1, 1 } }); + auto per_sample_weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 3, 2, 1, 1 } }); tensor output_shape = {3, 2, 3, 2}; /* @@ -1307,8 +1304,8 @@ TEST(embedding_bag_fp32_gpu, packed_sum_dim3) { auto type = embedding_bag::packed_sum; topology topology; - topology.add(input_layout("Input0", emb_table.get_layout())); - topology.add(input_layout("Input1", indices.get_layout())); + topology.add(input_layout("Input0", emb_table->get_layout())); + topology.add(input_layout("Input1", indices->get_layout())); topology.add(data("Input2", per_sample_weights)); topology.add( embedding_bag("embedding_bag", {"Input0", "Input1", "Input2"}, type, output_shape) @@ -1322,7 +1319,7 @@ TEST(embedding_bag_fp32_gpu, packed_sum_dim3) { auto outputs = network.execute(); auto output = outputs.at("embedding_bag").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); /* * [ 3 @@ -1372,11 +1369,11 @@ TEST(embedding_bag_fp32_gpu, extended5_6) { // per_sample_weights : 3x2 // Output : 3x2 // Input values in fp16 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto emb_table = memory::allocate(engine, { data_types::f32, format::bfyx, { 5, 6, 1, 1 } }); - auto indices = memory::allocate(engine, { data_types::i32, format::bfyx, { 5, 1, 1, 1 } }); - auto segment_ids = memory::allocate(engine, { data_types::i32, format::bfyx, { 5, 1, 1, 1 } }); + auto emb_table = engine.allocate_memory({ data_types::f32, format::bfyx, { 5, 6, 1, 1 } }); + auto indices = engine.allocate_memory({ data_types::i32, format::bfyx, { 5, 1, 1, 1 } }); + auto segment_ids = engine.allocate_memory({ data_types::i32, format::bfyx, { 5, 1, 1, 1 } }); tensor output_shape = {5, 6, 1, 1}; set_values(emb_table, { @@ -1391,9 +1388,9 @@ TEST(embedding_bag_fp32_gpu, extended5_6) { auto type = embedding_bag::segments_sum; topology topology; - topology.add(input_layout("Input0", emb_table.get_layout())); - topology.add(input_layout("Input1", indices.get_layout())); - topology.add(input_layout("Input2", segment_ids.get_layout())); + topology.add(input_layout("Input0", emb_table->get_layout())); + topology.add(input_layout("Input1", indices->get_layout())); + topology.add(input_layout("Input2", segment_ids->get_layout())); topology.add( embedding_bag("embedding_bag", {"Input0", "Input1", "Input2"}, type, output_shape) ); @@ -1407,7 +1404,7 @@ TEST(embedding_bag_fp32_gpu, extended5_6) { auto outputs = network.execute(); auto output = outputs.at("embedding_bag").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0, 8, 15, 15, 9, 7, diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/extract_image_patches_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/extract_image_patches_gpu_test.cpp index ccbe6f5a769390..c627b088d1011a 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/extract_image_patches_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/extract_image_patches_gpu_test.cpp @@ -3,26 +3,23 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include -#include -#include -#include +#include "test_utils.h" + +#include +#include +#include -#include using namespace cldnn; -using namespace tests; +using namespace ::tests; TEST(extract_image_patches_gpu, basic) { // Input : 1x1x10x10 // Output : 1x9x2x2 tensor output_shape = {1, 9, 2, 2}; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch = 1; auto depth = 1; auto in_rows = 10; @@ -32,7 +29,7 @@ TEST(extract_image_patches_gpu, basic) { std::vector rates = {1, 1}; std::string auto_pad = "valid"; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { batch, depth, in_cols, in_rows } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { batch, depth, in_cols, in_rows } }); std::vector inputVals(batch * depth * in_rows * in_cols); std::generate(inputVals.begin(), inputVals.end(), []() { @@ -43,7 +40,7 @@ TEST(extract_image_patches_gpu, basic) { set_values(input, inputVals); topology topology; - topology.add(input_layout("Input0", input.get_layout())); + topology.add(input_layout("Input0", input->get_layout())); topology.add(extract_image_patches("extract_image_patches", "Input0", sizes, strides, rates, auto_pad, output_shape)); network network(engine, topology); @@ -54,7 +51,7 @@ TEST(extract_image_patches_gpu, basic) { EXPECT_EQ(outputs.begin()->first, "extract_image_patches"); auto output = outputs.at("extract_image_patches").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 1, 6, @@ -95,7 +92,7 @@ TEST(extract_image_patches_gpu, basic2) { // Input : 1x1x10x10 // Output : 1x16x1x1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch = 1; auto depth = 1; auto in_rows = 10; @@ -106,7 +103,7 @@ TEST(extract_image_patches_gpu, basic2) { std::string auto_pad = "valid"; tensor output_shape = {1, 16, 1, 1}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { batch, depth, in_cols, in_rows } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { batch, depth, in_cols, in_rows } }); std::vector inputVals(batch * depth * in_rows * in_cols); std::generate(inputVals.begin(), inputVals.end(), []() { @@ -117,7 +114,7 @@ TEST(extract_image_patches_gpu, basic2) { set_values(input, inputVals); topology topology; - topology.add(input_layout("Input0", input.get_layout())); + topology.add(input_layout("Input0", input->get_layout())); topology.add(extract_image_patches("extract_image_patches", "Input0", sizes, strides, rates, auto_pad, output_shape)); network network(engine, topology); @@ -128,7 +125,7 @@ TEST(extract_image_patches_gpu, basic2) { EXPECT_EQ(outputs.begin()->first, "extract_image_patches"); auto output = outputs.at("extract_image_patches").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 1, @@ -159,7 +156,7 @@ TEST(extract_image_patches_gpu, basic3) { // Input : 1x1x10x10 // Output : 1x16x2x2 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch = 1; auto depth = 1; auto in_rows = 10; @@ -170,7 +167,7 @@ TEST(extract_image_patches_gpu, basic3) { std::string auto_pad = "same_upper"; tensor output_shape = {1, 16, 2, 2}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { batch, depth, in_cols, in_rows } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { batch, depth, in_cols, in_rows } }); std::vector inputVals(batch * depth * in_rows * in_cols); std::generate(inputVals.begin(), inputVals.end(), []() { @@ -181,7 +178,7 @@ TEST(extract_image_patches_gpu, basic3) { set_values(input, inputVals); topology topology; - topology.add(input_layout("Input0", input.get_layout())); + topology.add(input_layout("Input0", input->get_layout())); topology.add(extract_image_patches("extract_image_patches", "Input0", sizes, strides, rates, auto_pad, output_shape)); network network(engine, topology); @@ -192,7 +189,7 @@ TEST(extract_image_patches_gpu, basic3) { EXPECT_EQ(outputs.begin()->first, "extract_image_patches"); auto output = outputs.at("extract_image_patches").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 0, 0, @@ -254,7 +251,7 @@ TEST(extract_image_patches_gpu, basic3_same_lower) { // Input : 1x1x10x10 // Output : 1x16x2x2 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch = 1; auto depth = 1; auto in_rows = 10; @@ -265,7 +262,7 @@ TEST(extract_image_patches_gpu, basic3_same_lower) { std::string auto_pad = "same_lower"; tensor output_shape = {1, 16, 2, 2}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { batch, depth, in_cols, in_rows } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { batch, depth, in_cols, in_rows } }); std::vector inputVals(batch * depth * in_rows * in_cols); std::generate(inputVals.begin(), inputVals.end(), []() { @@ -276,7 +273,7 @@ TEST(extract_image_patches_gpu, basic3_same_lower) { set_values(input, inputVals); topology topology; - topology.add(input_layout("Input0", input.get_layout())); + topology.add(input_layout("Input0", input->get_layout())); topology.add(extract_image_patches("extract_image_patches", "Input0", sizes, strides, rates, auto_pad, output_shape)); network network(engine, topology); @@ -287,7 +284,7 @@ TEST(extract_image_patches_gpu, basic3_same_lower) { EXPECT_EQ(outputs.begin()->first, "extract_image_patches"); auto output = outputs.at("extract_image_patches").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 0, 0, @@ -349,7 +346,7 @@ TEST(extract_image_patches_gpu, basic3_enough_space) { // Input : 1x1x10x10 // Output : 1x9x2x2 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch = 1; auto depth = 1; auto in_rows = 10; @@ -360,7 +357,7 @@ TEST(extract_image_patches_gpu, basic3_enough_space) { std::string auto_pad = "same_upper"; tensor output_shape = {1, 9, 2, 2}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { batch, depth, in_cols, in_rows } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { batch, depth, in_cols, in_rows } }); std::vector inputVals(batch * depth * in_rows * in_cols); std::generate(inputVals.begin(), inputVals.end(), []() { @@ -371,7 +368,7 @@ TEST(extract_image_patches_gpu, basic3_enough_space) { set_values(input, inputVals); topology topology; - topology.add(input_layout("Input0", input.get_layout())); + topology.add(input_layout("Input0", input->get_layout())); topology.add(extract_image_patches("extract_image_patches", "Input0", sizes, strides, rates, auto_pad, output_shape)); network network(engine, topology); @@ -382,7 +379,7 @@ TEST(extract_image_patches_gpu, basic3_enough_space) { EXPECT_EQ(outputs.begin()->first, "extract_image_patches"); auto output = outputs.at("extract_image_patches").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 1, 8, @@ -423,7 +420,7 @@ TEST(extract_image_patches_gpu, basic4) { // Input : 1x1x10x10 // Output : 1x9x2x2 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch = 1; auto depth = 1; auto in_rows = 10; @@ -434,7 +431,7 @@ TEST(extract_image_patches_gpu, basic4) { std::string auto_pad = "valid"; tensor output_shape = {1, 9, 2, 2}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { batch, depth, in_cols, in_rows } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { batch, depth, in_cols, in_rows } }); std::vector inputVals(batch * depth * in_rows * in_cols); std::generate(inputVals.begin(), inputVals.end(), []() { @@ -445,7 +442,7 @@ TEST(extract_image_patches_gpu, basic4) { set_values(input, inputVals); topology topology; - topology.add(input_layout("Input0", input.get_layout())); + topology.add(input_layout("Input0", input->get_layout())); topology.add(extract_image_patches("extract_image_patches", "Input0", sizes, strides, rates, auto_pad, output_shape)); network network(engine, topology); @@ -456,7 +453,7 @@ TEST(extract_image_patches_gpu, basic4) { EXPECT_EQ(outputs.begin()->first, "extract_image_patches"); auto output = outputs.at("extract_image_patches").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 1, 6, @@ -497,7 +494,7 @@ TEST(extract_image_patches_gpu, basic5) { // Input : 1x2x5x5 // Output : 1x8x2x2 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch = 1; auto depth = 2; auto in_rows = 5; @@ -508,7 +505,7 @@ TEST(extract_image_patches_gpu, basic5) { std::string auto_pad = "valid"; tensor output_shape = {1, 8, 2, 2}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { batch, depth, in_cols, in_rows } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { batch, depth, in_cols, in_rows } }); std::vector inputVals(batch * depth * in_rows * in_cols); std::generate(inputVals.begin(), inputVals.end(), []() { @@ -519,7 +516,7 @@ TEST(extract_image_patches_gpu, basic5) { set_values(input, inputVals); topology topology; - topology.add(input_layout("Input0", input.get_layout())); + topology.add(input_layout("Input0", input->get_layout())); topology.add(extract_image_patches("extract_image_patches", "Input0", sizes, strides, rates, auto_pad, output_shape)); network network(engine, topology); @@ -530,7 +527,7 @@ TEST(extract_image_patches_gpu, basic5) { EXPECT_EQ(outputs.begin()->first, "extract_image_patches"); auto output = outputs.at("extract_image_patches").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 1, 4, diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/fully_connected_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/fully_connected_gpu_test.cpp index 21f51050aa8185..b96ca63bb2e0e9 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/fully_connected_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/fully_connected_gpu_test.cpp @@ -3,20 +3,14 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include "api/fully_connected.hpp" -#include -#include -#include -#include -#include -#include "test_utils/test_utils.h" -#include -#include -#include "instrumentation.h" -#include "test_utils/network_test.h" + +#include "test_utils.h" +#include "network_test.h" + +#include +#include "cldnn/primitives/fully_connected.hpp" +#include +#include #include @@ -26,7 +20,7 @@ namespace cldnn } using namespace cldnn; -using namespace tests; +using namespace ::tests; cldnn::format::type layout_4d(cldnn::format f) { switch (f.value) { @@ -75,19 +69,19 @@ void generic_fully_connected_test(cldnn::format test_input_fmt, cldnn::format te VF input_rnd_vec = flatten_4d(test_input_fmt, input_rnd); VF weights_rnd_vec = flatten_4d(test_weights_fmt, weights_rnd); - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); tensor input_tensor(input_b, f, x, y); tensor weights_tensor(output_f, f, x, y); - auto input = memory::allocate(engine, { type_to_data_type::value, test_input_fmt, input_tensor }); - auto weights = memory::allocate(engine, { type_to_data_type::value, test_weights_fmt, weights_tensor }); - auto bias = memory::allocate(engine, { type_to_data_type::value, format::bfyx, { 1,1,output_f,1 } }); + auto input = engine.allocate_memory({ type_to_data_type::value, test_input_fmt, input_tensor }); + auto weights = engine.allocate_memory({ type_to_data_type::value, test_weights_fmt, weights_tensor }); + auto bias = engine.allocate_memory({ type_to_data_type::value, format::bfyx, { 1,1,output_f,1 } }); set_values(input, input_rnd_vec); set_values(weights, weights_rnd_vec); set_values(bias, bias_rnd_vec); primitive_id out_id = "fully_connected"; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), data("bias", bias), fully_connected(out_id, "input", "weights", "bias") @@ -105,8 +99,8 @@ void generic_fully_connected_test(cldnn::format test_input_fmt, cldnn::format te EXPECT_EQ(outputs.begin()->first, out_id); auto output_memory = outputs.at(out_id).get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); //EXPECT_EQ(output_layout.format.value, test_input_fmt); tensor output_tensor = output_layout.size; @@ -150,8 +144,8 @@ TEST(DISABLED_fully_connected_gpu, generic_random_short) { std::vector> input_sizes = { {28, 28}, {64, 64}, {100, 100}, {227, 227}, {1000, 1}, {1, 4096} }; VF outputs_x = { 5, 16 }; - const auto& engine = get_test_engine(); - bool f16_supported = !!engine.get_info().supports_fp16; + auto& engine = get_test_engine(); + bool f16_supported = !!engine.get_device_info().supports_fp16; if (!f16_supported) { std::cout << "[ SKIPPED ] float16 combinations are skipped (cl_khr_fp16 is not supported)." << std::endl; } @@ -199,15 +193,15 @@ TEST(fully_connected_gpu, no_biases) { const int32_t input_x = 3, input_b = 1, // size of whole input buffer weight_b = 4, weight_x = 3; // size of whole weights buffer - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate(engine, { data_types::f32,format::yxfb,{ input_b, 1, input_x, 1} }); - auto weights_prim = memory::allocate(engine, { data_types::f32,format::bfyx,{ weight_b, 1, weight_x, 1 } }); + auto input_prim = engine.allocate_memory({ data_types::f32,format::yxfb,{ input_b, 1, input_x, 1} }); + auto weights_prim = engine.allocate_memory({ data_types::f32,format::bfyx,{ weight_b, 1, weight_x, 1 } }); set_values(input_prim, { -0.5f, 2.0f, 0.5f }); set_values(weights_prim, { 1.5f, 1.0f, 0.5f, -1.0f, 0.0f, 0.5f, 0.5f, -0.5f, -2.0f, -0.5f, 1.0f, 1.5f }); - auto input = input_layout("input", input_prim.get_layout()); + auto input = input_layout("input", input_prim->get_layout()); auto w_data = data("weights", weights_prim); auto fc = fully_connected("full_con_prim", "input", "weights"); topology topology; @@ -224,7 +218,7 @@ TEST(fully_connected_gpu, no_biases) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); EXPECT_EQ(1.5f, output_ptr[0]); EXPECT_EQ(0.75f, output_ptr[1]); @@ -256,15 +250,15 @@ TEST(fully_connected_gpu, no_biases_int8) { const int32_t input_x = 3, input_b = 1, // size of whole input buffer weight_b = 4, weight_x = 3; // size of whole weights buffer - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate(engine, { data_types::f32,format::bfyx,{ input_b, 1, input_x, 1 } }); - auto weights_prim = memory::allocate(engine, { data_types::i8,format::bfyx,{ weight_b, 1, weight_x, 1 } }); + auto input_prim = engine.allocate_memory({ data_types::f32,format::bfyx,{ input_b, 1, input_x, 1 } }); + auto weights_prim = engine.allocate_memory({ data_types::i8,format::bfyx,{ weight_b, 1, weight_x, 1 } }); set_values(input_prim, { 8.4f, 2.3f, -4.49f }); set_values(weights_prim, { 2, 1, 0, -3, -2, 1, 0, -2, -4, -5, 10, 8 }); - auto input = input_layout("input", input_prim.get_layout()); + auto input = input_layout("input", input_prim->get_layout()); auto w_data = data("weights", weights_prim); auto ri = reorder("reorder_to_int", "input", { data_types::i8,format::bfyx,{ input_b, 1, input_x, 1 } }); auto fc = fully_connected("full_con_prim", "reorder_to_int", "weights"); @@ -284,7 +278,7 @@ TEST(fully_connected_gpu, no_biases_int8) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); EXPECT_EQ(18.0f, output_ptr[0]); EXPECT_EQ(-32.0f, output_ptr[1]); @@ -317,18 +311,18 @@ TEST(fully_connected_gpu, xb_f32_batch_1) { input_x = 3, input_b = 1, // size of whole input buffer weight_b = 4, weight_x = 3; // size of whole weights buffer - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate( engine, { data_types::f32, format::yxfb, { input_b, 1, input_x, 1 } }); - auto weights_prim = memory::allocate(engine, { data_types::f32,format::bfyx,{ weight_b, 1, weight_x, 1 } }); - auto bias_prim = memory::allocate(engine, { data_types::f32,format::bfyx, { 1,1,output_f, 1} }); + auto input_prim = engine.allocate_memory({ data_types::f32, format::yxfb, { input_b, 1, input_x, 1 } }); + auto weights_prim = engine.allocate_memory({ data_types::f32,format::bfyx,{ weight_b, 1, weight_x, 1 } }); + auto bias_prim = engine.allocate_memory({ data_types::f32,format::bfyx, { 1,1,output_f, 1} }); set_values(input_prim, { -0.5f, 2.0f, 0.5f }); set_values(weights_prim, { 1.5f, 1.0f, 0.5f, -1.0f, 0.0f, 0.5f, 0.5f, -0.5f, -2.0f, -0.5f, 1.0f, 1.5f }); set_values(bias_prim, { 1.0f, 2.0f, 3.0f, 4.0f }); topology topology( - input_layout("input", input_prim.get_layout()), + input_layout("input", input_prim->get_layout()), data("weights", weights_prim), data("bias", bias_prim), fully_connected("full_con_prim", "input", "weights", "bias") @@ -343,7 +337,7 @@ TEST(fully_connected_gpu, xb_f32_batch_1) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); EXPECT_EQ(2.5f, output_ptr[0]); EXPECT_EQ(2.75f, output_ptr[1]); @@ -377,18 +371,18 @@ TEST(fully_connected_gpu, xb_f32_batch_2) { input_x = 3, input_b = 2, // size of whole input buffer weight_b = 4, weight_x = 3; // size of whole weights buffer - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate(engine, { data_types::f32,format::yxfb,{ input_b,1,input_x, 1 } }); - auto weights_prim = memory::allocate(engine, { data_types::f32,format::bfyx,{ weight_b, 1, weight_x, 1 } }); - auto bias_prim = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1,1,output_f,1 } }); + auto input_prim = engine.allocate_memory({ data_types::f32,format::yxfb,{ input_b,1,input_x, 1 } }); + auto weights_prim = engine.allocate_memory({ data_types::f32,format::bfyx,{ weight_b, 1, weight_x, 1 } }); + auto bias_prim = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1,1,output_f,1 } }); set_values(input_prim, { -0.5f, 1.0f, 2.0f, 1.5f, 0.5f, 0.0f }); set_values(weights_prim, { 1.5f, 1.0f, 0.5f, -1.0f, 0.0f, 0.5f, 0.5f, -0.5f, -2.0f, -0.5f, 1.0f, 1.5f }); set_values(bias_prim, { 1.0f, 2.0f, 3.0f, 4.0f }); topology topology( - input_layout("input", input_prim.get_layout()), + input_layout("input", input_prim->get_layout()), data("weights", weights_prim), data("bias", bias_prim), fully_connected("full_con_prim", "input", "weights", "bias") @@ -403,7 +397,7 @@ TEST(fully_connected_gpu, xb_f32_batch_2) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); EXPECT_EQ(2.50f, output_ptr[0]); EXPECT_EQ(4.00f, output_ptr[1]); @@ -438,19 +432,19 @@ TEST(fully_connected_gpu, x_f32) { input_x = 3, // size of whole input buffer weight_b = 4, weight_x = 3; // size of whole weights buffer - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate(engine, { data_types::f32,format::bfyx, { 1,1,input_x,1 } }); + auto input_prim = engine.allocate_memory({ data_types::f32,format::bfyx, { 1,1,input_x,1 } }); //auto output_prim = memory::allocate({ memory::format::xb_f32,{ output_b,{ { output_f } },{ 1 } } }); - auto weights_prim = memory::allocate(engine, { data_types::f32,format::bfyx,{ weight_b, 1, weight_x, 1 } }); - auto bias_prim = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1,1,output_f,1 } }); + auto weights_prim = engine.allocate_memory({ data_types::f32,format::bfyx,{ weight_b, 1, weight_x, 1 } }); + auto bias_prim = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1,1,output_f,1 } }); set_values(input_prim, { -0.5f, 2.0f, 0.5f }); set_values(weights_prim, { 1.5f, 1.0f, 0.5f, -1.0f, 0.0f, 0.5f, 0.5f, -0.5f, -2.0f, -0.5f, 1.0f, 1.5f }); set_values(bias_prim, { 1.0f, 2.0f, 3.0f, 4.0f }); topology topology( - input_layout("input", input_prim.get_layout()), + input_layout("input", input_prim->get_layout()), data("weights", weights_prim), data("bias", bias_prim), fully_connected("full_con_prim", "input", "weights", "bias") @@ -465,7 +459,7 @@ TEST(fully_connected_gpu, x_f32) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); EXPECT_EQ(2.50f, output_ptr[0]); EXPECT_EQ(2.75f, output_ptr[1]); @@ -494,19 +488,19 @@ TEST(fully_connected_gpu, yxfn_f32) { // Output: // 10 -28.5 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 2, 2, 1 } }); + auto input_prim = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 2, 2, 1 } }); //auto output_prim = memory::allocate({ memory::format::xb_f32,{ 2 ,{ { 1 } }, 1 } }); - auto weights_prim = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 1 } }); - auto bias_prim = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 2, 1 } }); + auto weights_prim = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 1 } }); + auto bias_prim = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 2, 1 } }); set_values(input_prim, { 1.f, 3.f, -2.f, -4.f }); set_values(weights_prim, { 1.f, -1.f, 2.0f, 0.f, 3.0f, 4.0f, 0.5f, 5.0f }); set_values(bias_prim, { 1.0f, -5.0f }); topology topology( - input_layout("input", input_prim.get_layout()), + input_layout("input", input_prim->get_layout()), data("weights", weights_prim), data("bias", bias_prim), fully_connected("full_con_prim", "input", "weights", "bias") @@ -521,7 +515,7 @@ TEST(fully_connected_gpu, yxfn_f32) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); EXPECT_EQ(10, output_ptr[0]); EXPECT_EQ(-28.5, output_ptr[1]); @@ -552,19 +546,19 @@ TEST(fully_connected_gpu, xb_f32_batch_1_relu) { input_x = 3, input_b = 1, // size of whole input buffer weight_b = 4, weight_x = 3; // size of whole weights buffer - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate(engine, { data_types::f32,format::yxfb,{ input_b, 1, input_x, 1 } }); + auto input_prim = engine.allocate_memory({ data_types::f32,format::yxfb,{ input_b, 1, input_x, 1 } }); //auto output_prim = memory::allocate({ memory::format::xb_f32,{ output_b,{ { output_f } },{ 1 } } }); - auto weights_prim = memory::allocate(engine, { data_types::f32,format::bfyx,{ weight_b, 1, weight_x, 1 } }); - auto bias_prim = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1,1,output_f, 1 } }); + auto weights_prim = engine.allocate_memory({ data_types::f32,format::bfyx,{ weight_b, 1, weight_x, 1 } }); + auto bias_prim = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1,1,output_f, 1 } }); set_values(input_prim, { -0.5f, 2.0f, 0.5f }); set_values(weights_prim, { 1.5f, 1.0f, 0.5f, -1.0f, 0.0f, 0.5f, 0.5f, -0.5f, -2.0f, -0.5f, 1.0f, 1.5f }); set_values(bias_prim, { 1.0f, -2.0f, 3.0f, -4.0f }); topology topology( - input_layout("input", input_prim.get_layout()), + input_layout("input", input_prim->get_layout()), data("weights", weights_prim), data("bias", bias_prim), fully_connected("full_con_prim", "input", "weights", "bias"), @@ -580,7 +574,7 @@ TEST(fully_connected_gpu, xb_f32_batch_1_relu) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); EXPECT_EQ(2.50f, output_ptr[0]); EXPECT_EQ(0.00f, output_ptr[1]); @@ -614,19 +608,19 @@ TEST(fully_connected_gpu, xb_f32_batch_2_relu) { input_x = 3, input_b = 2, // size of whole input buffer weight_b = 4, weight_x = 3; // size of whole weights buffer - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate(engine, { data_types::f32,format::yxfb,{ input_b, 1, input_x, 1 } }); + auto input_prim = engine.allocate_memory({ data_types::f32,format::yxfb,{ input_b, 1, input_x, 1 } }); //auto output_prim = memory::allocate({ memory::format::xb_f32,{ output_b,{ { output_f } },{ 1 } } }); - auto weights_prim = memory::allocate(engine, { data_types::f32,format::bfyx,{ weight_b, 1, weight_x, 1 } }); - auto bias_prim = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1,1,output_f,1 } }); + auto weights_prim = engine.allocate_memory({ data_types::f32,format::bfyx,{ weight_b, 1, weight_x, 1 } }); + auto bias_prim = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1,1,output_f,1 } }); set_values(input_prim, { -0.5f, 1.0f, 2.0f, 1.5f, 0.5f, 0.0f }); set_values(weights_prim, { 1.5f, 1.0f, 0.5f, -1.0f, 0.0f, 0.5f, 0.5f, -0.5f, -2.0f, -0.5f, 1.0f, 1.5f }); set_values(bias_prim, { 1.0f, -2.0f, 3.0f, -4.0f }); topology topology( - input_layout("input", input_prim.get_layout()), + input_layout("input", input_prim->get_layout()), data("weights", weights_prim), data("bias", bias_prim), fully_connected("full_con_prim", "input", "weights", "bias"), @@ -642,7 +636,7 @@ TEST(fully_connected_gpu, xb_f32_batch_2_relu) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); EXPECT_EQ(2.50f, output_ptr[0]); EXPECT_EQ(4.00f, output_ptr[1]); @@ -677,19 +671,19 @@ TEST(fully_connected_gpu, x_f32_relu) { input_x = 3, // size of whole input buffer weight_b = 4, weight_x = 3; // size of whole weights buffer - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1,1,input_x,1 } }); + auto input_prim = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1,1,input_x,1 } }); //auto output_prim = memory::allocate({ memory::format::x_f32,{ 1 ,{ { output_f } }, 1 } }); - auto weights_prim = memory::allocate(engine, { data_types::f32,format::bfyx,{ weight_b, 1, weight_x, 1 } }); - auto bias_prim = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1,1,output_f,1 } }); + auto weights_prim = engine.allocate_memory({ data_types::f32,format::bfyx,{ weight_b, 1, weight_x, 1 } }); + auto bias_prim = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1,1,output_f,1 } }); set_values(input_prim, { -0.5f, 2.0f, 0.5f }); set_values(weights_prim, { 1.5f, 1.0f, 0.5f, -1.0f, 0.0f, 0.5f, 0.5f, -0.5f, -2.0f, -0.5f, 1.0f, 1.5f }); set_values(bias_prim, { 1.0f, -2.0f, 3.0f, -4.0f }); topology topology( - input_layout("input", input_prim.get_layout()), + input_layout("input", input_prim->get_layout()), data("weights", weights_prim), data("bias", bias_prim), fully_connected("full_con_prim", "input", "weights", "bias"), @@ -705,7 +699,7 @@ TEST(fully_connected_gpu, x_f32_relu) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); EXPECT_EQ(2.50f, output_ptr[0]); EXPECT_EQ(0.00f, output_ptr[1]); @@ -737,19 +731,19 @@ TEST(fully_connected_gpu, x_f32_relu_with_negative_slope) { input_x = 3, // size of whole input buffer weight_b = 4, weight_x = 3; // size of whole weights buffer - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1,1,input_x,1 } }); + auto input_prim = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1,1,input_x,1 } }); //auto output_prim = memory::allocate({ memory::format::x_f32,{ 1 ,{ { output_f } }, 1 } }); - auto weights_prim = memory::allocate(engine, { data_types::f32,format::bfyx,{ weight_b, 1, weight_x, 1 } }); - auto bias_prim = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1,1,output_f,1 } }); + auto weights_prim = engine.allocate_memory({ data_types::f32,format::bfyx,{ weight_b, 1, weight_x, 1 } }); + auto bias_prim = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1,1,output_f,1 } }); set_values(input_prim, { -0.5f, 2.0f, 0.5f }); set_values(weights_prim, { 1.5f, 1.0f, 0.5f, -1.0f, 0.0f, 0.5f, 0.5f, -0.5f, -2.0f, -0.5f, 1.0f, 1.5f }); set_values(bias_prim, { 1.0f, -2.0f, 3.0f, -4.0f }); topology topology( - input_layout("input", input_prim.get_layout()), + input_layout("input", input_prim->get_layout()), data("weights", weights_prim), data("bias", bias_prim), fully_connected("full_con_prim", "input", "weights", "bias"), @@ -765,7 +759,7 @@ TEST(fully_connected_gpu, x_f32_relu_with_negative_slope) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); EXPECT_EQ(2.50f, output_ptr[0]); EXPECT_EQ(-0.125f, output_ptr[1]); @@ -775,7 +769,7 @@ TEST(fully_connected_gpu, x_f32_relu_with_negative_slope) { TEST(fully_connected_gpu, b_fs_yx_fsv4) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int in_B = 2; const int in_F = 2048; @@ -791,11 +785,11 @@ TEST(fully_connected_gpu, b_fs_yx_fsv4) std::vector Data(in_F * in_B); // in_X=in_Y=1 int i = 0; std::generate(Data.begin(), Data.end(), [i]() mutable { return i++ % 9; }); - auto input = memory::allocate(engine, {data_types::i8, format::bfyx, {in_B, in_F, in_X, in_Y}}); + auto input = engine.allocate_memory({data_types::i8, format::bfyx, {in_B, in_F, in_X, in_Y}}); set_values(input, std::move(Data)); // Create a topology - topology topology(input_layout("input", input.get_layout())); + topology topology(input_layout("input", input->get_layout())); // Reorder topology.add(reorder("reorder_in", @@ -809,15 +803,19 @@ TEST(fully_connected_gpu, b_fs_yx_fsv4) return i % 2 ? -(i++) / W_F - 1 : (i++) / W_F + 1; }); auto weights_gold = - memory::allocate(engine, {data_types::i8, format::bfyx, {W_B, W_F, W_X, W_Y}}); + engine.allocate_memory({data_types::i8, format::bfyx, {W_B, W_F, W_X, W_Y}}); auto weights_imad = - memory::allocate(engine, {data_types::i8, format::bfyx, {W_B, W_F, W_X, W_Y}}); + engine.allocate_memory({data_types::i8, format::bfyx, {W_B, W_F, W_X, W_Y}}); set_values(weights_gold, Weights); set_values(weights_imad, std::move(Weights)); topology.add(data("weights_gold", weights_gold), data("weights_imad", weights_imad)); - auto bias_gold = memory::allocate(engine, {data_types::f32, format::bfyx, {1, 1, in_F, 1}}); - auto bias_imad = memory::allocate(engine, {data_types::f32, format::bfyx, {1, 1, in_F, 1}}); + auto bias_gold = engine.allocate_memory({data_types::f32, format::bfyx, {1, in_F, 1, 1}}); + auto bias_imad = engine.allocate_memory({data_types::f32, format::bfyx, {1, in_F, 1, 1}}); + + std::vector bias_data(in_F, 0); + set_values(bias_gold, bias_data); + set_values(bias_imad, bias_data); topology.add(data("bias_gold", bias_gold)); topology.add(data("bias_imad", bias_imad)); @@ -830,10 +828,10 @@ TEST(fully_connected_gpu, b_fs_yx_fsv4) topology.add(fullc_gold, fullc_imad); - auto input_low_mem = memory::allocate(engine, { data_types::f32, format::bfyx, {1, W_B, 1, 1} }); - auto input_high_mem = memory::allocate(engine, { data_types::f32, format::bfyx, {1, W_B, 1, 1} }); - auto output_low_mem = memory::allocate(engine, { data_types::f32, format::bfyx, {1, 1, 1, 1} }); - auto output_high_mem = memory::allocate(engine, { data_types::f32, format::bfyx, {1, 1, 1, 1} }); + auto input_low_mem = engine.allocate_memory({ data_types::f32, format::bfyx, {1, W_B, 1, 1} }); + auto input_high_mem = engine.allocate_memory({ data_types::f32, format::bfyx, {1, W_B, 1, 1} }); + auto output_low_mem = engine.allocate_memory({ data_types::f32, format::bfyx, {1, 1, 1, 1} }); + auto output_high_mem = engine.allocate_memory({ data_types::f32, format::bfyx, {1, 1, 1, 1} }); set_values(input_low_mem, generate_random_1d(W_B, -200, 0)); set_values(input_high_mem, generate_random_1d(W_B, 1, 200)); set_values(output_low_mem, {-127.0f}); @@ -868,21 +866,19 @@ TEST(fully_connected_gpu, b_fs_yx_fsv4) ASSERT_NE(out_gold, outputs.end()); ASSERT_NE(out_test, outputs.end()); - auto gold_ptr = out_gold->second.get_memory().pointer(); - auto test_ptr = out_test->second.get_memory().pointer(); + cldnn::mem_lock gold_ptr(out_gold->second.get_memory(), get_test_stream()); + cldnn::mem_lock test_ptr(out_test->second.get_memory(), get_test_stream()); ASSERT_EQ(gold_ptr.size(), test_ptr.size()); - for (size_t i = 0; i < gold_ptr.size(); i++) - { + for (size_t i = 0; i < gold_ptr.size(); i++) { ASSERT_EQ(gold_ptr[i], test_ptr[i]); } } -TEST(fully_connected_gpu, DISABLED_fs_byx_fsv32_b12) -{ - const auto& engine = get_test_engine(); +TEST(fully_connected_gpu, DISABLED_fs_byx_fsv32_b12) { + auto& engine = get_test_engine(); - if (!engine.get_info().supports_fp16) + if (!engine.get_device_info().supports_fp16) { std::cout << "[ SKIPPED ] The test is skipped (cl_khr_fp16 is not supported)." << std::endl; EXPECT_EQ(1, 1); @@ -896,9 +892,9 @@ TEST(fully_connected_gpu, DISABLED_fs_byx_fsv32_b12) const int input_f = 64; // Allocate memory - auto input_prim = memory::allocate(engine, { data_types::f16, format::bfyx, { batch_num, input_f, input_y, input_x } }); - auto weights_prim = memory::allocate(engine, { data_types::f16,format::bfyx,{ output_f, input_f, input_y, input_x } }); - auto bias_prim = memory::allocate(engine, { data_types::f16,format::bfyx,{ 1, 1, output_f, 1 } }); + auto input_prim = engine.allocate_memory({ data_types::f16, format::bfyx, { batch_num, input_f, input_y, input_x } }); + auto weights_prim = engine.allocate_memory({ data_types::f16,format::bfyx,{ output_f, input_f, input_y, input_x } }); + auto bias_prim = engine.allocate_memory({ data_types::f16,format::bfyx,{ 1, 1, output_f, 1 } }); // Generate random input data and set values auto input_data = generate_random_4d(batch_num, input_f, input_y, input_x, -1, 1); @@ -917,7 +913,7 @@ TEST(fully_connected_gpu, DISABLED_fs_byx_fsv32_b12) // Create topology to test topology topology( - input_layout("input", input_prim.get_layout()), + input_layout("input", input_prim->get_layout()), data("weights", weights_prim), data("bias", bias_prim), reorder("input_fsv", "input", {data_types::f16, format::fs_b_yx_fsv32, { batch_num, input_f, input_y, input_x } }), @@ -935,7 +931,7 @@ TEST(fully_connected_gpu, DISABLED_fs_byx_fsv32_b12) auto outputs = network.execute(); auto output_prim = outputs.at("out").get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); for (size_t bi = 0; bi < batch_num; ++bi) { @@ -956,9 +952,9 @@ TEST(fully_connected_gpu, DISABLED_fs_byx_fsv32_b12) TEST(fully_connected_gpu, DISABLED_fs_byx_fsv32_b34) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - if (!engine.get_info().supports_fp16) + if (!engine.get_device_info().supports_fp16) { std::cout << "[ SKIPPED ] The test is skipped (cl_khr_fp16 is not supported)." << std::endl; EXPECT_EQ(1, 1); @@ -972,9 +968,9 @@ TEST(fully_connected_gpu, DISABLED_fs_byx_fsv32_b34) const int input_f = 64; // Allocate memory - auto input_prim = memory::allocate(engine, { data_types::f16, format::bfyx, { batch_num, input_f, input_y, input_x } }); - auto weights_prim = memory::allocate(engine, { data_types::f16,format::bfyx,{ output_f, input_f, input_y, input_x } }); - auto bias_prim = memory::allocate(engine, { data_types::f16,format::bfyx,{ 1, 1, output_f, 1 } }); + auto input_prim = engine.allocate_memory({ data_types::f16, format::bfyx, { batch_num, input_f, input_y, input_x } }); + auto weights_prim = engine.allocate_memory({ data_types::f16,format::bfyx,{ output_f, input_f, input_y, input_x } }); + auto bias_prim = engine.allocate_memory({ data_types::f16,format::bfyx,{ 1, 1, output_f, 1 } }); // Generate random input data and set values auto input_data = generate_random_4d(batch_num, input_f, input_y, input_x, -1, 1); @@ -993,7 +989,7 @@ TEST(fully_connected_gpu, DISABLED_fs_byx_fsv32_b34) // Create topology to test topology topology( - input_layout("input", input_prim.get_layout()), + input_layout("input", input_prim->get_layout()), data("weights", weights_prim), data("bias", bias_prim), reorder("input_fsv", "input", { data_types::f16, format::fs_b_yx_fsv32, { batch_num, input_f, input_y, input_x } }), @@ -1011,7 +1007,7 @@ TEST(fully_connected_gpu, DISABLED_fs_byx_fsv32_b34) auto outputs = network.execute(); auto output_prim = outputs.at("out").get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); for (size_t bi = 0; bi < batch_num; ++bi) { @@ -1054,7 +1050,7 @@ struct fully_connected_random_test : ::testing::TestWithParam(output_f, input_f, input_y, input_x); auto bias_data = generate_smart_random_2d(1, output_f); - auto eng = get_test_engine(); + auto& eng = get_test_engine(); auto net = network_test(eng); auto input = net.add_input_layout("input", input_format, std::move(input_data)); auto weights = net.add_data("weights", format::oiyx, std::move(weights_data)); @@ -1152,7 +1148,7 @@ struct fully_connected_random_test_3d : ::testing::TestWithParam(output_y, input_y, 1, 1); auto bias_data = generate_smart_random_2d(1, output_y); - auto eng = get_test_engine(); + auto& eng = get_test_engine(); auto net = network_test(eng); auto input = net.add_input_layout("input", input_format, std::move(input_data)); auto weights = net.add_data("weights", format::oiyx, std::move(weights_data)); @@ -1314,14 +1310,14 @@ class fully_connected_quantized_test : public ::testing::Test { auto input_size = tensor(TensorValue(batch_num()), TensorValue(input_f()), TensorValue(input_x()), TensorValue(input_y())); auto weights_size = tensor(TensorValue(output_f()), TensorValue(input_f()), TensorValue(input_x()), TensorValue(input_y())); - auto input_prim = memory::allocate(engine, { input_data_type(), _fmt, input_size }); - auto weights_prim = memory::allocate(engine, { data_types::i8, format::bfyx, weights_size }); - auto quantization_input_low = memory::allocate(engine, { data_types::f32, format::bfyx, tensor(feature(output_f())) }); - auto quantization_input_high = memory::allocate(engine, { data_types::f32, format::bfyx, tensor(feature(output_f())) }); - auto quantization_output_low = memory::allocate(engine, { data_types::f32, format::bfyx, tensor(feature(1)) }); - auto quantization_output_high = memory::allocate(engine, { data_types::f32, format::bfyx, tensor(feature(1)) }); + auto input_prim = engine.allocate_memory({ input_data_type(), _fmt, input_size }); + auto weights_prim = engine.allocate_memory({ data_types::i8, format::bfyx, weights_size }); + auto quantization_input_low = engine.allocate_memory({ data_types::f32, format::bfyx, tensor(feature(output_f())) }); + auto quantization_input_high = engine.allocate_memory({ data_types::f32, format::bfyx, tensor(feature(output_f())) }); + auto quantization_output_low = engine.allocate_memory({ data_types::f32, format::bfyx, tensor(feature(1)) }); + auto quantization_output_high = engine.allocate_memory({ data_types::f32, format::bfyx, tensor(feature(1)) }); - VF input_flattened(input_prim.get_layout().get_linear_size()); + VF input_flattened(input_prim->get_layout().get_linear_size()); for (size_t bi = 0; bi < batch_num(); ++bi) for (size_t fi = 0; fi < input_f(); ++fi) for (size_t yi = 0; yi < input_y(); ++yi) @@ -1338,14 +1334,14 @@ class fully_connected_quantized_test : public ::testing::Test { set_values(quantization_output_low, { _quantization.output_low }); set_values(quantization_output_high, { _quantization.output_high }); - auto bias_prim = memory::allocate(engine, { data_types::i32, format::bfyx, tensor(feature(output_f())) }); + auto bias_prim = engine.allocate_memory({ data_types::i32, format::bfyx, tensor(feature(output_f())) }); set_values(bias_prim, _bias); topology topo; topo.add(data("weights", weights_prim)); topo.add(data("bias", bias_prim)); - topo.add(input_layout("input", input_prim.get_layout())); + topo.add(input_layout("input", input_prim->get_layout())); auto fc_prim = fully_connected("fc", "input", "weights", "bias"); fc_prim.output_data_type = type_to_data_type::value; topo.add(fc_prim); @@ -1374,7 +1370,7 @@ class fully_connected_quantized_test : public ::testing::Test { auto output = net.execute(); auto out_mem = output.at("output").get_memory(); - auto out_ptr = out_mem.pointer(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); for (size_t bi = 0; bi < batch_num(); ++bi) { for (size_t fi = 0; fi < output_f(); ++fi) { diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/fused_conv_eltwise_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/fused_conv_eltwise_gpu_test.cpp index 237c7aa12ebbe0..bcca8e4dd4fd7d 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/fused_conv_eltwise_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/fused_conv_eltwise_gpu_test.cpp @@ -3,36 +3,31 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include "api/convolution.hpp" -#include "api/eltwise.hpp" -#include "api/reorder.hpp" -#include -#include -#include -#include "test_utils/test_utils.h" -#include -#include - -#include + +#include "test_utils.h" + +#include +#include +#include +#include +#include +#include +#include #include #include -#include #include using namespace cldnn; -using namespace tests; +using namespace ::tests; using namespace testing; TEST(fused_conv_eltwise, basic_0) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 4, 5 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 4, 5 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, { 1.0f, 2.0f, -15.f, 3.0f, 4.0f, -15.f, 5.0f, 6.0f, -15.f, 7.0f, @@ -40,7 +35,7 @@ TEST(fused_conv_eltwise, basic_0) }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), convolution("conv", "input", { "weights" }), eltwise("eltwise", "input", "conv", eltwise_mode::sum), @@ -56,7 +51,7 @@ TEST(fused_conv_eltwise, basic_0) EXPECT_EQ(outputs.begin()->first, "out"); auto output = outputs.begin()->second.get_memory(); - auto&& out_layout = output.get_layout(); + auto&& out_layout = output->get_layout(); EXPECT_EQ(out_layout.format, format::bfyx); EXPECT_EQ(out_layout.size.batch[0], 1); @@ -67,11 +62,11 @@ TEST(fused_conv_eltwise, basic_0) TEST(fused_conv_eltwise, basic_image2d) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 4, 128, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 3, 256, 4 } }); - auto weights = memory::allocate(engine, { data_types::f16, format::bfyx, { 12, 4, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 4, 128, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 3, 256, 4 } }); + auto weights = engine.allocate_memory({ data_types::f16, format::bfyx, { 12, 4, 1, 1 } }); auto input_data1 = generate_random_4d(1, 4, 2, 128, -1, 1); auto input_data1_bfyx = flatten_4d(format::bfyx, input_data1); @@ -86,8 +81,8 @@ TEST(fused_conv_eltwise, basic_image2d) set_values(weights, weights_data_bfyx); topology topology_act( - input_layout("input", input.get_layout()), - input_layout("input2", input2.get_layout()), + input_layout("input", input->get_layout()), + input_layout("input2", input2->get_layout()), data("weights", weights), convolution("conv", "input", { "weights" }), depth_to_space("depth_to_space", "conv", 2, depth_to_space_mode::blocks_first), @@ -105,11 +100,11 @@ TEST(fused_conv_eltwise, basic_image2d) EXPECT_EQ(outputs_act.begin()->first, "eltwise"); auto output_act = outputs_act.begin()->second.get_memory(); - auto out_act_ptr = output_act.pointer(); + cldnn::mem_lock out_act_ptr(output_act, get_test_stream()); topology topology_ref( - input_layout("input", input.get_layout()), - input_layout("input2", input2.get_layout()), + input_layout("input", input->get_layout()), + input_layout("input2", input2->get_layout()), data("weights", weights), convolution("conv", "input", { "weights" }), depth_to_space("depth_to_space", "conv", 2, depth_to_space_mode::blocks_first), @@ -127,7 +122,7 @@ TEST(fused_conv_eltwise, basic_image2d) EXPECT_EQ(outputs_ref.begin()->first, "out"); auto output_ref = outputs_ref.begin()->second.get_memory(); - auto out_ref_ptr = output_ref.pointer(); + cldnn::mem_lock out_ref_ptr(output_ref, get_test_stream()); for (int i = 0;i < 3 * 256 * 4;i++) { EXPECT_EQ(out_act_ptr[i], out_ref_ptr[i]); @@ -136,10 +131,10 @@ TEST(fused_conv_eltwise, basic_image2d) TEST(fused_conv_eltwise, dont_fuse_if_conv_elt_are_outputs) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 4, 5 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 4, 5 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); set_values(input, { 1.0f, 2.0f, -15.f, 3.0f, 4.0f, -15.f, 5.0f, 6.0f, -15.f, 7.0f, @@ -147,7 +142,7 @@ TEST(fused_conv_eltwise, dont_fuse_if_conv_elt_are_outputs) }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), convolution("conv", "input", { "weights" }), eltwise("out", "input", "conv", eltwise_mode::sum)); @@ -162,7 +157,7 @@ TEST(fused_conv_eltwise, dont_fuse_if_conv_elt_are_outputs) EXPECT_EQ(outputs.begin()->first, "out"); auto output = outputs.begin()->second.get_memory(); - auto&& out_layout = output.get_layout(); + auto&& out_layout = output->get_layout(); EXPECT_EQ(out_layout.format, format::bfyx); EXPECT_EQ(out_layout.size.batch[0], 1); @@ -211,7 +206,7 @@ class FusedConvTest : public testing::Test void do_test(const fused_conv_eltwise& fused_prim) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); int n_features = static_cast(biases_values.size()); @@ -220,19 +215,11 @@ class FusedConvTest : public testing::Test auto biases_shape = tensor(1, n_features, 1, 1); auto sum_input_shape = tensor(1, n_features, 2, 1); - auto input = memory::allocate( - engine, - {type_to_data_type::value, format::bfyx, input_shape}); - auto weights = memory::allocate( - engine, - {type_to_data_type::value, format::bfyx, weights_shape}); + auto input = engine.allocate_memory({type_to_data_type::value, format::bfyx, input_shape}); + auto weights = engine.allocate_memory({type_to_data_type::value, format::bfyx, weights_shape}); - auto biases = memory::allocate( - engine, - {type_to_data_type::value, format::bfyx, biases_shape}); - auto sum_input = memory::allocate( - engine, - {type_to_data_type::value, format::bfyx, sum_input_shape}); + auto biases = engine.allocate_memory({type_to_data_type::value, format::bfyx, biases_shape}); + auto sum_input = engine.allocate_memory({type_to_data_type::value, format::bfyx, sum_input_shape}); set_values(input, input_values); std::vector post_processed_weights_values(n_features @@ -254,7 +241,7 @@ class FusedConvTest : public testing::Test set_values(biases, biases_values); set_values(sum_input, non_conv_input_values); - the_topology.add(input_layout("input", input.get_layout())); + the_topology.add(input_layout("input", input->get_layout())); the_topology.add(data("weights", weights)); the_topology.add(data("biases", biases)); the_topology.add(data("sum_input", sum_input)); @@ -269,8 +256,8 @@ class FusedConvTest : public testing::Test auto outputs = network.execute(); auto output_memory = outputs.at("fused_conv").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; int f_size = output_layout.size.feature[0]; diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/fusings_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/fusings_gpu_test.cpp index 2b9ddcbd3f4417..a3a88b7b2e8c69 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/fusings_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/fusings_gpu_test.cpp @@ -2,43 +2,35 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include "api/input_layout.hpp" -#include "api/convolution.hpp" -#include "api/quantize.hpp" -#include "api/topology.hpp" -#include "api/tensor.hpp" -#include "api/network.hpp" -#include "api/eltwise.hpp" -#include "api/fully_connected.hpp" -#include "api/gemm.hpp" -#include "api/binary_convolution.hpp" -#include "api/engine.hpp" -#include "api/data.hpp" -#include "api/resample.hpp" -#include "api/mvn.hpp" -#include "api/deconvolution.hpp" -#include "api/permute.hpp" -#include "api/gather.hpp" -#include "api/gather_nd.hpp" -#include "api/scatter_update.hpp" -#include "api/scatter_nd_update.hpp" -#include "api/scatter_elements_update.hpp" -#include "api/depth_to_space.hpp" -#include "api/space_to_depth.hpp" -#include "api/batch_to_space.hpp" -#include "api/space_to_batch.hpp" -#include "api/reduce.hpp" - - -#include "test_utils/test_utils.h" +#include "test_utils.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include using namespace cldnn; -using namespace tests; +using namespace ::tests; struct resample_test_params { tensor in_shape; @@ -137,7 +129,7 @@ struct normalize_test_params { template class BaseFusingTest : public ::testing::TestWithParam { public: - cldnn::engine engine; + cldnn::engine& engine = get_test_engine(); cldnn::topology topology_fused; cldnn::topology topology_non_fused; cldnn::build_options bo_fused; @@ -162,7 +154,7 @@ class BaseFusingTest : public ::testing::TestWithParam { for (auto& pi : net.get_primitives_info()) { if (pi.type_id == "reorder") { auto exec_prims = net.get_executed_primitives(); - auto it = std::find_if(exec_prims.begin(), exec_prims.end(), [&](const std::pair& e) -> bool { + auto it = std::find_if(exec_prims.begin(), exec_prims.end(), [&](const std::pair& e) -> bool { return e.first == pi.original_id; }); // We count executed reorders only @@ -194,23 +186,23 @@ class BaseFusingTest : public ::testing::TestWithParam { auto output_not_fused_prim = outputs_ref.begin()->second.get_memory(); auto output_fused_prim = outputs_fused.begin()->second.get_memory(); - if (output_not_fused_prim.get_layout().data_type == data_types::f32) { - auto ref = output_not_fused_prim.pointer(); - auto output_ptr = output_fused_prim.pointer(); - for (size_t i = 0; i < output_fused_prim.get_layout().count(); i++) { + if (output_not_fused_prim->get_layout().data_type == data_types::f32) { + cldnn::mem_lock ref(output_not_fused_prim, get_test_stream()); + cldnn::mem_lock output_ptr(output_fused_prim, get_test_stream()); + for (size_t i = 0; i < output_fused_prim->get_layout().count(); i++) { ASSERT_NEAR(ref[i], output_ptr[i], tolerance) << "i = " << i; } } else { - auto ref = output_not_fused_prim.pointer(); - auto output_ptr = output_fused_prim.pointer(); - for (size_t i = 0; i < output_fused_prim.get_layout().count(); i++) { + cldnn::mem_lock ref(output_not_fused_prim, get_test_stream()); + cldnn::mem_lock output_ptr(output_fused_prim, get_test_stream()); + for (size_t i = 0; i < output_fused_prim->get_layout().count(); i++) { ASSERT_NEAR(float16_to_float32(ref[i]), float16_to_float32(output_ptr[i]), tolerance) << "i = " << i; } } } - cldnn::memory get_mem(cldnn::layout l) { - auto prim = memory::allocate(engine, l); + cldnn::memory::ptr get_mem(cldnn::layout l) { + auto prim = engine.allocate_memory(l); tensor s = l.size; if (l.data_type == data_types::bin) { VF rnd_vec = generate_random_1d(s.count() / 32, min_random, max_random); @@ -229,8 +221,8 @@ class BaseFusingTest : public ::testing::TestWithParam { return prim; } - cldnn::memory get_mem(cldnn::layout l, float fill_value) { - auto prim = memory::allocate(engine, l); + cldnn::memory::ptr get_mem(cldnn::layout l, float fill_value) { + auto prim = engine.allocate_memory(l); tensor s = l.size; if (l.data_type == data_types::bin) { VF rnd_vec(s.count() / 32, static_cast(fill_value)); @@ -238,16 +230,18 @@ class BaseFusingTest : public ::testing::TestWithParam { } else if (l.data_type == data_types::f16) { VF rnd_vec(s.count(), float32_to_float16(fill_value)); set_values(prim, rnd_vec); - } else { + } else if (l.data_type == data_types::f32) { VF rnd_vec(s.count(), fill_value); set_values(prim, rnd_vec); + } else { + throw std::runtime_error("get_mem: Unsupported precision"); } return prim; } - cldnn::memory get_repeatless_mem(cldnn::layout l, int min, int max) { - auto prim = memory::allocate(engine, l); + cldnn::memory::ptr get_repeatless_mem(cldnn::layout l, int min, int max) { + auto prim = engine.allocate_memory(l); tensor s = l.size; if (l.data_type == data_types::f32) { VF rnd_vec = generate_random_norepetitions_1d(s.count(), min, max); @@ -267,8 +261,8 @@ class BaseFusingTest : public ::testing::TestWithParam { return prim; } - cldnn::memory get_mem(cldnn::layout l, int min, int max) { - auto prim = memory::allocate(engine, l); + cldnn::memory::ptr get_mem(cldnn::layout l, int min, int max) { + auto prim = engine.allocate_memory(l); tensor s = l.size; if (l.data_type == data_types::f32) { VF rnd_vec = generate_random_1d(s.count(), min, max); @@ -292,7 +286,7 @@ class BaseFusingTest : public ::testing::TestWithParam { return layout{ p.data_type, p.input_format, p.out_shape }; } - layout get_weights_layout(T& p, const int32_t split = 1) { + layout get_weights_layout(T& p, const int32_t /* split */ = 1) { cldnn::tensor weights_tensor; if (p.groups == 1) { weights_tensor = cldnn::tensor(batch(p.out_shape.feature[0]), feature(p.in_shape.feature[0]), @@ -304,7 +298,7 @@ class BaseFusingTest : public ::testing::TestWithParam { return layout{p.weights_type, p.weights_format, weights_tensor}; } - layout get_weights_layout(T& p, const int32_t split, cldnn::format f) { + layout get_weights_layout(T& p, const int32_t /* split */, cldnn::format f) { cldnn::tensor weights_tensor; weights_tensor = cldnn::tensor(batch(p.out_shape.feature[0]), feature(static_cast(p.in_shape.feature[0] / p.groups)), spatial(p.kernel.spatial[0], p.kernel.spatial[1], p.kernel.spatial[2])); @@ -836,7 +830,7 @@ INSTANTIATE_TEST_CASE_P(fusings_gpu, conv_fp32_prelu_eltwise, class conv_fp32_multi_eltwise_2 : public ConvFusingTest {}; TEST_P(conv_fp32_multi_eltwise_2, basic) { - if (engine.get_info().supports_immad) { + if (engine.get_device_info().supports_immad) { return; } @@ -871,7 +865,7 @@ INSTANTIATE_TEST_CASE_P(fusings_gpu, conv_fp32_multi_eltwise_2, class conv_fp32_multi_eltwise_2_clamp : public ConvFusingTest {}; TEST_P(conv_fp32_multi_eltwise_2_clamp, basic) { - if (engine.get_info().supports_immad) { + if (engine.get_device_info().supports_immad) { return; } @@ -907,7 +901,7 @@ INSTANTIATE_TEST_CASE_P(fusings_gpu, conv_fp32_multi_eltwise_2_clamp, class conv_fp32_multi_eltwise_4_clamp : public ConvFusingTest {}; TEST_P(conv_fp32_multi_eltwise_4_clamp, basic) { - if (engine.get_info().supports_immad) { + if (engine.get_device_info().supports_immad) { return; } @@ -947,7 +941,7 @@ INSTANTIATE_TEST_CASE_P(fusings_gpu, conv_fp32_multi_eltwise_4_clamp, class conv_fp32_multi_eltwise_3_fusing : public ConvFusingTest {}; TEST_P(conv_fp32_multi_eltwise_3_fusing, basic) { - if (engine.get_info().supports_immad) { + if (engine.get_device_info().supports_immad) { return; } @@ -8419,4 +8413,3 @@ INSTANTIATE_TEST_CASE_P(fusings_gpu, gather_nd_activation_scale_eltwise, gather_nd_test_params{ CASE_GATHER_ND_FP32_6D_3, 2, 5 }, gather_nd_test_params{ CASE_GATHER_ND_FP32_6D_4, 2, 5 }, }), ); - diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/gather_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/gather_gpu_test.cpp index fbfe62957f6ffd..c0387763873953 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/gather_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/gather_gpu_test.cpp @@ -2,23 +2,18 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include +#include "test_utils.h" -#include -#include -#include -#include -#include +#include +#include #include -#include using namespace cldnn; using namespace ::tests; TEST(gather7_gpu_fp16, d222_axisX_bdim_m1) { - // Dictionary : 2x2x2x2x2x2 + // Dictionary : 2x2x2x2x2x2 // Indexes : 2x2x2x1 // Axis : 5 // batch_dim : -1 @@ -35,19 +30,19 @@ TEST(gather7_gpu_fp16, d222_axisX_bdim_m1) { // 55.f 56.f 57.f 58.f 59.f 60.f 61.f 62.f 63.f 64.f // // Output: - // 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, - // 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f, 16.f, - // 17.f, 17.f, 19.f, 19.f, 21.f, 21.f, 23.f, 23.f, - // 25.f, 25.f, 27.f, 27.f, 29.f, 29.f, 31.f, 31.f, - // 33.f, 33.f, 35.f, 35.f, 37.f, 37.f, 39.f, 39.f, - // 41.f, 41.f, 43.f, 43.f, 45.f, 45.f, 47.f, 47.f, - // 50.f, 49.f, 52.f, 51.f, 54.f, 53.f, 56.f, 55.f, + // 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, + // 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f, 16.f, + // 17.f, 17.f, 19.f, 19.f, 21.f, 21.f, 23.f, 23.f, + // 25.f, 25.f, 27.f, 27.f, 29.f, 29.f, 31.f, 31.f, + // 33.f, 33.f, 35.f, 35.f, 37.f, 37.f, 39.f, 39.f, + // 41.f, 41.f, 43.f, 43.f, 45.f, 45.f, 47.f, 47.f, + // 50.f, 49.f, 52.f, 51.f, 54.f, 53.f, 56.f, 55.f, // 58.f, 57.f, 60.f, 59.f, 62.f, 61.f, 64.f, 63.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 2, 2, 2, 2, 2} }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 2 } }); // Indexes + auto input1 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 2, 2, 2, 2, 2} }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 2 } }); // Indexes auto axis = cldnn::gather::gather_axis::along_x; int64_t batch_dim = -1; @@ -68,14 +63,14 @@ TEST(gather7_gpu_fp16, d222_axisX_bdim_m1) { set_values(input2, { 0.f, 1.f, 0.f, 0.f, - + 0.f, 0.f, 1.f, 0.f }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); topology.add( gather("gather", "InputDictionary", "InputText", axis, format::bfwzyx, tensor(2, 2, 2, 2, 2, 2), batch_dim) ); @@ -88,16 +83,16 @@ TEST(gather7_gpu_fp16, d222_axisX_bdim_m1) { auto outputs = network.execute(); auto output = outputs.at("gather").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { - 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, - 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f, 16.f, - 17.f, 17.f, 19.f, 19.f, 21.f, 21.f, 23.f, 23.f, - 25.f, 25.f, 27.f, 27.f, 29.f, 29.f, 31.f, 31.f, - 33.f, 33.f, 35.f, 35.f, 37.f, 37.f, 39.f, 39.f, - 41.f, 41.f, 43.f, 43.f, 45.f, 45.f, 47.f, 47.f, - 50.f, 49.f, 52.f, 51.f, 54.f, 53.f, 56.f, 55.f, + 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, + 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f, 16.f, + 17.f, 17.f, 19.f, 19.f, 21.f, 21.f, 23.f, 23.f, + 25.f, 25.f, 27.f, 27.f, 29.f, 29.f, 31.f, 31.f, + 33.f, 33.f, 35.f, 35.f, 37.f, 37.f, 39.f, 39.f, + 41.f, 41.f, 43.f, 43.f, 45.f, 45.f, 47.f, 47.f, + 50.f, 49.f, 52.f, 51.f, 54.f, 53.f, 56.f, 55.f, 58.f, 57.f, 60.f, 59.f, 62.f, 61.f, 64.f, 63.f }; @@ -107,7 +102,7 @@ TEST(gather7_gpu_fp16, d222_axisX_bdim_m1) { } TEST(gather7_gpu_fp16, d323_axisY_bdim_m1) { - // Dictionary : 3x2x3x4x2 + // Dictionary : 3x2x3x4x2 // Indexes : 3x2x3x1 // Axis : 3 // batch_dim : -1 @@ -138,10 +133,10 @@ TEST(gather7_gpu_fp16, d323_axisY_bdim_m1) { // 119.f 120.f 115.f 116.f 113.f 114.f 125.f 126.f 121.f 122.f 123.f 124.f // 133.f 134.f 129.f 130.f 131.f 132.f 141.f 142.f 137.f 138.f 139.f 140.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 3, 2, 2, 4, 3} }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 3, 2, 1, 3 } }); // Indexes + auto input1 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 3, 2, 2, 4, 3} }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 3, 2, 1, 3 } }); // Indexes auto axis = cldnn::gather::gather_axis::along_y; int64_t batch_dim = -1; @@ -176,17 +171,17 @@ TEST(gather7_gpu_fp16, d323_axisY_bdim_m1) { set_values(input2, { 0.f, 0.f, 0.f, 3.f, 1.f, 0.f, - + 1.f, 1.f, 1.f, 2.f, 0.f, 3.f, - + 3.f, 1.f, 0.f, 2.f, 0.f, 1.f }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); topology.add( gather("gather", "InputDictionary", "InputText", axis, format::bfzyx, tensor(3, 2, 2, 3, 3), batch_dim) ); @@ -199,7 +194,7 @@ TEST(gather7_gpu_fp16, d323_axisY_bdim_m1) { auto outputs = network.execute(); auto output = outputs.at("gather").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 1.f, 2.f, 1.f, 2.f, 1.f, 2.f, @@ -218,7 +213,7 @@ TEST(gather7_gpu_fp16, d323_axisY_bdim_m1) { 77.f, 78.f, 73.f, 74.f, 79.f, 80.f, 85.f, 86.f, 81.f, 82.f, 87.f, 88.f, 93.f, 94.f, 89.f, 90.f, 95.f, 96.f, - + 103.f, 104.f, 99.f, 100.f, 97.f, 98.f, 111.f, 112.f, 107.f, 108.f, 105.f, 106.f, @@ -256,28 +251,28 @@ TEST(gather7_gpu_fp16, d44_axisY_bdim1) { // 29.f 16.f 75.f 74.f 74.f 8.f 29.f 29.f 7.f 18.f 54.f 54.f 38.f 16.f 40.f 40.f 74.f 24.f // 74.f 25.f 82.f 74.f 71.f 9.f 92.f 71.f 80.f 64.f 27.f 80.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 4, 3, 1, 5 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 4, 4, 1, 1 } }); // Indexes + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 4, 3, 1, 5 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 4, 4, 1, 1 } }); // Indexes auto axis = cldnn::gather::gather_axis::along_y; int64_t batch_dim = 1; set_values(input1, { FLOAT16(84.f), FLOAT16( 7.f), FLOAT16(10.f), FLOAT16(69.f), FLOAT16(13.f), - FLOAT16(47.f), FLOAT16(75.f), FLOAT16( 8.f), FLOAT16(65.f), FLOAT16(28.f), - FLOAT16( 5.f), FLOAT16(12.f), FLOAT16(56.f), FLOAT16(54.f), FLOAT16( 9.f), - - FLOAT16(31.f), FLOAT16(12.f), FLOAT16(71.f), FLOAT16(55.f), FLOAT16( 8.f), - FLOAT16(73.f), FLOAT16(16.f), FLOAT16(29.f), FLOAT16(81.f), FLOAT16(81.f), - FLOAT16(75.f), FLOAT16( 8.f), FLOAT16(74.f), FLOAT16(75.f), FLOAT16(51.f), - - FLOAT16( 7.f), FLOAT16(29.f), FLOAT16( 6.f), FLOAT16(72.f), FLOAT16(18.f), - FLOAT16(38.f), FLOAT16(54.f), FLOAT16(19.f), FLOAT16(70.f), FLOAT16(16.f), - FLOAT16(74.f), FLOAT16(40.f), FLOAT16(72.f), FLOAT16(88.f), FLOAT16(24.f), - - FLOAT16(14.f), FLOAT16(75.f), FLOAT16(74.f), FLOAT16(82.f), FLOAT16(25.f), - FLOAT16(48.f), FLOAT16(13.f), FLOAT16(71.f), FLOAT16(92.f), FLOAT16( 9.f), + FLOAT16(47.f), FLOAT16(75.f), FLOAT16( 8.f), FLOAT16(65.f), FLOAT16(28.f), + FLOAT16( 5.f), FLOAT16(12.f), FLOAT16(56.f), FLOAT16(54.f), FLOAT16( 9.f), + + FLOAT16(31.f), FLOAT16(12.f), FLOAT16(71.f), FLOAT16(55.f), FLOAT16( 8.f), + FLOAT16(73.f), FLOAT16(16.f), FLOAT16(29.f), FLOAT16(81.f), FLOAT16(81.f), + FLOAT16(75.f), FLOAT16( 8.f), FLOAT16(74.f), FLOAT16(75.f), FLOAT16(51.f), + + FLOAT16( 7.f), FLOAT16(29.f), FLOAT16( 6.f), FLOAT16(72.f), FLOAT16(18.f), + FLOAT16(38.f), FLOAT16(54.f), FLOAT16(19.f), FLOAT16(70.f), FLOAT16(16.f), + FLOAT16(74.f), FLOAT16(40.f), FLOAT16(72.f), FLOAT16(88.f), FLOAT16(24.f), + + FLOAT16(14.f), FLOAT16(75.f), FLOAT16(74.f), FLOAT16(82.f), FLOAT16(25.f), + FLOAT16(48.f), FLOAT16(13.f), FLOAT16(71.f), FLOAT16(92.f), FLOAT16( 9.f), FLOAT16(73.f), FLOAT16( 8.f), FLOAT16(80.f), FLOAT16(27.f), FLOAT16(64.f) }); @@ -289,8 +284,8 @@ TEST(gather7_gpu_fp16, d44_axisY_bdim1) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); topology.add( gather("gather", "InputDictionary", "InputText", axis, format::bfyx, tensor(4, 3, 1, 4), batch_dim) ); @@ -303,23 +298,23 @@ TEST(gather7_gpu_fp16, d44_axisY_bdim1) { auto outputs = network.execute(); auto output = outputs.at("gather").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { - 69.f, 10.f, 69.f, 13.f, - 65.f, 8.f, 65.f, 28.f, - 54.f, 56.f, 54.f, 9.f, + 69.f, 10.f, 69.f, 13.f, + 65.f, 8.f, 65.f, 28.f, + 54.f, 56.f, 54.f, 9.f, - 55.f, 71.f, 71.f, 12.f, - 81.f, 29.f, 29.f, 16.f, + 55.f, 71.f, 71.f, 12.f, + 81.f, 29.f, 29.f, 16.f, 75.f, 74.f, 74.f, 8.f, - 29.f, 29.f, 7.f, 18.f, - 54.f, 54.f, 38.f, 16.f, + 29.f, 29.f, 7.f, 18.f, + 54.f, 54.f, 38.f, 16.f, 40.f, 40.f, 74.f, 24.f, - 74.f, 25.f, 82.f, 74.f, - 71.f, 9.f, 92.f, 71.f, + 74.f, 25.f, 82.f, 74.f, + 71.f, 9.f, 92.f, 71.f, 80.f, 64.f, 27.f, 80.f }; @@ -345,10 +340,10 @@ TEST(gather7_gpu_fp16, d32_axisF_bdim_m1) { // Output: // 1.f 1.f 4.f 3.f 5.f 5.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 2, 1, 1 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 3, 2, 1, 1 } }); // Indexes + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 2, 1, 1 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 3, 2, 1, 1 } }); // Indexes auto axis = cldnn::gather::gather_axis::along_f; size_t batch_dim = -1; @@ -364,8 +359,8 @@ TEST(gather7_gpu_fp16, d32_axisF_bdim_m1) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); topology.add( gather("gather", "InputDictionary", "InputText", axis, format::bfyx, tensor(3, 2, 1, 1), batch_dim) ); @@ -378,10 +373,10 @@ TEST(gather7_gpu_fp16, d32_axisF_bdim_m1) { auto outputs = network.execute(); auto output = outputs.at("gather").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { - 1.f, 1.f, + 1.f, 1.f, 4.f, 3.f, 5.f, 5.f, }; @@ -408,10 +403,10 @@ TEST(gather7_gpu_fp16, d32_axisF_bdim1) { // Output: // 1.f 1.f 4.f 3.f 5.f 5.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 2, 1, 1 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 3, 2, 1, 1 } }); // Indexes + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 2, 1, 1 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 3, 2, 1, 1 } }); // Indexes auto axis = cldnn::gather::gather_axis::along_f; int64_t batch_dim = 1; @@ -427,8 +422,8 @@ TEST(gather7_gpu_fp16, d32_axisF_bdim1) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); topology.add( gather("gather", "InputDictionary", "InputText", axis, format::bfyx, tensor(3, 2, 1, 1), batch_dim) ); @@ -441,7 +436,7 @@ TEST(gather7_gpu_fp16, d32_axisF_bdim1) { auto outputs = network.execute(); auto output = outputs.at("gather").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 1.f, 1.f, 4.f, @@ -470,10 +465,10 @@ TEST(gather7_gpu_fp16, d32_axisF_bdim0) { // Output: // 1.f 1.f 4.f 3.f 5.f 5.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 2, 1, 1 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 3, 2, 1, 1 } }); // Indexes + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 2, 1, 1 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 3, 2, 1, 1 } }); // Indexes auto axis = cldnn::gather::gather_axis::along_f; size_t batch_dim = 0; @@ -489,8 +484,8 @@ TEST(gather7_gpu_fp16, d32_axisF_bdim0) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); topology.add( gather("gather", "InputDictionary", "InputText", axis, format::bfyx, tensor(3, 3, 1, 2), batch_dim) ); @@ -503,18 +498,18 @@ TEST(gather7_gpu_fp16, d32_axisF_bdim0) { auto outputs = network.execute(); auto output = outputs.at("gather").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { - 1.f, 1.f, + 1.f, 1.f, 2.f, 1.f, 1.f, 1.f, - 3.f, 3.f, + 3.f, 3.f, 4.f, 3.f, 3.f, 3.f, - 5.f, 5.f, + 5.f, 5.f, 6.f, 5.f, 5.f, 5.f }; @@ -540,10 +535,10 @@ TEST(gather_gpu_fp16, d14_axisB) { // Output: // 1.f, 2.f, 3.f, 4.f, 3.f, 4.f, 1.f, 2.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 4, 1, 1 } }); // Indexes + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 4, 1, 1 } }); // Indexes auto axis = cldnn::gather::gather_axis::along_b; set_values(input1, { @@ -557,8 +552,8 @@ TEST(gather_gpu_fp16, d14_axisB) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); topology.add( gather("gather", "InputDictionary", "InputText", axis, format::bfyx, tensor(1, 4, 1, 2)) ); @@ -571,7 +566,7 @@ TEST(gather_gpu_fp16, d14_axisB) { auto outputs = network.execute(); auto output = outputs.at("gather").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 1.f, 2.f, 3.f, 4.f, 3.f, 4.f, 1.f, 2.f @@ -599,10 +594,10 @@ TEST(gather_gpu_fp16, d222_axisB) { // Output: // 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 5.f, 6.f, 7.f, 8.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 2, 1, 2 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 2, 1, 2 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes auto axis = cldnn::gather::gather_axis::along_b; set_values(input1, { @@ -619,8 +614,8 @@ TEST(gather_gpu_fp16, d222_axisB) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); topology.add( gather("gather", "InputDictionary", "InputText", axis, format::bfyx, tensor(2, 2, 2, 2)) ); @@ -633,7 +628,7 @@ TEST(gather_gpu_fp16, d222_axisB) { auto outputs = network.execute(); auto output = outputs.at("gather").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 5.f, 6.f, 7.f, 8.f @@ -661,10 +656,10 @@ TEST(gather_gpu_fp16, d22_axisY) { // Output: // 1.f, 2.f, 3.f, 2.f, 4.f, 5.f, 6.f, 5.f, 7.f, 8.f, 9.f, 8.f, 10.f, 11.f, 12.f, 11.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 2, 1, 3 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 2, 1, 3 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes auto axis = cldnn::gather::gather_axis::along_y; set_values(input1, { @@ -680,8 +675,8 @@ TEST(gather_gpu_fp16, d22_axisY) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); topology.add( gather("gather", "InputDictionary", "InputText", axis, format::bfyx, tensor(2, 2, 2, 2)) ); @@ -694,7 +689,7 @@ TEST(gather_gpu_fp16, d22_axisY) { auto outputs = network.execute(); auto output = outputs.at("gather").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 1.f, 2.f, 3.f, 2.f, 4.f, 5.f, 6.f, 5.f, 7.f, 8.f, 9.f, 8.f, 10.f, 11.f, 12.f, 11.f @@ -722,10 +717,10 @@ TEST(gather_gpu_fp16, d22_axisF) { // Output: // 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 3.f, 4.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 9.f, 10.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 3, 1, 2 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 3, 1, 2 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes auto axis = cldnn::gather::gather_axis::along_f; set_values(input1, { @@ -741,8 +736,8 @@ TEST(gather_gpu_fp16, d22_axisF) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); topology.add( gather("gather", "InputDictionary", "InputText", axis, format::bfyx, tensor(2, 2, 2, 2)) ); @@ -755,7 +750,7 @@ TEST(gather_gpu_fp16, d22_axisF) { auto outputs = network.execute(); auto output = outputs.at("gather").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 3.f, 4.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 9.f, 10.f @@ -782,10 +777,10 @@ TEST(gather_gpu_fp32, d14_axisB) { // Output: // 1.f, 2.f, 3.f, 4.f, 3.f, 4.f, 1.f, 2.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 4, 1, 1 } }); // Indexes + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 4, 1, 1 } }); // Indexes auto axis = cldnn::gather::gather_axis::along_b; set_values(input1, { @@ -799,8 +794,8 @@ TEST(gather_gpu_fp32, d14_axisB) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); topology.add( gather("gather", "InputDictionary", "InputText", axis, format::bfyx, tensor(1, 4, 1, 2)) ); @@ -813,7 +808,7 @@ TEST(gather_gpu_fp32, d14_axisB) { auto outputs = network.execute(); auto output = outputs.at("gather").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 1.f, 2.f, 3.f, 4.f, 3.f, 4.f, 1.f, 2.f @@ -841,10 +836,10 @@ TEST(gather_gpu_fp32, d222_axisB) { // Output: // 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 5.f, 6.f, 7.f, 8.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 3, 2, 1, 2 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 3, 2, 1, 2 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes auto axis = cldnn::gather::gather_axis::along_b; set_values(input1, { @@ -860,8 +855,8 @@ TEST(gather_gpu_fp32, d222_axisB) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); topology.add( gather("gather", "InputDictionary", "InputText", axis, format::bfyx, tensor(2, 2, 2, 2)) ); @@ -874,7 +869,7 @@ TEST(gather_gpu_fp32, d222_axisB) { auto outputs = network.execute(); auto output = outputs.at("gather").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 5.f, 6.f, 7.f, 8.f @@ -902,10 +897,10 @@ TEST(gather_gpu_fp32, d22_axisY) { // Output: // 1.f, 2.f, 3.f, 2.f, 4.f, 5.f, 6.f, 5.f, 7.f, 8.f, 9.f, 8.f, 10.f, 11.f, 12.f, 11.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 3 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 3 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes auto axis = cldnn::gather::gather_axis::along_y; set_values(input1, { @@ -921,8 +916,8 @@ TEST(gather_gpu_fp32, d22_axisY) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); topology.add( gather("gather", "InputDictionary", "InputText", axis, format::bfyx, tensor(2, 2, 2, 2)) ); @@ -935,7 +930,7 @@ TEST(gather_gpu_fp32, d22_axisY) { auto outputs = network.execute(); auto output = outputs.at("gather").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 1.f, 2.f, 3.f, 2.f, 4.f, 5.f, 6.f, 5.f, 7.f, 8.f, 9.f, 8.f, 10.f, 11.f, 12.f, 11.f @@ -963,10 +958,10 @@ TEST(gather_gpu_fp32, d22_axisF) { // Output: // 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 3.f, 4.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 9.f, 10.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 3, 1, 2 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 3, 1, 2 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes auto axis = cldnn::gather::gather_axis::along_f; set_values(input1, { @@ -982,8 +977,8 @@ TEST(gather_gpu_fp32, d22_axisF) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); topology.add( gather("gather", "InputDictionary", "InputText", axis, format::bfyx, tensor(2, 2, 2, 2)) ); @@ -996,7 +991,7 @@ TEST(gather_gpu_fp32, d22_axisF) { auto outputs = network.execute(); auto output = outputs.at("gather").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 3.f, 4.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 9.f, 10.f @@ -1024,10 +1019,10 @@ TEST(gather_gpu_int32, d22_axisF) { // Output: // 1, 2, 3, 4, 5, 6, 3, 4, 7, 8, 9, 10, 11, 12, 9, 10 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::i32, format::bfyx, { 2, 3, 1, 2 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::i32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes + auto input1 = engine.allocate_memory({ data_types::i32, format::bfyx, { 2, 3, 1, 2 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::i32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes auto axis = cldnn::gather::gather_axis::along_f; set_values(input1, { @@ -1043,8 +1038,8 @@ TEST(gather_gpu_int32, d22_axisF) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); topology.add( gather("gather", "InputDictionary", "InputText", axis, format::bfyx, tensor(2, 2, 2, 2)) ); @@ -1057,7 +1052,7 @@ TEST(gather_gpu_int32, d22_axisF) { auto outputs = network.execute(); auto output = outputs.at("gather").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 1, 2, 3, 4, 5, 6, 3, 4, 7, 8, 9, 10, 11, 12, 9, 10 @@ -1084,10 +1079,10 @@ TEST(gather_gpu_int32, d14_axisB) { // Output: // 1, 2, 3, 4, 3, 4, 1, 2 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::i32, format::bfyx, { 2, 2, 1, 1 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::i32, format::bfyx, { 1, 4, 1, 1 } }); // Indexes + auto input1 = engine.allocate_memory({ data_types::i32, format::bfyx, { 2, 2, 1, 1 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::i32, format::bfyx, { 1, 4, 1, 1 } }); // Indexes auto axis = cldnn::gather::gather_axis::along_b; set_values(input1, { @@ -1101,8 +1096,8 @@ TEST(gather_gpu_int32, d14_axisB) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); topology.add( gather("gather", "InputDictionary", "InputText", axis, format::bfyx, tensor(1, 4, 1, 2)) ); @@ -1115,7 +1110,7 @@ TEST(gather_gpu_int32, d14_axisB) { auto outputs = network.execute(); auto output = outputs.at("gather").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 1, 2, 3, 4, 3, 4, 1, 2 @@ -1143,10 +1138,10 @@ TEST(gather_gpu_int32, d222_axisB) { // Output: // 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 5, 6, 7, 8 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 2, 1, 2 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::i32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes + auto input1 = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 2, 1, 2 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::i32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes auto axis = cldnn::gather::gather_axis::along_b; set_values(input1, { @@ -1162,8 +1157,8 @@ TEST(gather_gpu_int32, d222_axisB) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); topology.add( gather("gather", "InputDictionary", "InputText", axis, format::bfyx, tensor(2, 2, 2, 2)) ); @@ -1176,7 +1171,7 @@ TEST(gather_gpu_int32, d222_axisB) { auto outputs = network.execute(); auto output = outputs.at("gather").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 5, 6, 7, 8 @@ -1204,10 +1199,10 @@ TEST(gather_gpu_int32, d22_axisY) { // Output: // 1, 2, 3, 2, 4, 5, 6, 5, 7, 8, 9, 8, 10, 11, 12, 11 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::i32, format::bfyx, { 2, 2, 1, 3 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::i32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes + auto input1 = engine.allocate_memory({ data_types::i32, format::bfyx, { 2, 2, 1, 3 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::i32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes auto axis = cldnn::gather::gather_axis::along_y; set_values(input1, { @@ -1223,8 +1218,8 @@ TEST(gather_gpu_int32, d22_axisY) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); topology.add( gather("gather", "InputDictionary", "InputText", axis, format::bfyx, tensor(2, 2, 2, 2)) ); @@ -1237,7 +1232,7 @@ TEST(gather_gpu_int32, d22_axisY) { auto outputs = network.execute(); auto output = outputs.at("gather").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 1, 2, 3, 2, 4, 5, 6, 5, 7, 8, 9, 8, 10, 11, 12, 11 @@ -1268,10 +1263,10 @@ TEST(gather_gpu_fp32, d41_axisB) { // 7, 8, 9, 10, 11, 12 // 1, 2, 3, 4, 5, 6, - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 3 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); // Indexes + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 3 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); // Indexes auto axis = cldnn::gather::gather_axis::along_b; set_values(input1, { @@ -1287,8 +1282,8 @@ TEST(gather_gpu_fp32, d41_axisB) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); topology.add( gather("gather", "InputDictionary", "InputText", axis, format::bfyx, tensor(4, 1, 3, 2)) ); @@ -1301,7 +1296,7 @@ TEST(gather_gpu_fp32, d41_axisB) { auto outputs = network.execute(); auto output = outputs.at("gather").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, @@ -1334,10 +1329,10 @@ TEST(gather_gpu_fp32, d41_axisF) { // 3, 4, 1, 2, 3, 4, 5, 6, // 9, 10, 7, 8, 9, 10, 11, 12 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 3, 1, 2 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); // Indexes + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 3, 1, 2 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); // Indexes auto axis = cldnn::gather::gather_axis::along_f; set_values(input1, { @@ -1350,8 +1345,8 @@ TEST(gather_gpu_fp32, d41_axisF) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); topology.add( gather("gather", "InputDictionary", "InputText", axis, format::bfyx, tensor(2, 4, 2, 1)) ); @@ -1364,7 +1359,7 @@ TEST(gather_gpu_fp32, d41_axisF) { auto outputs = network.execute(); auto output = outputs.at("gather").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 3.f, 4.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, @@ -1393,10 +1388,10 @@ TEST(gather_gpu_fp32, d2_axisX) { // Output: // 1, 1, 2, 2, 3, 3, 4, 4 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::i32, format::bfyx, { 2, 1, 1, 1 } }); // Indexes + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::i32, format::bfyx, { 2, 1, 1, 1 } }); // Indexes auto axis = cldnn::gather::gather_axis::along_x; set_values(input1, { @@ -1409,8 +1404,8 @@ TEST(gather_gpu_fp32, d2_axisX) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); topology.add( gather("gather", "InputDictionary", "InputText", axis, format::bfyx, tensor(2, 2, 2, 1)) ); @@ -1423,7 +1418,7 @@ TEST(gather_gpu_fp32, d2_axisX) { auto outputs = network.execute(); auto output = outputs.at("gather").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 1.f, 1.f, 2.f, 2.f, @@ -1443,10 +1438,10 @@ TEST(gather_gpu_fp32, 322_axisF) { // Output : 3x2x2x1 // Input values in i32 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 3, 1, 1 } }); // data - auto input2 = memory::allocate(engine, { data_types::i32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes + auto input1 = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 3, 1, 1 } }); // data + auto input2 = engine.allocate_memory({ data_types::i32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes auto axis = cldnn::gather::gather_axis::along_f; set_values(input1, { @@ -1459,8 +1454,8 @@ TEST(gather_gpu_fp32, 322_axisF) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); topology.add( gather("gather", "InputDictionary", "InputText", axis, format::bfyx, tensor(3, 2, 1, 2)) ); @@ -1473,7 +1468,7 @@ TEST(gather_gpu_fp32, 322_axisF) { auto outputs = network.execute(); auto output = outputs.at("gather").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 1, 0, 2, 1, 11, 10, 12, 11, 21, 20, 22, 21 diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/gather_nd_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/gather_nd_gpu_test.cpp index 2999969928772b..9be5392902a836 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/gather_nd_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/gather_nd_gpu_test.cpp @@ -1,41 +1,25 @@ -// Copyright (c) 2021 Intel Corporation +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include +#include "test_utils.h" -#include -#include -#include -#include -#include +#include +#include -#include -#include using namespace cldnn; using namespace ::tests; -inline void DoTest(const engine& engine, - const cldnn::memory& input0, - const cldnn::memory& input1, +inline void DoTest(engine& engine, + const cldnn::memory::ptr input0, + const cldnn::memory::ptr input1, const std::vector& expected_results, const int indices_rank, const int batch_dims) { topology topology; - topology.add(input_layout("InputData", input0.get_layout())); - topology.add(input_layout("InputIndices", input1.get_layout())); + topology.add(input_layout("InputData", input0->get_layout())); + topology.add(input_layout("InputIndices", input1->get_layout())); topology.add( gather_nd("gather_nd", "InputData", "InputIndices", indices_rank, batch_dims) ); @@ -46,7 +30,7 @@ inline void DoTest(const engine& engine, network.set_input_data("InputIndices", input1); auto outputs = network.execute(); auto output = outputs.at("gather_nd").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], float16_to_float32(output_ptr[i])); @@ -54,12 +38,12 @@ inline void DoTest(const engine& engine, } TEST(gather_nd_gpu_fp16, d23322_i231312_ir6_batch2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int indices_rank = 6; const int batch_dims = 2; - auto input0 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 2, 3, 2, 2, 3 } }); // data - auto input1 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 3, 2, 1, 3, 1 } }); // indices + auto input0 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 2, 3, 2, 2, 3 } }); // data + auto input1 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 3, 2, 1, 3, 1 } }); // indices // expected output dim: {6,1,3,1,2} set_values(input0, { @@ -96,12 +80,12 @@ TEST(gather_nd_gpu_fp16, d23322_i231312_ir6_batch2) { } TEST(gather_nd_gpu_fp16, d231322_i231321_ir6_batch5) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int indices_rank = 6; const int batch_dims = 5; - auto input0 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 3, 2, 2, 3, 1 } }); // data - auto input1 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 3, 1, 2, 3, 1 } }); // indices + auto input0 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 3, 2, 2, 3, 1 } }); // data + auto input1 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 3, 1, 2, 3, 1 } }); // indices // expected output dim: {36} set_values(input0, { @@ -138,12 +122,12 @@ TEST(gather_nd_gpu_fp16, d231322_i231321_ir6_batch5) { } TEST(gather_nd_gpu_fp16, d23322_i23321_ir5_batch4) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int indices_rank = 5; const int batch_dims = 4; - auto input0 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 2, 3, 2, 2, 3 } }); // data - auto input1 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 2, 3, 1, 2, 3 } }); // indices + auto input0 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 2, 3, 2, 2, 3 } }); // data + auto input1 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 2, 3, 1, 2, 3 } }); // indices // expected output dim: {36} set_values(input0, { @@ -180,12 +164,12 @@ TEST(gather_nd_gpu_fp16, d23322_i23321_ir5_batch4) { } TEST(gather_nd_gpu_fp16, d23223_i2321_ir4_batch3) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int indices_rank = 4; const int batch_dims = 3; - auto input0 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 2, 3, 3, 2, 2 } }); // data - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 3, 1, 2 } }); // indices + auto input0 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 2, 3, 3, 2, 2 } }); // data + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 3, 1, 2 } }); // indices // expected output dim: {2*3*2,3} set_values(input0, { @@ -222,12 +206,12 @@ TEST(gather_nd_gpu_fp16, d23223_i2321_ir4_batch3) { } TEST(gather_nd_gpu_fp16, d2342_i2312_ir4_batch2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int indices_rank = 4; const int batch_dims = 2; - auto input0 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 3, 2, 4 } }); // data - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 3, 2, 1 } }); // indices + auto input0 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 3, 2, 4 } }); // data + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 3, 2, 1 } }); // indices // expected output dim: {6,1} set_values(input0, { @@ -264,12 +248,12 @@ TEST(gather_nd_gpu_fp16, d2342_i2312_ir4_batch2) { } TEST(gather_nd_gpu_fp16, d234_i2311_ir4_batch2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int indices_rank = 4; const int batch_dims = 2; - auto input0 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 3, 1, 4 } }); // data - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 3, 1, 1 } }); // indices + auto input0 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 3, 1, 4 } }); // data + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 3, 1, 1 } }); // indices // expected output dim: {6,1,1} set_values(input0, { @@ -307,12 +291,12 @@ TEST(gather_nd_gpu_fp16, d234_i2311_ir4_batch2) { } TEST(gather_nd_gpu_fp16, d234_i21_ir2_batch1) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int indices_rank = 2; const int batch_dims = 1; - auto input0 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 3, 1, 4 } }); // data - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); // indices + auto input0 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 3, 1, 4 } }); // data + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); // indices // expected output dim: {2,4} set_values(input0, { @@ -340,12 +324,12 @@ TEST(gather_nd_gpu_fp16, d234_i21_ir2_batch1) { } TEST(gather_nd_gpu_fp16, d22_i21_ir2_batch1) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int indices_rank = 2; const int batch_dims = 1; - auto input0 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); // data - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); // indices + auto input0 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); // data + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); // indices // expected output dim: 2 set_values(input0, { @@ -367,12 +351,12 @@ TEST(gather_nd_gpu_fp16, d22_i21_ir2_batch1) { } TEST(gather_nd_gpu_fp16, d3223_i321113_ir6_batch0) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int indices_rank = 6; const int batch_dims = 0; - auto input0 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 2, 3, 2 } }); // data - auto input1 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 3, 2, 3, 1, 1, 1 } }); // indices + auto input0 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 2, 3, 2 } }); // data + auto input1 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 3, 2, 3, 1, 1, 1 } }); // indices // expected output dim: 321113 set_values(input0, { @@ -412,12 +396,12 @@ TEST(gather_nd_gpu_fp16, d3223_i321113_ir6_batch0) { } TEST(gather_nd_gpu_fp16, d3221_i32312_ir3_batch0) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int indices_rank = 3; const int batch_dims = 0; - auto input0 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 3, 2, 2, 1, 3 } }); // data - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 2, 1, 2 } }); // indices + auto input0 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 3, 2, 2, 1, 3 } }); // data + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 2, 1, 2 } }); // indices // expected output dim: 32312 set_values(input0, { @@ -457,12 +441,12 @@ TEST(gather_nd_gpu_fp16, d3221_i32312_ir3_batch0) { } TEST(gather_nd_gpu_fp16, d3231_i32312_ir3_batch0) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int indices_rank = 3; const int batch_dims = 0; - auto input0 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 3, 2, 2, 1, 3 } }); // data - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 2, 1, 3 } }); // indices + auto input0 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 3, 2, 2, 1, 3 } }); // data + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 2, 1, 3 } }); // indices // expected output dim: {3,2,1,2} set_values(input0, { @@ -502,12 +486,12 @@ TEST(gather_nd_gpu_fp16, d3231_i32312_ir3_batch0) { } TEST(gather_nd_gpu_fp16, d3112_i3221_ir4_batch0) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int indices_rank = 4; const int batch_dims = 0; - auto input0 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 1, 2, 1 } }); // data - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 2, 1, 2 } }); // indices + auto input0 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 1, 2, 1 } }); // data + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 2, 1, 2 } }); // indices // expected output dim: {3,2,2,1,1,2} set_values(input0, { @@ -542,12 +526,12 @@ TEST(gather_nd_gpu_fp16, d3112_i3221_ir4_batch0) { } TEST(gather_nd_gpu_fp16, d311211_i322111_ir4_batch0) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int indices_rank = 4; const int batch_dims = 0; - auto input0 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 3, 1, 1, 1, 2, 1 } }); // data - auto input1 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 3, 2, 1, 1, 1, 2 } }); // indices + auto input0 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 3, 1, 1, 1, 2, 1 } }); // data + auto input1 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 3, 2, 1, 1, 1, 2 } }); // indices // expected output dim: {3,2,2,1,1,2,1,1} set_values(input0, { @@ -582,12 +566,12 @@ TEST(gather_nd_gpu_fp16, d311211_i322111_ir4_batch0) { } TEST(gather_nd_gpu_fp16, d3332_i3223_ir4_batch0) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int indices_rank = 4; const int batch_dims = 0; - auto input0 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 3, 3, 2 } }); // data - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 2, 3, 2 } }); // indices + auto input0 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 3, 3, 2 } }); // data + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 2, 3, 2 } }); // indices set_values(input0, { FLOAT16(1), FLOAT16(2), FLOAT16(3), FLOAT16(4), FLOAT16(5), FLOAT16(6), @@ -629,12 +613,12 @@ TEST(gather_nd_gpu_fp16, d3332_i3223_ir4_batch0) { } TEST(gather_nd_gpu_fp16, d3323_i322_ir3_batch0) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int indices_rank = 3; const int batch_dims = 0; - auto input0 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 3, 3, 2 } }); // data - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 2, 1, 2 } }); // indices + auto input0 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 3, 3, 2 } }); // data + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 2, 1, 2 } }); // indices set_values(input0, { FLOAT16(1), FLOAT16(2), FLOAT16(3), FLOAT16(4), FLOAT16(5), FLOAT16(6), @@ -676,12 +660,12 @@ TEST(gather_nd_gpu_fp16, d3323_i322_ir3_batch0) { } TEST(gather_nd_gpu_fp16, d22_i21_ir2_batch0) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int indices_rank = 2; const int batch_dims = 0; - auto input0 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); // data - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); // indices + auto input0 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); // data + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); // indices set_values(input0, { FLOAT16(1), FLOAT16(2), @@ -701,12 +685,12 @@ TEST(gather_nd_gpu_fp16, d22_i21_ir2_batch0) { } TEST(gather_nd_gpu_fp16, d22_i32_ir2_batch0) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int indices_rank = 2; const int batch_dims = 0; - auto input0 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); // data - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 2, 1, 1 } }); // indices + auto input0 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); // data + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 2, 1, 1 } }); // indices set_values(input0, { FLOAT16(1), FLOAT16(2), @@ -727,4 +711,3 @@ TEST(gather_nd_gpu_fp16, d22_i32_ir2_batch0) { DoTest(engine,input0, input1, expected_results, indices_rank, batch_dims); } - diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/gemm_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/gemm_gpu_test.cpp index 136c1a3c107f04..ae1ca356924dcf 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/gemm_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/gemm_gpu_test.cpp @@ -3,17 +3,11 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include -#include -#include -#include +#include "test_utils.h" -#include "test_utils/test_utils.h" -#include "test_utils/uniform_quantized_real_distribution.hpp" +#include +#include #include @@ -21,14 +15,14 @@ using namespace cldnn; using namespace ::tests; TEST(gemm_gpu, basic_bfyx_t1) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 3, 4 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 4 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 3, 4 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 4 } }); std::vector input_data = { - 1.f, -2.f, 3.f, - -4.f, 5.f, 6.f, - 1.f, 2.f, 3.f, + 1.f, -2.f, 3.f, + -4.f, 5.f, 6.f, + 1.f, 2.f, 3.f, 3.f, 2.f, -1.f, }; @@ -48,10 +42,10 @@ TEST(gemm_gpu, basic_bfyx_t1) { topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( - input_layout("input2", input2.get_layout()) + input_layout("input2", input2->get_layout()) ); topology.add( gemm("output", { "input", "input2" }, data_types::f32, true, false) @@ -63,7 +57,7 @@ TEST(gemm_gpu, basic_bfyx_t1) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); EXPECT_EQ(output_ptr.size(), (uint32_t)3); for (uint32_t i = 0; i < out_data.size(); ++i) { @@ -71,13 +65,13 @@ TEST(gemm_gpu, basic_bfyx_t1) { } } TEST(gemm_gpu, basic_bfyx_t2) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 4, 3 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 4, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 4, 3 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 4, 1 } }); std::vector input_data = { - 1.f, -2.f, 3.f, -4.f, - 5.f, 6.f, 1.f, 2.f, + 1.f, -2.f, 3.f, -4.f, + 5.f, 6.f, 1.f, 2.f, 3.f, 3.f, 2.f, -1.f, }; @@ -94,10 +88,10 @@ TEST(gemm_gpu, basic_bfyx_t2) { topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( - input_layout("input2", input2.get_layout()) + input_layout("input2", input2->get_layout()) ); topology.add( gemm("output", { "input", "input2" }, data_types::f32, false, true) @@ -109,7 +103,7 @@ TEST(gemm_gpu, basic_bfyx_t2) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); EXPECT_EQ(output_ptr.size(), (uint32_t)3); for (uint32_t i = 0; i < out_data.size(); ++i) { @@ -118,14 +112,14 @@ TEST(gemm_gpu, basic_bfyx_t2) { } TEST(gemm_gpu, basic_bfyx_t1t2) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 1, 3, 4 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 1, 4, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 1, 3, 4 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 1, 4, 1 } }); std::vector input_data = { - 1.f, -2.f, 3.f, - -4.f, 5.f, 6.f, - 1.f, 2.f, 3.f, + 1.f, -2.f, 3.f, + -4.f, 5.f, 6.f, + 1.f, 2.f, 3.f, 3.f, 2.f, -1.f, 1.f, -2.f, 3.f, @@ -150,10 +144,10 @@ TEST(gemm_gpu, basic_bfyx_t1t2) { topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( - input_layout("input2", input2.get_layout()) + input_layout("input2", input2->get_layout()) ); topology.add( gemm("output", { "input", "input2" }, data_types::f32, true, true) @@ -165,7 +159,7 @@ TEST(gemm_gpu, basic_bfyx_t1t2) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); EXPECT_EQ(output_ptr.size(), (uint32_t)6); for (uint32_t i = 0; i < out_data.size(); ++i) { @@ -174,19 +168,19 @@ TEST(gemm_gpu, basic_bfyx_t1t2) { } TEST(gemm_gpu, basic_input3) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 3, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 2, 3 } }); - auto input3 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 2, 2 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 3, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 2, 3 } }); + auto input3 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 2, 2 } }); float alpha = 2.f; float beta = 10.f; - std::vector input_data = { + std::vector input_data = { 1.0f, 2.0f, 3.0f, 1.0f, 0.0f, 1.0f }; - std::vector input_data2 = { + std::vector input_data2 = { 3.0f, 3.0f, 1.0f, 2.0f, 1.0f, 2.0f, @@ -208,13 +202,13 @@ TEST(gemm_gpu, basic_input3) { topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( - input_layout("input2", input2.get_layout()) + input_layout("input2", input2->get_layout()) ); topology.add( - input_layout("input3", input3.get_layout()) + input_layout("input3", input3->get_layout()) ); topology.add( gemm("output", { "input", "input2", "input3" }, data_types::f32, false, false, alpha, beta) @@ -227,20 +221,20 @@ TEST(gemm_gpu, basic_input3) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); EXPECT_EQ(output_ptr.size(), (uint32_t)4); - for (uint32_t i = 0; i < out_data.size(); ++i) { + for (uint32_t i = 0; i < out_data.size(); ++i) { EXPECT_FLOAT_EQ(output_ptr[i], out_data[i]); } } TEST(gemm_gpu, basic_input3_t1t2) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 4, 3 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 3, 2 } }); - auto input3 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 2, 4 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 4, 3 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 3, 2 } }); + auto input3 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 2, 4 } }); float alpha = 2.f; float beta = 3.f; @@ -251,7 +245,7 @@ TEST(gemm_gpu, basic_input3_t1t2) { }; std::vector input_data2 = { - 3.0f, 3.0f, 1.0f, + 3.0f, 3.0f, 1.0f, 2.0f, 1.0f, 2.0f, }; @@ -275,13 +269,13 @@ TEST(gemm_gpu, basic_input3_t1t2) { topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( - input_layout("input2", input2.get_layout()) + input_layout("input2", input2->get_layout()) ); topology.add( - input_layout("input3", input3.get_layout()) + input_layout("input3", input3->get_layout()) ); topology.add( gemm("output", { "input", "input2", "input3" }, data_types::f32, true, true, alpha, beta) @@ -294,7 +288,7 @@ TEST(gemm_gpu, basic_input3_t1t2) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); EXPECT_EQ(output_ptr.size(), (uint32_t)8); @@ -303,10 +297,10 @@ TEST(gemm_gpu, basic_input3_t1t2) { } } TEST(gemm_gpu, basic_input3_1) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 3, 4 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 2, 3 } }); - auto input3 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 2, 4 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 3, 4 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 2, 3 } }); + auto input3 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 2, 4 } }); float alpha = 2.f; float beta = 3.f; @@ -343,13 +337,13 @@ TEST(gemm_gpu, basic_input3_1) { topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( - input_layout("input2", input2.get_layout()) + input_layout("input2", input2->get_layout()) ); topology.add( - input_layout("input3", input3.get_layout()) + input_layout("input3", input3->get_layout()) ); topology.add( gemm("output", { "input", "input2", "input3" }, data_types::f32, false, false, alpha, beta) @@ -363,7 +357,7 @@ TEST(gemm_gpu, basic_input3_1) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); EXPECT_EQ(output_ptr.size(), (uint32_t)8); @@ -373,10 +367,10 @@ TEST(gemm_gpu, basic_input3_1) { } TEST(gemm_gpu, basic_input3_t2) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 3, 4 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 3, 2 } }); - auto input3 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 2, 4 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 3, 4 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 3, 2 } }); + auto input3 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 2, 4 } }); float alpha = 2.f; float beta = 3.f; @@ -412,13 +406,13 @@ TEST(gemm_gpu, basic_input3_t2) { topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( - input_layout("input2", input2.get_layout()) + input_layout("input2", input2->get_layout()) ); topology.add( - input_layout("input3", input3.get_layout()) + input_layout("input3", input3->get_layout()) ); topology.add( gemm("output", { "input", "input2", "input3" }, data_types::f32, false, true, alpha, beta) @@ -431,7 +425,7 @@ TEST(gemm_gpu, basic_input3_t2) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); EXPECT_EQ(output_ptr.size(), (uint32_t)8); @@ -441,10 +435,10 @@ TEST(gemm_gpu, basic_input3_t2) { } TEST(gemm_gpu, basic_input3_t1) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 4, 3 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 2, 3 } }); - auto input3 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 2, 4 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 4, 3 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 2, 3 } }); + auto input3 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 2, 4 } }); float alpha = 2.f; float beta = 3.f; @@ -480,13 +474,13 @@ TEST(gemm_gpu, basic_input3_t1) { topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( - input_layout("input2", input2.get_layout()) + input_layout("input2", input2->get_layout()) ); topology.add( - input_layout("input3", input3.get_layout()) + input_layout("input3", input3->get_layout()) ); topology.add( gemm("output", { "input", "input2", "input3" }, data_types::f32, true, false, alpha, beta) @@ -499,7 +493,7 @@ TEST(gemm_gpu, basic_input3_t1) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); EXPECT_EQ(output_ptr.size(), (uint32_t)8); @@ -509,13 +503,13 @@ TEST(gemm_gpu, basic_input3_t1) { } TEST(gemm_gpu, basic_bfyx) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 1, 4, 3 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 1, 1, 4 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 1, 4, 3 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 1, 1, 4 } }); std::vector input_data = { - 1.f, -2.f, 3.f, -4.f, - 5.f, 6.f, 7.f, 8.f, + 1.f, -2.f, 3.f, -4.f, + 5.f, 6.f, 7.f, 8.f, -10.f, 12.f, 13.f, -13.f, 1.f, -2.f, 3.f, -4.f, @@ -524,9 +518,9 @@ TEST(gemm_gpu, basic_bfyx) { }; std::vector input_data2 = { - 2.f, - 5.f, - -4.f, + 2.f, + 5.f, + -4.f, -7.f, 2.f, 5.f, @@ -542,10 +536,10 @@ TEST(gemm_gpu, basic_bfyx) { topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( - input_layout("input2", input2.get_layout()) + input_layout("input2", input2->get_layout()) ); topology.add( gemm("output", { "input", "input2" }, data_types::f32) @@ -557,9 +551,9 @@ TEST(gemm_gpu, basic_bfyx) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + - EXPECT_EQ(output_ptr.size(), (uint32_t)6); for (uint32_t i = 0; i < out_data.size(); ++i) { EXPECT_FLOAT_EQ(output_ptr[i], out_data[i]); @@ -567,9 +561,9 @@ TEST(gemm_gpu, basic_bfyx) { } TEST(gemm_gpu, basic3_bfyx) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 5, 1, 500, 9 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 5, 1, 1, 500 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 5, 1, 500, 9 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 5, 1, 1, 500 } }); std::vector input_data = { -0.000449777f, -0.000137405f, -0.0762075f, 0.000949166f, 0.0346124f, -0.0111424f, 0.0108357f, 0.0121679f, 0.0242749f, 0.052692f, -0.0017713f, 0.0053728f, 0.0128862f, -0.0162366f, 0.0125041f, -0.00602398f, 0.0107778f, -0.00323086f, -0.00914208f, -0.013884f, 0.00755173f, -0.0175622f, 0.00473339f, -0.015003f, -0.0238219f, 0.004502f, 0.00187154f, 0.0041163f, -9.36184e-05f, 0.00873372f, 0.0121869f, -0.020973f, -0.006006f, -0.0038208f, 0.00210471f, 0.00255549f, -0.0251856f, -0.0626372f, -0.0059258f, -0.0058662f, -0.0946306f, 0.00197436f, 0.00105865f, -0.0033595f, 0.0158977f, -0.0036025f, -0.00568902f, -0.0202577f, -0.000251319f, -0.0117895f, -0.0144239f, -0.0144024f, -0.0150431f, -0.0354826f, -0.0135123f, -0.000422157f, 0.0286438f, -0.000884989f, -0.00675718f, 0.013241f, -0.0118388f, 0.0321394f, -0.000803071f, 0.11408f, -0.00806301f, -0.00831608f, 0.0165189f, 0.016094f, -0.000449332f, -0.00695901f, 0.0437514f, -0.00172117f, 0.00180391f, -0.000859933f, -0.0144826f, 0.0262613f, -0.00194352f, -1.98829e-05f, -0.00902827f, -0.00400867f, -0.00600827f, 0.0120846f, -0.0162493f, 0.0418596f, 0.00131911f, -0.00631566f, 0.00270484f, -0.0950513f, 0.00726431f, -0.0169798f, -0.000554365f, -0.00256903f, -0.00885843f, 0.0104025f, 0.00590779f, -0.00175832f, 0.0168603f, 0.00964353f, -0.0180614f, 0.0213157f, 0.0209548f, -0.0231143f, -0.00121617f, -0.0129815f, -0.0199287f, 0.00863336f, -0.00464991f, 0.0162288f, -0.340115f, -0.011018f, -0.0593997f, 0.00644821f, 0.0416332f, 0.0394596f, 0.0172296f, 0.00494231f, 0.0143805f, -0.00819845f, 0.00196982f, 0.00393258f, 0.0246168f, -0.0235927f, 0.0131416f, -0.0190432f, -0.0237865f, -0.0155627f, 0.0265165f, 0.0162884f, 0.00321098f, 0.0136674f, -0.000966112f, -0.0100813f, -0.00604589f, 0.00889466f, 0.0113945f, 0.0264707f, 0.00371883f, -0.00843358f, 0.0145675f, 0.0048638f, 0.00110399f, -0.00130233f, 0.00740726f, -0.00393368f, -0.0242178f, 0.00341681f, 0.00115369f, -0.00297881f, -0.0844071f, 0.0537151f, -0.00209399f, 0.0310295f, 0.0383914f, 0.00456459f, 0.0188114f, -0.0177144f, 0.0133258f, 0.0584683f, -0.00640495f, 0.0175946f, 0.0186782f, 0.00213311f, 0.00393403f, 0.00382759f, 0.00267507f, 0.00493673f, -0.00856695f, -0.00627955f, -0.0103436f, -0.000671664f, -0.110419f, 0.0307264f, 0.0042176f, 0.0031638f, 0.0154172f, 0.00265482f, 0.0410853f, 0.00833895f, -0.0183989f, -0.000717906f, -0.0090387f, -0.00404523f, -0.00976238f, -0.0137555f, 0.000157289f, -0.00341186f, -0.0214878f, 0.0142639f, 0.00624623f, 0.000537292f, -0.0520912f, -0.0432221f, -0.00330415f, 0.0263942f, -0.00150974f, 0.00172088f, -0.0815726f, -0.0201155f, -0.00986346f, 0.0121252f, 0.00198959f, -0.0349936f, -0.00608366f, -0.00399543f, 0.0192487f, -0.0123156f, 0.0072797f, 0.000507143f, 0.0334805f, 0.000609379f, 0.00961966f, -0.00697663f, 0.00201967f, -0.0207349f, -0.0103385f, -0.00343849f, -0.00330492f, 0.035106f, -0.00456996f, 0.00197528f, 0.016148f, 0.0142903f, 0.0616483f, 0.0093118f, -0.0596028f, 0.00945764f, -0.00659242f, 0.118389f, -0.00259384f, -0.00285344f, 0.00567036f, 0.0195813f, -0.00461807f, -0.0608699f, 0.00380259f, 0.00143385f, -0.00466997f, 0.0194046f, -0.0198423f, -0.00334569f, -0.014399f, 0.0130021f, -0.0141619f, -0.00859914f, 0.00997122f, -0.0198446f, -0.0094162f, -0.0116609f, -0.0111888f, -0.00903524f, 0.00937981f, 0.01772f, -0.00236374f, -0.00870162f, 0.000141193f, -0.0343695f, -0.00997931f, 0.0073531f, -0.100394f, -0.00367661f, -0.00124499f, 0.00318026f, 0.0554203f, -0.00342582f, -0.0104147f, -0.0577869f, -0.0126485f, -0.0332496f, 0.0346141f, 0.0307962f, -0.0174745f, -0.0387339f, 0.0167707f, -0.0363424f, 0.0154902f, -0.0118644f, -4.63543e-06f, -0.0683506f, -0.0344076f, -0.00104884f, -0.00883997f, -0.00305185f, -0.0150299f, -0.0186403f, 0.0110238f, 0.00779224f, -0.0102231f, 0.0087488f, -0.0138988f, -0.0229105f, -0.0244903f, -0.0202919f, 0.00135903f, -0.00574432f, 0.00254918f, 0.0340209f, -0.046428f, -0.00670622f, 0.000925543f, -0.0249251f, -0.00275456f, 0.0199177f, 0.000210993f, 0.027762f, -0.0228046f, 0.0484813f, 0.00538959f, 0.0136714f, -0.00690097f, -0.0448533f, -0.00815204f, 0.00734891f, 0.0173959f, -0.0379109f, 0.0594617f, -0.00722084f, 0.0415935f, 0.014792f, -0.0170252f, -0.0139396f, 0.00146415f, 0.00117702f, 0.0685559f, 0.00727832f, -0.107566f, -0.0112505f, 0.033853f, 0.0046957f, -0.0242369f, 0.0148181f, -0.0723487f, -0.00961667f, 0.0304085f, -0.00520772f, -0.0316467f, 0.0327801f, -0.00755137f, 0.0166041f, -0.0557288f, -0.0227759f, -0.00314548f, 0.0152585f, 0.020071f, -0.0377076f, 0.00687613f, -0.0273935f, -0.00647955f, 0.0105047f, -0.0137238f, 0.023264f, -0.0455722f, -0.00221414f, -0.0258535f, -0.0236395f, 0.0593407f, 0.00448763f, 0.0150777f, 0.00437925f, 0.0295782f, -0.0344752f, 0.00365267f, 0.140464f, -0.0479012f, 0.025726f, 0.119063f, 0.000301925f, -0.00810565f, -0.354073f, -0.0723185f, -0.0046123f, 0.033882f, -0.044552f, -0.0138361f, 0.00384129f, 0.0139111f, -0.01667f, -0.0821503f, 0.0029974f, -0.0306725f, 0.0160366f, 0.0334754f, 0.0192693f, -0.00616713f, -0.00232275f, 0.0107987f, 0.00437057f, 0.0017298f, 0.0196916f, -0.0417255f, -0.00911193f, 0.00876709f, -0.00172422f, -0.00105248f, -0.0191631f, -0.00387423f, -0.0102766f, -0.025317f, -0.0416204f, -0.0319611f, -0.00359193f, 0.00424064f, -0.00575092f, -0.0282402f, 0.0745899f, -0.0126492f, -0.0162564f, -0.261967f, -0.705265f, -0.0403731f, -0.00209634f, -0.694297f, 0.00956909f, 0.0158826f, 0.0130207f, 0.003825f, -0.000300812f, -0.0121346f, 0.00642053f, -0.012902f, 0.0309272f, 0.0609192f, -0.00654145f, -0.0937578f, -0.00432024f, -0.00767539f, 0.0461248f, 0.00701077f, -0.0174477f, 0.00563833f, -0.0107107f, -0.0255275f, 0.00892488f, -0.00166062f, 0.039829f, -0.00150394f, 0.00742194f, -0.00885529f, -0.0103532f, 0.0777858f, 0.0885367f, -0.00425715f, 0.0423651f, -0.0446651f, -0.635069f, -0.00919329f, -0.00356176f, 0.00988705f, 0.0116529f, -0.0401253f, 0.00260105f, 0.00573955f, -0.0667439f, 0.101175f, 0.0765288f, -0.0120077f, 0.00322599f, -0.0192768f, 0.0382749f, -0.222119f, -0.0452036f, 0.0424303f, 0.0890699f, 0.0117557f, 0.0315167f, 0.0284256f, 0.00541845f, -0.250147f, 0.00420668f, -0.0189724f, -0.00416381f, -0.00162803f, -0.0108763f, -0.00970892f, 0.0134476f, -0.0254931f, 0.0307225f, 0.00128596f, 0.0171106f, 0.00467854f, -0.0124376f, 0.0183396f, 0.0021754f, 0.00170886f, -0.0226898f, 0.0250111f, -0.0533301f, -0.0163268f, 0.00618995f, 0.0416378f, 0.0475397f, 0.0105684f, -0.00440933f, 0.0496722f, -0.0215733f, -0.0256361f, -0.0285091f, -0.0276881f, -0.00102202f, -0.0720219f, -0.0296656f, @@ -3145,10 +3139,10 @@ TEST(gemm_gpu, basic3_bfyx) { topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( - input_layout("input2", input2.get_layout()) + input_layout("input2", input2->get_layout()) ); topology.add( gemm("output", { "input", "input2" }, data_types::f32) @@ -3160,7 +3154,7 @@ TEST(gemm_gpu, basic3_bfyx) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); EXPECT_EQ(output_ptr.size(), (uint32_t)45); for (uint32_t i = 0; i < out_data.size(); ++i) { @@ -3170,9 +3164,9 @@ TEST(gemm_gpu, basic3_bfyx) { } TEST(gemm_gpu, basic_smarcink2) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 1, 3, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 1, 2, 3 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 1, 3, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 1, 2, 3 } }); std::vector input_data = { 1.0f, 2.0f, 3.0f, @@ -3204,10 +3198,10 @@ TEST(gemm_gpu, basic_smarcink2) { topology topology; topology.add( - input_layout("input", input.get_layout()) + input_layout("input", input->get_layout()) ); topology.add( - input_layout("input2", input2.get_layout()) + input_layout("input2", input2->get_layout()) ); topology.add( gemm("output", { "input", "input2" }, data_types::f32) @@ -3219,7 +3213,7 @@ TEST(gemm_gpu, basic_smarcink2) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); EXPECT_EQ(output_ptr.size(), (uint32_t)8); for (uint32_t i = 0; i < out_data.size(); ++i) { @@ -3414,7 +3408,7 @@ class GemmBaseTest : public ::testing::TestWithParam { } void execute(gemm_params& p) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto y0_size = p.m_size; auto y0_pitch = p.k_size; @@ -3461,19 +3455,19 @@ class GemmBaseTest : public ::testing::TestWithParam { auto input0_size = tensor((int)p.b0_num, (int)p.f0_num, (int)x0_size, (int)y0_size); VVVVF input0_data = generate_random_4d(p.b0_num, p.f0_num, x0_size, y0_size, p.range0[0], p.range0[1], p.range0[2]); auto input0_data_bfyx = flatten_4d(format::bfyx, input0_data); - auto input0_mem = memory::allocate(engine, { p.allocate0_type, format::bfyx, input0_size }); + auto input0_mem = engine.allocate_memory({ p.allocate0_type, format::bfyx, input0_size }); set_values(input0_mem, input0_data_bfyx); auto input1_size = tensor((int)p.b1_num, (int)p.f1_num, (int)x1_size, (int)y1_size); VVVVF input1_data = generate_random_4d(p.b1_num, p.f1_num, x1_size, y1_size, p.range1[0], p.range1[1], p.range1[2]); auto input1_data_bfyx = flatten_4d(format::bfyx, input1_data); - auto input1_mem = memory::allocate(engine, { p.allocate1_type, format::bfyx, input1_size }); + auto input1_mem = engine.allocate_memory({ p.allocate1_type, format::bfyx, input1_size }); set_values(input1_mem, input1_data_bfyx); auto input2_size = tensor((int)p.b2_num, (int)p.f2_num, (int)x2_size, (int)y2_size); VVVVF input2_data = generate_random_4d(p.b2_num, p.f2_num, x2_size, y2_size, p.range2[0], p.range2[1], p.range2[2]); auto input2_data_bfyx = flatten_4d(format::bfyx, input2_data); - auto input2_mem = memory::allocate(engine, { p.allocate2_type, format::bfyx, input2_size }); + auto input2_mem = engine.allocate_memory({ p.allocate2_type, format::bfyx, input2_size }); set_values(input2_mem, input2_data_bfyx); std::vector out_data(p.b_out_num * p.f_out_num * p.m_size * p.n_size); @@ -3505,9 +3499,9 @@ class GemmBaseTest : public ::testing::TestWithParam { } topology topology; - topology.add(input_layout("input0", input0_mem.get_layout())); - topology.add(input_layout("input1", input1_mem.get_layout())); - topology.add(input_layout("input2", input2_mem.get_layout())); + topology.add(input_layout("input0", input0_mem->get_layout())); + topology.add(input_layout("input1", input1_mem->get_layout())); + topology.add(input_layout("input2", input2_mem->get_layout())); topology.add(gemm("gemm_bfyx", { "input0", "input1", "input2" }, p.output_type, p.transpose_input0, p.transpose_input1, p.alpha, p.beta)); topology.add(reorder("reorder_bfyx", "gemm_bfyx", format::bfyx, data_types::f32)); @@ -3521,7 +3515,7 @@ class GemmBaseTest : public ::testing::TestWithParam { network.set_input_data("input2", input2_mem); auto outputs = network.execute(); auto output = outputs.at("reorder_bfyx").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); EXPECT_EQ(output_ptr.size(), (size_t)(p.b_out_num * p.f_out_num * p.m_size * p.n_size)); if (sizeof(input0_type) == 1) { diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/loop_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/loop_gpu_test.cpp index 9a61d29f8e2652..37c0a0309497ac 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/loop_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/loop_gpu_test.cpp @@ -3,17 +3,18 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include "api/eltwise.hpp" -#include -#include + #include "test_utils/test_utils.h" -#include -#include -#include -#include + +#include +#include +#include +#include +#include "cldnn/primitives/eltwise.hpp" +#include +#include +#include +#include #include #include @@ -26,13 +27,13 @@ using namespace testing; TEST(loop_gpu, basic_no_concat) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_mem = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 4, 5 } }); - auto operand_mem = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 4, 5 } }); - auto trip_count_mem = memory::allocate(engine, { data_types::i32, format::bfyx, { 1, 1, 1, 1 } }); - auto initial_condition_mem = memory::allocate(engine, { data_types::i32, format::bfyx, { 1, 1, 1, 1 } }); - auto num_iteration_mem = memory::allocate(engine, { data_types::i32, format::bfyx, { 1, 1, 1, 1 } }); + auto input_mem = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 4, 5 } }); + auto operand_mem = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 4, 5 } }); + auto trip_count_mem = engine.allocate_memory({ data_types::i32, format::bfyx, { 1, 1, 1, 1 } }); + auto initial_condition_mem = engine.allocate_memory({ data_types::i32, format::bfyx, { 1, 1, 1, 1 } }); + auto num_iteration_mem = engine.allocate_memory({ data_types::i32, format::bfyx, { 1, 1, 1, 1 } }); std::vector input_data{ 1.0f, 2.0f, -15.f, 3.0f, 4.0f, -15.f, 5.0f, 6.0f, -15.f, 7.0f, @@ -65,9 +66,9 @@ TEST(loop_gpu, basic_no_concat) }; topology topology( - input_layout("input", input_mem.get_layout()), - input_layout("trip_count", trip_count_mem.get_layout()), - input_layout("initial_condition", initial_condition_mem.get_layout()), + input_layout("input", input_mem->get_layout()), + input_layout("trip_count", trip_count_mem->get_layout()), + input_layout("initial_condition", initial_condition_mem->get_layout()), mutable_data("num_iteration", num_iteration_mem), loop("loop", {"input"}, body, "trip_count", "initial_condition", "num_iteration", @@ -82,33 +83,33 @@ TEST(loop_gpu, basic_no_concat) auto outputs = network.execute(); EXPECT_EQ(outputs.size(), 1); auto output = outputs.begin()->second.get_memory(); - auto output_layout = output.get_layout(); + auto output_layout = output->get_layout(); EXPECT_EQ(output_layout.size.batch[0], 1); EXPECT_EQ(output_layout.size.feature[0], 1); EXPECT_EQ(output_layout.size.spatial[0], 4); EXPECT_EQ(output_layout.size.spatial[1], 5); - auto ptr = num_iteration_mem.pointer(); + mem_lock ptr{num_iteration_mem, get_test_stream()}; EXPECT_EQ(ptr[0], trip_count); // value check - auto output_ptr = output.pointer(); + mem_lock output_ptr{output, get_test_stream()}; EXPECT_EQ(output_ptr.size(), input_data.size()); - for (size_t i=0, iend = input_data.size(); i input_data{ 1.0f, 2.0f, -15.f, 3.0f, 4.0f, -15.f, 5.0f, 6.0f, -15.f, 7.0f, @@ -128,7 +129,7 @@ TEST(loop_gpu, basic_concat) set_values(initial_condition_mem, {initial_condition}); topology body( - input_layout("input", operand_mem.get_layout()), + input_layout("input", operand_mem->get_layout()), data("eltwise_operand", operand_mem), eltwise("eltwise", "input", "eltwise_operand", eltwise_mode::sum) ); @@ -139,9 +140,9 @@ TEST(loop_gpu, basic_concat) std::vector back_edges {}; topology topology( - input_layout("input", input_mem.get_layout()), - input_layout("trip_count", trip_count_mem.get_layout()), - input_layout("initial_condition", initial_condition_mem.get_layout()), + input_layout("input", input_mem->get_layout()), + input_layout("trip_count", trip_count_mem->get_layout()), + input_layout("initial_condition", initial_condition_mem->get_layout()), mutable_data("num_iteration", num_iteration_mem), loop("loop", {"input"}, body, "trip_count", "initial_condition", "num_iteration", @@ -156,19 +157,19 @@ TEST(loop_gpu, basic_concat) auto outputs = network.execute(); EXPECT_EQ(outputs.size(), 1); auto output = outputs.begin()->second.get_memory(); - auto output_layout = output.get_layout(); + auto output_layout = output->get_layout(); EXPECT_EQ(output_layout.size.batch[0], 1); EXPECT_EQ(output_layout.size.feature[0], 1); EXPECT_EQ(output_layout.size.spatial[0], 4); EXPECT_EQ(output_layout.size.spatial[1], 5); - auto ptr = num_iteration_mem.pointer(); + mem_lock ptr{num_iteration_mem, get_test_stream()}; const int32_t actual_iterations = ptr[0]; EXPECT_EQ(actual_iterations, trip_count); // value check - auto output_ptr = output.pointer(); + mem_lock output_ptr{output, get_test_stream()}; for (size_t i=0, iend = input_data.size(); iget_layout()), data("inner_eltwise_operand", inner_operand_mem), eltwise("inner_eltwise", "inner_input", "inner_eltwise_operand", eltwise_mode::sum) ); @@ -232,9 +233,9 @@ TEST(loop_gpu, basic_concat_nested) // set outer loop body ///////////////////////////////// topology outer_loop_body( - input_layout("inner_input", input_mem.get_layout()), - input_layout("trip_count", inner_trip_count_mem.get_layout()), - input_layout("initial_condition", inner_initial_condition_mem.get_layout()), + input_layout("inner_input", input_mem->get_layout()), + input_layout("trip_count", inner_trip_count_mem->get_layout()), + input_layout("initial_condition", inner_initial_condition_mem->get_layout()), mutable_data("inner_num_iteration", inner_num_iteration_mem), loop("inner_loop", {"inner_input", "trip_count", "initial_condition"}, inner_loop_body, "trip_count", "initial_condition", "inner_num_iteration", @@ -254,12 +255,12 @@ TEST(loop_gpu, basic_concat_nested) // set main topology ///////////////////////////////// topology main_topology( - input_layout("input", input_mem.get_layout()), - input_layout("trip_count", trip_count_mem.get_layout()), - input_layout("initial_condition", initial_condition_mem.get_layout()), + input_layout("input", input_mem->get_layout()), + input_layout("trip_count", trip_count_mem->get_layout()), + input_layout("initial_condition", initial_condition_mem->get_layout()), mutable_data("num_iteration", num_iteration_mem), - input_layout("inner_trip_count", inner_trip_count_mem.get_layout()), - input_layout("inner_initial_condition", inner_initial_condition_mem.get_layout()), + input_layout("inner_trip_count", inner_trip_count_mem->get_layout()), + input_layout("inner_initial_condition", inner_initial_condition_mem->get_layout()), loop("loop", {"input", "inner_trip_count", "inner_initial_condition"}, outer_loop_body, "trip_count", "initial_condition", "num_iteration", outer_input_primitive_maps, outer_output_primitive_maps, outer_back_edges, outer_trip_count) @@ -278,7 +279,7 @@ TEST(loop_gpu, basic_concat_nested) auto outputs = network.execute(); EXPECT_EQ(outputs.size(), 1); auto output = outputs.begin()->second.get_memory(); - auto output_layout = output.get_layout(); + auto output_layout = output->get_layout(); ///////////////////////////////// // calculate expected output @@ -303,16 +304,16 @@ TEST(loop_gpu, basic_concat_nested) EXPECT_EQ(output_layout.size.spatial[1], 5); // check trip count = actual iteration - auto inner_num_iteration_ptr = inner_num_iteration_mem.pointer(); + mem_lock inner_num_iteration_ptr{inner_num_iteration_mem, get_test_stream()}; int64_t inner_actual_iterations = inner_num_iteration_ptr[0]; EXPECT_EQ(inner_actual_iterations, inner_trip_count); - auto num_iteration_ptr = num_iteration_mem.pointer(); + mem_lock num_iteration_ptr{num_iteration_mem, get_test_stream()}; int64_t actual_iterations = num_iteration_ptr[0]; EXPECT_EQ(actual_iterations, outer_trip_count); // check output values EXPECT_EQ(output_layout.count(), expected.size()); - auto output_ptr = output.pointer(); + mem_lock output_ptr{output, get_test_stream()}; for (size_t i=0 ;i -#include -#include -#include -#include -#include -#include +#include "test_utils.h" -#include +#include +#include +#include using namespace cldnn; using namespace ::tests; @@ -20,14 +16,14 @@ using namespace ::tests; TEST(lrn_fp32_gpu, basic) { // input : 1x16x1x1 // Output : 1x16x1x1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const size_t b = 1; const size_t f = 16; const size_t y = 1; const size_t x = 1; - auto input = memory::allocate(engine, { data_types::f32, format::b_fs_yx_fsv16, { b, f, x, y } }); + auto input = engine.allocate_memory({ data_types::f32, format::b_fs_yx_fsv16, { b, f, x, y } }); std::vector inputVals(b * f * y * x); std::generate(inputVals.begin(), inputVals.end(), []() { static float n = 0; @@ -37,7 +33,7 @@ TEST(lrn_fp32_gpu, basic) { set_values(input, inputVals); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); uint32_t size = 2; float k = 0.5f; float alpha = 9.9e-05f; @@ -51,7 +47,7 @@ TEST(lrn_fp32_gpu, basic) { auto outputs = network.execute(); auto output = outputs.at("lrn").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 1.99901f, 3.99486f, 5.98519f, @@ -69,14 +65,14 @@ TEST(lrn_fp32_gpu, basic) { TEST(lrn_fp32_gpu, basic2) { // input : 1x16x1x1 // Output : 1x16x1x1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const size_t b = 1; const size_t f = 16; const size_t y = 1; const size_t x = 1; - auto input = memory::allocate(engine, { data_types::f32, format::b_fs_yx_fsv16, { b, f, x, y } }); + auto input = engine.allocate_memory({ data_types::f32, format::b_fs_yx_fsv16, { b, f, x, y } }); std::vector inputVals(b * f * y * x); std::generate(inputVals.begin(), inputVals.end(), []() { static float n = 0; @@ -86,7 +82,7 @@ TEST(lrn_fp32_gpu, basic2) { set_values(input, inputVals); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); uint32_t size = 5; float k = 0.5f; float alpha = 9.9e-05f; @@ -100,7 +96,7 @@ TEST(lrn_fp32_gpu, basic2) { auto outputs = network.execute(); auto output = outputs.at("lrn").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 1.99889f, 3.99525f, 5.98696f, @@ -118,14 +114,14 @@ TEST(lrn_fp32_gpu, basic2) { TEST(lrn_fp16_gpu, basic1) { // input : 1x16x1x1 // Output : 1x16x1x1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const size_t b = 1; const size_t f = 16; const size_t y = 1; const size_t x = 1; - auto input = memory::allocate(engine, { data_types::f16, format::b_fs_yx_fsv16, { b, f, x, y } }); + auto input = engine.allocate_memory({ data_types::f16, format::b_fs_yx_fsv16, { b, f, x, y } }); std::vector inputVals(b * f * y * x); std::generate(inputVals.begin(), inputVals.end(), []() { static float n = 0; @@ -135,7 +131,7 @@ TEST(lrn_fp16_gpu, basic1) { set_values(input, inputVals); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); uint32_t size = 5; float k = 0.5f; float alpha = 9.9e-05f; @@ -149,7 +145,7 @@ TEST(lrn_fp16_gpu, basic1) { auto outputs = network.execute(); auto output = outputs.at("lrn").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 1.99889f, 3.99525f, 5.98696f, @@ -167,14 +163,14 @@ TEST(lrn_fp16_gpu, basic1) { TEST(lrn_fp32_gpu, basic3) { // input : 2x16x4x4 // Output : 2x16x4x4 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const size_t b = 2; const size_t f = 16; const size_t y = 4; const size_t x = 4; - auto input = memory::allocate(engine, { data_types::f32, format::b_fs_yx_fsv16, { b, f, x, y } }); + auto input = engine.allocate_memory({ data_types::f32, format::b_fs_yx_fsv16, { b, f, x, y } }); std::vector inputVals(b * f * y * x); std::generate(inputVals.begin(), inputVals.end(), []() { static float n = 0; @@ -184,7 +180,7 @@ TEST(lrn_fp32_gpu, basic3) { set_values(input, inputVals); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); uint32_t size = 5; float k = 1.f; float alpha = 9.89999971e-05f; @@ -198,7 +194,7 @@ TEST(lrn_fp32_gpu, basic3) { auto outputs = network.execute(); auto output = outputs.at("lrn").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 0.999792f, 1.99911f, 2.99755f, 3.99466f, 4.99f, 5.98313f, 6.97361f, 7.96102f, 8.94493f, 9.92493f, diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/lstm_dynamic_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/lstm_dynamic_gpu_test.cpp index 04100ead3c7b9d..c8a037bfbf157e 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/lstm_dynamic_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/lstm_dynamic_gpu_test.cpp @@ -1,34 +1,30 @@ -// Copyright (C) 2018-2021 Intel Corporation +// Copyright (C) 2018-2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -#include -#include "api/memory.hpp" -#include "api/mutable_data.hpp" -#include "api/input_layout.hpp" -#include "api/lstm.hpp" -#include "api/lstm_dynamic.hpp" -#include "api/reorder.hpp" -#include "api_extension/lstm_dynamic_input.hpp" -#include "api_extension/lstm_dynamic_timeloop.hpp" -#include "api/topology.hpp" -#include "api/tensor.hpp" -#include "api/network.hpp" -#include "api/engine.hpp" -#include "test_utils/test_utils.h" -#include "api/data.hpp" -#include "instrumentation.h" -#include +#include "test_utils.h" + +#include +#include +#include +#include +#include +#include +#include +#include + #include #include #include +#ifndef __clang__ #pragma warning( disable : 4503 ) +#endif #define MEASURE_PERF false #define MEASURE_LOOP 50 using namespace cldnn; -using namespace tests; +using namespace ::tests; namespace { float sigmoid(float x) { @@ -217,29 +213,28 @@ struct lstm_dynamic_input_layer_test : public ::testing::Test VF ref_weights_vec = flatten_4d(cldnn::format::bfyx, ref_weights); VF ref_bias_vec = flatten_4d(cldnn::format::bfyx, ref_bias); - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); VF ref_dynamic_length; for (auto& v : dynamic_lengths) ref_dynamic_length.push_back((T)v); constexpr auto dt = std::is_same::value ? data_types::f32 : data_types::f16; - memory input_mem = memory::allocate(engine, { dt, format::bfyx,{ batch_size, max_sequence_len, input_size, direction } }); + auto input_mem = engine.allocate_memory({ dt, format::bfyx,{ batch_size, max_sequence_len, input_size, direction } }); set_values(input_mem, ref_input_vec); - memory weights_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, direction, input_size, 4 * hidden_size } }); + auto weights_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, direction, input_size, 4 * hidden_size } }); set_values(weights_mem, ref_weights_vec); - memory dynamic_length_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, 1, batch_size, 1 } }); + auto dynamic_length_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, 1, batch_size, 1 } }); set_values(dynamic_length_mem, ref_dynamic_length); - memory bias_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, 1, 4 * hidden_size, direction } }); + auto bias_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, 1, 4 * hidden_size, direction } }); set_values(bias_mem, ref_bias_vec); topology topology; - topology.add(input_layout("input", input_mem.get_layout())); - topology.add(input_layout("dyn_len", dynamic_length_mem.get_layout())); + topology.add(input_layout("input", input_mem->get_layout())); + topology.add(input_layout("dyn_len", dynamic_length_mem->get_layout())); topology.add(data("weights", weights_mem)); std::string bias_id = ""; - if (has_bias) - { + if (has_bias) { bias_id = "bias"; topology.add(data(bias_id, bias_mem)); } @@ -277,8 +272,9 @@ struct lstm_dynamic_input_layer_test : public ::testing::Test auto outputs = network.execute(); auto out = outputs.at("dynamic_lstm_input"); - auto out_tensor = out.get_memory().get_layout().size; - auto out_ptr = out.get_memory().pointer(); + auto out_tensor = out.get_memory()->get_layout().size; + cldnn::mem_lock out_ptr(out.get_memory(), get_test_stream()); + auto output_ref = dynamic_lstm::lstm_dynamic_input_ref(ref_input, ref_weights, ref_bias, dynamic_lengths, max_sequence_len, has_bias, direction); @@ -331,31 +327,31 @@ struct lstm_dynamic_single_layer_test : public ::testing::Test VF ref_hidden_vec = flatten_4d(cldnn::format::bfyx, ref_hidden); VF ref_cell_vec = flatten_4d(cldnn::format::bfyx, ref_cell); - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); constexpr auto dt = std::is_same::value ? data_types::f32 : data_types::f16; VF ref_dynamic_length; for (auto& v : dynamic_lengths) ref_dynamic_length.push_back((T)v); - memory input_mem = memory::allocate(engine, { dt, format::bfyx,{ batch_size, max_sequence_len, input_size, direction } }); + auto input_mem = engine.allocate_memory({ dt, format::bfyx,{ batch_size, max_sequence_len, input_size, direction } }); set_values(input_mem, ref_input_vec); - memory weights_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, direction, input_size, 4 * hidden_size } }); + auto weights_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, direction, input_size, 4 * hidden_size } }); set_values(weights_mem, ref_weights_vec); - memory recurrent_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, direction, hidden_size, 4 * hidden_size } }); + auto recurrent_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, direction, hidden_size, 4 * hidden_size } }); set_values(recurrent_mem, ref_recurrent_vec); - memory dynamic_length_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, 1, batch_size, 1 } }); + auto dynamic_length_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, 1, batch_size, 1 } }); set_values(dynamic_length_mem, ref_dynamic_length); - memory bias_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, 1, 4 * hidden_size, direction } }); + auto bias_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, 1, 4 * hidden_size, direction } }); set_values(bias_mem, ref_bias_vec); - memory initial_hidden_mem = memory::allocate(engine, { dt, format::bfyx,{ batch_size, 1, hidden_size, direction } }); + auto initial_hidden_mem = engine.allocate_memory({ dt, format::bfyx,{ batch_size, 1, hidden_size, direction } }); set_values(initial_hidden_mem, ref_hidden_vec); - memory initial_cell_mem = memory::allocate(engine, { dt, format::bfyx,{ batch_size, 1, hidden_size, direction } }); + auto initial_cell_mem = engine.allocate_memory({ dt, format::bfyx,{ batch_size, 1, hidden_size, direction } }); set_values(initial_cell_mem, ref_cell_vec); topology topology; - topology.add(input_layout("input", input_mem.get_layout())); - topology.add(input_layout("dyn_len", dynamic_length_mem.get_layout())); + topology.add(input_layout("input", input_mem->get_layout())); + topology.add(input_layout("dyn_len", dynamic_length_mem->get_layout())); topology.add(data("weights", weights_mem)); topology.add(data("recurrent", recurrent_mem)); @@ -381,7 +377,9 @@ struct lstm_dynamic_single_layer_test : public ::testing::Test } std::string last_hidden_state = ""; - memory last_hidden_mem = memory::allocate(engine, { dt, format::bfyx,{ batch_size, 1, hidden_size, direction } }); + auto last_hidden_mem = engine.allocate_memory({ dt, format::bfyx,{ batch_size, 1, hidden_size, direction } }); + last_hidden_mem->fill(get_test_stream()); + get_test_stream().finish(); if (has_last_hidden_state) { last_hidden_state = "last_hidden_state"; @@ -389,7 +387,9 @@ struct lstm_dynamic_single_layer_test : public ::testing::Test } std::string last_cell_state = ""; - memory last_cell_mem = memory::allocate(engine, { dt, format::bfyx,{ batch_size, 1, hidden_size, direction } }); + auto last_cell_mem = engine.allocate_memory({ dt, format::bfyx,{ batch_size, 1, hidden_size, direction } }); + last_cell_mem->fill(get_test_stream()); + get_test_stream().finish(); if (has_last_cell_state) { last_cell_state = "last_cell_state"; @@ -436,10 +436,11 @@ struct lstm_dynamic_single_layer_test : public ::testing::Test clip_threshold, input_forget); auto real_outs = network.execute(); auto out = real_outs.at("dynamic_lstm"); - auto out_tensor = out.get_memory().get_layout().size; - auto out_ptr = out.get_memory().pointer(); - auto last_hidden_ptr = last_hidden_mem.pointer(); - auto last_cell_ptr = last_cell_mem.pointer(); + auto out_tensor = out.get_memory()->get_layout().size; + + cldnn::mem_lock out_ptr(out.get_memory(), get_test_stream()); + cldnn::mem_lock last_hidden_ptr(last_hidden_mem, get_test_stream()); + cldnn::mem_lock last_cell_ptr(last_cell_mem, get_test_stream()); size_t i = 0, i_lh = 0, i_lc = 0; for (auto b = 0; b < out_tensor.batch[0]; b++) { @@ -474,8 +475,8 @@ struct lstm_dynamic_single_layer_test : public ::testing::Test //check optional last hidden state output if(has_last_hidden_state && len == dynamic_lengths[b] - 1) { - auto ratio = (float)ref_output_hidden[b][len][dir][x] / (float)last_hidden_ptr[i_lh++]; - EXPECT_TRUE(std::abs((1.0f - ratio) < 0.01f)) + auto ratio = (float)ref_output_hidden[b][len][dir][x] / (float)last_hidden_ptr[i_lh++]; + EXPECT_TRUE(std::abs(1.0f - ratio) < 0.01f) << "check has_last_hidden_state with ratio: " << ratio << ", " << "b:" << b << ", " << "len:" << len << ", " @@ -499,7 +500,7 @@ struct lstm_dynamic_single_layer_test : public ::testing::Test if(has_last_cell_state && len == dynamic_lengths[b] - 1) { auto ratio = (float)ref_output_cell[b][len][dir][x] / (float)last_cell_ptr[i_lc++]; - EXPECT_TRUE(std::abs((1.0f - ratio) < 0.01f)) + EXPECT_TRUE(std::abs(1.0f - ratio) < 0.01f) << "check has_last_cell_state with ratio: " << ratio << ", " << "b:" << b << ", " << "len:" << len << ", " @@ -869,17 +870,17 @@ TEST(lstm_dynamic_negative, wrong_weights_size) { auto batch_size = 1, max_sequence_len = 10, input_size = 16, hidden_size = 32, direction = 1; auto wrong_value = 50; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); cldnn::data_types dt = cldnn::data_types::f32; - memory input_mem = memory::allocate(engine, { dt, format::bfyx, { batch_size, max_sequence_len, input_size, 1 } }); - memory weights_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, direction, input_size, wrong_value } }); - memory recurrent_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, direction, hidden_size, 4 * hidden_size } }); - memory dynamic_length_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, 1, batch_size, 1 } }); - memory bias_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, 1, 4 * hidden_size, 1 } }); + auto input_mem = engine.allocate_memory({ dt, format::bfyx, { batch_size, max_sequence_len, input_size, 1 } }); + auto weights_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, direction, input_size, wrong_value } }); + auto recurrent_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, direction, hidden_size, 4 * hidden_size } }); + auto dynamic_length_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, 1, batch_size, 1 } }); + auto bias_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, 1, 4 * hidden_size, 1 } }); topology topology; - topology.add(input_layout("input", input_mem.get_layout())); - topology.add(input_layout("dyn_len", dynamic_length_mem.get_layout())); + topology.add(input_layout("input", input_mem->get_layout())); + topology.add(input_layout("dyn_len", dynamic_length_mem->get_layout())); topology.add(data("weights", weights_mem)); topology.add(data("recurrent", recurrent_mem)); topology.add(lstm_dynamic("dynamic_lstm", @@ -894,17 +895,17 @@ TEST(lstm_dynamic_negative, wrong_recurrent_size_0) { auto batch_size = 1, max_sequence_len = 10, input_size = 16, hidden_size = 32, direction = 1; auto wrong_value = 50; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); cldnn::data_types dt = cldnn::data_types::f32; - memory input_mem = memory::allocate(engine, { dt, format::bfyx,{ batch_size, max_sequence_len, input_size, 1 } }); - memory weights_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, direction, input_size, 4 * hidden_size } }); - memory recurrent_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, direction, wrong_value, 4 * hidden_size } }); - memory dynamic_length_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, 1, batch_size, 1 } }); - memory bias_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, 1, 4 * hidden_size, 1 } }); + auto input_mem = engine.allocate_memory({ dt, format::bfyx,{ batch_size, max_sequence_len, input_size, 1 } }); + auto weights_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, direction, input_size, 4 * hidden_size } }); + auto recurrent_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, direction, wrong_value, 4 * hidden_size } }); + auto dynamic_length_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, 1, batch_size, 1 } }); + auto bias_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, 1, 4 * hidden_size, 1 } }); topology topology; - topology.add(input_layout("input", input_mem.get_layout())); - topology.add(input_layout("dyn_len", dynamic_length_mem.get_layout())); + topology.add(input_layout("input", input_mem->get_layout())); + topology.add(input_layout("dyn_len", dynamic_length_mem->get_layout())); topology.add(data("weights", weights_mem)); topology.add(data("recurrent", recurrent_mem)); topology.add(lstm_dynamic("dynamic_lstm", @@ -919,17 +920,17 @@ TEST(lstm_dynamic_negative, wrong_recurrent_size_1) { auto batch_size = 1, max_sequence_len = 10, input_size = 16, hidden_size = 32, direction = 1; auto wrong_value = 50; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); cldnn::data_types dt = cldnn::data_types::f32; - memory input_mem = memory::allocate(engine, { dt, format::bfyx,{ batch_size, max_sequence_len, input_size, 1 } }); - memory weights_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, direction, input_size, 4 * hidden_size } }); - memory recurrent_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, direction, wrong_value, 4 * hidden_size } }); - memory dynamic_length_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, 1, batch_size, 1 } }); - memory bias_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, 1, 4 * hidden_size, 1 } }); + auto input_mem = engine.allocate_memory({ dt, format::bfyx,{ batch_size, max_sequence_len, input_size, 1 } }); + auto weights_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, direction, input_size, 4 * hidden_size } }); + auto recurrent_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, direction, wrong_value, 4 * hidden_size } }); + auto dynamic_length_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, 1, batch_size, 1 } }); + auto bias_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, 1, 4 * hidden_size, 1 } }); topology topology; - topology.add(input_layout("input", input_mem.get_layout())); - topology.add(input_layout("dyn_len", dynamic_length_mem.get_layout())); + topology.add(input_layout("input", input_mem->get_layout())); + topology.add(input_layout("dyn_len", dynamic_length_mem->get_layout())); topology.add(data("weights", weights_mem)); topology.add(data("recurrent", recurrent_mem)); topology.add(lstm_dynamic("dynamic_lstm", @@ -944,17 +945,17 @@ TEST(lstm_dynamic_negative, wrong_dynamic_length_size_0) { auto batch_size = 1, max_sequence_len = 10, input_size = 16, hidden_size = 32, direction = 1; auto wrong_value = 50; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); cldnn::data_types dt = cldnn::data_types::f32; - memory input_mem = memory::allocate(engine, { dt, format::bfyx,{ batch_size, max_sequence_len, input_size, 1 } }); - memory weights_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, direction, input_size, 4 * hidden_size } }); - memory recurrent_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, direction, hidden_size, 4 * hidden_size } }); - memory dynamic_length_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, 1, wrong_value, 1 } }); - memory bias_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, 1, 4 * hidden_size, 1 } }); + auto input_mem = engine.allocate_memory({ dt, format::bfyx,{ batch_size, max_sequence_len, input_size, 1 } }); + auto weights_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, direction, input_size, 4 * hidden_size } }); + auto recurrent_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, direction, hidden_size, 4 * hidden_size } }); + auto dynamic_length_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, 1, wrong_value, 1 } }); + auto bias_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, 1, 4 * hidden_size, 1 } }); topology topology; - topology.add(input_layout("input", input_mem.get_layout())); - topology.add(input_layout("dyn_len", dynamic_length_mem.get_layout())); + topology.add(input_layout("input", input_mem->get_layout())); + topology.add(input_layout("dyn_len", dynamic_length_mem->get_layout())); topology.add(data("weights", weights_mem)); topology.add(data("recurrent", recurrent_mem)); topology.add(lstm_dynamic("dynamic_lstm", @@ -969,17 +970,17 @@ TEST(lstm_dynamic_negative, wrong_dynamic_length_size_1) { auto batch_size = 50, max_sequence_len = 10, input_size = 16, hidden_size = 32, direction = 1; auto wrong_value = 2; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); cldnn::data_types dt = cldnn::data_types::f32; - memory input_mem = memory::allocate(engine, { dt, format::bfyx,{ batch_size, max_sequence_len, input_size, 1 } }); - memory weights_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, direction, input_size, 4 * hidden_size } }); - memory recurrent_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, direction, hidden_size, 4 * hidden_size } }); - memory dynamic_length_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, 1, wrong_value, 1 } }); - memory bias_mem = memory::allocate(engine, { dt, format::bfyx,{ 1, 1, 4 * hidden_size, 1 } }); + auto input_mem = engine.allocate_memory({ dt, format::bfyx,{ batch_size, max_sequence_len, input_size, 1 } }); + auto weights_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, direction, input_size, 4 * hidden_size } }); + auto recurrent_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, direction, hidden_size, 4 * hidden_size } }); + auto dynamic_length_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, 1, wrong_value, 1 } }); + auto bias_mem = engine.allocate_memory({ dt, format::bfyx,{ 1, 1, 4 * hidden_size, 1 } }); topology topology; - topology.add(input_layout("input", input_mem.get_layout())); - topology.add(input_layout("dyn_len", dynamic_length_mem.get_layout())); + topology.add(input_layout("input", input_mem->get_layout())); + topology.add(input_layout("dyn_len", dynamic_length_mem->get_layout())); topology.add(data("weights", weights_mem)); topology.add(data("recurrent", recurrent_mem)); topology.add(lstm_dynamic("dynamic_lstm", @@ -989,5 +990,3 @@ TEST(lstm_dynamic_negative, wrong_dynamic_length_size_1) { "recurrent")); ASSERT_ANY_THROW(network network(engine, topology)); } - - diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/lstm_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/lstm_gpu_test.cpp index 866343d92974f2..d9b968d205f503 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/lstm_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/lstm_gpu_test.cpp @@ -3,22 +3,16 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include "api/lstm.hpp" -#include -#include -#include -#include -#include -#include -#include -#include -#include "test_utils/test_utils.h" -#include -#include "instrumentation.h" -#include + +#include "test_utils.h" + +#include +#include +#include +#include +#include +#include +#include #include #include @@ -28,7 +22,7 @@ #endif using namespace cldnn; -using namespace tests; +using namespace ::tests; #define FERROR 1E-4 @@ -219,10 +213,10 @@ void generic_lstm_gemm_gpu_test(int sequence_len, int direction, int batch_size, VVVVF ref_output = lstm_gemm_reference(ref_input, ref_weights, ref_recurrent, ref_bias, ref_hidden, 0, hasBias, hasHidden); constexpr auto dt = std::is_same::value ? data_types::f32 : data_types::f16; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - // If the input is of fp16 type then, the memory will be allocated as such - if (!engine.get_info().supports_fp16) + // If the input is of fp16 type then, the memory::ptr will be allocated as such + if (!engine.get_device_info().supports_fp16) { if (dt == data_types::f16) { @@ -230,11 +224,11 @@ void generic_lstm_gemm_gpu_test(int sequence_len, int direction, int batch_size, } } - memory input = memory::allocate(engine, { dt, format::bfyx, { batch_size, sequence_len, input_size, 1 } }); - memory weights = memory::allocate(engine, { dt, format::bfyx, { 1, direction, input_size, 4 * hidden_size } }); - memory recurrent = memory::allocate(engine, { dt, format::bfyx, { 1, direction, hidden_size, 4 * hidden_size } }); - memory biases = memory::allocate(engine, { dt, format::bfyx, { 1, 1, 4 * hidden_size, direction } }); - memory hidden = memory::allocate(engine, { dt, format::bfyx, { batch_size, direction, hidden_size, 1 } }); + memory::ptr input = engine.allocate_memory({ dt, format::bfyx, { batch_size, sequence_len, input_size, 1 } }); + memory::ptr weights = engine.allocate_memory({ dt, format::bfyx, { 1, direction, input_size, 4 * hidden_size } }); + memory::ptr recurrent = engine.allocate_memory({ dt, format::bfyx, { 1, direction, hidden_size, 4 * hidden_size } }); + memory::ptr biases = engine.allocate_memory({ dt, format::bfyx, { 1, 1, 4 * hidden_size, direction } }); + memory::ptr hidden = engine.allocate_memory({ dt, format::bfyx, { batch_size, direction, hidden_size, 1 } }); set_values(input, ref_input_vec); set_values(weights, ref_weights_vec); @@ -243,14 +237,14 @@ void generic_lstm_gemm_gpu_test(int sequence_len, int direction, int batch_size, set_values(hidden, ref_hidden_vec); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("weights", weights)); topology.add(data("recurrent", recurrent)); if (hasBias) { topology.add(data("biases", biases)); } if (hasHidden) { - topology.add(input_layout("hidden", hidden.get_layout())); + topology.add(input_layout("hidden", hidden->get_layout())); } topology.add(lstm_gemm("lstm_gemm", "input", "weights", "recurrent", hasBias ? "biases" : "", hasHidden ? "hidden" : "")); @@ -265,7 +259,7 @@ void generic_lstm_gemm_gpu_test(int sequence_len, int direction, int batch_size, EXPECT_EQ(outputs.size(), size_t(1)); auto output = outputs.begin()->second.get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); int i = 0; for (int b = 0; b < batch_size; ++b) { for (int x = 0; x < 4 * hidden_size; ++x) @@ -295,10 +289,10 @@ void generic_lstm_elt_gpu_test(int /* sequence_len */, int direction, int batch_ // to error from 1E-4 to 1E-2 constexpr float ferror = std::is_same::value ? (float)1E-4 : (float)1E-2; constexpr auto dt = std::is_same::value ? data_types::f32 : data_types::f16; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - // If the input is of fp16 type then, the memory will be allocated as such - if (!engine.get_info().supports_fp16) + // If the input is of fp16 type then, the memory::ptr will be allocated as such + if (!engine.get_device_info().supports_fp16) { if (dt == data_types::f16) { @@ -306,15 +300,15 @@ void generic_lstm_elt_gpu_test(int /* sequence_len */, int direction, int batch_ } } - memory tempGEMM = memory::allocate(engine, { dt, format::bfyx,{ batch_size, direction, 4 * hidden_size, 1 } }); - memory cell = memory::allocate(engine, { dt, format::bfyx,{ batch_size, direction, hidden_size, 1 } }); + memory::ptr tempGEMM = engine.allocate_memory({ dt, format::bfyx,{ batch_size, direction, 4 * hidden_size, 1 } }); + memory::ptr cell = engine.allocate_memory({ dt, format::bfyx,{ batch_size, direction, hidden_size, 1 } }); set_values(tempGEMM, ref_tempGEMM_vec); set_values(cell, ref_cell_vec); topology topology; - topology.add(input_layout("tempGEMM", tempGEMM.get_layout())); + topology.add(input_layout("tempGEMM", tempGEMM->get_layout())); if (hasCell) { - topology.add(input_layout("cell", cell.get_layout())); + topology.add(input_layout("cell", cell->get_layout())); } topology.add(lstm_elt("lstm_elt", "tempGEMM", hasCell ? "cell" : "", clip_threshold, input_forget)); @@ -328,7 +322,7 @@ void generic_lstm_elt_gpu_test(int /* sequence_len */, int direction, int batch_ EXPECT_EQ(outputs.size(), size_t(1)); auto output = outputs.begin()->second.get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int b = 0; b < batch_size; ++b) { for (int j = 0; j < 2; ++j) { for (int x = 0; x < hidden_size; ++x) @@ -349,11 +343,11 @@ std::string get_string_id(size_t i) { // --------------- Manually constructed LSTM ---------------------------------------- // This function manually generates an lstm node sequence by conbining lstm_gemm and lstm_elt nodes // it requires that the output of the lstm_elt node is croped to obtain the corresponding hidden and cell outputs -void generate_lstm_topology(topology& t, memory& input, memory& hidden, memory& cell, - memory& weights, memory& recurrent, memory& biases, int sequence_len, +void generate_lstm_topology(topology& t, memory::ptr input, memory::ptr hidden, memory::ptr cell, + memory::ptr weights, memory::ptr recurrent, memory::ptr biases, int sequence_len, bool hasBias = true, bool hasInitialHidden = true, bool hasInitialCell = true) { - auto hidden_size = hidden.get_layout().size; - t.add(input_layout("input", input.get_layout())); + auto hidden_size = hidden->get_layout().size; + t.add(input_layout("input", input->get_layout())); std::vector> input_ids_offsets; std::vector output_ids_offsets; for (int i = 0; i < sequence_len; ++i) @@ -372,12 +366,12 @@ void generate_lstm_topology(topology& t, memory& input, memory& hidden, memory& } if (hasInitialHidden) { - t.add(input_layout("hidden", hidden.get_layout())); + t.add(input_layout("hidden", hidden->get_layout())); hiddenStr = "hidden"; } if (hasInitialCell) { - t.add(input_layout("cell", cell.get_layout())); + t.add(input_layout("cell", cell->get_layout())); cellStr = "cell"; } for (int i = 0; i < sequence_len; ++i) { @@ -423,13 +417,13 @@ void generic_lstm_custom_gpu_test(int sequence_len, int direction, int batch_siz lstm_reference(ref_input, ref_hidden, ref_cell, ref_weights, ref_recurrent, ref_bias, ref_output, last_hidden, last_cell, hasBias, hasInitialHidden, hasInitialCell); - const auto& engine = get_test_engine(); - memory input = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ batch_size, sequence_len, input_size, 1 } }); - memory weights = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ 1, direction, input_size, 4 * hidden_size } }); - memory recurrent = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ 1, direction, hidden_size, 4 * hidden_size } }); - memory biases = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ 1, 1, 4 * hidden_size, direction } }); - memory hidden = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ batch_size, direction, hidden_size, 1 } }); - memory cell = memory::allocate(engine, { type_to_data_type::value, format::bfyx,{ batch_size, direction, hidden_size, 1 } }); + auto& engine = get_test_engine(); + memory::ptr input = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ batch_size, sequence_len, input_size, 1 } }); + memory::ptr weights = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ 1, direction, input_size, 4 * hidden_size } }); + memory::ptr recurrent = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ 1, direction, hidden_size, 4 * hidden_size } }); + memory::ptr biases = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ 1, 1, 4 * hidden_size, direction } }); + memory::ptr hidden = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ batch_size, direction, hidden_size, 1 } }); + memory::ptr cell = engine.allocate_memory({ type_to_data_type::value, format::bfyx,{ batch_size, direction, hidden_size, 1 } }); set_values(input, ref_input_vec); set_values(weights, ref_weights_vec); set_values(recurrent, ref_recurrent_vec); @@ -448,11 +442,11 @@ void generic_lstm_custom_gpu_test(int sequence_len, int direction, int batch_siz auto outputs = network.execute(); ASSERT_EQ(outputs.size(), size_t(1)); - size_t output_size = outputs.begin()->second.get_memory().size() / sizeof(T); + size_t output_size = outputs.begin()->second.get_memory()->size() / sizeof(T); ASSERT_EQ(output_size, size_t(hidden_size * sequence_len * batch_size * direction)); auto output = outputs.begin()->second.get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); int i = 0; for (int b = 0; b < batch_size; ++b) { for (int s = 0; s < sequence_len; ++s) { @@ -526,10 +520,10 @@ void generic_lstm_gpu_test(int layers, int sequence_len, int direction, int batc // to error from 1E-4 to 1E-2 constexpr float ferror = std::is_same::value ? (float)1E-4 : (float)1E-2; constexpr auto dt = std::is_same::value ? data_types::f32 : data_types::f16; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - // If the input is of fp16 type then, the memory will be allocated as such - if (!engine.get_info().supports_fp16) + // If the input is of fp16 type then, the memory::ptr will be allocated as such + if (!engine.get_device_info().supports_fp16) { if (dt == data_types::f16) { @@ -537,29 +531,29 @@ void generic_lstm_gpu_test(int layers, int sequence_len, int direction, int batc } } - memory input = memory::allocate(engine, { dt, format::bfyx, {batch_size, sequence_len, input_size, 1} }); + memory::ptr input = engine.allocate_memory({ dt, format::bfyx, {batch_size, sequence_len, input_size, 1} }); set_values(input, ref_input_vec); - std::vector weights; - std::vector recurrent; - std::vector biases; - std::vector hidden; - std::vector cell; + std::vector weights; + std::vector recurrent; + std::vector biases; + std::vector hidden; + std::vector cell; for(int i = 0; i < layers; ++i) { - weights.push_back(memory::allocate(engine, { dt, format::bfyx, { 1, direction, i==0 ? input_size : hidden_size, 4 * hidden_size } })); + weights.push_back(engine.allocate_memory({ dt, format::bfyx, { 1, direction, i==0 ? input_size : hidden_size, 4 * hidden_size } })); set_values(weights[i], ref_weights_vec[i]); - recurrent.push_back(memory::allocate(engine, { dt, format::bfyx, { 1, direction, hidden_size, 4 * hidden_size } })); + recurrent.push_back(engine.allocate_memory({ dt, format::bfyx, { 1, direction, hidden_size, 4 * hidden_size } })); set_values(recurrent[i], ref_recurrent_vec[i]); if (hasBias) { - biases.push_back(memory::allocate(engine, { dt, format::bfyx, { 1, 1, 4 * hidden_size, direction } })); + biases.push_back(engine.allocate_memory({ dt, format::bfyx, { 1, 1, 4 * hidden_size, direction } })); set_values(biases[i], ref_bias_vec[i]); } if (hasInitialHidden) { - hidden.push_back(memory::allocate(engine, { dt, format::bfyx, { batch_size, 1, hidden_size, direction } })); + hidden.push_back(engine.allocate_memory({ dt, format::bfyx, { batch_size, 1, hidden_size, direction } })); set_values(hidden[i], ref_hidden_vec[i]); } if (hasInitialCell) { - cell.push_back(memory::allocate(engine, { dt, format::bfyx, { batch_size, 1, hidden_size, direction} })); + cell.push_back(engine.allocate_memory({ dt, format::bfyx, { batch_size, 1, hidden_size, direction} })); set_values(cell[i], ref_cell_vec[i]); } } @@ -569,7 +563,7 @@ void generic_lstm_gpu_test(int layers, int sequence_len, int direction, int batc std::vector lstm_inputs; std::vector output_ids_offsets; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); for (int i = 0; i < sequence_len; ++i) { input_ids_offsets.push_back({get_string_id(i), {0, i, 0, 0}}); lstm_inputs.push_back("inputSplit:"+get_string_id(i)); @@ -588,8 +582,8 @@ void generic_lstm_gpu_test(int layers, int sequence_len, int direction, int batc topology.add(data(weights_id, weights[i])); topology.add(data(recurrent_id, recurrent[i])); if (hasBias) topology.add(data(biases_id, biases[i])); - if (hasInitialHidden) topology.add(input_layout(hidden_id, hidden[i].get_layout())); - if (hasInitialCell) topology.add(input_layout(cell_id, cell[i].get_layout())); + if (hasInitialHidden) topology.add(input_layout(hidden_id, hidden[i]->get_layout())); + if (hasInitialCell) topology.add(input_layout(cell_id, cell[i]->get_layout())); if (i == 0) { topology.add(lstm(lstm_id, lstm_inputs, weights_id, recurrent_id, hasBias ? biases_id : "", hasInitialHidden ? hidden_id : "", hasInitialCell ? cell_id : "", "", @@ -617,13 +611,13 @@ void generic_lstm_gpu_test(int layers, int sequence_len, int direction, int batc auto outputs = network.execute(); { ASSERT_EQ(outputs.size(), size_t(1)); - size_t output_size = outputs.begin()->second.get_memory().size() / sizeof(T); + size_t output_size = outputs.begin()->second.get_memory()->size() / sizeof(T); ASSERT_EQ(output_size, size_t(hidden_size * sequence_len * batch_size * direction)); auto output = outputs.begin()->second.get_memory(); // Get the output tensor - cldnn::layout output_layout = output.get_layout(); + cldnn::layout output_layout = output->get_layout(); cldnn::tensor output_tensor = output_layout.size; // Compare the output tensor configuration against the reference value @@ -633,7 +627,7 @@ void generic_lstm_gpu_test(int layers, int sequence_len, int direction, int batc ASSERT_EQ(direction, output_tensor.spatial[1]); ASSERT_EQ(hidden_size, output_tensor.spatial[0]); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); int32_t i = 0; for (int32_t b = 0; b < batch_size; ++b) { for (int32_t s = 0; s < sequence_len; ++s) { @@ -683,14 +677,14 @@ void lstm_gpu_output_test(const lstm_output_selection& output_selection, int dir last_hidden, last_cell, true, true, true, (T)0, false, true); - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - memory input = memory::allocate(engine, { type_to_data_type::value, format::bfyx, {batch_size, sequence_len, input_size, 1} }); - memory weights = memory::allocate(engine, { type_to_data_type::value, format::bfyx, { 1, directions, input_size , 4 * hidden_size } }); - memory recurrent = memory::allocate(engine, { type_to_data_type::value, format::bfyx, { 1, directions, hidden_size, 4 * hidden_size } }); - memory biases = memory::allocate(engine, { type_to_data_type::value, format::bfyx, { 1, 1, 4 * hidden_size, directions } }); - memory hidden = memory::allocate(engine, { type_to_data_type::value, format::bfyx, { batch_size, 1, hidden_size, directions } }); - memory cell = memory::allocate(engine, { type_to_data_type::value, format::bfyx, { batch_size, 1, hidden_size, directions } }); + memory::ptr input = engine.allocate_memory({ type_to_data_type::value, format::bfyx, {batch_size, sequence_len, input_size, 1} }); + memory::ptr weights = engine.allocate_memory({ type_to_data_type::value, format::bfyx, { 1, directions, input_size , 4 * hidden_size } }); + memory::ptr recurrent = engine.allocate_memory({ type_to_data_type::value, format::bfyx, { 1, directions, hidden_size, 4 * hidden_size } }); + memory::ptr biases = engine.allocate_memory({ type_to_data_type::value, format::bfyx, { 1, 1, 4 * hidden_size, directions } }); + memory::ptr hidden = engine.allocate_memory({ type_to_data_type::value, format::bfyx, { batch_size, 1, hidden_size, directions } }); + memory::ptr cell = engine.allocate_memory({ type_to_data_type::value, format::bfyx, { batch_size, 1, hidden_size, directions } }); set_values(input, ref_input_vec); set_values(weights, ref_weights_vec); @@ -709,7 +703,7 @@ void lstm_gpu_output_test(const lstm_output_selection& output_selection, int dir std::vector lstm_inputs; std::vector output_ids_offsets; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); for (int i = 0; i < sequence_len; ++i) { input_ids_offsets.push_back({get_string_id(i), {0, i, 0, 0}}); @@ -719,8 +713,8 @@ void lstm_gpu_output_test(const lstm_output_selection& output_selection, int dir topology.add(data("weights", weights)); topology.add(data("recurrent", recurrent)); topology.add(data("biases", biases)); - topology.add(input_layout("hidden", hidden.get_layout())); - topology.add(input_layout("cell", cell.get_layout())); + topology.add(input_layout("hidden", hidden->get_layout())); + topology.add(input_layout("cell", cell->get_layout())); topology.add(lstm("lstm", lstm_inputs, "weights", "recurrent", "biases", "hidden", "cell", "", 0, false, { activation_func::logistic, activation_func::hyperbolic_tan, activation_func::hyperbolic_tan }, {}, @@ -752,11 +746,11 @@ void lstm_gpu_output_test(const lstm_output_selection& output_selection, int dir for (auto itr = outputs.begin(); itr != outputs.end(); itr++) { - auto output_tensor = itr->second.get_memory().get_layout().size; + auto output_tensor = itr->second.get_memory()->get_layout().size; primitive_id primitive_name = itr->first; - cldnn::memory output_memory = itr->second.get_memory(); - int32_t output_size = (int32_t)(itr->second.get_memory().size() / sizeof(T)); + cldnn::memory::ptr output_memory = itr->second.get_memory(); + int32_t output_size = (int32_t)(itr->second.get_memory()->size() / sizeof(T)); cldnn::tensor ref_output_tensor; VVVVF ref_primitive_output; @@ -793,7 +787,7 @@ void lstm_gpu_output_test(const lstm_output_selection& output_selection, int dir ASSERT_EQ(ref_directions, output_tensor.spatial[1]); // directions should match ASSERT_EQ(ref_hidden_size, output_tensor.spatial[0]); // input size should match - auto output_ptr = output_memory.pointer(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int32_t i = 0; for (int32_t b = 0; b < ref_batch_size; ++b) { @@ -846,14 +840,14 @@ void lstm_gpu_format_test(const cldnn::format& format, int directions) { last_hidden, last_cell, true, true, true, (T)0, false, true); - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - memory input = memory::allocate(engine, { type_to_data_type::value,format, {batch_size, sequence_len, input_size, 1} }); - memory weights = memory::allocate(engine, { type_to_data_type::value, format::bfyx, { 1, directions, input_size , 4 * hidden_size } }); - memory recurrent = memory::allocate(engine, { type_to_data_type::value, format::bfyx, { 1, directions, hidden_size, 4 * hidden_size } }); - memory biases = memory::allocate(engine, { type_to_data_type::value, format::bfyx, { 1, 1, 4 * hidden_size, directions } }); - memory hidden = memory::allocate(engine, { type_to_data_type::value, format, { batch_size, 1, hidden_size, directions } }); - memory cell = memory::allocate(engine, { type_to_data_type::value, format, { batch_size, 1, hidden_size, directions } }); + memory::ptr input = engine.allocate_memory({ type_to_data_type::value,format, {batch_size, sequence_len, input_size, 1} }); + memory::ptr weights = engine.allocate_memory({ type_to_data_type::value, format::bfyx, { 1, directions, input_size , 4 * hidden_size } }); + memory::ptr recurrent = engine.allocate_memory({ type_to_data_type::value, format::bfyx, { 1, directions, hidden_size, 4 * hidden_size } }); + memory::ptr biases = engine.allocate_memory({ type_to_data_type::value, format::bfyx, { 1, 1, 4 * hidden_size, directions } }); + memory::ptr hidden = engine.allocate_memory({ type_to_data_type::value, format, { batch_size, 1, hidden_size, directions } }); + memory::ptr cell = engine.allocate_memory({ type_to_data_type::value, format, { batch_size, 1, hidden_size, directions } }); set_values(input, ref_input_vec); set_values(weights, ref_weights_vec); @@ -872,7 +866,7 @@ void lstm_gpu_format_test(const cldnn::format& format, int directions) { std::vector lstm_inputs; std::vector output_ids_offsets; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); for (int i = 0; i < sequence_len; ++i) { input_ids_offsets.push_back({get_string_id(i), {0, i, 0, 0}}); @@ -882,8 +876,8 @@ void lstm_gpu_format_test(const cldnn::format& format, int directions) { topology.add(data("weights", weights)); topology.add(data("recurrent", recurrent)); topology.add(data("biases", biases)); - topology.add(input_layout("hidden", hidden.get_layout())); - topology.add(input_layout("cell", cell.get_layout())); + topology.add(input_layout("hidden", hidden->get_layout())); + topology.add(input_layout("cell", cell->get_layout())); topology.add(lstm("lstm"+get_string_id(0), lstm_inputs, "weights", "recurrent", "biases", "hidden", "cell", "", 0, false, { activation_func::logistic, activation_func::hyperbolic_tan, activation_func::hyperbolic_tan }, {}, @@ -918,11 +912,11 @@ void lstm_gpu_format_test(const cldnn::format& format, int directions) { for (auto itr = outputs.begin(); itr != outputs.end(); itr++) { - auto output_tensor = itr->second.get_memory().get_layout().size; + auto output_tensor = itr->second.get_memory()->get_layout().size; primitive_id primitive_name = itr->first; - cldnn::memory output_memory = itr->second.get_memory(); - int32_t output_size = (int32_t)(itr->second.get_memory().size() / sizeof(T)); + cldnn::memory::ptr output_memory = itr->second.get_memory(); + int32_t output_size = (int32_t)(itr->second.get_memory()->size() / sizeof(T)); cldnn::tensor ref_output_tensor; VVVVF ref_primitive_output; @@ -959,7 +953,7 @@ void lstm_gpu_format_test(const cldnn::format& format, int directions) { ASSERT_EQ(ref_directions, output_tensor.spatial[1]); // directions should match ASSERT_EQ(ref_hidden_size, output_tensor.spatial[0]); // input size should match - auto output_ptr = output_memory.pointer(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int32_t i = 0; if (format == cldnn::format::bfyx) { @@ -1025,14 +1019,14 @@ void lstm_gpu_users_test() { VVVVF last_hidden(batch_size, VVVF(1, VVF(directions, VF(hidden_size)))); VVVVF last_cell(batch_size, VVVF(1, VVF(directions, VF(hidden_size)))); - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - memory input = memory::allocate(engine, { type_to_data_type::value, format::bfyx, {batch_size, sequence_len, input_size, 1} }); - memory weights = memory::allocate(engine, { type_to_data_type::value, format::bfyx, { 1, directions, input_size , 4 * hidden_size } }); - memory recurrent = memory::allocate(engine, { type_to_data_type::value, format::bfyx, { 1, directions, hidden_size, 4 * hidden_size } }); - memory biases = memory::allocate(engine, { type_to_data_type::value, format::bfyx, { 1, 1, 4 * hidden_size, directions } }); - memory hidden = memory::allocate(engine, { type_to_data_type::value, format::bfyx, { batch_size, 1, hidden_size, directions } }); - memory cell = memory::allocate(engine, { type_to_data_type::value, format::bfyx, { batch_size, 1, hidden_size, directions } }); + memory::ptr input = engine.allocate_memory({ type_to_data_type::value, format::bfyx, {batch_size, sequence_len, input_size, 1} }); + memory::ptr weights = engine.allocate_memory({ type_to_data_type::value, format::bfyx, { 1, directions, input_size , 4 * hidden_size } }); + memory::ptr recurrent = engine.allocate_memory({ type_to_data_type::value, format::bfyx, { 1, directions, hidden_size, 4 * hidden_size } }); + memory::ptr biases = engine.allocate_memory({ type_to_data_type::value, format::bfyx, { 1, 1, 4 * hidden_size, directions } }); + memory::ptr hidden = engine.allocate_memory({ type_to_data_type::value, format::bfyx, { batch_size, 1, hidden_size, directions } }); + memory::ptr cell = engine.allocate_memory({ type_to_data_type::value, format::bfyx, { batch_size, 1, hidden_size, directions } }); set_values(input, ref_input_vec); set_values(weights, ref_weights_vec); @@ -1045,7 +1039,7 @@ void lstm_gpu_users_test() { std::vector> input_ids_offsets; std::vector lstm_inputs; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); for (int i = 0; i < sequence_len; ++i) { input_ids_offsets.push_back({get_string_id(i), {0, i, 0, 0}}); @@ -1055,8 +1049,8 @@ void lstm_gpu_users_test() { topology.add(data("weights", weights)); topology.add(data("recurrent", recurrent)); topology.add(data("biases", biases)); - topology.add(input_layout("hidden", hidden.get_layout())); - topology.add(input_layout("cell", cell.get_layout())); + topology.add(input_layout("hidden", hidden->get_layout())); + topology.add(input_layout("cell", cell->get_layout())); topology.add(lstm("lstm", lstm_inputs, "weights", "recurrent", "biases", "hidden", "cell", "", 0, false, { activation_func::logistic, activation_func::hyperbolic_tan, activation_func::hyperbolic_tan }, {}, @@ -1074,8 +1068,8 @@ void lstm_gpu_users_test() { // check if the number of returned primitives match the expected number of output primitives ASSERT_EQ(size_t(1), outputs.size()); - cldnn::memory output_memory = outputs.begin()->second.get_memory(); - auto output_ptr = output_memory.pointer(); + cldnn::memory::ptr output_memory = outputs.begin()->second.get_memory(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); for (int32_t b = 0; b < batch_size; ++b) { for (int32_t s = 0; s < 1; ++s) { @@ -1148,31 +1142,31 @@ void lstm_gpu_concatenated_input_test(int layers, int sequence_len, int directio clip_threshold, input_forget, false); } - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - memory input = memory::allocate(engine, { type_to_data_type::value, format::bfyx, {batch_size, sequence_len, input_size, 1} }); + memory::ptr input = engine.allocate_memory({ type_to_data_type::value, format::bfyx, {batch_size, sequence_len, input_size, 1} }); set_values(input, ref_input_vec); - std::vector weights; - std::vector recurrent; - std::vector biases; - std::vector hidden; - std::vector cell; + std::vector weights; + std::vector recurrent; + std::vector biases; + std::vector hidden; + std::vector cell; for (int i = 0; i < layers; ++i) { - weights.push_back(memory::allocate(engine, { type_to_data_type::value, format::bfyx, { 1, direction, i == 0 ? input_size : hidden_size, 4 * hidden_size } })); + weights.push_back(engine.allocate_memory({ type_to_data_type::value, format::bfyx, { 1, direction, i == 0 ? input_size : hidden_size, 4 * hidden_size } })); set_values(weights[i], ref_weights_vec[i]); - recurrent.push_back(memory::allocate(engine, { type_to_data_type::value, format::bfyx, { 1, direction, hidden_size, 4 * hidden_size } })); + recurrent.push_back(engine.allocate_memory({ type_to_data_type::value, format::bfyx, { 1, direction, hidden_size, 4 * hidden_size } })); set_values(recurrent[i], ref_recurrent_vec[i]); if (has_bias) { - biases.push_back(memory::allocate(engine, { type_to_data_type::value, format::bfyx, { 1, 1, 4 * hidden_size, direction } })); + biases.push_back(engine.allocate_memory({ type_to_data_type::value, format::bfyx, { 1, 1, 4 * hidden_size, direction } })); set_values(biases[i], ref_bias_vec[i]); } if (has_initial_hidden) { - hidden.push_back(memory::allocate(engine, { type_to_data_type::value, format::bfyx, { batch_size, 1, hidden_size, direction } })); + hidden.push_back(engine.allocate_memory({ type_to_data_type::value, format::bfyx, { batch_size, 1, hidden_size, direction } })); set_values(hidden[i], ref_hidden_vec[i]); } if (has_initial_cell) { - cell.push_back(memory::allocate(engine, { type_to_data_type::value, format::bfyx, { batch_size, 1, hidden_size, direction} })); + cell.push_back(engine.allocate_memory({ type_to_data_type::value, format::bfyx, { batch_size, 1, hidden_size, direction} })); set_values(cell[i], ref_cell_vec[i]); } } @@ -1182,7 +1176,7 @@ void lstm_gpu_concatenated_input_test(int layers, int sequence_len, int directio std::vector lstm_inputs; std::vector output_ids_offsets; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); cldnn::primitive_id prev_node_id; for (int i = 0; i < layers; ++i) { @@ -1198,8 +1192,8 @@ void lstm_gpu_concatenated_input_test(int layers, int sequence_len, int directio topology.add(data(weights_id, weights[i])); topology.add(data(recurrent_id, recurrent[i])); if (has_bias) topology.add(data(biases_id, biases[i])); - if (has_initial_hidden) topology.add(input_layout(hidden_id, hidden[i].get_layout())); - if (has_initial_cell) topology.add(input_layout(cell_id, cell[i].get_layout())); + if (has_initial_hidden) topology.add(input_layout(hidden_id, hidden[i]->get_layout())); + if (has_initial_cell) topology.add(input_layout(cell_id, cell[i]->get_layout())); if (i == 0) { topology.add(lstm(lstm_id, { "input" }, weights_id, recurrent_id, has_bias ? biases_id : "", has_initial_hidden ? hidden_id : "", has_initial_cell ? cell_id : "", "", @@ -1232,13 +1226,13 @@ void lstm_gpu_concatenated_input_test(int layers, int sequence_len, int directio auto outputs = network.execute(); { ASSERT_EQ(outputs.size(), size_t(1)); - size_t output_size = outputs.begin()->second.get_memory().size() / sizeof(T); + size_t output_size = outputs.begin()->second.get_memory()->size() / sizeof(T); ASSERT_EQ(output_size, size_t(hidden_size * sequence_len * batch_size * direction)); auto output = outputs.begin()->second.get_memory(); // Get the output tensor - cldnn::layout output_layout = output.get_layout(); + cldnn::layout output_layout = output->get_layout(); cldnn::tensor output_tensor = output_layout.size; // Compare the output tensor configuration against the reference value @@ -1248,7 +1242,7 @@ void lstm_gpu_concatenated_input_test(int layers, int sequence_len, int directio ASSERT_EQ(direction, output_tensor.spatial[1]); ASSERT_EQ(hidden_size, output_tensor.spatial[0]); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); int32_t i = 0; for (int32_t b = 0; b < batch_size; ++b) { for (int32_t s = 0; s < sequence_len; ++s) { @@ -1388,49 +1382,49 @@ void lstm_gpu_chain_test(int batch_size, int input_size, int hidden_size, } } - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); tensor input_tensor = { batch_size, sequence_len, input_size, 1 }; layout layout = { type_to_data_type::value, cldnn::format::bfyx, input_tensor }; - memory input = memory::allocate(engine, layout); + memory::ptr input = engine.allocate_memory(layout); set_values(input, ref_input_vec); // 2-dim vectors to support chain and layers - std::vector> weights; - std::vector> recurrent; - std::vector> biases; - std::vector> hidden; - std::vector> cell; + std::vector> weights; + std::vector> recurrent; + std::vector> biases; + std::vector> hidden; + std::vector> cell; for (size_t chain = 0; chain < chains; chain++) { - std::vector per_chain_weights; - std::vector per_chain_recurrent; - std::vector per_chain_biases; - std::vector per_chain_hidden; - std::vector per_chain_cell; + std::vector per_chain_weights; + std::vector per_chain_recurrent; + std::vector per_chain_biases; + std::vector per_chain_hidden; + std::vector per_chain_cell; for (size_t layer = 0; layer < layers; layer++) { - per_chain_weights.push_back(memory::allocate(engine, { type_to_data_type::value, format::bfyx, {1, directions, layer == 0 ? input_size : hidden_size, 4 * hidden_size} })); + per_chain_weights.push_back(engine.allocate_memory({ type_to_data_type::value, format::bfyx, {1, directions, layer == 0 ? input_size : hidden_size, 4 * hidden_size} })); set_values(per_chain_weights[layer], ref_weights_vec[chain][layer]); - per_chain_recurrent.push_back(memory::allocate(engine, { type_to_data_type::value, format::bfyx, {1, directions, hidden_size, 4 * hidden_size} })); + per_chain_recurrent.push_back(engine.allocate_memory({ type_to_data_type::value, format::bfyx, {1, directions, hidden_size, 4 * hidden_size} })); set_values(per_chain_recurrent[layer], ref_recurrent_vec[chain][layer]); if (has_bias) { - per_chain_biases.push_back(memory::allocate(engine, { type_to_data_type::value, format::bfyx, {1, 1, 4 * hidden_size, directions} })); + per_chain_biases.push_back(engine.allocate_memory({ type_to_data_type::value, format::bfyx, {1, 1, 4 * hidden_size, directions} })); set_values(per_chain_biases[layer], ref_bias_vec[chain][layer]); } if (has_initial_hidden) { - per_chain_hidden.push_back(memory::allocate(engine, { type_to_data_type::value, format::bfyx, {1, 1, hidden_size, directions} })); + per_chain_hidden.push_back(engine.allocate_memory({ type_to_data_type::value, format::bfyx, {1, 1, hidden_size, directions} })); set_values(per_chain_hidden[layer], ref_hidden_vec[chain][layer]); } if (has_initial_cell) { - per_chain_cell.push_back(memory::allocate(engine, { type_to_data_type::value, format::bfyx, {1, 1, hidden_size, directions} })); + per_chain_cell.push_back(engine.allocate_memory({ type_to_data_type::value, format::bfyx, {1, 1, hidden_size, directions} })); set_values(per_chain_cell[layer], ref_cell_vec[chain][layer]); } } @@ -1448,7 +1442,7 @@ void lstm_gpu_chain_test(int batch_size, int input_size, int hidden_size, std::vector lstm_inputs; std::vector output_ids_offsets; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); for (int feature = 0; feature < sequence_len; feature++) { input_ids_offsets.push_back({ get_string_id(feature), {0, feature, 0, 0} }); @@ -1498,8 +1492,8 @@ void lstm_gpu_chain_test(int batch_size, int input_size, int hidden_size, if (chain == 0 && layer == 0) { - if (has_initial_hidden) topology.add(input_layout(hidden_id, hidden[chain][layer].get_layout())); - if (has_initial_cell) topology.add(input_layout(cell_id, cell[chain][layer].get_layout())); + if (has_initial_hidden) topology.add(input_layout(hidden_id, hidden[chain][layer]->get_layout())); + if (has_initial_cell) topology.add(input_layout(cell_id, cell[chain][layer]->get_layout())); } // Get the initial hidden and initial cell for each layer for each chain link @@ -1577,7 +1571,7 @@ void lstm_gpu_chain_test(int batch_size, int input_size, int hidden_size, auto outputs = network.execute(); for (auto itr = outputs.begin(); itr != outputs.end(); itr++) { - auto output_tensor = itr->second.get_memory().get_layout().size; + auto output_tensor = itr->second.get_memory()->get_layout().size; primitive_id primitive_name = itr->first; // Split the primitive id to get the chain id @@ -1589,8 +1583,8 @@ void lstm_gpu_chain_test(int batch_size, int input_size, int hidden_size, size_t chain_id = stoi(chain_str); size_t layer_id = stoi(layer_str); - cldnn::memory output_memory = itr->second.get_memory(); - int32_t output_size = (int32_t)(itr->second.get_memory().size() / sizeof(T)); + cldnn::memory::ptr output_memory = itr->second.get_memory(); + int32_t output_size = (int32_t)(itr->second.get_memory()->size() / sizeof(T)); cldnn::tensor ref_output_tensor; VVVVF ref_primitive_output; @@ -1628,7 +1622,7 @@ void lstm_gpu_chain_test(int batch_size, int input_size, int hidden_size, ASSERT_EQ(ref_directions, output_tensor.spatial[1]); // directions should match ASSERT_EQ(ref_hidden_size, output_tensor.spatial[0]); // input size should match - auto output_ptr = output_memory.pointer(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int32_t i = 0; for (int32_t b = 0; b < ref_batch_size; ++b) { @@ -2049,4 +2043,3 @@ TEST(lstm_gpu, generic_lstm_stacked_bi_f16) { // integration testing using multi-layer and chained LSTMs // LSTMs single input // optional activation list - diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/max_unpooling_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/max_unpooling_gpu_test.cpp index 1fbdba583d7b01..0cb3c2cb828f1a 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/max_unpooling_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/max_unpooling_gpu_test.cpp @@ -3,22 +3,18 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include "api/max_unpooling.hpp" -#include -#include -#include -#include "test_utils/test_utils.h" -#include -#include -#include -#include -#include "test_utils/float16.h" + +#include "test_utils.h" + +#include +#include +#include +#include +#include +#include using namespace cldnn; -using namespace tests; +using namespace ::tests; TEST(max_unpooling_gpu, basic_in2x3x2x2) { // Input : 2x2x2x1 @@ -45,10 +41,10 @@ TEST(max_unpooling_gpu, basic_in2x3x2x2) { // f1: b0: 0 0 0 b1: 0 0 0 // f1: b0: 0 8 16 b1: 12 0 17 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 1 } }); - auto arg_max = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 1 } }); + auto arg_max = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); set_values(input, { 4.0f, 4.0f, @@ -65,7 +61,7 @@ TEST(max_unpooling_gpu, basic_in2x3x2x2) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("arg_max", arg_max)); topology.add(max_unpooling("max_unpooling", "input", "arg_max", { 1, 1, 2, 2 }, { 1, 1, 1, 1 })); @@ -76,8 +72,8 @@ TEST(max_unpooling_gpu, basic_in2x3x2x2) { auto outputs = network.execute(); auto output = outputs.at("max_unpooling").get_memory(); - auto output_ptr = output.pointer(); - auto output_layout = output.get_layout(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + auto output_layout = output->get_layout(); EXPECT_EQ(output_layout.format, format::bfyx); EXPECT_EQ(output_layout.size.spatial[1], 2); @@ -127,10 +123,10 @@ TEST(max_unpooling_gpu, basic_in2x3x2x2_output_padding) { // f1: b0: 0 0 0 b1: 0 0 0 // f1: b0: 0 8 16 b1: 12 0 17 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); - auto arg_max = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); + auto arg_max = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); set_values(input, { 4.0f, 4.0f, @@ -147,7 +143,7 @@ TEST(max_unpooling_gpu, basic_in2x3x2x2_output_padding) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("arg_max", arg_max)); topology.add(max_unpooling("max_unpooling", "input", "arg_max", { 1, 1, 2, 2 }, { 1, 1, 1, 1 }, { 0, 0, 0, 0 }, padding({ 0, 0, 1, 1 }, 0))); @@ -158,8 +154,8 @@ TEST(max_unpooling_gpu, basic_in2x3x2x2_output_padding) { auto outputs = network.execute(); auto output = outputs.at("max_unpooling").get_memory(); - auto output_ptr = output.pointer(); - auto output_layout = output.get_layout(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + auto output_layout = output->get_layout(); EXPECT_EQ(output_layout.format, format::bfyx); EXPECT_EQ(output_layout.size.spatial[1], 2); @@ -218,10 +214,10 @@ TEST(max_unpooling_gpu, basic_in2x3x2x2_output_size) { // f1: b0: 0 0 0 b1: 0 0 0 // f1: b0: 0 8 16 b1: 12 0 17 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); - auto arg_max = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); + auto arg_max = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); set_values(input, { 4.0f, 4.0f, @@ -238,7 +234,7 @@ TEST(max_unpooling_gpu, basic_in2x3x2x2_output_size) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("arg_max", arg_max)); topology.add(max_unpooling("max_unpooling", "input", "arg_max", {2, 2, 3, 2})); @@ -249,8 +245,8 @@ TEST(max_unpooling_gpu, basic_in2x3x2x2_output_size) { auto outputs = network.execute(); auto output = outputs.at("max_unpooling").get_memory(); - auto output_ptr = output.pointer(); - auto output_layout = output.get_layout(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + auto output_layout = output->get_layout(); EXPECT_EQ(output_layout.format, format::bfyx); EXPECT_EQ(output_layout.size.spatial[1], 2); @@ -299,10 +295,10 @@ TEST(max_unpooling_gpu, basic_in2x3x2x2_fp16) { // f1: b0: 0 0 0 b1: 0 0 0 // f1: b0: 0 8 16 b1: 12 0 17 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f16, format::bfyx,{ 2, 2, 2, 1 } }); - auto arg_max = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx,{ 2, 2, 2, 1 } }); + auto arg_max = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); set_values(input, { FLOAT16(4.0f), FLOAT16(4.0f), @@ -319,7 +315,7 @@ TEST(max_unpooling_gpu, basic_in2x3x2x2_fp16) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("arg_max", arg_max)); topology.add(max_unpooling("max_unpooling", "input", "arg_max", { 1, 1, 2, 2 }, { 1, 1, 1, 1 })); @@ -330,8 +326,8 @@ TEST(max_unpooling_gpu, basic_in2x3x2x2_fp16) { auto outputs = network.execute(); auto output = outputs.at("max_unpooling").get_memory(); - auto output_ptr = output.pointer(); - auto output_layout = output.get_layout(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + auto output_layout = output->get_layout(); EXPECT_EQ(output_layout.format, format::bfyx); EXPECT_EQ(output_layout.size.spatial[1], 2); @@ -379,10 +375,10 @@ TEST(max_unpooling_gpu, basic_in2x2x3x2_max_with_argmax_pooling_unpooling) { // f1: b0: 0 0 0 b1: 0 0 0 // f1: b0: 0 8 16 b1: 12 0 17 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 3, 2 } }); - auto arg_max = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 3, 2 } }); + auto arg_max = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); set_values(input, { 1.0f, 2.0f, -10.f, @@ -396,7 +392,7 @@ TEST(max_unpooling_gpu, basic_in2x2x3x2_max_with_argmax_pooling_unpooling) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(mutable_data("arg_max", arg_max)); topology.add(pooling("pooling_max_with_argmax", "input", "arg_max", pooling_mode::max_with_argmax, { 1, 1, 2, 2 }, { 1, 1, 1, 1 })); topology.add(max_unpooling("max_unpooling", "pooling_max_with_argmax", "arg_max", { 1, 1, 2, 2 }, { 1, 1, 1, 1 })); @@ -408,9 +404,9 @@ TEST(max_unpooling_gpu, basic_in2x2x3x2_max_with_argmax_pooling_unpooling) { auto outputs = network.execute(); auto output = outputs.at("max_unpooling").get_memory(); - auto output_ptr = output.pointer(); - auto output_layout = output.get_layout(); - auto argmax_ptr = arg_max.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + auto output_layout = output->get_layout(); + cldnn::mem_lock argmax_ptr(arg_max, get_test_stream()); EXPECT_EQ(output_layout.format, format::bfyx); EXPECT_EQ(output_layout.size.spatial[1], 2); @@ -443,4 +439,4 @@ TEST(max_unpooling_gpu, basic_in2x2x3x2_max_with_argmax_pooling_unpooling) { for (size_t i = 0; i < expected_argmax_vec.size(); ++i) { EXPECT_EQ(expected_argmax_vec[i], argmax_ptr[i]); } -} \ No newline at end of file +} diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/memory_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/memory_test.cpp index d303700be2ffd2..861cd2672cd4e9 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/memory_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/memory_test.cpp @@ -4,24 +4,19 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "test_utils/test_utils.h" +#include "test_utils.h" + +#include +#include +#include +#include +#include +#include +#include +#include using namespace cldnn; -using namespace tests; +using namespace ::tests; #if 0 TEST(memory_tests, DISABLED_execution_loop) @@ -31,12 +26,12 @@ TEST(memory_tests, DISABLED_execution_loop) memory in = memory::allocate(eng, layout{ data_types::f32, format::bfyx, { 1, 1, 1000, 1000 } }); topology tpl{ - input_layout("in", in.get_layout()), + input_layout("in", in->get_layout()), activation("out", "in", activation_func::linear) }; network net(eng, tpl); - + while (true) { net.set_input_data("in", in); @@ -51,7 +46,7 @@ TEST(memory_tests, DISABLED_network_creation_loop) memory in = memory::allocate(eng, layout{ data_types::f32, format::bfyx,{ 1, 1, 1000, 1000 } }); topology tpl{ - input_layout("in", in.get_layout()), + input_layout("in", in->get_layout()), activation("out", "in", activation_func::linear) }; @@ -62,17 +57,19 @@ TEST(memory_tests, DISABLED_network_creation_loop) } #endif TEST(memory_pool, basic_non_padded_relu_pipe) { - // 5 relu's of size 1x4x1x1 - const cldnn::engine engine;// here we need new engine + // We need a new engine here to get correct get_max_used_device_memory() result + // If we reuse common engine, then max memory value will be taken from some previously executed tests + // as it's tracked within engine instance + auto engine = create_test_engine(); auto batch_num = 1; auto feature_num = 4; auto x_size = 1; auto y_size = 1; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); + auto input = engine->allocate_memory({ data_types::f32, format::bfyx,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(activation("relu", "input", activation_func::relu)); topology.add(activation("relu1", "relu", activation_func::relu)); topology.add(activation("relu2", "relu1", activation_func::relu)); @@ -85,27 +82,27 @@ TEST(memory_pool, basic_non_padded_relu_pipe) { build_options bo; bo.set_option(build_option::optimize_data(true)); - network network(engine, topology, bo); + network network(*engine, topology, bo); network.set_input_data("input", input); auto outputs = network.execute(); - EXPECT_EQ(engine.get_max_used_device_memory_size(), (uint64_t) 64); + EXPECT_EQ(engine->get_max_used_device_memory(), (uint64_t) 64); } TEST(memory_pool, basic_non_padded_relu_and_pooling_pipe) { - // uncomment this line to disable memory pool - /*engine_configuration cfg{ false, false, false, std::string(), std::string(), true, std::string(),std::string(), 0, false }; - engine engine{ cfg };*/ - const cldnn::engine engine;// here we need new engine + // We need a new engine here to get correct get_max_used_device_memory() result + // If we reuse common engine, then max memory value will be taken from some previously executed tests + // as it's tracked within engine instance + auto engine = create_test_engine(); auto batch_num = 1; auto feature_num = 4; auto x_size = 4; auto y_size = 4; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); + auto input = engine->allocate_memory({ data_types::f32, format::bfyx,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(activation("relu", "input", activation_func::relu)); topology.add(activation("relu1", "relu", activation_func::relu)); topology.add(pooling("pool1", "relu1",pooling_mode::max, { 1,1,3,3 }, { 1,1,2,2 })); @@ -117,11 +114,11 @@ TEST(memory_pool, basic_non_padded_relu_and_pooling_pipe) { build_options bo; bo.set_option(build_option::optimize_data(true)); - network network(engine, topology, bo); + network network(*engine, topology, bo); network.set_input_data("input", input); auto outputs = network.execute(); - EXPECT_EQ(engine.get_max_used_device_memory_size(), (uint64_t)896); + EXPECT_EQ(engine->get_max_used_device_memory(), (uint64_t)896); } TEST(memory_pool, multi_outputs_network) { @@ -130,19 +127,16 @@ TEST(memory_pool, multi_outputs_network) { // -- relu2 -- relu3 -- relu5--relu6--relu7 // neither of relu5, relu6 nor relu7 can share resource with relu4. - // uncomment this line to disable memory pool - /*engine_configuration cfg{ false, false, false, std::string(), std::string(), true, std::string(),std::string(), 0, false }; - engine engine{ cfg };*/ - const cldnn::engine engine;// here we need new engine + auto engine = create_test_engine(); auto batch_num = 1; auto feature_num = 4; auto x_size = 4; auto y_size = 4; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); + auto input = engine->allocate_memory({ data_types::f32, format::bfyx,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(activation("relu", "input", activation_func::relu)); topology.add(activation("relu1", "relu", activation_func::relu)); topology.add(activation("relu2", "input", activation_func::relu)); @@ -155,11 +149,11 @@ TEST(memory_pool, multi_outputs_network) { build_options bo; bo.set_option(build_option::optimize_data(true)); - network network(engine, topology, bo); + network network(*engine, topology, bo); network.set_input_data("input", input); auto outputs = network.execute(); - EXPECT_EQ(engine.get_max_used_device_memory_size(), (uint64_t)1536); + EXPECT_EQ(engine->get_max_used_device_memory(), (uint64_t)1536); } TEST(memory_pool, oooq) { @@ -168,17 +162,19 @@ TEST(memory_pool, oooq) { -- relu3 -- relu5 --------- neither of relu5, relu6 nor relu7 can share resource with relu4. */ - engine_configuration cfg{ false, false, false, std::string(), std::string(), true /*oooq*/, std::string(),std::string(), priority_mode_types::disabled, throttle_mode_types::disabled, true /*mem_pool*/ }; - engine engine{ cfg }; + // We need a new engine here to get correct get_max_used_device_memory() result + // If we reuse common engine, then max memory value will be taken from some previously executed tests + // as it's tracked within engine instance + auto engine = create_test_engine(); auto batch_num = 1; auto feature_num = 4; auto x_size = 4; auto y_size = 4; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); + auto input = engine->allocate_memory({ data_types::f32, format::bfyx,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(activation("relu1", "input", activation_func::relu)); topology.add(activation("relu2", "input", activation_func::relu)); topology.add(activation("relu3", "input", activation_func::relu)); @@ -191,11 +187,11 @@ TEST(memory_pool, oooq) { build_options bo; bo.set_option(build_option::optimize_data(true)); - network network(engine, topology, bo); + network network(*engine, topology, bo); network.set_input_data("input", input); auto outputs = network.execute(); - EXPECT_EQ(engine.get_max_used_device_memory_size(), (uint64_t) 2560); + EXPECT_EQ(engine->get_max_used_device_memory(), (uint64_t) 2560); } TEST(memory_pool, DISABLED_shared_mem_pool_same_topology_twice) { @@ -204,14 +200,16 @@ TEST(memory_pool, DISABLED_shared_mem_pool_same_topology_twice) { -- relu3 -- relu5 --------- neither of relu5, relu6 nor relu7 can share resource with relu4. */ - engine_configuration cfg{ false, false, false, std::string(), std::string(), true /*oooq*/, std::string(),std::string(), priority_mode_types::disabled, throttle_mode_types::disabled, true /*mem_pool*/ }; - engine engine{ cfg }; + // We need a new engine here to get correct get_max_used_device_memory() result + // If we reuse common engine, then max memory value will be taken from some previously executed tests + // as it's tracked within engine instance + auto engine = create_test_engine(); auto batch_num = 1; auto feature_num = 4; auto inp_x_size = 4; auto inp_y_size = 4; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ tensor(spatial(inp_x_size, inp_y_size), feature(feature_num), batch(batch_num)) } }); + auto input = engine->allocate_memory({ data_types::f32, format::bfyx,{ tensor(spatial(inp_x_size, inp_y_size), feature(feature_num), batch(batch_num)) } }); set_values(input, { 1.0f, 2.5f, 3.0f, 4.0f, 5.0f, 2.0f, 2.0f, 3.0f, 6.1f, 4.7f, 1.0f, 1.0f, 8.2f, 1.0f, 2.0f, 1.0f, @@ -221,7 +219,7 @@ TEST(memory_pool, DISABLED_shared_mem_pool_same_topology_twice) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(activation("relu1", "input", activation_func::relu)); topology.add(activation("relu2", "input", activation_func::sqrt)); topology.add(activation("relu3", "input", activation_func::square)); @@ -234,25 +232,25 @@ TEST(memory_pool, DISABLED_shared_mem_pool_same_topology_twice) { build_options bo; bo.set_option(build_option::optimize_data(true)); - network network_first(engine, topology, bo); + network network_first(*engine, topology, bo); network_first.set_input_data("input", input); auto outputs = network_first.execute(); auto output_memory_first = outputs.at("relu6").get_memory(); - auto output_layout_first = output_memory_first.get_layout(); - auto output_ptr_first = output_memory_first.pointer(); + auto output_layout_first = output_memory_first->get_layout(); + cldnn::mem_lock output_ptr_first(output_memory_first, get_test_stream()); - EXPECT_EQ(engine.get_max_used_device_memory_size(), (uint64_t) 2560); + EXPECT_EQ(engine->get_max_used_device_memory(), (uint64_t) 2560); - network network_second(engine, topology, bo); + network network_second(*engine, topology, bo); network_second.set_input_data("input", input); auto outputs_second = network_second.execute(); auto output_memory_second = outputs_second.at("relu6").get_memory(); - auto output_layout_second = output_memory_second.get_layout(); - auto output_ptr_second = output_memory_second.pointer(); + auto output_layout_second = output_memory_second->get_layout(); + cldnn::mem_lock output_ptr_second(output_memory_second, get_test_stream()); - EXPECT_EQ(engine.get_max_used_device_memory_size(), (uint64_t) 3328); + EXPECT_EQ(engine->get_max_used_device_memory(), (uint64_t) 3328); EXPECT_EQ(output_layout_first, output_layout_second); @@ -279,16 +277,17 @@ TEST(memory_pool, DISABLED_shared_mem_pool_same_topology_twice) { } TEST(memory_pool, DISABLED_shared_mem_pool_same_topology_twice_weights) { - - engine_configuration cfg{ false, false, false, std::string(), std::string(), true /*oooq*/, std::string(),std::string(), priority_mode_types::disabled, throttle_mode_types::disabled, true /*mem_pool*/ }; - engine engine{ cfg }; + // We need a new engine here to get correct get_max_used_device_memory() result + // If we reuse common engine, then max memory value will be taken from some previously executed tests + // as it's tracked within engine instance + auto engine = create_test_engine(); auto batch_num = 1; auto feature_num = 3; auto inp_x_size = 4; auto inp_y_size = 4; - auto input= memory::allocate(engine, { data_types::f32, format::bfyx,{ tensor(spatial(inp_x_size, inp_y_size), feature(feature_num), batch(batch_num)) } }); - auto weights = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 1, 3, 2 } }); + auto input= engine->allocate_memory({ data_types::f32, format::bfyx,{ tensor(spatial(inp_x_size, inp_y_size), feature(feature_num), batch(batch_num)) } }); + auto weights = engine->allocate_memory({ data_types::f32,format::bfyx,{ 1, 1, 3, 2 } }); std::vector dummy_input_data_1 = { /*f0 xy*/ 0.8f, 0.65f, 0.1f, 1.0f, 1.0f, 0.5f, 0.11f, 0.33f, 0.66f, 0.11f, 0.22f, 0.33f, 0.99f, 0.8f, 0.7f, 0.5f, @@ -300,7 +299,7 @@ TEST(memory_pool, DISABLED_shared_mem_pool_same_topology_twice_weights) { set_values(weights, { 0.10f, 0.2f, 0.1f, 0.2f, 0.1f, 0.2f }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), convolution("conv", "input", { "weights" }, { 1, 1, 1, 2 }), softmax("softmax", "conv")); @@ -308,31 +307,31 @@ TEST(memory_pool, DISABLED_shared_mem_pool_same_topology_twice_weights) { build_options bo; bo.set_option(build_option::optimize_data(true)); - network network_first(engine, topology, bo); + network network_first(*engine, topology, bo); network_first.set_input_data("input", input); auto outputs = network_first.execute(); uint64_t cl_mem_result = 824; uint64_t usm_result = 1208; // USM have a higher peak, since transfering memory to device adds temporay memory bytes allocated. Old memory is deallocated quickly, but max peak is higher. - auto is_correct = engine.get_max_used_device_memory_size() == cl_mem_result - || engine.get_max_used_device_memory_size() == usm_result; + auto is_correct = engine->get_max_used_device_memory() == cl_mem_result + || engine->get_max_used_device_memory() == usm_result; EXPECT_TRUE(is_correct) << "Memory max peak is not correct"; auto output_memory_first = outputs.at("softmax").get_memory(); - auto output_layout_first = output_memory_first.get_layout(); - auto output_ptr_first = output_memory_first.pointer(); + auto output_layout_first = output_memory_first->get_layout(); + cldnn::mem_lock output_ptr_first(output_memory_first, get_test_stream()); - network network_second(engine, topology, bo); + network network_second(*engine, topology, bo); network_second.set_input_data("input", input); auto outputs_second = network_second.execute(); auto output_memory_second = outputs_second.at("softmax").get_memory(); - auto output_layout_second = output_memory_second.get_layout(); - auto output_ptr_second = output_memory_second.pointer(); + auto output_layout_second = output_memory_second->get_layout(); + cldnn::mem_lock output_ptr_second(output_memory_second, get_test_stream()); cl_mem_result = 1224; usm_result = 1992; // USM have a higher peak, since transfering memory to device adds temporay memory bytes allocated. Old memory is deallocated quickly, but max peak is higher. - is_correct = engine.get_max_used_device_memory_size() == cl_mem_result - || engine.get_max_used_device_memory_size() == usm_result; + is_correct = engine->get_max_used_device_memory() == cl_mem_result + || engine->get_max_used_device_memory() == usm_result; EXPECT_TRUE(is_correct) << "Memory max peak is not correct"; EXPECT_EQ(output_layout_first, output_layout_second); @@ -359,9 +358,10 @@ TEST(memory_pool, DISABLED_shared_mem_pool_same_topology_twice_weights) { } TEST(memory_pool, shared_mem_pool_diff_batches) { - - engine_configuration cfg{ false, false, false, std::string(), std::string(), true /*oooq*/, std::string(),std::string(), priority_mode_types::disabled, throttle_mode_types::disabled, true /*mem_pool*/ }; - engine engine{ cfg }; + // We need a new engine here to get correct get_max_used_device_memory() result + // If we reuse common engine, then max memory value will be taken from some previously executed tests + // as it's tracked within engine instance + auto engine = create_test_engine(); auto batch_8 = 8; auto batch_1 = 1; auto feature_num = 3; @@ -371,9 +371,9 @@ TEST(memory_pool, shared_mem_pool_diff_batches) { auto fmt = format::bfyx; layout lay_batch_1 = { dt, fmt, { tensor(spatial(inp_x_size, inp_y_size), feature(feature_num), batch(batch_1)) }}; layout lay_batch_8 = { dt, fmt, { tensor(spatial(inp_x_size, inp_y_size), feature(feature_num), batch(batch_8)) }}; - auto input_1 = memory::allocate(engine, lay_batch_1); - auto input_8 = memory::allocate(engine, lay_batch_8); - auto weights = memory::allocate(engine, { dt, fmt, { 1, 1, 3, 2 } }); + auto input_1 = engine->allocate_memory(lay_batch_1); + auto input_8 = engine->allocate_memory(lay_batch_8); + auto weights = engine->allocate_memory({ dt, fmt, { 1, 1, 3, 2 } }); std::vector dummy_input_data_1 = generate_random_1d(batch_1*feature_num*inp_x_size*inp_y_size, 0, 1); std::vector dummy_input_data_8 = generate_random_1d(batch_8*feature_num*inp_x_size*inp_y_size, 0, 1); @@ -383,7 +383,7 @@ TEST(memory_pool, shared_mem_pool_diff_batches) { set_values(weights, { 0.10f, 0.2f, 0.1f, 0.2f, 0.1f, 0.2f }); topology topo( - input_layout("input", input_8.get_layout()), + input_layout("input", input_8->get_layout()), data("weights", weights), convolution("conv", "input", { "weights" }, { 1, 1, 1, 2 }), softmax("softmax", "conv")); @@ -391,25 +391,27 @@ TEST(memory_pool, shared_mem_pool_diff_batches) { build_options bo; bo.set_option(build_option::optimize_data(true)); - network network_first(engine, topo, bo); + network network_first(*engine, topo, bo); network_first.set_input_data("input", input_8); auto outputs = network_first.execute(); - auto dev_info = engine.get_info(); - EXPECT_EQ(engine.get_max_used_device_memory_size(), (uint64_t)3928); + auto dev_info = engine->get_device_info(); + EXPECT_EQ(engine->get_max_used_device_memory(), (uint64_t)3928); - topo.change_input_layout("input", input_1.get_layout());//change input layout to batch=1 + topo.change_input_layout("input", input_1->get_layout());//change input layout to batch=1 - network network_second(engine, topo, bo); + network network_second(*engine, topo, bo); network_second.set_input_data("input", input_1); auto outputs_second = network_second.execute(); - EXPECT_EQ(engine.get_max_used_device_memory_size(), (uint64_t)3928); + EXPECT_EQ(engine->get_max_used_device_memory(), (uint64_t)3928); } TEST(memory_pool, shared_dep_two_output) { + // We need a new engine here to get correct get_max_used_device_memory() result + // If we reuse common engine, then max memory value will be taken from some previously executed tests + // as it's tracked within engine instance + auto engine = create_test_engine(); - engine_configuration cfg{ false, false, false, std::string(), std::string(), true /*oooq*/, std::string(),std::string(), priority_mode_types::disabled, throttle_mode_types::disabled, true /*mem_pool*/ }; - engine engine{ cfg }; auto batch_1 = 1; auto feature_num = 1; auto inp_x_size = 4; @@ -417,7 +419,7 @@ TEST(memory_pool, shared_dep_two_output) { auto dt = data_types::f32; auto fmt = format::bfyx; layout lay_batch_1 = { dt, fmt,{ tensor(spatial(inp_x_size, inp_y_size), feature(feature_num), batch(batch_1)) } }; - auto input_1 = memory::allocate(engine, lay_batch_1); + auto input_1 = engine->allocate_memory(lay_batch_1); set_random_values(input_1); //build primitives @@ -445,21 +447,19 @@ TEST(memory_pool, shared_dep_two_output) { build_options bo; bo.set_option(build_option::optimize_data(true)); - network network(engine, topo, bo); + network network(*engine, topo, bo); auto outputs = network.execute(); - EXPECT_EQ(engine.get_max_used_device_memory_size(), (uint64_t)256); + EXPECT_EQ(engine->get_max_used_device_memory(), (uint64_t)256); } TEST(memory_pool, non_opt_intermidate_opt_after) { - - engine_configuration cfg{ false, false, false, std::string(), std::string(), true /*oooq*/, std::string(),std::string(), priority_mode_types::disabled, throttle_mode_types::disabled, true /*mem_pool*/ }; - engine engine{ cfg }; + auto& engine = get_test_engine(); auto input_layout1 = layout(cldnn::data_types::f32, cldnn::format::bfyx, { 1, 1, 2, 2 }); auto input_layout2 = layout(cldnn::data_types::f32, cldnn::format::bfyx, { 1, 1, 2, 2 }); - auto input_memory1 = cldnn::memory::allocate(engine, input_layout1); - auto input_memory2 = cldnn::memory::allocate(engine, input_layout2); - auto scale_memory = cldnn::memory::allocate(engine, layout(cldnn::data_types::f32, cldnn::format::bfyx, { 1,1,1,1 })); + auto input_memory1 = engine.allocate_memory(input_layout1); + auto input_memory2 = engine.allocate_memory(input_layout2); + auto scale_memory = engine.allocate_memory(layout(cldnn::data_types::f32, cldnn::format::bfyx, { 1,1,1,1 })); auto data_memory = cldnn::data("scale_mem", scale_memory); set_values(input_memory1, { 1.0f, 2.0f, 3.0f, 4.0f }); @@ -496,20 +496,19 @@ TEST(memory_pool, non_opt_intermidate_opt_after) { auto out1 = outputs.at("elt1"); auto out2 = outputs.at("elt2"); - auto out1_ptr = out1.get_memory().pointer(); - auto out2_ptr = out2.get_memory().pointer(); + cldnn::mem_lock out1_ptr(out1.get_memory(), get_test_stream()); + cldnn::mem_lock out2_ptr(out2.get_memory(), get_test_stream()); EXPECT_EQ(out1_ptr[0], 1.0f); EXPECT_EQ(out2_ptr[0], 2.0f); } TEST(memory_pool, add_mem_dep_test) { + auto& engine = get_test_engine(); - engine_configuration cfg{ false, false, false, std::string(), std::string(), true /*oooq*/, std::string(),std::string(), priority_mode_types::disabled, throttle_mode_types::disabled, true /*mem_pool*/ }; - engine engine{ cfg }; auto input_layout1 = layout(cldnn::data_types::f32, cldnn::format::bfyx, { 1, 2, 2, 2 }); - auto input_memory1 = cldnn::memory::allocate(engine, input_layout1); - auto scale_memory = cldnn::memory::allocate(engine, layout(cldnn::data_types::f32, cldnn::format::bfyx, { 1,1,1,1 })); + auto input_memory1 = engine.allocate_memory(input_layout1); + auto scale_memory = engine.allocate_memory(layout(cldnn::data_types::f32, cldnn::format::bfyx, { 1,1,1,1 })); auto data_memory = cldnn::data("scale_mem", scale_memory); set_values(input_memory1, { 1.0f, 2.0f, 3.0f, 4.0f, @@ -545,8 +544,8 @@ TEST(memory_pool, add_mem_dep_test) { auto out1 = outputs.at("out3"); auto out2 = outputs.at("out4"); - auto out1_ptr = out1.get_memory().pointer(); - auto out2_ptr = out2.get_memory().pointer(); + cldnn::mem_lock out1_ptr(out1.get_memory(), get_test_stream()); + cldnn::mem_lock out2_ptr(out2.get_memory(), get_test_stream()); EXPECT_EQ(out1_ptr[0], 1.0f); EXPECT_EQ(out1_ptr[1], 2.0f); EXPECT_EQ(out1_ptr[2], 3.0f); diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/mvn_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/mvn_gpu_test.cpp index 410fc6cad02bd3..5632a19cfd4ebe 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/mvn_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/mvn_gpu_test.cpp @@ -4,26 +4,22 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include "api/mvn.hpp" -#include "api/reorder.hpp" -#include -#include -#include -#include "test_utils/test_utils.h" -#include -#include "float16.h" #include "test_utils.h" +#include +#include +#include + +#include + using namespace cldnn; +using namespace ::tests; class mvn_gpu_test : public ::testing::TestWithParam {}; template -void mvn_compute_mean_across_channels(cldnn::memory& output, bool normalize_variance) { - auto output_size = output.get_layout().size; +void mvn_compute_mean_across_channels(cldnn::memory::ptr output, bool normalize_variance) { + auto output_size = output->get_layout().size; uint32_t batch_size = output_size.batch[0]; uint32_t feature_size = output_size.feature[0]; @@ -31,9 +27,9 @@ void mvn_compute_mean_across_channels(cldnn::memory& output, bool normalize_vari uint32_t y_size = output_size.spatial[1]; uint32_t x_size = output_size.spatial[0]; - auto buff = output.pointer(); + cldnn::mem_lock buff(output, get_test_stream()); - float err_margin = output.get_layout().data_type == data_types::f32 ? 1e-03F : 1e-02F; + float err_margin = output->get_layout().data_type == data_types::f32 ? 1e-03F : 1e-02F; for (uint32_t b = 0; b < batch_size; ++b) { float sum = 0.f; @@ -43,7 +39,7 @@ void mvn_compute_mean_across_channels(cldnn::memory& output, bool normalize_vari for (uint32_t y = 0; y < y_size; ++y) { for (uint32_t x = 0; x < x_size; ++x) { auto index_tensor = tensor(batch(b), feature(f), spatial(x, y, z, 0)); - size_t data_index = output.get_layout().get_linear_offset(index_tensor); + size_t data_index = output->get_layout().get_linear_offset(index_tensor); float data = static_cast(buff[data_index]); sum += data; if (normalize_variance) @@ -65,8 +61,8 @@ void mvn_compute_mean_across_channels(cldnn::memory& output, bool normalize_vari } template -void mvn_compute_mean_within_channels(cldnn::memory& output, bool normalize_variance) { - auto output_size = output.get_layout().size; +void mvn_compute_mean_within_channels(cldnn::memory::ptr output, bool normalize_variance) { + auto output_size = output->get_layout().size; uint32_t batch_size = output_size.batch[0]; uint32_t feature_size = output_size.feature[0]; @@ -74,9 +70,9 @@ void mvn_compute_mean_within_channels(cldnn::memory& output, bool normalize_vari uint32_t y_size = output_size.spatial[1]; uint32_t x_size = output_size.spatial[0]; - auto buff = output.pointer(); + cldnn::mem_lock buff(output, get_test_stream()); - float err_margin = output.get_layout().data_type == data_types::f32 ? 1e-03F : 1e-02F; + float err_margin = output->get_layout().data_type == data_types::f32 ? 1e-03F : 1e-02F; for (uint32_t b = 0; b < batch_size; ++b) { for (uint32_t f = 0; f < feature_size; ++f) { @@ -86,7 +82,7 @@ void mvn_compute_mean_within_channels(cldnn::memory& output, bool normalize_vari for (uint32_t y = 0; y < y_size; ++y) { for (uint32_t x = 0; x < x_size; ++x) { auto index_tensor = tensor(batch(b), feature(f), spatial(x, y, z, 0)); - size_t data_index = output.get_layout().get_linear_offset(index_tensor); + size_t data_index = output->get_layout().get_linear_offset(index_tensor); float data = static_cast(buff[data_index]); sum += data; if (normalize_variance) @@ -110,16 +106,16 @@ void mvn_compute_mean_within_channels(cldnn::memory& output, bool normalize_vari TEST(mvn_gpu_test, mvn_test_across_channels_outside_sqrt_bfyx) { // mvn across channels fp32 test with normalize_variance set to false using namespace cldnn; - using namespace tests; + using namespace ::tests; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {7, 10, 17, 13}}); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {7, 10, 17, 13}}); tests::set_random_values(input, true, 8, 100); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(mvn("mvn", "input", false, 1e-10f, false, true)); network network(engine, topology); @@ -139,14 +135,14 @@ TEST(mvn_gpu_test, mvn_test_across_channels_inside_sqrt_bfyx) { using namespace cldnn; using namespace tests; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {7, 10, 17, 13}}); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {7, 10, 17, 13}}); tests::set_random_values(input, true, 8, 100); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(mvn("mvn", "input", false, 1e-10f, true, true)); network network(engine, topology); @@ -164,16 +160,16 @@ TEST(mvn_gpu_test, mvn_test_across_channels_inside_sqrt_bfyx) { TEST(mvn_gpu_test, mvn_test_across_channels_bfyx_outside_sqrt_fp16) { // mvn across channels fp16 test with normalize_variance set to false using namespace cldnn; - using namespace tests; + using namespace ::tests; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f16, format::bfyx, {7, 10, 17, 13}}); + auto input = engine.allocate_memory({data_types::f16, format::bfyx, {7, 10, 17, 13}}); tests::set_random_values(input, true, 8, 100); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(mvn("mvn", "input", false, 1e-10f, false, true)); network network(engine, topology); @@ -193,14 +189,14 @@ TEST(mvn_gpu_test, mvn_test_across_channels_inside_sqrt_bfyx_fp16) { using namespace cldnn; using namespace tests; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f16, format::bfyx, {7, 10, 17, 13}}); + auto input = engine.allocate_memory({data_types::f16, format::bfyx, {7, 10, 17, 13}}); tests::set_random_values(input, true, 8, 100); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(mvn("mvn", "input", false, 1e-10f, true, true)); network network(engine, topology); @@ -218,16 +214,16 @@ TEST(mvn_gpu_test, mvn_test_across_channels_inside_sqrt_bfyx_fp16) { TEST(mvn_gpu_test, mvn_test_across_channels_outside_sqrt_bfyx_normalize_variance) { // mvn across channels fp32 test with normalize_variance set to true using namespace cldnn; - using namespace tests; + using namespace ::tests; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {7, 10, 17, 13}}); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {7, 10, 17, 13}}); tests::set_random_values(input, true, 8, 100); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(mvn("mvn", "input", true, 1e-10f, false, true)); network network(engine, topology); @@ -247,14 +243,14 @@ TEST(mvn_gpu_test, mvn_test_across_channels_inside_sqrt_bfyx_normalize_variance) using namespace cldnn; using namespace tests; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {7, 10, 17, 13}}); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {7, 10, 17, 13}}); tests::set_random_values(input, true, 8, 100); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(mvn("mvn", "input", true, 1e-10f, true, true)); network network(engine, topology); @@ -274,14 +270,14 @@ TEST(mvn_gpu_test, mvn_test_across_channels_outside_sqrt_bfyx_normalize_variance using namespace cldnn; using namespace tests; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f16, format::bfyx, {7, 10, 17, 13}}); + auto input = engine.allocate_memory({data_types::f16, format::bfyx, {7, 10, 17, 13}}); tests::set_random_values(input, true, 8, 100); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(mvn("mvn", "input", true, 1e-10f, false, true)); network network(engine, topology); @@ -299,16 +295,16 @@ TEST(mvn_gpu_test, mvn_test_across_channels_outside_sqrt_bfyx_normalize_variance TEST(mvn_gpu_test, mvn_test_across_channels_inside_sqrt_bfyx_normalize_variance_fp16) { // mvn across channels fp16 test with normalize_variance set to true using namespace cldnn; - using namespace tests; + using namespace ::tests; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f16, format::bfyx, {7, 10, 17, 13}}); + auto input = engine.allocate_memory({data_types::f16, format::bfyx, {7, 10, 17, 13}}); tests::set_random_values(input, true, 8, 100); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(mvn("mvn", "input", true, 1e-10f, true, true)); network network(engine, topology); @@ -328,14 +324,14 @@ TEST(mvn_gpu_test, mvn_test_within_channels_outside_sqrt_bfyx) { using namespace cldnn; using namespace tests; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {7, 10, 17, 13}}); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {7, 10, 17, 13}}); tests::set_random_values(input, true, 8, 100); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(mvn("mvn", "input", false, 1e-10f, false, false)); network network(engine, topology); @@ -353,16 +349,16 @@ TEST(mvn_gpu_test, mvn_test_within_channels_outside_sqrt_bfyx) { TEST(mvn_gpu_test, mvn_test_within_channels_inside_sqrt__bfyx) { // mvn within channels fp32 test with normalize_variance set to false using namespace cldnn; - using namespace tests; + using namespace ::tests; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {7, 10, 17, 13}}); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {7, 10, 17, 13}}); tests::set_random_values(input, true, 8, 100); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(mvn("mvn", "input", false, 1e-10f, true, false)); network network(engine, topology); @@ -380,16 +376,16 @@ TEST(mvn_gpu_test, mvn_test_within_channels_inside_sqrt__bfyx) { TEST(mvn_gpu_test, mvn_test_within_channels_outside_sqrt_bfyx_fp16) { // mvn within channels fp16 test with normalize_variance set to false using namespace cldnn; - using namespace tests; + using namespace ::tests; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f16, format::bfyx, {7, 10, 17, 13}}); + auto input = engine.allocate_memory({data_types::f16, format::bfyx, {7, 10, 17, 13}}); tests::set_random_values(input, true, 8, 100); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(mvn("mvn", "input", false, 1e-10f, false, false)); network network(engine, topology); @@ -409,14 +405,14 @@ TEST(mvn_gpu_test, mvn_test_within_channels_inside_sqrt_bfyx_fp16) { using namespace cldnn; using namespace tests; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f16, format::bfyx, {7, 10, 17, 13}}); + auto input = engine.allocate_memory({data_types::f16, format::bfyx, {7, 10, 17, 13}}); tests::set_random_values(input, true, 8, 100); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(mvn("mvn", "input", false, 1e-10f, true, false)); network network(engine, topology); @@ -434,16 +430,16 @@ TEST(mvn_gpu_test, mvn_test_within_channels_inside_sqrt_bfyx_fp16) { TEST(mvn_gpu_test, mvn_test_within_channels_outside_sqrt_bfyx_normalize_variance) { // mvn within channels fp32 test with normalize_variance set to true using namespace cldnn; - using namespace tests; + using namespace ::tests; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {7, 10, 17, 13}}); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {7, 10, 17, 13}}); tests::set_random_values(input, true, 8, 100); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(mvn("mvn", "input", true, 1e-10f, false, false)); network network(engine, topology); @@ -463,14 +459,14 @@ TEST(mvn_gpu_test, mvn_test_within_channels_inside_sqrt_bfyx_normalize_variance) using namespace cldnn; using namespace tests; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {7, 10, 17, 13}}); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {7, 10, 17, 13}}); tests::set_random_values(input, true, 8, 100); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(mvn("mvn", "input", true, 1e-10f, true, false)); network network(engine, topology); @@ -490,14 +486,14 @@ TEST(mvn_gpu_test, mvn_test_within_channels_outside_sqrt_bfyx_normalize_variance using namespace cldnn; using namespace tests; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f16, format::bfyx, {7, 10, 17, 13}}); + auto input = engine.allocate_memory({data_types::f16, format::bfyx, {7, 10, 17, 13}}); tests::set_random_values(input, true, 8, 100); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(mvn("mvn", "input", true, 1e-10f, false, false)); network network(engine, topology); @@ -515,16 +511,16 @@ TEST(mvn_gpu_test, mvn_test_within_channels_outside_sqrt_bfyx_normalize_variance TEST(mvn_gpu_test, mvn_test_within_channels_inside_sqrt_bfyx_normalize_variance_fp16) { // mvn within channels fp16 test with normalize_variance set to true using namespace cldnn; - using namespace tests; + using namespace ::tests; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f16, format::bfyx, {7, 10, 17, 13}}); + auto input = engine.allocate_memory({data_types::f16, format::bfyx, {7, 10, 17, 13}}); tests::set_random_values(input, true, 8, 100); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(mvn("mvn", "input", true, 1e-10f, true, false)); network network(engine, topology); @@ -551,16 +547,16 @@ struct mvn_basic_test_params { struct mvn_random_test : ::testing::TestWithParam { template - void fill_data(memory& mem, const tests::VVVVVF& data) { - auto size = mem.get_layout().size; - auto ptr = mem.pointer(); + void fill_data(memory::ptr mem, const tests::VVVVVF& data) { + auto size = mem->get_layout().size; + cldnn::mem_lock ptr(mem, get_test_stream()); for (size_t bi = 0; bi < static_cast(size.batch[0]); ++bi) { for (size_t fi = 0; fi < static_cast(size.feature[0]); ++fi) { for (size_t zi = 0; zi < static_cast(size.spatial[2]); ++zi) { for (size_t yi = 0; yi < static_cast(size.spatial[1]); ++yi) { for (size_t xi = 0; xi < static_cast(size.spatial[0]); ++xi) { auto tensor_addr = tensor(batch(bi), feature(fi), spatial(xi, yi, zi, 0)); - auto offset = mem.get_layout().get_linear_offset(tensor_addr); + auto offset = mem->get_layout().get_linear_offset(tensor_addr); ptr[offset] = data[bi][fi][xi][yi][zi]; } } @@ -570,8 +566,8 @@ struct mvn_random_test : ::testing::TestWithParam { } template - void fill_random_data(memory& mem, int min, int max, int k = 8) { - auto size = mem.get_layout().size; + void fill_random_data(memory::ptr mem, int min, int max, int k = 8) { + auto size = mem->get_layout().size; auto input_data = tests::generate_random_5d(size.batch[0], size.feature[0], size.spatial[0], @@ -583,14 +579,14 @@ struct mvn_random_test : ::testing::TestWithParam { fill_data(mem, input_data); } - void check_result(memory& output, bool across_channels, bool normalize_variance) { - if (output.get_layout().data_type == data_types::f32) { + void check_result(memory::ptr output, bool across_channels, bool normalize_variance) { + if (output->get_layout().data_type == data_types::f32) { if (across_channels) { mvn_compute_mean_across_channels(output, normalize_variance); } else { mvn_compute_mean_within_channels(output, normalize_variance); } - } else if (output.get_layout().data_type == data_types::f16) { + } else if (output->get_layout().data_type == data_types::f16) { if (across_channels) { mvn_compute_mean_across_channels(output, normalize_variance); } else { @@ -599,11 +595,11 @@ struct mvn_random_test : ::testing::TestWithParam { } } - void execute(const mvn_basic_test_params& params, const engine& eng) { + void execute(const mvn_basic_test_params& params, engine& eng) { auto& size = params.input_size; auto& output_pad = params.output_pad; - auto input = memory::allocate(eng, {params.input_type, params.input_format, size}); + auto input = eng.allocate_memory({params.input_type, params.input_format, size}); switch (params.input_type) { case data_types::f32: @@ -623,7 +619,7 @@ struct mvn_random_test : ::testing::TestWithParam { } topology topo; - topo.add(input_layout("input", input.get_layout())); + topo.add(input_layout("input", input->get_layout())); auto prim = mvn("mvn", "input", params.normalize_variance, 1e-10f, false, params.across_channels); prim.output_padding = output_pad; topo.add(prim); @@ -642,7 +638,7 @@ struct mvn_random_test : ::testing::TestWithParam { }; TEST_P(mvn_random_test, random) { - auto eng = tests::get_test_engine(); + auto& eng = tests::get_test_engine(); this->execute(GetParam(), eng); } diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/non_max_suppression_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/non_max_suppression_test.cpp index 554e648608607a..7ca881a7b2747b 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/non_max_suppression_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/non_max_suppression_test.cpp @@ -4,17 +4,14 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// -#include - #include "test_utils.h" -#include "api/topology.hpp" -#include "api/network.hpp" -#include "api/input_layout.hpp" -#include "api/non_max_suppression.hpp" -#include "api/data.hpp" +#include +#include +#include using namespace cldnn; +using namespace ::tests; template struct non_max_suppression_basic : public testing::Test { @@ -73,14 +70,14 @@ struct non_max_suppression_basic : public testing::Test { const layout boxes_layout = layout(type_to_data_type::value, format::bfyx, tensor(batch(batch_size), feature(boxes_num), spatial(1, 4))); const layout scores_layout = layout(type_to_data_type::value, format::bfyx, tensor(batch(batch_size), feature(classes_num), spatial(1, boxes_num))); - memory get_boxes_memory(engine& engine) { - auto mem = memory::allocate(engine, boxes_layout); + memory::ptr get_boxes_memory(engine& engine) { + auto mem = engine.allocate_memory(boxes_layout); tests::set_values(mem, boxes_data); return mem; } - memory get_scores_memory(engine& engine) { - auto mem = memory::allocate(engine, scores_layout); + memory::ptr get_scores_memory(engine& engine) { + auto mem = engine.allocate_memory(scores_layout); tests::set_values(mem, scores_data); return mem; } @@ -92,7 +89,7 @@ using nms_types = testing::Types; TYPED_TEST_CASE(non_max_suppression_basic, nms_types); TYPED_TEST(non_max_suppression_basic, basic) { - auto engine = tests::get_test_engine(); + auto& engine = tests::get_test_engine(); topology topo; topo.add(input_layout("boxes", this->boxes_layout)); @@ -122,7 +119,7 @@ TYPED_TEST(non_max_suppression_basic, basic) { }; auto out_mem = result.at("nms").get_memory(); - auto out_ptr = out_mem.pointer(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); ASSERT_EQ(expected_out.size(), out_ptr.size()); for (size_t i = 0; i < expected_out.size(); ++i) { @@ -131,9 +128,9 @@ TYPED_TEST(non_max_suppression_basic, basic) { } TYPED_TEST(non_max_suppression_basic, num_per_class) { - auto engine = tests::get_test_engine(); + auto& engine = tests::get_test_engine(); - auto num_per_class_mem = memory::allocate(engine, layout(data_types::f32, format::bfyx, tensor(batch(1)))); + auto num_per_class_mem = engine.allocate_memory(layout(data_types::f32, format::bfyx, tensor(batch(1)))); tests::set_values(num_per_class_mem, { 1.f }); topology topo; @@ -165,7 +162,7 @@ TYPED_TEST(non_max_suppression_basic, num_per_class) { }; auto out_mem = result.at("nms").get_memory(); - auto out_ptr = out_mem.pointer(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); ASSERT_EQ(expected_out.size(), out_ptr.size()); for (size_t i = 0; i < expected_out.size(); ++i) { @@ -174,11 +171,11 @@ TYPED_TEST(non_max_suppression_basic, num_per_class) { } TYPED_TEST(non_max_suppression_basic, iou_threshold) { - auto engine = tests::get_test_engine(); + auto& engine = tests::get_test_engine(); - auto num_per_class_mem = memory::allocate(engine, layout(data_types::f32, format::bfyx, tensor(batch(1)))); + auto num_per_class_mem = engine.allocate_memory(layout(data_types::f32, format::bfyx, tensor(batch(1)))); tests::set_values(num_per_class_mem, { 3.f }); - auto iou_threshold_mem = memory::allocate(engine, layout(data_types::f32, format::bfyx, tensor(batch(1)))); + auto iou_threshold_mem = engine.allocate_memory(layout(data_types::f32, format::bfyx, tensor(batch(1)))); tests::set_values(iou_threshold_mem, { 0.4f }); topology topo; @@ -211,7 +208,7 @@ TYPED_TEST(non_max_suppression_basic, iou_threshold) { }; auto out_mem = result.at("nms").get_memory(); - auto out_ptr = out_mem.pointer(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); ASSERT_EQ(expected_out.size(), out_ptr.size()); for (size_t i = 0; i < expected_out.size(); ++i) { @@ -220,13 +217,13 @@ TYPED_TEST(non_max_suppression_basic, iou_threshold) { } TYPED_TEST(non_max_suppression_basic, score_threshold) { - auto engine = tests::get_test_engine(); + auto& engine = tests::get_test_engine(); - auto num_per_class_mem = memory::allocate(engine, layout(data_types::f32, format::bfyx, tensor(batch(1)))); + auto num_per_class_mem = engine.allocate_memory(layout(data_types::f32, format::bfyx, tensor(batch(1)))); tests::set_values(num_per_class_mem, { 3.f }); - auto iou_threshold_mem = memory::allocate(engine, layout(data_types::f32, format::bfyx, tensor(batch(1)))); + auto iou_threshold_mem = engine.allocate_memory(layout(data_types::f32, format::bfyx, tensor(batch(1)))); tests::set_values(iou_threshold_mem, { 0.4f }); - auto score_threshold_mem = memory::allocate(engine, layout(data_types::f32, format::bfyx, tensor(batch(1)))); + auto score_threshold_mem = engine.allocate_memory(layout(data_types::f32, format::bfyx, tensor(batch(1)))); tests::set_values(score_threshold_mem, { 0.4f }); topology topo; @@ -260,7 +257,7 @@ TYPED_TEST(non_max_suppression_basic, score_threshold) { }; auto out_mem = result.at("nms").get_memory(); - auto out_ptr = out_mem.pointer(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); ASSERT_EQ(expected_out.size(), out_ptr.size()); for (size_t i = 0; i < expected_out.size(); ++i) { @@ -269,15 +266,15 @@ TYPED_TEST(non_max_suppression_basic, score_threshold) { } TYPED_TEST(non_max_suppression_basic, soft_nms_sigma) { - auto engine = tests::get_test_engine(); + auto& engine = tests::get_test_engine(); - auto num_per_class_mem = memory::allocate(engine, layout(data_types::f32, format::bfyx, tensor(batch(1)))); + auto num_per_class_mem = engine.allocate_memory(layout(data_types::f32, format::bfyx, tensor(batch(1)))); tests::set_values(num_per_class_mem, { 3.f }); - auto iou_threshold_mem = memory::allocate(engine, layout(data_types::f32, format::bfyx, tensor(batch(1)))); + auto iou_threshold_mem = engine.allocate_memory(layout(data_types::f32, format::bfyx, tensor(batch(1)))); tests::set_values(iou_threshold_mem, { 0.4f }); - auto score_threshold_mem = memory::allocate(engine, layout(data_types::f32, format::bfyx, tensor(batch(1)))); + auto score_threshold_mem = engine.allocate_memory(layout(data_types::f32, format::bfyx, tensor(batch(1)))); tests::set_values(score_threshold_mem, { 0.4f }); - auto soft_nms_sigma_mem = memory::allocate(engine, layout(data_types::f32, format::bfyx, tensor(batch(1)))); + auto soft_nms_sigma_mem = engine.allocate_memory(layout(data_types::f32, format::bfyx, tensor(batch(1)))); tests::set_values(soft_nms_sigma_mem, { 0.5f }); topology topo; @@ -312,7 +309,7 @@ TYPED_TEST(non_max_suppression_basic, soft_nms_sigma) { }; auto out_mem = result.at("nms").get_memory(); - auto out_ptr = out_mem.pointer(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); ASSERT_EQ(expected_out.size(), out_ptr.size()); for (size_t i = 0; i < expected_out.size(); ++i) { diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/normalizel2_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/normalizel2_gpu_test.cpp index 00a400cce57453..a96185c7d8f9c3 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/normalizel2_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/normalizel2_gpu_test.cpp @@ -3,15 +3,12 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include -#include -#include -#include "test_utils/test_utils.h" -#include +#include "test_utils.h" + +#include +#include +#include #include #include @@ -23,15 +20,15 @@ TEST(normalizel2_f32_gpu, basic) { // Input : 1x2x3x3 // Output : 1x2x3x3 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const unsigned b = 1; const unsigned f = 2; const unsigned y = 3; const unsigned x = 3; - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {b, f, y, x}}); - auto weights = memory::allocate(engine, {data_types::f32, format::bfyx, {1, f, 1, 1}}); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {b, f, y, x}}); + auto weights = engine.allocate_memory({data_types::f32, format::bfyx, {1, f, 1, 1}}); std::vector inputVals(b * f * y * x); std::generate(inputVals.begin(), inputVals.end(), []() { @@ -47,7 +44,7 @@ TEST(normalizel2_f32_gpu, basic) { set_values(weights, weightVals); topology topology; - topology.add(input_layout("Input0", input.get_layout())); + topology.add(input_layout("Input0", input->get_layout())); topology.add(data("Input1", weights)); topology.add(normalize("normalizel2", "Input0", "Input1", false)); @@ -58,7 +55,7 @@ TEST(normalizel2_f32_gpu, basic) { auto outputs = network.execute(); auto output = outputs.at("normalizel2").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = {0.f, 0.0995037f, @@ -88,15 +85,15 @@ TEST(normalizel2_f32_gpu, basic2) { // Input : 1x2x3x3 // Output : 1x2x3x3 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const unsigned b = 1; const unsigned f = 2; const unsigned y = 3; const unsigned x = 3; - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {b, f, y, x}}); - auto weights = memory::allocate(engine, {data_types::f32, format::bfyx, {1, f, 1, 1}}); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {b, f, y, x}}); + auto weights = engine.allocate_memory({data_types::f32, format::bfyx, {1, f, 1, 1}}); std::vector inputVals(b * f * y * x); std::generate(inputVals.begin(), inputVals.end(), []() { @@ -112,7 +109,7 @@ TEST(normalizel2_f32_gpu, basic2) { set_values(weights, weightVals); topology topology; - topology.add(input_layout("Input0", input.get_layout())); + topology.add(input_layout("Input0", input->get_layout())); topology.add(data("Input1", weights)); topology.add(normalize("normalizel2", "Input0", "Input1", true)); @@ -123,7 +120,7 @@ TEST(normalizel2_f32_gpu, basic2) { auto outputs = network.execute(); auto output = outputs.at("normalizel2").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = {0.f, 0.0236691f, @@ -153,15 +150,15 @@ TEST(normalizel2_int8_gpu, basic) { // Input : 1x2x3x3 // Output : 1x2x3x3 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const unsigned b = 1; const unsigned f = 2; const unsigned y = 3; const unsigned x = 3; - auto input = memory::allocate(engine, {data_types::i8, format::bfyx, {b, f, y, x}}); - auto weights = memory::allocate(engine, {data_types::f32, format::bfyx, {1, f, 1, 1}}); + auto input = engine.allocate_memory({data_types::i8, format::bfyx, {b, f, y, x}}); + auto weights = engine.allocate_memory({data_types::f32, format::bfyx, {1, f, 1, 1}}); std::vector inputVals(b * f * y * x); std::generate(inputVals.begin(), inputVals.end(), []() { @@ -177,7 +174,7 @@ TEST(normalizel2_int8_gpu, basic) { set_values(weights, weightVals); topology topology; - topology.add(input_layout("Input0", input.get_layout())); + topology.add(input_layout("Input0", input->get_layout())); topology.add(data("Input1", weights)); topology.add(normalize("normalizel2", "Input0", "Input1", false)); @@ -188,7 +185,7 @@ TEST(normalizel2_int8_gpu, basic) { auto outputs = network.execute(); auto output = outputs.at("normalizel2").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = {0.f, 0.0995037f, @@ -218,15 +215,15 @@ TEST(normalizel2_int8_gpu, basic2) { // Input : 1x2x3x3 // Output : 1x2x3x3 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const unsigned b = 1; const unsigned f = 2; const unsigned y = 3; const unsigned x = 3; - auto input = memory::allocate(engine, {data_types::i8, format::bfyx, {b, f, y, x}}); - auto weights = memory::allocate(engine, {data_types::f32, format::bfyx, {1, f, 1, 1}}); + auto input = engine.allocate_memory({data_types::i8, format::bfyx, {b, f, y, x}}); + auto weights = engine.allocate_memory({data_types::f32, format::bfyx, {1, f, 1, 1}}); std::vector inputVals(b * f * y * x); std::generate(inputVals.begin(), inputVals.end(), []() { @@ -242,7 +239,7 @@ TEST(normalizel2_int8_gpu, basic2) { set_values(weights, weightVals); topology topology; - topology.add(input_layout("Input0", input.get_layout())); + topology.add(input_layout("Input0", input->get_layout())); topology.add(data("Input1", weights)); topology.add(normalize("normalizel2", "Input0", "Input1", true)); @@ -253,7 +250,7 @@ TEST(normalizel2_int8_gpu, basic2) { auto outputs = network.execute(); auto output = outputs.at("normalizel2").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = {0.f, 0.0236691f, diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/one_hot_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/one_hot_gpu_test.cpp index cb510e4a685119..08bb8690be0976 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/one_hot_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/one_hot_gpu_test.cpp @@ -3,17 +3,11 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include -#include -#include -#include +#include "test_utils.h" -#include "test_utils/test_utils.h" -#include "test_utils/uniform_quantized_real_distribution.hpp" +#include +#include #include @@ -83,13 +77,13 @@ void generic_one_hot_test_int(cldnn::format test_input_fmt, int input_b, int inp VVVVF input_rnd = generate_random_4d(input_b, input_f, input_y, input_x, min_random, max_random); VF input_rnd_vec = flatten_4d(test_input_fmt, input_rnd); - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); tensor input_tensor(input_b, input_f, input_x, input_y); - auto input = memory::allocate(engine, { type_to_data_type::value, test_input_fmt, input_tensor }); + auto input = engine.allocate_memory({ type_to_data_type::value, test_input_fmt, input_tensor }); set_values(input, input_rnd_vec); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(one_hot("output", "input", shape, one_hot_axis)); network network(engine, topology); @@ -99,8 +93,8 @@ void generic_one_hot_test_int(cldnn::format test_input_fmt, int input_b, int inp EXPECT_EQ(outputs.begin()->first, "output"); auto output_memory = outputs.at("output").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); VVVVF output_cpu = one_hot_cpu(input_rnd, one_hot_axis, one_hot_limit, input_padding_y, input_padding_x, output_padding_y, output_padding_x); EXPECT_EQ(output_layout.format.value, test_input_fmt.value); @@ -166,11 +160,11 @@ TEST(one_hot_gpu_i32, bfzyx_ax4) { VF input_rnd_vec = {0, 1}; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); tensor input_tensor(in_b, in_f, in_x, in_y); - auto input = memory::allocate(engine, { data_types::i32, format::bfyx, input_tensor }); + auto input = engine.allocate_memory({ data_types::i32, format::bfyx, input_tensor }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(one_hot("output","input", shape, one_hot_axis)); set_values(input, input_rnd_vec); @@ -182,8 +176,8 @@ TEST(one_hot_gpu_i32, bfzyx_ax4) { EXPECT_EQ(outputs.begin()->first, "output"); auto output_memory = outputs.at("output").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); tensor output_tensor = output_layout.get_buffer_size(); int z_size = output_tensor.spatial[2]; @@ -225,11 +219,11 @@ TEST(one_hot_gpu_i64, bfzyx_ax4) { VF input_rnd_vec = {0, 1}; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); tensor input_tensor(in_b, in_f, in_x, in_y); - auto input = memory::allocate(engine, { data_types::i64, format::bfyx, input_tensor }); + auto input = engine.allocate_memory({ data_types::i64, format::bfyx, input_tensor }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(one_hot("output","input", shape, one_hot_axis)); set_values(input, input_rnd_vec); @@ -241,8 +235,8 @@ TEST(one_hot_gpu_i64, bfzyx_ax4) { EXPECT_EQ(outputs.begin()->first, "output"); auto output_memory = outputs.at("output").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); tensor output_tensor = output_layout.get_buffer_size(); int z_size = output_tensor.spatial[2]; @@ -284,11 +278,11 @@ TEST(one_hot_gpu_i32_to_f32, bfyx_ax4) { VF input_rnd_vec = {0, 1}; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); tensor input_tensor(in_b, in_f, in_x, in_y); - auto input = memory::allocate(engine, { data_types::i32, format::bfyx, input_tensor }); + auto input = engine.allocate_memory({ data_types::i32, format::bfyx, input_tensor }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(one_hot("output","input", shape, data_types::f32, one_hot_axis)); set_values(input, input_rnd_vec); @@ -300,8 +294,8 @@ TEST(one_hot_gpu_i32_to_f32, bfyx_ax4) { EXPECT_EQ(outputs.begin()->first, "output"); auto output_memory = outputs.at("output").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); tensor output_tensor = output_layout.get_buffer_size(); int z_size = output_tensor.spatial[2]; @@ -338,11 +332,11 @@ TEST(one_hot_gpu_i64_to_f32, bfyx_ax4) { VF input_rnd_vec = {0, 1}; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); tensor input_tensor(in_b, in_f, in_x, in_y); - auto input = memory::allocate(engine, { data_types::i64, format::bfyx, input_tensor }); + auto input = engine.allocate_memory({ data_types::i64, format::bfyx, input_tensor }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(one_hot("output","input", shape, data_types::f32, one_hot_axis)); set_values(input, input_rnd_vec); @@ -354,8 +348,8 @@ TEST(one_hot_gpu_i64_to_f32, bfyx_ax4) { EXPECT_EQ(outputs.begin()->first, "output"); auto output_memory = outputs.at("output").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); tensor output_tensor = output_layout.get_buffer_size(); int z_size = output_tensor.spatial[2]; @@ -389,11 +383,11 @@ TEST(one_hot_gpu_i32, bfzyx_ax0) { VF input_rnd_vec = {0, 1}; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); tensor input_tensor(in_b, in_f, in_x, in_y); - auto input = memory::allocate(engine, { data_types::i32, format::bfyx, input_tensor }); + auto input = engine.allocate_memory({ data_types::i32, format::bfyx, input_tensor }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(one_hot("output","input", shape, one_hot_axis)); set_values(input, input_rnd_vec); @@ -405,8 +399,8 @@ TEST(one_hot_gpu_i32, bfzyx_ax0) { EXPECT_EQ(outputs.begin()->first, "output"); auto output_memory = outputs.at("output").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); tensor output_tensor = output_layout.get_buffer_size(); int z_size = output_tensor.spatial[2]; @@ -444,11 +438,11 @@ TEST(one_hot_gpu_i64, bfzyx_ax0) { VF input_rnd_vec = {0, 1}; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); tensor input_tensor(in_b, in_f, in_x, in_y); - auto input = memory::allocate(engine, { data_types::i64, format::bfyx, input_tensor }); + auto input = engine.allocate_memory({ data_types::i64, format::bfyx, input_tensor }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(one_hot("output","input", shape, one_hot_axis)); set_values(input, input_rnd_vec); @@ -460,8 +454,8 @@ TEST(one_hot_gpu_i64, bfzyx_ax0) { EXPECT_EQ(outputs.begin()->first, "output"); auto output_memory = outputs.at("output").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); tensor output_tensor = output_layout.get_buffer_size(); int z_size = output_tensor.spatial[2]; @@ -499,11 +493,11 @@ TEST(one_hot_gpu_i32, bfzyx_ax1) { VF input_rnd_vec = {0, 1}; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); tensor input_tensor(in_b, in_f, in_x, in_y); - auto input = memory::allocate(engine, { data_types::i32, format::bfyx, input_tensor }); + auto input = engine.allocate_memory({ data_types::i32, format::bfyx, input_tensor }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(one_hot("output","input", shape, one_hot_axis)); set_values(input, input_rnd_vec); @@ -515,8 +509,8 @@ TEST(one_hot_gpu_i32, bfzyx_ax1) { EXPECT_EQ(outputs.begin()->first, "output"); auto output_memory = outputs.at("output").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); tensor output_tensor = output_layout.get_buffer_size(); int z_size = output_tensor.spatial[2]; @@ -554,11 +548,11 @@ TEST(one_hot_gpu_i64, bfzyx_ax1) { VF input_rnd_vec = {0, 1}; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); tensor input_tensor(in_b, in_f, in_x, in_y); - auto input = memory::allocate(engine, { data_types::i64, format::bfyx, input_tensor }); + auto input = engine.allocate_memory({ data_types::i64, format::bfyx, input_tensor }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(one_hot("output","input", shape, one_hot_axis)); set_values(input, input_rnd_vec); @@ -570,8 +564,8 @@ TEST(one_hot_gpu_i64, bfzyx_ax1) { EXPECT_EQ(outputs.begin()->first, "output"); auto output_memory = outputs.at("output").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); tensor output_tensor = output_layout.get_buffer_size(); int z_size = output_tensor.spatial[2]; @@ -609,11 +603,11 @@ TEST(one_hot_gpu_i32, bfzyx_ax2) { VF input_rnd_vec = {0, 1}; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); tensor input_tensor(in_b, in_f, in_x, in_y); - auto input = memory::allocate(engine, { data_types::i32, format::bfyx, input_tensor }); + auto input = engine.allocate_memory({ data_types::i32, format::bfyx, input_tensor }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(one_hot("output","input", shape, one_hot_axis)); set_values(input, input_rnd_vec); @@ -625,8 +619,8 @@ TEST(one_hot_gpu_i32, bfzyx_ax2) { EXPECT_EQ(outputs.begin()->first, "output"); auto output_memory = outputs.at("output").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); tensor output_tensor = output_layout.get_buffer_size(); int z_size = output_tensor.spatial[2]; @@ -664,11 +658,11 @@ TEST(one_hot_gpu_i64, bfzyx_ax2) { VF input_rnd_vec = {0, 1}; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); tensor input_tensor(in_b, in_f, in_x, in_y); - auto input = memory::allocate(engine, { data_types::i64, format::bfyx, input_tensor }); + auto input = engine.allocate_memory({ data_types::i64, format::bfyx, input_tensor }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(one_hot("output","input", shape, one_hot_axis)); set_values(input, input_rnd_vec); @@ -680,8 +674,8 @@ TEST(one_hot_gpu_i64, bfzyx_ax2) { EXPECT_EQ(outputs.begin()->first, "output"); auto output_memory = outputs.at("output").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); tensor output_tensor = output_layout.get_buffer_size(); int z_size = output_tensor.spatial[2]; @@ -719,11 +713,11 @@ TEST(one_hot_gpu_i32, bfzyx_ax3) { VF input_rnd_vec = {0, 1}; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); tensor input_tensor(in_b, in_f, in_x, in_y); - auto input = memory::allocate(engine, { data_types::i32, format::bfyx, input_tensor }); + auto input = engine.allocate_memory({ data_types::i32, format::bfyx, input_tensor }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(one_hot("output","input", shape, one_hot_axis)); set_values(input, input_rnd_vec); @@ -735,8 +729,8 @@ TEST(one_hot_gpu_i32, bfzyx_ax3) { EXPECT_EQ(outputs.begin()->first, "output"); auto output_memory = outputs.at("output").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); tensor output_tensor = output_layout.get_buffer_size(); int z_size = output_tensor.spatial[2]; @@ -774,11 +768,11 @@ TEST(one_hot_gpu_i64, bfzyx_ax3) { VF input_rnd_vec = {0, 1}; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); tensor input_tensor(in_b, in_f, in_x, in_y); - auto input = memory::allocate(engine, { data_types::i64, format::bfyx, input_tensor }); + auto input = engine.allocate_memory({ data_types::i64, format::bfyx, input_tensor }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(one_hot("output","input", shape, one_hot_axis)); set_values(input, input_rnd_vec); @@ -790,8 +784,8 @@ TEST(one_hot_gpu_i64, bfzyx_ax3) { EXPECT_EQ(outputs.begin()->first, "output"); auto output_memory = outputs.at("output").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); tensor output_tensor = output_layout.get_buffer_size(); int z_size = output_tensor.spatial[2]; @@ -818,11 +812,11 @@ TEST(one_hot_gpu_i64, bfzyx_ax3) { } TEST(one_hot_error, basic_error_wrong_axis) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::i32, format::bfyx,{ 1, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::i32, format::bfyx,{ 1, 1, 1, 1 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(one_hot("output", "input", tensor(1, 1, 1, 50), 5)); std::string msg_to_find = "Incorrect parameters configuration: one_hot_axis should be less or equal to 4."; @@ -830,11 +824,11 @@ TEST(one_hot_error, basic_error_wrong_axis) { } TEST(one_hot_error, basic_error_bad_shape) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::i32, format::bfyx,{ 1, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::i32, format::bfyx,{ 1, 1, 1, 1 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(one_hot("output", "input", tensor(1, 5, 1, 50), 2)); std::string msg_to_find = "Incorrect parameters configuration: shape does not fit input size."; diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/permute_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/permute_gpu_test.cpp index d22a5bf8077e9d..7fb709d9845984 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/permute_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/permute_gpu_test.cpp @@ -3,31 +3,28 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include "api/permute.hpp" -#include "api/reorder.hpp" -#include -#include -#include -#include "test_utils/test_utils.h" -#include -#include -#include -#include + +#include "test_utils.h" + +#include +#include +#include +#include +#include +#include +#include + #include -#include #include #include using namespace cldnn; -using namespace tests; +using namespace ::tests; using namespace testing; TEST(permute_gpu_f32, output_ordering_test) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); std::vector> input_tensors = { @@ -60,9 +57,9 @@ TEST(permute_gpu_f32, output_ordering_test) for (auto const& perm : permutations) { - auto input = memory::allocate(engine, { data_types::f32, fr, tensor(inp_t) }); + auto input = engine.allocate_memory({ data_types::f32, fr, tensor(inp_t) }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), permute("permute", "input", perm)); network network(engine, topology); @@ -72,7 +69,7 @@ TEST(permute_gpu_f32, output_ordering_test) auto output_mem = output.get_memory(); EXPECT_EQ(outputs.size(), size_t(1)); auto ref_tensor = get_permutation(inp_t, perm); - auto out_tensor = output_mem.get_layout().size; + auto out_tensor = output_mem->get_layout().size; EXPECT_EQ(out_tensor.batch[0], ref_tensor[0]); EXPECT_EQ(out_tensor.feature[0], ref_tensor[1]); EXPECT_EQ(out_tensor.spatial[0], ref_tensor[2]); @@ -95,9 +92,9 @@ TEST(permute_gpu_f32, basic_bfyx_permute_0_1_2_3) // // Output = input - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 3, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 3, 2 } }); std::vector values = { @@ -117,7 +114,7 @@ TEST(permute_gpu_f32, basic_bfyx_permute_0_1_2_3) set_values(input, values); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), permute("permute", "input", { 0, 1, 2, 3 })); network network(engine, topology); @@ -129,7 +126,7 @@ TEST(permute_gpu_f32, basic_bfyx_permute_0_1_2_3) auto output = outputs.begin()->second.get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 24; i++) { EXPECT_FLOAT_EQ(values[i], output_ptr[i]); @@ -157,9 +154,9 @@ TEST(permute_gpu_f32, basic_bfyx_permute_0_1_3_2) // f1: b0: -15 -15 b1: -15 -15 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 3, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 3, 2 } }); set_values(input, { 1.0f, 2.0f, -15.f, @@ -176,7 +173,7 @@ TEST(permute_gpu_f32, basic_bfyx_permute_0_1_3_2) }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), permute("permute", "input", { 0, 1, 3, 2 })); network network(engine, topology); @@ -206,7 +203,7 @@ TEST(permute_gpu_f32, basic_bfyx_permute_0_1_3_2) -15.0f, -15.0f, }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 24; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -216,14 +213,14 @@ TEST(permute_gpu_f32, basic_bfyx_permute_0_1_3_2) TEST(permute_gpu_f32, basic_yxfb_permute_1_0_2_3) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_mem = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 100, 64, 1 } }); + auto input_mem = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 100, 64, 1 } }); tests::set_random_values(input_mem); topology topology( - input_layout("input", input_mem.get_layout()), + input_layout("input", input_mem->get_layout()), permute("permute", "input", { 1, 0, 2, 3 })); network network(engine, topology); @@ -235,8 +232,8 @@ TEST(permute_gpu_f32, basic_yxfb_permute_1_0_2_3) auto output = outputs.begin()->second.get_memory(); - auto output_ptr = output.pointer(); - auto input_ptr = input_mem.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + cldnn::mem_lock input_ptr(input_mem, get_test_stream()); for (int i = 0; i < 6400; i++) { EXPECT_FLOAT_EQ(input_ptr[i], output_ptr[i]); @@ -265,9 +262,9 @@ TEST(permute_gpu_f32, basic_bfyx_permute_0_1_3_2_input_padding) // f1: b0: -15 -15 b1: -15 -15 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 3, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 3, 2 } }); set_values(input, { 1.0f, 2.0f, -15.f, @@ -284,8 +281,8 @@ TEST(permute_gpu_f32, basic_bfyx_permute_0_1_3_2_input_padding) }); topology topology( - input_layout("input", input.get_layout()), - reorder("reorder", "input", input.get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 })), + input_layout("input", input->get_layout()), + reorder("reorder", "input", input->get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 })), permute("permute", "reorder", { 0, 1, 3, 2 })); network network(engine, topology); @@ -315,7 +312,7 @@ TEST(permute_gpu_f32, basic_bfyx_permute_0_1_3_2_input_padding) -15.0f, -15.0f, }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 24; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -329,9 +326,9 @@ TEST(permute_gpu_f32, basic_yxfb_permute_batch_with_feature) // Permute order : { 1, 0, 2, 3 } // Output : yxfb:2x8x1x1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 8, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 8, 2, 1, 1 } }); set_values(input, { //b0 - b7 for f=0 @@ -342,7 +339,7 @@ TEST(permute_gpu_f32, basic_yxfb_permute_batch_with_feature) }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), permute("permute", "input", { 1, 0, 2, 3 })); network network(engine, topology); @@ -353,7 +350,7 @@ TEST(permute_gpu_f32, basic_yxfb_permute_batch_with_feature) EXPECT_EQ(outputs.begin()->first, "permute"); auto output = outputs.begin()->second.get_memory(); - auto out_tensor = output.get_layout().size; + auto out_tensor = output->get_layout().size; EXPECT_EQ(out_tensor.batch[0], 2); EXPECT_EQ(out_tensor.feature[0], 8); EXPECT_EQ(out_tensor.spatial[0], 1); @@ -370,7 +367,7 @@ TEST(permute_gpu_f32, basic_yxfb_permute_batch_with_feature) 5.2f, 8.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -384,9 +381,9 @@ TEST(permute_gpu_f32, basic_bfyx_permute_batch_with_feature) // Permute order : { 1, 0, 2, 3 } // Output : yxfb:2x8x1x1 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 8, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 8, 1, 1 } }); set_values(input, { //f0 - f7 for b=0 @@ -397,7 +394,7 @@ TEST(permute_gpu_f32, basic_bfyx_permute_batch_with_feature) }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), permute("permute", "input", { 1, 0, 2, 3 })); network network(engine, topology); @@ -408,7 +405,7 @@ TEST(permute_gpu_f32, basic_bfyx_permute_batch_with_feature) EXPECT_EQ(outputs.begin()->first, "permute"); auto output = outputs.begin()->second.get_memory(); - auto out_tensor = output.get_layout().size; + auto out_tensor = output->get_layout().size; EXPECT_EQ(out_tensor.batch[0], 8); EXPECT_EQ(out_tensor.feature[0], 2); EXPECT_EQ(out_tensor.spatial[0], 1); @@ -425,7 +422,7 @@ TEST(permute_gpu_f32, basic_bfyx_permute_batch_with_feature) 5.2f, 8.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -436,9 +433,9 @@ TEST(permute_gpu_f32, basic_bfyx_permute_batch_with_feature) template void permute_test_with_reorder() { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 3, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 3, 2 } }); set_values(input, { 1.0f, 2.0f, -15.f, @@ -455,7 +452,7 @@ void permute_test_with_reorder() }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("reorder", "input", { DType, format::bfyx,{ 2, 2, 3, 2 } }), permute("permute", "reorder", { 0, 1, 3, 2 }), reorder("reorder_out", "permute", { data_types::f32, format::bfyx,{ 2, 2, 3, 2 } })); @@ -487,7 +484,7 @@ void permute_test_with_reorder() -15.0f, -15.0f, }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 24; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -512,8 +509,8 @@ TEST(permute_fuse_reorder_gpu_f32, basic_b_fs_yx_fsv4_permute_1_8_16_1) // Permute1 order : {0, 3, 1, 2} // Permute2 order : {0, 2, 3, 1} - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, {1, 8, 1, 16}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, {1, 8, 1, 16}}); std::vector values = { 0.0f, 1.0f, 2.0f, 3.0f, @@ -553,7 +550,7 @@ TEST(permute_fuse_reorder_gpu_f32, basic_b_fs_yx_fsv4_permute_1_8_16_1) set_values(input, values); // unfused topology topology_unfused( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("reorder1", "input", format::b_fs_yx_fsv4, data_types::f32), permute("permute", "reorder1", { 0, 3, 1, 2}), reorder("reorder2", "permute", format::bfyx, data_types::f32), @@ -568,7 +565,7 @@ TEST(permute_fuse_reorder_gpu_f32, basic_b_fs_yx_fsv4_permute_1_8_16_1) // fused network topology topology_fused( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("reorder1", "input", format::b_fs_yx_fsv4, data_types::f32), permute("permute", "reorder1", { 0, 3, 1, 2}), reorder("reorder2", "permute", format::bfyx, data_types::f32), // to be fused to previous permute @@ -582,11 +579,11 @@ TEST(permute_fuse_reorder_gpu_f32, basic_b_fs_yx_fsv4_permute_1_8_16_1) auto outputs_fused = fused.execute(); auto outputs_unfused = unfused.execute(); auto output_fused = outputs_fused.begin()->second.get_memory(); - auto output_fused_ptr = output_fused.pointer(); + cldnn::mem_lock output_fused_ptr(output_fused, get_test_stream()); auto output_unfused = outputs_unfused.begin()->second.get_memory(); - auto output_unfused_ptr = output_unfused.pointer(); - EXPECT_EQ(output_fused.get_layout().format, cldnn::format::bfyx); - EXPECT_EQ(output_unfused.get_layout().format, cldnn::format::bfyx); + cldnn::mem_lock output_unfused_ptr(output_unfused, get_test_stream()); + EXPECT_EQ(output_fused->get_layout().format, cldnn::format::bfyx); + EXPECT_EQ(output_unfused->get_layout().format, cldnn::format::bfyx); EXPECT_EQ(fused.get_executed_primitives().size(), 4); EXPECT_EQ(unfused.get_executed_primitives().size(), 5); @@ -599,13 +596,13 @@ TEST(permute_fuse_reorder_gpu_f32, basic_b_fs_yx_fsv4_permute_1_8_16_1) TEST(fc_permute_crop_gpu, basic_permute_yxfb) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_mem = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 5, 1, 512 } }); + auto input_mem = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 5, 1, 512 } }); //Topolgy creates permute which "repalces" the batch with the feature. topology topology( - input_layout("input", input_mem.get_layout()), // yxfb {1, 5, 1, 512 }} + input_layout("input", input_mem->get_layout()), // yxfb {1, 5, 1, 512 }} permute("permute", "input", { 1, 0, 2, 3 }) // yxfb {5, 1, 1, 512} --- without permute fix yxfb {1, 5, 512, 1} ); @@ -617,25 +614,25 @@ TEST(fc_permute_crop_gpu, basic_permute_yxfb) EXPECT_EQ(outputs.begin()->first, "permute"); auto output = outputs.begin()->second.get_memory(); - auto out_tensor = output.get_layout().size; + auto out_tensor = output->get_layout().size; EXPECT_EQ(out_tensor.batch[0], 5); EXPECT_EQ(out_tensor.feature[0], 1); EXPECT_EQ(out_tensor.spatial[0], 1); EXPECT_EQ(out_tensor.spatial[1], 512); - EXPECT_EQ(output.get_layout().format, cldnn::format::yxfb); + EXPECT_EQ(output->get_layout().format, cldnn::format::yxfb); } TEST(fc_permute_crop_gpu, basic_0) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_mem = memory::allocate(engine, { data_types::f32, format::yxfb,{ 5, 11264, 1, 1 } }); - auto weights_mem = memory::allocate(engine, { data_types::f32, format::yxio,{ 512, 11264, 1, 1 } }); - auto bias_mem = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 512, 1 } }); + auto input_mem = engine.allocate_memory({ data_types::f32, format::yxfb,{ 5, 11264, 1, 1 } }); + auto weights_mem = engine.allocate_memory({ data_types::f32, format::yxio,{ 512, 11264, 1, 1 } }); + auto bias_mem = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 512, 1 } }); topology topology( - input_layout("input", input_mem.get_layout()), // bfyx {5, 11264, 1, 1}} + input_layout("input", input_mem->get_layout()), // bfyx {5, 11264, 1, 1}} data("weights", weights_mem), data("bias", bias_mem), fully_connected("fully_connected", "input", "weights", "bias"), // yxfb {5, 512, 1, 1} @@ -652,25 +649,25 @@ TEST(fc_permute_crop_gpu, basic_0) EXPECT_EQ(outputs.begin()->first, "crop"); auto output = outputs.begin()->second.get_memory(); - auto out_tensor = output.get_layout().size; + auto out_tensor = output->get_layout().size; EXPECT_EQ(out_tensor.batch[0], 1); EXPECT_EQ(out_tensor.feature[0], 1); EXPECT_EQ(out_tensor.spatial[0], 1); EXPECT_EQ(out_tensor.spatial[1], 512); - EXPECT_EQ(output.get_layout().format, cldnn::format::yxfb); + EXPECT_EQ(output->get_layout().format, cldnn::format::yxfb); } TEST(fc_permute_gpu, basic_permute_bfyx) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_mem = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 5, 1, 256 } }); + auto input_mem = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 5, 1, 256 } }); tests::set_random_values(input_mem); //Topolgy creates permute which "repalces" the batch with the feature. topology topology( - input_layout("input", input_mem.get_layout()), + input_layout("input", input_mem->get_layout()), permute("permute", "input", { 1, 0, 2, 3 }) ); @@ -682,15 +679,15 @@ TEST(fc_permute_gpu, basic_permute_bfyx) EXPECT_EQ(outputs.begin()->first, "permute"); auto output = outputs.begin()->second.get_memory(); - auto out_tensor = output.get_layout().size; + auto out_tensor = output->get_layout().size; EXPECT_EQ(out_tensor.batch[0], 5); EXPECT_EQ(out_tensor.feature[0], 1); EXPECT_EQ(out_tensor.spatial[0], 1); EXPECT_EQ(out_tensor.spatial[1], 256); - EXPECT_EQ(output.get_layout().format, cldnn::format::bfyx); + EXPECT_EQ(output->get_layout().format, cldnn::format::bfyx); - auto input_ptr = input_mem.pointer(); - auto output_ptr = output.pointer(); + cldnn::mem_lock input_ptr(input_mem, get_test_stream()); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 5 * 256; i++) EXPECT_NEAR(input_ptr[i], output_ptr[i], 1e-3f); @@ -698,7 +695,7 @@ TEST(fc_permute_gpu, basic_permute_bfyx) TEST(permute_gpu_f32, permute_bfwzyx) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int b = 1; const int f = 2; const int x = 3; @@ -708,8 +705,8 @@ TEST(permute_gpu_f32, permute_bfwzyx) std::vector permute_order = { 1, 0, 5, 4, 3, 2 }; auto input_size = cldnn::tensor(batch(b), feature(f), spatial(x, y, z, w)); - auto input_mem = memory::allocate(engine, { data_types::f32, format::bfwzyx, input_size }); - auto input_data = generate_random_1d(input_mem.get_layout().count(), -1, 1); + auto input_mem = engine.allocate_memory({ data_types::f32, format::bfwzyx, input_size }); + auto input_data = generate_random_1d(input_mem->get_layout().count(), -1, 1); set_values(input_mem, input_data); @@ -726,11 +723,11 @@ TEST(permute_gpu_f32, permute_bfwzyx) auto in_index = cldnn::tensor(batch(bi), feature(fi), spatial(xi, yi, zi, wi)); auto out_index = cldnn::tensor(batch(fi), feature(bi), spatial(wi, zi, yi, xi)); expected_output[expected_layout.get_linear_offset(out_index)] = - input_data[input_mem.get_layout().get_linear_offset(in_index)]; + input_data[input_mem->get_layout().get_linear_offset(in_index)]; } topology topology( - input_layout("input", input_mem.get_layout()), + input_layout("input", input_mem->get_layout()), permute("permute", "input", permute_order) ); @@ -742,16 +739,16 @@ TEST(permute_gpu_f32, permute_bfwzyx) EXPECT_EQ(outputs.begin()->first, "permute"); auto output = outputs.begin()->second.get_memory(); - auto out_tensor = output.get_layout().size; + auto out_tensor = output->get_layout().size; EXPECT_EQ(out_tensor.batch[0], 2); EXPECT_EQ(out_tensor.feature[0], 1); EXPECT_EQ(out_tensor.spatial[0], 6); EXPECT_EQ(out_tensor.spatial[1], 5); EXPECT_EQ(out_tensor.spatial[2], 4); EXPECT_EQ(out_tensor.spatial[3], 3); - EXPECT_EQ(output.get_layout().format, cldnn::format::bfwzyx); + EXPECT_EQ(output->get_layout().format, cldnn::format::bfwzyx); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < output_ptr.size(); ++i) { @@ -787,7 +784,7 @@ TEST(permute_gpu_f32, 6D_reshape_permute_reshape) // 0 2 0 2 0 2 0 2 // 1 3 1 3 1 3 1 3 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int b = 1; const int f = 4; const int x = 2; @@ -800,7 +797,7 @@ TEST(permute_gpu_f32, 6D_reshape_permute_reshape) std::vector permute_order = { 0, 1, 5, 4, 2, 3 }; auto input_size = cldnn::tensor(batch(b), feature(f), spatial(x, y)); - auto input_mem = memory::allocate(engine, { data_types::f32, format::bfyx, input_size }); + auto input_mem = engine.allocate_memory({ data_types::f32, format::bfyx, input_size }); std::vector input_data = { 0.f, 0.f, 0.f, 0.f, 1.f, 1.f, 1.f, 1.f, @@ -818,7 +815,7 @@ TEST(permute_gpu_f32, 6D_reshape_permute_reshape) set_values(input_mem, input_data); topology topology( - input_layout("input", input_mem.get_layout()), + input_layout("input", input_mem->get_layout()), reorder("input_6d", "input", { data_types::f32, format::bfwzyx, cldnn::tensor(batch(b), feature(f), spatial(x, y)) }), reshape("reshape_4_to_6", "input_6d", cldnn::tensor(batch(b), feature(f_reshape), spatial(x, y, z_reshape, w_reshape))), permute("permute", "reshape_4_to_6", permute_order), @@ -835,7 +832,7 @@ TEST(permute_gpu_f32, 6D_reshape_permute_reshape) auto output = outputs.begin()->second.get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < output_ptr.size(); ++i) { @@ -847,9 +844,9 @@ TEST(permute_gpu_f32, basic_bfzyx_permute_0_2_3_4_1) // Input : bfzyx:2x2x2x2x3 // Permute order : { 0,2,3,4,1 } - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 2, 2, 3, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 2, 2, 3, 2, 2 } }); set_values(input, { 1.0f, 2.0f, -15.f, //B0, F0, // z0 y0 x-3 @@ -874,7 +871,7 @@ TEST(permute_gpu_f32, basic_bfzyx_permute_0_2_3_4_1) }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), permute("permute", "input", { 0, 2, 3, 4, 1 })); network network(engine, topology); @@ -885,14 +882,14 @@ TEST(permute_gpu_f32, basic_bfzyx_permute_0_2_3_4_1) EXPECT_EQ(outputs.begin()->first, "permute"); auto output = outputs.begin()->second.get_memory(); - auto out_tensor = output.get_layout().size; + auto out_tensor = output->get_layout().size; EXPECT_EQ(out_tensor.batch[0], 2); EXPECT_EQ(out_tensor.feature[0], 3); EXPECT_EQ(out_tensor.spatial[0], 2); EXPECT_EQ(out_tensor.spatial[1], 2); EXPECT_EQ(out_tensor.spatial[2], 2); - EXPECT_EQ(output.get_layout().format, cldnn::format::bfzyx); + EXPECT_EQ(output->get_layout().format, cldnn::format::bfzyx); float answers[48] = { 1.0f, 3.0f, 2.0f, 4.0f, @@ -909,7 +906,7 @@ TEST(permute_gpu_f32, basic_bfzyx_permute_0_2_3_4_1) -15.0f, -15.0f, -15.0f, -15.0f, }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 48; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -929,9 +926,9 @@ TEST(permute_gpu_f32_tile_8x8_4x4, normal_bfyx_0_3_1_2) { constexpr size_t array_size = 256; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 8, 8, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 8, 8, 2 } }); std::vector input_data; input_data.reserve(array_size); @@ -941,7 +938,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, normal_bfyx_0_3_1_2) { set_values(input, input_data); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), permute("permute", "input", { 0, 3, 1, 2 })); network network(engine, topology); @@ -972,7 +969,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, normal_bfyx_0_3_1_2) { 142.f, 158.f, 174.f, 190.f, 206.f, 222.f, 238.f, 254.f, 143.f, 159.f, 175.f, 191.f, 207.f, 223.f, 239.f, 255.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < array_size; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -985,9 +982,9 @@ TEST(permute_gpu_f32_tile_8x8_4x4, f_remainder_bfyx_0_3_1_2) { constexpr size_t array_size = 160; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 5, 8, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 5, 8, 2 } }); std::vector input_data; input_data.reserve(array_size); @@ -997,7 +994,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, f_remainder_bfyx_0_3_1_2) { set_values(input, input_data); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), permute("permute", "input", { 0, 3, 1, 2 })); network network(engine, topology); @@ -1022,7 +1019,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, f_remainder_bfyx_0_3_1_2) { 156.f, 93.f, 109.f, 125.f, 141.f, 157.f, 94.f, 110.f, 126.f, 142.f, 158.f, 95.f, 111.f, 127.f, 143.f, 159.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < array_size; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -1035,9 +1032,9 @@ TEST(permute_gpu_f32_tile_8x8_4x4, x_remainder_bfyx_0_3_1_2) { constexpr size_t array_size = 160; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 8, 5, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 8, 5, 2 } }); set_values(input, { 0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f, @@ -1053,7 +1050,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, x_remainder_bfyx_0_3_1_2) { }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), permute("permute", "input", { 0, 3, 1, 2 })); network network(engine, topology); @@ -1078,7 +1075,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, x_remainder_bfyx_0_3_1_2) { 88.f, 98.f, 108.f, 118.f, 128.f, 138.f, 148.f, 158.f, 89.f, 99.f, 109.f, 119.f, 129.f, 139.f, 149.f, 159.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < array_size; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -1091,9 +1088,9 @@ TEST(permute_gpu_f32_tile_8x8_4x4, xf_remainder_bfyx_0_3_1_2) { constexpr size_t array_size = 100; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 5, 5, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 5, 5, 2 } }); std::vector input_data; input_data.reserve(array_size); @@ -1103,7 +1100,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, xf_remainder_bfyx_0_3_1_2) { set_values(input, input_data); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), permute("permute", "input", { 0, 3, 1, 2 })); network network(engine, topology); @@ -1128,7 +1125,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, xf_remainder_bfyx_0_3_1_2) { 58.f, 68.f, 78.f, 88.f, 98.f, 59.f, 69.f, 79.f, 89.f, 99.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < array_size; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -1141,9 +1138,9 @@ TEST(permute_gpu_f32_tile_8x8_4x4, normal_bfzyx_0_4_1_2_3) { constexpr size_t array_size = 512; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 2, 8, 8, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 2, 8, 8, 2, 2 } }); std::vector input_data; input_data.reserve(array_size); @@ -1153,7 +1150,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, normal_bfzyx_0_4_1_2_3) { set_values(input, input_data); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), permute("permute", "input", { 0, 4, 1, 2, 3 })); network network(engine, topology); @@ -1190,7 +1187,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, normal_bfzyx_0_4_1_2_3) { 287.f, 319.f, 351.f, 383.f, 415.f, 447.f, 479.f, 511.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < array_size; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -1203,9 +1200,9 @@ TEST(permute_gpu_f32_tile_8x8_4x4, f_remainder_bfzyx_0_4_1_2_3) { constexpr size_t array_size = 320; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 2, 5, 8, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 2, 5, 8, 2, 2 } }); std::vector input_data; input_data.reserve(array_size); @@ -1215,7 +1212,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, f_remainder_bfzyx_0_4_1_2_3) { set_values(input, input_data); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), permute("permute", "input", { 0, 4, 1, 2, 3 })); network network(engine, topology); @@ -1244,7 +1241,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, f_remainder_bfzyx_0_4_1_2_3) { 254.f, 286.f, 318.f, 191.f, 223.f, 255.f, 287.f, 319.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < array_size; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -1257,9 +1254,9 @@ TEST(permute_gpu_f32_tile_8x8_4x4, x_remainder_bfzyx_0_4_1_2_3) { constexpr size_t array_size = 320; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 2, 8, 5, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 2, 8, 5, 2, 2 } }); std::vector input_data; input_data.reserve(array_size); @@ -1269,7 +1266,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, x_remainder_bfzyx_0_4_1_2_3) { set_values(input, input_data); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), permute("permute", "input", { 0, 4, 1, 2, 3 })); network network(engine, topology); @@ -1298,7 +1295,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, x_remainder_bfzyx_0_4_1_2_3) { 179.f, 199.f, 219.f, 239.f, 259.f, 279.f, 299.f, 319.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < array_size; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -1311,9 +1308,9 @@ TEST(permute_gpu_f32_tile_8x8_4x4, xf_remainder_bfzyx_0_4_1_2_3) { constexpr size_t array_size = 200; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 2, 5, 5, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 2, 5, 5, 2, 2 } }); std::vector input_data; input_data.reserve(array_size); @@ -1323,7 +1320,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, xf_remainder_bfzyx_0_4_1_2_3) { set_values(input, input_data); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), permute("permute", "input", { 0, 4, 1, 2, 3 })); network network(engine, topology); @@ -1352,7 +1349,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, xf_remainder_bfzyx_0_4_1_2_3) { 119.f, 139.f, 159.f, 179.f, 199.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < array_size; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -1365,9 +1362,9 @@ TEST(permute_gpu_f32_tile_8x8_4x4, normal_bfwzyx_0_5_4_1_2_3) { constexpr size_t array_size = 1024; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfwzyx,{ 2, 8, 8, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfwzyx,{ 2, 8, 8, 2, 2, 2 } }); std::vector input_data; input_data.reserve(array_size); @@ -1377,7 +1374,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, normal_bfwzyx_0_5_4_1_2_3) { set_values(input, input_data); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), permute("permute", "input", { 0, 5, 1, 2, 3, 4 })); network network(engine, topology); @@ -1424,7 +1421,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, normal_bfwzyx_0_5_4_1_2_3) { 572.f, 636.f, 700.f, 764.f, 828.f, 892.f, 956.f, 1020.f, 573.f, 637.f, 701.f, 765.f, 829.f, 893.f, 957.f, 1021.f, 574.f, 638.f, 702.f, 766.f, 830.f, 894.f, 958.f, 1022.f, 575.f, 639.f, 703.f, 767.f, 831.f, 895.f, 959.f, 1023.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < array_size; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -1437,9 +1434,9 @@ TEST(permute_gpu_f32_tile_8x8_4x4, f_remainder_bfwzyx_0_5_4_1_2_3) { constexpr size_t array_size = 640; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfwzyx,{ 2, 5, 8, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfwzyx,{ 2, 5, 8, 2, 2, 2 } }); std::vector input_data; input_data.reserve(array_size); @@ -1449,7 +1446,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, f_remainder_bfwzyx_0_5_4_1_2_3) { set_values(input, input_data); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), permute("permute", "input", { 0, 5, 1, 2, 3, 4 })); network network(engine, topology); @@ -1484,7 +1481,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, f_remainder_bfwzyx_0_5_4_1_2_3) { 569.f, 633.f, 378.f, 442.f, 506.f, 570.f, 634.f, 379.f, 443.f, 507.f, 571.f, 635.f, 380.f, 444.f, 508.f, 572.f, 636.f, 381.f, 445.f, 509.f, 573.f, 637.f, 382.f, 446.f, 510.f, 574.f, 638.f, 383.f, 447.f, 511.f, 575.f, 639.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < array_size; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -1497,9 +1494,9 @@ TEST(permute_gpu_f32_tile_8x8_4x4, x_remainder_bfwzyx_0_5_4_1_2_3) { constexpr size_t array_size = 640; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfwzyx,{ 2, 8, 5, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfwzyx,{ 2, 8, 5, 2, 2, 2 } }); std::vector input_data; input_data.reserve(array_size); @@ -1509,7 +1506,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, x_remainder_bfwzyx_0_5_4_1_2_3) { set_values(input, input_data); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), permute("permute", "input", { 0, 5, 1, 2, 3, 4 })); network network(engine, topology); @@ -1544,7 +1541,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, x_remainder_bfwzyx_0_5_4_1_2_3) { 356.f, 396.f, 436.f, 476.f, 516.f, 556.f, 596.f, 636.f, 357.f, 397.f, 437.f, 477.f, 517.f, 557.f, 597.f, 637.f, 358.f, 398.f, 438.f, 478.f, 518.f, 558.f, 598.f, 638.f, 359.f, 399.f, 439.f, 479.f, 519.f, 559.f, 599.f, 639.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < array_size; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -1557,9 +1554,9 @@ TEST(permute_gpu_f32_tile_8x8_4x4, xf_remainder_bfwzyx_0_5_4_1_2_3) { constexpr size_t array_size = 400; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfwzyx,{ 2, 5, 5, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfwzyx,{ 2, 5, 5, 2, 2, 2 } }); std::vector input_data; input_data.reserve(array_size); @@ -1569,7 +1566,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, xf_remainder_bfwzyx_0_5_4_1_2_3) { set_values(input, input_data); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), permute("permute", "input", { 0, 5, 1, 2, 3, 4 })); network network(engine, topology); @@ -1604,7 +1601,7 @@ TEST(permute_gpu_f32_tile_8x8_4x4, xf_remainder_bfwzyx_0_5_4_1_2_3) { 236.f, 276.f, 316.f, 356.f, 396.f, 237.f, 277.f, 317.f, 357.f, 397.f, 238.f, 278.f, 318.f, 358.f, 398.f, 239.f, 279.f, 319.f, 359.f, 399.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < array_size; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -1618,7 +1615,7 @@ struct TiledPermuteParam { class TiledPermuteTest : public ::testing::TestWithParam { public: - const cldnn::engine engine; + cldnn::engine& engine = get_test_engine(); TiledPermuteTest(): engine(get_test_engine()) { } template @@ -1627,7 +1624,7 @@ class TiledPermuteTest : public ::testing::TestWithParam { } template - void set_random_values(const cldnn::memory& mem) const { + void set_random_values(const cldnn::memory::ptr mem) const { tests::set_random_values(mem); } @@ -1647,11 +1644,11 @@ void TiledPermuteTest::compare_value(FLOAT16 a, FLOAT16 b) const { } template<> -void TiledPermuteTest::set_random_values(const cldnn::memory& mem) const { +void TiledPermuteTest::set_random_values(const cldnn::memory::ptr mem) const { // tests::set_random_values() is not supported std::mt19937 gen; static std::uniform_int_distribution uid(std::numeric_limits::min(), std::numeric_limits::max()); - auto ptr = mem.pointer(); + cldnn::mem_lock ptr(mem, get_test_stream()); for (auto it = ptr.begin(); it != ptr.end(); ++it) { *it = static_cast(uid(gen)); } @@ -1680,11 +1677,11 @@ void TiledPermuteTest::run_test(const std::vector& si order.push_back(i); } - auto input = memory::allocate(engine, {Data_Type, format, tensor}); + auto input = engine.allocate_memory({Data_Type, format, tensor}); set_random_values(input); topology topology_ref = topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("reorder", "input", {Data_Type, format_fsv, tensor}), permute("output", "reorder", order ) ); @@ -1698,7 +1695,7 @@ void TiledPermuteTest::run_test(const std::vector& si network_ref.set_input_data("input", input); auto outputs_ref = network_ref.execute(); auto output_ref = outputs_ref.begin()->second.get_memory(); - auto output_ref_ptr = output_ref.pointer(); + cldnn::mem_lock output_ref_ptr(output_ref, get_test_stream()); // run with permute_tile_8x8_4x4_fsv16 cldnn::build_options options_tile; @@ -1709,10 +1706,10 @@ void TiledPermuteTest::run_test(const std::vector& si network_tile.set_input_data("input", input); auto outputs_tile = network_tile.execute(); auto output_tile = outputs_tile.begin()->second.get_memory(); - auto output_tile_ptr = output_tile.pointer(); + cldnn::mem_lock output_tile_ptr(output_tile, get_test_stream()); // compare results - const size_t output_size= output_ref.get_layout().get_linear_size(); + const size_t output_size= output_ref->get_layout().get_linear_size(); for (size_t i = 0; i < output_size; i++) { compare_value(output_ref_ptr[i], output_tile_ptr[i]); diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/pooling_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/pooling_gpu_test.cpp index a1dc98c8b0351e..009490ac681d44 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/pooling_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/pooling_gpu_test.cpp @@ -3,21 +3,17 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include "api/pooling.hpp" -#include "api/mutable_data.hpp" -#include -#include -#include -#include "test_utils/test_utils.h" -#include "api/reorder.hpp" -#include -#include "test_utils/float16.h" + +#include "test_utils.h" + +#include +#include +#include +#include +#include using namespace cldnn; -using namespace tests; +using namespace ::tests; namespace cldnn { template <> @@ -223,12 +219,12 @@ TEST(pooling_forward_gpu, basic_max_byxf_f32_wsiz3x3_wstr1x1_i1x3x3x8_nopad) { // Expected output: // [ 8.0, 0.0, 0.0, 4,0, 0,5, -0.5, -0.5, -0.5 ] - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate(engine, { data_types::f32, format::byxf,{ 1, 8, 3, 3 } }); + auto input_prim = engine.allocate_memory({ data_types::f32, format::byxf,{ 1, 8, 3, 3 } }); topology topology; - topology.add(input_layout("input_prim", input_prim.get_layout())); + topology.add(input_layout("input_prim", input_prim->get_layout())); topology.add(pooling("pool_prim", "input_prim", pooling_mode::max, { 1,1,3,3 }, { 1,1,1,1 })); network network(engine, topology); set_values(input_prim, { 0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, -0.5f, @@ -248,7 +244,7 @@ TEST(pooling_forward_gpu, basic_max_byxf_f32_wsiz3x3_wstr1x1_i1x3x3x8_nopad) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); EXPECT_EQ(4.0f, output_ptr[3]); } @@ -268,12 +264,12 @@ TEST(pooling_forward_gpu, basic_max_yxfb_f32_wsiz3x3_wstr1x1_i3x3x1x1_nopad) { // Expected output: // [ 2.0] - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 3, 3 } }); + auto input_prim = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 3, 3 } }); topology topology; - topology.add(input_layout("input_prim", input_prim.get_layout())); + topology.add(input_layout("input_prim", input_prim->get_layout())); topology.add(pooling("pool_prim", "input_prim", pooling_mode::max, { 1,1,3,3 }, { 1,1,1,1 })); network network(engine, topology); @@ -286,7 +282,7 @@ TEST(pooling_forward_gpu, basic_max_yxfb_f32_wsiz3x3_wstr1x1_i3x3x1x1_nopad) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); EXPECT_EQ(2.0f, output_ptr[0]); } @@ -306,12 +302,12 @@ TEST(pooling_forward_gpu, basic_max_yxfb_f32_global_i3x3x1x1_nopad) { // Expected output: // [ 2.0] - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 1, 3, 3 } }); + auto input_prim = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 1, 3, 3 } }); topology topology; - topology.add(input_layout("input_prim", input_prim.get_layout())); + topology.add(input_layout("input_prim", input_prim->get_layout())); topology.add(pooling("pool_prim", "input_prim", pooling_mode::max)); network network(engine, topology); @@ -324,7 +320,7 @@ TEST(pooling_forward_gpu, basic_max_yxfb_f32_global_i3x3x1x1_nopad) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); EXPECT_EQ(2.0f, output_ptr[0]); } @@ -336,12 +332,12 @@ TEST(pooling_forward_gpu, basic_max_b_fs_yx_fsv16_i8_global_i3x3x1x1_nopad) { // Global pooling: true // Padding: none - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate(engine, { data_types::i8, format::b_fs_yx_fsv16, { 1, 16, 3, 3 } }); + auto input_prim = engine.allocate_memory({ data_types::i8, format::b_fs_yx_fsv16, { 1, 16, 3, 3 } }); topology topology; - topology.add(input_layout("input_prim", input_prim.get_layout())); + topology.add(input_layout("input_prim", input_prim->get_layout())); topology.add(pooling("pool_prim", "input_prim", pooling_mode::max)); network network(engine, topology); @@ -365,7 +361,7 @@ TEST(pooling_forward_gpu, basic_max_b_fs_yx_fsv16_i8_global_i3x3x1x1_nopad) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); std::vector answers = { 8, 44, 8, 81, 64, 8, 12, 66, 14, 8, 99, 64, 8, 11, 18, 21 }; @@ -382,12 +378,12 @@ TEST(pooling_forward_gpu, basic_avg_b_fs_yx_fsv16_i8_global_i3x3x1x1_nopad) { // Global pooling: true // Padding: none - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate(engine, { data_types::i8, format::b_fs_yx_fsv16, { 1, 16, 3, 3 } }); + auto input_prim = engine.allocate_memory({ data_types::i8, format::b_fs_yx_fsv16, { 1, 16, 3, 3 } }); topology topology; - topology.add(input_layout("input_prim", input_prim.get_layout())); + topology.add(input_layout("input_prim", input_prim->get_layout())); topology.add(pooling("pool_prim", "input_prim", pooling_mode::average)); network network(engine, topology); @@ -411,7 +407,7 @@ TEST(pooling_forward_gpu, basic_avg_b_fs_yx_fsv16_i8_global_i3x3x1x1_nopad) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); std::vector answers = { 29, 199, 241, 63, 85, 85, 213, 64, 85, 85, 21, 64, 142, 227, 8, 65, @@ -428,7 +424,7 @@ TEST(pooling_forward_gpu, basic_avg_b_fs_yx_fsv16_i8_global_i3x3x1x1_nopad) { TEST(pooling_forward_gpu, basic_max_pooling_int8) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); layout in_layout = { type_to_data_type::value,format::byxf,{ 1,1,3,3 } }; layout out_layout = { type_to_data_type::value,format::byxf,{ 1,1,1,1 } }; layout byte_layout = { type_to_data_type::value, format::bfyx,{ 1,1,3,3 } }; @@ -436,7 +432,7 @@ TEST(pooling_forward_gpu, basic_max_pooling_int8) { std::list final_results = { 10.0f }; // Allocate memory for input image. - auto input_memory = memory::allocate(engine, in_layout); + auto input_memory = engine.allocate_memory(in_layout); set_values(input_memory, input_f); // Create input_layout description @@ -464,7 +460,7 @@ TEST(pooling_forward_gpu, basic_max_pooling_int8) { auto outputs = network.execute(); auto interm = outputs.at("reorder2").get_memory(); - auto interm_ptr = interm.pointer(); + cldnn::mem_lock interm_ptr(interm, get_test_stream()); unsigned int cntr = 0; for (const auto& exp : final_results) { @@ -474,7 +470,7 @@ TEST(pooling_forward_gpu, basic_max_pooling_int8) { TEST(pooling_forward_gpu, basic_avg_pooling_int8) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); layout in_layout = { type_to_data_type::value,format::byxf,{ 1,1,3,3 } }; layout out_layout = { type_to_data_type::value,format::byxf,{ 1,1,1,1 } }; layout byte_layout = { type_to_data_type::value, format::bfyx,{ 1,1,3,3 } }; @@ -488,7 +484,7 @@ TEST(pooling_forward_gpu, basic_avg_pooling_int8) { } final_result /= input_f.size(); // Allocate memory for input image. - auto input_memory = memory::allocate(engine, in_layout); + auto input_memory = engine.allocate_memory(in_layout); set_values(input_memory, input_f); // Create input_layout description @@ -516,7 +512,7 @@ TEST(pooling_forward_gpu, basic_avg_pooling_int8) { auto outputs = network.execute(); auto interm = outputs.at("reorder2").get_memory(); - auto interm_ptr = interm.pointer(); + cldnn::mem_lock interm_ptr(interm, get_test_stream()); EXPECT_EQ(final_result, interm_ptr[0]); } @@ -537,12 +533,12 @@ TEST(pooling_forward_gpu, basic_max_yxfb_f32_wsiz2x2_wstr1x1_i3x3x1x1_nopad) { // [ 2.0, 1.5] // [ 2.0, 1.5] - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 3, 3 } }); + auto input_prim = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 3, 3 } }); topology topology; - topology.add(input_layout("input_prim", input_prim.get_layout())); + topology.add(input_layout("input_prim", input_prim->get_layout())); topology.add(pooling("pool_prim", "input_prim", pooling_mode::max, { 1,1,2,2 }, { 1,1,1,1 })); network network(engine, topology); @@ -555,7 +551,7 @@ TEST(pooling_forward_gpu, basic_max_yxfb_f32_wsiz2x2_wstr1x1_i3x3x1x1_nopad) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); EXPECT_EQ(2.0f, output_ptr[0]); EXPECT_EQ(1.5f, output_ptr[1]); @@ -581,12 +577,12 @@ TEST(pooling_forward_gpu, basic_max_yxfb_f32_wsiz2x2_wstr2x2_i4x4x1x1_nopad) { // [ 2.0, 0.5] // [ 0.5, 0.5] - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 4, 4 } }); + auto input_prim = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 4, 4 } }); topology topology; - topology.add(input_layout("input_prim", input_prim.get_layout())); + topology.add(input_layout("input_prim", input_prim->get_layout())); topology.add(pooling("pool_prim", "input_prim", pooling_mode::max, { 1,1,2,2 }, { 1,1,2,2 })); network network(engine, topology); @@ -599,7 +595,7 @@ TEST(pooling_forward_gpu, basic_max_yxfb_f32_wsiz2x2_wstr2x2_i4x4x1x1_nopad) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); EXPECT_EQ(2.0f, output_ptr[0]); EXPECT_EQ(0.5f, output_ptr[1]); @@ -635,12 +631,12 @@ TEST(pooling_forward_gpu, basic_max_yxfb_f32_wsiz2x2_wstr1x1_i3x3x2x2_nopad) { // [ 0.5, 1.0] [ 1.0, 0.5] // [-0.5, 1.5] [ 1.0, 0.0] - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 3, 3 } }); + auto input_prim = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 3, 3 } }); topology topology; - topology.add(input_layout("input_prim", input_prim.get_layout())); + topology.add(input_layout("input_prim", input_prim->get_layout())); topology.add(pooling("pool_prim", "input_prim", pooling_mode::max, { 1,1,2,2 }, { 1,1,1,1 })); network network(engine, topology); @@ -653,7 +649,7 @@ TEST(pooling_forward_gpu, basic_max_yxfb_f32_wsiz2x2_wstr1x1_i3x3x2x2_nopad) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); EXPECT_EQ(1.0f, output_ptr[0]); EXPECT_EQ(0.0f, output_ptr[2]); EXPECT_EQ(0.5f, output_ptr[4]); EXPECT_EQ(1.5f, output_ptr[6]); @@ -685,12 +681,12 @@ TEST(pooling_forward_gpu, offsets_max_yxfb_f32_wsiz2x2_wstr2x2_i2x2x1x1_zeropad) // [ 1.5, -0.5] // [ -1, 0.5] - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); + auto input_prim = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); topology topology; - topology.add(input_layout("input_prim", input_prim.get_layout())); + topology.add(input_layout("input_prim", input_prim->get_layout())); topology.add(pooling("pool_prim", "input_prim", pooling_mode::max, { 1,1,2,2 }, { 1,1,2,2 }, { 0, 0, -1,-1 })); network network(engine, topology); @@ -703,7 +699,7 @@ TEST(pooling_forward_gpu, offsets_max_yxfb_f32_wsiz2x2_wstr2x2_i2x2x1x1_zeropad) auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); EXPECT_EQ( 1.5f, output_ptr[0]); EXPECT_EQ(-0.5f, output_ptr[1]); EXPECT_EQ(-1.0f, output_ptr[2]); @@ -730,12 +726,12 @@ TEST(pooling_forward_gpu, offsets_max_yxfb_f32_wsiz2x2_wstr2x2_i3x3x1x1_zeropad) // [ 1.5, -0.5] // [ 1, -0.5] - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 3, 3 } }); + auto input_prim = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 3, 3 } }); topology topology; - topology.add(input_layout("input_prim", input_prim.get_layout())); + topology.add(input_layout("input_prim", input_prim->get_layout())); topology.add(pooling("pool_prim", "input_prim", pooling_mode::max, { 1,1,2,2 }, { 1,1,2,2 }, { 0,0,-1,-1 })); network network(engine, topology); @@ -753,13 +749,13 @@ TEST(pooling_forward_gpu, offsets_max_yxfb_f32_wsiz2x2_wstr2x2_i3x3x1x1_zeropad) EXPECT_EQ(outputs.begin()->first, "pool_prim"); auto output_prim = outputs.begin()->second.get_memory(); - EXPECT_EQ((int)output_prim.get_layout().size.count(), 4); + EXPECT_EQ((int)output_prim->get_layout().size.count(), 4); - auto output_ptr = output_prim.pointer(); - EXPECT_EQ(1.5f, get_value(output_ptr, 0)); - EXPECT_EQ(-0.5f, get_value(output_ptr, 1)); - EXPECT_EQ(1.0f, get_value(output_ptr, 2)); - EXPECT_EQ(-0.5f, get_value(output_ptr, 3)); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); + EXPECT_EQ(1.5f, output_ptr[0]); + EXPECT_EQ(-0.5f, output_ptr[1]); + EXPECT_EQ(1.0f, output_ptr[2]); + EXPECT_EQ(-0.5f, output_ptr[3]); } TEST(pooling_forward_gpu, basic_avg_yxfb_f32_wsiz2x2_wstr1x1_i3x3x1x1_nopad) { @@ -779,12 +775,12 @@ TEST(pooling_forward_gpu, basic_avg_yxfb_f32_wsiz2x2_wstr1x1_i3x3x1x1_nopad) { // [ 1.0, 0.625] // [ 1.625, 0.875] - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 3, 3 } }); + auto input_prim = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 3, 3 } }); topology topology; - topology.add(input_layout("input_prim", input_prim.get_layout())); + topology.add(input_layout("input_prim", input_prim->get_layout())); topology.add(pooling("pool_prim", "input_prim", pooling_mode::average,{ 1,1,2,2 },{ 1,1,1,1 })); network network(engine, topology); @@ -797,7 +793,7 @@ TEST(pooling_forward_gpu, basic_avg_yxfb_f32_wsiz2x2_wstr1x1_i3x3x1x1_nopad) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); EXPECT_EQ(1.0f, output_ptr[0]); EXPECT_EQ(0.625f, output_ptr[1]); @@ -824,12 +820,12 @@ TEST(pooling_forward_gpu, offsets_avg_yxfb_f32_wsiz2x2_wstr2x2_i2x2x1x1_zeropad) // [ 0.375, -0.125] // [ -0.25, 0.125] - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); + auto input_prim = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 2, 2 } }); topology topology; - topology.add(input_layout("input_prim", input_prim.get_layout())); + topology.add(input_layout("input_prim", input_prim->get_layout())); topology.add(pooling("pool_prim", "input_prim", pooling_mode::average, { 1,1,2,2 }, { 1,1,2,2 }, { 0,0,-1,-1 })); network network(engine, topology); @@ -842,7 +838,7 @@ TEST(pooling_forward_gpu, offsets_avg_yxfb_f32_wsiz2x2_wstr2x2_i2x2x1x1_zeropad) auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); EXPECT_EQ(0.375f, output_ptr[0]); EXPECT_EQ(-0.125f, output_ptr[1]); EXPECT_EQ(-0.25f, output_ptr[2]); @@ -869,12 +865,12 @@ TEST(pooling_forward_gpu, offsets_avg_bfyx_f32_wsiz3x3_wstr3x3_i1x1x3x3_zeropad) // [ 0.177777, -0.133333] // [ 0.333333, 0.55] - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 3, 3 } }); + auto input_prim = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 3, 3 } }); topology topology; - topology.add(input_layout("input_prim", input_prim.get_layout())); + topology.add(input_layout("input_prim", input_prim->get_layout())); topology.add(pooling("pool_prim", "input_prim", pooling_mode::average, { 1,1,3,3 }, { 1,1,3,3 }, { 0,0,-1,-1 })); network network(engine, topology); @@ -890,7 +886,7 @@ TEST(pooling_forward_gpu, offsets_avg_bfyx_f32_wsiz3x3_wstr3x3_i1x1x3x3_zeropad) auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); EXPECT_NEAR(output_ptr[0], 0.177777f, 1e-05F); EXPECT_NEAR(output_ptr[1], -0.133333f, 1e-05F); @@ -917,12 +913,12 @@ TEST(pooling_forward_gpu, offsets_avg_yxfb_f32_wsiz2x2_wstr2x2_i3x3x1x1_zeropad) // [ 0.375, 0.5] // [ -0.125, -1.125] - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input_prim = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 3, 3 } }); + auto input_prim = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 3, 3 } }); topology topology; - topology.add(input_layout("input_prim", input_prim.get_layout())); + topology.add(input_layout("input_prim", input_prim->get_layout())); topology.add(pooling("pool_prim", "input_prim", pooling_mode::average, { 1,1,2,2 }, { 1,1,2,2 }, { 0,0,-1,-1 })); network network(engine, topology); @@ -934,9 +930,9 @@ TEST(pooling_forward_gpu, offsets_avg_yxfb_f32_wsiz2x2_wstr2x2_i3x3x1x1_zeropad) EXPECT_EQ(outputs.begin()->first, "pool_prim"); auto output_prim = outputs.begin()->second.get_memory(); - EXPECT_EQ((int)output_prim.get_layout().size.count(), 4); + EXPECT_EQ((int)output_prim->get_layout().size.count(), 4); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); EXPECT_EQ(0.375f, output_ptr[0]); EXPECT_EQ(0.5f, output_ptr[1]); EXPECT_EQ(-0.125f, output_ptr[2]); @@ -966,7 +962,7 @@ TEST(pooling_forward_gpu, offsets_avg_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i2x2x1x1_out // [0, 0, 0, 0, 0, 0] // [0, 0, 0, 0, 0, 0] - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); std::vector formats_to_test = { format::yxfb , format::bfyx }; for (std::vector::iterator it = formats_to_test.begin(); it != formats_to_test.end(); ++it) @@ -974,10 +970,10 @@ TEST(pooling_forward_gpu, offsets_avg_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i2x2x1x1_out std::cout << "Testing format: " << format::order(*it) << std::endl; tensor input_tensor( 1, 1, 2, 2 ); - auto input_prim = memory::allocate(engine, { data_types::f32, *it, input_tensor }); + auto input_prim = engine.allocate_memory({ data_types::f32, *it, input_tensor }); topology topology; - topology.add(input_layout("input_prim", input_prim.get_layout())); + topology.add(input_layout("input_prim", input_prim->get_layout())); topology.add(pooling("pool_prim", "input_prim", pooling_mode::average, { 1,1,2,2 }, { 1,1,2,2 }, { 0,0,-1,-1 }, padding{ { 0,0,2,2 }, 0 })); network network(engine, topology); @@ -998,7 +994,7 @@ TEST(pooling_forward_gpu, offsets_avg_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i2x2x1x1_out EXPECT_EQ(outputs.begin()->first, "pool_prim"); auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); for (size_t i = 0; i < expected.size(); ++i) { EXPECT_EQ(expected[i], output_ptr[i]); } @@ -1027,7 +1023,7 @@ TEST(pooling_forward_gpu, offsets_max_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i3x3x1x1_out // [0, 1, -0.5, 0, 0] // [0, 0, 0, 0, 0] - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); std::vector formats_to_test = { format::yxfb , format::bfyx }; for (std::vector::iterator it = formats_to_test.begin(); it != formats_to_test.end(); ++it) @@ -1035,10 +1031,10 @@ TEST(pooling_forward_gpu, offsets_max_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i3x3x1x1_out std::cout << "Testing format: " << format::order(*it) << std::endl; tensor input_tensor( 1, 1, 3, 3 ); - auto input_prim = memory::allocate(engine, { data_types::f32, *it, input_tensor }); + auto input_prim = engine.allocate_memory({ data_types::f32, *it, input_tensor }); topology topology; - topology.add(input_layout("input_prim", input_prim.get_layout())); + topology.add(input_layout("input_prim", input_prim->get_layout())); topology.add(pooling("pool_prim", "input_prim", pooling_mode::max, { 1,1,2,2 }, { 1,1,2,2 }, { 0,0,-1,-1 }, padding{ { 0,0,1,1 }, 0 })); network network(engine, topology); @@ -1063,10 +1059,10 @@ TEST(pooling_forward_gpu, offsets_max_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i3x3x1x1_out EXPECT_EQ(outputs.begin()->first, "pool_prim"); auto output_prim = outputs.begin()->second.get_memory(); - EXPECT_EQ((int)output_prim.get_layout().size.count(), 4); - EXPECT_EQ((int)output_prim.get_layout().get_buffer_size().count(), 16); + EXPECT_EQ((int)output_prim->get_layout().size.count(), 4); + EXPECT_EQ((int)output_prim->get_layout().get_buffer_size().count(), 16); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); for (size_t i = 0; i < expected.size(); ++i) { EXPECT_EQ(expected[i], output_ptr[i]); } @@ -1097,7 +1093,7 @@ TEST(pooling_forward_gpu, offsets_avg_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i2x2x1x1_inp // [0, 0, 0, 0, 0, 0] // [0, 0, 0, 0, 0, 0] - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); std::vector formats_to_test = { format::yxfb , format::bfyx }; for (std::vector::iterator it = formats_to_test.begin(); it != formats_to_test.end(); ++it) @@ -1105,11 +1101,11 @@ TEST(pooling_forward_gpu, offsets_avg_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i2x2x1x1_inp std::cout << "Testing format: " << format::order(*it) << std::endl; tensor input_tensor( 1, 1, 2, 2 ); - auto input_prim = memory::allocate(engine, { data_types::f32, *it, input_tensor }); + auto input_prim = engine.allocate_memory({ data_types::f32, *it, input_tensor }); topology topology; - topology.add(input_layout("input_prim", input_prim.get_layout())); - topology.add(reorder("reorder", "input_prim", input_prim.get_layout().with_padding(padding{ {0,0,1,2}, 0 }))); + topology.add(input_layout("input_prim", input_prim->get_layout())); + topology.add(reorder("reorder", "input_prim", input_prim->get_layout().with_padding(padding{ {0,0,1,2}, 0 }))); topology.add(pooling("pool_prim", "reorder", pooling_mode::average, { 1,1,2,2 }, { 1,1,2,2 }, { 0,0,-1,-1 }, padding{ { 0,0,2,2 }, 0 })); network network(engine, topology); @@ -1130,7 +1126,7 @@ TEST(pooling_forward_gpu, offsets_avg_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i2x2x1x1_inp EXPECT_EQ(outputs.begin()->first, "pool_prim"); auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); for (size_t i = 0; i < expected.size(); ++i) { EXPECT_EQ(expected[i], output_ptr[i]); } @@ -1160,7 +1156,7 @@ TEST(pooling_forward_gpu, offsets_max_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i3x3x1x1_inp // [0, 1, -0.5, 0] // [0, 0, 0, 0, 0] - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); std::vector formats_to_test = { format::yxfb , format::bfyx }; for (std::vector::iterator it = formats_to_test.begin(); it != formats_to_test.end(); ++it) @@ -1168,11 +1164,11 @@ TEST(pooling_forward_gpu, offsets_max_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i3x3x1x1_inp std::cout << "Testing format: " << format::order(*it) << std::endl; tensor input_tensor( 1, 1, 3, 3 ); - auto input_prim = memory::allocate(engine, { data_types::f32, *it, input_tensor }); + auto input_prim = engine.allocate_memory({ data_types::f32, *it, input_tensor }); topology topology; - topology.add(input_layout("input_prim", input_prim.get_layout())); - topology.add(reorder("reorder", "input_prim", input_prim.get_layout().with_padding(padding{ { 0, 0, 1, 2 }, 0 }))); + topology.add(input_layout("input_prim", input_prim->get_layout())); + topology.add(reorder("reorder", "input_prim", input_prim->get_layout().with_padding(padding{ { 0, 0, 1, 2 }, 0 }))); topology.add(pooling("pool_prim", "reorder", pooling_mode::max, { 1,1,2,2 }, { 1,1,2,2 }, { 0,0,-1,-1 }, padding{ { 0,0,1,1 }, 0 })); network network(engine, topology); @@ -1197,10 +1193,10 @@ TEST(pooling_forward_gpu, offsets_max_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i3x3x1x1_inp EXPECT_EQ(outputs.begin()->first, "pool_prim"); auto output_prim = outputs.begin()->second.get_memory(); - EXPECT_EQ((int)output_prim.get_layout().size.count(), 4); - EXPECT_EQ((int)output_prim.get_layout().get_buffer_size().count(), 16); + EXPECT_EQ((int)output_prim->get_layout().size.count(), 4); + EXPECT_EQ((int)output_prim->get_layout().get_buffer_size().count(), 16); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); for (size_t i = 0; i < expected.size(); ++i) { EXPECT_EQ(expected[i], output_ptr[i]); } @@ -1231,7 +1227,7 @@ TEST(pooling_forward_gpu, avg_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i2x2x1x1_inpad2x1_ou // [0, 0, 0, 0, 0, 0] // [0, 0, 0, 0, 0, 0] - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); std::vector formats_to_test = { format::yxfb , format::bfyx }; for (std::vector::iterator it = formats_to_test.begin(); it != formats_to_test.end(); ++it) @@ -1239,11 +1235,11 @@ TEST(pooling_forward_gpu, avg_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i2x2x1x1_inpad2x1_ou std::cout << "Testing format: " << format::order(*it) << std::endl; tensor input_tensor( 1, 1, 4, 4 ); - auto input_prim = memory::allocate(engine, { data_types::f32, *it, input_tensor }); + auto input_prim = engine.allocate_memory({ data_types::f32, *it, input_tensor }); topology topology; - topology.add(input_layout("input_prim", input_prim.get_layout())); - topology.add(reorder("reorder", "input_prim", input_prim.get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 }))); + topology.add(input_layout("input_prim", input_prim->get_layout())); + topology.add(reorder("reorder", "input_prim", input_prim->get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 }))); topology.add(pooling("pool_prim", "reorder", pooling_mode::average, { 1,1,2,2 }, { 1,1,2,2 }, { 0,0,0,0 }, padding{ { 0,0,2,2 }, 0 })); network network(engine, topology); @@ -1268,7 +1264,7 @@ TEST(pooling_forward_gpu, avg_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i2x2x1x1_inpad2x1_ou EXPECT_EQ(outputs.begin()->first, "pool_prim"); auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); for (size_t i = 0; i < expected.size(); ++i) { EXPECT_EQ(expected[i], output_ptr[i]); } @@ -1299,7 +1295,7 @@ TEST(pooling_forward_gpu, max_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i3x3x1x1_inpad2x1_ou // [0, 12, 14, 16, 0] // [0, 0, 0, 0, 0] - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); std::vector formats_to_test = { format::yxfb , format::bfyx }; for (std::vector::iterator it = formats_to_test.begin(); it != formats_to_test.end(); ++it) @@ -1307,11 +1303,11 @@ TEST(pooling_forward_gpu, max_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i3x3x1x1_inpad2x1_ou std::cout << "Testing format: " << format::order(*it) << std::endl; tensor input_tensor( 1, 1, 5, 5 ); - auto input_prim = memory::allocate(engine, { data_types::f32, *it, input_tensor }); + auto input_prim = engine.allocate_memory({ data_types::f32, *it, input_tensor }); topology topology; - topology.add(input_layout("input_prim", input_prim.get_layout())); - topology.add(reorder("reorder", "input_prim", input_prim.get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 }))); + topology.add(input_layout("input_prim", input_prim->get_layout())); + topology.add(reorder("reorder", "input_prim", input_prim->get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 }))); topology.add(pooling("pool_prim", "reorder", pooling_mode::max, { 1,1,2,2 }, { 1,1,2,2 }, { 0,0,-1,-1 }, padding{ { 0,0,1,1 }, 0 })); network network(engine, topology); @@ -1339,10 +1335,10 @@ TEST(pooling_forward_gpu, max_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i3x3x1x1_inpad2x1_ou EXPECT_EQ(outputs.begin()->first, "pool_prim"); auto output_prim = outputs.begin()->second.get_memory(); - EXPECT_EQ((int)output_prim.get_layout().size.count(), 9); - EXPECT_EQ((int)output_prim.get_layout().get_buffer_size().count(), 25); + EXPECT_EQ((int)output_prim->get_layout().size.count(), 9); + EXPECT_EQ((int)output_prim->get_layout().get_buffer_size().count(), 25); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr (output_prim, get_test_stream()); for (size_t i = 0; i < expected.size(); ++i) { EXPECT_EQ(expected[i], output_ptr[i]); } @@ -1368,10 +1364,10 @@ TEST(pooling_forward_gpu, basic_in2x2x3x2_max_with_argmax) { // f0: b0: 4 4 b1: 15 13 // f1: b0: 10 11 b1: 21 23 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 3, 2 } }); - auto arg_max = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 3, 2 } }); + auto arg_max = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); set_values(input, { 1.0f, 2.0f, -10.f, @@ -1385,7 +1381,7 @@ TEST(pooling_forward_gpu, basic_in2x2x3x2_max_with_argmax) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(mutable_data("arg_max", arg_max)); topology.add(pooling("pooling", "input", "arg_max", pooling_mode::max_with_argmax, { 1, 1, 2, 2 }, { 1, 1, 1, 1 })); @@ -1396,9 +1392,9 @@ TEST(pooling_forward_gpu, basic_in2x2x3x2_max_with_argmax) { auto outputs = network.execute(); auto output = outputs.at("pooling").get_memory(); - auto output_ptr = output.pointer(); - auto output_layout = output.get_layout(); - auto argmax_ptr = arg_max.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + auto output_layout = output->get_layout(); + cldnn::mem_lock argmax_ptr(arg_max, get_test_stream()); EXPECT_EQ(output_layout.format, format::bfyx); EXPECT_EQ(output_layout.size.spatial[1], 1); @@ -1445,10 +1441,10 @@ TEST(pooling_forward_gpu, basic_in2x2x3x2x1_max_with_argmax) { // f0: b0: 4 4 b1: 15 13 // f1: b0: 10 11 b1: 21 23 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 2, 2, 3, 2, 1 } }); - auto arg_max = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 2, 2, 2, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 2, 2, 3, 2, 1 } }); + auto arg_max = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 2, 2, 2, 1, 1 } }); set_values(input, { 1.0f, 2.0f, -10.f, @@ -1462,7 +1458,7 @@ TEST(pooling_forward_gpu, basic_in2x2x3x2x1_max_with_argmax) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(mutable_data("arg_max", arg_max)); topology.add(pooling("pooling", "input", "arg_max", pooling_mode::max_with_argmax, { 1, 1, 2, 2, 1 }, { 1, 1, 1, 1, 1 })); @@ -1473,9 +1469,9 @@ TEST(pooling_forward_gpu, basic_in2x2x3x2x1_max_with_argmax) { auto outputs = network.execute(); auto output = outputs.at("pooling").get_memory(); - auto output_ptr = output.pointer(); - auto output_layout = output.get_layout(); - auto argmax_ptr = arg_max.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + auto output_layout = output->get_layout(); + cldnn::mem_lock argmax_ptr(arg_max, get_test_stream()); EXPECT_EQ(output_layout.format, format::bfzyx); EXPECT_EQ(output_layout.size.spatial[2], 1); @@ -1524,10 +1520,10 @@ TEST(pooling_forward_gpu, basic_in2x2x3x2_max_with_argmax_input_padding) { // f0: b0: 4 4 b1: 15 13 // f1: b0: 10 11 b1: 21 23 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 3, 2 } }); - auto arg_max = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 3, 2 } }); + auto arg_max = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); set_values(input, { 1.0f, 2.0f, -10.f, @@ -1541,8 +1537,8 @@ TEST(pooling_forward_gpu, basic_in2x2x3x2_max_with_argmax_input_padding) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(reorder("reorder", "input", input.get_layout().with_padding(padding{ { 0, 0, 2, 2 }, 0 }))); + topology.add(input_layout("input", input->get_layout())); + topology.add(reorder("reorder", "input", input->get_layout().with_padding(padding{ { 0, 0, 2, 2 }, 0 }))); topology.add(mutable_data("arg_max", arg_max)); topology.add(pooling("pooling", "reorder", "arg_max", pooling_mode::max_with_argmax, { 1, 1, 2, 2 }, { 1, 1, 1, 1 })); @@ -1553,9 +1549,9 @@ TEST(pooling_forward_gpu, basic_in2x2x3x2_max_with_argmax_input_padding) { auto outputs = network.execute(); auto output = outputs.at("pooling").get_memory(); - auto output_ptr = output.pointer(); - auto output_layout = output.get_layout(); - auto argmax_ptr = arg_max.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + auto output_layout = output->get_layout(); + cldnn::mem_lock argmax_ptr(arg_max, get_test_stream()); EXPECT_EQ(output_layout.format, format::bfyx); EXPECT_EQ(output_layout.size.spatial[1], 1); @@ -1603,10 +1599,10 @@ TEST(pooling_forward_gpu, basic_in2x2x3x2_max_with_argmax_output_padding) { // f0: b0: 4 4 b1: 15 13 // f1: b0: 10 11 b1: 21 23 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 3, 2 } }); - auto arg_max = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 3, 2 } }); + auto arg_max = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); set_values(input, { 1.0f, 2.0f, -10.f, @@ -1620,8 +1616,8 @@ TEST(pooling_forward_gpu, basic_in2x2x3x2_max_with_argmax_output_padding) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(reorder("reorder", "input", input.get_layout().with_padding(padding{ { 0, 0, 2, 2 }, 0 }))); + topology.add(input_layout("input", input->get_layout())); + topology.add(reorder("reorder", "input", input->get_layout().with_padding(padding{ { 0, 0, 2, 2 }, 0 }))); topology.add(mutable_data("arg_max", arg_max)); topology.add(pooling("pooling", "reorder", "arg_max", pooling_mode::max_with_argmax, { 1, 1, 2, 2 }, { 1, 1, 1, 1 }, { 0, 0, 0, 0 }, padding({ 0, 0, 1, 1 }, 0))); @@ -1632,9 +1628,9 @@ TEST(pooling_forward_gpu, basic_in2x2x3x2_max_with_argmax_output_padding) { auto outputs = network.execute(); auto output = outputs.at("pooling").get_memory(); - auto output_ptr = output.pointer(); - auto output_layout = output.get_layout(); - auto argmax_ptr = arg_max.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + auto output_layout = output->get_layout(); + cldnn::mem_lock argmax_ptr(arg_max, get_test_stream()); EXPECT_EQ(output_layout.format, format::bfyx); EXPECT_EQ(output_layout.size.spatial[1], 1); @@ -1692,10 +1688,10 @@ TEST(pooling_forward_gpu, basic_in2x2x3x2_max_with_argmax_with_output_size) { // f0: b0: 4 4 b1: 15 13 // f1: b0: 10 11 b1: 21 23 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 3, 2 } }); - auto arg_max = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 3, 2 } }); + auto arg_max = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 1 } }); set_values(input, { 1.0f, 2.0f, -10.f, @@ -1709,7 +1705,7 @@ TEST(pooling_forward_gpu, basic_in2x2x3x2_max_with_argmax_with_output_size) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(mutable_data("arg_max", arg_max)); topology.add(pooling("pooling", "input", "arg_max", pooling_mode::max_with_argmax, { 1, 1, 2, 2 }, { 1, 1, 1, 1 }, { 0, 0, 0, 0 }, { 2, 2, 2, 1 })); @@ -1720,9 +1716,9 @@ TEST(pooling_forward_gpu, basic_in2x2x3x2_max_with_argmax_with_output_size) { auto outputs = network.execute(); auto output = outputs.at("pooling").get_memory(); - auto output_ptr = output.pointer(); - auto output_layout = output.get_layout(); - auto argmax_ptr = arg_max.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + auto output_layout = output->get_layout(); + cldnn::mem_lock argmax_ptr(arg_max, get_test_stream()); EXPECT_EQ(output_layout.format, format::bfyx); EXPECT_EQ(output_layout.size.spatial[1], 1); @@ -1755,38 +1751,36 @@ static void generic_average_wo_padding_test(format fmt, tensor output, tensor in { constexpr auto dt = std::is_same::value ? data_types::f32 : data_types::f16; - engine eng; + auto& engine = get_test_engine(); - if (!eng.get_info().supports_fp16) - { - if(dt == data_types::f16) - { + if (!engine.get_device_info().supports_fp16) { + if (dt == data_types::f16) { return; } } - auto input_mem = memory::allocate(eng, layout{ dt, fmt, input }); + auto input_mem = engine.allocate_memory(layout{ dt, fmt, input }); set_values(input_mem, std::vector(input.count(), DataType(1))); std::vector expected_output(output.count(), DataType(1)); topology tpl; - tpl.add(input_layout("in", input_mem.get_layout())); + tpl.add(input_layout("in", input_mem->get_layout())); auto pool_in = "in"; if (offset != tensor()) { - tpl.add(reorder("reorder", "in", input_mem.get_layout().with_padding((padding) offset.negate().sizes()))); + tpl.add(reorder("reorder", "in", input_mem->get_layout().with_padding((padding) offset.negate().sizes()))); pool_in = "reorder"; } tpl.add(pooling("pool", pool_in, pooling_mode::average_no_padding, window, stride, offset)); - network net(eng, tpl); + network net(engine, tpl); net.set_input_data("in", input_mem); auto output_mem = net.execute().at("pool").get_memory(); - ASSERT_EQ(output_mem.count(), expected_output.size()); - EXPECT_EQ(output_mem.get_layout().size, output); - auto out_ptr = output_mem.pointer(); + ASSERT_EQ(output_mem->count(), expected_output.size()); + EXPECT_EQ(output_mem->get_layout().size, output); + cldnn::mem_lock out_ptr(output_mem, get_test_stream()); for (size_t i = 0; i < expected_output.size(); ++i) EXPECT_FLOAT_EQ(out_ptr[i], expected_output[i]); @@ -1959,16 +1953,13 @@ TEST(pooling_forward_gpu, b_fs_yx_fsv4) std::vector vGoldOutput; std::vector vTestOutput; - engine engine; + auto& engine = get_test_engine(); // "Golden" Pooling { // Mem initialization // This is user data, no kernels here - auto input = memory::allocate(engine, - { data_types::i8, - format::bfyx, - { in_B, in_F, in_X, in_Y } }); + auto input = engine.allocate_memory({ data_types::i8, format::bfyx, { in_B, in_F, in_X, in_Y } }); set_values(input, std::move(DataGold)); auto pool = pooling("pool_GOLD", @@ -1978,7 +1969,7 @@ TEST(pooling_forward_gpu, b_fs_yx_fsv4) { 1, 1, S_X, S_Y }); // stride // Create a topology with a simple Convolution layer - topology topology(input_layout("input", input.get_layout()), + topology topology(input_layout("input", input->get_layout()), pool); // Network processing @@ -1989,7 +1980,7 @@ TEST(pooling_forward_gpu, b_fs_yx_fsv4) auto searchC = outputs.find("pool_GOLD"); ASSERT_FALSE(searchC == outputs.end()); auto output = outputs.begin()->second.get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); vGoldOutput.reserve(output_ptr.size()); for (size_t i = 0; i < output_ptr.size(); i++) vGoldOutput.push_back(output_ptr[i]); @@ -2003,15 +1994,12 @@ TEST(pooling_forward_gpu, b_fs_yx_fsv4) // Mem initialization // This is user data, no kernels here - auto input = memory::allocate(engine, - { data_types::i8, - format::bfyx, - { in_B, in_F, in_X, in_Y } }); + auto input = engine.allocate_memory({ data_types::i8, format::bfyx, { in_B, in_F, in_X, in_Y } }); set_values(input, std::move(Data)); // Add input to topology topology.add( - input_layout("input", input.get_layout())); + input_layout("input", input->get_layout())); // Reorder (a-ka swizzelling) input to MMAD/IMAD Pooling format topology.add(reorder("reorder_Swizzelled", @@ -2041,7 +2029,7 @@ TEST(pooling_forward_gpu, b_fs_yx_fsv4) auto searchC = outputs.find("reorder_UnSwizzelled"); ASSERT_FALSE(searchC == outputs.end()); auto output = outputs.begin()->second.get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); vTestOutput.reserve(output_ptr.size()); for (size_t i = 0; i < output_ptr.size(); i++) vTestOutput.push_back(output_ptr[i]); @@ -2057,8 +2045,8 @@ TEST(pooling_forward_gpu, b_fs_yx_fsv4) TEST(pooling_forward_gpu, fs_b_yx_fsv32_avg_3x3_input_2x2_pool_1x1_stride_2x2_output) { - const auto& engine = get_test_engine(); - bool f16_supported = !!engine.get_info().supports_fp16; + auto& engine = get_test_engine(); + bool f16_supported = !!engine.get_device_info().supports_fp16; if (!f16_supported) { std::cout << "[ SKIPPED ] float16 combinations are skipped (cl_khr_fp16 is not supported)." << std::endl; return; @@ -2080,10 +2068,10 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_avg_3x3_input_2x2_pool_1x1_stride_2x2_ou // [ 1.0, 0.625] // [ 1.625, 0.875] - auto input_prim = memory::allocate(engine, { data_types::f16, format::yxfb, { 1, 1, 3, 3 } }); + auto input_prim = engine.allocate_memory({ data_types::f16, format::yxfb, { 1, 1, 3, 3 } }); topology topology; - topology.add(input_layout("input", input_prim.get_layout())); + topology.add(input_layout("input", input_prim->get_layout())); topology.add(reorder("reorder_input", "input", layout(data_types::f16, format::fs_b_yx_fsv32, { 1, 1, 3, 3 }))); topology.add(pooling("avg_pooling", "reorder_input", pooling_mode::average, { 1,1,2,2 }, { 1,1,1,1 })); topology.add(reorder("reorder_after_pooling", "avg_pooling", layout(data_types::f16, format::bfyx, { 1,1,2,2 }))); @@ -2098,7 +2086,7 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_avg_3x3_input_2x2_pool_1x1_stride_2x2_ou auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); EXPECT_EQ(1.0f, float(output_ptr[0])); EXPECT_EQ(0.625f, float(output_ptr[1])); @@ -2109,8 +2097,8 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_avg_3x3_input_2x2_pool_1x1_stride_2x2_ou TEST(pooling_forward_gpu, fs_b_yx_fsv32_avg_3x3_input_2x2_pool_2x2_stride) { - const auto& engine = get_test_engine(); - bool f16_supported = !!engine.get_info().supports_fp16; + auto& engine = get_test_engine(); + bool f16_supported = !!engine.get_device_info().supports_fp16; if (!f16_supported) { std::cout << "[ SKIPPED ] float16 combinations are skipped (cl_khr_fp16 is not supported)." << std::endl; return; @@ -2132,10 +2120,10 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_avg_3x3_input_2x2_pool_2x2_stride) // [ 1.0, 0 ] // [ 1.5, 3.5] - auto input_prim = memory::allocate(engine, { data_types::f16, format::yxfb, { 1, 1, 3, 3 } }); + auto input_prim = engine.allocate_memory({ data_types::f16, format::yxfb, { 1, 1, 3, 3 } }); topology topology; - topology.add(input_layout("input", input_prim.get_layout())); + topology.add(input_layout("input", input_prim->get_layout())); topology.add(reorder("reorder_input", "input", layout(data_types::f16, format::fs_b_yx_fsv32, { 1, 1, 3, 3 }))); topology.add(pooling("avg_pooling", "reorder_input", pooling_mode::average, { 1,1,2,2 }, { 1,1,2,2 })); topology.add(reorder("reorder_after_pooling", "avg_pooling", layout(data_types::f16, format::bfyx, { 1,1,3,3 }))); @@ -2149,7 +2137,7 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_avg_3x3_input_2x2_pool_2x2_stride) EXPECT_EQ(outputs.begin()->first, "reorder_after_pooling"); auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); EXPECT_EQ(1.0f, float(output_ptr[0])); EXPECT_EQ(0.f, float(output_ptr[1])); @@ -2161,8 +2149,8 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_avg_3x3_input_2x2_pool_2x2_stride) TEST(pooling_forward_gpu, fs_b_yx_fsv32_avg_2x2x3x3_input_2x2_pool_2x2_stride) { - const auto& engine = get_test_engine(); - bool f16_supported = !!engine.get_info().supports_fp16; + auto& engine = get_test_engine(); + bool f16_supported = !!engine.get_device_info().supports_fp16; if (!f16_supported) { std::cout << "[ SKIPPED ] float16 combinations are skipped (cl_khr_fp16 is not supported)." << std::endl; return; @@ -2198,10 +2186,10 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_avg_2x2x3x3_input_2x2_pool_2x2_stride) const int out_x = 2; const int out_y = 2; - auto input_prim = memory::allocate(engine, { data_types::f16, format::bfyx, { batch_count, features_count, 3, 3 } }); + auto input_prim = engine.allocate_memory({ data_types::f16, format::bfyx, { batch_count, features_count, 3, 3 } }); topology topology; - topology.add(input_layout("input", input_prim.get_layout())); + topology.add(input_layout("input", input_prim->get_layout())); topology.add(reorder("reorder_input", "input", layout(data_types::f16, format::fs_b_yx_fsv32, { batch_count, features_count, 3, 3 }))); topology.add(pooling("avg_pooling", "reorder_input", pooling_mode::average, { 1,1,2,2 }, { 1,1,2,2 })); topology.add(reorder("reorder_after_pooling", "avg_pooling", layout(data_types::f16, format::bfyx, { batch_count, features_count, out_y, out_x }))); @@ -2219,7 +2207,7 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_avg_2x2x3x3_input_2x2_pool_2x2_stride) auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); ASSERT_EQ((int)output_ptr.size(), batch_count * features_count*out_x*out_y); @@ -2240,8 +2228,8 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_avg_2x2x3x3_input_2x2_pool_2x2_stride) } TEST(pooling_forward_gpu, fs_b_yx_fsv32_max_1x1x3x3_input_2x2_pool_2x2_stride_2x2_outpad) { - const auto& engine = get_test_engine(); - bool f16_supported = !!engine.get_info().supports_fp16; + auto& engine = get_test_engine(); + bool f16_supported = !!engine.get_device_info().supports_fp16; if (!f16_supported) { std::cout << "[ SKIPPED ] float16 combinations are skipped (cl_khr_fp16 is not supported)." << std::endl; return; @@ -2269,10 +2257,10 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_max_1x1x3x3_input_2x2_pool_2x2_stride_2x // [0, 0, 0, 0, 0] tensor input_tensor(1, 1, 3, 3); - auto input_prim = memory::allocate(engine, { data_types::f16, format::bfyx, input_tensor }); + auto input_prim = engine.allocate_memory({ data_types::f16, format::bfyx, input_tensor }); topology topology; - topology.add(input_layout("input_prim", input_prim.get_layout())); + topology.add(input_layout("input_prim", input_prim->get_layout())); topology.add(reorder("reorder_input", "input_prim", layout(data_types::f16, format::fs_b_yx_fsv32, input_tensor))); topology.add(pooling("pool_prim", "reorder_input", pooling_mode::max, { 1,1,2,2 }, { 1,1,2,2 }, { 0,0,-1,-1 }, padding{ { 0,0,1,1 }, 0 })); topology.add(reorder("reorder_pooling", "pool_prim", layout(data_types::f16, format::bfyx, { 1,1,4,4 }, padding{ {0,0,1,1},0 }))); @@ -2299,10 +2287,10 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_max_1x1x3x3_input_2x2_pool_2x2_stride_2x EXPECT_EQ(outputs.begin()->first, "reorder_pooling"); auto output_prim = outputs.begin()->second.get_memory(); - EXPECT_EQ((int)output_prim.get_layout().size.count(), 4); - EXPECT_EQ((int)output_prim.get_layout().get_buffer_size().count(), 16); + EXPECT_EQ((int)output_prim->get_layout().size.count(), 4); + EXPECT_EQ((int)output_prim->get_layout().get_buffer_size().count(), 16); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); for (size_t i = 0; i < expected.size(); ++i) { EXPECT_EQ(expected[i], float(output_ptr[i])); @@ -2311,8 +2299,8 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_max_1x1x3x3_input_2x2_pool_2x2_stride_2x } TEST(pooling_forward_gpu, fs_b_yx_fsv32_max_1x1x5x5_input_2x2_pool_2x2_stride_2x2_outpad_2x1_inpad) { - const auto& engine = get_test_engine(); - bool f16_supported = !!engine.get_info().supports_fp16; + auto& engine = get_test_engine(); + bool f16_supported = !!engine.get_device_info().supports_fp16; if (!f16_supported) { std::cout << "[ SKIPPED ] float16 combinations are skipped (cl_khr_fp16 is not supported)." << std::endl; return; @@ -2342,10 +2330,10 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_max_1x1x5x5_input_2x2_pool_2x2_stride_2x // [ 0, 0, 0, 0, 0] tensor input_tensor(1, 1, 5, 5); - auto input_prim = memory::allocate(engine, { data_types::f16, format::bfyx, input_tensor }); + auto input_prim = engine.allocate_memory({ data_types::f16, format::bfyx, input_tensor }); topology topology; - topology.add(input_layout("input_prim", input_prim.get_layout())); + topology.add(input_layout("input_prim", input_prim->get_layout())); topology.add(reorder("reorder_input", "input_prim", layout(data_types::f16, format::fs_b_yx_fsv32, input_tensor, padding{ { 0,0,2,1 } , 0 }))); topology.add(pooling("pool_prim", "reorder_input", pooling_mode::max, { 1,1,2,2 }, { 1,1,2,2 }, { 0,0,-1,-1 }, padding{ { 0,0,1,1 }, 0 })); topology.add(reorder("reorder_pooling", "pool_prim", layout(data_types::f16, format::bfyx, input_tensor, padding{{0,0,1,1},0}))); @@ -2375,10 +2363,10 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_max_1x1x5x5_input_2x2_pool_2x2_stride_2x EXPECT_EQ(outputs.begin()->first, "reorder_pooling"); auto output_prim = outputs.begin()->second.get_memory(); - EXPECT_EQ((int)output_prim.get_layout().size.count(), 9); - EXPECT_EQ((int)output_prim.get_layout().get_buffer_size().count(), 25); + EXPECT_EQ((int)output_prim->get_layout().size.count(), 9); + EXPECT_EQ((int)output_prim->get_layout().get_buffer_size().count(), 25); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); for (size_t i = 0; i < expected.size(); ++i) { EXPECT_EQ(expected[i], float(output_ptr[i])); @@ -2387,8 +2375,8 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_max_1x1x5x5_input_2x2_pool_2x2_stride_2x TEST(pooling_forward_gpu, fs_b_yx_fsv32_avg_65x5x6x7_input_3x3_pool_4x4_stride_3x2_outpad_2x3_inpad) { - const auto& engine = get_test_engine(); - bool f16_supported = !!engine.get_info().supports_fp16; + auto& engine = get_test_engine(); + bool f16_supported = !!engine.get_device_info().supports_fp16; if (!f16_supported) { std::cout << "[ SKIPPED ] float16 combinations are skipped (cl_khr_fp16 is not supported)." << std::endl; return; @@ -2414,7 +2402,7 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_avg_65x5x6x7_input_3x3_pool_4x4_stride_3 input_data[i] = FLOAT16((float)i/float(input_data.size())); } - auto input_prim = memory::allocate(engine, { data_types::f16,format::bfyx,input_tensor }); + auto input_prim = engine.allocate_memory({ data_types::f16,format::bfyx,input_tensor }); set_values(input_prim, input_data); std::vector golden_results; @@ -2422,15 +2410,15 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_avg_65x5x6x7_input_3x3_pool_4x4_stride_3 { //GOLDEN TOPOLOGY topology golden_topology; - golden_topology.add(input_layout("input", input_prim.get_layout())); - golden_topology.add(reorder("reorder_input", "input", input_prim.get_layout().with_padding(padding{ {0,0,x_in_pad,y_in_pad},0 }))); + golden_topology.add(input_layout("input", input_prim->get_layout())); + golden_topology.add(reorder("reorder_input", "input", input_prim->get_layout().with_padding(padding{ {0,0,x_in_pad,y_in_pad},0 }))); golden_topology.add(pooling("golden_pooling", "reorder_input", pooling_mode::average, { 1,1,pool_size,pool_size }, { 1,1,stride_size,stride_size }, { 0,0,0,0 }, padding{ { 0,0,x_out_pad,y_out_pad },0 })); network golden_network(engine, golden_topology); golden_network.set_input_data("input", input_prim); auto outputs = golden_network.execute(); - auto output_ptr = outputs.begin()->second.get_memory().pointer(); + cldnn::mem_lock output_ptr(outputs.begin()->second.get_memory(), get_test_stream()); for (size_t i = 0; i < output_ptr.size(); i++) { golden_results.push_back(float(output_ptr[i])); @@ -2439,7 +2427,7 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_avg_65x5x6x7_input_3x3_pool_4x4_stride_3 { //FSV32 TOPOLOGY topology golden_topology; - golden_topology.add(input_layout("input", input_prim.get_layout())); + golden_topology.add(input_layout("input", input_prim->get_layout())); golden_topology.add(reorder("reorder_input", "input", layout(data_types::f16, format::fs_b_yx_fsv32, input_tensor, padding{ {0,0,x_in_pad, y_in_pad}, 0 }))); golden_topology.add(pooling("fsv32_pooling", "reorder_input", pooling_mode::average, { 1,1,pool_size,pool_size }, { 1,1,stride_size,stride_size }, { 0,0,0,0 }, padding{ { 0,0,x_out_pad,y_out_pad },0 })); golden_topology.add(reorder("reorder_pooling", "fsv32_pooling", layout(data_types::f16, format::bfyx, input_tensor, padding{ { 0,0,x_out_pad,y_out_pad },0 }))); @@ -2448,7 +2436,7 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_avg_65x5x6x7_input_3x3_pool_4x4_stride_3 fsv32_network.set_input_data("input", input_prim); auto outputs = fsv32_network.execute(); - auto output_ptr = outputs.begin()->second.get_memory().pointer(); + cldnn::mem_lock output_ptr(outputs.begin()->second.get_memory(), get_test_stream()); for (size_t i = 0; i < output_ptr.size(); i++) { fsv32_results.push_back(float(output_ptr[i])); @@ -2493,7 +2481,7 @@ class pooling_test_base { virtual void run_expect(const VVVVVF& expected) { - auto eng = get_test_engine(); + auto& eng = get_test_engine(); auto topo = build_topology(eng); auto opts = build_options( build_option::optimize_data(true) @@ -2504,7 +2492,7 @@ class pooling_test_base { auto input_lay = layout(input_type(), input_format(), input_size); - auto input_mem = memory::allocate(eng, input_lay); + auto input_mem = eng.allocate_memory(input_lay); std::vector input_flat(input_lay.get_linear_size(), static_cast(0)); for (size_t bi = 0; bi < batch_num(); ++bi) for (size_t fi = 0; fi < input_features(); ++fi) @@ -2520,8 +2508,8 @@ class pooling_test_base { net.set_input_data("input", input_mem); auto result = net.execute(); auto out_mem = result.at(output_id()).get_memory(); - auto out_lay = out_mem.get_layout(); - auto out_ptr = out_mem.cldnn::memory::template pointer(); + auto out_lay = out_mem->get_layout(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); std::string kernel; for (auto i : net.get_primitives_info()) { @@ -2779,12 +2767,12 @@ class pooling_scale_random_test_base : public pooling_random_test_base; using output_t = typename parent::output_t; - topology build_topology(const engine& eng) override { + topology build_topology(engine& eng) override { topology topo = parent::build_topology(eng); auto scale_lay = layout(this->output_type(), format::bfyx, tensor(batch(1), feature(this->input_features()), spatial(1, 1, 1, 1))); - auto scale_mem = memory::allocate(eng, scale_lay); - auto shift_mem = memory::allocate(eng, scale_lay); + auto scale_mem = eng.allocate_memory(scale_lay); + auto shift_mem = eng.allocate_memory(scale_lay); set_values(scale_mem, _scale); set_values(shift_mem, _shift); @@ -2864,7 +2852,7 @@ INSTANTIATE_TEST_CASE_P( TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x8x8_input_2x2_pool_2x2_stride) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int features = 16; const int batches = 16; @@ -2880,7 +2868,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x8x8_input_2x2_pool_2x2_stride) auto input_data = generate_random_1d(batches * features * x_input * y_input, -10, 10); - auto input_prim = memory::allocate(engine, {data_types::f32, format::bfyx, input_tensor}); + auto input_prim = engine.allocate_memory({data_types::f32, format::bfyx, input_tensor}); set_values(input_prim, input_data); std::vector golden_results; @@ -2889,8 +2877,8 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x8x8_input_2x2_pool_2x2_stride) { // golden topology topology golden_topology; - golden_topology.add(input_layout("input", input_prim.get_layout())); - golden_topology.add(reorder("reorder_input", "input", input_prim.get_layout())); + golden_topology.add(input_layout("input", input_prim->get_layout())); + golden_topology.add(reorder("reorder_input", "input", input_prim->get_layout())); golden_topology.add(pooling("golden_pooling", "reorder_input", pooling_mode::max, {1, 1, pool_size, pool_size}, {1, 1, stride_size, stride_size}, {0, 0, -x_in_pad, -y_in_pad})); @@ -2898,7 +2886,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x8x8_input_2x2_pool_2x2_stride) golden_network.set_input_data("input", input_prim); auto outputs = golden_network.execute(); - auto output_ptr = outputs.begin()->second.get_memory().pointer(); + cldnn::mem_lock output_ptr(outputs.begin()->second.get_memory(), get_test_stream()); for (size_t i = 0; i < output_ptr.size(); i++) { golden_results.push_back(float(output_ptr[i])); @@ -2908,7 +2896,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x8x8_input_2x2_pool_2x2_stride) { // bfzyx_bsv16_fsv16 topology topology tested_topology; - tested_topology.add(input_layout("input", input_prim.get_layout())); + tested_topology.add(input_layout("input", input_prim->get_layout())); tested_topology.add(reorder("reorder_input", "input", layout(data_types::f32, format::bs_fs_yx_bsv16_fsv16, input_tensor))); tested_topology.add(pooling("bsv16_fsv16_pooling", "reorder_input", pooling_mode::max, {1, 1, pool_size, pool_size}, @@ -2922,9 +2910,9 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x8x8_input_2x2_pool_2x2_stride) bsv16_fsv16_network.set_input_data("input", input_prim); auto outputs = bsv16_fsv16_network.execute(); - auto output_ptr = outputs.at("reorder_pooling").get_memory().pointer(); + cldnn::mem_lock output_ptr(outputs.at("reorder_pooling").get_memory(), get_test_stream()); - ASSERT_EQ(outputs.at("bsv16_fsv16_pooling").get_memory().get_layout().format, format::bs_fs_yx_bsv16_fsv16); + ASSERT_EQ(outputs.at("bsv16_fsv16_pooling").get_memory()->get_layout().format, format::bs_fs_yx_bsv16_fsv16); for (size_t i = 0; i < output_ptr.size(); i++) { @@ -2948,7 +2936,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x8x8_input_2x2_pool_2x2_stride) TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x2x2_input_4x4_pool_1x1_stride_1x1_inpad) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int features = 16; const int batches = 16; @@ -2964,7 +2952,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x2x2_input_4x4_pool_1x1_stride_1x auto input_data = generate_random_1d(batches * features * x_input * y_input, -10, 10); - auto input_prim = memory::allocate(engine, {data_types::f32, format::bfyx, input_tensor}); + auto input_prim = engine.allocate_memory({data_types::f32, format::bfyx, input_tensor}); set_values(input_prim, input_data); std::vector golden_results; @@ -2973,8 +2961,8 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x2x2_input_4x4_pool_1x1_stride_1x { // golden topology topology golden_topology; - golden_topology.add(input_layout("input", input_prim.get_layout())); - golden_topology.add(reorder("reorder_input", "input", input_prim.get_layout())); + golden_topology.add(input_layout("input", input_prim->get_layout())); + golden_topology.add(reorder("reorder_input", "input", input_prim->get_layout())); golden_topology.add( pooling("golden_pooling", "reorder_input", pooling_mode::max, {1, 1, pool_size, pool_size}, {1, 1, stride_size, stride_size}, {0, 0, -x_in_pad, -y_in_pad})); @@ -2983,7 +2971,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x2x2_input_4x4_pool_1x1_stride_1x golden_network.set_input_data("input", input_prim); auto outputs = golden_network.execute(); - auto output_ptr = outputs.begin()->second.get_memory().pointer(); + cldnn::mem_lock output_ptr(outputs.begin()->second.get_memory(), get_test_stream()); for (size_t i = 0; i < output_ptr.size(); i++) { golden_results.push_back(float(output_ptr[i])); } @@ -2992,7 +2980,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x2x2_input_4x4_pool_1x1_stride_1x { // bs_fs_yx_bsv16_fsv16 topology topology tested_topology; - tested_topology.add(input_layout("input", input_prim.get_layout())); + tested_topology.add(input_layout("input", input_prim->get_layout())); tested_topology.add(reorder("reorder_input", "input", layout(data_types::f32, format::bs_fs_yx_bsv16_fsv16, input_tensor))); tested_topology.add( @@ -3006,9 +2994,9 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x2x2_input_4x4_pool_1x1_stride_1x bsv16_fsv16_network.set_input_data("input", input_prim); auto outputs = bsv16_fsv16_network.execute(); - auto output_ptr = outputs.at("reorder_pooling").get_memory().pointer(); + cldnn::mem_lock output_ptr(outputs.at("reorder_pooling").get_memory(), get_test_stream()); - ASSERT_EQ(outputs.at("bsv16_fsv16_pooling").get_memory().get_layout().format, format::bs_fs_yx_bsv16_fsv16); + ASSERT_EQ(outputs.at("bsv16_fsv16_pooling").get_memory()->get_layout().format, format::bs_fs_yx_bsv16_fsv16); for (size_t i = 0; i < output_ptr.size(); i++) { @@ -3031,7 +3019,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x2x2_input_4x4_pool_1x1_stride_1x TEST(pooling_forward_gpu, bsv16_fsv16_avg_16x16x20x20_input_5x5_pool_3x3_stride) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int features = 16; const int batches = 16; @@ -3047,7 +3035,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_avg_16x16x20x20_input_5x5_pool_3x3_stride) auto input_data = generate_random_1d(batches * features * x_input * y_input, -10, 10); - auto input_prim = memory::allocate(engine, {data_types::f32, format::bfyx, input_tensor}); + auto input_prim = engine.allocate_memory({data_types::f32, format::bfyx, input_tensor}); set_values(input_prim, input_data); std::vector golden_results; @@ -3056,8 +3044,8 @@ TEST(pooling_forward_gpu, bsv16_fsv16_avg_16x16x20x20_input_5x5_pool_3x3_stride) { // golden topology topology golden_topology; - golden_topology.add(input_layout("input", input_prim.get_layout())); - golden_topology.add(reorder("reorder_input", "input", input_prim.get_layout())); + golden_topology.add(input_layout("input", input_prim->get_layout())); + golden_topology.add(reorder("reorder_input", "input", input_prim->get_layout())); golden_topology.add(pooling("golden_pooling", "reorder_input", pooling_mode::average, {1, 1, pool_size, pool_size}, {1, 1, stride_size, stride_size}, {0, 0, -x_in_pad, -y_in_pad})); @@ -3065,7 +3053,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_avg_16x16x20x20_input_5x5_pool_3x3_stride) golden_network.set_input_data("input", input_prim); auto outputs = golden_network.execute(); - auto output_ptr = outputs.begin()->second.get_memory().pointer(); + cldnn::mem_lock output_ptr(outputs.begin()->second.get_memory(), get_test_stream()); for (size_t i = 0; i < output_ptr.size(); i++) { @@ -3076,7 +3064,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_avg_16x16x20x20_input_5x5_pool_3x3_stride) { // bs_fs_yx_bsv16_fsv16 topology topology tested_topology; - tested_topology.add(input_layout("input", input_prim.get_layout())); + tested_topology.add(input_layout("input", input_prim->get_layout())); tested_topology.add(reorder("reorder_input", "input", layout(data_types::f32, format::bs_fs_yx_bsv16_fsv16, input_tensor))); tested_topology.add(pooling("bsv16_fsv16_pooling", "reorder_input", pooling_mode::average, {1, 1, pool_size, pool_size}, @@ -3090,9 +3078,9 @@ TEST(pooling_forward_gpu, bsv16_fsv16_avg_16x16x20x20_input_5x5_pool_3x3_stride) bsv16_fsv16_network.set_input_data("input", input_prim); auto outputs = bsv16_fsv16_network.execute(); - auto output_ptr = outputs.at("reorder_pooling").get_memory().pointer(); + cldnn::mem_lock output_ptr(outputs.at("reorder_pooling").get_memory(), get_test_stream()); - ASSERT_EQ(outputs.at("bsv16_fsv16_pooling").get_memory().get_layout().format, format::bs_fs_yx_bsv16_fsv16); + ASSERT_EQ(outputs.at("bsv16_fsv16_pooling").get_memory()->get_layout().format, format::bs_fs_yx_bsv16_fsv16); for (size_t i = 0; i < output_ptr.size(); i++) { @@ -3115,7 +3103,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_avg_16x16x20x20_input_5x5_pool_3x3_stride) TEST(pooling_forward_gpu, bsv16_fsv16_avg_16x16x20x20_input_5x5_pool_3x1_stride) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int features = 16; const int batches = 16; @@ -3132,7 +3120,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_avg_16x16x20x20_input_5x5_pool_3x1_stride) auto input_data = generate_random_1d(batches * features * x_input * y_input, -10, 10); - auto input_prim = memory::allocate(engine, {data_types::f32, format::bfyx, input_tensor}); + auto input_prim = engine.allocate_memory({data_types::f32, format::bfyx, input_tensor}); set_values(input_prim, input_data); std::vector golden_results; @@ -3141,8 +3129,8 @@ TEST(pooling_forward_gpu, bsv16_fsv16_avg_16x16x20x20_input_5x5_pool_3x1_stride) { // golden topology topology golden_topology; - golden_topology.add(input_layout("input", input_prim.get_layout())); - golden_topology.add(reorder("reorder_input", "input", input_prim.get_layout())); + golden_topology.add(input_layout("input", input_prim->get_layout())); + golden_topology.add(reorder("reorder_input", "input", input_prim->get_layout())); golden_topology.add(pooling("golden_pooling", "reorder_input", pooling_mode::average, {1, 1, pool_size, pool_size}, {1, 1, stride_size_x, stride_size_y}, {0, 0, -x_in_pad, -y_in_pad})); @@ -3150,7 +3138,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_avg_16x16x20x20_input_5x5_pool_3x1_stride) golden_network.set_input_data("input", input_prim); auto outputs = golden_network.execute(); - auto output_ptr = outputs.begin()->second.get_memory().pointer(); + cldnn::mem_lock output_ptr(outputs.begin()->second.get_memory(), get_test_stream()); for (size_t i = 0; i < output_ptr.size(); i++) { @@ -3161,7 +3149,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_avg_16x16x20x20_input_5x5_pool_3x1_stride) { // bs_fs_yx_bsv16_fsv16 topology topology tested_topology; - tested_topology.add(input_layout("input", input_prim.get_layout())); + tested_topology.add(input_layout("input", input_prim->get_layout())); tested_topology.add(reorder("reorder_input", "input", layout(data_types::f32, format::bs_fs_yx_bsv16_fsv16, input_tensor))); tested_topology.add(pooling("bsv16_fsv16_pooling", "reorder_input", pooling_mode::average, {1, 1, pool_size, pool_size}, {1, 1, stride_size_x, stride_size_y}, {0, 0, -x_in_pad, -y_in_pad})); @@ -3173,9 +3161,9 @@ TEST(pooling_forward_gpu, bsv16_fsv16_avg_16x16x20x20_input_5x5_pool_3x1_stride) bsv16_fsv16_network.set_input_data("input", input_prim); auto outputs = bsv16_fsv16_network.execute(); - auto output_ptr = outputs.at("reorder_pooling").get_memory().pointer(); + cldnn::mem_lock output_ptr(outputs.at("reorder_pooling").get_memory(), get_test_stream()); - ASSERT_EQ(outputs.at("bsv16_fsv16_pooling").get_memory().get_layout().format, format::bs_fs_yx_bsv16_fsv16); + ASSERT_EQ(outputs.at("bsv16_fsv16_pooling").get_memory()->get_layout().format, format::bs_fs_yx_bsv16_fsv16); for (size_t i = 0; i < output_ptr.size(); i++) { @@ -3198,7 +3186,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_avg_16x16x20x20_input_5x5_pool_3x1_stride) TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x20x20_input_5x5_pool_3x1_stride) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int features = 16; const int batches = 16; @@ -3215,7 +3203,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x20x20_input_5x5_pool_3x1_stride) auto input_data = generate_random_1d(batches * features * x_input * y_input, -10, 10); - auto input_prim = memory::allocate(engine, { data_types::f32,format::bfyx,input_tensor }); + auto input_prim = engine.allocate_memory({ data_types::f32,format::bfyx,input_tensor }); set_values(input_prim, input_data); std::vector golden_results; @@ -3224,8 +3212,8 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x20x20_input_5x5_pool_3x1_stride) { // golden topology topology golden_topology; - golden_topology.add(input_layout("input", input_prim.get_layout())); - golden_topology.add(reorder("reorder_input", "input", input_prim.get_layout())); + golden_topology.add(input_layout("input", input_prim->get_layout())); + golden_topology.add(reorder("reorder_input", "input", input_prim->get_layout())); golden_topology.add(pooling("golden_pooling", "reorder_input", pooling_mode::max, {1, 1, pool_size, pool_size}, {1, 1, stride_size_x, stride_size_y}, {0, 0, -x_in_pad, -y_in_pad})); @@ -3233,7 +3221,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x20x20_input_5x5_pool_3x1_stride) golden_network.set_input_data("input", input_prim); auto outputs = golden_network.execute(); - auto output_ptr = outputs.begin()->second.get_memory().pointer(); + cldnn::mem_lock output_ptr(outputs.begin()->second.get_memory(), get_test_stream()); for (size_t i = 0; i < output_ptr.size(); i++) { @@ -3244,7 +3232,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x20x20_input_5x5_pool_3x1_stride) { // bs_fs_yx_bsv16_fsv16 topology topology tested_topology; - tested_topology.add(input_layout("input", input_prim.get_layout())); + tested_topology.add(input_layout("input", input_prim->get_layout())); tested_topology.add(reorder("reorder_input", "input", layout(data_types::f32, format::bs_fs_yx_bsv16_fsv16, input_tensor))); tested_topology.add( @@ -3258,9 +3246,9 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x20x20_input_5x5_pool_3x1_stride) bsv16_fsv16_network.set_input_data("input", input_prim); auto outputs = bsv16_fsv16_network.execute(); - auto output_ptr = outputs.at("reorder_pooling").get_memory().pointer(); + cldnn::mem_lock output_ptr(outputs.at("reorder_pooling").get_memory(), get_test_stream()); - ASSERT_EQ(outputs.at("bsv16_fsv16_pooling").get_memory().get_layout().format, format::bs_fs_yx_bsv16_fsv16); + ASSERT_EQ(outputs.at("bsv16_fsv16_pooling").get_memory()->get_layout().format, format::bs_fs_yx_bsv16_fsv16); for (size_t i = 0; i < output_ptr.size(); i++) { @@ -3283,7 +3271,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x20x20_input_5x5_pool_3x1_stride) TEST(pooling_forward_gpu, bsv16_fsv16_max_32x32x20x20_input_5x5_pool_3x1_stride) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int features = 32; const int batches = 32; @@ -3300,7 +3288,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_32x32x20x20_input_5x5_pool_3x1_stride) auto input_data = generate_random_1d(batches * features * x_input * y_input, -10, 10); - auto input_prim = memory::allocate(engine, { data_types::f32,format::bfyx,input_tensor }); + auto input_prim = engine.allocate_memory({ data_types::f32,format::bfyx,input_tensor }); set_values(input_prim, input_data); std::vector golden_results; @@ -3309,8 +3297,8 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_32x32x20x20_input_5x5_pool_3x1_stride) { // golden topology topology golden_topology; - golden_topology.add(input_layout("input", input_prim.get_layout())); - golden_topology.add(reorder("reorder_input", "input", input_prim.get_layout())); + golden_topology.add(input_layout("input", input_prim->get_layout())); + golden_topology.add(reorder("reorder_input", "input", input_prim->get_layout())); golden_topology.add(pooling("golden_pooling", "reorder_input", pooling_mode::max, {1, 1, pool_size, pool_size}, {1, 1, stride_size_x, stride_size_y}, {0, 0, -x_in_pad, -y_in_pad})); @@ -3318,7 +3306,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_32x32x20x20_input_5x5_pool_3x1_stride) golden_network.set_input_data("input", input_prim); auto outputs = golden_network.execute(); - auto output_ptr = outputs.begin()->second.get_memory().pointer(); + cldnn::mem_lock output_ptr(outputs.begin()->second.get_memory(), get_test_stream()); for (size_t i = 0; i < output_ptr.size(); i++) { @@ -3329,7 +3317,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_32x32x20x20_input_5x5_pool_3x1_stride) { // bs_fs_yx_bsv16_fsv16 topology topology tested_topology; - tested_topology.add(input_layout("input", input_prim.get_layout())); + tested_topology.add(input_layout("input", input_prim->get_layout())); tested_topology.add(reorder("reorder_input", "input", layout(data_types::f32, format::bs_fs_yx_bsv16_fsv16, input_tensor))); tested_topology.add( @@ -3343,9 +3331,9 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_32x32x20x20_input_5x5_pool_3x1_stride) bsv16_fsv16_network.set_input_data("input", input_prim); auto outputs = bsv16_fsv16_network.execute(); - auto output_ptr = outputs.at("reorder_pooling").get_memory().pointer(); + cldnn::mem_lock output_ptr(outputs.at("reorder_pooling").get_memory(), get_test_stream()); - ASSERT_EQ(outputs.at("bsv16_fsv16_pooling").get_memory().get_layout().format, format::bs_fs_yx_bsv16_fsv16); + ASSERT_EQ(outputs.at("bsv16_fsv16_pooling").get_memory()->get_layout().format, format::bs_fs_yx_bsv16_fsv16); for (size_t i = 0; i < output_ptr.size(); i++) { @@ -3368,7 +3356,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_32x32x20x20_input_5x5_pool_3x1_stride) TEST(pooling_forward_gpu, bsv16_fsv16_max_32x16x20x20_input_5x5_pool_3x1_stride) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int features = 16; const int batches = 32; @@ -3389,7 +3377,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_32x16x20x20_input_5x5_pool_3x1_stride) input_data[i] = static_cast(i); } - auto input_prim = memory::allocate(engine, { data_types::f32,format::bfyx,input_tensor }); + auto input_prim = engine.allocate_memory({ data_types::f32,format::bfyx,input_tensor }); set_values(input_prim, input_data); std::vector golden_results; @@ -3398,8 +3386,8 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_32x16x20x20_input_5x5_pool_3x1_stride) { // golden topology topology golden_topology; - golden_topology.add(input_layout("input", input_prim.get_layout())); - golden_topology.add(reorder("reorder_input", "input", input_prim.get_layout())); + golden_topology.add(input_layout("input", input_prim->get_layout())); + golden_topology.add(reorder("reorder_input", "input", input_prim->get_layout())); golden_topology.add(pooling("golden_pooling", "reorder_input", pooling_mode::max, {1, 1, pool_size, pool_size}, {1, 1, stride_size_x, stride_size_y}, {0, 0, -x_in_pad, -y_in_pad})); @@ -3407,7 +3395,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_32x16x20x20_input_5x5_pool_3x1_stride) golden_network.set_input_data("input", input_prim); auto outputs = golden_network.execute(); - auto output_ptr = outputs.begin()->second.get_memory().pointer(); + cldnn::mem_lock output_ptr(outputs.begin()->second.get_memory(), get_test_stream()); for (size_t i = 0; i < output_ptr.size(); i++) { @@ -3418,7 +3406,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_32x16x20x20_input_5x5_pool_3x1_stride) { // bs_fs_yx_bsv16_fsv16 topology topology tested_topology; - tested_topology.add(input_layout("input", input_prim.get_layout())); + tested_topology.add(input_layout("input", input_prim->get_layout())); tested_topology.add(reorder("reorder_input", "input", layout(data_types::f32, format::bs_fs_yx_bsv16_fsv16, input_tensor))); tested_topology.add( @@ -3432,9 +3420,9 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_32x16x20x20_input_5x5_pool_3x1_stride) bsv16_fsv16_network.set_input_data("input", input_prim); auto outputs = bsv16_fsv16_network.execute(); - auto output_ptr = outputs.at("reorder_pooling").get_memory().pointer(); + cldnn::mem_lock output_ptr(outputs.at("reorder_pooling").get_memory(), get_test_stream()); - ASSERT_EQ(outputs.at("bsv16_fsv16_pooling").get_memory().get_layout().format, format::bs_fs_yx_bsv16_fsv16); + ASSERT_EQ(outputs.at("bsv16_fsv16_pooling").get_memory()->get_layout().format, format::bs_fs_yx_bsv16_fsv16); for (size_t i = 0; i < output_ptr.size(); i++) { @@ -3521,7 +3509,7 @@ class pooling_test : public tests::generic_test return false; } - virtual void prepare_input_for_test(std::vector& inputs) + virtual void prepare_input_for_test(std::vector& inputs) { if (generic_params->data_type == data_types::f32) { @@ -3534,13 +3522,13 @@ class pooling_test : public tests::generic_test } template - void prepare_input_for_test_typed(std::vector& inputs) + void prepare_input_for_test_typed(std::vector& inputs) { int k = (generic_params->data_type == data_types::f32) ? 8 : 4; auto input = inputs[0]; - auto input_size = inputs[0].get_layout().size; + auto input_size = inputs[0]->get_layout().size; VVVVF input_rnd = generate_random_4d(input_size.batch[0], input_size.feature[0], input_size.spatial[1], input_size.spatial[0], -10, 10, k); - VF input_rnd_vec = flatten_4d(input.get_layout().format, input_rnd); + VF input_rnd_vec = flatten_4d(input->get_layout().format, input_rnd); set_values(input, input_rnd_vec); } @@ -3579,14 +3567,13 @@ class pooling_test : public tests::generic_test } template - memory generate_reference_typed(const std::vector& inputs) - { + memory::ptr generate_reference_typed(const std::vector& inputs) { auto pooling = std::static_pointer_cast(layer_params); - int batch = inputs[0].get_layout().size.batch[0]; - int feature = inputs[0].get_layout().size.feature[0]; - int height = inputs[0].get_layout().size.spatial[1]; - int width = inputs[0].get_layout().size.spatial[0]; + int batch = inputs[0]->get_layout().size.batch[0]; + int feature = inputs[0]->get_layout().size.feature[0]; + int height = inputs[0]->get_layout().size.spatial[1]; + int width = inputs[0]->get_layout().size.spatial[0]; cldnn::pooling_mode pooling_mode = pooling->mode; @@ -3605,22 +3592,22 @@ class pooling_test : public tests::generic_test int pooled_height = output_tensor.spatial[1]; //Output is bfyx - auto output = memory::allocate(engine, cldnn::layout(inputs[0].get_layout().data_type, cldnn::format::bfyx, output_tensor, pooling->output_padding)); + auto output = engine.allocate_memory(cldnn::layout(inputs[0]->get_layout().data_type, cldnn::format::bfyx, output_tensor, pooling->output_padding)); - auto input_mem = inputs[0].pointer(); - auto output_mem = output.pointer(); + cldnn::mem_lock input_mem(inputs[0], get_test_stream()); + cldnn::mem_lock output_mem(output, get_test_stream()); - int output_width = output.get_layout().get_buffer_size().spatial[0]; - int output_height = output.get_layout().get_buffer_size().spatial[1]; + int output_width = output->get_layout().get_buffer_size().spatial[0]; + int output_height = output->get_layout().get_buffer_size().spatial[1]; - const auto input_desc = get_linear_memory_desc(inputs[0].get_layout()); - const auto output_desc = get_linear_memory_desc(output.get_layout()); + const auto input_desc = get_linear_memory_desc(inputs[0]->get_layout()); + const auto output_desc = get_linear_memory_desc(output->get_layout()); switch (pooling_mode) { case cldnn::pooling_mode::max: { - for (int i = 0; i < (int)output.get_layout().get_buffer_size().count(); i++) + for (int i = 0; i < (int)output->get_layout().get_buffer_size().count(); i++) { output_mem[i] = (generic_params->data_type == data_types::f32) ? -FLT_MAX : -65504; } @@ -3640,13 +3627,13 @@ class pooling_test : public tests::generic_test int input_offset_y_end = std::min(input_offset_y_start + kernel_height, height); input_offset_y_start = std::max(input_offset_y_start, 0); - const size_t output_index = get_linear_index(output.get_layout(), b, f, h, w, output_desc); + const size_t output_index = get_linear_index(output->get_layout(), b, f, h, w, output_desc); for (int y = input_offset_y_start; y < input_offset_y_end; y++) { for (int x = input_offset_x_start; x < input_offset_x_end; x++) { - const size_t input_index = get_linear_index(inputs[0].get_layout(), b, f, y, x, input_desc); + const size_t input_index = get_linear_index(inputs[0]->get_layout(), b, f, y, x, input_desc); if (input_mem[input_index] > output_mem[output_index]) { @@ -3683,7 +3670,7 @@ class pooling_test : public tests::generic_test return y*x; }; - for (int i = 0; i < (int)output.get_layout().get_buffer_size().count(); i++) + for (int i = 0; i < (int)output->get_layout().get_buffer_size().count(); i++) { output_mem[i] = 0; } @@ -3712,7 +3699,7 @@ class pooling_test : public tests::generic_test { for (int x = input_offset_x_start; x < input_offset_x_end; x++) { - const size_t input_index = get_linear_index(inputs[0].get_layout(), b, f, y, x, input_desc); + const size_t input_index = get_linear_index(inputs[0]->get_layout(), b, f, y, x, input_desc); output_mem[output_index] += input_mem[input_index]; if (!dynamic_mode || pooling_mode == cldnn::pooling_mode::average_no_padding) { @@ -3746,7 +3733,7 @@ class pooling_test : public tests::generic_test return output; } - virtual memory generate_reference(const std::vector& inputs) + virtual memory::ptr generate_reference(const std::vector& inputs) { if (generic_params->data_type == data_types::f32) { diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/propagate_constants_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/propagate_constants_gpu_test.cpp index 264eb954d3936c..3425bfd427c773 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/propagate_constants_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/propagate_constants_gpu_test.cpp @@ -2,40 +2,34 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#include -#include "api/memory.hpp" -#include -#include -#include -#include -#include "test_utils/test_utils.h" -#include -#include -#include -#include +#include "test_utils.h" + +#include +#include +#include +#include +#include using namespace cldnn; -using namespace tests; +using namespace ::tests; //We expect additional reorder to be added in between "weights1" and "reshape1". //This situation should be handled properly by propagate constants optimization phase TEST(propagate_constants, copy_dependecies_from_nodes) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); build_options build_opt; build_opt.set_option(build_option::optimize_data(true)); - auto input = memory::allocate(engine, { data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); - auto weights1 = memory::allocate(engine, { data_types::f16, format::yxfb,{ 1, 1, 2, 1 } }); - auto weights2 = memory::allocate(engine, { data_types::f32, format::byxf,{ 1, 1, 1, 2 } }); + auto input = engine.allocate_memory({ data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); + auto weights1 = engine.allocate_memory({ data_types::f16, format::yxfb,{ 1, 1, 2, 1 } }); + auto weights2 = engine.allocate_memory({ data_types::f32, format::byxf,{ 1, 1, 1, 2 } }); set_values(input, { FLOAT16(1.1f), FLOAT16(1.2f), FLOAT16(1.3f), FLOAT16(1.4f) }); set_values(weights1, { FLOAT16(2.1f), FLOAT16(3.1f) }); set_values(weights2, { 1.1f, 0.1f }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("weights1", weights1)); topology.add(data("weights2", weights2)); topology.add(reshape("reshape1", "weights1", tensor(spatial(1, 2)))); @@ -49,9 +43,8 @@ TEST(propagate_constants, copy_dependecies_from_nodes) { auto outputs = network.execute(); float epsilon = 1e-2f; - for (auto& it : outputs) - { - auto output = it.second.get_memory().pointer(); + for (auto& it : outputs) { + cldnn::mem_lock output(it.second.get_memory(), get_test_stream()); EXPECT_NEAR(7.8f, output[0], epsilon); } -} \ No newline at end of file +} diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/proposal_cpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/proposal_cpu_test.cpp index 7cbec32a861bfb..a7ea1040828e28 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/proposal_cpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/proposal_cpu_test.cpp @@ -2,18 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include +#include "test_utils.h" + +#include +#include -#include -#include "api/memory.hpp" -#include -#include -#include -#include -#include -#include "test_utils/test_utils.h" -#include "test_utils/float16.h" +#include namespace cldnn { @@ -21,7 +15,7 @@ template<> struct type_to_data_type { static const data_types value = d } using namespace cldnn; -using namespace tests; +using namespace ::tests; using namespace std; extern float cls_scores_data[]; @@ -65,11 +59,10 @@ class TestRunnerProposal public: explicit TestRunnerProposal(cldnn::tensor image_info_size); - memory Run(std::vector& data, - std::vector& rois); + memory::ptr Run(std::vector& data, + std::vector& rois); private: - engine _engine; layout _cls_scores_layout; layout _bbox_pred_layout; layout _image_info_layout; @@ -103,20 +96,21 @@ TestRunnerProposal::TestRunnerProposal(cldnn::tensor image_in _topology.add(_test_layer); - _network.reset(new network(_engine, _topology)); + _network.reset(new network(get_test_engine(), _topology)); } template -memory TestRunnerProposal::Run(std::vector& cls_scores_vals, - std::vector& bbox_pred_vals) +memory::ptr TestRunnerProposal::Run(std::vector& cls_scores_vals, + std::vector& bbox_pred_vals) { - memory cls_scores = memory::attach(_cls_scores_layout, cls_scores_vals.data(), cls_scores_vals.size()); - memory bbox_pred = memory::attach(_bbox_pred_layout, bbox_pred_vals.data(), bbox_pred_vals.size()); + auto& engine = get_test_engine(); + memory::ptr cls_scores = engine.attach_memory(_cls_scores_layout, cls_scores_vals.data()); + memory::ptr bbox_pred = engine.attach_memory(_bbox_pred_layout, bbox_pred_vals.data()); std::vector image_info_vals = { (ImInfoType)((float)image_h - 0.0000001f), // check fp robustness of the layer (ImInfoType)((float)image_w + 0.0000001f), // check fp robustness of the layer (ImInfoType)((float)image_z) }; - memory image_info = memory::allocate(_engine, _image_info_layout); + memory::ptr image_info = engine.allocate_memory(_image_info_layout); tests::set_values(image_info, image_info_vals); _network->set_input_data(cls_scores_name, cls_scores); @@ -134,10 +128,10 @@ TEST(proposal, basic) { TestRunnerProposal t({ 1, 3, 1, 1 }); - const memory& output = t.Run(cls_scores, bbox_pred); - ASSERT_EQ(output.get_layout().count(), proposal_ref_size); + memory::ptr output = t.Run(cls_scores, bbox_pred); + ASSERT_EQ(output->get_layout().count(), proposal_ref_size); - auto f = output.pointer(); + cldnn::mem_lock f(output, get_test_stream()); for (size_t i = 0; i < proposal_ref_size; i++) { EXPECT_NEAR(f[i], proposal_ref[i], epsilon); @@ -150,10 +144,10 @@ TEST(proposal, fp16) { TestRunnerProposal t({ 1, 3, 1, 1 }); - const memory& output = t.Run(cls_scores, bbox_pred); - ASSERT_EQ(output.get_layout().count(), proposal_ref_size); + memory::ptr output = t.Run(cls_scores, bbox_pred); + ASSERT_EQ(output->get_layout().count(), proposal_ref_size); - auto d = output.pointer(); + cldnn::mem_lock d(output, get_test_stream()); for (size_t i = 0; i < proposal_ref_size; i++) { FLOAT16 ref(proposal_ref[i]); @@ -167,10 +161,10 @@ TEST(proposal, scores_fp16_im_info_fp32) { TestRunnerProposal t({ 1, 3, 1, 1 }); - const memory& output = t.Run(cls_scores, bbox_pred); - ASSERT_EQ(output.get_layout().count(), proposal_ref_size); + memory::ptr output = t.Run(cls_scores, bbox_pred); + ASSERT_EQ(output->get_layout().count(), proposal_ref_size); - auto d = output.pointer(); + cldnn::mem_lock d(output, get_test_stream()); for (size_t i = 0; i < proposal_ref_size; i++) { FLOAT16 ref(proposal_ref[i]); @@ -184,10 +178,10 @@ TEST(proposal, scores_fp32_im_info_fp16) { TestRunnerProposal t({ 1, 3, 1, 1 }); - const memory& output = t.Run(cls_scores, bbox_pred); - ASSERT_EQ(output.get_layout().count(), proposal_ref_size); + memory::ptr output = t.Run(cls_scores, bbox_pred); + ASSERT_EQ(output->get_layout().count(), proposal_ref_size); - auto d = output.pointer(); + cldnn::mem_lock d(output, get_test_stream()); for (size_t i = 0; i < proposal_ref_size; i++) { float ref(proposal_ref[i]); @@ -201,10 +195,10 @@ TEST(proposal, img_info_batched) { TestRunnerProposal t({ 2, 3, 1, 1 }); - const memory& output = t.Run(cls_scores, bbox_pred); - ASSERT_EQ(output.get_layout().count(), proposal_ref_size); + memory::ptr output = t.Run(cls_scores, bbox_pred); + ASSERT_EQ(output->get_layout().count(), proposal_ref_size); - auto f = output.pointer(); + cldnn::mem_lock f(output, get_test_stream()); for (size_t i = 0; i < proposal_ref_size; i++) { EXPECT_NEAR(f[i], proposal_ref[i], epsilon); @@ -217,10 +211,10 @@ TEST(proposal, img_info_batch_only) { TestRunnerProposal t({ 3, 1, 1, 1 }); - const memory& output = t.Run(cls_scores, bbox_pred); - ASSERT_EQ(output.get_layout().count(), proposal_ref_size); + memory::ptr output = t.Run(cls_scores, bbox_pred); + ASSERT_EQ(output->get_layout().count(), proposal_ref_size); - auto f = output.pointer(); + cldnn::mem_lock f(output, get_test_stream()); for (size_t i = 0; i < proposal_ref_size; i++) { EXPECT_NEAR(f[i], proposal_ref[i], epsilon); diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/pyramid_roi_align_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/pyramid_roi_align_gpu_test.cpp index 58afd3089287c8..a4e168ee9a018c 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/pyramid_roi_align_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/pyramid_roi_align_gpu_test.cpp @@ -3,21 +3,15 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "test_utils.h" -#include "test_utils/test_utils.h" +#include +#include +#include using namespace cldnn; -using namespace tests; +using namespace ::tests; template struct pyramid_roi_align_typed_test : testing::Test { @@ -31,7 +25,7 @@ TYPED_TEST_CASE(pyramid_roi_align_typed_test, pyramid_roi_align_types); TYPED_TEST(pyramid_roi_align_typed_test, smoke_4levels) { using Type = typename pyramid_roi_align_typed_test::Type; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int rois_num = 3; const int output_size = 2; @@ -85,11 +79,11 @@ TYPED_TEST(pyramid_roi_align_typed_test, smoke_4levels) { auto P4_lay = layout(this->data_type, format::bfyx, tensor(1, 1, P4_size, P4_size)); auto P5_lay = layout(this->data_type, format::bfyx, tensor(1, 1, P5_size, P5_size)); - auto rois_mem = memory::allocate(engine, rois_lay); - auto P2_mem = memory::allocate(engine, P2_lay); - auto P3_mem = memory::allocate(engine, P3_lay); - auto P4_mem = memory::allocate(engine, P4_lay); - auto P5_mem = memory::allocate(engine, P5_lay); + auto rois_mem = engine.allocate_memory(rois_lay); + auto P2_mem = engine.allocate_memory(P2_lay); + auto P3_mem = engine.allocate_memory(P3_lay); + auto P4_mem = engine.allocate_memory(P4_lay); + auto P5_mem = engine.allocate_memory(P5_lay); tests::set_values(rois_mem, rois_data); tests::set_values(P2_mem, P2_data); @@ -129,7 +123,7 @@ TYPED_TEST(pyramid_roi_align_typed_test, smoke_4levels) { auto result = net.execute(); auto out_mem = result.at("pyramid").get_memory(); - auto out_ptr = out_mem.pointer(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); ASSERT_EQ(expected_out.size(), out_ptr.size()); for (size_t i = 0; i < expected_out.size(); ++i) { diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/quantize_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/quantize_gpu_test.cpp index 1d0dfaa4beb219..f5090ab08ff1c0 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/quantize_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/quantize_gpu_test.cpp @@ -3,31 +3,25 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include -#include -#include -#include +#include "test_utils.h" -#include "test_utils/test_utils.h" +#include +#include +#include #include -#include -#include using namespace cldnn; using namespace ::tests; TEST(quantize_gpu, quantize_levels_2_output_broadcast_inputs_1) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {1, 16, 2, 2}}); - auto input_low = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 16, 1, 1 } }); - auto input_high = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 16, 1, 1 } }); - auto output_low = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); - auto output_high = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {1, 16, 2, 2}}); + auto input_low = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 16, 1, 1 } }); + auto input_high = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 16, 1, 1 } }); + auto output_low = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); + auto output_high = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); set_values(input, { -1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 2.0f, 2.0f, 3.0f, @@ -83,7 +77,7 @@ TEST(quantize_gpu, quantize_levels_2_output_broadcast_inputs_1) { topology topology; topology.add( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("input_low", input_low), data("input_high", input_high), data("output_low", output_low), @@ -96,13 +90,13 @@ TEST(quantize_gpu, quantize_levels_2_output_broadcast_inputs_1) { auto outputs = network.execute(); auto output = outputs.at("quantize").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); // Check that layout and memory contains logical size of tensor - ASSERT_EQ(output.count(), (size_t)64); - ASSERT_EQ(output.get_layout().count(), (size_t)64); + ASSERT_EQ(output->count(), (size_t)64); + ASSERT_EQ(output->get_layout().count(), (size_t)64); - ASSERT_EQ(output.size(), ref_data.size() * sizeof(uint32_t)); + ASSERT_EQ(output->size(), ref_data.size() * sizeof(uint32_t)); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_EQ(output_ptr[i], ref_data[i]) << " index = " << i; @@ -110,11 +104,11 @@ TEST(quantize_gpu, quantize_levels_2_output_broadcast_inputs_1) { } TEST(quantize_gpu, quantize_levels_2_output_broadcast_inputs_1_ch8) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {1, 8, 2, 2}}); - auto input_thresh = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 8, 1, 1 } }); - auto output_low = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); - auto output_high = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {1, 8, 2, 2}}); + auto input_thresh = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 8, 1, 1 } }); + auto output_low = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); + auto output_high = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); set_values(input, { -1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 2.0f, 2.0f, 3.0f, @@ -147,7 +141,7 @@ TEST(quantize_gpu, quantize_levels_2_output_broadcast_inputs_1_ch8) { topology topology; topology.add( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("input_low", input_thresh), data("input_high", input_thresh), data("output_low", output_low), @@ -160,13 +154,13 @@ TEST(quantize_gpu, quantize_levels_2_output_broadcast_inputs_1_ch8) { auto outputs = network.execute(); auto output = outputs.at("quantize").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); // Check that layout and memory contains logical size of tensor - ASSERT_EQ(output.count(), (size_t)32); - ASSERT_EQ(output.get_layout().count(), (size_t)32); + ASSERT_EQ(output->count(), (size_t)32); + ASSERT_EQ(output->get_layout().count(), (size_t)32); - ASSERT_EQ(output.size(), ref_data.size() * sizeof(uint32_t)); + ASSERT_EQ(output->size(), ref_data.size() * sizeof(uint32_t)); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_EQ(output_ptr[i], ref_data[i]) << " index = " << i; @@ -174,11 +168,11 @@ TEST(quantize_gpu, quantize_levels_2_output_broadcast_inputs_1_ch8) { } TEST(quantize_gpu, quantize_levels_2_output_broadcast_inputs_1_ch8_binary_pack) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {1, 8, 2, 2}}); - auto input_thresh = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 8, 1, 1 } }); - auto output_low = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); - auto output_high = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {1, 8, 2, 2}}); + auto input_thresh = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 8, 1, 1 } }); + auto output_low = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); + auto output_high = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); set_values(input, { -1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 2.0f, 2.0f, 3.0f, @@ -210,7 +204,7 @@ TEST(quantize_gpu, quantize_levels_2_output_broadcast_inputs_1_ch8_binary_pack) topology topology; topology.add( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("input_low", input_thresh), data("input_high", input_thresh), data("output_low", output_low), @@ -226,13 +220,13 @@ TEST(quantize_gpu, quantize_levels_2_output_broadcast_inputs_1_ch8_binary_pack) auto outputs = network.execute(); auto output = outputs.at("reorder").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); // Check that layout and memory contains logical size of tensor - ASSERT_EQ(output.count(), (size_t)32); - ASSERT_EQ(output.get_layout().count(), (size_t)32); + ASSERT_EQ(output->count(), (size_t)32); + ASSERT_EQ(output->get_layout().count(), (size_t)32); - ASSERT_EQ(output.size(), ref_data.size() * sizeof(uint32_t)); + ASSERT_EQ(output->size(), ref_data.size() * sizeof(uint32_t)); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_EQ(output_ptr[i], ref_data[i]) << " index = " << i; @@ -240,12 +234,12 @@ TEST(quantize_gpu, quantize_levels_2_output_broadcast_inputs_1_ch8_binary_pack) } TEST(quantize_gpu, quantize_levels_2_output_broadcast_inputs_2) { - const cldnn::engine& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {1, 16, 2, 2}}); - auto input_low = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); - auto input_high = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); - auto output_low = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); - auto output_high = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); + cldnn::engine& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {1, 16, 2, 2}}); + auto input_low = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); + auto input_high = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); + auto output_low = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); + auto output_high = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); set_values(input, { -1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 2.0f, 2.0f, 3.0f, @@ -291,7 +285,7 @@ TEST(quantize_gpu, quantize_levels_2_output_broadcast_inputs_2) { topology topology; topology.add( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("input_low", input_low), data("input_high", input_high), data("output_low", output_low), @@ -304,13 +298,13 @@ TEST(quantize_gpu, quantize_levels_2_output_broadcast_inputs_2) { auto outputs = network.execute(); auto output = outputs.at("quantize").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); // Check that layout and memory contains logical size of tensor - ASSERT_EQ(output.count(), (size_t)64); - ASSERT_EQ(output.get_layout().count(), (size_t)64); + ASSERT_EQ(output->count(), (size_t)64); + ASSERT_EQ(output->get_layout().count(), (size_t)64); - ASSERT_EQ(output.size(), ref_data.size() * sizeof(float)); + ASSERT_EQ(output->size(), ref_data.size() * sizeof(float)); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_EQ(output_ptr[i], ref_data[i]) << " index = " << i; @@ -318,12 +312,12 @@ TEST(quantize_gpu, quantize_levels_2_output_broadcast_inputs_2) { } TEST(quantize_gpu, quantize_levels_3) { - const cldnn::engine& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {1, 16, 2, 2}}); - auto input_low = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 16, 1, 1 } }); - auto input_high = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 16, 1, 1 } }); - auto output_low = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); - auto output_high = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); + cldnn::engine& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {1, 16, 2, 2}}); + auto input_low = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 16, 1, 1 } }); + auto input_high = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 16, 1, 1 } }); + auto output_low = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); + auto output_high = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); set_values(input, { -1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 2.0f, 2.0f, 3.0f, @@ -380,7 +374,7 @@ TEST(quantize_gpu, quantize_levels_3) { topology topology; topology.add( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("input_low", input_low), data("input_high", input_high), data("output_low", output_low), @@ -393,14 +387,14 @@ TEST(quantize_gpu, quantize_levels_3) { auto outputs = network.execute(); auto output = outputs.at("quantize").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); // Check that layout and memory contains logical size of tensor - ASSERT_EQ(output.count(), ref_data.size()); - ASSERT_EQ(output.get_layout().count(), ref_data.size()); + ASSERT_EQ(output->count(), ref_data.size()); + ASSERT_EQ(output->get_layout().count(), ref_data.size()); // Check that memory physical size consider binary pack - ASSERT_EQ(output.size(), ref_data.size() * sizeof(float)); + ASSERT_EQ(output->size(), ref_data.size() * sizeof(float)); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_EQ(output_ptr[i], ref_data[i]) << " i=" << i; @@ -408,12 +402,12 @@ TEST(quantize_gpu, quantize_levels_3) { } TEST(quantize_gpu, quantize_levels_256_2d_unsigned) { - const cldnn::engine& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {1, 16, 2, 2}}); - auto input_low = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 16, 1, 1 } }); - auto input_high = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 16, 1, 1 } }); - auto output_low = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); - auto output_high = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); + cldnn::engine& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {1, 16, 2, 2}}); + auto input_low = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 16, 1, 1 } }); + auto input_high = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 16, 1, 1 } }); + auto output_low = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); + auto output_high = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); set_values(input, { -1.0f, 2.1f, 3.0f, 4.0f, 5.0f, 2.0f, 2.0f, 3.0f, @@ -471,7 +465,7 @@ TEST(quantize_gpu, quantize_levels_256_2d_unsigned) { topology topology; topology.add( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("input_low", input_low), data("input_high", input_high), data("output_low", output_low), @@ -484,14 +478,14 @@ TEST(quantize_gpu, quantize_levels_256_2d_unsigned) { auto outputs = network.execute(); auto output = outputs.at("quantize").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); // Check that layout and memory contains logical size of tensor - ASSERT_EQ(output.count(), ref_data.size()); - ASSERT_EQ(output.get_layout().count(), ref_data.size()); + ASSERT_EQ(output->count(), ref_data.size()); + ASSERT_EQ(output->get_layout().count(), ref_data.size()); // Check that memory physical size consider binary pack - ASSERT_EQ(output.size(), ref_data.size() * sizeof(uint8_t)); + ASSERT_EQ(output->size(), ref_data.size() * sizeof(uint8_t)); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_EQ(output_ptr[i], ref_data[i]) << " i=" << i; @@ -499,12 +493,12 @@ TEST(quantize_gpu, quantize_levels_256_2d_unsigned) { } TEST(quantize_gpu, quantize_levels_256_3d_unsigned) { - const cldnn::engine& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfzyx, {1, 16, 2, 1, 2}}); - auto input_low = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 16, 1, 1 } }); - auto input_high = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 16, 1, 1 } }); - auto output_low = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); - auto output_high = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); + cldnn::engine& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfzyx, {1, 16, 2, 1, 2}}); + auto input_low = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 16, 1, 1 } }); + auto input_high = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 16, 1, 1 } }); + auto output_low = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); + auto output_high = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 1, 1, 1 } }); set_values(input, { -1.0f, 2.1f, 3.0f, 4.0f, 5.0f, 2.0f, 2.0f, 3.0f, @@ -562,7 +556,7 @@ TEST(quantize_gpu, quantize_levels_256_3d_unsigned) { topology topology; topology.add( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("input_low", input_low), data("input_high", input_high), data("output_low", output_low), @@ -576,14 +570,14 @@ TEST(quantize_gpu, quantize_levels_256_3d_unsigned) { auto outputs = network.execute(); auto output = outputs.at("out").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); // Check that layout and memory contains logical size of tensor - ASSERT_EQ(output.count(), ref_data.size()); - ASSERT_EQ(output.get_layout().count(), ref_data.size()); + ASSERT_EQ(output->count(), ref_data.size()); + ASSERT_EQ(output->get_layout().count(), ref_data.size()); // Check that memory physical size consider binary pack - ASSERT_EQ(output.size(), ref_data.size() * sizeof(uint8_t)); + ASSERT_EQ(output->size(), ref_data.size() * sizeof(uint8_t)); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_EQ(output_ptr[i], ref_data[i]) << " i=" << i; diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/reduce_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/reduce_gpu_test.cpp index f1b906058ab249..77a3e06d40c1dc 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/reduce_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/reduce_gpu_test.cpp @@ -2,20 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include "api/reduce.hpp" -#include -#include -#include -#include "test_utils/test_utils.h" -#include -#include "test_utils/float16.h" +#include "test_utils.h" + +#include +#include +#include + #include #include using namespace cldnn; -using namespace tests; +using namespace ::tests; template struct accumulator_type { @@ -432,7 +429,7 @@ struct output_data_type { template class ReduceTestBase : public ::testing::TestWithParam { protected: - cldnn::engine engine = get_test_engine(); + cldnn::engine& engine = get_test_engine(); int batch_num, input_f, input_w, input_z, input_y, input_x; cldnn::format input_format = format::any; cldnn::reduce_mode reduce_mode; @@ -480,10 +477,10 @@ class ReduceTestBase : public ::testing::TestWithParam(batch_num, input_f, input_x, input_y, input_z, input_w, 1, 10); auto input_lay = layout(input_dt, layout_format, input_size); - auto input_mem = memory::allocate(engine, input_lay); + auto input_mem = engine.allocate_memory(input_lay); { - auto input_ptr = input_mem.pointer(); + cldnn::mem_lock input_ptr(input_mem, get_test_stream()); for (int fi = 0; fi < input_f; fi++) for (int wi = 0; wi < input_w; wi++) for (int zi = 0; zi < input_z; zi++) @@ -505,7 +502,7 @@ class ReduceTestBase : public ::testing::TestWithParamget_layout())); topology.add(red); build_options options; options.set_option(build_option::optimize_data(true)); @@ -517,8 +514,8 @@ class ReduceTestBase : public ::testing::TestWithParam(); - auto out_lay = out_mem.get_layout(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); + auto out_lay = out_mem->get_layout(); ASSERT_EQ(out_lay.size.sizes()[0], reference_result.size()); // b ASSERT_EQ(out_lay.size.sizes()[1], reference_result[0].size()); // f @@ -543,11 +540,11 @@ class ReduceTestBase : public ::testing::TestWithParamget_layout())); topology.add(reduce("reduce", "input", reduce_mode::sum, {cldnn::reduce::along_b}, 0)); network network(engine, topology); @@ -774,7 +771,7 @@ TEST(reduce_gpu, common_bfyx) { std::vector ref_data = {1.0f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -782,13 +779,13 @@ TEST(reduce_gpu, common_bfyx) { } TEST(reduce_gpu, common_bfyx_keepdims) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {1, 3, 4, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {1, 3, 4, 1}}); set_values(input, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::sum, {cldnn::reduce::along_x, cldnn::reduce::along_y}, 1)); network network(engine, topology); @@ -804,7 +801,7 @@ TEST(reduce_gpu, common_bfyx_keepdims) { std::vector ref_data = {6.0f, 22.0f, 38.0f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -812,13 +809,13 @@ TEST(reduce_gpu, common_bfyx_keepdims) { } TEST(reduce_gpu, regr_bfyx_keepdims) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, {1, 3, 2, 2} }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, {1, 3, 2, 2} }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::sum, { cldnn::reduce::along_b, cldnn::reduce::along_x }, 1)); network network(engine, topology); @@ -834,7 +831,7 @@ TEST(reduce_gpu, regr_bfyx_keepdims) { std::vector ref_data = { 1.0f, 5.0f, 9.0f, 13.0f, 17.0f, 21.0f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -842,13 +839,13 @@ TEST(reduce_gpu, regr_bfyx_keepdims) { } TEST(reduce_gpu, common_bfzyx) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfzyx, {1, 1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfzyx, {1, 1, 1, 1, 1}}); set_values(input, {1.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::sum, {cldnn::reduce::along_b}, 0)); network network(engine, topology); @@ -864,7 +861,7 @@ TEST(reduce_gpu, common_bfzyx) { std::vector ref_data = {1.0f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -872,13 +869,13 @@ TEST(reduce_gpu, common_bfzyx) { } TEST(reduce_gpu, common_bfzyx_keepdims) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfzyx, {1, 1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfzyx, {1, 1, 1, 1, 1}}); set_values(input, {1.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::sum, {cldnn::reduce::along_b}, 1)); network network(engine, topology); @@ -894,7 +891,7 @@ TEST(reduce_gpu, common_bfzyx_keepdims) { std::vector ref_data = {1.0f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -902,13 +899,13 @@ TEST(reduce_gpu, common_bfzyx_keepdims) { } TEST(reduce_gpu, common_bfwzyx) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, tensor(format::bfwzyx, {1, 3, 4, 1, 1, 1})}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, tensor(format::bfwzyx, {1, 3, 4, 1, 1, 1})}); set_values(input, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::sum, {cldnn::reduce::along_w, cldnn::reduce::along_z, cldnn::reduce::along_y, cldnn::reduce::along_x}, 0)); network network(engine, topology); @@ -924,7 +921,7 @@ TEST(reduce_gpu, common_bfwzyx) { std::vector ref_data = {6.0f, 22.0f, 38.0f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -932,13 +929,13 @@ TEST(reduce_gpu, common_bfwzyx) { } TEST(reduce_gpu, common_bfwzyx_keepdims) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, tensor(format::bfwzyx, {1, 3, 4, 1, 1, 1})}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, tensor(format::bfwzyx, {1, 3, 4, 1, 1, 1})}); set_values(input, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::sum, {cldnn::reduce::along_f, cldnn::reduce::along_w, cldnn::reduce::along_z}, 1)); network network(engine, topology); @@ -954,7 +951,7 @@ TEST(reduce_gpu, common_bfwzyx_keepdims) { std::vector ref_data = {66.0f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -962,14 +959,14 @@ TEST(reduce_gpu, common_bfwzyx_keepdims) { } TEST(reduce_gpu, common_bfwzyx_max_keepdims) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, {2, 3, 4, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, {2, 3, 4, 1, 1, 1}}); set_values(input, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::max, {cldnn::reduce::along_b, cldnn::reduce::along_f}, 1)); network network(engine, topology); @@ -985,7 +982,7 @@ TEST(reduce_gpu, common_bfwzyx_max_keepdims) { std::vector ref_data = {20.0f, 21.0f, 22.0f, 23.0f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -993,13 +990,13 @@ TEST(reduce_gpu, common_bfwzyx_max_keepdims) { } TEST(reduce_gpu, common_bfwzyx_min) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); set_values(input, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::min, {cldnn::reduce::along_f, cldnn::reduce::along_w}, 0)); network network(engine, topology); @@ -1015,7 +1012,7 @@ TEST(reduce_gpu, common_bfwzyx_min) { std::vector ref_data = {0.0f, 3.0f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -1023,13 +1020,13 @@ TEST(reduce_gpu, common_bfwzyx_min) { } TEST(reduce_gpu, common_bfwzyx_min_keepdims) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); set_values(input, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::min, {cldnn::reduce::along_f, cldnn::reduce::along_w}, 1)); network network(engine, topology); @@ -1045,7 +1042,7 @@ TEST(reduce_gpu, common_bfwzyx_min_keepdims) { std::vector ref_data = {0.0f, 3.0f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -1053,13 +1050,13 @@ TEST(reduce_gpu, common_bfwzyx_min_keepdims) { } TEST(reduce_gpu, common_bfwzyx_mean) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); set_values(input, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::mean, {cldnn::reduce::along_f, cldnn::reduce::along_w}, 0)); network network(engine, topology); @@ -1075,7 +1072,7 @@ TEST(reduce_gpu, common_bfwzyx_mean) { std::vector ref_data = {1.0f, 4.0f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -1083,13 +1080,13 @@ TEST(reduce_gpu, common_bfwzyx_mean) { } TEST(reduce_gpu, common_bfwzyx_mean_keepdims) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); set_values(input, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::mean, {cldnn::reduce::along_f, cldnn::reduce::along_w}, 1)); network network(engine, topology); @@ -1105,7 +1102,7 @@ TEST(reduce_gpu, common_bfwzyx_mean_keepdims) { std::vector ref_data = {1.0f, 4.0f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -1113,13 +1110,13 @@ TEST(reduce_gpu, common_bfwzyx_mean_keepdims) { } TEST(reduce_gpu, common_bfwzyx_prod) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); set_values(input, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::prod, {cldnn::reduce::along_f, cldnn::reduce::along_w}, 0)); network network(engine, topology); @@ -1135,7 +1132,7 @@ TEST(reduce_gpu, common_bfwzyx_prod) { std::vector ref_data = {0.0f, 60.0f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -1143,13 +1140,13 @@ TEST(reduce_gpu, common_bfwzyx_prod) { } TEST(reduce_gpu, common_bfwzyx_prod_keepdims) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); set_values(input, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::prod, {cldnn::reduce::along_f, cldnn::reduce::along_w}, 1)); network network(engine, topology); @@ -1165,7 +1162,7 @@ TEST(reduce_gpu, common_bfwzyx_prod_keepdims) { std::vector ref_data = {0.0f, 60.0f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -1173,14 +1170,14 @@ TEST(reduce_gpu, common_bfwzyx_prod_keepdims) { } TEST(reduce_gpu, common_bfwzyx_sum_keepdims) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, {2, 3, 4, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, {2, 3, 4, 1, 1, 1}}); set_values(input, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::sum, {cldnn::reduce::along_b, cldnn::reduce::along_f}, 1)); network network(engine, topology); @@ -1196,7 +1193,7 @@ TEST(reduce_gpu, common_bfwzyx_sum_keepdims) { std::vector ref_data = {60.0f, 66.0f, 72.0f, 78.0f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -1204,13 +1201,13 @@ TEST(reduce_gpu, common_bfwzyx_sum_keepdims) { } TEST(reduce_gpu, common_bfwzyx_logical_and) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); set_values(input, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::logical_and, {cldnn::reduce::along_f, cldnn::reduce::along_w}, 0)); network network(engine, topology); @@ -1226,7 +1223,7 @@ TEST(reduce_gpu, common_bfwzyx_logical_and) { std::vector ref_data = {0, 1}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -1234,13 +1231,13 @@ TEST(reduce_gpu, common_bfwzyx_logical_and) { } TEST(reduce_gpu, common_bfwzyx_logical_and_keepdims) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); set_values(input, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::logical_and, {cldnn::reduce::along_f, cldnn::reduce::along_w}, 1)); network network(engine, topology); @@ -1256,7 +1253,7 @@ TEST(reduce_gpu, common_bfwzyx_logical_and_keepdims) { std::vector ref_data = {0, 1}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -1264,13 +1261,13 @@ TEST(reduce_gpu, common_bfwzyx_logical_and_keepdims) { } TEST(reduce_gpu, common_bfwzyx_logical_or) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); set_values(input, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::logical_or, {cldnn::reduce::along_f, cldnn::reduce::along_w}, 0)); network network(engine, topology); @@ -1286,7 +1283,7 @@ TEST(reduce_gpu, common_bfwzyx_logical_or) { std::vector ref_data = {1, 1}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -1294,13 +1291,13 @@ TEST(reduce_gpu, common_bfwzyx_logical_or) { } TEST(reduce_gpu, common_bfwzyx_logical_or_keepdims) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); set_values(input, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::logical_or, {cldnn::reduce::along_f, cldnn::reduce::along_w}, 1)); network network(engine, topology); @@ -1316,7 +1313,7 @@ TEST(reduce_gpu, common_bfwzyx_logical_or_keepdims) { std::vector ref_data = {1, 1}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -1324,13 +1321,13 @@ TEST(reduce_gpu, common_bfwzyx_logical_or_keepdims) { } TEST(reduce_gpu, common_bfwzyx_sum_square) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); set_values(input, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::sum_square, {cldnn::reduce::along_f, cldnn::reduce::along_w}, 0)); network network(engine, topology); @@ -1346,7 +1343,7 @@ TEST(reduce_gpu, common_bfwzyx_sum_square) { std::vector ref_data = {5.0f, 50.0f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -1354,13 +1351,13 @@ TEST(reduce_gpu, common_bfwzyx_sum_square) { } TEST(reduce_gpu, common_bfwzyx_sum_square_keepdims) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); set_values(input, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::sum_square, {cldnn::reduce::along_f, cldnn::reduce::along_w}, 1)); network network(engine, topology); @@ -1376,7 +1373,7 @@ TEST(reduce_gpu, common_bfwzyx_sum_square_keepdims) { std::vector ref_data = {5.0f, 50.0f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -1384,13 +1381,13 @@ TEST(reduce_gpu, common_bfwzyx_sum_square_keepdims) { } TEST(reduce_gpu, common_bfwzyx_l1) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); set_values(input, {0.0f, 1.0f, -2.0f, 3.0f, 4.0f, -5.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::l1, {cldnn::reduce::along_f, cldnn::reduce::along_w}, 0)); network network(engine, topology); @@ -1406,7 +1403,7 @@ TEST(reduce_gpu, common_bfwzyx_l1) { std::vector ref_data = {3.0f, 12.0f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -1414,13 +1411,13 @@ TEST(reduce_gpu, common_bfwzyx_l1) { } TEST(reduce_gpu, common_bfwzyx_l1_keepdims) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); set_values(input, {0.0f, 1.0f, -2.0f, 3.0f, 4.0f, -5.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::l1, {cldnn::reduce::along_f, cldnn::reduce::along_w}, 1)); network network(engine, topology); @@ -1436,7 +1433,7 @@ TEST(reduce_gpu, common_bfwzyx_l1_keepdims) { std::vector ref_data = {3.0f, 12.0f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -1444,13 +1441,13 @@ TEST(reduce_gpu, common_bfwzyx_l1_keepdims) { } TEST(reduce_gpu, common_bfwzyx_l2) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); set_values(input, {0.0f, 1.0f, -2.0f, 3.0f, 4.0f, -5.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::l2, {cldnn::reduce::along_f, cldnn::reduce::along_w}, 0)); network network(engine, topology); @@ -1466,7 +1463,7 @@ TEST(reduce_gpu, common_bfwzyx_l2) { std::vector ref_data = {2.236067977f, 7.071067812f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -1474,13 +1471,13 @@ TEST(reduce_gpu, common_bfwzyx_l2) { } TEST(reduce_gpu, common_bfwzyx_l2_keepdims) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); set_values(input, {0.0f, 1.0f, -2.0f, 3.0f, 4.0f, -5.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::l2, {cldnn::reduce::along_f, cldnn::reduce::along_w}, 1)); network network(engine, topology); @@ -1496,7 +1493,7 @@ TEST(reduce_gpu, common_bfwzyx_l2_keepdims) { std::vector ref_data = {2.236067977f, 7.071067812f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -1504,13 +1501,13 @@ TEST(reduce_gpu, common_bfwzyx_l2_keepdims) { } TEST(reduce_gpu, common_bfwzyx_log_sum) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); set_values(input, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::log_sum, {cldnn::reduce::along_f, cldnn::reduce::along_w}, 0)); network network(engine, topology); @@ -1526,7 +1523,7 @@ TEST(reduce_gpu, common_bfwzyx_log_sum) { std::vector ref_data = {1.0986122887f, 2.4849066498f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -1534,13 +1531,13 @@ TEST(reduce_gpu, common_bfwzyx_log_sum) { } TEST(reduce_gpu, common_bfwzyx_log_sum_keepdims) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); set_values(input, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::log_sum, {cldnn::reduce::along_f, cldnn::reduce::along_w}, 1)); network network(engine, topology); @@ -1556,7 +1553,7 @@ TEST(reduce_gpu, common_bfwzyx_log_sum_keepdims) { std::vector ref_data = {1.0986122887f, 2.4849066498f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -1564,13 +1561,13 @@ TEST(reduce_gpu, common_bfwzyx_log_sum_keepdims) { } TEST(reduce_gpu, common_bfwzyx_log_sum_exp) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); set_values(input, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::log_sum_exp, {cldnn::reduce::along_f, cldnn::reduce::along_w}, 0)); network network(engine, topology); @@ -1586,7 +1583,7 @@ TEST(reduce_gpu, common_bfwzyx_log_sum_exp) { std::vector ref_data = {2.407605964f, 5.407605964f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -1594,13 +1591,13 @@ TEST(reduce_gpu, common_bfwzyx_log_sum_exp) { } TEST(reduce_gpu, common_bfwzyx_log_sum_exp_keepdims) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfwzyx, {2, 3, 1, 1, 1, 1}}); set_values(input, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reduce("reduce", "input", reduce_mode::log_sum_exp, {cldnn::reduce::along_f, cldnn::reduce::along_w}, 1)); network network(engine, topology); @@ -1616,7 +1613,7 @@ TEST(reduce_gpu, common_bfwzyx_log_sum_exp_keepdims) { std::vector ref_data = {2.407605964f, 5.407605964f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < ref_data.size(); ++i) { EXPECT_TRUE(are_equal(ref_data[i], output_ptr[i])); @@ -1626,7 +1623,7 @@ TEST(reduce_gpu, common_bfwzyx_log_sum_exp_keepdims) { template class ReduceXYWithBigTensorTestBase : public ::testing::TestWithParam { protected: - cldnn::engine engine = get_test_engine(); + cldnn::engine& engine = get_test_engine(); int batch_num, input_f, input_w, input_z, input_y, input_x; cldnn::format input_format = format::any; cldnn::reduce_mode reduce_mode; @@ -1675,10 +1672,11 @@ class ReduceXYWithBigTensorTestBase : public ::testing::TestWithParam(batch_num, input_f, input_x, input_y, input_z, input_w, 1, 5, 9); auto input_lay = layout(input_dt, layout_format, input_size); - auto input_mem = memory::allocate(engine, input_lay); + auto input_mem = engine.allocate_memory(input_lay); { - auto input_ptr = input_mem.pointer(); + cldnn::mem_lock input_ptr(input_mem, get_test_stream()); + for (int fi = 0; fi < input_f; fi++) for (int wi = 0; wi < input_w; wi++) for (int zi = 0; zi < input_z; zi++) @@ -1718,7 +1716,7 @@ class ReduceXYWithBigTensorTestBase : public ::testing::TestWithParamget_layout())); topology.add(red); build_options options; options.set_option(build_option::optimize_data(true)); @@ -1730,8 +1728,8 @@ class ReduceXYWithBigTensorTestBase : public ::testing::TestWithParam(); - auto out_lay = out_mem.get_layout(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); + auto out_lay = out_mem->get_layout(); ASSERT_EQ(out_lay.size.sizes()[0], reference_result.size()); // b ASSERT_EQ(out_lay.size.sizes()[1], reference_result[0].size()); // f diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/region_yolo_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/region_yolo_gpu_test.cpp index 62d02ef2abd54a..e1d5d9b2a71873 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/region_yolo_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/region_yolo_gpu_test.cpp @@ -2,18 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include +#include "test_utils.h" -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include -#include using namespace cldnn; using namespace ::tests; @@ -186,26 +184,26 @@ namespace internal template static void runRegionTest(internal::region_yolo_test_params& params) { - engine eng; + auto& engine = get_test_engine(); const tensor kInputTensor(params.tensor[0], params.tensor[1], params.tensor[2], params.tensor[3]); auto inputData = generate_random_1d(params.tensor[0] * params.tensor[1] * params.tensor[2] * params.tensor[3], -1, 1); - auto inputPrim = memory::allocate(eng, { params.dataType, format::bfyx, kInputTensor }); + auto inputPrim = engine.allocate_memory({ params.dataType, format::bfyx, kInputTensor }); set_values(inputPrim, inputData); topology topology; - topology.add(input_layout("InputData", inputPrim.get_layout())); + topology.add(input_layout("InputData", inputPrim->get_layout())); topology.add(reorder("reorder_pre", "InputData", params.fmt, params.dataType)); topology.add(region_yolo("region_yolo", "reorder_pre", params.coords, params.classes, params.regionNum, static_cast(params.mask.size()), params.softMax)); topology.add(reorder("reorder_post", "region_yolo", format::bfyx, params.dataType)); - network network(eng, topology); + network network(engine, topology); network.set_input_data("InputData", inputPrim); auto outputs = network.execute(); auto output = outputs.at("reorder_post").get_memory(); - auto outputData = output.pointer(); + cldnn::mem_lock outputData(output, get_test_stream()); /// reference value std::vector refOutputData(inputData.size()); diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/removing_output_node_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/removing_output_node_test.cpp index 65e1c9f0ec0410..f8151686b50dc3 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/removing_output_node_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/removing_output_node_test.cpp @@ -2,22 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include "test_utils.h" -#include -#include -#include -#include -#include - -#include "test_utils/test_utils.h" +#include +#include +#include +#include +#include using namespace cldnn; -using namespace tests; +using namespace ::tests; using namespace testing; TEST(removing_output_node, multiple_outputs) { @@ -28,7 +22,7 @@ TEST(removing_output_node, multiple_outputs) { // |_ // reshape(bfyx); - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 6; auto feature_num = 1; auto x_size = 1; @@ -40,10 +34,10 @@ TEST(removing_output_node, multiple_outputs) { tensor after_strided_slice = tensor(spatial(y_size, feature_num), feature(batch_num), batch(1)); tensor after_reshape = tensor(feature(batch_num * feature_num * y_size * x_size)); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, initial_shape }); - auto begin = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, initial_shape }); + auto begin = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); set_values(begin, { 1, 0, 1, 0 @@ -56,7 +50,7 @@ TEST(removing_output_node, multiple_outputs) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(shuffle_channels("shuffle_channels", "input", group, axis)); topology.add(reshape("reshape", "shuffle_channels", after_reshape)); topology.add(data("input2", begin)); @@ -76,9 +70,9 @@ TEST(removing_output_node, multiple_outputs) { auto outputs = network.execute(); auto output = outputs.at("reshape").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); - ASSERT_TRUE(output.get_layout().size == after_reshape); + ASSERT_TRUE(output->get_layout().size == after_reshape); for (size_t i = 0; i < out_vec.size(); i++) EXPECT_EQ(output_ptr[i], out_vec[i]); @@ -86,9 +80,9 @@ TEST(removing_output_node, multiple_outputs) { // checking the output node has the same name after output node deleting due to StridedSlice optimization ASSERT_TRUE(outputs.find("strided_slice") != outputs.end()); auto output2 = outputs.at("strided_slice").get_memory(); - auto output_ptr2 = output.pointer(); + cldnn::mem_lock output_ptr2(output, get_test_stream()); - ASSERT_TRUE(output2.get_layout().size == after_strided_slice); + ASSERT_TRUE(output2->get_layout().size == after_strided_slice); for (size_t i = 0; i < out_vec.size(); i++) EXPECT_EQ(output_ptr2[i], out_vec[i]); @@ -114,10 +108,10 @@ TEST(removing_output_node, output_node_optimization) { // 21 28 39 // 18 20 20 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32,format::yxfb,{ 1, 1, 5, 4 } }); - auto weights = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 1, 3, 2 } }); + auto input = engine.allocate_memory({ data_types::f32,format::yxfb,{ 1, 1, 5, 4 } }); + auto weights = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 1, 3, 2 } }); set_values(input, { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 2.0f, 2.0f, 3.0f, 4.0f, 6.0f, 3.0f, 3.0f, 3.0f, 5.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }); set_values(weights, { 1.0f, 2.0f, 1.0f, 2.0f, 1.0f, 2.0f }); @@ -126,7 +120,7 @@ TEST(removing_output_node, output_node_optimization) { { 17.0f, 19.0f, 19.0f } }; topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("weights", weights)); topology.add(convolution("conv", "input", { "weights" }, { 1,1,1,2 })); topology.add(activation("relu", "conv", activation_func::relu)); @@ -140,8 +134,8 @@ TEST(removing_output_node, output_node_optimization) { EXPECT_EQ(outputs.begin()->first, "relu"); auto output_memory = outputs.at("relu").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/reorder_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/reorder_gpu_test.cpp index f2c80c3b06130c..6f0b6a3dfc1eac 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/reorder_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/reorder_gpu_test.cpp @@ -3,31 +3,27 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include "api/reorder.hpp" -#include "api/crop.hpp" -#include -#include -#include -#include -#include "test_utils/test_utils.h" -#include + +#include "test_utils.h" + +#include +#include +#include "cldnn/primitives/reorder.hpp" +#include "cldnn/primitives/crop.hpp" +#include #include -#include #include using namespace cldnn; -using namespace tests; +using namespace ::tests; using namespace testing; static void compare_bfyx2blocked_with_ref(const std::string& kernel_name, const data_types input_data_type, const data_types output_data_type, cldnn::format input_format, cldnn::format output_format, int32_t b_in, int32_t f_in, int32_t x_in, int32_t y_in, int32_t z_in = 0, int32_t w_in = 0) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); tensor ts; if (input_format.dimension() == 4) { @@ -40,11 +36,11 @@ static void compare_bfyx2blocked_with_ref(const std::string& kernel_name, ts = { b_in, f_in, x_in, y_in, z_in, w_in }; } - auto input = memory::allocate(engine, { input_data_type, input_format, ts }); + auto input = engine.allocate_memory({ input_data_type, input_format, ts }); layout output_layout(output_data_type, output_format, ts); if (input_data_type == data_types::i8) { - auto input_ptr = input.pointer(); + mem_lock input_ptr{input, get_test_stream()}; unsigned char i = 1; for (auto it = input_ptr.begin(); it != input_ptr.end(); ++it) { @@ -54,7 +50,7 @@ static void compare_bfyx2blocked_with_ref(const std::string& kernel_name, } } } else { - auto input_ptr = input.pointer(); + mem_lock input_ptr{input, get_test_stream()}; float i = 1.f; for (auto it = input_ptr.begin(); it != input_ptr.end(); ++it) { @@ -64,7 +60,7 @@ static void compare_bfyx2blocked_with_ref(const std::string& kernel_name, } topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("reorder", "input", output_layout)); // run on reference(reorder_data) kernel @@ -78,11 +74,11 @@ static void compare_bfyx2blocked_with_ref(const std::string& kernel_name, std::map outputs_ref; outputs_ref = network_ref.execute(); - cldnn::event e1 = outputs_ref.at("reorder").get_event(); - e1.wait(); + cldnn::event::ptr e1 = outputs_ref.at("reorder").get_event(); + e1->wait(); auto output_ref = outputs_ref.begin()->second.get_memory(); - auto output_ref_ptr = output_ref.pointer(); + mem_lock output_ref_ptr{output_ref, get_test_stream()}; // run on optimized kernel cldnn::build_options options; @@ -95,11 +91,11 @@ static void compare_bfyx2blocked_with_ref(const std::string& kernel_name, std::map outputs; outputs = network.execute(); - cldnn::event e2 = outputs.at("reorder").get_event(); - e2.wait(); + cldnn::event::ptr e2 = outputs.at("reorder").get_event(); + e2->wait(); auto output = outputs.begin()->second.get_memory(); - auto output_ptr = output.pointer(); + mem_lock output_ptr{output, get_test_stream()}; // compare results const size_t output_size = output_ref_ptr.size(); @@ -206,17 +202,17 @@ TEST(reorder_gpu_optimization, compare_with_ref__bfyx_to_blocked_format_differen } TEST(reorder_gpu_optimization, bfyx_to_fsv16_without_f_remainder) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int32_t b_in = 1; const int32_t f_in = 8 * 4; const int32_t y_in = 4; const int32_t x_in = 8 * 2; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { b_in,f_in,x_in,y_in } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { b_in,f_in,x_in,y_in } }); layout output_layout(data_types::f32, format::b_fs_yx_fsv16, { b_in,f_in,x_in,y_in }); // Set incremental input value - auto input_ptr = input.pointer(); + mem_lock input_ptr{input, get_test_stream()}; float i = 0.f; for (auto it = input_ptr.begin(); it != input_ptr.end(); ++it) { @@ -224,7 +220,7 @@ TEST(reorder_gpu_optimization, bfyx_to_fsv16_without_f_remainder) { } topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("reorder", "input", output_layout)); network network(engine, topology); @@ -235,7 +231,7 @@ TEST(reorder_gpu_optimization, bfyx_to_fsv16_without_f_remainder) { EXPECT_EQ(outputs.begin()->first, "reorder"); auto output = outputs.begin()->second.get_memory(); - auto output_ptr = output.pointer(); + mem_lock output_ptr{output, get_test_stream()}; auto get_fsv16_index = [](int32_t /* b_size */, int32_t f_size, int32_t y_size, int32_t x_size, int32_t b, int32_t f, int32_t y, int32_t x) { @@ -291,9 +287,9 @@ TEST(reorder_gpu_f32, basic) { // b1 f1: 12 8 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); layout output_layout(data_types::f32, format::bfyx,{ 2,2,2,2 }); set_values(input, { @@ -311,7 +307,7 @@ TEST(reorder_gpu_f32, basic) { }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("reorder", "input", output_layout)); network network(engine, topology); @@ -337,7 +333,7 @@ TEST(reorder_gpu_f32, basic) { 12.0f, 8.0f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -376,11 +372,11 @@ TEST(reorder_gpu_f32, basic_subtract) { // b1 f1: 10 7 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); layout output_layout( data_types::f32, format::bfyx, {2,2,2,2} ); - auto subtract = memory::allocate(engine, { data_types::f32, format::byxf, { 1, 2, 2, 2 } }); + auto subtract = engine.allocate_memory({ data_types::f32, format::byxf, { 1, 2, 2, 2 } }); set_values(input, { 1.f, 0.f, @@ -402,8 +398,8 @@ TEST(reorder_gpu_f32, basic_subtract) { }); topology topology( - input_layout("input", input.get_layout()), - input_layout("subtract", subtract.get_layout()), + input_layout("input", input->get_layout()), + input_layout("subtract", subtract->get_layout()), reorder("reorder", "input", output_layout, "subtract")); network network(engine, topology); @@ -429,7 +425,7 @@ TEST(reorder_gpu_f32, basic_subtract) { 10.0f, 7.0f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -465,9 +461,9 @@ TEST(reorder_gpu_f32, basic_subtract_value) { // b1 f1: 9.5 5.5 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); layout output_layout(data_types::f32, format::bfyx,{ 2,2,2,2 }); std::vector subtract_val = { 0.5, 2.5 }; @@ -486,7 +482,7 @@ TEST(reorder_gpu_f32, basic_subtract_value) { }); topology topology; - topology.add(input_layout("input", input.get_layout()), reorder("reorder", "input", output_layout, subtract_val)); + topology.add(input_layout("input", input->get_layout()), reorder("reorder", "input", output_layout, subtract_val)); network network(engine, topology); network.set_input_data("input", input); @@ -510,7 +506,7 @@ TEST(reorder_gpu_f32, basic_subtract_value) { 9.5f, 5.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { EXPECT_TRUE(are_equal(answers[i], output_ptr[i])); @@ -549,18 +545,18 @@ TEST(reorder_gpu_f16, basic_subtract_f32_output_f32) { // b1 f1: 10 7 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - if (!engine.get_info().supports_fp16) + if (!engine.get_device_info().supports_fp16) { std::cout << "[ SKIPPED ] The test is skipped (cl_khr_fp16 is not supported)." << std::endl; EXPECT_EQ(1, 1); return; } - auto input = memory::allocate(engine, { data_types::f16, format::yxfb, { 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f16, format::yxfb, { 2, 2, 2, 2 } }); layout output_layout(data_types::f32, format::bfyx,{ 2,2,2,2 }); - auto subtract = memory::allocate(engine, { data_types::f32, format::byxf, { 1, 2, 2, 2 } }); + auto subtract = engine.allocate_memory({ data_types::f32, format::byxf, { 1, 2, 2, 2 } }); set_values(input, { half_t(1.f), half_t(0.f), @@ -582,7 +578,7 @@ TEST(reorder_gpu_f16, basic_subtract_f32_output_f32) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("subtract", subtract)); topology.add(reorder("reorder", "input", output_layout, "subtract")); @@ -608,7 +604,7 @@ TEST(reorder_gpu_f16, basic_subtract_f32_output_f32) { 10.0f, 7.0f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { EXPECT_TRUE(are_equal(answers[i], output_ptr[i])); @@ -644,15 +640,15 @@ TEST(reorder_gpu_f16, basic_subtract_value) { // b1 f1: 9.5 5.5 // - const auto& engine = get_test_engine(); - if (!engine.get_info().supports_fp16) + auto& engine = get_test_engine(); + if (!engine.get_device_info().supports_fp16) { std::cout << "[ SKIPPED ] The test is skipped (cl_khr_fp16 is not supported)." << std::endl; EXPECT_EQ(1, 1); return; } - auto input = memory::allocate(engine, { data_types::f16, format::yxfb, { 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f16, format::yxfb, { 2, 2, 2, 2 } }); layout output_layout(data_types::f16, format::bfyx,{ 2,2,2,2 }); std::vector subtract_val = { 0.5, 2.5 }; @@ -671,7 +667,7 @@ TEST(reorder_gpu_f16, basic_subtract_value) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reorder("reorder", "input", output_layout, subtract_val)); network network(engine, topology); @@ -696,7 +692,7 @@ TEST(reorder_gpu_f16, basic_subtract_value) { half_t(9.5f), half_t(5.5f) }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { EXPECT_TRUE(are_equal(static_cast(answers[i]), static_cast(output_ptr[i]))); @@ -713,9 +709,9 @@ TEST(reorder_gpu, basic_convert_f16_f32_f16) { // Output is expected to contain the same value as input in range of indices from 0x0000 to 0xF801. // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - if (!engine.get_info().supports_fp16) + if (!engine.get_device_info().supports_fp16) { std::cout << "[ SKIPPED ] The test is skipped (cl_khr_fp16 is not supported)." << std::endl; EXPECT_EQ(1, 1); @@ -736,14 +732,14 @@ TEST(reorder_gpu, basic_convert_f16_f32_f16) { expected_values[0xF802] = half_t(0x8000, 0); // -0 expected_values[0xF803] = half_t(0xFC12, 0); // A NaN (sample: -NaN.0x12). - auto input = memory::allocate(engine, { data_types::f16, format::yxfb, { 1, static_cast(expected_values.size()) / 4, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f16, format::yxfb, { 1, static_cast(expected_values.size()) / 4, 2, 2 } }); layout interm_layout( data_types::f32, format::byxf, { 1, static_cast(expected_values.size()) / 4, 2, 2 }); - auto output_layout = input.get_layout(); + auto output_layout = input->get_layout(); set_values(input, expected_values); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reorder("reorder_f16_f32", "input", interm_layout)); topology.add(reorder("reorder_f32_f16", "reorder_f16_f32", output_layout)); @@ -762,7 +758,7 @@ TEST(reorder_gpu, basic_convert_f16_f32_f16) { EXPECT_TRUE(outputs.find("reorder_f32_f16") != outputs.end()); auto interm = outputs.at("reorder_f16_f32").get_memory(); - auto interm_ptr = interm.pointer(); + cldnn::mem_lock interm_ptr(interm, get_test_stream()); // Sample positive. EXPECT_TRUE(are_equal(interm_ptr[0x3400], 0.25f)); @@ -783,7 +779,7 @@ TEST(reorder_gpu, basic_convert_f16_f32_f16) { EXPECT_TRUE(std::isnan(interm_ptr[0xF803])); auto output = outputs.at("reorder_f32_f16").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 0xF802; ++i) // NOTE: do not test for possibly ambiguous values of floating point (-0, NaNs). { EXPECT_TRUE(are_equal(static_cast(expected_values[i]), static_cast(output_ptr[i]))); @@ -792,14 +788,14 @@ TEST(reorder_gpu, basic_convert_f16_f32_f16) { TEST(reorder_gpu, basic_convert_int8) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); layout in_layout = { type_to_data_type::value,format::byxf,{ 1,1,3,3 } }; layout byte_layout = { type_to_data_type::value, format::bfyx,{ 1,1,3,3 } }; std::initializer_list input_f = { 1.0f, -2.5f, 3.1f, -4.0f, 5.03f, -6.99f, 7.0f, -8.0f, 9.0f }; std::list final_results = { 1.0f, -3.0f, 3.0f, -4.0f, 5.0f, -7.0f, 7.0f, -8.0f, 9.0f }; // Allocate memory for input image. - auto input_memory = memory::allocate(engine, in_layout); + auto input_memory = engine.allocate_memory(in_layout); set_values(input_memory, input_f); // Create input_layout description @@ -830,7 +826,7 @@ TEST(reorder_gpu, basic_convert_int8) { auto outputs = network.execute(); auto interm = outputs.at("reorder2").get_memory(); - auto interm_ptr = interm.pointer(); + cldnn::mem_lock interm_ptr(interm, get_test_stream()); unsigned int cntr = 0; for (const auto& exp : final_results) { @@ -849,9 +845,9 @@ TEST(reorder_gpu, basic_convert_uint8rgbabyxf_to_fp32_bfyx) { // const int kernel_size = 5; const int feature_size = 4; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - if (!engine.get_info().supports_fp16) + if (!engine.get_device_info().supports_fp16) { std::cout << "[ SKIPPED ] The test is skipped (cl_khr_fp16 is not supported)." << std::endl; EXPECT_EQ(1, 1); @@ -869,7 +865,7 @@ TEST(reorder_gpu, basic_convert_uint8rgbabyxf_to_fp32_bfyx) { layout output_layout = { type_to_data_type::value, format::bfyx, {1,4,kernel_size,kernel_size } }; // Allocate memory for input image. - auto input_memory = memory::allocate(engine, in_layout); + auto input_memory = engine.allocate_memory(in_layout); set_values(input_memory, input_i8); // Create input_layout description @@ -916,8 +912,8 @@ TEST(reorder_gpu, basic_convert_uint8rgbabyxf_to_fp32_bfyx) { EXPECT_TRUE(outputs.find("crop") != outputs.end()); auto interm = outputs.at("reorder_input").get_memory(); - auto interm_ptr = interm.pointer(); - auto interm_size = outputs.at("reorder_input").get_memory().count(); + cldnn::mem_lock interm_ptr(interm, get_test_stream()); + auto interm_size = outputs.at("reorder_input").get_memory()->count(); EXPECT_EQ(interm_size,(size_t) (1*feature_size*kernel_size*kernel_size)); // Sample positive. @@ -939,8 +935,8 @@ TEST(reorder_gpu, basic_convert_uint8rgbabyxf_to_fp32_bfyx) { } auto output = outputs.at("crop").get_memory(); - auto output_ptr = output.pointer(); - auto output_size = outputs.at("crop").get_memory().count(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + auto output_size = output->count(); EXPECT_EQ(output_size,(size_t) (1 * (feature_size-1)*kernel_size*kernel_size)); for (target_index = 0; target_index < output_size; target_index++) @@ -980,9 +976,9 @@ TEST(reorder_gpu_f32, basic_yxfb_to_bfyx_input_padding) // f1: b0: 5 6 b1: 1.5 5.2 // f1: b0: 7 8 b1: 12 8 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); layout output_layout(data_types::f32, format::bfyx, { 2,2,2,2 }); set_values(input, { @@ -1000,8 +996,8 @@ TEST(reorder_gpu_f32, basic_yxfb_to_bfyx_input_padding) }); topology topology( - input_layout("input", input.get_layout()), - reorder("reorder", "input", input.get_layout().format, input.get_layout().data_type, "", reorder_mean_mode::subtract, padding{ { 0, 0, 1, 2 }, 0 }), + input_layout("input", input->get_layout()), + reorder("reorder", "input", input->get_layout().format, input->get_layout().data_type, "", reorder_mean_mode::subtract, padding{ { 0, 0, 1, 2 }, 0 }), reorder("reorder2", "reorder", output_layout)); network network(engine, topology); @@ -1026,7 +1022,7 @@ TEST(reorder_gpu_f32, basic_yxfb_to_bfyx_input_padding) 1.5f, 5.2f, 12.0f, 8.0f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -1059,9 +1055,9 @@ TEST(reorder_gpu_f32, basic_bfyx_to_yxfb_input_padding) // b1 f1: 12 8 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); layout output_layout(data_types::f32, format::yxfb, { 2,2,2,2 }); set_values(input, { @@ -1079,8 +1075,8 @@ TEST(reorder_gpu_f32, basic_bfyx_to_yxfb_input_padding) }); topology topology( - input_layout("input", input.get_layout()), - reorder("reorder", "input", input.get_layout().format, input.get_layout().data_type, "", reorder_mean_mode::subtract, padding{ { 0, 0, 2, 1 }, 0 }), + input_layout("input", input->get_layout()), + reorder("reorder", "input", input->get_layout().format, input->get_layout().data_type, "", reorder_mean_mode::subtract, padding{ { 0, 0, 2, 1 }, 0 }), reorder("reorder2", "reorder", output_layout)); network network(engine, topology); @@ -1106,7 +1102,7 @@ TEST(reorder_gpu_f32, basic_bfyx_to_yxfb_input_padding) 8.f, 8.f }; std::vector out; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { out.push_back(output_ptr[i]); @@ -1120,9 +1116,9 @@ TEST(reorder_gpu_f32, basic_bfyx_to_bfzyx) // Input : bfyx:2x2x2x2 // Output : bfzyx:2x2x1X2x2 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); set_values(input, { 1.f, 0.f, @@ -1139,7 +1135,7 @@ TEST(reorder_gpu_f32, basic_bfyx_to_bfzyx) }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("reorder", "input", format::bfzyx, data_types::f32)); network network(engine, topology); @@ -1150,8 +1146,8 @@ TEST(reorder_gpu_f32, basic_bfyx_to_bfzyx) EXPECT_EQ(outputs.begin()->first, "reorder"); auto output = outputs.begin()->second.get_memory(); - EXPECT_TRUE(output.get_layout().format == format::bfzyx); - auto sizes = output.get_layout().size; + EXPECT_TRUE(output->get_layout().format == format::bfzyx); + auto sizes = output->get_layout().size; EXPECT_TRUE(sizes.batch[0] == 2); EXPECT_TRUE(sizes.feature[0] == 2); EXPECT_TRUE(sizes.spatial[0] == 2); @@ -1172,7 +1168,7 @@ TEST(reorder_gpu_f32, basic_bfyx_to_bfzyx) 8.f, 8.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -1184,9 +1180,9 @@ TEST(reorder_gpu_f32, basic_yxfb_to_bfzyx) // Input : yxfb:2x2x2x2 // Output : bfzyx:2x2x1X2x2 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); set_values(input, { 1.f, 0.f, @@ -1203,7 +1199,7 @@ TEST(reorder_gpu_f32, basic_yxfb_to_bfzyx) }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("reorder", "input", format::bfzyx, data_types::f32)); network network(engine, topology); @@ -1214,8 +1210,8 @@ TEST(reorder_gpu_f32, basic_yxfb_to_bfzyx) EXPECT_EQ(outputs.begin()->first, "reorder"); auto output = outputs.begin()->second.get_memory(); - EXPECT_TRUE(output.get_layout().format == format::bfzyx); - auto sizes = output.get_layout().size; + EXPECT_TRUE(output->get_layout().format == format::bfzyx); + auto sizes = output->get_layout().size; EXPECT_TRUE(sizes.batch[0] == 2); EXPECT_TRUE(sizes.feature[0] == 2); EXPECT_TRUE(sizes.spatial[0] == 2); @@ -1236,7 +1232,7 @@ TEST(reorder_gpu_f32, basic_yxfb_to_bfzyx) 12.0f, 8.0f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -1248,9 +1244,9 @@ TEST(reorder_gpu_f32, basic_bfzyx_to_bfyx) // Input : bfzyx:2x2x2x2x2 // Output : bfyx:2x2x4x2 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 2, 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 2, 2, 2, 2, 2 } }); set_values(input, { 1.f, 0.f, @@ -1279,7 +1275,7 @@ TEST(reorder_gpu_f32, basic_bfzyx_to_bfyx) }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("reorder", "input", format::bfyx, data_types::f32)); network network(engine, topology); @@ -1290,8 +1286,8 @@ TEST(reorder_gpu_f32, basic_bfzyx_to_bfyx) EXPECT_EQ(outputs.begin()->first, "reorder"); auto output = outputs.begin()->second.get_memory(); - EXPECT_TRUE(output.get_layout().format == format::bfyx); - auto sizes = output.get_layout().size; + EXPECT_TRUE(output->get_layout().format == format::bfyx); + auto sizes = output->get_layout().size; EXPECT_TRUE(sizes.batch[0] == 2); EXPECT_TRUE(sizes.feature[0] == 2); EXPECT_TRUE(sizes.spatial[0] == 2); @@ -1324,7 +1320,7 @@ TEST(reorder_gpu_f32, basic_bfzyx_to_bfyx) 8.f, 8.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]); @@ -1333,11 +1329,11 @@ TEST(reorder_gpu_f32, basic_bfzyx_to_bfyx) TEST(reorder_gpu_opt, basic_remove_redundant) { - engine eng; + auto& engine = get_test_engine(); - memory in = memory::allocate(eng, { data_types::f32, format::bfyx, tensor{ 1, 2, 2, 1 } }); + memory::ptr in = engine.allocate_memory({ data_types::f32, format::bfyx, tensor{ 1, 2, 2, 1 } }); topology tpl{ - input_layout("in", in.get_layout()), + input_layout("in", in->get_layout()), reorder("r1", "in", format::bfyx, data_types::f32), reorder("r2", "r1", format::yxfb, data_types::f32) }; @@ -1345,26 +1341,26 @@ TEST(reorder_gpu_opt, basic_remove_redundant) build_options opts; opts.set_option(build_option::optimize_data(true)); - network net(eng, tpl, opts); + network net(engine, tpl, opts); net.set_input_data("in", in); auto outputs = net.execute(); auto executed_primitives = net.get_executed_primitives(); EXPECT_TRUE(executed_primitives.count("r1") == 0); ASSERT_TRUE(outputs.count("r2") == 1); - EXPECT_TRUE(outputs.at("r2").get_memory().get_layout().format == format::yxfb); + EXPECT_TRUE(outputs.at("r2").get_memory()->get_layout().format == format::yxfb); } TEST(reorder_gpu_opt, remove_redundant_activation_fuse) { - engine eng; + auto& engine = get_test_engine(); - memory in = memory::allocate(eng, { data_types::f32, format::bfyx, tensor{ 1, 1, 2, 1 } }); + memory::ptr in = engine.allocate_memory({ data_types::f32, format::bfyx, tensor{ 1, 1, 2, 1 } }); set_values(in, { -1.0f, -1.0f }); - memory scale_mem = memory::allocate(eng, { data_types::f32, format::bfyx, tensor{1, 1, 1, 1 } }); + memory::ptr scale_mem = engine.allocate_memory({ data_types::f32, format::bfyx, tensor{1, 1, 1, 1 } }); set_values(scale_mem, { 2.0f }); topology tpl{ - input_layout("in", in.get_layout()), + input_layout("in", in->get_layout()), reorder("r1", "in", format::bfyx, data_types::f32), activation("relu", "r1", activation_func::relu_negative_slope, {0.01f, 0.0f}), data("scale_data", scale_mem), @@ -1374,22 +1370,22 @@ TEST(reorder_gpu_opt, remove_redundant_activation_fuse) build_options opts; opts.set_option(build_option::optimize_data(true)); - network net(eng, tpl, opts); + network net(engine, tpl, opts); net.set_input_data("in", in); auto outputs = net.execute(); - auto out_ptr = outputs.begin()->second.get_memory().pointer(); + cldnn::mem_lock out_ptr(outputs.begin()->second.get_memory(), get_test_stream()); EXPECT_FLOAT_EQ(out_ptr[0], -0.02f); EXPECT_FLOAT_EQ(out_ptr[1], -0.02f); } TEST(reorder_gpu_opt, basic_remove_redundant_output_due_to_implicit_reorders) { - engine eng; + auto& engine = get_test_engine(); - memory in = memory::allocate(eng, { data_types::f32, format::yxfb, tensor{ 1, 2, 2, 1 } }); - memory weights = memory::allocate(eng, { data_types::f32, format::bfyx, tensor{ 1, 2, 2, 1 } }); + memory::ptr in = engine.allocate_memory({ data_types::f32, format::yxfb, tensor{ 1, 2, 2, 1 } }); + memory::ptr weights = engine.allocate_memory({ data_types::f32, format::bfyx, tensor{ 1, 2, 2, 1 } }); topology tpl{ - input_layout("in", in.get_layout()), + input_layout("in", in->get_layout()), convolution("conv", "in",{ "weights" }), data("weights", weights), reorder("r1", "conv", format::bfyx, data_types::f32) //optimize data should add conversion from yxfb to bfyx and 'conv' should output data in bfyx as well (IE case) @@ -1401,23 +1397,23 @@ TEST(reorder_gpu_opt, basic_remove_redundant_output_due_to_implicit_reorders) opts.set_option(build_option::outputs({ "r1" })); opts.set_option(build_option::optimize_data(true)); - network net(eng, tpl, opts); + network net(engine, tpl, opts); net.set_input_data("in", in); auto outputs = net.execute(); EXPECT_TRUE(outputs.count("conv") == 0); ASSERT_TRUE(outputs.count("r1") == 1); - EXPECT_TRUE(outputs.at("r1").get_memory().get_layout().format == format::bfyx); + EXPECT_TRUE(outputs.at("r1").get_memory()->get_layout().format == format::bfyx); } TEST(reorder_gpu_opt, basic_remove_redundant_due_to_implicit_reorders) { - engine eng; + auto& engine = get_test_engine(); - memory in = memory::allocate(eng, { data_types::f32, format::yxfb, tensor{ 1, 2, 2, 1 } }); - memory weights = memory::allocate(eng, { data_types::f32, format::bfyx, tensor{ 1, 2, 2, 1 } }); + memory::ptr in = engine.allocate_memory({ data_types::f32, format::yxfb, tensor{ 1, 2, 2, 1 } }); + memory::ptr weights = engine.allocate_memory({ data_types::f32, format::bfyx, tensor{ 1, 2, 2, 1 } }); topology tpl{ - input_layout("in", in.get_layout()), + input_layout("in", in->get_layout()), convolution("conv", "in",{ "weights" }), data("weights", weights), reorder("r1", "conv", format::bfyx, data_types::f32), //optimize data should add conversion from yxfb to bfyx and 'conv' should output data in bfyx as well (IE case) @@ -1427,7 +1423,7 @@ TEST(reorder_gpu_opt, basic_remove_redundant_due_to_implicit_reorders) build_options opts; opts.set_option(build_option::optimize_data(true)); - network net(eng, tpl, opts); + network net(engine, tpl, opts); net.set_input_data("in", in); auto outputs = net.execute(); auto executed_primitives = net.get_executed_primitives(); @@ -1436,16 +1432,16 @@ TEST(reorder_gpu_opt, basic_remove_redundant_due_to_implicit_reorders) EXPECT_TRUE(executed_primitives.count("r1") == 0); //all pirmitives in this test needs to be executed ASSERT_TRUE(outputs.count("output") == 1); - EXPECT_TRUE(outputs.at("output").get_memory().get_layout().format == format::bfyx); + EXPECT_TRUE(outputs.at("output").get_memory()->get_layout().format == format::bfyx); } TEST(reorder_gpu_opt, non_trivial_remove_redundant) { - engine eng; + auto& engine = get_test_engine(); - memory in = memory::allocate(eng, { data_types::f32, format::yxfb, tensor{ 1, 1, 5, 2 } }); + memory::ptr in = engine.allocate_memory({ data_types::f32, format::yxfb, tensor{ 1, 1, 5, 2 } }); topology tpl{ - input_layout("in", in.get_layout()), + input_layout("in", in->get_layout()), reorder("r1", "in", format::bfyx, data_types::f32) }; @@ -1453,7 +1449,7 @@ TEST(reorder_gpu_opt, non_trivial_remove_redundant) opts.set_option(build_option::optimize_data(true)); - network net(eng, tpl, opts); + network net(engine, tpl, opts); net.set_input_data("in", in); auto outputs = net.execute(); auto executed_primitives = net.get_executed_primitives(); @@ -1463,15 +1459,15 @@ TEST(reorder_gpu_opt, non_trivial_remove_redundant) //ASSERT_TRUE(all_primitives.at("r1") == "_optimized_"); EXPECT_TRUE(executed_primitives.at("in") != outputs.at("r1").get_event()); ASSERT_TRUE(outputs.count("r1") == 1); - EXPECT_TRUE(outputs.at("r1").get_memory().get_layout().format == format::bfyx); + EXPECT_TRUE(outputs.at("r1").get_memory()->get_layout().format == format::bfyx); } TEST(reorder_gpu_opt, mean_mul) { - engine eng; + auto& engine = get_test_engine(); - memory in = memory::allocate(eng, { data_types::i8, format::bfyx, tensor{ 1, 3, 1, 2 } }); - memory mul = memory::allocate(eng, { data_types::f32, format::bfyx, tensor{1, 3, 1, 2 } }); + memory::ptr in = engine.allocate_memory({ data_types::i8, format::bfyx, tensor{ 1, 3, 1, 2 } }); + memory::ptr mul = engine.allocate_memory({ data_types::f32, format::bfyx, tensor{1, 3, 1, 2 } }); set_values(in, { 1, 2, @@ -1481,7 +1477,7 @@ TEST(reorder_gpu_opt, mean_mul) { 0.5f, 2.5f, -5.0f, 4.3f, 1.2f, -3.5f }); topology tpl{ - input_layout("in", in.get_layout()), + input_layout("in", in->get_layout()), data("mul",mul), reorder("r1", "in", format::bfyx, data_types::f32,"mul", reorder_mean_mode::mul) }; @@ -1489,12 +1485,12 @@ TEST(reorder_gpu_opt, mean_mul) float answers[] = { 0.5f, 5.0f, -15.0f, 17.2f, 6.0f, -21.0f }; build_options opts; opts.set_option(build_option::optimize_data(true)); - network net(eng, tpl, opts); + network net(engine, tpl, opts); net.set_input_data("in", in); auto outputs = net.execute(); auto output = outputs.begin()->second.get_memory(); - auto ptr = output.pointer(); + cldnn::mem_lock ptr(output, get_test_stream()); float* a_ptr = answers; for (auto& val : ptr) EXPECT_FLOAT_EQ(*(a_ptr++), val);; @@ -1503,10 +1499,10 @@ TEST(reorder_gpu_opt, mean_mul) TEST(reorder_gpu_opt, mean_div) { - engine eng; + auto& engine = get_test_engine(); - memory in = memory::allocate(eng, { data_types::i8, format::bfyx, tensor{ 1, 3, 1, 2 } }); - memory mul = memory::allocate(eng, { data_types::f32, format::bfyx, tensor{ 1, 3, 1, 2 } }); + memory::ptr in = engine.allocate_memory({ data_types::i8, format::bfyx, tensor{ 1, 3, 1, 2 } }); + memory::ptr mul = engine.allocate_memory({ data_types::f32, format::bfyx, tensor{ 1, 3, 1, 2 } }); set_values(in, { 1, 2, @@ -1516,7 +1512,7 @@ TEST(reorder_gpu_opt, mean_div) { 0.5f, 2.0f, -3.0f, 8.0f, 1.25f, -3.0f }); topology tpl{ - input_layout("in", in.get_layout()), + input_layout("in", in->get_layout()), data("mul",mul), reorder("r1", "in", format::bfyx, data_types::f32,"mul", reorder_mean_mode::div) }; @@ -1524,12 +1520,12 @@ TEST(reorder_gpu_opt, mean_div) float answers[] = { 2.0f, 1.0f, -1.0f, 0.5f, 4.0f, -2.0f }; build_options opts; opts.set_option(build_option::optimize_data(true)); - network net(eng, tpl, opts); + network net(engine, tpl, opts); net.set_input_data("in", in); auto outputs = net.execute(); auto output = outputs.begin()->second.get_memory(); - auto ptr = output.pointer(); + cldnn::mem_lock ptr(output, get_test_stream()); float* a_ptr = answers; for (auto& val : ptr) EXPECT_FLOAT_EQ(*(a_ptr++), val);; @@ -1538,9 +1534,9 @@ TEST(reorder_gpu_opt, mean_div) TEST(reorder_gpu_opt, mean_mul_val) { - engine eng; + auto& engine = get_test_engine(); - memory in = memory::allocate(eng, { data_types::i8, format::bfyx, tensor{ 1, 3, 1, 2 } }); + memory::ptr in = engine.allocate_memory({ data_types::i8, format::bfyx, tensor{ 1, 3, 1, 2 } }); set_values(in, { 1, 2, @@ -1548,19 +1544,19 @@ TEST(reorder_gpu_opt, mean_mul_val) 5, 60 }); std::vector mul_val = { 2.0f, 0.5f, 10.0f }; topology tpl{ - input_layout("in", in.get_layout()), + input_layout("in", in->get_layout()), reorder("r1", "in", format::bfyx, data_types::f32, mul_val, reorder_mean_mode::mul) }; float answers[] = { 2.0f, 4.0f, 1.5f, 2.0f, 50.0f, 600.0f }; build_options opts; opts.set_option(build_option::optimize_data(true)); - network net(eng, tpl, opts); + network net(engine, tpl, opts); net.set_input_data("in", in); auto outputs = net.execute(); auto output = outputs.begin()->second.get_memory(); - auto ptr = output.pointer(); + cldnn::mem_lock ptr(output, get_test_stream()); float* a_ptr = answers; for (auto& val : ptr) EXPECT_FLOAT_EQ(*(a_ptr++), val);; @@ -1568,9 +1564,9 @@ TEST(reorder_gpu_opt, mean_mul_val) TEST(reorder_gpu_opt, mean_mul_val_float_to_int) { - engine eng; + auto& engine = get_test_engine(); - memory in = memory::allocate(eng, { data_types::f32, format::bfyx, tensor{ 1, 3, 1, 2 } }); + memory::ptr in = engine.allocate_memory({ data_types::f32, format::bfyx, tensor{ 1, 3, 1, 2 } }); set_values(in, { 0.6f, 1.5f, @@ -1578,19 +1574,19 @@ TEST(reorder_gpu_opt, mean_mul_val_float_to_int) 5.0f, 60.0f }); std::vector mul_val = { 1.4f, 0.5f, 5.0f }; topology tpl{ - input_layout("in", in.get_layout()), + input_layout("in", in->get_layout()), reorder("r1", "in", format::bfyx, data_types::i8, mul_val, reorder_mean_mode::mul) }; char answers[] = { 1, 2, 2, 2, 25, 127 }; build_options opts; opts.set_option(build_option::optimize_data(true)); - network net(eng, tpl, opts); + network net(engine, tpl, opts); net.set_input_data("in", in); auto outputs = net.execute(); auto output = outputs.begin()->second.get_memory(); - auto ptr = output.pointer(); + cldnn::mem_lock ptr(output, get_test_stream()); char* a_ptr = answers; for (auto& val : ptr) EXPECT_EQ(*(a_ptr++), val); @@ -1599,9 +1595,9 @@ TEST(reorder_gpu_opt, mean_mul_val_float_to_int) TEST(reorder_gpu_i32, basic) { // Test for converting data types f32->i32 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); layout output_layout(data_types::i32, format::bfyx, { 2,2,2,2 }); set_values(input, { @@ -1612,7 +1608,7 @@ TEST(reorder_gpu_i32, basic) }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("reorder", "input", output_layout)); network network(engine, topology); @@ -1632,7 +1628,7 @@ TEST(reorder_gpu_i32, basic) }; int32_t* a_ptr = answers; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (auto& val : output_ptr) EXPECT_EQ(*(a_ptr++), val); } @@ -1640,9 +1636,9 @@ TEST(reorder_gpu_i32, basic) TEST(reorder_gpu_i64, basic) { // Test for converting data types f32->i64 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); layout output_layout(data_types::i64, format::bfyx, { 2,2,2,2 }); set_values(input, { @@ -1653,7 +1649,7 @@ TEST(reorder_gpu_i64, basic) }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("reorder", "input", output_layout)); network network(engine, topology); @@ -1673,19 +1669,19 @@ TEST(reorder_gpu_i64, basic) }; int64_t* a_ptr = answers; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (auto& val : output_ptr) EXPECT_EQ(*(a_ptr++), val); } TEST(reorder_gpu_binary, binary_output) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); cldnn::build_options options; options.set_option(cldnn::build_option::optimize_data(true)); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); layout output_layout(data_types::bin, format::b_fs_yx_32fp, { 2, 2, 2, 2 }); // Data is supposed to be quantized to {0,1} values @@ -1698,7 +1694,7 @@ TEST(reorder_gpu_binary, binary_output) }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("reorder", "input", output_layout)); network network(engine, topology); @@ -1709,17 +1705,17 @@ TEST(reorder_gpu_binary, binary_output) EXPECT_EQ(outputs.begin()->first, "reorder"); auto output = outputs.begin()->second.get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 1, 2, 3, 1, 1, 1, 0, 3 }; // Check that layout and memory contains logical size of tensor - ASSERT_EQ(output.count(), input.get_layout().count()); - ASSERT_EQ(output.get_layout().count(), input.get_layout().count()); + ASSERT_EQ(output->count(), input->get_layout().count()); + ASSERT_EQ(output->get_layout().count(), input->get_layout().count()); // Check that memory physical size consider binary pack - ASSERT_EQ(output.size(), answers.size() * sizeof(uint32_t)); + ASSERT_EQ(output->size(), answers.size() * sizeof(uint32_t)); for (size_t i = 0; i < answers.size(); ++i) { EXPECT_EQ(answers[i], output_ptr[i]) << "index: " << i; @@ -1728,12 +1724,12 @@ TEST(reorder_gpu_binary, binary_output) TEST(reorder_gpu_binary, binary_input) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); cldnn::build_options options; options.set_option(cldnn::build_option::optimize_data(true)); - auto input = memory::allocate(engine, { data_types::bin, format::b_fs_yx_32fp,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::bin, format::b_fs_yx_32fp,{ 2, 2, 2, 2 } }); layout output_layout(data_types::f32, format::bfyx, { 2, 2, 2, 2 }); // Data is supposed to be quantized to {0,1} values @@ -1749,7 +1745,7 @@ TEST(reorder_gpu_binary, binary_input) 1, 1, 0, 3 }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("reorder", "input", output_layout)); network network(engine, topology); @@ -1760,13 +1756,13 @@ TEST(reorder_gpu_binary, binary_input) EXPECT_EQ(outputs.begin()->first, "reorder"); auto output = outputs.begin()->second.get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); // Check that layout and memory contains logical size of tensor - ASSERT_EQ(output.count(), input.get_layout().count()); - ASSERT_EQ(output.get_layout().count(), input.get_layout().count()); + ASSERT_EQ(output->count(), input->get_layout().count()); + ASSERT_EQ(output->get_layout().count(), input->get_layout().count()); - ASSERT_EQ(output.size(), answers.size() * sizeof(float)); + ASSERT_EQ(output->size(), answers.size() * sizeof(float)); for (size_t i = 0; i < answers.size(); ++i) { EXPECT_EQ(answers[i], output_ptr[i]) << "index: " << i; @@ -1791,9 +1787,9 @@ TEST(reorder_gpu_f32, bfwzyx_bfyx_chain) // Expected output: // 0 1 -1 0 8 9 7 8 // 2 3 1 2 10 11 9 10 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, layout{ data_types::f32, format::bfyx, tensor{ batch(1), feature(4), spatial(2, 2) } }); + auto input = engine.allocate_memory(layout{ data_types::f32, format::bfyx, tensor{ batch(1), feature(4), spatial(2, 2) } }); std::vector data = { 1.f, 2.f, 3.f, 4.f, @@ -1813,7 +1809,7 @@ TEST(reorder_gpu_f32, bfwzyx_bfyx_chain) }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("reorder1", "input", format::bfwzyx, data_types::f32), reshape("reshape1", "reorder1", tensor(batch(2), feature(2), spatial(1, 1, 2, 2) )), reorder("reorder2", "reshape1", format::bfwzyx, data_types::f32, sub_bfwzyx), @@ -1832,8 +1828,8 @@ TEST(reorder_gpu_f32, bfwzyx_bfyx_chain) EXPECT_EQ(outputs.begin()->first, "out_reorder"); auto output = outputs.begin()->second.get_memory(); - EXPECT_TRUE(output.get_layout().format == format::bfwzyx); - auto sizes = output.get_layout().size; + EXPECT_TRUE(output->get_layout().format == format::bfwzyx); + auto sizes = output->get_layout().size; EXPECT_EQ(sizes.batch[0], 1); EXPECT_EQ(sizes.feature[0], 4); EXPECT_EQ(sizes.spatial[0], 2); @@ -1841,7 +1837,7 @@ TEST(reorder_gpu_f32, bfwzyx_bfyx_chain) EXPECT_EQ(sizes.spatial[2], 1); EXPECT_EQ(sizes.spatial[2], 1); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(output_ptr.size(), expected.size()); for (size_t i = 0; i < expected.size(); i++) @@ -1852,20 +1848,20 @@ TEST(reorder_gpu_f32, bfwzyx_bfyx_chain) TEST(reorder_gpu_f32, bfzyx_to_bsv16_fsv16) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int32_t b_in = 2; const int32_t f_in = 2; const int32_t x_in = 2; const int32_t y_in = 2; const int32_t z_in = 2; - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx, { b_in,f_in,x_in,y_in,z_in } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx, { b_in,f_in,x_in,y_in,z_in } }); layout output_layout(data_types::f32, format::bs_fs_zyx_bsv16_fsv16,{ b_in,f_in,x_in,y_in,z_in }); tests::set_random_values(input); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("reorder", "input", output_layout)); network network(engine, topology); @@ -1906,8 +1902,8 @@ TEST(reorder_gpu_f32, bfzyx_to_bsv16_fsv16) return output_offset; }; - auto input_ptr = input.pointer(); - auto output_ptr = output.pointer(); + cldnn::mem_lock input_ptr(input, get_test_stream()); + cldnn::mem_lock output_ptr(output, get_test_stream()); int32_t linear_index = 0; for (int32_t b = 0; b < b_in; b++) { for (int32_t f = 0; f < f_in; f++) { @@ -1930,7 +1926,7 @@ TEST(reorder_gpu_f32, bfzyx_to_bsv16_fsv16) TEST(reorder_gpu_f32, bfzyx_to_bsv16_fsv16_padded) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); const int32_t b_in = 2; const int32_t f_in = 2; const int32_t x_in = 2; @@ -1941,13 +1937,13 @@ TEST(reorder_gpu_f32, bfzyx_to_bsv16_fsv16_padded) const int32_t y_pad= 2; const int32_t x_pad= 1; - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx, { b_in,f_in,x_in,y_in,z_in } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx, { b_in,f_in,x_in,y_in,z_in } }); layout output_layout(data_types::f32, format::bs_fs_zyx_bsv16_fsv16,{ b_in,f_in,x_in,y_in,z_in }); tests::set_random_values(input); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("reorder", "input", output_layout.with_padding(padding({0, 0, x_pad, y_pad, 0}, 0.f)))); network network(engine, topology); @@ -1988,8 +1984,8 @@ TEST(reorder_gpu_f32, bfzyx_to_bsv16_fsv16_padded) return output_offset; }; - auto input_ptr = input.pointer(); - auto output_ptr = output.pointer(); + cldnn::mem_lock input_ptr(input, get_test_stream()); + cldnn::mem_lock output_ptr(output, get_test_stream()); int32_t linear_index = 0; for (int32_t b = 0; b < b_in; b++) { for (int32_t f = 0; f < f_in; f++) { @@ -2011,16 +2007,16 @@ TEST(reorder_gpu_f32, bfzyx_to_bsv16_fsv16_padded) TEST(reorder_gpu_f32, b_fs_yx_fsv16_to_bfyx_opt_allowed) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::b_fs_yx_fsv16, { 2, 12, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::b_fs_yx_fsv16, { 2, 12, 1, 1 } }); set_values(input, { 0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f, 16.f, 17.f, 18.f, 19.f, 20.f, 21.f, 22.f, 23.f, 24.f, 25.f, 26.f, 27.f, 28.f, 29.f, 30.f, 31.f }); const std::string reorder_name = "reorder_prim"; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), activation("first_activation", "input", activation_func::abs), reorder(reorder_name, "first_activation", format::bfyx, data_types::f32), activation("second_activation", reorder_name, activation_func::abs)); @@ -2045,7 +2041,7 @@ TEST(reorder_gpu_f32, b_fs_yx_fsv16_to_bfyx_opt_allowed) 16.f, 17.f, 18.f, 19.f, 20.f, 21.f, 22.f, 23.f, 24.f, 25.f, 26.f, 27.f, }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(output_ptr.size(), 24); for (size_t i = 0; i < output_ptr.size(); i++) { @@ -2055,19 +2051,19 @@ TEST(reorder_gpu_f32, b_fs_yx_fsv16_to_bfyx_opt_allowed) TEST(reorder_gpu_f32, b_fs_yx_fsv16_to_bfyx_opt_not_allowed) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::b_fs_yx_fsv16, { 1, 8, 1, 1 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::oiyx, { 1, 8, 3, 3 } }); + auto input = engine.allocate_memory({ data_types::f32, format::b_fs_yx_fsv16, { 1, 8, 1, 1 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::oiyx, { 1, 8, 3, 3 } }); set_values(input, { 0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f }); - set_values(weights, std::vector(weights.count(), 1)); + set_values(weights, std::vector(weights->count(), 1)); const std::string reorder_name = "reorder"; const std::string reorder_primitive_name = "reorder:" + reorder_name; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), data("weights", weights), reorder(reorder_name, "input", format::bfyx, data_types::f32), convolution("convolution", reorder_name, {"weights"}, {1,1,1,1}, {0,0,-1,-1}, {1,1,1,1})); @@ -2089,7 +2085,7 @@ TEST(reorder_gpu_f32, b_fs_yx_fsv16_to_bfyx_opt_not_allowed) float answers[1] = { 28.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 1; i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]) << "i=" << i; @@ -2098,9 +2094,9 @@ TEST(reorder_gpu_f32, b_fs_yx_fsv16_to_bfyx_opt_not_allowed) TEST(reorder_gpu_f32, b_fs_yx_fsv16_to_bfyx_opt_padded) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, + auto input = engine.allocate_memory({ data_types::f32, format::b_fs_yx_fsv16, { 2, 4, 1, 1 }, padding({1, 16, 0, 0}, {1, 0, 0, 0}) }); @@ -2124,7 +2120,7 @@ TEST(reorder_gpu_f32, b_fs_yx_fsv16_to_bfyx_opt_padded) const std::string reorder_name = "reorder_prim"; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder(reorder_name, "input", format::bfyx, data_types::f32), activation("activation", reorder_name, activation_func::abs)); @@ -2148,7 +2144,7 @@ TEST(reorder_gpu_f32, b_fs_yx_fsv16_to_bfyx_opt_padded) 16.f, 17.f, 18.f, 19.f, }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(output_ptr.size(), 8); for (size_t i = 0; i < output_ptr.size(); i++) { EXPECT_FLOAT_EQ(answers[i], output_ptr[i]) << "i=" << i; @@ -2158,21 +2154,21 @@ TEST(reorder_gpu_f32, b_fs_yx_fsv16_to_bfyx_opt_padded) TEST(reorder_gpu, any_format) { auto& engine = get_test_engine(); - auto input = memory::allocate(engine, layout(data_types::f32, format::yxfb, tensor(5, 7, 13, 9))); + auto input = engine.allocate_memory(layout(data_types::f32, format::yxfb, tensor(5, 7, 13, 9))); topology topo; - topo.add(input_layout("in", input.get_layout())); + topo.add(input_layout("in", input->get_layout())); topo.add(reorder("out", "in", format::any, data_types::f32)); network net(engine, topo); - auto data = generate_random_1d(input.count(), -1, 1); + auto data = generate_random_1d(input->count(), -1, 1); set_values(input, data); net.set_input_data("in", input); auto outputs = net.execute(); auto out_mem = outputs.at("out").get_memory(); - auto output = out_mem.pointer(); + cldnn::mem_lock output(out_mem, get_test_stream()); for (size_t i = 0; i < data.size(); ++i) { EXPECT_EQ(output[i], data[i]) << "i = " << i; @@ -2181,9 +2177,9 @@ TEST(reorder_gpu, any_format) { TEST(reorder_image2d_rgba_to_bfyx_gpu, basic) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::u8, format::image_2d_rgba, { 1, 3, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::u8, format::image_2d_rgba, { 1, 3, 2, 2 } }); layout output_layout(data_types::f16, format::bfyx, { 1, 3, 2, 2 }); set_values(input, { @@ -2194,7 +2190,7 @@ TEST(reorder_image2d_rgba_to_bfyx_gpu, basic) }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("reorder", "input", output_layout)); network network(engine, topology); @@ -2217,7 +2213,7 @@ TEST(reorder_image2d_rgba_to_bfyx_gpu, basic) 50.0f, 253.0f, }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr (output, get_test_stream()); for (int i = 0; i < 12; i++) { EXPECT_NEAR(FLOAT16(answers[i] / 255.f), output_ptr[i], 1e-3f); @@ -2227,9 +2223,9 @@ TEST(reorder_image2d_rgba_to_bfyx_gpu, basic) TEST(reorder_bfyx_to_image2d_rgba_gpu, basic) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 3, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 3, 2, 2 } }); layout output_layout(data_types::u8, format::image_2d_rgba, { 1, 3, 2, 2 }); set_values(input, { @@ -2244,7 +2240,7 @@ TEST(reorder_bfyx_to_image2d_rgba_gpu, basic) }); topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), reorder("reorder", "input", output_layout)); network network(engine, topology); @@ -2263,7 +2259,7 @@ TEST(reorder_bfyx_to_image2d_rgba_gpu, basic) 251, 252, 253, 0 }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { EXPECT_EQ(answers[i], output_ptr[i]); @@ -2329,7 +2325,7 @@ class reorder_test : public tests::generic_test } template - memory generate_reference_typed(const std::vector& inputs) + memory::ptr generate_reference_typed(const std::vector& inputs) { auto reorder = std::static_pointer_cast(layer_params); primitive_id mean = reorder->mean; @@ -2337,12 +2333,12 @@ class reorder_test : public tests::generic_test assert(mean == ""); assert(subtract_per_feature.size() == 0); - auto output = memory::allocate(engine, cldnn::layout(*reorder->output_data_type, inputs[0].get_layout().format, inputs[0].get_layout().size)); + auto output = engine.allocate_memory(cldnn::layout(*reorder->output_data_type, inputs[0]->get_layout().format, inputs[0]->get_layout().size)); - cldnn::pointer input_mem = inputs[0].pointer(); - cldnn::pointer output_mem = output.pointer(); + cldnn::mem_lock input_mem(inputs[0], get_test_stream()); + cldnn::mem_lock output_mem(output, get_test_stream()); - for (size_t i = 0; i < inputs[0].get_layout().get_linear_size(); i++) + for (size_t i = 0; i < inputs[0]->get_layout().get_linear_size(); i++) { // Write the output in the same order as the input with type conversion as needed. // The correct order will be checked in generic_test::compare_buffers. @@ -2352,7 +2348,7 @@ class reorder_test : public tests::generic_test return output; } - virtual memory generate_reference(const std::vector& inputs) + virtual memory::ptr generate_reference(const std::vector& inputs) { if (generic_params->data_type == data_types::f32) { diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/resample_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/resample_gpu_test.cpp index 1a02c57d79c0e7..ca7da7f9e83013 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/resample_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/resample_gpu_test.cpp @@ -3,19 +3,16 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include "api/resample.hpp" -#include -#include -#include -#include "test_utils/test_utils.h" -#include -#include + +#include "test_utils.h" + +#include +#include +#include +#include using namespace cldnn; -using namespace tests; +using namespace ::tests; TEST(resample_gpu, basic_in2x3x2x2_nearest) { // Input : 2x2x3x2 @@ -29,15 +26,15 @@ TEST(resample_gpu, basic_in2x3x2x2_nearest) { // f1: b0: 7 8 -16 b1: 12 9 -17 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 3, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 3, 2 } }); auto output_size = tensor(batch(2), feature(2), spatial(6, 4)); uint32_t num_filter = 0u; topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(resample("upsampling", "input", output_size, num_filter, resample_type::nearest)); set_values(input, { @@ -58,7 +55,7 @@ TEST(resample_gpu, basic_in2x3x2x2_nearest) { auto outputs = net.execute(); auto output = outputs.at("upsampling").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float answers[96] = { 1.f, 1.f, 2.f, 2.f, -10.f, -10.f, @@ -101,15 +98,15 @@ TEST(resample_gpu, basic_in2x3x2x2_bilinear) { // f0: b0: 3 4 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); auto output_size = tensor(batch(1), feature(1), spatial(4, 4)); uint32_t num_filter = 1u; topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(resample("upsampling", "input", output_size, num_filter, resample_type::caffe_bilinear)); set_values(input, { @@ -123,9 +120,9 @@ TEST(resample_gpu, basic_in2x3x2x2_bilinear) { auto outputs = net.execute(); auto output = outputs.at("upsampling").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); - EXPECT_EQ(output.get_layout().get_linear_size(), (size_t) 16); + EXPECT_EQ(output->get_layout().get_linear_size(), (size_t) 16); float answers[16] = { 1.f, 1.25f, 1.75f, 2.f, @@ -152,14 +149,14 @@ TEST(resample_gpu, basic_in1x1x2x2_interp) { // f0: b0: 3 4 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); auto output_size = tensor(batch(1), feature(1), spatial(4, 4)); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(resample("upsampling", "input", output_size, {0, 0, 0, 0}, {0, 0, 0, 0}, 0, resample_type::bilinear)); set_values(input, { @@ -173,9 +170,9 @@ TEST(resample_gpu, basic_in1x1x2x2_interp) { auto outputs = net.execute(); auto output = outputs.at("upsampling").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); - EXPECT_EQ(output.get_layout().get_linear_size(), (size_t) 16); + EXPECT_EQ(output->get_layout().get_linear_size(), (size_t) 16); float answers[16] = { 1.0f, 1.5f, 2.0f, 2.0f, @@ -202,14 +199,14 @@ TEST(resample_gpu, basic_in1x1x2x2_interp_f16) { // f0: b0: 3 4 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); auto output_size = tensor(batch(1), feature(1), spatial(4, 4)); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reorder("input_to_b_fs_yx_fsv16", "input", format::b_fs_yx_fsv16, data_types::f32)); topology.add(resample("resample", "input_to_b_fs_yx_fsv16", output_size, {0, 0, 0, 0}, {0, 0, 0, 0}, 0, resample_type::bilinear)); topology.add(reorder("res_to_bfyx", "resample", format::bfyx, data_types::f32)); @@ -228,12 +225,12 @@ TEST(resample_gpu, basic_in1x1x2x2_interp_f16) { auto outputs = net.execute(); auto resample_out = outputs.at("resample").get_memory(); - ASSERT_EQ(resample_out.get_layout().format, format::b_fs_yx_fsv16); + ASSERT_EQ(resample_out->get_layout().format, format::b_fs_yx_fsv16); auto output = outputs.at("res_to_bfyx").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); - EXPECT_EQ(output.get_layout().get_linear_size(), (size_t) 16); + EXPECT_EQ(output->get_layout().get_linear_size(), (size_t) 16); float answers[16] = { 1.0f, 1.5f, 2.0f, 2.0f, @@ -260,14 +257,14 @@ TEST(resample_gpu, basic_in1x1x2x2_interp_fsv32) { // f0: b0: 3 4 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); auto output_size = tensor(batch(1), feature(1), spatial(4, 4)); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reorder("input_to_fs_b_yx_fsv32", "input", format::fs_b_yx_fsv32, data_types::f16)); topology.add(resample("resample", "input_to_fs_b_yx_fsv32", output_size, {0, 0, 0, 0}, {0, 0, 0, 0}, 0, resample_type::bilinear)); topology.add(reorder("res_to_bfyx", "resample", format::bfyx, data_types::f32)); @@ -286,12 +283,12 @@ TEST(resample_gpu, basic_in1x1x2x2_interp_fsv32) { auto outputs = net.execute(); auto resample_out = outputs.at("resample").get_memory(); - ASSERT_EQ(resample_out.get_layout().format, format::fs_b_yx_fsv32); + ASSERT_EQ(resample_out->get_layout().format, format::fs_b_yx_fsv32); auto output = outputs.at("res_to_bfyx").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); - EXPECT_EQ(output.get_layout().get_linear_size(), (size_t) 16); + EXPECT_EQ(output->get_layout().get_linear_size(), (size_t) 16); float answers[16] = { 1.0f, 1.5f, 2.0f, 2.0f, @@ -319,14 +316,14 @@ TEST(resample_gpu, basic_in1x1x2x2_interp_align_1) { // f0: b0: 3 4 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); auto output_size = tensor(batch(1), feature(1), spatial(4, 4)); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(resample("upsampling", "input", output_size, {0, 0, 0, 0}, {0, 0, 0, 0}, 1, resample_type::bilinear)); set_values(input, { @@ -340,9 +337,9 @@ TEST(resample_gpu, basic_in1x1x2x2_interp_align_1) { auto outputs = net.execute(); auto output = outputs.at("upsampling").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); - EXPECT_EQ(output.get_layout().get_linear_size(), (size_t) 16); + EXPECT_EQ(output->get_layout().get_linear_size(), (size_t) 16); float answers[16] = { 1.000000f, 1.333333f, 1.666667f, 2.000000f, @@ -369,15 +366,15 @@ TEST(resample_gpu, nearest_asymmetric) { // f0: b0: 3 4 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); auto output_size = tensor(batch(1), feature(1), spatial(5, 4)); topology topology; uint32_t num_filter = 1u; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(resample("upsampling", "input", output_size, num_filter, resample_type::nearest)); set_values(input, { @@ -391,9 +388,9 @@ TEST(resample_gpu, nearest_asymmetric) { auto outputs = net.execute(); auto output = outputs.at("upsampling").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); - EXPECT_EQ(output.get_layout().get_linear_size(), (size_t)20); + EXPECT_EQ(output->get_layout().get_linear_size(), (size_t)20); float answers[20] = { 1.f, 1.f, 1.f, 2.f, 2.f, @@ -420,15 +417,15 @@ TEST(resample_gpu, nearest_asymmetric_i8) { // f0: b0: 3 4 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::i8, format::bfyx, { 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::i8, format::bfyx, { 1, 1, 2, 2 } }); auto output_size = tensor(batch(1), feature(1), spatial(5, 4)); topology topology; uint32_t num_filter = 1u; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(resample("upsampling", "input", output_size, num_filter, resample_type::nearest)); set_values(input, { @@ -442,9 +439,9 @@ TEST(resample_gpu, nearest_asymmetric_i8) { auto outputs = net.execute(); auto output = outputs.at("upsampling").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); - EXPECT_EQ(output.get_layout().get_linear_size(), (size_t)20); + EXPECT_EQ(output->get_layout().get_linear_size(), (size_t)20); int8_t answers[20] = { 1, 1, 1, 2, 2, @@ -471,15 +468,15 @@ TEST(resample_gpu, bilinear_asymmetric) { // f0: b0: 3 4 // - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); auto output_size = tensor(batch(1), feature(1), spatial(6, 4)); topology topology; uint32_t num_filter = 1u; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(resample("upsampling", "input", output_size, num_filter, resample_type::caffe_bilinear)); set_values(input, { @@ -493,9 +490,9 @@ TEST(resample_gpu, bilinear_asymmetric) { auto outputs = net.execute(); auto output = outputs.at("upsampling").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); - EXPECT_EQ(output.get_layout().get_linear_size(), (size_t)24); + EXPECT_EQ(output->get_layout().get_linear_size(), (size_t)24); float answers[24] = { 1.f, 1.f, 1.33333f, 1.66667f, 2.f, 2.f, @@ -525,21 +522,21 @@ struct resample_random_test_params { struct resample_random_test : testing::TestWithParam{ template - void fill_random_typed(memory& mem, int min, int max, int k) { - auto size = mem.get_layout().size; + void fill_random_typed(memory::ptr mem, int min, int max, int k) { + auto size = mem->get_layout().size; size_t b = size.batch[0]; size_t f = size.feature[0]; size_t x = size.spatial[0]; size_t y = size.spatial[1]; auto data = generate_random_4d(b, f, y, x, min, max, k); - auto ptr = mem.pointer(); + cldnn::mem_lock ptr(mem, get_test_stream()); for (size_t bi = 0; bi < b; ++bi) { for (size_t fi = 0; fi < f; ++fi) { for (size_t yi = 0; yi < y; ++yi) { for (size_t xi = 0; xi < x; ++xi) { auto coords = tensor(batch(bi), feature(fi), spatial(xi, yi, 0, 0)); - auto offset = mem.get_layout().get_linear_offset(coords); + auto offset = mem->get_layout().get_linear_offset(coords); ptr[offset] = data[bi][fi][yi][xi]; } } @@ -547,8 +544,8 @@ struct resample_random_test : testing::TestWithParamget_layout().data_type; switch (dt) { case data_types::f32: fill_random_typed(mem, -127, 127, 2); @@ -568,19 +565,19 @@ struct resample_random_test : testing::TestWithParam - void compare_nearest_typed(const memory& input, const memory& output, uint32_t align_corners) { - auto output_lay = output.get_layout(); + void compare_nearest_typed(const memory::ptr input, const memory::ptr output, uint32_t align_corners) { + auto output_lay = output->get_layout(); size_t b = output_lay.size.batch[0]; size_t f = output_lay.size.feature[0]; size_t x = output_lay.size.spatial[0]; size_t y = output_lay.size.spatial[1]; - size_t in_x = input.get_layout().size.spatial[0]; - size_t in_y = input.get_layout().size.spatial[1]; + size_t in_x = input->get_layout().size.spatial[0]; + size_t in_y = input->get_layout().size.spatial[1]; float x_ratio = x > align_corners ? static_cast(in_x - align_corners) / static_cast(x - align_corners) : 0.f; float y_ratio = y > align_corners ? static_cast(in_y - align_corners) / static_cast(y - align_corners) : 0.f; - auto in_ptr = input.pointer(); - auto out_ptr = output.pointer(); + cldnn::mem_lock in_ptr(input, get_test_stream()); + cldnn::mem_lock out_ptr(output, get_test_stream()); for (size_t bi = 0; bi < b; ++bi) { for (size_t fi = 0; fi < f; ++fi) { for (size_t yi = 0; yi < y; ++yi) { @@ -588,10 +585,10 @@ struct resample_random_test : testing::TestWithParam(floor(x_ratio * xi)); auto in_yi = static_cast(floor(y_ratio * yi)); auto in_coords = tensor(batch(bi), feature(fi), spatial(in_xi, in_yi, 0, 0)); - auto in_offset = input.get_layout().get_linear_offset(in_coords); + auto in_offset = input->get_layout().get_linear_offset(in_coords); auto in_val = in_ptr[in_offset]; auto out_coords = tensor(batch(bi), feature(fi), spatial(xi, yi, 0, 0)); - auto out_offset = output.get_layout().get_linear_offset(out_coords); + auto out_offset = output->get_layout().get_linear_offset(out_coords); auto out_val = out_ptr[out_offset]; EXPECT_EQ(in_val, out_val) << " at bi=" << bi << ", fi=" << fi << ", xi=" << xi << ", yi=" << yi; } @@ -601,20 +598,20 @@ struct resample_random_test : testing::TestWithParam - void compare_bilinear_typed(const memory& input, const memory& output, uint32_t align_corners) { - auto output_lay = output.get_layout(); + void compare_bilinear_typed(const memory::ptr input, const memory::ptr output, uint32_t align_corners) { + auto output_lay = output->get_layout(); size_t b = output_lay.size.batch[0]; size_t f = output_lay.size.feature[0]; size_t x = output_lay.size.spatial[0]; size_t y = output_lay.size.spatial[1]; - auto input_lay = input.get_layout(); + auto input_lay = input->get_layout(); size_t in_x = input_lay.size.spatial[0]; size_t in_y = input_lay.size.spatial[1]; float x_ratio = x > align_corners ? static_cast(in_x - align_corners) / static_cast(x - align_corners) : 0.f; float y_ratio = y > align_corners ? static_cast(in_y - align_corners) / static_cast(y - align_corners) : 0.f; - auto in_ptr = input.pointer(); - auto out_ptr = output.pointer(); + cldnn::mem_lock in_ptr(input, get_test_stream()); + cldnn::mem_lock out_ptr(output, get_test_stream()); for (size_t bi = 0; bi < b; ++bi) { for (size_t fi = 0; fi < f; ++fi) { for (size_t yi = 0; yi < y; ++yi) { @@ -658,8 +655,8 @@ struct resample_random_test : testing::TestWithParamget_layout().data_type; if (operation == resample_type::nearest) { // Nearest resampling implicitly ignores align_corners if (dt == data_types::f32) { @@ -691,7 +688,7 @@ struct resample_random_test : testing::TestWithParam { template - void fill_random_typed(memory& mem, int min, int max, int k) { - auto size = mem.get_layout().size; + void fill_random_typed(memory::ptr mem, int min, int max, int k) { + auto size = mem->get_layout().size; size_t b = size.batch[0]; size_t f = size.feature[0]; size_t x = size.spatial[0]; size_t y = size.spatial[1]; auto data = generate_random_4d(b, f, y, x, min, max, k); - auto ptr = mem.pointer(); + cldnn::mem_lock ptr(mem, get_test_stream()); for (size_t bi = 0; bi < b; ++bi) { for (size_t fi = 0; fi < f; ++fi) { for (size_t yi = 0; yi < y; ++yi) { for (size_t xi = 0; xi < x; ++xi) { auto coords = tensor(batch(bi), feature(fi), spatial(xi, yi, 0, 0)); - auto offset = mem.get_layout().get_linear_offset(coords); + auto offset = mem->get_layout().get_linear_offset(coords); ptr[offset] = data[bi][fi][yi][xi]; } } @@ -805,8 +802,8 @@ struct caffe_resample_random_test : testing::TestWithParamget_layout().data_type; switch (dt) { case data_types::f32: fill_random_typed(mem, -127, 127, 2); @@ -826,16 +823,16 @@ struct caffe_resample_random_test : testing::TestWithParam - bool compare_outputs(const memory& out_ref, const memory& out_opt) { - auto output_lay = out_ref.get_layout(); - auto opt_output_lay = out_opt.get_layout(); + bool compare_outputs(const memory::ptr out_ref, const memory::ptr out_opt) { + auto output_lay = out_ref->get_layout(); + auto opt_output_lay = out_opt->get_layout(); size_t b = output_lay.size.batch[0]; size_t f = output_lay.size.feature[0]; size_t x = output_lay.size.spatial[0]; size_t y = output_lay.size.spatial[1]; - auto ref_ptr = out_ref.pointer(); - auto opt_ptr = out_opt.pointer(); + cldnn::mem_lock ref_ptr(out_ref, get_test_stream()); + cldnn::mem_lock opt_ptr(out_opt, get_test_stream()); for (size_t bi = 0; bi < b; ++bi) { for (size_t fi = 0; fi < f; ++fi) { for (size_t yi = 0; yi < y; ++yi) { @@ -859,10 +856,10 @@ struct caffe_resample_random_test : testing::TestWithParamget_layout())); int32_t antialias = 0; float cube_coeff = -0.75f; resample_type mode = resample_type::nearest; @@ -1009,7 +1004,7 @@ TEST(resample_gpu, interpolate_in2x2x3x2_nearest1) { auto outputs = net.execute(); auto output = outputs.at("interpolate").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float answers[96] = { 0.f, 1.f, 1.f, 1.f, @@ -1058,19 +1053,19 @@ TEST(resample_gpu, interpolate_in2x2x3x2_nearest2) { // Output : 2x2x6x4 // Sample Type: Nearest - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); int b = 2; int f = 2; int y = 3; int x = 2; tensor shape = tensor{batch(b), feature(f), spatial(x, y)}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, shape }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, shape }); auto output_size = tensor(batch(b), feature(f), spatial(x*2, y*2)); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); int32_t antialias = 0; float cube_coeff = -0.75f; resample_type mode = resample_type::nearest; @@ -1098,7 +1093,7 @@ TEST(resample_gpu, interpolate_in2x2x3x2_nearest2) { auto outputs = net.execute(); auto output = outputs.at("interpolate").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float answers[96] = { 0.f, 0.f, 1.f, 1.f, @@ -1147,19 +1142,19 @@ TEST(resample_gpu, interpolate_in2x2x3x2_nearest3) { // Output : 2x2x6x4 // Sample Type: Nearest - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); int b = 2; int f = 2; int y = 3; int x = 2; tensor shape = tensor{batch(b), feature(f), spatial(x, y)}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, shape }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, shape }); auto output_size = tensor(batch(b), feature(f), spatial(x*2, y*2)); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); int32_t antialias = 0; float cube_coeff = -0.75f; resample_type mode = resample_type::nearest; @@ -1187,7 +1182,7 @@ TEST(resample_gpu, interpolate_in2x2x3x2_nearest3) { auto outputs = net.execute(); auto output = outputs.at("interpolate").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float answers[96] = { 0.f, 0.f, 1.f, 1.f, @@ -1236,19 +1231,19 @@ TEST(resample_gpu, interpolate_in2x2x3x2_nearest4) { // Output : 2x2x6x4 // Sample Type: Nearest - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); int b = 2; int f = 2; int y = 3; int x = 2; tensor shape = tensor{batch(b), feature(f), spatial(x, y)}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, shape }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, shape }); auto output_size = tensor(batch(b), feature(f), spatial(x*2, y*2)); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); int32_t antialias = 0; float cube_coeff = -0.75f; resample_type mode = resample_type::nearest; @@ -1276,7 +1271,7 @@ TEST(resample_gpu, interpolate_in2x2x3x2_nearest4) { auto outputs = net.execute(); auto output = outputs.at("interpolate").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float answers[96] = { 0.f, 0.f, 0.f, 1.f, @@ -1325,19 +1320,19 @@ TEST(resample_gpu, interpolate_in2x2x3x2_nearest5) { // Output : 2x2x6x4 // Sample Type: Nearest - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); int b = 2; int f = 2; int y = 3; int x = 2; tensor shape = tensor{batch(b), feature(f), spatial(x, y)}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, shape }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, shape }); auto output_size = tensor(batch(b), feature(f), spatial(x*2, y*2)); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); int32_t antialias = 0; float cube_coeff = -0.75f; resample_type mode = resample_type::nearest; @@ -1365,7 +1360,7 @@ TEST(resample_gpu, interpolate_in2x2x3x2_nearest5) { auto outputs = net.execute(); auto output = outputs.at("interpolate").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float answers[96] = { 0.f, 0.f, 0.f, 1.f, @@ -1414,21 +1409,21 @@ TEST(resample_gpu, interpolate_in2x2x3x2_coord_transform_mode1) { // Output : 2x2x6x4 // Sample Type: Nearest - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); int b = 2; int f = 2; int y = 3; int x = 2; tensor shape = tensor{batch(b), feature(f), spatial(x, y)}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, shape }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, shape }); y = 2; x = 3; auto output_size = tensor(batch(b), feature(f), spatial(x, y)); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); int32_t antialias = 0; float cube_coeff = -0.75f; resample_type mode = resample_type::nearest; @@ -1456,7 +1451,7 @@ TEST(resample_gpu, interpolate_in2x2x3x2_coord_transform_mode1) { auto outputs = net.execute(); auto output = outputs.at("interpolate").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 0.f, 0.f, 1.f, @@ -1483,21 +1478,21 @@ TEST(resample_gpu, interpolate_in2x2x3x2_coord_transform_mode2) { // Output : 2x2x6x4 // Sample Type: Nearest - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); int b = 2; int f = 2; int y = 3; int x = 2; tensor shape = tensor{batch(b), feature(f), spatial(x, y)}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, shape }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, shape }); y = 1; x = 3; auto output_size = tensor(batch(b), feature(f), spatial(x, y)); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); int32_t antialias = 0; float cube_coeff = -0.75f; resample_type mode = resample_type::nearest; @@ -1525,7 +1520,7 @@ TEST(resample_gpu, interpolate_in2x2x3x2_coord_transform_mode2) { auto outputs = net.execute(); auto output = outputs.at("interpolate").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 0.f, 0.f, 1.f, @@ -1546,21 +1541,21 @@ TEST(resample_gpu, interpolate_in2x2x3x2_coord_transform_mode3) { // Output : 2x2x6x4 // Sample Type: Nearest - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); int b = 2; int f = 2; int y = 3; int x = 2; tensor shape = tensor{batch(b), feature(f), spatial(x, y)}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, shape }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, shape }); y = 2; x = 3; auto output_size = tensor(batch(b), feature(f), spatial(x, y)); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); int32_t antialias = 0; float cube_coeff = -0.75f; resample_type mode = resample_type::nearest; @@ -1588,7 +1583,7 @@ TEST(resample_gpu, interpolate_in2x2x3x2_coord_transform_mode3) { auto outputs = net.execute(); auto output = outputs.at("interpolate").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 0.f, 1.f, 1.f, @@ -1615,21 +1610,21 @@ TEST(resample_gpu, interpolate_in2x2x3x2_coord_transform_mode4) { // Output : 2x2x6x4 // Sample Type: Nearest - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); int b = 2; int f = 2; int y = 3; int x = 2; tensor shape = tensor{batch(b), feature(f), spatial(x, y)}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, shape }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, shape }); y = 2; x = 3; auto output_size = tensor(batch(b), feature(f), spatial(x, y)); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); int32_t antialias = 0; float cube_coeff = -0.75f; resample_type mode = resample_type::nearest; @@ -1657,7 +1652,7 @@ TEST(resample_gpu, interpolate_in2x2x3x2_coord_transform_mode4) { auto outputs = net.execute(); auto output = outputs.at("interpolate").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 2.f, 3.f, 3.f, @@ -1684,21 +1679,21 @@ TEST(resample_gpu, interpolate_in2x2x3x2_coord_transform_mode5) { // Output : 2x2x6x4 // Sample Type: Nearest - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); int b = 2; int f = 2; int y = 3; int x = 2; tensor shape = tensor{batch(b), feature(f), spatial(x, y)}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, shape }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, shape }); y = 2; x = 3; auto output_size = tensor(batch(b), feature(f), spatial(x, y)); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); int32_t antialias = 0; float cube_coeff = -0.75f; resample_type mode = resample_type::nearest; @@ -1726,7 +1721,7 @@ TEST(resample_gpu, interpolate_in2x2x3x2_coord_transform_mode5) { auto outputs = net.execute(); auto output = outputs.at("interpolate").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 0.f, 0.f, 1.f, @@ -1753,21 +1748,21 @@ TEST(resample_gpu, interpolate_in2x2x3x2_cubic) { // Output : 2x2x6x4 // Sample Type: Nearest - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); int b = 2; int f = 2; int y = 3; int x = 2; tensor shape = tensor{batch(b), feature(f), spatial(x, y)}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, shape }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, shape }); y = 2; x = 3; auto output_size = tensor(batch(b), feature(f), spatial(x, y)); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); int32_t antialias = 0; float cube_coeff = -0.75f; resample_type mode = resample_type::cubic; @@ -1793,7 +1788,7 @@ TEST(resample_gpu, interpolate_in2x2x3x2_cubic) { auto outputs = net.execute(); auto output = outputs.at("interpolate").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 0.29600694f, 0.8828125f, 1.46961806f, @@ -1820,20 +1815,20 @@ TEST(resample_gpu, interpolate_in2x2x3x2_cubic2) { // Output : 2x2x6x4 // Sample Type: Nearest - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); int b = 1; int f = 1; int y = 3; int x = 2; tensor shape = tensor{batch(b), feature(f), spatial(x, y)}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, shape }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, shape }); x = 3; auto output_size = tensor(batch(b), feature(f), spatial(x, y)); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); int32_t antialias = 0; float cube_coeff = -0.75f; resample_type mode = resample_type::cubic; @@ -1853,7 +1848,7 @@ TEST(resample_gpu, interpolate_in2x2x3x2_cubic2) { auto outputs = net.execute(); auto output = outputs.at("interpolate").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 5.34722222f, 3.f, 0.65277778f, @@ -1872,21 +1867,21 @@ TEST(resample_gpu, interpolate_in2x2x3x2_linear) { // Output : 2x2x6x4 // Sample Type: Nearest - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); int b = 2; int f = 2; int y = 3; int x = 2; tensor shape = tensor{batch(b), feature(f), spatial(x, y)}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, shape }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, shape }); y = 2; x = 3; auto output_size = tensor(batch(b), feature(f), spatial(x, y)); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); int32_t antialias = 0; float cube_coeff = -0.75f; resample_type mode = resample_type::caffe_bilinear; @@ -1912,7 +1907,7 @@ TEST(resample_gpu, interpolate_in2x2x3x2_linear) { auto outputs = net.execute(); auto output = outputs.at("interpolate").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 0.5f, 1.f, 1.5f, @@ -1939,21 +1934,21 @@ TEST(resample_gpu, interpolate_in2x2x3x2_linear_onnx) { // Output : 2x2x6x4 // Sample Type: Nearest - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); int b = 1; int f = 1; int y = 2; int x = 2; tensor shape = tensor{batch(b), feature(f), spatial(x, y)}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, shape }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, shape }); y = 4; x = 4; auto output_size = tensor(batch(b), feature(f), spatial(x, y)); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); int32_t antialias = 0; float cube_coeff = -0.75f; resample_type mode = resample_type::bilinear; @@ -1974,7 +1969,7 @@ TEST(resample_gpu, interpolate_in2x2x3x2_linear_onnx) { auto outputs = net.execute(); auto output = outputs.at("interpolate").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 1.f, 1.33333f, 1.66667f, 2.f, @@ -1994,21 +1989,21 @@ TEST(resample_gpu, interpolate_in1x1x2x4_linear_scale) { // Output : 1x1x1x2 // Sample Type: Linear - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); int b = 1; int f = 1; int y = 2; int x = 4; tensor shape = tensor{batch(b), feature(f), spatial(x, y)}; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, shape }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, shape }); y = 1; x = 2; auto output_size = tensor(batch(b), feature(f), spatial(x, y)); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); int32_t antialias = 0; float cube_coeff = -0.75f; resample_type mode = resample_type::caffe_bilinear; @@ -2031,7 +2026,7 @@ TEST(resample_gpu, interpolate_in1x1x2x4_linear_scale) { auto outputs = net.execute(); auto output = outputs.at("interpolate").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector answers = { 2.6666665f, 4.3333331f diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/reshape_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/reshape_gpu_test.cpp index 69ad0f2be1f1af..ff35e58e75eb7f 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/reshape_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/reshape_gpu_test.cpp @@ -3,19 +3,15 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include -#include -#include -#include +#include "test_utils.h" -#include "test_utils/test_utils.h" +#include +#include +#include using namespace cldnn; -using namespace tests; +using namespace ::tests; using namespace testing; void verify_float(const float& output_value, const float& value) { @@ -30,7 +26,7 @@ template void generic_reshape_test(format fmt, tensor const& input_size, tensor const& reshape_size, bool /* in_place */, padding const& input_padd = padding(), padding const& output_padd = padding()) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); //allocate input memory auto data_type = data_types::f32; @@ -43,10 +39,10 @@ void generic_reshape_test(format fmt, tensor const& input_size, tensor const& re else if (std::is_same::value) data_type = data_types::i64; - auto input = memory::allocate(engine, {data_type, fmt, input_size}); + auto input = engine.allocate_memory({data_type, fmt, input_size}); { - auto input_ptr = input.cldnn::memory::pointer(); + cldnn::mem_lock input_ptr(input, get_test_stream()); auto input_itr = input_ptr.begin(); auto elements = input_size.count(); @@ -59,9 +55,9 @@ void generic_reshape_test(format fmt, tensor const& input_size, tensor const& re topology tpl; std::string reshape_input = "input"; - tpl.add(input_layout("input", input.get_layout())); + tpl.add(input_layout("input", input->get_layout())); if (input_padd) { - auto padded_input_layout = input.get_layout(); + auto padded_input_layout = input->get_layout(); padded_input_layout.data_padding = input_padd; tpl.add(reorder("reorder", "input", padded_input_layout)); reshape_input = "reorder"; @@ -79,15 +75,15 @@ void generic_reshape_test(format fmt, tensor const& input_size, tensor const& re auto net_input = outputs.at(reshape_input).get_memory(); auto output = outputs.at("reshape").get_memory(); - EXPECT_TRUE(output.get_layout().data_type == input.get_layout().data_type); //reshape should not change data_type - EXPECT_TRUE(output.get_layout().format.value == input.get_layout().format.value); //reshape should not change format + EXPECT_TRUE(output->get_layout().data_type == input->get_layout().data_type); //reshape should not change data_type + EXPECT_TRUE(output->get_layout().format.value == input->get_layout().format.value); //reshape should not change format //output size should be equal to requested plus output padding - ASSERT_TRUE(output.get_layout().size == reshape_size); - ASSERT_TRUE(output.get_layout().get_buffer_size() == reshape_size.add(output_padd.lower_size()).add(output_padd.upper_size())); + ASSERT_TRUE(output->get_layout().size == reshape_size); + ASSERT_TRUE(output->get_layout().get_buffer_size() == reshape_size.add(output_padd.lower_size()).add(output_padd.upper_size())); { - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); auto output_itr = output_ptr.begin(); auto sizes = reshape_size.sizes(fmt); @@ -439,15 +435,15 @@ TEST(reshape_gpu_f32, multiple_users_with_reorder) { // b1f0: 0.0 // b1f1: 4.0 - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 2; auto feature_num = 2; auto x_size = 1; auto y_size = 1; - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num))}}); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num))}}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(activation("relu", "input", activation_func::relu)); topology.add(reshape("reshape", "relu", tensor(batch(4)))); topology.add(reorder("reorder1", "reshape", format::yxfb, data_types::f32)); @@ -464,13 +460,13 @@ TEST(reshape_gpu_f32, multiple_users_with_reorder) { auto outputs = network.execute(); auto output = outputs.at("relu1").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < out1.size(); i++) EXPECT_EQ(output_ptr[i], out1[i]); auto output_2 = outputs.at("relu2").get_memory(); - auto output_ptr_2 = output_2.pointer(); + cldnn::mem_lock output_ptr_2(output_2, get_test_stream()); for (size_t i = 0; i < out2.size(); i++) EXPECT_EQ(output_ptr_2[i], out2[i]); @@ -487,12 +483,12 @@ TEST(reshape_gpu_f32, calc_output_shape) { // // output_shape (1, 1, 1, 4) - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {2, 2, 1, 1}}); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {2, 2, 1, 1}}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reshape("reshape", "input", tensor(1, 1, 0, -1))); set_values(input, {-1.f, 2.f, -3.f, 4.f}); @@ -506,14 +502,14 @@ TEST(reshape_gpu_f32, calc_output_shape) { auto output = outputs.at("reshape").get_memory(); - EXPECT_TRUE(output.get_layout().data_type == input.get_layout().data_type); - EXPECT_TRUE(output.get_layout().format == input.get_layout().format); + EXPECT_TRUE(output->get_layout().data_type == input->get_layout().data_type); + EXPECT_TRUE(output->get_layout().format == input->get_layout().format); - ASSERT_TRUE(output.get_layout().size == tensor(1, 1, 1, 4)); + ASSERT_TRUE(output->get_layout().size == tensor(1, 1, 1, 4)); float answers[4] = {-1.f, 2.f, -3.f, 4.f}; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 4; i++) { EXPECT_TRUE(are_equal(answers[i], output_ptr[i])); } @@ -523,12 +519,12 @@ TEST(reshape_gpu_f32, basic_bfwzyx) { // input: bfwzyx, (3, 3, 2, 2, 1, 1) // reshape: (1, 1, 2, 2, 3, 3), pad (0, 0, 0, 0, 0, 1) - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, layout{data_types::f32, format::bfwzyx, tensor{batch(3), feature(3), spatial(1, 1, 2, 2)}}); + auto input = engine.allocate_memory(layout{data_types::f32, format::bfwzyx, tensor{batch(3), feature(3), spatial(1, 1, 2, 2)}}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(reshape("reshape", "input", tensor(batch(1), feature(1), spatial(2, 2, 3, 3)), padding({0, 0, 0, 0, 0, 1}, 0.f))); // clang-format off @@ -573,10 +569,10 @@ TEST(reshape_gpu_f32, basic_bfwzyx) { auto output = outputs.at("reshape").get_memory(); - EXPECT_TRUE(output.get_layout().data_type == input.get_layout().data_type); - EXPECT_TRUE(output.get_layout().format == input.get_layout().format); + EXPECT_TRUE(output->get_layout().data_type == input->get_layout().data_type); + EXPECT_TRUE(output->get_layout().format == input->get_layout().format); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(output_ptr.size(), expected_out.size()); for (size_t i = 0; i < expected_out.size(); i++) { @@ -585,14 +581,14 @@ TEST(reshape_gpu_f32, basic_bfwzyx) { } TEST(reshape_gpu_f32, shrink_chain_partial) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 2; auto feature_num = 2; auto x_size = 1; auto y_size = 1; - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num))}}); - auto scale_in = memory::allocate(engine, {data_types::f32, format::bfyx, { tensor(feature(4)) }}); - auto shift_in = memory::allocate(engine, {data_types::f32, format::bfyx, { tensor(feature(4)) }}); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num))}}); + auto scale_in = engine.allocate_memory({data_types::f32, format::bfyx, { tensor(feature(4)) }}); + auto shift_in = engine.allocate_memory({data_types::f32, format::bfyx, { tensor(feature(4)) }}); std::vector scale_vals = {0.f, 1.f, 2.f, 3.f}; std::vector scale_shifts = {5.f, 10.f, 15.f, 20.0f}; @@ -600,7 +596,7 @@ TEST(reshape_gpu_f32, shrink_chain_partial) { set_values(shift_in, scale_shifts); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("scale_in", scale_in)); topology.add(data("shift_in", shift_in)); topology.add(activation("relu", "input", activation_func::relu)); @@ -621,17 +617,17 @@ TEST(reshape_gpu_f32, shrink_chain_partial) { auto outputs = network.execute(); auto output = outputs.at("out_reorder").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < out.size(); i++) EXPECT_EQ(output_ptr[i], out[i]) << " i=" << i; } TEST(reshape_gpu_f32, shrink_chain_full) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, { tensor(feature(4)) }}); - auto scale_in = memory::allocate(engine, {data_types::f32, format::bfyx, { tensor(feature(4)) }}); - auto shift_in = memory::allocate(engine, {data_types::f32, format::bfyx, { tensor(feature(4)) }}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, { tensor(feature(4)) }}); + auto scale_in = engine.allocate_memory({data_types::f32, format::bfyx, { tensor(feature(4)) }}); + auto shift_in = engine.allocate_memory({data_types::f32, format::bfyx, { tensor(feature(4)) }}); std::vector scale_vals = {0.f, 1.f, 2.f, 3.f}; std::vector scale_shifts = {5.f, 10.f, 15.f, 20.0f}; @@ -639,7 +635,7 @@ TEST(reshape_gpu_f32, shrink_chain_full) { set_values(shift_in, scale_shifts); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("scale_in", scale_in)); topology.add(data("shift_in", shift_in)); topology.add(activation("relu", "input", activation_func::relu)); @@ -660,17 +656,17 @@ TEST(reshape_gpu_f32, shrink_chain_full) { auto outputs = network.execute(); auto output = outputs.at("out_reorder").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < out.size(); i++) EXPECT_EQ(output_ptr[i], out[i]) << " i=" << i; } TEST(reshape_gpu_f32, shrink_chain_out) { - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, { tensor(feature(4)) }}); - auto scale_in = memory::allocate(engine, {data_types::f32, format::bfyx, { tensor(feature(4)) }}); - auto shift_in = memory::allocate(engine, {data_types::f32, format::bfyx, { tensor(feature(4)) }}); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, { tensor(feature(4)) }}); + auto scale_in = engine.allocate_memory({data_types::f32, format::bfyx, { tensor(feature(4)) }}); + auto shift_in = engine.allocate_memory({data_types::f32, format::bfyx, { tensor(feature(4)) }}); std::vector scale_vals = {0.f, 1.f, 2.f, 3.f}; std::vector scale_shifts = {5.f, 10.f, 15.f, 20.0f}; @@ -678,7 +674,7 @@ TEST(reshape_gpu_f32, shrink_chain_out) { set_values(shift_in, scale_shifts); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(activation("relu", "input", activation_func::relu)); topology.add(reshape("reshape", "relu", tensor(spatial(2, 2)))); topology.add(reorder("reorder", "reshape", format::bfyx, data_types::f32)); @@ -695,7 +691,7 @@ TEST(reshape_gpu_f32, shrink_chain_out) { auto outputs = network.execute(); auto output = outputs.at("reshape1").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < out.size(); i++) EXPECT_EQ(output_ptr[i], out[i]) << " i=" << i; diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/reverse_sequence_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/reverse_sequence_gpu_test.cpp index b7de3b16fa6d52..cb674704b29f75 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/reverse_sequence_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/reverse_sequence_gpu_test.cpp @@ -3,25 +3,22 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include -#include -#include +#include "test_utils.h" + +#include +#include #include -#include using namespace cldnn; using namespace ::tests; TEST(reverese_sequence_gpu_test, fp32_d2_2_ba1_sa0) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); - auto seq_lengths = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); + auto seq_lengths = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 1, 1, 1 } }); int32_t batch_axis = 1; int32_t seq_axis = 0; @@ -34,8 +31,8 @@ TEST(reverese_sequence_gpu_test, fp32_d2_2_ba1_sa0) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("seq_lengths", seq_lengths.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("seq_lengths", seq_lengths->get_layout())); topology.add( reverse_sequence("reverse_sequence", "input", "seq_lengths", seq_axis, batch_axis) ); @@ -48,7 +45,7 @@ TEST(reverese_sequence_gpu_test, fp32_d2_2_ba1_sa0) { auto outputs = network.execute(); auto output = outputs.at("reverse_sequence").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 3.0f, 2.0f, 1.0f @@ -60,10 +57,10 @@ TEST(reverese_sequence_gpu_test, fp32_d2_2_ba1_sa0) { } TEST(reverese_sequence_gpu_test, fp32_d3_3_3_ba0_sa1) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 3, 3, 1, 3 } }); - auto seq_lengths = memory::allocate(engine, { data_types::f32, format::bfyx, { 3, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 3, 3, 1, 3 } }); + auto seq_lengths = engine.allocate_memory({ data_types::f32, format::bfyx, { 3, 1, 1, 1 } }); int32_t batch_axis = 0; int32_t seq_axis = 1; @@ -78,8 +75,8 @@ TEST(reverese_sequence_gpu_test, fp32_d3_3_3_ba0_sa1) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("seq_lengths", seq_lengths.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("seq_lengths", seq_lengths->get_layout())); topology.add( reverse_sequence("reverse_sequence", "input", "seq_lengths", seq_axis, batch_axis) ); @@ -92,7 +89,7 @@ TEST(reverese_sequence_gpu_test, fp32_d3_3_3_ba0_sa1) { auto outputs = network.execute(); auto output = outputs.at("reverse_sequence").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 3.0f, 4.0f, 5.0f, 0.0f, 1.0f, 2.0f, 6.0f, 7.0f, 8.0f, @@ -106,10 +103,10 @@ TEST(reverese_sequence_gpu_test, fp32_d3_3_3_ba0_sa1) { } TEST(reverese_sequence_gpu_test, fp32_d3_3_3_ba2_sa0) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 3, 3, 1, 3 } }); - auto seq_lengths = memory::allocate(engine, { data_types::f32, format::bfyx, { 3, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 3, 3, 1, 3 } }); + auto seq_lengths = engine.allocate_memory({ data_types::f32, format::bfyx, { 3, 1, 1, 1 } }); int32_t batch_axis = 2; int32_t seq_axis = 0; @@ -124,8 +121,8 @@ TEST(reverese_sequence_gpu_test, fp32_d3_3_3_ba2_sa0) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("seq_lengths", seq_lengths.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("seq_lengths", seq_lengths->get_layout())); topology.add( reverse_sequence("reverse_sequence", "input", "seq_lengths", seq_axis, batch_axis) ); @@ -138,11 +135,11 @@ TEST(reverese_sequence_gpu_test, fp32_d3_3_3_ba2_sa0) { auto outputs = network.execute(); auto output = outputs.at("reverse_sequence").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { - 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, - 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, + 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f, 25.0f, 26.0f }; @@ -152,10 +149,10 @@ TEST(reverese_sequence_gpu_test, fp32_d3_3_3_ba2_sa0) { } TEST(reverese_sequence_gpu_test, fp32_d2_2_3_2ba0_sa3) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 3 } }); - auto seq_lengths = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 3 } }); + auto seq_lengths = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 1, 1, 1 } }); int32_t batch_axis = 0; int32_t seq_axis = 3; @@ -170,8 +167,8 @@ TEST(reverese_sequence_gpu_test, fp32_d2_2_3_2ba0_sa3) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("seq_lengths", seq_lengths.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("seq_lengths", seq_lengths->get_layout())); topology.add( reverse_sequence("reverse_sequence", "input", "seq_lengths", seq_axis, batch_axis) ); @@ -184,12 +181,12 @@ TEST(reverese_sequence_gpu_test, fp32_d2_2_3_2ba0_sa3) { auto outputs = network.execute(); auto output = outputs.at("reverse_sequence").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { - 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, - 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, - 13.0f, 12.0f, 15.0f, 14.0f, 17.0f, 16.0f, + 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, + 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, + 13.0f, 12.0f, 15.0f, 14.0f, 17.0f, 16.0f, 19.0f, 18.0f, 21.0f, 20.0f, 23.0f, 22.0f }; @@ -199,10 +196,10 @@ TEST(reverese_sequence_gpu_test, fp32_d2_2_3_2ba0_sa3) { } TEST(reverese_sequence_gpu_test, fp32_d2_2_3_2ba0_sa2) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 3 } }); - auto seq_lengths = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 3 } }); + auto seq_lengths = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 1, 1, 1 } }); int32_t batch_axis = 0; int32_t seq_axis = 2; @@ -217,8 +214,8 @@ TEST(reverese_sequence_gpu_test, fp32_d2_2_3_2ba0_sa2) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("seq_lengths", seq_lengths.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("seq_lengths", seq_lengths->get_layout())); topology.add( reverse_sequence("reverse_sequence", "input", "seq_lengths", seq_axis, batch_axis) ); @@ -231,12 +228,12 @@ TEST(reverese_sequence_gpu_test, fp32_d2_2_3_2ba0_sa2) { auto outputs = network.execute(); auto output = outputs.at("reverse_sequence").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { - 2.0f, 3.0f, 0.0f, 1.0f, 4.0f, 5.0f, - 8.0f, 9.0f, 6.0f, 7.0f, 10.0f, 11.0f, - 14.0f, 15.0f, 12.0f, 13.0f, 16.0f, 17.0f, + 2.0f, 3.0f, 0.0f, 1.0f, 4.0f, 5.0f, + 8.0f, 9.0f, 6.0f, 7.0f, 10.0f, 11.0f, + 14.0f, 15.0f, 12.0f, 13.0f, 16.0f, 17.0f, 20.0f, 21.0f, 18.0f, 19.0f, 22.0f, 23.0f }; @@ -246,10 +243,10 @@ TEST(reverese_sequence_gpu_test, fp32_d2_2_3_2ba0_sa2) { } TEST(reverese_sequence_gpu_test, fp32_d2_2_3_2ba2_sa0) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 3 } }); - auto seq_lengths = memory::allocate(engine, { data_types::f32, format::bfyx, { 3, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 3 } }); + auto seq_lengths = engine.allocate_memory({ data_types::f32, format::bfyx, { 3, 1, 1, 1 } }); int32_t batch_axis = 2; int32_t seq_axis = 0; @@ -264,8 +261,8 @@ TEST(reverese_sequence_gpu_test, fp32_d2_2_3_2ba2_sa0) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("seq_lengths", seq_lengths.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("seq_lengths", seq_lengths->get_layout())); topology.add( reverse_sequence("reverse_sequence", "input", "seq_lengths", seq_axis, batch_axis) ); @@ -278,12 +275,12 @@ TEST(reverese_sequence_gpu_test, fp32_d2_2_3_2ba2_sa0) { auto outputs = network.execute(); auto output = outputs.at("reverse_sequence").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { - 0.0f, 1.0f, 2.0f, 3.0f, 16.0f, 17.0f, - 6.0f, 7.0f, 8.0f, 9.0f, 22.0f, 23.0f, - 12.0f, 13.0f, 14.0f, 15.0f, 4.0f, 5.0f, + 0.0f, 1.0f, 2.0f, 3.0f, 16.0f, 17.0f, + 6.0f, 7.0f, 8.0f, 9.0f, 22.0f, 23.0f, + 12.0f, 13.0f, 14.0f, 15.0f, 4.0f, 5.0f, 18.0f, 19.0f, 20.0f, 21.0f, 10.0f, 11.0f }; @@ -293,10 +290,10 @@ TEST(reverese_sequence_gpu_test, fp32_d2_2_3_2ba2_sa0) { } TEST(reverese_sequence_gpu_test, fp16_d2_2_ba1_sa0) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); - auto seq_lengths = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); + auto seq_lengths = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 1, 1, 1 } }); int32_t batch_axis = 1; int32_t seq_axis = 0; @@ -309,8 +306,8 @@ TEST(reverese_sequence_gpu_test, fp16_d2_2_ba1_sa0) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("seq_lengths", seq_lengths.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("seq_lengths", seq_lengths->get_layout())); topology.add( reverse_sequence("reverse_sequence", "input", "seq_lengths", seq_axis, batch_axis) ); @@ -323,7 +320,7 @@ TEST(reverese_sequence_gpu_test, fp16_d2_2_ba1_sa0) { auto outputs = network.execute(); auto output = outputs.at("reverse_sequence").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 3.0f, 2.0f, 1.0f @@ -335,10 +332,10 @@ TEST(reverese_sequence_gpu_test, fp16_d2_2_ba1_sa0) { } TEST(reverese_sequence_gpu_test, fp16x2_d2_2_ba1_sa0) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); - auto seq_lengths = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); + auto seq_lengths = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); int32_t batch_axis = 1; int32_t seq_axis = 0; @@ -351,8 +348,8 @@ TEST(reverese_sequence_gpu_test, fp16x2_d2_2_ba1_sa0) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("seq_lengths", seq_lengths.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("seq_lengths", seq_lengths->get_layout())); topology.add( reverse_sequence("reverse_sequence", "input", "seq_lengths", seq_axis, batch_axis) ); @@ -365,7 +362,7 @@ TEST(reverese_sequence_gpu_test, fp16x2_d2_2_ba1_sa0) { auto outputs = network.execute(); auto output = outputs.at("reverse_sequence").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 3.0f, 2.0f, 1.0f @@ -377,10 +374,10 @@ TEST(reverese_sequence_gpu_test, fp16x2_d2_2_ba1_sa0) { } TEST(reverese_sequence_gpu_test, fp16_d3_3_3_ba0_sa1) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 3, 1, 3 } }); - auto seq_lengths = memory::allocate(engine, { data_types::f32, format::bfyx, { 3, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 3, 1, 3 } }); + auto seq_lengths = engine.allocate_memory({ data_types::f32, format::bfyx, { 3, 1, 1, 1 } }); int32_t batch_axis = 0; int32_t seq_axis = 1; @@ -395,8 +392,8 @@ TEST(reverese_sequence_gpu_test, fp16_d3_3_3_ba0_sa1) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("seq_lengths", seq_lengths.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("seq_lengths", seq_lengths->get_layout())); topology.add( reverse_sequence("reverse_sequence", "input", "seq_lengths", seq_axis, batch_axis) ); @@ -409,7 +406,7 @@ TEST(reverese_sequence_gpu_test, fp16_d3_3_3_ba0_sa1) { auto outputs = network.execute(); auto output = outputs.at("reverse_sequence").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 3.0f, 4.0f, 5.0f, 0.0f, 1.0f, 2.0f, 6.0f, 7.0f, 8.0f, @@ -423,10 +420,10 @@ TEST(reverese_sequence_gpu_test, fp16_d3_3_3_ba0_sa1) { } TEST(reverese_sequence_gpu_test, fp16_d3_3_3_ba2_sa0) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 3, 1, 3 } }); - auto seq_lengths = memory::allocate(engine, { data_types::f32, format::bfyx, { 3, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 3, 1, 3 } }); + auto seq_lengths = engine.allocate_memory({ data_types::f32, format::bfyx, { 3, 1, 1, 1 } }); int32_t batch_axis = 2; int32_t seq_axis = 0; @@ -441,8 +438,8 @@ TEST(reverese_sequence_gpu_test, fp16_d3_3_3_ba2_sa0) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("seq_lengths", seq_lengths.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("seq_lengths", seq_lengths->get_layout())); topology.add( reverse_sequence("reverse_sequence", "input", "seq_lengths", seq_axis, batch_axis) ); @@ -455,7 +452,7 @@ TEST(reverese_sequence_gpu_test, fp16_d3_3_3_ba2_sa0) { auto outputs = network.execute(); auto output = outputs.at("reverse_sequence").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, @@ -469,10 +466,10 @@ TEST(reverese_sequence_gpu_test, fp16_d3_3_3_ba2_sa0) { } TEST(reverese_sequence_gpu_test, fp16_d2_2_3_2ba0_sa3) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 2, 2, 3 } }); - auto seq_lengths = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 2, 2, 3 } }); + auto seq_lengths = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 1, 1, 1 } }); int32_t batch_axis = 0; int32_t seq_axis = 3; @@ -487,8 +484,8 @@ TEST(reverese_sequence_gpu_test, fp16_d2_2_3_2ba0_sa3) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("seq_lengths", seq_lengths.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("seq_lengths", seq_lengths->get_layout())); topology.add( reverse_sequence("reverse_sequence", "input", "seq_lengths", seq_axis, batch_axis) ); @@ -501,7 +498,7 @@ TEST(reverese_sequence_gpu_test, fp16_d2_2_3_2ba0_sa3) { auto outputs = network.execute(); auto output = outputs.at("reverse_sequence").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, @@ -516,10 +513,10 @@ TEST(reverese_sequence_gpu_test, fp16_d2_2_3_2ba0_sa3) { } TEST(reverese_sequence_gpu_test, fp16_d2_2_3_2ba0_sa2) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 2, 2, 3 } }); - auto seq_lengths = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 2, 2, 3 } }); + auto seq_lengths = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 1, 1, 1 } }); int32_t batch_axis = 0; int32_t seq_axis = 2; @@ -534,8 +531,8 @@ TEST(reverese_sequence_gpu_test, fp16_d2_2_3_2ba0_sa2) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("seq_lengths", seq_lengths.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("seq_lengths", seq_lengths->get_layout())); topology.add( reverse_sequence("reverse_sequence", "input", "seq_lengths", seq_axis, batch_axis) ); @@ -548,7 +545,7 @@ TEST(reverese_sequence_gpu_test, fp16_d2_2_3_2ba0_sa2) { auto outputs = network.execute(); auto output = outputs.at("reverse_sequence").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 2.0f, 3.0f, 0.0f, 1.0f, 4.0f, 5.0f, @@ -563,10 +560,10 @@ TEST(reverese_sequence_gpu_test, fp16_d2_2_3_2ba0_sa2) { } TEST(reverese_sequence_gpu_test, fp16_d2_2_3_2ba2_sa0) { - engine engine; + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 2, 2, 3 } }); - auto seq_lengths = memory::allocate(engine, { data_types::f32, format::bfyx, { 3, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 2, 2, 3 } }); + auto seq_lengths = engine.allocate_memory({ data_types::f32, format::bfyx, { 3, 1, 1, 1 } }); int32_t batch_axis = 2; int32_t seq_axis = 0; @@ -581,8 +578,8 @@ TEST(reverese_sequence_gpu_test, fp16_d2_2_3_2ba2_sa0) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("seq_lengths", seq_lengths.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("seq_lengths", seq_lengths->get_layout())); topology.add( reverse_sequence("reverse_sequence", "input", "seq_lengths", seq_axis, batch_axis) ); @@ -595,7 +592,7 @@ TEST(reverese_sequence_gpu_test, fp16_d2_2_3_2ba2_sa0) { auto outputs = network.execute(); auto output = outputs.at("reverse_sequence").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 1.0f, 2.0f, 3.0f, 16.0f, 17.0f, diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/scale_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/scale_gpu_test.cpp deleted file mode 100644 index 1e0359f1dada2e..00000000000000 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/scale_gpu_test.cpp +++ /dev/null @@ -1,1994 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include "api/scale.hpp" -#include -#include -#include -#include "test_utils/test_utils.h" -#include "api/reorder.hpp" -#include "api/data.hpp" - -#include - -using namespace cldnn; -using namespace tests; - -TEST(scale_gpu, basic_in2x3x2x2_mixed_types_in_fp32_out_fp16) { - const auto& engine = get_test_engine(); - - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 3, 2 } }); - auto scale_input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); - auto shift_input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 1, 1 } }); - - std::vector input_vec = { 1.0f, 0.0f, 5.0f, 1.5f, 2.0f, 0.0f, - 6.0f, 5.0f, -10.0f, -11.0f, -12.0f, -13.0f, - - 3.0f, 0.5f, 7.0f, 12.0f, 4.0f, -0.5f, - 8.0f, 8.0f, -14.0f, -15.0f, -16.0f, -17.0f }; - set_values(input, input_vec); - set_values(scale_input, { 2.0f, -1.0f }); - set_values(shift_input, { -5.0f, 10.0f }); - - std::vector result_vec = { -3.0f, -5.0f, 5.0f, -2.0f, -1.0f, -5.0f, - 4.0f, 5.0f, 20.0f, 21.0f, 22.0f, 23.0f, - - 1.0f, -4.0f, 9.0f, 19.0f , 3.0f, -6.0f, - 2.0f, 2.0f, 24.0f, 25.0f, 26.0f, 27.0f }; - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(data("scale_input", scale_input)); - topology.add(data("shift_input", shift_input)); - topology.add(scale("scale", "input", "scale_input", "shift_input", optional_data_type{data_types::f16})); - topology.add(reorder("reorder", "scale", format::bfyx, data_types::f32)); - - build_options bo; - bo.set_option(build_option::optimize_data(true)); - network network(engine, topology, bo); - - network.set_input_data("input", input); - - auto outputs = network.execute(); - - auto output = outputs.at("reorder").get_memory(); - auto output_ptr = output.pointer(); - - ASSERT_EQ(result_vec.size(), output.count()); - - for (unsigned int i = 0; i < result_vec.size(); ++i) { - EXPECT_NEAR(output_ptr[i], result_vec[i], 1e-05F); - } -} - -TEST(scale_gpu, basic_in2x3x2x2_mixed_types_in_fp16_out_fp32) { - const auto& engine = get_test_engine(); - - auto input = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 2, 3, 2 } }); - auto scale_input = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 2, 1, 1 } }); - auto shift_input = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 2, 1, 1 } }); - - std::vector input_vec = { half_t(1.0f), half_t(0.0f), half_t(5.0f), half_t(1.5f), half_t(2.0f), half_t(0.0f), - half_t(6.0f), half_t(5.0f), half_t(-10.0f), half_t(-11.0f), half_t(-12.0f), half_t(-13.0f), - - half_t(3.0f), half_t(0.5f), half_t( 7.0f), half_t(12.0f), half_t(4.0f), half_t(-0.5f), - half_t(8.0f), half_t(8.0f), half_t(-14.0f), half_t(-15.0f), half_t(-16.0f), half_t(-17.0f) }; - set_values(input, input_vec); - set_values(scale_input, { half_t(2.0f), half_t(-1.0f) }); - set_values(shift_input, { half_t(-5.0f), half_t(10.0f) }); - - std::vector result_vec = { -3.0f, -5.0f, 5.0f, -2.0f, -1.0f, -5.0f, - 4.0f, 5.0f, 20.0f, 21.0f, 22.0f, 23.0f, - - 1.0f, -4.0f, 9.0f, 19.0f , 3.0f, -6.0f, - 2.0f, 2.0f, 24.0f, 25.0f, 26.0f, 27.0f }; - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(data("scale_input", scale_input)); - topology.add(data("shift_input", shift_input)); - topology.add(scale("scale", "input", "scale_input", "shift_input", optional_data_type{data_types::f32})); - topology.add(reorder("reorder", "scale", format::bfyx, data_types::f32)); - - build_options bo; - bo.set_option(build_option::optimize_data(true)); - network network(engine, topology, bo); - - network.set_input_data("input", input); - - auto outputs = network.execute(); - - auto output = outputs.at("reorder").get_memory(); - auto output_ptr = output.pointer(); - - ASSERT_EQ(result_vec.size(), output.count()); - - for (unsigned int i = 0; i < result_vec.size(); ++i) { - EXPECT_NEAR(output_ptr[i], result_vec[i], 1e-05F); - } -} - -TEST(scale_gpu, basic_in2x3x2x2_mixed_types_in_fp32_scale_fp16_out_fp16) { - const auto& engine = get_test_engine(); - - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 3, 2 } }); - auto scale_input = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 2, 1, 1 } }); - auto shift_input = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 2, 1, 1 } }); - - std::vector input_vec = { 1.0f, 0.0f, 5.0f, 1.5f, 2.0f, 0.0f, - 6.0f, 5.0f, -10.0f, -11.0f, -12.0f, -13.0f, - - 3.0f, 0.5f, 7.0f, 12.0f, 4.0f, -0.5f, - 8.0f, 8.0f, -14.0f, -15.0f, -16.0f, -17.0f }; - set_values(input, input_vec); - set_values(scale_input, { half_t(2.0f), half_t(-1.0f) }); - set_values(shift_input, { half_t(-5.0f), half_t(10.0f) }); - - std::vector result_vec = { -3.0f, -5.0f, 5.0f, -2.0f, -1.0f, -5.0f, - 4.0f, 5.0f, 20.0f, 21.0f, 22.0f, 23.0f, - - 1.0f, -4.0f, 9.0f, 19.0f , 3.0f, -6.0f, - 2.0f, 2.0f, 24.0f, 25.0f, 26.0f, 27.0f }; - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(data("scale_input", scale_input)); - topology.add(data("shift_input", shift_input)); - topology.add(scale("scale", "input", "scale_input", "shift_input", optional_data_type{data_types::f16})); - topology.add(reorder("reorder", "scale", format::bfyx, data_types::f32)); - - build_options bo; - bo.set_option(build_option::optimize_data(true)); - network network(engine, topology, bo); - - network.set_input_data("input", input); - - auto outputs = network.execute(); - - auto output = outputs.at("reorder").get_memory(); - auto output_ptr = output.pointer(); - - ASSERT_EQ(result_vec.size(), output.count()); - - for (unsigned int i = 0; i < result_vec.size(); ++i) { - EXPECT_NEAR(output_ptr[i], result_vec[i], 1e-05F); - } -} - -TEST(scale_gpu, basic_in2x3x2x2_scale_same_size) { - // Scale : 2x3x2x2 - // Input : 2x3x2x2 - // Output : 2x3x2x2 - - // Input: - // f0: b0: 1 2 -10 b1: 0 0 -11 - // f0: b0: 3 4 -14 b1: 0.5 -0.5 -15 - // f1: b0: 5 6 -12 b1: 1.5 5.2 -13 - // f1: b0: 7 8 -16 b1: 12 8 -17 - // - // Scale: - // f0: b0: 0.1 0.2 0.25 b1: 0.3 0.4 0.5 - // f0: b0: 0.6 0.7 0.75 b1: 0.8 0.9 1 - // f1: b0: 1.1 1.2 1.25 b1: 1.3 1.4 1.5 - // f1: b0: 1.6 1.7 1.75 b1: 1.8 1.9 2 - - const auto& engine = get_test_engine(); - - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 3, 2 } }); - auto scale_input = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 3, 2 } }); - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("scale_input", scale_input.get_layout())); - topology.add(scale("scale", "input", "scale_input")); - - std::vector input_vec = { 1.f, 0.f, 5.f, 1.5f, - 2.f, 0.f, 6.f, 5.2f, - -10.f, -11.f, -12.f, -13.f, - 3.f, 0.5f, 7.f, 12.f, - 4.f, -0.5f, 8.f, 8.f, - -14.f, -15.f, -16.f, -17.f }; - set_values(input, input_vec); - - std::vector scale_input_vec = { - 0.1f, 0.3f, 1.1f, 1.3f, - 0.2f, 0.4f, 1.2f, 1.4f, - 0.25f, 0.5f, 1.25f, 1.5f, - 0.6f, 0.8f, 1.6f, 1.8f, - 0.7f, 0.9f, 1.7f, 1.9f, - 0.75f, 1.f, 1.75f, 2.f - }; - set_values(scale_input, scale_input_vec); - - network network(engine, topology); - - network.set_input_data("input", input); - network.set_input_data("scale_input", scale_input); - - auto outputs = network.execute(); - - auto output = outputs.at("scale").get_memory(); - auto output_ptr = output.pointer(); - - for (unsigned int i = 0; i < input_vec.size(); ++i) { - EXPECT_NEAR(output_ptr[i], input_vec[i] * scale_input_vec[i], 1e-05F); - } -} - -TEST(scale_gpu, basic_in2x3x2x2_scale_same_size_bfyx) { - // Scale : 2x3x2x2 - // Input : 2x3x2x2 - // Output : 2x3x2x2 - - // Input: - // f0: b0: 1 2 -10 b1: 0 0 -11 - // f0: b0: 3 4 -14 b1: 0.5 -0.5 -15 - // f1: b0: 5 6 -12 b1: 1.5 5.2 -13 - // f1: b0: 7 8 -16 b1: 12 8 -17 - // - // Scale: - // f0: b0: 0.1 0.2 0.25 b1: 0.3 0.4 0.5 - // f0: b0: 0.6 0.7 0.75 b1: 0.8 0.9 1 - // f1: b0: 1.1 1.2 1.25 b1: 1.3 1.4 1.5 - // f1: b0: 1.6 1.7 1.75 b1: 1.8 1.9 2 - - const auto& engine = get_test_engine(); - - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 3, 2 } }); - auto scale_input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 3, 2 } }); - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("scale_input", scale_input.get_layout())); - topology.add(scale("scale", "input", "scale_input")); - - std::vector input_vec = { - 1.f, 2.f, -10.f, 0.f, 0.f, -11.f, - 3.f, 4.f, -14.f, 0.5f, -0.5f, -15.f, - 5.f, 6.f, -12.f, 1.5f, 5.2f, -13.f, - 7.f, 8.f, -16.f, 12.f, 8.f, -17.f - }; - set_values(input, input_vec); - - std::vector scale_input_vec = { - 0.1f, 0.2f, 0.25f, 0.3f, 0.4f, 0.5f, - 0.6f, 0.7f, 0.75f, 0.8f, 0.9f, 1.f, - 1.1f, 1.2f, 1.25f, 1.3f, 1.4f, 1.5f, - 1.6f, 1.7f, 1.75f, 1.8f, 1.9f, 2.f - }; - set_values(scale_input, scale_input_vec); - - network network(engine, topology); - - network.set_input_data("input", input); - network.set_input_data("scale_input", scale_input); - - auto outputs = network.execute(); - - auto output = outputs.at("scale").get_memory(); - auto output_ptr = output.pointer(); - - for (unsigned int i = 0; i < input_vec.size(); ++i) { - EXPECT_NEAR(output_ptr[i], input_vec[i] * scale_input_vec[i], 1e-05F); - } -} - -TEST(scale_gpu, basic_in2x3x2x2_scale_same_size_scale_bfyx) { - // Scale : 2x3x2x2 - // Input : 2x3x2x2 - // Output : 2x3x2x2 - - // Input: - // f0: b0: 1 2 -10 b1: 0 0 -11 - // f0: b0: 3 4 -14 b1: 0.5 -0.5 -15 - // f1: b0: 5 6 -12 b1: 1.5 5.2 -13 - // f1: b0: 7 8 -16 b1: 12 8 -17 - // - // Scale: - // f0: b0: 0.1 0.2 0.25 b1: 0.3 0.4 0.5 - // f0: b0: 0.6 0.7 0.75 b1: 0.8 0.9 1 - // f1: b0: 1.1 1.2 1.25 b1: 1.3 1.4 1.5 - // f1: b0: 1.6 1.7 1.75 b1: 1.8 1.9 2 - - const auto& engine = get_test_engine(); - - auto batch_num = 2; - auto feature_num = 2; - auto x_size = 3; - auto y_size = 2; - - auto input = memory::allocate(engine, { data_types::f32,format::yxfb,{ batch_num, feature_num, x_size, y_size } }); - auto scale_input = memory::allocate(engine, { data_types::f32, format::bfyx,{ batch_num, feature_num, x_size, y_size } }); - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("scale_input", scale_input.get_layout())); - topology.add(scale("scale", "input", "scale_input")); - - std::vector input_vec = { 1.f, 0.f, 5.f, 1.5f, - 2.f, 0.f, 6.f, 5.2f, - -10.f, -11.f, -12.f, -13.f, - 3.f, 0.5f, 7.f, 12.f, - 4.f, -0.5f, 8.f, 8.f, - -14.f, -15.f, -16.f, -17.f }; - set_values(input, input_vec); - - std::vector scale_input_vec = { - 0.1f, 0.2f, 0.25f, 0.3f, 0.4f, 0.5f, - 0.6f, 0.7f, 0.75f, 0.8f, 0.9f, 1.f, - 1.1f, 1.2f, 1.25f, 1.3f, 1.4f, 1.5f, - 1.6f, 1.7f, 1.75f, 1.8f, 1.9f, 2.f - }; - set_values(scale_input, scale_input_vec); - - network network(engine, topology); - - network.set_input_data("input", input); - network.set_input_data("scale_input", scale_input); - - auto outputs = network.execute(); - - auto output = outputs.at("scale").get_memory(); - auto output_ptr = output.pointer(); - - for (int j = 0; j < feature_num; ++j) { //F - for (int i = 0; i < batch_num; ++i) { //B - for (int k = 0; k < y_size; ++k) { //Y - for (int l = 0; l < x_size; ++l) { //X - int linear_id = i + batch_num * (j + feature_num * (l + x_size * k)); - int linear_id_scale = l + x_size * (k + y_size * (j + i * feature_num)); - EXPECT_NEAR(output_ptr[linear_id], input_vec[linear_id] * scale_input_vec[linear_id_scale], 1e-05F); - } - } - } - } -} - -TEST(scale_gpu, basic_in2x3x2x2_scale_same_size_bias_term) { - // Scale : 2x3x2x2 - // Bias : 2x3x2x2 - // Input : 2x3x2x2 - // Output : 2x3x2x2 - - // Input: - // f0: b0: 1 2 -10 b1: 0 0 -11 - // f0: b0: 3 4 -14 b1: 0.5 -0.5 -15 - // f1: b0: 5 6 -12 b1: 1.5 5.2 -13 - // f1: b0: 7 8 -16 b1: 12 8 -17 - // - // Scale: - // f0: b0: 0.1 0.2 0.25 b1: 0.3 0.4 0.5 - // f0: b0: 0.6 0.7 0.75 b1: 0.8 0.9 1 - // f1: b0: 1.1 1.2 1.25 b1: 1.3 1.4 1.5 - // f1: b0: 1.6 1.7 1.75 b1: 1.8 1.9 2 - // - // Bias: - // f0: b0: 1.1 1.2 1.25 b1: 1.3 1.4 1.5 - // f0: b0: 2.6 2.7 2.75 b1: 2.8 2.9 2 - // f1: b0: 3.1 3.2 3.25 b1: 3.3 3.4 3.5 - // f1: b0: 4.6 4.7 4.75 b1: 4.8 4.9 4 - - const auto& engine = get_test_engine(); - - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 3, 2 } }); - auto scale_input = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 3, 2 } }); - auto bias = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 3, 2 } }); - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("scale_input", scale_input.get_layout())); - topology.add(input_layout("bias", bias.get_layout())); - topology.add(scale("scale", "input", "scale_input", "bias")); - - std::vector input_vec = { 1.f, 0.f, 5.f, 1.5f, - 2.f, 0.f, 6.f, 5.2f, - -10.f, -11.f, -12.f, -13.f, - 3.f, 0.5f, 7.f, 12.f, - 4.f, -0.5f, 8.f, 8.f, - -14.f, -15.f, -16.f, -17.f }; - set_values(input, input_vec); - - std::vector scale_input_vec = { - 0.1f, 0.3f, 1.1f, 1.3f, - 0.2f, 0.4f, 1.2f, 1.4f, - 0.25f, 0.5f, 1.25f, 1.5f, - 0.6f, 0.8f, 1.6f, 1.8f, - 0.7f, 0.9f, 1.7f, 1.9f, - 0.75f, 1.f, 1.75f, 2.f - }; - set_values(scale_input, scale_input_vec); - - std::vector bias_vec = { - 1.1f, 2.3f, 3.1f, 4.3f, - 1.2f, 2.4f, 3.2f, 4.4f, - 1.25f, 2.5f, 3.25f, 4.5f, - 1.6f, 2.8f, 3.6f, 4.8f, - 1.7f, 2.9f, 3.7f, 4.9f, - 1.75f, 2.f, 3.75f, 4.f - }; - set_values(bias, bias_vec); - - network network(engine, topology); - - network.set_input_data("input", input); - network.set_input_data("scale_input", scale_input); - network.set_input_data("bias", bias); - - auto outputs = network.execute(); - - auto output = outputs.at("scale").get_memory(); - auto output_ptr = output.pointer(); - - for (unsigned int i = 0; i < input_vec.size(); ++i) { - EXPECT_NEAR(output_ptr[i], input_vec[i] * scale_input_vec[i] + bias_vec[i], 1e-05F); - } -} - -TEST(scale_gpu, basic_in2x3x2x2_scale_scalar) { - // Scale : 1 - // Input : 2x3x2x2 - // Output : 2x3x2x2 - - // Input: - // f0: b0: 1 2 -10 b1: 0 0 -11 - // f0: b0: 3 4 -14 b1: 0.5 -0.5 -15 - // f1: b0: 5 6 -12 b1: 1.5 5.2 -13 - // f1: b0: 7 8 -16 b1: 12 8 -17 - // - // Scale: - // 0.1 0.2 - - const auto& engine = get_test_engine(); - - auto batch_num = 2; - auto feature_num = 2; - auto x_size = 3; - auto y_size = 2; - - auto input = memory::allocate(engine, { data_types::f32,format::yxfb,{ batch_num, feature_num, x_size, y_size } }); - auto scale_input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 1, 1 } }); - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("scale_input", scale_input.get_layout())); - topology.add(scale("scale", "input", "scale_input")); - - std::vector input_vec = { 1.f, 0.f, 5.f, 1.5f, - 2.f, 0.f, 6.f, 5.2f, - -10.f, -11.f, -12.f, -13.f, - 3.f, 0.5f, 7.f, 12.f, - 4.f, -0.5f, 8.f, 8.f, - -14.f, -15.f, -16.f, -17.f }; - set_values(input, input_vec); - - std::vector scale_input_vec = { - 0.1f, - }; - set_values(scale_input, scale_input_vec); - - network network(engine, topology); - - network.set_input_data("input", input); - network.set_input_data("scale_input", scale_input); - - auto outputs = network.execute(); - - auto output = outputs.at("scale").get_memory(); - auto output_ptr = output.pointer(); - - for (int j = 0; j < feature_num; ++j) { //F - for (int i = 0; i < batch_num; ++i) { //B - for (int k = 0; k < y_size; ++k) { //Y - for (int l = 0; l < x_size; ++l) { //X - int linear_id = i + batch_num * (j + feature_num * (l + x_size * k)); - int linear_id_scale = 0; - EXPECT_NEAR(output_ptr[linear_id], input_vec[linear_id] * scale_input_vec[linear_id_scale], 1e-05F); - } - } - } - } -} - -TEST(scale_gpu, basic_in2x3x2x2_scale_y) { - // Scale : 2 - // Input : 2x3x2x2 - // Output : 2x3x2x2 - - // Input: - // f0: b0: 1 2 -10 b1: 0 0 -11 - // f0: b0: 3 4 -14 b1: 0.5 -0.5 -15 - // f1: b0: 5 6 -12 b1: 1.5 5.2 -13 - // f1: b0: 7 8 -16 b1: 12 8 -17 - // - // Scale: - // 0.1 0.2 - - const auto& engine = get_test_engine(); - - auto batch_num = 2; - auto feature_num = 2; - auto x_size = 3; - auto y_size = 2; - - auto input = memory::allocate(engine, { data_types::f32,format::yxfb,{ batch_num, feature_num, x_size, y_size } }); - auto scale_input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1,1,1,y_size } }); - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("scale_input", scale_input.get_layout())); - topology.add(scale("scale", "input", "scale_input")); - - std::vector input_vec = { 1.f, 0.f, 5.f, 1.5f, - 2.f, 0.f, 6.f, 5.2f, - -10.f, -11.f, -12.f, -13.f, - 3.f, 0.5f, 7.f, 12.f, - 4.f, -0.5f, 8.f, 8.f, - -14.f, -15.f, -16.f, -17.f }; - set_values(input, input_vec); - - std::vector scale_input_vec = { - 0.1f, - 0.2f, - }; - set_values(scale_input, scale_input_vec); - - network network(engine, topology); - - network.set_input_data("input", input); - network.set_input_data("scale_input", scale_input); - - auto outputs = network.execute(); - - auto output = outputs.at("scale").get_memory(); - auto output_ptr = output.pointer(); - - for (int j = 0; j < feature_num; ++j) { //F - for (int i = 0; i < batch_num; ++i) { //B - for (int k = 0; k < y_size; ++k) { //Y - for (int l = 0; l < x_size; ++l) { //X - int linear_id = i + batch_num * (j + feature_num * (l + x_size * k)); - int linear_id_scale = k; - EXPECT_NEAR(output_ptr[linear_id], input_vec[linear_id] * scale_input_vec[linear_id_scale], 1e-05F); - } - } - } - } -} - -TEST(scale_gpu, basic_in2x3x2x2_scale_fb) { - // Scale : 2x3x2x2 - // Input : 2x3x2x2 - // Output : 2x3x2x2 - - // Input: - // f0: b0: 1 2 -10 b1: 0 0 -11 - // f0: b0: 3 4 -14 b1: 0.5 -0.5 -15 - // f1: b0: 5 6 -12 b1: 1.5 5.2 -13 - // f1: b0: 7 8 -16 b1: 12 8 -17 - // - // Scale: per feature per batch - // f0b0: 0.1 f0b1: 0.2 - // f1b0: 0.5 f1b1: 2.0 - - const auto& engine = get_test_engine(); - - auto batch_num = 2; - auto feature_num = 2; - auto x_size = 3; - auto y_size = 2; - - auto input = memory::allocate(engine, { data_types::f32,format::yxfb,{ batch_num, feature_num, x_size, y_size } }); - auto scale_input = memory::allocate(engine, { data_types::f32, format::yxfb,{ batch_num, feature_num, 1, 1 } }); - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("scale_input", scale_input.get_layout())); - topology.add(scale("scale", "input", "scale_input")); - - std::vector input_vec = { - 1.f, 0.f, 5.f, 1.5f, - 2.f, 0.f, 6.f, 5.2f, - -10.f, -11.f, -12.f, -13.f, - 3.f, 0.5f, 7.f, 12.f, - 4.f, -0.5f, 8.f, 8.f, - -14.f, -15.f, -16.f, -17.f }; - set_values(input, input_vec); - - std::vector scale_input_vec = { - 0.1f, 0.2f, 0.5f, 2.0f, - }; - set_values(scale_input, scale_input_vec); - - network network(engine, topology); - - network.set_input_data("input", input); - network.set_input_data("scale_input", scale_input); - - auto outputs = network.execute(); - - auto output = outputs.at("scale").get_memory(); - auto output_ptr = output.pointer(); - - for (int j = 0; j < feature_num; ++j) { //F - for (int i = 0; i < batch_num; ++i) { //B - for (int k = 0; k < y_size; ++k) { //Y - for (int l = 0; l < x_size; ++l) { //X - int linear_id = i + batch_num * (j + feature_num * (l + x_size * k)); - int linear_id_scale = i + feature_num * j; - EXPECT_NEAR(output_ptr[linear_id], input_vec[linear_id] * scale_input_vec[linear_id_scale], 1e-05F); - } - } - } - } -} - -TEST(scale_gpu, basic_in2x3x2x2_scale_f) { - // Scale : 2x3x2x2 - // Input : 2x3x2x2 - // Output : 2x3x2x2 - - // Input: - // f0: b0: 1 2 -10 b1: 0 0 -11 - // f0: b0: 3 4 -14 b1: 0.5 -0.5 -15 - // f1: b0: 5 6 -12 b1: 1.5 5.2 -13 - // f1: b0: 7 8 -16 b1: 12 8 -17 - // - // Scale: per feature - // f0bx: 0.1 f1bx: 0.2 - - const auto& engine = get_test_engine(); - - auto batch_num = 2; - auto feature_num = 2; - auto x_size = 3; - auto y_size = 2; - - auto input = memory::allocate(engine, { data_types::f32,format::yxfb,{ batch_num, feature_num, x_size, y_size } }); - auto scale_input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, feature_num, 1, 1 } }); - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("scale_input", scale_input.get_layout())); - topology.add(scale("scale", "input", "scale_input")); - - std::vector input_vec = { - 1.f, 0.f, 5.f, 1.5f, - 2.f, 0.f, 6.f, 5.2f, - -10.f, -11.f, -12.f, -13.f, - 3.f, 0.5f, 7.f, 12.f, - 4.f, -0.5f, 8.f, 8.f, - -14.f, -15.f, -16.f, -17.f }; - set_values(input, input_vec); - - std::vector scale_input_vec = { - //f0bx //f1bx - 0.1f, 0.2f - }; - set_values(scale_input, scale_input_vec); - - network network(engine, topology); - - network.set_input_data("input", input); - network.set_input_data("scale_input", scale_input); - - auto outputs = network.execute(); - - auto output = outputs.at("scale").get_memory(); - auto output_ptr = output.pointer(); - - for (int j = 0; j < feature_num; ++j) { //F - for (int i = 0; i < batch_num; ++i) { //B - for (int k = 0; k < y_size; ++k) { //Y - for (int l = 0; l < x_size; ++l) { //X - int linear_id = i + batch_num * (j + feature_num * (l + x_size * k)); - int linear_id_scale = j; - EXPECT_NEAR(output_ptr[linear_id], input_vec[linear_id] * scale_input_vec[linear_id_scale], 1e-05F); - } - } - } - } -} - -TEST(scale_gpu, basic_in2x3x2x2_scale_x) { - // Scale : 3 - // Input : 2x3x2x2 - // Output : 2x3x2x2 - - // Input: - // f0: b0: 1 2 -10 b1: 0 0 -11 - // f0: b0: 3 4 -14 b1: 0.5 -0.5 -15 - // f1: b0: 5 6 -12 b1: 1.5 5.2 -13 - // f1: b0: 7 8 -16 b1: 12 8 -17 - // - // Scale: - // 0.1 0.2 0.25 - - const auto& engine = get_test_engine(); - - auto batch_num = 2; - auto feature_num = 2; - auto x_size = 3; - auto y_size = 2; - - auto input = memory::allocate(engine, { data_types::f32,format::yxfb,{ batch_num, feature_num, x_size, y_size } }); - auto scale_input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 1, x_size, 1 } }); - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("scale_input", scale_input.get_layout())); - topology.add(scale("scale", "input", "scale_input")); - - std::vector input_vec = { 1.f, 0.f, 5.f, 1.5f, - 2.f, 0.f, 6.f, 5.2f, - -10.f, -11.f, -12.f, -13.f, - 3.f, 0.5f, 7.f, 12.f, - 4.f, -0.5f, 8.f, 8.f, - -14.f, -15.f, -16.f, -17.f }; - set_values(input, input_vec); - - std::vector scale_input_vec = { - 0.1f, - 0.2f, - 0.25f - }; - set_values(scale_input, scale_input_vec); - - network network(engine, topology); - - network.set_input_data("input", input); - network.set_input_data("scale_input", scale_input); - - auto outputs = network.execute(); - - auto output = outputs.at("scale").get_memory(); - auto output_ptr = output.pointer(); - - for (int j = 0; j < feature_num; ++j) { //F - for (int i = 0; i < batch_num; ++i) { //B - for (int k = 0; k < y_size; ++k) { //Y - for (int l = 0; l < x_size; ++l) { //X - int linear_id = i + batch_num * (j + feature_num * (l + x_size * k)); - int linear_id_scale = l; - EXPECT_NEAR(output_ptr[linear_id], input_vec[linear_id] * scale_input_vec[linear_id_scale], 1e-05F); - } - } - } - } -} - -TEST(scale_gpu, basic_in2x3x2x2_scale_xy) { - // Scale : 2x3x1x1 - // Input : 2x3x2x2 - // Output : 2x3x2x2 - - // Input: - // f0: b0: 1 2 -10 b1: 0 0 -11 - // f0: b0: 3 4 -14 b1: 0.5 -0.5 -15 - // f1: b0: 5 6 -12 b1: 1.5 5.2 -13 - // f1: b0: 7 8 -16 b1: 12 8 -17 - // - // Scale: - // f0: 0.1 0.2 0.25 - // f0: 0.6 0.7 0.75 - - const auto& engine = get_test_engine(); - - auto batch_num = 2; - auto feature_num = 2; - auto x_size = 3; - auto y_size = 2; - - auto input = memory::allocate(engine, { data_types::f32,format::yxfb,{ batch_num, feature_num, x_size, y_size } }); - auto scale_input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 1, x_size, y_size } }); - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("scale_input", scale_input.get_layout())); - topology.add(scale("scale", "input", "scale_input")); - - std::vector input_vec = { 1.f, 0.f, 5.f, 1.5f, - 2.f, 0.f, 6.f, 5.2f, - -10.f, -11.f, -12.f, -13.f, - 3.f, 0.5f, 7.f, 12.f, - 4.f, -0.5f, 8.f, 8.f, - -14.f, -15.f, -16.f, -17.f }; - set_values(input, input_vec); - - std::vector scale_input_vec = { - 0.1f, - 0.2f, - 0.25f, - 0.6f, - 0.7f, - 0.75f - }; - set_values(scale_input, scale_input_vec); - - network network(engine, topology); - - network.set_input_data("input", input); - network.set_input_data("scale_input", scale_input); - - auto outputs = network.execute(); - - auto output = outputs.at("scale").get_memory(); - auto output_ptr = output.pointer(); - - for (int j = 0; j < feature_num; ++j) { //F - for (int i = 0; i < batch_num; ++i) { //B - for (int k = 0; k < y_size; ++k) { //Y - for (int l = 0; l < x_size; ++l) { //X - int linear_id = i + batch_num * (j + feature_num * (l + x_size * k)); - int linear_id_scale = l + x_size * k; - EXPECT_NEAR(output_ptr[linear_id], input_vec[linear_id] * scale_input_vec[linear_id_scale], 1e-05F); - } - } - } - } -} - -TEST(scale_gpu, basic_in2x3x2x2_scale_batch1) { - // Scale : 2x3x2x1 - // Input : 2x3x2x2 - // Output : 2x3x2x2 - - // Input: - // f0: b0: 1 2 -10 b1: 0 0 -11 - // f0: b0: 3 4 -14 b1: 0.5 -0.5 -15 - // f1: b0: 5 6 -12 b1: 1.5 5.2 -13 - // f1: b0: 7 8 -16 b1: 12 8 -17 - // - // Scale: - // f0: b0: 0.1 0.2 0.25 - // f0: b0: 0.6 0.7 0.75 - // f1: b0: 1.1 1.2 1.25 - // f1: b0: 1.6 1.7 1.75 - - const auto& engine = get_test_engine(); - - auto batch_num = 2; - auto feature_num = 2; - auto x_size = 3; - auto y_size = 2; - - auto input = memory::allocate(engine, { data_types::f32,format::yxfb,{ batch_num, feature_num, x_size, y_size } }); - auto scale_input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, feature_num, x_size, y_size } }); - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("scale_input", scale_input.get_layout())); - topology.add(scale("scale", "input", "scale_input")); - - std::vector input_vec = { 1.f, 0.f, 5.f, 1.5f, - 2.f, 0.f, 6.f, 5.2f, - -10.f, -11.f, -12.f, -13.f, - 3.f, 0.5f, 7.f, 12.f, - 4.f, -0.5f, 8.f, 8.f, - -14.f, -15.f, -16.f, -17.f }; - set_values(input, input_vec); - - std::vector scale_input_vec = { - 0.1f, 1.1f, - 0.2f, 1.2f, - 0.25f, 1.25f, - 0.6f, 1.6f, - 0.7f, 1.7f, - 0.75f, 1.75f - }; - set_values(scale_input, scale_input_vec); - - network network(engine, topology); - - network.set_input_data("input", input); - network.set_input_data("scale_input", scale_input); - - auto outputs = network.execute(); - - auto output = outputs.at("scale").get_memory(); - auto output_ptr = output.pointer(); - - for (int j = 0; j < feature_num; ++j) { //F - for (int i = 0; i < batch_num; ++i) { //B - for (int k = 0; k < y_size; ++k) { //Y - for (int l = 0; l < x_size; ++l) { //X - int linear_id = i + batch_num * (j + feature_num * (l + x_size * k)); - int linear_id_scale = j + feature_num * (l + x_size * k); - EXPECT_NEAR(output_ptr[linear_id], input_vec[linear_id] * scale_input_vec[linear_id_scale], 1e-05F); - } - } - } - } -} - -TEST(scale_gpu, basic_in2x3_scale_same_size_bx) { - // Scale : 2x3 - // Bias : 2x3 - // Input : 2x3 - // Output : 2x3 - - // Input: - // b0: 1 2 -0.75 - // b1: 0 -1.5 -3 - // - // Scale: - // b0: 3.1 0.2 0.17 - // b1: 10 -3 1 - - // Bias: - // b0: -0.1 3.2 7 - // b1: 0 1 -1 - - const auto& engine = get_test_engine(); - - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 1, 3, 1 } }); - auto scale_input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 1, 3, 1 } }); - auto bias_input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 1, 3, 1 } }); - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("scale_input", scale_input.get_layout())); - topology.add(input_layout("bias_input", scale_input.get_layout())); - topology.add(scale("scale", "input", "scale_input", "bias_input")); - - std::vector input_vec = { - 1.f, 2.f, -0.75f, - 0.f, -1.5f, -3.f, - }; - set_values(input, input_vec); - - std::vector scale_vec = { - 3.1f, 0.2f, 0.17f, - 10.f, -3.f, 1.f, - }; - set_values(scale_input, scale_vec); - - std::vector bias_vec = { - -0.1f, 3.2f, 7.f, - 0.f, 1.f, -1.f, - }; - set_values(bias_input, bias_vec); - - network network(engine, topology); - - network.set_input_data("input", input); - network.set_input_data("scale_input", scale_input); - network.set_input_data("bias_input", bias_input); - - auto outputs = network.execute(); - - auto output = outputs.at("scale").get_memory(); - auto output_ptr = output.pointer(); - - for (unsigned int i = 0; i < input_vec.size(); ++i) { - EXPECT_NEAR(output_ptr[i], input_vec[i] * scale_vec[i] + bias_vec[i], 1e-05F); - } -} - -TEST(scale_gpu, basic_in2x3_scale_same_size_xb) { - // Scale : 2x3 - // Bias : 2x3 - // Input : 2x3 - // Output : 2x3 - - // Input: - // x0: 1 2 -0.75 - // x1: 0 -1.5 -3 - // - // Scale: - // x0: 3.1 0.2 0.17 - // x1: 10 -3 1 - - // Bias: - // x0: -0.1 3.2 7 - // x1: 0 1 -1 - - const auto& engine = get_test_engine(); - - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 3, 1, 2, 1 } }); - auto scale_input = memory::allocate(engine, { data_types::f32, format::yxfb, { 3, 1, 2, 1 } }); - auto bias_input = memory::allocate(engine, { data_types::f32, format::yxfb, { 3, 1, 2, 1 } }); - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("scale_input", scale_input.get_layout())); - topology.add(input_layout("bias_input", scale_input.get_layout())); - topology.add(scale("scale", "input", "scale_input", "bias_input")); - - std::vector input_vec = { - 1.f, 2.f, -0.75f, - 0.f, -1.5f, -3.f, - }; - set_values(input, input_vec); - - std::vector scale_vec = { - 3.1f, 0.2f, 0.17f, - 10.f, -3.f, 1.f, - }; - set_values(scale_input, scale_vec); - - std::vector bias_vec = { - -0.1f, 3.2f, 7.f, - 0.f, 1.f, -1.f, - }; - set_values(bias_input, bias_vec); - - network network(engine, topology); - - network.set_input_data("input", input); - network.set_input_data("scale_input", scale_input); - network.set_input_data("bias_input", bias_input); - - auto outputs = network.execute(); - - auto output = outputs.at("scale").get_memory(); - auto output_ptr = output.pointer(); - - for (unsigned int i = 0; i < input_vec.size(); ++i) { - EXPECT_NEAR(output_ptr[i], input_vec[i] * scale_vec[i] + bias_vec[i], 1e-05F); - } -} - -TEST(scale_gpu, basic_in2x3_scale_single_value_bx) { - // Scale : 1x1 - // Bias : 1x1 - // Input : 2x3 - // Output : 2x3 - - // Input: - // b0: 1 2 -0.75 - // b1: 0 -1.5 -3 - // - // Scale: - // 3.1 - - // Bias: - // -0.1 - - const auto& engine = get_test_engine(); - - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 1, 3, 1 } }); - auto scale_input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); - auto bias_input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("scale_input", scale_input.get_layout())); - topology.add(input_layout("bias_input", scale_input.get_layout())); - topology.add(scale("scale", "input", "scale_input", "bias_input")); - - std::vector input_vec = { - 1.f, 2.f, -0.75f, - 0.f, -1.5f, -3.f, - }; - set_values(input, input_vec); - - std::vector scale_vec = { - 3.1f, - }; - set_values(scale_input, scale_vec); - - std::vector bias_vec = { - -0.1f, - }; - set_values(bias_input, bias_vec); - - network network(engine, topology); - - network.set_input_data("input", input); - network.set_input_data("scale_input", scale_input); - network.set_input_data("bias_input", bias_input); - - auto outputs = network.execute(); - - auto output = outputs.at("scale").get_memory(); - auto output_ptr = output.pointer(); - - for (unsigned int i = 0; i < input_vec.size(); ++i) { - EXPECT_NEAR(output_ptr[i], input_vec[i] * scale_vec[0] + bias_vec[0], 1e-05F); - } -} - -TEST(scale_gpu, basic_in2x3_scale_single_value_xb) { - // Scale : 1x1 - // Bias : 1x1 - // Input : 2x3 - // Output : 2x3 - - // Input: - // x0: 1 2 -0.75 - // x1: 0 -1.5 -3 - // - // Scale: - // 3.1 - - // Bias: - // -0.1 - - const auto& engine = get_test_engine(); - - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 3, 1, 2, 1 } }); - auto scale_input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 1, 1 } }); - auto bias_input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 1, 1 } }); - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("scale_input", scale_input.get_layout())); - topology.add(input_layout("bias_input", scale_input.get_layout())); - topology.add(scale("scale", "input", "scale_input", "bias_input")); - - std::vector input_vec = { - 1.f, 2.f, -0.75f, - 0.f, -1.5f, -3.f, - }; - set_values(input, input_vec); - - std::vector scale_vec = { - 3.1f, - }; - set_values(scale_input, scale_vec); - - std::vector bias_vec = { - -0.1f, - }; - set_values(bias_input, bias_vec); - - network network(engine, topology); - - network.set_input_data("input", input); - network.set_input_data("scale_input", scale_input); - network.set_input_data("bias_input", bias_input); - - auto outputs = network.execute(); - - auto output = outputs.at("scale").get_memory(); - auto output_ptr = output.pointer(); - - for (unsigned int i = 0; i < input_vec.size(); ++i) { - EXPECT_NEAR(output_ptr[i], input_vec[i] * scale_vec[0] + bias_vec[0], 1e-05F); - } -} - -TEST(scale_gpu, basic_in2x3_scale_same_size_no_bias_bx) { - // Scale : 2x3 - // Input : 2x3 - // Output : 2x3 - - // Input: - // b0: 1 2 -0.75 - // b1: 0 -1.5 -3 - // - // Scale: - // b0: 3.1 0.2 0.17 - // b1: 10 -3 1 - - const auto& engine = get_test_engine(); - - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 1, 3, 1 } }); - auto scale_input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 1, 3, 1 } }); - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("scale_input", scale_input.get_layout())); - topology.add(scale("scale", "input", "scale_input")); - - std::vector input_vec = { - 1.f, 2.f, -0.75f, - 0.f, -1.5f, -3.f, - }; - set_values(input, input_vec); - - std::vector scale_vec = { - 3.1f, 0.2f, 0.17f, - 10.f, -3.f, 1.f, - }; - set_values(scale_input, scale_vec); - - network network(engine, topology); - - network.set_input_data("input", input); - network.set_input_data("scale_input", scale_input); - - auto outputs = network.execute(); - - auto output = outputs.at("scale").get_memory(); - auto output_ptr = output.pointer(); - - for (unsigned int i = 0; i < input_vec.size(); ++i) { - EXPECT_NEAR(output_ptr[i], input_vec[i] * scale_vec[i], 1e-05F); - } -} - -TEST(scale_gpu, basic_in2x3_scale_same_size_no_bias_xb) { - // Scale : 2x3 - // Input : 2x3 - // Output : 2x3 - - // Input: - // x0: 1 2 -0.75 - // x1: 0 -1.5 -3 - // - // Scale: - // x0: 3.1 0.2 0.17 - // x1: 10 -3 1 - - const auto& engine = get_test_engine(); - - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 3, 1, 2, 1 } }); - auto scale_input = memory::allocate(engine, { data_types::f32, format::yxfb, { 3, 1, 2, 1 } }); - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("scale_input", scale_input.get_layout())); - topology.add(scale("scale", "input", "scale_input")); - - std::vector input_vec = { - 1.f, 2.f, -0.75f, - 0.f, -1.5f, -3.f, - }; - set_values(input, input_vec); - - std::vector scale_vec = { - 3.1f, 0.2f, 0.17f, - 10.f, -3.f, 1.f, - }; - set_values(scale_input, scale_vec); - - network network(engine, topology); - - network.set_input_data("input", input); - network.set_input_data("scale_input", scale_input); - - auto outputs = network.execute(); - - auto output = outputs.at("scale").get_memory(); - auto output_ptr = output.pointer(); - - for (unsigned int i = 0; i < input_vec.size(); ++i) { - EXPECT_NEAR(output_ptr[i], input_vec[i] * scale_vec[i], 1e-05F); - } -} - -TEST(scale_gpu, basic_in2x3x2x2_scale_yxfb_bfyx_same_size_padding) { - // Scale : 2x2x1x1 - // Input : 2x2x1x1 - // Output : 2x2x1x1 - // Output Padding: 2x2 - // Input Padding: 2x1 (with reorder) - - // Input: - // 1 2 - // 3 4 - - // - // Scale: - // 0.1 0.2 - // 0.6 0.5 - - const auto& engine = get_test_engine(); - std::vector formats_to_test = { format::yxfb , format::bfyx }; - - for (std::vector::iterator it = formats_to_test.begin(); it != formats_to_test.end(); ++it) - { - std::cout << "Testing format: " << format::order(*it) << std::endl; - - tensor input_tensor(1, 1, 2, 2); - - auto input = memory::allocate(engine, { data_types::f32, *it, input_tensor }); - auto scale_input = memory::allocate(engine, { data_types::f32, *it, input_tensor }); - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(reorder("reorder", "input", input.get_layout().with_padding(padding{ { 0, 0, 1, 2 }, 0 }))); - topology.add(input_layout("scale_input", scale_input.get_layout())); - topology.add(scale("scale", "reorder", "scale_input", {}, padding( { 0, 0, 2, 2 }, 0 ))); - - std::vector input_vec = { 1.f, 2.f, 3.f, 4.f }; - set_values(input, input_vec); - - std::vector scale_input_vec = { 0.1f, 0.2f, 0.6f, 0.5f }; - set_values(scale_input, scale_input_vec); - - std::vector expected = { - 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, - 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, - 0.f, 0.f, 0.1f, 0.4f, 0.f, 0.f, - 0.f, 0.f, 1.8f, 2.0f, 0.f, 0.f, - 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, - 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, - }; - - network network(engine, topology); - - network.set_input_data("input", input); - network.set_input_data("scale_input", scale_input); - - auto outputs = network.execute(); - - auto output = outputs.at("scale").get_memory(); - auto output_ptr = output.pointer(); - - for (unsigned int i = 0; i < expected.size(); ++i) { - EXPECT_NEAR(output_ptr[i], expected[i], 1e-05F); - } - } -} - -TEST(scale_gpu, basic_in2x2x2x3x2_scale_same_size_bfzyx) { - // Scale : 2x2x2x3x2 - // Input : 2x2x2x3x2 - // Output : 2x2x2x3x2 - - const auto& engine = get_test_engine(); - - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 2, 2, 2, 3, 2 } }); - auto scale_input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 2, 2, 2, 3, 2 } }); - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("scale_input", scale_input.get_layout())); - topology.add(scale("scale", "input", "scale_input")); - - std::vector input_vec = { - 1.f, 2.f, -10.f, 0.f, 0.f, -11.f, - 3.f, 4.f, -14.f, 0.5f, -0.5f, -15.f, - 5.f, 6.f, -12.f, 1.5f, 5.2f, -13.f, - 7.f, 8.f, -16.f, 12.f, 8.f, -17.f, - 1.f, 2.f, -10.f, 0.f, 0.f, -11.f, - 3.f, 4.f, -14.f, 0.5f, -0.5f, -15.f, - 5.f, 6.f, -12.f, 1.5f, 5.2f, -13.f, - 7.f, 8.f, -16.f, 12.f, 8.f, -17.f - }; - set_values(input, input_vec); - - std::vector scale_input_vec = { - 0.1f, 0.2f, 0.25f, 0.3f, 0.4f, 0.5f, - 0.6f, 0.7f, 0.75f, 0.8f, 0.9f, 1.f, - 1.1f, 1.2f, 1.25f, 1.3f, 1.4f, 1.5f, - 1.6f, 1.7f, 1.75f, 1.8f, 1.9f, 2.f, - 0.1f, 0.2f, 0.25f, 0.3f, 0.4f, 0.5f, - 0.6f, 0.7f, 0.75f, 0.8f, 0.9f, 1.f, - 1.1f, 1.2f, 1.25f, 1.3f, 1.4f, 1.5f, - 1.6f, 1.7f, 1.75f, 1.8f, 1.9f, 2.f - }; - set_values(scale_input, scale_input_vec); - - network network(engine, topology); - - network.set_input_data("input", input); - network.set_input_data("scale_input", scale_input); - - auto outputs = network.execute(); - - auto output = outputs.at("scale").get_memory(); - auto output_ptr = output.pointer(); - - for (unsigned int i = 0; i < input_vec.size(); ++i) { - EXPECT_NEAR(output_ptr[i], input_vec[i] * scale_input_vec[i], 1e-05F); - } -} - -TEST(scale_gpu, basic_in2x2x2x2x3_scale_z) { - // Scale : 2 - // Input : 2x2x2x2x3 - // Output : 2x2x2x2x3 - - const auto& engine = get_test_engine(); - - auto batch_num = 2; - auto feature_num = 2; - auto z_size = 2; - auto y_size = 2; - auto x_size = 3; - - auto input = memory::allocate(engine, { data_types::f32,format::bfzyx,{ batch_num, feature_num, x_size, y_size, z_size } }); - auto scale_input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 1,1,1,1,z_size } }); - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("scale_input", scale_input.get_layout())); - topology.add(scale("scale", "input", "scale_input")); - - std::vector input_vec = { - 1.f, 0.f, 5.f, 1.5f, - 2.f, 0.f, 6.f, 5.2f, - -10.f, -11.f, -12.f, -13.f, - 3.f, 0.5f, 7.f, 12.f, - 4.f, -0.5f, 8.f, 8.f, - -14.f, -15.f, -16.f, -17.f, - 1.f, 0.f, 5.f, 1.5f, - 2.f, 0.f, 6.f, 5.2f, - -10.f, -11.f, -12.f, -13.f, - 3.f, 0.5f, 7.f, 12.f, - 4.f, -0.5f, 8.f, 8.f, - -14.f, -15.f, -16.f, -17.f - }; - set_values(input, input_vec); - - std::vector scale_input_vec = { - 0.1f, - 0.2f, - }; - set_values(scale_input, scale_input_vec); - - network network(engine, topology); - - network.set_input_data("input", input); - network.set_input_data("scale_input", scale_input); - - auto outputs = network.execute(); - - auto output = outputs.at("scale").get_memory(); - auto output_ptr = output.pointer(); - - for (int i = 0; i < batch_num; ++i) { //B - for (int j = 0; j < feature_num; ++j) { //F - for (int m = 0; m < z_size; ++m) { //Z - for (int k = 0; k < y_size; ++k) { //Y - for (int l = 0; l < x_size; ++l) { //X - int linear_id = l + x_size * (k + y_size * (m + z_size * (j + feature_num*i))); - int linear_id_scale = m; - EXPECT_NEAR(output_ptr[linear_id], input_vec[linear_id] * scale_input_vec[linear_id_scale], 1e-05F); - } - } - } - } - } -} - -TEST(scale_gpu, basic_in2x2x2x2x3_scale_xyz) { - // Scale : 1x1x2x2x3 - // Input : 2x2x2x2x3 - // Output : 2x2x2x2x3 - - const auto& engine = get_test_engine(); - - auto batch_num = 2; - auto feature_num = 2; - auto z_size = 2; - auto y_size = 2; - auto x_size = 3; - - auto input = memory::allocate(engine, { data_types::f32,format::bfzyx,{ batch_num, feature_num, x_size, y_size, z_size } }); - auto scale_input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 1,1, x_size, y_size, z_size } }); - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("scale_input", scale_input.get_layout())); - topology.add(scale("scale", "input", "scale_input")); - - std::vector input_vec = { - 1.f, 0.f, 5.f, 1.5f, - 2.f, 0.f, 6.f, 5.2f, - -10.f, -11.f, -12.f, -13.f, - 3.f, 0.5f, 7.f, 12.f, - 4.f, -0.5f, 8.f, 8.f, - -14.f, -15.f, -16.f, -17.f, - 1.f, 0.f, 5.f, 1.5f, - 2.f, 0.f, 6.f, 5.2f, - -10.f, -11.f, -12.f, -13.f, - 3.f, 0.5f, 7.f, 12.f, - 4.f, -0.5f, 8.f, 8.f, - -14.f, -15.f, -16.f, -17.f - }; - set_values(input, input_vec); - - std::vector scale_input_vec = { - 0.1f, - 0.2f, - 0.25f, - 0.6f, - 0.7f, - 0.75f, - 0.1f, - 0.2f, - 0.25f, - 0.6f, - 0.7f, - 0.75f - }; - set_values(scale_input, scale_input_vec); - - network network(engine, topology); - - network.set_input_data("input", input); - network.set_input_data("scale_input", scale_input); - - auto outputs = network.execute(); - - auto output = outputs.at("scale").get_memory(); - auto output_ptr = output.pointer(); - - for (int i = 0; i < batch_num; ++i) { //B - for (int j = 0; j < feature_num; ++j) { //F - for (int m = 0; m < z_size; ++m) { //Z - for (int k = 0; k < y_size; ++k) { //Y - for (int l = 0; l < x_size; ++l) { //X - int linear_id = l + x_size * (k + y_size * (m + z_size * (j + feature_num*i))); - int linear_id_scale = l + x_size * (k + y_size * m); - EXPECT_NEAR(output_ptr[linear_id], input_vec[linear_id] * scale_input_vec[linear_id_scale], 1e-05F); - } - } - } - } - } -} - -TEST(scale_gpu, basic_in2x2x2x2x2x3_scale_4d) { - // Scale : 1x2x1x1 - // Input : 2x2x2x2x2x3 - // Output : 2x2x2x2x2x3 - - const auto& engine = get_test_engine(); - - auto batch_num = 2; - auto feature_num = 2; - auto w_size = 2; - auto z_size = 2; - auto y_size = 2; - auto x_size = 3; - - tensor in_size = tensor(format::bfwzyx, { batch_num, feature_num, x_size, y_size, z_size, w_size }); - tensor scale_size = tensor(format::bfyx, { 1, feature_num, 1, 1 }); - - auto input = memory::allocate(engine, { data_types::f32, format::bfwzyx, in_size}); - auto scale_input = memory::allocate(engine, { data_types::f32, format::bfyx, scale_size }); - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("scale_input", scale_input.get_layout())); - topology.add(scale("scale", "input", "scale_input")); - - std::vector input_vec = generate_random_1d(in_size.count(), -10, 10); - set_values(input, input_vec); - - std::vector scale_input_vec = generate_random_1d(scale_input.count(), -10, 10); - set_values(scale_input, scale_input_vec); - - network network(engine, topology); - - network.set_input_data("input", input); - network.set_input_data("scale_input", scale_input); - - auto outputs = network.execute(); - - auto output = outputs.at("scale").get_memory(); - auto output_ptr = output.pointer(); - - for (int b = 0; b < batch_num; ++b) { - for (int f = 0; f < feature_num; ++f) { - for (int w = 0; w < w_size; ++w) { - for (int z = 0; z < z_size; ++z) { - for (int y = 0; y < y_size; ++y) { - for (int x = 0; x < x_size; ++x) { - int linear_id = x + x_size * (y + y_size * (z + z_size * (w + w_size * (f + feature_num * b)))); - int linear_id_scale = f; - EXPECT_NEAR(output_ptr[linear_id], input_vec[linear_id] * scale_input_vec[linear_id_scale], 1e-05f); - } - } - } - } - } - } -} - -TEST(scale_gpu, basic_in2x2x2x2x2x3_scale_6d) { - // Scale : 1x2x1x1x1x1 - // Input : 2x2x2x2x2x3 - // Output : 2x2x2x2x2x3 - - const auto& engine = get_test_engine(); - - auto batch_num = 2; - auto feature_num = 2; - auto w_size = 2; - auto z_size = 2; - auto y_size = 2; - auto x_size = 3; - - tensor in_size = tensor(format::bfwzyx, { batch_num, feature_num, x_size, y_size, z_size, w_size }); - tensor scale_size = tensor(format::bfwzyx, { 1, feature_num, 1, 1, 1, 1 }); - - auto input = memory::allocate(engine, { data_types::f32, format::bfwzyx, in_size}); - auto scale_input = memory::allocate(engine, { data_types::f32, format::bfwzyx, scale_size }); - - topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("scale_input", scale_input.get_layout())); - topology.add(scale("scale", "input", "scale_input")); - - std::vector input_vec = generate_random_1d(in_size.count(), -10, 10); - set_values(input, input_vec); - - std::vector scale_input_vec = generate_random_1d(scale_input.count(), -10, 10); - set_values(scale_input, scale_input_vec); - - network network(engine, topology); - - network.set_input_data("input", input); - network.set_input_data("scale_input", scale_input); - - auto outputs = network.execute(); - - auto output = outputs.at("scale").get_memory(); - auto output_ptr = output.pointer(); - - for (int b = 0; b < batch_num; ++b) { - for (int f = 0; f < feature_num; ++f) { - for (int w = 0; w < w_size; ++w) { - for (int z = 0; z < z_size; ++z) { - for (int y = 0; y < y_size; ++y) { - for (int x = 0; x < x_size; ++x) { - int linear_id = x + x_size * (y + y_size * (z + z_size * (w + w_size * (f + feature_num * b)))); - int linear_id_scale = f; - EXPECT_NEAR(output_ptr[linear_id], input_vec[linear_id] * scale_input_vec[linear_id_scale], 1e-05f); - } - } - } - } - } - } -} - -////////////////////////////////////////////////////////////////////////////// -// // -// Exhaustive Negative Matrix tests // -// // -////////////////////////////////////////////////////////////////////////////// - -//TODO: this should be done using TEST_P or some equivallent construct -static network setup_scale_network( - const data_types dt, - const tensor input_tensor, - const tensor scale_tensor, - const tensor bias_tensor, - const format f, - const format of, - bool pass_bias //TODO: a WA for lack of std::optional bias -) -{ - const auto& engine = get_test_engine(); - topology topology; - - auto input_mem = memory::allocate(engine, { dt, f, input_tensor }); - auto scale_mem = memory::allocate(engine, { dt, of, scale_tensor }); - topology.add(input_layout("input", input_mem.get_layout())); - topology.add(input_layout("scale_input", scale_mem.get_layout())); - - if (pass_bias) - { - auto bias_mem = memory::allocate(engine, { dt, f, bias_tensor }); - topology.add(input_layout("bias_input", bias_mem.get_layout())); - - topology.add(scale("scale", "input", "scale_input", "bias_input" )); - } - else - { - topology.add(scale("scale", "input", "scale_input")); - } -//TODO: this will be supported after the API change -// else -// { -// assert(!pass_bias); -// -// topology.add(scale("scale", "input", "scale_input")); -// } - - return network(engine, topology); -} - -TEST(NegativeScaleTest, TestAll) { - auto d = data_types::f32; - auto f = format::bfyx; - auto of = format::yxfb; - - std::vector t { 3, 4, 5, 6 }; - std::vector t2 { 5, 6, 4, 3 }; - - // broadcast rules mean that either the dim size is equal to input dim or is 1 - std::vector> good_ts = - { - { 1, 4, 5, 6 }, { 3, 1, 5, 6 }, { 3, 4, 1, 6 }, { 3, 4, 5, 1 }, - { 1, 1, 5, 6 }, { 1, 4, 1, 6 }, { 1, 4, 5, 1 }, { 3, 1, 1, 6 }, { 3, 1, 5, 1 }, { 3, 4, 1, 1 }, - { 1, 1, 1, 6 }, { 1, 1, 5, 1 }, { 1, 4, 1, 1 }, { 3, 1, 1, 1 } - }; - std::vector> bad_ts = { { 2, 4, 5, 6 }, { 3, 2, 5, 6 }, { 3, 4, 2, 6 }, { 3, 4, 5, 2 } }; - - //TODO: should be ASSERT_THROW(statement, exception_type) - but what exception type? - ASSERT_ANY_THROW(setup_scale_network(d, tensor{ }, tensor{ }, tensor{ }, f, of, false)); - ASSERT_ANY_THROW(setup_scale_network(d, tensor{ }, tensor{ }, tensor{ }, f, of, true)); - - ASSERT_ANY_THROW(setup_scale_network(d, tensor(t), tensor(t2), tensor(t), f, of, true)); - ASSERT_ANY_THROW(setup_scale_network(d, tensor(t), tensor(t2), tensor(t), f, of, false)); - - // make sure that it's the input that's masked in the scale/bias with a "1", not ther other way around - for (const auto & good : good_ts) - { - ASSERT_ANY_THROW(setup_scale_network(d, tensor(good), tensor(t), tensor(t), f, of, true)); - } - - // sizes must either be equal to input or at most have - for (const auto & bad : bad_ts) - { - ASSERT_ANY_THROW(setup_scale_network(d, tensor(t), tensor(bad), tensor(t), f, of, true)); - ASSERT_ANY_THROW(setup_scale_network(d, tensor(t), tensor(t), tensor(bad), f, of, true)); - - for (const auto & good : good_ts) - { - ASSERT_ANY_THROW(setup_scale_network(d, tensor(t), tensor(bad), tensor(good), f, of, true)); - ASSERT_ANY_THROW(setup_scale_network(d, tensor(t), tensor(good), tensor(bad), f, of, true)); - } - } - - // we expect the broadcast mask to be identical for scale and bias, when present - for (unsigned i = 0; i < good_ts.size(); ++i) - for (unsigned j = 0; j < good_ts.size(); ++j) - if (i != j) - { - ASSERT_ANY_THROW(setup_scale_network(d, tensor(t), tensor(good_ts[i]), tensor(good_ts[j]), f, of, true)); - } - -} - -////////////////////////////////////////////////////////////////////////////// -// // -// Exhaustive Positive Matrix tests // -// // -////////////////////////////////////////////////////////////////////////////// - -using namespace cldnn; - -class scale_test : public tests::generic_test -{ -public: - static void TearDownTestCase() - { - all_generic_params.clear(); - all_layer_params.clear(); - } - - //TODO: use an enum instead of int i - static std::vector> generate_specific_test_params(int variant) - { - std::vector> all_layer_params; - - switch(variant) - { - case 0: all_layer_params.emplace_back(new scale("scale", "input0", "input1")); break; - case 1: all_layer_params.emplace_back(new scale("scale", "input0", "input1", "input2")); break; - // case 3: all_layer_params.push_back(new scale("scale", "input0", "input1", true)); // This case should be checked by negative_scale_test - // case 4: all_layer_params.push_back(new scale("scale", "input0", "input1", false)); // This case should be checked by negative_scale_test - default: assert(0); - } - - return all_layer_params; - } - - static std::vector> generate_generic_test_params(int variant) - { - assert(!variant || variant == 1); - - std::vector> all_generic_params; - - auto data_types = test_data_types(); - - for (cldnn::data_types dt : data_types) - for (tensor & t : test_input_sizes) - { - std::vector> attempted_dims; - - for (int32_t b : test_batch_sizes) - for (auto f : test_feature_sizes) - for (int mask = 0; mask < 16; ++mask) //TODO: do we want to restrict it to some smaller subset like for (auto mask : { 0, 1, 3, 7, 15, 5, 10})? the problem is that because of the layout we might miss some interesting combinations since this is effectively hardcoded int he kernels - { - const int w = t.spatial[0]; - const int h = t.spatial[1]; - - const auto mb = mask & 0x8 ? b : 1; - const auto mf = mask & 0x4 ? f : 1; - const auto mh = mask & 0x2 ? h : 1; - const auto mw = mask & 0x1 ? w : 1; - - // avoid adding test cases with different masks leading to the same dimensions - if(attempted_dims.end() == std::find_if(attempted_dims.begin(), attempted_dims.end(), [=](const std::vector & arr) { return arr[0] == mb && arr[1] == mf && arr[2] == mh && arr[3] == mw; })) - { - std::vector tmp { mb, mf, mh, mw }; - attempted_dims.push_back(tmp); - - std::shared_ptr tp = std::make_shared(); - tp->data_type = dt; - - tp->input_layouts.push_back(cldnn::layout(tp->data_type, tp->fmt, cldnn::tensor( b, f, w, h ))); - tp->input_layouts.push_back(cldnn::layout(tp->data_type, tp->fmt, cldnn::tensor( mb, mf, mw, mh ))); - if (variant) - tp->input_layouts.push_back(cldnn::layout(tp->data_type, tp->fmt, cldnn::tensor( mb, mf, mw, mh ))); - - all_generic_params.emplace_back(tp); - } - } - } - - return all_generic_params; - } - - static std::vector, std::shared_ptr>> generate_all_test_params() - { - std::vector, std::shared_ptr>> res; - - for (int variant = 0; variant <= 1; ++variant) - { - auto tpv = generate_generic_test_params(variant); - auto pv = generate_specific_test_params(variant); - - for (auto & tp : tpv) - all_generic_params.emplace_back(tp); - - for (auto & p : pv) - all_layer_params.emplace_back(p); - - for (auto & tp : tpv) - for (auto & p: pv) - res.emplace_back(tp, p); - } - - return res; - } - - virtual bool is_format_supported(cldnn::format format) override - { - return format == cldnn::format::bfyx; - } - - template - memory generate_reference_typed(const std::vector & inputs) - { - assert(inputs.size() == 3 || inputs.size() == 2); - const bool bias_input_present = inputs.size() == 3; - - const memory & input = inputs[0]; - const memory & scale = inputs[1]; - const memory * bias = bias_input_present ? &inputs[2] : nullptr; - assert(!bias_input_present || bias); - - //Output is bfyx - auto output = memory::allocate(engine, cldnn::layout(input.get_layout().data_type, cldnn::format::bfyx, input.get_layout().size )); - - const auto in0_mem = input.pointer(); - const auto in1_mem = scale.pointer(); - const auto in2_mem_ptr = bias ? std::make_shared>(*bias) : nullptr; - const Type * const in2_mem = in2_mem_ptr ? in2_mem_ptr->data() : nullptr; //TODO: is the condition needed or is it nullptr anyway? - auto out_mem = output.pointer(); - - const auto input_sizes = input.get_layout().size.sizes(cldnn::format::bfyx); - - const int in0_b = input_sizes[0]; - const int in0_f = input_sizes[1]; - const int in0_h = input_sizes[2]; - const int in0_w = input_sizes[3]; - - { // asserting dims - const auto output_sizes = output.get_layout().size.sizes(cldnn::format::bfyx); - const int out_b = output_sizes[0]; (void) out_b; - const int out_f = output_sizes[1]; (void) out_f; - const int out_h = output_sizes[2]; (void) out_h; - const int out_w = output_sizes[3]; (void) out_w; - - const auto scale_sizes = scale.get_layout().size.sizes(cldnn::format::bfyx); - const int in1_b = scale_sizes[0]; (void) in1_b; - const int in1_f = scale_sizes[1]; (void) in1_f; - const int in1_h = scale_sizes[2]; (void) in1_h; - const int in1_w = scale_sizes[3]; (void) in1_w; - // input and output dims must match - assert(in0_b == out_b && in0_f == out_f && in0_h == out_h && in0_w == out_w); - - // scale/bias dims must be equal to in/out or be 1 for broadcast - assert(in1_b == 1 || in1_b == in0_b); - assert(in1_f == 1 || in1_f == in0_f); - assert(in1_h == 1 || in1_h == in0_h); - assert(in1_w == 1 || in1_w == in0_w); - - if (bias) - { - const auto bias_sizes = bias->get_layout().size.sizes(cldnn::format::bfyx); - const int in2_b = bias_sizes[0]; (void) in2_b; - const int in2_f = bias_sizes[1]; (void) in2_f; - const int in2_h = bias_sizes[2]; (void) in2_h; - const int in2_w = bias_sizes[3]; (void) in2_w; - - // scale/bias dims must be equal to in/out or be 1 for broadcast - assert(in2_b == 1 || in2_b == in1_b); - assert(in2_b == 1 || in2_f == in1_f); - assert(in2_b == 1 || in2_h == in1_h); - assert(in2_b == 1 || in2_w == in1_w); - } - } - - const auto input_desc = get_linear_memory_desc(input.get_layout()); - const auto output_desc = get_linear_memory_desc(output.get_layout()); - const auto scale_desc = get_linear_memory_desc(scale.get_layout()); - const auto bias_desc = - bias ? - get_linear_memory_desc(bias->get_layout()) : - memory_desc(); - - for (int n = 0; n < in0_b; ++n) - for (int c = 0; c < in0_f; ++c) - for (int y = 0; y < in0_h; ++y) - for (int x = 0; x < in0_w; ++x) - { - const size_t in0_idx = get_linear_index(input.get_layout(), n, c, y, x, input_desc); - const size_t in1_idx = get_linear_index_with_broadcast(scale.get_layout(), n, c, y, x, scale_desc); - const size_t out_idx = get_linear_index(output.get_layout(), n, c, y, x, output_desc); - - out_mem[out_idx] = in0_mem[in0_idx] * in1_mem[in1_idx]; - - if (bias) - { - const size_t in2_idx = get_linear_index_with_broadcast(bias->get_layout(), n, c, y, x, bias_desc); - out_mem[out_idx] += in2_mem[in2_idx]; - } - } - return output; - } - - virtual memory generate_reference(const std::vector & inputs) override - { - if (generic_params->data_type == data_types::f32) - { - return generate_reference_typed(inputs); - } - else - { - return generate_reference_typed(inputs); - } - } - - static std::string custom_param_name(const ::testing::TestParamInfo, std::shared_ptr>>& info) - { - std::stringstream res; - - const auto & p = std::get<0>(info.param); - - assert (p->data_type == data_types::f32 || - p->data_type == data_types::f16); - - res << info.index - << "_" << (p->data_type == data_types::f32 ? "f32" : "f16"); - - for (unsigned i = 0; i < p->input_layouts.size(); ++i) - { - if (i == 0) res << "_Input"; - if (i == 1) res << "_ScaleInput"; - if (i == 2) res << "_BiasInput"; - - const auto chans = format::traits(p->fmt).order; - - for (unsigned int j = 0; j < p->input_layouts[i].size.sizes(p->fmt).size(); ++j) - { - res << chans[j] << p->input_layouts[i].size.sizes(p->fmt)[j]; - } - } - return res.str(); - } - -private: - static std::vector> all_generic_params; - static std::vector> all_layer_params; -}; - -std::vector> scale_test::all_layer_params = {}; -std::vector> scale_test::all_generic_params = {}; - -TEST_P(scale_test, SCALE) -{ - run_single_test(); -} - -INSTANTIATE_TEST_CASE_P(DISABLED_SCALE, - scale_test, - ::testing::ValuesIn(scale_test::generate_all_test_params()), - scale_test::custom_param_name); diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/scatter_elements_update_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/scatter_elements_update_gpu_test.cpp index e190e590241b9f..02d5089f9c57d3 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/scatter_elements_update_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/scatter_elements_update_gpu_test.cpp @@ -2,17 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include +#include "test_utils.h" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include -#include using namespace cldnn; using namespace ::tests; @@ -42,11 +40,11 @@ TEST(scatter_elements_update_gpu_fp16, d2411_axisF) { // 10.f, 11.f, 5.f, 4.f, // 1.f, 7.f, 12.f, 13.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 4, 1, 1 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 4, 1, 1 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); // Updates auto axis = cldnn::scatter_elements_update::scatter_elements_update_axis::along_f; set_values(input1, { @@ -65,9 +63,9 @@ TEST(scatter_elements_update_gpu_fp16, d2411_axisF) { }); topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_elements_update("scatter_elements_update", "InputData", "InputIndices", "InputUpdates", axis) ); @@ -81,7 +79,7 @@ TEST(scatter_elements_update_gpu_fp16, d2411_axisF) { auto outputs = network.execute(); auto output = outputs.at("scatter_elements_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 10.f, 11.f, 5.f, 4.f, diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/scatter_nd_update_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/scatter_nd_update_gpu_test.cpp index 26dc684f5e52be..9977777fa0e4f9 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/scatter_nd_update_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/scatter_nd_update_gpu_test.cpp @@ -2,29 +2,27 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include +#include "test_utils.h" -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include -#include using namespace cldnn; using namespace ::tests; TEST(scatter_nd_update_gpu_fp16_test15, data5_indice3_update5) { - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 2, 2, 2, 4, 3 } }); // data - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 2, 1, 1 } }); // indices - auto input3 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 1, 2, 2, 4, 3, 2 } }); // updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 2, 2, 2, 4, 3 } }); // data + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 2, 1, 1 } }); // indices + auto input3 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 1, 2, 2, 4, 3, 2 } }); // updates set_values(input1, { // 0 @@ -90,9 +88,9 @@ TEST(scatter_nd_update_gpu_fp16_test15, data5_indice3_update5) { }; topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 3) ); @@ -107,7 +105,7 @@ TEST(scatter_nd_update_gpu_fp16_test15, data5_indice3_update5) { auto outputs = network.execute(); auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], float16_to_float32(output_ptr[i])); @@ -115,11 +113,11 @@ TEST(scatter_nd_update_gpu_fp16_test15, data5_indice3_update5) { } TEST(scatter_nd_update_gpu_fp16_test14, data5_indice2_update3) { - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 2, 2, 2, 4, 3 } }); // data 2x2x3x4x2 (bfzyx) - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 3, 1, 1 } }); // indices - auto input3 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 3, 4, 1, 1, 2 } }); // updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 2, 2, 2, 4, 3 } }); // data 2x2x3x4x2 (bfzyx) + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 3, 1, 1 } }); // indices + auto input3 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 3, 4, 1, 1, 2 } }); // updates set_values(input1, { // 0 @@ -174,9 +172,9 @@ TEST(scatter_nd_update_gpu_fp16_test14, data5_indice2_update3) { }; topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -191,7 +189,7 @@ TEST(scatter_nd_update_gpu_fp16_test14, data5_indice2_update3) { auto outputs = network.execute(); auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], float16_to_float32(output_ptr[i])); @@ -199,11 +197,11 @@ TEST(scatter_nd_update_gpu_fp16_test14, data5_indice2_update3) { } TEST(scatter_nd_update_gpu_fp16_test13, data4_indice2_update2) { - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 3, 4, 2 } }); // data 2x3x2x4 (bfyx) - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 3, 1, 1 } }); // indices - auto input3 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 4, 1, 1 } }); // updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 3, 4, 2 } }); // data 2x3x2x4 (bfyx) + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 3, 1, 1 } }); // indices + auto input3 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 4, 1, 1 } }); // updates set_values(input1, { FLOAT16(1.0f), FLOAT16(2.0f), FLOAT16(3.0f), FLOAT16(4.0f), FLOAT16(1.0f), FLOAT16(2.0f), FLOAT16(3.0f), FLOAT16(4.0f), @@ -238,9 +236,9 @@ TEST(scatter_nd_update_gpu_fp16_test13, data4_indice2_update2) { }; topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -255,7 +253,7 @@ TEST(scatter_nd_update_gpu_fp16_test13, data4_indice2_update2) { auto outputs = network.execute(); auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], float16_to_float32(output_ptr[i])); @@ -263,11 +261,11 @@ TEST(scatter_nd_update_gpu_fp16_test13, data4_indice2_update2) { } TEST(scatter_nd_update_gpu_fp16_test12, data3_indice3_update1) { - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 3, 1, 4 } }); // data 3x3x4 (bfy) - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 4, 3, 1, 1 } }); // indices - auto input3 = memory::allocate(engine, { data_types::f16, format::bfyx, { 4, 1, 1, 1 } }); // updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 3, 1, 4 } }); // data 3x3x4 (bfy) + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 4, 3, 1, 1 } }); // indices + auto input3 = engine.allocate_memory({ data_types::f16, format::bfyx, { 4, 1, 1, 1 } }); // updates set_values(input1, { FLOAT16(1.0f), FLOAT16(2.0f), FLOAT16(3.0f), FLOAT16(4.0f), @@ -309,9 +307,9 @@ TEST(scatter_nd_update_gpu_fp16_test12, data3_indice3_update1) { }; topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -326,7 +324,7 @@ TEST(scatter_nd_update_gpu_fp16_test12, data3_indice3_update1) { auto outputs = network.execute(); auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], float16_to_float32(output_ptr[i])); @@ -334,11 +332,11 @@ TEST(scatter_nd_update_gpu_fp16_test12, data3_indice3_update1) { } TEST(scatter_nd_update_gpu_fp16_test11, data6_indice1_update6) { - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 2, 2, 3, 4, 2 } }); // data - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 1, 1, 1 } }); // indices - auto input3 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 1, 2, 2, 3, 4, 2 } }); // updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 2, 2, 3, 4, 2 } }); // data + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 1, 1, 1 } }); // indices + auto input3 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 1, 2, 2, 3, 4, 2 } }); // updates set_values(input1, { // 0, 0, 0 @@ -440,9 +438,9 @@ TEST(scatter_nd_update_gpu_fp16_test11, data6_indice1_update6) { }; topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -457,7 +455,7 @@ TEST(scatter_nd_update_gpu_fp16_test11, data6_indice1_update6) { auto outputs = network.execute(); auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], float16_to_float32(output_ptr[i])); @@ -465,11 +463,11 @@ TEST(scatter_nd_update_gpu_fp16_test11, data6_indice1_update6) { } TEST(scatter_nd_update_gpu_fp16_test10, data5_indice1_update5) { - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 2, 2, 3, 4, 2 } }); // data - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); // indices - auto input3 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 2, 2, 3, 4, 2 } }); // updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 2, 2, 3, 4, 2 } }); // data + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); // indices + auto input3 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 2, 2, 3, 4, 2 } }); // updates set_values(input1, { // 0 @@ -537,9 +535,9 @@ TEST(scatter_nd_update_gpu_fp16_test10, data5_indice1_update5) { }; topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -554,7 +552,7 @@ TEST(scatter_nd_update_gpu_fp16_test10, data5_indice1_update5) { auto outputs = network.execute(); auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], float16_to_float32(output_ptr[i])); @@ -562,11 +560,11 @@ TEST(scatter_nd_update_gpu_fp16_test10, data5_indice1_update5) { } TEST(scatter_nd_update_gpu_fp16_test9, data4_indice1_update4) { - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 3, 4, 2 } }); // data - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); // indices - auto input3 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 3, 4, 2 } }); // updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 3, 4, 2 } }); // data + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); // indices + auto input3 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 3, 4, 2 } }); // updates set_values(input1, { // 0 @@ -616,9 +614,9 @@ TEST(scatter_nd_update_gpu_fp16_test9, data4_indice1_update4) { }; topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -633,7 +631,7 @@ TEST(scatter_nd_update_gpu_fp16_test9, data4_indice1_update4) { auto outputs = network.execute(); auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], float16_to_float32(output_ptr[i])); @@ -641,11 +639,11 @@ TEST(scatter_nd_update_gpu_fp16_test9, data4_indice1_update4) { } TEST(scatter_nd_update_gpu_fp16_test8, data6_indice2_update5) { - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 1, 2, 2, 3, 4, 2 } }); // data - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); // indices - auto input3 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 2, 1, 3, 4, 2 } }); // updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 1, 2, 2, 3, 4, 2 } }); // data + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); // indices + auto input3 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 2, 1, 3, 4, 2 } }); // updates set_values(input1, { //0,0 @@ -714,9 +712,9 @@ TEST(scatter_nd_update_gpu_fp16_test8, data6_indice2_update5) { }; topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -731,7 +729,7 @@ TEST(scatter_nd_update_gpu_fp16_test8, data6_indice2_update5) { auto outputs = network.execute(); auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], float16_to_float32(output_ptr[i])); @@ -739,11 +737,11 @@ TEST(scatter_nd_update_gpu_fp16_test8, data6_indice2_update5) { } TEST(scatter_nd_update_gpu_fp16_test7, data5_indice2_update4) { - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 1, 2, 3, 4, 2 } }); // data - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); // indices - auto input3 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 2, 2, 1, 3, 4 } }); // updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 1, 2, 3, 4, 2 } }); // data + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); // indices + auto input3 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 2, 2, 1, 3, 4 } }); // updates set_values(input1, { @@ -782,9 +780,9 @@ TEST(scatter_nd_update_gpu_fp16_test7, data5_indice2_update4) { }; topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -799,7 +797,7 @@ TEST(scatter_nd_update_gpu_fp16_test7, data5_indice2_update4) { auto outputs = network.execute(); auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], float16_to_float32(output_ptr[i])); @@ -808,11 +806,11 @@ TEST(scatter_nd_update_gpu_fp16_test7, data5_indice2_update4) { TEST(scatter_nd_update_gpu_fp16_test6, data4_indice2_update3) { - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 3, 4, 2 } }); // data - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 2, 1, 1 } }); // indices - auto input3 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 4, 1, 2 } }); // updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 3, 4, 2 } }); // data + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 2, 1, 1 } }); // indices + auto input3 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 4, 1, 2 } }); // updates set_values(input1, { @@ -848,9 +846,9 @@ TEST(scatter_nd_update_gpu_fp16_test6, data4_indice2_update3) { }; topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -865,7 +863,7 @@ TEST(scatter_nd_update_gpu_fp16_test6, data4_indice2_update3) { auto outputs = network.execute(); auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], float16_to_float32(output_ptr[i])); @@ -873,11 +871,11 @@ TEST(scatter_nd_update_gpu_fp16_test6, data4_indice2_update3) { } TEST(scatter_nd_update_gpu_fp16_test5, data3_indice2_update2) { - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 3, 1, 4 } }); // data - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 2, 1, 1 } }); // indices - auto input3 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 4, 1, 1 } }); // updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 3, 1, 4 } }); // data + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 2, 1, 1 } }); // indices + auto input3 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 4, 1, 1 } }); // updates set_values(input1, { @@ -913,9 +911,9 @@ TEST(scatter_nd_update_gpu_fp16_test5, data3_indice2_update2) { }; topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -930,7 +928,7 @@ TEST(scatter_nd_update_gpu_fp16_test5, data3_indice2_update2) { auto outputs = network.execute(); auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], float16_to_float32(output_ptr[i])); @@ -938,11 +936,11 @@ TEST(scatter_nd_update_gpu_fp16_test5, data3_indice2_update2) { } TEST(scatter_nd_update_gpu_fp16_test4, data2_indice2_update1) { - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 4, 1, 1 } }); // data - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 2, 1, 1 } }); // indices - auto input3 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 1, 1, 1 } }); // updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 4, 1, 1 } }); // data + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 2, 1, 1 } }); // indices + auto input3 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 1, 1, 1 } }); // updates set_values(input1, { @@ -968,9 +966,9 @@ TEST(scatter_nd_update_gpu_fp16_test4, data2_indice2_update1) { }; topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -985,7 +983,7 @@ TEST(scatter_nd_update_gpu_fp16_test4, data2_indice2_update1) { auto outputs = network.execute(); auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], float16_to_float32(output_ptr[i])); @@ -993,11 +991,11 @@ TEST(scatter_nd_update_gpu_fp16_test4, data2_indice2_update1) { } TEST(scatter_nd_update_gpu_fp16_test3, data3_indice1_update3) { - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 3, 4, 1 } }); // data - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); // indices - auto input3 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 3, 4, 1 } }); // updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 3, 4, 1 } }); // data + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); // indices + auto input3 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 3, 4, 1 } }); // updates set_values(input1, { @@ -1043,9 +1041,9 @@ TEST(scatter_nd_update_gpu_fp16_test3, data3_indice1_update3) { }; topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -1060,7 +1058,7 @@ TEST(scatter_nd_update_gpu_fp16_test3, data3_indice1_update3) { auto outputs = network.execute(); auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], float16_to_float32(output_ptr[i])); @@ -1069,11 +1067,11 @@ TEST(scatter_nd_update_gpu_fp16_test3, data3_indice1_update3) { TEST(scatter_nd_update_gpu_fp16_test2, data2_indice1_update2) { - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 4, 1, 1 } }); // data - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); // indices - auto input3 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 4, 1, 1 } }); // updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 4, 1, 1 } }); // data + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); // indices + auto input3 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 4, 1, 1 } }); // updates set_values(input1, { @@ -1098,9 +1096,9 @@ TEST(scatter_nd_update_gpu_fp16_test2, data2_indice1_update2) { }; topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -1115,7 +1113,7 @@ TEST(scatter_nd_update_gpu_fp16_test2, data2_indice1_update2) { auto outputs = network.execute(); auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], float16_to_float32(output_ptr[i])); @@ -1123,11 +1121,11 @@ TEST(scatter_nd_update_gpu_fp16_test2, data2_indice1_update2) { } TEST(scatter_nd_update_gpu_fp16_test1, data1_indice1_update1) { - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 8, 1, 1, 1 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 4, 1, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfyx, { 4, 1, 1, 1 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 8, 1, 1, 1 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 4, 1, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfyx, { 4, 1, 1, 1 } }); // Updates set_values(input1, { @@ -1147,9 +1145,9 @@ TEST(scatter_nd_update_gpu_fp16_test1, data1_indice1_update1) { }; topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -1164,7 +1162,7 @@ TEST(scatter_nd_update_gpu_fp16_test1, data1_indice1_update1) { auto outputs = network.execute(); auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], float16_to_float32(output_ptr[i])); @@ -1181,11 +1179,11 @@ TEST(scatter_nd_update_gpu_fp16, d6661_i2311) { // Input values in fp16 // - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 6, 6, 1, 6 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 3, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 6, 6, 1, 6 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 3, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); // Updates set_values(input1, { FLOAT16(100.f), FLOAT16(101.f), FLOAT16(102.f), FLOAT16(103.f), FLOAT16(104.f), FLOAT16(105.f), @@ -1242,9 +1240,9 @@ TEST(scatter_nd_update_gpu_fp16, d6661_i2311) { topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -1260,7 +1258,7 @@ TEST(scatter_nd_update_gpu_fp16, d6661_i2311) { auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 100.f, 101.f, 102.f, 103.f, 104.f, 105.f, @@ -1319,11 +1317,11 @@ TEST(scatter_nd_update_gpu_fp16, d6661_i2211) { // Input values in fp16 // - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 6, 6, 1, 6 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 6, 1, 1 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 6, 6, 1, 6 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 6, 1, 1 } }); // Updates set_values(input1, { @@ -1381,9 +1379,9 @@ TEST(scatter_nd_update_gpu_fp16, d6661_i2211) { }); topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -1399,7 +1397,7 @@ TEST(scatter_nd_update_gpu_fp16, d6661_i2211) { auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 100.f, 101.f, 102.f, 103.f, 104.f, 105.f, @@ -1458,11 +1456,11 @@ TEST(scatter_nd_update_gpu_fp16, d6661_i2111) { // Input values in fp16 // - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 6, 6, 1, 6 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 6, 1, 6 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 6, 6, 1, 6 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 6, 1, 6 } }); // Updates set_values(input1, { @@ -1531,9 +1529,9 @@ TEST(scatter_nd_update_gpu_fp16, d6661_i2111) { }); topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -1549,7 +1547,7 @@ TEST(scatter_nd_update_gpu_fp16, d6661_i2111) { auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 777.f, 999.f, 999.f, 999.f, 999.f, 999.f, @@ -1609,11 +1607,11 @@ TEST(scatter_nd_update_gpu_fp16, d3232_i2411) { // Input values in fp16 // - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 2, 2, 3 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 4, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 2, 2, 3 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 4, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); // Updates set_values(input1, { @@ -1652,9 +1650,9 @@ TEST(scatter_nd_update_gpu_fp16, d3232_i2411) { }); topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -1670,7 +1668,7 @@ TEST(scatter_nd_update_gpu_fp16, d3232_i2411) { auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 100.f, 101.f, @@ -1712,11 +1710,11 @@ TEST(scatter_nd_update_gpu_fp16, d3232_i2311) { // Input values in fp16 // - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 2, 2, 3 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 3, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 2, 2, 3 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 3, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); // Updates set_values(input1, { @@ -1755,9 +1753,9 @@ TEST(scatter_nd_update_gpu_fp16, d3232_i2311) { }); topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -1773,7 +1771,7 @@ TEST(scatter_nd_update_gpu_fp16, d3232_i2311) { auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 100.f, 101.f, @@ -1815,11 +1813,11 @@ TEST(scatter_nd_update_gpu_fp16, d3232_i2211) { // Input values in fp16 // - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 2, 2, 3 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 3, 1, 2 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 2, 2, 3 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 2, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 3, 1, 2 } }); // Updates set_values(input1, { @@ -1864,9 +1862,9 @@ TEST(scatter_nd_update_gpu_fp16, d3232_i2211) { }); topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -1882,7 +1880,7 @@ TEST(scatter_nd_update_gpu_fp16, d3232_i2211) { auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 100.f, 101.f, @@ -1924,11 +1922,11 @@ TEST(scatter_nd_update_gpu_fp16, d3232_i2111) { // Input values in fp16 // - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 3, 2, 2, 3 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 2, 2, 3 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 3, 2, 2, 3 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 1, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 2, 2, 3 } }); // Updates set_values(input1, { @@ -1981,9 +1979,9 @@ TEST(scatter_nd_update_gpu_fp16, d3232_i2111) { }); topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -1999,7 +1997,7 @@ TEST(scatter_nd_update_gpu_fp16, d3232_i2111) { auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 666.f, 666.f, @@ -2040,11 +2038,11 @@ TEST(scatter_nd_update_gpu_fp16, d32323_i25111) { // Input values in fp16 // - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 3, 2, 3, 2, 3 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 2, 5, 1, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 2, 1, 1, 1, 1 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 3, 2, 3, 2, 3 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 2, 5, 1, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 2, 1, 1, 1, 1 } }); // Updates set_values(input1, { @@ -2115,9 +2113,9 @@ TEST(scatter_nd_update_gpu_fp16, d32323_i25111) { }); topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -2133,7 +2131,7 @@ TEST(scatter_nd_update_gpu_fp16, d32323_i25111) { auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 100.f, 101.f, 102.f, @@ -2207,11 +2205,11 @@ TEST(scatter_nd_update_gpu_fp16, d32323_i24111) { // Input values in fp16 // - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 3, 2, 3, 2, 3 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 2, 4, 1, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 2, 3, 1, 1, 1 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 3, 2, 3, 2, 3 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 2, 4, 1, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 2, 3, 1, 1, 1 } }); // Updates set_values(input1, { @@ -2283,9 +2281,9 @@ TEST(scatter_nd_update_gpu_fp16, d32323_i24111) { }); topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -2301,7 +2299,7 @@ TEST(scatter_nd_update_gpu_fp16, d32323_i24111) { auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 100.f, 101.f, 102.f, @@ -2375,11 +2373,11 @@ TEST(scatter_nd_update_gpu_fp16, d32323_i23111) { // Input values in fp16 // - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 3, 2, 3, 2, 3 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 2, 3, 1, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 2, 2, 1, 1, 3 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 3, 2, 3, 2, 3 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 2, 3, 1, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 2, 2, 1, 1, 3 } }); // Updates set_values(input1, { @@ -2454,9 +2452,9 @@ TEST(scatter_nd_update_gpu_fp16, d32323_i23111) { }); topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -2472,7 +2470,7 @@ TEST(scatter_nd_update_gpu_fp16, d32323_i23111) { auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 100.f, 101.f, 102.f, @@ -2546,11 +2544,11 @@ TEST(scatter_nd_update_gpu_fp16, d32323_i22111) { // Input values in fp16 // - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 3, 2, 3, 2, 3 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 2, 2, 1, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 2, 3, 1, 3, 2 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 3, 2, 3, 2, 3 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 2, 2, 1, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 2, 3, 1, 3, 2 } }); // Updates set_values(input1, { @@ -2637,9 +2635,9 @@ TEST(scatter_nd_update_gpu_fp16, d32323_i22111) { }); topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -2655,7 +2653,7 @@ TEST(scatter_nd_update_gpu_fp16, d32323_i22111) { auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 100.f, 101.f, 102.f, @@ -2729,11 +2727,11 @@ TEST(scatter_nd_update_gpu_fp16, d32323_i21111) { // Input values in fp16 // - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 3, 2, 3, 2, 3 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 2, 1, 1, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 2, 2, 3, 2, 3 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 3, 2, 3, 2, 3 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 2, 1, 1, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 2, 2, 3, 2, 3 } }); // Updates set_values(input1, { @@ -2838,9 +2836,9 @@ TEST(scatter_nd_update_gpu_fp16, d32323_i21111) { }); topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -2856,7 +2854,7 @@ TEST(scatter_nd_update_gpu_fp16, d32323_i21111) { auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 555.f, 555.f, 555.f, @@ -2930,12 +2928,12 @@ TEST(scatter_nd_update_gpu_fp16, d222222_i261111) { // Input values in fp16 // - engine engine; + auto& engine = get_test_engine(); // memory order is bfxyzw - auto input1 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 2, 2, 2, 2, 2 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 6, 1, 1, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 1, 1, 1, 1, 1 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 2, 2, 2, 2, 2 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 6, 1, 1, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 1, 1, 1, 1, 1 } }); // Updates set_values(input1, { @@ -2998,9 +2996,9 @@ TEST(scatter_nd_update_gpu_fp16, d222222_i261111) { }); topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -3016,7 +3014,7 @@ TEST(scatter_nd_update_gpu_fp16, d222222_i261111) { auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 100.f, 101.f, @@ -3082,12 +3080,12 @@ TEST(scatter_nd_update_gpu_fp16, d222222_i251111) { // Input values in fp16 // - engine engine; + auto& engine = get_test_engine(); // memory order is bfxyzw - auto input1 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 2, 2, 2, 2, 2 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 5, 1, 1, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 2, 1, 1, 1, 1 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 2, 2, 2, 2, 2 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 5, 1, 1, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 2, 1, 1, 1, 1 } }); // Updates set_values(input1, { @@ -3151,9 +3149,9 @@ TEST(scatter_nd_update_gpu_fp16, d222222_i251111) { }); topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -3169,7 +3167,7 @@ TEST(scatter_nd_update_gpu_fp16, d222222_i251111) { auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 100.f, 101.f, @@ -3235,12 +3233,12 @@ TEST(scatter_nd_update_gpu_fp16, d222222_i241111) { // Input values in fp16 // - engine engine; + auto& engine = get_test_engine(); // memory order is bfxyzw - auto input1 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 2, 2, 2, 2, 2 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 4, 1, 1, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 2, 1, 1, 1, 2 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 2, 2, 2, 2, 2 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 4, 1, 1, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 2, 1, 1, 1, 2 } }); // Updates set_values(input1, { @@ -3307,9 +3305,9 @@ TEST(scatter_nd_update_gpu_fp16, d222222_i241111) { }); topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -3325,7 +3323,7 @@ TEST(scatter_nd_update_gpu_fp16, d222222_i241111) { auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 100.f, 101.f, @@ -3392,12 +3390,12 @@ TEST(scatter_nd_update_gpu_fp16, d222222_i231111) { // Input values in fp16 // - engine engine; + auto& engine = get_test_engine(); // memory order is bfxyzw - auto input1 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 2, 2, 2, 2, 2 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 3, 1, 1, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 2, 1, 1, 2, 2 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 2, 2, 2, 2, 2 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 3, 1, 1, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 2, 1, 1, 2, 2 } }); // Updates set_values(input1, { @@ -3470,9 +3468,9 @@ TEST(scatter_nd_update_gpu_fp16, d222222_i231111) { }); topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -3488,7 +3486,7 @@ TEST(scatter_nd_update_gpu_fp16, d222222_i231111) { auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 100.f, 101.f, @@ -3554,12 +3552,12 @@ TEST(scatter_nd_update_gpu_fp16, d222222_i221111) { // Input values in fp16 // - engine engine; + auto& engine = get_test_engine(); // memory order is bfxyzw - auto input1 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 2, 2, 2, 2, 2 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 2, 1, 1, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 2, 1, 2, 2, 2 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 2, 2, 2, 2, 2 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 2, 1, 1, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 2, 1, 2, 2, 2 } }); // Updates set_values(input1, { @@ -3644,9 +3642,9 @@ TEST(scatter_nd_update_gpu_fp16, d222222_i221111) { }); topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -3662,7 +3660,7 @@ TEST(scatter_nd_update_gpu_fp16, d222222_i221111) { auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 100.f, 101.f, @@ -3727,12 +3725,12 @@ TEST(scatter_nd_update_gpu_fp16, d222222_i211111) { // Input values in fp16 // - engine engine; + auto& engine = get_test_engine(); // memory order is bfxyzw - auto input1 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 2, 2, 2, 2, 2 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 1, 1, 1, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfwzyx, { 2, 2, 2, 2, 2, 2 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 2, 2, 2, 2, 2 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 1, 1, 1, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfwzyx, { 2, 2, 2, 2, 2, 2 } }); // Updates set_values(input1, { @@ -3841,9 +3839,9 @@ TEST(scatter_nd_update_gpu_fp16, d222222_i211111) { }); topology topology; - topology.add(input_layout("InputData", input1.get_layout())); - topology.add(input_layout("InputIndices", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputData", input1->get_layout())); + topology.add(input_layout("InputIndices", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_nd_update("scatter_nd_update", "InputData", "InputIndices", "InputUpdates", 2) ); @@ -3859,7 +3857,7 @@ TEST(scatter_nd_update_gpu_fp16, d222222_i211111) { auto output = outputs.at("scatter_nd_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 777.f, 777.f, diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/scatter_update_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/scatter_update_gpu_test.cpp index 01f2c7f02ef209..937695760e3a42 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/scatter_update_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/scatter_update_gpu_test.cpp @@ -2,17 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include +#include "test_utils.h" -#include -#include -#include -#include -#include +#include +#include #include -#include using namespace cldnn; using namespace ::tests; @@ -38,14 +33,14 @@ TEST(scatter_update_gpu_fp16, d2411_axisB) { // 0.f, 0.f, 0.f, 0.f // // Output: - // 3.f, 6.f, 5.f, 4.f, + // 3.f, 6.f, 5.f, 4.f, // 1.f, 7.f, 2.f, 9.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 4, 1, 1 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 1, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 4, 1, 1 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 4, 1, 1 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 1, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 4, 1, 1 } }); // Updates auto axis = cldnn::scatter_update::scatter_update_axis::along_b; set_values(input1, { @@ -63,34 +58,34 @@ TEST(scatter_update_gpu_fp16, d2411_axisB) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_update("scatter_update", "InputDictionary", "InputText", "InputUpdates", axis) ); - - network network(engine, topology); - - + + network network(engine, topology); + + network.set_input_data("InputDictionary", input1); network.set_input_data("InputText", input2); network.set_input_data("InputUpdates", input3); - + auto outputs = network.execute(); - + auto output = outputs.at("scatter_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { - 3.f, 6.f, 5.f, 4.f, + 3.f, 6.f, 5.f, 4.f, 1.f, 7.f, 2.f, 9.f }; for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], float16_to_float32(output_ptr[i])); - } + } } TEST(scatter_update_gpu_fp32, d8111_axisB) { @@ -114,11 +109,11 @@ TEST(scatter_update_gpu_fp32, d8111_axisB) { // 1.f, 11.f, 3.f, 10.f, 9.f, 6.f, 7.f, 12.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 8, 1, 1, 1 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 4, 1, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f32, format::bfyx, { 4, 1, 1, 1 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 8, 1, 1, 1 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 4, 1, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f32, format::bfyx, { 4, 1, 1, 1 } }); // Updates auto axis = cldnn::scatter_update::scatter_update_axis::along_b; set_values(input1, { @@ -134,32 +129,32 @@ TEST(scatter_update_gpu_fp32, d8111_axisB) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_update("scatter_update", "InputDictionary", "InputText", "InputUpdates", axis) ); - - network network(engine, topology); - - + + network network(engine, topology); + + network.set_input_data("InputDictionary", input1); network.set_input_data("InputText", input2); network.set_input_data("InputUpdates", input3); - - auto outputs = network.execute(); + + auto outputs = network.execute(); auto output = outputs.at("scatter_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 1.f, 11.f, 3.f, 10.f, 9.f, 6.f, 7.f, 12.f }; - + for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], output_ptr[i]); - } + } } TEST(scatter_update_gpu_fp16, d4311_axisB) { @@ -193,11 +188,11 @@ TEST(scatter_update_gpu_fp16, d4311_axisB) { // 6.f, 6.f, 6.f, // 7.f, 7.f, 7.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 4, 3, 1, 1 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 2, 1, 3 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 4, 3, 1, 1 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 2, 1, 3 } }); // Updates auto axis = cldnn::scatter_update::scatter_update_axis::along_b; set_values(input1, { @@ -221,34 +216,34 @@ TEST(scatter_update_gpu_fp16, d4311_axisB) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_update("scatter_update", "InputDictionary", "InputText", "InputUpdates", axis) ); - - network network(engine, topology); - + + network network(engine, topology); + network.set_input_data("InputDictionary", input1); network.set_input_data("InputText", input2); network.set_input_data("InputUpdates", input3); - - auto outputs = network.execute(); + + auto outputs = network.execute(); auto output = outputs.at("scatter_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { - 9.f, 10.f, 11.f, + 9.f, 10.f, 11.f, 8.f, 8.f, 8.f, - 6.f, 6.f, 6.f, + 6.f, 6.f, 6.f, 7.f, 7.f, 7.f }; - + for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], float16_to_float32(output_ptr[i])); - } + } } TEST(scatter_update_gpu_fp16, d2521_axisF) { @@ -302,24 +297,24 @@ TEST(scatter_update_gpu_fp16, d2521_axisF) { // 16.f, 17.f, // 141.f, 151.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 5, 1, 2 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 2, 2, 2 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 5, 1, 2 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 2, 2, 2 } }); // Updates auto axis = cldnn::scatter_update::scatter_update_axis::along_f; set_values(input1, { - FLOAT16(0.0f), FLOAT16(1.0f), - FLOAT16(2.0f), FLOAT16(3.0f), + FLOAT16(0.0f), FLOAT16(1.0f), + FLOAT16(2.0f), FLOAT16(3.0f), FLOAT16(4.0f), FLOAT16(5.0f), - FLOAT16(6.0f), FLOAT16(7.0f), + FLOAT16(6.0f), FLOAT16(7.0f), FLOAT16(8.0f), FLOAT16(9.0f), FLOAT16(10.0f), FLOAT16(11.0f), FLOAT16(12.0f), FLOAT16(13.0f), - FLOAT16(14.0f), FLOAT16(15.0f), - FLOAT16(16.0f), FLOAT16(17.0f), + FLOAT16(14.0f), FLOAT16(15.0f), + FLOAT16(16.0f), FLOAT16(17.0f), FLOAT16(18.0f), FLOAT16(19.0f) }); @@ -329,35 +324,35 @@ TEST(scatter_update_gpu_fp16, d2521_axisF) { }); set_values(input3, { - FLOAT16(21.0f), FLOAT16(31.0f), + FLOAT16(21.0f), FLOAT16(31.0f), FLOAT16(41.0f), FLOAT16(51.0f), - FLOAT16(61.0f), FLOAT16(71.0f), + FLOAT16(61.0f), FLOAT16(71.0f), FLOAT16(81.0f), FLOAT16(91.0f), FLOAT16(101.0f), FLOAT16(111.0f), FLOAT16(121.0f), FLOAT16(131.0f), - FLOAT16(141.0f), FLOAT16(151.0f), + FLOAT16(141.0f), FLOAT16(151.0f), FLOAT16(161.0f), FLOAT16(171.0f) }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_update("scatter_update", "InputDictionary", "InputText", "InputUpdates", axis) ); - - network network(engine, topology); - + + network network(engine, topology); + network.set_input_data("InputDictionary", input1); network.set_input_data("InputText", input2); network.set_input_data("InputUpdates", input3); - + auto outputs = network.execute(); auto output = outputs.at("scatter_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 21.f, 31.f, @@ -372,7 +367,7 @@ TEST(scatter_update_gpu_fp16, d2521_axisF) { 16.f, 17.f, 141.f, 151.f }; - + for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], float16_to_float32(output_ptr[i])); } @@ -415,11 +410,11 @@ TEST(scatter_update_gpu_fp16, d2241_axisY) { // 90.f, 120.f, 100.f, 110.f, // 130.f, 160.f, 140.f, 150.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 2, 1, 4 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 2, 2, 2 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 2, 1, 4 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 2, 2, 2 } }); // Updates auto axis = cldnn::scatter_update::scatter_update_axis::along_y; set_values(input1, { @@ -435,35 +430,35 @@ TEST(scatter_update_gpu_fp16, d2241_axisY) { }); set_values(input3, { - FLOAT16(0.0f), FLOAT16(20.0f), + FLOAT16(0.0f), FLOAT16(20.0f), FLOAT16(30.0f), FLOAT16(40.0f), - FLOAT16(50.0f), FLOAT16(60.0f), + FLOAT16(50.0f), FLOAT16(60.0f), FLOAT16(70.0f), FLOAT16(80.0f), FLOAT16(90.0f), FLOAT16(100.0f), FLOAT16(110.0f), FLOAT16(120.0f), - FLOAT16(130.0f), FLOAT16(140.0f), + FLOAT16(130.0f), FLOAT16(140.0f), FLOAT16(150.0f), FLOAT16(160.0f) }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_update("scatter_update", "InputDictionary", "InputText", "InputUpdates", axis) ); - - network network(engine, topology); - + + network network(engine, topology); + network.set_input_data("InputDictionary", input1); network.set_input_data("InputText", input2); network.set_input_data("InputUpdates", input3); - + auto outputs = network.execute(); auto output = outputs.at("scatter_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 40.f, 20.f, 30.f, @@ -472,7 +467,7 @@ TEST(scatter_update_gpu_fp16, d2241_axisY) { 130.f, 160.f, 140.f, 150.f }; - + for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], float16_to_float32(output_ptr[i])); } @@ -486,11 +481,11 @@ TEST(scatter_update_gpu_fp16, d8x2x20x1_axisB) { // Output : 8x2x20x1 // Input values in fp16 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 8, 2, 1, 20 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 3, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfyx, { 2, 3, 20, 2 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 8, 2, 1, 20 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 3, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfyx, { 2, 3, 20, 2 } }); // Updates auto axis = cldnn::scatter_update::scatter_update_axis::along_b; set_values(input1, { @@ -510,8 +505,8 @@ TEST(scatter_update_gpu_fp16, d8x2x20x1_axisB) { FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(0.0f), FLOAT16(0.0f), FLOAT16(0.0f), FLOAT16(0.0f),FLOAT16(0.0f), FLOAT16(0.0f),FLOAT16(0.0f), FLOAT16(0.0f),FLOAT16(0.0f), FLOAT16(0.0f), FLOAT16(0.0f), FLOAT16(0.0f), FLOAT16(0.0f), FLOAT16(0.0f),FLOAT16(0.0f), FLOAT16(0.0f),FLOAT16(0.0f), FLOAT16(0.0f),FLOAT16(0.0f), FLOAT16(0.0f), - FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f), - + FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f), + FLOAT16(0.0f), FLOAT16(0.0f), FLOAT16(0.0f), FLOAT16(0.0f),FLOAT16(0.0f), FLOAT16(0.0f),FLOAT16(0.0f), FLOAT16(0.0f),FLOAT16(0.0f), FLOAT16(0.0f), FLOAT16(0.0f), FLOAT16(0.0f), FLOAT16(0.0f), FLOAT16(0.0f),FLOAT16(0.0f), FLOAT16(0.0f),FLOAT16(0.0f), FLOAT16(0.0f),FLOAT16(0.0f), FLOAT16(0.0f), FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f),FLOAT16(1.0f), FLOAT16(1.0f), @@ -525,43 +520,43 @@ TEST(scatter_update_gpu_fp16, d8x2x20x1_axisB) { }); set_values(input3, { - FLOAT16(0), FLOAT16(1), FLOAT16(2), FLOAT16(3), FLOAT16(4), FLOAT16(5), FLOAT16(6), FLOAT16(7), FLOAT16(8), FLOAT16(9), FLOAT16(10), FLOAT16(11), FLOAT16(12), FLOAT16(13), FLOAT16(14), FLOAT16(15), FLOAT16(16), FLOAT16(17), FLOAT16(18), FLOAT16(19), + FLOAT16(0), FLOAT16(1), FLOAT16(2), FLOAT16(3), FLOAT16(4), FLOAT16(5), FLOAT16(6), FLOAT16(7), FLOAT16(8), FLOAT16(9), FLOAT16(10), FLOAT16(11), FLOAT16(12), FLOAT16(13), FLOAT16(14), FLOAT16(15), FLOAT16(16), FLOAT16(17), FLOAT16(18), FLOAT16(19), FLOAT16(20), FLOAT16(21), FLOAT16(22), FLOAT16(23), FLOAT16(24), FLOAT16(25), FLOAT16(26), FLOAT16(27), FLOAT16(28), FLOAT16(29), FLOAT16(30), FLOAT16(31), FLOAT16(32), FLOAT16(33), FLOAT16(34), FLOAT16(35), FLOAT16(36), FLOAT16(37), FLOAT16(38), FLOAT16(39), - + FLOAT16(40), FLOAT16(41), FLOAT16(42), FLOAT16(43), FLOAT16(44), FLOAT16(45), FLOAT16(46), FLOAT16(47), FLOAT16(48), FLOAT16(49), FLOAT16(50), FLOAT16(51), FLOAT16(52), FLOAT16(53), FLOAT16(54), FLOAT16(55), FLOAT16(56), FLOAT16(57), FLOAT16(58), FLOAT16(59), FLOAT16(60), FLOAT16(61), FLOAT16(62), FLOAT16(63), FLOAT16(64), FLOAT16(65), FLOAT16(66), FLOAT16(67), FLOAT16(68), FLOAT16(69), FLOAT16(70), FLOAT16(71), FLOAT16(72), FLOAT16(73), FLOAT16(74), FLOAT16(75), FLOAT16(76), FLOAT16(77), FLOAT16(78), FLOAT16(79), - + FLOAT16(80), FLOAT16(81), FLOAT16(82), FLOAT16(83), FLOAT16(84), FLOAT16(85), FLOAT16(86), FLOAT16(87), FLOAT16(88), FLOAT16(89), FLOAT16(90), FLOAT16(91), FLOAT16(92), FLOAT16(93), FLOAT16(94), FLOAT16(95), FLOAT16(96), FLOAT16(97), FLOAT16(98), FLOAT16(99), FLOAT16(100), FLOAT16(101), FLOAT16(102), FLOAT16(103), FLOAT16(104), FLOAT16(105), FLOAT16(106), FLOAT16(107), FLOAT16(108), FLOAT16(109), FLOAT16(110), FLOAT16(111), FLOAT16(112), FLOAT16(113), FLOAT16(114), FLOAT16(115), FLOAT16(116), FLOAT16(117), FLOAT16(118), FLOAT16(119), - + FLOAT16(120), FLOAT16(121), FLOAT16(122), FLOAT16(123), FLOAT16(124), FLOAT16(125), FLOAT16(126), FLOAT16(127), FLOAT16(128), FLOAT16(129), FLOAT16(130), FLOAT16(131), FLOAT16(132), FLOAT16(133), FLOAT16(134), FLOAT16(135), FLOAT16(136), FLOAT16(137), FLOAT16(138), FLOAT16(139), FLOAT16(140), FLOAT16(141), FLOAT16(142), FLOAT16(143), FLOAT16(144), FLOAT16(145), FLOAT16(146), FLOAT16(147), FLOAT16(148), FLOAT16(149), FLOAT16(150), FLOAT16(151), FLOAT16(152), FLOAT16(153), FLOAT16(154), FLOAT16(155), FLOAT16(156), FLOAT16(157), FLOAT16(158), FLOAT16(159), - + FLOAT16(160), FLOAT16(161), FLOAT16(162), FLOAT16(163), FLOAT16(164), FLOAT16(165), FLOAT16(166), FLOAT16(167), FLOAT16(168), FLOAT16(169), FLOAT16(170), FLOAT16(171), FLOAT16(172), FLOAT16(173), FLOAT16(174), FLOAT16(175), FLOAT16(176), FLOAT16(177), FLOAT16(178), FLOAT16(179), - FLOAT16(180), FLOAT16(181), FLOAT16(182), FLOAT16(183), FLOAT16(184), FLOAT16(185), FLOAT16(186), FLOAT16(187), FLOAT16(188), FLOAT16(189), FLOAT16(190), FLOAT16(191), FLOAT16(192), FLOAT16(193), FLOAT16(194), FLOAT16(195), FLOAT16(196), FLOAT16(197), FLOAT16(198), FLOAT16(199), + FLOAT16(180), FLOAT16(181), FLOAT16(182), FLOAT16(183), FLOAT16(184), FLOAT16(185), FLOAT16(186), FLOAT16(187), FLOAT16(188), FLOAT16(189), FLOAT16(190), FLOAT16(191), FLOAT16(192), FLOAT16(193), FLOAT16(194), FLOAT16(195), FLOAT16(196), FLOAT16(197), FLOAT16(198), FLOAT16(199), FLOAT16(200), FLOAT16(201), FLOAT16(202), FLOAT16(203), FLOAT16(204), FLOAT16(205), FLOAT16(206), FLOAT16(207), FLOAT16(208), FLOAT16(209), FLOAT16(210), FLOAT16(211), FLOAT16(212), FLOAT16(213), FLOAT16(214), FLOAT16(215), FLOAT16(216), FLOAT16(217), FLOAT16(218), FLOAT16(219), FLOAT16(220), FLOAT16(221), FLOAT16(222), FLOAT16(223), FLOAT16(224), FLOAT16(225), FLOAT16(226), FLOAT16(227), FLOAT16(228), FLOAT16(229), FLOAT16(230), FLOAT16(231), FLOAT16(232), FLOAT16(233), FLOAT16(234), FLOAT16(235), FLOAT16(236), FLOAT16(237), FLOAT16(238), FLOAT16(239) }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_update("scatter_update", "InputDictionary", "InputText", "InputUpdates", axis) ); - + network network(engine, topology); - + network.set_input_data("InputDictionary", input1); network.set_input_data("InputText", input2); network.set_input_data("InputUpdates", input3); - + auto outputs = network.execute(); - + auto output = outputs.at("scatter_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, @@ -569,26 +564,26 @@ TEST(scatter_update_gpu_fp16, d8x2x20x1_axisB) { 40.f, 41.f, 42.f, 43.f, 44.f, 45.f, 46.f, 47.f, 48.f, 49.f, 50.f, 51.f, 52.f, 53.f, 54.f, 55.f, 56.f, 57.f, 58.f, 59.f, 60.f, 61.f, 62.f, 63.f, 64.f, 65.f, 66.f, 67.f, 68.f, 69.f, 70.f, 71.f, 72.f, 73.f, 74.f, 75.f, 76.f, 77.f, 78.f, 79.f, - + 120.f, 121.f, 122.f, 123.f, 124.f, 125.f, 126.f, 127.f, 128.f, 129.f,130.f, 131.f, 132.f, 133.f, 134.f, 135.f, 136.f, 137.f, 138.f, 139.f, 140.f, 141.f, 142.f, 143.f, 144.f, 145.f, 146.f, 147.f, 148.f, 149.f,150.f, 151.f, 152.f, 153.f, 154.f, 155.f, 156.f, 157.f, 158.f, 159.f, 0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f, 16.f, 17.f, 18.f, 19.f, 20.f, 21.f, 22.f, 23.f, 24.f, 25.f, 26.f, 27.f, 28.f, 29.f, 30.f, 31.f, 32.f, 33.f, 34.f , 35.f, 36.f, 37.f, 38.f, 39.f, - - 200.f, 201.f, 202.f, 203.f, 204.f, 205.f, 206.f, 207.f, 208.f, 209.f,210.f, 211.f, 212.f, 213.f, 214.f, 215.f, 216.f, 217.f, 218.f, 219.f, + + 200.f, 201.f, 202.f, 203.f, 204.f, 205.f, 206.f, 207.f, 208.f, 209.f,210.f, 211.f, 212.f, 213.f, 214.f, 215.f, 216.f, 217.f, 218.f, 219.f, 220.f, 221.f, 222.f, 223.f, 224.f, 225.f, 226.f,227.f, 228.f, 229.f, 230.f, 231.f, 232.f, 233.f, 234.f, 235.f, 236.f, 237.f, 238.f, 239.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f , 1.f, 1.f, 1.f, 1.f, 1.f, - 80.f, 81.f, 82.f, 83.f, 84.f, 85.f, 86.f, 87.f, 88.f, 89.f, 90.f, 91.f, 92.f, 93.f, 94.f, 95.f, 96.f, 97.f, 98.f, 99.f, + 80.f, 81.f, 82.f, 83.f, 84.f, 85.f, 86.f, 87.f, 88.f, 89.f, 90.f, 91.f, 92.f, 93.f, 94.f, 95.f, 96.f, 97.f, 98.f, 99.f, 100.f, 101.f, 102.f, 103.f, 104.f, 105.f, 106.f, 107.f, 108.f, 109.f,110.f, 111.f, 112.f, 113.f, 114.f, 115.f, 116.f, 117.f, 118.f, 119.f, - 160.f, 161.f, 162.f, 163.f, 164.f, 165.f, 166.f, 167.f, 168.f, 169.f, 170.f, 171.f, 172.f, 173.f, 174.f, 175.f, 176.f, 177.f, 178.f, 179.f, + 160.f, 161.f, 162.f, 163.f, 164.f, 165.f, 166.f, 167.f, 168.f, 169.f, 170.f, 171.f, 172.f, 173.f, 174.f, 175.f, 176.f, 177.f, 178.f, 179.f, 180.f, 181.f, 182.f, 183.f, 184.f, 185.f, 186.f, 187.f, 188.f, 189.f, 190.f, 191.f, 192.f, 193.f, 194.f, 195.f, 196.f, 197.f, 198.f, 199.f }; - + for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], float16_to_float32(output_ptr[i])); } @@ -626,11 +621,11 @@ TEST(scatter_update_gpu_fp32, d2214_axisX) { // 90.f, 9.f, 80.f, 100.f, // 120.f, 13.f, 110.f, 130.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 4, 1 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 3, 1, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 3, 1 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 4, 1 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 3, 1, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 3, 1 } }); // Updates auto axis = cldnn::scatter_update::scatter_update_axis::along_x; set_values(input1, { @@ -652,23 +647,23 @@ TEST(scatter_update_gpu_fp32, d2214_axisX) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_update("scatter_update", "InputDictionary", "InputText", "InputUpdates", axis) ); - - network network(engine, topology); - + + network network(engine, topology); + network.set_input_data("InputDictionary", input1); network.set_input_data("InputText", input2); network.set_input_data("InputUpdates", input3); - + auto outputs = network.execute(); auto output = outputs.at("scatter_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 30.f, 1.f, 20.f, 40.f, @@ -677,7 +672,7 @@ TEST(scatter_update_gpu_fp32, d2214_axisX) { 120.f, 13.f, 110.f, 130.f }; - + for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], output_ptr[i]); } @@ -718,11 +713,11 @@ TEST(scatter_update_gpu_int32, d6211_axisB) { // 9, 10, // 60, 70 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::i32, format::bfyx, { 6, 2, 1, 1 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::i32, format::bfyx, { 1, 2, 1, 2 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::i32, format::bfyx, { 1, 2, 2, 2 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::i32, format::bfyx, { 6, 2, 1, 1 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::i32, format::bfyx, { 1, 2, 1, 2 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::i32, format::bfyx, { 1, 2, 2, 2 } }); // Updates auto axis = cldnn::scatter_update::scatter_update_axis::along_b; set_values(input1, { @@ -747,23 +742,23 @@ TEST(scatter_update_gpu_int32, d6211_axisB) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_update("scatter_update", "InputDictionary", "InputText", "InputUpdates", axis) ); - - network network(engine, topology); - + + network network(engine, topology); + network.set_input_data("InputDictionary", input1); network.set_input_data("InputText", input2); network.set_input_data("InputUpdates", input3); - + auto outputs = network.execute(); auto output = outputs.at("scatter_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 1, 2, @@ -811,11 +806,11 @@ TEST(scatter_update_gpu_int32, d3151_axisY) { // 70, 6, 60, 50, 80, // 110, 11, 100, 90, 120 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 1, 1, 5 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::i32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 1, 2, 2 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 1, 1, 5 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::i32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 1, 2, 2 } }); // Updates auto axis = cldnn::scatter_update::scatter_update_axis::along_y; set_values(input1, { @@ -839,30 +834,30 @@ TEST(scatter_update_gpu_int32, d3151_axisY) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_update("scatter_update", "InputDictionary", "InputText", "InputUpdates", axis) ); - - network network(engine, topology); - + + network network(engine, topology); + network.set_input_data("InputDictionary", input1); network.set_input_data("InputText", input2); network.set_input_data("InputUpdates", input3); - + auto outputs = network.execute(); auto output = outputs.at("scatter_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 30, 1, 20, 200, 40, 70, 6, 60, 50, 80, 110, 11, 100, 90, 120 }; - + for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], output_ptr[i]); } @@ -880,7 +875,7 @@ TEST(scatter_update_gpu_fp32, d24111_axisF_bfzyx) { // 2.f, 0.f // // Updates: - // 1.f, 2.f, + // 1.f, 2.f, // 3.f, 4.f // // Dictionary: @@ -888,14 +883,14 @@ TEST(scatter_update_gpu_fp32, d24111_axisF_bfzyx) { // 0.f, 0.f, 0.f, 0.f // // Output: - // 2.f, 0.f, 1.f, 0.f, + // 2.f, 0.f, 1.f, 0.f, // 4.f, 0.f, 3.f, 0.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 4, 1, 1 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 2, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f32, format::bfzyx, { 2, 1, 1, 2, 1 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 4, 1, 1 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 2, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f32, format::bfzyx, { 2, 1, 1, 2, 1 } }); // Updates auto axis = cldnn::scatter_update::scatter_update_axis::along_f; set_values(input1, { @@ -913,29 +908,29 @@ TEST(scatter_update_gpu_fp32, d24111_axisF_bfzyx) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_update("scatter_update", "InputDictionary", "InputText", "InputUpdates", axis) ); - - network network(engine, topology); - + + network network(engine, topology); + network.set_input_data("InputDictionary", input1); network.set_input_data("InputText", input2); network.set_input_data("InputUpdates", input3); - - auto outputs = network.execute(); + + auto outputs = network.execute(); auto output = outputs.at("scatter_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { - 2.f, 0.f, 1.f, 0.f, + 2.f, 0.f, 1.f, 0.f, 4.f, 0.f, 3.f, 0.f }; - + for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], output_ptr[i]); } @@ -970,19 +965,19 @@ TEST(scatter_update_gpu_int32, d121251_bfwzyx_axisB) { // 0, 1, 2, 3, 4, // 5, 6, 7, 8, 9, // 10, 11, 12, 13, 14, - // 15, 16, 17, 18, 19 + // 15, 16, 17, 18, 19 // // Output: // 40, 30, 20, 3, 50, // 80, 70, 60, 8, 90, // 120, 110, 100, 13, 130, - // 160, 150, 140, 18, 170 + // 160, 150, 140, 18, 170 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::i32, format::bfwzyx, tensor{ batch(1), feature(2), spatial(1, 5, 2, 1) }}); // Dictionary - auto input2 = memory::allocate(engine, { data_types::i32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::i32, format::bfwzyx, tensor{ batch(1), feature(2), spatial(2, 2, 2, 1) }}); // Updates + auto input1 = engine.allocate_memory({ data_types::i32, format::bfwzyx, tensor{ batch(1), feature(2), spatial(1, 5, 2, 1) }}); // Dictionary + auto input2 = engine.allocate_memory({ data_types::i32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::i32, format::bfwzyx, tensor{ batch(1), feature(2), spatial(2, 2, 2, 1) }}); // Updates auto axis = cldnn::scatter_update::scatter_update_axis::along_y; set_values(input1, { @@ -1009,23 +1004,23 @@ TEST(scatter_update_gpu_int32, d121251_bfwzyx_axisB) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_update("scatter_update", "InputDictionary", "InputText", "InputUpdates", axis) ); - - network network(engine, topology); - + + network network(engine, topology); + network.set_input_data("InputDictionary", input1); network.set_input_data("InputText", input2); network.set_input_data("InputUpdates", input3); - + auto outputs = network.execute(); - + auto output = outputs.at("scatter_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 40, 30, 20, 3, 50, @@ -1052,7 +1047,7 @@ TEST(scatter_update_gpu_fp32, d21511_bfzyx_axisX) { // 0.f, 1.f // // Updates: - // 10.f, 20.f, + // 10.f, 20.f, // 30.f, 40.f, // 50.f, 60.f, // 70.f, 80.f @@ -1066,11 +1061,11 @@ TEST(scatter_update_gpu_fp32, d21511_bfzyx_axisX) { // 70.f, 80.f, 7.f, 50.f, 60.f // - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfzyx, { 2, 1, 1, 1, 5 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Indices - auto input3 = memory::allocate(engine, { data_types::f32, format::bfzyx, { 2, 1, 1, 2, 2 } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f32, format::bfzyx, { 2, 1, 1, 1, 5 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); // Indices + auto input3 = engine.allocate_memory({ data_types::f32, format::bfzyx, { 2, 1, 1, 2, 2 } }); // Updates auto axis = cldnn::scatter_update::scatter_update_axis::along_z; set_values(input1, { @@ -1084,31 +1079,31 @@ TEST(scatter_update_gpu_fp32, d21511_bfzyx_axisX) { }); set_values(input3, { - 10.f, 20.f, + 10.f, 20.f, 30.f, 40.f, 50.f, 60.f, 70.f, 80.f }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_update("scatter_update", "InputDictionary", "InputText", "InputUpdates", axis) ); - + network network(engine, topology); - - + + network.set_input_data("InputDictionary", input1); network.set_input_data("InputText", input2); network.set_input_data("InputUpdates", input3); - + auto outputs = network.execute(); auto output = outputs.at("scatter_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 30.f, 40.f, 2.f, 10.f, 20.f, @@ -1133,16 +1128,16 @@ TEST(scatter_update_gpu_fp32, d1252_axisY_bfwzyx) { // 3.f, 4.f // // Updates: - // 20.f, 30.f, + // 20.f, 30.f, // 40.f, 50.f // - // 60.f, 70.f, + // 60.f, 70.f, // 80.f, 90.f // - // 100.f, 110.f, + // 100.f, 110.f, // 120.f, 130.f // - // 140.f, 150.f, + // 140.f, 150.f, // 160.f, 170.f // // Dictionary: @@ -1153,11 +1148,11 @@ TEST(scatter_update_gpu_fp32, d1252_axisY_bfwzyx) { // 40.f, 50.f, 2.f, 3.f, 20.f, 30.f, 60.f, 70.f, 80.f, 90.f, // 120.f, 130.f, 12.f, 13.f, 100.f, 110.f, 140.f, 150.f, 160.f, 170.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 2, 5 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 1, 1, 2 } }); // Indices - auto input3 = memory::allocate(engine, { data_types::f32, format::bfwzyx, tensor{ batch(1), feature(2), spatial(2, 2, 1, 2) } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 2, 5 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 1, 1, 2 } }); // Indices + auto input3 = engine.allocate_memory({ data_types::f32, format::bfwzyx, tensor{ batch(1), feature(2), spatial(2, 2, 1, 2) } }); // Updates auto axis = cldnn::scatter_update::scatter_update_axis::along_y; set_values(input1, { @@ -1171,43 +1166,43 @@ TEST(scatter_update_gpu_fp32, d1252_axisY_bfwzyx) { }); set_values(input3, { - 20.f, 30.f, + 20.f, 30.f, 40.f, 50.f, - 60.f, 70.f, + 60.f, 70.f, 80.f, 90.f, - - 100.f, 110.f, + + 100.f, 110.f, 120.f, 130.f, - - 140.f, 150.f, + + 140.f, 150.f, 160.f, 170.f }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_update("scatter_update", "InputDictionary", "InputText", "InputUpdates", axis) ); - - network network(engine, topology); - + + network network(engine, topology); + network.set_input_data("InputDictionary", input1); network.set_input_data("InputText", input2); network.set_input_data("InputUpdates", input3); - + auto outputs = network.execute(); auto output = outputs.at("scatter_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 40.f, 50.f, 2.f, 3.f, 20.f, 30.f, 60.f, 70.f, 80.f, 90.f, 120.f, 130.f, 12.f, 13.f, 100.f, 110.f, 140.f, 150.f, 160.f, 170.f }; - + for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], output_ptr[i]); } @@ -1240,11 +1235,11 @@ TEST(scatter_update_gpu_int32, d2115_axisX_bfwzyx) { // 0, 30, 20, 50, 40, // 5, 70, 60, 90, 80 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::i32, format::bfyx, { 2, 1, 5, 1 }}); // Dictionary - auto input2 = memory::allocate(engine, { data_types::i32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::i32, format::bfwzyx, tensor{ batch(2), feature(1), spatial(1, 2, 2, 1) }}); // Updates + auto input1 = engine.allocate_memory({ data_types::i32, format::bfyx, { 2, 1, 5, 1 }}); // Dictionary + auto input2 = engine.allocate_memory({ data_types::i32, format::bfyx, { 2, 2, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::i32, format::bfwzyx, tensor{ batch(2), feature(1), spatial(1, 2, 2, 1) }}); // Updates auto axis = cldnn::scatter_update::scatter_update_axis::along_x; set_values(input1, { @@ -1265,29 +1260,29 @@ TEST(scatter_update_gpu_int32, d2115_axisX_bfwzyx) { }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_update("scatter_update", "InputDictionary", "InputText", "InputUpdates", axis) ); - - network network(engine, topology); - + + network network(engine, topology); + network.set_input_data("InputDictionary", input1); network.set_input_data("InputText", input2); network.set_input_data("InputUpdates", input3); - + auto outputs = network.execute(); auto output = outputs.at("scatter_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0, 30, 20, 50, 40, 5, 70, 60, 90, 80 }; - + for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], output_ptr[i]); } @@ -1322,11 +1317,11 @@ TEST(scatter_update_gpu_fp16, d21214_bfzyx_axisX_bfwzyx) { // 8.f, 100.f, 90.f, 80.f, // 12.f, 130.f, 120.f, 110.f - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfzyx, { 2, 1, 4, 1, 2 } }); // Dictionary - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 3, 1, 1 } }); // Indexes - auto input3 = memory::allocate(engine, { data_types::f16, format::bfwzyx, tensor{ batch(2), feature(1), spatial(3, 1, 1, 2) } }); // Updates + auto input1 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 2, 1, 4, 1, 2 } }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 3, 1, 1 } }); // Indexes + auto input3 = engine.allocate_memory({ data_types::f16, format::bfwzyx, tensor{ batch(2), feature(1), spatial(3, 1, 1, 2) } }); // Updates auto axis = cldnn::scatter_update::scatter_update_axis::along_x; set_values(input1, { @@ -1341,30 +1336,30 @@ TEST(scatter_update_gpu_fp16, d21214_bfzyx_axisX_bfwzyx) { }); set_values(input3, { - FLOAT16(20.0f), FLOAT16(30.0f), FLOAT16(40.0f), + FLOAT16(20.0f), FLOAT16(30.0f), FLOAT16(40.0f), FLOAT16(50.0f), FLOAT16(60.0f), FLOAT16(70.0f), - FLOAT16(80.0f), FLOAT16(90.0f), FLOAT16(100.0f), + FLOAT16(80.0f), FLOAT16(90.0f), FLOAT16(100.0f), FLOAT16(110.0f), FLOAT16(120.0f), FLOAT16(130.0f) }); topology topology; - topology.add(input_layout("InputDictionary", input1.get_layout())); - topology.add(input_layout("InputText", input2.get_layout())); - topology.add(input_layout("InputUpdates", input3.get_layout())); + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); topology.add( scatter_update("scatter_update", "InputDictionary", "InputText", "InputUpdates", axis) ); - - network network(engine, topology); - + + network network(engine, topology); + network.set_input_data("InputDictionary", input1); network.set_input_data("InputText", input2); network.set_input_data("InputUpdates", input3); - + auto outputs = network.execute(); auto output = outputs.at("scatter_update").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 40.f, 30.f, 20.f, @@ -1372,7 +1367,7 @@ TEST(scatter_update_gpu_fp16, d21214_bfzyx_axisX_bfwzyx) { 8.f, 100.f, 90.f, 80.f, 12.f, 130.f, 120.f, 110.f }; - + for (size_t i = 0; i < expected_results.size(); ++i) { EXPECT_EQ(expected_results[i], float16_to_float32(output_ptr[i])); } diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/select_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/select_gpu_test.cpp index fff6997834b640..c4e698f82108b0 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/select_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/select_gpu_test.cpp @@ -3,30 +3,27 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include "api/select.hpp" -#include -#include -#include -#include "test_utils/test_utils.h" + +#include "test_utils.h" + +#include +#include "cldnn/primitives/select.hpp" using namespace cldnn; -using namespace tests; +using namespace ::tests; // select_gpu_f32 TEST(select_gpu_f32, select_basic) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb, { 2, 2, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); set_values(input, { @@ -62,7 +59,7 @@ TEST(select_gpu_f32, select_basic) { 15.f, 0.5f, 8.f, 12.f, 4.f, 6.5f, 8.f, -2.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -71,16 +68,16 @@ TEST(select_gpu_f32, select_basic) { } TEST(select_gpu_f32, select_basic_negative) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); set_values(input, { @@ -116,7 +113,7 @@ TEST(select_gpu_f32, select_basic_negative) { 15.f, 0.5f, 8.f, 12.f, 4.f, 6.5f, 8.f, -2.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -125,16 +122,16 @@ TEST(select_gpu_f32, select_basic_negative) { } TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_mask_2x2x1x2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 1, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 1, 2 } }); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input1", "input2")); set_values(input1, { @@ -202,7 +199,7 @@ TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_mask_2x2x1x2) { -0.5f, -2.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -211,16 +208,16 @@ TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_mask_2x2x1x2) { } TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_mask_1x1x1x1) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input1", "input2")); set_values(input1, { @@ -278,7 +275,7 @@ TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_mask_1x1x1x1) { -0.5f, -2.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -287,16 +284,16 @@ TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_mask_1x1x1x1) { } TEST(select_gpu_f32, select_basic_comma_byxf_2x2x2x2_bcast_mask_2x2x2x1) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::byxf, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::byxf ,{ 2, 2, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::byxf, { 2, 2, 2, 1 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::byxf, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::byxf ,{ 2, 2, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::byxf, { 2, 2, 2, 1 } }); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input1", "input2")); set_values(input1, { @@ -358,7 +355,7 @@ TEST(select_gpu_f32, select_basic_comma_byxf_2x2x2x2_bcast_mask_2x2x2x1) { -0.5f, 8.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -367,16 +364,16 @@ TEST(select_gpu_f32, select_basic_comma_byxf_2x2x2x2_bcast_mask_2x2x2x1) { } TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_in2_2x2x1x2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input1", "input2")); set_values(input1, { @@ -444,7 +441,7 @@ TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_in2_2x2x1x2) { 8.f, -0.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -453,16 +450,16 @@ TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_in2_2x2x1x2) { } TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_in1_2x2x2x1_bcast_in2_2x2x1x2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 1 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 1 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input1", "input2")); set_values(input1, { @@ -526,7 +523,7 @@ TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_in1_2x2x2x1_bcast_in2_2x2x1 4.f, -0.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -535,16 +532,16 @@ TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_in1_2x2x2x1_bcast_in2_2x2x1 } TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_mask_2x1x2x2_in1_1x2x2x2_in2_2x2x1x2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 1, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 1, 2, 2 } }); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input1", "input2")); set_values(input1, { @@ -600,7 +597,7 @@ TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_mask_2x1x2x2_in1_1x2x2x2_in -0.5f, 5.2f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -609,16 +606,16 @@ TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_mask_2x1x2x2_in1_1x2x2x2_in } TEST(select_gpu_f32, select_basic_comma_byxf_2x2x2x2_bcast_mask_2x1x2x2_in1_2x2x2x1_in2_2x2x1x2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::byxf, { 2, 2, 2, 1 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::byxf ,{ 2, 2, 1, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::byxf, { 2, 1, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::byxf, { 2, 2, 2, 1 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::byxf ,{ 2, 2, 1, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::byxf, { 2, 1, 2, 2 } }); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input1", "input2")); set_values(input1, { @@ -644,7 +641,7 @@ TEST(select_gpu_f32, select_basic_comma_byxf_2x2x2x2_bcast_mask_2x1x2x2_in1_2x2x 0.f, 0.1f, - 0.5f, + 0.5f, -0.f, -0.5f, @@ -676,7 +673,7 @@ TEST(select_gpu_f32, select_basic_comma_byxf_2x2x2x2_bcast_mask_2x1x2x2_in1_2x2x -2.f, 6.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -685,16 +682,16 @@ TEST(select_gpu_f32, select_basic_comma_byxf_2x2x2x2_bcast_mask_2x1x2x2_in1_2x2x } TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_in2_1x1x1x1) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input1", "input2")); set_values(input1, { @@ -752,7 +749,7 @@ TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_in2_1x1x1x1) { 8.f, 1.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -761,16 +758,16 @@ TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_in2_1x1x1x1) { } TEST(select_gpu_f32, select_basic_comma_byxf_2x2x2x2_bcast_in2_2x2x2x1) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::byxf, { 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::byxf ,{ 2, 2, 2, 1 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::byxf, { 2, 2, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::byxf, { 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::byxf ,{ 2, 2, 2, 1 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::byxf, { 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input1", "input2")); set_values(input1, { @@ -800,7 +797,7 @@ TEST(select_gpu_f32, select_basic_comma_byxf_2x2x2x2_bcast_in2_2x2x2x1) { 0.5f, 0.7f, 0.f, 0.f, - 0.f, 0.f, + 0.f, 0.f, -0.f, -0.1f, -0.f, -0.5f, @@ -832,7 +829,7 @@ TEST(select_gpu_f32, select_basic_comma_byxf_2x2x2x2_bcast_in2_2x2x2x1) { 8.f, 10.0f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -841,16 +838,16 @@ TEST(select_gpu_f32, select_basic_comma_byxf_2x2x2x2_bcast_in2_2x2x2x1) { } TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_in1_2x2x1x2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input1", "input2")); set_values(input1, { @@ -918,7 +915,7 @@ TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_in1_2x2x1x2) { 8.f, -2.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -927,16 +924,16 @@ TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_in1_2x2x1x2) { } TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_in1_1x1x1x1) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input1", "input2")); set_values(input1, { @@ -994,7 +991,7 @@ TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_in1_1x1x1x1) { 1.f, -2.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -1003,16 +1000,16 @@ TEST(select_gpu_f32, select_basic_bfyx_2x2x2x2_bcast_in1_1x1x1x1) { } TEST(select_gpu_f32, select_basic_comma_byxf_2x2x2x2_bcast_in1_2x2x2x1) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::byxf, { 2, 2, 2, 1 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::byxf ,{ 2, 2, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::byxf, { 2, 2, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::byxf, { 2, 2, 2, 1 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::byxf ,{ 2, 2, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::byxf, { 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input1", "input2")); set_values(input1, { @@ -1042,7 +1039,7 @@ TEST(select_gpu_f32, select_basic_comma_byxf_2x2x2x2_bcast_in1_2x2x2x1) { 0.f, 0.f, 0.1f, 0.3f, - 0.5f, 0.7f, + 0.5f, 0.7f, -0.f, -0.1f, -0.f, -0.5f, @@ -1074,7 +1071,7 @@ TEST(select_gpu_f32, select_basic_comma_byxf_2x2x2x2_bcast_in1_2x2x2x1) { 7.f, -2.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -1083,16 +1080,16 @@ TEST(select_gpu_f32, select_basic_comma_byxf_2x2x2x2_bcast_in1_2x2x2x1) { } TEST(select_gpu_f32, select_basic_comma_byxf_2x2x2x2_bcast_mask_2x1x2x2_in1_2x2x2x1) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::byxf, { 2, 2, 2, 1 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::byxf ,{ 2, 2, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::byxf, { 2, 1, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::byxf, { 2, 2, 2, 1 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::byxf ,{ 2, 2, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::byxf, { 2, 1, 2, 2 } }); topology topology; - topology.add(input_layout("input1", input1.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input1", input1->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input1", "input2")); set_values(input1, { @@ -1122,7 +1119,7 @@ TEST(select_gpu_f32, select_basic_comma_byxf_2x2x2x2_bcast_mask_2x1x2x2_in1_2x2x 0.f, 0.1f, - 0.5f, + 0.5f, -0.f, -0.5f, @@ -1154,7 +1151,7 @@ TEST(select_gpu_f32, select_basic_comma_byxf_2x2x2x2_bcast_mask_2x1x2x2_in1_2x2x -0.5f, -2.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -1163,16 +1160,16 @@ TEST(select_gpu_f32, select_basic_comma_byxf_2x2x2x2_bcast_mask_2x1x2x2_in1_2x2x } TEST(select_gpu_f32, select_basic_comma) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); set_values(input, { @@ -1208,7 +1205,7 @@ TEST(select_gpu_f32, select_basic_comma) { 15.f, 0.5f, 8.f, 12.f, 4.f, 6.5f, 8.f, -2.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -1217,79 +1214,79 @@ TEST(select_gpu_f32, select_basic_comma) { } TEST(select_gpu_f32, select_basic_error_input_sizes) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb,{ 3, 4, 5, 6 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb,{ 3, 4, 5, 6 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); EXPECT_ANY_THROW(network(engine, topology)); } TEST(select_gpu_f32, select_basic_error_mask_sizes) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::yxfb,{ 3, 4, 5, 6 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::yxfb,{ 3, 4, 5, 6 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); EXPECT_ANY_THROW(network(engine, topology)); } TEST(select_gpu_f32, select_basic_error_input_types) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::i8, format::yxfb,{ 2, 2, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::i8, format::yxfb,{ 2, 2, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); EXPECT_ANY_THROW(network(engine, topology)); } TEST(select_gpu_f32, select_basic_error_input_formats) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::bfyx,{ 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); EXPECT_ANY_THROW(network(engine, topology)); } TEST(select_gpu_f32, select_basic_byxf) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::byxf,{ 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::byxf,{ 2, 2, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::byxf,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::byxf,{ 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::byxf,{ 2, 2, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::byxf,{ 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); set_values(input, { @@ -1325,7 +1322,7 @@ TEST(select_gpu_f32, select_basic_byxf) { 15.f, 0.5f, 8.f, 12.f, 4.f, 6.5f, 8.f, -2.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -1334,16 +1331,16 @@ TEST(select_gpu_f32, select_basic_byxf) { } TEST(select_gpu_f32, select_basic_mask_f16) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f16, format::yxfb,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f16, format::yxfb,{ 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); set_values(input, { @@ -1379,7 +1376,7 @@ TEST(select_gpu_f32, select_basic_mask_f16) { 15.f, 0.5f, 8.f, 12.f, 4.f, 6.5f, 8.f, -2.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -1388,16 +1385,16 @@ TEST(select_gpu_f32, select_basic_mask_f16) { } TEST(select_gpu_f32, select_basic_mask_i8) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::i8, format::yxfb,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::i8, format::yxfb,{ 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); set_values(input, { @@ -1433,7 +1430,7 @@ TEST(select_gpu_f32, select_basic_mask_i8) { 15.f, 0.5f, 8.f, 12.f, 4.f, 6.5f, 8.f, -2.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -1442,16 +1439,16 @@ TEST(select_gpu_f32, select_basic_mask_i8) { } TEST(select_gpu_f32, select_basic_mask_u8) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::u8, format::yxfb,{ 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb,{ 2, 2, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::u8, format::yxfb,{ 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); set_values(input, { @@ -1487,7 +1484,7 @@ TEST(select_gpu_f32, select_basic_mask_u8) { 15.f, 0.5f, 8.f, 12.f, 4.f, 6.5f, 8.f, -2.5f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 16; i++) { @@ -1496,16 +1493,16 @@ TEST(select_gpu_f32, select_basic_mask_u8) { } TEST(select_gpu_f32, select_basic_1x1x2x2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 1, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 1, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 1, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 1, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 1, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); set_values(input, { @@ -1529,11 +1526,11 @@ TEST(select_gpu_f32, select_basic_1x1x2x2) { auto output = outputs.at("select").get_memory(); - float answers[4] = { + float answers[4] = { 0.5f, 2.5f, 2.f, 0.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 4; i++) { @@ -1542,16 +1539,16 @@ TEST(select_gpu_f32, select_basic_1x1x2x2) { } TEST(select_gpu_f32, select_basic_bfyx_1x1x2x2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); set_values(input, { @@ -1583,7 +1580,7 @@ TEST(select_gpu_f32, select_basic_bfyx_1x1x2x2) { 2.f, 0.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 4; i++) { @@ -1592,16 +1589,16 @@ TEST(select_gpu_f32, select_basic_bfyx_1x1x2x2) { } TEST(select_gpu_f32, select_basic_byxf_1x1x2x2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::byxf,{ 1, 1, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f32, format::byxf,{ 1, 1, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::byxf,{ 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::byxf,{ 1, 1, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f32, format::byxf,{ 1, 1, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::byxf,{ 1, 1, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); set_values(input, { @@ -1633,7 +1630,7 @@ TEST(select_gpu_f32, select_basic_byxf_1x1x2x2) { 2.f, 0.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 4; i++) { @@ -1643,16 +1640,16 @@ TEST(select_gpu_f32, select_basic_byxf_1x1x2x2) { // select_gpu_f16 TEST(select_gpu_f16, select_basic_1x1x2x2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); set_values(input, { @@ -1684,7 +1681,7 @@ TEST(select_gpu_f16, select_basic_1x1x2x2) { 2, 0 }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 4; i++) { @@ -1693,16 +1690,16 @@ TEST(select_gpu_f16, select_basic_1x1x2x2) { } TEST(select_gpu_f16, select_basic_mask_f32_1x1x2x2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 1, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); set_values(input, { @@ -1734,7 +1731,7 @@ TEST(select_gpu_f16, select_basic_mask_f32_1x1x2x2) { 2, 0 }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 4; i++) { @@ -1743,16 +1740,16 @@ TEST(select_gpu_f16, select_basic_mask_f32_1x1x2x2) { } TEST(select_gpu_f16, select_basic_mask_i8_1x1x2x2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::i8, format::yxfb,{ 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::i8, format::yxfb,{ 1, 1, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); set_values(input, { @@ -1784,7 +1781,7 @@ TEST(select_gpu_f16, select_basic_mask_i8_1x1x2x2) { 2, 0 }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 4; i++) { @@ -1793,16 +1790,16 @@ TEST(select_gpu_f16, select_basic_mask_i8_1x1x2x2) { } TEST(select_gpu_f16, select_basic_mask_u8_1x1x2x2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::u8, format::yxfb,{ 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::u8, format::yxfb,{ 1, 1, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); set_values(input, { @@ -1834,7 +1831,7 @@ TEST(select_gpu_f16, select_basic_mask_u8_1x1x2x2) { 2, 0 }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 4; i++) { @@ -1844,16 +1841,16 @@ TEST(select_gpu_f16, select_basic_mask_u8_1x1x2x2) { // select_gpu_i8 TEST(select_gpu_i8, select_basic_1x1x2x2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::i8, format::yxfb,{ 1, 1, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::i8, format::yxfb,{ 1, 1, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::i8, format::yxfb,{ 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::i8, format::yxfb,{ 1, 1, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::i8, format::yxfb,{ 1, 1, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::i8, format::yxfb,{ 1, 1, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); set_values(input, { @@ -1885,7 +1882,7 @@ TEST(select_gpu_i8, select_basic_1x1x2x2) { 2, 0 }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 4; i++) { @@ -1894,16 +1891,16 @@ TEST(select_gpu_i8, select_basic_1x1x2x2) { } TEST(select_gpu_i8, select_basic_mask_f32_1x1x2x2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::i8, format::yxfb,{ 1, 1, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::i8, format::yxfb,{ 1, 1, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::i8, format::yxfb,{ 1, 1, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::i8, format::yxfb,{ 1, 1, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 1, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); set_values(input, { @@ -1935,7 +1932,7 @@ TEST(select_gpu_i8, select_basic_mask_f32_1x1x2x2) { 2, 0 }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 4; i++) { @@ -1944,16 +1941,16 @@ TEST(select_gpu_i8, select_basic_mask_f32_1x1x2x2) { } TEST(select_gpu_i8, select_basic_mask_f16_1x1x2x2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::i8, format::yxfb,{ 1, 1, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::i8, format::yxfb,{ 1, 1, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::i8, format::yxfb,{ 1, 1, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::i8, format::yxfb,{ 1, 1, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); set_values(input, { @@ -1985,7 +1982,7 @@ TEST(select_gpu_i8, select_basic_mask_f16_1x1x2x2) { 2, 0 }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 4; i++) { @@ -1994,16 +1991,16 @@ TEST(select_gpu_i8, select_basic_mask_f16_1x1x2x2) { } TEST(select_gpu_i8, select_basic_mask_u8_1x1x2x2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::i8, format::yxfb,{ 1, 1, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::i8, format::yxfb,{ 1, 1, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::u8, format::yxfb,{ 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::i8, format::yxfb,{ 1, 1, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::i8, format::yxfb,{ 1, 1, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::u8, format::yxfb,{ 1, 1, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); set_values(input, { @@ -2035,7 +2032,7 @@ TEST(select_gpu_i8, select_basic_mask_u8_1x1x2x2) { 2, 0 }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 4; i++) { @@ -2045,16 +2042,16 @@ TEST(select_gpu_i8, select_basic_mask_u8_1x1x2x2) { // select_gpu_u8 TEST(select_gpu_u8, select_basic_1x1x2x2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::u8, format::yxfb,{ 1, 1, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::u8, format::yxfb,{ 1, 1, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::u8, format::yxfb,{ 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::u8, format::yxfb,{ 1, 1, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::u8, format::yxfb,{ 1, 1, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::u8, format::yxfb,{ 1, 1, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); set_values(input, { @@ -2086,7 +2083,7 @@ TEST(select_gpu_u8, select_basic_1x1x2x2) { 255, 0 }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 4; i++) { @@ -2095,16 +2092,16 @@ TEST(select_gpu_u8, select_basic_1x1x2x2) { } TEST(select_gpu_u8, select_basic_mask_f32_1x1x2x2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::u8, format::yxfb,{ 1, 1, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::u8, format::yxfb,{ 1, 1, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::u8, format::yxfb,{ 1, 1, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::u8, format::yxfb,{ 1, 1, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 1, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); set_values(input, { @@ -2136,7 +2133,7 @@ TEST(select_gpu_u8, select_basic_mask_f32_1x1x2x2) { 255, 0 }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 4; i++) { @@ -2145,16 +2142,16 @@ TEST(select_gpu_u8, select_basic_mask_f32_1x1x2x2) { } TEST(select_gpu_u8, select_basic_mask_f16_1x1x2x2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::u8, format::yxfb,{ 1, 1, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::u8, format::yxfb,{ 1, 1, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::u8, format::yxfb,{ 1, 1, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::u8, format::yxfb,{ 1, 1, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::f16, format::yxfb,{ 1, 1, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); set_values(input, { @@ -2186,7 +2183,7 @@ TEST(select_gpu_u8, select_basic_mask_f16_1x1x2x2) { 255, 0 }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 4; i++) { @@ -2195,16 +2192,16 @@ TEST(select_gpu_u8, select_basic_mask_f16_1x1x2x2) { } TEST(select_gpu_u8, select_basic_mask_i8_1x1x2x2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::u8, format::yxfb,{ 1, 1, 2, 2 } }); - auto input2 = memory::allocate(engine, { data_types::u8, format::yxfb,{ 1, 1, 2, 2 } }); - auto mask = memory::allocate(engine, { data_types::i8, format::yxfb,{ 1, 1, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::u8, format::yxfb,{ 1, 1, 2, 2 } }); + auto input2 = engine.allocate_memory({ data_types::u8, format::yxfb,{ 1, 1, 2, 2 } }); + auto mask = engine.allocate_memory({ data_types::i8, format::yxfb,{ 1, 1, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("input2", input2.get_layout())); - topology.add(input_layout("mask", mask.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(input_layout("mask", mask->get_layout())); topology.add(cldnn::select("select", "mask", "input", "input2")); set_values(input, { @@ -2236,7 +2233,7 @@ TEST(select_gpu_u8, select_basic_mask_i8_1x1x2x2) { 255, 0 }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (int i = 0; i < 4; i++) { diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/shuffle_channels_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/shuffle_channels_test.cpp index a1bbf1987715b5..55a5e8fa8979c0 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/shuffle_channels_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/shuffle_channels_test.cpp @@ -3,24 +3,21 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include -#include -#include +#include "test_utils.h" + +#include +#include #include -#include using namespace cldnn; using namespace ::tests; TEST(shuffle_channels_fp32_gpu, d1_15_2_2_ax1_g5) { - engine engine; + auto& engine = get_test_engine(); - auto input0 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 15, 2, 2 } }); + auto input0 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 15, 2, 2 } }); int32_t axis = 1; int32_t group = 5; @@ -34,7 +31,7 @@ TEST(shuffle_channels_fp32_gpu, d1_15_2_2_ax1_g5) { }); topology topology; - topology.add(input_layout("Input0", input0.get_layout())); + topology.add(input_layout("Input0", input0->get_layout())); topology.add( shuffle_channels("shuffle_channels", "Input0", group, axis) ); @@ -46,7 +43,7 @@ TEST(shuffle_channels_fp32_gpu, d1_15_2_2_ax1_g5) { auto outputs = network.execute(); auto output = outputs.at("shuffle_channels").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 1.f, 2.f, 3.f, 12.f, 13.f, 14.f, 15.f, 24.f, 25.f, 26.f, 27.f, 36.f, 37.f, 38.f, 39.f, 48.f, 49.f, 50.f, 51.f, @@ -60,9 +57,9 @@ TEST(shuffle_channels_fp32_gpu, d1_15_2_2_ax1_g5) { } TEST(shuffle_channels_fp32_gpu, d1_15_2_2_axm3_g5) { - engine engine; + auto& engine = get_test_engine(); - auto input0 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 15, 2, 2 } }); + auto input0 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 15, 2, 2 } }); int32_t axis = -3; int32_t group = 5; @@ -76,7 +73,7 @@ TEST(shuffle_channels_fp32_gpu, d1_15_2_2_axm3_g5) { }); topology topology; - topology.add(input_layout("Input0", input0.get_layout())); + topology.add(input_layout("Input0", input0->get_layout())); topology.add( shuffle_channels("shuffle_channels", "Input0", group, axis) ); @@ -88,7 +85,7 @@ TEST(shuffle_channels_fp32_gpu, d1_15_2_2_axm3_g5) { auto outputs = network.execute(); auto output = outputs.at("shuffle_channels").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 1.f, 2.f, 3.f, 12.f, 13.f, 14.f, 15.f, 24.f, 25.f, 26.f, 27.f, 36.f, 37.f, 38.f, 39.f, 48.f, 49.f, 50.f, 51.f, @@ -102,9 +99,9 @@ TEST(shuffle_channels_fp32_gpu, d1_15_2_2_axm3_g5) { } TEST(shuffle_channels_fp32_gpu, d15_2_2_ax0_g5) { - engine engine; + auto& engine = get_test_engine(); - auto input0 = memory::allocate(engine, { data_types::f32, format::bfyx, { 15, 2, 1, 2 } }); + auto input0 = engine.allocate_memory({ data_types::f32, format::bfyx, { 15, 2, 1, 2 } }); int32_t axis = 0; int32_t group = 5; @@ -118,7 +115,7 @@ TEST(shuffle_channels_fp32_gpu, d15_2_2_ax0_g5) { }); topology topology; - topology.add(input_layout("Input0", input0.get_layout())); + topology.add(input_layout("Input0", input0->get_layout())); topology.add( shuffle_channels("shuffle_channels", "Input0", group, axis) ); @@ -130,7 +127,7 @@ TEST(shuffle_channels_fp32_gpu, d15_2_2_ax0_g5) { auto outputs = network.execute(); auto output = outputs.at("shuffle_channels").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 1.f, 2.f, 3.f, 12.f, 13.f, 14.f, 15.f, 24.f, 25.f, 26.f, 27.f, 36.f, 37.f, 38.f, 39.f, 48.f, 49.f, 50.f, 51.f, @@ -144,9 +141,9 @@ TEST(shuffle_channels_fp32_gpu, d15_2_2_ax0_g5) { } TEST(shuffle_channels_fp32_gpu, d15_2_2_axm4_g5) { - engine engine; + auto& engine = get_test_engine(); - auto input0 = memory::allocate(engine, { data_types::f32, format::bfyx, { 15, 2, 1, 2 } }); + auto input0 = engine.allocate_memory({ data_types::f32, format::bfyx, { 15, 2, 1, 2 } }); int32_t axis = -4; int32_t group = 5; @@ -160,7 +157,7 @@ TEST(shuffle_channels_fp32_gpu, d15_2_2_axm4_g5) { }); topology topology; - topology.add(input_layout("Input0", input0.get_layout())); + topology.add(input_layout("Input0", input0->get_layout())); topology.add( shuffle_channels("shuffle_channels", "Input0", group, axis) ); @@ -172,7 +169,7 @@ TEST(shuffle_channels_fp32_gpu, d15_2_2_axm4_g5) { auto outputs = network.execute(); auto output = outputs.at("shuffle_channels").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 1.f, 2.f, 3.f, 12.f, 13.f, 14.f, 15.f, 24.f, 25.f, 26.f, 27.f, 36.f, 37.f, 38.f, 39.f, 48.f, 49.f, 50.f, 51.f, @@ -186,9 +183,9 @@ TEST(shuffle_channels_fp32_gpu, d15_2_2_axm4_g5) { } TEST(shuffle_channels_fp32_gpu, d2_2_6_axm2_g3) { - engine engine; + auto& engine = get_test_engine(); - auto input0 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 6 } }); + auto input0 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 6 } }); int32_t axis = -2; int32_t group = 3; @@ -199,7 +196,7 @@ TEST(shuffle_channels_fp32_gpu, d2_2_6_axm2_g3) { }); topology topology; - topology.add(input_layout("Input0", input0.get_layout())); + topology.add(input_layout("Input0", input0->get_layout())); topology.add( shuffle_channels("shuffle_channels", "Input0", group, axis) ); @@ -211,7 +208,7 @@ TEST(shuffle_channels_fp32_gpu, d2_2_6_axm2_g3) { auto outputs = network.execute(); auto output = outputs.at("shuffle_channels").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 2.f, 4.f, 1.f, 3.f, 5.f, 6.f, 8.f, 10.f, 7.f, 9.f, 11.f, @@ -224,9 +221,9 @@ TEST(shuffle_channels_fp32_gpu, d2_2_6_axm2_g3) { } TEST(shuffle_channels_fp32_gpu, d2_6_2_axm3_g3) { - engine engine; + auto& engine = get_test_engine(); - auto input0 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 6, 1, 2 } }); + auto input0 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 6, 1, 2 } }); int32_t axis = -3; int32_t group = 3; @@ -237,7 +234,7 @@ TEST(shuffle_channels_fp32_gpu, d2_6_2_axm3_g3) { }); topology topology; - topology.add(input_layout("Input0", input0.get_layout())); + topology.add(input_layout("Input0", input0->get_layout())); topology.add( shuffle_channels("shuffle_channels", "Input0", group, axis) ); @@ -249,7 +246,7 @@ TEST(shuffle_channels_fp32_gpu, d2_6_2_axm3_g3) { auto outputs = network.execute(); auto output = outputs.at("shuffle_channels").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 1.f, 4.f, 5.f, 8.f, 9.f, 2.f, 3.f, 6.f, 7.f, 10.f, 11.f, @@ -262,9 +259,9 @@ TEST(shuffle_channels_fp32_gpu, d2_6_2_axm3_g3) { } TEST(shuffle_channels_fp32_gpu, d2_2_6_axm2_g2) { - engine engine; + auto& engine = get_test_engine(); - auto input0 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 6 } }); + auto input0 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 6 } }); int32_t axis = -2; int32_t group = 2; @@ -275,7 +272,7 @@ TEST(shuffle_channels_fp32_gpu, d2_2_6_axm2_g2) { }); topology topology; - topology.add(input_layout("Input0", input0.get_layout())); + topology.add(input_layout("Input0", input0->get_layout())); topology.add( shuffle_channels("shuffle_channels", "Input0", group, axis) ); @@ -287,7 +284,7 @@ TEST(shuffle_channels_fp32_gpu, d2_2_6_axm2_g2) { auto outputs = network.execute(); auto output = outputs.at("shuffle_channels").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 3.f, 1.f, 4.f, 2.f, 5.f, 6.f, 9.f, 7.f, 10.f, 8.f, 11.f, @@ -300,9 +297,9 @@ TEST(shuffle_channels_fp32_gpu, d2_2_6_axm2_g2) { } TEST(shuffle_channels_fp32_gpu, d2_6_2_axm3_g2) { - engine engine; + auto& engine = get_test_engine(); - auto input0 = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 6, 1, 2 } }); + auto input0 = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 6, 1, 2 } }); int32_t axis = -3; int32_t group = 2; @@ -313,7 +310,7 @@ TEST(shuffle_channels_fp32_gpu, d2_6_2_axm3_g2) { }); topology topology; - topology.add(input_layout("Input0", input0.get_layout())); + topology.add(input_layout("Input0", input0->get_layout())); topology.add( shuffle_channels("shuffle_channels", "Input0", group, axis) ); @@ -325,7 +322,7 @@ TEST(shuffle_channels_fp32_gpu, d2_6_2_axm3_g2) { auto outputs = network.execute(); auto output = outputs.at("shuffle_channels").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 1.f, 6.f, 7.f, 2.f, 3.f, 8.f, 9.f, 4.f, 5.f, 10.f, 11.f, @@ -338,9 +335,9 @@ TEST(shuffle_channels_fp32_gpu, d2_6_2_axm3_g2) { } TEST(shuffle_channels_fp32_gpu, d6_axm0_g2) { - engine engine; + auto& engine = get_test_engine(); - auto input0 = memory::allocate(engine, { data_types::f32, format::bfyx, { 6, 1, 1, 1 } }); + auto input0 = engine.allocate_memory({ data_types::f32, format::bfyx, { 6, 1, 1, 1 } }); int32_t axis = 0; int32_t group = 2; @@ -349,7 +346,7 @@ TEST(shuffle_channels_fp32_gpu, d6_axm0_g2) { }); topology topology; - topology.add(input_layout("Input0", input0.get_layout())); + topology.add(input_layout("Input0", input0->get_layout())); topology.add( shuffle_channels("shuffle_channels", "Input0", group, axis) ); @@ -361,7 +358,7 @@ TEST(shuffle_channels_fp32_gpu, d6_axm0_g2) { auto outputs = network.execute(); auto output = outputs.at("shuffle_channels").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 3.f, 1.f, 4.f, 2.f, 5.f diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/softmax_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/softmax_gpu_test.cpp index 803ca0b3ae9c50..2ecc932b41e72d 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/softmax_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/softmax_gpu_test.cpp @@ -2,18 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include "api/memory.hpp" -#include -#include "api/softmax.hpp" -#include -#include -#include -#include "test_utils/test_utils.h" +#include "test_utils.h" + +#include +#include using namespace cldnn; using namespace std; -using namespace tests; +using namespace ::tests; class softmax_gpu_xb_f32_test_fixture: public ::testing::Test { public: @@ -27,14 +23,14 @@ class softmax_gpu_xb_f32_test_fixture: public ::testing::Test { float out_buffer[out_size]; float expected_buffer[out_size]; - const cldnn::engine& engine; - cldnn::memory input; + cldnn::engine& engine; + cldnn::memory::ptr input; //neural::primitive output = memory::allocate({ memory::format::xb_f32, {output_b, {{output_x}}, 1}}); softmax_gpu_xb_f32_test_fixture() : engine(get_test_engine()) - ,input(memory::allocate(engine, { data_types::f32, format::yxfb, { input_b, 1, input_x, 1}})) + , input(engine.allocate_memory({ data_types::f32, format::yxfb, { input_b, 1, input_x, 1}})) {} void compare_out_buffer_with_expected() { @@ -72,7 +68,7 @@ TEST_F(softmax_gpu_xb_f32_test_fixture, input_same_values) { set_values(input, in_b); - network network(engine, topology(input_layout("input", input.get_layout()), softmax("softmax", "input"))); + network network(engine, topology(input_layout("input", input->get_layout()), softmax("softmax", "input"))); network.set_input_data("input", input); auto outputs = network.execute(); @@ -81,10 +77,10 @@ TEST_F(softmax_gpu_xb_f32_test_fixture, input_same_values) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); for (uint32_t i = 0; i < out_size; i++) { - out_buffer[i] = get_value(output_ptr, i); + out_buffer[i] = output_ptr[i]; } compare_out_buffer_with_expected(); } @@ -102,7 +98,7 @@ TEST_F(softmax_gpu_xb_f32_test_fixture, input_same_values_batch_wise) { for(size_t i = 0; i < out_size; ++i) expected_buffer[i] = 0.1f; - network network(engine, topology(input_layout("input", input.get_layout()), softmax("softmax", "input"))); + network network(engine, topology(input_layout("input", input->get_layout()), softmax("softmax", "input"))); network.set_input_data("input", input); auto outputs = network.execute(); @@ -111,10 +107,10 @@ TEST_F(softmax_gpu_xb_f32_test_fixture, input_same_values_batch_wise) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); for (uint32_t i = 0; i < out_size; i++) { - out_buffer[i] = get_value(output_ptr, i); + out_buffer[i] = output_ptr[i]; } compare_out_buffer_with_expected_batch_wise(); } @@ -157,7 +153,7 @@ TEST_F(softmax_gpu_xb_f32_test_fixture, values_batch_wise) { for(size_t i = 0; i < out_size; ++i) out_buffer[i] = NAN; - network network(engine, topology(input_layout("input", input.get_layout()), softmax("softmax", "input"))); + network network(engine, topology(input_layout("input", input->get_layout()), softmax("softmax", "input"))); network.set_input_data("input", input); auto outputs = network.execute(); @@ -166,10 +162,10 @@ TEST_F(softmax_gpu_xb_f32_test_fixture, values_batch_wise) { auto output_prim = outputs.begin()->second.get_memory(); - auto output_ptr = output_prim.pointer(); + cldnn::mem_lock output_ptr(output_prim, get_test_stream()); for (uint32_t i = 0; i < out_size; i++) { - out_buffer[i] = get_value(output_ptr, i); + out_buffer[i] = output_ptr[i]; } compare_out_buffer_with_expected_batch_wise(); } @@ -178,11 +174,11 @@ TEST(softmax_gpu_bfyx_f32, normalize_fyx) { // Input : 2x3x2x2 static const int32_t x_size = 2, y_size = 2, feature_num = 3, batch_num = 2, buf_size = x_size*y_size * batch_num * feature_num; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ batch_num, feature_num, x_size , y_size } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ batch_num, feature_num, x_size , y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(softmax("softmax", "input")); set_values(input, { //bfyx @@ -208,11 +204,11 @@ TEST(softmax_gpu_bfyx_f32, normalize_fyx) { EXPECT_EQ(outputs.begin()->first, "softmax"); auto output = outputs.at("softmax").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float out_buffer[buf_size]; for (uint32_t i = 0; i < buf_size; i++) { - out_buffer[i] = get_value(output_ptr, i); + out_buffer[i] = output_ptr[i]; } float sum = 0; @@ -251,11 +247,11 @@ TEST(softmax_gpu_bfyx_f32, normalize_y) { // Input : 2x3x2x2 static const int32_t x_size = 2, y_size = 2, feature_num = 3, batch_num = 2, buf_size = x_size*y_size * batch_num * feature_num; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ batch_num, feature_num, x_size , y_size } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ batch_num, feature_num, x_size , y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(softmax("softmax", "input", softmax::normalize_y)); vector input_vec = { @@ -299,11 +295,11 @@ TEST(softmax_gpu_bfyx_f32, normalize_y) { EXPECT_EQ(outputs.begin()->first, "softmax"); auto output = outputs.at("softmax").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float out_buffer[buf_size]; for (uint32_t i = 0; i < buf_size; i++) { - out_buffer[i] = get_value(output_ptr, i); + out_buffer[i] = output_ptr[i]; } float temp_max = 0; @@ -345,11 +341,11 @@ TEST(softmax_gpu_bfyx_f32, normalize_f) { // Input : 2x3x2x2 static const int32_t x_size = 2, y_size = 2, feature_num = 3, batch_num = 2, buf_size = x_size*y_size * batch_num * feature_num; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx,{ batch_num, feature_num, x_size , y_size } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx,{ batch_num, feature_num, x_size , y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(softmax("softmax", "input", softmax::normalize_f)); vector input_vec = { @@ -387,11 +383,11 @@ TEST(softmax_gpu_bfyx_f32, normalize_f) { EXPECT_EQ(outputs.begin()->first, "softmax"); auto output = outputs.at("softmax").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float out_buffer[buf_size]; for (uint32_t i = 0; i < buf_size; i++) { - out_buffer[i] = get_value(output_ptr, i); + out_buffer[i] = output_ptr[i]; } float temp_max = 0; @@ -433,11 +429,11 @@ TEST(softmax_gpu_yxfb_f32, normalize_f) { static const int32_t x_size = 1, y_size = 2, feature_num = 1, batch_num = 12, buf_size = x_size*y_size * batch_num * feature_num; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ batch_num, feature_num, y_size , x_size } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ batch_num, feature_num, y_size , x_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(softmax("softmax", "input", softmax::normalize_fyx)); set_values(input, { //yxfb @@ -470,11 +466,11 @@ TEST(softmax_gpu_yxfb_f32, normalize_f) { EXPECT_EQ(outputs.begin()->first, "softmax"); auto output = outputs.at("softmax").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float out_buffer[buf_size]; for (uint32_t i = 0; i < buf_size; i++) { - out_buffer[i] = get_value(output_ptr, i); + out_buffer[i] = output_ptr[i]; } float expected_sum = 1.0f; @@ -510,11 +506,11 @@ TEST(softmax_gpu_bfzyx_f32, normalize_z) { // Input : 2x3x2x2x2 static const int32_t x_size = 2, y_size = 2, z_size = 2, feature_num = 3, batch_num = 2, buf_size = x_size *y_size * z_size * batch_num * feature_num; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ batch_num, feature_num, x_size , y_size, z_size } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx,{ batch_num, feature_num, x_size , y_size, z_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(softmax("softmax", "input", softmax::normalize_z)); vector input_vec = { @@ -553,11 +549,11 @@ TEST(softmax_gpu_bfzyx_f32, normalize_z) { EXPECT_EQ(outputs.begin()->first, "softmax"); auto output = outputs.at("softmax").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float out_buffer[buf_size]; for (uint32_t i = 0; i < buf_size; i++) { - out_buffer[i] = get_value(output_ptr, i); + out_buffer[i] = output_ptr[i]; } float temp_max = 0; @@ -602,11 +598,11 @@ TEST(softmax_gpu_bfyx_f32, normalize_all) { // Input : 2x3x2x2 static const int32_t x_size = 2, y_size = 2, feature_num = 3, batch_num = 2, buf_size = x_size * y_size * batch_num * feature_num; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfyx, {batch_num, feature_num, x_size, y_size}}); + auto input = engine.allocate_memory({data_types::f32, format::bfyx, {batch_num, feature_num, x_size, y_size}}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(softmax("softmax", "input", softmax::normalize_all)); set_values(input, {//bfyx @@ -627,11 +623,11 @@ TEST(softmax_gpu_bfyx_f32, normalize_all) { EXPECT_EQ(outputs.begin()->first, "softmax"); auto output = outputs.at("softmax").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float sum = 0.0f; float expected_sum = 1.0f; for (uint32_t i = 0; i < buf_size; i++) { - sum += get_value(output_ptr, i); + sum += output_ptr[i]; } EXPECT_EQ(true, are_equal(sum, expected_sum)); } @@ -640,11 +636,11 @@ TEST(softmax_gpu_yxfb_f32, normalize_all) { // Input : 2x2x3x2 static const int32_t x_size = 2, y_size = 2, feature_num = 3, batch_num = 2, buf_size = x_size * y_size * batch_num * feature_num; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::yxfb, {y_size, x_size, feature_num, batch_num}}); + auto input = engine.allocate_memory({data_types::f32, format::yxfb, {y_size, x_size, feature_num, batch_num}}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(softmax("softmax", "input", softmax::normalize_all)); set_values(input, {//yxfb @@ -665,11 +661,11 @@ TEST(softmax_gpu_yxfb_f32, normalize_all) { EXPECT_EQ(outputs.begin()->first, "softmax"); auto output = outputs.at("softmax").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float sum = 0.0f; float expected_sum = 1.0f; for (uint32_t i = 0; i < buf_size; i++) { - sum += get_value(output_ptr, i); + sum += output_ptr[i]; } EXPECT_EQ(true, are_equal(sum, expected_sum)); } @@ -678,11 +674,11 @@ TEST(softmax_gpu_bfzyx_f32, normalize_all) { // Input : 2x3x2x2x2 static const int32_t x_size = 2, y_size = 2, z_size = 2, feature_num = 3, batch_num = 2, buf_size = x_size * y_size * z_size * batch_num * feature_num; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f32, format::bfzyx, {batch_num, feature_num, x_size, y_size, z_size}}); + auto input = engine.allocate_memory({data_types::f32, format::bfzyx, {batch_num, feature_num, x_size, y_size, z_size}}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(softmax("softmax", "input", softmax::normalize_all)); set_values(input, {// z0y0x0 z0y0x1 z0y1x0 z0y1x1 z1y0x0 z1y0x1 z1y1x0 z1y1x1 @@ -702,11 +698,11 @@ TEST(softmax_gpu_bfzyx_f32, normalize_all) { EXPECT_EQ(outputs.begin()->first, "softmax"); auto output = outputs.at("softmax").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float sum = 0.0f; float expected_sum = 1.0f; for (uint32_t i = 0; i < buf_size; i++) { - sum += get_value(output_ptr, i); + sum += output_ptr[i]; } EXPECT_EQ(true, are_equal(sum, expected_sum)); } @@ -715,11 +711,11 @@ TEST(softmax_gpu_bfyx_f16, normalize_all) { // Input : 2x3x2x2 static const int32_t x_size = 2, y_size = 2, feature_num = 3, batch_num = 2, buf_size = x_size * y_size * batch_num * feature_num; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f16, format::bfyx, {batch_num, feature_num, x_size, y_size}}); + auto input = engine.allocate_memory({data_types::f16, format::bfyx, {batch_num, feature_num, x_size, y_size}}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(softmax("softmax", "input", softmax::normalize_all)); set_values(input, {//bfyx @@ -740,11 +736,11 @@ TEST(softmax_gpu_bfyx_f16, normalize_all) { EXPECT_EQ(outputs.begin()->first, "softmax"); auto output = outputs.at("softmax").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float sum = 0.0f; float expected_sum = 1.0f; for (uint32_t i = 0; i < buf_size; i++) { - sum += float16_to_float32(get_value(output_ptr, i)); + sum += float16_to_float32(output_ptr[i]); } ASSERT_NEAR(sum, expected_sum, 0.001); } @@ -753,11 +749,11 @@ TEST(softmax_gpu_yxfb_f16, normalize_all) { // Input : 2x2x3x2 static const int32_t x_size = 2, y_size = 2, feature_num = 3, batch_num = 2, buf_size = x_size * y_size * batch_num * feature_num; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f16, format::yxfb, {y_size, x_size, feature_num, batch_num}}); + auto input = engine.allocate_memory({data_types::f16, format::yxfb, {y_size, x_size, feature_num, batch_num}}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(softmax("softmax", "input", softmax::normalize_all)); set_values(input, {//yxfb @@ -778,11 +774,11 @@ TEST(softmax_gpu_yxfb_f16, normalize_all) { EXPECT_EQ(outputs.begin()->first, "softmax"); auto output = outputs.at("softmax").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float sum = 0.0f; float expected_sum = 1.0f; for (uint32_t i = 0; i < buf_size; i++) { - sum += float16_to_float32(get_value(output_ptr, i)); + sum += float16_to_float32(output_ptr[i]); } ASSERT_NEAR(sum, expected_sum, 0.001); } @@ -791,11 +787,11 @@ TEST(softmax_gpu_bfzyx_f16, normalize_all) { // Input : 2x3x2x2x2 static const int32_t x_size = 2, y_size = 2, z_size = 2, feature_num = 3, batch_num = 2, buf_size = x_size * y_size * z_size * batch_num * feature_num; - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, {data_types::f16, format::bfzyx, {batch_num, feature_num, x_size, y_size, z_size}}); + auto input = engine.allocate_memory({data_types::f16, format::bfzyx, {batch_num, feature_num, x_size, y_size, z_size}}); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(softmax("softmax", "input", softmax::normalize_all)); set_values(input, {// z0y0x0 z0y0x1 z0y1x0 z0y1x1 z1y0x0 z1y0x1 z1y1x0 z1y1x1 @@ -815,11 +811,11 @@ TEST(softmax_gpu_bfzyx_f16, normalize_all) { EXPECT_EQ(outputs.begin()->first, "softmax"); auto output = outputs.at("softmax").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); float sum = 0.0f; float expected_sum = 1.0f; for (uint32_t i = 0; i < buf_size; i++) { - sum += float16_to_float32(get_value(output_ptr, i)); + sum += float16_to_float32(output_ptr[i]); } ASSERT_NEAR(sum, expected_sum, 0.001); } @@ -884,28 +880,26 @@ class softmax_test : public tests::generic_test } template - memory generate_reference_typed(const std::vector & inputs) + memory::ptr generate_reference_typed(const std::vector & inputs) { assert(inputs.size() == 1); - const memory & input = inputs[0]; + const memory::ptr input = inputs[0]; //Output is bfyx - auto output = memory::allocate(engine, cldnn::layout(input.get_layout().data_type, input.get_layout().format, input.get_layout().size)); - -// const auto params = static_cast(layer_parmas); + auto output = engine.allocate_memory(cldnn::layout(input->get_layout().data_type, input->get_layout().format, input->get_layout().size)); - const auto in0_mem = input.pointer(); - auto out_mem = output.pointer(); + cldnn::mem_lock in0_mem(input, get_test_stream()); + cldnn::mem_lock out_mem(output, get_test_stream()); - const int in0_b = input.get_layout().size.sizes()[0]; - const int in0_f = input.get_layout().size.sizes()[1]; - const int in0_h = input.get_layout().size.sizes()[3]; - const int in0_w = input.get_layout().size.sizes()[2]; + const int in0_b = input->get_layout().size.sizes()[0]; + const int in0_f = input->get_layout().size.sizes()[1]; + const int in0_h = input->get_layout().size.sizes()[3]; + const int in0_w = input->get_layout().size.sizes()[2]; -// const int out_b = output.get_layout().size.transform(cldnn::format::bfyx, 0).sizes()[0]; -// const int out_f = output.get_layout().size.transform(cldnn::format::bfyx, 0).sizes()[1]; -// const int out_h = output.get_layout().size.transform(cldnn::format::bfyx, 0).sizes()[2]; -// const int out_w = output.get_layout().size.transform(cldnn::format::bfyx, 0).sizes()[3]; +// const int out_b = output->get_layout().size.transform(cldnn::format::bfyx, 0).sizes()[0]; +// const int out_f = output->get_layout().size.transform(cldnn::format::bfyx, 0).sizes()[1]; +// const int out_h = output->get_layout().size.transform(cldnn::format::bfyx, 0).sizes()[2]; +// const int out_w = output->get_layout().size.transform(cldnn::format::bfyx, 0).sizes()[3]; // assert(in0_b == out_b); // assert(in0_f == out_f); @@ -915,7 +909,7 @@ class softmax_test : public tests::generic_test std::vector cached_exp_vals; cached_exp_vals.resize(in0_f); - const auto input_desc = get_linear_memory_desc(input.get_layout()); + const auto input_desc = get_linear_memory_desc(input->get_layout()); for (int n = 0; n < in0_b; ++n) for (int y = 0; y < in0_h; ++y) @@ -925,7 +919,7 @@ class softmax_test : public tests::generic_test for (int c = 0; c < in0_f; ++c) { - const size_t in0_idx = get_linear_index(input.get_layout(), n, c, y, x, input_desc); + const size_t in0_idx = get_linear_index(input->get_layout(), n, c, y, x, input_desc); max_val = std::max(max_val, static_cast(in0_mem[in0_idx])); } @@ -934,7 +928,7 @@ class softmax_test : public tests::generic_test for (int c = 0; c < in0_f; ++c) { - const size_t in0_idx = get_linear_index(input.get_layout(), n, c, y, x, input_desc); + const size_t in0_idx = get_linear_index(input->get_layout(), n, c, y, x, input_desc); float tmp = static_cast((Type)std::exp(static_cast(in0_mem[in0_idx]) - max_val)); Z += tmp; @@ -943,7 +937,7 @@ class softmax_test : public tests::generic_test for (int c = 0; c < in0_f; ++c) { - const size_t out_idx = get_linear_index(output.get_layout(), n, c, y, x, input_desc); + const size_t out_idx = get_linear_index(output->get_layout(), n, c, y, x, input_desc); out_mem[out_idx] = (Type)(cached_exp_vals[c] / Z); } } @@ -951,7 +945,7 @@ class softmax_test : public tests::generic_test return output; } - virtual memory generate_reference(const std::vector & inputs) override + virtual memory::ptr generate_reference(const std::vector & inputs) override { if (generic_params->data_type == data_types::f32) { @@ -1008,4 +1002,3 @@ INSTANTIATE_TEST_CASE_P(DISABLED_SOFTMAX, softmax_test, ::testing::Combine(::testing::ValuesIn(softmax_test::generate_generic_test_params()), ::testing::ValuesIn(softmax_test::generate_specific_test_params())), softmax_test::custom_param_name); - diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/space_to_batch_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/space_to_batch_gpu_test.cpp index 9dec5cf8c7393a..cb46b0132079c1 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/space_to_batch_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/space_to_batch_gpu_test.cpp @@ -3,17 +3,14 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include -#include -#include -#include +#include "test_utils.h" + +#include +#include +#include #include -#include using namespace cldnn; using namespace ::tests; @@ -26,8 +23,8 @@ TEST(space_to_batch_fp16_gpu, i1222_bs1222_pb0000_pe0000) { // Output : 8x1x1x1 // Input values in fp16 - engine engine; - auto input = memory::allocate(engine, { data_types::f16, format::bfyx, {1,2,2,2} }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx, {1,2,2,2} }); set_values(input, { FLOAT16(0.0f), FLOAT16(1.0f), @@ -37,7 +34,7 @@ TEST(space_to_batch_fp16_gpu, i1222_bs1222_pb0000_pe0000) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(space_to_batch("space_to_batch", "Input", tensor(format::bfyx, {1,2,2,2}, 1), tensor(format::bfyx, {0,0,0,0}, 0), tensor(format::bfyx, {0,0,0,0}, 0), @@ -49,7 +46,7 @@ TEST(space_to_batch_fp16_gpu, i1222_bs1222_pb0000_pe0000) { auto outputs = network.execute(); auto output = outputs.at("space_to_batch").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f @@ -70,8 +67,8 @@ TEST(space_to_batch_fp16_gpu, i1242_bs1221_pb0020_pe0000) { // Output : 4x1x3x2 // Input values in fp16 - engine engine; - auto input = memory::allocate(engine, { data_types::f16, format::bfyx, {1,2,2,4} }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx, {1,2,2,4} }); set_values(input, { FLOAT16(0.0f), FLOAT16(1.0f), FLOAT16(2.0f), FLOAT16(3.0f), @@ -81,7 +78,7 @@ TEST(space_to_batch_fp16_gpu, i1242_bs1221_pb0020_pe0000) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(space_to_batch("space_to_batch", "Input", tensor(format::bfyx, {1,2,2,1}, 1), tensor(format::bfyx, {0,0,2,0}, 0), tensor(format::bfyx, {0,0,0,0}, 0), @@ -93,7 +90,7 @@ TEST(space_to_batch_fp16_gpu, i1242_bs1221_pb0020_pe0000) { auto outputs = network.execute(); auto output = outputs.at("space_to_batch").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 0.f, 0.f, 1.f, 4.f, 5.f, @@ -117,8 +114,8 @@ TEST(space_to_batch_fp16_gpu, i2132_bs1222_pb0010_pe0100) { // Output : 16x1x2x1 // Input values in fp16 - engine engine; - auto input = memory::allocate(engine, { data_types::f16, format::bfyx, {2,1,2,3} }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx, {2,1,2,3} }); set_values(input, { FLOAT16(0.0f), FLOAT16(1.0f), FLOAT16(2.0f), FLOAT16(3.0f), @@ -127,7 +124,7 @@ TEST(space_to_batch_fp16_gpu, i2132_bs1222_pb0010_pe0100) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(space_to_batch("space_to_batch", "Input", tensor(format::bfyx, {1,2,2,2}, 1), tensor(format::bfyx, {0,0,1,0}, 0), tensor(format::bfyx, {0,1,0,0}, 0), @@ -139,7 +136,7 @@ TEST(space_to_batch_fp16_gpu, i2132_bs1222_pb0010_pe0100) { auto outputs = network.execute(); auto output = outputs.at("space_to_batch").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 2.f, 0.f, 8.f, 0.f, 3.f, 0.f, 9.f, @@ -163,8 +160,8 @@ TEST(space_to_batch_fp16_gpu, i12132_bs12122_pb00010_pe00000) { // Output : 8x1x1x2x1 // Input values in fp16 - engine engine; - auto input = memory::allocate(engine, { data_types::f16, format::bfzyx, {1,2,2,3,1} }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f16, format::bfzyx, {1,2,2,3,1} }); set_values(input, { FLOAT16(0.0f), FLOAT16(1.0f), FLOAT16(2.0f), FLOAT16(3.0f), @@ -173,7 +170,7 @@ TEST(space_to_batch_fp16_gpu, i12132_bs12122_pb00010_pe00000) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(space_to_batch("space_to_batch", "Input", tensor(format::bfzyx, {1,2,1,2,2}, 1), tensor(format::bfzyx, {0,0,0,1,0}, 0), tensor(format::bfzyx, {0,0,0,0,0}, 0), @@ -185,7 +182,7 @@ TEST(space_to_batch_fp16_gpu, i12132_bs12122_pb00010_pe00000) { auto outputs = network.execute(); auto output = outputs.at("space_to_batch").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 2.f, 0.f, 3.f, 0.f, 4.f, 1.f, 5.f, @@ -207,9 +204,9 @@ TEST(space_to_batch_fp16_gpu, i134121_bs142121_pb010100_pe000000) { // Output : 16x1x2x2x1x1 // Input values in fp16 - engine engine; + auto& engine = get_test_engine(); tensor input_shape = tensor{ batch(1), feature(3), spatial(1, 2, 1, 4) }; - auto input = memory::allocate(engine, { data_types::f16, format::bfwzyx, input_shape }); + auto input = engine.allocate_memory({ data_types::f16, format::bfwzyx, input_shape }); set_values(input, { FLOAT16(0.0f), FLOAT16(1.0f), FLOAT16(2.0f), FLOAT16(3.0f), @@ -221,7 +218,7 @@ TEST(space_to_batch_fp16_gpu, i134121_bs142121_pb010100_pe000000) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(space_to_batch("space_to_batch", "Input", tensor(format::bfwzyx, {1,4,2,1,2,1}, 1), tensor(format::bfwzyx, {0,1,0,1,0,0}, 0), tensor(format::bfwzyx, {0,0,0,0,0,0}, 0), @@ -233,7 +230,7 @@ TEST(space_to_batch_fp16_gpu, i134121_bs142121_pb010100_pe000000) { auto outputs = network.execute(); auto output = outputs.at("space_to_batch").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, @@ -261,8 +258,8 @@ TEST(space_to_batch_fp16_gpu, i11611_bs1222_pb0010_pe0001_b_fs_yx_fsv16) { // Output : 8x8x1x1 // Input values in fp16 - engine engine; - auto input = memory::allocate(engine, { data_types::f16, format::bfyx, {1,16,1,1} }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx, {1,16,1,1} }); set_values(input, { FLOAT16(0.0f), FLOAT16(1.0f), FLOAT16(2.0f), FLOAT16(3.0f), @@ -272,7 +269,7 @@ TEST(space_to_batch_fp16_gpu, i11611_bs1222_pb0010_pe0001_b_fs_yx_fsv16) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(reorder("input_fsv", "Input", format::b_fs_yx_fsv16, data_types::f16)); topology.add(space_to_batch("space_to_batch", "input_fsv", tensor(format::bfyx, {1,2,2,2}, 1), tensor(format::bfyx, {0,0,1,0}, 0), @@ -286,7 +283,7 @@ TEST(space_to_batch_fp16_gpu, i11611_bs1222_pb0010_pe0001_b_fs_yx_fsv16) { auto outputs = network.execute(); auto output = outputs.at("stb_to_bfyx").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, @@ -314,8 +311,8 @@ TEST(space_to_batch_fp16_gpu, i1812_bs1221_pb0010_pe0200_b_fs_yx_fsv16) { // Output : 4x5x1x2 // Input values in fp16 - engine engine; - auto input = memory::allocate(engine, { data_types::f16, format::bfyx, {1,8,2,1} }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f16, format::bfyx, {1,8,2,1} }); set_values(input, { FLOAT16(0.0f), FLOAT16(1.0f), FLOAT16(2.0f), FLOAT16(3.0f), @@ -325,7 +322,7 @@ TEST(space_to_batch_fp16_gpu, i1812_bs1221_pb0010_pe0200_b_fs_yx_fsv16) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(reorder("input_fsv", "Input", format::b_fs_yx_fsv16, data_types::f16)); topology.add(space_to_batch("space_to_batch", "input_fsv", tensor(format::bfyx, {1,2,2,1}, 1), tensor(format::bfyx, {0,0,1,0}, 0), @@ -339,7 +336,7 @@ TEST(space_to_batch_fp16_gpu, i1812_bs1221_pb0010_pe0200_b_fs_yx_fsv16) { auto outputs = network.execute(); auto output = outputs.at("stb_to_bfyx").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, @@ -363,8 +360,8 @@ TEST(space_to_batch_fp32_gpu, i1222_bs1222_pb0000_pe0000) { // Output : 8x1x1x1 // Input values in fp32 - engine engine; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, {1,2,2,2} }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, {1,2,2,2} }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, @@ -372,7 +369,7 @@ TEST(space_to_batch_fp32_gpu, i1222_bs1222_pb0000_pe0000) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(space_to_batch("space_to_batch", "Input", tensor(format::bfyx, {1,2,2,2}, 1), tensor(format::bfyx, {0,0,0,0}, 0), tensor(format::bfyx, {0,0,0,0}, 0), @@ -384,7 +381,7 @@ TEST(space_to_batch_fp32_gpu, i1222_bs1222_pb0000_pe0000) { auto outputs = network.execute(); auto output = outputs.at("space_to_batch").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f @@ -405,8 +402,8 @@ TEST(space_to_batch_fp32_gpu, i1242_bs1221_pb0020_pe0000) { // Output : 4x1x3x2 // Input values in fp32 - engine engine; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, {1,2,2,4} }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, {1,2,2,4} }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, @@ -416,7 +413,7 @@ TEST(space_to_batch_fp32_gpu, i1242_bs1221_pb0020_pe0000) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(space_to_batch("space_to_batch", "Input", tensor(format::bfyx, {1,2,2,1}, 1), tensor(format::bfyx, {0,0,2,0}, 0), tensor(format::bfyx, {0,0,0,0}, 0), @@ -428,7 +425,7 @@ TEST(space_to_batch_fp32_gpu, i1242_bs1221_pb0020_pe0000) { auto outputs = network.execute(); auto output = outputs.at("space_to_batch").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 0.f, 0.f, 1.f, 4.f, 5.f, @@ -452,8 +449,8 @@ TEST(space_to_batch_fp32_gpu, i2132_bs1222_pb0010_pe0100) { // Output : 16x1x2x1 // Input values in fp32 - engine engine; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, {2,1,2,3} }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, {2,1,2,3} }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, @@ -462,7 +459,7 @@ TEST(space_to_batch_fp32_gpu, i2132_bs1222_pb0010_pe0100) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(space_to_batch("space_to_batch", "Input", tensor(format::bfyx, {1,2,2,2}, 1), tensor(format::bfyx, {0,0,1,0}, 0), tensor(format::bfyx, {0,1,0,0}, 0), @@ -474,7 +471,7 @@ TEST(space_to_batch_fp32_gpu, i2132_bs1222_pb0010_pe0100) { auto outputs = network.execute(); auto output = outputs.at("space_to_batch").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 2.f, 0.f, 8.f, 0.f, 3.f, 0.f, 9.f, @@ -498,8 +495,8 @@ TEST(space_to_batch_fp32_gpu, i12132_bs12122_pb00010_pe00000) { // Output : 8x1x1x2x1 // Input values in fp32 - engine engine; - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx, {1,2,2,3,1} }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx, {1,2,2,3,1} }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, @@ -508,7 +505,7 @@ TEST(space_to_batch_fp32_gpu, i12132_bs12122_pb00010_pe00000) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(space_to_batch("space_to_batch", "Input", tensor(format::bfzyx, {1,2,1,2,2}, 1), tensor(format::bfzyx, {0,0,0,1,0}, 0), tensor(format::bfzyx, {0,0,0,0,0}, 0), @@ -520,7 +517,7 @@ TEST(space_to_batch_fp32_gpu, i12132_bs12122_pb00010_pe00000) { auto outputs = network.execute(); auto output = outputs.at("space_to_batch").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 2.f, 0.f, 3.f, 0.f, 4.f, 1.f, 5.f, @@ -542,9 +539,9 @@ TEST(space_to_batch_fp32_gpu, i134121_bs142121_pb010100_pe000000) { // Output : 16x1x2x2x1x1 // Input values in fp32 - engine engine; + auto& engine = get_test_engine(); tensor input_shape = tensor{ batch(1), feature(3), spatial(1, 2, 1, 4) }; - auto input = memory::allocate(engine, { data_types::f32, format::bfwzyx, input_shape }); + auto input = engine.allocate_memory({ data_types::f32, format::bfwzyx, input_shape }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, @@ -554,7 +551,7 @@ TEST(space_to_batch_fp32_gpu, i134121_bs142121_pb010100_pe000000) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(space_to_batch("space_to_batch", "Input", tensor(format::bfwzyx, {1,4,2,1,2,1}, 1), tensor(format::bfwzyx, {0,1,0,1,0,0}, 0), tensor(format::bfwzyx, {0,0,0,0,0,0}, 0), @@ -566,7 +563,7 @@ TEST(space_to_batch_fp32_gpu, i134121_bs142121_pb010100_pe000000) { auto outputs = network.execute(); auto output = outputs.at("space_to_batch").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, @@ -594,8 +591,8 @@ TEST(space_to_batch_fp32_gpu, i11622_bs1421_pb0000_pe0000_b_fs_yx_fsv16) { // Output : 8x4x1x2 // Input values in fp32 - engine engine; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, {1,16,2,2} }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, {1,16,2,2} }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, @@ -609,7 +606,7 @@ TEST(space_to_batch_fp32_gpu, i11622_bs1421_pb0000_pe0000_b_fs_yx_fsv16) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(reorder("input_fsv", "Input", format::b_fs_yx_fsv16, data_types::f32)); topology.add(space_to_batch("space_to_batch", "input_fsv", tensor(format::bfyx, {1,4,2,1}, 1), tensor(format::bfyx, {0,0,0,0}, 0), @@ -623,7 +620,7 @@ TEST(space_to_batch_fp32_gpu, i11622_bs1421_pb0000_pe0000_b_fs_yx_fsv16) { auto outputs = network.execute(); auto output = outputs.at("stb_to_bfyx").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 1.f, 16.f, 17.f, 32.f, 33.f, 48.f, 49.f, @@ -651,8 +648,8 @@ TEST(space_to_batch_fp32_gpu, i1623_bs1312_pb0001_pe0000_b_fs_yx_fsv16) { // Output : 6x2x2x2 // Input values in fp32 - engine engine; - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, {1,6,3,2} }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, {1,6,3,2} }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, @@ -663,7 +660,7 @@ TEST(space_to_batch_fp32_gpu, i1623_bs1312_pb0001_pe0000_b_fs_yx_fsv16) { }); topology topology; - topology.add(input_layout("Input", input.get_layout())); + topology.add(input_layout("Input", input->get_layout())); topology.add(reorder("input_fsv", "Input", format::b_fs_yx_fsv16, data_types::f32)); topology.add(space_to_batch("space_to_batch", "input_fsv", tensor(format::bfyx, {1,3,1,2}, 1), tensor(format::bfyx, {0,0,0,1}, 0), @@ -677,7 +674,7 @@ TEST(space_to_batch_fp32_gpu, i1623_bs1312_pb0001_pe0000_b_fs_yx_fsv16) { auto outputs = network.execute(); auto output = outputs.at("stb_to_bfyx").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 1.f, 0.f, 4.f, 0.f, 19.f, 0.f, 22.f, diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/space_to_depth_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/space_to_depth_gpu_test.cpp index 76611b0f60f1aa..6614d4d6b75e8a 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/space_to_depth_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/space_to_depth_gpu_test.cpp @@ -3,16 +3,13 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include -#include -#include +#include "test_utils.h" + +#include +#include #include -#include using namespace cldnn; using namespace ::tests; @@ -27,9 +24,9 @@ TEST(space_to_depth_fp16_gpu, d1122_bs2_mbf) { // Output : 1x4x1x1 // Input values in fp16 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 1, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 1, 2, 2 } }); size_t block_size = 2; set_values(input1, { @@ -38,7 +35,7 @@ TEST(space_to_depth_fp16_gpu, d1122_bs2_mbf) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add( space_to_depth("space_to_depth", "Input0", space_to_depth::blocks_first, block_size) ); @@ -50,7 +47,7 @@ TEST(space_to_depth_fp16_gpu, d1122_bs2_mbf) { auto outputs = network.execute(); auto output = outputs.at("space_to_depth").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 1.f, 2.f, 3.f @@ -67,9 +64,9 @@ TEST(space_to_depth_fp16_gpu, d1142_bs2_mbf) { // Output : 1x4x2x1 // Input values in fp16 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 1, 2, 4 } }); + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 1, 2, 4 } }); size_t block_size = 2; set_values(input1, { @@ -80,7 +77,7 @@ TEST(space_to_depth_fp16_gpu, d1142_bs2_mbf) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add( space_to_depth("space_to_depth", "Input0", space_to_depth::blocks_first, block_size) ); @@ -92,7 +89,7 @@ TEST(space_to_depth_fp16_gpu, d1142_bs2_mbf) { auto outputs = network.execute(); auto output = outputs.at("space_to_depth").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 4.0f, 1.0f, 5.0f, 2.0f, 6.0f, 3.0f, 7.0f @@ -109,9 +106,9 @@ TEST(space_to_depth_fp16_gpu, d1264_bs2_mbf) { // Output : 1x8x3x2 // Input values in fp16 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 2, 4, 6 } }); + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 2, 4, 6 } }); size_t block_size = 2; set_values(input1, { @@ -128,7 +125,7 @@ TEST(space_to_depth_fp16_gpu, d1264_bs2_mbf) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add( space_to_depth("space_to_depth", "Input0", space_to_depth::blocks_first, block_size) ); @@ -140,7 +137,7 @@ TEST(space_to_depth_fp16_gpu, d1264_bs2_mbf) { auto outputs = network.execute(); auto output = outputs.at("space_to_depth").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 2.0f, 8.0f, 10.0f, 16.0f, 18.0f, @@ -164,9 +161,9 @@ TEST(space_to_depth_fp16_gpu, d1199_bs3_mbf) { // Output : 1x9x3x3 // Input values in fp16 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 1, 9, 9 } }); + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 1, 9, 9 } }); size_t block_size = 3; set_values(input1, { @@ -190,7 +187,7 @@ TEST(space_to_depth_fp16_gpu, d1199_bs3_mbf) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add( space_to_depth("space_to_depth", "Input0", space_to_depth::blocks_first, block_size) ); @@ -202,7 +199,7 @@ TEST(space_to_depth_fp16_gpu, d1199_bs3_mbf) { auto outputs = network.execute(); auto output = outputs.at("space_to_depth").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 3.0f, 6.0f, 27.0f, 30.0f, 33.0f, 54.0f, 57.0f, 60.0f, 1.0f, @@ -227,9 +224,9 @@ TEST(space_to_depth_fp32_gpu, d1122_bs2_mbf) { // Output : 1x4x1x1 // Input values in fp32 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); size_t block_size = 2; set_values(input1, { @@ -237,7 +234,7 @@ TEST(space_to_depth_fp32_gpu, d1122_bs2_mbf) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add( space_to_depth("space_to_depth", "Input0", space_to_depth::blocks_first, block_size) ); @@ -249,7 +246,7 @@ TEST(space_to_depth_fp32_gpu, d1122_bs2_mbf) { auto outputs = network.execute(); auto output = outputs.at("space_to_depth").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 1.f, 2.f, 3.f @@ -266,9 +263,9 @@ TEST(space_to_depth_fp32_gpu, d1142_bs2_mbf) { // Output : 1x4x2x1 // Input values in fp32 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 2, 4 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 2, 4 } }); size_t block_size = 2; set_values(input1, { @@ -276,7 +273,7 @@ TEST(space_to_depth_fp32_gpu, d1142_bs2_mbf) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add( space_to_depth("space_to_depth", "Input0", space_to_depth::blocks_first, block_size) ); @@ -288,7 +285,7 @@ TEST(space_to_depth_fp32_gpu, d1142_bs2_mbf) { auto outputs = network.execute(); auto output = outputs.at("space_to_depth").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 4.0f, 1.0f, 5.0f, 2.0f, 6.0f, 3.0f, 7.0f @@ -305,9 +302,9 @@ TEST(space_to_depth_fp32_gpu, d1264_bs2_mbf) { // Output : 1x8x3x2 // Input values in fp32 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 4, 6 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 4, 6 } }); size_t block_size = 2; set_values(input1, { @@ -324,7 +321,7 @@ TEST(space_to_depth_fp32_gpu, d1264_bs2_mbf) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add( space_to_depth("space_to_depth", "Input0", space_to_depth::blocks_first, block_size) ); @@ -336,7 +333,7 @@ TEST(space_to_depth_fp32_gpu, d1264_bs2_mbf) { auto outputs = network.execute(); auto output = outputs.at("space_to_depth").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 2.0f, 8.0f, 10.0f, 16.0f, 18.0f, @@ -360,9 +357,9 @@ TEST(space_to_depth_fp32_gpu, d1199_bs3_mbf) { // Output : 1x9x3x3 // Input values in fp32 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 9, 9 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 9, 9 } }); size_t block_size = 3; set_values(input1, { @@ -378,7 +375,7 @@ TEST(space_to_depth_fp32_gpu, d1199_bs3_mbf) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add( space_to_depth("space_to_depth", "Input0", space_to_depth::blocks_first, block_size) ); @@ -390,7 +387,7 @@ TEST(space_to_depth_fp32_gpu, d1199_bs3_mbf) { auto outputs = network.execute(); auto output = outputs.at("space_to_depth").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 3.0f, 6.0f, 27.0f, 30.0f, 33.0f, 54.0f, 57.0f, 60.0f, 1.0f, @@ -419,9 +416,9 @@ TEST(space_to_depth_fp16_gpu, d1122_bs2_mdf) { // Output : 1x4x1x1 // Input values in fp16 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 1, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 1, 2, 2 } }); size_t block_size = 2; set_values(input1, { @@ -430,7 +427,7 @@ TEST(space_to_depth_fp16_gpu, d1122_bs2_mdf) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add( space_to_depth("space_to_depth", "Input0", space_to_depth::depth_first, block_size) ); @@ -442,7 +439,7 @@ TEST(space_to_depth_fp16_gpu, d1122_bs2_mdf) { auto outputs = network.execute(); auto output = outputs.at("space_to_depth").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 1.f, 2.f, 3.f @@ -459,9 +456,9 @@ TEST(space_to_depth_fp16_gpu, d1142_bs2_mdf) { // Output : 1x4x2x1 // Input values in fp16 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 1, 2, 4 } }); + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 1, 2, 4 } }); size_t block_size = 2; set_values(input1, { @@ -472,7 +469,7 @@ TEST(space_to_depth_fp16_gpu, d1142_bs2_mdf) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add( space_to_depth("space_to_depth", "Input0", space_to_depth::depth_first, block_size) ); @@ -484,7 +481,7 @@ TEST(space_to_depth_fp16_gpu, d1142_bs2_mdf) { auto outputs = network.execute(); auto output = outputs.at("space_to_depth").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 4.0f, 1.0f, 5.0f, 2.0f, 6.0f, 3.0f, 7.0f @@ -501,9 +498,9 @@ TEST(space_to_depth_fp16_gpu, d1264_bs2_mdf) { // Output : 1x8x3x2 // Input values in fp16 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 2, 4, 6 } }); + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 2, 4, 6 } }); size_t block_size = 2; set_values(input1, { @@ -520,7 +517,7 @@ TEST(space_to_depth_fp16_gpu, d1264_bs2_mdf) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add( space_to_depth("space_to_depth", "Input0", space_to_depth::depth_first, block_size) ); @@ -532,7 +529,7 @@ TEST(space_to_depth_fp16_gpu, d1264_bs2_mdf) { auto outputs = network.execute(); auto output = outputs.at("space_to_depth").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 2.0f, 8.0f, 10.0f, 16.0f, 18.0f, @@ -556,9 +553,9 @@ TEST(space_to_depth_fp16_gpu, d1199_bs3_mdf) { // Output : 1x9x3x3 // Input values in fp16 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f16, format::bfyx, { 1, 1, 9, 9 } }); + auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 1, 9, 9 } }); size_t block_size = 3; set_values(input1, { @@ -582,7 +579,7 @@ TEST(space_to_depth_fp16_gpu, d1199_bs3_mdf) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add( space_to_depth("space_to_depth", "Input0", space_to_depth::depth_first, block_size) ); @@ -594,7 +591,7 @@ TEST(space_to_depth_fp16_gpu, d1199_bs3_mdf) { auto outputs = network.execute(); auto output = outputs.at("space_to_depth").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 3.0f, 6.0f, 27.0f, 30.0f, 33.0f, 54.0f, 57.0f, 60.0f, 1.0f, @@ -619,9 +616,9 @@ TEST(space_to_depth_fp32_gpu, d1122_bs2_mdf) { // Output : 1x4x1x1 // Input values in fp32 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 2, 2 } }); size_t block_size = 2; set_values(input1, { @@ -629,7 +626,7 @@ TEST(space_to_depth_fp32_gpu, d1122_bs2_mdf) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add( space_to_depth("space_to_depth", "Input0", space_to_depth::depth_first, block_size) ); @@ -641,7 +638,7 @@ TEST(space_to_depth_fp32_gpu, d1122_bs2_mdf) { auto outputs = network.execute(); auto output = outputs.at("space_to_depth").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.f, 1.f, 2.f, 3.f @@ -658,9 +655,9 @@ TEST(space_to_depth_fp32_gpu, d1142_bs2_mdf) { // Output : 1x4x2x1 // Input values in fp32 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 2, 4 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 2, 4 } }); size_t block_size = 2; set_values(input1, { @@ -668,7 +665,7 @@ TEST(space_to_depth_fp32_gpu, d1142_bs2_mdf) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add( space_to_depth("space_to_depth", "Input0", space_to_depth::depth_first, block_size) ); @@ -680,7 +677,7 @@ TEST(space_to_depth_fp32_gpu, d1142_bs2_mdf) { auto outputs = network.execute(); auto output = outputs.at("space_to_depth").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 4.0f, 1.0f, 5.0f, 2.0f, 6.0f, 3.0f, 7.0f @@ -697,9 +694,9 @@ TEST(space_to_depth_fp32_gpu, d1264_bs2_mdf) { // Output : 1x8x3x2 // Input values in fp32 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 4, 6 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 4, 6 } }); size_t block_size = 2; set_values(input1, { @@ -716,7 +713,7 @@ TEST(space_to_depth_fp32_gpu, d1264_bs2_mdf) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add( space_to_depth("space_to_depth", "Input0", space_to_depth::depth_first, block_size) ); @@ -728,7 +725,7 @@ TEST(space_to_depth_fp32_gpu, d1264_bs2_mdf) { auto outputs = network.execute(); auto output = outputs.at("space_to_depth").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 2.0f, 8.0f, 10.0f, 16.0f, 18.0f, @@ -752,9 +749,9 @@ TEST(space_to_depth_fp32_gpu, d1199_bs3_mdf) { // Output : 1x9x3x3 // Input values in fp32 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 9, 9 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 9, 9 } }); size_t block_size = 3; set_values(input1, { @@ -770,7 +767,7 @@ TEST(space_to_depth_fp32_gpu, d1199_bs3_mdf) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add( space_to_depth("space_to_depth", "Input0", space_to_depth::depth_first, block_size) ); @@ -782,7 +779,7 @@ TEST(space_to_depth_fp32_gpu, d1199_bs3_mdf) { auto outputs = network.execute(); auto output = outputs.at("space_to_depth").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 3.0f, 6.0f, 27.0f, 30.0f, 33.0f, 54.0f, 57.0f, 60.0f, 1.0f, @@ -807,9 +804,9 @@ TEST(space_to_depth_fp32_gpu, d1199_bs3_mdf_fsv16) { // Output : 1x9x3x3 // Input values in fp32 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 9, 9 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 9, 9 } }); size_t block_size = 3; set_values(input1, { @@ -825,7 +822,7 @@ TEST(space_to_depth_fp32_gpu, d1199_bs3_mdf_fsv16) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add(reorder("reorder", "Input0", format::b_fs_yx_fsv16, data_types::f32)); topology.add(space_to_depth("space_to_depth", "reorder", space_to_depth::depth_first, block_size)); topology.add(reorder("reorder_out", "space_to_depth", format::bfyx, data_types::f32)); @@ -837,7 +834,7 @@ TEST(space_to_depth_fp32_gpu, d1199_bs3_mdf_fsv16) { auto outputs = network.execute(); auto output = outputs.at("reorder_out").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 3.0f, 6.0f, 27.0f, 30.0f, 33.0f, 54.0f, 57.0f, 60.0f, 1.0f, @@ -862,9 +859,9 @@ TEST(space_to_depth_fp32_gpu, d1199_bs3_mdf_fsv4) { // Output : 1x9x3x3 // Input values in fp32 - engine engine; + auto& engine = get_test_engine(); - auto input1 = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 9, 9 } }); + auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 9, 9 } }); size_t block_size = 3; set_values(input1, { @@ -880,7 +877,7 @@ TEST(space_to_depth_fp32_gpu, d1199_bs3_mdf_fsv4) { }); topology topology; - topology.add(input_layout("Input0", input1.get_layout())); + topology.add(input_layout("Input0", input1->get_layout())); topology.add(reorder("reorder", "Input0", format::b_fs_yx_fsv4, data_types::f32)); topology.add(space_to_depth("space_to_depth", "reorder", space_to_depth::depth_first, block_size)); topology.add(reorder("reorder_out", "space_to_depth", format::bfyx, data_types::f32)); @@ -892,7 +889,7 @@ TEST(space_to_depth_fp32_gpu, d1199_bs3_mdf_fsv4) { auto outputs = network.execute(); auto output = outputs.at("reorder_out").get_memory(); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); std::vector expected_results = { 0.0f, 3.0f, 6.0f, 27.0f, 30.0f, 33.0f, 54.0f, 57.0f, 60.0f, 1.0f, diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/spatial_concatenate_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/spatial_concatenate_gpu_test.cpp index 27dcab87f8bff5..286588efefa928 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/spatial_concatenate_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/spatial_concatenate_gpu_test.cpp @@ -4,23 +4,19 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include "api/concatenation.hpp" -#include -#include -#include -#include "test_utils/test_utils.h" +#include "test_utils.h" + +#include +#include "cldnn/primitives/concatenation.hpp" using namespace cldnn; -using namespace tests; +using namespace ::tests; TEST(spatial_concatenate_f32_gpu, test01) { - engine eng; + auto& engine = get_test_engine(); - memory input1 = memory::allocate(eng, layout{ data_types::f32, format::bfyx, { 1,1,2,2 } }); - memory input2 = memory::allocate(eng, layout{ data_types::f32, format::bfyx, { 1,1,2,2 } }); + memory::ptr input1 = engine.allocate_memory(layout{ data_types::f32, format::bfyx, { 1,1,2,2 } }); + memory::ptr input2 = engine.allocate_memory(layout{ data_types::f32, format::bfyx, { 1,1,2,2 } }); set_values(input1, { 1.0f, 2.0f, @@ -38,11 +34,11 @@ TEST(spatial_concatenate_f32_gpu, test01) { }; topology tpl; - tpl.add(input_layout("in1", input1.get_layout())); - tpl.add(input_layout("in2", input2.get_layout())); + tpl.add(input_layout("in1", input1->get_layout())); + tpl.add(input_layout("in2", input2->get_layout())); tpl.add(concatenation("conc", { "in1", "in2" }, concatenation::along_x)); - network net(eng, tpl); + network net(engine, tpl); net.set_input_data("in1", input1); net.set_input_data("in2", input2); @@ -50,16 +46,16 @@ TEST(spatial_concatenate_f32_gpu, test01) { ASSERT_TRUE(outputs.size() == 1 && outputs.count("conc") == 1); auto output_mem = outputs.at("conc").get_memory(); - auto output_layout = output_mem.get_layout(); + auto output_layout = output_mem->get_layout(); - ASSERT_EQ(output_layout.size.batch[0], input1.get_layout().size.batch[0]); - ASSERT_EQ(output_layout.size.feature[0], input1.get_layout().size.feature[0]); - ASSERT_EQ(output_layout.size.spatial[1], input1.get_layout().size.spatial[1]); - ASSERT_EQ(output_layout.size.spatial[0], input1.get_layout().size.spatial[0] + input2.get_layout().size.spatial[0]); + ASSERT_EQ(output_layout.size.batch[0], input1->get_layout().size.batch[0]); + ASSERT_EQ(output_layout.size.feature[0], input1->get_layout().size.feature[0]); + ASSERT_EQ(output_layout.size.spatial[1], input1->get_layout().size.spatial[1]); + ASSERT_EQ(output_layout.size.spatial[0], input1->get_layout().size.spatial[0] + input2->get_layout().size.spatial[0]); - ASSERT_EQ(output_mem.get_layout().get_linear_size(), expected_output.size()); + ASSERT_EQ(output_mem->get_layout().get_linear_size(), expected_output.size()); { - auto out_ptr = output_mem.pointer(); + cldnn::mem_lock out_ptr(output_mem, get_test_stream()); size_t idx = 0; for (auto const& value : out_ptr) @@ -70,10 +66,10 @@ TEST(spatial_concatenate_f32_gpu, test01) { } TEST(spatial_concatenate_f32_gpu, test02) { - engine eng; + auto& engine = get_test_engine(); - memory input1 = memory::allocate(eng, layout{ data_types::f32, format::bfyx,{ 1,1,2,2 } }); - memory input2 = memory::allocate(eng, layout{ data_types::f32, format::bfyx,{ 1,1,2,2 } }); + memory::ptr input1 = engine.allocate_memory(layout{ data_types::f32, format::bfyx,{ 1,1,2,2 } }); + memory::ptr input2 = engine.allocate_memory(layout{ data_types::f32, format::bfyx,{ 1,1,2,2 } }); set_values(input1, { 1.0f, 2.0f, @@ -93,11 +89,11 @@ TEST(spatial_concatenate_f32_gpu, test02) { }; topology tpl; - tpl.add(input_layout("in1", input1.get_layout())); - tpl.add(input_layout("in2", input2.get_layout())); + tpl.add(input_layout("in1", input1->get_layout())); + tpl.add(input_layout("in2", input2->get_layout())); tpl.add(concatenation("conc", { "in1", "in2" }, concatenation::along_y)); - network net(eng, tpl); + network net(engine, tpl); net.set_input_data("in1", input1); net.set_input_data("in2", input2); @@ -105,16 +101,16 @@ TEST(spatial_concatenate_f32_gpu, test02) { ASSERT_TRUE(outputs.size() == 1 && outputs.count("conc") == 1); auto output_mem = outputs.at("conc").get_memory(); - auto output_layout = output_mem.get_layout(); + auto output_layout = output_mem->get_layout(); - ASSERT_EQ(output_layout.size.batch[0], input1.get_layout().size.batch[0]); - ASSERT_EQ(output_layout.size.feature[0], input1.get_layout().size.feature[0]); - ASSERT_EQ(output_layout.size.spatial[0], input1.get_layout().size.spatial[0]); - ASSERT_EQ(output_layout.size.spatial[1], input1.get_layout().size.spatial[1] + input2.get_layout().size.spatial[1]); + ASSERT_EQ(output_layout.size.batch[0], input1->get_layout().size.batch[0]); + ASSERT_EQ(output_layout.size.feature[0], input1->get_layout().size.feature[0]); + ASSERT_EQ(output_layout.size.spatial[0], input1->get_layout().size.spatial[0]); + ASSERT_EQ(output_layout.size.spatial[1], input1->get_layout().size.spatial[1] + input2->get_layout().size.spatial[1]); - ASSERT_EQ(output_mem.get_layout().get_linear_size(), expected_output.size()); + ASSERT_EQ(output_mem->get_layout().get_linear_size(), expected_output.size()); { - auto out_ptr = output_mem.pointer(); + cldnn::mem_lock out_ptr(output_mem, get_test_stream()); size_t idx = 0; for (auto const& value : out_ptr) @@ -125,10 +121,10 @@ TEST(spatial_concatenate_f32_gpu, test02) { } TEST(spatial_concatenate_f32_gpu, test03) { - engine eng; + auto& engine = get_test_engine(); - memory input1 = memory::allocate(eng, layout{ data_types::f32, format::bfyx,{ 1,1,2,2 } }); - memory input2 = memory::allocate(eng, layout{ data_types::f32, format::bfyx,{ 1,1,2,2 } }); + memory::ptr input1 = engine.allocate_memory(layout{ data_types::f32, format::bfyx,{ 1,1,2,2 } }); + memory::ptr input2 = engine.allocate_memory(layout{ data_types::f32, format::bfyx,{ 1,1,2,2 } }); set_values(input1, { 1.0f, 2.0f, @@ -150,11 +146,11 @@ TEST(spatial_concatenate_f32_gpu, test03) { }; topology tpl; - tpl.add(input_layout("in1", input1.get_layout())); - tpl.add(input_layout("in2", input2.get_layout())); + tpl.add(input_layout("in1", input1->get_layout())); + tpl.add(input_layout("in2", input2->get_layout())); tpl.add(concatenation("conc", { "in1", "in2" }, concatenation::along_y, padding({ 0, 0, 1, 1 }, 0.0f))); - network net(eng, tpl); + network net(engine, tpl); net.set_input_data("in1", input1); net.set_input_data("in2", input2); @@ -162,16 +158,16 @@ TEST(spatial_concatenate_f32_gpu, test03) { ASSERT_TRUE(outputs.size() == 1 && outputs.count("conc") == 1); auto output_mem = outputs.at("conc").get_memory(); - auto output_layout = output_mem.get_layout(); + auto output_layout = output_mem->get_layout(); - ASSERT_EQ(output_layout.size.batch[0], input1.get_layout().size.batch[0]); - ASSERT_EQ(output_layout.size.feature[0], input1.get_layout().size.feature[0]); - ASSERT_EQ(output_layout.size.spatial[0], input1.get_layout().size.spatial[0]); - ASSERT_EQ(output_layout.size.spatial[1], input1.get_layout().size.spatial[1] + input2.get_layout().size.spatial[1]); + ASSERT_EQ(output_layout.size.batch[0], input1->get_layout().size.batch[0]); + ASSERT_EQ(output_layout.size.feature[0], input1->get_layout().size.feature[0]); + ASSERT_EQ(output_layout.size.spatial[0], input1->get_layout().size.spatial[0]); + ASSERT_EQ(output_layout.size.spatial[1], input1->get_layout().size.spatial[1] + input2->get_layout().size.spatial[1]); - ASSERT_EQ(output_mem.get_layout().get_linear_size(), expected_output.size()); + ASSERT_EQ(output_mem->get_layout().get_linear_size(), expected_output.size()); { - auto out_ptr = output_mem.pointer(); + cldnn::mem_lock out_ptr(output_mem, get_test_stream()); size_t idx = 0; for (auto const& value : out_ptr) @@ -182,10 +178,10 @@ TEST(spatial_concatenate_f32_gpu, test03) { } TEST(spatial_concatenate_f32_gpu, test04) { - engine eng; + auto& engine = get_test_engine(); - memory input1 = memory::allocate(eng, layout{ data_types::f32, format::bfyx,{ 1,1,2,2 }, padding({ 0,0,0,0 }, { 0,0,1,0 }) }); - memory input2 = memory::allocate(eng, layout{ data_types::f32, format::bfyx,{ 1,1,2,2 }, padding({ 0,0,0,1 }, 0.0f) }); + memory::ptr input1 = engine.allocate_memory(layout{ data_types::f32, format::bfyx,{ 1,1,2,2 }, padding({ 0,0,0,0 }, { 0,0,1,0 }) }); + memory::ptr input2 = engine.allocate_memory(layout{ data_types::f32, format::bfyx,{ 1,1,2,2 }, padding({ 0,0,0,1 }, 0.0f) }); set_values(input1, { 1.0f, 2.0f, 0.0f, @@ -205,11 +201,11 @@ TEST(spatial_concatenate_f32_gpu, test04) { }; topology tpl; - tpl.add(input_layout("in1", input1.get_layout())); - tpl.add(input_layout("in2", input2.get_layout())); + tpl.add(input_layout("in1", input1->get_layout())); + tpl.add(input_layout("in2", input2->get_layout())); tpl.add(concatenation("conc", { "in1", "in2" }, concatenation::along_x, padding({ 0,0,2,0 }, { 0,0,0,0 }))); - network net(eng, tpl); + network net(engine, tpl); net.set_input_data("in1", input1); net.set_input_data("in2", input2); @@ -217,16 +213,16 @@ TEST(spatial_concatenate_f32_gpu, test04) { ASSERT_TRUE(outputs.size() == 1 && outputs.count("conc") == 1); auto output_mem = outputs.at("conc").get_memory(); - auto output_layout = output_mem.get_layout(); + auto output_layout = output_mem->get_layout(); - ASSERT_EQ(output_layout.size.batch[0], input1.get_layout().size.batch[0]); - ASSERT_EQ(output_layout.size.feature[0], input1.get_layout().size.feature[0]); - ASSERT_EQ(output_layout.size.spatial[1], input1.get_layout().size.spatial[1]); - ASSERT_EQ(output_layout.size.spatial[0], input1.get_layout().size.spatial[0] + input2.get_layout().size.spatial[0]); + ASSERT_EQ(output_layout.size.batch[0], input1->get_layout().size.batch[0]); + ASSERT_EQ(output_layout.size.feature[0], input1->get_layout().size.feature[0]); + ASSERT_EQ(output_layout.size.spatial[1], input1->get_layout().size.spatial[1]); + ASSERT_EQ(output_layout.size.spatial[0], input1->get_layout().size.spatial[0] + input2->get_layout().size.spatial[0]); - ASSERT_EQ(output_mem.get_layout().get_linear_size(), expected_output.size()); + ASSERT_EQ(output_mem->get_layout().get_linear_size(), expected_output.size()); { - auto out_ptr = output_mem.pointer(); + cldnn::mem_lock out_ptr(output_mem, get_test_stream()); size_t idx = 0; for (auto const& value : out_ptr) @@ -237,11 +233,11 @@ TEST(spatial_concatenate_f32_gpu, test04) { } TEST(spatial_concatenate_f32_gpu, inputs_3) { - engine eng; + auto& engine = get_test_engine(); - memory input1 = memory::allocate(eng, layout{ data_types::f32, format::bfyx, { 1,1,2,2 } }); - memory input2 = memory::allocate(eng, layout{ data_types::f32, format::bfyx, { 1,1,2,2 } }); - memory input3 = memory::allocate(eng, layout{ data_types::f32, format::bfyx, { 1,1,2,2 } }); + memory::ptr input1 = engine.allocate_memory(layout{ data_types::f32, format::bfyx, { 1,1,2,2 } }); + memory::ptr input2 = engine.allocate_memory(layout{ data_types::f32, format::bfyx, { 1,1,2,2 } }); + memory::ptr input3 = engine.allocate_memory(layout{ data_types::f32, format::bfyx, { 1,1,2,2 } }); set_values(input1, { 1.0f, 2.0f, @@ -264,12 +260,12 @@ TEST(spatial_concatenate_f32_gpu, inputs_3) { }; topology tpl; - tpl.add(input_layout("in1", input1.get_layout())); - tpl.add(input_layout("in2", input2.get_layout())); - tpl.add(input_layout("in3", input3.get_layout())); + tpl.add(input_layout("in1", input1->get_layout())); + tpl.add(input_layout("in2", input2->get_layout())); + tpl.add(input_layout("in3", input3->get_layout())); tpl.add(concatenation("conc", { "in1", "in2", "in3" }, concatenation::along_x)); - network net(eng, tpl); + network net(engine, tpl); net.set_input_data("in1", input1); net.set_input_data("in2", input2); net.set_input_data("in3", input3); @@ -278,16 +274,16 @@ TEST(spatial_concatenate_f32_gpu, inputs_3) { ASSERT_TRUE(outputs.size() == 1 && outputs.count("conc") == 1); auto output_mem = outputs.at("conc").get_memory(); - auto output_layout = output_mem.get_layout(); + auto output_layout = output_mem->get_layout(); - ASSERT_EQ(output_layout.size.batch[0], input1.get_layout().size.batch[0]); - ASSERT_EQ(output_layout.size.feature[0], input1.get_layout().size.feature[0]); - ASSERT_EQ(output_layout.size.spatial[1], input1.get_layout().size.spatial[1]); - ASSERT_EQ(output_layout.size.spatial[0], input1.get_layout().size.spatial[0] + input2.get_layout().size.spatial[0] + input3.get_layout().size.spatial[0]); + ASSERT_EQ(output_layout.size.batch[0], input1->get_layout().size.batch[0]); + ASSERT_EQ(output_layout.size.feature[0], input1->get_layout().size.feature[0]); + ASSERT_EQ(output_layout.size.spatial[1], input1->get_layout().size.spatial[1]); + ASSERT_EQ(output_layout.size.spatial[0], input1->get_layout().size.spatial[0] + input2->get_layout().size.spatial[0] + input3->get_layout().size.spatial[0]); - ASSERT_EQ(output_mem.get_layout().get_linear_size(), expected_output.size()); + ASSERT_EQ(output_mem->get_layout().get_linear_size(), expected_output.size()); { - auto out_ptr = output_mem.pointer(); + cldnn::mem_lock out_ptr(output_mem, get_test_stream()); size_t idx = 0; for (auto const& value : out_ptr) @@ -298,11 +294,11 @@ TEST(spatial_concatenate_f32_gpu, inputs_3) { } TEST(spatial_concatenate_f32_gpu, inputs_3_uneven_axis_b) { - engine eng; + auto& engine = get_test_engine(); - memory input1 = memory::allocate(eng, layout{ data_types::f32, format::bfyx, { 3,1,2,2 } }); - memory input2 = memory::allocate(eng, layout{ data_types::f32, format::bfyx, { 1,1,2,2 } }); - memory input3 = memory::allocate(eng, layout{ data_types::f32, format::bfyx, { 2,1,2,2 } }); + memory::ptr input1 = engine.allocate_memory(layout{ data_types::f32, format::bfyx, { 3,1,2,2 } }); + memory::ptr input2 = engine.allocate_memory(layout{ data_types::f32, format::bfyx, { 1,1,2,2 } }); + memory::ptr input3 = engine.allocate_memory(layout{ data_types::f32, format::bfyx, { 2,1,2,2 } }); set_values(input1, { 1.0f, 2.0f, @@ -352,12 +348,12 @@ TEST(spatial_concatenate_f32_gpu, inputs_3_uneven_axis_b) { }; topology tpl; - tpl.add(input_layout("in1", input1.get_layout())); - tpl.add(input_layout("in2", input2.get_layout())); - tpl.add(input_layout("in3", input3.get_layout())); + tpl.add(input_layout("in1", input1->get_layout())); + tpl.add(input_layout("in2", input2->get_layout())); + tpl.add(input_layout("in3", input3->get_layout())); tpl.add(concatenation("conc", { "in1", "in2", "in3" }, concatenation::along_b)); - network net(eng, tpl); + network net(engine, tpl); net.set_input_data("in1", input1); net.set_input_data("in2", input2); net.set_input_data("in3", input3); @@ -366,16 +362,16 @@ TEST(spatial_concatenate_f32_gpu, inputs_3_uneven_axis_b) { ASSERT_TRUE(outputs.size() == 1 && outputs.count("conc") == 1); auto output_mem = outputs.at("conc").get_memory(); - auto output_layout = output_mem.get_layout(); + auto output_layout = output_mem->get_layout(); - ASSERT_EQ(output_layout.size.batch[0], input1.get_layout().size.batch[0] + input2.get_layout().size.batch[0] + input3.get_layout().size.batch[0]); - ASSERT_EQ(output_layout.size.feature[0], input1.get_layout().size.feature[0]); - ASSERT_EQ(output_layout.size.spatial[1], input1.get_layout().size.spatial[1]); - ASSERT_EQ(output_layout.size.spatial[0], input1.get_layout().size.spatial[0]); + ASSERT_EQ(output_layout.size.batch[0], input1->get_layout().size.batch[0] + input2->get_layout().size.batch[0] + input3->get_layout().size.batch[0]); + ASSERT_EQ(output_layout.size.feature[0], input1->get_layout().size.feature[0]); + ASSERT_EQ(output_layout.size.spatial[1], input1->get_layout().size.spatial[1]); + ASSERT_EQ(output_layout.size.spatial[0], input1->get_layout().size.spatial[0]); - ASSERT_EQ(output_mem.get_layout().get_linear_size(), expected_output.size()); + ASSERT_EQ(output_mem->get_layout().get_linear_size(), expected_output.size()); { - auto out_ptr = output_mem.pointer(); + cldnn::mem_lock out_ptr(output_mem, get_test_stream()); size_t idx = 0; for (auto const& value : out_ptr) @@ -386,10 +382,10 @@ TEST(spatial_concatenate_f32_gpu, inputs_3_uneven_axis_b) { } TEST(spatial_concatenate_f32_gpu, inputs3d_axis_x) { - engine eng; + auto& engine = get_test_engine(); - memory input1 = memory::allocate(eng, layout{ data_types::f32, format::bfzyx, { 1,1,2,2,2 } }); - memory input2 = memory::allocate(eng, layout{ data_types::f32, format::bfzyx, { 1,1,2,2,2 } }); + memory::ptr input1 = engine.allocate_memory(layout{ data_types::f32, format::bfzyx, { 1,1,2,2,2 } }); + memory::ptr input2 = engine.allocate_memory(layout{ data_types::f32, format::bfzyx, { 1,1,2,2,2 } }); set_values(input1, { 1.0f, 2.0f, @@ -413,11 +409,11 @@ TEST(spatial_concatenate_f32_gpu, inputs3d_axis_x) { }; topology tpl; - tpl.add(input_layout("in1", input1.get_layout())); - tpl.add(input_layout("in2", input2.get_layout())); + tpl.add(input_layout("in1", input1->get_layout())); + tpl.add(input_layout("in2", input2->get_layout())); tpl.add(concatenation("conc", { "in1", "in2" }, concatenation::along_x)); - network net(eng, tpl); + network net(engine, tpl); net.set_input_data("in1", input1); net.set_input_data("in2", input2); @@ -425,17 +421,17 @@ TEST(spatial_concatenate_f32_gpu, inputs3d_axis_x) { ASSERT_TRUE(outputs.size() == 1 && outputs.count("conc") == 1); auto output_mem = outputs.at("conc").get_memory(); - auto output_layout = output_mem.get_layout(); + auto output_layout = output_mem->get_layout(); - ASSERT_EQ(output_layout.size.batch[0], input1.get_layout().size.batch[0]); - ASSERT_EQ(output_layout.size.feature[0], input1.get_layout().size.feature[0]); - ASSERT_EQ(output_layout.size.spatial[0], input1.get_layout().size.spatial[0] + input2.get_layout().size.spatial[0]); - ASSERT_EQ(output_layout.size.spatial[1], input1.get_layout().size.spatial[1]); - ASSERT_EQ(output_layout.size.spatial[2], input1.get_layout().size.spatial[2]); + ASSERT_EQ(output_layout.size.batch[0], input1->get_layout().size.batch[0]); + ASSERT_EQ(output_layout.size.feature[0], input1->get_layout().size.feature[0]); + ASSERT_EQ(output_layout.size.spatial[0], input1->get_layout().size.spatial[0] + input2->get_layout().size.spatial[0]); + ASSERT_EQ(output_layout.size.spatial[1], input1->get_layout().size.spatial[1]); + ASSERT_EQ(output_layout.size.spatial[2], input1->get_layout().size.spatial[2]); - ASSERT_EQ(output_mem.get_layout().get_linear_size(), expected_output.size()); + ASSERT_EQ(output_mem->get_layout().get_linear_size(), expected_output.size()); { - auto out_ptr = output_mem.pointer(); + cldnn::mem_lock out_ptr(output_mem, get_test_stream()); size_t idx = 0; for (auto const& value : out_ptr) @@ -446,10 +442,10 @@ TEST(spatial_concatenate_f32_gpu, inputs3d_axis_x) { } TEST(spatial_concatenate_f32_gpu, inputs3d_axis_y) { - engine eng; + auto& engine = get_test_engine(); - memory input1 = memory::allocate(eng, layout{ data_types::f32, format::bfzyx, { 1,1,2,2,2 } }); - memory input2 = memory::allocate(eng, layout{ data_types::f32, format::bfzyx, { 1,1,2,2,2 } }); + memory::ptr input1 = engine.allocate_memory(layout{ data_types::f32, format::bfzyx, { 1,1,2,2,2 } }); + memory::ptr input2 = engine.allocate_memory(layout{ data_types::f32, format::bfzyx, { 1,1,2,2,2 } }); set_values(input1, { 1.0f, 2.0f, @@ -477,11 +473,11 @@ TEST(spatial_concatenate_f32_gpu, inputs3d_axis_y) { }; topology tpl; - tpl.add(input_layout("in1", input1.get_layout())); - tpl.add(input_layout("in2", input2.get_layout())); + tpl.add(input_layout("in1", input1->get_layout())); + tpl.add(input_layout("in2", input2->get_layout())); tpl.add(concatenation("conc", { "in1", "in2" }, concatenation::along_y)); - network net(eng, tpl); + network net(engine, tpl); net.set_input_data("in1", input1); net.set_input_data("in2", input2); @@ -489,17 +485,17 @@ TEST(spatial_concatenate_f32_gpu, inputs3d_axis_y) { ASSERT_TRUE(outputs.size() == 1 && outputs.count("conc") == 1); auto output_mem = outputs.at("conc").get_memory(); - auto output_layout = output_mem.get_layout(); + auto output_layout = output_mem->get_layout(); - ASSERT_EQ(output_layout.size.batch[0], input1.get_layout().size.batch[0]); - ASSERT_EQ(output_layout.size.feature[0], input1.get_layout().size.feature[0]); - ASSERT_EQ(output_layout.size.spatial[0], input1.get_layout().size.spatial[0]); - ASSERT_EQ(output_layout.size.spatial[1], input1.get_layout().size.spatial[1] + input2.get_layout().size.spatial[1]); - ASSERT_EQ(output_layout.size.spatial[2], input1.get_layout().size.spatial[2]); + ASSERT_EQ(output_layout.size.batch[0], input1->get_layout().size.batch[0]); + ASSERT_EQ(output_layout.size.feature[0], input1->get_layout().size.feature[0]); + ASSERT_EQ(output_layout.size.spatial[0], input1->get_layout().size.spatial[0]); + ASSERT_EQ(output_layout.size.spatial[1], input1->get_layout().size.spatial[1] + input2->get_layout().size.spatial[1]); + ASSERT_EQ(output_layout.size.spatial[2], input1->get_layout().size.spatial[2]); - ASSERT_EQ(output_mem.get_layout().get_linear_size(), expected_output.size()); + ASSERT_EQ(output_mem->get_layout().get_linear_size(), expected_output.size()); { - auto out_ptr = output_mem.pointer(); + cldnn::mem_lock out_ptr(output_mem, get_test_stream()); size_t idx = 0; for (auto const& value : out_ptr) @@ -510,10 +506,10 @@ TEST(spatial_concatenate_f32_gpu, inputs3d_axis_y) { } TEST(spatial_concatenate_f32_gpu, inputs3d_axis_z) { - engine eng; + auto& engine = get_test_engine(); - memory input1 = memory::allocate(eng, layout{ data_types::f32, format::bfzyx, { 1,1,2,2,2 } }); - memory input2 = memory::allocate(eng, layout{ data_types::f32, format::bfzyx, { 1,1,2,2,2 } }); + memory::ptr input1 = engine.allocate_memory(layout{ data_types::f32, format::bfzyx, { 1,1,2,2,2 } }); + memory::ptr input2 = engine.allocate_memory(layout{ data_types::f32, format::bfzyx, { 1,1,2,2,2 } }); set_values(input1, { 1.0f, 2.0f, @@ -541,11 +537,11 @@ TEST(spatial_concatenate_f32_gpu, inputs3d_axis_z) { }; topology tpl; - tpl.add(input_layout("in1", input1.get_layout())); - tpl.add(input_layout("in2", input2.get_layout())); + tpl.add(input_layout("in1", input1->get_layout())); + tpl.add(input_layout("in2", input2->get_layout())); tpl.add(concatenation("conc", { "in1", "in2" }, concatenation::along_z)); - network net(eng, tpl); + network net(engine, tpl); net.set_input_data("in1", input1); net.set_input_data("in2", input2); @@ -553,17 +549,17 @@ TEST(spatial_concatenate_f32_gpu, inputs3d_axis_z) { ASSERT_TRUE(outputs.size() == 1 && outputs.count("conc") == 1); auto output_mem = outputs.at("conc").get_memory(); - auto output_layout = output_mem.get_layout(); + auto output_layout = output_mem->get_layout(); - ASSERT_EQ(output_layout.size.batch[0], input1.get_layout().size.batch[0]); - ASSERT_EQ(output_layout.size.feature[0], input1.get_layout().size.feature[0]); - ASSERT_EQ(output_layout.size.spatial[0], input1.get_layout().size.spatial[0]); - ASSERT_EQ(output_layout.size.spatial[1], input1.get_layout().size.spatial[1]); - ASSERT_EQ(output_layout.size.spatial[2], input1.get_layout().size.spatial[2] + input2.get_layout().size.spatial[2]); + ASSERT_EQ(output_layout.size.batch[0], input1->get_layout().size.batch[0]); + ASSERT_EQ(output_layout.size.feature[0], input1->get_layout().size.feature[0]); + ASSERT_EQ(output_layout.size.spatial[0], input1->get_layout().size.spatial[0]); + ASSERT_EQ(output_layout.size.spatial[1], input1->get_layout().size.spatial[1]); + ASSERT_EQ(output_layout.size.spatial[2], input1->get_layout().size.spatial[2] + input2->get_layout().size.spatial[2]); - ASSERT_EQ(output_mem.get_layout().get_linear_size(), expected_output.size()); + ASSERT_EQ(output_mem->get_layout().get_linear_size(), expected_output.size()); { - auto out_ptr = output_mem.pointer(); + cldnn::mem_lock out_ptr(output_mem, get_test_stream()); size_t idx = 0; for (auto const& value : out_ptr) @@ -574,10 +570,10 @@ TEST(spatial_concatenate_f32_gpu, inputs3d_axis_z) { } TEST(spatial_concatenate_f32_gpu, inputs3d_axis_b) { - engine eng; + auto& engine = get_test_engine(); - memory input1 = memory::allocate(eng, layout{ data_types::f32, format::bfzyx, { 2,1,2,2,2 } }); - memory input2 = memory::allocate(eng, layout{ data_types::f32, format::bfzyx, { 1,1,2,2,2 } }); + memory::ptr input1 = engine.allocate_memory(layout{ data_types::f32, format::bfzyx, { 2,1,2,2,2 } }); + memory::ptr input2 = engine.allocate_memory(layout{ data_types::f32, format::bfzyx, { 1,1,2,2,2 } }); set_values(input1, { 1.0f, 2.0f, @@ -616,11 +612,11 @@ TEST(spatial_concatenate_f32_gpu, inputs3d_axis_b) { }; topology tpl; - tpl.add(input_layout("in1", input1.get_layout())); - tpl.add(input_layout("in2", input2.get_layout())); + tpl.add(input_layout("in1", input1->get_layout())); + tpl.add(input_layout("in2", input2->get_layout())); tpl.add(concatenation("conc", { "in1", "in2" }, concatenation::along_b)); - network net(eng, tpl); + network net(engine, tpl); net.set_input_data("in1", input1); net.set_input_data("in2", input2); @@ -628,17 +624,17 @@ TEST(spatial_concatenate_f32_gpu, inputs3d_axis_b) { ASSERT_TRUE(outputs.size() == 1 && outputs.count("conc") == 1); auto output_mem = outputs.at("conc").get_memory(); - auto output_layout = output_mem.get_layout(); + auto output_layout = output_mem->get_layout(); - ASSERT_EQ(output_layout.size.batch[0], input1.get_layout().size.batch[0] + input2.get_layout().size.batch[0]); - ASSERT_EQ(output_layout.size.feature[0], input1.get_layout().size.feature[0]); - ASSERT_EQ(output_layout.size.spatial[0], input1.get_layout().size.spatial[0]); - ASSERT_EQ(output_layout.size.spatial[1], input1.get_layout().size.spatial[1]); - ASSERT_EQ(output_layout.size.spatial[2], input1.get_layout().size.spatial[2]); + ASSERT_EQ(output_layout.size.batch[0], input1->get_layout().size.batch[0] + input2->get_layout().size.batch[0]); + ASSERT_EQ(output_layout.size.feature[0], input1->get_layout().size.feature[0]); + ASSERT_EQ(output_layout.size.spatial[0], input1->get_layout().size.spatial[0]); + ASSERT_EQ(output_layout.size.spatial[1], input1->get_layout().size.spatial[1]); + ASSERT_EQ(output_layout.size.spatial[2], input1->get_layout().size.spatial[2]); - ASSERT_EQ(output_mem.get_layout().get_linear_size(), expected_output.size()); + ASSERT_EQ(output_mem->get_layout().get_linear_size(), expected_output.size()); { - auto out_ptr = output_mem.pointer(); + cldnn::mem_lock out_ptr(output_mem, get_test_stream()); size_t idx = 0; for (auto const& value : out_ptr) @@ -649,11 +645,11 @@ TEST(spatial_concatenate_f32_gpu, inputs3d_axis_b) { } TEST(spatial_concatenate_f32_gpu, inputs3d_3_uneven_axis_b) { - engine eng; + auto& engine = get_test_engine(); - memory input1 = memory::allocate(eng, layout{ data_types::f32, format::bfzyx, { 3,1,2,2,2 } }); - memory input2 = memory::allocate(eng, layout{ data_types::f32, format::bfzyx, { 1,1,2,2,2 } }); - memory input3 = memory::allocate(eng, layout{ data_types::f32, format::bfzyx, { 2,1,2,2,2 } }); + memory::ptr input1 = engine.allocate_memory(layout{ data_types::f32, format::bfzyx, { 3,1,2,2,2 } }); + memory::ptr input2 = engine.allocate_memory(layout{ data_types::f32, format::bfzyx, { 1,1,2,2,2 } }); + memory::ptr input3 = engine.allocate_memory(layout{ data_types::f32, format::bfzyx, { 2,1,2,2,2 } }); set_values(input1, { //b0 @@ -745,12 +741,12 @@ TEST(spatial_concatenate_f32_gpu, inputs3d_3_uneven_axis_b) { }; topology tpl; - tpl.add(input_layout("in1", input1.get_layout())); - tpl.add(input_layout("in2", input2.get_layout())); - tpl.add(input_layout("in3", input3.get_layout())); + tpl.add(input_layout("in1", input1->get_layout())); + tpl.add(input_layout("in2", input2->get_layout())); + tpl.add(input_layout("in3", input3->get_layout())); tpl.add(concatenation("conc", { "in1", "in2", "in3" }, concatenation::along_b)); - network net(eng, tpl); + network net(engine, tpl); net.set_input_data("in1", input1); net.set_input_data("in2", input2); net.set_input_data("in3", input3); @@ -759,17 +755,17 @@ TEST(spatial_concatenate_f32_gpu, inputs3d_3_uneven_axis_b) { ASSERT_TRUE(outputs.size() == 1 && outputs.count("conc") == 1); auto output_mem = outputs.at("conc").get_memory(); - auto output_layout = output_mem.get_layout(); + auto output_layout = output_mem->get_layout(); - ASSERT_EQ(output_layout.size.batch[0], input1.get_layout().size.batch[0] + input2.get_layout().size.batch[0] + input3.get_layout().size.batch[0]); - ASSERT_EQ(output_layout.size.feature[0], input1.get_layout().size.feature[0]); - ASSERT_EQ(output_layout.size.spatial[0], input1.get_layout().size.spatial[0]); - ASSERT_EQ(output_layout.size.spatial[1], input1.get_layout().size.spatial[1]); - ASSERT_EQ(output_layout.size.spatial[2], input1.get_layout().size.spatial[2]); + ASSERT_EQ(output_layout.size.batch[0], input1->get_layout().size.batch[0] + input2->get_layout().size.batch[0] + input3->get_layout().size.batch[0]); + ASSERT_EQ(output_layout.size.feature[0], input1->get_layout().size.feature[0]); + ASSERT_EQ(output_layout.size.spatial[0], input1->get_layout().size.spatial[0]); + ASSERT_EQ(output_layout.size.spatial[1], input1->get_layout().size.spatial[1]); + ASSERT_EQ(output_layout.size.spatial[2], input1->get_layout().size.spatial[2]); - ASSERT_EQ(output_mem.get_layout().get_linear_size(), expected_output.size()); + ASSERT_EQ(output_mem->get_layout().get_linear_size(), expected_output.size()); { - auto out_ptr = output_mem.pointer(); + cldnn::mem_lock out_ptr(output_mem, get_test_stream()); size_t idx = 0; for (auto const& value : out_ptr) diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/split_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/split_gpu_test.cpp index 0d420abfefabcd..10cb13acc3137d 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/split_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/split_gpu_test.cpp @@ -2,23 +2,18 @@ // SPDX-License-Identifier: Apache-2.0 // -/////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include "api/split.hpp" -#include "api/scale.hpp" -#include -#include -#include -#include -#include "test_utils/test_utils.h" +#include "test_utils.h" + +#include +#include +#include +#include #include #include using namespace cldnn; -using namespace tests; +using namespace ::tests; template std::vector generate_random_input(size_t b, size_t f, size_t y, size_t x, int min, int max) { @@ -34,7 +29,7 @@ std::vector generate_random_input(size_t b, size_t f, size_t y, size_t x, int } template -void check_feature_map(cldnn::pointer output_ptr, std::vector &input_vec, size_t batch_num, size_t feature_num, size_t y_size, size_t x_size, size_t feature_id, size_t factor) +void check_feature_map(T* output_ptr, std::vector &input_vec, size_t batch_num, size_t feature_num, size_t y_size, size_t x_size, size_t feature_id, size_t factor) { for (size_t b = 0; b < batch_num; ++b) { //B for (size_t y = 0; y < y_size; ++y) { //Y @@ -50,15 +45,15 @@ void check_feature_map(cldnn::pointer output_ptr, std::vector &input_vec, template void split_test(int batch_num, int feature_num, int x_size, int y_size, std::vector split_offsets) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); cldnn::tensor reference_input_size = { batch_num, feature_num, x_size, y_size }; - cldnn::memory input = memory::allocate(engine, { type_to_data_type::value, format::bfyx, reference_input_size }); + cldnn::memory::ptr input = engine.allocate_memory({ type_to_data_type::value, format::bfyx, reference_input_size }); std::vector > input_ids_offsets; topology topology; - topology.add(input_layout("input", input.get_layout())); - + topology.add(input_layout("input", input->get_layout())); + // lambda exoression to create the primitive id for the splits auto create_split_id = [](size_t splitNum) { std::stringstream ss; @@ -68,7 +63,7 @@ void split_test(int batch_num, int feature_num, int x_size, int y_size, std::vec }; // Create the splits with the split ids for the topology - for (size_t splitNum = 0; splitNum < split_offsets.size(); splitNum++) + for (size_t splitNum = 0; splitNum < split_offsets.size(); splitNum++) { input_ids_offsets.push_back({ create_split_id(splitNum), split_offsets[splitNum]}); } @@ -85,7 +80,7 @@ void split_test(int batch_num, int feature_num, int x_size, int y_size, std::vec // The number of splits should match the expected number of splits EXPECT_EQ(outputs.size(), size_t(split_offsets.size())); - + std::vector expected_sizes; for (size_t splitNum = 0; splitNum < split_offsets.size(); splitNum++) // Calculate the expected sizes { @@ -110,15 +105,15 @@ void split_test(int batch_num, int feature_num, int x_size, int y_size, std::vec expected_sizes.push_back(size); } - pointer input_ptr = input.pointer(); + cldnn::mem_lock input_ptr(input, get_test_stream()); for (size_t splitNum = 0; splitNum < split_offsets.size(); splitNum++) { primitive_id split_id = "split:" + create_split_id(splitNum); - cldnn::memory output = outputs.at(split_id).get_memory(); - auto prim = output.get_layout(); + cldnn::memory::ptr output = outputs.at(split_id).get_memory(); + auto prim = output->get_layout(); EXPECT_EQ(prim.size, expected_sizes[splitNum]); - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); // Output tensor size auto output_batch = prim.size.batch[0]; @@ -131,25 +126,25 @@ void split_test(int batch_num, int feature_num, int x_size, int y_size, std::vec auto input_feature_offset = split_offsets[splitNum].feature[0]; auto input_y_offset = split_offsets[splitNum].spatial[1]; auto input_x_offset = split_offsets[splitNum].spatial[0]; - + // iterator to iterate through input buffer auto input_batch_itr = input_batch_offset; auto input_feature_itr = input_feature_offset; auto input_y_itr = input_y_offset; auto input_x_itr = input_x_offset; - + for (auto b = 0; b < output_batch; ++b) { // B - + // reset the input feature iterator - input_feature_itr = input_feature_offset; + input_feature_itr = input_feature_offset; for (auto f = 0; f < output_feature; f++) { // F - + // reset the input y iterator - input_y_itr = input_y_offset; + input_y_itr = input_y_offset; for (auto y = 0; y < output_y; y++) { // Y - + // reset the input x iterator - input_x_itr = input_x_offset; + input_x_itr = input_x_offset; for (auto x = 0; x < output_x; x++) { // X auto linear_id = input_x_itr + x_size * (input_y_itr + y_size * (input_feature_itr + feature_num * input_batch_itr)); // index in input auto output_linear_id = x + output_x * (y + output_y * (f + output_feature * b)); // index in output @@ -180,7 +175,7 @@ TEST(split_gpu_f32, split_1d_uneven_2_splits) { auto y_size = 3; std::vector split_offsets = { {0, 0, 0, 0}, - {0, 1, 0, 0} + {0, 1, 0, 0} }; split_test(batch_num, feature_num, x_size, y_size, split_offsets); @@ -201,7 +196,7 @@ TEST(split_gpu_i64, split_1d_uneven_2_splits) { auto y_size = 3; std::vector split_offsets = { {0, 0, 0, 0}, - {0, 1, 0, 0} + {0, 1, 0, 0} }; split_test(batch_num, feature_num, x_size, y_size, split_offsets); @@ -209,13 +204,13 @@ TEST(split_gpu_i64, split_1d_uneven_2_splits) { TEST(split_gpu_f32, basic_split_concat_optimization) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32,format::bfyx,{ 1, 25, 1, 256 } }); + auto input = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 25, 1, 256 } }); tests::set_random_values(input); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); std::vector> offsets; std::vector ids; for (int i = 0; i < 25; i++) @@ -238,8 +233,8 @@ TEST(split_gpu_f32, basic_split_concat_optimization) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); - auto input_ptr = input.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + cldnn::mem_lock input_ptr(input, get_test_stream()); for (int i = 0; i < 25*256; ++i) { @@ -249,13 +244,13 @@ TEST(split_gpu_f32, basic_split_concat_optimization) { TEST(split_gpu_i64, basic_split_concat_optimization) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::i64,format::bfyx,{ 1, 25, 1, 256 } }); + auto input = engine.allocate_memory({ data_types::i64,format::bfyx,{ 1, 25, 1, 256 } }); tests::set_random_values(input); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); std::vector> offsets; std::vector ids; for (int i = 0; i < 25; i++) @@ -278,8 +273,8 @@ TEST(split_gpu_i64, basic_split_concat_optimization) { auto outputs = network.execute(); auto output = outputs.at("output").get_memory(); - auto output_ptr = output.pointer(); - auto input_ptr = input.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + cldnn::mem_lock input_ptr(input, get_test_stream()); for (int i = 0; i < 25*256; ++i) { @@ -523,17 +518,17 @@ TEST(split_gpu_f32, basic_in2x3x2x2_split_feature_bfyx) { // id: "out1", offsets: { 0, 1, 0, 0 } // id: "out2", offsets: { 0, 2, 0, 0 } - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 6; auto feature_num = 3; auto x_size = 4; auto y_size = 3; - auto input = memory::allocate(engine, { data_types::f32,format::bfyx,{ batch_num, feature_num, x_size, y_size } }); + auto input = engine.allocate_memory({ data_types::f32,format::bfyx,{ batch_num, feature_num, x_size, y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(split("split", "input", { { "out0", { 0, 0, 0, 0 } }, @@ -556,8 +551,8 @@ TEST(split_gpu_f32, basic_in2x3x2x2_split_feature_bfyx) { { auto split_id = "split:out" + std::to_string(i); auto output = outputs.at(split_id).get_memory(); - auto output_ptr = output.pointer(); - check_feature_map(output_ptr, input_vec, batch_num, feature_num, y_size, x_size, i, 1); + cldnn::mem_lock output_ptr(output, get_test_stream()); + check_feature_map(output_ptr.data(), input_vec, batch_num, feature_num, y_size, x_size, i, 1); } } @@ -569,17 +564,17 @@ TEST(split_gpu_i64, basic_in2x3x2x2_split_feature_bfyx) { // id: "out1", offsets: { 0, 1, 0, 0 } // id: "out2", offsets: { 0, 2, 0, 0 } - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 6; auto feature_num = 3; auto x_size = 4; auto y_size = 3; - auto input = memory::allocate(engine, { data_types::i64,format::bfyx,{ batch_num, feature_num, x_size, y_size } }); + auto input = engine.allocate_memory({ data_types::i64,format::bfyx,{ batch_num, feature_num, x_size, y_size } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(split("split", "input", { { "out0", { 0, 0, 0, 0 } }, @@ -602,8 +597,8 @@ TEST(split_gpu_i64, basic_in2x3x2x2_split_feature_bfyx) { { auto split_id = "split:out" + std::to_string(i); auto output = outputs.at(split_id).get_memory(); - auto output_ptr = output.pointer(); - check_feature_map(output_ptr, input_vec, batch_num, feature_num, y_size, x_size, i, 1); + cldnn::mem_lock output_ptr(output, get_test_stream()); + check_feature_map(output_ptr.data(), input_vec, batch_num, feature_num, y_size, x_size, i, 1); } } @@ -616,23 +611,23 @@ TEST(split_gpu_f32, basic_in2x3x2x2_split_scale_feature_bfyx) { // id: "out2", offsets: { 0, 2, 0, 0 } // Additional scale layer at the end - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); auto batch_num = 6; auto feature_num = 3; auto x_size = 4; auto y_size = 3; - auto input = memory::allocate(engine, { data_types::f32,format::bfyx,{ batch_num, feature_num, x_size, y_size } }); - auto scale_input0 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); - auto scale_input1 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); - auto scale_input2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32,format::bfyx,{ batch_num, feature_num, x_size, y_size } }); + auto scale_input0 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto scale_input1 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto scale_input2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); - topology.add(input_layout("scale_input0", scale_input0.get_layout())); - topology.add(input_layout("scale_input1", scale_input1.get_layout())); - topology.add(input_layout("scale_input2", scale_input2.get_layout())); + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("scale_input0", scale_input0->get_layout())); + topology.add(input_layout("scale_input1", scale_input1->get_layout())); + topology.add(input_layout("scale_input2", scale_input2->get_layout())); topology.add(split("split", "input", { { "out0",{ 0, 0, 0, 0 } }, @@ -649,7 +644,7 @@ TEST(split_gpu_f32, basic_in2x3x2x2_split_scale_feature_bfyx) { set_values(scale_input1, scale_input_vec1); std::vector scale_input_vec2 = { 3.f }; set_values(scale_input2, scale_input_vec2); - + std::vector input_vec = generate_random_input(batch_num, feature_num, y_size, x_size, -10, 10); set_values(input, input_vec); @@ -668,7 +663,7 @@ TEST(split_gpu_f32, basic_in2x3x2x2_split_scale_feature_bfyx) { { auto split_id = "scale" + std::to_string(i); auto output = outputs.at(split_id).get_memory(); - auto output_ptr = output.pointer(); - check_feature_map(output_ptr, input_vec, batch_num, feature_num, y_size, x_size, i, i + 1); + cldnn::mem_lock output_ptr(output, get_test_stream()); + check_feature_map(output_ptr.data(), input_vec, batch_num, feature_num, y_size, x_size, i, i + 1); } } diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/streams_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/streams_test.cpp index b679ac71a6be9e..ed1dfa1110a1b0 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/streams_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/streams_test.cpp @@ -2,50 +2,19 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include -#include -#include "test_utils/test_utils.h" +#include "test_utils.h" + +#include +#include +#include using namespace cldnn; -using namespace tests; - -static engine_configuration streams_config(false, - false, - false, - "", - "", - true, - "", - "", - priority_mode_types::disabled, - throttle_mode_types::disabled, - true, - 2); - -TEST(gpu_streams, DISABLED_can_allocate_memory_for_stream) -{ - engine _engine(streams_config); - - ASSERT_NO_THROW(memory::allocate(_engine, layout(data_types::f32, format::bfyx, {1, 2, 3, 4}))); - ASSERT_NO_THROW(memory::allocate(_engine, layout(data_types::f32, format::bfyx, {1, 2, 3, 4}), 0)); - ASSERT_NO_THROW(memory::allocate(_engine, layout(data_types::f32, format::bfyx, {1, 2, 3, 4}), 1)); - ASSERT_ANY_THROW(memory::allocate(_engine, layout(data_types::f32, format::bfyx, {1, 2, 3, 4}), 2)); - - auto mem0 = memory::allocate(_engine, layout(data_types::f32, format::bfyx, {1, 2, 3, 4}), 0); - ASSERT_EQ(mem0.get_net_id(), 0); - auto mem1 = memory::allocate(_engine, layout(data_types::f32, format::bfyx, {1, 2, 3, 4}), 1); - ASSERT_EQ(mem1.get_net_id(), 1); -} +using namespace ::tests; -TEST(gpu_streams, can_create_networks_for_stream) -{ - engine _engine(streams_config); +TEST(gpu_streams, can_create_networks_for_stream) { + auto& engine = get_test_engine(); - auto input = memory::allocate(_engine, { data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 5, 4 } }); set_values(input, { 1.0f, -2.0f, -3.0f, 4.0f, 5.0f, 2.0f, 2.0f, 3.0f, 4.0f, -6.0f, @@ -58,9 +27,9 @@ TEST(gpu_streams, can_create_networks_for_stream) 1.0f, 1.0f, 1.0f, -0.5f, 1.0f }; topology topology( - input_layout("input", input.get_layout()), + input_layout("input", input->get_layout()), activation("relu", "input", activation_func::relu_negative_slope, activation_additional_params{ 0.5f, 0.f }, padding{ { 0, 0, 0, 0 }, 0 })); - network network(_engine, topology, build_options()); + network network(engine, topology, build_options()); network.set_input_data("input", input); auto outputs = network.execute(); @@ -68,10 +37,8 @@ TEST(gpu_streams, can_create_networks_for_stream) EXPECT_EQ(outputs.begin()->first, "relu"); auto output_memory = outputs.at("relu").get_memory(); - auto output_layout = output_memory.get_layout(); - auto output_ptr = output_memory.pointer(); - - EXPECT_EQ(output_memory.get_net_id(), network.get_id()); + auto output_layout = output_memory->get_layout(); + cldnn::mem_lock output_ptr(output_memory, get_test_stream()); int y_size = output_layout.size.spatial[1]; int x_size = output_layout.size.spatial[0]; @@ -89,9 +56,9 @@ TEST(gpu_streams, can_create_networks_for_stream) } TEST(gpu_streams, check_networks_can_use_the_same_weights) { - engine _engine(streams_config); + auto& engine = get_test_engine(); - auto weights = memory::allocate(_engine, { data_types::f32,format::bfyx,{ 1, 1, 3, 2 } }); + auto weights = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 1, 3, 2 } }); VVF output_vec = { { 20.0f, 27.0f, 38.0f }, @@ -105,12 +72,12 @@ TEST(gpu_streams, check_networks_can_use_the_same_weights) { convolution("conv", "input", { "weights" }, { 1,1,1,2 })); set_values(weights, { 1.0f, 2.0f, 1.0f, 2.0f, 1.0f, 2.0f }); - program prog(_engine, topology, build_options()); + program prog(engine, topology, build_options()); network network0(prog, 0); network network1(prog, 1); - auto input0 = memory::allocate(_engine, input0_layout, network0.get_id()); - auto input1 = memory::allocate(_engine, input0_layout, network1.get_id()); + auto input0 = engine.allocate_memory(input0_layout); + auto input1 = engine.allocate_memory(input0_layout); set_values(input0, { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 2.0f, 2.0f, 3.0f, 4.0f, 6.0f, 3.0f, 3.0f, 3.0f, 5.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }); set_values(input1, { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 2.0f, 2.0f, 3.0f, 4.0f, 6.0f, 3.0f, 3.0f, 3.0f, 5.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }); @@ -126,12 +93,10 @@ TEST(gpu_streams, check_networks_can_use_the_same_weights) { auto output_memory0 = outputs0.at("conv").get_memory(); auto output_memory1 = outputs1.at("conv").get_memory(); - auto output_layout = output_memory0.get_layout(); - auto output_ptr0 = output_memory0.pointer(); - auto output_ptr1 = output_memory1.pointer(); + auto output_layout = output_memory0->get_layout(); + cldnn::mem_lock output_ptr0(output_memory0, get_test_stream()); + cldnn::mem_lock output_ptr1(output_memory1, get_test_stream()); - EXPECT_EQ(output_memory0.get_net_id(), network0.get_id()); - EXPECT_EQ(output_memory1.get_net_id(), network1.get_id()); auto wmem0 = network0.get_output_memory("weights"); auto wmem1 = network1.get_output_memory("weights"); @@ -153,3 +118,71 @@ TEST(gpu_streams, check_networks_can_use_the_same_weights) { } } } + +TEST(gpu_streams, check_networks_use_unique_mutable_data_per_stream) { + auto& engine = get_test_engine(); + + auto weights = engine.allocate_memory({ data_types::f32,format::bfyx,{ 1, 1, 3, 2 } }); + + VVF output_vec = { + { 20.0f, 27.0f, 38.0f }, + { 17.0f, 19.0f, 19.0f } }; + + layout input0_layout(data_types::f32, format::bfyx, { 1, 1, 5, 4 }); + + topology topology( + input_layout("input", input0_layout), + mutable_data("weights", weights), + convolution("conv", "input", { "weights" }, { 1,1,1,2 })); + + set_values(weights, { 1.0f, 2.0f, 1.0f, 2.0f, 1.0f, 2.0f }); + program prog(engine, topology, build_options()); + network network0(prog, 0); + network network1(prog, 1); + + auto input0 = engine.allocate_memory(input0_layout); + auto input1 = engine.allocate_memory(input0_layout); + set_values(input0, { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 2.0f, 2.0f, 3.0f, 4.0f, 6.0f, 3.0f, 3.0f, 3.0f, 5.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }); + set_values(input1, { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 2.0f, 2.0f, 3.0f, 4.0f, 6.0f, 3.0f, 3.0f, 3.0f, 5.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }); + + network0.set_input_data("input", input0); + network1.set_input_data("input", input1); + + auto outputs0 = network0.execute(); + auto outputs1 = network1.execute(); + EXPECT_EQ(outputs0.size(), size_t(1)); + EXPECT_EQ(outputs1.size(), size_t(1)); + EXPECT_EQ(outputs0.begin()->first, "conv"); + EXPECT_EQ(outputs1.begin()->first, "conv"); + + auto output_memory0 = outputs0.at("conv").get_memory(); + auto output_memory1 = outputs1.at("conv").get_memory(); + auto output_layout = output_memory0->get_layout(); + cldnn::mem_lock output_ptr0(output_memory0, get_test_stream()); + cldnn::mem_lock output_ptr1(output_memory1, get_test_stream()); + + auto wmem0 = network0.get_output_memory("weights"); + auto wmem1 = network1.get_output_memory("weights"); + + // check that each stream has unique weights data + ASSERT_NE(wmem0, wmem1); + + // check that initial memory is reused by the primary stream + ASSERT_EQ(wmem0, weights); + + int y_size = output_layout.size.spatial[1]; + int x_size = output_layout.size.spatial[0]; + int f_size = output_layout.size.feature[0]; + int b_size = output_layout.size.batch[0]; + EXPECT_EQ(output_layout.format, format::bfyx); + EXPECT_EQ(y_size, 2); + EXPECT_EQ(x_size, 3); + EXPECT_EQ(f_size, 1); + EXPECT_EQ(b_size, 1); + for (int y = 0; y < y_size; ++y) { + for (int x = 0; x < x_size; ++x) { + EXPECT_EQ(output_vec[y][x], output_ptr0[y * x_size + x]); + EXPECT_EQ(output_vec[y][x], output_ptr1[y * x_size + x]); + } + } +} diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/strided_slice_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/strided_slice_gpu_test.cpp index 2634f03962a2c3..aa4ec3aa0d3c32 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/strided_slice_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/strided_slice_gpu_test.cpp @@ -3,17 +3,15 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include "api/strided_slice.hpp" -#include -#include -#include -#include "test_utils/test_utils.h" -#include + +#include "test_utils.h" + +#include +#include +#include using namespace cldnn; -using namespace tests; +using namespace ::tests; TEST(strided_slice_gpu_f32_i32, test_2x2x2x2_full) { // Input (BFYX): 2x2x2x2 @@ -22,11 +20,11 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x2_full) { // Stride (BFYX): 1x1x1x1 // Output (BFYX): 2x2x2x2 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto begin = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto begin = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, @@ -43,7 +41,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x2_full) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -63,7 +61,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x2_full) { std::vector answers = { 0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(output_ptr.size(), answers.size()); for (size_t i = 0; i < answers.size(); ++i) @@ -79,11 +77,11 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x2_full) { // Stride (BFYX): 1x1x1x1 // Output (BFYX): 2x2x2x2 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto begin = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto begin = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, @@ -100,7 +98,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x2_full) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -120,7 +118,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x2_full) { std::vector answers = { 0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(output_ptr.size(), answers.size()); for (size_t i = 0; i < answers.size(); ++i) @@ -136,11 +134,11 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x2_ignore) { // Stride (BFYX): 1x1x1x1 // Output (BFYX): 2x2x2x2 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto begin = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto begin = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, @@ -157,7 +155,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x2_ignore) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -179,7 +177,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x2_ignore) { 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(output_ptr.size(), answers.size()); for (size_t i = 0; i < answers.size(); ++i) @@ -195,11 +193,11 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x2_ignore) { // Stride (BFYX): 1x1x1x1 // Output (BFYX): 2x2x2x2 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto begin = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto begin = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, @@ -216,7 +214,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x2_ignore) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -238,7 +236,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x2_ignore) { 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(output_ptr.size(), answers.size()); for (size_t i = 0; i < answers.size(); ++i) @@ -254,11 +252,11 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x2_single) { // Stride (BFYX): 1x1x1x1 // Output (BFYX): 1x1x1x1 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto begin = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto begin = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, @@ -275,7 +273,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x2_single) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -294,7 +292,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x2_single) { std::vector answers = { 15.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(output_ptr.size(), answers.size()); for (size_t i = 0; i < answers.size(); ++i) @@ -310,11 +308,11 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x2_single) { // Stride (BFYX): 1x1x1x1 // Output (BFYX): 1x1x1x1 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto begin = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto begin = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, @@ -331,7 +329,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x2_single) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -350,7 +348,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x2_single) { std::vector answers = { 15.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(output_ptr.size(), answers.size()); for (size_t i = 0; i < answers.size(); ++i) @@ -366,11 +364,11 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x4x3_stride) { // Stride (BFYX): 1x1x2x1 // Output (BFYX): 2x2x2x3 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 3, 4 } }); - auto begin = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 3, 4 } }); + auto begin = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); set_values(input, { 0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, @@ -391,7 +389,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x4x3_stride) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -413,7 +411,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x4x3_stride) { 24.f, 25.f, 26.f, 30.f, 31.f, 32.f, 36.f, 37.f, 38.f, 42.f, 43.f, 44.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(output_ptr.size(), answers.size()); for (size_t i = 0; i < answers.size(); ++i) @@ -429,11 +427,11 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x4x3_stride) { // Stride (BFYX): 1x1x2x1 // Output (BFYX): 2x2x2x3 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 3, 4 } }); - auto begin = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 3, 4 } }); + auto begin = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); set_values(input, { 0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, @@ -454,7 +452,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x4x3_stride) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -476,7 +474,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x4x3_stride) { 24.f, 25.f, 26.f, 30.f, 31.f, 32.f, 36.f, 37.f, 38.f, 42.f, 43.f, 44.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(output_ptr.size(), answers.size()); for (size_t i = 0; i < answers.size(); ++i) @@ -492,11 +490,11 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x4x4_part_stride) { // Stride (BFYX): 1x1x1x2 // Output (BFYX): 1x2x4x2 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 4, 4 } }); - auto begin = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 4, 4 } }); + auto begin = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, @@ -530,7 +528,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x4x4_part_stride) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -559,7 +557,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x4x4_part_stride) { 61.0f, 63.0f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(output_ptr.size(), answers.size()); for (size_t i = 0; i < answers.size(); ++i) @@ -575,11 +573,11 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x4x4_part_stride) { // Stride (BFYX): 1x1x1x2 // Output (BFYX): 1x2x4x2 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 4, 4 } }); - auto begin = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 4, 4 } }); + auto begin = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, @@ -613,7 +611,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x4x4_part_stride) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -642,7 +640,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x4x4_part_stride) { 61.0f, 63.0f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(output_ptr.size(), answers.size()); for (size_t i = 0; i < answers.size(); ++i) @@ -656,11 +654,11 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x4x1_new_axis_mask) { // New_axis_mask: 1 // Output (BFYX): 1x2x2x4 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 4 } }); - auto begin = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 4 } }); + auto begin = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, @@ -677,7 +675,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x4x1_new_axis_mask) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -699,7 +697,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x4x1_new_axis_mask) { 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < answers.size(); ++i) { @@ -712,11 +710,11 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x4x1_new_axis_mask) { // New_axis_mask: 1 // Output (BFYX): 1x2x2x4 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 4 } }); - auto begin = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 4 } }); + auto begin = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, @@ -733,7 +731,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x4x1_new_axis_mask) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -755,7 +753,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x4x1_new_axis_mask) { 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < answers.size(); ++i) { @@ -768,11 +766,11 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x1x1_new_axis_mask_2) { // New_axis_mask: 101 // Output (BFYX): 1x2x1x2 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); - auto begin = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); + auto begin = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f @@ -788,7 +786,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x1x1_new_axis_mask_2) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -809,7 +807,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x1x1_new_axis_mask_2) { 0.0f, 1.0f, 2.0f, 3.0f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < answers.size(); ++i) { @@ -822,11 +820,11 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x1x1_new_axis_mask_2) { // New_axis_mask: 101 // Output (BFYX): 1x2x1x2 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); - auto begin = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); + auto begin = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f @@ -842,7 +840,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x1x1_new_axis_mask_2) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -863,7 +861,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x1x1_new_axis_mask_2) { 0.0f, 1.0f, 2.0f, 3.0f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < answers.size(); ++i) { @@ -875,11 +873,11 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x1x1) { // Input (BFYX): 2x2x1x1 // Output (BFYX): 2x2x1x1 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); - auto begin = memory::allocate(engine, { data_types::i32, format::bfyx, { 2, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i32, format::bfyx, { 2, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i32, format::bfyx, { 2, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); + auto begin = engine.allocate_memory({ data_types::i32, format::bfyx, { 2, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i32, format::bfyx, { 2, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i32, format::bfyx, { 2, 1, 1, 1 } }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f @@ -895,7 +893,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x1x1) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -916,7 +914,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x1x1) { 0.0f, 1.0f, 2.0f, 3.0f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < answers.size(); ++i) { @@ -928,11 +926,11 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x1x1) { // Input (BFYX): 2x2x1x1 // Output (BFYX): 2x2x1x1 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); - auto begin = memory::allocate(engine, { data_types::i64, format::bfyx, { 2, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i64, format::bfyx, { 2, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i64, format::bfyx, { 2, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 1, 1 } }); + auto begin = engine.allocate_memory({ data_types::i64, format::bfyx, { 2, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i64, format::bfyx, { 2, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i64, format::bfyx, { 2, 1, 1, 1 } }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f @@ -948,7 +946,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x1x1) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -969,7 +967,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x1x1) { 0.0f, 1.0f, 2.0f, 3.0f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < answers.size(); ++i) { @@ -981,11 +979,11 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x1x1) { // Input (BFZYX): 2x2x2x1x1 // Output (BFZYX): 1x2x2x1x1 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx, { 2, 2, 1, 1, 2 } }); - auto begin = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx, { 2, 2, 1, 1, 2 } }); + auto begin = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f @@ -1001,7 +999,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x1x1) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -1022,7 +1020,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x1x1) { 0.0f, 1.0f, 2.0f, 3.0f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < answers.size(); ++i) { @@ -1034,11 +1032,11 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x1x1) { // Input (BFZYX): 2x2x2x1x1 // Output (BFZYX): 1x2x2x1x1 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx, { 2, 2, 1, 1, 2 } }); - auto begin = memory::allocate(engine, { data_types::i64, format::bfyx, { 3, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i64, format::bfyx, { 3, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i64, format::bfyx, { 3, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx, { 2, 2, 1, 1, 2 } }); + auto begin = engine.allocate_memory({ data_types::i64, format::bfyx, { 3, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i64, format::bfyx, { 3, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i64, format::bfyx, { 3, 1, 1, 1 } }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f @@ -1054,7 +1052,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x1x1) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -1075,7 +1073,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x1x1) { 0.0f, 1.0f, 2.0f, 3.0f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < answers.size(); ++i) { @@ -1087,11 +1085,11 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x1x1_2) { // Input (BFZYX): 2x2x2x1x1 // Output (BFZYX): 2x1x1x1x1 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx, { 2, 2, 1, 1, 2 } }); - auto begin = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx, { 2, 2, 1, 1, 2 } }); + auto begin = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f @@ -1107,7 +1105,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x1x1_2) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -1128,7 +1126,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x1x1_2) { 0.0f, 4.0f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < answers.size(); ++i) { @@ -1140,11 +1138,11 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x1x1_2) { // Input (BFZYX): 2x2x2x1x1 // Output (BFZYX): 2x1x1x1x1 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx, { 2, 2, 1, 1, 2 } }); - auto begin = memory::allocate(engine, { data_types::i64, format::bfyx, { 3, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i64, format::bfyx, { 3, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i64, format::bfyx, { 3, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx, { 2, 2, 1, 1, 2 } }); + auto begin = engine.allocate_memory({ data_types::i64, format::bfyx, { 3, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i64, format::bfyx, { 3, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i64, format::bfyx, { 3, 1, 1, 1 } }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f @@ -1160,7 +1158,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x1x1_2) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -1181,7 +1179,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x1x1_2) { 0.0f, 4.0f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < answers.size(); ++i) { @@ -1196,11 +1194,11 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x2_full_negative_stride) { // Stride (BFYX): -1x1x1x1 // Output (BFYX): 2x2x2x2 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto begin = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto begin = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i32, format::bfyx, { 4, 1, 1, 1 } }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, @@ -1217,7 +1215,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x2_full_negative_stride) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -1237,7 +1235,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x2_full_negative_stride) { std::vector answers = { 12.f, 13.f, 14.f, 15.f, 8.f, 9.f, 10.f, 11.f, 4.f, 5.f, 6.f, 7.f, 0.f, 1.f, 2.f, 3.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(output_ptr.size(), answers.size()); for (size_t i = 0; i < answers.size(); ++i) @@ -1253,11 +1251,11 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x2_full_negative_stride) { // Stride (BFYX): -1x1x1x1 // Output (BFYX): 2x2x2x2 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); - auto begin = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto begin = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i64, format::bfyx, { 4, 1, 1, 1 } }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, @@ -1274,7 +1272,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x2_full_negative_stride) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -1294,7 +1292,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x2_full_negative_stride) { std::vector answers = { 12.f, 13.f, 14.f, 15.f, 8.f, 9.f, 10.f, 11.f, 4.f, 5.f, 6.f, 7.f, 0.f, 1.f, 2.f, 3.f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); ASSERT_EQ(output_ptr.size(), answers.size()); for (size_t i = 0; i < answers.size(); ++i) @@ -1307,11 +1305,11 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x1x1_2_negative_all) { // Input (BFZYX): 2x2x2x1x1 // Output (BFZYX): 2x1x1x1x1 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx, { 2, 2, 1, 1, 2 } }); - auto begin = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx, { 2, 2, 1, 1, 2 } }); + auto begin = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i32, format::bfyx, { 3, 1, 1, 1 } }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f @@ -1327,7 +1325,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x1x1_2_negative_all) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -1348,7 +1346,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x1x1_2_negative_all) { 0.0f, 4.0f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < answers.size(); ++i) { @@ -1360,11 +1358,11 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x1x1_2_negative_all) { // Input (BFZYX): 2x2x2x1x1 // Output (BFZYX): 2x1x1x1x1 - const auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx, { 2, 2, 1, 1, 2 } }); - auto begin = memory::allocate(engine, { data_types::i64, format::bfyx, { 3, 1, 1, 1 } }); - auto end = memory::allocate(engine, { data_types::i64, format::bfyx, { 3, 1, 1, 1 } }); - auto strides = memory::allocate(engine, { data_types::i64, format::bfyx, { 3, 1, 1, 1 } }); + auto& engine = get_test_engine(); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx, { 2, 2, 1, 1, 2 } }); + auto begin = engine.allocate_memory({ data_types::i64, format::bfyx, { 3, 1, 1, 1 } }); + auto end = engine.allocate_memory({ data_types::i64, format::bfyx, { 3, 1, 1, 1 } }); + auto strides = engine.allocate_memory({ data_types::i64, format::bfyx, { 3, 1, 1, 1 } }); set_values(input, { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f @@ -1380,7 +1378,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x1x1_2_negative_all) { }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); @@ -1401,7 +1399,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x1x1_2_negative_all) { 0.0f, 4.0f }; - auto output_ptr = output.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); for (size_t i = 0; i < answers.size(); ++i) { diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/tensor_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/tensor_test.cpp index 22abf3fbc818eb..c7563f4e861c5e 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/tensor_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/tensor_test.cpp @@ -2,8 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include +#include "test_utils.h" TEST(tensor_api, order_new_notation) { diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/tile_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/tile_gpu_test.cpp index b734a9e7b4f666..b80f4eedd6d581 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/tile_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/tile_gpu_test.cpp @@ -3,22 +3,19 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include "api/tile.hpp" -#include -#include -#include -#include "test_utils/test_utils.h" + +#include "test_utils.h" + +#include +#include #include using namespace cldnn; -using namespace tests; +using namespace ::tests; template -void tile_ref(const memory& input, memory& output, tile::tile_axis axis, int num_tiles) +void tile_ref(const memory::ptr input, memory::ptr output, tile::tile_axis axis, int num_tiles) { auto get_sizes = [](const tensor& size, tile::tile_axis axis) -> std::pair { @@ -33,13 +30,13 @@ void tile_ref(const memory& input, memory& output, tile::tile_axis axis, int num } }; - const pointer src = input.pointer(); - pointer dst = output.pointer(); + cldnn::mem_lock src(input, get_test_stream()); + cldnn::mem_lock dst(output, get_test_stream()); const data_t* psrc = src.data(); data_t* pdst = dst.data(); - auto sizes = get_sizes(input.get_layout().size, axis); + auto sizes = get_sizes(input->get_layout().size, axis); int outer_dim = sizes.first; int inner_dim = sizes.second; @@ -58,13 +55,13 @@ void tile_ref(const memory& input, memory& output, tile::tile_axis axis, int num } TEST(tile_gpu, basic_in1x2x2x2_axis_b) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 2, 2 } }); - auto output_ref = memory::allocate(engine, { data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 2, 2 } }); + auto output_ref = engine.allocate_memory({ data_types::f32, format::bfyx, { 2, 2, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(tile("tile", "input", tensor(2, 2, 2, 2))); std::vector input_vec = { 1.f, 0.f, 5.f, 1.5f, @@ -78,22 +75,22 @@ TEST(tile_gpu, basic_in1x2x2x2_axis_b) { auto outputs = network.execute(); auto output = outputs.at("tile").get_memory(); - auto output_ptr = output.pointer(); - auto output_ref_ptr = output_ref.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + cldnn::mem_lock output_ref_ptr(output_ref, get_test_stream()); - for (unsigned int i = 0; i < output_ref.count(); ++i) { + for (unsigned int i = 0; i < output_ref->count(); ++i) { EXPECT_EQ(output_ptr[i], output_ref_ptr[i]) << "Index=" << i; } } TEST(tile_gpu, basic_in1x2x2x2_axis_f) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 2, 2 } }); - auto output_ref = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 4, 2, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 2, 2 } }); + auto output_ref = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 4, 2, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(tile("tile", "input", tensor(1, 4, 2, 2))); std::vector input_vec = { 1.f, 0.f, @@ -110,22 +107,22 @@ TEST(tile_gpu, basic_in1x2x2x2_axis_f) { auto outputs = network.execute(); auto output = outputs.at("tile").get_memory(); - auto output_ptr = output.pointer(); - auto output_ref_ptr = output_ref.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + cldnn::mem_lock output_ref_ptr(output_ref, get_test_stream()); - for (unsigned int i = 0; i < output_ref.count(); ++i) { + for (unsigned int i = 0; i < output_ref->count(); ++i) { EXPECT_EQ(output_ptr[i], output_ref_ptr[i]) << "Index=" << i; } } TEST(tile_gpu, basic_in1x2x2x2_axis_y) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 2, 2 } }); - auto output_ref = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 2, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 2, 2 } }); + auto output_ref = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 2, 4 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(tile("tile", "input", tensor(1, 2, 2, 4))); std::vector input_vec = { 1.f, 0.f, @@ -142,22 +139,22 @@ TEST(tile_gpu, basic_in1x2x2x2_axis_y) { auto outputs = network.execute(); auto output = outputs.at("tile").get_memory(); - auto output_ptr = output.pointer(); - auto output_ref_ptr = output_ref.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + cldnn::mem_lock output_ref_ptr(output_ref, get_test_stream()); - for (unsigned int i = 0; i < output_ref.count(); ++i) { + for (unsigned int i = 0; i < output_ref->count(); ++i) { EXPECT_EQ(output_ptr[i], output_ref_ptr[i]) << "Index=" << i; } } TEST(tile_gpu, basic_in1x2x2x2_axis_x) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 2, 2 } }); - auto output_ref = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 4, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 2, 2 } }); + auto output_ref = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 4, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(tile("tile", "input", tensor(1, 2, 4, 2))); std::vector input_vec = { 1.f, 0.f, @@ -174,22 +171,22 @@ TEST(tile_gpu, basic_in1x2x2x2_axis_x) { auto outputs = network.execute(); auto output = outputs.at("tile").get_memory(); - auto output_ptr = output.pointer(); - auto output_ref_ptr = output_ref.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + cldnn::mem_lock output_ref_ptr(output_ref, get_test_stream()); - for (unsigned int i = 0; i < output_ref.count(); ++i) { + for (unsigned int i = 0; i < output_ref->count(); ++i) { EXPECT_EQ(output_ptr[i], output_ref_ptr[i]) << "Index=" << i; } } TEST(tile_gpu, basic_in1x2x2x2_axis_x_dense) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 1, 2 } }); - auto output_ref = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 2, 4, 2 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 1, 2 } }); + auto output_ref = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 4, 2 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(tile("tile", "input", tensor(1, 2, 4, 2))); std::vector input_vec = { 1.f, 0.f, 5.f, 1.5f}; @@ -202,22 +199,22 @@ TEST(tile_gpu, basic_in1x2x2x2_axis_x_dense) { auto outputs = network.execute(); auto output = outputs.at("tile").get_memory(); - auto output_ptr = output.pointer(); - auto output_ref_ptr = output_ref.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + cldnn::mem_lock output_ref_ptr(output_ref, get_test_stream()); - for (unsigned int i = 0; i < output_ref.count(); ++i) { + for (unsigned int i = 0; i < output_ref->count(); ++i) { EXPECT_EQ(output_ptr[i], output_ref_ptr[i]) << "Index=" << i; } } TEST(tile_gpu, basic_in1x2x2x2_axis_z) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); - auto input = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 1, 2, 2, 2, 2 } }); - auto output_ref = memory::allocate(engine, { data_types::f32, format::bfzyx,{ 1, 2, 2, 2, 4 } }); + auto input = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 1, 2, 2, 2, 2 } }); + auto output_ref = engine.allocate_memory({ data_types::f32, format::bfzyx,{ 1, 2, 2, 2, 4 } }); topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(tile("tile", "input", tensor(1, 2, 2, 2, 4))); std::vector input_vec = { @@ -239,10 +236,10 @@ TEST(tile_gpu, basic_in1x2x2x2_axis_z) { auto outputs = network.execute(); auto output = outputs.at("tile").get_memory(); - auto output_ptr = output.pointer(); - auto output_ref_ptr = output_ref.pointer(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + cldnn::mem_lock output_ref_ptr(output_ref, get_test_stream()); - for (unsigned int i = 0; i < output_ref.count(); ++i) { + for (unsigned int i = 0; i < output_ref->count(); ++i) { EXPECT_EQ(output_ptr[i], output_ref_ptr[i]) << "Index=" << i; } } diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/topology_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/topology_test.cpp index 11e34e2f60158f..42eae68031cb9e 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/topology_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/topology_test.cpp @@ -2,25 +2,23 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include "test_utils/test_utils.h" +#include "test_utils.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include + #include -#include "api/memory.hpp" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include @@ -55,6 +53,7 @@ class topology_test : public ::testing::TestWithParam public: // return false for invalid output_layout virtual bool AddPrimitive(cldnn::topology& topology, cldnn::primitive_id id, cldnn::layout output_layout, std::deque& input_layouts) = 0; + virtual ~topology_layer_type() = default; }; static std::vector> layer_types; static cldnn::topology* CreateTopology(cldnn::layout output_layout, const std::vector generator_vec) @@ -112,7 +111,7 @@ class topology_test : public ::testing::TestWithParam static void AddRandomMemory(cldnn::topology& topology, cldnn::primitive_id id, cldnn::layout layout) { //todo: allocate mem, randomize values by type, add to topology - auto mem_primitive = cldnn::memory::allocate(topology_test::engine, layout); + auto mem_primitive = topology_test::engine.allocate_memory(layout); switch (layout.data_type) { case cldnn::data_types::f32: @@ -368,8 +367,8 @@ class topology_test : public ::testing::TestWithParam EXPECT_NE(topology, nullptr); cldnn::build_options options; options.set_option(cldnn::build_option::optimize_data(true)); - cldnn::engine temp_engine;// using temp_engine since reusing the same one does not free all resources (network build becomes slower and slower) - cldnn::network network(temp_engine, *topology, options); + auto& engine = tests::get_test_engine(); + cldnn::network network(engine, *topology, options); auto outputs = network.execute(); EXPECT_NE(outputs.find(topology_generator::output_layer_id), outputs.end()); @@ -443,11 +442,11 @@ class topology_test : public ::testing::TestWithParam cldnn::layout output_layout; std::vector generator; - static const cldnn::engine& engine; + static cldnn::engine& engine; static std::vector all_output_layouts;//just for tear-down }; -const cldnn::engine& topology_test::engine = tests::get_test_engine(); +cldnn::engine& topology_test::engine = tests::get_test_engine(); std::vector topology_test::all_output_layouts = {}; std::vector> topology_test::topology_generator::layer_types = { diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/trim_to_outputs_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/trim_to_outputs_gpu_test.cpp index bb613fccd13955..94689c2ce4b752 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/trim_to_outputs_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/trim_to_outputs_gpu_test.cpp @@ -4,18 +4,14 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include "api/memory.hpp" -#include -#include "api/concatenation.hpp" -#include -#include -#include -#include -#include "test_utils/test_utils.h" +#include "test_utils.h" + +#include +#include "cldnn/primitives/concatenation.hpp" +#include using namespace cldnn; -using namespace tests; +using namespace ::tests; /* This set of tests has been designed to check the correctness of trim_to_outputs optimization pass @@ -29,14 +25,14 @@ using namespace tests; ---> conv2 (to be eliminated) */ TEST(trim_to_outputs, one_node_to_eliminate_case1) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); build_options build_opt; build_opt.set_option(cldnn::build_option::outputs({ "conv1" })); build_opt.set_option(build_option::optimize_data(false)); // to avoid adding reorders - auto input = memory::allocate(engine, { data_types::f32, format::yxfb, { 1, 1, 1, 1 } }); - auto weights = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); - auto bias = memory::allocate(engine, { data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb, { 1, 1, 1, 1 } }); + auto weights = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); + auto bias = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } }); set_values(input, { 1.1f }); set_values(weights, { 2.1f }); @@ -45,7 +41,7 @@ TEST(trim_to_outputs, one_node_to_eliminate_case1) { std::vector out_data = { 3.91f }; topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("weights", weights)); topology.add(data("bias", bias)); topology.add(cldnn::convolution("conv1", { "input" }, { "weights" }, { "bias" })); @@ -61,7 +57,7 @@ TEST(trim_to_outputs, one_node_to_eliminate_case1) { for (auto& it : outputs) { - auto output_ptr = it.second.get_memory().pointer(); + cldnn::mem_lock output_ptr(it.second.get_memory(), get_test_stream()); for (size_t cntr = 0; cntr < out_data.size(); cntr++) { EXPECT_NEAR(output_ptr[cntr], out_data[cntr], 1e-4); @@ -78,16 +74,16 @@ Network structure: input -> conv1 (output) ---> conv2 (to be eliminated along with its weights and bias) */ TEST(trim_to_outputs, one_node_to_eliminate_case2) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); build_options build_opt; build_opt.set_option(cldnn::build_option::outputs({ "conv1" })); build_opt.set_option(build_option::optimize_data(false)); // to avoid adding reorders - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 1, 1, 1 } }); - auto weights1 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); - auto weights2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); - auto bias1 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); - auto bias2 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 1, 1, 1 } }); + auto weights1 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto weights2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto bias1 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto bias2 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); set_values(input, { 1.1f }); set_values(weights1, { 2.1f }); @@ -98,7 +94,7 @@ TEST(trim_to_outputs, one_node_to_eliminate_case2) { std::vector out_data = { 3.91f }; topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("weights1", weights1)); topology.add(data("bias1", bias1)); topology.add(cldnn::convolution("conv1", { "input" }, { "weights1" }, { "bias1" })); @@ -116,7 +112,7 @@ TEST(trim_to_outputs, one_node_to_eliminate_case2) { for (auto& it : outputs) { - auto output_ptr = it.second.get_memory().pointer(); + cldnn::mem_lock output_ptr(it.second.get_memory(), get_test_stream()); for (size_t cntr = 0; cntr < out_data.size(); cntr++) { @@ -135,16 +131,16 @@ Network structure: input ---> conv1 --- ---> conv4 (output) Convolutions conv2, conv3 should be optimized out along with weights23 shered by conv2 and conv3. */ TEST(trim_to_outputs, two_nodes_to_eliminate_case1) { - const auto& engine = get_test_engine(); + auto& engine = get_test_engine(); build_options build_opt; build_opt.set_option(cldnn::build_option::outputs({ "conv4" })); build_opt.set_option(build_option::optimize_data(false)); // to avoid adding reorders - auto input = memory::allocate(engine, { data_types::f32, format::yxfb,{ 1, 1, 1, 1 } }); - auto weights1 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); - auto weights23 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); - auto weights4 = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); - auto bias = memory::allocate(engine, { data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto input = engine.allocate_memory({ data_types::f32, format::yxfb,{ 1, 1, 1, 1 } }); + auto weights1 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto weights23 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto weights4 = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); + auto bias = engine.allocate_memory({ data_types::f32, format::bfyx,{ 1, 1, 1, 1 } }); set_values(input, { 1.1f }); set_values(weights1, { 2.1f }); @@ -155,7 +151,7 @@ TEST(trim_to_outputs, two_nodes_to_eliminate_case1) { std::vector out_data = { 9.42f }; topology topology; - topology.add(input_layout("input", input.get_layout())); + topology.add(input_layout("input", input->get_layout())); topology.add(data("weights1", weights1)); topology.add(data("bias", bias)); topology.add(cldnn::convolution("conv1", { "input" }, { "weights1" }, { "bias" })); @@ -175,7 +171,7 @@ TEST(trim_to_outputs, two_nodes_to_eliminate_case1) { for (auto& it : outputs) { - auto output_ptr = it.second.get_memory().pointer(); + cldnn::mem_lock output_ptr(it.second.get_memory(), get_test_stream()); for (size_t cntr = 0; cntr < out_data.size(); cntr++) { @@ -184,4 +180,3 @@ TEST(trim_to_outputs, two_nodes_to_eliminate_case1) { EXPECT_EQ(it.first, "conv4"); } } - diff --git a/inference-engine/thirdparty/clDNN/tests/test_utils/instrumentation.cpp b/inference-engine/thirdparty/clDNN/tests/test_utils/instrumentation.cpp deleted file mode 100644 index d8b2c73cc1145a..00000000000000 --- a/inference-engine/thirdparty/clDNN/tests/test_utils/instrumentation.cpp +++ /dev/null @@ -1,386 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "instrumentation.h" - -#include -#include -#include -#include -#include - -namespace instrumentation { - // initalize dumping directory for whole run - const std::string logger::dump_dir = DUMP_DIRECTORY; - - static float convert_half_to_float(cldnn::half_t val) - { - return static_cast(val); - } - - float convert_element(float f) - { - return f; - } - - float convert_element(cldnn::half_t h) - { - return convert_half_to_float(h); - } - - template - void dump_byxf(const cldnn::memory& mem, bool single_batch, cldnn::tensor::value_type batch_id, bool single_feature, cldnn::tensor::value_type feature_id, std::vector> & streams) - { - auto mem_arg = mem.get_layout(); - auto mem_ptr = mem.pointer(); - - unsigned int input_it = 0; - for (cldnn::tensor::value_type b = 0; b < mem_arg.size.batch[0]; b++) - { - for (cldnn::tensor::value_type y = 0; y < mem_arg.size.spatial[1]; y++) - { - for (cldnn::tensor::value_type x = 0; x < mem_arg.size.spatial[0]; x++) - { - for (cldnn::tensor::value_type f = 0; f < mem_arg.size.feature[0]; f++) - { - if ((!single_batch || b == batch_id) && (!single_feature || f == feature_id)) - { - streams[b][f] << convert_element(mem_ptr[input_it]) << " "; - if (x == mem_arg.size.spatial[0] - 1) - { - streams[b][f] << std::endl; - } - } - input_it++; - } - } - } - } - } - - template - void dump_bfyx(const cldnn::memory& mem, bool single_batch, cldnn::tensor::value_type batch_id, bool single_feature, cldnn::tensor::value_type feature_id, std::vector> & streams) - { - auto mem_arg = mem.get_layout(); - auto mem_ptr = mem.pointer(); - - unsigned int input_it = 0; - for (cldnn::tensor::value_type b = 0; b < mem_arg.size.batch[0]; b++) - { - for (cldnn::tensor::value_type f = 0; f < mem_arg.size.feature[0]; f++) - { - for (cldnn::tensor::value_type y = 0; y < mem_arg.size.spatial[1]; y++) - { - for (cldnn::tensor::value_type x = 0; x < mem_arg.size.spatial[0]; x++) - { - if ((!single_batch || b == batch_id) && (!single_feature || f == feature_id)) - { - streams[b][f] << convert_element(mem_ptr[input_it]) << " "; - if (x == mem_arg.size.spatial[0] - 1) - { - streams[b][f] << std::endl; - } - } - input_it++; - } - } - } - } - } - - template - void dump_yxfb(const cldnn::memory& mem, bool single_batch, cldnn::tensor::value_type batch_id, bool single_feature, cldnn::tensor::value_type feature_id, std::vector> & streams) - { - auto mem_arg = mem.get_layout(); - auto mem_ptr = mem.pointer(); - - unsigned int input_it = 0; - for (cldnn::tensor::value_type y = 0; y < mem_arg.size.spatial[1]; y++) - { - for (cldnn::tensor::value_type x = 0; x < mem_arg.size.spatial[0]; x++) - { - for (cldnn::tensor::value_type f = 0; f < mem_arg.size.feature[0]; f++) - { - for (cldnn::tensor::value_type b = 0; b < mem_arg.size.batch[0]; b++) - { - if ((!single_batch || b == batch_id) && (!single_feature || f == feature_id)) - { - streams[b][f] << convert_element(mem_ptr[input_it]) << " "; - if (x == mem_arg.size.spatial[0] - 1) - { - streams[b][f] << std::endl; - } - } - input_it++; - } - } - } - } - } - - template - void dump_xb(const cldnn::memory& mem, bool single_batch, cldnn::tensor::value_type batch_id, std::vector> & streams) - { - auto mem_arg = mem.get_layout(); - auto mem_ptr = mem.pointer(); - - unsigned int input_it = 0; - for (cldnn::tensor::value_type x = 0; x < mem_arg.size.spatial[0]; x++) - { - for (cldnn::tensor::value_type b = 0; b < mem_arg.size.batch[0]; b++) - { - if (!single_batch || b == batch_id) - { - streams[b][0] << convert_element(mem_ptr[input_it]) << std::endl; - } - input_it++; - } - } - } - - template - void dump_bx(const cldnn::memory& mem, bool single_batch, cldnn::tensor::value_type batch_id, std::vector> & streams) - { - auto mem_arg = mem.get_layout(); - auto mem_ptr = mem.pointer(); - - unsigned int input_it = 0; - for (cldnn::tensor::value_type b = 0; b < mem_arg.size.batch[0]; b++) - { - for (cldnn::tensor::value_type x = 0; x < mem_arg.size.spatial[0]; x++) - { - if (!single_batch || b == batch_id) - { - streams[b][0] << convert_element(mem_ptr[input_it]) << std::endl; - } - input_it++; - } - } - } - - template - void dump_yxio(const cldnn::memory& mem, std::stringstream & stream) - { - auto mem_arg = mem.get_layout(); - auto mem_ptr = mem.pointer(); - - auto i_size = mem_arg.size.batch[0]; - auto o_size = mem_arg.size.feature[0]; - auto x_size = mem_arg.size.spatial[0]; - auto y_size = mem_arg.size.spatial[1]; - unsigned int input_it = 0; - for (cldnn::tensor::value_type o = 0; o < o_size; o++) - { - for (cldnn::tensor::value_type i = 0; i < i_size; i++) - { - for (cldnn::tensor::value_type x = 0; x < x_size; x++) - { - for (cldnn::tensor::value_type y = 0; y < y_size; y++) - { - stream<< convert_element(mem_ptr[input_it]) << " "; - input_it++; - } - stream<< std::endl; - } - } - } - } - - template - void dump_oiyx(const cldnn::memory& mem, std::stringstream & stream) - { - auto mem_arg = mem.get_layout(); - auto mem_ptr = mem.pointer(); - - auto i_size = mem_arg.size.batch[0]; - auto o_size = mem_arg.size.feature[0]; - auto x_size = mem_arg.size.spatial[0]; - auto y_size = mem_arg.size.spatial[1]; - unsigned int input_it = 0; - for (cldnn::tensor::value_type x = 0; x < x_size; x++) - { - for (cldnn::tensor::value_type y = 0; y < y_size; y++) - { - for (cldnn::tensor::value_type i = 0; i < i_size; i++) - { - for (cldnn::tensor::value_type o = 0; o < o_size; o++) - { - stream << convert_element(mem_ptr[input_it]) << " "; - input_it++; - } - stream << std::endl; - } - } - } - } - - template - void dump_os_iyx_osv16(const cldnn::memory& mem, std::stringstream & stream) - { - auto mem_arg = mem.get_layout(); - auto mem_ptr = mem.pointer(); - - auto i_size = mem_arg.size.batch[0]; - auto o_size = mem_arg.size.feature[0]; - auto x_size = mem_arg.size.spatial[0]; - auto y_size = mem_arg.size.spatial[1]; - auto weights_size = i_size * o_size * x_size * y_size; //count() also counts feature[1] - int slice_value = 16; - cldnn::tensor::value_type it = 0; - while (it < weights_size) - { - stream << convert_element(mem_ptr[it]) << " "; - it++; - if (it % slice_value == 0) //separate every bsv with a new line - stream << std::endl; - }; - } - - template - void dump_bs_xs_xsv8_bsv8(const cldnn::memory& mem, std::stringstream & stream) - { - auto mem_arg = mem.get_layout(); - auto mem_ptr = mem.pointer(); - - auto i_size = mem_arg.size.batch[0]; //batch = input feature map - auto x_size = mem_arg.size.spatial[0]; // spatial_x = output feature map - auto weights_size = mem_arg.size.count(); - int xsv = 8, bsv = 8; - unsigned int input_it = 0, input_i_it= 0 , input_o_it = 0; - for (cldnn::tensor::value_type it = 0; it < weights_size; it++) - { - stream << convert_element(mem_ptr[input_it]) << " "; - input_i_it++; - if (input_i_it % bsv == 0) //separete every input slice with a new line - { - stream << std::endl; - input_o_it++; - input_i_it = 0; - } - input_it = input_o_it*bsv + input_i_it; - - if (input_it % (xsv*bsv) == 0) // seperate every block (8x8) with a new line - stream << std::endl; - } - } - - template - void dump_bs_x_bsv16(const cldnn::memory& mem, std::stringstream & stream) - { - auto mem_arg = mem.get_layout(); - auto mem_ptr = mem.pointer(); - - auto i_size = mem_arg.size.batch[0]; //batch = input feature map - auto x_size = mem_arg.size.spatial[0]; // spatial_x = output feature map - auto weights_size = mem_arg.size.count(); - int bsv = 16; - cldnn::tensor::value_type it = 0; - while (it < weights_size) - { - stream << convert_element(mem_ptr[it]) << " "; - it++; - if (it % bsv == 0) //separate every bsv with a new line - stream << std::endl; - } - } - - template - void dump(const cldnn::memory& mem, std::stringstream& stream) - { - auto mem_ptr = mem.pointer(); - - auto&& pitches = mem.get_layout().get_pitches(); - auto&& size = mem.get_layout().size; - for (cldnn::tensor::value_type b = 0; b < size.batch[0]; ++b) - { - stream << "============= BATCH " << b << " ============\n\n"; - for (cldnn::tensor::value_type f = 0; f < size.feature[0]; ++f) - { - stream << "feature " << f << ":\n"; - for (cldnn::tensor::value_type y = 0; y < size.spatial[1]; ++y) - { - for (cldnn::tensor::value_type x = 0; x < size.spatial[0]; ++x) - { - unsigned int input_it = b*pitches.batch[0] + f*pitches.feature[0] + y*pitches.spatial[1] + x*pitches.spatial[0]; - stream << convert_element(mem_ptr[input_it]) << " "; - input_it++; - } - stream << '\n'; - } - stream << std::endl; - } - } - } - - template - void dump(const cldnn::memory& mem, std::vector>& dump_strings) - { - auto mem_ptr = mem.pointer(); - std::stringstream stream; - - auto&& pitches = mem.get_layout().get_pitches(); - auto&& size = mem.get_layout().size; - for (cldnn::tensor::value_type b = 0; b < size.batch[0]; ++b) - { - for (cldnn::tensor::value_type f = 0; f < size.feature[0]; ++f) - { - for (cldnn::tensor::value_type y = 0; y < size.spatial[1]; ++y) - { - for (cldnn::tensor::value_type x = 0; x < size.spatial[0]; ++x) - { - unsigned int input_it = b*pitches.batch[0] + f*pitches.feature[0] + y*pitches.spatial[1] + x*pitches.spatial[0]; - stream << convert_element(mem_ptr[input_it]) << " "; - input_it++; - } - stream << std::endl; - dump_strings[b][f] = stream.str(); - } - } - } - } - - void logger::log_memory_to_file(const cldnn::memory& mem, std::string prefix, bool single_batch, cldnn::tensor::value_type batch_id, cldnn::tensor::value_type feature_id) - { - auto batch = mem.get_layout().size.batch[0]; - auto feature = mem.get_layout().size.feature[0]; - auto eng_type = "gpu" ; - std::vector> dump_strings(batch); - for(cldnn::tensor::value_type b = 0; b < batch; b++) - { - dump_strings[b].resize(feature); - } - - if (mem.get_layout().data_type == cldnn::data_types::f32) - dump(mem, dump_strings); - else - dump(mem, dump_strings); - - for (cldnn::tensor::value_type b = 0; b < batch; b++) - for (cldnn::tensor::value_type f = 0; f < feature; f++) - { - if (!single_batch || (b == batch_id && f == feature_id)) - { - std::string filename((dump_dir + "/" + prefix + "_" + eng_type + "_b" + std::to_string(b) + "_f" + std::to_string(f) + ".txt")); - std::ofstream file_stream(filename); - file_stream << dump_strings[b][f]; - file_stream.close(); - } - } - } - - void logger::log_weights_to_file(const cldnn::memory& mem, std::string prefix) - { - std::stringstream stream; - - if (mem.get_layout().data_type == cldnn::data_types::f32) - dump(mem, stream); - else - dump(mem, stream); - - std::string filename((dump_dir + "/" + prefix + ".txt")); - std::ofstream file_stream(filename); - file_stream << stream.str(); - file_stream.close(); - } -} diff --git a/inference-engine/thirdparty/clDNN/tests/test_utils/instrumentation.h b/inference-engine/thirdparty/clDNN/tests/test_utils/instrumentation.h deleted file mode 100644 index 8bb105356320c9..00000000000000 --- a/inference-engine/thirdparty/clDNN/tests/test_utils/instrumentation.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once -#include -#include -#include -#include "api/memory.hpp" - -#define DUMP_DIRECTORY "./" - -namespace instrumentation { - - template - std::string to_string(const std::chrono::duration val) { - namespace ch = std::chrono; - const ch::microseconds us(1); - const ch::milliseconds ms(1); - const ch::seconds s(1); - const std::chrono::duration abs_val(std::abs(val.count())); - - std::ostringstream os; - os << std::setprecision(3) << std::fixed; - if (abs_val > s) os << ch::duration_cast>(val).count() << " s"; - else if (abs_val > ms) os << ch::duration_cast>(val).count() << " ms"; - else if (abs_val > us) os << ch::duration_cast>(val).count() << " us"; - else os << ch::duration_cast(val).count() << " ns"; - return os.str(); - } - - struct logger - { - static void log_memory_to_file(const cldnn::memory&, std::string prefix = "", bool single_batch = false, cldnn::tensor::value_type batch_id = 0, cldnn::tensor::value_type feature_id = 0); - static void log_weights_to_file(const cldnn::memory&, std::string prefix = ""); - private: - static const std::string dump_dir; - }; -} diff --git a/inference-engine/thirdparty/clDNN/tests/test_utils/network_test.h b/inference-engine/thirdparty/clDNN/tests/test_utils/network_test.h index e83e3b50335753..efc9d7b6cbfd41 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_utils/network_test.h +++ b/inference-engine/thirdparty/clDNN/tests/test_utils/network_test.h @@ -7,14 +7,15 @@ #include #include "test_utils/test_utils.h" -#include "api/data.hpp" -#include "api/engine.hpp" -#include "api/fully_connected.hpp" -#include "api/input_layout.hpp" -#include "api/layout.hpp" -#include "api/memory.hpp" -#include "api/primitive.hpp" -#include "api/tensor.hpp" +#include +#include +#include +#include + +#include +#include +#include +#include #include #include @@ -57,7 +58,7 @@ struct typed_comparator { // ===================================================================================================================== // Reference tensor struct reference_tensor { - virtual void compare(cldnn::memory actual) = 0; + virtual void compare(cldnn::memory::ptr actual) = 0; }; template @@ -68,22 +69,23 @@ struct reference_tensor_typed : reference_tensor { using vector_type = VF; reference_tensor_typed(vector_type data) : reference(std::move(data)) {} - void compare(cldnn::memory actual) override { - auto ptr = actual.pointer(); + void compare(cldnn::memory::ptr actual) override { + cldnn::mem_lock ptr(actual, get_test_stream()); + for (size_t bi = 0; bi < reference.size(); ++bi) { auto coords = cldnn::tensor(cldnn::batch(bi), cldnn::feature(0), cldnn::spatial(0, 0, 0, 0)); - size_t offset = actual.get_layout().get_linear_offset(coords); + size_t offset = actual->get_layout().get_linear_offset(coords); auto& ref = reference[bi]; auto& val = ptr[offset]; TYPED_EXPECT_EQ(ref, val) << " at bi=" << bi; } } - void fill_memory(cldnn::memory mem) { - auto ptr = mem.pointer(); + void fill_memory(cldnn::memory::ptr mem) { + cldnn::mem_lock ptr(mem, get_test_stream()); for (size_t bi = 0; bi < reference.size(); ++bi) { auto coords = cldnn::tensor(cldnn::batch(bi), cldnn::feature(0), cldnn::spatial(0, 0, 0, 0)); - size_t offset = mem.get_layout().get_linear_offset(coords); + size_t offset = mem->get_layout().get_linear_offset(coords); ptr[offset] = reference[bi]; } } @@ -100,12 +102,12 @@ struct reference_tensor_typed : reference_tensor { using vector_type = VVF; reference_tensor_typed(vector_type data) : reference(std::move(data)) {} - void compare(cldnn::memory actual) override { - auto ptr = actual.pointer(); + void compare(cldnn::memory::ptr actual) override { + cldnn::mem_lock ptr(actual, get_test_stream()); for (size_t bi = 0; bi < reference.size(); ++bi) { for (size_t fi = 0; fi < reference[0].size(); ++fi) { auto coords = cldnn::tensor(cldnn::batch(bi), cldnn::feature(fi), cldnn::spatial(0, 0, 0, 0)); - size_t offset = actual.get_layout().get_linear_offset(coords); + size_t offset = actual->get_layout().get_linear_offset(coords); auto& ref = reference[bi][fi]; auto& val = ptr[offset]; TYPED_EXPECT_EQ(ref, val) << "at bi=" << bi << " fi=" << fi; @@ -113,12 +115,12 @@ struct reference_tensor_typed : reference_tensor { } } - void fill_memory(cldnn::memory mem) { - auto ptr = mem.pointer(); + void fill_memory(cldnn::memory::ptr mem) { + cldnn::mem_lock ptr(mem, get_test_stream()); for (size_t bi = 0; bi < reference.size(); ++bi) { for (size_t fi = 0; fi < reference[0].size(); ++fi) { auto coords = cldnn::tensor(cldnn::batch(bi), cldnn::feature(fi), cldnn::spatial(0, 0, 0, 0)); - size_t offset = mem.get_layout().get_linear_offset(coords); + size_t offset = mem->get_layout().get_linear_offset(coords); ptr[offset] = reference[bi][fi]; } } @@ -135,14 +137,14 @@ template struct reference_tensor_typed : reference_tensor { using vector_type = VVVVF; reference_tensor_typed(vector_type data) : reference(std::move(data)) {} - void compare(cldnn::memory actual) override { - auto ptr = actual.pointer(); + void compare(cldnn::memory::ptr actual) override { + cldnn::mem_lock ptr(actual, get_test_stream()); for (size_t bi = 0; bi < reference.size(); ++bi) { for (size_t fi = 0; fi < reference[0].size(); ++fi) { for (size_t yi = 0; yi < reference[0][0].size(); ++yi) { for (size_t xi = 0; xi < reference[0][0][0].size(); ++xi) { auto coords = cldnn::tensor(cldnn::batch(bi), cldnn::feature(fi), cldnn::spatial(xi, yi, 0, 0)); - size_t offset = actual.get_layout().get_linear_offset(coords); + size_t offset = actual->get_layout().get_linear_offset(coords); auto& ref = reference[bi][fi][yi][xi]; auto& val = ptr[offset]; TYPED_EXPECT_EQ(ref, val) << "at bi=" << bi << " fi=" << fi << " yi=" << yi << " xi=" << xi; @@ -152,14 +154,14 @@ struct reference_tensor_typed : reference_tensor { } } - void fill_memory(cldnn::memory mem) { - auto ptr = mem.pointer(); + void fill_memory(cldnn::memory::ptr mem) { + cldnn::mem_lock ptr(mem, get_test_stream()); for (size_t bi = 0; bi < reference.size(); ++bi) { for (size_t fi = 0; fi < reference[0].size(); ++fi) { for (size_t yi = 0; yi < reference[0][0].size(); ++yi) { for (size_t xi = 0; xi < reference[0][0][0].size(); ++xi) { auto coords = cldnn::tensor(cldnn::batch(bi), cldnn::feature(fi), cldnn::spatial(xi, yi, 0, 0)); - size_t offset = mem.get_layout().get_linear_offset(coords); + size_t offset = mem->get_layout().get_linear_offset(coords); ptr[offset] = reference[bi][fi][yi][xi]; } } @@ -257,6 +259,7 @@ struct reference_node_interface { virtual reference_tensor& get_reference() = 0; virtual cldnn::primitive_id get_id() = 0; + virtual ~reference_node_interface() = default; }; template @@ -275,7 +278,7 @@ struct reference_node : reference_node_interface { class network_test { public: - explicit network_test(cldnn::engine eng) : eng(eng) {} + explicit network_test(cldnn::engine& eng) : eng(eng) {} template typename reference_node::ptr add_input_layout(cldnn::primitive_id id, @@ -285,7 +288,7 @@ class network_test { auto shape = output.get_shape(); auto lt = cldnn::layout(cldnn::type_to_data_type::value, fmt, shape); topo.add(cldnn::input_layout(id, lt)); - auto mem = cldnn::memory::allocate(eng, lt); + auto mem = eng.allocate_memory(lt); output.fill_memory(mem); inputs.emplace(id, mem); return add_node(id, std::move(output), {}); @@ -298,7 +301,7 @@ class network_test { auto output = reference_tensor_typed(std::move(data)); auto shape = output.get_shape(); auto lt = cldnn::layout(cldnn::type_to_data_type::value, fmt, shape); - auto mem = cldnn::memory::allocate(eng, lt); + auto mem = eng.allocate_memory(lt); output.fill_memory(mem); topo.add(cldnn::data(id, mem)); return add_node(id, std::move(output), {}); @@ -384,10 +387,10 @@ class network_test { return node; } - cldnn::engine eng; + cldnn::engine& eng; cldnn::topology topo; std::map forced_impls; - std::map inputs; + std::map inputs; std::set outputs; }; diff --git a/inference-engine/thirdparty/clDNN/tests/test_utils/test_utils.cpp b/inference-engine/thirdparty/clDNN/tests/test_utils/test_utils.cpp index 86f0cfd7805c21..bfa964350dd7ab 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_utils/test_utils.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_utils/test_utils.cpp @@ -4,415 +4,366 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// -#include "api/memory.hpp" -#include -#include -#include -#include -#include -#include #include "test_utils.h" #include "float16.h" -#include "instrumentation.h" #include using namespace cldnn; -namespace tests -{ - const std::string graph_dump_dir = DUMP_DIRECTORY; +namespace tests { - generic_test::generic_test() : generic_params(std::get<0>(GetParam())), layer_params(std::get<1>(GetParam())), max_ulps_diff_allowed(4), random_values(true), dump_graphs(false), dump_memory(false) - { - } - void generic_test::run_single_test() - { - assert((generic_params->data_type == data_types::f32) || (generic_params->data_type == data_types::f16)); - if (dump_graphs) - { - generic_params->network_build_options.set_option(cldnn::build_option::graph_dumps_dir(DUMP_DIRECTORY)); - } - topology topology; - topology.add_primitive(layer_params); +generic_test::generic_test() + : generic_params(std::get<0>(GetParam())) + , layer_params(std::get<1>(GetParam())) + , max_ulps_diff_allowed(4) + , random_values(true) { } - std::vector input_mems; - std::vector input_layouts_names = {}; +void generic_test::run_single_test() { + assert((generic_params->data_type == data_types::f32) || (generic_params->data_type == data_types::f16)); + topology topology; + topology.add_primitive(layer_params); - size_t multipler = 0; - for (size_t i = 0 ; i < generic_params->input_layouts.size() ; i++) - { - input_mems.push_back( memory::allocate(engine, generic_params->input_layouts[i]) ); + std::vector input_mems; + std::vector input_layouts_names = {}; - if (random_values) - { - if (generic_params->data_type == data_types::f32) - { - tests::set_random_values(input_mems[i], true, 7, 10); - } - else - { - tests::set_random_values(input_mems[i], true, 5, 10); - } + size_t multipler = 0; + for (size_t i = 0 ; i < generic_params->input_layouts.size() ; i++) { + input_mems.push_back( engine.allocate_memory(generic_params->input_layouts[i]) ); + + if (random_values) { + if (generic_params->data_type == data_types::f32) { + tests::set_random_values(input_mems[i], true, 7, 10); + } else { + tests::set_random_values(input_mems[i], true, 5, 10); } - else - { - size_t size = generic_params->input_layouts[i].size.batch[0] * generic_params->input_layouts[i].size.feature[0]; + } else { + size_t size = generic_params->input_layouts[i].size.batch[0] * generic_params->input_layouts[i].size.feature[0]; - if (generic_params->data_type == data_types::f32) - { - std::vector values; - for (size_t j = 1; j <= size; j++) - { - values.push_back(static_cast(multipler + j)); - } - tests::set_values_per_batch_and_feature(input_mems[i], values); - multipler = values.size(); + if (generic_params->data_type == data_types::f32) { + std::vector values; + for (size_t j = 1; j <= size; j++) { + values.push_back(static_cast(multipler + j)); } - else - { - std::vector values; - for (size_t j = 1; j <= size; j++) - { - values.push_back(FLOAT16(static_cast(multipler + j))); - } - tests::set_values_per_batch_and_feature(input_mems[i], values); - multipler = values.size(); + tests::set_values_per_batch_and_feature(input_mems[i], values); + multipler = values.size(); + } else { + std::vector values; + for (size_t j = 1; j <= size; j++) { + values.push_back(FLOAT16(static_cast(multipler + j))); } - } - std::string input_name = "input" + std::to_string(i); - if ( (i == 0) && generic_params->network_build_options.get()->enabled() ) - { - // Add reorder after the first input in case of optimize data flag since it might change the input layout. - input_name = "input0_init"; - } - - // First input is provided to the network as input_layout. - // Other inputs are provided as input_layout if optimize data flag is off. Otherwise they are provided as data. - if ( (i == 0) || !generic_params->network_build_options.get()->enabled()) - { - topology.add(input_layout(input_name, input_mems[i].get_layout())); - input_layouts_names.push_back(input_name); - } - else - { - topology.add(data(input_name, input_mems[i])); - } - - if (!is_format_supported(generic_params->fmt)) - { - ASSERT_THROW(network bad(engine, topology), std::exception); - return; + tests::set_values_per_batch_and_feature(input_mems[i], values); + multipler = values.size(); } } - - if (generic_params->network_build_options.get()->enabled()) - { + std::string input_name = "input" + std::to_string(i); + if ((i == 0) && generic_params->network_build_options.get()->enabled()) { // Add reorder after the first input in case of optimize data flag since it might change the input layout. - topology.add(reorder("input0", "input0_init", input_mems[0].get_layout())); + input_name = "input0_init"; } - if (layer_params->input[0] == "reorder0") - { - // Add reorder layer with output padding as input to the tested layer. - topology.add(reorder("reorder0", "input0", input_mems[0].get_layout().with_padding(padding{ { 0, 0, 1, 3 },{ 0, 0, 5, 2 } }))); + // First input is provided to the network as input_layout. + // Other inputs are provided as input_layout if optimize data flag is off. Otherwise they are provided as data. + if ((i == 0) || !generic_params->network_build_options.get()->enabled()) { + topology.add(input_layout(input_name, input_mems[i]->get_layout())); + input_layouts_names.push_back(input_name); + } else { + topology.add(data(input_name, input_mems[i])); + } + + if (!is_format_supported(generic_params->fmt)) { + ASSERT_THROW(network bad(engine, topology), std::exception); + return; } + } - prepare_input_for_test(input_mems); + if (generic_params->network_build_options.get()->enabled()) { + // Add reorder after the first input in case of optimize data flag since it might change the input layout. + topology.add(reorder("input0", "input0_init", input_mems[0]->get_layout())); + } - network network(engine, topology, generic_params->network_build_options); + if (layer_params->input[0] == "reorder0") { + // Add reorder layer with output padding as input to the tested layer. + topology.add(reorder("reorder0", "input0", input_mems[0]->get_layout().with_padding(padding{ { 0, 0, 1, 3 },{ 0, 0, 5, 2 } }))); + } - for (size_t i = 0 ; i < input_layouts_names.size() ; i++) - { - network.set_input_data(input_layouts_names[i], input_mems[i]); - } + prepare_input_for_test(input_mems); - auto outputs = network.execute(); - EXPECT_EQ(outputs.size(), size_t(1)); + network network(engine, topology, generic_params->network_build_options); - auto output = outputs.begin()->second.get_memory(); + for (size_t i = 0 ; i < input_layouts_names.size() ; i++) { + network.set_input_data(input_layouts_names[i], input_mems[i]); + } - auto output_ref = generate_reference(input_mems); + auto outputs = network.execute(); + EXPECT_EQ(outputs.size(), size_t(1)); + auto output = outputs.begin()->second.get_memory(); - if (dump_memory) - { - std::string prefix = test_info.name(); - for (size_t i = 0; i < generic_params->input_layouts.size(); i++) - { - ::instrumentation::logger::log_memory_to_file(input_mems[i], prefix + "input" + std::to_string(i)); - } - for (size_t i = 0; i < outputs.size(); i++) - { - ::instrumentation::logger::log_memory_to_file(output, prefix + "output" + std::to_string(i)); - } - } + auto output_ref = generate_reference(input_mems); - if (output.get_layout().data_type == data_types::f32) - { - compare_buffers(output, output_ref); - } - else - { - compare_buffers(output, output_ref); - } + if (output->get_layout().data_type == data_types::f32) { + compare_buffers(output, output_ref); + } else { + compare_buffers(output, output_ref); } +} - template - void generic_test::compare_buffers(const memory& out, const memory& ref) - { - auto out_layout = out.get_layout(); - auto ref_layout = ref.get_layout(); +template +void generic_test::compare_buffers(const memory::ptr out, const memory::ptr ref) { + auto out_layout = out->get_layout(); + auto ref_layout = ref->get_layout(); - EXPECT_EQ(out_layout.size, ref_layout.size); - EXPECT_EQ(out_layout.data_type, ref_layout.data_type); - EXPECT_EQ(get_expected_output_tensor(), out_layout.size); - EXPECT_EQ(out_layout.get_linear_size(), ref_layout.get_linear_size()); - EXPECT_EQ(out_layout.data_padding, ref_layout.data_padding); + EXPECT_EQ(out_layout.size, ref_layout.size); + EXPECT_EQ(out_layout.data_type, ref_layout.data_type); + EXPECT_EQ(get_expected_output_tensor(), out_layout.size); + EXPECT_EQ(out_layout.get_linear_size(), ref_layout.get_linear_size()); + EXPECT_EQ(out_layout.data_padding, ref_layout.data_padding); - auto output_size = out_layout.size; + auto output_size = out_layout.size; - int batch_size = output_size.batch[0]; - int feature_size = output_size.feature[0]; - int y_size = output_size.spatial[1]; - int x_size = output_size.spatial[0]; + int batch_size = output_size.batch[0]; + int feature_size = output_size.feature[0]; + int y_size = output_size.spatial[1]; + int x_size = output_size.spatial[0]; - auto res_data = out.pointer(); - auto ref_data = ref.pointer(); + mem_lock res_data(out, get_test_stream()); + mem_lock ref_data(ref, get_test_stream()); - const auto out_desc = get_linear_memory_desc(out_layout); - const auto ref_desc = get_linear_memory_desc(ref_layout); + const auto out_desc = get_linear_memory_desc(out_layout); + const auto ref_desc = get_linear_memory_desc(ref_layout); - for (int b = 0; b < batch_size; b++) - { - for (int f = 0; f < feature_size; f++) - { - for (int y = 0; y < y_size; y++) - { - for (int x = 0; x < x_size; x++) - { - size_t res_index = get_linear_index(out_layout, b, f, y, x, out_desc); - size_t ref_index = get_linear_index(ref_layout, b, f, y, x, ref_desc); + for (int b = 0; b < batch_size; b++) { + for (int f = 0; f < feature_size; f++) { + for (int y = 0; y < y_size; y++) { + for (int x = 0; x < x_size; x++) { + size_t res_index = get_linear_index(out_layout, b, f, y, x, out_desc); + size_t ref_index = get_linear_index(ref_layout, b, f, y, x, ref_desc); - EXPECT_TRUE(floating_point_equal(res_data[res_index], ref_data[ref_index], max_ulps_diff_allowed)) - << "Expected " << (float)res_data[res_index] << " to be almost equal (within " << max_ulps_diff_allowed << " ULP's) to " << (float)ref_data[ref_index] - << " (ref index = " << ref_index << ", B " << b << ", F "<< f << ", Y " << y << ", X " << x << ")!"; + EXPECT_TRUE(floating_point_equal(res_data[res_index], ref_data[ref_index], max_ulps_diff_allowed)) + << "Expected " << (float)res_data[res_index] << " to be almost equal (within " + << max_ulps_diff_allowed << " ULP's) to " << (float)ref_data[ref_index] + << " (ref index = " << ref_index << ", B " << b << ", F "<< f << ", Y " << y << ", X " << x << ")!"; - if (HasFailure()) - { - return; - } + if (HasFailure()) { + return; } } } } } +} - static size_t calc_offfset(const layout & layout, const pitches& p) - { - auto lower_padding = layout.data_padding.lower_size(); - if (layout.format == format::bfzyx) { - return - p.b * lower_padding.batch[0] + - p.f * lower_padding.feature[0] + - p.z * lower_padding.spatial[2] + - p.y * lower_padding.spatial[1] + - p.x * lower_padding.spatial[0]; - } - else { - return - p.b * lower_padding.batch[0] + - p.f * lower_padding.feature[0] + - p.y * lower_padding.spatial[1] + - p.x * lower_padding.spatial[0]; - } +static size_t calc_offfset(const layout & layout, const pitches& p) { + auto lower_padding = layout.data_padding.lower_size(); + if (layout.format == format::bfzyx) { + return + p.b * lower_padding.batch[0] + + p.f * lower_padding.feature[0] + + p.z * lower_padding.spatial[2] + + p.y * lower_padding.spatial[1] + + p.x * lower_padding.spatial[0]; + } else { + return + p.b * lower_padding.batch[0] + + p.f * lower_padding.feature[0] + + p.y * lower_padding.spatial[1] + + p.x * lower_padding.spatial[0]; } +} - memory_desc generic_test::get_linear_memory_desc(const layout & layout) - { - pitches p; +memory_desc generic_test::get_linear_memory_desc(const layout & layout) { + pitches p; - switch (layout.format) - { - case format::bfyx: - { - p.x = 1; - p.y = layout.get_buffer_size().sizes(format::bfyx)[3] * p.x; - p.f = layout.get_buffer_size().sizes(format::bfyx)[2] * p.y; - p.b = layout.get_buffer_size().sizes(format::bfyx)[1] * p.f; - break; - } - case format::yxfb: - { - p.b = 1; - p.f = layout.get_buffer_size().sizes(format::yxfb)[3] * p.b; - p.x = layout.get_buffer_size().sizes(format::yxfb)[2] * p.f; - p.y = layout.get_buffer_size().sizes(format::yxfb)[1] * p.x; - break; - } - case format::fyxb: - { - p.b = 1; - p.x = layout.get_buffer_size().sizes(format::fyxb)[3] * p.b; - p.y = layout.get_buffer_size().sizes(format::fyxb)[2] * p.x; - p.f = layout.get_buffer_size().sizes(format::fyxb)[1] * p.y; - break; - } - case format::byxf: - { - p.f = 1; - p.x = layout.get_buffer_size().sizes(format::byxf)[3] * p.f; - p.y = layout.get_buffer_size().sizes(format::byxf)[2] * p.x; - p.b = layout.get_buffer_size().sizes(format::byxf)[1] * p.y; - break; - } - case format::bfzyx: - { - p.x = 1; - p.y = layout.get_buffer_size().sizes(format::bfzyx)[4] * p.x; - p.z = layout.get_buffer_size().sizes(format::bfzyx)[3] * p.y; - p.f = layout.get_buffer_size().sizes(format::bfzyx)[2] * p.z; - p.b = layout.get_buffer_size().sizes(format::bfzyx)[1] * p.f; - break; - } - default: - { - throw std::runtime_error("Format not supported yet."); - } + switch (layout.format) { + case format::bfyx: { + p.x = 1; + p.y = layout.get_buffer_size().sizes(format::bfyx)[3] * p.x; + p.f = layout.get_buffer_size().sizes(format::bfyx)[2] * p.y; + p.b = layout.get_buffer_size().sizes(format::bfyx)[1] * p.f; + break; + } + case format::yxfb: { + p.b = 1; + p.f = layout.get_buffer_size().sizes(format::yxfb)[3] * p.b; + p.x = layout.get_buffer_size().sizes(format::yxfb)[2] * p.f; + p.y = layout.get_buffer_size().sizes(format::yxfb)[1] * p.x; + break; + } + case format::fyxb: { + p.b = 1; + p.x = layout.get_buffer_size().sizes(format::fyxb)[3] * p.b; + p.y = layout.get_buffer_size().sizes(format::fyxb)[2] * p.x; + p.f = layout.get_buffer_size().sizes(format::fyxb)[1] * p.y; + break; + } + case format::byxf: { + p.f = 1; + p.x = layout.get_buffer_size().sizes(format::byxf)[3] * p.f; + p.y = layout.get_buffer_size().sizes(format::byxf)[2] * p.x; + p.b = layout.get_buffer_size().sizes(format::byxf)[1] * p.y; + break; + } + case format::bfzyx: { + p.x = 1; + p.y = layout.get_buffer_size().sizes(format::bfzyx)[4] * p.x; + p.z = layout.get_buffer_size().sizes(format::bfzyx)[3] * p.y; + p.f = layout.get_buffer_size().sizes(format::bfzyx)[2] * p.z; + p.b = layout.get_buffer_size().sizes(format::bfzyx)[1] * p.f; + break; + } + default: { + throw std::runtime_error("Format not supported yet."); } - - return{ p, calc_offfset(layout, p) }; } - size_t generic_test::get_linear_index(const layout&, size_t b, size_t f, size_t y, size_t x, const memory_desc& desc) - { - return - desc.offset + - b*desc.pitch.b + - f*desc.pitch.f + - y*desc.pitch.y + - x*desc.pitch.x; - } + return {p, calc_offfset(layout, p)}; +} - size_t generic_test::get_linear_index(const layout&, size_t b, size_t f, size_t z, size_t y, size_t x, const memory_desc& desc) - { - return - desc.offset + - b*desc.pitch.b + - f*desc.pitch.f + - z*desc.pitch.z + - y*desc.pitch.y + - x*desc.pitch.x; - } +size_t generic_test::get_linear_index(const layout&, size_t b, size_t f, size_t y, size_t x, const memory_desc& desc) +{ + return + desc.offset + + b*desc.pitch.b + + f*desc.pitch.f + + y*desc.pitch.y + + x*desc.pitch.x; +} - size_t generic_test::get_linear_index_with_broadcast(const layout& in_layout, size_t b, size_t f, size_t y, size_t x, const memory_desc& desc) - { - return - desc.offset + - (b % in_layout.size.batch[0]) * desc.pitch.b + - (f % in_layout.size.feature[0]) * desc.pitch.f + - (y % in_layout.size.spatial[1]) * desc.pitch.y + - (x % in_layout.size.spatial[0]) * desc.pitch.x; - } +size_t generic_test::get_linear_index(const layout&, size_t b, size_t f, size_t z, size_t y, size_t x, const memory_desc& desc) +{ + return + desc.offset + + b*desc.pitch.b + + f*desc.pitch.f + + z*desc.pitch.z + + y*desc.pitch.y + + x*desc.pitch.x; +} - //Default implementation. Should be overridden in derived class otherwise. - cldnn::tensor generic_test::get_expected_output_tensor() - { - return generic_params->input_layouts[0].size; - } +size_t generic_test::get_linear_index_with_broadcast(const layout& in_layout, size_t b, size_t f, size_t y, size_t x, const memory_desc& desc) +{ + return + desc.offset + + (b % in_layout.size.batch[0]) * desc.pitch.b + + (f % in_layout.size.feature[0]) * desc.pitch.f + + (y % in_layout.size.spatial[1]) * desc.pitch.y + + (x % in_layout.size.spatial[0]) * desc.pitch.x; +} - std::vector> generic_test::generate_generic_test_params(std::vector>& all_generic_params) - { - // , { format::yx,{ 531,777 } } , { format::yx,{ 4096,1980 } } , - //{ format::bfyx,{ 1,1,1,1 } } , { format::bfyx,{ 1,1,2,2 } } , { format::yx,{ 3,3 } } , { format::yx,{ 4,4 } } , { format::bfyx,{ 1,1,5,5 } } , { format::yx,{ 6,6 } } , { format::yx,{ 7,7 } } , - //{ format::yx,{ 8,8 } } , { format::yx,{ 9,9 } } , { format::yx,{ 10,10 } } , { format::yx,{ 11,11 } } , { format::yx,{ 12,12 } } , { format::yx,{ 13,13 } } , - //{ format::yx,{ 14,14 } } , { format::yx,{ 15,15 } } , { format::yx,{ 16,16 } } }; +//Default implementation. Should be overridden in derived class otherwise. +cldnn::tensor generic_test::get_expected_output_tensor() +{ + return generic_params->input_layouts[0].size; +} - auto data_types = test_data_types(); +std::vector> generic_test::generate_generic_test_params(std::vector>& all_generic_params) +{ + // , { format::yx,{ 531,777 } } , { format::yx,{ 4096,1980 } } , + //{ format::bfyx,{ 1,1,1,1 } } , { format::bfyx,{ 1,1,2,2 } } , { format::yx,{ 3,3 } } , { format::yx,{ 4,4 } } , { format::bfyx,{ 1,1,5,5 } } , { format::yx,{ 6,6 } } , { format::yx,{ 7,7 } } , + //{ format::yx,{ 8,8 } } , { format::yx,{ 9,9 } } , { format::yx,{ 10,10 } } , { format::yx,{ 11,11 } } , { format::yx,{ 12,12 } } , { format::yx,{ 13,13 } } , + //{ format::yx,{ 14,14 } } , { format::yx,{ 15,15 } } , { format::yx,{ 16,16 } } }; + + auto data_types = test_data_types(); - for (cldnn::data_types data_type : data_types) + for (cldnn::data_types data_type : data_types) + { + for (cldnn::format fmt : test_input_formats) { - for (cldnn::format fmt : test_input_formats) + for (int batch_size : test_batch_sizes) { - for (int batch_size : test_batch_sizes) + for (int feature_size : test_feature_sizes) { - for (int feature_size : test_feature_sizes) + for (tensor input_size : test_input_sizes) { - for (tensor input_size : test_input_sizes) - { - all_generic_params.emplace_back(new test_params(data_type, fmt, batch_size, feature_size, input_size)); - } + all_generic_params.emplace_back(new test_params(data_type, fmt, batch_size, feature_size, input_size)); } } } } - - return all_generic_params; } - const cldnn::engine & get_test_engine() - { - static const cldnn::engine engine; - return engine; - } + return all_generic_params; +} - const std::string test_dump::name() const - { - std::string temp = name_str; - std::replace(temp.begin(), temp.end(), '/', '_'); - return temp; +cldnn::engine_configuration get_test_engine_config() { + const bool enable_profiling = false; + const cldnn::queue_types queue_type = cldnn::queue_types::out_of_order; + std::string sources_dumps_dir = ""; + priority_mode_types priority_mode = priority_mode_types::disabled; + throttle_mode_types throttle_mode = throttle_mode_types::disabled; + bool use_memory_pool = true; + bool use_unified_shared_memory = true; + return engine_configuration(enable_profiling, queue_type, sources_dumps_dir, priority_mode, throttle_mode, use_memory_pool, use_unified_shared_memory); +} + +std::shared_ptr create_test_engine() { + return cldnn::engine::create(engine_types::ocl, runtime_types::ocl, get_test_engine_config()); +} + +cldnn::engine& get_test_engine() { + static std::shared_ptr test_engine = nullptr; + if (!test_engine) { + test_engine = create_test_engine(); } + return *test_engine; +} - const std::string test_dump::test_case_name() const - { - size_t pos = test_case_name_str.find("/"); - if (pos > test_case_name_str.length()) - { - pos = 0; - } - std::string temp = test_case_name_str.substr(pos); - return temp; +cldnn::stream& get_test_stream() { + static std::shared_ptr test_stream = nullptr; + if (!test_stream) + test_stream = get_test_engine().create_stream(); + return *test_stream; +} + +const std::string test_dump::name() const { + std::string temp = name_str; + std::replace(temp.begin(), temp.end(), '/', '_'); + return temp; +} + +const std::string test_dump::test_case_name() const { + size_t pos = test_case_name_str.find("/"); + if (pos > test_case_name_str.length()) { + pos = 0; } + std::string temp = test_case_name_str.substr(pos); + return temp; +} - std::string test_params::print_tensor(cldnn::tensor t) - { - std::stringstream str; - for (size_t i = 0; i < t.sizes(format::bfyx).size(); i++) - { - str << t.sizes(format::bfyx)[i] << " "; - } - str << "]"; - return str.str(); +std::string test_params::print_tensor(cldnn::tensor t) { + std::stringstream str; + for (size_t i = 0; i < t.sizes(format::bfyx).size(); i++) { + str << t.sizes(format::bfyx)[i] << " "; } + str << "]"; + return str.str(); +} - std::string test_params::print() - { - std::stringstream str; - str << "Data type: " << data_type_traits::name(data_type) << std::endl; +std::string test_params::print() { + std::stringstream str; + str << "Data type: " << data_type_traits::name(data_type) << std::endl; - for (int j = 0 ; j < (int)input_layouts.size(); j++) - { - const cldnn::tensor& t = input_layouts[j].size; + for (int j = 0 ; j < (int)input_layouts.size(); j++) { + const cldnn::tensor& t = input_layouts[j].size; - str << "Input " << j << ": " << print_tensor(t) << std::endl; - } - return str.str(); + str << "Input " << j << ": " << print_tensor(t) << std::endl; } + return str.str(); +} - std::vector generic_test::test_data_types() - { - std::vector result; - result.push_back(cldnn::data_types::f32); +std::vector generic_test::test_data_types() { + std::vector result; + result.push_back(cldnn::data_types::f32); - if(get_test_engine().get_info().supports_fp16) - { - result.push_back(cldnn::data_types::f16); - } - return result; + if (get_test_engine().get_device_info().supports_fp16) { + result.push_back(cldnn::data_types::f16); } + return result; +} - std::vector generic_test::test_input_formats = { cldnn::format::bfyx , cldnn::format::yxfb, cldnn::format::fyxb, cldnn::format::byxf }; - std::vector generic_test::test_batch_sizes = { 1, 2 };// 4, 8, 16}; - std::vector generic_test::test_feature_sizes = { 1, 2 };// , 3, 15}; - std::vector generic_test::test_input_sizes = { { 1, 1, 100, 100 } ,{ 1, 1, 277, 277 } ,{ 1, 1, 400, 600 } }; +std::vector generic_test::test_input_formats = { cldnn::format::bfyx , cldnn::format::yxfb, cldnn::format::fyxb, cldnn::format::byxf }; +std::vector generic_test::test_batch_sizes = { 1, 2 };// 4, 8, 16}; +std::vector generic_test::test_feature_sizes = { 1, 2 };// , 3, 15}; +std::vector generic_test::test_input_sizes = { { 1, 1, 100, 100 } ,{ 1, 1, 277, 277 } ,{ 1, 1, 400, 600 } }; -} +} // namespace tests diff --git a/inference-engine/thirdparty/clDNN/tests/test_utils/test_utils.h b/inference-engine/thirdparty/clDNN/tests/test_utils/test_utils.h index 436df5abb1e34e..bfe6cfc17988cc 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_utils/test_utils.h +++ b/inference-engine/thirdparty/clDNN/tests/test_utils/test_utils.h @@ -6,35 +6,49 @@ #pragma once -#include "api/memory.hpp" -#include "api/tensor.hpp" -#include "api/program.hpp" -#include "api/network.hpp" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include "float16.h" +#include "random_gen.h" +#include "uniform_quantized_real_distribution.hpp" +#include + #include #include #include #include #include -#include -#include -#include "float16.h" -#include "random_gen.h" -#include "api/concatenation.hpp" -#include "api/lrn.hpp" -#include "api/roi_pooling.hpp" -#include "api/scale.hpp" -#include "api/softmax.hpp" -#include "api/reorder.hpp" -#include "api/normalize.hpp" -#include "api/convolution.hpp" -#include "api/activation.hpp" -#include "api/pooling.hpp" - #include #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) namespace tests { + +std::shared_ptr create_test_engine(); +cldnn::engine& get_test_engine(); +cldnn::stream& get_test_stream(); + #define USE_RANDOM_SEED 0 #if USE_RANDOM_SEED std::random_device rnd_device; @@ -228,12 +242,12 @@ VVVVVVF generate_random_6d(size_t a, size_t b, size_t c, size_t d, size_t e, return v; } -template void set_value(const cldnn::pointer& ptr, uint32_t index, T value) { ptr[index] = value; } -template T get_value(const cldnn::pointer& ptr, uint32_t index) { return ptr[index]; } +template void set_value(T* ptr, uint32_t index, T value) { ptr[index] = value; } +template T get_value(T* ptr, uint32_t index) { return ptr[index]; } template -void set_values(const cldnn::memory& mem, std::initializer_list args ){ - auto ptr = mem.pointer(); +void set_values(cldnn::memory::ptr mem, std::initializer_list args) { + cldnn::mem_lock ptr(mem, get_test_stream()); auto it = ptr.begin(); for(auto x : args) @@ -241,8 +255,8 @@ void set_values(const cldnn::memory& mem, std::initializer_list args ){ } template -void set_values(const cldnn::memory& mem, std::vector args) { - auto ptr = mem.pointer(); +void set_values(cldnn::memory::ptr mem, std::vector args) { + cldnn::mem_lock ptr(mem, get_test_stream()); auto it = ptr.begin(); for (auto x : args) @@ -250,19 +264,14 @@ void set_values(const cldnn::memory& mem, std::vector args) { } template -void set_values_per_batch_and_feature(const cldnn::memory& mem, std::vector args) -{ - auto mem_ptr = mem.pointer(); - auto&& pitches = mem.get_layout().get_pitches(); - auto&& size = mem.get_layout().size; - for (cldnn::tensor::value_type b = 0; b < size.batch[0]; ++b) - { - for (cldnn::tensor::value_type f = 0; f < size.feature[0]; ++f) - { - for (cldnn::tensor::value_type y = 0; y < size.spatial[1]; ++y) - { - for (cldnn::tensor::value_type x = 0; x < size.spatial[0]; ++x) - { +void set_values_per_batch_and_feature(cldnn::memory::ptr mem, std::vector args) { + cldnn::mem_lock mem_ptr(mem, get_test_stream()); + auto&& pitches = mem->get_layout().get_pitches(); + auto&& size = mem->get_layout().size; + for (cldnn::tensor::value_type b = 0; b < size.batch[0]; ++b) { + for (cldnn::tensor::value_type f = 0; f < size.feature[0]; ++f) { + for (cldnn::tensor::value_type y = 0; y < size.spatial[1]; ++y) { + for (cldnn::tensor::value_type x = 0; x < size.spatial[0]; ++x) { unsigned int input_it = b*pitches.batch[0] + f*pitches.feature[0] + y*pitches.spatial[1] + x*pitches.spatial[0]; mem_ptr[input_it] = args[b*size.feature[0] + f]; } @@ -274,42 +283,37 @@ void set_values_per_batch_and_feature(const cldnn::memory& mem, std::vector a template::value || std::is_same::value>::type* = nullptr> -void set_random_values(const cldnn::memory& mem, bool sign = false, unsigned significand_bit = 8, unsigned scale = 1) +void set_random_values(cldnn::memory::ptr mem, bool sign = false, unsigned significand_bit = 8, unsigned scale = 1) { - auto ptr = mem.pointer(); + cldnn::mem_lock ptr(mem, get_test_stream()); std::mt19937 gen; - for (auto it = ptr.begin(); it != ptr.end(); ++it) - { + for (auto it = ptr.begin(); it != ptr.end(); ++it) { *it = rnd_generators::gen_number(gen, significand_bit, sign, false, scale); } } template::value>::type* = nullptr> -void set_random_values(const cldnn::memory& mem) +void set_random_values(cldnn::memory::ptr mem) { - auto ptr = mem.pointer(); + cldnn::mem_lock ptr(mem, get_test_stream()); std::mt19937 gen; static std::uniform_int_distribution uid(std::numeric_limits::min(), std::numeric_limits::max()); - for (auto it = ptr.begin(); it != ptr.end(); ++it) - { + for (auto it = ptr.begin(); it != ptr.end(); ++it) { *it = uid(gen); } } // Tries to construct a network, checking if an expected error appears -inline void check_exception_massage(const cldnn::engine& engine, cldnn::topology& topology, std::string msg_to_find) -{ +inline void check_exception_massage(cldnn::engine& engine, cldnn::topology& topology, std::string msg_to_find) { try { cldnn::network(engine, topology); - } - catch (std::exception & exc) { + } catch (std::exception & exc) { std::string msg(exc.what()); if (msg.find(msg_to_find) != std::string::npos) { throw; - } - else { + } else { printf("%s\n", exc.what()); } } @@ -372,20 +376,15 @@ inline bool floating_point_equal(float x, float y, int max_ulps_diff = 4) { } } -class test_params -{ +class test_params { public: - test_params() : - fmt(cldnn::format::bfyx) - { - } + test_params() : fmt(cldnn::format::bfyx) { } test_params(cldnn::data_types dt, cldnn::format input_format, int32_t batch_size, int32_t feature_size, cldnn::tensor input_size, cldnn::build_options const& options = cldnn::build_options()) : data_type(dt), fmt(input_format), - network_build_options(options) - { + network_build_options(options) { cldnn::tensor t = cldnn::tensor(batch_size, feature_size, input_size.spatial[0], input_size.spatial[1] ); input_layouts.push_back( cldnn::layout(dt, fmt, t) ); } @@ -402,38 +401,32 @@ class test_params static std::string print_tensor(cldnn::tensor tensor); }; -struct pitches -{ +struct pitches { size_t b, f, y, x, z; }; -struct memory_desc -{ +struct memory_desc { pitches pitch; size_t offset; }; -const cldnn::engine & get_test_engine(); - -struct test_dump -{ +struct test_dump { const std::string name() const; const std::string test_case_name() const; + private: const std::string test_case_name_str = ::testing::UnitTest::GetInstance()->current_test_info()->test_case_name(); const std::string name_str = ::testing::UnitTest::GetInstance()->current_test_info()->name(); }; -class generic_test : public ::testing::TestWithParam, std::shared_ptr>> -{ - +class generic_test : public ::testing::TestWithParam, std::shared_ptr>> { public: generic_test(); void run_single_test(); template - void compare_buffers(const cldnn::memory& out, const cldnn::memory& ref); + void compare_buffers(const cldnn::memory::ptr out, const cldnn::memory::ptr ref); static size_t get_linear_index(const cldnn::layout & layout, size_t b, size_t f, size_t y, size_t x, const memory_desc& desc); static size_t get_linear_index(const cldnn::layout & layout, size_t b, size_t f, size_t z, size_t y, size_t x, const memory_desc& desc); @@ -456,7 +449,7 @@ class generic_test : public ::testing::TestWithParam generic_params; test_dump test_info; std::shared_ptr layer_params; @@ -464,10 +457,10 @@ class generic_test : public ::testing::TestWithParam& inputs) = 0; + virtual cldnn::memory::ptr generate_reference(const std::vector& inputs) = 0; // Allows the test to override the random input data that the framework generates - virtual void prepare_input_for_test(std::vector& /*inputs*/) { } + virtual void prepare_input_for_test(std::vector& /*inputs*/) { } static std::vector test_data_types(); static std::vector test_input_formats; @@ -480,8 +473,7 @@ class generic_test : public ::testing::TestWithParam, std::shared_ptr>& t, ::std::ostream* os) -{ +inline void PrintTupleTo(const std::tuple, std::shared_ptr>& t, ::std::ostream* os) { std::stringstream str; auto test_param = std::get<0>(t); @@ -495,13 +487,10 @@ inline void PrintTupleTo(const std::tuple, std::sha //TODO: do layers not have param dumping? we could consider adding it - if (primitive->type == cldnn::concatenation::type_id()) - { + if (primitive->type == cldnn::concatenation::type_id()) { auto dc = std::static_pointer_cast(primitive); (void)dc; - } - else if(primitive->type == cldnn::lrn::type_id()) - { + } else if(primitive->type == cldnn::lrn::type_id()) { auto lrn = std::static_pointer_cast(primitive); std::string norm_region = (lrn->norm_region == cldnn::lrn_norm_region_across_channel) ? "across channel" : "within channel"; str << "Norm region: " << norm_region @@ -509,9 +498,7 @@ inline void PrintTupleTo(const std::tuple, std::sha << " Alpha: " << lrn->alpha << " Beta: " << lrn->beta << " K: " << lrn->k; - } - else if(primitive->type == cldnn::roi_pooling::type_id()) - { + } else if(primitive->type == cldnn::roi_pooling::type_id()) { auto p = std::static_pointer_cast(primitive); str << "Pooling mode: " << (p->mode == cldnn::pooling_mode::max ? "MAX" : "AVG") << " Pooled width: " << p->pooled_width @@ -520,51 +507,35 @@ inline void PrintTupleTo(const std::tuple, std::sha << " Spatial bins x: " << p->spatial_bins_x << " Spatial bins y: " << p->spatial_bins_y << " Output dim: " << p->output_dim; - } - else if(primitive->type == cldnn::scale::type_id()) - { + } else if(primitive->type == cldnn::scale::type_id()) { auto s = std::static_pointer_cast(primitive); (void)s; - } - else if(primitive->type == cldnn::softmax::type_id()) - { + } else if(primitive->type == cldnn::softmax::type_id()) { auto sm = std::static_pointer_cast(primitive); (void)sm; - } - else if (primitive->type == cldnn::reorder::type_id()) - { + } else if (primitive->type == cldnn::reorder::type_id()) { auto reorder = std::static_pointer_cast(primitive); str << "Output data type: " << cldnn::data_type_traits::name(*reorder->output_data_type) << " Mean: " << reorder->mean << "Subtract per feature: " << "TODO" /*std::vector subtract_per_feature*/; - } - else if (primitive->type == cldnn::normalize::type_id()) - { + } else if (primitive->type == cldnn::normalize::type_id()) { auto normalize = std::static_pointer_cast(primitive); std::string norm_region = normalize->across_spatial ? "across_spatial" : "within_spatial"; str << "Norm region: " << norm_region << " Epsilon: " << normalize->epsilon << " Scale input id: " << normalize->scale_input; - } - else if (primitive->type == cldnn::convolution::type_id()) - { + } else if (primitive->type == cldnn::convolution::type_id()) { auto convolution = std::static_pointer_cast(primitive); str << "Stride x: " << convolution->stride.spatial[0] << " Stride y: " << convolution->stride.spatial[1] << " Dilation x: " << convolution->dilation.spatial[0] << " Dilation y: " << convolution->dilation.spatial[1] << " Input offset x: " << convolution->input_offset.spatial[0] << " Input offset y: " << convolution->input_offset.spatial[1]; - } - else if (primitive->type == cldnn::activation::type_id()) - { + } else if (primitive->type == cldnn::activation::type_id()) { auto activation = std::static_pointer_cast(primitive); str << "Negative slope: " << activation->additional_params.a << " Negative slope input id: " << activation->additional_params_input; - } - else if (primitive->type == cldnn::pooling::type_id()) - { + } else if (primitive->type == cldnn::pooling::type_id()) { auto pooling = std::static_pointer_cast(primitive); std::string pooling_mode = (pooling->mode == cldnn::pooling_mode::max) ? "max" : "average"; str << "Pooling mode: " << pooling_mode << " Input offset x: " << pooling->input_offset.spatial[0] << " Input offset y: " << pooling->input_offset.spatial[1] << " Stride x: " << pooling->stride.spatial[0] << " Stride y: " << pooling->stride.spatial[1] << " Size x: " << pooling->size.spatial[0] << " Size y: " << pooling->size.spatial[1]; - } - else - { + } else { throw std::runtime_error("Not implemented yet for this primitive."); } @@ -577,130 +548,130 @@ T div_up(const T a, const U b) { return (a + b - 1) / b; } -inline void print_bin_blob(cldnn::memory& mem, std::string name) -{ - auto&& size = mem.get_layout().size; - - std::cerr << name; - std::cerr << " shape: "; - std::cerr << size.batch[0] << " "; - std::cerr << size.feature[0] << " "; - std::cerr << size.spatial[1] << " "; - std::cerr << size.spatial[0] << " "; - std::cerr << "(" << size.batch[0] * size.feature[0] * size.spatial[1] * size.spatial[0] << ")" << std::endl; - - auto mem_ptr = mem.pointer(); - - bool packed_ic = mem.get_layout().format == cldnn::format::b_fs_yx_32fp ? 1 : 0; - int B = size.batch[0]; - int C = size.feature[0]; - int H = size.spatial[1]; - int W = size.spatial[0]; - - for (cldnn::tensor::value_type b = 0; b < B; ++b) - { - for (cldnn::tensor::value_type f = 0; f < C; ++f) - { - for (cldnn::tensor::value_type y = 0; y < H; ++y) - { - for (cldnn::tensor::value_type x = 0; x < W; ++x) - { - if (!packed_ic) - { - size_t input_it = b * C*H*W + f * W*H + y * W + x; - size_t elem = input_it / 32; - size_t bit = input_it % 32; - std::cerr << ((mem_ptr[elem] & (1 << bit)) >> bit) << " "; - } - else - { - size_t input_it = b * (C / 32)*W*H + (f / 32)*W*H + y * W + x; - size_t bit = f % 32; - std::cerr << ((mem_ptr[input_it] & (1 << bit)) >> bit) << " "; - } - } - std::cerr << std::endl; - } - std::cerr << std::endl; - } - std::cerr << "==============" << std::endl; - } -} - -inline void print_bin_blob_packed(cldnn::memory& mem, std::string name) -{ - auto&& size = mem.get_layout().size; - - std::cerr << name; - std::cerr << " shape: "; - std::cerr << size.batch[0] << " "; - std::cerr << size.feature[0] << " "; - std::cerr << size.spatial[1] << " "; - std::cerr << size.spatial[0] << " "; - std::cerr << "(" << size.batch[0] * size.feature[0] * size.spatial[1] * size.spatial[0] << ")" << std::endl; - - auto mem_ptr = mem.pointer(); - - int B = size.batch[0]; - int C = size.feature[0]; - int H = size.spatial[1]; - int W = size.spatial[0]; - - for (cldnn::tensor::value_type b = 0; b < B; ++b) - { - for (cldnn::tensor::value_type f = 0; f < div_up(C, 32); ++f) - { - for (cldnn::tensor::value_type y = 0; y < H; ++y) - { - for (cldnn::tensor::value_type x = 0; x < W; ++x) - { - size_t input_it = b * div_up(C, 32)*W*H + f * W*H + y * W + x; - std::cerr << mem_ptr[input_it] << " "; - } - std::cerr << std::endl; - } - std::cerr << std::endl; - } - std::cerr << "==============" << std::endl; - } -} +// inline void print_bin_blob(cldnn::memory& mem, std::string name) +// { +// auto&& size = mem.get_layout().size; + +// std::cerr << name; +// std::cerr << " shape: "; +// std::cerr << size.batch[0] << " "; +// std::cerr << size.feature[0] << " "; +// std::cerr << size.spatial[1] << " "; +// std::cerr << size.spatial[0] << " "; +// std::cerr << "(" << size.batch[0] * size.feature[0] * size.spatial[1] * size.spatial[0] << ")" << std::endl; + +// auto mem_ptr = mem.pointer(); + +// bool packed_ic = mem.get_layout().format == cldnn::format::b_fs_yx_32fp ? 1 : 0; +// int B = size.batch[0]; +// int C = size.feature[0]; +// int H = size.spatial[1]; +// int W = size.spatial[0]; + +// for (cldnn::tensor::value_type b = 0; b < B; ++b) +// { +// for (cldnn::tensor::value_type f = 0; f < C; ++f) +// { +// for (cldnn::tensor::value_type y = 0; y < H; ++y) +// { +// for (cldnn::tensor::value_type x = 0; x < W; ++x) +// { +// if (!packed_ic) +// { +// size_t input_it = b * C*H*W + f * W*H + y * W + x; +// size_t elem = input_it / 32; +// size_t bit = input_it % 32; +// std::cerr << ((mem_ptr[elem] & (1 << bit)) >> bit) << " "; +// } +// else +// { +// size_t input_it = b * (C / 32)*W*H + (f / 32)*W*H + y * W + x; +// size_t bit = f % 32; +// std::cerr << ((mem_ptr[input_it] & (1 << bit)) >> bit) << " "; +// } +// } +// std::cerr << std::endl; +// } +// std::cerr << std::endl; +// } +// std::cerr << "==============" << std::endl; +// } +// } + +// inline void print_bin_blob_packed(cldnn::memory& mem, std::string name) +// { +// auto&& size = mem.get_layout().size; + +// std::cerr << name; +// std::cerr << " shape: "; +// std::cerr << size.batch[0] << " "; +// std::cerr << size.feature[0] << " "; +// std::cerr << size.spatial[1] << " "; +// std::cerr << size.spatial[0] << " "; +// std::cerr << "(" << size.batch[0] * size.feature[0] * size.spatial[1] * size.spatial[0] << ")" << std::endl; + +// auto mem_ptr = mem.pointer(); + +// int B = size.batch[0]; +// int C = size.feature[0]; +// int H = size.spatial[1]; +// int W = size.spatial[0]; + +// for (cldnn::tensor::value_type b = 0; b < B; ++b) +// { +// for (cldnn::tensor::value_type f = 0; f < div_up(C, 32); ++f) +// { +// for (cldnn::tensor::value_type y = 0; y < H; ++y) +// { +// for (cldnn::tensor::value_type x = 0; x < W; ++x) +// { +// size_t input_it = b * div_up(C, 32)*W*H + f * W*H + y * W + x; +// std::cerr << mem_ptr[input_it] << " "; +// } +// std::cerr << std::endl; +// } +// std::cerr << std::endl; +// } +// std::cerr << "==============" << std::endl; +// } +// } + +// inline void print_blob(cldnn::memory& mem, std::string name) +// { +// auto&& size = mem.get_layout().size; + +// std::cerr << name; +// std::cerr << " shape: "; +// std::cerr << size.batch[0] << " "; +// std::cerr << size.feature[0] << " "; +// std::cerr << size.spatial[1] << " "; +// std::cerr << size.spatial[0] << " "; +// std::cerr << "(" << size.batch[0] * size.feature[0] * size.spatial[1] * size.spatial[0] << ")" << std::endl; + +// auto mem_ptr = mem.pointer(); + +// int B = size.batch[0]; +// int C = size.feature[0]; +// int H = size.spatial[1]; +// int W = size.spatial[0]; + +// for (cldnn::tensor::value_type b = 0; b < B; ++b) +// { +// for (cldnn::tensor::value_type f = 0; f < C; ++f) +// { +// for (cldnn::tensor::value_type y = 0; y < H; ++y) +// { +// for (cldnn::tensor::value_type x = 0; x < W; ++x) +// { +// size_t input_it = b * C*W*H + f * W*H + y * W + x; +// std::cerr << std::setw(4) << mem_ptr[input_it] << " "; +// } +// std::cerr << std::endl; +// } +// std::cerr << std::endl; +// } +// std::cerr << "==============" << std::endl; +// } +// } -inline void print_blob(cldnn::memory& mem, std::string name) -{ - auto&& size = mem.get_layout().size; - - std::cerr << name; - std::cerr << " shape: "; - std::cerr << size.batch[0] << " "; - std::cerr << size.feature[0] << " "; - std::cerr << size.spatial[1] << " "; - std::cerr << size.spatial[0] << " "; - std::cerr << "(" << size.batch[0] * size.feature[0] * size.spatial[1] * size.spatial[0] << ")" << std::endl; - - auto mem_ptr = mem.pointer(); - - int B = size.batch[0]; - int C = size.feature[0]; - int H = size.spatial[1]; - int W = size.spatial[0]; - - for (cldnn::tensor::value_type b = 0; b < B; ++b) - { - for (cldnn::tensor::value_type f = 0; f < C; ++f) - { - for (cldnn::tensor::value_type y = 0; y < H; ++y) - { - for (cldnn::tensor::value_type x = 0; x < W; ++x) - { - size_t input_it = b * C*W*H + f * W*H + y * W + x; - std::cerr << std::setw(4) << mem_ptr[input_it] << " "; - } - std::cerr << std::endl; - } - std::cerr << std::endl; - } - std::cerr << "==============" << std::endl; - } -} } // namespace tests - diff --git a/inference-engine/thirdparty/clDNN/tests/test_utils/uniform_quantized_real_distribution.hpp b/inference-engine/thirdparty/clDNN/tests/test_utils/uniform_quantized_real_distribution.hpp index ea817fae29e242..464e15db83fa65 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_utils/uniform_quantized_real_distribution.hpp +++ b/inference-engine/thirdparty/clDNN/tests/test_utils/uniform_quantized_real_distribution.hpp @@ -20,7 +20,7 @@ #include #include -namespace cldnn { namespace tests { namespace distributions { +namespace tests { namespace distributions { /// @cond PRIVATE namespace detail @@ -812,7 +812,7 @@ class data_type_mask return os; } - + /// @brief Deserialize from stream. /// @@ -1537,4 +1537,5 @@ class uniform_quantized_real_distribution underlying_dist_type _base_distribution; ///< Base distribution used to generate input numbers. }; -}}} // namespace cldnn { namespace tests { namespace distributions +} // namespace distributions +} // namespace tests diff --git a/inference-engine/thirdparty/clDNN/tests_core_internal/CMakeLists.txt b/inference-engine/thirdparty/clDNN/tests_core_internal/CMakeLists.txt deleted file mode 100644 index 663f50000cc599..00000000000000 --- a/inference-engine/thirdparty/clDNN/tests_core_internal/CMakeLists.txt +++ /dev/null @@ -1,137 +0,0 @@ -# Copyright (C) 2018-2021 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 -# - -# ========================================= Name / Output settings ===================================== - -set(CLDNN_BUILD__PROJ "clDNN_tests_core_internal") -set(CLDNN_BUILD__PROJ_LABEL "${CLDNN_BUILD__PROJ}") -set(CLDNN_BUILD__PROJ_OUTPUT_NAME "${CLDNN_BUILD__PROJ}${CLDNN__OUT_CPU_SUFFIX}") - -# =========================================== Compiler options ========================================= -intel_config_flag_apply_settings(CompilerOptions CMAKE_CXX_FLAGS ALL_PATTERN "" - SET - StandardCxx11 - RttiEnabled - ) - -if (NOT MSVC) - intel_config_flag_apply_settings(CompilerOptions CMAKE_CXX_FLAGS ALL_PATTERN "" - SET_RAW - "-Wno-error=conversion-null" - "-Wno-error=type-limits" - ) -endif () - -find_package(OpenMP) -if (OPENMP_FOUND) - add_definitions(-DOPENMP_FOUND) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") -endif() - -# ================================== Compiler preprocessor definitions ================================= - -# ========================================= Source/Header files ======================================== - -set(__CLDNN_Label__main "") -file(GLOB __CLDNN_Sources__main - "${CMAKE_CURRENT_SOURCE_DIR}/*.h" - "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp" - "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" - ) - -set(__CLDNN_Directory__test_cases "${CMAKE_CURRENT_SOURCE_DIR}/test_cases") -set(__CLDNN_Label__test_cases "test cases") -file(GLOB __CLDNN_Sources__test_cases - "${__CLDNN_Directory__test_cases}/*.h" - "${__CLDNN_Directory__test_cases}/*.hpp" - "${__CLDNN_Directory__test_cases}/*.cpp" - ) - -set(__CLDNN_Directory__test_utils "${CMAKE_CURRENT_SOURCE_DIR}/../tests/test_utils") -set(__CLDNN_Label__test_utils "test utils") -file(GLOB __CLDNN_Sources__test_utils - "${__CLDNN_Directory__test_utils}/*.h" - "${__CLDNN_Directory__test_utils}/*.hpp" - "${__CLDNN_Directory__test_utils}/*.cpp" - ) - -set(__CLDNN_Directory__gtest "${CLDNN__GTEST_DIR}") -set(__CLDNN_Label__gtest "google test framework") -file(GLOB __CLDNN_Sources__gtest - "${__CLDNN_Directory__gtest}/*.cc" - ) - -if(UNIX) - set_source_files_properties(${__CLDNN_Sources__gtest} PROPERTIES - COMPILE_FLAGS "-Wno-undef") -endif() - -set(__CLDNN_AllSources - ${__CLDNN_Sources__main} - ${__CLDNN_Sources__test_cases} - ${__CLDNN_Sources__test_utils} - ${__CLDNN_Sources__gtest} - ) -# Helping with some generators. -set_property(SOURCE ${__CLDNN_Sources__cg_cache} PROPERTY GENERATED TRUE) - - -# =============================================== Filters ============================================== - -source_group("${__CLDNN_Label__main}" FILES ${__CLDNN_Sources__main}) -source_group("${__CLDNN_Label__test_cases}" FILES ${__CLDNN_Sources__test_cases}) -source_group("${__CLDNN_Label__test_utils}" FILES ${__CLDNN_Sources__test_utils}) - -# ===================================== Include/Link directories ======================================= - -include_directories( - "${CLDNN__MAIN_DIR}" - "${CLDNN__MAIN_DIR}/src" - "${CLDNN__MAIN_DIR}/src/include" - "${CLDNN__KERNEL_SELECTOR_DIR}/core" - "${CLDNN__KERNEL_SELECTOR_DIR}/core/common" - "${CLDNN__KERNEL_SELECTOR_DIR}/common" - "${__CLDNN_Directory__test_utils}" - "${CMAKE_CURRENT_SOURCE_DIR}" - ) - -include_directories(SYSTEM - "${CLDNN__GTEST_DIR}") - -# =================================== Link targets and dependencies ==================================== - -# Tests executable. -add_executable("${CLDNN_BUILD__PROJ}" - ${__CLDNN_AllSources} - ) - -if(COMMAND set_ie_threading_interface_for) - set_ie_threading_interface_for("${CLDNN_BUILD__PROJ}") -endif() - -set_property(TARGET "${CLDNN_BUILD__PROJ}" PROPERTY PROJECT_LABEL "${CLDNN_BUILD__PROJ_LABEL}") -set_property(TARGET "${CLDNN_BUILD__PROJ}" PROPERTY OUTPUT_NAME "${CLDNN_BUILD__PROJ_OUTPUT_NAME}") - -# Set library dependencies -target_link_libraries("${CLDNN_BUILD__PROJ}" PRIVATE "${CLDNN_BUILD__PROJ__clDNN}") - -if(WIN32) - target_link_libraries("${CLDNN_BUILD__PROJ}" PRIVATE setupapi) -elseif((NOT ANDROID) AND (UNIX)) - target_link_libraries("${CLDNN_BUILD__PROJ}" PRIVATE pthread) -endif() -target_link_libraries("${CLDNN_BUILD__PROJ}" PRIVATE ${CLDNN__SYSTEM_LINK_LIBRARIES}) - -# =================================== Custom pre- and post-steps ======================================= - -if(CLDNN__RUN_TESTS) - add_custom_command(TARGET "${CLDNN_BUILD__PROJ}" POST_BUILD - WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" - COMMAND "${CLDNN_BUILD__PROJ}" - COMMENT "Executing tests..." - ) -endif() - -# ====================================================================================================== diff --git a/inference-engine/thirdparty/clDNN/tests_core_internal/main.cpp b/inference-engine/thirdparty/clDNN/tests_core_internal/main.cpp deleted file mode 100644 index 7e583e9b068903..00000000000000 --- a/inference-engine/thirdparty/clDNN/tests_core_internal/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "gtest/gtest.h" - -int main(int argc, char* argv[]) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} \ No newline at end of file From b6d7af12ae84653c622b62a46756e5ddd030b523 Mon Sep 17 00:00:00 2001 From: Anna Khakimova Date: Wed, 16 Jun 2021 10:07:46 +0300 Subject: [PATCH 103/178] PP: Color conversion kernels refactoring (#5985) * [PP] POC of vectorised kernels refactoring - base/framework changes * [PP] POC of vectorised kernels refactoring - ChanToPlane implementation * [PP] POC of vectorised kernels refactoring - ChanToPlane, switched order of dispatching to first choose ISA type * [PP] POC of vectorised kernels refactoring - ChanToPlane, moved choose ISA stage to kernel package generation * Preparing * NV12ToRGB kernel refactoring * * I420ToRGB kernel refactoring Co-authored-by: Anton Potapov --- .../ie_preprocess_gapi_kernels_neon.cpp | 31 +- .../ie_preprocess_gapi_kernels_neon.hpp | 29 +- .../ie_preprocess_gapi_kernels_avx2.cpp | 31 +- .../ie_preprocess_gapi_kernels_avx2.hpp | 34 +- .../ie_preprocess_gapi_kernels_avx512.cpp | 31 +- .../ie_preprocess_gapi_kernels_avx512.hpp | 31 +- .../ie_preprocess_gapi_kernels_sse42.cpp | 30 +- .../ie_preprocess_gapi_kernels_sse42.hpp | 30 +- .../ie_preprocess_gapi_kernels.cpp | 579 ++++++++++-------- .../ie_preprocess_gapi_kernels_impl.hpp | 31 + .../ie_preprocess_gapi_kernels_simd_impl.hpp | 134 ++-- 11 files changed, 504 insertions(+), 487 deletions(-) diff --git a/inference-engine/src/preprocessing/arm_neon/ie_preprocess_gapi_kernels_neon.cpp b/inference-engine/src/preprocessing/arm_neon/ie_preprocess_gapi_kernels_neon.cpp index 779db927c32cb5..8290fda25ed8ea 100644 --- a/inference-engine/src/preprocessing/arm_neon/ie_preprocess_gapi_kernels_neon.cpp +++ b/inference-engine/src/preprocessing/arm_neon/ie_preprocess_gapi_kernels_neon.cpp @@ -90,21 +90,6 @@ void splitRow_32FC4(const float in[], float out0[], float out1[], splitRow_32FC4_Impl(in, out0, out1, out2, out3, length); } -void calculate_nv12_to_rgb(const uchar **srcY, - const uchar *srcUV, - uchar **dstRGBx, - int width) { - calculate_nv12_to_rgb_impl(srcY, srcUV, dstRGBx, width); -} - -void calculate_i420_to_rgb(const uchar **srcY, - const uchar *srcU, - const uchar *srcV, - uchar **dstRGBx, - int width) { - calculate_i420_to_rgb_impl(srcY, srcU, srcV, dstRGBx, width); -} - void calcRowArea_8U(uchar dst[], const uchar *src[], const Size& inSz, const Size& outSz, Q0_16 yalpha, const MapperUnit8U &ymap, int xmaxdf, const short xindex[], const Q0_16 xalpha[], @@ -119,14 +104,6 @@ void calcRowArea_32F(float dst[], const float *src[], const Size& inSz, calcRowArea_impl(dst, src, inSz, outSz, yalpha, ymap, xmaxdf, xindex, xalpha, vbuf); } -void copyRow_8U(const uint8_t in[], uint8_t out[], int length) { - copyRow_8U_impl(in, out, length); -} - -void copyRow_32F(const float in[], float out[], int length) { - copyRow_32F_impl(in, out, length); -} - // Resize (bi-linear, 32F) void calcRowLinear_32F(float* dst[], const float* src0[], @@ -708,6 +685,14 @@ void calcRowLinear_8UC1(uint8_t* dst[], } } } // namespace neon + +template void chanToPlaneRowImpl(neon_tag, const uint8_t* in, int chan, int chs, uint8_t* out, const int length); +template void chanToPlaneRowImpl(neon_tag, const float* in, int chan, int chs, float * out, const int length); + +template void nv12ToRgbRowImpl(neon_tag, const uint8_t** y_rows, const uint8_t* uv_row, uint8_t** out_rows, const int buf_width); + +template void i420ToRgbRowImpl(neon_tag, const uint8_t** y_rows, const uint8_t* u_row, + const uint8_t* v_row, uint8_t** out_rows, const int buf_width); } // namespace kernels } // namespace gapi } // namespace InferenceEngine diff --git a/inference-engine/src/preprocessing/arm_neon/ie_preprocess_gapi_kernels_neon.hpp b/inference-engine/src/preprocessing/arm_neon/ie_preprocess_gapi_kernels_neon.hpp index f3b21f73a95b44..4e0b82a62596c7 100644 --- a/inference-engine/src/preprocessing/arm_neon/ie_preprocess_gapi_kernels_neon.hpp +++ b/inference-engine/src/preprocessing/arm_neon/ie_preprocess_gapi_kernels_neon.hpp @@ -167,26 +167,31 @@ void splitRow_32FC4(const float in[], float out3[], int length); -void calculate_nv12_to_rgb(const uchar **srcY, - const uchar *srcUV, - uchar **dstRGBx, - int width); - void calculate_i420_to_rgb(const uchar **srcY, const uchar *srcU, const uchar *srcV, uchar **dstRGBx, int width); -void copyRow_8U(const uint8_t in[], - uint8_t out[], - int length); +} // namespace neon -void copyRow_32F(const float in[], - float out[], - int length); +template +void chanToPlaneRowImpl(isa_tag_t, const T* in, const int chan, const int chs, T* out, const int length); -} // namespace neon +extern template void chanToPlaneRowImpl(neon_tag, const uint8_t* in, const int chan, const int chs, uint8_t* out, const int length); +extern template void chanToPlaneRowImpl(neon_tag, const float* in, const int chan, const int chs, float * out, const int length); + +template +void nv12ToRgbRowImpl(isa_tag_t, const uint8_t** y_rows, const uint8_t* uv_row, uint8_t** out_rows, const int buf_width); + +extern template void nv12ToRgbRowImpl(neon_tag, const uint8_t** y_rows, const uint8_t* uv_row, uint8_t** out_rows, const int buf_width); + +template +void i420ToRgbRowImpl(isa_tag_t, const uint8_t** y_rows, const uint8_t* u_row, + const uint8_t* v_row, uint8_t** out_rows, const int buf_width); + +extern template void i420ToRgbRowImpl(neon_tag, const uint8_t** y_rows, const uint8_t* u_row, + const uint8_t* v_row, uint8_t** out_rows, const int buf_width); } // namespace kernels } // namespace gapi } // namespace InferenceEngine diff --git a/inference-engine/src/preprocessing/cpu_x86_avx2/ie_preprocess_gapi_kernels_avx2.cpp b/inference-engine/src/preprocessing/cpu_x86_avx2/ie_preprocess_gapi_kernels_avx2.cpp index 22d86e10538df4..aefd2e2dfc33ce 100644 --- a/inference-engine/src/preprocessing/cpu_x86_avx2/ie_preprocess_gapi_kernels_avx2.cpp +++ b/inference-engine/src/preprocessing/cpu_x86_avx2/ie_preprocess_gapi_kernels_avx2.cpp @@ -107,21 +107,6 @@ void splitRow_32FC4(const float in[], float out0[], float out1[], splitRow_32FC4_Impl(in, out0, out1, out2, out3, length); } -void calculate_nv12_to_rgb(const uchar **srcY, - const uchar *srcUV, - uchar **dstRGBx, - int width) { - calculate_nv12_to_rgb_impl(srcY, srcUV, dstRGBx, width); -} - -void calculate_i420_to_rgb(const uchar **srcY, - const uchar *srcU, - const uchar *srcV, - uchar **dstRGBx, - int width) { - calculate_i420_to_rgb_impl(srcY, srcU, srcV, dstRGBx, width); -} - void calcRowArea_8U(uchar dst[], const uchar *src[], const Size& inSz, const Size& outSz, Q0_16 yalpha, const MapperUnit8U &ymap, int xmaxdf, const short xindex[], const Q0_16 xalpha[], @@ -555,13 +540,6 @@ void calcRowLinear_8U(C4, std::array, 4> &dst, calcRowLinear_8UC_Impl(dst, src0, src1, alpha, clone, mapsx, beta, tmp, inSz, outSz, lpi); } -void copyRow_8U(const uint8_t in[], uint8_t out[], int length) { - copyRow_8U_impl(in, out, length); -} -void copyRow_32F(const float in[], float out[], int length) { - copyRow_32F_impl(in, out, length); -} - void calcRowLinear_32F(float *dst[], const float *src0[], const float *src1[], @@ -575,6 +553,15 @@ void calcRowLinear_32F(float *dst[], } } // namespace avx + +template void chanToPlaneRowImpl(avx2_tag, const uint8_t* in, const int chan, const int chs, uint8_t* out, const int length); +template void chanToPlaneRowImpl(avx2_tag, const float* in, const int chan, const int chs, float* out, const int length); + +template void nv12ToRgbRowImpl(avx2_tag, const uint8_t** y_rows, const uint8_t* uv_row, + uint8_t** out_rows, const int buf_width); + +template void i420ToRgbRowImpl(avx2_tag, const uint8_t** y_rows, const uint8_t* u_row, + const uint8_t* v_row, uint8_t** out_rows, const int buf_width); } // namespace kernels } // namespace gapi } // namespace InferenceEngine diff --git a/inference-engine/src/preprocessing/cpu_x86_avx2/ie_preprocess_gapi_kernels_avx2.hpp b/inference-engine/src/preprocessing/cpu_x86_avx2/ie_preprocess_gapi_kernels_avx2.hpp index 7226a51ddca1e1..512121b0f3dc76 100644 --- a/inference-engine/src/preprocessing/cpu_x86_avx2/ie_preprocess_gapi_kernels_avx2.hpp +++ b/inference-engine/src/preprocessing/cpu_x86_avx2/ie_preprocess_gapi_kernels_avx2.hpp @@ -181,27 +181,29 @@ void splitRow_32FC4(const float in[], float out2[], float out3[], int length); +} // namespace avx -void calculate_nv12_to_rgb(const uchar **srcY, - const uchar *srcUV, - uchar **dstRGBx, - int width); -void calculate_i420_to_rgb(const uchar **srcY, - const uchar *srcU, - const uchar *srcV, - uchar **dstRGBx, - int width); +template +void chanToPlaneRowImpl(isa_tag_t, const T* in, const int chan, const int chs, T* out, const int length); -void copyRow_8U(const uint8_t in[], - uint8_t out[], - int length); +extern template void chanToPlaneRowImpl(avx2_tag, const uint8_t* in, const int chan, const int chs, uint8_t* out, const int length); +extern template void chanToPlaneRowImpl(avx2_tag, const float* in, const int chan, const int chs, float * out, const int length); -void copyRow_32F(const float in[], - float out[], - int length); +template +void nv12ToRgbRowImpl(isa_tag_t, const uint8_t** y_rows, const uint8_t* uv_row, + uint8_t** out_rows, const int buf_width); -} // namespace avx +extern template void nv12ToRgbRowImpl(avx2_tag, const uint8_t** y_rows, + const uint8_t* uv_row, uint8_t** out_rows, + const int buf_width); + +template +void i420ToRgbRowImpl(isa_tag_t, const uint8_t** y_rows, const uint8_t* u_row, + const uint8_t* v_row, uint8_t** out_rows, const int buf_width); + +extern template void i420ToRgbRowImpl(avx2_tag, const uint8_t** y_rows, const uint8_t* u_row, + const uint8_t* v_row, uint8_t** out_rows, const int buf_width); } // namespace kernels } // namespace gapi } // namespace InferenceEngine diff --git a/inference-engine/src/preprocessing/cpu_x86_avx512/ie_preprocess_gapi_kernels_avx512.cpp b/inference-engine/src/preprocessing/cpu_x86_avx512/ie_preprocess_gapi_kernels_avx512.cpp index 05925d45c195c3..78b74f532d62a6 100644 --- a/inference-engine/src/preprocessing/cpu_x86_avx512/ie_preprocess_gapi_kernels_avx512.cpp +++ b/inference-engine/src/preprocessing/cpu_x86_avx512/ie_preprocess_gapi_kernels_avx512.cpp @@ -101,21 +101,6 @@ void splitRow_32FC4(const float in[], float out0[], float out1[], splitRow_32FC4_Impl(in, out0, out1, out2, out3, length); } -void calculate_nv12_to_rgb(const uchar **srcY, - const uchar *srcUV, - uchar **dstRGBx, - int width) { - calculate_nv12_to_rgb_impl(srcY, srcUV, dstRGBx, width); -} - -void calculate_i420_to_rgb(const uchar **srcY, - const uchar *srcU, - const uchar *srcV, - uchar **dstRGBx, - int width) { - calculate_i420_to_rgb_impl(srcY, srcU, srcV, dstRGBx, width); -} - void calcRowArea_8U(uchar dst[], const uchar *src[], const Size& inSz, const Size& outSz, Q0_16 yalpha, const MapperUnit8U &ymap, int xmaxdf, const short xindex[], const Q0_16 xalpha[], @@ -636,14 +621,6 @@ void calcRowLinear_8U(C4, std::array, 4> &dst, calcRowLinear_8UC_Impl(dst, src0, src1, alpha, clone, mapsx, beta, tmp, inSz, outSz, lpi); } -void copyRow_8U(const uint8_t in[], uint8_t out[], int length) { - copyRow_8U_impl(in, out, length); -} - -void copyRow_32F(const float in[], float out[], int length) { - copyRow_32F_impl(in, out, length); -} - void calcRowLinear_32F(float *dst[], const float *src0[], const float *src1[], @@ -657,6 +634,14 @@ void calcRowLinear_32F(float *dst[], } } // namespace avx512 + +template void chanToPlaneRowImpl(avx512_tag, const uint8_t* in, const int chan, const int chs, uint8_t* out, const int length); +template void chanToPlaneRowImpl(avx512_tag, const float* in, const int chan, const int chs, float* out, const int length); + +template void nv12ToRgbRowImpl(avx512_tag, const uint8_t** y_rows, const uint8_t* uv_row, uint8_t** out_rows, const int buf_width); + +template void i420ToRgbRowImpl(avx512_tag, const uint8_t** y_rows, const uint8_t* u_row, + const uint8_t* v_row, uint8_t** out_rows, const int buf_width); } // namespace kernels } // namespace gapi } // namespace InferenceEngine diff --git a/inference-engine/src/preprocessing/cpu_x86_avx512/ie_preprocess_gapi_kernels_avx512.hpp b/inference-engine/src/preprocessing/cpu_x86_avx512/ie_preprocess_gapi_kernels_avx512.hpp index 2323d9345d4321..8d2778781a35b4 100644 --- a/inference-engine/src/preprocessing/cpu_x86_avx512/ie_preprocess_gapi_kernels_avx512.hpp +++ b/inference-engine/src/preprocessing/cpu_x86_avx512/ie_preprocess_gapi_kernels_avx512.hpp @@ -180,27 +180,26 @@ void splitRow_32FC4(const float in[], float out2[], float out3[], int length); +} // namespace avx512 -void calculate_nv12_to_rgb(const uchar **srcY, - const uchar *srcUV, - uchar **dstRGBx, - int width); -void calculate_i420_to_rgb(const uchar **srcY, - const uchar *srcU, - const uchar *srcV, - uchar **dstRGBx, - int width); +template +void chanToPlaneRowImpl(isa_tag_t, const T* in, const int chan, const int chs, T* out, const int length); -void copyRow_8U(const uint8_t in[], - uint8_t out[], - int length); +extern template void chanToPlaneRowImpl(avx512_tag, const uint8_t* in, const int chan, const int chs, uint8_t* out, const int length); +extern template void chanToPlaneRowImpl(avx512_tag, const float* in, const int chan, const int chs, float* out, const int length); -void copyRow_32F(const float in[], - float out[], - int length); +template +void nv12ToRgbRowImpl(isa_tag_t, const uint8_t** y_rows, const uint8_t* uv_row, uint8_t** out_rows, const int buf_width); -} // namespace avx512 +extern template void nv12ToRgbRowImpl(avx512_tag, const uint8_t** y_rows, const uint8_t* uv_row, uint8_t** out_rows, const int buf_width); + +template +void i420ToRgbRowImpl(isa_tag_t, const uint8_t** y_rows, const uint8_t* u_row, + const uint8_t* v_row, uint8_t** out_rows, const int buf_width); + +extern template void i420ToRgbRowImpl(avx512_tag, const uint8_t** y_rows, const uint8_t* u_row, + const uint8_t* v_row, uint8_t** out_rows, const int buf_width); } // namespace kernels } // namespace gapi } // namespace InferenceEngine diff --git a/inference-engine/src/preprocessing/cpu_x86_sse42/ie_preprocess_gapi_kernels_sse42.cpp b/inference-engine/src/preprocessing/cpu_x86_sse42/ie_preprocess_gapi_kernels_sse42.cpp index 86fb156931ede4..4823e33537141a 100644 --- a/inference-engine/src/preprocessing/cpu_x86_sse42/ie_preprocess_gapi_kernels_sse42.cpp +++ b/inference-engine/src/preprocessing/cpu_x86_sse42/ie_preprocess_gapi_kernels_sse42.cpp @@ -1365,33 +1365,13 @@ void splitRow_32FC4(const float in[], splitRow_32FC4_Impl(in, out0, out1, out2, out3, length); } -void calculate_nv12_to_rgb(const uchar **srcY, - const uchar *srcUV, - uchar **dstRGBx, - int width) { - calculate_nv12_to_rgb_impl(srcY, srcUV, dstRGBx, width); -} - -void calculate_i420_to_rgb(const uchar **srcY, - const uchar *srcU, - const uchar *srcV, - uchar **dstRGBx, - int width) { - calculate_i420_to_rgb_impl(srcY, srcU, srcV, dstRGBx, width); -} +template void chanToPlaneRowImpl(sse42_tag, const uint8_t* in, const int chan, const int chs, uint8_t* out, const int length); +template void chanToPlaneRowImpl(sse42_tag, const float* in, const int chan, const int chs, float* out, const int length); -void copyRow_8U(const uint8_t in[], - uint8_t out[], - int length) { - copyRow_8U_impl(in, out, length); -} - -void copyRow_32F(const float in[], - float out[], - int length) { - copyRow_32F_impl(in, out, length); -} +template void nv12ToRgbRowImpl(sse42_tag, const uint8_t** y_rows, const uint8_t* uv_row, uint8_t** out_rows, const int buf_width); +template void i420ToRgbRowImpl(sse42_tag, const uint8_t** y_rows, const uint8_t* u_row, + const uint8_t* v_row, uint8_t** out_rows, const int buf_width); } // namespace kernels } // namespace gapi } // namespace InferenceEngine diff --git a/inference-engine/src/preprocessing/cpu_x86_sse42/ie_preprocess_gapi_kernels_sse42.hpp b/inference-engine/src/preprocessing/cpu_x86_sse42/ie_preprocess_gapi_kernels_sse42.hpp index 4e1eb471cd5aa9..8726013357e0fa 100644 --- a/inference-engine/src/preprocessing/cpu_x86_sse42/ie_preprocess_gapi_kernels_sse42.hpp +++ b/inference-engine/src/preprocessing/cpu_x86_sse42/ie_preprocess_gapi_kernels_sse42.hpp @@ -180,25 +180,25 @@ void splitRow_32FC4(const float in[], float out3[], int length); -void calculate_nv12_to_rgb(const uchar **srcY, - const uchar *srcUV, - uchar **dstRGBx, - int width); +template +void chanToPlaneRowImpl(isa_tag_t, const T* in, const int chan, const int chs, + T* out, const int length); -void calculate_i420_to_rgb(const uchar **srcY, - const uchar *srcU, - const uchar *srcV, - uchar **dstRGBx, - int width); +extern template void chanToPlaneRowImpl(sse42_tag, const uint8_t* in, const int chan, + const int chs, uint8_t* out, const int length); +extern template void chanToPlaneRowImpl(sse42_tag, const float* in, const int chan, + const int chs, float* out, const int length); +template +void nv12ToRgbRowImpl(isa_tag_t, const uint8_t** y_rows, const uint8_t* uv_row, uint8_t** out_rows, const int buf_width); -void copyRow_8U(const uint8_t in[], - uint8_t out[], - int length); +extern template void nv12ToRgbRowImpl(sse42_tag, const uint8_t** y_rows, const uint8_t* uv_row, uint8_t** out_rows, const int buf_width); -void copyRow_32F(const float in[], - float out[], - int length); +template +void i420ToRgbRowImpl(isa_tag_t, const uint8_t** y_rows, const uint8_t* u_row, + const uint8_t* v_row, uint8_t** out_rows, const int buf_width); +extern template void i420ToRgbRowImpl(sse42_tag, const uint8_t** y_rows, const uint8_t* u_row, + const uint8_t* v_row, uint8_t** out_rows, const int buf_width); } // namespace kernels } // namespace gapi } // namespace InferenceEngine diff --git a/inference-engine/src/preprocessing/ie_preprocess_gapi_kernels.cpp b/inference-engine/src/preprocessing/ie_preprocess_gapi_kernels.cpp index 0dd374bd3ffd4b..4cf4fffd74be9f 100644 --- a/inference-engine/src/preprocessing/ie_preprocess_gapi_kernels.cpp +++ b/inference-engine/src/preprocessing/ie_preprocess_gapi_kernels.cpp @@ -468,15 +468,86 @@ struct type_to_type {}; template struct type_dispatch_impl; +//FIXME: add test for type_dispatch template class typelist, typename... type> struct type_dispatch_impl> { template static result_t dispatch(type_id_t type_id, type_to_id_t&& type_to_id, type_to_value_t&& type_to_value, default_t default_value) { result_t res = default_value; - std::initializer_list ({(type_id == type_to_id(type_to_type{}) ? (res = type_to_value(type_to_type{})), 0 : 0)...}); + bool matched = false; + std::initializer_list ({ + !matched && (type_id == type_to_id(type_to_type{})) ? + (matched = true, res = type_to_value(type_to_type{})), 0 + : 0 + ... + }); return res; } + + template + static result_t dispatch(pred_t&& pred, type_to_value_t&& type_to_value, default_t default_value) { + result_t res = default_value; + + bool matched = false; + std::initializer_list ({ + !matched && pred(type_to_type{}) ? + (matched = true, res = type_to_value(type_to_type{})), 0 + : 0 + ... + }); + return res; + } +}; + +template +struct concat; + +template +using concat_t = typename concat::type; + +template class left_list, typename ... left_types, template class right_list, typename ... right_types> +struct concat, right_list>{ + using type = left_list; +}; + +template< class T, class U > +using is_same_t = typename std::is_same::type; + +template struct if_c_impl; + +template struct if_c_impl { + using type = T; +}; + +template struct if_c_impl { + using type = E; +}; + +template +using if_c = typename if_c_impl::type; + +template +using if_ = typename if_c_impl::type; + +template +struct remove; + +template +using remove_t = typename remove::type; + + +template class list, typename head_t, typename ... types, typename t> +struct remove, t> { + using type = concat_t< + if_, list<>, list>, + remove_t, t> + >; +}; + +template class list, typename t> +struct remove, t> { + using type = list<>; }; } // namespace @@ -490,6 +561,13 @@ result_t type_dispatch(type_id_t type_id, type_to_id_t&& type_to_id, type_to_val std::forward(default_value)); } +template ()(type_to_type> {}))> +result_t type_dispatch(pred_t&& pred, type_to_value_t&& type_to_value, default_t default_value = {}) { + return type_dispatch_impl::template dispatch(std::forward(pred), + std::forward(type_to_value), + std::forward(default_value)); +} namespace { struct cv_type_id { @@ -668,81 +746,47 @@ GAPI_FLUID_KERNEL(FSplit4, Split4, false) { }; //---------------------------------------------------------------------- - -template -static void chanToPlaneRow(const uint8_t* in, int chan, int chs, uint8_t* out, int length) { -// AVX512 implementation of wide universal intrinsics is slower than AVX2. -// It is turned off until the cause isn't found out. -#if 0 - #ifdef HAVE_AVX512 - if (with_cpu_x86_avx512f()) { - if (std::is_same::value && chs == 1) { - avx512::copyRow_8U(in, out, length); - return; - } - - if (std::is_same::value && chs == 1) { - avx512::copyRow_32F(reinterpret_cast(in), - reinterpret_cast(out), - length); - return; - } - } - #endif // HAVE_AVX512 +using isas_set = typelist< +#ifdef HAVE_AVX512 + avx512_tag, #endif +#ifdef HAVE_AVX2 + avx2_tag, +#endif +#ifdef HAVE_SSE + sse42_tag, +#endif +#ifdef HAVE_NEON + neon_tag, +#endif + //scalar "ISA" have to be the last one in the list, + //as the search for supported ISA is performed until first match + scalar_tag>; +#ifdef HAVE_AVX512 +bool is_present(avx512_tag) { return with_cpu_x86_avx512f(); } +#endif // HAVE_AVX512 - #ifdef HAVE_AVX2 - if (with_cpu_x86_avx2()) { - if (std::is_same::value && chs == 1) { - avx::copyRow_8U(in, out, length); - return; - } - - if (std::is_same::value && chs == 1) { - avx::copyRow_32F(reinterpret_cast(in), - reinterpret_cast(out), - length); - return; - } - } - #endif // HAVE_AVX2 - #ifdef HAVE_SSE - if (with_cpu_x86_sse42()) { - if (std::is_same::value && chs == 1) { - copyRow_8U(in, out, length); - return; - } - - if (std::is_same::value && chs == 1) { - copyRow_32F(reinterpret_cast(in), - reinterpret_cast(out), - length); - return; - } - } - #endif // HAVE_SSE +#ifdef HAVE_AVX2 +bool is_present(avx2_tag) { return with_cpu_x86_avx2(); } +#endif // HAVE_AVX2 - #ifdef HAVE_NEON - if (std::is_same::value && chs == 1) { - neon::copyRow_8U(in, out, length); - return; - } +#ifdef HAVE_SSE +bool is_present(sse42_tag) { return with_cpu_x86_sse42(); } +#endif // HAVE_SSE - if (std::is_same::value && chs == 1) { - neon::copyRow_32F(reinterpret_cast(in), - reinterpret_cast(out), - length); - return; - } - #endif // HAVE_NEON +#ifdef HAVE_NEON +bool is_present(neon_tag) { return true; } +#endif // HAVE_NEON - const auto inT = reinterpret_cast(in); - auto outT = reinterpret_cast< T*>(out); +//scalar version of kernels is always available +bool is_present(scalar_tag) { return true; } - for (int x = 0; x < length; x++) { - outT[x] = inT[x*chs + chan]; +struct is_isa_present { + template< typename isa_tag_t> + bool operator()(type_to_type) { + return is_present(isa_tag_t{}); } -} +}; // GAPI_OCV_KERNEL(OCVChanToPlane, ChanToPlane) { // static void run(const cv::Mat &in, int chan, cv::Mat &out) { @@ -774,15 +818,225 @@ static void chanToPlaneRow(const uint8_t* in, int chan, int chs, uint8_t* out, i // } // }; +namespace { + +using chan_to_plane_supported_types = typelist; + +template +void chanToPlaneRowImpl(scalar_tag, const T* in, int chan, int chs, T* out, int length) { + for (int x = 0; x < length; x++) { + out[x] = in[x*chs + chan]; + } +} + +template +struct typed_chan_to_plane_row { + using p_f = void (*)(const uint8_t* in, int chan, int chs, uint8_t* out, int length); + + template + p_f operator()(type_to_type ) { + return [](const uint8_t* in, int chan, int chs, uint8_t* out, int length){ + const auto inT = reinterpret_cast(in); + auto outT = reinterpret_cast< type*>(out); + + chanToPlaneRowImpl(isa_tag_t{}, inT, chan, chs, outT, length); + }; + } +}; +} //namespace + +namespace { + +using nv12_to_rgb_supported_types = typelist; + +void nv12ToRgbRowImpl(scalar_tag, const uint8_t** y_rows, const uint8_t* uv_row, + uint8_t** out_rows, const int buf_width) { + for (int i = 0; i < buf_width; i += 2) { + uint8_t u = uv_row[i]; + uint8_t v = uv_row[i + 1]; + int ruv, guv, buv; + uvToRGBuv(u, v, ruv, guv, buv); + + for (int y = 0; y < 2; y++) { + for (int x = 0; x < 2; x++) { + uint8_t vy = y_rows[y][i + x]; + uint8_t r, g, b; + yRGBuvToRGB(vy, ruv, guv, buv, r, g, b); + + out_rows[y][3 * (i + x)] = r; + out_rows[y][3 * (i + x) + 1] = g; + out_rows[y][3 * (i + x) + 2] = b; + } + } + } +} + +template +struct typed_nv12_to_rgb_row { + using p_f = void (*)(const uint8_t** y_rows, const uint8_t* uv_row, + uint8_t** out_rows, const int buf_width); + + template + p_f operator()(type_to_type) { + return [](const uint8_t** y_rows, const uint8_t* uv_row, + uint8_t** out_rows, const int buf_width) { + const auto inT1 = reinterpret_cast(y_rows); + const auto inT2 = reinterpret_cast(uv_row); + auto outT = reinterpret_cast(out_rows); + + nv12ToRgbRowImpl(isa_tag_t{}, inT1, inT2, outT, buf_width); + }; + } +}; +} // namespace + +namespace { + +using i420_to_rgb_supported_types = typelist; + +static void i420ToRgbRowImpl(scalar_tag, const uint8_t** y_rows, + const uint8_t* u_row, + const uint8_t* v_row, + uint8_t** out_rows, + const int buf_width) { + for (int i = 0; i < buf_width; i += 2) { + uchar u = u_row[i / 2]; + uchar v = v_row[i / 2]; + int ruv, guv, buv; + uvToRGBuv(u, v, ruv, guv, buv); + + for (int y = 0; y < 2; y++) { + for (int x = 0; x < 2; x++) { + uchar vy = y_rows[y][i + x]; + uchar r, g, b; + yRGBuvToRGB(vy, ruv, guv, buv, r, g, b); + + out_rows[y][3 * (i + x)] = r; + out_rows[y][3 * (i + x) + 1] = g; + out_rows[y][3 * (i + x) + 2] = b; + } + } + } +} + +template +struct typed_i420_to_rgb_row { + using p_f = void (*)(const uint8_t** y_rows, const uint8_t* u_row, const uint8_t* v_row, + uint8_t** out_rows, const int buf_width); + + template + p_f operator()(type_to_type) { + return [](const uint8_t** y_rows, const uint8_t* u_row, const uint8_t* v_row, + uint8_t** out_rows, const int buf_width) { + const auto inT1 = reinterpret_cast(y_rows); + const auto inT2 = reinterpret_cast(u_row); + const auto inT3 = reinterpret_cast(v_row); + auto outT = reinterpret_cast(out_rows); + + i420ToRgbRowImpl(isa_tag_t{}, inT1, inT2, inT3, outT, buf_width); + }; + } +}; +} // namespace + +template +struct choose_impl { GAPI_FLUID_KERNEL(FChanToPlane, ChanToPlane, false) { static const int Window = 1; static void run(const cv::gapi::fluid::View& in, int chan, cv::gapi::fluid::Buffer& out) { - const auto rowFunc = (in.meta().depth == CV_8U) ? &chanToPlaneRow : &chanToPlaneRow; + GAPI_DbgAssert(is_cv_type_in_list(out.meta().depth)); + + const auto rowFunc = type_dispatch(out.meta().depth, cv_type_id{}, typed_chan_to_plane_row{}, nullptr); + + GAPI_DbgAssert(rowFunc); + rowFunc(in.InLineB(0), chan, in.meta().chan, out.OutLineB(), in.length()); } }; +GAPI_FLUID_KERNEL(FNV12toRGB, NV12toRGB, false) { + static const int Window = 1; + static const int LPI = 2; + static const auto Kind = cv::GFluidKernel::Kind::YUV420toRGB; + + static void run(const cv::gapi::fluid::View & in_y, + const cv::gapi::fluid::View & in_uv, + cv::gapi::fluid::Buffer & out) { + GAPI_DbgAssert(is_cv_type_in_list(out.meta().depth)); + + const uchar* uv_row = in_uv.InLineB(0); + const uchar* y_rows[2] = { in_y.InLineB(0), in_y.InLineB(1) }; + uchar* out_rows[2] = { out.OutLineB(0), out.OutLineB(1) }; + + int buf_width = out.length(); + + const auto rowFunc = type_dispatch(out.meta().depth, cv_type_id{}, typed_nv12_to_rgb_row{}, nullptr); + + GAPI_DbgAssert(rowFunc); + + rowFunc(y_rows, uv_row, out_rows, buf_width); + } +}; + +GAPI_FLUID_KERNEL(FI420toRGB, I420toRGB, false) { + static const int Window = 1; + static const int LPI = 2; + static const auto Kind = cv::GFluidKernel::Kind::YUV420toRGB; + + static void run(const cv::gapi::fluid::View & in_y, + const cv::gapi::fluid::View & in_u, + const cv::gapi::fluid::View & in_v, + cv::gapi::fluid::Buffer & out) { + GAPI_DbgAssert(is_cv_type_in_list(out.meta().depth)); + + const uchar* u_row = in_u.InLineB(0); + const uchar* v_row = in_v.InLineB(0); + const uchar* y_rows[2] = { in_y.InLineB(0), in_y.InLineB(1) }; + uchar* out_rows[2] = { out.OutLineB(0), out.OutLineB(1) }; + + int buf_width = out.length(); + GAPI_DbgAssert(in_u.length() == in_v.length()); + + const auto rowFunc = type_dispatch(out.meta().depth, cv_type_id{}, typed_i420_to_rgb_row{}, nullptr); + + GAPI_DbgAssert(rowFunc); + + rowFunc(y_rows, u_row, v_row, out_rows, buf_width); + } +}; +}; + +namespace { +struct ColorConversionISA { + cv::gapi::GKernelPackage& pckg; + + ColorConversionISA(cv::gapi::GKernelPackage& _pckg) : pckg(_pckg) {} + + template + bool operator()(type_to_type) { + pckg.include::FI420toRGB>(); + pckg.include::FNV12toRGB>(); + pckg.include::FChanToPlane>(); + //at the moment type_dispatch requires something to be returned by the lambda + return true; + } +}; +} //namespace + +cv::gapi::GKernelPackage FColorConversionChooseISA() { + // At the moment AVX512 implementation of wide universal intrinsics is slower than AVX2. + // So, disable it for now. + using isas = remove_t; + + cv::gapi::GKernelPackage pckg; + ColorConversionISA ctpISA{pckg}; + + type_dispatch(is_isa_present{}, ctpISA, false); + + return pckg; +} + //---------------------------------------------------------------------- G_TYPED_KERNEL(ScalePlane8u, , "com.intel.ie.scale_plane_8u") { @@ -2234,180 +2488,6 @@ GAPI_FLUID_KERNEL(FScalePlaneArea8u, ScalePlaneArea8u, true) { } }; -static const int ITUR_BT_601_CY = 1220542; -static const int ITUR_BT_601_CUB = 2116026; -static const int ITUR_BT_601_CUG = -409993; -static const int ITUR_BT_601_CVG = -852492; -static const int ITUR_BT_601_CVR = 1673527; -static const int ITUR_BT_601_SHIFT = 20; - -static inline void uvToRGBuv(const uchar u, const uchar v, int& ruv, int& guv, int& buv) { - int uu, vv; - uu = static_cast(u) - 128; - vv = static_cast(v) - 128; - - ruv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CVR * vv; - guv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CVG * vv + ITUR_BT_601_CUG * uu; - buv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CUB * uu; -} - -static inline void yRGBuvToRGB(const uchar vy, const int ruv, const int guv, const int buv, - uchar& r, uchar& g, uchar& b) { - int yy = static_cast(vy); - int y = std::max(0, yy - 16) * ITUR_BT_601_CY; - r = saturate_cast((y + ruv) >> ITUR_BT_601_SHIFT); - g = saturate_cast((y + guv) >> ITUR_BT_601_SHIFT); - b = saturate_cast((y + buv) >> ITUR_BT_601_SHIFT); -} - -static void calculate_nv12_to_rgb_fallback(const uchar **y_rows, - const uchar *uv_row, - uchar **out_rows, - int buf_width) { - for (int i = 0; i < buf_width; i += 2) { - uchar u = uv_row[i]; - uchar v = uv_row[i + 1]; - int ruv, guv, buv; - uvToRGBuv(u, v, ruv, guv, buv); - - for (int y = 0; y < 2; y++) { - for (int x = 0; x < 2; x++) { - uchar vy = y_rows[y][i + x]; - uchar r, g, b; - yRGBuvToRGB(vy, ruv, guv, buv, r, g, b); - - out_rows[y][3*(i + x)] = r; - out_rows[y][3*(i + x) + 1] = g; - out_rows[y][3*(i + x) + 2] = b; - } - } - } -} - -static void calculate_i420_to_rgb_fallback(const uchar **y_rows, - const uchar *u_row, - const uchar *v_row, - uchar **out_rows, - int buf_width) { - for (int i = 0; i < buf_width; i += 2) { - uchar u = u_row[i / 2]; - uchar v = v_row[i / 2]; - int ruv, guv, buv; - uvToRGBuv(u, v, ruv, guv, buv); - - for (int y = 0; y < 2; y++) { - for (int x = 0; x < 2; x++) { - uchar vy = y_rows[y][i + x]; - uchar r, g, b; - yRGBuvToRGB(vy, ruv, guv, buv, r, g, b); - - out_rows[y][3*(i + x)] = r; - out_rows[y][3*(i + x) + 1] = g; - out_rows[y][3*(i + x) + 2] = b; - } - } - } -} - -GAPI_FLUID_KERNEL(FNV12toRGB, NV12toRGB, false) { - static const int Window = 1; - static const int LPI = 2; - static const auto Kind = cv::GFluidKernel::Kind::YUV420toRGB; - - static void run(const cv::gapi::fluid::View &in_y, - const cv::gapi::fluid::View &in_uv, - cv::gapi::fluid::Buffer &out) { - const uchar* uv_row = in_uv.InLineB(0); - const uchar* y_rows[2] = {in_y. InLineB(0), in_y. InLineB(1)}; - uchar* out_rows[2] = {out.OutLineB(0), out.OutLineB(1)}; - - int buf_width = out.length(); - -// AVX512 implementation of wide universal intrinsics is slower than AVX2. -// It is turned off until the cause isn't found out. - #if 0 - #ifdef HAVE_AVX512 - if (with_cpu_x86_avx512_core()) { - #define CV_AVX_512DQ 1 - avx512::calculate_nv12_to_rgb(y_rows, uv_row, out_rows, buf_width); - return; - } - #endif // HAVE_AVX512 - #endif - - #ifdef HAVE_AVX2 - if (with_cpu_x86_avx2()) { - avx::calculate_nv12_to_rgb(y_rows, uv_row, out_rows, buf_width); - return; - } - #endif // HAVE_AVX2 - #ifdef HAVE_SSE - if (with_cpu_x86_sse42()) { - calculate_nv12_to_rgb(y_rows, uv_row, out_rows, buf_width); - return; - } - #endif // HAVE_SSE - - #ifdef HAVE_NEON - neon::calculate_nv12_to_rgb(y_rows, uv_row, out_rows, buf_width); - return; - #endif // HAVE_NEON - - calculate_nv12_to_rgb_fallback(y_rows, uv_row, out_rows, buf_width); - } -}; - -GAPI_FLUID_KERNEL(FI420toRGB, I420toRGB, false) { - static const int Window = 1; - static const int LPI = 2; - static const auto Kind = cv::GFluidKernel::Kind::YUV420toRGB; - - static void run(const cv::gapi::fluid::View &in_y, - const cv::gapi::fluid::View &in_u, - const cv::gapi::fluid::View &in_v, - cv::gapi::fluid::Buffer &out) { - const uchar* u_row = in_u.InLineB(0); - const uchar* v_row = in_v.InLineB(0); - const uchar* y_rows[2] = {in_y. InLineB(0), in_y. InLineB(1)}; - uchar* out_rows[2] = {out.OutLineB(0), out.OutLineB(1)}; - - int buf_width = out.length(); - GAPI_DbgAssert(in_u.length() == in_v.length()); - - // AVX512 implementation of wide universal intrinsics is slower than AVX2. - // It is turned off until the cause isn't found out. - #if 0 - #ifdef HAVE_AVX512 - if (with_cpu_x86_avx512_core()) { - #define CV_AVX_512DQ 1 - avx512::calculate_i420_to_rgb(y_rows, u_row, v_row, out_rows, buf_width); - return; - } - #endif // HAVE_AVX512 - #endif - - #ifdef HAVE_AVX2 - if (with_cpu_x86_avx2()) { - avx::calculate_i420_to_rgb(y_rows, u_row, v_row, out_rows, buf_width); - return; - } - #endif // HAVE_AVX2 - #ifdef HAVE_SSE - if (with_cpu_x86_sse42()) { - calculate_i420_to_rgb(y_rows, u_row, v_row, out_rows, buf_width); - return; - } - #endif // HAVE_SSE - - #ifdef HAVE_NEON - neon::calculate_i420_to_rgb(y_rows, u_row, v_row, out_rows, buf_width); - return; - #endif // HAVE_NEON - - calculate_i420_to_rgb_fallback(y_rows, u_row, v_row, out_rows, buf_width); - } -}; - namespace { template @@ -2520,9 +2600,10 @@ GAPI_FLUID_KERNEL(FDivC, GDivC, false) { using namespace kernels; cv::gapi::GKernelPackage preprocKernels() { - return cv::gapi::kernels - < FChanToPlane - , FScalePlanes + return combine( + FColorConversionChooseISA(), + cv::gapi::kernels + (); + >()); } } // namespace gapi diff --git a/inference-engine/src/preprocessing/ie_preprocess_gapi_kernels_impl.hpp b/inference-engine/src/preprocessing/ie_preprocess_gapi_kernels_impl.hpp index 452a29b2e2daec..3acf5a56b26884 100644 --- a/inference-engine/src/preprocessing/ie_preprocess_gapi_kernels_impl.hpp +++ b/inference-engine/src/preprocessing/ie_preprocess_gapi_kernels_impl.hpp @@ -34,6 +34,12 @@ namespace InferenceEngine { namespace gapi { namespace kernels { +struct avx512_tag {}; +struct avx2_tag {}; +struct sse42_tag {}; +struct neon_tag {}; +struct scalar_tag {}; + template static inline DST saturate_cast(SRC x); template<> inline short saturate_cast(int x) { return (std::min)(SHRT_MAX, (std::max)(SHRT_MIN, x)); } template<> inline short saturate_cast(float x) { return saturate_cast(static_cast(std::rint(x))); } @@ -116,6 +122,31 @@ static inline Q8_8 mulaw(Q0_16 a, Q8_8 w) { return static_cast((a * w) >> static inline float mulas(float a, float s) { return a * s; } static inline float mulaw(float a, float w) { return a * w; } +static const int ITUR_BT_601_CY = 1220542; +static const int ITUR_BT_601_CUB = 2116026; +static const int ITUR_BT_601_CUG = -409993; +static const int ITUR_BT_601_CVG = -852492; +static const int ITUR_BT_601_CVR = 1673527; +static const int ITUR_BT_601_SHIFT = 20; + +static inline void uvToRGBuv(const uchar u, const uchar v, int& ruv, int& guv, int& buv) { + int uu, vv; + uu = static_cast(u) - 128; + vv = static_cast(v) - 128; + + ruv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CVR * vv; + guv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CVG * vv + ITUR_BT_601_CUG * uu; + buv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CUB * uu; +} + +static inline void yRGBuvToRGB(const uchar vy, const int ruv, const int guv, const int buv, + uchar& r, uchar& g, uchar& b) { + int yy = static_cast(vy); + int y = std::max(0, yy - 16) * ITUR_BT_601_CY; + r = saturate_cast((y + ruv) >> ITUR_BT_601_SHIFT); + g = saturate_cast((y + guv) >> ITUR_BT_601_SHIFT); + b = saturate_cast((y + buv) >> ITUR_BT_601_SHIFT); +} } // namespace kernels } // namespace gapi } // namespace InferenceEngine diff --git a/inference-engine/src/preprocessing/ie_preprocess_gapi_kernels_simd_impl.hpp b/inference-engine/src/preprocessing/ie_preprocess_gapi_kernels_simd_impl.hpp index a59111b86b64fe..e559b83b87e405 100644 --- a/inference-engine/src/preprocessing/ie_preprocess_gapi_kernels_simd_impl.hpp +++ b/inference-engine/src/preprocessing/ie_preprocess_gapi_kernels_simd_impl.hpp @@ -374,23 +374,6 @@ CV_ALWAYS_INLINE void splitRow_32FC4_Impl(const float in[], float out0[], float //------------------------------------------------------------------------------ -static const int ITUR_BT_601_CY = 1220542; -static const int ITUR_BT_601_CUB = 2116026; -static const int ITUR_BT_601_CUG = -409993; -static const int ITUR_BT_601_CVG = -852492; -static const int ITUR_BT_601_CVR = 1673527; -static const int ITUR_BT_601_SHIFT = 20; - -CV_ALWAYS_INLINE void uvToRGBuv(const uchar u, const uchar v, int& ruv, int& guv, int& buv) { - int uu, vv; - uu = static_cast(u) - 128; - vv = static_cast(v) - 128; - - ruv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CVR * vv; - guv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CVG * vv + ITUR_BT_601_CUG * uu; - buv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CUB * uu; -} - CV_ALWAYS_INLINE void uvToRGBuv(const v_uint8& u, const v_uint8& v, v_int32 (&ruv)[4], v_int32 (&guv)[4], v_int32 (&buv)[4]) { @@ -418,15 +401,6 @@ CV_ALWAYS_INLINE void uvToRGBuv(const v_uint8& u, const v_uint8& v, } } -CV_ALWAYS_INLINE void yRGBuvToRGB(const uchar vy, const int ruv, const int guv, - const int buv, uchar& r, uchar& g, uchar& b) { - int yy = static_cast(vy); - int y = std::max(0, yy - 16) * ITUR_BT_601_CY; - r = saturate_cast((y + ruv) >> ITUR_BT_601_SHIFT); - g = saturate_cast((y + guv) >> ITUR_BT_601_SHIFT); - b = saturate_cast((y + buv) >> ITUR_BT_601_SHIFT); -} - CV_ALWAYS_INLINE void yRGBuvToRGB(const v_uint8& vy, const v_int32 (&ruv)[4], const v_int32 (&guv)[4], @@ -464,16 +438,15 @@ CV_ALWAYS_INLINE void yRGBuvToRGB(const v_uint8& vy, bb = v_pack_u(b0, b1); } -CV_ALWAYS_INLINE void calculate_nv12_to_rgb_impl(const uchar **srcY, - const uchar *srcUV, - uchar **dstRGBx, - int width) { +template +CV_ALWAYS_INLINE void nv12ToRgbRowImpl(isa_tag_t, const uchar** srcY, const uchar* srcUV, + uchar** dstRGBx, const int width) { int i = 0; #if MANUAL_SIMD constexpr int nlanes = v_uint8::nlanes; - for ( ; i <= width - 2*nlanes; i += 2*nlanes) { + for (; i <= width - 2 * nlanes; i += 2 * nlanes) { v_uint8 u, v; v_load_deinterleave(srcUV + i, u, v); @@ -510,9 +483,7 @@ CV_ALWAYS_INLINE void calculate_nv12_to_rgb_impl(const uchar **srcY, v_store_interleave(dstRGBx[1] + i * 3, b1_0, g1_0, r1_0); v_store_interleave(dstRGBx[1] + i * 3 + 3 * nlanes, b1_1, g1_1, r1_1); } - - vx_cleanup(); - + //vx_cleanup(); #endif for (; i < width; i += 2) { @@ -527,25 +498,25 @@ CV_ALWAYS_INLINE void calculate_nv12_to_rgb_impl(const uchar **srcY, uchar r, g, b; yRGBuvToRGB(vy, ruv, guv, buv, r, g, b); - dstRGBx[y][3*(i + x)] = r; - dstRGBx[y][3*(i + x) + 1] = g; - dstRGBx[y][3*(i + x) + 2] = b; + dstRGBx[y][3 * (i + x)] = r; + dstRGBx[y][3 * (i + x) + 1] = g; + dstRGBx[y][3 * (i + x) + 2] = b; } } } } -CV_ALWAYS_INLINE void calculate_i420_to_rgb_impl(const uchar **srcY, const uchar *srcU, - const uchar *srcV, uchar **dstRGBx, - int width) { +template +CV_ALWAYS_INLINE void i420ToRgbRowImpl(isa_tag_t, const uint8_t** srcY, const uint8_t* srcU, + const uint8_t* srcV, uint8_t** dstRGBx, const int width) { int i = 0; #if MANUAL_SIMD constexpr int nlanes = v_uint8::nlanes; - for ( ; i <= width - 2*nlanes; i += 2*nlanes) { - v_uint8 u = vx_load(srcU + i/2); - v_uint8 v = vx_load(srcV + i/2); + for (; i <= width - 2 * nlanes; i += 2 * nlanes) { + v_uint8 u = vx_load(srcU + i / 2); + v_uint8 v = vx_load(srcV + i / 2); v_uint8 vy[4]; v_load_deinterleave(srcY[0] + i, vy[0], vy[1]); @@ -580,14 +551,11 @@ CV_ALWAYS_INLINE void calculate_i420_to_rgb_impl(const uchar **srcY, const uch v_store_interleave(dstRGBx[1] + i * 3, b1_0, g1_0, r1_0); v_store_interleave(dstRGBx[1] + i * 3 + 3 * nlanes, b1_1, g1_1, r1_1); } - - vx_cleanup(); - - #endif - + //vx_cleanup(); +#endif for (; i < width; i += 2) { - uchar u = srcU[i/2]; - uchar v = srcV[i/2]; + uchar u = srcU[i / 2]; + uchar v = srcV[i / 2]; int ruv, guv, buv; uvToRGBuv(u, v, ruv, guv, buv); @@ -597,9 +565,9 @@ CV_ALWAYS_INLINE void calculate_i420_to_rgb_impl(const uchar **srcY, const uch uchar r, g, b; yRGBuvToRGB(vy, ruv, guv, buv, r, g, b); - dstRGBx[y][3*(i + x)] = r; - dstRGBx[y][3*(i + x) + 1] = g; - dstRGBx[y][3*(i + x) + 2] = b; + dstRGBx[y][3 * (i + x)] = r; + dstRGBx[y][3 * (i + x) + 1] = g; + dstRGBx[y][3 * (i + x) + 2] = b; } } } @@ -737,48 +705,24 @@ CV_ALWAYS_INLINE void calcRowArea_impl(T dst[], const T *src[], const Size& inSz //------------------------------------------------------------------------------ -#if MANUAL_SIMD template -CV_ALWAYS_INLINE void copyRow_impl(const T in[], T out[], int l) { - VecT r; - r = vx_load(&in[l]); - vx_store(&out[l], r); -} -#endif - -CV_ALWAYS_INLINE void copyRow_8U_impl(const uint8_t in[], uint8_t out[], int length) { +CV_ALWAYS_INLINE void copyRow_Impl(const T in[], T out[], int length) { int l = 0; #if MANUAL_SIMD - constexpr int nlanes = v_uint8::nlanes; + const int nlanes = VecT::nlanes; - for (; l <= length - nlanes; l += nlanes) { - copyRow_impl(in, out, l); - } - - if (l < length && length >= nlanes) { - copyRow_impl(in, out, length - nlanes); - l = length; - } -#endif - - for (; l < length; l++) { - out[l] = in[l]; - } -} - -CV_ALWAYS_INLINE void copyRow_32F_impl(const float in[], float out[], int length) { - int l = 0; - -#if MANUAL_SIMD - constexpr int nlanes = v_float32::nlanes; + auto copy_row = [](const T in[], T out[], int l) { + VecT r = vx_load(&in[l]); + vx_store(&out[l], r); + }; for (; l <= length - nlanes; l += nlanes) { - copyRow_impl(in, out, l); + copy_row(in, out, l); } if (l < length && length >= nlanes) { - copyRow_impl(in, out, length - nlanes); + copy_row(in, out, length - nlanes); l = length; } #endif @@ -916,6 +860,26 @@ CV_ALWAYS_INLINE void calcRowLinear_32FC1(float *dst[], } } +template +struct vector_type_of; + +template +using vector_type_of_t = typename vector_type_of::type; + +template struct vector_type_of { using type = v_uint8; }; +template struct vector_type_of { using type = v_float32;}; + +template +CV_ALWAYS_INLINE void chanToPlaneRowImpl(isa_tag_t, const T* in, const int chan, const int chs, T* out, const int length) { + if (chs == 1) { + copyRow_Impl, T>(in, out, length); + return; + } + + for (int x = 0; x < length; x++) { + out[x] = in[x*chs + chan]; + } +} } // namespace kernels } // namespace gapi } // namespace InferenceEngine From dbe1c1ab49b3e59ec3c41ca715a9e7f01714bf77 Mon Sep 17 00:00:00 2001 From: Chenhu Wang Date: Wed, 16 Jun 2021 15:32:32 +0800 Subject: [PATCH 104/178] [CPU] Change rounding type in load/store emitters (#6134) --- .../src/mkldnn_plugin/emitters/jit_load_store_emitters.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/inference-engine/src/mkldnn_plugin/emitters/jit_load_store_emitters.cpp b/inference-engine/src/mkldnn_plugin/emitters/jit_load_store_emitters.cpp index 57689d6302d70a..83bc04c530db07 100644 --- a/inference-engine/src/mkldnn_plugin/emitters/jit_load_store_emitters.cpp +++ b/inference-engine/src/mkldnn_plugin/emitters/jit_load_store_emitters.cpp @@ -106,7 +106,6 @@ void jit_load_emitter::emit_isa(const Xbyak::Reg64 ®_src, int offset_byte, In break; case Precision::I32: if ((src_prc == Precision::FP32) || (src_prc == Precision::BF16)) { - h->uni_vroundps(Vmm(out_vec_idx), Vmm(out_vec_idx), 3); // rounding to zero h->uni_vcvtps2dq(Vmm(out_vec_idx), Vmm(out_vec_idx)); } break; @@ -552,7 +551,6 @@ template switch (src_prc) { case Precision::FP32: if ((dst_prc != Precision::FP32) && (dst_prc != Precision::BF16)) { - h->uni_vroundps(Vmm(in_vec_idx), Vmm(in_vec_idx), 3); // rounding to zero h->uni_vcvtps2dq(Vmm(in_vec_idx), Vmm(in_vec_idx)); } break; From 72cb75ffc7df4bf4fc59791b81d9627df34e4e83 Mon Sep 17 00:00:00 2001 From: Edward Shogulin Date: Wed, 16 Jun 2021 11:14:29 +0300 Subject: [PATCH 105/178] [LPT] Reshape folding extending: cherry-pick to master (#6151) * [LPT] Reshape folding extending * [LPT] tests addition * typo quick fix --- .../include/low_precision/network_helper.hpp | 6 ++ .../group_convolution_transformation.cpp | 75 +++++++++++++++++++ .../group_convolution_transformation.cpp | 28 +++++++ .../group_convolution_transformation.cpp | 28 +++++++ .../group_convolution_transformation.hpp | 5 ++ .../group_convolution_transformation.cpp | 16 ++++ .../group_convolution_function.hpp | 3 + .../src/group_convolution_function.cpp | 14 +++- 8 files changed, 174 insertions(+), 1 deletion(-) diff --git a/inference-engine/src/low_precision_transformations/include/low_precision/network_helper.hpp b/inference-engine/src/low_precision_transformations/include/low_precision/network_helper.hpp index 8cf52a13fe20ca..bf45cdeae94133 100644 --- a/inference-engine/src/low_precision_transformations/include/low_precision/network_helper.hpp +++ b/inference-engine/src/low_precision_transformations/include/low_precision/network_helper.hpp @@ -270,6 +270,12 @@ template std::shared_ptr fold_reshape(Args&&... args) { std::shared_ptr node = std::make_shared(std::forward(args)...); if (node->get_output_size() == 1) { + // issue #57985: remove fold_reshape & reuse nGraph implementation + const auto values = as_type_ptr(node->input_value(1).get_node_shared_ptr())->template cast_vector(); + if (std::any_of(values.begin(), values.end(), [](const int64_t value) { return (value == 0) || (value == -1); })) { + return fold(std::forward(args)...); + } + OutputVector folded; if (is_type(node->input_value(0).get_node_shared_ptr()) && is_type(node->input_value(1).get_node_shared_ptr())) { diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/group_convolution_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/group_convolution_transformation.cpp index d90999bb8ccad4..22844037c98d75 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/group_convolution_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/group_convolution_transformation.cpp @@ -53,6 +53,7 @@ class GroupConvolutionTestValues { ngraph::Shape inputShape; ngraph::Shape outputShape; size_t group; + int groupCalculationDimention; Actual actual; Expected expected; }; @@ -67,6 +68,7 @@ class GroupConvolutionTransformation : public LayerTransformation, public testin testValues.inputShape, testValues.outputShape, testValues.group, + testValues.groupCalculationDimention, testValues.actual.dequantization, testValues.actual.weights, testValues.actual.fakeQuantizeOnWeights, @@ -84,6 +86,7 @@ class GroupConvolutionTransformation : public LayerTransformation, public testin testValues.inputShape, testValues.outputShape, testValues.group, + testValues.groupCalculationDimention, testValues.expected.dequantizationBefore, testValues.expected.weights, testValues.expected.fakeQuantizeOnWeights, @@ -101,6 +104,7 @@ class GroupConvolutionTransformation : public LayerTransformation, public testin testValues.inputShape << "_" << testValues.outputShape << "_" << testValues.group << "_" << + testValues.groupCalculationDimention << "_" << testValues.actual.precisionBeforeDequantization << "_" << testValues.actual.dequantization << "_" << "_weights_" << testValues.actual.weights->get_element_type() << "_" << "{ " << @@ -123,6 +127,7 @@ const std::vector testValues = { { 1, 6, 224, 224 }, { 1, 24, 218, 218 }, 3ul, + -1, // ActualValues { ngraph::element::u8, @@ -142,12 +147,68 @@ const std::vector testValues = { {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 24, 1, 1 }}} // 0.0002 = 0.02 (on data) * 0.01 (on weights) } }, + + // group convolution, tensor quantization, with zero point + { + LayerTransformation::createParamsU8I8().setSupportAsymmetricQuantization(true), + { 1, 6, 224, 224 }, + { 1, 24, 218, 218 }, + 3ul, + 0, + // ActualValues + { + ngraph::element::u8, + {{ngraph::element::f32}, { 128.f }, { 0.02f }}, + op::Constant::create(ngraph::element::f32, ngraph::Shape{}, std::vector{ 2.f }), + { 255ul, Shape({ 1, 1, 1, 1 }), { 0.f }, { 254.f }, { -1.27f }, { 1.27f } }, + {} + }, + // ExpectedValues + { + ngraph::element::u8, + {{}, { { 128.f }, ngraph::element::f32, { 1, 6, 1, 1 }, false }, {}}, + op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ -125.f }), + {}, + {}, + ngraph::element::f32, + {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 24, 1, 1 }}} // 0.0002 = 0.02 (on data) * 0.01 (on weights) + } + }, + + // group convolution, tensor quantization, with zero point + { + LayerTransformation::createParamsU8I8().setSupportAsymmetricQuantization(true), + { 1, 6, 224, 224 }, + { 1, 24, 218, 218 }, + 3ul, + 1, + // ActualValues + { + ngraph::element::u8, + {{ngraph::element::f32}, { 128.f }, { 0.02f }}, + op::Constant::create(ngraph::element::f32, ngraph::Shape{}, std::vector{ 2.f }), + { 255ul, Shape({ 1, 1, 1, 1 }), { 0.f }, { 254.f }, { -1.27f }, { 1.27f } }, + {} + }, + // ExpectedValues + { + ngraph::element::u8, + {{}, { { 128.f }, ngraph::element::f32, { 1, 6, 1, 1 }, false }, {}}, + op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ -125.f }), + {}, + {}, + ngraph::element::f32, + {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 24, 1, 1 }}} // 0.0002 = 0.02 (on data) * 0.01 (on weights) + } + }, + // group convolution, tensor quantization, with zero point { LayerTransformation::createParamsU8I8().setSupportAsymmetricQuantization(false), { 1, 6, 224, 224 }, { 1, 24, 218, 218 }, 3ul, + -1, // ActualValues { ngraph::element::u8, @@ -173,6 +234,7 @@ const std::vector testValues = { { 1, 6, 224, 224 }, { 1, 24, 218, 218 }, 3ul, + -1, // ActualValues { ngraph::element::f32, @@ -198,6 +260,7 @@ const std::vector testValues = { { 1, 6, 224, 224 }, { 1, 24, 218, 218 }, 3ul, + -1, // ActualValues { ngraph::element::u8, @@ -241,6 +304,7 @@ const std::vector testValues = { { 1, 6, 224, 224 }, { 1, 24, 218, 218 }, 3ul, + -1, // ActualValues { ngraph::element::u8, @@ -274,6 +338,7 @@ const std::vector testValues = { { 1, 6, 224, 224 }, { 1, 24, 218, 218 }, 3ul, + -1, // ActualValues { ngraph::element::f32, @@ -299,6 +364,7 @@ const std::vector testValues = { { 1, 6, 224, 224 }, { 1, 24, 218, 218 }, 3ul, + -1, // ActualValues { ngraph::element::u8, @@ -324,6 +390,7 @@ const std::vector testValues = { { 1, 6, 224, 224 }, { 1, 6, 218, 218 }, 3ul, + -1, // ActualValues { ngraph::element::u8, @@ -349,6 +416,7 @@ const std::vector testValues = { { 1, 6, 224, 224 }, { 1, 6, 218, 218 }, 3ul, + -1, // ActualValues { ngraph::element::f32, @@ -374,6 +442,7 @@ const std::vector testValues = { { 1, 6, 224, 224 }, { 1, 6, 218, 218 }, 6ul, + -1, // ActualValues { ngraph::element::u8, @@ -414,6 +483,7 @@ const std::vector testValues = { { 1, 6, 224, 224 }, { 1, 6, 218, 218 }, 6ul, + -1, // ActualValues { ngraph::element::u8, @@ -447,6 +517,7 @@ const std::vector testValues = { { 1, 6, 224, 224 }, { 1, 6, 218, 218 }, 6ul, + -1, // ActualValues { ngraph::element::f32, @@ -472,6 +543,7 @@ const std::vector testValues = { { 1, 6, 224, 224 }, { 1, 6, 218, 218 }, 6ul, + -1, // ActualValues { ngraph::element::u8, @@ -497,6 +569,7 @@ const std::vector testValues = { { 1, 6, 224, 224 }, { 1, 6, 218, 218 }, 6ul, + -1, // ActualValues { ngraph::element::f32, @@ -523,6 +596,7 @@ const std::vector testValues = { { 1, 6, 224, 224 }, { 1, 24, 218, 218 }, 3ul, + -1, // ActualValues { ngraph::element::u8, @@ -567,6 +641,7 @@ const std::vector testValues = { { 1, 6, 224, 224 }, { 1, 24, 218, 218 }, 3ul, + -1, // ActualValues { ngraph::element::u8, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp index 36e81ef438d165..739897ee27350e 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp @@ -26,14 +26,40 @@ const std::vector pa ngraph::Shape{ 1, 6, 24, 24 }, ngraph::Shape{ 1, 24, 18, 18 }, 3ul, + -1, { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 25.5f }, { 0.f }, { 25.5f } }, { 255ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 254.f }, { -127.f }, { 127.f } }, + "Convolution", + "U8" + }, + // group convolution, tensor quantization + { + ngraph::Shape{ 1, 6, 24, 24 }, + ngraph::Shape{ 1, 24, 18, 18 }, + 3ul, + 0, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 25.5f }, { 0.f }, { 25.5f } }, + { 255ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 254.f }, { -127.f }, { 127.f } }, + "Convolution", + "U8" + }, + // group convolution, tensor quantization + { + ngraph::Shape{ 1, 6, 24, 24 }, + ngraph::Shape{ 1, 24, 18, 18 }, + 3ul, + 1, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 25.5f }, { 0.f }, { 25.5f } }, + { 255ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 254.f }, { -127.f }, { 127.f } }, + "Convolution", + "U8" }, // group convolution, per-channel quantization { ngraph::Shape{ 1, 6, 24, 24 }, ngraph::Shape{ 1, 24, 18, 18 }, 3ul, + -1, { 256ul, ngraph::Shape { 6, 1, 1, 1 }, @@ -49,6 +75,7 @@ const std::vector pa ngraph::Shape{ 1, 6, 24, 24 }, ngraph::Shape{ 1, 6, 18, 18 }, 6ul, + -1, { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 25.5f }, { 0.f }, { 25.5f } }, { 255ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 254.f }, { -127.f }, { 127.f } }, }, @@ -57,6 +84,7 @@ const std::vector pa ngraph::Shape{ 1, 6, 24, 24 }, ngraph::Shape{ 1, 6, 18, 18 }, 6ul, + -1, { 256ul, ngraph::Shape { 6, 1, 1, 1 }, diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp index 8c346ba667e75d..624d933188b7fa 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp @@ -26,14 +26,40 @@ const std::vector pa ngraph::Shape{ 1, 6, 24, 24 }, ngraph::Shape{ 1, 24, 18, 18 }, 3ul, + -1, { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 25.5f }, { 0.f }, { 25.5f } }, { 255ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 254.f }, { -127.f }, { 127.f } }, + "Convolution", + "U8" + }, + // group convolution, tensor quantization + { + ngraph::Shape{ 1, 6, 24, 24 }, + ngraph::Shape{ 1, 24, 18, 18 }, + 3ul, + 0, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 25.5f }, { 0.f }, { 25.5f } }, + { 255ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 254.f }, { -127.f }, { 127.f } }, + "Convolution", + "U8" + }, + // group convolution, tensor quantization + { + ngraph::Shape{ 1, 6, 24, 24 }, + ngraph::Shape{ 1, 24, 18, 18 }, + 3ul, + 1, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 25.5f }, { 0.f }, { 25.5f } }, + { 255ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 254.f }, { -127.f }, { 127.f } }, + "Convolution", + "U8" }, // group convolution, per-channel quantization { ngraph::Shape{ 1, 6, 24, 24 }, ngraph::Shape{ 1, 24, 18, 18 }, 3ul, + -1, { 256ul, ngraph::Shape { 6, 1, 1, 1 }, @@ -49,6 +75,7 @@ const std::vector pa ngraph::Shape{ 1, 6, 24, 24 }, ngraph::Shape{ 1, 6, 18, 18 }, 6ul, + -1, { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 25.5f }, { 0.f }, { 25.5f } }, { 255ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 254.f }, { -127.f }, { 127.f } }, }, @@ -57,6 +84,7 @@ const std::vector pa ngraph::Shape{ 1, 6, 24, 24 }, ngraph::Shape{ 1, 6, 18, 18 }, 6ul, + -1, { 256ul, ngraph::Shape { 6, 1, 1, 1 }, diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/group_convolution_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/group_convolution_transformation.hpp index 1910df5e46da3f..b7d92417182a2a 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/group_convolution_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/group_convolution_transformation.hpp @@ -18,8 +18,11 @@ class GroupConvolutionTransformationParam { ngraph::Shape inputShape; ngraph::Shape outputShape; size_t group; + int groupCalculationDimention; ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantizeOnData; ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights; + std::string layerName; + std::string expectedKernelType; }; typedef std::tuple< @@ -38,6 +41,8 @@ class GroupConvolutionTransformation : protected: void SetUp() override; + void Run() override; + private: void validate(); }; diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/group_convolution_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/group_convolution_transformation.cpp index f56c9743defdf2..c9baa32932975c 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/group_convolution_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/group_convolution_transformation.cpp @@ -33,6 +33,7 @@ std::string GroupConvolutionTransformation::getTestCaseName(testing::TestParamIn param.inputShape << "_" << param.outputShape << "_" << param.group << "_" << + param.groupCalculationDimention << "_" << param.fakeQuantizeOnData << "_" << param.fakeQuantizeOnWeights; return result.str(); @@ -51,12 +52,27 @@ void GroupConvolutionTransformation::SetUp() { param.inputShape, param.outputShape, param.group, + param.groupCalculationDimention, param.fakeQuantizeOnData, param.fakeQuantizeOnWeights); validate(); } +void GroupConvolutionTransformation::Run() { + LayerTestsCommon::Run(); + + const auto param = std::get<3>(GetParam()); + if (!param.layerName.empty()) { + const auto actualPrecision = getRuntimePrecisionByType(param.layerName); + auto expectedPrecision = param.expectedKernelType; + if (expectedPrecision == "FP32" && std::get<0>(GetParam()) == ngraph::element::f16) { + expectedPrecision = "FP16"; + } + EXPECT_EQ(actualPrecision, expectedPrecision); + } +} + void GroupConvolutionTransformation::validate() { ngraph::element::Type netPrecision; ngraph::pass::low_precision::LayerTransformation::Params params; diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/group_convolution_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/group_convolution_function.hpp index 2273de2602c4fc..1b94400f7bc099 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/group_convolution_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/group_convolution_function.hpp @@ -22,6 +22,7 @@ class GroupConvolutionFunction { const ngraph::Shape& inputShape, const ngraph::Shape& outputShape, const size_t groupCount, + const int groupCalculationDimention, const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore, std::shared_ptr weightsConst, const ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights); @@ -31,6 +32,7 @@ class GroupConvolutionFunction { const ngraph::Shape& inputShape, const ngraph::Shape& outputShape, const size_t groupCount, + const int groupCalculationDimention, const FakeQuantizeOnData& fakeQuantizeOnData, const FakeQuantizeOnWeights& fakeQuantizeOnWeights); @@ -39,6 +41,7 @@ class GroupConvolutionFunction { const ngraph::Shape& inputShape, const ngraph::Shape& outputShape, const size_t groupCount, + const int calculatedDimention, const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore, std::shared_ptr weightsConst, const ngraph::builder::subgraph::FakeQuantizeOnWeights& fakeQuantizeOnWeights, diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/group_convolution_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/group_convolution_function.cpp index 4d3b6153f08c56..205d57747ecebd 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/group_convolution_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/group_convolution_function.cpp @@ -28,6 +28,7 @@ std::shared_ptr createWeightsOriginal( const size_t inputChannelsCount, const size_t outputChannelsCount, const size_t groupCount, + const int calculatedDimention, const size_t kernelSize, const std::vector& weightsValues, const FakeQuantizeOnWeights& fakeQuantizeOnWeights, @@ -70,7 +71,12 @@ std::shared_ptr createWeightsOriginal( ngraph::opset1::Constant::create( element::i64, Shape{ 5 }, - std::vector({ groupCount, outputChannelsCount / groupCount, inputChannelsPerGroup, kernelSize, kernelSize })), + std::vector { + calculatedDimention == 0 ? -1 : static_cast(groupCount), + calculatedDimention == 1 ? -1 : static_cast(outputChannelsCount / groupCount), + static_cast(inputChannelsPerGroup), + static_cast(kernelSize), + static_cast(kernelSize) }), true); } @@ -82,6 +88,7 @@ std::shared_ptr GroupConvolutionFunction::getOriginal( const ngraph::Shape& inputShape, const ngraph::Shape& outputShape, const size_t groupCount, + const int groupCalculationDimention, const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore, std::shared_ptr weightsConst, const ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights) { @@ -103,6 +110,7 @@ std::shared_ptr GroupConvolutionFunction::getOriginal( inputChannelsCount, outputChannelsCount, groupCount, + groupCalculationDimention, kernelSize, weightsConst->cast_vector(), fakeQuantizeOnWeights, @@ -126,6 +134,7 @@ std::shared_ptr GroupConvolutionFunction::getOriginal( const ngraph::Shape& inputShape, const ngraph::Shape& outputShape, const size_t groupCount, + const int groupCalculationDimention, const FakeQuantizeOnData& fakeQuantizeOnData, const FakeQuantizeOnWeights& fakeQuantizeOnWeights) { const auto input = std::make_shared(precision, ngraph::Shape(inputShape)); @@ -156,6 +165,7 @@ std::shared_ptr GroupConvolutionFunction::getOriginal( inputChannelsCount, outputChannelsCount, groupCount, + groupCalculationDimention, kernelSize, weightsValues, fakeQuantizeOnWeights, @@ -178,6 +188,7 @@ std::shared_ptr GroupConvolutionFunction::get( const ngraph::Shape& inputShape, const ngraph::Shape& outputShape, const size_t groupCount, + const int calculatedDimention, const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore, std::shared_ptr weightsConst, const ngraph::builder::subgraph::FakeQuantizeOnWeights& fakeQuantizeOnWeights, @@ -216,6 +227,7 @@ std::shared_ptr GroupConvolutionFunction::get( inputChannelsCount, outputChannelsCount, groupCount, + calculatedDimention, kernelSize, weightsConst->cast_vector(), fakeQuantizeOnWeights, From b0c508d4ff8698d80dd0187465cdaba93234e59d Mon Sep 17 00:00:00 2001 From: Alexander Shchepetov Date: Wed, 16 Jun 2021 12:50:16 +0300 Subject: [PATCH 106/178] Add layer tests (#5789) Co-authored-by: alexander.shchepetov --- tests/layer_tests/.gitignore | 9 + tests/layer_tests/README.md | 32 + tests/layer_tests/common/constants.py | 25 + tests/layer_tests/common/layer_test_class.py | 155 ++++ tests/layer_tests/common/layer_utils.py | 58 ++ .../common/onnx_layer_test_class.py | 63 ++ .../layer_tests/common/tf_layer_test_class.py | 61 ++ .../layer_tests/common/utils/common_utils.py | 84 +++ .../common/utils/multiprocessing_utils.py | 99 +++ tests/layer_tests/common/utils/parsers.py | 28 + tests/layer_tests/common/utils/tf_utils.py | 109 +++ tests/layer_tests/conftest.py | 77 ++ tests/layer_tests/onnx_tests/conftest.py | 12 + tests/layer_tests/onnx_tests/test_abs.py | 178 +++++ .../onnx_tests/test_add_sub_mul_div.py | 337 +++++++++ tests/layer_tests/onnx_tests/test_and.py | 268 +++++++ tests/layer_tests/onnx_tests/test_argmax.py | 153 ++++ tests/layer_tests/onnx_tests/test_bn.py | 133 ++++ tests/layer_tests/onnx_tests/test_ceil.py | 194 +++++ tests/layer_tests/onnx_tests/test_clip.py | 169 +++++ tests/layer_tests/onnx_tests/test_concat.py | 225 ++++++ tests/layer_tests/onnx_tests/test_conv.py | 413 +++++++++++ .../onnx_tests/test_conv_transpose.py | 215 ++++++ tests/layer_tests/onnx_tests/test_cumsum.py | 267 +++++++ .../onnx_tests/test_dequantize_linear.py | 205 ++++++ tests/layer_tests/onnx_tests/test_dropout.py | 169 +++++ tests/layer_tests/onnx_tests/test_elu.py | 185 +++++ .../onnx_tests/test_embedding_bag.py | 131 ++++ tests/layer_tests/onnx_tests/test_flatten.py | 302 ++++++++ tests/layer_tests/onnx_tests/test_floor.py | 179 +++++ tests/layer_tests/onnx_tests/test_gather.py | 261 +++++++ tests/layer_tests/onnx_tests/test_gemm.py | 308 ++++++++ .../onnx_tests/test_hard_sigmoid.py | 235 ++++++ tests/layer_tests/onnx_tests/test_identity.py | 183 +++++ .../onnx_tests/test_image_scaler.py | 161 +++++ .../onnx_tests/test_instance_normalization.py | 111 +++ .../layer_tests/onnx_tests/test_leaky_relu.py | 204 ++++++ tests/layer_tests/onnx_tests/test_log.py | 193 +++++ .../layer_tests/onnx_tests/test_logsoftmax.py | 240 +++++++ tests/layer_tests/onnx_tests/test_lrn.py | 133 ++++ tests/layer_tests/onnx_tests/test_lstm.py | 160 +++++ tests/layer_tests/onnx_tests/test_matmul.py | 190 +++++ .../test_mean_variance_normalization.py | 73 ++ tests/layer_tests/onnx_tests/test_neg.py | 91 +++ tests/layer_tests/onnx_tests/test_non_zero.py | 194 +++++ tests/layer_tests/onnx_tests/test_not.py | 190 +++++ tests/layer_tests/onnx_tests/test_or.py | 277 +++++++ tests/layer_tests/onnx_tests/test_pad.py | 212 ++++++ tests/layer_tests/onnx_tests/test_pooling.py | 432 +++++++++++ tests/layer_tests/onnx_tests/test_prelu.py | 161 +++++ .../layer_tests/onnx_tests/test_reciprocal.py | 171 +++++ tests/layer_tests/onnx_tests/test_reduce.py | 179 +++++ .../layer_tests/onnx_tests/test_reduce_lp.py | 247 +++++++ tests/layer_tests/onnx_tests/test_relu.py | 183 +++++ tests/layer_tests/onnx_tests/test_reshape.py | 283 ++++++++ tests/layer_tests/onnx_tests/test_resize.py | 676 ++++++++++++++++++ .../layer_tests/onnx_tests/test_roi_align.py | 109 +++ tests/layer_tests/onnx_tests/test_scale.py | 144 ++++ tests/layer_tests/onnx_tests/test_scatter.py | 125 ++++ tests/layer_tests/onnx_tests/test_sigmoid.py | 196 +++++ tests/layer_tests/onnx_tests/test_sign.py | 176 +++++ tests/layer_tests/onnx_tests/test_slice.py | 399 +++++++++++ tests/layer_tests/onnx_tests/test_softmax.py | 167 +++++ tests/layer_tests/onnx_tests/test_softplus.py | 182 +++++ .../onnx_tests/test_split_concat.py | 307 ++++++++ tests/layer_tests/onnx_tests/test_sqrt.py | 187 +++++ tests/layer_tests/onnx_tests/test_squeeze.py | 210 ++++++ tests/layer_tests/onnx_tests/test_sum.py | 322 +++++++++ tests/layer_tests/onnx_tests/test_topk.py | 167 +++++ .../layer_tests/onnx_tests/test_transpose.py | 178 +++++ .../onnx_tests/test_trigonometry.py | 298 ++++++++ .../layer_tests/onnx_tests/test_unsqueeze.py | 210 ++++++ tests/layer_tests/onnx_tests/test_upsample.py | 188 +++++ tests/layer_tests/onnx_tests/test_where.py | 97 +++ tests/layer_tests/onnx_tests/test_xor.py | 268 +++++++ tests/layer_tests/requirements.txt | 2 + .../layer_tests/tensorflow_tests/conftest.py | 12 + .../tensorflow_tests/permutation_utils.py | 22 + .../tensorflow_tests/test_tf_Add.py | 281 ++++++++ .../tensorflow_tests/test_tf_BatchToSpace.py | 80 +++ .../tensorflow_tests/test_tf_BiasAdd.py | 194 +++++ .../tensorflow_tests/test_tf_Bucketize.py | 83 +++ .../tensorflow_tests/test_tf_Ceil.py | 78 ++ .../tensorflow_tests/test_tf_Concat.py | 114 +++ .../tensorflow_tests/test_tf_ELU.py | 88 +++ .../tensorflow_tests/test_tf_Eltwise.py | 79 ++ .../tensorflow_tests/test_tf_FakeQuantize.py | 125 ++++ .../tensorflow_tests/test_tf_Floor.py | 78 ++ .../tensorflow_tests/test_tf_Identity.py | 85 +++ .../tensorflow_tests/test_tf_Log.py | 79 ++ .../tensorflow_tests/test_tf_LogSoftmax.py | 138 ++++ .../tensorflow_tests/test_tf_Mul.py | 279 ++++++++ .../tensorflow_tests/test_tf_NormalizeL2.py | 207 ++++++ .../tensorflow_tests/test_tf_OneHot.py | 159 ++++ .../tensorflow_tests/test_tf_Pooling.py | 230 ++++++ .../tensorflow_tests/test_tf_ReLU.py | 85 +++ .../tensorflow_tests/test_tf_ReLU6.py | 85 +++ .../test_tf_Resample_pattern_new.py | 81 +++ .../tensorflow_tests/test_tf_Rsqrt.py | 73 ++ .../tensorflow_tests/test_tf_Select.py | 107 +++ .../tensorflow_tests/test_tf_Softplus.py | 90 +++ .../tensorflow_tests/test_tf_SpaceToBatch.py | 80 +++ .../tensorflow_tests/test_tf_Squeeze.py | 124 ++++ .../tensorflow_tests/test_tf_Sub.py | 294 ++++++++ .../tensorflow_tests/test_tf_Swish.py | 88 +++ .../tensorflow_tests/test_tf_TopK.py | 143 ++++ 106 files changed, 17876 insertions(+) create mode 100644 tests/layer_tests/.gitignore create mode 100644 tests/layer_tests/README.md create mode 100644 tests/layer_tests/common/constants.py create mode 100644 tests/layer_tests/common/layer_test_class.py create mode 100644 tests/layer_tests/common/layer_utils.py create mode 100644 tests/layer_tests/common/onnx_layer_test_class.py create mode 100644 tests/layer_tests/common/tf_layer_test_class.py create mode 100644 tests/layer_tests/common/utils/common_utils.py create mode 100644 tests/layer_tests/common/utils/multiprocessing_utils.py create mode 100644 tests/layer_tests/common/utils/parsers.py create mode 100644 tests/layer_tests/common/utils/tf_utils.py create mode 100644 tests/layer_tests/conftest.py create mode 100644 tests/layer_tests/onnx_tests/conftest.py create mode 100644 tests/layer_tests/onnx_tests/test_abs.py create mode 100644 tests/layer_tests/onnx_tests/test_add_sub_mul_div.py create mode 100644 tests/layer_tests/onnx_tests/test_and.py create mode 100644 tests/layer_tests/onnx_tests/test_argmax.py create mode 100644 tests/layer_tests/onnx_tests/test_bn.py create mode 100644 tests/layer_tests/onnx_tests/test_ceil.py create mode 100644 tests/layer_tests/onnx_tests/test_clip.py create mode 100644 tests/layer_tests/onnx_tests/test_concat.py create mode 100644 tests/layer_tests/onnx_tests/test_conv.py create mode 100644 tests/layer_tests/onnx_tests/test_conv_transpose.py create mode 100644 tests/layer_tests/onnx_tests/test_cumsum.py create mode 100644 tests/layer_tests/onnx_tests/test_dequantize_linear.py create mode 100644 tests/layer_tests/onnx_tests/test_dropout.py create mode 100644 tests/layer_tests/onnx_tests/test_elu.py create mode 100644 tests/layer_tests/onnx_tests/test_embedding_bag.py create mode 100644 tests/layer_tests/onnx_tests/test_flatten.py create mode 100644 tests/layer_tests/onnx_tests/test_floor.py create mode 100644 tests/layer_tests/onnx_tests/test_gather.py create mode 100644 tests/layer_tests/onnx_tests/test_gemm.py create mode 100644 tests/layer_tests/onnx_tests/test_hard_sigmoid.py create mode 100644 tests/layer_tests/onnx_tests/test_identity.py create mode 100644 tests/layer_tests/onnx_tests/test_image_scaler.py create mode 100644 tests/layer_tests/onnx_tests/test_instance_normalization.py create mode 100644 tests/layer_tests/onnx_tests/test_leaky_relu.py create mode 100644 tests/layer_tests/onnx_tests/test_log.py create mode 100644 tests/layer_tests/onnx_tests/test_logsoftmax.py create mode 100644 tests/layer_tests/onnx_tests/test_lrn.py create mode 100644 tests/layer_tests/onnx_tests/test_lstm.py create mode 100644 tests/layer_tests/onnx_tests/test_matmul.py create mode 100644 tests/layer_tests/onnx_tests/test_mean_variance_normalization.py create mode 100644 tests/layer_tests/onnx_tests/test_neg.py create mode 100644 tests/layer_tests/onnx_tests/test_non_zero.py create mode 100644 tests/layer_tests/onnx_tests/test_not.py create mode 100644 tests/layer_tests/onnx_tests/test_or.py create mode 100644 tests/layer_tests/onnx_tests/test_pad.py create mode 100644 tests/layer_tests/onnx_tests/test_pooling.py create mode 100644 tests/layer_tests/onnx_tests/test_prelu.py create mode 100644 tests/layer_tests/onnx_tests/test_reciprocal.py create mode 100644 tests/layer_tests/onnx_tests/test_reduce.py create mode 100644 tests/layer_tests/onnx_tests/test_reduce_lp.py create mode 100644 tests/layer_tests/onnx_tests/test_relu.py create mode 100644 tests/layer_tests/onnx_tests/test_reshape.py create mode 100644 tests/layer_tests/onnx_tests/test_resize.py create mode 100644 tests/layer_tests/onnx_tests/test_roi_align.py create mode 100644 tests/layer_tests/onnx_tests/test_scale.py create mode 100644 tests/layer_tests/onnx_tests/test_scatter.py create mode 100644 tests/layer_tests/onnx_tests/test_sigmoid.py create mode 100644 tests/layer_tests/onnx_tests/test_sign.py create mode 100644 tests/layer_tests/onnx_tests/test_slice.py create mode 100644 tests/layer_tests/onnx_tests/test_softmax.py create mode 100644 tests/layer_tests/onnx_tests/test_softplus.py create mode 100644 tests/layer_tests/onnx_tests/test_split_concat.py create mode 100644 tests/layer_tests/onnx_tests/test_sqrt.py create mode 100644 tests/layer_tests/onnx_tests/test_squeeze.py create mode 100644 tests/layer_tests/onnx_tests/test_sum.py create mode 100644 tests/layer_tests/onnx_tests/test_topk.py create mode 100644 tests/layer_tests/onnx_tests/test_transpose.py create mode 100644 tests/layer_tests/onnx_tests/test_trigonometry.py create mode 100644 tests/layer_tests/onnx_tests/test_unsqueeze.py create mode 100644 tests/layer_tests/onnx_tests/test_upsample.py create mode 100644 tests/layer_tests/onnx_tests/test_where.py create mode 100644 tests/layer_tests/onnx_tests/test_xor.py create mode 100644 tests/layer_tests/requirements.txt create mode 100644 tests/layer_tests/tensorflow_tests/conftest.py create mode 100644 tests/layer_tests/tensorflow_tests/permutation_utils.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_Add.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_BatchToSpace.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_BiasAdd.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_Bucketize.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_Ceil.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_Concat.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_ELU.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_Eltwise.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_FakeQuantize.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_Floor.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_Identity.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_Log.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_LogSoftmax.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_Mul.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_NormalizeL2.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_OneHot.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_Pooling.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_ReLU.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_ReLU6.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_Resample_pattern_new.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_Rsqrt.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_Select.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_Softplus.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_SpaceToBatch.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_Squeeze.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_Sub.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_Swish.py create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_TopK.py diff --git a/tests/layer_tests/.gitignore b/tests/layer_tests/.gitignore new file mode 100644 index 00000000000000..f7e78b45447612 --- /dev/null +++ b/tests/layer_tests/.gitignore @@ -0,0 +1,9 @@ +#IDE FILES +.pytest_cache + +#TESTS TEMP DIRECTORY +ir/ +out/ +tf_models/ +onnx_models/ + diff --git a/tests/layer_tests/README.md b/tests/layer_tests/README.md new file mode 100644 index 00000000000000..5787a19bbd21fb --- /dev/null +++ b/tests/layer_tests/README.md @@ -0,0 +1,32 @@ +# Layer tests + +This folder layer tests framework code and test files. + +## Getting Started + +#### Pre-requisites + +* OpenVINO should be configured as usual. + +#### Setup + +* Install requirements: + ```bash + pip3 install -r requirements.txt + ``` +* Set up environment variables for layer tests: + ```bash + export MO_ROOT=PATH_TO_MO + ``` + ```bash + export PYTHONPATH="path_to_openvino"/tests/layer_tests/:$PYTHONPATH + ``` + ```bash + export IE_APP_PATH="path_to_IE" + ``` +* Add IE dependencies in LD_LIBRARY_PATH. + +## Run tests +```bash +py.test +``` diff --git a/tests/layer_tests/common/constants.py b/tests/layer_tests/common/constants.py new file mode 100644 index 00000000000000..f1e97d43817983 --- /dev/null +++ b/tests/layer_tests/common/constants.py @@ -0,0 +1,25 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import os + + +if 'MO_ROOT' in os.environ: + mo_bin = os.environ['MO_ROOT'] + if not os.path.exists(mo_bin): + raise EnvironmentError( + "Environment variable MO_ROOT points to non existing path {}".format(mo_bin)) +else: + raise EnvironmentError("MO_ROOT variable is not set") + +if os.environ.get('OUTPUT_DIR') is not None: + out_path = os.environ['OUTPUT_DIR'] +else: + script_path = os.path.dirname(os.path.realpath(__file__)) + out_path = os.path.join(script_path, 'out') + if not os.path.exists(out_path): + os.makedirs(out_path) + +# supported_devices : CPU, GPU, MYRIAD, FPGA +test_device = os.environ.get('TEST_DEVICE', 'CPU;GPU').split(';') +test_precision = os.environ.get('TEST_PRECISION', 'FP32;FP16').split(';') diff --git a/tests/layer_tests/common/layer_test_class.py b/tests/layer_tests/common/layer_test_class.py new file mode 100644 index 00000000000000..28d08d23090d34 --- /dev/null +++ b/tests/layer_tests/common/layer_test_class.py @@ -0,0 +1,155 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import itertools +import os +import warnings +from pathlib import Path + +import numpy as np +from common.constants import test_device, test_precision +from common.layer_utils import IEInfer +from mo.utils.ir_engine.ir_engine import IREngine + +from common.utils.common_utils import generate_ir +from common.utils.parsers import mapping_parser + + +class CommonLayerTest: + input_model_key = "input_model" + + def produce_model_path(self, framework_model, save_path): + pass + + def get_framework_results(self, inputs_dict, model_path): + pass + + def _test(self, framework_model, ref_net, ie_device, precision, ir_version, temp_dir, + enabled_transforms='', disabled_transforms='', **kwargs): + """ + :param enabled_transforms/disabled_transforms: string with idxs of transforms that should be enabled/disabled. + Example: "transform_1,transform_2" + """ + model_path = self.produce_model_path(framework_model=framework_model, save_path=temp_dir) + + # TODO Pass environment variables via subprocess environment + os.environ['MO_ENABLED_TRANSFORMS'] = enabled_transforms + os.environ['MO_DISABLED_TRANSFORMS'] = disabled_transforms + + mo_params = {self.input_model_key: model_path, + "output_dir": temp_dir, + "data_type": precision, "model_name": 'model' + } + + if 'input_shapes' in kwargs and len(kwargs['input_shapes']): + input_shapes_str = [] + for ishape in kwargs['input_shapes']: + input_shapes_str.append('[' + ','.join([str(i) for i in ishape]) + ']') + mo_params.update(dict(input_shape=','.join(input_shapes_str))) + + if 'input_names' in kwargs and len(kwargs['input_names']): + mo_params.update(dict(input=','.join(kwargs['input_names']))) + + exit_code, stderr = generate_ir(**mo_params) + + del os.environ['MO_ENABLED_TRANSFORMS'] + del os.environ['MO_DISABLED_TRANSFORMS'] + assert not exit_code, ("IR generation failed with {} exit code: {}".format(exit_code, stderr)) + + path_to_xml = Path(temp_dir, 'model.xml') + path_to_bin = Path(temp_dir, 'model.bin') + + ir = IREngine(path_to_xml, path_to_bin, precision=precision) + if ref_net is not None: + (flag, resp) = ir.compare(ref_net) + assert flag, '\n'.join(resp) + + # Prepare feed dict + if 'kwargs_to_prepare_input' in kwargs and kwargs['kwargs_to_prepare_input']: + inputs_dict = self._prepare_input(ir.get_inputs(), kwargs['kwargs_to_prepare_input']) + else: + inputs_dict = self._prepare_input(ir.get_inputs()) + + # IE infer: + ie_engine = IEInfer(model=path_to_xml, + weights=path_to_bin, + device=ie_device) + infer_res = ie_engine.infer(input_data=inputs_dict) + + if hasattr(self, 'skip_framework') and self.skip_framework: + warnings.warn('Framework is skipped') + return + + # Framework infer: + fw_res = self.get_framework_results(inputs_dict=inputs_dict, model_path=model_path) + + if len(fw_res) == len(infer_res) == 1: + # match output layers directly + mapping_dict = {next(iter(fw_res)): next(iter(infer_res))} + else: + # Load mapping file + mapping_dict = mapping_parser(path_to_xml.with_suffix('.mapping')) + + if 'custom_eps' in kwargs and kwargs['custom_eps'] is not None: + custom_eps = kwargs['custom_eps'] + else: + custom_eps = 1e-4 + + # Compare Ie results with Framework results + fw_eps = custom_eps if precision == 'FP32' else 5e-2 + assert self.compare_ie_results_with_framework(infer_res=infer_res, framework_res=fw_res, + mapping_dict=mapping_dict, framework_eps=fw_eps), \ + "Comparing with Framework failed: ie_res={}; framework_res={}.".format(infer_res, fw_res) + + # Feed dict for each input is filled with random number. + # It is possible to redefine this function and generate your own input + def _prepare_input(self, inputs_dict): + for input in inputs_dict.keys(): + inputs_dict[input] = np.random.randint(-255, 255, inputs_dict[input]).astype(np.float32) + return inputs_dict + + def compare_ie_results_with_framework(self, infer_res, framework_res, mapping_dict, framework_eps): + is_ok = True + from common.utils.common_utils import allclose + for framework_out_name in framework_res: + if framework_out_name not in mapping_dict: + raise RuntimeError("Output {} not found in mapping file!".format(framework_out_name)) + + ie_out_name = mapping_dict[framework_out_name] + + if not allclose(infer_res[ie_out_name], framework_res[framework_out_name], atol=framework_eps, + rtol=framework_eps): + is_ok = False + print("Max diff is {}".format( + np.array(abs(infer_res[ie_out_name] - framework_res[framework_out_name])).max())) + else: + print("Accuracy validation successful!\n") + print("absolute eps: {}, relative eps: {}".format(framework_eps, framework_eps)) + return is_ok + + +def get_params(ie_device=None, precision=None): + """ + :param ie_device: list of devices + :param precision: list of precisions + """ + + ie_device_params = ie_device if ie_device else test_device + precision_params = precision if precision else test_precision + + test_args = [] + for element in itertools.product(ie_device_params, precision_params): + if element[0] == 'CPU' and element[1] == 'FP16': + continue + test_args.append(element) + return test_args + + +def check_ir_version(left, right, ir_version): + try: + _ir_version = int(ir_version) + except ValueError: + raise RuntimeError("Wrong ir version type: {}, must be an integer".format(ir_version)) + left_bound = _ir_version - 1 if left is None else left + right_bound = _ir_version + 1 if right is None else right + return left_bound <= _ir_version < right_bound diff --git a/tests/layer_tests/common/layer_utils.py b/tests/layer_tests/common/layer_utils.py new file mode 100644 index 00000000000000..a933ac719aa2b3 --- /dev/null +++ b/tests/layer_tests/common/layer_utils.py @@ -0,0 +1,58 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import subprocess +import sys + +from common.utils.multiprocessing_utils import multiprocessing_run + + +def shell(cmd, env=None, cwd=None): + if sys.platform.startswith('linux') or sys.platform == 'darwin': + cmd = ['/bin/bash', '-c', "".join(cmd)] + else: + cmd = "".join(cmd) + p = subprocess.Popen(cmd, cwd=cwd, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + (stdout, stderr) = p.communicate() + return p.returncode, stdout, stderr + + +class BaseInfer: + def __init__(self, name): + self.name = name + self.res = None + + def fw_infer(self, input_data): + raise RuntimeError("This is base class, please implement infer function for the specific framework") + + def infer(self, input_data): + self.res = multiprocessing_run(self.fw_infer, [input_data], self.name, timeout=60) + return self.res + + +class IEInfer(BaseInfer): + def __init__(self, model, weights, device): + super().__init__('Inference Engine') + self.device = device + self.model = model + self.weights = weights + + def fw_infer(self, input_data): + from openvino.inference_engine import IECore, get_version as ie_get_version + + print("Inference Engine version: {}".format(ie_get_version())) + print("Creating IE Core Engine...") + ie = IECore() + print("Reading network files") + net = ie.read_network(self.model, self.weights) + print("Loading network") + exec_net = ie.load_network(net, self.device) + print("Starting inference") + result = exec_net.infer(input_data) + + if "exec_net" in locals(): + del exec_net + if "ie" in locals(): + del ie + + return result diff --git a/tests/layer_tests/common/onnx_layer_test_class.py b/tests/layer_tests/common/onnx_layer_test_class.py new file mode 100644 index 00000000000000..ff97718f1c0417 --- /dev/null +++ b/tests/layer_tests/common/onnx_layer_test_class.py @@ -0,0 +1,63 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import os + +from common.layer_test_class import CommonLayerTest +from common.layer_utils import BaseInfer + + +def save_to_onnx(onnx_model, path_to_saved_onnx_model): + import onnx + path = os.path.join(path_to_saved_onnx_model, 'model.onnx') + onnx.save(onnx_model, path) + assert os.path.isfile(path), "model.onnx haven't been saved here: {}".format(path_to_saved_onnx_model) + return path + + +class Caffe2OnnxLayerTest(CommonLayerTest): + def produce_model_path(self, framework_model, save_path): + return save_to_onnx(framework_model, save_path) + + def get_framework_results(self, inputs_dict, model_path): + # Evaluate model via Caffe2 and IE + # Load the ONNX model + import onnx + model = onnx.load(model_path) + # Run the ONNX model with Caffe2 + import caffe2.python.onnx.backend + caffe2_res = caffe2.python.onnx.backend.run_model(model, inputs_dict) + res = dict() + for field in caffe2_res._fields: + res[field] = caffe2_res[field] + return res + + +class OnnxRuntimeInfer(BaseInfer): + def __init__(self, net): + super().__init__('OnnxRuntime') + self.net = net + + def fw_infer(self, input_data): + import onnxruntime as rt + + sess = rt.InferenceSession(self.net) + out = sess.run(None, input_data) + result = dict() + for i, output in enumerate(sess.get_outputs()): + result[output.name] = out[i] + + if "sess" in locals(): + del sess + + return result + + +class OnnxRuntimeLayerTest(CommonLayerTest): + def produce_model_path(self, framework_model, save_path): + return save_to_onnx(framework_model, save_path) + + def get_framework_results(self, inputs_dict, model_path): + ort = OnnxRuntimeInfer(net=model_path) + res = ort.infer(input_data=inputs_dict) + return res diff --git a/tests/layer_tests/common/tf_layer_test_class.py b/tests/layer_tests/common/tf_layer_test_class.py new file mode 100644 index 00000000000000..ab19c29e9701f8 --- /dev/null +++ b/tests/layer_tests/common/tf_layer_test_class.py @@ -0,0 +1,61 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import os + +from common.layer_test_class import CommonLayerTest + +from common.utils.tf_utils import summarize_graph + + +def save_to_pb(tf_model, path_to_saved_tf_model): + import tensorflow as tf + tf.io.write_graph(tf_model, path_to_saved_tf_model, 'model.pb', False) + assert os.path.isfile(os.path.join(path_to_saved_tf_model, 'model.pb')), "model.pb haven't been saved " \ + "here: {}".format(path_to_saved_tf_model) + return os.path.join(path_to_saved_tf_model, 'model.pb') + + +class CommonTFLayerTest(CommonLayerTest): + def produce_model_path(self, framework_model, save_path): + return save_to_pb(framework_model, save_path) + + def get_framework_results(self, inputs_dict, model_path): + # Evaluate model via Tensorflow and IE + # Load the Tensorflow model + import tensorflow as tf + from tensorflow.python.platform import gfile + + graph_summary = summarize_graph(model_path=model_path) + outputs_list = graph_summary["outputs"] + + tf.compat.v1.reset_default_graph() + + with tf.compat.v1.Session() as sess: + with gfile.FastGFile(model_path, 'rb') as f: + graph_def = tf.compat.v1.GraphDef() + graph_def.ParseFromString(f.read()) + sess.graph.as_default() + tf.compat.v1.import_graph_def(graph_def, name='') + + input = dict() + for key in inputs_dict.keys(): + data = inputs_dict.get(key) + if len(data.shape) == 4: # reshaping for 4D tensors + input[key+':0'] = data.transpose(0, 2, 3, 1) + elif len(data.shape) == 5: # reshaping for 5D tensors + input[key+':0'] = data.transpose(0, 2, 3, 4, 1) + else: + input[key+':0'] = data + tf_res = sess.run([out + ":0" for out in outputs_list], input) + + result = dict() + for i, output in enumerate(outputs_list): + _tf_res = tf_res[i] + if len(_tf_res.shape) == 4: # reshaping for 4D tensors + result[output] = _tf_res.transpose(0, 3, 1, 2) # 2, 0, 1 + elif len(_tf_res.shape) == 5: # reshaping for 5D tensors + result[output] = _tf_res.transpose(0, 4, 1, 2, 3) # 3, 0, 1, 2 + else: + result[output] = _tf_res + return result diff --git a/tests/layer_tests/common/utils/common_utils.py b/tests/layer_tests/common/utils/common_utils.py new file mode 100644 index 00000000000000..a487573afd862a --- /dev/null +++ b/tests/layer_tests/common/utils/common_utils.py @@ -0,0 +1,84 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import logging +import os +import subprocess +import sys + +import numpy as np + + +logger = logging.getLogger(__name__) + + +def generate_ir(coverage=False, **kwargs): + # Get default mo args + mo = os.path.join(os.environ.get("MO_ROOT"), "mo.py") + if coverage: + params = [sys.executable, '-m', 'coverage', 'run', '-p', '--source={}'.format(os.environ.get("MO_ROOT")), + '--omit=*_test.py', mo] + else: + params = [sys.executable, mo] + for key, value in kwargs.items(): + if key == "batch": + params.extend(("-b", str(value))) + elif key == "k": + params.extend(("-k", str(value))) + elif isinstance(value, bool) and value: + params.append("--{}".format(key)) + elif isinstance(value, bool) and not value: + continue + elif (isinstance(value, tuple) and value) or (isinstance(value, str)): + params.extend(("--{}".format(key), str('"{}"'.format(value)))) + elif (key == "mean_values" and (' ' in value or '(' in value)): + params.extend(("--{}".format(key), str('"{}"'.format(value)))) + else: + params.extend(("--{}".format(key), str(value))) + exit_code, stdout, stderr = shell(params) + logger.info("Model Optimizer out:\n{}".format(stdout)) + logger.error(stderr) + return exit_code, stderr + + +def shell(cmd, env=None, cwd=None, out_format="plain"): + """ + Run command execution in specified environment + :param cmd: list containing command and its parameters + :param env: set of environment variables to set for this command + :param cwd: working directory from which execute call + :param out_format: 'plain' or 'html'. If 'html' all '\n; symbols are replaced by '
' tag + :return: + """ + if sys.platform.startswith('linux') or sys.platform == 'darwin': + cmd = ['/bin/bash', '-c', "unset OMP_NUM_THREADS; " + " ".join(cmd)] + else: + cmd = " ".join(cmd) + + sys.stdout.write("Running command:\n" + "".join(cmd) + "\n") + p = subprocess.Popen(cmd, cwd=cwd, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + (stdout, stderr) = p.communicate() + stdout = str(stdout.decode('utf-8')) + stderr = str(stderr.decode('utf-8')) + if out_format == "html": + stdout = "
\n".join(stdout.split('\n')) + stderr = "
\n".join(stderr.split('\n')) + return p.returncode, stdout, stderr + + +def allclose(cur_array, ref_array, atol, rtol): + """ + Comparison of abs_diff and rel_diff with tolerances for every values of corresponding elements. + If (abs_diff < atol) or (rel_diff < rtol) for every element, comparison of elements will pass, else will fail. + Note: if value is very small, firstly abs_diff will be used. If value is huge, abs_diff may be failed, + and rel_diff will be used. So if tensor has small and huge values, need to compare every value + with abs_diff and rel_diff instead of using one of it for the whole array. + :param cur_array: tensor from IE + :param ref_array: tensor from FW + :param atol: absolute tolerance (threshold for absolute difference) + :param rtol: relative tolerance (threshold for relative difference) + :return: bool value means that values of tensors are equal with tolerance or not + """ + abs_diff = np.absolute(cur_array - ref_array) + max_val = np.maximum(np.absolute(cur_array), np.absolute(ref_array)) + return ((abs_diff < atol) | (abs_diff < rtol * max_val)).all() diff --git a/tests/layer_tests/common/utils/multiprocessing_utils.py b/tests/layer_tests/common/utils/multiprocessing_utils.py new file mode 100644 index 00000000000000..8d5293476d2ad9 --- /dev/null +++ b/tests/layer_tests/common/utils/multiprocessing_utils.py @@ -0,0 +1,99 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import logging as log +import os +import platform +import signal +import sys +import traceback +from multiprocessing import Process, Queue, TimeoutError, ProcessError +from queue import Empty as QueueEmpty +from typing import Callable, Union + +if platform.system() == "Darwin": + # Fix for MacOS + import multiprocessing + multiprocessing.set_start_method("forkserver", True) + + +def _mp_wrapped_func(func: Callable, func_args: list, queue: Queue, logger_queue: Queue): + """ + Wraps callable object with exception handling. Current wrapper is a target for + `multiprocessing_run` function + :param func: see `multiprocessing_run` + :param func_args: see `multiprocessing_run` + :param queue: multiprocessing.Queue(). Used for getting callable object return values + :param logger_queue: multiprocessing.Queue(). Used for getting logs from child process in parent process + :return: + """ + + error_message = "" + res = None + try: + res = func(*func_args) + except: + ex_type, ex_value, tb = sys.exc_info() + error_message = "{tb}\n{ex_type}: {ex_value}".format(tb=''.join(traceback.format_tb(tb)), + ex_type=ex_type.__name__, ex_value=ex_value) + queue.put((error_message, res)) + + +def multiprocessing_run(func: Callable, func_args: list, func_log_name: str, timeout: Union[int, None] = None): + """ + Wraps callable object to a separate process using multiprocessing module + :param func: callable object + :param func_args: list of arguments for callable + :param func_log_name: name of callable used for logging + :param timeout: positive int to limit execution time + :return: return value (or values) from callable object + """ + queue = Queue() + logger_queue = Queue(-1) + process = Process(target=_mp_wrapped_func, args=(func, func_args, queue, logger_queue)) + process.start() + try: + error_message, *ret_args = queue.get(timeout=timeout) + except QueueEmpty: + raise TimeoutError("{func} running timed out!".format(func=func_log_name)) + finally: + queue.close() + + # Extract logs from Queue and pass to root logger + while not logger_queue.empty(): + rec = logger_queue.get() + log.getLogger().handle(rec) + logger_queue.close() + + if process.is_alive(): + process.terminate() + process.join() + else: + exit_signal = multiprocessing_exitcode_to_signal(process.exitcode) + if exit_signal: + raise ProcessError( + "{func} was killed with a signal {signal}".format(func=func_log_name, signal=exit_signal)) + + if error_message: + raise ProcessError("\n{func} running failed: \n{msg}".format(func=func_log_name, msg=error_message)) + + ret_args = ret_args[0] if len(ret_args) == 1 else ret_args # unwrap from list if only 1 item is returned + return ret_args + + +def multiprocessing_exitcode_to_signal(exitcode): + """ + Map multiprocessing exitcode to signals from "signal" module + :param exitcode: multiprocessing exitcode + :return: signal from "signal" if exitcode mapped on signal or None + """ + # Multiprocessing return negative values of signal of the process, but on Win they are positive. + # Bring the value to the positive format. + exit_code = exitcode if os.name == "nt" else -exitcode + if exit_code > 0: + code_map = {int(getattr(signal, sig)): str(getattr(signal, sig)) + for sig in dir(signal) if sig.startswith("SIG")} + exit_signal = code_map[exit_code] if exit_code in code_map else exit_code + else: + exit_signal = None + return exit_signal diff --git a/tests/layer_tests/common/utils/parsers.py b/tests/layer_tests/common/utils/parsers.py new file mode 100644 index 00000000000000..e5e97727c6a3b3 --- /dev/null +++ b/tests/layer_tests/common/utils/parsers.py @@ -0,0 +1,28 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import os +import xml.etree.ElementTree + + +def mapping_parser(file): + """ + Parse mapping file if it exists + :param file: Name of mapping file + :return: Dictionary with framework layers as keys and IR layers as values + """ + mapping_dict = {} + if os.path.splitext(file)[1] == '.mapping' and os.path.isfile(file): + xml_tree = xml.etree.ElementTree.parse(file) + xml_root = xml_tree.getroot() + for child in xml_root: + framework_info = child.find('.//framework') + ir_info = child.find('.//IR') + if framework_info is None: + continue + framework_name = framework_info.attrib['name'] + ir_name = ir_info.attrib['name'] if ir_info is not None else None + mapping_dict[framework_name] = ir_name + else: + raise FileNotFoundError("Mapping file was not found at path {}!".format(os.path.dirname(file))) + return mapping_dict diff --git a/tests/layer_tests/common/utils/tf_utils.py b/tests/layer_tests/common/utils/tf_utils.py new file mode 100644 index 00000000000000..7900586390cc1d --- /dev/null +++ b/tests/layer_tests/common/utils/tf_utils.py @@ -0,0 +1,109 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import os +import re + +import tensorflow as tf +import numpy as np + + +os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' + + +def load_graph(model_file, output_nodes_for_freeze=None): + is_meta = os.path.splitext(model_file)[-1] == ".meta" + + tf.compat.v1.reset_default_graph() + graph = tf.Graph() + graph_def = tf.compat.v1.GraphDef() if not is_meta else tf.compat.v1.MetaGraphDef() + + with open(model_file, "rb") as f: + graph_def.ParseFromString(f.read()) + + nodes_to_clear_device = graph_def.node if isinstance(graph_def, tf.compat.v1.GraphDef) else graph_def.graph_def.node + for node in nodes_to_clear_device: + node.device = "" + + if is_meta: + with tf.compat.v1.Session() as sess: + restorer = tf.compat.v1.train.import_meta_graph(graph_def) + restorer.restore(sess, re.sub('\.meta$', '', model_file)) + graph_def = tf.compat.v1.graph_util.convert_variables_to_constants(sess, graph_def.graph_def, output_nodes_for_freeze) + + with graph.as_default(): + tf.import_graph_def(graph_def, name='') + + return graph + + +def collect_tf_references(model_path, feed_dict, out_layer, output_nodes_for_freeze=None): + _feed_dict = dict() + + graph = load_graph(model_path, output_nodes_for_freeze) + output_tensors_list = list() + outputs_list = list() + for input in feed_dict: + input_node = [node for node in graph.as_graph_def().node if node.name == input][0] + if input_node.op == "Placeholder": + tensor = graph.get_tensor_by_name(input + ":0") + _feed_dict[tensor] = feed_dict[input] + else: + for parrent_input in input_node.input: + in_node = [node for node in graph.as_graph_def().node if node.name == parrent_input][0] + if in_node.op in ['Const', 'Assign', 'NoOp', 'Assert']: + continue + else: + tensor = graph.get_tensor_by_name(parrent_input + ":0") + _feed_dict[tensor] = feed_dict[input] + + for output in out_layer: + tensor = graph.get_tensor_by_name(output + ":0") + output_tensors_list.append(tensor) + outputs_list.append(output) + with graph.as_default(): + with tf.compat.v1.Session(graph=graph) as sess: + outputs = sess.run(output_tensors_list, feed_dict=_feed_dict) + out_dict = dict(zip(outputs_list, outputs)) + return out_dict + + +def children(op, graph): + op = graph.get_operation_by_name(op) + return set(op for out in op.outputs for op in out.consumers()) + + +def summarize_graph(model_path, output_nodes_for_freeze=None, reshape_net=None): + placeholders = dict() + variables = list() + outputs = list() + graph = load_graph(model_path, output_nodes_for_freeze) + unlikely_output_types = ['Const', 'Assign', 'NoOp', 'Placeholder', 'Assert', 'switch_t', 'switch_f'] + for node in graph.as_graph_def().node: + if node.op == 'Placeholder': + node_dict = dict() + node_dict['type'] = tf.DType(node.attr['dtype'].type).name + node_dict['shape'] = str(node.attr['shape'].shape.dim).replace('\n', '').replace(' ', '').replace( + 'size:', '').replace('[', '').replace(']', '') + node_dict['shape'] = tuple(map(lambda x: int(x), node_dict['shape'].split(','))) + placeholders[node.name] = node_dict + if node.op == "Variable" or node.op == "VariableV2": + variables.append(node.name) + if len(children(node.name, graph)) == 0: + if node.op not in unlikely_output_types and node.name.split('/')[-1] not in unlikely_output_types: + outputs.append(node.name) + result = dict() + result['inputs'] = placeholders + result['outputs'] = outputs + + if reshape_net: + out_layer = list(result['inputs'].keys()) + result['outputs'] + feed_dict = {} + for inputl in reshape_net: + feed_dict.update({inputl: np.ones(shape=reshape_net[inputl])}) + scoring_res = collect_tf_references(model_path=model_path, feed_dict=feed_dict, out_layer=out_layer) + for layer in scoring_res: + if layer in result['inputs']: + result['inputs'][layer]['shape'] = scoring_res[layer].shape + + return result diff --git a/tests/layer_tests/conftest.py b/tests/layer_tests/conftest.py new file mode 100644 index 00000000000000..350fd22a3b20f5 --- /dev/null +++ b/tests/layer_tests/conftest.py @@ -0,0 +1,77 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import re +from pathlib import Path +import tempfile + +import pytest +from common import constants + + +def pytest_make_parametrize_id(config, val, argname): + return " {0}:{1} ".format(argname, val) + + +def pytest_collection_modifyitems(items): + def remove_ignored_attrs(ref_dict, dict_to_upd): + _dict_to_upd = dict_to_upd.copy() + for key, value in dict_to_upd.items(): + if key not in ref_dict.keys(): + _dict_to_upd.pop(key) + elif isinstance(value, dict): + _dict_to_upd[key] = remove_ignored_attrs(ref_dict[key], value) + return _dict_to_upd + + for test in items: + special_marks = [mark for mark in test.own_markers if "special_" in mark.name] + for mark in special_marks: + if mark.name == "special_xfail": + params = test.callspec.params + # Remove items from params if key of item is not in mark.kwargs["args"]. + # Remaining items will be used to mark test cases that contain them. + # It is required to specify in mark only valuable parameters + # (e.g. {"device": "FP16"} will mean that for all test cases with FP16 test will be marked) + params = remove_ignored_attrs(mark.kwargs["args"], params) + if mark.kwargs["args"] == params: + test.add_marker(pytest.mark.xfail(reason=mark.kwargs["reason"])) + + +@pytest.mark.hookwrapper +def pytest_runtest_makereport(item, call): + pytest_html = item.config.pluginmanager.getplugin('html') + outcome = yield + report = outcome.get_result() + extra = getattr(report, 'extra', []) + if report.when == 'call': + xfail_reason = getattr(report, 'wasxfail', None) + if report.skipped and xfail_reason: + jira_ticket_nums = re.findall(r"\*-\d+", xfail_reason) + for ticket_num in jira_ticket_nums: + extra.append(pytest_html.extras.url(ticket_num)) + report.extra = extra + + +def pytest_addoption(parser): + """Specify command-line options for all plugins""" + parser.addoption( + "--ir_version", + required=True, + action="store", + help="Version of IR to generate by Model Optimizer") + + +@pytest.fixture(scope="session") +def ir_version(request): + """Fixture function for command-line option.""" + return request.config.getoption('ir_version') + + +@pytest.fixture(scope="function") +def temp_dir(request): + """Create directory for test purposes.""" + Path(constants.out_path).mkdir(parents=True, exist_ok=True) + test_name = re.sub(r"[^\w_]", "_", request.node.originalname) + device = request.node.funcargs["ie_device"].upper() + temp_dir = tempfile.TemporaryDirectory(dir=constants.out_path, prefix=f"{device}_{test_name}") + yield str(temp_dir.name) diff --git a/tests/layer_tests/onnx_tests/conftest.py b/tests/layer_tests/onnx_tests/conftest.py new file mode 100644 index 00000000000000..bbf635f56809ac --- /dev/null +++ b/tests/layer_tests/onnx_tests/conftest.py @@ -0,0 +1,12 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import inspect + +from common.layer_test_class import get_params + + +def pytest_generate_tests(metafunc): + test_gen_attrs_names = list(inspect.signature(get_params).parameters) + params = get_params() + metafunc.parametrize(test_gen_attrs_names, params, scope="function") diff --git a/tests/layer_tests/onnx_tests/test_abs.py b/tests/layer_tests/onnx_tests/test_abs.py new file mode 100644 index 00000000000000..577965df82ad68 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_abs.py @@ -0,0 +1,178 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestAbs(OnnxRuntimeLayerTest): + def create_net(self, shape, ir_version): + """ + ONNX net IR net + + Input->Abs->Output => Input->Abs + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + node_def = onnx.helper.make_node( + 'Abs', + inputs=['input'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'Abs'}, + 'node_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result') + ]) + + return onnx_net, ref_net + + def create_net_const(self, shape, precision, ir_version): + """ + ONNX net IR net + + Input->Concat(+abs const)->Output => Input->Concat(+const) + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + import numpy as np + + concat_axis = 0 + output_shape = shape.copy() + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + constant = np.random.randint(-127, 127, shape).astype(np.float) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + node_def = onnx.helper.make_node( + 'Abs', + inputs=['const'], + outputs=['abs'] + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'abs'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + constant = abs(constant) + if precision == 'FP16': + constant = constant.astype(np.float16) + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': constant.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': shape, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result') + ]) + + return onnx_net, ref_net + + test_data = [dict(shape=[10, 12]), + dict(shape=[8, 10, 12]), + dict(shape=[6, 8, 10, 12]), + dict(shape=[4, 6, 8, 10, 12])] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_abs(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_abs_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_add_sub_mul_div.py b/tests/layer_tests/onnx_tests/test_add_sub_mul_div.py new file mode 100644 index 00000000000000..9076ce8e650f11 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_add_sub_mul_div.py @@ -0,0 +1,337 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.onnx_layer_test_class import Caffe2OnnxLayerTest + + +class TestOperations(Caffe2OnnxLayerTest): + def create_net(self, shape1, shape2, op, precision, ir_version, opset=None): + """ + ONNX net IR net + + Input->Add/Mul with const->Output => Input->Eltwise + """ + + # + # Create ONNX model + # + + from onnx import helper + from onnx import TensorProto + + if op not in ['Add', 'Sub', 'Mul', 'Div']: + raise ValueError("Operation has to be either Add or Mul or Sub or Div") + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape1) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape1) + + min_val = 1 if op == 'Div' else -127 + if shape2: + const = np.random.randint(min_val, 127, shape2).astype(np.float) + else: + const = np.random.randint(min_val, 127, 1).astype(np.float) + # TODO: add check when MO remove redundant layer (as Add/Sub if const = 0 or Mul/Div if const = 1) + if const in [0, 1]: + const = np.array([2], dtype=np.float) + + node_const_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['const'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=const.shape, + vals=const.flatten(), + ), + ) + + node_def = helper.make_node( + op, + inputs=['input', 'const'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + args = dict(producer_name='test_model') + if opset: + args['opset_imports'] = [helper.make_opsetid("", opset)] + onnx_net = helper.make_model(graph_def, **args) + + # Create reference IR net + if op == 'Div': + const = np.power(const, -1) + elif op == 'Sub': + const = -const + + ref_net = None + + return onnx_net, ref_net + + def create_net_const(self, shape1, shape2, op, precision, ir_version, opset=None): + """ + ONNX net IR net + + Input->Concat with two added/multiplied consts->Output => Input->Concat + """ + + # + # Create ONNX model + # + + from onnx import helper + from onnx import TensorProto + + if op not in ['Add', 'Sub', 'Mul', 'Div']: + raise ValueError("op has to be either Add or Mul") + + concat_axis = 0 + output_shape = list(shape1) + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape1) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + const1 = np.random.randint(-127, 127, shape1).astype(np.float) + min_val = 1 if op == 'Div' else -127 + if shape2: + const2 = np.random.randint(min_val, 127, shape2).astype(np.float) + else: + const2 = np.random.randint(min_val, 127, 1).astype(np.float) + + node_const1_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=const1.shape, + vals=const1.flatten(), + ), + ) + + node_const2_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['const2'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=const2.shape, + vals=const2.flatten(), + ), + ) + + node_def = helper.make_node( + op, + inputs=['const1', 'const2'], + outputs=['node_out'] + ) + + node_concat_def = helper.make_node( + 'Concat', + inputs=['input', 'node_out'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const1_def, node_const2_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + args = dict(producer_name='test_model') + if opset: + args['opset_imports'] = [helper.make_opsetid("", opset)] + onnx_net = helper.make_model(graph_def, **args) + + # Create reference IR net + if op == 'Add': + constant_calculated = np.add(const1, const2) + elif op == 'Sub': + constant_calculated = np.subtract(const1, const2) + elif op == 'Mul': + constant_calculated = np.multiply(const1, const2) + elif op == 'Div': + constant_calculated = np.divide(const1, const2) + + if precision == 'FP16': + constant_calculated = constant_calculated.astype(np.float16) + + ref_net = None + + return onnx_net, ref_net + + test_data_precommit = [dict(shape1=[2, 4], shape2=[2, 4]), + # scalar cases + dict(shape1=[2, 4], shape2=None)] + + test_data = [dict(shape1=[4, 6], shape2=[4, 6]), + dict(shape1=[4, 6, 8], shape2=[4, 6, 8]), + dict(shape1=[4, 6, 8, 10], shape2=[4, 6, 8, 10]), + dict(shape1=[4, 6, 8, 10, 12], shape2=[4, 6, 8, 10, 12]), + # scalar cases + dict(shape1=[4, 6], shape2=None), + dict(shape1=[4, 6, 8], shape2=None), + dict(shape1=[4, 6, 8, 10], shape2=None), + dict(shape1=[4, 6, 8, 10, 12], shape2=None)] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_add(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, op='Add', precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_add_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, op='Add', precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_sub(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, op='Sub', precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_sub_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, op='Sub', precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_mul(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, op='Mul', precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_mul_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, op='Mul', precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_div(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, op='Div', precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_div_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, op='Div', precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_add_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, op='Add', precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_add_const_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, op='Add', precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_sub_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, op='Sub', precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_sub_const_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, op='Sub', precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_mul_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, op='Mul', precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_mul_const_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, op='Mul', precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_div_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, op='Div', precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_div_const_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, op='Div', precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_add_opset6(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, op='Add', precision=precision, opset=6, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_add_const_opset6(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, op='Add', precision=precision, opset=6, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_sub_opset6(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, op='Sub', precision=precision, opset=6, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_sub_const_opset6(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, op='Sub', precision=precision, opset=6, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_mul_opset6(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, op='Mul', precision=precision, opset=6, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_mul_const_opset6(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, op='Mul', precision=precision, opset=6, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_div_opset6(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, op='Div', precision=precision, opset=6, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_div_const_opset6(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, op='Div', precision=precision, opset=6, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_and.py b/tests/layer_tests/onnx_tests/test_and.py new file mode 100644 index 00000000000000..115fe1e706dd1c --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_and.py @@ -0,0 +1,268 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestAnd(OnnxRuntimeLayerTest): + def _prepare_input(self, inputs_dict): + for input in inputs_dict.keys(): + inputs_dict[input] = np.random.randint(0, 2, inputs_dict[input]).astype(np.bool) + return inputs_dict + + def create_net(self, shape1, shape2, ir_version): + """ + ONNX net IR net + + Input->And with 2nd input->Output => Input->LogicalAnd + """ + + # + # Create ONNX model + # + + from onnx import helper + from onnx import TensorProto + + input1 = helper.make_tensor_value_info('input1', TensorProto.BOOL, shape1) + input2 = helper.make_tensor_value_info('input2', TensorProto.BOOL, shape2) + output = helper.make_tensor_value_info('output', TensorProto.BOOL, shape1) + + node_def = helper.make_node( + 'And', + inputs=['input1', 'input2'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input1, input2], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # Create reference IR net + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input1': {'kind': 'op', 'type': 'Parameter'}, + 'input1_data': {'shape': shape1, 'kind': 'data'}, + 'input2': {'kind': 'op', 'type': 'Parameter'}, + 'input2_data': {'shape': shape2, 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'LogicalAnd'}, + 'node_data': {'shape': shape1, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input1', 'input1_data'), + ('input2', 'input2_data'), + ('input1_data', 'node'), + ('input2_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result')]) + + return onnx_net, ref_net + + def create_net_one_const(self, shape1, shape2, ir_version): + """ + ONNX net IR net + + Input->And with const->Output => Input->LogicalAnd + """ + + # + # Create ONNX model + # + + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.BOOL, shape1) + output = helper.make_tensor_value_info('output', TensorProto.BOOL, shape1) + + const = np.random.randint(0, 2, shape2).astype(np.bool) + + node_const_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['const'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.BOOL, + dims=const.shape, + vals=const.flatten(), + ), + ) + + node_def = helper.make_node( + 'And', + inputs=['input', 'const'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # Create reference IR net + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape1, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': const.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': const.shape, 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'LogicalAnd'}, + 'node_data': {'shape': shape1, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'node'), + ('const_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result')]) + + return onnx_net, ref_net + + def create_net_const(self, shape1, shape2, ir_version): + """ + ONNX net IR net + + Input->Concat with const and const->Output => Input->Concat + """ + + # + # Create ONNX model + # + + from onnx import helper + from onnx import TensorProto + + concat_axis = 0 + output_shape = list(shape1) + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.BOOL, shape1) + output = helper.make_tensor_value_info('output', TensorProto.BOOL, output_shape) + + const1 = np.random.randint(0, 2, shape1).astype(np.bool) + const2 = np.random.randint(0, 2, shape2).astype(np.bool) + + node_const1_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.BOOL, + dims=const1.shape, + vals=const1.flatten(), + ), + ) + + node_const2_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['const2'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.BOOL, + dims=const2.shape, + vals=const2.flatten(), + ), + ) + + node_def = helper.make_node( + 'And', + inputs=['const1', 'const2'], + outputs=['node_out'] + ) + + node_concat_def = helper.make_node( + 'Concat', + inputs=['input', 'node_out'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const1_def, node_const2_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # Create reference IR net + constant_calculated = np.logical_and(const1, const2) + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': const1.shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': constant_calculated.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': const1.shape, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result')]) + + return onnx_net, ref_net + + test_data = [dict(shape1=[4, 6], shape2=[4, 6]), + dict(shape1=[4, 6, 8], shape2=[4, 6, 8]), + dict(shape1=[4, 6, 8, 10], shape2=[4, 6, 8, 10]), + dict(shape1=[4, 6, 8, 10, 12], shape2=[4, 6, 8, 10, 12])] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_and(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_and_one_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_one_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_and_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_argmax.py b/tests/layer_tests/onnx_tests/test_argmax.py new file mode 100644 index 00000000000000..476a06d187b7e6 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_argmax.py @@ -0,0 +1,153 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestArgMax(OnnxRuntimeLayerTest): + def create_net(self, shape, axis, keepdims, ir_version): + """ + ONNX net IR net + + Input->ArgMax->Output => Input->TopK + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + output_shape = shape.copy() + output_shape[axis if axis is not None else 0] = 1 + output_shape_squeeze = output_shape.copy() + if keepdims == 0: + output_shape_squeeze.remove(1) + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.INT64, output_shape_squeeze) + + const = np.random.randint(-10, 10, output_shape_squeeze).astype(np.int64) + + args = dict() + if axis is not None: + args['axis'] = axis + else: + axis = 0 + if keepdims is not None: + args['keepdims'] = keepdims + node_def = onnx.helper.make_node( + 'ArgMax', + inputs=['input'], + outputs=['argmax' if keepdims is None or keepdims == 1 else 'output'], + **args + ) + edges = [node_def] + + if keepdims is None or keepdims == 1: + node_flatten_def = onnx.helper.make_node( + 'Flatten', + inputs=['argmax'], + outputs=['output'] + ) + edges.append(node_flatten_def) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + edges, + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'const_indata': {'shape': [1], 'kind': 'data'}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': [], 'kind': 'data'}, # TODO shape [] or [1] ?? + 'node': {'kind': 'op', 'type': 'TopK'}, + 'node_data': {'shape': output_shape, 'kind': 'data'}, + 'indices_data': {'shape': output_shape, 'kind': 'data'}, + 'result1': {'kind': 'op', 'type': 'Result'}, + 'result2': {'kind': 'op', 'type': 'Result'} + } + edges = [('input', 'input_data'), + ('const_indata', 'const'), + ('const', 'const_data'), + ('input_data', 'node'), + ('const_data', 'node'), + ('node', 'node_data'), + ('node', 'indices_data'), + ('node_data', 'result1')] + if keepdims == 0: + nodes_attributes.update({'squeeze_const_indata': {'shape': [1], 'kind': 'data'}, + 'squeeze_const': {'kind': 'op', 'type': 'Const'}, + 'squeeze_const_data': {'shape': [1], 'kind': 'data'}, + 'squeeze': {'kind': 'op', 'type': 'Squeeze'}, + 'squeeze_data': {'shape': output_shape_squeeze, 'kind': 'data'} + }) + edges.extend([('squeeze_const_indata', 'squeeze_const'), + ('squeeze_const', 'squeeze_const_data'), + ('indices_data', 'squeeze'), + ('squeeze_const_data', 'squeeze'), + ('squeeze', 'squeeze_data'), + ('squeeze_data', 'result2')]) + else: + nodes_attributes.update( + {'flatten_const_indata': {'kind': 'data', 'value': [0, -1]}, + 'flatten_const': {'kind': 'op', 'type': 'Const'}, + 'flatten_const_data': {'shape': [2], 'kind': 'data'}, + 'flatten': {'kind': 'op', 'type': 'Reshape'}, + 'flatten_data': {'shape': [output_shape_squeeze[0], np.prod(output_shape_squeeze[1:])], + 'kind': 'data'} + }) + edges.extend([('indices_data', 'flatten'), + ('flatten_const_indata', 'flatten_const'), + ('flatten_const', 'flatten_const_data'), + ('flatten_const_data', 'flatten'), + ('flatten', 'flatten_data'), + ('flatten_data', 'result2')]) + + ref_net = build_graph(nodes_attributes, edges) + + return onnx_net, ref_net + + test_data = [ + dict(shape=[10, 12], axis=None), + dict(shape=[10, 12], axis=1), + dict(shape=[8, 10, 12], axis=None), + dict(shape=[8, 10, 12], axis=1), + dict(shape=[8, 10, 12], axis=2), + dict(shape=[6, 8, 10, 12], axis=None), + dict(shape=[6, 8, 10, 12], axis=1), + dict(shape=[6, 8, 10, 12], axis=2), + dict(shape=[6, 8, 10, 12], axis=3), + dict(shape=[4, 6, 8, 10, 12], axis=None), + dict(shape=[4, 6, 8, 10, 12], axis=1), + dict(shape=[4, 6, 8, 10, 12], axis=2), + dict(shape=[4, 6, 8, 10, 12], axis=3), + dict(shape=[4, 6, 8, 10, 12], axis=4)] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.parametrize("keepdims", [None, 0]) + @pytest.mark.nightly + def test_argmax(self, params, keepdims, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version, keepdims=keepdims), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_bn.py b/tests/layer_tests/onnx_tests/test_bn.py new file mode 100644 index 00000000000000..fb916f4a9aaae0 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_bn.py @@ -0,0 +1,133 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.onnx_layer_test_class import Caffe2OnnxLayerTest + + +class TestBatchNormalization(Caffe2OnnxLayerTest): + def create_net(self, shape, epsilon, precision, ir_version, opset=None): + """ + ONNX net IR net + + Input->BatchNormalization->Output => Input->ScaleShift(Power) + """ + + # + # Create ONNX model + # + + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + scale_const = np.random.randint(128, 256, shape[1]).astype(np.float32) / 128. + bias_const = np.random.randint(0, 128, shape[1]).astype(np.float32) / 128. + mean_const = np.random.randint(-127, 127, shape[1]).astype(np.float32) + var_const = np.random.randint(128, 256, shape[1]).astype(np.float32) / 128. + + node_scale_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['scale_const'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=scale_const.shape, + vals=scale_const.flatten(), + ), + ) + + node_bias_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['bias'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=bias_const.shape, + vals=bias_const.flatten(), + ), + ) + + node_mean_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['mean'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=mean_const.shape, + vals=mean_const.flatten(), + ), + ) + + node_var_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['var'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=var_const.shape, + vals=var_const.flatten(), + ), + ) + + args = dict(epsilon=epsilon) + if opset == 6: + args['is_test'] = 1; + node_def = helper.make_node( + 'BatchNormalization', + inputs=['input', 'scale_const', 'bias', 'mean', 'var'], + outputs=['output'], + **args + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_scale_def, node_bias_def, node_mean_def, node_var_def, node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + args = dict(producer_name='test_model') + if opset: + args['opset_imports'] = [helper.make_opsetid("", opset)] + onnx_net = helper.make_model(graph_def, **args) + + # + # Create reference IR net + # + + ref_net = None + + return onnx_net, ref_net + + test_data = [dict(shape=[1, 1, 4, 6], epsilon=0.001), + dict(shape=[1, 2, 4, 6], epsilon=0.001), + dict(shape=[2, 3, 4, 6], epsilon=0.001)] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_bn(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_bn_opset6(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, precision=precision, opset=6, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_bn_opset7(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, precision=precision, opset=7, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_ceil.py b/tests/layer_tests/onnx_tests/test_ceil.py new file mode 100644 index 00000000000000..cde48393375ead --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_ceil.py @@ -0,0 +1,194 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestCeil(OnnxRuntimeLayerTest): + def create_net(self, shape, ir_version): + """ + ONNX net IR net + + Input->Ceil->Output => Input->Ceiling + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + node_def = onnx.helper.make_node( + 'Ceil', + inputs=['input'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'Ceiling'}, + 'node_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result') + ]) + + return onnx_net, ref_net + + def create_net_const(self, shape, precision, ir_version): + """ + ONNX net IR net + + Input->Concat(+ceil const)->Output => Input->Concat(+const) + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + import numpy as np + + concat_axis = 0 + output_shape = shape.copy() + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + constant = np.random.randn(*shape).astype(np.float) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + node_def = onnx.helper.make_node( + 'Ceil', + inputs=['const1'], + outputs=['floor'] + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'floor'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + constant = np.ceil(constant) + if precision == 'FP16': + constant = constant.astype(np.float16) + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': constant.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': shape, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result') + ]) + + return onnx_net, ref_net + + test_data_precommit = [dict(shape=[2, 4, 6, 8, 10])] + + test_data = [ + dict(shape=[1, 2]), + dict(shape=[2, 4, 6]), + dict(shape=[2, 4, 6, 8]), + dict(shape=[2, 4, 6, 8, 10])] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_ceil_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_ceil_const_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_ceil(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_ceil_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_clip.py b/tests/layer_tests/onnx_tests/test_clip.py new file mode 100644 index 00000000000000..94b55bf80ef53e --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_clip.py @@ -0,0 +1,169 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestClip(OnnxRuntimeLayerTest): + def create_net(self, shape, ir_version, opset, min=None, max=None): + """ + ONNX net IR net + + Input->Clip->Output => Input->Clamp + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + nodes = [] + if opset < 11: + args = dict() + if min is not None: + args['min'] = min + if max is not None: + args['max'] = max + node_def = onnx.helper.make_node( + 'Clip', + inputs=['input'], + outputs=['output'], + **args + ) + nodes.append(node_def) + else: + clip_inputs = ['input'] + if min is not None: + node_min_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['min_const'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=[], + vals=[min], + ), + ) + clip_inputs.append('min_const') + nodes.append(node_min_def) + else: + clip_inputs.append('') + if max is not None: + node_max_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['max_const'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=[], + vals=[max], + ), + ) + clip_inputs.append('max_const') + nodes.append(node_max_def) + node_def = onnx.helper.make_node( + 'Clip', + inputs=clip_inputs, + outputs=['output'] + ) + nodes.append(node_def) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + nodes, + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + args = dict(producer_name='test_model') + if opset: + args['opset_imports'] = [helper.make_opsetid("", opset)] + onnx_net = helper.make_model(graph_def, **args) + + # + # Create reference IR net + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + if opset < 11 or min is not None and max is not None: + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'Clamp', + 'min': min if min is not None else -3.4028235e+38, + 'max': max if max is not None else 3.4028235e+38}, + 'node_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result') + ]) + else: + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': [min] if min is not None else [max]}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': [], 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'Minimum' if max is not None else 'Maximum'}, + 'node_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'node'), + ('const_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result') + ]) + + return onnx_net, ref_net + + test_data = [dict(shape=[12], min=-3.5), + dict(shape=[12], max=3.5), + dict(shape=[12], min=-3.5, max=3.5), + dict(shape=[10, 12], min=-3.5), + dict(shape=[10, 12], max=3.5), + dict(shape=[10, 12], min=-3.5, max=3.5), + dict(shape=[8, 10, 12], min=-3.5), + dict(shape=[8, 10, 12], max=3.5), + dict(shape=[8, 10, 12], min=-3.5, max=3.5), + dict(shape=[6, 8, 10, 12], min=-3.5), + dict(shape=[6, 8, 10, 12], max=3.5), + dict(shape=[6, 8, 10, 12], min=-3.5, max=3.5), + dict(shape=[4, 6, 8, 10, 12], min=-3.5), + dict(shape=[4, 6, 8, 10, 12], max=3.5), + dict(shape=[4, 6, 8, 10, 12], min=-3.5, max=3.5)] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_clip_opset6(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version, opset=6), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_clip_opset11(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version, opset=11), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_concat.py b/tests/layer_tests/onnx_tests/test_concat.py new file mode 100644 index 00000000000000..1321ccda5b9c1c --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_concat.py @@ -0,0 +1,225 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import Caffe2OnnxLayerTest +from unit_tests.utils.graph import build_graph + + +class TestConcat(Caffe2OnnxLayerTest): + # TODO Add test with default values (axis=0) + def create_concat_net_const(self, input_shape, output_shape, axis, ir_version): + """ + ONNX net IR net + + Input(const)----->Concat--------->Concat->Output => Input--->Concat + Input(const)-----' ' Const---' + Input-' + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + import numpy as np + + concat_axis = 0 + concat_output_shape = output_shape.copy() + concat_output_shape[concat_axis] *= 2 + + const_number = np.prod(input_shape) + constant = np.random.randint(-127, 127, const_number).astype(np.float) + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, output_shape) + + # Output for concat + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, concat_output_shape) + + node_const1_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const1_tensor', + data_type=TensorProto.FLOAT, + dims=input_shape, + vals=constant, + ), + ) + + node_const2_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const2'], + value=helper.make_tensor( + name='const2_tensor', + data_type=TensorProto.FLOAT, + dims=input_shape, + vals=constant, + ), + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['const1', 'const2'], + outputs=['output_concat'], + axis=axis + ) + + node_dyn_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'output_concat'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const1_def, node_const2_def, node_concat_def, node_dyn_concat_def], + 'test_concat_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_split_model') + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + constant_reshape = np.reshape(constant, input_shape) + constant_reshape = np.concatenate([constant_reshape, constant_reshape], axis=axis) + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': output_shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': constant_reshape.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': output_shape, 'value': None, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': concat_output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result') + ]) + + return onnx_net, ref_net + + test_data_3D = [ + dict(input_shape=[1, 50, 50], + output_shape=[2, 50, 50], + axis=0), + + dict(input_shape=[2, 50, 50], + output_shape=[2, 100, 50], + axis=1), + + dict(input_shape=[4, 50, 50], + output_shape=[4, 50, 100], + axis=2), + ] + + test_data_4D_precommit = [ + dict(input_shape=[1, 32, 800, 800], + output_shape=[2, 32, 800, 800], + axis=0) + ] + + test_data_4D = [ + dict(input_shape=[1, 32, 800, 800], + output_shape=[2, 32, 800, 800], + axis=0), + + dict(input_shape=[4, 32, 80, 80], + output_shape=[4, 64, 80, 80], + axis=1), + + dict(input_shape=[2, 21, 80, 80], + output_shape=[2, 21, 160, 80], + axis=2), + + dict(input_shape=[3, 21, 80, 80], + output_shape=[3, 21, 80, 160], + axis=3), + ] + + test_data_5D_precommit = [ + dict(input_shape=[1, 50, 50, 80, 60], + output_shape=[2, 50, 50, 80, 60], + axis=0), + + dict(input_shape=[1, 50, 50, 80, 60], + output_shape=[1, 50, 50, 80, 120], + axis=4), + ] + + test_data_5D = [ + dict(input_shape=[1, 50, 50, 80, 60], + output_shape=[2, 50, 50, 80, 60], + axis=0), + + dict(input_shape=[1, 50, 50, 80, 60], + output_shape=[1, 100, 50, 80, 60], + axis=1), + + dict(input_shape=[1, 50, 50, 80, 60], + output_shape=[1, 50, 100, 80, 60], + axis=2), + + dict(input_shape=[1, 50, 50, 80, 60], + output_shape=[1, 50, 50, 160, 60], + axis=3), + + dict(input_shape=[1, 50, 50, 80, 60], + output_shape=[1, 50, 50, 80, 120], + axis=4), + ] + + @pytest.mark.parametrize("params", test_data_3D) + @pytest.mark.nightly + def test_concat_3D_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_concat_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_4D_precommit) + @pytest.mark.precommit + def test_concat_4D_const_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_concat_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + def test_concat_4D_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_concat_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_5D_precommit) + @pytest.mark.nightly + def test_concat_5D_const_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_concat_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.nightly + def test_concat_5D_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_concat_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_conv.py b/tests/layer_tests/onnx_tests/test_conv.py new file mode 100644 index 00000000000000..94774be4af9345 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_conv.py @@ -0,0 +1,413 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import os + +import numpy as np +import pytest +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestConv(OnnxRuntimeLayerTest): + def _prepare_input(self, inputs_dict): + for input in inputs_dict.keys(): + inputs_dict[input] = np.random.randn(*inputs_dict[input]).astype(np.float32) + return inputs_dict + + def create_net(self, shape, weights_shape, dilations, group, pads, strides, bias, ir_version, auto_pad=None): + """ + ONNX net IR net + + Input->Conv->Output => Input->Convolution + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + output_shape = np.array(shape) + output_shape[1] = group + _pads = np.array(pads).reshape([2, -1]) + kernel_extent = np.array(dilations) * (np.array(weights_shape[2:]) - 1) + 1 + spatial_val_wo_stride = shape[2:] + np.add(_pads[0, :], _pads[1, :]) - kernel_extent + output_shape[2:] = (spatial_val_wo_stride.astype(np.float) / strides + 1).astype(np.int64) + output_shape = output_shape.astype(np.int).tolist() + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + weights_const = np.random.randn(*weights_shape).astype(np.float32) + + node_weights_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['weights'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=weights_const.shape, + vals=weights_const.flatten(), + ), + ) + + conv_args = dict(kernel_shape=weights_shape[2:], + dilations=dilations, + group=group, + strides=strides) + if pads and auto_pad not in ['SAME_UPPER', 'SAME_LOWER']: + conv_args['pads'] = pads + if auto_pad: + conv_args['auto_pad'] = auto_pad + if bias: + bias_const = np.random.randint(-10, 10, weights_shape[0]).astype(np.float32) + + node_bias_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['bias'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=bias_const.shape, + vals=bias_const.flatten(), + ), + ) + node_def = onnx.helper.make_node( + 'Conv', + inputs=['input', 'weights', 'bias'], + outputs=['output'], + **conv_args + ) + nodes = [node_weights_def, node_bias_def, node_def] + else: + node_def = onnx.helper.make_node( + 'Conv', + inputs=['input', 'weights'], + outputs=['output'], + **conv_args + ) + nodes = [node_weights_def, node_def] + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + nodes, + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + if len(shape) == 3: + input_shape = shape.copy() + input_shape.insert(2, 1) + node_shape = output_shape.copy() + node_shape.insert(2, 1) + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'before_shape_const_indata': {'shape': [len(input_shape)], 'value': input_shape, 'kind': 'data'}, + 'before_shape_const': {'kind': 'op', 'type': 'Const'}, + 'before_shape_const_data': {'shape': [len(input_shape)], 'kind': 'data'}, + 'reshape_before': {'kind': 'op', 'type': 'Reshape'}, + 'reshape_before_data': {'shape': input_shape, 'kind': 'data'}, + 'kernel_indata': {'kind': 'data', 'shape': [len(weights_const.flatten())]}, + 'kernel': {'kind': 'op', 'type': 'Const'}, + 'kernel_data': {'kind': 'data', 'value': None}, + 'node': {'kind': 'op', 'type': 'Convolution' if group == 1 else 'GroupConvolution', + 'dilations': [1, dilations[0]], + 'pads_begin': [0, _pads[0, 0]], 'pads_end': [0, _pads[1, 0]]}, + 'node_data': {'shape': node_shape, 'kind': 'data'}, + 'after_shape_const_indata': {'shape': [len(output_shape)], 'value': output_shape, 'kind': 'data'}, + 'after_shape_const': {'kind': 'op', 'type': 'Const'}, + 'after_shape_const_data': {'shape': [len(output_shape)], 'kind': 'data'}, + 'reshape_after': {'kind': 'op', 'type': 'Reshape'}, + 'reshape_after_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'}} + edges = [('input', 'input_data'), + ('input_data', 'reshape_before'), + ('before_shape_const_indata', 'before_shape_const'), + ('before_shape_const', 'before_shape_const_data'), + ('before_shape_const_data', 'reshape_before'), + ('reshape_before', 'reshape_before_data'), + ('reshape_before_data', 'node'), + ('kernel_indata', 'kernel'), + ('kernel', 'kernel_data'), + ('kernel_data', 'node'), + ('node', 'node_data'), + ('node_data', 'reshape_after'), + ('after_shape_const_indata', 'after_shape_const'), + ('after_shape_const', 'after_shape_const_data'), + ('after_shape_const_data', 'reshape_after'), + ('reshape_after', 'reshape_after_data')] + if bias: + nodes_attributes.update({'const_indata': {'kind': 'data', 'value': bias_const.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'kind': 'data', 'shape': None}, + 'bias': {'type': 'Add', 'kind': 'op'}, + 'bias_data': {'kind': 'data', 'shape': output_shape}}) + edges += [('reshape_after_data', 'bias'), + ('const_indata', 'const'), + ('const', 'const_data'), + ('const_data', 'bias'), + ('bias', 'bias_data'), + ('bias_data', 'result')] + else: + edges += [('reshape_after_data', 'result')] + ref_net = build_graph(nodes_attributes, edges) + else: + _weights_shape = weights_shape.copy() + if group != 1: + _weights_shape.insert(1, 1) + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'kernel_indata': {'kind': 'data', 'value': weights_const.flatten()}, + 'kernel': {'kind': 'op', 'type': 'Const'}, + 'kernel_data': {'kind': 'data', 'shape': _weights_shape}, + 'node': {'kind': 'op', 'type': 'Convolution' if group == 1 else 'GroupConvolution', + 'dilations': dilations, 'pads_begin': _pads[0, :], 'pads_end': _pads[1, :]}, + 'node_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'}} + edges = [('input', 'input_data'), + ('input_data', 'node'), + ('kernel_indata', 'kernel'), + ('kernel', 'kernel_data'), + ('kernel_data', 'node'), + ('node', 'node_data')] + + if bias: + nodes_attributes.update({'const_indata': {'kind': 'data', 'value': bias_const.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'kind': 'data', 'shape': None}, + 'bias': {'type': 'Add', 'kind': 'op'}, + 'bias_data': {'kind': 'data', 'shape': output_shape}}) + edges += [('node_data', 'bias'), + ('const_indata', 'const'), + ('const', 'const_data'), + ('const_data', 'bias'), + ('bias', 'bias_data'), + ('bias_data', 'result')] + else: + edges += [('node_data', 'result')] + + ref_net = build_graph(nodes_attributes, edges) + + return onnx_net, ref_net + + test_data_3D = [ + dict(weights_shape=[1, 3, 3], group=1), + dict(weights_shape=[1, 3, 5], group=1), + dict(weights_shape=[3, 1, 3], group=3), + dict(weights_shape=[3, 1, 5], group=3)] + + test_data_3D_autopad = [ + dict(weights_shape=[1, 3, 3], group=1, pads=[1, 1], strides=[1], dilations=[1]), + dict(weights_shape=[1, 3, 3], group=1, pads=[2, 2], strides=[1], dilations=[2]), + dict(weights_shape=[1, 3, 3], group=1, pads=[1, 1], strides=[2], dilations=[1]), + dict(weights_shape=[1, 3, 3], group=1, pads=[2, 2], strides=[2], dilations=[2]), + dict(weights_shape=[1, 3, 5], group=1, pads=[2, 2], strides=[1], dilations=[1]), + dict(weights_shape=[1, 3, 5], group=1, pads=[4, 4], strides=[1], dilations=[2]), + dict(weights_shape=[1, 3, 5], group=1, pads=[2, 2], strides=[2], dilations=[1]), + dict(weights_shape=[1, 3, 5], group=1, pads=[4, 4], strides=[2], dilations=[2]), + dict(weights_shape=[3, 1, 3], group=3, pads=[1, 1], strides=[1], dilations=[1]), + dict(weights_shape=[3, 1, 3], group=3, pads=[2, 2], strides=[1], dilations=[2]), + dict(weights_shape=[3, 1, 3], group=3, pads=[1, 1], strides=[2], dilations=[1]), + dict(weights_shape=[3, 1, 3], group=3, pads=[2, 2], strides=[2], dilations=[2]), + dict(weights_shape=[3, 1, 5], group=3, pads=[2, 2], strides=[1], dilations=[1]), + dict(weights_shape=[3, 1, 5], group=3, pads=[4, 4], strides=[1], dilations=[2]), + dict(weights_shape=[3, 1, 5], group=3, pads=[2, 2], strides=[2], dilations=[1]), + dict(weights_shape=[3, 1, 5], group=3, pads=[4, 4], strides=[2], dilations=[2])] + + test_data_4D_precommit = [ + dict(weights_shape=[1, 3, 3, 3], group=1), + dict(weights_shape=[3, 1, 3, 3], group=3)] + + test_data_4D = [ + dict(weights_shape=[1, 3, 3, 3], group=1), + dict(weights_shape=[1, 3, 5, 3], group=1), + dict(weights_shape=[3, 1, 3, 3], group=3), + dict(weights_shape=[3, 1, 3, 5], group=3)] + + test_data_4D_autopad = [ + dict(weights_shape=[1, 3, 3, 3], group=1, pads=[1, 1, 1, 1], strides=[1, 1], dilations=[1, 1]), + dict(weights_shape=[1, 3, 3, 3], group=1, pads=[2, 2, 2, 2], strides=[1, 1], dilations=[2, 2]), + dict(weights_shape=[1, 3, 3, 3], group=1, pads=[3, 5, 3, 5], strides=[1, 1], dilations=[3, 5]), + dict(weights_shape=[1, 3, 3, 3], group=1, pads=[1, 1, 1, 1], strides=[2, 2], dilations=[1, 1]), + dict(weights_shape=[1, 3, 3, 3], group=1, pads=[2, 2, 2, 2], strides=[2, 2], dilations=[2, 2]), + dict(weights_shape=[1, 3, 3, 3], group=1, pads=[3, 5, 3, 5], strides=[2, 2], dilations=[3, 5]), + dict(weights_shape=[1, 3, 3, 3], group=1, pads=[1, 0, 1, 0], strides=[3, 5], dilations=[1, 1]), + dict(weights_shape=[1, 3, 3, 3], group=1, pads=[2, 0, 2, 0], strides=[3, 5], dilations=[2, 2]), + dict(weights_shape=[1, 3, 3, 3], group=1, pads=[3, 3, 3, 3], strides=[3, 5], dilations=[3, 5]), + dict(weights_shape=[1, 3, 5, 3], group=1, pads=[2, 1, 2, 1], strides=[1, 1], dilations=[1, 1]), + dict(weights_shape=[1, 3, 5, 3], group=1, pads=[4, 2, 4, 2], strides=[1, 1], dilations=[2, 2]), + dict(weights_shape=[1, 3, 5, 3], group=1, pads=[6, 5, 6, 5], strides=[1, 1], dilations=[3, 5]), + dict(weights_shape=[1, 3, 5, 3], group=1, pads=[2, 1, 2, 1], strides=[2, 2], dilations=[1, 1]), + dict(weights_shape=[1, 3, 5, 3], group=1, pads=[4, 2, 4, 2], strides=[2, 2], dilations=[2, 2]), + dict(weights_shape=[1, 3, 5, 3], group=1, pads=[6, 5, 6, 5], strides=[2, 2], dilations=[3, 5]), + dict(weights_shape=[1, 3, 5, 3], group=1, pads=[2, 0, 2, 0], strides=[3, 5], dilations=[1, 1]), + dict(weights_shape=[1, 3, 5, 3], group=1, pads=[4, 0, 4, 0], strides=[3, 5], dilations=[2, 2]), + dict(weights_shape=[1, 3, 5, 3], group=1, pads=[6, 3, 6, 3], strides=[3, 5], dilations=[3, 5]), + dict(weights_shape=[3, 1, 3, 3], group=3, pads=[1, 1, 1, 1], strides=[1, 1], dilations=[1, 1]), + dict(weights_shape=[3, 1, 3, 3], group=3, pads=[2, 2, 2, 2], strides=[1, 1], dilations=[2, 2]), + dict(weights_shape=[3, 1, 3, 3], group=3, pads=[3, 5, 3, 5], strides=[1, 1], dilations=[3, 5]), + dict(weights_shape=[3, 1, 3, 3], group=3, pads=[1, 1, 1, 1], strides=[2, 2], dilations=[1, 1]), + dict(weights_shape=[3, 1, 3, 3], group=3, pads=[2, 2, 2, 2], strides=[2, 2], dilations=[2, 2]), + dict(weights_shape=[3, 1, 3, 3], group=3, pads=[3, 5, 3, 5], strides=[2, 2], dilations=[3, 5]), + dict(weights_shape=[3, 1, 3, 3], group=3, pads=[1, 0, 1, 0], strides=[3, 5], dilations=[1, 1]), + dict(weights_shape=[3, 1, 3, 3], group=3, pads=[2, 0, 2, 0], strides=[3, 5], dilations=[2, 2]), + dict(weights_shape=[3, 1, 3, 3], group=3, pads=[3, 3, 3, 3], strides=[3, 5], dilations=[3, 5]), + dict(weights_shape=[3, 1, 3, 5], group=3, pads=[1, 2, 1, 2], strides=[1, 1], dilations=[1, 1]), + dict(weights_shape=[3, 1, 3, 5], group=3, pads=[2, 4, 2, 4], strides=[1, 1], dilations=[2, 2]), + dict(weights_shape=[3, 1, 3, 5], group=3, pads=[3, 10, 3, 10], strides=[1, 1], dilations=[3, 5]), + dict(weights_shape=[3, 1, 3, 5], group=3, pads=[1, 2, 1, 2], strides=[2, 2], dilations=[1, 1]), + dict(weights_shape=[3, 1, 3, 5], group=3, pads=[2, 4, 2, 4], strides=[2, 2], dilations=[2, 2]), + dict(weights_shape=[3, 1, 3, 5], group=3, pads=[3, 10, 3, 10], strides=[2, 2], dilations=[3, 5]), + dict(weights_shape=[3, 1, 3, 5], group=3, pads=[1, 0, 1, 0], strides=[3, 5], dilations=[1, 1]), + dict(weights_shape=[3, 1, 3, 5], group=3, pads=[2, 2, 2, 2], strides=[3, 5], dilations=[2, 2]), + dict(weights_shape=[3, 1, 3, 5], group=3, pads=[3, 8, 3, 8], strides=[3, 5], dilations=[3, 5])] + + test_data_5D_precommit = [ + dict(weights_shape=[1, 3, 3, 3, 3], group=1), + dict(weights_shape=[3, 1, 3, 3, 3], group=3)] + + test_data_5D = [ + dict(weights_shape=[1, 3, 3, 3, 3], group=1), + dict(weights_shape=[1, 3, 3, 4, 5], group=1), + dict(weights_shape=[3, 1, 3, 3, 3], group=3), + dict(weights_shape=[3, 1, 5, 4, 3], group=3)] + + test_data_5D_autopad = [ + dict(weights_shape=[1, 3, 3, 3, 3], group=1, pads=[1, 1, 1, 1, 1, 1], strides=[1, 1, 1], dilations=[1, 1, 1]), + dict(weights_shape=[1, 3, 3, 3, 3], group=1, pads=[2, 2, 2, 2, 2, 2], strides=[1, 1, 1], dilations=[2, 2, 2]), + dict(weights_shape=[1, 3, 3, 3, 3], group=1, pads=[3, 4, 5, 3, 4, 5], strides=[1, 1, 1], dilations=[3, 4, 5]), + dict(weights_shape=[1, 3, 3, 3, 3], group=1, pads=[1, 1, 1, 1, 1, 1], strides=[2, 2, 2], dilations=[1, 1, 1]), + dict(weights_shape=[1, 3, 3, 3, 3], group=1, pads=[2, 2, 2, 2, 2, 2], strides=[2, 2, 2], dilations=[2, 2, 2]), + dict(weights_shape=[1, 3, 3, 3, 3], group=1, pads=[3, 4, 5, 3, 4, 5], strides=[2, 2, 2], dilations=[3, 4, 5]), + dict(weights_shape=[1, 3, 3, 3, 3], group=1, pads=[1, 1, 0, 1, 1, 0], strides=[3, 4, 5], dilations=[1, 1, 1]), + dict(weights_shape=[1, 3, 3, 3, 3], group=1, pads=[2, 2, 0, 2, 2, 0], strides=[3, 4, 5], dilations=[2, 2, 2]), + dict(weights_shape=[1, 3, 3, 3, 3], group=1, pads=[3, 4, 3, 3, 4, 3], strides=[3, 4, 5], dilations=[3, 4, 5]), + dict(weights_shape=[1, 3, 3, 4, 5], group=1, pads=[1, 1, 2, 1, 2, 2], strides=[1, 1, 1], dilations=[1, 1, 1]), + dict(weights_shape=[1, 3, 3, 4, 5], group=1, pads=[2, 3, 4, 2, 3, 4], strides=[1, 1, 1], dilations=[2, 2, 2]), + dict(weights_shape=[1, 3, 3, 4, 5], group=1, pads=[3, 6, 10, 3, 6, 10], strides=[1, 1, 1], dilations=[3, 4, 5]), + dict(weights_shape=[1, 3, 3, 4, 5], group=1, pads=[1, 1, 2, 1, 2, 2], strides=[2, 2, 2], dilations=[1, 1, 1]), + dict(weights_shape=[1, 3, 3, 4, 5], group=1, pads=[2, 3, 4, 2, 3, 4], strides=[2, 2, 2], dilations=[2, 2, 2]), + dict(weights_shape=[1, 3, 3, 4, 5], group=1, pads=[3, 6, 10, 3, 6, 10], strides=[2, 2, 2], dilations=[3, 4, 5]), + dict(weights_shape=[1, 3, 3, 4, 5], group=1, pads=[1, 1, 0, 1, 2, 0], strides=[3, 4, 5], dilations=[1, 1, 1]), + dict(weights_shape=[1, 3, 3, 4, 5], group=1, pads=[2, 3, 2, 2, 3, 2], strides=[3, 4, 5], dilations=[2, 2, 2]), + dict(weights_shape=[1, 3, 3, 4, 5], group=1, pads=[3, 6, 8, 3, 6, 8], strides=[3, 4, 5], dilations=[3, 4, 5]), + dict(weights_shape=[3, 1, 3, 3, 3], group=3, pads=[1, 1, 1, 1, 1, 1], strides=[1, 1, 1], dilations=[1, 1, 1]), + dict(weights_shape=[3, 1, 3, 3, 3], group=3, pads=[2, 2, 2, 2, 2, 2], strides=[1, 1, 1], dilations=[2, 2, 2]), + dict(weights_shape=[3, 1, 3, 3, 3], group=3, pads=[3, 4, 5, 3, 4, 5], strides=[1, 1, 1], dilations=[3, 4, 5]), + dict(weights_shape=[3, 1, 3, 3, 3], group=3, pads=[1, 1, 1, 1, 1, 1], strides=[2, 2, 2], dilations=[1, 1, 1]), + dict(weights_shape=[3, 1, 3, 3, 3], group=3, pads=[2, 2, 2, 2, 2, 2], strides=[2, 2, 2], dilations=[2, 2, 2]), + dict(weights_shape=[3, 1, 3, 3, 3], group=3, pads=[3, 4, 5, 3, 4, 5], strides=[2, 2, 2], dilations=[3, 4, 5]), + dict(weights_shape=[3, 1, 3, 3, 3], group=3, pads=[1, 1, 0, 1, 1, 0], strides=[3, 4, 5], dilations=[1, 1, 1]), + dict(weights_shape=[3, 1, 3, 3, 3], group=3, pads=[2, 2, 0, 2, 2, 0], strides=[3, 4, 5], dilations=[2, 2, 2]), + dict(weights_shape=[3, 1, 3, 3, 3], group=3, pads=[3, 4, 3, 3, 4, 3], strides=[3, 4, 5], dilations=[3, 4, 5]), + dict(weights_shape=[3, 1, 5, 4, 3], group=3, pads=[2, 1, 1, 2, 2, 1], strides=[1, 1, 1], dilations=[1, 1, 1]), + dict(weights_shape=[3, 1, 5, 4, 3], group=3, pads=[4, 3, 2, 4, 3, 2], strides=[1, 1, 1], dilations=[2, 2, 2]), + dict(weights_shape=[3, 1, 5, 4, 3], group=3, pads=[6, 6, 5, 6, 6, 5], strides=[1, 1, 1], dilations=[3, 4, 5]), + dict(weights_shape=[3, 1, 5, 4, 3], group=3, pads=[2, 1, 1, 2, 2, 1], strides=[2, 2, 2], dilations=[1, 1, 1]), + dict(weights_shape=[3, 1, 5, 4, 3], group=3, pads=[4, 3, 2, 4, 3, 2], strides=[2, 2, 2], dilations=[2, 2, 2]), + dict(weights_shape=[3, 1, 5, 4, 3], group=3, pads=[6, 6, 5, 6, 6, 5], strides=[2, 2, 2], dilations=[3, 4, 5]), + dict(weights_shape=[3, 1, 5, 4, 3], group=3, pads=[2, 1, 0, 2, 2, 0], strides=[3, 4, 5], dilations=[1, 1, 1]), + dict(weights_shape=[3, 1, 5, 4, 3], group=3, pads=[4, 3, 0, 4, 3, 0], strides=[3, 4, 5], dilations=[2, 2, 2]), + dict(weights_shape=[3, 1, 5, 4, 3], group=3, pads=[6, 6, 3, 6, 6, 3], strides=[3, 4, 5], dilations=[3, 4, 5])] + + @pytest.mark.parametrize("params", test_data_3D) + @pytest.mark.parametrize("dilations", [[1], [2]]) + @pytest.mark.parametrize("pads", [[0, 0], [1, 1], [1, 2]]) + @pytest.mark.parametrize("strides", [[1], [2]]) + @pytest.mark.parametrize("bias", [False, True]) + @pytest.mark.nightly + def test_conv_3D(self, params, dilations, pads, strides, bias, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, shape=[2, 3, 25], dilations=dilations, pads=pads, strides=strides, + bias=bias, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_3D_autopad[:-1]) + @pytest.mark.parametrize("auto_pad", ['SAME_UPPER', 'SAME_LOWER']) + @pytest.mark.parametrize("bias", [False, True]) + @pytest.mark.nightly + @pytest.mark.xfail(reason='autopad dimetions do not agree with framework') + def test_conv_3D_autopad(self, params, auto_pad, bias, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, shape=[2, 3, 25], bias=bias, auto_pad=auto_pad, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_4D_precommit) + @pytest.mark.parametrize("dilations", [[3, 5]]) + @pytest.mark.parametrize("pads", [[1, 2, 3, 4]]) + @pytest.mark.parametrize("strides", [[3, 5]]) + @pytest.mark.parametrize("bias", [False, True]) + @pytest.mark.precommit + def test_conv_4D_precommit(self, params, dilations, pads, strides, bias, ie_device, precision, + ir_version, temp_dir): + self._test(*self.create_net(**params, shape=[2, 3, 25, 25], dilations=dilations, pads=pads, strides=strides, + bias=bias, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.parametrize("dilations", [[1, 1], [2, 2], [3, 5]]) + @pytest.mark.parametrize("pads", [[0, 0, 0, 0], [1, 1, 1, 1], [1, 2, 3, 4]]) + @pytest.mark.parametrize("strides", [[1, 1], [2, 2], [3, 5]]) + @pytest.mark.parametrize("bias", [False, True]) + @pytest.mark.nightly + def test_conv_4D(self, params, dilations, pads, strides, bias, ie_device, precision, ir_version, temp_dir): + self._test( + *self.create_net(**params, shape=[2, 3, 25, 25], dilations=dilations, pads=pads, strides=strides, bias=bias, + ir_version=ir_version), ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_4D_autopad[:-1]) + @pytest.mark.parametrize("auto_pad", ['SAME_UPPER', 'SAME_LOWER']) + @pytest.mark.parametrize("bias", [False, True]) + @pytest.mark.nightly + @pytest.mark.xfail(reason='autopad dimetions do not agree with framework') + def test_conv_4D_autopad(self, params, auto_pad, bias, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, shape=[2, 3, 25, 25], bias=bias, auto_pad=auto_pad, + ir_version=ir_version), ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_5D_precommit) + @pytest.mark.parametrize("dilations", [[3, 4, 5]]) + @pytest.mark.parametrize("pads", [[1, 2, 3, 4, 5, 6]]) + @pytest.mark.parametrize("strides", [[3, 4, 5]]) + @pytest.mark.parametrize("bias", [False, True]) + @pytest.mark.precommit + def test_conv_5D_precommit(self, params, dilations, pads, strides, bias, ie_device, precision, + ir_version, temp_dir): + self._test(*self.create_net(**params, shape=[2, 3, 25, 25, 25], dilations=dilations, pads=pads, strides=strides, + bias=bias, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.parametrize("dilations", [[1, 1, 1], [2, 2, 2], [3, 4, 5]]) + @pytest.mark.parametrize("pads", [[0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6]]) + @pytest.mark.parametrize("strides", [[1, 1, 1], [2, 2, 2], [3, 4, 5]]) + @pytest.mark.parametrize("bias", [False, True]) + @pytest.mark.nightly + def test_conv_5D(self, params, dilations, pads, strides, bias, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, shape=[2, 3, 25, 25, 25], dilations=dilations, pads=pads, strides=strides, + bias=bias, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_5D_autopad[:-1]) + @pytest.mark.parametrize("auto_pad", ['SAME_UPPER', 'SAME_LOWER']) + @pytest.mark.parametrize("bias", [False, True]) + @pytest.mark.nightly + @pytest.mark.xfail(reason='autopad dimetions do not agree with framework') + def test_conv_5D_autopad(self, params, auto_pad, bias, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, shape=[2, 3, 25, 25, 25], bias=bias, auto_pad=auto_pad, + ir_version=ir_version), ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_conv_transpose.py b/tests/layer_tests/onnx_tests/test_conv_transpose.py new file mode 100644 index 00000000000000..1de48549f3fd1c --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_conv_transpose.py @@ -0,0 +1,215 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest +from common.onnx_layer_test_class import OnnxRuntimeLayerTest + + +class TestConvTranspose(OnnxRuntimeLayerTest): + def _prepare_input(self, inputs_dict): + for input in inputs_dict.keys(): + inputs_dict[input] = np.random.randn(*inputs_dict[input]).astype(np.float32) + return inputs_dict + + def create_conv_transpose(self, ir_version, input_shape, output_shape, kernel_shape, strides, group=1, + dilations=None, pads=None, force_output_shape=False, output_padding=None, bias=False, + auto_pad=None): + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, input_shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + weights = np.random.randn(*kernel_shape).astype(np.float) + + node_weights_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['kernel'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=weights.shape, + vals=weights.flatten(), + ), + ) + + conv_attrs = { + 'strides': strides, + 'group': group, + 'kernel_shape': kernel_shape[2:], # As we have NCHW layout + } + + if pads is not None: + if not force_output_shape: + conv_attrs.update({'pads': pads}) + else: + pads = np.zeros(2 * (len(input_shape) - 2)) + _pads = np.array(pads).reshape([2, -1]) + if output_padding is not None: + conv_attrs.update({'output_padding': output_padding}) + if dilations is not None: + conv_attrs.update({'dilations': dilations}) + else: + dilations = np.ones(len(input_shape) - 2) + if force_output_shape: + conv_attrs.update({'output_shape': output_shape[2:]}) + + if auto_pad: + conv_attrs.update({'auto_pad': auto_pad}) + + nodes = [node_weights_def] + if bias: + bias_const = np.random.randint(-10, 10, kernel_shape[0]).astype(np.float32) + + node_bias_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['bias'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=bias_const.shape, + vals=bias_const.flatten(), + ), + ) + node_conv_transpose = onnx.helper.make_node( + 'ConvTranspose', + inputs=['input', 'kernel', 'bias'], + outputs=['output'], + **conv_attrs + ) + nodes.extend([node_bias_def, node_conv_transpose]) + else: + node_conv_transpose = onnx.helper.make_node( + 'ConvTranspose', + inputs=['input', 'kernel'], + outputs=['output'], + **conv_attrs + ) + nodes.append(node_conv_transpose) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + nodes, + 'test_conv_transpose_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_conv_transpose_model') + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + ref_net = None + + return onnx_net, ref_net + + common_tests_4D_precommit = [ + pytest.param(dict(input_shape=[1, 3, 10, 10], output_shape=[1, 3, 12, 12], + kernel_shape=[3, 3, 2, 2], strides=[1, 1], dilations=[2, 2]), + marks=pytest.mark.skip(reason="Skipped until fixed")), + pytest.param(dict(input_shape=[1, 2, 20, 20], output_shape=[1, 2, 85, 85], + kernel_shape=[2, 1, 8, 8], strides=[4, 4], group=2, output_padding=[1, 1]), + marks=pytest.mark.skip(reason="Skipped until fixed")) + ] + + common_tests_4D = [ + dict(input_shape=[1, 3, 10, 10], output_shape=[1, 3, 11, 11], + kernel_shape=[3, 3, 2, 2], strides=[1, 1]), + dict(input_shape=[1, 3, 10, 10], output_shape=[1, 3, 20, 20], + kernel_shape=[3, 3, 2, 2], strides=[2, 2]), + dict(input_shape=[1, 3, 10, 10], output_shape=[1, 3, 12, 12], + kernel_shape=[3, 3, 2, 2], strides=[1, 1], dilations=[2, 2]), + dict(input_shape=[1, 3, 10, 10], output_shape=[1, 3, 21, 21], + kernel_shape=[3, 3, 2, 2], strides=[2, 2], dilations=[2, 2]), + dict(input_shape=[1, 2, 20, 20], output_shape=[1, 2, 85, 85], + kernel_shape=[2, 1, 8, 8], strides=[4, 4], group=2, output_padding=[1, 1]), + ] + + explicit_pads_tests_4D = common_tests_4D + [ + dict(input_shape=[1, 2, 20, 20], output_shape=[1, 2, 80, 80], + kernel_shape=[2, 1, 8, 8], strides=[4, 4], group=2, pads=[2, 2, 2, 2]), + dict(input_shape=[1, 2, 20, 20], output_shape=[1, 2, 87, 87], + kernel_shape=[2, 1, 8, 8], strides=[4, 4], group=2, pads=[2, 2, 2, 2], dilations=[2, 2]), + dict(input_shape=[1, 2, 20, 20], output_shape=[1, 2, 80, 80], + kernel_shape=[2, 1, 8, 8], strides=[4, 4], group=2, pads=[2, 2, 2, 2], force_output_shape=True), + ] + + valid_auto_pad_tests_4D = common_tests_4D + [ + dict(input_shape=[1, 2, 20, 20], output_shape=[1, 2, 84, 84], + kernel_shape=[2, 1, 8, 8], strides=[4, 4], group=2), + dict(input_shape=[1, 2, 20, 20], output_shape=[1, 2, 91, 91], + kernel_shape=[2, 1, 8, 8], strides=[4, 4], group=2, dilations=[2, 2]), + dict(input_shape=[1, 2, 20, 20], output_shape=[1, 2, 80, 80], + kernel_shape=[2, 1, 8, 8], strides=[4, 4], group=2, force_output_shape=True), + ] + + same_auto_pad_tests_4D = [ + dict(input_shape=[1, 3, 10, 10], output_shape=[1, 3, 10, 10], + kernel_shape=[3, 3, 2, 2], strides=[1, 1]), + dict(input_shape=[1, 3, 10, 10], output_shape=[1, 3, 20, 20], + kernel_shape=[3, 3, 2, 2], strides=[2, 2]), + dict(input_shape=[1, 2, 20, 20], output_shape=[1, 2, 80, 80], + kernel_shape=[2, 1, 8, 8], strides=[4, 4], group=2), + dict(input_shape=[1, 3, 10, 10], output_shape=[1, 3, 10, 10], + kernel_shape=[3, 3, 2, 2], strides=[1, 1], dilations=[2, 2]), + dict(input_shape=[1, 3, 10, 10], output_shape=[1, 3, 20, 20], + kernel_shape=[3, 3, 2, 2], strides=[2, 2], dilations=[2, 2]), + dict(input_shape=[1, 2, 20, 20], output_shape=[1, 2, 80, 80], + kernel_shape=[2, 1, 8, 8], strides=[4, 4], group=2, dilations=[2, 2]), + dict(input_shape=[1, 2, 20, 20], output_shape=[1, 2, 80, 80], + kernel_shape=[2, 1, 8, 8], strides=[4, 4], group=2, force_output_shape=True), + dict(input_shape=[1, 2, 20, 20], output_shape=[1, 2, 81, 81], + kernel_shape=[2, 1, 8, 8], strides=[4, 4], group=2, output_padding=[1, 1]), + ] + + @pytest.mark.parametrize("params", common_tests_4D_precommit) + @pytest.mark.parametrize("bias", [False, True]) + @pytest.mark.parametrize("auto_pad", ["NOTSET"]) + @pytest.mark.precommit + def test_conv_transpose_4D_precommit(self, params, bias, ie_device, precision, ir_version, auto_pad, temp_dir): + if ie_device == 'GPU' and 'dilations' in params: + pytest.xfail('dilations are not supported on GPU') + self._test(*self.create_conv_transpose(**params, ir_version=ir_version, bias=bias, auto_pad=auto_pad), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", explicit_pads_tests_4D) + @pytest.mark.parametrize("bias", [False, True]) + @pytest.mark.parametrize("auto_pad", ["NOTSET"]) + @pytest.mark.nightly + def test_conv_transpose_4D(self, params, bias, ie_device, precision, ir_version, auto_pad, temp_dir): + if ie_device == 'GPU' and 'dilations' in params: + pytest.xfail('dilations are not supported on GPU') + self._test(*self.create_conv_transpose(**params, ir_version=ir_version, bias=bias, auto_pad=auto_pad), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", valid_auto_pad_tests_4D) + @pytest.mark.parametrize("bias", [False, True]) + @pytest.mark.parametrize("auto_pad", ["VALID"]) + @pytest.mark.nightly + def test_conv_transpose_valid_auto_pad_4D(self, params, bias, ie_device, precision, ir_version, auto_pad, temp_dir): + if ie_device == 'GPU' and 'dilations' in params: + pytest.xfail('dilations are not supported on GPU') + self._test(*self.create_conv_transpose(**params, ir_version=ir_version, bias=bias, auto_pad=auto_pad), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", same_auto_pad_tests_4D) + @pytest.mark.parametrize("bias", [False, True]) + @pytest.mark.parametrize("auto_pad", ["SAME_UPPER", "SAME_LOWER"]) + @pytest.mark.nightly + def test_conv_transpose_same_auto_pad_4D(self, params, bias, ie_device, precision, ir_version, auto_pad, temp_dir): + if ie_device == 'GPU' and 'dilations' in params: + pytest.xfail('dilations are not supported on GPU') + self._test(*self.create_conv_transpose(**params, ir_version=ir_version, bias=bias, auto_pad=auto_pad), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_cumsum.py b/tests/layer_tests/onnx_tests/test_cumsum.py new file mode 100644 index 00000000000000..b49f00f887c3ff --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_cumsum.py @@ -0,0 +1,267 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +def cumsum(a, axis=None, exclusive=False, reverse=False): + if reverse: + a = np.flip(a, axis) + res = np.cumsum(a, axis=axis) + if exclusive: + res -= a + if reverse: + res = np.flip(res, axis) + return res + + +class TestCumSum(OnnxRuntimeLayerTest): + def create_net(self, shape, ir_version, axis=None, reverse=None, exclusive=None): + """ + ONNX net IR net + + Input->CumSum->Output => Input->CumSum + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + nodes = [] + inputs = ['input'] + if axis is not None: + node_axis_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['axis'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.INT64, + dims=[], + vals=[axis], + ), + ) + nodes.append(node_axis_def) + inputs.append('axis') + + args = dict() + if exclusive is not None: + args['exclusive'] = exclusive + if reverse is not None: + args['reverse'] = reverse + node_def = onnx.helper.make_node( + 'CumSum', + inputs=inputs, + outputs=['output'], + **args + ) + nodes.append(node_def) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + nodes, + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + onnx.checker.check_model(onnx_net) + + # + # Create reference IR net + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'CumSum'}, + 'node_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + if exclusive is not None: + nodes_attributes['node']['exclusive'] = exclusive + if reverse is not None: + nodes_attributes['node']['reverse'] = reverse + edges = [('input', 'input_data'), + ('input_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result') + ] + if axis is not None: + nodes_attributes.update({ + 'input_axis_data': {'kind': 'data', 'value': [axis]}, + 'axis': {'kind': 'op', 'type': 'Const'}, + 'axis_data': {'shape': [], 'kind': 'data'}}) + edges.extend([('input_axis_data', 'axis'), + ('axis', 'axis_data'), + ('axis_data', 'node')]) + ref_net = build_graph(nodes_attributes, edges) + + return onnx_net, ref_net + + def create_net_const(self, shape, precision, ir_version, axis=None, reverse=None, exclusive=None): + """ + ONNX net IR net + + Input->Concat(+cumsum const)->Output => Input->Concat(+const) + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + import numpy as np + + concat_axis = 0 + output_shape = shape.copy() + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + constant = np.random.randn(*shape).astype(np.float) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + nodes = [node_const_def] + inputs = ['const1'] + if axis is not None: + node_axis_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['axis'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.INT64, + dims=[], + vals=[axis], + ), + ) + nodes.append(node_axis_def) + inputs.append('axis') + + args = dict() + if exclusive is not None: + args['exclusive'] = exclusive + if reverse is not None: + args['reverse'] = reverse + node_def = onnx.helper.make_node( + 'CumSum', + inputs=inputs, + outputs=['cumsum'], + **args + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'cumsum'], + outputs=['output'], + axis=concat_axis + ) + nodes.extend([node_def, node_concat_def]) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + nodes, + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + onnx.checker.check_model(onnx_net) + + # + # Create reference IR net + # + constant = cumsum(constant, axis=axis, reverse=reverse, exclusive=exclusive) + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': constant.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': shape, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result') + ]) + + return onnx_net, ref_net + + test_data = [ + dict(shape=[1]), + dict(shape=[1, 2]), + dict(shape=[2, 4, 6]), + dict(shape=[2, 4, 6, 8]), + dict(shape=[2, 4, 6, 8, 10]), + dict(shape=[1, 2], axis=-2), + dict(shape=[1, 2], axis=1), + dict(shape=[2, 4, 6], axis=-3), + dict(shape=[2, 4, 6], axis=2), + dict(shape=[2, 4, 6, 8], axis=-4), + dict(shape=[2, 4, 6, 8], axis=3), + dict(shape=[2, 4, 6, 8, 10], axis=-1), + dict(shape=[2, 4, 6, 8, 10], axis=4)] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.parametrize("reverse", [0, 1]) + @pytest.mark.parametrize("exclusive", [0, 1]) + @pytest.mark.nightly + def test_cumsum(self, params, reverse, exclusive, ie_device, precision, ir_version, temp_dir): + if 'axis' not in params: + pytest.skip('No axis cases fail in ONNX') + self._test(*self.create_net(**params, exclusive=exclusive, reverse=reverse, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.parametrize("reverse", [0, 1]) + @pytest.mark.parametrize("exclusive", [0, 1]) + @pytest.mark.nightly + def test_cumsum_const(self, params, reverse, exclusive, ie_device, precision, ir_version, temp_dir): + if 'axis' not in params: + pytest.skip('No axis cases fail in ONNX') + self._test(*self.create_net_const(**params, precision=precision, exclusive=exclusive, reverse=reverse, + ir_version=ir_version), ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_dequantize_linear.py b/tests/layer_tests/onnx_tests/test_dequantize_linear.py new file mode 100644 index 00000000000000..1bf364accff938 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_dequantize_linear.py @@ -0,0 +1,205 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestDequantizeLinear(OnnxRuntimeLayerTest): + def _prepare_input(self, inputs_dict): + for input in inputs_dict.keys(): + inputs_dict[input] = np.random.randint(np.iinfo(self.inp_type).min, + np.iinfo(self.inp_type).max, + inputs_dict[input], + dtype=self.inp_type) + return inputs_dict + + def create_dequanize_linear(self, shape, y_scale: np.array, y_zero_point=None, axis=None, opset=10, ir_version='10'): + """ + ONNX net IR net + + Input->DequantizeLinear->Output => Input->Sub->Mul + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + self.inp_type = y_zero_point.dtype if y_zero_point is not None else np.uint8 + onnx_type = TensorProto.UINT8 if self.inp_type == np.uint8 else TensorProto.INT8 + input = helper.make_tensor_value_info('input', onnx_type, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + nodes = [] + inputs = ['input', 'y_scale'] + node_scale_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['y_scale'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=y_scale.shape, + vals=y_scale.flatten(), + ), + ) + nodes.append(node_scale_def) + + if y_zero_point is not None: + node_zero_point_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['y_zero_point'], + value=helper.make_tensor( + name='const_tensor', + data_type=onnx_type, + dims=y_zero_point.shape, + vals=y_zero_point.flatten(), + ), + ) + inputs.append('y_zero_point') + nodes.append(node_zero_point_def) + args = dict() + if axis is not None: + args['axis'] = axis + node_def = onnx.helper.make_node( + 'DequantizeLinear', + inputs=inputs, + outputs=['output'], + **args + ) + nodes.append(node_def) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + nodes, + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model', + opset_imports=[helper.make_opsetid("", opset)]) + onnx.checker.check_model(onnx_net) + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'input_scale_data': {'kind': 'data', 'value': y_scale}, + 'scale_const': {'kind': 'op', 'type': 'Const'}, + 'scale_data': {'shape': np.ones(len(shape)), 'kind': 'data'}, + 'mul': {'kind': 'op', 'type': 'Multiply'}, + 'mul_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + edges = [('input', 'input_data'), + ('input_data', 'mul'), + ('input_scale_data', 'scale_const'), + ('scale_const', 'scale_data'), + ('scale_data', 'mul'), + ('mul', 'mul_data')] + if y_zero_point is not None: + nodes_attributes.update({ + 'input_zero_data': {'kind': 'data', 'value': -y_scale * y_zero_point}, + 'zero_const': {'kind': 'op', 'type': 'Const'}, + 'zero_data': {'shape': np.ones(len(shape)), 'kind': 'data'}, + 'sub': {'kind': 'op', 'type': 'Add'}, + 'sub_data': {'shape': shape, 'kind': 'data'}, + }) + edges.extend([('mul_data', 'sub'), + ('input_zero_data', 'zero_const'), + ('zero_const', 'zero_data'), + ('zero_data', 'sub'), + ('sub', 'sub_data'), + ('sub_data', 'result')]) + else: + edges.append(('mul_data', 'result')) + + ref_net = None + if check_ir_version(10, None, ir_version): + ref_net = build_graph(nodes_attributes, edges) + + return onnx_net, ref_net + + test_data = [ + dict(shape=[8], y_scale=np.array(2, dtype=np.float), y_zero_point=np.array(128, dtype=np.uint8)), + dict(shape=[8], y_scale=np.array(2, dtype=np.float), y_zero_point=np.array(1, dtype=np.int8)), + dict(shape=[2, 4], y_scale=np.array(2, dtype=np.float), y_zero_point=np.array(128, dtype=np.uint8)), + dict(shape=[2, 4], y_scale=np.array(2, dtype=np.float), y_zero_point=np.array(1, dtype=np.int8)), + dict(shape=[2, 4, 6], y_scale=np.array(2, dtype=np.float), y_zero_point=np.array(128, dtype=np.uint8)), + dict(shape=[2, 4, 6], y_scale=np.array(2, dtype=np.float), y_zero_point=np.array(1, dtype=np.int8)), + dict(shape=[2, 4, 6, 8], y_scale=np.array(2, dtype=np.float), y_zero_point=np.array(128, dtype=np.uint8)), + dict(shape=[2, 4, 6, 8], y_scale=np.array(2, dtype=np.float), y_zero_point=np.array(1, dtype=np.int8)), + dict(shape=[2, 4, 6, 8, 10], y_scale=np.array(2, dtype=np.float), y_zero_point=np.array(128, dtype=np.uint8)), + dict(shape=[2, 4, 6, 8, 10], y_scale=np.array(2, dtype=np.float), y_zero_point=np.array(1, dtype=np.int8)), + ] + test_data_def_zerop = [ + dict(shape=[8], y_scale=np.array(2, dtype=np.float)), + dict(shape=[2, 4], y_scale=np.array(2, dtype=np.float)), + dict(shape=[2, 4, 6], y_scale=np.array(2, dtype=np.float)), + dict(shape=[2, 4, 6, 8], y_scale=np.array(2, dtype=np.float)), + dict(shape=[2, 4, 6, 8, 10], y_scale=np.array(2, dtype=np.float)), + ] + + test_data_axis = [ + dict(shape=[2, 4], y_scale=np.array([2, 2.5, 3, 2.3], dtype=np.float), axis=1), + dict(shape=[2, 4], y_scale=np.array([2, 2.5, 3, 2.3], dtype=np.float), + y_zero_point=np.array([128, 128, 128, 128], dtype=np.uint8), axis=1), + dict(shape=[2, 4], y_scale=np.array([2, 2.5, 3, 2.3], dtype=np.float), + y_zero_point=np.array([1, 1, 1, 1], dtype=np.int8), axis=1), + dict(shape=[2, 4, 6], y_scale=np.array([2, 2.5, 3, 2.3], dtype=np.float), axis=1), + dict(shape=[2, 4, 6], y_scale=np.array([2, 2.5, 3, 2.3], dtype=np.float), + y_zero_point=np.array([128, 128, 128, 128], dtype=np.uint8), axis=1), + dict(shape=[2, 4, 6], y_scale=np.array([2, 2.5, 3, 2.3], dtype=np.float), + y_zero_point=np.array([1, 1, 1, 1], dtype=np.int8), axis=1), + dict(shape=[2, 4, 6, 8], y_scale=np.array([2, 2.5, 3, 2.3], dtype=np.float), axis=1), + dict(shape=[2, 4, 6, 8], y_scale=np.array([2, 2.5, 3, 2.3], dtype=np.float), + y_zero_point=np.array([128, 128, 128, 128], dtype=np.uint8), axis=1), + dict(shape=[2, 4, 6, 8], y_scale=np.array([2, 2.5, 3, 2.3], dtype=np.float), + y_zero_point=np.array([1, 1, 1, 1], dtype=np.int8), axis=1), + dict(shape=[2, 4, 6, 8, 10], y_scale=np.array([2, 2.5, 3, 2.3], dtype=np.float), axis=1), + dict(shape=[2, 4, 6, 8, 10], y_scale=np.array([2, 2.5, 3, 2.3], dtype=np.float), + y_zero_point=np.array([128, 128, 128, 128], dtype=np.uint8), axis=1), + dict(shape=[2, 4, 6, 8, 10], y_scale=np.array([2, 2.5, 3, 2.3], dtype=np.float), + y_zero_point=np.array([1, 1, 1, 1], dtype=np.int8), axis=1), + ] + + @pytest.mark.parametrize("params", test_data_def_zerop) + @pytest.mark.nightly + @pytest.mark.xfail(reason='Defualt zero_point fails on onnxruntime') + def test_quantize_linear_def_zerop_opset10(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_dequanize_linear(**params, ir_version=ir_version), ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_quantize_linear_opset10(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_dequanize_linear(**params, ir_version=ir_version), ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data + test_data_def_zerop) + @pytest.mark.nightly + @pytest.mark.skip(reason='DequantizeLinear-13 is unsupported in MO') + def test_quantize_linear_opset13(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_dequanize_linear(**params, opset=13, ir_version=ir_version), ie_device, precision, + ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_axis) + @pytest.mark.nightly + @pytest.mark.skip(reason='DequantizeLinear-13 is unsupported in MO') + def test_quantize_linear_axis_opset13(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_dequanize_linear(**params, opset=13, ir_version=ir_version), ie_device, precision, + ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_dropout.py b/tests/layer_tests/onnx_tests/test_dropout.py new file mode 100644 index 00000000000000..618fdc02d32aac --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_dropout.py @@ -0,0 +1,169 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.onnx_layer_test_class import Caffe2OnnxLayerTest + + +class TestDropout(Caffe2OnnxLayerTest): + def create_net(self, shape, ratio, ir_version, opset=None): + """ + ONNX net IR net + + Input->Dropout->Sigmoid->Output => Input->sigmoid + + """ + + # + # Create ONNX model + # + + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + args = dict() + if ratio: + args['ratio'] = ratio + if opset == 6: + args['is_test'] = 1 + node_def = helper.make_node( + 'Dropout', + inputs=['input'], + outputs=['dropout'], + **args + ) + + sigmoid_def = helper.make_node( + 'Sigmoid', + inputs=['dropout'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def, sigmoid_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + args = dict(producer_name='test_model') + if opset: + args['opset_imports'] = [helper.make_opsetid("", opset)] + onnx_net = helper.make_model(graph_def, **args) + + # + # Create reference IR net + # + + ref_net = None + + return onnx_net, ref_net + + def create_net_const(self, shape, ratio, ir_version, opset=None): + """ + ONNX net IR net + + Input->Concat(+dropout with const)->Output => Input->Concat(+const) + + """ + + from onnx import helper + from onnx import TensorProto + + constant = np.random.randint(-127, 127, shape).astype(np.float) + + concat_axis = 0 + output_shape = shape.copy() + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + node_const_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + args = dict() + if ratio: + args['ratio'] = ratio + if opset == 6: + args['is_test'] = 1 + node_def = helper.make_node( + 'Dropout', + inputs=['const1'], + outputs=['dropout'], + **args + ) + + node_concat_def = helper.make_node( + 'Concat', + inputs=['input', 'dropout'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + args = dict(producer_name='test_model') + if opset: + args['opset_imports'] = [helper.make_opsetid("", opset)] + onnx_net = helper.make_model(graph_def, **args) + + ref_net = None + + return onnx_net, ref_net + + test_data = [dict(shape=[10, 12], ratio=None), + dict(shape=[10, 12], ratio=0.7), + dict(shape=[8, 10, 12], ratio=None), + dict(shape=[8, 10, 12], ratio=0.7), + dict(shape=[6, 8, 10, 12], ratio=None), + dict(shape=[6, 8, 10, 12], ratio=0.7), + dict(shape=[4, 6, 8, 10, 12], ratio=None), + dict(shape=[4, 6, 8, 10, 12], ratio=0.7)] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_dropout_opset6(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, opset=6, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_dropout(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_dropout_const_opset6(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, opset=6, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_dropout_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_elu.py b/tests/layer_tests/onnx_tests/test_elu.py new file mode 100644 index 00000000000000..c65b000b0826f6 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_elu.py @@ -0,0 +1,185 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import Caffe2OnnxLayerTest +from unit_tests.utils.graph import build_graph + + +class TestElu(Caffe2OnnxLayerTest): + def create_net(self, shape, alpha, ir_version): + """ + ONNX net IR net + + Input->Elu->Output => Input->elu + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + node_def = onnx.helper.make_node( + 'Elu', + inputs=['input'], + outputs=['output'], + alpha=alpha + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'Elu', 'alpha': alpha}, + 'node_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result') + ]) + + return onnx_net, ref_net + + def create_net_const(self, shape, alpha, precision, ir_version): + """ + ONNX net IR net + + Input->Concat(+elu const)->Output => Input->Concat(+const) + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + import numpy as np + + concat_axis = 0 + output_shape = shape.copy() + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + const_number = np.prod(shape) + constant = np.random.randint(-127, 127, const_number).astype(np.float) + constant = np.reshape(constant, shape) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + node_def = onnx.helper.make_node( + 'Elu', + inputs=['const1'], + outputs=['elu1'], + alpha=alpha + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'elu1'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + constant = np.clip(constant, 0, np.inf) + (np.exp(np.clip(constant, -np.inf, 0)) - 1) * alpha + if precision == 'FP16': + constant = constant.astype(np.float16) + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': constant.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': shape, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result') + ]) + + return onnx_net, ref_net + + test_data = [dict(shape=[10, 12], alpha=0.1), + dict(shape=[8, 10, 12], alpha=0.9), + dict(shape=[6, 8, 10, 12], alpha=1.5), + dict(shape=[4, 6, 8, 10, 12], alpha=4.5)] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_elu(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_elu_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_embedding_bag.py b/tests/layer_tests/onnx_tests/test_embedding_bag.py new file mode 100644 index 00000000000000..dce555c8261a33 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_embedding_bag.py @@ -0,0 +1,131 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import os + +import numpy as np +import pytest +import torch +import torch.nn as nn +from common.layer_test_class import CommonLayerTest, check_ir_version +from unit_tests.utils.graph import build_graph + + +class PytorchLayerTest(CommonLayerTest): + def produce_model_path(self, framework_model, save_path): + path = os.path.join(save_path, 'model.onnx') + self.torch_model = framework_model + torch.onnx.export(self.torch_model, self.var, path, output_names=['output']) + assert os.path.isfile(path), "model.onnx haven't been saved here: {}".format(save_path) + return path + + def get_framework_results(self, inputs_dict, model_path): + return {'output': self.torch_model(*self.var).detach().numpy()} + + +class EmbeddingBagModel(torch.nn.Module): + def __init__(self, n, m, indices_shape=None, per_sample_weights=False, mode="sum"): + super(EmbeddingBagModel, self).__init__() + EE = nn.EmbeddingBag(n, m, mode=mode, sparse=True) + self.W = np.random.uniform(low=-np.sqrt(1 / n), high=np.sqrt(1 / n), size=(n, m)).astype(np.float32) + EE.weight.data = torch.tensor(self.W, requires_grad=True) + self.embedding_bag = EE + if per_sample_weights: + self.per_sample_weights = torch.randn(indices_shape) + else: + self.per_sample_weights = None + + +class TestPytorchEmbeddingBag(PytorchLayerTest): + def _prepare_input(self, inputs_dict): + assert 'input' in inputs_dict and 'offsets' in inputs_dict, "input and offsets should be in inputs_dict" + indices, offsets = self.var + inputs_dict['input'] = indices.numpy().astype(np.int32) + inputs_dict['offsets'] = offsets.numpy().astype(np.int32) + return inputs_dict + + def create_net(self, n, m, emb_batch_size, ir_version, per_sample_weights=False, offsets=None): + """ + Pytorch net IR net + + Input->EmbeddingBag->Output => Input->Gather/SparseWeightedSum + + """ + # Create Pytorch model + EE = EmbeddingBagModel(n, m, indices_shape=[emb_batch_size], per_sample_weights=per_sample_weights) + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input_weights_data': {'kind': 'data', 'value': EE.W.flatten()}, + 'weights': {'kind': 'op', 'type': 'Const'}, + 'weights_data': {'shape': EE.W.shape, 'kind': 'data'}, + 'indices': {'kind': 'op', 'type': 'Parameter'}, + 'indices_data': {'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'EmbeddingBagOffsetsSum'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + edges = [('input_weights_data', 'weights'), + ('weights', 'weights_data'), + ('indices', 'indices_data'), + ('weights_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result') + ] + if offsets is not None: + nodes_attributes.update({ + 'offsets': {'kind': 'op', 'type': 'Parameter'}, + 'offsets_data': {'kind': 'data'}, + 'node_data': {'shape': [len(offsets), m], 'kind': 'data'}, + }) + edges.extend([ + ('offsets', 'offsets_data'), + ('indices_data', 'node'), + ('offsets_data', 'node'), + ]) + else: + nodes_attributes.update({ + 'input_shape_data': {'kind': 'data', 'value': [-1]}, + 'shape': {'kind': 'op', 'type': 'Const'}, + 'shape_data': {'shape': [1], 'kind': 'data'}, + 'reshape': {'kind': 'op', 'type': 'Reshape'}, + 'reshape_data': {'shape': [emb_batch_size], 'kind': 'data'}, + 'input_offsets_data': {'kind': 'data', 'value': np.arange(0, 128, 2)}, + 'offsets': {'kind': 'op', 'type': 'Const'}, + 'offsets_data': {'shape': [int(emb_batch_size / 2)], 'kind': 'data'}, + 'node_data': {'shape': [int(emb_batch_size / 2), m], 'kind': 'data'}, + }) + edges.extend([ + ('input_shape_data', 'shape'), + ('shape', 'shape_data'), + ('indices_data', 'reshape'), + ('shape_data', 'reshape'), + ('reshape', 'reshape_data'), + ('reshape_data', 'node'), + ('input_offsets_data', 'offsets'), + ('offsets', 'offsets_data'), + ('offsets_data', 'node'), + ]) + + ref_net = build_graph(nodes_attributes, edges) + if offsets is not None: + self.var = (torch.from_numpy(np.random.choice(n, emb_batch_size)).long(), + torch.from_numpy(np.array(offsets)).long()) + else: + self.var = ( + torch.from_numpy(np.random.choice(n, emb_batch_size).reshape(int(emb_batch_size / 2), 2)).long(),) + return EE, ref_net + + test_data = [ + dict(n=1460, m=16, emb_batch_size=128), + dict(n=1460, m=16, emb_batch_size=128, offsets=np.arange(0, 128)), + dict(n=1460, m=16, emb_batch_size=128, offsets=[0, 2, 6, 20, 80]), + # dict(n=1460, m=16, emb_batch_size=128, offsets=[0, 2, 6, 20, 80], per_sample_weights=True), + # per_sample_weights not supported in ONNX + dict(n=1460, m=16, emb_batch_size=128, offsets=[0, 2, 6, 20, 20, 80]) # empty bag case + ] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_pytorch_embedding_bag(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params), ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_flatten.py b/tests/layer_tests/onnx_tests/test_flatten.py new file mode 100644 index 00000000000000..bc24e300c20693 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_flatten.py @@ -0,0 +1,302 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.onnx_layer_test_class import OnnxRuntimeLayerTest + + +class TestFlatten(OnnxRuntimeLayerTest): + def create_flatten_net(self, axis, input_shape, dim, ir_version, opset=None): + """ + ONNX net IR net + + Input->Flatten->Output => Input->Reshape + + """ + + # + # Create ONNX model + # + + # TODO: possible move all imports to separate func? + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, input_shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, dim) + + node_flatten_def = onnx.helper.make_node( + 'Flatten', + inputs=['input'], + outputs=['output'], + axis=axis, + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_flatten_def], + 'test_flatten_model', + [input], + [output], + ) + + # Create the model (ModelProto) + args = dict(producer_name='test_model') + if opset: + args['opset_imports'] = [helper.make_opsetid("", opset)] + onnx_net = helper.make_model(graph_def, **args) + + # + # Create reference IR net + # Please, spesify 'type': 'Input' for inpit node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + return onnx_net, ref_net + + def create_flatten_net_const(self, axis, input_shape, dim, ir_version, opset=None): + """ + ONNX net IR net + + Input->Flatten->Concat->Output => Input->Concat + Input-' Const-' + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + import numpy as np + + concat_axis = 0 + concat_output_shape = dim.copy() + concat_output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, dim) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, concat_output_shape) + + const_number = np.prod(input_shape) + constant = np.random.randint(-127, 127, const_number).astype(np.float) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=input_shape, + vals=constant, + ), + ) + + node_flatten_def = onnx.helper.make_node( + 'Flatten', + inputs=['const'], + outputs=['flatten_output'], + axis=axis, + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'flatten_output'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_flatten_def, node_concat_def], + 'test_flatten_model', + [input], + [output], + ) + + # Create the model (ModelProto) + args = dict(producer_name='test_model') + if opset: + args['opset_imports'] = [helper.make_opsetid("", opset)] + onnx_net = helper.make_model(graph_def, **args) + + # + # Create reference IR net + # Please, spesify 'type': 'Input' for inpit node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + return onnx_net, ref_net + + test_data_3D = [ + dict(axis=0, input_shape=[1, 3, 224], dim=[1, 672]), + dict(axis=-3, input_shape=[1, 3, 224], dim=[1, 672]), + dict(axis=1, input_shape=[1, 3, 224], dim=[1, 672]), + dict(axis=-2, input_shape=[1, 3, 224], dim=[1, 672]), + dict(axis=2, input_shape=[2, 3, 224], dim=[6, 224]), + dict(axis=-1, input_shape=[2, 3, 224], dim=[6, 224]), + dict(axis=3, input_shape=[3, 3, 224], dim=[2016, 1]) + ] + + test_data_4D_precommit = [ + dict(axis=1, input_shape=[1, 3, 224, 224], dim=[1, 150528]), + dict(axis=-3, input_shape=[1, 3, 224, 224], dim=[1, 150528]) + ] + + test_data_4D = [ + dict(axis=0, input_shape=[1, 3, 224, 224], dim=[1, 150528]), + dict(axis=-4, input_shape=[1, 3, 224, 224], dim=[1, 150528]), + dict(axis=1, input_shape=[1, 3, 224, 224], dim=[1, 150528]), + dict(axis=-3, input_shape=[1, 3, 224, 224], dim=[1, 150528]), + dict(axis=2, input_shape=[2, 3, 224, 224], dim=[6, 50176]), + dict(axis=-2, input_shape=[2, 3, 224, 224], dim=[6, 50176]), + dict(axis=3, input_shape=[3, 3, 224, 224], dim=[2016, 224]), + dict(axis=-1, input_shape=[3, 3, 224, 224], dim=[2016, 224]), + dict(axis=4, input_shape=[4, 3, 224, 224], dim=[602112, 1]) + ] + + test_data_5D_precommit = [ + dict(axis=-5, input_shape=[1, 3, 9, 224, 224], dim=[1, 1354752]), + dict(axis=5, input_shape=[4, 3, 9, 224, 224], dim=[5419008, 1])] + + test_data_5D = [ + dict(axis=0, input_shape=[1, 3, 9, 224, 224], dim=[1, 1354752]), + dict(axis=-5, input_shape=[1, 3, 9, 224, 224], dim=[1, 1354752]), + dict(axis=1, input_shape=[1, 3, 9, 224, 224], dim=[1, 1354752]), + dict(axis=-4, input_shape=[1, 3, 9, 224, 224], dim=[1, 1354752]), + dict(axis=2, input_shape=[2, 3, 9, 224, 224], dim=[6, 451584]), + dict(axis=-3, input_shape=[2, 3, 9, 224, 224], dim=[6, 451584]), + dict(axis=3, input_shape=[3, 3, 9, 224, 224], dim=[81, 50176]), + dict(axis=-2, input_shape=[3, 3, 9, 224, 224], dim=[81, 50176]), + dict(axis=4, input_shape=[3, 3, 9, 224, 224], dim=[18144, 224]), + dict(axis=-1, input_shape=[3, 3, 9, 224, 224], dim=[18144, 224]), + dict(axis=5, input_shape=[4, 3, 9, 224, 224], dim=[5419008, 1]) + ] + + @pytest.mark.parametrize("params", test_data_3D) + @pytest.mark.parametrize("opset", [6, 9]) + @pytest.mark.nightly + def test_flatten_3D(self, params, opset, ie_device, precision, ir_version, temp_dir): + # negative axis not allowed by onnx spec for flatten-1 and flatten-9 + if params['axis'] < 0: + self.skip_framework = True + else: + self.skip_framework = False + self._test(*self.create_flatten_net(**params, ir_version=ir_version, opset=opset), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_3D) + @pytest.mark.parametrize("opset", [6, 9]) + @pytest.mark.nightly + def test_flatten_3D_const(self, params, opset, ie_device, precision, ir_version, temp_dir): + # negative axis not allowed by onnx spec for flatten-1 and flatten-9 + if params['axis'] < 0: + self.skip_framework = True + else: + self.skip_framework = False + self._test(*self.create_flatten_net_const(**params, ir_version=ir_version, opset=opset), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.parametrize("opset", [6, 9]) + @pytest.mark.nightly + def test_flatten_4D(self, params, opset, ie_device, precision, ir_version, temp_dir): + # negative axis not allowed by onnx spec for flatten-1 and flatten-9 + if params['axis'] < 0: + self.skip_framework = True + else: + self.skip_framework = False + self._test(*self.create_flatten_net(**params, ir_version=ir_version, opset=opset), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_4D_precommit) + @pytest.mark.parametrize("opset", [6, 9]) + @pytest.mark.precommit + def test_flatten_4D_precommit(self, params, opset, ie_device, precision, ir_version, temp_dir): + # negative axis not allowed by onnx spec for flatten-1 and flatten-9 + if params['axis'] < 0: + self.skip_framework = True + else: + self.skip_framework = False + self._test(*self.create_flatten_net(**params, ir_version=ir_version, opset=opset), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_4D_precommit) + @pytest.mark.parametrize("opset", [6, 9]) + @pytest.mark.nightly + def test_flatten_4D_const_precommit(self, params, opset, ie_device, precision, ir_version, temp_dir): + # negative axis not allowed by onnx spec for flatten-1 and flatten-9 + if params['axis'] < 0: + self.skip_framework = True + else: + self.skip_framework = False + self._test(*self.create_flatten_net_const(**params, ir_version=ir_version, opset=opset), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.parametrize("opset", [6, 9]) + @pytest.mark.nightly + def test_flatten_4D_const(self, params, opset, ie_device, precision, ir_version, temp_dir): + # negative axis not allowed by onnx spec for flatten-1 and flatten-9 + if params['axis'] < 0: + self.skip_framework = True + else: + self.skip_framework = False + self._test(*self.create_flatten_net_const(**params, ir_version=ir_version, opset=opset), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_5D_precommit) + @pytest.mark.parametrize("opset", [6, 9]) + @pytest.mark.nightly + def test_flatten_5D_precommit(self, params, opset, ie_device, precision, ir_version, temp_dir): + # negative axis not allowed by onnx spec for flatten-1 and flatten-9 + if params['axis'] < 0: + self.skip_framework = True + else: + self.skip_framework = False + self._test(*self.create_flatten_net(**params, ir_version=ir_version, opset=opset), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.parametrize("opset", [6, 9]) + @pytest.mark.nightly + def test_flatten_5D(self, params, opset, ie_device, precision, ir_version, temp_dir): + # negative axis not allowed by onnx spec for flatten-1 and flatten-9 + if params['axis'] < 0: + self.skip_framework = True + else: + self.skip_framework = False + self._test(*self.create_flatten_net(**params, ir_version=ir_version, opset=opset), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_5D_precommit) + @pytest.mark.parametrize("opset", [6, 9]) + @pytest.mark.nightly + def test_flatten_5D_const_precommit(self, params, opset, ie_device, precision, ir_version, temp_dir): + # negative axis not allowed by onnx spec for flatten-1 and flatten-9 + if params['axis'] < 0: + self.skip_framework = True + else: + self.skip_framework = False + self._test(*self.create_flatten_net_const(**params, ir_version=ir_version, opset=opset), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.parametrize("opset", [6, 9]) + @pytest.mark.nightly + def test_flatten_5D_const(self, params, opset, ie_device, precision, ir_version, temp_dir): + # negative axis not allowed by onnx spec for flatten-1 and flatten-9 + if params['axis'] < 0: + self.skip_framework = True + else: + self.skip_framework = False + self._test(*self.create_flatten_net_const(**params, ir_version=ir_version, opset=opset), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_floor.py b/tests/layer_tests/onnx_tests/test_floor.py new file mode 100644 index 00000000000000..2d6be9c7262854 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_floor.py @@ -0,0 +1,179 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestFloor(OnnxRuntimeLayerTest): + def create_net(self, shape, ir_version): + """ + ONNX net IR net + + Input->Floor->Output => Input->Floor + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + node_def = onnx.helper.make_node( + 'Floor', + inputs=['input'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'Floor'}, + 'node_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result') + ]) + + return onnx_net, ref_net + + def create_net_const(self, shape, precision, ir_version): + """ + ONNX net IR net + + Input->Concat(+floored const)->Output => Input->Concat(+const) + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + import numpy as np + + concat_axis = 0 + output_shape = shape.copy() + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + constant = np.random.randn(*shape).astype(np.float) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + node_def = onnx.helper.make_node( + 'Floor', + inputs=['const1'], + outputs=['floor'] + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'floor'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + constant = np.floor(constant) + if precision == 'FP16': + constant = constant.astype(np.float16) + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': constant.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': shape, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result') + ]) + + return onnx_net, ref_net + + test_data = [dict(shape=[10, 12]), + dict(shape=[8, 10, 12]), + dict(shape=[6, 8, 10, 12]), + dict(shape=[4, 6, 8, 10, 12])] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_floor(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_floor_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_gather.py b/tests/layer_tests/onnx_tests/test_gather.py new file mode 100644 index 00000000000000..c4c0ee9c12e179 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_gather.py @@ -0,0 +1,261 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestGather(OnnxRuntimeLayerTest): + def create_net(self, shape, axis, indices, output_shape, ir_version): + """ + ONNX net IR net + + Input->Gather->Output => Input->Gather + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + indices = np.array(indices) + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + node_indices_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['indices'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.INT64, + dims=indices.shape, + vals=indices.flatten(), + ), + ) + + args = dict() + if axis: + args['axis'] = axis + else: + axis = 0 + node_def = onnx.helper.make_node( + 'Gather', + inputs=['input', 'indices'], + outputs=['output'], + **args + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_indices_def, node_def], + 'test_model', + [input], + [output] + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': indices.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': indices.shape, 'kind': 'data', 'value': None}, + 'input_axis_const_data': {'kind': 'data', 'value': [axis]}, + 'axis_const': {'kind': 'op', 'type': 'Const'}, + 'axis_const_data': {'shape': [], 'kind': 'data', 'value': None}, + 'node': {'kind': 'op', 'type': 'Gather'}, + 'node_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_axis_const_data', 'axis_const'), + ('axis_const', 'axis_const_data'), + ('input_data', 'node'), + ('const_data', 'node'), + ('axis_const_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result') + ]) + + return onnx_net, ref_net + + def create_net_const(self, shape, axis, indices, output_shape, ir_version): + """ + ONNX net IR net + + Input->Concat(+gathered const)->Output => Input->Concat(+const) + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + indices = np.array(indices) + + concat_axis = 0 + input_shape = output_shape.copy() + concat_output_shape = output_shape.copy() + concat_output_shape[concat_axis] = 2 * concat_output_shape[concat_axis] + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, input_shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, concat_output_shape) + + constant = np.random.randint(-127, 127, shape).astype(np.float) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + node_indices_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['indices'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.INT64, + dims=indices.shape, + vals=indices.flatten(), + ), + ) + + args = dict() + if axis: + args['axis'] = axis + node_def = onnx.helper.make_node( + 'Gather', + inputs=['const1', 'indices'], + outputs=['gather'], + **args + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'gather'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_indices_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + constant = np.take(constant, indices, axis=axis if axis else 0) + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': input_shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': constant.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': constant.shape, 'kind': 'data', 'value': None}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': concat_output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result') + ]) + + return onnx_net, ref_net + + test_data_precommit = [ + dict(shape=[6, 8, 10, 12], axis=2, indices=[[0, 2, 4], [5, 7, 9]], output_shape=[6, 8, 2, 3, 12]), + dict(shape=[4, 6, 8, 10, 12], axis=1, indices=[2, 5], output_shape=[4, 2, 8, 10, 12]), + dict(shape=[4, 6, 8, 10, 12], axis=-1, indices=[5, 8], output_shape=[4, 6, 8, 10, 2])] + + test_data = [dict(shape=[10, 12], axis=0, indices=[3, 6], output_shape=[2, 12]), + dict(shape=[10, 12], axis=1, indices=[4, 7], output_shape=[10, 2]), + dict(shape=[10, 12], axis=-1, indices=[4, 7], output_shape=[10, 2]), + dict(shape=[10, 12], axis=None, indices=[[0, 1, 3, 4], [5, 6, 8, 9]], output_shape=[2, 4, 12]), + dict(shape=[10, 12], axis=1, indices=[[0, 1, 3, 4, 5], [6, 7, 9, 10, 11]], output_shape=[10, 2, 5]), + dict(shape=[8, 10, 12], axis=0, indices=[3, 6], output_shape=[2, 10, 12]), + dict(shape=[8, 10, 12], axis=1, indices=[4, 7], output_shape=[8, 2, 12]), + dict(shape=[8, 10, 12], axis=2, indices=[5, 8], output_shape=[8, 10, 2]), + dict(shape=[8, 10, 12], axis=-1, indices=[5, 8], output_shape=[8, 10, 2]), + dict(shape=[8, 10, 12], axis=None, indices=[[0, 1], [3, 4], [6, 7]], output_shape=[3, 2, 10, 12]), + dict(shape=[8, 10, 12], axis=1, indices=[[0, 2, 4], [5, 7, 9]], output_shape=[8, 2, 3, 12]), + dict(shape=[6, 8, 10, 12], axis=0, indices=[2, 5], output_shape=[2, 8, 10, 12]), + dict(shape=[6, 8, 10, 12], axis=1, indices=[3, 6], output_shape=[6, 2, 10, 12]), + dict(shape=[6, 8, 10, 12], axis=2, indices=[4, 7], output_shape=[6, 8, 2, 12]), + dict(shape=[6, 8, 10, 12], axis=3, indices=[5, 8], output_shape=[6, 8, 10, 2]), + dict(shape=[6, 8, 10, 12], axis=-1, indices=[5, 8], output_shape=[6, 8, 10, 2]), + dict(shape=[6, 8, 10, 12], axis=None, indices=[[0, 1, 2], [3, 4, 5]], output_shape=[2, 3, 8, 10, 12]), + dict(shape=[6, 8, 10, 12], axis=2, indices=[[0, 2, 4], [5, 7, 9]], output_shape=[6, 8, 2, 3, 12]), + dict(shape=[4, 6, 8, 10, 12], axis=0, indices=[1, 3], output_shape=[2, 6, 8, 10, 12]), + dict(shape=[4, 6, 8, 10, 12], axis=1, indices=[2, 5], output_shape=[4, 2, 8, 10, 12]), + dict(shape=[4, 6, 8, 10, 12], axis=2, indices=[3, 6], output_shape=[4, 6, 2, 10, 12]), + dict(shape=[4, 6, 8, 10, 12], axis=3, indices=[4, 7], output_shape=[4, 6, 8, 2, 12]), + dict(shape=[4, 6, 8, 10, 12], axis=4, indices=[5, 8], output_shape=[4, 6, 8, 10, 2]), + dict(shape=[4, 6, 8, 10, 12], axis=-1, indices=[5, 8], output_shape=[4, 6, 8, 10, 2])] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_gather(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_gather(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_gather_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_gemm.py b/tests/layer_tests/onnx_tests/test_gemm.py new file mode 100644 index 00000000000000..83bbe411c04959 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_gemm.py @@ -0,0 +1,308 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import os + +import numpy as np +import pytest +import torch +from common.layer_test_class import CommonLayerTest +from common.onnx_layer_test_class import OnnxRuntimeLayerTest + + +class TestGemm(OnnxRuntimeLayerTest): + def _prepare_input(self, inputs_dict): + for input in inputs_dict.keys(): + inputs_dict[input] = np.random.randn(*inputs_dict[input]).astype(np.float32) + return inputs_dict + + def create_net(self, shapeA, shapeB, shapeC, alpha, beta, trans_a, trans_b, precision, ir_version): + """ + ONNX net IR net + + Input->Gemm->Output => Input->Concat + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + max_len = max([len(shapeA), len(shapeB)]) + extended_shape1 = np.concatenate([np.ones(max_len - len(shapeA)), shapeA], axis=0) + extended_shape2 = np.concatenate([np.ones(max_len - len(shapeB)), shapeB], axis=0) + output_shape = np.concatenate( + [np.maximum(*[extended_shape1[0:-2], extended_shape2[0:-2]]), [shapeA[-2], shapeB[-1]]], + axis=0).astype(np.int).tolist() + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shapeA) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + _shapeB = shapeB.copy() + if trans_b: + _shapeB.reverse() + const1 = np.random.ranf(_shapeB).astype(np.float) + const2 = np.random.ranf(shapeC).astype(np.float) + + node_const1_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=const1.shape, + vals=const1.flatten(), + ), + ) + + node_const2_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const2'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=const2.shape, + vals=const2.flatten(), + ), + ) + + attrs = dict() + if alpha: + attrs['alpha'] = alpha + if beta: + attrs['beta'] = beta + if trans_a: + attrs['transA'] = trans_a + if trans_b: + attrs['transB'] = trans_b + node_def = onnx.helper.make_node( + 'Gemm', + inputs=['input', 'const1', 'const2'], + outputs=['output'], + **attrs + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const1_def, node_const2_def, node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + if alpha: + const1 *= alpha + if beta: + const2 *= beta + if precision == 'FP16': + const1 = const1.astype(np.float16) + const2 = const2.astype(np.float16) + if not trans_b: + const1 = const1.transpose() + + ref_net = None + + return onnx_net, ref_net + + def create_net_double(self, shapeA, shapeB, shapeC, alpha, beta, trans_a, trans_b, precision, ir_version): + """ + ONNX net IR net + + Input->Gemm->Output => Input->Concat + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + _shapeA = shapeA.copy() + if trans_a: + _shapeA.reverse() + _shapeB = shapeB.copy() + if trans_b: + _shapeB.reverse() + + max_len = max([len(shapeA), len(shapeB)]) + extended_shape1 = np.concatenate([np.ones(max_len - len(shapeA)), shapeA], axis=0) + extended_shape2 = np.concatenate([np.ones(max_len - len(shapeB)), shapeB], axis=0) + output_shape = np.concatenate( + [np.maximum(*[extended_shape1[0:-2], extended_shape2[0:-2]]), [shapeA[-2], shapeB[-1]]], + axis=0).astype(np.int).tolist() + input1 = helper.make_tensor_value_info('input1', TensorProto.FLOAT, _shapeA) + input2 = helper.make_tensor_value_info('input2', TensorProto.FLOAT, _shapeB) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + const = np.random.ranf(shapeC).astype(np.float) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=const.shape, + vals=const.flatten(), + ), + ) + + attrs = dict() + if alpha: + attrs['alpha'] = alpha + if beta: + attrs['beta'] = beta + if trans_a: + attrs['transA'] = trans_a + if trans_b: + attrs['transB'] = trans_b + node_def = onnx.helper.make_node( + 'Gemm', + inputs=['input1', 'input2', 'const'], + outputs=['output'], + **attrs + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def], + 'test_model', + [input1, input2], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + if precision == 'FP16': + const = const.astype(np.float16) + ref_net = None + + return onnx_net, ref_net + + test_data = [ + dict(shapeA=[3, 6], shapeB=[6, 4], shapeC=[3, 4]) + ] + + test_data_bc = [ + dict(shapeA=[3, 6], shapeB=[6, 4], shapeC=[4]) + ] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.parametrize("alpha", [None, 0.1, 2.0]) + @pytest.mark.parametrize("beta", [None, 0.1, 2.0]) + @pytest.mark.parametrize("trans_a", [None]) + @pytest.mark.parametrize("trans_b", [None, 1]) + @pytest.mark.nightly + @pytest.mark.precommit + def test_gemm(self, params, alpha, beta, trans_a, trans_b, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(params['shapeA'], params['shapeB'], params['shapeC'], alpha, beta, trans_a, + trans_b, precision, ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_bc) + @pytest.mark.parametrize("alpha", [None, 0.1, 2.0]) + @pytest.mark.parametrize("beta", [None, 0.1, 2.0]) + @pytest.mark.parametrize("trans_a", [None]) # transA is not supported + @pytest.mark.parametrize("trans_b", [None, 1]) + @pytest.mark.nightly + @pytest.mark.precommit + def test_gemm_bc(self, params, alpha, beta, trans_a, trans_b, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(params['shapeA'], params['shapeB'], params['shapeC'], alpha, beta, trans_a, + trans_b, precision, ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.parametrize("alpha", [None, 0.1, 2.0]) + @pytest.mark.parametrize("beta", [None, 0.1, 2.0]) + @pytest.mark.parametrize("trans_a", [None, 1]) + @pytest.mark.parametrize("trans_b", [None, 1]) + @pytest.mark.nightly + @pytest.mark.precommit + def test_gemm_double(self, params, alpha, beta, trans_a, trans_b, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_double(params['shapeA'], params['shapeB'], params['shapeC'], alpha, beta, + trans_a, trans_b, precision, ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_bc) + @pytest.mark.parametrize("alpha", [None, 0.1, 2.0]) + @pytest.mark.parametrize("beta", [None, 0.1, 2.0]) + @pytest.mark.parametrize("trans_a", [None, 1]) + @pytest.mark.parametrize("trans_b", [None, 1]) + @pytest.mark.nightly + @pytest.mark.precommit + def test_gemm_double_bc(self, params, alpha, beta, trans_a, trans_b, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_double(params['shapeA'], params['shapeB'], params['shapeC'], alpha, beta, + trans_a, trans_b, precision, ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + +class PytorchLayerTest(CommonLayerTest): + def produce_model_path(self, framework_model, save_path): + path = os.path.join(save_path, 'model.onnx') + self.torch_model = framework_model['model'] + torch.onnx.export(self.torch_model, framework_model['var'], path, input_names=['input'], + output_names=['output']) + assert os.path.isfile(path), "model.onnx haven't been saved here: {}".format(save_path) + return path + + def get_framework_results(self, inputs_dict, model_path): + x = torch.tensor(inputs_dict['input'], dtype=torch.float32) + return {'output': self.torch_model(x).numpy()} + + +class GemmModel(torch.nn.Module): + def __init__(self, weights): + super(GemmModel, self).__init__() + self.weights = torch.from_numpy(weights) + + +class TestPytorchMM(PytorchLayerTest): + def create_net(self, precision, shape, w_shape, output_shape, ir_version): + """ + Pytorch net IR net + + Input->MM->Output => Input->FullyConnected + + """ + + weights_const = np.random.randn(*w_shape).astype(np.float32) + # Create Pytorch model + model = GemmModel(weights_const) + + if precision == 'FP16': + weights_const = weights_const.astype(np.float16) + + # Create reference IR net + + # TODO: add reference IR net. Now it is omitted since inference is more + # important and needs to be checked in the first + + ref_net = None + + return {'model': model, 'var': torch.randn(shape)}, ref_net + + test_data = [dict(shape=[1, 2048], w_shape=[2048, 3], output_shape=[1, 3])] + + # TODO mark as precommit (after successfully passing in nightly) + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_pytorch_mm(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(precision, **params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_hard_sigmoid.py b/tests/layer_tests/onnx_tests/test_hard_sigmoid.py new file mode 100644 index 00000000000000..e460d733e1c1f5 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_hard_sigmoid.py @@ -0,0 +1,235 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestHardSigmoid(OnnxRuntimeLayerTest): + def _prepare_input(self, inputs_dict): + for input in inputs_dict.keys(): + inputs_dict[input] = np.random.randn(*inputs_dict[input]).astype(np.float32) + return inputs_dict + + def create_net(self, shape, alpha, beta, ir_version): + """ + ONNX net IR net + + Input->HardSigmoid->Output => Input->HardSigmoid + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + args = dict() + if alpha is not None: + args['alpha'] = alpha + if beta is not None: + args['beta'] = beta + node_def = onnx.helper.make_node( + 'HardSigmoid', + inputs=['input'], + outputs=['output'], + **args + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'input_alpha_data': {'kind': 'data', 'value': [alpha if alpha is not None else 0.2]}, + 'alpha': {'kind': 'op', 'type': 'Const'}, + 'alpha_data': {'shape': [], 'kind': 'data'}, + 'input_beta_data': {'kind': 'data', 'value': [beta if beta is not None else 0.5]}, + 'beta': {'kind': 'op', 'type': 'Const'}, + 'beta_data': {'shape': [], 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'HardSigmoid'}, + 'node_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_alpha_data', 'alpha'), + ('alpha', 'alpha_data'), + ('input_beta_data', 'beta'), + ('beta', 'beta_data'), + ('input_data', 'node'), + ('alpha_data', 'node'), + ('beta_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result') + ]) + + return onnx_net, ref_net + + def create_net_const(self, shape, alpha, beta, precision, ir_version): + """ + ONNX net IR net + + Input->Concat(+hard sigmoid const)->Output => Input->Concat(+const) + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + import numpy as np + + concat_axis = 0 + output_shape = shape.copy() + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + const_number = np.prod(shape) + constant = np.random.randint(-127, 127, const_number).astype(np.float) + constant = np.reshape(constant, shape) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + args = dict() + if alpha is not None: + args['alpha'] = alpha + if beta is not None: + args['beta'] = beta + node_def = onnx.helper.make_node( + 'HardSigmoid', + inputs=['const1'], + outputs=['sigmoid1'], + **args + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'sigmoid1'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + constant = np.clip(constant * (alpha if alpha is not None else 0.2) + (beta if beta is not None else 0.5), 0, 1) + if precision == 'FP16': + constant = constant.astype(np.float16) + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': constant.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': shape, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result') + ]) + + return onnx_net, ref_net + + test_data_precommit = [ + dict(shape=[1, 2], alpha=None, beta=None), + dict(shape=[2, 3, 4, 5, 6], alpha=None, beta=0.7)] + + test_data = [ + dict(shape=[10, 12], alpha=None, beta=None), + dict(shape=[8, 10, 12], alpha=None, beta=None), + dict(shape=[6, 8, 10, 12], alpha=None, beta=None), + dict(shape=[4, 6, 8, 10, 12], alpha=None, beta=None), + dict(shape=[10, 12], alpha=0.3, beta=None), + dict(shape=[8, 10, 12], alpha=0.3, beta=None), + dict(shape=[6, 8, 10, 12], alpha=0.3, beta=None), + dict(shape=[4, 6, 8, 10, 12], alpha=0.3, beta=None), + dict(shape=[10, 12], alpha=None, beta=0.7), + dict(shape=[8, 10, 12], alpha=None, beta=0.7), + dict(shape=[6, 8, 10, 12], alpha=None, beta=0.7), + dict(shape=[4, 6, 8, 10, 12], alpha=None, beta=0.7), + dict(shape=[10, 12], alpha=0.1, beta=0.3), + dict(shape=[8, 10, 12], alpha=0.1, beta=0.3), + dict(shape=[6, 8, 10, 12], alpha=0.1, beta=0.3), + dict(shape=[4, 6, 8, 10, 12], alpha=0.1, beta=0.3)] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_hard_sigmoid(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.nightly + def test_hard_sigmoid_const_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_hard_sigmoid_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_identity.py b/tests/layer_tests/onnx_tests/test_identity.py new file mode 100644 index 00000000000000..e7d8d8acd65bf9 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_identity.py @@ -0,0 +1,183 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import Caffe2OnnxLayerTest +from unit_tests.utils.graph import build_graph + + +class TestIdentity(Caffe2OnnxLayerTest): + def create_net(self, shape, ir_version): + """ + ONNX net IR net + + Input->Identity->Sigmoid->Output => Input->sigmoid + + """ + + # + # Create ONNX model + # + + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + node_def = helper.make_node( + 'Identity', + inputs=['input'], + outputs=['identity'] + ) + + sigmoid_def = helper.make_node( + 'Sigmoid', + inputs=['identity'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def, sigmoid_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'sigmoid': {'kind': 'op', 'type': 'Sigmoid'}, + 'sigmoid_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'sigmoid'), + ('sigmoid', 'sigmoid_data'), + ('sigmoid_data', 'result') + ]) + + return onnx_net, ref_net + + def create_net_const(self, shape, precision, ir_version): + """ + ONNX net IR net + + Input->Concat(+identity on const)->Output => Input->Concat(+const) + + """ + + # + # Create ONNX model + # + + from onnx import helper + from onnx import TensorProto + + constant = np.random.randint(-127, 127, shape).astype(np.float) + + concat_axis = 0 + output_shape = shape.copy() + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + node_const_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + node_def = helper.make_node( + 'Identity', + inputs=['const1'], + outputs=['identity'] + ) + + node_concat_def = helper.make_node( + 'Concat', + inputs=['input', 'identity'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': constant.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': shape, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result') + ]) + + return onnx_net, ref_net + + test_data = [dict(shape=[10, 12]), + dict(shape=[8, 10, 12]), + dict(shape=[6, 8, 10, 12]), + dict(shape=[4, 6, 8, 10, 12])] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_identity(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_identity_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_image_scaler.py b/tests/layer_tests/onnx_tests/test_image_scaler.py new file mode 100644 index 00000000000000..ee4f3490b7d5df --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_image_scaler.py @@ -0,0 +1,161 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.onnx_layer_test_class import Caffe2OnnxLayerTest + + +class TestImageScaler(Caffe2OnnxLayerTest): + def create_net(self, shape, scale, ir_version): + """ + ONNX net IR net + + Input->ImageScaler->Output => Input->ScaleShift(Power) + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + bias = np.random.randint(-10, 10, shape[1]).astype(np.float) + + node_def = onnx.helper.make_node( + 'ImageScaler', + inputs=['input'], + outputs=['output'], + bias=bias, + scale=scale + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + + return onnx_net, ref_net + + def create_net_const(self, shape, scale, precision, ir_version): + """ + ONNX net IR net + + Input->Concat(+scaled const)->Output => Input->Concat(+const) + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + concat_axis = 0 + output_shape = shape.copy() + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + constant = np.random.randint(-127, 127, shape).astype(np.float) + bias = np.random.randint(-10, 10, shape[1]).astype(np.float) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + node_def = onnx.helper.make_node( + 'ImageScaler', + inputs=['const1'], + outputs=['scale'], + bias=bias, + scale=scale + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'scale'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + ir_const = constant * scale + np.expand_dims(np.expand_dims([bias], 2), 3) + if precision == 'FP16': + ir_const = ir_const.astype(np.float16) + + ref_net = None + + return onnx_net, ref_net + + test_data_precommit = [dict(shape=[2, 4, 6, 8], scale=4.5), + dict(shape=[1, 1, 10, 12], scale=0.5)] + + test_data = [dict(shape=[1, 1, 10, 12], scale=0.5), + dict(shape=[1, 3, 10, 12], scale=1.5), + dict(shape=[6, 8, 10, 12], scale=4.5)] + + @pytest.mark.parametrize("params", test_data_precommit) + def test_image_scaler_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_image_scaler(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_precommit) + def test_image_scaler_const_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_image_scaler_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_instance_normalization.py b/tests/layer_tests/onnx_tests/test_instance_normalization.py new file mode 100644 index 00000000000000..d7467f0951b4c3 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_instance_normalization.py @@ -0,0 +1,111 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.onnx_layer_test_class import OnnxRuntimeLayerTest + + +class TestInstanceNormalization(OnnxRuntimeLayerTest): + def create_net(self, shape, epsilon, precision, ir_version): + """ + ONNX net IR net + + Input->InstanceNormalization->Output => Input->MVN->ScaleShift(Power) + """ + + # + # Create ONNX model + # + + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + scale_const = np.random.randn(shape[1]).astype(np.float) + bias_const = np.random.randn(shape[1]).astype(np.float) + + node_scale_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['scale'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=scale_const.shape, + vals=scale_const.flatten(), + ), + ) + + node_bias_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['bias'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=bias_const.shape, + vals=bias_const.flatten(), + ), + ) + + args = dict() + if epsilon: + args['epsilon'] = epsilon + node_def = helper.make_node( + 'InstanceNormalization', + inputs=['input', 'scale', 'bias'], + outputs=['output'], + **args + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_scale_def, node_bias_def, node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + ref_net = None + + return onnx_net, ref_net + + test_data_precommit = [ + dict(shape=[1, 1, 4, 6], epsilon=0.001), + dict(shape=[1, 1, 2, 4, 6], epsilon=0.001)] + + test_data = [ + dict(shape=[1, 1, 4, 6], epsilon=None), + dict(shape=[1, 1, 4, 6], epsilon=0.001), + dict(shape=[1, 2, 4, 6], epsilon=None), + dict(shape=[1, 2, 4, 6], epsilon=0.001), + dict(shape=[2, 3, 4, 6], epsilon=None), + dict(shape=[2, 3, 4, 6], epsilon=0.001), + dict(shape=[1, 1, 2, 4, 6], epsilon=None), + dict(shape=[1, 1, 2, 4, 6], epsilon=0.001), + dict(shape=[1, 2, 4, 6, 6], epsilon=None), + dict(shape=[1, 2, 4, 6, 6], epsilon=0.001), + dict(shape=[2, 3, 4, 6, 6], epsilon=None), + dict(shape=[2, 3, 4, 6, 6], epsilon=0.001)] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_instance_normalization(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_instance_normalization(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_leaky_relu.py b/tests/layer_tests/onnx_tests/test_leaky_relu.py new file mode 100644 index 00000000000000..985ff27b801d4d --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_leaky_relu.py @@ -0,0 +1,204 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import Caffe2OnnxLayerTest +from unit_tests.utils.graph import build_graph + + +class TestLeakyRelu(Caffe2OnnxLayerTest): + def create_net(self, shape, alpha, ir_version): + """ + ONNX net IR net + + Input->LeakyRelu->Output => Input->ReLU + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + node_def = onnx.helper.make_node( + 'LeakyRelu', + inputs=['input'], + outputs=['output'], + alpha=alpha + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'alpha_indata': {'value': alpha, 'kind': 'data'}, + 'alpha': {'kind': 'op', 'type': 'Const'}, + 'alpha_data': {'shape': [1], 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'PReLU'}, + 'node_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('alpha_indata', 'alpha'), + ('alpha', 'alpha_data'), + ('alpha_data', 'node'), + ('input_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result')]) + + return onnx_net, ref_net + + def create_net_const(self, shape, alpha, precision, ir_version): + """ + ONNX net IR net + + Input->Concat(+LeakyRelu const)->Output => Input->Concat(+ReLU const) + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + import numpy as np + + concat_axis = 0 + output_shape = shape.copy() + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + const_number = np.prod(shape) + constant = np.random.randint(-127, 127, const_number).astype(np.float) + constant = np.reshape(constant, shape) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + node_def = onnx.helper.make_node( + 'LeakyRelu', + inputs=['const1'], + outputs=['lrelu1'], + alpha=alpha + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'lrelu1'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + constant = np.clip(constant, 0, np.inf) + np.clip(constant, -np.inf, 0) * alpha + if precision == 'FP16': + constant = constant.astype(np.float16) + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'const_indata': {'shape': None, 'kind': 'data'}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': shape, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('const_indata', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result')]) + + return onnx_net, ref_net + + test_data_precommit = [ + dict(shape=[1, 2], alpha=0.1), + dict(shape=[2, 3, 4, 5, 6], alpha=4.5)] + + test_data = [ + dict(shape=[10, 12], alpha=0.1), + dict(shape=[8, 10, 12], alpha=0.9), + dict(shape=[6, 8, 10, 12], alpha=1.5), + dict(shape=[4, 6, 8, 10, 12], alpha=4.5)] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_leaky_relu_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_leaky_relu(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_leaky_relu_const_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_leaky_relu_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_log.py b/tests/layer_tests/onnx_tests/test_log.py new file mode 100644 index 00000000000000..1b284b211ef686 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_log.py @@ -0,0 +1,193 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestLog(OnnxRuntimeLayerTest): + def _prepare_input(self, inputs_dict): + for input in inputs_dict.keys(): + inputs_dict[input] = np.random.rand(*(inputs_dict[input])).astype(np.float32) * 255 + 0.5 + return inputs_dict + + def create_net(self, shape, ir_version): + """ + ONNX net IR net + + Input->Log->Output => Input->Log + + """ + + # + # Create ONNX model + # + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + node_def = onnx.helper.make_node( + 'Log', + inputs=['input'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'Log'}, + 'node_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, [('input', 'input_data'), + ('input_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result')]) + + return onnx_net, ref_net + + def create_net_const(self, shape, precision, ir_version): + """ + ONNX net IR net + + Input->Concat(+log const)->Output => Input->Concat(+const) + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + concat_axis = 0 + output_shape = shape.copy() + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + constant = np.random.rand(*shape).astype(np.float) * 255 + 0.5 + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + node_def = onnx.helper.make_node( + 'Log', + inputs=['const'], + outputs=['log'] + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'log'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + constant = np.log(constant) + if precision == 'FP16': + constant = constant.astype(np.float16) + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': constant.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': shape, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result')]) + + return onnx_net, ref_net + + test_data_precommit = [dict(shape=[1, 2]), + dict(shape=[2, 3, 4, 5, 6])] + + test_data = [dict(shape=[10, 12]), + dict(shape=[8, 10, 12]), + dict(shape=[6, 8, 10, 12]), + dict(shape=[4, 6, 8, 10, 12])] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_log_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_log(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.nightly + def test_log_const_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_log_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_logsoftmax.py b/tests/layer_tests/onnx_tests/test_logsoftmax.py new file mode 100644 index 00000000000000..6371eae1a6642c --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_logsoftmax.py @@ -0,0 +1,240 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from mo.front.common.partial_infer.utils import int64_array +from unit_tests.utils.graph import build_graph + + +def second_input_data_of_reshape(src_shape, axis): + if axis == 0: + return [1, -1] + if axis == 1: + return [0, -1] + if axis > 1: + return [int(np.prod(int64_array(src_shape[: axis]))), -1] + return [-1, int(np.prod(int64_array(src_shape[len(src_shape) + axis:])))] + + +def get_flatten_shape(src_shape, axis): + flatten_axis = axis if axis >= 0 else len(src_shape) + axis + if flatten_axis == 0: + fst_dim = 1 + snd_dim = int(np.prod(int64_array(src_shape))) + elif flatten_axis == 1: + fst_dim = src_shape[0] + snd_dim = int(np.prod(int64_array(src_shape[1:]))) + else: + fst_dim = int(np.prod(int64_array(src_shape[: flatten_axis]))) + snd_dim = int(np.prod(int64_array(src_shape[flatten_axis:]))) + return [fst_dim, snd_dim] + + +class TestLog(OnnxRuntimeLayerTest): + def _prepare_input(self, inputs_dict): + for input in inputs_dict.keys(): + inputs_dict[input] = np.random.rand(*(inputs_dict[input])).astype(np.float32) * 255 + 0.5 + return inputs_dict + + def create_net(self, shape, logsoftmax_axis, ir_version): + """ + ONNX net IR net + + Input->LogSoftmax->Output => Input->Softmax->Log->Output + + """ + + # + # Create ONNX model + # + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + node_def = onnx.helper.make_node( + 'LogSoftmax', + inputs=['input'], + outputs=['output'], + axis=logsoftmax_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + ref_net = None + if check_ir_version(10, None, ir_version): + converted_shape = shape if len(shape) != 1 else shape[0] + flatten_shape = get_flatten_shape(shape, logsoftmax_axis) + reshape_data_val = second_input_data_of_reshape(shape, logsoftmax_axis) + reduce_sum_shape = np.copy(flatten_shape) + reduce_sum_shape[1] = 1 + + if len(shape) == 2 and shape == flatten_shape: + ref_nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter', 'shape': converted_shape}, + 'input_data': {'shape': shape, 'kind': 'data', 'value': None}, + 'flatten_shape_val': {'shape': int64_array(reshape_data_val).shape, + 'kind': 'data', + 'value': int64_array(reshape_data_val)}, + 'flatten_shape': {'type': 'Const', 'kind': 'op', 'shape': 2}, + 'flatten_shape_data': {'shape': int64_array([2]), 'kind': 'data', 'value': None}, + 'reshape': {'kind': 'op', 'type': 'Reshape'}, + 'reshape_data': {'kind': 'data', 'shape': flatten_shape, 'value': None}, + 'reduce_max_axis_val': {'shape': int64_array([1]).shape, 'kind': 'data', 'value': int64_array([1])}, + 'reduce_max_axis': {'type': 'Const', 'kind': 'op', 'shape': 1}, + 'reduce_max_axis_data': {'shape': int64_array([1]), 'kind': 'data', 'value': None}, + 'reduce_max': {'type': 'ReduceMax', 'kind': 'op', 'keep_dims': True}, + 'reduce_max_data': {'shape': reduce_sum_shape, 'kind': 'data', 'value': None}, + 'sub_first': {'type': 'Subtract', 'kind': 'op'}, + 'sub_first_data': {'shape': flatten_shape, 'kind': 'data', 'value': None}, + 'reduce_sum_axis_val': {'shape': int64_array([1]).shape, 'kind': 'data', 'value': int64_array([1])}, + 'reduce_sum_axis': {'type': 'Const', 'kind': 'op', 'shape': 1}, + 'reduce_sum_axis_data': {'shape': int64_array([1]), 'kind': 'data', 'value': None}, + 'reduce_sum': {'type': 'ReduceSum', 'kind': 'op', 'keep_dims': True}, + 'reduce_sum_data': {'shape': reduce_sum_shape, 'kind': 'data', 'value': None}, + 'exp': {'type': 'Exp', 'kind': 'op'}, + 'exp_data': {'shape': flatten_shape, 'kind': 'data', 'value': None}, + 'log': {'type': 'Log', 'kind': 'op'}, + 'log_data': {'shape': reduce_sum_shape, 'kind': 'data', 'value': None}, + 'sub_second': {'type': 'Subtract', 'kind': 'op'}, + 'sub_second_data': {'shape': flatten_shape, 'kind': 'data', 'value': None}, + 'result': {'kind': 'op', 'type': 'Result'}, + } + + ref_edges = [ + ('input', 'input_data'), + ('flatten_shape_val', 'flatten_shape'), + ('flatten_shape', 'flatten_shape_data'), + ('flatten_shape_data', 'reshape', {'in': 1}), + ('input_data', 'reshape', {'in': 0}), + ('reshape', 'reshape_data'), + ('reduce_max_axis_val', 'reduce_max_axis'), + ('reduce_max_axis', 'reduce_max_axis_data'), + ('reduce_max_axis_data', 'reduce_max', {'in': 1}), + ('reduce_max', 'reduce_max_data'), + ('reshape_data', 'reduce_max', {'out': 0, 'in': 0}), + ('reshape_data', 'sub_first', {'out': 0, 'in': 0}), + ('reduce_max_data', 'sub_first', {'in': 1}), + ('sub_first', 'sub_first_data'), + ('reduce_sum_axis_val', 'reduce_sum_axis'), + ('reduce_sum_axis', 'reduce_sum_axis_data'), + ('reduce_sum_axis_data', 'reduce_sum', {'in': 1}), + ('reduce_sum', 'reduce_sum_data'), + ('sub_first_data', 'exp'), + ('exp', 'exp_data'), + ('exp_data', 'reduce_sum', {'in': 0}), + ('reduce_sum_data', 'log'), + ('log', 'log_data'), + ('log_data', 'sub_second', {'in': 1}), + ('sub_second', 'sub_second_data'), + ('sub_first_data', 'sub_second', {'out': 0, 'in': 0}), + ('sub_second_data', 'result'), + ] + else: + ref_nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter', 'shape': converted_shape}, + 'input_data': {'shape': shape, 'kind': 'data', 'value': None}, + 'flatten_shape_val': {'shape': int64_array(reshape_data_val).shape, + 'kind': 'data', + 'value': int64_array(reshape_data_val)}, + 'flatten_shape': {'type': 'Const', 'kind': 'op', 'shape': 2}, + 'flatten_shape_data': {'shape': int64_array([2]), 'kind': 'data', 'value': None}, + 'reshape': {'kind': 'op', 'type': 'Reshape'}, + 'reshape_data': {'kind': 'data', 'shape': flatten_shape, 'value': None}, + 'reduce_max_axis_val': {'shape': int64_array([1]).shape, 'kind': 'data', 'value': int64_array([1])}, + 'reduce_max_axis': {'type': 'Const', 'kind': 'op', 'shape': 1}, + 'reduce_max_axis_data': {'shape': int64_array([1]), 'kind': 'data', 'value': None}, + 'reduce_max': {'type': 'ReduceMax', 'kind': 'op', 'keep_dims': True}, + 'reduce_max_data': {'shape': reduce_sum_shape, 'kind': 'data', 'value': None}, + 'sub_first': {'type': 'Subtract', 'kind': 'op'}, + 'sub_first_data': {'shape': flatten_shape, 'kind': 'data', 'value': None}, + 'reduce_sum_axis_val': {'shape': int64_array([1]).shape, 'kind': 'data', 'value': int64_array([1])}, + 'reduce_sum_axis': {'type': 'Const', 'kind': 'op', 'shape': 1}, + 'reduce_sum_axis_data': {'shape': int64_array([1]), 'kind': 'data', 'value': None}, + 'reduce_sum': {'type': 'ReduceSum', 'kind': 'op', 'keep_dims': True}, + 'reduce_sum_data': {'shape': reduce_sum_shape, 'kind': 'data', 'value': None}, + 'exp': {'type': 'Exp', 'kind': 'op'}, + 'exp_data': {'shape': flatten_shape, 'kind': 'data', 'value': None}, + 'log': {'type': 'Log', 'kind': 'op'}, + 'log_data': {'shape': reduce_sum_shape, 'kind': 'data', 'value': None}, + 'sub_second': {'type': 'Subtract', 'kind': 'op'}, + 'sub_second_data': {'shape': flatten_shape, 'kind': 'data', 'value': None}, + 'last_shape_val': {'shape': int64_array(shape).shape, 'kind': 'data', 'value': int64_array(shape)}, + 'last_shape': {'type': 'Const', 'kind': 'op', 'shape': len(shape)}, + 'last_shape_data': {'shape': int64_array([len(shape)]), 'kind': 'data', 'value': None}, + 'last_reshape': {'kind': 'op', 'type': 'Reshape'}, + 'last_reshape_data': {'kind': 'data', 'shape': shape, 'value': None}, + 'result': {'kind': 'op', 'type': 'Result'}, + } + + ref_edges = [ + ('input', 'input_data'), + ('flatten_shape_val', 'flatten_shape'), + ('flatten_shape', 'flatten_shape_data'), + ('flatten_shape_data', 'reshape', {'in': 1}), + ('input_data', 'reshape', {'in': 0}), + ('reshape', 'reshape_data'), + ('reduce_max_axis_val', 'reduce_max_axis'), + ('reduce_max_axis', 'reduce_max_axis_data'), + ('reduce_max_axis_data', 'reduce_max', {'in': 1}), + ('reduce_max', 'reduce_max_data'), + ('reshape_data', 'reduce_max', {'out': 0, 'in': 0}), + ('reshape_data', 'sub_first', {'out': 0, 'in': 0}), + ('reduce_max_data', 'sub_first', {'in': 1}), + ('sub_first', 'sub_first_data'), + ('reduce_sum_axis_val', 'reduce_sum_axis'), + ('reduce_sum_axis', 'reduce_sum_axis_data'), + ('reduce_sum_axis_data', 'reduce_sum', {'in': 1}), + ('reduce_sum', 'reduce_sum_data'), + ('sub_first_data', 'exp'), + ('exp', 'exp_data'), + ('exp_data', 'reduce_sum', {'in': 0}), + ('reduce_sum_data', 'log'), + ('log', 'log_data'), + ('log_data', 'sub_second', {'in': 1}), + ('sub_second', 'sub_second_data'), + ('sub_first_data', 'sub_second', {'out': 0, 'in': 0}), + ('last_shape_val', 'last_shape'), + ('last_shape', 'last_shape_data'), + ('last_shape_data', 'last_reshape', {'in': 1}), + ('sub_second_data', 'last_reshape', {'in': 0}), + ('last_reshape', 'last_reshape_data'), + ('last_reshape_data', 'result'), + ] + + ref_net = build_graph(ref_nodes_attributes, ref_edges) + return onnx_net, ref_net + + test_data_precommit = [ + dict(shape=[2, 4], logsoftmax_axis=-1), + dict(shape=[2, 3, 2, 5, 6], logsoftmax_axis=-2)] + + test_data = [ + dict(shape=[10, 12], logsoftmax_axis=-1), + dict(shape=[4, 5, 3], logsoftmax_axis=1), + dict(shape=[6, 8, 5, 7], logsoftmax_axis=2), + dict(shape=[2, 3, 2, 5, 6], logsoftmax_axis=-2)] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_log(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_lrn.py b/tests/layer_tests/onnx_tests/test_lrn.py new file mode 100644 index 00000000000000..66104f467b9c23 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_lrn.py @@ -0,0 +1,133 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestLRN(OnnxRuntimeLayerTest): + def create_net(self, shape, alpha, beta, bias, size, ir_version): + """ + ONNX net IR net + + Input->LRN->Output => Input->Norm->Power + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + args = dict(size=size) + if alpha: + args['alpha'] = alpha + if beta: + args['beta'] = beta + if bias: + args['bias'] = bias + node_def = onnx.helper.make_node( + 'LRN', + inputs=['input'], + outputs=['output'], + **args + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # Create reference IR net + if not alpha: + alpha = 0.0001 + if not beta: + beta = 0.75 + if not bias: + bias = 1.0 + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'const_indata': {'value': [1], 'kind': 'data'}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': [1], 'kind': 'data'}, + 'norm': {'kind': 'op', 'type': 'LRN', 'alpha': alpha / bias, 'beta': beta, 'bias': bias, + 'size': size}, # 'region': 'across' + 'norm_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + edges = [('input', 'input_data'), + ('input_data', 'norm'), + ('const_indata', 'const'), + ('const', 'const_data'), + ('const_data', 'norm'), + ('norm', 'norm_data'), + ('norm_data', 'result') + ] + + ref_net = build_graph(nodes_attributes, edges) + + return onnx_net, ref_net + + test_data_precommit = [ + dict(shape=[2, 12], alpha=None, beta=None, bias=None, size=1), + pytest.param(dict(shape=[2, 3, 12], alpha=0.0002, beta=0.5, bias=2.0, size=3), + marks=pytest.mark.skip(reason="Skipped until fixed")), + dict(shape=[2, 3, 12], alpha=0.0002, beta=0.5, bias=2.0, size=3), + dict(shape=[2, 3, 12], alpha=0.0002, beta=0.5, bias=2.0, size=3)] + + test_data = [ + dict(shape=[2, 12], alpha=None, beta=None, bias=None, size=1), + dict(shape=[2, 12], alpha=0.0002, beta=0.5, bias=2.0, size=1), + dict(shape=[2, 3, 12], alpha=None, beta=None, bias=None, size=3), + dict(shape=[2, 3, 12], alpha=0.0002, beta=0.5, bias=2.0, size=1), + dict(shape=[2, 3, 12], alpha=0.0002, beta=0.5, bias=2.0, size=3), + dict(shape=[2, 3, 8, 10, 12], alpha=None, beta=None, bias=None, size=3), + dict(shape=[2, 3, 8, 10, 12], alpha=0.0002, beta=0.5, bias=2.0, size=1), + dict(shape=[2, 3, 8, 10, 12], alpha=0.0002, beta=0.5, bias=2.0, size=3)] + + test_data_4D = [ + dict(shape=[2, 3, 10, 12], alpha=None, beta=None, bias=None, size=3), + dict(shape=[2, 3, 10, 12], alpha=0.0002, beta=0.5, bias=2.0, size=1), + dict(shape=[2, 3, 10, 12], alpha=0.0002, beta=0.5, bias=2.0, size=3)] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_lrn_precommit(self, params, ie_device, precision, ir_version, temp_dir): + # onnxruntime only supports 4D tensors for LRN + self.skip_framework = True + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_lrn(self, params, ie_device, precision, ir_version, temp_dir): + # onnxruntime only supports 4D tensors for LRN + self.skip_framework = True + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + @pytest.mark.precommit + def test_lrn_4D(self, params, ie_device, precision, ir_version, temp_dir): + self.skip_framework = False + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_lstm.py b/tests/layer_tests/onnx_tests/test_lstm.py new file mode 100644 index 00000000000000..e142d0070a40c2 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_lstm.py @@ -0,0 +1,160 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.onnx_layer_test_class import Caffe2OnnxLayerTest + + +class TestLSTM(Caffe2OnnxLayerTest): + skip_framework = True + + def create_lstm(self, direction: str, cell_type: str, hidden_size=128): + """ + ONNX net + + Input->LSTM->Output => Only accuracy check + + """ + + # Create ONNX model + + import onnx + from onnx import helper + from onnx import TensorProto + + assert cell_type in ['LSTM', 'RNN', 'GRU'] + assert direction in ['forward', 'reverse', 'bidirectional'] + n_gates = {'LSTM': 4, 'RNN': 1, 'GRU': 3} + M = n_gates[cell_type] + + seq_len = 10 + batch_size = 4 + input_size = 64 + num_direction = 1 if direction in ["forward", "reverse"] else 2 + + input_shape = [seq_len, batch_size, input_size] + output_shape = [seq_len, num_direction, batch_size, hidden_size] + + w_shape = [num_direction, M * hidden_size, input_size] + r_shape = [num_direction, M * hidden_size, hidden_size] + + init_h_shape = [num_direction, batch_size, hidden_size] + init_c_shape = [num_direction, batch_size, hidden_size] + + init_h_value = np.ones(init_h_shape, dtype=np.float32) + init_c_value = np.ones(init_c_shape, dtype=np.float32) + + w_value = np.ones(w_shape, dtype=np.float32) + r_value = np.ones(r_shape, dtype=np.float32) + + # Creating LSTM Operation + x = helper.make_tensor_value_info('X', TensorProto.FLOAT, input_shape) + y = helper.make_tensor_value_info('Y', TensorProto.FLOAT, None) + + w = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['W'], + value=onnx.helper.make_tensor( + name='const_tensor', + data_type=onnx.TensorProto.FLOAT, + dims=w_value.shape, + vals=w_value.flatten().astype(float), + ), + ) + + r = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['R'], + value=onnx.helper.make_tensor( + name='const_tensor', + data_type=onnx.TensorProto.FLOAT, + dims=r_value.shape, + vals=r_value.flatten().astype(float), + ), + ) + + init_h = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['init_h'], + value=onnx.helper.make_tensor( + name='const_tensor', + data_type=onnx.TensorProto.FLOAT, + dims=init_h_value.shape, + vals=init_h_value.flatten().astype(float), + ), + ) + + inputs = ['X', 'W', 'R', '', '', 'init_h'] + + if cell_type == 'LSTM': + init_c = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['init_c'], + value=onnx.helper.make_tensor( + name='const_tensor', + data_type=onnx.TensorProto.FLOAT, + dims=init_c_value.shape, + vals=init_c_value.flatten().astype(float), + ), + ) + + inputs.append('init_c') + + node_lstm = onnx.helper.make_node( + cell_type, + inputs=inputs, + outputs=['', 'Y'], + hidden_size=hidden_size, + direction=direction, + ) + + # Create the graph (GraphProto) + if cell_type == 'LSTM': + graph_def = helper.make_graph( + [w, r, init_h, init_c, node_lstm], + 'test_lstm', + [x], + [y], + ) + else: + graph_def = helper.make_graph( + [w, r, init_h, node_lstm], + 'test_lstm', + [x], + [y], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_{}_model'.format(cell_type)) + + # We do not create reference graph, as it's too complicated to construct it + # Moreover, IR reader do not support TensorIterator layers + # So we return None to skip IR comparision + + return onnx_net, None + + @pytest.mark.precommit + @pytest.mark.parametrize('direction', ["forward", "bidirectional", "reverse"]) + @pytest.mark.parametrize('cell_type', ["LSTM", "GRU", "RNN"]) + def test_lstm_simple_precommit(self, direction, cell_type, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_lstm(direction, cell_type), ie_device, precision, ir_version, temp_dir=temp_dir) + + # LSTM/RNN/GRU Sequence Generation + @pytest.mark.parametrize('direction', ["forward", "bidirectional", "reverse"]) + @pytest.mark.parametrize('cell_type', ["LSTM", "GRU", "RNN"]) + def test_lstm_sequence_generate(self, direction, cell_type, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_lstm(direction, cell_type), ie_device, precision, ir_version, + disabled_transforms='lstm_to_tensor_iterator,gru_and_rnn_to_tensor_iterator', temp_dir=temp_dir) + + # TODO: add more params for nightly + @pytest.mark.nightly + @pytest.mark.parametrize('direction', ["forward", "bidirectional", "reverse"]) + @pytest.mark.parametrize('cell_type', ["LSTM", "GRU", "RNN"]) + def test_lstm_nightly(self, direction, cell_type, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_lstm(direction, cell_type), ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_matmul.py b/tests/layer_tests/onnx_tests/test_matmul.py new file mode 100644 index 00000000000000..d9fd24588093ed --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_matmul.py @@ -0,0 +1,190 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.onnx_layer_test_class import OnnxRuntimeLayerTest + + +class TestMatMul(OnnxRuntimeLayerTest): + def _prepare_input(self, inputs_dict): + for input in inputs_dict.keys(): + inputs_dict[input] = np.random.randn(*inputs_dict[input]).astype(np.float32) + return inputs_dict + + def create_net(self, shape1, shape2, precision, ir_version): + """ + ONNX net IR net + + Input->MatMul with const->Output => Input->FullyConnected + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + max_len = max([len(shape1), len(shape2)]) + extended_shape1 = np.concatenate([np.ones(max_len - len(shape1)), shape1], axis=0) + extended_shape2 = np.concatenate([np.ones(max_len - len(shape2)), shape2], axis=0) + output_shape = np.concatenate( + [np.maximum(*[extended_shape1[0:-2], extended_shape2[0:-2]]), [shape1[-2], shape2[-1]]], + axis=0).astype(np.int).tolist() + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape1) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + const = np.random.randn(*shape2).astype(np.float32) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=const.shape, + vals=const.flatten(), + ), + ) + + node_def = onnx.helper.make_node( + 'MatMul', + inputs=['input', 'const'], + outputs=['mm_output'] + ) + + # to avoid mapping problems + node_elu_def = onnx.helper.make_node( + 'Elu', + inputs=['mm_output'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def, node_elu_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # Please, spesify 'type': 'Input' for inpit node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + if precision == 'FP16': + const = const.astype(np.float16) + ref_net = None + + return onnx_net, ref_net + + def create_dual_net(self, shape1, shape2, ir_version): + """ + ONNX net IR net + + Input->MatMul->Output => Input->Concat + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + max_len = max([len(shape1), len(shape2)]) + extended_shape1 = np.concatenate([np.ones(max_len - len(shape1)), shape1], axis=0) + extended_shape2 = np.concatenate([np.ones(max_len - len(shape2)), shape2], axis=0) + output_shape = np.concatenate( + [np.maximum(*[extended_shape1[0:-2], extended_shape2[0:-2]]), [shape1[-2], shape2[-1]]], + axis=0).astype(np.int).tolist() + input1 = helper.make_tensor_value_info('input1', TensorProto.FLOAT, shape1) + input2 = helper.make_tensor_value_info('input2', TensorProto.FLOAT, shape2) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + node_def = onnx.helper.make_node( + 'MatMul', + inputs=['input1', 'input2'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input1, input2], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # Please, spesify 'type': 'Input' for inpit node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + return onnx_net, ref_net + + test_data = [ + dict(shape1=[4, 6], shape2=[6, 4]), + dict(shape1=[1, 4, 6], shape2=[1, 6, 4]), + dict(shape1=[2, 4, 6], shape2=[2, 6, 4]), + dict(shape1=[1, 1, 4, 6], shape2=[1, 1, 6, 4]), + dict(shape1=[1, 2, 4, 6], shape2=[1, 2, 6, 4]), + dict(shape1=[2, 3, 4, 6], shape2=[2, 3, 6, 4]), + dict(shape1=[2, 3, 4, 4, 6], shape2=[2, 3, 4, 6, 4]) + ] + + test_data_broadcasting = [ + dict(shape1=[1, 4, 6], shape2=[6, 4]), + dict(shape1=[2, 4, 6], shape2=[6, 4]), + dict(shape1=[2, 4, 6], shape2=[1, 6, 4]), + dict(shape1=[1, 1, 4, 6], shape2=[6, 4]), + dict(shape1=[1, 1, 4, 6], shape2=[1, 6, 4]), + dict(shape1=[1, 2, 4, 6], shape2=[6, 4]), + dict(shape1=[1, 2, 4, 6], shape2=[2, 6, 4]), + dict(shape1=[2, 3, 4, 6], shape2=[6, 4]), + dict(shape1=[2, 3, 4, 6], shape2=[3, 6, 4]), + dict(shape1=[2, 3, 4, 6], shape2=[1, 3, 6, 4]), + dict(shape1=[2, 3, 4, 4, 6], shape2=[6, 4]), + dict(shape1=[2, 3, 4, 4, 6], shape2=[4, 6, 4]), + dict(shape1=[2, 3, 4, 4, 6], shape2=[3, 4, 6, 4]) + ] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_matmul(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_broadcasting) + @pytest.mark.nightly + def test_matmul_bc(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_dual_matmul(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_dual_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_broadcasting) + @pytest.mark.nightly + def test_dual_matmul_bc(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_dual_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_mean_variance_normalization.py b/tests/layer_tests/onnx_tests/test_mean_variance_normalization.py new file mode 100644 index 00000000000000..eb9d5e3b262dea --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_mean_variance_normalization.py @@ -0,0 +1,73 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.onnx_layer_test_class import OnnxRuntimeLayerTest + + +class TestMeanVarianceNormalization(OnnxRuntimeLayerTest): + def _prepare_input(self, inputs_dict): + for input in inputs_dict.keys(): + inputs_dict[input] = np.random.randn(*inputs_dict[input]).astype(np.float32) + return inputs_dict + + def create_net(self, shape, axes, ir_version): + """ + ONNX net IR net + + Input->MeanVarianceNormalization->Output => Input->MVN + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + node_def = onnx.helper.make_node( + 'MeanVarianceNormalization', + inputs=['input'], + outputs=['output'], + axes=axes + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output] + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + return onnx_net, ref_net + + test_data = [ + dict(shape=[7, 2, 3, 5], axes=[2, 3]), + dict(shape=[7, 2, 3, 5], axes=[1, 2, 3]), + dict(shape=[7, 2, 3, 5, 11], axes=[2, 3, 4]), + dict(shape=[7, 2, 3, 5, 11], axes=[1, 2, 3, 4]) + ] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_mvn(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_neg.py b/tests/layer_tests/onnx_tests/test_neg.py new file mode 100644 index 00000000000000..3dd2e0106fdbbd --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_neg.py @@ -0,0 +1,91 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import Caffe2OnnxLayerTest +from unit_tests.utils.graph import build_graph + + +class TestNeg(Caffe2OnnxLayerTest): + def create_neg(self, shape, ir_version): + """ + ONNX net IR net + + Input->Neg->Output => Input->Power(scale=-1, shift=0, power=1) + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + node_reduce_mean_def = onnx.helper.make_node( + 'Neg', + inputs=['input'], + outputs=['output'], + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_reduce_mean_def], + 'test_neg_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_neg_model') + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'neg': {'kind': 'op', 'type': 'Negative'}, + 'neg_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'neg'), + ('neg', 'neg_data'), + ('neg_data', 'result') + ]) + + return onnx_net, ref_net + + test_data_precommit = [dict(shape=[2, 3, 4]), + dict(shape=[1, 3, 124, 124])] + + test_data = [dict(shape=[1, 64]), + dict(shape=[2, 3, 4]), + dict(shape=[1, 3, 124, 124]), + ] + + @pytest.mark.parametrize('params', test_data_precommit) + @pytest.mark.precommit + def test_neg_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_neg(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize('params', test_data) + @pytest.mark.nightly + def test_neg(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_neg(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_non_zero.py b/tests/layer_tests/onnx_tests/test_non_zero.py new file mode 100644 index 00000000000000..da83e8e7e26bba --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_non_zero.py @@ -0,0 +1,194 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import Caffe2OnnxLayerTest +from unit_tests.utils.graph import build_graph + + +class TestNonZero(Caffe2OnnxLayerTest): + def create_net(self, shape, ir_version): + """ + ONNX net IR net + + Input->NonZero->Output => Input->NonZero->Result + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + node_def = onnx.helper.make_node( + 'NonZero', + inputs=['input'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'NonZero', 'version': 'opset3', 'output_type': 'i64'}, + 'node_data': {'shape': [len(shape), np.prod(shape)], 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result') + ]) + return onnx_net, ref_net + + def create_net_const(self, input_value, output_value, precision, ir_version): + """ + ONNX net IR net + + Input->Concat(+NonZero const)->Output => Input->Concat(+const)->Result + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + concat_axis = 0 + output_shape = list(output_value.shape) + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, output_value.shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=input_value.shape, + vals=input_value.flatten(), + ), + ) + + node_def = onnx.helper.make_node( + 'NonZero', + inputs=['const1'], + outputs=['nonzero1'] + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'nonzero1'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': output_value.shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': output_value.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': output_value.shape, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result') + ]) + + return onnx_net, ref_net + + test_data = [ + dict(shape=[10, 12]), + dict(shape=[8, 10, 12]), + dict(shape=[6, 8, 10, 12]), + dict(shape=[4, 6, 8, 10, 12]) + ] + + test_const_data = [ + dict( + input_value=np.array([3, 0, 0, 0, 4, 0, 5, 6, 0]).reshape((3, 3)), + output_value=np.array([0, 1, 2, 2, 0, 1, 0, 1]).reshape(2, 4), + ), + dict( + input_value=np.array([0, 1, 0, 1]).reshape((4)), + output_value=np.array([1, 3]).reshape((1, 2)), + ), + dict( + input_value=np.array([0, 1, 0, 1, 1, 0, 1, 0]).reshape((2, 4)), + output_value=np.array([0, 0, 1, 1, 1, 3, 0, 2]).reshape((2, 4)), + ), + dict( + input_value=np.array([1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0]).reshape((2, 3, 3)), + output_value=np.array([0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 2, 2, 2, + 0, 0, 0, 1, 1, 2, 0, 2, 1, 0, 1, 2, 0, 1, 2, 0, 2, 1]).reshape((3, 12)), + ), + ] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_non_zero(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_const_data) + @pytest.mark.nightly + def test_non_zero_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_not.py b/tests/layer_tests/onnx_tests/test_not.py new file mode 100644 index 00000000000000..da840eef28e887 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_not.py @@ -0,0 +1,190 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestNot(OnnxRuntimeLayerTest): + def _prepare_input(self, inputs_dict): + for input in inputs_dict.keys(): + inputs_dict[input] = np.random.randint(0, 2, inputs_dict[input]).astype(np.bool) + return inputs_dict + + def create_net(self, shape, ir_version): + """ + ONNX net IR net + + Input->Not->Output => Input->LogicalNot + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.BOOL, shape) + output = helper.make_tensor_value_info('output', TensorProto.BOOL, shape) + + node_def = onnx.helper.make_node( + 'Not', + inputs=['input'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'LogicalNot'}, + 'node_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result') + ]) + + return onnx_net, ref_net + + def create_net_const(self, shape, ir_version): + """ + ONNX net IR net + + Input->Concat(+not const)->Output => Input->Concat(+const) + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + concat_axis = 0 + output_shape = shape.copy() + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.BOOL, shape) + output = helper.make_tensor_value_info('output', TensorProto.BOOL, output_shape) + + constant = np.random.randint(0, 2, shape).astype(np.bool) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.BOOL, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + node_def = onnx.helper.make_node( + 'Not', + inputs=['const1'], + outputs=['not'] + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'not'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + constant = np.logical_not(constant) + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': constant.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': shape, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result') + ]) + + return onnx_net, ref_net + + test_data_precommit = [dict(shape=[2, 3, 4]), + dict(shape=[2, 4, 6, 8, 10])] + + test_data = [dict(shape=[10, 12]), + dict(shape=[8, 10, 12]), + dict(shape=[6, 8, 10, 12]), + dict(shape=[4, 6, 8, 10, 12])] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_not_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_not(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_not_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_or.py b/tests/layer_tests/onnx_tests/test_or.py new file mode 100644 index 00000000000000..8580f7e8bfd6ec --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_or.py @@ -0,0 +1,277 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestOr(OnnxRuntimeLayerTest): + def _prepare_input(self, inputs_dict): + for input in inputs_dict.keys(): + inputs_dict[input] = np.random.randint(0, 2, inputs_dict[input]).astype(np.bool) + return inputs_dict + + def create_net(self, shape1, shape2, ir_version): + """ + ONNX net IR net + + Input->Or with 2nd input->Output => Input->LogicalOr + """ + + # + # Create ONNX model + # + + from onnx import helper + from onnx import TensorProto + + input1 = helper.make_tensor_value_info('input1', TensorProto.BOOL, shape1) + input2 = helper.make_tensor_value_info('input2', TensorProto.BOOL, shape2) + output = helper.make_tensor_value_info('output', TensorProto.BOOL, shape1) + + node_def = helper.make_node( + 'Or', + inputs=['input1', 'input2'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input1, input2], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # Create reference IR net + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input1': {'kind': 'op', 'type': 'Parameter'}, + 'input1_data': {'shape': shape1, 'kind': 'data'}, + 'input2': {'kind': 'op', 'type': 'Parameter'}, + 'input2_data': {'shape': shape2, 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'LogicalOr'}, + 'node_data': {'shape': shape1, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input1', 'input1_data'), + ('input2', 'input2_data'), + ('input1_data', 'node'), + ('input2_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result')]) + + return onnx_net, ref_net + + def create_net_one_const(self, shape1, shape2, ir_version): + """ + ONNX net IR net + + Input->Or with const->Output => Input->LogicalOr + """ + + # + # Create ONNX model + # + + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.BOOL, shape1) + output = helper.make_tensor_value_info('output', TensorProto.BOOL, shape1) + + const = np.random.randint(0, 2, shape2).astype(np.bool) + + node_const_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['const'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.BOOL, + dims=const.shape, + vals=const.flatten(), + ), + ) + + node_def = helper.make_node( + 'Or', + inputs=['input', 'const'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # Create reference IR net + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape1, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': const.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': const.shape, 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'LogicalOr'}, + 'node_data': {'shape': shape1, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'node'), + ('const_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result')]) + + return onnx_net, ref_net + + def create_net_const(self, shape1, shape2, ir_version): + """ + ONNX net IR net + + Input->Concat with const or const->Output => Input->Concat + """ + + # + # Create ONNX model + # + + from onnx import helper + from onnx import TensorProto + + concat_axis = 0 + output_shape = list(shape1) + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.BOOL, shape1) + output = helper.make_tensor_value_info('output', TensorProto.BOOL, output_shape) + + const1 = np.random.randint(0, 2, shape1).astype(np.bool) + const2 = np.random.randint(0, 2, shape2).astype(np.bool) + + node_const1_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.BOOL, + dims=const1.shape, + vals=const1.flatten(), + ), + ) + + node_const2_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['const2'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.BOOL, + dims=const2.shape, + vals=const2.flatten(), + ), + ) + + node_def = helper.make_node( + 'Or', + inputs=['const1', 'const2'], + outputs=['node_out'] + ) + + node_concat_def = helper.make_node( + 'Concat', + inputs=['input', 'node_out'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const1_def, node_const2_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # Create reference IR net + constant_calculated = np.logical_or(const1, const2) + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': const1.shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': constant_calculated.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': const1.shape, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result')]) + + return onnx_net, ref_net + + test_data_precommit = [dict(shape1=[2, 3, 4], shape2=[2, 3, 4]), + dict(shape1=[2, 4, 6, 8, 10], shape2=[2, 4, 6, 8, 10])] + + test_data = [dict(shape1=[4, 6], shape2=[4, 6]), + dict(shape1=[4, 6, 8], shape2=[4, 6, 8]), + dict(shape1=[4, 6, 8, 10], shape2=[4, 6, 8, 10]), + dict(shape1=[4, 6, 8, 10, 12], shape2=[4, 6, 8, 10, 12])] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_or_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_or(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_or_one_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_one_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_or_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_pad.py b/tests/layer_tests/onnx_tests/test_pad.py new file mode 100644 index 00000000000000..56c1870287156a --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_pad.py @@ -0,0 +1,212 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestPad(OnnxRuntimeLayerTest): + def create_net(self, shape, mode, pads, value, ir_version, opset=None): + """ + ONNX net IR net + + Input->Pad->Output => Input->Pad + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + _pads = np.array(pads).reshape([2, -1]) + output_shape = (np.array(shape) + _pads[0, :] + _pads[1, :]).tolist() + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + nodes = [] + if opset is not None and opset < 11: + args = dict(pads=pads) + if mode: + args['mode'] = mode + if value: + args['value'] = value + node_def = onnx.helper.make_node( + 'Pad', + inputs=['input'], + outputs=['pad'], + **args + ) + nodes.append(node_def) + else: + node_pads_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['pads'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.INT64, + dims=[len(pads)], + vals=pads, + ), + ) + + inputs = ['input', 'pads'] + if value is not None: + node_value_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['value'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=[], + vals=[value], + ), + ) + inputs.append('value') + nodes.append(node_value_def) + + args = dict() + if mode: + args['mode'] = mode + node_def = onnx.helper.make_node( + 'Pad', + inputs=inputs, + outputs=['pad'], + **args + ) + nodes.extend([node_pads_def, node_def]) + + sigmoid_def = onnx.helper.make_node( + 'Elu', + inputs=['pad'], + outputs=['output'] + ) + nodes.append(sigmoid_def) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + nodes, + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + args = dict(producer_name='test_model') + if opset: + args['opset_imports'] = [helper.make_opsetid("", opset)] + onnx_net = helper.make_model(graph_def, **args) + + # + # Create reference IR net + # + ref_net = None + if check_ir_version(10, None, ir_version): + + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'pads_begin_indata': {'value': _pads[0, :], 'kind': 'data'}, + 'pads_begin': {'kind': 'op', 'type': 'Const'}, + 'pads_begin_data': {'shape': [len(_pads[0, :])], 'kind': 'data'}, + 'pads_end_indata': {'value': _pads[1, :], 'kind': 'data'}, + 'pads_end': {'kind': 'op', 'type': 'Const'}, + 'pads_end_data': {'shape': [len(_pads[1, :])], 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'Pad', 'pad_mode': 'constant' if not mode else mode}, + 'node_data': {'shape': output_shape, 'kind': 'data'}, + 'elu': {'kind': 'op', 'type': 'Elu'}, + 'elu_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + edges = [('input', 'input_data'), + ('input_data', 'node'), + ('pads_begin_indata', 'pads_begin'), + ('pads_begin', 'pads_begin_data'), + ('pads_begin_data', 'node'), + ('pads_end_indata', 'pads_end'), + ('pads_end', 'pads_end_data'), + ('pads_end_data', 'node'), + ('node', 'node_data'), + ('node_data', 'elu'), + ('elu', 'elu_data'), + ('elu_data', 'result') + ] + + if mode in (None, "constant"): + nodes_attributes.update({'const_node_indata': {'value': value, 'kind': 'data'}, + 'const_node': {'kind': 'op', 'type': 'Const'}, + 'const_node_data': {'shape': None, 'kind': 'data'} + }) + edges += [('const_node_indata', 'const_node'), + ('const_node', 'const_node_data'), + ('const_node_data', 'node') + ] + + ref_net = build_graph(nodes_attributes, edges) + + return onnx_net, ref_net + + test_data_precommit = [ + pytest.param(dict(shape=[6, 8, 10, 12], pads=[1, 2, 3, 4, 5, 6, 7, 8]), + marks=pytest.mark.skip(reason="Skipped until fixed")), + pytest.param(dict(shape=[8, 10, 12, 14, 16], pads=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), + marks=pytest.mark.skip(reason="Skipped until fixed"))] + + test_data = [dict(shape=[10, 12], pads=[1, 1, 1, 1]), + dict(shape=[10, 12], pads=[1, 2, 3, 4]), + dict(shape=[8, 10, 12], pads=[0, 0, 1, 0, 0, 1]), + dict(shape=[8, 10, 12], pads=[1, 2, 3, 4, 5, 6]), + dict(shape=[6, 8, 10, 12], pads=[0, 0, 1, 1, 0, 0, 1, 1]), + dict(shape=[6, 8, 10, 12], pads=[0, 0, 1, 2, 0, 0, 3, 4]), + dict(shape=[6, 8, 10, 12], pads=[1, 1, 1, 1, 1, 1, 1, 1]), + dict(shape=[6, 8, 10, 12], pads=[1, 2, 3, 4, 5, 6, 7, 8]), + dict(shape=[8, 10, 12, 14, 16], pads=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), + dict(shape=[8, 10, 12, 14, 16], pads=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10])] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.parametrize("mode_value", [(None, None), + (None, 0.5), + ('constant', None), + ('constant', 0.5), + ('reflect', None), + ('edge', None)]) + @pytest.mark.nightly + def test_pad_opset_9(self, params, mode_value, ie_device, precision, ir_version, temp_dir): + mode, value = mode_value + self._test(*self.create_net(**params, mode=mode, value=value, ir_version=ir_version, opset=9), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.parametrize("mode_value", [(None, None), + (None, 0.5), + ('constant', None), + ('constant', 0.5), + ('reflect', None), + ('edge', None)]) + @pytest.mark.precommit + def test_pad_opset_latest_precommit(self, params, mode_value, ie_device, precision, ir_version, temp_dir): + mode, value = mode_value + self._test(*self.create_net(**params, mode=mode, value=value, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.parametrize("mode_value", [(None, None), + (None, 0.5), + ('constant', None), + ('constant', 0.5), + ('reflect', None), + ('edge', None)]) + @pytest.mark.nightly + def test_pad_opset_latest(self, params, mode_value, ie_device, precision, ir_version, temp_dir): + mode, value = mode_value + self._test(*self.create_net(**params, mode=mode, value=value, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_pooling.py b/tests/layer_tests/onnx_tests/test_pooling.py new file mode 100644 index 00000000000000..3213718b9ac5de --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_pooling.py @@ -0,0 +1,432 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +def float_array(x): + return np.array(x, dtype=np.float) + + +class TestPooling(OnnxRuntimeLayerTest): + def create_net(self, shape, kernel_shape, pads, strides, op, ir_version, count_include_pad=None, auto_pad=None, + storage_order=None, ceil=False, opset=None): + """ + ONNX net IR net + + Input->Pooling>Output => Input->Pooling + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + node_args = dict(kernel_shape=kernel_shape) + if auto_pad is not None: + node_args['auto_pad'] = auto_pad + if auto_pad == 'VALID': + pads = np.zeros(len(shape[2:]) * 2, dtype=np.int) + else: + auto_pad = 'NOTSET' + if count_include_pad is not None: + node_args['count_include_pad'] = count_include_pad + else: + count_include_pad = 0 + if storage_order is not None: + node_args['storage_order'] = storage_order + if pads is not None: + if auto_pad == 'NOTSET': + node_args['pads'] = pads + _pads = np.transpose(np.array(pads).reshape([2, -1])) + else: + _pads = np.zeros([len(kernel_shape), 2]) + if strides is not None: + node_args['strides'] = strides + else: + strides = np.ones(len(kernel_shape)) + + if ceil: + node_args['ceil_mode'] = 1 + + if auto_pad in ['SAME_UPPER', 'SAME_LOWER']: + out_spacial_shape = np.ceil(np.array(shape[2:], dtype=np.float) / strides) + else: + rounding = np.ceil if ceil else np.floor + out_spacial_shape = rounding( + (float_array(shape[2:]) + np.add(_pads[:, 0], _pads[:, 1]) - float_array(kernel_shape)) / strides + 1) + + out_shape = np.array(shape) + out_shape[2:] = out_spacial_shape + out_shape = out_shape.astype(np.int).tolist() + concat_axis = 0 + out_concat_shape = out_shape.copy() + out_concat_shape[concat_axis] *= 2 + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, out_concat_shape) + + constant = np.random.randint(-127, 127, out_shape).astype(np.float) + + node_def = onnx.helper.make_node( + op, + inputs=['input'], + outputs=['pool'], + **node_args + ) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['pool', 'const1'], + outputs=['output'], + axis=concat_axis + ) + + graph_def = helper.make_graph( + [node_def, node_const_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + args = dict(producer_name='test_model') + if opset: + args['opset_imports'] = [helper.make_opsetid("", opset)] + onnx_net = helper.make_model(graph_def, **args) + + # + # Create reference IR net + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'node': {'kind': 'op', 'type': None, + 'pads_begin': _pads[:, 0] if len(shape) > 3 else _pads[0, 0], + 'pads_end': _pads[:, 1] if len(shape) > 3 else _pads[0, 1], + 'kernel': kernel_shape[0] if len(kernel_shape) == 1 else kernel_shape, + 'rounding_type': 'ceil' if auto_pad != 'NOTSET' or ceil else 'floor', + 'auto_pad': None}, + 'node_data': {'shape': out_shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': constant.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': out_shape, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': out_concat_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + if op == 'AveragePool': + nodes_attributes['node']['type'] = 'AvgPool' + nodes_attributes['node']['exclude-pad'] = 'true' if count_include_pad == 0 else 'false' + else: + nodes_attributes['node']['type'] = 'MaxPool' + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'node'), + ('node', 'node_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('node_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result') + ]) + + return onnx_net, ref_net + + def create_global_net(self, shape, op, ir_version): + """ + ONNX net IR net + + Input->GlobalPooling>Output => Input->Pooling + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + out_shape = np.ones(len(shape)) + out_shape[:2] = np.array(shape)[:2] + out_shape = out_shape.astype(np.int).tolist() + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, out_shape) + + node_def = onnx.helper.make_node( + op, + inputs=['input'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'input_axes_data': {'kind': 'data', 'value': list(range(2, len(shape)))}, + 'axes': {'kind': 'op', 'type': 'Const'}, + 'axes_data': {'shape': [len(shape) - 2], 'kind': 'data'}, + 'node': {'kind': 'op', 'type': None}, + 'node_data': {'shape': out_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + if op == 'GlobalAveragePool': + nodes_attributes['node']['type'] = 'ReduceMean' + else: + nodes_attributes['node']['type'] = 'ReduceMax' + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'node'), + ('input_axes_data', 'axes'), + ('axes', 'axes_data'), + ('axes_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result') + ]) + + return onnx_net, ref_net + + test_data_precommit = [ + dict(shape=[2, 3, 10], kernel_shape=[2], pads=None, strides=[3]), + dict(shape=[2, 3, 30, 30], kernel_shape=[5, 5], pads=None, strides=[3, 2]), + dict(shape=[2, 3, 28, 28, 28], kernel_shape=[5, 5, 5], pads=[2, 4, 2, 0, 0, 2], strides=None), + dict(shape=[2, 3, 30, 30, 30], kernel_shape=[5, 5, 5], pads=None, strides=[3, 3, 5])] + + test_data = [ + dict(shape=[2, 3, 10], kernel_shape=[2], pads=None, strides=None), + dict(shape=[2, 3, 10], kernel_shape=[2], pads=[2, 2], strides=None), + dict(shape=[2, 3, 10], kernel_shape=[2], pads=None, strides=[3]), + dict(shape=[2, 3, 30, 30], kernel_shape=[2, 2], pads=None, strides=None), + dict(shape=[2, 3, 30, 30], kernel_shape=[4, 2], pads=None, strides=None), + dict(shape=[2, 3, 30, 30], kernel_shape=[2, 4], pads=None, strides=None), + dict(shape=[2, 3, 28, 28], kernel_shape=[3, 3], pads=[2, 2, 2, 2], strides=None), + dict(shape=[2, 3, 28, 28], kernel_shape=[5, 5], pads=[0, 2, 0, 4], strides=None), + dict(shape=[2, 3, 28, 28], kernel_shape=[5, 5], pads=[2, 0, 4, 0], strides=None), + dict(shape=[2, 3, 30, 30], kernel_shape=[5, 5], pads=None, strides=[3, 3]), + dict(shape=[2, 3, 30, 30], kernel_shape=[5, 5], pads=None, strides=[2, 3]), + dict(shape=[2, 3, 30, 30], kernel_shape=[5, 5], pads=None, strides=[3, 2]), + dict(shape=[2, 3, 30, 30, 30], kernel_shape=[2, 2, 2], pads=None, strides=None), + dict(shape=[2, 3, 30, 30, 30], kernel_shape=[4, 2, 2], pads=None, strides=None), + dict(shape=[2, 3, 30, 30, 30], kernel_shape=[2, 4, 2], pads=None, strides=None), + dict(shape=[2, 3, 30, 30, 30], kernel_shape=[2, 2, 4], pads=None, strides=None), + dict(shape=[2, 3, 28, 28, 28], kernel_shape=[3, 3, 3], pads=[2, 2, 2, 2, 2, 2], strides=None), + dict(shape=[2, 3, 28, 28, 28], kernel_shape=[5, 5, 5], pads=[2, 4, 2, 0, 0, 2], strides=None), + dict(shape=[2, 3, 30, 30, 30], kernel_shape=[5, 5, 5], pads=None, strides=[3, 3, 3]), + dict(shape=[2, 3, 30, 30, 30], kernel_shape=[5, 5, 5], pads=None, strides=[5, 3, 3]), + dict(shape=[2, 3, 30, 30, 30], kernel_shape=[5, 5, 5], pads=None, strides=[3, 5, 3]), + dict(shape=[2, 3, 30, 30, 30], kernel_shape=[5, 5, 5], pads=None, strides=[3, 3, 5])] + + test_data_autopad_precommit = [ + dict(shape=[2, 3, 30, 30, 30], auto_pad='VALID', kernel_shape=[2, 2, 4], pads=None, strides=None), + dict(shape=[2, 3, 21, 21, 21], auto_pad='VALID', kernel_shape=[3, 3, 3], pads=None, strides=[3, 2, 3]), + dict(shape=[2, 3, 21, 21, 21], auto_pad='VALID', kernel_shape=[3, 3, 3], pads=None, strides=[3, 3, 2])] + + test_data_autopad = [ + dict(shape=[2, 3, 10], auto_pad='SAME_UPPER', kernel_shape=[2], pads=[0, 1], strides=[3]), + dict(shape=[2, 3, 10], auto_pad='SAME_LOWER', kernel_shape=[2], pads=[0, 1], strides=[3]), + dict(shape=[2, 3, 10], auto_pad='VALID', kernel_shape=[2], pads=None, strides=[3]), + dict(shape=[2, 3, 30, 30], auto_pad='SAME_UPPER', kernel_shape=[2, 2], pads=[0, 0, 1, 1], strides=None), + dict(shape=[2, 3, 30, 30], auto_pad='SAME_UPPER', kernel_shape=[4, 2], pads=[1, 0, 2, 1], strides=None), + dict(shape=[2, 3, 30, 30], auto_pad='SAME_UPPER', kernel_shape=[2, 4], pads=[0, 1, 1, 2], strides=None), + dict(shape=[2, 3, 30, 30], auto_pad='SAME_UPPER', kernel_shape=[5, 5], pads=[1, 1, 1, 1], strides=[3, 3]), + dict(shape=[2, 3, 30, 30], auto_pad='SAME_UPPER', kernel_shape=[5, 5], pads=[1, 1, 2, 1], strides=[2, 3]), + dict(shape=[2, 3, 30, 30], auto_pad='SAME_UPPER', kernel_shape=[5, 5], pads=[1, 1, 1, 2], strides=[3, 2]), + dict(shape=[2, 3, 30, 30], auto_pad='SAME_LOWER', kernel_shape=[2, 2], pads=[0, 0, 1, 1], strides=None), + dict(shape=[2, 3, 30, 30], auto_pad='SAME_LOWER', kernel_shape=[4, 2], pads=[1, 0, 2, 1], strides=None), + dict(shape=[2, 3, 30, 30], auto_pad='SAME_LOWER', kernel_shape=[2, 4], pads=[0, 1, 1, 2], strides=None), + dict(shape=[2, 3, 30, 30], auto_pad='SAME_LOWER', kernel_shape=[5, 5], pads=[1, 1, 1, 1], strides=[3, 3]), + dict(shape=[2, 3, 30, 30], auto_pad='SAME_LOWER', kernel_shape=[5, 5], pads=[1, 1, 2, 1], strides=[2, 3]), + dict(shape=[2, 3, 30, 30], auto_pad='SAME_LOWER', kernel_shape=[5, 5], pads=[1, 1, 1, 2], strides=[3, 2]), + dict(shape=[2, 3, 30, 30], auto_pad='VALID', kernel_shape=[2, 2], pads=None, strides=None), + dict(shape=[2, 3, 30, 30], auto_pad='VALID', kernel_shape=[4, 2], pads=None, strides=None), + dict(shape=[2, 3, 30, 30], auto_pad='VALID', kernel_shape=[2, 4], pads=None, strides=None), + dict(shape=[2, 3, 21, 21], auto_pad='VALID', kernel_shape=[3, 3], pads=None, strides=[3, 3]), + dict(shape=[2, 3, 21, 21], auto_pad='VALID', kernel_shape=[3, 3], pads=None, strides=[2, 3]), + dict(shape=[2, 3, 21, 21], auto_pad='VALID', kernel_shape=[3, 3], pads=None, strides=[3, 2]), + dict(shape=[2, 3, 30, 30, 30], auto_pad='SAME_UPPER', kernel_shape=[2, 2, 2], pads=[0, 0, 0, 1, 1, 1], + strides=None), + dict(shape=[2, 3, 30, 30, 30], auto_pad='SAME_UPPER', kernel_shape=[4, 2, 2], pads=[1, 0, 0, 2, 1, 1], + strides=None), + dict(shape=[2, 3, 30, 30, 30], auto_pad='SAME_UPPER', kernel_shape=[2, 4, 2], pads=[0, 1, 0, 1, 2, 1], + strides=None), + dict(shape=[2, 3, 30, 30, 30], auto_pad='SAME_UPPER', kernel_shape=[2, 2, 4], pads=[0, 0, 1, 1, 1, 2], + strides=None), + dict(shape=[2, 3, 30, 30, 30], auto_pad='SAME_UPPER', kernel_shape=[5, 5, 5], pads=[1, 1, 1, 1, 1, 1], + strides=[3, 3, 3]), + dict(shape=[2, 3, 30, 30, 30], auto_pad='SAME_UPPER', kernel_shape=[5, 5, 5], pads=[0, 1, 1, 0, 1, 1], + strides=[5, 3, 3]), + dict(shape=[2, 3, 30, 30, 30], auto_pad='SAME_UPPER', kernel_shape=[5, 5, 5], pads=[1, 0, 1, 1, 0, 1], + strides=[3, 5, 3]), + dict(shape=[2, 3, 30, 30, 30], auto_pad='SAME_UPPER', kernel_shape=[5, 5, 5], pads=[1, 1, 0, 1, 1, 0], + strides=[3, 3, 5]), + dict(shape=[2, 3, 30, 30, 30], auto_pad='SAME_LOWER', kernel_shape=[2, 2, 2], pads=[0, 0, 0, 1, 1, 1], + strides=None), + dict(shape=[2, 3, 30, 30, 30], auto_pad='SAME_LOWER', kernel_shape=[4, 2, 2], pads=[1, 0, 0, 2, 1, 1], + strides=None), + dict(shape=[2, 3, 30, 30, 30], auto_pad='SAME_LOWER', kernel_shape=[2, 4, 2], pads=[0, 1, 0, 1, 2, 1], + strides=None), + dict(shape=[2, 3, 30, 30, 30], auto_pad='SAME_LOWER', kernel_shape=[2, 2, 4], pads=[0, 0, 1, 1, 1, 2], + strides=None), + dict(shape=[2, 3, 30, 30, 30], auto_pad='SAME_LOWER', kernel_shape=[5, 5, 5], pads=[1, 1, 1, 1, 1, 1], + strides=[3, 3, 3]), + dict(shape=[2, 3, 30, 30, 30], auto_pad='SAME_LOWER', kernel_shape=[5, 5, 5], pads=[0, 1, 1, 0, 1, 1], + strides=[5, 3, 3]), + dict(shape=[2, 3, 30, 30, 30], auto_pad='SAME_LOWER', kernel_shape=[5, 5, 5], pads=[1, 0, 1, 1, 0, 1], + strides=[3, 5, 3]), + dict(shape=[2, 3, 30, 30, 30], auto_pad='SAME_LOWER', kernel_shape=[5, 5, 5], pads=[1, 1, 0, 1, 1, 0], + strides=[3, 3, 5]), + dict(shape=[2, 3, 30, 30, 30], auto_pad='VALID', kernel_shape=[2, 2, 2], pads=None, strides=None), + dict(shape=[2, 3, 30, 30, 30], auto_pad='VALID', kernel_shape=[4, 2, 2], pads=None, strides=None), + dict(shape=[2, 3, 30, 30, 30], auto_pad='VALID', kernel_shape=[2, 4, 2], pads=None, strides=None), + dict(shape=[2, 3, 30, 30, 30], auto_pad='VALID', kernel_shape=[2, 2, 4], pads=None, strides=None), + dict(shape=[2, 3, 21, 21, 21], auto_pad='VALID', kernel_shape=[3, 3, 3], pads=None, strides=[3, 3, 3]), + dict(shape=[2, 3, 21, 21, 21], auto_pad='VALID', kernel_shape=[3, 3, 3], pads=None, strides=[2, 3, 3]), + dict(shape=[2, 3, 21, 21, 21], auto_pad='VALID', kernel_shape=[3, 3, 3], pads=None, strides=[3, 2, 3]), + dict(shape=[2, 3, 21, 21, 21], auto_pad='VALID', kernel_shape=[3, 3, 3], pads=None, strides=[3, 3, 2])] + + global_test_data = [dict(shape=[2, 3, 10]), + dict(shape=[2, 3, 32, 32]), + dict(shape=[2, 3, 32, 32, 32])] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.parametrize("incl_pad", [None, 1]) + @pytest.mark.nightly + def test_avgpool_opset7(self, params, incl_pad, ie_device, precision, ir_version, temp_dir): + if not len(params['shape']) in [4, 5]: + pytest.skip("Pooling layer support only 4D and 5D input tensors") + self._test( + *self.create_net(**params, op='AveragePool', count_include_pad=incl_pad, ir_version=ir_version, opset=7), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_autopad) + @pytest.mark.nightly + def test_avgpool_opset7_autopad(self, params, ie_device, precision, ir_version, temp_dir): + if not len(params['shape']) in [4, 5]: + pytest.skip("Pooling layer support only 4D and 5D input tensors") + self._test(*self.create_net(**params, op='AveragePool', ir_version=ir_version, opset=7), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.parametrize("incl_pad", [None, 1]) + @pytest.mark.parametrize("ceil", [True, False]) + @pytest.mark.nightly + def test_avgpool_opset10(self, params, incl_pad, ceil, ie_device, precision, ir_version, temp_dir): + if not len(params['shape']) in [4, 5]: + pytest.skip("Pooling layer support only 4D and 5D input tensors") + self._test( + *self.create_net(**params, op='AveragePool', count_include_pad=incl_pad, ceil=ceil, ir_version=ir_version, + opset=10), ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_autopad) + @pytest.mark.nightly + def test_avgpool_opset10_autopad(self, params, ie_device, precision, ir_version, temp_dir): + if not len(params['shape']) in [4, 5]: + pytest.skip("Pooling layer support only 4D and 5D input tensors") + self._test(*self.create_net(**params, op='AveragePool', ir_version=ir_version, opset=10), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.parametrize("st_order", [None, 1]) + @pytest.mark.nightly + def test_maxpool_opset8(self, params, st_order, ie_device, precision, ir_version, temp_dir): + if not len(params['shape']) in [4, 5]: + pytest.skip("Pooling layer support only 4D and 5D input tensors") + self._test(*self.create_net(**params, op='MaxPool', storage_order=st_order, ir_version=ir_version, opset=8), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_autopad) + @pytest.mark.nightly + def test_maxpool_opset8_autopad(self, params, ie_device, precision, ir_version, temp_dir): + if not len(params['shape']) in [4, 5]: + pytest.skip("Pooling layer support only 4D and 5D input tensors") + self._test(*self.create_net(**params, op='MaxPool', ir_version=ir_version, opset=8), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.parametrize("st_order", [None, 1]) + @pytest.mark.parametrize("ceil", [True, False]) + @pytest.mark.nightly + def test_maxpool_opset10(self, params, st_order, ceil, ie_device, precision, ir_version, temp_dir): + if not len(params['shape']) in [4, 5]: + pytest.skip("Pooling layer support only 4D and 5D input tensors") + self._test(*self.create_net(**params, op='MaxPool', storage_order=st_order, ceil=ceil, ir_version=ir_version, + opset=10), ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_autopad_precommit) + @pytest.mark.precommit + def test_maxpool_opset10_autopad(self, params, ie_device, precision, ir_version, temp_dir): + if not len(params['shape']) in [4, 5]: + pytest.skip("Pooling layer support only 4D and 5D input tensors") + self._test(*self.create_net(**params, op='MaxPool', ir_version=ir_version, opset=10), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_autopad) + @pytest.mark.nightly + def test_maxpool_opset10_autopad(self, params, ie_device, precision, ir_version, temp_dir): + if not len(params['shape']) in [4, 5]: + pytest.skip("Pooling layer support only 4D and 5D input tensors") + self._test(*self.create_net(**params, op='MaxPool', ir_version=ir_version, opset=10), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", global_test_data) + @pytest.mark.nightly + def test_global_avgpool(self, params, ie_device, precision, ir_version, temp_dir): + if not len(params['shape']) in [4, 5]: + pytest.skip("Pooling layer support only 4D and 5D input tensors") + self._test(*self.create_global_net(**params, op='GlobalAveragePool', ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", global_test_data) + @pytest.mark.nightly + def test_global_maxpool(self, params, ie_device, precision, ir_version, temp_dir): + if not len(params['shape']) in [4, 5]: + pytest.skip("Pooling layer support only 4D and 5D input tensors") + self._test(*self.create_global_net(**params, op='GlobalMaxPool', ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_prelu.py b/tests/layer_tests/onnx_tests/test_prelu.py new file mode 100644 index 00000000000000..303ff0270ab9d6 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_prelu.py @@ -0,0 +1,161 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import Caffe2OnnxLayerTest +from unit_tests.utils.graph import build_graph + + +class TestPRelu(Caffe2OnnxLayerTest): + def create_net(self, shape, slope_shape, precision, ir_version, opset=None): + """ + ONNX net IR net + + Input->PRelu->Output => Input->PReLU + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + const = np.random.randn(*slope_shape).astype(np.float32) + + node_slope_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['slope'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=const.shape, + vals=const.flatten(), + ), + ) + + node_def = onnx.helper.make_node( + 'PRelu', + inputs=['input', 'slope'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_slope_def, node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + args = dict(producer_name='test_model') + if opset: + args['opset_imports'] = [helper.make_opsetid("", opset)] + onnx_net = helper.make_model(graph_def, **args) + + # + # Create reference IR net + # + ref_net = None + if check_ir_version(10, None, ir_version): + + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'weights_indata': {'kind': 'data', 'value': const.flatten()}, + 'weights': {'kind': 'op', 'type': 'Const'}, + 'weights_data': {'kind': 'data', 'shape': [len(const.flatten())]}, + 'node': {'kind': 'op', 'type': 'PReLU'}, + 'node_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'node'), + ('weights_indata', 'weights'), + ('weights', 'weights_data'), + ('weights_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result') + ]) + + return onnx_net, ref_net + + # Note: IE only support slopes of one element or of size equal to number of channels. + test_data_shared_channels = [ + dict(shape=[10, 12], slope_shape=[12]), + dict(shape=[8, 10, 12], slope_shape=[10]), + dict(shape=[6, 8, 10, 12], slope_shape=[8]), + dict(shape=[4, 6, 8, 10, 12], slope_shape=[6])] + + test_data_scalar_precommit = [ + dict(shape=[2, 4, 6, 8], slope_shape=[1]), + dict(shape=[2, 4, 6, 8, 10], slope_shape=[1]) + ] + + test_data_scalar = [ + dict(shape=[10, 12], slope_shape=[1]), + dict(shape=[8, 10, 12], slope_shape=[1]), + dict(shape=[6, 8, 10, 12], slope_shape=[1]), + dict(shape=[4, 6, 8, 10, 12], slope_shape=[1])] + + test_data_precommit = [dict(shape=[8, 10, 12], slope_shape=[10])] + + @pytest.mark.parametrize("params", test_data_scalar) + @pytest.mark.nightly + def test_prelu_opset6_scalar(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, precision=precision, opset=6, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_shared_channels) + @pytest.mark.nightly + def test_prelu_opset6_shared_channels(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, precision=precision, opset=6, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_scalar) + @pytest.mark.nightly + def test_prelu_opset7_scalar(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, precision=precision, opset=7, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_shared_channels) + @pytest.mark.nightly + def test_prelu_opset7_shared_channels(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, precision=precision, opset=7, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_prelu_shared_channels_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_scalar_precommit) + @pytest.mark.precommit + def test_prelu_scalar_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_scalar) + @pytest.mark.nightly + def test_prelu_scalar(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_shared_channels) + @pytest.mark.nightly + def test_prelu_shared_channels(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_reciprocal.py b/tests/layer_tests/onnx_tests/test_reciprocal.py new file mode 100644 index 00000000000000..4161ed28860635 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_reciprocal.py @@ -0,0 +1,171 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.onnx_layer_test_class import OnnxRuntimeLayerTest + + +class TestReciprocal(OnnxRuntimeLayerTest): + def create_net(self, shape, ir_version): + """ + ONNX net IR net + + Input+258->Reciprocal->Output => Input->Power + """ + + # + # Create ONNX model + # + + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + # adding 258 is needed to avoid division by zero + node_const_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['const'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=[1], + vals=[258], + ), + ) + + node_add_def = helper.make_node( + 'Add', + inputs=['input', 'const'], + outputs=['add'] + ) + + node_def = helper.make_node( + 'Reciprocal', + inputs=['add'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_add_def, node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # Create reference IR net + + ref_net = None + + return onnx_net, ref_net + + def create_net_const(self, shape, precision, ir_version): + """ + ONNX net IR net + + Input->Concat with reciprocal consts->Output => Input->Concat + """ + + # + # Create ONNX model + # + + from onnx import helper + from onnx import TensorProto + + concat_axis = 0 + output_shape = list(shape) + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + const = np.random.randint(1, 256, shape).astype(np.float) + + node_const_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['const'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=const.shape, + vals=const.flatten(), + ), + ) + + node_def = helper.make_node( + 'Reciprocal', + inputs=['const'], + outputs=['node_out'] + ) + + node_concat_def = helper.make_node( + 'Concat', + inputs=['input', 'node_out'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # Create reference IR net + + constant_calculated = 1 / const + if precision == 'FP16': + constant_calculated = constant_calculated.astype(np.float16) + + ref_net = None + + return onnx_net, ref_net + + test_data_precommit = [ + dict(shape=[2, 4]), + dict(shape=[2, 4, 6, 8])] + + test_data = [ + dict(shape=[4, 6]), + dict(shape=[4, 6, 8]), + dict(shape=[4, 6, 8, 10]), + dict(shape=[4, 6, 8, 10, 12])] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_reciprocal_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_reciprocal(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_reciprocal_const_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_reciprocal_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_reduce.py b/tests/layer_tests/onnx_tests/test_reduce.py new file mode 100644 index 00000000000000..2df16ef3d85aed --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_reduce.py @@ -0,0 +1,179 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestReduce(OnnxRuntimeLayerTest): + def create_reduce(self, shape, reshapped_shape, op, axes, keep_dims, ir_version): + """ + ONNX net IR net + + Input->Reduce Operation (axes)->Output => Input->Reduce Operation + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + if op not in ['ReduceMin', 'ReduceMax', 'ReduceMean', 'ReduceProd', 'ReduceSum']: + raise ValueError("Operation has to be either Reduce(Min or Max or Mean or Sum or Prod") + + output_shape = shape.copy() + for axis in axes: + output_shape[axis] = 1 + + if not keep_dims: + output_shape = [dim for dim in output_shape if dim != 1] + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + node_def = onnx.helper.make_node( + op, + inputs=['input'], + outputs=['output'], + axes=axes, + keepdims=keep_dims + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'input_data_1': {'shape': [len(axes)], 'value': axes, 'kind': 'data'}, + 'const_1': {'kind': 'op', 'type': 'Const'}, + 'const_data_1': {'shape': [len(axes)], 'kind': 'data'}, + 'reduce': {'kind': 'op', 'type': op, 'keep_dims': keep_dims}, + 'reduce_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data_1', 'const_1'), + ('const_1', 'const_data_1'), + ('input_data', 'reduce'), + ('const_data_1', 'reduce'), + ('reduce', 'reduce_data'), + ('reduce_data', 'result') + ]) + + return onnx_net, ref_net + + test_data_precommit = [ + dict(shape=[2, 4, 6], reshapped_shape=[2, 1, 4 * 6, 1], axes=[1, 2]), + dict(shape=[2, 4, 6, 8], reshapped_shape=[2, 1, 4 * 6 * 8, 1], axes=[1, 2, 3]), + dict(shape=[2, 4, 6, 8, 10], reshapped_shape=[2, 4, 6 * 8 * 10, 1], axes=[2, 3, 4]) + ] + + test_data = [ + dict(shape=[2, 4, 6], reshapped_shape=[1, 1, 2, 4 * 6], axes=[0]), + dict(shape=[2, 4, 6], reshapped_shape=[2, 1, 4, 6], axes=[1]), + dict(shape=[2, 4, 6], reshapped_shape=[2, 4, 6, 1], axes=[2]), + dict(shape=[2, 4, 6], reshapped_shape=[1, 1, 2 * 4, 6], axes=[0, 1]), + dict(shape=[2, 4, 6], reshapped_shape=[2, 1, 4 * 6, 1], axes=[1, 2]), + dict(shape=[2, 4, 6, 8], reshapped_shape=[1, 1, 2, 4 * 6 * 8], axes=[0]), + dict(shape=[2, 4, 6, 8], reshapped_shape=[2, 1, 4, 6 * 8], axes=[1]), + dict(shape=[2, 4, 6, 8], reshapped_shape=[2, 4, 6, 8], axes=[2]), + dict(shape=[2, 4, 6, 8], reshapped_shape=[2, 4 * 6, 8, 1], axes=[3]), + dict(shape=[2, 4, 6, 8], reshapped_shape=[1, 1, 2 * 4, 6 * 8], axes=[0, 1]), + dict(shape=[2, 4, 6, 8], reshapped_shape=[2, 1, 4 * 6, 8], axes=[1, 2]), + dict(shape=[2, 4, 6, 8], reshapped_shape=[2, 4, 6 * 8, 1], axes=[2, 3]), + dict(shape=[2, 4, 6, 8], reshapped_shape=[1, 1, 2 * 4 * 6, 8], axes=[0, 1, 2]), + dict(shape=[2, 4, 6, 8], reshapped_shape=[2, 1, 4 * 6 * 8, 1], axes=[1, 2, 3]), + dict(shape=[2, 4, 6, 8, 10], reshapped_shape=[1, 1, 2, 4 * 6 * 8 * 10], axes=[0]), + dict(shape=[2, 4, 6, 8, 10], reshapped_shape=[2, 1, 4, 6 * 8 * 10], axes=[1]), + dict(shape=[2, 4, 6, 8, 10], reshapped_shape=[2, 4, 6, 8 * 10], axes=[2]), + dict(shape=[2, 4, 6, 8, 10], reshapped_shape=[2, 4 * 6, 8, 10], axes=[3]), + dict(shape=[2, 4, 6, 8, 10], reshapped_shape=[2, 4 * 6 * 8, 10, 1], axes=[4]), + dict(shape=[2, 4, 6, 8, 10], reshapped_shape=[1, 1, 2 * 4, 6 * 8 * 10], axes=[0, 1]), + dict(shape=[2, 4, 6, 8, 10], reshapped_shape=[2, 1, 4 * 6, 8 * 10], axes=[1, 2]), + dict(shape=[2, 4, 6, 8, 10], reshapped_shape=[2, 4, 6 * 8, 10], axes=[2, 3]), + dict(shape=[2, 4, 6, 8, 10], reshapped_shape=[2, 4 * 6, 8 * 10, 1], axes=[3, 4]), + dict(shape=[2, 4, 6, 8, 10], reshapped_shape=[1, 1, 2 * 4 * 6, 8 * 10], axes=[0, 1, 2]), + dict(shape=[2, 4, 6, 8, 10], reshapped_shape=[2, 4, 6 * 8 * 10, 1], axes=[2, 3, 4]) + ] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.parametrize("keep_dims", [True, False]) + @pytest.mark.precommit + def test_reduce_max_precommit(self, params, keep_dims, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_reduce(**params, op='ReduceMax', keep_dims=keep_dims, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.parametrize("keep_dims", [True, False]) + @pytest.mark.nightly + def test_reduce_max(self, params, keep_dims, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_reduce(**params, op='ReduceMax', keep_dims=keep_dims, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.parametrize("keep_dims", [True, False]) + @pytest.mark.nightly + def test_reduce_sum(self, params, keep_dims, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_reduce(**params, op='ReduceSum', keep_dims=keep_dims, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.parametrize("keep_dims", [True, False]) + @pytest.mark.nightly + def test_reduce_prod(self, params, keep_dims, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_reduce(**params, op='ReduceProd', keep_dims=keep_dims, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.parametrize("keep_dims", [True, False]) + @pytest.mark.precommit + def test_reduce_mean_precommit(self, params, keep_dims, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_reduce(**params, op='ReduceMean', keep_dims=keep_dims, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.parametrize("keep_dims", [True, False]) + @pytest.mark.nightly + @pytest.mark.precommit + def test_reduce_mean(self, params, keep_dims, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_reduce(**params, op='ReduceMean', keep_dims=keep_dims, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.parametrize("keep_dims", [True, False]) + @pytest.mark.precommit + def test_reduce_min_precommit(self, params, keep_dims, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_reduce(**params, op='ReduceMin', keep_dims=keep_dims, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.parametrize("keep_dims", [True, False]) + @pytest.mark.nightly + def test_reduce_min(self, params, keep_dims, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_reduce(**params, op='ReduceMin', keep_dims=keep_dims, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_reduce_lp.py b/tests/layer_tests/onnx_tests/test_reduce_lp.py new file mode 100644 index 00000000000000..4f8c42848334cb --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_reduce_lp.py @@ -0,0 +1,247 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestReduceL1L2(OnnxRuntimeLayerTest): + def create_reduce_lp(self, shape, axes, keep_dims, reduce_p, ir_version): + """ + ONNX net IR net + + Input->ReduceLX(axes)->Output => Input->ReduceLX + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + output_shape = shape.copy() + _axes = axes.copy() if axes is not None else list(range(len(shape))) + for axis in _axes: + output_shape[axis] = 1 + + if not keep_dims: + output_shape = [dim for dim in output_shape if dim != 1] + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + args = dict(keepdims=keep_dims) + if axes: + args['axes'] = axes + node_def = onnx.helper.make_node( + "ReduceL" + str(reduce_p), + inputs=['input'], + outputs=['output'], + **args + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'input_data_1': {'shape': [len(_axes)], 'value': _axes, 'kind': 'data'}, + 'const_1': {'kind': 'op', 'type': 'Const'}, + 'const_data_1': {'shape': [len(_axes)], 'kind': 'data'}, + 'reduce': {'kind': 'op', 'type': "ReduceL" + str(reduce_p), 'keep_dims': keep_dims}, + 'reduce_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data_1', 'const_1'), + ('const_1', 'const_data_1'), + ('input_data', 'reduce'), + ('const_data_1', 'reduce'), + ('reduce', 'reduce_data'), + ('reduce_data', 'result') + ]) + + return onnx_net, ref_net + + def create_reduce_lp_const(self, shape, axes, keep_dims, reduce_p, ir_version): + """ + ONNX net IR net + + Input->ReduceLX(axes)->Output => Input->ReduceLX + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + output_shape = shape.copy() + _axes = axes.copy() if axes is not None else list(range(len(shape))) + for axis in _axes: + output_shape[axis] = 1 + + if not keep_dims: + output_shape = [dim for dim in output_shape if dim != 1] + if len(output_shape) == 0: + output_shape = [1] + + concat_axis = 0 + concat_output_shape = output_shape.copy() + concat_output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, output_shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, concat_output_shape) + + constant = np.random.randn(*shape).astype(np.float) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + args = dict(keepdims=keep_dims) + if axes: + args['axes'] = axes + node_def = onnx.helper.make_node( + "ReduceL" + str(reduce_p), + inputs=['const1'], + outputs=['reduce'], + **args + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'reduce'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + constant = np.power(np.sum(a=np.abs(np.power(constant, reduce_p)), axis=tuple(_axes), keepdims=keep_dims), 1 / reduce_p) + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': output_shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': constant.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': constant.shape, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': concat_output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result') + ]) + + return onnx_net, ref_net + + test_data_precommit = [ + dict(shape=[2, 4, 6, 8], axes=[-3, -1, -2]), + dict(shape=[2, 4, 6, 8, 10], axes=[-4, -2]), + ] + + test_data = [ + dict(shape=[8], axes=None), + dict(shape=[8], axes=[0]), + dict(shape=[2, 4, 6], axes=None), + dict(shape=[2, 4, 6], axes=[1]), + dict(shape=[2, 4, 6], axes=[-2]), + dict(shape=[2, 4, 6], axes=[-2, -1]), + dict(shape=[2, 4, 6, 8], axes=[0]), + dict(shape=[2, 4, 6, 8], axes=[-3, -1, -2]), + dict(shape=[2, 4, 6, 8, 10], axes=None), + dict(shape=[2, 4, 6, 8, 10], axes=[-2]), + dict(shape=[2, 4, 6, 8, 10], axes=[1, 3]), + dict(shape=[2, 4, 6, 8, 10], axes=[-4, -2]), + ] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.parametrize("keep_dims", [True, False]) + @pytest.mark.parametrize("reduce_p", [1, 2]) + @pytest.mark.precommit + def test_reduce_lp_precommit(self, params, keep_dims, reduce_p, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_reduce_lp(**params, keep_dims=keep_dims, reduce_p=reduce_p, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.parametrize("keep_dims", [True, False]) + @pytest.mark.parametrize("reduce_p", [1, 2]) + @pytest.mark.nightly + def test_reduce_lp(self, params, keep_dims, reduce_p, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_reduce_lp(**params, keep_dims=keep_dims, reduce_p=reduce_p, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.parametrize("keep_dims", [True, False]) + @pytest.mark.parametrize("reduce_p", [1, 2]) + @pytest.mark.precommit + def test_reduce_lp_const_precommit(self, params, keep_dims, reduce_p, ie_device, precision, ir_version, temp_dir): + self._test( + *self.create_reduce_lp_const(**params, keep_dims=keep_dims, reduce_p=reduce_p, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.parametrize("keep_dims", [True, False]) + @pytest.mark.parametrize("reduce_p", [1, 2]) + @pytest.mark.nightly + def test_reduce_lp_const(self, params, keep_dims, reduce_p, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_reduce_lp_const(**params, keep_dims=keep_dims, reduce_p=reduce_p,ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_relu.py b/tests/layer_tests/onnx_tests/test_relu.py new file mode 100644 index 00000000000000..19cc96d1530405 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_relu.py @@ -0,0 +1,183 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import Caffe2OnnxLayerTest +from unit_tests.utils.graph import build_graph + + +class TestRelu(Caffe2OnnxLayerTest): + def create_net(self, shape, ir_version): + """ + ONNX net IR net + + Input->Relu->Output => Input->ReLU + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + node_def = onnx.helper.make_node( + 'Relu', + inputs=['input'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'ReLU'}, + 'node_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result') + ]) + + return onnx_net, ref_net + + def create_net_const(self, shape, precision, ir_version): + """ + ONNX net IR net + + Input->Concat(+Relu const)->Output => Input->Concat(+const) + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + import numpy as np + + concat_axis = 0 + output_shape = shape.copy() + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + const_number = np.prod(shape) + constant = np.random.randint(-127, 127, const_number).astype(np.float) + constant = np.reshape(constant, shape) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + node_def = onnx.helper.make_node( + 'Relu', + inputs=['const1'], + outputs=['relu1'] + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'relu1'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + constant = np.clip(constant, 0, np.inf) + if precision == 'FP16': + constant = constant.astype(np.float16) + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': constant.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': shape, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result') + ]) + + return onnx_net, ref_net + + test_data = [dict(shape=[10, 12]), + dict(shape=[8, 10, 12]), + dict(shape=[6, 8, 10, 12]), + dict(shape=[4, 6, 8, 10, 12]) + ] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_relu(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_relu_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_reshape.py b/tests/layer_tests/onnx_tests/test_reshape.py new file mode 100644 index 00000000000000..4483d1250455fb --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_reshape.py @@ -0,0 +1,283 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import Caffe2OnnxLayerTest +from unit_tests.utils.graph import build_graph + + +class TestReshape(Caffe2OnnxLayerTest): + def create_reshape_net(self, input_shape, output_shape, ir_version): + """ + ONNX net IR net + + Input->Reshape->Output => Input->Reshape + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, input_shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + node_shape_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['shape'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.INT64, + dims=[len(output_shape)], + vals=output_shape, + ), + ) + + node_reshape_def = onnx.helper.make_node( + 'Reshape', + inputs=['input', 'shape'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_shape_def, node_reshape_def], + 'test_reshape_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_reshape_model') + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': input_shape, 'kind': 'data'}, + 'input_data_1': {'shape': [len(output_shape)], 'value': output_shape, 'kind': 'data'}, + 'const_1': {'kind': 'op', 'type': 'Const'}, + 'const_data_1': {'shape': [len(output_shape)], 'value': None, 'kind': 'data'}, # 'value': output_shape, + 'reshape': {'kind': 'op', 'type': 'Reshape'}, + 'reshape_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data_1', 'const_1'), + ('const_1', 'const_data_1'), + ('const_data_1', 'reshape'), + ('input_data', 'reshape'), + ('reshape', 'reshape_data'), + ('reshape_data', 'result') + ]) + + return onnx_net, ref_net + + def create_reshape_net_const(self, input_shape, output_shape, ir_version): + """ + ONNX net IR net + + Input->Concat(+reshaped const)->Output => Input->Concat(+const) + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + import numpy as np + + concat_axis = 0 + concat_output_shape = output_shape.copy() + concat_output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, output_shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, concat_output_shape) + + const_number = np.prod(input_shape) + constant = np.random.randint(-127, 127, const_number).astype(np.float) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=input_shape, + vals=constant, + ), + ) + + node_shape_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['shape'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.INT64, + dims=[len(output_shape)], + vals=output_shape, + ), + ) + + node_reshape_def = onnx.helper.make_node( + 'Reshape', + inputs=['const1', 'shape'], + outputs=['reshape1'] + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'reshape1'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_shape_def, node_reshape_def, node_concat_def], + 'test_reshape_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_reshape_model') + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': output_shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': constant}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': output_shape, 'value': None, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': concat_output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result'), + ]) + + return onnx_net, ref_net + + test_data_5D = [dict(input_shape=[4, 6, 8, 10, 12], output_shape=[4, 6, 8, 120]), + dict(input_shape=[4, 6, 8, 10, 12], output_shape=[4, 6, 80, 12]), + dict(input_shape=[4, 6, 8, 10, 12], output_shape=[4, 48, 10, 12]), + dict(input_shape=[4, 6, 8, 10, 12], output_shape=[24, 8, 10, 12]), + dict(input_shape=[4, 6, 8, 10], output_shape=[2, 2, 6, 8, 10]), + dict(input_shape=[4, 6, 8, 10], output_shape=[4, 2, 3, 8, 10]), + dict(input_shape=[4, 6, 8, 10], output_shape=[4, 6, 2, 4, 10]), + dict(input_shape=[4, 6, 8, 10], output_shape=[4, 6, 8, 2, 5])] + + test_data_5D_precommit = [dict(input_shape=[2, 4, 6, 8, 10], output_shape=[8, 6, 8, 10])] + + test_data_4D = [dict(input_shape=[4, 6, 8, 10], output_shape=[24, 8, 10]), + dict(input_shape=[4, 6, 8, 10], output_shape=[4, 48, 10]), + dict(input_shape=[4, 6, 8, 10], output_shape=[4, 6, 80]), + dict(input_shape=[4, 6, 8, 10], output_shape=[192, 10]), + dict(input_shape=[4, 6, 8, 10], output_shape=[4, 480]), + dict(input_shape=[4, 6, 8], output_shape=[2, 2, 6, 8]), + dict(input_shape=[4, 6, 8], output_shape=[4, 2, 3, 8]), + dict(input_shape=[4, 6, 8], output_shape=[4, 6, 2, 4]), + dict(input_shape=[4, 6], output_shape=[2, 2, 2, 3])] + + test_data_4D_precommit = [dict(input_shape=[2, 4, 6, 8], output_shape=[48, 8])] + + test_data_3D = [dict(input_shape=[4, 6, 8], output_shape=[24, 8]), + dict(input_shape=[4, 6, 8], output_shape=[4, 48]), + dict(input_shape=[4, 6], output_shape=[2, 2, 6]), + dict(input_shape=[4, 6], output_shape=[4, 2, 3]), + dict(input_shape=[4, 6], output_shape=[2, 4, 3])] + + test_data_3D_precommit = [dict(input_shape=[2, 4, 6], output_shape=[8, 6])] + + @pytest.mark.parametrize("params", test_data_5D_precommit) + @pytest.mark.precommit + def test_reshape_5D_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_reshape_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_4D_precommit) + @pytest.mark.precommit + def test_reshape_4D_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_reshape_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_3D_precommit) + @pytest.mark.precommit + def test_reshape_3D_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_reshape_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.nightly + @pytest.mark.precommit + def test_reshape_5D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_reshape_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + def test_reshape_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_reshape_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_3D) + @pytest.mark.nightly + def test_reshape_3D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_reshape_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.nightly + def test_reshape_const_5D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_reshape_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + def test_reshape_const_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_reshape_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_3D) + @pytest.mark.nightly + def test_reshape_const_3D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_reshape_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_resize.py b/tests/layer_tests/onnx_tests/test_resize.py new file mode 100644 index 00000000000000..3106ed52a778a4 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_resize.py @@ -0,0 +1,676 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from mo.front.common.partial_infer.utils import int64_array +from mo.middle.passes.convert_data_type import data_type_str_to_np, np_data_type_to_destination_type +from unit_tests.utils.graph import build_graph + + +class TestResize(OnnxRuntimeLayerTest): + def create_resize_net(self, input_shape, output_shape, scales, sizes, + coordinate_transformation_mode, cubic_coeff_a, mode, + nearest_mode, precision, ir_version): + import onnx + from onnx import helper + from onnx import TensorProto + + input_rank = len(input_shape) + + roi_node = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['roi'], + value=helper.make_tensor( + name='roi_consts', + data_type=TensorProto.FLOAT, + dims=[2 * input_rank], + vals=np.array([*np.zeros(input_rank), *np.ones(input_rank)]) + ) + ) + + onnx_scales = scales + if scales is None: + onnx_scales = np.array(output_shape).astype(np.float) / np.array(input_shape).astype(np.float) + scales_node = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['scales'], + value=helper.make_tensor( + name='scales_const', + data_type=TensorProto.FLOAT, + dims=[len(output_shape)], + vals=onnx_scales + ) + ) + + nodes_list = [roi_node, scales_node] + inputs_list = ['input', 'roi', 'scales'] + + if sizes is not None: + sizes_node = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['sizes'], + value=helper.make_tensor( + name='sizes_const', + data_type=TensorProto.INT64, + dims=[len(output_shape)], + vals=sizes + ) + ) + + nodes_list.append(sizes_node) + inputs_list.append('sizes') + + args = dict() + + onnx_mode = mode or 'nearest' + onnx_nearest_mode = nearest_mode or 'round_prefer_floor' + cube_coeff = -0.75 if cubic_coeff_a is None else cubic_coeff_a + onnx_coordinate_transformation_mode = coordinate_transformation_mode or 'half_pixel' + + args['nearest_mode'] = onnx_nearest_mode + args['mode'] = onnx_mode + args['cubic_coeff_a'] = cube_coeff + args['coordinate_transformation_mode'] = onnx_coordinate_transformation_mode + + x = helper.make_tensor_value_info('input', TensorProto.FLOAT, input_shape) + y = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + resize_node = onnx.helper.make_node( + 'Resize', + inputs=inputs_list, + outputs=['output'], + **args, + ) + + nodes_list.append(resize_node) + + graph_def = onnx.helper.make_graph(nodes_list, 'test_model', [x], [y]) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + onnx.checker.check_model(onnx_net) + + # + # Create reference IR net + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + if sizes is None and scales is None: + return onnx_net, ref_net + + input_shape_as_array = int64_array(input_shape) + + if sizes is not None and scales is not None: + shape_calculation_mode = 'sizes' + sizes_value = int64_array(sizes) + scales_value = np.array(scales).astype(np.float) + elif sizes is not None and scales is None: + shape_calculation_mode = 'sizes' + sizes_value = int64_array(sizes) + scales_value = sizes_value / input_shape_as_array + else: + shape_calculation_mode = 'scales' + scales_value = np.array(scales).astype(np.float) + sizes_value = np.floor(input_shape_as_array * scales_value + 1e-5).astype(np.int64) + + if precision == 'FP16': + sizes_value = sizes_value.astype(np.float16) + scales_value = scales_value.astype(np.float16) + + interp_mode = convert_onnx_mode(onnx_mode) + + interp_attrs = { + 'type': 'Interpolate', + 'kind': 'op', + 'mode': interp_mode, + 'shape_calculation_mode': shape_calculation_mode, + 'coordinate_transformation_mode': onnx_coordinate_transformation_mode, + 'nearest_mode': onnx_nearest_mode, + 'antialias': 0, + 'cube_coeff': cube_coeff, + 'pads_begin': np.zeros(input_rank).astype(np.int64), + 'pads_end': np.zeros(input_rank).astype(np.int64), + 'version': 'opset4' + } + + if shape_calculation_mode == 'scales': + ref_net = create_ref_net_in_scales_mode(precision, input_shape_as_array, output_shape, + sizes_value, scales_value, interp_attrs) + else: + ref_net = create_ref_net_in_sizes_mode(precision, input_shape_as_array, output_shape, + sizes_value, scales_value, interp_attrs) + + return onnx_net, ref_net + + test_data = [ + dict(input_shape=[1, 1, 4, 4], output_shape=[1, 1, 3, 3], + scales=[1.0, 1.0, 0.8, 0.8], sizes=None, + coordinate_transformation_mode='half_pixel', + cubic_coeff_a=None, mode='cubic', nearest_mode=None), + dict(input_shape=[1, 1, 4, 4], output_shape=[1, 1, 3, 3], + scales=[1.0, 1.0, 0.8, 0.8], sizes=None, + coordinate_transformation_mode='align_corners', + cubic_coeff_a=None, mode='cubic', nearest_mode=None), + dict(input_shape=[1, 1, 2, 4], output_shape=[1, 1, 1, 2], + scales=[1.0, 1.0, 0.6, 0.6], sizes=None, + coordinate_transformation_mode=None, + cubic_coeff_a=None, mode='linear', nearest_mode=None), + dict(input_shape=[1, 1, 2, 4], output_shape=[1, 1, 1, 2], + scales=[1.0, 1.0, 0.6, 0.6], sizes=None, + coordinate_transformation_mode='align_corners', + cubic_coeff_a=None, mode='linear', nearest_mode=None), + dict(input_shape=[1, 1, 2, 4], output_shape=[1, 1, 1, 2], + scales=[1.0, 1.0, 0.6, 0.6], sizes=None, + coordinate_transformation_mode=None, + cubic_coeff_a=None, mode='nearest', nearest_mode=None), + dict(input_shape=[1, 1, 4, 4], output_shape=[1, 1, 8, 8], + scales=[1.0, 1.0, 2.0, 2.0], sizes=None, + coordinate_transformation_mode=None, + cubic_coeff_a=None, mode='cubic', nearest_mode=None), + dict(input_shape=[1, 1, 4, 4], output_shape=[1, 1, 8, 8], + scales=[1.0, 1.0, 2.0, 2.0], sizes=None, + coordinate_transformation_mode='align_corners', + cubic_coeff_a=None, mode='cubic', nearest_mode=None), + dict(input_shape=[1, 1, 4, 4], output_shape=[1, 1, 8, 8], + scales=[1.0, 1.0, 2.0, 2.0], sizes=None, + coordinate_transformation_mode='asymmetric', + cubic_coeff_a=None, mode='cubic', nearest_mode=None), + dict(input_shape=[1, 1, 2, 2], output_shape=[1, 1, 4, 4], + scales=[1.0, 1.0, 2.0, 2.0], sizes=None, + coordinate_transformation_mode=None, + cubic_coeff_a=None, mode='linear', nearest_mode=None), + dict(input_shape=[1, 1, 2, 2], output_shape=[1, 1, 4, 4], + scales=[1.0, 1.0, 2.0, 2.0], sizes=None, + coordinate_transformation_mode='align_corners', + cubic_coeff_a=None, mode='linear', nearest_mode=None), + dict(input_shape=[1, 1, 2, 2], output_shape=[1, 1, 4, 4], + scales=[1.0, 1.0, 2.0, 2.0], sizes=None, + coordinate_transformation_mode=None, + cubic_coeff_a=None, mode='nearest', nearest_mode=None) + ] + + @pytest.mark.parametrize("params", test_data) + def test_resize(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_resize_net(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, custom_eps=2.0e-4, temp_dir=temp_dir) + + test_data_cubic = [ + dict(input_shape=[1, 3, 100, 200], output_shape=[1, 3, 350, 150], + scales=[1.0, 1.0, 3.5, 150 / 200], sizes=None), + dict(input_shape=[16, 7, 190, 400], output_shape=[16, 7, 390, 600], + scales=[1.0, 1.0, 390 / 190, 600 / 400], sizes=None), + dict(input_shape=[4, 33, 1024, 800], output_shape=[4, 33, 512, 800], + scales=[1.0, 1.0, 0.5, 1.0], sizes=None), + dict(input_shape=[4, 33, 3, 800], output_shape=[4, 33, 1, 800], + scales=[1.0, 1.0, 0.3333334, 1.0], sizes=None), + dict(input_shape=[100, 200], output_shape=[350, 150], + scales=[3.5, 150 / 200], sizes=None), + dict(input_shape=[190, 400], output_shape=[390, 600], + scales=[390 / 190, 600 / 400], sizes=None), + dict(input_shape=[1024, 800], output_shape=[512, 800], + scales=[0.5, 1.0], sizes=None), + dict(input_shape=[3, 800], output_shape=[1, 800], + scales=[0.3333334, 1.0], sizes=None) + ] + + @pytest.mark.parametrize("params", test_data_cubic) + @pytest.mark.parametrize("coordinate_transformation_mode", + ['half_pixel', 'pytorch_half_pixel', 'align_corners', + 'asymmetric', 'tf_half_pixel_for_nn']) + @pytest.mark.parametrize("cubic_coeff_a", [-0.75]) + @pytest.mark.parametrize("mode", ['cubic']) + @pytest.mark.parametrize("nearest_mode", ['round_prefer_floor']) + def test_resize_combined_cubic(self, params, coordinate_transformation_mode, cubic_coeff_a, mode, + nearest_mode, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_resize_net(**params, + coordinate_transformation_mode=coordinate_transformation_mode, + cubic_coeff_a=cubic_coeff_a, mode=mode, nearest_mode=nearest_mode, + precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, custom_eps=2.6e-2, temp_dir=temp_dir) + + test_data_nearest = [ + dict(input_shape=[1, 3, 100, 200], output_shape=[1, 3, 350, 150], + scales=[1.0, 1.0, 3.5, 150 / 200], sizes=None), + dict(input_shape=[16, 7, 190, 400], output_shape=[16, 7, 390, 600], + scales=[1.0, 1.0, 390 / 190, 600 / 400], sizes=None), + dict(input_shape=[4, 33, 600, 800], output_shape=[4, 33, 300, 800], + scales=[1.0, 1.0, 0.5, 1.0], sizes=None), + dict(input_shape=[4, 33, 3, 800], output_shape=[4, 33, 1, 800], + scales=[1.0, 1.0, 0.3333334, 1.0], sizes=None), + ] + + @pytest.mark.parametrize("params", test_data_nearest) + @pytest.mark.parametrize("coordinate_transformation_mode", + ['half_pixel', 'pytorch_half_pixel', 'align_corners', + 'asymmetric', 'tf_half_pixel_for_nn']) + @pytest.mark.parametrize("cubic_coeff_a", [-0.75]) + @pytest.mark.parametrize("mode", ['nearest']) + @pytest.mark.parametrize("nearest_mode", ['round_prefer_floor', 'round_prefer_ceil', + 'floor', 'ceil']) + def test_resize_combined_nearest(self, params, coordinate_transformation_mode, cubic_coeff_a, mode, + nearest_mode, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_resize_net(**params, + coordinate_transformation_mode=coordinate_transformation_mode, + cubic_coeff_a=cubic_coeff_a, mode=mode, nearest_mode=nearest_mode, + precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_linear = [ + dict(input_shape=[1, 3, 100, 200], output_shape=[1, 3, 350, 150], + scales=[1.0, 1.0, 3.5, 150 / 200], sizes=None), + dict(input_shape=[16, 7, 190, 400], output_shape=[16, 7, 390, 600], + scales=[1.0, 1.0, 390 / 190, 600 / 400], sizes=None), + dict(input_shape=[4, 33, 600, 800], output_shape=[4, 33, 300, 800], + scales=[1.0, 1.0, 0.5, 1.0], sizes=None), + dict(input_shape=[4, 33, 3, 800], output_shape=[4, 33, 1, 800], + scales=[1.0, 1.0, 0.3333334, 1.0], sizes=None), + dict(input_shape=[100, 200], output_shape=[350, 150], + scales=[3.5, 150 / 200], sizes=None), + dict(input_shape=[190, 400], output_shape=[390, 600], + scales=[390 / 190, 600 / 400], sizes=None), + dict(input_shape=[600, 800], output_shape=[300, 800], + scales=[0.5, 1.0], sizes=None), + dict(input_shape=[3, 800], output_shape=[1, 800], + scales=[0.3333334, 1.0], sizes=None), + ] + + @pytest.mark.parametrize("params", test_data_linear) + @pytest.mark.parametrize("coordinate_transformation_mode", + ['half_pixel', 'pytorch_half_pixel', 'align_corners', + 'asymmetric', 'tf_half_pixel_for_nn']) + @pytest.mark.parametrize("cubic_coeff_a", [-0.75]) + @pytest.mark.parametrize("mode", ['linear']) + @pytest.mark.parametrize("nearest_mode", ['round_prefer_floor']) + def test_resize_combined_linear(self, params, coordinate_transformation_mode, cubic_coeff_a, mode, + nearest_mode, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_resize_net(**params, + coordinate_transformation_mode=coordinate_transformation_mode, + cubic_coeff_a=cubic_coeff_a, mode=mode, nearest_mode=nearest_mode, + precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, custom_eps=2.0e-2, temp_dir=temp_dir) + + test_data_sizes = [ + dict(input_shape=[1, 1, 4, 4], output_shape=[1, 1, 3, 3], + scales=None, sizes=[1, 1, 3, 3], + coordinate_transformation_mode=None, + cubic_coeff_a=None, mode='cubic', nearest_mode=None), + dict(input_shape=[1, 1, 4, 4], output_shape=[1, 1, 3, 1], + scales=None, sizes=[1, 1, 3, 1], + coordinate_transformation_mode='pytorch_half_pixel', + cubic_coeff_a=None, mode='linear', nearest_mode=None), + dict(input_shape=[1, 1, 2, 4], output_shape=[1, 1, 1, 3], + scales=None, sizes=[1, 1, 1, 3], + coordinate_transformation_mode=None, + cubic_coeff_a=None, mode='nearest', nearest_mode=None), + dict(input_shape=[1, 1, 2, 4], output_shape=[1, 1, 1, 2], + scales=None, sizes=[1, 1, 1, 2], + coordinate_transformation_mode=None, + cubic_coeff_a=None, mode='nearest', nearest_mode=None), + dict(input_shape=[1, 1, 4, 4], output_shape=[1, 1, 3, 2], + scales=None, sizes=[1, 1, 3, 2], + coordinate_transformation_mode='tf_half_pixel_for_nn', + cubic_coeff_a=None, mode='nearest', nearest_mode=None), + dict(input_shape=[1, 1, 4, 4], output_shape=[1, 1, 9, 10], + scales=None, sizes=[1, 1, 9, 10], + coordinate_transformation_mode=None, + cubic_coeff_a=None, mode='cubic', nearest_mode=None), + dict(input_shape=[1, 1, 2, 2], output_shape=[1, 1, 7, 8], + scales=None, sizes=[1, 1, 7, 8], + coordinate_transformation_mode=None, + cubic_coeff_a=None, mode='nearest', nearest_mode=None), + dict(input_shape=[1, 1, 4, 4], output_shape=[1, 1, 8, 8], + scales=None, sizes=[1, 1, 8, 8], + coordinate_transformation_mode='half_pixel', + cubic_coeff_a=None, mode='nearest', nearest_mode='ceil'), + dict(input_shape=[1, 1, 4, 4], output_shape=[1, 1, 8, 8], + scales=None, sizes=[1, 1, 8, 8], + coordinate_transformation_mode='align_corners', + cubic_coeff_a=None, mode='nearest', nearest_mode='floor'), + dict(input_shape=[1, 1, 4, 4], output_shape=[1, 1, 8, 8], + scales=None, sizes=[1, 1, 8, 8], + coordinate_transformation_mode='asymmetric', + cubic_coeff_a=None, mode='nearest', nearest_mode='round_prefer_ceil'), + ] + + @pytest.mark.parametrize("params", test_data_sizes) + def test_resize_sizes(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_resize_net(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_sizes_cubic = [ + dict(input_shape=[1, 3, 100, 200], output_shape=[1, 3, 350, 150], + scales=None, sizes=[1, 3, 350, 150]), + dict(input_shape=[16, 7, 190, 400], output_shape=[16, 7, 390, 600], + scales=None, sizes=[16, 7, 390, 600]), + dict(input_shape=[4, 15, 700, 800], output_shape=[4, 15, 350, 800], + scales=None, sizes=[4, 15, 350, 800]), + dict(input_shape=[4, 15, 3, 200], output_shape=[4, 15, 1, 200], + scales=None, sizes=[4, 15, 1, 200]), + dict(input_shape=[100, 200], output_shape=[350, 150], + scales=None, sizes=[350, 150]), + dict(input_shape=[190, 400], output_shape=[390, 600], + scales=None, sizes=[390, 600]), + dict(input_shape=[700, 800], output_shape=[350, 800], + scales=None, sizes=[350, 800]), + dict(input_shape=[3, 200], output_shape=[1, 200], + scales=None, sizes=[1, 200]), + ] + + @pytest.mark.parametrize("params", test_data_sizes_cubic) + @pytest.mark.parametrize("coordinate_transformation_mode", + ['half_pixel', 'pytorch_half_pixel', 'align_corners', + 'asymmetric', 'tf_half_pixel_for_nn']) + @pytest.mark.parametrize("cubic_coeff_a", [-0.75]) + @pytest.mark.parametrize("mode", ['cubic']) + @pytest.mark.parametrize("nearest_mode", ['round_prefer_floor']) + def test_resize_combined_sizes_cubic(self, params, coordinate_transformation_mode, cubic_coeff_a, mode, + nearest_mode, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_resize_net(**params, + coordinate_transformation_mode=coordinate_transformation_mode, + cubic_coeff_a=cubic_coeff_a, mode=mode, nearest_mode=nearest_mode, + precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, custom_eps=2.6e-2, temp_dir=temp_dir) + + test_data_sizes_nearest = [ + dict(input_shape=[1, 3, 100, 200], output_shape=[1, 3, 350, 150], + scales=None, sizes=[1, 3, 350, 150]), + dict(input_shape=[16, 7, 190, 400], output_shape=[16, 7, 390, 600], + scales=None, sizes=[16, 7, 390, 600]), + dict(input_shape=[4, 33, 600, 800], output_shape=[4, 33, 300, 800], + scales=None, sizes=[4, 33, 300, 800]), + dict(input_shape=[4, 33, 3, 800], output_shape=[4, 33, 1, 800], + scales=None, sizes=[4, 33, 1, 800]), + dict(input_shape=[3, 100, 200], output_shape=[3, 350, 150], + scales=None, sizes=[3, 350, 150]), + dict(input_shape=[7, 190, 400], output_shape=[7, 390, 600], + scales=None, sizes=[7, 390, 600]), + dict(input_shape=[33, 600, 800], output_shape=[33, 300, 800], + scales=None, sizes=[33, 300, 800]), + dict(input_shape=[33, 3, 800], output_shape=[33, 1, 800], + scales=None, sizes=[33, 1, 800]), + dict(input_shape=[100, 200], output_shape=[350, 150], + scales=None, sizes=[350, 150]), + dict(input_shape=[190, 400], output_shape=[390, 600], + scales=None, sizes=[390, 600]), + dict(input_shape=[600, 800], output_shape=[300, 800], + scales=None, sizes=[300, 800]), + dict(input_shape=[3, 800], output_shape=[1, 800], + scales=None, sizes=[1, 800]), + dict(input_shape=[100], output_shape=[350], + scales=None, sizes=[350]), + dict(input_shape=[190], output_shape=[390], + scales=None, sizes=[390]), + dict(input_shape=[600], output_shape=[300], + scales=None, sizes=[300]), + dict(input_shape=[3], output_shape=[1], + scales=None, sizes=[1]), + ] + + @pytest.mark.parametrize("params", test_data_sizes_nearest) + @pytest.mark.parametrize("coordinate_transformation_mode", + ['half_pixel', 'pytorch_half_pixel', 'align_corners', + 'asymmetric', 'tf_half_pixel_for_nn']) + @pytest.mark.parametrize("cubic_coeff_a", [-0.75]) + @pytest.mark.parametrize("mode", ['nearest']) + @pytest.mark.parametrize("nearest_mode", ['round_prefer_floor', 'round_prefer_ceil', + 'floor', 'ceil']) + def test_resize_combined_sizes_nearest(self, params, coordinate_transformation_mode, cubic_coeff_a, mode, + nearest_mode, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_resize_net(**params, + coordinate_transformation_mode=coordinate_transformation_mode, + cubic_coeff_a=cubic_coeff_a, mode=mode, nearest_mode=nearest_mode, + precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_sizes_linear = [ + dict(input_shape=[1, 3, 100, 200], output_shape=[1, 3, 350, 150], + scales=None, sizes=[1, 3, 350, 150]), + dict(input_shape=[16, 7, 190, 400], output_shape=[16, 7, 390, 600], + scales=None, sizes=[16, 7, 390, 600]), + dict(input_shape=[4, 33, 600, 800], output_shape=[4, 33, 300, 800], + scales=None, sizes=[4, 33, 300, 800]), + dict(input_shape=[4, 33, 3, 800], output_shape=[4, 33, 1, 800], + scales=None, sizes=[4, 33, 1, 800]), + dict(input_shape=[100, 200], output_shape=[350, 150], + scales=None, sizes=[350, 150]), + dict(input_shape=[190, 400], output_shape=[390, 600], + scales=None, sizes=[390, 600]), + dict(input_shape=[600, 800], output_shape=[300, 800], + scales=None, sizes=[300, 800]), + dict(input_shape=[3, 800], output_shape=[1, 800], + scales=None, sizes=[1, 800]), + ] + + @pytest.mark.parametrize("params", test_data_sizes_linear) + @pytest.mark.parametrize("coordinate_transformation_mode", + ['half_pixel', 'pytorch_half_pixel', 'align_corners', + 'asymmetric', 'tf_half_pixel_for_nn']) + @pytest.mark.parametrize("cubic_coeff_a", [-0.75]) + @pytest.mark.parametrize("mode", ['linear']) + @pytest.mark.parametrize("nearest_mode", ['round_prefer_floor']) + def test_resize_combined_sizes_linear(self, params, coordinate_transformation_mode, cubic_coeff_a, mode, + nearest_mode, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_resize_net(**params, + coordinate_transformation_mode=coordinate_transformation_mode, + cubic_coeff_a=cubic_coeff_a, mode=mode, nearest_mode=nearest_mode, + precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, custom_eps=2.0e-2, temp_dir=temp_dir) + + +def create_ref_net_in_sizes_mode(precision, input_shape, output_shape, sizes_value, scales_value, attrs): + input_data_type = np_data_type_to_destination_type(data_type_str_to_np(precision)) + input_rank = len(input_shape) + epsilon = np.array([1.0e-5]) + spatial_dims = spatial_dimensions(input_shape) + begin_dim = spatial_dims[0] + end_dim = input_rank + + spatial_sizes_value = sizes_value[spatial_dims] + + nodes_attrs = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': input_shape, 'kind': 'data'}, + 'shape_of': {'kind': 'op', 'type': 'ShapeOf'}, + 'shape_of_data': {'shape': int64_array([input_rank]), 'kind': 'data'}, + 'shape_to_float': {'kind': 'op', 'type': 'Convert', 'destination_type': input_data_type}, + 'shape_to_float_data': {'shape': int64_array([input_rank]), 'kind': 'data'}, + 'div': {'kind': 'op', 'type': 'Divide'}, + 'div_data': {'shape': int64_array([input_rank]), 'kind': 'data'}, + 'div_sizes_const_data': {'kind': 'data', 'value': sizes_value}, + 'div_sizes_const': {'kind': 'op', 'type': 'Const'}, + 'div_sizes_data': {'shape': int64_array([input_rank]), 'kind': 'data'}, + 'eps_const_data': {'kind': 'data', 'value': epsilon}, + 'eps_const': {'kind': 'op', 'type': 'Const'}, + 'eps_data': {'shape': int64_array([1]), 'kind': 'data'}, + 'add': {'kind': 'op', 'type': 'Add'}, + 'add_data': {'shape': int64_array([input_rank]), 'kind': 'data'}, + 'ss_scales': { + 'kind': 'op', 'type': 'StridedSlice', 'begin_mask': 0, + 'end_mask': 0, 'new_axis_mask': 0, + 'shrink_axis_mask': 0, 'ellipsis_mask': 0 + }, + 'ss_scales_data': {'shape': int64_array([len(spatial_sizes_value)]), 'kind': 'data'}, + 'ss_scales_begin_const_data': {'kind': 'data', 'value': int64_array([begin_dim])}, + 'ss_scales_begin_const': {'kind': 'op', 'type': 'Const'}, + 'ss_scales_begin_data': {'shape': int64_array([1]), 'kind': 'data'}, + 'ss_scales_end_const_data': {'kind': 'data', 'value': int64_array([end_dim])}, + 'ss_scales_end_const': {'kind': 'op', 'type': 'Const'}, + 'ss_scales_end_data': {'shape': int64_array([1]), 'kind': 'data'}, + 'ss_scales_stride_const_data': {'kind': 'data', 'value': int64_array([1])}, + 'ss_scales_stride_const': {'kind': 'op', 'type': 'Const'}, + 'ss_scales_stride_data': {'shape': int64_array([1]), 'kind': 'data'}, + 'sizes_const_data': {'kind': 'data', 'value': spatial_sizes_value}, + 'sizes_const': {'kind': 'op', 'type': 'Const'}, + 'sizes_data': {'shape': int64_array([len(spatial_sizes_value)]), 'kind': 'data'}, + 'axes_const_data': {'kind': 'data', 'value': spatial_dims}, + 'axes_const': {'kind': 'op', 'type': 'Const'}, + 'axes_data': {'shape': int64_array([len(spatial_dims)]), 'kind': 'data'}, + 'interpolate': attrs, + 'interpolate_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'}, + } + edges = [ + ('input', 'input_data'), + ('input_data', 'interpolate', {'in': 0, 'out': 0}), + ('input_data', 'shape_of', {'in': 0, 'out': 0}), + ('shape_of', 'shape_of_data'), + ('shape_of_data', 'shape_to_float'), + ('shape_to_float', 'shape_to_float_data'), + ('shape_to_float_data', 'div', {'in': 1}), + ('div_sizes_const_data', 'div_sizes_const'), + ('div_sizes_const', 'div_sizes_data'), + ('div_sizes_data', 'div', {'in': 0}), + ('div', 'div_data'), + ('eps_const_data', 'eps_const'), + ('eps_const', 'eps_data'), + ('div_data', 'add', {'in': 0}), + ('eps_data', 'add', {'in': 1}), + ('add', 'add_data'), + ('add_data', 'ss_scales', {'in': 0}), + ('ss_scales', 'ss_scales_data'), + ('ss_scales_begin_const_data', 'ss_scales_begin_const'), + ('ss_scales_begin_const', 'ss_scales_begin_data'), + ('ss_scales_begin_data', 'ss_scales', {'in': 1}), + ('ss_scales_end_const_data', 'ss_scales_end_const'), + ('ss_scales_end_const', 'ss_scales_end_data'), + ('ss_scales_end_data', 'ss_scales', {'in': 2}), + ('ss_scales_stride_const_data', 'ss_scales_stride_const'), + ('ss_scales_stride_const', 'ss_scales_stride_data'), + ('ss_scales_stride_data', 'ss_scales', {'in': 3}), + ('ss_scales_data', 'interpolate', {'in': 2}), + ('sizes_const_data', 'sizes_const'), + ('sizes_const', 'sizes_data'), + ('sizes_data', 'interpolate', {'in': 1}), + ('axes_const_data', 'axes_const'), + ('axes_const', 'axes_data'), + ('axes_data', 'interpolate', {'in': 3}), + ('interpolate', 'interpolate_data'), + ('interpolate_data', 'result') + ] + + return build_graph(nodes_attrs, edges) + + +def create_ref_net_in_scales_mode(precision, input_shape, output_shape, sizes_value, scales_value, attrs): + input_data_type = np_data_type_to_destination_type(data_type_str_to_np(precision)) + input_rank = len(input_shape) + epsilon = np.array([1.0e-5]) + spatial_dims = spatial_dimensions(input_shape) + begin_dim = spatial_dims[0] + end_dim = input_rank + + spatial_scales_value = scales_value[spatial_dims] + + nodes_attrs = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': input_shape, 'kind': 'data'}, + 'shape_of': {'kind': 'op', 'type': 'ShapeOf'}, + 'shape_of_data': {'shape': int64_array([input_rank]), 'kind': 'data'}, + 'shape_to_float': {'kind': 'op', 'type': 'Convert', 'destination_type': input_data_type}, + 'shape_to_float_data': {'shape': int64_array([input_rank]), 'kind': 'data'}, + 'mul': {'kind': 'op', 'type': 'Multiply'}, + 'mul_scales_const_data': {'kind': 'data', 'value': scales_value}, + 'mul_scales_const': {'kind': 'op', 'type': 'Const'}, + 'mul_scales_data': {'shape': int64_array([input_rank]), 'kind': 'data'}, + 'mul_data': {'shape': int64_array([input_rank]), 'kind': 'data'}, + 'eps_const_data': {'kind': 'data', 'value': epsilon}, + 'eps_const': {'kind': 'op', 'type': 'Const'}, + 'eps_data': {'shape': int64_array([1]), 'kind': 'data'}, + 'add': {'kind': 'op', 'type': 'Add'}, + 'add_data': {'shape': int64_array([input_rank]), 'kind': 'data'}, + 'floor': {'type': 'Floor', 'kind': 'op'}, + 'floor_data': {'shape': int64_array([input_rank]), 'kind': 'data'}, + 'to_int': {'kind': 'op', 'type': 'Convert', 'destination_type': 'i64'}, + 'to_int_data': {'shape': int64_array([input_rank]), 'kind': 'data'}, + 'strided_slice': { + 'kind': 'op', 'type': 'StridedSlice', 'begin_mask': 0, + 'end_mask': 0, 'new_axis_mask': 0, + 'shrink_axis_mask': 0, 'ellipsis_mask': 0 + }, + 'strided_slice_data': {'shape': int64_array([len(spatial_scales_value)]), 'kind': 'data'}, + 'begin_const_data': {'kind': 'data', 'value': int64_array([begin_dim])}, + 'begin_const': {'kind': 'op', 'type': 'Const'}, + 'begin_data': {'shape': int64_array([1]), 'kind': 'data'}, + 'end_const_data': {'kind': 'data', 'value': int64_array([end_dim])}, + 'end_const': {'kind': 'op', 'type': 'Const'}, + 'end_data': {'shape': int64_array([1]), 'kind': 'data'}, + 'stride_const_data': {'kind': 'data', 'value': int64_array([1])}, + 'stride_const': {'kind': 'op', 'type': 'Const'}, + 'stride_data': {'shape': int64_array([1]), 'kind': 'data'}, + 'scales_const_data': {'kind': 'data', 'value': spatial_scales_value}, + 'scales_const': {'kind': 'op', 'type': 'Const'}, + 'scales_data': {'shape': int64_array([len(spatial_scales_value)]), 'kind': 'data'}, + 'axes_const_data': {'kind': 'data', 'value': spatial_dims}, + 'axes_const': {'kind': 'op', 'type': 'Const'}, + 'axes_data': {'shape': int64_array([len(spatial_dims)]), 'kind': 'data'}, + 'interpolate': attrs, + 'interpolate_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'}, + } + edges = [ + ('input', 'input_data'), + ('input_data', 'interpolate', {'in': 0, 'out': 0}), + ('input_data', 'shape_of', {'in': 0, 'out': 0}), + ('shape_of', 'shape_of_data'), + ('shape_of_data', 'shape_to_float'), + ('shape_to_float', 'shape_to_float_data'), + ('shape_to_float_data', 'mul', {'in': 0}), + ('mul_scales_const_data', 'mul_scales_const'), + ('mul_scales_const', 'mul_scales_data'), + ('mul_scales_data', 'mul', {'in': 1}), + ('mul', 'mul_data'), + ('eps_const_data', 'eps_const'), + ('eps_const', 'eps_data'), + ('mul_data', 'add', {'in': 0}), + ('eps_data', 'add', {'in': 1}), + ('add', 'add_data'), + ('add_data', 'floor'), + ('floor', 'floor_data'), + ('floor_data', 'to_int'), + ('to_int', 'to_int_data'), + ('to_int_data', 'strided_slice', {'in': 0}), + ('strided_slice', 'strided_slice_data'), + ('begin_const_data', 'begin_const'), + ('begin_const', 'begin_data'), + ('begin_data', 'strided_slice', {'in': 1}), + ('end_const_data', 'end_const'), + ('end_const', 'end_data'), + ('end_data', 'strided_slice', {'in': 2}), + ('stride_const_data', 'stride_const'), + ('stride_const', 'stride_data'), + ('stride_data', 'strided_slice', {'in': 3}), + ('strided_slice_data', 'interpolate', {'in': 1}), + ('scales_const_data', 'scales_const'), + ('scales_const', 'scales_data'), + ('scales_data', 'interpolate', {'in': 2}), + ('axes_const_data', 'axes_const'), + ('axes_const', 'axes_data'), + ('axes_data', 'interpolate', {'in': 3}), + ('interpolate', 'interpolate_data'), + ('interpolate_data', 'result') + ] + + return build_graph(nodes_attrs, edges) + + +def spatial_dimensions(shape): + rank = len(shape) + if rank >= 4: + return np.arange(2, rank) + elif rank in [1, 2]: + return np.arange(0, rank) + else: + return np.arange(1, rank) + + +def convert_onnx_mode(mode: str) -> str: + return {'nearest': 'nearest', 'linear': 'linear_onnx', 'cubic': 'cubic'}[mode] diff --git a/tests/layer_tests/onnx_tests/test_roi_align.py b/tests/layer_tests/onnx_tests/test_roi_align.py new file mode 100644 index 00000000000000..b7b89dd05b993d --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_roi_align.py @@ -0,0 +1,109 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestROIAlign(OnnxRuntimeLayerTest): + def create_net(self, input_shape, rois_shape, indices_shape, output_shape, + pooled_h, pooled_w, mode, sampling_ratio, spatial_scale, ir_version): + """ + ONNX net IR net + + Input->ROIAlign->Output => Parameter->ROIAlign->Result + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, input_shape) + rois = helper.make_tensor_value_info('rois', TensorProto.FLOAT, rois_shape) + indices = helper.make_tensor_value_info('indices', TensorProto.FLOAT, indices_shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + node_def = onnx.helper.make_node( + 'ROIAlign', + inputs=['input', 'rois', 'indices'], + outputs=['output'], + **{'output_height': pooled_h, 'output_width': pooled_w, 'mode': mode, + 'sampling_ratio': sampling_ratio, 'spatial_scale': spatial_scale}, + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input, rois, indices], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + # comparison in these tests starts from input node, as we have 3 of them IREngine gets confused + # and takes the first input node in inputs list sorted by lexicographical order + '1_input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': input_shape, 'kind': 'data'}, + + '2_rois': {'kind': 'op', 'type': 'Parameter'}, + 'rois_data': {'shape': rois_shape, 'kind': 'data'}, + + '3_indices': {'kind': 'op', 'type': 'Parameter'}, + 'indices_data': {'shape': indices_shape, 'kind': 'data'}, + + 'node': {'kind': 'op', 'type': 'ROIAlign', 'pooled_h': pooled_h, 'pooled_w': pooled_w, + 'mode': mode, 'sampling_ratio': sampling_ratio, 'spatial_scale': spatial_scale}, + 'node_data': {'shape': output_shape, 'kind': 'data'}, + + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [ + ('1_input', 'input_data'), + ('input_data', 'node', {'in': 0}), + ('2_rois', 'rois_data'), + ('rois_data', 'node', {'in': 1}), + ('3_indices', 'indices_data'), + ('indices_data', 'node', {'in': 2}), + + ('node', 'node_data'), + ('node_data', 'result') + ]) + return onnx_net, ref_net + + test_data = [ + dict(input_shape=[1, 256, 200, 272], rois_shape=[1000, 4], indices_shape=[1000], + pooled_h=7, pooled_w=7, mode="avg", sampling_ratio=2, spatial_scale=0.25, + output_shape=[1000, 256, 7, 7]), + dict(input_shape=[7, 256, 200, 200], rois_shape=[1000, 4], indices_shape=[1000], + pooled_h=6, pooled_w=6, mode="max", sampling_ratio=2, spatial_scale=16.0, + output_shape=[1000, 256, 6, 6]), + dict(input_shape=[7, 256, 200, 200], rois_shape=[1000, 4], indices_shape=[1000], + pooled_h=5, pooled_w=6, mode="max", sampling_ratio=2, spatial_scale=16.0, + output_shape=[1000, 256, 5, 6]), + + ] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_roi_align(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_scale.py b/tests/layer_tests/onnx_tests/test_scale.py new file mode 100644 index 00000000000000..a624a19596b317 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_scale.py @@ -0,0 +1,144 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.onnx_layer_test_class import Caffe2OnnxLayerTest + + +class TestScale(Caffe2OnnxLayerTest): + def create_net(self, shape, scale, ir_version): + """ + ONNX net IR net + + Input->Scale->Output => Input->Power + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + node_def = onnx.helper.make_node( + 'Scale', + inputs=['input'], + outputs=['output'], + scale=scale + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + + return onnx_net, ref_net + + def create_net_const(self, shape, scale, precision, ir_version): + """ + ONNX net IR net + + Input->Concat(+scaled const)->Output => Input->Concat(+const) + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + import numpy as np + + concat_axis = 0 + output_shape = shape.copy() + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + constant = np.random.randint(-127, 127, shape).astype(np.float) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + node_def = onnx.helper.make_node( + 'Scale', + inputs=['const1'], + outputs=['scale'], + scale=scale + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'scale'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + ir_const = constant.flatten() * scale + if precision == 'FP16': + ir_const = ir_const.astype(np.float16) + + ref_net = None + + return onnx_net, ref_net + + test_data = [dict(shape=[10, 12], scale=0.1), + dict(shape=[8, 10, 12], scale=0.9), + dict(shape=[6, 8, 10, 12], scale=1.5), + dict(shape=[4, 6, 8, 10, 12], scale=4.5)] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_scale(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_scale_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_scatter.py b/tests/layer_tests/onnx_tests/test_scatter.py new file mode 100644 index 00000000000000..eda9fc29dccdfb --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_scatter.py @@ -0,0 +1,125 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import Caffe2OnnxLayerTest +from unit_tests.utils.graph import build_graph + + +class TestScatters(Caffe2OnnxLayerTest): + op = None + + def create_net(self, input_shape, indices_shape, updates_shape, output_shape, + axis, ir_version): + """ + ONNX net IR net + + Input->Scatter->Output => Parameter->ScatterElementsUpdate->Result + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + data = helper.make_tensor_value_info('data', TensorProto.FLOAT, input_shape) + indices = helper.make_tensor_value_info('indices', TensorProto.INT64, indices_shape) + updates = helper.make_tensor_value_info('updates', TensorProto.FLOAT, indices_shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + params = {'axis': axis} if axis is not None else {} + node_def = onnx.helper.make_node( + self.op, + inputs=['data', 'indices', 'updates'], + outputs=['output'], + **params, + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [data, indices, updates], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + # comparison in these tests starts from input node, as we have 3 of them IREngine gets confused + # and takes the first input node in inputs list sorted by lexicographical order + '1_input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': input_shape, 'kind': 'data'}, + + '2_indices': {'kind': 'op', 'type': 'Parameter'}, + 'indices_data': {'shape': indices_shape, 'kind': 'data'}, + + '3_updates': {'kind': 'op', 'type': 'Parameter'}, + 'updates_data': {'shape': updates_shape, 'kind': 'data'}, + + 'const_indata': {'kind': 'data', 'value': np.int64(axis) if axis is not None else np.int64(0)}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'kind': 'data'}, + + 'node': {'kind': 'op', 'type': 'ScatterElementsUpdate'}, + 'node_data': {'shape': output_shape, 'kind': 'data'}, + + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [ + ('1_input', 'input_data'), + ('input_data', 'node', {'in': 0}), + ('2_indices', 'indices_data'), + ('indices_data', 'node', {'in': 1}), + ('3_updates', 'updates_data'), + ('updates_data', 'node', {'in': 2}), + ('const_indata', 'const'), + ('const', 'const_data'), + ('const_data', 'node', {'in': 3}), + + ('node', 'node_data'), + ('node_data', 'result') + ]) + return onnx_net, ref_net + + +test_data = [ + dict(input_shape=[1, 5], indices_shape=[1, 2], updates_shape=[1, 2], + axis=1, output_shape=[1, 5]), + dict(input_shape=[1, 256, 200, 272], indices_shape=[1, 256, 200, 272], updates_shape=[1, 256, 200, 272], + axis=None, output_shape=[1, 256, 200, 272])] + + +class TestScatter(TestScatters): + op = 'Scatter' + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_scatter(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + +class TestScatterElements(TestScatters): + op = 'ScatterElements' + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_scatter_elements(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_sigmoid.py b/tests/layer_tests/onnx_tests/test_sigmoid.py new file mode 100644 index 00000000000000..bf0c517f68bee3 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_sigmoid.py @@ -0,0 +1,196 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestSigmoid(OnnxRuntimeLayerTest): + def _prepare_input(self, inputs_dict): + for input in inputs_dict.keys(): + inputs_dict[input] = np.random.randn(*inputs_dict[input]).astype(np.float32) + return inputs_dict + + def create_net(self, shape, ir_version): + """ + ONNX net IR net + + Input->Sigmoid->Output => Input->sigmoid + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + node_def = onnx.helper.make_node( + 'Sigmoid', + inputs=['input'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'Sigmoid'}, + 'node_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result') + ]) + + return onnx_net, ref_net + + def create_net_const(self, shape, precision, ir_version): + """ + ONNX net IR net + + Input->Concat(+sigmoid const)->Output => Input->Concat(+const) + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + import numpy as np + + concat_axis = 0 + output_shape = shape.copy() + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + const_number = np.prod(shape) + constant = np.random.randint(-127, 127, const_number).astype(np.float) + constant = np.reshape(constant, shape) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + node_def = onnx.helper.make_node( + 'Sigmoid', + inputs=['const1'], + outputs=['sigmoid1'] + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'sigmoid1'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + constant = 1.0 / (1.0 + np.exp(np.negative(constant))) + if precision == 'FP16': + constant = constant.astype(np.float16) + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': constant.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': shape, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result') + ]) + + return onnx_net, ref_net + + test_data_precommit = [dict(shape=[2, 4, 6, 8, 10])] + + test_data = [dict(shape=[10, 12]), + dict(shape=[8, 10, 12]), + dict(shape=[6, 8, 10, 12]), + dict(shape=[4, 6, 8, 10, 12])] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_sigmoid_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_sigmoid(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_sigmoid_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_sign.py b/tests/layer_tests/onnx_tests/test_sign.py new file mode 100644 index 00000000000000..90794322561f1a --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_sign.py @@ -0,0 +1,176 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestSign(OnnxRuntimeLayerTest): + def create_net(self, shape, ir_version): + """ + ONNX net IR net + + Input->Sign->Output => Input->Sign + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + node_def = onnx.helper.make_node( + 'Sign', + inputs=['input'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'Sign'}, + 'node_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result') + ]) + + return onnx_net, ref_net + + def create_net_const(self, shape, precision, ir_version): + """ + ONNX net IR net + + Input->Concat(+sign const)->Output => Input->Concat(+const) + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + import numpy as np + + concat_axis = 0 + output_shape = shape.copy() + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + constant = np.random.randn(*shape).astype(np.float) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + node_def = onnx.helper.make_node( + 'Sign', + inputs=['const1'], + outputs=['sign'] + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'sign'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + constant = np.sign(constant) + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': constant.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': shape, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result') + ]) + + return onnx_net, ref_net + + test_data = [dict(shape=[12]), + dict(shape=[10, 12]), + dict(shape=[8, 10, 12]), + dict(shape=[6, 8, 10, 12]), + dict(shape=[4, 6, 8, 10, 12])] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_sign(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_sign_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_slice.py b/tests/layer_tests/onnx_tests/test_slice.py new file mode 100644 index 00000000000000..28b1786b5c27bd --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_slice.py @@ -0,0 +1,399 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.onnx_layer_test_class import OnnxRuntimeLayerTest + + +class TestSlice(OnnxRuntimeLayerTest): + def create_net(self, shape, axes, ends, starts, ir_version, opset=6, steps=None): + """ + ONNX net IR net + + Input->Slice->Output => Input->Crop + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + # calculate output shape + test_arr = np.zeros(shape) + slice_idx = [None] * len(shape) + for i, axis in enumerate(axes): + slice_idx[axis] = slice(starts[i], ends[i], steps[i] if steps is not None else 1) + for axis, s in enumerate(slice_idx): + if s is None: + slice_idx[axis] = slice(0, shape[axis], 1) + test_arr = test_arr[tuple(slice_idx)] + + output_shape = list(test_arr.shape) + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + nodes = list() + if opset < 10: + node_def = onnx.helper.make_node( + 'Slice', + inputs=['input'], + outputs=['slice'], + starts=starts, + ends=ends, + axes=axes + ) + nodes.append(node_def) + else: + node_starts_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['starts'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.INT64, + dims=[len(starts)], + vals=starts + ) + ) + node_ends_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['ends'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.INT64, + dims=[len(ends)], + vals=ends + ) + ) + node_axes_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['axes'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.INT64, + dims=[len(axes)], + vals=axes + ) + ) + inputs = ['input', 'starts', 'ends', 'axes'] + if steps: + node_steps_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['steps'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.INT64, + dims=[len(steps)], + vals=steps + ) + ) + nodes.append(node_steps_def) + inputs.append('steps') + + node_def = onnx.helper.make_node( + 'Slice', + inputs=inputs, + outputs=['slice'] + ) + nodes.extend([node_starts_def, node_ends_def, node_axes_def, node_def]) + + elu_def = onnx.helper.make_node( + 'Elu', + inputs=['slice'], + outputs=['output'] + ) + nodes.append(elu_def) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + nodes, + 'test_model', + [input], + [output] + ) + + # Create the model (ModelProto) + args = dict(producer_name='test_model') + if opset: + args['opset_imports'] = [helper.make_opsetid("", opset)] + onnx_net = helper.make_model(graph_def, **args) + + # + # Create reference IR net + # + + ref_net = None + + return onnx_net, ref_net + + def create_net_const(self, shape, axes, ends, starts, ir_version, opset=6, steps=None): + """ + ONNX net IR net + + Input->Concat(+sliced const)->Output => Input->Concat(+const) + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + # calculate output shape + constant = np.random.randint(-127, 127, shape).astype(np.float) + + slice_idx = [None] * len(shape) + for i, axis in enumerate(axes): + slice_idx[axis] = slice(starts[i], ends[i], steps[i] if steps is not None else 1) + + for axis, s in enumerate(slice_idx): + if s is None: + slice_idx[axis] = slice(0, shape[axis], 1) + + constant_after = constant[tuple(slice_idx)] + + output_shape = list(constant_after.shape) + + concat_axis = 0 + concat_output_shape = output_shape.copy() + concat_output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, output_shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, concat_output_shape) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=shape, + vals=constant.flatten(), + ), + ) + + nodes = [node_const_def] + if opset < 10: + node_def = onnx.helper.make_node( + 'Slice', + inputs=['const1'], + outputs=['slice'], + starts=starts, + ends=ends, + axes=axes + ) + nodes.append(node_def) + else: + node_starts_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['starts'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.INT64, + dims=[len(starts)], + vals=starts + ) + ) + node_ends_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['ends'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.INT64, + dims=[len(ends)], + vals=ends + ) + ) + node_axes_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['axes'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.INT64, + dims=[len(axes)], + vals=axes + ) + ) + + inputs = ['const1', 'starts', 'ends', 'axes'] + if steps: + node_steps_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['steps'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.INT64, + dims=[len(steps)], + vals=steps + ) + ) + nodes.append(node_steps_def) + inputs.append('steps') + + node_def = onnx.helper.make_node( + 'Slice', + inputs=inputs, + outputs=['slice'] + ) + nodes.extend([node_starts_def, node_ends_def, node_axes_def, node_def]) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'slice'], + outputs=['output'], + axis=concat_axis + ) + nodes.append(node_concat_def) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + nodes, + 'test_reshape_model', + [input], + [output], + ) + + # Create the model (ModelProto) + args = dict(producer_name='test_model') + if opset: + args['opset_imports'] = [helper.make_opsetid("", opset)] + onnx_net = helper.make_model(graph_def, **args) + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + return onnx_net, ref_net + + test_data_no_steps = [ + dict(shape=[10, 12], axes=[0], starts=[1], ends=[9]), + dict(shape=[10, 12], axes=[1], starts=[1], ends=[11]), + dict(shape=[10, 12], axes=[0, 1], starts=[1, 1], ends=[9, 11]), + dict(shape=[8, 10, 12], axes=[0], starts=[1], ends=[7]), + dict(shape=[8, 10, 12], axes=[1], starts=[1], ends=[9]), + dict(shape=[8, 10, 12], axes=[2], starts=[1], ends=[11]), + dict(shape=[8, 10, 12], axes=[0, 1], starts=[1, 1], ends=[7, 9]), + dict(shape=[8, 10, 12], axes=[1, 2], starts=[1, 1], ends=[9, 11]), + dict(shape=[8, 10, 12], axes=[0, 2], starts=[1, 1], ends=[7, 11]), + dict(shape=[8, 10, 12], axes=[0, 1, 2], starts=[1, 1, 1], ends=[7, 9, 11]), + dict(shape=[6, 8, 10, 12], axes=[0], starts=[1], ends=[5]), + dict(shape=[6, 8, 10, 12], axes=[1], starts=[1], ends=[7]), + dict(shape=[6, 8, 10, 12], axes=[2], starts=[1], ends=[9]), + dict(shape=[6, 8, 10, 12], axes=[3], starts=[1], ends=[11]), + dict(shape=[6, 8, 10, 12], axes=[0, 1], starts=[1, 1], ends=[5, 7]), + dict(shape=[6, 8, 10, 12], axes=[1, 2], starts=[1, 1], ends=[7, 9]), + dict(shape=[6, 8, 10, 12], axes=[2, 3], starts=[1, 1], ends=[9, 11]), + dict(shape=[6, 8, 10, 12], axes=[0, 2], starts=[1, 1], ends=[5, 9]), + dict(shape=[6, 8, 10, 12], axes=[0, 3], starts=[1, 1], ends=[5, 11]), + dict(shape=[6, 8, 10, 12], axes=[1, 3], starts=[1, 1], ends=[7, 11]), + dict(shape=[6, 8, 10, 12], axes=[0, 1, 2], starts=[1, 1, 1], ends=[5, 7, 9]), + dict(shape=[6, 8, 10, 12], axes=[1, 2, 3], starts=[1, 1, 1], ends=[7, 9, 11]), + dict(shape=[6, 8, 10, 12], axes=[0, 2, 3], starts=[1, 1, 1], ends=[5, 9, 11]), + dict(shape=[6, 8, 10, 12], axes=[0, 1, 3], starts=[1, 1, 1], ends=[5, 7, 11]), + dict(shape=[6, 8, 10, 12], axes=[0, 1, 2, 3], starts=[1, 1, 1, 1], ends=[5, 7, 9, 11]), + dict(shape=[4, 6, 8, 10, 12], axes=[0], starts=[1], ends=[3]), + dict(shape=[4, 6, 8, 10, 12], axes=[1], starts=[1], ends=[5]), + dict(shape=[4, 6, 8, 10, 12], axes=[2], starts=[1], ends=[7]), + dict(shape=[4, 6, 8, 10, 12], axes=[3], starts=[1], ends=[9]), + dict(shape=[4, 6, 8, 10, 12], axes=[4], starts=[1], ends=[11]), + dict(shape=[4, 6, 8, 10, 12], axes=[0, 1], starts=[1, 1], ends=[3, 5]), + dict(shape=[4, 6, 8, 10, 12], axes=[2, 3], starts=[1, 1], ends=[7, 9]), + dict(shape=[4, 6, 8, 10, 12], axes=[3, 4], starts=[1, 1], ends=[9, 11]), + dict(shape=[4, 6, 8, 10, 12], axes=[0, 1, 2], starts=[1, 1, 1], ends=[3, 5, 7]), + dict(shape=[4, 6, 8, 10, 12], axes=[1, 2, 3], starts=[1, 1, 1], ends=[5, 7, 9]), + dict(shape=[4, 6, 8, 10, 12], axes=[2, 3, 4], starts=[1, 1, 1], ends=[7, 9, 11]), + dict(shape=[4, 6, 8, 10, 12], axes=[0, 1, 2, 3], starts=[1, 1, 1, 1], ends=[3, 5, 7, 9]), + dict(shape=[4, 6, 8, 10, 12], axes=[1, 2, 3, 4], starts=[1, 1, 1, 1], ends=[5, 7, 9, 11]), + dict(shape=[4, 6, 8, 10, 12], axes=[0, 1, 2, 3, 4], starts=[1, 1, 1, 1, 1], ends=[3, 5, 7, 9, 11]), + ] + + test_data_with_steps = [ + dict(shape=[10, 12], axes=[0, 1], starts=[1, 1], ends=[9, 11], steps=[2, 2]), + dict(shape=[10, 12], axes=[0, 1], starts=[9, 11], ends=[1, 1], steps=[-1, -1]), + dict(shape=[10, 12], axes=[0], starts=[-1], ends=[-9999], steps=[-1]), + dict(shape=[10, 12], axes=[1], starts=[-1], ends=[-9999], steps=[-1]), + dict(shape=[10, 12], axes=[0, 1], starts=[9, 11], ends=[1, 1], steps=[-2, -2]), + dict(shape=[8, 10, 12], axes=[0, 1, 2], starts=[1, 1, 1], ends=[7, 9, 11], steps=[2, 2, 2]), + dict(shape=[8, 10, 12], axes=[0, 1, 2], starts=[7, 9, 11], ends=[1, 1, 1], steps=[-1, -1, -1]), + dict(shape=[8, 10, 12], axes=[0], starts=[-1], ends=[-9999], steps=[-1]), + dict(shape=[8, 10, 12], axes=[1], starts=[-1], ends=[-9999], steps=[-1]), + dict(shape=[8, 10, 12], axes=[2], starts=[-1], ends=[-9999], steps=[-1]), + dict(shape=[8, 10, 12], axes=[0, 1, 2], starts=[7, 9, 11], ends=[1, 1, 1], steps=[-2, -2, -2]), + dict(shape=[6, 8, 10, 12], axes=[0, 1, 2, 3], starts=[1, 1, 1, 1], ends=[5, 7, 9, 11], steps=[2, 2, 2, 2]), + dict(shape=[6, 8, 10, 12], axes=[0, 1, 2, 3], starts=[5, 7, 9, 11], ends=[1, 1, 1, 1], steps=[-1, -1, -1, -1]), + dict(shape=[6, 8, 10, 12], axes=[0], starts=[-1], ends=[-9999], steps=[-1]), + dict(shape=[6, 8, 10, 12], axes=[1], starts=[-1], ends=[-9999], steps=[-1]), + dict(shape=[6, 8, 10, 12], axes=[2], starts=[-1], ends=[-9999], steps=[-1]), + dict(shape=[6, 8, 10, 12], axes=[3], starts=[-1], ends=[-9999], steps=[-1]), + dict(shape=[6, 8, 10, 12], axes=[0, 1, 2, 3], starts=[5, 7, 9, 11], ends=[1, 1, 1, 1], steps=[-2, -2, -2, -2]), + dict(shape=[4, 6, 8, 10, 12], axes=[0, 1, 2, 3, 4], starts=[1, 1, 1, 1, 1], ends=[3, 5, 7, 9, 11], + steps=[2, 2, 2, 2, 2]), + dict(shape=[4, 6, 8, 10, 12], axes=[0, 1, 2, 3, 4], starts=[3, 5, 7, 9, 11], ends=[1, 1, 1, 1, 1], + steps=[-1, -1, -1, -1, -1]), + dict(shape=[4, 6, 8, 10, 12], axes=[0], starts=[-1], ends=[-9999], steps=[-1]), + dict(shape=[4, 6, 8, 10, 12], axes=[1], starts=[-1], ends=[-9999], steps=[-1]), + dict(shape=[4, 6, 8, 10, 12], axes=[2], starts=[-1], ends=[-9999], steps=[-1]), + dict(shape=[4, 6, 8, 10, 12], axes=[3], starts=[-1], ends=[-9999], steps=[-1]), + dict(shape=[4, 6, 8, 10, 12], axes=[4], starts=[-1], ends=[-9999], steps=[-1]), + dict(shape=[4, 6, 8, 10, 12], axes=[0, 1, 2, 3, 4], starts=[3, 5, 7, 9, 11], ends=[1, 1, 1, 1, 1], + steps=[-2, -2, -2, -2, -2]), + ] + + @pytest.mark.parametrize("params", test_data_no_steps) + @pytest.mark.nightly + def test_slice_opset6(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, opset=6, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_no_steps) + @pytest.mark.nightly + def test_slice_const_opset6(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, opset=6, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_no_steps + test_data_with_steps) + @pytest.mark.nightly + def test_slice_opset10(self, params, ie_device, precision, ir_version, temp_dir): + self._test( + *self.create_net(**params, opset=10, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_no_steps + test_data_with_steps) + @pytest.mark.nightly + def test_slice_const_opset10(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, opset=10, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_no_steps + test_data_with_steps) + @pytest.mark.nightly + def test_slice_opset11(self, params, ie_device, precision, ir_version, temp_dir): + self._test( + *self.create_net(**params, opset=11, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_no_steps + test_data_with_steps) + @pytest.mark.nightly + def test_slice_const_opset11(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, opset=11, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_softmax.py b/tests/layer_tests/onnx_tests/test_softmax.py new file mode 100644 index 00000000000000..cf4a5d4d6cd8a6 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_softmax.py @@ -0,0 +1,167 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from mo.front.common.partial_infer.utils import int64_array +from unit_tests.utils.graph import build_graph + + +def second_input_data_of_reshape(src_shape, axis): + if axis == 0: + return [1, -1] + if axis == 1: + return [0, -1] + if axis > 1: + return [int(np.prod(int64_array(src_shape[: axis]))), -1] + return [-1, int(np.prod(int64_array(src_shape[len(src_shape) + axis: ])))] + + +def get_flatten_shape(src_shape, axis): + flatten_axis = axis if axis >= 0 else len(src_shape) + axis + if flatten_axis == 0: + fst_dim = 1 + snd_dim = int(np.prod(int64_array(src_shape))) + elif flatten_axis == 1: + fst_dim = src_shape[0] + snd_dim = int(np.prod(int64_array(src_shape[1: ]))) + else: + fst_dim = int(np.prod(int64_array(src_shape[: flatten_axis]))) + snd_dim = int(np.prod(int64_array(src_shape[flatten_axis: ]))) + return [fst_dim, snd_dim] + + +class TestSoftmax(OnnxRuntimeLayerTest): + def _prepare_input(self, inputs_dict): + for input in inputs_dict.keys(): + inputs_dict[input] = np.random.randn(*inputs_dict[input]).astype(np.float32) + return inputs_dict + + def create_net(self, shape, softmax_axis, ir_version): + """ + ONNX net IR net + + Input->Softmax->Output => Input->Reshape->SoftMax->Reshape + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + node_def = onnx.helper.make_node( + 'Softmax', + inputs=['input'], + outputs=['output'], + axis=softmax_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + + converted_shape = shape if len(shape) != 1 else shape[0] + flatten_shape = get_flatten_shape(shape, softmax_axis) + reshape_data_val = second_input_data_of_reshape(shape, softmax_axis) + + if check_ir_version(10, None, ir_version): + if len(shape) == 2 and shape == flatten_shape: + ref_nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter', 'shape': converted_shape}, + 'input_data': {'shape': shape, 'kind': 'data', 'value': None}, + 'flatten_shape_val': {'shape': int64_array(reshape_data_val).shape, + 'kind': 'data', + 'value': int64_array(reshape_data_val)}, + 'flatten_shape': {'type': 'Const', 'kind': 'op', 'shape': 2}, + 'flatten_shape_data': {'shape': int64_array([2]), 'kind': 'data', 'value': None}, + 'reshape': {'kind': 'op', 'type': 'Reshape'}, + 'reshape_data': {'kind': 'data', 'shape': flatten_shape, 'value': None}, + 'softmax': {'type': 'SoftMax', 'kind': 'op', 'axis': 1}, + 'softmax_data': {'shape': flatten_shape, 'kind': 'data', 'value': None}, + 'result': {'kind': 'op', 'type': 'Result'}, + } + + ref_edges = [ + ('input', 'input_data'), + ('flatten_shape_val', 'flatten_shape'), + ('flatten_shape', 'flatten_shape_data'), + ('flatten_shape_data', 'reshape', {'in': 1}), + ('input_data', 'reshape', {'in': 0}), + ('reshape', 'reshape_data'), + ('reshape_data', 'softmax'), + ('softmax', 'softmax_data'), + ('softmax_data', 'result'), + ] + else: + ref_nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter', 'shape': converted_shape}, + 'input_data': {'shape': shape, 'kind': 'data', 'value': None}, + 'flatten_shape_val': {'shape': int64_array(reshape_data_val).shape, + 'kind': 'data', + 'value': int64_array(reshape_data_val)}, + 'flatten_shape': {'type': 'Const', 'kind': 'op', 'shape': 2}, + 'flatten_shape_data': {'shape': int64_array([2]), 'kind': 'data', 'value': None}, + 'reshape': {'kind': 'op', 'type': 'Reshape'}, + 'reshape_data': {'kind': 'data', 'shape': flatten_shape, 'value': None}, + 'softmax': {'type': 'SoftMax', 'kind': 'op', 'axis': 1}, + 'softmax_data': {'shape': flatten_shape, 'kind': 'data', 'value': None}, + 'last_shape_val': {'shape': int64_array(shape).shape, 'kind': 'data', 'value': int64_array(shape)}, + 'last_shape': {'type': 'Const', 'kind': 'op', 'shape': len(shape)}, + 'last_shape_data': {'shape': int64_array([len(shape)]), 'kind': 'data', 'value': None}, + 'last_reshape': {'kind': 'op', 'type': 'Reshape'}, + 'last_reshape_data': {'kind': 'data', 'shape': shape, 'value': None}, + 'result': {'kind': 'op', 'type': 'Result'}, + } + + ref_edges = [ + ('input', 'input_data'), + ('flatten_shape_val', 'flatten_shape'), + ('flatten_shape', 'flatten_shape_data'), + ('flatten_shape_data', 'reshape', {'in': 1}), + ('input_data', 'reshape', {'in': 0}), + ('reshape', 'reshape_data'), + ('reshape_data', 'softmax'), + ('softmax', 'softmax_data'), + ('last_shape_val', 'last_shape'), + ('last_shape', 'last_shape_data'), + ('last_shape_data', 'last_reshape', {'in': 1}), + ('softmax_data', 'last_reshape', {'in': 0}), + ('last_reshape', 'last_reshape_data'), + ('last_reshape_data', 'result'), + ] + + ref_net = build_graph(ref_nodes_attributes, ref_edges) + + return onnx_net, ref_net + + test_data = [dict(shape=[10, 12], softmax_axis=0), + dict(shape=[10, 12], softmax_axis=1)] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_softmax(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_softplus.py b/tests/layer_tests/onnx_tests/test_softplus.py new file mode 100644 index 00000000000000..ea5b56071e0dd2 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_softplus.py @@ -0,0 +1,182 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import Caffe2OnnxLayerTest +from unit_tests.utils.graph import build_graph + + +class TestSoftplus(Caffe2OnnxLayerTest): + def create_net(self, shape, ir_version): + """ + ONNX net IR net + + Input->Softplus->Output => Input->Softplus + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + node_def = onnx.helper.make_node( + 'Softplus', + inputs=['input'], + outputs=['output'], + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'SoftPlus'}, + 'node_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result') + ]) + + return onnx_net, ref_net + + def create_net_const(self, shape, precision, ir_version): + """ + ONNX net IR net + + Input->Concat(+Softplus const)->Output => Input->Concat(+const) + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + import numpy as np + + concat_axis = 0 + output_shape = shape.copy() + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + constant = np.random.rand(*shape).astype(np.float32) * 255 + 0.5 + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + node_def = onnx.helper.make_node( + 'Softplus', + inputs=['const1'], + outputs=['Softplus1'], + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'Softplus1'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + constant = np.log(np.exp(constant) + 1.0) + if precision == 'FP16': + constant = constant.astype(np.float16) + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': constant.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': shape, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result') + ]) + + return onnx_net, ref_net + + test_data = [dict(shape=[12]), + dict(shape=[10, 12]), + dict(shape=[8, 10, 12]), + dict(shape=[6, 8, 10, 12]), + dict(shape=[4, 6, 8, 10, 12])] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_softplus(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_softplus_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_split_concat.py b/tests/layer_tests/onnx_tests/test_split_concat.py new file mode 100644 index 00000000000000..b9bac5aaf2504c --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_split_concat.py @@ -0,0 +1,307 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.onnx_layer_test_class import Caffe2OnnxLayerTest + + +test_data_3D = [ + dict(input_shape=[1, 50, 50], output_shapes=[[1, 50, 25], [1, 50, 25]], axis=2), + dict(input_shape=[2, 50, 50], output_shapes=[[2, 20, 50], [2, 15, 50], [2, 15, 50]], axis=1), + dict(input_shape=[4, 50, 50], output_shapes=[[1, 50, 50], [1, 50, 50], [1, 50, 50], [1, 50, 50]], axis=0)] + +test_data_4D = [ + dict(input_shape=[1, 32, 800, 800], output_shapes=[[1, 16, 800, 800], [1, 16, 800, 800]], axis=1), + dict(input_shape=[4, 32, 80, 80], output_shapes=[[4, 8, 80, 80], [4, 8, 80, 80], [4, 8, 80, 80], [4, 8, 80, 80]], + axis=1), + dict(input_shape=[2, 21, 80, 80], output_shapes=[[2, 7, 80, 80], [2, 7, 80, 80], [2, 7, 80, 80]], axis=1), + dict(input_shape=[3, 21, 80, 80], output_shapes=[[3, 14, 80, 80], [3, 5, 80, 80], [3, 2, 80, 80]], axis=1), + dict(input_shape=[3, 21, 80, 80], output_shapes=[[1, 21, 80, 80], [1, 21, 80, 80], [1, 21, 80, 80]], axis=0), + dict(input_shape=[3, 21, 80, 80], output_shapes=[[3, 21, 20, 80], [3, 21, 35, 80], [3, 21, 25, 80]], axis=2), + dict(input_shape=[3, 21, 80, 80], output_shapes=[[3, 21, 80, 40], [3, 21, 80, 10], [3, 21, 80, 30]], axis=3)] + +test_data_5D = [ + dict(input_shape=[1, 50, 50, 80, 60], + output_shapes=[[1, 50, 10, 80, 60], + [1, 50, 10, 80, 60], + [1, 50, 10, 80, 60], + [1, 50, 10, 80, 60], + [1, 50, 10, 80, 60]], axis=2), + dict(input_shape=[1, 50, 50, 80, 60], output_shapes=[[1, 25, 50, 80, 60], [1, 25, 50, 80, 60]], axis=1)] + + +class TestSplitConcat(Caffe2OnnxLayerTest): + # TODO Add test with default values (axis=0) + def create_split_concat_net(self, input_shape, output_shapes, axis, ir_version): + """ + ONNX net IR net + + Input->Split->Concat->Output => Input->Split->Concat + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, input_shape) + outputs, split = [], [] + for id, output_shape in enumerate(output_shapes): + helper.make_tensor_value_info('output_{}'.format(id), TensorProto.FLOAT, output_shape) + outputs.append('output_{}'.format(id)) + split.append(output_shape[axis]) + + # Output for concat + output_concat = helper.make_tensor_value_info('output_concat', TensorProto.FLOAT, input_shape) + + node_split_def = onnx.helper.make_node( + 'Split', + inputs=['input'], + outputs=outputs, + axis=axis, + split=split + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=outputs, + outputs=['output_concat'], + axis=axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_split_def, node_concat_def], + 'test_split_model', + [input], + [output_concat], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_split_model') + + # + # Create reference IR net + # Please, spesify 'type': 'Input' for inpit node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + return onnx_net, ref_net + + # TODO Add test with default values (axis=0) + def create_split_concat_net_const(self, input_shape, output_shapes, axis, ir_version): + """ + ONNX net IR net + + Input(const)->Split->Concat--->Concat->Output => Input--->Concat + Input-' Const-' + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + import numpy as np + + concat_axis = 0 + concat_output_shape = input_shape.copy() + concat_output_shape[concat_axis] *= 2 + + const_number = np.prod(input_shape) + constant = np.random.randint(-127, 127, const_number).astype(np.float) + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, input_shape) + outputs, split = [], [] + for id, output_shape in enumerate(output_shapes): + helper.make_tensor_value_info('output_{}'.format(id), TensorProto.FLOAT, output_shape) + outputs.append('output_{}'.format(id)) + split.append(output_shape[axis]) + + # Output for concat + output_concat = helper.make_tensor_value_info('output_dyn_concat', TensorProto.FLOAT, concat_output_shape) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=input_shape, + vals=constant, + ), + ) + + node_split_def = onnx.helper.make_node( + 'Split', + inputs=['const1'], + outputs=outputs, + axis=axis, + split=split + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=outputs, + outputs=['output_concat'], + axis=axis + ) + + node_dyn_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'output_concat'], + outputs=['output_dyn_concat'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_split_def, node_concat_def, node_dyn_concat_def], + 'test_split_model', + [input], + [output_concat], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_split_model') + + # + # Create reference IR net + # Please, spesify 'type': 'Input' for inpit node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + return onnx_net, ref_net + + @pytest.mark.parametrize("params", test_data_3D) + @pytest.mark.nightly + def test_split_3D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_split_concat_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + def test_split_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_split_concat_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.nightly + def test_split_5D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_split_concat_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_3D) + @pytest.mark.nightly + def test_split_3D_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test( + *self.create_split_concat_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + def test_split_4D_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test( + *self.create_split_concat_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.nightly + def test_split_5D_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test( + *self.create_split_concat_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + +class TestSplit(Caffe2OnnxLayerTest): + # TODO Add test with default values (axis=0) + def create_split_net(self, input_shape, output_shapes, axis, ir_version): + """ + ONNX net IR net + + Input->Split->Output => Input->Split + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, input_shape) + outputs, split = [], [] + for id, output_shape in enumerate(output_shapes): + out = helper.make_tensor_value_info('output_{}'.format(id), TensorProto.FLOAT, output_shape) + outputs.append((out, 'output_{}'.format(id))) + split.append(output_shape[axis]) + + node_split_def = onnx.helper.make_node( + 'Split', + inputs=['input'], + outputs=['node_{}'.format(x[1]) for x in outputs], + axis=axis, + split=split + ) + nodes = [node_split_def] + + for x in outputs: + nodes.append(onnx.helper.make_node( + 'Elu', + inputs=['node_{}'.format(x[1])], + outputs=[x[1]] + )) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + nodes, + 'test_split_model', + [input], + [x[0] for x in outputs], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_split_model') + + # + # Create reference IR net + # Please, spesify 'type': 'Input' for inpit node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + return onnx_net, ref_net + + @pytest.mark.parametrize("params", test_data_3D) + @pytest.mark.nightly + def test_split_3D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_split_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + def test_split_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_split_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.nightly + def test_split_5D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_split_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_sqrt.py b/tests/layer_tests/onnx_tests/test_sqrt.py new file mode 100644 index 00000000000000..09b6df3b481bb4 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_sqrt.py @@ -0,0 +1,187 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestSqrt(OnnxRuntimeLayerTest): + def _prepare_input(self, inputs_dict): + for input in inputs_dict.keys(): + inputs_dict[input] = np.random.randint(0, 255, inputs_dict[input]).astype(np.float32) + return inputs_dict + + def create_net(self, shape, ir_version): + """ + ONNX net IR net + + Input->Sqrt->Output => Input->Power + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + node_def = onnx.helper.make_node( + 'Sqrt', + inputs=['input'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'const_indata': {'shape': None, 'kind': 'data'}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': np.ones(len(shape)), 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'Power'}, + 'node_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('const_indata', 'const'), + ('const', 'const_data'), + ('input_data', 'node'), + ('const_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result')]) + + return onnx_net, ref_net + + def create_net_const(self, shape, precision, ir_version): + """ + ONNX net IR net + + Input->Concat(+sqrt const)->Output => Input->Concat(+const) + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + concat_axis = 0 + output_shape = shape.copy() + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + constant = np.random.rand(*shape).astype(np.float) * 255 + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + node_def = onnx.helper.make_node( + 'Sqrt', + inputs=['const'], + outputs=['sqrt'] + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'sqrt'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + constant = np.sqrt(constant) + if precision == 'FP16': + constant = constant.astype(np.float16) + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': constant.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': shape, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result')]) + + return onnx_net, ref_net + + test_data = [dict(shape=[10, 12]), + dict(shape=[8, 10, 12]), + dict(shape=[6, 8, 10, 12]), + dict(shape=[4, 6, 8, 10, 12])] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_sqrt(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_sqrt_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_squeeze.py b/tests/layer_tests/onnx_tests/test_squeeze.py new file mode 100644 index 00000000000000..413d3d86ec9fff --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_squeeze.py @@ -0,0 +1,210 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.onnx_layer_test_class import Caffe2OnnxLayerTest + + +class TestSqueeze(Caffe2OnnxLayerTest): + def create_squeeze_net(self, axes, input_shape, output_shape, ir_version): + """ + ONNX net IR net + + Input->Squeeze(axes=0)->Output => Input->Reshape + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, input_shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + node_squeeze_def = onnx.helper.make_node( + 'Squeeze', + inputs=['input'], + outputs=['output'], + axes=axes + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_squeeze_def], + 'test_squeeze_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_squeeze_model') + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + return onnx_net, ref_net + + def create_squeeze_net_const(self, axes, input_shape, output_shape, ir_version): + """ + ONNX net IR net + + Input->Concat(+squeezed const)->Output => Input->Concat(+const) + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + import numpy as np + + concat_axis = 0 + concat_output_shape = output_shape.copy() + concat_output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, output_shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, concat_output_shape) + + const_number = np.prod(input_shape) + constant = np.random.randint(-127, 127, const_number).astype(np.float) + constant = np.reshape(constant, input_shape) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + node_squeeze_def = onnx.helper.make_node( + 'Squeeze', + inputs=['const1'], + outputs=['squeeze1'], + axes=axes + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'squeeze1'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_squeeze_def, node_concat_def], + 'test_squeeze_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_squeeze_model') + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + return onnx_net, ref_net + + test_data_5D = [ + dict(axes=[0], input_shape=[1, 2, 3, 10, 10], output_shape=[2, 3, 10, 10]), + dict(axes=[1], input_shape=[2, 1, 3, 10, 10], output_shape=[2, 3, 10, 10]), + dict(axes=[2], input_shape=[2, 3, 1, 10, 10], output_shape=[2, 3, 10, 10]), + dict(axes=[3], input_shape=[2, 3, 10, 1, 10], output_shape=[2, 3, 10, 10]), + dict(axes=[4], input_shape=[2, 3, 10, 10, 1], output_shape=[2, 3, 10, 10]), + dict(axes=[0, 1], input_shape=[1, 1, 3, 10, 10], output_shape=[3, 10, 10]), + dict(axes=[0, 2], input_shape=[1, 3, 1, 10, 10], output_shape=[3, 10, 10]), + dict(axes=[0, 3], input_shape=[1, 3, 10, 1, 10], output_shape=[3, 10, 10]), + dict(axes=[0, 4], input_shape=[1, 3, 10, 10, 1], output_shape=[3, 10, 10]), + dict(axes=[1, 2], input_shape=[3, 1, 1, 10, 10], output_shape=[3, 10, 10]), + dict(axes=[1, 3], input_shape=[3, 1, 10, 1, 10], output_shape=[3, 10, 10]), + dict(axes=[1, 4], input_shape=[3, 1, 10, 10, 1], output_shape=[3, 10, 10]), + dict(axes=[2, 3], input_shape=[3, 10, 1, 1, 10], output_shape=[3, 10, 10]), + dict(axes=[2, 4], input_shape=[3, 10, 1, 10, 1], output_shape=[3, 10, 10]), + dict(axes=[3, 4], input_shape=[3, 10, 10, 1, 1], output_shape=[3, 10, 10]), + dict(axes=[0, 1, 2], input_shape=[1, 1, 1, 10, 10], output_shape=[10, 10]), + dict(axes=[0, 1, 3], input_shape=[1, 1, 10, 1, 10], output_shape=[10, 10]), + dict(axes=[0, 1, 4], input_shape=[1, 1, 10, 10, 1], output_shape=[10, 10]), + dict(axes=[0, 2, 3], input_shape=[1, 10, 1, 1, 10], output_shape=[10, 10]), + dict(axes=[0, 2, 4], input_shape=[1, 10, 1, 10, 1], output_shape=[10, 10]), + dict(axes=[0, 3, 4], input_shape=[1, 10, 10, 1, 1], output_shape=[10, 10]), + dict(axes=[1, 2, 3], input_shape=[10, 1, 1, 1, 10], output_shape=[10, 10]), + dict(axes=[1, 2, 4], input_shape=[10, 1, 1, 10, 1], output_shape=[10, 10]), + dict(axes=[1, 3, 4], input_shape=[10, 1, 10, 1, 1], output_shape=[10, 10]), + dict(axes=[2, 3, 4], input_shape=[10, 10, 1, 1, 1], output_shape=[10, 10])] + + test_data_4D = [ + dict(axes=[0], input_shape=[1, 3, 10, 10], output_shape=[3, 10, 10]), + dict(axes=[1], input_shape=[3, 1, 10, 10], output_shape=[3, 10, 10]), + dict(axes=[2], input_shape=[3, 10, 1, 10], output_shape=[3, 10, 10]), + dict(axes=[3], input_shape=[3, 10, 10, 1], output_shape=[3, 10, 10]), + dict(axes=[0, 1], input_shape=[1, 1, 10, 10], output_shape=[10, 10]), + dict(axes=[0, 2], input_shape=[1, 10, 1, 10], output_shape=[10, 10]), + dict(axes=[0, 3], input_shape=[1, 10, 10, 1], output_shape=[10, 10]), + dict(axes=[1, 2], input_shape=[10, 1, 1, 10], output_shape=[10, 10]), + dict(axes=[1, 3], input_shape=[10, 1, 10, 1], output_shape=[10, 10]), + dict(axes=[2, 3], input_shape=[10, 10, 1, 1], output_shape=[10, 10])] + + test_data_3D = [ + dict(axes=[0], input_shape=[1, 10, 10], output_shape=[10, 10]), + dict(axes=[1], input_shape=[10, 1, 10], output_shape=[10, 10]), + dict(axes=[2], input_shape=[10, 10, 1], output_shape=[10, 10])] + + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.nightly + def test_squeeze_5D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_squeeze_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + def test_squeeze_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_squeeze_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_3D) + @pytest.mark.nightly + def test_squeeze_3D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_squeeze_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.nightly + def test_squeeze_const_5D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_squeeze_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + def test_squeeze_const_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_squeeze_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_3D) + @pytest.mark.nightly + def test_squeeze_const_3D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_squeeze_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_sum.py b/tests/layer_tests/onnx_tests/test_sum.py new file mode 100644 index 00000000000000..bd4896144c0a49 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_sum.py @@ -0,0 +1,322 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.onnx_layer_test_class import OnnxRuntimeLayerTest + + +class TestSum(OnnxRuntimeLayerTest): + def create_net(self, dyn_shapes, const_shapes, precision, ir_version, opset=None): + """ + ONNX net IR net + + Inputs->Sum with consts->Output => Input->Eltwise + """ + + # + # Create ONNX model + # + + from onnx import helper + from onnx import TensorProto + + inputs = list() + input_names = list() + out_shape_len = 0 + for i, shape in enumerate(dyn_shapes): + input_name = 'input{}'.format(i + 1) + inputs.append(helper.make_tensor_value_info(input_name, TensorProto.FLOAT, shape)) + input_names.append(input_name) + if len(shape) > out_shape_len: + out_shape_len = len(shape) + output_shape = shape + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + nodes = list() + consts = list() + for i, shape in enumerate(const_shapes): + const = np.random.randint(-127, 127, shape).astype(np.float) + const_name = 'const{}'.format(i + 1) + nodes.append(helper.make_node( + 'Constant', + inputs=[], + outputs=[const_name], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=const.shape, + vals=const.flatten(), + ), + )) + input_names.append(const_name) + consts.append(const) + + nodes.append(helper.make_node( + 'Sum', + inputs=input_names, + outputs=['output'] + )) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + nodes, + 'test_model', + inputs, + [output], + ) + + # Create the model (ModelProto) + args = dict(producer_name='test_model') + if opset: + args['opset_imports'] = [helper.make_opsetid("", opset)] + onnx_net = helper.make_model(graph_def, **args) + + # Create reference IR net + + ref_net = None + # Too complicated IR to generate by hand + + return onnx_net, ref_net + + def create_const_net(self, const_shapes, ir_version, opset=None): + """ + ONNX net IR net + + Inputs->Concat with Sum of consts->Output => Input->Concat with consts + """ + + # + # Create ONNX model + # + + from onnx import helper + from onnx import TensorProto + + shape_len = 0 + for shape in const_shapes: + if len(shape) > shape_len: + shape_len = len(shape) + input_shape = shape + + concat_axis = 0 + output_shape = input_shape.copy() + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, input_shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + nodes = list() + input_names = list() + consts = list() + for i, shape in enumerate(const_shapes): + const = np.random.randint(-127, 127, shape).astype(np.float) + const_name = 'const{}'.format(i + 1) + nodes.append(helper.make_node( + 'Constant', + inputs=[], + outputs=[const_name], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=const.shape, + vals=const.flatten(), + ), + )) + input_names.append(const_name) + consts.append(const) + + nodes.append(helper.make_node( + 'Sum', + inputs=input_names, + outputs=['sum'] + )) + + nodes.append(helper.make_node( + 'Concat', + inputs=['input', 'sum'], + outputs=['output'], + axis=concat_axis + )) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + nodes, + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + args = dict(producer_name='test_model') + if opset: + args['opset_imports'] = [helper.make_opsetid("", opset)] + onnx_net = helper.make_model(graph_def, **args) + + # Create reference IR net + + ref_net = None + + return onnx_net, ref_net + + test_data_precommit = [ + dict(dyn_shapes=[[4, 6, 8], [4, 6, 8], [4, 6, 8]], + const_shapes=[[4, 6, 8], [4, 6, 8], [4, 6, 8]]), + dict(dyn_shapes=[[4, 6, 8, 10, 12]], + const_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12]]), + dict(dyn_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12], [4, 6, 8, 10, 12]], + const_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12], [4, 6, 8, 10, 12]])] + + test_data = [ + # TODO: Add broadcasting tests. Note: Sum-6 doesn't support broadcasting + dict(dyn_shapes=[[4, 6]], const_shapes=[[4, 6]]), + dict(dyn_shapes=[[4, 6]], const_shapes=[[4, 6], [4, 6]]), + dict(dyn_shapes=[[4, 6]], const_shapes=[[4, 6], [4, 6], [4, 6]]), + dict(dyn_shapes=[[4, 6], [4, 6]], const_shapes=[]), + dict(dyn_shapes=[[4, 6], [4, 6]], const_shapes=[[4, 6]]), + dict(dyn_shapes=[[4, 6], [4, 6]], const_shapes=[[4, 6], [4, 6]]), + dict(dyn_shapes=[[4, 6], [4, 6]], const_shapes=[[4, 6], [4, 6], [4, 6]]), + dict(dyn_shapes=[[4, 6], [4, 6], [4, 6]], const_shapes=[]), + dict(dyn_shapes=[[4, 6], [4, 6], [4, 6]], const_shapes=[[4, 6]]), + dict(dyn_shapes=[[4, 6], [4, 6], [4, 6]], const_shapes=[[4, 6], [4, 6]]), + dict(dyn_shapes=[[4, 6], [4, 6], [4, 6]], const_shapes=[[4, 6], [4, 6], [4, 6]]), + dict(dyn_shapes=[[4, 6, 8]], const_shapes=[[4, 6, 8]]), + dict(dyn_shapes=[[4, 6, 8]], const_shapes=[[4, 6, 8], [4, 6, 8]]), + dict(dyn_shapes=[[4, 6, 8]], const_shapes=[[4, 6, 8], [4, 6, 8], [4, 6, 8]]), + dict(dyn_shapes=[[4, 6, 8], [4, 6, 8]], const_shapes=[]), + dict(dyn_shapes=[[4, 6, 8], [4, 6, 8]], const_shapes=[[4, 6, 8]]), + dict(dyn_shapes=[[4, 6, 8], [4, 6, 8]], const_shapes=[[4, 6, 8], [4, 6, 8]]), + dict(dyn_shapes=[[4, 6, 8], [4, 6, 8]], const_shapes=[[4, 6, 8], [4, 6, 8], [4, 6, 8]]), + dict(dyn_shapes=[[4, 6, 8], [4, 6, 8], [4, 6, 8]], const_shapes=[]), + dict(dyn_shapes=[[4, 6, 8], [4, 6, 8], [4, 6, 8]], const_shapes=[[4, 6, 8]]), + dict(dyn_shapes=[[4, 6, 8], [4, 6, 8], [4, 6, 8]], const_shapes=[[4, 6, 8], [4, 6, 8]]), + dict(dyn_shapes=[[4, 6, 8], [4, 6, 8], [4, 6, 8]], const_shapes=[[4, 6, 8], [4, 6, 8], [4, 6, 8]]), + dict(dyn_shapes=[[4, 6, 8, 10]], const_shapes=[[4, 6, 8, 10]]), + dict(dyn_shapes=[[4, 6, 8, 10]], const_shapes=[[4, 6, 8, 10], [4, 6, 8, 10]]), + dict(dyn_shapes=[[4, 6, 8, 10]], const_shapes=[[4, 6, 8, 10], [4, 6, 8, 10], [4, 6, 8, 10]]), + dict(dyn_shapes=[[4, 6, 8, 10], [4, 6, 8, 10]], const_shapes=[]), + dict(dyn_shapes=[[4, 6, 8, 10], [4, 6, 8, 10]], const_shapes=[[4, 6, 8, 10]]), + dict(dyn_shapes=[[4, 6, 8, 10], [4, 6, 8, 10]], const_shapes=[[4, 6, 8, 10], [4, 6, 8, 10]]), + dict(dyn_shapes=[[4, 6, 8, 10], [4, 6, 8, 10]], const_shapes=[[4, 6, 8, 10], [4, 6, 8, 10], [4, 6, 8, 10]]), + dict(dyn_shapes=[[4, 6, 8, 10], [4, 6, 8, 10], [4, 6, 8, 10]], const_shapes=[]), + dict(dyn_shapes=[[4, 6, 8, 10], [4, 6, 8, 10], [4, 6, 8, 10]], const_shapes=[[4, 6, 8, 10]]), + dict(dyn_shapes=[[4, 6, 8, 10], [4, 6, 8, 10], [4, 6, 8, 10]], const_shapes=[[4, 6, 8, 10], [4, 6, 8, 10]]), + dict(dyn_shapes=[[4, 6, 8, 10], [4, 6, 8, 10], [4, 6, 8, 10]], + const_shapes=[[4, 6, 8, 10], [4, 6, 8, 10], [4, 6, 8, 10]]), + dict(dyn_shapes=[[4, 6, 8, 10, 12]], const_shapes=[[4, 6, 8, 10, 12]]), + dict(dyn_shapes=[[4, 6, 8, 10, 12]], const_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12]]), + dict(dyn_shapes=[[4, 6, 8, 10, 12]], const_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12], [4, 6, 8, 10, 12]]), + dict(dyn_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12]], const_shapes=[]), + dict(dyn_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12]], const_shapes=[[4, 6, 8, 10, 12]]), + dict(dyn_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12]], const_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12]]), + dict(dyn_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12]], + const_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12], [4, 6, 8, 10, 12]]), + dict(dyn_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12], [4, 6, 8, 10, 12]], const_shapes=[]), + dict(dyn_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12], [4, 6, 8, 10, 12]], const_shapes=[[4, 6, 8, 10, 12]]), + dict(dyn_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12], [4, 6, 8, 10, 12]], + const_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12]]), + dict(dyn_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12], [4, 6, 8, 10, 12]], + const_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12], [4, 6, 8, 10, 12]])] + + const_test_data_precommit = [ + dict(const_shapes=[[4, 6, 8, 10], [4, 6, 8, 10], [4, 6, 8, 10]]), + dict(const_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12], [4, 6, 8, 10, 12], [4, 6, 8, 10, 12]]) + ] + + const_test_data = [ + dict(const_shapes=[[4, 6], [4, 6]]), + dict(const_shapes=[[4, 6], [4, 6], [4, 6]]), + dict(const_shapes=[[4, 6], [4, 6], [4, 6], [4, 6]]), + dict(const_shapes=[[4, 6, 8], [4, 6, 8]]), + dict(const_shapes=[[4, 6, 8], [4, 6, 8], [4, 6, 8]]), + dict(const_shapes=[[4, 6, 8], [4, 6, 8], [4, 6, 8], [4, 6, 8]]), + dict(const_shapes=[[4, 6, 8, 10], [4, 6, 8, 10]]), + dict(const_shapes=[[4, 6, 8, 10], [4, 6, 8, 10], [4, 6, 8, 10]]), + dict(const_shapes=[[4, 6, 8, 10], [4, 6, 8, 10], [4, 6, 8, 10], [4, 6, 8, 10]]), + dict(const_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12]]), + dict(const_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12], [4, 6, 8, 10, 12]]), + dict(const_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12], [4, 6, 8, 10, 12], [4, 6, 8, 10, 12]]) + ] + + const_test_data_broadcasting_precommit = [ + dict(const_shapes=[[4, 6, 8, 10], [10], [10], [10]]), + dict(const_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12], [12]]), + dict(const_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12], [4, 6, 8, 10, 12], [12]]) + ] + + const_test_data_broadcasting = [ + dict(const_shapes=[[4, 6], [6]]), + dict(const_shapes=[[4, 6], [6], [6]]), + dict(const_shapes=[[4, 6], [4, 6], [6]]), + dict(const_shapes=[[4, 6], [6], [6], [6]]), + dict(const_shapes=[[4, 6], [4, 6], [6], [6]]), + dict(const_shapes=[[4, 6], [4, 6], [4, 6], [6]]), + dict(const_shapes=[[4, 6, 8], [8]]), + dict(const_shapes=[[4, 6, 8], [8], [8]]), + dict(const_shapes=[[4, 6, 8], [4, 6, 8], [8]]), + dict(const_shapes=[[4, 6, 8], [8], [8], [8]]), + dict(const_shapes=[[4, 6, 8], [4, 6, 8], [8], [8]]), + dict(const_shapes=[[4, 6, 8], [4, 6, 8], [4, 6, 8], [8]]), + dict(const_shapes=[[4, 6, 8, 10], [10]]), + dict(const_shapes=[[4, 6, 8, 10], [10], [10]]), + dict(const_shapes=[[4, 6, 8, 10], [4, 6, 8, 10], [10]]), + dict(const_shapes=[[4, 6, 8, 10], [10], [10], [10]]), + dict(const_shapes=[[4, 6, 8, 10], [4, 6, 8, 10], [10], [10]]), + dict(const_shapes=[[4, 6, 8, 10], [4, 6, 8, 10], [4, 6, 8, 10], [10]]), + dict(const_shapes=[[4, 6, 8, 10, 12], [12]]), + dict(const_shapes=[[4, 6, 8, 10, 12], [12], [12]]), + dict(const_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12], [12]]), + dict(const_shapes=[[4, 6, 8, 10, 12], [12], [12], [12]]), + dict(const_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12], [12], [12]]), + dict(const_shapes=[[4, 6, 8, 10, 12], [4, 6, 8, 10, 12], [4, 6, 8, 10, 12], [12]]) + ] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_sum_opset6(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, precision=precision, opset=6, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_sum_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, precision=precision, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_sum(self, params, ie_device, precision, ir_version, temp_dir): + self._test( + *self.create_net(**params, precision=precision, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", const_test_data) + @pytest.mark.nightly + def test_sum_const_opset6(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_const_net(**params, opset=6, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", const_test_data_precommit) + @pytest.mark.precommit + def test_sum_const_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_const_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", const_test_data) + @pytest.mark.nightly + def test_sum_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_const_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", const_test_data_broadcasting_precommit) + @pytest.mark.precommit + def test_sum_const_broadcasting_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_const_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", const_test_data_broadcasting) + @pytest.mark.nightly + def test_sum_const_broadcasting(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_const_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_topk.py b/tests/layer_tests/onnx_tests/test_topk.py new file mode 100644 index 00000000000000..863bf95352eff9 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_topk.py @@ -0,0 +1,167 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.onnx_layer_test_class import OnnxRuntimeLayerTest + + +class TestTopK(OnnxRuntimeLayerTest): + def create_net(self, shape, k, axis, ir_version, largest=None, sorted=None, opset=None): + """ + ONNX net IR net + + Input->TopK->Output => Input->TopK + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + output_shape = shape.copy() + if axis is not None: + output_shape[axis] = k + else: + output_shape[-1] = k + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + values = helper.make_tensor_value_info('cvalues', TensorProto.FLOAT, output_shape) + indices = helper.make_tensor_value_info('cindices', TensorProto.INT64, output_shape) + + const1 = np.ones(output_shape).astype(np.int64) + const2 = np.ones(output_shape).astype(np.float) + + nodes = list() + inputs = ['input'] + if opset > 9: + node_k_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['k'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.INT64, + dims=[1], + vals=[k], + ), + ) + nodes.append(node_k_def) + inputs.append('k') + + args = dict() + if opset < 10: + args['k'] = k + if axis is not None: + args['axis'] = axis + if sorted is not None: + args['sorted'] = sorted + if largest is not None: + args['largest'] = largest + + node_def = onnx.helper.make_node( + 'TopK', + inputs=inputs, + outputs=['values', 'indices'], + **args + ) + + node_const1_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor2', + data_type=TensorProto.INT64, + dims=const1.shape, + vals=const1.flatten(), + ), + ) + + node_add1_def = onnx.helper.make_node( + 'Add', + inputs=['indices', 'const1'], + outputs=['cindices'] + ) + + node_const2_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const2'], + value=helper.make_tensor( + name='const_tensor3', + data_type=TensorProto.FLOAT, + dims=const2.shape, + vals=const2.flatten(), + ), + ) + + node_add2_def = onnx.helper.make_node( + 'Add', + inputs=['values', 'const2'], + outputs=['cvalues'] + ) + + nodes.extend([node_def, node_const1_def, node_add1_def, node_const2_def, node_add2_def]) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + nodes, + 'test_model', + [input], + [values, indices], + ) + + # Create the model (ModelProto) + args = dict(producer_name='test_model') + if opset: + args['opset_imports'] = [helper.make_opsetid("", opset)] + onnx_net = helper.make_model(graph_def, **args) + + # + # Create reference IR net + # + + ref_net = None + + return onnx_net, ref_net + + test_data = [dict(shape=[10, 12], k=3, axis=0), + dict(shape=[10, 12], k=5, axis=1), + dict(shape=[8, 10, 12], k=3, axis=0), + dict(shape=[8, 10, 12], k=4, axis=1), + dict(shape=[8, 10, 12], k=5, axis=2), + dict(shape=[6, 8, 10, 12], k=3, axis=0), + dict(shape=[6, 8, 10, 12], k=4, axis=1), + dict(shape=[6, 8, 10, 12], k=5, axis=2), + dict(shape=[6, 8, 10, 12], k=6, axis=3), + dict(shape=[4, 6, 8, 10, 12], k=3, axis=0), + dict(shape=[4, 6, 8, 10, 12], k=4, axis=1), + dict(shape=[4, 6, 8, 10, 12], k=5, axis=2), + dict(shape=[4, 6, 8, 10, 12], k=6, axis=3), + dict(shape=[4, 6, 8, 10, 12], k=7, axis=4)] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_topk_opset6(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, opset=6, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_topk_opset10(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, opset=10, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.parametrize("largest", [1, 0, None]) + @pytest.mark.parametrize("sorted", [1, 0, None]) + @pytest.mark.nightly + def test_topk_opset11(self, params, ie_device, precision, ir_version, largest, sorted, temp_dir): + self._test(*self.create_net(**params, largest=largest, sorted=sorted, + opset=11, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_transpose.py b/tests/layer_tests/onnx_tests/test_transpose.py new file mode 100644 index 00000000000000..13e26b626c48bc --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_transpose.py @@ -0,0 +1,178 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import itertools + +import numpy as np +import pytest +from common.onnx_layer_test_class import Caffe2OnnxLayerTest + + +class TestTranspose(Caffe2OnnxLayerTest): + def create_net(self, shape, perm, ir_version): + """ + ONNX net IR net + + Input->Transpose->Sigmoid->Output => Input->Permute->sigmoid + + """ + + # + # Create ONNX model + # + + from onnx import helper + from onnx import TensorProto + + output_shape = np.transpose(np.ones(shape), perm).shape + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + args = dict() + if perm: + args['perm'] = perm + node_def = helper.make_node( + 'Transpose', + inputs=['input'], + outputs=['transpose'], + **args + ) + + sigmoid_def = helper.make_node( + 'Sigmoid', + inputs=['transpose'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def, sigmoid_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + if not perm: + perm = list(reversed(range(len(shape)))) + + return onnx_net, ref_net + + def create_net_const(self, shape, perm, ir_version): + """ + ONNX net IR net + + Input->Concat(+transposed const)->Output => Input->Concat(+const) + + """ + + # + # Create ONNX model + # + + from onnx import helper + from onnx import TensorProto + + constant = np.random.randint(-127, 127, shape).astype(np.float) + constant_transposed = np.transpose(constant, perm) + + concat_axis = 0 + input_shape = list(constant_transposed.shape) + output_shape = input_shape.copy() + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, input_shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + node_const_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + args = dict() + if perm: + args['perm'] = perm + node_def = helper.make_node( + 'Transpose', + inputs=['const1'], + outputs=['transpose'], + **args + ) + + node_concat_def = helper.make_node( + 'Concat', + inputs=['input', 'transpose'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + + ref_net = None + + return onnx_net, ref_net + + test_data_precommit = [dict(shape=[4, 6, 8, 10, 12], perm=None), + dict(shape=[8, 10, 12], perm=[2, 1, 0]), + dict(shape=[6, 8, 10, 12], perm=[0, 3, 1, 2]), + dict(shape=[4, 6, 8, 10, 12], perm=[1, 0, 4, 3, 2])] + + test_data = [dict(shape=[10, 12], perm=None), + dict(shape=[8, 10, 12], perm=None), + dict(shape=[6, 8, 10, 12], perm=None), + dict(shape=[4, 6, 8, 10, 12], perm=None)] + + for shape in [[10, 12], [8, 10, 12], [6, 8, 10, 12], [4, 6, 8, 10, 12]]: + for perm in itertools.permutations(np.arange(len(shape))): + test_data.append(dict(shape=shape, perm=list(perm))) + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_transpose_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_transpose(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.nightly + def test_transpose_const_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_transpose_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_trigonometry.py b/tests/layer_tests/onnx_tests/test_trigonometry.py new file mode 100644 index 00000000000000..6499f007a33da3 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_trigonometry.py @@ -0,0 +1,298 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestTrigonomery(OnnxRuntimeLayerTest): + def _prepare_input(self, inputs_dict): + for input in inputs_dict.keys(): + inputs_dict[input] = np.random.rand(*(inputs_dict[input])).astype(np.float32) + return inputs_dict + + def create_net(self, shape, op, ir_version): + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + assert op in ['Sin', 'Sinh', 'Asin', 'Cos', 'Cosh', 'Acos', 'Tan', 'Tanh', 'Atan'] + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + node_def = onnx.helper.make_node( + op, + inputs=['input'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'node': {'kind': 'op', 'type': op}, + 'node_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result')]) + + return onnx_net, ref_net + + def create_net_const(self, shape, op, precision, ir_version): + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + assert op in ['Sin', 'Sinh', 'Asin', 'Cos', 'Cosh', 'Acos', 'Tan', 'Tanh', 'Atan'] + + concat_axis = 0 + output_shape = shape.copy() + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + constant = np.random.rand(*shape).astype(np.float) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + node_def = onnx.helper.make_node( + op, + inputs=['const'], + outputs=['res'] + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'res'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # + # Create reference IR net + # + if op == 'Sin': + constant = np.sin(constant) + elif op == 'Sinh': + constant = np.sinh(constant) + elif op == 'Asin': + constant = np.arcsin(constant) + elif op == 'Cos': + constant = np.cos(constant) + elif op == 'Cosh': + constant = np.cosh(constant) + elif op == 'Acos': + constant = np.arccos(constant) + elif op == 'Tan': + constant = np.tan(constant) + elif op == 'Tanh': + constant = np.tanh(constant) + elif op == 'Atan': + constant = np.arctan(constant) + if precision == 'FP16': + constant = constant.astype(np.float16) + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': constant.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': shape, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result')]) + + return onnx_net, ref_net + + test_data_precommit = [dict(shape=[2, 4, 6, 8])] + + test_data = [dict(shape=[10, 12]), + dict(shape=[8, 10, 12]), + dict(shape=[6, 8, 10, 12]), + dict(shape=[4, 6, 8, 10, 12])] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_sin(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version, op='Sin'), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_sinh(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version, op='Sinh'), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_asin(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version, op='Asin'), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_cos_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version, op='Cos'), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_cos(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version, op='Cos'), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_cosh(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version, op='Cosh'), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_acos(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version, op='Acos'), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_tan(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version, op='Tan'), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_tanh(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version, op='Tanh'), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_atan(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version, op='Atan'), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_sin_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, ir_version=ir_version, precision=precision, op='Sin'), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_sinh_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, ir_version=ir_version, precision=precision, op='Sinh'), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_asin_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, ir_version=ir_version, precision=precision, op='Asin'), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_cos_const_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, ir_version=ir_version, precision=precision, op='Cos'), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_cos_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, ir_version=ir_version, precision=precision, op='Cos'), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_cosh_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, ir_version=ir_version, precision=precision, op='Cosh'), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_acos_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, ir_version=ir_version, precision=precision, op='Acos'), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_tan_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, ir_version=ir_version, precision=precision, op='Tan'), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_tanh_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, ir_version=ir_version, precision=precision, op='Tanh'), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_atan_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, ir_version=ir_version, precision=precision, op='Atan'), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_unsqueeze.py b/tests/layer_tests/onnx_tests/test_unsqueeze.py new file mode 100644 index 00000000000000..4042a2cda63971 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_unsqueeze.py @@ -0,0 +1,210 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.onnx_layer_test_class import Caffe2OnnxLayerTest + + +class TestUnsqueeze(Caffe2OnnxLayerTest): + def create_unsqueeze_net(self, axes, input_shape, output_shape, ir_version): + """ + ONNX net IR net + + Input->Unsqueeze(axes=0)->Output => Input->Reshape + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, input_shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + node_squeeze_def = onnx.helper.make_node( + 'Unsqueeze', + inputs=['input'], + outputs=['output'], + axes=axes + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_squeeze_def], + 'test_squeeze_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_squeeze_model') + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + return onnx_net, ref_net + + def create_unsqueeze_net_const(self, axes, input_shape, output_shape, ir_version): + """ + ONNX net IR net + + Input->Concat(+unsqueezed const)->Output => Input->Concat(+const) + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + import numpy as np + + concat_axis = 1 + concat_output_shape = output_shape.copy() + concat_output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, output_shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, concat_output_shape) + + const_number = np.prod(input_shape) + constant = np.random.randint(-127, 127, const_number).astype(np.float) + constant = np.reshape(constant, input_shape) + + node_const_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=constant.shape, + vals=constant.flatten(), + ), + ) + + node_squeeze_def = onnx.helper.make_node( + 'Unsqueeze', + inputs=['const1'], + outputs=['unsqueeze1'], + axes=axes + ) + + node_concat_def = onnx.helper.make_node( + 'Concat', + inputs=['input', 'unsqueeze1'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_squeeze_def, node_concat_def], + 'test_unsqueeze_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_unsqueeze_model') + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + ref_net = None + + return onnx_net, ref_net + + test_data_5D = [ + dict(axes=[0], input_shape=[2, 3, 10, 10], output_shape=[1, 2, 3, 10, 10]), + dict(axes=[1], input_shape=[2, 3, 10, 10], output_shape=[2, 1, 3, 10, 10]), + dict(axes=[2], input_shape=[2, 3, 10, 10], output_shape=[2, 3, 1, 10, 10]), + dict(axes=[3], input_shape=[2, 3, 10, 10], output_shape=[2, 3, 10, 1, 10]), + dict(axes=[4], input_shape=[2, 3, 10, 10], output_shape=[2, 3, 10, 10, 1]), + dict(axes=[0, 1], input_shape=[3, 10, 10], output_shape=[1, 1, 3, 10, 10]), + dict(axes=[0, 2], input_shape=[3, 10, 10], output_shape=[1, 3, 1, 10, 10]), + dict(axes=[0, 3], input_shape=[3, 10, 10], output_shape=[1, 3, 10, 1, 10]), + dict(axes=[0, 4], input_shape=[3, 10, 10], output_shape=[1, 3, 10, 10, 1]), + dict(axes=[1, 2], input_shape=[3, 10, 10], output_shape=[3, 1, 1, 10, 10]), + dict(axes=[1, 3], input_shape=[3, 10, 10], output_shape=[3, 1, 10, 1, 10]), + dict(axes=[1, 4], input_shape=[3, 10, 10], output_shape=[3, 1, 10, 10, 1]), + dict(axes=[2, 3], input_shape=[3, 10, 10], output_shape=[3, 10, 1, 1, 10]), + dict(axes=[2, 4], input_shape=[3, 10, 10], output_shape=[3, 10, 1, 10, 1]), + dict(axes=[3, 4], input_shape=[3, 10, 10], output_shape=[3, 10, 10, 1, 1]), + dict(axes=[0, 1, 2], input_shape=[10, 10], output_shape=[1, 1, 1, 10, 10]), + dict(axes=[0, 1, 3], input_shape=[10, 10], output_shape=[1, 1, 10, 1, 10]), + dict(axes=[0, 1, 4], input_shape=[10, 10], output_shape=[1, 1, 10, 10, 1]), + dict(axes=[0, 2, 3], input_shape=[10, 10], output_shape=[1, 10, 1, 1, 10]), + dict(axes=[0, 2, 4], input_shape=[10, 10], output_shape=[1, 10, 1, 10, 1]), + dict(axes=[0, 3, 4], input_shape=[10, 10], output_shape=[1, 10, 10, 1, 1]), + dict(axes=[1, 2, 3], input_shape=[10, 10], output_shape=[10, 1, 1, 1, 10]), + dict(axes=[1, 2, 4], input_shape=[10, 10], output_shape=[10, 1, 1, 10, 1]), + dict(axes=[1, 3, 4], input_shape=[10, 10], output_shape=[10, 1, 10, 1, 1]), + dict(axes=[2, 3, 4], input_shape=[10, 10], output_shape=[10, 10, 1, 1, 1])] + + test_data_4D = [ + dict(axes=[0], input_shape=[3, 10, 10], output_shape=[1, 3, 10, 10]), + dict(axes=[1], input_shape=[3, 10, 10], output_shape=[3, 1, 10, 10]), + dict(axes=[2], input_shape=[3, 10, 10], output_shape=[3, 10, 1, 10]), + dict(axes=[3], input_shape=[3, 10, 10], output_shape=[3, 10, 10, 1]), + dict(axes=[3], input_shape=[3, 10, 10], output_shape=[3, 10, 10, 1]), + dict(axes=[0, 1], input_shape=[10, 10], output_shape=[1, 1, 10, 10]), + dict(axes=[0, 2], input_shape=[10, 10], output_shape=[1, 10, 1, 10]), + dict(axes=[0, 3], input_shape=[10, 10], output_shape=[1, 10, 10, 1]), + dict(axes=[1, 2], input_shape=[10, 10], output_shape=[10, 1, 1, 10]), + dict(axes=[1, 3], input_shape=[10, 10], output_shape=[10, 1, 10, 1]), + dict(axes=[2, 3], input_shape=[10, 10], output_shape=[10, 10, 1, 1])] + + test_data_3D = [ + dict(axes=[0], input_shape=[10, 10], output_shape=[1, 10, 10]), + dict(axes=[1], input_shape=[10, 10], output_shape=[10, 1, 10]), + dict(axes=[2], input_shape=[10, 10], output_shape=[10, 10, 1])] + + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.nightly + def test_unsqueeze_5D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_unsqueeze_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + def test_unsqueeze_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_unsqueeze_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_3D) + @pytest.mark.nightly + def test_unsqueeze_3D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_unsqueeze_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.nightly + def test_unsqueeze_const_5D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_unsqueeze_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + def test_unsqueeze_const_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_unsqueeze_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_3D) + @pytest.mark.nightly + def test_unsqueeze_const_3D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_unsqueeze_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_upsample.py b/tests/layer_tests/onnx_tests/test_upsample.py new file mode 100644 index 00000000000000..0a796dbbeabde0 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_upsample.py @@ -0,0 +1,188 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import math +import os + +import pytest +import torch +from common.layer_test_class import CommonLayerTest +from common.onnx_layer_test_class import OnnxRuntimeLayerTest + + +class TestUpsample(OnnxRuntimeLayerTest): + def create_net(self, shape, mode, scales, opset, ir_version): + """ + ONNX net IR net + + Input->Upsample->Output => Input->Resample + + """ + + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + assert opset in [7, 9] + + output_shape = shape.copy() + output_shape[-1] = math.floor(scales[-1] * shape[-1]) + output_shape[-2] = math.floor(scales[-2] * shape[-2]) + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, output_shape) + + args = dict() + nodes = [] + if opset == 7: + args['scales'] = scales + else: + node_scales_def = onnx.helper.make_node( + 'Constant', + inputs=[], + outputs=['scales'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.FLOAT, + dims=[len(scales)], + vals=scales, + ), + ) + nodes.append(node_scales_def) + + if mode: + args['mode'] = mode + node_def = helper.make_node( + 'Upsample', + inputs=['input'] if opset == 7 else ['input', 'scales'], + outputs=['output'], + **args + ) + nodes.append(node_def) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + nodes, + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, + producer_name='test_model', + opset_imports=[helper.make_opsetid("", opset)]) + + # Create reference IR net + mode_to_resample_type = {None: 'caffe.ResampleParameter.NEAREST', + 'nearest': 'caffe.ResampleParameter.NEAREST', + 'linear': 'caffe.ResampleParameter.LINEAR'} + assert mode in mode_to_resample_type + + ref_net = None + + return onnx_net, ref_net + + test_data = [dict(shape=[1, 3, 10, 12], scales=[1., 1., 2., 2.]), + dict(shape=[1, 3, 10, 12], scales=[1., 1., 2.5, 2.5]), + dict(shape=[1, 3, 10, 12], scales=[1., 1., 2.5, 2.])] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.parametrize("mode", [None, 'nearest']) + @pytest.mark.parametrize("opset", [7, 9]) + @pytest.mark.nightly + def test_upsample_nearest(self, params, mode, opset, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, mode=mode, opset=opset, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.parametrize("opset", [7, 9]) + @pytest.mark.nightly + @pytest.mark.xfail(reason='Both onnxruntime and caffe2 calculate linear upsampling differently from IE') + def test_upsample_linear(self, params, opset, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, mode='linear', opset=opset, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + +class PytorchLayerTest(CommonLayerTest): + def produce_model_path(self, framework_model, save_path): + path = os.path.join(save_path, 'model.onnx') + self.torch_model = framework_model['model'] + torch.onnx.export(self.torch_model, framework_model['var'], path, output_names=['output']) + assert os.path.isfile(path), "model.onnx haven't been saved here: {}".format(save_path) + return path + + def get_framework_results(self, inputs_dict, model_path): + x = torch.tensor(inputs_dict['input'], dtype=torch.float32) + return {'output': self.torch_model(x).numpy()} + + +class UpsampleModel(torch.nn.Module): + def __init__(self, mode, size, scale_factor): + super(UpsampleModel, self).__init__() + args = dict() + if mode: + args['mode'] = mode + if scale_factor: + args['scale_factor'] = scale_factor + elif size: + args['size'] = size + self.upsample = torch.nn.modules.upsampling.Upsample(**args) + + +class TestPytorchUpsample(PytorchLayerTest): + def create_net(self, shape, mode, size, scale_factor, ir_version): + """ + Pytorch net IR net + + Input->Upsample->Output => Input->Resample + + """ + + output_shape = shape.copy() + if size: + output_shape[2] = size[0] + output_shape[3] = size[1] + elif scale_factor: + output_shape[2] = scale_factor * output_shape[2] + output_shape[3] = scale_factor * output_shape[3] + + # Create Pytorch model + model = UpsampleModel(mode, size, scale_factor) + + # Create reference IR net + mode_to_resample_type = {None: 'caffe.ResampleParameter.NEAREST', + 'nearest': 'caffe.ResampleParameter.NEAREST', + 'bilinear': 'caffe.ResampleParameter.LINEAR'} + assert mode in mode_to_resample_type + + ref_net = None + + return {'model': model, 'var': torch.randn(shape)}, ref_net + + test_data_precommit = [dict(shape=[1, 3, 10, 10], size=(25, 25), scale_factor=None), + dict(shape=[1, 3, 10, 10], size=None, scale_factor=2)] + + test_data = [dict(shape=[1, 3, 10, 10], size=(20, 20), scale_factor=None), + dict(shape=[1, 3, 10, 10], size=(25, 25), scale_factor=None), + dict(shape=[1, 3, 10, 10], size=None, scale_factor=2)] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.parametrize("mode", [None, 'nearest']) + def test_pytorch_upsample_precommit(self, params, mode, ie_device, precision, ir_version, temp_dir): + if ie_device == 'GPU': + pytest.skip('Linear upsampling not supported on GPU') + self._test(*self.create_net(**params, mode=mode, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.parametrize("mode", [None, 'nearest', 'bilinear']) + @pytest.mark.nightly + def test_pytorch_upsample(self, params, mode, ie_device, precision, ir_version, temp_dir): + if ie_device == 'GPU' and mode == 'bilinear': + pytest.skip('Linear upsampling not supported on GPU') + self._test(*self.create_net(**params, mode=mode, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_where.py b/tests/layer_tests/onnx_tests/test_where.py new file mode 100644 index 00000000000000..577685d65fa2f8 --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_where.py @@ -0,0 +1,97 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestWhere(OnnxRuntimeLayerTest): + def _prepare_input(self, inputs_dict): + for input in inputs_dict.keys(): + inputs_dict[input] = np.random.randint(0, 2, inputs_dict[input]).astype(np.bool) + return inputs_dict + + def create_net(self, condition_shape, shape_than, else_shape, ir_version): + """ + ONNX net IR net + + Input->Where->Output => Input->Select + """ + + # + # Create ONNX model + # + + from onnx import helper + from onnx import TensorProto + + input_cond = helper.make_tensor_value_info('input_cond', TensorProto.BOOL, condition_shape) + input_than = helper.make_tensor_value_info('input_than', TensorProto.BOOL, shape_than) + input_else = helper.make_tensor_value_info('input_else', TensorProto.BOOL, else_shape) + output = helper.make_tensor_value_info('output', TensorProto.BOOL, condition_shape) + + node_def = helper.make_node( + 'Where', + inputs=['input_cond', 'input_than', 'input_else'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input_cond, input_than, input_else], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # Create reference IR net + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input_cond': {'kind': 'op', 'type': 'Parameter'}, + 'input_cond_data': {'shape': condition_shape, 'kind': 'data'}, + + 'input_than': {'kind': 'op', 'type': 'Parameter'}, + 'input_than_data': {'shape': shape_than, 'kind': 'data'}, + + 'input_else': {'kind': 'op', 'type': 'Parameter'}, + 'input_else_data': {'shape': else_shape, 'kind': 'data'}, + + 'node': {'kind': 'op', 'type': 'Select'}, + 'node_data': {'shape': condition_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input_cond', 'input_cond_data'), + ('input_than', 'input_than_data'), + ('input_else', 'input_else_data'), + ('input_cond_data', 'node'), + ('input_than_data', 'node'), + ('input_else_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result')]) + + return onnx_net, ref_net + + test_data = [dict(condition_shape=[4, 6], shape_than=[4, 6], else_shape=[4, 6]), + dict(condition_shape=[4, 6], shape_than=[4, 6], else_shape=[1, 6]), + dict(condition_shape=[15, 3, 5], shape_than=[15, 1, 5], else_shape=[15, 3, 5]), + dict(condition_shape=[2, 3, 4, 5], shape_than=[], else_shape=[2, 3, 4, 5]), + dict(condition_shape=[2, 3, 4, 5], shape_than=[5], else_shape=[2, 3, 4, 5]), + dict(condition_shape=[2, 3, 4, 5], shape_than=[2, 1, 1, 5], else_shape=[2, 3, 4, 5]), + dict(condition_shape=[2, 3, 4, 5], shape_than=[2, 3, 4, 5], else_shape=[1, 3, 1, 5]), + ] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_where(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/onnx_tests/test_xor.py b/tests/layer_tests/onnx_tests/test_xor.py new file mode 100644 index 00000000000000..8b6626d524181d --- /dev/null +++ b/tests/layer_tests/onnx_tests/test_xor.py @@ -0,0 +1,268 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.layer_test_class import check_ir_version +from common.onnx_layer_test_class import OnnxRuntimeLayerTest +from unit_tests.utils.graph import build_graph + + +class TestXor(OnnxRuntimeLayerTest): + def _prepare_input(self, inputs_dict): + for input in inputs_dict.keys(): + inputs_dict[input] = np.random.randint(0, 2, inputs_dict[input]).astype(np.bool) + return inputs_dict + + def create_net(self, shape1, shape2, ir_version): + """ + ONNX net IR net + + Input->Xor with 2nd input->Output => Input->LogicalXor + """ + + # + # Create ONNX model + # + + from onnx import helper + from onnx import TensorProto + + input1 = helper.make_tensor_value_info('input1', TensorProto.BOOL, shape1) + input2 = helper.make_tensor_value_info('input2', TensorProto.BOOL, shape2) + output = helper.make_tensor_value_info('output', TensorProto.BOOL, shape1) + + node_def = helper.make_node( + 'Xor', + inputs=['input1', 'input2'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def], + 'test_model', + [input1, input2], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # Create reference IR net + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input1': {'kind': 'op', 'type': 'Parameter'}, + 'input1_data': {'shape': shape1, 'kind': 'data'}, + 'input2': {'kind': 'op', 'type': 'Parameter'}, + 'input2_data': {'shape': shape2, 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'LogicalXor'}, + 'node_data': {'shape': shape1, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input1', 'input1_data'), + ('input2', 'input2_data'), + ('input1_data', 'node'), + ('input2_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result')]) + + return onnx_net, ref_net + + def create_net_one_const(self, shape1, shape2, ir_version): + """ + ONNX net IR net + + Input->Xor with const->Output => Input->LogicalXor + """ + + # + # Create ONNX model + # + + from onnx import helper + from onnx import TensorProto + + input = helper.make_tensor_value_info('input', TensorProto.BOOL, shape1) + output = helper.make_tensor_value_info('output', TensorProto.BOOL, shape1) + + const = np.random.randint(0, 2, shape2).astype(np.bool) + + node_const_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['const'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.BOOL, + dims=const.shape, + vals=const.flatten(), + ), + ) + + node_def = helper.make_node( + 'Xor', + inputs=['input', 'const'], + outputs=['output'] + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const_def, node_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # Create reference IR net + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape1, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': const.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': const.shape, 'kind': 'data'}, + 'node': {'kind': 'op', 'type': 'LogicalXor'}, + 'node_data': {'shape': shape1, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'node'), + ('const_data', 'node'), + ('node', 'node_data'), + ('node_data', 'result')]) + + return onnx_net, ref_net + + def create_net_const(self, shape1, shape2, ir_version): + """ + ONNX net IR net + + Input->Concat with const xor const->Output => Input->Concat + """ + + # + # Create ONNX model + # + + from onnx import helper + from onnx import TensorProto + + concat_axis = 0 + output_shape = list(shape1) + output_shape[concat_axis] *= 2 + + input = helper.make_tensor_value_info('input', TensorProto.BOOL, shape1) + output = helper.make_tensor_value_info('output', TensorProto.BOOL, output_shape) + + const1 = np.random.randint(0, 2, shape1).astype(np.bool) + const2 = np.random.randint(0, 2, shape2).astype(np.bool) + + node_const1_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['const1'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.BOOL, + dims=const1.shape, + vals=const1.flatten(), + ), + ) + + node_const2_def = helper.make_node( + 'Constant', + inputs=[], + outputs=['const2'], + value=helper.make_tensor( + name='const_tensor', + data_type=TensorProto.BOOL, + dims=const2.shape, + vals=const2.flatten(), + ), + ) + + node_def = helper.make_node( + 'Xor', + inputs=['const1', 'const2'], + outputs=['node_out'] + ) + + node_concat_def = helper.make_node( + 'Concat', + inputs=['input', 'node_out'], + outputs=['output'], + axis=concat_axis + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_const1_def, node_const2_def, node_def, node_concat_def], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # Create reference IR net + constant_calculated = np.logical_xor(const1, const2) + + ref_net = None + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': const1.shape, 'kind': 'data'}, + 'input_const_data': {'kind': 'data', 'value': constant_calculated.flatten()}, + 'const': {'kind': 'op', 'type': 'Const'}, + 'const_data': {'shape': const1.shape, 'kind': 'data'}, + 'concat': {'kind': 'op', 'type': 'Concat', 'axis': concat_axis}, + 'concat_data': {'shape': output_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_const_data', 'const'), + ('const', 'const_data'), + ('input_data', 'concat'), + ('const_data', 'concat'), + ('concat', 'concat_data'), + ('concat_data', 'result')]) + + return onnx_net, ref_net + + test_data = [dict(shape1=[4, 6], shape2=[4, 6]), + dict(shape1=[4, 6, 8], shape2=[4, 6, 8]), + dict(shape1=[4, 6, 8, 10], shape2=[4, 6, 8, 10]), + dict(shape1=[4, 6, 8, 10, 12], shape2=[4, 6, 8, 10, 12])] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_xor(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_xor_one_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_one_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_xor_const(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_net_const(**params, ir_version=ir_version), ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/requirements.txt b/tests/layer_tests/requirements.txt new file mode 100644 index 00000000000000..717c816c904b8c --- /dev/null +++ b/tests/layer_tests/requirements.txt @@ -0,0 +1,2 @@ +requests>=2.25.1 +numpy~=1.19.5 diff --git a/tests/layer_tests/tensorflow_tests/conftest.py b/tests/layer_tests/tensorflow_tests/conftest.py new file mode 100644 index 00000000000000..bbf635f56809ac --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/conftest.py @@ -0,0 +1,12 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import inspect + +from common.layer_test_class import get_params + + +def pytest_generate_tests(metafunc): + test_gen_attrs_names = list(inspect.signature(get_params).parameters) + params = get_params() + metafunc.parametrize(test_gen_attrs_names, params, scope="function") diff --git a/tests/layer_tests/tensorflow_tests/permutation_utils.py b/tests/layer_tests/tensorflow_tests/permutation_utils.py new file mode 100644 index 00000000000000..c26c7b690f72ec --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/permutation_utils.py @@ -0,0 +1,22 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np + +from mo.ops.op import PermuteAttrs + + +def permute_nhwc_to_nchw(shape): + perm = PermuteAttrs.get_nhwc_to_nchw_permutation(len(shape)).perm + new_shape = np.array(shape)[perm] + return new_shape + + +def permute_nchw_to_nhwc(shape): + perm = PermuteAttrs.get_nchw_to_nhwc_permutation(len(shape)).perm + new_shape = np.array(shape)[perm] + return new_shape + + +def permute_axis(axis, permutation_inv): + return permutation_inv[axis] diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Add.py b/tests/layer_tests/tensorflow_tests/test_tf_Add.py new file mode 100644 index 00000000000000..46508f610d7a6f --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_Add.py @@ -0,0 +1,281 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.tf_layer_test_class import CommonTFLayerTest + + +class TestAdd(CommonTFLayerTest): + def create_add_placeholder_const_net(self, x_shape, y_shape, ir_version): + """ + Tensorflow net IR net + + Placeholder->Add => Placeholder->Eltwise or Power or ScaleShift + / / + Const-------/ Const-------/ + + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + tf_x_shape = x_shape.copy() + tf_y_shape = y_shape.copy() + # reshaping + if len(tf_x_shape) >= 3: + tf_x_shape.append(tf_x_shape.pop(1)) + if len(tf_y_shape) >= 3: + tf_y_shape.append(tf_y_shape.pop(1)) + + x = tf.compat.v1.placeholder(tf.float32, tf_x_shape, 'Input') + constant_value = np.random.randint(-256, 256, tf_y_shape).astype(np.float32) + if (constant_value == 0).all(): + # Avoid elimination of the layer from IR + constant_value = constant_value + 1 + y = tf.constant(constant_value) + + add = tf.add(x, y, name="Operation") + add_shape = add.shape.as_list() + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + if len(add_shape) >= 3: + # Permute add_shape to (N,C,...) format + order = [0, len(add_shape) - 1] + list(range(1, len(add_shape) - 1)) + add_shape = [add_shape[i] for i in order] + + y_shape_to_compare = tf_y_shape.copy() + while len(y_shape_to_compare) < len(x_shape): + # Expand shape of constant with 1 + y_shape_to_compare = [1] + y_shape_to_compare + constant_value = np.expand_dims(constant_value, axis=0) + + if len(y_shape_to_compare) >= 3: + # Permute constant_value to (N,C,...) format for correct further reshape + order = [0, len(y_shape_to_compare) - 1] + list(range(1, len(y_shape_to_compare) - 1)) + y_shape_to_compare = [y_shape_to_compare[i] for i in order] + constant_value = np.transpose(constant_value, order) + + ref_net = None + + return tf_net, ref_net + + # TODO: implement tests for 2 Consts + Add + + test_data_1D = [ + # Power + dict(x_shape=[1], y_shape=[1]), + # Eltwise + pytest.param(dict(x_shape=[3], y_shape=[3]), marks=pytest.mark.xfail(reason="*-19180")) + ] + + @pytest.mark.parametrize("params", test_data_1D) + @pytest.mark.nightly + def test_add_placeholder_const_1D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_add_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_2D = [ + # Power + dict(x_shape=[1, 1], y_shape=[1, 1]), + # ScaleShift + dict(x_shape=[1, 3], y_shape=[1, 3]), + # Eltwise + pytest.param(dict(x_shape=[3, 1], y_shape=[3, 1]), marks=pytest.mark.xfail(reason="*-19180")), + # Eltwise + dict(x_shape=[2, 3], y_shape=[2, 3]) + ] + + @pytest.mark.parametrize("params", test_data_2D) + @pytest.mark.nightly + def test_add_placeholder_const_2D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_add_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_3D = [ + # Power + dict(x_shape=[1, 1, 1], y_shape=[1, 1, 1]), + # ScaleShift + pytest.param(dict(x_shape=[1, 3, 1], y_shape=[1, 3, 1]), marks=pytest.mark.xfail(reason="*-19053")), + # Eltwise + pytest.param(dict(x_shape=[1, 1, 3], y_shape=[1, 1, 3]), + marks=[pytest.mark.xfail(reason="*-19053"), pytest.mark.xfail(reason="*-18830")]), + # Eltwise + pytest.param(dict(x_shape=[1, 3, 224], y_shape=[1, 3, 224]), marks=pytest.mark.xfail(reason="*-19053")) + ] + + @pytest.mark.parametrize("params", test_data_3D) + @pytest.mark.nightly + def test_add_placeholder_const_3D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_add_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_4D = [ + # Power + dict(x_shape=[1, 1, 1, 1], y_shape=[1, 1, 1, 1]), + # ScaleShift + dict(x_shape=[1, 3, 1, 1], y_shape=[1, 3, 1, 1]), + # Eltwise + pytest.param(dict(x_shape=[1, 1, 1, 3], y_shape=[1, 1, 1, 3]), marks=pytest.mark.xfail(reason="*-19180")), + # Eltwise + dict(x_shape=[1, 3, 222, 224], y_shape=[1, 3, 222, 224]) + ] + + # TODO mark as precommit (after successfully passing in nightly) + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + def test_add_placeholder_const_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_add_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_5D = [ + # Power + dict(x_shape=[1, 1, 1, 1, 1], y_shape=[1, 1, 1, 1, 1]), + # ScaleShift + dict(x_shape=[1, 3, 1, 1, 1], y_shape=[1, 3, 1, 1, 1]), + # Eltwise + pytest.param(dict(x_shape=[1, 1, 1, 1, 3], y_shape=[1, 1, 1, 1, 3]), + marks=pytest.mark.xfail(reason="*-19180")), + # Eltwise + dict(x_shape=[1, 3, 50, 100, 224], y_shape=[1, 3, 50, 100, 224]) + ] + + # TODO mark as precommit (after successfully passing in nightly) + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.nightly + def test_add_placeholder_const_5D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_add_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version=ir_version, temp_dir=temp_dir) + + ############################################################################################### + # # + # Broadcast cases # + # # + ############################################################################################### + + test_data_broadcast_1D = [ + # Power + dict(x_shape=[3], y_shape=[1]) + ] + + @pytest.mark.parametrize("params", test_data_broadcast_1D) + @pytest.mark.nightly + def test_add_placeholder_const_broadcast_1D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_add_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version=ir_version, temp_dir=temp_dir) + + test_data_broadcast_2D = [ + # Power + dict(x_shape=[1, 1], y_shape=[1]), + # Power + dict(x_shape=[1, 3], y_shape=[1]), + # ScaleShift + dict(x_shape=[1, 3], y_shape=[3]), + # Eltwise + dict(x_shape=[3, 1], y_shape=[3]), + # Eltwise + pytest.param(dict(x_shape=[3, 1], y_shape=[1, 3, 1, 1]), marks=pytest.mark.xfail(reason="*-19051")) + ] + + @pytest.mark.parametrize("params", test_data_broadcast_2D) + @pytest.mark.nightly + def test_add_placeholder_const_broadcast_2D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_add_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version=ir_version, temp_dir=temp_dir) + + test_data_broadcast_3D = [ + # Power + dict(x_shape=[1, 1, 1], y_shape=[1]), + # Power + pytest.param(dict(x_shape=[1, 3, 1], y_shape=[1]), marks=pytest.mark.xfail(reason="*-19053")), + # ScaleShift + pytest.param(dict(x_shape=[1, 3, 1], y_shape=[3]), marks=pytest.mark.xfail(reason="*-19053")), + # Eltwise + pytest.param(dict(x_shape=[1, 3, 1], y_shape=[3, 1]), marks=pytest.mark.xfail(reason="*-19053")), + # Eltwise + pytest.param(dict(x_shape=[1, 1, 1], y_shape=[3, 1]), marks=pytest.mark.xfail(reason="*-19053")), + # Eltwise + pytest.param(dict(x_shape=[3, 1, 224], y_shape=[1, 3, 224]), marks=pytest.mark.xfail(reason="*-19053")), + # Eltwise + pytest.param(dict(x_shape=[2, 3, 1], y_shape=[1, 3, 2]), marks=pytest.mark.xfail(reason="*-19053")), + ] + + @pytest.mark.parametrize("params", test_data_broadcast_3D) + @pytest.mark.nightly + def test_add_placeholder_const_broadcast_3D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_add_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version=ir_version, temp_dir=temp_dir) + + test_data_broadcast_4D = [ + # Power + dict(x_shape=[1, 1, 1, 1], y_shape=[1]), + # Power + dict(x_shape=[1, 3, 1, 1], y_shape=[1]), + # ScaleShift + dict(x_shape=[1, 3, 1, 1], y_shape=[3]), + # ScaleShift + dict(x_shape=[1, 3, 100, 224], y_shape=[3]), + # Eltwise + dict(x_shape=[1, 1, 1, 3], y_shape=[3]), + # Eltwise + dict(x_shape=[1, 3, 1, 1], y_shape=[3, 1]), + # Eltwise + dict(x_shape=[1, 3, 1, 2], y_shape=[3, 1, 2]), + # Eltwise + dict(x_shape=[1, 3, 1, 2], y_shape=[1, 3, 2]), + # Eltwise + dict(x_shape=[1, 3, 100, 224], y_shape=[1, 1, 1, 224]), + # Eltwise + dict(x_shape=[2, 3, 1, 2], y_shape=[1, 3, 2, 1]) + ] + + @pytest.mark.parametrize("params", test_data_broadcast_4D) + @pytest.mark.nightly + @pytest.mark.precommit + def test_add_placeholder_const_broadcast_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_add_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version=ir_version, temp_dir=temp_dir) + + test_data_broadcast_5D = [ + # Power + dict(x_shape=[1, 1, 1, 1, 1], y_shape=[1]), + # Power + dict(x_shape=[1, 3, 1, 1, 1], y_shape=[1, 1]), + # ScaleShift + dict(x_shape=[1, 3, 1, 1, 1], y_shape=[3]), + # Eltwise + dict(x_shape=[1, 1, 1, 1, 3], y_shape=[3]), + # Eltwise + dict(x_shape=[1, 3, 1, 1, 1], y_shape=[3, 1]), + # Eltwise + dict(x_shape=[1, 3, 1, 1, 2], y_shape=[1, 3, 2]), + # Eltwise + dict(x_shape=[1, 3, 5, 1, 2], y_shape=[5, 3, 2, 1]), + # Eltwise + dict(x_shape=[1, 3, 50, 100, 224], y_shape=[1, 1, 1, 1, 224]), + # Eltwise + dict(x_shape=[2, 3, 1, 2, 1], y_shape=[1, 3, 2, 1, 1]) + ] + + @pytest.mark.parametrize("params", test_data_broadcast_5D) + @pytest.mark.nightly + @pytest.mark.precommit + def test_add_placeholder_const_broadcast_5D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_add_placeholder_const_net(**params, ir_version=ir_version), ie_device, precision, + ir_version=ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_BatchToSpace.py b/tests/layer_tests/tensorflow_tests/test_tf_BatchToSpace.py new file mode 100644 index 00000000000000..f7d46dfcef4dba --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_BatchToSpace.py @@ -0,0 +1,80 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.tf_layer_test_class import CommonTFLayerTest + + +class TestBatchToSpace(CommonTFLayerTest): + def create_batch_to_space_net(self, in_shape, crops_value, block_shape_value, out_shape, ir_version): + """ + Tensorflow net IR net + + Input->BatchToSpace => Input->BatchToSpace + + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + x = tf.compat.v1.placeholder(tf.float32, in_shape, 'Input') + crops = tf.constant(crops_value) + block_shape = tf.constant(block_shape_value) + tf.batch_to_space(x, block_shape, crops, name='Operation') + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + return tf_net, ref_net + + test_data_4D = [ + dict(in_shape=[4, 1, 1, 3], block_shape_value=[1], crops_value=[[0, 0]], + out_shape=[4, 1, 1, 3]), + dict(in_shape=[4, 1, 1, 3], block_shape_value=[2, 2], crops_value=[[0, 0], [0, 0]], + out_shape=[1, 2, 2, 3]), + dict(in_shape=[60, 100, 30, 30], block_shape_value=[3, 2], crops_value=[[1, 5], [4, 1]], + out_shape=[2, 2, 1, 1]), + # todo: enable these tests after supporting the general case on CPU + # dict(in_shape=[4, 1, 1, 1], block_shape_value=[2, 1, 2], crops_value=[[0, 0], [0, 0], [0, 0]], + # out_shape=[]), + # dict(in_shape=[12, 1, 1, 3], block_shape_value=[3, 2, 2], crops_value=[[1, 0], [0, 1], [1, 1]], + # out_shape=[1, 2, 1, 4]), + # dict(in_shape=[36, 2, 2, 3], block_shape_value=[2, 3, 3], crops_value=[[1, 0], [0, 0], [2, 2]], + # out_shape=[2, 3, 6, 5]) + ] + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + def test_batch_to_space_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_batch_to_space_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_5D = [ + dict(in_shape=[72, 2, 1, 4, 2], block_shape_value=[3, 4, 2], crops_value=[[1, 2], [0, 0], [3, 0]], + out_shape=[3, 3, 4, 5, 2]), + # todo: enable these tests after supporting the general case on CPU + # dict(in_shape=[144, 2, 1, 4, 1], block_shape_value=[3, 4, 2, 2], + # crops_value=[[1, 2], [0, 0], [3, 0], [0, 0]], out_shape=[3, 3, 4, 5, 2]), + ] + + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.nightly + def test_batch_to_space_5D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_batch_to_space_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_BiasAdd.py b/tests/layer_tests/tensorflow_tests/test_tf_BiasAdd.py new file mode 100644 index 00000000000000..b7e997195f58ba --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_BiasAdd.py @@ -0,0 +1,194 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.tf_layer_test_class import CommonTFLayerTest + + +class TestBiasAdd(CommonTFLayerTest): + def create_bias_add_placeholder_const_net(self, shape, ir_version): + """ + Tensorflow net IR net + + Placeholder->BiasAdd => Placeholder->Power or ScaleShift + / / + Const-------/ Const-------/ + + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + import numpy as np + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + tf_x_shape = shape.copy() + # reshaping + if len(tf_x_shape) >= 3: + tf_x_shape.append(tf_x_shape.pop(1)) + tf_y_shape = tf_x_shape[-1:] + + x = tf.compat.v1.placeholder(tf.float32, tf_x_shape, 'Input') + constant_value = np.random.randint(0, 1, tf_y_shape).astype(np.float32) + if (constant_value == 0).all(): + # Avoid elimination of the layer from IR + constant_value = constant_value + 1 + y = tf.constant(constant_value) + + tf.nn.bias_add(x, y, name="Operation") + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + return tf_net, ref_net + + def create_bias_add_2_consts_net(self, shape, ir_version): + """ + Tensorflow net IR net + + Const->BiasAdd-->Concat => Const---->Concat + / / / + Const--/ / Placeholder-/ + / + Placeholder---/ + + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + import numpy as np + + tf.compat.v1.reset_default_graph() + + tf_concat_axis = -1 + + # Create the graph and model + with tf.compat.v1.Session() as sess: + tf_x_shape = shape.copy() + # reshaping + if len(tf_x_shape) >= 3: + tf_x_shape.append(tf_x_shape.pop(1)) + tf_y_shape = tf_x_shape[-1:] + + constant_value_x = np.random.randint(-256, 256, tf_x_shape).astype(np.float32) + x = tf.constant(constant_value_x) + constant_value_y = np.random.randint(-256, 256, tf_y_shape).astype(np.float32) + y = tf.constant(constant_value_y) + + add = tf.nn.bias_add(x, y, name="Operation") + add_shape = add.shape.as_list() + add_value = add.eval() + + placeholder = tf.compat.v1.placeholder(tf.float32, tf_x_shape, 'Input') # Input_1 in graph_def + + concat = tf.concat([placeholder, add], axis=tf_concat_axis, name='Operation') + concat_shape = concat.shape.as_list() + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + # Format axis to positive value + concat_ax = tf_concat_axis if tf_concat_axis >= 0 else tf_concat_axis + len(shape) + if len(shape) >= 3: + # Permute shapes to (N,C,...) format + order = [0, len(concat_shape) - 1] + list(range(1, len(concat_shape) - 1)) + concat_shape = [concat_shape[i] for i in order] + concat_ax = order.index(concat_ax) + add_value = np.transpose(add_value, order) + + ref_net = None + + return tf_net, ref_net + + test_data_2D = [ + dict(shape=[1, 1]), + dict(shape=[1, 224]) + ] + + @pytest.mark.parametrize("params", test_data_2D) + @pytest.mark.nightly + def test_bias_add_placeholder_const_2D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_bias_add_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_2D) + @pytest.mark.nightly + def test_bias_add_2_consts_2D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_bias_add_2_consts_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_3D = [ + pytest.param(dict(shape=[1, 1, 224]), marks=pytest.mark.xfail(reason="*-19053")), + pytest.param(dict(shape=[1, 3, 224]), marks=pytest.mark.xfail(reason="*-19053")) + ] + + @pytest.mark.parametrize("params", test_data_3D) + @pytest.mark.nightly + def test_bias_add_placeholder_const_3D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_bias_add_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_3D) + @pytest.mark.nightly + def test_bias_add_2_consts_3D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_bias_add_2_consts_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_4D = [ + dict(shape=[1, 1, 100, 224]), + dict(shape=[1, 3, 100, 224]) + ] + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + @pytest.mark.precommit + def test_bias_add_placeholder_const_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_bias_add_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + def test_bias_add_2_consts_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_bias_add_2_consts_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_5D = [ + dict(shape=[1, 1, 50, 100, 224]), + dict(shape=[1, 3, 220, 222, 224]) + ] + + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.nightly + @pytest.mark.precommit + def test_bias_add_placeholder_const_5D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_bias_add_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.nightly + def test_bias_add_2_consts_5D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_bias_add_2_consts_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Bucketize.py b/tests/layer_tests/tensorflow_tests/test_tf_Bucketize.py new file mode 100644 index 00000000000000..10d0bc6de74386 --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_Bucketize.py @@ -0,0 +1,83 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest +import tensorflow as tf +from common.layer_test_class import check_ir_version +from common.tf_layer_test_class import CommonTFLayerTest +from unit_tests.utils.graph import build_graph + + +class TestBucketize(CommonTFLayerTest): + def create_bucketize_net(self, input_shape, input_type, boundaries_size, ir_version): + """ + Tensorflow net: IR net: + Input => Input Boundaries + | \ / + Bucketize Bucketize + {attrs: boundaries} + """ + + # create Tensorflow model + tf.compat.v1.reset_default_graph() + with tf.compat.v1.Session() as sess: + x = tf.compat.v1.placeholder(input_type, input_shape, 'Input') + constant_value = np.arange(-boundaries_size * 5, boundaries_size * 5, 10, dtype=np.float32) + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # create reference IR net + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': input_shape, 'kind': 'data'}, + 'boundaries_input_data': {'shape': constant_value.shape, 'kind': 'data'}, + 'boundaries': {'type': 'Const', 'kind': 'op'}, + 'boundaries_data': {'kind': 'data', 'shape': constant_value.shape}, + 'bucketize': {'kind': 'op', 'type': 'Bucketize'}, + 'bucketize_data': {'shape': input_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'bucketize', {'in': 0}), + ('boundaries_input_data', 'boundaries'), + ('boundaries', 'boundaries_data'), + ('boundaries_data', 'bucketize', {'in': 1}), + ('bucketize', 'bucketize_data'), + ('bucketize_data', 'result') + ]) + + return tf_net, ref_net + + test_data_float32 = [ + dict(input_shape=[5], input_type=tf.float32, boundaries_size=1), + dict(input_shape=[5], input_type=tf.float32, boundaries_size=3), + dict(input_shape=[4, 8], input_type=tf.float32, boundaries_size=5), + dict(input_shape=[2, 4, 7], input_type=tf.float32, boundaries_size=10), + dict(input_shape=[2, 4, 7, 8], input_type=tf.float32, boundaries_size=12), + dict(input_shape=[2, 4, 7, 8, 10], input_type=tf.float32, boundaries_size=14)] + + @pytest.mark.parametrize("params", test_data_float32) + @pytest.mark.nightly + def test_bucketize_float32(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_bucketize_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_int32 = [ + dict(input_shape=[5], input_type=tf.int32, boundaries_size=1), + dict(input_shape=[5], input_type=tf.int32, boundaries_size=3), + dict(input_shape=[4, 8], input_type=tf.int32, boundaries_size=5), + dict(input_shape=[2, 4, 7], input_type=tf.int32, boundaries_size=10), + dict(input_shape=[2, 4, 7, 8], input_type=tf.float32, boundaries_size=12), + dict(input_shape=[2, 4, 7, 8, 10], input_type=tf.float32, boundaries_size=14)] + + @pytest.mark.parametrize("params", test_data_int32) + @pytest.mark.nightly + def test_bucketize_int32(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_bucketize_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Ceil.py b/tests/layer_tests/tensorflow_tests/test_tf_Ceil.py new file mode 100644 index 00000000000000..c516a598b88f64 --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_Ceil.py @@ -0,0 +1,78 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.layer_test_class import check_ir_version +from common.tf_layer_test_class import CommonTFLayerTest +from unit_tests.utils.graph import build_graph + + +class TestCeil(CommonTFLayerTest): + def create_ceil_net(self, shape, ir_version): + """ + Tensorflow net IR net + + Input->Ceil => Input->Ceil + + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + shapes = shape.copy() + # reshaping + if len(shapes) >= 3: + shapes.append(shapes.pop(1)) + input = tf.compat.v1.placeholder(tf.float32, shapes, 'Input') + + tf.math.ceil(input, name='Operation') + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'Ceiling': {'kind': 'op', 'type': 'Ceiling'}, + 'Ceiling_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'Ceiling'), + ('Ceiling', 'Ceiling_data'), + ('Ceiling_data', 'result') + ]) + + return tf_net, ref_net + + test_data_precommit = [dict(shape=[3, 2, 3, 7, 6])] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_ceil_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_ceil_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data = [dict(shape=[1]), + dict(shape=[2, 5]), + dict(shape=[5, 3, 7, 4]), + dict(shape=[3, 2, 3, 7, 6])] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_ceil(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_ceil_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Concat.py b/tests/layer_tests/tensorflow_tests/test_tf_Concat.py new file mode 100644 index 00000000000000..cfa6ca0e958c35 --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_Concat.py @@ -0,0 +1,114 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.tf_layer_test_class import CommonTFLayerTest + + +class TestConcat(CommonTFLayerTest): + def create_concat_net(self, shape, axis, ir_version): + """ + Tensorflow net IR net + + Input->Concat => Input->Concat + + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + + ax = axis + + input_shape_x = shape.copy() + # reshaping + if len(input_shape_x) >= 3: + input_shape_x.append(input_shape_x.pop(1)) + + # TODO: add concat with const inputs to check fusing (as in ONNX) + + x = tf.compat.v1.placeholder(tf.float32, input_shape_x, 'Input') + y = tf.compat.v1.placeholder(tf.float32, input_shape_x, 'Input') # Input_1 in graph_def + + concat = tf.concat([x, y], axis=ax, name='Operation') + concat_shape = concat.shape.as_list() + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + # Format axis to positive value + concat_ax = axis if axis >= 0 else axis + len(shape) + if len(shape) >= 3: + # Permute shape to (N,C,...) format and compute correct axis value + order = [0, len(concat_shape) - 1] + list(range(1, len(concat_shape) - 1)) + concat_shape = [concat_shape[i] for i in order] + concat_ax = order.index(concat_ax) + + ref_net = None + + return tf_net, ref_net + + # TODO: create tests for concat with 1 input and multiple inputs + + test_data_1D = [dict(shape=[1], axis=0), + dict(shape=[1], axis=-1)] + + @pytest.mark.parametrize("params", test_data_1D) + @pytest.mark.nightly + def test_concat_1D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_concat_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_2D = [dict(shape=[1, 224], axis=0), + dict(shape=[1, 224], axis=-1)] + + @pytest.mark.parametrize("params", test_data_2D) + @pytest.mark.nightly + def test_concat_2D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_concat_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_3D = [pytest.param(dict(shape=[1, 3, 224], axis=0), marks=pytest.mark.xfail(reason="*-19053")), + pytest.param(dict(shape=[1, 3, 224], axis=-1), marks=pytest.mark.xfail(reason="*-19053")), + pytest.param(dict(shape=[1, 3, 224], axis=2), marks=pytest.mark.xfail(reason="*-19053"))] + + @pytest.mark.parametrize("params", test_data_3D) + @pytest.mark.nightly + def test_concat_3D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_concat_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_4D = [dict(shape=[1, 3, 100, 224], axis=0), + dict(shape=[1, 3, 100, 224], axis=-1), + dict(shape=[1, 3, 100, 224], axis=2)] + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + @pytest.mark.precommit + def test_concat_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_concat_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_5D = [dict(shape=[1, 3, 50, 100, 224], axis=0), + dict(shape=[1, 3, 50, 100, 224], axis=-1), + dict(shape=[1, 3, 50, 100, 224], axis=2)] + + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.nightly + def test_concat_5D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_concat_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_ELU.py b/tests/layer_tests/tensorflow_tests/test_tf_ELU.py new file mode 100644 index 00000000000000..7e183cf9c3438d --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_ELU.py @@ -0,0 +1,88 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest +from common.layer_test_class import check_ir_version +from common.tf_layer_test_class import CommonTFLayerTest +from unit_tests.utils.graph import build_graph + + +class TestELU(CommonTFLayerTest): + def create_elu_net(self, shape, ir_version): + """ + Tensorflow net IR net + + Input->ELU => Input->ELU + + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + + shapes = shape.copy() + # reshaping + if len(shapes) >= 4: + shapes.append(shapes.pop(1)) + input = tf.compat.v1.placeholder(tf.float32, shapes, 'Input') + + tf.nn.elu(input, name='Operation') + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'ELU': {'kind': 'op', 'type': 'Elu'}, + 'ELU_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'ELU'), + ('ELU', 'ELU_data'), + ('ELU_data', 'result') + ]) + + return tf_net, ref_net + + test_data_precommit = [dict(shape=[4, 6, 8, 10, 12])] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_elu_precommit(self, params, ie_device, precision, ir_version, temp_dir): + if ie_device == 'GPU': + pytest.skip("5D tensors is not supported on GPU") + self._test(*self.create_elu_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data = [dict(shape=[10, 12]), + dict(shape=[8, 10, 12]), + dict(shape=[6, 8, 10, 12]), + dict(shape=[4, 6, 8, 10, 12])] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_elu(self, params, ie_device, precision, ir_version, temp_dir): + if ie_device == 'GPU': + pytest.skip("5D tensors is not supported on GPU") + self._test(*self.create_elu_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Eltwise.py b/tests/layer_tests/tensorflow_tests/test_tf_Eltwise.py new file mode 100644 index 00000000000000..d6880f3e0a1e31 --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_Eltwise.py @@ -0,0 +1,79 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.tf_layer_test_class import CommonTFLayerTest + + +class TestEltwise(CommonTFLayerTest): + def create_eltwise_net(self, shape, operation, ir_version): + """ + Tensorflow net IR net + + Inputs->Eltwise => Inputs->Eltwise + + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + + shapes = shape.copy() + # reshaping + if len(shapes) >= 4: + shapes.append(shapes.pop(1)) + + x = tf.compat.v1.placeholder(tf.float32, shapes, 'Input') + y = tf.compat.v1.placeholder(tf.float32, shapes, 'Input') # Input_1 in graph_def + + if operation == 'sum': + tf.add(x, y, name='Operation') + elif operation == 'max': + tf.maximum(x, y, name='Operation') + elif operation == 'mul': + tf.multiply(x, y, name='Operation') + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + return tf_net, ref_net + + test_data = [] + for operation in ['sum', 'max', 'mul']: + test_data.extend([dict(shape=[1, 224], operation=operation), + dict(shape=[1, 224, 224], operation=operation), + dict(shape=[1, 3, 224, 224], operation=operation)]) + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_eltwise(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_eltwise_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_5D = [] + for operation in ['sum', 'max', 'mul']: + test_data_5D.extend([dict(shape=[1, 3, 224, 224, 224], operation=operation)]) + + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.precommit + def test_eltwise_5D_precommit(self, params, ie_device, precision, ir_version, temp_dir): + if ie_device == 'GPU': + pytest.skip("5D tensors is not supported on GPU") + self._test(*self.create_eltwise_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_FakeQuantize.py b/tests/layer_tests/tensorflow_tests/test_tf_FakeQuantize.py new file mode 100644 index 00000000000000..d4d8fe91b845cb --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_FakeQuantize.py @@ -0,0 +1,125 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.layer_test_class import check_ir_version +from common.tf_layer_test_class import CommonTFLayerTest +from mo.front.common.partial_infer.utils import int64_array +from unit_tests.utils.graph import build_graph, regular_op_with_shaped_data, connect, \ + shaped_data, connect_front, regular_op + + +class TestFakeQuantize(CommonTFLayerTest): + def _prepare_input(self, inputs_dict, kwargs): + assert len(inputs_dict) == 1 + assert np.array(list(inputs_dict.values())[0]) == np.array([11]) + assert 'nudged_il' in kwargs and kwargs['nudged_il'] is not None + assert 'nudged_ih' in kwargs and kwargs['nudged_ih'] is not None + assert 'expected_step' in kwargs and kwargs['expected_step'] is not None + + expected_nudged_input_min = kwargs['nudged_il'] + expected_nudged_input_max = kwargs['nudged_ih'] + expected_step = kwargs['expected_step'] + + return {list(inputs_dict.keys())[0]: np.array([ + expected_nudged_input_min - expected_step, + expected_nudged_input_min - 0.01, expected_nudged_input_min, + expected_nudged_input_min + 0.01, + expected_nudged_input_min + expected_step - 0.01, + expected_nudged_input_min + expected_step, + expected_nudged_input_min + expected_step + 0.01, + expected_nudged_input_max - 0.01, expected_nudged_input_max, + expected_nudged_input_max + 0.01, + expected_nudged_input_max + expected_step + ])} + + def create_fake_quantize_net(self, il, ih, num_bits, narrow_range, nudged_il, nudged_ih, expected_step, ir_version): + # original tf model + import tensorflow as tf + tf.compat.v1.reset_default_graph() + with tf.compat.v1.Session() as sess: + data = tf.compat.v1.placeholder(tf.float32, [11], 'parameter') + input_min = tf.constant(il, name='input_min') + input_max = tf.constant(ih, name='input_max') + tf.quantization.fake_quant_with_min_max_vars(data, input_min, input_max, num_bits, narrow_range, 'fq') + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # reference graph to compare with IR + ref_net = None + if check_ir_version(10, None, ir_version): + levels = 2 ** num_bits - int(narrow_range) + + # data (shape, value) -> const (shape, vale) -> data (shape, no value) + const_for_layer_tests = lambda name, value: { + **{name + '_dd': {'kind': 'data', 'value': value, 'shape': value.shape}}, + **{name: {'kind': 'op', 'type': 'Const'}}, + **shaped_data(name + '_d', int64_array(value.shape))} + + connect_const_for_layer_tests = lambda first_tensor_name, second_tensor_name: [ + *connect_front(first_tensor_name + '_dd', first_tensor_name), + *connect(first_tensor_name, second_tensor_name)] + + nodes = { + **regular_op_with_shaped_data('parameter', [11], {'type': 'Parameter'}), + **const_for_layer_tests('il', np.array([nudged_il], dtype=np.float32)), + **const_for_layer_tests('ih', np.array([nudged_ih], dtype=np.float32)), + **const_for_layer_tests('ol', np.array([nudged_il], dtype=np.float32)), + **const_for_layer_tests('oh', np.array([nudged_ih], dtype=np.float32)), + **regular_op_with_shaped_data('fq', [11], {'type': 'FakeQuantize', 'levels': levels}), + **regular_op('result', {'type': 'Result'}), + } + edges = [ + *connect('parameter', '0:fq'), + *connect_const_for_layer_tests('il', '1:fq'), + *connect_const_for_layer_tests('ih', '2:fq'), + *connect_const_for_layer_tests('ol', '3:fq'), + *connect_const_for_layer_tests('oh', '4:fq'), + *connect('fq', 'result'), + ] + ref_net = build_graph(nodes, edges) + + return tf_net, ref_net + + test_data = [ + # with8BitsNoScalingNoNudging + dict(il=0.0, ih=255.0, num_bits=8, narrow_range=False, nudged_il=0.0, nudged_ih=255.0, expected_step=1.0), + # with8BitsScalingAndNudgingDown + dict(il=0.5, ih=128.0, num_bits=8, narrow_range=False, nudged_il=0.0, nudged_ih=127.5, expected_step=0.5), + # with8BitsScalingAndNudgingUp + dict(il=-128.0, ih=-0.5, num_bits=8, narrow_range=False, nudged_il=-127.5, nudged_ih=0.0, expected_step=0.5), + # with8BitsScalingAndNudgingBetween + dict(il=-0.1, ih=127.4, num_bits=8, narrow_range=False, nudged_il=0.0, nudged_ih=127.5, expected_step=0.5), + # with8BitsNarrowRangeNoScalingNoNudging + dict(il=0.0, ih=254.0, num_bits=8, narrow_range=True, nudged_il=0.0, nudged_ih=254.0, expected_step=1.0), + # with8BitsNarrowRangeScalingAndNudgingDown + dict(il=0.1, ih=127.1, num_bits=8, narrow_range=True, nudged_il=0.0, nudged_ih=127.0, expected_step=0.5), + # with8BitsNarrowRangeScalingAndNudgingUp + dict(il=-127.1, ih=-0.1, num_bits=8, narrow_range=True, nudged_il=-127.0, nudged_ih=0.0, expected_step=0.5), + # with8BitsNarrowRangeScalingAndNudgingBetween + dict(il=-0.1, ih=126.9, num_bits=8, narrow_range=True, nudged_il=0.0, nudged_ih=127.0, expected_step=0.5), + # with7BitsNoScalingNoNudging + dict(il=0.0, ih=127.0, num_bits=7, narrow_range=False, nudged_il=0.0, nudged_ih=127.0, expected_step=1.0), + # with7BitsScalingAndNudgingDown + dict(il=0.5, ih=64.0, num_bits=7, narrow_range=False, nudged_il=0.0, nudged_ih=63.5, expected_step=0.5), + # with7BitsScalingAndNudgingUp + dict(il=-64.0, ih=-0.5, num_bits=7, narrow_range=False, nudged_il=-63.5, nudged_ih=0.0, expected_step=0.5), + # with7BitsScalingAndNudgingBetween + dict(il=-0.1, ih=63.4, num_bits=7, narrow_range=False, nudged_il=0.0, nudged_ih=63.5, expected_step=0.5), + # with7BitsNarrowRangeNoScalingNoNudging + dict(il=0.0, ih=126.0, num_bits=7, narrow_range=True, nudged_il=0.0, nudged_ih=126.0, expected_step=1.0), + # with7BitsNarrowRangeScalingAndNudgingDown + dict(il=0.1, ih=63.1, num_bits=7, narrow_range=True, nudged_il=0.0, nudged_ih=63.0, expected_step=0.5), + # with7BitsNarrowRangeScalingAndNudgingUp + dict(il=-63.1, ih=-0.1, num_bits=7, narrow_range=True, nudged_il=-63.0, nudged_ih=0.0, expected_step=0.5), + # with7BitsNarrowRangeScalingAndNudgingBetween + dict(il=-0.1, ih=62.9, num_bits=7, narrow_range=True, nudged_il=0.0, nudged_ih=63.0, expected_step=0.5)] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_fake_quantize(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_fake_quantize_net(**params, ir_version=ir_version), ie_device, precision, ir_version, + kwargs_to_prepare_input=params, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Floor.py b/tests/layer_tests/tensorflow_tests/test_tf_Floor.py new file mode 100644 index 00000000000000..9c47f1f5910bcc --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_Floor.py @@ -0,0 +1,78 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.layer_test_class import check_ir_version +from common.tf_layer_test_class import CommonTFLayerTest +from unit_tests.utils.graph import build_graph + + +class TestFloor(CommonTFLayerTest): + def create_floor_net(self, shape, ir_version): + """ + Tensorflow net IR net + + Input->Floor => Input->Floor + + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + shapes = shape.copy() + # reshaping + if len(shapes) >= 3: + shapes.append(shapes.pop(1)) + input = tf.compat.v1.placeholder(tf.float32, shapes, 'Input') + + tf.floor(input, name='Operation') + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'Floor': {'kind': 'op', 'type': 'Floor'}, + 'Floor_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'Floor'), + ('Floor', 'Floor_data'), + ('Floor_data', 'result') + ]) + + return tf_net, ref_net + + test_data_precommit = [dict(shape=[3, 2, 3, 7, 6])] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_floor_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_floor_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data = [dict(shape=[1]), + dict(shape=[2, 5]), + dict(shape=[5, 3, 7, 4]), + dict(shape=[3, 2, 3, 7, 6])] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_floor(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_floor_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Identity.py b/tests/layer_tests/tensorflow_tests/test_tf_Identity.py new file mode 100644 index 00000000000000..6e963e85c4e766 --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_Identity.py @@ -0,0 +1,85 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.layer_test_class import check_ir_version +from common.tf_layer_test_class import CommonTFLayerTest +from unit_tests.utils.graph import build_graph + + +class TestIdentity(CommonTFLayerTest): + def create_identity_net(self, shape, ir_version): + """ + Tensorflow net IR net + + Input->Identity->ReLU => Input->ReLU + + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + x_shape = shape.copy() + # reshaping + if len(x_shape) >= 3: + x_shape.append(x_shape.pop(1)) + + x = tf.compat.v1.placeholder(tf.float32, x_shape, 'Input') + id = tf.identity(x, name="Operation") + tf.nn.relu(id, name='Operation') + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'inputX': {'kind': 'op', 'type': 'Parameter'}, + 'inputX_data': {'shape': shape, 'kind': 'data'}, + 'ReLU': {'kind': 'op', 'type': 'ReLU'}, + 'ReLU_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + ref_net = build_graph(nodes_attributes, + [('inputX', 'inputX_data'), + ('inputX_data', 'ReLU'), + ('ReLU', 'ReLU_data'), + ('ReLU_data', 'result') + ]) + + return tf_net, ref_net + + test_data_precommit = [dict(shape=[1, 3, 50, 100, 224])] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_identity_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_identity_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data = [dict(shape=[1]), + dict(shape=[1, 224]), + pytest.param(dict(shape=[1, 3, 224]), marks=pytest.mark.xfail(reason="*-19053")), + dict(shape=[1, 3, 100, 224]), + dict(shape=[1, 3, 50, 100, 224])] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_identity(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_identity_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Log.py b/tests/layer_tests/tensorflow_tests/test_tf_Log.py new file mode 100644 index 00000000000000..f979071395183e --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_Log.py @@ -0,0 +1,79 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.layer_test_class import check_ir_version +from common.tf_layer_test_class import CommonTFLayerTest +from unit_tests.utils.graph import build_graph + + +class TestLog(CommonTFLayerTest): + def create_log_net(self, shape, ir_version): + """ + Tensorflow net IR net + + Input->Log => Input->Log + + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + shapes = shape.copy() + # reshaping + if len(shapes) >= 3: + shapes.append(shapes.pop(1)) + input = tf.compat.v1.placeholder(tf.float32, shapes, 'Input') + + tf.math.log(input, name='Operation') + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'log': {'kind': 'op', 'type': 'Log'}, + 'log_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'log'), + ('log', 'log_data'), + ('log_data', 'result') + ]) + + return tf_net, ref_net + + test_data_precommit = [ + pytest.param(dict(shape=[3, 2, 3, 7, 6]), marks=pytest.mark.skip(reason="Skipped until fixed"))] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_log_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_log_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data = [dict(shape=[1]), + dict(shape=[2, 5]), + dict(shape=[5, 3, 7, 4]), + dict(shape=[3, 2, 3, 7, 6])] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_log(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_log_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_LogSoftmax.py b/tests/layer_tests/tensorflow_tests/test_tf_LogSoftmax.py new file mode 100644 index 00000000000000..8cb3087cc3e2fc --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_LogSoftmax.py @@ -0,0 +1,138 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +from distutils.version import LooseVersion + +import numpy as np +import pytest +from common.layer_test_class import check_ir_version +from common.tf_layer_test_class import CommonTFLayerTest +from mo.front.common.partial_infer.utils import int64_array +from unit_tests.utils.graph import build_graph + + +class TestLogSoftmax(CommonTFLayerTest): + def create_log_softmax_net(self, shape, reduction_axis, ir_version): + """ + Tensorflow net IR net + + Input->LogSoftmax => Input->Softmax->Log + + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + shapes = shape.copy() + # reshaping + if len(shapes) >= 3: + shapes.append(shapes.pop(1)) + input = tf.compat.v1.placeholder(tf.float32, shapes, 'Input') + if LooseVersion(tf.__version__) < LooseVersion('2.0.0'): + tf.nn.log_softmax(input, name='Operation', axis=reduction_axis) + else: + tf.nn.log_softmax(input, axis=reduction_axis, name='Operation') + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + ref_net = None + + reduce_sum_shape = np.copy(shape) + rank = len(shape) + if rank in {4, 5}: + reduction_axis = reduction_axis if reduction_axis >= 0 else rank + reduction_axis + if rank == 4: + reduction_axis = {0: 0, 1: 2, 2: 3, 3: 1}[reduction_axis] + else: + reduction_axis = {0: 0, 1: 2, 2: 3, 3: 4, 4: 1}[reduction_axis] + + reduce_sum_shape[reduction_axis] = 1 + + converted_shape = shape if rank != 1 else shape[0] + if check_ir_version(10, None, ir_version): + ref_nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter', 'shape': converted_shape}, + 'input_data': {'shape': shape, 'kind': 'data', 'value': None}, + 'reduce_max_axis_val': {'shape': int64_array([reduction_axis]).shape, + 'kind': 'data', + 'value': int64_array([reduction_axis])}, + 'reduce_max_axis': {'type': 'Const', 'kind': 'op', 'shape': 1}, + 'reduce_max_axis_data': {'shape': int64_array([1]), 'kind': 'data', 'value': None}, + 'reduce_max': {'type': 'ReduceMax', 'kind': 'op', 'keep_dims': True}, + 'reduce_max_data': {'shape': reduce_sum_shape, 'kind': 'data', 'value': None}, + 'sub_first': {'type': 'Subtract', 'kind': 'op'}, + 'sub_first_data': {'shape': shape, 'kind': 'data', 'value': None}, + 'reduce_sum_axis_val': {'shape': int64_array([reduction_axis]).shape, + 'kind': 'data', + 'value': int64_array([reduction_axis])}, + 'reduce_sum_axis': {'type': 'Const', 'kind': 'op', 'shape': 1}, + 'reduce_sum_axis_data': {'shape': int64_array([1]), 'kind': 'data', 'value': None}, + 'reduce_sum': {'type': 'ReduceSum', 'kind': 'op', 'keep_dims': True}, + 'reduce_sum_data': {'shape': reduce_sum_shape, 'kind': 'data', 'value': None}, + 'exp': {'type': 'Exp', 'kind': 'op'}, + 'exp_data': {'shape': shape, 'kind': 'data', 'value': None}, + 'log': {'type': 'Log', 'kind': 'op'}, + 'log_data': {'shape': reduce_sum_shape, 'kind': 'data', 'value': None}, + 'sub_second': {'type': 'Subtract', 'kind': 'op'}, + 'sub_second_data': {'shape': shape, 'kind': 'data', 'value': None}, + 'result': {'kind': 'op', 'type': 'Result'}, + } + + ref_edges = [ + ('input', 'input_data'), + ('reduce_max_axis_val', 'reduce_max_axis'), + ('reduce_max_axis', 'reduce_max_axis_data'), + ('reduce_max_axis_data', 'reduce_max', {'in': 1}), + ('reduce_max', 'reduce_max_data'), + ('input_data', 'reduce_max', {'out': 0, 'in': 0}), + ('input_data', 'sub_first', {'out': 0, 'in': 0}), + ('reduce_max_data', 'sub_first', {'in': 1}), + ('sub_first', 'sub_first_data'), + ('reduce_sum_axis_val', 'reduce_sum_axis'), + ('reduce_sum_axis', 'reduce_sum_axis_data'), + ('reduce_sum_axis_data', 'reduce_sum', {'in': 1}), + ('reduce_sum', 'reduce_sum_data'), + ('sub_first_data', 'exp'), + ('exp', 'exp_data'), + ('exp_data', 'reduce_sum', {'in': 0}), + ('reduce_sum_data', 'log'), + ('log', 'log_data'), + ('log_data', 'sub_second', {'in': 1}), + ('sub_second', 'sub_second_data'), + ('sub_first_data', 'sub_second', {'out': 0, 'in': 0}), + ('sub_second_data', 'result'), + ] + + ref_net = build_graph(ref_nodes_attributes, ref_edges) + + return tf_net, ref_net + + test_data_precommit = [ + pytest.param(dict(shape=[3, 2, 3, 7, 6], reduction_axis=-1), + marks=pytest.mark.skip(reason="Skipped until fixed")) + ] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_log_softmax_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_log_softmax_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data = [dict(shape=[1], reduction_axis=-1), + dict(shape=[2, 5], reduction_axis=-1), + dict(shape=[5, 3, 7, 4], reduction_axis=-1), + dict(shape=[3, 2, 3, 7, 6], reduction_axis=-1)] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_log_softmax(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_log_softmax_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Mul.py b/tests/layer_tests/tensorflow_tests/test_tf_Mul.py new file mode 100644 index 00000000000000..a877e639d6571a --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_Mul.py @@ -0,0 +1,279 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.tf_layer_test_class import CommonTFLayerTest + + +class TestMul(CommonTFLayerTest): + def create_mul_placeholder_const_net(self, x_shape, y_shape, ir_version): + """ + Tensorflow net IR net + + Placeholder->Mul => Placeholder->Eltwise or Power or ScaleShift + / / + Const-------/ Const-------/ + + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + tf_x_shape = x_shape.copy() + tf_y_shape = y_shape.copy() + # reshaping + if len(tf_x_shape) >= 3: + tf_x_shape.append(tf_x_shape.pop(1)) + if len(tf_y_shape) >= 3: + tf_y_shape.append(tf_y_shape.pop(1)) + + x = tf.compat.v1.placeholder(tf.float32, tf_x_shape, 'Input') + constant_value = np.random.randint(-255, 255, tf_y_shape).astype(np.float32) + if (constant_value == 1).all(): + # Avoid elimination of the layer from IR + constant_value = constant_value + 1 + y = tf.constant(constant_value) + + mul = tf.multiply(x, y, name="Operation") + mul_shape = mul.shape.as_list() + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + if len(mul_shape) >= 3: + # Permute mul_shape to (N,C,...) format + order = [0, len(mul_shape) - 1] + list(range(1, len(mul_shape) - 1)) + mul_shape = [mul_shape[i] for i in order] + + y_shape_to_compare = tf_y_shape.copy() + while len(y_shape_to_compare) < len(x_shape): + # Expand shape of constant with 1 + y_shape_to_compare = [1] + y_shape_to_compare + constant_value = np.expand_dims(constant_value, axis=0) + + if len(y_shape_to_compare) >= 3: + # Permute constant_value to (N,C,...) format for correct further reshape + order = [0, len(y_shape_to_compare) - 1] + list(range(1, len(y_shape_to_compare) - 1)) + y_shape_to_compare = [y_shape_to_compare[i] for i in order] + constant_value = np.transpose(constant_value, order) + + ref_net = None + + return tf_net, ref_net + + # TODO: implement tests for 2 Consts + Mul + + test_data_1D = [ + # Power + dict(x_shape=[1], y_shape=[1]), + # Eltwise + pytest.param(dict(x_shape=[3], y_shape=[3]), marks=pytest.mark.xfail(reason="*-19180")) + ] + + @pytest.mark.parametrize("params", test_data_1D) + @pytest.mark.nightly + def test_mul_placeholder_const_1D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_mul_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_2D = [ + # Power + dict(x_shape=[1, 1], y_shape=[1, 1]), + # ScaleShift + dict(x_shape=[1, 3], y_shape=[1, 3]), + # Eltwise + pytest.param(dict(x_shape=[3, 1], y_shape=[3, 1]), marks=pytest.mark.xfail(reason="*-19180")), + # Eltwise + dict(x_shape=[2, 3], y_shape=[2, 3]) + ] + + @pytest.mark.parametrize("params", test_data_2D) + @pytest.mark.nightly + def test_mul_placeholder_const_2D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_mul_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_3D = [ + # Power + dict(x_shape=[1, 1, 1], y_shape=[1, 1, 1]), + # ScaleShift + pytest.param(dict(x_shape=[1, 3, 1], y_shape=[1, 3, 1]), marks=pytest.mark.xfail(reason="*-19053")), + # Eltwise + pytest.param(dict(x_shape=[1, 1, 3], y_shape=[1, 1, 3]), + marks=[pytest.mark.xfail(reason="*-19053"), pytest.mark.xfail(reason="*-18830")]), + # Eltwise + pytest.param(dict(x_shape=[1, 3, 224], y_shape=[1, 3, 224]), marks=pytest.mark.xfail(reason="*-19053")) + ] + + @pytest.mark.parametrize("params", test_data_3D) + @pytest.mark.nightly + def test_mul_placeholder_const_3D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_mul_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_4D = [ + # Power + dict(x_shape=[1, 1, 1, 1], y_shape=[1, 1, 1, 1]), + # ScaleShift + dict(x_shape=[1, 3, 1, 1], y_shape=[1, 3, 1, 1]), + # Eltwise + pytest.param(dict(x_shape=[1, 1, 1, 3], y_shape=[1, 1, 1, 3]), marks=pytest.mark.xfail(reason="*-19180")), + # Eltwise + dict(x_shape=[1, 3, 222, 224], y_shape=[1, 3, 222, 224]) + ] + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + def test_mul_placeholder_const_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_mul_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_5D = [ + # Power + dict(x_shape=[1, 1, 1, 1, 1], y_shape=[1, 1, 1, 1, 1]), + # ScaleShift + dict(x_shape=[1, 3, 1, 1, 1], y_shape=[1, 3, 1, 1, 1]), + # Eltwise + pytest.param(dict(x_shape=[1, 1, 1, 1, 3], y_shape=[1, 1, 1, 1, 3]), + marks=pytest.mark.xfail(reason="*-19180")), + # Eltwise + dict(x_shape=[1, 3, 50, 100, 224], y_shape=[1, 3, 50, 100, 224]) + ] + + # TODO mark as precommit (after successfully passing in nightly) + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.nightly + def test_mul_placeholder_const_5D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_mul_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + ############################################################################################### + # # + # Broadcast cases # + # # + ############################################################################################### + + test_data_broadcast_1D = [ # Power + dict(x_shape=[3], y_shape=[1]) + ] + + @pytest.mark.parametrize("params", test_data_broadcast_1D) + @pytest.mark.nightly + def test_mul_placeholder_const_broadcast_1D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_mul_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_broadcast_2D = [ + # Power + dict(x_shape=[1, 1], y_shape=[1]), + # Power + dict(x_shape=[1, 3], y_shape=[1]), + # ScaleShift + dict(x_shape=[1, 3], y_shape=[3]), + # Eltwise + dict(x_shape=[3, 1], y_shape=[3]), + # Eltwise + pytest.param(dict(x_shape=[3, 1], y_shape=[1, 3, 1, 1]), marks=pytest.mark.xfail(reason="*-19051")) + ] + + @pytest.mark.parametrize("params", test_data_broadcast_2D) + @pytest.mark.nightly + def test_mul_placeholder_const_broadcast_2D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_mul_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_broadcast_3D = [ + # Power + dict(x_shape=[1, 1, 1], y_shape=[1]), + # Power + pytest.param(dict(x_shape=[1, 3, 1], y_shape=[1]), marks=pytest.mark.xfail(reason="*-19053")), + # ScaleShift + pytest.param(dict(x_shape=[1, 3, 1], y_shape=[3]), marks=pytest.mark.xfail(reason="*-19053")), + # Eltwise + pytest.param(dict(x_shape=[1, 3, 1], y_shape=[3, 1]), marks=pytest.mark.xfail(reason="*-19053")), + # Eltwise + pytest.param(dict(x_shape=[1, 1, 1], y_shape=[3, 1]), marks=pytest.mark.xfail(reason="*-19053")), + # Eltwise + pytest.param(dict(x_shape=[3, 1, 224], y_shape=[1, 3, 224]), marks=pytest.mark.xfail(reason="*-19053")), + # Eltwise + pytest.param(dict(x_shape=[2, 3, 1], y_shape=[1, 3, 2]), marks=pytest.mark.xfail(reason="*-19053")), + ] + + # TODO mark as precommit (after successfully passing in nightly) + @pytest.mark.parametrize("params", test_data_broadcast_3D) + @pytest.mark.nightly + def test_mul_placeholder_const_broadcast_3D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_mul_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_broadcast_4D = [ + # Power + dict(x_shape=[1, 1, 1, 1], y_shape=[1]), + # Power + dict(x_shape=[1, 3, 1, 1], y_shape=[1]), + # ScaleShift + dict(x_shape=[1, 3, 1, 1], y_shape=[3]), + # ScaleShift + dict(x_shape=[1, 3, 100, 224], y_shape=[3]), + # Eltwise + dict(x_shape=[1, 1, 1, 3], y_shape=[3]), + # Eltwise + dict(x_shape=[1, 3, 1, 1], y_shape=[3, 1]), + # Eltwise + dict(x_shape=[1, 3, 1, 2], y_shape=[3, 1, 2]), + # Eltwise + dict(x_shape=[1, 3, 1, 2], y_shape=[1, 3, 2]), + # Eltwise + dict(x_shape=[1, 3, 100, 224], y_shape=[1, 1, 1, 224]), + # Eltwise + dict(x_shape=[2, 3, 1, 2], y_shape=[1, 3, 2, 1]) + ] + + @pytest.mark.parametrize("params", test_data_broadcast_4D) + @pytest.mark.nightly + @pytest.mark.precommit + def test_mul_placeholder_const_broadcast_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_mul_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_broadcast_5D = [ + # Power + dict(x_shape=[1, 1, 1, 1, 1], y_shape=[1]), + # Power + dict(x_shape=[1, 3, 1, 1, 1], y_shape=[1, 1]), + # ScaleShift + dict(x_shape=[1, 3, 1, 1, 1], y_shape=[3]), + # Eltwise + dict(x_shape=[1, 1, 1, 1, 3], y_shape=[3]), + # Eltwise + dict(x_shape=[1, 3, 1, 1, 1], y_shape=[3, 1]), + # Eltwise + dict(x_shape=[1, 3, 1, 1, 2], y_shape=[1, 3, 2]), + # Eltwise + dict(x_shape=[1, 3, 5, 1, 2], y_shape=[5, 3, 2, 1]), + # Eltwise + dict(x_shape=[1, 3, 50, 100, 224], y_shape=[1, 1, 1, 1, 224]), + # Eltwise + dict(x_shape=[2, 3, 1, 2, 1], y_shape=[1, 3, 2, 1, 1]) + ] + + @pytest.mark.parametrize("params", test_data_broadcast_5D) + @pytest.mark.nightly + def test_mul_placeholder_const_broadcast_5D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_mul_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_NormalizeL2.py b/tests/layer_tests/tensorflow_tests/test_tf_NormalizeL2.py new file mode 100644 index 00000000000000..1dc4b914172645 --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_NormalizeL2.py @@ -0,0 +1,207 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.tf_layer_test_class import CommonTFLayerTest +from mo.front.common.partial_infer.utils import int64_array +from unit_tests.utils.graph import build_graph +from tensorflow_tests.permutation_utils import permute_nchw_to_nhwc, permute_nhwc_to_nchw + + +class TestNormalizeL2(CommonTFLayerTest): + @staticmethod + def build_tf_graph(shape, axes): + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + # Permute NCHW -> NHWC for TF network creation + net_shape = permute_nchw_to_nhwc(shape) + + data = tf.compat.v1.placeholder(tf.float32, shape=net_shape, name='data') + + result = tf.math.l2_normalize(data, + axes, + name='Operation') + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + return tf_net + + @staticmethod + def create_normalize_l2_net_fusable(shape, axes, output_axes, ir_version): + tf_net = TestNormalizeL2.build_tf_graph(shape, axes) + + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'axes_input_data': {'shape': int64_array([len(axes)]), 'kind': 'data', 'value': int64_array(output_axes)}, + 'axes': {'kind': 'op', 'type': 'Const'}, + 'axes_data': {'shape': int64_array([len(axes)]), 'kind': 'data'}, + 'normalize_l2': {'kind': 'op', 'type': 'NormalizeL2'}, + 'normalize_l2_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'}, + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'normalize_l2', {'out': 0, 'in': 0}), + ('axes_input_data', 'axes'), + ('axes', 'axes_data'), + ('axes_data', 'normalize_l2', {'in': 1, 'out': 0}), + ('normalize_l2', 'normalize_l2_data'), + ('normalize_l2_data', 'result'), + ]) + + return tf_net, ref_net + + @staticmethod + def create_normalize_l2_net_non_fusable(shape, axes, output_axes, ir_version): + tf_net = TestNormalizeL2.build_tf_graph(shape, axes) + + reduced_shape = permute_nchw_to_nhwc(shape).copy() + for axis in axes: + reduced_shape[axis] = 1 + reduced_shape = permute_nhwc_to_nchw(reduced_shape) + + eltwise_shapes = int64_array(np.ones(len(shape))) + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + + 'power_const_input_data': {'shape': int64_array([1]), 'kind': 'data', 'value': np.array([2.0])}, + 'power_const': {'kind': 'op', 'type': 'Const'}, + 'power_const_data': {'shape': eltwise_shapes, 'kind': 'data'}, + 'power': {'kind': 'op', 'type': 'Power'}, + 'power_data': {'shape': shape, 'kind': 'data'}, + + 'reduce': {'kind': 'op', 'type': 'ReduceSum', 'keep_dims': True}, + 'reduce_data': {'shape': reduced_shape, 'kind': 'data'}, + 'reduce_axes_input_data': {'shape': int64_array([len(axes)]), 'kind': 'data', + 'value': int64_array(output_axes)}, + 'reduce_axes': {'kind': 'op', 'type': 'Const'}, + 'reduce_axes_data': {'shape': int64_array([len(axes)]), 'kind': 'data'}, + + 'maximum_const_input_data': {'shape': int64_array([1]), 'kind': 'data', 'value': np.array([1e-12])}, + 'maximum_const': {'kind': 'op', 'type': 'Const'}, + 'maximum_const_data': {'shape': eltwise_shapes, 'kind': 'data'}, + 'maximum': {'kind': 'op', 'type': 'Maximum'}, + 'maximum_data': {'shape': reduced_shape, 'kind': 'data'}, + + 'power2_const_input_data': {'shape': int64_array([1]), 'kind': 'data', 'value': np.array([-0.5])}, + 'power2_const': {'kind': 'op', 'type': 'Const'}, + 'power2_const_data': {'shape': eltwise_shapes, 'kind': 'data'}, + 'power2': {'kind': 'op', 'type': 'Power'}, + 'power2_data': {'shape': reduced_shape, 'kind': 'data'}, + + 'multiply': {'kind': 'op', 'type': 'Multiply'}, + 'multiply_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'}, + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + + ('input_data', 'power', {'out': 0, 'in': 0}), + ('power_const_input_data', 'power_const'), + ('power_const', 'power_const_data'), + ('power_const_data', 'power', {'out': 0, 'in': 1}), + ('power', 'power_data'), + + ('power_data', 'reduce', {'out': 0, 'in': 0}), + ('reduce_axes_input_data', 'reduce_axes'), + ('reduce_axes', 'reduce_axes_data'), + ('reduce_axes_data', 'reduce', {'out': 0, 'in': 1}), + ('reduce', 'reduce_data'), + + ('reduce_data', 'maximum', {'out': 0, 'in': 0}), + ('maximum_const_input_data', 'maximum_const'), + ('maximum_const', 'maximum_const_data'), + ('maximum_const_data', 'maximum', {'out': 0, 'in': 1}), + ('maximum', 'maximum_data'), + + ('maximum_data', 'power2', {'out': 0, 'in': 0}), + ('power2_const_input_data', 'power2_const'), + ('power2_const', 'power2_const_data'), + ('power2_const_data', 'power2', {'out': 0, 'in': 1}), + ('power2', 'power2_data'), + + ('input_data', 'multiply', {'out': 0, 'in': 0}), + ('power2_data', 'multiply', {'out': 0, 'in': 1}), + ('multiply', 'multiply_data'), + ('multiply_data', 'result'), + ]) + + return tf_net, ref_net + + test_data_fusable_precommit = [ + pytest.param(dict(shape=[2, 3, 5], axes=[1, -1], output_axes=[1, 2]), + marks=pytest.mark.skip(reason="Skipped until fixed")), + pytest.param(dict(shape=[2, 3, 5, 7], axes=[1, 2, 3], output_axes=[2, 3, 1]), + marks=pytest.mark.skip(reason="Skipped until fixed")) + ] + + @pytest.mark.parametrize("params", test_data_fusable_precommit) + @pytest.mark.precommit + def test_NormalizeL2_fusable_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_normalize_l2_net_fusable(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_non_fusable_precommit = [ + pytest.param(dict(shape=[2, 3, 5], axes=[0, 1, 2], output_axes=[0, 1, 2]), + marks=pytest.mark.skip(reason="Skipped until fixed")), + pytest.param(dict(shape=[2, 3, 5, 7, 9], axes=[-1], output_axes=[1]), + marks=pytest.mark.skip(reason="Skipped until fixed")), + pytest.param(dict(shape=[2, 3, 5, 7, 9], axes=[1, 2, 3, 4], output_axes=[2, 3, 4, 1]), + marks=pytest.mark.skip(reason="Skipped until fixed")) + ] + + @pytest.mark.parametrize("params", test_data_non_fusable_precommit) + @pytest.mark.precommit + def test_NormalizeL2_non_fusable_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_normalize_l2_net_non_fusable(**params, ir_version=ir_version), + ie_device, precision, ir_version, + temp_dir=temp_dir) + + test_data_fusable = [ + dict(shape=[5, 6], axes=[1], output_axes=[1]), + dict(shape=[2, 3, 5], axes=[1], output_axes=[1]), + dict(shape=[2, 3, 5], axes=[-2], output_axes=[1]), + dict(shape=[2, 3, 5], axes=[1, -1], output_axes=[1, 2]), + dict(shape=[2, 3, 5, 7], axes=[-1], output_axes=[1]), + dict(shape=[2, 3, 5, 7], axes=[1, 2, 3], output_axes=[2, 3, 1]), + ] + + @pytest.mark.parametrize("params", test_data_fusable) + @pytest.mark.nightly + def test_NormalizeL2_fusable(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_normalize_l2_net_fusable(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_non_fusable = [ + dict(shape=[5], axes=[0], output_axes=[0]), + dict(shape=[5, 6], axes=[0], output_axes=[0]), + dict(shape=[5, 6], axes=[0, 1], output_axes=[0, 1]), + dict(shape=[2, 3, 5], axes=[0], output_axes=[0]), + dict(shape=[2, 3, 5], axes=[2], output_axes=[2]), + dict(shape=[2, 3, 5], axes=[0, 1, 2], output_axes=[0, 1, 2]), + dict(shape=[2, 3, 5, 7], axes=[0], output_axes=[0]), + dict(shape=[2, 3, 5, 7], axes=[1], output_axes=[2]), + dict(shape=[2, 3, 5, 7], axes=[2], output_axes=[3]), + dict(shape=[2, 3, 5, 7], axes=[1, 2], output_axes=[2, 3]), + dict(shape=[2, 3, 5, 7], axes=[1, 3], output_axes=[2, 1]), + dict(shape=[2, 3, 5, 7], axes=[0, 1, 2], output_axes=[0, 2, 3]), + dict(shape=[2, 3, 5, 7, 9], axes=[-1], output_axes=[1]), + dict(shape=[2, 3, 5, 7, 9], axes=[1, 2, 3, 4], output_axes=[2, 3, 4, 1]), + ] + + @pytest.mark.parametrize("params", test_data_non_fusable) + @pytest.mark.nightly + def test_NormalizeL2_non_fusable(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_normalize_l2_net_non_fusable(**params, ir_version=ir_version), + ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_OneHot.py b/tests/layer_tests/tensorflow_tests/test_tf_OneHot.py new file mode 100644 index 00000000000000..5e2d1d9131bf6b --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_OneHot.py @@ -0,0 +1,159 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest +from common.tf_layer_test_class import CommonTFLayerTest +from tensorflow_tests.permutation_utils import permute_nchw_to_nhwc + + +class TestOneHot(CommonTFLayerTest): + @staticmethod + def create_one_hot_net(shape, depth, on_value, off_value, axis, ir_version): + """ + Tensorflow net + + Input -> OneHot + + IR net (can contain Permutes for input/output of OneHot, depending on shapes), all cases are: + + Input (< 3D) -> OneHot + + Input (3D) -> OneHot -> Permute (NHWC -> NCHW) + + Input (> 3D) -> Permute (NCHW -> NHWC) -> OneHot -> Permute (NHWC -> NCHW) + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + # Permute NCHW -> NHWC for TF network creation + net_shape = permute_nchw_to_nhwc(shape) + + indices = tf.compat.v1.placeholder(tf.int32, shape=net_shape, name='input_indices') + + result = tf.one_hot(indices, + depth, + on_value, + off_value, + axis, + name='Operation') + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # + # Create reference IR net + # + + if on_value is None: + on_value = 1.0 + if off_value is None: + off_value = 0.0 + + axis = len(shape) if axis is None else axis + + ref_net = None + + return tf_net, ref_net + + test_data_1D = [ + # check for default on/off value, axis params + dict(shape=[5], depth=7, on_value=None, off_value=None, axis=None), + dict(shape=[5], depth=7, on_value=2.0, off_value=-1.0, axis=0)] + + @pytest.mark.parametrize("params", test_data_1D) + @pytest.mark.nightly + def test_OneHot_1D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_one_hot_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_2D = [ + dict(shape=[5, 6], depth=7, on_value=None, off_value=None, axis=None), + # check for default on/off value, axis params + dict(shape=[5, 6], depth=7, on_value=5.0, off_value=None, axis=None), + # check for default on/off value, axis params + dict(shape=[5, 6], depth=7, on_value=None, off_value=-1.0, axis=None), + # check for default on/off value, axis params + dict(shape=[5, 6], depth=7, on_value=None, off_value=None, axis=1), + # check for default on/off value, axis params + dict(shape=[5, 6], depth=7, on_value=2.0, off_value=-3.0, axis=0), + dict(shape=[5, 6], depth=7, on_value=2.0, off_value=-3.0, axis=1), + ] + + @pytest.mark.parametrize("params", test_data_2D) + @pytest.mark.nightly + def test_OneHot_2D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_one_hot_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_3D = [ + dict(shape=[5, 6, 7], depth=8, on_value=None, off_value=None, axis=None), + # check for default on/off value, axis params + dict(shape=[5, 6, 7], depth=8, on_value=6.0, off_value=None, axis=None), + # check for default on/off value, axis params + dict(shape=[5, 6, 7], depth=8, on_value=None, off_value=4.0, axis=None), + # check for default on/off value, axis params + dict(shape=[5, 6, 7], depth=8, on_value=None, off_value=None, axis=1), + # check for default on/off value, axis params + dict(shape=[5, 6, 7], depth=8, on_value=None, off_value=None, axis=0), + dict(shape=[5, 6, 7], depth=8, on_value=None, off_value=None, axis=1), + dict(shape=[5, 6, 7], depth=8, on_value=None, off_value=None, axis=2), + ] + + @pytest.mark.parametrize("params", test_data_3D) + @pytest.mark.nightly + def test_OneHot_3D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_one_hot_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_4D = [ + dict(shape=[5, 6, 7, 8], depth=9, on_value=None, off_value=None, axis=None), + # check for default on/off value, axis params + dict(shape=[5, 6, 7, 8], depth=9, on_value=None, off_value=None, axis=2), + # check for default on/off value, axis params + dict(shape=[5, 6, 7, 8], depth=9, on_value=5.0, off_value=None, axis=None), + # check for default on/off value, axis params + dict(shape=[5, 6, 7, 8], depth=9, on_value=None, off_value=6.0, axis=None), + # check for default on/off value, axis params + dict(shape=[5, 6, 7, 8], depth=9, on_value=None, off_value=None, axis=0), + dict(shape=[5, 6, 7, 8], depth=9, on_value=None, off_value=None, axis=1), + dict(shape=[5, 6, 7, 8], depth=9, on_value=None, off_value=None, axis=2), + dict(shape=[5, 6, 7, 8], depth=9, on_value=None, off_value=None, axis=3), + ] + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + @pytest.mark.precommit + def test_OneHot_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_one_hot_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_5D = [ + dict(shape=[4, 5, 6, 7, 8], depth=9, on_value=None, off_value=None, axis=None), + # check for default on/off value, axis params + dict(shape=[4, 5, 6, 7, 8], depth=9, on_value=2.0, off_value=None, axis=None), + # check for default on/off value, axis params + dict(shape=[4, 5, 6, 7, 8], depth=9, on_value=None, off_value=4.0, axis=None), + # check for default on/off value, axis params + dict(shape=[4, 5, 6, 7, 8], depth=9, on_value=None, off_value=None, axis=1), + # check for default on/off value, axis params + dict(shape=[4, 5, 6, 7, 8], depth=9, on_value=None, off_value=None, axis=0), + dict(shape=[4, 5, 6, 7, 8], depth=9, on_value=None, off_value=None, axis=1), + dict(shape=[4, 5, 6, 7, 8], depth=9, on_value=None, off_value=None, axis=2), + dict(shape=[4, 5, 6, 7, 8], depth=9, on_value=None, off_value=None, axis=3), + dict(shape=[4, 5, 6, 7, 8], depth=9, on_value=None, off_value=None, axis=4), + ] + + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.nightly + def test_OneHot_5D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_one_hot_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Pooling.py b/tests/layer_tests/tensorflow_tests/test_tf_Pooling.py new file mode 100644 index 00000000000000..c0dd7f96aae193 --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_Pooling.py @@ -0,0 +1,230 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest +from common.layer_test_class import check_ir_version +from common.tf_layer_test_class import CommonTFLayerTest +from unit_tests.utils.graph import build_graph + + +class TestPooling(CommonTFLayerTest): + def create_pooling_net(self, kernel_size, strides, pads, in_shape, out_shape, method, ir_version): + """ + Tensorflow net IR net + + Input->Pooling => Input->Pooling + + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + + pads_begin, pads_end, padding = pads + + # 4D tensors + if len(in_shape) == 4: + input_shape = [in_shape[0], in_shape[2], in_shape[3], in_shape[1]] + input = tf.compat.v1.placeholder(tf.float32, input_shape, 'Input') + + stride = [1, strides[0], strides[1], 1] + kernel = [1, kernel_size[0], kernel_size[1], 1] + + if method == 'max': + tf.nn.max_pool2d(input=input, ksize=kernel, strides=stride, padding=padding, name='Operation') + elif method == 'avg': + tf.nn.avg_pool2d(input=input, ksize=kernel, strides=stride, padding=padding, name='Operation') + + # 5D tensors + elif len(in_shape) == 5: + input_shape = [in_shape[0], in_shape[2], in_shape[3], in_shape[4], in_shape[1]] + input = tf.compat.v1.placeholder(tf.float32, input_shape, 'Input') + + stride = [1, strides[0], strides[1], strides[2], 1] + kernel = [1, kernel_size[0], kernel_size[1], kernel_size[2], 1] + + if method == 'max': + tf.nn.max_pool3d(input, kernel, stride, padding, name='Operation') # , data_format='NCHW') + elif method == 'avg': + tf.nn.avg_pool3d(input, kernel, stride, padding, name='Operation') # , data_format='NCHW') + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': in_shape, 'kind': 'data'}, + 'pooling': {'kernel': kernel_size, 'pads_begin': pads_begin, 'pads_end': pads_end, + 'strides': strides, 'kind': 'op', 'type': None}, + 'pooling_data': {'shape': out_shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + if method == 'avg': + nodes_attributes['pooling']['type'] = 'AvgPool' + elif method == 'max': + nodes_attributes['pooling']['type'] = 'MaxPool' + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'pooling'), + ('pooling', 'pooling_data'), + ('pooling_data', 'result') + ]) + + return tf_net, ref_net + + test_data_4D = [] + for method in ['max', 'avg']: + test_data_4D.extend([dict(kernel_size=[1, 1], strides=[1, 1], pads=[[0, 0], [0, 0], 'SAME'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 224, 224], method=method), + dict(kernel_size=[2, 2], strides=[2, 2], pads=[[0, 0], [0, 0], 'SAME'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 112, 112], method=method), + dict(kernel_size=[2, 4], strides=[2, 4], pads=[[0, 0], [0, 0], 'SAME'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 112, 56], method=method), + dict(kernel_size=[4, 2], strides=[4, 2], pads=[[0, 0], [0, 0], 'SAME'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 56, 112], method=method), + dict(kernel_size=[2, 3], strides=[2, 3], pads=[[0, 0], [0, 1], 'SAME'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 112, 75], method=method), + dict(kernel_size=[3, 2], strides=[3, 2], pads=[[0, 0], [1, 0], 'SAME'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 75, 112], method=method), + dict(kernel_size=[3, 3], strides=[2, 2], pads=[[0, 0], [1, 1], 'SAME'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 112, 112], method=method), + dict(kernel_size=[3, 2], strides=[2, 2], pads=[[0, 0], [1, 0], 'SAME'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 112, 112], method=method), + dict(kernel_size=[2, 3], strides=[2, 3], pads=[[0, 0], [0, 1], 'SAME'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 112, 75], method=method), + dict(kernel_size=[111, 111], strides=[111, 111], pads=[[54, 54], [55, 55], 'SAME'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 3, 3], method=method), + dict(kernel_size=[111, 113], strides=[111, 113], pads=[[54, 1], [55, 1], 'SAME'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 3, 2], method=method), + dict(kernel_size=[113, 113], strides=[113, 113], pads=[[1, 1], [1, 1], 'SAME'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 2, 2], method=method), + dict(kernel_size=[113, 113], strides=[111, 111], pads=[[55, 55], [56, 56], 'SAME'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 3, 3], method=method)]) + + test_data_4D.extend([dict(kernel_size=[1, 1], strides=[1, 1], pads=[[0, 0], [0, 0], 'VALID'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 224, 224], method=method), + dict(kernel_size=[2, 2], strides=[2, 2], pads=[[0, 0], [0, 0], 'VALID'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 112, 112], method=method), + dict(kernel_size=[2, 4], strides=[2, 4], pads=[[0, 0], [0, 0], 'VALID'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 112, 56], method=method), + dict(kernel_size=[4, 2], strides=[4, 2], pads=[[0, 0], [0, 0], 'VALID'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 56, 112], method=method), + dict(kernel_size=[2, 3], strides=[2, 3], pads=[[0, 0], [0, 0], 'VALID'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 112, 74], method=method), + dict(kernel_size=[3, 2], strides=[3, 2], pads=[[0, 0], [0, 0], 'VALID'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 74, 112], method=method), + dict(kernel_size=[3, 3], strides=[2, 2], pads=[[0, 0], [0, 0], 'VALID'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 111, 111], method=method), + dict(kernel_size=[3, 2], strides=[2, 2], pads=[[0, 0], [0, 0], 'VALID'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 111, 112], method=method), + dict(kernel_size=[2, 3], strides=[2, 3], pads=[[0, 0], [0, 0], 'VALID'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 112, 74], method=method), + dict(kernel_size=[111, 111], strides=[111, 111], pads=[[0, 0], [0, 0], 'VALID'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 2, 2], method=method), + dict(kernel_size=[111, 113], strides=[111, 113], pads=[[0, 0], [0, 0], 'VALID'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 2, 1], method=method), + dict(kernel_size=[113, 113], strides=[113, 113], pads=[[0, 0], [0, 0], 'VALID'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 1, 1], method=method), + dict(kernel_size=[113, 113], strides=[111, 111], pads=[[0, 0], [0, 0], 'VALID'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 2, 2], method=method), + dict(kernel_size=[224, 224], strides=[1, 1], pads=[[0, 0], [0, 0], 'VALID'], + in_shape=[1, 3, 224, 224], out_shape=[1, 3, 1, 1], method=method)]) + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + def test_pool_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_pooling_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_5D = [] + for method in ['max', 'avg']: + test_data_5D.extend([dict(kernel_size=[1, 1, 1], strides=[1, 1, 1], pads=[[0, 0, 0], [0, 0, 0], 'SAME'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 224, 224, 224], method=method), + dict(kernel_size=[2, 2, 2], strides=[2, 2, 2], pads=[[0, 0, 0], [0, 0, 0], 'SAME'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 112, 112, 112], method=method), + dict(kernel_size=[2, 2, 4], strides=[2, 2, 4], pads=[[0, 0, 0], [0, 0, 0], 'SAME'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 112, 112, 56], method=method), + dict(kernel_size=[4, 2, 2], strides=[4, 2, 2], pads=[[0, 0, 0], [0, 0, 0], 'SAME'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 56, 112, 112], method=method), + dict(kernel_size=[2, 2, 3], strides=[2, 2, 3], pads=[[0, 0, 0], [0, 0, 1], 'SAME'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 112, 112, 75], method=method), + dict(kernel_size=[3, 2, 2], strides=[3, 2, 2], pads=[[0, 0, 0], [1, 0, 0], 'SAME'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 75, 112, 112], method=method), + dict(kernel_size=[3, 3, 3], strides=[2, 2, 2], pads=[[0, 0, 0], [1, 1, 1], 'SAME'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 112, 112, 112], method=method), + dict(kernel_size=[3, 2, 2], strides=[2, 2, 2], pads=[[0, 0, 0], [1, 0, 0], 'SAME'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 112, 112, 112], method=method), + dict(kernel_size=[2, 2, 3], strides=[2, 2, 3], pads=[[0, 0, 0], [0, 0, 1], 'SAME'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 112, 112, 75], method=method), + dict(kernel_size=[111, 111, 111], strides=[111, 111, 111], + pads=[[54, 54, 54], [55, 55, 55], 'SAME'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 3, 3, 3], method=method), + dict(kernel_size=[111, 111, 113], strides=[111, 111, 113], + pads=[[54, 54, 1], [55, 55, 1], 'SAME'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 3, 3, 2], method=method), + dict(kernel_size=[113, 113, 113], strides=[113, 113, 113], + pads=[[1, 1, 1], [1, 1, 1], 'SAME'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 2, 2, 2], method=method), + dict(kernel_size=[113, 113, 113], strides=[111, 111, 111], + pads=[[55, 55, 55], [56, 56, 56], 'SAME'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 3, 3, 3], method=method)]) + + test_data_5D.extend([dict(kernel_size=[1, 1, 1], strides=[1, 1, 1], pads=[[0, 0, 0], [0, 0, 0], 'VALID'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 224, 224, 224], method=method), + dict(kernel_size=[2, 2, 2], strides=[2, 2, 2], pads=[[0, 0, 0], [0, 0, 0], 'VALID'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 112, 112, 112], method=method), + dict(kernel_size=[2, 2, 4], strides=[2, 2, 4], pads=[[0, 0, 0], [0, 0, 0], 'VALID'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 112, 112, 56], method=method), + dict(kernel_size=[4, 2, 2], strides=[4, 2, 2], pads=[[0, 0, 0], [0, 0, 0], 'VALID'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 56, 112, 112], method=method), + dict(kernel_size=[2, 2, 3], strides=[2, 2, 3], pads=[[0, 0, 0], [0, 0, 0], 'VALID'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 112, 112, 74], method=method), + dict(kernel_size=[3, 2, 2], strides=[3, 2, 2], pads=[[0, 0, 0], [0, 0, 0], 'VALID'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 74, 112, 112], method=method), + dict(kernel_size=[3, 3, 3], strides=[2, 2, 2], pads=[[0, 0, 0], [0, 0, 0], 'VALID'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 111, 111, 111], method=method), + dict(kernel_size=[3, 2, 2], strides=[2, 2, 2], pads=[[0, 0, 0], [0, 0, 0], 'VALID'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 111, 112, 112], method=method), + dict(kernel_size=[2, 2, 3], strides=[2, 2, 3], pads=[[0, 0, 0], [0, 0, 0], 'VALID'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 112, 112, 74], method=method), + dict(kernel_size=[111, 111, 111], strides=[111, 111, 111], + pads=[[0, 0, 0], [0, 0, 0], 'VALID'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 2, 2, 2], method=method), + dict(kernel_size=[111, 111, 113], strides=[111, 111, 113], + pads=[[0, 0, 0], [0, 0, 0], 'VALID'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 2, 2, 1], method=method), + dict(kernel_size=[113, 113, 113], strides=[113, 113, 113], + pads=[[0, 0, 0], [0, 0, 0], 'VALID'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 1, 1, 1], method=method), + dict(kernel_size=[113, 113, 113], strides=[111, 111, 111], + pads=[[0, 0, 0], [0, 0, 0], 'VALID'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 2, 2, 2], method=method), + dict(kernel_size=[224, 224, 224], strides=[1, 1, 1], + pads=[[0, 0, 0], [0, 0, 0], 'VALID'], + in_shape=[1, 3, 224, 224, 224], out_shape=[1, 3, 1, 1, 1], method=method)]) + + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.nightly + def test_pool_5D(self, params, ie_device, precision, ir_version, temp_dir): + if ie_device == 'GPU': + pytest.skip("5D tensors is not supported on GPU") + self._test(*self.create_pooling_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_ReLU.py b/tests/layer_tests/tensorflow_tests/test_tf_ReLU.py new file mode 100644 index 00000000000000..c178e6f8b55aef --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_ReLU.py @@ -0,0 +1,85 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.layer_test_class import check_ir_version +from common.tf_layer_test_class import CommonTFLayerTest +from unit_tests.utils.graph import build_graph + + +class TestReLU(CommonTFLayerTest): + def create_relu_net(self, shape, ir_version): + """ + Tensorflow net IR net + + Input->ReLU => Input->ReLU + + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + shapes = shape.copy() + # reshaping + if len(shapes) >= 3: + shapes.append(shapes.pop(1)) + input = tf.compat.v1.placeholder(tf.float32, shapes, 'Input') + + tf.nn.relu(input, name='Operation') + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'ReLU': {'kind': 'op', 'type': 'ReLU'}, + 'ReLU_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'ReLU'), + ('ReLU', 'ReLU_data'), + ('ReLU_data', 'result') + ]) + + return tf_net, ref_net + + test_data_precommit = [dict(shape=[1, 3, 50, 100, 224])] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_relu_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_relu_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data = [dict(shape=[1]), + dict(shape=[1, 224]), + pytest.param(dict(shape=[1, 3, 224]), marks=pytest.mark.xfail(reason="*-19053")), + dict(shape=[1, 3, 100, 224]), + dict(shape=[1, 3, 50, 100, 224])] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_relu(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_relu_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_ReLU6.py b/tests/layer_tests/tensorflow_tests/test_tf_ReLU6.py new file mode 100644 index 00000000000000..fd846a82358428 --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_ReLU6.py @@ -0,0 +1,85 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.layer_test_class import check_ir_version +from common.tf_layer_test_class import CommonTFLayerTest +from unit_tests.utils.graph import build_graph + + +class TestReLU6(CommonTFLayerTest): + def create_relu6_net(self, shape, ir_version): + """ + Tensorflow net IR net + + Input->ReLU6 => Input->Clamp + + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + shapes = shape.copy() + # reshaping + if len(shapes) >= 3: + shapes.append(shapes.pop(1)) + input = tf.compat.v1.placeholder(tf.float32, shapes, 'Input') + + tf.nn.relu6(input, name='Operation') + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'ReLU6': {'kind': 'op', 'type': 'Clamp', "max": 6, "min": 0}, + 'ReLU6_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'ReLU6'), + ('ReLU6', 'ReLU6_data'), + ('ReLU6_data', 'result') + ]) + + return tf_net, ref_net + + test_data_precommit = [dict(shape=[1, 3, 50, 100, 224])] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_relu6_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_relu6_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data = [dict(shape=[1]), + dict(shape=[1, 224]), + pytest.param(dict(shape=[1, 3, 224]), marks=pytest.mark.xfail(reason="*-19053")), + dict(shape=[1, 3, 100, 224]), + dict(shape=[1, 3, 50, 100, 224])] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_relu6(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_relu6_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Resample_pattern_new.py b/tests/layer_tests/tensorflow_tests/test_tf_Resample_pattern_new.py new file mode 100644 index 00000000000000..e3afdda6972d02 --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_Resample_pattern_new.py @@ -0,0 +1,81 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.tf_layer_test_class import CommonTFLayerTest +from unit_tests.utils.graph import build_graph + + +class TestResamplePattern(CommonTFLayerTest): + def _prepare_input(self, inputs_dict): + for input in inputs_dict.keys(): + inputs_dict[input] = np.random.randint(1, 256, inputs_dict[input]).astype(np.float32) + return inputs_dict + + def create_resample_net(self, shape, factor): + """ + The sub-graph in TF that could be expressed as a single Resample operation. + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + tf_shape = shape.copy() + tf_shape = np.array(tf_shape)[[0, 2, 3, 1]] + + input = tf.compat.v1.placeholder(tf.float32, tf_shape, 'Input') + + transpose_1 = tf.transpose(a=input, perm=[1, 2, 3, 0]) + expand_dims = tf.expand_dims(transpose_1, 0) + tile = tf.tile(expand_dims, [factor * factor, 1, 1, 1, 1]) + bts = tf.batch_to_space(tile, [factor, factor], [[0, 0], [0, 0]]) + strided_slice = bts[0, ...] + tf.transpose(a=strided_slice, perm=[3, 0, 1, 2]) + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + new_shape = shape.copy() + new_shape[2] *= factor + new_shape[3] *= factor + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Input'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'resample': {'kind': 'op', 'type': 'caffe.ResampleParameter.NEAREST', "factor": factor, + "height": 0, "width": 0, "antialias": 0}, + 'resample_data': {'shape': new_shape, 'kind': 'data'}, + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'resample'), + ('resample', 'resample_data') + ]) + + return tf_net, ref_net + + test_data = [dict(shape=[1, 1, 100, 200], factor=2), + dict(shape=[1, 1, 200, 300], factor=3)] + + # TODO mark as precommit (after successfully passing in nightly) + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + @pytest.mark.xfail(reason="*-22273") + def test_resample(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_resample_net(params['shape'], params['factor']), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Rsqrt.py b/tests/layer_tests/tensorflow_tests/test_tf_Rsqrt.py new file mode 100644 index 00000000000000..953d73f6809b3a --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_Rsqrt.py @@ -0,0 +1,73 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.tf_layer_test_class import CommonTFLayerTest + + +class TestRsqrt(CommonTFLayerTest): + def _prepare_input(self, inputs_dict): + for input in inputs_dict.keys(): + inputs_dict[input] = np.random.randint(1, 256, inputs_dict[input]).astype(np.float32) + return inputs_dict + + def create_rsqrt_net(self, shape, ir_version): + """ + Tensorflow net IR net + + Input->Rsqrt => Input->Power + + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + shapes = shape.copy() + # reshaping + if len(shapes) >= 3: + shapes.append(shapes.pop(1)) + input = tf.compat.v1.placeholder(tf.float32, shapes, 'Input') + + tf.math.rsqrt(input, name='Operation') + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + return tf_net, ref_net + + test_data_precommit = [dict(shape=[1, 3, 50, 100, 224])] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_rsqrt_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_rsqrt_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data = [dict(shape=[1]), + dict(shape=[1, 224]), + pytest.param(dict(shape=[1, 3, 224]), marks=pytest.mark.xfail(reason="*-19053")), + dict(shape=[1, 3, 100, 224]), + dict(shape=[1, 3, 50, 100, 224])] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_rsqrt(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_rsqrt_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Select.py b/tests/layer_tests/tensorflow_tests/test_tf_Select.py new file mode 100644 index 00000000000000..ee24964589b494 --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_Select.py @@ -0,0 +1,107 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.tf_layer_test_class import CommonTFLayerTest +from tensorflow_tests.permutation_utils import permute_nchw_to_nhwc + + +class TestSelect(CommonTFLayerTest): + def create_select_net(self, shape_condition, shape_input, ir_version): + """ + Tensorflow net IR net + + Condition --| Condition --| + v v + Input_1-> Select Input_1-> Select + ^ ^ + Input_2-----| Input_2-----| + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + # Permute shapes NCHW -> NHWC for TF network creation + shape_condition_net = permute_nchw_to_nhwc(shape_condition) + shape_input_net = permute_nchw_to_nhwc(shape_input) + + condition = tf.compat.v1.placeholder(tf.bool, shape_condition_net, 'Input_condition') + input_1 = tf.compat.v1.placeholder(tf.float32, shape_input_net, 'Input_1') + input_2 = tf.compat.v1.placeholder(tf.float32, shape_input_net, 'Input_2') + + tf.compat.v1.where(condition, input_1, input_2, name='Operation') + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + return tf_net, ref_net + + test_data_1D = [dict(shape_condition=[2], shape_input=[2])] + + @pytest.mark.parametrize("params", test_data_1D) + @pytest.mark.nightly + def test_select_1D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_select_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_2D = [ + dict(shape_condition=[2], shape_input=[2, 3]), + dict(shape_condition=[3, 5], shape_input=[3, 5]), + ] + + @pytest.mark.parametrize("params", test_data_2D) + @pytest.mark.nightly + def test_select_2D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_select_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_3D = [ + dict(shape_condition=[3], shape_input=[3, 4, 5]), + dict(shape_condition=[3, 4, 5], shape_input=[3, 4, 5]), + ] + + @pytest.mark.parametrize("params", test_data_3D) + @pytest.mark.nightly + def test_select_3D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_select_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_4D = [ + dict(shape_condition=[3], shape_input=[3, 4, 5, 6]), + dict(shape_condition=[3, 4, 5, 6], shape_input=[3, 4, 5, 6]), + ] + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + @pytest.mark.precommit + def test_select_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_select_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_5D = [ + dict(shape_condition=[3], shape_input=[3, 4, 5, 6, 7]), + dict(shape_condition=[3, 4, 5, 6, 7], shape_input=[3, 4, 5, 6, 7]), + ] + + # TODO mark as precommit (after successfully passing in nightly) + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.nightly + def test_select_5D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_select_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Softplus.py b/tests/layer_tests/tensorflow_tests/test_tf_Softplus.py new file mode 100644 index 00000000000000..a295e4660e9174 --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_Softplus.py @@ -0,0 +1,90 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.layer_test_class import check_ir_version +from common.tf_layer_test_class import CommonTFLayerTest +from unit_tests.utils.graph import build_graph + + +class TestSoftplus(CommonTFLayerTest): + def create_softplus_net(self, shape, ir_version): + """ + Tensorflow net IR net + + Input->Softplus => Input->Softplus + + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.reset_default_graph() + + # Create the graph and model + with tf.Session() as sess: + shapes = shape.copy() + # reshaping + if len(shapes) > 3: + shapes.append(shapes.pop(1)) + input = tf.placeholder(tf.float32, shapes, 'Input') + + tf.math.softplus(input, name='Operation') + + tf.global_variables_initializer() + tf_net = sess.graph_def + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'Softplus': {'kind': 'op', 'type': 'SoftPlus'}, + 'Softplus_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'Softplus'), + ('Softplus', 'Softplus_data'), + ('Softplus_data', 'result') + ]) + + return tf_net, ref_net + + test_data_precommit = [ + pytest.param(dict(shape=[1, 3, 100, 224]), + marks=pytest.mark.skip(reason="Skipped until fixed")), + pytest.param(dict(shape=[1, 3, 50, 100, 224]), + marks=pytest.mark.skip(reason="Skipped until fixed")) + ] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_softplus_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_softplus_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data = [dict(shape=[1]), + dict(shape=[1, 224]), + dict(shape=[1, 3, 224]), + dict(shape=[1, 3, 100, 224]), + dict(shape=[1, 3, 50, 100, 224])] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_softplus(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_softplus_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_SpaceToBatch.py b/tests/layer_tests/tensorflow_tests/test_tf_SpaceToBatch.py new file mode 100644 index 00000000000000..f86ab7dc2acf21 --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_SpaceToBatch.py @@ -0,0 +1,80 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.tf_layer_test_class import CommonTFLayerTest + + +class TestSpaceToBatch(CommonTFLayerTest): + def create_space_to_batch_net(self, in_shape, pads_value, block_shape_value, out_shape, ir_version): + """ + Tensorflow net IR net + + Input->SpaceToBatch => Input->SpaceToBatch + + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + x = tf.compat.v1.placeholder(tf.float32, in_shape, 'Input') + pads = tf.constant(pads_value) + block_shape = tf.constant(block_shape_value) + tf.space_to_batch(x, block_shape, pads, name='Operation') + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + return tf_net, ref_net + + test_data_4D = [ + dict(in_shape=[4, 1, 1, 3], block_shape_value=[1], pads_value=[[0, 0]], + out_shape=[4, 1, 1, 3]), + dict(in_shape=[1, 2, 2, 1], block_shape_value=[2, 2], pads_value=[[0, 0], [0, 0]], + out_shape=[4, 1, 1, 3]), + dict(in_shape=[1, 2, 2, 3], block_shape_value=[2, 2], pads_value=[[0, 0], [0, 0]], + out_shape=[4, 1, 1, 3]), + dict(in_shape=[1, 2, 9, 1], block_shape_value=[4, 3], pads_value=[[1, 1], [2, 4]], + out_shape=[12, 1, 1, 3]), + # todo: enable these tests after supporting the general case on CPU + # dict(in_shape=[1, 2, 1, 4], block_shape_value=[3, 2, 2], pads_value=[[1, 0], [0, 1], [1, 1]], + # out_shape=[12, 1, 1, 3]), + # dict(in_shape=[2, 3, 6, 5], block_shape_value=[2, 3, 3], pads_value=[[1, 0], [0, 0], [2, 2]], + # out_shape=[36, 2, 2, 3]) + ] + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + def test_space_to_batch_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_space_to_batch_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_5D = [ + dict(in_shape=[3, 3, 4, 5, 2], block_shape_value=[3, 4, 2], pads_value=[[1, 2], [0, 0], [3, 0]], + out_shape=[72, 2, 1, 4, 2]), + # todo: enable these tests after supporting the general case on CPU + # dict(in_shape=[3, 3, 4, 5, 2], block_shape_value=[3, 4, 2, 2], + # pads_value=[[1, 2], [0, 0], [3, 0], [0, 0]], out_shape=[144, 2, 1, 4, 1]), + ] + + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.nightly + def test_space_to_batch_5D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_space_to_batch_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Squeeze.py b/tests/layer_tests/tensorflow_tests/test_tf_Squeeze.py new file mode 100644 index 00000000000000..0ef13751b3463e --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_Squeeze.py @@ -0,0 +1,124 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.tf_layer_test_class import CommonTFLayerTest + + +class TestSqueeze(CommonTFLayerTest): + def create_squeeze_net(self, shape, axis, ir_version): + """ + Tensorflow net IR net + + Input->Squeeze => Input->[Permute]->Reshape + + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + x_shape = shape.copy() + # reshaping + if len(x_shape) >= 3: + x_shape.append(x_shape.pop(1)) + + x = tf.compat.v1.placeholder(tf.float32, x_shape, 'Input') + squeeze = tf.squeeze(x, axis=axis, name="Operation") + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + unsigned_axis = [ax if ax > -1 else len(x_shape) + ax for ax in axis] + if not unsigned_axis: + unsigned_axis = [i for i, dim in enumerate(shape) if dim == 1] + + ref_net = None + + return tf_net, ref_net + + test_data_1D = [ + pytest.param(dict(shape=[1], axis=[]), marks=pytest.mark.xfail(reason="*-18807")), + pytest.param(dict(shape=[1], axis=[0]), marks=pytest.mark.xfail(reason="*-18859")), + pytest.param(dict(shape=[1], axis=[-1]), marks=pytest.mark.xfail(reason="*-18859")) + ] + + @pytest.mark.parametrize("params", test_data_1D) + @pytest.mark.nightly + def test_squeeze_1D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_squeeze_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_2D = [ + pytest.param(dict(shape=[1, 1], axis=[]), marks=pytest.mark.xfail(reason="*-18807")), + dict(shape=[1, 1], axis=[0]), + dict(shape=[1, 1], axis=[-1]) + ] + + @pytest.mark.parametrize("params", test_data_2D) + @pytest.mark.nightly + def test_squeeze_2D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_squeeze_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_3D = [ + pytest.param(dict(shape=[1, 1, 3], axis=[]), + marks=[pytest.mark.xfail(reason="*-18807"), pytest.mark.xfail(reason="*-19053")]), + pytest.param(dict(shape=[1, 1, 3], axis=[0]), marks=pytest.mark.xfail(reason="*-19053")), + pytest.param(dict(shape=[1, 1, 3], axis=[-1]), marks=pytest.mark.xfail(reason="*-19053")) + ] + + # TODO mark as precommit (after successfully passing in nightly) + @pytest.mark.parametrize("params", test_data_3D) + @pytest.mark.nightly + def test_squeeze_3D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_squeeze_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_4D = [ + pytest.param(dict(shape=[1, 1, 50, 100], axis=[]), marks=pytest.mark.xfail(reason="*-18807")), + dict(shape=[1, 1, 50, 100], axis=[0]), + dict(shape=[1, 1, 50, 100], axis=[-1]), + dict(shape=[1, 100, 50, 1], axis=[0, 2]) + ] + + # TODO mark as precommit (after successfully passing in nightly) + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + def test_squeeze_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_squeeze_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_5D = [ + pytest.param(dict(shape=[1, 1, 50, 100, 224], axis=[]), marks=pytest.mark.xfail(reason="*-18807")), + pytest.param(dict(shape=[1, 1, 50, 100, 224], axis=[0]), marks=pytest.mark.xfail(reason="*-18879")), + pytest.param(dict(shape=[1, 1, 50, 100, 224], axis=[-1]), marks=pytest.mark.xfail(reason="*-18879")), + dict(shape=[1, 224, 1, 100, 1], axis=[0, 3]), + dict(shape=[1, 224, 1, 100, 1], axis=[0, 1, 3]), + dict(shape=[1, 224, 1, 1, 100], axis=[0, 1, 2]), + dict(shape=[1, 224, 1, 1, 1], axis=[0, 1, 2, 3]) + ] + + # TODO mark as precommit (after successfully passing in nightly) + @pytest.mark.special_xfail(args={'ie_device': 'GPU', 'precision': 'FP16', 'params': {'axis': [0, 3]}}, + reason="*-19394") + @pytest.mark.special_xfail(args={'ie_device': 'GPU', 'precision': 'FP16', 'params': {'axis': [0, 1, 3]}}, + reason="*-19394") + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.nightly + def test_squeeze_5D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_squeeze_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Sub.py b/tests/layer_tests/tensorflow_tests/test_tf_Sub.py new file mode 100644 index 00000000000000..00f63494255d5b --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_Sub.py @@ -0,0 +1,294 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from common.tf_layer_test_class import CommonTFLayerTest + + +class TestSub(CommonTFLayerTest): + def create_sub_placeholder_const_net(self, x_shape, y_shape, ir_version): + """ + Tensorflow net IR net + + Placeholder->Sub => Placeholder->Eltwise or Power or ScaleShift + / / + Const-------/ Const-------/ + + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + tf_x_shape = x_shape.copy() + tf_y_shape = y_shape.copy() + # reshaping + if len(tf_x_shape) >= 3: + tf_x_shape.append(tf_x_shape.pop(1)) + if len(tf_y_shape) >= 3: + tf_y_shape.append(tf_y_shape.pop(1)) + + x = tf.compat.v1.placeholder(tf.float32, tf_x_shape, 'Input') + constant_value = np.random.randint(-256, 256, tf_y_shape).astype(np.float32) + if (constant_value == 0).all(): + # Avoid elimination of the layer from IR + constant_value = constant_value + 1 + y = tf.constant(constant_value) + + sub = tf.subtract(x, y, name="Operation") + sub_shape = sub.shape.as_list() + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + if len(sub_shape) >= 3: + # Permute sub_shape to (N,C,...) format + order = [0, len(sub_shape) - 1] + list(range(1, len(sub_shape) - 1)) + sub_shape = [sub_shape[i] for i in order] + + y_shape_to_compare = tf_y_shape.copy() + while len(y_shape_to_compare) < len(x_shape): + # Expand shape of constant with 1 + y_shape_to_compare = [1] + y_shape_to_compare + constant_value = np.expand_dims(constant_value, axis=0) + + if len(y_shape_to_compare) >= 3: + # Permute constant_value to (N,C,...) format for correct further reshape + order = [0, len(y_shape_to_compare) - 1] + list(range(1, len(y_shape_to_compare) - 1)) + y_shape_to_compare = [y_shape_to_compare[i] for i in order] + constant_value = np.transpose(constant_value, order) + + ref_net = None + + return tf_net, ref_net + + # TODO: implement tests for 2 Consts + Sub + + test_data_1D = [ + # Power + dict(x_shape=[1], y_shape=[1]), + # Eltwise + pytest.param(dict(x_shape=[3], y_shape=[3]), marks=pytest.mark.xfail(reason="*-19180")) + ] + + @pytest.mark.parametrize("params", test_data_1D) + @pytest.mark.nightly + def test_sub_placeholder_const_1D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_sub_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, + temp_dir=temp_dir) + + test_data_2D = [ + # Power + dict(x_shape=[1, 1], y_shape=[1, 1]), + # ScaleShift + dict(x_shape=[1, 3], y_shape=[1, 3]), + # Eltwise + pytest.param(dict(x_shape=[3, 1], y_shape=[3, 1]), marks=pytest.mark.xfail(reason="*-19180")), + # Eltwise + dict(x_shape=[2, 3], y_shape=[2, 3]) + ] + + @pytest.mark.parametrize("params", test_data_2D) + @pytest.mark.nightly + def test_sub_placeholder_const_2D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_sub_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, + temp_dir=temp_dir) + + test_data_3D = [ + # Power + dict(x_shape=[1, 1, 1], y_shape=[1, 1, 1]), + # ScaleShift + pytest.param(dict(x_shape=[1, 3, 1], y_shape=[1, 3, 1]), marks=pytest.mark.xfail(reason="*-19053")), + # Eltwise + pytest.param(dict(x_shape=[1, 1, 3], y_shape=[1, 1, 3]), + marks=[pytest.mark.xfail(reason="*-19053"), pytest.mark.xfail(reason="*-18830")]), + # Eltwise + pytest.param(dict(x_shape=[1, 3, 224], y_shape=[1, 3, 224]), marks=pytest.mark.xfail(reason="*-19053")) + ] + + # TODO mark as precommit (after successfully passing in nightly) + @pytest.mark.parametrize("params", test_data_3D) + @pytest.mark.nightly + def test_sub_placeholder_const_3D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_sub_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, + temp_dir=temp_dir) + + test_data_4D = [ + # Power + dict(x_shape=[1, 1, 1, 1], y_shape=[1, 1, 1, 1]), + # ScaleShift + dict(x_shape=[1, 3, 1, 1], y_shape=[1, 3, 1, 1]), + # Eltwise + pytest.param(dict(x_shape=[1, 1, 1, 3], y_shape=[1, 1, 1, 3]), marks=pytest.mark.xfail(reason="*-19180")), + # Eltwise + dict(x_shape=[1, 3, 222, 224], y_shape=[1, 3, 222, 224]) + ] + + # TODO mark as precommit (after successfully passing in nightly) + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + def test_sub_placeholder_const_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_sub_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, + temp_dir=temp_dir) + + test_data_5D = [ + # Power + dict(x_shape=[1, 1, 1, 1, 1], y_shape=[1, 1, 1, 1, 1]), + # ScaleShift + dict(x_shape=[1, 3, 1, 1, 1], y_shape=[1, 3, 1, 1, 1]), + # Eltwise + pytest.param(dict(x_shape=[1, 1, 1, 1, 3], y_shape=[1, 1, 1, 1, 3]), + marks=pytest.mark.xfail(reason="*-19180")), + # Eltwise + dict(x_shape=[1, 3, 50, 100, 224], y_shape=[1, 3, 50, 100, 224]) + ] + + # TODO mark as precommit (after successfully passing in nightly) + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.nightly + def test_sub_placeholder_const_5D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_sub_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, + temp_dir=temp_dir) + + ############################################################################################### + # # + # Broadcast cases # + # # + ############################################################################################### + + test_data_broadcast_1D = [ # Power + dict(x_shape=[3], y_shape=[1]) + ] + + @pytest.mark.parametrize("params", test_data_broadcast_1D) + @pytest.mark.nightly + def test_sub_placeholder_const_broadcast_1D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_sub_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, + temp_dir=temp_dir) + + test_data_broadcast_2D = [ + # Power + dict(x_shape=[1, 1], y_shape=[1]), + # Power + dict(x_shape=[1, 3], y_shape=[1]), + # ScaleShift + dict(x_shape=[1, 3], y_shape=[3]), + # Eltwise + dict(x_shape=[3, 1], y_shape=[3]), + # Eltwise + pytest.param(dict(x_shape=[3, 1], y_shape=[1, 3, 1, 1]), marks=pytest.mark.xfail(reason="*-19051")) + ] + + @pytest.mark.parametrize("params", test_data_broadcast_2D) + @pytest.mark.nightly + def test_sub_placeholder_const_broadcast_2D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_sub_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, + temp_dir=temp_dir) + + test_data_broadcast_3D = [ + # Power + dict(x_shape=[1, 1, 1], y_shape=[1]), + # Power + pytest.param(dict(x_shape=[1, 3, 1], y_shape=[1]), marks=pytest.mark.xfail(reason="*-19053")), + # ScaleShift + pytest.param(dict(x_shape=[1, 3, 1], y_shape=[3]), marks=pytest.mark.xfail(reason="*-19053")), + # Eltwise + pytest.param(dict(x_shape=[1, 3, 1], y_shape=[3, 1]), marks=pytest.mark.xfail(reason="*-19053")), + # Eltwise + pytest.param(dict(x_shape=[1, 1, 1], y_shape=[3, 1]), marks=pytest.mark.xfail(reason="*-19053")), + # Eltwise + pytest.param(dict(x_shape=[3, 1, 224], y_shape=[1, 3, 224]), marks=pytest.mark.xfail(reason="*-19053")), + # Eltwise + pytest.param(dict(x_shape=[2, 3, 1], y_shape=[1, 3, 2]), marks=pytest.mark.xfail(reason="*-19053")), + ] + + # TODO mark as precommit (after successfully passing in nightly) + @pytest.mark.parametrize("params", test_data_broadcast_3D) + @pytest.mark.nightly + def test_sub_placeholder_const_broadcast_3D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_sub_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, + temp_dir=temp_dir) + + test_data_broadcast_4D = [ + # Power + dict(x_shape=[1, 1, 1, 1], y_shape=[1]), + # Power + dict(x_shape=[1, 3, 1, 1], y_shape=[1]), + # ScaleShift + dict(x_shape=[1, 3, 1, 1], y_shape=[3]), + # Eltwise + dict(x_shape=[1, 3, 100, 224], y_shape=[3]), + # Eltwise + dict(x_shape=[1, 1, 1, 3], y_shape=[3]), + # Eltwise + dict(x_shape=[1, 3, 1, 1], y_shape=[3, 1]), + # Eltwise + dict(x_shape=[1, 3, 1, 2], y_shape=[3, 1, 2]), + # Eltwise + dict(x_shape=[1, 3, 1, 2], y_shape=[1, 3, 2]), + # Eltwise + pytest.param(dict(x_shape=[1, 3, 100, 224], y_shape=[1, 1, 1, 224]), + marks=pytest.mark.xfail(reason="*-19180")), + # Eltwise + dict(x_shape=[2, 3, 1, 2], y_shape=[1, 3, 2, 1]) + ] + + # TODO mark as precommit (after successfully passing in nightly) + @pytest.mark.parametrize("params", test_data_broadcast_4D) + @pytest.mark.nightly + def test_sub_placeholder_const_broadcast_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_sub_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, + temp_dir=temp_dir) + + test_data_broadcast_5D = [ + # Power + dict(x_shape=[1, 1, 1, 1, 1], y_shape=[1, 1, 1, 1, 1]), + # Power + dict(x_shape=[1, 3, 1, 1, 1], y_shape=[1, 1]), + # ScaleShift + dict(x_shape=[1, 3, 1, 1, 1], y_shape=[3]), + # Eltwise + dict(x_shape=[1, 1, 1, 1, 3], y_shape=[3]), + # Eltwise + dict(x_shape=[1, 3, 1, 1, 1], y_shape=[3, 1]), + # Eltwise + dict(x_shape=[1, 3, 1, 1, 2], y_shape=[1, 3, 2]), + # Eltwise + dict(x_shape=[1, 3, 5, 1, 2], y_shape=[5, 3, 2, 1]), + # Eltwise + pytest.param(dict(x_shape=[1, 3, 50, 100, 224], y_shape=[1, 1, 1, 1, 224]), + marks=pytest.mark.xfail(reason="*-19180")), + # Eltwise + dict(x_shape=[2, 3, 1, 2, 1], y_shape=[1, 3, 2, 1, 1]) + ] + + # TODO mark as precommit (after successfully passing in nightly) + @pytest.mark.parametrize("params", test_data_broadcast_5D) + @pytest.mark.nightly + def test_sub_placeholder_const_broadcast_5D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_sub_placeholder_const_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, + temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Swish.py b/tests/layer_tests/tensorflow_tests/test_tf_Swish.py new file mode 100644 index 00000000000000..158a43353ac79c --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_Swish.py @@ -0,0 +1,88 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.layer_test_class import check_ir_version +from common.tf_layer_test_class import CommonTFLayerTest +from unit_tests.utils.graph import build_graph + + +class TestSwish(CommonTFLayerTest): + def create_swish_net(self, shape, ir_version): + """ + Tensorflow net IR net + + Input->Swish => Input->Swish + + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.reset_default_graph() + + # Create the graph and model + with tf.Session() as sess: + shapes = shape.copy() + # reshaping + if len(shapes) > 3: + shapes.append(shapes.pop(1)) + input = tf.placeholder(tf.float32, shapes, 'Input') + + tf.nn.swish(input) + + tf.global_variables_initializer() + tf_net = sess.graph_def + + # + # Create reference IR net + # Please, specify 'type': 'Input' for input node + # Moreover, do not forget to validate ALL layer attributes!!! + # + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'Swish': {'kind': 'op', 'type': 'Swish'}, + 'Swish_data': {'shape': shape, 'kind': 'data'}, + 'result': {'kind': 'op', 'type': 'Result'} + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'Swish'), + ('Swish', 'Swish_data'), + ('Swish_data', 'result') + ]) + + return tf_net, ref_net + + test_data_precommit = [ + pytest.param(dict(shape=[1, 3, 50, 100, 224]), + marks=pytest.mark.skip(reason="Skipped until fixed")) + ] + + @pytest.mark.parametrize("params", test_data_precommit) + @pytest.mark.precommit + def test_swish_precommit(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_swish_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data = [dict(shape=[1]), + dict(shape=[1, 224]), + dict(shape=[1, 3, 224]), + dict(shape=[1, 3, 100, 224]), + dict(shape=[1, 3, 50, 100, 224])] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_swish(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_swish_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_TopK.py b/tests/layer_tests/tensorflow_tests/test_tf_TopK.py new file mode 100644 index 00000000000000..c2d2fe54c07044 --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_TopK.py @@ -0,0 +1,143 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from common.layer_test_class import check_ir_version +from common.tf_layer_test_class import CommonTFLayerTest +from mo.ops.op import PermuteAttrs +from unit_tests.utils.graph import build_graph +from tensorflow_tests.permutation_utils import permute_nchw_to_nhwc, permute_axis + + +class Test_TopK(CommonTFLayerTest): + @staticmethod + def create_topK_net(shape, k, ir_version): + """ + Tensorflow net: + + |-> Values + Input -> TopK | + |-> Indices + + + IR net: + + |-> Values + Input -> TopK | + |-> Indices + + """ + + # + # Create Tensorflow model + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + shape_net = permute_nchw_to_nhwc(shape) + + input_tensor = tf.compat.v1.placeholder(tf.int32, shape=shape_net, name='Input') + values, indices = tf.nn.top_k(input_tensor, k=k, sorted=True, name='Operation') + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # + # Create reference IR net + # + topk_output_shape = shape.copy() + inverse_nhwc_nchw = PermuteAttrs.get_nhwc_to_nchw_permutation(len(topk_output_shape)).inv + topk_axis = permute_axis(len(topk_output_shape) - 1, inverse_nhwc_nchw) # we need to permute axis attribute + topk_output_shape[topk_axis] = k + + ref_net = None + + if check_ir_version(10, None, ir_version): + nodes_attributes = { + 'input': {'kind': 'op', 'type': 'Parameter'}, + 'input_data': {'shape': shape, 'kind': 'data'}, + 'Const_k_input_data': {'shape': [], 'kind': 'data'}, + 'Const_k': {'kind': 'op', 'type': 'Const'}, + 'Const_k_data': {'shape': [], 'kind': 'data'}, + 'TopK': {'kind': 'op', 'type': 'TopK', 'axis': topk_axis, 'mode': 'max', 'sort': 'value'}, + 'TopK_data_1': {'shape': topk_output_shape, 'kind': 'data'}, + 'TopK_data_2': {'shape': topk_output_shape, 'kind': 'data'}, + 'result_1': {'kind': 'op', 'type': 'Result'}, + 'result_2': {'kind': 'op', 'type': 'Result'}, + } + + ref_net = build_graph(nodes_attributes, + [('input', 'input_data'), + ('input_data', 'TopK', {'in': 0}), + + ('Const_k_input_data', 'Const_k'), + ('Const_k', 'Const_k_data'), + ('Const_k_data', 'TopK', {'in': 1}), + + ('TopK', 'TopK_data_1', {'out': 0}), + ('TopK', 'TopK_data_2', {'out': 1}), + ('TopK_data_1', 'result_1'), + ('TopK_data_2', 'result_2'), + ]) + + return tf_net, ref_net + + test_data_1D = [ + dict(shape=[15], k=10), + dict(shape=[15], k=5), + ] + + @pytest.mark.parametrize("params", test_data_1D) + @pytest.mark.nightly + def test_TopK_1D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_topK_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_2D = [ + dict(shape=[14, 15], k=10), + dict(shape=[14, 15], k=5), + ] + + @pytest.mark.parametrize("params", test_data_2D) + @pytest.mark.nightly + def test_TopK_2D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_topK_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_3D = [ + dict(shape=[13, 14, 15], k=10), + dict(shape=[13, 14, 15], k=5), + ] + + @pytest.mark.parametrize("params", test_data_3D) + @pytest.mark.nightly + def test_TopK_3D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_topK_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_4D = [ + dict(shape=[12, 13, 14, 15], k=10), + dict(shape=[12, 13, 14, 15], k=5), + ] + + @pytest.mark.parametrize("params", test_data_4D) + @pytest.mark.nightly + def test_TopK_4D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_topK_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) + + test_data_5D = [ + dict(shape=[11, 12, 13, 14, 15], k=10), + dict(shape=[11, 12, 13, 14, 15], k=5), + ] + + @pytest.mark.parametrize("params", test_data_5D) + @pytest.mark.nightly + def test_TopK_5D(self, params, ie_device, precision, ir_version, temp_dir): + self._test(*self.create_topK_net(**params, ir_version=ir_version), + ie_device, precision, ir_version, temp_dir=temp_dir) From 7b2779c406bcf00c42102a1faedd459ea70a7b45 Mon Sep 17 00:00:00 2001 From: Rafal Blaczkowski Date: Wed, 16 Jun 2021 12:25:06 +0200 Subject: [PATCH 107/178] cleanup improvement (#6186) --- .ci/openvino-onnx/Jenkinsfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.ci/openvino-onnx/Jenkinsfile b/.ci/openvino-onnx/Jenkinsfile index 5fe24928798f3d..ff2e8a451253c4 100644 --- a/.ci/openvino-onnx/Jenkinsfile +++ b/.ci/openvino-onnx/Jenkinsfile @@ -155,10 +155,9 @@ def getConfigurationsMap() { CONFIGURATION_WORKFLOW = { configuration -> node("OpenVINO") { + String workdir = "${HOME}/workspace/${BUILD_NUMBER}_${env.CHANGE_ID}_${configuration.name}" try { PROJECT_NAME = "openvino" - String workdir = "${HOME}/workspace/${BUILD_NUMBER}_${env.CHANGE_ID}_${configuration.name}" - stage("Clone repository") { prepare_repository(workdir) } @@ -185,10 +184,10 @@ CONFIGURATION_WORKFLOW = { configuration -> } finally { stage("Cleanup") { - deleteDir() String docker_container_name = get_docker_container_name(configuration) sh """ docker rm -f ${docker_container_name} + rm -rf ${workdir} """ } } From dc0d482c23432ba72367a84e4639faeb18c32ee5 Mon Sep 17 00:00:00 2001 From: Mateusz Tabaka Date: Wed, 16 Jun 2021 12:45:36 +0200 Subject: [PATCH 108/178] Add support for fp64 in Sqrt's evaluate method (#5913) It's required for t2t-vit models. --- ngraph/core/src/op/sqrt.cpp | 4 +++- ngraph/test/constant_folding.cpp | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ngraph/core/src/op/sqrt.cpp b/ngraph/core/src/op/sqrt.cpp index e706e4ae7c2157..339a8b74706d7c 100644 --- a/ngraph/core/src/op/sqrt.cpp +++ b/ngraph/core/src/op/sqrt.cpp @@ -57,6 +57,7 @@ namespace sqrtop NGRAPH_TYPE_CASE(evaluate_sqrt, u64, arg0, out, count); NGRAPH_TYPE_CASE(evaluate_sqrt, f16, arg0, out, count); NGRAPH_TYPE_CASE(evaluate_sqrt, f32, arg0, out, count); + NGRAPH_TYPE_CASE(evaluate_sqrt, f64, arg0, out, count); default: rc = false; break; } return rc; @@ -79,7 +80,8 @@ bool op::Sqrt::has_evaluate() const case ngraph::element::u32: case ngraph::element::u64: case ngraph::element::f16: - case ngraph::element::f32: return true; + case ngraph::element::f32: + case ngraph::element::f64: return true; default: break; } return false; diff --git a/ngraph/test/constant_folding.cpp b/ngraph/test/constant_folding.cpp index c34dcb12c6e0b7..d6b2d98ee9f25a 100644 --- a/ngraph/test/constant_folding.cpp +++ b/ngraph/test/constant_folding.cpp @@ -300,6 +300,7 @@ TEST(constant_folding, constant_unary_binary) auto g = make_shared(element::i32, Shape{2}, values_g); auto h = make_shared(element::boolean, Shape{2, 2}, values_h); auto i = make_shared(element::boolean, Shape{2}, values_i); + auto doubles = make_shared(element::f64, Shape{2}, std::vector{4.0, 9.0}); auto add = make_shared(a, b); auto sub = make_shared(a, b); @@ -328,6 +329,7 @@ TEST(constant_folding, constant_unary_binary) auto logical_or_autob_numpy = make_shared(h, i, op::AutoBroadcastType::NUMPY); auto logical_xor_autob_numpy = make_shared(h, i, op::AutoBroadcastType::NUMPY); + auto doubles_sqrt = make_shared(doubles); auto neg_sqrt = make_shared(c); @@ -355,7 +357,8 @@ TEST(constant_folding, constant_unary_binary) less_autob_numpy, less_eq_autob_numpy, logical_or_autob_numpy, - logical_xor_autob_numpy}, + logical_xor_autob_numpy, + doubles_sqrt}, ParameterVector{}); auto func_error = make_shared(NodeVector{neg_sqrt}, ParameterVector{}); @@ -388,6 +391,7 @@ TEST(constant_folding, constant_unary_binary) vector less_eq_autob_numpy_expected{1, 1, 0, 1}; vector logical_or_autob_numpy_expected{0, 1, 1, 1}; vector logical_xor_autob_numpy_expected{0, 1, 1, 0}; + vector doubles_sqrt_expected{2.0, 3.0}; ASSERT_EQ(get_result_constant(func, 0), add_expected); ASSERT_EQ(get_result_constant(func, 1), sub_expected); @@ -414,6 +418,7 @@ TEST(constant_folding, constant_unary_binary) ASSERT_EQ(get_result_constant(func, 22), less_eq_autob_numpy_expected); ASSERT_EQ(get_result_constant(func, 23), logical_or_autob_numpy_expected); ASSERT_EQ(get_result_constant(func, 24), logical_xor_autob_numpy_expected); + ASSERT_EQ(get_result_constant(func, 25), doubles_sqrt_expected); ASSERT_NO_THROW(pass_manager.run_passes(func_error)); } From d76d2674782d3c3bc83be7c06cfa7db42b804326 Mon Sep 17 00:00:00 2001 From: Mateusz Tabaka Date: Wed, 16 Jun 2021 12:46:33 +0200 Subject: [PATCH 109/178] Add support for fp64 in Convert's evaluate (#5911) It's required for t2t-vit models. --- ngraph/core/src/op/convert.cpp | 4 ++++ ngraph/test/constant_folding.cpp | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/ngraph/core/src/op/convert.cpp b/ngraph/core/src/op/convert.cpp index 4230c3a9afbe71..a920fec7729600 100644 --- a/ngraph/core/src/op/convert.cpp +++ b/ngraph/core/src/op/convert.cpp @@ -104,6 +104,7 @@ namespace convert TYPE_OUT_CASE(bf16, arg, out); TYPE_OUT_CASE(f16, arg, out); TYPE_OUT_CASE(f32, arg, out); + TYPE_OUT_CASE(f64, arg, out); TYPE_OUT_CASE(boolean, arg, out); default: rc = false; break; } @@ -129,6 +130,7 @@ namespace convert NGRAPH_TYPE_CASE(evaluate_convert, bf16, arg, out); NGRAPH_TYPE_CASE(evaluate_convert, f16, arg, out); NGRAPH_TYPE_CASE(evaluate_convert, f32, arg, out); + NGRAPH_TYPE_CASE(evaluate_convert, f64, arg, out); NGRAPH_TYPE_CASE(evaluate_convert, boolean, arg, out); default: rc = false; break; } @@ -200,6 +202,7 @@ bool op::v0::Convert::has_evaluate() const case ngraph::element::bf16: case ngraph::element::f16: case ngraph::element::f32: + case ngraph::element::f64: case ngraph::element::boolean: break; default: return false; } @@ -219,6 +222,7 @@ bool op::v0::Convert::has_evaluate() const case ngraph::element::bf16: case ngraph::element::f16: case ngraph::element::f32: + case ngraph::element::f64: case ngraph::element::boolean: break; default: return false; } diff --git a/ngraph/test/constant_folding.cpp b/ngraph/test/constant_folding.cpp index d6b2d98ee9f25a..0f5ce320531673 100644 --- a/ngraph/test/constant_folding.cpp +++ b/ngraph/test/constant_folding.cpp @@ -464,6 +464,16 @@ TEST(constant_folding, const_convert) vector expected{true, false, true, false, true, false, true}; test_const_convert(in, expected); } + { + vector in{1, 2, 3, 4, 5}; + vector expected{1.0, 2.0, 3.0, 4.0, 5.0}; + test_const_convert(in, expected); + } + { + vector in{1.2, 2.1, 3.3, 4.45, 5.02}; + vector expected{1, 2, 3, 4, 5}; + test_const_convert(in, expected); + } } TEST(constant_folding, shape_of_v0) From b05977a536bff6f618aabe8008bb43db23b3ea71 Mon Sep 17 00:00:00 2001 From: Alexandra Sidorova Date: Wed, 16 Jun 2021 14:14:50 +0300 Subject: [PATCH 110/178] [CPU][IE TESTS] Added more input shapes for Pooling tests (#6083) --- .../plugin/cpu/single_layer_tests/pooling.cpp | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/pooling.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/pooling.cpp index 0df9c464c4f5fd..6fb1f7d1169440 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/pooling.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/pooling.cpp @@ -105,6 +105,22 @@ const auto ref = CPUSpecificParams{{}, {}, {"ref_any"}, "ref_any"}; const std::vector vecCpuConfigs = {ref, sse42, avx, avx512}; const std::vector inpOutPrecision = {Precision::FP32, Precision::BF16}; +const std::vector> inputShapes4D = { + std::vector{3, 4, 64, 64}, + std::vector{2, 8, 8, 12}, + std::vector{1, 16, 16, 12}, + std::vector{1, 21, 8, 4}, + std::vector{1, 32, 8, 8}, +}; + +const std::vector> inputShapes5D = { + std::vector{1, 4, 16, 16, 16}, + std::vector{2, 8, 8, 8, 8}, + std::vector{2, 16, 12, 16, 20}, + std::vector{1, 19, 16, 20, 8}, + std::vector{1, 32, 16, 8, 12}, +}; + const std::vector paramsMax4D = { poolSpecificParams{ ngraph::helpers::PoolingTypes::MAX, {2, 2}, {2, 2}, {0, 0}, {0, 0}, ngraph::op::RoundingType::CEIL, ngraph::op::PadType::EXPLICIT, false }, @@ -137,7 +153,7 @@ INSTANTIATE_TEST_CASE_P(smoke_MaxPool_CPU_4D, PoolingLayerCPUTest, ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector({1, 3, 64, 64})), + ::testing::ValuesIn(inputShapes4D), ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigs)), ::testing::Values(emptyFusingSpec)), @@ -152,7 +168,7 @@ INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_4D, PoolingLayerCPUTest, ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector({1, 4, 64, 64})), + ::testing::ValuesIn(inputShapes4D), ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigs)), ::testing::Values(emptyFusingSpec)), @@ -167,7 +183,7 @@ INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_4D_NotOptimized, PoolingLayerCPUTest, ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector({1, 4, 64, 64})), + ::testing::ValuesIn(inputShapes4D), ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::Values(ref), ::testing::Values(emptyFusingSpec)), @@ -207,7 +223,7 @@ INSTANTIATE_TEST_CASE_P(smoke_MaxPool_CPU_5D, PoolingLayerCPUTest, ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector({1, 3, 16, 32, 32})), + ::testing::ValuesIn(inputShapes5D), ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigs)), ::testing::Values(emptyFusingSpec)), @@ -222,7 +238,7 @@ INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_5D, PoolingLayerCPUTest, ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector({1, 4, 32, 32, 32})), + ::testing::ValuesIn(inputShapes5D), ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigs)), ::testing::Values(emptyFusingSpec)), @@ -237,7 +253,7 @@ INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_5D_NotOptimized, PoolingLayerCPUTest, ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector({1, 4, 16, 16, 16})), + ::testing::ValuesIn(inputShapes5D), ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::Values(ref), ::testing::Values(emptyFusingSpec)), @@ -272,7 +288,7 @@ INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_4D_I8, PoolingLayerCPUTest, ::testing::Values(Precision::FP32), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector({1, 4, 64, 64})), + ::testing::ValuesIn(inputShapes4D), ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_4D)), ::testing::ValuesIn(fusingParamsSet)), @@ -287,7 +303,7 @@ INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_5D_I8, PoolingLayerCPUTest, ::testing::Values(Precision::FP32), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector({1, 4, 16, 16, 16})), + ::testing::ValuesIn(inputShapes5D), ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_5D)), ::testing::ValuesIn(fusingParamsSet)), From 5b847fabe842a9124efbfccb39655e73f4dac19b Mon Sep 17 00:00:00 2001 From: Egor Duplensky Date: Wed, 16 Jun 2021 14:42:26 +0300 Subject: [PATCH 111/178] [CPU] Refactor load_emitter_context semantic. Update store emitter (#5824) * [CPU] Refactor load_emitter_context semantic. Update store emitter New load_emitter_context constructor arguments order seems to be more convenient. Store emitter now emits bf16 emu. --- .../mkldnn_plugin/emitters/jit_load_store_emitters.cpp | 5 +++++ .../mkldnn_plugin/emitters/jit_load_store_emitters.hpp | 6 ++++-- .../src/mkldnn_plugin/nodes/mkldnn_mvn_node.cpp | 7 +++---- .../src/mkldnn_plugin/nodes/mkldnn_roi_pooling_node.cpp | 9 ++++----- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/inference-engine/src/mkldnn_plugin/emitters/jit_load_store_emitters.cpp b/inference-engine/src/mkldnn_plugin/emitters/jit_load_store_emitters.cpp index 83bc04c530db07..4d1e3819394fc8 100644 --- a/inference-engine/src/mkldnn_plugin/emitters/jit_load_store_emitters.cpp +++ b/inference-engine/src/mkldnn_plugin/emitters/jit_load_store_emitters.cpp @@ -510,6 +510,11 @@ size_t jit_store_emitter::aux_vecs_count() const { size_t jit_store_emitter::get_inputs_num() const { return 1; } +void jit_store_emitter::emit_data() const { + if (emu_vcvtneps2bf16) + emu_vcvtneps2bf16->emit_data(); +} + void jit_store_emitter::emit_impl(const std::vector &in_idxs, const std::vector &out_idxs, const std::vector &pool_vec_idxs, const std::vector &pool_gpr_idxs, const emitter_context *emit_context) const { diff --git a/inference-engine/src/mkldnn_plugin/emitters/jit_load_store_emitters.hpp b/inference-engine/src/mkldnn_plugin/emitters/jit_load_store_emitters.hpp index 00c2e49262d9a5..ec863d0c69e596 100644 --- a/inference-engine/src/mkldnn_plugin/emitters/jit_load_store_emitters.hpp +++ b/inference-engine/src/mkldnn_plugin/emitters/jit_load_store_emitters.hpp @@ -18,8 +18,8 @@ struct load_emitter_context : public emitter_context { load_emitter_context() : src_prc_(Precision::FP32), dst_prc_(Precision::FP32), load_num_(8), offset_byte_(0), is_fill_(false), fill_value_("zero") {} - load_emitter_context(Precision src_prc, Precision dst_prc, int load_num, bool is_fill = false, std::string fill_value = "zero", int offset_byte = 0): - src_prc_(src_prc), dst_prc_(dst_prc), load_num_(load_num), is_fill_(is_fill), fill_value_(fill_value), offset_byte_(offset_byte) {} + load_emitter_context(Precision src_prc, Precision dst_prc, int load_num, int offset_byte = 0, bool is_fill = false, std::string fill_value = "zero"): + src_prc_(src_prc), dst_prc_(dst_prc), load_num_(load_num), offset_byte_(offset_byte), is_fill_(is_fill), fill_value_(fill_value) {} int offset_byte_; int load_num_; @@ -124,6 +124,8 @@ class jit_store_emitter : public jit_emitter { size_t get_inputs_num() const override; + void emit_data() const override; + std::shared_ptr get_emu_vcvtneps2bf16() const { return emu_vcvtneps2bf16; } diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_mvn_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_mvn_node.cpp index f27a40e3bd255a..baff79e5d75317 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_mvn_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_mvn_node.cpp @@ -306,8 +306,8 @@ struct jit_uni_mvn_mean_variance_kernel_f32 : public jit_uni_mvn_mean_variance_k inline void worker_tail_planar() { Precision dst_prc = isFloatCompatible(jcp_.src_prc) ? Precision::FP32 : Precision::I32; load_emitter->emit_code({static_cast(reg_src.getIdx())}, {static_cast(vmm_val.getIdx())}, - std::make_shared(jcp_.src_prc, dst_prc, tail_num, true, "zero"), - {}, {load_pool_gpr_idxs}); + std::make_shared(jcp_.src_prc, dst_prc, tail_num, 0, true), + {}, {load_pool_gpr_idxs}); if (jcp_.normalize_variance) { if (!isFloatCompatible(jcp_.src_prc)) @@ -477,8 +477,7 @@ struct jit_uni_mvn_kernel_f32 : public jit_uni_mvn_kernel, public jit_generator this->postamble(); load_emitter->emit_data(); - if (!mayiuse(avx512_core_bf16) && mayiuse(avx512_core) && store_emitter != nullptr && store_emitter->get_emu_vcvtneps2bf16() != nullptr) - store_emitter->get_emu_vcvtneps2bf16()->emit_data(); + store_emitter->emit_data(); for (auto& inj : eltwise_injectors) inj->prepare_table(); diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_roi_pooling_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_roi_pooling_node.cpp index 77db762169254e..a1a7f8329a5c52 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_roi_pooling_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_roi_pooling_node.cpp @@ -88,8 +88,7 @@ struct jit_uni_roi_pooling_kernel_f32 : public jit_uni_roi_pooling_kernel, publi this->postamble(); load_emitter->emit_data(); - if (!mayiuse(avx512_core_bf16) && mayiuse(avx512_core) && store_emitter != nullptr && store_emitter->get_emu_vcvtneps2bf16() != nullptr) - store_emitter->get_emu_vcvtneps2bf16()->emit_data(); + store_emitter->emit_data(); } private: @@ -155,7 +154,7 @@ struct jit_uni_roi_pooling_kernel_f32 : public jit_uni_roi_pooling_kernel, publi Vmm vmm_max = get_acc_reg(i); load_emitter->emit_code({static_cast(reg_input.getIdx())}, {static_cast(vmm_max.getIdx())}, - std::make_shared(jpp_.src_prc, Precision::FP32, step, false, "zero", i * src_c_off), + std::make_shared(jpp_.src_prc, Precision::FP32, step, i * src_c_off), {}, load_pool_gpr_idxs); } @@ -169,7 +168,7 @@ struct jit_uni_roi_pooling_kernel_f32 : public jit_uni_roi_pooling_kernel, publi Vmm vmm_src = get_src_reg(i); load_emitter->emit_code({static_cast(aux_reg_input1.getIdx())}, {static_cast(vmm_src.getIdx())}, - std::make_shared(jpp_.src_prc, Precision::FP32, step, false, "zero", i * src_c_off), + std::make_shared(jpp_.src_prc, Precision::FP32, step, i * src_c_off), {}, load_pool_gpr_idxs); if (isa == cpu::x64::sse41) { @@ -222,7 +221,7 @@ struct jit_uni_roi_pooling_kernel_f32 : public jit_uni_roi_pooling_kernel, publi for (int i = 0; i < c_blocks; i++) { const int src_c_off = i * jpp_.ih * jpp_.iw * jpp_.c_block * jpp_.src_data_size; - const auto load_context = std::make_shared(jpp_.src_prc, Precision::FP32, step, false, "zero", src_c_off); + const auto load_context = std::make_shared(jpp_.src_prc, Precision::FP32, step, src_c_off); mov(aux_reg_input, reg_input); From 99ebda98f16f2290285f8c6673e039e3104c2687 Mon Sep 17 00:00:00 2001 From: Vladislav Volkov Date: Wed, 16 Jun 2021 15:54:40 +0300 Subject: [PATCH 112/178] [CPU] Memory leak in jit_uni_i8i8_pooling kernel (#6188) --- inference-engine/thirdparty/mkl-dnn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inference-engine/thirdparty/mkl-dnn b/inference-engine/thirdparty/mkl-dnn index 87516e47dae71f..e0381c369fc3be 160000 --- a/inference-engine/thirdparty/mkl-dnn +++ b/inference-engine/thirdparty/mkl-dnn @@ -1 +1 @@ -Subproject commit 87516e47dae71fc9c326d0f3685c1572c740e127 +Subproject commit e0381c369fc3bed487b0dcfef7e9fcb2e0aea575 From b1db3448e7b72fa54dbf60d26c7155f03a0baa7c Mon Sep 17 00:00:00 2001 From: Tomasz Jankowski Date: Wed, 16 Jun 2021 14:57:29 +0200 Subject: [PATCH 113/178] [ONNX] Extend ONNX Importer for operation "Einsum" (#6074) --- ngraph/frontend/onnx_import/src/op/einsum.cpp | 30 ++++++++++++ ngraph/frontend/onnx_import/src/op/einsum.hpp | 25 ++++++++++ .../frontend/onnx_import/src/ops_bridge.cpp | 2 + ngraph/python/tests/__init__.py | 4 +- .../python/tests/test_ngraph/test_einsum.py | 6 +-- ngraph/python/tests/test_onnx/test_backend.py | 15 +++--- ngraph/test/models/onnx/einsum_sum.prototxt | 47 +++++++++++++++++++ ngraph/test/onnx/onnx_import.in.cpp | 33 +++++++++++-- 8 files changed, 142 insertions(+), 20 deletions(-) create mode 100644 ngraph/frontend/onnx_import/src/op/einsum.cpp create mode 100644 ngraph/frontend/onnx_import/src/op/einsum.hpp create mode 100644 ngraph/test/models/onnx/einsum_sum.prototxt diff --git a/ngraph/frontend/onnx_import/src/op/einsum.cpp b/ngraph/frontend/onnx_import/src/op/einsum.cpp new file mode 100644 index 00000000000000..1d2a7a4edc997a --- /dev/null +++ b/ngraph/frontend/onnx_import/src/op/einsum.cpp @@ -0,0 +1,30 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "op/einsum.hpp" +#include "default_opset.hpp" + +namespace ngraph +{ + namespace onnx_import + { + namespace op + { + namespace set_1 + { + OutputVector einsum(const Node& node) + { + const std::string& equation{node.get_attribute_value("equation")}; + + return OutputVector{ + std::make_shared(node.get_ng_inputs(), equation)}; + } + + } // namespace set_1 + + } // namespace op + + } // namespace onnx_import + +} // namespace ngraph diff --git a/ngraph/frontend/onnx_import/src/op/einsum.hpp b/ngraph/frontend/onnx_import/src/op/einsum.hpp new file mode 100644 index 00000000000000..c9f87479ea0b9a --- /dev/null +++ b/ngraph/frontend/onnx_import/src/op/einsum.hpp @@ -0,0 +1,25 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "ngraph/node.hpp" +#include "onnx_import/core/node.hpp" + +namespace ngraph +{ + namespace onnx_import + { + namespace op + { + namespace set_1 + { + OutputVector einsum(const Node& node); + + } // namespace set_1 + } // namespace op + + } // namespace onnx_import + +} // namespace ngraph diff --git a/ngraph/frontend/onnx_import/src/ops_bridge.cpp b/ngraph/frontend/onnx_import/src/ops_bridge.cpp index f7864360ba7b43..0055b8afc4a4ca 100644 --- a/ngraph/frontend/onnx_import/src/ops_bridge.cpp +++ b/ngraph/frontend/onnx_import/src/ops_bridge.cpp @@ -42,6 +42,7 @@ #include "op/dequantize_linear.hpp" #include "op/div.hpp" #include "op/dropout.hpp" +#include "op/einsum.hpp" #include "op/elu.hpp" #include "op/equal.hpp" #include "op/erf.hpp" @@ -340,6 +341,7 @@ namespace ngraph REGISTER_OPERATOR("Dropout", 1, dropout); REGISTER_OPERATOR("Dropout", 7, dropout); REGISTER_OPERATOR("Dropout", 12, dropout); + REGISTER_OPERATOR("Einsum", 1, einsum); REGISTER_OPERATOR("Elu", 1, elu); REGISTER_OPERATOR("Equal", 1, equal); REGISTER_OPERATOR("Erf", 1, erf); diff --git a/ngraph/python/tests/__init__.py b/ngraph/python/tests/__init__.py index 817d4584534934..3bcf0d961fb3db 100644 --- a/ngraph/python/tests/__init__.py +++ b/ngraph/python/tests/__init__.py @@ -25,8 +25,6 @@ def xfail_test(reason="Mark the test as expected to fail", strict=True): skip_segfault = pytest.mark.skip(reason="Segmentation fault error") xfail_issue_33488 = xfail_test(reason="RuntimeError: nGraph does not support the following ONNX operations:" "MaxUnpool") -xfail_issue_33512 = xfail_test(reason="RuntimeError: nGraph does not support the following ONNX operations:" - "Einsum") xfail_issue_33535 = xfail_test(reason="nGraph does not support the following ONNX operations:" "DynamicQuantizeLinear") xfail_issue_33538 = xfail_test(reason="RuntimeError: nGraph does not support the following ONNX operations:" @@ -145,5 +143,5 @@ def xfail_test(reason="Mark the test as expected to fail", strict=True): xfail_issue_49754 = xfail_test(reason="RuntimeError: Unsupported dynamic ops: v1::TopKIE") xfail_issue_52463 = xfail_test(reason="test_operator_add_size1_singleton_broadcast_cpu - " "Not equal to tolerance") -xfail_issue_45432 = xfail_test(reason="Einsum is not implemented in CPU plugin.") +xfail_issue_58033 = xfail_test(reason="Einsum operation misses support for complex ellipsis equations") xfail_issue_onnx_models_140 = xfail_test(reason="https://github.com/onnx/models/issues/140") diff --git a/ngraph/python/tests/test_ngraph/test_einsum.py b/ngraph/python/tests/test_ngraph/test_einsum.py index a89b6c3ff35d89..fb7581d9160fa9 100644 --- a/ngraph/python/tests/test_ngraph/test_einsum.py +++ b/ngraph/python/tests/test_ngraph/test_einsum.py @@ -3,7 +3,7 @@ import pytest from ngraph.utils.types import get_element_type -from tests import xfail_issue_45432 +from tests import xfail_issue_58033 from tests.runtime import get_runtime @@ -86,13 +86,13 @@ def test_simple_ellipsis(data_type): einsum_op_exec([(5, 3, 4)], "a...->...", data_type) -@xfail_issue_45432 +@xfail_issue_58033 @pytest.mark.parametrize("data_type", [np.float32, np.int32]) def test_multiple_ellipsis(data_type): einsum_op_exec([(3, 5), 1], "a...,...->a...", data_type, with_value=True) -@xfail_issue_45432 +@xfail_issue_58033 @pytest.mark.parametrize("data_type", [np.float32, np.int32]) def test_broadcasting_ellipsis(data_type): einsum_op_exec([(9, 1, 4, 3), (3, 11, 7, 1)], "a...b,b...->a...", data_type, with_value=True) diff --git a/ngraph/python/tests/test_onnx/test_backend.py b/ngraph/python/tests/test_onnx/test_backend.py index a8ee1cbb065c6e..f8a1d99c900eab 100644 --- a/ngraph/python/tests/test_onnx/test_backend.py +++ b/ngraph/python/tests/test_onnx/test_backend.py @@ -9,7 +9,6 @@ from tests import (BACKEND_NAME, xfail_issue_33488, - xfail_issue_33512, xfail_issue_33535, xfail_issue_33538, xfail_issue_33581, @@ -59,7 +58,9 @@ xfail_issue_49753, xfail_issue_49754, xfail_issue_52463, - xfail_issue_55760) + xfail_issue_55760, + xfail_issue_58033, + ) def expect_fail(test_case_path, xfail): # type: (str) -> None @@ -285,12 +286,6 @@ def expect_fail(test_case_path, xfail): # type: (str) -> None "OnnxBackendNodeModelTest.test_qlinearconv_cpu"), (xfail_issue_38724, "OnnxBackendNodeModelTest.test_resize_tf_crop_and_resize_cpu"), - (xfail_issue_33512, - "OnnxBackendNodeModelTest.test_einsum_transpose_cpu", - "OnnxBackendNodeModelTest.test_einsum_batch_diagonal_cpu", - "OnnxBackendNodeModelTest.test_einsum_batch_matmul_cpu", - "OnnxBackendNodeModelTest.test_einsum_sum_cpu", - "OnnxBackendNodeModelTest.test_einsum_inner_prod_cpu"), (xfail_issue_33606, "OnnxBackendNodeModelTest.test_det_2d_cpu", "OnnxBackendNodeModelTest.test_det_nd_cpu"), @@ -368,7 +363,9 @@ def expect_fail(test_case_path, xfail): # type: (str) -> None "OnnxBackendNodeModelTest.test_quantizelinear_cpu"), (xfail_issue_33593, "OnnxBackendNodeModelTest.test_maxpool_with_argmax_2d_precomputed_strides_cpu", - "OnnxBackendNodeModelTest.test_maxpool_with_argmax_2d_precomputed_pads_cpu",) + "OnnxBackendNodeModelTest.test_maxpool_with_argmax_2d_precomputed_pads_cpu",), + (xfail_issue_58033, + "OnnxBackendNodeModelTest.test_einsum_batch_diagonal_cpu"), ] for test_group in tests_expected_to_fail: diff --git a/ngraph/test/models/onnx/einsum_sum.prototxt b/ngraph/test/models/onnx/einsum_sum.prototxt new file mode 100644 index 00000000000000..0f56b47d3abfe3 --- /dev/null +++ b/ngraph/test/models/onnx/einsum_sum.prototxt @@ -0,0 +1,47 @@ +ir_version: 7 +producer_name: "backend-test" +graph { + node { + input: "x" + output: "y" + op_type: "Einsum" + attribute { + name: "equation" + s: "ij->i" + type: STRING + } + } + name: "test_einsum_sum" + input { + name: "x" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 3 + } + dim { + dim_value: 4 + } + } + } + } + } + output { + name: "y" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 3 + } + } + } + } + } +} +opset_import { + version: 12 +} diff --git a/ngraph/test/onnx/onnx_import.in.cpp b/ngraph/test/onnx/onnx_import.in.cpp index 849a015c4c3807..943d6b90ca1b2e 100644 --- a/ngraph/test/onnx/onnx_import.in.cpp +++ b/ngraph/test/onnx/onnx_import.in.cpp @@ -4615,18 +4615,18 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_constant_sparse_tensor_float_8x17) 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f}); test_case.run(); -} - +} + NGRAPH_TEST(${BACKEND_NAME}, onnx_constant_sparse_tensor_float_2x3x4) { auto function = onnx_import::import_onnx_model( file_util::path_join(SERIALIZED_ZOO, "onnx/constant_sparse_tensor_float_2x3x4.prototxt")); auto test_case = test::TestCase(function); - test_case.add_expected_output(Shape{2, 3, 4}, {1.f, 0.f, 0.f, 8.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 3.f, 0.f, + test_case.add_expected_output(Shape{2, 3, 4}, {1.f, 0.f, 0.f, 8.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 3.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 3.f, 0.f}); test_case.run(); -} +} NGRAPH_TEST(${BACKEND_NAME}, onnx_constant_sparse_tensor_float_2x2x3x4) { @@ -4636,7 +4636,30 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_constant_sparse_tensor_float_2x2x3x4) auto test_case = test::TestCase(function); test_case.add_expected_output(Shape{2, 2, 3, 4}, {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 2.f, 3.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 0.f, - 0.f, 0.f, 0.f, 8.f, 0.f, 1.f, 2.f, 0.f, 0.f, 0.f, 3.f, 0.f, + 0.f, 0.f, 0.f, 8.f, 0.f, 1.f, 2.f, 0.f, 0.f, 0.f, 3.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 2.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f}); test_case.run(); } + +NGRAPH_TEST(${BACKEND_NAME}, onnx_einsum_sum) +{ + auto function = onnx_import::import_onnx_model( + file_util::path_join(SERIALIZED_ZOO, "onnx/einsum_sum.prototxt")); + auto test_case = test::TestCase(function); + test_case.add_input(Shape{3, 4}, + {1.764052345967664, + 0.4001572083672233, + 0.9787379841057392, + 2.240893199201458, + 1.8675579901499675, + -0.977277879876411, + 0.9500884175255894, + -0.1513572082976979, + -0.10321885179355784, + 0.41059850193837233, + 0.144043571160878, + 1.454273506962975}); + test_case.add_expected_output( + Shape{3}, {5.3838407376420845, 1.689011319501448, 1.9056967282686674}); + test_case.run(); +} From 2c775d48b27e3148769ce9998d48e75642c019a4 Mon Sep 17 00:00:00 2001 From: Gleb Kazantaev Date: Wed, 16 Jun 2021 16:02:57 +0300 Subject: [PATCH 114/178] Remove Pruning from MO (#6191) --- .../src/offline_transformations/src/moc_transformations.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/inference-engine/src/offline_transformations/src/moc_transformations.cpp b/inference-engine/src/offline_transformations/src/moc_transformations.cpp index 35f4a575c15c74..745e173b4d765d 100644 --- a/inference-engine/src/offline_transformations/src/moc_transformations.cpp +++ b/inference-engine/src/offline_transformations/src/moc_transformations.cpp @@ -12,9 +12,5 @@ NGRAPH_RTTI_DEFINITION(ngraph::pass::MOCTransformations, "MOCTransformations", 0); bool ngraph::pass::MOCTransformations::run_on_function(std::shared_ptr f) { - ngraph::pass::Manager m(get_pass_config()); - m.register_pass(); - m.run_passes(f); - return false; } \ No newline at end of file From 5c55d390e82ba055bb09e7366b4a105180c46c0e Mon Sep 17 00:00:00 2001 From: Elizaveta Lobanova Date: Wed, 16 Jun 2021 16:19:21 +0300 Subject: [PATCH 115/178] [GNA] Allow 2d reshape of the first diagonal layer (#6115) --- inference-engine/src/gna_plugin/gna_groups.hpp | 7 ------- .../src/gna_plugin/optimizer/gna_pass_manager.cpp | 5 ++--- .../gna/pass_tests/convert_matmul_to_pointwise_conv.cpp | 3 +-- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/inference-engine/src/gna_plugin/gna_groups.hpp b/inference-engine/src/gna_plugin/gna_groups.hpp index 2449338821c109..704588a153d039 100644 --- a/inference-engine/src/gna_plugin/gna_groups.hpp +++ b/inference-engine/src/gna_plugin/gna_groups.hpp @@ -52,13 +52,6 @@ inline bool HasTo2DReshapeData(InferenceEngine::CNNLayerPtr layer) { if (!GNAPluginNS::LayerInfo(layer).isSyntheticScaleShift()) return false; - // Don't reshape the first dnn layer since it breaks groups recognition - auto prevLayer = InferenceEngine::CNNNetPrevLayerSkipCertain(layer, 0, [](InferenceEngine::CNNLayerPtr ptr) { - return LayerInfo(ptr).isNonValuesChangable(); - }); - IE_ASSERT(prevLayer != nullptr); - if (LayerInfo(prevLayer).isInput()) return false; - // Don't reshape diagonallayers with bias connection return !GNAPluginNS::LayerInfo(getCreatorLayer(layer->insData.front().lock()).lock()).has32BOutput(); } diff --git a/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp b/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp index b8962cebd36e23..ef333e7e46f115 100644 --- a/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp +++ b/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp @@ -85,9 +85,8 @@ static void insertDiagonalLayerBetween(InferenceEngine::CNNLayerPtr prevLayer, return LayerInfo(ptr).isNonValuesChangable(); }); IE_ASSERT(inputLayer != nullptr); - size_t weightsSize = (LayerInfo(prevLayer).has32BOutput() || LayerInfo(inputLayer).isInput()) ? - nextLayer->outData[0]->getDims().back() : - Get2DReshapedData(nextLayer->outData[0], 8)->getDims()[1]; + size_t weightsSize = LayerInfo(prevLayer).has32BOutput() ? nextLayer->outData[0]->getDims().back() : + Get2DReshapedData(nextLayer->outData[0], 8)->getDims()[1]; std::vector weightsValues(weightsSize, fillValue); IE_ASSERT(diagLayer != nullptr); diagLayer->_weights = make_shared_blob( diff --git a/inference-engine/tests/functional/plugin/gna/pass_tests/convert_matmul_to_pointwise_conv.cpp b/inference-engine/tests/functional/plugin/gna/pass_tests/convert_matmul_to_pointwise_conv.cpp index 7e3d15174f3e5f..86bfe5e25c013a 100644 --- a/inference-engine/tests/functional/plugin/gna/pass_tests/convert_matmul_to_pointwise_conv.cpp +++ b/inference-engine/tests/functional/plugin/gna/pass_tests/convert_matmul_to_pointwise_conv.cpp @@ -217,8 +217,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ConvertMatmulToPointwiseConvTest, ConvertMatmulToP ::testing::ValuesIn(inputShape)), ConvertMatmulToPointwiseConv::getTestCaseName); -// Issue 55662 -INSTANTIATE_TEST_CASE_P(DISABLED_smoke_ConvertMatmulToPointwiseConvTest, ConvertMatmulToPointwiseConvWithFq, +INSTANTIATE_TEST_CASE_P(smoke_ConvertMatmulToPointwiseConvTest, ConvertMatmulToPointwiseConvWithFq, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), From b8313c4fae5a794508b0808145182fe2dd62caea Mon Sep 17 00:00:00 2001 From: Taylor Yeonbok Lee Date: Wed, 16 Jun 2021 23:47:08 +0900 Subject: [PATCH 116/178] [IE CLDNN] Disable crop optimization only when the node is inside a loop body program (#6192) --- .../src/graph_optimizer/prepare_buffer_fusing.cpp | 2 +- .../thirdparty/clDNN/src/include/loop_inst.h | 2 +- .../thirdparty/clDNN/src/include/program_impl.h | 8 ++++++-- inference-engine/thirdparty/clDNN/src/program.cpp | 11 +++++++---- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/inference-engine/thirdparty/clDNN/src/graph_optimizer/prepare_buffer_fusing.cpp b/inference-engine/thirdparty/clDNN/src/graph_optimizer/prepare_buffer_fusing.cpp index eebd65149ad27a..c57e72ad5f4a4e 100644 --- a/inference-engine/thirdparty/clDNN/src/graph_optimizer/prepare_buffer_fusing.cpp +++ b/inference-engine/thirdparty/clDNN/src/graph_optimizer/prepare_buffer_fusing.cpp @@ -283,7 +283,7 @@ void prepare_buffer_fusing::run(program_impl& p) { } if (node.get_dependencies().size() == 1 && node.get_users().size() > 0) { - if (node.get_dependency(0).is_type()) { + if (p.is_loop_body() && node.get_dependency(0).is_type()) { return; } // optimization is available for cropping across depth(features) only diff --git a/inference-engine/thirdparty/clDNN/src/include/loop_inst.h b/inference-engine/thirdparty/clDNN/src/include/loop_inst.h index e39bb90f43185a..08e7d416d441ea 100644 --- a/inference-engine/thirdparty/clDNN/src/include/loop_inst.h +++ b/inference-engine/thirdparty/clDNN/src/include/loop_inst.h @@ -266,7 +266,7 @@ struct typed_program_node : public typed_program_node_base { auto opts = get_program().get_options(); std::vector output_names_vec(output_names.begin(), output_names.end()); opts.set_option(build_option::outputs(output_names_vec)); - body_program = program_impl::build_program(get_program().get_engine(), body, opts, false); + body_program = program_impl::build_program(get_program().get_engine(), body, opts, false, false, true); } const primitive_id& get_trip_count_id() const { return get_primitive()->trip_count_id; } diff --git a/inference-engine/thirdparty/clDNN/src/include/program_impl.h b/inference-engine/thirdparty/clDNN/src/include/program_impl.h index fe8c8cb55f2795..df45537f00ad91 100644 --- a/inference-engine/thirdparty/clDNN/src/include/program_impl.h +++ b/inference-engine/thirdparty/clDNN/src/include/program_impl.h @@ -138,7 +138,8 @@ struct program_impl { topology_impl const& topology, build_options const& options, bool is_internal, - bool no_optimizations = false); + bool no_optimizations = false, + bool is_body_program = false); /* constructor used to build a program from subset of nodes of other program (used in propagate_constants) */ program_impl(engine& engine_ref, std::set> const& nodes, @@ -153,6 +154,7 @@ struct program_impl { std::vector& get_outputs() { return outputs; } // ToDo: redesign reorder-inputs pass to make it const as_well as get_engine and get options + bool is_loop_body() const { return is_body_program; } bool is_debug_build() const { return options.get()->enabled(); } const nodes_ordering& get_processing_order() const; nodes_ordering& get_processing_order(); @@ -228,7 +230,8 @@ struct program_impl { const topology_impl& topology, const build_options& options, bool is_internal = false, - bool no_optimizations = false); + bool no_optimizations = false, + bool is_body_program = false); static ptr build_program(engine& engine, const std::set>& nodes, const build_options& options, @@ -253,6 +256,7 @@ struct program_impl { nodes_ordering processing_order; std::unique_ptr pm; std::shared_ptr tuning_cache; + bool is_body_program; std::map> nodes_map; diff --git a/inference-engine/thirdparty/clDNN/src/program.cpp b/inference-engine/thirdparty/clDNN/src/program.cpp index ec59a526be0ac8..1bd903640287cd 100644 --- a/inference-engine/thirdparty/clDNN/src/program.cpp +++ b/inference-engine/thirdparty/clDNN/src/program.cpp @@ -84,13 +84,15 @@ program_impl::program_impl(engine& engine_ref, topology_impl const& topology, build_options const& options, bool is_internal, - bool no_optimizations) + bool no_optimizations, + bool is_body_program) : _engine(engine_ref), _stream(_engine.create_stream()), program_state(_engine), options(options), processing_order(), - tuning_cache(nullptr) { + tuning_cache(nullptr), + is_body_program(is_body_program) { init_primitives(); kernel_selector::KernelBase::ResetCounter(); set_options(); @@ -163,8 +165,9 @@ program_impl::ptr program_impl::build_program(engine& engine, const topology_impl& topology, const build_options& options, bool is_internal, - bool no_optimizations) { - return std::make_shared(engine, topology, options, is_internal, no_optimizations); + bool no_optimizations, + bool is_body_program) { + return std::make_shared(engine, topology, options, is_internal, no_optimizations, is_body_program); } program_impl::ptr program_impl::build_program(engine& engine, From db67c1b2b99f36f5ac46713c41b518db25cac1c0 Mon Sep 17 00:00:00 2001 From: Gabriele Galiero Casay Date: Wed, 16 Jun 2021 17:11:25 +0200 Subject: [PATCH 117/178] Add reduce operations to script with trusted ops (#6200) --- .../layer_tests_summary/utils/constants.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py index 7e193c2d790df0..8309b0e85935c0 100644 --- a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py +++ b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py @@ -66,7 +66,12 @@ 'ReadValue-6', 'ReduceL1-4', 'ReduceL2-4', + 'ReduceLogicalAnd-1', + 'ReduceLogicalOr-1', + 'ReduceMax-1', 'ReduceMean-1', + 'ReduceMin-1', + 'ReduceProd-1', 'ReduceSum-1', 'RegionYOLO-1', 'Relu-1', From f9771253ae3de75bb666f8b6c2d82b542080861f Mon Sep 17 00:00:00 2001 From: Jozef Daniecki Date: Thu, 17 Jun 2021 07:47:35 +0200 Subject: [PATCH 118/178] VariadicSplit revision (#6106) * Add visitor tests for VariadicSplit. * Add backend tests sceleton. * Add backend unit tests. * Add backend tests with dynamic function. * Remove redundand headers. * Modified backend tests to check also scalar axis. * Remove unused headers. * Changed backend tests to test `-1` value in split_lenghts tensor. * Const correctness improved in validate_and_infer_types. * Add VariadicSplit to summarize.py. --- .../layer_tests_summary/utils/constants.py | 3 +- .../core/include/ngraph/op/variadic_split.hpp | 2 - ngraph/core/src/op/variadic_split.cpp | 29 +- ngraph/test/CMakeLists.txt | 2 + ngraph/test/backend/variadic_split.in.cpp | 360 ++++++++++++++++++ ngraph/test/runtime/ie/unit_test.manifest | 7 + ngraph/test/visitors/op/variadic_split.cpp | 32 ++ 7 files changed, 416 insertions(+), 19 deletions(-) create mode 100644 ngraph/test/backend/variadic_split.in.cpp create mode 100644 ngraph/test/visitors/op/variadic_split.cpp diff --git a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py index 8309b0e85935c0..cdbcdcf6c54ae8 100644 --- a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py +++ b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py @@ -94,5 +94,6 @@ 'TopK-1', 'TopK-3', 'Transpose-1', - 'Unsqueeze-1' + 'Unsqueeze-1', + 'VariadicSplit-1', ] diff --git a/ngraph/core/include/ngraph/op/variadic_split.hpp b/ngraph/core/include/ngraph/op/variadic_split.hpp index 4293270fcbe344..fbff40bc21ac62 100644 --- a/ngraph/core/include/ngraph/op/variadic_split.hpp +++ b/ngraph/core/include/ngraph/op/variadic_split.hpp @@ -4,9 +4,7 @@ #pragma once -#include "ngraph/coordinate.hpp" #include "ngraph/op/op.hpp" -#include "ngraph/strides.hpp" namespace ngraph { diff --git a/ngraph/core/src/op/variadic_split.cpp b/ngraph/core/src/op/variadic_split.cpp index 505584ec6e1bc2..4b3cf710bc66a5 100644 --- a/ngraph/core/src/op/variadic_split.cpp +++ b/ngraph/core/src/op/variadic_split.cpp @@ -5,13 +5,9 @@ #include #include "itt.hpp" -#include "ngraph/op/constant.hpp" -#include "ngraph/op/util/op_types.hpp" #include "ngraph/op/variadic_split.hpp" -#include "ngraph/validation_util.hpp" - -#include "ngraph/runtime/host_tensor.hpp" #include "ngraph/runtime/reference/slice.hpp" +#include "ngraph/validation_util.hpp" using namespace std; using namespace ngraph; @@ -49,11 +45,11 @@ void ngraph::op::v1::VariadicSplit::validate_and_infer_types() split_lengths_pshape.rank(), " instead."); - auto num_outputs = split_lengths_pshape[0].get_length(); - auto data = input_value(0); - auto axis_source = input_value(1); - auto split_lengths_source = input_value(2); - auto data_shape = data.get_partial_shape(); + const auto num_outputs = split_lengths_pshape[0].get_length(); + const auto data = input_value(0); + const auto axis_source = input_value(1); + const auto split_lengths_source = input_value(2); + const auto data_shape = data.get_partial_shape(); const auto& data_type = data.get_element_type(); set_output_size(num_outputs); @@ -61,9 +57,9 @@ void ngraph::op::v1::VariadicSplit::validate_and_infer_types() const auto& split_lengths_constant = get_constant_from_source(split_lengths_source); if (data_shape.rank().is_static() && axis_input_constant && split_lengths_constant) { - auto axis_val = axis_input_constant->cast_vector()[0]; + const auto axis_val = axis_input_constant->cast_vector()[0]; // Adjust split axis in case of negatives - int64_t axis = ngraph::normalize_axis(this, axis_val, data_shape.rank()); + const int64_t axis = ngraph::normalize_axis(this, axis_val, data_shape.rank()); auto split_lengths = split_lengths_constant->cast_vector(); // Adjust split lengths in case of negatives @@ -92,8 +88,8 @@ void ngraph::op::v1::VariadicSplit::validate_and_infer_types() sum_of_splits += split_lengths[i]; } } - auto data_shape_dims = vector{data.get_partial_shape()}; - auto dimension_at_axis = data_shape_dims.at(axis); + const auto data_shape_dims = vector{data.get_partial_shape()}; + const auto dimension_at_axis = data_shape_dims.at(axis); if (negative_one >= 0 && dimension_at_axis.is_static()) { @@ -112,8 +108,9 @@ void ngraph::op::v1::VariadicSplit::validate_and_infer_types() for (int64_t output{0}; output < num_outputs; ++output) { - auto output_split_dim = split_lengths.at(output) == -1 ? Dimension::dynamic() - : split_lengths.at(output); + const auto output_split_dim = split_lengths.at(output) == -1 + ? Dimension::dynamic() + : split_lengths.at(output); auto tmp_shape = data_shape_dims; tmp_shape.at(axis) = output_split_dim; set_output_type(output, data_type, PartialShape{tmp_shape}); diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index ca45c965c9ffa3..efeb68e670ec94 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -288,6 +288,7 @@ set(SRC visitors/op/topk.cpp visitors/op/transpose.cpp visitors/op/unsqueeze.cpp + visitors/op/variadic_split.cpp uint4.cpp util.cpp ) @@ -466,6 +467,7 @@ set(MULTI_TEST_SRC backend/unhandled_op.in.cpp backend/unsqueeze.in.cpp backend/validate_call.in.cpp + backend/variadic_split.in.cpp backend/zero_sized.in.cpp ) diff --git a/ngraph/test/backend/variadic_split.in.cpp b/ngraph/test/backend/variadic_split.in.cpp new file mode 100644 index 00000000000000..d582d567550270 --- /dev/null +++ b/ngraph/test/backend/variadic_split.in.cpp @@ -0,0 +1,360 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "util/engine/test_engines.hpp" +#include "util/test_case.hpp" +#include "util/test_control.hpp" + +using namespace std; +using namespace ngraph; + +static string s_manifest = "${MANIFEST}"; +using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); + +namespace +{ + template + std::shared_ptr StaticVariadicSplit(ngraph::element::Type_t inputs_type, + Shape data_shape, + Shape axis_shape, + Shape split_lenghts_shape, + std::vector axis_value, + std::vector split_lenghts_value) + { + const auto data = make_shared(inputs_type, data_shape); + const auto axis = op::Constant::create(inputs_type, axis_shape, axis_value); + const auto split_lengths = + op::Constant::create(inputs_type, split_lenghts_shape, split_lenghts_value); + const auto variadic_split = make_shared(data, axis, split_lengths); + return make_shared(variadic_split, ParameterVector{data}); + } + + std::shared_ptr DynamicVariadicSplit(ngraph::element::Type_t inputs_type, + Shape data_shape, + Shape axis_shape, + Shape split_lenghts_shape) + { + const auto data = make_shared(inputs_type, data_shape); + const auto axis = make_shared(inputs_type, axis_shape); + const auto split_lengths = make_shared(inputs_type, split_lenghts_shape); + const auto variadic_split = make_shared(data, axis, split_lengths); + return make_shared(variadic_split, ParameterVector{data, axis, split_lengths}); + } +} // namespace + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_1d_static) +{ + const Shape data_shape{10}; + const std::vector data{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + const Shape axis_shape{1}; + const std::vector axis_value{0}; + const Shape split_lenghts_shape{3}; + const std::vector split_lenghts{5, 3, 2}; + + auto test_case = test::TestCase(StaticVariadicSplit( + element::i32, data_shape, axis_shape, split_lenghts_shape, axis_value, split_lenghts)); + + test_case.add_input(data_shape, data); + test_case.add_expected_output(Shape{5}, {1, 2, 3, 4, 5}); + test_case.add_expected_output(Shape{3}, {6, 7, 8}); + test_case.add_expected_output(Shape{2}, {9, 10}); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_1d_dynamic) +{ + const Shape data_shape{10}; + const std::vector data{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + const Shape axis_shape{1}; + const std::vector axis_value{0}; + const Shape split_lenghts_shape{3}; + const std::vector split_lenghts{5, 3, 2}; + + const auto f = DynamicVariadicSplit(element::i32, data_shape, axis_shape, split_lenghts_shape); + auto test_case = test::TestCase(f); + + test_case.add_input(data_shape, data); + test_case.add_input(axis_shape, axis_value); + test_case.add_input(split_lenghts_shape, split_lenghts); + test_case.add_expected_output(Shape{5}, {1, 2, 3, 4, 5}); + test_case.add_expected_output(Shape{3}, {6, 7, 8}); + test_case.add_expected_output(Shape{2}, {9, 10}); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_2d_axis_0_static) +{ + const Shape data_shape{6, 2}; + const std::vector data{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; + const Shape axis_shape{}; // scalar + const std::vector axis_value{0}; + const Shape split_lenghts_shape{2}; + const std::vector split_lenghts{4, 2}; + + auto test_case = test::TestCase(StaticVariadicSplit( + element::i32, data_shape, axis_shape, split_lenghts_shape, axis_value, split_lenghts)); + + test_case.add_input(data_shape, data); + test_case.add_expected_output(Shape{4, 2}, {1, 2, 3, 4, 5, 6, 7, 8}); + test_case.add_expected_output(Shape{2, 2}, {9, 10, 11, 12}); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_2d_axis_0_dynamic) +{ + const Shape data_shape{6, 2}; + const std::vector data{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; + const Shape axis_shape{}; // scalar + const std::vector axis_value{0}; + const Shape split_lenghts_shape{2}; + const std::vector split_lenghts{4, 2}; + + auto test_case = test::TestCase( + DynamicVariadicSplit(element::i32, data_shape, axis_shape, split_lenghts_shape)); + + test_case.add_input(data_shape, data); + test_case.add_input(axis_shape, axis_value); + test_case.add_input(split_lenghts_shape, split_lenghts); + test_case.add_expected_output(Shape{4, 2}, {1, 2, 3, 4, 5, 6, 7, 8}); + test_case.add_expected_output(Shape{2, 2}, {9, 10, 11, 12}); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_2d_axis_1_static) +{ + const Shape data_shape{4, 3}; + const std::vector data{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; + const Shape axis_shape{}; // scalar + const std::vector axis_value{1}; + const Shape split_lenghts_shape{2}; + const std::vector split_lenghts{1, 2}; + + auto test_case = test::TestCase(StaticVariadicSplit( + element::i32, data_shape, axis_shape, split_lenghts_shape, axis_value, split_lenghts)); + + test_case.add_input(data_shape, data); + test_case.add_expected_output(Shape{4, 1}, {1, 4, 7, 10}); + test_case.add_expected_output(Shape{4, 2}, {2, 3, 5, 6, 8, 9, 11, 12}); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_2d_axis_1_dynamic) +{ + const Shape data_shape{4, 3}; + const std::vector data{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; + const Shape axis_shape{}; // scalar + const std::vector axis_value{1}; + const Shape split_lenghts_shape{2}; + const std::vector split_lenghts{1, 2}; + + auto test_case = test::TestCase( + DynamicVariadicSplit(element::i32, data_shape, axis_shape, split_lenghts_shape)); + + test_case.add_input(data_shape, data); + test_case.add_input(axis_shape, axis_value); + test_case.add_input(split_lenghts_shape, split_lenghts); + test_case.add_expected_output(Shape{4, 1}, {1, 4, 7, 10}); + test_case.add_expected_output(Shape{4, 2}, {2, 3, 5, 6, 8, 9, 11, 12}); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_4d_axis_0_static) +{ + const Shape data_shape{6, 2, 3, 1}; + std::vector data(shape_size(data_shape)); + std::iota(data.begin(), data.end(), 0); + const Shape axis_shape{1}; + const std::vector axis_value{0}; + const Shape split_lenghts_shape{3}; + const std::vector split_lenghts{3, 1, 2}; + + auto test_case = test::TestCase(StaticVariadicSplit( + element::i32, data_shape, axis_shape, split_lenghts_shape, axis_value, split_lenghts)); + + test_case.add_input(data_shape, data); + test_case.add_expected_output( + Shape{3, 2, 3, 1}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}); + test_case.add_expected_output(Shape{1, 2, 3, 1}, {18, 19, 20, 21, 22, 23}); + test_case.add_expected_output(Shape{2, 2, 3, 1}, + {24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35}); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_4d_axis_0_dynamic) +{ + const Shape data_shape{6, 2, 3, 1}; + std::vector data(shape_size(data_shape)); + std::iota(data.begin(), data.end(), 0); + const Shape axis_shape{1}; + const std::vector axis_value{0}; + const Shape split_lenghts_shape{3}; + const std::vector split_lenghts{3, 1, 2}; + + auto test_case = test::TestCase( + DynamicVariadicSplit(element::i32, data_shape, axis_shape, split_lenghts_shape)); + + test_case.add_input(data_shape, data); + test_case.add_input(axis_shape, axis_value); + test_case.add_input(split_lenghts_shape, split_lenghts); + test_case.add_expected_output( + Shape{3, 2, 3, 1}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}); + test_case.add_expected_output(Shape{1, 2, 3, 1}, {18, 19, 20, 21, 22, 23}); + test_case.add_expected_output(Shape{2, 2, 3, 1}, + {24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35}); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_4d_axis_1_static) +{ + const Shape data_shape{2, 8, 2, 2}; + std::vector data(shape_size(data_shape)); + std::iota(data.begin(), data.end(), 0); + + const Shape axis_shape{1}; + const std::vector axis_value{1}; + const Shape split_lenghts_shape{4}; + const std::vector split_lenghts{1, 3, 2, 2}; + + auto test_case = test::TestCase(StaticVariadicSplit( + element::i32, data_shape, axis_shape, split_lenghts_shape, axis_value, split_lenghts)); + + test_case.add_input(data_shape, data); + test_case.add_expected_output(Shape{2, 1, 2, 2}, {0, 1, 2, 3, 32, 33, 34, 35}); + test_case.add_expected_output( + Shape{2, 3, 2, 2}, + {4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47}); + test_case.add_expected_output( + Shape{2, 2, 2, 2}, {16, 17, 18, 19, 20, 21, 22, 23, 48, 49, 50, 51, 52, 53, 54, 55}); + test_case.add_expected_output( + Shape{2, 2, 2, 2}, {24, 25, 26, 27, 28, 29, 30, 31, 56, 57, 58, 59, 60, 61, 62, 63}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_4d_axis_1_dynamic) +{ + const Shape data_shape{2, 8, 2, 2}; + std::vector data(shape_size(data_shape)); + std::iota(data.begin(), data.end(), 0); + + const Shape axis_shape{1}; + const std::vector axis_value{1}; + const Shape split_lenghts_shape{4}; + const std::vector split_lenghts{1, 3, 2, 2}; + + auto test_case = test::TestCase( + DynamicVariadicSplit(element::i32, data_shape, axis_shape, split_lenghts_shape)); + + test_case.add_input(data_shape, data); + test_case.add_input(axis_shape, axis_value); + test_case.add_input(split_lenghts_shape, split_lenghts); + test_case.add_expected_output(Shape{2, 1, 2, 2}, {0, 1, 2, 3, 32, 33, 34, 35}); + test_case.add_expected_output( + Shape{2, 3, 2, 2}, + {4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47}); + test_case.add_expected_output( + Shape{2, 2, 2, 2}, {16, 17, 18, 19, 20, 21, 22, 23, 48, 49, 50, 51, 52, 53, 54, 55}); + test_case.add_expected_output( + Shape{2, 2, 2, 2}, {24, 25, 26, 27, 28, 29, 30, 31, 56, 57, 58, 59, 60, 61, 62, 63}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_4d_axis_2_static) +{ + const Shape data_shape{2, 1, 6, 2}; + std::vector data(shape_size(data_shape)); + std::iota(data.begin(), data.end(), 0); + + const Shape axis_shape{1}; + const std::vector axis_value{2}; + const Shape split_lenghts_shape{3}; + const std::vector split_lenghts{3, 1, 2}; + + auto test_case = test::TestCase(StaticVariadicSplit( + element::i32, data_shape, axis_shape, split_lenghts_shape, axis_value, split_lenghts)); + + test_case.add_input(data_shape, data); + test_case.add_expected_output(Shape{2, 1, 3, 2}, + {0, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16, 17}); + test_case.add_expected_output(Shape{2, 1, 1, 2}, {6, 7, 18, 19}); + test_case.add_expected_output(Shape{2, 1, 2, 2}, {8, 9, 10, 11, 20, 21, 22, 23}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_4d_axis_2_dynamic) +{ + const Shape data_shape{2, 1, 6, 2}; + std::vector data(shape_size(data_shape)); + std::iota(data.begin(), data.end(), 0); + + const Shape axis_shape{1}; + const std::vector axis_value{2}; + const Shape split_lenghts_shape{3}; + const std::vector split_lenghts{-1, 1, 2}; // -1 means "all remaining items" + + auto test_case = test::TestCase( + DynamicVariadicSplit(element::i32, data_shape, axis_shape, split_lenghts_shape)); + + test_case.add_input(data_shape, data); + test_case.add_input(axis_shape, axis_value); + test_case.add_input(split_lenghts_shape, split_lenghts); + test_case.add_expected_output(Shape{2, 1, 3, 2}, + {0, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16, 17}); + test_case.add_expected_output(Shape{2, 1, 1, 2}, {6, 7, 18, 19}); + test_case.add_expected_output(Shape{2, 1, 2, 2}, {8, 9, 10, 11, 20, 21, 22, 23}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_4d_axis_3_static) +{ + const Shape data_shape{2, 1, 2, 6}; + std::vector data(shape_size(data_shape)); + std::iota(data.begin(), data.end(), 0); + + const Shape axis_shape{1}; + const std::vector axis_value{3}; + const Shape split_lenghts_shape{3}; + const std::vector split_lenghts{1, -1, 3}; // -1 means "all remaining items" + + auto test_case = test::TestCase(StaticVariadicSplit( + element::i32, data_shape, axis_shape, split_lenghts_shape, axis_value, split_lenghts)); + + test_case.add_input(data_shape, data); + test_case.add_expected_output(Shape{2, 1, 2, 1}, {0, 6, 12, 18}); + test_case.add_expected_output(Shape{2, 1, 2, 2}, {1, 2, 7, 8, 13, 14, 19, 20}); + test_case.add_expected_output(Shape{2, 1, 2, 3}, + {3, 4, 5, 9, 10, 11, 15, 16, 17, 21, 22, 23}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_4d_axis_3_dynamic) +{ + const Shape data_shape{2, 1, 2, 6}; + std::vector data(shape_size(data_shape)); + std::iota(data.begin(), data.end(), 0); + + const Shape axis_shape{1}; + const std::vector axis_value{3}; + const Shape split_lenghts_shape{3}; + const std::vector split_lenghts{1, 2, -1}; // -1 means "all remaining items" + + auto test_case = test::TestCase( + DynamicVariadicSplit(element::i32, data_shape, axis_shape, split_lenghts_shape)); + + test_case.add_input(data_shape, data); + test_case.add_input(axis_shape, axis_value); + test_case.add_input(split_lenghts_shape, split_lenghts); + test_case.add_expected_output(Shape{2, 1, 2, 1}, {0, 6, 12, 18}); + test_case.add_expected_output(Shape{2, 1, 2, 2}, {1, 2, 7, 8, 13, 14, 19, 20}); + test_case.add_expected_output(Shape{2, 1, 2, 3}, + {3, 4, 5, 9, 10, 11, 15, 16, 17, 21, 22, 23}); + + test_case.run(); +} \ No newline at end of file diff --git a/ngraph/test/runtime/ie/unit_test.manifest b/ngraph/test/runtime/ie/unit_test.manifest index adfebe2b57aac4..aa4079eee82c89 100644 --- a/ngraph/test/runtime/ie/unit_test.manifest +++ b/ngraph/test/runtime/ie/unit_test.manifest @@ -1529,6 +1529,13 @@ onnx_controlflow_loop_infinite # unsupported dynamic ops onnx_dyn_shapes_reduce_max_dynamic_input_rank_negative_axis IE_GPU.range_v4_trunc_inputs +variadic_split_1d_dynamic +variadic_split_2d_axis_0_dynamic +variadic_split_2d_axis_1_dynamic +variadic_split_4d_axis_0_dynamic +variadic_split_4d_axis_1_dynamic +variadic_split_4d_axis_2_dynamic +variadic_split_4d_axis_3_dynamic # CPU plugin does not support bool type IE_CPU.evaluate_2D_gather_elements_3x2_data_bool diff --git a/ngraph/test/visitors/op/variadic_split.cpp b/ngraph/test/visitors/op/variadic_split.cpp new file mode 100644 index 00000000000000..ae4b0c8c2d6503 --- /dev/null +++ b/ngraph/test/visitors/op/variadic_split.cpp @@ -0,0 +1,32 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" + +#include "ngraph/ngraph.hpp" +#include "ngraph/op/util/attr_types.hpp" +#include "ngraph/opsets/opset1.hpp" + +#include "util/visitor.hpp" + +using namespace std; +using namespace ngraph; +using ngraph::test::NodeBuilder; +using ngraph::test::ValueMap; + +TEST(attributes, variadic_split_op) +{ + using namespace opset1; + + NodeBuilder::get_ops().register_factory(); + auto data = make_shared(element::i32, Shape{200}); + auto axis = make_shared(element::i32, Shape{1}); + auto split_lengths = make_shared(element::i32, Shape{1}); + + auto split = make_shared(data, axis, split_lengths); + NodeBuilder builder(split); + const auto expected_attr_count = 0; + + EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); +} From 8390f40788dcc28ad8f12f8f9ee6c07b9c83fcf8 Mon Sep 17 00:00:00 2001 From: Edward Shogulin Date: Thu, 17 Jun 2021 12:36:25 +0300 Subject: [PATCH 119/178] [LPT] Empty shape on weights handling: cherry-pick to master (#6170) * [LPT] empty shape on weights fix * [LPT] SplitTransformation naming fix * [LPT] tests Co-authored-by: Vladislav Golubev --- .../src/split.cpp | 6 +-- .../src/weightable_layer_transformation.cpp | 9 +++- ...nvolution_backprop_data_transformation.cpp | 41 +++++++++++++++++++ ...nvolution_backprop_data_transformation.cpp | 7 ++++ .../convolution_transformation.cpp | 8 ++++ ...nvolution_backprop_data_transformation.cpp | 7 ++++ .../convolution_transformation.cpp | 8 ++++ 7 files changed, 81 insertions(+), 5 deletions(-) diff --git a/inference-engine/src/low_precision_transformations/src/split.cpp b/inference-engine/src/low_precision_transformations/src/split.cpp index 486111dd73778a..919c6b5e87b185 100644 --- a/inference-engine/src/low_precision_transformations/src/split.cpp +++ b/inference-engine/src/low_precision_transformations/src/split.cpp @@ -111,13 +111,13 @@ void SplitTransformation::updateOutputs( updateOutput(context, lastNodes[0], originalNode); } else { const std::string originalName = originalNode->get_friendly_name(); - for (auto& lastNode : lastNodes) { + for (size_t outIdx = 0; outIdx < lastNodes.size(); ++outIdx) { for (size_t i = 0; i < outputSize; ++i) { std::shared_ptr result = context.function->get_output_op(i); std::shared_ptr outputNode = result->get_input_node_shared_ptr(0); - if (outputNode.get() == lastNode.get()) { + if (outputNode.get() == lastNodes[outIdx].get()) { originalNode->set_friendly_name(originalName + LayerTransformation::originalLayerPostfix); - lastNode->set_friendly_name(originalName + "." + std::to_string(i)); + lastNodes[outIdx]->set_friendly_name(originalName + "." + std::to_string(outIdx)); break; } } diff --git a/inference-engine/src/low_precision_transformations/src/weightable_layer_transformation.cpp b/inference-engine/src/low_precision_transformations/src/weightable_layer_transformation.cpp index ce0ae3473d92e5..babcc95303cffe 100644 --- a/inference-engine/src/low_precision_transformations/src/weightable_layer_transformation.cpp +++ b/inference-engine/src/low_precision_transformations/src/weightable_layer_transformation.cpp @@ -157,10 +157,15 @@ bool WeightableLayerTransformation::canBeTransformed(const TransformationContext } const size_t outChannelsShapeIndex = is_type(layer) ? 1ul : 0ul; - if ( // Check if all dimensions of scale except the output channels are all ones + if ( + // expected, it's ok: return true + (shape_size(constOutputShape) != 1ul) && + // not expected, something wrong: return false + ((constOutputShape.size() <= outChannelsShapeIndex) || + // Check if all dimensions of scale except the output channels are all ones (shape_size(constOutputShape) != constOutputShape[outChannelsShapeIndex]) || ((constOutputShape[outChannelsShapeIndex] != 1ul) && - (fqFromWeights->get_output_shape(0)[outChannelsShapeIndex] != constOutputShape[outChannelsShapeIndex]))) { + (fqFromWeights->get_output_shape(0)[outChannelsShapeIndex] != constOutputShape[outChannelsShapeIndex])))) { return false; } } else { diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_backprop_data_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_backprop_data_transformation.cpp index 8e89b952526462..10ba4513f20549 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_backprop_data_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_backprop_data_transformation.cpp @@ -116,6 +116,7 @@ class ConvolutionBackpropDataTransformation : public LayerTransformation, public SimpleLowPrecisionTransformer transform; transform.add(testValues.params); transform.transform(actualFunction); + std::shared_ptr refWeights = pass::low_precision::fold( testValues.expected.weights, opset1::Constant::create( @@ -202,6 +203,26 @@ const std::vector testValues = true } }, + // with zero point + { + LayerTransformation::createParamsU8I8(), + // ActualValues + { + ngraph::element::u8, + {{ngraph::element::f32}, { 128.f }, { 0.02f }}, + { 255ul, Shape({}), { 0.f }, { 254.f }, { -1.27f }, { 1.27f } }, + op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ 2.f }) + }, + // ExpectedValues + { + ngraph::element::u8, + {{}, { { 128.f }, ngraph::element::f32, {}, false }, {}}, + {}, + {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1 }}}, + op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ -125.f }), + true + } + }, // updatePrecisions = false { LayerTransformation::createParamsU8I8().setUpdatePrecisions(false), @@ -262,6 +283,26 @@ const std::vector testValues = true } }, + // without zero point + { + LayerTransformation::createParamsU8I8(), + // ActualValues + { + ngraph::element::u8, + {{ngraph::element::f32}, {}, { 0.02f }}, + { 255ul, Shape({}), { 0.f }, { 254.f }, { -1.27f }, { 1.27f } }, + op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ 2.f }) + }, + // ExpectedValues + { + ngraph::element::u8, + {}, + {}, + {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1 }}}, + op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ -125.f }), + true + } + }, // QDq version { LayerTransformation::createParamsU8I8(), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp index a6e2e93a37ebb8..223f9743a61888 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp @@ -27,6 +27,13 @@ const std::vector params "Convolution", "U8" }, + { + { 256ul, ngraph::Shape {}, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, + false, + { 255ul, ngraph::Shape {}, { 0.f }, { 254.f }, { -12.7f }, { 12.7f } }, + false, + "Convolution", + "U8" + }, { { 16ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, false, diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp index 2cf625b58628a6..697059e3ce24bf 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp @@ -28,6 +28,13 @@ const std::vector params "Convolution", "U8" }, + { + { 256ul, ngraph::Shape {}, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, + false, + { 255ul, ngraph::Shape {}, { 0.f }, { 254.f }, { -12.7f }, { 12.7f } }, + false, + "Convolution", + "U8" + }, { { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { -12.75f }, { 6.375f } }, true, From ccd568a2d2b0bc5b10e0b4469c1e9acb0681a26a Mon Sep 17 00:00:00 2001 From: Pavel Esir Date: Thu, 17 Jun 2021 13:02:07 +0300 Subject: [PATCH 120/178] [nG] Gather-8 shell (#6171) * gather-8 nGraph shell * added opset8 tbl; added visit_attribute test * corrected opset tbl --- ngraph/core/include/ngraph/op/gather.hpp | 27 ++ ngraph/core/include/ngraph/opsets/opset8.hpp | 17 + .../core/include/ngraph/opsets/opset8_tbl.hpp | 179 ++++++++ ngraph/core/src/op/gather.cpp | 47 ++ ngraph/test/type_prop/gather.cpp | 413 +++++++++++++++++- ngraph/test/visitors/op/gather.cpp | 16 + 6 files changed, 691 insertions(+), 8 deletions(-) create mode 100644 ngraph/core/include/ngraph/opsets/opset8.hpp create mode 100644 ngraph/core/include/ngraph/opsets/opset8_tbl.hpp diff --git a/ngraph/core/include/ngraph/op/gather.hpp b/ngraph/core/include/ngraph/op/gather.hpp index 9293521a7d0047..61bbf33bc3a2be 100644 --- a/ngraph/core/include/ngraph/op/gather.hpp +++ b/ngraph/core/include/ngraph/op/gather.hpp @@ -61,5 +61,32 @@ namespace ngraph clone_with_new_inputs(const OutputVector& new_args) const override; }; } // namespace v7 + + namespace v8 + { + /// \brief Gather slices from axis of params according to indices + class NGRAPH_API Gather : public op::util::GatherBase + { + public: + NGRAPH_RTTI_DECLARATION; + Gather() = default; + + /// \param data The tensor from which slices are gathered + /// \param indices Tensor with indexes to gather + /// \param axis The tensor is a dimension index to gather data from + /// \param batch_dims The number of batch dimension in data and indices tensors. + Gather(const Output& data, + const Output& indices, + const Output& axis, + const int64_t batch_dims = 0); + + bool visit_attributes(AttributeVisitor& visitor) override; + void validate_and_infer_types() override; + int64_t get_batch_dims() const; + + std::shared_ptr + clone_with_new_inputs(const OutputVector& new_args) const override; + }; + } // namespace v8 } // namespace op } // namespace ngraph diff --git a/ngraph/core/include/ngraph/opsets/opset8.hpp b/ngraph/core/include/ngraph/opsets/opset8.hpp new file mode 100644 index 00000000000000..f31a3142cf69a7 --- /dev/null +++ b/ngraph/core/include/ngraph/opsets/opset8.hpp @@ -0,0 +1,17 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "ngraph/ops.hpp" + +namespace ngraph +{ + namespace opset8 + { +#define NGRAPH_OP(a, b) using b::a; +#include "ngraph/opsets/opset8_tbl.hpp" +#undef NGRAPH_OP + } // namespace opset8 +} // namespace ngraph diff --git a/ngraph/core/include/ngraph/opsets/opset8_tbl.hpp b/ngraph/core/include/ngraph/opsets/opset8_tbl.hpp new file mode 100644 index 00000000000000..0dbe077ddae1bd --- /dev/null +++ b/ngraph/core/include/ngraph/opsets/opset8_tbl.hpp @@ -0,0 +1,179 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#ifndef NGRAPH_OP +#warning "NGRAPH_OP not defined" +#define NGRAPH_OP(x, y) +#endif + +NGRAPH_OP(Abs, ngraph::op::v0) +NGRAPH_OP(Acos, ngraph::op::v0) +NGRAPH_OP(Add, ngraph::op::v1) +NGRAPH_OP(Asin, ngraph::op::v0) +NGRAPH_OP(Atan, ngraph::op::v0) +NGRAPH_OP(AvgPool, ngraph::op::v1) +NGRAPH_OP(BatchNormInference, ngraph::op::v5) +NGRAPH_OP(BinaryConvolution, ngraph::op::v1) +NGRAPH_OP(Broadcast, ngraph::op::v3) +NGRAPH_OP(Bucketize, ngraph::op::v3) +NGRAPH_OP(CTCGreedyDecoder, ngraph::op::v0) +NGRAPH_OP(Ceiling, ngraph::op::v0) +NGRAPH_OP(Clamp, ngraph::op::v0) +NGRAPH_OP(Concat, ngraph::op::v0) +NGRAPH_OP(Constant, ngraph::op) +NGRAPH_OP(Convert, ngraph::op::v0) +NGRAPH_OP(ConvertLike, ngraph::op::v1) +NGRAPH_OP(Convolution, ngraph::op::v1) +NGRAPH_OP(ConvolutionBackpropData, ngraph::op::v1) +NGRAPH_OP(Cos, ngraph::op::v0) +NGRAPH_OP(Cosh, ngraph::op::v0) +NGRAPH_OP(CumSum, ngraph::op::v0) +NGRAPH_OP(DeformableConvolution, ngraph::op::v1) +NGRAPH_OP(DeformablePSROIPooling, ngraph::op::v1) +NGRAPH_OP(DepthToSpace, ngraph::op::v0) +NGRAPH_OP(DetectionOutput, ngraph::op::v0) +NGRAPH_OP(Divide, ngraph::op::v1) +NGRAPH_OP(Elu, ngraph::op::v0) +NGRAPH_OP(Erf, ngraph::op::v0) +NGRAPH_OP(Equal, ngraph::op::v1) +NGRAPH_OP(Exp, ngraph::op::v0) +NGRAPH_OP(ExtractImagePatches, ngraph::op::v3) +NGRAPH_OP(FakeQuantize, ngraph::op::v0) +NGRAPH_OP(Floor, ngraph::op::v0) +NGRAPH_OP(FloorMod, ngraph::op::v1) +NGRAPH_OP(GatherTree, ngraph::op::v1) +NGRAPH_OP(Greater, ngraph::op::v1) +NGRAPH_OP(GreaterEqual, ngraph::op::v1) +NGRAPH_OP(GroupConvolution, ngraph::op::v1) +NGRAPH_OP(GroupConvolutionBackpropData, ngraph::op::v1) +NGRAPH_OP(GRN, ngraph::op::v0) +NGRAPH_OP(HardSigmoid, ngraph::op::v0) +NGRAPH_OP(Less, ngraph::op::v1) +NGRAPH_OP(LessEqual, ngraph::op::v1) +NGRAPH_OP(Log, ngraph::op::v0) +NGRAPH_OP(LogicalAnd, ngraph::op::v1) +NGRAPH_OP(LogicalNot, ngraph::op::v1) +NGRAPH_OP(LogicalOr, ngraph::op::v1) +NGRAPH_OP(LogicalXor, ngraph::op::v1) +NGRAPH_OP(LRN, ngraph::op::v0) +NGRAPH_OP(LSTMCell, ngraph::op::v4) +NGRAPH_OP(MatMul, ngraph::op::v0) +NGRAPH_OP(MaxPool, ngraph::op::v1) +NGRAPH_OP(Maximum, ngraph::op::v1) +NGRAPH_OP(Minimum, ngraph::op::v1) +NGRAPH_OP(Mod, ngraph::op::v1) +NGRAPH_OP(Multiply, ngraph::op::v1) +NGRAPH_OP(Negative, ngraph::op::v0) +NGRAPH_OP(NormalizeL2, ngraph::op::v0) +NGRAPH_OP(NotEqual, ngraph::op::v1) +NGRAPH_OP(OneHot, ngraph::op::v1) +NGRAPH_OP(PRelu, ngraph::op::v0) +NGRAPH_OP(PSROIPooling, ngraph::op::v0) +NGRAPH_OP(Pad, ngraph::op::v1) +NGRAPH_OP(Parameter, ngraph::op::v0) +NGRAPH_OP(Power, ngraph::op::v1) +NGRAPH_OP(PriorBox, ngraph::op::v0) +NGRAPH_OP(PriorBoxClustered, ngraph::op::v0) +NGRAPH_OP(Proposal, ngraph::op::v4) +NGRAPH_OP(Range, ngraph::op::v4) +NGRAPH_OP(Relu, ngraph::op::v0) +NGRAPH_OP(ReduceMax, ngraph::op::v1) +NGRAPH_OP(ReduceLogicalAnd, ngraph::op::v1) +NGRAPH_OP(ReduceLogicalOr, ngraph::op::v1) +NGRAPH_OP(ReduceMean, ngraph::op::v1) +NGRAPH_OP(ReduceMin, ngraph::op::v1) +NGRAPH_OP(ReduceProd, ngraph::op::v1) +NGRAPH_OP(ReduceSum, ngraph::op::v1) +NGRAPH_OP(RegionYolo, ngraph::op::v0) +NGRAPH_OP(ReorgYolo, ngraph::op::v0) +NGRAPH_OP(Reshape, ngraph::op::v1) +NGRAPH_OP(Result, ngraph::op::v0) +NGRAPH_OP(ReverseSequence, ngraph::op::v0) +NGRAPH_OP(ROIPooling, ngraph::op::v0) +NGRAPH_OP(ScatterNDUpdate, ngraph::op::v3) +NGRAPH_OP(Select, ngraph::op::v1) +NGRAPH_OP(Selu, ngraph::op::v0) +NGRAPH_OP(Sign, ngraph::op::v0) +NGRAPH_OP(Sigmoid, ngraph::op::v0) +NGRAPH_OP(Sin, ngraph::op::v0) +NGRAPH_OP(Sinh, ngraph::op::v0) +NGRAPH_OP(Softmax, ngraph::op::v1) +NGRAPH_OP(Sqrt, ngraph::op::v0) +NGRAPH_OP(SpaceToDepth, ngraph::op::v0) +NGRAPH_OP(Split, ngraph::op::v1) +NGRAPH_OP(SquaredDifference, ngraph::op::v0) +NGRAPH_OP(Squeeze, ngraph::op::v0) +NGRAPH_OP(StridedSlice, ngraph::op::v1) +NGRAPH_OP(Subtract, ngraph::op::v1) +NGRAPH_OP(Tan, ngraph::op::v0) +NGRAPH_OP(Tanh, ngraph::op::v0) +NGRAPH_OP(TensorIterator, ngraph::op::v0) +NGRAPH_OP(Tile, ngraph::op::v0) +NGRAPH_OP(Transpose, ngraph::op::v1) +NGRAPH_OP(Unsqueeze, ngraph::op::v0) +NGRAPH_OP(VariadicSplit, ngraph::op::v1) + +// New operations added in opset2 +NGRAPH_OP(BatchToSpace, ngraph::op::v1) +NGRAPH_OP(SpaceToBatch, ngraph::op::v1) + +// New operations added in opset3 +NGRAPH_OP(EmbeddingBagPackedSum, ngraph::op::v3) +NGRAPH_OP(EmbeddingSegmentsSum, ngraph::op::v3) +NGRAPH_OP(EmbeddingBagOffsetsSum, ngraph::op::v3) +NGRAPH_OP(GRUCell, ngraph::op::v3) +NGRAPH_OP(NonZero, ngraph::op::v3) +NGRAPH_OP(RNNCell, ngraph::op::v0) +NGRAPH_OP(ROIAlign, ngraph::op::v3) +NGRAPH_OP(ScatterElementsUpdate, ngraph::op::v3) +NGRAPH_OP(ScatterUpdate, ngraph::op::v3) +NGRAPH_OP(ShuffleChannels, ngraph::op::v0) +NGRAPH_OP(ShapeOf, ngraph::op::v3) +NGRAPH_OP(TopK, ngraph::op::v3) + +// New operations added in opset4 +NGRAPH_OP(Acosh, ngraph::op::v3) +NGRAPH_OP(Asinh, ngraph::op::v3) +NGRAPH_OP(Atanh, ngraph::op::v3) +NGRAPH_OP(CTCLoss, ngraph::op::v4) +NGRAPH_OP(HSwish, ngraph::op::v4) +NGRAPH_OP(Interpolate, ngraph::op::v4) +NGRAPH_OP(Mish, ngraph::op::v4) +NGRAPH_OP(ReduceL1, ngraph::op::v4) +NGRAPH_OP(ReduceL2, ngraph::op::v4) +NGRAPH_OP(SoftPlus, ngraph::op::v4) +NGRAPH_OP(Swish, ngraph::op::v4) + +// New operations added in opset5 +NGRAPH_OP(GatherND, ngraph::op::v5) +NGRAPH_OP(GRUSequence, ngraph::op::v5) +NGRAPH_OP(HSigmoid, ngraph::op::v5) +NGRAPH_OP(LogSoftmax, ngraph::op::v5) +NGRAPH_OP(Loop, ngraph::op::v5) +NGRAPH_OP(LSTMSequence, ngraph::op::v5) +NGRAPH_OP(NonMaxSuppression, ngraph::op::v5) +NGRAPH_OP(RNNSequence, ngraph::op::v5) +NGRAPH_OP(Round, ngraph::op::v5) + +// New operations added in opset6 +NGRAPH_OP(CTCGreedyDecoderSeqLen, ngraph::op::v6) +NGRAPH_OP(ExperimentalDetectronDetectionOutput, ngraph::op::v6) +NGRAPH_OP(ExperimentalDetectronGenerateProposalsSingleImage, ngraph::op::v6) +NGRAPH_OP(ExperimentalDetectronPriorGridGenerator, ngraph::op::v6) +NGRAPH_OP(ExperimentalDetectronROIFeatureExtractor, ngraph::op::v6) +NGRAPH_OP(ExperimentalDetectronTopKROIs, ngraph::op::v6) +NGRAPH_OP(GatherElements, ngraph::op::v6) +NGRAPH_OP(MVN, ngraph::op::v6) +NGRAPH_OP(Assign, ngraph::op::v6) // new version +NGRAPH_OP(ReadValue, ngraph::op::v6) // new version + +// New operations added in opset7 +NGRAPH_OP(DFT, ngraph::op::v7) +NGRAPH_OP(Einsum, ngraph::op::v7) +NGRAPH_OP(Gelu, ngraph::op::v7) +NGRAPH_OP(IDFT, ngraph::op::v7) +NGRAPH_OP(Roll, ngraph::op::v7) + +// New operations added in opset8 +NGRAPH_OP(Gather, ngraph::op::v8) diff --git a/ngraph/core/src/op/gather.cpp b/ngraph/core/src/op/gather.cpp index f2ddc9948b3241..aeacffc271995a 100644 --- a/ngraph/core/src/op/gather.cpp +++ b/ngraph/core/src/op/gather.cpp @@ -86,3 +86,50 @@ shared_ptr op::v7::Gather::clone_with_new_inputs(const OutputVector& new_a check_new_args_count(this, new_args); return make_shared(new_args.at(0), new_args.at(1), new_args.at(2), m_batch_dims); } + +NGRAPH_RTTI_DEFINITION(op::v8::Gather, "Gather", 8, op::util::GatherBase); + +op::v8::Gather::Gather(const Output& data, + const Output& indices, + const Output& axis, + const int64_t batch_dims) + : GatherBase(data, indices, axis, batch_dims) +{ + constructor_validate_and_infer_types(); +} + +void op::v8::Gather::validate_and_infer_types() +{ + NGRAPH_OP_SCOPE(v8_Gather_validate_and_infer_types); + NODE_VALIDATION_CHECK(this, + get_input_element_type(1).is_integral_number(), + "Indices element type must be of an integral number type."); + + NODE_VALIDATION_CHECK(this, + get_input_element_type(2).is_integral_number(), + "Axis element type must be of an integral number type."); + + op::util::GatherBase::validate_and_infer_types(); +} + +int64_t op::v8::Gather::get_batch_dims() const +{ + if (m_batch_dims < 0 && get_input_partial_shape(1).rank().is_static()) + return m_batch_dims + get_input_partial_shape(1).rank().get_length(); + else + return m_batch_dims; +} + +bool ngraph::op::v8::Gather::visit_attributes(AttributeVisitor& visitor) +{ + NGRAPH_OP_SCOPE(v8_Gather_visit_attributes); + visitor.on_attribute("batch_dims", m_batch_dims); + return true; +} + +shared_ptr op::v8::Gather::clone_with_new_inputs(const OutputVector& new_args) const +{ + NGRAPH_OP_SCOPE(v8_Gather_clone_with_new_inputs); + check_new_args_count(this, new_args); + return make_shared(new_args.at(0), new_args.at(1), new_args.at(2), m_batch_dims); +} diff --git a/ngraph/test/type_prop/gather.cpp b/ngraph/test/type_prop/gather.cpp index 70bfc8530ee1ff..96b2bbff832736 100644 --- a/ngraph/test/type_prop/gather.cpp +++ b/ngraph/test/type_prop/gather.cpp @@ -13,7 +13,7 @@ using namespace ngraph; // ------------------------------ V1 ------------------------------ -TEST(type_prop, gather_axis_0) +TEST(type_prop, gather_v1_axis_0) { Shape params_shape{3, 2}; Shape indices_shape{2, 2}; @@ -27,7 +27,7 @@ TEST(type_prop, gather_axis_0) ASSERT_EQ(G->get_axis(), 0); } -TEST(type_prop, gather_7_uint8) +TEST(type_prop, gather_v1_uint8) { // Gather_1 must allow even if indices is not int32/int64 PartialShape data_shape{3, 2}; @@ -44,7 +44,7 @@ TEST(type_prop, gather_7_uint8) ASSERT_EQ(G->get_axis(), 0); } -TEST(type_prop, gather_7_float32) +TEST(type_prop, gather_v1_float32) { // Gather_1 should allow non int32/int64 indices PartialShape data_shape{3, 2}; @@ -335,7 +335,7 @@ TEST(type_prop, gather_7_axis_not_set_positive_batch_dims) ASSERT_EQ(G->get_output_partial_shape(0), out_shape); } -// --------------------- Negative tests ------------------------------ +// --------------------- V7 Negative tests ------------------------------ TEST(type_prop, gather_7_incorrect_axis_shape) { @@ -470,8 +470,7 @@ TEST(type_prop, gather_7_batch_dims_less_indices_rank_check) } } -// disabled until decision of type constrains for gather -TEST(type_prop, DISABLED_gather_7_indices_type_check) +TEST(type_prop, gather_7_indices_type_check) { PartialShape data_shape{1, 20, 20, 22, 22}; PartialShape indices_shape{1, 3}; @@ -500,8 +499,7 @@ TEST(type_prop, DISABLED_gather_7_indices_type_check) } } -// disabled until decision of type constrains for gather -TEST(type_prop, DISABLED_gather_7_axis_type_check) +TEST(type_prop, gather_7_axis_type_check) { PartialShape data_shape{1, 20, 20, 22, 22}; PartialShape indices_shape{1, 3}; @@ -529,3 +527,402 @@ TEST(type_prop, DISABLED_gather_7_axis_type_check) FAIL() << "Deduced type check failed for unexpected reason"; } } + +// ------------------------------ V8 ------------------------------ + +TEST(type_prop, gather_v8_axis_0) +{ + PartialShape data_shape{3, 2}; + PartialShape indices_shape{2, 2}; + PartialShape out_shape{2, 2, 2}; + int64_t batch_dims = 0; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i32, indices_shape); + auto A = op::Constant::create(element::i64, Shape{}, {0}); + auto G = make_shared(D, I, A, batch_dims); + + ASSERT_EQ(G->get_element_type(), element::f32); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); + ASSERT_EQ(G->get_axis(), 0); +} + +TEST(type_prop, gather_v8_axis_1) +{ + PartialShape data_shape{3, 3}; + PartialShape indices_shape{1, 2}; + PartialShape out_shape{3, 1, 2}; + int64_t axis = 1; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i32, indices_shape); + auto A = op::Constant::create(element::i64, Shape{}, {axis}); + auto G = make_shared(D, I, A); + + ASSERT_EQ(G->get_element_type(), element::f32); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); + ASSERT_EQ(G->get_axis(), 1); +} + +TEST(type_prop, gather_v8_negative_axis) +{ + PartialShape data_shape{5, 6, 7}; + PartialShape indices_shape{4}; + PartialShape out_shape{5, 4, 7}; + int64_t axis = -2; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + auto G = make_shared(D, I, A); + + ASSERT_EQ(G->get_axis(), 1); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); +} + +TEST(type_prop, gather_v8_dynamic_pshape_batch_dims_1_axis_1) +{ + PartialShape data_shape{Dimension(1, 7), 20, 20}; + PartialShape indices_shape{Dimension(7, 10), 3, 8}; + PartialShape out_shape{7, 3, 8, 20}; + int64_t axis = 1; + int64_t batch_dims = 1; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + auto G = make_shared(D, I, A, batch_dims); + + ASSERT_EQ(G->get_element_type(), element::f32); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); +} + +TEST(type_prop, gather_v8_dynamic_pshape_batch_dims_1_axis_3) +{ + PartialShape data_shape{Dimension(1, 7), Dimension(1, 3), 200, 400}; + PartialShape indices_shape{Dimension(7, 10), Dimension(2, 10), 3, 8}; + PartialShape out_shape{7, Dimension(1, 3), 200, Dimension(2, 10), 3, 8}; + int64_t axis = 3; + int64_t batch_dims = 1; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + auto G = make_shared(D, I, A, batch_dims); + + ASSERT_EQ(G->get_element_type(), element::f32); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); +} + +TEST(type_prop, gather_v8_dynamic_2d_pshape_batch_dim) +{ + PartialShape data_shape{Dimension(1, 7), Dimension(1, 3), 200, 400}; + PartialShape indices_shape{Dimension(7, 10), Dimension(2, 10), 3, 8}; + PartialShape out_shape{7, Dimension(2, 3), 3, 8, 400}; + int64_t axis = 2; + int64_t batch_dims = 2; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + auto G = make_shared(D, I, A, batch_dims); + + ASSERT_EQ(G->get_element_type(), element::f32); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); +} + +TEST(type_prop, gather_v8_dynamic_2d_pshape_batch_dim_axis_3) +{ + PartialShape data_shape{Dimension(1, 7), Dimension(1, 3), 200, 400}; + PartialShape indices_shape{Dimension(7, 10), Dimension(2, 10), 3, 8}; + PartialShape out_shape{7, Dimension(2, 3), 200, 3, 8}; + int64_t axis = 3; + int64_t batch_dims = 2; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + auto G = make_shared(D, I, A, batch_dims); + + ASSERT_EQ(G->get_element_type(), element::f32); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); +} + +TEST(type_prop, gather_v8_dynamic_rank) +{ + PartialShape data_shape{Dimension(1, 7), Dimension(1, 3), 200, 400}; + PartialShape indices_shape = PartialShape::dynamic(Rank(3, 5)); + PartialShape out_shape = PartialShape::dynamic(Rank(4, 6)); + int64_t axis = 3; + int64_t batch_dims = 2; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + auto G = make_shared(D, I, A, batch_dims); + + ASSERT_EQ(G->get_element_type(), element::f32); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); +} + +TEST(type_prop, gather_v8_axis_boundcheck_for_dynamic_data_rank) +{ + PartialShape data_shape = PartialShape::dynamic(); + PartialShape indices_shape{7, 3, 8}; + PartialShape out_shape = PartialShape::dynamic(); + int64_t axis = 3; + int64_t batch_dims = 2; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + auto G = make_shared(D, I, A, batch_dims); + + ASSERT_EQ(G->get_element_type(), element::f32); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); +} + +TEST(type_prop, gather_v8_dynamic_rank_negative_batch_dims) +{ + PartialShape data_shape{Dimension(1, 7), Dimension(1, 3), 200, 400}; + PartialShape indices_shape = PartialShape::dynamic(Rank(3, 5)); + PartialShape out_shape = PartialShape::dynamic(Rank(3, 5)); + int64_t axis = 3; + int64_t batch_dims = -2; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + auto G = make_shared(D, I, A, batch_dims); + + ASSERT_EQ(G->get_element_type(), element::f32); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); +} + +TEST(type_prop, gather_v8_axis_not_set) +{ + PartialShape data_shape{1, 1, 200, 400}; + PartialShape indices_shape{2, 2}; + // default batch_dims = 0 + PartialShape out_shape = PartialShape::dynamic(5); // out_rank = data_rank + indices_rank - 1 - batch_dims + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + auto A = make_shared(element::i32, Shape{1}); + auto G = make_shared(D, I, A); + + ASSERT_EQ(G->get_element_type(), element::f32); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); +} + +TEST(type_prop, gather_v8_axis_not_set_positive_batch_dims) +{ + PartialShape data_shape{2, 1, 200, 400}; + PartialShape indices_shape{2, 2}; + int64_t batch_dims = 1; + PartialShape out_shape = PartialShape({2, + Dimension::dynamic(), + Dimension::dynamic(), + Dimension::dynamic()}); + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + auto A = make_shared(element::i32, Shape{1}); + auto G = make_shared(D, I, A, batch_dims); + + ASSERT_EQ(G->get_element_type(), element::f32); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); +} + +// --------------------- V8 Negative tests ------------------------------ + +TEST(type_prop, gather_v8_incorrect_axis_shape) +{ + auto D = make_shared(element::f32, Shape{5, 6}); + auto I = make_shared(element::i64, Shape{4}); + auto A = make_shared(element::i64, Shape{2}); + + try + { + auto G = make_shared(D, I, A); + // Should have thrown, so fail if it didn't + FAIL() << "Incorrect A input shape"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + std::string("Axis input must be scalar or have 1 element")); + } + catch (...) + { + FAIL() << "Deduced type check failed for unexpected reason"; + } +} + +TEST(type_prop, gather_v8_axis_out_of_input_rank) +{ + auto D = make_shared(element::f32, Shape{5, 6}); + auto I = make_shared(element::i64, Shape{4}); + auto A = make_shared(element::i64, Shape{1}, vector{2}); + int64_t batch_dims = 0; + try + { + auto G = make_shared(D, I, A, batch_dims); + // Should have thrown, so fail if it didn't + FAIL() << "axis check failed"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING( + error.what(), std::string("Normalized axis must be >= 0 and < data_rank. But instead got")); + } + catch (...) + { + FAIL() << "Deduced type check failed for unexpected reason"; + } +} + +TEST(type_prop, gather_v8_dynamic_batch_dims_inconsistent) +{ + PartialShape data_shape{Dimension(1, 7), 20, 20}; + PartialShape indices_shape{Dimension(8, 10), 3, 8}; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + int64_t axis = 1; + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + int64_t batch_dims = 1; + + try + { + auto G = make_shared(D, I, A, batch_dims); + // Should have thrown, so fail if it didn't + FAIL() << "Shape inconsistency check for dynamic PartialShape failed"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING( + error.what(), + std::string("data and indices must have equal or intersecting sizes until batch_dims")); + } + catch (...) + { + FAIL() << "Deduced type check failed for unexpected reason"; + } +} + +TEST(type_prop, gather_v8_batch_dims_less_check) +{ + PartialShape data_shape{1, 3, 20}; + PartialShape indices_shape{1, 3, 8}; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + int64_t axis = 1; + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + int64_t batch_dims = 2; + + try + { + auto G = make_shared(D, I, A, batch_dims); + // Should have thrown, so fail if it didn't + FAIL() << "batch_dims check failed"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING( + error.what(), + std::string("After normalization batch_dims must be <= axis. But instead got: batch_dims =")); + } + catch (...) + { + FAIL() << "Deduced type check failed for unexpected reason"; + } +} + +TEST(type_prop, gather_v8_batch_dims_less_indices_rank_check) +{ + PartialShape data_shape{1, 20, 20, 22, 22}; + PartialShape indices_shape{1, 3}; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + int64_t axis = 4; + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + int64_t batch_dims = 3; + + try + { + auto G = make_shared(D, I, A, batch_dims); + // Should have thrown, so fail if it didn't + FAIL() << "batch_dims check failed"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING( + error.what(), + std::string("batch_dims must be <= indices_rank")); + } + catch (...) + { + FAIL() << "Deduced type check failed for unexpected reason"; + } +} + +TEST(type_prop, gather_v8_indices_type_check) +{ + PartialShape data_shape{1, 20, 20, 22, 22}; + PartialShape indices_shape{1, 3}; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::f32, indices_shape); + int64_t axis = 4; + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + int64_t batch_dims = 0; + + try + { + auto G = make_shared(D, I, A, batch_dims); + // Should have thrown, so fail if it didn't + FAIL() << "indices element_type check failed"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING( + error.what(), + std::string("Indices element type must be of an integral number type")); + } + catch (...) + { + FAIL() << "Deduced type check failed for unexpected reason"; + } +} + +TEST(type_prop, gather_v8_axis_type_check) +{ + PartialShape data_shape{1, 20, 20, 22, 22}; + PartialShape indices_shape{1, 3}; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i32, indices_shape); + int64_t axis = 4; + auto A = make_shared(element::f32, Shape{1}, vector{axis}); + int64_t batch_dims = 0; + + try + { + auto G = make_shared(D, I, A, batch_dims); + // Should have thrown, so fail if it didn't + FAIL() << "axis element_type check failed"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING( + error.what(), + std::string("Axis element type must be of an integral number type")); + } + catch (...) + { + FAIL() << "Deduced type check failed for unexpected reason"; + } +} diff --git a/ngraph/test/visitors/op/gather.cpp b/ngraph/test/visitors/op/gather.cpp index 3e6446a07b8e89..c162d8949ffa41 100644 --- a/ngraph/test/visitors/op/gather.cpp +++ b/ngraph/test/visitors/op/gather.cpp @@ -7,6 +7,7 @@ #include "ngraph/ngraph.hpp" #include "ngraph/opsets/opset1.hpp" #include "ngraph/opsets/opset7.hpp" +#include "ngraph/opsets/opset8.hpp" #include "util/visitor.hpp" @@ -29,3 +30,18 @@ TEST(attributes, gather_v7_op) EXPECT_EQ(g_gather->get_batch_dims(), gather->get_batch_dims()); } + +TEST(attributes, gather_v8_op) +{ + NodeBuilder::get_ops().register_factory(); + auto data = make_shared(element::i32, Shape{2, 3, 4}); + auto indices = make_shared(element::i32, Shape{2}); + auto axis = make_shared(element::i32, Shape{}, 2); + int64_t batch_dims = 1; + + auto gather = make_shared(data, indices, axis, batch_dims); + NodeBuilder builder(gather); + auto g_gather = as_type_ptr(builder.create()); + + EXPECT_EQ(g_gather->get_batch_dims(), gather->get_batch_dims()); +} From cadaefea8c4e9441b9e4190f1fcb6adbf10e1f9d Mon Sep 17 00:00:00 2001 From: Maria Kaglinskaya Date: Thu, 17 Jun 2021 16:10:58 +0300 Subject: [PATCH 121/178] Added i8, u8 precisions in Gather constant folding (#6195) --- ngraph/core/src/op/util/gather_base.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ngraph/core/src/op/util/gather_base.cpp b/ngraph/core/src/op/util/gather_base.cpp index a58ab3e3851d71..566d9184e33dd4 100644 --- a/ngraph/core/src/op/util/gather_base.cpp +++ b/ngraph/core/src/op/util/gather_base.cpp @@ -236,6 +236,8 @@ namespace gather { NGRAPH_TYPE_CASE(evaluate_gather, i32, arg0, arg1, out, axis, batch_dims); NGRAPH_TYPE_CASE(evaluate_gather, i64, arg0, arg1, out, axis, batch_dims); + NGRAPH_TYPE_CASE(evaluate_gather, i8, arg0, arg1, out, axis, batch_dims); + NGRAPH_TYPE_CASE(evaluate_gather, u8, arg0, arg1, out, axis, batch_dims); NGRAPH_TYPE_CASE(evaluate_gather, u32, arg0, arg1, out, axis, batch_dims); NGRAPH_TYPE_CASE(evaluate_gather, u64, arg0, arg1, out, axis, batch_dims); NGRAPH_TYPE_CASE(evaluate_gather, f16, arg0, arg1, out, axis, batch_dims); From 3063afdbfc41fe0d1f9e63f2eb13c6584db287bd Mon Sep 17 00:00:00 2001 From: Nadezhda Ageeva Date: Thu, 17 Jun 2021 16:47:59 +0300 Subject: [PATCH 122/178] [GNA]: enable ITT couners and conditional compilation for GNA plugin (#5998) --- .../src/gna_plugin/CMakeLists.txt | 10 +++++-- .../gna_plugin/frontend/model_quantizer.hpp | 2 ++ inference-engine/src/gna_plugin/gna_itt.hpp | 21 ++++++++++++++ .../src/gna_plugin/gna_plugin.cpp | 8 ++++- .../gna_plugin/optimizer/gna_pass_manager.cpp | 29 +++++++++++++++++++ ...onvert_matmul_to_pointwise_convolution.cpp | 10 +++++-- ...transpose_after_convolution_or_pooling.cpp | 2 ++ .../insert_transpose_before_matmul.cpp | 5 +++- .../transformations/remove_extra_reshapes.cpp | 5 +++- .../reorder_activation_and_pooling.cpp | 5 +++- ...lit_convolution_with_large_buffer_size.cpp | 10 +++++-- .../transformations/swap_input_matmul_gna.cpp | 5 +++- 12 files changed, 98 insertions(+), 14 deletions(-) create mode 100644 inference-engine/src/gna_plugin/gna_itt.hpp diff --git a/inference-engine/src/gna_plugin/CMakeLists.txt b/inference-engine/src/gna_plugin/CMakeLists.txt index f3ce2858570733..36b9d6d5cc0b8e 100644 --- a/inference-engine/src/gna_plugin/CMakeLists.txt +++ b/inference-engine/src/gna_plugin/CMakeLists.txt @@ -29,12 +29,15 @@ endif() # # Shared plugin library -# +# ie_add_plugin(NAME ${TARGET_NAME} DEVICE_NAME "GNA" SOURCES ${SOURCES} ${HEADERS}) +# Enable support of CC for the plugin +ie_mark_target_as_cc(${TARGET_NAME}) + # saving rpath to GNA shared library be used by CI log_rpath_from_dir(GNA ${libGNA_LIBRARIES_BASE_PATH}) @@ -67,7 +70,8 @@ target_compile_definitions(${TARGET_NAME}_test_static target_link_libraries(${TARGET_NAME}_test_static PUBLIC inference_engine_preproc_s inference_engine_transformations libGNA::API) target_include_directories(${TARGET_NAME}_test_static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} - $) + $ + PRIVATE $) set_target_properties(${TARGET_NAME}_test_static PROPERTIES COMPILE_PDB_NAME ${TARGET_NAME}_test_static) set_target_properties(${TARGET_NAME} ${TARGET_NAME}_test_static @@ -76,6 +80,6 @@ set_target_properties(${TARGET_NAME} ${TARGET_NAME}_test_static # install file(GLOB_RECURSE source_list "${libGNA_LIBRARIES_BASE_PATH}/*${CMAKE_SHARED_LIBRARY_SUFFIX}*") -install(FILES ${source_list} +install(FILES ${source_list} DESTINATION ${IE_CPACK_IE_DIR}/external/gna/lib COMPONENT gna) diff --git a/inference-engine/src/gna_plugin/frontend/model_quantizer.hpp b/inference-engine/src/gna_plugin/frontend/model_quantizer.hpp index 1f3f125a029172..b57813858ac69a 100644 --- a/inference-engine/src/gna_plugin/frontend/model_quantizer.hpp +++ b/inference-engine/src/gna_plugin/frontend/model_quantizer.hpp @@ -15,6 +15,7 @@ #include "layer_quantizer.hpp" #include "scale_factor_calc.hpp" #include "weights_converter.hpp" +#include "gna_itt.hpp" namespace GNAPluginNS { @@ -40,6 +41,7 @@ class ModelQuantizer { template InferenceEngine::CNNNetwork quantize(const InferenceEngine::CNNNetwork &model, const PreQuantisationCb &cb, std::vector scaleFactor) const { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "ModelQuantizer::quantize"); auto visitor = [&](InferenceEngine::CNNLayerPtr lp) { auto newLayer = InferenceEngine::injectData(lp); transformLayer(newLayer, WeightsConverter()); diff --git a/inference-engine/src/gna_plugin/gna_itt.hpp b/inference-engine/src/gna_plugin/gna_itt.hpp new file mode 100644 index 00000000000000..3fa0211973329e --- /dev/null +++ b/inference-engine/src/gna_plugin/gna_itt.hpp @@ -0,0 +1,21 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +/** + * @brief Defines openvino domains for tracing + * @file gna_itt.hpp + */ + +#pragma once + +#include + +namespace GNAPluginNS { +namespace itt { +namespace domains { + OV_ITT_DOMAIN(GNAPlugin); + OV_ITT_DOMAIN(GNA_LT); +} +} +} diff --git a/inference-engine/src/gna_plugin/gna_plugin.cpp b/inference-engine/src/gna_plugin/gna_plugin.cpp index f49d543def1f37..cb227304649638 100644 --- a/inference-engine/src/gna_plugin/gna_plugin.cpp +++ b/inference-engine/src/gna_plugin/gna_plugin.cpp @@ -37,7 +37,7 @@ #include #include "gna_graph_patterns.hpp" #include "gna_tensor_tools.hpp" -#include +#include "gna_itt.hpp" #include #include @@ -391,6 +391,7 @@ GNAPlugin::GNAPlugin(const std::map& configMap) { } void GNAPlugin::Init() { + OV_ITT_SCOPED_TASK(itt::domains::GNAPlugin, "Init"); dnn = std::make_shared(backend::AMIntelDNN()); inputsDesc = std::make_shared(GNAPluginNS::InputDesc()); gnaFlags = std::make_shared(GNAPluginNS::GNAFlags()); @@ -401,6 +402,7 @@ void GNAPlugin::Init() { } void GNAPlugin::InitGNADevice() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "InitGNADevice"); #if GNA_LIB_VER == 1 gnadevice = std::make_shared(gnaFlags->gna_lib_async_threads_num, gnaFlags->gna_openmp_multithreading, @@ -419,6 +421,7 @@ void GNAPlugin::InitGNADevice() { } void GNAPlugin::UpdateGnaQuantModeFromNetwork(InferenceEngine::CNNNetwork & network) { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "UpdateGnaQuantModeFromNetwork"); // fp32 emulation mode dont need any modifications to configuration if (config.gnaFlags.sw_fp32) return; @@ -454,6 +457,7 @@ void GNAPlugin::UpdateGnaQuantModeFromNetwork(InferenceEngine::CNNNetwork & netw } void GNAPlugin::UpdateInputScaleFromNetwork(InferenceEngine::CNNNetwork & network) { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "UpdateInputScaleFromNetwork"); // fp32 emulation mode dont need any modifications to configuration if (config.gnaFlags.sw_fp32) return; @@ -561,6 +565,7 @@ bool GNAPlugin::TryToInitOutput(int portId, InferenceEngine::CNNLayerPtr layer) } void GNAPlugin::FillInputsAndOutputsTranspositionInfo(const InferenceEngine::CNNNetwork& net) { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "FillInputsAndOutputsTranspositionInfo"); auto printTranspositionInfo = [](const std::vector &transpositionInfo) { for (const auto &transpositionInfoPart : transpositionInfo) { gnalog() << "transpose=" << transpositionInfoPart.transpose << " rows_num=" << transpositionInfoPart.num_transpose_rows @@ -663,6 +668,7 @@ void GNAPlugin::AddDebugProperties(const InferenceEngine::CNNLayerPtr layer, #endif void GNAPlugin::LoadNetwork(CNNNetwork & _network) { + OV_ITT_SCOPED_TASK(itt::domains::GNAPlugin, "LoadNetwork"); std::shared_ptr convertedNetwork; if (_network.getFunction()) { CNNNetwork clonedNetwork = InferenceEngine::cloneNetwork(_network); diff --git a/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp b/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp index ef333e7e46f115..5355a7b28f1277 100644 --- a/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp +++ b/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp @@ -41,6 +41,7 @@ #include "gna_graph_patterns.hpp" #include "gna_data_types.hpp" #include "gna_tensor_tools.hpp" +#include "gna_itt.hpp" using namespace InferenceEngine; using namespace InferenceEngine::details; @@ -112,6 +113,7 @@ static void insertDiagonalLayerBetween(InferenceEngine::CNNLayerPtr prevLayer, */ static CNNLayerPtr InsertCopyLayer(CNNLayerPtr prevLayer, CNNLayerPtr nextLayer, int beforeIdx, std::shared_ptr passmanager, std::string copyLayerType) { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "InsertCopyLayer"); auto quantized = InferenceEngine::getInjectedData(prevLayer); std::string copyName = copyLayerType + std::string("_") + std::to_string(passmanager->getIntVar(copyLayersCounter)++); gnalog() << "Inserted " << copyName << " between: " << prevLayer->name << " and " << nextLayer->name << std::endl; @@ -257,6 +259,7 @@ static std::vector getCandidatesForIdentityInsertion(const CNNLayer } void InsertDiagonalLayerPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "InsertDiagonalLayerPass"); bool lowPrecision = getPassManager()->isLowPrecision(); for (auto & l : *pLayers) { @@ -304,6 +307,7 @@ void InsertDiagonalLayerPass::run() { } void HandleMultipleActivationsForTheLayerPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "HandleMultipleActivationsForTheLayerPass"); // found layer followed by multiple activations for (auto & l : *pLayers) { CNNLayerSet activations; @@ -333,6 +337,7 @@ void HandleMultipleActivationsForTheLayerPass::run() { } void ForbidActivationFusingPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "ForbidActivationFusingPass"); for (auto& l : *pLayers) { if (LayerInfo(l).isActivation()) { auto prevLayer = CNNNetPrevLayer(l); @@ -370,6 +375,7 @@ namespace { } // namespace void ReorderMaxPoolPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "ReorderMaxPoolPass"); // detecting following pattern // conv->activation->maxpooling // changing it to conv->maxpooling->activation @@ -398,6 +404,7 @@ void ReorderMaxPoolPass::run() { } void SubstituteSoftSignPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "SubstituteSoftSignPass"); //detecting following pattern // irv7 model: irv10 model: // a layer a layer @@ -501,6 +508,7 @@ void SubstituteSoftSignPass::run() { } } void SubstitutePReluPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "SubstitutePReluPass"); auto getScale = [](CNNLayer* layer) { auto powerCandidate = LayerInfo(layer); if (!powerCandidate.isPower()) return 0.0f; @@ -606,6 +614,7 @@ void SubstitutePReluPass::run() { } void ReversePermutationsPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "ReversePermutationsPass"); std::function)> prevLayerSkipCertain = [&prevLayerSkipCertain](CNNLayerPtr layer, std::function shouldSkip) -> CNNLayerPtr { if (CNNNetHasPrevLayer(layer.get())) { @@ -698,6 +707,7 @@ void ReversePermutationsPass::run() { } void RemovePermutationsNHWCToNCHWPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "RemovePermutationsNHWCToNCHWPass"); std::set permutations_to_remove; std::list> nhwc_layout_patterns; for (auto& l : *pLayers) { @@ -781,6 +791,7 @@ void RemovePermutationsNHWCToNCHWPass::run() { } void InsertIdentityLayerPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "InsertIdentityLayerPass"); auto quantized = InferenceEngine::getInjectedData(pLayers->front()); auto createIdentityLayer = [quantized, this](const TensorDesc& tensorDesc) { int numOfIdentityLayers = this->getPassManager()->getIntVar(identityLayersCounterName)++; @@ -898,6 +909,7 @@ void InsertIdentityLayerPass::run() { } void InsertCopyLayerPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "InsertCopyLayerPass"); // Copy layer insertion happens in few cases: // Crop output goes to concat layer -> copy layer insertion // Splitted part of input goes to concat layer -> copy layer insertion @@ -1020,6 +1032,7 @@ void InsertCopyLayerPass::run() { } void FlattenTrivialConcatPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "FlattenTrivialConcatPass"); // change all trivial concatenations (concatenation where output buffer is a buffer made by appending input buffers) // by reshaping its inputs to 1 x total_input_size and its output to 1 x total_cocat_size and chaning the axis to 1 // for example if 4D concat have unaligned inputs then ConcatAlignFilters need to be used if sizes before @@ -1103,6 +1116,7 @@ void FlattenTrivialConcatPass::run() { } void InsertConcatAligningFilterPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "InsertConcatAligningFilterPass"); auto quantized = InferenceEngine::getInjectedData(pLayers->front()); if (getPassManager()->getPolicy().ConcatAlignmentPolicy == Policy::ConcatAlignment::DISABLED) { @@ -1221,6 +1235,7 @@ void InsertConcatAligningFilterPass::run() { } void ReorderConcatInputsPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "ReorderConcatInputsPass"); auto quantized = InferenceEngine::getInjectedData(pLayers->front()); // aligning specific not required in fp32 mode if (getPassManager()->getPolicy().ConcatAlignmentPolicy == Policy::ConcatAlignment::DISABLED_FOR_FP32 && !quantized) { @@ -1318,6 +1333,7 @@ void ReorderConcatInputsPass::run() { } void InsertSplitAligningFilterPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "InsertSplitAligningFilterPass"); // currently split layer only supports 2 bytes in int16 and int8 mode. In fp32 mode this is not necessary but is useful for testing const int bytesPerSplitElement = 2; auto quantized = InferenceEngine::getInjectedData(pLayers->front()); @@ -1437,6 +1453,7 @@ static InferenceEngine::Blob::Ptr tileBlob(Blob::Ptr& blob, size_t TileTo) { } void EltwiseSplitOverChannelsPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "EltwiseSplitOverChannelsPass"); if (getPassManager()->getPolicy().GNAAffineDiagonalPolicy.limitedTo == Policy::GNAAffineDiagonal::UNLIMIT) { return; } @@ -1552,6 +1569,7 @@ void EltwiseSplitOverChannelsPass::run() { } void SubstituteScaleShiftBroadCastPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "SubstituteScaleShiftBroadCastPass"); std::map reshaped_data; auto quantized = InferenceEngine::getInjectedData(pLayers->front()); @@ -1633,6 +1651,7 @@ void SubstituteScaleShiftBroadCastPass::run() { } void BroadcastConstPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "BroadcastConstPass"); for (auto constLayer : *pLayers) { if (!LayerInfo(constLayer).isConst()) { continue; @@ -1685,6 +1704,7 @@ void BroadcastConstPass::run() { } void InsertIdentityToLSTMCellPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "InsertIdentityToLSTMCellPass"); for (auto layer : *pLayers) { if (layer->type == "LSTMCell") { // This fixed the cases when both functional and non-functional outputs are mixed (or not outputs are used) @@ -1722,6 +1742,7 @@ void InsertIdentityToLSTMCellPass::run() { } void BreakFusingOfOutputLayersPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "BreakFusingOfOutputLayersPass"); #if GNA_LIB_VER == 1 return; #endif @@ -1765,6 +1786,7 @@ void BreakFusingOfOutputLayersPass::run() { } void UnrollLSTMCellPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "UnrollLSTMCellPass"); InferenceEngine::NetPass::UnrollRNN_if(getPassManager()->getNetwork(), [] (const RNNCellBase& rnn) -> bool { if (rnn.clip != 0.0f) return true; @@ -1781,6 +1803,7 @@ void UnrollLSTMCellPass::run() { } void UnrollTIPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "UnrollTIPass"); auto sts = InferenceEngine::NetPass::UnrollTI(getPassManager()->getNetwork()); if (!sts) { THROW_GNA_EXCEPTION << "TensorIterator layer cannot be unrolled!"; @@ -1788,6 +1811,7 @@ void UnrollTIPass::run() { } void RemoveConstPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "RemoveConstPass"); auto network = getPassManager()->getNetwork(); IE_SUPPRESS_DEPRECATED_START auto & icnnnet = static_cast(network); @@ -1801,6 +1825,7 @@ void RemoveConstPass::run() { } void RemoveSingleInputConcatPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "RemoveSingleInputConcatPass"); for (auto &l : *pLayers) { if (l->type == "Concat") { auto concat = dynamic_cast(l.get()); @@ -1828,6 +1853,7 @@ void RemoveSingleInputConcatPass::run() { } void FuseMultipleIdentitiesPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "FuseMultipleIdentitiesPass"); for (auto &l : *pLayers) { if (l->insData.empty()) continue; @@ -1909,6 +1935,7 @@ void FuseMultipleIdentitiesPass::run() { } void FuseFQIntoWeightsPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "FuseFQIntoWeightsPass"); auto isNonFunctional = [](CNNLayerPtr ptr) { return LayerInfo(ptr).isNonFunctional(); }; @@ -2067,6 +2094,7 @@ void FuseFQIntoWeightsPass::run() { } void MoveFakeQuantizeLayerIntoQuantParamsPass :: run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "MoveFakeQuantizeLayerIntoQuantParamsPass"); auto quantized = InferenceEngine::getInjectedData(pLayers->front()); if (!quantized) { return; @@ -2268,6 +2296,7 @@ void MoveFakeQuantizeLayerIntoQuantParamsPass :: run() { } void TransposeWeightsFromNCHWToNHWCPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "TransposeWeightsFromNCHWToNHWCPass"); if (!MustBeConvertedFromNCHWToNHWC(*pLayers)) return; auto printTranspositionInfo = [](const std::vector &transpositionInfo) { diff --git a/inference-engine/src/gna_plugin/transformations/convert_matmul_to_pointwise_convolution.cpp b/inference-engine/src/gna_plugin/transformations/convert_matmul_to_pointwise_convolution.cpp index da7e6279624c81..e49d95ac2f2271 100644 --- a/inference-engine/src/gna_plugin/transformations/convert_matmul_to_pointwise_convolution.cpp +++ b/inference-engine/src/gna_plugin/transformations/convert_matmul_to_pointwise_convolution.cpp @@ -1,6 +1,7 @@ // Copyright (C) 2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // +#include #include "transformations/convert_matmul_to_pointwise_convolution.hpp" @@ -107,6 +108,7 @@ static bool Convert(std::shared_ptr matmul_node, } ConvertMatmulToPointWiseConvolution::ConvertMatmulToPointWiseConvolution() { + MATCHER_SCOPE(ConvertMatmulToPointWiseConvolution); auto const_input = ngraph::pattern::wrap_type(); auto const_fq = ngraph::pattern::wrap_type({const_input, ngraph::pattern::wrap_type(), @@ -121,11 +123,12 @@ ConvertMatmulToPointWiseConvolution::ConvertMatmulToPointWiseConvolution() { return Convert(pattern_map.at(matmul).get_node_shared_ptr(), nullptr, nullptr, nullptr); }; - auto m = std::make_shared(matmul, "ConvertMatmulToPointWiseConvolution"); + auto m = std::make_shared(matmul, matcher_name); this->register_matcher(m, callback); } ConvertMatmulWithBiasToPointWiseConvolution::ConvertMatmulWithBiasToPointWiseConvolution() { + MATCHER_SCOPE(ConvertMatmulWithBiasToPointWiseConvolution); auto const_input = ngraph::pattern::wrap_type(); auto const_fq = ngraph::pattern::wrap_type({const_input, ngraph::pattern::wrap_type(), @@ -143,11 +146,12 @@ ConvertMatmulWithBiasToPointWiseConvolution::ConvertMatmulWithBiasToPointWiseCon pattern_map.at(bias).get_node_shared_ptr(), nullptr); }; - auto m = std::make_shared(add, "ConvertMatmulWithBiasToPointWiseConvolution"); + auto m = std::make_shared(add, matcher_name); this->register_matcher(m, callback); } ConvertMatmulWithFqToPointWiseConvolution::ConvertMatmulWithFqToPointWiseConvolution() { + MATCHER_SCOPE(ConvertMatmulWithFqToPointWiseConvolution); auto const_input = ngraph::pattern::wrap_type(); auto const_fq = ngraph::pattern::wrap_type({const_input, ngraph::pattern::wrap_type(), @@ -175,6 +179,6 @@ ConvertMatmulWithFqToPointWiseConvolution::ConvertMatmulWithFqToPointWiseConvolu pattern_map.at(out_fq).get_node_shared_ptr()); }; - auto m = std::make_shared(out_fq, "ConvertMatmulWithFqToPointWiseConvolution"); + auto m = std::make_shared(out_fq, matcher_name); this->register_matcher(m, callback); } \ No newline at end of file diff --git a/inference-engine/src/gna_plugin/transformations/insert_transpose_after_convolution_or_pooling.cpp b/inference-engine/src/gna_plugin/transformations/insert_transpose_after_convolution_or_pooling.cpp index 6bfef2587aeff2..4954529762d582 100644 --- a/inference-engine/src/gna_plugin/transformations/insert_transpose_after_convolution_or_pooling.cpp +++ b/inference-engine/src/gna_plugin/transformations/insert_transpose_after_convolution_or_pooling.cpp @@ -1,6 +1,7 @@ // Copyright (C) 2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // +#include #include "transformations/insert_transpose_after_convolution_or_pooling.hpp" @@ -16,6 +17,7 @@ using namespace GNAPluginNS; NGRAPH_RTTI_DEFINITION(InsertTransposeAfterConvOrPool, "InsertTransposeAfterConvOrPool", 0); bool InsertTransposeAfterConvOrPool::run_on_function(std::shared_ptr f) { + RUN_ON_FUNCTION_SCOPE(InsertTransposeAfterConvOrPool); bool is_graph_modfied = false; for (auto& node : f->get_ordered_ops()) { if (std::dynamic_pointer_cast(node) == nullptr && diff --git a/inference-engine/src/gna_plugin/transformations/insert_transpose_before_matmul.cpp b/inference-engine/src/gna_plugin/transformations/insert_transpose_before_matmul.cpp index 4de8966d351660..3e5c579af8f14a 100644 --- a/inference-engine/src/gna_plugin/transformations/insert_transpose_before_matmul.cpp +++ b/inference-engine/src/gna_plugin/transformations/insert_transpose_before_matmul.cpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include "transformations/insert_transpose_before_matmul.hpp" #include @@ -13,6 +15,7 @@ using namespace GNAPluginNS; NGRAPH_RTTI_DEFINITION(InsertTransposeBeforeMatmul, "InsertTransposeBeforeMatmul", 0); InsertTransposeBeforeMatmul::InsertTransposeBeforeMatmul() { + MATCHER_SCOPE(InsertTransposeBeforeMatmul); auto reshape = ngraph::pattern::wrap_type({ngraph::pattern::any_input(), ngraph::pattern::any_input()}, ngraph::pattern::rank_equals(2)); @@ -59,6 +62,6 @@ InsertTransposeBeforeMatmul::InsertTransposeBeforeMatmul() { return true; }; - auto m = std::make_shared(root, "InsertTransposeBeforeMatmul"); + auto m = std::make_shared(root, matcher_name); this->register_matcher(m, callback); } diff --git a/inference-engine/src/gna_plugin/transformations/remove_extra_reshapes.cpp b/inference-engine/src/gna_plugin/transformations/remove_extra_reshapes.cpp index 1a7d6da2a33c8b..e1cfdefa31177c 100644 --- a/inference-engine/src/gna_plugin/transformations/remove_extra_reshapes.cpp +++ b/inference-engine/src/gna_plugin/transformations/remove_extra_reshapes.cpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include "transformations/remove_extra_reshapes.hpp" #include @@ -12,6 +14,7 @@ using namespace GNAPluginNS; NGRAPH_RTTI_DEFINITION(RemoveExtraReshapes, "RemoveExtraReshapes", 0); RemoveExtraReshapes::RemoveExtraReshapes() { + MATCHER_SCOPE(RemoveExtraReshapes); const auto reshape = ngraph::pattern::wrap_type(); const auto pooling = ngraph::pattern::wrap_type({reshape}); @@ -26,6 +29,6 @@ RemoveExtraReshapes::RemoveExtraReshapes() { return true; }; - auto m = std::make_shared(pooling, "RemoveExtraReshapes"); + auto m = std::make_shared(pooling, matcher_name); this->register_matcher(m, callback); } diff --git a/inference-engine/src/gna_plugin/transformations/reorder_activation_and_pooling.cpp b/inference-engine/src/gna_plugin/transformations/reorder_activation_and_pooling.cpp index 69bab295ba75e2..7e67d900e38423 100644 --- a/inference-engine/src/gna_plugin/transformations/reorder_activation_and_pooling.cpp +++ b/inference-engine/src/gna_plugin/transformations/reorder_activation_and_pooling.cpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include "transformations/reorder_activation_and_pooling.hpp" #include @@ -15,6 +17,7 @@ using namespace GNAPluginNS; NGRAPH_RTTI_DEFINITION(ReorderActivationAndPooling, "ReorderActivationAndPooling", 0); ReorderActivationAndPooling::ReorderActivationAndPooling() { + MATCHER_SCOPE(ReorderActivationAndPooling); auto conv = ngraph::pattern::wrap_type({ngraph::pattern::any_input(), ngraph::pattern::any_input()}); auto add = ngraph::pattern::wrap_type({conv, ngraph::pattern::any_input()}); @@ -63,6 +66,6 @@ ReorderActivationAndPooling::ReorderActivationAndPooling() { return true; }; - auto m = std::make_shared(pool, "ReorderActivationAndPooling"); + auto m = std::make_shared(pool, matcher_name); this->register_matcher(m, callback); } diff --git a/inference-engine/src/gna_plugin/transformations/split_convolution_with_large_buffer_size.cpp b/inference-engine/src/gna_plugin/transformations/split_convolution_with_large_buffer_size.cpp index a9d79c831ab34d..2e750308e5f3d1 100644 --- a/inference-engine/src/gna_plugin/transformations/split_convolution_with_large_buffer_size.cpp +++ b/inference-engine/src/gna_plugin/transformations/split_convolution_with_large_buffer_size.cpp @@ -1,6 +1,7 @@ // Copyright (C) 2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // +#include #include "transformations/split_convolution_with_large_buffer_size.hpp" @@ -77,6 +78,7 @@ static bool Convert(std::shared_ptr conv, } SplitConvolution::SplitConvolution() { + MATCHER_SCOPE(SplitConvolution); auto conv = ngraph::pattern::wrap_type({ngraph::pattern::any_input(), ngraph::pattern::any_input()}); @@ -85,11 +87,12 @@ SplitConvolution::SplitConvolution() { return Convert(pattern_map.at(conv).get_node_shared_ptr(), nullptr, nullptr, nullptr); }; - auto m = std::make_shared(conv, "SplitConvolution"); + auto m = std::make_shared(conv, matcher_name); this->register_matcher(m, callback); } SplitConvolutionWithBias::SplitConvolutionWithBias() { + MATCHER_SCOPE(SplitConvolutionWithBias); auto conv = ngraph::pattern::wrap_type({ngraph::pattern::any_input(), ngraph::pattern::any_input()}); auto bias = ngraph::pattern::wrap_type(); @@ -101,11 +104,12 @@ SplitConvolutionWithBias::SplitConvolutionWithBias() { pattern_map.at(bias).get_node_shared_ptr(), nullptr); }; - auto m = std::make_shared(add, "SplitConvolutionWithBias"); + auto m = std::make_shared(add, matcher_name); this->register_matcher(m, callback); } SplitConvolutionWithFq::SplitConvolutionWithFq() { + MATCHER_SCOPE(SplitConvolutionWithFq); auto conv = ngraph::pattern::wrap_type({ngraph::pattern::any_input(), ngraph::pattern::any_input()}); auto bias = ngraph::pattern::wrap_type(); @@ -126,6 +130,6 @@ SplitConvolutionWithFq::SplitConvolutionWithFq() { return Convert(pattern_map.at(conv).get_node_shared_ptr(), add_node, bias_node, pattern_map.at(out_fq).get_node_shared_ptr()); }; - auto m = std::make_shared(out_fq, "SplitConvolutionWithFq"); + auto m = std::make_shared(out_fq, matcher_name); this->register_matcher(m, callback); } \ No newline at end of file diff --git a/inference-engine/src/gna_plugin/transformations/swap_input_matmul_gna.cpp b/inference-engine/src/gna_plugin/transformations/swap_input_matmul_gna.cpp index 9a725c33cf7151..d177b83ba40e60 100644 --- a/inference-engine/src/gna_plugin/transformations/swap_input_matmul_gna.cpp +++ b/inference-engine/src/gna_plugin/transformations/swap_input_matmul_gna.cpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include #include @@ -19,6 +21,7 @@ using namespace GNAPluginNS; NGRAPH_RTTI_DEFINITION(SwapInputMatMul, "SwapInputMatMul", 0); SwapInputMatMul::SwapInputMatMul() { + MATCHER_SCOPE(SwapInputMatMul); auto matmul = ngraph::pattern::wrap_type({ngraph::pattern::any_input( ngraph::pattern::has_static_shape()), ngraph::pattern::any_input(ngraph::pattern::has_static_shape())}, ngraph::pattern::has_static_shape()); @@ -95,6 +98,6 @@ SwapInputMatMul::SwapInputMatMul() { return true; }; - auto m = std::make_shared(matmul, "SwapInputMatMul"); + auto m = std::make_shared(matmul, matcher_name); this->register_matcher(m, callback); } \ No newline at end of file From e61a594199ab222d8239635b1d651ce3f6bf11a4 Mon Sep 17 00:00:00 2001 From: "Gladilov, Gleb" Date: Thu, 17 Jun 2021 18:54:39 +0300 Subject: [PATCH 123/178] [IE][VPU]: Configuration options in VPU plugins refactoring (#3211) * [IE]: Enables Abstract class -> Parameter conversion support Parameter has templated constructor allowing to write code ``` Parameter p = i; // i of type int for example ``` This constructor uses SFINAE to resolve ambiguity with move-constructor, so checks that argument is not of the same type. In case it's not the same type it calls std::tuple constructors that constructs an instance of argument type. In the following case: ``` Parameter p = static_cast(abstractRef); // abstractRef is a reference to abstract class ``` We have a reference to some abstract class that defines explicit cast operator to Parameter. In contrast with expectations, instead of cast operator, Parameter constructor is instantiated, since template type deduction for Parameter constructor didn't fail (abstract class has not the same type as Parameter). Instantiation of tuple constructor used inside failed: it's impossible to create an instance of abstract class what lead to compile-time error. To resolve the issue additional condition introduced to check if argument type is abstract. Signed-off-by: Gladilov, Gleb * [IE]: Enables PrintTo method for Parameter and tests on it Inference Engine API for configuration options uses Parameter type as a return type of GetConfig method. Parameter is intended to store object associated with configuration option. To support objects of different types its constructor is templated. Parameter overloads cast operators which are templated as well. Both constructor and cast operators are implicit, which makes it possible to implicitly convert any type to Parameter and vice versa. Since Parameter is a part of Inference Engine configuration API it's essential google tests on API contain Parameter as tests parameter. For each test parameter Google Test framework tries to print it to an output stream. For that purpose, Google Test checks if test parameter has output stream operator or PrintTo method. If not, it checks if it could be implicitly converted to integral type and, in this case, prints it as a long integer. InferenceEngine::Parameter does not define output stream operator, but could be implicitly converted to an integer, according cast operators mentioned above, so Google Test tries to convert to integer. Since Parameter not necessarily contains integer, this conversion throws an exception of type mismatch, which makes it impossible to use Parameter in Google Test framework as is. In order to resolve that issue Parameter should define either output stream operator or PrintTo method. If Parameter will define output stream operator it will make it possible to compile streaming almost any object to an output stream. The reason for it is C++ checks if object could be implicitly converted to other type which defines output stream operator, if objects itself doesn't do it (e.g. `stream << "text";` calls std::string::operator<<, since char const* is implicitly convertible to std::string). Taking this into consideration the only way to support Parameter in Google Test without breaking backward compatibility is define PrintTo method. Signed-off-by: Gladilov, Gleb * [IE]: Fixes ill-formed extending std names According to the standard: The behavior of a C++ program is undefined if it adds declarations or definitions to namespace std or to a namespace within namespace std unless otherwise specified. A program may add a template specialization for any standard library template to namespace std only if the declaration depends on a user-defined type and the specialization meets the standard library requirements for the original template and is not explicitly prohibited. As as an unexpected result, InferenceEngine::Parameter that contains std::vector can be printed via PrintTo. In that case operator<< version from Inference Engine is picked up. Signed-off-by: Gladilov, Gleb * [IE][VPU]: Moves CompilationConfig out of GT header Keeping config in a separate header simplifies migration to new interface. Signed-off-by: Gladilov, Gleb * [IE][VPU]: Removes Platform enum Since there is enum from MVNC for the same purpose there is no need in Platform anyway Signed-off-by: Gladilov, Gleb * [IE][VPU]: Introduces containers utility header Contains some helpers to work with C++ maps Signed-off-by: Gladilov, Gleb * [IE][VPU]: Introduces new configuration API The main ideas are separate option-specific logic from common container, automate logic processing public vs private, deprecated, compile-time vs runtime-time options and remove code duplication. Since IE defines configuration API using std::string and Parameter, options have to provide ways to be represented as Parameter (ex.: GetConfig is called) and be defined using std::string (ex.: SetConfig is called). Keeping information about actual key value is useful for error reporting. New API fallbacks to previous version in case of unsupported options are requested. This way migration becomes iterative and looks simpler. Options containers are related to corresponding components: CompilationConfig (name to be changed) - GraphTransformer, PluginConfiguration - base class for plugins configurations, MyriadConfiguration - Myriad plugin configuration, HDDLConfiguration - HDDL plugin configuration (to be introduced in a separate request) Signed-off-by: Gladilov, Gleb * [IE][VPU]: Replaces CompilationConfig with PluginConfiguration Some of options to be refactored are stored inside CompilationConfig. CompilationConfig is passed to graph transformer as a compiler to be processed. Since it's separate data structure and migration process is iterative we need a mechanism to provide some of compilation options from new interface and some from old. It cannot be done via plugin specific class (MyriadConfiguration), since there are others plugins as graph transformer users. Plugin specific class (MyriadConfiguration) already inherits from old version (MyriadConfig), which in turn inherits from ParsedConfig containing CompilationConfig. To resolve the issue MyriadConfig inheritance from ParsedConfig is made virtual to make it possible for PluginConfiguration to virtually inherit from ParsedConfig as well an so make PluginConfiguration data structure for configuration options for graph transformer. Since PluginConfiguration is base class of MyriadConfiguration as well as MyriadConfig and inheritance is virtual plugin just casts its specific configuration to base one passing to graph transformer. Signed-off-by: Gladilov, Gleb * [IE][VPU]: Enables new tests on configuration API * Enables following new shared tests on configuration API * Can load network with empty configuration * Check default value for configuration option * Can load network with correct configuration * Check custom value for configuration option (set and compare) * Check public configuration options are visible through API * Check private configuration options are invisible through API * Check GetConfig throws an exception on incorrect key * Refactors myriad plugin instantiations for shared tests Signed-off-by: Gladilov, Gleb * [IE][VPU]: Extracts LogLevel enum to a separate header Signed-off-by: Gladilov, Gleb * [IE][VPU]: Refactors LOG_LEVEL configuration option Signed-off-by: Gladilov, Gleb * [IE][VPU]: Refactors COPY_OPTIMIZATION configuration option Signed-off-by: Gladilov, Gleb * [IE][VPU]: Fixes behavior tests build Signed-off-by: Gladilov, Gleb * [IE][VPU]: Updates tests on new exception class Signed-off-by: Gladilov, Gleb * [IE][VPU]: Removes unused variable from mvnc test Signed-off-by: Gladilov, Gleb * [IE][VPU]: Removes SizeVector streaming call New assertion macro IE_ASSERT implementation uses output streaming operator with r-value reference argument as a stream. This prevents the compiler from picking up overload from InferenceEngine::details, since our version takes stream by non-const l-value reference. Since there is no simple solution to provide output streaming operator overload for r-value references as well and this call is just a message for assert in test utilities, it was decided just to remove call for now. Signed-off-by: Gladilov, Gleb --- inference-engine/include/ie_parameter.hpp | 51 +- inference-engine/src/plugin_api/debug.h | 7 +- .../vpu/common/include/vpu/configuration.hpp | 99 ++++ .../configuration/as_parameter_enabler.hpp | 18 + .../options/copy_optimization.hpp | 34 ++ .../vpu/configuration/options/log_level.hpp | 36 ++ .../configuration/plugin_configuration.hpp | 142 +++++ .../vpu/configuration/switch_converters.hpp | 15 + .../include/vpu/parsed_config.hpp | 12 +- .../common/include/vpu/parsed_config_base.hpp | 11 +- .../include/vpu/private_plugin_config.hpp | 0 .../common/include/vpu/utils/containers.hpp | 40 ++ .../vpu/common/include/vpu/utils/error.hpp | 14 +- .../common/include/vpu/utils/log_level.hpp | 21 + .../vpu/common/include/vpu/utils/logger.hpp | 15 +- .../configuration/as_parameter_enabler.cpp | 10 + .../options/copy_optimization.cpp | 45 ++ .../src/configuration/options/log_level.cpp | 64 +++ .../configuration/plugin_configuration.cpp | 114 ++++ .../src/configuration/switch_converters.cpp | 25 + .../src/parsed_config.cpp | 1 - .../src/vpu/common/src/parsed_config_base.cpp | 37 +- .../src/vpu/graph_transformer/CMakeLists.txt | 9 +- .../include/vpu/compile_env.hpp | 25 +- .../include/vpu/graph_transformer.hpp | 110 +--- .../vpu/graph_transformer_internal.hpp | 4 +- .../graph_transformer/src/backend/backend.cpp | 10 +- .../src/frontend/detect_network_batch.cpp | 2 +- .../src/frontend/frontend.cpp | 16 +- .../src/frontend/in_out_convert.cpp | 18 +- .../src/frontend/parse_data.cpp | 4 +- .../src/frontend/unroll_loops.cpp | 6 +- .../src/graph_transformer.cpp | 71 +-- .../src/middleend/pass_manager.cpp | 33 +- .../middleend/passes/adjust_data_location.cpp | 4 +- .../src/middleend/passes/eliminate_copy.cpp | 3 +- .../src/middleend/passes/inject_sw.cpp | 2 +- .../passes/merge_eltwise_and_relu.cpp | 2 +- .../src/middleend/passes/merge_hw_stages.cpp | 2 +- .../passes/replace_deconv_by_conv.cpp | 2 +- .../src/middleend/passes/weights_analysis.cpp | 4 +- .../vpu/graph_transformer/src/model/stage.cpp | 2 +- .../src/stages/activation.cpp | 2 +- .../src/stages/convolution.cpp | 12 +- .../vpu/graph_transformer/src/stages/fc.cpp | 4 +- .../graph_transformer/src/stages/mtcnn.cpp | 2 +- .../graph_transformer/src/stages/permute.cpp | 2 +- .../graph_transformer/src/stages/pooling.cpp | 8 +- .../configuration/myriad_configuration.cpp | 31 ++ .../configuration/myriad_configuration.hpp | 21 + .../src/vpu/myriad_plugin/myriad_config.h | 2 +- .../myriad_executable_network.cpp | 33 +- .../myriad_plugin/myriad_executable_network.h | 32 +- .../src/vpu/myriad_plugin/myriad_executor.cpp | 5 +- .../src/vpu/myriad_plugin/myriad_executor.h | 10 +- .../vpu/myriad_plugin/myriad_infer_request.h | 1 + .../src/vpu/myriad_plugin/myriad_metrics.cpp | 2 +- .../src/vpu/myriad_plugin/myriad_plugin.cpp | 70 ++- .../src/vpu/myriad_plugin/myriad_plugin.h | 3 +- .../inference_engine/parameter_tests.cpp | 105 +++- .../functional/plugin/myriad/CMakeLists.txt | 13 + .../behavior/config.cpp | 496 +++++++++++------- .../include/base/behavior_test_utils.hpp | 126 ++++- .../plugin/shared/include/behavior/config.hpp | 97 +++- .../common_test_utils/data_utils.cpp | 6 +- .../unit/vpu/base/graph_transformer_tests.cpp | 23 +- .../unit/vpu/base/graph_transformer_tests.hpp | 6 +- .../tests/unit/vpu/blob_reader_tests.cpp | 5 +- .../passes_tests/annotate_memory_types.cpp | 2 +- .../plugin_tests/behavior_test_plugin.h | 3 +- .../myriad_tests/helpers/myriad_devices.cpp | 1 - .../myriad_tests/helpers/myriad_devices.hpp | 5 +- .../helpers/myriad_protocol_case.cpp | 1 + .../vpu/myriad_tests/vpu_watchdog_tests.cpp | 1 + .../plugin_tests/vpu_test_data.hpp | 1 + .../common/layers/myriad_layers_blob_test.cpp | 11 +- .../layers/myriad_layers_concat_test.hpp | 1 + .../graph_transformer/gt_functional_tests.cpp | 16 +- .../graph_transformer/gt_functional_tests.hpp | 10 +- .../merge_permute_and_reorder_test.cpp | 4 +- .../helpers/tests_vpu_common.hpp | 2 +- .../tests_deprecated/unit/CMakeLists.txt | 1 + .../engines/gna/layers/gna_squeeze_test.cpp | 2 + .../vpu/adjust_data_location_tests.cpp | 4 +- .../vpu/get_vpu_scale_from_ir_tests.cpp | 8 +- .../engines/vpu/graph_transformer_tests.cpp | 22 +- .../engines/vpu/graph_transformer_tests.hpp | 6 +- .../vpu/replace_deconv_by_conv_tests.cpp | 2 +- .../get_num_iterations_test.cpp | 2 + .../thirdparty/movidius/XLink/CMakeLists.txt | 3 + .../thirdparty/movidius/mvnc/CMakeLists.txt | 3 + .../movidius/mvnc/tests/mvnc_tests_common.cpp | 1 - 92 files changed, 1773 insertions(+), 596 deletions(-) create mode 100644 inference-engine/src/vpu/common/include/vpu/configuration.hpp create mode 100644 inference-engine/src/vpu/common/include/vpu/configuration/as_parameter_enabler.hpp create mode 100644 inference-engine/src/vpu/common/include/vpu/configuration/options/copy_optimization.hpp create mode 100644 inference-engine/src/vpu/common/include/vpu/configuration/options/log_level.hpp create mode 100644 inference-engine/src/vpu/common/include/vpu/configuration/plugin_configuration.hpp create mode 100644 inference-engine/src/vpu/common/include/vpu/configuration/switch_converters.hpp rename inference-engine/src/vpu/{graph_transformer => common}/include/vpu/parsed_config.hpp (80%) rename inference-engine/src/vpu/{graph_transformer => common}/include/vpu/private_plugin_config.hpp (100%) create mode 100644 inference-engine/src/vpu/common/include/vpu/utils/containers.hpp create mode 100644 inference-engine/src/vpu/common/include/vpu/utils/log_level.hpp create mode 100644 inference-engine/src/vpu/common/src/configuration/as_parameter_enabler.cpp create mode 100644 inference-engine/src/vpu/common/src/configuration/options/copy_optimization.cpp create mode 100644 inference-engine/src/vpu/common/src/configuration/options/log_level.cpp create mode 100644 inference-engine/src/vpu/common/src/configuration/plugin_configuration.cpp create mode 100644 inference-engine/src/vpu/common/src/configuration/switch_converters.cpp rename inference-engine/src/vpu/{graph_transformer => common}/src/parsed_config.cpp (99%) create mode 100644 inference-engine/src/vpu/myriad_plugin/configuration/myriad_configuration.cpp create mode 100644 inference-engine/src/vpu/myriad_plugin/configuration/myriad_configuration.hpp diff --git a/inference-engine/include/ie_parameter.hpp b/inference-engine/include/ie_parameter.hpp index 1343f89db32939..683f02fd6a552f 100644 --- a/inference-engine/include/ie_parameter.hpp +++ b/inference-engine/include/ie_parameter.hpp @@ -86,7 +86,8 @@ class INFERENCE_ENGINE_API_CLASS(Parameter) { * @param parameter object */ template ::type, Parameter>::value>::type> + typename = typename std::enable_if::type, Parameter>::value && + !std::is_abstract::type>::value>::type> Parameter(T&& parameter) { // NOLINT static_assert(!std::is_same::type, Parameter>::value, "To prevent recursion"); ptr = new RealData::type>(std::forward(parameter)); @@ -254,6 +255,21 @@ class INFERENCE_ENGINE_API_CLASS(Parameter) { return !(*this == rhs); } + /** + * @brief Prints underlying object to the given output stream. + * Uses operator<< if it is defined, leaves stream unchanged otherwise. + * In case of empty parameter or nullptr stream immediately returns. + * + * @param object Object to be printed to the given output stream. + * @param stream Output stream object will be printed to. + */ + friend void PrintTo(const Parameter& object, std::ostream* stream) { + if (object.empty() || !stream) { + return; + } + object.ptr->print(*stream); + } + private: template struct CheckOperatorEqual { @@ -273,6 +289,24 @@ class INFERENCE_ENGINE_API_CLASS(Parameter) { template struct HasOperatorEqual : CheckOperatorEqual::type {}; + template + struct CheckOutputStreamOperator { + template + static auto test(W*) -> decltype(std::declval() << std::declval(), std::true_type()) { + return {}; + } + + template + static auto test(...) -> std::false_type { + return {}; + } + + using type = typename std::is_same(nullptr))>::type; + }; + + template + struct HasOutputStreamOperator : CheckOutputStreamOperator::type {}; + struct Any { #ifdef __ANDROID__ virtual ~Any(); @@ -282,6 +316,7 @@ class INFERENCE_ENGINE_API_CLASS(Parameter) { virtual bool is(const std::type_info&) const = 0; virtual Any* copy() const = 0; virtual bool operator==(const Any& rhs) const = 0; + virtual void print(std::ostream&) const = 0; }; template @@ -318,6 +353,20 @@ class INFERENCE_ENGINE_API_CLASS(Parameter) { bool operator==(const Any& rhs) const override { return rhs.is(typeid(T)) && equal(*this, rhs); } + + template + typename std::enable_if::value, void>::type + print(std::ostream& stream, const U& object) const {} + + template + typename std::enable_if::value, void>::type + print(std::ostream& stream, const U& object) const { + stream << object; + } + + void print(std::ostream& stream) const override { + print(stream, get()); + } }; template diff --git a/inference-engine/src/plugin_api/debug.h b/inference-engine/src/plugin_api/debug.h index 838c5b02941f00..d52c7b0b942038 100644 --- a/inference-engine/src/plugin_api/debug.h +++ b/inference-engine/src/plugin_api/debug.h @@ -25,6 +25,9 @@ #include "ie_algorithm.hpp" +namespace InferenceEngine { +namespace details { + /** * @brief Serializes a `std::vector` to a `std::ostream` * @ingroup ie_dev_api_error_debug @@ -32,7 +35,6 @@ * @param vec A vector to serialize * @return A reference to a `std::stream` */ -namespace std { template inline std::ostream& operator<<(std::ostream& out, const std::vector& vec) { if (vec.empty()) return std::operator<<(out, "[]"); @@ -42,10 +44,7 @@ inline std::ostream& operator<<(std::ostream& out, const std::vector& vec) { } return out << "]"; } -} // namespace std -namespace InferenceEngine { -namespace details { /** * @brief trim from start (in place) * @ingroup ie_dev_api_error_debug diff --git a/inference-engine/src/vpu/common/include/vpu/configuration.hpp b/inference-engine/src/vpu/common/include/vpu/configuration.hpp new file mode 100644 index 00000000000000..4ed6f77b91fdaf --- /dev/null +++ b/inference-engine/src/vpu/common/include/vpu/configuration.hpp @@ -0,0 +1,99 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include + +#include "caseless.hpp" + +#include "vpu/utils/optional.hpp" + +namespace vpu { + +struct CompilationConfig { + int numSHAVEs = -1; + int numCMXSlices = -1; + int numExecutors = -1; + int tilingCMXLimitKB = -1; + + bool hwOptimization = true; + bool hwExtraSplit = false; + + std::string irWithVpuScalesDir; + + std::string customLayers; + + bool detectBatch = true; + + Optional injectSwOps; + Optional packDataInCmx; + bool mergeHwPoolToConv = true; + bool hwDilation = false; + bool forceDeprecatedCnnConversion = false; + bool enableEarlyEltwiseReLUFusion = true; + + std::map> ioStrides; + + // + // Debug options + // + + InferenceEngine::details::caseless_set hwWhiteList; + InferenceEngine::details::caseless_set hwBlackList; + + bool hwDisabled(const std::string& layerName) const { + if (!hwWhiteList.empty()) { + return hwWhiteList.count(layerName) == 0; + } + + if (!hwBlackList.empty()) { + return hwBlackList.count(layerName) != 0; + } + + return false; + } + + InferenceEngine::details::caseless_set noneLayers; + + bool skipAllLayers() const { + if (noneLayers.size() == 1) { + const auto& val = *noneLayers.begin(); + return val == "*"; + } + return false; + } + + bool skipLayerType(const std::string& layerType) const { + return noneLayers.count(layerType) != 0; + } + bool ignoreUnknownLayers = false; + + std::string dumpInternalGraphFileName; + std::string dumpInternalGraphDirectory; + bool dumpAllPasses; + + bool disableReorder = false; // TODO: rename to enableReorder and switch logic. + bool disableConvertStages = false; + bool enablePermuteMerging = true; + bool enableReplWithSCRelu = false; + bool enableReplaceWithReduceMean = true; + bool enableTensorIteratorUnrolling = false; + bool forcePureTensorIterator = false; + bool enableMemoryTypesAnnotation = false; + bool enableWeightsAnalysis = true; + bool checkPreprocessingInsideModel = true; + bool enableCustomReshapeParam = false; + + // + // Deprecated options + // + + float inputScale = 1.0f; + float inputBias = 0.0f; +}; + +} // namespace vpu diff --git a/inference-engine/src/vpu/common/include/vpu/configuration/as_parameter_enabler.hpp b/inference-engine/src/vpu/common/include/vpu/configuration/as_parameter_enabler.hpp new file mode 100644 index 00000000000000..4d480461ec7e71 --- /dev/null +++ b/inference-engine/src/vpu/common/include/vpu/configuration/as_parameter_enabler.hpp @@ -0,0 +1,18 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +#include "ie_parameter.hpp" + +template +struct AsParsedParameterEnabler { + static InferenceEngine::Parameter asParameter(const std::string& value) { return {OptionConcept::parse(value)}; } +}; + +struct AsParameterEnabler { + static InferenceEngine::Parameter asParameter(const std::string& value); +}; diff --git a/inference-engine/src/vpu/common/include/vpu/configuration/options/copy_optimization.hpp b/inference-engine/src/vpu/common/include/vpu/configuration/options/copy_optimization.hpp new file mode 100644 index 00000000000000..5777774fdf40cd --- /dev/null +++ b/inference-engine/src/vpu/common/include/vpu/configuration/options/copy_optimization.hpp @@ -0,0 +1,34 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +#include "vpu/configuration/as_parameter_enabler.hpp" + +namespace vpu { + +namespace details { + +enum class Access; +enum class Category; + +} // namespace details + +class PluginConfiguration; + +struct CopyOptimizationOption : public AsParsedParameterEnabler { + using value_type = bool; + + static std::string key(); + static void validate(const std::string&); + static void validate(const PluginConfiguration&); + static std::string defaultValue(); + static value_type parse(const std::string&); + static details::Access access(); + static details::Category category(); +}; + +} // namespace vpu diff --git a/inference-engine/src/vpu/common/include/vpu/configuration/options/log_level.hpp b/inference-engine/src/vpu/common/include/vpu/configuration/options/log_level.hpp new file mode 100644 index 00000000000000..48ced0d2fbbdd7 --- /dev/null +++ b/inference-engine/src/vpu/common/include/vpu/configuration/options/log_level.hpp @@ -0,0 +1,36 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +#include "vpu/configuration/as_parameter_enabler.hpp" + +namespace vpu { + +enum class LogLevel; + +namespace details { + +enum class Access; +enum class Category; + +} // namespace details + +class PluginConfiguration; + +struct LogLevelOption : public AsParameterEnabler { + using value_type = LogLevel; + + static std::string key(); + static void validate(const std::string&); + static void validate(const PluginConfiguration&); + static std::string defaultValue(); + static value_type parse(const std::string&); + static details::Access access(); + static details::Category category(); +}; + +} // namespace vpu diff --git a/inference-engine/src/vpu/common/include/vpu/configuration/plugin_configuration.hpp b/inference-engine/src/vpu/common/include/vpu/configuration/plugin_configuration.hpp new file mode 100644 index 00000000000000..ced07f36477ee9 --- /dev/null +++ b/inference-engine/src/vpu/common/include/vpu/configuration/plugin_configuration.hpp @@ -0,0 +1,142 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "ie_parameter.hpp" + +#include "vpu/utils/logger.hpp" + +namespace vpu { + +class PluginConfiguration; + +struct ConfigurationOptionConcept { + virtual std::string key() const = 0; + virtual void validate(const std::string&) const = 0; + virtual void validate(const PluginConfiguration&) const = 0; + virtual InferenceEngine::Parameter asParameter(const std::string&) const = 0; +}; + +namespace details { + +template +struct ConfigurationOptionModel : public ConfigurationOptionConcept { + std::string key() const override { return Option::key(); } + void validate(const std::string& value) const override { return Option::validate(value); } + void validate(const PluginConfiguration& options) const override { Option::validate(options); } + InferenceEngine::Parameter asParameter(const std::string& value) const override { return Option::asParameter(value); } +}; + +enum class Deprecation { + Off, + On +}; + +enum class Access { + Private, + Public +}; + +enum class Category { + CompileTime, + RunTime +}; + +class ConfigurationEntry { +public: + template + ConfigurationEntry(Option, details::Deprecation deprecation) + : m_access(Option::access()) + , m_deprecation(deprecation) + , m_category(Option::category()) + , m_value(std::make_shared>()) + {} + + ConfigurationOptionConcept& get(); + const ConfigurationOptionConcept& get() const; + + std::string key() const; + bool isPrivate() const; + bool isDeprecated() const; + Category getCategory() const; + +private: + Access m_access = Access::Public; + Deprecation m_deprecation = Deprecation::Off; + Category m_category = Category::CompileTime; + std::shared_ptr m_value; +}; + +} // namespace details + +// TODO: remove virtual inheritance once all options are migrated +// it's needed to pass updated compilation config to graph transformer +class PluginConfiguration : public virtual ParsedConfig { +public: + PluginConfiguration(); + + void from(const std::map& config); + void fromAtRuntime(const std::map& config); + std::unordered_set getPublicKeys() const; + bool supports(const std::string& key) const; + + template + void registerOption() { + const auto& key = Option::key(); + concepts.emplace(key, details::ConfigurationEntry(Option{}, details::Deprecation::Off)); + if (values.count(key) == 0) { + // option could be registered more than once if there are deprecated versions of it + values.emplace(key, Option::defaultValue()); + } + } + + template + void registerDeprecatedOption(const std::string& deprecatedKey) { + const auto& key = Option::key(); + concepts.emplace(deprecatedKey, details::ConfigurationEntry(Option{}, details::Deprecation::On)); + if (values.count(key) == 0) { + // option could be registered more than once if there are deprecated versions of it + values.emplace(key, Option::defaultValue()); + } + } + + template + typename Option::value_type get() const { + const auto& key = Option::key(); + validate(key); + return Option::parse(values.at(key)); + } + + void set(const std::string& key, const std::string& value); + + const std::string& operator[](const std::string& key) const; + + InferenceEngine::Parameter asParameter(const std::string& key) const; + + virtual void validate() const; + +private: + std::unordered_map concepts; + std::unordered_map values; + + Logger::Ptr logger; + + enum class Mode { + Default, + RunTime + }; + void create(const std::map& config, Mode mode = Mode::Default); + + void validate(const std::string& key) const; +}; + +} // namespace vpu diff --git a/inference-engine/src/vpu/common/include/vpu/configuration/switch_converters.hpp b/inference-engine/src/vpu/common/include/vpu/configuration/switch_converters.hpp new file mode 100644 index 00000000000000..0348286871a708 --- /dev/null +++ b/inference-engine/src/vpu/common/include/vpu/configuration/switch_converters.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +namespace vpu { + +const std::unordered_map& string2switch(); +const std::unordered_map& switch2string(); + +} // namespace vpu diff --git a/inference-engine/src/vpu/graph_transformer/include/vpu/parsed_config.hpp b/inference-engine/src/vpu/common/include/vpu/parsed_config.hpp similarity index 80% rename from inference-engine/src/vpu/graph_transformer/include/vpu/parsed_config.hpp rename to inference-engine/src/vpu/common/include/vpu/parsed_config.hpp index d220cda3c3ba56..aa1793806e945d 100644 --- a/inference-engine/src/vpu/graph_transformer/include/vpu/parsed_config.hpp +++ b/inference-engine/src/vpu/common/include/vpu/parsed_config.hpp @@ -10,11 +10,11 @@ #include #include +#include #include #include -#include #include #include #include @@ -23,6 +23,12 @@ namespace vpu { class ParsedConfig : public ParsedConfigBase { public: + ParsedConfig() = default; + ParsedConfig(const ParsedConfig&) = default; + ParsedConfig& operator=(const ParsedConfig&) = default; + ParsedConfig(ParsedConfig&&) = delete; + ParsedConfig& operator=(ParsedConfig&&) = delete; + const std::string& compilerLogFilePath() const { return _compilerLogFilePath; } @@ -31,6 +37,10 @@ class ParsedConfig : public ParsedConfigBase { return _compileConfig; } + CompilationConfig& compileConfig() { + return _compileConfig; + } + bool printReceiveTensorTime() const { return _printReceiveTensorTime; } diff --git a/inference-engine/src/vpu/common/include/vpu/parsed_config_base.hpp b/inference-engine/src/vpu/common/include/vpu/parsed_config_base.hpp index 6c7e776461d139..fc57ea8ed240f3 100644 --- a/inference-engine/src/vpu/common/include/vpu/parsed_config_base.hpp +++ b/inference-engine/src/vpu/common/include/vpu/parsed_config_base.hpp @@ -25,10 +25,6 @@ VPU_DECLARE_ENUM(ConfigMode, class ParsedConfigBase { public: - LogLevel logLevel() const { - return _logLevel; - } - bool exclusiveAsyncRequests() const { return _exclusiveAsyncRequests; } @@ -37,11 +33,9 @@ class ParsedConfigBase { ParsedConfigBase(); virtual ~ParsedConfigBase(); - void update( - const std::map& config, - ConfigMode mode = ConfigMode::Any); - protected: + void update(const std::map& config, ConfigMode mode = ConfigMode::Any); + virtual const std::unordered_set& getCompileOptions() const; virtual const std::unordered_set& getRunTimeOptions() const; virtual const std::unordered_set& getDeprecatedOptions() const; @@ -130,7 +124,6 @@ class ParsedConfigBase { Logger::Ptr _log; private: - LogLevel _logLevel = LogLevel::None; bool _exclusiveAsyncRequests = false; }; diff --git a/inference-engine/src/vpu/graph_transformer/include/vpu/private_plugin_config.hpp b/inference-engine/src/vpu/common/include/vpu/private_plugin_config.hpp similarity index 100% rename from inference-engine/src/vpu/graph_transformer/include/vpu/private_plugin_config.hpp rename to inference-engine/src/vpu/common/include/vpu/private_plugin_config.hpp diff --git a/inference-engine/src/vpu/common/include/vpu/utils/containers.hpp b/inference-engine/src/vpu/common/include/vpu/utils/containers.hpp new file mode 100644 index 00000000000000..745613c977ece8 --- /dev/null +++ b/inference-engine/src/vpu/common/include/vpu/utils/containers.hpp @@ -0,0 +1,40 @@ +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +#include "error.hpp" + +namespace vpu { + +template class Map> +inline std::vector getKeys(const Map& map) { + auto keys = std::vector{}; + keys.reserve(map.size()); + std::transform(map.cbegin(), map.cend(), std::back_inserter(keys), [](const std::pair& entry) { return entry.first; }); + return keys; +} + +template class Map> +inline std::vector getValues(const Map& map) { + auto values = std::vector{}; + values.reserve(map.size()); + std::transform(map.cbegin(), map.cend(), std::back_inserter(values), [](const std::pair& entry) { return entry.second; }); + return values; +} + +template class Map> +inline Map inverse(const Map& map) { + auto inverted = Map{}; + for (const auto& entry : map) { + const auto& insertion = inverted.emplace(entry.second, entry.first); + VPU_THROW_UNLESS(insertion.second, "Could not invert map {} due to duplicated value \"{}\"", map, entry.second); + } + return inverted; +} + +} // namespace vpu diff --git a/inference-engine/src/vpu/common/include/vpu/utils/error.hpp b/inference-engine/src/vpu/common/include/vpu/utils/error.hpp index 2180e6c86c0320..1c36e1f7dd41d5 100644 --- a/inference-engine/src/vpu/common/include/vpu/utils/error.hpp +++ b/inference-engine/src/vpu/common/include/vpu/utils/error.hpp @@ -29,6 +29,11 @@ class UnsupportedLayerException : public VPUException { using VPUException::VPUException; }; +class UnsupportedConfigurationOptionException : public VPUException { +public: + using VPUException::VPUException; +}; + template void throwFormat(const char* fileName, int lineNumber, const char* messageFormat, Args&&... args) { IE_THROW(GeneralError) << '\n' << fileName << ':' << lineNumber << ' ' @@ -47,13 +52,20 @@ void throwFormat(const char* fileName, int lineNumber, const char* messageFormat } \ } while (false) -#define VPU_THROW_UNSUPPORTED_UNLESS(condition, ...) \ +#define VPU_THROW_UNSUPPORTED_LAYER_UNLESS(condition, ...) \ do { \ if (!(condition)) { \ ::vpu::details::throwFormat<::vpu::details::UnsupportedLayerException>(__FILE__, __LINE__, __VA_ARGS__); \ } \ } while (false) +#define VPU_THROW_UNSUPPORTED_OPTION_UNLESS(condition, ...) \ + do { \ + if (!(condition)) { \ + ::vpu::details::throwFormat<::vpu::details::UnsupportedConfigurationOptionException>(__FILE__, __LINE__, __VA_ARGS__); \ + } \ + } while (false) + #ifdef NDEBUG # define VPU_INTERNAL_CHECK(condition, ...) \ do { \ diff --git a/inference-engine/src/vpu/common/include/vpu/utils/log_level.hpp b/inference-engine/src/vpu/common/include/vpu/utils/log_level.hpp new file mode 100644 index 00000000000000..51eb753150815d --- /dev/null +++ b/inference-engine/src/vpu/common/include/vpu/utils/log_level.hpp @@ -0,0 +1,21 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "vpu/utils/enums.hpp" + +namespace vpu { + +VPU_DECLARE_ENUM(LogLevel, + None, + Fatal, /* used for very severe error events that will most probably cause the application to terminate */ + Error, /* reporting events which are not expected during normal execution, containing probable reason */ + Warning, /* indicating events which are not usual and might lead to errors later */ + Info, /* short enough messages about ongoing activity in the process */ + Debug, /* more fine-grained messages with references to particular data and explanations */ + Trace /* involved and detailed information about execution, helps to trace the execution flow, produces huge output */ +) + +} // namespace vpu diff --git a/inference-engine/src/vpu/common/include/vpu/utils/logger.hpp b/inference-engine/src/vpu/common/include/vpu/utils/logger.hpp index de06c8511adcfd..931d02a1648ce4 100644 --- a/inference-engine/src/vpu/common/include/vpu/utils/logger.hpp +++ b/inference-engine/src/vpu/common/include/vpu/utils/logger.hpp @@ -13,6 +13,7 @@ #include #include #include +#include namespace vpu { @@ -39,20 +40,6 @@ OutputStream::Ptr fileOutput(const std::string& fileName); OutputStream::Ptr defaultOutput(const std::string& fileName = std::string()); -// -// Logger -// - -VPU_DECLARE_ENUM(LogLevel, - None, - Fatal, /* used for very severe error events that will most probably cause the application to terminate */ - Error, /* reporting events which are not expected during normal execution, containing probable reason */ - Warning, /* indicating events which are not usual and might lead to errors later */ - Info, /* short enough messages about ongoing activity in the process */ - Debug, /* more fine-grained messages with references to particular data and explanations */ - Trace /* involved and detailed information about execution, helps to trace the execution flow, produces huge output */ -) - class Logger final { public: using Ptr = std::shared_ptr; diff --git a/inference-engine/src/vpu/common/src/configuration/as_parameter_enabler.cpp b/inference-engine/src/vpu/common/src/configuration/as_parameter_enabler.cpp new file mode 100644 index 00000000000000..04c9d525971e72 --- /dev/null +++ b/inference-engine/src/vpu/common/src/configuration/as_parameter_enabler.cpp @@ -0,0 +1,10 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +InferenceEngine::Parameter AsParameterEnabler::asParameter(const std::string& value) { + return {value}; +} + diff --git a/inference-engine/src/vpu/common/src/configuration/options/copy_optimization.cpp b/inference-engine/src/vpu/common/src/configuration/options/copy_optimization.cpp new file mode 100644 index 00000000000000..7fc384aac01d6b --- /dev/null +++ b/inference-engine/src/vpu/common/src/configuration/options/copy_optimization.cpp @@ -0,0 +1,45 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "vpu/private_plugin_config.hpp" +#include "vpu/utils/containers.hpp" +#include "vpu/configuration/options/copy_optimization.hpp" +#include "vpu/configuration/switch_converters.hpp" +#include "vpu/configuration/plugin_configuration.hpp" + +namespace vpu { + +void CopyOptimizationOption::validate(const std::string& value) { + const auto& converters = string2switch(); + VPU_THROW_UNLESS(converters.count(value) != 0, R"(unexpected copy optimization option value "{}", only {} are supported)", value, getKeys(converters)); +} + +void CopyOptimizationOption::validate(const PluginConfiguration& configuration) { + validate(configuration[key()]); +} + +std::string CopyOptimizationOption::key() { + return InferenceEngine::MYRIAD_COPY_OPTIMIZATION; +} + +details::Access CopyOptimizationOption::access() { + return details::Access::Private; +} + +details::Category CopyOptimizationOption::category() { + return details::Category::CompileTime; +} + +std::string CopyOptimizationOption::defaultValue() { + return InferenceEngine::PluginConfigParams::YES; +} + +CopyOptimizationOption::value_type CopyOptimizationOption::parse(const std::string& value) { + const auto& converters = string2switch(); + VPU_THROW_UNSUPPORTED_OPTION_UNLESS(converters.count(value) != 0, R"(unexpected copy optimization option value "{}", only {} are supported)", + value, getKeys(converters)); + return converters.at(value); +} + +} // namespace vpu diff --git a/inference-engine/src/vpu/common/src/configuration/options/log_level.cpp b/inference-engine/src/vpu/common/src/configuration/options/log_level.cpp new file mode 100644 index 00000000000000..79729aebfef8d3 --- /dev/null +++ b/inference-engine/src/vpu/common/src/configuration/options/log_level.cpp @@ -0,0 +1,64 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "vpu/configuration/options/log_level.hpp" +#include "vpu/utils/log_level.hpp" +#include "vpu/utils/containers.hpp" +#include "vpu/configuration/plugin_configuration.hpp" + +#include "ie_plugin_config.hpp" + +#include + +namespace vpu { + +namespace { + +const std::unordered_map& string2level() { + static const std::unordered_map converters = { + {CONFIG_VALUE(LOG_NONE), LogLevel::None}, + {CONFIG_VALUE(LOG_ERROR), LogLevel::Error}, + {CONFIG_VALUE(LOG_WARNING), LogLevel::Warning}, + {CONFIG_VALUE(LOG_INFO), LogLevel::Info}, + {CONFIG_VALUE(LOG_DEBUG), LogLevel::Debug}, + {CONFIG_VALUE(LOG_TRACE), LogLevel::Trace}, + }; + return converters; +} + +} // namespace + +void LogLevelOption::validate(const std::string& value) { + const auto& converters = string2level(); + VPU_THROW_UNLESS(converters.count(value) != 0, R"(unexpected log level option value "{}", only {} are supported)", value, getKeys(converters)); +} + +void LogLevelOption::validate(const PluginConfiguration& configuration) { + validate(configuration[key()]); +} + +std::string LogLevelOption::key() { + return InferenceEngine::PluginConfigParams::KEY_LOG_LEVEL; +} + +details::Access LogLevelOption::access() { + return details::Access::Public; +} + +details::Category LogLevelOption::category() { + return details::Category::CompileTime; +} + +std::string LogLevelOption::defaultValue() { + return InferenceEngine::PluginConfigParams::LOG_NONE; +} + +LogLevelOption::value_type LogLevelOption::parse(const std::string& value) { + const auto& converters = string2level(); + VPU_THROW_UNSUPPORTED_OPTION_UNLESS(converters.count(value) != 0, R"(unexpected log level option value "{}", only {} are supported)", + value, getKeys(converters)); + return converters.at(value); +} + +} // namespace vpu diff --git a/inference-engine/src/vpu/common/src/configuration/plugin_configuration.cpp b/inference-engine/src/vpu/common/src/configuration/plugin_configuration.cpp new file mode 100644 index 00000000000000..6e051606c675b1 --- /dev/null +++ b/inference-engine/src/vpu/common/src/configuration/plugin_configuration.cpp @@ -0,0 +1,114 @@ +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "vpu/utils/error.hpp" +#include "vpu/configuration/plugin_configuration.hpp" + +#include "ie_plugin_config.hpp" + +namespace vpu { + +namespace details { + +ConfigurationOptionConcept& ConfigurationEntry::get() { + return *m_value; +} + +const ConfigurationOptionConcept& ConfigurationEntry::get() const { + return *m_value; +} + +bool ConfigurationEntry::isPrivate() const { + return m_access == Access::Private; +} + +bool ConfigurationEntry::isDeprecated() const { + return m_deprecation == Deprecation::On; +} + +Category ConfigurationEntry::getCategory() const { + return m_category; +} + +std::string ConfigurationEntry::key() const { + return m_value->key(); +} + +} // namespace details + +PluginConfiguration::PluginConfiguration() : logger(std::make_shared("Configuration", LogLevel::Warning, consoleOutput())) {} + + +std::unordered_set PluginConfiguration::getPublicKeys() const { + auto publicKeys = std::unordered_set{}; + for (const auto& entry : concepts) { + const auto& key = entry.first; + const auto& option = entry.second; + if (option.isPrivate()) { + continue; + } + publicKeys.insert(key); + } + return publicKeys; +} + +bool PluginConfiguration::supports(const std::string& key) const { + return concepts.count(key) != 0; +} + +void PluginConfiguration::from(const std::map& config) { + create(config); +} + +void PluginConfiguration::fromAtRuntime(const std::map& config) { + create(config, Mode::RunTime); +} + +void PluginConfiguration::validate() const { + for (const auto& option : concepts) { + option.second.get().validate(*this); + } +} + +void PluginConfiguration::create(const std::map& config, Mode mode) { + for (const auto& entry : config) { + const auto& key = entry.first; + validate(key); + + const auto& optionConcept = concepts.at(key); + if (mode == Mode::RunTime && optionConcept.getCategory() == details::Category::CompileTime) { + logger->warning("Configuration option \"{}\" is used after network is loaded. Its value is going to be ignored.", key); + continue; + } + + const auto& value = entry.second; + set(key, value); + } +} + +InferenceEngine::Parameter PluginConfiguration::asParameter(const std::string& key) const { + const auto& value = operator[](key); + return concepts.at(key).get().asParameter(value); +} + +void PluginConfiguration::validate(const std::string& key) const { + VPU_THROW_UNSUPPORTED_OPTION_UNLESS(supports(key), "Encountered an unsupported key {}, supported keys are {}", key, getPublicKeys()); + if (concepts.at(key).isDeprecated()) { + logger->warning("Encountered deprecated option {} usage, consider replacing it with {} option", key, concepts.at(key).key()); + } +} + +const std::string& PluginConfiguration::operator[](const std::string& key) const { + validate(key); + return values.at(concepts.at(key).key()); +} + +void PluginConfiguration::set(const std::string& key, const std::string& value) { + validate(key); + const auto& optionConcept = concepts.at(key).get(); + optionConcept.validate(value); + values[optionConcept.key()] = value; +} + +} // namespace vpu diff --git a/inference-engine/src/vpu/common/src/configuration/switch_converters.cpp b/inference-engine/src/vpu/common/src/configuration/switch_converters.cpp new file mode 100644 index 00000000000000..232b184cf8dfb2 --- /dev/null +++ b/inference-engine/src/vpu/common/src/configuration/switch_converters.cpp @@ -0,0 +1,25 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "vpu/utils/containers.hpp" +#include "vpu/configuration/switch_converters.hpp" + +#include "ie_plugin_config.hpp" + +namespace vpu { + +const std::unordered_map& string2switch() { + static const std::unordered_map converters = { + {CONFIG_VALUE(NO), false}, + {CONFIG_VALUE(YES), true} + }; + return converters; +} + +const std::unordered_map& switch2string() { + static const auto converters = inverse(string2switch()); + return converters; +} + +} // namespace vpu diff --git a/inference-engine/src/vpu/graph_transformer/src/parsed_config.cpp b/inference-engine/src/vpu/common/src/parsed_config.cpp similarity index 99% rename from inference-engine/src/vpu/graph_transformer/src/parsed_config.cpp rename to inference-engine/src/vpu/common/src/parsed_config.cpp index 5e8779a73127ee..b0a2ec46c9392a 100644 --- a/inference-engine/src/vpu/graph_transformer/src/parsed_config.cpp +++ b/inference-engine/src/vpu/common/src/parsed_config.cpp @@ -169,7 +169,6 @@ void ParsedConfig::parse(const std::map& config) { setOption(_compileConfig.dumpAllPasses, switches, config, ie::MYRIAD_DUMP_ALL_PASSES); setOption(_compileConfig.detectBatch, switches, config, ie::MYRIAD_DETECT_NETWORK_BATCH); - setOption(_compileConfig.copyOptimization, switches, config, ie::MYRIAD_COPY_OPTIMIZATION); setOption(_compileConfig.packDataInCmx, switches, config, ie::MYRIAD_PACK_DATA_IN_CMX); setOption(_compileConfig.ignoreUnknownLayers, switches, config, ie::MYRIAD_IGNORE_UNKNOWN_LAYERS); setOption(_compileConfig.hwOptimization, switches, config, ie::MYRIAD_ENABLE_HW_ACCELERATION); diff --git a/inference-engine/src/vpu/common/src/parsed_config_base.cpp b/inference-engine/src/vpu/common/src/parsed_config_base.cpp index 876232bd15e820..c9e8a36f4a7c45 100644 --- a/inference-engine/src/vpu/common/src/parsed_config_base.cpp +++ b/inference-engine/src/vpu/common/src/parsed_config_base.cpp @@ -59,13 +59,7 @@ void ParsedConfigBase::update( } const std::unordered_set& ParsedConfigBase::getCompileOptions() const { -IE_SUPPRESS_DEPRECATED_START - static const std::unordered_set options = { - CONFIG_KEY(LOG_LEVEL), - VPU_CONFIG_KEY(LOG_LEVEL) - }; -IE_SUPPRESS_DEPRECATED_END - + static const std::unordered_set options; return options; } @@ -73,8 +67,6 @@ const std::unordered_set& ParsedConfigBase::getRunTimeOptions() con IE_SUPPRESS_DEPRECATED_START static const std::unordered_set options = { CONFIG_KEY(EXCLUSIVE_ASYNC_REQUESTS), - CONFIG_KEY(LOG_LEVEL), - VPU_CONFIG_KEY(LOG_LEVEL) }; IE_SUPPRESS_DEPRECATED_END @@ -82,37 +74,12 @@ IE_SUPPRESS_DEPRECATED_END } const std::unordered_set& ParsedConfigBase::getDeprecatedOptions() const { - IE_SUPPRESS_DEPRECATED_START - static const std::unordered_set options = { - VPU_CONFIG_KEY(LOG_LEVEL) - }; - IE_SUPPRESS_DEPRECATED_END - + static const std::unordered_set options; return options; } void ParsedConfigBase::parse(const std::map& config) { - static const std::unordered_map logLevels = { - { CONFIG_VALUE(LOG_NONE), LogLevel::None }, - { CONFIG_VALUE(LOG_ERROR), LogLevel::Error }, - { CONFIG_VALUE(LOG_WARNING), LogLevel::Warning }, - { CONFIG_VALUE(LOG_INFO), LogLevel::Info }, - { CONFIG_VALUE(LOG_DEBUG), LogLevel::Debug }, - { CONFIG_VALUE(LOG_TRACE), LogLevel::Trace } - }; - - setOption(_logLevel, logLevels, config, CONFIG_KEY(LOG_LEVEL)); setOption(_exclusiveAsyncRequests, switches, config, CONFIG_KEY(EXCLUSIVE_ASYNC_REQUESTS)); - -IE_SUPPRESS_DEPRECATED_START - setOption(_logLevel, logLevels, config, VPU_CONFIG_KEY(LOG_LEVEL)); -IE_SUPPRESS_DEPRECATED_END - -#ifndef NDEBUG - if (const auto envVar = std::getenv("IE_VPU_LOG_LEVEL")) { - _logLevel = logLevels.at(envVar); - } -#endif } std::unordered_set ParsedConfigBase::merge( diff --git a/inference-engine/src/vpu/graph_transformer/CMakeLists.txt b/inference-engine/src/vpu/graph_transformer/CMakeLists.txt index bc73ab5b155696..1de08e8cae3be4 100644 --- a/inference-engine/src/vpu/graph_transformer/CMakeLists.txt +++ b/inference-engine/src/vpu/graph_transformer/CMakeLists.txt @@ -48,8 +48,13 @@ function(add_graph_transformer_target TARGET_NAME STATIC_IE) target_link_libraries(${TARGET_NAME} PUBLIC pugixml vpu_common_lib) endif() - target_link_libraries(${TARGET_NAME} PUBLIC ${NGRAPH_LIBRARIES} - PRIVATE openvino::itt) + target_link_libraries(${TARGET_NAME} + PUBLIC + ${NGRAPH_LIBRARIES} + PRIVATE + openvino::itt + mvnc # TODO: remove once all options are migrated + ) if(WIN32) target_compile_definitions(${TARGET_NAME} PRIVATE NOMINMAX) diff --git a/inference-engine/src/vpu/graph_transformer/include/vpu/compile_env.hpp b/inference-engine/src/vpu/graph_transformer/include/vpu/compile_env.hpp index 157b13a0b59b03..3228c7e1a4cedf 100644 --- a/inference-engine/src/vpu/graph_transformer/include/vpu/compile_env.hpp +++ b/inference-engine/src/vpu/graph_transformer/include/vpu/compile_env.hpp @@ -8,28 +8,29 @@ #include #include #include +#include namespace vpu { struct DeviceResources { - static int numShaves(const Platform& platform); - static int numSlices(const Platform& platform); + static int numShaves(const ncDevicePlatform_t& platform); + static int numSlices(const ncDevicePlatform_t& platform); static int numStreams(); }; struct DefaultAllocation { - static int numStreams(const Platform& platform, const CompilationConfig& configuration); - static int numSlices(const Platform& platform, int numStreams); - static int numShaves(const Platform& platform, int numStreams, int numSlices); + static int numStreams(const ncDevicePlatform_t& platform, const PluginConfiguration& configuration); + static int numSlices(const ncDevicePlatform_t& platform, int numStreams); + static int numShaves(const ncDevicePlatform_t& platform, int numStreams, int numSlices); static int tilingCMXLimit(int numSlices); }; struct CompileEnv final { public: - Platform platform; + ncDevicePlatform_t platform; Resources resources; - CompilationConfig config; + PluginConfiguration config; Logger::Ptr log; @@ -49,14 +50,14 @@ struct CompileEnv final { static const CompileEnv* getOrNull(); static void init( - Platform platform, - const CompilationConfig& config, - const Logger::Ptr& log); - static void updateConfig(const CompilationConfig& config); + ncDevicePlatform_t platform, + const PluginConfiguration& config, + const Logger::Ptr& log); + static void updateConfig(const PluginConfiguration& config); static void free(); private: - explicit CompileEnv(Platform platform); + explicit CompileEnv(ncDevicePlatform_t platform); }; } // namespace vpu diff --git a/inference-engine/src/vpu/graph_transformer/include/vpu/graph_transformer.hpp b/inference-engine/src/vpu/graph_transformer/include/vpu/graph_transformer.hpp index c0881b9b0c6ddc..afe4974502ccb3 100644 --- a/inference-engine/src/vpu/graph_transformer/include/vpu/graph_transformer.hpp +++ b/inference-engine/src/vpu/graph_transformer/include/vpu/graph_transformer.hpp @@ -21,108 +21,14 @@ #include #include #include +#include + +#include "mvnc.h" namespace vpu { namespace ie = InferenceEngine; -// -// CompilationConfig -// - -VPU_DECLARE_ENUM(Platform, - MYRIAD_2 = 2450, - MYRIAD_X = 2480, -) - -struct CompilationConfig final { - // - // Compilation options - // - - int numSHAVEs = -1; - int numCMXSlices = -1; - int numExecutors = -1; - int tilingCMXLimitKB = -1; - - bool hwOptimization = true; - bool hwExtraSplit = false; - - std::string irWithVpuScalesDir; - - std::string customLayers; - - bool detectBatch = true; - - Optional copyOptimization; - Optional injectSwOps; - Optional packDataInCmx; - bool mergeHwPoolToConv = true; - bool hwDilation = false; - bool forceDeprecatedCnnConversion = false; - bool enableEarlyEltwiseReLUFusion = true; - - std::map> ioStrides; - - // - // Debug options - // - - ie::details::caseless_set hwWhiteList; - ie::details::caseless_set hwBlackList; - - bool hwDisabled(const std::string& layerName) const { - if (!hwWhiteList.empty()) { - return hwWhiteList.count(layerName) == 0; - } - - if (!hwBlackList.empty()) { - return hwBlackList.count(layerName) != 0; - } - - return false; - } - - ie::details::caseless_set noneLayers; - - bool skipAllLayers() const { - if (noneLayers.size() == 1) { - const auto& val = *noneLayers.begin(); - return val == "*"; - } - return false; - } - - bool skipLayerType(const std::string& layerType) const { - return noneLayers.count(layerType) != 0; - } - bool ignoreUnknownLayers = false; - - std::string dumpInternalGraphFileName; - std::string dumpInternalGraphDirectory; - bool dumpAllPasses; - - bool disableReorder = false; // TODO: rename to enableReorder and switch logic. - bool disableConvertStages = false; - bool enablePermuteMerging = true; - bool enableReplWithSCRelu = false; - bool enableReplaceWithReduceMean = true; - bool enableTensorIteratorUnrolling = false; - bool forcePureTensorIterator = false; - bool enableMemoryTypesAnnotation = false; - bool enableWeightsAnalysis = true; - bool checkPreprocessingInsideModel = true; - bool enableCustomReshapeParam = false; - - // - // Deprecated options - // - - float inputScale = 1.0f; - float inputBias = 0.0f; -}; - - // // DataInfo // @@ -165,17 +71,17 @@ struct CompiledGraph final { // compileNetwork // -CompiledGraph::Ptr compileNetwork(const ie::CNNNetwork& network, Platform platform, const CompilationConfig& config, const Logger::Ptr& log, - const ie::ICore* core); +CompiledGraph::Ptr compileNetwork(const ie::CNNNetwork& network, ncDevicePlatform_t platform, const PluginConfiguration& config, const Logger::Ptr& log, + const ie::ICore* core); -CompiledGraph::Ptr compileSubNetwork(const ie::CNNNetwork& network, const CompilationConfig& subConfig, const ie::ICore* core); +CompiledGraph::Ptr compileSubNetwork(const ie::CNNNetwork& network, const PluginConfiguration& subConfig, const ie::ICore* core); // // getSupportedLayers // -std::set getSupportedLayers(const ie::CNNNetwork& network, Platform platform, const CompilationConfig& config, const Logger::Ptr& log, - const ie::ICore* core); +std::set getSupportedLayers(const ie::CNNNetwork& network, ncDevicePlatform_t platform, const PluginConfiguration& config, const Logger::Ptr& log, + const ie::ICore* core); // // Blob version and checks diff --git a/inference-engine/src/vpu/graph_transformer/include/vpu/graph_transformer_internal.hpp b/inference-engine/src/vpu/graph_transformer/include/vpu/graph_transformer_internal.hpp index 141512bd40cecc..99cddb1be791c9 100644 --- a/inference-engine/src/vpu/graph_transformer/include/vpu/graph_transformer_internal.hpp +++ b/inference-engine/src/vpu/graph_transformer/include/vpu/graph_transformer_internal.hpp @@ -12,8 +12,8 @@ namespace vpu { CompiledGraph::Ptr compileModel( const Model& model, - Platform platform, - const CompilationConfig& config, + ncDevicePlatform_t platform, + const PluginConfiguration& config, const Logger::Ptr& log); } // namespace vpu diff --git a/inference-engine/src/vpu/graph_transformer/src/backend/backend.cpp b/inference-engine/src/vpu/graph_transformer/src/backend/backend.cpp index fdb632993b6f6b..27a9d40794e7b0 100644 --- a/inference-engine/src/vpu/graph_transformer/src/backend/backend.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/backend/backend.cpp @@ -85,12 +85,12 @@ void BackEnd::dumpModel( std::string fileName; - if (!env.config.dumpInternalGraphFileName.empty()) { - fileName = fileNameNoExt(env.config.dumpInternalGraphFileName); - } else if (!env.config.dumpInternalGraphDirectory.empty()) { + if (!env.config.compileConfig().dumpInternalGraphFileName.empty()) { + fileName = fileNameNoExt(env.config.compileConfig().dumpInternalGraphFileName); + } else if (!env.config.compileConfig().dumpInternalGraphDirectory.empty()) { fileName = formatString( "%s/vpu_graph_%f%f%i_%s", - env.config.dumpInternalGraphDirectory, + env.config.compileConfig().dumpInternalGraphDirectory, std::setw(2), std::setfill('0'), model->attrs().get("index"), replaceBadCharacters(model->name())); @@ -99,7 +99,7 @@ void BackEnd::dumpModel( } if (!postfix.empty()) { - if (!env.config.dumpAllPasses) { + if (!env.config.compileConfig().dumpAllPasses) { return; } diff --git a/inference-engine/src/vpu/graph_transformer/src/frontend/detect_network_batch.cpp b/inference-engine/src/vpu/graph_transformer/src/frontend/detect_network_batch.cpp index 9e3a3f7eab542e..48de8bb9f87dc2 100644 --- a/inference-engine/src/vpu/graph_transformer/src/frontend/detect_network_batch.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/frontend/detect_network_batch.cpp @@ -29,7 +29,7 @@ void FrontEnd::detectNetworkBatch( using PrecisionsMap = std::map; const auto& env = CompileEnv::get(); - if (!env.config.detectBatch) { + if (!env.config.compileConfig().detectBatch) { // skip batch extraction step and go as is return; } diff --git a/inference-engine/src/vpu/graph_transformer/src/frontend/frontend.cpp b/inference-engine/src/vpu/graph_transformer/src/frontend/frontend.cpp index 5ee49dd4ed2905..c399cdc8d2d5b6 100644 --- a/inference-engine/src/vpu/graph_transformer/src/frontend/frontend.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/frontend/frontend.cpp @@ -436,7 +436,7 @@ void FrontEnd::processTrivialCases(const Model& model) { void FrontEnd::defaultOnUnsupportedLayerCallback(const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs, const std::string& extraMessage) { const auto& env = CompileEnv::get(); - VPU_THROW_UNSUPPORTED_UNLESS(env.config.ignoreUnknownLayers, "Failed to compile layer \"%v\": %v", layer->name, extraMessage); + VPU_THROW_UNSUPPORTED_LAYER_UNLESS(env.config.compileConfig().ignoreUnknownLayers, "Failed to compile layer \"%v\": %v", layer->name, extraMessage); _stageBuilder->addNoneStage(model, layer->name, layer, inputs, outputs); } @@ -466,15 +466,15 @@ ModelPtr FrontEnd::runCommonPasses(ie::CNNNetwork network, // Parse custom layers // - if (!env.config.customLayers.empty()) { - env.log->trace("Parse custom layers : %s", env.config.customLayers); + if (!env.config.compileConfig().customLayers.empty()) { + env.log->trace("Parse custom layers : %s", env.config.compileConfig().customLayers); VPU_LOGGER_SECTION(env.log); - if (env.platform != Platform::MYRIAD_X) { + if (env.platform != ncDevicePlatform_t::NC_MYRIAD_X) { VPU_THROW_FORMAT("Custom layers are not supported for %v platforms", env.platform); } - _customLayers = CustomLayer::loadFromFile(env.config.customLayers); + _customLayers = CustomLayer::loadFromFile(env.config.compileConfig().customLayers); } // @@ -494,7 +494,7 @@ ModelPtr FrontEnd::runCommonPasses(ie::CNNNetwork network, env.log->trace("Update IE Network"); VPU_LOGGER_SECTION(env.log); - if (network.getFunction() && env.config.forceDeprecatedCnnConversion) { + if (network.getFunction() && env.config.compileConfig().forceDeprecatedCnnConversion) { network = convertNetwork(network); } @@ -545,7 +545,7 @@ ModelPtr FrontEnd::runCommonPasses(ie::CNNNetwork network, processTrivialCases(model); - if (!CompileEnv::get().config.disableConvertStages) { + if (!CompileEnv::get().config.compileConfig().disableConvertStages) { addDataTypeConvertStages(model); } @@ -567,7 +567,7 @@ ModelPtr FrontEnd::runCommonPasses(ie::CNNNetwork network, getInputAndOutputData(model, layer, inputs, outputs); - if (env.config.skipAllLayers() || env.config.skipLayerType(layer->type)) { + if (env.config.compileConfig().skipAllLayers() || env.config.compileConfig().skipLayerType(layer->type)) { _stageBuilder->addNoneStage(model, layer->name, layer, inputs, outputs); supportedLayer(layer); continue; diff --git a/inference-engine/src/vpu/graph_transformer/src/frontend/in_out_convert.cpp b/inference-engine/src/vpu/graph_transformer/src/frontend/in_out_convert.cpp index 6308504cfcc3db..159bd3430a4c01 100644 --- a/inference-engine/src/vpu/graph_transformer/src/frontend/in_out_convert.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/frontend/in_out_convert.cpp @@ -22,7 +22,7 @@ void FrontEnd::addDataTypeConvertStages(const Model& model) { env.log->trace("Add Data type conversion stages"); VPU_LOGGER_SECTION(env.log); - const bool hasScaleBias = env.config.inputScale != 1.0f || env.config.inputBias != 0.0f; + const bool hasScaleBias = env.config.compileConfig().inputScale != 1.0f || env.config.compileConfig().inputBias != 0.0f; for (const auto& input : model->datas()) { if (input->usage() != DataUsage::Input) { @@ -38,11 +38,11 @@ void FrontEnd::addDataTypeConvertStages(const Model& model) { env.log->trace("Apply deprecated scale/bias parameters"); std::ostringstream postfix; - if (env.config.inputScale != 1.0f) { - postfix << "@SCALE=" << InferenceEngine::CNNLayer::ie_serialize_float(env.config.inputScale); + if (env.config.compileConfig().inputScale != 1.0f) { + postfix << "@SCALE=" << InferenceEngine::CNNLayer::ie_serialize_float(env.config.compileConfig().inputScale); } - if (env.config.inputBias != 0.0f) { - postfix << "@BIAS=" << InferenceEngine::CNNLayer::ie_serialize_float(env.config.inputBias); + if (env.config.compileConfig().inputBias != 0.0f) { + postfix << "@BIAS=" << InferenceEngine::CNNLayer::ie_serialize_float(env.config.compileConfig().inputBias); } const auto scaledInput = model->duplicateData( @@ -55,9 +55,9 @@ void FrontEnd::addDataTypeConvertStages(const Model& model) { model, scaledInput->name(), nullptr, - env.config.inputScale, + env.config.compileConfig().inputScale, 1.0f, - env.config.inputBias, + env.config.compileConfig().inputBias, input, scaledInput); } @@ -89,8 +89,8 @@ void FrontEnd::addDataTypeConvertStages(const Model& model) { inputFP16->name(), input, inputFP16, - env.config.inputScale, - env.config.inputBias); + env.config.compileConfig().inputScale, + env.config.compileConfig().inputBias); break; } diff --git a/inference-engine/src/vpu/graph_transformer/src/frontend/parse_data.cpp b/inference-engine/src/vpu/graph_transformer/src/frontend/parse_data.cpp index 00ab79700603cd..392c0b86df84a5 100644 --- a/inference-engine/src/vpu/graph_transformer/src/frontend/parse_data.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/frontend/parse_data.cpp @@ -25,8 +25,8 @@ void FrontEnd::parseInputAndOutputData(const Model& model) { VPU_LOGGER_SECTION(env.log); const auto parseIOStrides = [&env](const std::string& name, const Data& data) { - const auto& match = env.config.ioStrides.find(name); - if (match == env.config.ioStrides.end()) { + const auto& match = env.config.compileConfig().ioStrides.find(name); + if (match == env.config.compileConfig().ioStrides.end()) { return; } diff --git a/inference-engine/src/vpu/graph_transformer/src/frontend/unroll_loops.cpp b/inference-engine/src/vpu/graph_transformer/src/frontend/unroll_loops.cpp index 28386c243a289e..34ca4835a9210a 100644 --- a/inference-engine/src/vpu/graph_transformer/src/frontend/unroll_loops.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/frontend/unroll_loops.cpp @@ -21,7 +21,7 @@ void FrontEnd::unrollLoops(ie::CNNNetwork& network) { env.log->trace("Unroll TensorIterator loops"); VPU_LOGGER_SECTION(env.log); - if (!env.config.irWithVpuScalesDir.empty()) { + if (!env.config.compileConfig().irWithVpuScalesDir.empty()) { // TODO: Scale dumps does not work with IR, which contain Tensor Iterator layers, because we cannot serialize them. #-23429 for (auto iterator = ie::details::CNNNetworkIterator(network); iterator != ie::details::CNNNetworkIterator(); ++iterator) { const auto& layer = *iterator; @@ -30,11 +30,11 @@ void FrontEnd::unrollLoops(ie::CNNNetwork& network) { } } - if (env.config.forcePureTensorIterator) { + if (env.config.compileConfig().forcePureTensorIterator) { return; } - if (env.config.enableTensorIteratorUnrolling) { + if (env.config.compileConfig().enableTensorIteratorUnrolling) { ie::NetPass::UnrollTI(network); } else { // Try to convert network to a RNN sequence due to performance reasons diff --git a/inference-engine/src/vpu/graph_transformer/src/graph_transformer.cpp b/inference-engine/src/vpu/graph_transformer/src/graph_transformer.cpp index 644529866ba949..180632e2846871 100644 --- a/inference-engine/src/vpu/graph_transformer/src/graph_transformer.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/graph_transformer.cpp @@ -42,6 +42,7 @@ #include #include #include +#include namespace vpu { @@ -55,7 +56,7 @@ thread_local CompileEnv* g_compileEnv = nullptr; } // namespace -CompileEnv::CompileEnv(Platform platform) : platform(platform) {} +CompileEnv::CompileEnv(ncDevicePlatform_t platform) : platform(platform) {} const CompileEnv& CompileEnv::get() { IE_ASSERT(g_compileEnv != nullptr); @@ -70,7 +71,7 @@ const CompileEnv* CompileEnv::getOrNull() { return g_compileEnv; } -void CompileEnv::init(Platform platform, const CompilationConfig& config, const Logger::Ptr& log) { +void CompileEnv::init(ncDevicePlatform_t platform, const PluginConfiguration& config, const Logger::Ptr& log) { g_compileEnv = new CompileEnv(platform); g_compileEnv->config = config; g_compileEnv->log = log; @@ -79,31 +80,37 @@ void CompileEnv::init(Platform platform, const CompilationConfig& config, const g_compileEnv->profile.setLogger(log); #endif - if (platform == Platform::MYRIAD_2) { - g_compileEnv->config.hwOptimization = false; + if (platform == ncDevicePlatform_t::NC_MYRIAD_2) { + g_compileEnv->config.compileConfig().hwOptimization = false; } - VPU_THROW_UNLESS(g_compileEnv->config.numSHAVEs <= g_compileEnv->config.numCMXSlices, + VPU_THROW_UNLESS(g_compileEnv->config.compileConfig().numSHAVEs <= g_compileEnv->config.compileConfig().numCMXSlices, R"(Value of configuration option ("{}") must be not greater than value of configuration option ("{}"), but {} > {} are provided)", - ie::MYRIAD_NUMBER_OF_SHAVES, ie::MYRIAD_NUMBER_OF_CMX_SLICES, config.numSHAVEs, config.numCMXSlices); + ie::MYRIAD_NUMBER_OF_SHAVES, ie::MYRIAD_NUMBER_OF_CMX_SLICES, config.compileConfig().numSHAVEs, config.compileConfig().numCMXSlices); - const auto numExecutors = config.numExecutors != -1 ? config.numExecutors : DefaultAllocation::numStreams(platform, config); + const auto numExecutors = config.compileConfig().numExecutors != -1 ? config.compileConfig().numExecutors : DefaultAllocation::numStreams(platform, config); VPU_THROW_UNLESS(numExecutors >= 1 && numExecutors <= DeviceResources::numStreams(), R"(Value of configuration option ("{}") must be in the range [{}, {}], actual is "{}")", ie::MYRIAD_THROUGHPUT_STREAMS, 1, DeviceResources::numStreams(), numExecutors); - const auto numSlices = config.numCMXSlices != -1 ? config.numCMXSlices : DefaultAllocation::numSlices(platform, numExecutors); + const auto numSlices = config.compileConfig().numCMXSlices != -1 + ? config.compileConfig().numCMXSlices + : DefaultAllocation::numSlices(platform, numExecutors); VPU_THROW_UNLESS(numSlices >= 1 && numSlices <= DeviceResources::numSlices(platform), R"(Value of configuration option ("{}") must be in the range [{}, {}], actual is "{}")", ie::MYRIAD_NUMBER_OF_CMX_SLICES, 1, DeviceResources::numSlices(platform), numSlices); int defaultCmxLimit = DefaultAllocation::tilingCMXLimit(numSlices); - const auto tilingCMXLimit = config.tilingCMXLimitKB != -1 ? std::min(config.tilingCMXLimitKB * 1024, defaultCmxLimit) : defaultCmxLimit; + const auto tilingCMXLimit = config.compileConfig().tilingCMXLimitKB != -1 + ? std::min(config.compileConfig().tilingCMXLimitKB * 1024, defaultCmxLimit) + : defaultCmxLimit; VPU_THROW_UNLESS(tilingCMXLimit >= 0, R"(Value of configuration option ("{}") must be greater than {}, actual is "{}")", ie::MYRIAD_TILING_CMX_LIMIT_KB, 0, tilingCMXLimit); - const auto numShaves = config.numSHAVEs != -1 ? config.numSHAVEs : DefaultAllocation::numShaves(platform, numExecutors, numSlices); + const auto numShaves = config.compileConfig().numSHAVEs != -1 + ? config.compileConfig().numSHAVEs + : DefaultAllocation::numShaves(platform, numExecutors, numSlices); VPU_THROW_UNLESS(numShaves >= 1 && numShaves <= DeviceResources::numShaves(platform), R"(Value of configuration option ("{}") must be in the range [{}, {}], actual is "{}")", ie::MYRIAD_NUMBER_OF_SHAVES, 1, DeviceResources::numShaves(platform), numShaves); @@ -123,7 +130,7 @@ void CompileEnv::init(Platform platform, const CompilationConfig& config, const g_compileEnv->initialized = true; } -void CompileEnv::updateConfig(const CompilationConfig& config) { +void CompileEnv::updateConfig(const PluginConfiguration& config) { IE_ASSERT(g_compileEnv != nullptr); IE_ASSERT(g_compileEnv->initialized); @@ -165,9 +172,9 @@ CompiledGraph::Ptr compileImpl(const ie::CNNNetwork& network, const ie::ICore* c middleEnd->run(model); - if (!env.config.irWithVpuScalesDir.empty()) { - network.serialize(env.config.irWithVpuScalesDir + "/" + network.getName() + "_scales.xml", - env.config.irWithVpuScalesDir + "/" + network.getName() + "_scales.bin"); + if (!env.config.compileConfig().irWithVpuScalesDir.empty()) { + network.serialize(env.config.compileConfig().irWithVpuScalesDir + "/" + network.getName() + "_scales.xml", + env.config.compileConfig().irWithVpuScalesDir + "/" + network.getName() + "_scales.bin"); } return backEnd->build(model, frontEnd->origLayers()); @@ -191,8 +198,8 @@ CompiledGraph::Ptr compileImpl(const Model& model) { } // namespace -CompiledGraph::Ptr compileNetwork(const ie::CNNNetwork& network, Platform platform, const CompilationConfig& config, const Logger::Ptr& log, - const ie::ICore* core) { +CompiledGraph::Ptr compileNetwork(const ie::CNNNetwork& network, ncDevicePlatform_t platform, const PluginConfiguration& config, const Logger::Ptr& log, + const ie::ICore* core) { CompileEnv::init(platform, config, log); AutoScope autoDeinit([] { CompileEnv::free(); @@ -205,8 +212,8 @@ CompiledGraph::Ptr compileNetwork(const ie::CNNNetwork& network, Platform platfo CompiledGraph::Ptr compileModel( const Model& model, - Platform platform, - const CompilationConfig& config, + ncDevicePlatform_t platform, + const PluginConfiguration& config, const Logger::Ptr& log) { CompileEnv::init(platform, config, log); AutoScope autoDeinit([] { @@ -218,7 +225,7 @@ CompiledGraph::Ptr compileModel( return compileImpl(model); } -CompiledGraph::Ptr compileSubNetwork(const ie::CNNNetwork& network, const CompilationConfig& subConfig, const ie::ICore* core) { +CompiledGraph::Ptr compileSubNetwork(const ie::CNNNetwork& network, const PluginConfiguration& subConfig, const ie::ICore* core) { VPU_PROFILE(compileSubNetwork); const auto& env = CompileEnv::get(); @@ -238,11 +245,11 @@ CompiledGraph::Ptr compileSubNetwork(const ie::CNNNetwork& network, const Compil // std::set getSupportedLayers( - const ie::CNNNetwork& network, - Platform platform, - const CompilationConfig& config, - const Logger::Ptr& log, - const ie::ICore* core) { + const ie::CNNNetwork& network, + ncDevicePlatform_t platform, + const PluginConfiguration& config, + const Logger::Ptr& log, + const ie::ICore* core) { CompileEnv::init(platform, config, log); AutoScope autoDeinit([] { CompileEnv::free(); @@ -255,28 +262,28 @@ std::set getSupportedLayers( return frontEnd->checkSupportedLayers(network); } -int DeviceResources::numShaves(const Platform& platform) { - return platform == Platform::MYRIAD_2 ? 12 : 16; +int DeviceResources::numShaves(const ncDevicePlatform_t& platform) { + return platform == ncDevicePlatform_t::NC_MYRIAD_2 ? 12 : 16; } -int DeviceResources::numSlices(const Platform& platform) { - return platform == Platform::MYRIAD_2 ? 12 : 19; +int DeviceResources::numSlices(const ncDevicePlatform_t& platform) { + return platform == ncDevicePlatform_t::NC_MYRIAD_2 ? 12 : 19; } int DeviceResources::numStreams() { return 3; } -int DefaultAllocation::numStreams(const Platform& platform, const CompilationConfig& configuration) { - return platform == Platform::MYRIAD_X && configuration.hwOptimization ? 2 : 1; +int DefaultAllocation::numStreams(const ncDevicePlatform_t& platform, const PluginConfiguration& configuration) { + return platform == ncDevicePlatform_t::NC_MYRIAD_X && configuration.compileConfig().hwOptimization ? 2 : 1; } -int DefaultAllocation::numSlices(const Platform& platform, int numStreams) { +int DefaultAllocation::numSlices(const ncDevicePlatform_t& platform, int numStreams) { const auto capabilities = DeviceResources::numSlices(platform); return capabilities / numStreams; } -int DefaultAllocation::numShaves(const Platform& platform, int numStreams, int numSlices) { +int DefaultAllocation::numShaves(const ncDevicePlatform_t& platform, int numStreams, int numSlices) { const auto numAvailableShaves = DeviceResources::numShaves(platform); if (numStreams == 1) { return numAvailableShaves; diff --git a/inference-engine/src/vpu/graph_transformer/src/middleend/pass_manager.cpp b/inference-engine/src/vpu/graph_transformer/src/middleend/pass_manager.cpp index c40588acb93a81..f5e5d6ff2dfb96 100644 --- a/inference-engine/src/vpu/graph_transformer/src/middleend/pass_manager.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/middleend/pass_manager.cpp @@ -10,6 +10,7 @@ #include #include +#include namespace vpu { @@ -93,7 +94,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { ADD_PASS(convertShapeNotation); ADD_DUMP_PASS("convertShapeNotation"); - if (!env.config.disableReorder && !env.config.hwOptimization) { + if (!env.config.compileConfig().disableReorder && !env.config.compileConfig().hwOptimization) { ADD_PASS(reorderInputsToChannelMinor); ADD_DUMP_PASS("reorderInputsToChannelMinor"); } @@ -125,7 +126,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { // To overcome fp16 limitations // - if (env.config.hwOptimization && env.config.enableWeightsAnalysis) { + if (env.config.compileConfig().hwOptimization && env.config.compileConfig().enableWeightsAnalysis) { ADD_PASS(analyzeWeightableLayers); ADD_DUMP_PASS("analyzeWeightableLayers"); } @@ -150,7 +151,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { // Model HW-specific optimizations // - if (env.config.hwOptimization) { + if (env.config.compileConfig().hwOptimization) { ADD_PASS(replaceFCbyConv); ADD_DUMP_PASS("replaceFCbyConv"); @@ -161,7 +162,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { ADD_PASS(replaceDeconvByConv); ADD_DUMP_PASS("replaceDeconvByConv"); - if (env.config.hwDilation) { + if (env.config.compileConfig().hwDilation) { ADD_PASS(reshapeDilationConv); ADD_DUMP_PASS("reshapeDilationConv"); } @@ -173,7 +174,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { // Pass should be located before "adjustDataBatch" because "adjustDataBatch" specifies "origConvOutput" attribute // for convolution in order to provide that information to "hwConvTiling" pass. // Otherwise, "hwConvTiling" will see incorrect values in "origConvOutput" attribute. - if (env.config.enableCustomReshapeParam) { + if (env.config.compileConfig().enableCustomReshapeParam) { ADD_PASS(reshapeBeforeConvTiling); ADD_DUMP_PASS("reshapeBeforeConvTiling"); } @@ -197,7 +198,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { ADD_PASS(hwPadding); ADD_DUMP_PASS("hwPadding"); - if (env.config.hwOptimization) { + if (env.config.compileConfig().hwOptimization) { ADD_PASS(splitLargeKernelConv); ADD_DUMP_PASS("splitLargeKernelConv"); } @@ -209,7 +210,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { ADD_PASS(adjustDataBatch); ADD_DUMP_PASS("adjustDataBatch"); - if (env.config.enableReplWithSCRelu) { + if (env.config.compileConfig().enableReplWithSCRelu) { ADD_PASS(replaceWithSCReLU); ADD_DUMP_PASS("replaceWithSCReLU"); } @@ -218,13 +219,13 @@ PassSet::Ptr PassManager::buildMiddleEnd() { // HW stages tiling // - if (env.config.hwOptimization) { + if (env.config.compileConfig().hwOptimization) { ADD_PASS(hwConvTiling); ADD_PASS(hwPoolTiling); ADD_PASS(hwFullyConnectedTiling); ADD_DUMP_PASS("hwTiling"); - if (env.config.hwExtraSplit) { + if (env.config.compileConfig().hwExtraSplit) { ADD_PASS(hwExtraSplit); ADD_DUMP_PASS("hwExtraSplit"); } @@ -242,7 +243,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { // // this stage should be executed after "hwPoolTiling" // and before "swPoolAdaptation" - if (env.config.enableReplaceWithReduceMean) { + if (env.config.compileConfig().enableReplaceWithReduceMean) { ADD_PASS(replaceWithReduceMean); ADD_DUMP_PASS("replaceWithReduceMean"); } @@ -261,7 +262,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { ADD_PASS(mergeReLUAndBias); ADD_DUMP_PASS("mergeReLUAndBias"); - if (env.config.enableEarlyEltwiseReLUFusion) { + if (env.config.compileConfig().enableEarlyEltwiseReLUFusion) { ADD_PASS(mergeEltwiseAndReLUDynamic); ADD_DUMP_PASS("mergeEltwiseAndReLUDynamic"); } @@ -279,7 +280,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { // TODO: mergePermute support for reorder stage too. // TODO: pass that will swap Permute and per-element operations. - if (env.config.enablePermuteMerging) { + if (env.config.compileConfig().enablePermuteMerging) { ADD_PASS(mergePermuteStages); ADD_DUMP_PASS("mergePermuteStages"); } @@ -326,7 +327,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { // Model common optimizations // - if (env.config.copyOptimization.getOrDefault(true)) { + if (env.config.get()) { ADD_PASS(eliminateCopyStages); ADD_DUMP_PASS("eliminateCopyStages"); } @@ -334,7 +335,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { // // HW/SW injection - if (env.config.hwOptimization && env.config.injectSwOps.getOrDefault(true)) { + if (env.config.compileConfig().hwOptimization && env.config.compileConfig().injectSwOps.getOrDefault(true)) { ADD_PASS(injectSw); ADD_DUMP_PASS("injectSw"); } @@ -350,7 +351,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { // HW stages finalization // - if (env.config.hwOptimization) { + if (env.config.compileConfig().hwOptimization) { ADD_PASS(finalizeHwOps); ADD_DUMP_PASS("hwFinalization"); } @@ -361,7 +362,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { ADD_PASS(markFastStages); ADD_DUMP_PASS("markFastStages"); - if (env.config.enableMemoryTypesAnnotation) { + if (env.config.compileConfig().enableMemoryTypesAnnotation) { ADD_PASS(annotateMemoryTypes); ADD_DUMP_PASS("annotateMemoryTypes"); } diff --git a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/adjust_data_location.cpp b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/adjust_data_location.cpp index c734ef2a06bbef..4990b8153ca0aa 100644 --- a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/adjust_data_location.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/adjust_data_location.cpp @@ -48,7 +48,7 @@ void PassImpl::run(const Model& model) { allocNonIntermediateData(model); adjustModelForMemReqs(model); copyHwMisalignedInput(model); - if (env.config.packDataInCmx.getOrDefault(true)) { + if (env.config.compileConfig().packDataInCmx.getOrDefault(true)) { packDataInCmx(model); } } @@ -147,7 +147,7 @@ void PassImpl::collectMemReqs(const Model& model) { } void PassImpl::resetStageOrder(const Model& model) { - if (!CompileEnv::get().config.hwOptimization) + if (!CompileEnv::get().config.compileConfig().hwOptimization) return; static const std::string s_expectCMXOutput {"expectCMXOutput"}; diff --git a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/eliminate_copy.cpp b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/eliminate_copy.cpp index 74a42d8a13e6cc..9d9bf482e75a06 100644 --- a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/eliminate_copy.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/eliminate_copy.cpp @@ -14,6 +14,7 @@ #include #include +#include namespace vpu { @@ -78,7 +79,7 @@ void PassImpl::run(const Model& model) { std::queue copyToRemove; - if (!env.config.copyOptimization.hasValue()) { + if (!env.config.get()) { int nCopyStages = 0; for (const auto& stage : model->getStages()) { if (stage->type() == StageType::Copy) { diff --git a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/inject_sw.cpp b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/inject_sw.cpp index d8827d522d276d..4fb8c5c01232a4 100644 --- a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/inject_sw.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/inject_sw.cpp @@ -68,7 +68,7 @@ void PassImpl::run(const Model& model) { // Collect HW and SW candidates // - if (!env.config.injectSwOps.hasValue() && + if (!env.config.compileConfig().injectSwOps.hasValue() && model->numStages() > nMaxStagesForInjectSw) { env.log->warning( "Pass [injectSw] SKIPPED : number of stages (%d) is larger than threshold %d", diff --git a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/merge_eltwise_and_relu.cpp b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/merge_eltwise_and_relu.cpp index 4684cc50ee6691..548557b594b1dc 100644 --- a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/merge_eltwise_and_relu.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/merge_eltwise_and_relu.cpp @@ -30,7 +30,7 @@ class PassImpl final : public Pass { }; void PassImpl::run(const Model& model) { - const bool enableEarlyEltwiseReLUFusion = CompileEnv::get().config.enableEarlyEltwiseReLUFusion; + const bool enableEarlyEltwiseReLUFusion = CompileEnv::get().config.compileConfig().enableEarlyEltwiseReLUFusion; if (enableEarlyEltwiseReLUFusion) { if (m_mode == MergeMode::DYNAMIC_NETWORK) { VPU_PROFILE(mergeEltwiseAndReLUDynamic); diff --git a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/merge_hw_stages.cpp b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/merge_hw_stages.cpp index 5bade8b8bbce8d..5b83fd0e49b475 100644 --- a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/merge_hw_stages.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/merge_hw_stages.cpp @@ -170,7 +170,7 @@ void PassImpl::run(const Model& model) { // Try to merge next Pooling layer // - if (env.config.mergeHwPoolToConv) { + if (env.config.compileConfig().mergeHwPoolToConv) { if (stage->type() == StageType::StubConv) { if (auto nextPoolStage = getNextPoolStage(stage, output)) { output = nextPoolStage->output(0); diff --git a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/replace_deconv_by_conv.cpp b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/replace_deconv_by_conv.cpp index beb1e55cbb84bd..4ca08a4f65f100 100644 --- a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/replace_deconv_by_conv.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/replace_deconv_by_conv.cpp @@ -148,7 +148,7 @@ void PassImpl::run(const Model& model) { auto output = stage->output(0); const auto& env = CompileEnv::get(); - if (env.config.hwDisabled(stage->origLayer()->name)) { + if (env.config.compileConfig().hwDisabled(stage->origLayer()->name)) { continue; } diff --git a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/weights_analysis.cpp b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/weights_analysis.cpp index 27e703ec4f53cc..24efadc78574b5 100644 --- a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/weights_analysis.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/weights_analysis.cpp @@ -88,7 +88,7 @@ bool isScalable(const Stage& stage) { bool checkGrowingOutput(const Model& model) { const auto& env = CompileEnv::get(); - if (!env.config.checkPreprocessingInsideModel) { + if (!env.config.compileConfig().checkPreprocessingInsideModel) { return false; } @@ -258,7 +258,7 @@ void PassImpl::run(const Model& model) { scale = static_cast(1ULL << static_cast(shift)); } - if (!env.config.irWithVpuScalesDir.empty()) { + if (!env.config.compileConfig().irWithVpuScalesDir.empty()) { stage->origLayer()->params["vpu_scale"] = toString(scale); } } diff --git a/inference-engine/src/vpu/graph_transformer/src/model/stage.cpp b/inference-engine/src/vpu/graph_transformer/src/model/stage.cpp index 7323587ce9f38b..cad7da95ca8e41 100644 --- a/inference-engine/src/vpu/graph_transformer/src/model/stage.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/model/stage.cpp @@ -199,7 +199,7 @@ StageSHAVEsRequirements StageNode::getSHAVEsRequirements() const { // return max for Myriad2 const auto& compileEnv = CompileEnv::get(); - if (compileEnv.platform == Platform::MYRIAD_2) { + if (compileEnv.platform == ncDevicePlatform_t::NC_MYRIAD_2) { return StageSHAVEsRequirements::NeedMax; } diff --git a/inference-engine/src/vpu/graph_transformer/src/stages/activation.cpp b/inference-engine/src/vpu/graph_transformer/src/stages/activation.cpp index 04c4923fcae189..7f666964414e59 100644 --- a/inference-engine/src/vpu/graph_transformer/src/stages/activation.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/stages/activation.cpp @@ -24,7 +24,7 @@ void FrontEnd::parseActivation(const Model& model, const ie::CNNLayerPtr& layer, const auto type = layer->GetParamAsString("type"); const auto activationParserIt = activationParsers.find(type); - VPU_THROW_UNSUPPORTED_UNLESS(activationParserIt != activationParsers.end(), + VPU_THROW_UNSUPPORTED_LAYER_UNLESS(activationParserIt != activationParsers.end(), "Failed to compile layer \"%v\"(type = %v) ", layer->name, type); activationParserIt->second(model, layer, inputs, outputs); diff --git a/inference-engine/src/vpu/graph_transformer/src/stages/convolution.cpp b/inference-engine/src/vpu/graph_transformer/src/stages/convolution.cpp index 529456f919ebcd..695bd43f3c9bf5 100644 --- a/inference-engine/src/vpu/graph_transformer/src/stages/convolution.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/stages/convolution.cpp @@ -163,9 +163,9 @@ void parseConv2D(const Model & model, kernelStrideY, dilationX, dilationY, - env.config.hwOptimization, - env.config.hwDilation, - env.config.hwDisabled(layer->name)); + env.config.compileConfig().hwOptimization, + env.config.compileConfig().hwDilation, + env.config.compileConfig().hwDisabled(layer->name)); // // Create const datas @@ -476,9 +476,9 @@ void parseConvND(const Model & model, strides[1], dilations[0], dilations[1], - env.config.hwOptimization, - env.config.hwDilation, - env.config.hwDisabled(layer->name)); + env.config.compileConfig().hwOptimization, + env.config.compileConfig().hwDilation, + env.config.compileConfig().hwDisabled(layer->name)); int try_hw = tryHW ? 1 : 0; diff --git a/inference-engine/src/vpu/graph_transformer/src/stages/fc.cpp b/inference-engine/src/vpu/graph_transformer/src/stages/fc.cpp index c2994273ca7401..96da14dc941a12 100644 --- a/inference-engine/src/vpu/graph_transformer/src/stages/fc.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/stages/fc.cpp @@ -37,13 +37,13 @@ void FrontEnd::parseFullyConnected(const Model& model, const ie::CNNLayerPtr& _l // Check if HW is applicable // - auto tryHW = env.config.hwOptimization; + auto tryHW = env.config.compileConfig().hwOptimization; if (output->desc().dim(Dim::W, 1) != 1 || output->desc().dim(Dim::H, 1) != 1) { tryHW = false; } - if (env.config.hwDisabled(layer->name)) { + if (env.config.compileConfig().hwDisabled(layer->name)) { tryHW = false; } diff --git a/inference-engine/src/vpu/graph_transformer/src/stages/mtcnn.cpp b/inference-engine/src/vpu/graph_transformer/src/stages/mtcnn.cpp index 795b45c8a04486..e9d6899f7abc6a 100644 --- a/inference-engine/src/vpu/graph_transformer/src/stages/mtcnn.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/stages/mtcnn.cpp @@ -162,7 +162,7 @@ void FrontEnd::parseMTCNN(const Model& model, const ie::CNNLayerPtr& layer, cons IE_ASSERT(inputs.size() == 1); IE_ASSERT(outputs.size() == 1); - if (!env.config.hwOptimization) { + if (!env.config.compileConfig().hwOptimization) { VPU_THROW_EXCEPTION << "MTCNN layer supports Myriad X with NCE only"; } diff --git a/inference-engine/src/vpu/graph_transformer/src/stages/permute.cpp b/inference-engine/src/vpu/graph_transformer/src/stages/permute.cpp index 411cc2de0d7438..071c2fb0328d3e 100644 --- a/inference-engine/src/vpu/graph_transformer/src/stages/permute.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/stages/permute.cpp @@ -124,7 +124,7 @@ Stage StageBuilder::addReorderStage( const Data& output) { const auto* env = CompileEnv::getOrNull(); VPU_THROW_UNLESS( - env == nullptr || !env->config.disableReorder, + env == nullptr || !env->config.compileConfig().disableReorder, "Tried to add Reorder Stage %v, while DISABLE_REORDER option was set", name); diff --git a/inference-engine/src/vpu/graph_transformer/src/stages/pooling.cpp b/inference-engine/src/vpu/graph_transformer/src/stages/pooling.cpp index 5551e72231bd44..2823d0c9165424 100644 --- a/inference-engine/src/vpu/graph_transformer/src/stages/pooling.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/stages/pooling.cpp @@ -221,8 +221,8 @@ void parsePool2D(const Model & model, // const auto& env = CompileEnv::get(); - bool hwOptimization = env.config.hwOptimization; - bool hwDisabled = env.config.hwDisabled(layer->name); + bool hwOptimization = env.config.compileConfig().hwOptimization; + bool hwDisabled = env.config.compileConfig().hwDisabled(layer->name); int inputWidth = input->desc().dim(Dim::W); int inputHeight = input->desc().dim(Dim::H); @@ -480,8 +480,8 @@ void parsePoolND(const Model & model, // const auto& env = CompileEnv::get(); - bool hwOptimization = env.config.hwOptimization; - bool hwDisabled = env.config.hwDisabled(layer->name); + bool hwOptimization = env.config.compileConfig().hwOptimization; + bool hwDisabled = env.config.compileConfig().hwDisabled(layer->name); bool tryHW = canTryHW(poolLayer->_type, input_shape[0], diff --git a/inference-engine/src/vpu/myriad_plugin/configuration/myriad_configuration.cpp b/inference-engine/src/vpu/myriad_plugin/configuration/myriad_configuration.cpp new file mode 100644 index 00000000000000..41a53f0619eb4b --- /dev/null +++ b/inference-engine/src/vpu/myriad_plugin/configuration/myriad_configuration.cpp @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "configuration/myriad_configuration.hpp" + +namespace vpu { + +MyriadConfiguration::MyriadConfiguration() {} + +void MyriadConfiguration::from(const std::map& configuration) { + std::map migratedOptions, notMigratedOptions; + for (const auto& entry : configuration) { + auto& destination = PluginConfiguration::supports(entry.first) ? migratedOptions : notMigratedOptions; + destination.emplace(entry); + } + PluginConfiguration::from(migratedOptions); + update(notMigratedOptions); +} + +void MyriadConfiguration::fromAtRuntime(const std::map& configuration) { + std::map migratedOptions, notMigratedOptions; + for (const auto& entry : configuration) { + auto& destination = PluginConfiguration::supports(entry.first) ? migratedOptions : notMigratedOptions; + destination.emplace(entry); + } + PluginConfiguration::fromAtRuntime(migratedOptions); + update(notMigratedOptions, ConfigMode::RunTime); +} + +} // namespace vpu diff --git a/inference-engine/src/vpu/myriad_plugin/configuration/myriad_configuration.hpp b/inference-engine/src/vpu/myriad_plugin/configuration/myriad_configuration.hpp new file mode 100644 index 00000000000000..080d262c7037cb --- /dev/null +++ b/inference-engine/src/vpu/myriad_plugin/configuration/myriad_configuration.hpp @@ -0,0 +1,21 @@ +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "vpu/configuration/plugin_configuration.hpp" +#include "myriad_config.h" + +namespace vpu { + +class MyriadConfiguration final : public PluginConfiguration, public MyriadPlugin::MyriadConfig { +public: + MyriadConfiguration(); + + // TODO: remove once all options are migrated + void from(const std::map& configuration); + void fromAtRuntime(const std::map& configuration); +}; + +} // namespace vpu diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_config.h b/inference-engine/src/vpu/myriad_plugin/myriad_config.h index 176e677a9b6f1a..5745516e179189 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_config.h +++ b/inference-engine/src/vpu/myriad_plugin/myriad_config.h @@ -34,7 +34,7 @@ VPU_DECLARE_ENUM(MovidiusDdrType, MICRON_1GB = 4, ) -class MyriadConfig final : public ParsedConfig { +class MyriadConfig : public virtual ParsedConfig { public: const std::string& pluginLogFilePath() const { return _pluginLogFilePath; diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.cpp b/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.cpp index 7a0a22499c1942..f8806435188aa0 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.cpp +++ b/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.cpp @@ -14,6 +14,7 @@ #include #include #include +#include using namespace InferenceEngine; @@ -25,23 +26,24 @@ namespace MyriadPlugin { ExecutableNetwork::ExecutableNetwork( std::shared_ptr mvnc, std::vector& devicePool, - const MyriadConfig& config, + const MyriadConfiguration& config, const ie::ICore* core) : _config(config), _core(core) { VPU_PROFILE(ExecutableNetwork); + const auto& logLevel = _config.get(); + _log = std::make_shared( "MyriadPlugin", - _config.logLevel(), + logLevel, defaultOutput(_config.pluginLogFilePath())); - _executor = std::make_shared(_config.forceReset(), std::move(mvnc), _config.logLevel(), _log); + _executor = std::make_shared(_config.forceReset(), std::move(mvnc), logLevel, _log); _device = _executor->openDevice(devicePool, _config); - const auto& compileConfig = config.compileConfig(); const auto& revision = _device->revision(); - _actualNumExecutors = compileConfig.numExecutors != -1 ? compileConfig.numExecutors : DefaultAllocation::numStreams(revision, compileConfig); + _actualNumExecutors = config.compileConfig().numExecutors != -1 ? config.compileConfig().numExecutors : DefaultAllocation::numStreams(revision, config); _supportedMetrics = { METRIC_KEY(NETWORK_NAME), @@ -56,22 +58,22 @@ ExecutableNetwork::ExecutableNetwork( const ie::CNNNetwork& network, std::shared_ptr mvnc, std::vector& devicePool, - const MyriadConfig& config, + const MyriadConfiguration& config, const ie::ICore* core) : ExecutableNetwork(std::move(mvnc), devicePool, config, core) { VPU_PROFILE(ExecutableNetwork); const auto compilerLog = std::make_shared( "GraphCompiler", - _config.logLevel(), + _config.get(), defaultOutput(_config.compilerLogFilePath())); if (_device == nullptr) IE_THROW() << "No device was detected"; auto compiledGraph = compileNetwork( network, - static_cast(_device->_platform), - _config.compileConfig(), + _device->_platform, + _config, compilerLog, _core); @@ -100,9 +102,7 @@ ExecutableNetwork::ExecutableNetwork( } } -void ExecutableNetwork::Import(std::istream& strm, - std::vector &devicePool, - const MyriadConfig& config) { +void ExecutableNetwork::Import(std::istream& strm, std::vector &devicePool, const MyriadConfiguration& configuration) { auto currentPos = strm.tellg(); strm.seekg(0, strm.end); auto blobSize = strm.tellg() - currentPos; @@ -147,11 +147,8 @@ void ExecutableNetwork::Import(std::istream& strm, } } -ExecutableNetwork::ExecutableNetwork(std::istream& strm, - std::shared_ptr mvnc, - std::vector &devicePool, - const MyriadConfig& config, - const ie::ICore* core) : +ExecutableNetwork::ExecutableNetwork(std::istream& strm, std::shared_ptr mvnc, std::vector &devicePool, + const MyriadConfiguration& config, const ie::ICore* core) : ExecutableNetwork(std::move(mvnc), devicePool, config, core) { VPU_PROFILE(ExecutableNetwork); Import(strm, devicePool, config); @@ -161,7 +158,7 @@ ExecutableNetwork::ExecutableNetwork( const std::string& blobFilename, std::shared_ptr mvnc, std::vector& devicePool, - const MyriadConfig& config, + const MyriadConfiguration& config, const ie::ICore* core) : ExecutableNetwork(std::move(mvnc), devicePool, config, core) { VPU_PROFILE(ExecutableNetwork); diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.h b/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.h index 22824ee5ec1c47..0b58bf2f4802e9 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.h +++ b/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.h @@ -32,23 +32,14 @@ class ExecutableNetwork : public ie::ExecutableNetworkThreadSafeDefault { public: typedef std::shared_ptr Ptr; - explicit ExecutableNetwork(const ie::CNNNetwork& network, - std::shared_ptr mvnc, - std::vector &devicePool, - const MyriadConfig& config, - const ie::ICore* core); + ExecutableNetwork(const InferenceEngine::CNNNetwork& network, std::shared_ptr mvnc, std::vector &devicePool, + const MyriadConfiguration& configuration, const ie::ICore* core); - explicit ExecutableNetwork(std::istream& strm, - std::shared_ptr mvnc, - std::vector &devicePool, - const MyriadConfig& config, - const ie::ICore* core); + ExecutableNetwork(std::istream& strm, std::shared_ptr mvnc, std::vector &devicePool, const MyriadConfiguration& configuration, + const ie::ICore* core); - explicit ExecutableNetwork(const std::string &blobFilename, - std::shared_ptr mvnc, - std::vector &devicePool, - const MyriadConfig& config, - const ie::ICore* core); + ExecutableNetwork(const std::string &blobFilename, std::shared_ptr mvnc, std::vector &devicePool, + const MyriadConfiguration& configuration, const ie::ICore* core); virtual ~ExecutableNetwork() { @@ -97,9 +88,7 @@ class ExecutableNetwork : public ie::ExecutableNetworkThreadSafeDefault { ie::CNNNetwork GetExecGraphInfo() override; - void Import(std::istream& strm, - std::vector &devicePool, - const MyriadConfig& config); + void Import(std::istream& strm, std::vector &devicePool, const MyriadConfiguration& configuration); private: Logger::Ptr _log; @@ -108,7 +97,7 @@ class ExecutableNetwork : public ie::ExecutableNetworkThreadSafeDefault { GraphDesc _graphDesc; DevicePtr _device; GraphMetaInfo _graphMetaData; - MyriadConfig _config; + MyriadConfiguration _config; const ie::ICore* _core = nullptr; int _actualNumExecutors = 0; std::vector _supportedMetrics; @@ -119,10 +108,7 @@ class ExecutableNetwork : public ie::ExecutableNetworkThreadSafeDefault { const size_t _maxTaskExecutorGetResultCount = 1; std::queue _taskExecutorGetResultIds; - ExecutableNetwork(std::shared_ptr mvnc, - std::vector &devicePool, - const MyriadConfig& config, - const ie::ICore* core); + ExecutableNetwork(std::shared_ptr mvnc, std::vector &devicePool, const MyriadConfiguration& config, const ie::ICore* core); ie::ITaskExecutor::Ptr getNextTaskExecutor() { std::string id = _taskExecutorGetResultIds.front(); diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_executor.cpp b/inference-engine/src/vpu/myriad_plugin/myriad_executor.cpp index d92a948ce5727b..49cf63c4e636c5 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_executor.cpp +++ b/inference-engine/src/vpu/myriad_plugin/myriad_executor.cpp @@ -73,8 +73,7 @@ MyriadExecutor::MyriadExecutor(bool forceReset, std::shared_ptr mvnc, /* * @brief Boot available device */ -ncStatus_t MyriadExecutor::bootNextDevice(std::vector &devicePool, - const MyriadConfig& config) { +ncStatus_t MyriadExecutor::bootNextDevice(std::vector &devicePool, const MyriadConfiguration& config) { VPU_PROFILE(bootNextDevice); // #-17972, #-16790 #if defined(NO_BOOT) @@ -221,7 +220,7 @@ ncStatus_t MyriadExecutor::bootNextDevice(std::vector &devicePool, } DevicePtr MyriadExecutor::openDevice(std::vector& devicePool, - const MyriadConfig& config) { + const MyriadConfiguration& config) { VPU_PROFILE(openDevice); std::lock_guard lock(device_mutex); diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_executor.h b/inference-engine/src/vpu/myriad_plugin/myriad_executor.h index e7c9c8614ee91b..d9883d8501e843 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_executor.h +++ b/inference-engine/src/vpu/myriad_plugin/myriad_executor.h @@ -13,6 +13,7 @@ #include #include "myriad_mvnc_wrapper.h" +#include "configuration/myriad_configuration.hpp" #include @@ -63,9 +64,9 @@ struct DeviceDesc { ((config.protocol() == NC_ANY_PROTOCOL) || (_protocol == config.protocol())); } - Platform revision() const { + ncDevicePlatform_t revision() const { VPU_THROW_UNLESS(_platform != NC_ANY_PLATFORM, "Cannot get a revision from not booted device"); - return _platform == NC_MYRIAD_2 ? Platform::MYRIAD_2 : Platform::MYRIAD_X; + return _platform; } }; @@ -86,7 +87,7 @@ class MyriadExecutor { * @brief Get myriad device * @return Already booted and empty device or new booted device */ - DevicePtr openDevice(std::vector &devicePool, const MyriadConfig& config); + DevicePtr openDevice(std::vector &devicePool, const MyriadConfiguration& config); static void closeDevices(std::vector &devicePool, std::shared_ptr mvnc); @@ -134,8 +135,7 @@ class MyriadExecutor { * @param configPlatform Boot the selected platform * @param configProtocol Boot device with selected protocol */ - ncStatus_t bootNextDevice(std::vector &devicePool, - const MyriadConfig& config); + ncStatus_t bootNextDevice(std::vector &devicePool, const MyriadConfiguration& config); }; typedef std::shared_ptr MyriadExecutorPtr; diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.h b/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.h index 667b93b6aae1b5..9373f771fb927a 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.h +++ b/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.h @@ -14,6 +14,7 @@ #include #include +#include #include "myriad_executor.h" #include "myriad_config.h" diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_metrics.cpp b/inference-engine/src/vpu/myriad_plugin/myriad_metrics.cpp index fc022ff4184eae..e91ef8333fe83d 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_metrics.cpp +++ b/inference-engine/src/vpu/myriad_plugin/myriad_metrics.cpp @@ -31,6 +31,7 @@ MyriadMetrics::MyriadMetrics() { }; IE_SUPPRESS_DEPRECATED_START + // TODO: remove once all options are migrated _supportedConfigKeys = { MYRIAD_ENABLE_HW_ACCELERATION, MYRIAD_ENABLE_RECEIVING_TENSOR_TIME, @@ -45,7 +46,6 @@ IE_SUPPRESS_DEPRECATED_START KEY_VPU_MYRIAD_FORCE_RESET, KEY_VPU_MYRIAD_PLATFORM, - CONFIG_KEY(LOG_LEVEL), CONFIG_KEY(EXCLUSIVE_ASYNC_REQUESTS), CONFIG_KEY(PERF_COUNT), CONFIG_KEY(CONFIG_FILE), diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_plugin.cpp b/inference-engine/src/vpu/myriad_plugin/myriad_plugin.cpp index 75e7ef395d9266..7771cc8bfbf88c 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_plugin.cpp +++ b/inference-engine/src/vpu/myriad_plugin/myriad_plugin.cpp @@ -18,8 +18,9 @@ #include #include #include -#include -#include + +#include +#include #include "myriad_plugin.h" @@ -34,31 +35,40 @@ IExecutableNetworkInternal::Ptr Engine::LoadExeNetworkImpl( const std::map& config) { VPU_PROFILE(LoadExeNetworkImpl); - auto parsedConfigCopy = _parsedConfig; - parsedConfigCopy.update(config); + auto executableNetworkConfiguration = _parsedConfig; + executableNetworkConfiguration.from(config); + executableNetworkConfiguration.validate(); - return std::make_shared(network, _mvnc, _devicePool, parsedConfigCopy, GetCore()); + return std::make_shared(network, _mvnc, _devicePool, executableNetworkConfiguration, GetCore()); } void Engine::SetConfig(const std::map &config) { - _parsedConfig.update(config); + _parsedConfig.from(config); + // TODO: remove once all options are migrated for (const auto& entry : config) { _config[entry.first] = entry.second; } + +#ifndef NDEBUG + if (const auto envVar = std::getenv("IE_VPU_LOG_LEVEL")) { + _parsedConfig.set(LogLevelOption::key(), envVar); + } +#endif } Parameter Engine::GetConfig(const std::string& name, const std::map& options) const { - auto supported_keys = _metrics->SupportedConfigKeys(); - if (std::find(supported_keys.begin(), - supported_keys.end(), name) == supported_keys.end()) { - IE_THROW() << "Unsupported config key : " << name; - } + // TODO: remove once all options are migrated + const auto& supportedKeys = _metrics->SupportedConfigKeys(); + VPU_THROW_UNSUPPORTED_OPTION_UNLESS(supportedKeys.count(name) == 1 || _parsedConfig.supports(name), "Unsupported configuration key: {}", name); Parameter result; - auto option = _config.find(name); - if (option != _config.end()) - result = option->second; + if (_parsedConfig.supports(name)) { + result = _parsedConfig.asParameter(name); + } else if (_config.count(name)) { + // TODO: remove once all options are migrated + result = _config.at(name); + } return result; } @@ -70,7 +80,7 @@ QueryNetworkResult Engine::QueryNetwork( QueryNetworkResult res; auto parsedConfigCopy = _parsedConfig; - parsedConfigCopy.update(config); + parsedConfigCopy.from(config); const auto deviceName = parsedConfigCopy.deviceName(); if (!deviceName.empty()) { @@ -80,13 +90,13 @@ QueryNetworkResult Engine::QueryNetwork( const auto log = std::make_shared( "GraphCompiler", - parsedConfigCopy.logLevel(), + _parsedConfig.get(), defaultOutput(parsedConfigCopy.compilerLogFilePath())); const auto supportedLayers = getSupportedLayers( network, - static_cast(parsedConfigCopy.platform()), - parsedConfigCopy.compileConfig(), + parsedConfigCopy.platform(), + parsedConfigCopy, log, GetCore()); @@ -111,6 +121,7 @@ Engine::Engine(std::shared_ptr mvnc) : _pluginName = "MYRIAD"; + // TODO: remove once all options are migrated IE_SUPPRESS_DEPRECATED_START _config = { { MYRIAD_ENABLE_HW_ACCELERATION, CONFIG_VALUE(YES) }, @@ -126,13 +137,19 @@ IE_SUPPRESS_DEPRECATED_START { KEY_VPU_MYRIAD_FORCE_RESET, CONFIG_VALUE(NO) }, { KEY_VPU_MYRIAD_PLATFORM, "" }, - { KEY_LOG_LEVEL, CONFIG_VALUE(LOG_NONE) }, { KEY_EXCLUSIVE_ASYNC_REQUESTS, CONFIG_VALUE(NO) }, { KEY_PERF_COUNT, CONFIG_VALUE(NO) }, { KEY_CONFIG_FILE, "" }, { KEY_DEVICE_ID, "" }, }; IE_SUPPRESS_DEPRECATED_END + + _parsedConfig.registerOption(); + _parsedConfig.registerOption(); + +IE_SUPPRESS_DEPRECATED_START + _parsedConfig.registerDeprecatedOption(VPU_CONFIG_KEY(LOG_LEVEL)); +IE_SUPPRESS_DEPRECATED_END } InferenceEngine::IExecutableNetworkInternal::Ptr Engine::ImportNetwork( @@ -140,14 +157,12 @@ InferenceEngine::IExecutableNetworkInternal::Ptr Engine::ImportNetwork( const std::map& config) { VPU_PROFILE(ImportNetwork); - auto parsedConfigCopy = _parsedConfig; - parsedConfigCopy.update(config, ConfigMode::RunTime); + auto executableNetworkConfiguration = _parsedConfig; + executableNetworkConfiguration.fromAtRuntime(config); + executableNetworkConfiguration.validate(); - const auto executableNetwork = - std::make_shared( - model, _mvnc, _devicePool, parsedConfigCopy, GetCore()); + const auto executableNetwork = std::make_shared(model, _mvnc, _devicePool, executableNetworkConfiguration, GetCore()); executableNetwork->SetPointerToPlugin(shared_from_this()); - return executableNetwork; } @@ -186,7 +201,10 @@ InferenceEngine::Parameter Engine::GetMetric(const std::string& name, const auto& supportedMetrics = _metrics->SupportedMetrics(); IE_SET_METRIC_RETURN(SUPPORTED_METRICS, std::vector{supportedMetrics.cbegin(), supportedMetrics.cend()}); } else if (name == METRIC_KEY(SUPPORTED_CONFIG_KEYS)) { - const auto& supportedConfigKeys = _metrics->SupportedConfigKeys(); + // TODO: remove once all options are migrated + auto supportedConfigKeys = _metrics->SupportedConfigKeys(); + const auto& publicKeys = _parsedConfig.getPublicKeys(); + supportedConfigKeys.insert(publicKeys.cbegin(), publicKeys.cend()); IE_SET_METRIC_RETURN(SUPPORTED_CONFIG_KEYS, std::vector{supportedConfigKeys.cbegin(), supportedConfigKeys.cend()}); } else if (name == METRIC_KEY(OPTIMIZATION_CAPABILITIES)) { const auto& optimizationCapabilities = _metrics->OptimizationCapabilities(); diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_plugin.h b/inference-engine/src/vpu/myriad_plugin/myriad_plugin.h index 9fb074b5ac174c..1d7536600c265b 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_plugin.h +++ b/inference-engine/src/vpu/myriad_plugin/myriad_plugin.h @@ -8,6 +8,7 @@ #include "myriad_executable_network.h" #include "myriad_mvnc_wrapper.h" #include "myriad_metrics.h" +#include "configuration/myriad_configuration.hpp" #include #include #include @@ -50,7 +51,7 @@ class Engine : public ie::IInferencePlugin { const std::map& options) const override; private: - MyriadConfig _parsedConfig; + MyriadConfiguration _parsedConfig; std::vector _devicePool; std::shared_ptr _mvnc; std::shared_ptr _metrics; diff --git a/inference-engine/tests/functional/inference_engine/parameter_tests.cpp b/inference-engine/tests/functional/inference_engine/parameter_tests.cpp index 85496e9170715d..49c72cad916c49 100644 --- a/inference-engine/tests/functional/inference_engine/parameter_tests.cpp +++ b/inference-engine/tests/functional/inference_engine/parameter_tests.cpp @@ -246,6 +246,18 @@ TEST_F(ParameterTests, ParametersCStringEqual) { ASSERT_FALSE(p1 != p2); } +TEST_F(ParameterTests, MapOfParametersEqual) { + std::map map0; + map0["testParamInt"] = 4; + map0["testParamString"] = "test"; + const auto map1 = map0; + + Parameter p0 = map0; + Parameter p1 = map1; + ASSERT_TRUE(p0 == p1); + ASSERT_FALSE(p0 != p1); +} + TEST_F(ParameterTests, CompareParametersWithoutEqualOperator) { class TestClass { public: @@ -312,4 +324,95 @@ TEST_F(ParameterTests, ParameterRemovedRealObjectPointerWithDuplication) { } ASSERT_EQ(1, DestructorTest::constructorCount); ASSERT_EQ(1, DestructorTest::destructorCount); -} \ No newline at end of file +} + +TEST_F(ParameterTests, PrintToEmptyParameterDoesNothing) { + Parameter p; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), std::string{}); +} + +TEST_F(ParameterTests, PrintToIntParameter) { + int value = -5; + Parameter p = value; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), std::to_string(value)); +} + +TEST_F(ParameterTests, PrintToUIntParameter) { + unsigned int value = 5; + Parameter p = value; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), std::to_string(value)); +} + +TEST_F(ParameterTests, PrintToSize_tParameter) { + std::size_t value = 5; + Parameter p = value; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), std::to_string(value)); +} + +TEST_F(ParameterTests, PrintToFloatParameter) { + Parameter p = 5.5f; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), std::string{"5.5"}); +} + +TEST_F(ParameterTests, PrintToStringParameter) { + std::string value = "some text"; + Parameter p = value; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), value); +} + +TEST_F(ParameterTests, PrintToVectorOfIntsParameterDoesNothing) { + Parameter p = std::vector{-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5}; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), std::string{}); +} + +TEST_F(ParameterTests, PrintToVectorOfUIntsParameterDoesNothing) { + Parameter p = std::vector{0, 1, 2, 3, 4, 5}; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), std::string{}); +} + +TEST_F(ParameterTests, PrintToVectorOfSize_tParameterDoesNothing) { + Parameter p = std::vector{0, 1, 2, 3, 4, 5}; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), std::string{}); +} + +TEST_F(ParameterTests, PrintToVectorOfFloatsParameterDoesNothing) { + Parameter p = std::vector{0.0f, 1.1f, 2.2f, 3.3f, 4.4f, 5.5f}; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), std::string{}); +} + +TEST_F(ParameterTests, PrintToVectorOfStringsParameterDoesNothing) { + Parameter p = std::vector{"zero", "one", "two", "three", "four", "five"}; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), std::string{}); +} + +TEST_F(ParameterTests, PrintToMapOfParametersDoesNothing) { + std::map refMap; + refMap["testParamInt"] = 4; + refMap["testParamString"] = "test"; + Parameter p = refMap; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), std::string{}); +} diff --git a/inference-engine/tests/functional/plugin/myriad/CMakeLists.txt b/inference-engine/tests/functional/plugin/myriad/CMakeLists.txt index 6a5b0f90e90f05..14f387fa7bae8a 100644 --- a/inference-engine/tests/functional/plugin/myriad/CMakeLists.txt +++ b/inference-engine/tests/functional/plugin/myriad/CMakeLists.txt @@ -4,19 +4,32 @@ set(TARGET_NAME myriadFuncTests) +disable_deprecated_warnings() + +include(${XLINK_DIR}/XLink.cmake) + addIeTargetTest( NAME ${TARGET_NAME} ROOT ${CMAKE_CURRENT_SOURCE_DIR} INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${IE_MAIN_SOURCE_DIR}/src/vpu/graph_transformer/include + ${IE_MAIN_SOURCE_DIR}/tests_deprecated/behavior/vpu/myriad_tests/helpers + ${XLINK_INCLUDE} + ${XLINK_PLATFORM_INCLUDE} DEPENDENCIES myriadPlugin LINK_LIBRARIES vpu_common_lib vpu_graph_transformer funcSharedTests + mvnc ADD_CPPLINT + DEFINES + __PC__ + OBJECT_FILES + ${IE_MAIN_SOURCE_DIR}/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_devices.hpp + ${IE_MAIN_SOURCE_DIR}/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_devices.cpp LABELS VPU MYRIAD diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/config.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/config.cpp index 8198792fd836b3..773419d78f18e9 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/config.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/config.cpp @@ -5,209 +5,353 @@ #include "vpu/vpu_plugin_config.hpp" #include "vpu/private_plugin_config.hpp" #include "behavior/config.hpp" +#include "myriad_devices.hpp" IE_SUPPRESS_DEPRECATED_START -using namespace BehaviorTestsDefinitions; namespace { - const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16 - }; - - const std::vector> Configs = { - {{InferenceEngine::MYRIAD_ENABLE_FORCE_RESET, CONFIG_VALUE(YES)}}, - {{InferenceEngine::MYRIAD_ENABLE_FORCE_RESET, CONFIG_VALUE(NO)}}, - - {{CONFIG_KEY(LOG_LEVEL), CONFIG_VALUE(LOG_NONE)}}, - {{CONFIG_KEY(LOG_LEVEL), CONFIG_VALUE(LOG_ERROR)}}, - {{CONFIG_KEY(LOG_LEVEL), CONFIG_VALUE(LOG_WARNING)}}, - {{CONFIG_KEY(LOG_LEVEL), CONFIG_VALUE(LOG_INFO)}}, - {{CONFIG_KEY(LOG_LEVEL), CONFIG_VALUE(LOG_DEBUG)}}, - {{CONFIG_KEY(LOG_LEVEL), CONFIG_VALUE(LOG_TRACE)}}, - - {{InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, CONFIG_VALUE(YES)}}, - {{InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, CONFIG_VALUE(NO)}}, - - {{InferenceEngine::MYRIAD_TILING_CMX_LIMIT_KB, "-1"}}, - {{InferenceEngine::MYRIAD_TILING_CMX_LIMIT_KB, "0"}}, - {{InferenceEngine::MYRIAD_TILING_CMX_LIMIT_KB, "10"}}, - - {{InferenceEngine::MYRIAD_ENABLE_RECEIVING_TENSOR_TIME, CONFIG_VALUE(YES)}}, - {{InferenceEngine::MYRIAD_ENABLE_RECEIVING_TENSOR_TIME, CONFIG_VALUE(NO)}}, - {{InferenceEngine::MYRIAD_PROTOCOL, InferenceEngine::MYRIAD_USB}}, - {{InferenceEngine::MYRIAD_PROTOCOL, InferenceEngine::MYRIAD_PCIE}}, - - {{InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "1"}}, - {{InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "2"}}, - {{InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "3"}}, - - {{InferenceEngine::MYRIAD_ENABLE_WEIGHTS_ANALYSIS, CONFIG_VALUE(YES)}}, - {{InferenceEngine::MYRIAD_ENABLE_WEIGHTS_ANALYSIS, CONFIG_VALUE(NO)}}, - // Deprecated - {{VPU_MYRIAD_CONFIG_KEY(FORCE_RESET), CONFIG_VALUE(YES)}}, - {{VPU_MYRIAD_CONFIG_KEY(FORCE_RESET), CONFIG_VALUE(NO)}}, - - {{VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), CONFIG_VALUE(YES)}}, - {{VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), CONFIG_VALUE(NO)}}, - - {{VPU_CONFIG_KEY(PRINT_RECEIVE_TENSOR_TIME), CONFIG_VALUE(YES)}}, - {{VPU_CONFIG_KEY(PRINT_RECEIVE_TENSOR_TIME), CONFIG_VALUE(NO)}}, - - {{VPU_MYRIAD_CONFIG_KEY(PROTOCOL), VPU_MYRIAD_CONFIG_VALUE(USB)}}, - {{VPU_MYRIAD_CONFIG_KEY(PROTOCOL), VPU_MYRIAD_CONFIG_VALUE(PCIE)}}, +using namespace BehaviorTestsDefinitions; +using namespace InferenceEngine::PluginConfigParams; - {{VPU_MYRIAD_CONFIG_KEY(PLATFORM), VPU_MYRIAD_CONFIG_VALUE(2450)}}, - {{VPU_MYRIAD_CONFIG_KEY(PLATFORM), VPU_MYRIAD_CONFIG_VALUE(2480)}} +const std::vector& getPrecisions() { + static const std::vector precisions = { + InferenceEngine::Precision::FP32, + InferenceEngine::Precision::FP16, }; - - const std::vector> MultiConfigs = { - {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, - {CONFIG_KEY(LOG_LEVEL), CONFIG_VALUE(LOG_DEBUG)}}, - {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, - {InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, CONFIG_VALUE(YES)}}, - - // Deprecated - {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, - {VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), CONFIG_VALUE(YES)}} + return precisions; +} + +std::vector> getCorrectConfigs() { + std::vector> correctConfigs = { + {{KEY_LOG_LEVEL, LOG_NONE}}, + {{KEY_LOG_LEVEL, LOG_ERROR}}, + {{KEY_LOG_LEVEL, LOG_WARNING}}, + {{KEY_LOG_LEVEL, LOG_INFO}}, + {{KEY_LOG_LEVEL, LOG_DEBUG}}, + {{KEY_LOG_LEVEL, LOG_TRACE}}, + + {{InferenceEngine::MYRIAD_ENABLE_FORCE_RESET, CONFIG_VALUE(YES)}}, + {{InferenceEngine::MYRIAD_ENABLE_FORCE_RESET, CONFIG_VALUE(NO)}}, + + {{InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, CONFIG_VALUE(YES)}}, + {{InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, CONFIG_VALUE(NO)}}, + + {{InferenceEngine::MYRIAD_TILING_CMX_LIMIT_KB, "-1"}}, + {{InferenceEngine::MYRIAD_TILING_CMX_LIMIT_KB, "0"}}, + {{InferenceEngine::MYRIAD_TILING_CMX_LIMIT_KB, "10"}}, + + {{InferenceEngine::MYRIAD_ENABLE_RECEIVING_TENSOR_TIME, CONFIG_VALUE(YES)}}, + {{InferenceEngine::MYRIAD_ENABLE_RECEIVING_TENSOR_TIME, CONFIG_VALUE(NO)}}, + + {{InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "1"}}, + {{InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "2"}}, + {{InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "3"}}, + + {{InferenceEngine::MYRIAD_ENABLE_WEIGHTS_ANALYSIS, CONFIG_VALUE(YES)}}, + {{InferenceEngine::MYRIAD_ENABLE_WEIGHTS_ANALYSIS, CONFIG_VALUE(NO)}}, + + // Deprecated + {{VPU_CONFIG_KEY(LOG_LEVEL), LOG_NONE}}, + {{VPU_CONFIG_KEY(LOG_LEVEL), LOG_ERROR}}, + {{VPU_CONFIG_KEY(LOG_LEVEL), LOG_WARNING}}, + {{VPU_CONFIG_KEY(LOG_LEVEL), LOG_INFO}}, + {{VPU_CONFIG_KEY(LOG_LEVEL), LOG_DEBUG}}, + {{VPU_CONFIG_KEY(LOG_LEVEL), LOG_TRACE}}, + + {{VPU_MYRIAD_CONFIG_KEY(FORCE_RESET), CONFIG_VALUE(YES)}}, + {{VPU_MYRIAD_CONFIG_KEY(FORCE_RESET), CONFIG_VALUE(NO)}}, + + {{VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), CONFIG_VALUE(YES)}}, + {{VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), CONFIG_VALUE(NO)}}, + + {{VPU_CONFIG_KEY(PRINT_RECEIVE_TENSOR_TIME), CONFIG_VALUE(YES)}}, + {{VPU_CONFIG_KEY(PRINT_RECEIVE_TENSOR_TIME), CONFIG_VALUE(NO)}}, + + {{VPU_MYRIAD_CONFIG_KEY(PLATFORM), VPU_MYRIAD_CONFIG_VALUE(2480)}}, + + { + {KEY_LOG_LEVEL, LOG_INFO}, + {InferenceEngine::MYRIAD_COPY_OPTIMIZATION, InferenceEngine::PluginConfigParams::NO}, + {InferenceEngine::MYRIAD_ENABLE_FORCE_RESET, CONFIG_VALUE(YES)}, + {InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, CONFIG_VALUE(YES)}, + {InferenceEngine::MYRIAD_TILING_CMX_LIMIT_KB, "10"}, + {InferenceEngine::MYRIAD_ENABLE_RECEIVING_TENSOR_TIME, CONFIG_VALUE(YES)}, + {InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "1"}, + {InferenceEngine::MYRIAD_ENABLE_WEIGHTS_ANALYSIS, CONFIG_VALUE(YES)}, + }, }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectConfigTests, - ::testing::Combine( - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), - ::testing::ValuesIn(Configs)), - CorrectConfigTests::getTestCaseName); - - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, CorrectConfigTests, - ::testing::Combine( - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CommonTestUtils::DEVICE_MULTI), - ::testing::ValuesIn(MultiConfigs)), - CorrectConfigTests::getTestCaseName); - - const std::vector> inconfigs = { - {{InferenceEngine::MYRIAD_PROTOCOL, "BLUETOOTH"}}, - {{InferenceEngine::MYRIAD_PROTOCOL, "LAN"}}, - - {{InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, "ON"}}, - {{InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, "OFF"}}, - - {{InferenceEngine::MYRIAD_ENABLE_FORCE_RESET, "ON"}}, - {{InferenceEngine::MYRIAD_ENABLE_FORCE_RESET, "OFF"}}, - - {{CONFIG_KEY(LOG_LEVEL), "VERBOSE"}}, - - {{InferenceEngine::MYRIAD_TILING_CMX_LIMIT_KB, "-10"}}, - - {{InferenceEngine::MYRIAD_ENABLE_RECEIVING_TENSOR_TIME, "ON"}}, - {{InferenceEngine::MYRIAD_ENABLE_RECEIVING_TENSOR_TIME, "OFF"}}, - - {{InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "Two"}}, - {{InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "SINGLE"}}, - - {{InferenceEngine::MYRIAD_ENABLE_WEIGHTS_ANALYSIS, "ON"}}, - {{InferenceEngine::MYRIAD_ENABLE_WEIGHTS_ANALYSIS, "OFF"}}, - - // Deprecated - {{VPU_MYRIAD_CONFIG_KEY(PROTOCOL), "BLUETOOTH"}}, - {{VPU_MYRIAD_CONFIG_KEY(PROTOCOL), "LAN"}}, - - {{VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), "ON"}}, - {{VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), "OFF"}}, + MyriadDevicesInfo info; + if (info.getAmountOfDevices(ncDeviceProtocol_t::NC_PCIE) > 0) { + correctConfigs.emplace_back(std::map{{VPU_MYRIAD_CONFIG_KEY(PROTOCOL), VPU_MYRIAD_CONFIG_VALUE(PCIE)}}); + correctConfigs.emplace_back(std::map{{InferenceEngine::MYRIAD_PROTOCOL, InferenceEngine::MYRIAD_PCIE}}); + } + + if (info.getAmountOfDevices(ncDeviceProtocol_t::NC_USB) > 0) { + correctConfigs.emplace_back(std::map{{VPU_MYRIAD_CONFIG_KEY(PROTOCOL), VPU_MYRIAD_CONFIG_VALUE(USB)}}); + correctConfigs.emplace_back(std::map{{InferenceEngine::MYRIAD_PROTOCOL, InferenceEngine::MYRIAD_USB}}); + } + + return correctConfigs; +} + +INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectConfigTests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), + ::testing::ValuesIn(getCorrectConfigs())), + CorrectConfigTests::getTestCaseName); + +const std::vector>& getCorrectMultiConfigs() { + static const std::vector> correctMultiConfigs = { + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + }, + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {KEY_LOG_LEVEL, LOG_DEBUG}, + }, + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {InferenceEngine::MYRIAD_COPY_OPTIMIZATION, InferenceEngine::PluginConfigParams::NO}, + }, + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, YES}, + }, + + // Deprecated + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {VPU_CONFIG_KEY(LOG_LEVEL), LOG_DEBUG}, + }, + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), CONFIG_VALUE(YES)}, + }, + }; + return correctMultiConfigs; +} + +INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, CorrectConfigTests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MULTI), + ::testing::ValuesIn(getCorrectMultiConfigs())), + CorrectConfigTests::getTestCaseName); + +const std::vector>& getDefaultEntries() { + static const std::vector> defaultEntries = { + {KEY_LOG_LEVEL, {LOG_NONE}}, + }; + return defaultEntries; +} + +INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectSingleOptionDefaultValueConfigTests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), + ::testing::ValuesIn(getDefaultEntries()))); + +const std::vector>& getCustomEntries() { + static const std::vector> customEntries = { + std::make_tuple(KEY_LOG_LEVEL, LOG_NONE, InferenceEngine::Parameter{LOG_NONE}), + std::make_tuple(KEY_LOG_LEVEL, LOG_ERROR, InferenceEngine::Parameter{LOG_ERROR}), + std::make_tuple(KEY_LOG_LEVEL, LOG_WARNING, InferenceEngine::Parameter{LOG_WARNING}), + std::make_tuple(KEY_LOG_LEVEL, LOG_INFO, InferenceEngine::Parameter{LOG_INFO}), + std::make_tuple(KEY_LOG_LEVEL, LOG_DEBUG, InferenceEngine::Parameter{LOG_DEBUG}), + std::make_tuple(KEY_LOG_LEVEL, LOG_TRACE, InferenceEngine::Parameter{LOG_TRACE}), + + std::make_tuple(VPU_CONFIG_KEY(LOG_LEVEL), LOG_NONE, InferenceEngine::Parameter{LOG_NONE}), + std::make_tuple(VPU_CONFIG_KEY(LOG_LEVEL), LOG_ERROR, InferenceEngine::Parameter{LOG_ERROR}), + std::make_tuple(VPU_CONFIG_KEY(LOG_LEVEL), LOG_WARNING, InferenceEngine::Parameter{LOG_WARNING}), + std::make_tuple(VPU_CONFIG_KEY(LOG_LEVEL), LOG_INFO, InferenceEngine::Parameter{LOG_INFO}), + std::make_tuple(VPU_CONFIG_KEY(LOG_LEVEL), LOG_DEBUG, InferenceEngine::Parameter{LOG_DEBUG}), + std::make_tuple(VPU_CONFIG_KEY(LOG_LEVEL), LOG_TRACE, InferenceEngine::Parameter{LOG_TRACE}), + + std::make_tuple(InferenceEngine::MYRIAD_COPY_OPTIMIZATION, InferenceEngine::PluginConfigParams::YES, InferenceEngine::Parameter{true}), + std::make_tuple(InferenceEngine::MYRIAD_COPY_OPTIMIZATION, InferenceEngine::PluginConfigParams::NO, InferenceEngine::Parameter{false}), + }; + return customEntries; +} + +INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectSingleOptionCustomValueConfigTests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), + ::testing::ValuesIn(getCustomEntries()))); + +const std::vector& getPublicOptions() { + static const std::vector publicOptions = { + KEY_LOG_LEVEL, + VPU_CONFIG_KEY(LOG_LEVEL), + }; + return publicOptions; +} + +INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectConfigPublicOptionsTests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), + ::testing::ValuesIn(getPublicOptions()))); + +const std::vector& getPrivateOptions() { + static const std::vector privateOptions = { + InferenceEngine::MYRIAD_COPY_OPTIMIZATION, + }; + return privateOptions; +} - {{VPU_MYRIAD_CONFIG_KEY(FORCE_RESET), "ON"}}, - {{VPU_MYRIAD_CONFIG_KEY(FORCE_RESET), "OFF"}}, +INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectConfigPrivateOptionsTests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), + ::testing::ValuesIn(getPrivateOptions()))); - {{VPU_CONFIG_KEY(PRINT_RECEIVE_TENSOR_TIME), "ON"}}, - {{VPU_CONFIG_KEY(PRINT_RECEIVE_TENSOR_TIME), "OFF"}}, +const std::vector>& getIncorrectConfigs() { + static const std::vector> incorrectConfigs = { + {{KEY_LOG_LEVEL, "INCORRECT_LOG_LEVEL"}}, - {{VPU_MYRIAD_CONFIG_KEY(PLATFORM), "-1"}}, - {{VPU_MYRIAD_CONFIG_KEY(PLATFORM), "0"}}, - {{VPU_MYRIAD_CONFIG_KEY(PLATFORM), "1"}}, - }; + {{InferenceEngine::MYRIAD_COPY_OPTIMIZATION, "ON"}}, + {{InferenceEngine::MYRIAD_COPY_OPTIMIZATION, "OFF"}}, - const std::vector> multiinconfigs = { - {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, - {InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, "ON"}}, - {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, - {CONFIG_KEY(LOG_LEVEL), "VERBOSE"}}, - - // Deprecated - {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, - {VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), "ON"}}, - - {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, - {VPU_MYRIAD_CONFIG_KEY(PLATFORM), "-1"}}, - {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, - {VPU_MYRIAD_CONFIG_KEY(PLATFORM), "0"}}, - {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, - {VPU_MYRIAD_CONFIG_KEY(PLATFORM), "1"}}, - }; + {{InferenceEngine::MYRIAD_PROTOCOL, "BLUETOOTH"}}, + {{InferenceEngine::MYRIAD_PROTOCOL, "LAN"}}, - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigTests, - ::testing::Combine( - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), - ::testing::ValuesIn(inconfigs)), - IncorrectConfigTests::getTestCaseName); + {{InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, "ON"}}, + {{InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, "OFF"}}, - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, IncorrectConfigTests, - ::testing::Combine( - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CommonTestUtils::DEVICE_MULTI), - ::testing::ValuesIn(multiinconfigs)), - IncorrectConfigTests::getTestCaseName); + {{InferenceEngine::MYRIAD_ENABLE_FORCE_RESET, "ON"}}, + {{InferenceEngine::MYRIAD_ENABLE_FORCE_RESET, "OFF"}}, + {{InferenceEngine::MYRIAD_TILING_CMX_LIMIT_KB, "-10"}}, + {{InferenceEngine::MYRIAD_ENABLE_RECEIVING_TENSOR_TIME, "ON"}}, + {{InferenceEngine::MYRIAD_ENABLE_RECEIVING_TENSOR_TIME, "OFF"}}, - const std::vector> Inconf = { - {{"some_nonexistent_key", "some_unknown_value"}} - }; + {{InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "Two"}}, + {{InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "SINGLE"}}, - const std::vector> multiInconf = { - {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES , CommonTestUtils::DEVICE_MYRIAD}, - {"some_nonexistent_key", "some_unknown_value"}} - }; + {{InferenceEngine::MYRIAD_ENABLE_WEIGHTS_ANALYSIS, "ON"}}, + {{InferenceEngine::MYRIAD_ENABLE_WEIGHTS_ANALYSIS, "OFF"}}, + // Deprecated + {{VPU_CONFIG_KEY(LOG_LEVEL), "INCORRECT_LOG_LEVEL"}}, - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigAPITests, - ::testing::Combine( - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), - ::testing::ValuesIn(Inconf)), - IncorrectConfigAPITests::getTestCaseName); + {{VPU_MYRIAD_CONFIG_KEY(PROTOCOL), "BLUETOOTH"}}, + {{VPU_MYRIAD_CONFIG_KEY(PROTOCOL), "LAN"}}, - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, IncorrectConfigAPITests, - ::testing::Combine( - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CommonTestUtils::DEVICE_MULTI), - ::testing::ValuesIn(multiInconf)), - IncorrectConfigAPITests::getTestCaseName); + {{VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), "ON"}}, + {{VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), "OFF"}}, + {{VPU_MYRIAD_CONFIG_KEY(FORCE_RESET), "ON"}}, + {{VPU_MYRIAD_CONFIG_KEY(FORCE_RESET), "OFF"}}, + {{VPU_CONFIG_KEY(PRINT_RECEIVE_TENSOR_TIME), "ON"}}, + {{VPU_CONFIG_KEY(PRINT_RECEIVE_TENSOR_TIME), "OFF"}}, + {{VPU_MYRIAD_CONFIG_KEY(PLATFORM), "-1"}}, + {{VPU_MYRIAD_CONFIG_KEY(PLATFORM), "0"}}, + {{VPU_MYRIAD_CONFIG_KEY(PLATFORM), "1"}}, - const std::vector> conf = { - {} + { + {KEY_LOG_LEVEL, LOG_INFO}, + {InferenceEngine::MYRIAD_COPY_OPTIMIZATION, "ON"}, + {InferenceEngine::MYRIAD_PROTOCOL, "BLUETOOTH"}, + {InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, CONFIG_VALUE(YES)}, + {InferenceEngine::MYRIAD_ENABLE_FORCE_RESET, "ON"}, + {InferenceEngine::MYRIAD_TILING_CMX_LIMIT_KB, "10"}, + {InferenceEngine::MYRIAD_ENABLE_WEIGHTS_ANALYSIS, "OFF"}, + {InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "1"}, + {InferenceEngine::MYRIAD_ENABLE_WEIGHTS_ANALYSIS, "ON"}, + }, }; - - const std::vector> multiconf = { - {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES , CommonTestUtils::DEVICE_MYRIAD}} + return incorrectConfigs; +} + +INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigTests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), + ::testing::ValuesIn(getIncorrectConfigs())), + IncorrectConfigTests::getTestCaseName); + +const std::vector>& getIncorrectMultiConfigs() { + static const std::vector> incorrectMultiConfigs = { + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {KEY_LOG_LEVEL, "INCORRECT_LOG_LEVEL"}, + }, + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, "ON"}, + }, + + // Deprecated + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {VPU_CONFIG_KEY(LOG_LEVEL), "INCORRECT_LOG_LEVEL"}, + }, + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), "ON"}, + }, + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {VPU_MYRIAD_CONFIG_KEY(PLATFORM), "-1"}, + }, + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {VPU_MYRIAD_CONFIG_KEY(PLATFORM), "0"}, + }, + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {VPU_MYRIAD_CONFIG_KEY(PLATFORM), "1"}, + }, }; + return incorrectMultiConfigs; +} + +INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, IncorrectConfigTests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MULTI), + ::testing::ValuesIn(getIncorrectMultiConfigs())), + IncorrectConfigTests::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigSingleOptionTests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), + ::testing::Values("INCORRECT_KEY"))); + +INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectConfigAPITests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), + ::testing::Values(std::map{})), + CorrectConfigAPITests::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, CorrectConfigAPITests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MULTI), + ::testing::ValuesIn(getCorrectMultiConfigs())), + CorrectConfigAPITests::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigAPITests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), + ::testing::Values(std::map{{"INCORRECT_KEY", "INCORRECT_VALUE"}})), + IncorrectConfigAPITests::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, IncorrectConfigAPITests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MULTI), + ::testing::ValuesIn(getIncorrectMultiConfigs())), + IncorrectConfigAPITests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectConfigAPITests, - ::testing::Combine( - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), - ::testing::ValuesIn(conf)), - CorrectConfigAPITests::getTestCaseName); - - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, CorrectConfigAPITests, - ::testing::Combine( - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CommonTestUtils::DEVICE_MULTI), - ::testing::ValuesIn(multiconf)), - CorrectConfigAPITests::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/shared/include/base/behavior_test_utils.hpp b/inference-engine/tests/functional/plugin/shared/include/base/behavior_test_utils.hpp index e21eb11624b20d..5705bdc8ae37c6 100644 --- a/inference-engine/tests/functional/plugin/shared/include/base/behavior_test_utils.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/base/behavior_test_utils.hpp @@ -27,11 +27,45 @@ #include "ngraph_functions/pass/convert_prc.hpp" namespace BehaviorTestsUtils { - typedef std::tuple< - InferenceEngine::Precision, // Network precision - std::string, // Device name - std::map // Config - > BehaviorParams; + +using BehaviorParamsEmptyConfig = std::tuple< + InferenceEngine::Precision, // Network precision + std::string // Device name +>; + +class BehaviorTestsEmptyConfig : public testing::WithParamInterface, + public CommonTestUtils::TestsCommon { +public: + static std::string getTestCaseName(testing::TestParamInfo obj) { + InferenceEngine::Precision netPrecision; + std::string targetDevice; + std::tie(netPrecision, targetDevice) = obj.param; + std::ostringstream result; + result << "netPRC=" << netPrecision.name() << "_"; + result << "targetDevice=" << targetDevice; + return result.str(); + } + + void SetUp() override { + std::tie(netPrecision, targetDevice) = this->GetParam(); + function = ngraph::builder::subgraph::makeConvPoolRelu(); + } + + void TearDown() override { + function.reset(); + } + + std::shared_ptr ie = PluginCache::get().ie(); + std::shared_ptr function; + InferenceEngine::Precision netPrecision; + std::string targetDevice; +}; + +typedef std::tuple< + InferenceEngine::Precision, // Network precision + std::string, // Device name + std::map // Config +> BehaviorParams; class BehaviorTestsBasic : public testing::WithParamInterface, public CommonTestUtils::TestsCommon { @@ -71,4 +105,86 @@ class BehaviorTestsBasic : public testing::WithParamInterface, std::map configuration; }; +using BehaviorParamsSingleOption = std::tuple< + InferenceEngine::Precision, // Network precision + std::string, // Device name + std::string // Key +>; + +class BehaviorTestsSingleOption : public testing::WithParamInterface, + public CommonTestUtils::TestsCommon { +public: + void SetUp() override { + std::tie(netPrecision, targetDevice, key) = this->GetParam(); + function = ngraph::builder::subgraph::makeConvPoolRelu(); + } + + void TearDown() override { + function.reset(); + } + + std::shared_ptr ie = PluginCache::get().ie(); + std::shared_ptr function; + InferenceEngine::Precision netPrecision; + std::string targetDevice; + std::string key; +}; + +using BehaviorParamsSingleOptionDefault = std::tuple< + InferenceEngine::Precision, // Network precision + std::string, // Device name + std::pair // Configuration key and its default value +>; + +class BehaviorTestsSingleOptionDefault : public testing::WithParamInterface, + public CommonTestUtils::TestsCommon { +public: + void SetUp() override { + std::pair entry; + std::tie(netPrecision, targetDevice, entry) = this->GetParam(); + std::tie(key, value) = entry; + function = ngraph::builder::subgraph::makeConvPoolRelu(); + } + + void TearDown() override { + function.reset(); + } + + std::shared_ptr ie = PluginCache::get().ie(); + std::shared_ptr function; + InferenceEngine::Precision netPrecision; + std::string targetDevice; + std::string key; + InferenceEngine::Parameter value; +}; + +using BehaviorParamsSingleOptionCustom = std::tuple< + InferenceEngine::Precision, // Network precision + std::string, // Device name + std::tuple // Configuration key, value and reference +>; + +class BehaviorTestsSingleOptionCustom : public testing::WithParamInterface, + public CommonTestUtils::TestsCommon { +public: + void SetUp() override { + std::tuple entry; + std::tie(netPrecision, targetDevice, entry) = this->GetParam(); + std::tie(key, value, reference) = entry; + function = ngraph::builder::subgraph::makeConvPoolRelu(); + } + + void TearDown() override { + function.reset(); + } + + std::shared_ptr ie = PluginCache::get().ie(); + std::shared_ptr function; + InferenceEngine::Precision netPrecision; + std::string targetDevice; + std::string key; + std::string value; + InferenceEngine::Parameter reference; +}; + } // namespace BehaviorTestsUtils diff --git a/inference-engine/tests/functional/plugin/shared/include/behavior/config.hpp b/inference-engine/tests/functional/plugin/shared/include/behavior/config.hpp index e13fe679b2a82c..efdd24187ae31b 100644 --- a/inference-engine/tests/functional/plugin/shared/include/behavior/config.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/behavior/config.hpp @@ -27,9 +27,11 @@ #include "ngraph_functions/subgraph_builders.hpp" namespace BehaviorTestsDefinitions { - using CorrectConfigTests = BehaviorTestsUtils::BehaviorTestsBasic; + + using EmptyConfigTests = BehaviorTestsUtils::BehaviorTestsEmptyConfig; + // Setting empty config doesn't throw - TEST_P(CorrectConfigTests, SetEmptyConfig) { + TEST_P(EmptyConfigTests, SetEmptyConfig) { // Skip test according to plugin specific disabledTestPatterns() (if any) SKIP_IF_CURRENT_TEST_IS_DISABLED() // Create CNNNetwork from ngrpah::Function @@ -39,6 +41,29 @@ namespace BehaviorTestsDefinitions { ASSERT_NO_THROW(ie->SetConfig(config, targetDevice)); } + TEST_P(EmptyConfigTests, CanLoadNetworkWithEmptyConfig) { + // Skip test according to plugin specific disabledTestPatterns() (if any) + SKIP_IF_CURRENT_TEST_IS_DISABLED() + // Create CNNNetwork from ngrpah::Function + InferenceEngine::CNNNetwork cnnNet(function); + std::map config; + ASSERT_NO_THROW(ie->GetMetric(targetDevice, METRIC_KEY(SUPPORTED_CONFIG_KEYS))); + ASSERT_NO_THROW(ie->LoadNetwork(cnnNet, targetDevice, config)); + } + + using CorrectSingleOptionDefaultValueConfigTests = BehaviorTestsUtils::BehaviorTestsSingleOptionDefault; + + TEST_P(CorrectSingleOptionDefaultValueConfigTests, CheckDefaultValueOfConfig) { + // Skip test according to plugin specific disabledTestPatterns() (if any) + SKIP_IF_CURRENT_TEST_IS_DISABLED() + // Create CNNNetwork from ngrpah::Function + InferenceEngine::CNNNetwork cnnNet(function); + ASSERT_NO_THROW(ie->GetMetric(targetDevice, METRIC_KEY(SUPPORTED_CONFIG_KEYS))); + ASSERT_EQ(ie->GetConfig(targetDevice, key), value); + } + + using CorrectConfigTests = BehaviorTestsUtils::BehaviorTestsBasic; + // Setting correct config doesn't throw TEST_P(CorrectConfigTests, SetCorrectConfig) { // Skip test according to plugin specific disabledTestPatterns() (if any) @@ -49,6 +74,53 @@ namespace BehaviorTestsDefinitions { ASSERT_NO_THROW(ie->SetConfig(configuration, targetDevice)); } + TEST_P(CorrectConfigTests, CanLoadNetworkWithCorrectConfig) { + // Skip test according to plugin specific disabledTestPatterns() (if any) + SKIP_IF_CURRENT_TEST_IS_DISABLED() + // Create CNNNetwork from ngrpah::Function + InferenceEngine::CNNNetwork cnnNet(function); + ASSERT_NO_THROW(ie->LoadNetwork(cnnNet, targetDevice, configuration)); + } + + using CorrectSingleOptionCustomValueConfigTests = BehaviorTestsUtils::BehaviorTestsSingleOptionCustom; + + TEST_P(CorrectSingleOptionCustomValueConfigTests, CheckCustomValueOfConfig) { + // Skip test according to plugin specific disabledTestPatterns() (if any) + SKIP_IF_CURRENT_TEST_IS_DISABLED() + // Create CNNNetwork from ngrpah::Function + InferenceEngine::CNNNetwork cnnNet(function); + ASSERT_NO_THROW(ie->GetMetric(targetDevice, METRIC_KEY(SUPPORTED_CONFIG_KEYS))); + std::map configuration = {{key, value}}; + ASSERT_NO_THROW(ie->SetConfig(configuration, targetDevice)); + ASSERT_EQ(ie->GetConfig(targetDevice, key), reference); + } + + using CorrectConfigPublicOptionsTests = BehaviorTestsUtils::BehaviorTestsSingleOption; + + TEST_P(CorrectConfigPublicOptionsTests, CanSeePublicOption) { + // Skip test according to plugin specific disabledTestPatterns() (if any) + SKIP_IF_CURRENT_TEST_IS_DISABLED() + // Create CNNNetwork from ngrpah::Function + InferenceEngine::CNNNetwork cnnNet(function); + InferenceEngine::Parameter metric; + ASSERT_NO_THROW(metric = ie->GetMetric(targetDevice, METRIC_KEY(SUPPORTED_CONFIG_KEYS))); + const auto& supportedOptions = metric.as>(); + ASSERT_NE(std::find(supportedOptions.cbegin(), supportedOptions.cend(), key), supportedOptions.cend()); + } + + using CorrectConfigPrivateOptionsTests = BehaviorTestsUtils::BehaviorTestsSingleOption; + + TEST_P(CorrectConfigPrivateOptionsTests, CanNotSeePrivateOption) { + // Skip test according to plugin specific disabledTestPatterns() (if any) + SKIP_IF_CURRENT_TEST_IS_DISABLED() + // Create CNNNetwork from ngrpah::Function + InferenceEngine::CNNNetwork cnnNet(function); + InferenceEngine::Parameter metric; + ASSERT_NO_THROW(metric = ie->GetMetric(targetDevice, METRIC_KEY(SUPPORTED_CONFIG_KEYS))); + const auto& supportedOptions = metric.as>(); + ASSERT_EQ(std::find(supportedOptions.cbegin(), supportedOptions.cend(), key), supportedOptions.cend()); + } + using IncorrectConfigTests = BehaviorTestsUtils::BehaviorTestsBasic; TEST_P(IncorrectConfigTests, SetConfigWithIncorrectKey) { @@ -67,7 +139,7 @@ namespace BehaviorTestsDefinitions { } } - TEST_P(IncorrectConfigTests, canNotLoadNetworkWithIncorrectConfig) { + TEST_P(IncorrectConfigTests, CanNotLoadNetworkWithIncorrectConfig) { // Skip test according to plugin specific disabledTestPatterns() (if any) SKIP_IF_CURRENT_TEST_IS_DISABLED() // Create CNNNetwork from ngrpah::Function @@ -80,6 +152,17 @@ namespace BehaviorTestsDefinitions { } } + using IncorrectConfigSingleOptionTests = BehaviorTestsUtils::BehaviorTestsSingleOption; + + TEST_P(IncorrectConfigSingleOptionTests, CanNotGetConfigWithIncorrectConfig) { + // Skip test according to plugin specific disabledTestPatterns() (if any) + SKIP_IF_CURRENT_TEST_IS_DISABLED() + // Create CNNNetwork from ngrpah::Function + InferenceEngine::CNNNetwork cnnNet(function); + ASSERT_NO_THROW(ie->GetMetric(targetDevice, METRIC_KEY(SUPPORTED_CONFIG_KEYS))); + ASSERT_THROW(ie->GetConfig(targetDevice, key), InferenceEngine::Exception); + } + using IncorrectConfigAPITests = BehaviorTestsUtils::BehaviorTestsBasic; TEST_P(IncorrectConfigAPITests, SetConfigWithNoExistingKey) { @@ -99,7 +182,7 @@ namespace BehaviorTestsDefinitions { using CorrectConfigAPITests = BehaviorTestsUtils::BehaviorTestsBasic; - TEST_P(CorrectConfigAPITests, canSetExclusiveAsyncRequests) { + TEST_P(CorrectConfigAPITests, CanSetExclusiveAsyncRequests) { // Skip test according to plugin specific disabledTestPatterns() (if any) SKIP_IF_CURRENT_TEST_IS_DISABLED() // Create CNNNetwork from ngrpah::Function @@ -130,7 +213,7 @@ namespace BehaviorTestsDefinitions { } } - TEST_P(CorrectConfigAPITests, withoutExclusiveAsyncRequests) { + TEST_P(CorrectConfigAPITests, WithoutExclusiveAsyncRequests) { // Skip test according to plugin specific disabledTestPatterns() (if any) SKIP_IF_CURRENT_TEST_IS_DISABLED() // Create CNNNetwork from ngrpah::Function @@ -159,7 +242,7 @@ namespace BehaviorTestsDefinitions { } } - TEST_P(CorrectConfigAPITests, reusableCPUStreamsExecutor) { + TEST_P(CorrectConfigAPITests, ReusableCPUStreamsExecutor) { // Skip test according to plugin specific disabledTestPatterns() (if any) SKIP_IF_CURRENT_TEST_IS_DISABLED() ASSERT_EQ(0u, InferenceEngine::ExecutorManager::getInstance()->getExecutorsNumber()); @@ -200,4 +283,4 @@ namespace BehaviorTestsDefinitions { ASSERT_EQ(0u, InferenceEngine::ExecutorManager::getInstance()->getIdleCPUStreamsExecutorsNumber()); } } -} // namespace BehaviorTestsDefinitions \ No newline at end of file +} // namespace BehaviorTestsDefinitions diff --git a/inference-engine/tests/ie_test_utils/common_test_utils/data_utils.cpp b/inference-engine/tests/ie_test_utils/common_test_utils/data_utils.cpp index 68d3af73a39d04..dbd552d6da8bdb 100644 --- a/inference-engine/tests/ie_test_utils/common_test_utils/data_utils.cpp +++ b/inference-engine/tests/ie_test_utils/common_test_utils/data_utils.cpp @@ -9,6 +9,8 @@ #include #include +using namespace InferenceEngine::details; + namespace CommonTestUtils { bool isDenseBlob(const InferenceEngine::Blob::Ptr& blob) { @@ -69,8 +71,8 @@ void fill_data_with_broadcast(InferenceEngine::Blob::Ptr& blob, InferenceEngine: if (src_dims[i] != dst_dims[i] && src_dims[i] != 1) compatible = false; } - IE_ASSERT(compatible) << "fill_data_with_broadcast error: Tensor shape " << values_dims - << " can not be broadcasted to shape " << blob_dims; + + IE_ASSERT(compatible); auto fill_strides_like_plain = [] (SizeVector dims) { SizeVector str(dims.size()); diff --git a/inference-engine/tests/unit/vpu/base/graph_transformer_tests.cpp b/inference-engine/tests/unit/vpu/base/graph_transformer_tests.cpp index 5f018914a5ee8e..52ff0425928522 100644 --- a/inference-engine/tests/unit/vpu/base/graph_transformer_tests.cpp +++ b/inference-engine/tests/unit/vpu/base/graph_transformer_tests.cpp @@ -6,6 +6,9 @@ #include +#include +#include + #include #include @@ -287,6 +290,8 @@ void GraphTransformerTest::SetUp() { frontEnd = std::make_shared(stageBuilder, &_mockCore); backEnd = std::make_shared(); passManager = std::make_shared(stageBuilder, backEnd); + + config = createConfiguration(); } void GraphTransformerTest::TearDown() { @@ -301,13 +306,13 @@ void GraphTransformerTest::TearDown() { void GraphTransformerTest::InitCompileEnv() { if (const auto envVar = std::getenv("IE_VPU_DUMP_INTERNAL_GRAPH_FILE_NAME")) { - config.dumpInternalGraphFileName = envVar; + config.compileConfig().dumpInternalGraphFileName = envVar; } if (const auto envVar = std::getenv("IE_VPU_DUMP_INTERNAL_GRAPH_DIRECTORY")) { - config.dumpInternalGraphDirectory = envVar; + config.compileConfig().dumpInternalGraphDirectory = envVar; } if (const auto envVar = std::getenv("IE_VPU_DUMP_ALL_PASSES")) { - config.dumpAllPasses = std::stoi(envVar) != 0; + config.compileConfig().dumpAllPasses = std::stoi(envVar) != 0; } CompileEnv::init(platform, config, _log); @@ -342,4 +347,16 @@ TestModel GraphTransformerTest::CreateTestModel() { return TestModel(CreateModel()); } +PluginConfiguration createConfiguration() { + PluginConfiguration configuration; + configuration.registerOption(); + configuration.registerOption(); + +IE_SUPPRESS_DEPRECATED_START + configuration.registerDeprecatedOption(VPU_CONFIG_KEY(LOG_LEVEL)); +IE_SUPPRESS_DEPRECATED_END + + return configuration; +} + } // namespace vpu diff --git a/inference-engine/tests/unit/vpu/base/graph_transformer_tests.hpp b/inference-engine/tests/unit/vpu/base/graph_transformer_tests.hpp index ea2fa0de07b694..fd007cca4f40bc 100644 --- a/inference-engine/tests/unit/vpu/base/graph_transformer_tests.hpp +++ b/inference-engine/tests/unit/vpu/base/graph_transformer_tests.hpp @@ -130,10 +130,12 @@ void checkStageTestInds(const StageRange& stageRange, std::initializer_list bool checkExecutionOrder(const Model& model, const std::vector& execOrder); +PluginConfiguration createConfiguration(); + class GraphTransformerTest : public ::testing::Test { public: - Platform platform = Platform::MYRIAD_X; - CompilationConfig config; + ncDevicePlatform_t platform = ncDevicePlatform_t::NC_MYRIAD_X; + PluginConfiguration config; StageBuilder::Ptr stageBuilder; FrontEnd::Ptr frontEnd; diff --git a/inference-engine/tests/unit/vpu/blob_reader_tests.cpp b/inference-engine/tests/unit/vpu/blob_reader_tests.cpp index 91115fc522a8dd..0092c540885287 100644 --- a/inference-engine/tests/unit/vpu/blob_reader_tests.cpp +++ b/inference-engine/tests/unit/vpu/blob_reader_tests.cpp @@ -12,6 +12,8 @@ #include #include +#include "graph_transformer_tests.hpp" + #include #include @@ -48,9 +50,8 @@ class VPUBlobReaderHeaderTests: public ::testing::Test, public testing::WithPara auto fn_ptr = ngraph::builder::subgraph::makeSplitConvConcat(); ASSERT_NO_THROW(_network = InferenceEngine::CNNNetwork(fn_ptr)); - CompilationConfig compileConfig; auto log = std::make_shared("GraphCompiler", LogLevel::None, consoleOutput()); - _compiledGraph = compileNetwork(_network, Platform::MYRIAD_X, compileConfig, log, &_mockCore); + _compiledGraph = compileNetwork(_network, ncDevicePlatform_t::NC_MYRIAD_X, createConfiguration(), log, &_mockCore); } CNNNetwork _network; diff --git a/inference-engine/tests/unit/vpu/middleend_tests/passes_tests/annotate_memory_types.cpp b/inference-engine/tests/unit/vpu/middleend_tests/passes_tests/annotate_memory_types.cpp index f1f841101c56bf..14e73c28cc7cec 100644 --- a/inference-engine/tests/unit/vpu/middleend_tests/passes_tests/annotate_memory_types.cpp +++ b/inference-engine/tests/unit/vpu/middleend_tests/passes_tests/annotate_memory_types.cpp @@ -24,7 +24,7 @@ class AnnotateMemoryTypes : public GraphTransformerTest, public testing::WithPar protected: void SetUp() override { ASSERT_NO_FATAL_FAILURE(GraphTransformerTest::SetUp()); - config.enableMemoryTypesAnnotation = true; + config.compileConfig().enableMemoryTypesAnnotation = true; ASSERT_NO_FATAL_FAILURE(InitCompileEnv()); ASSERT_NO_FATAL_FAILURE(InitPipeline()); diff --git a/inference-engine/tests_deprecated/behavior/shared_tests/plugin_tests/behavior_test_plugin.h b/inference-engine/tests_deprecated/behavior/shared_tests/plugin_tests/behavior_test_plugin.h index ef1b9e308110c9..e5c4c17679efaa 100644 --- a/inference-engine/tests_deprecated/behavior/shared_tests/plugin_tests/behavior_test_plugin.h +++ b/inference-engine/tests_deprecated/behavior/shared_tests/plugin_tests/behavior_test_plugin.h @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -111,4 +110,4 @@ const TestModel convReluNormPoolFcModelQ78 = getConvReluNormPoolFcModel(Inferenc class FPGAHangingTest : public BehaviorPluginTest { }; -#endif \ No newline at end of file +#endif diff --git a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_devices.cpp b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_devices.cpp index d5adac10397fc5..5016a4a3b9d8b3 100644 --- a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_devices.cpp +++ b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_devices.cpp @@ -30,7 +30,6 @@ std::vector MyriadDevicesInfo::getDevicesList( const ncDeviceProtocol_t deviceProtocol, const ncDevicePlatform_t devicePlatform, const XLinkDeviceState_t state) { - deviceDesc_t req_deviceDesc = {}; req_deviceDesc.protocol = convertProtocolToXlink(deviceProtocol); req_deviceDesc.platform = convertPlatformToXlink(devicePlatform); diff --git a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_devices.hpp b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_devices.hpp index a5628fcd0e60fb..ed9265f868cc5a 100644 --- a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_devices.hpp +++ b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_devices.hpp @@ -30,8 +30,7 @@ class MyriadDevicesInfo { std::vector getDevicesList( const ncDeviceProtocol_t deviceProtocol = NC_ANY_PROTOCOL, const ncDevicePlatform_t devicePlatform = NC_ANY_PLATFORM, - const XLinkDeviceState_t state = X_LINK_ANY_STATE - ); + const XLinkDeviceState_t state = X_LINK_ANY_STATE); inline bool isMyriadXDevice(const std::string &device_name); inline bool isMyriad2Device(const std::string &device_name); @@ -77,4 +76,4 @@ long MyriadDevicesInfo::getAmountOfUnbootedDevices(const ncDeviceProtocol_t devi long MyriadDevicesInfo::getAmountOfBootedDevices(const ncDeviceProtocol_t deviceProtocol) { return getAmountOfDevices(deviceProtocol, NC_ANY_PLATFORM, X_LINK_BOOTED); -} \ No newline at end of file +} diff --git a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_protocol_case.cpp b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_protocol_case.cpp index 48c8a413b84feb..a6b77a6b523a04 100644 --- a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_protocol_case.cpp +++ b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_protocol_case.cpp @@ -4,6 +4,7 @@ #include "myriad_protocol_case.hpp" #include "mvnc_ext.h" +#include "vpu/myriad_config.hpp" void MyriadProtocolTests::SetUp() { protocol = GetParam(); diff --git a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_watchdog_tests.cpp b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_watchdog_tests.cpp index c2ecf468b4638e..f55dd04473594a 100644 --- a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_watchdog_tests.cpp +++ b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_watchdog_tests.cpp @@ -15,6 +15,7 @@ #include "helpers/myriad_devices.hpp" #include +#include using namespace std; using namespace ::testing; diff --git a/inference-engine/tests_deprecated/behavior/vpu/shared_tests_instances/plugin_tests/vpu_test_data.hpp b/inference-engine/tests_deprecated/behavior/vpu/shared_tests_instances/plugin_tests/vpu_test_data.hpp index b1bb32646b6529..6a1ab38d36a4e2 100644 --- a/inference-engine/tests_deprecated/behavior/vpu/shared_tests_instances/plugin_tests/vpu_test_data.hpp +++ b/inference-engine/tests_deprecated/behavior/vpu/shared_tests_instances/plugin_tests/vpu_test_data.hpp @@ -3,6 +3,7 @@ // #include "behavior_test_plugin.h" +#include "vpu/myriad_config.hpp" // correct params #define BEH_MYRIAD BehTestParams("MYRIAD", \ diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_blob_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_blob_test.cpp index fc210dee5b7d26..7a2c027be03113 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_blob_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_blob_test.cpp @@ -169,10 +169,15 @@ TEST_F(myriadConfigsWithBlobImportTests_smoke, TryingToSetCompileOptionPrintsWar std::string content = redirectCoutStream.str(); for (auto &&elem : config) { + // TODO: remove once all options are migrated + std::stringstream deprecatedExpectedMsgStream; + deprecatedExpectedMsgStream << "[Warning][VPU][Config] " << elem.first; + const auto& deprecatedMsg = deprecatedExpectedMsgStream.str(); + std::stringstream expectedMsgStream; - expectedMsgStream << "[Warning][VPU][Config] " << elem.first; - std::string msg = expectedMsgStream.str(); - ASSERT_TRUE(content.find(msg) != std::string::npos) << msg; + expectedMsgStream << "[Warning][VPU][Configuration] Configuration option \"" << elem.first; + const auto& msg = expectedMsgStream.str(); + ASSERT_TRUE(content.find(msg) != std::string::npos || content.find(deprecatedMsg) != std::string::npos) << msg; } } diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_concat_test.hpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_concat_test.hpp index 775708c6389c7f..5d6074334f810f 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_concat_test.hpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_concat_test.hpp @@ -5,6 +5,7 @@ #include "myriad_layers_tests.hpp" using namespace InferenceEngine; +using namespace InferenceEngine::details; using myriadConcatTestParams = std::tuple; typedef myriadLayerTestBaseWithParam myriadLayersTestsConcat_smoke; diff --git a/inference-engine/tests_deprecated/functional/vpu/graph_transformer/gt_functional_tests.cpp b/inference-engine/tests_deprecated/functional/vpu/graph_transformer/gt_functional_tests.cpp index b5c98e0b368a97..ca07c26f03a92e 100644 --- a/inference-engine/tests_deprecated/functional/vpu/graph_transformer/gt_functional_tests.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/graph_transformer/gt_functional_tests.cpp @@ -7,6 +7,8 @@ #include #include #include +#include +#include using namespace InferenceEngine; using namespace vpu; @@ -19,12 +21,12 @@ void graphTransformerFunctionalTests::SetUp() { vpuLayersTests::SetUp(); _stageBuilder = std::make_shared(); - _platform = CheckMyriadX() ? Platform::MYRIAD_X : Platform::MYRIAD_2; + _platform = CheckMyriadX() ? ncDevicePlatform_t::NC_MYRIAD_X : ncDevicePlatform_t::NC_MYRIAD_2; } void graphTransformerFunctionalTests::CreateModel() { const auto compilerLog = std::make_shared("Test", LogLevel::Info, consoleOutput()); - CompileEnv::init(_platform, _compilationConfig, compilerLog); + CompileEnv::init(_platform, _configuration, compilerLog); AutoScope autoDeinit([] { CompileEnv::free(); }); @@ -43,7 +45,13 @@ void graphTransformerFunctionalTests::CreateModel() { void graphTransformerFunctionalTests::PrepareGraphCompilation() { SetSeed(DEFAULT_SEED_VALUE); - _compilationConfig = CompilationConfig(); + + _configuration.registerOption(); + _configuration.registerOption(); +IE_SUPPRESS_DEPRECATED_START + _configuration.registerDeprecatedOption(VPU_CONFIG_KEY(LOG_LEVEL)); +IE_SUPPRESS_DEPRECATED_END + _inputsInfo.clear(); _outputsInfo.clear(); _inputMap.clear(); @@ -87,7 +95,7 @@ int64_t graphTransformerFunctionalTests::CompileAndInfer(Blob::Ptr& inputBlob, B auto compiledGraph = compileModel( _gtModel, _platform, - _compilationConfig, + _configuration, compilerLog); std::istringstream instream(std::string(compiledGraph->blob.data(), compiledGraph->blob.size())); diff --git a/inference-engine/tests_deprecated/functional/vpu/graph_transformer/gt_functional_tests.hpp b/inference-engine/tests_deprecated/functional/vpu/graph_transformer/gt_functional_tests.hpp index 155b9f21ea3683..ff3063b217f7f2 100644 --- a/inference-engine/tests_deprecated/functional/vpu/graph_transformer/gt_functional_tests.hpp +++ b/inference-engine/tests_deprecated/functional/vpu/graph_transformer/gt_functional_tests.hpp @@ -25,12 +25,12 @@ class graphTransformerFunctionalTests : public vpuLayersTests { bool lockLayout = false); protected: - vpu::ModelPtr _gtModel; - vpu::CompilationConfig _compilationConfig; - vpu::StageBuilder::Ptr _stageBuilder; - vpu::Data _dataIntermediate; + vpu::ModelPtr _gtModel; + vpu::PluginConfiguration _configuration; + vpu::StageBuilder::Ptr _stageBuilder; + vpu::Data _dataIntermediate; private: - vpu::Platform _platform = vpu::Platform::MYRIAD_X; + ncDevicePlatform_t _platform = ncDevicePlatform_t::NC_MYRIAD_X; InferenceEngine::ExecutableNetwork _executableNetwork; }; diff --git a/inference-engine/tests_deprecated/functional/vpu/graph_transformer/merge_permute_and_reorder_test.cpp b/inference-engine/tests_deprecated/functional/vpu/graph_transformer/merge_permute_and_reorder_test.cpp index abcf7b062c6133..ec6332dcc98231 100644 --- a/inference-engine/tests_deprecated/functional/vpu/graph_transformer/merge_permute_and_reorder_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/graph_transformer/merge_permute_and_reorder_test.cpp @@ -62,8 +62,8 @@ class myriadGTMergePermuteNDTests_nightly: const bool usePermuteMerging, Blob::Ptr& outputBlob) { PrepareGraphCompilation(); - _compilationConfig.detectBatch = false; - _compilationConfig.enablePermuteMerging = usePermuteMerging; + _configuration.compileConfig().detectBatch = false; + _configuration.compileConfig().enablePermuteMerging = usePermuteMerging; IE_ASSERT(permutationVectors.size() >= 2); diff --git a/inference-engine/tests_deprecated/helpers/tests_vpu_common.hpp b/inference-engine/tests_deprecated/helpers/tests_vpu_common.hpp index 12417a62a0027b..5cfc76f825b486 100644 --- a/inference-engine/tests_deprecated/helpers/tests_vpu_common.hpp +++ b/inference-engine/tests_deprecated/helpers/tests_vpu_common.hpp @@ -13,7 +13,7 @@ #include "single_layer_common.hpp" #include "vpu/vpu_plugin_config.hpp" -#include +#include using config_t = std::map; diff --git a/inference-engine/tests_deprecated/unit/CMakeLists.txt b/inference-engine/tests_deprecated/unit/CMakeLists.txt index 18d7724add571a..c222e01f2b30b3 100644 --- a/inference-engine/tests_deprecated/unit/CMakeLists.txt +++ b/inference-engine/tests_deprecated/unit/CMakeLists.txt @@ -63,6 +63,7 @@ if (ENABLE_MYRIAD) engines/vpu/myriad_tests/helpers/*cpp engines/vpu/myriad_tests/helpers/*h ${IE_MAIN_SOURCE_DIR}/src/vpu/myriad_plugin/*.cpp + ${IE_MAIN_SOURCE_DIR}/src/vpu/myriad_plugin/configuration/*.cpp ) include_directories( engines/vpu/myriad_tests/helpers diff --git a/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_squeeze_test.cpp b/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_squeeze_test.cpp index ee3b84c8c83d84..603efb6578e9cd 100644 --- a/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_squeeze_test.cpp +++ b/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_squeeze_test.cpp @@ -12,6 +12,8 @@ #include #include "../gna_matcher.hpp" +using namespace InferenceEngine::details; + typedef struct { std::vector input_shape; std::vector squeeze_indices; diff --git a/inference-engine/tests_deprecated/unit/engines/vpu/adjust_data_location_tests.cpp b/inference-engine/tests_deprecated/unit/engines/vpu/adjust_data_location_tests.cpp index 5e5ebf2908222c..77ce658129ffbe 100644 --- a/inference-engine/tests_deprecated/unit/engines/vpu/adjust_data_location_tests.cpp +++ b/inference-engine/tests_deprecated/unit/engines/vpu/adjust_data_location_tests.cpp @@ -25,8 +25,8 @@ using VPU_AdjustDataLocationTest = GraphTransformerTest; // TEST_F(VPU_AdjustDataLocationTest, FlushCMX_TwoSpecialConsumers) { - config.numSHAVEs = 1; - config.numCMXSlices = 1; + config.compileConfig().numSHAVEs = 1; + config.compileConfig().numCMXSlices = 1; InitCompileEnv(); DataDesc dataDesc1(DataType::FP16, DimsOrder::NCHW, {CMX_SLICE_SIZE / (2 * 2), 1, 2, 1}); diff --git a/inference-engine/tests_deprecated/unit/engines/vpu/get_vpu_scale_from_ir_tests.cpp b/inference-engine/tests_deprecated/unit/engines/vpu/get_vpu_scale_from_ir_tests.cpp index aac3ac3ee97b2d..d0c2855f6794ca 100644 --- a/inference-engine/tests_deprecated/unit/engines/vpu/get_vpu_scale_from_ir_tests.cpp +++ b/inference-engine/tests_deprecated/unit/engines/vpu/get_vpu_scale_from_ir_tests.cpp @@ -24,8 +24,8 @@ TEST_F(VPU_AddVpuScaleTest, CanAddVpuScaleToNetwork) { InitCompileEnv(); auto& env = CompileEnv::get(); - CompilationConfig config{}; - config.irWithVpuScalesDir = "/"; + auto config = createConfiguration(); + config.compileConfig().irWithVpuScalesDir = "/"; env.updateConfig(config); std::shared_ptr function; @@ -69,8 +69,8 @@ TEST_F(VPU_AddVpuScaleTest, CanAddVpuScaleToNetwork) { TEST_F(VPU_AddVpuScaleTest, VpuScaleFromIrChangesWeights) { InitCompileEnv(); const auto& env = CompileEnv::get(); - CompilationConfig config{}; - config.irWithVpuScalesDir = "/"; + auto config = createConfiguration(); + config.compileConfig().irWithVpuScalesDir = "/"; env.updateConfig(config); std::shared_ptr function; diff --git a/inference-engine/tests_deprecated/unit/engines/vpu/graph_transformer_tests.cpp b/inference-engine/tests_deprecated/unit/engines/vpu/graph_transformer_tests.cpp index cd4b1619bdfc93..d0cd3a315ccc80 100644 --- a/inference-engine/tests_deprecated/unit/engines/vpu/graph_transformer_tests.cpp +++ b/inference-engine/tests_deprecated/unit/engines/vpu/graph_transformer_tests.cpp @@ -8,6 +8,8 @@ #include #include +#include +#include namespace vpu { @@ -158,6 +160,18 @@ void TestModel::setStageBatchInfo( } } +PluginConfiguration createConfiguration() { + PluginConfiguration configuration; + configuration.registerOption(); + configuration.registerOption(); + +IE_SUPPRESS_DEPRECATED_START + configuration.registerDeprecatedOption(VPU_CONFIG_KEY(LOG_LEVEL)); +IE_SUPPRESS_DEPRECATED_END + + return configuration; +} + void GraphTransformerTest::SetUp() { ASSERT_NO_FATAL_FAILURE(TestsCommon::SetUp()); @@ -170,6 +184,8 @@ void GraphTransformerTest::SetUp() { frontEnd = std::make_shared(stageBuilder, &_mockCore); backEnd = std::make_shared(); passManager = std::make_shared(stageBuilder, backEnd); + + config = createConfiguration(); } void GraphTransformerTest::TearDown() { @@ -186,13 +202,13 @@ void GraphTransformerTest::TearDown() { void GraphTransformerTest::InitCompileEnv() { if (const auto envVar = std::getenv("IE_VPU_DUMP_INTERNAL_GRAPH_FILE_NAME")) { - config.dumpInternalGraphFileName = envVar; + config.compileConfig().dumpInternalGraphFileName = envVar; } if (const auto envVar = std::getenv("IE_VPU_DUMP_INTERNAL_GRAPH_DIRECTORY")) { - config.dumpInternalGraphDirectory = envVar; + config.compileConfig().dumpInternalGraphDirectory = envVar; } if (const auto envVar = std::getenv("IE_VPU_DUMP_ALL_PASSES")) { - config.dumpAllPasses = std::stoi(envVar) != 0; + config.compileConfig().dumpAllPasses = std::stoi(envVar) != 0; } CompileEnv::init(platform, config, _log); diff --git a/inference-engine/tests_deprecated/unit/engines/vpu/graph_transformer_tests.hpp b/inference-engine/tests_deprecated/unit/engines/vpu/graph_transformer_tests.hpp index dc9768ea529ce1..6a656bc94d2f37 100644 --- a/inference-engine/tests_deprecated/unit/engines/vpu/graph_transformer_tests.hpp +++ b/inference-engine/tests_deprecated/unit/engines/vpu/graph_transformer_tests.hpp @@ -176,10 +176,12 @@ void CheckStageTestInds(const StageRange& stageRange, std::initializer_list } } +PluginConfiguration createConfiguration(); + class GraphTransformerTest : public TestsCommon { public: - Platform platform = Platform::MYRIAD_X; - CompilationConfig config; + ncDevicePlatform_t platform = ncDevicePlatform_t::NC_MYRIAD_X; + PluginConfiguration config; StageBuilder::Ptr stageBuilder; FrontEnd::Ptr frontEnd; diff --git a/inference-engine/tests_deprecated/unit/engines/vpu/replace_deconv_by_conv_tests.cpp b/inference-engine/tests_deprecated/unit/engines/vpu/replace_deconv_by_conv_tests.cpp index ef18901be416d1..59e9c77dadc023 100644 --- a/inference-engine/tests_deprecated/unit/engines/vpu/replace_deconv_by_conv_tests.cpp +++ b/inference-engine/tests_deprecated/unit/engines/vpu/replace_deconv_by_conv_tests.cpp @@ -91,7 +91,7 @@ TEST_F(VPU_ReplaceDeconvByConvTest, deconvReplacedByConvIfKernelSizeFitsHWUnit) } TEST_F(VPU_ReplaceDeconvByConvTest, deconvCannotBeReplacedByConvIfDisabledInConfig) { - config.hwBlackList.insert("deconv"); + config.compileConfig().hwBlackList.insert("deconv"); InitCompileEnv(); InitDeconvStage(16, 15); diff --git a/inference-engine/tests_deprecated/unit/inference_engine_tests/get_num_iterations_test.cpp b/inference-engine/tests_deprecated/unit/inference_engine_tests/get_num_iterations_test.cpp index 36990430195bba..01fb9f61163ba5 100644 --- a/inference-engine/tests_deprecated/unit/inference_engine_tests/get_num_iterations_test.cpp +++ b/inference-engine/tests_deprecated/unit/inference_engine_tests/get_num_iterations_test.cpp @@ -10,6 +10,8 @@ namespace { +using InferenceEngine::details::operator<<; + struct From { explicit From(int new_value) : value(new_value) {} int value; diff --git a/inference-engine/thirdparty/movidius/XLink/CMakeLists.txt b/inference-engine/thirdparty/movidius/XLink/CMakeLists.txt index 6e7f904227afec..9b365d8da3961f 100644 --- a/inference-engine/thirdparty/movidius/XLink/CMakeLists.txt +++ b/inference-engine/thirdparty/movidius/XLink/CMakeLists.txt @@ -40,3 +40,6 @@ if (ENABLE_MYRIAD_NO_BOOT) endif() set_property(TARGET ${TARGET_NAME} PROPERTY C_STANDARD 99) + +# TODO: remove once all options are migrated +ie_developer_export_targets(${TARGET_NAME}) diff --git a/inference-engine/thirdparty/movidius/mvnc/CMakeLists.txt b/inference-engine/thirdparty/movidius/mvnc/CMakeLists.txt index 37fd33e136bfe5..31a22c740351a8 100644 --- a/inference-engine/thirdparty/movidius/mvnc/CMakeLists.txt +++ b/inference-engine/thirdparty/movidius/mvnc/CMakeLists.txt @@ -71,6 +71,9 @@ if(NOT WIN32) ${LIBUSB_LIBRARY}) endif() +# TODO: remove once all options are migrated +ie_developer_export_targets(${TARGET_NAME}) + if(ENABLE_TESTS AND ENABLE_MYRIAD_MVNC_TESTS) add_subdirectory(tests) endif() diff --git a/inference-engine/thirdparty/movidius/mvnc/tests/mvnc_tests_common.cpp b/inference-engine/thirdparty/movidius/mvnc/tests/mvnc_tests_common.cpp index 0f7b69d1b4935a..1a3bca457f9a0e 100644 --- a/inference-engine/thirdparty/movidius/mvnc/tests/mvnc_tests_common.cpp +++ b/inference-engine/thirdparty/movidius/mvnc/tests/mvnc_tests_common.cpp @@ -300,7 +300,6 @@ TEST_P(MvncOpenDevice, WatchdogShouldResetDeviceWithoutConnection) { if (availableDevices_ == 0) GTEST_SKIP() << ncProtocolToStr(_deviceProtocol) << " devices not found"; - ncDeviceHandle_t* deviceHandle = nullptr; std::string deviceName; deviceDesc_t deviceDescToBoot = {}; deviceDesc_t in_deviceDesc = {}; From 6d4704ba9dc953d9135bd4ffe9b39378a9e00836 Mon Sep 17 00:00:00 2001 From: Maria Kaglinskaya Date: Thu, 17 Jun 2021 19:59:33 +0300 Subject: [PATCH 124/178] Fix klocwork master (#6219) * Fix klockwork issues in pruning transformation * Fixed tabs --- .../src/offline_transformations/include/mask_attribute.hpp | 6 ++++-- .../offline_transformations/src/pruning/propagate_masks.cpp | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/inference-engine/src/offline_transformations/include/mask_attribute.hpp b/inference-engine/src/offline_transformations/include/mask_attribute.hpp index 48c5b4ee9f0864..282f81b054e9f3 100644 --- a/inference-engine/src/offline_transformations/include/mask_attribute.hpp +++ b/inference-engine/src/offline_transformations/include/mask_attribute.hpp @@ -96,7 +96,8 @@ class Mask : public std::vector>, auto mask_2_iter = mask->rbegin(); while (mask_1_iter != rend() && - mask_2_iter != mask->rend()) { + mask_2_iter != mask->rend() && + result_iter != result_mask->rend()) { // Merge mask dimension values for both masks // Example: (MaskValue[1,2,3,4], MaskValue[2,3]) -> MaskValue[2,3] for (const auto & value : *mask_1_iter) { @@ -119,7 +120,8 @@ class Mask : public std::vector>, auto mask_2_iter = mask->rbegin(); while (mask_1_iter != rend() && - mask_2_iter != mask->rend()) { + mask_2_iter != mask->rend() && + result_iter != result_mask->rend()) { // Union mask dimension values for both masks // Example: (MaskValue[1,2,3,4], MaskValue[2, 5]) -> MaskValue[1, 2, 3, 4, 5] for (const auto & value : *mask_1_iter) { diff --git a/inference-engine/src/offline_transformations/src/pruning/propagate_masks.cpp b/inference-engine/src/offline_transformations/src/pruning/propagate_masks.cpp index 424b6ae958317d..271b200f31b5bc 100644 --- a/inference-engine/src/offline_transformations/src/pruning/propagate_masks.cpp +++ b/inference-engine/src/offline_transformations/src/pruning/propagate_masks.cpp @@ -246,6 +246,9 @@ class ngraph::pass::mask_propagation::Reshape : public MatcherPass { // To allow pruning on weights (allow reshape input Group (0) dim changing) replace Reshape Shape constant // [G, 1, 1, X, Y, Z] by [-1, 1, 1, X, Y, Z]. auto old_shape_const = std::dynamic_pointer_cast(m_shape.get_node_shared_ptr()); + if (!old_shape_const) { + return false; + } auto shape_value = old_shape_const.get()->cast_vector(); shape_value[0] = -1; auto new_const = opset6::Constant::create(old_shape_const->get_element_type(), @@ -462,6 +465,9 @@ class ngraph::pass::mask_propagation::Concat : public MatcherPass{ const auto & pattern_map = m.get_pattern_value_map(); const auto & m_output = pattern_map.at(concat); auto concat_ptr = std::dynamic_pointer_cast(m_output.get_node_shared_ptr()); + if (!concat_ptr) { + return false; + } auto axis = concat_ptr->get_concatenation_axis(); auto inputs = concat_ptr->inputs(); From 03b00f63bc06003cae49a1bf9d3d2c793592fb88 Mon Sep 17 00:00:00 2001 From: Egor Duplensky Date: Thu, 17 Jun 2021 21:18:14 +0300 Subject: [PATCH 125/178] [CPU] Extend blob dumping (#5939) * [CPU] Extend blob dumping * Allow multiple node types * Allow dump only input / output blobs * Allow dump all blobs using "*" --- .../src/mkldnn_plugin/utils/README.md | 38 +++++++++--- .../mkldnn_plugin/utils/debug_capabilities.h | 2 + .../src/mkldnn_plugin/utils/node_dumper.cpp | 62 +++++++++++++------ .../src/mkldnn_plugin/utils/node_dumper.h | 13 ++-- 4 files changed, 83 insertions(+), 32 deletions(-) diff --git a/inference-engine/src/mkldnn_plugin/utils/README.md b/inference-engine/src/mkldnn_plugin/utils/README.md index d3b98f1cb48f2f..bd3f1329a5e785 100644 --- a/inference-engine/src/mkldnn_plugin/utils/README.md +++ b/inference-engine/src/mkldnn_plugin/utils/README.md @@ -6,7 +6,7 @@ Use the following cmake option to enable debug capabilities: ## Blob dumping Blob dumping is controlled by environment variables (filters). -The variables define conditions of the node which input, output and internal blobs +The variables define conditions of the node which input and output blobs should be dumped for. > **NOTE**: Nothing is dumped by default @@ -15,11 +15,13 @@ should be dumped for. Environment variables can be set per execution, for example: ```sh - OV_CPU_BLOB_DUMP_DIR=dump_dir binary ... + OV_CPU_BLOB_DUMP_DIR=dump_dir OV_CPU_BLOB_DUMP_FORMAT=TEXT OV_CPU_BLOB_DUMP_NODE_PORTS=OUT binary ... ``` or for shell session (bash example): ```sh export OV_CPU_BLOB_DUMP_DIR=dump_dir + export OV_CPU_BLOB_DUMP_FORMAT=TEXT + export OV_CPU_BLOB_DUMP_NODE_PORTS=OUT binary ... ``` ### Specify dump directory @@ -35,8 +37,22 @@ Options are: * BIN (default) * TEXT +### Filter input / output blobs +To dump only input / output blobs: +```sh + OV_CPU_BLOB_DUMP_NODE_PORTS='' binary ... +``` +Example: +```sh + OV_CPU_BLOB_DUMP_NODE_PORTS=OUT binary ... +``` +Options are: +* IN +* OUT +* ALL + ### Filter by execution ID -To dump blobs only for node with specified execution IDs: +To dump blobs only for nodes with specified execution IDs: ```sh OV_CPU_BLOB_DUMP_NODE_EXEC_ID='' binary ... ``` @@ -46,19 +62,19 @@ Example: ``` ### Filter by type -To dump blobs only for node with specified type: +To dump blobs only for nodes with specified types: ```sh - OV_CPU_BLOB_DUMP_NODE_TYPE= binary ... + OV_CPU_BLOB_DUMP_NODE_TYPE= binary ... ``` Example: ```sh - OV_CPU_BLOB_DUMP_NODE_TYPE=Convolution binary ... + OV_CPU_BLOB_DUMP_NODE_TYPE='Convolution Reorder' binary ... ``` > **NOTE**: see **enum Type** in [mkldnn_node.h](../mkldnn_node.h) for list of the types ### Filter by name -To dump blobs only for node with name matching specified regex: +To dump blobs only for nodes with name matching specified regex: ```sh OV_CPU_BLOB_DUMP_NODE_NAME= binary ... ``` @@ -68,9 +84,17 @@ Example: ``` ### Dump all the blobs +```sh + OV_CPU_BLOB_DUMP_NODE_NAME="*" binary ... +``` + or ```sh OV_CPU_BLOB_DUMP_NODE_NAME=".+" binary ... ``` + or +```sh + OV_CPU_BLOB_DUMP_NODE_PORTS=ALL binary ... +``` ## Graph serialization The functionality allows to serialize execution graph using environment variable: diff --git a/inference-engine/src/mkldnn_plugin/utils/debug_capabilities.h b/inference-engine/src/mkldnn_plugin/utils/debug_capabilities.h index be6e7a830c2c63..c2784f8a46772f 100644 --- a/inference-engine/src/mkldnn_plugin/utils/debug_capabilities.h +++ b/inference-engine/src/mkldnn_plugin/utils/debug_capabilities.h @@ -20,6 +20,7 @@ class Config { readParam(blobDumpDir, "OV_CPU_BLOB_DUMP_DIR"); readParam(blobDumpFormat, "OV_CPU_BLOB_DUMP_FORMAT"); readParam(blobDumpNodeExecId, "OV_CPU_BLOB_DUMP_NODE_EXEC_ID"); + readParam(blobDumpNodePorts, "OV_CPU_BLOB_DUMP_NODE_PORTS"); readParam(blobDumpNodeType, "OV_CPU_BLOB_DUMP_NODE_TYPE"); readParam(blobDumpNodeName, "OV_CPU_BLOB_DUMP_NODE_NAME"); readParam(execGraphPath, "OV_CPU_EXEC_GRAPH_PATH"); @@ -28,6 +29,7 @@ class Config { std::string blobDumpDir; std::string blobDumpFormat; std::string blobDumpNodeExecId; + std::string blobDumpNodePorts; std::string blobDumpNodeType; std::string blobDumpNodeName; std::string execGraphPath; diff --git a/inference-engine/src/mkldnn_plugin/utils/node_dumper.cpp b/inference-engine/src/mkldnn_plugin/utils/node_dumper.cpp index 9f3af44a66a26a..1cfbae1ab5ff09 100644 --- a/inference-engine/src/mkldnn_plugin/utils/node_dumper.cpp +++ b/inference-engine/src/mkldnn_plugin/utils/node_dumper.cpp @@ -20,7 +20,7 @@ using namespace InferenceEngine; namespace MKLDNNPlugin { NodeDumper::NodeDumper(const DebugCaps::Config& config, const int _count) - : dumpFormat(DUMP_FORMAT::BIN) + : dumpFormat(FORMAT::BIN) , dumpDirName("mkldnn_dump") , count(_count) { if (!config.blobDumpDir.empty()) @@ -32,6 +32,9 @@ NodeDumper::NodeDumper(const DebugCaps::Config& config, const int _count) if (!config.blobDumpNodeExecId.empty()) dumpFilters[FILTER::BY_EXEC_ID] = config.blobDumpNodeExecId; + if (!config.blobDumpNodePorts.empty()) + dumpFilters[FILTER::BY_PORTS] = config.blobDumpNodePorts; + if (!config.blobDumpNodeType.empty()) dumpFilters[FILTER::BY_TYPE] = config.blobDumpNodeType; @@ -40,7 +43,7 @@ NodeDumper::NodeDumper(const DebugCaps::Config& config, const int _count) } void NodeDumper::dumpInputBlobs(const MKLDNNNodePtr& node) const { - if (!shouldBeDumped(node)) + if (!shouldBeDumped(node, "IN")) return; auto exec_order = std::to_string(node->getExecIndex()); @@ -60,7 +63,7 @@ void NodeDumper::dumpInputBlobs(const MKLDNNNodePtr& node) const { file_name = file_name.substr(file_name.size() - 240); auto dump_file = dumpDirName + "/#" + exec_order + "_" + file_name; - std::cout << "Dump before: " << dump_file << std::endl; + std::cout << "Dump inputs: " << dump_file << std::endl; TensorDesc desc = prEdge->getDesc(); if (desc.getPrecision() == Precision::BIN) @@ -77,7 +80,7 @@ void NodeDumper::dumpInputBlobs(const MKLDNNNodePtr& node) const { } void NodeDumper::dumpOutputBlobs(const MKLDNNNodePtr& node) const { - if (!shouldBeDumped(node)) + if (!shouldBeDumped(node, "OUT")) return; auto exec_order = std::to_string(node->getExecIndex()); @@ -96,7 +99,7 @@ void NodeDumper::dumpOutputBlobs(const MKLDNNNodePtr& node) const { file_name = file_name.substr(file_name.size() - 240); auto dump_file = dumpDirName + "/#" + exec_order + "_" + file_name; - std::cout << "Dump after: " << dump_file << std::endl; + std::cout << "Dump outputs: " << dump_file << std::endl; TensorDesc desc = childEdge->getDesc(); if (desc.getPrecision() == Precision::BIN) @@ -130,56 +133,77 @@ void NodeDumper::dumpInternalBlobs(const MKLDNNNodePtr& node) const { void NodeDumper::dump(const BlobDumper& bd, const std::string& file) const { switch (dumpFormat) { - case DUMP_FORMAT::BIN: { + case FORMAT::BIN: { bd.dump(file); break; } - case DUMP_FORMAT::TEXT: { + case FORMAT::TEXT: { bd.dumpAsTxt(file); break; } default: - IE_THROW() << "Unknown dump format"; + IE_THROW() << "NodeDumper: Unknown dump format"; } } -bool NodeDumper::shouldBeDumped(const MKLDNNNodePtr& node) const { +bool NodeDumper::shouldBeDumped(const MKLDNNNodePtr& node, const std::string& portsKind) const { if (dumpFilters.empty()) return false; - if (dumpFilters.count(FILTER::BY_EXEC_ID)) { // filter by exec id env set + if (dumpFilters.count(FILTER::BY_PORTS)) { // filter by ports configured + if (dumpFilters.at(FILTER::BY_PORTS) != "ALL" && + portsKind != dumpFilters.at(FILTER::BY_PORTS)) + return false; + } + + if (dumpFilters.count(FILTER::BY_EXEC_ID)) { // filter by exec id configured std::stringstream ss(dumpFilters.at(FILTER::BY_EXEC_ID)); int id; bool matched = false; + while (ss >> id) { - if (node->getExecIndex() == id) // exec id matches + if (node->getExecIndex() == id) {// exec id matches matched = true; + break; + } } if (!matched) return false; } - if (dumpFilters.count(FILTER::BY_TYPE)) { // filter by type env set - if (NameFromType(node->getType()) != dumpFilters.at(FILTER::BY_TYPE)) // type does not match + if (dumpFilters.count(FILTER::BY_TYPE)) { // filter by type configured + std::stringstream ss(dumpFilters.at(FILTER::BY_TYPE)); + std::string type; + bool matched = false; + + while (ss >> type) { + if (NameFromType(node->getType()) == type) {// type does not match + matched = true; + break; + } + } + + if (!matched) return false; } - if (dumpFilters.count(FILTER::BY_NAME)) { // filter by name env set - if (!std::regex_match(node->getName(), std::regex(dumpFilters.at(FILTER::BY_NAME)))) // name does not match + if (dumpFilters.count(FILTER::BY_NAME)) { // filter by name configured + if (dumpFilters.at(FILTER::BY_NAME) != "*" && // to have 'single char' option for matching all the names + !std::regex_match(node->getName(), std::regex(dumpFilters.at(FILTER::BY_NAME)))) // name does not match return false; } return true; } -NodeDumper::DUMP_FORMAT NodeDumper::parseDumpFormat(const std::string& format) const { +NodeDumper::FORMAT NodeDumper::parseDumpFormat(const std::string& format) const { if (format == "BIN") - return DUMP_FORMAT::BIN; + return FORMAT::BIN; else if (format == "TEXT") - return DUMP_FORMAT::TEXT; + return FORMAT::TEXT; else - IE_THROW() << "Unknown dump format"; + IE_THROW() << "NodeDumper: Unknown dump format"; } void NodeDumper::formatNodeName(std::string& name) const { diff --git a/inference-engine/src/mkldnn_plugin/utils/node_dumper.h b/inference-engine/src/mkldnn_plugin/utils/node_dumper.h index 0580bee4731b91..bac237c8883249 100644 --- a/inference-engine/src/mkldnn_plugin/utils/node_dumper.h +++ b/inference-engine/src/mkldnn_plugin/utils/node_dumper.h @@ -31,28 +31,29 @@ class NodeDumper { private: void dumpInternalBlobs(const MKLDNNNodePtr& node) const; void dump(const BlobDumper& bd, const std::string& file) const; - bool shouldBeDumped(const MKLDNNNodePtr &node) const; + bool shouldBeDumped(const MKLDNNNodePtr &node, const std::string& portsKind) const; - enum class DUMP_FORMAT { + enum class FORMAT { BIN, TEXT, }; - DUMP_FORMAT parseDumpFormat(const std::string& format) const; + FORMAT parseDumpFormat(const std::string& format) const; void formatNodeName(std::string& name) const; - DUMP_FORMAT dumpFormat; + FORMAT dumpFormat; std::string dumpDirName; int count; enum FILTER { + BY_PORTS, BY_EXEC_ID, BY_TYPE, BY_NAME, - COUNT, }; - std::unordered_map dumpFilters; + // std::hash is necessary for Ubuntu-16.04 (gcc-5.4 and defect in C++11 standart) + std::unordered_map> dumpFilters; }; } // namespace MKLDNNPlugin #endif // CPU_DEBUG_CAPS From 1fadfdafe74a268a0ee287eaf83eef6ca78e8481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Do=C5=82bniak?= Date: Fri, 18 Jun 2021 04:41:26 +0200 Subject: [PATCH 126/178] Deprecation of Node::get_default_value and some cleanup (#6203) * Deprecated the get_default_value method of Node class * Cleanup of the obsolete get_version methods * Deprecation warnings suppression * Deprecation of get_default_value for v0 ops --- ngraph/core/include/ngraph/node.hpp | 2 ++ ngraph/core/include/ngraph/op/add.hpp | 1 - ngraph/core/include/ngraph/op/avg_pool.hpp | 3 ++- ngraph/core/include/ngraph/op/binary_convolution.hpp | 1 - ngraph/core/include/ngraph/op/convolution.hpp | 2 ++ ngraph/core/include/ngraph/op/cum_sum.hpp | 2 ++ ngraph/core/include/ngraph/op/divide.hpp | 1 - ngraph/core/include/ngraph/op/group_conv.hpp | 2 ++ ngraph/core/include/ngraph/op/log_softmax.hpp | 1 - ngraph/core/include/ngraph/op/max_pool.hpp | 3 ++- ngraph/core/include/ngraph/op/pad.hpp | 1 - ngraph/core/include/ngraph/op/reduce_l1.hpp | 3 ++- ngraph/core/include/ngraph/op/reduce_l2.hpp | 3 ++- ngraph/core/include/ngraph/op/reduce_mean.hpp | 1 - ngraph/core/include/ngraph/op/reduce_prod.hpp | 3 ++- ngraph/core/include/ngraph/op/reduce_sum.hpp | 4 ++-- ngraph/core/include/ngraph/op/reshape.hpp | 1 - ngraph/core/include/ngraph/op/reverse.hpp | 5 ++--- ngraph/core/include/ngraph/op/softmax.hpp | 5 ++--- ngraph/core/include/ngraph/op/strided_slice.hpp | 1 - ngraph/core/include/ngraph/op/topk.hpp | 5 ++--- ngraph/core/src/op/reverse.cpp | 2 +- ngraph/core/src/op/softmax.cpp | 2 +- ngraph/core/src/op/topk.cpp | 2 +- ngraph/test/runtime/op/avg_pool.hpp | 2 ++ ngraph/test/runtime/op/convolution.hpp | 2 ++ 26 files changed, 33 insertions(+), 27 deletions(-) diff --git a/ngraph/core/include/ngraph/node.hpp b/ngraph/core/include/ngraph/node.hpp index 51a0cccfa25ba4..3d4880298b9d10 100644 --- a/ngraph/core/include/ngraph/node.hpp +++ b/ngraph/core/include/ngraph/node.hpp @@ -434,6 +434,8 @@ namespace ngraph /// \return Version of this node virtual size_t get_version() const { return get_type_info().version; } + + NGRAPH_DEPRECATED("This method is deprecated and will be removed soon.") virtual std::shared_ptr get_default_value() const { return nullptr; } /// Use instance ids for comparison instead of memory addresses to improve determinism bool operator<(const Node& other) const { return m_instance_id < other.m_instance_id; } diff --git a/ngraph/core/include/ngraph/op/add.hpp b/ngraph/core/include/ngraph/op/add.hpp index c16c8baac7b0f8..1cf09af76cf6cf 100644 --- a/ngraph/core/include/ngraph/op/add.hpp +++ b/ngraph/core/include/ngraph/op/add.hpp @@ -48,7 +48,6 @@ namespace ngraph bool visit_attributes(AttributeVisitor& visitor) override; - size_t get_version() const override { return 1; } bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override; bool has_evaluate() const override; diff --git a/ngraph/core/include/ngraph/op/avg_pool.hpp b/ngraph/core/include/ngraph/op/avg_pool.hpp index 8f414a6274d6c0..a46250885f33af 100644 --- a/ngraph/core/include/ngraph/op/avg_pool.hpp +++ b/ngraph/core/include/ngraph/op/avg_pool.hpp @@ -49,7 +49,6 @@ namespace ngraph op::RoundingType rounding_type = op::RoundingType::FLOOR, const PadType& auto_pad = op::PadType::EXPLICIT); - size_t get_version() const override { return 1; } void validate_and_infer_types() override; bool visit_attributes(AttributeVisitor& visitor) override; @@ -76,7 +75,9 @@ namespace ngraph op::RoundingType get_rounding_type() const; void set_rounding_type(op::RoundingType rounding_type); /// \return The default value for AvgPool. + NGRAPH_SUPPRESS_DEPRECATED_START virtual std::shared_ptr get_default_value() const override; + NGRAPH_SUPPRESS_DEPRECATED_END protected: Shape m_kernel; diff --git a/ngraph/core/include/ngraph/op/binary_convolution.hpp b/ngraph/core/include/ngraph/op/binary_convolution.hpp index 12e2c448f54036..3d4bf98496e620 100644 --- a/ngraph/core/include/ngraph/op/binary_convolution.hpp +++ b/ngraph/core/include/ngraph/op/binary_convolution.hpp @@ -59,7 +59,6 @@ namespace ngraph float pad_value, const PadType& auto_pad = PadType::EXPLICIT); - size_t get_version() const override { return 1; } void validate_and_infer_types() override; bool visit_attributes(AttributeVisitor& visitor) override; diff --git a/ngraph/core/include/ngraph/op/convolution.hpp b/ngraph/core/include/ngraph/op/convolution.hpp index 72a365be533705..31f82c3c390fe9 100644 --- a/ngraph/core/include/ngraph/op/convolution.hpp +++ b/ngraph/core/include/ngraph/op/convolution.hpp @@ -72,7 +72,9 @@ namespace ngraph const PadType& get_auto_pad() const { return m_auto_pad; } void set_auto_pad(const PadType& auto_pad) { m_auto_pad = auto_pad; } /// \return The default value for Convolution. + NGRAPH_SUPPRESS_DEPRECATED_START virtual std::shared_ptr get_default_value() const override; + NGRAPH_SUPPRESS_DEPRECATED_END protected: Strides m_strides; diff --git a/ngraph/core/include/ngraph/op/cum_sum.hpp b/ngraph/core/include/ngraph/op/cum_sum.hpp index 8a133a2502b26c..72cfe89225642d 100644 --- a/ngraph/core/include/ngraph/op/cum_sum.hpp +++ b/ngraph/core/include/ngraph/op/cum_sum.hpp @@ -91,7 +91,9 @@ namespace ngraph void validate_and_infer_types() override; /// \return The default value for CumSum. + NGRAPH_SUPPRESS_DEPRECATED_START virtual std::shared_ptr get_default_value() const override; + NGRAPH_SUPPRESS_DEPRECATED_END bool is_exclusive() const { return m_exclusive; } bool is_reverse() const { return m_reverse; } diff --git a/ngraph/core/include/ngraph/op/divide.hpp b/ngraph/core/include/ngraph/op/divide.hpp index 0c33fe6774ee98..f2e40dc55320b1 100644 --- a/ngraph/core/include/ngraph/op/divide.hpp +++ b/ngraph/core/include/ngraph/op/divide.hpp @@ -50,7 +50,6 @@ namespace ngraph virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; - size_t get_version() const override { return 1; } bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override; bool has_evaluate() const override; diff --git a/ngraph/core/include/ngraph/op/group_conv.hpp b/ngraph/core/include/ngraph/op/group_conv.hpp index ebda0392d96571..e55e3fd3457c0b 100644 --- a/ngraph/core/include/ngraph/op/group_conv.hpp +++ b/ngraph/core/include/ngraph/op/group_conv.hpp @@ -71,7 +71,9 @@ namespace ngraph const PadType& get_auto_pad() const { return m_auto_pad; } void set_auto_pad(const PadType& auto_pad) { m_auto_pad = auto_pad; } /// \return The default value for Convolution. + NGRAPH_SUPPRESS_DEPRECATED_START virtual std::shared_ptr get_default_value() const override; + NGRAPH_SUPPRESS_DEPRECATED_END protected: Strides m_strides; diff --git a/ngraph/core/include/ngraph/op/log_softmax.hpp b/ngraph/core/include/ngraph/op/log_softmax.hpp index 8bc4cec8e06694..f43bb82c5dff21 100644 --- a/ngraph/core/include/ngraph/op/log_softmax.hpp +++ b/ngraph/core/include/ngraph/op/log_softmax.hpp @@ -30,7 +30,6 @@ namespace ngraph bool visit_attributes(AttributeVisitor& visitor) override; void validate_and_infer_types() override; - size_t get_version() const override { return 1; } virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; diff --git a/ngraph/core/include/ngraph/op/max_pool.hpp b/ngraph/core/include/ngraph/op/max_pool.hpp index 9ca644cae75513..fcfbf69132d84d 100644 --- a/ngraph/core/include/ngraph/op/max_pool.hpp +++ b/ngraph/core/include/ngraph/op/max_pool.hpp @@ -41,7 +41,6 @@ namespace ngraph const PadType& auto_pad = op::PadType::EXPLICIT); bool visit_attributes(AttributeVisitor& visitor) override; - size_t get_version() const override { return 1; } void validate_and_infer_types() override; virtual std::shared_ptr @@ -69,7 +68,9 @@ namespace ngraph m_rounding_type = rounding_mode; } /// \return The default value for MaxPool. + NGRAPH_SUPPRESS_DEPRECATED_START virtual std::shared_ptr get_default_value() const override; + NGRAPH_SUPPRESS_DEPRECATED_END bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override; diff --git a/ngraph/core/include/ngraph/op/pad.hpp b/ngraph/core/include/ngraph/op/pad.hpp index 93ef2740b60bac..9f0b94cf16c91b 100644 --- a/ngraph/core/include/ngraph/op/pad.hpp +++ b/ngraph/core/include/ngraph/op/pad.hpp @@ -57,7 +57,6 @@ namespace ngraph Pad() = default; bool visit_attributes(AttributeVisitor& visitor) override; - size_t get_version() const override { return 1; } void validate_and_infer_types() override; virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; diff --git a/ngraph/core/include/ngraph/op/reduce_l1.hpp b/ngraph/core/include/ngraph/op/reduce_l1.hpp index 5760f855727fe3..5dd82a2b1f834d 100644 --- a/ngraph/core/include/ngraph/op/reduce_l1.hpp +++ b/ngraph/core/include/ngraph/op/reduce_l1.hpp @@ -31,9 +31,10 @@ namespace ngraph const Output& reduction_axes, bool keep_dims = false); - size_t get_version() const override { return 4; } /// \return The default value for Reduce. + NGRAPH_SUPPRESS_DEPRECATED_START virtual std::shared_ptr get_default_value() const override; + NGRAPH_SUPPRESS_DEPRECATED_END virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; diff --git a/ngraph/core/include/ngraph/op/reduce_l2.hpp b/ngraph/core/include/ngraph/op/reduce_l2.hpp index 4cd629f22aaaf4..35c8419c3dd5c5 100644 --- a/ngraph/core/include/ngraph/op/reduce_l2.hpp +++ b/ngraph/core/include/ngraph/op/reduce_l2.hpp @@ -30,9 +30,10 @@ namespace ngraph const Output& reduction_axes, bool keep_dims = false); - size_t get_version() const override { return 4; } /// \return The default value for Reduce. + NGRAPH_SUPPRESS_DEPRECATED_START virtual std::shared_ptr get_default_value() const override; + NGRAPH_SUPPRESS_DEPRECATED_END virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; diff --git a/ngraph/core/include/ngraph/op/reduce_mean.hpp b/ngraph/core/include/ngraph/op/reduce_mean.hpp index fb4c393b3d5252..dd64240981032b 100644 --- a/ngraph/core/include/ngraph/op/reduce_mean.hpp +++ b/ngraph/core/include/ngraph/op/reduce_mean.hpp @@ -26,7 +26,6 @@ namespace ngraph const Output& reduction_axes, bool keep_dims = false); - size_t get_version() const override { return 1; } std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; diff --git a/ngraph/core/include/ngraph/op/reduce_prod.hpp b/ngraph/core/include/ngraph/op/reduce_prod.hpp index 12ded1656d1aaf..2b1b73d3927cb2 100644 --- a/ngraph/core/include/ngraph/op/reduce_prod.hpp +++ b/ngraph/core/include/ngraph/op/reduce_prod.hpp @@ -30,9 +30,10 @@ namespace ngraph const Output& reduction_axes, bool keep_dims = false); - size_t get_version() const override { return 1; } /// \return The default value for Product. + NGRAPH_SUPPRESS_DEPRECATED_START virtual std::shared_ptr get_default_value() const override; + NGRAPH_SUPPRESS_DEPRECATED_END virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; diff --git a/ngraph/core/include/ngraph/op/reduce_sum.hpp b/ngraph/core/include/ngraph/op/reduce_sum.hpp index 5bef40536b1c43..83b663c10e6a12 100644 --- a/ngraph/core/include/ngraph/op/reduce_sum.hpp +++ b/ngraph/core/include/ngraph/op/reduce_sum.hpp @@ -77,13 +77,13 @@ namespace ngraph const Output& reduction_axes, bool keep_dims = false); - size_t get_version() const override { return 1; } - virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; /// \return The default value for Sum. + NGRAPH_SUPPRESS_DEPRECATED_START virtual std::shared_ptr get_default_value() const override; + NGRAPH_SUPPRESS_DEPRECATED_END bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override; diff --git a/ngraph/core/include/ngraph/op/reshape.hpp b/ngraph/core/include/ngraph/op/reshape.hpp index 6be77386cd014c..da2725247c0df4 100644 --- a/ngraph/core/include/ngraph/op/reshape.hpp +++ b/ngraph/core/include/ngraph/op/reshape.hpp @@ -46,7 +46,6 @@ namespace ngraph bool visit_attributes(AttributeVisitor& visitor) override; void validate_and_infer_types() override; - size_t get_version() const override { return 1; } virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; diff --git a/ngraph/core/include/ngraph/op/reverse.hpp b/ngraph/core/include/ngraph/op/reverse.hpp index 2a71ec75df2b13..012d02879df1d7 100644 --- a/ngraph/core/include/ngraph/op/reverse.hpp +++ b/ngraph/core/include/ngraph/op/reverse.hpp @@ -15,14 +15,14 @@ namespace ngraph class NGRAPH_API Reverse : public Op { public: + NGRAPH_RTTI_DECLARATION; + enum class Mode { INDEX, MASK }; - static constexpr NodeTypeInfo type_info{"Reverse", 1}; - const NodeTypeInfo& get_type_info() const override { return type_info; } Reverse() = default; /// \brief Constructs a reverse operation. /// @@ -47,7 +47,6 @@ namespace ngraph /// \return The second input data interpretation mode. Mode get_mode() const { return m_mode; } void set_mode(const Mode mode) { m_mode = mode; } - virtual size_t get_version() const override { return 1; } bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override; bool has_evaluate() const override; diff --git a/ngraph/core/include/ngraph/op/softmax.hpp b/ngraph/core/include/ngraph/op/softmax.hpp index 34537618153b70..33201cc843c344 100644 --- a/ngraph/core/include/ngraph/op/softmax.hpp +++ b/ngraph/core/include/ngraph/op/softmax.hpp @@ -15,8 +15,8 @@ namespace ngraph class NGRAPH_API Softmax : public Op { public: - static constexpr NodeTypeInfo type_info{"Softmax", 1}; - const NodeTypeInfo& get_type_info() const override { return type_info; } + NGRAPH_RTTI_DECLARATION; + Softmax() : m_axis(0) { @@ -34,7 +34,6 @@ namespace ngraph bool visit_attributes(AttributeVisitor& visitor) override; void validate_and_infer_types() override; - size_t get_version() const override { return 1; } virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; diff --git a/ngraph/core/include/ngraph/op/strided_slice.hpp b/ngraph/core/include/ngraph/op/strided_slice.hpp index 33144706b74b28..10e7e00feff779 100644 --- a/ngraph/core/include/ngraph/op/strided_slice.hpp +++ b/ngraph/core/include/ngraph/op/strided_slice.hpp @@ -90,7 +90,6 @@ namespace ngraph std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; void validate_and_infer_types() override; - size_t get_version() const override { return 1; } bool evaluate(const HostTensorVector& output_values, const HostTensorVector& input_values) const override; bool has_evaluate() const override; diff --git a/ngraph/core/include/ngraph/op/topk.hpp b/ngraph/core/include/ngraph/op/topk.hpp index 6d03190b6f63ab..e5ad952c46aff3 100644 --- a/ngraph/core/include/ngraph/op/topk.hpp +++ b/ngraph/core/include/ngraph/op/topk.hpp @@ -21,11 +21,11 @@ namespace ngraph class NGRAPH_API TopK : public Op { public: + NGRAPH_RTTI_DECLARATION; + using SortType = TopKSortType; using Mode = TopKMode; - static constexpr NodeTypeInfo type_info{"TopK", 1}; - const NodeTypeInfo& get_type_info() const override { return type_info; } /// \brief Constructs a TopK operation TopK() = default; /// \brief Constructs a TopK operation with two outputs: values and indices. @@ -60,7 +60,6 @@ namespace ngraph virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; - virtual size_t get_version() const override { return 1; } /// \brief Returns axis value after normalization /// \note If input rank required to normalization is dynamic, the exception is /// thrown diff --git a/ngraph/core/src/op/reverse.cpp b/ngraph/core/src/op/reverse.cpp index 68571a94a95100..903e9eea6c2531 100644 --- a/ngraph/core/src/op/reverse.cpp +++ b/ngraph/core/src/op/reverse.cpp @@ -18,7 +18,7 @@ using namespace std; using namespace ngraph; -constexpr NodeTypeInfo op::v1::Reverse::type_info; +NGRAPH_RTTI_DEFINITION(op::v1::Reverse, "Reverse", 1); op::v1::Reverse::Reverse(const Output& data, const Output& reversed_axes, diff --git a/ngraph/core/src/op/softmax.cpp b/ngraph/core/src/op/softmax.cpp index ae4317a9c12b11..097d46dd1594d1 100644 --- a/ngraph/core/src/op/softmax.cpp +++ b/ngraph/core/src/op/softmax.cpp @@ -51,7 +51,7 @@ namespace } // namespace // *** SOFTMAX OP SET V1 *** -constexpr NodeTypeInfo op::v1::Softmax::type_info; +NGRAPH_RTTI_DEFINITION(op::v1::Softmax, "Softmax", 1); op::v1::Softmax::Softmax(const Output& arg, const size_t axis) : Op({arg}) diff --git a/ngraph/core/src/op/topk.cpp b/ngraph/core/src/op/topk.cpp index 6b91fd13339e43..b346c5d238f60b 100644 --- a/ngraph/core/src/op/topk.cpp +++ b/ngraph/core/src/op/topk.cpp @@ -205,7 +205,7 @@ namespace topk } // namespace topk // v1 version starts -constexpr NodeTypeInfo op::v1::TopK::type_info; +NGRAPH_RTTI_DEFINITION(op::v1::TopK, "TopK", 1); static const std::uint64_t UNKNOWN_NORMALIZED_AXIS = std::numeric_limits::max(); diff --git a/ngraph/test/runtime/op/avg_pool.hpp b/ngraph/test/runtime/op/avg_pool.hpp index 1fab6fc25de2ec..701b3e174f3f46 100644 --- a/ngraph/test/runtime/op/avg_pool.hpp +++ b/ngraph/test/runtime/op/avg_pool.hpp @@ -146,7 +146,9 @@ namespace ngraph bool get_ceil_mode() const; void set_ceil_mode(bool ceil_mode); /// \return The default value for AvgPool. + NGRAPH_SUPPRESS_DEPRECATED_START virtual std::shared_ptr get_default_value() const override; + NGRAPH_SUPPRESS_DEPRECATED_END protected: Shape m_window_shape; diff --git a/ngraph/test/runtime/op/convolution.hpp b/ngraph/test/runtime/op/convolution.hpp index 5ddea7b0f7de6f..f5d45d269183af 100644 --- a/ngraph/test/runtime/op/convolution.hpp +++ b/ngraph/test/runtime/op/convolution.hpp @@ -178,7 +178,9 @@ namespace ngraph const PadType& get_pad_type() const { return m_pad_type; } void set_pad_type(const PadType& pad_type) { m_pad_type = pad_type; } /// \return The default value for Convolution. + NGRAPH_SUPPRESS_DEPRECATED_START virtual std::shared_ptr get_default_value() const override; + NGRAPH_SUPPRESS_DEPRECATED_END protected: Strides m_window_movement_strides; From 94352874a56793a5f379fe6cbb90a686377ed361 Mon Sep 17 00:00:00 2001 From: Piotr Szmelczynski Date: Fri, 18 Jun 2021 04:50:02 +0200 Subject: [PATCH 127/178] Revise ceiling (#6124) * update spec * add RTTI macro * clean backend test file * create visitor test * remove Ceiling cpu functional tests from skip_test_config * fix skip_test_config conflict * Add type_prop test for Ceiling. * Fix failing ceiling type_prop tests. * Replace unary_ops.cpp with single test op files. * Enable integer tests. Co-authored-by: Szymon Durawa --- docs/ops/arithmetic/Ceiling_1.md | 20 +++++++------- .../single_layer_tests/activation.cpp | 1 + .../skip_tests_config.cpp | 2 -- .../layer_tests_summary/utils/constants.py | 1 + ngraph/core/include/ngraph/op/ceiling.hpp | 3 +-- ngraph/core/src/op/ceiling.cpp | 2 +- ngraph/test/CMakeLists.txt | 10 ++++++- ngraph/test/backend/ceiling.in.cpp | 7 ----- ngraph/test/runtime/ie/unit_test.manifest | 3 --- ngraph/test/type_prop/abs.cpp | 9 +++++++ ngraph/test/type_prop/acos.cpp | 9 +++++++ ngraph/test/type_prop/asin.cpp | 9 +++++++ ngraph/test/type_prop/ceiling.cpp | 9 +++++++ ngraph/test/type_prop/exp.cpp | 9 +++++++ ngraph/test/type_prop/floor.cpp | 9 +++++++ ngraph/test/type_prop/sin.cpp | 9 +++++++ ngraph/test/type_prop/sqrt.cpp | 9 +++++++ .../{unary_ops.cpp => unary_ops.hpp} | 6 +---- ngraph/test/visitors/op/ceiling.cpp | 26 +++++++++++++++++++ 19 files changed, 122 insertions(+), 31 deletions(-) create mode 100644 ngraph/test/type_prop/abs.cpp create mode 100644 ngraph/test/type_prop/acos.cpp create mode 100644 ngraph/test/type_prop/asin.cpp create mode 100644 ngraph/test/type_prop/ceiling.cpp create mode 100644 ngraph/test/type_prop/exp.cpp create mode 100644 ngraph/test/type_prop/floor.cpp create mode 100644 ngraph/test/type_prop/sin.cpp create mode 100644 ngraph/test/type_prop/sqrt.cpp rename ngraph/test/type_prop/{unary_ops.cpp => unary_ops.hpp} (94%) create mode 100644 ngraph/test/visitors/op/ceiling.cpp diff --git a/docs/ops/arithmetic/Ceiling_1.md b/docs/ops/arithmetic/Ceiling_1.md index 588b5ff6842f55..4d4cfeb945002e 100644 --- a/docs/ops/arithmetic/Ceiling_1.md +++ b/docs/ops/arithmetic/Ceiling_1.md @@ -2,31 +2,31 @@ **Versioned name**: *Ceiling-1* -**Category**: Arithmetic unary operation +**Category**: Arithmetic unary operation **Short description**: *Ceiling* performs element-wise ceiling operation with given tensor. -**Attributes**: +**Detailed description**: For each element from the input tensor calculates corresponding +element in the output tensor with the following formula: - No attributes available. +\f[ +a_{i} = ceiling(a_{i}) +\f] + +**Attributes**: *Ceiling* operation has no attributes. **Inputs** -* **1**: An tensor of type T. **Required.** +* **1**: A tensor of type *T* and arbitrary shape. **Required.** **Outputs** -* **1**: The result of element-wise ceiling operation. A tensor of type T. +* **1**: The result of element-wise ceiling operation. A tensor of type *T*. **Types** * *T*: any numeric type. -*Ceiling* does the following with the input tensor *a*: - -\f[ -a_{i} = ceiling(a_{i}) -\f] **Examples** diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp index 6e762ed562c004..510e4039e2bfd0 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp @@ -64,6 +64,7 @@ const std::map>> activationTypes // List of operations that should be tested also with integer precision const std::map>> intActivationTypes = { + {Ceiling, {}}, {Sqrt, {}}, {Tanh, {}}, }; diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp index 3d4678bf5892b4..aa4c6dafb02c4b 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp @@ -33,8 +33,6 @@ std::vector disabledTestPatterns() { // TODO: Issue: 34055 R"(.*ShapeOfLayerTest.*)", R"(.*ReluShapeOfSubgraphTest.*)", - // TODO: Issue: 34805 - R"(.*ActivationLayerTest.*Ceiling.*)", // TODO: Issue: 43314 R"(.*Broadcast.*mode=BIDIRECTIONAL.*inNPrec=BOOL.*)", // TODO: Issue 43417 sporadic issue, looks like an issue in test, reproducible only on Windows platform diff --git a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py index cdbcdcf6c54ae8..7db26eb289542f 100644 --- a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py +++ b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py @@ -13,6 +13,7 @@ 'Broadcast-1', 'Broadcast-3', 'Bucketize-3', + 'Ceiling-1', 'CTCGreedyDecoder-1', 'CTCGreedyDecoderSeqLen-6', 'Concat-1', diff --git a/ngraph/core/include/ngraph/op/ceiling.hpp b/ngraph/core/include/ngraph/op/ceiling.hpp index 491ca099b2ac47..7ac74ad3dd407c 100644 --- a/ngraph/core/include/ngraph/op/ceiling.hpp +++ b/ngraph/core/include/ngraph/op/ceiling.hpp @@ -16,8 +16,7 @@ namespace ngraph class NGRAPH_API Ceiling : public util::UnaryElementwiseArithmetic { public: - static constexpr NodeTypeInfo type_info{"Ceiling", 0}; - const NodeTypeInfo& get_type_info() const override { return type_info; } + NGRAPH_RTTI_DECLARATION; /// \brief Constructs a ceiling operation. Ceiling() = default; /// \brief Constructs a ceiling operation. diff --git a/ngraph/core/src/op/ceiling.cpp b/ngraph/core/src/op/ceiling.cpp index 7ef0e8a6bece10..22abc45eba3ac2 100644 --- a/ngraph/core/src/op/ceiling.cpp +++ b/ngraph/core/src/op/ceiling.cpp @@ -12,7 +12,7 @@ using namespace std; using namespace ngraph; -constexpr NodeTypeInfo op::Ceiling::type_info; +NGRAPH_RTTI_DEFINITION(op::v0::Ceiling, "Ceiling", 0, util::UnaryElementwiseArithmetic); op::Ceiling::Ceiling(const Output& arg) : UnaryElementwiseArithmetic(arg) diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index efeb68e670ec94..fcb4f013775139 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -99,6 +99,9 @@ set(SRC span.cpp specialize_function.cpp tensor.cpp + type_prop/abs.cpp + type_prop/acos.cpp + type_prop/asin.cpp type_prop/assign.cpp type_prop/avg_pool.cpp type_prop/batch_norm.cpp @@ -107,6 +110,7 @@ set(SRC type_prop/binary_elementwise.cpp type_prop/broadcast.cpp type_prop/bucketize.cpp + type_prop/ceiling.cpp type_prop/clamp.cpp type_prop/concat.cpp type_prop/constant.cpp @@ -123,6 +127,7 @@ set(SRC type_prop/dft.cpp type_prop/dyn_reshape.cpp type_prop/einsum.cpp + type_prop/exp.cpp type_prop/experimental_detectron_generate_proposals.cpp type_prop/experimental_detectron_roi_feature_extractor.cpp type_prop/experimental_detectron_topkrois.cpp @@ -135,6 +140,7 @@ set(SRC type_prop/embeddingbag_packedsum.cpp type_prop/embedding_segments_sum.cpp type_prop/fake_quantize.cpp + type_prop/floor.cpp type_prop/floor_mod.cpp type_prop/gather.cpp type_prop/gather_elements.cpp @@ -201,11 +207,13 @@ set(SRC type_prop/selu.cpp type_prop/shape_of.cpp type_prop/shuffle_channels.cpp + type_prop/sin.cpp type_prop/softmax.cpp type_prop/softplus.cpp type_prop/space_to_batch.cpp type_prop/space_to_depth.cpp type_prop/split.cpp + type_prop/sqrt.cpp type_prop/squared_difference.cpp type_prop/squeeze.cpp type_prop/swish.cpp @@ -214,7 +222,6 @@ set(SRC type_prop/top_k.cpp type_prop/transpose.cpp type_prop/unary_elementwise.cpp - type_prop/unary_ops.cpp type_prop/unsqueeze.cpp type_prop/variadic_split.cpp type_prop_layers.cpp @@ -224,6 +231,7 @@ set(SRC visitors/op/batch_norm.cpp visitors/op/broadcast.cpp visitors/op/bucketize.cpp + visitors/op/ceiling.cpp visitors/op/constant.cpp visitors/op/convert.cpp visitors/op/convolution_backprop.cpp diff --git a/ngraph/test/backend/ceiling.in.cpp b/ngraph/test/backend/ceiling.in.cpp index cfd5d71e3e1315..2cf7b5489491b0 100644 --- a/ngraph/test/backend/ceiling.in.cpp +++ b/ngraph/test/backend/ceiling.in.cpp @@ -2,13 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include -#include - // clang-format off #ifdef ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS #define DEFAULT_FLOAT_TOLERANCE_BITS ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS diff --git a/ngraph/test/runtime/ie/unit_test.manifest b/ngraph/test/runtime/ie/unit_test.manifest index aa4079eee82c89..03d0185ad8f310 100644 --- a/ngraph/test/runtime/ie/unit_test.manifest +++ b/ngraph/test/runtime/ie/unit_test.manifest @@ -723,9 +723,6 @@ cum_sum_2dim cum_sum_3d cum_sum_2dim_allmodes -# Unsupported primitive of type: Ceiling -ceiling - # Incorrect dimensions for broadcasting for Add auto_bcast_binary_elementwise_pdpd_dynamic diff --git a/ngraph/test/type_prop/abs.cpp b/ngraph/test/type_prop/abs.cpp new file mode 100644 index 00000000000000..7ef727bdee09f5 --- /dev/null +++ b/ngraph/test/type_prop/abs.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Type = ::testing::Types; + +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_abs, UnaryOperator, Type); diff --git a/ngraph/test/type_prop/acos.cpp b/ngraph/test/type_prop/acos.cpp new file mode 100644 index 00000000000000..8bff6e06dd968a --- /dev/null +++ b/ngraph/test/type_prop/acos.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Type = ::testing::Types; + +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_acos, UnaryOperator, Type); diff --git a/ngraph/test/type_prop/asin.cpp b/ngraph/test/type_prop/asin.cpp new file mode 100644 index 00000000000000..96293580d57dc4 --- /dev/null +++ b/ngraph/test/type_prop/asin.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Type = ::testing::Types; + +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_asin, UnaryOperator, Type); diff --git a/ngraph/test/type_prop/ceiling.cpp b/ngraph/test/type_prop/ceiling.cpp new file mode 100644 index 00000000000000..f173a031491074 --- /dev/null +++ b/ngraph/test/type_prop/ceiling.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Type = ::testing::Types; + +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_ceiling, UnaryOperator, Type); diff --git a/ngraph/test/type_prop/exp.cpp b/ngraph/test/type_prop/exp.cpp new file mode 100644 index 00000000000000..f25c335504ef7a --- /dev/null +++ b/ngraph/test/type_prop/exp.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Type = ::testing::Types; + +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_exp, UnaryOperator, Type); diff --git a/ngraph/test/type_prop/floor.cpp b/ngraph/test/type_prop/floor.cpp new file mode 100644 index 00000000000000..3eca60835f0b1a --- /dev/null +++ b/ngraph/test/type_prop/floor.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Type = ::testing::Types; + +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_floor, UnaryOperator, Type); diff --git a/ngraph/test/type_prop/sin.cpp b/ngraph/test/type_prop/sin.cpp new file mode 100644 index 00000000000000..ab777d9a4429bd --- /dev/null +++ b/ngraph/test/type_prop/sin.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Type = ::testing::Types; + +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_sin, UnaryOperator, Type); diff --git a/ngraph/test/type_prop/sqrt.cpp b/ngraph/test/type_prop/sqrt.cpp new file mode 100644 index 00000000000000..48a5ce13a85300 --- /dev/null +++ b/ngraph/test/type_prop/sqrt.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Type = ::testing::Types; + +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_sqrt, UnaryOperator, Type); diff --git a/ngraph/test/type_prop/unary_ops.cpp b/ngraph/test/type_prop/unary_ops.hpp similarity index 94% rename from ngraph/test/type_prop/unary_ops.cpp rename to ngraph/test/type_prop/unary_ops.hpp index 788b50917fa6a2..e8babcba4067d5 100644 --- a/ngraph/test/type_prop/unary_ops.cpp +++ b/ngraph/test/type_prop/unary_ops.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2021 Intel Corporation +// Copyright (C) 2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -95,7 +95,3 @@ REGISTER_TYPED_TEST_CASE_P(UnaryOperator, dynamic_rank_input_shape_2D, dynamic_rank_input_shape_3D, dynamic_rank_input_shape_full); - -using Types = ::testing::Types; - -INSTANTIATE_TYPED_TEST_CASE_P(type_prop, UnaryOperator, Types); diff --git a/ngraph/test/visitors/op/ceiling.cpp b/ngraph/test/visitors/op/ceiling.cpp new file mode 100644 index 00000000000000..34ed3b653b36ef --- /dev/null +++ b/ngraph/test/visitors/op/ceiling.cpp @@ -0,0 +1,26 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" + +#include "ngraph/ngraph.hpp" +#include "ngraph/op/util/attr_types.hpp" +#include "ngraph/opsets/opset1.hpp" +#include "util/visitor.hpp" + +using namespace std; +using namespace ngraph; +using ngraph::test::NodeBuilder; + +TEST(attributes, ceiling_op) +{ + NodeBuilder::get_ops().register_factory(); + const auto A = make_shared(element::f32, Shape{5, 2}); + + const auto ceiling = make_shared(A); + NodeBuilder builder(ceiling); + + const auto expected_attr_count = 0; + EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); +} From 73ef2ffb415bea856472ddec61679f3af75ee6a2 Mon Sep 17 00:00:00 2001 From: cecilia peng Date: Fri, 18 Jun 2021 14:20:00 +0800 Subject: [PATCH 128/178] MulticlassNms-8 spec. (#5907) * MulticlassNms-8 spec. This Op functionally extends NonMaxSuppression-5, to perform more post-processing phases, and lay out the detection outputs in the way of PaddlePaddle detection. * Update MulticlassNMS_8.md Clarify the meaning of "nms_top_k". * Update MulticlassNMS_8.md * Update MulticlassNMS_8.md * Update MulticlassNMS_8.md * Update MulticlassNMS_8.md * Update MulticlassNMS_8.md --- docs/doxygen/ie_docs.xml | 1 + docs/ops/sort/MulticlassNMS_8.md | 161 +++++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+) create mode 100644 docs/ops/sort/MulticlassNMS_8.md diff --git a/docs/doxygen/ie_docs.xml b/docs/doxygen/ie_docs.xml index 503f9f3898601b..c12cc4d22be918 100644 --- a/docs/doxygen/ie_docs.xml +++ b/docs/doxygen/ie_docs.xml @@ -194,6 +194,7 @@ limitations under the License. + diff --git a/docs/ops/sort/MulticlassNMS_8.md b/docs/ops/sort/MulticlassNMS_8.md new file mode 100644 index 00000000000000..16997a81397ef0 --- /dev/null +++ b/docs/ops/sort/MulticlassNMS_8.md @@ -0,0 +1,161 @@ +## MulticlassNonMaxSuppression {#openvino_docs_ops_sort_MulticlassNonMaxSuppression_8} + +**Versioned name**: *MulticlassNonMaxSuppression-8* + +**Category**: *Sorting and maximization* + +**Short description**: *MulticlassNonMaxSuppression* performs multi-class non-maximum suppression of the boxes with predicted scores. + +**Detailed description**: *MulticlassNonMaxSuppression* is a multi-phase operation. It implements non-maximum suppression algorithm as described below: + +1. Let `B = [b_0,...,b_n]` be the list of initial detection boxes, `S = [s_0,...,s_N]` be the list of corresponding scores. +2. Let `D = []` be an initial collection of resulting boxes. Let `adaptive_threshold = iou_threshold`. +3. If `B` is empty, go to step 9. +4. Take the box with highest score. Suppose that it is the box `b` with the score `s`. +5. Delete `b` from `B`. +6. If the score `s` is greater than or equal to `score_threshold`, add `b` to `D`, else go to step 9. +7. If `nms_eta < 1` and `adaptive_threshold > 0.5`, update `adaptive_threshold *= nms_eta`. +8. For each input box `b_i` from `B` and the corresponding score `s_i`, set `s_i = 0` when `iou(b, b_i) > adaptive_threshold`, and go to step 3. +9. Return `D`, a collection of the corresponding scores `S`, and the number of elements in `D`. + +This algorithm is applied independently to each class of each batch element. The operation feeds at most `nms_top_k` scoring candidate boxes to this algorithm. +The total number of output boxes of each batch element must not exceed `keep_top_k`. +Boxes of `background_class` are skipped and thus eliminated. + +**Attributes**: + +* *sort_result* + + * **Description**: *sort_result* specifies the order of output elements. + * **Range of values**: `class`, `score`, `none` + * *class* - sort selected boxes by class id (ascending). + * *score* - sort selected boxes by score (descending). + * *none* - do not guarantee the order. + * **Type**: `string` + * **Default value**: `none` + * **Required**: *No* + +* *sort_result_across_batch* + + * **Description**: *sort_result_across_batch* is a flag that specifies whenever it is necessary to sort selected boxes across batches or not. + * **Range of values**: true or false + * *true* - sort selected boxes across batches. + * *false* - do not sort selected boxes across batches (boxes are sorted per batch element). + * **Type**: boolean + * **Default value**: false + * **Required**: *No* + +* *output_type* + + * **Description**: the tensor type of outputs `selected_indices` and `valid_outputs`. + * **Range of values**: `i64` or `i32` + * **Type**: `string` + * **Default value**: `i64` + * **Required**: *No* + +* *iou_threshold* + + * **Description**: intersection over union threshold. + * **Range of values**: a floating-point number + * **Type**: `float` + * **Default value**: `0` + * **Required**: *No* + +* *score_threshold* + + * **Description**: minimum score to consider box for the processing. + * **Range of values**: a floating-point number + * **Type**: `float` + * **Default value**: `0` + * **Required**: *No* + +* *nms_top_k* + + * **Description**: maximum number of boxes to be selected per class. + * **Range of values**: an integer + * **Type**: `int` + * **Default value**: `-1` meaning to keep all boxes + * **Required**: *No* + +* *keep_top_k* + + * **Description**: maximum number of boxes to be selected per batch element. + * **Range of values**: an integer + * **Type**: `int` + * **Default value**: `-1` meaning to keep all boxes + * **Required**: *No* + +* *background_class* + + * **Description**: the background class id. + * **Range of values**: an integer + * **Type**: `int` + * **Default value**: `-1` meaning to keep all classes. + * **Required**: *No* + +* *nms_eta* + + * **Description**: eta parameter for adaptive NMS. + * **Range of values**: a floating-point number in close range `[0, 1.0]`. + * **Type**: `float` + * **Default value**: `1.0` + * **Required**: *No* + +**Inputs**: + +* **1**: `boxes` - tensor of type *T* and shape `[num_batches, num_boxes, 4]` with box coordinates. The box coordinates are layout as `[xmin, ymin, xmax, ymax]`. **Required.** + +* **2**: `scores` - tensor of type *T* and shape `[num_batches, num_classes, num_boxes]` with box scores. **Required.** + +**Outputs**: + +* **1**: `selected_outputs` - tensor of type *T_THRESHOLDS* and shape `[number of selected boxes, 6]` containing the selected boxes with score and class as tuples `[class_id, box_score, xmin, ymin, xmax, ymax]`. + +* **2**: `selected_indices` - tensor of type *T_IND* and shape `[number of selected boxes, 1]` the selected indices in the flattened `boxes`, which are absolute values cross batches. Therefore possible valid values are in the range `[0, num_batches * num_boxes - 1]`. + +* **3**: `selected_num` - 1D tensor of type *T_IND* and shape `[num_batches]` representing the number of selected boxes for each batch element. + +When there is no box selected, `selected_num` is filled with `0`. `selected_outputs` is an empty tensor of shape `[0, 6]`, and `selected_indices` is an empty tensor of shape `[0, 1]`. + +**Types** + +* *T*: floating point type. + +* *T_MAX_BOXES*: integer type. + +* *T_THRESHOLDS*: floating point type. + +* *T_IND*: `int64` or `int32`. + +**Example** + +```xml + + + + + 3 + 100 + 4 + + + 3 + 5 + 100 + + + + + -1 + 6 + + + -1 + 1 + + + 3 + + + +``` From 9dd0531599d74fdf281c83179e9e10bcd3ce37ac Mon Sep 17 00:00:00 2001 From: Gabriele Galiero Casay Date: Fri, 18 Jun 2021 08:20:40 +0200 Subject: [PATCH 129/178] Negative operation specification refactoring (#6204) * update spec * update supported types in spec * Minor changes in spec Co-authored-by: pszmel --- docs/ops/arithmetic/Negative_1.md | 32 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/docs/ops/arithmetic/Negative_1.md b/docs/ops/arithmetic/Negative_1.md index 2e17112e7bcc51..997342c2d05da1 100644 --- a/docs/ops/arithmetic/Negative_1.md +++ b/docs/ops/arithmetic/Negative_1.md @@ -2,35 +2,33 @@ **Versioned name**: *Negative-1* -**Category**: Arithmetic unary operation +**Category**: Arithmetic unary operation -**Short description**: *Negative* performs element-wise negative operation with given tensor. +**Short description**: *Negative* performs element-wise negative operation on a given input tensor. -**Attributes**: +**Detailed description** - No attributes available. +*Negative* performs element-wise negative operation on a given input tensor, based on the following mathematical formula: + +\f[ +a_{i} = -a_{i} +\f] + +**Attributes**: *Negative* operation has no attributes. **Inputs** -* **1**: An tensor of type T. **Required.** +* **1**: A tensor of type *T* and arbitrary shape. **Required.** **Outputs** -* **1**: The result of element-wise negative operation. A tensor of type T. +* **1**: The result of element-wise *Negative* operation applied to the input tensor. A tensor of type *T* and the same shape as input tensor. **Types** -* *T*: any numeric type. - -*Negative* does the following with the input tensor *a*: - -\f[ -a_{i} = -a_{i} -\f] - -**Examples** +* *T*: any supported signed numeric type. -*Example 1* +**Example** ```xml @@ -47,4 +45,4 @@ a_{i} = -a_{i} -``` \ No newline at end of file +``` From 8543b42ac0a50877c4816dcae8ae15933b49c506 Mon Sep 17 00:00:00 2001 From: Ivan Tikhonov Date: Fri, 18 Jun 2021 09:50:29 +0300 Subject: [PATCH 130/178] DeformableConvolution v8 specification (#5684) * ModulatedDeformableConvolution spec * add bilinear_interpolation_mode attribute * updated formulas for DeformableConv v1 and v8, applied review remarks * fix doxygen formulas * Update Deformable conv v8 spec, update docs --- docs/doxygen/ie_docs.xml | 2 +- .../convolution/DeformableConvolution_1.md | 20 +++ .../convolution/DeformableConvolution_8.md | 168 ++++++++++++++++++ docs/ops/opset8.md | 2 +- 4 files changed, 190 insertions(+), 2 deletions(-) create mode 100644 docs/ops/convolution/DeformableConvolution_8.md diff --git a/docs/doxygen/ie_docs.xml b/docs/doxygen/ie_docs.xml index c12cc4d22be918..faabfab9238054 100644 --- a/docs/doxygen/ie_docs.xml +++ b/docs/doxygen/ie_docs.xml @@ -131,7 +131,7 @@ limitations under the License. - + diff --git a/docs/ops/convolution/DeformableConvolution_1.md b/docs/ops/convolution/DeformableConvolution_1.md index 2cba8d84039fe9..612d3c419d4ec2 100644 --- a/docs/ops/convolution/DeformableConvolution_1.md +++ b/docs/ops/convolution/DeformableConvolution_1.md @@ -8,6 +8,26 @@ **Detailed description**: *Deformable Convolution* is similar to regular *Convolution* but its receptive field is deformed because of additional spatial offsets used during input sampling. More thorough explanation can be found in [Deformable Convolutions Demystified](https://towardsdatascience.com/deformable-convolutions-demystified-2a77498699e8) and [Deformable Convolutional Networks](https://arxiv.org/abs/1703.06211). +Output is calculated using the following formula: + + \f[ + + y(p) = \sum_{k = 1}^{K}w_{k}x(p + p_{k} + {\Delta}p_{k}) + + \f] + +Where +* K is a number of sampling locations, e.g. for kernel 3x3 and dilation = 1, K = 9 + +* \f$x(p)\f$ and \f$y(p)\f$ denote the features at location p from the input feature maps x and output feature maps y + +* \f$w_{k}\f$ is the weight for k-th location. + +* \f$p_{k}\f$ is pre-specified offset for the k-th location, e.g. K = 9 and +\f$p_{k} \in \{(-1, -1),(-1, 0), . . . ,(1, 1)\}\f$ + +* \f${\Delta}p_{k}\f$ is the learnable offset for the k-th location. + **Attributes**: * *strides* diff --git a/docs/ops/convolution/DeformableConvolution_8.md b/docs/ops/convolution/DeformableConvolution_8.md new file mode 100644 index 00000000000000..cf59584a5f4104 --- /dev/null +++ b/docs/ops/convolution/DeformableConvolution_8.md @@ -0,0 +1,168 @@ +## DeformableConvolution {#openvino_docs_ops_convolution_DeformableConvolution_8} + +**Versioned name**: *DeformableConvolution-8* + +**Category**: Convolution + +**Short description**: Computes 2D deformable convolution of input and kernel tensors. + +**Detailed description**: *Deformable Convolution* is similar to regular *Convolution* but its receptive field is deformed because of additional spatial offsets used during input sampling. More thorough explanation can be found in [Deformable Convolutions Demystified](https://towardsdatascience.com/deformable-convolutions-demystified-2a77498699e8), [Deformable Convolutional Networks](https://arxiv.org/abs/1703.06211). + +Modification of DeformableConvolution using modulating scalars is also supported. Please refer to [Deformable ConvNets v2: More Deformable, Better Results](https://arxiv.org/pdf/1811.11168.pdf). + +Output is calculated using the following formula: + + \f[ + + y(p) = \sum_{k = 1}^{K}w_{k}x(p + p_{k} + {\Delta}p_{k}) * {\Delta}m_{k} + + \f] +Where +* K is a number of sampling locations, e.g. for kernel 3x3 and dilation = 1, K = 9 + +* \f$x(p)\f$ and \f$y(p)\f$ denote the features at location p from the input feature maps x and output feature maps y + +* \f$w_{k}\f$ is the weight for k-th location. + +* \f$p_{k}\f$ is pre-specified offset for the k-th location, e.g. K = 9 and +\f$p_{k} \in \{(-1, -1),(-1, 0), . . . ,(1, 1)\}\f$ + +* \f${\Delta}p_{k}\f$ is the learnable offset for the k-th location. + +* \f${\Delta}m_{k}\f$ is the modulation scalar from 0 to 1 for the k-th location. + +**Attributes**: + +* *strides* + + * **Description**: *strides* is a distance (in pixels) to slide the filter on the feature map over the `(y,x)` axes. For example, *strides* equal `2,1` means sliding the filter 2 pixel at a time over height dimension and 1 over width dimension. + * **Range of values**: integer values starting from `0` + * **Type**: `int[]` + * **Default value**: None + * **Required**: *yes* + +* *pads_begin* + + * **Description**: *pads_begin* is a number of pixels to add to the beginning along each axis. For example, *pads_begin* equal `1,2` means adding 1 pixel to the top of the input and 2 to the left of the input. + * **Range of values**: integer values starting from `0` + * **Type**: `int[]` + * **Default value**: None + * **Required**: *yes* + * **Note**: the attribute is ignored when *auto_pad* attribute is specified. + +* *pads_end* + + * **Description**: *pads_end* is a number of pixels to add to the ending along each axis. For example, *pads_end* equal `1,2` means adding 1 pixel to the bottom of the input and 2 to the right of the input. + * **Range of values**: integer values starting from `0` + * **Type**: `int[]` + * **Default value**: None + * **Required**: *yes* + * **Note**: the attribute is ignored when *auto_pad* attribute is specified. + +* *dilations* + + * **Description**: *dilations* denotes the distance in width and height between elements (weights) in the filter. For example, *dilation* equal `1,1` means that all the elements in the filter are neighbors, so it is the same as for the usual convolution. *dilation* equal `2,2` means that all the elements in the filter are matched not to adjacent elements in the input matrix, but to those that are adjacent with distance 1. + * **Range of values**: integer value starting from `0` + * **Type**: `int[]` + * **Default value**: None + * **Required**: *yes* + +* *auto_pad* + + * **Description**: *auto_pad* how the padding is calculated. Possible values: + * *explicit* - use explicit padding values from *pads_begin* and *pads_end*. + * *same_upper* - the input is padded to match the output size. In case of odd padding value an extra padding is added at the end. + * *same_lower* - the input is padded to match the output size. In case of odd padding value an extra padding is added at the beginning. + * *valid* - do not use padding. + * **Type**: `string` + * **Default value**: explicit + * **Required**: *no* + * **Note**: *pads_begin* and *pads_end* attributes are ignored when *auto_pad* is specified. + + +* *group* + + * **Description**: *group* is the number of groups which *output* and *input* should be split into. For example, *group* equal to 1 means that all filters are applied to the whole input (usual convolution), *group* equal to 2 means that both *input* and *output* channels are separated into two groups and the *i-th output* group is connected to the *i-th input* group channel. *group* equal to a number of output feature maps implies depth-wise separable convolution. + * **Range of values**: integer value starting from `1` + * **Type**: `int` + * **Default value**: `1` + * **Required**: *no* + +* *deformable_group* + + * **Description**: *deformable_group* is the number of groups in which *offsets* input and *output* should be split into along the channel axis. Apply the deformable convolution using the i-th part of the offsets part on the i-th out. + * **Range of values**: integer value starting from `1` + * **Type**: `int` + * **Default value**: `1` + * **Required**: *no* + +* *bilinear_interpolation_padding* + + * **Description**: *bilinear_interpolation_padding* is the number of pixels outside of the feature map boundary to apply bilinear interpolation. + * **Range of values**: non-negative integer value + * **Type**: `int` + * **Default value**: `0` + * **Required**: *no* + +**Inputs**: + +* **1**: Input tensor of type *T* and rank 4. Layout is `NCYX` (number of batches, number of channels, spatial axes Y and X). **Required.** + +* **2**: Offsets tensor of type *T* and rank 4. Layout is `NCYX` (number of batches, *deformable_group* \* kernel_Y \* kernel_X \* 2, spatial axes Y and X). **Required.** + +* **3**: Kernel tensor of type *T* and rank 4. Layout is `OIYX` (number of output channels, number of input channels, spatial axes Y and X). **Required.** + +* **4**: ModulationScalars tensor of type *T2* and rank 4, the values are within [0, 1]. Layout is `NCYX` (number of batches, *deformable_group* \* kernel_Y \* kernel_X, spatial axes Y and X). If the input is not provided, the values are assumed to be equal to 1. **Optional.** + + +**Outputs**: + +* **1**: Output tensor of type *T* and rank 4. Layout is `NOYX` (number of batches, number of kernel output channels, spatial axes Y and X). + +**Types**: + +* *T*: Any numeric type. +* *T2*: Any supported floating point. + +**Example** + +2D DeformableConvolution (deformable_group=1) +```xml + + + + + 1 + 4 + 224 + 224 + + + 1 + 50 + 220 + 220 + + + 64 + 4 + 5 + 5 + + + 1 + 25 + 220 + 220 + + + + + 1 + 64 + 220 + 220 + + + +``` diff --git a/docs/ops/opset8.md b/docs/ops/opset8.md index 8f43927b5ec360..fc68d6f32e07ea 100644 --- a/docs/ops/opset8.md +++ b/docs/ops/opset8.md @@ -40,7 +40,7 @@ declared in `namespace opset8`. * [Cos](arithmetic/Cos_1.md) * [Cosh](arithmetic/Cosh_1.md) * [CumSum](arithmetic/CumSum_3.md) -* [DeformableConvolution](convolution/DeformableConvolution_1.md) +* [DeformableConvolution](convolution/DeformableConvolution_8.md) * [DeformablePSROIPooling](detection/DeformablePSROIPooling_1.md) * [DepthToSpace](movement/DepthToSpace_1.md) * [DetectionOutput](detection/DetectionOutput_1.md) From 70f9d8564e5aced17ca975e5b543e5f7666b0127 Mon Sep 17 00:00:00 2001 From: Vladimir Gavrilov Date: Fri, 18 Jun 2021 09:54:41 +0300 Subject: [PATCH 131/178] Written reading the operation CTCGreedyDecoder for ONNX (as a custom operation). (#6215) --- model-optimizer/automation/package_BOM.txt | 7 ++++--- .../{tf => }/CTCGreedyDecoderReplacement.py | 0 .../front/{tf => }/CTCLossReplacement.py | 2 +- .../front/onnx/CTCGreedyDecoder_ext.py | 19 +++++++++++++++++++ .../{tf => }/sparse_to_dense_replacer.py | 4 ++-- .../CTCGreedyDecoderReplacement_test.py | 2 +- .../front/{tf => }/CTCLossReplacement_test.py | 2 +- .../{tf => }/sparse_to_dense_replacer_test.py | 2 +- 8 files changed, 29 insertions(+), 9 deletions(-) rename model-optimizer/extensions/front/{tf => }/CTCGreedyDecoderReplacement.py (100%) rename model-optimizer/extensions/front/{tf => }/CTCLossReplacement.py (98%) create mode 100644 model-optimizer/extensions/front/onnx/CTCGreedyDecoder_ext.py rename model-optimizer/extensions/front/{tf => }/sparse_to_dense_replacer.py (93%) rename model-optimizer/unit_tests/extensions/front/{tf => }/CTCGreedyDecoderReplacement_test.py (97%) rename model-optimizer/unit_tests/extensions/front/{tf => }/CTCLossReplacement_test.py (99%) rename model-optimizer/unit_tests/extensions/front/{tf => }/sparse_to_dense_replacer_test.py (96%) diff --git a/model-optimizer/automation/package_BOM.txt b/model-optimizer/automation/package_BOM.txt index e7c779543cdda8..668eb02325ff97 100644 --- a/model-optimizer/automation/package_BOM.txt +++ b/model-optimizer/automation/package_BOM.txt @@ -134,6 +134,8 @@ extensions/front/caffe/split_to_identity.py extensions/front/caffe/tanh.py extensions/front/ChangePlaceholderTypes.py extensions/front/create_tensor_nodes.py +extensions/front/CTCGreedyDecoderReplacement.py +extensions/front/CTCLossReplacement.py extensions/front/disable_weights_quantize_value_propagation.py extensions/front/div.py extensions/front/DropoutWithRandomUniformReplacer.py @@ -274,6 +276,7 @@ extensions/front/onnx/constant_of_shape_ext.py extensions/front/onnx/constant_of_shape_to_broadcast.py extensions/front/onnx/conv_ext.py extensions/front/onnx/crop_ext.py +extensions/front/onnx/CTCGreedyDecoder_ext.py extensions/front/onnx/cumsum_ext.py extensions/front/onnx/deformable_conv_ext.py extensions/front/onnx/depth_to_space_ext.py @@ -370,6 +373,7 @@ extensions/front/SizeReplacer.py extensions/front/softmax.py extensions/front/Softplus_fusion.py extensions/front/softsign_replacer.py +extensions/front/sparse_to_dense_replacer.py extensions/front/split_normalizer.py extensions/front/SqueezeNormalize.py extensions/front/sub.py @@ -401,9 +405,7 @@ extensions/front/tf/CorrectRollAxes.py extensions/front/tf/crop_and_resize_ext.py extensions/front/tf/CropAndResizeReplacement.py extensions/front/tf/CTCGreedyDecoder_ext.py -extensions/front/tf/CTCGreedyDecoderReplacement.py extensions/front/tf/CTCLoss_ext.py -extensions/front/tf/CTCLossReplacement.py extensions/front/tf/cumsum_ext.py extensions/front/tf/deconv_ext.py extensions/front/tf/depth_to_space.py @@ -497,7 +499,6 @@ extensions/front/tf/sparse_fill_empty_rows_ext.py extensions/front/tf/sparse_segment_mean_ext.py extensions/front/tf/sparse_segment_sqrtn_ext.py extensions/front/tf/sparse_segment_sum_ext.py -extensions/front/tf/sparse_to_dense_replacer.py extensions/front/tf/split_ext.py extensions/front/tf/ssd_support.json extensions/front/tf/ssd_support_api_v1.14.json diff --git a/model-optimizer/extensions/front/tf/CTCGreedyDecoderReplacement.py b/model-optimizer/extensions/front/CTCGreedyDecoderReplacement.py similarity index 100% rename from model-optimizer/extensions/front/tf/CTCGreedyDecoderReplacement.py rename to model-optimizer/extensions/front/CTCGreedyDecoderReplacement.py diff --git a/model-optimizer/extensions/front/tf/CTCLossReplacement.py b/model-optimizer/extensions/front/CTCLossReplacement.py similarity index 98% rename from model-optimizer/extensions/front/tf/CTCLossReplacement.py rename to model-optimizer/extensions/front/CTCLossReplacement.py index c47296db98e39e..ea2e6cbd3bc135 100644 --- a/model-optimizer/extensions/front/tf/CTCLossReplacement.py +++ b/model-optimizer/extensions/front/CTCLossReplacement.py @@ -20,7 +20,7 @@ class CTCLossReplacement(FrontReplacementSubgraph): enabled = True def run_before(self): - from extensions.front.tf.CTCGreedyDecoderReplacement import CTCGreedyDecoderReplacement + from extensions.front.CTCGreedyDecoderReplacement import CTCGreedyDecoderReplacement return [CTCGreedyDecoderReplacement] def pattern(self): diff --git a/model-optimizer/extensions/front/onnx/CTCGreedyDecoder_ext.py b/model-optimizer/extensions/front/onnx/CTCGreedyDecoder_ext.py new file mode 100644 index 00000000000000..31e0799876c4c2 --- /dev/null +++ b/model-optimizer/extensions/front/onnx/CTCGreedyDecoder_ext.py @@ -0,0 +1,19 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +from extensions.ops.ctc_greedy_decoder_seq_len import CTCGreedyDecoderSeqLenOp +from mo.front.extractor import FrontExtractorOp +from mo.front.onnx.extractors.utils import onnx_attr + + +class CTCCGreedyDecoderFrontExtractor(FrontExtractorOp): + op = 'CTCGreedyDecoder' + enabled = True + + @classmethod + def extract(cls, node): + attrs = { + 'merge_repeated': bool(onnx_attr(node, 'merge_repeated', 'i', default=1)), + } + CTCGreedyDecoderSeqLenOp.update_node_stat(node, attrs) + return cls.enabled diff --git a/model-optimizer/extensions/front/tf/sparse_to_dense_replacer.py b/model-optimizer/extensions/front/sparse_to_dense_replacer.py similarity index 93% rename from model-optimizer/extensions/front/tf/sparse_to_dense_replacer.py rename to model-optimizer/extensions/front/sparse_to_dense_replacer.py index 1440b150696a94..f285192a5a009c 100644 --- a/model-optimizer/extensions/front/tf/sparse_to_dense_replacer.py +++ b/model-optimizer/extensions/front/sparse_to_dense_replacer.py @@ -21,8 +21,8 @@ class SparseToDenseReplacer(FrontReplacementOp): enabled = True def run_after(self): - from extensions.front.tf.CTCGreedyDecoderReplacement import CTCGreedyDecoderReplacement - from extensions.front.tf.CTCLossReplacement import CTCLossReplacement + from extensions.front.CTCGreedyDecoderReplacement import CTCGreedyDecoderReplacement + from extensions.front.CTCLossReplacement import CTCLossReplacement return [CTCGreedyDecoderReplacement, CTCLossReplacement] def replace_op(self, graph: Graph, node: Node): diff --git a/model-optimizer/unit_tests/extensions/front/tf/CTCGreedyDecoderReplacement_test.py b/model-optimizer/unit_tests/extensions/front/CTCGreedyDecoderReplacement_test.py similarity index 97% rename from model-optimizer/unit_tests/extensions/front/tf/CTCGreedyDecoderReplacement_test.py rename to model-optimizer/unit_tests/extensions/front/CTCGreedyDecoderReplacement_test.py index c4d1d467df4160..063d71173e1f7e 100644 --- a/model-optimizer/unit_tests/extensions/front/tf/CTCGreedyDecoderReplacement_test.py +++ b/model-optimizer/unit_tests/extensions/front/CTCGreedyDecoderReplacement_test.py @@ -3,7 +3,7 @@ import unittest -from extensions.front.tf.CTCGreedyDecoderReplacement import CTCGreedyDecoderReplacement, CTCGreedyDecoderWithSparseToDenseShapeReplacement +from extensions.front.CTCGreedyDecoderReplacement import CTCGreedyDecoderReplacement, CTCGreedyDecoderWithSparseToDenseShapeReplacement from mo.front.common.partial_infer.utils import int64_array from mo.utils.ir_engine.compare_graphs import compare_graphs from unit_tests.utils.graph import build_graph, const diff --git a/model-optimizer/unit_tests/extensions/front/tf/CTCLossReplacement_test.py b/model-optimizer/unit_tests/extensions/front/CTCLossReplacement_test.py similarity index 99% rename from model-optimizer/unit_tests/extensions/front/tf/CTCLossReplacement_test.py rename to model-optimizer/unit_tests/extensions/front/CTCLossReplacement_test.py index f173ec15c17367..77ecfc8fa1afd9 100644 --- a/model-optimizer/unit_tests/extensions/front/tf/CTCLossReplacement_test.py +++ b/model-optimizer/unit_tests/extensions/front/CTCLossReplacement_test.py @@ -5,7 +5,7 @@ import unittest from argparse import Namespace -from extensions.front.tf.CTCLossReplacement import CTCLossReplacement +from extensions.front.CTCLossReplacement import CTCLossReplacement from mo.front.common.partial_infer.utils import int64_array from mo.utils.ir_engine.compare_graphs import compare_graphs from unit_tests.utils.graph import build_graph, const diff --git a/model-optimizer/unit_tests/extensions/front/tf/sparse_to_dense_replacer_test.py b/model-optimizer/unit_tests/extensions/front/sparse_to_dense_replacer_test.py similarity index 96% rename from model-optimizer/unit_tests/extensions/front/tf/sparse_to_dense_replacer_test.py rename to model-optimizer/unit_tests/extensions/front/sparse_to_dense_replacer_test.py index 4e624dfd069c1e..588d52198c9c16 100644 --- a/model-optimizer/unit_tests/extensions/front/tf/sparse_to_dense_replacer_test.py +++ b/model-optimizer/unit_tests/extensions/front/sparse_to_dense_replacer_test.py @@ -3,7 +3,7 @@ import unittest -from extensions.front.tf.sparse_to_dense_replacer import SparseToDenseReplacer +from extensions.front.sparse_to_dense_replacer import SparseToDenseReplacer from mo.front.common.partial_infer.utils import int64_array from mo.utils.ir_engine.compare_graphs import compare_graphs from unit_tests.utils.graph import build_graph, const From 1048e6f69b3590f91d83c17c40a426d6b5a16e43 Mon Sep 17 00:00:00 2001 From: Krzysztof Bruniecki Date: Fri, 18 Jun 2021 11:42:18 +0200 Subject: [PATCH 132/178] [GNA] Introduce an option to invoke the QoS feature (#5827) * [GNA] [WIP] Introduce an option to invoke the QoS feature 56759 * Apply remaining revew (typos) for PR 5741 * Introduce HW_WITH_SW_FBACK * Add unit test for HW_WITH_SW_FBACK * Enable HW_WITH_SW_FBACK in speech_sample cpp * Use perf counters to report number of HW delivered frames to the user (eg speech_sample) * Update speech_sample.hpp based on review * Update gna_config.hpp Describe special perf counter * lint fix * Apply review * Remove special performance counter * Add GNA frequency for 6/151 CPU family/model * Update inference-engine/samples/speech_sample/main.cpp Co-authored-by: Mikhail Ryzhov * Update main.cpp Co-authored-by: Mikhail Ryzhov --- inference-engine/include/gna/gna_config.hpp | 1 + .../samples/speech_sample/main.cpp | 45 +++++++++++-------- .../samples/speech_sample/speech_sample.hpp | 5 +-- .../src/gna_plugin/gna_device.cpp | 8 ++-- .../src/gna_plugin/gna_device.hpp | 6 --- .../src/gna_plugin/gna_plugin_config.cpp | 26 ++++++----- .../convolution_negative.cpp | 26 +++++------ .../tests/unit/gna/gna_plugin_config_test.cpp | 5 +++ 8 files changed, 66 insertions(+), 56 deletions(-) diff --git a/inference-engine/include/gna/gna_config.hpp b/inference-engine/include/gna/gna_config.hpp index 958227696a1c98..3433ab58887f7a 100644 --- a/inference-engine/include/gna/gna_config.hpp +++ b/inference-engine/include/gna/gna_config.hpp @@ -65,6 +65,7 @@ DECLARE_GNA_CONFIG_KEY(DEVICE_MODE); DECLARE_GNA_CONFIG_VALUE(AUTO); DECLARE_GNA_CONFIG_VALUE(HW); +DECLARE_GNA_CONFIG_VALUE(HW_WITH_SW_FBACK); DECLARE_GNA_CONFIG_VALUE(SW); DECLARE_GNA_CONFIG_VALUE(SW_EXACT); DECLARE_GNA_CONFIG_VALUE(SW_FP32); diff --git a/inference-engine/samples/speech_sample/main.cpp b/inference-engine/samples/speech_sample/main.cpp index 2b9131774ad557..57db61a8e9e8cd 100644 --- a/inference-engine/samples/speech_sample/main.cpp +++ b/inference-engine/samples/speech_sample/main.cpp @@ -236,7 +236,8 @@ float getGnaFrequencyMHz() { const uint8_t cannon_lake_model = 102; const uint8_t gemini_lake_model = 122; const uint8_t ice_lake_model = 126; - const uint8_t next_model = 140; + const uint8_t tgl_model = 140; + const uint8_t next_model = 151; native_cpuid(&eax, &ebx, &ecx, &edx); family = (eax >> 8) & 0xF; @@ -254,6 +255,7 @@ float getGnaFrequencyMHz() { switch (model) { case cannon_lake_model: case ice_lake_model: + case tgl_model: case next_model: return 400; case gemini_lake_model: @@ -287,13 +289,14 @@ void printReferenceCompareResults(score_error_t const& totalError, size_t frames /** * @brief Print a report on the performance counts * @param utterancePerfMap reference to a map to store performance counters - * @param callsNum frame index + * @param numberOfFrames number of frames * @param stream output stream * @param fullDeviceName full device name string + * @param numberOfFramesOnHw number of frames delivered to GNA HW * @return none. */ -void printPerformanceCounters(std::map const& utterancePerfMap, size_t callsNum, std::ostream& stream, - std::string fullDeviceName) { +void printPerformanceCounters(std::map const& utterancePerfMap, size_t numberOfFrames, + std::ostream& stream, std::string fullDeviceName, const uint64_t numberOfFramesOnHw) { #if !defined(__arm__) && !defined(_M_ARM) && !defined(__aarch64__) && !defined(_M_ARM64) stream << std::endl << "Performance counts:" << std::endl; stream << std::setw(10) << std::right << "" @@ -305,29 +308,29 @@ void printPerformanceCounters(std::map(it.second.realTime_uSec); - float call_units = current_units / callsNum; - // if GNA HW counters - // get frequency of GNA module - float freq = getGnaFrequencyMHz(); - current_units /= freq * 1000; - call_units /= freq; + float current_units_us = static_cast(it.second.realTime_uSec) / freq; + float call_units_us = current_units_us / numberOfFrames; if (FLAGS_d.find("GNA") != std::string::npos) { stream << std::setw(30) << std::left << counter_name.substr(4, counter_name.size() - 1); } else { stream << std::setw(30) << std::left << counter_name; } - stream << std::setw(16) << std::right << current_units; - stream << std::setw(21) << std::right << call_units; + stream << std::setw(16) << std::right << current_units_us / 1000; + stream << std::setw(21) << std::right << call_units_us; stream << std::endl; } stream << std::endl; std::cout << std::endl; std::cout << "Full device name: " << fullDeviceName << std::endl; std::cout << std::endl; + stream << "Number of frames delivered to GNA HW: " << numberOfFramesOnHw; + stream << "/" << numberOfFrames; + stream << std::endl; #endif } @@ -346,16 +349,20 @@ void getPerformanceCounters(InferenceEngine::InferRequest& request, std::map const& perfCounters, - std::map& totalPerfCounters) { + std::map& totalPerfCounters, uint64_t& totalRunsOnHw) { + auto runOnHw = false; for (const auto& pair : perfCounters) { totalPerfCounters[pair.first].realTime_uSec += pair.second.realTime_uSec; + runOnHw |= pair.second.realTime_uSec > 0; // if realTime is above zero, that means that a primitive was executed on the device } + totalRunsOnHw += runOnHw; } /** @@ -443,6 +450,7 @@ bool ParseAndCheckCommandLine(int argc, char* argv[]) { "GPU", "GNA_AUTO", "GNA_HW", + "GNA_HW_WITH_SW_FBACK", "GNA_SW_EXACT", "GNA_SW", "GNA_SW_FP32", @@ -829,6 +837,7 @@ int main(int argc, char* argv[]) { /** Work with each utterance **/ for (uint32_t utteranceIndex = 0; utteranceIndex < numUtterances; ++utteranceIndex) { std::map utterancePerfMap; + uint64_t totalNumberOfRunsOnHw = 0; std::string uttName; uint32_t numFrames(0), n(0); std::vector numFrameElementsInput; @@ -984,7 +993,7 @@ int main(int argc, char* argv[]) { // retrieve new counters getPerformanceCounters(inferRequest.inferRequest, callPerfMap); // summarize retrieved counters with all previous - sumPerformanceCounters(callPerfMap, utterancePerfMap); + sumPerformanceCounters(callPerfMap, utterancePerfMap, totalNumberOfRunsOnHw); } } // ----------------------------------------------------------------------------------------------------- @@ -1092,7 +1101,7 @@ int main(int argc, char* argv[]) { std::cout << "Average Infer time per frame:\t\t" << totalTime / static_cast(numFrames) << " ms" << std::endl; if (FLAGS_pc) { // print performance results - printPerformanceCounters(utterancePerfMap, frameIndex, std::cout, getFullDeviceName(ie, FLAGS_d)); + printPerformanceCounters(utterancePerfMap, frameIndex, std::cout, getFullDeviceName(ie, FLAGS_d), totalNumberOfRunsOnHw); } if (!FLAGS_r.empty()) { // print statistical score error diff --git a/inference-engine/samples/speech_sample/speech_sample.hpp b/inference-engine/samples/speech_sample/speech_sample.hpp index cafe4db5c61758..66d3b24a4c5c47 100644 --- a/inference-engine/samples/speech_sample/speech_sample.hpp +++ b/inference-engine/samples/speech_sample/speech_sample.hpp @@ -21,10 +21,9 @@ static const char model_message[] = "Required. Path to an .xml file with a train /// @brief message for assigning cnn calculation to device static const char target_device_message[] = "Optional. Specify a target device to infer on. CPU, GPU, MYRIAD, GNA_AUTO, GNA_HW, " - "GNA_SW_FP32, " + "GNA_HW_WITH_SW_FBACK, GNA_SW_FP32, " "GNA_SW_EXACT and HETERO with combination of GNA as the primary device and CPU" - " as a secondary (e.g. HETERO:GNA,CPU) are supported. The list of available devices is shown " - "below. " + " as a secondary (e.g. HETERO:GNA,CPU) are supported. " "The sample will look for a suitable plugin for device specified."; /// @brief message for execution target diff --git a/inference-engine/src/gna_plugin/gna_device.cpp b/inference-engine/src/gna_plugin/gna_device.cpp index cbfc47f57aab0b..85a246ea34f134 100644 --- a/inference-engine/src/gna_plugin/gna_device.cpp +++ b/inference-engine/src/gna_plugin/gna_device.cpp @@ -96,14 +96,12 @@ void GNADeviceHelper::setUpActiveList(const uint32_t requestConfigId, uint32_t l const auto status = Gna2RequestConfigEnableActiveList(requestConfigId, layerIndex, num_active_indices, ptr_active_indices); checkGna2Status(status, "Gna2RequestConfigEnableActiveList"); } -void GNADeviceHelper::propagateSync(const uint32_t requestConfigId, Gna2AccelerationMode gna2AccelerationMode) { - wait(propagate(requestConfigId, gna2AccelerationMode)); -} uint32_t GNADeviceHelper::propagate(const uint32_t requestConfigId, Gna2AccelerationMode gna2AccelerationMode) { std::unique_lock lockGnaCalls{ acrossPluginsSync }; uint32_t reqId{}; - if (gna2AccelerationMode == Gna2AccelerationModeHardware && + if ((gna2AccelerationMode == Gna2AccelerationModeHardware || + gna2AccelerationMode == Gna2AccelerationModeHardwareWithSoftwareFallback) && detectedGnaDevVersion == Gna2DeviceVersionSoftwareEmulation) { gnawarn() << "GNA Device not detected, consider using other mode of acceleration"; } @@ -541,6 +539,8 @@ void GNADeviceHelper::updateGnaPerfCounters() { #if GNA_LIB_VER == 2 instrumentationTotal[0] = instrumentationResults[0]; instrumentationTotal[1] = instrumentationResults[1]; + instrumentationResults[0] = 0; + instrumentationResults[1] = 0; #else nGNAPerfResultsTotal.hw.stall = nGNAPerfResults.hw.stall; nGNAPerfResultsTotal.hw.total = nGNAPerfResults.hw.total; diff --git a/inference-engine/src/gna_plugin/gna_device.hpp b/inference-engine/src/gna_plugin/gna_device.hpp index e032e5532dafc3..cae32c70b1de3e 100644 --- a/inference-engine/src/gna_plugin/gna_device.hpp +++ b/inference-engine/src/gna_plugin/gna_device.hpp @@ -117,18 +117,12 @@ class GNADeviceHelper { uint8_t *alloc(uint32_t size_requested, uint32_t *size_granted); #if GNA_LIB_VER == 1 - void propagateSync(const intel_nnet_type_t *pNeuralNetwork, - const uint32_t *pActiveIndices, - uint32_t nActiveIndices, - intel_gna_proc_t nGNAProcType); - uint32_t propagate(const intel_nnet_type_t *pNeuralNetwork, const uint32_t *pActiveIndices, uint32_t nActiveIndices, intel_gna_proc_t nGNAProcType); #else void setUpActiveList(unsigned req_config_id, uint32_t layerIndex, uint32_t* ptr_active_indices, uint32_t num_active_indices); - void propagateSync(const uint32_t requestConfigId, Gna2AccelerationMode gna2AccelerationMode); uint32_t propagate(const uint32_t requestConfigId, Gna2AccelerationMode gna2AccelerationMode); uint32_t createModel(Gna2Model& gnaModel) const; void releaseModel(const uint32_t model_id); diff --git a/inference-engine/src/gna_plugin/gna_plugin_config.cpp b/inference-engine/src/gna_plugin/gna_plugin_config.cpp index 2dcb05d6ab8a3f..766e7d2d52c609 100644 --- a/inference-engine/src/gna_plugin/gna_plugin_config.cpp +++ b/inference-engine/src/gna_plugin/gna_plugin_config.cpp @@ -23,6 +23,7 @@ static const caseless_unordered_map supported_values = { {GNAConfigParams::GNA_SW_EXACT, GNA_SOFTWARE & GNA_HARDWARE} }; static const std::vector supported_values_on_gna2 = { + GNAConfigParams::GNA_HW_WITH_SW_FBACK, GNAConfigParams::GNA_GEN, GNAConfigParams::GNA_GEN_EXACT, GNAConfigParams::GNA_SSE, @@ -34,18 +35,19 @@ static const std::vector supported_values_on_gna2 = { }; #else static const caseless_unordered_map > supported_values = { - {GNAConfigParams::GNA_AUTO, {Gna2AccelerationModeAuto, false}}, - {GNAConfigParams::GNA_HW, {Gna2AccelerationModeHardware, false}}, - {GNAConfigParams::GNA_SW, {Gna2AccelerationModeSoftware, false}}, - {GNAConfigParams::GNA_SW_EXACT, {Gna2AccelerationModeSoftware, true}}, - {GNAConfigParams::GNA_GEN, {Gna2AccelerationModeGeneric, false}}, - {GNAConfigParams::GNA_GEN_EXACT, {Gna2AccelerationModeGeneric, true}}, - {GNAConfigParams::GNA_SSE, {Gna2AccelerationModeSse4x2, false}}, - {GNAConfigParams::GNA_SSE_EXACT, {Gna2AccelerationModeSse4x2, true}}, - {GNAConfigParams::GNA_AVX1, {Gna2AccelerationModeAvx1, false}}, - {GNAConfigParams::GNA_AVX1_EXACT, {Gna2AccelerationModeAvx1, true}}, - {GNAConfigParams::GNA_AVX2, {Gna2AccelerationModeAvx2, false}}, - {GNAConfigParams::GNA_AVX2_EXACT, {Gna2AccelerationModeAvx2, true}}, + {GNAConfigParams::GNA_AUTO, {Gna2AccelerationModeAuto, false}}, + {GNAConfigParams::GNA_HW, {Gna2AccelerationModeHardware, false}}, + {GNAConfigParams::GNA_HW_WITH_SW_FBACK, {Gna2AccelerationModeHardwareWithSoftwareFallback, false}}, + {GNAConfigParams::GNA_SW, {Gna2AccelerationModeSoftware, false}}, + {GNAConfigParams::GNA_SW_EXACT, {Gna2AccelerationModeSoftware, true}}, + {GNAConfigParams::GNA_GEN, {Gna2AccelerationModeGeneric, false}}, + {GNAConfigParams::GNA_GEN_EXACT, {Gna2AccelerationModeGeneric, true}}, + {GNAConfigParams::GNA_SSE, {Gna2AccelerationModeSse4x2, false}}, + {GNAConfigParams::GNA_SSE_EXACT, {Gna2AccelerationModeSse4x2, true}}, + {GNAConfigParams::GNA_AVX1, {Gna2AccelerationModeAvx1, false}}, + {GNAConfigParams::GNA_AVX1_EXACT, {Gna2AccelerationModeAvx1, true}}, + {GNAConfigParams::GNA_AVX2, {Gna2AccelerationModeAvx2, false}}, + {GNAConfigParams::GNA_AVX2_EXACT, {Gna2AccelerationModeAvx2, true}}, }; #endif diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/convolution_negative.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/convolution_negative.cpp index e25236aafabf7e..aa4975e602facd 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/convolution_negative.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/convolution_negative.cpp @@ -24,7 +24,7 @@ const std::vector> kernels2D = { {3, 3}, }; -const std::vector> InvalidKernels2D = { +const std::vector> kernels2DInvalid = { {1, 4}, {2, 3}, {3, 2}, @@ -50,8 +50,8 @@ const std::vector> dilations2D = { {1, 1}, }; const std::vector> dilations2DInvalid = { {2, 2}, }; -const std::vector numOutCannels2D = { 32 }; -const std::vector numOutCannels2DInvalid = { 1, 7, 9, 400 }; +const std::vector numOutChannels2D = { 32 }; +const std::vector numOutChannels2DInvalid = { 1, 7, 9, 400 }; const std::vector> input2DNCHWFine = { { 1, 8, 20, 16 } }; @@ -68,16 +68,16 @@ const auto conv2DParametersFine = ::testing::Combine( ::testing::ValuesIn(padBegins2D), ::testing::ValuesIn(padEnds2D), ::testing::ValuesIn(dilations2D), - ::testing::ValuesIn(numOutCannels2D), + ::testing::ValuesIn(numOutChannels2D), ::testing::Values(ngraph::op::PadType::EXPLICIT) ); const auto conv2DParametersInvalidKernel = ::testing::Combine( - ::testing::ValuesIn(InvalidKernels2D), + ::testing::ValuesIn(kernels2DInvalid), ::testing::ValuesIn(strides2D), ::testing::ValuesIn(padBegins2D), ::testing::ValuesIn(padEnds2D), ::testing::ValuesIn(dilations2D), - ::testing::ValuesIn(numOutCannels2D), + ::testing::ValuesIn(numOutChannels2D), ::testing::Values(ngraph::op::PadType::EXPLICIT) ); const auto conv2DParametersInvalidFilterNumber = ::testing::Combine( @@ -86,7 +86,7 @@ const auto conv2DParametersInvalidFilterNumber = ::testing::Combine( ::testing::ValuesIn(padBegins2D), ::testing::ValuesIn(padEnds2D), ::testing::ValuesIn(dilations2D), - ::testing::ValuesIn(numOutCannels2DInvalid), + ::testing::ValuesIn(numOutChannels2DInvalid), ::testing::Values(ngraph::op::PadType::EXPLICIT) ); const auto conv2DParametersInvalidPadding = ::testing::Combine( @@ -95,7 +95,7 @@ const auto conv2DParametersInvalidPadding = ::testing::Combine( ::testing::ValuesIn(padBegins2DInvalid), ::testing::ValuesIn(padEnds2DInvalid), ::testing::ValuesIn(dilations2D), - ::testing::ValuesIn(numOutCannels2D), + ::testing::ValuesIn(numOutChannels2D), ::testing::Values(ngraph::op::PadType::EXPLICIT) ); const auto conv2DParametersInvalidStride = ::testing::Combine( @@ -104,7 +104,7 @@ const auto conv2DParametersInvalidStride = ::testing::Combine( ::testing::ValuesIn(padBegins2D), ::testing::ValuesIn(padEnds2D), ::testing::ValuesIn(dilations2D), - ::testing::ValuesIn(numOutCannels2D), + ::testing::ValuesIn(numOutChannels2D), ::testing::Values(ngraph::op::PadType::EXPLICIT) ); const auto conv2DParametersInvalidDilation = ::testing::Combine( @@ -113,7 +113,7 @@ const auto conv2DParametersInvalidDilation = ::testing::Combine( ::testing::ValuesIn(padBegins2D), ::testing::ValuesIn(padEnds2D), ::testing::ValuesIn(dilations2DInvalid), - ::testing::ValuesIn(numOutCannels2D), + ::testing::ValuesIn(numOutChannels2D), ::testing::Values(ngraph::op::PadType::EXPLICIT) ); @@ -142,7 +142,7 @@ class GnaConv2DNegativeTest : public ConvolutionLayerTest, protected GnaLayerTes } }; -#define GNA_NEG_INSTANTIATE(whats_wrong, sufix_params, sufix_input, error_message) \ +#define GNA_NEG_INSTANTIATE(whats_wrong, suffix_params, suffix_input, error_message) \ struct GnaConv2DNegativeTest##whats_wrong : GnaConv2DNegativeTest { \ std::string expectedSubstring() override { \ return error_message; \ @@ -153,13 +153,13 @@ TEST_P(GnaConv2DNegativeTest##whats_wrong, ThrowAsNotSupported) { } \ INSTANTIATE_TEST_CASE_P(smoke_GnaConv2DNegativeTestInvalid##whats_wrong, GnaConv2DNegativeTest##whats_wrong, \ ::testing::Combine( \ - conv2DParameters##sufix_params, \ + conv2DParameters##suffix_params, \ ::testing::ValuesIn(netPrecisions), \ ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), \ ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), \ ::testing::Values(InferenceEngine::Layout::ANY), \ ::testing::Values(InferenceEngine::Layout::ANY), \ - ::testing::ValuesIn(input2DNCHW##sufix_input), \ + ::testing::ValuesIn(input2DNCHW##suffix_input), \ ::testing::Values(CommonTestUtils::DEVICE_GNA)), \ GnaConv2DNegativeTest##whats_wrong::getTestCaseName); diff --git a/inference-engine/tests/unit/gna/gna_plugin_config_test.cpp b/inference-engine/tests/unit/gna/gna_plugin_config_test.cpp index bdfd50ba03700d..7fa12a428251ff 100644 --- a/inference-engine/tests/unit/gna/gna_plugin_config_test.cpp +++ b/inference-engine/tests/unit/gna/gna_plugin_config_test.cpp @@ -107,6 +107,11 @@ TEST_F(GNAPluginConfigTest, GnaConfigDeviceModeTest) { #else EXPECT_EQ(config.pluginGna2AccMode, Gna2AccelerationModeHardware); EXPECT_EQ(config.swExactMode, false); +#endif +#if GNA_LIB_VER == 2 + SetAndCompare(GNA_CONFIG_KEY(DEVICE_MODE), GNAConfigParams::GNA_HW_WITH_SW_FBACK); + EXPECT_EQ(config.pluginGna2AccMode, Gna2AccelerationModeHardwareWithSoftwareFallback); + EXPECT_EQ(config.swExactMode, false); #endif SetAndCompare(GNA_CONFIG_KEY(DEVICE_MODE), GNAConfigParams::GNA_SW); #if GNA_LIB_VER == 1 From b6e62e7a0b1ddb8d598a2edfc6d97cad59e2eefe Mon Sep 17 00:00:00 2001 From: Rafal Blaczkowski Date: Fri, 18 Jun 2021 11:58:42 +0200 Subject: [PATCH 133/178] Update Openvino ONNX CI Azure check (#6227) * Update * update models * update models * Fix models path --- .ci/azure/linux_ngraph_onnx.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.ci/azure/linux_ngraph_onnx.yml b/.ci/azure/linux_ngraph_onnx.yml index e11e72e102d33f..1e13710f2c2b1e 100644 --- a/.ci/azure/linux_ngraph_onnx.yml +++ b/.ci/azure/linux_ngraph_onnx.yml @@ -17,6 +17,8 @@ jobs: WORK_DIR: $(Pipeline.Workspace)/_w MODELS_DIR: /mount/cinfsshare/onnxtestdata TMP_DIR: /mnt/tmp + ONNX_MODEL_ZOO_SHA: "d58213534f2a4d1c4b19ba62b3bb5f544353256e" + steps: - script: | @@ -55,7 +57,7 @@ jobs: - script: docker build --tag=openvino-onnx-ci-image --file=.ci/openvino-onnx/Dockerfile . displayName: 'Docker build' - - script: ngraph/python/tests/test_onnx/model_zoo_preprocess.sh -d $(TMP_DIR) -o + - script: ngraph/python/tests/test_onnx/model_zoo_preprocess.sh -d $(TMP_DIR) -o -s "$(ONNX_MODEL_ZOO_SHA)" displayName: 'Get models' - script: | @@ -77,6 +79,6 @@ jobs: displayName: 'Create swap' - script: | - docker run --name openvino-onnx-ci-container --volume $(TMP_DIR)/model_zoo:/root/.onnx/model_zoo --volume $(MODELS_DIR)/msft:/root/.onnx/model_zoo/MSFT openvino-onnx-ci-image + docker run --name openvino-onnx-ci-container --volume $(TMP_DIR)/model_zoo/onnx_model_zoo_$(ONNX_MODEL_ZOO_SHA):/root/.onnx/model_zoo/onnx_model_zoo --volume $(MODELS_DIR)/msft:/root/.onnx/model_zoo/MSFT openvino-onnx-ci-image /bin/bash -c "tox && tox -e zoo_models" displayName: 'Docker run' From 63211d548f5ed960e269ba6fa9e0015885cc96ba Mon Sep 17 00:00:00 2001 From: "Gladilov, Gleb" Date: Fri, 18 Jun 2021 13:34:30 +0300 Subject: [PATCH 134/178] Fixes skip tests config after tests renaming (#6231) Signed-off-by: Gladilov, Gleb --- docs/template_plugin/tests/functional/skip_tests_config.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/template_plugin/tests/functional/skip_tests_config.cpp b/docs/template_plugin/tests/functional/skip_tests_config.cpp index 252ed7c9a712c9..8d100118a9d248 100644 --- a/docs/template_plugin/tests/functional/skip_tests_config.cpp +++ b/docs/template_plugin/tests/functional/skip_tests_config.cpp @@ -10,10 +10,10 @@ std::vector disabledTestPatterns() { return { ".*ExclusiveAsyncRequests.*", - ".*reusableCPUStreamsExecutor.*", + ".*ReusableCPUStreamsExecutor.*", R"(.*SplitLayerTest.*numSplits\=30.*)", // CVS-51758 ".*PreprocessConversionTest.*oLT=NHWC.*", ".*PreprocessDynamicallyInSetBlobTest.*oPRC=0.*oLT=1.*", }; -} \ No newline at end of file +} From b5f2383c1c7115d1209289e722066e2807b1f889 Mon Sep 17 00:00:00 2001 From: Gleb Kazantaev Date: Fri, 18 Jun 2021 17:27:12 +0300 Subject: [PATCH 135/178] Add std::shared_ptr attribute comparison support (#6222) * Add std::shared_ptr attribute comparision support * Added unit test --- .../transformations/low_latency_test.cpp | 12 ++++++--- .../common_test_utils/ngraph_test_utils.cpp | 4 +++ .../common_test_utils/ngraph_test_utils.hpp | 27 +++++++++++++++++-- .../core/include/ngraph/op/util/variable.hpp | 6 +++++ ngraph/test/type_prop/assign.cpp | 23 ++++++++++++++++ 5 files changed, 67 insertions(+), 5 deletions(-) diff --git a/inference-engine/tests/functional/inference_engine/transformations/low_latency_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/low_latency_test.cpp index 2d1594d38411db..6e151972e47cdb 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/low_latency_test.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/low_latency_test.cpp @@ -25,12 +25,18 @@ TEST(TransformationTests, LowLatencyLSTM) { std::shared_ptr f(nullptr), f_ref(nullptr); { auto X = std::make_shared(element::f32, Shape{1, 1, 16}); + X->set_friendly_name("X"); auto H_init = std::make_shared(element::f32, Shape{1, 128}); + H_init->set_friendly_name("H_init"); auto C_init = std::make_shared(element::f32, Shape{1, 128}); + C_init->set_friendly_name("C_init"); auto Xi = std::make_shared(element::f32, Shape{1, 1, 16}); + Xi->set_friendly_name("Xi"); auto H_t = std::make_shared(element::f32, Shape{1, 128}); + H_t->set_friendly_name("H_t"); auto C_t = std::make_shared(element::f32, Shape{1, 128}); + C_t->set_friendly_name("C_t"); // Body auto axis = ngraph::opset6::Constant::create(ngraph::element::i64, ngraph::Shape{}, {0}); @@ -79,8 +85,8 @@ TEST(TransformationTests, LowLatencyLSTM) { auto H_t = std::make_shared(element::f32, Shape{1, 128}); auto C_t = std::make_shared(element::f32, Shape{1, 128}); - const std::string variable_name_H("LSTMTensorIterator/variable0"); - const std::string variable_name_C("LSTMTensorIterator/variable1"); + const std::string variable_name_H("LSTMTensorIterator/H_t/variable_2"); + const std::string variable_name_C("LSTMTensorIterator/C_t/variable_0"); auto variable_H = std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, variable_name_H}); auto variable_C = std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, variable_name_C}); auto read_value_H = std::make_shared(H_t, variable_H); @@ -107,7 +113,7 @@ TEST(TransformationTests, LowLatencyLSTM) { assign_H->add_control_dependency(read_value_H); assign_C->add_control_dependency(read_value_C); } - auto res = compare_functions(f, f_ref); + auto res = compare_functions(f, f_ref, true, false, false, true, true); ASSERT_TRUE(res.first) << res.second; } diff --git a/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.cpp b/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.cpp index eee6e9613c8ce3..3d0ec47531d326 100644 --- a/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.cpp +++ b/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.cpp @@ -803,6 +803,8 @@ void ReadAndStoreAttributes::on_adapter(const std::string& name, ngraph::ValueAc insert(name, storage::MemoryChunk{storage::MemoryChunk::Data(beg, end)}); } else if (auto framework_node_attr = ngraph::as_type>(&adapter)) { insert(name, framework_node_attr->get()); + } else if (auto variable_ptr = ngraph::as_type>>(&adapter)) { + insert(name, variable_ptr->get()); } else { m_read_result += "store attr [ ERR ]: " + name + " [drop `void` comparison which is '" + adapter.get_type_info().name + @@ -882,6 +884,8 @@ void ReadAndCompareAttributes::verify_others(const std::string &name, ngraph::Va verify_mem_buf(name, a->get()); } else if (auto attrs = ngraph::as_type>(&adapter)) { verify(name, attrs->get()); + } else if (auto variable_ptr = ngraph::as_type>>(&adapter)) { + verify(name, variable_ptr->get()); } else { m_cmp_result += "compare attr [ ERR ]: " + name + " [drop `void` comparison which is '" + adapter.get_type_info().name + diff --git a/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.hpp b/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.hpp index 5e7220b7872f0f..ab636060af1264 100644 --- a/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.hpp +++ b/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.hpp @@ -322,7 +322,8 @@ class Storage : private AttributeStorage, private AttributeStorage>, private AttributeStorage, private AttributeStorage, - private AttributeStorage { + private AttributeStorage, + private AttributeStorage> { public: template const AttributeStorage& storage() const { @@ -361,7 +362,8 @@ class Storage : private AttributeStorage, storage>().get_attributes_number() + storage().get_attributes_number() + storage().get_attributes_number() + - storage().get_attributes_number(); + storage().get_attributes_number() + + storage>().get_attributes_number(); } }; @@ -562,6 +564,14 @@ struct Equal { } }; +template <> +struct Equal> { + static bool equal_value( + const std::shared_ptr& lhs, const std::shared_ptr& rhs) { + return lhs->get_info() == rhs->get_info(); + } +}; + template <> struct Equal { static constexpr uint8_t BITS_IN_BYTE_COUNT = 8; @@ -705,6 +715,19 @@ struct Get { } }; +template <> +struct Get, void> { + static std::string value(const std::shared_ptr& variable) { + std::stringstream oss; + const auto variable_info = variable->get_info(); + oss << "["; + oss << "data_shape=" << variable_info.data_shape << ", "; + oss << "data_type=" << variable_info.data_type << ", "; + oss << "variable_id=" << variable_info.variable_id; + oss << "]"; + return oss.str(); + } +}; } // namespace str diff --git a/ngraph/core/include/ngraph/op/util/variable.hpp b/ngraph/core/include/ngraph/op/util/variable.hpp index 6d0f48dafd40b6..3390de9026e3d2 100644 --- a/ngraph/core/include/ngraph/op/util/variable.hpp +++ b/ngraph/core/include/ngraph/op/util/variable.hpp @@ -14,6 +14,12 @@ namespace ngraph PartialShape data_shape; element::Type data_type; std::string variable_id; + + inline bool operator==(const VariableInfo& other) const + { + return data_shape == other.data_shape && data_type == other.data_type && + variable_id == other.variable_id; + } }; class NGRAPH_API Variable diff --git a/ngraph/test/type_prop/assign.cpp b/ngraph/test/type_prop/assign.cpp index 9f8169ae71f3c2..996231175e3e77 100644 --- a/ngraph/test/type_prop/assign.cpp +++ b/ngraph/test/type_prop/assign.cpp @@ -64,3 +64,26 @@ TEST(type_prop, assign_read_value_new_shape) ASSERT_EQ(variable->get_info().data_type, element::f16); ASSERT_EQ(variable->get_info().data_shape, (PartialShape{3, {4, 5}, 8})); } + +TEST(type_prop, variable_comparison) +{ + auto variable1 = + std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, "ID"}); + + auto variable2 = + std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, "ID"}); + + auto variable3 = + std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, "ID1"}); + + auto variable4 = + std::make_shared(VariableInfo{PartialShape::dynamic(), element::f32, "ID"}); + + auto variable5 = + std::make_shared(VariableInfo{Shape{1}, element::dynamic, "ID"}); + + ASSERT_TRUE(variable1->get_info() == variable2->get_info()); + ASSERT_FALSE(variable1->get_info() == variable3->get_info()); + ASSERT_FALSE(variable1->get_info() == variable4->get_info()); + ASSERT_FALSE(variable1->get_info() == variable5->get_info()); +} \ No newline at end of file From 020af3ddddc371e12bc591b81157a85cd62d6dd9 Mon Sep 17 00:00:00 2001 From: Alexander Shchepetov Date: Fri, 18 Jun 2021 17:36:08 +0300 Subject: [PATCH 136/178] add TF Roll op test (#6228) --- .../tensorflow_tests/test_tf_Roll.py | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_Roll.py diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Roll.py b/tests/layer_tests/tensorflow_tests/test_tf_Roll.py new file mode 100644 index 00000000000000..340adcc1eca60a --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_Roll.py @@ -0,0 +1,42 @@ +import pytest +import tensorflow as tf +from common.tf_layer_test_class import CommonTFLayerTest + + +class TestTFRoll(CommonTFLayerTest): + def create_tf_roll_net(self, shift, axis, x_shape, input_type, ir_version): + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + tf_x_shape = x_shape.copy() + # reshaping + if len(tf_x_shape) >= 3: + tf_x_shape.append(tf_x_shape.pop(1)) + + x = tf.compat.v1.placeholder(input_type, tf_x_shape, 'Input') + roll = tf.roll(x, shift=shift, axis=axis) + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # TODO: add reference IR net. Now it is omitted and tests only inference result that is more important + ref_net = None + + return tf_net, ref_net + + test_data = [dict(shift=[1], axis=[-1], x_shape=[4, 3], input_type=tf.float32), + dict(shift=[1, 5, -7], axis=[0, 1, 1], x_shape=[2, 3, 5], input_type=tf.float16), + dict(shift=[11, -8], axis=[-1, -2], x_shape=[3, 4, 3, 1], input_type=tf.int32), + dict(shift=[7, -2, 5], axis=[0, -1, -1], x_shape=[5, 2, 3, 7], input_type=tf.int64), + dict(shift=[3, 7], axis=[0, 1], x_shape=[2, 4, 3, 5, 4], input_type=tf.half), + pytest.param(dict(shift=[1, -2], axis=[0, 1], x_shape=[2, 4, 3, 5], input_type=tf.float32), + marks=pytest.mark.precommit)] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_tf_roll(self, params, ie_device, precision, ir_version, temp_dir): + if ie_device == 'GPU': + pytest.skip("Roll is not supported on GPU") + self._test(*self.create_tf_roll_net(**params, ir_version=ir_version), ie_device, precision, + temp_dir=temp_dir, ir_version=ir_version, **params) From ac01777166c03948b9b378655ad22bd37dfd8850 Mon Sep 17 00:00:00 2001 From: cecilia peng Date: Fri, 18 Jun 2021 22:39:23 +0800 Subject: [PATCH 137/178] MatrixNMS-8 spec. (#5948) * Specification of a new operator called MatrixNMS. This Op functionally equivalent to NonMaxSuppression-5, with an non max suppression algorithm called matrix_nms, and perform more post-processing phases, and lay out the detection outputs in the way of PaddlePaddle detection. * Update docs/ops/sort/MatrixNMS_8.md Co-authored-by: Anastasiya Ageeva * Update docs/ops/sort/MatrixNMS_8.md Co-authored-by: Anastasiya Ageeva * Update docs/ops/sort/MatrixNMS_8.md Co-authored-by: Anastasiya Ageeva * Update docs/ops/sort/MatrixNMS_8.md Co-authored-by: Anastasiya Ageeva * Update docs/ops/sort/MatrixNMS_8.md Co-authored-by: Anastasiya Ageeva * Update docs/ops/sort/MatrixNMS_8.md Co-authored-by: Anastasiya Ageeva * Update docs/ops/sort/MatrixNMS_8.md Co-authored-by: Anastasiya Ageeva * Update docs/ops/sort/MatrixNMS_8.md Co-authored-by: Anastasiya Ageeva * Update MatrixNMS_8.md * Update MatrixNMS_8.md Co-authored-by: Anastasiya Ageeva --- docs/doxygen/ie_docs.xml | 1 + docs/ops/sort/MatrixNMS_8.md | 168 +++++++++++++++++++++++++++++++++++ 2 files changed, 169 insertions(+) create mode 100644 docs/ops/sort/MatrixNMS_8.md diff --git a/docs/doxygen/ie_docs.xml b/docs/doxygen/ie_docs.xml index faabfab9238054..120492baef0c2d 100644 --- a/docs/doxygen/ie_docs.xml +++ b/docs/doxygen/ie_docs.xml @@ -189,6 +189,7 @@ limitations under the License. + diff --git a/docs/ops/sort/MatrixNMS_8.md b/docs/ops/sort/MatrixNMS_8.md new file mode 100644 index 00000000000000..d3a422307223c9 --- /dev/null +++ b/docs/ops/sort/MatrixNMS_8.md @@ -0,0 +1,168 @@ +## MatrixNonMaxSuppression {#openvino_docs_ops_sort_MatrixNms_8} + +**Versioned name**: *MatrixNonMaxSuppression-8* + +**Category**: *Sorting and maximization* + +**Short description**: *MatrixNonMaxSuppression* performs matrix non-maximum suppression (NMS) of the boxes with predicted scores. + +**Detailed description**: The operation performs the following: + +1. Selects candidate bounding boxes with scores higher than `score_threshold`. +2. For each class, selects at most `nms_top_k` candidate boxes. +3. Decays scores of the candidate boxes according to the Matrix NMS algorithm [Wang et al](https://arxiv.org/abs/2003.10152.pdf). This algorithm is applied independently to each class and each batch element. Boxes of `background_class` are skipped and thus eliminated during the process. +4. Selects boxes with the decayed scores higher than `post_threshold`, and selects at most `keep_top_k` scoring candidate boxes per batch element. + +The Matrix NMS algorithm is described below: +1. Sort descending the candidate boxes by score, and compute `n*n` pairwise IOU (IntersectionOverUnion) matrix `X` for the top `n` boxes. Suppose `n` is the number of candidate boxes. +2. Set the lower triangle and diagonal of `X` to 0. Therefore get the upper triangular matrix `X`. +3. Take the column-wise max of `X` to compute a vector `K` of maximum IOU for each candidate box. +4. Repeat element value of `K` along axis 1. Suppose this gets a matrix `X_cmax`. +5. Compute the decay factor: `decay_factor = exp((X_cmax**2 - X**2) * gaussian_sigma)` if `decay_function` is `guassian`, else `decay_factor = (1 - X) / (1 - X_cmax)`. +6. Take the column-wise min of `decay_factor`, and element-wise multiply with scores to decay them. + +**Attributes**: + +* *sort_result* + + * **Description**: *sort_result* specifies the order of output elements. + * **Range of values**: `class`, `score`, `none` + * *class* - sort selected boxes by class id (ascending). + * *score* - sort selected boxes by score (descending). + * *none* - do not guarantee the order. + * **Type**: `string` + * **Default value**: `none` + * **Required**: *No* + +* *sort_result_across_batch* + + * **Description**: *sort_result_across_batch* is a flag that specifies whenever it is necessary to sort selected boxes across batches or not. + * **Range of values**: true or false + * *true* - sort selected boxes across batches. + * *false* - do not sort selected boxes across batches (boxes are sorted per batch element). + * **Type**: boolean + * **Default value**: false + * **Required**: *No* + +* *output_type* + + * **Description**: the tensor type of outputs `selected_indices` and `valid_outputs`. + * **Range of values**: `i64` or `i32` + * **Type**: `string` + * **Default value**: `i64` + * **Required**: *No* + +* *score_threshold* + + * **Description**: minimum score to consider box for the processing. + * **Range of values**: a floating-point number + * **Type**: `float` + * **Default value**: `0` + * **Required**: *No* + +* *nms_top_k* + + * **Description**: maximum number of boxes to be selected per class. + * **Range of values**: an integer + * **Type**: `int` + * **Default value**: `-1` meaning to keep all boxes + * **Required**: *No* + +* *keep_top_k* + + * **Description**: maximum number of boxes to be selected per batch element. + * **Range of values**: an integer + * **Type**: `int` + * **Default value**: `-1` meaning to keep all boxes + * **Required**: *No* + +* *background_class* + + * **Description**: the background class id. + * **Range of values**: an integer + * **Type**: `int` + * **Default value**: `-1` meaning to keep all classes + * **Required**: *No* + +* *decay_function* + + * **Description**: decay function used to decay scores. + * **Range of values**: `gaussian`, `linear` + * **Type**: `string` + * **Default value**: `linear` + * **Required**: *No* + +* *gaussian_sigma* + + * **Description**: gaussian_sigma parameter for gaussian decay_function. + * **Range of values**: a floating-point number + * **Type**: `float` + * **Default value**: `2.0` + * **Required**: *No* + +* *post_threshold* + + * **Description**: threshold to filter out boxes with low confidence score after decaying. + * **Range of values**: a floating-point number + * **Type**: `float` + * **Default value**: `0` + * **Required**: *No* + +**Inputs**: + +* **1**: `boxes` - tensor of type *T* and shape `[num_batches, num_boxes, 4]` with box coordinates. The box cooridnates are layout as `[xmin, ymin, xmax, ymax]`. **Required.** + +* **2**: `scores` - tensor of type *T* and shape `[num_batches, num_classes, num_boxes]` with box scores. **Required.** + +**Outputs**: + +* **1**: `selected_outputs` - tensor of type *T_THRESHOLDS* and shape `[number of selected boxes, 6]` containing the selected boxes with score and class as tuples `[class_id, box_score, xmin, ymin, xmax, ymax]`. + +* **2**: `selected_indices` - tensor of type *T_IND* and shape `[number of selected boxes, 1]` the selected indices in the flattened input `boxes`, which are absolute values cross batches. Therefore possible valid values are in the range `[0, num_batches * num_boxes - 1]`. + +* **3**: `selected_num` - 1D tensor of type *T_IND* and shape `[num_batches]` representing the number of selected boxes for each batch element. + +When there is no box selected, `selected_num` is filled with `0`. `selected_outputs` is an empty tensor of shape `[0, 6]`, and `selected_indices` is an empty tensor of shape `[0, 1]`. + +**Types** + +* *T*: floating point type. + +* *T_MAX_BOXES*: integer type. + +* *T_THRESHOLDS*: floating point type. + +* *T_IND*: `int64` or `int32`. + +**Example** + +```xml + + + + + 3 + 100 + 4 + + + 3 + 5 + 100 + + + + + -1 + 6 + + + -1 + 1 + + + 3 + + + +``` From 72c8743a7128488aab77e7c9c662b3f5aa4e1381 Mon Sep 17 00:00:00 2001 From: Gleb Kazantaev Date: Fri, 18 Jun 2021 17:59:43 +0300 Subject: [PATCH 138/178] Add NGRAPH_UNIT_TEST_ENABLE cmake key to control backends build in unit-test target (#6232) --- ngraph/CMakeLists.txt | 2 ++ ngraph/test/CMakeLists.txt | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ngraph/CMakeLists.txt b/ngraph/CMakeLists.txt index a05ca3b15c624d..55e218daa2c924 100644 --- a/ngraph/CMakeLists.txt +++ b/ngraph/CMakeLists.txt @@ -84,6 +84,7 @@ if (APPLE) endif() option(NGRAPH_UNIT_TEST_ENABLE "Control the building of unit tests" ON) +option(NGRAPH_UNIT_TEST_BACKENDS_ENABLE "Control the building of unit tests using backends" ON) option(NGRAPH_INTERPRETER_ENABLE "Control the building of the INTERPRETER backend" ON) option(NGRAPH_DEBUG_ENABLE "Enable output for NGRAPH_DEBUG statements" OFF) option(NGRAPH_ONNX_IMPORT_ENABLE "Enable ONNX importer" OFF) @@ -117,6 +118,7 @@ message(STATUS "NGRAPH_THREAD_SANITIZER_ENABLE: ${NGRAPH_THREAD_SANITIZER_ message(STATUS "NGRAPH_UB_SANITIZER_ENABLE: ${NGRAPH_UB_SANITIZER_ENABLE}") message(STATUS "NGRAPH_USE_PROTOBUF_LITE: ${NGRAPH_USE_PROTOBUF_LITE}") message(STATUS "NGRAPH_UNIT_TEST_ENABLE: ${NGRAPH_UNIT_TEST_ENABLE}") +message(STATUS "NGRAPH_UNIT_TEST_BACKENDS_ENABLE: ${NGRAPH_UNIT_TEST_BACKENDS_ENABLE}") # Setup CMAKE_ARGS to be forwarded to External Projects set(NGRAPH_FORWARD_CMAKE_ARGS diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index fcb4f013775139..278121669a83c1 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -304,7 +304,7 @@ set(SRC set_source_files_properties(includes.cpp PROPERTIES COMPILE_DEFINITIONS NGRAPH_INCLUDES="${PROJECT_SOURCE_DIR}/src/ngraph") -if (ENABLE_MKL_DNN) +if (ENABLE_MKL_DNN AND NGRAPH_UNIT_TEST_BACKENDS_ENABLE) message(STATUS "NGRAPH_TESTS: IE:CPU enabled") set(ACTIVE_BACKEND_LIST ${ACTIVE_BACKEND_LIST} "IE:CPU") if (ENABLE_STRICT_DEPENDENCIES) @@ -314,7 +314,7 @@ if (ENABLE_MKL_DNN) endif() endif() -if (ENABLE_CLDNN) +if (ENABLE_CLDNN AND NGRAPH_UNIT_TEST_BACKENDS_ENABLE) message(STATUS "NGRAPH_TESTS: IE:GPU enabled") set(ACTIVE_BACKEND_LIST ${ACTIVE_BACKEND_LIST} "IE:GPU") if (ENABLE_STRICT_DEPENDENCIES) @@ -324,7 +324,7 @@ if (ENABLE_CLDNN) endif() endif() -if (NGRAPH_INTERPRETER_ENABLE) +if (NGRAPH_INTERPRETER_ENABLE AND NGRAPH_UNIT_TEST_BACKENDS_ENABLE) list(APPEND SRC builder.cpp backend_api.cpp) From 7e664119281eb60d24dd30ea39a8b163404ab5db Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sun, 20 Jun 2021 13:01:32 +0300 Subject: [PATCH 139/178] Remove deprecated api (#6256) * Revert "Fixed creation of C++ wrappers from old API (#5805)" This reverts commit ffe03b6ed35a6cf5912282ee0dc08dfc59555acf. * Removed deprecated API * Fixes 2 --- .../include/cpp/ie_executable_network.hpp | 15 -- .../include/cpp/ie_infer_request.hpp | 16 -- .../include/cpp/ie_memory_state.hpp | 48 +--- .../include/ie_iexecutable_network.hpp | 17 -- .../include/ie_iinfer_request.hpp | 16 -- inference-engine/include/ie_imemory_state.hpp | 95 -------- inference-engine/include/ie_parameter.hpp | 42 ---- inference-engine/include/ie_unicode.hpp | 69 ------ .../cpp/ie_executable_network.cpp | 103 +-------- .../cpp/ie_executable_network_base.hpp | 20 -- .../cpp/ie_infer_async_request_base.hpp | 19 +- .../inference_engine/cpp/ie_infer_request.cpp | 205 +----------------- .../cpp/ie_variable_state.cpp | 39 ---- .../cpp/ie_variable_state_base.hpp | 59 ----- .../interface/ie_ivariable_state_internal.cpp | 3 - .../src/inference_engine/ie_parameter.cpp | 45 ---- .../interface/ie_ivariable_state_internal.hpp | 8 - .../async_infer_request_test.cpp | 14 -- .../inference_engine/executable_network.cpp | 35 +-- .../inference_engine/variable_state.cpp | 20 -- ...ntization_during_memory_requantization.cpp | 4 +- .../src/subgraph/memory_LSTMCell.cpp | 4 +- .../subgraph/negative_memory_layer_offset.cpp | 2 +- .../ie_test_utils/unit_test_utils/mock.cpp | 1 - .../mocks/mock_ie_ivariable_state.hpp | 25 --- .../mocks/mock_iexecutable_network.hpp | 1 - .../mocks/mock_iinfer_request.hpp | 1 - .../ie_executable_network_test.cpp | 1 - 28 files changed, 30 insertions(+), 897 deletions(-) delete mode 100644 inference-engine/include/ie_imemory_state.hpp delete mode 100644 inference-engine/include/ie_unicode.hpp delete mode 100644 inference-engine/src/inference_engine/cpp/ie_variable_state_base.hpp delete mode 100644 inference-engine/src/inference_engine/ie_parameter.cpp delete mode 100644 inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_ie_ivariable_state.hpp diff --git a/inference-engine/include/cpp/ie_executable_network.hpp b/inference-engine/include/cpp/ie_executable_network.hpp index eb1824f9da041e..81d5b10e7dd4be 100644 --- a/inference-engine/include/cpp/ie_executable_network.hpp +++ b/inference-engine/include/cpp/ie_executable_network.hpp @@ -32,9 +32,6 @@ class IExecutableNetworkInternal; class INFERENCE_ENGINE_API_CLASS(ExecutableNetwork) { details::SharedObjectLoader _so; std::shared_ptr _impl; - IE_SUPPRESS_DEPRECATED_START - std::shared_ptr actual; - IE_SUPPRESS_DEPRECATED_END /** * @brief Constructs ExecutableNetwork from the initialized std::shared_ptr @@ -51,18 +48,6 @@ class INFERENCE_ENGINE_API_CLASS(ExecutableNetwork) { */ ExecutableNetwork() = default; - IE_SUPPRESS_DEPRECATED_START - /** - * @deprecated This ctor will be removed in 2022.1 - * @brief Constructs ExecutableNetwork from the initialized std::shared_ptr - * @param exec Initialized shared pointer - * @param splg Plugin to use. This is required to ensure that ExecutableNetwork can work properly even if plugin object is destroyed. - */ - INFERENCE_ENGINE_DEPRECATED("This ctor will be removed in 2022.1") - explicit ExecutableNetwork(std::shared_ptr exec, - std::shared_ptr splg = {}); - IE_SUPPRESS_DEPRECATED_END - /** * @brief Gets the Executable network output Data node information. * diff --git a/inference-engine/include/cpp/ie_infer_request.hpp b/inference-engine/include/cpp/ie_infer_request.hpp index fd71bf18bc2cc1..c5d52ec6fc0905 100644 --- a/inference-engine/include/cpp/ie_infer_request.hpp +++ b/inference-engine/include/cpp/ie_infer_request.hpp @@ -35,10 +35,6 @@ class ICompletionCallbackWrapper; class INFERENCE_ENGINE_API_CLASS(InferRequest) { details::SharedObjectLoader _so; std::shared_ptr _impl; - IE_SUPPRESS_DEPRECATED_START - IInferRequest::Ptr actual; - std::shared_ptr callback; - IE_SUPPRESS_DEPRECATED_END /** * @brief Constructs InferRequest from the initialized std::shared_ptr @@ -71,18 +67,6 @@ class INFERENCE_ENGINE_API_CLASS(InferRequest) { */ InferRequest() = default; - IE_SUPPRESS_DEPRECATED_START - /** - * @deprecated This ctor will be removed in 2022.1 - * @brief Constructs InferRequest from the initialized std::shared_ptr - * @param request Initialized shared pointer - * @param splg Plugin to use. This is required to ensure that InferRequest can work properly even if plugin object is destroyed. - */ - INFERENCE_ENGINE_DEPRECATED("This ctor will be removed in 2022.1") - explicit InferRequest(IInferRequest::Ptr request, - std::shared_ptr splg = {}); - IE_SUPPRESS_DEPRECATED_END - /** * @brief Sets input/output data to infer * diff --git a/inference-engine/include/cpp/ie_memory_state.hpp b/inference-engine/include/cpp/ie_memory_state.hpp index 0c055cec40cc79..8d54f79f06ce6a 100644 --- a/inference-engine/include/cpp/ie_memory_state.hpp +++ b/inference-engine/include/cpp/ie_memory_state.hpp @@ -3,7 +3,7 @@ // /** - * @brief A header file that provides wrapper classes for IVariableState + * @brief A header file that provides VariableState * * @file ie_memory_state.hpp */ @@ -16,21 +16,17 @@ #include "ie_api.h" #include "ie_blob.h" #include "details/ie_so_loader.h" -#include "ie_imemory_state.hpp" namespace InferenceEngine { class IVariableStateInternal; /** - * @brief C++ exception based error reporting wrapper of API class IVariableState + * @brief VariableState class */ class INFERENCE_ENGINE_API_CLASS(VariableState) { details::SharedObjectLoader _so; std::shared_ptr _impl; - IE_SUPPRESS_DEPRECATED_START - std::shared_ptr actual; - IE_SUPPRESS_DEPRECATED_END /** * @brief Constructs VariableState from the initialized std::shared_ptr @@ -48,55 +44,27 @@ class INFERENCE_ENGINE_API_CLASS(VariableState) { */ VariableState() = default; - IE_SUPPRESS_DEPRECATED_START /** - * @deprecated This ctor will be removed in 2022.1 - * @brief constructs VariableState from the initialized std::shared_ptr - * @param pState Initialized shared pointer - * @param plg Optional: Plugin to use. This is required to ensure that VariableState can work properly even if plugin object is destroyed. - */ - INFERENCE_ENGINE_DEPRECATED("This ctor will be removed in 2022.1") - explicit VariableState(std::shared_ptr pState, - std::shared_ptr plg = {}); - IE_SUPPRESS_DEPRECATED_END - - /** - * @copybrief IVariableState::Reset - * - * Wraps IVariableState::Reset + * @brief Reset internal variable state for relevant infer request, + * to a value specified as default for according ReadValue node */ void Reset(); /** - * @copybrief IVariableState::GetName - * - * Wraps IVariableState::GetName + * @brief Gets name of current variable state, if length of array is not enough name is truncated by len, null + * terminator is inserted as well. As variable state name `variable_id` from according `ReadValue` used. * @return A string representing a state name */ std::string GetName() const; /** - * @copybrief IVariableState::GetState - * - * Wraps IVariableState::GetState + * @brief Returns the value of the variable state. * @return A blob representing a state */ Blob::CPtr GetState() const; /** - * @copybrief IVariableState::GetLastState - * @deprecated Use IVariableState::SetState instead - * - * Wraps IVariableState::GetLastState - * @return A blob representing a last state - */ - INFERENCE_ENGINE_DEPRECATED("Use VariableState::GetState function instead") - Blob::CPtr GetLastState() const; - - /** - * @copybrief IVariableState::SetState - * - * Wraps IVariableState::SetState + * @brief Sets the new state for the next inference. * @param state The current state to set */ void SetState(Blob::Ptr state); diff --git a/inference-engine/include/ie_iexecutable_network.hpp b/inference-engine/include/ie_iexecutable_network.hpp index caef9bb95b95bd..bb0a6f71c4ac3f 100644 --- a/inference-engine/include/ie_iexecutable_network.hpp +++ b/inference-engine/include/ie_iexecutable_network.hpp @@ -18,7 +18,6 @@ #include "ie_common.h" #include "ie_icnn_network.hpp" #include "ie_iinfer_request.hpp" -#include "ie_imemory_state.hpp" #include "ie_input_info.hpp" #include "ie_parameter.hpp" #include "ie_remote_context.hpp" @@ -113,22 +112,6 @@ class INFERENCE_ENGINE_DEPRECATED("Use InferenceEngine::ExecutableNetwork instea INFERENCE_ENGINE_DEPRECATED("Use InferenceEngine::ExecutableNetwork::GetExecGraphInfo instead") virtual StatusCode GetExecGraphInfo(ICNNNetwork::Ptr& graphPtr, ResponseDesc* resp) noexcept = 0; - /** - * @deprecated Use InferRequest::QueryState instead - * @brief Gets state control interface for given executable network. - * - * State control essential for recurrent networks - * - * @param pState reference to a pointer that receives internal states - * @param idx requested index for receiving memory state - * @param resp Optional: pointer to an already allocated object to contain information in case of failure - * @return Status code of the operation: InferenceEngine::OK (0) for success, OUT_OF_BOUNDS (-6) no memory state for - * given index - */ - INFERENCE_ENGINE_DEPRECATED("Use InferRequest::QueryState instead") - virtual StatusCode QueryState(IVariableState::Ptr& pState, size_t idx, ResponseDesc* resp) noexcept = 0; - IE_SUPPRESS_DEPRECATED_END - /** * @brief Sets configuration for current executable network * diff --git a/inference-engine/include/ie_iinfer_request.hpp b/inference-engine/include/ie_iinfer_request.hpp index 7d762d96a11305..4fd200c0252062 100644 --- a/inference-engine/include/ie_iinfer_request.hpp +++ b/inference-engine/include/ie_iinfer_request.hpp @@ -17,7 +17,6 @@ #include "ie_blob.h" #include "ie_common.h" #include "ie_preprocess.hpp" -#include "ie_imemory_state.hpp" namespace InferenceEngine { @@ -195,21 +194,6 @@ class INFERENCE_ENGINE_DEPRECATED("Use InferenceEngine::InferRequest C++ wrapper */ virtual InferenceEngine::StatusCode SetBatch(int batch_size, ResponseDesc* resp) noexcept = 0; - IE_SUPPRESS_DEPRECATED_START - /** - * @brief Gets state control interface for given infer request. - * - * State control essential for recurrent networks - * - * @param pState reference to a pointer that receives internal states - * @param idx requested index for receiving memory state - * @param resp Optional: pointer to an already allocated object to contain information in case of failure - * @return Status code of the operation: InferenceEngine::OK (0) for success, OUT_OF_BOUNDS (-6) no memory state for - * given index - */ - virtual StatusCode QueryState(IVariableState::Ptr& pState, size_t idx, ResponseDesc* resp) noexcept = 0; - IE_SUPPRESS_DEPRECATED_END - protected: ~IInferRequest() = default; }; diff --git a/inference-engine/include/ie_imemory_state.hpp b/inference-engine/include/ie_imemory_state.hpp deleted file mode 100644 index 7f3ef99cbd11d3..00000000000000 --- a/inference-engine/include/ie_imemory_state.hpp +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/** - * @brief a header file for IVariableState interface - * - * @file ie_imemory_state.hpp - */ - -#pragma once - -#include - -#include "ie_blob.h" -#include "ie_common.h" - -namespace InferenceEngine { - -/** - * @deprecated Use InferenceEngine::VariableState C++ wrapper instead - * @interface IVariableState - * @brief Manages data for reset operations - */ -class INFERENCE_ENGINE_DEPRECATED("InferenceEngine::") IVariableState { -public: - IE_SUPPRESS_DEPRECATED_START - /** - * @brief A shared pointer to the IVariableState interface - */ - using Ptr = std::shared_ptr; - IE_SUPPRESS_DEPRECATED_END - - /** - * @brief Gets name of current variable state, if length of array is not enough name is truncated by len, null - * terminator is inserted as well. As variable state name `variable_id` from according `ReadValue` used. - * - * @param name preallocated buffer for receiving name - * @param len Length of the buffer - * @param resp Optional: pointer to an already allocated object to contain information in case of failure - * @return Status code of the operation: InferenceEngine::OK (0) for success - */ - virtual StatusCode GetName(char* name, size_t len, ResponseDesc* resp) const noexcept = 0; - - /** - * @brief Reset internal variable state for relevant infer request, to a value specified as default for according ReadValue node - * - * @param resp Optional: pointer to an already allocated object to contain information in case of failure - * @return Status code of the operation: InferenceEngine::OK (0) for success* - */ - virtual StatusCode Reset(ResponseDesc* resp) noexcept = 0; - - /** - * @brief Sets the new state for the next inference. - * - * This method can fail if Blob size does not match the internal state size or precision - * - * @param newState The data to use as new state - * @param resp Optional: pointer to an already allocated object to contain information in case of failure - * @return Status code of the operation: InferenceEngine::OK (0) for success - */ - virtual StatusCode SetState(Blob::Ptr newState, ResponseDesc* resp) noexcept = 0; - - /** - * @brief Returns the value of the variable state. - * - * @param state A reference to a blob containing a variable state - * @param resp Optional: pointer to an already allocated object to contain information in case of failure - * @return Status code of the operation: InferenceEngine::OK (0) for success - */ - INFERENCE_ENGINE_DEPRECATED("Use GetState function instead") - virtual StatusCode GetLastState(Blob::CPtr& state, ResponseDesc* resp) const noexcept { - return GetState(state, resp); - } - - /** - * @brief Returns the value of the variable state. - * - * @param state A reference to a blob containing a variable state - * @param resp Optional: pointer to an already allocated object to contain information in case of failure - * @return Status code of the operation: InferenceEngine::OK (0) for success - */ - virtual StatusCode GetState(Blob::CPtr& state, ResponseDesc* resp) const noexcept = 0; -}; - -IE_SUPPRESS_DEPRECATED_START - -/** - * @brief For compatibility reasons. - */ -using IMemoryState = IVariableState; - -IE_SUPPRESS_DEPRECATED_END - -} // namespace InferenceEngine \ No newline at end of file diff --git a/inference-engine/include/ie_parameter.hpp b/inference-engine/include/ie_parameter.hpp index 683f02fd6a552f..4aa6760d474874 100644 --- a/inference-engine/include/ie_parameter.hpp +++ b/inference-engine/include/ie_parameter.hpp @@ -49,26 +49,6 @@ class INFERENCE_ENGINE_API_CLASS(Parameter) { std::swap(ptr, parameter.ptr); } - /** - * @deprecated Use ngraph::Variant directly - * @brief Creates parameter from variant. - * This method creates empty parameter if variant doesn't contain Parameter - * - * @param var ngraph variant - */ - INFERENCE_ENGINE_DEPRECATED("Use ngraph::Variant directly") - Parameter(const std::shared_ptr& var); - - /** - * @deprecated Use ngraph::Variant directly - * @brief Creates parameter from variant. - * This method creates empty parameter if variant doesn't contain Parameter - * - * @param var ngraph variant - */ - INFERENCE_ENGINE_DEPRECATED("Use ngraph::Variant directly") - Parameter(std::shared_ptr& var); - /** * @brief Copy constructor * @@ -204,28 +184,6 @@ class INFERENCE_ENGINE_API_CLASS(Parameter) { return dyn_cast::type>(ptr); } - /** - * @deprecated Use ngraph::Variant directly - * @brief Converts parameter to shared pointer on ngraph::Variant - * - * @return shared pointer on ngraph::Variant - */ - INFERENCE_ENGINE_DEPRECATED("Use ngraph::Variant directly") - std::shared_ptr asVariant() const; - - /** - * @deprecated Use ngraph::Variant directly - * @brief Casts to shared pointer on ngraph::Variant - * - * @return shared pointer on ngraph::Variant - */ - INFERENCE_ENGINE_DEPRECATED("Use ngraph::Variant directly") - operator std::shared_ptr() const { - IE_SUPPRESS_DEPRECATED_START - return asVariant(); - IE_SUPPRESS_DEPRECATED_END - } - /** * Dynamic cast to specified type * @tparam T type diff --git a/inference-engine/include/ie_unicode.hpp b/inference-engine/include/ie_unicode.hpp deleted file mode 100644 index dc943d6f558be5..00000000000000 --- a/inference-engine/include/ie_unicode.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/** - * @brief This is a header file with common inference engine definitions - * - * @file ie_unicode.hpp - */ -#pragma once - -#include -#include -#include -#include -#include -#include - -#ifdef UNICODE -typedef wchar_t tchar; -typedef std::wstring file_name_t; -#else -typedef char tchar; -typedef std::string file_name_t; -#endif - -namespace InferenceEngine { - -/** - * @deprecated Use OS-native conversion utilities - * @brief Conversion from possibly-wide character string to a single-byte chain. - * @param str A possibly-wide character string - * @return A single-byte character string - */ -INFERENCE_ENGINE_DEPRECATED("Use OS-native conversion utilities") -inline std::string fileNameToString(const file_name_t& str) { -#ifdef UNICODE - size_t maxlen = (str.length() + 1) * sizeof(wchar_t) / sizeof(char); - std::vector mbstr(maxlen); - mbstr[0] = 0; - std::wcstombs(&mbstr[0], str.c_str(), maxlen); - std::string res = std::string(&mbstr[0]); - return res; -#else - return str; -#endif -} - -/** - * @deprecated Use OS-native conversion utilities - * @brief Conversion from single-byte character string to a possibly-wide one - * @param str A single-byte character string - * @return A possibly-wide character string - */ -INFERENCE_ENGINE_DEPRECATED("Use OS-native conversion utilities") -inline file_name_t stringToFileName(const std::string& str) { -#ifdef UNICODE - size_t maxlen = str.length() + 1; - std::vector wcstr(maxlen); - wcstr[0] = 0; - std::mbstowcs(&wcstr[0], str.c_str(), maxlen); - file_name_t res = file_name_t(&wcstr[0]); - return res; -#else - return str; -#endif -} - -} // namespace InferenceEngine diff --git a/inference-engine/src/inference_engine/cpp/ie_executable_network.cpp b/inference-engine/src/inference_engine/cpp/ie_executable_network.cpp index 6de781d11e62ec..a4afee5a28ba2b 100644 --- a/inference-engine/src/inference_engine/cpp/ie_executable_network.cpp +++ b/inference-engine/src/inference_engine/cpp/ie_executable_network.cpp @@ -25,47 +25,15 @@ ExecutableNetwork::ExecutableNetwork(const details::SharedObjectLoader& so, IE_SUPPRESS_DEPRECATED_START -ExecutableNetwork::ExecutableNetwork(IExecutableNetwork::Ptr exec, - std::shared_ptr splg) - : _so(), _impl(), actual(exec) { - if (splg) { - _so = *splg; - } - - // plg can be null, but not the actual - if (actual == nullptr) - IE_THROW(NotAllocated) << "ExecutableNetwork was not initialized."; -} - ConstOutputsDataMap ExecutableNetwork::GetOutputsInfo() const { - if (actual) { - ConstOutputsDataMap data; - CALL_STATUS_FNC(GetOutputsInfo, data); - return data; - } - EXEC_NET_CALL_STATEMENT(return _impl->GetOutputsInfo()); } ConstInputsDataMap ExecutableNetwork::GetInputsInfo() const { - if (actual) { - ConstInputsDataMap info; - CALL_STATUS_FNC(GetInputsInfo, info); - return info; - } - EXEC_NET_CALL_STATEMENT(return _impl->GetInputsInfo()); } void ExecutableNetwork::reset(IExecutableNetwork::Ptr newActual) { - if (actual) { - if (newActual == nullptr) { - THROW_IE_EXCEPTION << "ExecutableNetwork wrapper used for reset was not initialized."; - } - this->actual.swap(newActual); - return; - } - if (_impl == nullptr) IE_THROW() << "ExecutableNetwork was not initialized."; if (newActual == nullptr) IE_THROW() << "ExecutableNetwork wrapper used for reset was not initialized."; auto newBase = std::dynamic_pointer_cast(newActual); @@ -76,36 +44,10 @@ void ExecutableNetwork::reset(IExecutableNetwork::Ptr newActual) { } ExecutableNetwork::operator IExecutableNetwork::Ptr() { - if (actual) { - return actual; - } - return std::make_shared(_impl); } std::vector ExecutableNetwork::QueryState() { - if (actual) { - if (actual == nullptr) THROW_IE_EXCEPTION << "ExecutableNetwork was not initialized."; - IVariableState::Ptr pState = nullptr; - auto res = OK; - std::vector controller; - for (size_t idx = 0; res == OK; ++idx) { - ResponseDesc resp; - IE_SUPPRESS_DEPRECATED_START - res = actual->QueryState(pState, idx, &resp); - IE_SUPPRESS_DEPRECATED_END - if (res != OK && res != OUT_OF_BOUNDS) { - THROW_IE_EXCEPTION << resp.msg; - } - if (res != OUT_OF_BOUNDS) { - controller.push_back(VariableState(pState, - std::make_shared(_so))); - } - } - - return controller; - } - std::vector controller; EXEC_NET_CALL_STATEMENT( for (auto&& state : _impl->QueryState()) { @@ -115,13 +57,6 @@ std::vector ExecutableNetwork::QueryState() { } InferRequest ExecutableNetwork::CreateInferRequest() { - if (actual) { - IInferRequest::Ptr req; - CALL_STATUS_FNC(CreateInferRequest, req); - if (req.get() == nullptr) THROW_IE_EXCEPTION << "Internal error: pointer to infer request is null"; - return InferRequest(req, std::make_shared(_so)); - } - EXEC_NET_CALL_STATEMENT(return {_so, _impl->CreateInferRequest()}); } @@ -130,72 +65,38 @@ InferRequest::Ptr ExecutableNetwork::CreateInferRequestPtr() { } void ExecutableNetwork::Export(const std::string& modelFileName) { - if (actual) { - CALL_STATUS_FNC(Export, modelFileName); - return; - } EXEC_NET_CALL_STATEMENT(_impl->Export(modelFileName)); } void ExecutableNetwork::Export(std::ostream& networkModel) { - if (actual) { - CALL_STATUS_FNC(Export, networkModel); - return; - } EXEC_NET_CALL_STATEMENT(_impl->Export(networkModel)); } CNNNetwork ExecutableNetwork::GetExecGraphInfo() { - if (actual) { - IE_SUPPRESS_DEPRECATED_START - ICNNNetwork::Ptr ptr = nullptr; - CALL_STATUS_FNC(GetExecGraphInfo, ptr); - return CNNNetwork(ptr); - IE_SUPPRESS_DEPRECATED_END - } EXEC_NET_CALL_STATEMENT(return _impl->GetExecGraphInfo()); } void ExecutableNetwork::SetConfig(const std::map& config) { - if (actual) { - CALL_STATUS_FNC(SetConfig, config); - return; - } EXEC_NET_CALL_STATEMENT(_impl->SetConfig(config)); } Parameter ExecutableNetwork::GetConfig(const std::string& name) const { - if (actual) { - Parameter configValue; - CALL_STATUS_FNC(GetConfig, name, configValue); - return configValue; - } EXEC_NET_CALL_STATEMENT(return _impl->GetConfig(name)); } Parameter ExecutableNetwork::GetMetric(const std::string& name) const { - if (actual) { - Parameter metricValue; - CALL_STATUS_FNC(GetMetric, name, metricValue); - return metricValue; - } EXEC_NET_CALL_STATEMENT(return _impl->GetMetric(name)); } RemoteContext::Ptr ExecutableNetwork::GetContext() const { - if (actual) { - RemoteContext::Ptr pContext; - CALL_STATUS_FNC(GetContext, pContext); - return pContext; - } EXEC_NET_CALL_STATEMENT(return _impl->GetContext()); } bool ExecutableNetwork::operator!() const noexcept { - return !_impl || !actual; + return !_impl; } ExecutableNetwork::operator bool() const noexcept { - return !!_impl || !!actual; + return !!_impl; } } // namespace InferenceEngine diff --git a/inference-engine/src/inference_engine/cpp/ie_executable_network_base.hpp b/inference-engine/src/inference_engine/cpp/ie_executable_network_base.hpp index 2f813c0b783560..c87b1fc7098a2c 100644 --- a/inference-engine/src/inference_engine/cpp/ie_executable_network_base.hpp +++ b/inference-engine/src/inference_engine/cpp/ie_executable_network_base.hpp @@ -18,7 +18,6 @@ #include #include #include "cpp/exception2status.hpp" -#include "ie_variable_state_base.hpp" #include "ie_infer_async_request_base.hpp" namespace InferenceEngine { @@ -64,29 +63,10 @@ class ExecutableNetworkBase : public IExecutableNetwork { TO_STATUS(_impl->Export(networkModel)); } - IE_SUPPRESS_DEPRECATED_START StatusCode GetExecGraphInfo(ICNNNetwork::Ptr& graphPtr, ResponseDesc* resp) noexcept override { - // should be refactored together with ExecutableNetwork interface TO_STATUS(graphPtr = _impl->GetExecGraphInfo()); } - INFERENCE_ENGINE_DEPRECATED("Use InferRequest::QueryState instead") - StatusCode QueryState(IVariableState::Ptr& pState, size_t idx, ResponseDesc* resp) noexcept override { - try { - auto v = _impl->QueryState(); - if (idx >= v.size()) { - return OUT_OF_BOUNDS; - } - pState = std::make_shared(v[idx]); - return OK; - } catch (const std::exception& ex) { - return InferenceEngine::DescriptionBuffer(GENERAL_ERROR, resp) << ex.what(); - } catch (...) { - return InferenceEngine::DescriptionBuffer(UNEXPECTED); - } - } - IE_SUPPRESS_DEPRECATED_END - StatusCode SetConfig(const std::map& config, ResponseDesc* resp) noexcept override { TO_STATUS(_impl->SetConfig(config)); } diff --git a/inference-engine/src/inference_engine/cpp/ie_infer_async_request_base.hpp b/inference-engine/src/inference_engine/cpp/ie_infer_async_request_base.hpp index 1253947eeafd15..6ede78f720e3a2 100644 --- a/inference-engine/src/inference_engine/cpp/ie_infer_async_request_base.hpp +++ b/inference-engine/src/inference_engine/cpp/ie_infer_async_request_base.hpp @@ -10,10 +10,10 @@ #include "cpp/exception2status.hpp" #include "cpp_interfaces/plugin_itt.hpp" -#include "ie_variable_state_base.hpp" #include #include "ie_iinfer_request.hpp" #include "ie_preprocess.hpp" + namespace InferenceEngine { #define CATCH_IE_EXCEPTION_TO_STATUS_NO_RESP(StatusCode, ExceptionType) catch (const ExceptionType& ex) { \ @@ -169,23 +169,6 @@ class InferRequestBase : public IInferRequest { StatusCode SetBatch(int batch_size, ResponseDesc* resp) noexcept override { TO_STATUS(_impl->SetBatch(batch_size)); } - - IE_SUPPRESS_DEPRECATED_START - StatusCode QueryState(IVariableState::Ptr& pState, size_t idx, ResponseDesc* resp) noexcept override { - try { - auto v = _impl->QueryState(); - if (idx >= v.size()) { - return OUT_OF_BOUNDS; - } - pState = std::make_shared(v[idx]); - return OK; - } catch (const std::exception& ex) { - return InferenceEngine::DescriptionBuffer(GENERAL_ERROR, resp) << ex.what(); - } catch (...) { - return InferenceEngine::DescriptionBuffer(UNEXPECTED); - } - } - IE_SUPPRESS_DEPRECATED_END }; IE_SUPPRESS_DEPRECATED_END diff --git a/inference-engine/src/inference_engine/cpp/ie_infer_request.cpp b/inference-engine/src/inference_engine/cpp/ie_infer_request.cpp index 97fba9af7f924f..9e68666b7a36f6 100644 --- a/inference-engine/src/inference_engine/cpp/ie_infer_request.cpp +++ b/inference-engine/src/inference_engine/cpp/ie_infer_request.cpp @@ -23,44 +23,17 @@ namespace InferenceEngine { InferRequest::InferRequest(const details::SharedObjectLoader& so, const IInferRequestInternal::Ptr& impl) - : _so(so), _impl(impl), actual() { + : _so(so), _impl(impl) { IE_ASSERT(_impl != nullptr); } IE_SUPPRESS_DEPRECATED_START -InferRequest::InferRequest(IInferRequest::Ptr request, - std::shared_ptr splg) - : _so(), _impl(), actual(request) { - if (splg) { - _so = *splg; - } - - // plg can be null, but not the actual - if (actual == nullptr) - IE_THROW(NotAllocated) << "InferRequest was not initialized."; -} - void InferRequest::SetBlob(const std::string& name, const Blob::Ptr& data) { - if (actual) { - CALL_STATUS_FNC(SetBlob, name.c_str(), data); - return; - } INFER_REQ_CALL_STATEMENT(_impl->SetBlob(name, data);) } Blob::Ptr InferRequest::GetBlob(const std::string& name) { - if (actual) { - Blob::Ptr data; - CALL_STATUS_FNC(GetBlob, name.c_str(), data); - std::string error = "Internal error: blob with name `" + name + "` is not allocated!"; - auto blobPtr = data.get(); - const bool remoteBlobPassed = blobPtr->is(); - if (blobPtr == nullptr) IE_THROW() << error; - if (!remoteBlobPassed && blobPtr->buffer() == nullptr) IE_THROW() << error; - return data; - } - Blob::Ptr blobPtr; INFER_REQ_CALL_STATEMENT(blobPtr = _impl->GetBlob(name);) std::string error = "Internal error: blob with name `" + name + "` is not allocated!"; @@ -71,60 +44,26 @@ Blob::Ptr InferRequest::GetBlob(const std::string& name) { } void InferRequest::SetBlob(const std::string &name, const Blob::Ptr &data, const PreProcessInfo& info) { - if (actual) { - CALL_STATUS_FNC(SetBlob, name.c_str(), data, info); - return; - } - INFER_REQ_CALL_STATEMENT(_impl->SetBlob(name, data, info);) } const PreProcessInfo& InferRequest::GetPreProcess(const std::string& name) const { - if (actual) { - const PreProcessInfo* info = nullptr; - CALL_STATUS_FNC(GetPreProcess, name.c_str(), &info); - return *info; - } - INFER_REQ_CALL_STATEMENT(return _impl->GetPreProcess(name);) } void InferRequest::Infer() { - if (actual) { - CALL_STATUS_FNC_NO_ARGS(Infer); - return; - } - INFER_REQ_CALL_STATEMENT(_impl->Infer();) } void InferRequest::Cancel() { - if (actual) { - CALL_STATUS_FNC_NO_ARGS(Cancel); - return; - } - INFER_REQ_CALL_STATEMENT(_impl->Cancel();) } std::map InferRequest::GetPerformanceCounts() const { - if (actual) { - std::map perfMap; - CALL_STATUS_FNC(GetPerformanceCounts, perfMap); - return perfMap; - } - INFER_REQ_CALL_STATEMENT(return _impl->GetPerformanceCounts();) } void InferRequest::SetInput(const BlobMap& inputs) { - if (actual) { - for (auto&& input : inputs) { - CALL_STATUS_FNC(SetBlob, input.first.c_str(), input.second); - } - return; - } - INFER_REQ_CALL_STATEMENT( for (auto&& input : inputs) { _impl->SetBlob(input.first, input.second); @@ -133,13 +72,6 @@ void InferRequest::SetInput(const BlobMap& inputs) { } void InferRequest::SetOutput(const BlobMap& results) { - if (actual) { - for (auto&& result : results) { - CALL_STATUS_FNC(SetBlob, result.first.c_str(), result.second); - } - return; - } - INFER_REQ_CALL_STATEMENT( for (auto&& result : results) { _impl->SetBlob(result.first, result.second); @@ -148,106 +80,19 @@ void InferRequest::SetOutput(const BlobMap& results) { } void InferRequest::SetBatch(const int batch) { - if (actual) { - CALL_STATUS_FNC(SetBatch, batch); - return; - } - INFER_REQ_CALL_STATEMENT(_impl->SetBatch(batch);) } void InferRequest::StartAsync() { - if (actual) { - CALL_STATUS_FNC_NO_ARGS(StartAsync); - return; - } - INFER_REQ_CALL_STATEMENT(_impl->StartAsync();) } StatusCode InferRequest::Wait(int64_t millis_timeout) { - if (actual) { - ResponseDesc resp; - if (actual == nullptr) IE_THROW() << "InferRequest was not initialized."; - auto res = actual->Wait(millis_timeout, &resp); - if (res != OK && res != RESULT_NOT_READY && - res != INFER_NOT_STARTED && res != INFER_CANCELLED) { - IE_EXCEPTION_SWITCH(res, ExceptionType, - InferenceEngine::details::ThrowNow{} - <<= std::stringstream{} << IE_LOCATION << resp.msg) - } - return res; - } - INFER_REQ_CALL_STATEMENT(return _impl->Wait(millis_timeout);) } -namespace details { - -class ICompletionCallbackWrapper { -public: - virtual ~ICompletionCallbackWrapper() = default; - - virtual void call(InferenceEngine::IInferRequest::Ptr request, InferenceEngine::StatusCode code) const noexcept = 0; -}; - -template -class CompletionCallbackWrapper : public ICompletionCallbackWrapper { - T lambda; - -public: - explicit CompletionCallbackWrapper(const T& lambda): lambda(lambda) {} - - void call(InferenceEngine::IInferRequest::Ptr /*request*/, InferenceEngine::StatusCode /*code*/) const - noexcept override { - lambda(); - } -}; - -template <> -class CompletionCallbackWrapper : public ICompletionCallbackWrapper { - IInferRequest::CompletionCallback callBack; - -public: - explicit CompletionCallbackWrapper(const IInferRequest::CompletionCallback& callBack): callBack(callBack) {} - - void call(InferenceEngine::IInferRequest::Ptr request, InferenceEngine::StatusCode code) const noexcept override { - callBack(request, code); - } -}; - -template <> -class CompletionCallbackWrapper> : public ICompletionCallbackWrapper { - std::function lambda; - -public: - explicit CompletionCallbackWrapper(const std::function& lambda) - : lambda(lambda) {} - - void call(InferenceEngine::IInferRequest::Ptr request, InferenceEngine::StatusCode code) const noexcept override { - lambda(InferRequest(request), code); - } -}; - -void callWrapper(InferenceEngine::IInferRequest::Ptr request, InferenceEngine::StatusCode code) { - details::ICompletionCallbackWrapper* pWrapper = nullptr; - ResponseDesc dsc; - request->GetUserData(reinterpret_cast(&pWrapper), &dsc); - pWrapper->call(request, code); -} - -} // namespace details - void InferRequest::SetCompletionCallbackImpl(std::function callbackToSet) { - if (actual) { - using T = std::function; - callback.reset(new details::CompletionCallbackWrapper(callbackToSet)); - CALL_STATUS_FNC(SetUserData, callback.get()); - actual->SetCompletionCallback(InferenceEngine::details::callWrapper); - return; - } - INFER_REQ_CALL_STATEMENT( _impl->SetCallback([callbackToSet] (std::exception_ptr) { callbackToSet(); @@ -274,14 +119,6 @@ void InferRequest::SetCompletionCallbackImpl(std::function callbackToSet void InferRequest::SetCompletionCallbackImpl(std::function callbackToSet) { - if (actual) { - using T = std::function; - callback.reset(new details::CompletionCallbackWrapper(callbackToSet)); - CALL_STATUS_FNC(SetUserData, callback.get()); - actual->SetCompletionCallback(InferenceEngine::details::callWrapper); - return; - } - INFER_REQ_CALL_STATEMENT( auto weakThis = InferRequest{_so, std::shared_ptr{_impl.get(), [](IInferRequestInternal*){}}}; _impl->SetCallback([callbackToSet, weakThis] (std::exception_ptr exceptionPtr) { @@ -303,14 +140,6 @@ void InferRequest::SetCompletionCallbackImpl(std::function(callbackToSet)); - CALL_STATUS_FNC(SetUserData, callback.get()); - actual->SetCompletionCallback(InferenceEngine::details::callWrapper); - return; - } - INFER_REQ_CALL_STATEMENT( IInferRequest::Ptr weakThis = InferRequest{_so, std::shared_ptr{_impl.get(), [](IInferRequestInternal*){}}}; _impl->SetCallback([callbackToSet, weakThis] (std::exception_ptr exceptionPtr) { @@ -332,38 +161,12 @@ void InferRequest::SetCompletionCallbackImpl(IInferRequest::CompletionCallback c } InferRequest::operator IInferRequest::Ptr () { - if (actual) { - return actual; - } - INFER_REQ_CALL_STATEMENT( return std::make_shared(_impl); ) } std::vector InferRequest::QueryState() { - if (actual) { - IE_SUPPRESS_DEPRECATED_START - if (actual == nullptr) IE_THROW() << "ExecutableNetwork was not initialized."; - IVariableState::Ptr pState = nullptr; - auto res = OK; - std::vector controller; - for (size_t idx = 0; res == OK; ++idx) { - ResponseDesc resp; - res = actual->QueryState(pState, idx, &resp); - if (res != OK && res != OUT_OF_BOUNDS) { - IE_THROW() << resp.msg; - } - if (res != OUT_OF_BOUNDS) { - controller.push_back(VariableState(pState, - std::make_shared(_so))); - } - } - IE_SUPPRESS_DEPRECATED_END - - return controller; - } - std::vector controller; INFER_REQ_CALL_STATEMENT( for (auto&& state : _impl->QueryState()) { @@ -374,11 +177,11 @@ std::vector InferRequest::QueryState() { } bool InferRequest::operator!() const noexcept { - return !_impl || !actual; + return !_impl; } InferRequest::operator bool() const noexcept { - return (!!_impl) || (!!actual); + return (!!_impl); } bool InferRequest::operator!=(const InferRequest& r) const noexcept { @@ -386,7 +189,7 @@ bool InferRequest::operator!=(const InferRequest& r) const noexcept { } bool InferRequest::operator==(const InferRequest& r) const noexcept { - return r._impl == _impl && r.actual == actual; + return r._impl == _impl; } } // namespace InferenceEngine diff --git a/inference-engine/src/inference_engine/cpp/ie_variable_state.cpp b/inference-engine/src/inference_engine/cpp/ie_variable_state.cpp index 46f99d3fc6c1d0..63f7305e8b2b38 100644 --- a/inference-engine/src/inference_engine/cpp/ie_variable_state.cpp +++ b/inference-engine/src/inference_engine/cpp/ie_variable_state.cpp @@ -4,7 +4,6 @@ #include "details/ie_so_loader.h" #include "cpp/ie_memory_state.hpp" -#include "ie_imemory_state.hpp" #include "cpp_interfaces/interface/ie_ivariable_state_internal.hpp" #include "exception2status.hpp" @@ -24,57 +23,19 @@ VariableState::VariableState(const details::SharedObjectLoader& so, IE_SUPPRESS_DEPRECATED_START -VariableState::VariableState(std::shared_ptr state, - std::shared_ptr splg) - : _so(), _impl(), actual(state) { - if (splg) { - _so = *splg; - } - - // plg can be null, but not the actual - if (actual == nullptr) - IE_THROW(NotAllocated) << "VariableState was not initialized."; -} - -Blob::CPtr VariableState::GetLastState() const { - return GetState(); -} - void VariableState::Reset() { - if (actual) { - CALL_STATUS_FNC_NO_ARGS(Reset); - return; - } - VARIABLE_CALL_STATEMENT(_impl->Reset()); } std::string VariableState::GetName() const { - if (actual) { - char name[256]; - CALL_STATUS_FNC(GetName, name, sizeof(name)); - return name; - } - VARIABLE_CALL_STATEMENT(return _impl->GetName()); } Blob::CPtr VariableState::GetState() const { - if (actual) { - Blob::CPtr stateBlob; - CALL_STATUS_FNC(GetState, stateBlob); - return stateBlob; - } - VARIABLE_CALL_STATEMENT(return _impl->GetState()); } void VariableState::SetState(Blob::Ptr state) { - if (actual) { - CALL_STATUS_FNC(SetState, state); - return; - } - VARIABLE_CALL_STATEMENT(_impl->SetState(state)); } diff --git a/inference-engine/src/inference_engine/cpp/ie_variable_state_base.hpp b/inference-engine/src/inference_engine/cpp/ie_variable_state_base.hpp deleted file mode 100644 index 2481ca67852ddb..00000000000000 --- a/inference-engine/src/inference_engine/cpp/ie_variable_state_base.hpp +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -#include "cpp/exception2status.hpp" -#include "cpp_interfaces/interface/ie_ivariable_state_internal.hpp" -#include "ie_imemory_state.hpp" - -namespace InferenceEngine { - -IE_SUPPRESS_DEPRECATED_START - -/** - * @brief Default implementation for IVariableState - * @ingroup ie_dev_api_variable_state_api - */ -class VariableStateBase : public IVariableState { - std::shared_ptr impl; - -public: - /** - * @brief Constructor with actual underlying implementation. - * @param impl Underlying implementation of type IVariableStateInternal - */ - explicit VariableStateBase(std::shared_ptr impl): impl(impl) { - if (impl == nullptr) { - IE_THROW() << "VariableStateBase implementation is not defined"; - } - } - - StatusCode GetName(char* name, size_t len, ResponseDesc* resp) const noexcept override { - for (size_t i = 0; i != len; i++) { - name[i] = 0; - } - DescriptionBuffer buf(name, len); - TO_STATUS(buf << impl->GetName()); - return OK; - } - - StatusCode Reset(ResponseDesc* resp) noexcept override { - TO_STATUS(impl->Reset()); - } - - StatusCode SetState(Blob::Ptr newState, ResponseDesc* resp) noexcept override { - TO_STATUS(impl->SetState(newState)); - } - - StatusCode GetState(Blob::CPtr& state, ResponseDesc* resp) const noexcept override { - TO_STATUS(state = impl->GetState()); - } -}; - -IE_SUPPRESS_DEPRECATED_END - -} // namespace InferenceEngine diff --git a/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_ivariable_state_internal.cpp b/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_ivariable_state_internal.cpp index 0171292d36bbdc..a499e816ee0b2c 100644 --- a/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_ivariable_state_internal.cpp +++ b/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_ivariable_state_internal.cpp @@ -23,7 +23,4 @@ Blob::CPtr IVariableStateInternal::GetState() const { return state; } -Blob::CPtr IVariableStateInternal::GetLastState() const { - return GetState(); -} } // namespace InferenceEngine diff --git a/inference-engine/src/inference_engine/ie_parameter.cpp b/inference-engine/src/inference_engine/ie_parameter.cpp deleted file mode 100644 index 61fbf54c37dcc2..00000000000000 --- a/inference-engine/src/inference_engine/ie_parameter.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include - -#include - -namespace ngraph { - -template class INFERENCE_ENGINE_API_CLASS(VariantImpl); - -template <> -class INFERENCE_ENGINE_API_CLASS(VariantWrapper) : public VariantImpl { -public: - static constexpr VariantTypeInfo type_info {"Variant::InferenceEngine::Parameter", 0}; - const VariantTypeInfo& get_type_info() const override { - return type_info; - } - VariantWrapper(const value_type& value): VariantImpl(value) {} // NOLINT -}; - -} // namespace ngraph - -constexpr ngraph::VariantTypeInfo ngraph::VariantWrapper::type_info; - -InferenceEngine::Parameter::Parameter(const std::shared_ptr& var) { - if (auto paramWrapper = std::dynamic_pointer_cast>(var)) { - auto param = paramWrapper->get(); - if (!param.empty()) ptr = param.ptr->copy(); - } -} - -InferenceEngine::Parameter::Parameter(std::shared_ptr& var) { - if (auto paramWrapper = std::dynamic_pointer_cast>(var)) { - auto param = paramWrapper->get(); - if (!param.empty()) ptr = param.ptr->copy(); - } -} - - -std::shared_ptr InferenceEngine::Parameter::asVariant() const { - return std::make_shared>(*this); -} diff --git a/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_ivariable_state_internal.hpp b/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_ivariable_state_internal.hpp index f92fd556f00f45..d34af53631a556 100644 --- a/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_ivariable_state_internal.hpp +++ b/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_ivariable_state_internal.hpp @@ -50,14 +50,6 @@ class INFERENCE_ENGINE_API_CLASS(IVariableStateInternal) : public std::enable_sh */ virtual Blob::CPtr GetState() const; - /** - * @deprecated Use IVariableStateInternal::GetState method instead - * @brief Returns the value of the variable state. - * @return The value of the variable state - */ - INFERENCE_ENGINE_DEPRECATED("Use IVariableStateInternal::GetState method instead") - virtual Blob::CPtr GetLastState() const; - protected: /** * @brief A default dtor diff --git a/inference-engine/tests/functional/inference_engine/async_infer_request_test.cpp b/inference-engine/tests/functional/inference_engine/async_infer_request_test.cpp index cc5cc1fe4eb826..6393aa69d16199 100644 --- a/inference-engine/tests/functional/inference_engine/async_infer_request_test.cpp +++ b/inference-engine/tests/functional/inference_engine/async_infer_request_test.cpp @@ -5,26 +5,12 @@ #include #include -#include "unit_test_utils/mocks/mock_iinfer_request.hpp" using namespace ::testing; using namespace std; using namespace InferenceEngine; using namespace InferenceEngine::details; -IE_SUPPRESS_DEPRECATED_START - -TEST(InferRequestCPPTests, throwsOnUninitialized) { - std::shared_ptr ptr; - ASSERT_THROW(InferRequest req(ptr), InferenceEngine::NotAllocated); -} - -TEST(InferRequestCPPTests, nothrowOnInitialized) { - std::shared_ptr ptr = std::make_shared(); - ASSERT_NO_THROW(InferRequest req(ptr)); -} - -IE_SUPPRESS_DEPRECATED_END TEST(InferRequestCPPTests, throwsOnUninitializedSetBlob) { InferRequest req; diff --git a/inference-engine/tests/functional/inference_engine/executable_network.cpp b/inference-engine/tests/functional/inference_engine/executable_network.cpp index 8db2bf40ed2402..89653bdc5ee7f1 100644 --- a/inference-engine/tests/functional/inference_engine/executable_network.cpp +++ b/inference-engine/tests/functional/inference_engine/executable_network.cpp @@ -4,75 +4,60 @@ #include #include -#include "unit_test_utils/mocks/mock_iexecutable_network.hpp" using namespace ::testing; using namespace std; using namespace InferenceEngine; using namespace InferenceEngine::details; -IE_SUPPRESS_DEPRECATED_START - -TEST(ExecutableNetworkTests, throwsOnUninitialized) { - std::shared_ptr ptr; - ASSERT_THROW(ExecutableNetwork req(ptr), InferenceEngine::NotAllocated); -} - -TEST(ExecutableNetworkTests, nothrowOnInitialized) { - std::shared_ptr ptr = std::make_shared(); - ASSERT_NO_THROW(ExecutableNetwork req(ptr)); -} - -IE_SUPPRESS_DEPRECATED_END - TEST(ExecutableNetworkTests, throwsOnUninitializedGetOutputsInfo) { ExecutableNetwork exec; - ASSERT_THROW(exec.GetOutputsInfo(), InferenceEngine::Exception); + ASSERT_THROW(exec.GetOutputsInfo(), InferenceEngine::NotAllocated); } TEST(ExecutableNetworkTests, throwsOnUninitializedGetInputsInfo) { ExecutableNetwork exec; - ASSERT_THROW(exec.GetInputsInfo(), InferenceEngine::Exception); + ASSERT_THROW(exec.GetInputsInfo(), InferenceEngine::NotAllocated); } TEST(ExecutableNetworkTests, throwsOnUninitializedExport) { ExecutableNetwork exec; - ASSERT_THROW(exec.Export(std::string()), InferenceEngine::Exception); + ASSERT_THROW(exec.Export(std::string()), InferenceEngine::NotAllocated); } TEST(ExecutableNetworkTests, throwsOnUninitializedExportStream) { ExecutableNetwork exec; - ASSERT_THROW(exec.Export(std::cout), InferenceEngine::Exception); + ASSERT_THROW(exec.Export(std::cout), InferenceEngine::NotAllocated); } TEST(ExecutableNetworkTests, throwsOnUninitializedGetExecGraphInfo) { ExecutableNetwork exec; - ASSERT_THROW(exec.GetExecGraphInfo(), InferenceEngine::Exception); + ASSERT_THROW(exec.GetExecGraphInfo(), InferenceEngine::NotAllocated); } TEST(ExecutableNetworkTests, throwsOnUninitializedQueryState) { IE_SUPPRESS_DEPRECATED_START ExecutableNetwork exec; - ASSERT_THROW(exec.QueryState(), InferenceEngine::Exception); + ASSERT_THROW(exec.QueryState(), InferenceEngine::NotAllocated); IE_SUPPRESS_DEPRECATED_END } TEST(ExecutableNetworkTests, throwsOnUninitializedSetConfig) { ExecutableNetwork exec; - ASSERT_THROW(exec.SetConfig({{}}), InferenceEngine::Exception); + ASSERT_THROW(exec.SetConfig({{}}), InferenceEngine::NotAllocated); } TEST(ExecutableNetworkTests, throwsOnUninitializedGetConfig) { ExecutableNetwork exec; - ASSERT_THROW(exec.GetConfig({}), InferenceEngine::Exception); + ASSERT_THROW(exec.GetConfig({}), InferenceEngine::NotAllocated); } TEST(ExecutableNetworkTests, throwsOnUninitializedGetMetric) { ExecutableNetwork exec; - ASSERT_THROW(exec.GetMetric({}), InferenceEngine::Exception); + ASSERT_THROW(exec.GetMetric({}), InferenceEngine::NotAllocated); } TEST(ExecutableNetworkTests, throwsOnUninitializedGetContext) { ExecutableNetwork exec; - ASSERT_THROW(exec.GetContext(), InferenceEngine::Exception); + ASSERT_THROW(exec.GetContext(), InferenceEngine::NotAllocated); } \ No newline at end of file diff --git a/inference-engine/tests/functional/inference_engine/variable_state.cpp b/inference-engine/tests/functional/inference_engine/variable_state.cpp index 5073a155fca2e9..f17bd599bb6026 100644 --- a/inference-engine/tests/functional/inference_engine/variable_state.cpp +++ b/inference-engine/tests/functional/inference_engine/variable_state.cpp @@ -5,32 +5,12 @@ #include #include -#include "unit_test_utils/mocks/mock_ie_ivariable_state.hpp" using namespace ::testing; using namespace std; using namespace InferenceEngine; using namespace InferenceEngine::details; -IE_SUPPRESS_DEPRECATED_START - -TEST(VariableStateCPPTests, throwsOnUninitialized) { - std::shared_ptr ptr; - ASSERT_THROW(VariableState var(ptr), InferenceEngine::NotAllocated); -} - -TEST(VariableStateCPPTests, nothrowOnInitialized) { - std::shared_ptr ptr = std::make_shared(); - ASSERT_NO_THROW(VariableState var(ptr)); -} - -TEST(VariableStateCPPTests, throwsOnUninitializedGetLastState) { - VariableState req; - ASSERT_THROW(req.GetLastState(), InferenceEngine::NotAllocated); -} - -IE_SUPPRESS_DEPRECATED_END - TEST(VariableStateCPPTests, throwsOnUninitializedReset) { VariableState req; ASSERT_THROW(req.Reset(), InferenceEngine::NotAllocated); diff --git a/inference-engine/tests/functional/shared_test_classes/src/subgraph/concat_quantization_during_memory_requantization.cpp b/inference-engine/tests/functional/shared_test_classes/src/subgraph/concat_quantization_during_memory_requantization.cpp index b02dc5b86b7f54..729dfdb4e508ef 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/subgraph/concat_quantization_during_memory_requantization.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/subgraph/concat_quantization_during_memory_requantization.cpp @@ -104,11 +104,11 @@ namespace SubgraphTestsDefinitions { for (auto& state : states) { auto name = state.GetName(); if (name == "memory_1") { - auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state.GetLastState()->getTensorDesc(), + auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state.GetState()->getTensorDesc(), memory_1_init.data(), memory_1_init.size()); state.SetState(blob); } else if (name == "memory_2") { - auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state.GetLastState()->getTensorDesc(), + auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state.GetState()->getTensorDesc(), memory_2_init.data(), memory_2_init.size()); state.SetState(blob); } else { diff --git a/inference-engine/tests/functional/shared_test_classes/src/subgraph/memory_LSTMCell.cpp b/inference-engine/tests/functional/shared_test_classes/src/subgraph/memory_LSTMCell.cpp index bac0c293add651..291774616714a7 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/subgraph/memory_LSTMCell.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/subgraph/memory_LSTMCell.cpp @@ -280,11 +280,11 @@ namespace SubgraphTestsDefinitions { for (auto& state : states) { auto name = state.GetName(); if (name.find("cell_state_1") != std::string::npos) { - auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state.GetLastState()->getTensorDesc(), + auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state.GetState()->getTensorDesc(), cell_memory_init.data(), cell_memory_init.size()); state.SetState(blob); } else if (name.find("hidden_state_1") != std::string::npos) { - auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state.GetLastState()->getTensorDesc(), + auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state.GetState()->getTensorDesc(), hidden_memory_init.data(), hidden_memory_init.size()); state.SetState(blob); } else { diff --git a/inference-engine/tests/functional/shared_test_classes/src/subgraph/negative_memory_layer_offset.cpp b/inference-engine/tests/functional/shared_test_classes/src/subgraph/negative_memory_layer_offset.cpp index c11eff780f7275..9375b7b6baf31f 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/subgraph/negative_memory_layer_offset.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/subgraph/negative_memory_layer_offset.cpp @@ -77,7 +77,7 @@ namespace SubgraphTestsDefinitions { for (auto& state : states) { auto name = state.GetName(); if (name == "memory") { - auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state.GetLastState()->getTensorDesc(), + auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state.GetState()->getTensorDesc(), memory_init.data(), memory_init.size()); state.SetState(blob); } else { diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mock.cpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mock.cpp index 676bf59b340061..980044f8d0265d 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mock.cpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mock.cpp @@ -4,7 +4,6 @@ #include "unit_test_utils/mocks/mock_allocator.hpp" #include "unit_test_utils/mocks/mock_icnn_network.hpp" -#include "unit_test_utils/mocks/mock_ie_ivariable_state.hpp" #include "unit_test_utils/mocks/mock_iexecutable_network.hpp" #include "unit_test_utils/mocks/mock_iinfer_request.hpp" #include "unit_test_utils/mocks/mock_not_empty_icnn_network.hpp" diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_ie_ivariable_state.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_ie_ivariable_state.hpp deleted file mode 100644 index eac6fcbfa3f246..00000000000000 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_ie_ivariable_state.hpp +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include - -#include "ie_imemory_state.hpp" - -using namespace InferenceEngine; - -IE_SUPPRESS_DEPRECATED_START - -class MockIVariableState : public InferenceEngine::IVariableState { -public: - MOCK_QUALIFIED_METHOD3(GetName, const noexcept, StatusCode(char * , size_t, ResponseDesc *)); - MOCK_QUALIFIED_METHOD1(Reset, noexcept, StatusCode(ResponseDesc *)); - MOCK_QUALIFIED_METHOD2(SetState, noexcept, StatusCode(Blob::Ptr, ResponseDesc *)); - MOCK_QUALIFIED_METHOD2(GetState, const noexcept, StatusCode(Blob::CPtr &, ResponseDesc *)); -}; - -IE_SUPPRESS_DEPRECATED_END diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iexecutable_network.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iexecutable_network.hpp index 147ee892a8f1e0..a5187953206ddd 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iexecutable_network.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iexecutable_network.hpp @@ -32,7 +32,6 @@ class MockIExecutableNetwork : public IExecutableNetwork { MOCK_QUALIFIED_METHOD3(GetConfig, const noexcept, StatusCode(const std::string &name, Parameter &result, ResponseDesc *resp)); MOCK_QUALIFIED_METHOD3(GetMetric, const noexcept, StatusCode(const std::string &name, Parameter &result, ResponseDesc *resp)); MOCK_QUALIFIED_METHOD2(GetContext, const noexcept, StatusCode(RemoteContext::Ptr &pContext, ResponseDesc *resp)); - MOCK_QUALIFIED_METHOD3(QueryState, noexcept, StatusCode(IVariableState::Ptr &, size_t, ResponseDesc *)); }; IE_SUPPRESS_DEPRECATED_END diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iinfer_request.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iinfer_request.hpp index a56ad790a979ea..bac5fc7773e024 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iinfer_request.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iinfer_request.hpp @@ -35,7 +35,6 @@ class MockIInferRequest : public IInferRequest { MOCK_QUALIFIED_METHOD3(SetBlob, noexcept, StatusCode(const char*, const Blob::Ptr&, ResponseDesc*)); MOCK_QUALIFIED_METHOD4(SetBlob, noexcept, StatusCode(const char*, const Blob::Ptr&, const PreProcessInfo&, ResponseDesc*)); MOCK_QUALIFIED_METHOD2(SetBatch, noexcept, StatusCode(int batch, ResponseDesc*)); - MOCK_QUALIFIED_METHOD3(QueryState, noexcept, StatusCode(IVariableState::Ptr &, size_t, ResponseDesc *)); MOCK_QUALIFIED_METHOD1(Cancel, noexcept, InferenceEngine::StatusCode(ResponseDesc*)); }; diff --git a/inference-engine/tests/unit/inference_engine/ie_executable_network_test.cpp b/inference-engine/tests/unit/inference_engine/ie_executable_network_test.cpp index 2c35e8652dfcc0..998620c026da7f 100644 --- a/inference-engine/tests/unit/inference_engine/ie_executable_network_test.cpp +++ b/inference-engine/tests/unit/inference_engine/ie_executable_network_test.cpp @@ -13,7 +13,6 @@ #include "unit_test_utils/mocks/mock_iexecutable_network.hpp" #include "unit_test_utils/mocks/mock_iinfer_request.hpp" -#include "unit_test_utils/mocks/mock_ie_ivariable_state.hpp" #include "unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp" #include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp" #include "unit_test_utils/mocks/cpp_interfaces/interface/mock_ivariable_state_internal.hpp" From 0361e7ca73f6dc6241eedcb4623c84b46d1a0129 Mon Sep 17 00:00:00 2001 From: LuweiZhou Date: Mon, 21 Jun 2021 12:01:11 +0800 Subject: [PATCH 140/178] Migrate the unary OP visitor to typed template test. (#6181) * Migrate the unary OP visitor to typed template test. The unaray OP list is :Floor, Log, Result, Sqrt, Squeeze. Signed-off-by: Luwei Zhou * Add element precision type into GTEST typed parameter. Signed-off-by: Luwei Zhou * Update the license to new version. Signed-off-by: Luwei Zhou * Update the OP Ceiling visitor test to use unary typed template. Signed-off-by: Luwei Zhou --- ngraph/test/visitors/op/ceiling.cpp | 27 +++--------- ngraph/test/visitors/op/floor.cpp | 27 ++++-------- ngraph/test/visitors/op/log.cpp | 34 ++++----------- ngraph/test/visitors/op/result.cpp | 26 ++++-------- ngraph/test/visitors/op/sqrt.cpp | 33 ++++----------- ngraph/test/visitors/op/squeeze.cpp | 32 ++++----------- ngraph/test/visitors/op/unary_ops.hpp | 59 +++++++++++++++++++++++++++ 7 files changed, 103 insertions(+), 135 deletions(-) create mode 100644 ngraph/test/visitors/op/unary_ops.hpp diff --git a/ngraph/test/visitors/op/ceiling.cpp b/ngraph/test/visitors/op/ceiling.cpp index 34ed3b653b36ef..11e71e1e9c604e 100644 --- a/ngraph/test/visitors/op/ceiling.cpp +++ b/ngraph/test/visitors/op/ceiling.cpp @@ -2,25 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "gtest/gtest.h" +#include "unary_ops.hpp" +using Type = ::testing::Types>; -#include "ngraph/ngraph.hpp" -#include "ngraph/op/util/attr_types.hpp" -#include "ngraph/opsets/opset1.hpp" -#include "util/visitor.hpp" - -using namespace std; -using namespace ngraph; -using ngraph::test::NodeBuilder; - -TEST(attributes, ceiling_op) -{ - NodeBuilder::get_ops().register_factory(); - const auto A = make_shared(element::f32, Shape{5, 2}); - - const auto ceiling = make_shared(A); - NodeBuilder builder(ceiling); - - const auto expected_attr_count = 0; - EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); -} +INSTANTIATE_TYPED_TEST_CASE_P(visitor_without_atrribute, + UnaryOperatorVisitor, + Type, + UnaryOperatorTypeName); \ No newline at end of file diff --git a/ngraph/test/visitors/op/floor.cpp b/ngraph/test/visitors/op/floor.cpp index 57cd6011c67239..98731229010b1b 100644 --- a/ngraph/test/visitors/op/floor.cpp +++ b/ngraph/test/visitors/op/floor.cpp @@ -2,25 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "gtest/gtest.h" +#include "unary_ops.hpp" -#include "ngraph/ngraph.hpp" -#include "ngraph/op/util/attr_types.hpp" -#include "ngraph/opsets/opset1.hpp" -#include "util/visitor.hpp" +using Types = ::testing::Types, + UnaryOperatorType>; -using namespace std; -using namespace ngraph; -using ngraph::test::NodeBuilder; - -TEST(attributes, floor_op) -{ - NodeBuilder::get_ops().register_factory(); - const auto A = make_shared(element::f32, Shape{5, 2}); - - const auto floor = make_shared(A); - NodeBuilder builder(floor); - - const auto expected_attr_count = 0; - EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); -} +INSTANTIATE_TYPED_TEST_CASE_P(visitor_without_atrribute, + UnaryOperatorVisitor, + Types, + UnaryOperatorTypeName); \ No newline at end of file diff --git a/ngraph/test/visitors/op/log.cpp b/ngraph/test/visitors/op/log.cpp index 02d6293871c028..5acb4971ba81f2 100644 --- a/ngraph/test/visitors/op/log.cpp +++ b/ngraph/test/visitors/op/log.cpp @@ -1,29 +1,11 @@ // Copyright (C) 2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // - -#include "gtest/gtest.h" - -#include "ngraph/ngraph.hpp" -#include "ngraph/op/util/attr_types.hpp" -#include "ngraph/opsets/opset1.hpp" - -#include "util/visitor.hpp" - -using namespace std; -using namespace ngraph; -using ngraph::test::NodeBuilder; - -TEST(attributes, log_op) -{ - using namespace opset1; - - NodeBuilder::get_ops().register_factory(); - const auto data_input = make_shared(element::f32, Shape{1, 2, 3}); - const auto op = make_shared(data_input); - - NodeBuilder builder(op); - const auto expected_attr_count = 0; - - EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); -} \ No newline at end of file +#include "unary_ops.hpp" +using Types = ::testing::Types, + UnaryOperatorType>; + +INSTANTIATE_TYPED_TEST_CASE_P(visitor_without_atrribute, + UnaryOperatorVisitor, + Types, + UnaryOperatorTypeName); \ No newline at end of file diff --git a/ngraph/test/visitors/op/result.cpp b/ngraph/test/visitors/op/result.cpp index 528d1ee50cfe54..df01ad5f913371 100644 --- a/ngraph/test/visitors/op/result.cpp +++ b/ngraph/test/visitors/op/result.cpp @@ -2,24 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" -#include "ngraph/opsets/opset1.hpp" -#include "util/visitor.hpp" +#include "unary_ops.hpp" -using namespace std; -using namespace ngraph; -using ngraph::test::NodeBuilder; -using ngraph::test::ValueMap; +using Types = ::testing::Types, + UnaryOperatorType>; -TEST(attributes, result) -{ - NodeBuilder::get_ops().register_factory(); - const auto data_node = make_shared(element::f32, Shape{1}); - const auto result = make_shared(data_node); - - NodeBuilder builder(result); - const auto expected_attr_count = 0; - - EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); -} +INSTANTIATE_TYPED_TEST_CASE_P(visitor_without_atrribute, + UnaryOperatorVisitor, + Types, + UnaryOperatorTypeName); \ No newline at end of file diff --git a/ngraph/test/visitors/op/sqrt.cpp b/ngraph/test/visitors/op/sqrt.cpp index 23bc0035390c81..5e26c542348dbf 100644 --- a/ngraph/test/visitors/op/sqrt.cpp +++ b/ngraph/test/visitors/op/sqrt.cpp @@ -2,28 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "gtest/gtest.h" - -#include "ngraph/ngraph.hpp" -#include "ngraph/op/util/attr_types.hpp" -#include "ngraph/opsets/opset1.hpp" - -#include "util/visitor.hpp" - -using namespace std; -using namespace ngraph; -using ngraph::test::NodeBuilder; - -TEST(attributes, sqrt_op) -{ - using namespace opset1; - - NodeBuilder::get_ops().register_factory(); - const auto data_input = make_shared(element::f32, Shape{1, 2, 3}); - const auto op = make_shared(data_input); - - NodeBuilder builder(op); - const auto expected_attr_count = 0; - - EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); -} +#include "unary_ops.hpp" +using Types = ::testing::Types, + UnaryOperatorType>; + +INSTANTIATE_TYPED_TEST_CASE_P(visitor_without_atrribute, + UnaryOperatorVisitor, + Types, + UnaryOperatorTypeName); \ No newline at end of file diff --git a/ngraph/test/visitors/op/squeeze.cpp b/ngraph/test/visitors/op/squeeze.cpp index feed9fcdf9be81..a8b0c2c488c1ab 100644 --- a/ngraph/test/visitors/op/squeeze.cpp +++ b/ngraph/test/visitors/op/squeeze.cpp @@ -2,27 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "gtest/gtest.h" - -#include "ngraph/ngraph.hpp" -#include "ngraph/op/util/attr_types.hpp" -#include "ngraph/opsets/opset1.hpp" - -#include "util/visitor.hpp" - -using namespace std; -using namespace ngraph; -using ngraph::test::NodeBuilder; -using ngraph::test::ValueMap; - -TEST(attributes, squeeze_op) -{ - NodeBuilder::get_ops().register_factory(); - const auto data_node = make_shared(element::f32, Shape{1}); - const auto squeeze = make_shared(data_node); - - NodeBuilder builder(squeeze); - const auto expected_attr_count = 0; - - EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); -} +#include "unary_ops.hpp" +using Types = ::testing::Types, + UnaryOperatorType>; + +INSTANTIATE_TYPED_TEST_CASE_P(visitor_without_atrribute, + UnaryOperatorVisitor, + Types, + UnaryOperatorTypeName); \ No newline at end of file diff --git a/ngraph/test/visitors/op/unary_ops.hpp b/ngraph/test/visitors/op/unary_ops.hpp new file mode 100644 index 00000000000000..16764c42a7c2cc --- /dev/null +++ b/ngraph/test/visitors/op/unary_ops.hpp @@ -0,0 +1,59 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" + +#include "ngraph/op/util/attr_types.hpp" +#include "util/visitor.hpp" + +using namespace ngraph; +using ngraph::test::NodeBuilder; +template +class UnaryOperatorType +{ +public: + using op_type = T; + static constexpr element::Type_t element_type = ELEMENT_TYPE; +}; +template +class UnaryOperatorVisitor : public testing::Test +{ +}; + +class UnaryOperatorTypeName +{ +public: + template + static std::string GetName(int) + { + using OP_Type = typename T::op_type; + constexpr element::Type precision(T::element_type); + const ngraph::Node::type_info_t typeinfo = OP_Type::get_type_info_static(); + std::string op_name{typeinfo.name}; + op_name.append("_"); + return (op_name.append(precision.get_type_name())); + } +}; + +TYPED_TEST_CASE_P(UnaryOperatorVisitor); + +TYPED_TEST_P(UnaryOperatorVisitor, No_Attribute_4D) +{ + using OP_Type = typename TypeParam::op_type; + const element::Type_t element_type = TypeParam::element_type; + + NodeBuilder::get_ops().register_factory(); + const auto A = std::make_shared(element_type, PartialShape{2, 2, 2, 2}); + + const auto op_func = std::make_shared(A); + NodeBuilder builder(op_func); + const auto expected_attr_count = 0; + EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); +} + +REGISTER_TYPED_TEST_CASE_P(UnaryOperatorVisitor, No_Attribute_4D); From 6239ff8a1c4146d8c2ed2dffc87ac46613bb6387 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 21 Jun 2021 08:27:15 +0300 Subject: [PATCH 141/178] Removed deprecated documentation (#6253) * Removed deprecated documentation * Removed snippets --- docs/IE_DG/Migration_CoreAPI.md | 70 ------------------------- docs/IE_DG/OnnxImporterTutorial.md | 67 ----------------------- docs/IE_DG/supported_plugins/FPGA.md | 22 -------- docs/doxygen/doxygen-ignore.txt | 2 + docs/doxygen/ie_docs.xml | 3 -- docs/snippets/CMakeLists.txt | 11 ---- docs/snippets/Migration_CoreAPI.cpp | 48 ----------------- docs/snippets/OnnxImporterTutorial0.cpp | 19 ------- docs/snippets/OnnxImporterTutorial1.cpp | 15 ------ docs/snippets/OnnxImporterTutorial2.cpp | 29 ---------- docs/snippets/OnnxImporterTutorial3.cpp | 12 ----- 11 files changed, 2 insertions(+), 296 deletions(-) delete mode 100644 docs/IE_DG/Migration_CoreAPI.md delete mode 100644 docs/IE_DG/OnnxImporterTutorial.md delete mode 100644 docs/IE_DG/supported_plugins/FPGA.md delete mode 100644 docs/snippets/Migration_CoreAPI.cpp delete mode 100644 docs/snippets/OnnxImporterTutorial0.cpp delete mode 100644 docs/snippets/OnnxImporterTutorial1.cpp delete mode 100644 docs/snippets/OnnxImporterTutorial2.cpp delete mode 100644 docs/snippets/OnnxImporterTutorial3.cpp diff --git a/docs/IE_DG/Migration_CoreAPI.md b/docs/IE_DG/Migration_CoreAPI.md deleted file mode 100644 index d49bd425bc87c6..00000000000000 --- a/docs/IE_DG/Migration_CoreAPI.md +++ /dev/null @@ -1,70 +0,0 @@ -[DEPRECATED] Migration from Inference Engine Plugin API to Core API {#openvino_docs_IE_DG_Migration_CoreAPI} -=============================== - -For 2019 R2 Release, the new Inference Engine Core API is introduced. This guide is updated to reflect the new API approach. The Inference Engine Plugin API is still supported, but is going to be deprecated in future releases. - -This section provides common steps to migrate your application written using the Inference Engine Plugin API (`InferenceEngine::InferencePlugin`) to the Inference Engine Core API (`InferenceEngine::Core`). - -To learn how to write a new application using the Inference Engine, refer to [Integrate the Inference Engine Request API with Your Application](Integrate_with_customer_application_new_API.md) and [Inference Engine Samples Overview](Samples_Overview.md). - -## Inference Engine Core Class - -The Inference Engine Core class is implemented on top existing Inference Engine Plugin API and handles plugins internally. -The main responsibility of the `InferenceEngine::Core` class is to hide plugin specifics inside and provide a new layer of abstraction that works with devices (`InferenceEngine::Core::GetAvailableDevices`). Almost all methods of this class accept `deviceName` as an additional parameter that denotes an actual device you are working with. Plugins are listed in the `plugins.xml` file, which is loaded during constructing `InferenceEngine::Core` objects: - -```bash - - - - - ... - -``` - -## Migration Steps - -Common migration process includes the following steps: - -1. Migrate from the `InferenceEngine::InferencePlugin` initialization: - -@snippet snippets/Migration_CoreAPI.cpp part0 - -to the `InferenceEngine::Core` class initialization: - -@snippet snippets/Migration_CoreAPI.cpp part1 - -2. Instead of using `InferenceEngine::CNNNetReader` to read IR: - -@snippet snippets/Migration_CoreAPI.cpp part2 - -read networks using the Core class: - -@snippet snippets/Migration_CoreAPI.cpp part3 - -The Core class also allows reading models from the ONNX format (more information is [here](./ONNX_Support.md)): - -@snippet snippets/Migration_CoreAPI.cpp part4 - -3. Instead of adding CPU device extensions to the plugin: - -@snippet snippets/Migration_CoreAPI.cpp part5 - -add extensions to CPU device using the Core class: - -@snippet snippets/Migration_CoreAPI.cpp part6 - -4. Instead of setting configuration keys to a particular plugin, set (key, value) pairs via `InferenceEngine::Core::SetConfig` - -@snippet snippets/Migration_CoreAPI.cpp part7 - -> **NOTE**: If `deviceName` is omitted as the last argument, configuration is set for all Inference Engine devices. - -5. Migrate from loading the network to a particular plugin: - -@snippet snippets/Migration_CoreAPI.cpp part8 - -to `InferenceEngine::Core::LoadNetwork` to a particular device: - -@snippet snippets/Migration_CoreAPI.cpp part9 - -After you have an instance of `InferenceEngine::ExecutableNetwork`, all other steps are as usual. diff --git a/docs/IE_DG/OnnxImporterTutorial.md b/docs/IE_DG/OnnxImporterTutorial.md deleted file mode 100644 index f4538633a7e805..00000000000000 --- a/docs/IE_DG/OnnxImporterTutorial.md +++ /dev/null @@ -1,67 +0,0 @@ -# ONNX* Importer API Tutorial {#openvino_docs_IE_DG_OnnxImporterTutorial} - -> **NOTE**: This tutorial is deprecated. Since OpenVINO™ 2020.4 version, Inference Engine enables reading ONNX models via the Inference Engine Core API -> and there is no need to use directly the low-level ONNX* Importer API anymore. -> To read ONNX\* models, it's recommended to use the `Core::ReadNetwork()` method that provide a uniform way to read models from IR or ONNX format. - -This tutorial demonstrates how to use the ONNX\* Importer API. -This API makes it possible to create an nGraph `Function` object from an imported ONNX model. - -All functions of the ONNX Importer API are in the [onnx.hpp][onnx_header] header file. - -Two categories of API functions: -* Helper functions that check which ONNX ops are supported in a current version of the ONNX Importer -* Functions that read ONNX models from a stream or file and result in an nGraph function, which can be executed using the Inference Engine - -## Check Which ONNX Ops Are Supported - -To list all supported ONNX ops in a specific version and domain, use the `get_supported_operators` -as shown in the example below: - -@snippet snippets/OnnxImporterTutorial0.cpp part0 - -The above code produces a list of all the supported operators for the `version` and `domain` you specified and outputs a list similar to this: -```cpp -Abs -Acos -... -Xor -``` - -To determine whether a specific ONNX operator in a particular version and domain is supported by the importer, use the `is_operator_supported` function as shown in the example below: - -@snippet snippets/OnnxImporterTutorial1.cpp part1 - -## Import ONNX Model - -To import an ONNX model, use the `import_onnx_model` function. -The method has two overloads: -* `import_onnx_model` takes a stream as an input, for example, file stream, memory stream -* `import_onnx_model` takes a file path as an input - -Refer to the sections below for details. - -> **NOTE**: The examples below use the ONNX ResNet50 model, which is available at the [ONNX Model Zoo][onnx_model_zoo]: -> ```bash -> $ wget https://s3.amazonaws.com/download.onnx/models/opset_8/resnet50.tar.gz -> $ tar -xzvf resnet50.tar.gz -> ``` - -Once you create the `ng_function`, you can use it to run computation on the Inference Engine. -As it was shown in [Build a Model with nGraph Library](../nGraph_DG/build_function.md), `std::shared_ptr` can be transformed into a `CNNNetwork`. - - -### Stream as Input - -The code below shows how to convert the ONNX ResNet50 model to the nGraph function using `import_onnx_model` with the stream as an input: - -@snippet snippets/OnnxImporterTutorial2.cpp part2 - -### Filepath as Input - -The code below shows how to convert the ONNX ResNet50 model to the nGraph function using `import_onnx_model` with the filepath as an input: - -@snippet snippets/OnnxImporterTutorial3.cpp part3 - -[onnx_header]: https://github.com/NervanaSystems/ngraph/blob/master/src/ngraph/frontend/onnx_import/onnx.hpp -[onnx_model_zoo]: https://github.com/onnx/models diff --git a/docs/IE_DG/supported_plugins/FPGA.md b/docs/IE_DG/supported_plugins/FPGA.md deleted file mode 100644 index 63ae6e62ed7be0..00000000000000 --- a/docs/IE_DG/supported_plugins/FPGA.md +++ /dev/null @@ -1,22 +0,0 @@ -FPGA Plugin {#openvino_docs_IE_DG_supported_plugins_FPGA} -=========== - -## Product Change Notice -Intel® Distribution of OpenVINO™ toolkit for Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA and the Intel® Programmable Acceleration Card with Intel® Arria® 10 GX FPGA - -
OperationOperation{{ d }}{{ d }}
- - - - - - - - -
Change Notice BeginsJuly 2020
Change DateOctober 2020
- -Intel will be transitioning to the next-generation programmable deep-learning solution based on FPGAs in order to increase the level of customization possible in FPGA deep-learning. As part of this transition, future standard releases (i.e., non-LTS releases) of Intel® Distribution of OpenVINO™ toolkit will no longer include the Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA and the Intel® Programmable Acceleration Card with Intel® Arria® 10 GX FPGA. - -Intel® Distribution of OpenVINO™ toolkit 2020.3.X LTS release will continue to support Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA and the Intel® Programmable Acceleration Card with Intel® Arria® 10 GX FPGA. For questions about next-generation programmable deep-learning solutions based on FPGAs, please talk to your sales representative or contact us to get the latest FPGA updates. - -For documentation for the FPGA plugin available in previous releases of Intel® Distribution of OpenVINO™ toolkit with FPGA Support, see documentation for the [2020.4 version](https://docs.openvinotoolkit.org/2020.4/openvino_docs_IE_DG_supported_plugins_FPGA.html) and lower. \ No newline at end of file diff --git a/docs/doxygen/doxygen-ignore.txt b/docs/doxygen/doxygen-ignore.txt index 0be7a70dc06342..7f963ac63e71de 100644 --- a/docs/doxygen/doxygen-ignore.txt +++ b/docs/doxygen/doxygen-ignore.txt @@ -22,6 +22,8 @@ inference-engine/include/vpu/vpu_config.hpp inference-engine/include/vpu/vpu_plugin_config.hpp openvino/docs/benchmarks/performance_int8_vs_fp32.md openvino/docs/get_started/get_started_macos.md +openvino/docs/optimization_guide/dldt_optimization_guide.md +openvino/docs/IE_DG/ShapeInference.md inference-engine/include/details/ie_so_pointer.hpp inference-engine/include/ie_compound_blob.h inference-engine/include/ie_data.h diff --git a/docs/doxygen/ie_docs.xml b/docs/doxygen/ie_docs.xml index 120492baef0c2d..b8581444627662 100644 --- a/docs/doxygen/ie_docs.xml +++ b/docs/doxygen/ie_docs.xml @@ -291,11 +291,9 @@ limitations under the License. - - @@ -311,7 +309,6 @@ limitations under the License. - diff --git a/docs/snippets/CMakeLists.txt b/docs/snippets/CMakeLists.txt index 1d2a20eea0a3d7..48edae1e832547 100644 --- a/docs/snippets/CMakeLists.txt +++ b/docs/snippets/CMakeLists.txt @@ -26,17 +26,6 @@ if(NOT OpenCV_FOUND) "${CMAKE_CURRENT_SOURCE_DIR}/ShapeInference.cpp") endif() -# ONNX importer related files -if(NOT NGRAPH_ONNX_IMPORT_ENABLE) - list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/OnnxImporterTutorial0.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/OnnxImporterTutorial1.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/OnnxImporterTutorial2.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/OnnxImporterTutorial3.cpp") -endif() - -# remove snippets for deprecated / removed API -list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/Migration_CoreAPI.cpp") - # requires mfxFrameSurface1 and MSS API list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/dldt_optimization_guide2.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/dldt_optimization_guide3.cpp" diff --git a/docs/snippets/Migration_CoreAPI.cpp b/docs/snippets/Migration_CoreAPI.cpp deleted file mode 100644 index fd89803093b307..00000000000000 --- a/docs/snippets/Migration_CoreAPI.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include - -int main() { -std::string deviceName = "Device name"; -//! [part0] -InferenceEngine::InferencePlugin plugin = InferenceEngine::PluginDispatcher({ FLAGS_pp }).getPluginByDevice(FLAGS_d); -//! [part0] - -//! [part1] -InferenceEngine::Core core; -//! [part1] - -//! [part2] -InferenceEngine::CNNNetReader network_reader; -network_reader.ReadNetwork(fileNameToString(input_model)); -network_reader.ReadWeights(fileNameToString(input_model).substr(0, input_model.size() - 4) + ".bin"); -InferenceEngine::CNNNetwork network = network_reader.getNetwork(); -//! [part2] - -//! [part3] -InferenceEngine::CNNNetwork network = core.ReadNetwork(input_model); -//! [part3] - -//! [part4] -InferenceEngine::CNNNetwork network = core.ReadNetwork("model.onnx"); -//! [part4] - -//! [part5] -plugin.AddExtension(std::make_shared()); -//! [part5] - -//! [part6] -core.AddExtension(std::make_shared(), "CPU"); -//! [part6] - -//! [part7] -core.SetConfig({{PluginConfigParams::KEY_CONFIG_FILE, FLAGS_c}}, "GPU"); -//! [part7] - -//! [part8] -auto execNetwork = plugin.LoadNetwork(network, { }); -//! [part8] - -//! [part9] -auto execNetwork = core.LoadNetwork(network, deviceName, { }); -//! [part9] -return 0; -} diff --git a/docs/snippets/OnnxImporterTutorial0.cpp b/docs/snippets/OnnxImporterTutorial0.cpp deleted file mode 100644 index cf434622cb9395..00000000000000 --- a/docs/snippets/OnnxImporterTutorial0.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include -#include "onnx_import/onnx.hpp" -#include -#include - -int main() { -//! [part0] -const std::int64_t version = 12; -const std::string domain = "ai.onnx"; -const std::set supported_ops = ngraph::onnx_import::get_supported_operators(version, domain); - -for(const auto& op : supported_ops) -{ - std::cout << op << std::endl; -} -//! [part0] -return 0; -} diff --git a/docs/snippets/OnnxImporterTutorial1.cpp b/docs/snippets/OnnxImporterTutorial1.cpp deleted file mode 100644 index 60122f1a1ea025..00000000000000 --- a/docs/snippets/OnnxImporterTutorial1.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include "onnx_import/onnx.hpp" - -int main() { -//! [part1] -const std::string op_name = "Abs"; -const std::int64_t version = 12; -const std::string domain = "ai.onnx"; -const bool is_abs_op_supported = ngraph::onnx_import::is_operator_supported(op_name, version, domain); - -std::cout << "Abs in version 12, domain `ai.onnx`is supported: " << (is_abs_op_supported ? "true" : "false") << std::endl; -//! [part1] -return 0; -} diff --git a/docs/snippets/OnnxImporterTutorial2.cpp b/docs/snippets/OnnxImporterTutorial2.cpp deleted file mode 100644 index 00ce2949a1d163..00000000000000 --- a/docs/snippets/OnnxImporterTutorial2.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -#include "onnx_import/onnx.hpp" -#include -#include - -int main() { -//! [part2] - const char * resnet50_path = "resnet50/model.onnx"; - std::ifstream resnet50_stream(resnet50_path); - if (resnet50_stream.is_open()) - { - try - { - const std::shared_ptr ng_function = ngraph::onnx_import::import_onnx_model(resnet50_stream); - - // Check shape of the first output, for example - std::cout << ng_function->get_output_shape(0) << std::endl; - // The output is Shape{1, 1000} - } - catch (const ngraph::ngraph_error& error) - { - std::cout << "Error when importing ONNX model: " << error.what() << std::endl; - } - } - resnet50_stream.close(); -//! [part2] -return 0; -} diff --git a/docs/snippets/OnnxImporterTutorial3.cpp b/docs/snippets/OnnxImporterTutorial3.cpp deleted file mode 100644 index 6fc1e1b59de907..00000000000000 --- a/docs/snippets/OnnxImporterTutorial3.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include -#include "onnx_import/onnx.hpp" -#include - -int main() { -//! [part3] -const char * resnet50_path = "resnet50/model.onnx"; -const std::shared_ptr ng_function = ngraph::onnx_import::import_onnx_model(resnet50_path); -//! [part3] -return 0; -} From 487aff7d7ed98bcc0684ada35cdd3a04e120a94f Mon Sep 17 00:00:00 2001 From: Eugeny Volosenkov Date: Mon, 21 Jun 2021 09:53:09 +0300 Subject: [PATCH 142/178] [Attention OCR] Document model support (#6153) * Add doc How to convert AttentionOCR * Add converting * Add converting 2 * Add converting 3 * Fix document * Fix document1 * Fix document1 * Fix document1 * Fix ie_docs * Fix model/path * Add link to Convert_Model_From_TensorFlow.md * fix doc * Fix documentation --- .../Convert_Model_From_TensorFlow.md | 2 +- .../Convert_AttentionOCR_From_Tensorflow.md | 35 +++++++++++++++++++ docs/doxygen/ie_docs.xml | 1 + 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 docs/MO_DG/prepare_model/convert_model/tf_specific/Convert_AttentionOCR_From_Tensorflow.md diff --git a/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_TensorFlow.md b/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_TensorFlow.md index c4721cdead07ee..7e29a7668b2f24 100644 --- a/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_TensorFlow.md +++ b/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_TensorFlow.md @@ -161,7 +161,7 @@ Where `HEIGHT` and `WIDTH` are the input images height and width for which the m * [GNMT](https://github.com/tensorflow/nmt) topology can be converted using [these instructions](tf_specific/Convert_GNMT_From_Tensorflow.md). * [BERT](https://github.com/google-research/bert) topology can be converted using [these instructions](tf_specific/Convert_BERT_From_Tensorflow.md). * [XLNet](https://github.com/zihangdai/xlnet) topology can be converted using [these instructions](tf_specific/Convert_XLNet_From_Tensorflow.md). - +* [Attention OCR](https://github.com/emedvedev/attention-ocr) topology can be converted using [these instructions](tf_specific/Convert_AttentionOCR_From_Tensorflow.md). ## Loading Non-Frozen Models to the Model Optimizer diff --git a/docs/MO_DG/prepare_model/convert_model/tf_specific/Convert_AttentionOCR_From_Tensorflow.md b/docs/MO_DG/prepare_model/convert_model/tf_specific/Convert_AttentionOCR_From_Tensorflow.md new file mode 100644 index 00000000000000..90e94677dd7f33 --- /dev/null +++ b/docs/MO_DG/prepare_model/convert_model/tf_specific/Convert_AttentionOCR_From_Tensorflow.md @@ -0,0 +1,35 @@ +# Convert TensorFlow* Attention OCR Model to Intermediate Representation {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_AttentionOCR_From_Tensorflow} + +This tutorial explains how to convert the Attention OCR (AOCR) model from the [TensorFlow* Attention OCR repository](https://github.com/emedvedev/attention-ocr) to the Intermediate Representation (IR). + +## Extract Model from `aocr` Library + +The easiest way to get an AOCR model is to download `aocr` Python\* library: +``` +pip install git+https://github.com/emedvedev/attention-ocr.git@master#egg=aocr +``` +This library contains a pretrained model and allows to train and run AOCR using the command line. After installing `aocr`, you can extract the model: +``` +aocr export --format=frozengraph model/path/ +``` +After this step you can find the model in model/path/ folder. + +## Convert the TensorFlow* AOCR Model to IR + +The original AOCR model contains data preprocessing which consists of the following steps: +* Decoding input data to binary format where input data is an image represented as a string. +* Resizing binary image to working resolution. + +After that, the resized image is sent to the convolution neural network (CNN). The Model Optimizer does not support image decoding so you should cut of preprocessing part of the model using '--input' command line parameter. +```sh +python3 path/to/model_optimizer/mo_tf.py \ +--input_model=model/path/frozen_graph.pb \ +--input="map/TensorArrayStack/TensorArrayGatherV3:0[1 32 86 1]" \ +--output "transpose_1,transpose_2" \ +--output_dir path/to/ir/ +``` + +Where: +* `map/TensorArrayStack/TensorArrayGatherV3:0[1 32 86 1]` - name of node producing tensor after preprocessing. +* `transpose_1` - name of the node producing tensor with predicted characters. +* `transpose_2` - name of the node producing tensor with predicted characters probabilties \ No newline at end of file diff --git a/docs/doxygen/ie_docs.xml b/docs/doxygen/ie_docs.xml index b8581444627662..8841672b430623 100644 --- a/docs/doxygen/ie_docs.xml +++ b/docs/doxygen/ie_docs.xml @@ -41,6 +41,7 @@ limitations under the License. + From cd0ded7ee39ad47f42ad204f910b5d6871fc643a Mon Sep 17 00:00:00 2001 From: Alina Kladieva Date: Mon, 21 Jun 2021 12:38:49 +0300 Subject: [PATCH 143/178] Exclude test failing on Ubuntu20 precommit scope (#6202) --- .../myriad/shared_tests_instances/skip_tests_config.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/skip_tests_config.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/skip_tests_config.cpp index fc2b4b2d69b686..7badf1a9677a63 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/skip_tests_config.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/skip_tests_config.cpp @@ -44,6 +44,8 @@ std::vector disabledTestPatterns() { R"(.*IS=\(16\.16\.96\)\(96\)_eltwiseOpType=FloorMod_secondaryInputType=PARAMETER_opType=VECTOR_netPRC=FP32.*)", // TODO: Issue CVS-57108 R"(.*QueryNetworkHETEROWithMULTINoThrow_V10.*)", - R"(.*QueryNetworkMULTIWithHETERONoThrow_V10.*)" + R"(.*QueryNetworkMULTIWithHETERONoThrow_V10.*)", + // TODO: Issue CVS-58162 + R"(.*HoldersTestOnImportedNetwork\.CreateRequestWithCoreRemoved.*)" }; } From d71ac2e2c151557a740d87cb2e575a420a617994 Mon Sep 17 00:00:00 2001 From: Irina Burgun Date: Mon, 21 Jun 2021 13:07:34 +0300 Subject: [PATCH 144/178] Added filters block to report template (#6201) --- .../layer_tests_summary/summarize.py | 1 + .../layer_tests_summary/template/filters.js | 209 ++++++++++++++++ .../template/report_template.html | 236 +++++++++++------- .../layer_tests_summary/template/style.css | 88 +++++++ 4 files changed, 439 insertions(+), 95 deletions(-) create mode 100644 inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/template/filters.js create mode 100644 inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/template/style.css diff --git a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/summarize.py b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/summarize.py index 4419c4ffeb89ad..1245ae8a0fb9bf 100644 --- a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/summarize.py +++ b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/summarize.py @@ -126,6 +126,7 @@ def collect_statistic(root: ET.Element, is_conformance_mode: bool): pass_rate_avg[device.tag] = round(float(pass_rate_avg[device.tag]), 1) general_pass_rate[device.tag] = general_passed_tests[device.tag] * 100 / general_test_count[device.tag] general_pass_rate[device.tag] = round(float(general_pass_rate[device.tag]), 1) + trusted_ops[device.tag] = round(float(trusted_ops[device.tag] * 100 / len(results[device.tag])), 1) logger.info("Test number comparison between devices is started") for op in op_res: diff --git a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/template/filters.js b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/template/filters.js new file mode 100644 index 00000000000000..af832efa3cfb3b --- /dev/null +++ b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/template/filters.js @@ -0,0 +1,209 @@ +deviceList = []; +$(document).ready(function () { + var opsets = {}; + LoadOpsetNumbers(); + LoadDevices(); + + $("#filters").submit(function (event) { + event.preventDefault(); + filterTable(); + }); + $('#reset').click(function () { + $('#opsetNumber').val(0); + $('#operationName').val(''); + $('#status').prop("disabled", true).val(0); + $('#devices').val(0); + $('#references').val(0); + filterTable(); + }); + $('#devices').on('change', function () { + if (this.value == 0) { + $('#status').prop("disabled", true).val(0); + } else { + $('#status').prop("disabled", false); + }; + }); + +}); + +function LoadOpsetNumbers() { + var data = []; + + $('#data th[scope="row"]').each(function () { + + num = $(this).text().split("-")[1]; + if (data.indexOf(num) < 0) { + data.push(num); + } + }); + data.sort(); + data = $.map(data, function (item) { + return ""; + }); + $("#opsetNumber").html(''); + $("#opsetNumber").append(data.join("")); +} + +function LoadDevices() { + var data = []; + + $('.table-dark.device').each(function () { + if (data.indexOf($(this).text()) < 0) { + data.push($(this).text()); + } + }); + data.sort(); + deviceList = data; + data = $.map(data, function (item) { + return ""; + }); + $("#devices").html(''); + $("#devices").append(data.join("")); +} + +function filterTable() { + device = $("#devices").val(); + if (device == 0) { + $("#report td.value, #report td.table-secondary, #report td.table-primary, #report th.table-dark.device").show(); + } else { + $("#report td.value, #report td.table-secondary, #report td.table-primary, #report th.table-dark.device").filter(function () { + $(this).toggle($(this).hasClass(device)) + }); + } + opsetNumber = $("#opsetNumber").val(); + operationName = $('#operationName').val().trim(); + status = $('#status').val(); + references = $('#references').val(); + + $("#report #data tr").show(); + $('#report').show(); + $('#message').hide(); + if (opsetNumber != 0) { + $("#report #data tr").filter(function () { + $(this).toggle(checkVersion($(this), opsetNumber)); + }); + } + + if (operationName) { + $("#report #data tr:not(:hidden)").filter(function () { + $(this).toggle($(this).find('th').text().split("-")[0].toLowerCase().indexOf(operationName.toLowerCase()) > -1); + }); + } + + if (references != 0) { + if (references == 'nv') { + $("#report #data tr:not(:hidden)").filter(function () { + $(this).toggle($(this).find('th').hasClass("colorRed")) + }); + } else { + $("#report #data tr:not(:hidden)").filter(function () { + $(this).toggle(!$(this).find('th').hasClass("colorRed")); + }); + } + } + if (status != 0) { + if (status == 'p') { + $("#report #data tr:not(:hidden)").filter(function () { + $(this).toggle($(this).find('.value:visible[crashed="0"][failed="0"][skipped="0"]').length > 0) + }); + } else if (status == 'f') { + $("#report #data tr:not(:hidden)").filter(function () { + $(this).toggle($(this).find('.value:visible[passed="0"][crashed="0"][skipped="0"]').length > 0) + }); + } else if (status == 'c') { + $("#report #data tr:not(:hidden)").filter(function () { + $(this).toggle($(this).find('.value:visible[passed="0"][failed="0"][skipped="0"]').length > 0) + }); + } else if (status == 's') { + $("#report #data tr:not(:hidden)").filter(function () { + $(this).toggle($(this).find('.value:visible[passed="0"][failed="0"][crashed="0"]').length > 0) + }); + } else { // No tests + + $("#report #data tr:not(:hidden)").filter(function () { + $(this).toggle($(this).find('.table-secondary:visible').length > 0) + }); + } + } + + + if ($("#report #data tr").length == $("#report #data tr:hidden").length) { + $('#report').hide(); + $('#message').show(); + } else { + calculateStatistics(device); + } +} + +function checkVersion(element, opsetNumber) { + var name = element.find('th').text().split("-")[0]; + var version = element.find('th').text().split("-")[1]; + if (version > opsetNumber) { + return false; + } else { + var versions = []; + $('#report #data tr th[name^="' + name + '-"]').each(function () { + if ($(this).text().split('-')[1] <= opsetNumber) { + versions.push(+$(this).text().split('-')[1]); + } + }); + return version == Math.max.apply(null, versions); + } +} + +function calculateStatistics() { + if (device != 0) { + calculateColumnStatistics(device); + } else { + deviceList.map((el) => calculateColumnStatistics(el)) + } +} + +function calculateColumnStatistics(device) { + // total + total = $("#report #data tr:not(:hidden)").length; + $('#statistic .table-primary[scope="row"] i').text(total); + // trusted op + count_trasted_op = $("#report #data tr:not(:hidden) ." + device + ".value[value^='100'][crashed='0'][failed='0'][skipped='0']").length; + all_operations = $("#report #data tr:not(:hidden) .value." + device).length; + if (!all_operations) { + trasted_op = "---"; + } else { + trasted_op = (count_trasted_op * 100 / all_operations).toFixed(1) + ' %'; + } + $('#statistic .table-primary.' + device + '.trusted-ops').text(trasted_op); + $('#statistic .table-primary.' + device + '.test_total').text(all_operations || 0); + + // tested op_counter + tested_op_count = 0; + passed_tested_op_count = 0; + $("#report #data tr:not(:hidden) ." + device + ".value span").each(function () { + text = $(this).text().split(':')[1]; + if ($(this).hasClass('green')) { + passed_tested_op_count += +text; + } + tested_op_count += +text; + }); + + // General Pass Rate + if (tested_op_count == 0) { + $('#statistic .table-primary.' + device + '.general_pass_rate').text('---'); + + } else { + general_pass_rate = (passed_tested_op_count * 100 / tested_op_count).toFixed(1) + ' %'; + $('#statistic .table-primary.' + device + '.general_pass_rate').text(general_pass_rate); + } + $('#statistic .table-primary.' + device + '.tested-ops_count').text(tested_op_count); + + // AVG Pass Rate + sum_pass_rate = 0; + $("#report #data tr:not(:hidden) ." + device + ".value").each(function () { + sum_pass_rate += +$(this).attr('value'); + }); + if (all_operations == 0) { + $('#statistic .table-primary.' + device + '.avg_pass_rate').text('---'); + } else { + avg_pass_rate = (sum_pass_rate / all_operations).toFixed(1) + ' %'; + $('#statistic .table-primary.' + device + '.avg_pass_rate').text(avg_pass_rate); + } +} diff --git a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/template/report_template.html b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/template/report_template.html index 7d6f751f91701a..12bb09fcd8167c 100644 --- a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/template/report_template.html +++ b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/template/report_template.html @@ -1,5 +1,6 @@ + @@ -7,106 +8,151 @@ - + integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> + + + Report + - - - - +
+

Operations coverage summary: {{report_tag}} {{ timestamp }}

+
+
+ Acosh-4Not verified Ngraph references +
+ +
+ Collected statistic info +
+
+ N/ANo Tests +
+
+ Status: + P:85Passed + F:0Failed + S:2Skipped + C:0Crashed +
+
+
+ +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ -
-

Operations coverage summary: {{report_tag}} {{ timestamp }}

-
- - - - - - - - - - - -
"Operation_name"-"opset_version" Not verified Ngraph references
Collected statistic info
- - - - - {% for d in devices -%} - - {% endfor %} - - - - - - {% for d in devices -%} - - {% endfor %} - - - - {% for d in devices -%} - - {% endfor %} - - - - {% for d in devices -%} - - {% endfor %} - - - - {% for d in devices -%} - - {% endfor %} - - - - {% for d in devices -%} - - {% endfor %} - - - - {% for op in ordered_ops -%} - - {% if op in verified_operations -%} - - {% else -%} - - {% endif -%} - {% for d in devices -%} - {% if op in results[d] -%} - - {% else -%} - - {% endif -%} +
+ + +
+ + + + - {% endfor %} - - {% endfor -%} + +
Operation{{ d }}
Total: {{ordered_ops|length}}{{results[d]|length}}
Trusted op counter (passrate=100%):{{trusted_ops[d]}}
Tested op counter:{{general_test_count[d]}}
AVG passrate per op (=sum_pass_rates/covered_ops_num):{{pass_rate_avg[d]}}%
General passrate (=passed_tests/all_tests):{{general_pass_rate[d]}}%
{{ op }}{{ op }} - {{ results[d][op].passrate }}% (p:{{ results[d][op].passed }}, - f:{{ results[d][op].failed }},s:{{ results[d][op].skipped }}, - c:{{ results[d][op].crashed }}) - No tests
+ + + + {% for d in devices -%} + + {% endfor %} + + + + + + {% for d in devices -%} + + {% endfor %} + + + + {% for d in devices -%} + + {% endfor %} + + + + {% for d in devices -%} + + {% endfor %} + + + + {% for d in devices -%} + + {% endfor %} + + + + {% for d in devices -%} + + {% endfor %} + + + + {% for op in ordered_ops -%} + + - -
Operation{{ d }}
Total: {{ordered_ops|length}}{{results[d]|length}}
Trusted op (passrate=100%):{{trusted_ops[d]}} %
Tested op counter:{{general_test_count[d]}}
AVG passrate per op (=sum_pass_rates/covered_ops_num):{{pass_rate_avg[d]}} %
General passrate (=passed_tests/all_tests):{{general_pass_rate[d]}} %
{{ + op }}
+ {% for d in devices -%} + {% if op in results[d] -%} + + {{ results[d][op].passrate }} %
+ P:{{ results[d][op].passed }} + F:{{ results[d][op].failed }} + S:{{ results[d][op].skipped }} + C:{{ results[d][op].crashed }} + + {% else -%} + N/A + {% endif -%} + + {% endfor %} + + {% endfor -%} + + + + + diff --git a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/template/style.css b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/template/style.css new file mode 100644 index 00000000000000..11831d83b83e05 --- /dev/null +++ b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/template/style.css @@ -0,0 +1,88 @@ +body { + font-size: 14px; +} +.table td, .table th { + padding: .5em .75em; +} +.table td span { + font-size: 0.8em; +} +.value { + font-weight: 500; +} +.value span { + display:inline-block; + font-weight: 400; + padding: 1px 5px; + border-radius: 2px; + cursor: default; +} + .green { + background: #0080002e; +} +.red { + background: #ff000038; +} +.grey { + background: #8080803d; +} +.dark { + background: #8b000040; +} +.filters { + background: #FFF; + padding: 5px 10px; + position: sticky; + top: 0; +} +.filters form { + display: flex; + background: #efefef; + padding: 10px; + border-radius: 5px; +} +form div{ + margin-right: 10px; +} +form button { + align-self: center; + margin-top: 26px; + margin-left: 20px; +} +.main { + margin: 10px; +} +.legend { + display: flex; +} +.legend div { + display:flex; + align-items: center; + margin-right: 20px; +} +.legend span{ + display: inline-block; + padding: 3px 5px; + min-height: 25px; + min-width: 25px; +} +.colorRed { + color:#cf1d1d; + font-weight: bold; +} +.form-group { + margin-bottom: 0; +} +#message { + font-weight: 500; + font-size: 20px; + margin: 20px; + text-align: center; + color: #cf1d1d; +} +.table-dark:hover { + background: #212529!important; +} +h2 { + margin-bottom: 2rem; +} From 8c5fcdc5c9839838c16a44853414da649fad6729 Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Mon, 21 Jun 2021 15:05:16 +0300 Subject: [PATCH 145/178] Fixed incorrect check in IE backend (#6241) --- ngraph/test/runtime/ie/ie_tensor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ngraph/test/runtime/ie/ie_tensor.cpp b/ngraph/test/runtime/ie/ie_tensor.cpp index fd4e8468f92206..a7be07005e2275 100644 --- a/ngraph/test/runtime/ie/ie_tensor.cpp +++ b/ngraph/test/runtime/ie/ie_tensor.cpp @@ -36,7 +36,7 @@ void runtime::ie::IETensor::write(const void* src, size_t bytes) { m_data = AlignedBuffer(bytes); } - NGRAPH_CHECK(m_data.size() <= bytes, + NGRAPH_CHECK(bytes <= m_data.size(), "Buffer over-write. The buffer size: ", m_data.size(), " is lower than the number of bytes to write: ", From b2d25da04de5b6396ef98d4c2131adddb918bfcb Mon Sep 17 00:00:00 2001 From: Pavel Esir Date: Mon, 21 Jun 2021 15:33:13 +0300 Subject: [PATCH 146/178] [spec] add Gather-8 with negative indices (#6172) * add Gather-8 with negative indices * incremented version * updated opset8.md --- docs/doxygen/ie_docs.xml | 1 + docs/ops/movement/Gather_8.md | 200 ++++++++++++++++++++++++++++++++++ docs/ops/opset8.md | 2 +- 3 files changed, 202 insertions(+), 1 deletion(-) create mode 100644 docs/ops/movement/Gather_8.md diff --git a/docs/doxygen/ie_docs.xml b/docs/doxygen/ie_docs.xml index 8841672b430623..008b0d051646b1 100644 --- a/docs/doxygen/ie_docs.xml +++ b/docs/doxygen/ie_docs.xml @@ -161,6 +161,7 @@ limitations under the License. + diff --git a/docs/ops/movement/Gather_8.md b/docs/ops/movement/Gather_8.md new file mode 100644 index 00000000000000..bdb687bd467c02 --- /dev/null +++ b/docs/ops/movement/Gather_8.md @@ -0,0 +1,200 @@ +## Gather {#openvino_docs_ops_movement_Gather_8} + +**Versioned name**: *Gather-8* + +**Category**: Data movement operations + +**Short description**: *Gather* operation takes slices of data of the first input tensor according to the indices + specified with the second input tensor and axis from the third input. Semantics of this operation is identical to +TensorFlow\* [Gather](https://www.tensorflow.org/api_docs/python/tf/gather) operation. + +**Detailed description** + + output[p_0, p_1, ..., p_{axis-1}, i_b, ..., i_{M-1}, p_{axis+1}, ..., p_{N-1}] = + data[p_0, p_1, ..., p_{axis-1}, indices[p_0, p_1, ..., p_{b-1}, i_b, ..., i_{M-1}], p_{axis+1}, ..., p_{N-1}] + +Where `data`, `indices` and `axis` are tensors from first, second and third inputs correspondingly, `b` is +the number of batch dimensions. `N` and `M` are numbers of dimensions of `data` and `indices` tensors, respectively. + +**Attributes**: +* *batch_dims* + * **Description**: *batch_dims* (also denoted as `b`) is a leading number of dimensions of `data` tensor and `indices` + representing the batches, and *Gather* starts to gather from the `b` dimension. It requires the first `b` + dimensions in `data` and `indices` tensors to be equal. If `batch_dims` is less than zero, normalized value is used + `batch_dims = indices.rank + batch_dims`. + * **Range of values**: `[-min(data.rank, indices.rank); min(data.rank, indices.rank)]` and `batch_dims' <= axis'`. + Where `batch_dims'` and `axis'` stand for normalized `batch_dims` and `axis` values. + * **Type**: *T_AXIS* + * **Default value**: 0 + * **Required**: *no* + +Example 1 with default *batch_dims* value: +``` +batch_dims = 0 +axis = 0 + +indices = [0, 0, 4] +data = [1, 2, 3, 4, 5] +output = [1, 1, 5] +``` + +Example 2 with non-default *batch_dims* value: +``` +batch_dims = 1 +axis = 1 + +indices = [[0, 0, 4], <-- this is applied to the first batch + [4, 0, 0]] <-- this is applied to the second batch +indices_shape = (2, 3) + +data = [[1, 2, 3, 4, 5], <-- the first batch + [6, 7, 8, 9, 10]] <-- the second batch +data_shape = (2, 5) + +output = [[ 1, 1, 5], + [10, 6, 6]] +output_shape = (2, 3) +``` + +Example 3 with non-default *batch_dims* value: +``` +batch_dims = 2 +axis = 2 + +indices = [[[0, 0, 4], <-- this is applied to the first batch, index = (0, 0) + [4, 0, 0]], <-- this is applied to the second batch, index = (0, 1) + + [[1, 2, 4], <-- this is applied to the third batch, index = (1, 0) + [4, 3, 2]]] <-- this is applied to the fourth batch, index = (1, 1) +indices_shape = (2, 2, 3) + +data = [[[1, 2, 3, 4, 5], <-- the first batch, index = (0, 0) + [6, 7, 8, 9, 10]], <-- the second batch, index = (0, 1) + + [[11, 12, 13, 14, 15], <-- the third batch, index = (1, 0) + [16, 17, 18, 19, 20]]] <-- the fourth batch, index = (1, 1) +data_shape = (2, 2, 5) + +output = [[[ 1, 1, 5], + [10, 6, 6]], + + [[12, 13, 15], + [20, 19, 18]]] +output_shape = (2, 2, 3) +``` +Example 4 with *axis* > *batch_dims*: +``` +batch_dims = 1 +axis = 2 + +indices = [[1, 2, 4], <-- this is applied to the first batch + [4, 3, 2]] <-- this is applied to the second batch +indices_shape = (2, 3) + +data = [[[[ 1, 2, 3, 4], <-- first batch + [ 5, 6, 7, 8], + [ 9, 10, 11, 12], + [13, 14, 15, 16], + [17, 18, 19, 20]]], + + [[[21, 22, 23, 24], <-- second batch + [25, 26, 27, 28], + [29, 30, 31, 32], + [33, 34, 35, 36], + [37, 38, 39, 40]]]] +data_shape = (2, 1, 5, 4) + +output = [[[[ 5, 6, 7, 8], + [ 9, 10, 11, 12], + [17, 18, 19, 20]]], + + [[[37, 38, 39, 40], + [33, 34, 35, 36], + [29, 30, 31, 32]]]] +output_shape = (2, 1, 3, 4) +``` + +Example 5 with negative *batch_dims* value: +``` +batch_dims = -1 <-- normalized value will be indices.rank + batch_dims = 2 - 1 = 1 +axis = 1 + +indices = [[0, 0, 4], <-- this is applied to the first batch + [4, 0, 0]] <-- this is applied to the second batch +indices_shape = (2, 3) + +data = [[1, 2, 3, 4, 5], <-- the first batch + [6, 7, 8, 9, 10]] <-- the second batch +data_shape = (2, 5) + +output = [[ 1, 1, 5], + [10, 6, 6]] +output_shape = (2, 3) +``` + +Example 6 with negative indices: +``` +batch_dims = 0 +axis = 0 + +indices = [0, -2, -1] +data = [1, 2, 3, 4, 5] +output = [1, 4, 5] +``` + +**Inputs** + +* **1**: `data` tensor of type *T* with arbitrary data. **Required**. + +* **2**: `indices` tensor of type *T_IND* with indices to gather. 0D tensor (scalar) for indices is also allowed. + The values for indices are in the range `[-data[axis], data[axis] - 1]`. + Negative values of indices indicate reverse indexing from `data[axis]`. + **Required**. + +* **3**: Scalar or 1D tensor `axis` of *T_AXIS* type is a dimension index to gather data from. For example, +*axis* equal to 1 means that gathering is performed over the first dimension. Negative `axis` means reverse indexing and + will be normalized to value `axis = data.rank + axis`. Allowed values are from `[-len(data.shape), len(data.shape) - 1]` + and `axis' >= batch_dims'`. Where `axis'` and `batch_dims'` stand for normalized `batch_dims` and `axis` values. +**Required**. + +**Outputs** + +* **1**: The resulting tensor of type *T* that consists of elements from `data` tensor gathered by `indices`. The shape +of the output tensor is `data.shape[:axis] + indices.shape[batch_dims:] + data.shape[axis + 1:]` + +**Types** + +* *T*: any supported type. + +* *T_IND*: any supported integer types. + +* *T_AXIS*: any supported integer types. + +**Example** + +```xml + + + + + 2 + 64 + 128 + + + 2 + 32 + 21 + + + + + + 2 + 32 + 21 + 128 + + + +``` diff --git a/docs/ops/opset8.md b/docs/ops/opset8.md index fc68d6f32e07ea..02e97eab4e42f6 100644 --- a/docs/ops/opset8.md +++ b/docs/ops/opset8.md @@ -63,7 +63,7 @@ declared in `namespace opset8`. * [FakeQuantize](quantization/FakeQuantize_1.md) * [Floor](arithmetic/Floor_1.md) * [FloorMod](arithmetic/FloorMod_1.md) -* [Gather](movement/Gather_7.md) +* [Gather](movement/Gather_8.md) * [GatherElements](movement/GatherElements_6.md) * [GatherND_5](movement/GatherND_5.md) * [GatherTree](movement/GatherTree_1.md) From c5b940ecdb86d742844c399c4451bbca21c5f14e Mon Sep 17 00:00:00 2001 From: Egor Duplensky Date: Mon, 21 Jun 2021 16:13:19 +0300 Subject: [PATCH 147/178] Correct output nodes naming in scope of NMS transformation (#6119) * Correct output nodes naming in scope of NMS transformation Details: NMS transformation changes name of NMS node output (adds '/convert' suffix) In case NMS transformation is the last node before Output, it leads to the situation when InferRequest's network Outputs do not match any graph's Output nodes. Tickets: - 57695 * Add test --- .../convert_nms_to_nms_ie_internal.cpp | 5 +- .../nms_transformation_for_last_node.cpp | 13 +++ .../nms_transformation_for_last_node.hpp | 14 +++ .../nms_transformation_for_last_node.cpp | 88 +++++++++++++++++++ 4 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/nms_transformation_for_last_node.cpp create mode 100644 inference-engine/tests/functional/plugin/shared/include/execution_graph_tests/nms_transformation_for_last_node.hpp create mode 100644 inference-engine/tests/functional/plugin/shared/src/execution_graph_tests/nms_transformation_for_last_node.cpp diff --git a/inference-engine/src/transformations/src/transformations/op_conversions/convert_nms_to_nms_ie_internal.cpp b/inference-engine/src/transformations/src/transformations/op_conversions/convert_nms_to_nms_ie_internal.cpp index 3460985788e796..07b1d26ebe1a02 100644 --- a/inference-engine/src/transformations/src/transformations/op_conversions/convert_nms_to_nms_ie_internal.cpp +++ b/inference-engine/src/transformations/src/transformations/op_conversions/convert_nms_to_nms_ie_internal.cpp @@ -14,6 +14,7 @@ #include "ngraph_ops/nms_ie_internal.hpp" #include "transformations/op_conversions/convert_nms_to_nms_ie_internal.hpp" +#include "transformations/utils/utils.hpp" NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertNMSToNMSIEInternal, "ConvertNMSToNMSIEInternal", 0); @@ -103,14 +104,14 @@ ngraph::pass::ConvertNMSToNMSIEInternal::ConvertNMSToNMSIEInternal() { Output output_0 = nms_legacy->output(0); if (nms_5->output(0).get_element_type() != output_0.get_element_type()) { output_0 = std::make_shared(output_0, nms_5->output(0).get_element_type()); - output_0.get_node_shared_ptr()->set_friendly_name(nms_5->get_friendly_name() + "/convert.0"); + output_0.get_node_shared_ptr()->set_friendly_name(op::util::create_ie_output_name(nms_5->output(0))); new_ops.emplace_back(output_0.get_node_shared_ptr()); } Output output_2 = nms_legacy->output(2); if (nms_5->output(2).get_element_type() != output_2.get_element_type()) { output_2 = std::make_shared(output_2, nms_5->output(2).get_element_type()); - output_2.get_node_shared_ptr()->set_friendly_name(nms_5->get_friendly_name() + "/convert.2"); + output_2.get_node_shared_ptr()->set_friendly_name(op::util::create_ie_output_name(nms_5->output(2))); new_ops.emplace_back(output_2.get_node_shared_ptr()); } diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/nms_transformation_for_last_node.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/nms_transformation_for_last_node.cpp new file mode 100644 index 00000000000000..5d5fbe597f8398 --- /dev/null +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/nms_transformation_for_last_node.cpp @@ -0,0 +1,13 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "execution_graph_tests/nms_transformation_for_last_node.hpp" +#include "common_test_utils/test_constants.hpp" + +namespace { +using namespace ExecutionGraphTests; + +INSTANTIATE_TEST_CASE_P(smoke_NmsTransformationLastNode, ExecGraphNmsTransformLastNode, ::testing::Values(CommonTestUtils::DEVICE_CPU), + ExecGraphNmsTransformLastNode::getTestCaseName); +} // namespace diff --git a/inference-engine/tests/functional/plugin/shared/include/execution_graph_tests/nms_transformation_for_last_node.hpp b/inference-engine/tests/functional/plugin/shared/include/execution_graph_tests/nms_transformation_for_last_node.hpp new file mode 100644 index 00000000000000..4f6bee8a16b200 --- /dev/null +++ b/inference-engine/tests/functional/plugin/shared/include/execution_graph_tests/nms_transformation_for_last_node.hpp @@ -0,0 +1,14 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" + +namespace ExecutionGraphTests { + +class ExecGraphNmsTransformLastNode : public testing::TestWithParam { +public: + static std::string getTestCaseName(testing::TestParamInfo obj); +}; + +} // namespace ExecutionGraphTests diff --git a/inference-engine/tests/functional/plugin/shared/src/execution_graph_tests/nms_transformation_for_last_node.cpp b/inference-engine/tests/functional/plugin/shared/src/execution_graph_tests/nms_transformation_for_last_node.cpp new file mode 100644 index 00000000000000..5b67f9a468004e --- /dev/null +++ b/inference-engine/tests/functional/plugin/shared/src/execution_graph_tests/nms_transformation_for_last_node.cpp @@ -0,0 +1,88 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "execution_graph_tests/nms_transformation_for_last_node.hpp" + +#include + +#include +#include + +#include + +#include "functional_test_utils/skip_tests_config.hpp" +#include "common_test_utils/ngraph_test_utils.hpp" + +#include +#include +#include +#include + +namespace ExecutionGraphTests { + +std::string ExecGraphNmsTransformLastNode::getTestCaseName( + testing::TestParamInfo obj) { + std::string targetDevice = obj.param; + return "Dev=" + targetDevice; +} + +/** + * Infer simple graph with just NMS node. + * Verify that after NMS transformation network can be inferred + * especially, that NMS transformation does not change name + * of the output (Result) node + */ +TEST_P(ExecGraphNmsTransformLastNode, CheckIfCanBeInfered) { + SKIP_IF_CURRENT_TEST_IS_DISABLED() + + using namespace ngraph; + + auto device_name = this->GetParam(); + ngraph::Shape boxes_shape = {1, 2, 4}; + ngraph::Shape scores_shape = {1, 1, 2}; + float in_boxes[8] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}; + float in_scores[8] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}; + + auto boxes = std::make_shared(element::f32, boxes_shape); + auto scores = std::make_shared(element::f32, scores_shape); + auto max_output_boxes_per_class = opset5::Constant::create(element::i64, Shape{}, {10}); + auto iou_threshold = opset5::Constant::create(element::f32, Shape{}, {0.75}); + auto score_threshold = opset5::Constant::create(element::f32, Shape{}, {0.7}); + auto nms = std::make_shared(boxes, scores, max_output_boxes_per_class, + iou_threshold, score_threshold, + opset5::NonMaxSuppression::BoxEncodingType::CORNER, true, element::i64); + ngraph::ResultVector results { + std::make_shared(nms->output(0)), + }; + + auto f = std::make_shared(results, ParameterVector{boxes, scores}, "NMS"); + + auto ie = InferenceEngine::Core(); + auto net = InferenceEngine::CNNNetwork(f); + auto exec_net = ie.LoadNetwork(net, device_name); + auto infer_req = exec_net.CreateInferRequest(); + + InferenceEngine::TensorDesc tDesc1(InferenceEngine::Precision::FP32, boxes_shape, + InferenceEngine::Layout::CHW); + InferenceEngine::TensorDesc tDesc2(InferenceEngine::Precision::FP32, scores_shape, + InferenceEngine::Layout::CHW); + + InferenceEngine::Blob::Ptr inBlob1 = InferenceEngine::make_shared_blob(tDesc1, in_boxes); + infer_req.SetBlob(boxes->get_name(), inBlob1); + InferenceEngine::Blob::Ptr inBlob2 = InferenceEngine::make_shared_blob(tDesc2, in_scores); + infer_req.SetBlob(scores->get_name(), inBlob2); + + infer_req.Infer(); + + const auto& initial_outputs = net.getOutputsInfo(); + const auto& final_outputs = exec_net.GetOutputsInfo(); + + auto compareOutputNames = [] (const std::pair& lhs, + const std::pair& rhs) + { return lhs.first == rhs.first; }; + + ASSERT_TRUE(std::equal(initial_outputs.begin(), initial_outputs.end(), final_outputs.begin(), compareOutputNames)); +} + +} // namespace ExecutionGraphTests From 9e7d98fca9e79ad63fa3c4be80e69678960e252e Mon Sep 17 00:00:00 2001 From: Dmitrii Khurtin Date: Mon, 21 Jun 2021 17:53:38 +0300 Subject: [PATCH 148/178] Additional checks are added to prevent errors from occurring on the GNA library (#5953) * additional checks are added to prevent errors from occurring on the GNA library side * fixing after review * move AreLayersSupported from Cnn2D namespace * GNA_DEBUG is commented * batch size <= 8 test was added --- .../gna_plugin/backend/gna_limitations.cpp | 77 ++++++++++-- .../gna_plugin/backend/gna_limitations.hpp | 4 + .../src/gna_plugin/gna_plugin.cpp | 2 +- .../src/gna_plugin/layers/gna_layer_info.hpp | 26 ++++ .../src/gna_plugin/layers/gna_layer_type.cpp | 49 -------- .../src/gna_plugin/layers/gna_layer_type.hpp | 1 - .../gna_plugin/optimizer/gna_pass_manager.cpp | 7 ++ .../gna/pass_tests/layers_restrictions.cpp | 116 ++++++++++++++++++ 8 files changed, 224 insertions(+), 58 deletions(-) create mode 100644 inference-engine/tests/functional/plugin/gna/pass_tests/layers_restrictions.cpp diff --git a/inference-engine/src/gna_plugin/backend/gna_limitations.cpp b/inference-engine/src/gna_plugin/backend/gna_limitations.cpp index 8443856a449946..6afe55bd043d93 100644 --- a/inference-engine/src/gna_plugin/backend/gna_limitations.cpp +++ b/inference-engine/src/gna_plugin/backend/gna_limitations.cpp @@ -5,14 +5,15 @@ #include "gna_limitations.hpp" #include +#include +#include +#include +#include +#include -using GNAPluginNS::GNALimitations::Cnn2D::Validator; -using GNAPluginNS::GNALimitations::Cnn2D::VectorOrSquareLimit; -using GNAPluginNS::GNALimitations::Cnn2D::VectorOrSquareLimitByChannels; -using GNAPluginNS::GNALimitations::Cnn2D::VectorOrSquareLimitByChannelsAndPrecision; -using GNAPluginNS::GNALimitations::Cnn2D::RangeLimit; -using GNAPluginNS::GNALimitations::Cnn2D::RangeLimit2D; -using GNAPluginNS::GNALimitations::Cnn2D::RangeMultipleLimit; +namespace GNAPluginNS { +namespace GNALimitations { +namespace Cnn2D { bool RangeLimit::isValid(const uint32_t val) const { return val >= min && val <= max; @@ -127,3 +128,65 @@ void Validator::ThrowIfNotEmpty(const std::string prefix, const std::string erro THROW_GNA_EXCEPTION << prefix << error; } } + +} // namespace Cnn2D + +bool AreLayersSupported(InferenceEngine::CNNNetwork& network, std::string& errMessage) { + IE_SUPPRESS_DEPRECATED_START + InferenceEngine::InputsDataMap inputs = network.getInputsInfo(); + std::unordered_set allLayers; + InferenceEngine::CNNLayerPtr startLayer; + if (inputs.empty()) { + auto outputs = network.getOutputsInfo(); + IE_ASSERT(!outputs.empty()); + // If there are no inputs start search from an output + startLayer = getCreatorLayer(outputs.begin()->second).lock(); + } else { + auto network_input_precision = inputs.begin()->second->getPrecision(); + + if (network_input_precision != InferenceEngine::Precision::FP32 && + network_input_precision != InferenceEngine::Precision::I16 && + network_input_precision != InferenceEngine::Precision::U8) { + errMessage = "The plugin does not support input precision with " + + std::string(network_input_precision.name()) + + " format. Supported input precisions FP32, I16, U8\n"; + return false; + } + + auto & secondLayers = getInputTo(inputs.begin()->second->getInputData()); + if (secondLayers.empty()) { + errMessage = "Network consists of input layer only (GNA)\n"; + return false; + } + startLayer = secondLayers.begin()->second; + } + auto batch_size = network.getBatchSize(); + + bool check_result = true; + InferenceEngine::details::UnorderedDFS(allLayers, + startLayer, + [&](const InferenceEngine::CNNLayerPtr layer) { + if (GNAPluginNS::LayerTypeFromStr(layer->type) == GNAPluginNS::LayerType::NO_TYPE) { + errMessage = "The plugin does not support layer: " + layer->name + ":" + layer->type + "\n"; + check_result = false; + } + if (batch_size != 1 && GNAPluginNS::LayerInfo::isBatchSizeConstrained(layer->type)) { + errMessage = "topology with layer: " + layer->name + ", type: " + layer->type + + ", and batch size(" + std::to_string(batch_size) + ") != 1 not supported"; + check_result = false; + } + if (GNAPluginNS::LayerInfo(layer).isFullyConnected()) { + size_t output_batch_size = GNAPluginNS::LayerInfo(layer).getOutputBatchSize(); + if (output_batch_size > 8) { + errMessage = "topology with layer: " + layer->name + ", type: " + layer->type + + ", and batch size(" + std::to_string(output_batch_size) + ") not supported"; + check_result = false; + } + } + }, false); + IE_SUPPRESS_DEPRECATED_END + return check_result; +} + +} // namespace GNALimitations +} // namespace GNAPluginNS diff --git a/inference-engine/src/gna_plugin/backend/gna_limitations.hpp b/inference-engine/src/gna_plugin/backend/gna_limitations.hpp index 3a283cae895d15..59dd0478cfa900 100644 --- a/inference-engine/src/gna_plugin/backend/gna_limitations.hpp +++ b/inference-engine/src/gna_plugin/backend/gna_limitations.hpp @@ -6,6 +6,7 @@ #include "dnn_types.h" #include +#include namespace GNAPluginNS { namespace GNALimitations { @@ -94,5 +95,8 @@ class Validator { const uint32_t strideH, const uint32_t strideW) const; }; } // namespace Cnn2D + +bool AreLayersSupported(InferenceEngine::CNNNetwork& network, std::string& errMessage); + } // namespace GNALimitations } // namespace GNAPluginNS diff --git a/inference-engine/src/gna_plugin/gna_plugin.cpp b/inference-engine/src/gna_plugin/gna_plugin.cpp index cb227304649638..01ba39a638a0b4 100644 --- a/inference-engine/src/gna_plugin/gna_plugin.cpp +++ b/inference-engine/src/gna_plugin/gna_plugin.cpp @@ -723,7 +723,7 @@ void GNAPlugin::LoadNetwork(CNNNetwork & _network) { // Check the input network std::string error; - if (!AreLayersSupported(network, error)) { + if (!GNAPluginNS::GNALimitations::AreLayersSupported(network, error)) { THROW_GNA_EXCEPTION << error.c_str(); } diff --git a/inference-engine/src/gna_plugin/layers/gna_layer_info.hpp b/inference-engine/src/gna_plugin/layers/gna_layer_info.hpp index a4681bdff41e01..93fb4417dc7296 100644 --- a/inference-engine/src/gna_plugin/layers/gna_layer_info.hpp +++ b/inference-engine/src/gna_plugin/layers/gna_layer_info.hpp @@ -90,6 +90,32 @@ class LayerInfo { static InferenceEngine::details::caseless_set layersWithConstrains = {"memory", "convolution"}; return layersWithConstrains.find(name) != layersWithConstrains.end(); } + size_t getOutputBatchSize() const { + if (!layer) { + THROW_GNA_EXCEPTION << "layer is null"; + } + if (!layer->outData[0]) { + THROW_GNA_EXCEPTION << "output data of layer '" << layer->name << "' is null"; + } + auto& dims = layer->outData[0]->getDims(); + auto layout = layer->outData[0]->getLayout(); + switch (dims.size()) { + case 1: + return 1; + case 2: + if (layout == InferenceEngine::Layout::NC) { + return dims[0]; + } else if (layout == InferenceEngine::Layout::CN) { + return dims[1]; + } else { + THROW_GNA_EXCEPTION << "batch size is not define in layer '" << layer->name << "'"; + } + case 4: + return dims[0]; + default: + THROW_GNA_EXCEPTION << "batch size is not define in layer '" << layer->name << "'"; + } + } bool isActivation() const noexcept { IS_VALID(); static InferenceEngine::details::caseless_set activations = diff --git a/inference-engine/src/gna_plugin/layers/gna_layer_type.cpp b/inference-engine/src/gna_plugin/layers/gna_layer_type.cpp index a333d47c48aac3..7a3de49a2de052 100644 --- a/inference-engine/src/gna_plugin/layers/gna_layer_type.cpp +++ b/inference-engine/src/gna_plugin/layers/gna_layer_type.cpp @@ -15,52 +15,3 @@ GNAPluginNS::LayerType GNAPluginNS::LayerTypeFromStr(const std::string &str) { else return NO_TYPE; } - -bool GNAPluginNS::AreLayersSupported(InferenceEngine::CNNNetwork& network, std::string& errMessage) { - IE_SUPPRESS_DEPRECATED_START - InferenceEngine::InputsDataMap inputs = network.getInputsInfo(); - std::unordered_set allLayers; - InferenceEngine::CNNLayerPtr startLayer; - if (inputs.empty()) { - auto outputs = network.getOutputsInfo(); - IE_ASSERT(!outputs.empty()); - // If there are no inputs start search from an output - startLayer = getCreatorLayer(outputs.begin()->second).lock(); - } else { - auto network_input_precision = inputs.begin()->second->getPrecision(); - - if (network_input_precision != InferenceEngine::Precision::FP32 && - network_input_precision != InferenceEngine::Precision::I16 && - network_input_precision != InferenceEngine::Precision::U8) { - errMessage = "The plugin does not support input precision with " + - std::string(network_input_precision.name()) + - " format. Supported input precisions FP32, I16, U8\n"; - return false; - } - - auto & secondLayers = getInputTo(inputs.begin()->second->getInputData()); - if (secondLayers.empty()) { - errMessage = "Network consists of input layer only (GNA)\n"; - return false; - } - startLayer = secondLayers.begin()->second; - } - auto batch_size = network.getBatchSize(); - - bool check_result = true; - InferenceEngine::details::UnorderedDFS(allLayers, - startLayer, - [&](const InferenceEngine::CNNLayerPtr layer) { - if (LayerTypeFromStr(layer->type) == LayerType::NO_TYPE) { - errMessage = "The plugin does not support layer: " + layer->name + ":" + layer->type + "\n"; - check_result = false; - } - if (batch_size != 1 && LayerInfo::isBatchSizeConstrained(layer->type)) { - errMessage = "topology with layer: " + layer->name + ", type: " + layer->type + - ", and batch size(" + std::to_string(batch_size) + ") != 1 not supported"; - check_result = false; - } - }, false); - IE_SUPPRESS_DEPRECATED_END - return check_result; -} diff --git a/inference-engine/src/gna_plugin/layers/gna_layer_type.hpp b/inference-engine/src/gna_plugin/layers/gna_layer_type.hpp index 7fdbf7e576d24b..266590dba68e43 100644 --- a/inference-engine/src/gna_plugin/layers/gna_layer_type.hpp +++ b/inference-engine/src/gna_plugin/layers/gna_layer_type.hpp @@ -91,5 +91,4 @@ static const InferenceEngine::details::caseless_mapgetLayout() == Layout::NC && dims[0] > 8 || + concatInput->getLayout() == Layout::CN && dims[1] > 8) { + THROW_GNA_EXCEPTION << "unsupported batch number '" << + (concatInput->getLayout() == Layout::NC ? dims[0] : dims[1]) << + "' in layer '" << concatLayer->name << "'"; + } + auto outData = std::make_shared(filterName, TensorDesc(concatInput->getPrecision(), dims, diff --git a/inference-engine/tests/functional/plugin/gna/pass_tests/layers_restrictions.cpp b/inference-engine/tests/functional/plugin/gna/pass_tests/layers_restrictions.cpp new file mode 100644 index 00000000000000..fc7f15994d2044 --- /dev/null +++ b/inference-engine/tests/functional/plugin/gna/pass_tests/layers_restrictions.cpp @@ -0,0 +1,116 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// +// +#include +#include +#include + +#include + +#include "common_test_utils/common_utils.hpp" +#include "functional_test_utils/plugin_cache.hpp" +#include "shared_test_classes/base/layer_test_utils.hpp" +#include "functional_test_utils/blob_utils.hpp" +#include "ngraph_functions/utils/ngraph_helpers.hpp" +#include "ngraph_functions/builders.hpp" +#include "ngraph_functions/pass/convert_prc.hpp" + +using LayersRestrictionsParamsTuple = typename std::tuple< + InferenceEngine::Precision, // Network Precision + std::map, // Configuration + std::string>; // Device name + +namespace LayerTestsDefinitions { + +struct FullyConnectedBatchSizeMoreThan8 { + static const char* getName() { return "FullyConnectedBatchSizeMoreThan8"; } + static std::shared_ptr createTopology(const InferenceEngine::Precision& netPrecision) { + auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); + std::vector inputShape = {9, 1}; + auto params = ngraph::builder::makeParams(ngPrc, {inputShape}); + auto weights = CommonTestUtils::generate_float_numbers(inputShape[1] * inputShape[1], -0.0001f, 0.0001f); + auto fullyConnected = ngraph::builder::makeFullyConnected(params[0], ngPrc, inputShape[1], false, {}, weights); + ngraph::ResultVector results{ std::make_shared(fullyConnected) }; + return std::make_shared(results, params, getName()); + } + static const char* getMatch() { return "and batch size(9) not supported"; } +}; + +struct FullyConnectedBatchSizeLessThanOrEqual8 { + static const char* getName() { return "FullyConnectedBatchSizeLessThanOrEqual8"; } + static std::shared_ptr createTopology(const InferenceEngine::Precision& netPrecision) { + auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); + std::vector inputShape = {7, 1}; + auto params = ngraph::builder::makeParams(ngPrc, {inputShape}); + auto weights = CommonTestUtils::generate_float_numbers(inputShape[1] * inputShape[1], -0.0001f, 0.0001f); + auto fullyConnected = ngraph::builder::makeFullyConnected(params[0], ngPrc, inputShape[1], false, {}, weights); + ngraph::ResultVector results{ std::make_shared(fullyConnected) }; + return std::make_shared(results, params, getName()); + } +}; + +template +class LayersRestrictions : public testing::WithParamInterface, + public LayerTestsUtils::LayerTestsCommon { +public: + static std::string getTestCaseName(testing::TestParamInfo obj) { + InferenceEngine::Precision netPrecision; + std::map configuration; + std::string targetDevice; + std::tie(netPrecision, configuration, targetDevice) = obj.param; + std::ostringstream result; + result << T::getName() << "_"; + result << "netPRC=" << netPrecision.name() << "_"; + result << "targetDevice=" << targetDevice << "_"; + for (auto const& configItem : configuration) { + result << "configItem=" << configItem.first << "_" << configItem.second << "_"; + } + return result.str(); + } + static const char* getMatch() { return T::getMatch(); } + +protected: + void SetUp() override { + InferenceEngine::Precision netPrecision; + std::tie(netPrecision, configuration, targetDevice) = this->GetParam(); + function = T::createTopology(netPrecision); + } +}; + +using LayersRestrictionsFullyConnectedBatchSizeMoreThan8 = LayersRestrictions; +using LayersRestrictionsFullyConnectedBatchSizeLessThanOrEqual8 = LayersRestrictions; + +TEST_P(LayersRestrictionsFullyConnectedBatchSizeMoreThan8, CompareWithRefImpl) { + std::string what; + try { + LoadNetwork(); + } catch (const std::exception& e) { + what.assign(e.what()); + } + EXPECT_TRUE(what.find(getMatch()) != std::string::npos); +} + +TEST_P(LayersRestrictionsFullyConnectedBatchSizeLessThanOrEqual8, CompareWithRefImpl) { + Run(); +}; + +const std::vector netPrecisions = {InferenceEngine::Precision::FP32}; +const std::vector> configs = { + { {"GNA_DEVICE_MODE", "GNA_SW_EXACT"} } +}; + +INSTANTIATE_TEST_CASE_P(smoke_layers_restrictions, LayersRestrictionsFullyConnectedBatchSizeMoreThan8, + ::testing::Combine( + ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(configs), + ::testing::Values(CommonTestUtils::DEVICE_GNA)), + LayersRestrictionsFullyConnectedBatchSizeMoreThan8::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_layers_restrictions, LayersRestrictionsFullyConnectedBatchSizeLessThanOrEqual8, + ::testing::Combine( + ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(configs), + ::testing::Values(CommonTestUtils::DEVICE_GNA)), + LayersRestrictionsFullyConnectedBatchSizeLessThanOrEqual8::getTestCaseName); +} // namespace LayerTestsDefinitions From 6799a319112fce5bf5edfa1d36a395c22f143669 Mon Sep 17 00:00:00 2001 From: Vladislav Golubev Date: Mon, 21 Jun 2021 18:02:23 +0300 Subject: [PATCH 149/178] LPT fixes (#6214) * [LPT] StridedSlice fix * [LPT] separateInStandaloneBranch fix --- .../src/network_helper.cpp | 6 +- .../src/strided_slice.cpp | 9 +- ...te_in_standalone_branch_transformation.cpp | 6 +- .../strided_slice_transformation.cpp | 93 ++++++++++++++++++- 4 files changed, 106 insertions(+), 8 deletions(-) diff --git a/inference-engine/src/low_precision_transformations/src/network_helper.cpp b/inference-engine/src/low_precision_transformations/src/network_helper.cpp index 90995bc0ffb22d..346034e02abd89 100644 --- a/inference-engine/src/low_precision_transformations/src/network_helper.cpp +++ b/inference-engine/src/low_precision_transformations/src/network_helper.cpp @@ -549,7 +549,11 @@ std::shared_ptr NetworkHelper::separateInStandaloneBranch(std::sha } std::vector> inputs = node->input_values(); - const size_t inputIndex = NetworkHelper::getChildInputIndex(dequantization.multiply, node); + const auto originalParent = dequantization.multiply ? + dequantization.multiply->shared_from_this() : + dequantization.subtract->shared_from_this(); + + const size_t inputIndex = NetworkHelper::getChildInputIndex(originalParent, node); inputs[inputIndex] = parent; const std::shared_ptr newNode = node->clone_with_new_inputs(inputs); diff --git a/inference-engine/src/low_precision_transformations/src/strided_slice.cpp b/inference-engine/src/low_precision_transformations/src/strided_slice.cpp index a269e392302ce4..e3d420c849068f 100644 --- a/inference-engine/src/low_precision_transformations/src/strided_slice.cpp +++ b/inference-engine/src/low_precision_transformations/src/strided_slice.cpp @@ -17,13 +17,12 @@ std::shared_ptr stridedSliceDeqConstant( const std::shared_ptr strSlice, const std::shared_ptr dequantizaitonConstant) { auto constant = as_type_ptr(dequantizaitonConstant); - // issue #48857: constant is mistakenly recognized as a scalar. Uncomment after fix - //if (NetworkHelper::isScalarLike(constant)) { - // return NetworkHelper::toScalar(constant); - //} + auto constantShape = constant->get_shape(); + if (ngraph::shape_size(constantShape) == 1ul) { + return NetworkHelper::toScalar(constant); + } const auto stridedSliceShape = strSlice->get_input_shape(0); - auto constantShape = constant->get_shape(); if (stridedSliceShape.size() != constantShape.size()) { ngraph::Shape newConstantShape; if (ngraph::shape_size(constantShape) == 1) { diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/separate_in_standalone_branch_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/separate_in_standalone_branch_transformation.cpp index ec6176375b0493..04832b837fe4bc 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/separate_in_standalone_branch_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/separate_in_standalone_branch_transformation.cpp @@ -81,7 +81,6 @@ class SeparateInStandaloneBranchTransformation : "SeparateInStandaloneBranchTransformation"); }; actualFunction = createActualFunction(testValues.precisionBefore, shape, testValues.dequantization); - const auto result = actualFunction->get_results()[0]; ngraph::pass::low_precision::NetworkHelper::separateInStandaloneBranch(result->get_input_node_shared_ptr(0)); @@ -143,6 +142,11 @@ std::vector testValues = { ngraph::element::u8, { ngraph::element::f32, { 127.f }, { 0.02f } } }, + { + LayerTransformation::createParamsU8U8(), + ngraph::element::u8, + { ngraph::element::f32, { 127.f }, {} } + }, { LayerTransformation::createParamsU8U8().setSupportAsymmetricQuantization(true), ngraph::element::u8, diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/strided_slice_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/strided_slice_transformation.cpp index 8b16ce99d75eda..ca8f4a68518ace 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/strided_slice_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/strided_slice_transformation.cpp @@ -117,7 +117,8 @@ class StridedSliceTransformation : public LayerTransformation, public testing::W testValues.inputShape << testValues.actual.inputPrecision << "_" << toString(testValues.params) << testValues.actual.dequantization << "_strided_slice_params_" << testValues.layerParams.begin << testValues.layerParams.end << testValues.layerParams.beginMask << - testValues.layerParams.endMask << testValues.layerParams.strides; + testValues.layerParams.endMask << testValues.layerParams.strides << + testValues.layerParams.shrinkAxisMask << testValues.layerParams.newAxisMask; return result.str(); } }; @@ -161,6 +162,28 @@ StridedSliceTransformationTestValues::LayerParams specialDimensionEndSlice = { {} }; +StridedSliceTransformationTestValues::LayerParams sliceWithRemovedAxis = { + { 0, 1, 0, 0 }, // begin + { 1, 2, 1, 1 }, // end + { 1, 1, 1, 1 }, // strided + { 1, 0, 1, 1 }, // beginMask + { 1, 0, 1, 1 }, // endMask + { 0, 0, 0, 0 }, // newAxisMask + { 0, 1, 0, 0 }, // shrinkAxisMask + { 0, 0, 0, 0 } // elipsisMask +}; + +StridedSliceTransformationTestValues::LayerParams sliceWithAdditionalAxis = { + { 0, 1, 0, 0 }, // begin + { 1, 2, 1, 1 }, // end + { 1, 1, 1, 1 }, // strided + { 1, 0, 1, 1 }, // beginMask + { 1, 0, 1, 1 }, // endMask + { 0, 1, 0, 0 }, // newAxisMask + { 0, 0, 0, 0 }, // shrinkAxisMask + { 0, 0, 0, 0 } // elipsisMask +}; + const std::vector stridedSliceTransformationTestValues = { // U8: channel slice, per-tensor quantization { @@ -442,6 +465,74 @@ const std::vector stridedSliceTransformati {{ngraph::element::f32}, {}, { {0.1f, 0.01f}, ngraph::element::f32, {1, 2, 1, 1} }} } }, + // U8: channel slice, per-tensor quantization + { + ngraph::Shape{1, 3, 16, 1200}, + LayerTransformation::createParamsU8I8(), + sliceWithRemovedAxis, + { + ngraph::element::u8, + {{ngraph::element::f32}, {128.f}, {0.1f}} + }, + { + ngraph::element::u8, + {}, + ngraph::element::u8, + {{ngraph::element::f32}, {128.f}, {0.1f}} + } + }, + // U8: channel slice, per-channel quantization + { + ngraph::Shape{1, 3, 16, 1200}, + LayerTransformation::createParamsU8I8(), + sliceWithRemovedAxis, + { + ngraph::element::u8, + {{ngraph::element::f32}, { {128.f, 64.f, 32.f} }, { {0.1f, 0.2f, 0.3f} }} + }, + { + ngraph::element::u8, + {}, + ngraph::element::u8, + {{ngraph::element::f32}, {64.f}, {0.2f}}, + } + }, + // U8: channel slice, per-tensor quantization + { + ngraph::Shape{1, 3, 16, 1200}, + LayerTransformation::createParamsU8I8(), + sliceWithAdditionalAxis, + { + ngraph::element::u8, + {{ngraph::element::f32}, {128.f}, {0.1f}} + }, + { + ngraph::element::u8, + {}, + ngraph::element::u8, + {{ngraph::element::f32}, {128.f}, {0.1f}} + } + }, + // U8: channel slice, per-channel quantization + { + ngraph::Shape{1, 3, 16, 1200}, + LayerTransformation::createParamsU8I8(), + sliceWithAdditionalAxis, + { + ngraph::element::u8, + {{ngraph::element::f32}, { {128.f, 64.f, 32.f} }, { {0.1f, 0.2f, 0.3f} }} + }, + { + ngraph::element::u8, + {}, + ngraph::element::u8, + { + {ngraph::element::f32}, + { {128.f, 64.f, 32.f}, ngraph::element::f32, {1, 1, 3, 1, 1} }, + { {0.1f, 0.2f, 0.3f}, ngraph::element::f32, {1, 1, 3, 1, 1} } + }, + } + }, }; INSTANTIATE_TEST_CASE_P( From 3b2da7de3084374122e57f1c1636f1b22ad469c1 Mon Sep 17 00:00:00 2001 From: Pavel Esir Date: Mon, 21 Jun 2021 19:14:37 +0300 Subject: [PATCH 150/178] [docs] corrected DeepSpeech conversion (#6011) * corrected output names in DeepSpeech conversion doc * mo args correction * changed instruction for DeepSpeech version 0.8.2 * added venv activate; removed redundant ending * added picture and squashed MO graph input args into one * Apply suggestions from code review Co-authored-by: Tatiana Savina * applied review comments Co-authored-by: Tatiana Savina --- docs/MO_DG/img/DeepSpeech-0.8.2.png | 3 + docs/MO_DG/img/DeepSpeech.png | 3 - .../Convert_DeepSpeech_From_Tensorflow.md | 89 +++++++++++-------- 3 files changed, 55 insertions(+), 40 deletions(-) create mode 100644 docs/MO_DG/img/DeepSpeech-0.8.2.png delete mode 100644 docs/MO_DG/img/DeepSpeech.png diff --git a/docs/MO_DG/img/DeepSpeech-0.8.2.png b/docs/MO_DG/img/DeepSpeech-0.8.2.png new file mode 100644 index 00000000000000..ddab04ac34ac29 --- /dev/null +++ b/docs/MO_DG/img/DeepSpeech-0.8.2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fdff3768930f683b81ca466be4f947af3172933a702cd38201a254df27a68556 +size 62498 diff --git a/docs/MO_DG/img/DeepSpeech.png b/docs/MO_DG/img/DeepSpeech.png deleted file mode 100644 index b6f1ca96486850..00000000000000 --- a/docs/MO_DG/img/DeepSpeech.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7ed2c9052f631055090ef3744117ca5a8e8314e0717ba0fdc984e295caa5b925 -size 112455 diff --git a/docs/MO_DG/prepare_model/convert_model/tf_specific/Convert_DeepSpeech_From_Tensorflow.md b/docs/MO_DG/prepare_model/convert_model/tf_specific/Convert_DeepSpeech_From_Tensorflow.md index 74833cf3ad3332..29df0e4695d330 100644 --- a/docs/MO_DG/prepare_model/convert_model/tf_specific/Convert_DeepSpeech_From_Tensorflow.md +++ b/docs/MO_DG/prepare_model/convert_model/tf_specific/Convert_DeepSpeech_From_Tensorflow.md @@ -2,66 +2,81 @@ [DeepSpeech project](https://github.com/mozilla/DeepSpeech) provides an engine to train speech-to-text models. -## Download the Pre-Trained DeepSpeech Model +## Download the Pretrained DeepSpeech Model -[Pre-trained English speech-to-text model](https://github.com/mozilla/DeepSpeech#getting-the-pre-trained-model) -is publicly available. To download the model, please follow the instruction below: +Create a directory where model and metagraph with pretrained weights will be stored: +``` +mkdir deepspeech +cd deepspeech +``` +[Pretrained English speech-to-text model](https://github.com/mozilla/DeepSpeech/releases/tag/v0.8.2) is publicly available. +To download the model, follow the instruction below: * For UNIX*-like systems, run the following command: ``` -wget -O - https://github.com/mozilla/DeepSpeech/releases/download/v0.3.0/deepspeech-0.3.0-models.tar.gz | tar xvfz - +wget -O - https://github.com/mozilla/DeepSpeech/archive/v0.8.2.tar.gz | tar xvfz - +wget -O - https://github.com/mozilla/DeepSpeech/releases/download/v0.8.2/deepspeech-0.8.2-checkpoint.tar.gz | tar xvfz - ``` * For Windows* systems: - 1. Download the archive from the DeepSpeech project repository: [https://github.com/mozilla/DeepSpeech/releases/download/v0.3.0/deepspeech-0.3.0-models.tar.gz](https://github.com/mozilla/DeepSpeech/releases/download/v0.3.0/deepspeech-0.3.0-models.tar.gz). - 2. Unpack it with a file archiver application. + 1. Download the archive with the model: [https://github.com/mozilla/DeepSpeech/archive/v0.8.2.tar.gz](https://github.com/mozilla/DeepSpeech/archive/v0.8.2.tar.gz). + 2. Download the TensorFlow\* MetaGraph with pretrained weights: [https://github.com/mozilla/DeepSpeech/releases/download/v0.8.2/deepspeech-0.8.2-checkpoint.tar.gz](https://github.com/mozilla/DeepSpeech/releases/download/v0.8.2/deepspeech-0.8.2-checkpoint.tar.gz). + 3. Unpack it with a file archiver application. + +## Freeze the Model into a *.pb File -After you unpack the archive with the pre-trained model, you will have the new `models` directory with the -following files: +After unpacking the archives above, you have to freeze the model. Note that this requires +TensorFlow* version 1 which is not available under Python 3.8, so you need Python 3.7 or lower. +Before freezing, deploy a virtual environment and install the required packages: ``` -alphabet.txt -lm.binary -output_graph.pb -output_graph.pbmm -output_graph.rounded.pb -output_graph.rounded.pbmm -trie +virtualenv --python=python3.7 venv-deep-speech +source venv-deep-speech/bin/activate +cd DeepSpeech-0.8.2 +pip3 install -e . ``` +Freeze the model with the following command: +``` +python3 DeepSpeech.py --checkpoint_dir ../deepspeech-0.8.2-checkpoint --export_dir ../ +``` +After that, you will get the pretrained frozen model file `output_graph.pb` in the directory `deepspeech` created at +the beginning. The model contains the preprocessing and main parts. The first preprocessing part performs conversion of input +spectrogram into a form useful for speech recognition (mel). This part of the model is not convertible into +IR because it contains unsupported operations `AudioSpectrogram` and `Mfcc`. -Pre-trained frozen model file is `output_graph.pb`. - -![DeepSpeech model view](../../../img/DeepSpeech.png) +The main and most computationally expensive part of the model converts the preprocessed audio into text. +There are two specificities with the supported part of the model. -As you can see, the frozen model still has two variables: `previous_state_c` and -`previous_state_h`. It means that the model keeps training those variables at each inference. +The first is that the model contains an input with sequence length. So the model can be converted with +a fixed input length shape, thus the model is not reshapeable. +Refer to the [Using Shape Inference](../../../../IE_DG/ShapeInference.md). -At the first inference of this graph, the variables are initialized by zero tensors. After executing the `lstm_fused_cell` nodes, cell state and hidden state, which are the results of the `BlockLSTM` execution, are assigned to these two variables. +The second is that the frozen model still has two variables: `previous_state_c` and `previous_state_h`, figure +with the frozen *.pb model is below. It means that the model keeps training these variables at each inference. -With each inference of the DeepSpeech graph, initial cell state and hidden state data for `BlockLSTM` is taken from previous inference from variables. Outputs (cell state and hidden state) of `BlockLSTM` are reassigned to the same variables. +![DeepSpeech model view](../../../img/DeepSpeech-0.8.2.png) -It helps the model to remember the context of the words that it takes as input. +At the first inference the variables are initialized with zero tensors. After executing, the results of the `BlockLSTM` +are assigned to cell state and hidden state, which are these two variables. -## Convert the TensorFlow* DeepSpeech Model to IR +## Convert the Main Part of DeepSpeech Model into IR -The Model Optimizer assumes that the output model is for inference only. That is why you should cut those variables off and resolve keeping cell and hidden states on the application level. +Model Optimizer assumes that the output model is for inference only. That is why you should cut `previous_state_c` +and `previous_state_h` variables off and resolve keeping cell and hidden states on the application level. There are certain limitations for the model conversion: - Time length (`time_len`) and sequence length (`seq_len`) are equal. - Original model cannot be reshaped, so you should keep original shapes. -To generate the DeepSpeech Intermediate Representation (IR), provide the TensorFlow DeepSpeech model to the Model Optimizer with the following parameters: +To generate the IR, run the Model Optimizer with the following parameters: ```sh -python3 ./mo_tf.py \ ---input_model path_to_model/output_graph.pb \ ---freeze_placeholder_with_value input_lengths->[16] \ ---input input_node,previous_state_h/read,previous_state_c/read \ ---input_shape [1,16,19,26],[1,2048],[1,2048] \ ---output raw_logits,lstm_fused_cell/GatherNd,lstm_fused_cell/GatherNd_1 \ +python3 {path_to_mo}/mo_tf.py \ +--input_model output_graph.pb \ +--input "input_lengths->[16],input_node[1 16 19 26],previous_state_h[1 2048],previous_state_c[1 2048]" \ +--output "cudnn_lstm/rnn/multi_rnn_cell/cell_0/cudnn_compatible_lstm_cell/GatherNd_1,cudnn_lstm/rnn/multi_rnn_cell/cell_0/cudnn_compatible_lstm_cell/GatherNd,logits" \ --disable_nhwc_to_nchw ``` Where: -* `--freeze_placeholder_with_value input_lengths->[16]` freezes sequence length -* `--input input_node,previous_state_h/read,previous_state_c/read` and -`--input_shape [1,16,19,26],[1,2048],[1,2048]` replace the variables with a placeholder -* `--output raw_logits,lstm_fused_cell/GatherNd,lstm_fused_cell/GatherNd_1` gets data for the next model -execution. +* `input_lengths->[16]` Replaces the input node with name "input_lengths" with a constant tensor of shape [1] with a + single integer value 16. This means that the model now can consume input sequences of length 16 only. +* `input_node[1 16 19 26],previous_state_h[1 2048],previous_state_c[1 2048]` replaces the variables with a placeholder. +* `--output ".../GatherNd_1,.../GatherNd,logits" ` output node names. From 4dc9c03511692fd8d71f660f495cf4953236b348 Mon Sep 17 00:00:00 2001 From: Ilya Naumov Date: Mon, 21 Jun 2021 21:08:21 +0300 Subject: [PATCH 151/178] Fix demo scripts (#6280) * Fix unknown command line flag errors if -sample-options is used * Fix raw escape sequences output with dashes * Fix raw escape sequences output with run_again message * try change sampleoptions to array --- scripts/demo/demo_benchmark_app.sh | 28 +++++++++---------- scripts/demo/demo_security_barrier_camera.sh | 20 ++++++------- .../demo_squeezenet_download_convert_run.sh | 24 ++++++++-------- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/scripts/demo/demo_benchmark_app.sh b/scripts/demo/demo_benchmark_app.sh index 25d1f94ae8eca7..a287c406d2b2e7 100755 --- a/scripts/demo/demo_benchmark_app.sh +++ b/scripts/demo/demo_benchmark_app.sh @@ -33,8 +33,8 @@ case $key in shift ;; -sample-options) - sampleoptions="$2 $3 $4 $5 $6" - echo sample-options = "${sampleoptions}" + sampleoptions=("${@:2}") + echo sample-options = "${sampleoptions[*]}" shift ;; *) @@ -44,8 +44,8 @@ esac shift done -if ([ -z "$sampleoptions" ]); then - sampleoptions="-niter 1000" +if [ -z "${sampleoptions[*]}" ]; then + sampleoptions=( -niter 1000 ) fi target_precision="FP16" @@ -71,12 +71,12 @@ else fi if ! . "$setupvars_path" ; then - printf "Unable to run ./setupvars.sh. Please check its presence. %s" "${run_again}" + echo -ne "Unable to run ./setupvars.sh. Please check its presence. ${run_again}" exit 1 fi # Step 1. Download the Caffe model and the prototxt of the model -printf "%s" "${dashes}" +echo -ne "${dashes}" printf "\n\nDownloading the Caffe model and the prototxt" cur_path=$PWD @@ -143,7 +143,7 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then fi if ! command -v $python_binary &>/dev/null; then - printf "\n\nPython 3.5 (x64) or higher is not installed. It is required to run Model Optimizer, please install it. %s" "${run_again}" + echo -ne "\n\nPython 3.5 (x64) or higher is not installed. It is required to run Model Optimizer, please install it. ${run_again}" exit 1 fi @@ -166,14 +166,14 @@ ir_dir="${irs_path}/${model_dir}/${target_precision}" if [ ! -e "$ir_dir" ]; then # Step 2. Configure Model Optimizer - printf "%s" "${dashes}" + echo -ne "${dashes}" printf "Install Model Optimizer dependencies\n\n" cd "${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/install_prerequisites" . ./install_prerequisites.sh caffe cd "$cur_path" # Step 3. Convert a model with Model Optimizer - printf "%s" "${dashes}" + echo -ne "${dashes}" printf "Convert a model with Model Optimizer\n\n" mo_path="${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/mo.py" @@ -182,11 +182,11 @@ if [ ! -e "$ir_dir" ]; then print_and_run "$python_binary" "$downloader_dir/converter.py" --mo "$mo_path" --name "$model_name" -d "$models_path" -o "$irs_path" --precisions "$target_precision" else printf "\n\nTarget folder %s already exists. Skipping IR generation with Model Optimizer." "${ir_dir}" - printf "If you want to convert a model again, remove the entire %s folder. %s" "${ir_dir}" "${run_again}" + echo -ne "If you want to convert a model again, remove the entire ${ir_dir} folder. ${run_again}" fi # Step 4. Build samples -printf "%s" "${dashes}" +echo -ne "${dashes}" printf "Build Inference Engine samples\n\n" OS_PATH=$(uname -m) @@ -211,15 +211,15 @@ cmake -DCMAKE_BUILD_TYPE=Release "$samples_path" make $NUM_THREADS benchmark_app # Step 5. Run samples -printf "%s" "${dashes}" +echo -ne "${dashes}" printf "Run Inference Engine benchmark app\n\n" cd "$binaries_dir" cp -f "$ROOT_DIR/${model_name}.labels" "${ir_dir}/" -print_and_run ./benchmark_app -d "$target" -i "$target_image_path" -m "${ir_dir}/${model_name}.xml" -pc "${sampleoptions}" +print_and_run ./benchmark_app -d "$target" -i "$target_image_path" -m "${ir_dir}/${model_name}.xml" -pc "${sampleoptions[@]}" -printf "%s" "${dashes}" +echo -ne "${dashes}" printf "Inference Engine benchmark app completed successfully.\n\n" diff --git a/scripts/demo/demo_security_barrier_camera.sh b/scripts/demo/demo_security_barrier_camera.sh index eaf6cd6784e094..36e09cab7ba9fe 100755 --- a/scripts/demo/demo_security_barrier_camera.sh +++ b/scripts/demo/demo_security_barrier_camera.sh @@ -33,8 +33,8 @@ case $key in shift ;; -sample-options) - sampleoptions="$2 $3 $4 $5 $6" - echo sample-options = "${sampleoptions}" + sampleoptions=("${@:2}") + echo sample-options = "${sampleoptions[*]}" shift ;; *) @@ -112,7 +112,7 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then fi if ! command -v $python_binary &>/dev/null; then - printf "\n\nPython 3.5 (x64) or higher is not installed. It is required to run Model Optimizer, please install it. %s" "${run_again}" + echo -ne "\n\nPython 3.5 (x64) or higher is not installed. It is required to run Model Optimizer, please install it. ${run_again}" exit 1 fi @@ -128,12 +128,12 @@ else printf "Error: setupvars.sh is not found\n" fi if ! . "$setupvars_path" ; then - printf "Unable to run ./setupvars.sh. Please check its presence. %s" "${run_again}" + echo -ne "Unable to run ./setupvars.sh. Please check its presence. ${run_again}" exit 1 fi # Step 1. Downloading Intel models -printf "%s" "${dashes}" +echo -ne "${dashes}" printf "Downloading Intel models\n\n" @@ -161,13 +161,13 @@ while read -r model_opt model_name; do done < "$ROOT_DIR/demo_security_barrier_camera.conf" # Step 2. Build samples -printf "%s" "${dashes}" +echo -ne "${dashes}" printf "Build Inference Engine demos\n\n" demos_path="${INTEL_OPENVINO_DIR}/deployment_tools/open_model_zoo/demos" if ! command -v cmake &>/dev/null; then - printf "\n\nCMAKE is not installed. It is required to build Inference Engine demos. Please install it. %s" "${run_again}" + echo -ne "\n\nCMAKE is not installed. It is required to build Inference Engine demos. Please install it. ${run_again}" exit 1 fi @@ -189,13 +189,13 @@ cmake -DCMAKE_BUILD_TYPE=Release "$demos_path" make $NUM_THREADS security_barrier_camera_demo # Step 3. Run samples -printf "%s" "${dashes}" +echo -ne "${dashes}" printf "Run Inference Engine security_barrier_camera demo\n\n" binaries_dir="${build_dir}/${OS_PATH}/Release" cd "$binaries_dir" -print_and_run ./security_barrier_camera_demo -d "$target" -d_va "$target" -d_lpr "$target" -i "$target_image_path" "${model_args[@]}" "${sampleoptions}" +print_and_run ./security_barrier_camera_demo -d "$target" -d_va "$target" -d_lpr "$target" -i "$target_image_path" "${model_args[@]}" "${sampleoptions[@]}" -printf "%s" "${dashes}" +echo -ne "${dashes}" printf "Demo completed successfully.\n\n" diff --git a/scripts/demo/demo_squeezenet_download_convert_run.sh b/scripts/demo/demo_squeezenet_download_convert_run.sh index 91a9055375b7ef..24fc26c335c9bd 100755 --- a/scripts/demo/demo_squeezenet_download_convert_run.sh +++ b/scripts/demo/demo_squeezenet_download_convert_run.sh @@ -33,8 +33,8 @@ case $key in shift ;; -sample-options) - sampleoptions="$2 $3 $4 $5 $6" - echo sample-options = "${sampleoptions}" + sampleoptions=("${@:2}") + echo sample-options = "${sampleoptions[*]}" shift ;; *) @@ -67,12 +67,12 @@ else fi if ! . "$setupvars_path" ; then - printf "Unable to run ./setupvars.sh. Please check its presence. %s" "${run_again}" + echo -ne "Unable to run ./setupvars.sh. Please check its presence. ${run_again}" exit 1 fi # Step 1. Download the Caffe model and the prototxt of the model -printf "%s" "${dashes}" +echo -ne "${dashes}" printf "\n\nDownloading the Caffe model and the prototxt" cur_path=$PWD @@ -139,7 +139,7 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then fi if ! command -v $python_binary &>/dev/null; then - printf "\n\nPython 3.5 (x64) or higher is not installed. It is required to run Model Optimizer, please install it. %s" "${run_again}" + echo -ne "\n\nPython 3.5 (x64) or higher is not installed. It is required to run Model Optimizer, please install it. ${run_again}" exit 1 fi @@ -162,14 +162,14 @@ ir_dir="${irs_path}/${model_dir}/${target_precision}" if [ ! -e "$ir_dir" ]; then # Step 2. Configure Model Optimizer - printf "%s" "${dashes}" + echo -ne "${dashes}" printf "Install Model Optimizer dependencies\n\n" cd "${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/install_prerequisites" . ./install_prerequisites.sh caffe cd "$cur_path" # Step 3. Convert a model with Model Optimizer - printf "%s" "${dashes}" + echo -ne "${dashes}" printf "Convert a model with Model Optimizer\n\n" mo_path="${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/mo.py" @@ -178,11 +178,11 @@ if [ ! -e "$ir_dir" ]; then print_and_run "$python_binary" "$downloader_dir/converter.py" --mo "$mo_path" --name "$model_name" -d "$models_path" -o "$irs_path" --precisions "$target_precision" else printf "\n\nTarget folder %s already exists. Skipping IR generation with Model Optimizer." "${ir_dir}" - printf "If you want to convert a model again, remove the entire %s folder. %s" "${ir_dir}" "${run_again}" + echo -ne "If you want to convert a model again, remove the entire ${ir_dir} folder. ${run_again}" fi # Step 4. Build samples -printf "%s" "${dashes}" +echo -ne "${dashes}" printf "Build Inference Engine samples\n\n" OS_PATH=$(uname -m) @@ -207,14 +207,14 @@ cmake -DCMAKE_BUILD_TYPE=Release "$samples_path" make $NUM_THREADS classification_sample_async # Step 5. Run samples -printf "%s" "${dashes}" +echo -ne "${dashes}" printf "Run Inference Engine classification sample\n\n" cd "$binaries_dir" cp -f "$ROOT_DIR/${model_name}.labels" "${ir_dir}/" -print_and_run ./classification_sample_async -d "$target" -i "$target_image_path" -m "${ir_dir}/${model_name}.xml" "${sampleoptions}" +print_and_run ./classification_sample_async -d "$target" -i "$target_image_path" -m "${ir_dir}/${model_name}.xml" "${sampleoptions[@]}" -printf "%s" "${dashes}" +echo -ne "${dashes}" printf "Demo completed successfully.\n\n" From 6926d5d6398ffd56725ffa57e38f57a3a1e1cae8 Mon Sep 17 00:00:00 2001 From: Mikhail Nosov Date: Tue, 22 Jun 2021 08:24:47 +0300 Subject: [PATCH 152/178] [nGraph FE] Python bindings for nGraph FrontEndManager API (#5995) * [NG Frontend] Introduce classes and macros for Frontend-specific exceptions * [nGraph Frontend] Python bindings Exposing Python API for nGraph FrontEndManager introduced in PR #5470 * [nGraph Frontend] Python bindings Exposing Python API for nGraph FrontEndManager introduced in PR #5470 * Added docs + moved sources to 'pyngraph/frontend' * Fix issues after rebase * Fix clang * Moving ngraph/python/tests_cpp to ngraph/python/tests/mock * Fix cmakelists-related comments * Apply review comments * Added dots to docstrings * Cmake - Set target properties for ARCHIVE/PDB/COMPILE_PDB as well as for LIBRARY_OUTPUT_DIRECTORY --- .../frontend/frontend_manager/CMakeLists.txt | 15 + ngraph/python/CMakeLists.txt | 17 +- ngraph/python/setup.py | 1 + ngraph/python/src/ngraph/__init__.py | 16 +- ngraph/python/src/ngraph/frontend/__init__.py | 23 + .../python/src/pyngraph/frontend/frontend.cpp | 124 ++++ .../python/src/pyngraph/frontend/frontend.hpp | 11 + .../pyngraph/frontend/frontend_manager.cpp | 163 ++++++ .../pyngraph/frontend/frontend_manager.hpp | 18 + .../src/pyngraph/frontend/inputmodel.cpp | 364 ++++++++++++ .../src/pyngraph/frontend/inputmodel.hpp | 11 + ngraph/python/src/pyngraph/frontend/place.cpp | 319 ++++++++++ ngraph/python/src/pyngraph/frontend/place.hpp | 11 + ngraph/python/src/pyngraph/pyngraph.cpp | 14 + .../mock_py_ngraph_frontend/CMakeLists.txt | 22 + .../mock_py_frontend.cpp | 25 + .../mock_py_frontend.hpp | 542 +++++++++++++++++ .../mock/pyngraph_fe_mock_api/CMakeLists.txt | 19 + .../pyngraph_mock_frontend_api.cpp | 136 +++++ .../tests/test_ngraph/test_frontendmanager.py | 545 ++++++++++++++++++ 20 files changed, 2393 insertions(+), 3 deletions(-) create mode 100644 ngraph/python/src/ngraph/frontend/__init__.py create mode 100644 ngraph/python/src/pyngraph/frontend/frontend.cpp create mode 100644 ngraph/python/src/pyngraph/frontend/frontend.hpp create mode 100644 ngraph/python/src/pyngraph/frontend/frontend_manager.cpp create mode 100644 ngraph/python/src/pyngraph/frontend/frontend_manager.hpp create mode 100644 ngraph/python/src/pyngraph/frontend/inputmodel.cpp create mode 100644 ngraph/python/src/pyngraph/frontend/inputmodel.hpp create mode 100644 ngraph/python/src/pyngraph/frontend/place.cpp create mode 100644 ngraph/python/src/pyngraph/frontend/place.hpp create mode 100644 ngraph/python/tests/mock/mock_py_ngraph_frontend/CMakeLists.txt create mode 100644 ngraph/python/tests/mock/mock_py_ngraph_frontend/mock_py_frontend.cpp create mode 100644 ngraph/python/tests/mock/mock_py_ngraph_frontend/mock_py_frontend.hpp create mode 100644 ngraph/python/tests/mock/pyngraph_fe_mock_api/CMakeLists.txt create mode 100644 ngraph/python/tests/mock/pyngraph_fe_mock_api/pyngraph_mock_frontend_api.cpp create mode 100644 ngraph/python/tests/test_ngraph/test_frontendmanager.py diff --git a/ngraph/frontend/frontend_manager/CMakeLists.txt b/ngraph/frontend/frontend_manager/CMakeLists.txt index 5efd560357b357..d11be1439114ff 100644 --- a/ngraph/frontend/frontend_manager/CMakeLists.txt +++ b/ngraph/frontend/frontend_manager/CMakeLists.txt @@ -33,3 +33,18 @@ target_include_directories(${TARGET_NAME} PUBLIC $/python_api/${PYTHON_VERSION}/) @@ -73,11 +74,25 @@ file(GLOB_RECURSE SOURCES src/pyngraph/*.cpp) pybind11_add_module(_${PROJECT_NAME} MODULE ${SOURCES}) target_include_directories(_${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src") -target_link_libraries(_${PROJECT_NAME} PRIVATE ngraph::ngraph) + +target_link_libraries(_${PROJECT_NAME} PRIVATE ngraph::ngraph ngraph::frontend_manager) + if (TARGET ngraph::onnx_importer) add_dependencies(_${PROJECT_NAME} ngraph::onnx_importer) endif() +if(NGRAPH_UNIT_TEST_ENABLE) + add_subdirectory(tests/mock/mock_py_ngraph_frontend) + add_dependencies(_${PROJECT_NAME} mock_py_ngraph_frontend) + set_target_properties(mock_py_ngraph_frontend PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_DIRECTORY_BIN} + ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_DIRECTORY_BIN} + COMPILE_PDB_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_DIRECTORY_BIN} + PDB_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_DIRECTORY_BIN}) + + add_subdirectory(tests/mock/pyngraph_fe_mock_api) + add_dependencies(_${PROJECT_NAME} pybind_mock_frontend) +endif() + # perform copy if(OpenVINO_MAIN_SOURCE_DIR) add_custom_command(TARGET _${PROJECT_NAME} diff --git a/ngraph/python/setup.py b/ngraph/python/setup.py index dfbb03fad98c00..e90cc66d6d173d 100644 --- a/ngraph/python/setup.py +++ b/ngraph/python/setup.py @@ -39,6 +39,7 @@ "ngraph.impl.op", "ngraph.impl.op.util", "ngraph.impl.passes", + "ngraph.frontend", ] data_files = [] diff --git a/ngraph/python/src/ngraph/__init__.py b/ngraph/python/src/ngraph/__init__.py index 0b276049d33ea8..f51c5cea130510 100644 --- a/ngraph/python/src/ngraph/__init__.py +++ b/ngraph/python/src/ngraph/__init__.py @@ -11,11 +11,23 @@ except DistributionNotFound: __version__ = "0.0.0.dev0" -from ngraph.impl import Node + +from ngraph.impl import Dimension from ngraph.impl import Function +from ngraph.impl import Node +from ngraph.impl import PartialShape +from ngraph.frontend import FrontEnd +from ngraph.frontend import FrontEndCapabilities +from ngraph.frontend import FrontEndManager +from ngraph.frontend import GeneralFailure +from ngraph.frontend import NotImplementedFailure +from ngraph.frontend import InitializationFailure +from ngraph.frontend import InputModel +from ngraph.frontend import OpConversionFailure +from ngraph.frontend import OpValidationFailure +from ngraph.frontend import Place from ngraph.helpers import function_from_cnn from ngraph.helpers import function_to_cnn - from ngraph.opset7 import absolute from ngraph.opset7 import absolute as abs from ngraph.opset7 import acos diff --git a/ngraph/python/src/ngraph/frontend/__init__.py b/ngraph/python/src/ngraph/frontend/__init__.py new file mode 100644 index 00000000000000..0ea21ad7c8827b --- /dev/null +++ b/ngraph/python/src/ngraph/frontend/__init__.py @@ -0,0 +1,23 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +""" +Package: ngraph +Low level wrappers for the FrontEnd c++ api. +""" + +# flake8: noqa + +# main classes +from _pyngraph import FrontEndManager +from _pyngraph import FrontEnd +from _pyngraph import FrontEndCapabilities +from _pyngraph import InputModel +from _pyngraph import Place + +# exceptions +from _pyngraph import NotImplementedFailure +from _pyngraph import InitializationFailure +from _pyngraph import OpConversionFailure +from _pyngraph import OpValidationFailure +from _pyngraph import GeneralFailure diff --git a/ngraph/python/src/pyngraph/frontend/frontend.cpp b/ngraph/python/src/pyngraph/frontend/frontend.cpp new file mode 100644 index 00000000000000..ecc736b37f0269 --- /dev/null +++ b/ngraph/python/src/pyngraph/frontend/frontend.cpp @@ -0,0 +1,124 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include +#include + +#include "frontend_manager.hpp" +#include "frontend_manager/frontend_exceptions.hpp" +#include "frontend_manager/frontend_manager.hpp" +#include "pyngraph/function.hpp" + +namespace py = pybind11; + +void regclass_pyngraph_FrontEnd(py::module m) +{ + py::class_> fem( + m, "FrontEnd", py::dynamic_attr()); + fem.doc() = "ngraph.impl.FrontEnd wraps ngraph::frontend::FrontEnd"; + + fem.def("load_from_file", + &ngraph::frontend::FrontEnd::load_from_file, + py::arg("path"), + R"( + Loads an input model by specified model file path. + + Parameters + ---------- + path : str + Main model file path. + + Returns + ---------- + load_from_file : InputModel + Loaded input model. + )"); + + fem.def("convert", + static_cast (ngraph::frontend::FrontEnd::*)( + ngraph::frontend::InputModel::Ptr) const>(&ngraph::frontend::FrontEnd::convert), + py::arg("model"), + R"( + Completely convert and normalize entire function, throws if it is not possible. + + Parameters + ---------- + model : InputModel + Input model. + + Returns + ---------- + convert : Function + Fully converted nGraph function. + )"); + + fem.def("convert", + static_cast (ngraph::frontend::FrontEnd::*)( + std::shared_ptr) const>(&ngraph::frontend::FrontEnd::convert), + py::arg("function"), + R"( + Completely convert the remaining, not converted part of a function. + + Parameters + ---------- + function : Function + Partially converted nGraph function. + + Returns + ---------- + convert : Function + Fully converted nGraph function. + )"); + + fem.def("convert_partially", + &ngraph::frontend::FrontEnd::convert_partially, + py::arg("model"), + R"( + Convert only those parts of the model that can be converted leaving others as-is. + Converted parts are not normalized by additional transformations; normalize function or + another form of convert function should be called to finalize the conversion process. + + Parameters + ---------- + model : InputModel + Input model. + + Returns + ---------- + convert_partially : Function + Partially converted nGraph function. + )"); + + fem.def("decode", + &ngraph::frontend::FrontEnd::decode, + py::arg("model"), + R"( + Convert operations with one-to-one mapping with decoding nodes. + Each decoding node is an nGraph node representing a single FW operation node with + all attributes represented in FW-independent way. + + Parameters + ---------- + model : InputModel + Input model. + + Returns + ---------- + decode : Function + nGraph function after decoding. + )"); + + fem.def("normalize", + &ngraph::frontend::FrontEnd::normalize, + py::arg("function"), + R"( + Runs normalization passes on function that was loaded with partial conversion. + + Parameters + ---------- + function : Function + Partially converted nGraph function. + )"); +} diff --git a/ngraph/python/src/pyngraph/frontend/frontend.hpp b/ngraph/python/src/pyngraph/frontend/frontend.hpp new file mode 100644 index 00000000000000..de28e950bb5c97 --- /dev/null +++ b/ngraph/python/src/pyngraph/frontend/frontend.hpp @@ -0,0 +1,11 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +namespace py = pybind11; + +void regclass_pyngraph_FrontEnd(py::module m); diff --git a/ngraph/python/src/pyngraph/frontend/frontend_manager.cpp b/ngraph/python/src/pyngraph/frontend/frontend_manager.cpp new file mode 100644 index 00000000000000..a550f22e516257 --- /dev/null +++ b/ngraph/python/src/pyngraph/frontend/frontend_manager.cpp @@ -0,0 +1,163 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include +#include + +#include "frontend_manager.hpp" +#include "frontend_manager/frontend_exceptions.hpp" +#include "frontend_manager/frontend_manager.hpp" + +namespace py = pybind11; + +void regclass_pyngraph_FrontEndManager(py::module m) +{ + py::class_> + fem(m, "FrontEndManager", py::dynamic_attr()); + fem.doc() = "ngraph.impl.FrontEndManager wraps ngraph::frontend::FrontEndManager"; + + fem.def(py::init<>()); + + fem.def("get_available_front_ends", + &ngraph::frontend::FrontEndManager::get_available_front_ends, + R"( + Gets list of registered frontends. + + Returns + ---------- + get_available_front_ends : List[str] + List of available frontend names. + )"); + fem.def("load_by_framework", + &ngraph::frontend::FrontEndManager::load_by_framework, + py::arg("framework"), + py::arg("capabilities") = ngraph::frontend::FrontEndCapabilities::FEC_DEFAULT, + R"( + Loads frontend by name of framework and capabilities. + + Parameters + ---------- + framework : str + Framework name. Throws exception if name is not in list of available frontends. + + capabilities : int + Frontend capabilities. Default is FrontEndCapabilities.FEC_DEFAULT. It is recommended to use only + those capabilities which are needed to minimize load time. + + Returns + ---------- + load_by_framework : FrontEnd + Frontend interface for further loading of models. + )"); +} + +void regclass_pyngraph_FEC(py::module m) +{ + class FeCaps + { + public: + int get_caps() const { return m_caps; } + + private: + int m_caps; + }; + + py::class_> type(m, "FrontEndCapabilities"); + // type.doc() = "FrontEndCapabilities"; + type.attr("DEFAULT") = ngraph::frontend::FrontEndCapabilities::FEC_DEFAULT; + type.attr("CUT") = ngraph::frontend::FrontEndCapabilities::FEC_CUT; + type.attr("NAMES") = ngraph::frontend::FrontEndCapabilities::FEC_NAMES; + type.attr("WILDCARDS") = ngraph::frontend::FrontEndCapabilities::FEC_WILDCARDS; + + type.def( + "__eq__", + [](const FeCaps& a, const FeCaps& b) { return a.get_caps() == b.get_caps(); }, + py::is_operator()); +} + +void regclass_pyngraph_GeneralFailureFrontEnd(py::module m) +{ + static py::exception exc(std::move(m), "GeneralFailure"); + py::register_exception_translator([](std::exception_ptr p) { + try + { + if (p) + std::rethrow_exception(p); + } + catch (const ngraph::frontend::GeneralFailure& e) + { + exc(e.what()); + } + }); +} + +void regclass_pyngraph_OpValidationFailureFrontEnd(py::module m) +{ + static py::exception exc(std::move(m), + "OpValidationFailure"); + py::register_exception_translator([](std::exception_ptr p) { + try + { + if (p) + std::rethrow_exception(p); + } + catch (const ngraph::frontend::OpValidationFailure& e) + { + exc(e.what()); + } + }); +} + +void regclass_pyngraph_OpConversionFailureFrontEnd(py::module m) +{ + static py::exception exc(std::move(m), + "OpConversionFailure"); + py::register_exception_translator([](std::exception_ptr p) { + try + { + if (p) + std::rethrow_exception(p); + } + catch (const ngraph::frontend::OpConversionFailure& e) + { + exc(e.what()); + } + }); +} + +void regclass_pyngraph_InitializationFailureFrontEnd(py::module m) +{ + static py::exception exc(std::move(m), + "InitializationFailure"); + py::register_exception_translator([](std::exception_ptr p) { + try + { + if (p) + std::rethrow_exception(p); + } + catch (const ngraph::frontend::InitializationFailure& e) + { + exc(e.what()); + } + }); +} + +void regclass_pyngraph_NotImplementedFailureFrontEnd(py::module m) +{ + static py::exception exc(std::move(m), + "NotImplementedFailure"); + py::register_exception_translator([](std::exception_ptr p) { + try + { + if (p) + std::rethrow_exception(p); + } + catch (const ngraph::frontend::NotImplementedFailure& e) + { + exc(e.what()); + } + }); +} diff --git a/ngraph/python/src/pyngraph/frontend/frontend_manager.hpp b/ngraph/python/src/pyngraph/frontend/frontend_manager.hpp new file mode 100644 index 00000000000000..35caa7e5dd1def --- /dev/null +++ b/ngraph/python/src/pyngraph/frontend/frontend_manager.hpp @@ -0,0 +1,18 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +namespace py = pybind11; + +void regclass_pyngraph_FrontEndManager(py::module m); +void regclass_pyngraph_FEC(py::module m); +void regclass_pyngraph_NotImplementedFailureFrontEnd(py::module m); +void regclass_pyngraph_InitializationFailureFrontEnd(py::module m); +void regclass_pyngraph_OpConversionFailureFrontEnd(py::module m); +void regclass_pyngraph_OpValidationFailureFrontEnd(py::module m); +void regclass_pyngraph_GeneralFailureFrontEnd(py::module m); + diff --git a/ngraph/python/src/pyngraph/frontend/inputmodel.cpp b/ngraph/python/src/pyngraph/frontend/inputmodel.cpp new file mode 100644 index 00000000000000..f8775763806d97 --- /dev/null +++ b/ngraph/python/src/pyngraph/frontend/inputmodel.cpp @@ -0,0 +1,364 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include +#include + +#include "frontend_manager/frontend_exceptions.hpp" +#include "frontend_manager/frontend_manager.hpp" + +namespace py = pybind11; + +void regclass_pyngraph_InputModel(py::module m) +{ + py::class_> im( + m, "InputModel", py::dynamic_attr()); + im.doc() = "ngraph.impl.InputModel wraps ngraph::frontend::InputModel"; + + im.def("get_place_by_tensor_name", + &ngraph::frontend::InputModel::get_place_by_tensor_name, + py::arg("tensorName"), + R"( + Returns a tensor place by a tensor name following framework conventions, or + nullptr if a tensor with this name doesn't exist. + + Parameters + ---------- + tensorName : str + Name of tensor. + + Returns + ---------- + get_place_by_tensor_name : Place + Tensor place corresponding to specified tensor name. + )"); + + im.def("get_place_by_operation_name", + &ngraph::frontend::InputModel::get_place_by_operation_name, + py::arg("operationName"), + R"( + Returns an operation place by an operation name following framework conventions, or + nullptr if an operation with this name doesn't exist. + + Parameters + ---------- + operationName : str + Name of operation. + + Returns + ---------- + get_place_by_operation_name : Place + Place representing operation. + )"); + + im.def("get_place_by_operation_name_and_input_port", + &ngraph::frontend::InputModel::get_place_by_operation_name_and_input_port, + py::arg("operationName"), + py::arg("inputPortIndex"), + R"( + Returns an input port place by operation name and appropriate port index. + + Parameters + ---------- + operationName : str + Name of operation. + + inputPortIndex : int + Index of input port for this operation. + + Returns + ---------- + get_place_by_operation_name_and_input_port : Place + Place representing input port of operation. + )"); + + im.def("get_place_by_operation_name_and_output_port", + &ngraph::frontend::InputModel::get_place_by_operation_name_and_output_port, + py::arg("operationName"), + py::arg("outputPortIndex"), + R"( + Returns an output port place by operation name and appropriate port index. + + Parameters + ---------- + operationName : str + Name of operation. + + outputPortIndex : int + Index of output port for this operation. + + Returns + ---------- + get_place_by_operation_name_and_output_port : Place + Place representing output port of operation. + )"); + + im.def("set_name_for_tensor", + &ngraph::frontend::InputModel::set_name_for_tensor, + py::arg("tensor"), + py::arg("newName"), + R"( + Sets name for tensor. Overwrites existing names of this place. + + Parameters + ---------- + tensor : Place + Tensor place. + + newName : str + New name for this tensor. + )"); + + im.def("add_name_for_tensor", + &ngraph::frontend::InputModel::add_name_for_tensor, + py::arg("tensor"), + py::arg("newName"), + R"( + Adds new name for tensor + + Parameters + ---------- + tensor : Place + Tensor place. + + newName : str + New name to be added to this place. + )"); + + im.def("set_name_for_operation", + &ngraph::frontend::InputModel::set_name_for_operation, + py::arg("operation"), + py::arg("newName"), + R"( + Adds new name for tensor. + + Parameters + ---------- + operation : Place + Operation place. + + newName : str + New name for this operation. + )"); + + im.def("free_name_for_tensor", + &ngraph::frontend::InputModel::free_name_for_tensor, + py::arg("name"), + R"( + Unassign specified name from tensor place(s). + + Parameters + ---------- + name : str + Name of tensor. + )"); + + im.def("free_name_for_operation", + &ngraph::frontend::InputModel::free_name_for_operation, + py::arg("name"), + R"( + Unassign specified name from operation place(s). + + Parameters + ---------- + name : str + Name of operation. + )"); + + im.def("set_name_for_dimension", + &ngraph::frontend::InputModel::set_name_for_dimension, + py::arg("place"), + py::arg("dimIndex"), + py::arg("dimName"), + R"( + Set name for a particular dimension of a place (e.g. batch dimension). + + Parameters + ---------- + place : Place + Model's place. + + shapeDimIndex : int + Dimension index. + + dimName : str + Name to assign on this dimension. + )"); + + im.def("cut_and_add_new_input", + &ngraph::frontend::InputModel::cut_and_add_new_input, + py::arg("place"), + py::arg("newName") = std::string(), + R"( + Cut immediately before this place and assign this place as new input; prune + all nodes that don't contribute to any output. + + Parameters + ---------- + place : Place + New place to be assigned as input. + + newNameOptional : str + Optional new name assigned to this input place. + )"); + + im.def("cut_and_add_new_output", + &ngraph::frontend::InputModel::cut_and_add_new_output, + py::arg("place"), + py::arg("newName") = std::string(), + R"( + Cut immediately before this place and assign this place as new output; prune + all nodes that don't contribute to any output. + + Parameters + ---------- + place : Place + New place to be assigned as output. + + newNameOptional : str + Optional new name assigned to this output place. + )"); + + im.def("add_output", + &ngraph::frontend::InputModel::add_output, + py::arg("place"), + R"( + Assign this place as new output or add necessary nodes to represent a new output. + + Parameters + ---------- + place : Place + Anchor point to add an output. + )"); + + im.def("remove_output", + &ngraph::frontend::InputModel::remove_output, + py::arg("place"), + R"( + Removes any sinks directly attached to this place with all inbound data flow + if it is not required by any other output. + + Parameters + ---------- + place : Place + Model place + )"); + + im.def("set_partial_shape", + &ngraph::frontend::InputModel::set_partial_shape, + py::arg("place"), + py::arg("shape"), + R"( + Defines all possible shape that may be used for this place; place should be + uniquely refer to some data. This partial shape will be converted to corresponding + shape of results ngraph nodes and will define shape inference when the model is + converted to ngraph. + + Parameters + ---------- + place : Place + Model place. + + shape : PartialShape + Partial shape for this place. + )"); + + im.def("get_partial_shape", + &ngraph::frontend::InputModel::get_partial_shape, + py::arg("place"), + R"( + Returns current partial shape used for this place. + + Parameters + ---------- + place : Place + Model place + + Returns + ---------- + get_partial_shape : PartialShape + Partial shape for this place. + )"); + + im.def("get_inputs", + &ngraph::frontend::InputModel::get_inputs, + R"( + Returns all inputs for a model. + + Returns + ---------- + get_inputs : List[Place] + A list of input places. + )"); + + im.def("get_outputs", + &ngraph::frontend::InputModel::get_outputs, + R"( + Returns all outputs for a model. An output is a terminal place in a graph where data escapes the flow. + + Returns + ---------- + get_outputs : List[Place] + A list of output places + )"); + + im.def("extract_subgraph", + &ngraph::frontend::InputModel::extract_subgraph, + py::arg("inputs"), + py::arg("outputs"), + R"( + Leaves only subgraph that are defined by new inputs and new outputs. + + Parameters + ---------- + inputs : List[Place] + Array of new input places. + + outputs : List[Place] + Array of new output places. + )"); + + im.def("override_all_inputs", + &ngraph::frontend::InputModel::override_all_inputs, + py::arg("inputs"), + R"( + Modifies the graph to use new inputs instead of existing ones. New inputs + should completely satisfy all existing outputs. + + Parameters + ---------- + inputs : List[Place] + Array of new input places. + )"); + + im.def("override_all_outputs", + &ngraph::frontend::InputModel::override_all_outputs, + py::arg("outputs"), + R"( + Replaces all existing outputs with new ones removing all data flow that + is not required for new outputs. + + Parameters + ---------- + outputs : List[Place] + Vector with places that will become new outputs; may intersect existing outputs. + )"); + + im.def("set_element_type", + &ngraph::frontend::InputModel::set_element_type, + py::arg("place"), + py::arg("type"), + R"( + Sets new element type for a place. + + Parameters + ---------- + place : Place + Model place. + + type : ngraph.Type + New element type. + )"); +} diff --git a/ngraph/python/src/pyngraph/frontend/inputmodel.hpp b/ngraph/python/src/pyngraph/frontend/inputmodel.hpp new file mode 100644 index 00000000000000..e95179c4a8cddc --- /dev/null +++ b/ngraph/python/src/pyngraph/frontend/inputmodel.hpp @@ -0,0 +1,11 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +namespace py = pybind11; + +void regclass_pyngraph_InputModel(py::module m); diff --git a/ngraph/python/src/pyngraph/frontend/place.cpp b/ngraph/python/src/pyngraph/frontend/place.cpp new file mode 100644 index 00000000000000..19bc36ef13a3b0 --- /dev/null +++ b/ngraph/python/src/pyngraph/frontend/place.cpp @@ -0,0 +1,319 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include +#include + +#include "frontend_manager.hpp" +#include "frontend_manager/frontend_exceptions.hpp" +#include "frontend_manager/frontend_manager.hpp" +#include "pyngraph/function.hpp" + +namespace py = pybind11; + +void regclass_pyngraph_Place(py::module m) +{ + py::class_> place( + m, "Place", py::dynamic_attr()); + place.doc() = "ngraph.impl.Place wraps ngraph::frontend::Place"; + + place.def("is_input", + &ngraph::frontend::Place::is_input, + R"( + Returns true if this place is input for a model. + + Returns + ---------- + is_input : bool + True if this place is input for a model + )"); + + place.def("is_output", + &ngraph::frontend::Place::is_output, + R"( + Returns true if this place is output for a model. + + Returns + ---------- + is_output : bool + True if this place is output for a model. + )"); + + place.def("get_names", + &ngraph::frontend::Place::get_names, + R"( + All associated names (synonyms) that identify this place in the graph in a framework specific way. + + Returns + ---------- + get_names : List[str] + 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. + )"); + + place.def("is_equal", + &ngraph::frontend::Place::is_equal, + py::arg("other"), + R"( + Returns true if another place is the same as this place. + + Parameters + ---------- + other : Place + Another place object. + + Returns + ---------- + is_equal : bool + True if another place is the same as this place. + )"); + + place.def("is_equal_data", + &ngraph::frontend::Place::is_equal_data, + py::arg("other"), + R"( + Returns true if another place points to the same data. + Note: The same data means all places on path: + output port -> output edge -> tensor -> input edge -> input port. + + Parameters + ---------- + other : Place + Another place object. + + Returns + ---------- + is_equal_data : bool + True if another place points to the same data. + )"); + + place.def( + "get_consuming_operations", + [](const ngraph::frontend::Place& self, py::object outputPortIndex) { + if (outputPortIndex == py::none()) + { + return self.get_consuming_operations(); + } + else + { + return self.get_consuming_operations(py::cast(outputPortIndex)); + } + }, + py::arg("outputPortIndex") = py::none(), + R"( + Returns references to all operation nodes that consume data from this place for specified output port. + Note: It can be called for any kind of graph place searching for the first consuming operations. + + Parameters + ---------- + outputPortIndex : int + If place is an operational node it specifies which output port should be considered + May not be set if node has only one output port. + + Returns + ---------- + get_consuming_operations : List[Place] + A list with all operation node references that consumes data from this place + )"); + + place.def( + "get_target_tensor", + [](const ngraph::frontend::Place& self, py::object outputPortIndex) { + if (outputPortIndex == py::none()) + { + return self.get_target_tensor(); + } + else + { + return self.get_target_tensor(py::cast(outputPortIndex)); + } + }, + py::arg("outputPortIndex") = py::none(), + R"( + Returns a tensor place that gets data from this place; applicable for operations, + output ports and output edges. + + Parameters + ---------- + outputPortIndex : int + Output port index if the current place is an operation node and has multiple output ports. + May not be set if place has only one output port. + + Returns + ---------- + get_consuming_operations : Place + A tensor place which hold the resulting value for this place. + )"); + + place.def( + "get_producing_operation", + [](const ngraph::frontend::Place& self, py::object inputPortIndex) { + if (inputPortIndex == py::none()) + { + return self.get_producing_operation(); + } + else + { + return self.get_producing_operation(py::cast(inputPortIndex)); + } + }, + py::arg("inputPortIndex") = py::none(), + R"( + Get an operation node place that immediately produces data for this place. + + Parameters + ---------- + inputPortIndex : int + If a given place is itself an operation node, this specifies a port index. + May not be set if place has only one input port. + + Returns + ---------- + get_producing_operation : Place + An operation place that produces data for this place. + )"); + + place.def("get_producing_port", + &ngraph::frontend::Place::get_producing_port, + R"( + Returns a port that produces data for this place. + + Returns + ---------- + get_producing_port : Place + A port place that produces data for this place. + )"); + + place.def( + "get_input_port", + [](const ngraph::frontend::Place& self, py::object inputName, py::object inputPortIndex) { + if (inputName == py::none()) + { + if (inputPortIndex == py::none()) + { + return self.get_input_port(); + } + else + { + return self.get_input_port(py::cast(inputPortIndex)); + } + } + else + { + if (inputPortIndex == py::none()) + { + return self.get_input_port(py::cast(inputName)); + } + else + { + return self.get_input_port(py::cast(inputName), + py::cast(inputPortIndex)); + } + } + }, + py::arg("inputName") = py::none(), + py::arg("inputPortIndex") = py::none(), + R"( + For operation node returns reference to an input port with specified name and index. + + Parameters + ---------- + inputName : str + Name of port group. May not be set if node has one input port group. + + inputPortIndex : int + Input port index in a group. May not be set if node has one input port in a group. + + Returns + ---------- + get_input_port : Place + Appropriate input port place. + )"); + + place.def( + "get_output_port", + [](const ngraph::frontend::Place& self, py::object outputName, py::object outputPortIndex) { + if (outputName == py::none()) + { + if (outputPortIndex == py::none()) + { + return self.get_output_port(); + } + else + { + return self.get_output_port(py::cast(outputPortIndex)); + } + } + else + { + if (outputPortIndex == py::none()) + { + return self.get_output_port(py::cast(outputName)); + } + else + { + return self.get_output_port(py::cast(outputName), + py::cast(outputPortIndex)); + } + } + }, + py::arg("outputName") = py::none(), + py::arg("outputPortIndex") = py::none(), + R"( + For operation node returns reference to an output port with specified name and index. + + Parameters + ---------- + outputName : str + Name of output port group. May not be set if node has one output port group. + + outputPortIndex : int + Output port index. May not be set if node has one output port in a group. + + Returns + ---------- + get_output_port : Place + Appropriate output port place. + )"); + + place.def("get_consuming_ports", + &ngraph::frontend::Place::get_consuming_ports, + R"( + Returns all input ports that consume data flows through this place. + + Returns + ---------- + get_consuming_ports : List[Place] + Input ports that consume data flows through this place. + )"); + + place.def( + "get_source_tensor", + [](const ngraph::frontend::Place& self, py::object inputPortIndex) { + if (inputPortIndex == py::none()) + { + return self.get_source_tensor(); + } + else + { + return self.get_source_tensor(py::cast(inputPortIndex)); + } + }, + py::arg("inputPortIndex") = py::none(), + R"( + Returns a tensor place that supplies data for this place; applicable for operations, + input ports and input edges. + + Parameters + ---------- + inputPortIndex : int + Input port index for operational node. May not be specified if place has only one input port. + + Returns + ---------- + get_source_tensor : Place + A tensor place which supplies data for this place. + )"); +} diff --git a/ngraph/python/src/pyngraph/frontend/place.hpp b/ngraph/python/src/pyngraph/frontend/place.hpp new file mode 100644 index 00000000000000..1a52e21f028e24 --- /dev/null +++ b/ngraph/python/src/pyngraph/frontend/place.hpp @@ -0,0 +1,11 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +namespace py = pybind11; + +void regclass_pyngraph_Place(py::module m); diff --git a/ngraph/python/src/pyngraph/pyngraph.cpp b/ngraph/python/src/pyngraph/pyngraph.cpp index 92b507b64834e1..0849de45f58554 100644 --- a/ngraph/python/src/pyngraph/pyngraph.cpp +++ b/ngraph/python/src/pyngraph/pyngraph.cpp @@ -17,6 +17,10 @@ #include "pyngraph/onnx_import/onnx_import.hpp" #endif #include "pyngraph/dimension.hpp" +#include "pyngraph/frontend/frontend.hpp" +#include "pyngraph/frontend/frontend_manager.hpp" +#include "pyngraph/frontend/inputmodel.hpp" +#include "pyngraph/frontend/place.hpp" #include "pyngraph/ops/constant.hpp" #include "pyngraph/ops/parameter.hpp" #include "pyngraph/ops/result.hpp" @@ -41,6 +45,16 @@ PYBIND11_MODULE(_pyngraph, m) regclass_pyngraph_Shape(m); regclass_pyngraph_PartialShape(m); regclass_pyngraph_Node(m); + regclass_pyngraph_Place(m); + regclass_pyngraph_InitializationFailureFrontEnd(m); + regclass_pyngraph_GeneralFailureFrontEnd(m); + regclass_pyngraph_OpConversionFailureFrontEnd(m); + regclass_pyngraph_OpValidationFailureFrontEnd(m); + regclass_pyngraph_NotImplementedFailureFrontEnd(m); + regclass_pyngraph_FEC(m); + regclass_pyngraph_FrontEndManager(m); + regclass_pyngraph_FrontEnd(m); + regclass_pyngraph_InputModel(m); regclass_pyngraph_Input(m); regclass_pyngraph_Output(m); regclass_pyngraph_NodeFactory(m); diff --git a/ngraph/python/tests/mock/mock_py_ngraph_frontend/CMakeLists.txt b/ngraph/python/tests/mock/mock_py_ngraph_frontend/CMakeLists.txt new file mode 100644 index 00000000000000..d39827b0f18830 --- /dev/null +++ b/ngraph/python/tests/mock/mock_py_ngraph_frontend/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + +set(TARGET_FE_NAME "mock_py_ngraph_frontend") + +file(GLOB_RECURSE LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +file(GLOB_RECURSE LIBRARY_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp) + +source_group("src" FILES ${LIBRARY_SRC}) +source_group("include" FILES ${LIBRARY_HEADERS}) + +# Create shared library +add_library(${TARGET_FE_NAME} SHARED ${LIBRARY_SRC} ${LIBRARY_HEADERS}) + +target_include_directories(${TARGET_FE_NAME} PRIVATE ".") + +target_include_directories(${TARGET_FE_NAME} PRIVATE ${FRONTEND_INCLUDE_PATH} ${NGRAPH_INCLUDE_PATH}) +target_link_libraries(${TARGET_FE_NAME} PRIVATE frontend_manager) +target_link_libraries(${TARGET_FE_NAME} PUBLIC ngraph PRIVATE ngraph::builder) + +add_clang_format_target(${TARGET_FE_NAME}_clang FOR_TARGETS ${TARGET_FE_NAME}) diff --git a/ngraph/python/tests/mock/mock_py_ngraph_frontend/mock_py_frontend.cpp b/ngraph/python/tests/mock/mock_py_ngraph_frontend/mock_py_frontend.cpp new file mode 100644 index 00000000000000..22a6e23a2b0a36 --- /dev/null +++ b/ngraph/python/tests/mock/mock_py_ngraph_frontend/mock_py_frontend.cpp @@ -0,0 +1,25 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "mock_py_frontend.hpp" +#include "frontend_manager/frontend_manager.hpp" +#include "frontend_manager/frontend_manager_defs.hpp" +#include "ngraph/visibility.hpp" + +using namespace ngraph; +using namespace ngraph::frontend; + +extern "C" MOCK_API FrontEndVersion GetAPIVersion() +{ + return OV_FRONTEND_API_VERSION; +} + +extern "C" MOCK_API void* GetFrontEndData() +{ + FrontEndPluginInfo* res = new FrontEndPluginInfo(); + res->m_name = "mock_py"; + res->m_creator = [](FrontEndCapFlags flags) { return std::make_shared(flags); }; + + return res; +} diff --git a/ngraph/python/tests/mock/mock_py_ngraph_frontend/mock_py_frontend.hpp b/ngraph/python/tests/mock/mock_py_ngraph_frontend/mock_py_frontend.hpp new file mode 100644 index 00000000000000..651e9e53809683 --- /dev/null +++ b/ngraph/python/tests/mock/mock_py_ngraph_frontend/mock_py_frontend.hpp @@ -0,0 +1,542 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "frontend_manager/frontend_manager.hpp" +#include "frontend_manager/frontend_manager_defs.hpp" +#include "ngraph/visibility.hpp" + +// Defined if we are building the plugin DLL (instead of using it) +#ifdef mock_py_ngraph_frontend_EXPORTS +#define MOCK_API NGRAPH_HELPER_DLL_EXPORT +#else +#define MOCK_API NGRAPH_HELPER_DLL_IMPORT +#endif // mock1_ngraph_frontend_EXPORTS + +// OK to have 'using' in mock header + +using namespace ngraph; +using namespace ngraph::frontend; + +//////////////////////////////// + +struct MOCK_API PlaceStat +{ + int m_get_names = 0; + int m_get_consuming_operations = 0; + int m_get_target_tensor = 0; + int m_get_producing_operation = 0; + int m_get_producing_port = 0; + int m_get_input_port = 0; + int m_get_output_port = 0; + int m_get_consuming_ports = 0; + int m_is_input = 0; + int m_is_output = 0; + int m_is_equal = 0; + int m_is_equal_data = 0; + int m_get_source_tensor = 0; + + // Arguments tracking + std::string m_lastArgString; + int m_lastArgInt; + Place::Ptr m_lastArgPlace = nullptr; + + // Getters + int get_names() const { return m_get_names; } + int get_consuming_operations() const { return m_get_consuming_operations; } + int get_target_tensor() const { return m_get_target_tensor; } + int get_producing_operation() const { return m_get_producing_operation; } + int get_producing_port() const { return m_get_producing_port; } + int get_input_port() const { return m_get_input_port; } + int get_output_port() const { return m_get_output_port; } + int get_consuming_ports() const { return m_get_consuming_ports; } + int is_input() const { return m_is_input; } + int is_output() const { return m_is_output; } + int is_equal() const { return m_is_equal; } + int is_equal_data() const { return m_is_equal_data; } + int get_source_tensor() const { return m_get_source_tensor; } + + // Arguments getters + std::string get_lastArgString() const { return m_lastArgString; } + int get_lastArgInt() const { return m_lastArgInt; } + Place::Ptr get_lastArgPlace() const { return m_lastArgPlace; } +}; + +class MOCK_API PlaceMockPy : public Place +{ + mutable PlaceStat m_stat; + +public: + std::vector get_names() const override + { + m_stat.m_get_names++; + return {}; + } + + std::vector get_consuming_operations() const override + { + m_stat.m_get_consuming_operations++; + m_stat.m_lastArgInt = -1; + return {std::make_shared()}; + } + + std::vector get_consuming_operations(int outputPortIndex) const override + { + m_stat.m_get_consuming_operations++; + m_stat.m_lastArgInt = outputPortIndex; + return {std::make_shared()}; + } + + Place::Ptr get_target_tensor() const override + { + m_stat.m_get_target_tensor++; + m_stat.m_lastArgInt = -1; + return std::make_shared(); + } + + Place::Ptr get_target_tensor(int outputPortIndex) const override + { + m_stat.m_get_target_tensor++; + m_stat.m_lastArgInt = outputPortIndex; + return std::make_shared(); + } + + Place::Ptr get_producing_operation() const override + { + m_stat.m_get_producing_operation++; + m_stat.m_lastArgInt = -1; + return std::make_shared(); + } + + Place::Ptr get_producing_operation(int inputPortIndex) const override + { + m_stat.m_get_producing_operation++; + m_stat.m_lastArgInt = inputPortIndex; + return std::make_shared(); + } + + Place::Ptr get_producing_port() const override + { + m_stat.m_get_producing_port++; + return std::make_shared(); + } + + Place::Ptr get_input_port() const override + { + m_stat.m_get_input_port++; + m_stat.m_lastArgInt = -1; + return std::make_shared(); + } + + Place::Ptr get_input_port(int inputPortIndex) const override + { + m_stat.m_get_input_port++; + m_stat.m_lastArgInt = inputPortIndex; + return std::make_shared(); + } + + Place::Ptr get_input_port(const std::string& inputName) const override + { + m_stat.m_get_input_port++; + m_stat.m_lastArgInt = -1; + m_stat.m_lastArgString = inputName; + return std::make_shared(); + } + + Place::Ptr get_input_port(const std::string& inputName, int inputPortIndex) const override + { + m_stat.m_get_input_port++; + m_stat.m_lastArgInt = inputPortIndex; + m_stat.m_lastArgString = inputName; + return std::make_shared(); + } + + Place::Ptr get_output_port() const override + { + m_stat.m_get_output_port++; + m_stat.m_lastArgInt = -1; + return std::make_shared(); + } + + Place::Ptr get_output_port(int outputPortIndex) const override + { + m_stat.m_get_output_port++; + m_stat.m_lastArgInt = outputPortIndex; + return std::make_shared(); + } + + Place::Ptr get_output_port(const std::string& outputName) const override + { + m_stat.m_get_output_port++; + m_stat.m_lastArgInt = -1; + m_stat.m_lastArgString = outputName; + return std::make_shared(); + } + + Place::Ptr get_output_port(const std::string& outputName, int outputPortIndex) const override + { + m_stat.m_get_output_port++; + m_stat.m_lastArgInt = outputPortIndex; + m_stat.m_lastArgString = outputName; + return std::make_shared(); + } + + std::vector get_consuming_ports() const override + { + m_stat.m_get_consuming_ports++; + return {std::make_shared()}; + } + + bool is_input() const override + { + m_stat.m_is_input++; + return false; + } + + bool is_output() const override + { + m_stat.m_is_output++; + return false; + } + + bool is_equal(Ptr another) const override + { + m_stat.m_is_equal++; + m_stat.m_lastArgPlace = another; + return false; + } + + bool is_equal_data(Ptr another) const override + { + m_stat.m_is_equal_data++; + m_stat.m_lastArgPlace = another; + return false; + } + + Place::Ptr get_source_tensor(int inputPortIndex) const override + { + m_stat.m_get_source_tensor++; + m_stat.m_lastArgInt = inputPortIndex; + return {std::make_shared()}; + } + + Place::Ptr get_source_tensor() const override + { + m_stat.m_get_source_tensor++; + m_stat.m_lastArgInt = -1; + return {std::make_shared()}; + } + + //---------------Stat-------------------- + PlaceStat get_stat() const { return m_stat; } +}; + +//////////////////////////////// + +struct MOCK_API ModelStat +{ + int m_get_inputs = 0; + int m_get_outputs = 0; + int m_get_place_by_tensor_name = 0; + int m_get_place_by_operation_name = 0; + int m_get_place_by_operation_and_input_port = 0; + int m_get_place_by_operation_and_output_port = 0; + int m_set_name_for_tensor = 0; + int m_add_name_for_tensor = 0; + int m_set_name_for_operation = 0; + int m_free_name_for_tensor = 0; + int m_free_name_for_operation = 0; + int m_set_name_for_dimension = 0; + int m_cut_and_add_new_input = 0; + int m_cut_and_add_new_output = 0; + int m_add_output = 0; + int m_remove_output = 0; + int m_set_partial_shape = 0; + int m_get_partial_shape = 0; + int m_set_element_type = 0; + + int m_extract_subgraph = 0; + int m_override_all_inputs = 0; + int m_override_all_outputs = 0; + + // Arguments tracking + std::string m_lastArgString; + int m_lastArgInt; + Place::Ptr m_lastArgPlace = nullptr; + std::vector m_lastArgInputPlaces; + std::vector m_lastArgOutputPlaces; + ngraph::element::Type m_lastArgElementType; + ngraph::PartialShape m_lastArgPartialShape; + + // Getters + int get_inputs() const { return m_get_inputs; } + int get_outputs() const { return m_get_outputs; } + int extract_subgraph() const { return m_extract_subgraph; } + int override_all_inputs() const { return m_override_all_inputs; } + int override_all_outputs() const { return m_override_all_outputs; } + int get_place_by_tensor_name() const { return m_get_place_by_tensor_name; } + int get_place_by_operation_name() const { return m_get_place_by_operation_name; } + int get_place_by_operation_and_input_port() const + { + return m_get_place_by_operation_and_input_port; + } + int get_place_by_operation_and_output_port() const + { + return m_get_place_by_operation_and_output_port; + } + int set_name_for_tensor() const { return m_set_name_for_tensor; } + int add_name_for_tensor() const { return m_add_name_for_tensor; } + int set_name_for_operation() const { return m_set_name_for_operation; } + int free_name_for_tensor() const { return m_free_name_for_tensor; } + int free_name_for_operation() const { return m_free_name_for_operation; } + int set_name_for_dimension() const { return m_set_name_for_dimension; } + int cut_and_add_new_input() const { return m_cut_and_add_new_input; } + int cut_and_add_new_output() const { return m_cut_and_add_new_output; } + int add_output() const { return m_add_output; } + int remove_output() const { return m_remove_output; } + int set_partial_shape() const { return m_set_partial_shape; } + int get_partial_shape() const { return m_get_partial_shape; } + int set_element_type() const { return m_set_element_type; } + + // Arguments getters + std::string get_lastArgString() const { return m_lastArgString; } + int get_lastArgInt() const { return m_lastArgInt; } + Place::Ptr get_lastArgPlace() const { return m_lastArgPlace; } + std::vector get_lastArgInputPlaces() const { return m_lastArgInputPlaces; } + std::vector get_lastArgOutputPlaces() const { return m_lastArgOutputPlaces; } + ngraph::element::Type get_lastArgElementType() const { return m_lastArgElementType; } + ngraph::PartialShape get_lastArgPartialShape() const { return m_lastArgPartialShape; } +}; + +class MOCK_API InputModelMockPy : public InputModel +{ + mutable ModelStat m_stat; + +public: + std::vector get_inputs() const override + { + m_stat.m_get_inputs++; + return {std::make_shared()}; + } + + std::vector get_outputs() const override + { + m_stat.m_get_outputs++; + return {std::make_shared()}; + } + + Place::Ptr get_place_by_tensor_name(const std::string& tensorName) const override + { + m_stat.m_get_place_by_tensor_name++; + m_stat.m_lastArgString = tensorName; + return std::make_shared(); + } + + Place::Ptr get_place_by_operation_name(const std::string& operationName) override + { + m_stat.m_get_place_by_operation_name++; + m_stat.m_lastArgString = operationName; + return std::make_shared(); + } + + Place::Ptr get_place_by_operation_name_and_input_port(const std::string& operationName, + int inputPortIndex) override + { + m_stat.m_get_place_by_operation_and_input_port++; + m_stat.m_lastArgInt = inputPortIndex; + m_stat.m_lastArgString = operationName; + return std::make_shared(); + } + + Place::Ptr get_place_by_operation_name_and_output_port(const std::string& operationName, + int outputPortIndex) override + { + m_stat.m_get_place_by_operation_and_output_port++; + m_stat.m_lastArgInt = outputPortIndex; + m_stat.m_lastArgString = operationName; + return std::make_shared(); + } + + void set_name_for_tensor(Place::Ptr tensor, const std::string& newName) override + { + m_stat.m_set_name_for_tensor++; + m_stat.m_lastArgPlace = tensor; + m_stat.m_lastArgString = newName; + } + + void add_name_for_tensor(Place::Ptr tensor, const std::string& newName) override + { + m_stat.m_add_name_for_tensor++; + m_stat.m_lastArgPlace = tensor; + m_stat.m_lastArgString = newName; + } + + void set_name_for_operation(Place::Ptr operation, const std::string& newName) override + { + m_stat.m_set_name_for_operation++; + m_stat.m_lastArgPlace = operation; + m_stat.m_lastArgString = newName; + } + + void free_name_for_tensor(const std::string& name) override + { + m_stat.m_free_name_for_tensor++; + m_stat.m_lastArgString = name; + } + + void free_name_for_operation(const std::string& name) override + { + m_stat.m_free_name_for_operation++; + m_stat.m_lastArgString = name; + } + + void set_name_for_dimension(Place::Ptr place, + size_t shapeDimIndex, + const std::string& dimName) override + { + m_stat.m_set_name_for_dimension++; + m_stat.m_lastArgPlace = place; + m_stat.m_lastArgInt = static_cast(shapeDimIndex); + m_stat.m_lastArgString = dimName; + } + + void cut_and_add_new_input(Place::Ptr place, const std::string& newNameOptional) override + { + m_stat.m_cut_and_add_new_input++; + m_stat.m_lastArgPlace = place; + m_stat.m_lastArgString = newNameOptional; + } + + void cut_and_add_new_output(Place::Ptr place, const std::string& newNameOptional) override + { + m_stat.m_cut_and_add_new_output++; + m_stat.m_lastArgPlace = place; + m_stat.m_lastArgString = newNameOptional; + } + + Place::Ptr add_output(Place::Ptr place) override + { + m_stat.m_add_output++; + m_stat.m_lastArgPlace = place; + return std::make_shared(); + } + + void remove_output(Place::Ptr place) override + { + m_stat.m_remove_output++; + m_stat.m_lastArgPlace = place; + } + + void override_all_outputs(const std::vector& outputs) override + { + m_stat.m_override_all_outputs++; + m_stat.m_lastArgOutputPlaces = outputs; + } + + void override_all_inputs(const std::vector& inputs) override + { + m_stat.m_override_all_inputs++; + m_stat.m_lastArgInputPlaces = inputs; + } + + void extract_subgraph(const std::vector& inputs, + const std::vector& outputs) override + { + m_stat.m_extract_subgraph++; + m_stat.m_lastArgInputPlaces = inputs; + m_stat.m_lastArgOutputPlaces = outputs; + } + + // Setting tensor properties + void set_partial_shape(Place::Ptr place, const ngraph::PartialShape& shape) override + { + m_stat.m_set_partial_shape++; + m_stat.m_lastArgPlace = place; + m_stat.m_lastArgPartialShape = shape; + } + + ngraph::PartialShape get_partial_shape(Place::Ptr place) const override + { + m_stat.m_get_partial_shape++; + m_stat.m_lastArgPlace = place; + return {}; + } + + void set_element_type(Place::Ptr place, const ngraph::element::Type& type) override + { + m_stat.m_set_element_type++; + m_stat.m_lastArgPlace = place; + m_stat.m_lastArgElementType = type; + } + + //---------------Stat-------------------- + ModelStat get_stat() const { return m_stat; } +}; + +///////////////////////////////////////////////////////// + +struct MOCK_API FeStat +{ + FrontEndCapFlags m_load_flags; + std::vector m_load_paths; + int m_convert_model = 0; + int m_convert = 0; + int m_convert_partially = 0; + int m_decode = 0; + int m_normalize = 0; + // Getters + FrontEndCapFlags load_flags() const { return m_load_flags; } + std::vector load_paths() const { return m_load_paths; } + int convert_model() const { return m_convert_model; } + int convert() const { return m_convert; } + int convert_partially() const { return m_convert_partially; } + int decode() const { return m_decode; } + int normalize() const { return m_normalize; } +}; + +class MOCK_API FrontEndMockPy : public FrontEnd +{ + mutable FeStat m_stat; + +public: + FrontEndMockPy(FrontEndCapFlags flags) { m_stat.m_load_flags = flags; } + + InputModel::Ptr load_from_file(const std::string& path) const override + { + m_stat.m_load_paths.push_back(path); + return std::make_shared(); + } + + std::shared_ptr convert(InputModel::Ptr model) const override + { + m_stat.m_convert_model++; + return std::make_shared(NodeVector{}, ParameterVector{}); + } + + std::shared_ptr convert(std::shared_ptr func) const override + { + m_stat.m_convert++; + return func; + } + + std::shared_ptr convert_partially(InputModel::Ptr model) const override + { + m_stat.m_convert_partially++; + return std::make_shared(NodeVector{}, ParameterVector{}); + } + + std::shared_ptr decode(InputModel::Ptr model) const override + { + m_stat.m_decode++; + return std::make_shared(NodeVector{}, ParameterVector{}); + } + + void normalize(std::shared_ptr function) const override + { + m_stat.m_normalize++; + } + + FeStat get_stat() const { return m_stat; } +}; diff --git a/ngraph/python/tests/mock/pyngraph_fe_mock_api/CMakeLists.txt b/ngraph/python/tests/mock/pyngraph_fe_mock_api/CMakeLists.txt new file mode 100644 index 00000000000000..7d2e4a3077acc0 --- /dev/null +++ b/ngraph/python/tests/mock/pyngraph_fe_mock_api/CMakeLists.txt @@ -0,0 +1,19 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + +set(TARGET_FE_NAME "mock_py_ngraph_frontend") +set(PYBIND_FE_NAME "pybind_mock_frontend") + +set(PYBIND_FE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/pyngraph_mock_frontend_api.cpp) + +source_group("src" FILES ${PYBIND_FE_SRC}) + +pybind11_add_module(${PYBIND_FE_NAME} MODULE ${PYBIND_FE_SRC}) + +target_link_libraries(${PYBIND_FE_NAME} PRIVATE ngraph::ngraph ngraph::frontend_manager) +target_link_libraries(${PYBIND_FE_NAME} PRIVATE ${TARGET_FE_NAME}) + +add_dependencies(${PYBIND_FE_NAME} ${TARGET_FE_NAME}) + +add_clang_format_target(${PYBIND_FE_NAME}_clang FOR_TARGETS ${PYBIND_FE_NAME}) diff --git a/ngraph/python/tests/mock/pyngraph_fe_mock_api/pyngraph_mock_frontend_api.cpp b/ngraph/python/tests/mock/pyngraph_fe_mock_api/pyngraph_mock_frontend_api.cpp new file mode 100644 index 00000000000000..ec87842d417330 --- /dev/null +++ b/ngraph/python/tests/mock/pyngraph_fe_mock_api/pyngraph_mock_frontend_api.cpp @@ -0,0 +1,136 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include + +#include "../mock_py_ngraph_frontend/mock_py_frontend.hpp" + +namespace py = pybind11; +using namespace ngraph; +using namespace ngraph::frontend; + +static void register_mock_frontend_stat(py::module m) +{ + m.def( + "get_fe_stat", + [](const std::shared_ptr& fe) { + std::shared_ptr ptr = std::dynamic_pointer_cast(fe); + if (ptr) + { + auto stat = ptr->get_stat(); + return stat; + } + return FeStat(); + }, + py::arg("frontend")); + + py::class_ feStat(m, "FeStat", py::dynamic_attr()); + feStat.def_property_readonly("load_flags", &FeStat::load_flags); + feStat.def_property_readonly("load_paths", &FeStat::load_paths); + feStat.def_property_readonly("convert_model", &FeStat::convert_model); + feStat.def_property_readonly("convert", &FeStat::convert); + feStat.def_property_readonly("convert_partially", &FeStat::convert_partially); + feStat.def_property_readonly("decode", &FeStat::decode); + feStat.def_property_readonly("normalize", &FeStat::normalize); +} + +static void register_mock_model_stat(py::module m) +{ + m.def( + "get_mdl_stat", + [](const std::shared_ptr& mdl) { + std::shared_ptr ptr = + std::dynamic_pointer_cast(mdl); + if (ptr) + { + auto stat = ptr->get_stat(); + return stat; + } + return ModelStat(); + }, + py::arg("model")); + + py::class_ mdlStat(m, "ModelStat", py::dynamic_attr()); + mdlStat.def_property_readonly("get_inputs", &ModelStat::get_inputs); + mdlStat.def_property_readonly("get_outputs", &ModelStat::get_outputs); + mdlStat.def_property_readonly("get_place_by_tensor_name", &ModelStat::get_place_by_tensor_name); + mdlStat.def_property_readonly("get_place_by_operation_name", + &ModelStat::get_place_by_operation_name); + mdlStat.def_property_readonly("get_place_by_operation_and_input_port", + &ModelStat::get_place_by_operation_and_input_port); + mdlStat.def_property_readonly("get_place_by_operation_and_output_port", + &ModelStat::get_place_by_operation_and_output_port); + + mdlStat.def_property_readonly("set_name_for_tensor", &ModelStat::set_name_for_tensor); + mdlStat.def_property_readonly("add_name_for_tensor", &ModelStat::add_name_for_tensor); + mdlStat.def_property_readonly("set_name_for_operation", &ModelStat::set_name_for_operation); + mdlStat.def_property_readonly("free_name_for_tensor", &ModelStat::free_name_for_tensor); + mdlStat.def_property_readonly("free_name_for_operation", &ModelStat::free_name_for_operation); + mdlStat.def_property_readonly("set_name_for_dimension", &ModelStat::set_name_for_dimension); + mdlStat.def_property_readonly("cut_and_add_new_input", &ModelStat::cut_and_add_new_input); + mdlStat.def_property_readonly("cut_and_add_new_output", &ModelStat::cut_and_add_new_output); + mdlStat.def_property_readonly("add_output", &ModelStat::add_output); + mdlStat.def_property_readonly("remove_output", &ModelStat::remove_output); + mdlStat.def_property_readonly("set_partial_shape", &ModelStat::set_partial_shape); + mdlStat.def_property_readonly("get_partial_shape", &ModelStat::get_partial_shape); + mdlStat.def_property_readonly("set_element_type", &ModelStat::set_element_type); + mdlStat.def_property_readonly("extract_subgraph", &ModelStat::extract_subgraph); + mdlStat.def_property_readonly("override_all_inputs", &ModelStat::override_all_inputs); + mdlStat.def_property_readonly("override_all_outputs", &ModelStat::override_all_outputs); + + // Arguments tracking + mdlStat.def_property_readonly("lastArgString", &ModelStat::get_lastArgString); + mdlStat.def_property_readonly("lastArgInt", &ModelStat::get_lastArgInt); + mdlStat.def_property_readonly("lastArgPlace", &ModelStat::get_lastArgPlace); + mdlStat.def_property_readonly("lastArgInputPlaces", &ModelStat::get_lastArgInputPlaces); + mdlStat.def_property_readonly("lastArgOutputPlaces", &ModelStat::get_lastArgOutputPlaces); + mdlStat.def_property_readonly("lastArgElementType", &ModelStat::get_lastArgElementType); + mdlStat.def_property_readonly("lastArgPartialShape", &ModelStat::get_lastArgPartialShape); +} + +static void register_mock_place_stat(py::module m) +{ + m.def( + "get_place_stat", + [](const Place::Ptr& fe) { + std::shared_ptr ptr = std::dynamic_pointer_cast(fe); + if (ptr) + { + auto stat = ptr->get_stat(); + return stat; + } + return PlaceStat(); + }, + py::arg("place")); + + py::class_ placeStat(m, "PlaceStat", py::dynamic_attr()); + + placeStat.def_property_readonly("lastArgString", &PlaceStat::get_lastArgString); + placeStat.def_property_readonly("lastArgInt", &PlaceStat::get_lastArgInt); + placeStat.def_property_readonly("lastArgPlace", &PlaceStat::get_lastArgPlace); + + placeStat.def_property_readonly("get_names", &PlaceStat::get_names); + placeStat.def_property_readonly("get_consuming_operations", + &PlaceStat::get_consuming_operations); + placeStat.def_property_readonly("get_target_tensor", &PlaceStat::get_target_tensor); + placeStat.def_property_readonly("get_producing_operation", &PlaceStat::get_producing_operation); + placeStat.def_property_readonly("get_producing_port", &PlaceStat::get_producing_port); + placeStat.def_property_readonly("get_input_port", &PlaceStat::get_input_port); + placeStat.def_property_readonly("get_output_port", &PlaceStat::get_output_port); + placeStat.def_property_readonly("get_consuming_ports", &PlaceStat::get_consuming_ports); + placeStat.def_property_readonly("is_input", &PlaceStat::is_input); + placeStat.def_property_readonly("is_output", &PlaceStat::is_output); + placeStat.def_property_readonly("is_equal", &PlaceStat::is_equal); + placeStat.def_property_readonly("is_equal_data", &PlaceStat::is_equal_data); + placeStat.def_property_readonly("get_source_tensor", &PlaceStat::get_source_tensor); +} + +PYBIND11_MODULE(pybind_mock_frontend, m) +{ + m.doc() = "Mock frontend call counters for testing Pyngraph frontend bindings"; + register_mock_frontend_stat(m); + register_mock_model_stat(m); + register_mock_place_stat(m); +} diff --git a/ngraph/python/tests/test_ngraph/test_frontendmanager.py b/ngraph/python/tests/test_ngraph/test_frontendmanager.py new file mode 100644 index 00000000000000..6c3d080657cc6f --- /dev/null +++ b/ngraph/python/tests/test_ngraph/test_frontendmanager.py @@ -0,0 +1,545 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest + +from ngraph import PartialShape +from ngraph.frontend import FrontEndCapabilities, FrontEndManager, InitializationFailure +from ngraph.utils.types import get_element_type + +mock_available = True +try: + from pybind_mock_frontend import get_fe_stat, get_mdl_stat, get_place_stat +except Exception: + print("No mock frontend available") + mock_available = False + +# FrontEndManager shall be initialized and destroyed after all tests finished +# This is because destroy of FrontEndManager will unload all plugins, no objects shall exist after this +fem = FrontEndManager() + +mock_needed = pytest.mark.skipif(not mock_available, + reason="mock fe is not available") + + +# ---------- FrontEnd tests --------------- +@mock_needed +def test_load_by_framework_caps(): + frontEnds = fem.get_available_front_ends() + assert frontEnds is not None + assert "mock_py" in frontEnds + caps = [FrontEndCapabilities.DEFAULT, + FrontEndCapabilities.CUT, + FrontEndCapabilities.NAMES, + FrontEndCapabilities.WILDCARDS, + FrontEndCapabilities.CUT | FrontEndCapabilities.NAMES | FrontEndCapabilities.WILDCARDS] + for cap in caps: + fe = fem.load_by_framework(framework="mock_py", capabilities=cap) + stat = get_fe_stat(fe) + assert cap == stat.load_flags + for i in range(len(caps) - 1): + for j in range(i + 1, len(caps)): + assert caps[i] != caps[j] + + +def test_load_by_unknown_framework(): + frontEnds = fem.get_available_front_ends() + assert not("UnknownFramework" in frontEnds) + try: + fem.load_by_framework("UnknownFramework") + except InitializationFailure as exc: + print(exc) + else: + raise AssertionError("Unexpected exception.") + + +@mock_needed +def test_load_from_file(): + fe = fem.load_by_framework(framework="mock_py") + assert fe is not None + model = fe.load_from_file("abc.bin") + assert model is not None + stat = get_fe_stat(fe) + assert "abc.bin" in stat.load_paths + + +@mock_needed +def test_convert_model(): + fe = fem.load_by_framework(framework="mock_py") + assert fe is not None + model = fe.load_from_file(path="") + func = fe.convert(model=model) + assert func is not None + stat = get_fe_stat(fe) + assert stat.convert_model == 1 + + +@mock_needed +def test_convert_partially(): + fe = fem.load_by_framework(framework="mock_py") + assert fe is not None + model = fe.load_from_file(path="") + func = fe.convert_partially(model=model) + stat = get_fe_stat(fe) + assert stat.convert_partially == 1 + fe.convert(function=func) + stat = get_fe_stat(fe) + assert stat.convert == 1 + + +@mock_needed +def test_decode_and_normalize(): + fe = fem.load_by_framework(framework="mock_py") + assert fe is not None + model = fe.load_from_file(path="") + func = fe.decode(model=model) + stat = get_fe_stat(fe) + assert stat.decode == 1 + fe.normalize(function=func) + stat = get_fe_stat(fe) + assert stat.normalize == 1 + assert stat.decode == 1 + + +# --------InputModel tests----------------- +@mock_needed +def init_model(): + fe = fem.load_by_framework(framework="mock_py") + model = fe.load_from_file(path="") + return model + + +@mock_needed +def test_model_get_inputs(): + model = init_model() + for i in range(1, 10): + model.get_inputs() + stat = get_mdl_stat(model) + assert stat.get_inputs == i + + +@mock_needed +def test_model_get_outputs(): + model = init_model() + for i in range(1, 10): + model.get_outputs() + stat = get_mdl_stat(model) + assert stat.get_outputs == i + + +@mock_needed +def test_model_get_place_by_tensor_name(): + model = init_model() + for i in range(1, 10): + name = str(i) + model.get_place_by_tensor_name(tensorName=name) + stat = get_mdl_stat(model) + assert stat.get_place_by_tensor_name == i + assert stat.lastArgString == name + + +@mock_needed +def test_model_get_place_by_operation_name(): + model = init_model() + for i in range(1, 10): + name = str(i) + model.get_place_by_operation_name(operationName=name) + stat = get_mdl_stat(model) + assert stat.get_place_by_operation_name == i + assert stat.lastArgString == name + + +@mock_needed +def test_model_get_place_by_operation_name_and_input_port(): + model = init_model() + for i in range(1, 10): + name = str(i) + model.get_place_by_operation_name_and_input_port(operationName=name, inputPortIndex=i * 2) + stat = get_mdl_stat(model) + assert stat.get_place_by_operation_and_input_port == i + assert stat.lastArgString == name + assert stat.lastArgInt == i * 2 + + +@mock_needed +def test_model_get_place_by_operation_name_and_output_port(): + model = init_model() + for i in range(1, 10): + name = str(i) + model.get_place_by_operation_name_and_output_port(operationName=name, outputPortIndex=i * 2) + stat = get_mdl_stat(model) + assert stat.get_place_by_operation_and_output_port == i + assert stat.lastArgString == name + assert stat.lastArgInt == i * 2 + + +@mock_needed +def test_model_set_name_for_tensor(): + model = init_model() + place = model.get_place_by_tensor_name(tensorName="") + model.set_name_for_tensor(tensor=place, newName="1234") + stat = get_mdl_stat(model) + assert stat.set_name_for_tensor == 1 + assert stat.lastArgString == "1234" + assert stat.lastArgPlace == place + + +@mock_needed +def test_model_add_name_for_tensor(): + model = init_model() + place = model.get_place_by_tensor_name(tensorName="") + model.add_name_for_tensor(tensor=place, newName="1234") + stat = get_mdl_stat(model) + assert stat.add_name_for_tensor == 1 + assert stat.lastArgString == "1234" + assert stat.lastArgPlace == place + + +@mock_needed +def test_model_set_name_for_operation(): + model = init_model() + place = model.get_place_by_operation_name(operationName="") + model.set_name_for_operation(operation=place, newName="1111") + stat = get_mdl_stat(model) + assert stat.set_name_for_operation == 1 + assert stat.lastArgString == "1111" + assert stat.lastArgPlace == place + + +@mock_needed +def test_model_free_name_for_tensor(): + model = init_model() + model.free_name_for_tensor(name="2222") + stat = get_mdl_stat(model) + assert stat.free_name_for_tensor == 1 + assert stat.lastArgString == "2222" + + +@mock_needed +def test_model_free_name_for_operation(): + model = init_model() + model.free_name_for_operation(name="3333") + stat = get_mdl_stat(model) + assert stat.free_name_for_operation == 1 + assert stat.lastArgString == "3333" + + +@mock_needed +def test_model_set_name_for_dimension(): + model = init_model() + place = model.get_place_by_operation_name(operationName="") + model.set_name_for_dimension(place=place, dimIndex=123, dimName="4444") + stat = get_mdl_stat(model) + assert stat.set_name_for_dimension == 1 + assert stat.lastArgString == "4444" + assert stat.lastArgInt == 123 + assert stat.lastArgPlace == place + + +@mock_needed +def test_model_cut_and_add_new_input(): + model = init_model() + place = model.get_place_by_operation_name("") + model.cut_and_add_new_input(place=place, newName="5555") + stat = get_mdl_stat(model) + assert stat.cut_and_add_new_input == 1 + assert stat.lastArgString == "5555" + assert stat.lastArgPlace == place + model.cut_and_add_new_input(place=place) + stat = get_mdl_stat(model) + assert stat.cut_and_add_new_input == 2 + assert stat.lastArgString == "" + assert stat.lastArgPlace == place + + +@mock_needed +def test_model_cut_and_add_new_output(): + model = init_model() + place = model.get_place_by_operation_name("") + model.cut_and_add_new_output(place=place, newName="5555") + stat = get_mdl_stat(model) + assert stat.cut_and_add_new_output == 1 + assert stat.lastArgString == "5555" + assert stat.lastArgPlace == place + model.cut_and_add_new_output(place=place) + stat = get_mdl_stat(model) + assert stat.cut_and_add_new_output == 2 + assert stat.lastArgString == "" + assert stat.lastArgPlace == place + + +@mock_needed +def test_model_add_output(): + model = init_model() + place = model.get_place_by_operation_name("") + place2 = model.add_output(place=place) + assert place2 is not None + stat = get_mdl_stat(model) + assert stat.add_output == 1 + assert stat.lastArgPlace == place + + +@mock_needed +def test_model_remove_output(): + model = init_model() + place = model.get_place_by_operation_name("") + model.remove_output(place=place) + stat = get_mdl_stat(model) + assert stat.remove_output == 1 + assert stat.lastArgPlace == place + + +@mock_needed +def test_model_set_partial_shape(): + model = init_model() + place = model.get_place_by_tensor_name(tensorName="") + test_shape = PartialShape([1, 2, 3, 4]) + model.set_partial_shape(place=place, shape=test_shape) + stat = get_mdl_stat(model) + assert stat.set_partial_shape == 1 + assert stat.lastArgPlace == place + assert stat.lastArgPartialShape == test_shape + + +@mock_needed +def test_model_get_partial_shape(): + model = init_model() + place = model.get_place_by_tensor_name(tensorName="") + shape = model.get_partial_shape(place=place) + assert shape is not None + stat = get_mdl_stat(model) + assert stat.get_partial_shape == 1 + assert stat.lastArgPlace == place + + +@mock_needed +def test_model_override_all_inputs(): + model = init_model() + place1 = model.get_place_by_tensor_name(tensorName="p1") + place2 = model.get_place_by_tensor_name(tensorName="p2") + model.override_all_inputs(inputs=[place1, place2]) + stat = get_mdl_stat(model) + assert stat.override_all_inputs == 1 + assert len(stat.lastArgInputPlaces) == 2 + assert stat.lastArgInputPlaces[0] == place1 + assert stat.lastArgInputPlaces[1] == place2 + + +@mock_needed +def test_model_override_all_outputs(): + model = init_model() + place1 = model.get_place_by_tensor_name(tensorName="p1") + place2 = model.get_place_by_tensor_name(tensorName="p2") + model.override_all_outputs(outputs=[place1, place2]) + stat = get_mdl_stat(model) + assert stat.override_all_outputs == 1 + assert len(stat.lastArgOutputPlaces) == 2 + assert stat.lastArgOutputPlaces[0] == place1 + assert stat.lastArgOutputPlaces[1] == place2 + + +@mock_needed +def test_model_extract_subgraph(): + model = init_model() + place1 = model.get_place_by_tensor_name(tensorName="p1") + place2 = model.get_place_by_tensor_name(tensorName="p2") + place3 = model.get_place_by_tensor_name(tensorName="p3") + place4 = model.get_place_by_tensor_name(tensorName="p4") + model.extract_subgraph(inputs=[place1, place2], outputs=[place3, place4]) + stat = get_mdl_stat(model) + assert stat.extract_subgraph == 1 + assert len(stat.lastArgInputPlaces) == 2 + assert stat.lastArgInputPlaces[0] == place1 + assert stat.lastArgInputPlaces[1] == place2 + assert len(stat.lastArgOutputPlaces) == 2 + assert stat.lastArgOutputPlaces[0] == place3 + assert stat.lastArgOutputPlaces[1] == place4 + + +@mock_needed +def test_model_set_element_type(): + model = init_model() + place = model.get_place_by_tensor_name(tensorName="") + model.set_element_type(place=place, type=get_element_type(np.int32)) + stat = get_mdl_stat(model) + assert stat.set_element_type == 1 + assert stat.lastArgPlace == place + assert stat.lastArgElementType == get_element_type(np.int32) + + +# ----------- Place test ------------ +@mock_needed +def init_place(): + fe = fem.load_by_framework(framework="mock_py") + model = fe.load_from_file(path="") + place = model.get_place_by_tensor_name(tensorName="") + return model, place + + +@mock_needed +def test_place_is_input(): + _, place = init_place() + assert place.is_input() is not None + stat = get_place_stat(place) + assert stat.is_input == 1 + + +@mock_needed +def test_place_is_output(): + _, place = init_place() + assert place.is_output() is not None + stat = get_place_stat(place) + assert stat.is_output == 1 + + +@mock_needed +def test_place_get_names(): + _, place = init_place() + assert place.get_names() is not None + stat = get_place_stat(place) + assert stat.get_names == 1 + + +@mock_needed +def test_place_is_equal(): + model, place = init_place() + place2 = model.get_place_by_tensor_name("2") + assert place.is_equal(other=place2) is not None + stat = get_place_stat(place) + assert stat.is_equal == 1 + assert stat.lastArgPlace == place2 + + +@mock_needed +def test_place_is_equal_data(): + model, place = init_place() + place2 = model.get_place_by_tensor_name("2") + assert place.is_equal_data(other=place2) is not None + stat = get_place_stat(place) + assert stat.is_equal_data == 1 + assert stat.lastArgPlace == place2 + + +@mock_needed +def test_place_get_consuming_operations(): + _, place = init_place() + assert place.get_consuming_operations(outputPortIndex=22) is not None + stat = get_place_stat(place) + assert stat.get_consuming_operations == 1 + assert stat.lastArgInt == 22 + assert place.get_consuming_operations() is not None + stat = get_place_stat(place) + assert stat.get_consuming_operations == 2 + assert stat.lastArgInt == -1 + + +@mock_needed +def test_place_get_target_tensor(): + _, place = init_place() + assert place.get_target_tensor(outputPortIndex=22) is not None + stat = get_place_stat(place) + assert stat.get_target_tensor == 1 + assert stat.lastArgInt == 22 + assert place.get_target_tensor() is not None + stat = get_place_stat(place) + assert stat.get_target_tensor == 2 + assert stat.lastArgInt == -1 + + +@mock_needed +def test_place_get_producing_operation(): + _, place = init_place() + assert place.get_producing_operation(inputPortIndex=22) is not None + stat = get_place_stat(place) + assert stat.get_producing_operation == 1 + assert stat.lastArgInt == 22 + assert place.get_producing_operation() is not None + stat = get_place_stat(place) + assert stat.get_producing_operation == 2 + assert stat.lastArgInt == -1 + + +@mock_needed +def test_place_get_producing_port(): + _, place = init_place() + assert place.get_producing_port() is not None + stat = get_place_stat(place) + assert stat.get_producing_port == 1 + + +@mock_needed +def test_place_get_input_port(): + _, place = init_place() + assert place.get_input_port() is not None + stat = get_place_stat(place) + assert stat.get_input_port == 1 + assert stat.lastArgInt == -1 + assert place.get_input_port(inputPortIndex=22) is not None + stat = get_place_stat(place) + assert stat.get_input_port == 2 + assert stat.lastArgInt == 22 + + +@mock_needed +def test_place_get_input_port2(): + _, place = init_place() + assert place.get_input_port(inputName="abc") is not None + stat = get_place_stat(place) + assert stat.get_input_port == 1 + assert stat.lastArgInt == -1 + assert stat.lastArgString == "abc" + assert place.get_input_port(inputName="abcd", inputPortIndex=22) is not None + stat = get_place_stat(place) + assert stat.get_input_port == 2 + assert stat.lastArgInt == 22 + assert stat.lastArgString == "abcd" + + +@mock_needed +def test_place_get_output_port(): + _, place = init_place() + assert place.get_output_port() is not None + stat = get_place_stat(place) + assert stat.get_output_port == 1 + assert stat.lastArgInt == -1 + assert place.get_output_port(outputPortIndex=22) is not None + stat = get_place_stat(place) + assert stat.get_output_port == 2 + assert stat.lastArgInt == 22 + + +@mock_needed +def test_place_get_output_port2(): + _, place = init_place() + assert place.get_output_port(outputName="abc") is not None + stat = get_place_stat(place) + assert stat.get_output_port == 1 + assert stat.lastArgInt == -1 + assert stat.lastArgString == "abc" + assert place.get_output_port(outputName="abcd", outputPortIndex=22) is not None + stat = get_place_stat(place) + assert stat.get_output_port == 2 + assert stat.lastArgInt == 22 + assert stat.lastArgString == "abcd" + + +@mock_needed +def test_place_get_consuming_ports(): + _, place = init_place() + assert place.get_consuming_ports() is not None + stat = get_place_stat(place) + assert stat.get_consuming_ports == 1 + + +@mock_needed +def test_place_get_source_tensor(): + _, place = init_place() + assert place.get_source_tensor() is not None + stat = get_place_stat(place) + assert stat.get_source_tensor == 1 + assert stat.lastArgInt == -1 + assert place.get_source_tensor(inputPortIndex=22) is not None + stat = get_place_stat(place) + assert stat.get_source_tensor == 2 + assert stat.lastArgInt == 22 From 77912ca06e50da435b1793e00b014ab14ad63459 Mon Sep 17 00:00:00 2001 From: Piotr Szmelczynski Date: Tue, 22 Jun 2021 08:44:31 +0200 Subject: [PATCH 153/178] Revise negative (#5955) * update spec * add RTTI macro * create visitor test * clean backend test file * add negative to type_prop tests of unary_ops * add validate_and_infer_types method * remove negative from type_propp unary_ops * create negative type_prop tests * remove boolean check from validate_and_infer_types * update supported types in spec * Remove check for signed numeric types * Remove type_prop test cases with non-signed type * Add zero sized negative test to interpreter manifest * Revert "update supported types in spec" This reverts commit a7ac3e4dc85e6d0408858c25d651e5699b6c5f5d. * Revert "update spec" This reverts commit 4c431d753df465e5b8a7bdc1925ed316f6c56a82. * Add minor changes to review op class * Add validation of inputs and outputs in evaluate * Use shape from host tensor to calculate element count * Minor changes in variable names of backend tests * Add SLT case with integer precision * Add operation to list of trusted ops * Address review comments: * Add bf16 precision to evaluate method * Use unary ops typed case tests for type_prop tests * Add end of line to interpreter manifest * Refactored visitor unit test * Fix typo in visitor test name Co-authored-by: ggalieroc --- .../single_layer_tests/activation.cpp | 1 + .../layer_tests_summary/utils/constants.py | 1 + ngraph/core/include/ngraph/op/negative.hpp | 3 +-- ngraph/core/src/op/negative.cpp | 15 +++++++-------- ngraph/test/CMakeLists.txt | 2 ++ ngraph/test/backend/negative.in.cpp | 18 ++++++------------ .../runtime/interpreter/unit_test.manifest | 3 +++ ngraph/test/type_prop/negative.cpp | 9 +++++++++ ngraph/test/visitors/op/ceiling.cpp | 4 ++-- ngraph/test/visitors/op/floor.cpp | 4 ++-- ngraph/test/visitors/op/log.cpp | 4 ++-- ngraph/test/visitors/op/negative.cpp | 13 +++++++++++++ ngraph/test/visitors/op/result.cpp | 4 ++-- ngraph/test/visitors/op/sqrt.cpp | 4 ++-- ngraph/test/visitors/op/squeeze.cpp | 4 ++-- 15 files changed, 55 insertions(+), 34 deletions(-) create mode 100644 ngraph/test/type_prop/negative.cpp create mode 100644 ngraph/test/visitors/op/negative.cpp diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp index 510e4039e2bfd0..51e379a67f128b 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp @@ -64,6 +64,7 @@ const std::map>> activationTypes // List of operations that should be tested also with integer precision const std::map>> intActivationTypes = { + {Negative, {}}, {Ceiling, {}}, {Sqrt, {}}, {Tanh, {}}, diff --git a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py index 7db26eb289542f..24e42cd5e04d81 100644 --- a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py +++ b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py @@ -54,6 +54,7 @@ 'MaxPool-1', 'Mish-4', 'Multiply-1', + 'Negative-1', 'NonMaxSuppression-4', 'NonMaxSuppression-5', 'PSROIPooling-1', diff --git a/ngraph/core/include/ngraph/op/negative.hpp b/ngraph/core/include/ngraph/op/negative.hpp index 69c7d39bdc0da4..1768a58c01012b 100644 --- a/ngraph/core/include/ngraph/op/negative.hpp +++ b/ngraph/core/include/ngraph/op/negative.hpp @@ -16,8 +16,7 @@ namespace ngraph class NGRAPH_API Negative : public util::UnaryElementwiseArithmetic { public: - static constexpr NodeTypeInfo type_info{"Negative", 0}; - const NodeTypeInfo& get_type_info() const override { return type_info; } + NGRAPH_RTTI_DECLARATION; /// \brief Constructs a negative operation. Negative() = default; /// \brief Constructs a negative operation. diff --git a/ngraph/core/src/op/negative.cpp b/ngraph/core/src/op/negative.cpp index f670ac19a2e125..4ed3c44e53b508 100644 --- a/ngraph/core/src/op/negative.cpp +++ b/ngraph/core/src/op/negative.cpp @@ -6,11 +6,12 @@ #include "itt.hpp" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/runtime/reference/negate.hpp" +#include "ngraph/validation_util.hpp" using namespace std; using namespace ngraph; -constexpr NodeTypeInfo op::Negative::type_info; +NGRAPH_RTTI_DEFINITION(op::v0::Negative, "Negative", 0, util::UnaryElementwiseArithmetic); op::Negative::Negative(const Output& arg) : UnaryElementwiseArithmetic(arg) @@ -48,11 +49,9 @@ namespace negativeop switch (arg0->get_element_type()) { - NGRAPH_TYPE_CASE(evaluate_negative, boolean, arg0, out, count); NGRAPH_TYPE_CASE(evaluate_negative, i32, arg0, out, count); NGRAPH_TYPE_CASE(evaluate_negative, i64, arg0, out, count); - NGRAPH_TYPE_CASE(evaluate_negative, u32, arg0, out, count); - NGRAPH_TYPE_CASE(evaluate_negative, u64, arg0, out, count); + NGRAPH_TYPE_CASE(evaluate_negative, bf16, arg0, out, count); NGRAPH_TYPE_CASE(evaluate_negative, f16, arg0, out, count); NGRAPH_TYPE_CASE(evaluate_negative, f32, arg0, out, count); default: rc = false; break; @@ -64,7 +63,10 @@ namespace negativeop bool op::Negative::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { NGRAPH_OP_SCOPE(v0_Negative_evaluate); - return negativeop::evaluate_negative(inputs[0], outputs[0], shape_size(get_output_shape(0))); + NGRAPH_CHECK(validate_host_tensor_vector(inputs, 1)); + NGRAPH_CHECK(validate_host_tensor_vector(outputs, 1)); + return negativeop::evaluate_negative( + inputs[0], outputs[0], shape_size(outputs[0]->get_shape())); } bool op::Negative::has_evaluate() const @@ -72,11 +74,8 @@ bool op::Negative::has_evaluate() const NGRAPH_OP_SCOPE(v0_Negative_has_evaluate); switch (get_input_element_type(0)) { - case ngraph::element::boolean: case ngraph::element::i32: case ngraph::element::i64: - case ngraph::element::u32: - case ngraph::element::u64: case ngraph::element::f16: case ngraph::element::f32: return true; default: break; diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index 278121669a83c1..2b7757f0527b81 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -167,6 +167,7 @@ set(SRC type_prop/mish.cpp type_prop/mod.cpp type_prop/mvn.cpp + type_prop/negative.cpp type_prop/non_max_suppression.cpp type_prop/non_zero.cpp type_prop/normalize.cpp @@ -257,6 +258,7 @@ set(SRC visitors/op/max_pool.cpp visitors/op/mod.cpp visitors/op/mvn.cpp + visitors/op/negative.cpp visitors/op/non_max_suppression.cpp visitors/op/normalize_l2.cpp visitors/op/one_hot.cpp diff --git a/ngraph/test/backend/negative.in.cpp b/ngraph/test/backend/negative.in.cpp index a092fe6f7607a4..01aca08610dce9 100644 --- a/ngraph/test/backend/negative.in.cpp +++ b/ngraph/test/backend/negative.in.cpp @@ -2,13 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include -#include - // clang-format off #ifdef ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS #define DEFAULT_FLOAT_TOLERANCE_BITS ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS @@ -49,15 +42,16 @@ NGRAPH_TEST(${BACKEND_NAME}, negative_i32) { auto shape_a = Shape{2, 5}; auto A = make_shared(element::i32, shape_a); - auto relu = make_shared(A); + auto negative = make_shared(A); auto shape_rt = Shape{2, 5}; - auto f = make_shared(relu, ParameterVector{A}); + auto f = make_shared(negative, ParameterVector{A}); std::vector a{1, 8, -8, 17, -2, 1, 8, -8, 17, -1}; + std::vector r{-1, -8, 8, -17, 2, -1, -8, 8, -17, 1}; auto test_case = test::TestCase(f); test_case.add_input(shape_a, a); - test_case.add_expected_output(shape_rt, {-1, -8, 8, -17, 2, -1, -8, 8, -17, 1}); + test_case.add_expected_output(shape_rt, r); test_case.run(); } @@ -65,9 +59,9 @@ NGRAPH_TEST(${BACKEND_NAME}, negative_f32) { auto shape_a = Shape{2, 5}; auto A = make_shared(element::f32, shape_a); - auto relu = make_shared(A); + auto negative = make_shared(A); auto shape_rt = Shape{2, 5}; - auto f = make_shared(relu, ParameterVector{A}); + auto f = make_shared(negative, ParameterVector{A}); std::vector a{1.35f, 8.76f, -8.0f, 17.234f, -2.121f, 1.0f, 8.7f, -8.92f, 17.0f, -1.0f}; diff --git a/ngraph/test/runtime/interpreter/unit_test.manifest b/ngraph/test/runtime/interpreter/unit_test.manifest index 799025f3b92752..a76df269cddff2 100644 --- a/ngraph/test/runtime/interpreter/unit_test.manifest +++ b/ngraph/test/runtime/interpreter/unit_test.manifest @@ -158,3 +158,6 @@ INTERPRETER.onnx_model_experimental_detectron_roi_feature_extractor # No evaluator for DeformableConv2D onnx_model_deformable_conv_2d + +# No support for unsigned types +INTERPRETER.zero_sized_negative diff --git a/ngraph/test/type_prop/negative.cpp b/ngraph/test/type_prop/negative.cpp new file mode 100644 index 00000000000000..68313c2f5442b7 --- /dev/null +++ b/ngraph/test/type_prop/negative.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Type = ::testing::Types; + +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_negative, UnaryOperator, Type); diff --git a/ngraph/test/visitors/op/ceiling.cpp b/ngraph/test/visitors/op/ceiling.cpp index 11e71e1e9c604e..327fb4ac4b3569 100644 --- a/ngraph/test/visitors/op/ceiling.cpp +++ b/ngraph/test/visitors/op/ceiling.cpp @@ -5,7 +5,7 @@ #include "unary_ops.hpp" using Type = ::testing::Types>; -INSTANTIATE_TYPED_TEST_CASE_P(visitor_without_atrribute, +INSTANTIATE_TYPED_TEST_CASE_P(visitor_without_attribute, UnaryOperatorVisitor, Type, - UnaryOperatorTypeName); \ No newline at end of file + UnaryOperatorTypeName); diff --git a/ngraph/test/visitors/op/floor.cpp b/ngraph/test/visitors/op/floor.cpp index 98731229010b1b..be2fb04372b7cf 100644 --- a/ngraph/test/visitors/op/floor.cpp +++ b/ngraph/test/visitors/op/floor.cpp @@ -7,7 +7,7 @@ using Types = ::testing::Types, UnaryOperatorType>; -INSTANTIATE_TYPED_TEST_CASE_P(visitor_without_atrribute, +INSTANTIATE_TYPED_TEST_CASE_P(visitor_without_attribute, UnaryOperatorVisitor, Types, - UnaryOperatorTypeName); \ No newline at end of file + UnaryOperatorTypeName); diff --git a/ngraph/test/visitors/op/log.cpp b/ngraph/test/visitors/op/log.cpp index 5acb4971ba81f2..84e87eb6db3edc 100644 --- a/ngraph/test/visitors/op/log.cpp +++ b/ngraph/test/visitors/op/log.cpp @@ -5,7 +5,7 @@ using Types = ::testing::Types, UnaryOperatorType>; -INSTANTIATE_TYPED_TEST_CASE_P(visitor_without_atrribute, +INSTANTIATE_TYPED_TEST_CASE_P(visitor_without_attribute, UnaryOperatorVisitor, Types, - UnaryOperatorTypeName); \ No newline at end of file + UnaryOperatorTypeName); diff --git a/ngraph/test/visitors/op/negative.cpp b/ngraph/test/visitors/op/negative.cpp new file mode 100644 index 00000000000000..769a629fad66ca --- /dev/null +++ b/ngraph/test/visitors/op/negative.cpp @@ -0,0 +1,13 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Types = ::testing::Types, + UnaryOperatorType>; + +INSTANTIATE_TYPED_TEST_CASE_P(visitor_without_attribute, + UnaryOperatorVisitor, + Types, + UnaryOperatorTypeName); diff --git a/ngraph/test/visitors/op/result.cpp b/ngraph/test/visitors/op/result.cpp index df01ad5f913371..27e0e45e891b0e 100644 --- a/ngraph/test/visitors/op/result.cpp +++ b/ngraph/test/visitors/op/result.cpp @@ -7,7 +7,7 @@ using Types = ::testing::Types, UnaryOperatorType>; -INSTANTIATE_TYPED_TEST_CASE_P(visitor_without_atrribute, +INSTANTIATE_TYPED_TEST_CASE_P(visitor_without_attribute, UnaryOperatorVisitor, Types, - UnaryOperatorTypeName); \ No newline at end of file + UnaryOperatorTypeName); diff --git a/ngraph/test/visitors/op/sqrt.cpp b/ngraph/test/visitors/op/sqrt.cpp index 5e26c542348dbf..1df6ae6420a97d 100644 --- a/ngraph/test/visitors/op/sqrt.cpp +++ b/ngraph/test/visitors/op/sqrt.cpp @@ -6,7 +6,7 @@ using Types = ::testing::Types, UnaryOperatorType>; -INSTANTIATE_TYPED_TEST_CASE_P(visitor_without_atrribute, +INSTANTIATE_TYPED_TEST_CASE_P(visitor_without_attribute, UnaryOperatorVisitor, Types, - UnaryOperatorTypeName); \ No newline at end of file + UnaryOperatorTypeName); diff --git a/ngraph/test/visitors/op/squeeze.cpp b/ngraph/test/visitors/op/squeeze.cpp index a8b0c2c488c1ab..9c6813af16fece 100644 --- a/ngraph/test/visitors/op/squeeze.cpp +++ b/ngraph/test/visitors/op/squeeze.cpp @@ -6,7 +6,7 @@ using Types = ::testing::Types, UnaryOperatorType>; -INSTANTIATE_TYPED_TEST_CASE_P(visitor_without_atrribute, +INSTANTIATE_TYPED_TEST_CASE_P(visitor_without_attribute, UnaryOperatorVisitor, Types, - UnaryOperatorTypeName); \ No newline at end of file + UnaryOperatorTypeName); From 5ce5f9e0c86944ca9acbcc08f60a048757835ee3 Mon Sep 17 00:00:00 2001 From: Duncan Ding Date: Tue, 22 Jun 2021 15:04:11 +0800 Subject: [PATCH 154/178] Revise SoftPlus operation reference implementation 37559 (#5938) * change threshold to 20 instead of max limit of data type * add invalid input type test case * add invalid input data check * add input type dynamic check * add backend test case * add more clarity on spec and align with real implementation * Revert "[CPU] Fix for CoreThreadingTestsWithIterations tests (#5892)" This reverts commit 115aa143ef8d8a0a17aed705db2f6d6e1dcb4164. * Revert "Revert "[CPU] Fix for CoreThreadingTestsWithIterations tests (#5892)"" This reverts commit 95afa50d94b7164968753194557888ecf16a9e69. * Revert "change threshold to 20 instead of max limit of data type" This reverts commit 91af8250567f843161f920be2b44f219a127efb4. * Revert "add more clarity on spec and align with real implementation" This reverts commit a3b232a8fbfe69cb35f96a011588102a79fb12b0. * add visitor attribute test case * Revert "add visitor attribute test case" This reverts commit 610728f1abbe89178a514fecf2e02443e6739c74. * add attribute test case * revise the attribute visitor test per parametrized visitor API PR: #6181 --- ngraph/core/src/op/softplus.cpp | 7 +++++ ngraph/test/CMakeLists.txt | 2 ++ ngraph/test/backend/softplus.in.cpp | 45 ++++++++++++++++++++++++++++ ngraph/test/type_prop/softplus.cpp | 20 +++++++++++++ ngraph/test/visitors/op/softplus.cpp | 12 ++++++++ 5 files changed, 86 insertions(+) create mode 100644 ngraph/test/backend/softplus.in.cpp create mode 100644 ngraph/test/visitors/op/softplus.cpp diff --git a/ngraph/core/src/op/softplus.cpp b/ngraph/core/src/op/softplus.cpp index f37008220a4fe0..23f356ae74f232 100644 --- a/ngraph/core/src/op/softplus.cpp +++ b/ngraph/core/src/op/softplus.cpp @@ -29,6 +29,13 @@ bool op::v4::SoftPlus::visit_attributes(AttributeVisitor& visitor) void op::v4::SoftPlus::validate_and_infer_types() { NGRAPH_OP_SCOPE(v4_SoftPlus_validate_and_infer_types); + const element::Type& input_et = get_input_element_type(0); + + NODE_VALIDATION_CHECK(this, + input_et.is_dynamic() || input_et.is_real(), + "Input element type must be float. Got: ", + input_et); + set_output_size(1); set_output_type(0, get_input_element_type(0), get_input_partial_shape(0)); } diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index 2b7757f0527b81..6f4e2bb0db47a2 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -287,6 +287,7 @@ set(SRC visitors/op/selu.cpp visitors/op/shuffle_channels.cpp visitors/op/softmax.cpp + visitors/op/softplus.cpp visitors/op/space_to_batch.cpp visitors/op/space_to_depth.cpp visitors/op/split.cpp @@ -463,6 +464,7 @@ set(MULTI_TEST_SRC backend/sin.in.cpp backend/sinh.in.cpp backend/softmax.in.cpp + backend/softplus.in.cpp backend/space_to_batch.in.cpp backend/split.in.cpp backend/sqrt.in.cpp diff --git a/ngraph/test/backend/softplus.in.cpp b/ngraph/test/backend/softplus.in.cpp new file mode 100644 index 00000000000000..c1e45a10c23422 --- /dev/null +++ b/ngraph/test/backend/softplus.in.cpp @@ -0,0 +1,45 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include +#include +#include +#include +#include + +// clang-format off +#ifdef ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS +#define DEFAULT_FLOAT_TOLERANCE_BITS ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS +#endif + +#ifdef ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS +#define DEFAULT_DOUBLE_TOLERANCE_BITS ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS +#endif +// clang-format on + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "util/engine/test_engines.hpp" +#include "util/test_case.hpp" +#include "util/test_control.hpp" + +using namespace std; +using namespace ngraph; + +static string s_manifest = "${MANIFEST}"; +using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); + +NGRAPH_TEST(${BACKEND_NAME}, softplus) +{ + auto A = make_shared(element::f32, Shape{4}); + auto softplus = make_shared(A); + auto function = make_shared(NodeVector{softplus}, ParameterVector{A}); + + auto test_case = test::TestCase(function); + test_case.add_input(vector{-1.0, 0.0, 1.0, 20.0}); + test_case.add_expected_output( + vector{0.31326166, 0.69314718, 1.3132616, 20.0}); + test_case.run(); +} diff --git a/ngraph/test/type_prop/softplus.cpp b/ngraph/test/type_prop/softplus.cpp index 7d6ddb49144b0e..d0cec9fdd27d6d 100644 --- a/ngraph/test/type_prop/softplus.cpp +++ b/ngraph/test/type_prop/softplus.cpp @@ -40,3 +40,23 @@ TEST(type_prop, softplus_partial_static_rank) (PartialShape{1, Dimension::dynamic(), 6}))); ASSERT_TRUE(softplus_func->get_output_partial_shape(0).rank().is_static()); } + +TEST(type_prop, softplus_invalid_element_type) +{ + auto data = make_shared(element::i32, Shape{2, 2}); + + try + { + auto softplus = make_shared(data); + // Input element type is boolean + FAIL() << "Invalid int element type for input not detected"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), "Input element type must be float"); + } + catch (...) + { + FAIL() << "Numeric element type node validation check failed for unexpected reason"; + } +} diff --git a/ngraph/test/visitors/op/softplus.cpp b/ngraph/test/visitors/op/softplus.cpp new file mode 100644 index 00000000000000..e5ff77e3a4e86e --- /dev/null +++ b/ngraph/test/visitors/op/softplus.cpp @@ -0,0 +1,12 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Types = ::testing::Types>; + +INSTANTIATE_TYPED_TEST_CASE_P(visitor_without_atrribute, + UnaryOperatorVisitor, + Types, + UnaryOperatorTypeName); From b68166fc3cb97116dc5685539f852d5174601b21 Mon Sep 17 00:00:00 2001 From: Yuan Hu Date: Tue, 22 Jun 2021 16:05:26 +0800 Subject: [PATCH 155/178] Revise Round operation reference implementation (#6287) * Revise OP Round improve the input type error check add attribute test case Signed-off-by: Hu, Yuan2 * fix clang code style issue Signed-off-by: Hu, Yuan2 --- ngraph/core/src/op/round.cpp | 2 ++ ngraph/test/CMakeLists.txt | 1 + ngraph/test/backend/round.in.cpp | 2 +- ngraph/test/visitors/op/round.cpp | 42 +++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 ngraph/test/visitors/op/round.cpp diff --git a/ngraph/core/src/op/round.cpp b/ngraph/core/src/op/round.cpp index dde7a19d81bff1..83ed1fff66bb88 100644 --- a/ngraph/core/src/op/round.cpp +++ b/ngraph/core/src/op/round.cpp @@ -83,6 +83,8 @@ bool ngraph::op::v5::Round::visit_attributes(AttributeVisitor& visitor) void op::v5::Round::validate_and_infer_types() { NGRAPH_OP_SCOPE(v5_Round_validate_and_infer_types); + NODE_VALIDATION_CHECK( + this, get_input_size() == 1, "Only accepts one argument. Got: ", get_input_size()); set_output_size(1); set_output_type(0, get_input_element_type(0), get_input_partial_shape(0)); } diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index 6f4e2bb0db47a2..e25b6410ba09dc 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -284,6 +284,7 @@ set(SRC visitors/op/reverse_sequence.cpp visitors/op/rnn_cell.cpp visitors/op/roi_pooling.cpp + visitors/op/round.cpp visitors/op/selu.cpp visitors/op/shuffle_channels.cpp visitors/op/softmax.cpp diff --git a/ngraph/test/backend/round.in.cpp b/ngraph/test/backend/round.in.cpp index c58ecc7d8dcbbf..d8fa657b0101d9 100644 --- a/ngraph/test/backend/round.in.cpp +++ b/ngraph/test/backend/round.in.cpp @@ -19,7 +19,7 @@ using namespace ngraph; static string s_manifest = "${MANIFEST}"; -NGRAPH_TEST(${BACKEND_NAME}, round) +NGRAPH_TEST(${BACKEND_NAME}, round_half_to_even) { Shape shape{5}; auto A = make_shared(element::f32, shape); diff --git a/ngraph/test/visitors/op/round.cpp b/ngraph/test/visitors/op/round.cpp new file mode 100644 index 00000000000000..159d07edd332d7 --- /dev/null +++ b/ngraph/test/visitors/op/round.cpp @@ -0,0 +1,42 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" + +#include "ngraph/ngraph.hpp" +#include "ngraph/op/util/attr_types.hpp" +#include "ngraph/opsets/opset1.hpp" +#include "ngraph/opsets/opset3.hpp" +#include "ngraph/opsets/opset4.hpp" +#include "ngraph/opsets/opset5.hpp" + +#include "util/visitor.hpp" + +using namespace std; +using namespace ngraph; +using ngraph::test::NodeBuilder; +using ngraph::test::ValueMap; + +void static test_mode(opset5::Round::RoundMode mode) +{ + NodeBuilder::get_ops().register_factory(); + auto data = make_shared(element::f32, Shape{200}); + auto round = make_shared(data, opset5::Round::RoundMode::HALF_TO_EVEN); + NodeBuilder builder(round); + auto g_round = as_type_ptr(builder.create()); + + EXPECT_EQ(g_round->get_mode(), round->get_mode()); +} + +TEST(attributes, round_op_enum_mode_half_to_even) +{ + test_mode(opset5::Round::RoundMode::HALF_TO_EVEN); +} + +TEST(attributes, round_op_enum_mode_half_away_from_zero) +{ + test_mode(opset5::Round::RoundMode::HALF_AWAY_FROM_ZERO); +} + + From 38bb6dc8741a085c727bc37d7fd0f8455601af5f Mon Sep 17 00:00:00 2001 From: cecilia peng Date: Tue, 22 Jun 2021 17:34:34 +0800 Subject: [PATCH 156/178] spec revise: add attribute "normalize" to Paddle NMS operators. (#6290) --- docs/ops/sort/MatrixNMS_8.md | 10 ++++++++++ docs/ops/sort/MulticlassNMS_8.md | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/docs/ops/sort/MatrixNMS_8.md b/docs/ops/sort/MatrixNMS_8.md index d3a422307223c9..b578822d6ebd81 100644 --- a/docs/ops/sort/MatrixNMS_8.md +++ b/docs/ops/sort/MatrixNMS_8.md @@ -84,6 +84,16 @@ The Matrix NMS algorithm is described below: * **Default value**: `-1` meaning to keep all classes * **Required**: *No* +* *normalized* + + * **Description**: *normalized* is a flag that indicates whether `boxes` are normalized or not. + * **Range of values**: true or false + * *true* - the box coordinates are normalized. + * *false* - the box coordinates are not normalized. + * **Type**: boolean + * **Default value**: True + * **Required**: *No* + * *decay_function* * **Description**: decay function used to decay scores. diff --git a/docs/ops/sort/MulticlassNMS_8.md b/docs/ops/sort/MulticlassNMS_8.md index 16997a81397ef0..866254963fdfa8 100644 --- a/docs/ops/sort/MulticlassNMS_8.md +++ b/docs/ops/sort/MulticlassNMS_8.md @@ -93,6 +93,16 @@ Boxes of `background_class` are skipped and thus eliminated. * **Default value**: `-1` meaning to keep all classes. * **Required**: *No* +* *normalized* + + * **Description**: *normalized* is a flag that indicates whether `boxes` are normalized or not. + * **Range of values**: true or false + * *true* - the box coordinates are normalized. + * *false* - the box coordinates are not normalized. + * **Type**: boolean + * **Default value**: True + * **Required**: *No* + * *nms_eta* * **Description**: eta parameter for adaptive NMS. From 15ee515a88085a3209dfdef36f2ce4d97e2153e9 Mon Sep 17 00:00:00 2001 From: Edward Shogulin Date: Tue, 22 Jun 2021 13:05:27 +0300 Subject: [PATCH 157/178] [Runtime] INT8 inference documentation update (#5949) --- docs/IE_DG/Int8Inference.md | 47 ++++++++++++++++---------------- docs/IE_DG/img/cpu_int8_flow.png | 3 -- 2 files changed, 23 insertions(+), 27 deletions(-) delete mode 100644 docs/IE_DG/img/cpu_int8_flow.png diff --git a/docs/IE_DG/Int8Inference.md b/docs/IE_DG/Int8Inference.md index 917c7836de293b..889af6a53278b1 100644 --- a/docs/IE_DG/Int8Inference.md +++ b/docs/IE_DG/Int8Inference.md @@ -1,6 +1,13 @@ # Low-Precision 8-bit Integer Inference {#openvino_docs_IE_DG_Int8Inference} -## Disclaimer +## Table of Contents +1. [Supported devices](#supported-devices) +2. [Low-Precision 8-bit Integer Inference Workflow](#low-precision-8-bit-integer-inference-workflow) +3. [Prerequisites](#prerequisites) +4. [Inference](#inference) +5. [Results analysis](#results-analysis) + +## Supported devices Low-precision 8-bit inference is optimized for: - Intel® architecture processors with the following instruction set architecture extensions: @@ -12,16 +19,22 @@ Low-precision 8-bit inference is optimized for: - Intel® Iris® Xe Graphics - Intel® Iris® Xe MAX Graphics - A model must be quantized. You can use a quantized model from [OpenVINO™ Toolkit Intel's Pre-Trained Models](@ref omz_models_group_intel) or quantize a model yourself. For quantization, you can use the: - - [Post-Training Optimization Tool](@ref pot_README) delivered with the Intel® Distribution of OpenVINO™ toolkit release package. + - [Post-Training Optimization Tool](@ref pot_docs_LowPrecisionOptimizationGuide) delivered with the Intel® Distribution of OpenVINO™ toolkit release package. - [Neural Network Compression Framework](https://www.intel.com/content/www/us/en/artificial-intelligence/posts/openvino-nncf.html) available on GitHub: https://github.com/openvinotoolkit/nncf -## Introduction - -A lot of investigation was made in the field of deep learning with the idea of using low precision computations during inference in order to boost deep learning pipelines and gather higher performance. For example, one of the popular approaches is to shrink the precision of activations and weights values from `fp32` precision to smaller ones, for example, to `fp11` or `int8`. For more information about this approach, refer to -**Brief History of Lower Precision in Deep Learning** section in [this whitepaper](https://software.intel.com/en-us/articles/lower-numerical-precision-deep-learning-inference-and-training). +## Low-Precision 8-bit Integer Inference Workflow 8-bit computations (referred to as `int8`) offer better performance compared to the results of inference in higher precision (for example, `fp32`), because they allow loading more data into a single processor instruction. Usually the cost for significant boost is a reduced accuracy. However, it is proved that an accuracy drop can be negligible and depends on task requirements, so that the application engineer can set up the maximum accuracy drop that is acceptable. +For 8-bit integer computations, a model must be quantized. Quantized models can be downloaded from [Overview of OpenVINO™ Toolkit Intel's Pre-Trained Models](@ref omz_models_group_intel). If the model is not quantized, you can use the [Post-Training Optimization Tool](@ref pot_README) to quantize the model. The quantization process adds [FakeQuantize](../ops/quantization/FakeQuantize_1.md) layers on activations and weights for most layers. Read more about mathematical computations in the [Uniform Quantization with Fine-Tuning](https://github.com/openvinotoolkit/nncf/blob/develop/docs/compression_algorithms/Quantization.md). + +When you pass the quantized IR to the OpenVINO™ plugin, the plugin automatically recognizes it as a quantized model and performs 8-bit inference. Note, if you pass a quantized model to another plugin that does not support 8-bit inference but supports all operations from the model, the model is inferred in precision that this plugin supports. + +In *Runtime stage* stage, the quantized model is loaded to the plugin. The plugin uses `Low Precision Transformation` component to update the model to infer it in low precision: + - Update `FakeQuantize` layers to have quantized output tensors in low precision range and add dequantization layers to compensate the update. Dequantization layers are pushed through as many layers as possible to have more layers in low precision. After that, most layers have quantized input tensors in low precision range and can be inferred in low precision. Ideally, dequantization layers should be fused in the next `FakeQuantize` layer. + - Weights are quantized and stored in `Constant` layers. + +## Prerequisites Let's explore quantized [TensorFlow* implementation of ResNet-50](https://github.com/openvinotoolkit/open_model_zoo/tree/master/models/public/resnet-50-tf) model. Use [Model Downloader](@ref omz_tools_downloader) tool to download the `fp16` model from [OpenVINO™ Toolkit - Open Model Zoo repository](https://github.com/openvinotoolkit/open_model_zoo): ```sh @@ -31,28 +44,16 @@ After that you should quantize model by the [Model Quantizer](@ref omz_tools_dow ```sh ./quantizer.py --model_dir public/resnet-50-tf --dataset_dir --precisions=FP16-INT8 ``` + +## Inference + The simplest way to infer the model and collect performance counters is [C++ Benchmark Application](../../inference-engine/samples/benchmark_app/README.md). ```sh ./benchmark_app -m resnet-50-tf.xml -d CPU -niter 1 -api sync -report_type average_counters -report_folder pc_report_dir ``` If you infer the model with the OpenVINO™ CPU plugin and collect performance counters, all operations (except last not quantized SoftMax) are executed in INT8 precision. -## Low-Precision 8-bit Integer Inference Workflow - -For 8-bit integer computations, a model must be quantized. Quantized models can be downloaded from [Overview of OpenVINO™ Toolkit Intel's Pre-Trained Models](@ref omz_models_group_intel). If the model is not quantized, you can use the [Post-Training Optimization Tool](@ref pot_README) to quantize the model. The quantization process adds [FakeQuantize](../ops/quantization/FakeQuantize_1.md) layers on activations and weights for most layers. Read more about mathematical computations in the [Uniform Quantization with Fine-Tuning](https://github.com/openvinotoolkit/nncf/blob/develop/docs/compression_algorithms/Quantization.md). - -8-bit inference pipeline includes two stages (also refer to the figure below): -1. *Offline stage*, or *model quantization*. During this stage, [FakeQuantize](../ops/quantization/FakeQuantize_1.md) layers are added before most layers to have quantized tensors before layers in a way that low-precision accuracy drop for 8-bit integer inference satisfies the specified threshold. The output of this stage is a quantized model. Quantized model precision is not changed, quantized tensors are in original precision range (`fp32`). `FakeQuantize` layer has `levels` attribute which defines quants count. Quants count defines precision which is used during inference. For `int8` range `levels` attribute value has to be 255 or 256. To quantize the model, you can use the [Post-Training Optimization Tool](@ref pot_README) delivered with the Intel® Distribution of OpenVINO™ toolkit release package. - - When you pass the quantized IR to the OpenVINO™ plugin, the plugin automatically recognizes it as a quantized model and performs 8-bit inference. Note, if you pass a quantized model to another plugin that does not support 8-bit inference but supports all operations from the model, the model is inferred in precision that this plugin supports. - -2. *Runtime stage*. This stage is an internal procedure of the OpenVINO™ plugin. During this stage, the quantized model is loaded to the plugin. The plugin uses `Low Precision Transformation` component to update the model to infer it in low precision: - - Update `FakeQuantize` layers to have quantized output tensors in low precision range and add dequantization layers to compensate the update. Dequantization layers are pushed through as many layers as possible to have more layers in low precision. After that, most layers have quantized input tensors in low precision range and can be inferred in low precision. Ideally, dequantization layers should be fused in the next `FakeQuantize` layer. - - Weights are quantized and stored in `Constant` layers. - -![int8_flow] - -## Performance Counters +## Results analysis Information about layer precision is stored in the performance counters that are available from the Inference Engine API. For example, the part of performance counters table for quantized [TensorFlow* implementation of ResNet-50](https://github.com/openvinotoolkit/open_model_zoo/tree/master/models/public/resnet-50-tf) model inference on [CPU Plugin](supported_plugins/CPU.md) looks as follows: @@ -79,5 +80,3 @@ available from the Inference Engine API. For example, the part of performance co > * Suffix `FP32` for layers computed in 32-bit precision All `Convolution` layers are executed in int8 precision. Rest layers are fused into Convolutions using post operations optimization technique, which is described in [Internal CPU Plugin Optimizations](supported_plugins/CPU.md). - -[int8_flow]: img/cpu_int8_flow.png diff --git a/docs/IE_DG/img/cpu_int8_flow.png b/docs/IE_DG/img/cpu_int8_flow.png deleted file mode 100644 index 794430126b2877..00000000000000 --- a/docs/IE_DG/img/cpu_int8_flow.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:83bcd7888d3843ddfd9a601288627e98f5874290c00b9988bf1beac9209f2e8d -size 79741 From b0e932567d72557123ac49fc6d1ccd8cef53ad9a Mon Sep 17 00:00:00 2001 From: Evgenya Stepyreva Date: Tue, 22 Jun 2021 14:35:30 +0300 Subject: [PATCH 158/178] ShuffleChannels shape propagation unified (#6269) --- ngraph/core/src/op/shuffle_channels.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/ngraph/core/src/op/shuffle_channels.cpp b/ngraph/core/src/op/shuffle_channels.cpp index 71683af4030d61..d38a560f72b9c3 100644 --- a/ngraph/core/src/op/shuffle_channels.cpp +++ b/ngraph/core/src/op/shuffle_channels.cpp @@ -63,11 +63,10 @@ void op::ShuffleChannels::validate_and_infer_types() if (get_input_partial_shape(0).is_static()) { const auto shape = get_input_shape(0); - NODE_VALIDATION_CHECK( this, shape.size() >= 1, "The input tensor's shape is expected to be at least 1D."); - size_t axis_zb = get_zero_based_axis(); + size_t axis_zb = get_zero_based_axis(); NODE_VALIDATION_CHECK(this, axis_zb < shape.size(), "The 'axis' parameter for ShuffleChannels has to point to one of the " @@ -81,14 +80,8 @@ void op::ShuffleChannels::validate_and_infer_types() this, channel_dim_size % m_group == 0, "The channel dimension size has to be a multiple of the groups parameter value."); - set_output_size(1); - set_output_type(0, data_type, shape); - } - else - { - const auto shape = get_input_partial_shape(0); - set_output_type(0, data_type, shape); } + set_output_type(0, data_type, get_input_partial_shape(0)); } shared_ptr op::ShuffleChannels::clone_with_new_inputs(const OutputVector& new_args) const From 1bc18d8f4e8bd9b98e367b1becd3fd678853d5a6 Mon Sep 17 00:00:00 2001 From: Maxim Vafin Date: Tue, 22 Jun 2021 15:00:27 +0300 Subject: [PATCH 159/178] Add ngraph shell for AdaptivePool operations (#6126) Apply review feedback Fix code style Add visitors tests Check visitor for type attribute --- .../include/ngraph/op/adaptive_avg_pool.hpp | 43 ++++++ .../include/ngraph/op/adaptive_max_pool.hpp | 54 ++++++++ ngraph/core/include/ngraph/ops.hpp | 2 + ngraph/core/include/ngraph/opsets/opset.hpp | 1 + .../core/include/ngraph/opsets/opset8_tbl.hpp | 2 + ngraph/core/src/op/adaptive_avg_pool.cpp | 73 ++++++++++ ngraph/core/src/op/adaptive_max_pool.cpp | 83 ++++++++++++ ngraph/test/CMakeLists.txt | 4 + ngraph/test/type_prop/adaptive_avg_pool.cpp | 107 +++++++++++++++ ngraph/test/type_prop/adaptive_max_pool.cpp | 128 ++++++++++++++++++ ngraph/test/visitors/op/adaptive_avg_pool.cpp | 27 ++++ ngraph/test/visitors/op/adaptive_max_pool.cpp | 29 ++++ 12 files changed, 553 insertions(+) create mode 100644 ngraph/core/include/ngraph/op/adaptive_avg_pool.hpp create mode 100644 ngraph/core/include/ngraph/op/adaptive_max_pool.hpp create mode 100644 ngraph/core/src/op/adaptive_avg_pool.cpp create mode 100644 ngraph/core/src/op/adaptive_max_pool.cpp create mode 100644 ngraph/test/type_prop/adaptive_avg_pool.cpp create mode 100644 ngraph/test/type_prop/adaptive_max_pool.cpp create mode 100644 ngraph/test/visitors/op/adaptive_avg_pool.cpp create mode 100644 ngraph/test/visitors/op/adaptive_max_pool.cpp diff --git a/ngraph/core/include/ngraph/op/adaptive_avg_pool.hpp b/ngraph/core/include/ngraph/op/adaptive_avg_pool.hpp new file mode 100644 index 00000000000000..e030cd8852d174 --- /dev/null +++ b/ngraph/core/include/ngraph/op/adaptive_avg_pool.hpp @@ -0,0 +1,43 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "ngraph/op/op.hpp" +#include "ngraph/op/util/attr_types.hpp" + +namespace ngraph +{ + namespace op + { + namespace v8 + { + /// \brief Adaptive average pooling operation. + /// + class NGRAPH_API AdaptiveAvgPool : public Op + { + public: + NGRAPH_RTTI_DECLARATION; + + AdaptiveAvgPool() = default; + + /// + /// \brief Constructs adaptive average pooling operation. + /// + /// \param data Input data + /// + /// \param output_shape 1D tensor describing output shape for spatial + /// dimensions. + /// + AdaptiveAvgPool(const Output& data, const Output& output_shape); + + void validate_and_infer_types() override; + bool visit_attributes(AttributeVisitor& visitor) override; + + std::shared_ptr + clone_with_new_inputs(const OutputVector& new_args) const override; + }; + } // namespace v8 + } // namespace op +} // namespace ngraph diff --git a/ngraph/core/include/ngraph/op/adaptive_max_pool.hpp b/ngraph/core/include/ngraph/op/adaptive_max_pool.hpp new file mode 100644 index 00000000000000..2e528c5ed87d3b --- /dev/null +++ b/ngraph/core/include/ngraph/op/adaptive_max_pool.hpp @@ -0,0 +1,54 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "ngraph/op/op.hpp" +#include "ngraph/op/util/attr_types.hpp" + +namespace ngraph +{ + namespace op + { + namespace v8 + { + /// \brief Adaptive max pooling operation. + /// + class NGRAPH_API AdaptiveMaxPool : public Op + { + public: + NGRAPH_RTTI_DECLARATION; + + AdaptiveMaxPool() = default; + + /// + /// \brief Constructs adaptive max pooling operation. + /// + /// \param data Input data + /// + /// \param output_shape 1D tensor describing output shape for spatial + /// dimensions. + /// + /// \param index_element_type Specifies the output tensor type for indices + /// output + /// + AdaptiveMaxPool( + const Output& data, + const Output& output_shape, + const ngraph::element::Type& index_element_type = ngraph::element::i64); + + void validate_and_infer_types() override; + bool visit_attributes(AttributeVisitor& visitor) override; + + std::shared_ptr + clone_with_new_inputs(const OutputVector& new_args) const override; + + element::Type get_index_element_type() const { return m_index_element_type; } + + protected: + ngraph::element::Type m_index_element_type = ngraph::element::i64; + }; + } // namespace v8 + } // namespace op +} // namespace ngraph diff --git a/ngraph/core/include/ngraph/ops.hpp b/ngraph/core/include/ngraph/ops.hpp index 5a4ad078616db7..6999dc93c9de71 100644 --- a/ngraph/core/include/ngraph/ops.hpp +++ b/ngraph/core/include/ngraph/ops.hpp @@ -9,6 +9,8 @@ #include "ngraph/op/abs.hpp" #include "ngraph/op/acos.hpp" #include "ngraph/op/acosh.hpp" +#include "ngraph/op/adaptive_avg_pool.hpp" +#include "ngraph/op/adaptive_max_pool.hpp" #include "ngraph/op/add.hpp" #include "ngraph/op/and.hpp" #include "ngraph/op/asin.hpp" diff --git a/ngraph/core/include/ngraph/opsets/opset.hpp b/ngraph/core/include/ngraph/opsets/opset.hpp index f0929ed839da55..9ba03cbcd89a35 100644 --- a/ngraph/core/include/ngraph/opsets/opset.hpp +++ b/ngraph/core/include/ngraph/opsets/opset.hpp @@ -124,4 +124,5 @@ namespace ngraph const NGRAPH_API OpSet& get_opset5(); const NGRAPH_API OpSet& get_opset6(); const NGRAPH_API OpSet& get_opset7(); + const NGRAPH_API OpSet& get_opset8(); } // namespace ngraph diff --git a/ngraph/core/include/ngraph/opsets/opset8_tbl.hpp b/ngraph/core/include/ngraph/opsets/opset8_tbl.hpp index 0dbe077ddae1bd..627441eb30033b 100644 --- a/ngraph/core/include/ngraph/opsets/opset8_tbl.hpp +++ b/ngraph/core/include/ngraph/opsets/opset8_tbl.hpp @@ -177,3 +177,5 @@ NGRAPH_OP(Roll, ngraph::op::v7) // New operations added in opset8 NGRAPH_OP(Gather, ngraph::op::v8) +NGRAPH_OP(AdaptiveAvgPool, ngraph::op::v8) +NGRAPH_OP(AdaptiveMaxPool, ngraph::op::v8) diff --git a/ngraph/core/src/op/adaptive_avg_pool.cpp b/ngraph/core/src/op/adaptive_avg_pool.cpp new file mode 100644 index 00000000000000..ef0321fad1769a --- /dev/null +++ b/ngraph/core/src/op/adaptive_avg_pool.cpp @@ -0,0 +1,73 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "ngraph/op/adaptive_avg_pool.hpp" +#include "itt.hpp" +#include "ngraph/attribute_visitor.hpp" +#include "ngraph/graph_util.hpp" +#include "ngraph/validation_util.hpp" + +using namespace std; +using namespace ngraph; + +NGRAPH_RTTI_DEFINITION(op::v8::AdaptiveAvgPool, "AdaptiveAvgPool", 8); + +op::v8::AdaptiveAvgPool::AdaptiveAvgPool(const Output& data, const Output& output_shape) + : Op({data, output_shape}) +{ + constructor_validate_and_infer_types(); +} + +bool op::v8::AdaptiveAvgPool::visit_attributes(AttributeVisitor& visitor) +{ + NGRAPH_OP_SCOPE(v8_AdaptiveAvgPool_visit_attributes); + return true; +} + +void op::v8::AdaptiveAvgPool::validate_and_infer_types() +{ + NGRAPH_OP_SCOPE(v8_AdaptiveAvgPool_validate_and_infer_types); + + const PartialShape& data_shape = get_input_partial_shape(0); + + NODE_VALIDATION_CHECK(this, + data_shape.rank().compatible(3) || data_shape.rank().compatible(4) || + data_shape.rank().compatible(5), + "Expected a 3D, 4D or 5D tensor for the input. Got: ", + data_shape); + + auto output_shape = PartialShape::dynamic(data_shape.rank()); + if (data_shape.rank().is_static()) + { + if (data_shape[0].is_static()) + { + output_shape[0] = data_shape[0]; // batch size + } + if (data_shape[1].is_static()) + { + output_shape[1] = data_shape[1]; // channel size + } + if (const auto& const_output_shape = get_constant_from_source(input_value(1))) + { + auto output_spatial_shape = const_output_shape->cast_vector(); + NODE_VALIDATION_CHECK(this, + (size_t)data_shape.rank().get_length() == + 2 + output_spatial_shape.size(), + "Output shape is not compatible with input data rank"); + int i = 2; + for (auto& dim : output_spatial_shape) + { + output_shape[i++] = dim; + } + } + } + set_output_type(0, get_input_element_type(0), output_shape); +} + +shared_ptr op::v8::AdaptiveAvgPool::clone_with_new_inputs(const OutputVector& new_args) const +{ + NGRAPH_OP_SCOPE(v8_AdaptiveAvgPool_clone_with_new_inputs); + check_new_args_count(this, new_args); + return make_shared(new_args.at(0), new_args.at(1)); +} diff --git a/ngraph/core/src/op/adaptive_max_pool.cpp b/ngraph/core/src/op/adaptive_max_pool.cpp new file mode 100644 index 00000000000000..88f4fc1e230799 --- /dev/null +++ b/ngraph/core/src/op/adaptive_max_pool.cpp @@ -0,0 +1,83 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "ngraph/op/adaptive_max_pool.hpp" +#include "itt.hpp" +#include "ngraph/attribute_visitor.hpp" +#include "ngraph/graph_util.hpp" +#include "ngraph/validation_util.hpp" + +using namespace std; +using namespace ngraph; + +NGRAPH_RTTI_DEFINITION(op::v8::AdaptiveMaxPool, "AdaptiveMaxPool", 8); + +op::v8::AdaptiveMaxPool::AdaptiveMaxPool(const Output& data, + const Output& output_shape, + const ngraph::element::Type& index_element_type) + : Op({data, output_shape}) + , m_index_element_type{index_element_type} +{ + constructor_validate_and_infer_types(); +} + +bool op::v8::AdaptiveMaxPool::visit_attributes(AttributeVisitor& visitor) +{ + NGRAPH_OP_SCOPE(v8_AdaptiveMaxPool_visit_attributes); + visitor.on_attribute("index_element_type", m_index_element_type); + return true; +} + +void op::v8::AdaptiveMaxPool::validate_and_infer_types() +{ + NGRAPH_OP_SCOPE(v8_AdaptiveMaxPool_validate_and_infer_types); + + NODE_VALIDATION_CHECK(this, + m_index_element_type == element::i64 || + m_index_element_type == element::i32, + "Index element type must be i32 or i64"); + + const PartialShape& data_shape = get_input_partial_shape(0); + + NODE_VALIDATION_CHECK(this, + data_shape.rank().compatible(3) || data_shape.rank().compatible(4) || + data_shape.rank().compatible(5), + "Expected a 3D, 4D or 5D tensor for the input. Got: ", + data_shape); + + auto output_shape = PartialShape::dynamic(data_shape.rank()); + if (data_shape.rank().is_static()) + { + if (data_shape[0].is_static()) + { + output_shape[0] = data_shape[0]; // batch size + } + if (data_shape[1].is_static()) + { + output_shape[1] = data_shape[1]; // channel size + } + if (const auto& const_output_shape = get_constant_from_source(input_value(1))) + { + auto output_spatial_shape = const_output_shape->cast_vector(); + NODE_VALIDATION_CHECK(this, + (size_t)data_shape.rank().get_length() == + 2 + output_spatial_shape.size(), + "Output shape is not compatible with input data rank"); + int i = 2; + for (auto& dim : output_spatial_shape) + { + output_shape[i++] = dim; + } + } + } + set_output_type(0, get_input_element_type(0), output_shape); + set_output_type(1, m_index_element_type, output_shape); +} + +shared_ptr op::v8::AdaptiveMaxPool::clone_with_new_inputs(const OutputVector& new_args) const +{ + NGRAPH_OP_SCOPE(v8_AdaptiveMaxPool_clone_with_new_inputs); + check_new_args_count(this, new_args); + return make_shared(new_args.at(0), new_args.at(1), m_index_element_type); +} diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index e25b6410ba09dc..f6d12b6483d4f6 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -101,6 +101,8 @@ set(SRC tensor.cpp type_prop/abs.cpp type_prop/acos.cpp + type_prop/adaptive_avg_pool.cpp + type_prop/adaptive_max_pool.cpp type_prop/asin.cpp type_prop/assign.cpp type_prop/avg_pool.cpp @@ -229,6 +231,8 @@ set(SRC visitors/partial_shape.cpp visitors/user_op.cpp visitors/value_map.cpp + visitors/op/adaptive_avg_pool.cpp + visitors/op/adaptive_max_pool.cpp visitors/op/batch_norm.cpp visitors/op/broadcast.cpp visitors/op/bucketize.cpp diff --git a/ngraph/test/type_prop/adaptive_avg_pool.cpp b/ngraph/test/type_prop/adaptive_avg_pool.cpp new file mode 100644 index 00000000000000..09923756bc3fd7 --- /dev/null +++ b/ngraph/test/type_prop/adaptive_avg_pool.cpp @@ -0,0 +1,107 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "util/type_prop.hpp" + +using namespace std; +using namespace ngraph; + +TEST(type_prop, adaptive_avg_pool) +{ + const PartialShape arg_shape{1, 6, 8, 9}; + const vector output_shape{5, 7}; + + auto data = make_shared(element::f32, arg_shape); + auto out_shape = op::Constant::create(element::i64, Shape{2}, output_shape); + auto adaptive_pool = make_shared(data, out_shape); + + ASSERT_TRUE(adaptive_pool->get_output_partial_shape(0).same_scheme({1, 6, 5, 7})); +} + +TEST(type_prop, adaptive_avg_pool_dyn_batch) +{ + const PartialShape arg_shape{Dimension::dynamic(), 6, 8, 9}; + const vector output_shape{5, 7}; + + auto data = make_shared(element::f32, arg_shape); + auto out_shape = op::Constant::create(element::i64, Shape{2}, output_shape); + auto adaptive_pool = make_shared(data, out_shape); + + ASSERT_TRUE( + adaptive_pool->get_output_partial_shape(0).same_scheme({Dimension::dynamic(), 6, 5, 7})); +} + +TEST(type_prop, adaptive_avg_pool_dyn_channels) +{ + const PartialShape arg_shape{1, Dimension::dynamic(), 8, 9}; + const vector output_shape{5, 7}; + + auto data = make_shared(element::f32, arg_shape); + auto out_shape = op::Constant::create(element::i64, Shape{2}, output_shape); + auto adaptive_pool = make_shared(data, out_shape); + + ASSERT_TRUE( + adaptive_pool->get_output_partial_shape(0).same_scheme({1, Dimension::dynamic(), 5, 7})); +} + +TEST(type_prop, adaptive_avg_pool_dyn_spatial) +{ + const PartialShape arg_shape{1, 6, Dimension::dynamic(), Dimension::dynamic()}; + const vector output_shape{5, 7}; + + auto data = make_shared(element::f32, arg_shape); + auto out_shape = op::Constant::create(element::i64, Shape{2}, output_shape); + auto adaptive_pool = make_shared(data, out_shape); + + ASSERT_TRUE( + adaptive_pool->get_output_partial_shape(0).same_scheme({1, 6, 5, 7})); +} + +TEST(type_prop, adaptive_avg_pool_dyn_output_shape) +{ + const PartialShape arg_shape{1, 6, 8, 9}; + + auto data = make_shared(element::f32, arg_shape); + auto out_shape = make_shared(element::i64, Shape{2}); + auto adaptive_pool = make_shared(data, out_shape); + + ASSERT_TRUE(adaptive_pool->get_output_partial_shape(0).same_scheme( + {1, 6, Dimension::dynamic(), Dimension::dynamic()})); +} + +TEST(type_prop, adaptive_avg_pool_dyn_rank) +{ + const PartialShape arg_shape = PartialShape::dynamic(); + + auto data = make_shared(element::f32, arg_shape); + auto out_shape = make_shared(element::i64, Shape{2}); + auto adaptive_pool = make_shared(data, out_shape); + + ASSERT_TRUE(adaptive_pool->get_output_partial_shape(0).same_scheme(PartialShape::dynamic())); +} + +TEST(type_prop, adaptive_avg_pool_unsupported_input_shape) +{ + const PartialShape arg_shape{1, 6}; + const vector output_shape{1}; + + auto data = make_shared(element::f32, arg_shape); + auto out_shape = op::Constant::create(element::i64, Shape{}, output_shape); + + EXPECT_THROW(make_shared(data, out_shape), NodeValidationFailure); +} + +TEST(type_prop, adaptive_avg_pool_wrong_out_shape) +{ + const PartialShape arg_shape{1, 6, 8, 9}; + const vector output_shape{5, 7, 8}; + + auto data = make_shared(element::f32, arg_shape); + auto out_shape = op::Constant::create(element::i64, Shape{3}, output_shape); + + EXPECT_THROW(make_shared(data, out_shape), + NodeValidationFailure); +} diff --git a/ngraph/test/type_prop/adaptive_max_pool.cpp b/ngraph/test/type_prop/adaptive_max_pool.cpp new file mode 100644 index 00000000000000..0526be23c446a1 --- /dev/null +++ b/ngraph/test/type_prop/adaptive_max_pool.cpp @@ -0,0 +1,128 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "util/type_prop.hpp" + +using namespace std; +using namespace ngraph; + +TEST(type_prop, adaptive_max_pool) +{ + const PartialShape arg_shape{1, 6, 8, 9}; + const vector output_shape{5, 7}; + + auto data = make_shared(element::f32, arg_shape); + auto out_shape = op::Constant::create(element::i64, Shape{2}, output_shape); + auto adaptive_pool = make_shared(data, out_shape); + + ASSERT_TRUE(adaptive_pool->get_output_partial_shape(0).same_scheme({1, 6, 5, 7})); + ASSERT_TRUE(adaptive_pool->get_output_partial_shape(1).same_scheme({1, 6, 5, 7})); +} + +TEST(type_prop, adaptive_max_pool_i32_indices) +{ + const PartialShape arg_shape{1, 6, 8, 9}; + const vector output_shape{5, 7}; + + auto data = make_shared(element::f32, arg_shape); + auto out_shape = op::Constant::create(element::i64, Shape{2}, output_shape); + auto adaptive_pool = make_shared(data, out_shape, element::i32); + + ASSERT_TRUE(adaptive_pool->get_output_partial_shape(0).same_scheme({1, 6, 5, 7})); + ASSERT_EQ(adaptive_pool->output(1).get_element_type(), element::i32); + ASSERT_TRUE(adaptive_pool->get_output_partial_shape(1).same_scheme({1, 6, 5, 7})); +} + +TEST(type_prop, adaptive_max_pool_dyn_batch) +{ + const PartialShape arg_shape{Dimension::dynamic(), 6, 8, 9}; + const vector output_shape{5, 7}; + + auto data = make_shared(element::f32, arg_shape); + auto out_shape = op::Constant::create(element::i64, Shape{2}, output_shape); + auto adaptive_pool = make_shared(data, out_shape); + + ASSERT_TRUE( + adaptive_pool->get_output_partial_shape(0).same_scheme({Dimension::dynamic(), 6, 5, 7})); + ASSERT_TRUE( + adaptive_pool->get_output_partial_shape(1).same_scheme({Dimension::dynamic(), 6, 5, 7})); +} + +TEST(type_prop, adaptive_max_pool_dyn_channels) +{ + const PartialShape arg_shape{1, Dimension::dynamic(), 8, 9}; + const vector output_shape{5, 7}; + + auto data = make_shared(element::f32, arg_shape); + auto out_shape = op::Constant::create(element::i64, Shape{2}, output_shape); + auto adaptive_pool = make_shared(data, out_shape); + + ASSERT_TRUE( + adaptive_pool->get_output_partial_shape(0).same_scheme({1, Dimension::dynamic(), 5, 7})); + ASSERT_TRUE( + adaptive_pool->get_output_partial_shape(1).same_scheme({1, Dimension::dynamic(), 5, 7})); +} + +TEST(type_prop, adaptive_max_pool_dyn_spatial) +{ + const PartialShape arg_shape{1, 6, Dimension::dynamic(), Dimension::dynamic()}; + const vector output_shape{5, 7}; + + auto data = make_shared(element::f32, arg_shape); + auto out_shape = op::Constant::create(element::i64, Shape{2}, output_shape); + auto adaptive_pool = make_shared(data, out_shape); + + ASSERT_TRUE(adaptive_pool->get_output_partial_shape(0).same_scheme({1, 6, 5, 7})); + ASSERT_TRUE(adaptive_pool->get_output_partial_shape(1).same_scheme({1, 6, 5, 7})); +} + +TEST(type_prop, adaptive_max_pool_dyn_output_shape) +{ + const PartialShape arg_shape{1, 6, 8, 9}; + + auto data = make_shared(element::f32, arg_shape); + auto out_shape = make_shared(element::i64, Shape{2}); + auto adaptive_pool = make_shared(data, out_shape); + + ASSERT_TRUE(adaptive_pool->get_output_partial_shape(0).same_scheme( + {1, 6, Dimension::dynamic(), Dimension::dynamic()})); + ASSERT_TRUE(adaptive_pool->get_output_partial_shape(1).same_scheme( + {1, 6, Dimension::dynamic(), Dimension::dynamic()})); +} + +TEST(type_prop, adaptive_max_pool_dyn_rank) +{ + const PartialShape arg_shape = PartialShape::dynamic(); + + auto data = make_shared(element::f32, arg_shape); + auto out_shape = make_shared(element::i64, Shape{2}); + auto adaptive_pool = make_shared(data, out_shape); + + ASSERT_TRUE(adaptive_pool->get_output_partial_shape(0).same_scheme(PartialShape::dynamic())); + ASSERT_TRUE(adaptive_pool->get_output_partial_shape(1).same_scheme(PartialShape::dynamic())); +} + +TEST(type_prop, adaptive_max_pool_unsupported_input_shape) +{ + const PartialShape arg_shape{1, 6}; + const vector output_shape{1}; + + auto data = make_shared(element::f32, arg_shape); + auto out_shape = op::Constant::create(element::i64, Shape{}, output_shape); + + EXPECT_THROW(make_shared(data, out_shape), NodeValidationFailure); +} + +TEST(type_prop, adaptive_max_pool_wrong_out_shape) +{ + const PartialShape arg_shape{1, 6, 8, 9}; + const vector output_shape{5, 7, 8}; + + auto data = make_shared(element::f32, arg_shape); + auto out_shape = op::Constant::create(element::i64, Shape{3}, output_shape); + + EXPECT_THROW(make_shared(data, out_shape), NodeValidationFailure); +} diff --git a/ngraph/test/visitors/op/adaptive_avg_pool.cpp b/ngraph/test/visitors/op/adaptive_avg_pool.cpp new file mode 100644 index 00000000000000..377b955e1f01e0 --- /dev/null +++ b/ngraph/test/visitors/op/adaptive_avg_pool.cpp @@ -0,0 +1,27 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" + +#include "ngraph/ngraph.hpp" +#include "ngraph/op/util/attr_types.hpp" +#include "ngraph/opsets/opset8.hpp" +#include "util/visitor.hpp" + +using namespace std; +using namespace ngraph; +using ngraph::test::NodeBuilder; + +TEST(attributes, adaptive_avg_pool_op) +{ + NodeBuilder::get_ops().register_factory(); + const auto A = make_shared(element::f32, Shape{1, 3, 5, 4}); + const auto out_shape = op::Constant::create(element::i64, Shape{2}, {4, 3}); + + const auto adaptive_pool = make_shared(A, out_shape); + NodeBuilder builder(adaptive_pool); + + const auto expected_attr_count = 0; + EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); +} diff --git a/ngraph/test/visitors/op/adaptive_max_pool.cpp b/ngraph/test/visitors/op/adaptive_max_pool.cpp new file mode 100644 index 00000000000000..6210235c7d2342 --- /dev/null +++ b/ngraph/test/visitors/op/adaptive_max_pool.cpp @@ -0,0 +1,29 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" + +#include "ngraph/ngraph.hpp" +#include "ngraph/op/util/attr_types.hpp" +#include "ngraph/opsets/opset8.hpp" +#include "util/visitor.hpp" + +using namespace std; +using namespace ngraph; +using ngraph::test::NodeBuilder; + +TEST(attributes, adaptive_max_pool_op) +{ + NodeBuilder::get_ops().register_factory(); + const auto A = make_shared(element::f32, Shape{1, 3, 5, 4}); + const auto out_shape = op::Constant::create(element::i64, Shape{2}, {4, 3}); + + const auto adaptive_pool = make_shared(A, out_shape); + NodeBuilder builder(adaptive_pool); + auto g_adaptive_pool = as_type_ptr(builder.create()); + + const auto expected_attr_count = 1; + EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); + EXPECT_EQ(g_adaptive_pool->get_index_element_type(), adaptive_pool->get_index_element_type()); +} From 3426a239081f5eebed8b521778b0e90b59280a41 Mon Sep 17 00:00:00 2001 From: Evgenya Stepyreva Date: Tue, 22 Jun 2021 15:04:55 +0300 Subject: [PATCH 160/178] Range for convert precision (#6265) * ConvertPrecision for opset4::Range * ConvertPrecision test for Range operation --- .../transformations/convert_precision.hpp | 1 + .../transformations/convert_precision.cpp | 26 +++++++++++++++++++ ngraph/core/include/ngraph/op/range.hpp | 3 +++ ngraph/core/src/pass/convert_precision.cpp | 19 +++++++++++++- 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/inference-engine/src/transformations/include/transformations/convert_precision.hpp b/inference-engine/src/transformations/include/transformations/convert_precision.hpp index 56ea4dba7b9391..e7b8eab2fd1124 100644 --- a/inference-engine/src/transformations/include/transformations/convert_precision.hpp +++ b/inference-engine/src/transformations/include/transformations/convert_precision.hpp @@ -49,6 +49,7 @@ class NGRAPH_API ConvertPrecision; * opset4::Parameter * opset4::Convert * opset4::ShapeOf + * opset4::Range * opset3::NonMaxSuppression * opset4::NonMaxSuppression * opset4::TopK diff --git a/inference-engine/tests/functional/inference_engine/transformations/convert_precision.cpp b/inference-engine/tests/functional/inference_engine/transformations/convert_precision.cpp index a52b677037d56f..0604d062886204 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/convert_precision.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/convert_precision.cpp @@ -119,6 +119,32 @@ TEST(TransformationTests, ConvertPrecision_ShapeOf) { ASSERT_FALSE(has_type(f)); } + +TEST(TransformationTests, ConvertPrecision_Range) { + std::shared_ptr f(nullptr); + { + auto start = std::make_shared(element::f16, Shape{}); + auto stop = std::make_shared(element::f16, Shape{}); + auto shift = std::make_shared(element::f16, Shape{}); + auto range = std::make_shared(start, stop, shift, element::i64); + + f = std::make_shared(NodeVector{range}, ParameterVector{start, stop, shift}); + + pass::Manager manager; + + static const precisions_array precisions = { + { ngraph::element::i64, ngraph::element::i32 }, + { ngraph::element::f16, ngraph::element::f32 } + }; + + manager.register_pass(precisions); + manager.run_passes(f); + } + + ASSERT_FALSE(has_type(f)); + ASSERT_FALSE(has_type(f)); +} + TEST(TransformationTests, ConvertPrecision_ConstantRelu) { std::shared_ptr f(nullptr); { diff --git a/ngraph/core/include/ngraph/op/range.hpp b/ngraph/core/include/ngraph/op/range.hpp index fe09eecdf777f8..a63d6fac7c5e5c 100644 --- a/ngraph/core/include/ngraph/op/range.hpp +++ b/ngraph/core/include/ngraph/op/range.hpp @@ -43,6 +43,9 @@ namespace ngraph bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override; bool has_evaluate() const override; + void set_output_type(element::Type output_type) { m_output_type = output_type; } + // Overload collision with method on Node + using Node::set_output_type; private: element::Type m_output_type; diff --git a/ngraph/core/src/pass/convert_precision.cpp b/ngraph/core/src/pass/convert_precision.cpp index c5bfe5e95899cb..1efd710aa01bcf 100644 --- a/ngraph/core/src/pass/convert_precision.cpp +++ b/ngraph/core/src/pass/convert_precision.cpp @@ -28,6 +28,9 @@ bool fuse_type_to_shapeof(const std::shared_ptr& node, bool fuse_type_to_shapeof_v0(const std::shared_ptr& node, ngraph::element::Type to, size_t idx); +bool fuse_type_to_range_v4(const std::shared_ptr& node, + ngraph::element::Type to, + size_t idx); bool fuse_type_to_parameter(const std::shared_ptr& node, ngraph::element::Type to, size_t idx); @@ -341,7 +344,8 @@ bool ngraph::pass::ConvertPrecision::run_on_function(std::shared_ptr}, {opset4::ReduceLogicalOr::type_info, fuse_type_to_reduce_logical}, - {opset1::ShapeOf::type_info, fuse_type_to_shapeof_v0}}; + {opset1::ShapeOf::type_info, fuse_type_to_shapeof_v0}, + {opset4::Range::type_info, fuse_type_to_range_v4}}; type_to_fuse.insert(m_additional_type_to_fuse_map.begin(), m_additional_type_to_fuse_map.end()); @@ -383,6 +387,19 @@ bool fuse_type_to_shapeof(const std::shared_ptr& node, element::Ty return false; } +bool fuse_type_to_range_v4(const std::shared_ptr& node, element::Type to, size_t idx) +{ + if (auto range = as_type_ptr(node)) + { + if (to.is_integral_number() || to.is_real()) + { + range->set_output_type(to); + return true; + } + } + return false; +} + bool fuse_type_to_parameter(const std::shared_ptr& node, element::Type to, size_t idx) { if (auto param = as_type_ptr(node)) From eabaa260eea15a8cf898d9017a7f70e8b3369e65 Mon Sep 17 00:00:00 2001 From: Egor Duplensky Date: Tue, 22 Jun 2021 15:54:24 +0300 Subject: [PATCH 161/178] [Python Tools] Fix cross_check_tool device config parsing (#6150) --- inference-engine/tools/cross_check_tool/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inference-engine/tools/cross_check_tool/utils.py b/inference-engine/tools/cross_check_tool/utils.py index 088f5b7973996b..8d5d778b41cb1a 100644 --- a/inference-engine/tools/cross_check_tool/utils.py +++ b/inference-engine/tools/cross_check_tool/utils.py @@ -295,7 +295,7 @@ def get_config_dictionary(config_file): return config with open(config_file) as f: config_line = f.readline() - key = config_line.split(config_file)[0] + key = config_line.split()[0] value = config_line[len(key):].strip() config[key] = value return config From fa2f9c5201983d7ce247d1723083ca033f3c672d Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Tue, 22 Jun 2021 17:39:39 +0300 Subject: [PATCH 162/178] Migrated to official GoogleTest repo (#6286) * Move gtest to /wqthirdparty * Fixed inference engine tests * Fixed unit-tests * Fixed GPU * Fixed clDNN_unit_tests compilation * Reverted ngraph changes * Fixed VPU tests * Fixed deprecated tests compilation * Removed OpenVINO clone * Added public submodule * Removed * Fixed Windows * More updates for INSTANTIATE_TEST_SUITE_P * Use release-1.10.0 * Removed ngraph copy of gtest * Revert "Removed ngraph copy of gtest" This reverts commit ec9fe08d79acf77b0a77f1b255c1b39cc9ce93cb. * Fixes for TYPED_TEST_CASE * Fixed GNA tests * Updated submodule * Updaed index * TMP disabled tests * Revert changes and fix compilation errors * Fixed caching tests * Revert back * Revert back all Co-authored-by: Michael Nosov --- .gitmodules | 8 +- docs/IE_PLUGIN_DG/PluginTesting.md | 2 +- .../behavior/caching_tests.cpp | 2 +- .../behavior/config.cpp | 8 +- .../behavior/core_integration.cpp | 50 +- .../behavior/cpp_holders.cpp | 6 +- .../behavior/exec_graph_info.cpp | 2 +- .../behavior/infer_request.cpp | 2 +- .../behavior/infer_request_callback.cpp | 2 +- .../behavior/infer_request_config.cpp | 2 +- .../behavior/infer_request_input.cpp | 2 +- .../behavior/infer_request_output.cpp | 2 +- .../behavior/layout.cpp | 2 +- .../behavior/preprocessing.cpp | 4 +- .../behavior/set_preprocess.cpp | 10 +- .../behavior/test_plugin.cpp | 6 +- .../behavior/version.cpp | 2 +- .../hetero/query_network.cpp | 2 +- .../hetero/synthetic.cpp | 4 +- .../single_layer_tests/convolution.cpp | 8 +- .../single_layer_tests/reshape.cpp | 6 +- .../single_layer_tests/softmax.cpp | 4 +- .../single_layer_tests/split.cpp | 2 +- .../gna_plugin/optimizer/gna_pass_manager.cpp | 6 +- .../inference_engine/blob_copy_test.cpp | 4 +- .../inference_engine/caching_test.cpp | 6 +- .../cnn_network/matmul_sr_tests.cpp | 2 +- .../ir_serialization/serialize.cpp | 4 +- .../lp_transformations/add_transformation.cpp | 2 +- .../avg_pool_transformation.cpp | 2 +- .../clamp_transformation.cpp | 2 +- .../compose_fake_quantize_transformation.cpp | 2 +- ...ction_with_intermediate_transformation.cpp | 2 +- .../concat_transformation.cpp | 2 +- ...t_with_different_precision_on_children.cpp | 2 +- ...ate_precision_selection_transformation.cpp | 2 +- ...th_intermediate_reshape_transformation.cpp | 2 +- ...oncat_with_intermediate_transformation.cpp | 2 +- ...ermediate_with_constant_transformation.cpp | 2 +- .../concat_with_neighbors_transformation.cpp | 2 +- ...with_reshape_at_the_end_transformation.cpp | 2 +- .../concat_with_split_transformation.cpp | 4 +- ...ncat_with_strided_slice_transformation.cpp | 2 +- ...lly_transformation_with_dequantization.cpp | 2 +- ...nvert_subtract_constant_transformation.cpp | 2 +- ...nvolution_backprop_data_transformation.cpp | 2 +- .../convolution_qdq_transformation.cpp | 2 +- .../convolution_transformation.cpp | 2 +- .../convolution_with_incorrect_weights.cpp | 2 +- .../depth_to_space_transformation.cpp | 2 +- ...e_convert_on_const_path_transformation.cpp | 2 +- ...i_parent_dequantization_transformation.cpp | 2 +- ...d_two_output_branches_with_convolution.cpp | 2 +- ...tize_on_weights_with_unsupported_child.cpp | 2 +- ...ize_precision_selection_transformation.cpp | 2 +- .../fake_quantize_transformation.cpp | 2 +- ...ize_with_dq_not_optimal_transformation.cpp | 2 +- ..._with_dynamic_intervals_transformation.cpp | 2 +- .../fold_convert_transformation.cpp | 2 +- .../fold_fake_quantize_in_transformations.cpp | 2 +- .../fuse_convert_transformation.cpp | 2 +- .../fuse_fake_quantize_transformation.cpp | 2 +- ...ntize_with_multi_inputs_transformation.cpp | 2 +- ...ltiply_to_fake_quantize_transformation.cpp | 2 +- ...btract_to_fake_quantize_transformation.cpp | 2 +- ...et_dequantization_below_transformation.cpp | 2 +- .../get_dequantization_test.cpp | 2 +- .../get_dequantization_transformation.cpp | 2 +- .../group_convolution_transformation.cpp | 2 +- .../interpolate_transformation.cpp | 2 +- .../is_function_quantized_transformation.cpp | 2 +- .../mat_mul_transformation.cpp | 2 +- .../mat_mul_with_constant_transformation.cpp | 2 +- .../max_pool_transformation.cpp | 2 +- ...ve_dequantization_after_transformation.cpp | 2 +- ..._to_scaleshift_or_power_transformation.cpp | 2 +- ...ly_to_group_convolution_transformation.cpp | 2 +- .../multiply_transformation.cpp | 2 +- .../lp_transformations/mvn_transformation.cpp | 2 +- ...ormalize_dequantization_transformation.cpp | 2 +- .../normalize_l2_transformation.cpp | 2 +- .../prelu_transformation.cpp | 2 +- ..._through_dequantization_transformation.cpp | 2 +- ..._through_dequantization_transformation.cpp | 2 +- .../reduce_max_transformation.cpp | 2 +- .../reduce_mean_transformation.cpp | 2 +- .../reduce_min_transformation.cpp | 2 +- .../reduce_sum_transformation.cpp | 2 +- .../relu_transformation.cpp | 2 +- ...reshape_fully_connected_transformation.cpp | 2 +- .../reshape_transformation.cpp | 2 +- .../round_transformation.cpp | 2 +- ...te_in_standalone_branch_transformation.cpp | 2 +- .../shuffle_channels_transformation.cpp | 2 +- .../split_transformation.cpp | 2 +- .../squeeze_transformation.cpp | 2 +- .../strided_slice_transformation.cpp | 2 +- ...ultiply_to_multiply_add_transformation.cpp | 2 +- ...sformations_after_split_transformation.cpp | 2 +- .../transformer_is_function_quantized.cpp | 2 +- .../transpose_transformation.cpp | 2 +- .../unsqueeze_transformation.cpp | 2 +- .../variadic_split_transformation.cpp | 2 +- .../ngraph_reader/net_reader_test.cpp | 2 +- .../serialization/single_layer/activation.cpp | 8 +- .../serialization/single_layer/batch_norm.cpp | 2 +- .../single_layer/binary_convolution.cpp | 4 +- .../serialization/single_layer/broadcast.cpp | 2 +- .../serialization/single_layer/clamp.cpp | 2 +- .../serialization/single_layer/constant.cpp | 4 +- .../serialization/single_layer/convert.cpp | 2 +- .../single_layer/convolution.cpp | 4 +- .../single_layer/convolution_backprop.cpp | 2 +- .../single_layer/deformable_convolution.cpp | 4 +- .../single_layer/deformable_psroi_pooling.cpp | 2 +- .../single_layer/detection_output.cpp | 2 +- .../single_layer/elementwise.cpp | 2 +- .../single_layer/extractimagepatches.cpp | 2 +- .../single_layer/group_convolution.cpp | 2 +- .../group_convolution_backprop_data.cpp | 2 +- .../single_layer/minimum_maximum.cpp | 2 +- .../serialization/single_layer/mvn.cpp | 4 +- .../single_layer/non_max_suppression.cpp | 2 +- .../serialization/single_layer/nonzero.cpp | 2 +- .../single_layer/normalize_l2.cpp | 2 +- .../serialization/single_layer/one_hot.cpp | 2 +- .../serialization/single_layer/pad.cpp | 2 +- .../serialization/single_layer/pooling.cpp | 4 +- .../serialization/single_layer/prelu.cpp | 2 +- .../single_layer/prior_box_clustered.cpp | 2 +- .../serialization/single_layer/reduce_ops.cpp | 10 +- .../single_layer/region_yolo.cpp | 2 +- .../serialization/single_layer/reshape.cpp | 2 +- .../serialization/single_layer/result.cpp | 2 +- .../single_layer/scatter_nd_update.cpp | 2 +- .../single_layer/shuffle_channels.cpp | 2 +- .../single_layer/space_to_batch.cpp | 2 +- .../serialization/single_layer/split.cpp | 2 +- .../serialization/single_layer/squeeze.cpp | 2 +- .../single_layer/tensor_iterator.cpp | 2 +- .../serialization/single_layer/transpose.cpp | 6 +- .../serialization/single_layer/unsqueeze.cpp | 2 +- .../single_layer/variadic_split.cpp | 2 +- .../inference_engine/task_executor_tests.cpp | 4 +- .../broadcast_elementwise_fusion_test.cpp | 10 +- .../transformations/conv_fusion_test.cpp | 8 +- .../convert_broadcast3_test.cpp | 10 +- .../convert_convolution_test.cpp | 2 +- .../convert_deconvolution_test.cpp | 2 +- .../convert_reduce_to_pooling_test.cpp | 6 +- .../eliminate_unsqueeze_gather.cpp | 2 +- .../transformations/fq_decomposition_test.cpp | 16 +- .../transformations/fq_mul_fusion_test.cpp | 24 +- .../transformations/fq_reshape_fusion.cpp | 2 +- .../mul_add_conversion_test.cpp | 18 +- .../shuffle_channels_fusion_test.cpp | 2 +- .../transformations/softmax_fusion.cpp | 4 +- .../transpose_sinking_test.cpp | 6 +- .../transpose_to_reshape_test.cpp | 8 +- .../weights_dequantize_to_fake_quantize.cpp | 2 +- .../test_runner/src/read_ir/read_ir.cpp | 2 +- .../cpu/bfloat16/bf16_network_restoring.cpp | 2 +- .../plugin/cpu/bfloat16/bfloat16_helpers.hpp | 2 +- .../plugin/cpu/bfloat16/concat_in_place.cpp | 4 +- .../plugin/cpu/bfloat16/conv_add.cpp | 4 +- .../plugin/cpu/bfloat16/conv_conv.cpp | 4 +- .../plugin/cpu/bfloat16/conv_dwconv_relu.cpp | 4 +- .../cpu/bfloat16/conv_eltwise_depthwise.cpp | 6 +- .../conv_relu_pool_conv_relu_pool.cpp | 4 +- .../plugin/cpu/bfloat16/elt_max.cpp | 4 +- .../functional/plugin/cpu/bfloat16/elt_x3.cpp | 4 +- .../cpu/bfloat16/faster_100_5_1_1_conv.cpp | 4 +- .../plugin/cpu/bfloat16/gather_multiply.cpp | 4 +- .../gather_x2_add_mul_relu_concat_matmul.cpp | 4 +- .../plugin/cpu/bfloat16/memory_conv.cpp | 2 +- .../bfloat16/mobilenet_ssd_with_branching.cpp | 4 +- .../bfloat16/scaleshift_conv_eltwise_conv.cpp | 4 +- .../scaleshift_conv_eltwise_relu_conv.cpp | 4 +- .../scaleshift_conv_eltwise_scaleshift.cpp | 4 +- .../cpu/bfloat16/scaleshift_conv_elu_conv.cpp | 4 +- .../cpu/bfloat16/scaleshift_conv_relu.cpp | 4 +- .../scaleshift_conv_x2_concat_relu.cpp | 4 +- .../bfloat16/scaleshift_conv_x2_eltwise.cpp | 4 +- .../scaleshift_conv_x2_mixed1_eltwise.cpp | 4 +- .../scaleshift_conv_x2_mixed2_eltwise.cpp | 4 +- .../bfloat16/scaleshift_conv_x3_eltwise.cpp | 4 +- .../scaleshift_x2_conv_x2_eltwise.cpp | 4 +- .../scaleshift_x3_conv_eltwise_relu.cpp | 4 +- .../cpu/bfloat16/tail_fp32_optimization.cpp | 4 +- .../plugin/cpu/bfloat16/topk_inputs_i32.cpp | 4 +- .../behavior/add_output.cpp | 2 +- .../behavior/caching_tests.cpp | 2 +- .../behavior/config.cpp | 22 +- .../behavior/core_integration.cpp | 54 +- .../behavior/core_threading_tests.cpp | 6 +- .../behavior/cpp_holders.cpp | 2 +- .../behavior/exec_graph_info.cpp | 6 +- .../behavior/infer_request.cpp | 6 +- .../behavior/infer_request_callback.cpp | 6 +- .../behavior/infer_request_cancellation.cpp | 2 +- .../behavior/infer_request_config.cpp | 12 +- .../behavior/infer_request_input.cpp | 6 +- .../behavior/infer_request_output.cpp | 6 +- .../behavior/invalid_cases/proposal.cpp | 2 +- .../behavior/layout.cpp | 2 +- .../behavior/perf_counters.cpp | 4 +- .../behavior/preprocessing.cpp | 4 +- .../behavior/set_blob.cpp | 2 +- .../behavior/set_blob_of_kind.cpp | 8 +- .../behavior/set_preprocess.cpp | 24 +- .../behavior/test_plugin.cpp | 18 +- .../behavior/version.cpp | 8 +- .../configuration_tests.cpp | 2 +- .../configuration_tests/dynamic_batch.cpp | 4 +- .../exec_graph_serialization.cpp | 2 +- .../execution_graph_tests/keep_assign.cpp | 2 +- .../nms_transformation_for_last_node.cpp | 2 +- .../num_inputs_fusing_bin_conv.cpp | 2 +- .../remove_parameter.cpp | 2 +- .../runtime_precision.cpp | 2 +- .../unique_node_names.cpp | 2 +- .../hetero/query_network.cpp | 2 +- .../hetero/synthetic.cpp | 4 +- .../add_transformation.cpp | 2 +- .../clamp_transformation.cpp | 2 +- .../concat_transformation.cpp | 2 +- .../concat_with_child_and_output.cpp | 2 +- ...t_with_different_precision_on_children.cpp | 2 +- ...oncat_with_intermediate_transformation.cpp | 2 +- .../concat_with_neighbors_transformation.cpp | 2 +- .../concat_with_split_transformation.cpp | 2 +- ...nvolution_backprop_data_transformation.cpp | 2 +- .../convolution_qdq_transformation.cpp | 2 +- .../convolution_transformation.cpp | 4 +- .../depth_to_space_transformation.cpp | 4 +- ...e_quantize_and_avg_pool_transformation.cpp | 2 +- ...e_quantize_and_max_pool_transformation.cpp | 2 +- ...d_two_output_branches_with_convolution.cpp | 2 +- ...ize_precision_selection_transformation.cpp | 2 +- .../fake_quantize_transformation.cpp | 2 +- ...ize_with_dq_not_optimal_transformation.cpp | 2 +- .../fully_connected_transformation.cpp | 2 +- .../fuse_convert_transformation.cpp | 2 +- ...uantize_and_scale_shift_transformation.cpp | 2 +- .../fuse_fake_quantize_transformation.cpp | 2 +- ...ltiply_to_fake_quantize_transformation.cpp | 2 +- ...btract_to_fake_quantize_transformation.cpp | 2 +- .../gemm_transformation.cpp | 2 +- .../group_convolution_transformation.cpp | 2 +- .../groupconvolution_qdq_transformation.cpp | 2 +- .../interpolate_transformation.cpp | 2 +- .../mat_mul_transformation.cpp | 2 +- .../mat_mul_with_constant_transformation.cpp | 2 +- ..._constant_fake_quantize_transformation.cpp | 2 +- ...ly_to_group_convolution_transformation.cpp | 2 +- .../multiply_transformation.cpp | 2 +- ...ultiply_with_one_parent_transformation.cpp | 2 +- .../mvn_transformation.cpp | 2 +- .../normalize_transformation.cpp | 2 +- ...put_layers_handling_in_transformations.cpp | 2 +- ...handling_in_transformations_for_concat.cpp | 2 +- ...ansformations_for_concat_multi_channel.cpp | 2 +- .../prelu_transformation.cpp | 2 +- ..._through_dequantization_transformation.cpp | 2 +- .../reduce_max_transformation.cpp | 2 +- .../reduce_mean_transformation.cpp | 2 +- .../reduce_min_transformation.cpp | 2 +- .../reduce_sum_transformation.cpp | 2 +- .../relu_transformation.cpp | 2 +- .../reshape_transformation.cpp | 2 +- .../shuffle_channels_transformation.cpp | 2 +- .../split_transformation.cpp | 2 +- .../squeeze_transformation.cpp | 2 +- .../strided_slice_transformation.cpp | 2 +- ...ultiply_to_multiply_add_transformation.cpp | 2 +- .../subtract_transformation.cpp | 2 +- .../transpose_after_matmul_transformation.cpp | 2 +- .../transpose_transformation.cpp | 2 +- .../unsqueeze_transformation.cpp | 2 +- .../variadic_split_transformation.cpp | 2 +- .../multi/cpu_remote_blob_tests.cpp | 2 +- .../conv_bias_fusion.cpp | 2 +- .../plugin_specific_ngraph_conversion.cpp | 2 +- .../single_layer_tests/activation.cpp | 10 +- .../single_layer_tests/batch_norm.cpp | 2 +- .../single_layer_tests/batch_to_space.cpp | 2 +- .../single_layer_tests/binary_convolution.cpp | 4 +- .../single_layer_tests/broadcast.cpp | 14 +- .../single_layer_tests/bucketize.cpp | 4 +- .../single_layer_tests/clamp.cpp | 4 +- .../single_layer_tests/comparison.cpp | 2 +- .../single_layer_tests/concat.cpp | 2 +- .../single_layer_tests/constant.cpp | 4 +- .../single_layer_tests/convert.cpp | 2 +- .../single_layer_tests/convert_like.cpp | 2 +- .../single_layer_tests/convolution.cpp | 14 +- .../convolution_backprop_data.cpp | 20 +- .../single_layer_tests/ctc_greedy_decoder.cpp | 2 +- .../ctc_greedy_decoder_seq_len.cpp | 4 +- .../single_layer_tests/ctc_loss.cpp | 4 +- .../single_layer_tests/cum_sum.cpp | 16 +- .../deformable_convolution.cpp | 6 +- .../deformable_psroi_pooling.cpp | 4 +- .../single_layer_tests/depth_to_space.cpp | 4 +- .../single_layer_tests/detection_output.cpp | 4 +- .../single_layer_tests/dft.cpp | 8 +- .../single_layer_tests/eltwise.cpp | 4 +- .../embedding_bag_offsets_sum.cpp | 2 +- .../embedding_bag_packed_sum.cpp | 2 +- .../embedding_segments_sum.cpp | 2 +- .../extract_image_patches.cpp | 2 +- .../single_layer_tests/fake_quantize.cpp | 8 +- .../single_layer_tests/gather.cpp | 12 +- .../single_layer_tests/gather_elements.cpp | 10 +- .../single_layer_tests/gather_nd.cpp | 4 +- .../single_layer_tests/gather_tree.cpp | 2 +- .../single_layer_tests/group_convolution.cpp | 12 +- .../group_convolution_backprop_data.cpp | 12 +- .../single_layer_tests/gru_cell.cpp | 2 +- .../single_layer_tests/gru_sequence.cpp | 4 +- .../single_layer_tests/interpolate.cpp | 8 +- .../single_layer_tests/log_softmax.cpp | 4 +- .../single_layer_tests/logical.cpp | 4 +- .../single_layer_tests/loop.cpp | 6 +- .../single_layer_tests/lrn.cpp | 8 +- .../single_layer_tests/lstm_cell.cpp | 2 +- .../single_layer_tests/lstm_sequence.cpp | 4 +- .../single_layer_tests/mat_mul.cpp | 2 +- .../single_layer_tests/memory.cpp | 2 +- .../single_layer_tests/minimum_maximum.cpp | 2 +- .../single_layer_tests/mvn.cpp | 18 +- .../non_max_suppression.cpp | 2 +- .../single_layer_tests/normalize_l2.cpp | 2 +- .../single_layer_tests/one_hot.cpp | 6 +- .../single_layer_tests/pad.cpp | 12 +- .../single_layer_tests/pooling.cpp | 28 +- .../single_layer_tests/proposal.cpp | 2 +- .../single_layer_tests/psroi_pooling.cpp | 4 +- .../single_layer_tests/range.cpp | 2 +- .../single_layer_tests/reduce_ops.cpp | 16 +- .../single_layer_tests/region_yolo.cpp | 6 +- .../single_layer_tests/reorg_yolo.cpp | 12 +- .../single_layer_tests/reshape.cpp | 6 +- .../single_layer_tests/result.cpp | 2 +- .../single_layer_tests/reverse_sequence.cpp | 2 +- .../single_layer_tests/rnn_cell.cpp | 2 +- .../single_layer_tests/rnn_sequence.cpp | 4 +- .../single_layer_tests/roi_align.cpp | 4 +- .../single_layer_tests/roi_pooling.cpp | 4 +- .../single_layer_tests/roll.cpp | 16 +- .../single_layer_tests/scatter_ND_update.cpp | 2 +- .../scatter_elements_update.cpp | 2 +- .../single_layer_tests/scatter_update.cpp | 2 +- .../single_layer_tests/select.cpp | 4 +- .../single_layer_tests/shape_of.cpp | 2 +- .../single_layer_tests/shuffle_channels.cpp | 12 +- .../single_layer_tests/softmax.cpp | 4 +- .../single_layer_tests/space_to_batch.cpp | 4 +- .../single_layer_tests/space_to_depth.cpp | 4 +- .../single_layer_tests/split.cpp | 4 +- .../single_layer_tests/squeeze_unsqueeze.cpp | 4 +- .../single_layer_tests/strided_slice.cpp | 2 +- .../single_layer_tests/tensor_iterator.cpp | 4 +- .../single_layer_tests/tile.cpp | 4 +- .../single_layer_tests/topk.cpp | 2 +- .../single_layer_tests/transpose.cpp | 8 +- .../single_layer_tests/variadic_split.cpp | 2 +- .../subgraph_tests/codegen_add.cpp | 2 +- .../subgraph_tests/codegen_bert.cpp | 2 +- .../subgraph_tests/codegen_gelu.cpp | 2 +- .../subgraph_tests/constant_result.cpp | 2 +- .../subgraph_tests/conv_eltwise_fusion.cpp | 24 +- .../convert_pad_to_group_conv.cpp | 4 +- .../get_output_before_activation.cpp | 2 +- .../subgraph_tests/matmul_squeeze_add.cpp | 2 +- .../subgraph_tests/memory_LSTMCell.cpp | 2 +- .../subgraph_tests/multiple_LSTMCell.cpp | 2 +- .../subgraph_tests/multiply_add.cpp | 2 +- .../subgraph_tests/mvn_multiply_add.cpp | 6 +- .../subgraph_tests/parameter_result.cpp | 2 +- .../subgraph_tests/perm_conv_perm_concat.cpp | 2 +- .../quantized_convolution_backprop_data.cpp | 4 +- .../quantized_group_convolution.cpp | 4 +- ...ntized_group_convolution_backprop_data.cpp | 4 +- .../subgraph_tests/quantized_mat_mul.cpp | 6 +- .../subgraph_tests/range_add.cpp | 10 +- .../subgraph_tests/relu_shape_of.cpp | 2 +- .../reshape_squeeze_reshape_relu.cpp | 2 +- .../subgraph_tests/split_concat_memory.cpp | 2 +- .../subgraph_tests/split_conv_concat.cpp | 2 +- .../subgraph_tests/tensor_names.cpp | 2 +- .../subgraph_tests/variadic_split_pad.cpp | 2 +- .../cpu/single_layer_tests/activation.cpp | 4 +- .../cpu/single_layer_tests/batch_to_space.cpp | 8 +- .../plugin/cpu/single_layer_tests/concat.cpp | 22 +- .../plugin/cpu/single_layer_tests/convert.cpp | 4 +- .../convert_to_plugin_specific_node.cpp | 4 +- .../cpu/single_layer_tests/convolution.cpp | 46 +- .../convolution_backprop_data.cpp | 20 +- .../cpu/single_layer_tests/depth_to_space.cpp | 8 +- .../plugin/cpu/single_layer_tests/eltwise.cpp | 20 +- .../extract_image_patches.cpp | 2 +- .../cpu/single_layer_tests/fake_quantize.cpp | 10 +- .../single_layer_tests/gather_elements.cpp | 2 +- .../single_layer_tests/group_convolution.cpp | 38 +- .../group_convolution_backprop_data.cpp | 20 +- .../cpu/single_layer_tests/gru_cell.cpp | 2 +- .../cpu/single_layer_tests/gru_sequence.cpp | 4 +- .../cpu/single_layer_tests/interpolate.cpp | 12 +- .../plugin/cpu/single_layer_tests/logical.cpp | 4 +- .../cpu/single_layer_tests/lstm_cell.cpp | 2 +- .../cpu/single_layer_tests/lstm_sequence.cpp | 4 +- .../plugin/cpu/single_layer_tests/mat_mul.cpp | 6 +- .../plugin/cpu/single_layer_tests/mvn.cpp | 12 +- .../cpu/single_layer_tests/normalize.cpp | 6 +- .../plugin/cpu/single_layer_tests/one_hot.cpp | 10 +- .../plugin/cpu/single_layer_tests/pad.cpp | 16 +- .../plugin/cpu/single_layer_tests/pooling.cpp | 16 +- .../cpu/single_layer_tests/psroi_pooling.cpp | 4 +- .../cpu/single_layer_tests/reduce_ops.cpp | 16 +- .../cpu/single_layer_tests/region_yolo.cpp | 6 +- .../cpu/single_layer_tests/rnn_cell.cpp | 2 +- .../cpu/single_layer_tests/rnn_sequence.cpp | 4 +- .../cpu/single_layer_tests/roi_pooling.cpp | 4 +- .../cpu/single_layer_tests/roialign.cpp | 2 +- .../single_layer_tests/shuffle_channels.cpp | 8 +- .../plugin/cpu/single_layer_tests/softmax.cpp | 4 +- .../cpu/single_layer_tests/space_to_batch.cpp | 6 +- .../cpu/single_layer_tests/space_to_depth.cpp | 8 +- .../plugin/cpu/single_layer_tests/split.cpp | 26 +- .../cpu/single_layer_tests/strided_slice.cpp | 10 +- .../cpu/single_layer_tests/transpose.cpp | 8 +- .../cpu/subgraph_tests/src/conv3d_reshape.cpp | 2 +- .../cpu/subgraph_tests/src/conv_concat.cpp | 26 +- .../subgraph_tests/src/conv_maxpool_activ.cpp | 2 +- .../cpu/subgraph_tests/src/eltwise_chain.cpp | 4 +- .../src/fuse_muladd_ewsimple.cpp | 6 +- .../src/fuse_scaleshift_and_fakequantize.cpp | 2 +- .../src/fuse_transpose_reorder.cpp | 6 +- .../src/param_result_custom_blob.cpp | 4 +- .../cpu/subgraph_tests/src/reshape_fc.cpp | 2 +- ...shape_permute_conv_permute_reshape_act.cpp | 2 +- .../import_export_act_conv_act.cpp | 2 +- .../import_export_memory_layer.cpp | 2 +- .../plugin/gna/pass_tests/4d_eltwise.cpp | 4 +- .../gna/pass_tests/act_maxpool_reordering.cpp | 2 +- .../pass_tests/broadcast_const_with_fq.cpp | 2 +- .../convert_matmul_to_fullyconnected.cpp | 2 +- .../convert_matmul_to_pointwise_conv.cpp | 4 +- .../eltwise_split_over_channels_pass.cpp | 2 +- .../plugin/gna/pass_tests/fq_activation.cpp | 2 +- .../fq_fusion_with_multiple_weights.cpp | 2 +- .../gna/pass_tests/fq_maxpool_reordering.cpp | 2 +- .../insert_copy_layer_before_self_concat.cpp | 2 +- .../insert_transpose_before_matmul.cpp | 2 +- .../insert_transpose_between_convs.cpp | 4 +- .../gna/pass_tests/layers_restrictions.cpp | 4 +- .../remove_permutations_NHWC_to_NCHW_pass.cpp | 10 +- .../behavior/add_output.cpp | 2 +- .../behavior/caching_tests.cpp | 2 +- .../behavior/config.cpp | 6 +- .../behavior/core_integration.cpp | 56 +- .../behavior/core_threading_tests.cpp | 4 +- .../behavior/cpp_holders.cpp | 6 +- .../behavior/exec_graph_info.cpp | 2 +- .../behavior/infer_request.cpp | 4 +- .../behavior/infer_request_callback.cpp | 4 +- .../behavior/infer_request_config.cpp | 4 +- .../behavior/infer_request_input.cpp | 2 +- .../behavior/infer_request_output.cpp | 2 +- .../behavior/layout.cpp | 2 +- .../behavior/memory_states.cpp | 2 +- .../behavior/test_plugin.cpp | 6 +- .../behavior/version.cpp | 4 +- .../import_reshape_permute_conv.cpp | 2 +- .../single_layer_tests/activation.cpp | 2 +- .../single_layer_tests/concat.cpp | 2 +- .../single_layer_tests/convolution.cpp | 12 +- .../convolution_negative.cpp | 2 +- .../single_layer_tests/eltwise.cpp | 2 +- .../single_layer_tests/fake_quantize.cpp | 2 +- .../single_layer_tests/low_precision.cpp | 2 +- .../single_layer_tests/mat_mul.cpp | 2 +- .../single_layer_tests/memory.cpp | 2 +- .../single_layer_tests/pooling.cpp | 10 +- .../single_layer_tests/power.cpp | 2 +- .../single_layer_tests/split.cpp | 2 +- .../single_layer_tests/tensor_iterator.cpp | 2 +- .../activation_concats_eltwise.cpp | 2 +- .../subgraph_tests/activation_fq.cpp | 2 +- .../subgraph_tests/basic_lstm.cpp | 2 +- .../subgraph_tests/broadcast_power.cpp | 2 +- .../subgraph_tests/cascade_concat.cpp | 4 +- .../subgraph_tests/clamp_fq.cpp | 2 +- .../subgraph_tests/concat_conv.cpp | 2 +- .../subgraph_tests/concat_multi_input.cpp | 2 +- .../subgraph_tests/concat_quantization.cpp | 2 +- ...ntization_during_memory_requantization.cpp | 2 +- .../subgraph_tests/connect_split_concat.cpp | 4 +- .../subgraph_tests/const_conv_concat.cpp | 2 +- .../const_strided_slice_concat.cpp | 2 +- .../subgraph_tests/constant_result.cpp | 2 +- .../subgraph_tests/conv_fq_eltwise.cpp | 2 +- .../subgraph_tests/conv_fq_relu.cpp | 2 +- .../convolution_relu_sequence.cpp | 2 +- .../subgraph_tests/copy_before_squeeze.cpp | 2 +- .../subgraph_tests/crop4d.cpp | 2 +- .../subgraph_tests/delayed_copy_layer.cpp | 2 +- .../subgraph_tests/eltwise_conv_eltwise.cpp | 6 +- .../eltwise_reshape_activation.cpp | 2 +- .../subgraph_tests/fc_conv_fc.cpp | 6 +- .../first_connect_input_concat.cpp | 2 +- .../subgraph_tests/fq_conv_fq_affine.cpp | 2 +- .../get_output_before_activation.cpp | 2 +- .../handling_orientation_conv.cpp | 2 +- .../subgraph_tests/input_conv.cpp | 2 +- .../subgraph_tests/input_split_concat.cpp | 2 +- .../subgraph_tests/matmul_squeeze_add.cpp | 2 +- .../subgraph_tests/memory_LSTMCell.cpp | 2 +- .../memory_eltwise_reshape_concat.cpp | 2 +- .../multioutput_eltwise_squeeze_eltwise.cpp | 2 +- .../subgraph_tests/multiple_LSTMCell.cpp | 2 +- .../subgraph_tests/multiple_concat.cpp | 8 +- .../negative_memory_layer_offset.cpp | 2 +- .../subgraph_tests/perm_conv_perm_concat.cpp | 2 +- ...shape_permute_conv_permute_reshape_act.cpp | 2 +- .../reshape_squeeze_reshape_relu.cpp | 2 +- .../reshapre_permute_reshape.cpp | 2 +- .../subgraph_tests/scale_shift.cpp | 2 +- .../scaleshift_conv_scaleshift.cpp | 4 +- .../subgraph_tests/softsign.cpp | 2 +- .../subgraph_tests/split_conv.cpp | 2 +- .../subgraph_tests/split_conv_concat.cpp | 2 +- .../subgraph_tests/split_relu.cpp | 2 +- .../split_trivial_permute_concat.cpp | 2 +- .../subgraph_tests/stridedslice_conv.cpp | 2 +- .../subgraph_tests/tensor_names.cpp | 2 +- .../subgraph_tests/trivial_concat.cpp | 2 +- .../two_fake_quantize_to_fullyconnected.cpp | 6 +- .../cldnn_remote_blob_tests.cpp | 4 +- .../behavior/caching_tests.cpp | 2 +- .../behavior/config.cpp | 24 +- .../behavior/core_integration.cpp | 64 +- .../behavior/core_threading_tests.cpp | 4 +- .../behavior/cpp_holders.cpp | 2 +- .../behavior/exec_graph_info.cpp | 2 +- .../behavior/infer_request.cpp | 8 +- .../behavior/infer_request_callback.cpp | 8 +- .../behavior/infer_request_config.cpp | 8 +- .../behavior/infer_request_input.cpp | 8 +- .../behavior/infer_request_output.cpp | 8 +- .../behavior/layout.cpp | 2 +- .../behavior/perf_counters.cpp | 4 +- .../behavior/set_blob_of_kind.cpp | 2 +- .../behavior/set_preprocess.cpp | 12 +- .../behavior/test_plugin.cpp | 24 +- .../behavior/version.cpp | 10 +- .../configuration_tests/dynamic_batch.cpp | 4 +- .../unique_node_names.cpp | 2 +- .../hetero/query_network.cpp | 2 +- .../add_transformation.cpp | 2 +- .../clamp_transformation.cpp | 2 +- .../concat_transformation.cpp | 2 +- .../concat_with_child_and_output.cpp | 2 +- ...t_with_different_precision_on_children.cpp | 2 +- ...oncat_with_intermediate_transformation.cpp | 2 +- ...at_with_neighbors_graph_transformation.cpp | 2 +- .../concat_with_split_transformation.cpp | 2 +- ...nvolution_backprop_data_transformation.cpp | 2 +- .../convolution_qdq_transformation.cpp | 2 +- .../convolution_transformation.cpp | 4 +- .../depth_to_space_transformation.cpp | 4 +- ...e_quantize_and_avg_pool_transformation.cpp | 2 +- ...e_quantize_and_max_pool_transformation.cpp | 2 +- ...d_two_output_branches_with_convolution.cpp | 2 +- ...ize_precision_selection_transformation.cpp | 2 +- .../fake_quantize_transformation.cpp | 2 +- ...ize_with_dq_not_optimal_transformation.cpp | 2 +- .../fully_connected_transformation.cpp | 2 +- .../fuse_convert_transformation.cpp | 2 +- ...uantize_and_scale_shift_transformation.cpp | 2 +- .../fuse_fake_quantize_transformation.cpp | 2 +- ...ltiply_to_fake_quantize_transformation.cpp | 2 +- ...btract_to_fake_quantize_transformation.cpp | 2 +- .../gemm_transformation.cpp | 2 +- .../group_convolution_transformation.cpp | 2 +- .../groupconvolution_qdq_transformation.cpp | 2 +- .../interpolate_transformation.cpp | 2 +- .../mat_mul_transformation.cpp | 2 +- .../mat_mul_with_constant_transformation.cpp | 2 +- ..._constant_fake_quantize_transformation.cpp | 2 +- ...ly_to_group_convolution_transformation.cpp | 2 +- .../multiply_transformation.cpp | 2 +- ...ultiply_with_one_parent_transformation.cpp | 2 +- .../mvn_transformation.cpp | 2 +- .../normalize_transformation.cpp | 2 +- ...put_layers_handling_in_transformations.cpp | 2 +- ...handling_in_transformations_for_concat.cpp | 2 +- ...ansformations_for_concat_multi_channel.cpp | 2 +- .../prelu_transformation.cpp | 2 +- ..._through_dequantization_transformation.cpp | 2 +- .../reduce_max_transformation.cpp | 2 +- .../reduce_mean_transformation.cpp | 2 +- .../reduce_min_transformation.cpp | 2 +- .../reduce_sum_transformation.cpp | 2 +- .../relu_transformation.cpp | 2 +- .../reshape_transformation.cpp | 2 +- .../shuffle_channels_transformation.cpp | 2 +- .../split_transformation.cpp | 2 +- .../squeeze_transformation.cpp | 2 +- .../strided_slice_transformation.cpp | 2 +- ...ultiply_to_multiply_add_transformation.cpp | 2 +- .../subtract_transformation.cpp | 2 +- .../transpose_after_matmul_transformation.cpp | 2 +- .../transpose_transformation.cpp | 2 +- .../unsqueeze_transformation.cpp | 2 +- .../variadic_split_transformation.cpp | 2 +- .../multi/gpu_remote_blob_tests.cpp | 4 +- .../conv_bias_fusion.cpp | 2 +- .../plugin_specific_ngraph_conversion.cpp | 2 +- .../single_layer_tests/activation.cpp | 6 +- .../single_layer_tests/batch_norm.cpp | 2 +- .../single_layer_tests/batch_to_space.cpp | 2 +- .../single_layer_tests/broadcast.cpp | 14 +- .../single_layer_tests/comparison.cpp | 2 +- .../single_layer_tests/concat.cpp | 2 +- .../single_layer_tests/convert.cpp | 2 +- .../single_layer_tests/convert_like.cpp | 2 +- .../single_layer_tests/convolution.cpp | 6 +- .../convolution_backprop_data.cpp | 16 +- .../single_layer_tests/ctc_greedy_decoder.cpp | 2 +- .../ctc_greedy_decoder_seq_len.cpp | 4 +- .../single_layer_tests/cum_sum.cpp | 4 +- .../single_layer_tests/depth_to_space.cpp | 4 +- .../single_layer_tests/detection_output.cpp | 4 +- .../single_layer_tests/eltwise.cpp | 2 +- .../embedding_bag_offsets_sum.cpp | 2 +- .../embedding_bag_packed_sum.cpp | 2 +- .../embedding_segments_sum.cpp | 2 +- .../extract_image_patches.cpp | 2 +- .../single_layer_tests/fake_quantize.cpp | 2 +- .../single_layer_tests/gather.cpp | 28 +- .../single_layer_tests/gather_nd.cpp | 6 +- .../single_layer_tests/gather_tree.cpp | 2 +- .../single_layer_tests/grn.cpp | 2 +- .../single_layer_tests/group_convolution.cpp | 8 +- .../group_convolution_backprop_data.cpp | 8 +- .../single_layer_tests/gru_cell.cpp | 2 +- .../single_layer_tests/gru_sequence.cpp | 4 +- .../single_layer_tests/interpolate.cpp | 4 +- .../single_layer_tests/log_softmax.cpp | 4 +- .../single_layer_tests/logical.cpp | 4 +- .../single_layer_tests/lrn.cpp | 2 +- .../single_layer_tests/lstm_cell.cpp | 4 +- .../single_layer_tests/lstm_sequence.cpp | 6 +- .../single_layer_tests/mat_mul.cpp | 2 +- .../single_layer_tests/minimum_maximum.cpp | 2 +- .../single_layer_tests/mvn.cpp | 18 +- .../non_max_suppression.cpp | 2 +- .../single_layer_tests/normalize_l2.cpp | 2 +- .../single_layer_tests/pad.cpp | 8 +- .../single_layer_tests/pooling.cpp | 10 +- .../single_layer_tests/power.cpp | 2 +- .../prior_box_clustered.cpp | 2 +- .../single_layer_tests/proposal.cpp | 2 +- .../single_layer_tests/reduce_ops.cpp | 16 +- .../single_layer_tests/region_yolo.cpp | 6 +- .../single_layer_tests/reorg_yolo.cpp | 12 +- .../single_layer_tests/reshape.cpp | 6 +- .../single_layer_tests/reverse_sequence.cpp | 2 +- .../single_layer_tests/rnn_cell.cpp | 2 +- .../single_layer_tests/rnn_sequence.cpp | 4 +- .../scatter_elements_update.cpp | 2 +- .../single_layer_tests/scatter_nd_update.cpp | 2 +- .../single_layer_tests/scatter_update.cpp | 2 +- .../single_layer_tests/select.cpp | 4 +- .../single_layer_tests/shuffle_channels.cpp | 8 +- .../single_layer_tests/softmax.cpp | 4 +- .../single_layer_tests/space_to_batch.cpp | 2 +- .../single_layer_tests/space_to_depth.cpp | 4 +- .../single_layer_tests/split.cpp | 4 +- .../single_layer_tests/squeeze_unsqueeze.cpp | 4 +- .../single_layer_tests/strided_slice.cpp | 4 +- .../single_layer_tests/tile.cpp | 4 +- .../single_layer_tests/topk.cpp | 2 +- .../single_layer_tests/transpose.cpp | 6 +- .../single_layer_tests/variadic_split.cpp | 2 +- .../subgraph_tests/constant_result.cpp | 2 +- .../get_output_before_activation.cpp | 2 +- .../subgraph_tests/matmul_squeeze_add.cpp | 2 +- .../subgraph_tests/multiply_add.cpp | 2 +- .../subgraph_tests/parameter_result.cpp | 2 +- .../subgraph_tests/perm_conv_perm_concat.cpp | 2 +- .../quantized_convolution_backprop_data.cpp | 4 +- ...ntized_group_convolution_backprop_data.cpp | 4 +- .../subgraph_tests/reduce_eltwise.cpp | 6 +- ...shape_permute_conv_permute_reshape_act.cpp | 2 +- .../reshape_squeeze_reshape_relu.cpp | 2 +- .../subgraph_tests/scale_shift.cpp | 2 +- .../subgraph_tests/split_conv_concat.cpp | 2 +- .../subgraph_tests/tensor_names.cpp | 2 +- .../single_layer_tests/tensor_iterator.cpp | 2 +- .../operations/dynamic_shape_resolver.cpp | 12 +- .../operations/out_shape_of_reshape.cpp | 10 +- .../operations/static_shape_broadcast.cpp | 14 +- .../operations/static_shape_nonzero.cpp | 8 +- ...xtract_image_patches_to_reorg_yolo_vpu.cpp | 10 +- ...mic_to_static_shape_binary_elementwise.cpp | 2 +- .../dynamic_to_static_shape_broadcast.cpp | 4 +- .../dynamic_to_static_shape_clamp.cpp | 2 +- .../dynamic_to_static_shape_concat.cpp | 2 +- .../dynamic_to_static_shape_convert.cpp | 2 +- .../dynamic_to_static_shape_gather.cpp | 6 +- ...ynamic_to_static_shape_gather_elements.cpp | 2 +- .../dynamic_to_static_shape_gather_nd.cpp | 2 +- .../dynamic_to_static_shape_matmul.cpp | 2 +- ...ic_to_static_shape_non_max_suppression.cpp | 2 +- .../dynamic_to_static_shape_nonzero.cpp | 2 +- .../dynamic_to_static_shape_reduce.cpp | 4 +- .../dynamic_to_static_shape_reshape.cpp | 2 +- .../dynamic_to_static_shape_roialign.cpp | 6 +- .../dynamic_to_static_shape_scatter.cpp | 2 +- .../dynamic_to_static_shape_split.cpp | 2 +- .../dynamic_to_static_shape_squeeze.cpp | 2 +- .../dynamic_to_static_shape_topk.cpp | 4 +- .../dynamic_to_static_shape_transpose.cpp | 2 +- ...amic_to_static_shape_unary_elementwise.cpp | 2 +- .../dynamic_to_static_shape_unsqueeze.cpp | 2 +- ...dynamic_to_static_shape_variadic_split.cpp | 2 +- .../eliminate_shapeof_after_dsr.cpp | 6 +- .../behavior/caching_tests.cpp | 4 +- .../behavior/config.cpp | 26 +- .../behavior/core_integration.cpp | 42 +- .../behavior/core_threading_tests.cpp | 4 +- .../behavior/cpp_holders.cpp | 6 +- .../behavior/detect_network_batch_test.cpp | 2 +- .../behavior/exec_graph_info.cpp | 2 +- .../behavior/infer_request.cpp | 4 +- .../behavior/infer_request_callback.cpp | 4 +- .../behavior/infer_request_config.cpp | 8 +- .../behavior/infer_request_input.cpp | 4 +- .../behavior/infer_request_output.cpp | 4 +- .../behavior/layout.cpp | 2 +- .../behavior/query_network.cpp | 2 +- .../behavior/set_preprocess.cpp | 8 +- .../behavior/stress_tests.cpp | 2 +- .../behavior/test_plugin.cpp | 12 +- .../behavior/version.cpp | 6 +- .../import_export_tests/import_nonzero.cpp | 2 +- .../myriad_remote_blobs_tests.cpp | 2 +- .../single_layer_tests/activation.cpp | 2 +- .../single_layer_tests/comparison.cpp | 4 +- .../single_layer_tests/concat.cpp | 2 +- .../single_layer_tests/convolution.cpp | 6 +- .../ctc_greedy_decoder_seq_len.cpp | 2 +- .../single_layer_tests/eltwise.cpp | 4 +- .../single_layer_tests/gather_elements.cpp | 4 +- .../single_layer_tests/gather_nd.cpp | 2 +- .../single_layer_tests/interpolate.cpp | 14 +- .../single_layer_tests/logical.cpp | 4 +- .../single_layer_tests/mat_mul.cpp | 2 +- .../single_layer_tests/minimum_maximum.cpp | 2 +- .../single_layer_tests/mvn.cpp | 4 +- .../single_layer_tests/nonzero.cpp | 2 +- .../single_layer_tests/pad.cpp | 8 +- .../single_layer_tests/pooling.cpp | 12 +- .../single_layer_tests/proposal.cpp | 2 +- .../single_layer_tests/roi_pooling.cpp | 4 +- .../single_layer_tests/split.cpp | 4 +- .../single_layer_tests/strided_slice.cpp | 2 +- .../single_layer_tests/topk.cpp | 4 +- .../subgraph_tests/constant_result.cpp | 2 +- .../reshape_squeeze_reshape_relu.cpp | 2 +- .../subgraph_tests/split_conv_concat.cpp | 2 +- .../subgraph_tests/tensor_names.cpp | 2 +- .../myriad/single_layer_tests/gather.cpp | 2 +- .../out_shape_of_reshape.cpp | 2 +- .../static_shape_broadcast.cpp | 2 +- .../single_layer_tests/static_shape_nms.cpp | 8 +- .../static_shape_nonzero.cpp | 2 +- .../subgraph_tests/concat_split_transpose.cpp | 2 +- .../subgraph_tests/dsr_binary_elementwise.cpp | 12 +- .../myriad/subgraph_tests/dsr_clamp.cpp | 2 +- .../myriad/subgraph_tests/dsr_concat.cpp | 2 +- .../myriad/subgraph_tests/dsr_convert.cpp | 2 +- .../myriad/subgraph_tests/dsr_gather.cpp | 6 +- .../subgraph_tests/dsr_gather_elements.cpp | 2 +- .../myriad/subgraph_tests/dsr_gather_nd.cpp | 6 +- .../myriad/subgraph_tests/dsr_matmul.cpp | 2 +- .../dsr_non_max_suppression.cpp | 2 +- .../myriad/subgraph_tests/dsr_reduce.cpp | 4 +- .../myriad/subgraph_tests/dsr_reshape.cpp | 4 +- .../myriad/subgraph_tests/dsr_roialign.cpp | 6 +- .../myriad/subgraph_tests/dsr_scatter.cpp | 2 +- .../myriad/subgraph_tests/dsr_split.cpp | 2 +- .../myriad/subgraph_tests/dsr_squeeze.cpp | 2 +- .../subgraph_tests/dsr_strided_slice.cpp | 2 +- .../plugin/myriad/subgraph_tests/dsr_topk.cpp | 4 +- .../subgraph_tests/dsr_unary_elementwise.cpp | 2 +- .../myriad/subgraph_tests/dsr_unsqueeze.cpp | 2 +- .../subgraph_tests/dsr_variadic_split.cpp | 2 +- .../subgraph_tests/gather_gather_elements.cpp | 2 +- .../myriad/subgraph_tests/nms_nonzero.cpp | 2 +- .../subgraph_tests/nonzero_broadcast.cpp | 2 +- .../subgraph_tests/nonzero_transpose.cpp | 2 +- .../subgraph_tests/parameter_result.cpp | 2 +- .../parameter_shapeof_result.cpp | 2 +- .../subgraph_tests/topk_k_propagation.cpp | 12 +- .../subgraph_tests/unsqueeze_gather.cpp | 2 +- .../shared/src/behavior/caching_tests.cpp | 10 +- .../single_layer/non_max_suppression.hpp | 10 + .../tests/ie_test_utils/CMakeLists.txt | 4 +- .../common_test_utils/CMakeLists.txt | 62 +- .../common_test_utils/common_utils.cpp | 5 + .../common_test_utils/common_utils.hpp | 5 + .../ie_test_utils/common_test_utils/gtest | 1 - .../ie_test_utils/unit_test_utils/mock.cpp | 1 + .../cpp_interfaces/interface/mock_icore.hpp | 14 +- .../interface/mock_iinference_plugin.hpp | 20 +- .../unit_test_utils/mocks/mock_allocator.hpp | 8 +- .../mocks/mock_icnn_network.hpp | 40 +- .../mocks/mock_iexecutable_network.hpp | 24 +- .../mocks/mock_iinfer_request.hpp | 30 +- .../mocks/mock_not_empty_icnn_network.hpp | 17 +- .../unit/cpu/mkldnn_memory_desc_test.cpp | 10 +- .../tests/unit/cpu/mkldnn_memory_test.cpp | 4 +- .../ie_infer_async_request_base_test.cpp | 3 +- .../ie_memory_state_internal_test.cpp | 9 +- .../tests/unit/vpu/blob_reader_tests.cpp | 6 +- .../passes_tests/annotate_memory_types.cpp | 2 +- .../vpu/myriad_tests/aot_behavior_tests.cpp | 2 +- .../vpu/myriad_tests/vpu_boot_tests.cpp | 2 +- .../vpu/myriad_tests/vpu_protocol_tests.cpp | 2 +- .../vpu/myriad_tests/vpu_watchdog_tests.cpp | 2 +- .../fluid_preproc/cpu/fluid_tests_cpu.cpp | 70 +- .../backward_compatibility.cpp | 2 +- .../input_tests/parser_tests.cpp | 2 +- .../io_blob_tests/cropResize_tests.hpp | 4 +- .../shared_tests/io_blob_tests/dims_tests.hpp | 4 +- .../io_blob_tests/layout_tests.hpp | 6 +- .../functional/shared_tests/lstm/plg_test.hpp | 4 +- .../shared_tests/lstm/rnn_seq_test.hpp | 2 +- .../layers/myriad_layers_CTCDecoder_test.cpp | 2 +- ...myriad_layers_batch_normalization_test.cpp | 2 +- .../common/layers/myriad_layers_bias_test.cpp | 2 +- .../common/layers/myriad_layers_blob_test.cpp | 6 +- .../layers/myriad_layers_clamp_test.cpp | 2 +- .../layers/myriad_layers_concat_test.cpp | 2 +- .../layers/myriad_layers_conv_nd_test.cpp | 30 +- .../layers/myriad_layers_convert_test.cpp | 6 +- .../layers/myriad_layers_convolution1x1.cpp | 2 +- .../layers/myriad_layers_convolution3x3.cpp | 2 +- .../layers/myriad_layers_convolution_test.cpp | 102 +- .../common/layers/myriad_layers_copy_test.cpp | 2 +- .../common/layers/myriad_layers_crop_test.cpp | 6 +- .../layers/myriad_layers_custom_test.cpp | 14 +- .../myriad_layers_deconvolution_test.cpp | 14 +- .../layers/myriad_layers_eltwise_test.cpp | 48 +- .../common/layers/myriad_layers_elu_test.cpp | 2 +- .../common/layers/myriad_layers_erf_test.cpp | 2 +- ...myriad_layers_exp_detectionoutput_test.cpp | 2 +- .../myriad_layers_exp_generateproposals.cpp | 2 +- ...iad_layers_exp_priorgridgenerator_test.cpp | 6 +- .../common/layers/myriad_layers_exp_test.cpp | 2 +- .../myriad_layers_exp_topkrois_test.cpp | 2 +- .../layers/myriad_layers_flatten_test.cpp | 2 +- .../layers/myriad_layers_floor_test.cpp | 2 +- .../myriad_layers_fully_connected_tests.cpp | 6 +- .../common/layers/myriad_layers_gemm_test.cpp | 2 +- .../common/layers/myriad_layers_grn_test.cpp | 2 +- .../layers/myriad_layers_interp_test.cpp | 2 +- .../common/layers/myriad_layers_log_test.cpp | 2 +- .../common/layers/myriad_layers_lrn_test.cpp | 2 +- .../common/layers/myriad_layers_lstm_cell.cpp | 4 +- .../common/layers/myriad_layers_mvn_test.cpp | 2 +- .../layers/myriad_layers_nonzero_test.cpp | 2 +- .../layers/myriad_layers_normalize_test.cpp | 4 +- .../layers/myriad_layers_oneHot_test.cpp | 4 +- .../common/layers/myriad_layers_pad_test.cpp | 2 +- .../layers/myriad_layers_permute_nd_test.cpp | 14 +- .../layers/myriad_layers_permute_test.cpp | 4 +- .../layers/myriad_layers_pool_nd_test.cpp | 44 +- .../layers/myriad_layers_pooling_test.cpp | 48 +- .../layers/myriad_layers_power_test.cpp | 2 +- .../layers/myriad_layers_prelu_test.cpp | 16 +- .../myriad_layers_psroipooling_test.cpp | 2 +- .../myriad_layers_psroipooling_test.hpp | 2 +- .../layers/myriad_layers_reduce_test.cpp | 10 +- .../layers/myriad_layers_region_test.cpp | 4 +- .../common/layers/myriad_layers_relu_test.cpp | 16 +- .../layers/myriad_layers_reorg_test.cpp | 4 +- .../layers/myriad_layers_resample_test.cpp | 4 +- .../layers/myriad_layers_reshape_test.cpp | 8 +- .../myriad_layers_reverse_sequence_test.cpp | 2 +- .../layers/myriad_layers_roi_align_test.cpp | 8 +- ...riad_layers_roi_feature_extractor_test.cpp | 4 +- .../layers/myriad_layers_roi_pooling_test.cpp | 4 +- .../layers/myriad_layers_scale_test.cpp | 2 +- ...ad_layers_scatter_elements_update_test.cpp | 4 +- .../myriad_layers_scatter_update_test.cpp | 4 +- .../layers/myriad_layers_select_test.cpp | 2 +- .../layers/myriad_layers_sigmoid_test.cpp | 10 +- .../layers/myriad_layers_slice_test.cpp | 2 +- .../layers/myriad_layers_softmax_test.cpp | 2 +- .../layers/myriad_layers_split_test.cpp | 2 +- .../layers/myriad_layers_squeeze_test.cpp | 10 +- .../myriad_layers_strided_slice_test.cpp | 2 +- .../common/layers/myriad_layers_tanh_test.cpp | 10 +- .../common/layers/myriad_layers_tile_test.cpp | 4 +- .../common/layers/myriad_layers_topk_test.cpp | 2 +- .../layers/myriad_layers_unsqueeze_test.cpp | 2 +- .../vpu/common/myriad_get_output_tests.cpp | 2 +- .../vpu/common/myriad_hw_conv_tests.hpp | 130 +- .../vpu/common/myriad_hw_extra_tests.hpp | 20 +- .../vpu/common/myriad_hw_fc_tests.hpp | 28 +- .../vpu/common/myriad_hw_network_tests.hpp | 4 +- .../vpu/common/myriad_hw_pool_tests.hpp | 60 +- .../vpu/common/myriad_merge_permute_tests.cpp | 6 +- .../regression/helpers/vpu_case_common.hpp | 8 +- .../merge_permute_and_reorder_test.cpp | 4 +- .../vpu/myriad_tests/myriad_configs_tests.cpp | 8 +- .../myriad_multiple_graph_tests.cpp | 2 +- .../myriad_streams_configuration_tests.cpp | 2 +- .../single_layer_tests.cpp | 6 +- .../input_tests/parser_tests.cpp | 2 +- .../vpu/vpu_base/vpu_tests_config.hpp | 4 +- .../helpers/tests_vpu_common.hpp | 2 +- .../engines/gna/fp32_non_quantized_tests.cpp | 2 +- .../engines/gna/gna_input_precision_test.cpp | 2 +- .../unit/engines/gna/gna_matcher.cpp | 2 +- .../unit/engines/gna/gna_proc_type_test.cpp | 2 +- .../engines/gna/layers/activation_test.cpp | 2 +- .../gna/layers/gna_align_filter2_tests.cpp | 2 +- .../engines/gna/layers/gna_conv1d_test.cpp | 2 +- .../engines/gna/layers/gna_eltwise_test.cpp | 2 +- .../layers/gna_multi_input_to_concat_test.cpp | 2 +- .../engines/gna/layers/gna_permute_test.cpp | 2 +- .../gna/layers/gna_split_to_concat_test.cpp | 2 +- .../engines/gna/layers/gna_squeeze_test.cpp | 4 +- .../unit/engines/vpu/merge_parallel_fc.cpp | 4 +- .../vpu/mvnc/pthread_semaphore_tests.cpp | 2 +- .../unit/engines/vpu/mvnc/watchdog_tests.cpp | 8 +- .../engines/vpu/mvnc/xlink_device_tests.cpp | 2 +- .../myriad_tests/helpers/myriad_mvnc_stub.h | 4 +- .../vpu/myriad_tests/myriad_engine_tests.cpp | 18 +- .../vpu/myriad_tests/myriad_metrics_tests.cpp | 6 +- .../unit/graph_tools/graph_copy_tests.cpp | 4 +- .../unit/graph_tools/graph_tools_test.cpp | 4 +- .../get_num_iterations_test.cpp | 18 +- .../thirdparty/clDNN/CMakeLists.txt | 3 - .../clDNN/common/googletest-fused/License.txt | 28 - .../googletest-fused/gmock-gtest-all.cc | 13278 ---------- .../common/googletest-fused/gmock/gmock.h | 16697 ------------ .../common/googletest-fused/gtest/gtest.h | 21575 ---------------- .../clDNN/common/googletest-fused/version.txt | 4 - .../thirdparty/clDNN/tests/CMakeLists.txt | 18 +- .../module_tests/test_uqr_distribution.cpp | 2 +- .../tests/module_tests/usm_memory_test.cpp | 12 +- .../binary_convolution_gpu_test.cpp | 4 +- .../clDNN/tests/test_cases/cache_test.cpp | 2 +- .../test_cases/concatenation_gpu_test.cpp | 10 +- .../tests/test_cases/convolution_gpu_test.cpp | 24 +- .../clDNN/tests/test_cases/crop_gpu_test.cpp | 4 +- .../tests/test_cases/cum_sum_gpu_test.cpp | 24 +- .../test_cases/deconvolution_gpu_test.cpp | 6 +- .../test_cases/depth_concatenate_gpu_test.cpp | 2 +- .../test_cases/detection_output_test.cpp | 2 +- .../tests/test_cases/eltwise_gpu_test.cpp | 24 +- .../test_cases/fully_connected_gpu_test.cpp | 52 +- .../tests/test_cases/fusings_gpu_test.cpp | 544 +- .../clDNN/tests/test_cases/gemm_gpu_test.cpp | 60 +- .../test_cases/lstm_dynamic_gpu_test.cpp | 4 +- .../clDNN/tests/test_cases/mvn_gpu_test.cpp | 12 +- .../test_cases/non_max_suppression_test.cpp | 2 +- .../tests/test_cases/permute_gpu_test.cpp | 8 +- .../tests/test_cases/pooling_gpu_test.cpp | 10 +- .../test_cases/pyramid_roi_align_gpu_test.cpp | 2 +- .../tests/test_cases/reduce_gpu_test.cpp | 14 +- .../tests/test_cases/reorder_gpu_test.cpp | 2 +- .../tests/test_cases/resample_gpu_test.cpp | 12 +- .../tests/test_cases/softmax_gpu_test.cpp | 2 +- .../clDNN/tests/test_cases/topology_test.cpp | 2 +- .../clDNN/tests/test_utils/network_test.h | 2 +- .../movidius/mvnc/tests/mvnc_stress_tests.cpp | 2 +- .../movidius/mvnc/tests/mvnc_tests_common.cpp | 8 +- .../movidius/mvnc/tests/mvnc_tests_usb.cpp | 2 +- .../tests/XLink/XLink_common_tests.cpp | 16 +- tests/stress_tests/memcheck_tests/tests.cpp | 2 +- tests/stress_tests/memleaks_tests/tests.cpp | 6 +- tests/stress_tests/unittests/tests.cpp | 6 +- thirdparty/CMakeLists.txt | 56 +- thirdparty/gtest | 1 + 992 files changed, 2921 insertions(+), 54490 deletions(-) delete mode 160000 inference-engine/tests/ie_test_utils/common_test_utils/gtest delete mode 100644 inference-engine/thirdparty/clDNN/common/googletest-fused/License.txt delete mode 100644 inference-engine/thirdparty/clDNN/common/googletest-fused/gmock-gtest-all.cc delete mode 100644 inference-engine/thirdparty/clDNN/common/googletest-fused/gmock/gmock.h delete mode 100644 inference-engine/thirdparty/clDNN/common/googletest-fused/gtest/gtest.h delete mode 100644 inference-engine/thirdparty/clDNN/common/googletest-fused/version.txt create mode 160000 thirdparty/gtest diff --git a/.gitmodules b/.gitmodules index dad6d39352d7b0..586502884302ac 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,10 +6,6 @@ path = inference-engine/thirdparty/mkl-dnn url = https://github.com/openvinotoolkit/oneDNN.git ignore = dirty -[submodule "inference-engine/tests/ie_test_utils/common_test_utils/gtest"] - path = inference-engine/tests/ie_test_utils/common_test_utils/gtest - url = https://github.com/openvinotoolkit/googletest.git - ignore = dirty [submodule "inference-engine/samples/thirdparty/gflags"] path = inference-engine/samples/thirdparty/gflags url = https://github.com/gflags/gflags.git @@ -22,3 +18,7 @@ path = thirdparty/zlib/zlib url = https://github.com/madler/zlib.git ignore = dirty +[submodule "thirdparty/gtest"] + path = thirdparty/gtest + url = https://github.com/openvinotoolkit/googletest.git + ignore = dirty diff --git a/docs/IE_PLUGIN_DG/PluginTesting.md b/docs/IE_PLUGIN_DG/PluginTesting.md index 0aae6280601ca1..e2aabeff32e497 100644 --- a/docs/IE_PLUGIN_DG/PluginTesting.md +++ b/docs/IE_PLUGIN_DG/PluginTesting.md @@ -21,7 +21,7 @@ Engine concepts: plugin creation, multiple executable networks support, multiple @snippet single_layer_tests/convolution.cpp test_convolution:declare_parameters - - Instantiate the test itself using standard GoogleTest macro `INSTANTIATE_TEST_CASE_P`: + - Instantiate the test itself using standard GoogleTest macro `INSTANTIATE_TEST_SUITE_P`: @snippet single_layer_tests/convolution.cpp test_convolution:instantiate diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/caching_tests.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/caching_tests.cpp index f61e4c54d7ec81..a698d72e52610d 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/caching_tests.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/caching_tests.cpp @@ -15,7 +15,7 @@ namespace { 1, 2 }; - INSTANTIATE_TEST_CASE_P(smoke_CachingSupportCase_Template, LoadNetworkCacheTestBase, + INSTANTIATE_TEST_SUITE_P(smoke_CachingSupportCase_Template, LoadNetworkCacheTestBase, ::testing::Combine( ::testing::ValuesIn(LoadNetworkCacheTestBase::getStandardFunctions()), ::testing::ValuesIn(precisionsTemplate), diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/config.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/config.cpp index fad461c814da58..34e0eb46eace0c 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/config.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/config.cpp @@ -24,14 +24,14 @@ const std::vector> inconfigs = { {{TEMPLATE_CONFIG_KEY(THROUGHPUT_STREAMS), CONFIG_VALUE(NO)}}, }; -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigTests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, IncorrectConfigTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), ::testing::ValuesIn(inconfigs)), IncorrectConfigTests::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigAPITests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, IncorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), @@ -39,14 +39,14 @@ INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigAPITests, IncorrectConfigAPITests::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectConfigAPITests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, CorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), ::testing::ValuesIn(configs)), CorrectConfigAPITests::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, CorrectConfigTests, +INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, CorrectConfigTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/core_integration.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/core_integration.cpp index 2b669a6520a376..2c067aaf7b68ab 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/core_integration.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/core_integration.cpp @@ -16,11 +16,11 @@ namespace { // IE Class Common tests with // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassBasicTestP, IEClassBasicTestP, ::testing::Values(std::make_pair("templatePlugin", CommonTestUtils::DEVICE_TEMPLATE))); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassNetworkTestP, IEClassNetworkTestP, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE)); @@ -28,39 +28,39 @@ INSTANTIATE_TEST_CASE_P( // IE Class GetMetric // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassGetMetricTest, IEClassGetMetricTest_SUPPORTED_CONFIG_KEYS, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassGetMetricTest, IEClassGetMetricTest_SUPPORTED_METRICS, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassGetMetricTest, IEClassGetMetricTest_AVAILABLE_DEVICES, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassGetMetricTest, IEClassGetMetricTest_FULL_DEVICE_NAME, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassGetMetricTest, IEClassGetMetricTest_OPTIMIZATION_CAPABILITIES, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassGetMetricTest, IEClassGetMetricTest_RANGE_FOR_ASYNC_INFER_REQUESTS, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassGetMetricTest, IEClassGetMetricTest_ThrowUnsupported, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassGetConfigTest, IEClassGetConfigTest_ThrowUnsupported, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassGetAvailableDevices, IEClassGetAvailableDevices, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE)); @@ -111,7 +111,7 @@ TEST_F(IEClassSetConfigTestHETERO, smoke_SetConfigNoThrow) { // IE Class GetConfig // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassGetConfigTest, IEClassGetConfigTest, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE)); @@ -143,46 +143,46 @@ TEST_F(IEClassGetConfigTestTEMPLATE, smoke_GetConfigNoThrow) { // Executable Network GetMetric // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassExecutableNetworkGetMetricTest, IEClassExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE, "MULTI:TEMPLATE", "HETERO:TEMPLATE")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassExecutableNetworkGetMetricTest, IEClassExecutableNetworkGetMetricTest_SUPPORTED_METRICS, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE, "MULTI:TEMPLATE", "HETERO:TEMPLATE")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassExecutableNetworkGetMetricTest, IEClassExecutableNetworkGetMetricTest_NETWORK_NAME, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE, "MULTI:TEMPLATE", "HETERO:TEMPLATE")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassExecutableNetworkGetMetricTest, IEClassExecutableNetworkGetMetricTest_OPTIMAL_NUMBER_OF_INFER_REQUESTS, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE, "MULTI:TEMPLATE", "HETERO:TEMPLATE")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassExecutableNetworkGetMetricTest_ThrowsUnsupported, IEClassExecutableNetworkGetMetricTest, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE, "MULTI:TEMPLATE", "HETERO:TEMPLATE")); // // Executable Network GetConfig / SetConfig // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassExecutableNetworkGetConfigTest, IEClassExecutableNetworkGetConfigTest, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassExecutableNetworkSetConfigTest, IEClassExecutableNetworkSetConfigTest, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE)); // IE Class Query network -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassQueryNetworkTest, IEClassQueryNetworkTest, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE)); // IE Class Load network -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassLoadNetworkTest, IEClassLoadNetworkTest, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE)); @@ -192,19 +192,19 @@ INSTANTIATE_TEST_CASE_P( #ifdef ENABLE_MKL_DNN -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassHeteroExecutableNetworlGetMetricTest, IEClassHeteroExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassHeteroExecutableNetworlGetMetricTest, IEClassHeteroExecutableNetworkGetMetricTest_SUPPORTED_METRICS, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassHeteroExecutableNetworlGetMetricTest, IEClassHeteroExecutableNetworkGetMetricTest_NETWORK_NAME, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassHeteroExecutableNetworlGetMetricTest, IEClassHeteroExecutableNetworkGetMetricTest_TARGET_FALLBACK, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE)); diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/cpp_holders.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/cpp_holders.cpp index 8a2ee657b7917a..7c372c708ad3bb 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/cpp_holders.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/cpp_holders.cpp @@ -20,19 +20,19 @@ const std::vector> orders = { {2, 1, 0} }; -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, HoldersTest, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, HoldersTest, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), ::testing::ValuesIn(orders)), HoldersTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, HoldersTestImportNetwork, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, HoldersTestImportNetwork, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE, "HETERO:TEMPLATE"), ::testing::ValuesIn(orders)), HoldersTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, HoldersTestOnImportedNetwork, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, HoldersTestOnImportedNetwork, ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE, "HETERO:TEMPLATE"), HoldersTestOnImportedNetwork::getTestCaseName); diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/exec_graph_info.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/exec_graph_info.cpp index a0aa412fb0d6e9..597e029fc5be53 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/exec_graph_info.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/exec_graph_info.cpp @@ -19,7 +19,7 @@ const std::vector> configs = { {} }; -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, ExecGraphTests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, ExecGraphTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/infer_request.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/infer_request.cpp index 2b39ef540057b0..edb803a614f689 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/infer_request.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/infer_request.cpp @@ -19,7 +19,7 @@ const std::vector> configs = { {} }; -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferRequestTests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferRequestTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/infer_request_callback.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/infer_request_callback.cpp index 8fd635ae8bf481..3bc9d1f6f02d3f 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/infer_request_callback.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/infer_request_callback.cpp @@ -19,7 +19,7 @@ const std::vector> configs = { {} }; -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CallbackTests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, CallbackTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/infer_request_config.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/infer_request_config.cpp index 3ee70738e5a0d5..a6ffbe80bbcec9 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/infer_request_config.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/infer_request_config.cpp @@ -19,7 +19,7 @@ const std::vector> configs = { {} }; -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferConfigTests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferConfigTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/infer_request_input.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/infer_request_input.cpp index dde2fa6d2cd3f2..23d5cb7136faf4 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/infer_request_input.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/infer_request_input.cpp @@ -17,7 +17,7 @@ const std::vector> configs = { {} }; -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferRequestInputTests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferRequestInputTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/infer_request_output.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/infer_request_output.cpp index 9c8a24413fa647..eae52cec60c14e 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/infer_request_output.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/infer_request_output.cpp @@ -17,7 +17,7 @@ const std::vector> configs = { {} }; -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferRequestOutputTests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferRequestOutputTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/layout.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/layout.cpp index c5770ede2a0956..f4d8091b20e088 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/layout.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/layout.cpp @@ -26,7 +26,7 @@ const std::vector> inputShapes = { { 3 } }; -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, LayoutTest, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, LayoutTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/preprocessing.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/preprocessing.cpp index 29651f6da34f92..4aa9439b1ad891 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/preprocessing.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/preprocessing.cpp @@ -17,7 +17,7 @@ const std::vector> configs = { {} }; -INSTANTIATE_TEST_CASE_P(smoke_PreprocessingPrecisionConvertTestsViaSetInput, PreprocessingPrecisionConvertTest, +INSTANTIATE_TEST_SUITE_P(smoke_PreprocessingPrecisionConvertTestsViaSetInput, PreprocessingPrecisionConvertTest, ::testing::Combine( ::testing::ValuesIn(inputPrecisions), ::testing::Values(4), // Number of input tensor channels @@ -26,7 +26,7 @@ INSTANTIATE_TEST_CASE_P(smoke_PreprocessingPrecisionConvertTestsViaSetInput, Pre ::testing::ValuesIn(configs)), PreprocessingPrecisionConvertTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_PreprocessingPrecisionConvertTestsViaGetBlob, PreprocessingPrecisionConvertTest, +INSTANTIATE_TEST_SUITE_P(smoke_PreprocessingPrecisionConvertTestsViaGetBlob, PreprocessingPrecisionConvertTest, ::testing::Combine( ::testing::ValuesIn(inputPrecisions), ::testing::Values(4), // Number of input tensor channels (blob_copy only supports 4d and 5d tensors) diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/set_preprocess.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/set_preprocess.cpp index a33bcd7638cc8a..19841bb64da643 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/set_preprocess.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/set_preprocess.cpp @@ -26,21 +26,21 @@ const std::vector> heteroConfigs = { {{ "TARGET_FALLBACK", CommonTestUtils::DEVICE_TEMPLATE }} }; -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, PreprocessTest, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, PreprocessTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), ::testing::ValuesIn(configs)), PreprocessTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, PreprocessTest, +INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, PreprocessTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(multiConfigs)), PreprocessTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Hetero_BehaviorTests, PreprocessTest, +INSTANTIATE_TEST_SUITE_P(smoke_Hetero_BehaviorTests, PreprocessTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_HETERO), @@ -61,7 +61,7 @@ const std::vector ioLayouts = { InferenceEngine::Layout::NHWC }; -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, PreprocessConversionTest, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, PreprocessConversionTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(ioPrecisions), @@ -75,7 +75,7 @@ INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, PreprocessConversionTest, ::testing::ValuesIn(configs)), PreprocessConversionTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, PreprocessDynamicallyInSetBlobTest, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, PreprocessDynamicallyInSetBlobTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Bool(), diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/test_plugin.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/test_plugin.cpp index 8d65895bc36b04..b8d5e9bc9bdb5a 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/test_plugin.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/test_plugin.cpp @@ -17,21 +17,21 @@ const std::vector> configs = { {} }; -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, BehaviorTests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, BehaviorTests, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), ::testing::ValuesIn(configs)), BehaviorTests::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, BehaviorTestInput, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, BehaviorTestInput, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), ::testing::ValuesIn(configs)), BehaviorTestInput::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, BehaviorTestOutput, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, BehaviorTestOutput, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/version.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/version.cpp index 818a627a51973a..8b22d2eb24094e 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/version.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/version.cpp @@ -12,7 +12,7 @@ const std::vector> configs = { {} }; -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, VersionTest, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, VersionTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/hetero/query_network.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/hetero/query_network.cpp index b369e55adf225e..64b88ea714f88f 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/hetero/query_network.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/hetero/query_network.cpp @@ -13,7 +13,7 @@ using namespace HeteroTests; auto ConvBias = ngraph::builder::subgraph::makeConvBias(); -INSTANTIATE_TEST_CASE_P(smoke_FullySupportedTopologies, QueryNetworkTest, +INSTANTIATE_TEST_SUITE_P(smoke_FullySupportedTopologies, QueryNetworkTest, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE, "HETERO:TEMPLATE", "MULTI:TEMPLATE"), ::testing::Values(ConvBias)), diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/hetero/synthetic.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/hetero/synthetic.cpp index 15f940780ddb64..164d959e408c08 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/hetero/synthetic.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/hetero/synthetic.cpp @@ -11,13 +11,13 @@ namespace { using namespace HeteroTests; -INSTANTIATE_TEST_CASE_P(smoke_SingleMajorNode, HeteroSyntheticTest, +INSTANTIATE_TEST_SUITE_P(smoke_SingleMajorNode, HeteroSyntheticTest, ::testing::Combine( ::testing::Values(std::vector{{"TEMPLATE0", "templatePlugin"}, {"TEMPLATE1", "templatePlugin"}}), ::testing::ValuesIn(HeteroTests::HeteroSyntheticTest::_singleMajorNodeFunctions)), HeteroSyntheticTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(nightly_RandomMajorNodes, HeteroSyntheticTest, +INSTANTIATE_TEST_SUITE_P(nightly_RandomMajorNodes, HeteroSyntheticTest, ::testing::Combine( ::testing::Values(std::vector{{"TEMPLATE0", "templatePlugin"}, {"TEMPLATE1", "templatePlugin"}}), ::testing::ValuesIn(HeteroTests::HeteroSyntheticTest::_randomMajorNodeFunctions)), diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/convolution.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/convolution.cpp index 3f6d9c494066c7..c099cb3d5d4ffc 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/convolution.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/convolution.cpp @@ -57,7 +57,7 @@ const auto conv2DParams_AutoPadValid = ::testing::Combine( ); // ! [test_convolution:instantiate] -INSTANTIATE_TEST_CASE_P(Convolution2D_ExplicitPadding, ConvolutionLayerTest, +INSTANTIATE_TEST_SUITE_P(Convolution2D_ExplicitPadding, ConvolutionLayerTest, ::testing::Combine( conv2DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -70,7 +70,7 @@ INSTANTIATE_TEST_CASE_P(Convolution2D_ExplicitPadding, ConvolutionLayerTest, ConvolutionLayerTest::getTestCaseName); // ! [test_convolution:instantiate] -INSTANTIATE_TEST_CASE_P(Convolution2D_AutoPadValid, ConvolutionLayerTest, +INSTANTIATE_TEST_SUITE_P(Convolution2D_AutoPadValid, ConvolutionLayerTest, ::testing::Combine( conv2DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), @@ -113,7 +113,7 @@ const auto conv3DParams_AutoPadValid = ::testing::Combine( ::testing::Values(ngraph::op::PadType::VALID) ); -INSTANTIATE_TEST_CASE_P(smoke_Convolution3D_ExplicitPadding, ConvolutionLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Convolution3D_ExplicitPadding, ConvolutionLayerTest, ::testing::Combine( conv3DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -125,7 +125,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Convolution3D_ExplicitPadding, ConvolutionLayerTes ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE)), ConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(nightly_Convolution3D_AutoPadValid, ConvolutionLayerTest, +INSTANTIATE_TEST_SUITE_P(nightly_Convolution3D_AutoPadValid, ConvolutionLayerTest, ::testing::Combine( conv3DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/reshape.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/reshape.cpp index e0c986ad8b52e5..d95ecdd81c826f 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/reshape.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/reshape.cpp @@ -15,7 +15,7 @@ const std::vector netPrecisions = { InferenceEngine::Precision::FP32, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_ReshapeCheckDynBatch, ReshapeLayerTestRevise, ::testing::Combine( ::testing::Values(true), ::testing::ValuesIn(netPrecisions), @@ -29,7 +29,7 @@ INSTANTIATE_TEST_CASE_P( ::testing::Values(std::map({}))), ReshapeLayerTestRevise::getTestCaseName); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_ReshapeCheck, ReshapeLayerTestRevise, ::testing::Combine( ::testing::Values(true), ::testing::ValuesIn(netPrecisions), @@ -43,7 +43,7 @@ INSTANTIATE_TEST_CASE_P( ::testing::Values(std::map({}))), ReshapeLayerTestRevise::getTestCaseName); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_ReshapeCheckNegative, ReshapeLayerTestRevise, ::testing::Combine( ::testing::Values(true), ::testing::ValuesIn(netPrecisions), diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/softmax.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/softmax.cpp index 3ad1b07c736e5e..583d2d7b81e727 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/softmax.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/softmax.cpp @@ -41,7 +41,7 @@ const auto params2D = testing::Combine( testing::Values(std::map()) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_SoftMax2D, SoftMaxLayerTest, params2D, @@ -68,7 +68,7 @@ const auto params4D = testing::Combine( testing::Values(std::map()) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_SoftMax4D, SoftMaxLayerTest, params4D, diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/split.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/split.cpp index 44f2c6737785b4..f4ea3db8af9525 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/split.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/split.cpp @@ -11,7 +11,7 @@ using namespace LayerTestsDefinitions; namespace { -INSTANTIATE_TEST_CASE_P(smoke_NumSplitsCheck, SplitLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_NumSplitsCheck, SplitLayerTest, ::testing::Combine( ::testing::Values(1, 2, 3, 5, 6, 10, 30), ::testing::Values(0, 1, 2, 3), diff --git a/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp b/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp index ac01a2324c997a..5b0fbcd297d400 100644 --- a/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp +++ b/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp @@ -1216,8 +1216,8 @@ void InsertConcatAligningFilterPass::run() { // modifying output rows to be used - to avoid modification to original concat we are store num of elements in params dims[1] = num_rows_out; - if (concatInput->getLayout() == Layout::NC && dims[0] > 8 || - concatInput->getLayout() == Layout::CN && dims[1] > 8) { + if ((concatInput->getLayout() == Layout::NC && dims[0] > 8) || + (concatInput->getLayout() == Layout::CN && dims[1] > 8)) { THROW_GNA_EXCEPTION << "unsupported batch number '" << (concatInput->getLayout() == Layout::NC ? dims[0] : dims[1]) << "' in layer '" << concatLayer->name << "'"; @@ -1669,7 +1669,7 @@ void BroadcastConstPass::run() { }; auto nextLayer = CNNNetCheckNextLayerSkipCertain(constLayer, 0, 0, true, isNonFunctional).first; - if (!nextLayer || !LayerInfo(nextLayer).isEltwise() && !LayerInfo(nextLayer).isFakeQuantize()) { + if (!nextLayer || (!LayerInfo(nextLayer).isEltwise() && !LayerInfo(nextLayer).isFakeQuantize())) { continue; } diff --git a/inference-engine/tests/functional/inference_engine/blob_copy_test.cpp b/inference-engine/tests/functional/inference_engine/blob_copy_test.cpp index 1968c4cb91da9e..d6356f154d0c6d 100644 --- a/inference-engine/tests/functional/inference_engine/blob_copy_test.cpp +++ b/inference-engine/tests/functional/inference_engine/blob_copy_test.cpp @@ -320,7 +320,7 @@ std::vector BlobCopy_PrecisionParams = { } // namespace -INSTANTIATE_TEST_CASE_P(accuracy, BlobCopyTest, +INSTANTIATE_TEST_SUITE_P(accuracy, BlobCopyTest, ::testing::Combine(::testing::ValuesIn(BlobCopy_srcLayoutParam), ::testing::ValuesIn(BlobCopy_dstLayoutParam), ::testing::ValuesIn(BlobCopy_BatchNum), @@ -468,7 +468,7 @@ TEST_P(BlobCopySetLayoutTest, BlobCopyWithNCHW_To_NHWC_After_setLayout) { ASSERT_TRUE(IsEqualBlobCopy(ref, dst)) << "'blob_copy' after setLayout function is not correct"; } -INSTANTIATE_TEST_CASE_P(accuracy, BlobCopySetLayoutTest, +INSTANTIATE_TEST_SUITE_P(accuracy, BlobCopySetLayoutTest, ::testing::Combine(::testing::ValuesIn(BlobCopySetLayout_Dims), ::testing::ValuesIn(BlobCopySetLayout_Precisions))); diff --git a/inference-engine/tests/functional/inference_engine/caching_test.cpp b/inference-engine/tests/functional/inference_engine/caching_test.cpp index cad8bd4428e3ba..4f27b8abaf99fa 100644 --- a/inference-engine/tests/functional/inference_engine/caching_test.cpp +++ b/inference-engine/tests/functional/inference_engine/caching_test.cpp @@ -67,7 +67,7 @@ class MockRemoteContext : public RemoteContext { MockRemoteContext(std::string name): m_name(std::move(name)) {} std::string getDeviceName() const noexcept { return m_name; } MOCK_METHOD2(CreateBlob, RemoteBlob::Ptr(const TensorDesc&, const ParamMap&)); - MOCK_QUALIFIED_METHOD0(getParams, const, ParamMap()); + MOCK_CONST_METHOD0(getParams, ParamMap()); }; class MockCachingInferencePluginBase : public InferenceEngine::IInferencePlugin { @@ -1075,7 +1075,7 @@ TEST_P(CachingTest, TestCacheFileOldVersion) { if (index != std::string::npos) { content.replace(index, buildNum.size(), zeroBuild); } else { - SKIP(); + return; // skip test } std::ofstream out(fileName, std::ios_base::binary); out.write(content.c_str(), content.size()); @@ -1505,7 +1505,7 @@ TEST_P(CachingTest, LoadMulti_NoCachingOnDevice) { } } -INSTANTIATE_TEST_CASE_P(CachingTest, CachingTest, +INSTANTIATE_TEST_SUITE_P(CachingTest, CachingTest, ::testing::Combine( ::testing::ValuesIn(loadVariants), ::testing::ValuesIn(cacheFolders)), diff --git a/inference-engine/tests/functional/inference_engine/cnn_network/matmul_sr_tests.cpp b/inference-engine/tests/functional/inference_engine/cnn_network/matmul_sr_tests.cpp index a013ac8c902ba4..33940bfab6de15 100644 --- a/inference-engine/tests/functional/inference_engine/cnn_network/matmul_sr_tests.cpp +++ b/inference-engine/tests/functional/inference_engine/cnn_network/matmul_sr_tests.cpp @@ -70,7 +70,7 @@ class SmartReshapeMatMulTests : public CommonTestUtils::TestsCommon, public test TEST_P(SmartReshapeMatMulTests, ReshapeMatMul) { } -INSTANTIATE_TEST_CASE_P(NGraph, SmartReshapeMatMulTests, testing::Values( +INSTANTIATE_TEST_SUITE_P(NGraph, SmartReshapeMatMulTests, testing::Values( ReshapeMatMulTestCase{true, {1, 20, 30}, {30, 40}, {20, -1}, false, false, {{"input_A", {2, 20, 30}}}}, ReshapeMatMulTestCase{true, {1, 20, 30}, {40, 30}, {20, -1}, false, true, {{"input_A", {2, 20, 30}}}}, ReshapeMatMulTestCase{true, {1, 30, 20}, {30, 20}, {-1, 20}, true, false, {{"input_A", {2, 30, 20}}}}, diff --git a/inference-engine/tests/functional/inference_engine/ir_serialization/serialize.cpp b/inference-engine/tests/functional/inference_engine/ir_serialization/serialize.cpp index 990fa74c183460..c9efc087a318c2 100644 --- a/inference-engine/tests/functional/inference_engine/ir_serialization/serialize.cpp +++ b/inference-engine/tests/functional/inference_engine/ir_serialization/serialize.cpp @@ -53,7 +53,7 @@ TEST_P(SerializationTest, CompareFunctions) { ASSERT_TRUE(success) << message; } -INSTANTIATE_TEST_CASE_P(IRSerialization, SerializationTest, +INSTANTIATE_TEST_SUITE_P(IRSerialization, SerializationTest, testing::Values(std::make_tuple("add_abc.xml", "add_abc.bin"), std::make_tuple("add_abc_f64.xml", ""), std::make_tuple("add_abc_bin.xml", ""), @@ -76,7 +76,7 @@ INSTANTIATE_TEST_CASE_P(IRSerialization, SerializationTest, #ifdef NGRAPH_ONNX_IMPORT_ENABLE -INSTANTIATE_TEST_CASE_P(ONNXSerialization, SerializationTest, +INSTANTIATE_TEST_SUITE_P(ONNXSerialization, SerializationTest, testing::Values(std::make_tuple("add_abc.prototxt", ""), std::make_tuple("split_equal_parts_2d.prototxt", ""), std::make_tuple("addmul_abc.prototxt", ""), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/add_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/add_transformation.cpp index 8098b89e73c1b2..2644d58470fc43 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/add_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/add_transformation.cpp @@ -807,7 +807,7 @@ const std::vector addTransformationTestValues = { } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, AddTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/avg_pool_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/avg_pool_transformation.cpp index 94d0abed429aeb..1e200cba65525c 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/avg_pool_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/avg_pool_transformation.cpp @@ -336,7 +336,7 @@ const std::vector testValues = { }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, AvgPoolTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/clamp_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/clamp_transformation.cpp index d2785e355a4d7b..994fe9a644eed1 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/clamp_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/clamp_transformation.cpp @@ -451,7 +451,7 @@ const std::vector testValues = { true // non dequantization multiply }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ClampTransformation, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/compose_fake_quantize_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/compose_fake_quantize_transformation.cpp index ce66f1848e0010..247569a9573bf9 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/compose_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/compose_fake_quantize_transformation.cpp @@ -140,7 +140,7 @@ const std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ComposeFakeQuantizeTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_selection_with_intermediate_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_selection_with_intermediate_transformation.cpp index 8f553ac5fd64ea..cadf373676c82d 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_selection_with_intermediate_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_selection_with_intermediate_transformation.cpp @@ -173,7 +173,7 @@ const std::vector testValues = { } }; - INSTANTIATE_TEST_CASE_P( + INSTANTIATE_TEST_SUITE_P( smoke_LPT, ConcatSelectionWithIntermediateTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_transformation.cpp index c199e60fbfd143..fd50c03c1c55f1 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_transformation.cpp @@ -737,7 +737,7 @@ const std::vector shapes = { { 4, 3, 9, 9 } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ConcatTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_different_precision_on_children.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_different_precision_on_children.cpp index dc2567fb70dbac..53fddd1e39d123 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_different_precision_on_children.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_different_precision_on_children.cpp @@ -237,7 +237,7 @@ const std::vector testValues = { }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ConcatWithDifferentChildrenTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_precision_selection_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_precision_selection_transformation.cpp index 0d6b29d5fe55d4..82afd2c7fe3954 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_precision_selection_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_precision_selection_transformation.cpp @@ -306,7 +306,7 @@ const std::vector shapes = { { 4, 3, 9, 9 } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ConcatWithIntermediatePrecisionSelectionTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_reshape_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_reshape_transformation.cpp index ea537db49cfc98..a56c34ce08aefd 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_reshape_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_reshape_transformation.cpp @@ -133,7 +133,7 @@ const std::vector testValues = { }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ConcatWithIntermediateReshapeTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_transformation.cpp index 974111bdae8015..5963cbb8fd37a5 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_transformation.cpp @@ -292,7 +292,7 @@ const std::vector shapes = { { 4, 3, 9, 9 } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ConcatWithIntermediateTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_with_constant_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_with_constant_transformation.cpp index 7ddf74cd52a0ea..0a6b0cbdc7ccdd 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_with_constant_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_with_constant_transformation.cpp @@ -309,7 +309,7 @@ const std::vector shapes = { { 4, 3, 9, 9 } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ConcatWithIntermediateWithConstantTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_neighbors_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_neighbors_transformation.cpp index c099b523b39140..7a8098a996b40e 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_neighbors_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_neighbors_transformation.cpp @@ -344,7 +344,7 @@ const std::vector shapes = { { 4, 3, 9, 9 } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ConcatWithNeighborsTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_reshape_at_the_end_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_reshape_at_the_end_transformation.cpp index 8f2f17a00f8b77..599e4f2c0bc5af 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_reshape_at_the_end_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_reshape_at_the_end_transformation.cpp @@ -206,7 +206,7 @@ const std::vector shapes = { { 4, 3, 9, 9 } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ConcatWithReshapeAtTheEndTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_split_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_split_transformation.cpp index 5f966576594b3d..de12ada6591b87 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_split_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_split_transformation.cpp @@ -300,7 +300,7 @@ const std::vector testValues = { }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ConcatWithSplitTransformation, ::testing::Combine( @@ -334,7 +334,7 @@ const std::vector testValues = { }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ConcatWithSplitTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_strided_slice_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_strided_slice_transformation.cpp index f11f20da124404..72dd960dbc406e 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_strided_slice_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_strided_slice_transformation.cpp @@ -273,7 +273,7 @@ const std::vector shapes = { { 4, 4, 9, 9 } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ConcatWithStridedSliceTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/convert_mul_or_add_finally_transformation_with_dequantization.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/convert_mul_or_add_finally_transformation_with_dequantization.cpp index 585f57c707e58b..edb4e813b7fe7a 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/convert_mul_or_add_finally_transformation_with_dequantization.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/convert_mul_or_add_finally_transformation_with_dequantization.cpp @@ -109,7 +109,7 @@ std::vector te } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ConvertMulOrAddFinallyTransformationWithDequantization, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/convert_subtract_constant_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/convert_subtract_constant_transformation.cpp index d908a6c6c9f064..235c6f77e26e62 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/convert_subtract_constant_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/convert_subtract_constant_transformation.cpp @@ -324,7 +324,7 @@ const std::vector testValues = }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ConvertSubtractConstantTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_backprop_data_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_backprop_data_transformation.cpp index 10ba4513f20549..eb62cd89b24436 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_backprop_data_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_backprop_data_transformation.cpp @@ -445,7 +445,7 @@ const std::vector testValues = }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ConvolutionBackpropDataTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_qdq_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_qdq_transformation.cpp index 75b1d965e53416..6812b00c1da4cc 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_qdq_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_qdq_transformation.cpp @@ -495,7 +495,7 @@ const std::vector testValues = { }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ConvolutionQDqTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_transformation.cpp index 8c2d42dfbf3c98..bad2201a65dcc9 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_transformation.cpp @@ -424,7 +424,7 @@ const std::vector testValues = { }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ConvolutionTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_with_incorrect_weights.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_with_incorrect_weights.cpp index b85c333928f1d8..7a6b43bc54788c 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_with_incorrect_weights.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_with_incorrect_weights.cpp @@ -130,7 +130,7 @@ const std::vector testValues = { }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ConvolutionWIthIncorrectWeightsTransformation, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/depth_to_space_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/depth_to_space_transformation.cpp index afbc2346c0f811..8ba97cb1e0ed34 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/depth_to_space_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/depth_to_space_transformation.cpp @@ -244,7 +244,7 @@ const std::vector testValues = { }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, DepthToSpaceTransformation, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/disable_convert_on_const_path_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/disable_convert_on_const_path_transformation.cpp index 23396b71cda2bb..5a2fbe0f39aee9 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/disable_convert_on_const_path_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/disable_convert_on_const_path_transformation.cpp @@ -161,7 +161,7 @@ const std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, DisableConvertOnConstPathTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/elementwise_with_multi_parent_dequantization_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/elementwise_with_multi_parent_dequantization_transformation.cpp index 6945e3ed1c0243..415301ec850816 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/elementwise_with_multi_parent_dequantization_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/elementwise_with_multi_parent_dequantization_transformation.cpp @@ -154,7 +154,7 @@ const std::vector shapes = { // TODO: 3D tensor }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, FakeQuantizeAndTwoOutputBranchesWithConvolutionTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_on_weights_with_unsupported_child.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_on_weights_with_unsupported_child.cpp index f430adb5974318..b29eff3926e379 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_on_weights_with_unsupported_child.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_on_weights_with_unsupported_child.cpp @@ -119,7 +119,7 @@ const std::vector testValue }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, FakeQuantizeOnWeightsWithUnsupportedChild, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_precision_selection_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_precision_selection_transformation.cpp index 5bbf9363792d69..c0db76cfd24d7b 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_precision_selection_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_precision_selection_transformation.cpp @@ -193,7 +193,7 @@ const std::vector shapes = { // TODO: 3D tensor }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, FakeQuantizePrecisionSelectionTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_transformation.cpp index 9ec593b6371502..7154009ff6fd25 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_transformation.cpp @@ -222,7 +222,7 @@ const std::vector shapes = { // TODO: 3D tensor }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, FakeQuantizeTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp index b057615dcad5d4..a67d10ed8bf164 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp @@ -205,7 +205,7 @@ const std::vector shapes = { // TODO: 3D tensor }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, FakeQuantizeWithNotOptimalTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_with_dynamic_intervals_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_with_dynamic_intervals_transformation.cpp index e7955f9987153f..77513ca6b92148 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_with_dynamic_intervals_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_with_dynamic_intervals_transformation.cpp @@ -157,7 +157,7 @@ const std::vector fake const std::vector shapes = { { 1, 32, 72, 48 } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, FakeQuantizeWithDynamicIntervalsTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/fold_convert_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/fold_convert_transformation.cpp index 68b6e16b9a68a4..94a978e582588e 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/fold_convert_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/fold_convert_transformation.cpp @@ -165,7 +165,7 @@ const std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, FoldConvertTransformation, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/fold_fake_quantize_in_transformations.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/fold_fake_quantize_in_transformations.cpp index fe2b958d2164b7..3be09188b8cdb3 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/fold_fake_quantize_in_transformations.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/fold_fake_quantize_in_transformations.cpp @@ -206,7 +206,7 @@ const std::vector testValues = { }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, FoldFakeQuantizeInTransformations, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/fuse_convert_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/fuse_convert_transformation.cpp index 626b251ebfc66f..e3854ad12cd990 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/fuse_convert_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/fuse_convert_transformation.cpp @@ -180,7 +180,7 @@ TEST_P(FuseConvertTransformation, CompareFunctions) { ASSERT_TRUE(res.first) << res.second; } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, FuseConvertTransformation, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/fuse_fake_quantize_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/fuse_fake_quantize_transformation.cpp index 100b166e92e403..6b063c008757dc 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/fuse_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/fuse_fake_quantize_transformation.cpp @@ -342,7 +342,7 @@ const std::vector testValues = { }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, FuseFakeQuantizeTransformation, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/fuse_fake_quantize_with_multi_inputs_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/fuse_fake_quantize_with_multi_inputs_transformation.cpp index fcbb532a6f1cc8..0f51338a464600 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/fuse_fake_quantize_with_multi_inputs_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/fuse_fake_quantize_with_multi_inputs_transformation.cpp @@ -135,7 +135,7 @@ const std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, FuseFakeQuantizeWithMultiInputsTransformation, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/fuse_multiply_to_fake_quantize_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/fuse_multiply_to_fake_quantize_transformation.cpp index bf0ce1b4484b84..2fe1093cd9420f 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/fuse_multiply_to_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/fuse_multiply_to_fake_quantize_transformation.cpp @@ -140,7 +140,7 @@ const std::vector testValues }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, FuseMultiplyToFakeQuantizeTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/fuse_subtract_to_fake_quantize_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/fuse_subtract_to_fake_quantize_transformation.cpp index 94016eb98f8705..d65c313ebabfc8 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/fuse_subtract_to_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/fuse_subtract_to_fake_quantize_transformation.cpp @@ -217,7 +217,7 @@ const std::vector testValues }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, FuseSubtractToFakeQuantizeTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/get_dequantization_below_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/get_dequantization_below_transformation.cpp index c92126b3252d12..53a803e88a9852 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/get_dequantization_below_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/get_dequantization_below_transformation.cpp @@ -124,7 +124,7 @@ const std::vector shapes = { // TODO: 3D tensor }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, GetDequantizationBelowTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/get_dequantization_test.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/get_dequantization_test.cpp index 0260a46467a419..3e6af62a9376fd 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/get_dequantization_test.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/get_dequantization_test.cpp @@ -78,7 +78,7 @@ TEST_P(GetDequantizationTestTransformation, CompareFunctions) { ASSERT_TRUE(res.first) << res.second; } -INSTANTIATE_TEST_CASE_P(smoke_LPT, GetDequantizationTestTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, GetDequantizationTestTransformation, ::testing::Combine( ::testing::ValuesIn(isConvert), ::testing::ValuesIn(isSubtract), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/get_dequantization_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/get_dequantization_transformation.cpp index 7f527e210929a5..1e69ae86bc8157 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/get_dequantization_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/get_dequantization_transformation.cpp @@ -155,7 +155,7 @@ const std::vector shapes = { // TODO: 3D tensor }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, GetDequantizationTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/group_convolution_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/group_convolution_transformation.cpp index 22844037c98d75..e8ba7d4e5f1c26 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/group_convolution_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/group_convolution_transformation.cpp @@ -702,7 +702,7 @@ const std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, GroupConvolutionTransformation, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/interpolate_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/interpolate_transformation.cpp index 0e90edef6d7e5f..74a78d350e04a3 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/interpolate_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/interpolate_transformation.cpp @@ -446,7 +446,7 @@ TEST_P(InterpolateTransformation, CompareFunctions) { ASSERT_TRUE(res.first) << res.second; } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, InterpolateTransformation, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/is_function_quantized_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/is_function_quantized_transformation.cpp index 860f7931cf64ca..b66b02eba31e2d 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/is_function_quantized_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/is_function_quantized_transformation.cpp @@ -109,7 +109,7 @@ const std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, IsFunctionQuantizedTransformation, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/mat_mul_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/mat_mul_transformation.cpp index 934326f9573f63..090c46bbd9a444 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/mat_mul_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/mat_mul_transformation.cpp @@ -357,7 +357,7 @@ std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, MatMulTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/mat_mul_with_constant_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/mat_mul_with_constant_transformation.cpp index 5c4e171d504847..35e2806fd63bb6 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/mat_mul_with_constant_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/mat_mul_with_constant_transformation.cpp @@ -592,7 +592,7 @@ std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, MatMulWithConstantTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/max_pool_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/max_pool_transformation.cpp index c7c3bae73fcf9e..f3c641b9af19b9 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/max_pool_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/max_pool_transformation.cpp @@ -208,7 +208,7 @@ const std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, MaxPoolTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/move_dequantization_after_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/move_dequantization_after_transformation.cpp index c50375d14df92b..a9106994aa7320 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/move_dequantization_after_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/move_dequantization_after_transformation.cpp @@ -256,7 +256,7 @@ const std::vector testValues = { }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, MoveDequantizationAfterTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/mul_add_to_scaleshift_or_power_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/mul_add_to_scaleshift_or_power_transformation.cpp index 14da96bd21bf94..0b32cedb3515f6 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/mul_add_to_scaleshift_or_power_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/mul_add_to_scaleshift_or_power_transformation.cpp @@ -135,7 +135,7 @@ const std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, MulAddToScaleshiftOrPowerTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/multiply_to_group_convolution_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/multiply_to_group_convolution_transformation.cpp index a7f4013c315d88..858041bba68897 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/multiply_to_group_convolution_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/multiply_to_group_convolution_transformation.cpp @@ -312,7 +312,7 @@ TEST_P(MultiplyToGroupConvolutionTransformation, CompareFunctions) { ASSERT_TRUE(res.first) << res.second; } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, MultiplyToGroupConvolutionTransformation, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/multiply_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/multiply_transformation.cpp index a17839f8d3c4cd..7441cf2916026b 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/multiply_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/multiply_transformation.cpp @@ -727,7 +727,7 @@ const std::vector multiplyTransformationTestVa }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, MultiplyTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/mvn_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/mvn_transformation.cpp index ba90f89d3f4a42..40cb46151dc4a0 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/mvn_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/mvn_transformation.cpp @@ -298,7 +298,7 @@ TEST_P(MVNTransformation, CompareFunctions) { ASSERT_TRUE(res.first) << res.second; } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, MVNTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/normalize_dequantization_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/normalize_dequantization_transformation.cpp index 63592e5b35ce99..17a8b601f12c6c 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/normalize_dequantization_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/normalize_dequantization_transformation.cpp @@ -163,7 +163,7 @@ const std::vector testValues = { }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, NormalizeDequantizationTransformation, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/normalize_l2_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/normalize_l2_transformation.cpp index 72e1c715ac6de5..6e34ea092d92ea 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/normalize_l2_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/normalize_l2_transformation.cpp @@ -269,7 +269,7 @@ const std::vector normalizeL2Transformation }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, NormalizeL2Transformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/prelu_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/prelu_transformation.cpp index bbe0e3bd9a2668..66e6a161a7a8de 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/prelu_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/prelu_transformation.cpp @@ -159,7 +159,7 @@ const std::vector testValues = { }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, PReluTransformation, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/pull_reshape_through_dequantization_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/pull_reshape_through_dequantization_transformation.cpp index f00dcc62173953..33a9b90cd54c78 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/pull_reshape_through_dequantization_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/pull_reshape_through_dequantization_transformation.cpp @@ -349,7 +349,7 @@ const std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, PullReshapeThroughDequantizationTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/pull_transpose_through_dequantization_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/pull_transpose_through_dequantization_transformation.cpp index 5794ffc55e5d7c..fd459eeb1d1a6a 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/pull_transpose_through_dequantization_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/pull_transpose_through_dequantization_transformation.cpp @@ -237,7 +237,7 @@ const std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, PullTransposeThroughDequantizationTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/reduce_max_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/reduce_max_transformation.cpp index 4d2ab19bdb3e83..23569ae8f8043b 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/reduce_max_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/reduce_max_transformation.cpp @@ -301,7 +301,7 @@ const std::vector reduceMaxTransformationTestVal }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ReduceMaxTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/reduce_mean_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/reduce_mean_transformation.cpp index 5a61b55f21b6fa..1fbfbb4362d373 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/reduce_mean_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/reduce_mean_transformation.cpp @@ -269,7 +269,7 @@ const std::vector reduceMeanTransformationTestVa }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ReduceMeanTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/reduce_min_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/reduce_min_transformation.cpp index 65a01088ab55f0..563a30ebdc6f1d 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/reduce_min_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/reduce_min_transformation.cpp @@ -301,7 +301,7 @@ const std::vector reduceMinTransformationTestVal }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ReduceMinTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/reduce_sum_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/reduce_sum_transformation.cpp index 0dcf43331f00c9..95c9d8b57078d2 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/reduce_sum_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/reduce_sum_transformation.cpp @@ -293,7 +293,7 @@ const std::vector reduceSumTransformationTestVal }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ReduceSumTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/relu_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/relu_transformation.cpp index 090bf1b6aeab16..92ee87caa61123 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/relu_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/relu_transformation.cpp @@ -234,7 +234,7 @@ const std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ReluTransformation, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/reshape_fully_connected_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/reshape_fully_connected_transformation.cpp index a0ad21362ed6d9..9c78d2178973b7 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/reshape_fully_connected_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/reshape_fully_connected_transformation.cpp @@ -99,7 +99,7 @@ std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ReshapeFullyConnectedTransformation, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/reshape_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/reshape_transformation.cpp index c2ff5b59048e44..2ea6cb9f088292 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/reshape_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/reshape_transformation.cpp @@ -647,7 +647,7 @@ TEST_P(ReshapeTransformation, CompareFunctions) { ASSERT_TRUE(res.first) << res.second; } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ReshapeTransformation, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/round_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/round_transformation.cpp index 04ff6e9f0d3700..0612881bff3646 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/round_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/round_transformation.cpp @@ -102,7 +102,7 @@ TEST_P(RoundTransformation, CompareFunctions) { ASSERT_TRUE(res.first) << res.second; } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( LPT, RoundTransformation, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/separate_in_standalone_branch_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/separate_in_standalone_branch_transformation.cpp index 04832b837fe4bc..a62be54c87f860 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/separate_in_standalone_branch_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/separate_in_standalone_branch_transformation.cpp @@ -158,7 +158,7 @@ std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, SeparateInStandaloneBranchTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/shuffle_channels_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/shuffle_channels_transformation.cpp index 88a205089d6a5d..d70f611b91d5de 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/shuffle_channels_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/shuffle_channels_transformation.cpp @@ -280,7 +280,7 @@ const std::vector testValues = { }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, ShuffleChannelsTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/split_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/split_transformation.cpp index b08d154c17cbab..89b5b166e8c7d6 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/split_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/split_transformation.cpp @@ -456,7 +456,7 @@ const std::vector testValues = { { } }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, SplitTransformation, ::testing::Combine( diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/squeeze_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/squeeze_transformation.cpp index a753c972ba3fd8..ffac08817e352f 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/squeeze_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/squeeze_transformation.cpp @@ -223,7 +223,7 @@ const std::vector testValues = { }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, SqueezeTransformation, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/strided_slice_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/strided_slice_transformation.cpp index ca8f4a68518ace..028fa55a2cb468 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/strided_slice_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/strided_slice_transformation.cpp @@ -535,7 +535,7 @@ const std::vector stridedSliceTransformati }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, StridedSliceTransformation, ::testing::ValuesIn(stridedSliceTransformationTestValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/subtract_multiply_to_multiply_add_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/subtract_multiply_to_multiply_add_transformation.cpp index e7a7ca81fbc679..d854afe64286af 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/subtract_multiply_to_multiply_add_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/subtract_multiply_to_multiply_add_transformation.cpp @@ -273,7 +273,7 @@ const std::vector testVal }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, SubtractMultiplyToMultiplyAddTransformation, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/transformations_after_split_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/transformations_after_split_transformation.cpp index d4e5b3773055be..0795c8d5101697 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/transformations_after_split_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/transformations_after_split_transformation.cpp @@ -213,7 +213,7 @@ const std::vector transformationNames = { "SubtractMultiplyToMultiplyAddTransformation", }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, TransformationsAfterSplitTransformation, ::testing::ValuesIn(transformationNames), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/transformer_is_function_quantized.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/transformer_is_function_quantized.cpp index 1ad9e702d182b2..5a00bbc015cb58 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/transformer_is_function_quantized.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/transformer_is_function_quantized.cpp @@ -79,7 +79,7 @@ const std::vector testValues = { { {}, {} } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, TransformerIsFunctionQuantized, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/transpose_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/transpose_transformation.cpp index de8d2f780b828a..ad07bcd6bc7d2f 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/transpose_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/transpose_transformation.cpp @@ -202,7 +202,7 @@ TEST_P(TransposeTransformation, CompareFunctions) { ASSERT_TRUE(res.first) << res.second; } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, TransposeTransformation, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/unsqueeze_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/unsqueeze_transformation.cpp index 00359326fb0a93..2aa00c5cefdf20 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/unsqueeze_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/unsqueeze_transformation.cpp @@ -223,7 +223,7 @@ const std::vector testValues = { }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, UnsqueezeTransformation, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/variadic_split_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/variadic_split_transformation.cpp index 990de4d98d7a56..b5075dfc7f429f 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/variadic_split_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/variadic_split_transformation.cpp @@ -464,7 +464,7 @@ const std::vector testValues = { { } }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LPT, VariadicSplitTransformation, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/ngraph_reader/net_reader_test.cpp b/inference-engine/tests/functional/inference_engine/ngraph_reader/net_reader_test.cpp index 3944a8853823e0..d32b6ab07de619 100644 --- a/inference-engine/tests/functional/inference_engine/ngraph_reader/net_reader_test.cpp +++ b/inference-engine/tests/functional/inference_engine/ngraph_reader/net_reader_test.cpp @@ -198,7 +198,7 @@ static const auto params = testing::Combine( testing::Values(InferenceEngine::SizeVector{1, 3, 227, 227}), testing::Values(InferenceEngine::Precision::FP32, InferenceEngine::Precision::FP16)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( NetReaderTest, NetReaderTest, params, diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/activation.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/activation.cpp index ff6a32786c8a6a..fb0c8acd71b806 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/activation.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/activation.cpp @@ -99,11 +99,11 @@ const auto basicPreluCases = ::testing::Combine( ); -INSTANTIATE_TEST_CASE_P(smoke_Activation_Basic, ActivationLayerTest, basicCases, ActivationLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Activation_Basic_Prelu, ActivationLayerTest, basicPreluCases, ActivationLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Activation_Basic, ActivationLayerTest, basicCases, ActivationLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Activation_Basic_Prelu, ActivationLayerTest, basicPreluCases, ActivationLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Activation_Basic, ActivationParamLayerTest, basicPreluCases, ActivationLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Activation_Basic, ActivationParamLayerTest, basicPreluCases, ActivationLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Activation_Basic, ActivationDynamicLayerTest, basicCases, ActivationLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Activation_Basic, ActivationDynamicLayerTest, basicCases, ActivationLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/batch_norm.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/batch_norm.cpp index cc1cbf7dff2a73..3f78aea438be00 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/batch_norm.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/batch_norm.cpp @@ -45,7 +45,7 @@ const auto batchNormParams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_BatchNorm_Serialization, BatchNormLayerTest, batchNormParams, diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/binary_convolution.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/binary_convolution.cpp index 4ffae87a5706df..aa4f5c9eb3f5a5 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/binary_convolution.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/binary_convolution.cpp @@ -37,7 +37,7 @@ const auto binConv2DParams_AutoPadValid = ::testing::Combine( ::testing::Values(ngraph::op::PadType::VALID), ::testing::ValuesIn(pad_values)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_BinaryConvolution2D_Serialization_ExplicitPadding, BinaryConvolutionLayerTest, ::testing::Combine( binConv2DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -49,7 +49,7 @@ INSTANTIATE_TEST_CASE_P( ::testing::Values(CommonTestUtils::DEVICE_CPU)), BinaryConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_BinaryConvolution2D__Serialization_AutoPadValid, BinaryConvolutionLayerTest, ::testing::Combine( binConv2DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/broadcast.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/broadcast.cpp index 1e101775319f01..0bfc51fa9831f9 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/broadcast.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/broadcast.cpp @@ -27,7 +27,7 @@ const auto numpyBroadcastParams1 = ::testing::Combine( ::testing::Values(inShapesNumpy[0]), ::testing::ValuesIn(inputPrecisions), ::testing::Values(CommonTestUtils::DEVICE_CPU)); -INSTANTIATE_TEST_CASE_P(smoke_Broadcast1Serialization, BroadcastLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Broadcast1Serialization, BroadcastLayerTest, numpyBroadcastParams1, BroadcastLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/clamp.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/clamp.cpp index 607989781e6f72..7bff8a3359a1cb 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/clamp.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/clamp.cpp @@ -22,7 +22,7 @@ const std::vector netPrecisions = { const std::vector> intervals = { {-20.1, -10.5}, {-10.0, 10.0}, {10.3, 20.4}}; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Clamp_Serialization, ClampLayerTest, ::testing::Combine( ::testing::ValuesIn(inShapes), diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/constant.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/constant.cpp index 4d4cce07bf0d0e..0fc324f2bd6492 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/constant.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/constant.cpp @@ -41,13 +41,13 @@ std::vector precisionsWithNegativeValues = { std::vector dataWithNegativeValues = {"1", "-2", "3", "-4", "5", "-6", "7", "-1", "2", "-3", "4", "-5"}; -INSTANTIATE_TEST_CASE_P(smoke_Constant_Serialization, ConstantLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Constant_Serialization, ConstantLayerTest, ::testing::Combine(::testing::ValuesIn(shapes), ::testing::ValuesIn(precisions), ::testing::Values(data), ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConstantLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Constant_Serialization_with_negative_values, ConstantLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Constant_Serialization_with_negative_values, ConstantLayerTest, ::testing::Combine(::testing::ValuesIn(shapes), ::testing::ValuesIn(precisionsWithNegativeValues), ::testing::Values(dataWithNegativeValues), diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/convert.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/convert.cpp index e6d6bc19ed7d6d..7cc308c41e287c 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/convert.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/convert.cpp @@ -25,7 +25,7 @@ TEST_P(ConvertLayerTest, Serialize) { Serialize(); } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Serialization_ConvertLayerTest, ConvertLayerTest, ::testing::Combine(::testing::Values(inShape), ::testing::ValuesIn(precisions), diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/convolution.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/convolution.cpp index 7e22ba3e388df6..f68db9c3b08a05 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/convolution.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/convolution.cpp @@ -36,7 +36,7 @@ const auto conv2DParams_AutoPadValid = ::testing::Combine( ::testing::ValuesIn(dilations), ::testing::ValuesIn(numOutChannels), ::testing::Values(ngraph::op::PadType::VALID)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Convolution2D_Serialization_ExplicitPadding, ConvolutionLayerTest, ::testing::Combine( conv2DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -48,7 +48,7 @@ INSTANTIATE_TEST_CASE_P( ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Convolution2D__Serialization_AutoPadValid, ConvolutionLayerTest, ::testing::Combine( conv2DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/convolution_backprop.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/convolution_backprop.cpp index 2f9383ad914475..0e29deb207e8f1 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/convolution_backprop.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/convolution_backprop.cpp @@ -41,7 +41,7 @@ const auto convolutionBackpropData2DParams = ::testing::Combine( ::testing::ValuesIn(dilations), ::testing::ValuesIn(numOutChannels), ::testing::ValuesIn(pad_types), ::testing::ValuesIn(outPadding)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_convolutionBackpropData2D_Serialization, ConvolutionBackpropLayerTest, ::testing::Combine( convolutionBackpropData2DParams, diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/deformable_convolution.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/deformable_convolution.cpp index a73f583f8b87c7..09107a33cd576d 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/deformable_convolution.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/deformable_convolution.cpp @@ -42,7 +42,7 @@ const auto conv2DParams_AutoPadValid = ::testing::Combine( ::testing::ValuesIn(defor_groups), ::testing::ValuesIn(numOutChannels), ::testing::Values(ngraph::op::PadType::VALID)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_DeformableConvolution2D_Serialization_ExplicitPadding, DeformableConvolutionLayerTest, ::testing::Combine( conv2DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -54,7 +54,7 @@ INSTANTIATE_TEST_CASE_P( ::testing::Values(CommonTestUtils::DEVICE_CPU)), DeformableConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_DeformableConvolution2D__Serialization_AutoPadValid, DeformableConvolutionLayerTest, ::testing::Combine( conv2DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/deformable_psroi_pooling.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/deformable_psroi_pooling.cpp index ffdedd39905a7b..c4606cf7dec44c 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/deformable_psroi_pooling.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/deformable_psroi_pooling.cpp @@ -30,6 +30,6 @@ namespace { ::testing::Values(InferenceEngine::Precision::FP32), // Net precision ::testing::Values(CommonTestUtils::DEVICE_CPU)); // Device name - INSTANTIATE_TEST_CASE_P(smoke_TestsDeformablePSROIPooling, DeformablePSROIPoolingLayerTest, deformablePSROICases_test_params, + INSTANTIATE_TEST_SUITE_P(smoke_TestsDeformablePSROIPooling, DeformablePSROIPoolingLayerTest, deformablePSROICases_test_params, DeformablePSROIPoolingLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/detection_output.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/detection_output.cpp index e1f66b84c22276..00d5382d6fe32f 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/detection_output.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/detection_output.cpp @@ -66,7 +66,7 @@ namespace { ::testing::Values(objectnessScore), ::testing::Values(CommonTestUtils::DEVICE_CPU)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_DetectionOutput3In, DetectionOutputLayerTest, params3Inputs, diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/elementwise.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/elementwise.cpp index 7d2ac7f47a1957..1a131fffaf52ec 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/elementwise.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/elementwise.cpp @@ -57,7 +57,7 @@ const auto elementiwiseParams = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::Values(additionalConfig)); -INSTANTIATE_TEST_CASE_P(smoke_ElementwiseSerialization, EltwiseLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ElementwiseSerialization, EltwiseLayerTest, elementiwiseParams, EltwiseLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/extractimagepatches.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/extractimagepatches.cpp index 7e48a0ad0e93a7..6eda8ccde991be 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/extractimagepatches.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/extractimagepatches.cpp @@ -27,7 +27,7 @@ const std::vector netPrecision = { InferenceEngine::Precision::FP32 }; -INSTANTIATE_TEST_CASE_P(smoke_ExtractImagePatchesLayerTest, ExtractImagePatchesTest, +INSTANTIATE_TEST_SUITE_P(smoke_ExtractImagePatchesLayerTest, ExtractImagePatchesTest, ::testing::Combine(::testing::ValuesIn(inShapes), ::testing::ValuesIn(kSizes), ::testing::ValuesIn(strides), diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/group_convolution.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/group_convolution.cpp index ca080890ee37b0..66b5ec2684feb3 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/group_convolution.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/group_convolution.cpp @@ -40,7 +40,7 @@ const auto groupConv2DParams = ::testing::Combine( ::testing::ValuesIn(dilations), ::testing::ValuesIn(numOutChannels), ::testing::ValuesIn(numGroups), ::testing::ValuesIn(pad_types)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_GroupConvolution2D_Serialization, GroupConvolutionLayerTest, ::testing::Combine( groupConv2DParams, ::testing::ValuesIn(precisions), diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/group_convolution_backprop_data.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/group_convolution_backprop_data.cpp index d98ff4016e4bd0..df5596e2363d6d 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/group_convolution_backprop_data.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/group_convolution_backprop_data.cpp @@ -40,7 +40,7 @@ const auto groupConvBackpropData2DParams = ::testing::Combine( ::testing::ValuesIn(dilations), ::testing::ValuesIn(numOutChannels), ::testing::ValuesIn(numGroups), ::testing::ValuesIn(pad_types)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_GroupConvBackpropData2D_Serialization, GroupConvBackpropDataLayerTest, ::testing::Combine( groupConvBackpropData2DParams, diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/minimum_maximum.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/minimum_maximum.cpp index 19417dc8e0f64c..d64b7cf4e61915 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/minimum_maximum.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/minimum_maximum.cpp @@ -36,7 +36,7 @@ const std::vector inputType = { ngraph::helpers::InputLayerType::PARAMETER, }; -INSTANTIATE_TEST_CASE_P(smoke_maximum, MaxMinLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_maximum, MaxMinLayerTest, ::testing::Combine( ::testing::ValuesIn(inShapes), ::testing::ValuesIn(opType), diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/mvn.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/mvn.cpp index cc8f5728d31322..b5a3cf828c79b7 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/mvn.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/mvn.cpp @@ -31,7 +31,7 @@ TEST_P(MvnLayerTest, Serialize) { Serialize(); } -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsMVN, MvnLayerTest, MvnCases, +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsMVN, MvnLayerTest, MvnCases, MvnLayerTest::getTestCaseName); // ------------------- MVN-6 ------------------------------------------------- @@ -47,7 +47,7 @@ TEST_P(Mvn6LayerTest, Serialize) { Serialize(); } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_MVN_5D, Mvn6LayerTest, ::testing::Combine(::testing::ValuesIn(std::vector>{ {1, 10, 5, 7, 8}, {1, 3, 8, 9, 49}}), diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/non_max_suppression.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/non_max_suppression.cpp index 633b69b02bdd54..510d8b860e6dd3 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/non_max_suppression.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/non_max_suppression.cpp @@ -52,6 +52,6 @@ namespace { ::testing::ValuesIn(outType), ::testing::Values(CommonTestUtils::DEVICE_CPU)); - INSTANTIATE_TEST_CASE_P(smoke_NmsLayerTest, NmsLayerTest, nmsParams, NmsLayerTest::getTestCaseName); + INSTANTIATE_TEST_SUITE_P(smoke_NmsLayerTest, NmsLayerTest, nmsParams, NmsLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/nonzero.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/nonzero.cpp index 2d0c7453ec9fd2..a10a2c52510b66 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/nonzero.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/nonzero.cpp @@ -25,7 +25,7 @@ std::vector inputPrecisions = { ConfigMap config; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_NonZeroLayerTest, NonZeroLayerTest, ::testing::Combine(::testing::ValuesIn(inputDims), ::testing::ValuesIn(inputPrecisions), diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/normalize_l2.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/normalize_l2.cpp index 68b5ce21bab004..cf56b7cbacdd4d 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/normalize_l2.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/normalize_l2.cpp @@ -30,7 +30,7 @@ const std::vector netPrecisions = { Precision::BF16 }; -INSTANTIATE_TEST_CASE_P(smoke_NormalizeL2Serialization, NormalizeL2LayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_NormalizeL2Serialization, NormalizeL2LayerTest, testing::Combine( testing::ValuesIn(axes), testing::ValuesIn(eps), diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/one_hot.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/one_hot.cpp index 7a013aa7b55d13..42a80dd60b7756 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/one_hot.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/one_hot.cpp @@ -34,6 +34,6 @@ const auto oneHotParams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_OneHotConstSerialization, OneHotLayerTest, oneHotParams, +INSTANTIATE_TEST_SUITE_P(smoke_OneHotConstSerialization, OneHotLayerTest, oneHotParams, OneHotLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/pad.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/pad.cpp index 6a3a9a484ac815..6035d38f1752cd 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/pad.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/pad.cpp @@ -35,6 +35,6 @@ const auto pad2DConstparams = testing::Combine( testing::Values(std::vector{13, 5}), testing::Values(CommonTestUtils::DEVICE_CPU)); -INSTANTIATE_TEST_CASE_P(smoke_Pad2DConstSerialization, PadLayerTest, pad2DConstparams, +INSTANTIATE_TEST_SUITE_P(smoke_Pad2DConstSerialization, PadLayerTest, pad2DConstparams, PadLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/pooling.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/pooling.cpp index c1a05395e17759..df14f0bac5d541 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/pooling.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/pooling.cpp @@ -55,7 +55,7 @@ namespace { ::testing::ValuesIn(padTypes), ::testing::Values(excludePad[0])); - INSTANTIATE_TEST_CASE_P(smoke_AvgPoolExcluePad, PoolingLayerTest, + INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolExcluePad, PoolingLayerTest, ::testing::Combine( avgExcludePadParams, ::testing::ValuesIn(netPrecisions), @@ -77,7 +77,7 @@ namespace { ::testing::ValuesIn(padTypes), ::testing::Values(excludePad[1])); - INSTANTIATE_TEST_CASE_P(smoke_AvgPool, PoolingLayerTest, + INSTANTIATE_TEST_SUITE_P(smoke_AvgPool, PoolingLayerTest, ::testing::Combine( avgPadParams, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/prelu.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/prelu.cpp index d00123b4eb13ef..35d708bd9a1031 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/prelu.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/prelu.cpp @@ -38,6 +38,6 @@ const auto basicCases = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_ActivationPreluSerialization, +INSTANTIATE_TEST_SUITE_P(smoke_ActivationPreluSerialization, ActivationLayerTest, basicCases, ActivationLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/prior_box_clustered.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/prior_box_clustered.cpp index dd0f2d5144d5a9..f59e469660b56d 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/prior_box_clustered.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/prior_box_clustered.cpp @@ -61,7 +61,7 @@ namespace { ::testing::ValuesIn(offsets), ::testing::ValuesIn(variances)); - INSTANTIATE_TEST_CASE_P(smoke_PriorBoxClustered_Basic, PriorBoxClusteredLayerTest, + INSTANTIATE_TEST_SUITE_P(smoke_PriorBoxClustered_Basic, PriorBoxClusteredLayerTest, ::testing::Combine( layerSpeficParams, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/reduce_ops.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/reduce_ops.cpp index 8f28fc7f72b2af..61b0353c83650a 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/reduce_ops.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/reduce_ops.cpp @@ -140,35 +140,35 @@ const auto params_ReductionTypesLogical = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_ReduceOneAxis_Serialization, ReduceOpsLayerTest, paramsOneAxis, ReduceOpsLayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_ReduceLogicalOneAxis_Serialization, ReduceOpsLayerTest, paramsOneAxisLogical, ReduceOpsLayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_ReduceAxes_Serialization, ReduceOpsLayerTest, params_Axes, ReduceOpsLayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Reduce_ReductionTypes_Serialization, ReduceOpsLayerTest, params_ReductionTypes, ReduceOpsLayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_ReduceLogical_ReductionTypes_Serialization, ReduceOpsLayerTest, params_ReductionTypesLogical, diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/region_yolo.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/region_yolo.cpp index 228fbb33192ca1..c5bb56e763bed1 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/region_yolo.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/region_yolo.cpp @@ -33,7 +33,7 @@ namespace { const int start_axis = 1; const int end_axis = 3; - INSTANTIATE_TEST_CASE_P(smoke_RegionYolov3Serialization, RegionYoloLayerTest, + INSTANTIATE_TEST_SUITE_P(smoke_RegionYolov3Serialization, RegionYoloLayerTest, ::testing::Combine( ::testing::ValuesIn(inShapes_v3), ::testing::Values(classes[0]), diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/reshape.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/reshape.cpp index 9ba9aec704b19d..96338ae40de2f2 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/reshape.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/reshape.cpp @@ -19,7 +19,7 @@ namespace { InferenceEngine::Precision::FP16 }; - INSTANTIATE_TEST_CASE_P(smoke_ReshapeSerialization, ReshapeLayerTestRevise, + INSTANTIATE_TEST_SUITE_P(smoke_ReshapeSerialization, ReshapeLayerTestRevise, ::testing::Combine( ::testing::Values(true), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/result.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/result.cpp index aa7e365bc79cec..174779da42a9b2 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/result.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/result.cpp @@ -25,7 +25,7 @@ std::vector inputPrecisions = { ConfigMap config; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_ResultLayerTest, ResultLayerTest, ::testing::Combine(::testing::ValuesIn(inputDims), ::testing::ValuesIn(inputPrecisions), diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/scatter_nd_update.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/scatter_nd_update.cpp index 668eeadcd8a43e..95fcf54112337a 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/scatter_nd_update.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/scatter_nd_update.cpp @@ -42,7 +42,7 @@ const auto ScatterNDUpdateCases = ::testing::Combine( ::testing::ValuesIn(idxPrecisions), ::testing::Values(CommonTestUtils::DEVICE_CPU)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_ScatterNDUpdateLayerTestSerialization, ScatterNDUpdateLayerTest, ScatterNDUpdateCases, diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/shuffle_channels.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/shuffle_channels.cpp index e66352547e4d70..0dc0411d1d749c 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/shuffle_channels.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/shuffle_channels.cpp @@ -35,7 +35,7 @@ const auto shuffleChannelsParamsNegativeAxis4D = ::testing::Combine( ::testing::ValuesIn(groups) ); -INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannelsSerialization, ShuffleChannelsLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannelsSerialization, ShuffleChannelsLayerTest, ::testing::Combine( shuffleChannelsParams4D, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/space_to_batch.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/space_to_batch.cpp index 1b55e2fbac71f1..d5293dc50500ac 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/space_to_batch.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/space_to_batch.cpp @@ -31,7 +31,7 @@ const auto SpaceToBatch4D = ::testing::Combine( ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(CommonTestUtils::DEVICE_CPU)); -INSTANTIATE_TEST_CASE_P(smoke_spacetobatch4D_Serialization, +INSTANTIATE_TEST_SUITE_P(smoke_spacetobatch4D_Serialization, SpaceToBatchLayerTest, SpaceToBatch4D, SpaceToBatchLayerTest::getTestCaseName); diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/split.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/split.cpp index 80b1ca17ecacad..56e56900beb39b 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/split.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/split.cpp @@ -20,7 +20,7 @@ const std::vector netPrecisions = { InferenceEngine::Precision::U16, InferenceEngine::Precision::BOOL}; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Split_Serialization, SplitLayerTest, ::testing::Combine( ::testing::Values(1, 2, 5, 10), diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/squeeze.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/squeeze.cpp index 126f01f2a0d4c7..7164d4da8be974 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/squeeze.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/squeeze.cpp @@ -32,7 +32,7 @@ const std::vector netPrecisions = { const std::vector opTypes = { ngraph::helpers::SqueezeOpType::SQUEEZE}; -INSTANTIATE_TEST_CASE_P(smoke_Squeeze_Basic, SqueezeUnsqueezeLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Squeeze_Basic, SqueezeUnsqueezeLayerTest, ::testing::Combine( ::testing::ValuesIn(CommonTestUtils::combineParams(axesVectors)), ::testing::ValuesIn(opTypes), diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/tensor_iterator.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/tensor_iterator.cpp index 5c2ba098b0567f..b76879ef12fcee 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/tensor_iterator.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/tensor_iterator.cpp @@ -27,7 +27,7 @@ const std::vector clip = {0.f}; const std::vector direction = { ngraph::op::RecurrentSequenceDirection::FORWARD, ngraph::op::RecurrentSequenceDirection::REVERSE}; -INSTANTIATE_TEST_CASE_P(smoke_TensorIterator, TensorIteratorTest, +INSTANTIATE_TEST_SUITE_P(smoke_TensorIterator, TensorIteratorTest, ::testing::Combine( ::testing::ValuesIn(decompose), ::testing::ValuesIn(sequenceLength), diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/transpose.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/transpose.cpp index 4fd458c12441b1..8b9b2be7bd1b47 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/transpose.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/transpose.cpp @@ -23,7 +23,7 @@ const std::vector netPrecisions = { std::vector> inputShape2D = {{2, 10}, {10, 2}, {10, 10}}; std::vector> order2D = {{}, {0, 1}, {1, 0}}; -INSTANTIATE_TEST_CASE_P(smoke_Transpose2D, TransposeLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Transpose2D, TransposeLayerTest, ::testing::Combine( ::testing::ValuesIn(order2D), ::testing::ValuesIn(netPrecisions), @@ -40,7 +40,7 @@ std::vector> order4D = { {}, {0, 1, 2, 3} }; -INSTANTIATE_TEST_CASE_P(smoke_Transpose4D, TransposeLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Transpose4D, TransposeLayerTest, ::testing::Combine( ::testing::ValuesIn(order4D), ::testing::ValuesIn(netPrecisions), @@ -57,7 +57,7 @@ std::vector> order5D = { {}, {0, 1, 2, 3, 4} }; -INSTANTIATE_TEST_CASE_P(smoke_Transpose5D, TransposeLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Transpose5D, TransposeLayerTest, ::testing::Combine( ::testing::ValuesIn(order5D), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/unsqueeze.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/unsqueeze.cpp index 2e26a70d6274c7..bd62fd2dcc4c1c 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/unsqueeze.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/unsqueeze.cpp @@ -32,7 +32,7 @@ const std::vector netPrecisions = { const std::vector opTypes = { ngraph::helpers::SqueezeOpType::UNSQUEEZE}; -INSTANTIATE_TEST_CASE_P(smoke_Squeeze_Basic, SqueezeUnsqueezeLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Squeeze_Basic, SqueezeUnsqueezeLayerTest, ::testing::Combine( ::testing::ValuesIn(CommonTestUtils::combineParams(axesVectors)), ::testing::ValuesIn(opTypes), diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/variadic_split.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/variadic_split.cpp index 117d7ccbb52f4e..ed8b1edea41317 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/variadic_split.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/variadic_split.cpp @@ -24,7 +24,7 @@ namespace { {1, 16, 5, 8}, }; - INSTANTIATE_TEST_CASE_P(smoke_VariadicSplitSerialization, VariadicSplitLayerTest, + INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplitSerialization, VariadicSplitLayerTest, ::testing::Combine( ::testing::ValuesIn(numSplits), ::testing::Values(0, 1, 2, 3), diff --git a/inference-engine/tests/functional/inference_engine/task_executor_tests.cpp b/inference-engine/tests/functional/inference_engine/task_executor_tests.cpp index d3ffda26614b47..c4fe68a87b7e15 100644 --- a/inference-engine/tests/functional/inference_engine/task_executor_tests.cpp +++ b/inference-engine/tests/functional/inference_engine/task_executor_tests.cpp @@ -198,7 +198,7 @@ static auto Executors = ::testing::Values( } ); -INSTANTIATE_TEST_CASE_P(TaskExecutorTests, TaskExecutorTests, Executors); +INSTANTIATE_TEST_SUITE_P(TaskExecutorTests, TaskExecutorTests, Executors); static auto AsyncExecutors = ::testing::Values( [] { @@ -209,5 +209,5 @@ static auto AsyncExecutors = ::testing::Values( } ); -INSTANTIATE_TEST_CASE_P(ASyncTaskExecutorTests, ASyncTaskExecutorTests, AsyncExecutors); +INSTANTIATE_TEST_SUITE_P(ASyncTaskExecutorTests, ASyncTaskExecutorTests, AsyncExecutors); diff --git a/inference-engine/tests/functional/inference_engine/transformations/broadcast_elementwise_fusion_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/broadcast_elementwise_fusion_test.cpp index 324bfae029b890..a9667226068d27 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/broadcast_elementwise_fusion_test.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/broadcast_elementwise_fusion_test.cpp @@ -238,32 +238,32 @@ TEST_P(NoEliminateDynamicBroadcastTest, CompareFunctions) { eliminate_broadcast_test(f, f_ref); } -INSTANTIATE_TEST_CASE_P(EliminateBroadcast, EliminateBroadcastTest, +INSTANTIATE_TEST_SUITE_P(EliminateBroadcast, EliminateBroadcastTest, testing::Values(std::make_tuple(InputShape{1, 2, 3}, InputShape{1, 2, 3}, TargetShape{1, 2, 3}), std::make_tuple(InputShape{DYN, 2, 3}, InputShape{1, 2, 3}, TargetShape{1, 2, 3}), std::make_tuple(InputShape{DYN, DYN, DYN}, InputShape{1, 1, 1}, TargetShape{1, 1, 1}), std::make_tuple(InputShape{1, 2, 3}, InputShape{2, 3}, TargetShape{2, 3}), std::make_tuple(InputShape{1, 2, 1}, InputShape{1}, TargetShape{1}))); -INSTANTIATE_TEST_CASE_P(EliminateBroadcastSwapInputs, EliminateBroadcastSwapInputsTest, +INSTANTIATE_TEST_SUITE_P(EliminateBroadcastSwapInputs, EliminateBroadcastSwapInputsTest, testing::Values(std::make_tuple(InputShape{1, 2, 3}, InputShape{1, 2, 3}, TargetShape{1, 2, 3}), std::make_tuple(InputShape{DYN, 2, 3}, InputShape{1, 2, 3}, TargetShape{1, 2, 3}), std::make_tuple(InputShape{DYN, DYN, DYN}, InputShape{1, 1, 1}, TargetShape{1, 1, 1}), std::make_tuple(InputShape{1, 2, 3}, InputShape{2, 3}, TargetShape{2, 3}), std::make_tuple(InputShape{1, 2, 1}, InputShape{1}, TargetShape{1}))); -INSTANTIATE_TEST_CASE_P(NoEliminateBroadcast, NoEliminateBroadcastTest, +INSTANTIATE_TEST_SUITE_P(NoEliminateBroadcast, NoEliminateBroadcastTest, testing::Values(std::make_tuple(InputShape{1, 2, 1}, InputShape{3}, TargetShape{3}), std::make_tuple(InputShape{DYN, 2, 3}, InputShape{3, 2, 3}, TargetShape{3, 2, 3}), std::make_tuple(InputShape{DYN, DYN, DYN}, InputShape{3, 2, 1}, TargetShape{3, 2, 1}), std::make_tuple(ngraph::PartialShape::dynamic(), InputShape{1, 2, 3}, TargetShape{1, 2, 3}), std::make_tuple(ngraph::PartialShape::dynamic(), ngraph::PartialShape::dynamic(), TargetShape{1, 2, 3}))); -INSTANTIATE_TEST_CASE_P(EliminateDynamicBroadcast, EliminateDynamicBroadcastTest, +INSTANTIATE_TEST_SUITE_P(EliminateDynamicBroadcast, EliminateDynamicBroadcastTest, testing::Values(std::make_tuple(InputShape{2, 2, 4}, InputShape{2, DYN, 4}, InputShape{2, DYN, 4}, InputShape{2, DYN, 4}), std::make_tuple(InputShape{2, 2, 4}, InputShape{DYN, DYN, DYN}, InputShape{DYN, DYN, DYN}, InputShape{DYN, DYN, DYN}), std::make_tuple(InputShape{2, 2, 4}, InputShape{2, 2, 4}, InputShape{2, DYN, 4}, InputShape{2, 2, 4}))); -INSTANTIATE_TEST_CASE_P(NoEliminateDynamicBroadcast, NoEliminateDynamicBroadcastTest, +INSTANTIATE_TEST_SUITE_P(NoEliminateDynamicBroadcast, NoEliminateDynamicBroadcastTest, testing::Values(std::make_tuple(InputShape{2, 1, 4}, InputShape{2, DYN, 4}, InputShape{2, DYN, 4}), std::make_tuple(InputShape{2, DYN, 4}, InputShape{2, DYN, 4}, InputShape{2, DYN, 4}))); diff --git a/inference-engine/tests/functional/inference_engine/transformations/conv_fusion_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/conv_fusion_test.cpp index b12a0f6f9de0e6..9610df3e6ba018 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/conv_fusion_test.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/conv_fusion_test.cpp @@ -125,7 +125,7 @@ TEST_P(ConvFusionTests, CompareFunctions) { using add = ngraph::opset5::Add; using mul = ngraph::opset5::Multiply; -INSTANTIATE_TEST_CASE_P(ConvAddFusion, ConvFusionTests, +INSTANTIATE_TEST_SUITE_P(ConvAddFusion, ConvFusionTests, testing::Values(std::make_tuple(InputShape{DYN, DYN, DYN, DYN, DYN}, WeightsShape{8, 3, 1, 2, 3}, add::type_info, EltwiseShape{8, 1, 1, 1}, false), std::make_tuple(InputShape{DYN, 3, 64, 64, 64}, WeightsShape{8, 3, 1, 2, 3}, add::type_info, EltwiseShape{8, 1, 1, 1}, false), std::make_tuple(InputShape{2, DYN, 64, 64, 64}, WeightsShape{9, 3, 2, 3, 1}, add::type_info, EltwiseShape{9, 1, 1, 1}, false), @@ -143,12 +143,12 @@ INSTANTIATE_TEST_CASE_P(ConvAddFusion, ConvFusionTests, std::make_tuple(InputShape{2, DYN, 9}, WeightsShape{2, 3, 2}, add::type_info, EltwiseShape{2, 1}, false), std::make_tuple(InputShape{3, 3, DYN}, WeightsShape{1, 3, 3}, add::type_info, EltwiseShape{1, 1}, false))); -INSTANTIATE_TEST_CASE_P(DISABLED_ConvAddFusionNegative, ConvFusionTests, +INSTANTIATE_TEST_SUITE_P(DISABLED_ConvAddFusionNegative, ConvFusionTests, testing::Values(std::make_tuple(InputShape{DYN, DYN, DYN, DYN, DYN}, WeightsShape{8, 3, 1, 2, 3}, add::type_info, EltwiseShape{2, 1}, true), std::make_tuple(InputShape{DYN, 3, 64, 64, 64}, WeightsShape{8, 3, 1, 2, 3}, add::type_info, EltwiseShape{8, 1, 1}, true), std::make_tuple(InputShape{2, DYN, 64, 64, 64}, WeightsShape{9, 3, 2, 3, 1}, add::type_info, EltwiseShape{9, 1, 1, 1, 1}, true))); -INSTANTIATE_TEST_CASE_P(DISABLED_ConvMulFusion, ConvFusionTests, +INSTANTIATE_TEST_SUITE_P(DISABLED_ConvMulFusion, ConvFusionTests, testing::Values(std::make_tuple(InputShape{DYN, DYN, DYN, DYN, DYN}, WeightsShape{8, 3, 1, 2, 3}, mul::type_info, EltwiseShape{8, 1, 1, 1}, false), std::make_tuple(InputShape{DYN, 3, 64, 64, 64}, WeightsShape{8, 3, 1, 2, 3}, mul::type_info, EltwiseShape{8, 1, 1, 1}, false), std::make_tuple(InputShape{2, DYN, 64, 64, 64}, WeightsShape{9, 3, 2, 3, 1}, mul::type_info, EltwiseShape{9, 1, 1, 1}, false), @@ -166,7 +166,7 @@ INSTANTIATE_TEST_CASE_P(DISABLED_ConvMulFusion, ConvFusionTests, std::make_tuple(InputShape{2, DYN, 9}, WeightsShape{2, 3, 2}, mul::type_info, EltwiseShape{2, 1}, false), std::make_tuple(InputShape{3, 3, DYN}, WeightsShape{1, 3, 3}, mul::type_info, EltwiseShape{1, 1}, false))); -INSTANTIATE_TEST_CASE_P(DISABLED_ConvMulFusionNegative, ConvFusionTests, +INSTANTIATE_TEST_SUITE_P(DISABLED_ConvMulFusionNegative, ConvFusionTests, testing::Values(std::make_tuple(InputShape{DYN, DYN, DYN, DYN, DYN}, WeightsShape{8, 3, 1, 2, 3}, mul::type_info, EltwiseShape{2, 1}, true), std::make_tuple(InputShape{DYN, 3, 64, 64}, WeightsShape{8, 3, 1, 2, 3}, mul::type_info, EltwiseShape{8, 1, 1}, true), std::make_tuple(InputShape{2, DYN, 64, 64}, WeightsShape{9, 3, 2, 3, 1}, mul::type_info, EltwiseShape{9, 1, 1, 1, 1}, true))); diff --git a/inference-engine/tests/functional/inference_engine/transformations/convert_broadcast3_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/convert_broadcast3_test.cpp index 7058f52eb5ce42..95b54fe0461174 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/convert_broadcast3_test.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/convert_broadcast3_test.cpp @@ -223,7 +223,7 @@ TEST_P(ConvertBroadcast3BIDIRECTBroadcastLogicalOrTest, CompareFunctions) { convert_broadcast3_test(f, f_ref); } -INSTANTIATE_TEST_CASE_P(ConvertBroadcast3NUMPY, ConvertBroadcast3NUMPYTest, +INSTANTIATE_TEST_SUITE_P(ConvertBroadcast3NUMPY, ConvertBroadcast3NUMPYTest, testing::Values(std::make_tuple(InputShape{DYN, DYN, DYN, DYN, DYN}, TargetShape{1, 2, 3, 4, 5}), std::make_tuple(InputShape{DYN, 3, 64, 64, 64}, TargetShape{8, 3, 64, 64, 64}), std::make_tuple(InputShape{2, DYN, 64, 64, 64}, TargetShape{2, 3, 64, 64, 64}), @@ -241,7 +241,7 @@ INSTANTIATE_TEST_CASE_P(ConvertBroadcast3NUMPY, ConvertBroadcast3NUMPYTest, std::make_tuple(InputShape{2, DYN, 9}, TargetShape{2, 3, 9}), std::make_tuple(InputShape{3, 3, DYN}, TargetShape{3, 3, 3}))); -INSTANTIATE_TEST_CASE_P(ConvertBroadcast3BIDIRECT, ConvertBroadcast3BIDIRECTMulTest, +INSTANTIATE_TEST_SUITE_P(ConvertBroadcast3BIDIRECT, ConvertBroadcast3BIDIRECTMulTest, testing::Values(std::make_tuple(InputShape{DYN, DYN, DYN, DYN, DYN}, TargetShape{1, 2, 3, 4, 5}), std::make_tuple(InputShape{DYN, 3, 64, 64, 64}, TargetShape{1, 3, 64, 64, 64}), std::make_tuple(InputShape{2, DYN, 64, 64, 64}, TargetShape{2, 1, 64, 64, 64}), @@ -261,7 +261,7 @@ INSTANTIATE_TEST_CASE_P(ConvertBroadcast3BIDIRECT, ConvertBroadcast3BIDIRECTMulT std::make_tuple(InputShape{2, DYN, 9}, TargetShape{2, 1, 9}), std::make_tuple(InputShape{3, 3, DYN}, TargetShape{3, 3, 1}))); -INSTANTIATE_TEST_CASE_P(ConvertBroadcast3BIDIRECT, ConvertBroadcast3BIDIRECTBroadcastTest, +INSTANTIATE_TEST_SUITE_P(ConvertBroadcast3BIDIRECT, ConvertBroadcast3BIDIRECTBroadcastTest, testing::Values(std::make_tuple(InputShape{DYN, DYN, DYN, DYN, DYN}, TargetShape{2, 2, 3, 4, 5}, TargetShape{2, 2, 3, 4, 5}), std::make_tuple(InputShape{DYN, 3, 64, 64, 64}, TargetShape{3, 3, 64, 64, 64}, TargetShape{3, 3, 64, 64, 64}), std::make_tuple(InputShape{2, DYN, 64, 64, 64}, TargetShape{2, 3, 64, 64, 1}, TargetShape{2, 3, 64, 64, 64}), @@ -280,7 +280,7 @@ INSTANTIATE_TEST_CASE_P(ConvertBroadcast3BIDIRECT, ConvertBroadcast3BIDIRECTBroa std::make_tuple(InputShape{2, DYN, 9}, TargetShape{2, 2, 1}, TargetShape{2, 2, 9}), std::make_tuple(InputShape{3, 3, DYN}, TargetShape{3}, TargetShape{3, 3, 3}))); -INSTANTIATE_TEST_CASE_P(ConvertBroadcast3BIDIRECT, ConvertBroadcast3BIDIRECTBroadcastMultiplyTest, +INSTANTIATE_TEST_SUITE_P(ConvertBroadcast3BIDIRECT, ConvertBroadcast3BIDIRECTBroadcastMultiplyTest, testing::Values(std::make_tuple(InputShape{DYN, DYN, DYN, DYN, DYN}, TargetShape{5}), std::make_tuple(InputShape{DYN, 3, 64, 64, 64}, TargetShape{4}), std::make_tuple(InputShape{2, DYN, 64, 64, 64}, TargetShape{3}), @@ -296,7 +296,7 @@ INSTANTIATE_TEST_CASE_P(ConvertBroadcast3BIDIRECT, ConvertBroadcast3BIDIRECTBroa std::make_tuple(InputShape{2, DYN, 9}, TargetShape{3}), std::make_tuple(InputShape{3, 3, DYN}, TargetShape{2}))); -INSTANTIATE_TEST_CASE_P(ConvertBroadcast3BIDIRECT, ConvertBroadcast3BIDIRECTBroadcastLogicalOrTest, +INSTANTIATE_TEST_SUITE_P(ConvertBroadcast3BIDIRECT, ConvertBroadcast3BIDIRECTBroadcastLogicalOrTest, testing::Values(std::make_tuple(InputShape{DYN, DYN, DYN, DYN, DYN}, TargetShape{5}), std::make_tuple(InputShape{DYN, 3, 64, 64, 64}, TargetShape{4}), std::make_tuple(InputShape{2, DYN, 64, 64, 64}, TargetShape{3}), diff --git a/inference-engine/tests/functional/inference_engine/transformations/convert_convolution_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/convert_convolution_test.cpp index 43bd10eccd1aa4..1a8e196be5950e 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/convert_convolution_test.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/convert_convolution_test.cpp @@ -80,7 +80,7 @@ TEST_P(ConvertConvolutionTest, CompareFunctions) { ASSERT_TRUE(orig_shape.same_scheme(f->get_output_partial_shape(0))) << "Shape " << orig_shape << " is not equal to " << f->get_output_partial_shape(0); } -INSTANTIATE_TEST_CASE_P(ConvertConvolution, ConvertConvolutionTest, +INSTANTIATE_TEST_SUITE_P(ConvertConvolution, ConvertConvolutionTest, testing::Values(std::make_tuple(InputShape{DYN, DYN, DYN, DYN, DYN}, WeightsShape{8, 3, 1, 2, 3}), std::make_tuple(InputShape{DYN, 3, 64, 64, 64}, WeightsShape{8, 3, 1, 2, 3}), std::make_tuple(InputShape{2, DYN, 64, 64, 64}, WeightsShape{9, 3, 2, 3, 1}), diff --git a/inference-engine/tests/functional/inference_engine/transformations/convert_deconvolution_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/convert_deconvolution_test.cpp index 51f60318f1824a..3c456c7f083c6d 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/convert_deconvolution_test.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/convert_deconvolution_test.cpp @@ -76,7 +76,7 @@ TEST_P(ConvertDeconvolutionTest, CompareFunctions) { ASSERT_TRUE(orig_shape.same_scheme(f->get_output_partial_shape(0))) << "Shape " << orig_shape << " is not equal to " << f->get_output_partial_shape(0); } -INSTANTIATE_TEST_CASE_P(ConvertDeconvolution, ConvertDeconvolutionTest, +INSTANTIATE_TEST_SUITE_P(ConvertDeconvolution, ConvertDeconvolutionTest, testing::Values(std::make_tuple(InputShape{DYN, DYN, DYN, DYN, DYN}, WeightsShape{3, 8, 1, 2, 3}), std::make_tuple(InputShape{DYN, 3, 64, 64, 64}, WeightsShape{3, 8, 1, 2, 3}), std::make_tuple(InputShape{2, DYN, 64, 64, 64}, WeightsShape{3, 9, 2, 3, 1}), diff --git a/inference-engine/tests/functional/inference_engine/transformations/convert_reduce_to_pooling_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/convert_reduce_to_pooling_test.cpp index 813fe6a7dbf182..34b287a47bc7dc 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/convert_reduce_to_pooling_test.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/convert_reduce_to_pooling_test.cpp @@ -121,17 +121,17 @@ TEST_P(ConvertReduceToPoolingTests, CompareFunctions) { #define MAX std::make_shared() -INSTANTIATE_TEST_CASE_P(ReduceToMaxPooling, ConvertReduceToPoolingTests, +INSTANTIATE_TEST_SUITE_P(ReduceToMaxPooling, ConvertReduceToPoolingTests, testing::Values(std::make_tuple(MAX, InputShape{2, 3, 64, 64}, ReduceAxes{3}, KeepDims{true}, ReduceToPoolParams({}, {1, 64}, {})), std::make_tuple(MAX, InputShape{2, 3, 64, 64}, ReduceAxes{3, 2}, KeepDims{true}, ReduceToPoolParams({}, {64, 64}, {})))); -INSTANTIATE_TEST_CASE_P(ReduceToReshape, ConvertReduceToPoolingTests, +INSTANTIATE_TEST_SUITE_P(ReduceToReshape, ConvertReduceToPoolingTests, testing::Values(std::make_tuple(MAX, InputShape{2, 3, 64, 1}, ReduceAxes{3}, KeepDims{false}, ReduceToPoolParams({1, 3, 64}, {}, {})), std::make_tuple(MAX, InputShape{2, 3}, ReduceAxes{-2}, KeepDims{false}, ReduceToPoolParams({3}, {}, {})), std::make_tuple(MAX, InputShape{2, 3, 1}, ReduceAxes{2}, KeepDims{false}, ReduceToPoolParams({1, 3}, {}, {})), std::make_tuple(MAX, InputShape{2, 3, 1, 1}, ReduceAxes{0, 3, 2}, KeepDims{false}, ReduceToPoolParams({3}, {}, {})))); -INSTANTIATE_TEST_CASE_P(ReduceToReshapePoolReshape, ConvertReduceToPoolingTests, +INSTANTIATE_TEST_SUITE_P(ReduceToReshapePoolReshape, ConvertReduceToPoolingTests, testing::Values(std::make_tuple(MAX, InputShape{2, 3, 3}, ReduceAxes{1, 2}, KeepDims{false}, ReduceToPoolParams({1, 1, 9, 1}, {9, 1}, {1})), std::make_tuple(MAX, InputShape{2, 9}, ReduceAxes{-1}, KeepDims{true}, ReduceToPoolParams({1, 1, 9, 1}, {9, 1}, {1, 1})), std::make_tuple(MAX, InputShape{2, 3, 4, 1}, ReduceAxes{1, 3, 2}, KeepDims{false}, ReduceToPoolParams({1, 1, 12, 1}, {12, 1}, {1})))); diff --git a/inference-engine/tests/functional/inference_engine/transformations/eliminate_unsqueeze_gather.cpp b/inference-engine/tests/functional/inference_engine/transformations/eliminate_unsqueeze_gather.cpp index 526695879d8908..cc91018e1555a9 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/eliminate_unsqueeze_gather.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/eliminate_unsqueeze_gather.cpp @@ -71,7 +71,7 @@ class EliminateUnsqueezeGatherTest : public CommonTestUtils::TestsCommon, TEST_P(EliminateUnsqueezeGatherTest, CompareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, EliminateUnsqueezeGatherTest, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, EliminateUnsqueezeGatherTest, testing::Combine( testing::Values( ngraph::element::f16, ngraph::element::f32, diff --git a/inference-engine/tests/functional/inference_engine/transformations/fq_decomposition_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/fq_decomposition_test.cpp index d5b49446232faf..91d218924db641 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/fq_decomposition_test.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/fq_decomposition_test.cpp @@ -186,28 +186,28 @@ const auto broadcast_6D_fq_basic = ::testing::Combine(::testing::ValuesIn(precis ::testing::Values(ngraph::Shape{1, 1, 1, 5, 6, 7}), ::testing::ValuesIn(levels)); -INSTANTIATE_TEST_CASE_P(SimpleFakeQuantize_Decomposition, FakeQuantizeDecompositionTest, +INSTANTIATE_TEST_SUITE_P(SimpleFakeQuantize_Decomposition, FakeQuantizeDecompositionTest, ::testing::Combine( simple_fq_basic, ::testing::ValuesIn(input_ranges_supported), ::testing::Values(true)), FakeQuantizeDecompositionTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(BroadcastFakeQuantize_Decomposition, FakeQuantizeDecompositionTest, +INSTANTIATE_TEST_SUITE_P(BroadcastFakeQuantize_Decomposition, FakeQuantizeDecompositionTest, ::testing::Combine( broadcast_fq_basic, ::testing::ValuesIn(input_ranges_supported), ::testing::Values(true)), FakeQuantizeDecompositionTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(ElementwiseFakeQuantize_Decomposition, FakeQuantizeDecompositionTest, +INSTANTIATE_TEST_SUITE_P(ElementwiseFakeQuantize_Decomposition, FakeQuantizeDecompositionTest, ::testing::Combine( elementwise_fq_basic, ::testing::ValuesIn(input_ranges_supported), ::testing::Values(true)), FakeQuantizeDecompositionTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(FakeQuantize6D_Decomposition, FakeQuantizeDecompositionTest, +INSTANTIATE_TEST_SUITE_P(FakeQuantize6D_Decomposition, FakeQuantizeDecompositionTest, ::testing::Combine( broadcast_6D_fq_basic, ::testing::ValuesIn(input_ranges_supported), @@ -220,28 +220,28 @@ const std::vector> input_ranges_unsupported = { {-5.0f, -5.0f} }; -INSTANTIATE_TEST_CASE_P(SimpleFakeQuantize_NoDecomposition, FakeQuantizeDecompositionTest, +INSTANTIATE_TEST_SUITE_P(SimpleFakeQuantize_NoDecomposition, FakeQuantizeDecompositionTest, ::testing::Combine( simple_fq_basic, ::testing::ValuesIn(input_ranges_unsupported), ::testing::Values(false)), FakeQuantizeDecompositionTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(BroadcastFakeQuantize_NoDecomposition, FakeQuantizeDecompositionTest, +INSTANTIATE_TEST_SUITE_P(BroadcastFakeQuantize_NoDecomposition, FakeQuantizeDecompositionTest, ::testing::Combine( broadcast_fq_basic, ::testing::ValuesIn(input_ranges_unsupported), ::testing::Values(false)), FakeQuantizeDecompositionTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(ElementwiseFakeQuantize_NoDecomposition, FakeQuantizeDecompositionTest, +INSTANTIATE_TEST_SUITE_P(ElementwiseFakeQuantize_NoDecomposition, FakeQuantizeDecompositionTest, ::testing::Combine( elementwise_fq_basic, ::testing::ValuesIn(input_ranges_unsupported), ::testing::Values(false)), FakeQuantizeDecompositionTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(FakeQuantize6D_NoDecomposition, FakeQuantizeDecompositionTest, +INSTANTIATE_TEST_SUITE_P(FakeQuantize6D_NoDecomposition, FakeQuantizeDecompositionTest, ::testing::Combine( broadcast_6D_fq_basic, ::testing::ValuesIn(input_ranges_unsupported), diff --git a/inference-engine/tests/functional/inference_engine/transformations/fq_mul_fusion_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/fq_mul_fusion_test.cpp index 920f2aa8954eb5..57135f0285a3b6 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/fq_mul_fusion_test.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/fq_mul_fusion_test.cpp @@ -92,84 +92,84 @@ TEST_P(FQMulFusion, ExpectFusion) { }; namespace { -INSTANTIATE_TEST_CASE_P(ScalarFQParams_C6_4D_channel_0, FQMulFusion, +INSTANTIATE_TEST_SUITE_P(ScalarFQParams_C6_4D_channel_0, FQMulFusion, ::testing::Combine(::testing::Values(ngraph::Shape{64, 3, 7, 7}), ::testing::Values(ngraph::Shape{}), ::testing::Values(ngraph::Shape{}), ::testing::Values(ngraph::Shape{64, 1, 1, 1}), ::testing::Values(ngraph::Shape{64, 1, 1, 1}))); -INSTANTIATE_TEST_CASE_P(ScalarFQParams_C6_4D_channel_1, FQMulFusion, +INSTANTIATE_TEST_SUITE_P(ScalarFQParams_C6_4D_channel_1, FQMulFusion, ::testing::Combine(::testing::Values(ngraph::Shape{64, 3, 7, 7}), ::testing::Values(ngraph::Shape{}), ::testing::Values(ngraph::Shape{}), ::testing::Values(ngraph::Shape{1, 3, 1, 1}), ::testing::Values(ngraph::Shape{1, 3, 1, 1}))); -INSTANTIATE_TEST_CASE_P(ScalarFQParams_C6_scalar, FQMulFusion, +INSTANTIATE_TEST_SUITE_P(ScalarFQParams_C6_scalar, FQMulFusion, ::testing::Combine(::testing::Values(ngraph::Shape{64, 3, 7, 7}), ::testing::Values(ngraph::Shape{}), ::testing::Values(ngraph::Shape{}), ::testing::Values(ngraph::Shape{}), ::testing::Values(ngraph::Shape{}))); -INSTANTIATE_TEST_CASE_P(FQOutputs1D_C6_scalar, FQMulFusion, +INSTANTIATE_TEST_SUITE_P(FQOutputs1D_C6_scalar, FQMulFusion, ::testing::Combine(::testing::Values(ngraph::Shape{64, 3, 7, 7}), ::testing::Values(ngraph::Shape{}), ::testing::Values(ngraph::Shape{1}), ::testing::Values(ngraph::Shape{}), ::testing::Values(ngraph::Shape{1}))); -INSTANTIATE_TEST_CASE_P(FQOutputs_NHWC_C6_scalar, FQMulFusion, +INSTANTIATE_TEST_SUITE_P(FQOutputs_NHWC_C6_scalar, FQMulFusion, ::testing::Combine(::testing::Values(ngraph::Shape{1, 7, 7, 3}), ::testing::Values(ngraph::Shape{}), ::testing::Values(ngraph::Shape{1, 1, 1, 3}), ::testing::Values(ngraph::Shape{}), ::testing::Values(ngraph::Shape{1, 1, 1, 3}))); -INSTANTIATE_TEST_CASE_P(FQOutputs_NCHW_C6_scalar, FQMulFusion, +INSTANTIATE_TEST_SUITE_P(FQOutputs_NCHW_C6_scalar, FQMulFusion, ::testing::Combine(::testing::Values(ngraph::Shape{1, 3, 7, 7}), ::testing::Values(ngraph::Shape{}), ::testing::Values(ngraph::Shape{1, 3, 1, 1}), ::testing::Values(ngraph::Shape{}), ::testing::Values(ngraph::Shape{1, 3, 1, 1}))); -INSTANTIATE_TEST_CASE_P(FQInputs_4D_with_channel_dimension, FQMulFusion, +INSTANTIATE_TEST_SUITE_P(FQInputs_4D_with_channel_dimension, FQMulFusion, ::testing::Combine(::testing::Values(ngraph::Shape{1, 64, 3, 3}), ::testing::Values(ngraph::Shape{1, 1, 1, 1}), ::testing::Values(ngraph::Shape{1, 64, 1, 1}), ::testing::Values(ngraph::Shape{1, 64, 1, 1}), ::testing::Values(ngraph::Shape{1, 64, 1, 1}))); -INSTANTIATE_TEST_CASE_P(FQInputs_4D_per__multiplier_with_channel, FQMulFusion, +INSTANTIATE_TEST_SUITE_P(FQInputs_4D_per__multiplier_with_channel, FQMulFusion, ::testing::Combine(::testing::Values(ngraph::Shape{1, 64, 3, 3}), ::testing::Values(ngraph::Shape{1, 1, 1, 1}), ::testing::Values(ngraph::Shape{1, 1, 1, 1}), ::testing::Values(ngraph::Shape{1, 64, 1, 1}), ::testing::Values(ngraph::Shape{1, 64, 1, 1}))); -INSTANTIATE_TEST_CASE_P(FQInputs_4D_with_channel__multiplier_4D_per_tensor, FQMulFusion, +INSTANTIATE_TEST_SUITE_P(FQInputs_4D_with_channel__multiplier_4D_per_tensor, FQMulFusion, ::testing::Combine(::testing::Values(ngraph::Shape{1, 64, 3, 3}), ::testing::Values(ngraph::Shape{1, 1, 1, 1}), ::testing::Values(ngraph::Shape{1, 64, 1, 1}), ::testing::Values(ngraph::Shape{1, 1, 1, 1}), ::testing::Values(ngraph::Shape{1, 64, 1, 1}))); -INSTANTIATE_TEST_CASE_P(FQInputs_4D__multiplier_channel_3rd_dim, FQMulFusion, +INSTANTIATE_TEST_SUITE_P(FQInputs_4D__multiplier_channel_3rd_dim, FQMulFusion, ::testing::Combine(::testing::Values(ngraph::Shape{1, 64, 3, 3}), ::testing::Values(ngraph::Shape{1, 1, 1, 1}), ::testing::Values(ngraph::Shape{1, 64, 1, 1}), ::testing::Values(ngraph::Shape{1, 1, 3, 1}), ::testing::Values(ngraph::Shape{1, 64, 3, 1}))); -INSTANTIATE_TEST_CASE_P(FQOutputs_1D__multiplier_3D, FQMulFusion, +INSTANTIATE_TEST_SUITE_P(FQOutputs_1D__multiplier_3D, FQMulFusion, ::testing::Combine(::testing::Values(ngraph::Shape{1, 64, 3, 3}), ::testing::Values(ngraph::Shape{1, 64, 1, 1}), ::testing::Values(ngraph::Shape{1}), ::testing::Values(ngraph::Shape{1, 3, 1}), ::testing::Values(ngraph::Shape{1, 3, 1}))); -INSTANTIATE_TEST_CASE_P(FQInOUt_ones__multiplier_4D_with_channel, FQMulFusion, +INSTANTIATE_TEST_SUITE_P(FQInOUt_ones__multiplier_4D_with_channel, FQMulFusion, ::testing::Combine(::testing::Values(ngraph::Shape{1, 64, 3, 3}), ::testing::Values(ngraph::Shape{1, 1, 1, 1}), ::testing::Values(ngraph::Shape{1, 1, 1, 1}), diff --git a/inference-engine/tests/functional/inference_engine/transformations/fq_reshape_fusion.cpp b/inference-engine/tests/functional/inference_engine/transformations/fq_reshape_fusion.cpp index 5fe78681594042..4f0760923471e6 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/fq_reshape_fusion.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/fq_reshape_fusion.cpp @@ -113,7 +113,7 @@ TEST_P(nGraphFQReshapeFusionTests, ReshapeMatMul) { ASSERT_TRUE(res.first) << res.second; } -INSTANTIATE_TEST_CASE_P(NGraph, nGraphFQReshapeFusionTests, testing::Values( +INSTANTIATE_TEST_SUITE_P(NGraph, nGraphFQReshapeFusionTests, testing::Values( // positive FQReshapeFusionTestCase{{1, 2, 1, 3}, {2, 1, 1}, {1}, {1, 1}, {1, 2, 1, 1}, {2, 3}, {2, 1}, {1, 1}, DO_NOT_RESHAPE, {2, 1}, false}, FQReshapeFusionTestCase{{1, 2, 1, 3}, {2, 1, 1}, {1}, {1, 1}, {1, 2, 1, 1}, {1, 2, 1, 3}, {1, 2, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, DO_NOT_RESHAPE, false}, diff --git a/inference-engine/tests/functional/inference_engine/transformations/mul_add_conversion_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/mul_add_conversion_test.cpp index 22c18407a0743c..8da572786cd121 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/mul_add_conversion_test.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/mul_add_conversion_test.cpp @@ -176,7 +176,7 @@ TEST_P(MulOrAddConversionTests, CompareFunctions) { #define ELTWISE_SUM MulAddConversionTests::get_eltwise_add_reference #define ELTWISE_PROD MulAddConversionTests::get_eltwise_mul_reference -INSTANTIATE_TEST_CASE_P(MulAddToScaleShift, MulAddConversionTests, testing::Combine( +INSTANTIATE_TEST_SUITE_P(MulAddToScaleShift, MulAddConversionTests, testing::Combine( testing::Values(std::make_tuple(InputShape{DYN, 3, 64, 64}, CONST(ngraph::Shape({1, 3, 1, 1}), 0.5), CONST(ngraph::Shape({1, 3, 1, 1}), 0.5), false), @@ -188,7 +188,7 @@ INSTANTIATE_TEST_CASE_P(MulAddToScaleShift, MulAddConversionTests, testing::Comb CONST(ngraph::Shape({1, 3, 1, 1}), 0.5), false)), testing::Values(SCALESHIFT))); -INSTANTIATE_TEST_CASE_P(MulToScaleShift, MulOrAddConversionTests, testing::Combine( +INSTANTIATE_TEST_SUITE_P(MulToScaleShift, MulOrAddConversionTests, testing::Combine( testing::Values(std::make_tuple(InputShape{DYN, 3, 64, 64}, CONST(ngraph::Shape({1, 3, 1, 1}), 0.5), NONE, false), @@ -200,7 +200,7 @@ INSTANTIATE_TEST_CASE_P(MulToScaleShift, MulOrAddConversionTests, testing::Combi NONE, false)), testing::Values(SCALESHIFT))); -INSTANTIATE_TEST_CASE_P(AddToScaleShift, MulOrAddConversionTests, testing::Combine( +INSTANTIATE_TEST_SUITE_P(AddToScaleShift, MulOrAddConversionTests, testing::Combine( testing::Values(std::make_tuple(InputShape{DYN, 3, 64, 64}, NONE, CONST(ngraph::Shape({1, 3, 1, 1}), 0.5), false), @@ -212,7 +212,7 @@ INSTANTIATE_TEST_CASE_P(AddToScaleShift, MulOrAddConversionTests, testing::Combi CONST(ngraph::Shape({1, 3, 1, 1}), 0.5), false)), testing::Values(SCALESHIFT))); -INSTANTIATE_TEST_CASE_P(MulAddToPower, MulAddConversionTests, testing::Combine( +INSTANTIATE_TEST_SUITE_P(MulAddToPower, MulAddConversionTests, testing::Combine( testing::Values(std::make_tuple(InputShape{DYN, 3, 64, 64}, CONST(ngraph::Shape({1}), 0.5), CONST(ngraph::Shape({1}), 0.5), false), @@ -224,7 +224,7 @@ INSTANTIATE_TEST_CASE_P(MulAddToPower, MulAddConversionTests, testing::Combine( CONST(ngraph::Shape({1}), 0.5), false)), testing::Values(POWER))); -INSTANTIATE_TEST_CASE_P(MulToPower, MulOrAddConversionTests, testing::Combine( +INSTANTIATE_TEST_SUITE_P(MulToPower, MulOrAddConversionTests, testing::Combine( testing::Values(std::make_tuple(InputShape{DYN, 3, 64, 64}, CONST(ngraph::Shape({1}), 0.5), NONE, false), @@ -236,7 +236,7 @@ INSTANTIATE_TEST_CASE_P(MulToPower, MulOrAddConversionTests, testing::Combine( NONE, false)), testing::Values(POWER))); -INSTANTIATE_TEST_CASE_P(AddToPower, MulOrAddConversionTests, testing::Combine( +INSTANTIATE_TEST_SUITE_P(AddToPower, MulOrAddConversionTests, testing::Combine( testing::Values(std::make_tuple(InputShape{DYN, 3, 64, 64}, NONE, CONST(ngraph::Shape({1}), 0.5), false), @@ -249,7 +249,7 @@ INSTANTIATE_TEST_CASE_P(AddToPower, MulOrAddConversionTests, testing::Combine( testing::Values(POWER))); -INSTANTIATE_TEST_CASE_P(MulAddNegative, MulAddConversionTests, testing::Combine( +INSTANTIATE_TEST_SUITE_P(MulAddNegative, MulAddConversionTests, testing::Combine( testing::Values(std::make_tuple(InputShape{DYN, 3, DYN}, CONST(ngraph::Shape({1, 1, 3, 1}), 0.5), CONST(ngraph::Shape({3, 1}), 0.5)/*detect broadcast case*/, false), @@ -270,7 +270,7 @@ INSTANTIATE_TEST_CASE_P(MulAddNegative, MulAddConversionTests, testing::Combine( CONST(ngraph::Shape({1, 3, 1, 1}), 0.5), false)), testing::Values(SAME))); -INSTANTIATE_TEST_CASE_P(MulToEltwise, MulOrAddConversionTests, testing::Combine( +INSTANTIATE_TEST_SUITE_P(MulToEltwise, MulOrAddConversionTests, testing::Combine( testing::Values(std::make_tuple(InputShape{DYN, 3, 64}, CONST(ngraph::Shape({1, 1, 64}), 0.5), NONE, false), @@ -303,7 +303,7 @@ INSTANTIATE_TEST_CASE_P(MulToEltwise, MulOrAddConversionTests, testing::Combine( NONE, true)), testing::Values(ELTWISE_PROD))); -INSTANTIATE_TEST_CASE_P(AddToEltwise, MulOrAddConversionTests, testing::Combine( +INSTANTIATE_TEST_SUITE_P(AddToEltwise, MulOrAddConversionTests, testing::Combine( testing::Values(std::make_tuple(InputShape{DYN, 3, 64}, NONE, CONST(ngraph::Shape({1, 1, 64}), 0.5), false), diff --git a/inference-engine/tests/functional/inference_engine/transformations/shuffle_channels_fusion_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/shuffle_channels_fusion_test.cpp index db379df386f8e5..5819423f1766b0 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/shuffle_channels_fusion_test.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/shuffle_channels_fusion_test.cpp @@ -127,7 +127,7 @@ const std::vector testValues = { { {128, 720 * 480}, {1, 2, 64, 720 * 480}, {0, 2, 1, 3}, {1, -1, 720, 480}, false, false }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( TransformationTests, ShuffleChannelsFusion, ::testing::ValuesIn(testValues), diff --git a/inference-engine/tests/functional/inference_engine/transformations/softmax_fusion.cpp b/inference-engine/tests/functional/inference_engine/transformations/softmax_fusion.cpp index f8f982cd48192e..e8d5ad211165a0 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/softmax_fusion.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/softmax_fusion.cpp @@ -55,7 +55,7 @@ TEST_P(SoftmaxFusionFixture, SoftmaxFusion) { ASSERT_TRUE(res.first) << res.second; } -INSTANTIATE_TEST_CASE_P(SoftmaxFusionTests, SoftmaxFusionFixture, +INSTANTIATE_TEST_SUITE_P(SoftmaxFusionTests, SoftmaxFusionFixture, ::testing::Values( std::make_tuple(1, 1), std::make_tuple(1, -2), @@ -109,7 +109,7 @@ TEST_P(NegativeSoftmaxFusionFixture, NegativeSoftmaxFusion) { ASSERT_TRUE(res.first) << res.second; } -INSTANTIATE_TEST_CASE_P(NegativeSoftmaxFusionTests, NegativeSoftmaxFusionFixture, +INSTANTIATE_TEST_SUITE_P(NegativeSoftmaxFusionTests, NegativeSoftmaxFusionFixture, ::testing::ValuesIn(std::vector, std::vector>>{ std::make_tuple, std::vector>({2}, {1}), std::make_tuple, std::vector>({1}, {-1}), diff --git a/inference-engine/tests/functional/inference_engine/transformations/transpose_sinking_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/transpose_sinking_test.cpp index 7e8db994280f75..9d0c6fdf715dea 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/transpose_sinking_test.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/transpose_sinking_test.cpp @@ -94,7 +94,7 @@ TEST_P(TransposeSinkingFQ, TransposeFQReduce) { } -INSTANTIATE_TEST_CASE_P(TransformationTest, TransposeSinkingFQ, testing::Values( +INSTANTIATE_TEST_SUITE_P(TransformationTest, TransposeSinkingFQ, testing::Values( TransposeFQReduceParams{{1, 3, 240, 140}, {0, 2, 3, 1}, {1}, {3}, {1, 1, 1, 1}, {1, 1, 1, 3}, {1, 2}, true, {1, 1, 1, 1}, {1, 3, 1, 1}, {1, 1, 1, 1}, {1, 3, 1, 1}, {2, 3}, {0, 2, 3, 1}}, TransposeFQReduceParams{{1, 3, 240, 140}, {0, 2, 3, 1}, {1}, {3}, {1, 1, 1, 1}, {1, 1, 1, 3}, {1, 2}, false, @@ -175,7 +175,7 @@ ASSERT_TRUE(res.first) << res.second; } -INSTANTIATE_TEST_CASE_P(TransposeSinkingReduces, TransposeSinking, testing::Combine( +INSTANTIATE_TEST_SUITE_P(TransposeSinkingReduces, TransposeSinking, testing::Combine( testing::Values( TransposeReduceParams{{1, 3, 240, 140}, {0, 2, 3, 1}, {1, 2}, true, {2, 3}, {0, 2, 3, 1}}, TransposeReduceParams{{10, 20, 30, 40, 50, 60, 70}, {0, 6, 1, 5, 2, 4, 3}, {1, 3, 6}, true, {6, 5, 3}, {0, 6, 1, 5, 2, 4, 3}}, @@ -194,7 +194,7 @@ INSTANTIATE_TEST_CASE_P(TransposeSinkingReduces, TransposeSinking, testing::Comb ngraph::opset6::ReduceLogicalAnd::type_info, ngraph::opset6::ReduceLogicalOr::type_info))); -INSTANTIATE_TEST_CASE_P(TransposeSinkingSqueeze, TransposeSinking, testing::Combine( +INSTANTIATE_TEST_SUITE_P(TransposeSinkingSqueeze, TransposeSinking, testing::Combine( testing::Values( TransposeReduceParams{{2, 3, 1, 1}, {0, 2, 3, 1}, {1, 2}, false, {2, 3}, {0, 1}}, TransposeReduceParams{{10, 20, 30, 1, 50, 1, 1}, {0, 6, 1, 5, 2, 4, 3}, {1, 3, 6}, false, {6, 5, 3}, {0, 1, 2, 3}}), diff --git a/inference-engine/tests/functional/inference_engine/transformations/transpose_to_reshape_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/transpose_to_reshape_test.cpp index bd07dd7ef99f66..154f11e00c10fd 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/transpose_to_reshape_test.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/transpose_to_reshape_test.cpp @@ -112,7 +112,7 @@ TEST_P(TransposeToReshapeTests, CompareFunctions) { #define EMPTY_FUNCTION ReferenceParams(false, true) #define SHAPE_OF_GATHER ReferenceParams() -INSTANTIATE_TEST_CASE_P(KeepTranspose, TransposeToReshapeTests, +INSTANTIATE_TEST_SUITE_P(KeepTranspose, TransposeToReshapeTests, testing::Values(std::make_tuple(InputShape{1, 3, 64, 64}, TransposeOrder{0, 1, 3, 2}, SAME_FUNCTION), std::make_tuple(InputShape{1, 3, 1, 64}, TransposeOrder{2, 0, 3, 1}, SAME_FUNCTION), std::make_tuple(InputShape{1, 3, 1, 3}, TransposeOrder{3, 0, 2, 1}, SAME_FUNCTION), @@ -121,19 +121,19 @@ INSTANTIATE_TEST_CASE_P(KeepTranspose, TransposeToReshapeTests, std::make_tuple(InputShape{DYN, DYN, 1}, TransposeOrder{2, 1, 0}, SAME_FUNCTION), std::make_tuple(InputShape{DYN, DYN}, TransposeOrder{1, 0}, SAME_FUNCTION))); -INSTANTIATE_TEST_CASE_P(EliminateTranspose, TransposeToReshapeTests, +INSTANTIATE_TEST_SUITE_P(EliminateTranspose, TransposeToReshapeTests, testing::Values(std::make_tuple(InputShape{1, 3, 64, 64}, TransposeOrder{0, 1, 2, 3}, EMPTY_FUNCTION), std::make_tuple(InputShape{1, 1, 1}, TransposeOrder{2, 0, 1}, EMPTY_FUNCTION), std::make_tuple(InputShape{DYN, DYN}, TransposeOrder{0, 1}, EMPTY_FUNCTION))); -INSTANTIATE_TEST_CASE_P(ReshapeWithConstant, TransposeToReshapeTests, +INSTANTIATE_TEST_SUITE_P(ReshapeWithConstant, TransposeToReshapeTests, testing::Values(std::make_tuple(InputShape{1, 3, 64, 1}, TransposeOrder{0, 1, 3, 2}, ReferenceParams({1, 3, 1, 64})), std::make_tuple(InputShape{1, 3, 1, 64}, TransposeOrder{1, 0, 3, 2}, ReferenceParams({3, 1, 64, 1})), std::make_tuple(InputShape{DYN, DYN, 1}, TransposeOrder{0, 2, 1}, ReferenceParams({0, 1, -1})), std::make_tuple(InputShape{1, 1, DYN}, TransposeOrder{2, 1, 0}, ReferenceParams({-1, 0, 1})), std::make_tuple(InputShape{DYN, 1, 64, 1}, TransposeOrder{1, 0, 3, 2}, ReferenceParams({1, -1, 1, 64})))); -INSTANTIATE_TEST_CASE_P(ReshapeWithGather, TransposeToReshapeTests, +INSTANTIATE_TEST_SUITE_P(ReshapeWithGather, TransposeToReshapeTests, testing::Values(std::make_tuple(InputShape{DYN, 1, DYN, 1}, TransposeOrder{1, 0, 3, 2}, SHAPE_OF_GATHER), std::make_tuple(InputShape{1, DYN, DYN, DYN}, TransposeOrder{1, 2, 3, 0}, SHAPE_OF_GATHER))); diff --git a/inference-engine/tests/functional/inference_engine/transformations/weights_dequantize_to_fake_quantize.cpp b/inference-engine/tests/functional/inference_engine/transformations/weights_dequantize_to_fake_quantize.cpp index a860565d53281c..944456e01f2c3c 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/weights_dequantize_to_fake_quantize.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/weights_dequantize_to_fake_quantize.cpp @@ -84,7 +84,7 @@ TEST_P(TranslateNewWeightFormatToOldOne, ReshapeMatMul) { ASSERT_TRUE(res.first) << res.second; } -INSTANTIATE_TEST_CASE_P(NGraph, TranslateNewWeightFormatToOldOne, testing::Combine( +INSTANTIATE_TEST_SUITE_P(NGraph, TranslateNewWeightFormatToOldOne, testing::Combine( testing::Values( FQ_as_Mul_Sub_dequantize{-128, 127, 1, 2, (-128 - 1) * 2, (127 - 1) * 2, 256}, FQ_as_Mul_Sub_dequantize{-127, 127, 1, 2, (-127 - 1) * 2, (127 - 1) * 2, 255}, diff --git a/inference-engine/tests/functional/plugin/conformance/test_runner/src/read_ir/read_ir.cpp b/inference-engine/tests/functional/plugin/conformance/test_runner/src/read_ir/read_ir.cpp index 922573884a3d68..a3e70abb4873f8 100644 --- a/inference-engine/tests/functional/plugin/conformance/test_runner/src/read_ir/read_ir.cpp +++ b/inference-engine/tests/functional/plugin/conformance/test_runner/src/read_ir/read_ir.cpp @@ -16,7 +16,7 @@ std::vector IRFolderPaths = {}; std::vector disabledTests = {}; namespace { -INSTANTIATE_TEST_CASE_P(conformance, +INSTANTIATE_TEST_SUITE_P(conformance, ReadIRTest, ::testing::Combine( ::testing::ValuesIn(CommonTestUtils::getFileListByPatternRecursive(IRFolderPaths, std::regex(R"(.*\.xml)"))), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/bf16_network_restoring.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/bf16_network_restoring.cpp index 6f41e879e7ac81..3355659619837d 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/bf16_network_restoring.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/bf16_network_restoring.cpp @@ -201,7 +201,7 @@ TEST_P(BF16NetworkRestore1, CompareWithRefImpl) { }; -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, BF16NetworkRestore1, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, BF16NetworkRestore1, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/bfloat16_helpers.hpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/bfloat16_helpers.hpp index 4c9414e08658be..f319b2baf122d7 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/bfloat16_helpers.hpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/bfloat16_helpers.hpp @@ -120,7 +120,7 @@ typedef std::tuple< * TEST_P(ScaleshiftConv_x3_Eltwise, CompareWithRefImpl) { test(); }; - * 3. INSTANTIATE_TEST_CASE_P(smoke_bfloat16_NoReshape, ScaleshiftConv_x3_Eltwise, + * 3. INSTANTIATE_TEST_SUITE_P(smoke_bfloat16_NoReshape, ScaleshiftConv_x3_Eltwise, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/concat_in_place.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/concat_in_place.cpp index 6e5f1161d4cb08..d81033f0d2a0d5 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/concat_in_place.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/concat_in_place.cpp @@ -140,7 +140,7 @@ TEST_P(Concat_in_place, CompareWithRefImpl) { test(); }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, Concat_in_place, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, Concat_in_place, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -149,7 +149,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, Concat_in_place, ::testing::Values(CommonTestUtils::DEVICE_CPU)), Concat_in_place::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, Concat_in_place, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, Concat_in_place, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/conv_add.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/conv_add.cpp index 7ba4ff64729701..510345ca562268 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/conv_add.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/conv_add.cpp @@ -121,7 +121,7 @@ TEST_P(ConvAdd, CompareWithRefImpl) { test(); }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ConvAdd, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, ConvAdd, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -130,7 +130,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ConvAdd, ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvAdd::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, ConvAdd, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, ConvAdd, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/conv_conv.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/conv_conv.cpp index 8695fdc3e536f3..bccdaef98625f6 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/conv_conv.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/conv_conv.cpp @@ -110,7 +110,7 @@ TEST_P(ConvConv, CompareWithRefImpl) { test(); }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ConvConv, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, ConvConv, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -119,7 +119,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ConvConv, ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvConv::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, ConvConv, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, ConvConv, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/conv_dwconv_relu.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/conv_dwconv_relu.cpp index 0f6350b57170ed..6c9180b78ba015 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/conv_dwconv_relu.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/conv_dwconv_relu.cpp @@ -129,7 +129,7 @@ TEST_P(ConvDWConvReLU, CompareWithRefImpl) { test(); }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ConvDWConvReLU, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, ConvDWConvReLU, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -138,7 +138,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ConvDWConvReLU, ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvDWConvReLU::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, ConvDWConvReLU, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, ConvDWConvReLU, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/conv_eltwise_depthwise.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/conv_eltwise_depthwise.cpp index 224eb3b1c880fd..a673912fac04ee 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/conv_eltwise_depthwise.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/conv_eltwise_depthwise.cpp @@ -226,7 +226,7 @@ TEST_P(ConvEltwiseDepthwise, CompareWithRefImpl) { Run_test(); }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_1x1_depthwise_BF16, ConvEltwiseDepthwise, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_1x1_depthwise_BF16, ConvEltwiseDepthwise, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(SizeVector({ 1, 5, 1, 1 })), @@ -236,7 +236,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_1x1_depthwise_BF16, ConvEltwiseDepth ::testing::Values(std::string("jit_avx512_1x1_BF16"))), ConvEltwiseDepthwise::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_gemm_depthwise_BF16, ConvEltwiseDepthwise, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_gemm_depthwise_BF16, ConvEltwiseDepthwise, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(SizeVector({ 1, 3, 10, 10 })), @@ -246,7 +246,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_gemm_depthwise_BF16, ConvEltwiseDept ::testing::Values(std::string("jit_avx512_BF16"))), ConvEltwiseDepthwise::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_conv_depthwise_BF16, ConvEltwiseDepthwise, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_conv_depthwise_BF16, ConvEltwiseDepthwise, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(SizeVector({ 1, 5, 10, 10 })), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/conv_relu_pool_conv_relu_pool.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/conv_relu_pool_conv_relu_pool.cpp index 536e92a142ba58..1b83146fca7c58 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/conv_relu_pool_conv_relu_pool.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/conv_relu_pool_conv_relu_pool.cpp @@ -179,7 +179,7 @@ TEST_P(ConvReLUPoolConvReLUPool, CompareWithRefImpl) { }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ConvReLUPoolConvReLUPool, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, ConvReLUPoolConvReLUPool, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -188,7 +188,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ConvReLUPoolConvReLUPool, ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvReLUPoolConvReLUPool::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, ConvReLUPoolConvReLUPool, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, ConvReLUPoolConvReLUPool, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/elt_max.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/elt_max.cpp index 95eedfc6d814f7..150c3f71580d01 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/elt_max.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/elt_max.cpp @@ -132,7 +132,7 @@ TEST_P(Elt_max, CompareWithRefImpl) { }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, Elt_max, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, Elt_max, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -141,7 +141,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, Elt_max, ::testing::Values(CommonTestUtils::DEVICE_CPU)), Elt_max::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, Elt_max, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, Elt_max, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/elt_x3.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/elt_x3.cpp index 53516f32e57871..5e71b92b19ddcf 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/elt_x3.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/elt_x3.cpp @@ -189,7 +189,7 @@ TEST_P(Elt_x3, CompareWithRefImpl) { test(); }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, Elt_x3, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, Elt_x3, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -198,7 +198,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, Elt_x3, ::testing::Values(CommonTestUtils::DEVICE_CPU)), Elt_x3::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, Elt_x3, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, Elt_x3, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/faster_100_5_1_1_conv.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/faster_100_5_1_1_conv.cpp index 04928f1eed9fcc..93141614abd451 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/faster_100_5_1_1_conv.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/faster_100_5_1_1_conv.cpp @@ -117,7 +117,7 @@ TEST_P(Faster100_5_1_1_Conv, CompareWithRefImpl) { }; -INSTANTIATE_TEST_CASE_P(smoke_bfloat16_NoReshape, Faster100_5_1_1_Conv, +INSTANTIATE_TEST_SUITE_P(smoke_bfloat16_NoReshape, Faster100_5_1_1_Conv, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -126,7 +126,7 @@ INSTANTIATE_TEST_CASE_P(smoke_bfloat16_NoReshape, Faster100_5_1_1_Conv, ::testing::Values(CommonTestUtils::DEVICE_CPU)), Faster100_5_1_1_Conv::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, Faster100_5_1_1_Conv, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, Faster100_5_1_1_Conv, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/gather_multiply.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/gather_multiply.cpp index 8436ce732074a6..e4283a18931b18 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/gather_multiply.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/gather_multiply.cpp @@ -110,7 +110,7 @@ TEST_P(Gather_multiply, CompareWithRefImpl) { test(); }; -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, Gather_multiply, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, Gather_multiply, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), @@ -119,7 +119,7 @@ INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, Gather_multiply, ::testing::Values(CommonTestUtils::DEVICE_CPU)), Gather_multiply::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, Gather_multiply, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, Gather_multiply, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/gather_x2_add_mul_relu_concat_matmul.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/gather_x2_add_mul_relu_concat_matmul.cpp index 492faef53148cc..ee0ce7ae308676 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/gather_x2_add_mul_relu_concat_matmul.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/gather_x2_add_mul_relu_concat_matmul.cpp @@ -137,7 +137,7 @@ TEST_P(Gather_x2_add_mul_relu_concat_matmul, CompareWithRefImpl) { }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, Gather_x2_add_mul_relu_concat_matmul, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, Gather_x2_add_mul_relu_concat_matmul, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -146,7 +146,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, Gather_x2_add_mul_relu_co ::testing::Values(CommonTestUtils::DEVICE_CPU)), Gather_x2_add_mul_relu_concat_matmul::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, Gather_x2_add_mul_relu_concat_matmul, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, Gather_x2_add_mul_relu_concat_matmul, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/memory_conv.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/memory_conv.cpp index ec754661f9dd6d..fc2cebf349340e 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/memory_conv.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/memory_conv.cpp @@ -105,7 +105,7 @@ TEST_P(MemoryConv, CheckTypeConversion) { ASSERT_EQ(ngraph::element::bf16, mem_w->input(0).get_element_type()); } -INSTANTIATE_TEST_CASE_P(smoke_CPU, MemoryConv, +INSTANTIATE_TEST_SUITE_P(smoke_CPU, MemoryConv, ::testing::Combine( ::testing::Values(Precision::BF16, Precision::FP32), ::testing::Values(SizeVector{1, 200}), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/mobilenet_ssd_with_branching.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/mobilenet_ssd_with_branching.cpp index 3215e553e57c06..1dadf97341b42f 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/mobilenet_ssd_with_branching.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/mobilenet_ssd_with_branching.cpp @@ -164,7 +164,7 @@ TEST_P(MobileNet_ssd_with_branching, CompareWithRefImpl) { test(); }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, MobileNet_ssd_with_branching, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, MobileNet_ssd_with_branching, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -173,7 +173,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, MobileNet_ssd_with_branch ::testing::Values(CommonTestUtils::DEVICE_CPU)), MobileNet_ssd_with_branching::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, MobileNet_ssd_with_branching, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, MobileNet_ssd_with_branching, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_eltwise_conv.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_eltwise_conv.cpp index 98f7ee4361414b..8b39519ed1bade 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_eltwise_conv.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_eltwise_conv.cpp @@ -136,7 +136,7 @@ TEST_P(ScaleshiftConvEltwiseConv, CompareWithRefImpl) { test(); }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConvEltwiseConv, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConvEltwiseConv, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -145,7 +145,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConvEltwiseConv ::testing::Values(CommonTestUtils::DEVICE_CPU)), ScaleshiftConvEltwiseConv::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, ScaleshiftConvEltwiseConv, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, ScaleshiftConvEltwiseConv, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_eltwise_relu_conv.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_eltwise_relu_conv.cpp index 014ab08e5f0c63..854ba27949bbb6 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_eltwise_relu_conv.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_eltwise_relu_conv.cpp @@ -141,7 +141,7 @@ TEST_P(ScaleshiftConvEltwiseReluConv, CompareWithRefImpl) { test(); }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConvEltwiseReluConv, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConvEltwiseReluConv, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -150,7 +150,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConvEltwiseRelu ::testing::Values(CommonTestUtils::DEVICE_CPU)), ScaleshiftConvEltwiseReluConv::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, ScaleshiftConvEltwiseReluConv, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, ScaleshiftConvEltwiseReluConv, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_eltwise_scaleshift.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_eltwise_scaleshift.cpp index 8abb82066de81b..c47afc8c24d058 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_eltwise_scaleshift.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_eltwise_scaleshift.cpp @@ -133,7 +133,7 @@ TEST_P(ScaleshiftConvEltwiseScaleshift, CompareWithRefImpl) { test(); }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConvEltwiseScaleshift, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConvEltwiseScaleshift, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -142,7 +142,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConvEltwiseScal ::testing::Values(CommonTestUtils::DEVICE_CPU)), ScaleshiftConvEltwiseScaleshift::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, ScaleshiftConvEltwiseScaleshift, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, ScaleshiftConvEltwiseScaleshift, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_elu_conv.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_elu_conv.cpp index f9735e60bc359b..825501350d1163 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_elu_conv.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_elu_conv.cpp @@ -121,7 +121,7 @@ TEST_P(ScaleshiftConvEluConv, CompareWithRefImpl) { test(); }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConvEluConv, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConvEluConv, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -130,7 +130,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConvEluConv, ::testing::Values(CommonTestUtils::DEVICE_CPU)), ScaleshiftConvEluConv::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, ScaleshiftConvEluConv, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, ScaleshiftConvEluConv, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_relu.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_relu.cpp index 33d494658babda..bd725c29b903c5 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_relu.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_relu.cpp @@ -109,7 +109,7 @@ TEST_P(ScaleshiftConvRelu, CompareWithRefImpl) { test(); }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConvRelu, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConvRelu, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -118,7 +118,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConvRelu, ::testing::Values(CommonTestUtils::DEVICE_CPU)), ScaleshiftConvRelu::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, ScaleshiftConvRelu, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, ScaleshiftConvRelu, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_x2_concat_relu.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_x2_concat_relu.cpp index d00b5144b0f157..aee55af910a13e 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_x2_concat_relu.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_x2_concat_relu.cpp @@ -126,7 +126,7 @@ TEST_P(ScaleshiftConv_x2_ConcatRelu, CompareWithRefImpl) { test(); }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConv_x2_ConcatRelu, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConv_x2_ConcatRelu, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -135,7 +135,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConv_x2_ConcatR ::testing::Values(CommonTestUtils::DEVICE_CPU)), ScaleshiftConv_x2_ConcatRelu::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, ScaleshiftConv_x2_ConcatRelu, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, ScaleshiftConv_x2_ConcatRelu, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_x2_eltwise.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_x2_eltwise.cpp index 8a46347e5a7f1a..97d29dd540e5c4 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_x2_eltwise.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_x2_eltwise.cpp @@ -119,7 +119,7 @@ TEST_P(ScaleshiftConv_x2_Eltwise, CompareWithRefImpl) { test(); }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConv_x2_Eltwise, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConv_x2_Eltwise, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -128,7 +128,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConv_x2_Eltwise ::testing::Values(CommonTestUtils::DEVICE_CPU)), ScaleshiftConv_x2_Eltwise::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, ScaleshiftConv_x2_Eltwise, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, ScaleshiftConv_x2_Eltwise, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_x2_mixed1_eltwise.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_x2_mixed1_eltwise.cpp index b517c66a9e0dc3..df17ac9fc026f9 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_x2_mixed1_eltwise.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_x2_mixed1_eltwise.cpp @@ -119,7 +119,7 @@ TEST_P(ScaleshiftConv_x2_mixed1_Eltwise, CompareWithRefImpl) { test(); }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConv_x2_mixed1_Eltwise, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConv_x2_mixed1_Eltwise, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -128,7 +128,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConv_x2_mixed1_ ::testing::Values(CommonTestUtils::DEVICE_CPU)), ScaleshiftConv_x2_mixed1_Eltwise::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, ScaleshiftConv_x2_mixed1_Eltwise, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, ScaleshiftConv_x2_mixed1_Eltwise, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_x2_mixed2_eltwise.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_x2_mixed2_eltwise.cpp index d8601d6f9dd1ca..58f1be475f6f26 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_x2_mixed2_eltwise.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_x2_mixed2_eltwise.cpp @@ -122,7 +122,7 @@ TEST_P(ScaleshiftConv_x2_mixed2_Eltwise, CompareWithRefImpl) { test(); }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConv_x2_mixed2_Eltwise, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConv_x2_mixed2_Eltwise, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -131,7 +131,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConv_x2_mixed2_ ::testing::Values(CommonTestUtils::DEVICE_CPU)), ScaleshiftConv_x2_mixed2_Eltwise::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, ScaleshiftConv_x2_mixed2_Eltwise, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, ScaleshiftConv_x2_mixed2_Eltwise, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_x3_eltwise.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_x3_eltwise.cpp index aba2d02a111ca8..36b8145cb17f70 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_x3_eltwise.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_conv_x3_eltwise.cpp @@ -155,7 +155,7 @@ TEST_P(ScaleshiftConv_x3_Eltwise, CompareWithRefImpl) { test(); }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConv_x3_Eltwise, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConv_x3_Eltwise, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -164,7 +164,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, ScaleshiftConv_x3_Eltwise ::testing::Values(CommonTestUtils::DEVICE_CPU)), ScaleshiftConv_x3_Eltwise::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, ScaleshiftConv_x3_Eltwise, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, ScaleshiftConv_x3_Eltwise, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_x2_conv_x2_eltwise.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_x2_conv_x2_eltwise.cpp index 043aa6b87a01f8..c710be46f10199 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_x2_conv_x2_eltwise.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_x2_conv_x2_eltwise.cpp @@ -141,7 +141,7 @@ TEST_P(Scaleshift_x2_Conv_x2_Eltwise, CompareWithRefImpl) { test(); }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, Scaleshift_x2_Conv_x2_Eltwise, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, Scaleshift_x2_Conv_x2_Eltwise, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -150,7 +150,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, Scaleshift_x2_Conv_x2_Elt ::testing::Values(CommonTestUtils::DEVICE_CPU)), Scaleshift_x2_Conv_x2_Eltwise::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, Scaleshift_x2_Conv_x2_Eltwise, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, Scaleshift_x2_Conv_x2_Eltwise, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_x3_conv_eltwise_relu.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_x3_conv_eltwise_relu.cpp index a9916754d1ea12..dbed0feef7d65e 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_x3_conv_eltwise_relu.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/scaleshift_x3_conv_eltwise_relu.cpp @@ -161,7 +161,7 @@ TEST_P(Scaleshift_x3_ConvEltwiseRelu, CompareWithRefImpl) { test(); }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, Scaleshift_x3_ConvEltwiseRelu, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, Scaleshift_x3_ConvEltwiseRelu, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -170,7 +170,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, Scaleshift_x3_ConvEltwise ::testing::Values(CommonTestUtils::DEVICE_CPU)), Scaleshift_x3_ConvEltwiseRelu::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, Scaleshift_x3_ConvEltwiseRelu, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, Scaleshift_x3_ConvEltwiseRelu, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/tail_fp32_optimization.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/tail_fp32_optimization.cpp index a4dcc9713ca8b4..0d3cea9eef2ddc 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/tail_fp32_optimization.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/tail_fp32_optimization.cpp @@ -124,7 +124,7 @@ TEST_P(PoolingAfterConv, CompareWithRefImpl) { }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, PoolingAfterConv, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, PoolingAfterConv, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -133,7 +133,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, PoolingAfterConv, ::testing::Values(CommonTestUtils::DEVICE_CPU)), PoolingAfterConv::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, PoolingAfterConv, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, PoolingAfterConv, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/bfloat16/topk_inputs_i32.cpp b/inference-engine/tests/functional/plugin/cpu/bfloat16/topk_inputs_i32.cpp index 32912caca0b25c..fb8d97c2981f78 100644 --- a/inference-engine/tests/functional/plugin/cpu/bfloat16/topk_inputs_i32.cpp +++ b/inference-engine/tests/functional/plugin/cpu/bfloat16/topk_inputs_i32.cpp @@ -146,7 +146,7 @@ TEST_P(TopKInputsI32, CompareWithRefImpl) { }; -INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, TopKInputsI32, +INSTANTIATE_TEST_SUITE_P(smoke_FP32_bfloat16_NoReshape, TopKInputsI32, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::FP32), @@ -155,7 +155,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FP32_bfloat16_NoReshape, TopKInputsI32, ::testing::Values(CommonTestUtils::DEVICE_CPU)), TopKInputsI32::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BF16_bfloat16_NoReshape, TopKInputsI32, +INSTANTIATE_TEST_SUITE_P(smoke_BF16_bfloat16_NoReshape, TopKInputsI32, ::testing::Combine( ::testing::Values(Precision::FP32), ::testing::Values(Precision::BF16), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/add_output.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/add_output.cpp index 030da02964b20a..e197301c5342ed 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/add_output.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/add_output.cpp @@ -32,6 +32,6 @@ std::vector testCases = { addOutputsParams(getTargetNetwork(), {"Memory"}, CommonTestUtils::DEVICE_CPU) }; -INSTANTIATE_TEST_CASE_P(smoke_AddOutputBasic, AddOutputsTest, +INSTANTIATE_TEST_SUITE_P(smoke_AddOutputBasic, AddOutputsTest, ::testing::ValuesIn(testCases), AddOutputsTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/caching_tests.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/caching_tests.cpp index c9e4d9c4294fe5..c541f4e21bafde 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/caching_tests.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/caching_tests.cpp @@ -22,7 +22,7 @@ namespace { 1, 2 }; - INSTANTIATE_TEST_CASE_P(smoke_CachingSupportCase_CPU, LoadNetworkCacheTestBase, + INSTANTIATE_TEST_SUITE_P(smoke_CachingSupportCase_CPU, LoadNetworkCacheTestBase, ::testing::Combine( ::testing::ValuesIn(LoadNetworkCacheTestBase::getStandardFunctions()), ::testing::ValuesIn(precisionsCPU), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/config.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/config.cpp index e3f0adb1cb6117..ffc91dee6d1366 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/config.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/config.cpp @@ -45,21 +45,21 @@ namespace { {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectConfigTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, CorrectConfigTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(Configs)), CorrectConfigTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, CorrectConfigTests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, CorrectConfigTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(MultiConfigs)), CorrectConfigTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, CorrectConfigTests, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, CorrectConfigTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), @@ -90,56 +90,56 @@ namespace { {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES , CommonTestUtils::DEVICE_CPU}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectConfigAPITests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, CorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(conf)), CorrectConfigAPITests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, CorrectConfigAPITests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, CorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(multiconf)), CorrectConfigAPITests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, CorrectConfigAPITests, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, CorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), ::testing::ValuesIn(AutoConfigs)), CorrectConfigAPITests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, IncorrectConfigTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(inconfigs)), IncorrectConfigTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, IncorrectConfigTests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, IncorrectConfigTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(multiinconfigs)), IncorrectConfigTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigAPITests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, IncorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(inconfigs)), IncorrectConfigAPITests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, IncorrectConfigAPITests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, IncorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(multiinconfigs)), IncorrectConfigAPITests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, IncorrectConfigAPITests, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, IncorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/core_integration.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/core_integration.cpp index 54fbba129b5d15..040911489e5e69 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/core_integration.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/core_integration.cpp @@ -13,15 +13,15 @@ namespace { // IE Class Common tests with // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassCommon, IEClassBasicTestP, ::testing::Values(std::make_pair("MKLDNNPlugin", "CPU"))); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassNetworkTestP, IEClassNetworkTestP, ::testing::Values("CPU")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassImportExportTestP, IEClassImportExportTestP, ::testing::Values("HETERO:CPU")); @@ -29,43 +29,43 @@ INSTANTIATE_TEST_CASE_P( // IE Class GetMetric // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassGetMetricTest, IEClassGetMetricTest_SUPPORTED_CONFIG_KEYS, ::testing::Values("CPU", "MULTI", "HETERO", "AUTO")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassGetMetricTest, IEClassGetMetricTest_SUPPORTED_METRICS, ::testing::Values("CPU", "MULTI", "HETERO", "AUTO")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassGetMetricTest, IEClassGetMetricTest_AVAILABLE_DEVICES, ::testing::Values("CPU")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassGetMetricTest, IEClassGetMetricTest_FULL_DEVICE_NAME, ::testing::Values("CPU", "MULTI", "HETERO", "AUTO")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassGetMetricTest, IEClassGetMetricTest_OPTIMIZATION_CAPABILITIES, ::testing::Values("CPU", "AUTO")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassGetMetricTest, IEClassGetMetricTest_RANGE_FOR_ASYNC_INFER_REQUESTS, ::testing::Values("CPU")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassGetMetricTest, IEClassGetMetricTest_RANGE_FOR_STREAMS, ::testing::Values("CPU")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassGetMetricTest, IEClassGetMetricTest_ThrowUnsupported, ::testing::Values("CPU", "MULTI", "HETERO", "AUTO")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassGetConfigTest, IEClassGetConfigTest_ThrowUnsupported, ::testing::Values("CPU", "MULTI", "HETERO", "AUTO")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassGetAvailableDevices, IEClassGetAvailableDevices, ::testing::Values("CPU")); @@ -73,7 +73,7 @@ INSTANTIATE_TEST_CASE_P( // IE Class GetConfig // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassGetConfigTest, IEClassGetConfigTest, ::testing::Values("CPU")); @@ -81,23 +81,23 @@ INSTANTIATE_TEST_CASE_P( // Executable Network GetMetric // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassExecutableNetworkGetMetricTest, IEClassExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS, ::testing::Values("CPU", "MULTI:CPU", "HETERO:CPU", "AUTO:CPU")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassExecutableNetworkGetMetricTest, IEClassExecutableNetworkGetMetricTest_SUPPORTED_METRICS, ::testing::Values("CPU", "MULTI:CPU", "HETERO:CPU", "AUTO:CPU")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassExecutableNetworkGetMetricTest, IEClassExecutableNetworkGetMetricTest_NETWORK_NAME, ::testing::Values("CPU", "MULTI:CPU", "HETERO:CPU", "AUTO:CPU")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassExecutableNetworkGetMetricTest, IEClassExecutableNetworkGetMetricTest_OPTIMAL_NUMBER_OF_INFER_REQUESTS, ::testing::Values("CPU", "MULTI:CPU", "HETERO:CPU", "AUTO:CPU")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassExecutableNetworkGetMetricTest, IEClassExecutableNetworkGetMetricTest_ThrowsUnsupported, ::testing::Values("CPU", "MULTI:CPU", "HETERO:CPU", "AUTO:CPU")); @@ -105,11 +105,11 @@ INSTANTIATE_TEST_CASE_P( // Executable Network GetConfig / SetConfig // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassExecutableNetworkGetConfigTest, IEClassExecutableNetworkGetConfigTest, ::testing::Values("CPU")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassExecutableNetworkSetConfigTest, IEClassExecutableNetworkSetConfigTest, ::testing::Values("CPU")); @@ -117,19 +117,19 @@ INSTANTIATE_TEST_CASE_P( // Hetero Executable Network GetMetric // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassHeteroExecutableNetworkGetMetricTest, IEClassHeteroExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS, ::testing::Values("CPU")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassHeteroExecutableNetworkGetMetricTest, IEClassHeteroExecutableNetworkGetMetricTest_SUPPORTED_METRICS, ::testing::Values("CPU")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassHeteroExecutableNetworkGetMetricTest, IEClassHeteroExecutableNetworkGetMetricTest_NETWORK_NAME, ::testing::Values("CPU")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassHeteroExecutableNetworkGetMetricTest, IEClassHeteroExecutableNetworkGetMetricTest_TARGET_FALLBACK, ::testing::Values("CPU")); @@ -150,13 +150,13 @@ TEST(IEClassBasicTest, smoke_SetConfigAfterCreatedThrow) { // IE Class Query network -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassQueryNetworkTest, IEClassQueryNetworkTest, ::testing::Values("CPU")); // IE Class Load network -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassLoadNetworkTest, IEClassLoadNetworkTest, ::testing::Values("CPU")); } // namespace \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/core_threading_tests.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/core_threading_tests.cpp index 87dc75d3be8a32..fe294e97075b5f 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/core_threading_tests.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/core_threading_tests.cpp @@ -18,16 +18,16 @@ const Params paramsStreams[] = { }; } // namespace -INSTANTIATE_TEST_CASE_P(CPU, CoreThreadingTests, testing::ValuesIn(params), CoreThreadingTests::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(CPU, CoreThreadingTests, testing::ValuesIn(params), CoreThreadingTests::getTestCaseName); -INSTANTIATE_TEST_CASE_P(CPU, CoreThreadingTestsWithIterations, +INSTANTIATE_TEST_SUITE_P(CPU, CoreThreadingTestsWithIterations, testing::Combine(testing::ValuesIn(params), testing::Values(4), testing::Values(50), testing::Values(ModelClass::Default)), CoreThreadingTestsWithIterations::getTestCaseName); -INSTANTIATE_TEST_CASE_P(CPU_Streams, CoreThreadingTestsWithIterations, +INSTANTIATE_TEST_SUITE_P(CPU_Streams, CoreThreadingTestsWithIterations, testing::Combine(testing::ValuesIn(paramsStreams), testing::Values(4), testing::Values(50), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/cpp_holders.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/cpp_holders.cpp index b71d2e3d0a1e67..22546c9b74ac7d 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/cpp_holders.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/cpp_holders.cpp @@ -21,7 +21,7 @@ namespace { {0, 1, 3, 2} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, HoldersTest, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, HoldersTest, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(orders)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/exec_graph_info.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/exec_graph_info.cpp index c54175304f52c1..ee0bad4bb1f051 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/exec_graph_info.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/exec_graph_info.cpp @@ -22,21 +22,21 @@ namespace { {{ InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, ExecGraphTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, ExecGraphTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(configs)), ExecGraphTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, ExecGraphTests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, ExecGraphTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(multiConfigs)), ExecGraphTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, ExecGraphTests, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, ExecGraphTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request.cpp index ced3a3d22104be..b5c9180ef8461a 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request.cpp @@ -28,21 +28,21 @@ namespace { {{ AUTO_CONFIG_KEY(DEVICE_LIST) , CommonTestUtils::DEVICE_CPU}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferRequestTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferRequestTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(configs)), InferRequestTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, InferRequestTests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, InferRequestTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(Multiconfigs)), InferRequestTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_AutoPlugin_BehaviorTests, InferRequestTests, + INSTANTIATE_TEST_SUITE_P(smoke_AutoPlugin_BehaviorTests, InferRequestTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_callback.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_callback.cpp index 3033c404bbfcec..8483b82c3db437 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_callback.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_callback.cpp @@ -25,21 +25,21 @@ const std::vector> autoConfigs = { {{ AUTO_CONFIG_KEY(DEVICE_LIST) , CommonTestUtils::DEVICE_CPU}} }; -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CallbackTests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, CallbackTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(configs)), CallbackTests::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, CallbackTests, +INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, CallbackTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(multiConfigs)), CallbackTests::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, CallbackTests, +INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, CallbackTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_cancellation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_cancellation.cpp index 612d9047208635..0d2aa9a72fd19d 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_cancellation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_cancellation.cpp @@ -15,7 +15,7 @@ const std::vector> configs = { {}, }; -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CancellationTests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, CancellationTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_config.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_config.cpp index 3db325234cf1a6..1f5e502818a32a 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_config.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_config.cpp @@ -54,42 +54,42 @@ namespace { {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferConfigTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferConfigTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(configs)), InferConfigTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, InferConfigTests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, InferConfigTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(multiConfigs)), InferConfigTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, InferConfigTests, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, InferConfigTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), ::testing::ValuesIn(autoConfigs)), InferConfigTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferConfigInTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferConfigInTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(InConfigs)), InferConfigTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, InferConfigInTests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, InferConfigInTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(MultiInConfigs)), InferConfigInTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, InferConfigInTests, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, InferConfigInTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_input.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_input.cpp index eb988c0043a289..73bc9fb8f97ffa 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_input.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_input.cpp @@ -29,21 +29,21 @@ namespace { {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferRequestInputTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferRequestInputTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(configs)), InferRequestInputTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, InferRequestInputTests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, InferRequestInputTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(multiConfigs)), InferRequestInputTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, InferRequestInputTests, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, InferRequestInputTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_output.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_output.cpp index a77253f8900fa5..36ad2752244d6f 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_output.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/infer_request_output.cpp @@ -25,21 +25,21 @@ namespace { {{InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferRequestOutputTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferRequestOutputTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(configs)), InferRequestOutputTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, InferRequestOutputTests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, InferRequestOutputTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(multiConfigs)), InferRequestOutputTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, InferRequestOutputTests, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, InferRequestOutputTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/invalid_cases/proposal.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/invalid_cases/proposal.cpp index dd8c3167e121e5..48fe63eb398a70 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/invalid_cases/proposal.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/invalid_cases/proposal.cpp @@ -44,7 +44,7 @@ const auto proposalParams = ::testing::Combine( ::testing::ValuesIn(framework_) ); -INSTANTIATE_TEST_CASE_P(invalid, ProposalBehTest, +INSTANTIATE_TEST_SUITE_P(invalid, ProposalBehTest, ::testing::Combine( proposalParams, ::testing::ValuesIn(img_info_invalid), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/layout.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/layout.cpp index 908ec597e0d340..f3854504d81cce 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/layout.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/layout.cpp @@ -26,7 +26,7 @@ namespace { { 3 } }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, LayoutTest, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, LayoutTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_CPU, "HETERO:CPU"), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/perf_counters.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/perf_counters.cpp index 8bf1a8f95ba766..39aff76e6fd230 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/perf_counters.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/perf_counters.cpp @@ -14,14 +14,14 @@ namespace { {{ MULTI_CONFIG_KEY(DEVICE_PRIORITIES) , CommonTestUtils::DEVICE_CPU}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, PerfCountersTest, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, PerfCountersTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(configs)), PerfCountersTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, PerfCountersTest, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, PerfCountersTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_MULTI), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/preprocessing.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/preprocessing.cpp index f4059b4688283a..657dfe5e947b56 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/preprocessing.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/preprocessing.cpp @@ -17,7 +17,7 @@ const std::vector> configs = { {} }; -INSTANTIATE_TEST_CASE_P(BehaviourPreprocessingTestsViaSetInput, PreprocessingPrecisionConvertTest, +INSTANTIATE_TEST_SUITE_P(BehaviourPreprocessingTestsViaSetInput, PreprocessingPrecisionConvertTest, ::testing::Combine( ::testing::ValuesIn(inputPrecisions), ::testing::Values(1, 2, 3, 4, 5), // Number of input tensor channels @@ -26,7 +26,7 @@ INSTANTIATE_TEST_CASE_P(BehaviourPreprocessingTestsViaSetInput, PreprocessingPre ::testing::ValuesIn(configs)), PreprocessingPrecisionConvertTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(BehaviourPreprocessingTestsViaGetBlob, PreprocessingPrecisionConvertTest, +INSTANTIATE_TEST_SUITE_P(BehaviourPreprocessingTestsViaGetBlob, PreprocessingPrecisionConvertTest, ::testing::Combine( ::testing::ValuesIn(inputPrecisions), ::testing::Values(4, 5), // Number of input tensor channels (blob_copy only supports 4d and 5d tensors) diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/set_blob.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/set_blob.cpp index 923cf62a61cd5d..214e9dc9cb49a5 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/set_blob.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/set_blob.cpp @@ -18,4 +18,4 @@ const auto params = ::testing::Combine(::testing::ValuesIn(precisionSet), ::testing::ValuesIn(typeSet), ::testing::Values(CommonTestUtils::DEVICE_CPU)); -INSTANTIATE_TEST_CASE_P(smoke_SetBlobCPU, SetBlobTest, params, SetBlobTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_SetBlobCPU, SetBlobTest, params, SetBlobTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/set_blob_of_kind.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/set_blob_of_kind.cpp index c6814674d3fb23..0ce335bcfada2c 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/set_blob_of_kind.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/set_blob_of_kind.cpp @@ -19,26 +19,26 @@ const SetBlobOfKindConfig autoConfig{}; const SetBlobOfKindConfig multiConfig{{ MULTI_CONFIG_KEY(DEVICE_PRIORITIES) , CommonTestUtils::DEVICE_CPU}}; const SetBlobOfKindConfig heteroConfig{{ "TARGET_FALLBACK", CommonTestUtils::DEVICE_CPU }}; -INSTANTIATE_TEST_CASE_P(smoke_SetBlobOfKindCPU, SetBlobOfKindTest, +INSTANTIATE_TEST_SUITE_P(smoke_SetBlobOfKindCPU, SetBlobOfKindTest, ::testing::Combine(::testing::ValuesIn(blobKinds), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::Values(cpuConfig)), SetBlobOfKindTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_SetBlobOfKindMULTI, SetBlobOfKindTest, +INSTANTIATE_TEST_SUITE_P(smoke_SetBlobOfKindMULTI, SetBlobOfKindTest, ::testing::Combine(::testing::ValuesIn(blobKinds), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::Values(multiConfig)), SetBlobOfKindTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_SetBlobOfKindAUTO, SetBlobOfKindTest, +INSTANTIATE_TEST_SUITE_P(smoke_SetBlobOfKindAUTO, SetBlobOfKindTest, ::testing::Combine(::testing::ValuesIn(blobKinds), ::testing::Values(CommonTestUtils::DEVICE_AUTO + std::string(":") + CommonTestUtils::DEVICE_CPU), ::testing::Values(autoConfig)), SetBlobOfKindTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_SetBlobOfKindHETERO, SetBlobOfKindTest, +INSTANTIATE_TEST_SUITE_P(smoke_SetBlobOfKindHETERO, SetBlobOfKindTest, ::testing::Combine(::testing::ValuesIn(blobKinds), ::testing::Values(CommonTestUtils::DEVICE_HETERO), ::testing::Values(heteroConfig)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/set_preprocess.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/set_preprocess.cpp index 3db386c50c7294..d3450e08ee27b2 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/set_preprocess.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/set_preprocess.cpp @@ -31,28 +31,28 @@ namespace { {{ InferenceEngine::KEY_AUTO_DEVICE_LIST , CommonTestUtils::DEVICE_CPU}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, PreprocessTest, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, PreprocessTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(configs)), PreprocessTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Hetero_BehaviorTests, PreprocessTest, + INSTANTIATE_TEST_SUITE_P(smoke_Hetero_BehaviorTests, PreprocessTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_HETERO), ::testing::ValuesIn(heteroConfigs)), PreprocessTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, PreprocessTest, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, PreprocessTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(multiConfigs)), PreprocessTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, PreprocessTest, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, PreprocessTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), @@ -74,7 +74,7 @@ namespace { InferenceEngine::Layout::NHWC }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, PreprocessConversionTest, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, PreprocessConversionTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(ioPrecisions), @@ -88,7 +88,7 @@ namespace { ::testing::ValuesIn(configs)), PreprocessConversionTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, PreprocessDynamicallyInSetBlobTest, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, PreprocessDynamicallyInSetBlobTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Bool(), @@ -102,7 +102,7 @@ namespace { ::testing::ValuesIn(configs)), PreprocessDynamicallyInSetBlobTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Hetero_BehaviorTests, PreprocessConversionTest, + INSTANTIATE_TEST_SUITE_P(smoke_Hetero_BehaviorTests, PreprocessConversionTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(ioPrecisions), @@ -116,7 +116,7 @@ namespace { ::testing::ValuesIn(heteroConfigs)), PreprocessConversionTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Hetero_BehaviorTests, PreprocessDynamicallyInSetBlobTest, + INSTANTIATE_TEST_SUITE_P(smoke_Hetero_BehaviorTests, PreprocessDynamicallyInSetBlobTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Bool(), @@ -130,7 +130,7 @@ namespace { ::testing::ValuesIn(heteroConfigs)), PreprocessDynamicallyInSetBlobTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, PreprocessConversionTest, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, PreprocessConversionTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(ioPrecisions), @@ -144,7 +144,7 @@ namespace { ::testing::ValuesIn(multiConfigs)), PreprocessConversionTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, PreprocessDynamicallyInSetBlobTest, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, PreprocessDynamicallyInSetBlobTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Bool(), @@ -158,7 +158,7 @@ namespace { ::testing::ValuesIn(multiConfigs)), PreprocessDynamicallyInSetBlobTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, PreprocessConversionTest, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, PreprocessConversionTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(ioPrecisions), @@ -172,7 +172,7 @@ namespace { ::testing::ValuesIn(autoConfigs)), PreprocessConversionTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, PreprocessDynamicallyInSetBlobTest, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, PreprocessDynamicallyInSetBlobTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Bool(), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/test_plugin.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/test_plugin.cpp index da76bc26498b1e..f8728390c9ed9b 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/test_plugin.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/test_plugin.cpp @@ -46,63 +46,63 @@ namespace { }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, BehaviorTestOutput, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, BehaviorTestOutput, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(configsOutput)), BehaviorTestOutput::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, BehaviorTestOutput, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, BehaviorTestOutput, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(MultiConfigsInputOutput)), BehaviorTestOutput::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, BehaviorTestOutput, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, BehaviorTestOutput, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), ::testing::ValuesIn(AutoConfigsInputOutput)), BehaviorTestOutput::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, BehaviorTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, BehaviorTests, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(configs)), BehaviorTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, BehaviorTests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, BehaviorTests, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(MultiConfigs)), BehaviorTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, BehaviorTests, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, BehaviorTests, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_AUTO), ::testing::ValuesIn(AutoConfigs)), BehaviorTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, BehaviorTestInput, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, BehaviorTestInput, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(configsInput)), BehaviorTestInput::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, BehaviorTestInput, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, BehaviorTestInput, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(MultiConfigsInputOutput)), BehaviorTestInput::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, BehaviorTestInput, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, BehaviorTestInput, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/version.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/version.cpp index bcbe9dfaf08fdf..66b5a3c06685cd 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/version.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/version.cpp @@ -22,28 +22,28 @@ namespace { {{ HETERO_CONFIG_KEY(DUMP_GRAPH_DOT) , CommonTestUtils::DEVICE_CPU}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, VersionTest, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, VersionTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(configs)), VersionTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, VersionTest, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, VersionTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(Multiconfigs)), VersionTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, VersionTest, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, VersionTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_AUTO), ::testing::ValuesIn(Autoconfigs)), VersionTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Hetero_BehaviorTests, VersionTest, + INSTANTIATE_TEST_SUITE_P(smoke_Hetero_BehaviorTests, VersionTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_HETERO), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/configuration_tests/configuration_tests.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/configuration_tests/configuration_tests.cpp index dc1e42f28e2ede..48f4b0bc4d274c 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/configuration_tests/configuration_tests.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/configuration_tests/configuration_tests.cpp @@ -13,7 +13,7 @@ auto defaultBindThreadParameter = InferenceEngine::Parameter{std::string{CONFIG_ #else auto defaultBindThreadParameter = InferenceEngine::Parameter{std::string{CONFIG_VALUE(YES)}}; #endif -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Basic, DefaultConfigurationTest, ::testing::Combine( diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/configuration_tests/dynamic_batch.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/configuration_tests/dynamic_batch.cpp index 6c882e13ab71cb..0b6ff2ae24e74b 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/configuration_tests/dynamic_batch.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/configuration_tests/dynamic_batch.cpp @@ -19,7 +19,7 @@ std::map additional_config = { } // namespace -INSTANTIATE_TEST_CASE_P(smoke_DynamicBatchTest_async, DynamicBatchTest, +INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchTest_async, DynamicBatchTest, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::Values(InferenceEngine::Precision::FP32), @@ -28,7 +28,7 @@ INSTANTIATE_TEST_CASE_P(smoke_DynamicBatchTest_async, DynamicBatchTest, ::testing::Values(additional_config)), DynamicBatchTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_DynamicBatchTest_sync, DynamicBatchTest, +INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchTest_sync, DynamicBatchTest, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::Values(InferenceEngine::Precision::FP32), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/exec_graph_serialization.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/exec_graph_serialization.cpp index f8bcd35e9a469b..5d0346424a1bca 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/exec_graph_serialization.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/exec_graph_serialization.cpp @@ -9,7 +9,7 @@ namespace { using namespace ExecutionGraphTests; -INSTANTIATE_TEST_CASE_P(smoke_serialization, ExecGraphSerializationTest, +INSTANTIATE_TEST_SUITE_P(smoke_serialization, ExecGraphSerializationTest, ::testing::Values(CommonTestUtils::DEVICE_CPU), ExecGraphSerializationTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/keep_assign.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/keep_assign.cpp index 83f9808d267b2b..de0da5d16078f1 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/keep_assign.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/keep_assign.cpp @@ -9,7 +9,7 @@ using namespace ExecutionGraphTests; namespace { -INSTANTIATE_TEST_CASE_P(smoke_KeepAssign, ExecGraphKeepAssignNode, +INSTANTIATE_TEST_SUITE_P(smoke_KeepAssign, ExecGraphKeepAssignNode, ::testing::Values(CommonTestUtils::DEVICE_CPU), ExecGraphKeepAssignNode::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/nms_transformation_for_last_node.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/nms_transformation_for_last_node.cpp index 5d5fbe597f8398..8d4d11972d9fb0 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/nms_transformation_for_last_node.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/nms_transformation_for_last_node.cpp @@ -8,6 +8,6 @@ namespace { using namespace ExecutionGraphTests; -INSTANTIATE_TEST_CASE_P(smoke_NmsTransformationLastNode, ExecGraphNmsTransformLastNode, ::testing::Values(CommonTestUtils::DEVICE_CPU), +INSTANTIATE_TEST_SUITE_P(smoke_NmsTransformationLastNode, ExecGraphNmsTransformLastNode, ::testing::Values(CommonTestUtils::DEVICE_CPU), ExecGraphNmsTransformLastNode::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/num_inputs_fusing_bin_conv.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/num_inputs_fusing_bin_conv.cpp index 4ff4c385747dd3..4b31128536189b 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/num_inputs_fusing_bin_conv.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/num_inputs_fusing_bin_conv.cpp @@ -8,6 +8,6 @@ namespace { using namespace ExecutionGraphTests; -INSTANTIATE_TEST_CASE_P(smoke_inputsNumFusingBinConv, ExecGraphInputsFusingBinConv, ::testing::Values(CommonTestUtils::DEVICE_CPU), +INSTANTIATE_TEST_SUITE_P(smoke_inputsNumFusingBinConv, ExecGraphInputsFusingBinConv, ::testing::Values(CommonTestUtils::DEVICE_CPU), ExecGraphInputsFusingBinConv::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/remove_parameter.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/remove_parameter.cpp index 790a8f91aeda61..2706e2c3578ace 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/remove_parameter.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/remove_parameter.cpp @@ -9,7 +9,7 @@ using namespace ExecutionGraphTests; namespace { -INSTANTIATE_TEST_CASE_P(smoke_removeParameter, ExecGraphRemoveParameterNode, +INSTANTIATE_TEST_SUITE_P(smoke_removeParameter, ExecGraphRemoveParameterNode, ::testing::Values(CommonTestUtils::DEVICE_CPU), ExecGraphRemoveParameterNode::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/runtime_precision.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/runtime_precision.cpp index f95ba68b777ddf..6d1272c2c8f175 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/runtime_precision.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/runtime_precision.cpp @@ -24,7 +24,7 @@ const std::vector params = { {makeFakeQuantizeBinaryConvolutionFunction, {Precision::FP32}, {{"FakeQuantize", Precision::FP32}, {"BinaryConvolution", Precision::BIN}}}, }; -INSTANTIATE_TEST_CASE_P(smoke_ExecGraph, ExecGraphRuntimePrecision, +INSTANTIATE_TEST_SUITE_P(smoke_ExecGraph, ExecGraphRuntimePrecision, ::testing::Combine( ::testing::ValuesIn(params), ::testing::Values(CommonTestUtils::DEVICE_CPU)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/unique_node_names.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/unique_node_names.cpp index ebd1d57c3ef107..d470fc7bc04730 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/unique_node_names.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/unique_node_names.cpp @@ -15,7 +15,7 @@ const std::vector netPrecisions = { InferenceEngine::Precision::FP32 }; -INSTANTIATE_TEST_CASE_P(smoke_NoReshape, ExecGraphUniqueNodeNames, +INSTANTIATE_TEST_SUITE_P(smoke_NoReshape, ExecGraphUniqueNodeNames, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::SizeVector({1, 2, 5, 5})), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/hetero/query_network.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/hetero/query_network.cpp index ff05d70af9cad7..0ba1d74c899913 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/hetero/query_network.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/hetero/query_network.cpp @@ -13,7 +13,7 @@ using namespace HeteroTests; auto ConvBias = ngraph::builder::subgraph::makeConvBias(); -INSTANTIATE_TEST_CASE_P(smoke_FullySupportedTopologies, QueryNetworkTest, +INSTANTIATE_TEST_SUITE_P(smoke_FullySupportedTopologies, QueryNetworkTest, ::testing::Combine( ::testing::Values("CPU", "HETERO:CPU", "MULTI:CPU"), ::testing::Values(ConvBias)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/hetero/synthetic.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/hetero/synthetic.cpp index 49f4ddda323f55..8c531cb2c151fb 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/hetero/synthetic.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/hetero/synthetic.cpp @@ -11,13 +11,13 @@ namespace { using namespace HeteroTests; -INSTANTIATE_TEST_CASE_P(smoke_SingleMajorNode, HeteroSyntheticTest, +INSTANTIATE_TEST_SUITE_P(smoke_SingleMajorNode, HeteroSyntheticTest, ::testing::Combine( ::testing::Values(std::vector{{"CPU0", "MKLDNNPlugin"}, {"CPU1", "MKLDNNPlugin"}}), ::testing::ValuesIn(HeteroTests::HeteroSyntheticTest::_singleMajorNodeFunctions)), HeteroSyntheticTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(nightly_RandomMajorNodes, HeteroSyntheticTest, +INSTANTIATE_TEST_SUITE_P(nightly_RandomMajorNodes, HeteroSyntheticTest, ::testing::Combine( ::testing::Values(std::vector{{"CPU0", "MKLDNNPlugin"}, {"CPU1", "MKLDNNPlugin"}}), ::testing::ValuesIn(HeteroTests::HeteroSyntheticTest::_randomMajorNodeFunctions)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp index c90dc6545d6a11..f575a6cc2ec472 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp @@ -68,7 +68,7 @@ const std::vector params = { { {}, {}, false }, { {}, {}, true }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, AddTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, AddTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/clamp_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/clamp_transformation.cpp index a657058d1feb1f..6f45a17b35214e 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/clamp_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/clamp_transformation.cpp @@ -76,7 +76,7 @@ const std::vector params{ } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ClampTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ClampTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_transformation.cpp index be35416515a9d7..60d5e1ff730589 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_transformation.cpp @@ -49,7 +49,7 @@ const std::vector shapes = { ngraph::Shape({ 4, 3, 16, 16 }) }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ConcatTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::ValuesIn(shapes), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_child_and_output.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_child_and_output.cpp index 5688483d58b110..0141d37d23a5ef 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_child_and_output.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_child_and_output.cpp @@ -42,7 +42,7 @@ const std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ConcatWithChildAndOutputTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatWithChildAndOutputTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 6, 10, 10 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_different_precision_on_children.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_different_precision_on_children.cpp index fe0cd0b5465477..dc7d9936e6af76 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_different_precision_on_children.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_different_precision_on_children.cpp @@ -45,7 +45,7 @@ const std::vector testValues = { const std::vector multiChannel = { true/*, false*/ }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ConcatWithDifferentChildrenTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatWithDifferentChildrenTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 6, 10, 10 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_intermediate_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_intermediate_transformation.cpp index c4f984b8e94a65..8c24e9cec2091d 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_intermediate_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_intermediate_transformation.cpp @@ -31,7 +31,7 @@ const std::vector shapes = { { 4, 3, 16, 16 } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ConcatWithIntermediateTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatWithIntermediateTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(shapes), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_neighbors_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_neighbors_transformation.cpp index 9ece832517f48c..a0724e1bfe667c 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_neighbors_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_neighbors_transformation.cpp @@ -28,7 +28,7 @@ const std::vector shapes = { { 4, 3, 16, 16 } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ConcatWithNeighborsGraphTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatWithNeighborsGraphTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::ValuesIn(shapes), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp index 4c9d43c124f847..f6d2f1c16b78fd 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp @@ -45,7 +45,7 @@ const std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ConcatWithSplitTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatWithSplitTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 6, 10, 10 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp index 223f9743a61888..180ef107e02ebb 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp @@ -108,7 +108,7 @@ const std::vector outputShapes = { { 16, 16 } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ConvolutionBackpropDataTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConvolutionBackpropDataTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(inputShapes), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_qdq_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_qdq_transformation.cpp index fdaae7a35f7c88..5cb46fc2ee868c 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_qdq_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_qdq_transformation.cpp @@ -238,7 +238,7 @@ const std::vector shapes = { { 4, 3, 4, 4 } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ConvolutionQDqTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConvolutionQDqTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(shapes), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_transformation.cpp index 594e645980aa74..0a574422ae8469 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_transformation.cpp @@ -101,7 +101,7 @@ const std::vector shapes = { { 4, 3, 16, 16 } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ConvolutionTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConvolutionTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(shapes), @@ -125,7 +125,7 @@ const std::vector i } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ConvolutionWIthIncorrectWeightsTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConvolutionWIthIncorrectWeightsTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/depth_to_space_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/depth_to_space_transformation.cpp index baf025aefacca9..d9057f66a92565 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/depth_to_space_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/depth_to_space_transformation.cpp @@ -34,7 +34,7 @@ const auto DepthToSpaceBS2 = ::testing::Combine( ::testing::Values(2) ); -INSTANTIATE_TEST_CASE_P(LPT_BS2, DepthToSpaceTransformation, DepthToSpaceBS2, DepthToSpaceTransformation::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(LPT_BS2, DepthToSpaceTransformation, DepthToSpaceBS2, DepthToSpaceTransformation::getTestCaseName); const std::vector inputShapesBS3 = { {1, 9, 3, 3}, {2, 27, 5, 4} @@ -48,5 +48,5 @@ const auto DepthToSpaceBS3 = ::testing::Combine( ::testing::Values(3) ); -INSTANTIATE_TEST_CASE_P(smoke_LPT_BS3, DepthToSpaceTransformation, DepthToSpaceBS3, DepthToSpaceTransformation::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_LPT_BS3, DepthToSpaceTransformation, DepthToSpaceBS3, DepthToSpaceTransformation::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp index cf86089bfd68f5..d0f2b614f43a89 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp @@ -26,7 +26,7 @@ const std::vector fakeQuantizes = // FakeQuantizeOnData -INSTANTIATE_TEST_CASE_P(smoke_LPT, FakeQuantizeAndAvgPoolTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, FakeQuantizeAndAvgPoolTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp index fe184eef51659a..78df11d2f7853d 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp @@ -26,7 +26,7 @@ const std::vector fakeQuantizes = // FakeQuantizeOnData -INSTANTIATE_TEST_CASE_P(smoke_LPT, FakeQuantizeAndMaxPoolTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, FakeQuantizeAndMaxPoolTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp index 29124d9503b9c8..adb79c659ecd32 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp @@ -28,7 +28,7 @@ const std::vector testValues = } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, FakeQuantizeAndTwoOutputBranchesWithConvolutionTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, FakeQuantizeAndTwoOutputBranchesWithConvolutionTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp index 3b897406957e18..f2e7df2acde38b 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp @@ -56,7 +56,7 @@ const std::vector testVa }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, FakeQuantizePrecisionSelectionTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, FakeQuantizePrecisionSelectionTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp index 0208a6b0e7217b..69ce1065c206c1 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp @@ -59,7 +59,7 @@ const std::vector fakeQuantizeOnDataValues = { // { 256ul, { 1ul }, { -1.28f} , { 1.27f } } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, FakeQuantizeTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, FakeQuantizeTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp index 073e13da0b78d1..af1a82dcd41bfe 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp @@ -101,7 +101,7 @@ const std::vector fakeQuanti } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, FakeQuantizeWithNotOptimalTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, FakeQuantizeWithNotOptimalTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fully_connected_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fully_connected_transformation.cpp index e439c53abcefd4..a285b41a53675f 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fully_connected_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fully_connected_transformation.cpp @@ -41,7 +41,7 @@ const std::vector tras LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams() }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, FullyConnectedTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, FullyConnectedTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(shapes), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_convert_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_convert_transformation.cpp index f59e9bcf8e8ffe..8082ecfe96d7ec 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_convert_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_convert_transformation.cpp @@ -31,7 +31,7 @@ const std::vector deqOperat const std::vector constInput = { true, false }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, FuseConvertTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, FuseConvertTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::ValuesIn(inputAndQuantizationShapes), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp index 189cc02d14b1cd..8d4b127eb48ae0 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp @@ -33,7 +33,7 @@ const std::vector fakeQuantizeOnD // }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, FuseFakeQuantizeAndScaleShiftTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, FuseFakeQuantizeAndScaleShiftTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 9, 9 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_transformation.cpp index 39a32db4ceeafc..d1d38ed94d72fd 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_transformation.cpp @@ -104,7 +104,7 @@ const std::vector testValues = { }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, FuseFakeQuantizeTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, FuseFakeQuantizeTransformation, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(testValues)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.cpp index 927c64cad19e2a..81674818d6bce2 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.cpp @@ -31,7 +31,7 @@ const std::vector testValues }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, FuseMultiplyToFakeQuantizeTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, FuseMultiplyToFakeQuantizeTransformation, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(testValues)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.cpp index 252015a0a42c9a..4a65f1eb27bc4a 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.cpp @@ -31,7 +31,7 @@ const std::vector testValues }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, FuseSubtractToFakeQuantizeTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, FuseSubtractToFakeQuantizeTransformation, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(testValues)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp index 52e9223f208e5a..242df59cfff1ae 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp @@ -27,7 +27,7 @@ const std::vector trasformationParamValues = { LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8() }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, GemmTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, GemmTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(dimensions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp index 739897ee27350e..d8a81076d61ce9 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp @@ -97,7 +97,7 @@ const std::vector pa } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, GroupConvolutionTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, GroupConvolutionTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/groupconvolution_qdq_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/groupconvolution_qdq_transformation.cpp index 54f14fb037d20e..74c60def9fc5c5 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/groupconvolution_qdq_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/groupconvolution_qdq_transformation.cpp @@ -492,7 +492,7 @@ const std::vector shapes = { { 1, 4, 7, 7 } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, GroupConvolutionQDqTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, GroupConvolutionQDqTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(shapes), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/interpolate_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/interpolate_transformation.cpp index d8e2854699ea91..7954fac1a232a0 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/interpolate_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/interpolate_transformation.cpp @@ -47,5 +47,5 @@ const auto combineValues = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(interpAttrs)); -INSTANTIATE_TEST_CASE_P(smoke_LPT, InterpolateTransformation, combineValues, InterpolateTransformation::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_LPT, InterpolateTransformation, combineValues, InterpolateTransformation::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp index 58caafc62f5dd9..2df46fe0bfc5c5 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp @@ -42,7 +42,7 @@ std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, MatMulTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, MatMulTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::Values(ngraph::Shape({ 1, 384, 1024 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_with_constant_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_with_constant_transformation.cpp index 34e2dbf542d46b..776be2284259d2 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_with_constant_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_with_constant_transformation.cpp @@ -96,7 +96,7 @@ std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, MatMulWithConstantTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, MatMulWithConstantTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp index 47d7d6eda915b4..76ec3422c0638d 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp @@ -26,7 +26,7 @@ const std::vector> inputShapes = { std::pair({ 1, 16 }, { 16, 10 }) }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, MatMulWithOptimizedConstantFakeQuantizeTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, MatMulWithOptimizedConstantFakeQuantizeTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(inputShapes), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_to_group_convolution_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_to_group_convolution_transformation.cpp index 0a7baea851642d..39dc081f40265a 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_to_group_convolution_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_to_group_convolution_transformation.cpp @@ -22,7 +22,7 @@ const std::vector fqOnData = { { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 25.5f }, { -12.8f }, { 12.7f } } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, MultiplyToGroupConvolutionTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, MultiplyToGroupConvolutionTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::ValuesIn(inputShapes), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_transformation.cpp index 1814b6830eea09..8f791dc2e7cf5f 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_transformation.cpp @@ -67,7 +67,7 @@ const std::vector params = { { {}, {}, false }, { {}, {}, true }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, MultiplyTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, MultiplyTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp index efafab0e36ec6b..2c790eb7023473 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp @@ -21,7 +21,7 @@ const std::vector values = { } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, MultiplyWithOneParentTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, MultiplyWithOneParentTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp index fd3811e909eb56..505fffa8d54424 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp @@ -20,7 +20,7 @@ const std::vector reductionAxes = { { 2, 3 }, { 1, 2, 3 } }; const std::vector normalizeVariance = { true, false }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, MVNTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, MVNTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::ValuesIn(inputAndQuantizationShapes), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/normalize_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/normalize_transformation.cpp index ed312302d5ec1a..6a88af8938d97b 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/normalize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/normalize_transformation.cpp @@ -29,7 +29,7 @@ const std::vector fuseMultiplyValues = { true, false }; const std::vector shiftValues = { true, false }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, NormalizeL2Transformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, NormalizeL2Transformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::ValuesIn(inputAndQuantizationShapes), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations.cpp index d2ae271b277c67..828d9f852bf53b 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations.cpp @@ -23,7 +23,7 @@ const std::vector trasformationParamValues = { }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, OutputLayersHandlingInTransformations, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, OutputLayersHandlingInTransformations, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations_for_concat.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations_for_concat.cpp index ea42b1c8ef336b..a8ee6f581f5467 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations_for_concat.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations_for_concat.cpp @@ -22,7 +22,7 @@ const std::vector trasformationParamValues = { LayerTestsUtils::LayerTransformationParamsFactory::createParamsU8I8() }; -INSTANTIATE_TEST_CASE_P(DISABLED_smoke_LPT, OutputLayersHandlingInTransformationsForConcat, +INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_LPT, OutputLayersHandlingInTransformationsForConcat, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations_for_concat_multi_channel.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations_for_concat_multi_channel.cpp index aa09761dd87519..6c0c6ad3fd1bfb 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations_for_concat_multi_channel.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations_for_concat_multi_channel.cpp @@ -23,7 +23,7 @@ const std::vector trasformationParamValues = { }; // TODO: issue #41231: enable previous LPT version tests -INSTANTIATE_TEST_CASE_P(DISABLED_smoke_LPT, OutputLayersHandlingInTransformationsForConcatMultiChannel, +INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_LPT, OutputLayersHandlingInTransformationsForConcatMultiChannel, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp index ac0af7702391b0..bb35f882e628c8 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp @@ -23,7 +23,7 @@ std::vector testValues = { { { 256ul, ngraph::Shape({}), {-12.8f / 2.f}, {12.7f}, {-12.8f / 2.f}, {12.7f} }, true } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, PReluTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, PReluTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/pull_reshape_through_dequantization_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/pull_reshape_through_dequantization_transformation.cpp index d0c33423c175d6..0d8ca9c22840b9 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/pull_reshape_through_dequantization_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/pull_reshape_through_dequantization_transformation.cpp @@ -70,7 +70,7 @@ const std::vector dequantizationOnWeightElementwiseConstantShapes { ngraph::Shape({1, 16}) } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, PullReshapeThroughDequantizationTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, PullReshapeThroughDequantizationTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(inputShapes), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_max_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_max_transformation.cpp index 6a29b84fb0ebe3..a24ef762ea5db9 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_max_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_max_transformation.cpp @@ -104,7 +104,7 @@ const std::vector params = }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ReduceMaxTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ReduceMaxTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 10, 10 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_mean_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_mean_transformation.cpp index 7310ca764e671e..7c6d1b60c6ba7c 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_mean_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_mean_transformation.cpp @@ -104,7 +104,7 @@ const std::vector params = }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ReduceMeanTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ReduceMeanTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 10, 10 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_min_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_min_transformation.cpp index 5bc4f1f3ba0b60..af56b057a33084 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_min_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_min_transformation.cpp @@ -104,7 +104,7 @@ const std::vector params = }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ReduceMinTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ReduceMinTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 10, 10 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_sum_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_sum_transformation.cpp index 2ab45ce1fb92b8..cf767b71e4d860 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_sum_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_sum_transformation.cpp @@ -90,7 +90,7 @@ const std::vector params = }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ReduceSumTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ReduceSumTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 10, 10 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp index 25d7bd0398e267..460d050f6aaa79 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp @@ -24,7 +24,7 @@ std::vector testValues = { { { 256ul, ngraph::Shape({}), {-12.8f / 2.f}, {12.7f}, {-12.8f / 2.f}, {12.7f} }, true } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ReluTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ReluTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp index 5a9342ca718655..599b3de32e6d2c 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp @@ -52,7 +52,7 @@ const std::vector params = { }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ReshapeTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ReshapeTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/shuffle_channels_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/shuffle_channels_transformation.cpp index 6d2e97a0008ea9..2a214de6d3a2f1 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/shuffle_channels_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/shuffle_channels_transformation.cpp @@ -90,7 +90,7 @@ const std::vector par }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ShuffleChannelsTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ShuffleChannelsTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(inputShapes), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/split_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/split_transformation.cpp index be380eeac0963f..56f3c7e2f256f9 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/split_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/split_transformation.cpp @@ -84,7 +84,7 @@ const std::vector params = { } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, SplitTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, SplitTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/squeeze_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/squeeze_transformation.cpp index efe0109ee55192..0e608b55c10fa2 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/squeeze_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/squeeze_transformation.cpp @@ -45,7 +45,7 @@ namespace { } }; - INSTANTIATE_TEST_CASE_P(smoke_LPT, SqueezeTransformation, + INSTANTIATE_TEST_SUITE_P(smoke_LPT, SqueezeTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/strided_slice_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/strided_slice_transformation.cpp index 273daf6f7102e8..a66106064a1a44 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/strided_slice_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/strided_slice_transformation.cpp @@ -89,7 +89,7 @@ const std::vector params } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, StridedSliceTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, StridedSliceTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 24, 24 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.cpp index db33013688268e..6f2c4136e1a159 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.cpp @@ -58,7 +58,7 @@ const std::vector testVal }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, SubtractMultiplyToMultiplyAddTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, SubtractMultiplyToMultiplyAddTransformation, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(testValues)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp index 4b3c6a792c3efb..3a5d5d6a32f607 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp @@ -22,7 +22,7 @@ const std::vector trasformationParamValues = { LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8() }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, SubtractTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, SubtractTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp index f378f4ff487639..98eb3cdde77033 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp @@ -26,7 +26,7 @@ const std::vector perTensorValues = { true, false }; const std::vector transposeChannelDimValues = { true, false }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, TransposeAfterMatMulTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, TransposeAfterMatMulTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/transpose_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/transpose_transformation.cpp index 28c09a394543dc..390daa853c254c 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/transpose_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/transpose_transformation.cpp @@ -41,7 +41,7 @@ const std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, TransposeTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, TransposeTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/unsqueeze_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/unsqueeze_transformation.cpp index b245edb9bec4f4..eb8e47fe08c36a 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/unsqueeze_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/unsqueeze_transformation.cpp @@ -50,7 +50,7 @@ namespace { } }; - INSTANTIATE_TEST_CASE_P(smoke_LPT, UnsqueezeTransformation, + INSTANTIATE_TEST_SUITE_P(smoke_LPT, UnsqueezeTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/variadic_split_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/variadic_split_transformation.cpp index 5778caa6fb8687..247dce334444f3 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/variadic_split_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/variadic_split_transformation.cpp @@ -90,7 +90,7 @@ const std::vector param }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, VariadicSplitTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, VariadicSplitTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/multi/cpu_remote_blob_tests.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/multi/cpu_remote_blob_tests.cpp index 3b0ba475eae223..ba5442e158e815 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/multi/cpu_remote_blob_tests.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/multi/cpu_remote_blob_tests.cpp @@ -11,5 +11,5 @@ const std::vector device_names_and_support_for_remot {{CPU}, false}, // CPU via MULTI }; -INSTANTIATE_TEST_CASE_P(smoke_RemoteBlobMultiCPU, MultiDevice_SupportTest, +INSTANTIATE_TEST_SUITE_P(smoke_RemoteBlobMultiCPU, MultiDevice_SupportTest, ::testing::ValuesIn(device_names_and_support_for_remote_blobs), MultiDevice_SupportTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/ngraph_conversion_tests/conv_bias_fusion.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/ngraph_conversion_tests/conv_bias_fusion.cpp index 5f8562bfa555d3..53d8627119c85d 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/ngraph_conversion_tests/conv_bias_fusion.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/ngraph_conversion_tests/conv_bias_fusion.cpp @@ -9,6 +9,6 @@ using namespace NGraphConversionTestsDefinitions; namespace { -INSTANTIATE_TEST_CASE_P(smoke_Basic, ConvBiasFusion, ::testing::Values("CPU"), ConvBiasFusion::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Basic, ConvBiasFusion, ::testing::Values("CPU"), ConvBiasFusion::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/ngraph_conversion_tests/plugin_specific_ngraph_conversion.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/ngraph_conversion_tests/plugin_specific_ngraph_conversion.cpp index 5ba015166dd6af..d4b2e16b6ee316 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/ngraph_conversion_tests/plugin_specific_ngraph_conversion.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/ngraph_conversion_tests/plugin_specific_ngraph_conversion.cpp @@ -9,6 +9,6 @@ using namespace NGraphConversionTestsDefinitions; namespace { -INSTANTIATE_TEST_CASE_P(smoke_Basic, PluginSpecificConversion, ::testing::Values("CPU"), PluginSpecificConversion::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Basic, PluginSpecificConversion, ::testing::Values("CPU"), PluginSpecificConversion::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp index 51e379a67f128b..87f986f980fffc 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp @@ -124,10 +124,10 @@ const auto basicIntegerOperations = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_Activation_Basic, ActivationLayerTest, basicCases, ActivationLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Activation_Basic, ActivationDynamicLayerTest, basicCases, ActivationLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Integer_Activation_Basic, ActivationLayerTest, basicIntegerOperations, ActivationLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Activation_Basic, ActivationLayerTest, basicCases, ActivationLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Activation_Basic, ActivationDynamicLayerTest, basicCases, ActivationLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Integer_Activation_Basic, ActivationLayerTest, basicIntegerOperations, ActivationLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Activation_Basic_Prelu_Const, ActivationLayerTest, basicPreluCases, ActivationLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Activation_Basic_Prelu_Param, ActivationParamLayerTest, basicPreluCases, ActivationLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Activation_Basic_Prelu_Const, ActivationLayerTest, basicPreluCases, ActivationLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Activation_Basic_Prelu_Param, ActivationParamLayerTest, basicPreluCases, ActivationLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/batch_norm.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/batch_norm.cpp index 753efd3acaa84c..f765e2d0afeadb 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/batch_norm.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/batch_norm.cpp @@ -40,7 +40,7 @@ const auto batchNormParams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_BatchNorm, BatchNormLayerTest, batchNormParams, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/batch_to_space.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/batch_to_space.cpp index 18a099484fffb6..ddf930f34b72b5 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/batch_to_space.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/batch_to_space.cpp @@ -49,7 +49,7 @@ batchToSpaceParamsTuple bts_only_test_cases[] = { CommonTestUtils::DEVICE_CPU), }; -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN, BatchToSpaceLayerTest, ::testing::ValuesIn(bts_only_test_cases), +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN, BatchToSpaceLayerTest, ::testing::ValuesIn(bts_only_test_cases), BatchToSpaceLayerTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/binary_convolution.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/binary_convolution.cpp index d451e80b292067..369015510d567a 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/binary_convolution.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/binary_convolution.cpp @@ -44,7 +44,7 @@ const auto binConv2DParams_ValidPadding = ::testing::Combine( ::testing::Values(ngraph::op::PadType::VALID), ::testing::ValuesIn(padValues)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_BinaryConvolution2D_ExplicitPadding, BinaryConvolutionLayerTest, ::testing::Combine( binConv2DParams_ExplicitPadding, @@ -57,7 +57,7 @@ INSTANTIATE_TEST_CASE_P( ::testing::Values(CommonTestUtils::DEVICE_CPU)), BinaryConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_BinaryConvolution2D_AutoPadValid, BinaryConvolutionLayerTest, ::testing::Combine( binConv2DParams_ValidPadding, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/broadcast.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/broadcast.cpp index 8f69fd6ee4bcef..d30ba6cd215ba5 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/broadcast.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/broadcast.cpp @@ -38,7 +38,7 @@ const auto numpyBroadcastParams1 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_TestNumpyBroadcast1, BroadcastLayerTest, numpyBroadcastParams1, @@ -54,7 +54,7 @@ const auto numpyBroadcastParams2 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_TestNumpyBroadcast2, BroadcastLayerTest, numpyBroadcastParams2, @@ -84,7 +84,7 @@ const auto bidirectionalBroadcastParams1 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_TestBidirectionalBroadcast1, BroadcastLayerTest, bidirectionalBroadcastParams1, @@ -100,7 +100,7 @@ const auto bidirectionalBroadcastParams2 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_TestBidirectionalBroadcast2, BroadcastLayerTest, bidirectionalBroadcastParams2, @@ -116,7 +116,7 @@ const auto bidirectionalBroadcastParams3 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_TestBidirectionalBroadcast3, BroadcastLayerTest, bidirectionalBroadcastParams3, @@ -149,7 +149,7 @@ const auto explicitBroadcastParams1 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_TestExplicitBroadcast1, BroadcastLayerTest, explicitBroadcastParams1, @@ -165,7 +165,7 @@ const auto explicitBroadcastParams2 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_TestExplicitBroadcast2, BroadcastLayerTest, explicitBroadcastParams2, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/bucketize.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/bucketize.cpp index 6d75dfe3717a2d..6398fa83ef0fb0 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/bucketize.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/bucketize.cpp @@ -52,5 +52,5 @@ const auto test_Bucketize_left_edge = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_TestsBucketize_right, BucketizeLayerTest, test_Bucketize_right_edge, BucketizeLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_TestsBucketize_left, BucketizeLayerTest, test_Bucketize_left_edge, BucketizeLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsBucketize_right, BucketizeLayerTest, test_Bucketize_right_edge, BucketizeLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsBucketize_left, BucketizeLayerTest, test_Bucketize_left_edge, BucketizeLayerTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/clamp.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/clamp.cpp index 200350fd316067..9f146ae0dbf12b 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/clamp.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/clamp.cpp @@ -48,5 +48,5 @@ const auto test_Clamp_unsigned = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_TestsClamp_signed, ClampLayerTest, test_Clamp_signed, ClampLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_TestsClamp_unsigned, ClampLayerTest, test_Clamp_unsigned, ClampLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsClamp_signed, ClampLayerTest, test_Clamp_signed, ClampLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsClamp_unsigned, ClampLayerTest, test_Clamp_unsigned, ClampLayerTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/comparison.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/comparison.cpp index d1602d698a07e3..ad6c1c897b1c42 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/comparison.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/comparison.cpp @@ -50,6 +50,6 @@ const auto ComparisonTestParams = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::Values(additional_config)); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs, ComparisonLayerTest, ComparisonTestParams, ComparisonLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs, ComparisonLayerTest, ComparisonTestParams, ComparisonLayerTest::getTestCaseName); } // namespace \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/concat.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/concat.cpp index 7c75e31a3548b9..e983d4a65ec428 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/concat.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/concat.cpp @@ -24,7 +24,7 @@ std::vector>> inShapes = { std::vector netPrecisions = {InferenceEngine::Precision::FP32, InferenceEngine::Precision::FP16}; -INSTANTIATE_TEST_CASE_P(smoke_NoReshape, ConcatLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_NoReshape, ConcatLayerTest, ::testing::Combine( ::testing::ValuesIn(axes), ::testing::ValuesIn(inShapes), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/constant.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/constant.cpp index 06ee157d39108f..5a06250dd6ed08 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/constant.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/constant.cpp @@ -39,13 +39,13 @@ std::vector precisionsWithNegativeValues{ std::vector dataWithNegativeValues{"1", "-2", "3", "-4", "5", "-6", "7", "-1", "2", "-3", "4", "-5"}; -INSTANTIATE_TEST_CASE_P(smoke_Constant, ConstantLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Constant, ConstantLayerTest, ::testing::Combine(::testing::ValuesIn(shapes), ::testing::ValuesIn(precisions), ::testing::Values(data), ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConstantLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Constant_with_negative_values, ConstantLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Constant_with_negative_values, ConstantLayerTest, ::testing::Combine(::testing::ValuesIn(shapes), ::testing::ValuesIn(precisionsWithNegativeValues), ::testing::Values(dataWithNegativeValues), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convert.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convert.cpp index 3a024a65965bc1..70ed6c6512fc41 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convert.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convert.cpp @@ -24,7 +24,7 @@ const std::vector precisions = { Precision::FP32 }; -INSTANTIATE_TEST_CASE_P(smoke_ConvertLayerTest, ConvertLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvertLayerTest, ConvertLayerTest, ::testing::Combine( ::testing::Values(inShape), ::testing::ValuesIn(precisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convert_like.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convert_like.cpp index abb8d43057e3b1..f9e20dcf0de0a2 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convert_like.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convert_like.cpp @@ -19,7 +19,7 @@ const std::vector netPrecisions = { InferenceEngine::Precision::I8, }; -INSTANTIATE_TEST_CASE_P(smoke_NoReshape, ConvertLikeLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_NoReshape, ConvertLikeLayerTest, ::testing::Combine( ::testing::Values(inShape), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convolution.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convolution.cpp index 325636314d7bd5..fbaba32e8d8b87 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convolution.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convolution.cpp @@ -35,7 +35,7 @@ const auto conv1DParams_AutoPadValid = ::testing::Combine( ::testing::ValuesIn(dilations1D), ::testing::ValuesIn(numOutChannels1D), ::testing::Values(ngraph::op::PadType::VALID)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Convolution1D_ExplicitPadding, ConvolutionLayerTest, ::testing::Combine( conv1DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -47,7 +47,7 @@ INSTANTIATE_TEST_CASE_P( ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Convolution1D_AutoPadValid, ConvolutionLayerTest, ::testing::Combine( conv1DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), @@ -79,7 +79,7 @@ const auto conv2DParams_AutoPadValid = ::testing::Combine( ::testing::ValuesIn(dilations), ::testing::ValuesIn(numOutChannels), ::testing::Values(ngraph::op::PadType::VALID)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Convolution2D_ExplicitPadding, ConvolutionLayerTest, ::testing::Combine( conv2DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -91,7 +91,7 @@ INSTANTIATE_TEST_CASE_P( ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Convolution2D_AutoPadValid, ConvolutionLayerTest, ::testing::Combine( conv2DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), @@ -120,7 +120,7 @@ namespace specificWeightLayout { ::testing::Values(numOutChannels), ::testing::Values(ngraph::op::PadType::EXPLICIT)); - INSTANTIATE_TEST_CASE_P(smoke_Convolution2D_SpecificWeightLayout, ConvolutionLayerTest, + INSTANTIATE_TEST_SUITE_P(smoke_Convolution2D_SpecificWeightLayout, ConvolutionLayerTest, ::testing::Combine(conv2DParams_WeightLayout, ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), @@ -151,7 +151,7 @@ const auto conv3DParams_AutoPadValid = ::testing::Combine( ::testing::ValuesIn(dilations3d), ::testing::ValuesIn(numOutChannels3D), ::testing::Values(ngraph::op::PadType::VALID)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Convolution3D_ExplicitPadding, ConvolutionLayerTest, ::testing::Combine( conv3DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -163,7 +163,7 @@ INSTANTIATE_TEST_CASE_P( ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Convolution3D_AutoPadValid, ConvolutionLayerTest, ::testing::Combine( conv3DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convolution_backprop_data.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convolution_backprop_data.cpp index 1a5f3885c9364b..7fe868eccba9ac 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convolution_backprop_data.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convolution_backprop_data.cpp @@ -51,7 +51,7 @@ const auto conv2DParams_AutoPadValid = ::testing::Combine( ::testing::ValuesIn(emptyOutputPadding) ); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_ExplicitPadding, ConvolutionBackpropLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData2D_ExplicitPadding, ConvolutionBackpropLayerTest, ::testing::Combine( conv2DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -64,7 +64,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_ExplicitPadding, Convolu ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvolutionBackpropLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_AutoPadValid, ConvolutionBackpropLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData2D_AutoPadValid, ConvolutionBackpropLayerTest, ::testing::Combine( conv2DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), @@ -80,7 +80,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_AutoPadValid, Convolutio const std::vector> inputShape2D = {{1, 3, 9, 12}}; const std::vector> outputShapes2D = {{6, 6}, {4, 9}}; -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_OutputShapeDefined, ConvolutionBackpropLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData2D_OutputShapeDefined, ConvolutionBackpropLayerTest, ::testing::Combine( conv2DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), @@ -117,7 +117,7 @@ const auto conv2DParams_AutoPadValid_output_padding = ::testing::Combine( ::testing::ValuesIn(outputPadding2D) ); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_ExplicitPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData2D_ExplicitPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, ::testing::Combine( conv2DParams_AutoPadValid_output_padding, ::testing::ValuesIn(netPrecisions), @@ -130,7 +130,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_ExplicitPadding_OutputPa ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvolutionBackpropLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_AutoPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData2D_AutoPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, ::testing::Combine( conv2DParams_ExplicitPadding_output_padding, ::testing::ValuesIn(netPrecisions), @@ -174,7 +174,7 @@ const auto conv3DParams_AutoPadValid = ::testing::Combine( ::testing::ValuesIn(emptyOutputPadding) ); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_ExplicitPadding, ConvolutionBackpropLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData3D_ExplicitPadding, ConvolutionBackpropLayerTest, ::testing::Combine( conv3DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -187,7 +187,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_ExplicitPadding, Convolu ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvolutionBackpropLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_AutoPadValid, ConvolutionBackpropLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData3D_AutoPadValid, ConvolutionBackpropLayerTest, ::testing::Combine( conv3DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), @@ -203,7 +203,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_AutoPadValid, Convolutio const std::vector> inputShape3D = {{1, 3, 10, 10, 10}}; const std::vector> outputShapes3D = {{8, 8, 8}, {10, 10, 10}}; -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_OutputShapeDefined, ConvolutionBackpropLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData3D_OutputShapeDefined, ConvolutionBackpropLayerTest, ::testing::Combine( conv3DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), @@ -240,7 +240,7 @@ const auto conv3DParams_AutoPadValid_output_padding = ::testing::Combine( ::testing::ValuesIn(outputPadding3D) ); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_ExplicitPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData3D_ExplicitPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, ::testing::Combine( conv3DParams_AutoPadValid_output_padding, ::testing::ValuesIn(netPrecisions), @@ -253,7 +253,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_ExplicitPadding_OutputPa ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvolutionBackpropLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_AutoPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData3D_AutoPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, ::testing::Combine( conv3DParams_ExplicitPadding_output_padding, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/ctc_greedy_decoder.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/ctc_greedy_decoder.cpp index b0ddcd67c89d10..4b349fc5978e6a 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/ctc_greedy_decoder.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/ctc_greedy_decoder.cpp @@ -34,7 +34,7 @@ const auto basicCases = ::testing::Combine( ::testing::ValuesIn(mergeRepeated), ::testing::Values(CommonTestUtils::DEVICE_CPU)); -INSTANTIATE_TEST_CASE_P(smoke_CtcGreedyDecoderBasic, CTCGreedyDecoderLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_CtcGreedyDecoderBasic, CTCGreedyDecoderLayerTest, basicCases, CTCGreedyDecoderLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/ctc_greedy_decoder_seq_len.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/ctc_greedy_decoder_seq_len.cpp index 2247dfd7821fd7..f25df60e99af0e 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/ctc_greedy_decoder_seq_len.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/ctc_greedy_decoder_seq_len.cpp @@ -33,11 +33,11 @@ const auto basicCases = ::testing::Combine( ::testing::ValuesIn(mergeRepeated), ::testing::Values(CommonTestUtils::DEVICE_CPU)); -INSTANTIATE_TEST_CASE_P(smoke_set1, CTCGreedyDecoderSeqLenLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_set1, CTCGreedyDecoderSeqLenLayerTest, basicCases, CTCGreedyDecoderSeqLenLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_set2, CTCGreedyDecoderSeqLenLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_set2, CTCGreedyDecoderSeqLenLayerTest, ::testing::Combine( ::testing::ValuesIn(std::vector>{{2, 8, 11}, {4, 10, 55}}), ::testing::ValuesIn(std::vector{5, 100}), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/ctc_loss.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/ctc_loss.cpp index e0609683606a92..7203f49950c6e8 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/ctc_loss.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/ctc_loss.cpp @@ -35,7 +35,7 @@ const auto ctcLossArgsSubset1 = ::testing::Combine( ::testing::ValuesIn(unique) ); -INSTANTIATE_TEST_CASE_P(smoke_Set1, CTCLossLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Set1, CTCLossLayerTest, ::testing::Combine( ctcLossArgsSubset1, ::testing::ValuesIn(fPrecisions), @@ -56,7 +56,7 @@ const auto ctcLossArgsSubset2 = ::testing::Combine( ::testing::ValuesIn(unique) ); -INSTANTIATE_TEST_CASE_P(smoke_Set2, CTCLossLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Set2, CTCLossLayerTest, ::testing::Combine( ctcLossArgsSubset2, ::testing::ValuesIn(fPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/cum_sum.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/cum_sum.cpp index 9a8325041a6785..eef6c6551216cb 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/cum_sum.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/cum_sum.cpp @@ -105,11 +105,11 @@ const auto testCasesAxis_6 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsCumSum_negative_axis, CumSumLayerTest, testCasesNegativeAxis, CumSumLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsCumSum_axis_0, CumSumLayerTest, testCasesAxis_0, CumSumLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsCumSum_axis_1, CumSumLayerTest, testCasesAxis_1, CumSumLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsCumSum_axis_2, CumSumLayerTest, testCasesAxis_2, CumSumLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsCumSum_axis_3, CumSumLayerTest, testCasesAxis_3, CumSumLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsCumSum_axis_4, CumSumLayerTest, testCasesAxis_4, CumSumLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsCumSum_axis_5, CumSumLayerTest, testCasesAxis_5, CumSumLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsCumSum_axis_6, CumSumLayerTest, testCasesAxis_6, CumSumLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsCumSum_negative_axis, CumSumLayerTest, testCasesNegativeAxis, CumSumLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsCumSum_axis_0, CumSumLayerTest, testCasesAxis_0, CumSumLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsCumSum_axis_1, CumSumLayerTest, testCasesAxis_1, CumSumLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsCumSum_axis_2, CumSumLayerTest, testCasesAxis_2, CumSumLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsCumSum_axis_3, CumSumLayerTest, testCasesAxis_3, CumSumLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsCumSum_axis_4, CumSumLayerTest, testCasesAxis_4, CumSumLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsCumSum_axis_5, CumSumLayerTest, testCasesAxis_5, CumSumLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsCumSum_axis_6, CumSumLayerTest, testCasesAxis_6, CumSumLayerTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/deformable_convolution.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/deformable_convolution.cpp index e54812fe516a5c..7bf74fb3a82cd3 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/deformable_convolution.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/deformable_convolution.cpp @@ -54,7 +54,7 @@ const auto deformableConv2DParams_DeformableGroups_AutoPadExplicit = ::testing:: ::testing::ValuesIn(multiple_defor_groups), ::testing::ValuesIn(numOutChannels), ::testing::Values(ngraph::op::PadType::EXPLICIT)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_DeformableConvolution2D_ExplicitPadding, DeformableConvolutionLayerTest, ::testing::Combine( deformableConv2DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -66,7 +66,7 @@ INSTANTIATE_TEST_CASE_P( ::testing::Values(CommonTestUtils::DEVICE_CPU)), DeformableConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_DeformableConvolution2D_AutoPadValid, DeformableConvolutionLayerTest, ::testing::Combine( deformableConv2DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), @@ -78,7 +78,7 @@ INSTANTIATE_TEST_CASE_P( ::testing::Values(CommonTestUtils::DEVICE_CPU)), DeformableConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_DeformableConvolution2D_DeformableGroups_ExplicitPadding, DeformableConvolutionLayerTest, ::testing::Combine( deformableConv2DParams_DeformableGroups_AutoPadExplicit, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/deformable_psroi_pooling.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/deformable_psroi_pooling.cpp index 4a0a16c3822004..8cf39c201df8ab 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/deformable_psroi_pooling.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/deformable_psroi_pooling.cpp @@ -27,7 +27,7 @@ namespace { ::testing::Values(InferenceEngine::Precision::FP32), // Net precision ::testing::Values(CommonTestUtils::DEVICE_CPU)); // Device name - INSTANTIATE_TEST_CASE_P(smoke_TestsDeformablePSROIPooling, DeformablePSROIPoolingLayerTest, deformablePSROICases_test_params, + INSTANTIATE_TEST_SUITE_P(smoke_TestsDeformablePSROIPooling, DeformablePSROIPoolingLayerTest, deformablePSROICases_test_params, DeformablePSROIPoolingLayerTest::getTestCaseName); @@ -47,6 +47,6 @@ namespace { ::testing::Values(InferenceEngine::Precision::FP32), // Net precision ::testing::Values(CommonTestUtils::DEVICE_CPU)); // Device name - INSTANTIATE_TEST_CASE_P(smoke_TestsDeformablePSROIPooling_advanced, DeformablePSROIPoolingLayerTest, deformablePSROICases_test_params_advanced, + INSTANTIATE_TEST_SUITE_P(smoke_TestsDeformablePSROIPooling_advanced, DeformablePSROIPoolingLayerTest, deformablePSROICases_test_params_advanced, DeformablePSROIPoolingLayerTest::getTestCaseName); } // namespace \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/depth_to_space.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/depth_to_space.cpp index d8785579ed6409..33955e2e4a160d 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/depth_to_space.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/depth_to_space.cpp @@ -36,7 +36,7 @@ const auto DepthToSpaceBS2 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_DepthToSpaceBS2, DepthToSpaceLayerTest, DepthToSpaceBS2, DepthToSpaceLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_DepthToSpaceBS2, DepthToSpaceLayerTest, DepthToSpaceBS2, DepthToSpaceLayerTest::getTestCaseName); const std::vector> inputShapesBS3 = { {1, 9, 1, 1}, {1, 9, 2, 2}, {1, 9, 3, 3}, {2, 36, 3, 3}, {2, 27, 5, 4}, @@ -51,6 +51,6 @@ const auto DepthToSpaceBS3 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_DepthToSpaceBS3, DepthToSpaceLayerTest, DepthToSpaceBS3, DepthToSpaceLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_DepthToSpaceBS3, DepthToSpaceLayerTest, DepthToSpaceBS3, DepthToSpaceLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/detection_output.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/detection_output.cpp index e30c577241fbba..c40ab0ca365209 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/detection_output.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/detection_output.cpp @@ -56,7 +56,7 @@ const auto params3Inputs = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_DetectionOutput3In, DetectionOutputLayerTest, params3Inputs, DetectionOutputLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_DetectionOutput3In, DetectionOutputLayerTest, params3Inputs, DetectionOutputLayerTest::getTestCaseName); /* =============== 5 inputs cases =============== */ @@ -80,6 +80,6 @@ const auto params5Inputs = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_DetectionOutput5In, DetectionOutputLayerTest, params5Inputs, DetectionOutputLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_DetectionOutput5In, DetectionOutputLayerTest, params5Inputs, DetectionOutputLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/dft.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/dft.cpp index 27e5f5051dcae6..c917b1bd887a2c 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/dft.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/dft.cpp @@ -101,7 +101,7 @@ const auto testCase4D = ::testing::Combine( ); -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsDFT_1d, DFTLayerTest, testCase1D, DFTLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsDFT_2d, DFTLayerTest, testCase2D, DFTLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsDFT_3d, DFTLayerTest, testCase3D, DFTLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsDFT_4d, DFTLayerTest, testCase4D, DFTLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsDFT_1d, DFTLayerTest, testCase1D, DFTLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsDFT_2d, DFTLayerTest, testCase2D, DFTLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsDFT_3d, DFTLayerTest, testCase3D, DFTLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsDFT_4d, DFTLayerTest, testCase4D, DFTLayerTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/eltwise.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/eltwise.cpp index ea9c438abe2722..b0933abc379763 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/eltwise.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/eltwise.cpp @@ -66,7 +66,7 @@ const auto multiply_params = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::Values(additional_config)); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs, EltwiseLayerTest, multiply_params, EltwiseLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs, EltwiseLayerTest, multiply_params, EltwiseLayerTest::getTestCaseName); std::vector>> inShapesSingleThread = { @@ -96,7 +96,7 @@ const auto single_thread_params = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::Values(additional_config_single_thread)); -INSTANTIATE_TEST_CASE_P(smoke_SingleThread, EltwiseLayerTest, single_thread_params, EltwiseLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_SingleThread, EltwiseLayerTest, single_thread_params, EltwiseLayerTest::getTestCaseName); } // namespace \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/embedding_bag_offsets_sum.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/embedding_bag_offsets_sum.cpp index 7bd296bca76df5..79081a70dfc692 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/embedding_bag_offsets_sum.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/embedding_bag_offsets_sum.cpp @@ -39,7 +39,7 @@ const auto embBagOffsetSumArgSet = ::testing::Combine( ::testing::ValuesIn(with_default_index) ); -INSTANTIATE_TEST_CASE_P(smoke, EmbeddingBagOffsetsSumLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke, EmbeddingBagOffsetsSumLayerTest, ::testing::Combine( embBagOffsetSumArgSet, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/embedding_bag_packed_sum.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/embedding_bag_packed_sum.cpp index 805a766f49110d..47f5686637835d 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/embedding_bag_packed_sum.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/embedding_bag_packed_sum.cpp @@ -33,7 +33,7 @@ const auto embBagPackedSumArgSet = ::testing::Combine( ::testing::ValuesIn(with_weights) ); -INSTANTIATE_TEST_CASE_P(smoke, EmbeddingBagPackedSumLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke, EmbeddingBagPackedSumLayerTest, ::testing::Combine( embBagPackedSumArgSet, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/embedding_segments_sum.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/embedding_segments_sum.cpp index 70d982c5f33ef4..ad80292245c0fa 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/embedding_segments_sum.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/embedding_segments_sum.cpp @@ -41,7 +41,7 @@ const auto embSegmentsSumArgSet = ::testing::Combine( ::testing::ValuesIn(with_default_index) ); -INSTANTIATE_TEST_CASE_P(smoke, EmbeddingSegmentsSumLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke, EmbeddingSegmentsSumLayerTest, ::testing::Combine( embSegmentsSumArgSet, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/extract_image_patches.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/extract_image_patches.cpp index 14ca4d3e6194cc..32278fb9ade5e5 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/extract_image_patches.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/extract_image_patches.cpp @@ -25,7 +25,7 @@ const std::vector netPrecisions = { InferenceEngine::Precision::I64 }; -INSTANTIATE_TEST_CASE_P(smoke_layers_CPU, ExtractImagePatchesTest, +INSTANTIATE_TEST_SUITE_P(smoke_layers_CPU, ExtractImagePatchesTest, ::testing::Combine( ::testing::ValuesIn(inDataShape), ::testing::ValuesIn(kernels), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/fake_quantize.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/fake_quantize.cpp index 3dbb6f5fd539b5..bc0440b0d87f4a 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/fake_quantize.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/fake_quantize.cpp @@ -33,7 +33,7 @@ const auto fqParams = ::testing::Combine( ::testing::Values(inputParams) ); -INSTANTIATE_TEST_CASE_P(smoke_FakeQuantize, FakeQuantizeLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantize, FakeQuantizeLayerTest, ::testing::Combine( fqParams, ::testing::ValuesIn(netPrecisions), @@ -64,7 +64,7 @@ const auto fqParamsPerChannelAxis1 = ::testing::Combine( ::testing::Values(inputParams) ); -INSTANTIATE_TEST_CASE_P(smoke_FakeQuantizePerChannelAxis0, FakeQuantizeLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizePerChannelAxis0, FakeQuantizeLayerTest, ::testing::Combine( fqParamsPerChannelAxis0, ::testing::ValuesIn(netPrecisions), @@ -77,7 +77,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FakeQuantizePerChannelAxis0, FakeQuantizeLayerTest ::testing::Values(config)), FakeQuantizeLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_FakeQuantizePerChannelAxis1, FakeQuantizeLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizePerChannelAxis1, FakeQuantizeLayerTest, ::testing::Combine( fqParamsPerChannelAxis1, ::testing::ValuesIn(netPrecisions), @@ -99,7 +99,7 @@ const auto fqParamsPerChannel2D = ::testing::Combine( ::testing::Values(inputParams) ); -INSTANTIATE_TEST_CASE_P(smoke_FakeQuantizePerChannel2D, FakeQuantizeLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizePerChannel2D, FakeQuantizeLayerTest, ::testing::Combine( fqParamsPerChannel2D, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gather.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gather.cpp index 32038696be6f68..d187d5d86cc918 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gather.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gather.cpp @@ -44,7 +44,7 @@ const auto gather7Params_1D = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_Gather7_1D, Gather7LayerTest, gather7Params_1D, Gather7LayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Gather7_1D, Gather7LayerTest, gather7Params_1D, Gather7LayerTest::getTestCaseName); const std::vector> inputShapes_2D = { std::vector{4, 19}, @@ -74,7 +74,7 @@ const auto gather7Params_2D = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_Gather7_2D, Gather7LayerTest, gather7Params_2D, Gather7LayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Gather7_2D, Gather7LayerTest, gather7Params_2D, Gather7LayerTest::getTestCaseName); const std::vector> inputShapes4D = { std::vector{4, 5, 6, 7}, @@ -105,7 +105,7 @@ const auto gather7ParamsSubset_BD0 = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_Gather7_BD0, Gather7LayerTest, gather7ParamsSubset_BD0, Gather7LayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Gather7_BD0, Gather7LayerTest, gather7ParamsSubset_BD0, Gather7LayerTest::getTestCaseName); const std::vector> indicesShapes_BD1 = { std::vector{4, 2}, @@ -132,7 +132,7 @@ const auto gather7ParamsSubset_BD1 = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_Gather7_BD1, Gather7LayerTest, gather7ParamsSubset_BD1, Gather7LayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Gather7_BD1, Gather7LayerTest, gather7ParamsSubset_BD1, Gather7LayerTest::getTestCaseName); const std::vector> indicesShapes_BD2 = { std::vector{4, 5, 4, 3}, @@ -158,7 +158,7 @@ const auto gather7ParamsSubset_BD2 = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_Gather7_BD2, Gather7LayerTest, gather7ParamsSubset_BD2, Gather7LayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Gather7_BD2, Gather7LayerTest, gather7ParamsSubset_BD2, Gather7LayerTest::getTestCaseName); const std::vector> indicesShapes_NegativeBD = { std::vector{4, 5, 4}, @@ -186,6 +186,6 @@ const auto gather7ParamsSubset_NegativeBD = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_Gather7_NegativeBD, Gather7LayerTest, gather7ParamsSubset_NegativeBD, Gather7LayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Gather7_NegativeBD, Gather7LayerTest, gather7ParamsSubset_NegativeBD, Gather7LayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gather_elements.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gather_elements.cpp index b07dfe252e1370..1ad8bbd0d4c335 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gather_elements.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gather_elements.cpp @@ -24,7 +24,7 @@ const std::vector iPrecisions = { InferenceEngine::Precision::I64 }; -INSTANTIATE_TEST_CASE_P(smoke_set1, GatherElementsLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_set1, GatherElementsLayerTest, ::testing::Combine( ::testing::Values(std::vector({2, 2})), // Data shape ::testing::Values(std::vector({2, 2})), // Indices shape @@ -34,7 +34,7 @@ INSTANTIATE_TEST_CASE_P(smoke_set1, GatherElementsLayerTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), GatherElementsLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_set2, GatherElementsLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_set2, GatherElementsLayerTest, ::testing::Combine( ::testing::Values(std::vector({2, 2, 1})), // Data shape ::testing::Values(std::vector({4, 2, 1})), // Indices shape @@ -44,7 +44,7 @@ INSTANTIATE_TEST_CASE_P(smoke_set2, GatherElementsLayerTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), GatherElementsLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_set3, GatherElementsLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_set3, GatherElementsLayerTest, ::testing::Combine( ::testing::Values(std::vector({2, 2, 3, 5})), // Data shape ::testing::Values(std::vector({2, 2, 3, 7})), // Indices shape @@ -54,7 +54,7 @@ INSTANTIATE_TEST_CASE_P(smoke_set3, GatherElementsLayerTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), GatherElementsLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_set4, GatherElementsLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_set4, GatherElementsLayerTest, ::testing::Combine( ::testing::Values(std::vector({3, 2, 3, 8})), // Data shape ::testing::Values(std::vector({2, 2, 3, 8})), // Indices shape @@ -64,7 +64,7 @@ INSTANTIATE_TEST_CASE_P(smoke_set4, GatherElementsLayerTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), GatherElementsLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_set5, GatherElementsLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_set5, GatherElementsLayerTest, ::testing::Combine( ::testing::Values(std::vector({3, 2, 3, 4, 8})), // Data shape ::testing::Values(std::vector({3, 2, 3, 5, 8})), // Indices shape diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gather_nd.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gather_nd.cpp index a467f96ec22fb8..1639dabcb557d6 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gather_nd.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gather_nd.cpp @@ -31,7 +31,7 @@ const auto gatherNDArgsSubset1 = ::testing::Combine( {{2, 1}, {2, 1, 1}})), // Indices shape ::testing::ValuesIn(std::vector({0, 1})) // Batch dims ); -INSTANTIATE_TEST_CASE_P(smoke_Set1, GatherNDLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Set1, GatherNDLayerTest, ::testing::Combine( gatherNDArgsSubset1, ::testing::ValuesIn(dPrecisions), @@ -47,7 +47,7 @@ const auto gatherNDArgsSubset2 = ::testing::Combine( {{15, 12, 2}, {15, 12, 5, 9, 1, 3}})), // Indices shape ::testing::ValuesIn(std::vector({0, 1, 2})) // Batch dims ); -INSTANTIATE_TEST_CASE_P(smoke_Set2, GatherNDLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Set2, GatherNDLayerTest, ::testing::Combine( gatherNDArgsSubset2, ::testing::ValuesIn(dPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gather_tree.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gather_tree.cpp index cb19f2e2b3bbdc..0076fd7b8fe588 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gather_tree.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gather_tree.cpp @@ -23,7 +23,7 @@ const std::vector secondaryInputTypes = { ngraph::helpers::InputLayerType::PARAMETER }; -INSTANTIATE_TEST_CASE_P(Basic_smoke, GatherTreeLayerTest, +INSTANTIATE_TEST_SUITE_P(Basic_smoke, GatherTreeLayerTest, ::testing::Combine( ::testing::ValuesIn(inputShapes), ::testing::ValuesIn(secondaryInputTypes), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/group_convolution.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/group_convolution.cpp index 417ad9d0130096..10da188bcb7e3e 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/group_convolution.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/group_convolution.cpp @@ -39,7 +39,7 @@ const auto groupConv1DParams_AutoPadValid = ::testing::Combine( ::testing::ValuesIn(numGroups1d), ::testing::Values(ngraph::op::PadType::VALID)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_GroupConvolution1D_ExplicitPadding, GroupConvolutionLayerTest, ::testing::Combine( groupConv1DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -51,7 +51,7 @@ INSTANTIATE_TEST_CASE_P( ::testing::Values(CommonTestUtils::DEVICE_CPU)), GroupConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_GroupConvolution1D_AutoPadValid, GroupConvolutionLayerTest, ::testing::Combine( groupConv1DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), @@ -87,7 +87,7 @@ const auto groupConv2DParams_AutoPadValid = ::testing::Combine( ::testing::ValuesIn(numGroups), ::testing::Values(ngraph::op::PadType::VALID)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_GroupConvolution2D_ExplicitPadding, GroupConvolutionLayerTest, ::testing::Combine( groupConv2DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -99,7 +99,7 @@ INSTANTIATE_TEST_CASE_P( ::testing::Values(CommonTestUtils::DEVICE_CPU)), GroupConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_GroupConvolution2D_AutoPadValid, GroupConvolutionLayerTest, ::testing::Combine( groupConv2DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), @@ -130,7 +130,7 @@ const auto groupConv3DParams_AutoPadValid = ::testing::Combine( ::testing::ValuesIn(dilations3d), ::testing::Values(4), ::testing::Values(2), ::testing::Values(ngraph::op::PadType::VALID)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_GroupConvolution3D_ExplicitPadding, GroupConvolutionLayerTest, ::testing::Combine( groupConv3DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -142,7 +142,7 @@ INSTANTIATE_TEST_CASE_P( ::testing::Values(CommonTestUtils::DEVICE_CPU)), GroupConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_GroupConvolution3D_AutoPadValid, GroupConvolutionLayerTest, ::testing::Combine( groupConv3DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/group_convolution_backprop_data.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/group_convolution_backprop_data.cpp index 70a1151d9bae1d..2f08be54039156 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/group_convolution_backprop_data.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/group_convolution_backprop_data.cpp @@ -50,7 +50,7 @@ const auto groupConvBackpropData1DParams_AutoPadValid = ::testing::Combine( ::testing::Values(ngraph::op::PadType::VALID) ); -INSTANTIATE_TEST_CASE_P(smoke_GroupConvBackpropData1D_ExplicitPadding, GroupConvBackpropDataLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConvBackpropData1D_ExplicitPadding, GroupConvBackpropDataLayerTest, ::testing::Combine( groupConvBackpropData1DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -62,7 +62,7 @@ INSTANTIATE_TEST_CASE_P(smoke_GroupConvBackpropData1D_ExplicitPadding, GroupConv ::testing::Values(CommonTestUtils::DEVICE_CPU)), GroupConvBackpropDataLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_GroupConvBackpropData1D_AutoPadValid, GroupConvBackpropDataLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConvBackpropData1D_AutoPadValid, GroupConvBackpropDataLayerTest, ::testing::Combine( groupConvBackpropData1DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), @@ -104,7 +104,7 @@ const auto groupConvBackpropData2DParams_AutoPadValid = ::testing::Combine( ::testing::Values(ngraph::op::PadType::VALID) ); -INSTANTIATE_TEST_CASE_P(smoke_GroupConvBackpropData2D_ExplicitPadding, GroupConvBackpropDataLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConvBackpropData2D_ExplicitPadding, GroupConvBackpropDataLayerTest, ::testing::Combine( groupConvBackpropData2DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -116,7 +116,7 @@ INSTANTIATE_TEST_CASE_P(smoke_GroupConvBackpropData2D_ExplicitPadding, GroupConv ::testing::Values(CommonTestUtils::DEVICE_CPU)), GroupConvBackpropDataLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_GroupConvBackpropData2D_AutoPadValid, GroupConvBackpropDataLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConvBackpropData2D_AutoPadValid, GroupConvBackpropDataLayerTest, ::testing::Combine( groupConvBackpropData2DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), @@ -158,7 +158,7 @@ const auto groupConvBackpropData3DParams_AutoPadValid = ::testing::Combine( ::testing::Values(ngraph::op::PadType::VALID) ); -INSTANTIATE_TEST_CASE_P(smoke_GroupConvBackpropData3D_ExplicitPadding, GroupConvBackpropDataLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConvBackpropData3D_ExplicitPadding, GroupConvBackpropDataLayerTest, ::testing::Combine( groupConvBackpropData3DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -170,7 +170,7 @@ INSTANTIATE_TEST_CASE_P(smoke_GroupConvBackpropData3D_ExplicitPadding, GroupConv ::testing::Values(CommonTestUtils::DEVICE_CPU)), GroupConvBackpropDataLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_GroupConvBackpropData3D_AutoPadValid, GroupConvBackpropDataLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConvBackpropData3D_AutoPadValid, GroupConvBackpropDataLayerTest, ::testing::Combine( groupConvBackpropData3DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gru_cell.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gru_cell.cpp index 51e7dad83ca208..350d6dc74f5198 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gru_cell.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gru_cell.cpp @@ -21,7 +21,7 @@ namespace { std::vector netPrecisions = {InferenceEngine::Precision::FP32, InferenceEngine::Precision::FP16}; - INSTANTIATE_TEST_CASE_P(smoke_GRUCellCommon, GRUCellTest, + INSTANTIATE_TEST_SUITE_P(smoke_GRUCellCommon, GRUCellTest, ::testing::Combine( ::testing::ValuesIn(should_decompose), ::testing::ValuesIn(batch), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gru_sequence.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gru_sequence.cpp index 5521023a192fd2..884a6e3bd2897d 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gru_sequence.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/gru_sequence.cpp @@ -34,7 +34,7 @@ namespace { std::vector netPrecisions = {InferenceEngine::Precision::FP32, InferenceEngine::Precision::FP16}; - INSTANTIATE_TEST_CASE_P(smoke_GRUSequenceCommonZeroClip, GRUSequenceTest, + INSTANTIATE_TEST_SUITE_P(smoke_GRUSequenceCommonZeroClip, GRUSequenceTest, ::testing::Combine( ::testing::ValuesIn(mode), ::testing::ValuesIn(seq_lengths_zero_clip), @@ -49,7 +49,7 @@ namespace { ::testing::Values(CommonTestUtils::DEVICE_CPU)), GRUSequenceTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_GRUSequenceCommonClip, GRUSequenceTest, + INSTANTIATE_TEST_SUITE_P(smoke_GRUSequenceCommonClip, GRUSequenceTest, ::testing::Combine( ::testing::ValuesIn(mode), ::testing::ValuesIn(seq_lengths_clip_non_zero), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/interpolate.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/interpolate.cpp index 08c529379767a7..5d617ce9c90ea0 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/interpolate.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/interpolate.cpp @@ -108,7 +108,7 @@ const auto interpolateCases = ::testing::Combine( ::testing::ValuesIn(defaultAxes), ::testing::ValuesIn(defaultScales)); -INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Basic, InterpolateLayerTest, ::testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_Interpolate_Basic, InterpolateLayerTest, ::testing::Combine( interpolateCasesWithoutNearest, ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), @@ -121,7 +121,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Basic, InterpolateLayerTest, ::testing ::testing::Values(additional_config)), InterpolateLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Nearest, InterpolateLayerTest, ::testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_Interpolate_Nearest, InterpolateLayerTest, ::testing::Combine( interpolateCases, ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), @@ -166,7 +166,7 @@ const auto interpolateCasesTail = ::testing::Combine( ::testing::ValuesIn(defaultAxes), ::testing::ValuesIn(defaultScalesTailTest)); -INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Basic_Down_Sample_Tail, InterpolateLayerTest, ::testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_Interpolate_Basic_Down_Sample_Tail, InterpolateLayerTest, ::testing::Combine( interpolateCasesWithoutNearestTail, ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), @@ -179,7 +179,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Basic_Down_Sample_Tail, InterpolateLay ::testing::Values(additional_config)), InterpolateLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Nearest_Down_Sample_Tail, InterpolateLayerTest, ::testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_Interpolate_Nearest_Down_Sample_Tail, InterpolateLayerTest, ::testing::Combine( interpolateCasesTail, ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/log_softmax.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/log_softmax.cpp index 37042c8ad7d9cb..2b9a71ddfeffe0 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/log_softmax.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/log_softmax.cpp @@ -37,7 +37,7 @@ const auto params2D = testing::Combine( testing::Values(std::map()) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LogSoftmax2D, LogSoftmaxLayerTest, params2D, @@ -66,7 +66,7 @@ const auto params4D = testing::Combine( testing::Values(std::map()) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LogSoftmax4D, LogSoftmaxLayerTest, params4D, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/logical.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/logical.cpp index 0e252f6753873c..b90ed72b717c50 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/logical.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/logical.cpp @@ -74,8 +74,8 @@ const auto LogicalTestParamsNot = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::Values(additional_config)); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs, LogicalLayerTest, LogicalTestParams, LogicalLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs, LogicalLayerTest, LogicalTestParams, LogicalLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefsNot, LogicalLayerTest, LogicalTestParamsNot, LogicalLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefsNot, LogicalLayerTest, LogicalTestParamsNot, LogicalLayerTest::getTestCaseName); } // namespace \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/loop.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/loop.cpp index 1a14f9a97e4cbe..505d5f7f29d617 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/loop.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/loop.cpp @@ -20,7 +20,7 @@ namespace { std::vector netPrecisions = {InferenceEngine::Precision::FP32, InferenceEngine::Precision::FP16}; - INSTANTIATE_TEST_CASE_P(smoke_LoopCommonZeroClip, LoopTest, + INSTANTIATE_TEST_SUITE_P(smoke_LoopCommonZeroClip, LoopTest, ::testing::Combine( ::testing::ValuesIn(execute_first_iteration), ::testing::ValuesIn(is_body_condition_const), @@ -48,7 +48,7 @@ namespace { using namespace testing; using namespace InferenceEngine; - INSTANTIATE_TEST_CASE_P(smoke_StaticShapeLoop, StaticShapeLoopTest, + INSTANTIATE_TEST_SUITE_P(smoke_StaticShapeLoop, StaticShapeLoopTest, Combine( ValuesIn(std::vector{true, false}), Values(true), @@ -58,7 +58,7 @@ namespace { Values(Precision::FP32, Precision::I32), Values(CommonTestUtils::DEVICE_CPU))); using namespace testing; - INSTANTIATE_TEST_CASE_P(smoke_TrivialLoop, TrivialLoopTest, + INSTANTIATE_TEST_SUITE_P(smoke_TrivialLoop, TrivialLoopTest, Combine( Values(Precision::FP32, Precision::I32), Values({2, 3, 4}), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/lrn.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/lrn.cpp index 916abf39f4cd8d..4863b9934486ad 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/lrn.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/lrn.cpp @@ -22,7 +22,7 @@ namespace LRN2D { const std::vector> axes = {{1}}; -INSTANTIATE_TEST_CASE_P(smoke_LrnCheck_2D, LrnLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_LrnCheck_2D, LrnLayerTest, ::testing::Combine(::testing::Values(alpha), ::testing::Values(beta), ::testing::Values(bias), @@ -41,7 +41,7 @@ namespace LRN3D { const std::vector> axes = {{1}, {2}}; -INSTANTIATE_TEST_CASE_P(smoke_LrnCheck_3D, LrnLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_LrnCheck_3D, LrnLayerTest, ::testing::Combine(::testing::Values(alpha), ::testing::Values(beta), ::testing::Values(bias), @@ -60,7 +60,7 @@ namespace LRN4D { const std::vector> axes = {{1}, {2, 3}, {3, 2}}; -INSTANTIATE_TEST_CASE_P(smoke_LrnCheck_4D, LrnLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_LrnCheck_4D, LrnLayerTest, ::testing::Combine(::testing::Values(alpha), ::testing::Values(beta), ::testing::Values(bias), @@ -79,7 +79,7 @@ namespace LRN5D { const std::vector> axes = {{1}, {2, 3, 4}, {4, 2, 3}}; -INSTANTIATE_TEST_CASE_P(smoke_LrnCheck_5D, LrnLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_LrnCheck_5D, LrnLayerTest, ::testing::Combine(::testing::Values(alpha), ::testing::Values(beta), ::testing::Values(bias), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/lstm_cell.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/lstm_cell.cpp index cc1f0a4fa783bf..5affa8d67d3331 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/lstm_cell.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/lstm_cell.cpp @@ -21,7 +21,7 @@ namespace { std::vector netPrecisions = {InferenceEngine::Precision::FP32, InferenceEngine::Precision::FP16}; - INSTANTIATE_TEST_CASE_P(smoke_LSTMCellCommon, LSTMCellTest, + INSTANTIATE_TEST_SUITE_P(smoke_LSTMCellCommon, LSTMCellTest, ::testing::Combine( ::testing::ValuesIn(should_decompose), ::testing::ValuesIn(batch), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/lstm_sequence.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/lstm_sequence.cpp index 3ccbddc8f31c35..aea380561198ef 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/lstm_sequence.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/lstm_sequence.cpp @@ -34,7 +34,7 @@ namespace { std::vector netPrecisions = {InferenceEngine::Precision::FP32, InferenceEngine::Precision::FP16}; - INSTANTIATE_TEST_CASE_P(smoke_LSTMSequenceCommonZeroClip, LSTMSequenceTest, + INSTANTIATE_TEST_SUITE_P(smoke_LSTMSequenceCommonZeroClip, LSTMSequenceTest, ::testing::Combine( ::testing::ValuesIn(mode), ::testing::ValuesIn(seq_lengths_zero_clip), @@ -48,7 +48,7 @@ namespace { ::testing::Values(CommonTestUtils::DEVICE_CPU)), LSTMSequenceTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_LSTMSequenceCommonClip, LSTMSequenceTest, + INSTANTIATE_TEST_SUITE_P(smoke_LSTMSequenceCommonClip, LSTMSequenceTest, ::testing::Combine( ::testing::ValuesIn(mode), ::testing::ValuesIn(seq_lengths_clip_non_zero), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/mat_mul.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/mat_mul.cpp index 4a0d5dcdcbd556..680276b2f721e1 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/mat_mul.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/mat_mul.cpp @@ -44,7 +44,7 @@ std::vector secondaryInputTypes = { std::map additional_config = {}; -INSTANTIATE_TEST_CASE_P(smoke_MatMul, MatMulTest, +INSTANTIATE_TEST_SUITE_P(smoke_MatMul, MatMulTest, ::testing::Combine( ::testing::ValuesIn(shapeRelatedParams), ::testing::ValuesIn(inputPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/memory.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/memory.cpp index 062ea0cad9194e..c0a0fa3b430e89 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/memory.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/memory.cpp @@ -32,7 +32,7 @@ const std::vector iterationCount { 10 }; -INSTANTIATE_TEST_CASE_P(smoke_MemoryTest, MemoryTest, +INSTANTIATE_TEST_SUITE_P(smoke_MemoryTest, MemoryTest, ::testing::Combine( ::testing::ValuesIn(transformation), ::testing::ValuesIn(iterationCount), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/minimum_maximum.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/minimum_maximum.cpp index 64c3878736eb72..e2f5f72497e15d 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/minimum_maximum.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/minimum_maximum.cpp @@ -35,7 +35,7 @@ const std::vector inputType = { ngraph::helpers::InputLayerType::PARAMETER, }; -INSTANTIATE_TEST_CASE_P(smoke_maximum, MaxMinLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_maximum, MaxMinLayerTest, ::testing::Combine( ::testing::ValuesIn(inShapes), ::testing::ValuesIn(opType), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/mvn.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/mvn.cpp index c633c1b6bc82dd..73fdce483efd20 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/mvn.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/mvn.cpp @@ -50,7 +50,7 @@ const auto MvnCases = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsMVN, MvnLayerTest, MvnCases, MvnLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsMVN, MvnLayerTest, MvnCases, MvnLayerTest::getTestCaseName); @@ -73,7 +73,7 @@ const std::vector epsilonF = { 0.0001 }; -INSTANTIATE_TEST_CASE_P(smoke_MVN_5D, Mvn6LayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MVN_5D, Mvn6LayerTest, ::testing::Combine( ::testing::ValuesIn(std::vector>{{1, 10, 5, 7, 8}, {1, 3, 8, 9, 49}}), ::testing::ValuesIn(dataPrecisions), @@ -85,7 +85,7 @@ INSTANTIATE_TEST_CASE_P(smoke_MVN_5D, Mvn6LayerTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), Mvn6LayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MVN_4D, Mvn6LayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MVN_4D, Mvn6LayerTest, ::testing::Combine( ::testing::ValuesIn(std::vector>{{1, 10, 5, 17}, {1, 3, 8, 9}}), ::testing::ValuesIn(dataPrecisions), @@ -97,7 +97,7 @@ INSTANTIATE_TEST_CASE_P(smoke_MVN_4D, Mvn6LayerTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), Mvn6LayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MVN_3D, Mvn6LayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MVN_3D, Mvn6LayerTest, ::testing::Combine( ::testing::ValuesIn(std::vector>{{1, 32, 17}, {1, 37, 9}}), ::testing::ValuesIn(dataPrecisions), @@ -109,7 +109,7 @@ INSTANTIATE_TEST_CASE_P(smoke_MVN_3D, Mvn6LayerTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), Mvn6LayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MVN_2D, Mvn6LayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MVN_2D, Mvn6LayerTest, ::testing::Combine( ::testing::ValuesIn(std::vector>{{3, 5}, {2, 55}}), ::testing::ValuesIn(dataPrecisions), @@ -121,7 +121,7 @@ INSTANTIATE_TEST_CASE_P(smoke_MVN_2D, Mvn6LayerTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), Mvn6LayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MVN_1D, Mvn6LayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MVN_1D, Mvn6LayerTest, ::testing::Combine( ::testing::ValuesIn(std::vector>{{3}, {9}, {55}}), ::testing::ValuesIn(dataPrecisions), @@ -133,7 +133,7 @@ INSTANTIATE_TEST_CASE_P(smoke_MVN_1D, Mvn6LayerTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), Mvn6LayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Decomposition_3D, Mvn6LayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Decomposition_3D, Mvn6LayerTest, ::testing::Combine( ::testing::ValuesIn(std::vector>{{1, 32, 17}, {1, 37, 9}}), ::testing::ValuesIn(dataPrecisions), @@ -145,7 +145,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Decomposition_3D, Mvn6LayerTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), Mvn6LayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Decomposition_4D, Mvn6LayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Decomposition_4D, Mvn6LayerTest, ::testing::Combine( ::testing::ValuesIn(std::vector>{{1, 16, 5, 8}, {2, 19, 5, 10}}), ::testing::ValuesIn(dataPrecisions), @@ -157,7 +157,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Decomposition_4D, Mvn6LayerTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), Mvn6LayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Decomposition_10D, Mvn6LayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Decomposition_10D, Mvn6LayerTest, ::testing::Combine( ::testing::ValuesIn(std::vector>{{1, 3, 5, 4, 2, 6, 5, 3, 2, 1}}), ::testing::ValuesIn(dataPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/non_max_suppression.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/non_max_suppression.cpp index a8d10d65bdf329..4bc28cf1b5b747 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/non_max_suppression.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/non_max_suppression.cpp @@ -39,4 +39,4 @@ const auto nmsParams = ::testing::Combine(::testing::ValuesIn(inShapeParams), ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_NmsLayerTest, NmsLayerTest, nmsParams, NmsLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_NmsLayerTest, NmsLayerTest, nmsParams, NmsLayerTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/normalize_l2.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/normalize_l2.cpp index 75b2c0a5b492cd..843609102e44ce 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/normalize_l2.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/normalize_l2.cpp @@ -34,7 +34,7 @@ const auto normL2params = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( NormalizeL2, NormalizeL2LayerTest, normL2params, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/one_hot.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/one_hot.cpp index 9ab687d76f2834..7a14b67f0ea183 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/one_hot.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/one_hot.cpp @@ -32,7 +32,7 @@ const auto oneHotParams_IC = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_OneHotIntConst, OneHotLayerTest, oneHotParams_IC, @@ -60,7 +60,7 @@ const auto oneHotParams_Ax = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_OneHotAxrng, OneHotLayerTest, oneHotParams_Ax, @@ -89,7 +89,7 @@ const auto oneHotParams_T = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_OneHotArgType, OneHotLayerTest, oneHotParams_T, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/pad.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/pad.cpp index 0a760ed69e59e6..17e9f4e17dfaf8 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/pad.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/pad.cpp @@ -43,7 +43,7 @@ const auto pad1DConstparams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Pad1DConst, PadLayerTest, pad1DConstparams, @@ -63,7 +63,7 @@ const auto pad1Dparams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Pad1D, PadLayerTest, pad1Dparams, @@ -86,7 +86,7 @@ const auto pad2DConstparams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Pad2DConst, PadLayerTest, pad2DConstparams, @@ -106,7 +106,7 @@ const auto pad2Dparams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Pad2D, PadLayerTest, pad2Dparams, @@ -129,7 +129,7 @@ const auto pad4DConstparams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Pad4DConst, PadLayerTest, pad4DConstparams, @@ -149,7 +149,7 @@ const auto pad4Dparams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Pad4D, PadLayerTest, pad4Dparams, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/pooling.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/pooling.cpp index 0e71de6d4c33af..a3053fb6809820 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/pooling.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/pooling.cpp @@ -54,7 +54,7 @@ const auto maxPool_ExplicitPad_FloorRounding_Params = ::testing::Combine( ::testing::Values(false) // placeholder value - exclude pad not applicable for max pooling ); -INSTANTIATE_TEST_CASE_P(smoke_MaxPool_ExplicitPad_FloorRounding, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_ExplicitPad_FloorRounding, PoolingLayerTest, ::testing::Combine( maxPool_ExplicitPad_FloorRounding_Params, ::testing::ValuesIn(netPrecisions), @@ -78,7 +78,7 @@ const auto maxPool_SameUpperPad_FloorRounding_Params = ::testing::Combine( ::testing::Values(false) // placeholder value - exclude pad not applicable for max pooling ); -INSTANTIATE_TEST_CASE_P(smoke_MaxPool_SameUpperPad_FloorRounding, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_SameUpperPad_FloorRounding, PoolingLayerTest, ::testing::Combine( maxPool_SameUpperPad_FloorRounding_Params, ::testing::ValuesIn(netPrecisions), @@ -102,7 +102,7 @@ const auto maxPool_SameLowerPad_FloorRounding_Params = ::testing::Combine( ::testing::Values(false) // placeholder value - exclude pad not applicable for max pooling ); -INSTANTIATE_TEST_CASE_P(smoke_MaxPool_SameLowerPad_FloorRounding, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_SameLowerPad_FloorRounding, PoolingLayerTest, ::testing::Combine( maxPool_SameUpperPad_FloorRounding_Params, ::testing::ValuesIn(netPrecisions), @@ -126,7 +126,7 @@ const auto maxPool_ExplicitPad_FloorRounding_5Dinput_Params = ::testing::Combine ::testing::Values(false) // placeholder value - exclude pad not applicable for max pooling ); -INSTANTIATE_TEST_CASE_P(smoke_MaxPool_ExplicitPad_FloorRounding_5Dinput, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_ExplicitPad_FloorRounding_5Dinput, PoolingLayerTest, ::testing::Combine( maxPool_ExplicitPad_FloorRounding_5Dinput_Params, ::testing::ValuesIn(netPrecisions), @@ -150,7 +150,7 @@ const auto maxPool_SameUpperPad_FloorRounding_5Dinput_Params = ::testing::Combin ::testing::Values(false) // placeholder value - exclude pad not applicable for max pooling ); -INSTANTIATE_TEST_CASE_P(smoke_MaxPool_SameUpperPad_FloorRounding_5Dinput, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_SameUpperPad_FloorRounding_5Dinput, PoolingLayerTest, ::testing::Combine( maxPool_SameUpperPad_FloorRounding_5Dinput_Params, ::testing::ValuesIn(netPrecisions), @@ -174,7 +174,7 @@ const auto maxPool_SameLowerPad_CeilRounding_5Dinput_Params = ::testing::Combine ::testing::Values(false) // placeholder value - exclude pad not applicable for max pooling ); -INSTANTIATE_TEST_CASE_P(smoke_MaxPool_SameLowerPad_CeilRounding_5Dinput, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_SameLowerPad_CeilRounding_5Dinput, PoolingLayerTest, ::testing::Combine( maxPool_SameUpperPad_FloorRounding_5Dinput_Params, ::testing::ValuesIn(netPrecisions), @@ -198,7 +198,7 @@ const auto maxPool_ExplicitPad_CeilRounding_Params = ::testing::Combine( ::testing::Values(false) // placeholder value - exclude pad not applicable for max pooling ); -INSTANTIATE_TEST_CASE_P(smoke_MaxPool_ExplicitPad_CeilRounding, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_ExplicitPad_CeilRounding, PoolingLayerTest, ::testing::Combine( maxPool_ExplicitPad_CeilRounding_Params, ::testing::ValuesIn(netPrecisions), @@ -225,7 +225,7 @@ const auto avgPoolExplicitPadCeilRoundingParams = ::testing::Combine( ::testing::Values(true, false) ); -INSTANTIATE_TEST_CASE_P(smoke_AvgPool_ExplicitPad_CeilRounding, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_ExplicitPad_CeilRounding, PoolingLayerTest, ::testing::Combine( avgPoolExplicitPadCeilRoundingParams, ::testing::ValuesIn(netPrecisions), @@ -242,7 +242,7 @@ std::vector psParams({poolSpecificParams(ngraph::helpers::Po poolSpecificParams(ngraph::helpers::PoolingTypes::AVG, {7, 7}, {1, 1}, {0, 0}, {1, 1}, ngraph::op::RoundingType::CEIL, ngraph::op::PadType::EXPLICIT, false)}); -INSTANTIATE_TEST_CASE_P(smoke_AvgPool_ExplicitPad_CeilRounding_corner, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_ExplicitPad_CeilRounding_corner, PoolingLayerTest, ::testing::Combine( ::testing::ValuesIn(psParams), ::testing::ValuesIn(netPrecisions), @@ -267,7 +267,7 @@ const auto avgPoolExplicitPadFloorRoundingParams = ::testing::Combine( ); -INSTANTIATE_TEST_CASE_P(smoke_AvgPool_ExplicitPad_FloorRounding, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_ExplicitPad_FloorRounding, PoolingLayerTest, ::testing::Combine( avgPoolExplicitPadFloorRoundingParams, ::testing::ValuesIn(netPrecisions), @@ -291,7 +291,7 @@ const auto avgPool_ExplicitPad_FloorRounding_5Dinput_Params = ::testing::Combine ::testing::Values(true, false) ); -INSTANTIATE_TEST_CASE_P(smoke_AvgPool_ExplicitPad_FloorRounding_5Dinput, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_ExplicitPad_FloorRounding_5Dinput, PoolingLayerTest, ::testing::Combine( avgPool_ExplicitPad_FloorRounding_5Dinput_Params, ::testing::ValuesIn(netPrecisions), @@ -315,7 +315,7 @@ const auto avgPool_SameUpperPad_FloorRounding_5Dinput_Params = ::testing::Combin ::testing::Values(true) ); -INSTANTIATE_TEST_CASE_P(smoke_AvgPool_SameUpperPad_FloorRounding_5Dinput, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_SameUpperPad_FloorRounding_5Dinput, PoolingLayerTest, ::testing::Combine( avgPool_SameUpperPad_FloorRounding_5Dinput_Params, ::testing::ValuesIn(netPrecisions), @@ -339,7 +339,7 @@ const auto avgPool_SameLowerPad_CeilRounding_5Dinput_Params = ::testing::Combine ::testing::Values(true) ); -INSTANTIATE_TEST_CASE_P(smoke_AvgPool_SameLowerPad_CeilRounding_5Dinput, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_SameLowerPad_CeilRounding_5Dinput, PoolingLayerTest, ::testing::Combine( avgPool_SameLowerPad_CeilRounding_5Dinput_Params, ::testing::ValuesIn(netPrecisions), @@ -365,7 +365,7 @@ const auto allPools_ValidPad_Params = ::testing::Combine( ::testing::Values(false) // placeholder value - exclude pad not applicable for max pooling ); -INSTANTIATE_TEST_CASE_P(smoke_MAX_and_AVGPool_ValidPad, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MAX_and_AVGPool_ValidPad, PoolingLayerTest, ::testing::Combine( allPools_ValidPad_Params, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/proposal.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/proposal.cpp index df5352605093ba..a225800b954cd4 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/proposal.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/proposal.cpp @@ -39,7 +39,7 @@ const auto proposalParams = ::testing::Combine( ::testing::ValuesIn(framework_) ); -INSTANTIATE_TEST_CASE_P(smoke_Proposal_tests, ProposalLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Proposal_tests, ProposalLayerTest, ::testing::Combine( proposalParams, ::testing::Values(CommonTestUtils::DEVICE_CPU)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/psroi_pooling.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/psroi_pooling.cpp index 6c896b56aa8845..cca6d83a882ac9 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/psroi_pooling.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/psroi_pooling.cpp @@ -24,7 +24,7 @@ const auto PSROICases_average = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_TestsPSROIPooling_average, PSROIPoolingLayerTest, PSROICases_average, PSROIPoolingLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsPSROIPooling_average, PSROIPoolingLayerTest, PSROICases_average, PSROIPoolingLayerTest::getTestCaseName); const auto PSROICases_bilinear = ::testing::Combine( @@ -40,4 +40,4 @@ const auto PSROICases_bilinear = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_TestsPSROIPooling_bilinear, PSROIPoolingLayerTest, PSROICases_bilinear, PSROIPoolingLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsPSROIPooling_bilinear, PSROIPoolingLayerTest, PSROICases_bilinear, PSROIPoolingLayerTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/range.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/range.cpp index acc17b1142eed3..c4bfa1f1567f4e 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/range.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/range.cpp @@ -20,7 +20,7 @@ const std::vector netPrecisions = { InferenceEngine::Precision::FP16 }; -INSTANTIATE_TEST_CASE_P(smoke_Basic, RangeLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Basic, RangeLayerTest, ::testing::Combine( ::testing::ValuesIn(start), ::testing::ValuesIn(stop), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reduce_ops.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reduce_ops.cpp index f5d96aa0d5d330..2608c1bb4584f2 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reduce_ops.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reduce_ops.cpp @@ -166,56 +166,56 @@ const auto params_ReductionTypesLogical = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_ReduceOneAxis, ReduceOpsLayerTest, paramsOneAxis, ReduceOpsLayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_ReduceLogicalOneAxis, ReduceOpsLayerTest, paramsOneAxisLogical, ReduceOpsLayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Reduce_Precisions, ReduceOpsLayerTest, params_Precisions, ReduceOpsLayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Reduce_InputShapes, ReduceOpsLayerTest, params_InputShapes, ReduceOpsLayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Reduce_Axes, ReduceOpsLayerTest, params_Axes, ReduceOpsLayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Reduce_ReductionTypes, ReduceOpsLayerTest, params_ReductionTypes, ReduceOpsLayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_ReduceLogical_ReductionTypes, ReduceOpsLayerTest, params_ReductionTypesLogical, ReduceOpsLayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Reduce, ReduceOpsLayerWithSpecificInputTest, testing::Combine( diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/region_yolo.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/region_yolo.cpp index ac4e3b384039b9..8961b4a91882f9 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/region_yolo.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/region_yolo.cpp @@ -80,6 +80,6 @@ const auto testCase_yolov2_caffe = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_TestsRegionYolov3, RegionYoloLayerTest, testCase_yolov3, RegionYoloLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_TestsRegionYoloMxnet, RegionYoloLayerTest, testCase_yolov3_mxnet, RegionYoloLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_TestsRegionYoloCaffe, RegionYoloLayerTest, testCase_yolov2_caffe, RegionYoloLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsRegionYolov3, RegionYoloLayerTest, testCase_yolov3, RegionYoloLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsRegionYoloMxnet, RegionYoloLayerTest, testCase_yolov3_mxnet, RegionYoloLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsRegionYoloCaffe, RegionYoloLayerTest, testCase_yolov2_caffe, RegionYoloLayerTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reorg_yolo.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reorg_yolo.cpp index 32a1f934968d43..c288688cd548ea 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reorg_yolo.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reorg_yolo.cpp @@ -67,9 +67,9 @@ const auto testCase_batch_2 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_TestsReorgYolo_caffe_YoloV2, ReorgYoloLayerTest, testCase_caffe_yolov2, ReorgYoloLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_TestsReorgYolo_stride_2_smallest, ReorgYoloLayerTest, testCase_smallest, ReorgYoloLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_TestsReorgYolo_stride_2, ReorgYoloLayerTest, testCase_stride_2, ReorgYoloLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_TestsReorgYolo_stride_3, ReorgYoloLayerTest, testCase_stride_3, ReorgYoloLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_TestsReorgYolo_smaller_h, ReorgYoloLayerTest, testCase_smaller_h, ReorgYoloLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_TestsReorgYolo_batch_2, ReorgYoloLayerTest, testCase_batch_2, ReorgYoloLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_caffe_YoloV2, ReorgYoloLayerTest, testCase_caffe_yolov2, ReorgYoloLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_stride_2_smallest, ReorgYoloLayerTest, testCase_smallest, ReorgYoloLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_stride_2, ReorgYoloLayerTest, testCase_stride_2, ReorgYoloLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_stride_3, ReorgYoloLayerTest, testCase_stride_3, ReorgYoloLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_smaller_h, ReorgYoloLayerTest, testCase_smaller_h, ReorgYoloLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_batch_2, ReorgYoloLayerTest, testCase_batch_2, ReorgYoloLayerTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reshape.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reshape.cpp index 28419ec971fca7..6baed1f21fc1ac 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reshape.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reshape.cpp @@ -15,7 +15,7 @@ const std::vector netPrecisions = { InferenceEngine::Precision::FP16 }; -INSTANTIATE_TEST_CASE_P(smoke_ReshapeCheckDynBatch, ReshapeLayerTestRevise, +INSTANTIATE_TEST_SUITE_P(smoke_ReshapeCheckDynBatch, ReshapeLayerTestRevise, ::testing::Combine( ::testing::Values(true), ::testing::ValuesIn(netPrecisions), @@ -29,7 +29,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ReshapeCheckDynBatch, ReshapeLayerTestRevise, ::testing::Values(std::map({{CONFIG_KEY(DYN_BATCH_ENABLED), CONFIG_VALUE(YES)}}))), ReshapeLayerTestRevise::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ReshapeCheck, ReshapeLayerTestRevise, +INSTANTIATE_TEST_SUITE_P(smoke_ReshapeCheck, ReshapeLayerTestRevise, ::testing::Combine( ::testing::Values(true), ::testing::ValuesIn(netPrecisions), @@ -43,7 +43,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ReshapeCheck, ReshapeLayerTestRevise, ::testing::Values(std::map({}))), ReshapeLayerTestRevise::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ReshapeCheckNegative, ReshapeLayerTestRevise, +INSTANTIATE_TEST_SUITE_P(smoke_ReshapeCheckNegative, ReshapeLayerTestRevise, ::testing::Combine( ::testing::Values(true), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/result.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/result.cpp index fd30ef30a0ab30..f352eacaa39661 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/result.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/result.cpp @@ -21,7 +21,7 @@ std::vector inputPrecisions = { ConfigMap config; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_ResultLayerTest, ResultLayerTest, ::testing::Combine(::testing::ValuesIn(inputDims), ::testing::ValuesIn(inputPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reverse_sequence.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reverse_sequence.cpp index 91e0fc5bf5f1ba..b1f864d12ae14f 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reverse_sequence.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reverse_sequence.cpp @@ -33,7 +33,7 @@ const std::vector secondaryInputTypes = { ngraph::helpers::InputLayerType::PARAMETER }; -INSTANTIATE_TEST_CASE_P(Basic_smoke, ReverseSequenceLayerTest, +INSTANTIATE_TEST_SUITE_P(Basic_smoke, ReverseSequenceLayerTest, ::testing::Combine( ::testing::ValuesIn(batchAxisIndices), ::testing::ValuesIn(seqAxisIndices), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/rnn_cell.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/rnn_cell.cpp index db9c450dba8006..e730cc0d2f9bfb 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/rnn_cell.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/rnn_cell.cpp @@ -19,7 +19,7 @@ namespace { std::vector netPrecisions = {InferenceEngine::Precision::FP32, InferenceEngine::Precision::FP16}; - INSTANTIATE_TEST_CASE_P(smoke_RNNCellCommon, RNNCellTest, + INSTANTIATE_TEST_SUITE_P(smoke_RNNCellCommon, RNNCellTest, ::testing::Combine( ::testing::ValuesIn(should_decompose), ::testing::ValuesIn(batch), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/rnn_sequence.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/rnn_sequence.cpp index 3db31d471c532c..e5f7b821564ade 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/rnn_sequence.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/rnn_sequence.cpp @@ -31,7 +31,7 @@ namespace { }; std::vector netPrecisions = {InferenceEngine::Precision::FP32}; - INSTANTIATE_TEST_CASE_P(smoke_RNNSequenceCommonZeroClip, RNNSequenceTest, + INSTANTIATE_TEST_SUITE_P(smoke_RNNSequenceCommonZeroClip, RNNSequenceTest, ::testing::Combine( ::testing::ValuesIn(mode), ::testing::ValuesIn(seq_lengths_zero_clip), @@ -45,7 +45,7 @@ namespace { ::testing::Values(CommonTestUtils::DEVICE_CPU)), RNNSequenceTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_RNNSequenceCommonClip, RNNSequenceTest, + INSTANTIATE_TEST_SUITE_P(smoke_RNNSequenceCommonClip, RNNSequenceTest, ::testing::Combine( ::testing::ValuesIn(mode), ::testing::ValuesIn(seq_lengths_clip_non_zero), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/roi_align.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/roi_align.cpp index 38c97de0ffbd15..b4cb181519c902 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/roi_align.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/roi_align.cpp @@ -31,7 +31,7 @@ const auto ROIAlignCases_average = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_TestsROIAlign_average, ROIAlignLayerTest, ROIAlignCases_average, ROIAlignLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsROIAlign_average, ROIAlignLayerTest, ROIAlignCases_average, ROIAlignLayerTest::getTestCaseName); const auto ROIAlignCases_max = ::testing::Combine( ::testing::ValuesIn( @@ -49,4 +49,4 @@ const auto ROIAlignCases_max = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_TestsROIAlign_max, ROIAlignLayerTest, ROIAlignCases_max, ROIAlignLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsROIAlign_max, ROIAlignLayerTest, ROIAlignCases_max, ROIAlignLayerTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/roi_pooling.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/roi_pooling.cpp index 8387a754b43afe..279f5333e22f6a 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/roi_pooling.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/roi_pooling.cpp @@ -61,5 +61,5 @@ const auto test_ROIPooling_bilinear = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_TestsROIPooling_max, ROIPoolingLayerTest, test_ROIPooling_max, ROIPoolingLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_TestsROIPooling_bilinear, ROIPoolingLayerTest, test_ROIPooling_bilinear, ROIPoolingLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsROIPooling_max, ROIPoolingLayerTest, test_ROIPooling_max, ROIPoolingLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsROIPooling_bilinear, ROIPoolingLayerTest, test_ROIPooling_bilinear, ROIPoolingLayerTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/roll.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/roll.cpp index f47d29704ded90..af67f1eb431990 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/roll.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/roll.cpp @@ -84,13 +84,13 @@ const auto testCaseUnordNegAxesAndShifts10D = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsRoll_2d_zero_shifts, RollLayerTest, testCase2DZeroShifts, RollLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsRoll_1d, RollLayerTest, testCase1D, RollLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsRoll_2d, RollLayerTest, testCase2D, RollLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsRoll_3d, RollLayerTest, testCase3D, RollLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsRoll_negative_unordered_axes_4d, RollLayerTest, testCaseNegativeUnorderedAxes4D, RollLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsRoll_negative_unordered_axes_5d, RollLayerTest, testCaseRepeatingAxes5D, RollLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsRoll_negative_shifts_6d, RollLayerTest, testCaseNegativeShifts6D, RollLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsRoll_unord_neg_shifts_and_axes_10d, RollLayerTest, testCaseUnordNegAxesAndShifts10D, RollLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsRoll_2d_zero_shifts, RollLayerTest, testCase2DZeroShifts, RollLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsRoll_1d, RollLayerTest, testCase1D, RollLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsRoll_2d, RollLayerTest, testCase2D, RollLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsRoll_3d, RollLayerTest, testCase3D, RollLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsRoll_negative_unordered_axes_4d, RollLayerTest, testCaseNegativeUnorderedAxes4D, RollLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsRoll_negative_unordered_axes_5d, RollLayerTest, testCaseRepeatingAxes5D, RollLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsRoll_negative_shifts_6d, RollLayerTest, testCaseNegativeShifts6D, RollLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsRoll_unord_neg_shifts_and_axes_10d, RollLayerTest, testCaseUnordNegAxesAndShifts10D, RollLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/scatter_ND_update.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/scatter_ND_update.cpp index 081d07345347cc..cbccbd3793b2ed 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/scatter_ND_update.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/scatter_ND_update.cpp @@ -36,6 +36,6 @@ const auto ScatterNDUpdateCases = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_ScatterNDUpdate, ScatterNDUpdateLayerTest, ScatterNDUpdateCases, ScatterNDUpdateLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_ScatterNDUpdate, ScatterNDUpdateLayerTest, ScatterNDUpdateCases, ScatterNDUpdateLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/scatter_elements_update.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/scatter_elements_update.cpp index 15b8852b101392..64c808b260aa18 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/scatter_elements_update.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/scatter_elements_update.cpp @@ -42,7 +42,7 @@ const auto ScatterEltUpdateCases = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_ScatterEltsUpdate, ScatterElementsUpdateLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ScatterEltsUpdate, ScatterElementsUpdateLayerTest, ScatterEltUpdateCases, ScatterElementsUpdateLayerTest::getTestCaseName); } // namespace \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/scatter_update.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/scatter_update.cpp index b9ef4bbbfc9614..31362e0b2646b2 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/scatter_update.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/scatter_update.cpp @@ -41,6 +41,6 @@ const auto ScatterUpdateCase = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_ScatterUpdate, ScatterUpdateLayerTest, ScatterUpdateCase, ScatterUpdateLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_ScatterUpdate, ScatterUpdateLayerTest, ScatterUpdateCase, ScatterUpdateLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/select.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/select.cpp index 315c3331db9800..424f692b1ef6aa 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/select.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/select.cpp @@ -81,6 +81,6 @@ const auto numpyCases = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsSelect_none, SelectLayerTest, noneCases, SelectLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsSelect_none, SelectLayerTest, noneCases, SelectLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MKLDNN_TestsSelect_numpy, SelectLayerTest, numpyCases, SelectLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MKLDNN_TestsSelect_numpy, SelectLayerTest, numpyCases, SelectLayerTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/shape_of.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/shape_of.cpp index 9dbd9a6abbff27..814d3c64f7f5a9 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/shape_of.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/shape_of.cpp @@ -14,7 +14,7 @@ namespace { InferenceEngine::Precision::I32 }; - INSTANTIATE_TEST_CASE_P(smoke_Check, ShapeOfLayerTest, + INSTANTIATE_TEST_SUITE_P(smoke_Check, ShapeOfLayerTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(std::vector({10, 10, 10})), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/shuffle_channels.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/shuffle_channels.cpp index b338d02efc14bd..dfc51edd9ca298 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/shuffle_channels.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/shuffle_channels.cpp @@ -24,7 +24,7 @@ const auto shuffleChannelsParams4D = ::testing::Combine( ::testing::ValuesIn(groups) ); -INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels4D, ShuffleChannelsLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannels4D, ShuffleChannelsLayerTest, ::testing::Combine( shuffleChannelsParams4D, ::testing::ValuesIn(netPrecisions), @@ -37,7 +37,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels4D, ShuffleChannelsLayerTest, ShuffleChannelsLayerTest::getTestCaseName); // ND support tests -INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels6D, ShuffleChannelsLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannels6D, ShuffleChannelsLayerTest, ::testing::Combine( ::testing::Values(std::tuple(2, 3)), ::testing::ValuesIn(netPrecisions), @@ -49,7 +49,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels6D, ShuffleChannelsLayerTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), ShuffleChannelsLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels5D, ShuffleChannelsLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannels5D, ShuffleChannelsLayerTest, ::testing::Combine( ::testing::Values(std::tuple(2, 3)), ::testing::ValuesIn(netPrecisions), @@ -61,7 +61,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels5D, ShuffleChannelsLayerTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), ShuffleChannelsLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels3D, ShuffleChannelsLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannels3D, ShuffleChannelsLayerTest, ::testing::Combine( ::testing::Values(std::tuple(1, 3)), ::testing::ValuesIn(netPrecisions), @@ -73,7 +73,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels3D, ShuffleChannelsLayerTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), ShuffleChannelsLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels2D, ShuffleChannelsLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannels2D, ShuffleChannelsLayerTest, ::testing::Combine( ::testing::Values(std::tuple(1, 3)), ::testing::ValuesIn(netPrecisions), @@ -85,7 +85,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels2D, ShuffleChannelsLayerTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), ShuffleChannelsLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels1D, ShuffleChannelsLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannels1D, ShuffleChannelsLayerTest, ::testing::Combine( ::testing::Values(std::tuple(0, 3)), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/softmax.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/softmax.cpp index 4c90f92d98b117..23d4c6555da928 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/softmax.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/softmax.cpp @@ -41,7 +41,7 @@ const auto params2D = testing::Combine( testing::Values(std::map()) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_SoftMax2D, SoftMaxLayerTest, params2D, @@ -68,7 +68,7 @@ const auto params4D = testing::Combine( testing::Values(std::map()) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_SoftMax4D, SoftMaxLayerTest, params4D, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/space_to_batch.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/space_to_batch.cpp index 884440c7bdedbc..f6afb616f60655 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/space_to_batch.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/space_to_batch.cpp @@ -37,7 +37,7 @@ const auto SpaceToBatch4D = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_spacetobatch4D, SpaceToBatchLayerTest, SpaceToBatch4D, SpaceToBatchLayerTest::getTestCaseName); @@ -67,7 +67,7 @@ const auto SpaceToBatch5D = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_spacetobatch5D, SpaceToBatchLayerTest, SpaceToBatch5D, SpaceToBatchLayerTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/space_to_depth.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/space_to_depth.cpp index ff7e33e495ec26..29d2af87ea4f29 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/space_to_depth.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/space_to_depth.cpp @@ -36,7 +36,7 @@ const auto SpaceToDepthBS2 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_SpaceToDepthBS2, SpaceToDepthLayerTest, SpaceToDepthBS2, SpaceToDepthLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_SpaceToDepthBS2, SpaceToDepthLayerTest, SpaceToDepthBS2, SpaceToDepthLayerTest::getTestCaseName); const std::vector> inputShapesBS3 = { {1, 1, 3, 3}, {1, 1, 6, 6}, {1, 1, 9, 9}, {2, 4, 9, 9}, {2, 3, 15, 12}, @@ -51,6 +51,6 @@ const auto SpaceToDepthBS3 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_SpaceToDepthBS3, SpaceToDepthLayerTest, SpaceToDepthBS3, SpaceToDepthLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_SpaceToDepthBS3, SpaceToDepthLayerTest, SpaceToDepthBS3, SpaceToDepthLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/split.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/split.cpp index 35d3149dcc361c..7c12638fd6d4ad 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/split.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/split.cpp @@ -18,7 +18,7 @@ const std::vector netPrecisions = { InferenceEngine::Precision::U8 }; -INSTANTIATE_TEST_CASE_P(smoke_NumSplitsCheck, SplitLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_NumSplitsCheck, SplitLayerTest, ::testing::Combine( ::testing::Values(1, 2, 3, 5), ::testing::Values(0, 1, 2, 3), @@ -32,7 +32,7 @@ INSTANTIATE_TEST_CASE_P(smoke_NumSplitsCheck, SplitLayerTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), SplitLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_splitWithUnusedOutputsTest, SplitLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_splitWithUnusedOutputsTest, SplitLayerTest, ::testing::Combine( ::testing::Values(5), ::testing::Values(0), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/squeeze_unsqueeze.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/squeeze_unsqueeze.cpp index a5a8f35a35080b..2145c5d37eaaa9 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/squeeze_unsqueeze.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/squeeze_unsqueeze.cpp @@ -38,7 +38,7 @@ const std::vector opTypes = { ngraph::helpers::SqueezeOpType::UNSQUEEZE }; -INSTANTIATE_TEST_CASE_P(smoke_Basic, SqueezeUnsqueezeLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Basic, SqueezeUnsqueezeLayerTest, ::testing::Combine( ::testing::ValuesIn(CommonTestUtils::combineParams(axesVectors)), ::testing::ValuesIn(opTypes), @@ -50,7 +50,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Basic, SqueezeUnsqueezeLayerTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), SqueezeUnsqueezeLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Basic_emptyAxes, SqueezeUnsqueezeLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Basic_emptyAxes, SqueezeUnsqueezeLayerTest, ::testing::Combine( ::testing::ValuesIn(CommonTestUtils::combineParams(emptyAxesVectors)), ::testing::Values(ngraph::helpers::SqueezeOpType::SQUEEZE), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/strided_slice.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/strided_slice.cpp index 9897df6a8303ed..bd749a0b51c7d9 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/strided_slice.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/strided_slice.cpp @@ -116,7 +116,7 @@ std::vector ss_only_test_cases = { { 1, 1, 1, 0, 1 }, { 1, 1, 1, 0, 1 }, { }, { 0, 1, 0, 0, 0 }, { } }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_MKLDNN, StridedSliceLayerTest, ::testing::Combine( ::testing::ValuesIn(ss_only_test_cases), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/tensor_iterator.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/tensor_iterator.cpp index 2a551b695f9685..279e4e98495eef 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/tensor_iterator.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/tensor_iterator.cpp @@ -28,7 +28,7 @@ namespace { std::vector netPrecisions = {InferenceEngine::Precision::FP32, InferenceEngine::Precision::FP16}; - INSTANTIATE_TEST_CASE_P(smoke_TensorIteratorCommon, TensorIteratorTest, + INSTANTIATE_TEST_SUITE_P(smoke_TensorIteratorCommon, TensorIteratorTest, ::testing::Combine( ::testing::ValuesIn(should_decompose), ::testing::ValuesIn(seq_lengths_zero_clip), @@ -43,7 +43,7 @@ namespace { ::testing::Values(CommonTestUtils::DEVICE_CPU)), TensorIteratorTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_TensorIteratorCommonClip, TensorIteratorTest, + INSTANTIATE_TEST_SUITE_P(smoke_TensorIteratorCommonClip, TensorIteratorTest, ::testing::Combine( ::testing::ValuesIn(should_decompose), ::testing::ValuesIn(seq_lengths_clip_non_zero), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/tile.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/tile.cpp index 5894b1c1ec6724..bff906dd1019ec 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/tile.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/tile.cpp @@ -22,7 +22,7 @@ const std::vector> repeats3D = { {1, 1, 1} }; -INSTANTIATE_TEST_CASE_P(smoke_Tile, TileLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Tile, TileLayerTest, ::testing::Combine( ::testing::ValuesIn(repeats3D), ::testing::ValuesIn(netPrecisions), @@ -39,7 +39,7 @@ const std::vector> repeats6D = { {1, 1, 1, 1, 1, 1} }; -INSTANTIATE_TEST_CASE_P(smoke_Tile6d, TileLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Tile6d, TileLayerTest, ::testing::Combine( ::testing::ValuesIn(repeats6D), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/topk.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/topk.cpp index d3da99f63690dc..dfb717a6b64df6 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/topk.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/topk.cpp @@ -38,7 +38,7 @@ const std::vector sortTypes = { }; -INSTANTIATE_TEST_CASE_P(smoke_TopK, TopKLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_TopK, TopKLayerTest, ::testing::Combine( ::testing::ValuesIn(k), ::testing::ValuesIn(axes), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/transpose.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/transpose.cpp index 044448b7843968..0575fc345b79dc 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/transpose.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/transpose.cpp @@ -23,7 +23,7 @@ const std::vector netPrecisions = { std::vector> inputShape2D = {{2, 10}, {10, 2}, {10, 10}}; std::vector> order2D = {{}, {0, 1}, {1, 0}}; -INSTANTIATE_TEST_CASE_P(smoke_Transpose2D, TransposeLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Transpose2D, TransposeLayerTest, ::testing::Combine( ::testing::ValuesIn(order2D), ::testing::ValuesIn(netPrecisions), @@ -43,7 +43,7 @@ std::vector> order4D = { {3, 0, 1, 2}, {3, 0, 2, 1}, {3, 1, 0, 2}, {3, 1, 2, 0}, {3, 2, 0, 1}, {3, 2, 1, 0} }; -INSTANTIATE_TEST_CASE_P(smoke_Transpose4D, TransposeLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Transpose4D, TransposeLayerTest, ::testing::Combine( ::testing::ValuesIn(order4D), ::testing::ValuesIn(netPrecisions), @@ -61,7 +61,7 @@ std::vector> order5D = { {1, 4, 2, 3, 0}, {2, 4, 1, 0, 3}, {3, 0, 2, 1, 4}, {4, 1, 0, 3, 2}, {0, 4, 1, 2, 3}, }; -INSTANTIATE_TEST_CASE_P(smoke_Transpose5D, TransposeLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Transpose5D, TransposeLayerTest, ::testing::Combine( ::testing::ValuesIn(order5D), ::testing::ValuesIn(netPrecisions), @@ -79,7 +79,7 @@ std::vector> order6D = { {1, 5, 4, 2, 3, 0}, {2, 5, 4, 1, 0, 3}, {3, 0, 2, 1, 4, 5}, {5, 1, 0, 4, 3, 2}, {0, 5, 1, 2, 3, 4}, }; -INSTANTIATE_TEST_CASE_P(smoke_Transpose6D, TransposeLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Transpose6D, TransposeLayerTest, ::testing::Combine( ::testing::ValuesIn(order6D), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/variadic_split.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/variadic_split.cpp index db0c9e156e6af5..7b9af2bbae2c29 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/variadic_split.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/variadic_split.cpp @@ -25,7 +25,7 @@ namespace { {4, 11, 6, 9} }; - INSTANTIATE_TEST_CASE_P(smoke_NumSplitsCheck, VariadicSplitLayerTest, + INSTANTIATE_TEST_SUITE_P(smoke_NumSplitsCheck, VariadicSplitLayerTest, ::testing::Combine( ::testing::ValuesIn(numSplits), ::testing::Values(0, 1, 2, 3), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_add.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_add.cpp index 72c50bce2a4f7f..940aa4bf5c81b0 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_add.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_add.cpp @@ -16,7 +16,7 @@ namespace { InferenceEngine::Precision::FP32 }; - INSTANTIATE_TEST_CASE_P(NoReshape, CodegenAdd, + INSTANTIATE_TEST_SUITE_P(NoReshape, CodegenAdd, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::SizeVector({1, 42, 16, 64})), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_bert.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_bert.cpp index 97b3737d69366d..ea76ba4d7dfb49 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_bert.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_bert.cpp @@ -16,7 +16,7 @@ namespace { InferenceEngine::Precision::FP32 }; - INSTANTIATE_TEST_CASE_P(NoReshape, CodegenBert, + INSTANTIATE_TEST_SUITE_P(NoReshape, CodegenBert, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::SizeVector({1, 42, 16, 64})), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_gelu.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_gelu.cpp index 81b03911dabe41..c7e9a5664b74ff 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_gelu.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/codegen_gelu.cpp @@ -16,7 +16,7 @@ namespace { InferenceEngine::Precision::FP32 }; - INSTANTIATE_TEST_CASE_P(NoReshape, CodegenGelu, + INSTANTIATE_TEST_SUITE_P(NoReshape, CodegenGelu, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::SizeVector({1, 384, 4096})), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/constant_result.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/constant_result.cpp index 19dcaacecda54e..10fb3563eee56d 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/constant_result.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/constant_result.cpp @@ -34,7 +34,7 @@ const std::vector precisions = { Precision::BOOL }; -INSTANTIATE_TEST_CASE_P(smoke_Check, ConstantResultSubgraphTest, +INSTANTIATE_TEST_SUITE_P(smoke_Check, ConstantResultSubgraphTest, ::testing::Combine( ::testing::ValuesIn(types), ::testing::ValuesIn(shapes), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/conv_eltwise_fusion.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/conv_eltwise_fusion.cpp index 920891a726ae51..fe598de71bac73 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/conv_eltwise_fusion.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/conv_eltwise_fusion.cpp @@ -16,7 +16,7 @@ namespace { #define ADD(X) std::tuple(ngraph::opset4::Add::type_info, X) #define IN std::vector> - INSTANTIATE_TEST_CASE_P(smoke_Convolution_1D, ConvEltwiseFusion, + INSTANTIATE_TEST_SUITE_P(smoke_Convolution_1D, ConvEltwiseFusion, ::testing::Combine( ::testing::Values(ngraph::opset4::Convolution::type_info), ::testing::ValuesIn(IN({MUL(4), ADD(5)})), @@ -27,7 +27,7 @@ namespace { ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvEltwiseFusion::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_GroupConvolution_1D, ConvEltwiseFusion, + INSTANTIATE_TEST_SUITE_P(smoke_GroupConvolution_1D, ConvEltwiseFusion, ::testing::Combine( ::testing::Values(ngraph::opset4::GroupConvolution::type_info), ::testing::ValuesIn(IN({MUL(4), ADD(5)})), @@ -38,7 +38,7 @@ namespace { ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvEltwiseFusion::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData_1D, ConvEltwiseFusion, + INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData_1D, ConvEltwiseFusion, ::testing::Combine( ::testing::Values(ngraph::opset4::ConvolutionBackpropData::type_info), ::testing::ValuesIn(IN({MUL(4), ADD(5)})), @@ -49,7 +49,7 @@ namespace { ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvEltwiseFusion::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_GroupConvolutionBackpropData_1D, ConvEltwiseFusion, + INSTANTIATE_TEST_SUITE_P(smoke_GroupConvolutionBackpropData_1D, ConvEltwiseFusion, ::testing::Combine( ::testing::Values(ngraph::opset4::GroupConvolutionBackpropData::type_info), ::testing::ValuesIn(IN({MUL(4), ADD(5)})), @@ -68,7 +68,7 @@ namespace { {1, 1, 1, 1} }; - INSTANTIATE_TEST_CASE_P(smoke_Convolution_2D, ConvEltwiseFusion, + INSTANTIATE_TEST_SUITE_P(smoke_Convolution_2D, ConvEltwiseFusion, ::testing::Combine( ::testing::Values(ngraph::opset4::Convolution::type_info), ::testing::ValuesIn(IN({MUL(4), ADD(5)})), @@ -79,7 +79,7 @@ namespace { ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvEltwiseFusion::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_GroupConvolution_2D, ConvEltwiseFusion, + INSTANTIATE_TEST_SUITE_P(smoke_GroupConvolution_2D, ConvEltwiseFusion, ::testing::Combine( ::testing::Values(ngraph::opset4::GroupConvolution::type_info), ::testing::ValuesIn(IN({MUL(4), ADD(5)})), @@ -90,7 +90,7 @@ namespace { ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvEltwiseFusion::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData_2D, ConvEltwiseFusion, + INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData_2D, ConvEltwiseFusion, ::testing::Combine( ::testing::Values(ngraph::opset4::ConvolutionBackpropData::type_info), ::testing::ValuesIn(IN({MUL(4), ADD(5)})), @@ -101,7 +101,7 @@ namespace { ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvEltwiseFusion::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_GroupConvolutionBackpropData_2D, ConvEltwiseFusion, + INSTANTIATE_TEST_SUITE_P(smoke_GroupConvolutionBackpropData_2D, ConvEltwiseFusion, ::testing::Combine( ::testing::Values(ngraph::opset4::GroupConvolutionBackpropData::type_info), ::testing::ValuesIn(IN({MUL(4), ADD(5)})), @@ -117,7 +117,7 @@ namespace { {3}, {3, 1}, {3, 1, 1, 1} }; - INSTANTIATE_TEST_CASE_P(smoke_Convolution_2D_Negative, ConvEltwiseFusion, + INSTANTIATE_TEST_SUITE_P(smoke_Convolution_2D_Negative, ConvEltwiseFusion, ::testing::Combine( ::testing::Values(ngraph::opset4::Convolution::type_info), ::testing::ValuesIn(IN({MUL(6), ADD(6)})), @@ -128,7 +128,7 @@ namespace { ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvEltwiseFusion::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_GroupConvolution_2D_Negative, ConvEltwiseFusion, + INSTANTIATE_TEST_SUITE_P(smoke_GroupConvolution_2D_Negative, ConvEltwiseFusion, ::testing::Combine( ::testing::Values(ngraph::opset4::GroupConvolution::type_info), ::testing::ValuesIn(IN({MUL(6), ADD(6)})), @@ -139,7 +139,7 @@ namespace { ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvEltwiseFusion::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData_2D_Negative, ConvEltwiseFusion, + INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData_2D_Negative, ConvEltwiseFusion, ::testing::Combine( ::testing::Values(ngraph::opset4::ConvolutionBackpropData::type_info), ::testing::ValuesIn(IN({MUL(6), ADD(6)})), @@ -150,7 +150,7 @@ namespace { ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvEltwiseFusion::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_GroupConvolutionBackpropData_2D_Negative, ConvEltwiseFusion, + INSTANTIATE_TEST_SUITE_P(smoke_GroupConvolutionBackpropData_2D_Negative, ConvEltwiseFusion, ::testing::Combine( ::testing::Values(ngraph::opset4::GroupConvolutionBackpropData::type_info), ::testing::ValuesIn(IN({MUL(6), ADD(6)})), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/convert_pad_to_group_conv.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/convert_pad_to_group_conv.cpp index 2ab868e8ca04ad..556eafd6aaf239 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/convert_pad_to_group_conv.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/convert_pad_to_group_conv.cpp @@ -16,7 +16,7 @@ namespace { const std::vector values{0., 1.}; - INSTANTIATE_TEST_CASE_P(smoke_Pad_1D, ConvertPadToConvTests, + INSTANTIATE_TEST_SUITE_P(smoke_Pad_1D, ConvertPadToConvTests, ::testing::Combine( ::testing::Values(ngraph::Shape{1, 8, 64}), ::testing::ValuesIn(pads_1d), @@ -31,7 +31,7 @@ namespace { {0, 0, 10, 10}, {0, 0, 0, 4}, {0, 0, 4, 0} }; - INSTANTIATE_TEST_CASE_P(smoke_Pad_2D, ConvertPadToConvTests, + INSTANTIATE_TEST_SUITE_P(smoke_Pad_2D, ConvertPadToConvTests, ::testing::Combine( ::testing::Values(ngraph::Shape{1, 8, 64, 16}), ::testing::ValuesIn(pads_2d), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/get_output_before_activation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/get_output_before_activation.cpp index 6f47cf9d7d9dff..337490706795b6 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/get_output_before_activation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/get_output_before_activation.cpp @@ -23,7 +23,7 @@ namespace { std::map additional_config = {}; } // namespace -INSTANTIATE_TEST_CASE_P(OutputBeforeActivation, OutputBeforeActivation, +INSTANTIATE_TEST_SUITE_P(OutputBeforeActivation, OutputBeforeActivation, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::Values(InferenceEngine::Precision::FP32), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/matmul_squeeze_add.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/matmul_squeeze_add.cpp index 9cab6afd9fb68d..ac3192476002cd 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/matmul_squeeze_add.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/matmul_squeeze_add.cpp @@ -36,7 +36,7 @@ std::vector output_sizes = { 8 }; -INSTANTIATE_TEST_CASE_P(smoke_MatmulSqueezeAdd, MatmulSqueezeAddTest, +INSTANTIATE_TEST_SUITE_P(smoke_MatmulSqueezeAdd, MatmulSqueezeAddTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/memory_LSTMCell.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/memory_LSTMCell.cpp index 8e9754343474cb..2d7af0c03d32e0 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/memory_LSTMCell.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/memory_LSTMCell.cpp @@ -33,7 +33,7 @@ namespace SubgraphTestsDefinitions { std::map additional_config = { }; - INSTANTIATE_TEST_CASE_P(smoke_MemoryLSTMCellTest, MemoryLSTMCellTest, + INSTANTIATE_TEST_SUITE_P(smoke_MemoryLSTMCellTest, MemoryLSTMCellTest, ::testing::Combine( ::testing::ValuesIn(transformation), ::testing::Values(CommonTestUtils::DEVICE_CPU), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/multiple_LSTMCell.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/multiple_LSTMCell.cpp index 4c18ee6ea054bb..f0f8e6c6895399 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/multiple_LSTMCell.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/multiple_LSTMCell.cpp @@ -35,7 +35,7 @@ std::map additional_config = { } // namespace -INSTANTIATE_TEST_CASE_P(MultipleLSTMCellTest, MultipleLSTMCellTest, +INSTANTIATE_TEST_SUITE_P(MultipleLSTMCellTest, MultipleLSTMCellTest, ::testing::Combine( ::testing::ValuesIn(transformation), ::testing::Values(CommonTestUtils::DEVICE_CPU), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/multiply_add.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/multiply_add.cpp index 37df66d8b6bbbf..73145968aa718e 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/multiply_add.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/multiply_add.cpp @@ -22,7 +22,7 @@ const std::vector> inputShapes = { {1, 3, 2, 2, 2, 2, 2, 2, 4, 5}, }; -INSTANTIATE_TEST_CASE_P(smoke_MultipleAdd_Nd, MultiplyAddLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MultipleAdd_Nd, MultiplyAddLayerTest, ::testing::Combine( ::testing::ValuesIn(inputShapes), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/mvn_multiply_add.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/mvn_multiply_add.cpp index 3150926b2a9ea9..58087839db20a9 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/mvn_multiply_add.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/mvn_multiply_add.cpp @@ -55,7 +55,7 @@ const std::vector> shapes_3D = { std::pair{ SizeVector{2, 3, 3}, SizeVector{2, 3, 3}}, }; -INSTANTIATE_TEST_CASE_P(smoke_MVNMultiplyAdd_1D, MVNMultiplyAdd, +INSTANTIATE_TEST_SUITE_P(smoke_MVNMultiplyAdd_1D, MVNMultiplyAdd, ::testing::Combine( ::testing::ValuesIn(shapes_1D), ::testing::ValuesIn(netPrecision), @@ -67,7 +67,7 @@ INSTANTIATE_TEST_CASE_P(smoke_MVNMultiplyAdd_1D, MVNMultiplyAdd, ::testing::Values(CommonTestUtils::DEVICE_CPU)), MVNMultiplyAdd::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MVNMultiplyAdd_2D, MVNMultiplyAdd, +INSTANTIATE_TEST_SUITE_P(smoke_MVNMultiplyAdd_2D, MVNMultiplyAdd, ::testing::Combine( ::testing::ValuesIn(shapes_2D), ::testing::ValuesIn(netPrecision), @@ -79,7 +79,7 @@ INSTANTIATE_TEST_CASE_P(smoke_MVNMultiplyAdd_2D, MVNMultiplyAdd, ::testing::Values(CommonTestUtils::DEVICE_CPU)), MVNMultiplyAdd::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MVNMultiplyAdd_3D, MVNMultiplyAdd, +INSTANTIATE_TEST_SUITE_P(smoke_MVNMultiplyAdd_3D, MVNMultiplyAdd, ::testing::Combine( ::testing::ValuesIn(shapes_3D), ::testing::ValuesIn(netPrecision), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/parameter_result.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/parameter_result.cpp index 7eb8265150c599..3da2e776949a58 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/parameter_result.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/parameter_result.cpp @@ -8,7 +8,7 @@ using namespace SubgraphTestsDefinitions; namespace { - INSTANTIATE_TEST_CASE_P(smoke_Check, ParameterResultSubgraphTest, + INSTANTIATE_TEST_SUITE_P(smoke_Check, ParameterResultSubgraphTest, ::testing::Values(CommonTestUtils::DEVICE_CPU), ParameterResultSubgraphTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/perm_conv_perm_concat.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/perm_conv_perm_concat.cpp index da0b67cd8c4f03..01192fdffd5386 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/perm_conv_perm_concat.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/perm_conv_perm_concat.cpp @@ -31,7 +31,7 @@ std::map additional_config = { } // namespace namespace SubgraphTestsDefinitions { -INSTANTIATE_TEST_CASE_P(smoke_basic, PermConvPermConcat, +INSTANTIATE_TEST_SUITE_P(smoke_basic, PermConvPermConcat, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/quantized_convolution_backprop_data.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/quantized_convolution_backprop_data.cpp index 0413002c0967e3..2d35a470247bd3 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/quantized_convolution_backprop_data.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/quantized_convolution_backprop_data.cpp @@ -42,7 +42,7 @@ const auto quantConvBackpropData2DParams = ::testing::Combine( ::testing::ValuesIn(granularity) ); -INSTANTIATE_TEST_CASE_P(smoke_QuantConvBackpropData2D, QuantConvBackpropDataLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_QuantConvBackpropData2D, QuantConvBackpropDataLayerTest, ::testing::Combine( quantConvBackpropData2DParams, ::testing::ValuesIn(netPrecisions), @@ -70,7 +70,7 @@ const auto quantConvBackpropData3DParams = ::testing::Combine( ::testing::ValuesIn(granularity) ); -INSTANTIATE_TEST_CASE_P(smoke_QuantConvBackpropData3D, QuantConvBackpropDataLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_QuantConvBackpropData3D, QuantConvBackpropDataLayerTest, ::testing::Combine( quantConvBackpropData3DParams, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/quantized_group_convolution.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/quantized_group_convolution.cpp index 33c010dc36ca29..7627c3730ddf9b 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/quantized_group_convolution.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/quantized_group_convolution.cpp @@ -46,7 +46,7 @@ const auto quantGroupConv2DParams = ::testing::Combine( ::testing::ValuesIn(quantizeWeights) ); -INSTANTIATE_TEST_CASE_P(smoke_QuantGroupConv2D, QuantGroupConvLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_QuantGroupConv2D, QuantGroupConvLayerTest, ::testing::Combine( quantGroupConv2DParams, ::testing::ValuesIn(netPrecisions), @@ -75,7 +75,7 @@ const auto quantGroupConv3DParams = ::testing::Combine( ::testing::ValuesIn(quantizeWeights) ); -INSTANTIATE_TEST_CASE_P(smoke_QuantGroupConv3D, QuantGroupConvLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_QuantGroupConv3D, QuantGroupConvLayerTest, ::testing::Combine( quantGroupConv3DParams, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/quantized_group_convolution_backprop_data.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/quantized_group_convolution_backprop_data.cpp index bc64dd43041553..ef002cc8ee5e6e 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/quantized_group_convolution_backprop_data.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/quantized_group_convolution_backprop_data.cpp @@ -44,7 +44,7 @@ const auto quantGroupConvBackpropData2DParams = ::testing::Combine( ::testing::ValuesIn(granularity) ); -INSTANTIATE_TEST_CASE_P(smoke_QuantGroupConvBackpropData2D, QuantGroupConvBackpropDataLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_QuantGroupConvBackpropData2D, QuantGroupConvBackpropDataLayerTest, ::testing::Combine( quantGroupConvBackpropData2DParams, ::testing::ValuesIn(netPrecisions), @@ -73,7 +73,7 @@ const auto quantGroupConvBackpropData3DParams = ::testing::Combine( ::testing::ValuesIn(granularity) ); -INSTANTIATE_TEST_CASE_P(smoke_QuantGroupConvBackpropData3D, QuantGroupConvBackpropDataLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_QuantGroupConvBackpropData3D, QuantGroupConvBackpropDataLayerTest, ::testing::Combine( quantGroupConvBackpropData3DParams, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/quantized_mat_mul.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/quantized_mat_mul.cpp index 3af9da8f49c961..7914371a463d30 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/quantized_mat_mul.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/quantized_mat_mul.cpp @@ -77,7 +77,7 @@ const auto quantParams_i32 = ::testing::Combine( ::testing::Values(InferenceEngine::Precision::I32) ); -INSTANTIATE_TEST_CASE_P(smoke_QuantMatMul_i8i8, QuantMatMulTest, +INSTANTIATE_TEST_SUITE_P(smoke_QuantMatMul_i8i8, QuantMatMulTest, ::testing::Combine( quantParams_i8, quantParams_i8, @@ -87,7 +87,7 @@ INSTANTIATE_TEST_CASE_P(smoke_QuantMatMul_i8i8, QuantMatMulTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), QuantMatMulTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_QuantMatMul_u8i8, QuantMatMulTest, +INSTANTIATE_TEST_SUITE_P(smoke_QuantMatMul_u8i8, QuantMatMulTest, ::testing::Combine( quantParams_u8, quantParams_i8, @@ -97,7 +97,7 @@ INSTANTIATE_TEST_CASE_P(smoke_QuantMatMul_u8i8, QuantMatMulTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), QuantMatMulTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_QuantMatMul_i16i32, QuantMatMulTest, +INSTANTIATE_TEST_SUITE_P(smoke_QuantMatMul_i16i32, QuantMatMulTest, ::testing::Combine( quantParams_i16, quantParams_i32, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/range_add.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/range_add.cpp index 9a53c864dd99bc..35e388f328ec9f 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/range_add.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/range_add.cpp @@ -30,7 +30,7 @@ const std::vector netPrecisions = { // ------------------------------ V0 ------------------------------ -INSTANTIATE_TEST_CASE_P(smoke_BasicPositive, RangeAddSubgraphTest, +INSTANTIATE_TEST_SUITE_P(smoke_BasicPositive, RangeAddSubgraphTest, ::testing::Combine( ::testing::ValuesIn(positiveStart), ::testing::ValuesIn(positiveStop), @@ -43,7 +43,7 @@ INSTANTIATE_TEST_CASE_P(smoke_BasicPositive, RangeAddSubgraphTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), RangeAddSubgraphTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BasicNegative, RangeAddSubgraphTest, +INSTANTIATE_TEST_SUITE_P(smoke_BasicNegative, RangeAddSubgraphTest, ::testing::Combine( ::testing::ValuesIn(negativeStart), ::testing::ValuesIn(negativeStop), @@ -57,7 +57,7 @@ INSTANTIATE_TEST_CASE_P(smoke_BasicNegative, RangeAddSubgraphTest, RangeAddSubgraphTest::getTestCaseName); // ------------------------------ V4 ------------------------------ -INSTANTIATE_TEST_CASE_P(smoke_BasicPositive, RangeNumpyAddSubgraphTest, +INSTANTIATE_TEST_SUITE_P(smoke_BasicPositive, RangeNumpyAddSubgraphTest, ::testing::Combine( ::testing::ValuesIn(positiveStart), ::testing::ValuesIn(positiveStop), @@ -70,7 +70,7 @@ INSTANTIATE_TEST_CASE_P(smoke_BasicPositive, RangeNumpyAddSubgraphTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), RangeNumpyAddSubgraphTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BasicNegative, RangeNumpyAddSubgraphTest, +INSTANTIATE_TEST_SUITE_P(smoke_BasicNegative, RangeNumpyAddSubgraphTest, ::testing::Combine( ::testing::ValuesIn(negativeStart), ::testing::ValuesIn(negativeStop), @@ -83,7 +83,7 @@ INSTANTIATE_TEST_CASE_P(smoke_BasicNegative, RangeNumpyAddSubgraphTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), RangeNumpyAddSubgraphTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BasicTruncateInputs, RangeNumpyAddSubgraphTest, +INSTANTIATE_TEST_SUITE_P(smoke_BasicTruncateInputs, RangeNumpyAddSubgraphTest, ::testing::Combine( ::testing::ValuesIn(trunc_start), ::testing::ValuesIn(trunc_stop), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/relu_shape_of.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/relu_shape_of.cpp index 917cb6932c0cab..a1618c3d2fb01c 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/relu_shape_of.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/relu_shape_of.cpp @@ -14,7 +14,7 @@ namespace { InferenceEngine::Precision::I32 }; - INSTANTIATE_TEST_CASE_P(smoke_Check, ReluShapeOfSubgraphTest, + INSTANTIATE_TEST_SUITE_P(smoke_Check, ReluShapeOfSubgraphTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(std::vector({20, 10, 10, 10})), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/reshape_squeeze_reshape_relu.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/reshape_squeeze_reshape_relu.cpp index 1e4666b523b5e0..8645cb95325671 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/reshape_squeeze_reshape_relu.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/reshape_squeeze_reshape_relu.cpp @@ -38,7 +38,7 @@ namespace { ngraph::helpers::SqueezeOpType::UNSQUEEZE }; - INSTANTIATE_TEST_CASE_P(smoke_reshape_squeeze_reshape_relu, ReshapeSqueezeReshapeRelu, + INSTANTIATE_TEST_SUITE_P(smoke_reshape_squeeze_reshape_relu, ReshapeSqueezeReshapeRelu, ::testing::Combine( ::testing::ValuesIn(inputs), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/split_concat_memory.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/split_concat_memory.cpp index a5c93c9ac9ca51..8fdf19bcb5894f 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/split_concat_memory.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/split_concat_memory.cpp @@ -26,7 +26,7 @@ const std::vector shapes = { {3, 8}, }; -INSTANTIATE_TEST_CASE_P(smoke_CPU, SplitConcatMemory, +INSTANTIATE_TEST_SUITE_P(smoke_CPU, SplitConcatMemory, ::testing::Combine( ::testing::ValuesIn(shapes), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/split_conv_concat.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/split_conv_concat.cpp index 12dedadc265072..b156873f470a26 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/split_conv_concat.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/split_conv_concat.cpp @@ -16,7 +16,7 @@ const std::vector netPrecisions = { InferenceEngine::Precision::FP16 }; -INSTANTIATE_TEST_CASE_P(smoke_NoReshape, SplitConvConcat, +INSTANTIATE_TEST_SUITE_P(smoke_NoReshape, SplitConvConcat, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::SizeVector({1, 6, 40, 40})), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/tensor_names.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/tensor_names.cpp index e5d104920cb3f2..8e4e93ceb63d95 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/tensor_names.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/tensor_names.cpp @@ -10,7 +10,7 @@ using namespace SubgraphTestsDefinitions; namespace { - INSTANTIATE_TEST_CASE_P(smoke_Check, TensorNamesTest, + INSTANTIATE_TEST_SUITE_P(smoke_Check, TensorNamesTest, ::testing::Values(CommonTestUtils::DEVICE_CPU), TensorNamesTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/variadic_split_pad.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/variadic_split_pad.cpp index 3e73dbeccf8a1e..8f188589344462 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/variadic_split_pad.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/variadic_split_pad.cpp @@ -48,7 +48,7 @@ const std::vector padMode = { ngraph::helpers::PadMode::SYMMETRIC }; -INSTANTIATE_TEST_CASE_P(smoke_CPU, VariadicSplitPad, +INSTANTIATE_TEST_SUITE_P(smoke_CPU, VariadicSplitPad, ::testing::Combine( ::testing::ValuesIn(shapes), ::testing::Values(1), diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/activation.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/activation.cpp index d473bbde6e2c62..f2e5a76e33c483 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/activation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/activation.cpp @@ -128,7 +128,7 @@ const auto basicCases4D = ::testing::Combine( ::testing::ValuesIn(filterCPUSpecificParams(cpuParams_4D)) ); -INSTANTIATE_TEST_CASE_P(smoke_Activation4D_Eltwise_CPU_BF16, ActivationLayerCPUTest, basicCases4D, ActivationLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Activation4D_Eltwise_CPU_BF16, ActivationLayerCPUTest, basicCases4D, ActivationLayerCPUTest::getTestCaseName); std::vector cpuParams_5D = { CPUSpecificParams({nCdhw16c}, {nCdhw16c}, {}, {}), @@ -154,6 +154,6 @@ const auto basicCases5D = ::testing::Combine( ::testing::ValuesIn(filterCPUSpecificParams(cpuParams_5D)) ); -INSTANTIATE_TEST_CASE_P(smoke_Activation5D_Eltwise_CPU_BF16, ActivationLayerCPUTest, basicCases5D, ActivationLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Activation5D_Eltwise_CPU_BF16, ActivationLayerCPUTest, basicCases5D, ActivationLayerCPUTest::getTestCaseName); } // namespace } // namespace CPULayerTestsDefinitions \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/batch_to_space.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/batch_to_space.cpp index 82c97a51166ca6..a1c583adfcc1b2 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/batch_to_space.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/batch_to_space.cpp @@ -120,10 +120,10 @@ const auto batchToSpaceParamsSet4D2 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(cpuParams_4D)); -INSTANTIATE_TEST_CASE_P(smoke_BatchToSpaceCPULayerTestCase1_4D, BatchToSpaceCPULayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_BatchToSpaceCPULayerTestCase1_4D, BatchToSpaceCPULayerTest, batchToSpaceParamsSet4D1, BatchToSpaceCPULayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BatchToSpaceCPULayerTestCase2_4D, BatchToSpaceCPULayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_BatchToSpaceCPULayerTestCase2_4D, BatchToSpaceCPULayerTest, batchToSpaceParamsSet4D2, BatchToSpaceCPULayerTest::getTestCaseName); const std::vector> blockShape5D1 = {{1, 1, 2, 2, 1}, {1, 2, 1, 2, 2}}; @@ -169,10 +169,10 @@ const auto batchToSpaceParamsSet5D2 = ::testing::Combine( ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(cpuParams_5D)); -INSTANTIATE_TEST_CASE_P(smoke_BatchToSpaceCPULayerTestCase1_5D, BatchToSpaceCPULayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_BatchToSpaceCPULayerTestCase1_5D, BatchToSpaceCPULayerTest, batchToSpaceParamsSet5D1, BatchToSpaceCPULayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BatchToSpaceCPULayerTestCase2_5D, BatchToSpaceCPULayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_BatchToSpaceCPULayerTestCase2_5D, BatchToSpaceCPULayerTest, batchToSpaceParamsSet5D2, BatchToSpaceCPULayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/concat.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/concat.cpp index 32b7b6d60910d0..11c20c7cd01fcd 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/concat.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/concat.cpp @@ -96,7 +96,7 @@ const std::vector netPrecisions = { Precision::BF16 }; -INSTANTIATE_TEST_CASE_P(concat_Concat4D_CPU_Block8inPlace, ConcatLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(concat_Concat4D_CPU_Block8inPlace, ConcatLayerCPUTest, ::testing::Combine( ::testing::Values(1), ::testing::Values(std::vector>{{1, 8, 3, 5}, @@ -106,7 +106,7 @@ INSTANTIATE_TEST_CASE_P(concat_Concat4D_CPU_Block8inPlace, ConcatLayerCPUTest, ::testing::Values(planar_4D, planarChannels_4D, blocked8_4D)), ConcatLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Concat4D_CPU_Block8, ConcatLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Concat4D_CPU_Block8, ConcatLayerCPUTest, ::testing::Combine( ::testing::Values(0, 2, 3), ::testing::Values(std::vector>{{2, 16, 3, 5}, @@ -116,7 +116,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Concat4D_CPU_Block8, ConcatLayerCPUTest, ::testing::Values(planar_4D_ref, planarChannels_4D, blocked8_4D_ref)), ConcatLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Concat4D_CPU_Block16inPlace, ConcatLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Concat4D_CPU_Block16inPlace, ConcatLayerCPUTest, ::testing::Combine( ::testing::Values(1), ::testing::Values(std::vector>{{2, 16, 3, 5}, @@ -126,7 +126,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Concat4D_CPU_Block16inPlace, ConcatLayerCPUTest, ::testing::Values(blocked16_4D)), ConcatLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Concat4D_CPU_Block16, ConcatLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Concat4D_CPU_Block16, ConcatLayerCPUTest, ::testing::Combine( ::testing::Values(0, 2, 3), ::testing::Values(std::vector>{{2, 32, 3, 5}, @@ -136,7 +136,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Concat4D_CPU_Block16, ConcatLayerCPUTest, ::testing::Values(blocked16_4D_ref)), ConcatLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(concat_Concat5D_CPU_Block8inPlace, ConcatLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(concat_Concat5D_CPU_Block8inPlace, ConcatLayerCPUTest, ::testing::Combine( ::testing::Values(1), ::testing::Values(std::vector>{{1, 8, 3, 5, 7}, @@ -146,7 +146,7 @@ INSTANTIATE_TEST_CASE_P(concat_Concat5D_CPU_Block8inPlace, ConcatLayerCPUTest, ::testing::Values(planar_5D, planarChannels_5D, blocked8_5D)), ConcatLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Concat5D_CPU_Block8, ConcatLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_Block8, ConcatLayerCPUTest, ::testing::Combine( ::testing::Values(0, 2, 3, 4), ::testing::Values(std::vector>{{2, 16, 3, 5, 7}, @@ -156,7 +156,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Concat5D_CPU_Block8, ConcatLayerCPUTest, ::testing::Values(planar_5D_ref, planarChannels_5D, blocked8_5D_ref)), ConcatLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Concat5D_CPU_Block16inPlace, ConcatLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_Block16inPlace, ConcatLayerCPUTest, ::testing::Combine( ::testing::Values(1), ::testing::Values(std::vector>{{2, 16, 3, 5, 7}, @@ -166,7 +166,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Concat5D_CPU_Block16inPlace, ConcatLayerCPUTest, ::testing::Values(blocked16_5D)), ConcatLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Concat5D_CPU_Block16, ConcatLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_Block16, ConcatLayerCPUTest, ::testing::Combine( ::testing::Values(0, 2, 3, 4), ::testing::Values(std::vector>{{2, 32, 3, 5, 7}, @@ -177,7 +177,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Concat5D_CPU_Block16, ConcatLayerCPUTest, ConcatLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Concat_inPlace, ConcatLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Concat_inPlace, ConcatLayerCPUTest, ::testing::Combine( ::testing::Values(1), ::testing::Values(std::vector>{{2, 3, 5}, @@ -189,7 +189,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Concat_inPlace, ConcatLayerCPUTest, ::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"})), ConcatLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Concat3D, ConcatLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Concat3D, ConcatLayerCPUTest, ::testing::Combine( ::testing::Values(0, 2), ::testing::Values(std::vector>{{2, 4, 5}, @@ -199,7 +199,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Concat3D, ConcatLayerCPUTest, ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), ConcatLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Concat_1D_2D, ConcatLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Concat_1D_2D, ConcatLayerCPUTest, ::testing::Combine( ::testing::Values(0), ::testing::Values(std::vector>{{2, 4}, diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/convert.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/convert.cpp index e0ef6bfee15ce6..3a8d3a920e20c3 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/convert.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/convert.cpp @@ -33,7 +33,7 @@ const std::vector precisions = { Precision::BF16 }; -INSTANTIATE_TEST_CASE_P(smoke_ConvertLayerTest_From_BF16, ConvertCPULayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvertLayerTest_From_BF16, ConvertCPULayerTest, ::testing::Combine( ::testing::Values(inShape), ::testing::Values(Precision::BF16), @@ -43,7 +43,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ConvertLayerTest_From_BF16, ConvertCPULayerTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvertLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ConvertLayerTest_To_BF16, ConvertCPULayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvertLayerTest_To_BF16, ConvertCPULayerTest, ::testing::Combine( ::testing::Values(inShape), ::testing::ValuesIn(precisions), diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/convert_to_plugin_specific_node.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/convert_to_plugin_specific_node.cpp index a59b7f6fc3b5ce..204cf031f02783 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/convert_to_plugin_specific_node.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/convert_to_plugin_specific_node.cpp @@ -104,7 +104,7 @@ const auto testParamsEltwise = ::testing::Combine(::testing::ValuesIn(nonConstIS ::testing::ValuesIn(port), ::testing::Values(0)); -INSTANTIATE_TEST_CASE_P(smoke_CheckEltwise, ConvertToPluginSpecificNode, testParamsEltwise, ConvertToPluginSpecificNode::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CheckEltwise, ConvertToPluginSpecificNode, testParamsEltwise, ConvertToPluginSpecificNode::getTestCaseName); const auto testParamsPower = ::testing::Combine(::testing::ValuesIn(nonConstIS), ::testing::ValuesIn(constIS), @@ -113,7 +113,7 @@ const auto testParamsPower = ::testing::Combine(::testing::ValuesIn(nonConstIS), ::testing::Values(1), ::testing::Values(0)); -INSTANTIATE_TEST_CASE_P(smoke_CheckPower, ConvertToPluginSpecificNode, testParamsPower, ConvertToPluginSpecificNode::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CheckPower, ConvertToPluginSpecificNode, testParamsPower, ConvertToPluginSpecificNode::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/convolution.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/convolution.cpp index 9be9a270ec701e..b8d447d5a2737f 100755 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/convolution.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/convolution.cpp @@ -220,7 +220,7 @@ const std::vector CPUParams_GEMM_2D = { conv_gemm_2D_nspc }; -INSTANTIATE_TEST_CASE_P(smoke_Conv_2D_GEMM_FP32, ConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_GEMM_FP32, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_GEMM_2D, @@ -236,7 +236,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Conv_2D_GEMM_FP32, ConvolutionLayerCPUTest, ::testing::Values(cpuEmptyPluginConfig)), ConvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Conv_2D_GEMM_BF16, ConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_GEMM_BF16, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_GEMM_2D, @@ -252,7 +252,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Conv_2D_GEMM_BF16, ConvolutionLayerCPUTest, ::testing::Values(cpuBF16PluginConfig)), ConvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Conv_2D_GEMM_I8, ConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_GEMM_I8, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_GEMM_2D, @@ -284,7 +284,7 @@ const std::vector CPUParams_GEMM_3D = { conv_gemm_3D_nspc }; -INSTANTIATE_TEST_CASE_P(smoke_Conv_3D_GEMM_FP32, ConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_GEMM_FP32, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_GEMM_3D, @@ -300,7 +300,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Conv_3D_GEMM_FP32, ConvolutionLayerCPUTest, ::testing::Values(cpuEmptyPluginConfig)), ConvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Conv_3D_GEMM_BF16, ConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_GEMM_BF16, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_GEMM_3D, @@ -316,7 +316,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Conv_3D_GEMM_BF16, ConvolutionLayerCPUTest, ::testing::Values(cpuBF16PluginConfig)), ConvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Conv_3D_GEMM_I8, ConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_GEMM_I8, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_GEMM_3D, @@ -352,7 +352,7 @@ const std::vector CPUParams_2D = { conv_avx512_2D_nspc }; -INSTANTIATE_TEST_CASE_P(smoke_Conv_2D_FP32, ConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_FP32, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_2D, @@ -368,7 +368,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Conv_2D_FP32, ConvolutionLayerCPUTest, ::testing::Values(cpuEmptyPluginConfig)), ConvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Conv_2D_BF16, ConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_BF16, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_2D, @@ -384,7 +384,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Conv_2D_BF16, ConvolutionLayerCPUTest, ::testing::Values(cpuBF16PluginConfig)), ConvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Conv_2D_I8, ConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_I8, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_2D, @@ -406,7 +406,7 @@ const std::vector CPUParams_2D_plain_to_blocked = { conv_avx512_plain_to_blocked_2D, }; -INSTANTIATE_TEST_CASE_P(smoke_Conv_PlainToBlocked_2D_FP32, ConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Conv_PlainToBlocked_2D_FP32, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_2D, @@ -422,7 +422,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Conv_PlainToBlocked_2D_FP32, ConvolutionLayerCPUTe ::testing::Values(cpuEmptyPluginConfig)), ConvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Conv_PlainToBlocked_2D_BF16, ConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Conv_PlainToBlocked_2D_BF16, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_2D, @@ -457,7 +457,7 @@ const std::vector CPUParams_3D = { conv_avx512_3D_nspc }; -INSTANTIATE_TEST_CASE_P(smoke_Conv_3D_FP32, ConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_FP32, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_3D, @@ -473,7 +473,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Conv_3D_FP32, ConvolutionLayerCPUTest, ::testing::Values(cpuEmptyPluginConfig)), ConvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Conv_3D_BF16, ConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_BF16, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_3D, @@ -489,7 +489,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Conv_3D_BF16, ConvolutionLayerCPUTest, ::testing::Values(cpuBF16PluginConfig)), ConvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Conv_3D_I8, ConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_I8, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_3D, @@ -510,7 +510,7 @@ const std::vector CPUParams_3D_plain_to_blocked = { conv_avx512_plain_to_blocked_3D, }; -INSTANTIATE_TEST_CASE_P(smoke_Conv_PlainToBlocked_3D_FP32, ConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Conv_PlainToBlocked_3D_FP32, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_3D, @@ -526,7 +526,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Conv_PlainToBlocked_3D_FP32, ConvolutionLayerCPUTe ::testing::Values(cpuEmptyPluginConfig)), ConvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Conv_PlainToBlocked_3D_BF16, ConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Conv_PlainToBlocked_3D_BF16, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_3D, @@ -563,7 +563,7 @@ const std::vector CPUParams_1x1_2D = { conv_avx512_2D_1x1_nspc }; -INSTANTIATE_TEST_CASE_P(smoke_Conv_2D_1x1_FP32, ConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_1x1_FP32, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_1x1_2D, @@ -579,7 +579,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Conv_2D_1x1_FP32, ConvolutionLayerCPUTest, ::testing::Values(cpuEmptyPluginConfig)), ConvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Conv_2D_1x1_BF16, ConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_1x1_BF16, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_1x1_2D, @@ -595,7 +595,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Conv_2D_1x1_BF16, ConvolutionLayerCPUTest, ::testing::Values(cpuBF16PluginConfig)), ConvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Conv_2D_1x1_I8, ConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_1x1_I8, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_1x1_2D, @@ -635,7 +635,7 @@ const std::vector CPUParams_1D = { conv_avx512_1D }; -INSTANTIATE_TEST_CASE_P(smoke_Conv_1D, ConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_1D, @@ -670,7 +670,7 @@ const auto convParams_Planar_ExplicitPadding_2D = ::testing::Combine( ::testing::Values(ngraph::op::PadType::EXPLICIT) ); -INSTANTIATE_TEST_CASE_P(smoke_Conv_Jit_Planar_2D_FP32, ConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Conv_Jit_Planar_2D_FP32, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_Planar_ExplicitPadding_2D, @@ -703,7 +703,7 @@ const auto convParams_Planar_ExplicitPadding_3D = ::testing::Combine( ::testing::Values(ngraph::op::PadType::EXPLICIT) ); -INSTANTIATE_TEST_CASE_P(smoke_Conv_Jit_Planar_3D_FP32, ConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Conv_Jit_Planar_3D_FP32, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_Planar_ExplicitPadding_3D, @@ -752,7 +752,7 @@ const auto convParams_2D = ::testing::Combine( ::testing::Values(ngraph::op::PadType::EXPLICIT) ); -INSTANTIATE_TEST_CASE_P(smoke_Conv_winograd, ConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Conv_winograd, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_2D, diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/convolution_backprop_data.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/convolution_backprop_data.cpp index f1d144f666ebf9..69544f12e1f665 100755 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/convolution_backprop_data.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/convolution_backprop_data.cpp @@ -152,7 +152,7 @@ const auto convParams_ExplicitPadding_Planar_2D = ::testing::Combine( ::testing::ValuesIn(emptyOutputPadding) ); -INSTANTIATE_TEST_CASE_P(smoke_Deconv_2D_Planar_FP32, DeconvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Deconv_2D_Planar_FP32, DeconvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_Planar_2D, @@ -169,7 +169,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Deconv_2D_Planar_FP32, DeconvolutionLayerCPUTest, ::testing::Values(cpuEmptyPluginConfig)), DeconvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Deconv_2D_Planar_BF16, DeconvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Deconv_2D_Planar_BF16, DeconvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_Planar_2D, @@ -198,7 +198,7 @@ const auto convParams_ExplicitPadding_Planar_3D = ::testing::Combine( ::testing::ValuesIn(emptyOutputPadding) ); -INSTANTIATE_TEST_CASE_P(smoke_Deconv_3D_Planar_FP32, DeconvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Deconv_3D_Planar_FP32, DeconvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_Planar_3D, @@ -215,7 +215,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Deconv_3D_Planar_FP32, DeconvolutionLayerCPUTest, ::testing::Values(cpuEmptyPluginConfig)), DeconvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Deconv_3D_Planar_BF16, DeconvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Deconv_3D_Planar_BF16, DeconvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_Planar_3D, @@ -244,7 +244,7 @@ const auto convParams_ExplicitPadding_Blocked_2D = ::testing::Combine( ::testing::ValuesIn(emptyOutputPadding) ); -INSTANTIATE_TEST_CASE_P(smoke_Deconv_2D_Blocked_FP32, DeconvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Deconv_2D_Blocked_FP32, DeconvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_Blocked_2D, @@ -261,7 +261,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Deconv_2D_Blocked_FP32, DeconvolutionLayerCPUTest, ::testing::Values(cpuEmptyPluginConfig)), DeconvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Deconv_2D_Blocked_BF16, DeconvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Deconv_2D_Blocked_BF16, DeconvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_Blocked_2D, @@ -290,7 +290,7 @@ const auto convParams_ExplicitPadding_Blocked_3D = ::testing::Combine( ::testing::ValuesIn(emptyOutputPadding) ); -INSTANTIATE_TEST_CASE_P(smoke_Deconv_3D_Blocked_FP32, DeconvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Deconv_3D_Blocked_FP32, DeconvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_Blocked_3D, @@ -307,7 +307,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Deconv_3D_Blocked_FP32, DeconvolutionLayerCPUTest, ::testing::Values(cpuEmptyPluginConfig)), DeconvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Deconv_3D_Blocked_BF16, DeconvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Deconv_3D_Blocked_BF16, DeconvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_Blocked_3D, @@ -337,7 +337,7 @@ const auto convParams_ExplicitPadding_1x1_2D = ::testing::Combine( ::testing::ValuesIn(emptyOutputPadding) ); -INSTANTIATE_TEST_CASE_P(smoke_Deconv_2D_1x1_FP32, DeconvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Deconv_2D_1x1_FP32, DeconvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_1x1_2D, @@ -354,7 +354,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Deconv_2D_1x1_FP32, DeconvolutionLayerCPUTest, ::testing::Values(cpuEmptyPluginConfig)), DeconvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Deconv_2D_1x1_BF16, DeconvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Deconv_2D_1x1_BF16, DeconvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_ExplicitPadding_1x1_2D, diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/depth_to_space.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/depth_to_space.cpp index 8588d9d2658632..a5e54532001ca5 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/depth_to_space.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/depth_to_space.cpp @@ -124,7 +124,7 @@ const auto depthToSpaceBS2_4DParams = testing::Combine( testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBS2_4D)) ); -INSTANTIATE_TEST_CASE_P(smoke_CPUDepthToSpaceBS2_4D, DepthToSpaceLayerCPUTest, depthToSpaceBS2_4DParams, DepthToSpaceLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CPUDepthToSpaceBS2_4D, DepthToSpaceLayerCPUTest, depthToSpaceBS2_4DParams, DepthToSpaceLayerCPUTest::getTestCaseName); const std::vector CPUParamsBS3_4D = { cpuParams_nhwc_avx2, @@ -142,7 +142,7 @@ const auto depthToSpaceBS3_4DParams = testing::Combine( ::testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBS3_4D)) ); -INSTANTIATE_TEST_CASE_P(smoke_CPUDepthToSpaceBS3_4D, DepthToSpaceLayerCPUTest, depthToSpaceBS3_4DParams, DepthToSpaceLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CPUDepthToSpaceBS3_4D, DepthToSpaceLayerCPUTest, depthToSpaceBS3_4DParams, DepthToSpaceLayerCPUTest::getTestCaseName); const std::vector> inputShapesBS2_5D = { {1, 128, 1, 1, 1}, {1, 128, 2, 1, 2}, {1, 256, 2, 1, 3}, {2, 256, 3, 1, 1}, {1, 384, 1, 2, 2}, {2, 512, 1, 2, 1} @@ -171,7 +171,7 @@ const auto depthToSpaceBS2_5DParams = testing::Combine( ::testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBS2_5D)) ); -INSTANTIATE_TEST_CASE_P(smoke_CPUDepthToSpaceBS2_5D, DepthToSpaceLayerCPUTest, depthToSpaceBS2_5DParams, DepthToSpaceLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CPUDepthToSpaceBS2_5D, DepthToSpaceLayerCPUTest, depthToSpaceBS2_5DParams, DepthToSpaceLayerCPUTest::getTestCaseName); const std::vector CPUParamsBS3_5D = { cpuParams_ndhwc_avx2, @@ -189,7 +189,7 @@ const auto depthToSpaceBS3_5DParams = testing::Combine( ::testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBS3_5D)) ); -INSTANTIATE_TEST_CASE_P(smoke_CPUDepthToSpaceBS3_5D, DepthToSpaceLayerCPUTest, depthToSpaceBS3_5DParams, DepthToSpaceLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CPUDepthToSpaceBS3_5D, DepthToSpaceLayerCPUTest, depthToSpaceBS3_5DParams, DepthToSpaceLayerCPUTest::getTestCaseName); } // namespace } // namespace CPULayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/eltwise.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/eltwise.cpp index 0deb0efc300965..3932b9349bb212 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/eltwise.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/eltwise.cpp @@ -167,7 +167,7 @@ const auto params_4D = ::testing::Combine( ::testing::Values(additional_config)), ::testing::ValuesIn(filterCPUSpecificParams(cpuParams_4D))); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs_4D_MemOrder, EltwiseLayerCPUTest, params_4D, EltwiseLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_MemOrder, EltwiseLayerCPUTest, params_4D, EltwiseLayerCPUTest::getTestCaseName); const auto params_4D_emptyCPUSpec = ::testing::Combine( ::testing::Combine( @@ -183,7 +183,7 @@ const auto params_4D_emptyCPUSpec = ::testing::Combine( ::testing::Values(additional_config)), ::testing::Values(emptyCPUSpec)); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs_4D_emptyCPUSpec, EltwiseLayerCPUTest, params_4D_emptyCPUSpec, EltwiseLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_emptyCPUSpec, EltwiseLayerCPUTest, params_4D_emptyCPUSpec, EltwiseLayerCPUTest::getTestCaseName); std::vector>> inShapes_5D = { {{2, 4, 3, 4, 1}}, @@ -212,7 +212,7 @@ const auto params_5D = ::testing::Combine( ::testing::Values(additional_config)), ::testing::ValuesIn(filterCPUSpecificParams(cpuParams_5D))); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs_5D_MemOrder, EltwiseLayerCPUTest, params_5D, EltwiseLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_5D_MemOrder, EltwiseLayerCPUTest, params_5D, EltwiseLayerCPUTest::getTestCaseName); const auto params_5D_emptyCPUSpec = ::testing::Combine( ::testing::Combine( @@ -228,7 +228,7 @@ const auto params_5D_emptyCPUSpec = ::testing::Combine( ::testing::Values(additional_config)), ::testing::Values(emptyCPUSpec)); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs_5D, EltwiseLayerCPUTest, params_5D_emptyCPUSpec, EltwiseLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_5D, EltwiseLayerCPUTest, params_5D_emptyCPUSpec, EltwiseLayerCPUTest::getTestCaseName); std::vector>> inShapes_4D_Blocked_Planar = { {{2, 17, 31, 3}, {2, 1, 31, 3}}, @@ -253,7 +253,7 @@ const auto params_4D_Blocked_Planar = ::testing::Combine( ::testing::Values(additional_config)), ::testing::ValuesIn(filterCPUSpecificParams(cpuParams_4D_Blocked_Planar))); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs_4D_Blocked_Planar, EltwiseLayerCPUTest, params_4D_Blocked_Planar, EltwiseLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_Blocked_Planar, EltwiseLayerCPUTest, params_4D_Blocked_Planar, EltwiseLayerCPUTest::getTestCaseName); std::vector>> inShapes_4D_Planar_Blocked = { @@ -279,7 +279,7 @@ const auto params_4D_Planar_Blocked = ::testing::Combine( ::testing::Values(additional_config)), ::testing::ValuesIn(filterCPUSpecificParams(cpuParams_4D_Planar_Blocked))); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs_4D_Planar_Blocked, EltwiseLayerCPUTest, params_4D_Planar_Blocked, EltwiseLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_Planar_Blocked, EltwiseLayerCPUTest, params_4D_Planar_Blocked, EltwiseLayerCPUTest::getTestCaseName); std::vector>> inShapes_5D_Blocked_Planar = { @@ -305,7 +305,7 @@ const auto params_5D_Blocked_Planar = ::testing::Combine( ::testing::Values(additional_config)), ::testing::ValuesIn(filterCPUSpecificParams(cpuParams_5D_Blocked_Planar))); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs_5D_Blocked_Planar, EltwiseLayerCPUTest, params_5D_Blocked_Planar, EltwiseLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_5D_Blocked_Planar, EltwiseLayerCPUTest, params_5D_Blocked_Planar, EltwiseLayerCPUTest::getTestCaseName); std::vector>> inShapes_5D_Planar_Blocked = { @@ -331,7 +331,7 @@ const auto params_5D_Planar_Blocked = ::testing::Combine( ::testing::Values(additional_config)), ::testing::ValuesIn(filterCPUSpecificParams(cpuParams_5D_Planar_Blocked))); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs_5D_Planar_Blocked, EltwiseLayerCPUTest, params_5D_Planar_Blocked, EltwiseLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_5D_Planar_Blocked, EltwiseLayerCPUTest, params_5D_Planar_Blocked, EltwiseLayerCPUTest::getTestCaseName); std::vector>> inShapes_4D_1D = { @@ -359,7 +359,7 @@ const auto params_4D_1D = ::testing::Combine( ::testing::Values(additional_config)), ::testing::ValuesIn(filterCPUSpecificParams(cpuParams_4D_1D))); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs_4D_1D, EltwiseLayerCPUTest, params_4D_1D, EltwiseLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_1D, EltwiseLayerCPUTest, params_4D_1D, EltwiseLayerCPUTest::getTestCaseName); std::vector>> inShapes_5D_1D = { {{2, 17, 5, 4, 10}, {10}}, @@ -386,7 +386,7 @@ const auto params_5D_1D = ::testing::Combine( ::testing::Values(additional_config)), ::testing::ValuesIn(filterCPUSpecificParams(cpuParams_5D_1D))); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs_5D_1D, EltwiseLayerCPUTest, params_5D_1D, EltwiseLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_5D_1D, EltwiseLayerCPUTest, params_5D_1D, EltwiseLayerCPUTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/extract_image_patches.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/extract_image_patches.cpp index 028cd9118d8c3d..20edee2aad70d4 100755 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/extract_image_patches.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/extract_image_patches.cpp @@ -84,7 +84,7 @@ const auto Layer_params = ::testing::Combine( ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(CommonTestUtils::DEVICE_CPU)); -INSTANTIATE_TEST_CASE_P(smoke_ExtractImagePatches_CPU, ExtractImagePatchesLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_ExtractImagePatches_CPU, ExtractImagePatchesLayerCPUTest, ::testing::Combine(Layer_params, ::testing::Values(CPUParams)), ExtractImagePatchesLayerCPUTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/fake_quantize.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/fake_quantize.cpp index a5832b40835d49..09bc5f27a62195 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/fake_quantize.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/fake_quantize.cpp @@ -174,7 +174,7 @@ const auto testParams4D_jit = ::testing::Combine(specificParams4D_jit, ::testing::ValuesIn(input_ranges), ::testing::Values(false), ::testing::ValuesIn(filterCPUSpecificParams(memForm4D_jit))); -INSTANTIATE_TEST_CASE_P(smoke_FakeQuantizeLayerCPUTest_4D_jit, FakeQuantizeLayerCPUTest, testParams4D_jit, FakeQuantizeLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_4D_jit, FakeQuantizeLayerCPUTest, testParams4D_jit, FakeQuantizeLayerCPUTest::getTestCaseName); std::vector memForm4D_ref = { @@ -197,7 +197,7 @@ const auto testParams4D_ref = ::testing::Combine(specificParams4D_ref, ::testing::ValuesIn(input_ranges), ::testing::Values(false), ::testing::ValuesIn(memForm4D_ref)); -INSTANTIATE_TEST_CASE_P(smoke_FakeQuantizeLayerCPUTest_4D_ref, FakeQuantizeLayerCPUTest, testParams4D_ref, FakeQuantizeLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_4D_ref, FakeQuantizeLayerCPUTest, testParams4D_ref, FakeQuantizeLayerCPUTest::getTestCaseName); std::vector memForm5D_jit = { @@ -224,7 +224,7 @@ const auto testParams5D_jit = ::testing::Combine(specificParams5D_jit, ::testing::Values(false), ::testing::ValuesIn(filterCPUSpecificParams(memForm5D_jit))); -INSTANTIATE_TEST_CASE_P(smoke_FakeQuantizeLayerCPUTest_5D_jit, FakeQuantizeLayerCPUTest, testParams5D_jit, FakeQuantizeLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_5D_jit, FakeQuantizeLayerCPUTest, testParams5D_jit, FakeQuantizeLayerCPUTest::getTestCaseName); std::vector memForm5D_ref = { @@ -248,7 +248,7 @@ const auto testParams5D_ref = ::testing::Combine(specificParams5D_ref, ::testing::Values(false), ::testing::ValuesIn(memForm5D_ref)); -INSTANTIATE_TEST_CASE_P(smoke_FakeQuantizeLayerCPUTest_5D_ref, FakeQuantizeLayerCPUTest, testParams5D_ref, FakeQuantizeLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_5D_ref, FakeQuantizeLayerCPUTest, testParams5D_ref, FakeQuantizeLayerCPUTest::getTestCaseName); } // namespace fqImpl @@ -281,7 +281,7 @@ const auto testParams = ::testing::Combine(specificParams, ::testing::Values(true), ::testing::Values(CPUSpecificParams{})); -INSTANTIATE_TEST_CASE_P(smoke_FakeQuantizeLayerCPUTest_Decompos, FakeQuantizeLayerCPUTest, testParams, FakeQuantizeLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_Decompos, FakeQuantizeLayerCPUTest, testParams, FakeQuantizeLayerCPUTest::getTestCaseName); } // namespace fqDecompos diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/gather_elements.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/gather_elements.cpp index 7ea6cb505bac1c..32b6b04ad69072 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/gather_elements.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/gather_elements.cpp @@ -76,7 +76,7 @@ std::vector cpuParams_4D = { CPUSpecificParams({nchw}, {nchw}, {}, {}) }; -INSTANTIATE_TEST_CASE_P(smoke_set1, GatherElementsCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_set1, GatherElementsCPUTest, ::testing::Combine( ::testing::Combine( ::testing::Values(std::vector({2, 3, 5, 7})), // Data shape diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/group_convolution.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/group_convolution.cpp index 5e18a0f3ba099a..1f75554b1b49ea 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/group_convolution.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/group_convolution.cpp @@ -218,7 +218,7 @@ const std::vector CPUParams_Gemm_2D = { conv_gemm_2D_nspc }; -INSTANTIATE_TEST_CASE_P(smoke_GroupConv_2D_Gemm_FP32, GroupConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConv_2D_Gemm_FP32, GroupConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( groupConvParams_ExplicitPadding_Gemm_2D, @@ -233,7 +233,7 @@ INSTANTIATE_TEST_CASE_P(smoke_GroupConv_2D_Gemm_FP32, GroupConvolutionLayerCPUTe ::testing::ValuesIn(fusingParamsSet)), GroupConvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_GroupConv_2D_Gemm_BF16, GroupConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConv_2D_Gemm_BF16, GroupConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( groupConvParams_ExplicitPadding_Gemm_2D, @@ -265,7 +265,7 @@ const std::vector CPUParams_Gemm_3D = { conv_gemm_3D_nspc }; -INSTANTIATE_TEST_CASE_P(smoke_GroupConv_3D_Gemm_FP32, GroupConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConv_3D_Gemm_FP32, GroupConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( groupConvParams_ExplicitPadding_Gemm_3D, @@ -280,7 +280,7 @@ INSTANTIATE_TEST_CASE_P(smoke_GroupConv_3D_Gemm_FP32, GroupConvolutionLayerCPUTe ::testing::ValuesIn(fusingParamsSet)), GroupConvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_GroupConv_3D_Gemm_BF16, GroupConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConv_3D_Gemm_BF16, GroupConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( groupConvParams_ExplicitPadding_Gemm_3D, @@ -316,7 +316,7 @@ const std::vector CPUParams_2D = { conv_avx512_2D_nspc }; -INSTANTIATE_TEST_CASE_P(smoke_GroupConv_2D_FP32, GroupConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConv_2D_FP32, GroupConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( groupConvParams_ExplicitPadding_2D, @@ -331,7 +331,7 @@ INSTANTIATE_TEST_CASE_P(smoke_GroupConv_2D_FP32, GroupConvolutionLayerCPUTest, ::testing::ValuesIn(fusingParamsSet)), GroupConvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_GroupConv_2D_BF16, GroupConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConv_2D_BF16, GroupConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( groupConvParams_ExplicitPadding_2D, @@ -366,7 +366,7 @@ const std::vector CPUParams_3D = { conv_avx512_3D_nspc }; -INSTANTIATE_TEST_CASE_P(smoke_GroupConv_3D_FP32, GroupConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConv_3D_FP32, GroupConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( groupConvParams_ExplicitPadding_3D, @@ -381,7 +381,7 @@ INSTANTIATE_TEST_CASE_P(smoke_GroupConv_3D_FP32, GroupConvolutionLayerCPUTest, ::testing::ValuesIn(fusingParamsSet)), GroupConvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_GroupConv_3D_BF16, GroupConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConv_3D_BF16, GroupConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( groupConvParams_ExplicitPadding_3D, @@ -417,7 +417,7 @@ const std::vector CPUParams_DW_2D = { conv_avx512_dw_2D_nspc }; -INSTANTIATE_TEST_CASE_P(smoke_GroupConv_2D_DW_FP32, GroupConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConv_2D_DW_FP32, GroupConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( groupConvParams_ExplicitPadding_DW_2D, @@ -433,7 +433,7 @@ INSTANTIATE_TEST_CASE_P(smoke_GroupConv_2D_DW_FP32, GroupConvolutionLayerCPUTest GroupConvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_GroupConv_2D_DW_BF16, GroupConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConv_2D_DW_BF16, GroupConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( groupConvParams_ExplicitPadding_DW_2D, @@ -469,7 +469,7 @@ const std::vector CPUParams_DW_3D = { conv_avx512_dw_3D_nspc }; -INSTANTIATE_TEST_CASE_P(smoke_GroupConv_3D_DW_FP32, GroupConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConv_3D_DW_FP32, GroupConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( groupConvParams_ExplicitPadding_DW_3D, @@ -586,7 +586,7 @@ const std::vector gemmGroupConvTestCases = gener 2, 1, {10, 10, 10}, 3, 3, CPUParams_Gemm_3D, vecPrcConnectParams) ); -INSTANTIATE_TEST_CASE_P(smoke_GEMM_GroupConv, GroupConvolutionLayerCPUTest, ::testing::ValuesIn(filterParamsSetForDevice(gemmGroupConvTestCases)), +INSTANTIATE_TEST_SUITE_P(smoke_GEMM_GroupConv, GroupConvolutionLayerCPUTest, ::testing::ValuesIn(filterParamsSetForDevice(gemmGroupConvTestCases)), GroupConvolutionLayerCPUTest::getTestCaseName); /* ============= JIT SSE42 GroupConvolution ============= */ @@ -637,7 +637,7 @@ const std::vector JIT_SSE42_GroupConvTestCases = // 2, 1, {10, 10, 10}, 8, 8, cpuParams_sse42_3D), ); -INSTANTIATE_TEST_CASE_P(smoke_JIT_SSE42_GroupConv, GroupConvolutionLayerCPUTest, ::testing::ValuesIn(filterParamsSetForDevice(JIT_SSE42_GroupConvTestCases)), +INSTANTIATE_TEST_SUITE_P(smoke_JIT_SSE42_GroupConv, GroupConvolutionLayerCPUTest, ::testing::ValuesIn(filterParamsSetForDevice(JIT_SSE42_GroupConvTestCases)), GroupConvolutionLayerCPUTest::getTestCaseName); /* ============= JIT AVX2 GroupConvolution ============= */ @@ -687,7 +687,7 @@ const std::vector JIT_AVX2_GroupConvTestCases = 2, 1, {10, 10, 10}, 8, 8, avx2_GroupConv_3D, vecPrcConnectParamsFP32) ); -INSTANTIATE_TEST_CASE_P(smoke_JIT_AVX2_GroupConv, GroupConvolutionLayerCPUTest, ::testing::ValuesIn(filterParamsSetForDevice(JIT_AVX2_GroupConvTestCases)), +INSTANTIATE_TEST_SUITE_P(smoke_JIT_AVX2_GroupConv, GroupConvolutionLayerCPUTest, ::testing::ValuesIn(filterParamsSetForDevice(JIT_AVX2_GroupConvTestCases)), GroupConvolutionLayerCPUTest::getTestCaseName); /* ============= JIT AVX512 GroupConvolution ============= */ @@ -718,7 +718,7 @@ const std::vector JIT_AVX512_GroupConvTestCases 2, 1, {10, 10, 10}, 16, 16, avx512_GroupConv_3D, vecPrcConnectParams) ); -INSTANTIATE_TEST_CASE_P(smoke_JIT_AVX512_GroupConv, GroupConvolutionLayerCPUTest, ::testing::ValuesIn(filterParamsSetForDevice(JIT_AVX512_GroupConvTestCases)), +INSTANTIATE_TEST_SUITE_P(smoke_JIT_AVX512_GroupConv, GroupConvolutionLayerCPUTest, ::testing::ValuesIn(filterParamsSetForDevice(JIT_AVX512_GroupConvTestCases)), GroupConvolutionLayerCPUTest::getTestCaseName); /* ============= JIT SSE42 DW GroupConvolution ============= */ @@ -754,7 +754,7 @@ const std::vector JIT_SSE42_DW_GroupConvTestCase 8, 1, {10, 10, 10}, 1, 1, sse42_DW_3D, vecPrcConnectParamsFP32) ); -INSTANTIATE_TEST_CASE_P(smoke_JIT_SSE42_DW_GroupConv, GroupConvolutionLayerCPUTest, ::testing::ValuesIn(filterParamsSetForDevice +INSTANTIATE_TEST_SUITE_P(smoke_JIT_SSE42_DW_GroupConv, GroupConvolutionLayerCPUTest, ::testing::ValuesIn(filterParamsSetForDevice (JIT_SSE42_DW_GroupConvTestCases)), GroupConvolutionLayerCPUTest::getTestCaseName); /* ============= JIT AVX2 DW GroupConvolution ============= */ @@ -790,7 +790,7 @@ const std::vector JIT_AVX2_DW_GroupConvTestCases 8, 1, {10, 10, 10}, 1, 1, avx2_DW_3D, vecPrcConnectParamsFP32) ); -INSTANTIATE_TEST_CASE_P(smoke_JIT_AVX2_DW_GroupConv, GroupConvolutionLayerCPUTest, ::testing::ValuesIn(filterParamsSetForDevice +INSTANTIATE_TEST_SUITE_P(smoke_JIT_AVX2_DW_GroupConv, GroupConvolutionLayerCPUTest, ::testing::ValuesIn(filterParamsSetForDevice (JIT_AVX2_DW_GroupConvTestCases)), GroupConvolutionLayerCPUTest::getTestCaseName); /* ============= JIT AVX512 DW GroupConvolution ============= */ @@ -825,7 +825,7 @@ const std::vector JIT_AVX512_DW_GroupConvTestCas 16, 1, {10, 10, 10}, 1, 1, avx512_DW_3D, vecPrcConnectParams) ); -INSTANTIATE_TEST_CASE_P(smoke_JIT_AVX512_DW_GroupConv, GroupConvolutionLayerCPUTest, ::testing::ValuesIn(filterParamsSetForDevice +INSTANTIATE_TEST_SUITE_P(smoke_JIT_AVX512_DW_GroupConv, GroupConvolutionLayerCPUTest, ::testing::ValuesIn(filterParamsSetForDevice (JIT_AVX512_DW_GroupConvTestCases)), GroupConvolutionLayerCPUTest::getTestCaseName); /* ============= JIT SSE42 1x1 Convolution (not supported with groups) ============= */ @@ -860,7 +860,7 @@ const std::vector CPUParams_1D = { conv_avx512_1D }; -INSTANTIATE_TEST_CASE_P(smoke_GroupConv_1D, GroupConvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConv_1D, GroupConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( convParams_1D, diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/group_convolution_backprop_data.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/group_convolution_backprop_data.cpp index 8645f0e21be869..8ceff946d147d1 100755 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/group_convolution_backprop_data.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/group_convolution_backprop_data.cpp @@ -169,7 +169,7 @@ const auto groupConvParams_ExplicitPadding_Planar_2D = ::testing::Combine( ::testing::Values(ngraph::op::PadType::EXPLICIT) ); -INSTANTIATE_TEST_CASE_P(smoke_GroupDeconv_2D_Planar_FP32, GroupDeconvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupDeconv_2D_Planar_FP32, GroupDeconvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( groupConvParams_ExplicitPadding_Planar_2D, @@ -185,7 +185,7 @@ INSTANTIATE_TEST_CASE_P(smoke_GroupDeconv_2D_Planar_FP32, GroupDeconvolutionLaye ::testing::Values(cpuEmptyPluginConfig)), GroupDeconvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_GroupDeconv_2D_Planar_BF16, GroupDeconvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupDeconv_2D_Planar_BF16, GroupDeconvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( groupConvParams_ExplicitPadding_Planar_2D, @@ -213,7 +213,7 @@ const auto groupConvParams_ExplicitPadding_Planar_3D = ::testing::Combine( ::testing::Values(ngraph::op::PadType::EXPLICIT) ); -INSTANTIATE_TEST_CASE_P(smoke_GroupDeconv_3D_Planar_FP32, GroupDeconvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupDeconv_3D_Planar_FP32, GroupDeconvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( groupConvParams_ExplicitPadding_Planar_3D, @@ -229,7 +229,7 @@ INSTANTIATE_TEST_CASE_P(smoke_GroupDeconv_3D_Planar_FP32, GroupDeconvolutionLaye ::testing::Values(cpuEmptyPluginConfig)), GroupDeconvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_GroupDeconv_3D_Planar_BF16, GroupDeconvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupDeconv_3D_Planar_BF16, GroupDeconvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( groupConvParams_ExplicitPadding_Planar_3D, @@ -257,7 +257,7 @@ const auto groupConvParams_ExplicitPadding_Blocked_2D = ::testing::Combine( ::testing::Values(ngraph::op::PadType::EXPLICIT) ); -INSTANTIATE_TEST_CASE_P(smoke_GroupDeconv_2D_Blocked_FP32, GroupDeconvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupDeconv_2D_Blocked_FP32, GroupDeconvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( groupConvParams_ExplicitPadding_Blocked_2D, @@ -273,7 +273,7 @@ INSTANTIATE_TEST_CASE_P(smoke_GroupDeconv_2D_Blocked_FP32, GroupDeconvolutionLay ::testing::Values(cpuEmptyPluginConfig)), GroupDeconvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_GroupDeconv_2D_Blocked_BF16, GroupDeconvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupDeconv_2D_Blocked_BF16, GroupDeconvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( groupConvParams_ExplicitPadding_Blocked_2D, @@ -301,7 +301,7 @@ const auto groupConvParams_ExplicitPadding_Blocked_3D = ::testing::Combine( ::testing::Values(ngraph::op::PadType::EXPLICIT) ); -INSTANTIATE_TEST_CASE_P(smoke_GroupDeconv_3D_Blocked_FP32, GroupDeconvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupDeconv_3D_Blocked_FP32, GroupDeconvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( groupConvParams_ExplicitPadding_Blocked_3D, @@ -317,7 +317,7 @@ INSTANTIATE_TEST_CASE_P(smoke_GroupDeconv_3D_Blocked_FP32, GroupDeconvolutionLay ::testing::Values(cpuEmptyPluginConfig)), GroupDeconvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_GroupDeconv_3D_Blocked_BF16, GroupDeconvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupDeconv_3D_Blocked_BF16, GroupDeconvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( groupConvParams_ExplicitPadding_Blocked_3D, @@ -345,7 +345,7 @@ const auto groupConvParams_ExplicitPadding_DW_2D = ::testing::Combine( ::testing::Values(ngraph::op::PadType::EXPLICIT) ); -INSTANTIATE_TEST_CASE_P(smoke_GroupDeconv_2D_DW_FP32, GroupDeconvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupDeconv_2D_DW_FP32, GroupDeconvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( groupConvParams_ExplicitPadding_DW_2D, @@ -361,7 +361,7 @@ INSTANTIATE_TEST_CASE_P(smoke_GroupDeconv_2D_DW_FP32, GroupDeconvolutionLayerCPU ::testing::Values(cpuEmptyPluginConfig)), GroupDeconvolutionLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_GroupDeconv_2D_DW_BF16, GroupDeconvolutionLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupDeconv_2D_DW_BF16, GroupDeconvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( groupConvParams_ExplicitPadding_DW_2D, diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/gru_cell.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/gru_cell.cpp index 6f58eeda2f42e0..1e5a3602765a16 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/gru_cell.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/gru_cell.cpp @@ -117,7 +117,7 @@ std::vector clip = {0.f}; std::vector linear_before_reset = {true, false}; std::vector netPrecisions = {InferenceEngine::Precision::FP32}; -INSTANTIATE_TEST_CASE_P(smoke_GRUCellCPU, +INSTANTIATE_TEST_SUITE_P(smoke_GRUCellCPU, GRUCellCPUTest, ::testing::Combine(::testing::Combine(::testing::ValuesIn(should_decompose), ::testing::ValuesIn(batch), diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/gru_sequence.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/gru_sequence.cpp index 55ece3f0a663be..799f7516887429 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/gru_sequence.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/gru_sequence.cpp @@ -186,7 +186,7 @@ std::vector direction = {ngraph::op::Rec std::vector netPrecisions = {InferenceEngine::Precision::FP32}; -INSTANTIATE_TEST_CASE_P(smoke_GRUSequenceCPU, +INSTANTIATE_TEST_SUITE_P(smoke_GRUSequenceCPU, GRUSequenceCPUTest, ::testing::Combine(::testing::Combine(::testing::ValuesIn(mode), ::testing::ValuesIn(seq_lengths_zero_clip), @@ -202,7 +202,7 @@ INSTANTIATE_TEST_CASE_P(smoke_GRUSequenceCPU, ::testing::ValuesIn(additionalConfig)), GRUSequenceCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_GRUSequenceCPUBatchSizeOne, +INSTANTIATE_TEST_SUITE_P(smoke_GRUSequenceCPUBatchSizeOne, GRUSequenceCPUTest, ::testing::Combine(::testing::Combine(::testing::ValuesIn(mode), ::testing::ValuesIn(seq_lengths_zero_clip), diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/interpolate.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/interpolate.cpp index 55863095e75acb..05783b6b122096 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/interpolate.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/interpolate.cpp @@ -260,7 +260,7 @@ std::vector> filterAdditionalConfig() { } } -INSTANTIATE_TEST_CASE_P(smoke_InterpolateNN_Layout_Test, InterpolateLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_InterpolateNN_Layout_Test, InterpolateLayerCPUTest, ::testing::Combine( ::testing::Combine( interpolateCasesNN, @@ -278,7 +278,7 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateNN_Layout_Test, InterpolateLayerCPUTest ::testing::ValuesIn(filterAdditionalConfig())), InterpolateLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_InterpolateLinearOnnx_Layout_Test, InterpolateLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_InterpolateLinearOnnx_Layout_Test, InterpolateLayerCPUTest, ::testing::Combine( ::testing::Combine( interpolateCasesLinearOnnx, @@ -296,7 +296,7 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateLinearOnnx_Layout_Test, InterpolateLaye ::testing::ValuesIn(filterAdditionalConfig())), InterpolateLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_InterpolateLinear_Layout_Test, InterpolateLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_InterpolateLinear_Layout_Test, InterpolateLayerCPUTest, ::testing::Combine( ::testing::Combine( interpolateCasesLinear, @@ -314,7 +314,7 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateLinear_Layout_Test, InterpolateLayerCPU ::testing::ValuesIn(filterAdditionalConfig())), InterpolateLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_InterpolateCubic_Layout_Test, InterpolateLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_InterpolateCubic_Layout_Test, InterpolateLayerCPUTest, ::testing::Combine( ::testing::Combine( interpolateCasesCubic, @@ -387,7 +387,7 @@ const auto interpolateCasesNN5D = ::testing::Combine( ::testing::ValuesIn(defaultAxes5D), ::testing::ValuesIn(defaultScales5D)); -INSTANTIATE_TEST_CASE_P(smoke_InterpolateLinearOnnx5D_Layout_Test, InterpolateLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_InterpolateLinearOnnx5D_Layout_Test, InterpolateLayerCPUTest, ::testing::Combine( ::testing::Combine( interpolateCasesLinearOnnx5D, @@ -405,7 +405,7 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateLinearOnnx5D_Layout_Test, InterpolateLa ::testing::ValuesIn(filterAdditionalConfig())), InterpolateLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_InterpolateNN5D_Layout_Test, InterpolateLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_InterpolateNN5D_Layout_Test, InterpolateLayerCPUTest, ::testing::Combine( ::testing::Combine( interpolateCasesNN5D, diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/logical.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/logical.cpp index 6e423ca669f855..d9bcddab858e16 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/logical.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/logical.cpp @@ -150,9 +150,9 @@ const auto LogicalTestParamsNot = ::testing::Combine( ::testing::Values(emptyCPUSpec)); -INSTANTIATE_TEST_CASE_P(smoke_Logical_Eltwise_CPU_BF16, LogicalLayerCPUTest, LogicalTestParams, LogicalLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Logical_Eltwise_CPU_BF16, LogicalLayerCPUTest, LogicalTestParams, LogicalLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Logical_Not_Eltwise_CPU_BF16, LogicalLayerCPUTest, LogicalTestParamsNot, LogicalLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Logical_Not_Eltwise_CPU_BF16, LogicalLayerCPUTest, LogicalTestParamsNot, LogicalLayerCPUTest::getTestCaseName); } // namespace } // namespace CPULayerTestsDefinitions \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/lstm_cell.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/lstm_cell.cpp index 4ee12f62ea9353..32ab7da1004790 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/lstm_cell.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/lstm_cell.cpp @@ -115,7 +115,7 @@ std::vector> activations = {{"sigmoid", "tanh", "tanh"} std::vector clip{0.f}; std::vector netPrecisions = {InferenceEngine::Precision::FP32, InferenceEngine::Precision::BF16}; -INSTANTIATE_TEST_CASE_P(smoke_LSTMCellCPU, +INSTANTIATE_TEST_SUITE_P(smoke_LSTMCellCPU, LSTMCellLayerCPUTest, ::testing::Combine(::testing::Combine(::testing::ValuesIn(should_decompose), ::testing::ValuesIn(batch), diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/lstm_sequence.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/lstm_sequence.cpp index 234a579085cd01..959d5e0c89d6e2 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/lstm_sequence.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/lstm_sequence.cpp @@ -195,7 +195,7 @@ std::vector clip{0.f}; std::vector direction = {ngraph::op::RecurrentSequenceDirection::FORWARD}; std::vector netPrecisions = {InferenceEngine::Precision::FP32}; -INSTANTIATE_TEST_CASE_P(smoke_LSTMSequenceCPU, +INSTANTIATE_TEST_SUITE_P(smoke_LSTMSequenceCPU, LSTMSequenceCPUTest, ::testing::Combine(::testing::Combine(::testing::ValuesIn(mode), ::testing::ValuesIn(seq_lengths_zero_clip), @@ -211,7 +211,7 @@ INSTANTIATE_TEST_CASE_P(smoke_LSTMSequenceCPU, ::testing::ValuesIn(additionalConfig)), LSTMSequenceCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_LSTMSequenceCPUbatchSizeOne, +INSTANTIATE_TEST_SUITE_P(smoke_LSTMSequenceCPUbatchSizeOne, LSTMSequenceCPUTest, ::testing::Combine(::testing::Combine(::testing::ValuesIn(mode), ::testing::ValuesIn(seq_lengths_zero_clip), diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/mat_mul.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/mat_mul.cpp index 020d9ffc3bf4f8..c2285e5f8cf0a8 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/mat_mul.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/mat_mul.cpp @@ -149,7 +149,7 @@ const auto testParams2D = ::testing::Combine(fullyConnectedParams2D, ::testing::Values(MatMulNodeType::FullyConnected), ::testing::ValuesIn(fusingParamsSet2D)); -INSTANTIATE_TEST_CASE_P(smoke_Check_2D, MatMulLayerCPUTest, testParams2D, MatMulLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Check_2D, MatMulLayerCPUTest, testParams2D, MatMulLayerCPUTest::getTestCaseName); const std::vector> IS3D = { {{1, 32, 120}, {120, 5}}, @@ -171,7 +171,7 @@ const auto testParams3D = ::testing::Combine(fullyConnectedParams3D, ::testing::Values(MatMulNodeType::FullyConnected), ::testing::ValuesIn(fusingParamsSet3D)); -INSTANTIATE_TEST_CASE_P(smoke_Check_3D, MatMulLayerCPUTest, testParams3D, MatMulLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Check_3D, MatMulLayerCPUTest, testParams3D, MatMulLayerCPUTest::getTestCaseName); }; // namespace fullyConnected @@ -196,7 +196,7 @@ const auto testParams = ::testing::Combine(gemmParams, ::testing::Values(MatMulNodeType::MatMul), ::testing::Values(emptyFusingSpec)); -INSTANTIATE_TEST_CASE_P(smoke_Check, MatMulLayerCPUTest, testParams, MatMulLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Check, MatMulLayerCPUTest, testParams, MatMulLayerCPUTest::getTestCaseName); }; // namespace gemm diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/mvn.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/mvn.cpp index f89e302c539e50..6b877960e7f2f6 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/mvn.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/mvn.cpp @@ -171,7 +171,7 @@ const auto Mvn3D = ::testing::Combine( ::testing::ValuesIn(inpPrc), ::testing::ValuesIn(outPrc)); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs_Mvn3D, MvnLayerCPUTest, Mvn3D, MvnLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Mvn3D, MvnLayerCPUTest, Mvn3D, MvnLayerCPUTest::getTestCaseName); const auto Mvn4D = ::testing::Combine( ::testing::Combine( @@ -186,7 +186,7 @@ const auto Mvn4D = ::testing::Combine( ::testing::ValuesIn(inpPrc), ::testing::ValuesIn(outPrc)); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs_Mvn4D, MvnLayerCPUTest, Mvn4D, MvnLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Mvn4D, MvnLayerCPUTest, Mvn4D, MvnLayerCPUTest::getTestCaseName); const auto Mvn5D = ::testing::Combine( ::testing::Combine( @@ -201,7 +201,7 @@ const auto Mvn5D = ::testing::Combine( ::testing::ValuesIn(inpPrc), ::testing::ValuesIn(outPrc)); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs_Mvn5D, MvnLayerCPUTest, Mvn5D, MvnLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Mvn5D, MvnLayerCPUTest, Mvn5D, MvnLayerCPUTest::getTestCaseName); // 1D 2D case std::vector fusingUnaryEltwiseParamsSet { @@ -225,7 +225,7 @@ const auto Mvn1D = ::testing::Combine( ::testing::ValuesIn(inpPrc), ::testing::ValuesIn(outPrc)); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs_Mvn1D, MvnLayerCPUTest, Mvn1D, MvnLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Mvn1D, MvnLayerCPUTest, Mvn1D, MvnLayerCPUTest::getTestCaseName); // 2D no transformed const auto Mvn2D = ::testing::Combine( @@ -241,7 +241,7 @@ const auto Mvn2D = ::testing::Combine( ::testing::ValuesIn(inpPrc), ::testing::ValuesIn(outPrc)); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs_Mvn2D, MvnLayerCPUTest, Mvn2D, MvnLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Mvn2D, MvnLayerCPUTest, Mvn2D, MvnLayerCPUTest::getTestCaseName); // 2d transformed const auto Mvn2DTrans = ::testing::Combine( @@ -257,7 +257,7 @@ const auto Mvn2DTrans = ::testing::Combine( ::testing::ValuesIn(inpPrc), ::testing::ValuesIn(outPrc)); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs_MVN2DTrans, MvnLayerCPUTest, Mvn2DTrans, MvnLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_MVN2DTrans, MvnLayerCPUTest, Mvn2DTrans, MvnLayerCPUTest::getTestCaseName); } // namespace } // namespace CPULayerTestsDefinitions \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/normalize.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/normalize.cpp index 74b265d1935dcf..17e9b24f76b26c 100755 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/normalize.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/normalize.cpp @@ -119,7 +119,7 @@ const auto testParams_2D = ::testing::Combine(normalizeParams_2D, ::testing::Values(CPUSpecificParams{}), ::testing::ValuesIn(fusingParamsSet)); -INSTANTIATE_TEST_CASE_P(smoke_2D, NormalizeL2LayerCPUTest, testParams_2D, NormalizeL2LayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_2D, NormalizeL2LayerCPUTest, testParams_2D, NormalizeL2LayerCPUTest::getTestCaseName); /* ============= 3D ============= */ const std::vector> inputShape_3D = { @@ -144,7 +144,7 @@ const auto testParams_3D = ::testing::Combine(normalizeParams_3D, ::testing::Values(CPUSpecificParams{}), ::testing::ValuesIn(fusingParamsSet)); -INSTANTIATE_TEST_CASE_P(smoke_3D, NormalizeL2LayerCPUTest, testParams_3D, NormalizeL2LayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_3D, NormalizeL2LayerCPUTest, testParams_3D, NormalizeL2LayerCPUTest::getTestCaseName); /* ============= 4D ============= */ const std::vector> inputShape_4D = { @@ -183,7 +183,7 @@ const auto testParams_4D = ::testing::Combine(normalizeParams_4D, ::testing::ValuesIn(getCPUSpecificParams()), ::testing::ValuesIn(fusingParamsSet)); -INSTANTIATE_TEST_CASE_P(smoke_4D, NormalizeL2LayerCPUTest, testParams_4D, NormalizeL2LayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_4D, NormalizeL2LayerCPUTest, testParams_4D, NormalizeL2LayerCPUTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/one_hot.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/one_hot.cpp index 4e966d6c0f91b9..e3f083e7460763 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/one_hot.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/one_hot.cpp @@ -100,7 +100,7 @@ const auto testCase_1d = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::Values(emptyCPUSpec) ); -INSTANTIATE_TEST_CASE_P(smoke_OneHotCPU_1D, OneHotLayerCPUTest, testCase_1d, OneHotLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_OneHotCPU_1D, OneHotLayerCPUTest, testCase_1d, OneHotLayerCPUTest::getTestCaseName); // 1d -> 2d, axis default @@ -116,7 +116,7 @@ const auto testCase_2d = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::Values(emptyCPUSpec) ); -INSTANTIATE_TEST_CASE_P(smoke_OneHotCPU_2D, OneHotLayerCPUTest, testCase_2d, OneHotLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_OneHotCPU_2D, OneHotLayerCPUTest, testCase_2d, OneHotLayerCPUTest::getTestCaseName); // 2d -> 3d, on_value, off_value const auto testCase_3d = ::testing::Combine( @@ -131,7 +131,7 @@ const auto testCase_3d = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::Values(emptyCPUSpec) ); -INSTANTIATE_TEST_CASE_P(smoke_OneHotCPU_3D, OneHotLayerCPUTest, testCase_3d, OneHotLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_OneHotCPU_3D, OneHotLayerCPUTest, testCase_3d, OneHotLayerCPUTest::getTestCaseName); // 3d -> 4d const auto testCase_4d = ::testing::Combine( @@ -146,7 +146,7 @@ const auto testCase_4d = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::Values(emptyCPUSpec) ); -INSTANTIATE_TEST_CASE_P(smoke_OneHotCPU_4D, OneHotLayerCPUTest, testCase_4d, OneHotLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_OneHotCPU_4D, OneHotLayerCPUTest, testCase_4d, OneHotLayerCPUTest::getTestCaseName); // 4d -> 5d const auto testCase_5d = ::testing::Combine( @@ -161,7 +161,7 @@ const auto testCase_5d = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::Values(emptyCPUSpec) ); -INSTANTIATE_TEST_CASE_P(smoke_OneHotCPU_5D, OneHotLayerCPUTest, testCase_5d, OneHotLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_OneHotCPU_5D, OneHotLayerCPUTest, testCase_5d, OneHotLayerCPUTest::getTestCaseName); } // namespace } // namespace CPULayerTestsDefinitions \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/pad.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/pad.cpp index 82bdc0971a6dba..b528e9f644f42b 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/pad.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/pad.cpp @@ -122,7 +122,7 @@ const auto pad4DConstParamsBlocked = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_CPUPad4DConstBlocked, PadLayerCPUTest, ::testing::Combine( @@ -145,7 +145,7 @@ const auto pad4DConstParams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_CPUPad4DConst, PadLayerCPUTest, ::testing::Combine( @@ -167,7 +167,7 @@ const auto pad4DParamsBlocked = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_CPUPad4DBlocked, PadLayerCPUTest, ::testing::Combine( @@ -189,7 +189,7 @@ const auto pad4DParams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_CPUPad4D, PadLayerCPUTest, ::testing::Combine( @@ -225,7 +225,7 @@ const auto pad5DConstParamsBlocked = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_CPUPad5DConstBlocked, PadLayerCPUTest, ::testing::Combine( @@ -247,7 +247,7 @@ const auto pad5DConstParams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_CPUPad5DConst, PadLayerCPUTest, ::testing::Combine( @@ -269,7 +269,7 @@ const auto pad5DParamsBlocked = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_CPUPad5DBlocked, PadLayerCPUTest, ::testing::Combine( @@ -291,7 +291,7 @@ const auto pad5DParams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_CPUPad5D, PadLayerCPUTest, ::testing::Combine( diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/pooling.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/pooling.cpp index 6fb1f7d1169440..0021a43dbb9d8b 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/pooling.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/pooling.cpp @@ -144,7 +144,7 @@ const std::vector paramsAvg4D_RefOnly = { ngraph::op::RoundingType::CEIL, ngraph::op::PadType::EXPLICIT, false }, }; -INSTANTIATE_TEST_CASE_P(smoke_MaxPool_CPU_4D, PoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_4D, PoolingLayerCPUTest, ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(paramsMax4D), @@ -159,7 +159,7 @@ INSTANTIATE_TEST_CASE_P(smoke_MaxPool_CPU_4D, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_4D, PoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_4D, PoolingLayerCPUTest, ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(paramsAvg4D), @@ -174,7 +174,7 @@ INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_4D, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_4D_NotOptimized, PoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_4D_NotOptimized, PoolingLayerCPUTest, ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(paramsAvg4D_RefOnly), @@ -214,7 +214,7 @@ const std::vector paramsAvg5D_RefOnly = { ngraph::op::RoundingType::CEIL, ngraph::op::PadType::EXPLICIT, false }, }; -INSTANTIATE_TEST_CASE_P(smoke_MaxPool_CPU_5D, PoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_5D, PoolingLayerCPUTest, ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(paramsMax5D), @@ -229,7 +229,7 @@ INSTANTIATE_TEST_CASE_P(smoke_MaxPool_CPU_5D, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_5D, PoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D, PoolingLayerCPUTest, ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(paramsAvg5D), @@ -244,7 +244,7 @@ INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_5D, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_5D_NotOptimized, PoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D_NotOptimized, PoolingLayerCPUTest, ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(paramsAvg5D_RefOnly), @@ -279,7 +279,7 @@ std::vector fusingParamsSet { fusingFakeQuantizePerChannel, }; -INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_4D_I8, PoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_4D_I8, PoolingLayerCPUTest, ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(paramsAvg4D), @@ -294,7 +294,7 @@ INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_4D_I8, PoolingLayerCPUTest, ::testing::ValuesIn(fusingParamsSet)), PoolingLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_AvgPool_CPU_5D_I8, PoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D_I8, PoolingLayerCPUTest, ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(paramsAvg5D), diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/psroi_pooling.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/psroi_pooling.cpp index 5327e72a6a2281..01131bf0b24e9c 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/psroi_pooling.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/psroi_pooling.cpp @@ -163,7 +163,7 @@ const auto psroiPoolingBilinearParams = ::testing::Combine( ::testing::Values("bilinear") ); -INSTANTIATE_TEST_CASE_P(smoke_PSROIPoolingAverageLayoutTest, PSROIPoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_PSROIPoolingAverageLayoutTest, PSROIPoolingLayerCPUTest, ::testing::Combine( ::testing::Combine( psroiPoolingAverageParams, @@ -172,7 +172,7 @@ INSTANTIATE_TEST_CASE_P(smoke_PSROIPoolingAverageLayoutTest, PSROIPoolingLayerCP ::testing::ValuesIn(filterCPUSpecificParams(resCPUParams))), PSROIPoolingLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_PSROIPoolingBilinearLayoutTest, PSROIPoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_PSROIPoolingBilinearLayoutTest, PSROIPoolingLayerCPUTest, ::testing::Combine( ::testing::Combine( psroiPoolingBilinearParams, diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/reduce_ops.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/reduce_ops.cpp index dc528b82fad1c6..222651e51ff564 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/reduce_ops.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/reduce_ops.cpp @@ -282,56 +282,56 @@ const auto params_MultiAxisLogical5D = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU)), testing::ValuesIn(filterCPUSpecificParams(cpuParams_5D))); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_ReduceOneAxis_CPU, ReduceCPULayerTest, paramsOneAxis, ReduceCPULayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_ReduceLogicalOneAxis_CPU, ReduceCPULayerTest, paramsOneAxisLogical, ReduceCPULayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Reduce_ReductionTypes_CPU, ReduceCPULayerTest, params_MultiAxis, ReduceCPULayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Reduce_ReductionTypes4D_CPU, ReduceCPULayerTest, params_MultiAxis_4D, ReduceCPULayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Reduce_ReductionTypes5D_CPU, ReduceCPULayerTest, params_MultiAxis_5D, ReduceCPULayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_ReduceLogical_ReductionTypes_CPU, ReduceCPULayerTest, params_MultiAxisLogical, ReduceCPULayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_ReduceLogical4D_ReductionTypes_CPU, ReduceCPULayerTest, params_MultiAxisLogical4D, ReduceCPULayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_ReduceLogical5D_ReductionTypes_CPU, ReduceCPULayerTest, params_MultiAxisLogical5D, diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/region_yolo.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/region_yolo.cpp index 4c88cf8d884873..e5a00a813f765d 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/region_yolo.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/region_yolo.cpp @@ -160,8 +160,8 @@ const auto testCase_yolov2_caffe = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU) ); -INSTANTIATE_TEST_CASE_P(smoke_TestsRegionYolov3CPU, RegionYoloCPULayerTest, testCase_yolov3, RegionYoloCPULayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_TestsRegionYoloMxnetCPU, RegionYoloCPULayerTest, testCase_yolov3_mxnet, RegionYoloCPULayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_TestsRegionYoloCaffeCPU, RegionYoloCPULayerTest, testCase_yolov2_caffe, RegionYoloCPULayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsRegionYolov3CPU, RegionYoloCPULayerTest, testCase_yolov3, RegionYoloCPULayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsRegionYoloMxnetCPU, RegionYoloCPULayerTest, testCase_yolov3_mxnet, RegionYoloCPULayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsRegionYoloCaffeCPU, RegionYoloCPULayerTest, testCase_yolov2_caffe, RegionYoloCPULayerTest::getTestCaseName); } // namespace } // namespace CPULayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/rnn_cell.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/rnn_cell.cpp index 381bdfecf369a6..59b23396c38396 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/rnn_cell.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/rnn_cell.cpp @@ -107,7 +107,7 @@ std::vector> activations = {{"relu"}, {"sigmoid"}, {"ta std::vector clip = {0.f}; std::vector netPrecisions = {InferenceEngine::Precision::FP32}; -INSTANTIATE_TEST_CASE_P(smoke_RNNCellCPU, +INSTANTIATE_TEST_SUITE_P(smoke_RNNCellCPU, RNNCellCPUTest, ::testing::Combine(::testing::Combine(::testing::ValuesIn(should_decompose), ::testing::ValuesIn(batch), diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/rnn_sequence.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/rnn_sequence.cpp index 6c7f873cc95c9d..e1e66a660501e8 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/rnn_sequence.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/rnn_sequence.cpp @@ -167,7 +167,7 @@ std::vector direction{ngraph::op::Recurr std::vector netPrecisions = {InferenceEngine::Precision::FP32}; -INSTANTIATE_TEST_CASE_P(smoke_RNNSequenceCPU, +INSTANTIATE_TEST_SUITE_P(smoke_RNNSequenceCPU, RNNSequenceCPUTest, ::testing::Combine(::testing::Combine(::testing::ValuesIn(mode), ::testing::ValuesIn(seq_lengths_zero_clip), @@ -183,7 +183,7 @@ INSTANTIATE_TEST_CASE_P(smoke_RNNSequenceCPU, ::testing::ValuesIn(additionalConfig)), RNNSequenceCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_RNNSequenceCPUBatchSizeOne, +INSTANTIATE_TEST_SUITE_P(smoke_RNNSequenceCPUBatchSizeOne, RNNSequenceCPUTest, ::testing::Combine(::testing::Combine(::testing::ValuesIn(mode), ::testing::ValuesIn(seq_lengths_zero_clip), diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/roi_pooling.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/roi_pooling.cpp index 7422befc949160..094a9f4b507fc1 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/roi_pooling.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/roi_pooling.cpp @@ -186,14 +186,14 @@ const auto test_ROIPooling_bilinear = ::testing::Combine(::testing::ValuesIn(inS ::testing::ValuesIn(netPRCs), ::testing::Values(CommonTestUtils::DEVICE_CPU)); -INSTANTIATE_TEST_CASE_P(smoke_ROIPoolingCPU_max, +INSTANTIATE_TEST_SUITE_P(smoke_ROIPoolingCPU_max, ROIPoolingCPULayerTest, ::testing::Combine(test_ROIPooling_max, ::testing::ValuesIn(selectCPUInfoForDevice()), ::testing::ValuesIn(additionalConfig)), ROIPoolingCPULayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ROIPoolingCPU_bilinear, +INSTANTIATE_TEST_SUITE_P(smoke_ROIPoolingCPU_bilinear, ROIPoolingCPULayerTest, ::testing::Combine(test_ROIPooling_bilinear, ::testing::ValuesIn(selectCPUInfoForDevice()), diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/roialign.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/roialign.cpp index aac49d69274c50..78a6fdcd0cba00 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/roialign.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/roialign.cpp @@ -163,7 +163,7 @@ const auto roiAlignParams = ::testing::Combine( ::testing::ValuesIn(inputShapeVector) // feature map shape ); -INSTANTIATE_TEST_CASE_P(smoke_ROIAlignLayoutTest, ROIAlignLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_ROIAlignLayoutTest, ROIAlignLayerCPUTest, ::testing::Combine( ::testing::Combine( roiAlignParams, diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/shuffle_channels.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/shuffle_channels.cpp index 0548aad8c5e7be..bb06d40a551153 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/shuffle_channels.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/shuffle_channels.cpp @@ -151,7 +151,7 @@ const auto shuffleChannelsParams5D = ::testing::Combine( ::testing::ValuesIn(std::vector{1, 2, 3, 6}) ); -INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels4D, ShuffleChannelsLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannels4D, ShuffleChannelsLayerCPUTest, ::testing::Combine( ::testing::Combine( shuffleChannelsParams4D, @@ -165,7 +165,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels4D, ShuffleChannelsLayerCPUTest, ::testing::ValuesIn(filterCPUInfoForDevice4D())), ShuffleChannelsLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels5D, ShuffleChannelsLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannels5D, ShuffleChannelsLayerCPUTest, ::testing::Combine( ::testing::Combine( shuffleChannelsParams5D, @@ -189,7 +189,7 @@ const auto shuffleChannelsParams5DBlock = ::testing::Combine( ::testing::ValuesIn(std::vector{1, 2, 3, 6}) ); -INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels4DBlock, ShuffleChannelsLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannels4DBlock, ShuffleChannelsLayerCPUTest, ::testing::Combine( ::testing::Combine( shuffleChannelsParams4DBlock, @@ -203,7 +203,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels4DBlock, ShuffleChannelsLayerCPUTes ::testing::ValuesIn(filterCPUInfoForDevice4DBlock())), ShuffleChannelsLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels5DBlock, ShuffleChannelsLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannels5DBlock, ShuffleChannelsLayerCPUTest, ::testing::Combine( ::testing::Combine( shuffleChannelsParams5DBlock, diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/softmax.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/softmax.cpp index d672629ab0ca69..2877a64c44a457 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/softmax.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/softmax.cpp @@ -118,7 +118,7 @@ const auto OptimizedParams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU), testing::Values(emptyCPUSpec)); -INSTANTIATE_TEST_CASE_P(smoke_SoftMax_Optimized_CPU, SoftMaxLayerCPUTest, OptimizedParams, SoftMaxLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_SoftMax_Optimized_CPU, SoftMaxLayerCPUTest, OptimizedParams, SoftMaxLayerCPUTest::getTestCaseName); const auto NotOptimizedParams = testing::Combine( testing::Values(Precision::FP32, Precision::BF16), @@ -126,7 +126,7 @@ const auto NotOptimizedParams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_CPU), testing::Values(notOptimizedCPUSpec)); -INSTANTIATE_TEST_CASE_P(smoke_SoftMax_CPU, SoftMaxLayerCPUTest, NotOptimizedParams, SoftMaxLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_SoftMax_CPU, SoftMaxLayerCPUTest, NotOptimizedParams, SoftMaxLayerCPUTest::getTestCaseName); } // namespace } // namespace CPULayerTestsDefinitions \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/space_to_batch.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/space_to_batch.cpp index 64dd742000c88e..61301aebba7846 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/space_to_batch.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/space_to_batch.cpp @@ -125,10 +125,10 @@ const auto spaceToBatchParamsSet4D2 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(cpuParams_4D)); -INSTANTIATE_TEST_CASE_P(smoke_SpaceToBatchCPULayerTestCase1_4D, SpaceToBatchCPULayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_SpaceToBatchCPULayerTestCase1_4D, SpaceToBatchCPULayerTest, spaceToBatchParamsSet4D1, SpaceToBatchCPULayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_SpaceToBatchCPULayerTestCase2_4D, SpaceToBatchCPULayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_SpaceToBatchCPULayerTestCase2_4D, SpaceToBatchCPULayerTest, spaceToBatchParamsSet4D2, SpaceToBatchCPULayerTest::getTestCaseName); const std::vector> blockShape5D = {{1, 1, 2, 2, 1}, {1, 2, 4, 1, 3}}; @@ -157,7 +157,7 @@ const auto spaceToBatchParamsSet5D = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(cpuParams_5D)); -INSTANTIATE_TEST_CASE_P(smoke_SpaceToBatchCPULayerTestCase_5D, SpaceToBatchCPULayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_SpaceToBatchCPULayerTestCase_5D, SpaceToBatchCPULayerTest, spaceToBatchParamsSet5D, SpaceToBatchCPULayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/space_to_depth.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/space_to_depth.cpp index a080146064f453..4c3bdbbba8d516 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/space_to_depth.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/space_to_depth.cpp @@ -124,7 +124,7 @@ const auto spaceToDepthBS2_4DParams = testing::Combine( testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBS2_4D)) ); -INSTANTIATE_TEST_CASE_P(smoke_CPUSpaceToDepthBS2_4D, SpaceToDepthLayerCPUTest, spaceToDepthBS2_4DParams, SpaceToDepthLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CPUSpaceToDepthBS2_4D, SpaceToDepthLayerCPUTest, spaceToDepthBS2_4DParams, SpaceToDepthLayerCPUTest::getTestCaseName); const std::vector CPUParamsBS3_4D = { cpuParams_nhwc_avx2, @@ -142,7 +142,7 @@ const auto spaceToDepthBS3_4DParams = testing::Combine( ::testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBS3_4D)) ); -INSTANTIATE_TEST_CASE_P(smoke_CPUSpaceToDepthBS3_4D, SpaceToDepthLayerCPUTest, spaceToDepthBS3_4DParams, SpaceToDepthLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CPUSpaceToDepthBS3_4D, SpaceToDepthLayerCPUTest, spaceToDepthBS3_4DParams, SpaceToDepthLayerCPUTest::getTestCaseName); const std::vector> inputShapesBS2_5D = { {1, 16, 2, 2, 2}, {1, 16, 4, 4, 2}, {1, 32, 2, 6, 2}, {2, 32, 4, 2, 2}, {1, 48, 6, 2, 2}, {2, 64, 2, 2, 6} @@ -171,7 +171,7 @@ const auto spaceToDepthBS2_5DParams = testing::Combine( ::testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBS2_5D)) ); -INSTANTIATE_TEST_CASE_P(smoke_CPUSpaceToDepthBS2_5D, SpaceToDepthLayerCPUTest, spaceToDepthBS2_5DParams, SpaceToDepthLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CPUSpaceToDepthBS2_5D, SpaceToDepthLayerCPUTest, spaceToDepthBS2_5DParams, SpaceToDepthLayerCPUTest::getTestCaseName); const std::vector CPUParamsBS3_5D = { cpuParams_ndhwc_avx2, @@ -189,7 +189,7 @@ const auto spaceToDepthBS3_5DParams = testing::Combine( ::testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBS3_5D)) ); -INSTANTIATE_TEST_CASE_P(smoke_CPUSpaceToDepthBS3_5D, SpaceToDepthLayerCPUTest, spaceToDepthBS3_5DParams, SpaceToDepthLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CPUSpaceToDepthBS3_5D, SpaceToDepthLayerCPUTest, spaceToDepthBS3_5DParams, SpaceToDepthLayerCPUTest::getTestCaseName); } // namespace } // namespace CPULayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/split.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/split.cpp index 7129ee4c4aea51..14b83c08ae07a6 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/split.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/split.cpp @@ -126,7 +126,7 @@ const std::vector> outIndices3 = {{0, 1, 2}, {0, 1, 1, 0, 2} const std::vector> outIndices4 = {{0, 1, 2, 3}, {0, 1, 1, 0, 2, 3}, {0, 0, 0, 2, 3}}; -INSTANTIATE_TEST_CASE_P(smoke_Split4D_CPU_Nspc2NcspSpecial, SplitLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Split4D_CPU_Nspc2NcspSpecial, SplitLayerCPUTest, ::testing::Combine( ::testing::Values(4), ::testing::Values(1), @@ -137,7 +137,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Split4D_CPU_Nspc2NcspSpecial, SplitLayerCPUTest, ::testing::Values(perChannelsToPlanar_4D)), SplitLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Split5D_CPU_Nspc2NcspSpecial, SplitLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Split5D_CPU_Nspc2NcspSpecial, SplitLayerCPUTest, ::testing::Combine( ::testing::Values(3), ::testing::Values(1), @@ -148,7 +148,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Split5D_CPU_Nspc2NcspSpecial, SplitLayerCPUTest, ::testing::Values(perChannelsToPlanar_5D)), SplitLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Split4D_CPU_Block8inPlace, SplitLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Split4D_CPU_Block8inPlace, SplitLayerCPUTest, ::testing::Combine( ::testing::Values(3), ::testing::Values(0, 1), @@ -159,7 +159,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Split4D_CPU_Block8inPlace, SplitLayerCPUTest, ::testing::Values(planar_4D, planar_4D_ref, perChannels_4D, blocked8_4D)), SplitLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Split4D_CPU_Block8, SplitLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Split4D_CPU_Block8, SplitLayerCPUTest, ::testing::Combine( ::testing::Values(3), ::testing::Values(2, 3), @@ -170,7 +170,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Split4D_CPU_Block8, SplitLayerCPUTest, ::testing::Values(planar_4D, planar_4D_ref, perChannels_4D, blocked8_4D_ref)), SplitLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Split4D_CPU_Block16inPlace, SplitLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Split4D_CPU_Block16inPlace, SplitLayerCPUTest, ::testing::Combine( ::testing::Values(4), ::testing::Values(0, 1), @@ -181,7 +181,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Split4D_CPU_Block16inPlace, SplitLayerCPUTest, ::testing::Values(blocked16_4D)), SplitLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Split4D_CPU_Block16, SplitLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Split4D_CPU_Block16, SplitLayerCPUTest, ::testing::Combine( ::testing::Values(4), ::testing::Values(2, 3), @@ -192,7 +192,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Split4D_CPU_Block16, SplitLayerCPUTest, ::testing::Values(blocked16_4D_ref)), SplitLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Split5D_CPU_Block8inPlace, SplitLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Split5D_CPU_Block8inPlace, SplitLayerCPUTest, ::testing::Combine( ::testing::Values(3), ::testing::Values(0, 1), @@ -203,7 +203,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Split5D_CPU_Block8inPlace, SplitLayerCPUTest, ::testing::Values(planar_5D, planar_5D_ref, perChannels_5D, blocked8_5D)), SplitLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Split5D_CPU_Block8, SplitLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Split5D_CPU_Block8, SplitLayerCPUTest, ::testing::Combine( ::testing::Values(3), ::testing::Values(2, 3, 4), @@ -214,7 +214,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Split5D_CPU_Block8, SplitLayerCPUTest, ::testing::Values(planar_5D, planar_5D_ref, perChannels_5D, blocked8_5D_ref)), SplitLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Split5D_CPU_Block16inPlace, SplitLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Split5D_CPU_Block16inPlace, SplitLayerCPUTest, ::testing::Combine( ::testing::Values(4), ::testing::Values(0, 1), @@ -225,7 +225,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Split5D_CPU_Block16inPlace, SplitLayerCPUTest, ::testing::Values(blocked16_5D)), SplitLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Split5D_CPU_Block16, SplitLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Split5D_CPU_Block16, SplitLayerCPUTest, ::testing::Combine( ::testing::Values(4), ::testing::Values(2, 3, 4), @@ -236,7 +236,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Split5D_CPU_Block16, SplitLayerCPUTest, ::testing::Values(blocked16_5D_ref)), SplitLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Split3D, SplitLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Split3D, SplitLayerCPUTest, ::testing::Combine( ::testing::Values(7), ::testing::Values(0, 1, 2), @@ -247,7 +247,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Split3D, SplitLayerCPUTest, ::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"}, CPUSpecificParams{{}, {}, {"ref"}, "ref"})), SplitLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Split2D, SplitLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Split2D, SplitLayerCPUTest, ::testing::Combine( ::testing::Values(2), ::testing::Values(0, 1), @@ -258,7 +258,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Split2D, SplitLayerCPUTest, ::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"}, CPUSpecificParams{{}, {}, {"ref"}, "ref"})), SplitLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Split1D, SplitLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_Split1D, SplitLayerCPUTest, ::testing::Combine( ::testing::Values(5), ::testing::Values(0), diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/strided_slice.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/strided_slice.cpp index c4746897552ef2..b01e2455a2904e 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/strided_slice.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/strided_slice.cpp @@ -121,7 +121,7 @@ const auto StridedSliceParamsPlain2D = ::testing::Combine( ::testing::Values(additional_config), ::testing::Values(emptyCPUSpec)); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs_Plain_2D, StridedSliceLayerCPUTest, StridedSliceParamsPlain2D, StridedSliceLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Plain_2D, StridedSliceLayerCPUTest, StridedSliceParamsPlain2D, StridedSliceLayerCPUTest::getTestCaseName); const std::vector testCasesCommon4D = { StridedSliceSpecificParams{ { 1, 5, 32, 32 }, { 0, 2, 5, 4 }, { 1, 4, 28, 27 }, { 1, 1, 1, 1 }, @@ -162,7 +162,7 @@ const auto StridedSliceParamsCommon4D = ::testing::Combine( ::testing::Values(additional_config), ::testing::ValuesIn(CPUParamsCommon4D)); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs_Common_4D, StridedSliceLayerCPUTest, StridedSliceParamsCommon4D, StridedSliceLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_4D, StridedSliceLayerCPUTest, StridedSliceParamsCommon4D, StridedSliceLayerCPUTest::getTestCaseName); const std::vector testCasesBlocked4D = { StridedSliceSpecificParams{ { 1, 16, 32, 32 }, { 0, 0, 5, 4 }, { 1, 16, 28, 27 }, { 1, 1, 1, 1 }, @@ -207,7 +207,7 @@ const auto StridedSliceParamsBlocked4D = ::testing::Combine( ::testing::Values(additional_config), ::testing::ValuesIn(CPUParamsBlocked4D)); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs_Blocked_4D, StridedSliceLayerCPUTest, StridedSliceParamsBlocked4D, StridedSliceLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Blocked_4D, StridedSliceLayerCPUTest, StridedSliceParamsBlocked4D, StridedSliceLayerCPUTest::getTestCaseName); const std::vector testCasesCommon5D = { StridedSliceSpecificParams{ { 1, 5, 20, 32, 32 }, { 0, 2, 0, 5, 4 }, { 1, 4, 5, 28, 27 }, { 1, 1, 1, 1, 1 }, @@ -250,7 +250,7 @@ const auto StridedSliceParamsCommon5D = ::testing::Combine( ::testing::Values(additional_config), ::testing::ValuesIn(CPUParamsCommon5D)); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs_Common_5D, StridedSliceLayerCPUTest, StridedSliceParamsCommon5D, StridedSliceLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_5D, StridedSliceLayerCPUTest, StridedSliceParamsCommon5D, StridedSliceLayerCPUTest::getTestCaseName); const std::vector testCasesBlocked5D = { StridedSliceSpecificParams{ { 1, 16, 20, 32, 32 }, { 0, 0, 0, 5, 4 }, { 1, 16, 5, 28, 27 }, { 1, 1, 1, 1, 1 }, @@ -297,7 +297,7 @@ const auto StridedSliceParamsBlocked5D = ::testing::Combine( ::testing::Values(additional_config), ::testing::ValuesIn(CPUParamsBlocked5D)); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs_Blocked_5D, StridedSliceLayerCPUTest, StridedSliceParamsBlocked5D, StridedSliceLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Blocked_5D, StridedSliceLayerCPUTest, StridedSliceParamsBlocked5D, StridedSliceLayerCPUTest::getTestCaseName); } // namespace } // namespace CPULayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/transpose.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/transpose.cpp index 053ba0ebeae69c..9708b8d50ec48d 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/transpose.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/transpose.cpp @@ -136,7 +136,7 @@ const auto params4D = ::testing::Combine( ::testing::Values(additional_config), ::testing::ValuesIn(CPUParams4D)); -INSTANTIATE_TEST_CASE_P(smoke_Transpose4D_CPU, TransposeLayerCPUTest, params4D, TransposeLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Transpose4D_CPU, TransposeLayerCPUTest, params4D, TransposeLayerCPUTest::getTestCaseName); const auto paramsPerChannels4D = ::testing::Combine( ::testing::ValuesIn(inputOrderPerChannels4D), @@ -146,7 +146,7 @@ const auto paramsPerChannels4D = ::testing::Combine( ::testing::Values(additional_config), ::testing::Values(cpuParams_nhwc)); -INSTANTIATE_TEST_CASE_P(smoke_PermutePerChannels4D_CPU, TransposeLayerCPUTest, paramsPerChannels4D, TransposeLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_PermutePerChannels4D_CPU, TransposeLayerCPUTest, paramsPerChannels4D, TransposeLayerCPUTest::getTestCaseName); const std::vector> inputShapes5D = { {2, 32, 5, 10, 20} @@ -189,7 +189,7 @@ const auto params5D = ::testing::Combine( ::testing::Values(additional_config), ::testing::ValuesIn(CPUParams5D)); -INSTANTIATE_TEST_CASE_P(smoke_Transpose5D_CPU, TransposeLayerCPUTest, params5D, TransposeLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Transpose5D_CPU, TransposeLayerCPUTest, params5D, TransposeLayerCPUTest::getTestCaseName); const auto paramsPerChannels5D = ::testing::Combine( ::testing::ValuesIn(inputOrderPerChannels5D), @@ -199,7 +199,7 @@ const auto paramsPerChannels5D = ::testing::Combine( ::testing::Values(additional_config), ::testing::Values(cpuParams_ndhwc)); -INSTANTIATE_TEST_CASE_P(smoke_PermutePerChannels5D_CPU, TransposeLayerCPUTest, paramsPerChannels5D, TransposeLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_PermutePerChannels5D_CPU, TransposeLayerCPUTest, paramsPerChannels5D, TransposeLayerCPUTest::getTestCaseName); } // namespace } // namespace CPULayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/conv3d_reshape.cpp b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/conv3d_reshape.cpp index 80ff36aeeae034..fd65019e6acaa0 100644 --- a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/conv3d_reshape.cpp +++ b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/conv3d_reshape.cpp @@ -91,7 +91,7 @@ const std::vector numOut = { 1, 2, 5 }; const auto conv3dReshapeParams = ::testing::Combine(::testing::ValuesIn(convType), ::testing::ValuesIn(numOut)); -INSTANTIATE_TEST_CASE_P(smoke_Conv3dReshapeTest, Conv3dReshapeTest, conv3dReshapeParams, Conv3dReshapeTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Conv3dReshapeTest, Conv3dReshapeTest, conv3dReshapeParams, Conv3dReshapeTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/conv_concat.cpp b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/conv_concat.cpp index be03883ed6e8e0..aef68679e83ac0 100644 --- a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/conv_concat.cpp +++ b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/conv_concat.cpp @@ -160,7 +160,7 @@ const auto params2DConv = ::testing::Combine( ::testing::Values(axis) ); -INSTANTIATE_TEST_CASE_P(smoke_Convolution2D1x1, ConvConcatSubgraphTest, params2DConv, ConvConcatSubgraphTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Convolution2D1x1, ConvConcatSubgraphTest, params2DConv, ConvConcatSubgraphTest::getTestCaseName); const std::vector CPUParams2DDeconv = { conv_avx2_2D_1x1, @@ -175,7 +175,7 @@ const auto params2DDeconv = ::testing::Combine( ::testing::Values(axis) ); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D1x1, ConvConcatSubgraphTest, params2DDeconv, ConvConcatSubgraphTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData2D1x1, ConvConcatSubgraphTest, params2DDeconv, ConvConcatSubgraphTest::getTestCaseName); } // namespace Kernel_1x1 @@ -198,7 +198,7 @@ const auto params2D = ::testing::Combine( ::testing::Values(axis) ); -INSTANTIATE_TEST_CASE_P(smoke_DWGroupConvolutionBackpropData2D, ConvConcatSubgraphTest, params2D, ConvConcatSubgraphTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_DWGroupConvolutionBackpropData2D, ConvConcatSubgraphTest, params2D, ConvConcatSubgraphTest::getTestCaseName); } // namespace GroupConvolutionBackpropDataDWConcat @@ -221,7 +221,7 @@ const auto params2D = ::testing::Combine( ::testing::Values(axis) ); -INSTANTIATE_TEST_CASE_P(smoke_DWGroupConvolution2D, ConvConcatSubgraphTest, params2D, ConvConcatSubgraphTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_DWGroupConvolution2D, ConvConcatSubgraphTest, params2D, ConvConcatSubgraphTest::getTestCaseName); /* ============= GroupConvolution (DW 3D) ============= */ commonConvParams dwConvParams3D = commonConvParams{kernelSize3D, strides3D, padBegin3D, padEnd3D, dilation3D, numOutChannels, paddingType, numOutChannels}; @@ -240,7 +240,7 @@ const auto params3D = ::testing::Combine( ::testing::Values(axis) ); -INSTANTIATE_TEST_CASE_P(smoke_DWGroupConvolution3D, ConvConcatSubgraphTest, params3D, ConvConcatSubgraphTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_DWGroupConvolution3D, ConvConcatSubgraphTest, params3D, ConvConcatSubgraphTest::getTestCaseName); } // namespace GroupConvolutionDWConcat @@ -261,7 +261,7 @@ const auto params2D = ::testing::Combine( ::testing::Values(axis) ); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D, ConvConcatSubgraphTest, params2D, ConvConcatSubgraphTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData2D, ConvConcatSubgraphTest, params2D, ConvConcatSubgraphTest::getTestCaseName); /* ============= ConvolutionBackpropData (3D) ============= */ const std::vector CPUParams3D = { @@ -278,7 +278,7 @@ const auto params3D = ::testing::Combine( ::testing::Values(axis) ); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D, ConvConcatSubgraphTest, params3D, ConvConcatSubgraphTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData3D, ConvConcatSubgraphTest, params3D, ConvConcatSubgraphTest::getTestCaseName); } // namespace ConvolutionBackpropDataConcat @@ -301,7 +301,7 @@ const auto params2D = ::testing::Combine( ::testing::Values(axis) ); -INSTANTIATE_TEST_CASE_P(smoke_Convolution2D, ConvConcatSubgraphTest, params2D, ConvConcatSubgraphTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Convolution2D, ConvConcatSubgraphTest, params2D, ConvConcatSubgraphTest::getTestCaseName); /* ============= Convolution (3D) ============= */ const std::vector CPUParams3D = { @@ -319,7 +319,7 @@ const auto params3D = ::testing::Combine( ::testing::Values(axis) ); -INSTANTIATE_TEST_CASE_P(smoke_Convolution3D, ConvConcatSubgraphTest, params3D, ConvConcatSubgraphTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Convolution3D, ConvConcatSubgraphTest, params3D, ConvConcatSubgraphTest::getTestCaseName); } // namespace ConvolutionConact @@ -342,7 +342,7 @@ const auto params2D = ::testing::Combine( ::testing::Values(axis) ); -INSTANTIATE_TEST_CASE_P(smoke_GroupConvolution2D, ConvConcatSubgraphTest, params2D, ConvConcatSubgraphTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_GroupConvolution2D, ConvConcatSubgraphTest, params2D, ConvConcatSubgraphTest::getTestCaseName); /* ============= GroupConvolution (3D) ============= */ const std::vector CPUParams3D = { @@ -360,7 +360,7 @@ const auto params3D = ::testing::Combine( ::testing::Values(axis) ); -INSTANTIATE_TEST_CASE_P(smoke_GroupConvolution3D, ConvConcatSubgraphTest, params3D, ConvConcatSubgraphTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_GroupConvolution3D, ConvConcatSubgraphTest, params3D, ConvConcatSubgraphTest::getTestCaseName); } // namespace GroupConvolutionConcat @@ -382,7 +382,7 @@ const auto params2D = ::testing::Combine( ::testing::Values(axis) ); -INSTANTIATE_TEST_CASE_P(smoke_GroupConvolutionBackpropData2D, ConvConcatSubgraphTest, params2D, ConvConcatSubgraphTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_GroupConvolutionBackpropData2D, ConvConcatSubgraphTest, params2D, ConvConcatSubgraphTest::getTestCaseName); /* ============= GroupConvolutionBackpropData (3D) ============= */ const std::vector CPUParams3D = { @@ -399,7 +399,7 @@ const auto params3D = ::testing::Combine( ::testing::Values(axis) ); -INSTANTIATE_TEST_CASE_P(smoke_GroupConvolutionBackpropData3D, ConvConcatSubgraphTest, params3D, ConvConcatSubgraphTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_GroupConvolutionBackpropData3D, ConvConcatSubgraphTest, params3D, ConvConcatSubgraphTest::getTestCaseName); } // namespace GroupConvolutionBackpropDataConcat diff --git a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/conv_maxpool_activ.cpp b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/conv_maxpool_activ.cpp index 632fc25d1dd2a8..bc8600fd853f16 100644 --- a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/conv_maxpool_activ.cpp +++ b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/conv_maxpool_activ.cpp @@ -78,7 +78,7 @@ const std::vector fusingParamsSet { fusingSigmoid }; -INSTANTIATE_TEST_CASE_P(smoke_Check, ConvPoolActivTest, ::testing::ValuesIn(fusingParamsSet), ConvPoolActivTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Check, ConvPoolActivTest, ::testing::ValuesIn(fusingParamsSet), ConvPoolActivTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/eltwise_chain.cpp b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/eltwise_chain.cpp index 25c109b5c051c9..8179b0867b4cde 100644 --- a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/eltwise_chain.cpp +++ b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/eltwise_chain.cpp @@ -140,7 +140,7 @@ std::vector> eltwiseOps = { { EltwiseTypes::DIVIDE, EltwiseTypes::SQUARED_DIFF, EltwiseTypes::ADD }, }; -INSTANTIATE_TEST_CASE_P(smoke_EltwiseChain, EltwiseChainTest, +INSTANTIATE_TEST_SUITE_P(smoke_EltwiseChain, EltwiseChainTest, ::testing::Combine( ::testing::ValuesIn(inputShapes), ::testing::ValuesIn(inputPrecisions), @@ -172,7 +172,7 @@ std::vector> inputPrecisionsFQ { { Precision::FP32, Precision::FP32, Precision::FP32, Precision::FP32 } }; -INSTANTIATE_TEST_CASE_P(smoke_EltwiseChainWithFQ, EltwiseChainTest, +INSTANTIATE_TEST_SUITE_P(smoke_EltwiseChainWithFQ, EltwiseChainTest, ::testing::Combine( ::testing::ValuesIn(inputShapesFQ), ::testing::ValuesIn(inputPrecisionsFQ), diff --git a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/fuse_muladd_ewsimple.cpp b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/fuse_muladd_ewsimple.cpp index c48947dfa707a7..76e9e453ce40c1 100644 --- a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/fuse_muladd_ewsimple.cpp +++ b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/fuse_muladd_ewsimple.cpp @@ -59,7 +59,7 @@ TEST_P(FuseMulAddAndEwSimpleTest1, CompareWithRefs) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_Basic, FuseMulAddAndEwSimpleTest1, mulAddAndEwSimpleCommonParams, FuseMulAddAndEwSimpleTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Basic, FuseMulAddAndEwSimpleTest1, mulAddAndEwSimpleCommonParams, FuseMulAddAndEwSimpleTest::getTestCaseName); // Fused EltwiseAndSimple comes on the 2nd input into MulAdd @@ -84,7 +84,7 @@ TEST_P(FuseMulAddAndEwSimpleTest2, CompareWithRefs) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_Basic, FuseMulAddAndEwSimpleTest2, mulAddAndEwSimpleCommonParams, FuseMulAddAndEwSimpleTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Basic, FuseMulAddAndEwSimpleTest2, mulAddAndEwSimpleCommonParams, FuseMulAddAndEwSimpleTest::getTestCaseName); // Fused MulAdd with more than 3 inputs @@ -108,5 +108,5 @@ TEST_P(FuseMulAddAndEwSimpleTest3, CompareWithRefs) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_Basic, FuseMulAddAndEwSimpleTest3, mulAddAndEwSimpleCommonParams, FuseMulAddAndEwSimpleTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Basic, FuseMulAddAndEwSimpleTest3, mulAddAndEwSimpleCommonParams, FuseMulAddAndEwSimpleTest::getTestCaseName); } // namespace SubgraphTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/fuse_scaleshift_and_fakequantize.cpp b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/fuse_scaleshift_and_fakequantize.cpp index 871d93ab68860f..7c2dadd9f5262f 100644 --- a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/fuse_scaleshift_and_fakequantize.cpp +++ b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/fuse_scaleshift_and_fakequantize.cpp @@ -109,7 +109,7 @@ std::vector>> quantizes { { {0.f}, {2.55f}, {0.f}, {2.55f} }, }; -INSTANTIATE_TEST_CASE_P(smoke_FuseScaleShiftAndFakeQuantize, FuseScaleShiftAndFakeQuantizeTest, +INSTANTIATE_TEST_SUITE_P(smoke_FuseScaleShiftAndFakeQuantize, FuseScaleShiftAndFakeQuantizeTest, ::testing::Combine( ::testing::ValuesIn(inputShapes), ::testing::Values(element::f32), diff --git a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/fuse_transpose_reorder.cpp b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/fuse_transpose_reorder.cpp index 3c07843a39c7b1..3f8eab0dd936de 100644 --- a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/fuse_transpose_reorder.cpp +++ b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/fuse_transpose_reorder.cpp @@ -97,7 +97,7 @@ TEST_P(FuseTransposeAndReorderTest, CompareWithRefs) { CheckTransposeCount(0); } -INSTANTIATE_TEST_CASE_P(smoke_Basic, FuseTransposeAndReorderTest, fuseTransposeAndReorderCommonParams, FuseTransposeAndReorderTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Basic, FuseTransposeAndReorderTest, fuseTransposeAndReorderCommonParams, FuseTransposeAndReorderTest::getTestCaseName); /* FuseTransposeAndReorderTest1 graph @@ -174,7 +174,7 @@ TEST_P(FuseTransposeAndReorderTest1, DISABLED_CompareWithRefs) { CheckTransposeCount(2); } -INSTANTIATE_TEST_CASE_P(smoke_Basic, FuseTransposeAndReorderTest1, fuseTransposeAndReorderCommonParams, FuseTransposeAndReorderTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Basic, FuseTransposeAndReorderTest1, fuseTransposeAndReorderCommonParams, FuseTransposeAndReorderTest::getTestCaseName); /* FuseTransposeAndReorderTest2 graph @@ -236,6 +236,6 @@ TEST_P(FuseTransposeAndReorderTest2, CompareWithRefs) { CheckTransposeCount(1); } -INSTANTIATE_TEST_CASE_P(smoke_Basic, FuseTransposeAndReorderTest2, fuseTransposeAndReorderCommonParams, FuseTransposeAndReorderTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Basic, FuseTransposeAndReorderTest2, fuseTransposeAndReorderCommonParams, FuseTransposeAndReorderTest::getTestCaseName); } // namespace SubgraphTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/param_result_custom_blob.cpp b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/param_result_custom_blob.cpp index 85d7e4787cec82..020bcac57565ba 100644 --- a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/param_result_custom_blob.cpp +++ b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/param_result_custom_blob.cpp @@ -53,7 +53,7 @@ TEST_P(ParameterResultCustomBlobTest, CompareWithRefs) { Run(); } namespace { - INSTANTIATE_TEST_CASE_P(smoke_Check_Custom_Blob, ParameterResultCustomBlobTest, + INSTANTIATE_TEST_SUITE_P(smoke_Check_Custom_Blob, ParameterResultCustomBlobTest, ::testing::Values(CommonTestUtils::DEVICE_CPU), ParameterResultSubgraphTest::getTestCaseName); } // namespace @@ -79,7 +79,7 @@ TEST_P(ParameterResultSameBlobTest, CompareWithRefs) { Run(); } namespace { - INSTANTIATE_TEST_CASE_P(smoke_Check_Same_Blob, ParameterResultSameBlobTest, + INSTANTIATE_TEST_SUITE_P(smoke_Check_Same_Blob, ParameterResultSameBlobTest, ::testing::Values(CommonTestUtils::DEVICE_CPU), ParameterResultSubgraphTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/reshape_fc.cpp b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/reshape_fc.cpp index 1ed41cb5b2b996..50a6218f63f9e3 100644 --- a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/reshape_fc.cpp +++ b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/reshape_fc.cpp @@ -91,7 +91,7 @@ const auto reshapeFCParams = ::testing::Combine(::testing::ValuesIn(isFC), ::testing::ValuesIn(transpose), ::testing::ValuesIn(fusingParamsSet)); -INSTANTIATE_TEST_CASE_P(smoke_Check, ReshapeFCTest, reshapeFCParams, ReshapeFCTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Check, ReshapeFCTest, reshapeFCParams, ReshapeFCTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/reshape_permute_conv_permute_reshape_act.cpp b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/reshape_permute_conv_permute_reshape_act.cpp index b389e2bc3fb938..a54bd62b4297e1 100644 --- a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/reshape_permute_conv_permute_reshape_act.cpp +++ b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/reshape_permute_conv_permute_reshape_act.cpp @@ -32,7 +32,7 @@ std::vector netPrecisions = { std::map additional_config = { }; namespace SubgraphTestsDefinitions { - INSTANTIATE_TEST_CASE_P(smoke_basic, ConvReshapeAct, + INSTANTIATE_TEST_SUITE_P(smoke_basic, ConvReshapeAct, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), diff --git a/inference-engine/tests/functional/plugin/gna/Import_export_tests/import_export_act_conv_act.cpp b/inference-engine/tests/functional/plugin/gna/Import_export_tests/import_export_act_conv_act.cpp index e5abadfb1cc67f..18feccd8cbc98f 100644 --- a/inference-engine/tests/functional/plugin/gna/Import_export_tests/import_export_act_conv_act.cpp +++ b/inference-engine/tests/functional/plugin/gna/Import_export_tests/import_export_act_conv_act.cpp @@ -165,7 +165,7 @@ const std::vector> importConfigs = { } }; -INSTANTIATE_TEST_CASE_P(smoke_ImportActConvAct, ImportActConvActTest, +INSTANTIATE_TEST_SUITE_P(smoke_ImportActConvAct, ImportActConvActTest, ::testing::Combine( ::testing::ValuesIn(inputShape), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gna/Import_export_tests/import_export_memory_layer.cpp b/inference-engine/tests/functional/plugin/gna/Import_export_tests/import_export_memory_layer.cpp index c3f7a0c78ae176..f0deafaf07140d 100644 --- a/inference-engine/tests/functional/plugin/gna/Import_export_tests/import_export_memory_layer.cpp +++ b/inference-engine/tests/functional/plugin/gna/Import_export_tests/import_export_memory_layer.cpp @@ -130,7 +130,7 @@ const std::vector> importConfigs = { }, }; -INSTANTIATE_TEST_CASE_P(smoke_ImportNetworkMemoryCase, ImportMemoryTest, +INSTANTIATE_TEST_SUITE_P(smoke_ImportNetworkMemoryCase, ImportMemoryTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/pass_tests/4d_eltwise.cpp b/inference-engine/tests/functional/plugin/gna/pass_tests/4d_eltwise.cpp index 37cb4a825690bd..00f32649eb9229 100644 --- a/inference-engine/tests/functional/plugin/gna/pass_tests/4d_eltwise.cpp +++ b/inference-engine/tests/functional/plugin/gna/pass_tests/4d_eltwise.cpp @@ -157,7 +157,7 @@ class Eltwise4dMultipleInput : public testing::WithParamInterface ngraph::helpers::EltwiseTypes::ADD }; - INSTANTIATE_TEST_CASE_P(smoke_Eltwise4d, Eltwise4dBroadcast, + INSTANTIATE_TEST_SUITE_P(smoke_Eltwise4d, Eltwise4dBroadcast, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), @@ -165,7 +165,7 @@ class Eltwise4dMultipleInput : public testing::WithParamInterface ::testing::ValuesIn(eltwiseOpTypes)), Eltwise4dBroadcast::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Eltwise4d, Eltwise4dMultipleInput, + INSTANTIATE_TEST_SUITE_P(smoke_Eltwise4d, Eltwise4dMultipleInput, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/pass_tests/act_maxpool_reordering.cpp b/inference-engine/tests/functional/plugin/gna/pass_tests/act_maxpool_reordering.cpp index 36b7d209aa2ffe..eea2de7d6e4d2c 100644 --- a/inference-engine/tests/functional/plugin/gna/pass_tests/act_maxpool_reordering.cpp +++ b/inference-engine/tests/functional/plugin/gna/pass_tests/act_maxpool_reordering.cpp @@ -125,7 +125,7 @@ const std::vector activationTypes = { ngraph::helpers::ActivationTypes::Abs }; -INSTANTIATE_TEST_CASE_P(smoke_act_maxpool_reordering, ActMaxpoolReordering, +INSTANTIATE_TEST_SUITE_P(smoke_act_maxpool_reordering, ActMaxpoolReordering, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/pass_tests/broadcast_const_with_fq.cpp b/inference-engine/tests/functional/plugin/gna/pass_tests/broadcast_const_with_fq.cpp index 7c5f24cf3e84e9..085d69999f2bee 100644 --- a/inference-engine/tests/functional/plugin/gna/pass_tests/broadcast_const_with_fq.cpp +++ b/inference-engine/tests/functional/plugin/gna/pass_tests/broadcast_const_with_fq.cpp @@ -80,7 +80,7 @@ const std::vector> configs = { { {"GNA_DEVICE_MODE", "GNA_SW_EXACT"} } }; -INSTANTIATE_TEST_CASE_P(smoke_broadcast_const_with_fq, BroadcastConstWithFq, +INSTANTIATE_TEST_SUITE_P(smoke_broadcast_const_with_fq, BroadcastConstWithFq, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(inputShapes1), diff --git a/inference-engine/tests/functional/plugin/gna/pass_tests/convert_matmul_to_fullyconnected.cpp b/inference-engine/tests/functional/plugin/gna/pass_tests/convert_matmul_to_fullyconnected.cpp index f4a74fe58c8b11..4cd9a227cbf105 100644 --- a/inference-engine/tests/functional/plugin/gna/pass_tests/convert_matmul_to_fullyconnected.cpp +++ b/inference-engine/tests/functional/plugin/gna/pass_tests/convert_matmul_to_fullyconnected.cpp @@ -103,7 +103,7 @@ const std::vector>> input_shapes = { }; -INSTANTIATE_TEST_CASE_P(smoke_convert_matmul_to_fc, ConvertMatmulToFcPass, +INSTANTIATE_TEST_SUITE_P(smoke_convert_matmul_to_fc, ConvertMatmulToFcPass, ::testing::Combine( ::testing::ValuesIn(input_shapes), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gna/pass_tests/convert_matmul_to_pointwise_conv.cpp b/inference-engine/tests/functional/plugin/gna/pass_tests/convert_matmul_to_pointwise_conv.cpp index 86bfe5e25c013a..2065ed394d2706 100644 --- a/inference-engine/tests/functional/plugin/gna/pass_tests/convert_matmul_to_pointwise_conv.cpp +++ b/inference-engine/tests/functional/plugin/gna/pass_tests/convert_matmul_to_pointwise_conv.cpp @@ -209,7 +209,7 @@ const std::vector> fqStats = { {-0.5, 0.5} }; -INSTANTIATE_TEST_CASE_P(smoke_ConvertMatmulToPointwiseConvTest, ConvertMatmulToPointwiseConv, +INSTANTIATE_TEST_SUITE_P(smoke_ConvertMatmulToPointwiseConvTest, ConvertMatmulToPointwiseConv, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), @@ -217,7 +217,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ConvertMatmulToPointwiseConvTest, ConvertMatmulToP ::testing::ValuesIn(inputShape)), ConvertMatmulToPointwiseConv::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ConvertMatmulToPointwiseConvTest, ConvertMatmulToPointwiseConvWithFq, +INSTANTIATE_TEST_SUITE_P(smoke_ConvertMatmulToPointwiseConvTest, ConvertMatmulToPointwiseConvWithFq, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/pass_tests/eltwise_split_over_channels_pass.cpp b/inference-engine/tests/functional/plugin/gna/pass_tests/eltwise_split_over_channels_pass.cpp index f4c6cc98d34136..5f69ab0261521c 100644 --- a/inference-engine/tests/functional/plugin/gna/pass_tests/eltwise_split_over_channels_pass.cpp +++ b/inference-engine/tests/functional/plugin/gna/pass_tests/eltwise_split_over_channels_pass.cpp @@ -80,7 +80,7 @@ const std::vector> inputShape = { {1, 500000} }; -INSTANTIATE_TEST_CASE_P(smoke_EltwiseSplitOverChennels, EltwiseSplitOverChannelsPassTest, +INSTANTIATE_TEST_SUITE_P(smoke_EltwiseSplitOverChennels, EltwiseSplitOverChannelsPassTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/pass_tests/fq_activation.cpp b/inference-engine/tests/functional/plugin/gna/pass_tests/fq_activation.cpp index ff0495f756eb12..9299fceb643527 100644 --- a/inference-engine/tests/functional/plugin/gna/pass_tests/fq_activation.cpp +++ b/inference-engine/tests/functional/plugin/gna/pass_tests/fq_activation.cpp @@ -122,7 +122,7 @@ const std::vector levels = { 65535, }; -INSTANTIATE_TEST_CASE_P(smoke_fq_activation, FQActivation, +INSTANTIATE_TEST_SUITE_P(smoke_fq_activation, FQActivation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/pass_tests/fq_fusion_with_multiple_weights.cpp b/inference-engine/tests/functional/plugin/gna/pass_tests/fq_fusion_with_multiple_weights.cpp index d65a94eaca6e5c..a4a26ba18d043f 100644 --- a/inference-engine/tests/functional/plugin/gna/pass_tests/fq_fusion_with_multiple_weights.cpp +++ b/inference-engine/tests/functional/plugin/gna/pass_tests/fq_fusion_with_multiple_weights.cpp @@ -129,7 +129,7 @@ const std::vector levels = { 65535, }; -INSTANTIATE_TEST_CASE_P(smoke_fq_fusion, FQFusionWithMultipleWeights, +INSTANTIATE_TEST_SUITE_P(smoke_fq_fusion, FQFusionWithMultipleWeights, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/pass_tests/fq_maxpool_reordering.cpp b/inference-engine/tests/functional/plugin/gna/pass_tests/fq_maxpool_reordering.cpp index 316df2ca9d7665..a8c5e52d30d4e4 100644 --- a/inference-engine/tests/functional/plugin/gna/pass_tests/fq_maxpool_reordering.cpp +++ b/inference-engine/tests/functional/plugin/gna/pass_tests/fq_maxpool_reordering.cpp @@ -136,7 +136,7 @@ const std::vector levels = { 65535, }; -INSTANTIATE_TEST_CASE_P(smoke_fq_maxpool_reordering, FQMaxpoolReordering, +INSTANTIATE_TEST_SUITE_P(smoke_fq_maxpool_reordering, FQMaxpoolReordering, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/pass_tests/insert_copy_layer_before_self_concat.cpp b/inference-engine/tests/functional/plugin/gna/pass_tests/insert_copy_layer_before_self_concat.cpp index 5c01537be7dc36..421280a7189cc5 100644 --- a/inference-engine/tests/functional/plugin/gna/pass_tests/insert_copy_layer_before_self_concat.cpp +++ b/inference-engine/tests/functional/plugin/gna/pass_tests/insert_copy_layer_before_self_concat.cpp @@ -103,7 +103,7 @@ std::vector concatsNum = {1, 2, 3, 4}; std::vector netPrecisions = {InferenceEngine::Precision::FP32, InferenceEngine::Precision::FP16}; -INSTANTIATE_TEST_CASE_P(smoke_InsertCopy, InsertCopyBeforeSelfConcatTest, +INSTANTIATE_TEST_SUITE_P(smoke_InsertCopy, InsertCopyBeforeSelfConcatTest, ::testing::Combine( ::testing::ValuesIn(axes), ::testing::ValuesIn(inShapes), diff --git a/inference-engine/tests/functional/plugin/gna/pass_tests/insert_transpose_before_matmul.cpp b/inference-engine/tests/functional/plugin/gna/pass_tests/insert_transpose_before_matmul.cpp index eb867e05e31000..2c4298c9e97d74 100644 --- a/inference-engine/tests/functional/plugin/gna/pass_tests/insert_transpose_before_matmul.cpp +++ b/inference-engine/tests/functional/plugin/gna/pass_tests/insert_transpose_before_matmul.cpp @@ -120,7 +120,7 @@ const std::vector inputShape = { const std::vector firstInputConst = {false, true}; -INSTANTIATE_TEST_CASE_P(smoke_InsertTransposeBeforeMatmulTest, InsertTransposeBeforeMatmul, +INSTANTIATE_TEST_SUITE_P(smoke_InsertTransposeBeforeMatmulTest, InsertTransposeBeforeMatmul, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/pass_tests/insert_transpose_between_convs.cpp b/inference-engine/tests/functional/plugin/gna/pass_tests/insert_transpose_between_convs.cpp index 6e63962504c41c..578eecb33ac3d9 100644 --- a/inference-engine/tests/functional/plugin/gna/pass_tests/insert_transpose_between_convs.cpp +++ b/inference-engine/tests/functional/plugin/gna/pass_tests/insert_transpose_between_convs.cpp @@ -209,7 +209,7 @@ const std::vector> inputShape = { {1, 4, 1, 128} }; -INSTANTIATE_TEST_CASE_P(smoke_InsertTransposeBetweenConvsTest, InsertTransposeBetweenConvs, +INSTANTIATE_TEST_SUITE_P(smoke_InsertTransposeBetweenConvsTest, InsertTransposeBetweenConvs, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), @@ -217,7 +217,7 @@ INSTANTIATE_TEST_CASE_P(smoke_InsertTransposeBetweenConvsTest, InsertTransposeBe ::testing::ValuesIn(inputShape)), InsertTransposeBetweenConvs::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_InsertTransposeBetweenConvsWithPoolTest, InsertTransposeBetweenConvsWithPool, +INSTANTIATE_TEST_SUITE_P(smoke_InsertTransposeBetweenConvsWithPoolTest, InsertTransposeBetweenConvsWithPool, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/pass_tests/layers_restrictions.cpp b/inference-engine/tests/functional/plugin/gna/pass_tests/layers_restrictions.cpp index fc7f15994d2044..15d2075f5baac3 100644 --- a/inference-engine/tests/functional/plugin/gna/pass_tests/layers_restrictions.cpp +++ b/inference-engine/tests/functional/plugin/gna/pass_tests/layers_restrictions.cpp @@ -100,14 +100,14 @@ const std::vector> configs = { { {"GNA_DEVICE_MODE", "GNA_SW_EXACT"} } }; -INSTANTIATE_TEST_CASE_P(smoke_layers_restrictions, LayersRestrictionsFullyConnectedBatchSizeMoreThan8, +INSTANTIATE_TEST_SUITE_P(smoke_layers_restrictions, LayersRestrictionsFullyConnectedBatchSizeMoreThan8, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(configs), ::testing::Values(CommonTestUtils::DEVICE_GNA)), LayersRestrictionsFullyConnectedBatchSizeMoreThan8::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_layers_restrictions, LayersRestrictionsFullyConnectedBatchSizeLessThanOrEqual8, +INSTANTIATE_TEST_SUITE_P(smoke_layers_restrictions, LayersRestrictionsFullyConnectedBatchSizeLessThanOrEqual8, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(configs), diff --git a/inference-engine/tests/functional/plugin/gna/pass_tests/remove_permutations_NHWC_to_NCHW_pass.cpp b/inference-engine/tests/functional/plugin/gna/pass_tests/remove_permutations_NHWC_to_NCHW_pass.cpp index d5cd3fc58f8d6d..326d2cbb8ef949 100644 --- a/inference-engine/tests/functional/plugin/gna/pass_tests/remove_permutations_NHWC_to_NCHW_pass.cpp +++ b/inference-engine/tests/functional/plugin/gna/pass_tests/remove_permutations_NHWC_to_NCHW_pass.cpp @@ -471,7 +471,7 @@ class RemovePermutationsWithEltwiseTest : public testing::WithParamInterface{false, true})), // with activation RemovePermutationsWithPoolAndActTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_PermutationPass, RemovePermutationsWithTwoConvTest, + INSTANTIATE_TEST_SUITE_P(smoke_PermutationPass, RemovePermutationsWithTwoConvTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), @@ -504,7 +504,7 @@ class RemovePermutationsWithEltwiseTest : public testing::WithParamInterface testCases = { addOutputsParams(getTargetNetwork(), {"Memory_1"}, CommonTestUtils::DEVICE_GNA) }; -INSTANTIATE_TEST_CASE_P(smoke_AddOutputBasic, AddOutputsTest, +INSTANTIATE_TEST_SUITE_P(smoke_AddOutputBasic, AddOutputsTest, ::testing::ValuesIn(testCases), AddOutputsTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/caching_tests.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/caching_tests.cpp index 5d956898897025..620e6285cd9584 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/caching_tests.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/caching_tests.cpp @@ -17,7 +17,7 @@ namespace { 1, 2 }; - INSTANTIATE_TEST_CASE_P(smoke_CachingSupportCase_GNA, LoadNetworkCacheTestBase, + INSTANTIATE_TEST_SUITE_P(smoke_CachingSupportCase_GNA, LoadNetworkCacheTestBase, ::testing::Combine( ::testing::ValuesIn(LoadNetworkCacheTestBase::getStandardFunctions()), ::testing::ValuesIn(precisionsGNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/config.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/config.cpp index 2c74871bd324ea..13b8f62c966092 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/config.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/config.cpp @@ -22,7 +22,7 @@ namespace { {{InferenceEngine::GNAConfigParams::KEY_GNA_COMPACT_MODE, "ON"}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, IncorrectConfigTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), @@ -38,7 +38,7 @@ namespace { }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigAPITests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, IncorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), @@ -51,7 +51,7 @@ namespace { {} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectConfigAPITests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, CorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/core_integration.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/core_integration.cpp index 52efa7af27bea1..c2b9a62b0492d9 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/core_integration.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/core_integration.cpp @@ -13,12 +13,12 @@ namespace { // IE Class Common tests with // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassBasicTestP, IEClassBasicTestP, ::testing::Values(std::make_pair("GNAPlugin", "GNA"))); // TODO -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( DISABLED_smoke_IEClassNetworkTestP, IEClassNetworkTestP, ::testing::Values("GNA")); @@ -26,41 +26,41 @@ INSTANTIATE_TEST_CASE_P( // IE Class GetMetric // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetMetricTest, IEClassGetMetricTest_SUPPORTED_CONFIG_KEYS, ::testing::Values("GNA", "MULTI", "HETERO")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetMetricTest, IEClassGetMetricTest_SUPPORTED_METRICS, ::testing::Values("GNA", "MULTI", "HETERO")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetMetricTest, IEClassGetMetricTest_AVAILABLE_DEVICES, ::testing::Values("GNA")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetMetricTest, IEClassGetMetricTest_FULL_DEVICE_NAME, ::testing::Values("GNA", "MULTI", "HETERO")); // TODO: Issue: 30198 -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( DISABLED_smoke_IEClassGetMetricTest, IEClassGetMetricTest_OPTIMIZATION_CAPABILITIES, ::testing::Values("GNA")); // TODO: Issue: 30199 -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( DISABLED_smoke_IEClassGetMetricTest, IEClassGetMetricTest_RANGE_FOR_ASYNC_INFER_REQUESTS, ::testing::Values("GNA")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetMetricTest, IEClassGetMetricTest_ThrowUnsupported, ::testing::Values("GNA", "MULTI", "HETERO")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetConfigTest, IEClassGetConfigTest_ThrowUnsupported, ::testing::Values("GNA", "MULTI", "HETERO")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetAvailableDevices, IEClassGetAvailableDevices, ::testing::Values("GNA")); @@ -68,7 +68,7 @@ INSTANTIATE_TEST_CASE_P( // IE Class GetConfig // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetConfigTest, IEClassGetConfigTest, ::testing::Values("GNA")); @@ -77,27 +77,27 @@ INSTANTIATE_TEST_CASE_P( // // TODO: Convolution with 3D input is not supported on GNA -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( DISABLED_smoke_IEClassExecutableNetworkGetMetricTest, IEClassExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS, ::testing::Values("GNA" /*, "MULTI:GNA", "HETERO:GNA" */)); // TODO: Convolution with 3D input is not supported on GNA -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( DISABLED_smoke_IEClassExecutableNetworkGetMetricTest, IEClassExecutableNetworkGetMetricTest_SUPPORTED_METRICS, ::testing::Values("GNA" /*, "MULTI:GNA", "HETERO:GNA" */)); // TODO: this metric is not supported by the plugin -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( DISABLED_smoke_IEClassExecutableNetworkGetMetricTest, IEClassExecutableNetworkGetMetricTest_NETWORK_NAME, ::testing::Values("GNA", "MULTI:GNA", "HETERO:GNA")); // TODO: Convolution with 3D input is not supported on GNA -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( DISABLED_smoke_IEClassExecutableNetworkGetMetricTest, IEClassExecutableNetworkGetMetricTest_OPTIMAL_NUMBER_OF_INFER_REQUESTS, ::testing::Values("GNA"/*, "MULTI:GNA", "HETERO:GNA" */)); // TODO: Convolution with 3D input is not supported on GNA -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( DISABLED_smoke_IEClassExecutableNetworkGetMetricTest, IEClassExecutableNetworkGetMetricTest_ThrowsUnsupported, ::testing::Values("GNA", /* "MULTI:GNA", */ "HETERO:GNA")); @@ -106,17 +106,17 @@ INSTANTIATE_TEST_CASE_P( // // TODO: Convolution with 3D input is not supported on GNA -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( DISABLED_smoke_IEClassExecutableNetworkGetConfigTest, IEClassExecutableNetworkGetConfigTest, ::testing::Values("GNA")); // TODO: Convolution with 3D input is not supported on GNA -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( DISABLED_smoke_IEClassExecutableNetworkSetConfigTest, IEClassExecutableNetworkSetConfigTest, ::testing::Values("GNA")); // TODO: Convolution with 3D input is not supported on GNA -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( DISABLED_smoke_IEClassExecutableNetworkSupportedConfigTest, IEClassExecutableNetworkSupportedConfigTest, ::testing::Combine(::testing::Values("GNA"), ::testing::Values(std::make_pair(GNA_CONFIG_KEY(DEVICE_MODE), GNAConfigParams::GNA_HW), @@ -125,7 +125,7 @@ INSTANTIATE_TEST_CASE_P( std::make_pair(GNA_CONFIG_KEY(DEVICE_MODE), GNAConfigParams::GNA_AUTO)))); // TODO: Convolution with 3D input is not supported on GNA -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( DISABLED_smoke_IEClassExecutableNetworkUnsupportedConfigTest, IEClassExecutableNetworkUnsupportedConfigTest, ::testing::Combine(::testing::Values("GNA"), ::testing::Values(std::make_pair(GNA_CONFIG_KEY(DEVICE_MODE), GNAConfigParams::GNA_SW_FP32), @@ -146,7 +146,7 @@ TEST_P(IEClassExecutableNetworkSetConfigFromFp32Test, SetConfigFromFp32Throws) { } // TODO: Convolution with 3D input is not supported on GNA -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( DISABLED_smoke_IEClassExecutableNetworkSetConfigFromFp32Test, IEClassExecutableNetworkSetConfigFromFp32Test, ::testing::Combine(::testing::Values("GNA"), ::testing::Values(std::make_pair(GNA_CONFIG_KEY(DEVICE_MODE), GNAConfigParams::GNA_HW), @@ -157,13 +157,13 @@ INSTANTIATE_TEST_CASE_P( // IE Class Query network -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassQueryNetworkTest, IEClassQueryNetworkTest, ::testing::Values("GNA")); // IE Class Load network -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassLoadNetworkTest, IEClassLoadNetworkTest, ::testing::Values("GNA")); @@ -172,21 +172,21 @@ INSTANTIATE_TEST_CASE_P( // // TODO: verify hetero interop -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( DISABLED_smoke_IEClassHeteroExecutableNetworlGetMetricTest, IEClassHeteroExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS, ::testing::Values("GNA")); // TODO: verify hetero interop -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( DISABLED_smoke_IEClassHeteroExecutableNetworlGetMetricTest, IEClassHeteroExecutableNetworkGetMetricTest_SUPPORTED_METRICS, ::testing::Values("GNA")); // TODO: verify hetero interop -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( DISABLED_smoke_IEClassHeteroExecutableNetworlGetMetricTest, IEClassHeteroExecutableNetworkGetMetricTest_NETWORK_NAME, ::testing::Values("GNA")); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassHeteroExecutableNetworlGetMetricTest, IEClassHeteroExecutableNetworkGetMetricTest_TARGET_FALLBACK, ::testing::Values("GNA")); } // namespace diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/core_threading_tests.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/core_threading_tests.cpp index f1cb21ac6b5f0e..690ec0a0bfb688 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/core_threading_tests.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/core_threading_tests.cpp @@ -14,9 +14,9 @@ Params params[] = { std::vector< std::tuple > paramsWithIterations{ params[0], params[2] }; } // namespace -INSTANTIATE_TEST_CASE_P(GNA, CoreThreadingTests, testing::ValuesIn(params), CoreThreadingTests::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(GNA, CoreThreadingTests, testing::ValuesIn(params), CoreThreadingTests::getTestCaseName); -INSTANTIATE_TEST_CASE_P(GNA, CoreThreadingTestsWithIterations, +INSTANTIATE_TEST_SUITE_P(GNA, CoreThreadingTestsWithIterations, testing::Combine(testing::ValuesIn(paramsWithIterations), testing::Values(3), testing::Values(4), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/cpp_holders.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/cpp_holders.cpp index 433d4adf9336cc..38ac8bf5f13ab6 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/cpp_holders.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/cpp_holders.cpp @@ -21,19 +21,19 @@ namespace { {0, 1, 3, 2} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, HoldersTest, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, HoldersTest, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GNA), ::testing::ValuesIn(orders)), HoldersTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, HoldersTestImportNetwork, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, HoldersTestImportNetwork, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GNA), ::testing::ValuesIn(orders)), HoldersTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, HoldersTestOnImportedNetwork, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, HoldersTestOnImportedNetwork, ::testing::Values(CommonTestUtils::DEVICE_GNA), HoldersTestOnImportedNetwork::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/exec_graph_info.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/exec_graph_info.cpp index d8cb26b4499588..84b86f47f0477a 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/exec_graph_info.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/exec_graph_info.cpp @@ -15,7 +15,7 @@ namespace { {}, }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, ExecGraphTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, ExecGraphTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/infer_request.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/infer_request.cpp index 9d67255fafc429..055c23f047a1de 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/infer_request.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/infer_request.cpp @@ -10,14 +10,14 @@ const std::vector netPrecisions = { InferenceEngine::Precision::FP32 }; -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferRequestTests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferRequestTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), ::testing::Values(std::map({}))), InferRequestTests::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferRequestTestsResultNotReady, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferRequestTestsResultNotReady, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/infer_request_callback.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/infer_request_callback.cpp index 6b7c64fe39f8b1..9336cb7efa315e 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/infer_request_callback.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/infer_request_callback.cpp @@ -20,14 +20,14 @@ const std::vector> multiConfigs = { }; -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CallbackTests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, CallbackTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), ::testing::ValuesIn(configs)), CallbackTests::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, CallbackTests, +INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, CallbackTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/infer_request_config.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/infer_request_config.cpp index 62d2a94ffa81da..c21747bd33506e 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/infer_request_config.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/infer_request_config.cpp @@ -29,14 +29,14 @@ namespace { {{InferenceEngine::GNAConfigParams::KEY_GNA_COMPACT_MODE, InferenceEngine::PluginConfigParams::NO}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferConfigTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferConfigTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), ::testing::ValuesIn(configs)), InferConfigTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferConfigInTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferConfigInTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/infer_request_input.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/infer_request_input.cpp index 81620660e0f250..6aa0825d34df4b 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/infer_request_input.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/infer_request_input.cpp @@ -15,7 +15,7 @@ namespace { {} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferRequestInputTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferRequestInputTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/infer_request_output.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/infer_request_output.cpp index da5b0b42611ae2..a8c4ed86f3e245 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/infer_request_output.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/infer_request_output.cpp @@ -14,7 +14,7 @@ namespace { {} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferRequestOutputTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferRequestOutputTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/layout.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/layout.cpp index 2d5f773bf41e83..ccbab8aecb4891 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/layout.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/layout.cpp @@ -22,7 +22,7 @@ namespace { { 1, 3 } }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, LayoutTest, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, LayoutTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/memory_states.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/memory_states.cpp index 475b7693c41ba7..c2db36ff9f3ed7 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/memory_states.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/memory_states.cpp @@ -127,6 +127,6 @@ std::vector memoryStateTestCases = { memoryStateParams(getNetwork(), {"c_1-3", "r_1-3"}, CommonTestUtils::DEVICE_GNA) }; -INSTANTIATE_TEST_CASE_P(smoke_VariableStateBasic, VariableStateTest, +INSTANTIATE_TEST_SUITE_P(smoke_VariableStateBasic, VariableStateTest, ::testing::ValuesIn(memoryStateTestCases), VariableStateTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/test_plugin.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/test_plugin.cpp index 4ee7a5a8761abe..8c5e79825f55f1 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/test_plugin.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/test_plugin.cpp @@ -16,21 +16,21 @@ namespace { {} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, BehaviorTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, BehaviorTests, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_GNA), ::testing::ValuesIn(configs)), BehaviorTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, BehaviorTestInput, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, BehaviorTestInput, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), ::testing::ValuesIn(configs)), BehaviorTestInput::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, BehaviorTestOutput, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, BehaviorTestOutput, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/version.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/version.cpp index 74850f0129ba6e..e9c9c12d292b8e 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/version.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/behavior/version.cpp @@ -14,14 +14,14 @@ namespace { {{ HETERO_CONFIG_KEY(DUMP_GRAPH_DOT) , CommonTestUtils::DEVICE_GNA}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, VersionTest, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, VersionTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_GNA), ::testing::ValuesIn(configs)), VersionTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Hetero_BehaviorTests, VersionTest, + INSTANTIATE_TEST_SUITE_P(smoke_Hetero_BehaviorTests, VersionTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_HETERO), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/import_export_tests/import_reshape_permute_conv.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/import_export_tests/import_reshape_permute_conv.cpp index 442cb116f5d387..0d824402305da1 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/import_export_tests/import_reshape_permute_conv.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/import_export_tests/import_reshape_permute_conv.cpp @@ -74,7 +74,7 @@ const std::vector appHeaders = { "APPLICATION_HEADER" }; -INSTANTIATE_TEST_CASE_P(smoke_ImportNetworkCase, ImportReshapePermuteConvGNA, +INSTANTIATE_TEST_SUITE_P(smoke_ImportNetworkCase, ImportReshapePermuteConvGNA, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/activation.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/activation.cpp index 8e800d1b1c86c2..9de08e5f84ffd8 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/activation.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/activation.cpp @@ -61,6 +61,6 @@ const auto basicCases = ::testing::Combine( ); -INSTANTIATE_TEST_CASE_P(smoke_Activation_Basic, ActivationLayerTest, basicCases, ActivationLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Activation_Basic, ActivationLayerTest, basicCases, ActivationLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/concat.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/concat.cpp index 022898dd3c7bac..68107baee29bd3 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/concat.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/concat.cpp @@ -22,7 +22,7 @@ std::vector>> inShapes = { std::vector netPrecisions = {InferenceEngine::Precision::FP32, InferenceEngine::Precision::FP16}; // TODO: Issue: 26421 -INSTANTIATE_TEST_CASE_P(smoke_NoReshape, ConcatLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_NoReshape, ConcatLayerTest, ::testing::Combine( ::testing::ValuesIn(axes), ::testing::ValuesIn(inShapes), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/convolution.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/convolution.cpp index 6605857612aa49..7231ec975f4efe 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/convolution.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/convolution.cpp @@ -147,7 +147,7 @@ const auto conv2DParams_AutoPadValid_MapTo1d = ::testing::Combine( ); // TODO: padding isn't currently supported in GNA -INSTANTIATE_TEST_CASE_P(DISABLED_smoke_Convolution2D_ExplicitPadding_Height1, ConvolutionLayerTest, +INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_Convolution2D_ExplicitPadding_Height1, ConvolutionLayerTest, ::testing::Combine( conv2DParams_ExplicitPadding_Height1, ::testing::ValuesIn(netPrecisions), @@ -159,7 +159,7 @@ INSTANTIATE_TEST_CASE_P(DISABLED_smoke_Convolution2D_ExplicitPadding_Height1, Co ::testing::Values(CommonTestUtils::DEVICE_GNA)), ConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(DISABLED_smoke_Convolution2D_ExplicitPadding_Width1, ConvolutionLayerTest, +INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_Convolution2D_ExplicitPadding_Width1, ConvolutionLayerTest, ::testing::Combine( conv2DParams_ExplicitPadding_Width1, ::testing::ValuesIn(netPrecisions), @@ -171,7 +171,7 @@ INSTANTIATE_TEST_CASE_P(DISABLED_smoke_Convolution2D_ExplicitPadding_Width1, Con ::testing::Values(CommonTestUtils::DEVICE_GNA)), ConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Convolution2D_AutoPadValid_Height1, ConvolutionLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Convolution2D_AutoPadValid_Height1, ConvolutionLayerTest, ::testing::Combine( conv2DParams_AutoPadValid_Height1, ::testing::ValuesIn(netPrecisions), @@ -183,7 +183,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Convolution2D_AutoPadValid_Height1, ConvolutionLay ::testing::Values(CommonTestUtils::DEVICE_GNA)), ConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Convolution2D_AutoPadValid_Width1, ConvolutionLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Convolution2D_AutoPadValid_Width1, ConvolutionLayerTest, ::testing::Combine( conv2DParams_AutoPadValid_Width1, ::testing::ValuesIn(netPrecisions), @@ -195,7 +195,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Convolution2D_AutoPadValid_Width1, ConvolutionLaye ::testing::Values(CommonTestUtils::DEVICE_GNA)), ConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Convolution2D_AutoPadValid_MapTo1d, ConvolutionLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Convolution2D_AutoPadValid_MapTo1d, ConvolutionLayerTest, ::testing::Combine( conv2DParams_AutoPadValid_MapTo1d, ::testing::ValuesIn(netPrecisions), @@ -207,7 +207,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Convolution2D_AutoPadValid_MapTo1d, ConvolutionLay ::testing::Values(CommonTestUtils::DEVICE_GNA)), ConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Convolution2D_Kernels2D, GnaConvolutionLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Convolution2D_Kernels2D, GnaConvolutionLayerTest, ::testing::Combine( conv2DParams_Kernels2D, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/convolution_negative.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/convolution_negative.cpp index aa4975e602facd..2235a2b90fa5d0 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/convolution_negative.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/convolution_negative.cpp @@ -151,7 +151,7 @@ struct GnaConv2DNegativeTest##whats_wrong : GnaConv2DNegativeTest { TEST_P(GnaConv2DNegativeTest##whats_wrong, ThrowAsNotSupported) { \ Run(); \ } \ -INSTANTIATE_TEST_CASE_P(smoke_GnaConv2DNegativeTestInvalid##whats_wrong, GnaConv2DNegativeTest##whats_wrong, \ +INSTANTIATE_TEST_SUITE_P(smoke_GnaConv2DNegativeTestInvalid##whats_wrong, GnaConv2DNegativeTest##whats_wrong, \ ::testing::Combine( \ conv2DParameters##suffix_params, \ ::testing::ValuesIn(netPrecisions), \ diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/eltwise.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/eltwise.cpp index 13430d921e7b16..6c13b86e434dc7 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/eltwise.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/eltwise.cpp @@ -59,5 +59,5 @@ const auto multiply_params = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GNA), ::testing::Values(additional_config)); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs, EltwiseLayerTest, multiply_params, EltwiseLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs, EltwiseLayerTest, multiply_params, EltwiseLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/fake_quantize.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/fake_quantize.cpp index 31ec8bc4a62cf8..4a50e05ce089d4 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/fake_quantize.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/fake_quantize.cpp @@ -84,7 +84,7 @@ const auto fqParams = ::testing::Combine( ::testing::ValuesIn(inputParams) ); -INSTANTIATE_TEST_CASE_P(smoke_FakeQuantize, FakeQuantizeLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantize, FakeQuantizeLayerTest, ::testing::Combine( fqParams, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/low_precision.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/low_precision.cpp index 04853e098605f5..9d68c1cea942a5 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/low_precision.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/low_precision.cpp @@ -58,7 +58,7 @@ const std::vector>> co {"sw_exact_i8", config_i8}, }; -INSTANTIATE_TEST_CASE_P(DISABLED_smoke_LowPrecision, GnaLowPrecisionTest, +INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_LowPrecision, GnaLowPrecisionTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/mat_mul.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/mat_mul.cpp index f8ad9761689918..f502d0ed3cbd02 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/mat_mul.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/mat_mul.cpp @@ -27,7 +27,7 @@ std::vector secondaryInputTypes = { std::map additional_config = {{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}}; -INSTANTIATE_TEST_CASE_P(smoke_MatMul, MatMulTest, +INSTANTIATE_TEST_SUITE_P(smoke_MatMul, MatMulTest, ::testing::Combine( ::testing::ValuesIn(shapeRelatedParams), ::testing::ValuesIn(inputPrecisions), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/memory.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/memory.cpp index c04b76705ccac0..3e3c053f192c80 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/memory.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/memory.cpp @@ -34,7 +34,7 @@ const std::vector iterationCount { 10 }; -INSTANTIATE_TEST_CASE_P(smoke_MemoryTest, MemoryTest, +INSTANTIATE_TEST_SUITE_P(smoke_MemoryTest, MemoryTest, ::testing::Combine( ::testing::ValuesIn(transformation), ::testing::ValuesIn(iterationCount), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/pooling.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/pooling.cpp index cd5af6385d2ac8..880a3f95bb6bc5 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/pooling.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/pooling.cpp @@ -40,7 +40,7 @@ const auto maxPool_ExplicitPad_FloorRounding_Params = ::testing::Combine( ); // TODO: Issue: 26503 -INSTANTIATE_TEST_CASE_P(DISABLED_smoke_MaxPool_ExplicitPad_FloorRpunding, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_MaxPool_ExplicitPad_FloorRpunding, PoolingLayerTest, ::testing::Combine( maxPool_ExplicitPad_FloorRounding_Params, ::testing::ValuesIn(netPrecisions), @@ -65,7 +65,7 @@ const auto maxPool_ExplicitPad_CeilRounding_Params = ::testing::Combine( ::testing::Values(false) // placeholder value - exclude pad not applicable for max pooling ); // TODO: Issue: 26503 -INSTANTIATE_TEST_CASE_P(DISABLED_smoke_MaxPool_ExplicitPad_CeilRpunding, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_MaxPool_ExplicitPad_CeilRpunding, PoolingLayerTest, ::testing::Combine( maxPool_ExplicitPad_CeilRounding_Params, ::testing::ValuesIn(netPrecisions), @@ -93,7 +93,7 @@ const auto avgPoolExplicitPadCeilRoundingParams = ::testing::Combine( ::testing::Values(true, false) ); // TODO: Issue: 26503 -INSTANTIATE_TEST_CASE_P(DISABLED_smoke_AvgPool_ExplicitPad_CeilRounding, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_AvgPool_ExplicitPad_CeilRounding, PoolingLayerTest, ::testing::Combine( avgPoolExplicitPadCeilRoundingParams, ::testing::ValuesIn(netPrecisions), @@ -118,7 +118,7 @@ const auto avgPoolExplicitPadFloorRoundingParams = ::testing::Combine( ); // TODO: Issue: 26503 -INSTANTIATE_TEST_CASE_P(DISABLED_smoke_AvgPool_ExplicitPad_FloorRounding, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_AvgPool_ExplicitPad_FloorRounding, PoolingLayerTest, ::testing::Combine( avgPoolExplicitPadFloorRoundingParams, ::testing::ValuesIn(netPrecisions), @@ -144,7 +144,7 @@ const auto allPools_ValidPad_Params = ::testing::Combine( ::testing::Values(false) // placeholder value - exclude pad not applicable for max pooling ); // TODO: Issue: 26503 -INSTANTIATE_TEST_CASE_P(DISABLED_smoke_MAX_and_AVGPool_ValidPad, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_MAX_and_AVGPool_ValidPad, PoolingLayerTest, ::testing::Combine( allPools_ValidPad_Params, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/power.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/power.cpp index 1c67b1b35ce791..892e96670f6b85 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/power.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/power.cpp @@ -36,7 +36,7 @@ namespace { InferenceEngine::Precision::FP16, }; - INSTANTIATE_TEST_CASE_P(smoke_power, PowerLayerTest, + INSTANTIATE_TEST_SUITE_P(smoke_power, PowerLayerTest, ::testing::Combine( ::testing::ValuesIn(inShapes), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/split.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/split.cpp index a2740dd8ea7867..80f784e5cf4568 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/split.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/split.cpp @@ -16,7 +16,7 @@ const std::vector netPrecisions = { }; // TODO: Issue: 26411 -INSTANTIATE_TEST_CASE_P(DISABLED_smoke_NumSplitsCheck, SplitLayerTest, +INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_NumSplitsCheck, SplitLayerTest, ::testing::Combine( ::testing::Values(1), ::testing::Values(0, 1), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/tensor_iterator.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/tensor_iterator.cpp index 64cb0d1d7760d8..55e72e2b819834 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/tensor_iterator.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/tensor_iterator.cpp @@ -21,7 +21,7 @@ namespace { InferenceEngine::Precision::FP16 }; - INSTANTIATE_TEST_CASE_P(smoke_TensorIterator, TensorIteratorTest, + INSTANTIATE_TEST_SUITE_P(smoke_TensorIterator, TensorIteratorTest, ::testing::Combine( ::testing::ValuesIn(should_decompose), ::testing::ValuesIn(seqLengths), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/activation_concats_eltwise.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/activation_concats_eltwise.cpp index f08ef63d0b9842..e3c190cc176981 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/activation_concats_eltwise.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/activation_concats_eltwise.cpp @@ -31,7 +31,7 @@ const std::vector netPrecisions = { std::map additional_config = {}; -INSTANTIATE_TEST_CASE_P(smoke_CompareRefs, ActivationConcatsEltwise, +INSTANTIATE_TEST_SUITE_P(smoke_CompareRefs, ActivationConcatsEltwise, ::testing::Combine( ::testing::ValuesIn(input_sizes), ::testing::ValuesIn(concat_const_sizes), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/activation_fq.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/activation_fq.cpp index 223b243768b971..e3f51c28d76ed1 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/activation_fq.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/activation_fq.cpp @@ -67,7 +67,7 @@ const std::vector activations = { ngraph::helpers::ActivationTypes::Exp }; -INSTANTIATE_TEST_CASE_P(smoke_ActivationFQSubgraph, ActivationFakeQuantizeSubgraphTest, +INSTANTIATE_TEST_SUITE_P(smoke_ActivationFQSubgraph, ActivationFakeQuantizeSubgraphTest, ::testing::Combine( fqParams, ::testing::ValuesIn(activations), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/basic_lstm.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/basic_lstm.cpp index ff5633c0d865a1..5b6530090c0f3a 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/basic_lstm.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/basic_lstm.cpp @@ -29,7 +29,7 @@ const std::vector> size_params = { const std::vector decompose = { false, true }; -INSTANTIATE_TEST_CASE_P(smoke_BasicLSTM, Basic_LSTM_S, +INSTANTIATE_TEST_SUITE_P(smoke_BasicLSTM, Basic_LSTM_S, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/broadcast_power.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/broadcast_power.cpp index 252e64cb2753c7..5cabf80e6add53 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/broadcast_power.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/broadcast_power.cpp @@ -39,7 +39,7 @@ const std::vector>> input_shapes { }; -INSTANTIATE_TEST_CASE_P(PowerBroadcast, BroadcastPowerTest, +INSTANTIATE_TEST_SUITE_P(PowerBroadcast, BroadcastPowerTest, ::testing::Combine( ::testing::ValuesIn(input_shapes), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/cascade_concat.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/cascade_concat.cpp index fc408535b6d235..f4a68244df0690 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/cascade_concat.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/cascade_concat.cpp @@ -43,7 +43,7 @@ namespace { {"GNA_SCALE_FACTOR_2", "1"} }; - INSTANTIATE_TEST_CASE_P(smoke_cascade_concat, CascadeConcat, + INSTANTIATE_TEST_SUITE_P(smoke_cascade_concat, CascadeConcat, ::testing::Combine( ::testing::ValuesIn(shape1), ::testing::ValuesIn(shape2), @@ -54,7 +54,7 @@ namespace { ::testing::Values(additional_config)), CascadeConcat::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_cascade_concat_multioutput, CascadeConcat, + INSTANTIATE_TEST_SUITE_P(smoke_cascade_concat_multioutput, CascadeConcat, ::testing::Combine( ::testing::ValuesIn(shape1), ::testing::ValuesIn(shape2), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/clamp_fq.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/clamp_fq.cpp index 2a53f88a83aa5d..bf0a38ee4bc3ca 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/clamp_fq.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/clamp_fq.cpp @@ -72,7 +72,7 @@ const auto fqParams = ::testing::Combine( ); -INSTANTIATE_TEST_CASE_P(smoke_Clamp_FQ_subgraph, ClampFakeQuantizeSubgraphTest, +INSTANTIATE_TEST_SUITE_P(smoke_Clamp_FQ_subgraph, ClampFakeQuantizeSubgraphTest, ::testing::Combine( fqParams, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/concat_conv.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/concat_conv.cpp index 4b657aec21e3fe..2087e98dfe1954 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/concat_conv.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/concat_conv.cpp @@ -39,7 +39,7 @@ std::vector outputChannels = { 8 }; -INSTANTIATE_TEST_CASE_P(smoke_ConcatConvTest, ConcatConvTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConcatConvTest, ConcatConvTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/concat_multi_input.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/concat_multi_input.cpp index c748d53a83fa3e..0a153590268bb2 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/concat_multi_input.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/concat_multi_input.cpp @@ -32,7 +32,7 @@ std::map additional_config = { {"GNA_PRECISION", "I16"}, }; -INSTANTIATE_TEST_CASE_P(smoke_concat_multi_input, ConcatMultiInput, +INSTANTIATE_TEST_SUITE_P(smoke_concat_multi_input, ConcatMultiInput, ::testing::Combine( ::testing::ValuesIn(inShapes), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/concat_quantization.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/concat_quantization.cpp index 01db9ae551f0ea..90e6961b404fc1 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/concat_quantization.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/concat_quantization.cpp @@ -21,7 +21,7 @@ const std::vector> configs = { } }; -INSTANTIATE_TEST_CASE_P(smoke_ConcatQuantization, ConcatQuantization, +INSTANTIATE_TEST_SUITE_P(smoke_ConcatQuantization, ConcatQuantization, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/concat_quantization_during_memory_requantization.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/concat_quantization_during_memory_requantization.cpp index 32df9109d6af06..0357c545f57872 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/concat_quantization_during_memory_requantization.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/concat_quantization_during_memory_requantization.cpp @@ -31,7 +31,7 @@ namespace { 32 }; - INSTANTIATE_TEST_CASE_P(smoke_concat_quant_memory_requant, ConcatQuantDuringMemoryRequantTest, + INSTANTIATE_TEST_SUITE_P(smoke_concat_quant_memory_requant, ConcatQuantDuringMemoryRequantTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/connect_split_concat.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/connect_split_concat.cpp index 47bb9adda01581..3322d3f0800ba6 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/connect_split_concat.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/connect_split_concat.cpp @@ -17,14 +17,14 @@ std::map additional_config = { {"GNA_COMPACT_MODE", "NO"} }; -INSTANTIATE_TEST_CASE_P(multiple_connect_split_concat, MultipleConnectSplitConcatTest, +INSTANTIATE_TEST_SUITE_P(multiple_connect_split_concat, MultipleConnectSplitConcatTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), ::testing::Values(additional_config)), MultipleConnectSplitConcatTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(connect_split_concat_concat, SplitConcatConcatTest, +INSTANTIATE_TEST_SUITE_P(connect_split_concat_concat, SplitConcatConcatTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/const_conv_concat.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/const_conv_concat.cpp index 48224037b2ae82..3a03f5c7cbc455 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/const_conv_concat.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/const_conv_concat.cpp @@ -44,7 +44,7 @@ std::vector outputChannels = { 64 }; -INSTANTIATE_TEST_CASE_P(smoke_ConstConvConcatTest, ConstConvConcatTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConstConvConcatTest, ConstConvConcatTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/const_strided_slice_concat.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/const_strided_slice_concat.cpp index 06fec972d17231..35d42981e8fd85 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/const_strided_slice_concat.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/const_strided_slice_concat.cpp @@ -39,7 +39,7 @@ std::vector constChunksNumber = { 1, 3 }; -INSTANTIATE_TEST_CASE_P(smoke_ConstStridedSliceConcatTest, ConstStridedSliceConcatTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConstStridedSliceConcatTest, ConstStridedSliceConcatTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/constant_result.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/constant_result.cpp index 3c3c7978fe24bd..8c9f9ab1d03672 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/constant_result.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/constant_result.cpp @@ -34,7 +34,7 @@ const std::vector precisions = { Precision::BOOL }; -INSTANTIATE_TEST_CASE_P(smoke_Check, ConstantResultSubgraphTest, +INSTANTIATE_TEST_SUITE_P(smoke_Check, ConstantResultSubgraphTest, ::testing::Combine( ::testing::ValuesIn(types), ::testing::ValuesIn(shapes), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/conv_fq_eltwise.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/conv_fq_eltwise.cpp index 0a09c33f6df8f6..f9358fee19fa28 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/conv_fq_eltwise.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/conv_fq_eltwise.cpp @@ -46,7 +46,7 @@ const auto convParams = ::testing::Combine( ::testing::ValuesIn(outputChannels) ); -INSTANTIATE_TEST_CASE_P(smoke_ConvFqEltwiseTest, ConvFqEltwiseTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvFqEltwiseTest, ConvFqEltwiseTest, ::testing::Combine( fqParams, convParams, diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/conv_fq_relu.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/conv_fq_relu.cpp index 2a2296950e628d..ebb96d8aa17fb8 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/conv_fq_relu.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/conv_fq_relu.cpp @@ -46,7 +46,7 @@ const auto convParams = ::testing::Combine( ::testing::ValuesIn(outputChannels) ); -INSTANTIATE_TEST_CASE_P(smoke_ConvFqReluTest, ConvFqReluTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvFqReluTest, ConvFqReluTest, ::testing::Combine( fqParams, convParams, diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/convolution_relu_sequence.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/convolution_relu_sequence.cpp index 7600e34a7fb095..8169ac44bee6a3 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/convolution_relu_sequence.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/convolution_relu_sequence.cpp @@ -190,7 +190,7 @@ const std::vector > configs = { }; // Enable when using GNA 2.1 library -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionReluSequenceTest, GnaConvolutionReluSequenceTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionReluSequenceTest, GnaConvolutionReluSequenceTest, ::testing::Combine( ::testing::ValuesIn(convReluSpecificParamsAllAll), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/copy_before_squeeze.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/copy_before_squeeze.cpp index 3e82d4f0e8b43e..6e3d94864708bb 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/copy_before_squeeze.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/copy_before_squeeze.cpp @@ -26,7 +26,7 @@ namespace { {1, 640} }; - INSTANTIATE_TEST_CASE_P(smoke_copy_before_squeeze, CopyBeforeSqueezeTest, + INSTANTIATE_TEST_SUITE_P(smoke_copy_before_squeeze, CopyBeforeSqueezeTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/crop4d.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/crop4d.cpp index 7e390c381585a7..335c15ff2e8275 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/crop4d.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/crop4d.cpp @@ -30,7 +30,7 @@ const std::vector> configs = { } }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_crop4d_gna, Crop4dTest, ::testing::Combine( ::testing::ValuesIn(ss_only_test_cases), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/delayed_copy_layer.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/delayed_copy_layer.cpp index 41a8c1d68e0d7e..3f3cfa1f063ed4 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/delayed_copy_layer.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/delayed_copy_layer.cpp @@ -17,7 +17,7 @@ namespace { {"GNA_COMPACT_MODE", "NO"} }; - INSTANTIATE_TEST_CASE_P(delayed_copy_layer, DelayedCopyTest, + INSTANTIATE_TEST_SUITE_P(delayed_copy_layer, DelayedCopyTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/eltwise_conv_eltwise.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/eltwise_conv_eltwise.cpp index bacdd0d90061bc..ae29ad27baed8e 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/eltwise_conv_eltwise.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/eltwise_conv_eltwise.cpp @@ -45,7 +45,7 @@ std::vector outputChannels = { 8 }; -INSTANTIATE_TEST_CASE_P(smoke_EltwiseAfterConvTest, EltwiseAfterConvTest, +INSTANTIATE_TEST_SUITE_P(smoke_EltwiseAfterConvTest, EltwiseAfterConvTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), @@ -55,7 +55,7 @@ INSTANTIATE_TEST_CASE_P(smoke_EltwiseAfterConvTest, EltwiseAfterConvTest, ::testing::ValuesIn(outputChannels)), EltwiseAfterConvTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_EltwiseBeforeConvTest, EltwiseBeforeConvTest, +INSTANTIATE_TEST_SUITE_P(smoke_EltwiseBeforeConvTest, EltwiseBeforeConvTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), @@ -65,7 +65,7 @@ INSTANTIATE_TEST_CASE_P(smoke_EltwiseBeforeConvTest, EltwiseBeforeConvTest, ::testing::ValuesIn(outputChannels)), EltwiseBeforeConvTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_EltwiseWithTwoConvsAsInputsTest, EltwiseWithTwoConvsAsInputsTest, +INSTANTIATE_TEST_SUITE_P(smoke_EltwiseWithTwoConvsAsInputsTest, EltwiseWithTwoConvsAsInputsTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/eltwise_reshape_activation.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/eltwise_reshape_activation.cpp index 332da49fb38b41..8e7af93c892d00 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/eltwise_reshape_activation.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/eltwise_reshape_activation.cpp @@ -30,7 +30,7 @@ std::vector> additional_config = { } }; -INSTANTIATE_TEST_CASE_P(smoke_EltwiseReshapeActivationTest, EltwiseReshapeActivation, +INSTANTIATE_TEST_SUITE_P(smoke_EltwiseReshapeActivationTest, EltwiseReshapeActivation, ::testing::Combine( ::testing::ValuesIn(shapes), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/fc_conv_fc.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/fc_conv_fc.cpp index db70b15fd5c01e..069398cd7d5c4c 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/fc_conv_fc.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/fc_conv_fc.cpp @@ -45,7 +45,7 @@ std::vector outputChannels = { 8 }; -INSTANTIATE_TEST_CASE_P(smoke_FcAfterConvTest, FcAfterConvTest, +INSTANTIATE_TEST_SUITE_P(smoke_FcAfterConvTest, FcAfterConvTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), @@ -55,7 +55,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FcAfterConvTest, FcAfterConvTest, ::testing::ValuesIn(outputChannels)), FcAfterConvTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_FcBeforeConvTest, FcBeforeConvTest, +INSTANTIATE_TEST_SUITE_P(smoke_FcBeforeConvTest, FcBeforeConvTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), @@ -65,7 +65,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FcBeforeConvTest, FcBeforeConvTest, ::testing::ValuesIn(outputChannels)), FcBeforeConvTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_FcBetweenConvsTest, FcBetweenConvsTest, +INSTANTIATE_TEST_SUITE_P(smoke_FcBetweenConvsTest, FcBetweenConvsTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/first_connect_input_concat.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/first_connect_input_concat.cpp index 3a7bdf8935d524..e62bdd99cfcb72 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/first_connect_input_concat.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/first_connect_input_concat.cpp @@ -27,7 +27,7 @@ std::map additional_config = { {"GNA_COMPACT_MODE", "NO"}, }; -INSTANTIATE_TEST_CASE_P(smoke_concat_first_input, ConcatFirstInputTest, +INSTANTIATE_TEST_SUITE_P(smoke_concat_first_input, ConcatFirstInputTest, ::testing::Combine( ::testing::ValuesIn(inShapes), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/fq_conv_fq_affine.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/fq_conv_fq_affine.cpp index e48d4ad12c0c8e..34957dc3da754e 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/fq_conv_fq_affine.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/fq_conv_fq_affine.cpp @@ -48,7 +48,7 @@ const auto convParams = ::testing::Combine( const std::vector permute = {false, true}; -INSTANTIATE_TEST_CASE_P(smoke_FqConvFqAffineTest, FqConvFqAffineTest, +INSTANTIATE_TEST_SUITE_P(smoke_FqConvFqAffineTest, FqConvFqAffineTest, ::testing::Combine( fqParams, convParams, diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/get_output_before_activation.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/get_output_before_activation.cpp index 7588776f73b64c..f7b2e5fd5eb018 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/get_output_before_activation.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/get_output_before_activation.cpp @@ -28,7 +28,7 @@ std::map additional_config = { }; } // namespace -INSTANTIATE_TEST_CASE_P(OutputBeforeActivation, OutputBeforeActivation, +INSTANTIATE_TEST_SUITE_P(OutputBeforeActivation, OutputBeforeActivation, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GNA), ::testing::Values(InferenceEngine::Precision::FP32), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/handling_orientation_conv.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/handling_orientation_conv.cpp index f752ba54f1d6cc..ed51ceb4c59b63 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/handling_orientation_conv.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/handling_orientation_conv.cpp @@ -21,7 +21,7 @@ const std::vector> configs = { } }; -INSTANTIATE_TEST_CASE_P(smoke_handling_orientation, HandlingOrientationClass, +INSTANTIATE_TEST_SUITE_P(smoke_handling_orientation, HandlingOrientationClass, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/input_conv.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/input_conv.cpp index 3fad3b60d27d46..9b15275b91d1e9 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/input_conv.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/input_conv.cpp @@ -46,7 +46,7 @@ std::vector addReshape = { false }; -INSTANTIATE_TEST_CASE_P(smoke_InputConv, InputConvTest, +INSTANTIATE_TEST_SUITE_P(smoke_InputConv, InputConvTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/input_split_concat.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/input_split_concat.cpp index 2e667336fecbe9..873b8518a795e9 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/input_split_concat.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/input_split_concat.cpp @@ -30,7 +30,7 @@ const std::vector> inputShapes = { {1, 320} }; -INSTANTIATE_TEST_CASE_P(smoke_InputSplitConcat, InputSplitConcatTest, +INSTANTIATE_TEST_SUITE_P(smoke_InputSplitConcat, InputSplitConcatTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/matmul_squeeze_add.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/matmul_squeeze_add.cpp index 17afb8cd5a8af3..2b638fad70e8b7 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/matmul_squeeze_add.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/matmul_squeeze_add.cpp @@ -39,7 +39,7 @@ std::vector output_sizes = { 8 }; -INSTANTIATE_TEST_CASE_P(smoke_MatmulSqueezeAdd, MatmulSqueezeAddTest, +INSTANTIATE_TEST_SUITE_P(smoke_MatmulSqueezeAdd, MatmulSqueezeAddTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/memory_LSTMCell.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/memory_LSTMCell.cpp index 5818a40d4ecaa2..db2ca0e8f743b6 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/memory_LSTMCell.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/memory_LSTMCell.cpp @@ -36,7 +36,7 @@ namespace SubgraphTestsDefinitions { {"GNA_SCALE_FACTOR_0", "1638.4"}, }; - INSTANTIATE_TEST_CASE_P(smoke_MemoryLSTMCellTest, MemoryLSTMCellTest, + INSTANTIATE_TEST_SUITE_P(smoke_MemoryLSTMCellTest, MemoryLSTMCellTest, ::testing::Combine( ::testing::ValuesIn(transformation), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/memory_eltwise_reshape_concat.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/memory_eltwise_reshape_concat.cpp index bf287286ac59db..13264c36b312c6 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/memory_eltwise_reshape_concat.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/memory_eltwise_reshape_concat.cpp @@ -26,7 +26,7 @@ std::map additional_config = { }; } // namespace -INSTANTIATE_TEST_CASE_P(smoke_MemoryEltwiseReshapeConcatTest, MemoryEltwiseReshapeConcatTest, +INSTANTIATE_TEST_SUITE_P(smoke_MemoryEltwiseReshapeConcatTest, MemoryEltwiseReshapeConcatTest, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GNA), ::testing::Values(InferenceEngine::Precision::FP32), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/multioutput_eltwise_squeeze_eltwise.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/multioutput_eltwise_squeeze_eltwise.cpp index 0055e18c95bafc..b937e07b93a1e5 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/multioutput_eltwise_squeeze_eltwise.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/multioutput_eltwise_squeeze_eltwise.cpp @@ -31,7 +31,7 @@ namespace { InferenceEngine::Precision::FP16, }; - INSTANTIATE_TEST_CASE_P(smoke_multioutput_eltwise_identity, MultioutputEltwiseReshapeEltwise, + INSTANTIATE_TEST_SUITE_P(smoke_multioutput_eltwise_identity, MultioutputEltwiseReshapeEltwise, ::testing::Combine( ::testing::ValuesIn(inputs), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/multiple_LSTMCell.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/multiple_LSTMCell.cpp index d59c023773bb38..3f695bd1bffefa 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/multiple_LSTMCell.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/multiple_LSTMCell.cpp @@ -38,7 +38,7 @@ std::map additional_config = { } // namespace -INSTANTIATE_TEST_CASE_P(MultipleLSTMCellTest, MultipleLSTMCellTest, +INSTANTIATE_TEST_SUITE_P(MultipleLSTMCellTest, MultipleLSTMCellTest, ::testing::Combine( ::testing::ValuesIn(transformation), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/multiple_concat.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/multiple_concat.cpp index 0cb64714ffb702..2cd3e96ee992e3 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/multiple_concat.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/multiple_concat.cpp @@ -34,7 +34,7 @@ std::map additional_config = { }; } // namespace -INSTANTIATE_TEST_CASE_P(I_aligned_C_aligned, MultipleConcatTest, +INSTANTIATE_TEST_SUITE_P(I_aligned_C_aligned, MultipleConcatTest, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GNA), ::testing::Values(InferenceEngine::Precision::FP32), @@ -43,7 +43,7 @@ INSTANTIATE_TEST_CASE_P(I_aligned_C_aligned, MultipleConcatTest, ::testing::Values(additional_config)), MultipleConcatTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(I_aligned_C_unaligned, MultipleConcatTest, +INSTANTIATE_TEST_SUITE_P(I_aligned_C_unaligned, MultipleConcatTest, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GNA), ::testing::Values(InferenceEngine::Precision::FP32), @@ -52,7 +52,7 @@ INSTANTIATE_TEST_CASE_P(I_aligned_C_unaligned, MultipleConcatTest, ::testing::Values(additional_config)), MultipleConcatTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(I_unaligned_C_aligned, MultipleConcatTest, +INSTANTIATE_TEST_SUITE_P(I_unaligned_C_aligned, MultipleConcatTest, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GNA), ::testing::Values(InferenceEngine::Precision::FP32), @@ -61,7 +61,7 @@ INSTANTIATE_TEST_CASE_P(I_unaligned_C_aligned, MultipleConcatTest, ::testing::Values(additional_config)), MultipleConcatTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(I_unaligned_C_unaligned, MultipleConcatTest, +INSTANTIATE_TEST_SUITE_P(I_unaligned_C_unaligned, MultipleConcatTest, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GNA), ::testing::Values(InferenceEngine::Precision::FP32), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/negative_memory_layer_offset.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/negative_memory_layer_offset.cpp index 36b530e4469501..c1d038f0463219 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/negative_memory_layer_offset.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/negative_memory_layer_offset.cpp @@ -32,7 +32,7 @@ namespace { 100 }; - INSTANTIATE_TEST_CASE_P(smoke_negative_memory_layer_offset, NegativeMemoryOffsetTest, + INSTANTIATE_TEST_SUITE_P(smoke_negative_memory_layer_offset, NegativeMemoryOffsetTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/perm_conv_perm_concat.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/perm_conv_perm_concat.cpp index e6fd385f5f825e..f5a812e40ea614 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/perm_conv_perm_concat.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/perm_conv_perm_concat.cpp @@ -32,7 +32,7 @@ std::map additional_config = { } // namespace namespace SubgraphTestsDefinitions { - INSTANTIATE_TEST_CASE_P(smoke_basic, PermConvPermConcat, + INSTANTIATE_TEST_SUITE_P(smoke_basic, PermConvPermConcat, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/reshape_permute_conv_permute_reshape_act.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/reshape_permute_conv_permute_reshape_act.cpp index a07908927c1d0c..08a665e4e06c91 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/reshape_permute_conv_permute_reshape_act.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/reshape_permute_conv_permute_reshape_act.cpp @@ -35,7 +35,7 @@ std::map additional_config = { }; namespace SubgraphTestsDefinitions { - INSTANTIATE_TEST_CASE_P(smoke_basic, ConvReshapeAct, + INSTANTIATE_TEST_SUITE_P(smoke_basic, ConvReshapeAct, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/reshape_squeeze_reshape_relu.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/reshape_squeeze_reshape_relu.cpp index 5cf777fe654281..e9163914719484 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/reshape_squeeze_reshape_relu.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/reshape_squeeze_reshape_relu.cpp @@ -38,7 +38,7 @@ namespace { ngraph::helpers::SqueezeOpType::UNSQUEEZE }; - INSTANTIATE_TEST_CASE_P(smoke_reshape_squeeze_reshape_relu, ReshapeSqueezeReshapeRelu, + INSTANTIATE_TEST_SUITE_P(smoke_reshape_squeeze_reshape_relu, ReshapeSqueezeReshapeRelu, ::testing::Combine( ::testing::ValuesIn(inputs), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/reshapre_permute_reshape.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/reshapre_permute_reshape.cpp index 27c9b22c0e87e0..f74add45bfb896 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/reshapre_permute_reshape.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/reshapre_permute_reshape.cpp @@ -22,7 +22,7 @@ namespace { InferenceEngine::Precision::FP16, }; - INSTANTIATE_TEST_CASE_P(smoke_reshape_permute_reshape, ReshapePermuteReshape, + INSTANTIATE_TEST_SUITE_P(smoke_reshape_permute_reshape, ReshapePermuteReshape, ::testing::Combine( ::testing::ValuesIn(inputs), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/scale_shift.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/scale_shift.cpp index 759413f8bd5b19..c5856c9fca5ce4 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/scale_shift.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/scale_shift.cpp @@ -42,7 +42,7 @@ namespace { InferenceEngine::Precision::FP16, }; - INSTANTIATE_TEST_CASE_P(smoke_scale_shift, ScaleShiftLayerTest, + INSTANTIATE_TEST_SUITE_P(smoke_scale_shift, ScaleShiftLayerTest, ::testing::Combine( ::testing::ValuesIn(inShapes), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/scaleshift_conv_scaleshift.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/scaleshift_conv_scaleshift.cpp index 2e476ac1f876cf..2a823babc5ee8e 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/scaleshift_conv_scaleshift.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/scaleshift_conv_scaleshift.cpp @@ -45,7 +45,7 @@ std::vector outputChannels = { 8 }; -INSTANTIATE_TEST_CASE_P(smoke_ScaleShiftAfterConvTest, ScaleShiftAfterConvTest, +INSTANTIATE_TEST_SUITE_P(smoke_ScaleShiftAfterConvTest, ScaleShiftAfterConvTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), @@ -55,7 +55,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ScaleShiftAfterConvTest, ScaleShiftAfterConvTest, ::testing::ValuesIn(outputChannels)), ScaleShiftAfterConvTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ScaleShiftBeforeConvTest, ScaleShiftBeforeConvTest, +INSTANTIATE_TEST_SUITE_P(smoke_ScaleShiftBeforeConvTest, ScaleShiftBeforeConvTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/softsign.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/softsign.cpp index 58c987151c060c..00333131e3b1cb 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/softsign.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/softsign.cpp @@ -33,7 +33,7 @@ std::vector> input_shapes = { {1, 1, 1, 100} }; -INSTANTIATE_TEST_CASE_P(smoke_Softsign, SoftsignTest, +INSTANTIATE_TEST_SUITE_P(smoke_Softsign, SoftsignTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/split_conv.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/split_conv.cpp index bf71c5e2c9de58..0b508c3b1fd794 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/split_conv.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/split_conv.cpp @@ -42,7 +42,7 @@ std::vector outputChannels = { 8 }; -INSTANTIATE_TEST_CASE_P(smoke_SplitConvTest, SplitConvTest, +INSTANTIATE_TEST_SUITE_P(smoke_SplitConvTest, SplitConvTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/split_conv_concat.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/split_conv_concat.cpp index 3a3c4e3bbba30d..755613335b30bd 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/split_conv_concat.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/split_conv_concat.cpp @@ -19,7 +19,7 @@ std::vector> inputShapes = { {1, 32, 1, 1026} }; -INSTANTIATE_TEST_CASE_P(smoke_SplitConvConcat, SplitConvConcat, +INSTANTIATE_TEST_SUITE_P(smoke_SplitConvConcat, SplitConvConcat, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(inputShapes), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/split_relu.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/split_relu.cpp index b9764b919fc821..69a5e053f726aa 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/split_relu.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/split_relu.cpp @@ -47,7 +47,7 @@ namespace { {std::string(GNA_CONFIG_KEY(COMPACT_MODE)), "NO"} }; - INSTANTIATE_TEST_CASE_P(smoke_split_connected, SplitRelu, + INSTANTIATE_TEST_SUITE_P(smoke_split_connected, SplitRelu, ::testing::Combine( ::testing::ValuesIn(inputs), ::testing::ValuesIn(connect_index), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/split_trivial_permute_concat.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/split_trivial_permute_concat.cpp index 49047d3cf8341f..1982001ed9dcd8 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/split_trivial_permute_concat.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/split_trivial_permute_concat.cpp @@ -27,7 +27,7 @@ namespace { std::vector split_axes = { 1 }; // only channels split is currently supported by gna for 4d inputs std::vector concat_axes = { 1 }; // only channels concat is currently supported by gna for 4d inputs - INSTANTIATE_TEST_CASE_P(smoke_split_trivial_permute_concat, SplitTrivialPermuteConcatTest, + INSTANTIATE_TEST_SUITE_P(smoke_split_trivial_permute_concat, SplitTrivialPermuteConcatTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/stridedslice_conv.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/stridedslice_conv.cpp index 4517005f3d7afa..c0894a2e6b406a 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/stridedslice_conv.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/stridedslice_conv.cpp @@ -36,7 +36,7 @@ std::vector outputChannels = { 8 }; -INSTANTIATE_TEST_CASE_P(smoke_SliceConvTest, SliceConvTest, +INSTANTIATE_TEST_SUITE_P(smoke_SliceConvTest, SliceConvTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GNA), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/tensor_names.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/tensor_names.cpp index 5ef074f3496285..8a1489aebbb509 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/tensor_names.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/tensor_names.cpp @@ -10,7 +10,7 @@ using namespace SubgraphTestsDefinitions; namespace { - INSTANTIATE_TEST_CASE_P(smoke_Check, TensorNamesTest, + INSTANTIATE_TEST_SUITE_P(smoke_Check, TensorNamesTest, ::testing::Values(CommonTestUtils::DEVICE_GNA), TensorNamesTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/trivial_concat.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/trivial_concat.cpp index 866080faa2a38e..aed6bf9b9ebc61 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/trivial_concat.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/trivial_concat.cpp @@ -27,7 +27,7 @@ std::map additional_config = { {"GNA_SCALE_FACTOR_0", "2000.0"}, }; -INSTANTIATE_TEST_CASE_P(smoke_trivial_concat_Basic, TrivialConcatLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_trivial_concat_Basic, TrivialConcatLayerTest, ::testing::Combine( ::testing::ValuesIn(inShapes), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/two_fake_quantize_to_fullyconnected.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/two_fake_quantize_to_fullyconnected.cpp index 5de8e1813aab9a..fb85c4334ca9a0 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/two_fake_quantize_to_fullyconnected.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/two_fake_quantize_to_fullyconnected.cpp @@ -80,7 +80,7 @@ const auto fqParams_I16 = ::testing::Combine( ::testing::ValuesIn(inputParams_I8) ); -INSTANTIATE_TEST_CASE_P(smoke_FakeQuantize_subgraph, FakeQuantizeSubgraphTest, +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantize_subgraph, FakeQuantizeSubgraphTest, ::testing::Combine( fqParams, ::testing::ValuesIn(netPrecisions), @@ -94,7 +94,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FakeQuantize_subgraph, FakeQuantizeSubgraphTest, ::testing::ValuesIn(biases)), FakeQuantizeSubgraphTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_FakeQuantize_subgraph_U8, FakeQuantizeSubgraphTest, +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantize_subgraph_U8, FakeQuantizeSubgraphTest, ::testing::Combine( fqParams_I8, ::testing::ValuesIn(netPrecisions), @@ -108,7 +108,7 @@ INSTANTIATE_TEST_CASE_P(smoke_FakeQuantize_subgraph_U8, FakeQuantizeSubgraphTest ::testing::ValuesIn(biases)), FakeQuantizeSubgraphTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_FakeQuantize_subgraph_I16, FakeQuantizeSubgraphTest, +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantize_subgraph_I16, FakeQuantizeSubgraphTest, ::testing::Combine( fqParams_I16, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/remote_blob_tests/cldnn_remote_blob_tests.cpp b/inference-engine/tests/functional/plugin/gpu/remote_blob_tests/cldnn_remote_blob_tests.cpp index 6837c0b84c33a8..30b740464a62f3 100644 --- a/inference-engine/tests/functional/plugin/gpu/remote_blob_tests/cldnn_remote_blob_tests.cpp +++ b/inference-engine/tests/functional/plugin/gpu/remote_blob_tests/cldnn_remote_blob_tests.cpp @@ -269,7 +269,7 @@ TEST_P(BatchedBlob_Test, canInputNV12) { const std::vector num_batches{1, 2, 4}; -INSTANTIATE_TEST_CASE_P(smoke_RemoteBlob, BatchedBlob_Test, ::testing::ValuesIn(num_batches), BatchedBlob_Test::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_RemoteBlob, BatchedBlob_Test, ::testing::ValuesIn(num_batches), BatchedBlob_Test::getTestCaseName); class TwoNets_Test : public CommonTestUtils::TestsCommon, public testing::WithParamInterface { void SetUp() override { @@ -357,4 +357,4 @@ TEST_P(TwoNets_Test, canInferTwoExecNets) { const std::vector num_streams{1, 2}; -INSTANTIATE_TEST_CASE_P(smoke_RemoteBlob, TwoNets_Test, ::testing::ValuesIn(num_streams), TwoNets_Test::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_RemoteBlob, TwoNets_Test, ::testing::ValuesIn(num_streams), TwoNets_Test::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/caching_tests.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/caching_tests.cpp index e840f2aa797f75..247d1482e765cd 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/caching_tests.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/caching_tests.cpp @@ -22,7 +22,7 @@ namespace { 1, 2 }; - INSTANTIATE_TEST_CASE_P(smoke_CachingSupportCase_GPU, LoadNetworkCacheTestBase, + INSTANTIATE_TEST_SUITE_P(smoke_CachingSupportCase_GPU, LoadNetworkCacheTestBase, ::testing::Combine( ::testing::ValuesIn(LoadNetworkCacheTestBase::getStandardFunctions()), ::testing::ValuesIn(precisionsGPU), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/config.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/config.cpp index a8c039e43915a4..235e82475c117b 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/config.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/config.cpp @@ -50,21 +50,21 @@ namespace { }; IE_SUPPRESS_DEPRECATED_END - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, IncorrectConfigTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(inconfigs)), IncorrectConfigTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, IncorrectConfigTests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, IncorrectConfigTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(multiinconfigs)), IncorrectConfigTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, IncorrectConfigTests, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, IncorrectConfigTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), @@ -111,63 +111,63 @@ namespace { {{InferenceEngine::KEY_AUTO_DEVICE_LIST , std::string(CommonTestUtils::DEVICE_CPU) + "," + CommonTestUtils::DEVICE_GPU}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectConfigAPITests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, CorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(conf)), CorrectConfigAPITests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_GPU_BehaviorTests, CorrectConfigAPITests, + INSTANTIATE_TEST_SUITE_P(smoke_GPU_BehaviorTests, CorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(conf_gpu)), CorrectConfigAPITests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, CorrectConfigAPITests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, CorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(multiconf)), CorrectConfigAPITests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, CorrectConfigAPITests, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, CorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), ::testing::ValuesIn(autoconf)), CorrectConfigAPITests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_AutoCG_BehaviorTests, CorrectConfigAPITests, + INSTANTIATE_TEST_SUITE_P(smoke_AutoCG_BehaviorTests, CorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), ::testing::ValuesIn(auto_cpu_gpu_conf)), CorrectConfigAPITests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigAPITests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, IncorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(conf)), IncorrectConfigAPITests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, IncorrectConfigAPITests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, IncorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(multiconf)), IncorrectConfigAPITests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, IncorrectConfigAPITests, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, IncorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), ::testing::ValuesIn(autoinconfigs)), IncorrectConfigAPITests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_AutoCG_BehaviorTests, IncorrectConfigAPITests, + INSTANTIATE_TEST_SUITE_P(smoke_AutoCG_BehaviorTests, IncorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/core_integration.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/core_integration.cpp index 68b23831e47944..a260d3a28d334a 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/core_integration.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/core_integration.cpp @@ -19,12 +19,12 @@ namespace { // IE Class Common tests with // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassCommon, IEClassBasicTestP, ::testing::Values(std::make_pair("clDNNPlugin", "GPU")) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassNetworkTestP, IEClassNetworkTestP, ::testing::Values("GPU") ); @@ -33,62 +33,62 @@ INSTANTIATE_TEST_CASE_P( // IE Class GetMetric // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetMetricTest, IEClassGetMetricTest_SUPPORTED_CONFIG_KEYS, ::testing::Values("GPU", "MULTI", "HETERO", "AUTO") ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetMetricTest, IEClassGetMetricTest_SUPPORTED_METRICS, ::testing::Values("GPU", "MULTI", "HETERO", "AUTO") ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetMetricTest, IEClassGetMetricTest_AVAILABLE_DEVICES, ::testing::Values("GPU") ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetMetricTest, IEClassGetMetricTest_FULL_DEVICE_NAME, ::testing::Values("GPU", "MULTI", "HETERO", "AUTO") ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetMetricTest, IEClassGetMetricTest_OPTIMIZATION_CAPABILITIES, ::testing::Values("GPU") ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetMetricTest, IEClassGetMetricTest_DEVICE_GOPS, ::testing::Values("GPU") ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetMetricTest, IEClassGetMetricTest_DEVICE_TYPE, ::testing::Values("GPU") ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetMetricTest, IEClassGetMetricTest_RANGE_FOR_ASYNC_INFER_REQUESTS, ::testing::Values("GPU") ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetMetricTest, IEClassGetMetricTest_RANGE_FOR_STREAMS, ::testing::Values("GPU") ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetMetricTest, IEClassGetMetricTest_ThrowUnsupported, ::testing::Values("GPU", "MULTI", "HETERO", "AUTO") ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetConfigTest, IEClassGetConfigTest_ThrowUnsupported, ::testing::Values("GPU", "MULTI", "HETERO", "AUTO") ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetAvailableDevices, IEClassGetAvailableDevices, ::testing::Values("GPU") ); @@ -110,7 +110,7 @@ TEST_P(IEClassGetMetricTest_GPU_DEVICE_TOTAL_MEM_SIZE, GetMetricAndPrintNoThrow) ASSERT_METRIC_SUPPORTED(GPU_METRIC_KEY(DEVICE_TOTAL_MEM_SIZE)); } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetMetricTest, IEClassGetMetricTest_GPU_DEVICE_TOTAL_MEM_SIZE, ::testing::Values("GPU") ); @@ -129,7 +129,7 @@ TEST_P(IEClassGetMetricTest_GPU_UARCH_VERSION, GetMetricAndPrintNoThrow) { ASSERT_METRIC_SUPPORTED(GPU_METRIC_KEY(UARCH_VERSION)); } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetMetricTest, IEClassGetMetricTest_GPU_UARCH_VERSION, ::testing::Values("GPU") ); @@ -148,7 +148,7 @@ TEST_P(IEClassGetMetricTest_GPU_EXECUTION_UNITS_COUNT, GetMetricAndPrintNoThrow) ASSERT_METRIC_SUPPORTED(GPU_METRIC_KEY(EXECUTION_UNITS_COUNT)); } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetMetricTest, IEClassGetMetricTest_GPU_EXECUTION_UNITS_COUNT, ::testing::Values("GPU") ); @@ -157,7 +157,7 @@ INSTANTIATE_TEST_CASE_P( // IE Class GetConfig // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassGetConfigTest, IEClassGetConfigTest, ::testing::Values("GPU") ); @@ -166,27 +166,27 @@ INSTANTIATE_TEST_CASE_P( // Executable Network GetMetric // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassExecutableNetworkGetMetricTest, IEClassExecutableNetworkGetMetricTest_OPTIMAL_NUMBER_OF_INFER_REQUESTS, ::testing::Values("GPU", "MULTI:GPU", "HETERO:GPU", "AUTO:GPU,CPU") ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassExecutableNetworkGetMetricTest, IEClassExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS, ::testing::Values("GPU", "MULTI:GPU", "HETERO:GPU", "AUTO:GPU,CPU") ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassExecutableNetworkGetMetricTest, IEClassExecutableNetworkGetMetricTest_SUPPORTED_METRICS, ::testing::Values("GPU", "MULTI:GPU", "HETERO:GPU", "AUTO:GPU,CPU") ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassExecutableNetworkGetMetricTest, IEClassExecutableNetworkGetMetricTest_NETWORK_NAME, ::testing::Values("GPU", "MULTI:GPU", "HETERO:GPU", "AUTO:GPU,CPU") ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassExecutableNetworkGetMetricTest, IEClassExecutableNetworkGetMetricTest_ThrowsUnsupported, ::testing::Values("GPU", "MULTI:GPU", "HETERO:GPU", "AUTO:GPU,CPU") ); @@ -195,12 +195,12 @@ INSTANTIATE_TEST_CASE_P( // Executable Network GetConfig / SetConfig // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassExecutableNetworkGetConfigTest, IEClassExecutableNetworkGetConfigTest, ::testing::Values("GPU") ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassExecutableNetworkSetConfigTest, IEClassExecutableNetworkSetConfigTest, ::testing::Values("GPU") ); @@ -209,41 +209,41 @@ INSTANTIATE_TEST_CASE_P( // Hetero Executable Network GetMetric // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassHeteroExecutableNetworlGetMetricTest, IEClassHeteroExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS, ::testing::Values("GPU") ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassHeteroExecutableNetworlGetMetricTest, IEClassHeteroExecutableNetworkGetMetricTest_SUPPORTED_METRICS, ::testing::Values("GPU") ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassHeteroExecutableNetworlGetMetricTest, IEClassHeteroExecutableNetworkGetMetricTest_NETWORK_NAME, ::testing::Values("GPU") ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nightly_IEClassHeteroExecutableNetworlGetMetricTest, IEClassHeteroExecutableNetworkGetMetricTest_TARGET_FALLBACK, ::testing::Values("GPU") ); // IE Class Query network -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassQueryNetworkTest, IEClassQueryNetworkTest, ::testing::Values("GPU") ); // IE Class Load network -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassLoadNetworkTest, IEClassLoadNetworkTest, ::testing::Values("GPU") ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassHeteroExecutableNetworkGetMetricTest, IEClassLoadNetworkAfterCoreRecreateTest, ::testing::Values("GPU") ); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/core_threading_tests.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/core_threading_tests.cpp index db06501a896e3b..779e0212d0fd33 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/core_threading_tests.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/core_threading_tests.cpp @@ -39,9 +39,9 @@ TEST_P(CoreThreadingTestsWithIterations, smoke_LoadNetwork_RemoteContext) { }, numIterations, numThreads); } -INSTANTIATE_TEST_CASE_P(smoke_GPU, CoreThreadingTests, testing::ValuesIn(params), CoreThreadingTests::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_GPU, CoreThreadingTests, testing::ValuesIn(params), CoreThreadingTests::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_GPU, CoreThreadingTestsWithIterations, +INSTANTIATE_TEST_SUITE_P(smoke_GPU, CoreThreadingTestsWithIterations, testing::Combine(testing::ValuesIn(params), testing::Values(4), testing::Values(20), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/cpp_holders.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/cpp_holders.cpp index 329db9f216d115..12ad85d05be141 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/cpp_holders.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/cpp_holders.cpp @@ -18,7 +18,7 @@ namespace { {2, 1, 0} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, HoldersTest, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, HoldersTest, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(orders)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/exec_graph_info.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/exec_graph_info.cpp index 1a3ca13252c030..8b220fad0326a6 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/exec_graph_info.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/exec_graph_info.cpp @@ -15,7 +15,7 @@ namespace { {}, }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, ExecGraphTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, ExecGraphTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request.cpp index 866f4b1cb68ac5..c04aeffd48bc97 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request.cpp @@ -26,28 +26,28 @@ namespace { {{InferenceEngine::KEY_AUTO_DEVICE_LIST , std::string(CommonTestUtils::DEVICE_CPU) + "," + CommonTestUtils::DEVICE_GPU}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferRequestTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferRequestTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::Values(std::map({}))), InferRequestTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, InferRequestTests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, InferRequestTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(configs)), InferRequestTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, InferRequestTests, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, InferRequestTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), ::testing::ValuesIn(autoconfigs)), InferRequestTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_AutoCG_BehaviorTests, InferRequestTests, + INSTANTIATE_TEST_SUITE_P(smoke_AutoCG_BehaviorTests, InferRequestTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_callback.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_callback.cpp index 3d9963a41d791f..a0108e84339d4a 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_callback.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_callback.cpp @@ -27,28 +27,28 @@ const std::vector> auto_cpu_gpu_conf = { {{InferenceEngine::KEY_AUTO_DEVICE_LIST , std::string(CommonTestUtils::DEVICE_CPU) + "," + CommonTestUtils::DEVICE_GPU}} }; -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CallbackTests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, CallbackTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(configs)), CallbackTests::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, CallbackTests, +INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, CallbackTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(multiConfigs)), CallbackTests::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, CallbackTests, +INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, CallbackTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), ::testing::ValuesIn(autoConfigs)), CallbackTests::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_AutoCG_BehaviorTests, CallbackTests, +INSTANTIATE_TEST_SUITE_P(smoke_AutoCG_BehaviorTests, CallbackTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_config.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_config.cpp index 0072369d920734..f48cd8451a71f3 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_config.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_config.cpp @@ -27,28 +27,28 @@ namespace { {{InferenceEngine::KEY_AUTO_DEVICE_LIST , std::string(CommonTestUtils::DEVICE_CPU) + "," + CommonTestUtils::DEVICE_GPU}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferConfigTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferConfigTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(configs)), InferConfigTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, InferConfigTests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, InferConfigTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(multiConfigs)), InferConfigTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, InferConfigTests, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, InferConfigTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), ::testing::ValuesIn(autoConfigs)), InferConfigTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_AutoCG_BehaviorTests, InferConfigTests, + INSTANTIATE_TEST_SUITE_P(smoke_AutoCG_BehaviorTests, InferConfigTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_input.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_input.cpp index 59f4dd21677c24..f63be4c8854326 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_input.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_input.cpp @@ -33,28 +33,28 @@ namespace { {{InferenceEngine::KEY_AUTO_DEVICE_LIST , std::string(CommonTestUtils::DEVICE_CPU) + "," + CommonTestUtils::DEVICE_GPU}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferRequestInputTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferRequestInputTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(configs)), InferRequestInputTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, InferRequestInputTests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, InferRequestInputTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(multiConfigs)), InferRequestInputTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, InferRequestInputTests, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, InferRequestInputTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), ::testing::ValuesIn(autoConfigs)), InferRequestInputTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_AutoCG_BehaviorTests, InferRequestInputTests, + INSTANTIATE_TEST_SUITE_P(smoke_AutoCG_BehaviorTests, InferRequestInputTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_output.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_output.cpp index 1135f6d9f7d8e4..638106e6a75a52 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_output.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/infer_request_output.cpp @@ -29,28 +29,28 @@ namespace { {{InferenceEngine::KEY_AUTO_DEVICE_LIST , std::string(CommonTestUtils::DEVICE_CPU) + "," + CommonTestUtils::DEVICE_GPU}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferRequestOutputTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferRequestOutputTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(configs)), InferRequestOutputTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, InferRequestOutputTests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, InferRequestOutputTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(multiConfigs)), InferRequestOutputTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, InferRequestOutputTests, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, InferRequestOutputTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), ::testing::ValuesIn(autoConfigs)), InferRequestOutputTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_AutoCG_BehaviorTests, InferRequestOutputTests, + INSTANTIATE_TEST_SUITE_P(smoke_AutoCG_BehaviorTests, InferRequestOutputTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/layout.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/layout.cpp index 6748fc58c50c32..c705c3a9d76d73 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/layout.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/layout.cpp @@ -20,7 +20,7 @@ namespace { { 1, 3 }, }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, LayoutTest, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, LayoutTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_GPU), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/perf_counters.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/perf_counters.cpp index d8a89ef317d425..cc6a2a14a24fa7 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/perf_counters.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/perf_counters.cpp @@ -14,14 +14,14 @@ namespace { {{ MULTI_CONFIG_KEY(DEVICE_PRIORITIES) , CommonTestUtils::DEVICE_GPU}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, PerfCountersTest, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, PerfCountersTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(configs)), PerfCountersTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, PerfCountersTest, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, PerfCountersTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_MULTI), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/set_blob_of_kind.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/set_blob_of_kind.cpp index 936abfe826dd8d..f055c0b0ec9c8c 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/set_blob_of_kind.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/set_blob_of_kind.cpp @@ -17,7 +17,7 @@ const std::vector blobKinds = { const SetBlobOfKindConfig gpuConfig{}; //nothing special -INSTANTIATE_TEST_CASE_P(smoke_SetBlobOfKindGPU, SetBlobOfKindTest, +INSTANTIATE_TEST_SUITE_P(smoke_SetBlobOfKindGPU, SetBlobOfKindTest, ::testing::Combine(::testing::ValuesIn(blobKinds), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::Values(gpuConfig)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/set_preprocess.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/set_preprocess.cpp index 80c1fdccca9800..136cb96436ca61 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/set_preprocess.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/set_preprocess.cpp @@ -30,28 +30,28 @@ namespace { {{InferenceEngine::KEY_AUTO_DEVICE_LIST , std::string(CommonTestUtils::DEVICE_CPU) + "," + CommonTestUtils::DEVICE_GPU}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, PreprocessTest, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, PreprocessTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(configs)), PreprocessTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, PreprocessTest, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, PreprocessTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(multiConfigs)), PreprocessTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, PreprocessTest, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, PreprocessTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), ::testing::ValuesIn(autoConfigs)), PreprocessTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_AutoCG_BehaviorTests, PreprocessTest, + INSTANTIATE_TEST_SUITE_P(smoke_AutoCG_BehaviorTests, PreprocessTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), @@ -73,7 +73,7 @@ namespace { InferenceEngine::Layout::NHWC }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, PreprocessConversionTest, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, PreprocessConversionTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(ioPrecisions), @@ -87,7 +87,7 @@ namespace { ::testing::ValuesIn(configs)), PreprocessConversionTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, PreprocessDynamicallyInSetBlobTest, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, PreprocessDynamicallyInSetBlobTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Bool(), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/test_plugin.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/test_plugin.cpp index 729bf57c64ac8a..36790623b489ab 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/test_plugin.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/test_plugin.cpp @@ -47,84 +47,84 @@ namespace { {{InferenceEngine::PluginConfigParams::KEY_GPU_THROUGHPUT_STREAMS, InferenceEngine::PluginConfigParams::GPU_THROUGHPUT_AUTO}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, BehaviorTestOutput, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, BehaviorTestOutput, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(configsOutput)), BehaviorTestOutput::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, BehaviorTestOutput, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, BehaviorTestOutput, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(MultiConfigsInputOutput)), BehaviorTestOutput::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, BehaviorTestOutput, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, BehaviorTestOutput, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), ::testing::ValuesIn(AutoConfigs)), BehaviorTestOutput::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_AutoCG_BehaviorTests, BehaviorTestOutput, + INSTANTIATE_TEST_SUITE_P(smoke_AutoCG_BehaviorTests, BehaviorTestOutput, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), ::testing::ValuesIn(auto_cpu_gpu_conf)), BehaviorTestOutput::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, BehaviorTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, BehaviorTests, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(configs)), BehaviorTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, BehaviorTests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, BehaviorTests, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(MultiConfigs)), BehaviorTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, BehaviorTests, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, BehaviorTests, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_AUTO), ::testing::ValuesIn(AutoConfigs)), BehaviorTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_AutoCG_BehaviorTests, BehaviorTests, + INSTANTIATE_TEST_SUITE_P(smoke_AutoCG_BehaviorTests, BehaviorTests, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_AUTO), ::testing::ValuesIn(auto_cpu_gpu_conf)), BehaviorTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, BehaviorTestInput, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, BehaviorTestInput, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(configsInput)), BehaviorTestInput::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, BehaviorTestInput, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, BehaviorTestInput, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(MultiConfigsInputOutput)), BehaviorTestInput::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, BehaviorTestInput, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, BehaviorTestInput, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), ::testing::ValuesIn(AutoConfigs)), BehaviorTestInput::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_AutoCG_BehaviorTests, BehaviorTestInput, + INSTANTIATE_TEST_SUITE_P(smoke_AutoCG_BehaviorTests, BehaviorTestInput, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_AUTO), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/version.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/version.cpp index 81ec5b808d3116..6b69c22855ecee 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/version.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/version.cpp @@ -26,35 +26,35 @@ namespace { {{ HETERO_CONFIG_KEY(DUMP_GRAPH_DOT) , CommonTestUtils::DEVICE_GPU}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, VersionTest, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, VersionTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(configs)), VersionTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, VersionTest, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, VersionTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(Multiconfigs)), VersionTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Auto_BehaviorTests, VersionTest, + INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, VersionTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_AUTO), ::testing::ValuesIn(Autoconfigs)), VersionTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_AutoCG_BehaviorTests, VersionTest, + INSTANTIATE_TEST_SUITE_P(smoke_AutoCG_BehaviorTests, VersionTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_AUTO), ::testing::ValuesIn(auto_cpu_gpu_conf)), VersionTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Hetero_BehaviorTests, VersionTest, + INSTANTIATE_TEST_SUITE_P(smoke_Hetero_BehaviorTests, VersionTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_HETERO), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/configuration_tests/dynamic_batch.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/configuration_tests/dynamic_batch.cpp index 6f3cac60cfb74c..36a13d4ea5f733 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/configuration_tests/dynamic_batch.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/configuration_tests/dynamic_batch.cpp @@ -20,7 +20,7 @@ std::map additional_config = { } // namespace -INSTANTIATE_TEST_CASE_P(smoke_DynamicBatchTest_async, DynamicBatchTest, +INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchTest_async, DynamicBatchTest, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::Values(InferenceEngine::Precision::FP32), @@ -29,7 +29,7 @@ INSTANTIATE_TEST_CASE_P(smoke_DynamicBatchTest_async, DynamicBatchTest, ::testing::Values(additional_config)), DynamicBatchTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_DynamicBatchTest_sync, DynamicBatchTest, +INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchTest_sync, DynamicBatchTest, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::Values(InferenceEngine::Precision::FP32), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/execution_graph_tests/unique_node_names.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/execution_graph_tests/unique_node_names.cpp index d3689b4492c894..275d8f179fbf9e 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/execution_graph_tests/unique_node_names.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/execution_graph_tests/unique_node_names.cpp @@ -15,7 +15,7 @@ const std::vector netPrecisions = { InferenceEngine::Precision::FP32 }; -INSTANTIATE_TEST_CASE_P(smoke_NoReshape, ExecGraphUniqueNodeNames, +INSTANTIATE_TEST_SUITE_P(smoke_NoReshape, ExecGraphUniqueNodeNames, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::SizeVector({1, 2, 5, 5})), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/hetero/query_network.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/hetero/query_network.cpp index a23cf6b936b24a..893f1fce09bdf0 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/hetero/query_network.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/hetero/query_network.cpp @@ -15,7 +15,7 @@ auto ConvBias = ngraph::builder::subgraph::makeConvBias(); auto SplitConvConcat = ngraph::builder::subgraph::makeNestedSplitConvConcat(); auto BranchSplitConvConcat = ngraph::builder::subgraph::makeSplitConvConcatNestedInBranch(); -INSTANTIATE_TEST_CASE_P(smoke_FullySupportedTopologies, QueryNetworkTest, +INSTANTIATE_TEST_SUITE_P(smoke_FullySupportedTopologies, QueryNetworkTest, ::testing::Combine( ::testing::Values("GPU", "HETERO:GPU,CPU", "MULTI:GPU,CPU"), ::testing::Values(ConvBias, SplitConvConcat, BranchSplitConvConcat)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp index 8a33dacde43fea..7b51e051339c3c 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp @@ -68,7 +68,7 @@ const std::vector params = { { {}, {}, false }, { {}, {}, true }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, AddTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, AddTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/clamp_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/clamp_transformation.cpp index 078146f1819c10..408cbb550714c0 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/clamp_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/clamp_transformation.cpp @@ -76,7 +76,7 @@ const std::vector params = { } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ClampTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ClampTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_transformation.cpp index 57cca3618123ae..f22eb9f63a142f 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_transformation.cpp @@ -39,7 +39,7 @@ const std::vector testValues = { }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ConcatTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_child_and_output.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_child_and_output.cpp index b5702fe243114e..f53eb289438546 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_child_and_output.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_child_and_output.cpp @@ -42,7 +42,7 @@ const std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ConcatWithChildAndOutputTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatWithChildAndOutputTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 6, 10, 10 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_different_precision_on_children.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_different_precision_on_children.cpp index 0b2834837164b1..d7605440afe6f5 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_different_precision_on_children.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_different_precision_on_children.cpp @@ -45,7 +45,7 @@ const std::vector testValues = { const std::vector multiChannel = { true/*, false*/ }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ConcatWithDifferentChildrenTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatWithDifferentChildrenTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 10, 10 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_intermediate_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_intermediate_transformation.cpp index 16daf1cbc1d377..00f5467b33c714 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_intermediate_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_intermediate_transformation.cpp @@ -26,7 +26,7 @@ const std::vector tras const std::vector transparentIntermediateValues = { true, false }; const std::vector multiChannelValues = { /*true,*/ false }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ConcatWithIntermediateTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatWithIntermediateTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp index c009d2694f02d4..2dc3a2b4fdecd7 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp @@ -23,7 +23,7 @@ const std::vector tras LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8() }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ConcatWithNeighborsGraphTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatWithNeighborsGraphTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp index cf789286f7f97f..2c969a1775fd4d 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp @@ -45,7 +45,7 @@ const std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ConcatWithSplitTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatWithSplitTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 6, 10, 10 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp index 697059e3ce24bf..e656b6f3ff54e6 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp @@ -111,7 +111,7 @@ const std::vector outputShapes = { { 16, 16 } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ConvolutionBackpropDataTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConvolutionBackpropDataTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(inputShapes), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_qdq_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_qdq_transformation.cpp index 43928a7ec1caee..bb1bd0cb8dcb5e 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_qdq_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_qdq_transformation.cpp @@ -238,7 +238,7 @@ const std::vector shapes = { { 4, 3, 4, 4 } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ConvolutionQDqTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConvolutionQDqTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(shapes), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_transformation.cpp index 2a0c8ff14fc7ac..6b76d8a9eaafa2 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_transformation.cpp @@ -64,7 +64,7 @@ const std::vector params } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ConvolutionTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConvolutionTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), @@ -88,7 +88,7 @@ const std::vector i } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ConvolutionWIthIncorrectWeightsTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConvolutionWIthIncorrectWeightsTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/depth_to_space_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/depth_to_space_transformation.cpp index 2075bfe18d76d2..85e076155cc443 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/depth_to_space_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/depth_to_space_transformation.cpp @@ -34,7 +34,7 @@ const auto DepthToSpaceBS2 = ::testing::Combine( ::testing::Values(2) ); -INSTANTIATE_TEST_CASE_P(LPT_BS2, DepthToSpaceTransformation, DepthToSpaceBS2, DepthToSpaceTransformation::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(LPT_BS2, DepthToSpaceTransformation, DepthToSpaceBS2, DepthToSpaceTransformation::getTestCaseName); const std::vector inputShapesBS3 = { {1, 9, 3, 3}, {2, 27, 5, 4} @@ -48,5 +48,5 @@ const auto DepthToSpaceBS3 = ::testing::Combine( ::testing::Values(3) ); -INSTANTIATE_TEST_CASE_P(LPT_BS3, DepthToSpaceTransformation, DepthToSpaceBS3, DepthToSpaceTransformation::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(LPT_BS3, DepthToSpaceTransformation, DepthToSpaceBS3, DepthToSpaceTransformation::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp index 45ca8e01a7d7c9..ea2587340fff7b 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp @@ -27,7 +27,7 @@ const std::vector fakeQuantizes = // FakeQuantizeOnData -INSTANTIATE_TEST_CASE_P(smoke_LPT, FakeQuantizeAndAvgPoolTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, FakeQuantizeAndAvgPoolTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp index 56e2ecd29a9ac3..ba1bc5bb20a674 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp @@ -27,7 +27,7 @@ const std::vector fakeQuantizes = // FakeQuantizeOnData -INSTANTIATE_TEST_CASE_P(smoke_LPT, FakeQuantizeAndMaxPoolTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, FakeQuantizeAndMaxPoolTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp index dc48bcb9941561..fa47c845378a6d 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp @@ -28,7 +28,7 @@ const std::vector testValues = } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, FakeQuantizeAndTwoOutputBranchesWithConvolutionTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, FakeQuantizeAndTwoOutputBranchesWithConvolutionTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp index f70b1cdde5fdad..2b67ce0720cd28 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp @@ -57,7 +57,7 @@ const std::vector testVa }; // GPU issue -INSTANTIATE_TEST_CASE_P(DISABLED_LPT, FakeQuantizePrecisionSelectionTransformation, +INSTANTIATE_TEST_SUITE_P(DISABLED_LPT, FakeQuantizePrecisionSelectionTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp index 62fb144c785e6b..fe2ae3c55d6d7c 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp @@ -59,7 +59,7 @@ const std::vector fakeQuantizeOnDataValues = { // { 256ul, { 1ul }, { -1.28f} , { 1.27f } } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, FakeQuantizeTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, FakeQuantizeTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp index 963b6e6f28a7a3..6e780a94ed2e09 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp @@ -101,7 +101,7 @@ const std::vector fakeQuanti } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, FakeQuantizeWithNotOptimalTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, FakeQuantizeWithNotOptimalTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fully_connected_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fully_connected_transformation.cpp index db3665f6aaf317..45bf73121d2bfa 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fully_connected_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fully_connected_transformation.cpp @@ -41,7 +41,7 @@ const std::vector tras LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams() }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, FullyConnectedTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, FullyConnectedTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(shapes), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_convert_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_convert_transformation.cpp index 01013dd414758b..537f95363e17df 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_convert_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_convert_transformation.cpp @@ -32,7 +32,7 @@ const std::vector deqOperat const std::vector constInput = { true, false }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, FuseConvertTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, FuseConvertTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::ValuesIn(inputAndQuantizationShapes), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp index 175141ef885d45..f78feda5ce6443 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp @@ -34,7 +34,7 @@ const std::vector fakeQuantizeOnD // }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, FuseFakeQuantizeAndScaleShiftTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, FuseFakeQuantizeAndScaleShiftTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 9, 9 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_transformation.cpp index 3125575ec5f1ab..07b0f0a8ad8cd5 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_transformation.cpp @@ -104,7 +104,7 @@ const std::vector testValues = { }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, FuseFakeQuantizeTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, FuseFakeQuantizeTransformation, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(testValues)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.cpp index 2cc508be12b9dd..58fee1528c2ad1 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.cpp @@ -30,7 +30,7 @@ namespace { }, }; - INSTANTIATE_TEST_CASE_P(smoke_LPT, FuseMultiplyToFakeQuantizeTransformation, + INSTANTIATE_TEST_SUITE_P(smoke_LPT, FuseMultiplyToFakeQuantizeTransformation, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(testValues)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.cpp index 35861a9830aeb1..0b25acfc569d04 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.cpp @@ -30,7 +30,7 @@ namespace { }, }; - INSTANTIATE_TEST_CASE_P(smoke_LPT, FuseSubtractToFakeQuantizeTransformation, + INSTANTIATE_TEST_SUITE_P(smoke_LPT, FuseSubtractToFakeQuantizeTransformation, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(testValues)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp index ca0f60b35f4e91..cd2b40ceb26e41 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp @@ -24,7 +24,7 @@ const std::vector trasformationParamValues = { LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsI8I8() }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, GemmTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, GemmTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(dimensions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp index 624d933188b7fa..18325c824f4f49 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp @@ -97,7 +97,7 @@ const std::vector pa } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, GroupConvolutionTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, GroupConvolutionTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/groupconvolution_qdq_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/groupconvolution_qdq_transformation.cpp index 5f07e42d4b2ef2..b95d0e7f8c6521 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/groupconvolution_qdq_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/groupconvolution_qdq_transformation.cpp @@ -492,7 +492,7 @@ const std::vector shapes = { { 1, 4, 7, 7 } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, GroupConvolutionQDqTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, GroupConvolutionQDqTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(shapes), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/interpolate_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/interpolate_transformation.cpp index c00f6bf695e56a..33135bb451a019 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/interpolate_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/interpolate_transformation.cpp @@ -48,5 +48,5 @@ const auto combineValues = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(interpAttrs)); -INSTANTIATE_TEST_CASE_P(smoke_LPT, InterpolateTransformation, combineValues, InterpolateTransformation::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_LPT, InterpolateTransformation, combineValues, InterpolateTransformation::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp index 5afaefb92be6ec..6d0df41c7f48ab 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp @@ -30,7 +30,7 @@ std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, MatMulTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, MatMulTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::Values(ngraph::Shape({ 1, 384, 1024 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_with_constant_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_with_constant_transformation.cpp index bff6d09467bd9a..919f2dd9388b68 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_with_constant_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_with_constant_transformation.cpp @@ -91,7 +91,7 @@ std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, MatMulWithConstantTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, MatMulWithConstantTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp index a3d2c4eac12975..8759d2903bc228 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp @@ -27,7 +27,7 @@ const std::vector> inputShapes = { std::pair({ 1, 16 }, { 16, 10 }) }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, MatMulWithOptimizedConstantFakeQuantizeTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, MatMulWithOptimizedConstantFakeQuantizeTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(inputShapes), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_to_group_convolution_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_to_group_convolution_transformation.cpp index 2bb1abfb9ed980..4f60cc1a3bb765 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_to_group_convolution_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_to_group_convolution_transformation.cpp @@ -23,7 +23,7 @@ const std::vector fqOnData = { { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 25.5f }, { -12.8f }, { 12.7f } } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, MultiplyToGroupConvolutionTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, MultiplyToGroupConvolutionTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::ValuesIn(inputShapes), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_transformation.cpp index b107cff023fd83..6c294cb6d9c1d2 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_transformation.cpp @@ -67,7 +67,7 @@ const std::vector params = { { {}, {}, false }, { {}, {}, true }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, MultiplyTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, MultiplyTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp index dba8fb64ad7848..083b4e8357b7ff 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp @@ -21,7 +21,7 @@ const std::vector values = { } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, MultiplyWithOneParentTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, MultiplyWithOneParentTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp index 7599e34484d56b..da5fbff9e91836 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp @@ -21,7 +21,7 @@ namespace { const std::vector normalizeVariance = { true, false }; - INSTANTIATE_TEST_CASE_P(smoke_LPT, MVNTransformation, + INSTANTIATE_TEST_SUITE_P(smoke_LPT, MVNTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::ValuesIn(inputAndQuantizationShapes), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/normalize_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/normalize_transformation.cpp index 0fa6be4ada6a15..fe30318107a6b6 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/normalize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/normalize_transformation.cpp @@ -29,7 +29,7 @@ const std::vector fuseMultiplyValues = { true, false }; const std::vector shiftValues = { true, false }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, NormalizeL2Transformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, NormalizeL2Transformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::ValuesIn(inputAndQuantizationShapes), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations.cpp index 487a99a379d74d..ebbc0ce20030b6 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations.cpp @@ -19,7 +19,7 @@ const std::vector trasformationParamValues = { LayerTestsUtils::LayerTransformationParamsFactory::createParams() }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, OutputLayersHandlingInTransformations, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, OutputLayersHandlingInTransformations, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations_for_concat.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations_for_concat.cpp index 1901cc4a219bb8..dfc77a5cc4c557 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations_for_concat.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations_for_concat.cpp @@ -19,7 +19,7 @@ const std::vector trasformationParamValues = { LayerTestsUtils::LayerTransformationParamsFactory::createParams() }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, OutputLayersHandlingInTransformationsForConcat, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, OutputLayersHandlingInTransformationsForConcat, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations_for_concat_multi_channel.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations_for_concat_multi_channel.cpp index cbf5ccb423c59d..98ea4e3340518d 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations_for_concat_multi_channel.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/output_layers_handling_in_transformations_for_concat_multi_channel.cpp @@ -19,7 +19,7 @@ const std::vector trasformationParamValues = { LayerTestsUtils::LayerTransformationParamsFactory::createParams() }; -INSTANTIATE_TEST_CASE_P(DISABLED_smoke_LPT, OutputLayersHandlingInTransformationsForConcatMultiChannel, +INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_LPT, OutputLayersHandlingInTransformationsForConcatMultiChannel, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp index e65229a9f81d55..aea8e1be969c10 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp @@ -25,7 +25,7 @@ std::vector testValues = { }; // PRelu in low precision is not supported in GPU -INSTANTIATE_TEST_CASE_P(DISABLED_LPT, PReluTransformation, +INSTANTIATE_TEST_SUITE_P(DISABLED_LPT, PReluTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/pull_reshape_through_dequantization_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/pull_reshape_through_dequantization_transformation.cpp index aecad435daafe5..04c82dfaff6cca 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/pull_reshape_through_dequantization_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/pull_reshape_through_dequantization_transformation.cpp @@ -70,7 +70,7 @@ const std::vector dequantizationOnWeightElementwiseConstantShapes { ngraph::Shape({1, 16}) } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, PullReshapeThroughDequantizationTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, PullReshapeThroughDequantizationTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(inputShapes), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_max_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_max_transformation.cpp index 8e4d6d49682e23..f53880f5df795a 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_max_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_max_transformation.cpp @@ -88,7 +88,7 @@ const std::vector params = }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ReduceMaxTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ReduceMaxTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 10, 10 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_mean_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_mean_transformation.cpp index 138117498749fc..5b343f98747ee1 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_mean_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_mean_transformation.cpp @@ -88,7 +88,7 @@ const std::vector params = }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ReduceMeanTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ReduceMeanTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 10, 10 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_min_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_min_transformation.cpp index 3fcc88fdecd7f4..89aeb83f875b27 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_min_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_min_transformation.cpp @@ -88,7 +88,7 @@ const std::vector params = }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ReduceMinTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ReduceMinTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 10, 10 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_sum_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_sum_transformation.cpp index 9b2d2fa9341b23..46cd094fcc13fc 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_sum_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_sum_transformation.cpp @@ -78,7 +78,7 @@ const std::vector params = }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ReduceSumTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ReduceSumTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 10, 10 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp index 219a64f9c005cf..a1d65bbf658c07 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp @@ -24,7 +24,7 @@ std::vector testValues = { { { 256ul, ngraph::Shape({}), {-12.8f / 2.f}, {12.7f}, {-12.8f / 2.f}, {12.7f} }, true } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ReluTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ReluTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp index 46ca94e9cb7e97..a8d40ca957f76f 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp @@ -52,7 +52,7 @@ const std::vector params = { }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ReshapeTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ReshapeTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/shuffle_channels_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/shuffle_channels_transformation.cpp index e1fae4213e9c0b..19a0cfbd01503a 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/shuffle_channels_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/shuffle_channels_transformation.cpp @@ -77,7 +77,7 @@ const std::vector par }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ShuffleChannelsTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, ShuffleChannelsTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(inputShapes), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/split_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/split_transformation.cpp index 9f9ce9f544b8cc..18535a437dafee 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/split_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/split_transformation.cpp @@ -84,7 +84,7 @@ const std::vector params = { } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, SplitTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, SplitTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/squeeze_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/squeeze_transformation.cpp index 36512fd4e58258..586a1ac9695b18 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/squeeze_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/squeeze_transformation.cpp @@ -46,7 +46,7 @@ namespace { } }; - INSTANTIATE_TEST_CASE_P(smoke_LPT, SqueezeTransformation, + INSTANTIATE_TEST_SUITE_P(smoke_LPT, SqueezeTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/strided_slice_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/strided_slice_transformation.cpp index bc974c50570f9f..477fb83a1587c3 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/strided_slice_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/strided_slice_transformation.cpp @@ -86,7 +86,7 @@ const std::vector params } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, StridedSliceTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, StridedSliceTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 24, 24 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.cpp index 41d4109cb5bc90..b9a63e37cfbf85 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.cpp @@ -57,7 +57,7 @@ const std::vector testVal }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, SubtractMultiplyToMultiplyAddTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, SubtractMultiplyToMultiplyAddTransformation, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(testValues)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp index 4bdb067f4b9116..f58f01d8fc5724 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp @@ -20,7 +20,7 @@ const std::vector trasformationParamValues = { LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams() }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, SubtractTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, SubtractTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp index e3cdb1f93ff173..7377d54b6cd9e0 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp @@ -24,7 +24,7 @@ const std::vector perTensorValues = { true, false }; const std::vector transposeChannelDimValues = { true, false }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, TransposeAfterMatMulTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, TransposeAfterMatMulTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/transpose_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/transpose_transformation.cpp index e35f3cde45ab43..b1913f592d1ff0 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/transpose_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/transpose_transformation.cpp @@ -41,7 +41,7 @@ const std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, TransposeTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, TransposeTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/unsqueeze_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/unsqueeze_transformation.cpp index 9397d7482ebf74..5bb19861240c52 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/unsqueeze_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/unsqueeze_transformation.cpp @@ -51,7 +51,7 @@ namespace { } }; - INSTANTIATE_TEST_CASE_P(smoke_LPT, UnsqueezeTransformation, + INSTANTIATE_TEST_SUITE_P(smoke_LPT, UnsqueezeTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/variadic_split_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/variadic_split_transformation.cpp index 6b83a4a0bf426d..95f4e4487aa4d9 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/variadic_split_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/variadic_split_transformation.cpp @@ -90,7 +90,7 @@ const std::vector param }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, VariadicSplitTransformation, +INSTANTIATE_TEST_SUITE_P(smoke_LPT, VariadicSplitTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/multi/gpu_remote_blob_tests.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/multi/gpu_remote_blob_tests.cpp index 4fffb2cad6e157..26e2655607d283 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/multi/gpu_remote_blob_tests.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/multi/gpu_remote_blob_tests.cpp @@ -16,7 +16,7 @@ const std::vector device_names_and_support_for_remot #endif }; -INSTANTIATE_TEST_CASE_P(smoke_RemoteBlobMultiGPU, MultiDevice_SupportTest, +INSTANTIATE_TEST_SUITE_P(smoke_RemoteBlobMultiGPU, MultiDevice_SupportTest, ::testing::ValuesIn(device_names_and_support_for_remote_blobs), MultiDevice_SupportTest::getTestCaseName); TEST_P(MultiDevice_Test, cannotInferRemoteBlobIfNotInitializedForDevice) { @@ -53,5 +53,5 @@ const std::vector device_names_and_support_for_remote_blobs2 { {"GPU.1"}, // another GPU (the test will test its presence), different OCL contexts }; -INSTANTIATE_TEST_CASE_P(smoke_RemoteBlobMultiInitializedWithoutGPU, MultiDevice_Test, +INSTANTIATE_TEST_SUITE_P(smoke_RemoteBlobMultiInitializedWithoutGPU, MultiDevice_Test, ::testing::ValuesIn(device_names_and_support_for_remote_blobs2), MultiDevice_Test::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/ngraph_conversion_tests/conv_bias_fusion.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/ngraph_conversion_tests/conv_bias_fusion.cpp index 37471e8cc67041..fe6a2dda21374b 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/ngraph_conversion_tests/conv_bias_fusion.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/ngraph_conversion_tests/conv_bias_fusion.cpp @@ -9,6 +9,6 @@ using namespace NGraphConversionTestsDefinitions; namespace { -INSTANTIATE_TEST_CASE_P(smoke_Basic, ConvBiasFusion, ::testing::Values(CommonTestUtils::DEVICE_GPU), ConvBiasFusion::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Basic, ConvBiasFusion, ::testing::Values(CommonTestUtils::DEVICE_GPU), ConvBiasFusion::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/ngraph_conversion_tests/plugin_specific_ngraph_conversion.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/ngraph_conversion_tests/plugin_specific_ngraph_conversion.cpp index bbfc01e3f1877f..3774936fe78725 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/ngraph_conversion_tests/plugin_specific_ngraph_conversion.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/ngraph_conversion_tests/plugin_specific_ngraph_conversion.cpp @@ -9,6 +9,6 @@ using namespace NGraphConversionTestsDefinitions; namespace { -INSTANTIATE_TEST_CASE_P(smoke_Basic, PluginSpecificConversion, ::testing::Values("GPU"), PluginSpecificConversion::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Basic, PluginSpecificConversion, ::testing::Values("GPU"), PluginSpecificConversion::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/activation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/activation.cpp index e7e1f8a63440a1..c62641c0b4cab7 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/activation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/activation.cpp @@ -95,9 +95,9 @@ const auto basicPreluCases = ::testing::Combine( ); -INSTANTIATE_TEST_CASE_P(smoke_Activation_Basic, ActivationLayerTest, basicCases, ActivationLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Activation_Basic_Prelu, ActivationLayerTest, basicPreluCases, ActivationLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Activation_Basic, ActivationLayerTest, basicCases, ActivationLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Activation_Basic_Prelu, ActivationLayerTest, basicPreluCases, ActivationLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Activation_Basic, ActivationParamLayerTest, basicPreluCases, ActivationLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Activation_Basic, ActivationParamLayerTest, basicPreluCases, ActivationLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/batch_norm.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/batch_norm.cpp index 94c15c93018ce4..fe89b264d9a3ea 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/batch_norm.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/batch_norm.cpp @@ -39,7 +39,7 @@ const auto batchNormParams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_BatchNorm, BatchNormLayerTest, batchNormParams, diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/batch_to_space.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/batch_to_space.cpp index 7194d632344120..1a05db98a6a4f8 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/batch_to_space.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/batch_to_space.cpp @@ -119,6 +119,6 @@ batchToSpaceParamsTuple bts_only_test_cases[] = { CommonTestUtils::DEVICE_GPU) }; -INSTANTIATE_TEST_CASE_P(smoke_CLDNN, BatchToSpaceLayerTest, ::testing::ValuesIn(bts_only_test_cases), +INSTANTIATE_TEST_SUITE_P(smoke_CLDNN, BatchToSpaceLayerTest, ::testing::ValuesIn(bts_only_test_cases), BatchToSpaceLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/broadcast.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/broadcast.cpp index aa055e9b5282f0..979552b9933b54 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/broadcast.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/broadcast.cpp @@ -38,7 +38,7 @@ const auto numpyBroadcastParams1 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_TestNumpyBroadcast1, BroadcastLayerTest, numpyBroadcastParams1, @@ -54,7 +54,7 @@ const auto numpyBroadcastParams2 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_TestNumpyBroadcast2, BroadcastLayerTest, numpyBroadcastParams2, @@ -84,7 +84,7 @@ const auto bidirectionalBroadcastParams1 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_TestBidirectionalBroadcast1, BroadcastLayerTest, bidirectionalBroadcastParams1, @@ -100,7 +100,7 @@ const auto bidirectionalBroadcastParams2 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_TestBidirectionalBroadcast2, BroadcastLayerTest, bidirectionalBroadcastParams2, @@ -116,7 +116,7 @@ const auto bidirectionalBroadcastParams3 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_TestBidirectionalBroadcast3, BroadcastLayerTest, bidirectionalBroadcastParams3, @@ -149,7 +149,7 @@ const auto explicitBroadcastParams1 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_TestExplicitBroadcast1, BroadcastLayerTest, explicitBroadcastParams1, @@ -165,7 +165,7 @@ const auto explicitBroadcastParams2 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_TestExplicitBroadcast2, BroadcastLayerTest, explicitBroadcastParams2, diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/comparison.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/comparison.cpp index 877bd366e0e9a6..e92cdf4f41763b 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/comparison.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/comparison.cpp @@ -50,6 +50,6 @@ const auto ComparisonTestParams = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::Values(additional_config)); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs, ComparisonLayerTest, ComparisonTestParams, ComparisonLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs, ComparisonLayerTest, ComparisonTestParams, ComparisonLayerTest::getTestCaseName); } // namespace \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/concat.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/concat.cpp index bde5e2fc19bbe7..a57887e900fbab 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/concat.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/concat.cpp @@ -24,7 +24,7 @@ std::vector netPrecisions = {InferenceEngine::Precis InferenceEngine::Precision::I64}; -INSTANTIATE_TEST_CASE_P(smoke_NoReshape, ConcatLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_NoReshape, ConcatLayerTest, ::testing::Combine( ::testing::ValuesIn(axes), ::testing::ValuesIn(inShapes), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/convert.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/convert.cpp index 130360d4cdf472..e404be39af6039 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/convert.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/convert.cpp @@ -19,7 +19,7 @@ const std::vector netPrecisions = { InferenceEngine::Precision::I8, }; -INSTANTIATE_TEST_CASE_P(smoke_NoReshape, ConvertLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_NoReshape, ConvertLayerTest, ::testing::Combine( ::testing::Values(inShape), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/convert_like.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/convert_like.cpp index 8b0208ea8cc51c..c55dc9d85bd6a6 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/convert_like.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/convert_like.cpp @@ -19,7 +19,7 @@ const std::vector netPrecisions = { InferenceEngine::Precision::I8, }; -INSTANTIATE_TEST_CASE_P(smoke_NoReshape, ConvertLikeLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_NoReshape, ConvertLikeLayerTest, ::testing::Combine( ::testing::Values(inShape), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/convolution.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/convolution.cpp index 6b4c1bea5cf523..94e77a1a4a7201 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/convolution.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/convolution.cpp @@ -50,7 +50,7 @@ const auto conv2DParams_AutoPadValid = ::testing::Combine( ::testing::Values(ngraph::op::PadType::VALID) ); -INSTANTIATE_TEST_CASE_P(smoke_Convolution2D_ExplicitPadding, ConvolutionLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Convolution2D_ExplicitPadding, ConvolutionLayerTest, ::testing::Combine( conv2DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -62,7 +62,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Convolution2D_ExplicitPadding, ConvolutionLayerTes ::testing::Values(CommonTestUtils::DEVICE_GPU)), ConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Convolution2D_AutoPadValid, ConvolutionLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Convolution2D_AutoPadValid, ConvolutionLayerTest, ::testing::Combine( conv2DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), @@ -97,7 +97,7 @@ const auto conv3DParams = ::testing::Combine( ::testing::Values(ngraph::op::PadType::EXPLICIT) ); -INSTANTIATE_TEST_CASE_P(smoke_Convolution3D_Basic1, ConvolutionLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Convolution3D_Basic1, ConvolutionLayerTest, ::testing::Combine( conv3DParams, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/convolution_backprop_data.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/convolution_backprop_data.cpp index f404d932bc86a0..a34a5b75e1b711 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/convolution_backprop_data.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/convolution_backprop_data.cpp @@ -56,7 +56,7 @@ const auto conv2DParams_AutoPadValid = ::testing::Combine( ::testing::ValuesIn(emptyOutputPadding) ); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_ExplicitPadding, ConvolutionBackpropLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData2D_ExplicitPadding, ConvolutionBackpropLayerTest, ::testing::Combine( conv2DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions2D), @@ -69,7 +69,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_ExplicitPadding, Convolu ::testing::Values(CommonTestUtils::DEVICE_GPU)), ConvolutionBackpropLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_AutoPadValid, ConvolutionBackpropLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData2D_AutoPadValid, ConvolutionBackpropLayerTest, ::testing::Combine( conv2DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions2D), @@ -106,7 +106,7 @@ const auto conv2DParams_AutoPadValid_output_padding = ::testing::Combine( ::testing::ValuesIn(outputPadding2D) ); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_ExplicitPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData2D_ExplicitPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, ::testing::Combine( conv2DParams_AutoPadValid_output_padding, ::testing::ValuesIn(netPrecisions), @@ -119,7 +119,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_ExplicitPadding_OutputPa ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvolutionBackpropLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData2D_AutoPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData2D_AutoPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, ::testing::Combine( conv2DParams_ExplicitPadding_output_padding, ::testing::ValuesIn(netPrecisions), @@ -166,7 +166,7 @@ const auto conv3DParams_AutoPadValid = ::testing::Combine( ::testing::ValuesIn(emptyOutputPadding) ); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_ExplicitPadding, ConvolutionBackpropLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData3D_ExplicitPadding, ConvolutionBackpropLayerTest, ::testing::Combine( conv3DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions3D), @@ -179,7 +179,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_ExplicitPadding, Convolu ::testing::Values(CommonTestUtils::DEVICE_GPU)), ConvolutionBackpropLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_AutoPadValid, ConvolutionBackpropLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData3D_AutoPadValid, ConvolutionBackpropLayerTest, ::testing::Combine( conv3DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions3D), @@ -216,7 +216,7 @@ const auto conv3DParams_AutoPadValid_output_padding = ::testing::Combine( ::testing::ValuesIn(outputPadding3D) ); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_ExplicitPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData3D_ExplicitPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, ::testing::Combine( conv3DParams_AutoPadValid_output_padding, ::testing::ValuesIn(netPrecisions), @@ -229,7 +229,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_ExplicitPadding_OutputPa ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvolutionBackpropLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ConvolutionBackpropData3D_AutoPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackpropData3D_AutoPadding_OutputPaddingDefined, ConvolutionBackpropLayerTest, ::testing::Combine( conv3DParams_ExplicitPadding_output_padding, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/ctc_greedy_decoder.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/ctc_greedy_decoder.cpp index a9faeddaa46325..3c423614217ab0 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/ctc_greedy_decoder.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/ctc_greedy_decoder.cpp @@ -34,7 +34,7 @@ const auto basicCases = ::testing::Combine( ::testing::ValuesIn(mergeRepeated), ::testing::Values(CommonTestUtils::DEVICE_GPU)); -INSTANTIATE_TEST_CASE_P(smoke_CtcGreedyDecoderBasic, CTCGreedyDecoderLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_CtcGreedyDecoderBasic, CTCGreedyDecoderLayerTest, basicCases, CTCGreedyDecoderLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/ctc_greedy_decoder_seq_len.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/ctc_greedy_decoder_seq_len.cpp index 497686924b2af4..04042aa4de5020 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/ctc_greedy_decoder_seq_len.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/ctc_greedy_decoder_seq_len.cpp @@ -33,11 +33,11 @@ const auto basicCases = ::testing::Combine( ::testing::ValuesIn(mergeRepeated), ::testing::Values(CommonTestUtils::DEVICE_GPU)); -INSTANTIATE_TEST_CASE_P(smoke_set1, CTCGreedyDecoderSeqLenLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_set1, CTCGreedyDecoderSeqLenLayerTest, basicCases, CTCGreedyDecoderSeqLenLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_set2, CTCGreedyDecoderSeqLenLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_set2, CTCGreedyDecoderSeqLenLayerTest, ::testing::Combine( ::testing::ValuesIn(std::vector>{{2, 8, 11}, {4, 10, 55}}), ::testing::ValuesIn(std::vector{5, 100}), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/cum_sum.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/cum_sum.cpp index b92a453693f27e..12cebb9f8d4565 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/cum_sum.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/cum_sum.cpp @@ -26,7 +26,7 @@ std::vector precisions = {InferenceEngine::Precision std::vector> shape1d = {{10}}; std::vector axis1d = {0}; -INSTANTIATE_TEST_CASE_P(smoke_CumSum1D, CumSumLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_CumSum1D, CumSumLayerTest, ::testing::Combine( ::testing::ValuesIn(shape1d), ::testing::ValuesIn(precisions), @@ -36,7 +36,7 @@ INSTANTIATE_TEST_CASE_P(smoke_CumSum1D, CumSumLayerTest, ::testing::Values(CommonTestUtils::DEVICE_GPU)), CumSumLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_CumSum, CumSumLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_CumSum, CumSumLayerTest, ::testing::Combine( ::testing::ValuesIn(inShapes), ::testing::ValuesIn(precisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/depth_to_space.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/depth_to_space.cpp index 4e42493d567978..89b8bc7de845d1 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/depth_to_space.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/depth_to_space.cpp @@ -34,7 +34,7 @@ const auto DepthToSpaceBS2 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P(smoke_DepthToSpaceBS2, DepthToSpaceLayerTest, DepthToSpaceBS2, DepthToSpaceLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_DepthToSpaceBS2, DepthToSpaceLayerTest, DepthToSpaceBS2, DepthToSpaceLayerTest::getTestCaseName); const std::vector> inputShapesBS3 = { {1, 9, 1, 1}, {1, 9, 2, 2}, {1, 9, 3, 3}, {2, 36, 3, 3}, {2, 27, 5, 4}, @@ -48,6 +48,6 @@ const auto DepthToSpaceBS3 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P(smoke_DepthToSpaceBS3, DepthToSpaceLayerTest, DepthToSpaceBS3, DepthToSpaceLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_DepthToSpaceBS3, DepthToSpaceLayerTest, DepthToSpaceBS3, DepthToSpaceLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/detection_output.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/detection_output.cpp index e12fdbc6ea2779..7be886fbaadc42 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/detection_output.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/detection_output.cpp @@ -56,7 +56,7 @@ const auto params3Inputs = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P(smoke_DetectionOutput3In, DetectionOutputLayerTest, params3Inputs, DetectionOutputLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_DetectionOutput3In, DetectionOutputLayerTest, params3Inputs, DetectionOutputLayerTest::getTestCaseName); /* =============== 5 inputs cases =============== */ @@ -80,6 +80,6 @@ const auto params5Inputs = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P(smoke_DetectionOutput5In, DetectionOutputLayerTest, params5Inputs, DetectionOutputLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_DetectionOutput5In, DetectionOutputLayerTest, params5Inputs, DetectionOutputLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/eltwise.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/eltwise.cpp index 3cd2feebf58399..fc411847cb9159 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/eltwise.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/eltwise.cpp @@ -66,7 +66,7 @@ const auto multiply_params = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::Values(additional_config)); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs, EltwiseLayerTest, multiply_params, EltwiseLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs, EltwiseLayerTest, multiply_params, EltwiseLayerTest::getTestCaseName); std::vector>> inShapesSingleThread = { diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/embedding_bag_offsets_sum.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/embedding_bag_offsets_sum.cpp index afb5945fa19cd9..cc88c9527bd580 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/embedding_bag_offsets_sum.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/embedding_bag_offsets_sum.cpp @@ -49,7 +49,7 @@ const auto embBagOffsetSumArgSet = ::testing::Combine( ::testing::ValuesIn(offsets), ::testing::ValuesIn(default_index), ::testing::ValuesIn(with_weights), ::testing::ValuesIn(with_default_index)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke, EmbeddingBagOffsetsSumLayerTest, ::testing::Combine(embBagOffsetSumArgSet, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/embedding_bag_packed_sum.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/embedding_bag_packed_sum.cpp index 2981ac862663d2..c7379c8bb8ff86 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/embedding_bag_packed_sum.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/embedding_bag_packed_sum.cpp @@ -39,7 +39,7 @@ const auto embBagPackedSumArgSet = ::testing::Combine( ::testing::ValuesIn(emb_table_shape), ::testing::ValuesIn(indices), ::testing::ValuesIn(with_weights)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke, EmbeddingBagPackedSumLayerTest, ::testing::Combine(embBagPackedSumArgSet, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/embedding_segments_sum.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/embedding_segments_sum.cpp index 34caed6822dce9..5239daf682057b 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/embedding_segments_sum.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/embedding_segments_sum.cpp @@ -45,7 +45,7 @@ const auto embSegmentsSumArgSet = ::testing::Combine( ::testing::ValuesIn(default_index), ::testing::ValuesIn(with_weights), ::testing::ValuesIn(with_default_index)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke, EmbeddingSegmentsSumLayerTest, ::testing::Combine(embSegmentsSumArgSet, ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(indPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/extract_image_patches.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/extract_image_patches.cpp index 1749c0db0963c7..ca6db6370842c0 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/extract_image_patches.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/extract_image_patches.cpp @@ -56,7 +56,7 @@ const auto extractImagePatchesParamsSet = ::testing::Combine( ::testing::ValuesIn(autoPads) ); -INSTANTIATE_TEST_CASE_P(smoke_layers_GPU, ExtractImagePatchesTest, +INSTANTIATE_TEST_SUITE_P(smoke_layers_GPU, ExtractImagePatchesTest, ::testing::Combine( ::testing::ValuesIn(inDataShape), ::testing::ValuesIn(kernels), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/fake_quantize.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/fake_quantize.cpp index ba1e5a6ca67136..a5223cb641c697 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/fake_quantize.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/fake_quantize.cpp @@ -32,7 +32,7 @@ const auto fqParams = ::testing::Combine( ::testing::Values(inputParams) ); -INSTANTIATE_TEST_CASE_P(smoke_FakeQuantize, FakeQuantizeLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantize, FakeQuantizeLayerTest, ::testing::Combine( fqParams, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gather.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gather.cpp index 2d98eba92b5aa4..6af03cf397d85c 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gather.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gather.cpp @@ -126,28 +126,28 @@ const auto GatherAxes4i8b2 = testing::Combine( testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Gather7Axes4i4b1, Gather7LayerTest, GatherAxes4i4b1, Gather7LayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Gather7Axes4i4b2, Gather7LayerTest, GatherAxes4i4b1, Gather7LayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Gather7Axes4i8b1, Gather7LayerTest, GatherAxes4i8b1, Gather7LayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Gather7Axes4i8b2, Gather7LayerTest, GatherAxes4i8b2, @@ -232,7 +232,7 @@ const auto GatherAxes4 = testing::Combine( testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_GatherAxes4, GatherLayerTest, GatherAxes4, @@ -252,7 +252,7 @@ const auto Gather6dAxes4 = testing::Combine( testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Gather6dAxes4, GatherLayerTest, Gather6dAxes4, @@ -300,7 +300,7 @@ const auto GatherAxes3 = testing::Combine( testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_GatherAxes3, GatherLayerTest, GatherAxes3, @@ -320,7 +320,7 @@ const auto Gather6dAxes3 = testing::Combine( testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Gather6dAxes3, GatherLayerTest, Gather6dAxes3, @@ -369,7 +369,7 @@ const auto GatherAxes2 = testing::Combine( testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_GatherAxes2, GatherLayerTest, GatherAxes2, @@ -389,7 +389,7 @@ const auto Gather6dAxes2 = testing::Combine( testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Gather6dAxes2, GatherLayerTest, Gather6dAxes2, @@ -439,7 +439,7 @@ const auto GatherAxes1 = testing::Combine( testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_GatherAxes1, GatherLayerTest, GatherAxes1, @@ -459,7 +459,7 @@ const auto Gather6dAxes1 = testing::Combine( testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Gather6dAxes1, GatherLayerTest, Gather6dAxes1, @@ -510,7 +510,7 @@ const auto GatherAxes0 = testing::Combine( testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_GatherAxes0, GatherLayerTest, GatherAxes0, @@ -530,7 +530,7 @@ const auto Gather6dAxes0 = testing::Combine( testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Gather6dAxes0, GatherLayerTest, Gather6dAxes0, diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gather_nd.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gather_nd.cpp index be599acaef41ca..83cd36196537de 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gather_nd.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gather_nd.cpp @@ -33,7 +33,7 @@ const auto gatherNDArgsSubset1 = ::testing::Combine( ::testing::ValuesIn(std::vector({ 0, 1 })) // Batch dims ); -INSTANTIATE_TEST_CASE_P(smoke_GatherND_set1, GatherNDLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_GatherND_set1, GatherNDLayerTest, ::testing::Combine( gatherNDArgsSubset1, ::testing::ValuesIn(inputPrecisions), @@ -51,7 +51,7 @@ const auto gatherNDArgsSubset2 = ::testing::Combine( ::testing::ValuesIn(std::vector({ 1, 2 })) // Batch dims ); -INSTANTIATE_TEST_CASE_P(smoke_GatherND_set2, GatherNDLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_GatherND_set2, GatherNDLayerTest, ::testing::Combine( gatherNDArgsSubset2, ::testing::ValuesIn(inputPrecisions), @@ -69,7 +69,7 @@ const auto gatherNDArgsSubset3 = ::testing::Combine( ::testing::ValuesIn(std::vector({ 3, 4 })) // Batch dims ); -INSTANTIATE_TEST_CASE_P(smoke_GatherND_set3, GatherNDLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_GatherND_set3, GatherNDLayerTest, ::testing::Combine( gatherNDArgsSubset3, ::testing::ValuesIn(inputPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gather_tree.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gather_tree.cpp index ee09b1fa36a73a..a1b5488a1b670d 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gather_tree.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gather_tree.cpp @@ -23,7 +23,7 @@ const std::vector secondaryInputTypes = { ngraph::helpers::InputLayerType::PARAMETER }; -INSTANTIATE_TEST_CASE_P(Basic_smoke, GatherTreeLayerTest, +INSTANTIATE_TEST_SUITE_P(Basic_smoke, GatherTreeLayerTest, ::testing::Combine( ::testing::ValuesIn(inputShapes), ::testing::ValuesIn(secondaryInputTypes), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/grn.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/grn.cpp index 52c0ed6c59b140..84dd2994e85675 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/grn.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/grn.cpp @@ -27,7 +27,7 @@ namespace { ::testing::Values(0.33f, 1.1f), ::testing::Values(CommonTestUtils::DEVICE_GPU)); - INSTANTIATE_TEST_CASE_P(smoke_Grn_Basic, GrnLayerTest, + INSTANTIATE_TEST_SUITE_P(smoke_Grn_Basic, GrnLayerTest, basicCases, GrnLayerTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/group_convolution.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/group_convolution.cpp index 75a28f94315714..603433d1bfdf43 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/group_convolution.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/group_convolution.cpp @@ -45,7 +45,7 @@ const auto groupConv2DParams_AutoPadValid = ::testing::Combine( ::testing::Values(ngraph::op::PadType::VALID) ); -INSTANTIATE_TEST_CASE_P(smoke_GroupConvolution2D_ExplicitPadding, GroupConvolutionLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConvolution2D_ExplicitPadding, GroupConvolutionLayerTest, ::testing::Combine( groupConv2DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -57,7 +57,7 @@ INSTANTIATE_TEST_CASE_P(smoke_GroupConvolution2D_ExplicitPadding, GroupConvoluti ::testing::Values(CommonTestUtils::DEVICE_GPU)), GroupConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_GroupConvolution2D_AutoPadValid, GroupConvolutionLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConvolution2D_AutoPadValid, GroupConvolutionLayerTest, ::testing::Combine( groupConv2DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), @@ -97,7 +97,7 @@ const auto groupConv3DParams_AutoPadValid = ::testing::Combine( ::testing::Values(ngraph::op::PadType::VALID) ); -INSTANTIATE_TEST_CASE_P(smoke_GroupConvolution3D_ExplicitPadding, GroupConvolutionLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConvolution3D_ExplicitPadding, GroupConvolutionLayerTest, ::testing::Combine( groupConv3DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -109,7 +109,7 @@ INSTANTIATE_TEST_CASE_P(smoke_GroupConvolution3D_ExplicitPadding, GroupConvoluti ::testing::Values(CommonTestUtils::DEVICE_GPU)), GroupConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_GroupConvolution3D_AutoPadValid, GroupConvolutionLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConvolution3D_AutoPadValid, GroupConvolutionLayerTest, ::testing::Combine( groupConv3DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/group_convolution_backprop_data.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/group_convolution_backprop_data.cpp index 40e751e817a899..5e4b6db1501810 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/group_convolution_backprop_data.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/group_convolution_backprop_data.cpp @@ -48,7 +48,7 @@ const auto groupConvBackpropData2DParams_AutoPadValid = ::testing::Combine( ::testing::Values(ngraph::op::PadType::VALID) ); -INSTANTIATE_TEST_CASE_P(smoke_GroupConvBackpropData2D_ExplicitPadding, GroupConvBackpropDataLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConvBackpropData2D_ExplicitPadding, GroupConvBackpropDataLayerTest, ::testing::Combine( groupConvBackpropData2DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -60,7 +60,7 @@ INSTANTIATE_TEST_CASE_P(smoke_GroupConvBackpropData2D_ExplicitPadding, GroupConv ::testing::Values(CommonTestUtils::DEVICE_GPU)), GroupConvBackpropDataLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_GroupConvBackpropData2D_AutoPadValid, GroupConvBackpropDataLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConvBackpropData2D_AutoPadValid, GroupConvBackpropDataLayerTest, ::testing::Combine( groupConvBackpropData2DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), @@ -102,7 +102,7 @@ const auto groupConvBackpropData3DParams_AutoPadValid = ::testing::Combine( ::testing::Values(ngraph::op::PadType::VALID) ); -INSTANTIATE_TEST_CASE_P(smoke_GroupConvBackpropData3D_ExplicitPadding, GroupConvBackpropDataLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConvBackpropData3D_ExplicitPadding, GroupConvBackpropDataLayerTest, ::testing::Combine( groupConvBackpropData3DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -114,7 +114,7 @@ INSTANTIATE_TEST_CASE_P(smoke_GroupConvBackpropData3D_ExplicitPadding, GroupConv ::testing::Values(CommonTestUtils::DEVICE_GPU)), GroupConvBackpropDataLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_GroupConvBackpropData3D_AutoPadValid, GroupConvBackpropDataLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_GroupConvBackpropData3D_AutoPadValid, GroupConvBackpropDataLayerTest, ::testing::Combine( groupConvBackpropData3DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gru_cell.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gru_cell.cpp index 7224b098c9fb98..0188040bfbdb28 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gru_cell.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gru_cell.cpp @@ -21,7 +21,7 @@ namespace { std::vector netPrecisions = {InferenceEngine::Precision::FP32, InferenceEngine::Precision::FP16}; - INSTANTIATE_TEST_CASE_P(GRUCellCommon, GRUCellTest, + INSTANTIATE_TEST_SUITE_P(GRUCellCommon, GRUCellTest, ::testing::Combine( ::testing::ValuesIn(should_decompose), ::testing::ValuesIn(batch), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gru_sequence.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gru_sequence.cpp index d0033f4f4738c3..7b613dadc91c38 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gru_sequence.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gru_sequence.cpp @@ -34,7 +34,7 @@ namespace { std::vector netPrecisions = {InferenceEngine::Precision::FP32, InferenceEngine::Precision::FP16}; - INSTANTIATE_TEST_CASE_P(GRUSequenceCommonZeroClip, GRUSequenceTest, + INSTANTIATE_TEST_SUITE_P(GRUSequenceCommonZeroClip, GRUSequenceTest, ::testing::Combine( ::testing::ValuesIn(mode), ::testing::ValuesIn(seq_lengths_zero_clip), @@ -49,7 +49,7 @@ namespace { ::testing::Values(CommonTestUtils::DEVICE_GPU)), GRUSequenceTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(GRUSequenceCommonClip, GRUSequenceTest, + INSTANTIATE_TEST_SUITE_P(GRUSequenceCommonClip, GRUSequenceTest, ::testing::Combine( ::testing::ValuesIn(mode), ::testing::ValuesIn(seq_lengths_clip_non_zero), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/interpolate.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/interpolate.cpp index 0b210ebef2e4db..c26f168d62848a 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/interpolate.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/interpolate.cpp @@ -108,7 +108,7 @@ const auto interpolateCasesNearesMode = ::testing::Combine( ::testing::ValuesIn(defaultAxes), ::testing::ValuesIn(defaultScales)); -INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Basic, InterpolateLayerTest, ::testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_Interpolate_Basic, InterpolateLayerTest, ::testing::Combine( interpolateCasesWithoutNearest, ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), @@ -121,7 +121,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Basic, InterpolateLayerTest, ::testing ::testing::Values(additional_config)), InterpolateLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Nearest, InterpolateLayerTest, ::testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_Interpolate_Nearest, InterpolateLayerTest, ::testing::Combine( interpolateCasesNearesMode, ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/log_softmax.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/log_softmax.cpp index eb62a64128029e..b84f9736077590 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/log_softmax.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/log_softmax.cpp @@ -37,7 +37,7 @@ const auto params2D = testing::Combine( testing::Values(std::map()) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LogSoftmax2D, LogSoftmaxLayerTest, params2D, @@ -66,7 +66,7 @@ const auto params4D = testing::Combine( testing::Values(std::map()) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_LogSoftmax4D, LogSoftmaxLayerTest, params4D, diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/logical.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/logical.cpp index c8dd9db4c2e1ad..588cebf8a3966b 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/logical.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/logical.cpp @@ -74,8 +74,8 @@ const auto LogicalTestParamsNot = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::Values(additional_config)); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefs, LogicalLayerTest, LogicalTestParams, LogicalLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs, LogicalLayerTest, LogicalTestParams, LogicalLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_CompareWithRefsNot, LogicalLayerTest, LogicalTestParamsNot, LogicalLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefsNot, LogicalLayerTest, LogicalTestParamsNot, LogicalLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/lrn.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/lrn.cpp index b513e61a137421..d9b7099399d4c3 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/lrn.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/lrn.cpp @@ -21,7 +21,7 @@ const double beta = 2; const double bias = 1.0; const size_t size = 5; -INSTANTIATE_TEST_CASE_P(smoke_LrnCheck, LrnLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_LrnCheck, LrnLayerTest, ::testing::Combine(::testing::Values(alpha), ::testing::Values(beta), ::testing::Values(bias), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/lstm_cell.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/lstm_cell.cpp index b9267eb552d08a..855a0e432621de 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/lstm_cell.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/lstm_cell.cpp @@ -23,7 +23,7 @@ std::vector clip{0.f, 0.7f}; std::vector netPrecisions = {InferenceEngine::Precision::FP32, InferenceEngine::Precision::FP16}; -INSTANTIATE_TEST_CASE_P(LSTMCellCommon, LSTMCellTest, +INSTANTIATE_TEST_SUITE_P(LSTMCellCommon, LSTMCellTest, ::testing::Combine( ::testing::ValuesIn(should_decompose), ::testing::ValuesIn(batch), @@ -35,7 +35,7 @@ INSTANTIATE_TEST_CASE_P(LSTMCellCommon, LSTMCellTest, ::testing::Values(CommonTestUtils::DEVICE_GPU)), LSTMCellTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_LSTMCellCommon, LSTMCellTest, +INSTANTIATE_TEST_SUITE_P(smoke_LSTMCellCommon, LSTMCellTest, ::testing::Combine( ::testing::ValuesIn(should_decompose), ::testing::ValuesIn(batch), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/lstm_sequence.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/lstm_sequence.cpp index d79cee69eea5d5..604931349eca9a 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/lstm_sequence.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/lstm_sequence.cpp @@ -36,7 +36,7 @@ std::vector direction = {ngraph::op::Rec std::vector netPrecisions = {InferenceEngine::Precision::FP32, InferenceEngine::Precision::FP16}; -INSTANTIATE_TEST_CASE_P(LSTMSequenceCommonZeroClip, LSTMSequenceTest, +INSTANTIATE_TEST_SUITE_P(LSTMSequenceCommonZeroClip, LSTMSequenceTest, ::testing::Combine( ::testing::ValuesIn(mode), ::testing::ValuesIn(seq_lengths_zero_clip), @@ -50,7 +50,7 @@ INSTANTIATE_TEST_CASE_P(LSTMSequenceCommonZeroClip, LSTMSequenceTest, ::testing::Values(CommonTestUtils::DEVICE_GPU)), LSTMSequenceTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(LSTMSequenceCommonClip, LSTMSequenceTest, +INSTANTIATE_TEST_SUITE_P(LSTMSequenceCommonClip, LSTMSequenceTest, ::testing::Combine( ::testing::ValuesIn(mode), ::testing::ValuesIn(seq_lengths_clip_non_zero), @@ -64,7 +64,7 @@ INSTANTIATE_TEST_CASE_P(LSTMSequenceCommonClip, LSTMSequenceTest, ::testing::Values(CommonTestUtils::DEVICE_GPU)), LSTMSequenceTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_LSTMSequenceCommonClip, LSTMSequenceTest, +INSTANTIATE_TEST_SUITE_P(smoke_LSTMSequenceCommonClip, LSTMSequenceTest, ::testing::Combine( ::testing::ValuesIn(mode), ::testing::ValuesIn(seq_lengths_clip_non_zero), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/mat_mul.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/mat_mul.cpp index 88a05601e2243f..757bd2955b264e 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/mat_mul.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/mat_mul.cpp @@ -26,7 +26,7 @@ std::vector secondaryInputTypes = { std::map additional_config = {}; -INSTANTIATE_TEST_CASE_P(smoke_MatMul, MatMulTest, +INSTANTIATE_TEST_SUITE_P(smoke_MatMul, MatMulTest, ::testing::Combine( ::testing::ValuesIn(shapeRelatedParams), ::testing::ValuesIn(inputPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/minimum_maximum.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/minimum_maximum.cpp index 8c1ba19aa05f15..e2af2e0d970c85 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/minimum_maximum.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/minimum_maximum.cpp @@ -35,7 +35,7 @@ const std::vector inputType = { ngraph::helpers::InputLayerType::PARAMETER, }; -INSTANTIATE_TEST_CASE_P(smoke_maximum, MaxMinLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_maximum, MaxMinLayerTest, ::testing::Combine( ::testing::ValuesIn(inShapes), ::testing::ValuesIn(opType), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/mvn.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/mvn.cpp index 97d1335c813d70..a4e83dc98732c4 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/mvn.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/mvn.cpp @@ -47,7 +47,7 @@ const auto MvnCases = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P(smoke_CLDNN_TestsMVN, MvnLayerTest, MvnCases, MvnLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CLDNN_TestsMVN, MvnLayerTest, MvnCases, MvnLayerTest::getTestCaseName); std::vector dataPrecisions = { InferenceEngine::Precision::FP32, @@ -68,7 +68,7 @@ const std::vector epsilonF = { 0.0001 }; -INSTANTIATE_TEST_CASE_P(smoke_MVN_5D, Mvn6LayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MVN_5D, Mvn6LayerTest, ::testing::Combine( ::testing::ValuesIn(std::vector>{{1, 10, 5, 7, 8}, {1, 3, 8, 9, 49}}), ::testing::ValuesIn(dataPrecisions), @@ -80,7 +80,7 @@ INSTANTIATE_TEST_CASE_P(smoke_MVN_5D, Mvn6LayerTest, ::testing::Values(CommonTestUtils::DEVICE_GPU)), Mvn6LayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MVN_4D, Mvn6LayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MVN_4D, Mvn6LayerTest, ::testing::Combine( ::testing::ValuesIn(std::vector>{{1, 10, 5, 17}, {1, 3, 8, 9}}), ::testing::ValuesIn(dataPrecisions), @@ -92,7 +92,7 @@ INSTANTIATE_TEST_CASE_P(smoke_MVN_4D, Mvn6LayerTest, ::testing::Values(CommonTestUtils::DEVICE_GPU)), Mvn6LayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MVN_3D, Mvn6LayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MVN_3D, Mvn6LayerTest, ::testing::Combine( ::testing::ValuesIn(std::vector>{{1, 32, 17}, {1, 37, 9}}), ::testing::ValuesIn(dataPrecisions), @@ -104,7 +104,7 @@ INSTANTIATE_TEST_CASE_P(smoke_MVN_3D, Mvn6LayerTest, ::testing::Values(CommonTestUtils::DEVICE_GPU)), Mvn6LayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MVN_2D, Mvn6LayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MVN_2D, Mvn6LayerTest, ::testing::Combine( ::testing::ValuesIn(std::vector>{{3, 5}, {2, 55}}), ::testing::ValuesIn(dataPrecisions), @@ -116,7 +116,7 @@ INSTANTIATE_TEST_CASE_P(smoke_MVN_2D, Mvn6LayerTest, ::testing::Values(CommonTestUtils::DEVICE_GPU)), Mvn6LayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Decomposition_1D, Mvn6LayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Decomposition_1D, Mvn6LayerTest, ::testing::Combine( ::testing::ValuesIn(std::vector>{{3}, {9}, {55}}), ::testing::ValuesIn(dataPrecisions), @@ -128,7 +128,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Decomposition_1D, Mvn6LayerTest, ::testing::Values(CommonTestUtils::DEVICE_GPU)), Mvn6LayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Decomposition_3D, Mvn6LayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Decomposition_3D, Mvn6LayerTest, ::testing::Combine( ::testing::ValuesIn(std::vector>{{1, 32, 17}, {1, 37, 9}}), ::testing::ValuesIn(dataPrecisions), @@ -140,7 +140,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Decomposition_3D, Mvn6LayerTest, ::testing::Values(CommonTestUtils::DEVICE_GPU)), Mvn6LayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Decomposition_4D, Mvn6LayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Decomposition_4D, Mvn6LayerTest, ::testing::Combine( ::testing::ValuesIn(std::vector>{{1, 16, 5, 8}, {2, 19, 5, 10}}), ::testing::ValuesIn(dataPrecisions), @@ -152,7 +152,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Decomposition_4D, Mvn6LayerTest, ::testing::Values(CommonTestUtils::DEVICE_GPU)), Mvn6LayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Decomposition_6D, Mvn6LayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Decomposition_6D, Mvn6LayerTest, ::testing::Combine( ::testing::ValuesIn(std::vector>{{1, 3, 5, 4, 2, 6}}), ::testing::ValuesIn(dataPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/non_max_suppression.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/non_max_suppression.cpp index 47abf07e3ce53c..c402ba66ec441f 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/non_max_suppression.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/non_max_suppression.cpp @@ -39,4 +39,4 @@ const auto nmsParams = ::testing::Combine(::testing::ValuesIn(inShapeParams), ::testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P(smoke_NmsLayerTest, NmsLayerTest, nmsParams, NmsLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_NmsLayerTest, NmsLayerTest, nmsParams, NmsLayerTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/normalize_l2.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/normalize_l2.cpp index 438e26ed039fd1..6a3632f00f0a03 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/normalize_l2.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/normalize_l2.cpp @@ -34,7 +34,7 @@ const auto normL2params = testing::Combine( testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_NormalizeL2, NormalizeL2LayerTest, normL2params, diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/pad.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/pad.cpp index 1d2d3ab67913e2..8e8a3f018aaf0d 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/pad.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/pad.cpp @@ -36,7 +36,7 @@ const auto pad2DConstparams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Pad2DConst, PadLayerTest, pad2DConstparams, @@ -56,7 +56,7 @@ const auto pad2Dparams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Pad2D, PadLayerTest, pad2Dparams, @@ -79,7 +79,7 @@ const auto pad4DConstparams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Pad4DConst, PadLayerTest, pad4DConstparams, @@ -99,7 +99,7 @@ const auto pad4Dparams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Pad4D, PadLayerTest, pad4Dparams, diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/pooling.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/pooling.cpp index ff326a2d0a4c78..bf4c365ae954e9 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/pooling.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/pooling.cpp @@ -40,7 +40,7 @@ const auto maxPool_ExplicitPad_FloorRounding_Params = ::testing::Combine( ::testing::Values(false) // placeholder value - exclude pad not applicable for max pooling ); -INSTANTIATE_TEST_CASE_P(smoke_MaxPool_ExplicitPad_FloorRpunding, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_ExplicitPad_FloorRpunding, PoolingLayerTest, ::testing::Combine( maxPool_ExplicitPad_FloorRounding_Params, ::testing::ValuesIn(netPrecisions), @@ -65,7 +65,7 @@ const auto maxPool_ExplicitPad_CeilRounding_Params = ::testing::Combine( ::testing::Values(false) // placeholder value - exclude pad not applicable for max pooling ); -INSTANTIATE_TEST_CASE_P(smoke_MaxPool_ExplicitPad_CeilRpunding, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_ExplicitPad_CeilRpunding, PoolingLayerTest, ::testing::Combine( maxPool_ExplicitPad_CeilRounding_Params, ::testing::ValuesIn(netPrecisions), @@ -92,7 +92,7 @@ const auto avgPoolExplicitPadCeilRoundingParams = ::testing::Combine( ::testing::Values(true, false) ); -INSTANTIATE_TEST_CASE_P(smoke_AvgPool_ExplicitPad_CeilRounding, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_ExplicitPad_CeilRounding, PoolingLayerTest, ::testing::Combine( avgPoolExplicitPadCeilRoundingParams, ::testing::ValuesIn(netPrecisions), @@ -117,7 +117,7 @@ const auto avgPoolExplicitPadFloorRoundingParams = ::testing::Combine( ); -INSTANTIATE_TEST_CASE_P(smoke_AvgPool_ExplicitPad_FloorRounding, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_ExplicitPad_FloorRounding, PoolingLayerTest, ::testing::Combine( avgPoolExplicitPadFloorRoundingParams, ::testing::ValuesIn(netPrecisions), @@ -143,7 +143,7 @@ const auto allPools_ValidPad_Params = ::testing::Combine( ::testing::Values(false) // placeholder value - exclude pad not applicable for max pooling ); -INSTANTIATE_TEST_CASE_P(smoke_MAX_and_AVGPool_ValidPad, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MAX_and_AVGPool_ValidPad, PoolingLayerTest, ::testing::Combine( allPools_ValidPad_Params, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/power.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/power.cpp index 288b641754eaa1..f66634b7782624 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/power.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/power.cpp @@ -34,7 +34,7 @@ namespace { InferenceEngine::Precision::FP16, }; - INSTANTIATE_TEST_CASE_P(smoke_power, PowerLayerTest, + INSTANTIATE_TEST_SUITE_P(smoke_power, PowerLayerTest, ::testing::Combine( ::testing::ValuesIn(inShapes), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/prior_box_clustered.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/prior_box_clustered.cpp index 171b85bc7740b1..108deb8d3f206c 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/prior_box_clustered.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/prior_box_clustered.cpp @@ -56,7 +56,7 @@ const auto layerSpeficParams = ::testing::Combine( ::testing::ValuesIn(variances) ); -INSTANTIATE_TEST_CASE_P(smoke_PriorBoxClustered_Basic, PriorBoxClusteredLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_PriorBoxClustered_Basic, PriorBoxClusteredLayerTest, ::testing::Combine( layerSpeficParams, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/proposal.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/proposal.cpp index 7562964b5e8498..4983c5a4b8fd3b 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/proposal.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/proposal.cpp @@ -39,7 +39,7 @@ const auto proposalParams = ::testing::Combine( ::testing::ValuesIn(framework_) ); -INSTANTIATE_TEST_CASE_P(smoke_Proposal_tests, ProposalLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Proposal_tests, ProposalLayerTest, ::testing::Combine( proposalParams, ::testing::Values(CommonTestUtils::DEVICE_GPU)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/reduce_ops.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/reduce_ops.cpp index 041f1040403741..0641408588c111 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/reduce_ops.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/reduce_ops.cpp @@ -169,56 +169,56 @@ const auto params_ReductionTypesLogical = testing::Combine( testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_ReduceOneAxis, ReduceOpsLayerTest, paramsOneAxis, ReduceOpsLayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_ReduceLogicalOneAxis, ReduceOpsLayerTest, paramsOneAxisLogical, ReduceOpsLayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Reduce_Precisions, ReduceOpsLayerTest, params_Precisions, ReduceOpsLayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Reduce_InputShapes, ReduceOpsLayerTest, params_InputShapes, ReduceOpsLayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Reduce_Axes, ReduceOpsLayerTest, params_Axes, ReduceOpsLayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Reduce_ReductionTypes, ReduceOpsLayerTest, params_ReductionTypes, ReduceOpsLayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_ReduceLogical_ReductionTypes, ReduceOpsLayerTest, params_ReductionTypesLogical, ReduceOpsLayerTest::getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Reduce, ReduceOpsLayerWithSpecificInputTest, testing::Combine( diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/region_yolo.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/region_yolo.cpp index 395210d020e265..cbcba098db08a3 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/region_yolo.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/region_yolo.cpp @@ -80,6 +80,6 @@ const auto testCase_yolov2_caffe = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P(smoke_TestsRegionYolov3, RegionYoloLayerTest, testCase_yolov3, RegionYoloLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_TestsRegionYoloMxnet, RegionYoloLayerTest, testCase_yolov3_mxnet, RegionYoloLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_TestsRegionYoloCaffe, RegionYoloLayerTest, testCase_yolov2_caffe, RegionYoloLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsRegionYolov3, RegionYoloLayerTest, testCase_yolov3, RegionYoloLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsRegionYoloMxnet, RegionYoloLayerTest, testCase_yolov3_mxnet, RegionYoloLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsRegionYoloCaffe, RegionYoloLayerTest, testCase_yolov2_caffe, RegionYoloLayerTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/reorg_yolo.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/reorg_yolo.cpp index e0294010774b84..566e4f36169eae 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/reorg_yolo.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/reorg_yolo.cpp @@ -67,9 +67,9 @@ const auto testCase_batch_2 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P(smoke_TestsReorgYolo_caffe_YoloV2, ReorgYoloLayerTest, testCase_caffe_yolov2, ReorgYoloLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_TestsReorgYolo_stride_2_smallest, ReorgYoloLayerTest, testCase_smallest, ReorgYoloLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_TestsReorgYolo_stride_2, ReorgYoloLayerTest, testCase_stride_2, ReorgYoloLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_TestsReorgYolo_stride_3, ReorgYoloLayerTest, testCase_stride_3, ReorgYoloLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_TestsReorgYolo_smaller_h, ReorgYoloLayerTest, testCase_smaller_h, ReorgYoloLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_TestsReorgYolo_batch_2, ReorgYoloLayerTest, testCase_batch_2, ReorgYoloLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_caffe_YoloV2, ReorgYoloLayerTest, testCase_caffe_yolov2, ReorgYoloLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_stride_2_smallest, ReorgYoloLayerTest, testCase_smallest, ReorgYoloLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_stride_2, ReorgYoloLayerTest, testCase_stride_2, ReorgYoloLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_stride_3, ReorgYoloLayerTest, testCase_stride_3, ReorgYoloLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_smaller_h, ReorgYoloLayerTest, testCase_smaller_h, ReorgYoloLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_batch_2, ReorgYoloLayerTest, testCase_batch_2, ReorgYoloLayerTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/reshape.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/reshape.cpp index 84d30807341593..831c4a4d7e5e56 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/reshape.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/reshape.cpp @@ -16,7 +16,7 @@ const std::vector netPrecisions = { }; //TODO: Issue : - 28981 -INSTANTIATE_TEST_CASE_P(DISABLE_smoke_ReshapeCheckDynBatch, ReshapeLayerTestRevise, +INSTANTIATE_TEST_SUITE_P(DISABLE_smoke_ReshapeCheckDynBatch, ReshapeLayerTestRevise, ::testing::Combine( ::testing::Values(true), ::testing::ValuesIn(netPrecisions), @@ -30,7 +30,7 @@ INSTANTIATE_TEST_CASE_P(DISABLE_smoke_ReshapeCheckDynBatch, ReshapeLayerTestRevi ::testing::Values(std::map({{CONFIG_KEY(DYN_BATCH_ENABLED), CONFIG_VALUE(YES)}}))), ReshapeLayerTestRevise::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ReshapeCheck, ReshapeLayerTestRevise, +INSTANTIATE_TEST_SUITE_P(smoke_ReshapeCheck, ReshapeLayerTestRevise, ::testing::Combine( ::testing::Values(true), ::testing::ValuesIn(netPrecisions), @@ -44,7 +44,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ReshapeCheck, ReshapeLayerTestRevise, ::testing::Values(std::map({}))), ReshapeLayerTestRevise::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ReshapeCheckNegative, ReshapeLayerTestRevise, +INSTANTIATE_TEST_SUITE_P(smoke_ReshapeCheckNegative, ReshapeLayerTestRevise, ::testing::Combine( ::testing::Values(true), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/reverse_sequence.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/reverse_sequence.cpp index aa4054030a696b..fb3d9786c83e92 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/reverse_sequence.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/reverse_sequence.cpp @@ -33,7 +33,7 @@ const std::vector secondaryInputTypes = { ngraph::helpers::InputLayerType::PARAMETER }; -INSTANTIATE_TEST_CASE_P(Basic_smoke, ReverseSequenceLayerTest, +INSTANTIATE_TEST_SUITE_P(Basic_smoke, ReverseSequenceLayerTest, ::testing::Combine( ::testing::ValuesIn(batchAxisIndices), ::testing::ValuesIn(seqAxisIndices), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/rnn_cell.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/rnn_cell.cpp index b353a97e318be8..9d0f3a58f3c0bb 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/rnn_cell.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/rnn_cell.cpp @@ -19,7 +19,7 @@ namespace { std::vector netPrecisions = {InferenceEngine::Precision::FP32, InferenceEngine::Precision::FP16}; - INSTANTIATE_TEST_CASE_P(RNNCellCommon, RNNCellTest, + INSTANTIATE_TEST_SUITE_P(RNNCellCommon, RNNCellTest, ::testing::Combine( ::testing::ValuesIn(should_decompose), ::testing::ValuesIn(batch), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/rnn_sequence.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/rnn_sequence.cpp index 718c1b6e771540..ba5f3fa50ac614 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/rnn_sequence.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/rnn_sequence.cpp @@ -31,7 +31,7 @@ std::vector direction = {ngraph::op::Rec }; std::vector netPrecisions = {InferenceEngine::Precision::FP32}; -INSTANTIATE_TEST_CASE_P(RNNSequenceCommonZeroClip, RNNSequenceTest, +INSTANTIATE_TEST_SUITE_P(RNNSequenceCommonZeroClip, RNNSequenceTest, ::testing::Combine( ::testing::ValuesIn(mode), ::testing::ValuesIn(seq_lengths_zero_clip), @@ -45,7 +45,7 @@ INSTANTIATE_TEST_CASE_P(RNNSequenceCommonZeroClip, RNNSequenceTest, ::testing::Values(CommonTestUtils::DEVICE_GPU)), RNNSequenceTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(RNNSequenceCommonClip, RNNSequenceTest, +INSTANTIATE_TEST_SUITE_P(RNNSequenceCommonClip, RNNSequenceTest, ::testing::Combine( ::testing::ValuesIn(mode), ::testing::ValuesIn(seq_lengths_clip_non_zero), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/scatter_elements_update.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/scatter_elements_update.cpp index 325ace5c88ad7e..ffa19fcc4fca70 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/scatter_elements_update.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/scatter_elements_update.cpp @@ -43,6 +43,6 @@ const auto ScatterEltUpdateCases = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P(smoke_ScatterEltsUpdate, ScatterElementsUpdateLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ScatterEltsUpdate, ScatterElementsUpdateLayerTest, ScatterEltUpdateCases, ScatterElementsUpdateLayerTest::getTestCaseName); } // namespace \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/scatter_nd_update.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/scatter_nd_update.cpp index 39767aaa50cdea..70800dd664c4db 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/scatter_nd_update.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/scatter_nd_update.cpp @@ -49,5 +49,5 @@ const auto ScatterNDUpdateCases = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P(smoke_ScatterNDUpdate, ScatterNDUpdateLayerTest, ScatterNDUpdateCases, ScatterNDUpdateLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_ScatterNDUpdate, ScatterNDUpdateLayerTest, ScatterNDUpdateCases, ScatterNDUpdateLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/scatter_update.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/scatter_update.cpp index 6f48dd1be4268e..ed4250538d90ae 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/scatter_update.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/scatter_update.cpp @@ -42,6 +42,6 @@ const auto ScatterUpdateCase = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P(smoke_ScatterUpdate, ScatterUpdateLayerTest, ScatterUpdateCase, ScatterUpdateLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_ScatterUpdate, ScatterUpdateLayerTest, ScatterUpdateCase, ScatterUpdateLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/select.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/select.cpp index f9a3e9b8c3ac03..dd0f75e78bab38 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/select.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/select.cpp @@ -63,6 +63,6 @@ const auto numpyCases = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P(smoke_CLDNN_TestsSelect_none, SelectLayerTest, noneCases, SelectLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CLDNN_TestsSelect_none, SelectLayerTest, noneCases, SelectLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_CLDNN_TestsSelect_numpy, SelectLayerTest, numpyCases, SelectLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CLDNN_TestsSelect_numpy, SelectLayerTest, numpyCases, SelectLayerTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/shuffle_channels.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/shuffle_channels.cpp index 0eb593e16f45e4..74821cf0cc4d25 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/shuffle_channels.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/shuffle_channels.cpp @@ -34,10 +34,10 @@ const auto testCases = ::testing::Combine(::testing::ValuesIn(shuffleParameters) ::testing::Values(CommonTestUtils::DEVICE_GPU)); -INSTANTIATE_TEST_CASE_P(smoke_GPU_ShuffleChannels, ShuffleChannelsLayerTest, testCases, ShuffleChannelsLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_GPU_ShuffleChannels, ShuffleChannelsLayerTest, testCases, ShuffleChannelsLayerTest::getTestCaseName); // ND support tests -INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels3D, ShuffleChannelsLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannels3D, ShuffleChannelsLayerTest, ::testing::Combine( ::testing::Values(std::tuple(1, 3)), ::testing::ValuesIn(netPrecisions), @@ -49,7 +49,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels3D, ShuffleChannelsLayerTest, ::testing::Values(CommonTestUtils::DEVICE_GPU)), ShuffleChannelsLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels2D, ShuffleChannelsLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannels2D, ShuffleChannelsLayerTest, ::testing::Combine( ::testing::Values(std::tuple(1, 3)), ::testing::ValuesIn(netPrecisions), @@ -61,7 +61,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels2D, ShuffleChannelsLayerTest, ::testing::Values(CommonTestUtils::DEVICE_GPU)), ShuffleChannelsLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ShuffleChannels1D, ShuffleChannelsLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannels1D, ShuffleChannelsLayerTest, ::testing::Combine( ::testing::Values(std::tuple(0, 3)), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/softmax.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/softmax.cpp index 98727447a883b3..ad797508c6f3ec 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/softmax.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/softmax.cpp @@ -41,7 +41,7 @@ const auto params2D = testing::Combine( testing::Values(std::map()) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_SoftMax2D, SoftMaxLayerTest, params2D, @@ -68,7 +68,7 @@ const auto params4D = testing::Combine( testing::Values(std::map()) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_SoftMax4D, SoftMaxLayerTest, params4D, diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/space_to_batch.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/space_to_batch.cpp index 149908a1d7dd06..2da3b2bb72985e 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/space_to_batch.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/space_to_batch.cpp @@ -119,6 +119,6 @@ spaceToBatchParamsTuple stb_only_test_cases[] = { CommonTestUtils::DEVICE_GPU), }; -INSTANTIATE_TEST_CASE_P(smoke_CLDNN, SpaceToBatchLayerTest, ::testing::ValuesIn(stb_only_test_cases), +INSTANTIATE_TEST_SUITE_P(smoke_CLDNN, SpaceToBatchLayerTest, ::testing::ValuesIn(stb_only_test_cases), SpaceToBatchLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/space_to_depth.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/space_to_depth.cpp index 4ad127c4d4c75f..e40127f312e58b 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/space_to_depth.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/space_to_depth.cpp @@ -34,7 +34,7 @@ const auto SpaceToDepthBS2 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P(SpaceToDepthBS2, SpaceToDepthLayerTest, SpaceToDepthBS2, SpaceToDepthLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(SpaceToDepthBS2, SpaceToDepthLayerTest, SpaceToDepthBS2, SpaceToDepthLayerTest::getTestCaseName); const std::vector> inputShapesBS3 = { {1, 1, 3, 3}, {1, 1, 6, 6}, {1, 1, 9, 9}, {2, 4, 9, 9}, {2, 3, 15, 12}, @@ -48,6 +48,6 @@ const auto SpaceToDepthBS3 = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P(SpaceToDepthBS3, SpaceToDepthLayerTest, SpaceToDepthBS3, SpaceToDepthLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(SpaceToDepthBS3, SpaceToDepthLayerTest, SpaceToDepthBS3, SpaceToDepthLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/split.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/split.cpp index c7fb37ec7488e8..a456325ad7e7d6 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/split.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/split.cpp @@ -17,7 +17,7 @@ const std::vector netPrecisions = { InferenceEngine::Precision::I64 }; -INSTANTIATE_TEST_CASE_P(smoke_NumSplitsCheck, SplitLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_NumSplitsCheck, SplitLayerTest, ::testing::Combine( ::testing::Values(1), ::testing::Values(0, 1, 2, 3), @@ -31,7 +31,7 @@ INSTANTIATE_TEST_CASE_P(smoke_NumSplitsCheck, SplitLayerTest, ::testing::Values(CommonTestUtils::DEVICE_GPU)), SplitLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_splitWithUnusedOutputsTest, SplitLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_splitWithUnusedOutputsTest, SplitLayerTest, ::testing::Combine( ::testing::Values(5), ::testing::Values(0), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/squeeze_unsqueeze.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/squeeze_unsqueeze.cpp index ca5b6ece34a9d0..895439d7d548f8 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/squeeze_unsqueeze.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/squeeze_unsqueeze.cpp @@ -38,7 +38,7 @@ const std::vector opTypes = { ngraph::helpers::SqueezeOpType::UNSQUEEZE }; -INSTANTIATE_TEST_CASE_P(smoke_Basic, SqueezeUnsqueezeLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Basic, SqueezeUnsqueezeLayerTest, ::testing::Combine( ::testing::ValuesIn(CommonTestUtils::combineParams(axesVectors)), ::testing::ValuesIn(opTypes), @@ -50,7 +50,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Basic, SqueezeUnsqueezeLayerTest, ::testing::Values(CommonTestUtils::DEVICE_GPU)), SqueezeUnsqueezeLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Basic_emptyAxes, SqueezeUnsqueezeLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Basic_emptyAxes, SqueezeUnsqueezeLayerTest, ::testing::Combine( ::testing::ValuesIn(CommonTestUtils::combineParams(emptyAxesVectors)), ::testing::Values(ngraph::helpers::SqueezeOpType::SQUEEZE), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/strided_slice.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/strided_slice.cpp index 7fb8dd1d8c6e13..1b4447a75dac13 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/strided_slice.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/strided_slice.cpp @@ -69,7 +69,7 @@ std::vector ss_only_test_cases_i64 = { {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, {} }, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_CLDNN_FP32, StridedSliceLayerTest, ::testing::Combine( ::testing::ValuesIn(ss_only_test_cases_fp32), @@ -82,7 +82,7 @@ INSTANTIATE_TEST_CASE_P( ::testing::Values(std::map())), StridedSliceLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_CLDNN_I64, StridedSliceLayerTest, ::testing::Combine( ::testing::ValuesIn(ss_only_test_cases_i64), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/tile.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/tile.cpp index 9ddeabf4789b94..8758fc208e8028 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/tile.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/tile.cpp @@ -21,7 +21,7 @@ const std::vector> repeats = { {2, 2, 2}, }; -INSTANTIATE_TEST_CASE_P(smoke_Tile, TileLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Tile, TileLayerTest, ::testing::Combine( ::testing::ValuesIn(repeats), ::testing::ValuesIn(netPrecisions), @@ -33,7 +33,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Tile, TileLayerTest, ::testing::Values(CommonTestUtils::DEVICE_GPU)), TileLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Tile6d, TileLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Tile6d, TileLayerTest, ::testing::Combine( ::testing::Values(std::vector({1, 1, 1, 2, 1, 2})), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/topk.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/topk.cpp index 2ac2c1a2373d5e..b34287c5bab924 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/topk.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/topk.cpp @@ -38,7 +38,7 @@ const std::vector sortTypes = { }; -INSTANTIATE_TEST_CASE_P(smoke_TopK, TopKLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_TopK, TopKLayerTest, ::testing::Combine( ::testing::ValuesIn(k), ::testing::ValuesIn(axes), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/transpose.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/transpose.cpp index 265b742e6f2afa..2fc92324ef5f09 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/transpose.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/transpose.cpp @@ -46,7 +46,7 @@ const auto params = testing::Combine( testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Transpose, TransposeLayerTest, params, @@ -82,7 +82,7 @@ const auto params5D = testing::Combine( testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Transpose_5D, TransposeLayerTest, params5D, @@ -118,7 +118,7 @@ const auto params6D = testing::Combine( testing::Values(CommonTestUtils::DEVICE_GPU) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Transpose_6D, TransposeLayerTest, params6D, diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/variadic_split.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/variadic_split.cpp index b5e91b031e7269..d6fc5e6f8309f1 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/variadic_split.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/variadic_split.cpp @@ -25,7 +25,7 @@ namespace { {4, 11, 6, 9} }; - INSTANTIATE_TEST_CASE_P(smoke_NumSplitsCheck, VariadicSplitLayerTest, + INSTANTIATE_TEST_SUITE_P(smoke_NumSplitsCheck, VariadicSplitLayerTest, ::testing::Combine( ::testing::ValuesIn(numSplits), ::testing::Values(0, 1, 2, 3), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/constant_result.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/constant_result.cpp index bf4ca2f13523da..35c31e30577465 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/constant_result.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/constant_result.cpp @@ -34,7 +34,7 @@ const std::vector precisions = { Precision::BOOL }; -INSTANTIATE_TEST_CASE_P(smoke_Check, ConstantResultSubgraphTest, +INSTANTIATE_TEST_SUITE_P(smoke_Check, ConstantResultSubgraphTest, ::testing::Combine( ::testing::ValuesIn(types), ::testing::ValuesIn(shapes), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/get_output_before_activation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/get_output_before_activation.cpp index 7c4be794741700..98027ac7bb64d6 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/get_output_before_activation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/get_output_before_activation.cpp @@ -23,7 +23,7 @@ namespace { std::map additional_config = {}; } // namespace -INSTANTIATE_TEST_CASE_P(OutputBeforeActivation, OutputBeforeActivation, +INSTANTIATE_TEST_SUITE_P(OutputBeforeActivation, OutputBeforeActivation, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::Values(InferenceEngine::Precision::FP32), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/matmul_squeeze_add.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/matmul_squeeze_add.cpp index 9afd80f0af9216..eb6d89436b707f 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/matmul_squeeze_add.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/matmul_squeeze_add.cpp @@ -36,7 +36,7 @@ std::vector output_sizes = { 8 }; -INSTANTIATE_TEST_CASE_P(MatmulSqueezeAdd, MatmulSqueezeAddTest, +INSTANTIATE_TEST_SUITE_P(MatmulSqueezeAdd, MatmulSqueezeAddTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/multiply_add.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/multiply_add.cpp index 642cb25d4cf150..7dae838e78d53a 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/multiply_add.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/multiply_add.cpp @@ -23,7 +23,7 @@ const std::vector> inputShapes = { {1, 3, 2, 2, 4, 5}, }; -INSTANTIATE_TEST_CASE_P(smoke_MultipleAdd_Nd, MultiplyAddLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MultipleAdd_Nd, MultiplyAddLayerTest, ::testing::Combine( ::testing::ValuesIn(inputShapes), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/parameter_result.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/parameter_result.cpp index 2819577a7710b5..9b3de7ad2b7439 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/parameter_result.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/parameter_result.cpp @@ -10,7 +10,7 @@ using namespace SubgraphTestsDefinitions; namespace { - INSTANTIATE_TEST_CASE_P(smoke_Check, ParameterResultSubgraphTest, + INSTANTIATE_TEST_SUITE_P(smoke_Check, ParameterResultSubgraphTest, ::testing::Values(CommonTestUtils::DEVICE_GPU), ParameterResultSubgraphTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/perm_conv_perm_concat.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/perm_conv_perm_concat.cpp index 88da94c4ddb6c1..6f757c2bfdaf50 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/perm_conv_perm_concat.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/perm_conv_perm_concat.cpp @@ -31,7 +31,7 @@ std::map additional_config = { } // namespace namespace SubgraphTestsDefinitions { - INSTANTIATE_TEST_CASE_P(smoke_basic, PermConvPermConcat, + INSTANTIATE_TEST_SUITE_P(smoke_basic, PermConvPermConcat, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/quantized_convolution_backprop_data.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/quantized_convolution_backprop_data.cpp index 48f6635bdae026..5f13a31053d0a4 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/quantized_convolution_backprop_data.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/quantized_convolution_backprop_data.cpp @@ -41,7 +41,7 @@ const auto quantConvBackpropData2DParams = ::testing::Combine( ::testing::ValuesIn(granularity) ); -INSTANTIATE_TEST_CASE_P(smoke_QuantConvBackpropData2D, QuantConvBackpropDataLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_QuantConvBackpropData2D, QuantConvBackpropDataLayerTest, ::testing::Combine( quantConvBackpropData2DParams, ::testing::ValuesIn(netPrecisions), @@ -69,7 +69,7 @@ const auto quantConvBackpropData3DParams = ::testing::Combine( ::testing::ValuesIn(granularity) ); -INSTANTIATE_TEST_CASE_P(smoke_QuantConvBackpropData3D, QuantConvBackpropDataLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_QuantConvBackpropData3D, QuantConvBackpropDataLayerTest, ::testing::Combine( quantConvBackpropData3DParams, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/quantized_group_convolution_backprop_data.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/quantized_group_convolution_backprop_data.cpp index b310104ff97e0f..f965da23574218 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/quantized_group_convolution_backprop_data.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/quantized_group_convolution_backprop_data.cpp @@ -43,7 +43,7 @@ const auto quantGroupConvBackpropData2DParams = ::testing::Combine( ::testing::ValuesIn(granularity) ); -INSTANTIATE_TEST_CASE_P(smoke_QuantGroupConvBackpropData2D, QuantGroupConvBackpropDataLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_QuantGroupConvBackpropData2D, QuantGroupConvBackpropDataLayerTest, ::testing::Combine( quantGroupConvBackpropData2DParams, ::testing::ValuesIn(netPrecisions), @@ -72,7 +72,7 @@ const auto quantGroupConvBackpropData3DParams = ::testing::Combine( ::testing::ValuesIn(granularity) ); -INSTANTIATE_TEST_CASE_P(smoke_QuantGroupConvBackpropData3D, QuantGroupConvBackpropDataLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_QuantGroupConvBackpropData3D, QuantGroupConvBackpropDataLayerTest, ::testing::Combine( quantGroupConvBackpropData3DParams, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/reduce_eltwise.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/reduce_eltwise.cpp index 04dbc6e800551e..62a6097184e27f 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/reduce_eltwise.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/reduce_eltwise.cpp @@ -14,7 +14,7 @@ const std::vector netPrecisions = { InferenceEngine::Precision::FP32, }; -INSTANTIATE_TEST_CASE_P(smoke_ReduceEltwise6D, ReduceEltwiseTest, +INSTANTIATE_TEST_SUITE_P(smoke_ReduceEltwise6D, ReduceEltwiseTest, testing::Combine( testing::Values(std::vector{2, 3, 4, 5, 6, 7}), testing::Values(std::vector{2, 3, 4}), @@ -24,7 +24,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ReduceEltwise6D, ReduceEltwiseTest, testing::Values(CommonTestUtils::DEVICE_GPU)), ReduceEltwiseTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ReduceEltwise5D, ReduceEltwiseTest, +INSTANTIATE_TEST_SUITE_P(smoke_ReduceEltwise5D, ReduceEltwiseTest, testing::Combine( testing::Values(std::vector{2, 3, 4, 5, 6}), testing::Values(std::vector{2, 3}), @@ -34,7 +34,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ReduceEltwise5D, ReduceEltwiseTest, testing::Values(CommonTestUtils::DEVICE_GPU)), ReduceEltwiseTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ReduceEltwise4D, ReduceEltwiseTest, +INSTANTIATE_TEST_SUITE_P(smoke_ReduceEltwise4D, ReduceEltwiseTest, testing::Combine( testing::Values(std::vector{2, 3, 4, 5}), testing::Values(std::vector{2}), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/reshape_permute_conv_permute_reshape_act.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/reshape_permute_conv_permute_reshape_act.cpp index 05fcaf36ecd9b7..88ac469ef1cf78 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/reshape_permute_conv_permute_reshape_act.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/reshape_permute_conv_permute_reshape_act.cpp @@ -32,7 +32,7 @@ std::vector netPrecisions = { std::map additional_config = {}; namespace SubgraphTestsDefinitions { - INSTANTIATE_TEST_CASE_P(smoke_basic, ConvReshapeAct, + INSTANTIATE_TEST_SUITE_P(smoke_basic, ConvReshapeAct, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/reshape_squeeze_reshape_relu.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/reshape_squeeze_reshape_relu.cpp index 75d90a5fa2913d..dbf28170fdd1bd 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/reshape_squeeze_reshape_relu.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/reshape_squeeze_reshape_relu.cpp @@ -39,7 +39,7 @@ namespace { ngraph::helpers::SqueezeOpType::UNSQUEEZE }; - INSTANTIATE_TEST_CASE_P(smoke_reshape_squeeze_reshape_relu, ReshapeSqueezeReshapeRelu, + INSTANTIATE_TEST_SUITE_P(smoke_reshape_squeeze_reshape_relu, ReshapeSqueezeReshapeRelu, ::testing::Combine( ::testing::ValuesIn(inputs_squeeze), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/scale_shift.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/scale_shift.cpp index 928a9f19df6028..5c1de701dee96f 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/scale_shift.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/scale_shift.cpp @@ -47,7 +47,7 @@ std::vector netPrecisions = {InferenceEngine::Precis } // namespace -INSTANTIATE_TEST_CASE_P(smoke_ScaleShift, ScaleShiftLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_ScaleShift, ScaleShiftLayerTest, ::testing::Combine( ::testing::ValuesIn(inShapes), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/split_conv_concat.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/split_conv_concat.cpp index 40364a93cd2c62..adafa4adbee17b 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/split_conv_concat.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/split_conv_concat.cpp @@ -15,7 +15,7 @@ const std::vector netPrecisions = { InferenceEngine::Precision::FP16 }; -INSTANTIATE_TEST_CASE_P(smoke_NoReshape, SplitConvConcat, +INSTANTIATE_TEST_SUITE_P(smoke_NoReshape, SplitConvConcat, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(std::vector({1, 6, 40, 40})), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/tensor_names.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/tensor_names.cpp index a1f5fc59981012..405966554288bd 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/tensor_names.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/tensor_names.cpp @@ -10,7 +10,7 @@ using namespace SubgraphTestsDefinitions; namespace { - INSTANTIATE_TEST_CASE_P(smoke_Check, TensorNamesTest, + INSTANTIATE_TEST_SUITE_P(smoke_Check, TensorNamesTest, ::testing::Values(CommonTestUtils::DEVICE_GPU), TensorNamesTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/gpu/single_layer_tests/tensor_iterator.cpp b/inference-engine/tests/functional/plugin/gpu/single_layer_tests/tensor_iterator.cpp index bce1ef106917f2..f35942099c9239 100644 --- a/inference-engine/tests/functional/plugin/gpu/single_layer_tests/tensor_iterator.cpp +++ b/inference-engine/tests/functional/plugin/gpu/single_layer_tests/tensor_iterator.cpp @@ -268,7 +268,7 @@ TEST_P(TensorIteratorWithConfigTest, CompareWithRefs) { using namespace LayerTestsDefinitions; namespace { - INSTANTIATE_TEST_CASE_P(smoke_TensorIteratorCommon, TensorIteratorWithConfigTest, + INSTANTIATE_TEST_SUITE_P(smoke_TensorIteratorCommon, TensorIteratorWithConfigTest, ::testing::Combine( ::testing::ValuesIn(std::vector {2, 4}), // seq lengths ::testing::ValuesIn(std::vector {1}), // only single batch supported diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/operations/dynamic_shape_resolver.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/operations/dynamic_shape_resolver.cpp index e3b5e4c137c2d9..650d39238e01cc 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/operations/dynamic_shape_resolver.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/operations/dynamic_shape_resolver.cpp @@ -87,7 +87,7 @@ std::set allNGraphStaticTypes() { return staticTypes; } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicShapeResolverTests, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicShapeResolverTests, testing::Combine( testing::ValuesIn(allNGraphStaticTypes()), testing::Values(DataShape{1, 800}, DataShape{1, 1}))); @@ -119,7 +119,7 @@ TEST_P(DynamicShapeResolverNegativeTestsDataType, ThrowsOnInvalidDimsType) { ASSERT_THROW(auto dynamicShapeResolver = std::make_shared(data, dims), ngraph::ngraph_error); } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicShapeResolverNegativeTestsDataType, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicShapeResolverNegativeTestsDataType, testing::Combine( testing::Values(ngraph::element::dynamic), testing::Values(ngraph::element::i64), testing::Values(DataPartialShape{1, 800}), @@ -139,7 +139,7 @@ std::set allNGraphNotIntegralTypes() { return notIntegralTypes; } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicShapeResolverNegativeTestsDimsType, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicShapeResolverNegativeTestsDimsType, testing::Combine( testing::ValuesIn(allNGraphStaticTypes()), testing::ValuesIn(allNGraphNotIntegralTypes()), testing::Values(DataPartialShape{1, 800}), @@ -150,7 +150,7 @@ TEST_P(DynamicShapeResolverNegativeTestsDataShape, ThrowsOnInvalidDimsType) { ASSERT_THROW(auto dynamicShapeResolver = std::make_shared(data, dims), ngraph::ngraph_error); } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicShapeResolverNegativeTestsDataShape, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicShapeResolverNegativeTestsDataShape, testing::Combine( testing::ValuesIn(allNGraphStaticTypes()), testing::Values(ngraph::element::i64), testing::Values( @@ -165,7 +165,7 @@ TEST_P(DynamicShapeResolverNegativeTestsDimsShape, ThrowsOnInvalidDimsType) { ASSERT_THROW(auto dynamicShapeResolver = std::make_shared(data, dims), ngraph::ngraph_error); } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicShapeResolverNegativeTestsDimsShape, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicShapeResolverNegativeTestsDimsShape, testing::Combine( testing::ValuesIn(allNGraphTypes()), testing::Values(ngraph::element::i64), testing::Values(DataShape{1, 800}), @@ -275,7 +275,7 @@ const auto basicCases = ::testing::Combine( ); -INSTANTIATE_TEST_CASE_P(smoke_DynamicShapeResolverPluginTests, DynamicShapeResolverPluginTests, +INSTANTIATE_TEST_SUITE_P(smoke_DynamicShapeResolverPluginTests, DynamicShapeResolverPluginTests, ::testing::Combine( ::testing::ValuesIn(inputDatas), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD)), diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/operations/out_shape_of_reshape.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/operations/out_shape_of_reshape.cpp index fd5687af017bc1..9128463dd6dd14 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/operations/out_shape_of_reshape.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/operations/out_shape_of_reshape.cpp @@ -98,7 +98,7 @@ TEST_P(OutShapeOfReshapeTests, CanValidateAndInferTypes) { ngraph::ParameterVector{m_inDataShapeParam, m_outShapeDescriptorParam})); } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, OutShapeOfReshapeTests, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, OutShapeOfReshapeTests, testing::Combine( testing::ValuesIn(tensorShapes), testing::ValuesIn(allNGraphIntegralNumberTypes()), testing::ValuesIn(tensorShapes), @@ -125,7 +125,7 @@ TEST_P(OutShapeOfReshapeTestsNegativeDataType, ThrowsOnInvalidDataType) { m_inDataShapeParam, m_outShapeDescriptorParam, true), ngraph::NodeValidationFailure); } -INSTANTIATE_TEST_CASE_P(smoke_InvalidInDataShapeTensorType, OutShapeOfReshapeTestsNegativeDataType, +INSTANTIATE_TEST_SUITE_P(smoke_InvalidInDataShapeTensorType, OutShapeOfReshapeTestsNegativeDataType, testing::Combine( testing::Values(TensorShape{4}), testing::ValuesIn(allNGraphNotIntegralTypes()), @@ -133,7 +133,7 @@ INSTANTIATE_TEST_CASE_P(smoke_InvalidInDataShapeTensorType, OutShapeOfReshapeTes testing::Values(ngraph::element::i64)) ); -INSTANTIATE_TEST_CASE_P(smoke_InvalidOutShapeDescriptorTensorType, OutShapeOfReshapeTestsNegativeDataType, +INSTANTIATE_TEST_SUITE_P(smoke_InvalidOutShapeDescriptorTensorType, OutShapeOfReshapeTestsNegativeDataType, testing::Combine( testing::Values(TensorShape{4}), testing::Values(ngraph::element::i64), @@ -155,7 +155,7 @@ TEST_P(OutShapeOfReshapeTestsNegativeDataShape, ThrowsOnInvalidDataShape) { ngraph::NodeValidationFailure); } -INSTANTIATE_TEST_CASE_P(smoke_InvalidInDataShapeTensorShape, OutShapeOfReshapeTestsNegativeDataShape, +INSTANTIATE_TEST_SUITE_P(smoke_InvalidInDataShapeTensorShape, OutShapeOfReshapeTestsNegativeDataShape, testing::Combine( testing::ValuesIn(invalidTensorShapes), testing::Values(ngraph::element::i64), @@ -163,7 +163,7 @@ INSTANTIATE_TEST_CASE_P(smoke_InvalidInDataShapeTensorShape, OutShapeOfReshapeTe testing::Values(ngraph::element::i64)) ); -INSTANTIATE_TEST_CASE_P(smoke_InvalidOutShapeDescriptorTensorShape, OutShapeOfReshapeTestsNegativeDataShape, +INSTANTIATE_TEST_SUITE_P(smoke_InvalidOutShapeDescriptorTensorShape, OutShapeOfReshapeTestsNegativeDataShape, testing::Combine( testing::ValuesIn(tensorShapes), testing::Values(ngraph::element::i64), diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/operations/static_shape_broadcast.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/operations/static_shape_broadcast.cpp index 79371a30a42c6a..79bc42c66e62b0 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/operations/static_shape_broadcast.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/operations/static_shape_broadcast.cpp @@ -151,7 +151,7 @@ TEST_P(StaticShapeBroadcastNumpyTests, CanValidateAndInferTypes) { ASSERT_EQ(m_tensorWithTargetShape->get_shape(), op->output(0).get_shape()); } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, StaticShapeBroadcastNumpyTests, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, StaticShapeBroadcastNumpyTests, testing::Combine( testing::ValuesIn(testNGraphNumericTypes), testing::ValuesIn(testNumpyStaticShapes)) ); @@ -167,7 +167,7 @@ TEST_P(StaticShapeBroadcastExplicitTests, CanValidateAndInferTypes) { ASSERT_EQ(m_tensorWithTargetShape->get_shape(), op->get_output_shape(0)); } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, StaticShapeBroadcastExplicitTests, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, StaticShapeBroadcastExplicitTests, testing::Combine( testing::ValuesIn(testNGraphNumericTypes), testing::ValuesIn(testExplicitStaticShapes)) ); @@ -183,7 +183,7 @@ TEST_P(StaticShapeBroadcastBidirectionalTests, CanValidateAndInferTypes) { ASSERT_EQ(m_tensorWithOutput->get_shape(), op->output(0).get_shape()); } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, StaticShapeBroadcastBidirectionalTests, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, StaticShapeBroadcastBidirectionalTests, testing::Combine( testing::ValuesIn(testNGraphNumericTypes), testing::ValuesIn(testBidirectionalStaticShapes)) ); @@ -204,7 +204,7 @@ TEST_P(StaticShapeBroadcastNumpyTestsNegativeNumInputs, ThrowsOnInvalidNumInputs ngraph::NodeValidationFailure); } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, StaticShapeBroadcastNumpyTestsNegativeNumInputs, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, StaticShapeBroadcastNumpyTestsNegativeNumInputs, testing::Combine( testing::Values(ngraph::element::f16), testing::Values(testNumpyStaticShapes[0])) ); @@ -218,7 +218,7 @@ TEST_P(StaticShapeBroadcastExplicitTestsNegativeNumInputs, ThrowsOnInvalidNumInp ngraph::NodeValidationFailure); } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, StaticShapeBroadcastExplicitTestsNegativeNumInputs, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, StaticShapeBroadcastExplicitTestsNegativeNumInputs, testing::Combine( testing::Values(ngraph::element::f16), testing::Values(testExplicitStaticShapes[0])) ); @@ -235,7 +235,7 @@ TEST_P(StaticShapeBroadcastBidirectionalTestsNegativeNumInputs, ThrowsOnInvalidN } using StaticShapeBroadcastTestsNegativeMode = StaticShapeBroadcastNumpyTests; -INSTANTIATE_TEST_CASE_P(smoke_NGraph, StaticShapeBroadcastTestsNegativeMode, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, StaticShapeBroadcastTestsNegativeMode, testing::Combine( testing::Values(ngraph::element::f16), testing::Values(testNumpyStaticShapes[0])) ); @@ -249,7 +249,7 @@ TEST_P(StaticShapeBroadcastTestsNegativeEvaluate, ThrowsOnInvalidMode) { m_tensor, targetShape), ngraph::NodeValidationFailure); } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, StaticShapeBroadcastTestsNegativeEvaluate, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, StaticShapeBroadcastTestsNegativeEvaluate, testing::Combine( testing::Values(ngraph::element::f16), testing::Values(testNumpyStaticShapes[0])) ); diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/operations/static_shape_nonzero.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/operations/static_shape_nonzero.cpp index 245bee742a33bb..80a9d9b64f6d9c 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/operations/static_shape_nonzero.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/operations/static_shape_nonzero.cpp @@ -88,7 +88,7 @@ TEST_P(StaticShapeNonZeroTests, CanValidateAndInferTypes) { ngraph::ParameterVector{m_param})); } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, StaticShapeNonZeroTests, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, StaticShapeNonZeroTests, testing::Combine( testing::ValuesIn(testNGraphNumericTypes), testing::ValuesIn(testStaticShapes), testing::ValuesIn(outputTypes)) @@ -105,7 +105,7 @@ TEST_P(StaticShapeNonZeroTestsNegativeInputDataType, ThrowsOnInvalidInputType) { ngraph::NodeValidationFailure); } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, StaticShapeNonZeroTestsNegativeInputDataType, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, StaticShapeNonZeroTestsNegativeInputDataType, testing::Combine( testing::Values(ngraph::element::dynamic), testing::ValuesIn(testStaticShapes), testing::ValuesIn(outputTypes)) @@ -118,7 +118,7 @@ TEST_P(StaticShapeNonZeroTestsNegativeDataShape, ThrowsOnInvalidDataShape) { ngraph::NodeValidationFailure); } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, StaticShapeNonZeroTestsNegativeDataShape, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, StaticShapeNonZeroTestsNegativeDataShape, testing::Combine( testing::ValuesIn(testNGraphNumericTypes), testing::ValuesIn(testDynamicShapes), testing::ValuesIn(outputTypes)) @@ -131,7 +131,7 @@ TEST_P(StaticShapeNonZeroTestsNegativeOutputDataType, ThrowsOnInvalidOutputType) ngraph::NodeValidationFailure); } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, StaticShapeNonZeroTestsNegativeOutputDataType, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, StaticShapeNonZeroTestsNegativeOutputDataType, testing::Combine( testing::ValuesIn(testNGraphNumericTypes), testing::ValuesIn(testStaticShapes), testing::Values(ngraph::element::boolean)) diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/convert_extract_image_patches_to_reorg_yolo_vpu.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/convert_extract_image_patches_to_reorg_yolo_vpu.cpp index e61a1765880c6d..f3bb5bc2d63fac 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/convert_extract_image_patches_to_reorg_yolo_vpu.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/convert_extract_image_patches_to_reorg_yolo_vpu.cpp @@ -85,7 +85,7 @@ TEST_P(ConvertEIPToReorgYoloPositiveTest, CompareFunctions) { ASSERT_TRUE(res.first) << res.second; } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, ConvertEIPToReorgYoloPositiveTest, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, ConvertEIPToReorgYoloPositiveTest, testing::Combine( testing::Values(ngraph::Shape{1, 64, 500, 500}), testing::Values(ngraph::Shape{5, 5}), testing::Values(ngraph::Strides{5, 5}), @@ -106,7 +106,7 @@ TEST_P(DoNotConvertEIPToReorgYoloOnDiffSizeAndStride, CompareFunctions) { ASSERT_FALSE(res.first) << res.second; } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DoNotConvertEIPToReorgYoloOnDiffSizeAndStride, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DoNotConvertEIPToReorgYoloOnDiffSizeAndStride, testing::Combine( testing::Values(ngraph::PartialShape{1, 64, 500, 500}), testing::Values(ngraph::Shape{5, 5}), testing::Values(ngraph::Strides{4, 4}), @@ -126,7 +126,7 @@ TEST_P(DoNotConvertEIPToReorgYoloOnNot4DInput, CompareFunctions) { EXPECT_ANY_THROW(transform(dataShape, sizes, strides, rates, padMode)); } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DoNotConvertEIPToReorgYoloOnNot4DInput, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DoNotConvertEIPToReorgYoloOnNot4DInput, testing::Combine( testing::Values(ngraph::PartialShape{1, 1, 64, 500, 500}, ngraph::PartialShape{64, 500, 500}, ngraph::PartialShape{500, 500}, @@ -154,7 +154,7 @@ TEST_P(DoNotConvertEIPToReorgYoloOnNotStaticInput, CompareFunctions) { ASSERT_TRUE(reorgIt == ops.end()); } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DoNotConvertEIPToReorgYoloOnNotStaticInput, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DoNotConvertEIPToReorgYoloOnNotStaticInput, testing::Combine( testing::Values(ngraph::PartialShape{1, 64, ngraph::Dimension::dynamic(), 500}, ngraph::PartialShape{1, 64, 500, ngraph::Dimension::dynamic()}), testing::Values(ngraph::Shape{5, 5}), @@ -169,7 +169,7 @@ TEST_P(DoNotConvertEIPToReorgYoloOnNonSingleRates, CompareFunctions) { ASSERT_FALSE(res.first) << res.second; } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DoNotConvertEIPToReorgYoloOnNonSingleRates, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DoNotConvertEIPToReorgYoloOnNonSingleRates, testing::Combine( testing::Values(ngraph::Shape{1, 64, 500, 500}), testing::Values(ngraph::Shape{5, 5}), testing::Values(ngraph::Strides{5, 5}), diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_binary_elementwise.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_binary_elementwise.cpp index 24dcef17e604cb..d1d87c77d071fa 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_binary_elementwise.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_binary_elementwise.cpp @@ -266,7 +266,7 @@ class DynamicToStaticShapeEltwise: public CommonTestUtils::TestsCommon, public t TEST_P(DynamicToStaticShapeEltwise, CompareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_EltwiseBroadcast, DynamicToStaticShapeEltwise, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_EltwiseBroadcast, DynamicToStaticShapeEltwise, testing::Combine( testing::Values( ngraph::element::f16, ngraph::element::f32, diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_broadcast.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_broadcast.cpp index dae6706a399b83..78de9260c2db61 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_broadcast.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_broadcast.cpp @@ -151,7 +151,7 @@ class DynamicToStaticShapeBroadcastExplicitTests TEST_P(DynamicToStaticShapeBroadcastExplicitTests, compareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticShapeBroadcastExplicitTests, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticShapeBroadcastExplicitTests, testing::Combine( testing::Values( ngraph::element::f16, ngraph::element::f32, @@ -297,7 +297,7 @@ class DynamicToStaticShapeBroadcastBidirectionalTests : public CommonTestUtils:: TEST_P(DynamicToStaticShapeBroadcastBidirectionalTests, compareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticShapeBroadcastBidirectionalTests, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticShapeBroadcastBidirectionalTests, testing::Combine( testing::Values( ngraph::element::f16, ngraph::element::f32, diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_clamp.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_clamp.cpp index 15ecbfc951e37d..97d3d79238f375 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_clamp.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_clamp.cpp @@ -72,7 +72,7 @@ class DynamicToStaticShapeClamp : public CommonTestUtils::TestsCommon, TEST_P(DynamicToStaticShapeClamp, CompareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticShapeClamp, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticShapeClamp, testing::Combine( testing::Values( ngraph::element::f16, ngraph::element::f32, diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_concat.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_concat.cpp index d18710a0bd9fae..90b62ee451c3fd 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_concat.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_concat.cpp @@ -134,7 +134,7 @@ std::vector concatParams = { {DataShapes{DataShape{3, 64, 128}, DataShape{3, 64, 256}, DataShape{3, 64, 512}}, -1}, }; -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticShapeConcatTests, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticShapeConcatTests, testing::Combine( testing::ValuesIn(dataTypes), testing::ValuesIn(concatParams))); diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_convert.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_convert.cpp index 851702d95752ff..e738d1d49c29c9 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_convert.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_convert.cpp @@ -72,7 +72,7 @@ class DynamicToStaticShapeConvert : public CommonTestUtils::TestsCommon, TEST_P(DynamicToStaticShapeConvert, CompareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticShapeConvert, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticShapeConvert, testing::Combine( testing::Values( ngraph::element::f16, ngraph::element::f32, diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_gather.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_gather.cpp index 13b1c44893af91..94463c74b717d2 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_gather.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_gather.cpp @@ -125,7 +125,7 @@ class DynamicToStaticShapeGatherDataDSR : public CommonTestUtils::TestsCommon, TEST_P(DynamicToStaticShapeGatherDataDSR, CompareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticShapeGatherDataDSR, combinations); +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticShapeGatherDataDSR, combinations); class DynamicToStaticShapeGatherIdxDSR : public CommonTestUtils::TestsCommon, public testing::WithParamInterface> { @@ -206,7 +206,7 @@ class DynamicToStaticShapeGatherIdxDSR : public CommonTestUtils::TestsCommon, TEST_P(DynamicToStaticShapeGatherIdxDSR, CompareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticShapeGatherIdxDSR, combinations); +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticShapeGatherIdxDSR, combinations); class DynamicToStaticShapeGather : public CommonTestUtils::TestsCommon, public testing::WithParamInterface> { @@ -289,6 +289,6 @@ class DynamicToStaticShapeGather : public CommonTestUtils::TestsCommon, TEST_P(DynamicToStaticShapeGather, CompareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticShapeGather, combinations); +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticShapeGather, combinations); } // namespace diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_gather_elements.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_gather_elements.cpp index c60be44e9e5d10..baf216e0101943 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_gather_elements.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_gather_elements.cpp @@ -128,6 +128,6 @@ class DynamicToStaticShapeGatherElements : public CommonTestUtils::TestsCommon, TEST_P(DynamicToStaticShapeGatherElements, CompareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticShapeGatherElements, combinations); +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticShapeGatherElements, combinations); } // namespace diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_gather_nd.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_gather_nd.cpp index f4f91dd2bf6235..16fbf15ea3c2bb 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_gather_nd.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_gather_nd.cpp @@ -186,6 +186,6 @@ class DynamicToStaticShapeGatherND : public CommonTestUtils::TestsCommon, TEST_P(DynamicToStaticShapeGatherND, CompareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticShapeGatherND, combinations); +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticShapeGatherND, combinations); } // namespace diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_matmul.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_matmul.cpp index fbab95ffbd4f9c..998b640d62d138 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_matmul.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_matmul.cpp @@ -204,6 +204,6 @@ class DynamicToStaticShapeMatMul: public CommonTestUtils::TestsCommon, TEST_P(DynamicToStaticShapeMatMul, CompareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_MatMul, DynamicToStaticShapeMatMul, combinations); +INSTANTIATE_TEST_SUITE_P(smoke_MatMul, DynamicToStaticShapeMatMul, combinations); } // namespace \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_non_max_suppression.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_non_max_suppression.cpp index c69468741d1dd9..b5e8cb06442411 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_non_max_suppression.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_non_max_suppression.cpp @@ -111,7 +111,7 @@ class DynamicToStaticShapeNonMaxSuppression : public CommonTestUtils::TestsCommo TEST_P(DynamicToStaticShapeNonMaxSuppression, CompareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticShapeNonMaxSuppression, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticShapeNonMaxSuppression, testing::Combine( testing::Values( ngraph::element::f16, ngraph::element::f32), diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_nonzero.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_nonzero.cpp index b62ce98c88b150..9da9b5072d373d 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_nonzero.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_nonzero.cpp @@ -91,7 +91,7 @@ TEST_P(DynamicToStaticShapeNonZeroTests, CompareFunctions) { compareFunctions(); } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticShapeNonZeroTests, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticShapeNonZeroTests, testing::Combine( testing::Values( ngraph::element::f16, ngraph::element::f32, diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_reduce.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_reduce.cpp index 13fbaee293a7ec..09bd745769c5f7 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_reduce.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_reduce.cpp @@ -158,7 +158,7 @@ class DynamicToStaticShapeReduce: public CommonTestUtils::TestsCommon, TEST_P(DynamicToStaticShapeReduce, CompareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_Arithmetic, DynamicToStaticShapeReduce, arithmetic_combinations); -INSTANTIATE_TEST_CASE_P(smoke_Logical, DynamicToStaticShapeReduce, logical_combinations); +INSTANTIATE_TEST_SUITE_P(smoke_Arithmetic, DynamicToStaticShapeReduce, arithmetic_combinations); +INSTANTIATE_TEST_SUITE_P(smoke_Logical, DynamicToStaticShapeReduce, logical_combinations); } // namespace diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_reshape.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_reshape.cpp index a0abc4e5c9ad41..1200660372ab8a 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_reshape.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_reshape.cpp @@ -114,7 +114,7 @@ std::shared_ptr generateDynamicReshapePattern(std::shared_ptr reference( TEST_P(DynamicToStaticShapeSplit, CompareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticShapeSplit, combinations); +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticShapeSplit, combinations); } // namespace diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_squeeze.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_squeeze.cpp index 65200017df2d9b..757a8fd511310a 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_squeeze.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_squeeze.cpp @@ -98,7 +98,7 @@ public testing::WithParamInterface> { TEST_P(DynamicToStaticShapeSqueeze, CompareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticShapeSqueeze, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticShapeSqueeze, testing::Combine( testing::Values( ngraph::element::f16, ngraph::element::f32, diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_topk.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_topk.cpp index e761ed6d94b645..b2674397fa8490 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_topk.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_topk.cpp @@ -135,7 +135,7 @@ class DynamicToStaticShapeTopKConst : public CommonTestUtils::TestsCommon, TEST_P(DynamicToStaticShapeTopKConst, CompareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticShapeTopKConst, combinations); +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticShapeTopKConst, combinations); class DynamicToStaticShapeTopK : public CommonTestUtils::TestsCommon, @@ -239,6 +239,6 @@ class DynamicToStaticShapeTopK : public CommonTestUtils::TestsCommon, TEST_P(DynamicToStaticShapeTopK, CompareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticShapeTopK, combinations); +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticShapeTopK, combinations); } // namespace diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_transpose.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_transpose.cpp index 71e6d7cf7e5f44..81214680410cde 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_transpose.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_transpose.cpp @@ -104,7 +104,7 @@ class DynamicToStaticShapeTranspose : public CommonTestUtils::TestsCommon, publi TEST_P(DynamicToStaticShapeTranspose, CompareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticShapeTranspose, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticShapeTranspose, testing::Combine( testing::Values( ngraph::element::f16, ngraph::element::f32, diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_unary_elementwise.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_unary_elementwise.cpp index 55bef3bb2ceed8..317b8153344e0f 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_unary_elementwise.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_unary_elementwise.cpp @@ -76,7 +76,7 @@ class DynamicToStaticShapeUnaryElementwise : public CommonTestUtils::TestsCommon TEST_P(DynamicToStaticShapeUnaryElementwise, CompareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticShapeUnaryElementwise, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticShapeUnaryElementwise, testing::Combine( testing::Values( ngraph::element::f16, ngraph::element::f32, diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_unsqueeze.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_unsqueeze.cpp index 8684b1e6bbabe4..9be7cfc2a688f3 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_unsqueeze.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_unsqueeze.cpp @@ -111,7 +111,7 @@ public testing::WithParamInterface> { TEST_P(DynamicToStaticShapeUnsqueeze, CompareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticShapeUnsqueeze, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticShapeUnsqueeze, testing::Combine( testing::Values( ngraph::element::f16, ngraph::element::f32, diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_variadic_split.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_variadic_split.cpp index 8d871bdd6c5757..75ed78c0880f7a 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_variadic_split.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_variadic_split.cpp @@ -135,6 +135,6 @@ class DynamicToStaticShapeVeriadicSplit : public CommonTestUtils::TestsCommon, TEST_P(DynamicToStaticShapeVeriadicSplit, CompareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticShapeVeriadicSplit, combinations); +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticShapeVeriadicSplit, combinations); } // namespace diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/eliminate_shapeof_after_dsr.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/eliminate_shapeof_after_dsr.cpp index 15b7f6f434ecc3..15d863b446fcfc 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/eliminate_shapeof_after_dsr.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/eliminate_shapeof_after_dsr.cpp @@ -69,7 +69,7 @@ class EliminateShapeOfAfterDSRTest : public CommonTestUtils::TestsCommon, TEST_P(EliminateShapeOfAfterDSRTest, CompareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, EliminateShapeOfAfterDSRTest, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, EliminateShapeOfAfterDSRTest, testing::Combine( testing::Values( ngraph::element::f16, ngraph::element::f32, @@ -134,7 +134,7 @@ class EliminateShapeOfAfterDSRWithoutOutputDSR : public CommonTestUtils::TestsCo TEST_P(EliminateShapeOfAfterDSRWithoutOutputDSR, CompareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, EliminateShapeOfAfterDSRWithoutOutputDSR, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, EliminateShapeOfAfterDSRWithoutOutputDSR, testing::Combine( testing::Values( ngraph::element::f16, ngraph::element::f32, @@ -203,7 +203,7 @@ class EliminateShapeOfAfterDSRKeepDSR : public CommonTestUtils::TestsCommon, TEST_P(EliminateShapeOfAfterDSRKeepDSR, CompareFunctions) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, EliminateShapeOfAfterDSRKeepDSR, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, EliminateShapeOfAfterDSRKeepDSR, testing::Combine( testing::Values( ngraph::element::f16, ngraph::element::f32, diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/caching_tests.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/caching_tests.cpp index c7b1194c2940fc..6c17496e7c2f19 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/caching_tests.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/caching_tests.cpp @@ -31,7 +31,7 @@ namespace { return funcs; } - INSTANTIATE_TEST_CASE_P(smoke_CachingSupportCase_Myriad, LoadNetworkCacheTestBase, + INSTANTIATE_TEST_SUITE_P(smoke_CachingSupportCase_Myriad, LoadNetworkCacheTestBase, ::testing::Combine( ::testing::ValuesIn(smoke_functions()), ::testing::ValuesIn(smoke_precisionsMyriad), @@ -39,7 +39,7 @@ namespace { ::testing::Values(CommonTestUtils::DEVICE_MYRIAD)), LoadNetworkCacheTestBase::getTestCaseName); - INSTANTIATE_TEST_CASE_P(nightly_CachingSupportCase_Myriad, LoadNetworkCacheTestBase, + INSTANTIATE_TEST_SUITE_P(nightly_CachingSupportCase_Myriad, LoadNetworkCacheTestBase, ::testing::Combine( ::testing::ValuesIn(LoadNetworkCacheTestBase::getStandardFunctions()), ::testing::ValuesIn(nightly_precisionsMyriad), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/config.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/config.cpp index 773419d78f18e9..a045692d932c2d 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/config.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/config.cpp @@ -96,7 +96,7 @@ std::vector> getCorrectConfigs() { return correctConfigs; } -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectConfigTests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, CorrectConfigTests, ::testing::Combine( ::testing::ValuesIn(getPrecisions()), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), @@ -134,7 +134,7 @@ const std::vector>& getCorrectMultiConfigs() return correctMultiConfigs; } -INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, CorrectConfigTests, +INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, CorrectConfigTests, ::testing::Combine( ::testing::ValuesIn(getPrecisions()), ::testing::Values(CommonTestUtils::DEVICE_MULTI), @@ -148,7 +148,7 @@ const std::vector>& getDefaul return defaultEntries; } -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectSingleOptionDefaultValueConfigTests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, CorrectSingleOptionDefaultValueConfigTests, ::testing::Combine( ::testing::ValuesIn(getPrecisions()), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), @@ -176,7 +176,7 @@ const std::vector& getPublicOptions() { return publicOptions; } -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectConfigPublicOptionsTests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, CorrectConfigPublicOptionsTests, ::testing::Combine( ::testing::ValuesIn(getPrecisions()), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), @@ -203,7 +203,7 @@ const std::vector& getPrivateOptions() { return privateOptions; } -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectConfigPrivateOptionsTests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, CorrectConfigPrivateOptionsTests, ::testing::Combine( ::testing::ValuesIn(getPrecisions()), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), @@ -270,7 +270,7 @@ const std::vector>& getIncorrectConfigs() { return incorrectConfigs; } -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigTests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, IncorrectConfigTests, ::testing::Combine( ::testing::ValuesIn(getPrecisions()), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), @@ -313,41 +313,41 @@ const std::vector>& getIncorrectMultiConfigs( return incorrectMultiConfigs; } -INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, IncorrectConfigTests, +INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, IncorrectConfigTests, ::testing::Combine( ::testing::ValuesIn(getPrecisions()), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(getIncorrectMultiConfigs())), IncorrectConfigTests::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigSingleOptionTests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, IncorrectConfigSingleOptionTests, ::testing::Combine( ::testing::ValuesIn(getPrecisions()), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::Values("INCORRECT_KEY"))); -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectConfigAPITests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, CorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(getPrecisions()), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::Values(std::map{})), CorrectConfigAPITests::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, CorrectConfigAPITests, +INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, CorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(getPrecisions()), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(getCorrectMultiConfigs())), CorrectConfigAPITests::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigAPITests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, IncorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(getPrecisions()), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::Values(std::map{{"INCORRECT_KEY", "INCORRECT_VALUE"}})), IncorrectConfigAPITests::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, IncorrectConfigAPITests, +INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, IncorrectConfigAPITests, ::testing::Combine( ::testing::ValuesIn(getPrecisions()), ::testing::Values(CommonTestUtils::DEVICE_MULTI), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/core_integration.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/core_integration.cpp index 2eaa15ec86612f..0897d13c2d102e 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/core_integration.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/core_integration.cpp @@ -26,11 +26,11 @@ std::pair plugins[] = { // IE Class Common tests with // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( IEClassBasicTestP_smoke, IEClassBasicTestP, ::testing::ValuesIn(plugins)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( IEClassNetworkTestP_smoke, IEClassNetworkTestP, ::testing::ValuesIn(devices)); @@ -52,17 +52,17 @@ TEST_P(IEClassNetworkTestP_VPU_GetMetric, smoke_OptimizationCapabilitiesReturnsF ASSERT_EQ(optimizationCapabilities.front(), METRIC_VALUE(FP16)); } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassGetMetricP, IEClassNetworkTestP_VPU_GetMetric, ::testing::ValuesIn(devices)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassImportExportTestP, IEClassImportExportTestP, ::testing::Values(std::string(CommonTestUtils::DEVICE_MYRIAD), "HETERO:" + std::string(CommonTestUtils::DEVICE_MYRIAD))); #if defined(ENABLE_MKL_DNN) && ENABLE_MKL_DNN -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_IEClassImportExportTestP_HETERO_CPU, IEClassImportExportTestP, ::testing::Values("HETERO:" + std::string(CommonTestUtils::DEVICE_MYRIAD) + ",CPU")); #endif @@ -71,27 +71,27 @@ INSTANTIATE_TEST_CASE_P( // Executable Network GetMetric // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( IEClassExecutableNetworkGetMetricTest_nightly, IEClassExecutableNetworkGetMetricTest_ThrowsUnsupported, ::testing::ValuesIn(devices)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( IEClassExecutableNetworkGetMetricTest_nightly, IEClassExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS, ::testing::ValuesIn(devices)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( IEClassExecutableNetworkGetMetricTest_nightly, IEClassExecutableNetworkGetMetricTest_SUPPORTED_METRICS, ::testing::ValuesIn(devices)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( IEClassExecutableNetworkGetMetricTest_nightly, IEClassExecutableNetworkGetMetricTest_NETWORK_NAME, ::testing::ValuesIn(devices)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( IEClassExecutableNetworkGetMetricTest_nightly, IEClassExecutableNetworkGetMetricTest_OPTIMAL_NUMBER_OF_INFER_REQUESTS, ::testing::ValuesIn(devices)); @@ -100,7 +100,7 @@ INSTANTIATE_TEST_CASE_P( // Executable Network GetConfig // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( IEClassExecutableNetworkGetConfigTest_nightly, IEClassExecutableNetworkGetConfigTest, ::testing::ValuesIn(devices)); @@ -109,32 +109,32 @@ INSTANTIATE_TEST_CASE_P( // IE Class GetMetric // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( IEClassGetMetricTest_nightly, IEClassGetMetricTest_ThrowUnsupported, ::testing::ValuesIn(devices)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( IEClassGetMetricTest_nightly, IEClassGetMetricTest_AVAILABLE_DEVICES, ::testing::ValuesIn(devices)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( IEClassGetMetricTest_nightly, IEClassGetMetricTest_SUPPORTED_METRICS, ::testing::ValuesIn(devices)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( IEClassGetMetricTest_nightly, IEClassGetMetricTest_SUPPORTED_CONFIG_KEYS, ::testing::ValuesIn(devices)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( IEClassGetMetricTest_nightly, IEClassGetMetricTest_OPTIMIZATION_CAPABILITIES, ::testing::ValuesIn(devices)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( IEClassGetMetricTest_nightly, IEClassGetMetricTest_RANGE_FOR_ASYNC_INFER_REQUESTS, ::testing::ValuesIn(devices)); @@ -143,26 +143,26 @@ INSTANTIATE_TEST_CASE_P( // IE Class GetConfig // -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( IEClassGetConfigTest_nightly, IEClassGetConfigTest, ::testing::ValuesIn(devices)); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( IEClassGetConfigTest_nightly, IEClassGetConfigTest_ThrowUnsupported, ::testing::ValuesIn(devices)); // IE Class Query network -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( DISABLED_IEClassQueryNetworkTest_smoke, IEClassQueryNetworkTest, ::testing::ValuesIn(devices)); // IE Class Load network -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( IEClassLoadNetworkTest_smoke, IEClassLoadNetworkTest, ::testing::ValuesIn(devices)); diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/core_threading_tests.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/core_threading_tests.cpp index 9ca3ccb37dd15d..9a8a54b6991bb6 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/core_threading_tests.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/core_threading_tests.cpp @@ -14,9 +14,9 @@ Params params[] = { } // namespace -INSTANTIATE_TEST_CASE_P(MYRIAD, CoreThreadingTests, testing::ValuesIn(params), CoreThreadingTests::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(MYRIAD, CoreThreadingTests, testing::ValuesIn(params), CoreThreadingTests::getTestCaseName); -INSTANTIATE_TEST_CASE_P(DISABLED_MYRIAD, CoreThreadingTestsWithIterations, +INSTANTIATE_TEST_SUITE_P(DISABLED_MYRIAD, CoreThreadingTestsWithIterations, testing::Combine(testing::ValuesIn(params), testing::Values(2), testing::Values(2), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/cpp_holders.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/cpp_holders.cpp index 08de6a3269e129..d64be9c7ac0ba7 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/cpp_holders.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/cpp_holders.cpp @@ -18,19 +18,19 @@ namespace { {2, 1, 0} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, HoldersTest, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, HoldersTest, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::ValuesIn(orders)), HoldersTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, HoldersTestImportNetwork, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, HoldersTestImportNetwork, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::ValuesIn(orders)), HoldersTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, HoldersTestOnImportedNetwork, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, HoldersTestOnImportedNetwork, ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), HoldersTestOnImportedNetwork::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/detect_network_batch_test.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/detect_network_batch_test.cpp index d4d6ef76525934..16bf3b8462dd6e 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/detect_network_batch_test.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/detect_network_batch_test.cpp @@ -13,7 +13,7 @@ const std::vector batchSizes = { }; namespace { - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, DetectNetworkBatch, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, DetectNetworkBatch, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::ValuesIn(batchSizes)), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/exec_graph_info.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/exec_graph_info.cpp index e644dbc140bd93..1e62bb2da87034 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/exec_graph_info.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/exec_graph_info.cpp @@ -15,7 +15,7 @@ namespace { {} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, ExecGraphTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, ExecGraphTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/infer_request.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/infer_request.cpp index 931fefbf391f8e..5e515c8b562e91 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/infer_request.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/infer_request.cpp @@ -17,14 +17,14 @@ const std::vector> configs = { {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}} }; -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferRequestTests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferRequestTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::Values(std::map({}))), InferRequestTests::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, InferRequestTests, +INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, InferRequestTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/infer_request_callback.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/infer_request_callback.cpp index 71c5b891cce86b..4bb24fca393597 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/infer_request_callback.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/infer_request_callback.cpp @@ -18,14 +18,14 @@ const std::vector> multiConfigs = { {{ MULTI_CONFIG_KEY(DEVICE_PRIORITIES) , CommonTestUtils::DEVICE_MYRIAD}} }; -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CallbackTests, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, CallbackTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::ValuesIn(configs)), CallbackTests::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, CallbackTests, +INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, CallbackTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/infer_request_config.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/infer_request_config.cpp index d3ff02668a3a2a..eba711f7b209fd 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/infer_request_config.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/infer_request_config.cpp @@ -76,28 +76,28 @@ namespace { {VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), CONFIG_VALUE(YES)}}, }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferConfigTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferConfigTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::ValuesIn(configs)), InferConfigTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, InferConfigTests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, InferConfigTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(multiConfigs)), InferConfigTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferConfigInTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferConfigInTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::ValuesIn(inferConfigs)), InferConfigInTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, InferConfigInTests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, InferConfigInTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/infer_request_input.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/infer_request_input.cpp index 201f76cf0c41a7..8b97210ca01939 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/infer_request_input.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/infer_request_input.cpp @@ -19,14 +19,14 @@ namespace { {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferRequestInputTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferRequestInputTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::ValuesIn(configs)), InferRequestInputTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, InferRequestInputTests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, InferRequestInputTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/infer_request_output.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/infer_request_output.cpp index dfa9d4dfe3c8ac..4ef86349b9aa71 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/infer_request_output.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/infer_request_output.cpp @@ -19,14 +19,14 @@ namespace { {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, InferRequestOutputTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferRequestOutputTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::ValuesIn(configs)), InferRequestOutputTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, InferRequestOutputTests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, InferRequestOutputTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/layout.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/layout.cpp index b0f9d38c93b3a8..33f02720fef002 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/layout.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/layout.cpp @@ -24,7 +24,7 @@ namespace { { 3 } }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, LayoutTest, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, LayoutTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP16), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/query_network.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/query_network.cpp index bacbb6e4de2787..01d9aec269419c 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/query_network.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/query_network.cpp @@ -16,7 +16,7 @@ auto TIwithLSTMcell = ngraph::builder::subgraph::makeTIwithLSTMcell(); auto SplitConvConcat = ngraph::builder::subgraph::makeNestedSplitConvConcat(); auto BranchSplitConvConcat = ngraph::builder::subgraph::makeSplitConvConcatNestedInBranch(); -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, QueryNetworkTest, +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, QueryNetworkTest, ::testing::Combine( ::testing::Values("MYRIAD", "HETERO:MYRIAD,CPU", "MULTI:MYRIAD,CPU"), ::testing::Values(ConvBias, TIwithLSTMcell, SplitConvConcat, BranchSplitConvConcat)), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/set_preprocess.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/set_preprocess.cpp index 1071fa66da8691..7ef46d71e7e913 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/set_preprocess.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/set_preprocess.cpp @@ -20,14 +20,14 @@ namespace { {{ InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES , CommonTestUtils::DEVICE_MYRIAD}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, PreprocessTest, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, PreprocessTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::ValuesIn(configs)), PreprocessTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, PreprocessTest, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, PreprocessTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), @@ -48,7 +48,7 @@ namespace { InferenceEngine::Layout::NHWC }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, PreprocessConversionTest, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, PreprocessConversionTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(ioPrecisions), @@ -62,7 +62,7 @@ namespace { ::testing::ValuesIn(configs)), PreprocessConversionTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, PreprocessDynamicallyInSetBlobTest, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, PreprocessDynamicallyInSetBlobTest, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Bool(), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/stress_tests.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/stress_tests.cpp index 8655b88d39b564..8b65e6d3f5156b 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/stress_tests.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/stress_tests.cpp @@ -9,7 +9,7 @@ using namespace LayerTestsDefinitions; const unsigned int g_BugAllocationLimit = 10000; namespace { - INSTANTIATE_TEST_CASE_P(nightly_BehaviorTests, MultipleAllocations, + INSTANTIATE_TEST_SUITE_P(nightly_BehaviorTests, MultipleAllocations, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::Values(g_BugAllocationLimit)), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/test_plugin.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/test_plugin.cpp index 7e7353aebb5ffa..c41206a5b43e53 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/test_plugin.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/test_plugin.cpp @@ -29,42 +29,42 @@ namespace { InferenceEngine::Precision::FP16 }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, BehaviorTestOutput, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, BehaviorTestOutput, ::testing::Combine( ::testing::ValuesIn(netPrecision), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::ValuesIn(configs)), BehaviorTestOutput::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, BehaviorTestOutput, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, BehaviorTestOutput, ::testing::Combine( ::testing::ValuesIn(netPrecision), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(MultiConfigsInputOutput)), BehaviorTestOutput::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, BehaviorTests, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, BehaviorTests, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::ValuesIn(configs)), BehaviorTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, BehaviorTests, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, BehaviorTests, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(MultiConfigs)), BehaviorTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, BehaviorTestInput, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, BehaviorTestInput, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::ValuesIn(configs)), BehaviorTestInput::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, BehaviorTestInput, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, BehaviorTestInput, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MULTI), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/version.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/version.cpp index 8c7613862357d0..d5e9f9d9162702 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/version.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/version.cpp @@ -18,21 +18,21 @@ namespace { {{ HETERO_CONFIG_KEY(DUMP_GRAPH_DOT) , CommonTestUtils::DEVICE_MYRIAD}} }; - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, VersionTest, + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, VersionTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::ValuesIn(configs)), VersionTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, VersionTest, + INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, VersionTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(Multiconfigs)), VersionTest::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Hetero_BehaviorTests, VersionTest, + INSTANTIATE_TEST_SUITE_P(smoke_Hetero_BehaviorTests, VersionTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32), ::testing::Values(CommonTestUtils::DEVICE_HETERO), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/import_export_tests/import_nonzero.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/import_export_tests/import_nonzero.cpp index ccdbb4182af9a3..4555ac1ec9d0c1 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/import_export_tests/import_nonzero.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/import_export_tests/import_nonzero.cpp @@ -26,7 +26,7 @@ const std::vector appHeaders = { "APPLICATION_HEADER" }; -INSTANTIATE_TEST_CASE_P(smoke_ImportNetworkCase, ImportNonZero, +INSTANTIATE_TEST_SUITE_P(smoke_ImportNetworkCase, ImportNonZero, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/myriad_remote_blobs_tests.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/myriad_remote_blobs_tests.cpp index 7a6948044cb797..15324128621e0e 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/myriad_remote_blobs_tests.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/myriad_remote_blobs_tests.cpp @@ -14,5 +14,5 @@ const std::vector device_names_and_support_for_remot #endif }; -INSTANTIATE_TEST_CASE_P(smoke_RemoteBlobMultiMyriad, MultiDevice_SupportTest, +INSTANTIATE_TEST_SUITE_P(smoke_RemoteBlobMultiMyriad, MultiDevice_SupportTest, ::testing::ValuesIn(device_names_and_support_for_remote_blobs), MultiDevice_SupportTest::getTestCaseName); \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/activation.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/activation.cpp index e87e73f6e6f47c..7fff88eb0bbaa6 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/activation.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/activation.cpp @@ -48,6 +48,6 @@ const auto basicCases = ::testing::Combine( ); -INSTANTIATE_TEST_CASE_P(smoke_Activation_Basic, ActivationLayerTest, basicCases, ActivationLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Activation_Basic, ActivationLayerTest, basicCases, ActivationLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/comparison.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/comparison.cpp index f4cfc820195b7e..4485bbdea68516 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/comparison.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/comparison.cpp @@ -50,7 +50,7 @@ std::vector comparisonOpTypesFpToInt = { ngraph::helpers::ComparisonTypes::LESS, }; -INSTANTIATE_TEST_CASE_P(smoke_ComparisonFp, +INSTANTIATE_TEST_SUITE_P(smoke_ComparisonFp, ComparisonLayerTest, ::testing::Combine( ::testing::ValuesIn(CommonTestUtils::combineParams(inputShapes)), @@ -63,7 +63,7 @@ INSTANTIATE_TEST_CASE_P(smoke_ComparisonFp, ::testing::Values(Config{{InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)}})), ComparisonLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ComparisonInt, +INSTANTIATE_TEST_SUITE_P(smoke_ComparisonInt, ComparisonLayerTest, ::testing::Combine( ::testing::ValuesIn(CommonTestUtils::combineParams(inputShapes)), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/concat.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/concat.cpp index f9500dad7e6226..228c892fa3ac3e 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/concat.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/concat.cpp @@ -20,7 +20,7 @@ std::vector>> inShapes = { std::vector netPrecisions = {InferenceEngine::Precision::FP16}; -INSTANTIATE_TEST_CASE_P(smoke_Concat_Basic, ConcatLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Concat_Basic, ConcatLayerTest, ::testing::Combine( ::testing::ValuesIn(axes), ::testing::ValuesIn(inShapes), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/convolution.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/convolution.cpp index ac5285cad1bad9..43a582b89fe71f 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/convolution.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/convolution.cpp @@ -60,7 +60,7 @@ const auto conv2DParams_BigDimensionValid = ::testing::Combine( ::testing::Values(ngraph::op::PadType::VALID) ); -INSTANTIATE_TEST_CASE_P(smoke_Convolution2D_ExplicitPadding, ConvolutionLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Convolution2D_ExplicitPadding, ConvolutionLayerTest, ::testing::Combine( conv2DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions), @@ -72,7 +72,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Convolution2D_ExplicitPadding, ConvolutionLayerTes ::testing::Values(CommonTestUtils::DEVICE_MYRIAD)), ConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Convolution2D_AutoPadValid, ConvolutionLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Convolution2D_AutoPadValid, ConvolutionLayerTest, ::testing::Combine( conv2DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions), @@ -83,7 +83,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Convolution2D_AutoPadValid, ConvolutionLayerTest, ::testing::Values(std::vector({1, 3, 30, 30})), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD)), ConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Convolution2D_BigDimensionValid, ConvolutionLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Convolution2D_BigDimensionValid, ConvolutionLayerTest, ::testing::Combine( conv2DParams_BigDimensionValid, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/ctc_greedy_decoder_seq_len.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/ctc_greedy_decoder_seq_len.cpp index c3866b9621ccc2..5025da6e91f61a 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/ctc_greedy_decoder_seq_len.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/ctc_greedy_decoder_seq_len.cpp @@ -29,7 +29,7 @@ const auto sequenceLengths = std::vector{1, 10, 50, 100}; const auto blankIndexes = std::vector{0, 10, 100}; -INSTANTIATE_TEST_CASE_P(smoke, CTCGreedyDecoderSeqLenLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke, CTCGreedyDecoderSeqLenLayerTest, ::testing::Combine( ::testing::ValuesIn(inputShape), ::testing::ValuesIn(sequenceLengths), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/eltwise.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/eltwise.cpp index dc258dec53825e..6821c49494a185 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/eltwise.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/eltwise.cpp @@ -55,7 +55,7 @@ std::vector eltwiseMathTypesINT = { ngraph::helpers::EltwiseTypes::DIVIDE, }; -INSTANTIATE_TEST_CASE_P(smoke_EltwiseMathFP, +INSTANTIATE_TEST_SUITE_P(smoke_EltwiseMathFP, EltwiseLayerTest, ::testing::Combine( ::testing::ValuesIn(inShapes), @@ -70,7 +70,7 @@ INSTANTIATE_TEST_CASE_P(smoke_EltwiseMathFP, ::testing::Values(Config{{InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)}})), EltwiseLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_EltwiseMathInt, +INSTANTIATE_TEST_SUITE_P(smoke_EltwiseMathInt, EltwiseLayerTest, ::testing::Combine( ::testing::ValuesIn(inShapes), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/gather_elements.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/gather_elements.cpp index e6dae4781080fa..55843e804bf32d 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/gather_elements.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/gather_elements.cpp @@ -33,7 +33,7 @@ const std::vector iPrecisions = { InferenceEngine::Precision::I32 }; -INSTANTIATE_TEST_CASE_P(smoke_GatherElements1, GatherElementsLayerTestVPU, +INSTANTIATE_TEST_SUITE_P(smoke_GatherElements1, GatherElementsLayerTestVPU, ::testing::Combine( ::testing::Values(std::vector({2, 2})), // Data shape ::testing::Values(std::vector({2, 2})), // Indices shape @@ -43,7 +43,7 @@ INSTANTIATE_TEST_CASE_P(smoke_GatherElements1, GatherElementsLayerTestVPU, ::testing::Values(CommonTestUtils::DEVICE_MYRIAD)), GatherElementsLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_GatherElements2, GatherElementsLayerTestVPU, +INSTANTIATE_TEST_SUITE_P(smoke_GatherElements2, GatherElementsLayerTestVPU, ::testing::Combine( ::testing::Values(std::vector({2, 65, 300})), // Data shape ::testing::Values(std::vector({2, 65, 64})), // Indices shape diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/gather_nd.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/gather_nd.cpp index d6dbf6f534913c..dc01dde5d878a3 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/gather_nd.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/gather_nd.cpp @@ -39,7 +39,7 @@ const std::vector layerParams = { GatherNDParamsSubset{{2, 2, 2, 2}, {2, 2, 1}, 2}, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_GatherND, GatherNDLayerTest, testing::Combine( diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/interpolate.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/interpolate.cpp index 3c7d701c09ef75..31d17ca51ba607 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/interpolate.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/interpolate.cpp @@ -179,7 +179,7 @@ const auto interpolateCasesWithoutNearestMode = ::testing::Combine( ::testing::ValuesIn(defaultAxes), ::testing::ValuesIn(defaultScales)); -INSTANTIATE_TEST_CASE_P(smoke_Interpolate_nearest_mode_no_batch, InterpolateLayerTest, ::testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_Interpolate_nearest_mode_no_batch, InterpolateLayerTest, ::testing::Combine( interpolateCasesNearestMode, ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), @@ -192,7 +192,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_nearest_mode_no_batch, InterpolateLaye ::testing::Values(Config{{InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)}})), InterpolateLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Interpolate_without_nearest_mode_no_batch, InterpolateLayerTest, ::testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_Interpolate_without_nearest_mode_no_batch, InterpolateLayerTest, ::testing::Combine( interpolateCasesWithoutNearestMode, ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), @@ -205,7 +205,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_without_nearest_mode_no_batch, Interpo ::testing::Values(Config{{InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)}})), InterpolateLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Interpolate_nearest_mode, InterpolateLayerTest, ::testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_Interpolate_nearest_mode, InterpolateLayerTest, ::testing::Combine( interpolateCasesNearestMode, ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), @@ -218,7 +218,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_nearest_mode, InterpolateLayerTest, :: ::testing::Values(Config{{InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)}})), InterpolateLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Interpolate_nearest_mode_more, InterpolateLayerTest, ::testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_Interpolate_nearest_mode_more, InterpolateLayerTest, ::testing::Combine( interpolateCasesNearestModeMore, ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), @@ -231,7 +231,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_nearest_mode_more, InterpolateLayerTes ::testing::Values(Config{{InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)}})), InterpolateLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Interpolate_without_nearest, InterpolateLayerTest, ::testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_Interpolate_without_nearest, InterpolateLayerTest, ::testing::Combine( interpolateCasesWithoutNearestMode, ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), @@ -244,7 +244,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_without_nearest, InterpolateLayerTest, ::testing::Values(Config{{InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)}})), InterpolateLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(nightly_Interpolate_without_nearest, InterpolateLayerTest, ::testing::Combine( +INSTANTIATE_TEST_SUITE_P(nightly_Interpolate_without_nearest, InterpolateLayerTest, ::testing::Combine( interpolateCasesWithoutNearestMode, ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), @@ -257,7 +257,7 @@ INSTANTIATE_TEST_CASE_P(nightly_Interpolate_without_nearest, InterpolateLayerTes ::testing::Values(Config{{InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)}})), InterpolateLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(nightly_Interpolate_nearest_mode_2x, InterpolateLayerTest, ::testing::Combine( +INSTANTIATE_TEST_SUITE_P(nightly_Interpolate_nearest_mode_2x, InterpolateLayerTest, ::testing::Combine( interpolateCasesNearestMode2x, ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/logical.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/logical.cpp index 8c1202dba66551..d4dd50db3e18b7 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/logical.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/logical.cpp @@ -66,7 +66,7 @@ std::map additional_config = { {InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)} }; -INSTANTIATE_TEST_CASE_P(smoke_EltwiseLogicalInt, +INSTANTIATE_TEST_SUITE_P(smoke_EltwiseLogicalInt, LogicalLayerTestVPU, ::testing::Combine( ::testing::ValuesIn(LogicalLayerTest::combineShapes(inputShapes)), @@ -81,7 +81,7 @@ INSTANTIATE_TEST_CASE_P(smoke_EltwiseLogicalInt, ::testing::Values(additional_config)), LogicalLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_EltwiseLogicalNotInt, +INSTANTIATE_TEST_SUITE_P(smoke_EltwiseLogicalNotInt, LogicalLayerTest, ::testing::Combine( ::testing::ValuesIn(LogicalLayerTest::combineShapes(inputShapesNot)), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/mat_mul.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/mat_mul.cpp index f947367633bba5..fcfa981c0e827f 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/mat_mul.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/mat_mul.cpp @@ -31,7 +31,7 @@ Config additionalConfig = { {InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)} }; -INSTANTIATE_TEST_CASE_P(smoke_MatMul, MatMulTest, +INSTANTIATE_TEST_SUITE_P(smoke_MatMul, MatMulTest, ::testing::Combine( ::testing::ValuesIn(shapeRelatedParams), ::testing::ValuesIn(inputPrecisions), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/minimum_maximum.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/minimum_maximum.cpp index 8db8e1297d32df..d174e19756d1ef 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/minimum_maximum.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/minimum_maximum.cpp @@ -33,7 +33,7 @@ const std::vector inputType = { ngraph::helpers::InputLayerType::PARAMETER, }; -INSTANTIATE_TEST_CASE_P(smoke_maximum, MaxMinLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_maximum, MaxMinLayerTest, ::testing::Combine( ::testing::ValuesIn(inShapes), ::testing::ValuesIn(opType), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/mvn.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/mvn.cpp index 1dc99bdd642978..2c78d5c6698a36 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/mvn.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/mvn.cpp @@ -35,7 +35,7 @@ const std::vector eps = { 1.0e-10, 1.0e-8, 1.0e-7, 1.0e-5, 1.0e-3 }; -INSTANTIATE_TEST_CASE_P(smoke_MVN_4D, Mvn6LayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MVN_4D, Mvn6LayerTest, ::testing::Combine( ::testing::ValuesIn(input_shape_4D), ::testing::Values(InferenceEngine::Precision::FP16), @@ -47,7 +47,7 @@ INSTANTIATE_TEST_CASE_P(smoke_MVN_4D, Mvn6LayerTest, ::testing::Values(CommonTestUtils::DEVICE_MYRIAD)), Mvn6LayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_MVN_3D, Mvn6LayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MVN_3D, Mvn6LayerTest, ::testing::Combine( ::testing::ValuesIn(input_shape_3D), ::testing::Values(InferenceEngine::Precision::FP16), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/nonzero.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/nonzero.cpp index 592236bb34bd23..b418a50da73f07 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/nonzero.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/nonzero.cpp @@ -38,7 +38,7 @@ const std::vector inputPrecisions = { InferenceEngine::Precision::U8, }; -INSTANTIATE_TEST_CASE_P(smoke_nonzero, NonZeroLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_nonzero, NonZeroLayerTest, ::testing::Combine( ::testing::ValuesIn(inShapes), ::testing::ValuesIn(inputPrecisions), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/pad.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/pad.cpp index ce681365a1c2b2..a4b5d32c220f24 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/pad.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/pad.cpp @@ -37,7 +37,7 @@ const auto pad4DConstParams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_MYRIAD) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Pad4DConst, PadLayerTest, pad4DConstParams, @@ -57,7 +57,7 @@ const auto pad4DParams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_MYRIAD) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Pad4D, PadLayerTest, pad4DParams, @@ -77,7 +77,7 @@ const auto pad3DConstParams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_MYRIAD) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Pad3DConst, PadLayerTest, pad3DConstParams, @@ -97,7 +97,7 @@ const auto pad3DParams = testing::Combine( testing::Values(CommonTestUtils::DEVICE_MYRIAD) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Pad3D, PadLayerTest, pad3DParams, diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/pooling.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/pooling.cpp index 0909880261ba90..83f4c60039dc46 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/pooling.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/pooling.cpp @@ -40,7 +40,7 @@ const auto maxPool_ExplicitPad_FloorRounding_Params = ::testing::Combine( ::testing::Values(false) // placeholder value - exclude pad not applicable for max pooling ); -INSTANTIATE_TEST_CASE_P(smoke_MaxPool_ExplicitPad_FloorRpunding, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_ExplicitPad_FloorRpunding, PoolingLayerTest, ::testing::Combine( maxPool_ExplicitPad_FloorRounding_Params, ::testing::ValuesIn(netPrecisions), @@ -67,7 +67,7 @@ const auto maxPool_ExplicitPad_CeilRounding_Params = ::testing::Combine( ::testing::Values(false) // placeholder value - exclude pad not applicable for max pooling ); -INSTANTIATE_TEST_CASE_P(smoke_MaxPool_ExplicitPad_CeilRpunding, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_ExplicitPad_CeilRpunding, PoolingLayerTest, ::testing::Combine( maxPool_ExplicitPad_CeilRounding_Params, ::testing::ValuesIn(netPrecisions), @@ -96,7 +96,7 @@ const auto avgPoolExplicitPadCeilRoundingParams = ::testing::Combine( ::testing::Values(true, false) ); -INSTANTIATE_TEST_CASE_P(smoke_AvgPool_ExplicitPad_CeilRounding, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_ExplicitPad_CeilRounding, PoolingLayerTest, ::testing::Combine( avgPoolExplicitPadCeilRoundingParams, ::testing::ValuesIn(netPrecisions), @@ -122,7 +122,7 @@ const auto avgPoolExplicitPadFloorRoundingParams = ::testing::Combine( ); -INSTANTIATE_TEST_CASE_P(smoke_AvgPool_ExplicitPad_FloorRounding, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_ExplicitPad_FloorRounding, PoolingLayerTest, ::testing::Combine( avgPoolExplicitPadFloorRoundingParams, ::testing::ValuesIn(netPrecisions), @@ -149,7 +149,7 @@ const auto allPools_ValidPad_Params = ::testing::Combine( ::testing::Values(false) // placeholder value - exclude pad not applicable for max pooling ); -INSTANTIATE_TEST_CASE_P(smoke_MAX_and_AVGPool_ValidPad, PoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MAX_and_AVGPool_ValidPad, PoolingLayerTest, ::testing::Combine( allPools_ValidPad_Params, ::testing::ValuesIn(netPrecisions), @@ -175,7 +175,7 @@ const auto avgGlobalPoolParams = ::testing::Combine( ::testing::Values(false) ); -INSTANTIATE_TEST_CASE_P(smoke_GlobalAvgPool, GlobalPoolingLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_GlobalAvgPool, GlobalPoolingLayerTest, ::testing::Combine( avgGlobalPoolParams, ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/proposal.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/proposal.cpp index 103dff03d6f15d..438274a55f1d3f 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/proposal.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/proposal.cpp @@ -40,7 +40,7 @@ const auto proposalParams = ::testing::Combine( ::testing::ValuesIn(framework_) ); -INSTANTIATE_TEST_CASE_P(smoke_Proposal_tests, ProposalLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Proposal_tests, ProposalLayerTest, ::testing::Combine( proposalParams, ::testing::Values(CommonTestUtils::DEVICE_MYRIAD)), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/roi_pooling.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/roi_pooling.cpp index 66baf439e144bf..d28509dbe33bf2 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/roi_pooling.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/roi_pooling.cpp @@ -52,7 +52,7 @@ const auto test_ROIPooling_bilinear = ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_MYRIAD) ); -INSTANTIATE_TEST_CASE_P(smoke_TestsROIPooling_max, ROIPoolingLayerTest, test_ROIPooling_max, ROIPoolingLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_TestsROIPooling_bilinear, ROIPoolingLayerTest, test_ROIPooling_bilinear, ROIPoolingLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsROIPooling_max, ROIPoolingLayerTest, test_ROIPooling_max, ROIPoolingLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsROIPooling_bilinear, ROIPoolingLayerTest, test_ROIPooling_bilinear, ROIPoolingLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/split.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/split.cpp index 11afafbc42ac4f..5e69eebc5032c4 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/split.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/split.cpp @@ -14,7 +14,7 @@ const std::vector netPrecisions = { InferenceEngine::Precision::FP16 }; -INSTANTIATE_TEST_CASE_P(smoke_NumSplitsCheck, SplitLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_NumSplitsCheck, SplitLayerTest, ::testing::Combine( ::testing::Values(5), // TODO: 0-axis excluded @@ -32,7 +32,7 @@ INSTANTIATE_TEST_CASE_P(smoke_NumSplitsCheck, SplitLayerTest, ::testing::Values(CommonTestUtils::DEVICE_MYRIAD)), SplitLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_splitWithUnusedOutputsTest, SplitLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_splitWithUnusedOutputsTest, SplitLayerTest, ::testing::Combine( ::testing::Values(5), // TODO: 0-axis excluded diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/strided_slice.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/strided_slice.cpp index 6c4003a3f3a08f..33893ae4241933 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/strided_slice.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/strided_slice.cpp @@ -55,7 +55,7 @@ Config getConfig() { return Config{ { InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO) } }; } -INSTANTIATE_TEST_CASE_P(smoke_StridedSlice_tests, StridedSliceLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_StridedSlice_tests, StridedSliceLayerTest, ::testing::Combine( ::testing::ValuesIn(testCases), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/topk.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/topk.cpp index 9b3e4c7239d4ae..722f528d876e62 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/topk.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/topk.cpp @@ -40,7 +40,7 @@ const std::vector sortTypes = { ngraph::opset5::TopK::SortType::SORT_VALUES, }; -INSTANTIATE_TEST_CASE_P(smoke_TopK_IndicesValuesSort, TopKLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_TopK_IndicesValuesSort, TopKLayerTest, ::testing::Combine( ::testing::ValuesIn(k), ::testing::ValuesIn(axes), @@ -54,7 +54,7 @@ INSTANTIATE_TEST_CASE_P(smoke_TopK_IndicesValuesSort, TopKLayerTest, ::testing::Values(CommonTestUtils::DEVICE_MYRIAD)), TopKLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_TopK_NoneSort, TopKLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_TopK_NoneSort, TopKLayerTest, ::testing::Combine( ::testing::Values(1), ::testing::ValuesIn(axes), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/subgraph_tests/constant_result.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/subgraph_tests/constant_result.cpp index 19fdc4ba9bf34f..919fcdef3d05a1 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/subgraph_tests/constant_result.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/subgraph_tests/constant_result.cpp @@ -34,7 +34,7 @@ const std::vector precisions = { Precision::BOOL }; -INSTANTIATE_TEST_CASE_P(smoke_Check, ConstantResultSubgraphTest, +INSTANTIATE_TEST_SUITE_P(smoke_Check, ConstantResultSubgraphTest, ::testing::Combine( ::testing::ValuesIn(types), ::testing::ValuesIn(shapes), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/subgraph_tests/reshape_squeeze_reshape_relu.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/subgraph_tests/reshape_squeeze_reshape_relu.cpp index bdc85b7ae9ff43..6636ef971ff19f 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/subgraph_tests/reshape_squeeze_reshape_relu.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/subgraph_tests/reshape_squeeze_reshape_relu.cpp @@ -32,7 +32,7 @@ namespace { ngraph::helpers::SqueezeOpType::UNSQUEEZE }; - INSTANTIATE_TEST_CASE_P(DISABLED_reshape_squeeze_reshape_relu, ReshapeSqueezeReshapeRelu, + INSTANTIATE_TEST_SUITE_P(DISABLED_reshape_squeeze_reshape_relu, ReshapeSqueezeReshapeRelu, ::testing::Combine( ::testing::ValuesIn(inputs), ::testing::ValuesIn(netPrecisions), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/subgraph_tests/split_conv_concat.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/subgraph_tests/split_conv_concat.cpp index 2688eed42fc06c..82224e56375d20 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/subgraph_tests/split_conv_concat.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/subgraph_tests/split_conv_concat.cpp @@ -15,7 +15,7 @@ const std::vector netPrecisions = { InferenceEngine::Precision::FP16 }; -INSTANTIATE_TEST_CASE_P(smoke_NoReshape, SplitConvConcat, +INSTANTIATE_TEST_SUITE_P(smoke_NoReshape, SplitConvConcat, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(std::vector({1, 6, 40, 40})), diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/subgraph_tests/tensor_names.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/subgraph_tests/tensor_names.cpp index b89622fb297f82..76fbf656b6f808 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/subgraph_tests/tensor_names.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/subgraph_tests/tensor_names.cpp @@ -10,7 +10,7 @@ using namespace SubgraphTestsDefinitions; namespace { - INSTANTIATE_TEST_CASE_P(smoke_Check, TensorNamesTest, + INSTANTIATE_TEST_SUITE_P(smoke_Check, TensorNamesTest, ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), TensorNamesTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/myriad/single_layer_tests/gather.cpp b/inference-engine/tests/functional/plugin/myriad/single_layer_tests/gather.cpp index d882c3ba7c2a82..96e245fad63fce 100644 --- a/inference-engine/tests/functional/plugin/myriad/single_layer_tests/gather.cpp +++ b/inference-engine/tests/functional/plugin/myriad/single_layer_tests/gather.cpp @@ -108,7 +108,7 @@ TEST_P(MyriadGatherLayerTest, accuracy) { Run(); } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( smoke_Gather, MyriadGatherLayerTest, testing::Combine( diff --git a/inference-engine/tests/functional/plugin/myriad/single_layer_tests/out_shape_of_reshape.cpp b/inference-engine/tests/functional/plugin/myriad/single_layer_tests/out_shape_of_reshape.cpp index 61b27f909e758e..681c14d3ce61ab 100644 --- a/inference-engine/tests/functional/plugin/myriad/single_layer_tests/out_shape_of_reshape.cpp +++ b/inference-engine/tests/functional/plugin/myriad/single_layer_tests/out_shape_of_reshape.cpp @@ -111,7 +111,7 @@ std::vector shapeParams = { std::make_tuple(InputShape{ 2, 5, 5, 0 }, ShapeDescriptor{ 0, 4 }, false), }; -INSTANTIATE_TEST_CASE_P(smoke_accuracy, OutShapeOfReshapeLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_accuracy, OutShapeOfReshapeLayerTest, ::testing::Combine( ::testing::ValuesIn(shapeParams), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD)), diff --git a/inference-engine/tests/functional/plugin/myriad/single_layer_tests/static_shape_broadcast.cpp b/inference-engine/tests/functional/plugin/myriad/single_layer_tests/static_shape_broadcast.cpp index fb1f38f1ae46ea..a1f62c1ce1a8af 100644 --- a/inference-engine/tests/functional/plugin/myriad/single_layer_tests/static_shape_broadcast.cpp +++ b/inference-engine/tests/functional/plugin/myriad/single_layer_tests/static_shape_broadcast.cpp @@ -124,7 +124,7 @@ std::vector broadcastPrecisions = { InferenceEngine::Precision::I32, }; -INSTANTIATE_TEST_CASE_P(smoke_accuracy, StaticShapeBroadcastLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_accuracy, StaticShapeBroadcastLayerTest, ::testing::Combine( ::testing::ValuesIn(broadcastParam), ::testing::ValuesIn(broadcastPrecisions), diff --git a/inference-engine/tests/functional/plugin/myriad/single_layer_tests/static_shape_nms.cpp b/inference-engine/tests/functional/plugin/myriad/single_layer_tests/static_shape_nms.cpp index ea5a44ed98817f..83dd6dd2b04fe4 100644 --- a/inference-engine/tests/functional/plugin/myriad/single_layer_tests/static_shape_nms.cpp +++ b/inference-engine/tests/functional/plugin/myriad/single_layer_tests/static_shape_nms.cpp @@ -115,7 +115,7 @@ std::vector NMSPrecisions = { }; // #-30919 -INSTANTIATE_TEST_CASE_P(DISABLED_accuracy, StaticShapeNMSLayerTest, +INSTANTIATE_TEST_SUITE_P(DISABLED_accuracy, StaticShapeNMSLayerTest, ::testing::Combine( ::testing::ValuesIn(NMSParams), ::testing::ValuesIn(NMSPrecisions), @@ -170,7 +170,7 @@ TEST_P(NMS1toStaticShapeNMS, PreviousNMSCanBeLoaded) { ASSERT_NO_THROW(LoadNetwork()); } -INSTANTIATE_TEST_CASE_P(smoke_NetworkLoad, NMS1toStaticShapeNMS, +INSTANTIATE_TEST_SUITE_P(smoke_NetworkLoad, NMS1toStaticShapeNMS, ::testing::Values(CommonTestUtils::DEVICE_MYRIAD)); class NMS3toStaticShapeNMS : public PreviousNMStoStaticShapeNMS { @@ -190,7 +190,7 @@ TEST_P(NMS3toStaticShapeNMS, PreviousNMSCanBeLoaded) { ASSERT_NO_THROW(LoadNetwork()); } -INSTANTIATE_TEST_CASE_P(smoke_NetworkLoad, NMS3toStaticShapeNMS, +INSTANTIATE_TEST_SUITE_P(smoke_NetworkLoad, NMS3toStaticShapeNMS, ::testing::Values(CommonTestUtils::DEVICE_MYRIAD)); class NMS4toStaticShapeNMS : public PreviousNMStoStaticShapeNMS { @@ -211,7 +211,7 @@ TEST_P(NMS4toStaticShapeNMS, PreviousNMSCanBeLoaded) { ASSERT_NO_THROW(LoadNetwork()); } -INSTANTIATE_TEST_CASE_P(smoke_NetworkLoad, NMS4toStaticShapeNMS, +INSTANTIATE_TEST_SUITE_P(smoke_NetworkLoad, NMS4toStaticShapeNMS, ::testing::Values(CommonTestUtils::DEVICE_MYRIAD)); } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/myriad/single_layer_tests/static_shape_nonzero.cpp b/inference-engine/tests/functional/plugin/myriad/single_layer_tests/static_shape_nonzero.cpp index 6833f2b0f2d406..c268a97753c363 100644 --- a/inference-engine/tests/functional/plugin/myriad/single_layer_tests/static_shape_nonzero.cpp +++ b/inference-engine/tests/functional/plugin/myriad/single_layer_tests/static_shape_nonzero.cpp @@ -111,7 +111,7 @@ std::vector inputPrecisions = { InferenceEngine::Precision::I32, }; -INSTANTIATE_TEST_CASE_P(smoke_accuracy, StaticShapeNonZeroLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_accuracy, StaticShapeNonZeroLayerTest, ::testing::Combine( ::testing::ValuesIn(inputDims), ::testing::ValuesIn(inputPrecisions), diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/concat_split_transpose.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/concat_split_transpose.cpp index 7845ee434f5507..1293b7e9609c7f 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/concat_split_transpose.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/concat_split_transpose.cpp @@ -74,7 +74,7 @@ std::vector> length = { {500, 500} }; -INSTANTIATE_TEST_CASE_P(SpecialStages, Concat_Split_Transpose, +INSTANTIATE_TEST_SUITE_P(SpecialStages, Concat_Split_Transpose, ::testing::Combine( ::testing::Values(ngraph::element::i32), ::testing::ValuesIn(dims), diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_binary_elementwise.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_binary_elementwise.cpp index 279dc7a783d291..003799dba8452b 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_binary_elementwise.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_binary_elementwise.cpp @@ -92,7 +92,7 @@ TEST_P(DSR_BinaryElementwiseBothDSR, CompareWithReference) { const auto& eltwiseType = std::get<2>(GetParam()); if (doNotSupportI32.count(eltwiseType) && inDataType == ngraph::element::i32) { - SKIP() << eltwiseType.name << " doesn't support int32_t inputs" << std::endl; + GTEST_SKIP() << eltwiseType.name << " doesn't support int32_t inputs" << std::endl; } Run(); @@ -105,7 +105,7 @@ std::vector dataShapesWithUpperBound = { }, }; -INSTANTIATE_TEST_CASE_P(smoke_DynamicBinaryElementwise, DSR_BinaryElementwiseBothDSR, +INSTANTIATE_TEST_SUITE_P(smoke_DynamicBinaryElementwise, DSR_BinaryElementwiseBothDSR, ::testing::Combine( ::testing::Values(ngraph::element::f16, ngraph::element::f32, ngraph::element::i32), ::testing::ValuesIn(dataShapesWithUpperBound), @@ -117,7 +117,7 @@ TEST_P(DSR_BinaryElementwiseSingleDSR, CompareWithReference) { const auto& eltwiseType = std::get<2>(GetParam()); if (doNotSupportI32.count(eltwiseType) && inDataType == ngraph::element::i32) { - SKIP() << eltwiseType.name << " doesn't support int32_t inputs" << std::endl; + GTEST_SKIP() << eltwiseType.name << " doesn't support int32_t inputs" << std::endl; } Run(); @@ -130,7 +130,7 @@ std::vector dataShapesWithUpperBoundSingleDSR = { }, }; -INSTANTIATE_TEST_CASE_P(smoke_DynamicBinaryElementwiseSingleDSR, DSR_BinaryElementwiseSingleDSR, +INSTANTIATE_TEST_SUITE_P(smoke_DynamicBinaryElementwiseSingleDSR, DSR_BinaryElementwiseSingleDSR, ::testing::Combine( ::testing::Values(ngraph::element::f16, ngraph::element::f32, ngraph::element::i32), ::testing::ValuesIn(dataShapesWithUpperBoundSingleDSR), @@ -169,7 +169,7 @@ TEST_P(DSR_BinaryElementwiseBothDSRCheckOutputShape, CheckOutputShape) { const auto& eltwiseType = std::get<2>(GetParam()); if (doNotSupportI32.count(eltwiseType) && inDataType == ngraph::element::i32) { - SKIP() << eltwiseType.name << " doesn't support int32_t inputs" << std::endl; + GTEST_SKIP() << eltwiseType.name << " doesn't support int32_t inputs" << std::endl; } Run(); @@ -334,7 +334,7 @@ std::vector dataShapesWithUpperBoundBothDSREmpty = { }, }; -INSTANTIATE_TEST_CASE_P(smoke_BinaryElementwiseBothDSRCheckOutputShape, DSR_BinaryElementwiseBothDSRCheckOutputShape, +INSTANTIATE_TEST_SUITE_P(smoke_BinaryElementwiseBothDSRCheckOutputShape, DSR_BinaryElementwiseBothDSRCheckOutputShape, ::testing::Combine( ::testing::Values(ngraph::element::f16, ngraph::element::f32, ngraph::element::i32), ::testing::ValuesIn(dataShapesWithUpperBoundBothDSREmpty), diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_clamp.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_clamp.cpp index 1cc7abf4ca9bb2..6d80220fbccee2 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_clamp.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_clamp.cpp @@ -38,7 +38,7 @@ TEST_P(DSR_Clamp, CompareWithReference) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_DynamicClamp, DSR_Clamp, +INSTANTIATE_TEST_SUITE_P(smoke_DynamicClamp, DSR_Clamp, ::testing::Combine( ::testing::Values(ngraph::element::f16, ngraph::element::f32), ::testing::Values(DataShapeWithUpperBound{DataShape{1, 800}, DataShape{2, 1000}}), diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_concat.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_concat.cpp index 58d3c5d4357970..81d1f3219f30a2 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_concat.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_concat.cpp @@ -98,7 +98,7 @@ std::vector concatParams = { }, }; -INSTANTIATE_TEST_CASE_P(smoke_DynamicConcat, DSR_Concat, ::testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_DynamicConcat, DSR_Concat, ::testing::Combine( ::testing::ValuesIn(dataTypes), ::testing::ValuesIn(concatParams), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD))); diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_convert.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_convert.cpp index 7ba067a7e7494c..99af45c332378b 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_convert.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_convert.cpp @@ -49,7 +49,7 @@ std::vector dataTypeConversionPairVector { {ngraph::element::f16, ngraph::element::i32}, }; -INSTANTIATE_TEST_CASE_P(smoke_DynamicConvert, DSR_Convert, +INSTANTIATE_TEST_SUITE_P(smoke_DynamicConvert, DSR_Convert, ::testing::Combine( ::testing::ValuesIn(dataTypeConversionPairVector), ::testing::Values(DataShapeWithUpperBound{ngraph::Shape{1, 800}, ngraph::Shape{2, 1000}}, diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_gather.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_gather.cpp index 628383b5bf6fa3..3d4b5be8dfb83c 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_gather.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_gather.cpp @@ -50,7 +50,7 @@ TEST_P(DSR_GatherDynamicDataStaticIdx, CompareWithReference) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_DynamicGatherData, DSR_GatherDynamicDataStaticIdx, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_DynamicGatherData, DSR_GatherDynamicDataStaticIdx, testing::Combine( testing::ValuesIn(dataTypeVector), testing::ValuesIn(idxTypeVector), testing::Values( @@ -88,7 +88,7 @@ TEST_P(DSR_GatherStaticDataDynamicIdx, CompareWithReference) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_DynamicGatherIdx, DSR_GatherStaticDataDynamicIdx, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_DynamicGatherIdx, DSR_GatherStaticDataDynamicIdx, testing::Combine( testing::ValuesIn(dataTypeVector), testing::ValuesIn(idxTypeVector), testing::Values( @@ -125,7 +125,7 @@ TEST_P(DSR_GatherDynamicDataDynamicIdx, CompareWithReference) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_DynamicGather, DSR_GatherDynamicDataDynamicIdx, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_DynamicGather, DSR_GatherDynamicDataDynamicIdx, testing::Combine( testing::ValuesIn(dataTypeVector), testing::ValuesIn(idxTypeVector), testing::Values( diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_gather_elements.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_gather_elements.cpp index fd27c196162d53..0529858d58112f 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_gather_elements.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_gather_elements.cpp @@ -49,7 +49,7 @@ TEST_P(DSR_GatherElements, CompareWithReference) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_DynamicGatherElements, DSR_GatherElements, +INSTANTIATE_TEST_SUITE_P(smoke_DynamicGatherElements, DSR_GatherElements, testing::Combine( testing::ValuesIn(dataTypeVector), testing::ValuesIn(idxTypeVector), diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_gather_nd.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_gather_nd.cpp index 0b0b2a7db16f8c..5003ea60685f88 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_gather_nd.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_gather_nd.cpp @@ -82,7 +82,7 @@ TEST_P(DSR_GatherNDDynamicDataStaticIdx, CompareWithReference) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_DynamicGatherData, DSR_GatherNDDynamicDataStaticIdx, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_DynamicGatherData, DSR_GatherNDDynamicDataStaticIdx, testing::Combine( testing::ValuesIn(dataTypeVector), testing::ValuesIn(idxTypeVector), testing::Values( @@ -112,7 +112,7 @@ TEST_P(DSR_GatherNDStaticDataDynamicIdx, CompareWithReference) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_DynamicGatherIdx, DSR_GatherNDStaticDataDynamicIdx, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_DynamicGatherIdx, DSR_GatherNDStaticDataDynamicIdx, testing::Combine( testing::ValuesIn(dataTypeVector), testing::ValuesIn(idxTypeVector), testing::Values( @@ -142,7 +142,7 @@ TEST_P(DSR_GatherNDDynamicDataDynamicIdx, CompareWithReference) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_DynamicGather, DSR_GatherNDDynamicDataDynamicIdx, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_DynamicGather, DSR_GatherNDDynamicDataDynamicIdx, testing::Combine( testing::ValuesIn(dataTypeVector), testing::ValuesIn(idxTypeVector), testing::Values( diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_matmul.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_matmul.cpp index 536da208e72d41..2bf60b55441c65 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_matmul.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_matmul.cpp @@ -99,5 +99,5 @@ TEST_P(DSR_MatMul, CompareWithReference) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_DynamicMatMul, DSR_MatMul, combinations); +INSTANTIATE_TEST_SUITE_P(smoke_DynamicMatMul, DSR_MatMul, combinations); } // namespace diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_non_max_suppression.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_non_max_suppression.cpp index a764cb07c338e5..a3e86b211e1f5b 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_non_max_suppression.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_non_max_suppression.cpp @@ -91,7 +91,7 @@ TEST_P(DSR_NonMaxSuppression, CompareWithReference) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_DynamicNonMaxSupression, DSR_NonMaxSuppression, +INSTANTIATE_TEST_SUITE_P(smoke_DynamicNonMaxSupression, DSR_NonMaxSuppression, ::testing::Combine( ::testing::Values( ngraph::element::f16, diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_reduce.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_reduce.cpp index 20fb3c905a92c1..2a0a89351ce895 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_reduce.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_reduce.cpp @@ -101,7 +101,7 @@ TEST_P(DSR_Reduce, CompareWithReference) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_DynamicArithmeticReduce, DSR_Reduce, arithmeticCombinations); -INSTANTIATE_TEST_CASE_P(smoke_DynamicLogicalReduce, DSR_Reduce, logicalCombinations); +INSTANTIATE_TEST_SUITE_P(smoke_DynamicArithmeticReduce, DSR_Reduce, arithmeticCombinations); +INSTANTIATE_TEST_SUITE_P(smoke_DynamicLogicalReduce, DSR_Reduce, logicalCombinations); } // namespace diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_reshape.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_reshape.cpp index 2aa408c7a5f6a2..d416dd7b357d0d 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_reshape.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_reshape.cpp @@ -88,13 +88,13 @@ const std::vector dataTypesVector = { ngraph::element::i32, }; -INSTANTIATE_TEST_CASE_P(smoke_DynamicReshape, DSR_ReshapeWithStaticDescriptor, +INSTANTIATE_TEST_SUITE_P(smoke_DynamicReshape, DSR_ReshapeWithStaticDescriptor, ::testing::Combine( ::testing::ValuesIn(dataTypesVector), ::testing::ValuesIn(reshapeTestParams), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD))); -INSTANTIATE_TEST_CASE_P(smoke_DynamicReshape, DSR_ReshapeWithDynamicDescriptor, +INSTANTIATE_TEST_SUITE_P(smoke_DynamicReshape, DSR_ReshapeWithDynamicDescriptor, ::testing::Combine( ::testing::ValuesIn(dataTypesVector), ::testing::ValuesIn(reshapeTestParams), diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_roialign.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_roialign.cpp index c3e55b5ce93ad2..19f07085ace75b 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_roialign.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_roialign.cpp @@ -54,7 +54,7 @@ TEST_P(DSR_ROIAlignDataDSR, CompareWithReference) { Run(); } -INSTANTIATE_TEST_CASE_P(DISABLED_DynamicROIAlignDataDSR, DSR_ROIAlignDataDSR, +INSTANTIATE_TEST_SUITE_P(DISABLED_DynamicROIAlignDataDSR, DSR_ROIAlignDataDSR, ::testing::Combine( ::testing::Values( ngraph::element::f16, @@ -99,7 +99,7 @@ TEST_P(DSR_ROIAlignROIDSR, CompareWithReference) { Run(); } -INSTANTIATE_TEST_CASE_P(DISABLED_smoke_DynamicROIAlign, DSR_ROIAlignROIDSR, +INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_DynamicROIAlign, DSR_ROIAlignROIDSR, ::testing::Combine( ::testing::Values( ngraph::element::f16, @@ -148,7 +148,7 @@ TEST_P(DSR_ROIAlign, CompareWithReference) { } // #-30909 -INSTANTIATE_TEST_CASE_P(DISABLED_smoke_DynamicROIAlign, DSR_ROIAlign, +INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_DynamicROIAlign, DSR_ROIAlign, ::testing::Combine( ::testing::Values( ngraph::element::f16, diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_scatter.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_scatter.cpp index 0aa93b16d50ba4..2871505b726355 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_scatter.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_scatter.cpp @@ -44,7 +44,7 @@ TEST_P(DSR_Scatter, CompareWithReference) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_DynamicScatter, DSR_Scatter, +INSTANTIATE_TEST_SUITE_P(smoke_DynamicScatter, DSR_Scatter, ::testing::Combine( testing::Values( ngraph::element::f16), diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_split.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_split.cpp index 0f8164bc831d8e..2378fdcc5185fa 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_split.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_split.cpp @@ -56,6 +56,6 @@ TEST_P(DSR_Split, CompareWithReference) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_DynamicSplit, DSR_Split, combinations); +INSTANTIATE_TEST_SUITE_P(smoke_DynamicSplit, DSR_Split, combinations); } // namespace diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_squeeze.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_squeeze.cpp index ef6f8cfad1e722..8399251b60d321 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_squeeze.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_squeeze.cpp @@ -49,7 +49,7 @@ TEST_P(DSR_Squeeze, CompareWithReference) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_DynamicSqueeze, DSR_Squeeze, +INSTANTIATE_TEST_SUITE_P(smoke_DynamicSqueeze, DSR_Squeeze, ::testing::Combine( ::testing::Values(ngraph::element::f16, ngraph::element::i32), ::testing::Values( diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_strided_slice.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_strided_slice.cpp index da7c6bd5530d21..0cb0bcb4211a7f 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_strided_slice.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_strided_slice.cpp @@ -67,7 +67,7 @@ std::vector precisions = { ngraph::element::i32 }; -INSTANTIATE_TEST_CASE_P(smoke_StridedSlice, DSR_StridedSlice, +INSTANTIATE_TEST_SUITE_P(smoke_StridedSlice, DSR_StridedSlice, ::testing::Combine( ::testing::ValuesIn(testCases), ::testing::ValuesIn(precisions), diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_topk.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_topk.cpp index bafc3d9212cb69..554ff1774bf1d6 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_topk.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_topk.cpp @@ -53,7 +53,7 @@ TEST_P(DSR_TopK_Const, CompareWithReference) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_DynamicTopKConst, DSR_TopK_Const, combinations); +INSTANTIATE_TEST_SUITE_P(smoke_DynamicTopKConst, DSR_TopK_Const, combinations); class DSR_TopK : public testing::WithParamInterface, public DSR_TestsCommon { protected: @@ -83,6 +83,6 @@ TEST_P(DSR_TopK, CompareWithReference) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_DynamicTopKConst, DSR_TopK, combinations); +INSTANTIATE_TEST_SUITE_P(smoke_DynamicTopKConst, DSR_TopK, combinations); } // namespace diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_unary_elementwise.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_unary_elementwise.cpp index 589bbaae849128..472cf02ddef715 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_unary_elementwise.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_unary_elementwise.cpp @@ -40,7 +40,7 @@ TEST_P(DSR_UnaryElementwise, CompareWithReference) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_DynamicUnaryElementwise, DSR_UnaryElementwise, +INSTANTIATE_TEST_SUITE_P(smoke_DynamicUnaryElementwise, DSR_UnaryElementwise, ::testing::Combine( ::testing::Values(ngraph::element::f16, ngraph::element::f32), ::testing::Values(DataShapeWithUpperBound{ngraph::Shape{8, 800}, ngraph::Shape{10, 1000}}), diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_unsqueeze.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_unsqueeze.cpp index 998e7f3878c97e..014c61fbb93f03 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_unsqueeze.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_unsqueeze.cpp @@ -44,7 +44,7 @@ TEST_P(DSR_Unsqueeze, CompareWithReference) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_DynamicUnsqueeze, DSR_Unsqueeze, +INSTANTIATE_TEST_SUITE_P(smoke_DynamicUnsqueeze, DSR_Unsqueeze, ::testing::Combine( ::testing::Values(ngraph::element::f16, ngraph::element::i32), ::testing::Values( diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_variadic_split.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_variadic_split.cpp index aead15031984f8..77bb741be24921 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_variadic_split.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_variadic_split.cpp @@ -57,6 +57,6 @@ TEST_P(DSR_VariadicSplit, CompareWithReference) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_DynamicGatherData, DSR_VariadicSplit, combinations); +INSTANTIATE_TEST_SUITE_P(smoke_DynamicGatherData, DSR_VariadicSplit, combinations); } // namespace diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/gather_gather_elements.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/gather_gather_elements.cpp index e8abae995bb344..09630d00540698 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/gather_gather_elements.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/gather_gather_elements.cpp @@ -131,6 +131,6 @@ TEST_P(Gather_GatherElements, CompareWithReference) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_Gather_GatherElements, Gather_GatherElements, testing::Values(CommonTestUtils::DEVICE_MYRIAD)); +INSTANTIATE_TEST_SUITE_P(smoke_Gather_GatherElements, Gather_GatherElements, testing::Values(CommonTestUtils::DEVICE_MYRIAD)); } // namespace \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/nms_nonzero.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/nms_nonzero.cpp index c71eeaceaaa1d2..344e3acb3ea045 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/nms_nonzero.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/nms_nonzero.cpp @@ -61,7 +61,7 @@ TEST_P(NMS_NonZero, CompareWithReference) { } // #-30919 -INSTANTIATE_TEST_CASE_P(DISABLED_DynamicNonMaxSupression, NMS_NonZero, +INSTANTIATE_TEST_SUITE_P(DISABLED_DynamicNonMaxSupression, NMS_NonZero, ::testing::Combine( ::testing::Values( ngraph::element::f16, diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/nonzero_broadcast.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/nonzero_broadcast.cpp index d739c1279cea8f..70d4a2fcd57b34 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/nonzero_broadcast.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/nonzero_broadcast.cpp @@ -136,7 +136,7 @@ std::vector broadcastTestParams = { { DataShapeWithUpperBound{ {128, 256}, {} }, DataShapeWithUpperBound{ {1, 128, 256}, {3, 128, 256} }, {1, 2} }, }; -INSTANTIATE_TEST_CASE_P(smoke_DynamicBroadcast, NonZero_Broadcast, +INSTANTIATE_TEST_SUITE_P(smoke_DynamicBroadcast, NonZero_Broadcast, ::testing::Combine( ::testing::ValuesIn(broadcastTestParams), ::testing::Values(ngraph::element::f16, ngraph::element::f32, ngraph::element::i32), diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/nonzero_transpose.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/nonzero_transpose.cpp index 9a446b4f727429..290838ec3fa622 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/nonzero_transpose.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/nonzero_transpose.cpp @@ -43,7 +43,7 @@ TEST_P(NonZero_Transpose, CompareWithReference) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_DynamicTranspose, NonZero_Transpose, +INSTANTIATE_TEST_SUITE_P(smoke_DynamicTranspose, NonZero_Transpose, ::testing::Combine( ::testing::Values(ngraph::element::f16, ngraph::element::f32, ngraph::element::i32), ::testing::Values(ngraph::Shape{1, 800}), diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/parameter_result.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/parameter_result.cpp index 57866f28ddeda4..3001e5b7e1b94f 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/parameter_result.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/parameter_result.cpp @@ -8,7 +8,7 @@ using namespace SubgraphTestsDefinitions; namespace { -INSTANTIATE_TEST_CASE_P(smoke_Check, ParameterResultSubgraphTest, +INSTANTIATE_TEST_SUITE_P(smoke_Check, ParameterResultSubgraphTest, ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ParameterResultSubgraphTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/parameter_shapeof_result.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/parameter_shapeof_result.cpp index d47af641a3c1ea..bb484899b3f8b9 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/parameter_shapeof_result.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/parameter_shapeof_result.cpp @@ -8,7 +8,7 @@ using namespace SubgraphTestsDefinitions; namespace { -INSTANTIATE_TEST_CASE_P(smoke_Check, ParameterShapeOfResultSubgraphTest, +INSTANTIATE_TEST_SUITE_P(smoke_Check, ParameterShapeOfResultSubgraphTest, ::testing::Combine( ::testing::Values( ngraph::element::f32, diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/topk_k_propagation.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/topk_k_propagation.cpp index e5a6c520a4b75e..9c5199b0adb90b 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/topk_k_propagation.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/topk_k_propagation.cpp @@ -77,7 +77,7 @@ const std::vector kVec = {0, 10, 100, 200, 500}; TEST_P(DynamicToStaticTopKPropagationConcatBased, KPropagation) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticTopKPropagationConcatBased, ::testing::ValuesIn(kVec)); +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticTopKPropagationConcatBased, ::testing::ValuesIn(kVec)); class DynamicToStaticTopKPropagationConcatReshape : public DynamicToStaticTopKPropagationConcatBased { protected: @@ -89,7 +89,7 @@ class DynamicToStaticTopKPropagationConcatReshape : public DynamicToStaticTopKPr TEST_P(DynamicToStaticTopKPropagationConcatReshape, KPropagation) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticTopKPropagationConcatReshape, ::testing::ValuesIn(kVec)); +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticTopKPropagationConcatReshape, ::testing::ValuesIn(kVec)); class DynamicToStaticTopKPropagationConcatSqueezeUnsqueeze : public DynamicToStaticTopKPropagationConcatBased { protected: @@ -104,7 +104,7 @@ class DynamicToStaticTopKPropagationConcatSqueezeUnsqueeze : public DynamicToSta TEST_P(DynamicToStaticTopKPropagationConcatSqueezeUnsqueeze, KPropagation) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticTopKPropagationConcatSqueezeUnsqueeze, ::testing::ValuesIn(kVec)); +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticTopKPropagationConcatSqueezeUnsqueeze, ::testing::ValuesIn(kVec)); class DynamicToStaticTopKPropagationConcatConvert : public DynamicToStaticTopKPropagationConcatBased { protected: @@ -117,7 +117,7 @@ class DynamicToStaticTopKPropagationConcatConvert : public DynamicToStaticTopKPr TEST_P(DynamicToStaticTopKPropagationConcatConvert, KPropagation) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticTopKPropagationConcatConvert, ::testing::ValuesIn(kVec)); +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticTopKPropagationConcatConvert, ::testing::ValuesIn(kVec)); class DynamicToStaticTopKPropagationShapeOfBased : public DynamicToStaticTopKPropagationBase { public: @@ -163,7 +163,7 @@ class DynamicToStaticTopKPropagationShapeOfGather : public DynamicToStaticTopKPr TEST_P(DynamicToStaticTopKPropagationShapeOfGather, KPropagation) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, DynamicToStaticTopKPropagationShapeOfGather, ::testing::ValuesIn(kVec)); +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, DynamicToStaticTopKPropagationShapeOfGather, ::testing::ValuesIn(kVec)); class KPropagationAfterShapeOfElimination : public DynamicToStaticTopKPropagationShapeOfBased { void SetUp() override { @@ -209,6 +209,6 @@ class KPropagationAfterShapeOfElimination : public DynamicToStaticTopKPropagatio TEST_P(KPropagationAfterShapeOfElimination, KPropagation) { } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, KPropagationAfterShapeOfElimination, ::testing::ValuesIn(kVec)); +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, KPropagationAfterShapeOfElimination, ::testing::ValuesIn(kVec)); } // namespace diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/unsqueeze_gather.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/unsqueeze_gather.cpp index c3d3e5ba9e734b..65e1d0def46578 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/unsqueeze_gather.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/unsqueeze_gather.cpp @@ -48,7 +48,7 @@ TEST_P(UnsqueezeGather, CompareWithRefs) { Run(); } -INSTANTIATE_TEST_CASE_P(smoke_NGraph, UnsqueezeGather, testing::Combine( +INSTANTIATE_TEST_SUITE_P(smoke_NGraph, UnsqueezeGather, testing::Combine( testing::Values( ngraph::element::f16, ngraph::element::f32), diff --git a/inference-engine/tests/functional/plugin/shared/src/behavior/caching_tests.cpp b/inference-engine/tests/functional/plugin/shared/src/behavior/caching_tests.cpp index 0f8f97c653451b..167afc80b6e17e 100644 --- a/inference-engine/tests/functional/plugin/shared/src/behavior/caching_tests.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/behavior/caching_tests.cpp @@ -139,7 +139,7 @@ void LoadNetworkCacheTestBase::SetUp() { try { function = fGen(m_precision, m_batchSize); } catch (...) { - SKIP(); + GTEST_SKIP(); } std::stringstream ss; @@ -168,11 +168,11 @@ void LoadNetworkCacheTestBase::Run() { }; if (!function) { GTEST_COUT << "Can't create function " << m_functionName << " with precision " << m_precision.get_type_name() << std::endl; - SKIP(); + GTEST_SKIP(); } if (!importExportSupported(*core)) { GTEST_COUT << "Plugin doesn't support import and export - skipping test" << std::endl; - SKIP(); + GTEST_SKIP(); } cnnNetwork = CNNNetwork{function}; ConfigureNetwork(); @@ -183,10 +183,10 @@ void LoadNetworkCacheTestBase::Run() { } catch (const Exception &ex) { GTEST_COUT << "Can't loadNetwork without cache for " << m_functionName << " with precision " << m_precision.get_type_name() << std::endl; GTEST_COUT << "Exception [" << ex.what() << "]" << std::endl; - SKIP(); + GTEST_SKIP(); } catch (...) { GTEST_COUT << "Can't loadNetwork without cache for " << m_functionName << " with precision " << m_precision.get_type_name() << std::endl; - SKIP(); // skip caching test if such network is not supported by device at all + GTEST_SKIP(); // skip caching test if such network is not supported by device at all } auto originalOutputs = GetOutputs(); diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/non_max_suppression.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/non_max_suppression.hpp index d608a7e7526974..67b0f5951782af 100644 --- a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/non_max_suppression.hpp +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/non_max_suppression.hpp @@ -10,6 +10,16 @@ #include "shared_test_classes/base/layer_test_utils.hpp" #include "ngraph_functions/builders.hpp" +namespace testing { +namespace internal { + +template <> inline void +PrintTo(const ::ngraph::op::v5::NonMaxSuppression::BoxEncodingType& value, + ::std::ostream* os) { } + +} +} + namespace LayerTestsDefinitions { using InputShapeParams = std::tuple +::std::ostream& ngraph::operator << (::std::ostream & os, const Function&) { + throw std::runtime_error("should not be called"); + return os; +} + namespace CommonTestUtils { IE_SUPPRESS_DEPRECATED_START diff --git a/inference-engine/tests/ie_test_utils/common_test_utils/common_utils.hpp b/inference-engine/tests/ie_test_utils/common_test_utils/common_utils.hpp index dc6aaf2e0518c5..39ea049ba1a612 100644 --- a/inference-engine/tests/ie_test_utils/common_test_utils/common_utils.hpp +++ b/inference-engine/tests/ie_test_utils/common_test_utils/common_utils.hpp @@ -15,6 +15,11 @@ #include #include +#include + +namespace ngraph { +::std::ostream& operator << (::std::ostream &, const Function&); +} namespace InferenceEngine { class CNNLayer; diff --git a/inference-engine/tests/ie_test_utils/common_test_utils/gtest b/inference-engine/tests/ie_test_utils/common_test_utils/gtest deleted file mode 160000 index 9bd163b993459b..00000000000000 --- a/inference-engine/tests/ie_test_utils/common_test_utils/gtest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9bd163b993459b2ca6ba2dc508577bbc8774c851 diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mock.cpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mock.cpp index 980044f8d0265d..9cc7309c1c9666 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mock.cpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mock.cpp @@ -14,6 +14,7 @@ #include "unit_test_utils/mocks/cpp_interfaces/impl/mock_executable_thread_safe_default.hpp" #include "unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp" +#include "unit_test_utils/mocks/cpp_interfaces/interface/mock_icore.hpp" #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_ivariable_state_internal.hpp" diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_icore.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_icore.hpp index f84f4086e34e2f..b061c4c3bdc090 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_icore.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_icore.hpp @@ -9,10 +9,10 @@ class MockICore : public InferenceEngine::ICore { public: - MOCK_QUALIFIED_METHOD0(GetTaskExecutor, const, std::shared_ptr()); + MOCK_CONST_METHOD0(GetTaskExecutor, std::shared_ptr()); - 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_CONST_METHOD2(ReadNetwork, InferenceEngine::CNNNetwork(const std::string&, const InferenceEngine::Blob::CPtr&)); + MOCK_CONST_METHOD2(ReadNetwork, InferenceEngine::CNNNetwork(const std::string&, const std::string&)); MOCK_METHOD3(LoadNetwork, InferenceEngine::SoExecutableNetworkInternal( const InferenceEngine::CNNNetwork&, const std::string&, const std::map&)); @@ -26,12 +26,12 @@ class MockICore : public InferenceEngine::ICore { MOCK_METHOD3(ImportNetwork, InferenceEngine::SoExecutableNetworkInternal( std::istream&, const InferenceEngine::RemoteContext::Ptr&, const std::map&)); - MOCK_QUALIFIED_METHOD3(QueryNetwork, const, InferenceEngine::QueryNetworkResult( + MOCK_CONST_METHOD3(QueryNetwork, InferenceEngine::QueryNetworkResult( const InferenceEngine::CNNNetwork&, const std::string&, const std::map&)); - MOCK_QUALIFIED_METHOD2(GetMetric, const, InferenceEngine::Parameter(const std::string&, const std::string&)); - MOCK_QUALIFIED_METHOD0(GetAvailableDevices, const, std::vector()); - MOCK_QUALIFIED_METHOD1(DeviceSupportsImportExport, const, bool(const std::string&)); // NOLINT not a cast to bool + MOCK_CONST_METHOD2(GetMetric, InferenceEngine::Parameter(const std::string&, const std::string&)); + MOCK_CONST_METHOD0(GetAvailableDevices, std::vector()); + MOCK_CONST_METHOD1(DeviceSupportsImportExport, bool(const std::string&)); // NOLINT not a cast to bool ~MockICore() = default; }; diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinference_plugin.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinference_plugin.hpp index 083a529e121493..f6bc2a47953c30 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinference_plugin.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinference_plugin.hpp @@ -7,8 +7,8 @@ #include #include -#include "cpp_interfaces/interface/ie_iplugin_internal.hpp" #include +#include "cpp_interfaces/interface/ie_iplugin_internal.hpp" class MockIInferencePlugin : public InferenceEngine::IInferencePlugin { public: @@ -21,13 +21,13 @@ class MockIInferencePlugin : public InferenceEngine::IInferencePlugin { const std::string&, const std::map&)); MOCK_METHOD1(SetConfig, void(const std::map &)); - MOCK_QUALIFIED_METHOD1(SetName, noexcept, void(const std::string&)); - MOCK_QUALIFIED_METHOD0(GetName, const noexcept, std::string(void)); - MOCK_QUALIFIED_METHOD1(SetCore, noexcept, void(InferenceEngine::ICore*)); - MOCK_QUALIFIED_METHOD0(GetCore, const noexcept, InferenceEngine::ICore *(void)); - MOCK_QUALIFIED_METHOD2(GetConfig, const, InferenceEngine::Parameter( + MOCK_METHOD(void, SetName, (const std::string&), (noexcept)); + MOCK_METHOD(std::string, GetName, (), (const, noexcept)); + MOCK_METHOD(void, SetCore, (InferenceEngine::ICore*), (noexcept)); + MOCK_METHOD(InferenceEngine::ICore *, GetCore, (), (const, noexcept)); + MOCK_CONST_METHOD2(GetConfig, InferenceEngine::Parameter( const std::string&, const std::map&)); - MOCK_QUALIFIED_METHOD2(GetMetric, const, InferenceEngine::Parameter( + MOCK_CONST_METHOD2(GetMetric, InferenceEngine::Parameter( const std::string&, const std::map&)); MOCK_METHOD1(CreateContext, InferenceEngine::RemoteContext::Ptr(const InferenceEngine::ParamMap&)); @@ -40,7 +40,7 @@ class MockIInferencePlugin : public InferenceEngine::IInferencePlugin { MOCK_METHOD3(ImportNetwork, std::shared_ptr( std::istream&, const InferenceEngine::RemoteContext::Ptr&, const std::map&)); - MOCK_QUALIFIED_METHOD2(QueryNetwork, const, - InferenceEngine::QueryNetworkResult(const InferenceEngine::CNNNetwork&, - const std::map&)); + MOCK_CONST_METHOD2(QueryNetwork, + InferenceEngine::QueryNetworkResult(const InferenceEngine::CNNNetwork&, + const std::map&)); }; diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_allocator.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_allocator.hpp index 47b77d999e0f8c..83af019e4343ab 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_allocator.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_allocator.hpp @@ -14,8 +14,8 @@ class MockAllocator : public InferenceEngine::IAllocator { public: - MOCK_QUALIFIED_METHOD2(lock, noexcept, void*(void*, InferenceEngine::LockOp)); - MOCK_QUALIFIED_METHOD1(unlock, noexcept, void(void *)); - MOCK_QUALIFIED_METHOD1(alloc, noexcept, void*(size_t)); - MOCK_QUALIFIED_METHOD1(free, noexcept, bool(void*)); // NOLINT(readability/casting) + MOCK_METHOD(void*, lock, (void*, InferenceEngine::LockOp), (noexcept)); + MOCK_METHOD(void, unlock, (void *), (noexcept)); + MOCK_METHOD(void*, alloc, (size_t), (noexcept)); + MOCK_METHOD(bool, free, (void*), (noexcept)); // NOLINT(readability/casting) }; diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_icnn_network.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_icnn_network.hpp index 618122505a4409..a3f7d337dd0bba 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_icnn_network.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_icnn_network.hpp @@ -27,23 +27,25 @@ class CNNLayer; */ class MockICNNNetwork final : public InferenceEngine::ICNNNetwork { public: - MOCK_QUALIFIED_METHOD0(getFunction, const noexcept, std::shared_ptr ()); - MOCK_QUALIFIED_METHOD0(getFunction, noexcept, std::shared_ptr()); - MOCK_QUALIFIED_METHOD1(getOutputsInfo, const noexcept, void(InferenceEngine::OutputsDataMap& out)); - MOCK_QUALIFIED_METHOD1(getInputsInfo, const noexcept, void(InferenceEngine::InputsDataMap &inputs)); - MOCK_QUALIFIED_METHOD1(getInput, const noexcept, InferenceEngine::InputInfo::Ptr(const std::string &inputName)); - MOCK_QUALIFIED_METHOD0(layerCount, const noexcept, size_t()); - MOCK_QUALIFIED_METHOD0(getName, const noexcept, const std::string&()); - MOCK_QUALIFIED_METHOD3(addOutput, noexcept, InferenceEngine::StatusCode(const std::string &, size_t, InferenceEngine::ResponseDesc*)); - MOCK_QUALIFIED_METHOD3(getLayerByName, const noexcept, InferenceEngine::StatusCode(const char* , - std::shared_ptr&, - InferenceEngine::ResponseDesc*)); - MOCK_QUALIFIED_METHOD2(setBatchSize, noexcept, InferenceEngine::StatusCode(const size_t size, InferenceEngine::ResponseDesc*)); - MOCK_QUALIFIED_METHOD0(getBatchSize, const noexcept, size_t()); - MOCK_QUALIFIED_METHOD1(getInputShapes, const noexcept, void(InferenceEngine::ICNNNetwork::InputShapes&)); - MOCK_QUALIFIED_METHOD2(reshape, noexcept, InferenceEngine::StatusCode(const InferenceEngine::ICNNNetwork::InputShapes &, InferenceEngine::ResponseDesc *)); - MOCK_QUALIFIED_METHOD3(serialize, const noexcept, InferenceEngine::StatusCode( - const std::string &, - const std::string &, - InferenceEngine::ResponseDesc*)); + MOCK_METHOD(std::shared_ptr, getFunction, (), (const, noexcept)); + MOCK_METHOD(std::shared_ptr, getFunction, (), (noexcept)); + MOCK_METHOD(void, getOutputsInfo, (InferenceEngine::OutputsDataMap& out), (const, noexcept)); + MOCK_METHOD(void, getInputsInfo, (InferenceEngine::InputsDataMap &inputs), (const, noexcept)); + MOCK_METHOD(InferenceEngine::InputInfo::Ptr, getInput, (const std::string &inputName), (const, noexcept)); + MOCK_METHOD(size_t, layerCount, (), (const, noexcept)); + MOCK_METHOD(const std::string&, getName, (), (const, noexcept)); + MOCK_METHOD(InferenceEngine::StatusCode, addOutput, + (const std::string &, size_t, InferenceEngine::ResponseDesc*), (noexcept)); + MOCK_METHOD(InferenceEngine::StatusCode, getLayerByName, + (const char* , std::shared_ptr&, InferenceEngine::ResponseDesc*), + (const, noexcept)); + MOCK_METHOD(InferenceEngine::StatusCode, setBatchSize, + (const size_t size, InferenceEngine::ResponseDesc*), (noexcept)); + MOCK_METHOD(size_t, getBatchSize, (), (const, noexcept)); + MOCK_METHOD(void, getInputShapes, (InferenceEngine::ICNNNetwork::InputShapes&), (const, noexcept)); + MOCK_METHOD(InferenceEngine::StatusCode, reshape, + (const InferenceEngine::ICNNNetwork::InputShapes &, InferenceEngine::ResponseDesc *), + (const, noexcept)); + MOCK_METHOD(InferenceEngine::StatusCode, serialize, + (const std::string &, const std::string &, InferenceEngine::ResponseDesc*), (const, noexcept)); }; diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iexecutable_network.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iexecutable_network.hpp index a5187953206ddd..5a6779f12ab521 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iexecutable_network.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iexecutable_network.hpp @@ -22,16 +22,20 @@ IE_SUPPRESS_DEPRECATED_START class MockIExecutableNetwork : public IExecutableNetwork { public: - MOCK_QUALIFIED_METHOD2(GetOutputsInfo, const noexcept, StatusCode(ConstOutputsDataMap &, ResponseDesc *)); - MOCK_QUALIFIED_METHOD2(GetInputsInfo, const noexcept, StatusCode(ConstInputsDataMap &, ResponseDesc *)); - MOCK_QUALIFIED_METHOD2(CreateInferRequest, noexcept, StatusCode(IInferRequest::Ptr &, ResponseDesc*)); - MOCK_QUALIFIED_METHOD2(Export, noexcept, StatusCode(const std::string &, ResponseDesc*)); - MOCK_QUALIFIED_METHOD2(Export, noexcept, StatusCode(std::ostream &, ResponseDesc *)); - MOCK_QUALIFIED_METHOD2(GetExecGraphInfo, noexcept, StatusCode(ICNNNetwork::Ptr &, ResponseDesc*)); - MOCK_QUALIFIED_METHOD2(SetConfig, noexcept, StatusCode(const std::map &config, ResponseDesc *resp)); - MOCK_QUALIFIED_METHOD3(GetConfig, const noexcept, StatusCode(const std::string &name, Parameter &result, ResponseDesc *resp)); - MOCK_QUALIFIED_METHOD3(GetMetric, const noexcept, StatusCode(const std::string &name, Parameter &result, ResponseDesc *resp)); - MOCK_QUALIFIED_METHOD2(GetContext, const noexcept, StatusCode(RemoteContext::Ptr &pContext, ResponseDesc *resp)); + MOCK_METHOD(StatusCode, GetOutputsInfo, (ConstOutputsDataMap &, ResponseDesc *), (const, noexcept)); + MOCK_METHOD(StatusCode, GetInputsInfo, (ConstInputsDataMap &, ResponseDesc *), (const, noexcept)); + MOCK_METHOD(StatusCode, CreateInferRequest, (IInferRequest::Ptr &, ResponseDesc*), (noexcept)); + MOCK_METHOD(StatusCode, Export, (const std::string &, ResponseDesc*), (noexcept)); + MOCK_METHOD(StatusCode, Export, (std::ostream &, ResponseDesc *), (noexcept)); + MOCK_METHOD(StatusCode, GetExecGraphInfo, (ICNNNetwork::Ptr &, ResponseDesc*), (noexcept)); + MOCK_METHOD(StatusCode, SetConfig, + ((const std::map &config), ResponseDesc *resp), (noexcept)); + MOCK_METHOD(StatusCode, GetConfig, + (const std::string &name, Parameter &result, ResponseDesc *resp), (const, noexcept)); + MOCK_METHOD(StatusCode, GetMetric, + (const std::string &name, Parameter &result, ResponseDesc *resp), (const, noexcept)); + MOCK_METHOD(StatusCode, GetContext, + (RemoteContext::Ptr &pContext, ResponseDesc *resp), (const, noexcept)); }; IE_SUPPRESS_DEPRECATED_END diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iinfer_request.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iinfer_request.hpp index bac5fc7773e024..32060d0138a804 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iinfer_request.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iinfer_request.hpp @@ -22,20 +22,22 @@ IE_SUPPRESS_DEPRECATED_START class MockIInferRequest : public IInferRequest { public: - MOCK_QUALIFIED_METHOD1(StartAsync, noexcept, StatusCode(ResponseDesc*)); - MOCK_QUALIFIED_METHOD2(Wait, noexcept, StatusCode(int64_t millis_timeout, ResponseDesc*)); - MOCK_QUALIFIED_METHOD2(GetUserData, noexcept, StatusCode(void**, ResponseDesc*)); - MOCK_QUALIFIED_METHOD2(SetUserData, noexcept, StatusCode(void*, ResponseDesc*)); - MOCK_QUALIFIED_METHOD1(SetCompletionCallback, noexcept, StatusCode(IInferRequest::CompletionCallback)); - MOCK_QUALIFIED_METHOD1(Infer, noexcept, StatusCode(ResponseDesc*)); - MOCK_QUALIFIED_METHOD2(GetPerformanceCounts, const noexcept, - StatusCode(std::map &perfMap, ResponseDesc*)); - MOCK_QUALIFIED_METHOD3(GetBlob, noexcept, StatusCode(const char*, Blob::Ptr&, ResponseDesc*)); - MOCK_QUALIFIED_METHOD3(GetPreProcess, const noexcept, StatusCode(const char*, const PreProcessInfo**, ResponseDesc*)); - MOCK_QUALIFIED_METHOD3(SetBlob, noexcept, StatusCode(const char*, const Blob::Ptr&, ResponseDesc*)); - MOCK_QUALIFIED_METHOD4(SetBlob, noexcept, StatusCode(const char*, const Blob::Ptr&, const PreProcessInfo&, ResponseDesc*)); - MOCK_QUALIFIED_METHOD2(SetBatch, noexcept, StatusCode(int batch, ResponseDesc*)); - MOCK_QUALIFIED_METHOD1(Cancel, noexcept, InferenceEngine::StatusCode(ResponseDesc*)); + MOCK_METHOD(StatusCode, StartAsync, (ResponseDesc*), (noexcept)); + MOCK_METHOD(StatusCode, Wait, (int64_t, ResponseDesc*), (noexcept)); + MOCK_METHOD(StatusCode, GetUserData, (void**, ResponseDesc*), (noexcept)); + MOCK_METHOD(StatusCode, SetUserData, (void*, ResponseDesc*), (noexcept)); + MOCK_METHOD(StatusCode, SetCompletionCallback, (IInferRequest::CompletionCallback), (noexcept)); + MOCK_METHOD(StatusCode, Infer, (ResponseDesc*), (noexcept)); + MOCK_METHOD(StatusCode, GetPerformanceCounts, + ((std::map &), ResponseDesc*), (const, noexcept)); + MOCK_METHOD(StatusCode, GetBlob, (const char*, Blob::Ptr&, ResponseDesc*), (noexcept)); + MOCK_METHOD(StatusCode, GetPreProcess, + (const char*, const PreProcessInfo**, ResponseDesc*), (const, noexcept)); + MOCK_METHOD(StatusCode, SetBlob, (const char*, const Blob::Ptr&, ResponseDesc*), (noexcept)); + MOCK_METHOD(StatusCode, SetBlob, + (const char*, const Blob::Ptr&, const PreProcessInfo&, ResponseDesc*), (noexcept)); + MOCK_METHOD(StatusCode, SetBatch, (int batch, ResponseDesc*), (noexcept)); + MOCK_METHOD(StatusCode, Cancel, (ResponseDesc*), (noexcept)); }; IE_SUPPRESS_DEPRECATED_END diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_not_empty_icnn_network.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_not_empty_icnn_network.hpp index 814336b887b872..f9ffeab2f2ddad 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_not_empty_icnn_network.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_not_empty_icnn_network.hpp @@ -34,14 +34,15 @@ class MockNotEmptyICNNNetwork final : public ICNNNetwork { std::shared_ptr getFunction() const noexcept override { return nullptr; } - MOCK_QUALIFIED_METHOD1(getInput, const noexcept, InputInfo::Ptr(const std::string &inputName)); - MOCK_QUALIFIED_METHOD0(layerCount, const noexcept, size_t()); - MOCK_QUALIFIED_METHOD3(addOutput, noexcept, StatusCode(const std::string &, size_t , ResponseDesc*)); - MOCK_QUALIFIED_METHOD2(setBatchSize, noexcept, StatusCode(const size_t size, ResponseDesc*)); - MOCK_QUALIFIED_METHOD0(getBatchSize, const noexcept, size_t()); - MOCK_QUALIFIED_METHOD1(getInputShapes, const noexcept, void(ICNNNetwork::InputShapes &)); - MOCK_QUALIFIED_METHOD2(reshape, noexcept, StatusCode(const ICNNNetwork::InputShapes &, ResponseDesc *)); - MOCK_QUALIFIED_METHOD3(serialize, const noexcept, StatusCode(const std::string &, const std::string &, InferenceEngine::ResponseDesc*)); + MOCK_METHOD(InputInfo::Ptr, getInput, (const std::string &inputName), (const, noexcept)); + MOCK_METHOD(size_t, layerCount, (), (const, noexcept)); + MOCK_METHOD(StatusCode, addOutput, (const std::string &, size_t , ResponseDesc*), (noexcept)); + MOCK_METHOD(StatusCode, setBatchSize, (const size_t size, ResponseDesc*), (noexcept)); + MOCK_METHOD(size_t, getBatchSize, (), (const, noexcept)); + MOCK_METHOD(void, getInputShapes, (ICNNNetwork::InputShapes &), (const, noexcept)); + MOCK_METHOD(StatusCode, reshape, (const ICNNNetwork::InputShapes &, ResponseDesc *), (noexcept)); + MOCK_METHOD(StatusCode, serialize, + (const std::string &, const std::string &, InferenceEngine::ResponseDesc*), (const, noexcept)); }; IE_SUPPRESS_DEPRECATED_END diff --git a/inference-engine/tests/unit/cpu/mkldnn_memory_desc_test.cpp b/inference-engine/tests/unit/cpu/mkldnn_memory_desc_test.cpp index ee7684cca24200..fd828df6dd9a92 100644 --- a/inference-engine/tests/unit/cpu/mkldnn_memory_desc_test.cpp +++ b/inference-engine/tests/unit/cpu/mkldnn_memory_desc_test.cpp @@ -131,23 +131,23 @@ TEST(MemDescTest, isTailCCheck) { } TEST(MemDescTest, constructWithPlainFormat) { - SKIP(); + GTEST_SKIP(); } TEST(MemDescTest, CheckScalar) { - SKIP(); + GTEST_SKIP(); } TEST(MemDescTest, UpperBound) { - SKIP(); + GTEST_SKIP(); } TEST(MemDescTest, BlockedConversion) { - SKIP(); + GTEST_SKIP(); } TEST(MemDescTest, ComaptibleWithFormat) { - SKIP(); + GTEST_SKIP(); } TEST(isSameMethodTest, CheckTensorWithSameStrides) { diff --git a/inference-engine/tests/unit/cpu/mkldnn_memory_test.cpp b/inference-engine/tests/unit/cpu/mkldnn_memory_test.cpp index 41e2d42cf7bada..7b46e154617e9c 100644 --- a/inference-engine/tests/unit/cpu/mkldnn_memory_test.cpp +++ b/inference-engine/tests/unit/cpu/mkldnn_memory_test.cpp @@ -11,9 +11,9 @@ using namespace MKLDNNPlugin; using namespace InferenceEngine; TEST(MemoryTest, SedDataCheck) { - SKIP(); + GTEST_SKIP(); } TEST(MemoryTest, SedDataWithAutoPadCheck) { - SKIP(); + GTEST_SKIP(); } diff --git a/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_infer_async_request_base_test.cpp b/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_infer_async_request_base_test.cpp index d0cde74580cb1b..6fbb50abe3e52c 100644 --- a/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_infer_async_request_base_test.cpp +++ b/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_infer_async_request_base_test.cpp @@ -3,8 +3,7 @@ // #include -#include -#include +#include #include #include diff --git a/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_memory_state_internal_test.cpp b/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_memory_state_internal_test.cpp index 83712bf6fd5a8f..f35afd674e4f55 100644 --- a/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_memory_state_internal_test.cpp +++ b/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_memory_state_internal_test.cpp @@ -184,18 +184,16 @@ TEST_F(VariableStateTests, VariableStateCanPropagateSetState) { TEST_F(VariableStateTests, VariableStateCanPropagateGetLastState) { IE_SUPPRESS_DEPRECATED_START std::vector toReturn; + toReturn.push_back(mockVariableStateInternal); float data[] = {123, 124, 125}; auto stateBlob = make_shared_blob({ Precision::FP32, {3}, C }, data, sizeof(data) / sizeof(*data)); - - toReturn.push_back(mockVariableStateInternal); - EXPECT_CALL(*mockExeNetworkInternal.get(), QueryState()).WillRepeatedly(Return(toReturn)); EXPECT_CALL(*mockVariableStateInternal.get(), GetState()).WillOnce(Return(stateBlob)); - auto saver = net->QueryState().front()->GetState(); + ASSERT_NE(saver, nullptr); ASSERT_FLOAT_EQ(saver->cbuffer().as()[0], 123); ASSERT_FLOAT_EQ(saver->cbuffer().as()[1], 124); ASSERT_FLOAT_EQ(saver->cbuffer().as()[2], 125); @@ -222,6 +220,7 @@ TEST_F(VariableStateTests, VariableStateInternalCanSaveState) { pState->SetState(stateBlob); auto saver = pState->GetState(); + ASSERT_NE(saver, nullptr); ASSERT_FLOAT_EQ(saver->cbuffer().as()[0], 123); ASSERT_FLOAT_EQ(saver->cbuffer().as()[1], 124); ASSERT_FLOAT_EQ(saver->cbuffer().as()[2], 125); @@ -240,6 +239,7 @@ TEST_F(VariableStateTests, VariableStateInternalCanSaveStateByReference) { data[2] = 123; auto saver = pState->GetState(); + ASSERT_NE(saver, nullptr); ASSERT_FLOAT_EQ(saver->cbuffer().as()[0], 121); ASSERT_FLOAT_EQ(saver->cbuffer().as()[1], 122); ASSERT_FLOAT_EQ(saver->cbuffer().as()[2], 123); @@ -338,6 +338,7 @@ TEST_F(VariableStateTests, InfReqVariableStateCanPropagateGetLastState) { EXPECT_CALL(*mockVariableStateInternal.get(), GetState()).WillOnce(Return(stateBlob)); auto saver = req->QueryState().front()->GetState(); + ASSERT_NE(saver, nullptr); ASSERT_FLOAT_EQ(saver->cbuffer().as()[0], 123); ASSERT_FLOAT_EQ(saver->cbuffer().as()[1], 124); ASSERT_FLOAT_EQ(saver->cbuffer().as()[2], 125); diff --git a/inference-engine/tests/unit/vpu/blob_reader_tests.cpp b/inference-engine/tests/unit/vpu/blob_reader_tests.cpp index 0092c540885287..5cb73484281d33 100644 --- a/inference-engine/tests/unit/vpu/blob_reader_tests.cpp +++ b/inference-engine/tests/unit/vpu/blob_reader_tests.cpp @@ -199,6 +199,6 @@ TEST_P(VPUBlobReaderOutputTests, canGetCorrectOutputNamesFromImportedNetwork) { const std::vector inputShape = {{1, 4, 10, 10}}; -INSTANTIATE_TEST_CASE_P(myriadBlobReader_nightly, VPUBlobReaderHeaderTests, ::testing::Values(inputShape)); -INSTANTIATE_TEST_CASE_P(myriadBlobReader_nightly, VPUBlobReaderInputTests, ::testing::Values(inputShape)); -INSTANTIATE_TEST_CASE_P(myriadBlobReader_nightly, VPUBlobReaderOutputTests, ::testing::Values(inputShape)); +INSTANTIATE_TEST_SUITE_P(myriadBlobReader_nightly, VPUBlobReaderHeaderTests, ::testing::Values(inputShape)); +INSTANTIATE_TEST_SUITE_P(myriadBlobReader_nightly, VPUBlobReaderInputTests, ::testing::Values(inputShape)); +INSTANTIATE_TEST_SUITE_P(myriadBlobReader_nightly, VPUBlobReaderOutputTests, ::testing::Values(inputShape)); diff --git a/inference-engine/tests/unit/vpu/middleend_tests/passes_tests/annotate_memory_types.cpp b/inference-engine/tests/unit/vpu/middleend_tests/passes_tests/annotate_memory_types.cpp index 14e73c28cc7cec..cb4bd63f44c7bf 100644 --- a/inference-engine/tests/unit/vpu/middleend_tests/passes_tests/annotate_memory_types.cpp +++ b/inference-engine/tests/unit/vpu/middleend_tests/passes_tests/annotate_memory_types.cpp @@ -103,7 +103,7 @@ class AnnotateMemoryTypes : public GraphTransformerTest, public testing::WithPar TEST_P(AnnotateMemoryTypes, SubgraphOf3Stages) { } -INSTANTIATE_TEST_CASE_P(unit, AnnotateMemoryTypes, testing::Combine( +INSTANTIATE_TEST_SUITE_P(unit, AnnotateMemoryTypes, testing::Combine( testing::Combine( testing::Values(MemoryType::DDR, MemoryType::CMX), testing::Values(MemoryType::DDR, MemoryType::CMX), diff --git a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/aot_behavior_tests.cpp b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/aot_behavior_tests.cpp index 99617e16f3bf46..b67029dbedcc2e 100644 --- a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/aot_behavior_tests.cpp +++ b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/aot_behavior_tests.cpp @@ -202,6 +202,6 @@ const BehTestParams vpuValues[] = { BEH_MYRIAD, }; -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTest, AOTBehaviorTests, ValuesIn(vpuValues), getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest, AOTBehaviorTests, ValuesIn(vpuValues), getTestCaseName); #endif diff --git a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_boot_tests.cpp b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_boot_tests.cpp index e96bcbe408c19d..0998c48e25cf96 100644 --- a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_boot_tests.cpp +++ b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_boot_tests.cpp @@ -96,4 +96,4 @@ const BehTestParams vpuValues[] = { BEH_MYRIAD, }; -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTest, MYRIADBoot, ValuesIn(vpuValues), getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest, MYRIADBoot, ValuesIn(vpuValues), getTestCaseName); diff --git a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_protocol_tests.cpp b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_protocol_tests.cpp index 8f987c7c399da1..50b345866c9552 100644 --- a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_protocol_tests.cpp +++ b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_protocol_tests.cpp @@ -48,7 +48,7 @@ TEST_P(MyriadProtocolTests, NoErrorsMessagesWhenLoadNetworkSuccessful) { } } -INSTANTIATE_TEST_CASE_P(smoke_VPUConfigProtocolTests, +INSTANTIATE_TEST_SUITE_P(smoke_VPUConfigProtocolTests, MyriadProtocolTests, ::testing::ValuesIn(myriadProtocols), MyriadProtocolTests::getTestCaseName); \ No newline at end of file diff --git a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_watchdog_tests.cpp b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_watchdog_tests.cpp index f55dd04473594a..a3dda5c82000db 100644 --- a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_watchdog_tests.cpp +++ b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_watchdog_tests.cpp @@ -261,4 +261,4 @@ const BehTestParams vpuValues[] = { BEH_MYRIAD, }; -INSTANTIATE_TEST_CASE_P(smoke_BehaviorTest, MYRIADWatchdog, ValuesIn(vpuValues), getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest, MYRIADWatchdog, ValuesIn(vpuValues), getTestCaseName); diff --git a/inference-engine/tests_deprecated/fluid_preproc/cpu/fluid_tests_cpu.cpp b/inference-engine/tests_deprecated/fluid_preproc/cpu/fluid_tests_cpu.cpp index e20fa1f066d7ba..f06ba5025df1e1 100644 --- a/inference-engine/tests_deprecated/fluid_preproc/cpu/fluid_tests_cpu.cpp +++ b/inference-engine/tests_deprecated/fluid_preproc/cpu/fluid_tests_cpu.cpp @@ -98,57 +98,57 @@ using namespace testing; #if defined(__arm__) || defined(__aarch64__) -INSTANTIATE_TEST_CASE_P(ResizeTestFluid_U8, ResizeTestGAPI, +INSTANTIATE_TEST_SUITE_P(ResizeTestFluid_U8, ResizeTestGAPI, Combine(Values(CV_8UC1, CV_8UC3), Values(cv::INTER_LINEAR, cv::INTER_AREA), Values(TEST_RESIZE_PAIRS), Values(4))); // error not more than 4 unit -INSTANTIATE_TEST_CASE_P(ResizeRGB8UTestFluid_U8, ResizeRGB8UTestGAPI, +INSTANTIATE_TEST_SUITE_P(ResizeRGB8UTestFluid_U8, ResizeRGB8UTestGAPI, Combine(Values(CV_8UC3, CV_8UC4), Values(cv::INTER_LINEAR), Values(TEST_RESIZE_PAIRS), Values(4))); // error not more than 4 unit #else -INSTANTIATE_TEST_CASE_P(ResizeTestFluid_U8, ResizeTestGAPI, +INSTANTIATE_TEST_SUITE_P(ResizeTestFluid_U8, ResizeTestGAPI, Combine(Values(CV_8UC1, CV_8UC3), Values(cv::INTER_LINEAR, cv::INTER_AREA), Values(TEST_RESIZE_PAIRS), Values(1))); // error not more than 1 unit -INSTANTIATE_TEST_CASE_P(ResizeRGB8UTestFluid_U8, ResizeRGB8UTestGAPI, +INSTANTIATE_TEST_SUITE_P(ResizeRGB8UTestFluid_U8, ResizeRGB8UTestGAPI, Combine(Values(CV_8UC3, CV_8UC4), Values(cv::INTER_LINEAR), Values(TEST_RESIZE_PAIRS), Values(1))); // error not more than 1 unit #endif -INSTANTIATE_TEST_CASE_P(ResizeTestFluid_F32, ResizeTestGAPI, +INSTANTIATE_TEST_SUITE_P(ResizeTestFluid_F32, ResizeTestGAPI, Combine(Values(CV_32FC1, CV_32FC3), Values(cv::INTER_LINEAR, cv::INTER_AREA), Values(TEST_RESIZE_PAIRS), Values(0.015))); // accuracy like ~1.5% -INSTANTIATE_TEST_CASE_P(SplitTestFluid, SplitTestGAPI, +INSTANTIATE_TEST_SUITE_P(SplitTestFluid, SplitTestGAPI, Combine(Values(2, 3, 4), Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_16F, CV_32F, CV_32S), Values(TEST_SIZES), Values(0))); -INSTANTIATE_TEST_CASE_P(ChanToPlaneTestFluid, ChanToPlaneTestGAPI, +INSTANTIATE_TEST_SUITE_P(ChanToPlaneTestFluid, ChanToPlaneTestGAPI, Combine(Values(1, 3), Values(CV_8U, CV_32F), Values(TEST_SIZES), Values(0))); -INSTANTIATE_TEST_CASE_P(MergeTestFluid, MergeTestGAPI, +INSTANTIATE_TEST_SUITE_P(MergeTestFluid, MergeTestGAPI, Combine(Values(2, 3, 4), Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_16F, CV_32F, CV_32S), Values(TEST_SIZES), Values(0))); -INSTANTIATE_TEST_CASE_P(NV12toRGBTestFluid, NV12toRGBTestGAPI, +INSTANTIATE_TEST_SUITE_P(NV12toRGBTestFluid, NV12toRGBTestGAPI, Combine(Values(cv::Size(3840, 2160), cv::Size(1920, 1080), cv::Size(1280, 720), @@ -159,7 +159,7 @@ INSTANTIATE_TEST_CASE_P(NV12toRGBTestFluid, NV12toRGBTestGAPI, cv::Size( 320, 200)), Values(0))); -INSTANTIATE_TEST_CASE_P(I420toRGBTestFluid, I420toRGBTestGAPI, +INSTANTIATE_TEST_SUITE_P(I420toRGBTestFluid, I420toRGBTestGAPI, Combine(Values(cv::Size(3840, 2160), cv::Size(1920, 1080), cv::Size(1280, 720), @@ -170,7 +170,7 @@ INSTANTIATE_TEST_CASE_P(I420toRGBTestFluid, I420toRGBTestGAPI, cv::Size( 320, 200)), Values(0))); -INSTANTIATE_TEST_CASE_P(ConvertDepthFluid, ConvertDepthTestGAPI, +INSTANTIATE_TEST_SUITE_P(ConvertDepthFluid, ConvertDepthTestGAPI, Combine(Values(CV_16U, CV_32F, CV_8U), Values(CV_32F, CV_16U, CV_8U), Values(cv::Size(3840, 2160), @@ -183,21 +183,21 @@ INSTANTIATE_TEST_CASE_P(ConvertDepthFluid, ConvertDepthTestGAPI, cv::Size( 320, 200)), Values(1))); -INSTANTIATE_TEST_CASE_P(DivCFluid, DivCTestGAPI, +INSTANTIATE_TEST_SUITE_P(DivCFluid, DivCTestGAPI, Combine(Values(CV_32F), Values(1), //channels Values(TEST_SIZES), Values(cv::Scalar{0.229}), Values(0))); -INSTANTIATE_TEST_CASE_P(SubCFluid, SubCTestGAPI, +INSTANTIATE_TEST_SUITE_P(SubCFluid, SubCTestGAPI, Combine(Values(CV_32F), Values(1), //channels Values(TEST_SIZES), Values(cv::Scalar{0.229}), Values(0.00001))); -INSTANTIATE_TEST_CASE_P(ResizeRoiTestFluid, ResizeRoiTestGAPI, +INSTANTIATE_TEST_SUITE_P(ResizeRoiTestFluid, ResizeRoiTestGAPI, Combine(Values(CV_8UC1, CV_8UC3), Values(cv::INTER_LINEAR), Values(std::make_pair(cv::Size(24, 24), cv::Size(12, 12))), @@ -207,7 +207,7 @@ INSTANTIATE_TEST_CASE_P(ResizeRoiTestFluid, ResizeRoiTestGAPI, cv::Rect{0, 9, 12, 3}), Values(1))); // error not more than 1 unit -INSTANTIATE_TEST_CASE_P(ResizeRGB8URoiTestFluid, ResizeRGB8URoiTestGAPI, +INSTANTIATE_TEST_SUITE_P(ResizeRGB8URoiTestFluid, ResizeRGB8URoiTestGAPI, Combine(Values(CV_8UC3, CV_8UC4), Values(cv::INTER_LINEAR), Values(std::make_pair(cv::Size(24, 24), cv::Size(12, 12))), @@ -220,38 +220,38 @@ INSTANTIATE_TEST_CASE_P(ResizeRGB8URoiTestFluid, ResizeRGB8URoiTestGAPI, //---------------------------------------------------------------------- #if defined(__arm__) || defined(__aarch64__) -INSTANTIATE_TEST_CASE_P(ResizeTestFluid_U8, ResizeTestIE, +INSTANTIATE_TEST_SUITE_P(ResizeTestFluid_U8, ResizeTestIE, Combine(Values(CV_8UC1, CV_8UC3), Values(cv::INTER_LINEAR, cv::INTER_AREA), Values(TEST_RESIZE_PAIRS), Values(4))); // error not more than 4 unit #else -INSTANTIATE_TEST_CASE_P(ResizeTestFluid_U8, ResizeTestIE, +INSTANTIATE_TEST_SUITE_P(ResizeTestFluid_U8, ResizeTestIE, Combine(Values(CV_8UC1, CV_8UC3), Values(cv::INTER_LINEAR, cv::INTER_AREA), Values(TEST_RESIZE_PAIRS), Values(1))); // error not more than 1 unit #endif -INSTANTIATE_TEST_CASE_P(ResizeTestFluid_F32, ResizeTestIE, +INSTANTIATE_TEST_SUITE_P(ResizeTestFluid_F32, ResizeTestIE, Combine(Values(CV_32FC1, CV_32FC3), Values(cv::INTER_LINEAR, cv::INTER_AREA), Values(TEST_RESIZE_PAIRS), Values(0.05))); // error within 0.05 units -INSTANTIATE_TEST_CASE_P(SplitTestFluid, SplitTestIE, +INSTANTIATE_TEST_SUITE_P(SplitTestFluid, SplitTestIE, Combine(Values(CV_8UC2, CV_8UC3, CV_8UC4, CV_32FC2, CV_32FC3, CV_32FC4), Values(TEST_SIZES), Values(0))); -INSTANTIATE_TEST_CASE_P(MergeTestFluid, MergeTestIE, +INSTANTIATE_TEST_SUITE_P(MergeTestFluid, MergeTestIE, Combine(Values(CV_8UC2, CV_8UC3, CV_8UC4, CV_32FC2, CV_32FC3, CV_32FC4), Values(TEST_SIZES), Values(0))); -INSTANTIATE_TEST_CASE_P(ColorConvertFluid_3ch, ColorConvertTestIE, +INSTANTIATE_TEST_SUITE_P(ColorConvertFluid_3ch, ColorConvertTestIE, Combine(Values(CV_8U, CV_32F), Values(InferenceEngine::ColorFormat::RGB), Values(InferenceEngine::NHWC, InferenceEngine::NCHW), @@ -259,7 +259,7 @@ INSTANTIATE_TEST_CASE_P(ColorConvertFluid_3ch, ColorConvertTestIE, Values(TEST_SIZES), Values(0))); -INSTANTIATE_TEST_CASE_P(ColorConvertFluid_4ch, ColorConvertTestIE, +INSTANTIATE_TEST_SUITE_P(ColorConvertFluid_4ch, ColorConvertTestIE, Combine(Values(CV_8U, CV_32F), Values(InferenceEngine::ColorFormat::RGBX, InferenceEngine::ColorFormat::BGRX), @@ -268,7 +268,7 @@ INSTANTIATE_TEST_CASE_P(ColorConvertFluid_4ch, ColorConvertTestIE, Values(TEST_SIZES), Values(0))); -INSTANTIATE_TEST_CASE_P(ColorConvertYUV420Fluid, ColorConvertYUV420TestIE, +INSTANTIATE_TEST_SUITE_P(ColorConvertYUV420Fluid, ColorConvertYUV420TestIE, Combine(Values(InferenceEngine::NV12, InferenceEngine::I420), Values(InferenceEngine::NHWC, InferenceEngine::NCHW), Values(cv::Size(3840, 2160), @@ -282,7 +282,7 @@ INSTANTIATE_TEST_CASE_P(ColorConvertYUV420Fluid, ColorConvertYUV420TestIE, cv::Size( 150, 150)), Values(0))); -INSTANTIATE_TEST_CASE_P(Reorder_HWC2CHW, ColorConvertTestIE, +INSTANTIATE_TEST_SUITE_P(Reorder_HWC2CHW, ColorConvertTestIE, Combine(Values(CV_8U, CV_32F, CV_16S, CV_16F), Values(InferenceEngine::ColorFormat::BGR), Values(InferenceEngine::NHWC), @@ -290,7 +290,7 @@ INSTANTIATE_TEST_CASE_P(Reorder_HWC2CHW, ColorConvertTestIE, Values(TEST_SIZES), Values(0))); -INSTANTIATE_TEST_CASE_P(Reorder_CHW2HWC, ColorConvertTestIE, +INSTANTIATE_TEST_SUITE_P(Reorder_CHW2HWC, ColorConvertTestIE, Combine(Values(CV_8U, CV_32F, CV_16S, CV_16F), Values(InferenceEngine::ColorFormat::BGR), Values(InferenceEngine::NCHW), @@ -298,7 +298,7 @@ INSTANTIATE_TEST_CASE_P(Reorder_CHW2HWC, ColorConvertTestIE, Values(TEST_SIZES), Values(0))); -INSTANTIATE_TEST_CASE_P(MeanValueGAPI32F, MeanValueGAPI, +INSTANTIATE_TEST_SUITE_P(MeanValueGAPI32F, MeanValueGAPI, Combine(Values(TEST_SIZES), Values(0.00001))); @@ -345,7 +345,7 @@ static const auto U8toU8 = std::make_pair(IE::Precision::U8,IE::Precision::U8); static const auto PRECISIONS = Values(U8toU8, std::make_pair(IE::Precision::FP32,IE::Precision::FP32)); -INSTANTIATE_TEST_CASE_P(ReorderResize_Frame, PreprocTest, +INSTANTIATE_TEST_SUITE_P(ReorderResize_Frame, PreprocTest, Combine(PRECISIONS, Values(IE::ResizeAlgorithm::RESIZE_BILINEAR), // AREA is not there yet Values(IE::ColorFormat::RAW), @@ -354,7 +354,7 @@ INSTANTIATE_TEST_CASE_P(ReorderResize_Frame, PreprocTest, Values(std::make_pair(1, 1), std::make_pair(3, 3)), FRAME_SIZES)); -INSTANTIATE_TEST_CASE_P(Scale3ch_Frame, PreprocTest, +INSTANTIATE_TEST_SUITE_P(Scale3ch_Frame, PreprocTest, Combine(PRECISIONS, Values(IE::ResizeAlgorithm::RESIZE_BILINEAR), // AREA is not there yet Values(IE::ColorFormat::RAW), @@ -363,7 +363,7 @@ INSTANTIATE_TEST_CASE_P(Scale3ch_Frame, PreprocTest, Values(std::make_pair(3, 3)), FRAME_SIZES)); -INSTANTIATE_TEST_CASE_P(ReorderResize_Patch, PreprocTest, +INSTANTIATE_TEST_SUITE_P(ReorderResize_Patch, PreprocTest, Combine(PRECISIONS, Values(IE::ResizeAlgorithm::RESIZE_BILINEAR), // AREA is not there yet Values(IE::ColorFormat::RAW), @@ -372,7 +372,7 @@ INSTANTIATE_TEST_CASE_P(ReorderResize_Patch, PreprocTest, Values(std::make_pair(1, 1), std::make_pair(3, 3)), PATCH_SIZES)); -INSTANTIATE_TEST_CASE_P(Everything_Resize, PreprocTest, +INSTANTIATE_TEST_SUITE_P(Everything_Resize, PreprocTest, Combine(PRECISIONS, Values(IE::ResizeAlgorithm::RESIZE_BILINEAR, IE::ResizeAlgorithm::RESIZE_AREA), Values(IE::ColorFormat::RAW), @@ -384,7 +384,7 @@ INSTANTIATE_TEST_CASE_P(Everything_Resize, PreprocTest, std::make_pair(4, 4)), Values(TEST_SIZES_PREPROC))); -INSTANTIATE_TEST_CASE_P(ColorFormats_3ch, PreprocTest, +INSTANTIATE_TEST_SUITE_P(ColorFormats_3ch, PreprocTest, Combine(PRECISIONS, Values(IE::ResizeAlgorithm::RESIZE_BILINEAR, IE::ResizeAlgorithm::RESIZE_AREA), Values(IE::ColorFormat::RGB), @@ -393,7 +393,7 @@ INSTANTIATE_TEST_CASE_P(ColorFormats_3ch, PreprocTest, Values(std::make_pair(3, 3)), Values(TEST_SIZES_PREPROC))); -INSTANTIATE_TEST_CASE_P(ColorFormats_4ch, PreprocTest, +INSTANTIATE_TEST_SUITE_P(ColorFormats_4ch, PreprocTest, Combine(PRECISIONS, Values(IE::ResizeAlgorithm::RESIZE_BILINEAR, IE::ResizeAlgorithm::RESIZE_AREA), Values(IE::ColorFormat::BGRX, IE::ColorFormat::RGBX), @@ -402,7 +402,7 @@ INSTANTIATE_TEST_CASE_P(ColorFormats_4ch, PreprocTest, Values(std::make_pair(4, 3)), Values(TEST_SIZES_PREPROC))); -INSTANTIATE_TEST_CASE_P(ColorFormat_NV12, PreprocTest, +INSTANTIATE_TEST_SUITE_P(ColorFormat_NV12, PreprocTest, Combine(Values(U8toU8), Values(IE::ResizeAlgorithm::RESIZE_BILINEAR, IE::ResizeAlgorithm::RESIZE_AREA), Values(IE::ColorFormat::NV12), @@ -412,7 +412,7 @@ INSTANTIATE_TEST_CASE_P(ColorFormat_NV12, PreprocTest, Values(TEST_SIZES_PREPROC))); -INSTANTIATE_TEST_CASE_P(PlainPrecisionConversions, PreprocTest, +INSTANTIATE_TEST_SUITE_P(PlainPrecisionConversions, PreprocTest, Combine(Values(std::make_pair(IE::Precision::U16,IE::Precision::FP32), std::make_pair(IE::Precision::FP32,IE::Precision::U16) ), @@ -424,7 +424,7 @@ INSTANTIATE_TEST_CASE_P(PlainPrecisionConversions, PreprocTest, Values(std::make_pair(cv::Size(640,480), cv::Size(640,480))))); -INSTANTIATE_TEST_CASE_P(PrecisionConversionsPipelines, PreprocTest, +INSTANTIATE_TEST_SUITE_P(PrecisionConversionsPipelines, PreprocTest, Combine(Values(std::make_pair(IE::Precision::U16, IE::Precision::FP32), std::make_pair(IE::Precision::FP32,IE::Precision::U8), std::make_pair(IE::Precision::U8, IE::Precision::FP32) diff --git a/inference-engine/tests_deprecated/functional/gna/backward_compatibility/backward_compatibility.cpp b/inference-engine/tests_deprecated/functional/gna/backward_compatibility/backward_compatibility.cpp index 618c857c7b5a30..21ddf424726415 100644 --- a/inference-engine/tests_deprecated/functional/gna/backward_compatibility/backward_compatibility.cpp +++ b/inference-engine/tests_deprecated/functional/gna/backward_compatibility/backward_compatibility.cpp @@ -121,7 +121,7 @@ const std::vector> importConfigs = { const std::vector nameExportModel = {"export2dot1.blob", "export2dot2.blob", "export2dot3.blob", "export2dot4.blob"}; -INSTANTIATE_TEST_CASE_P(smoke_OldVersion, BackwardCompatibilityTests, +INSTANTIATE_TEST_SUITE_P(smoke_OldVersion, BackwardCompatibilityTests, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values("GNA"), diff --git a/inference-engine/tests_deprecated/functional/gna/shared_tests_instance/input_tests/parser_tests.cpp b/inference-engine/tests_deprecated/functional/gna/shared_tests_instance/input_tests/parser_tests.cpp index d54817b53ed7ce..d53446b6a2e800 100644 --- a/inference-engine/tests_deprecated/functional/gna/shared_tests_instance/input_tests/parser_tests.cpp +++ b/inference-engine/tests_deprecated/functional/gna/shared_tests_instance/input_tests/parser_tests.cpp @@ -30,6 +30,6 @@ ir_test_params ir_test_cases[] = { ir_test_params("GNA", "FP32", negative_norm_k_case) }; -INSTANTIATE_TEST_CASE_P(FunctionalTest_smoke, IncorrectIRTests, +INSTANTIATE_TEST_SUITE_P(FunctionalTest_smoke, IncorrectIRTests, ::testing::ValuesIn(ir_test_cases), getTestName); \ No newline at end of file diff --git a/inference-engine/tests_deprecated/functional/shared_tests/io_blob_tests/cropResize_tests.hpp b/inference-engine/tests_deprecated/functional/shared_tests/io_blob_tests/cropResize_tests.hpp index 7000bedee2596b..957f47b31563f4 100644 --- a/inference-engine/tests_deprecated/functional/shared_tests/io_blob_tests/cropResize_tests.hpp +++ b/inference-engine/tests_deprecated/functional/shared_tests/io_blob_tests/cropResize_tests.hpp @@ -1186,9 +1186,9 @@ TEST_P(NV12ColorConvertTest, NV12Test) { ColorFormat::BGRX, ColorFormat::RGBX // #define PLUGING_CASE(_plugin, _test, _params) \ -// INSTANTIATE_TEST_CASE_P(_plugin##_run, _test, Combine(Values(#_plugin "Plugin"), _params) ) +// INSTANTIATE_TEST_SUITE_P(_plugin##_run, _test, Combine(Values(#_plugin "Plugin"), _params) ) #define PLUGING_CASE_WITH_SUFFIX(_device, _suffix, _test, _params) \ - INSTANTIATE_TEST_CASE_P(_device##_run##_suffix, _test, Combine(Values(#_device), _params) ) + INSTANTIATE_TEST_SUITE_P(_device##_run##_suffix, _test, Combine(Values(#_device), _params) ) #endif // USE_OPENCV diff --git a/inference-engine/tests_deprecated/functional/shared_tests/io_blob_tests/dims_tests.hpp b/inference-engine/tests_deprecated/functional/shared_tests/io_blob_tests/dims_tests.hpp index 866542377bd7cf..b89ed7f1c7dea4 100644 --- a/inference-engine/tests_deprecated/functional/shared_tests/io_blob_tests/dims_tests.hpp +++ b/inference-engine/tests_deprecated/functional/shared_tests/io_blob_tests/dims_tests.hpp @@ -192,7 +192,7 @@ static auto params = ::testing::Values(Precision::FP32); // network precision static auto params_myriad = ::testing::Values(Precision::FP16); // network precision #define PLUGING_CASE(_device, _test, _params) \ - INSTANTIATE_TEST_CASE_P(_device##_run, _test, ::testing::Combine(::testing::Values(#_device), _params) ) + INSTANTIATE_TEST_SUITE_P(_device##_run, _test, ::testing::Combine(::testing::Values(#_device), _params) ) #define PLUGING_CASE_WITH_SUFFIX(_device, _suffix, _test, _params) \ - INSTANTIATE_TEST_CASE_P(_device##_run##_suffix, _test, ::testing::Combine(::testing::Values(#_device), _params) ) + INSTANTIATE_TEST_SUITE_P(_device##_run##_suffix, _test, ::testing::Combine(::testing::Values(#_device), _params) ) diff --git a/inference-engine/tests_deprecated/functional/shared_tests/io_blob_tests/layout_tests.hpp b/inference-engine/tests_deprecated/functional/shared_tests/io_blob_tests/layout_tests.hpp index 502cefab902003..06f0a48d71e501 100644 --- a/inference-engine/tests_deprecated/functional/shared_tests/io_blob_tests/layout_tests.hpp +++ b/inference-engine/tests_deprecated/functional/shared_tests/io_blob_tests/layout_tests.hpp @@ -217,10 +217,10 @@ conv_param conv_p = { 3,3, // kernel {2,16,13,13}}; // out shape #define PLUGING_CASE(_device, _test, _params) \ - INSTANTIATE_TEST_CASE_P(_device##_run, _test, ::testing::Combine(::testing::Values(#_device), _params) ) + INSTANTIATE_TEST_SUITE_P(_device##_run, _test, ::testing::Combine(::testing::Values(#_device), _params) ) #define PLUGING_CASE_WITH_SUFFIX(_device, _suffix, _test, _params) \ - INSTANTIATE_TEST_CASE_P(_device##_run##_suffix, _test, ::testing::Combine(::testing::Values(#_device), _params) ) + INSTANTIATE_TEST_SUITE_P(_device##_run##_suffix, _test, ::testing::Combine(::testing::Values(#_device), _params) ) #define PLUGING_CASE_WITH_PREFIX(_device, _prefix, _test, _params) \ - INSTANTIATE_TEST_CASE_P(_prefix##_device##_run, _test, ::testing::Combine(::testing::Values(#_device), _params) ) + INSTANTIATE_TEST_SUITE_P(_prefix##_device##_run, _test, ::testing::Combine(::testing::Values(#_device), _params) ) diff --git a/inference-engine/tests_deprecated/functional/shared_tests/lstm/plg_test.hpp b/inference-engine/tests_deprecated/functional/shared_tests/lstm/plg_test.hpp index c7e5039b327fb3..9e5b63d76a3753 100644 --- a/inference-engine/tests_deprecated/functional/shared_tests/lstm/plg_test.hpp +++ b/inference-engine/tests_deprecated/functional/shared_tests/lstm/plg_test.hpp @@ -64,10 +64,10 @@ class Named { * @brief Macros to specify Per Plugin Run Test Case with parameters. */ #define RUN_CASE_P_WITH_SUFFIX(_plugin, _suffix, _test, _params) \ - INSTANTIATE_TEST_CASE_P(_plugin##_run##_suffix, _test, ::testing::Combine(::testing::Values(#_plugin), ::testing::ValuesIn(_params) )) + INSTANTIATE_TEST_SUITE_P(_plugin##_run##_suffix, _test, ::testing::Combine(::testing::Values(#_plugin), ::testing::ValuesIn(_params) )) /** * @brief Macros to specify Per Plugin Run Test Case with Cartesian Product of parameters. */ #define RUN_CASE_CP_WITH_SUFFIX(_plugin, _suffix, _test, _params, ...) \ - INSTANTIATE_TEST_CASE_P(_plugin##_run##_suffix, _test, ::testing::Combine(::testing::Values(#_plugin), _params), __VA_ARGS__ ) + INSTANTIATE_TEST_SUITE_P(_plugin##_run##_suffix, _test, ::testing::Combine(::testing::Values(#_plugin), _params), __VA_ARGS__ ) diff --git a/inference-engine/tests_deprecated/functional/shared_tests/lstm/rnn_seq_test.hpp b/inference-engine/tests_deprecated/functional/shared_tests/lstm/rnn_seq_test.hpp index 4e83949cf7389f..0c4db4ef993520 100644 --- a/inference-engine/tests_deprecated/functional/shared_tests/lstm/rnn_seq_test.hpp +++ b/inference-engine/tests_deprecated/functional/shared_tests/lstm/rnn_seq_test.hpp @@ -75,7 +75,7 @@ TEST_P(RNNSeqTest, DISABLED_SingleRNN) { auto resh = std::get<7>(p); if (device_name == "GPU" && cell.type != LSTM) - SKIP(); + GTEST_SKIP(); cell.clip = clip; diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_CTCDecoder_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_CTCDecoder_test.cpp index d645f5627ea3d2..c95b62f8b3e83e 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_CTCDecoder_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_CTCDecoder_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_CTCDecoder_test.hpp" -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( DISABLED_accuracy, myriadCTCDecoderLayerTests_smoke, ::testing::Combine( ::testing::Values({{1, 88, 1, 71}}), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_batch_normalization_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_batch_normalization_test.cpp index 7e0378afebfaa0..d64f8d4eeea5f0 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_batch_normalization_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_batch_normalization_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_batch_normalization_test.hpp" -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy, myriadLayersTestsBatchNormalization_smoke, ::testing::Values( bn_test_params{{1, 1, 16, 8}, 0.001f}, diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_bias_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_bias_test.cpp index a54a50efbe0303..8757631cb8e9bb 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_bias_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_bias_test.cpp @@ -4,6 +4,6 @@ #include "myriad_layers_bias_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsBias_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsBias_smoke, ::testing::ValuesIn(s_biasDims) ); diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_blob_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_blob_test.cpp index 7a2c027be03113..6128ac1ee1bd17 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_blob_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_blob_test.cpp @@ -62,7 +62,7 @@ TEST_P(myriadBlobTests_smoke, CanGetSameBlobsOnSameIR) { } } -INSTANTIATE_TEST_CASE_P(accuracy, myriadBlobTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadBlobTests_smoke, ::testing::Values(CONFIG_VALUE(YES), CONFIG_VALUE(NO)) ); @@ -356,7 +356,7 @@ using myriadExtraTests_smoke = myriadLayersTests_nightly; TEST_F(myriadExtraTests_smoke, ThereIsNoSegfaultOnZeroConvolutionWeights) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } tensor_test_params input_dims = { 1, 3, 25, 25 }; @@ -413,5 +413,5 @@ static const std::vector inputPrecisions = {Inferenc static const std::vector outputPrecisions = {InferenceEngine::Precision::FP16, InferenceEngine::Precision::FP32}; -INSTANTIATE_TEST_CASE_P(accuracy, myriadBlobExportAccuracyDifferentPrecisionOfInAndOutTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadBlobExportAccuracyDifferentPrecisionOfInAndOutTests_smoke, ::testing::Combine(::testing::ValuesIn(inputPrecisions), ::testing::ValuesIn(outputPrecisions))); diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_clamp_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_clamp_test.cpp index 4d031eed5dcd2c..5f5e64c36156a3 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_clamp_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_clamp_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_clamp_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsClampParams_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsClampParams_smoke, ::testing::Combine( ::testing::ValuesIn(s_clampTensors), ::testing::ValuesIn(s_clampParams)) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_concat_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_concat_test.cpp index 5872049504a145..7b7ad34fdce67b 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_concat_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_concat_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_concat_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsConcat_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsConcat_smoke, ::testing::Combine( ::testing::ValuesIn(s_concatCores), ::testing::ValuesIn(s_axis), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_conv_nd_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_conv_nd_test.cpp index 472403fa6f283a..f5c59174bd12b6 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_conv_nd_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_conv_nd_test.cpp @@ -12,7 +12,7 @@ using namespace testing; // //---------------------------------------------------------------------- -INSTANTIATE_TEST_CASE_P(tricky_ncdhw_userpad, myriadLayersConvNDTest_smoke, +INSTANTIATE_TEST_SUITE_P(tricky_ncdhw_userpad, myriadLayersConvNDTest_smoke, Combine( Values(InputShape {1, 3, 19, 65, 47}), Values(KernelShape {1, 3, 5}), @@ -26,7 +26,7 @@ INSTANTIATE_TEST_CASE_P(tricky_ncdhw_userpad, myriadLayersConvNDTest_smoke, ) ); -INSTANTIATE_TEST_CASE_P(tricky_ncdhw_autopad, myriadLayersConvNDTest_smoke, +INSTANTIATE_TEST_SUITE_P(tricky_ncdhw_autopad, myriadLayersConvNDTest_smoke, Combine( Values(InputShape {1, 3, 19, 65, 47}), Values(KernelShape {1, 3, 5}), @@ -48,7 +48,7 @@ INSTANTIATE_TEST_CASE_P(tricky_ncdhw_autopad, myriadLayersConvNDTest_smoke, // //---------------------------------------------------------------------- -INSTANTIATE_TEST_CASE_P(simple_ncdhw_userpad, myriadLayersConvNDTest_smoke, +INSTANTIATE_TEST_SUITE_P(simple_ncdhw_userpad, myriadLayersConvNDTest_smoke, Combine( Values(InputShape {1, 3, 20, 64, 48}), Values(KernelShape {3, 3, 3}), @@ -62,7 +62,7 @@ INSTANTIATE_TEST_CASE_P(simple_ncdhw_userpad, myriadLayersConvNDTest_smoke, ) ); -INSTANTIATE_TEST_CASE_P(simple_ncdhw_autopad, myriadLayersConvNDTest_smoke, +INSTANTIATE_TEST_SUITE_P(simple_ncdhw_autopad, myriadLayersConvNDTest_smoke, Combine( Values(InputShape {1, 3, 20, 64, 48}), Values(KernelShape {3, 3, 3}), @@ -84,7 +84,7 @@ INSTANTIATE_TEST_CASE_P(simple_ncdhw_autopad, myriadLayersConvNDTest_smoke, // //---------------------------------------------------------------------- -INSTANTIATE_TEST_CASE_P(tricky_nchw_userpad, myriadLayersConvNDTest_smoke, +INSTANTIATE_TEST_SUITE_P(tricky_nchw_userpad, myriadLayersConvNDTest_smoke, Combine( Values(InputShape {1, 3, 65, 47}), Values(KernelShape {1, 3}), @@ -98,7 +98,7 @@ INSTANTIATE_TEST_CASE_P(tricky_nchw_userpad, myriadLayersConvNDTest_smoke, ) ); -INSTANTIATE_TEST_CASE_P(tricky_nchw_autopad, myriadLayersConvNDTest_smoke, +INSTANTIATE_TEST_SUITE_P(tricky_nchw_autopad, myriadLayersConvNDTest_smoke, Combine( Values(InputShape {1, 3, 65, 47}), Values(KernelShape {1, 3}), @@ -120,7 +120,7 @@ INSTANTIATE_TEST_CASE_P(tricky_nchw_autopad, myriadLayersConvNDTest_smoke, // //---------------------------------------------------------------------- -INSTANTIATE_TEST_CASE_P(simple_nchw_userpad, myriadLayersConvNDTest_smoke, +INSTANTIATE_TEST_SUITE_P(simple_nchw_userpad, myriadLayersConvNDTest_smoke, Combine( Values(InputShape {1, 3, 64, 48}), Values(KernelShape {3, 3}), @@ -134,7 +134,7 @@ INSTANTIATE_TEST_CASE_P(simple_nchw_userpad, myriadLayersConvNDTest_smoke, ) ); -INSTANTIATE_TEST_CASE_P(simple_nchw_autopad, myriadLayersConvNDTest_smoke, +INSTANTIATE_TEST_SUITE_P(simple_nchw_autopad, myriadLayersConvNDTest_smoke, Combine( Values(InputShape {1, 3, 64, 48}), Values(KernelShape {3, 3}), @@ -158,7 +158,7 @@ INSTANTIATE_TEST_CASE_P(simple_nchw_autopad, myriadLayersConvNDTest_smoke, // NB: requires 1GB of RAM on device (e.g. ma2085 board) // Stress test: large image with large depth, large kernel -INSTANTIATE_TEST_CASE_P(i3d_id6, myriadLayersConvNDTest_smoke, +INSTANTIATE_TEST_SUITE_P(i3d_id6, myriadLayersConvNDTest_smoke, Combine( Values(InputShape {1, 3, 79, 224, 224}), Values(KernelShape {7, 7, 7}), @@ -171,7 +171,7 @@ INSTANTIATE_TEST_CASE_P(i3d_id6, myriadLayersConvNDTest_smoke, Values(Groups(1)))); // Like `i3d_id6` test but with smaller image (so must fit in Myriad X) -INSTANTIATE_TEST_CASE_P(i3d_id6_shrink, myriadLayersConvNDTest_smoke, +INSTANTIATE_TEST_SUITE_P(i3d_id6_shrink, myriadLayersConvNDTest_smoke, Combine( Values(InputShape {1, 3, 39, 112, 112}), Values(KernelShape {7, 7, 7}), @@ -184,7 +184,7 @@ INSTANTIATE_TEST_CASE_P(i3d_id6_shrink, myriadLayersConvNDTest_smoke, Values(Groups(1)))); // Average-size image, trivial kernel 1x1x1 -INSTANTIATE_TEST_CASE_P(i3d_id12, myriadLayersConvNDTest_smoke, +INSTANTIATE_TEST_SUITE_P(i3d_id12, myriadLayersConvNDTest_smoke, Combine( Values(InputShape {1, 64, 40, 56, 56}), Values(KernelShape {1, 1, 1}), @@ -197,7 +197,7 @@ INSTANTIATE_TEST_CASE_P(i3d_id12, myriadLayersConvNDTest_smoke, Values(Groups(1)))); // Average-size image, non-trivial kernel 3x3x3 -INSTANTIATE_TEST_CASE_P(i3d_id17, myriadLayersConvNDTest_smoke, +INSTANTIATE_TEST_SUITE_P(i3d_id17, myriadLayersConvNDTest_smoke, Combine( Values(InputShape {1, 64, 40, 56, 56}), Values(KernelShape {3, 3, 3}), @@ -210,7 +210,7 @@ INSTANTIATE_TEST_CASE_P(i3d_id17, myriadLayersConvNDTest_smoke, Values(Groups(1)))); // Small image (7x7), trivial kernel -INSTANTIATE_TEST_CASE_P(i3d_id249, myriadLayersConvNDTest_smoke, +INSTANTIATE_TEST_SUITE_P(i3d_id249, myriadLayersConvNDTest_smoke, Combine( Values(InputShape {1, 832, 10, 7, 7}), Values(KernelShape {1, 1, 1}), @@ -223,7 +223,7 @@ INSTANTIATE_TEST_CASE_P(i3d_id249, myriadLayersConvNDTest_smoke, Values(Groups(1)))); // Small image (7x7), non-trivial kernel -INSTANTIATE_TEST_CASE_P(i3d_id301, myriadLayersConvNDTest_smoke, +INSTANTIATE_TEST_SUITE_P(i3d_id301, myriadLayersConvNDTest_smoke, Combine( Values(InputShape {1, 48, 10, 7, 7}), Values(KernelShape {3, 3, 3}), @@ -236,7 +236,7 @@ INSTANTIATE_TEST_CASE_P(i3d_id301, myriadLayersConvNDTest_smoke, Values(Groups(1)))); // Trivial image (1x1), trivial kernel -INSTANTIATE_TEST_CASE_P(i3d_id314, myriadLayersConvNDTest_smoke, +INSTANTIATE_TEST_SUITE_P(i3d_id314, myriadLayersConvNDTest_smoke, Combine( Values(InputShape {1, 1024, 9, 1, 1}), Values(KernelShape {1, 1, 1}), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_convert_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_convert_test.cpp index 582311afe2289a..0b2fe34caeaa35 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_convert_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_convert_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_convert_test.hpp" -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy, myriadLayersTestsIOConvert_smoke, ::testing::Combine( ::testing::ValuesIn(inputsDims), @@ -13,7 +13,7 @@ INSTANTIATE_TEST_CASE_P( ) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy_customu8f16, myriadLayersTestsIOConvert_smoke, ::testing::Combine( ::testing::ValuesIn(inputsDims4D), @@ -22,7 +22,7 @@ INSTANTIATE_TEST_CASE_P( ) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy, myriadLayersTestsConvertWithFP16_smoke, ::testing::Combine( ::testing::ValuesIn(inputsDims), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_convolution1x1.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_convolution1x1.cpp index b25f1d80d38e12..eaf3e8f3052d64 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_convolution1x1.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_convolution1x1.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_convolution1x1.hpp" -INSTANTIATE_TEST_CASE_P(myriad, myriadConvolution1x1LayerTests_smoke, +INSTANTIATE_TEST_SUITE_P(myriad, myriadConvolution1x1LayerTests_smoke, ::testing::Combine( ::testing::Values(CONFIG_VALUE(NO)), ::testing::ValuesIn(s_isHWC), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_convolution3x3.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_convolution3x3.cpp index 537bef657fdf3b..97257fd76c51f3 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_convolution3x3.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_convolution3x3.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_convolution3x3.hpp" -INSTANTIATE_TEST_CASE_P(myriad, myriadConvolution3x3LayerTests_smoke, +INSTANTIATE_TEST_SUITE_P(myriad, myriadConvolution3x3LayerTests_smoke, ::testing::Combine( ::testing::Values(CONFIG_VALUE(NO)), ::testing::ValuesIn(s_DimsConfig))); diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_convolution_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_convolution_test.cpp index 9093504eaf65ea..8bea8f5d995f7d 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_convolution_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_convolution_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_convolution_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy_chw_dilation, myriadLayerConvolution_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_chw_dilation, myriadLayerConvolution_smoke, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 37, 43, 43) , MAKE_STRUCT(tensor_test_params, 1, 37, 19, 19)) @@ -21,7 +21,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_chw_dilation, myriadLayerConvolution_smoke, ) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayers_IR3_ConvTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayers_IR3_ConvTests_smoke, ::testing::Combine( ::testing::Values({1, 3, 32, 24}) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -33,7 +33,7 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadLayers_IR3_ConvTests_smoke, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_Batch_0, myriadLayers_BatchTest_ConvTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_Batch_0, myriadLayers_BatchTest_ConvTests_smoke, ::testing::Combine( ::testing::Values({10, 5, 1, 1}) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) @@ -45,7 +45,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_Batch_0, myriadLayers_BatchTest_ConvTests_smoke ) ); -INSTANTIATE_TEST_CASE_P(accuracy_Batch_1, myriadLayers_BatchTest_ConvTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_Batch_1, myriadLayers_BatchTest_ConvTests_smoke, ::testing::Combine( ::testing::Values({10, 576, 7, 7}) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) @@ -57,7 +57,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_Batch_1, myriadLayers_BatchTest_ConvTests_smoke ) ); -INSTANTIATE_TEST_CASE_P(accuracy_Batch_2, myriadLayers_BatchTest_ConvTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_Batch_2, myriadLayers_BatchTest_ConvTests_smoke, ::testing::Combine( ::testing::Values({10, 128, 7, 7}) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -69,7 +69,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_Batch_2, myriadLayers_BatchTest_ConvTests_smoke ) ); -INSTANTIATE_TEST_CASE_P(accuracy_Batch_3, myriadLayers_BatchTest_ConvTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_Batch_3, myriadLayers_BatchTest_ConvTests_smoke, ::testing::Combine( ::testing::Values({10, 4, 7, 7}) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) @@ -81,7 +81,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_Batch_3, myriadLayers_BatchTest_ConvTests_smoke ) ); -INSTANTIATE_TEST_CASE_P(accuracy_Batch_4, myriadLayers_BatchTest_ConvTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_Batch_4, myriadLayers_BatchTest_ConvTests_smoke, ::testing::Combine( ::testing::Values({10, 256, 7, 7}) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -93,7 +93,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_Batch_4, myriadLayers_BatchTest_ConvTests_smoke ) ); -INSTANTIATE_TEST_CASE_P(accuracy_Batch_5, myriadLayers_BatchTest_ConvTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_Batch_5, myriadLayers_BatchTest_ConvTests_smoke, ::testing::Combine( ::testing::Values({10, 1024, 4, 4}) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) @@ -105,7 +105,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_Batch_5, myriadLayers_BatchTest_ConvTests_smoke ) ); -INSTANTIATE_TEST_CASE_P(accuracy_Batch_6, myriadLayers_BatchTest_ConvTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_Batch_6, myriadLayers_BatchTest_ConvTests_smoke, ::testing::Combine( ::testing::Values({10, 192, 4, 4}) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -117,7 +117,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_Batch_6, myriadLayers_BatchTest_ConvTests_smoke ) ); -INSTANTIATE_TEST_CASE_P(accuracy_Batch_7, myriadLayers_BatchTest_ConvTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_Batch_7, myriadLayers_BatchTest_ConvTests_smoke, ::testing::Combine( ::testing::Values({10, 160, 4, 4}) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -129,7 +129,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_Batch_7, myriadLayers_BatchTest_ConvTests_smoke ) ); -INSTANTIATE_TEST_CASE_P(accuracy_Batch_8, myriadLayers_BatchTest_ConvTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_Batch_8, myriadLayers_BatchTest_ConvTests_smoke, ::testing::Combine( ::testing::Values({10, 224, 4, 4}) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -141,7 +141,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_Batch_8, myriadLayers_BatchTest_ConvTests_smoke ) ); -INSTANTIATE_TEST_CASE_P(accuracy_Batch_9, myriadLayers_BatchTest_ConvTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_Batch_9, myriadLayers_BatchTest_ConvTests_smoke, ::testing::Combine( ::testing::Values({10, 1024, 4, 4}) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) @@ -153,7 +153,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_Batch_9, myriadLayers_BatchTest_ConvTests_smoke ) ); -INSTANTIATE_TEST_CASE_P(accuracy_Batch_10, myriadLayers_BatchTest_ConvTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_Batch_10, myriadLayers_BatchTest_ConvTests_smoke, ::testing::Combine( ::testing::Values({1, 64, 56, 56}) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -165,7 +165,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_Batch_10, myriadLayers_BatchTest_ConvTests_smok ) ); -INSTANTIATE_TEST_CASE_P(accuracy_Batch_11, myriadLayers_BatchTest_ConvTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_Batch_11, myriadLayers_BatchTest_ConvTests_smoke, ::testing::Combine( ::testing::Values({10, 192, 7, 7}) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -177,7 +177,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_Batch_11, myriadLayers_BatchTest_ConvTests_smok ) ); -INSTANTIATE_TEST_CASE_P(accuracy_Batch_12, myriadLayers_BatchTest_ConvTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_Batch_12, myriadLayers_BatchTest_ConvTests_smoke, ::testing::Combine( ::testing::Values({10, 576, 7, 7}) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) @@ -189,7 +189,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_Batch_12, myriadLayers_BatchTest_ConvTests_smok ) ); -INSTANTIATE_TEST_CASE_P(accuracy_Batch_1, myriadLayers_BatchTest2_ConvTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_Batch_1, myriadLayers_BatchTest2_ConvTests_smoke, ::testing::Combine( ::testing::Values({10, 576, 7, 7}) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) @@ -201,7 +201,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_Batch_1, myriadLayers_BatchTest2_ConvTests_smok ) ); -INSTANTIATE_TEST_CASE_P(accuracy_3X3, myriadLayers_IR3_ConvTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_3X3, myriadLayers_IR3_ConvTests_smoke, ::testing::Combine( ::testing::Values({1, 3, 32, 24}) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -213,7 +213,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_3X3, myriadLayers_IR3_ConvTests_smoke, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_3X1, myriadLayers_IR3_ConvTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_3X1, myriadLayers_IR3_ConvTests_smoke, ::testing::Combine( ::testing::Values({1, 3, 32, 24}) , ::testing::Values(MAKE_STRUCT(param_size, 3, 1)) @@ -225,7 +225,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_3X1, myriadLayers_IR3_ConvTests_smoke, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_1X3, myriadLayers_IR3_ConvTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_1X3, myriadLayers_IR3_ConvTests_smoke, ::testing::Combine( ::testing::Values({1, 4, 16, 16}) , ::testing::Values(MAKE_STRUCT(param_size, 1, 3)) @@ -237,7 +237,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_1X3, myriadLayers_IR3_ConvTests_smoke, ) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayers_3X3X3_ConstInput_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayers_3X3X3_ConstInput_smoke, ::testing::Combine( ::testing::Values({1, 3, 10, 10}) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -249,7 +249,7 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadLayers_3X3X3_ConstInput_smoke, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_crossroad_spatialConv, myriadLayerConvolutionTensorFlow, +INSTANTIATE_TEST_SUITE_P(accuracy_crossroad_spatialConv, myriadLayerConvolutionTensorFlow, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 3, 1024, 1024)) , ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 3, 512, 512)) @@ -262,7 +262,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_crossroad_spatialConv, myriadLayerConvolutionTe ) ); -INSTANTIATE_TEST_CASE_P(accuracy_inception_v2, myriadLayerConvolutionTensorFlow, +INSTANTIATE_TEST_SUITE_P(accuracy_inception_v2, myriadLayerConvolutionTensorFlow, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 16, 28, 28)) , ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 64, 14, 14)) @@ -275,7 +275,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_inception_v2, myriadLayerConvolutionTensorFlow, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_inception_v1, myriadLayerConvolutionTensorFlow, +INSTANTIATE_TEST_SUITE_P(accuracy_inception_v1, myriadLayerConvolutionTensorFlow, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 3, 224, 224), MAKE_STRUCT(tensor_test_params, 1, 32, 224, 224) @@ -290,7 +290,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_inception_v1, myriadLayerConvolutionTensorFlow, ) ); -INSTANTIATE_TEST_CASE_P(test_3x3_SSD_dilation, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(test_3x3_SSD_dilation, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 512, 19, 19)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -303,7 +303,7 @@ INSTANTIATE_TEST_CASE_P(test_3x3_SSD_dilation, myriadLayerConvolution, ) ); -INSTANTIATE_TEST_CASE_P(test_TF_Resnet_50, myriadLayers_IR3_ConvTests_smoke, +INSTANTIATE_TEST_SUITE_P(test_TF_Resnet_50, myriadLayers_IR3_ConvTests_smoke, ::testing::Combine( ::testing::Values({1, 512, 38, 38}) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) @@ -315,7 +315,7 @@ INSTANTIATE_TEST_CASE_P(test_TF_Resnet_50, myriadLayers_IR3_ConvTests_smoke, ) ); -INSTANTIATE_TEST_CASE_P(test_3x3_icvnet_dilation, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(test_3x3_icvnet_dilation, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 24, 20, 20)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -330,7 +330,7 @@ INSTANTIATE_TEST_CASE_P(test_3x3_icvnet_dilation, myriadLayerConvolution, ) ); -INSTANTIATE_TEST_CASE_P(test_5x5_with_dilation, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(test_5x5_with_dilation, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 32, 64, 77)) , ::testing::Values(MAKE_STRUCT(param_size, 5, 5)) @@ -346,7 +346,7 @@ INSTANTIATE_TEST_CASE_P(test_5x5_with_dilation, myriadLayerConvolution, ) ); -INSTANTIATE_TEST_CASE_P(test_7x7_with_dilation, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(test_7x7_with_dilation, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 32, 64, 77)) , ::testing::Values(MAKE_STRUCT(param_size, 7, 7)) @@ -363,7 +363,7 @@ INSTANTIATE_TEST_CASE_P(test_7x7_with_dilation, myriadLayerConvolution, ); -INSTANTIATE_TEST_CASE_P(test_conv1x1, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(test_conv1x1, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 10, 13, 13)) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) @@ -377,7 +377,7 @@ INSTANTIATE_TEST_CASE_P(test_conv1x1, myriadLayerConvolution, ) ); -INSTANTIATE_TEST_CASE_P(test_yolo_tiny_2_512x13x13_use_3x3_convolution, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(test_yolo_tiny_2_512x13x13_use_3x3_convolution, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 512, 13, 13)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -390,7 +390,7 @@ INSTANTIATE_TEST_CASE_P(test_yolo_tiny_2_512x13x13_use_3x3_convolution, myriadLa ) ); -INSTANTIATE_TEST_CASE_P(test_yolo_tiny_2_512x13x13_use_1x1_convolution, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(test_yolo_tiny_2_512x13x13_use_1x1_convolution, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 4608, 13, 13)) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) @@ -403,7 +403,7 @@ INSTANTIATE_TEST_CASE_P(test_yolo_tiny_2_512x13x13_use_1x1_convolution, myriadLa ) ); -INSTANTIATE_TEST_CASE_P(accuracy_group, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(accuracy_group, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 32, 64, 77) , MAKE_STRUCT(tensor_test_params, 1, 32, 112, 96)) @@ -422,7 +422,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_group, myriadLayerConvolution, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_group_large_input, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(accuracy_group_large_input, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 32, 192, 336)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -437,7 +437,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_group_large_input, myriadLayerConvolution, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_any_group, myriadLayerConvolution_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_any_group, myriadLayerConvolution_smoke, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 32, 64, 77)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -453,7 +453,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_any_group, myriadLayerConvolution_smoke, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_any_group, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(accuracy_any_group, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 32, 64, 77)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -469,7 +469,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_any_group, myriadLayerConvolution, ) ); -INSTANTIATE_TEST_CASE_P(set_optimization_for_3x3_with_group, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(set_optimization_for_3x3_with_group, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 24, 80, 80) , MAKE_STRUCT(tensor_test_params, 1, 36, 80, 80)) @@ -484,7 +484,7 @@ INSTANTIATE_TEST_CASE_P(set_optimization_for_3x3_with_group, myriadLayerConvolut ) ); -INSTANTIATE_TEST_CASE_P(set_optimization_for_3x3s1, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(set_optimization_for_3x3s1, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 24, 80, 80)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -497,7 +497,7 @@ INSTANTIATE_TEST_CASE_P(set_optimization_for_3x3s1, myriadLayerConvolution, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_1x1, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(accuracy_1x1, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 16, 64, 64) , MAKE_STRUCT(tensor_test_params, 1, 32, 1, 1)) @@ -514,7 +514,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_1x1, myriadLayerConvolution, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_3x3, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(accuracy_3x3, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 8, 16, 16) , MAKE_STRUCT(tensor_test_params, 1, 8, 59, 73)) @@ -530,7 +530,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_3x3, myriadLayerConvolution, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_1x3, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(accuracy_1x3, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 8, 59, 73)) , ::testing::Values(MAKE_STRUCT(param_size, 1, 3), MAKE_STRUCT(param_size, 3, 1)) @@ -544,7 +544,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_1x3, myriadLayerConvolution, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_5x5, myriadLayerConvolution_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_5x5, myriadLayerConvolution_smoke, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 16, 32, 32) /*, MAKE_STRUCT(tensor_test_params, 1, 8, 511, 399) failed*/) @@ -561,7 +561,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_5x5, myriadLayerConvolution_smoke, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_5x5, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(accuracy_5x5, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 16, 32, 32) /*, MAKE_STRUCT(tensor_test_params, 1, 8, 511, 399) failed*/) @@ -578,7 +578,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_5x5, myriadLayerConvolution, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_7x7, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(accuracy_7x7, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 8, 32, 32) /*, MAKE_STRUCT(tensor_test_params, 1, 8, 511, 399) failed*/) @@ -595,7 +595,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_7x7, myriadLayerConvolution, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_3x3_large_input_1, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(accuracy_3x3_large_input_1, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 3, 720, 1280)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -608,7 +608,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_3x3_large_input_1, myriadLayerConvolution, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_3x3_large_input_2, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(accuracy_3x3_large_input_2, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 24, 357, 637)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -622,7 +622,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_3x3_large_input_2, myriadLayerConvolution, ); -INSTANTIATE_TEST_CASE_P(accuracy_3x3_large_input_3, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(accuracy_3x3_large_input_3, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 16, 359, 639)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -635,7 +635,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_3x3_large_input_3, myriadLayerConvolution, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_1x1_large_input, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(accuracy_1x1_large_input, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 24, 355, 635)) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) @@ -648,7 +648,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_1x1_large_input, myriadLayerConvolution, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_small_input_0, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(accuracy_small_input_0, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 128, 38, 38)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -660,7 +660,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_small_input_0, myriadLayerConvolution, , ::testing::Values(vpu::LayoutPreference::ChannelMinor) ) ); -INSTANTIATE_TEST_CASE_P(accuracy_small_input_1, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(accuracy_small_input_1, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 256, 2, 3)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -672,7 +672,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_small_input_1, myriadLayerConvolution, , ::testing::Values(vpu::LayoutPreference::ChannelMinor) ) ); -INSTANTIATE_TEST_CASE_P(accuracy_small_input_2, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(accuracy_small_input_2, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 256, 2, 2)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -684,7 +684,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_small_input_2, myriadLayerConvolution, , ::testing::Values(vpu::LayoutPreference::ChannelMinor) ) ); -INSTANTIATE_TEST_CASE_P(accuracy_small_input_3, myriadLayerConvolution, +INSTANTIATE_TEST_SUITE_P(accuracy_small_input_3, myriadLayerConvolution, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 256, 1, 1)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_copy_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_copy_test.cpp index 2dafed621277ba..2f42d4d9dfff13 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_copy_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_copy_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_copy_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayerCopy_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayerCopy_smoke, ::testing::Combine( ::testing::Values(MAKE_STRUCT(nd_tensor_test_params, {36, 19, 20, 21}) , MAKE_STRUCT(nd_tensor_test_params, {7, 8, 5, 12}) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_crop_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_crop_test.cpp index 8df5595df1786b..c7bcc255f3ca6e 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_crop_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_crop_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_crop_test.hpp" -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy_Crop, myriadLayerCropOneInputAndDim_smoke, ::testing::Combine( ::testing::ValuesIn(s_tileTensors1), @@ -14,7 +14,7 @@ INSTANTIATE_TEST_CASE_P( ::testing::ValuesIn(s_tileDim)) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy_Crop1, myriadLayerCropOneInput_smoke, ::testing::Combine( ::testing::ValuesIn(s_tileTensors1), @@ -24,7 +24,7 @@ INSTANTIATE_TEST_CASE_P( ::testing::ValuesIn(s_tileCropEnd)) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy_Crop2, myriadLayerCropTwoInputs_smoke, ::testing::Combine( ::testing::ValuesIn(s_tileTensors1), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_custom_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_custom_test.cpp index 106f2ea52532a6..ceebce481f85bb 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_custom_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_custom_test.cpp @@ -4,27 +4,27 @@ #include "myriad_layers_custom_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsShuffleChannel_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsShuffleChannel_smoke, ::testing::Combine( ::testing::ValuesIn(s_ShuffleChannelTensors), ::testing::ValuesIn(s_ShuffleChannelGroup), ::testing::ValuesIn(s_CustomConfig))); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsFakeQuantize_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsFakeQuantize_smoke, ::testing::Combine( ::testing::ValuesIn(s_QuantizeTensors), ::testing::ValuesIn(s_QuantizeLevels), ::testing::Values(IRVersion::v7, IRVersion::v10), ::testing::ValuesIn(s_CustomConfig))); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsQuantizeBinarize_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsQuantizeBinarize_smoke, ::testing::Combine( ::testing::ValuesIn(s_QuantizeTensors), ::testing::Values(2), ::testing::ValuesIn(s_QuantizeSwitchOut), ::testing::ValuesIn(s_CustomConfig))); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsBinaryConvolution_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsBinaryConvolution_smoke, ::testing::Combine( ::testing::ValuesIn(s_BinaryConvolutionTensors), ::testing::ValuesIn(s_BinaryConvolutionDilations), @@ -33,17 +33,17 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsBinaryConvolution_smoke, ::testing::ValuesIn(s_BinaryConvolutionStrides), ::testing::ValuesIn(s_CustomConfig))); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsExperimentalDetectronPriorGridGenerator_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsExperimentalDetectronPriorGridGenerator_smoke, ::testing::Combine( ::testing::ValuesIn(s_ExperimentalDetectronPriorGridGeneratorImageDims), ::testing::ValuesIn(s_CustomConfig))); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsCorrelate_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsCorrelate_smoke, ::testing::Combine( ::testing::ValuesIn(s_CorrelateParams), ::testing::ValuesIn(s_CustomConfig))); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsSpatialTransform_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsSpatialTransform_smoke, ::testing::Combine( ::testing::ValuesIn(s_SpatialTransformInputs), ::testing::ValuesIn(s_SpatialTransformTheta), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_deconvolution_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_deconvolution_test.cpp index 6dd93d3b1460e6..c7412b5760c193 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_deconvolution_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_deconvolution_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_deconvolution_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy_deconv_to_conv, myriadLayerDeconvolution_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_deconv_to_conv, myriadLayerDeconvolution_smoke, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 6, 5, 6)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 1), MAKE_STRUCT(param_size, 3, 3)) @@ -17,7 +17,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_deconv_to_conv, myriadLayerDeconvolution_smoke, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_deconv_to_conv_2, myriadLayerDeconvolution_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_deconv_to_conv_2, myriadLayerDeconvolution_smoke, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 2, 256, 14, 14)) , ::testing::Values(MAKE_STRUCT(param_size, 2, 2), MAKE_STRUCT(param_size, 3, 3)) @@ -30,7 +30,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_deconv_to_conv_2, myriadLayerDeconvolution_smok ) ); -INSTANTIATE_TEST_CASE_P(accuracy_group, myriadLayerDeconvolution_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_group, myriadLayerDeconvolution_smoke, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 384, 4, 2)) , ::testing::Values(MAKE_STRUCT(param_size, 2, 2) @@ -47,7 +47,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_group, myriadLayerDeconvolution_smoke, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_depthDeconv, myriadLayerDeconvolution_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_depthDeconv, myriadLayerDeconvolution_smoke, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 384, 4, 2)) , ::testing::Values(MAKE_STRUCT(param_size, 2, 2) @@ -65,7 +65,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_depthDeconv, myriadLayerDeconvolution_smoke, ) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayerDeconvolution_asymm_pad, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayerDeconvolution_asymm_pad, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 128, 60, 80), MAKE_STRUCT(tensor_test_params, 1, 2, 37, 59)) @@ -84,7 +84,7 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadLayerDeconvolution_asymm_pad, ) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayerDeconvolution_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayerDeconvolution_smoke, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 2, 37, 59) , MAKE_STRUCT(tensor_test_params, 1, 21, 16, 16) @@ -109,7 +109,7 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadLayerDeconvolution_smoke, ) ); -INSTANTIATE_TEST_CASE_P(extra3x3s1, myriadLayerDeconvolution_smoke, +INSTANTIATE_TEST_SUITE_P(extra3x3s1, myriadLayerDeconvolution_smoke, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 256, 1, 1)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_eltwise_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_eltwise_test.cpp index 9b307b8d91e438..8945b73fdd4fb2 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_eltwise_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_eltwise_test.cpp @@ -4,168 +4,168 @@ #include "myriad_layers_eltwise_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwiseMax_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwiseMax_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseInputs), ::testing::ValuesIn(s_eltwiseDims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwiseSum_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwiseSum_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseInputs), ::testing::ValuesIn(s_eltwiseDims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwiseSub_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwiseSub_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseOnlyTwoInputs), ::testing::ValuesIn(s_eltwiseDims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwiseMul_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwiseMul_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseInputs), ::testing::ValuesIn(s_eltwiseDims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwiseSumWithCoeff_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwiseSumWithCoeff_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseInputs), ::testing::ValuesIn(s_eltwiseDims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwiseSumWithBroadcast_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwiseSumWithBroadcast_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseInputs), ::testing::Values(4)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwiseSubWithCoeff_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwiseSubWithCoeff_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseOnlyTwoInputs), ::testing::ValuesIn(s_eltwiseDims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwiseSubWithBroadcast_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwiseSubWithBroadcast_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseOnlyTwoInputs), ::testing::Values(4)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwiseDiv_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwiseDiv_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseOnlyTwoInputs), ::testing::ValuesIn(s_eltwiseDims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwiseMin_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwiseMin_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseInputs), ::testing::ValuesIn(s_eltwiseDims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwiseSqDiff_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwiseSqDiff_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseOnlyTwoInputs), ::testing::ValuesIn(s_eltwiseDims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwisePow_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwisePow_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseOnlyTwoInputs), ::testing::ValuesIn(s_eltwiseDims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwiseFloorMod_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwiseFloorMod_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseOnlyTwoInputs), ::testing::ValuesIn(s_eltwiseDims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwiseEqual_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwiseEqual_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseOnlyTwoInputs), ::testing::ValuesIn(s_eltwiseDims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwiseNotEqual_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwiseNotEqual_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseOnlyTwoInputs), ::testing::ValuesIn(s_eltwiseDims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwiseGreater_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwiseGreater_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseOnlyTwoInputs), ::testing::ValuesIn(s_eltwiseDims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwiseGreaterEqual_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwiseGreaterEqual_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseOnlyTwoInputs), ::testing::ValuesIn(s_eltwiseDims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwiseLess_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwiseLess_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseOnlyTwoInputs), ::testing::ValuesIn(s_eltwiseDims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwiseLessEqual_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwiseLessEqual_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseOnlyTwoInputs), ::testing::ValuesIn(s_eltwiseDims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwiseLogicalNot_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwiseLogicalNot_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseOnlyOneInput), ::testing::ValuesIn(s_eltwiseDims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwiseLogicalAnd_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwiseLogicalAnd_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseInputs), ::testing::ValuesIn(s_eltwiseDims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwiseLogicalOr_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwiseLogicalOr_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseInputs), ::testing::ValuesIn(s_eltwiseDims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwiseLogicalXor_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwiseLogicalXor_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseInputs), ::testing::ValuesIn(s_eltwiseDims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsEltwiseMean_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsEltwiseMean_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseOnlyTwoInputs), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_elu_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_elu_test.cpp index 16d211a1467917..5e99e6795b445e 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_elu_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_elu_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_elu_test.hpp" -INSTANTIATE_TEST_CASE_P( accuracy, myriadLayersTestsELUParams_smoke, +INSTANTIATE_TEST_SUITE_P( accuracy, myriadLayersTestsELUParams_smoke, ::testing::Combine( ::testing::ValuesIn(s_powerTensors), ::testing::ValuesIn(s_powerParams)) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_erf_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_erf_test.cpp index 609d76fa4c227f..4730fa0a2e9fd1 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_erf_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_erf_test.cpp @@ -4,6 +4,6 @@ #include "myriad_layers_erf_test.hpp" -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy, myriadLayersTestsErf_smoke, ::testing::ValuesIn(s_ErfDims)); diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_exp_detectionoutput_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_exp_detectionoutput_test.cpp index 23f6b46deaca60..2ac5cb77e043a5 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_exp_detectionoutput_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_exp_detectionoutput_test.cpp @@ -18,7 +18,7 @@ static const std::vector s_layerParams_list = {{ 10.0, 10.0, 5.0, 5.0 }, 4.135166645050049, 0.5, 0.05, _MaxDetections, _NumClasses, 2000, 0 }, }; -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsExpDetectionOutput_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsExpDetectionOutput_smoke, ::testing::Combine( ::testing::ValuesIn(s_sizeParams_list), ::testing::ValuesIn(s_layerParams_list)) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_exp_generateproposals.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_exp_generateproposals.cpp index 63175d7ce9d843..027198d3f01be0 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_exp_generateproposals.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_exp_generateproposals.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_exp_generateproposals_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsExpGenerateProposals_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsExpGenerateProposals_smoke, ::testing::Combine( ::testing::ValuesIn(s_ExpGenerateProposalsLayerScores), ::testing::ValuesIn(s_ExpGenerateProposalsLayerImInfo), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_exp_priorgridgenerator_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_exp_priorgridgenerator_test.cpp index 1036a4bdf7da45..3c63109a214141 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_exp_priorgridgenerator_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_exp_priorgridgenerator_test.cpp @@ -4,19 +4,19 @@ #include "myriad_layers_exp_priorgridgenerator_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsExpPriorGridGeneratorAllInputs_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsExpPriorGridGeneratorAllInputs_smoke, ::testing::Combine( ::testing::ValuesIn(s_ExpPriorGridGeneratorLayerInputs), ::testing::ValuesIn(s_ExpPriorGridGeneratorLayerParam)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsExpPriorGridGeneratorNoFeatureMap_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsExpPriorGridGeneratorNoFeatureMap_smoke, ::testing::Combine( ::testing::ValuesIn(s_ExpPriorGridGenLayerNoFMInputs), ::testing::ValuesIn(s_ExpPriorGridGenLayerNoFMParam)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsExpPriorGridGeneratorNoInputImage_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsExpPriorGridGeneratorNoInputImage_smoke, ::testing::Combine( ::testing::ValuesIn(s_ExpPriorGridGenLayerNoInputImage), ::testing::ValuesIn(s_ExpPriorGridGenLayerNoInputImageParam)) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_exp_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_exp_test.cpp index b78906e928d640..def1e2174980fa 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_exp_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_exp_test.cpp @@ -4,6 +4,6 @@ #include "myriad_layers_exp_test.hpp" -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy, myriadLayersTestsExp_smoke, ::testing::ValuesIn(s_expParams)); diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_exp_topkrois_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_exp_topkrois_test.cpp index ff0094c4f20462..8ed4022ba138dd 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_exp_topkrois_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_exp_topkrois_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_exp_topkrois_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsExpTopKROIs_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsExpTopKROIs_smoke, ::testing::Combine( ::testing::ValuesIn(s_ExpTopKROIsInputRoisNum), ::testing::ValuesIn(s_ExpTopKROIsMaxRoisNum)) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_flatten_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_flatten_test.cpp index 98978ecfd11650..260f01d1b8f155 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_flatten_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_flatten_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_flatten_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsFlatten_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsFlatten_smoke, ::testing::Combine( ::testing::ValuesIn(s_flattenTensors), ::testing::ValuesIn(s_flattenAxis) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_floor_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_floor_test.cpp index cdd5dc7422ac10..046608b0d5e039 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_floor_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_floor_test.cpp @@ -4,6 +4,6 @@ #include "myriad_layers_floor_test.hpp" -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy, myriadLayersTestsFloor_smoke, ::testing::ValuesIn(s_FloorParams)); diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_fully_connected_tests.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_fully_connected_tests.cpp index 8ec8ad6378ce77..7e65bc26ec03f3 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_fully_connected_tests.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_fully_connected_tests.cpp @@ -3,19 +3,19 @@ // #include "myriad_layers_fully_connected_tests.hpp" -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy, myriadLayersTestsFullyConnected_smoke, ::testing::ValuesIn(s_fcTestParams) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsFullyConnectedBatch_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsFullyConnectedBatch_smoke, ::testing::Combine( ::testing::ValuesIn(s_fcTestBatchParams) , ::testing::ValuesIn(s_fcTestBatchOutSizes) ) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsFullyConnectedPVA_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsFullyConnectedPVA_smoke, ::testing::Combine( ::testing::ValuesIn(s_fcTestPVAParams) , ::testing::ValuesIn(s_fcTestPVAOutSizes) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_gemm_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_gemm_test.cpp index 7cb12c87748490..bd4c7483665e78 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_gemm_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_gemm_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_gemm_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayerGEMM_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayerGEMM_smoke, ::testing::Combine( ::testing::Values( MAKE_STRUCT(gemm_parameters, 4.7f, 2.3f, 5, 7, 11, 1, 2, 3, 4, 5, 6, 7, 8), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_grn_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_grn_test.cpp index 5cccc5f5be32d4..d8e94ac8dc899b 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_grn_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_grn_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_grn_test.hpp" -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy, myriadLayersTestsGRN_smoke, ::testing::Combine( ::testing::ValuesIn(s_GRNInputs), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_interp_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_interp_test.cpp index bfedb4600671d1..3fff0275d7bab7 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_interp_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_interp_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_interp_test.hpp" -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy, myriadLayersTestsInterp_smoke, ::testing::Combine( diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_log_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_log_test.cpp index 490a762997e805..0e709247015aab 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_log_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_log_test.cpp @@ -4,6 +4,6 @@ #include "myriad_layers_log_test.hpp" -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy, myriadLayersTestsLog_smoke, ::testing::ValuesIn(s_logParams)); diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_lrn_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_lrn_test.cpp index a7b3172ff43149..e3a0a66af6624a 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_lrn_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_lrn_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_lrn_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsLRN_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsLRN_smoke, ::testing::Combine( ::testing::ValuesIn(s_LRNTensors), ::testing::ValuesIn(s_LRNlocal_size), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_lstm_cell.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_lstm_cell.cpp index 819de8087dbbc6..1b7ad35d89261a 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_lstm_cell.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_lstm_cell.cpp @@ -162,6 +162,6 @@ TEST_F(myriadLayersTests_nightly, LSTMCellSequenceNet) { CompareCommonAbsolute(output, refOut0, ERROR_BOUND); } -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsLSTMCell_smoke, - ::testing::Values(MAKE_STRUCT(lstmcell_test_params, 512, 128)), +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsLSTMCell_smoke, + ::testing::Values(MAKE_STRUCT(lstmcell_test_params, 512, 128)) ); diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_mvn_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_mvn_test.cpp index 702c3688e560dc..16bf3cdc6655d2 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_mvn_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_mvn_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_mvn_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsMVN_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsMVN_smoke, ::testing::Combine( ::testing::ValuesIn(s_MVNTensors), ::testing::ValuesIn(s_MVN_acrossChannels), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_nonzero_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_nonzero_test.cpp index 0075457ce6a4db..7a330009890329 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_nonzero_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_nonzero_test.cpp @@ -4,5 +4,5 @@ #include "myriad_layers_nonzero_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayerTestNonZero_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayerTestNonZero_smoke, ::testing::ValuesIn(inputDims)); diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_normalize_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_normalize_test.cpp index 34b9e4600cd86b..37f5948e5c0cdf 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_normalize_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_normalize_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_normalize_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsNormalize_smoke, ::testing::Combine( +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsNormalize_smoke, ::testing::Combine( ::testing::Values( // small size, num_channels is not divisible by 8 MAKE_STRUCT(tensor_test_params, 1, 33, 1, 1), @@ -21,7 +21,7 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsNormalize_smoke, ::testing::C )); -INSTANTIATE_TEST_CASE_P(accuracy_more, myriadLayersTestsNormalize_smoke, ::testing::Combine( +INSTANTIATE_TEST_SUITE_P(accuracy_more, myriadLayersTestsNormalize_smoke, ::testing::Combine( ::testing::Values( //more tests MAKE_STRUCT(tensor_test_params, 1, 1, 38, 38), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_oneHot_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_oneHot_test.cpp index 7233519144730b..b3041a99167667 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_oneHot_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_oneHot_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_oneHot_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayerTestOneHot_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayerTestOneHot_smoke, ::testing::Values( MAKE_STRUCT(OneHotParams, {64}, 2, {0}, {}, {}), MAKE_STRUCT(OneHotParams, {64}, 2, {-1}, {}, {}), @@ -22,7 +22,7 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadLayerTestOneHot_smoke, MAKE_STRUCT(OneHotParams, {4, 8, 16, 32, 64}, 2, {-1}, {}, {}) )); -INSTANTIATE_TEST_CASE_P(accuracy_add, myriadLayerTestOneHot_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_add, myriadLayerTestOneHot_smoke, ::testing::Values( MAKE_STRUCT(OneHotParams, {16, 32, 64}, 2, {2}, {}, {}), MAKE_STRUCT(OneHotParams, {8, 16, 32,64}, 2, {2}, {}, {}), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_pad_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_pad_test.cpp index e45d93d121fb15..c68044dad2afd8 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_pad_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_pad_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_pad_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayerPad_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayerPad_smoke, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 64, 16, 16)), ::testing::Values(MAKE_STRUCT(pad_parameters, 0, 32, 1, 2, 0, 32, 3, 4)), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_permute_nd_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_permute_nd_test.cpp index 463163e8c561fb..96c50476c84b14 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_permute_nd_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_permute_nd_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_permute_nd_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy_2D, myriadLayersPermuteNDTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_2D, myriadLayersPermuteNDTests_smoke, ::testing::Combine( ::testing::ValuesIn(s_inTensors_2D) , ::testing::ValuesIn(s_permuteTensors_2D) @@ -12,7 +12,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_2D, myriadLayersPermuteNDTests_smoke, , ::testing::ValuesIn(s_permutePrecisions) )); -INSTANTIATE_TEST_CASE_P(accuracy_3D, myriadLayersPermuteNDTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_3D, myriadLayersPermuteNDTests_smoke, ::testing::Combine( ::testing::ValuesIn(s_inTensors_3D) , ::testing::ValuesIn(s_permuteTensors_3D) @@ -20,7 +20,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_3D, myriadLayersPermuteNDTests_smoke, , ::testing::ValuesIn(s_permutePrecisions) )); -INSTANTIATE_TEST_CASE_P(accuracy_4D, myriadLayersPermuteNDTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_4D, myriadLayersPermuteNDTests_smoke, ::testing::Combine( ::testing::ValuesIn(s_inTensors_4D) , ::testing::ValuesIn(s_permuteTensors_4D) @@ -28,7 +28,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_4D, myriadLayersPermuteNDTests_smoke, , ::testing::ValuesIn(s_permutePrecisions) )); -INSTANTIATE_TEST_CASE_P(accuracy_5D, myriadLayersPermuteNDTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_5D, myriadLayersPermuteNDTests_smoke, ::testing::Combine( ::testing::ValuesIn(s_inTensors_5D) , ::testing::ValuesIn(s_permuteTensors_5D) @@ -36,7 +36,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_5D, myriadLayersPermuteNDTests_smoke, , ::testing::ValuesIn(s_permutePrecisions) )); -INSTANTIATE_TEST_CASE_P(fc_to_conv_case, myriadLayersPermuteNDTests_smoke, +INSTANTIATE_TEST_SUITE_P(fc_to_conv_case, myriadLayersPermuteNDTests_smoke, ::testing::Values( std::make_tuple( SizeVector{8, 50, 256, 7, 7}, @@ -53,7 +53,7 @@ INSTANTIATE_TEST_CASE_P(fc_to_conv_case, myriadLayersPermuteNDTests_smoke, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_FasterRCNN, myriadLayersPermuteNDTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_FasterRCNN, myriadLayersPermuteNDTests_smoke, ::testing::Combine( ::testing::Values({1, 24, 14, 14}) ,::testing::Values({0, 2, 3, 1}) @@ -61,7 +61,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_FasterRCNN, myriadLayersPermuteNDTests_smoke, ,::testing::ValuesIn(s_permutePrecisions) )); -INSTANTIATE_TEST_CASE_P(accuracy_MaskRCNN, myriadLayersPermuteNDTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_MaskRCNN, myriadLayersPermuteNDTests_smoke, ::testing::Combine( ::testing::Values({4, 3, 1, 88, 120}) ,::testing::Values({0, 3, 4, 1, 2}) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_permute_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_permute_test.cpp index a8738e300b51c6..0ccef5858f03e4 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_permute_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_permute_test.cpp @@ -4,13 +4,13 @@ #include "myriad_layers_permute_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersPermuteTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersPermuteTests_smoke, ::testing::Combine( ::testing::ValuesIn(s_inTensors) , ::testing::ValuesIn(s_permuteTensors) )); -INSTANTIATE_TEST_CASE_P(accuracyFasterRCNN, myriadLayersPermuteTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracyFasterRCNN, myriadLayersPermuteTests_smoke, ::testing::Combine( ::testing::Values({1, 24, 14, 14}) ,::testing::Values({0, 2, 3, 1}) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_pool_nd_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_pool_nd_test.cpp index b6b791c108a08d..094ef5c4994df4 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_pool_nd_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_pool_nd_test.cpp @@ -12,7 +12,7 @@ using namespace testing; // //====================================================================== -INSTANTIATE_TEST_CASE_P(tricky_ncdhw_avg_userpad, +INSTANTIATE_TEST_SUITE_P(tricky_ncdhw_avg_userpad, myriadLayersPoolNDTest_smoke, Combine( Values(InputShape {1, 3, 19, 65, 47}), @@ -28,7 +28,7 @@ INSTANTIATE_TEST_CASE_P(tricky_ncdhw_avg_userpad, ) ); -INSTANTIATE_TEST_CASE_P(tricky_ncdhw_max_userpad, +INSTANTIATE_TEST_SUITE_P(tricky_ncdhw_max_userpad, myriadLayersPoolNDTest_smoke, Combine( Values(InputShape {1, 3, 19, 65, 47}), @@ -43,7 +43,7 @@ INSTANTIATE_TEST_CASE_P(tricky_ncdhw_max_userpad, ) ); -INSTANTIATE_TEST_CASE_P(tricky_ncdhw_avg_autopad, +INSTANTIATE_TEST_SUITE_P(tricky_ncdhw_avg_autopad, myriadLayersPoolNDTest_smoke, Combine( Values(InputShape {1, 3, 19, 65, 47}), @@ -61,7 +61,7 @@ INSTANTIATE_TEST_CASE_P(tricky_ncdhw_avg_autopad, ) ); -INSTANTIATE_TEST_CASE_P(tricky_ncdhw_max_autopad, +INSTANTIATE_TEST_SUITE_P(tricky_ncdhw_max_autopad, myriadLayersPoolNDTest_smoke, Combine( Values(InputShape {1, 3, 19, 65, 47}), @@ -84,7 +84,7 @@ INSTANTIATE_TEST_CASE_P(tricky_ncdhw_max_autopad, // //====================================================================== -INSTANTIATE_TEST_CASE_P(simple_ncdhw_avg_userpad, +INSTANTIATE_TEST_SUITE_P(simple_ncdhw_avg_userpad, myriadLayersPoolNDTest_smoke, Combine( Values(InputShape {1, 3, 20, 64, 48}), @@ -100,7 +100,7 @@ INSTANTIATE_TEST_CASE_P(simple_ncdhw_avg_userpad, ) ); -INSTANTIATE_TEST_CASE_P(simple_ncdhw_max_userpad, +INSTANTIATE_TEST_SUITE_P(simple_ncdhw_max_userpad, myriadLayersPoolNDTest_smoke, Combine( Values(InputShape {1, 3, 20, 64, 48}), @@ -124,7 +124,7 @@ INSTANTIATE_TEST_CASE_P(simple_ncdhw_max_userpad, // Issue-15146 HW AvgPool doesn't support excludePad parameter //---------------------------------------------------------------------- -INSTANTIATE_TEST_CASE_P(simple_ncdhw_avg_autopad_1, +INSTANTIATE_TEST_SUITE_P(simple_ncdhw_avg_autopad_1, myriadLayersPoolNDTest_smoke, Combine( Values(InputShape {1, 3, 20, 64, 48}), @@ -141,7 +141,7 @@ INSTANTIATE_TEST_CASE_P(simple_ncdhw_avg_autopad_1, ) ); -INSTANTIATE_TEST_CASE_P(simple_ncdhw_avg_autopad_2, +INSTANTIATE_TEST_SUITE_P(simple_ncdhw_avg_autopad_2, myriadLayersPoolNDTest_smoke, Combine( Values(InputShape {1, 3, 20, 64, 48}), @@ -158,7 +158,7 @@ INSTANTIATE_TEST_CASE_P(simple_ncdhw_avg_autopad_2, //---------------------------------------------------------------------- -INSTANTIATE_TEST_CASE_P(simple_ncdhw_max_autopad, +INSTANTIATE_TEST_SUITE_P(simple_ncdhw_max_autopad, myriadLayersPoolNDTest_smoke, Combine( Values(InputShape {1, 3, 20, 64, 48}), @@ -181,7 +181,7 @@ INSTANTIATE_TEST_CASE_P(simple_ncdhw_max_autopad, // //====================================================================== -INSTANTIATE_TEST_CASE_P(tricky_nchw_avg_userpad, +INSTANTIATE_TEST_SUITE_P(tricky_nchw_avg_userpad, myriadLayersPoolNDTest_smoke, Combine( Values(InputShape {1, 3, 65, 47}), @@ -197,7 +197,7 @@ INSTANTIATE_TEST_CASE_P(tricky_nchw_avg_userpad, ) ); -INSTANTIATE_TEST_CASE_P(tricky_nchw_max_userpad, +INSTANTIATE_TEST_SUITE_P(tricky_nchw_max_userpad, myriadLayersPoolNDTest_smoke, Combine( Values(InputShape {1, 3, 65, 47}), @@ -212,7 +212,7 @@ INSTANTIATE_TEST_CASE_P(tricky_nchw_max_userpad, ) ); -INSTANTIATE_TEST_CASE_P(tricky_nchw_avg_autopad, +INSTANTIATE_TEST_SUITE_P(tricky_nchw_avg_autopad, myriadLayersPoolNDTest_smoke, Combine( Values(InputShape {1, 3, 65, 47}), @@ -230,7 +230,7 @@ INSTANTIATE_TEST_CASE_P(tricky_nchw_avg_autopad, ) ); -INSTANTIATE_TEST_CASE_P(tricky_nchw_max_autopad, +INSTANTIATE_TEST_SUITE_P(tricky_nchw_max_autopad, myriadLayersPoolNDTest_smoke, Combine( Values(InputShape {1, 3, 65, 47}), @@ -253,7 +253,7 @@ INSTANTIATE_TEST_CASE_P(tricky_nchw_max_autopad, // //====================================================================== -INSTANTIATE_TEST_CASE_P(simple_nchw_avg_userpad, +INSTANTIATE_TEST_SUITE_P(simple_nchw_avg_userpad, myriadLayersPoolNDTest_smoke, Combine( Values(InputShape {1, 3, 64, 48}), @@ -269,7 +269,7 @@ INSTANTIATE_TEST_CASE_P(simple_nchw_avg_userpad, ) ); -INSTANTIATE_TEST_CASE_P(simple_nchw_max_userpad, +INSTANTIATE_TEST_SUITE_P(simple_nchw_max_userpad, myriadLayersPoolNDTest_smoke, Combine( Values(InputShape {1, 3, 64, 48}), @@ -293,7 +293,7 @@ INSTANTIATE_TEST_CASE_P(simple_nchw_max_userpad, // Issue-15146 HW AvgPool doesn't support excludePad parameter //---------------------------------------------------------------------- -INSTANTIATE_TEST_CASE_P(simple_nchw_avg_autopad_1, +INSTANTIATE_TEST_SUITE_P(simple_nchw_avg_autopad_1, myriadLayersPoolNDTest_smoke, Combine( Values(InputShape {1, 3, 64, 48}), @@ -310,7 +310,7 @@ INSTANTIATE_TEST_CASE_P(simple_nchw_avg_autopad_1, ) ); -INSTANTIATE_TEST_CASE_P(simple_nchw_avg_autopad_2, +INSTANTIATE_TEST_SUITE_P(simple_nchw_avg_autopad_2, myriadLayersPoolNDTest_smoke, Combine( Values(InputShape {1, 3, 64, 48}), @@ -327,7 +327,7 @@ INSTANTIATE_TEST_CASE_P(simple_nchw_avg_autopad_2, //---------------------------------------------------------------------- -INSTANTIATE_TEST_CASE_P(simple_nchw_max_autopad, +INSTANTIATE_TEST_SUITE_P(simple_nchw_max_autopad, myriadLayersPoolNDTest_smoke, Combine( Values(InputShape {1, 3, 64, 48}), @@ -350,7 +350,7 @@ INSTANTIATE_TEST_CASE_P(simple_nchw_max_autopad, // //====================================================================== -INSTANTIATE_TEST_CASE_P(i3d_id10, +INSTANTIATE_TEST_SUITE_P(i3d_id10, myriadLayersPoolNDTest_smoke, Combine( Values(InputShape {1, 64, 40, 112, 112}), @@ -363,7 +363,7 @@ INSTANTIATE_TEST_CASE_P(i3d_id10, Values(RoundingType("")), Values(ExcludePad(true)))); -INSTANTIATE_TEST_CASE_P(i3d_id47, +INSTANTIATE_TEST_SUITE_P(i3d_id47, myriadLayersPoolNDTest_smoke, Combine( Values(InputShape {1, 192, 40, 28, 28}), @@ -376,7 +376,7 @@ INSTANTIATE_TEST_CASE_P(i3d_id47, Values(RoundingType("")), Values(ExcludePad(true)))); -INSTANTIATE_TEST_CASE_P(i3d_id247, +INSTANTIATE_TEST_SUITE_P(i3d_id247, myriadLayersPoolNDTest_smoke, Combine( Values(InputShape {1, 832, 20, 14, 14}), @@ -389,7 +389,7 @@ INSTANTIATE_TEST_CASE_P(i3d_id247, Values(RoundingType("")), Values(ExcludePad(true)))); -INSTANTIATE_TEST_CASE_P(i3d_id312, +INSTANTIATE_TEST_SUITE_P(i3d_id312, myriadLayersPoolNDTest_smoke, Combine( Values(InputShape {1, 1024, 10, 7, 7}), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_pooling_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_pooling_test.cpp index 1fda0995a0b357..5bd7ddd3df49dc 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_pooling_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_pooling_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_pooling_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayers_IR3_BatchPoolingTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayers_IR3_BatchPoolingTests_smoke, ::testing::Combine( ::testing::Values({10, 192, 56, 56}) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) /* kernel */ @@ -17,7 +17,7 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadLayers_IR3_BatchPoolingTests_smoke, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_1, myriadLayers_IR3_BatchPoolingTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_1, myriadLayers_IR3_BatchPoolingTests_smoke, ::testing::Combine( ::testing::Values({10, 576, 14, 14}) , ::testing::Values(MAKE_STRUCT(param_size, 2, 2)) /* kernel */ @@ -31,7 +31,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_1, myriadLayers_IR3_BatchPoolingTests_smoke, ); -INSTANTIATE_TEST_CASE_P(accuracy_4X4, myriadLayers_IR3_PoolingTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_4X4, myriadLayers_IR3_PoolingTests_smoke, ::testing::Combine( ::testing::Values({10, 1024, 4, 4}) , ::testing::Values(MAKE_STRUCT(param_size, 4, 4)) /* kernel */ @@ -44,7 +44,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_4X4, myriadLayers_IR3_PoolingTests_smoke, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_1X1, myriadLayers_IR3_BatchPoolingTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_1X1, myriadLayers_IR3_BatchPoolingTests_smoke, ::testing::Combine( ::testing::Values({1, 3, 5, 7}) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) /* kernel */ @@ -57,7 +57,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_1X1, myriadLayers_IR3_BatchPoolingTests_smoke, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_2X2p0000, myriadLayers_IR3_BatchPoolingTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_2X2p0000, myriadLayers_IR3_BatchPoolingTests_smoke, ::testing::Combine( ::testing::Values({1, 512, 26, 26}) , ::testing::Values(MAKE_STRUCT(param_size, 2, 2)) /* kernel */ @@ -70,7 +70,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_2X2p0000, myriadLayers_IR3_BatchPoolingTests_sm ) ); -INSTANTIATE_TEST_CASE_P(accuracy_2X2p0001, myriadLayers_IR3_BatchPoolingTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_2X2p0001, myriadLayers_IR3_BatchPoolingTests_smoke, ::testing::Combine( ::testing::Values({1, 512, 26, 26}) , ::testing::Values(MAKE_STRUCT(param_size, 2, 2)) /* kernel */ @@ -82,7 +82,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_2X2p0001, myriadLayers_IR3_BatchPoolingTests_sm , ::testing::ValuesIn(s_poolingMethod) ) ); -INSTANTIATE_TEST_CASE_P(accuracy_2X2p0011, myriadLayers_IR3_BatchPoolingTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_2X2p0011, myriadLayers_IR3_BatchPoolingTests_smoke, ::testing::Combine( ::testing::Values({1, 512, 26, 26}) , ::testing::Values(MAKE_STRUCT(param_size, 2, 2)) /* kernel */ @@ -94,7 +94,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_2X2p0011, myriadLayers_IR3_BatchPoolingTests_sm , ::testing::ValuesIn(s_poolingMethod) ) ); -INSTANTIATE_TEST_CASE_P(accuracy_2X2p0111, myriadLayers_IR3_BatchPoolingTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_2X2p0111, myriadLayers_IR3_BatchPoolingTests_smoke, ::testing::Combine( ::testing::Values({1, 512, 26, 26}) , ::testing::Values(MAKE_STRUCT(param_size, 2, 2)) /* kernel */ @@ -106,7 +106,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_2X2p0111, myriadLayers_IR3_BatchPoolingTests_sm , ::testing::ValuesIn(s_poolingMethod) ) ); -INSTANTIATE_TEST_CASE_P(accuracy_2X2p1111, myriadLayers_IR3_BatchPoolingTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_2X2p1111, myriadLayers_IR3_BatchPoolingTests_smoke, ::testing::Combine( ::testing::Values({1, 512, 26, 26}) , ::testing::Values(MAKE_STRUCT(param_size, 2, 2)) /* kernel */ @@ -118,7 +118,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_2X2p1111, myriadLayers_IR3_BatchPoolingTests_sm , ::testing::ValuesIn(s_poolingMethod) ) ); -INSTANTIATE_TEST_CASE_P(accuracy_2X2p1110, myriadLayers_IR3_BatchPoolingTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_2X2p1110, myriadLayers_IR3_BatchPoolingTests_smoke, ::testing::Combine( ::testing::Values({1, 512, 26, 26}) , ::testing::Values(MAKE_STRUCT(param_size, 2, 2)) /* kernel */ @@ -130,7 +130,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_2X2p1110, myriadLayers_IR3_BatchPoolingTests_sm , ::testing::ValuesIn(s_poolingMethod) ) ); -INSTANTIATE_TEST_CASE_P(accuracy_2X2p1100, myriadLayers_IR3_BatchPoolingTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_2X2p1100, myriadLayers_IR3_BatchPoolingTests_smoke, ::testing::Combine( ::testing::Values({1, 512, 26, 26}) , ::testing::Values(MAKE_STRUCT(param_size, 2, 2)) /* kernel */ @@ -142,7 +142,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_2X2p1100, myriadLayers_IR3_BatchPoolingTests_sm , ::testing::ValuesIn(s_poolingMethod) ) ); -INSTANTIATE_TEST_CASE_P(accuracy_2X2p1000, myriadLayers_IR3_BatchPoolingTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_2X2p1000, myriadLayers_IR3_BatchPoolingTests_smoke, ::testing::Combine( ::testing::Values({1, 512, 26, 26}) , ::testing::Values(MAKE_STRUCT(param_size, 2, 2)) /* kernel */ @@ -154,7 +154,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_2X2p1000, myriadLayers_IR3_BatchPoolingTests_sm , ::testing::ValuesIn(s_poolingMethod) ) ); -INSTANTIATE_TEST_CASE_P(accuracy_2X2p1101, myriadLayers_IR3_BatchPoolingTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_2X2p1101, myriadLayers_IR3_BatchPoolingTests_smoke, ::testing::Combine( ::testing::Values({1, 512, 26, 26}) , ::testing::Values(MAKE_STRUCT(param_size, 2, 2)) /* kernel */ @@ -166,7 +166,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_2X2p1101, myriadLayers_IR3_BatchPoolingTests_sm , ::testing::ValuesIn(s_poolingMethod) ) ); -INSTANTIATE_TEST_CASE_P(accuracy_2X2p1011, myriadLayers_IR3_BatchPoolingTests_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_2X2p1011, myriadLayers_IR3_BatchPoolingTests_smoke, ::testing::Combine( ::testing::Values({1, 512, 26, 26}) , ::testing::Values(MAKE_STRUCT(param_size, 2, 2)) /* kernel */ @@ -179,14 +179,14 @@ INSTANTIATE_TEST_CASE_P(accuracy_2X2p1011, myriadLayers_IR3_BatchPoolingTests_sm ) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsMax_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsMax_smoke, ::testing::Combine( ::testing::ValuesIn(g_poolingInput), ::testing::ValuesIn(g_poolingLayerParamsFull), ::testing::ValuesIn(g_poolingLayout)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsMaxOverlappedByKernel_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsMaxOverlappedByKernel_smoke, ::testing::Combine( ::testing::Values({1, 1024, 6, 6}), ::testing::Values(MAKE_STRUCT(param_size, 7, 7)), @@ -195,7 +195,7 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsMaxOverlappedByKernel_smoke, ::testing::ValuesIn(g_poolingLayout)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsMaxPad4_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsMaxPad4_smoke, ::testing::Combine( ::testing::ValuesIn(g_poolingInputPad4), ::testing::ValuesIn(g_poolingKernelPad4), @@ -204,7 +204,7 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsMaxPad4_smoke, ::testing::ValuesIn(g_poolingLayout)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsAvgPad4_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsAvgPad4_smoke, ::testing::Combine( ::testing::ValuesIn(g_poolingInputPad4), ::testing::ValuesIn(g_poolingKernelPad4), @@ -213,24 +213,24 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsAvgPad4_smoke, ::testing::ValuesIn(g_poolingLayout)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsGlobalMax_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsGlobalMax_smoke, ::testing::ValuesIn(g_GlobalPoolingInput )); -INSTANTIATE_TEST_CASE_P(accuracy_3x3, myriadLayersTestsMax_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_3x3, myriadLayersTestsMax_smoke, ::testing::Combine( ::testing::ValuesIn(g_poolingInput), ::testing::ValuesIn(s_poolingLayerParams_k3x3), ::testing::ValuesIn(g_poolingLayout)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsAvg_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsAvg_smoke, ::testing::Combine( ::testing::ValuesIn(g_poolingInput), ::testing::ValuesIn(g_poolingLayerParamsFull), ::testing::ValuesIn(g_poolingLayout)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsAvgOverlappedByKernel_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsAvgOverlappedByKernel_smoke, ::testing::Combine( ::testing::Values({1, 1024, 6, 6}), ::testing::Values(MAKE_STRUCT(param_size, 7, 7)), @@ -239,12 +239,12 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsAvgOverlappedByKernel_smoke, ::testing::ValuesIn(g_poolingLayout)) ); -INSTANTIATE_TEST_CASE_P(accuracy_3x3, myriadLayersTestsAvg_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_3x3, myriadLayersTestsAvg_smoke, ::testing::Combine( ::testing::ValuesIn(g_poolingInput), ::testing::ValuesIn(s_poolingLayerParams_k3x3), ::testing::ValuesIn(g_poolingLayout)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsGlobalAvg_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsGlobalAvg_smoke, ::testing::ValuesIn(g_GlobalPoolingInput)); diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_power_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_power_test.cpp index a8557aa10ed013..8585729e5292fd 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_power_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_power_test.cpp @@ -3,7 +3,7 @@ // #include "myriad_layers_power_test.hpp" -INSTANTIATE_TEST_CASE_P( accuracy, myriadLayersTestsPowerParams_smoke, +INSTANTIATE_TEST_SUITE_P( accuracy, myriadLayersTestsPowerParams_smoke, ::testing::Combine( ::testing::ValuesIn(s_powerTensors), ::testing::ValuesIn(s_powerParams)) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_prelu_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_prelu_test.cpp index 7a6f469a06acee..35f41cbe28c32f 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_prelu_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_prelu_test.cpp @@ -4,14 +4,14 @@ #include "myriad_layers_prelu_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy_PReLU, myriadLayerPReLU_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_PReLU, myriadLayerPReLU_smoke, ::testing::Combine( ::testing::ValuesIn(s_PReLUTensors) , ::testing::Values(0, 1) ) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy, myriadLayerFullyConnectedWithPReLU_smoke, ::testing::Combine( ::testing::ValuesIn(g_fcTestParamsSubset), @@ -21,7 +21,7 @@ INSTANTIATE_TEST_CASE_P( ) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsMaxPoolingWithPReLU_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsMaxPoolingWithPReLU_smoke, ::testing::Combine( ::testing::ValuesIn(g_poolingInput), ::testing::ValuesIn(g_poolingLayerParamsLite), @@ -29,7 +29,7 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsMaxPoolingWithPReLU_smoke, ::testing::ValuesIn(s_PReluLayerParams)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsAvgPoolingWithPReLU_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsAvgPoolingWithPReLU_smoke, ::testing::Combine( ::testing::ValuesIn(g_poolingInput), ::testing::ValuesIn(g_poolingLayerParamsLite), @@ -37,7 +37,7 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsAvgPoolingWithPReLU_smoke, ::testing::ValuesIn(s_PReluLayerParams)) ); -INSTANTIATE_TEST_CASE_P(accuracy_postop, myriadLayersTestsMaxPoolingWithPReLU_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_postop, myriadLayersTestsMaxPoolingWithPReLU_smoke, ::testing::Combine( ::testing::ValuesIn(g_poolingInput_postOp), ::testing::Values(MAKE_STRUCT(pooling_layer_params, {3, 3}, {1, 1}, {1, 1})), @@ -45,7 +45,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_postop, myriadLayersTestsMaxPoolingWithPReLU_sm ::testing::Values(MAKE_STRUCT(PReLULayerDef, {{{PRELU_PARAM, "0"}}}))) ); -INSTANTIATE_TEST_CASE_P(accuracy_postop, myriadLayersTestsAvgPoolingWithPReLU_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_postop, myriadLayersTestsAvgPoolingWithPReLU_smoke, ::testing::Combine( ::testing::ValuesIn(g_poolingInput_postOp), ::testing::Values(MAKE_STRUCT(pooling_layer_params, {3, 3}, {1, 1}, {1, 1})), @@ -53,7 +53,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_postop, myriadLayersTestsAvgPoolingWithPReLU_sm ::testing::Values(MAKE_STRUCT(PReLULayerDef, {{{PRELU_PARAM, "0"}}}))) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayerConvolutionWithPReLU_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayerConvolutionWithPReLU_smoke, ::testing::Combine( ::testing::ValuesIn(g_convolutionTensors) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -65,7 +65,7 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadLayerConvolutionWithPReLU_smoke, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_postop, myriadLayerConvolutionWithPReLU_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_postop, myriadLayerConvolutionWithPReLU_smoke, ::testing::Combine( ::testing::ValuesIn(g_poolingInput_postOp) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_psroipooling_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_psroipooling_test.cpp index 1955910aa7f78f..4a5196bef7e81b 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_psroipooling_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_psroipooling_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_psroipooling_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsPSROIPooling_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsPSROIPooling_smoke, ::testing::Combine( ::testing::ValuesIn(s_PSROIPoolingLayerInput), ::testing::ValuesIn(s_PSROIPoolingLayerParam), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_psroipooling_test.hpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_psroipooling_test.hpp index 9f25bb1df37fd7..0aadb311e02402 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_psroipooling_test.hpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_psroipooling_test.hpp @@ -192,7 +192,7 @@ static std::vector s_PSROIPoolingNumROIs = { TEST_P(myriadLayersTestsPSROIPooling_smoke, PSROIPooling) { #ifdef _WIN32 - SKIP() << "Disabled for Windows. Issue-13239"; + GTEST_SKIP() << "Disabled for Windows. Issue-13239"; #endif tensor_test_params dims_layer_in = std::get<0>(GetParam()); PSROIPoolingParams test_params = std::get<1>(GetParam()); diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_reduce_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_reduce_test.cpp index eeb62e51ca0e27..689233138776cf 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_reduce_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_reduce_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_reduce_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsReduceAnd_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsReduceAnd_smoke, ::testing::Combine( ::testing::ValuesIn(s_input_pair), ::testing::ValuesIn(s_axes_list), @@ -12,7 +12,7 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsReduceAnd_smoke, ::testing::ValuesIn(s_keep_dims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsReduceMin_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsReduceMin_smoke, ::testing::Combine( ::testing::ValuesIn(s_input_pair), ::testing::ValuesIn(s_axes_list), @@ -20,7 +20,7 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsReduceMin_smoke, ::testing::ValuesIn(s_keep_dims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsReduceMax_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsReduceMax_smoke, ::testing::Combine( ::testing::ValuesIn(s_input_pair), ::testing::ValuesIn(s_axes_list), @@ -28,7 +28,7 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsReduceMax_smoke, ::testing::ValuesIn(s_keep_dims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsReduceSum_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsReduceSum_smoke, ::testing::Combine( ::testing::ValuesIn(s_input_pair), ::testing::ValuesIn(s_axes_list), @@ -36,7 +36,7 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsReduceSum_smoke, ::testing::ValuesIn(s_keep_dims)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsReduceMean_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsReduceMean_smoke, ::testing::Combine( ::testing::ValuesIn(s_input_pair), ::testing::ValuesIn(s_axes_list), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_region_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_region_test.cpp index a5470c4ac956f1..80c2a4c1e11a76 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_region_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_region_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_region_test.hpp" -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy, myriadLayersTestsRegionYolo_smoke, ::testing::Combine( ::testing::Values(4), @@ -19,7 +19,7 @@ INSTANTIATE_TEST_CASE_P( #ifdef VPU_HAS_CUSTOM_KERNELS -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy_custom, myriadLayersTestsRegionYolo_smoke, ::testing::Combine( ::testing::Values(4), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_relu_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_relu_test.cpp index 84c9a828040b65..da43b0b7922efd 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_relu_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_relu_test.cpp @@ -4,14 +4,14 @@ #include "myriad_layers_relu_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayerReLU_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayerReLU_smoke, ::testing::Combine( ::testing::ValuesIn(s_copyTensors), ::testing::ValuesIn(s_reluLayerParams) ) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy, myriadLayerFullyConnectedWithReLU_smoke, ::testing::Combine( ::testing::ValuesIn(g_fcTestParamsSubset), @@ -21,7 +21,7 @@ INSTANTIATE_TEST_CASE_P( ) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsMaxPoolingWithReLU_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsMaxPoolingWithReLU_smoke, ::testing::Combine( ::testing::ValuesIn(g_poolingInput), ::testing::ValuesIn(g_poolingLayerParamsLite), @@ -29,7 +29,7 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsMaxPoolingWithReLU_smoke, ::testing::ValuesIn(s_reluLayerParams)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsAvgPoolingWithReLU_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsAvgPoolingWithReLU_smoke, ::testing::Combine( ::testing::ValuesIn(g_poolingInput), ::testing::ValuesIn(g_poolingLayerParamsLite), @@ -37,7 +37,7 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsAvgPoolingWithReLU_smoke, ::testing::ValuesIn(s_reluLayerParams)) ); -INSTANTIATE_TEST_CASE_P(accuracy_postop, myriadLayersTestsMaxPoolingWithReLU_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_postop, myriadLayersTestsMaxPoolingWithReLU_smoke, ::testing::Combine( ::testing::ValuesIn(g_poolingInput_postOp), ::testing::Values(MAKE_STRUCT(pooling_layer_params, {3, 3}, {1, 1}, {1, 1})), @@ -45,7 +45,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_postop, myriadLayersTestsMaxPoolingWithReLU_smo ::testing::Values(MAKE_STRUCT(ReLULayerDef, {{{"negative_slope", "0.0"}}}))) ); -INSTANTIATE_TEST_CASE_P(accuracy_postop, myriadLayersTestsAvgPoolingWithReLU_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_postop, myriadLayersTestsAvgPoolingWithReLU_smoke, ::testing::Combine( ::testing::ValuesIn(g_poolingInput_postOp), ::testing::Values(MAKE_STRUCT(pooling_layer_params, {3, 3}, {1, 1}, {1, 1})), @@ -53,7 +53,7 @@ INSTANTIATE_TEST_CASE_P(accuracy_postop, myriadLayersTestsAvgPoolingWithReLU_smo ::testing::Values(MAKE_STRUCT(ReLULayerDef, {{{"negative_slope", "0.0"}}}))) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayerConvolutionWithReLU_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayerConvolutionWithReLU_smoke, ::testing::Combine( ::testing::ValuesIn(g_convolutionTensors) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -65,7 +65,7 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadLayerConvolutionWithReLU_smoke, ) ); -INSTANTIATE_TEST_CASE_P(accuracy_postop, myriadLayerConvolutionWithReLU_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_postop, myriadLayerConvolutionWithReLU_smoke, ::testing::Combine( ::testing::ValuesIn(g_poolingInput_postOp) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_reorg_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_reorg_test.cpp index 6b5e88de88d17f..964170e4f21ba6 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_reorg_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_reorg_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_reorg_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsReorg_smoke, ::testing::Combine( +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsReorg_smoke, ::testing::Combine( ::testing::ValuesIn(s_ReorgInputs), ::testing::Values(2), ::testing::Values(vpu::LayoutPreference::ChannelMinor, vpu::LayoutPreference::ChannelMajor), @@ -14,7 +14,7 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsReorg_smoke, ::testing::Combi #ifdef VPU_HAS_CUSTOM_KERNELS -INSTANTIATE_TEST_CASE_P(accuracy_custom, myriadLayersTestsReorg_smoke, ::testing::Combine( +INSTANTIATE_TEST_SUITE_P(accuracy_custom, myriadLayersTestsReorg_smoke, ::testing::Combine( ::testing::ValuesIn(s_ReorgInputs_CustomLayer), ::testing::Values(2), ::testing::Values(vpu::LayoutPreference::ChannelMinor, vpu::LayoutPreference::ChannelMajor), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_resample_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_resample_test.cpp index c111327edd8614..f9f57089c10a8a 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_resample_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_resample_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_resample_test.hpp" -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy, myriadResampleLayerTests_smoke, ::testing::Combine( ::testing::ValuesIn(s_ResampleInput), @@ -16,7 +16,7 @@ INSTANTIATE_TEST_CASE_P( #ifdef VPU_HAS_CUSTOM_KERNELS -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy_custom, myriadResampleLayerTests_smoke, ::testing::Combine( ::testing::ValuesIn(s_ResampleInput), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_reshape_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_reshape_test.cpp index 721a9c6820155e..3dde909a85efa5 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_reshape_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_reshape_test.cpp @@ -264,13 +264,13 @@ TEST_F(myriadLayerReshapeFasterRCNN_smoke, Reshape) { ASSERT_TRUE(generateNetAndInfer(NetworkInitParams().useHWOpt( CheckMyriadX()))); } -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayerReshape_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayerReshape_smoke, ::testing::Combine( ::testing::ValuesIn(s_reshapeInParams), ::testing::ValuesIn(s_reshapeOutParams)) ); -INSTANTIATE_TEST_CASE_P(fc_to_conv_case, myriadLayerReshape_smoke, +INSTANTIATE_TEST_SUITE_P(fc_to_conv_case, myriadLayerReshape_smoke, ::testing::Values( std::make_tuple( SizeVector{400, 12544}, @@ -291,11 +291,11 @@ INSTANTIATE_TEST_CASE_P(fc_to_conv_case, myriadLayerReshape_smoke, ) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsReshapeBeforeFC_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsReshapeBeforeFC_smoke, ::testing::Values(CONFIG_VALUE(YES), CONFIG_VALUE(NO)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsReshapeFasterRCNN_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsReshapeFasterRCNN_smoke, ::testing::Combine( ::testing::ValuesIn(s_convTensor) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_reverse_sequence_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_reverse_sequence_test.cpp index 21938c5e595ba1..2685d602f842f8 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_reverse_sequence_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_reverse_sequence_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_reverse_sequence_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayerReverseSequence_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayerReverseSequence_smoke, ::testing::Combine( ::testing::Values( MAKE_STRUCT(reverse_sequence_test_params, {5, 6, 18}, 0, 0) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_roi_align_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_roi_align_test.cpp index 87c467e3dfc6bd..a19af42ecf3425 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_roi_align_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_roi_align_test.cpp @@ -4,18 +4,18 @@ #include "myriad_layers_roi_align_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsROIAlign_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsROIAlign_smoke, ::testing::Combine( ::testing::ValuesIn(s_ROIAlignLayerInput), ::testing::ValuesIn(s_ROIAlignLayerParam), ::testing::ValuesIn(s_ROIAlignNumROIs), - ::testing::ValuesIn(s_ROIAlignMode)), + ::testing::ValuesIn(s_ROIAlignMode)) ); -INSTANTIATE_TEST_CASE_P(accuracy_faster, myriadLayersTestsROIAlign_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy_faster, myriadLayersTestsROIAlign_smoke, ::testing::Combine( ::testing::ValuesIn(s_ROIAlignLayerInput_Faster), ::testing::ValuesIn(s_ROIAlignLayerParam_Faster), ::testing::ValuesIn(s_ROIAlignNumROIs_Faster), - ::testing::ValuesIn(s_ROIAlignMode_Faster)), + ::testing::ValuesIn(s_ROIAlignMode_Faster)) ); diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_roi_feature_extractor_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_roi_feature_extractor_test.cpp index e047f00ce0c47a..2c30e1b1bc4e47 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_roi_feature_extractor_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_roi_feature_extractor_test.cpp @@ -4,9 +4,9 @@ #include "myriad_layers_roi_feature_extractor_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsROIFeatureExtractor_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsROIFeatureExtractor_smoke, ::testing::Combine( ::testing::ValuesIn(s_ROIFeatureExtractorLayerInput), ::testing::ValuesIn(s_ROIFeatureExtractorLayerParam), - ::testing::ValuesIn(s_ROIFeatureExtractorNumROIs)), + ::testing::ValuesIn(s_ROIFeatureExtractorNumROIs)) ); diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_roi_pooling_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_roi_pooling_test.cpp index dc88686743cd4d..6e8bf111eae12e 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_roi_pooling_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_roi_pooling_test.cpp @@ -4,11 +4,11 @@ #include "myriad_layers_roi_pooling_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsROIPooling_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsROIPooling_smoke, ::testing::Combine( ::testing::ValuesIn(s_ROIPoolingLayerInput), ::testing::ValuesIn(s_ROIPoolingLayerParam), ::testing::ValuesIn(s_ROIPoolingNumRois), ::testing::ValuesIn(s_ROIPoolingMethod), - ::testing::Values(IRVersion::v7, IRVersion::v10)), + ::testing::Values(IRVersion::v7, IRVersion::v10)) ); diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_scale_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_scale_test.cpp index 0bee6c57c432ee..66a2df071366dc 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_scale_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_scale_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_scale_test.hpp" -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy, myriadLayersTestsScale_smoke, ::testing::Combine( ::testing::ValuesIn(s_inputScaleTensors), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_scatter_elements_update_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_scatter_elements_update_test.cpp index e344d9fac8a151..e156cc2559a876 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_scatter_elements_update_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_scatter_elements_update_test.cpp @@ -53,12 +53,12 @@ static const std::vector dataShapeList_useCases = { { 16, 512, 56, 56 }, }; -INSTANTIATE_TEST_CASE_P(nd_tensors, myriadLayersScatterElementsUpdateTest_smoke, +INSTANTIATE_TEST_SUITE_P(nd_tensors, myriadLayersScatterElementsUpdateTest_smoke, Combine( ValuesIn(dataShapeList_ndTensors), ValuesIn(dataTypeList))); -INSTANTIATE_TEST_CASE_P(use_cases, myriadLayersScatterElementsUpdateTest_smoke, +INSTANTIATE_TEST_SUITE_P(use_cases, myriadLayersScatterElementsUpdateTest_smoke, Combine( ValuesIn(dataShapeList_useCases), ValuesIn(dataTypeList))); diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_scatter_update_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_scatter_update_test.cpp index 4412c1d1cf6248..640598f5fb55ff 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_scatter_update_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_scatter_update_test.cpp @@ -12,7 +12,7 @@ using namespace testing; // //---------------------------------------------------------------------- -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( nd_tensors, myriadLayersScatterUpdateTest_smoke, Values( @@ -49,7 +49,7 @@ INSTANTIATE_TEST_CASE_P( // //---------------------------------------------------------------------- -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( use_cases, myriadLayersScatterUpdateTest_smoke, Values( diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_select_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_select_test.cpp index 76939b7c23e7b4..ef886903419dd0 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_select_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_select_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_select_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsSelect_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsSelect_smoke, ::testing::Combine( ::testing::ValuesIn(s_eltwiseTensors), ::testing::ValuesIn(s_eltwiseDims)) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_sigmoid_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_sigmoid_test.cpp index 4eca99fa2ff43f..091740c25c65af 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_sigmoid_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_sigmoid_test.cpp @@ -4,25 +4,25 @@ #include "myriad_layers_sigmoid_test.hpp" -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy, myriadLayersTestsSigmoid_smoke, ::testing::ValuesIn(s_sigmoidParams)); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsMaxPoolingWithSigmoid_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsMaxPoolingWithSigmoid_smoke, ::testing::Combine( ::testing::ValuesIn(g_poolingInput), ::testing::ValuesIn(g_poolingLayerParamsLite), ::testing::ValuesIn(g_poolingLayout)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsAvgPoolingWithSigmoid_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsAvgPoolingWithSigmoid_smoke, ::testing::Combine( ::testing::ValuesIn(g_poolingInput), ::testing::ValuesIn(g_poolingLayerParamsLite), ::testing::ValuesIn(g_poolingLayout)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayerConvolutionWithSigmoid_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayerConvolutionWithSigmoid_smoke, ::testing::Combine( ::testing::ValuesIn(g_convolutionTensors) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -34,7 +34,7 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadLayerConvolutionWithSigmoid_smoke, ) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy, myriadLayerFullyConnectedWithSigmoid_smoke, ::testing::Combine( ::testing::ValuesIn(g_fcTestParamsSubset), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_slice_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_slice_test.cpp index f710365f2e02c3..c99bef79a167c2 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_slice_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_slice_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_slice_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsSlice_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsSlice_smoke, ::testing::Values( MAKE_STRUCT(SliceParams, {4, 8, 16, 32, 64}, {{4, 8, 16, 10, 64}, {4, 8, 16, 22, 64}}, 3), MAKE_STRUCT(SliceParams, {4, 8, 16, 32}, {{4, 8, 2, 32}, {4, 8, 14, 32}}, 2)) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_softmax_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_softmax_test.cpp index 75cea33ed2b3b2..3d64c5c37a1168 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_softmax_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_softmax_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_softmax_test.hpp" -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy, myriadLayersTestsSoftMax_smoke, ::testing::Combine( ::testing::ValuesIn(s_softMaxTensors) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_split_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_split_test.cpp index cc28aa41976701..c75d3b375924b4 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_split_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_split_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_split_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsSplit_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsSplit_smoke, ::testing::Values( MAKE_STRUCT(SplitParams, {4, 8, 16, 32, 64}, 2, 6), MAKE_STRUCT(SplitParams, {4, 8, 16, 32}, 2, 6), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_squeeze_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_squeeze_test.cpp index be4f155363970d..170aab55518f39 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_squeeze_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_squeeze_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_squeeze_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsSqueezeTC1_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsSqueezeTC1_smoke, ::testing::Combine( ::testing::ValuesIn(s_squeezeTensorsTC1), ::testing::ValuesIn(s_squeezeIndicesTC1), @@ -13,7 +13,7 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsSqueezeTC1_smoke, ) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsSqueezeTC2_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsSqueezeTC2_smoke, ::testing::Combine( ::testing::ValuesIn(s_squeezeTensorsTC2), ::testing::ValuesIn(s_squeezeIndicesTC2), @@ -23,7 +23,7 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsSqueezeTC2_smoke, ); // TODO: rewrite to ngraph to have reshape functionality -INSTANTIATE_TEST_CASE_P(DISABLED_accuracy, myriadLayersTestsSqueezeTC3_smoke, +INSTANTIATE_TEST_SUITE_P(DISABLED_accuracy, myriadLayersTestsSqueezeTC3_smoke, ::testing::Combine( ::testing::ValuesIn(s_squeezeTensorsTC3), ::testing::ValuesIn(s_squeezeIndicesTC3), @@ -33,7 +33,7 @@ INSTANTIATE_TEST_CASE_P(DISABLED_accuracy, myriadLayersTestsSqueezeTC3_smoke, ); // TODO: rewrite to ngraph to have reshape functionality -INSTANTIATE_TEST_CASE_P(DISABLED_accuracy, myriadLayersTestsSqueezeTC4_smoke, +INSTANTIATE_TEST_SUITE_P(DISABLED_accuracy, myriadLayersTestsSqueezeTC4_smoke, ::testing::Combine( ::testing::ValuesIn(s_squeezeTensorsTC4), ::testing::ValuesIn(s_squeezeIndicesTC4), @@ -42,7 +42,7 @@ INSTANTIATE_TEST_CASE_P(DISABLED_accuracy, myriadLayersTestsSqueezeTC4_smoke, ) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsSqueezeTC5_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsSqueezeTC5_smoke, ::testing::Combine( ::testing::ValuesIn(s_squeezeTensorsTC5), ::testing::ValuesIn(s_squeezeIndicesTC5), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_strided_slice_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_strided_slice_test.cpp index b3936b10db02e8..8df50c44271b17 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_strided_slice_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_strided_slice_test.cpp @@ -4,6 +4,6 @@ #include "myriad_layers_strided_slice_test.h" -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy, myriadLayersTestsStridedSlice_smoke, ::testing::ValuesIn(s_stridedSliceParams)); diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_tanh_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_tanh_test.cpp index 60f816b0842c25..5a7b5be8a46298 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_tanh_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_tanh_test.cpp @@ -4,11 +4,11 @@ #include "myriad_layers_tanh_test.hpp" -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy, myriadLayersTestsTanh_smoke, ::testing::ValuesIn(s_tanhParams)); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayerConvolutionWithTanH_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayerConvolutionWithTanH_smoke, ::testing::Combine( ::testing::ValuesIn(g_convolutionTensors) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -20,21 +20,21 @@ INSTANTIATE_TEST_CASE_P(accuracy, myriadLayerConvolutionWithTanH_smoke, ) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsMaxPoolingWithTanh_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsMaxPoolingWithTanh_smoke, ::testing::Combine( ::testing::ValuesIn(g_poolingInput), ::testing::ValuesIn(g_poolingLayerParamsLite), ::testing::ValuesIn(g_poolingLayout)) ); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsAvgPoolingWithTanh_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsAvgPoolingWithTanh_smoke, ::testing::Combine( ::testing::ValuesIn(g_poolingInput), ::testing::ValuesIn(g_poolingLayerParamsLite), ::testing::ValuesIn(g_poolingLayout)) ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( accuracy, myriadLayerFullyConnectedWithTanH_smoke, ::testing::Combine( ::testing::ValuesIn(g_fcTestParamsSubset), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_tile_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_tile_test.cpp index ad6d40376a515e..7d68de1b77ba3d 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_tile_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_tile_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_tile_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracyAdd, myriadLayerTestTile_smoke, +INSTANTIATE_TEST_SUITE_P(accuracyAdd, myriadLayerTestTile_smoke, ::testing::Combine( ::testing::Values( MAKE_STRUCT(tile_test::nd_tensor_test_params, {4, 5, 6}, 0) @@ -21,7 +21,7 @@ INSTANTIATE_TEST_CASE_P(accuracyAdd, myriadLayerTestTile_smoke, , ::testing::Values(2, 3, 5) )); -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayerTestTile_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayerTestTile_smoke, ::testing::Combine( ::testing::Values( MAKE_STRUCT(tile_test::nd_tensor_test_params, {4, 5, 6}, 1) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_topk_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_topk_test.cpp index 23a36df4f58559..1cf3edc8642d1a 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_topk_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_topk_test.cpp @@ -32,7 +32,7 @@ static const std::vector s_sorts_list = // "none", // currently is not supported by firmware }; -INSTANTIATE_TEST_CASE_P(accuracy, myriadTestsTopK_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadTestsTopK_smoke, ::testing::Combine( ::testing::ValuesIn(s_geometries_list), ::testing::ValuesIn(s_modes_list), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_unsqueeze_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_unsqueeze_test.cpp index 070a99e64051fe..d5384668bf99bf 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_unsqueeze_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_unsqueeze_test.cpp @@ -4,7 +4,7 @@ #include "myriad_layers_unsqueeze_test.hpp" -INSTANTIATE_TEST_CASE_P(accuracy, myriadLayersTestsUnsqueeze_smoke, +INSTANTIATE_TEST_SUITE_P(accuracy, myriadLayersTestsUnsqueeze_smoke, ::testing::Combine( ::testing::ValuesIn(s_squeezeTensors), ::testing::ValuesIn(s_squeezeIndices) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/myriad_get_output_tests.cpp b/inference-engine/tests_deprecated/functional/vpu/common/myriad_get_output_tests.cpp index 4d45cc5a9a2795..41540403574d9e 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/myriad_get_output_tests.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/myriad_get_output_tests.cpp @@ -4,7 +4,7 @@ #include "myriad_get_output_tests.hpp" -INSTANTIATE_TEST_CASE_P(Test_params_pool, myriadGetOutput_nightly, +INSTANTIATE_TEST_SUITE_P(Test_params_pool, myriadGetOutput_nightly, testing::Values( std::make_tuple(std::make_tuple(&full_model, &poolModel), "pool1_3x3_s2"), std::make_tuple(std::make_tuple(&full_model, &convModel), "conv1_7x7_s2"), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/myriad_hw_conv_tests.hpp b/inference-engine/tests_deprecated/functional/vpu/common/myriad_hw_conv_tests.hpp index f911e8e3fe7cf7..a8fed6cea07012 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/myriad_hw_conv_tests.hpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/myriad_hw_conv_tests.hpp @@ -105,7 +105,7 @@ class MyriadX_HW_Convolution_Tests_nightly TEST_P(MyriadX_HW_Convolution_Tests_nightly, Single) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } AddInitialCopyLayer(); @@ -117,7 +117,7 @@ TEST_P(MyriadX_HW_Convolution_Tests_nightly, Single) { TEST_P(MyriadX_HW_Convolution_Tests_nightly, WithReLU) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } AddInitialCopyLayer(); @@ -130,7 +130,7 @@ TEST_P(MyriadX_HW_Convolution_Tests_nightly, WithReLU) { TEST_P(MyriadX_HW_Convolution_Tests_nightly, WithLeakyReLU) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } AddConvolutionLayer(); @@ -142,7 +142,7 @@ TEST_P(MyriadX_HW_Convolution_Tests_nightly, WithLeakyReLU) { TEST_P(MyriadX_HW_Convolution_Tests_nightly, WithClamp) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } AddConvolutionLayer(); @@ -154,7 +154,7 @@ TEST_P(MyriadX_HW_Convolution_Tests_nightly, WithClamp) { TEST_P(MyriadX_HW_Convolution_Tests_nightly, MultipleInfer) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } AddConvolutionLayer(); @@ -162,7 +162,7 @@ TEST_P(MyriadX_HW_Convolution_Tests_nightly, MultipleInfer) { CompareWithItself(100); } -INSTANTIATE_TEST_CASE_P(MaskRcnn101_DILATION, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(MaskRcnn101_DILATION, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 256, 50, 50), MAKE_STRUCT(tensor_test_params, 1, 256, 100, 171)) @@ -175,7 +175,7 @@ INSTANTIATE_TEST_CASE_P(MaskRcnn101_DILATION, MyriadX_HW_Convolution_Tests_night ) ); -INSTANTIATE_TEST_CASE_P(kernel_7x7_DILATION, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(kernel_7x7_DILATION, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 32, 90, 90)) , ::testing::Values(MAKE_STRUCT(param_size, 7, 7)) @@ -187,7 +187,7 @@ INSTANTIATE_TEST_CASE_P(kernel_7x7_DILATION, MyriadX_HW_Convolution_Tests_nightl ) ); -INSTANTIATE_TEST_CASE_P(Unequal_hw_pad_dilationfactor_DILATION, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(Unequal_hw_pad_dilationfactor_DILATION, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 32, 128, 128)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3), @@ -201,7 +201,7 @@ INSTANTIATE_TEST_CASE_P(Unequal_hw_pad_dilationfactor_DILATION, MyriadX_HW_Convo ) ); -INSTANTIATE_TEST_CASE_P(Strides_DILATION, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(Strides_DILATION, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 32, 64, 64)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -215,7 +215,7 @@ INSTANTIATE_TEST_CASE_P(Strides_DILATION, MyriadX_HW_Convolution_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(conv_1x1s1p0_extra1, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_1x1s1p0_extra1, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 64, 180, 320)) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) @@ -227,7 +227,7 @@ INSTANTIATE_TEST_CASE_P(conv_1x1s1p0_extra1, MyriadX_HW_Convolution_Tests_nightl ) ); -INSTANTIATE_TEST_CASE_P(conv_1x1s1p0_extra2, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_1x1s1p0_extra2, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 512, 45, 80)) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) @@ -239,7 +239,7 @@ INSTANTIATE_TEST_CASE_P(conv_1x1s1p0_extra2, MyriadX_HW_Convolution_Tests_nightl ) ); -INSTANTIATE_TEST_CASE_P(conv_1x1s1p0_extra3, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_1x1s1p0_extra3, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 256, 45, 80)) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) @@ -251,7 +251,7 @@ INSTANTIATE_TEST_CASE_P(conv_1x1s1p0_extra3, MyriadX_HW_Convolution_Tests_nightl ) ); -INSTANTIATE_TEST_CASE_P(conv_1x1s1p0_extra4, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_1x1s1p0_extra4, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 512, 45, 80)) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) @@ -263,7 +263,7 @@ INSTANTIATE_TEST_CASE_P(conv_1x1s1p0_extra4, MyriadX_HW_Convolution_Tests_nightl ) ); -INSTANTIATE_TEST_CASE_P(conv_1x1s2p0_extra1, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_1x1s2p0_extra1, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 64, 180, 320)) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) @@ -275,7 +275,7 @@ INSTANTIATE_TEST_CASE_P(conv_1x1s2p0_extra1, MyriadX_HW_Convolution_Tests_nightl ) ); -INSTANTIATE_TEST_CASE_P(conv_1x1s2p0_extra2, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_1x1s2p0_extra2, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 128, 90, 160)) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) @@ -287,7 +287,7 @@ INSTANTIATE_TEST_CASE_P(conv_1x1s2p0_extra2, MyriadX_HW_Convolution_Tests_nightl ) ); -INSTANTIATE_TEST_CASE_P(conv_1x1s2p0_extra3, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_1x1s2p0_extra3, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 128, 90, 160)) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) @@ -299,7 +299,7 @@ INSTANTIATE_TEST_CASE_P(conv_1x1s2p0_extra3, MyriadX_HW_Convolution_Tests_nightl ) ); -INSTANTIATE_TEST_CASE_P(conv_3x3s2p1_extra1, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_3x3s2p1_extra1, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 64, 180, 320)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -311,7 +311,7 @@ INSTANTIATE_TEST_CASE_P(conv_3x3s2p1_extra1, MyriadX_HW_Convolution_Tests_nightl ) ); -INSTANTIATE_TEST_CASE_P(conv_3x3s2p1_extra2, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_3x3s2p1_extra2, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 128, 90, 160)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -323,7 +323,7 @@ INSTANTIATE_TEST_CASE_P(conv_3x3s2p1_extra2, MyriadX_HW_Convolution_Tests_nightl ) ); -INSTANTIATE_TEST_CASE_P(conv_3x3s2p1_extra3, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_3x3s2p1_extra3, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 256, 45, 80)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -335,7 +335,7 @@ INSTANTIATE_TEST_CASE_P(conv_3x3s2p1_extra3, MyriadX_HW_Convolution_Tests_nightl ) ); -INSTANTIATE_TEST_CASE_P(conv_3x3s2p1_extra4, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_3x3s2p1_extra4, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 32, 180, 320)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -347,7 +347,7 @@ INSTANTIATE_TEST_CASE_P(conv_3x3s2p1_extra4, MyriadX_HW_Convolution_Tests_nightl ) ); -INSTANTIATE_TEST_CASE_P(conv_1x1s1p0, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_1x1s1p0, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 64, 56, 56)) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) @@ -359,7 +359,7 @@ INSTANTIATE_TEST_CASE_P(conv_1x1s1p0, MyriadX_HW_Convolution_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(conv_1x1s1p0_resnet50, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_1x1s1p0_resnet50, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 2048, 7, 7)) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) @@ -372,7 +372,7 @@ INSTANTIATE_TEST_CASE_P(conv_1x1s1p0_resnet50, MyriadX_HW_Convolution_Tests_nigh ); // This case adds extra CopyMakeBorder stage -INSTANTIATE_TEST_CASE_P(conv_1x1s1p1, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_1x1s1p1, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 512, 13, 13)) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) @@ -384,7 +384,7 @@ INSTANTIATE_TEST_CASE_P(conv_1x1s1p1, MyriadX_HW_Convolution_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(conv_1x1s2p0, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_1x1s2p0, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 256, 56, 56), MAKE_STRUCT(tensor_test_params, 1, 512, 28, 28), @@ -398,7 +398,7 @@ INSTANTIATE_TEST_CASE_P(conv_1x1s2p0, MyriadX_HW_Convolution_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(conv_3x3s1p1, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_3x3s1p1, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 64, 56, 56)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -410,7 +410,7 @@ INSTANTIATE_TEST_CASE_P(conv_3x3s1p1, MyriadX_HW_Convolution_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(conv_3x3s1p1_yolo_tiny_v1_conv1, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_3x3s1p1_yolo_tiny_v1_conv1, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 3, 448, 448)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -422,7 +422,7 @@ INSTANTIATE_TEST_CASE_P(conv_3x3s1p1_yolo_tiny_v1_conv1, MyriadX_HW_Convolution_ ) ); -INSTANTIATE_TEST_CASE_P(conv_3x3s1p1_yolo_tiny_v1_conv7, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_3x3s1p1_yolo_tiny_v1_conv7, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 512, 7, 7)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -434,7 +434,7 @@ INSTANTIATE_TEST_CASE_P(conv_3x3s1p1_yolo_tiny_v1_conv7, MyriadX_HW_Convolution_ ) ); -INSTANTIATE_TEST_CASE_P(conv_3x3s1p1_yolo_tiny_v1_conv8, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_3x3s1p1_yolo_tiny_v1_conv8, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 1024, 7, 7)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -446,7 +446,7 @@ INSTANTIATE_TEST_CASE_P(conv_3x3s1p1_yolo_tiny_v1_conv8, MyriadX_HW_Convolution_ ) ); -INSTANTIATE_TEST_CASE_P(conv_3x3s1p1_vgg, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_3x3s1p1_vgg, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 64, 224, 224)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -458,7 +458,7 @@ INSTANTIATE_TEST_CASE_P(conv_3x3s1p1_vgg, MyriadX_HW_Convolution_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(conv_7x7s2p3, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_7x7s2p3, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 3, 224, 224)) , ::testing::Values(MAKE_STRUCT(param_size, 7, 7)) @@ -472,7 +472,7 @@ INSTANTIATE_TEST_CASE_P(conv_7x7s2p3, MyriadX_HW_Convolution_Tests_nightly, // This case for unsymmetric convolution -INSTANTIATE_TEST_CASE_P(conv_3x1s1_LPR, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_3x1s1_LPR, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 32, 22, 92)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 1)) @@ -484,7 +484,7 @@ INSTANTIATE_TEST_CASE_P(conv_3x1s1_LPR, MyriadX_HW_Convolution_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(conv_1x3s1_LPR, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_1x3s1_LPR, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 32, 22, 92)) , ::testing::Values(MAKE_STRUCT(param_size, 1, 3)) @@ -496,7 +496,7 @@ INSTANTIATE_TEST_CASE_P(conv_1x3s1_LPR, MyriadX_HW_Convolution_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(conv_1x5s1_LPR, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_1x5s1_LPR, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 256, 5, 88)) , ::testing::Values(MAKE_STRUCT(param_size, 1, 5)) @@ -508,7 +508,7 @@ INSTANTIATE_TEST_CASE_P(conv_1x5s1_LPR, MyriadX_HW_Convolution_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(conv_13x1s1_LPR, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_13x1s1_LPR, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 128, 1, 88)) , ::testing::Values(MAKE_STRUCT(param_size, 13, 1)) @@ -520,7 +520,7 @@ INSTANTIATE_TEST_CASE_P(conv_13x1s1_LPR, MyriadX_HW_Convolution_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(conv_5x1s1_LPR, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_5x1s1_LPR, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 128, 1, 28)) , ::testing::Values(MAKE_STRUCT(param_size, 5, 1)) @@ -532,7 +532,7 @@ INSTANTIATE_TEST_CASE_P(conv_5x1s1_LPR, MyriadX_HW_Convolution_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(conv_4x4s2p1, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_4x4s2p1, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 3, 256, 416)) , ::testing::Values(MAKE_STRUCT(param_size, 4, 4)) @@ -544,7 +544,7 @@ INSTANTIATE_TEST_CASE_P(conv_4x4s2p1, MyriadX_HW_Convolution_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(conv_5x5s2p1, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_5x5s2p1, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 3, 256, 416)) , ::testing::Values(MAKE_STRUCT(param_size, 5, 5)) @@ -556,7 +556,7 @@ INSTANTIATE_TEST_CASE_P(conv_5x5s2p1, MyriadX_HW_Convolution_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(conv_5x5s2p2, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_5x5s2p2, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 3, 256, 416)) , ::testing::Values(MAKE_STRUCT(param_size, 5, 5)) @@ -568,7 +568,7 @@ INSTANTIATE_TEST_CASE_P(conv_5x5s2p2, MyriadX_HW_Convolution_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(conv_3x3s1p1_group1, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_3x3s1p1_group1, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 32, 150, 150)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -580,7 +580,7 @@ INSTANTIATE_TEST_CASE_P(conv_3x3s1p1_group1, MyriadX_HW_Convolution_Tests_nightl ) ); -INSTANTIATE_TEST_CASE_P(conv_3x3s2p1_group1, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_3x3s2p1_group1, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 64, 150, 150)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -592,7 +592,7 @@ INSTANTIATE_TEST_CASE_P(conv_3x3s2p1_group1, MyriadX_HW_Convolution_Tests_nightl ) ); -INSTANTIATE_TEST_CASE_P(conv_3x3s2p1_group2, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_3x3s2p1_group2, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 128, 75, 75)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -604,7 +604,7 @@ INSTANTIATE_TEST_CASE_P(conv_3x3s2p1_group2, MyriadX_HW_Convolution_Tests_nightl ) ); -INSTANTIATE_TEST_CASE_P(conv_3x3s2p1_group3, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_3x3s2p1_group3, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 256, 38, 38)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -616,7 +616,7 @@ INSTANTIATE_TEST_CASE_P(conv_3x3s2p1_group3, MyriadX_HW_Convolution_Tests_nightl ) ); -INSTANTIATE_TEST_CASE_P(conv_3x3s1p1_pva_pvd, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_3x3s1p1_pva_pvd, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 6, 208, 368)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -628,7 +628,7 @@ INSTANTIATE_TEST_CASE_P(conv_3x3s1p1_pva_pvd, MyriadX_HW_Convolution_Tests_night ) ); -INSTANTIATE_TEST_CASE_P(conv_1x1s2p0_pva_pvd, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_1x1s2p0_pva_pvd, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 32, 128, 208)) , ::testing::Values(MAKE_STRUCT(param_size, 1, 1)) @@ -640,7 +640,7 @@ INSTANTIATE_TEST_CASE_P(conv_1x1s2p0_pva_pvd, MyriadX_HW_Convolution_Tests_night ) ); -INSTANTIATE_TEST_CASE_P(conv_3x3s1p1_ssd, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_3x3s1p1_ssd, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 128, 75, 75)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -652,7 +652,7 @@ INSTANTIATE_TEST_CASE_P(conv_3x3s1p1_ssd, MyriadX_HW_Convolution_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(conv_unequal_hw_pad, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_unequal_hw_pad, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 32, 128, 128)) , ::testing::Values(MAKE_STRUCT(param_size, 5, 5), @@ -665,7 +665,7 @@ INSTANTIATE_TEST_CASE_P(conv_unequal_hw_pad, MyriadX_HW_Convolution_Tests_nightl ) ); -INSTANTIATE_TEST_CASE_P(conv_3x3s3p1_resnet34, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(conv_3x3s3p1_resnet34, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 512, 75, 75)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -677,7 +677,7 @@ INSTANTIATE_TEST_CASE_P(conv_3x3s3p1_resnet34, MyriadX_HW_Convolution_Tests_nigh ) ); -INSTANTIATE_TEST_CASE_P(fc_to_conv_case, MyriadX_HW_Convolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(fc_to_conv_case, MyriadX_HW_Convolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 256, 56, 350)) , ::testing::Values(MAKE_STRUCT(param_size, 7, 7)) @@ -794,7 +794,7 @@ class MyriadX_HW_ConvPoolMerged_Tests_nightly TEST_P(MyriadX_HW_ConvPoolMerged_Tests_nightly, WithReLU) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } AddConvLayer(); @@ -807,7 +807,7 @@ TEST_P(MyriadX_HW_ConvPoolMerged_Tests_nightly, WithReLU) { TEST_P(MyriadX_HW_ConvPoolMerged_Tests_nightly, WithLeakyReLU) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } AddConvLayer(); @@ -818,7 +818,7 @@ TEST_P(MyriadX_HW_ConvPoolMerged_Tests_nightly, WithLeakyReLU) { CompareWithSW(maxerr); } -INSTANTIATE_TEST_CASE_P(yolo_conv1, MyriadX_HW_ConvPoolMerged_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(yolo_conv1, MyriadX_HW_ConvPoolMerged_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 3, 448, 448)), ::testing::Values(MAKE_STRUCT(param_size, 3, 3)), @@ -831,7 +831,7 @@ INSTANTIATE_TEST_CASE_P(yolo_conv1, MyriadX_HW_ConvPoolMerged_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(yolov2_tf_conv, MyriadX_HW_ConvPoolMerged_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(yolov2_tf_conv, MyriadX_HW_ConvPoolMerged_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 32, 304, 304), MAKE_STRUCT(tensor_test_params, 1, 64, 152, 152)), @@ -845,7 +845,7 @@ INSTANTIATE_TEST_CASE_P(yolov2_tf_conv, MyriadX_HW_ConvPoolMerged_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(yolo_conv2, MyriadX_HW_ConvPoolMerged_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(yolo_conv2, MyriadX_HW_ConvPoolMerged_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 16, 224, 224)), ::testing::Values(MAKE_STRUCT(param_size, 3, 3)), @@ -858,7 +858,7 @@ INSTANTIATE_TEST_CASE_P(yolo_conv2, MyriadX_HW_ConvPoolMerged_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(yolo_conv4, MyriadX_HW_ConvPoolMerged_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(yolo_conv4, MyriadX_HW_ConvPoolMerged_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 64, 56, 56)), ::testing::Values(MAKE_STRUCT(param_size, 3, 3)), @@ -871,7 +871,7 @@ INSTANTIATE_TEST_CASE_P(yolo_conv4, MyriadX_HW_ConvPoolMerged_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(ssd_case1, MyriadX_HW_ConvPoolMerged_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(ssd_case1, MyriadX_HW_ConvPoolMerged_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 64, 98, 150)), ::testing::Values(MAKE_STRUCT(param_size, 3, 3)), @@ -884,7 +884,7 @@ INSTANTIATE_TEST_CASE_P(ssd_case1, MyriadX_HW_ConvPoolMerged_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(vgg16_case1, MyriadX_HW_ConvPoolMerged_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(vgg16_case1, MyriadX_HW_ConvPoolMerged_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 512, 28, 28)), ::testing::Values(MAKE_STRUCT(param_size, 3, 3)), @@ -951,7 +951,7 @@ class MyriadX_HW_ConvTF_Tests_nightly : TEST_P(MyriadX_HW_ConvTF_Tests_nightly, Single) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } AddConvolutionLayer(); @@ -960,7 +960,7 @@ TEST_P(MyriadX_HW_ConvTF_Tests_nightly, Single) { CompareWithSW(maxerr); } -INSTANTIATE_TEST_CASE_P(tf, MyriadX_HW_ConvTF_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(tf, MyriadX_HW_ConvTF_Tests_nightly, ::testing::Values( std::make_tuple( MAKE_STRUCT(tensor_test_params, 1, 3, 224, 224), // input @@ -1124,7 +1124,7 @@ class MyriadX_HW_Deconvolution_Tests_nightly TEST_P(MyriadX_HW_Deconvolution_Tests_nightly, Single) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } AddInitialCopyLayer(); @@ -1136,7 +1136,7 @@ TEST_P(MyriadX_HW_Deconvolution_Tests_nightly, Single) { TEST_P(MyriadX_HW_Deconvolution_Tests_nightly, ScaleTests) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } AddInitialCopyLayer(); @@ -1146,7 +1146,7 @@ TEST_P(MyriadX_HW_Deconvolution_Tests_nightly, ScaleTests) { CompareWithSW(maxerr); } -INSTANTIATE_TEST_CASE_P(deconv_tf_ssd, MyriadX_HW_Deconvolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(deconv_tf_ssd, MyriadX_HW_Deconvolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 2, 3, 3)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -1157,7 +1157,7 @@ INSTANTIATE_TEST_CASE_P(deconv_tf_ssd, MyriadX_HW_Deconvolution_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(deconv_3x3_str1, MyriadX_HW_Deconvolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(deconv_3x3_str1, MyriadX_HW_Deconvolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 256, 3, 3), MAKE_STRUCT(tensor_test_params, 1, 128, 5, 5), @@ -1170,7 +1170,7 @@ INSTANTIATE_TEST_CASE_P(deconv_3x3_str1, MyriadX_HW_Deconvolution_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(hw_accuracy_deconv_3x3, MyriadX_HW_Deconvolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(hw_accuracy_deconv_3x3, MyriadX_HW_Deconvolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 256, 5, 5), MAKE_STRUCT(tensor_test_params, 1, 128, 11, 11), @@ -1185,7 +1185,7 @@ INSTANTIATE_TEST_CASE_P(hw_accuracy_deconv_3x3, MyriadX_HW_Deconvolution_Tests_n ) ); -INSTANTIATE_TEST_CASE_P(hw_accuracy_deconv, MyriadX_HW_Deconvolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(hw_accuracy_deconv, MyriadX_HW_Deconvolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 120, 36, 36), MAKE_STRUCT(tensor_test_params, 1, 73, 40, 54), @@ -1200,7 +1200,7 @@ INSTANTIATE_TEST_CASE_P(hw_accuracy_deconv, MyriadX_HW_Deconvolution_Tests_night ) ); -INSTANTIATE_TEST_CASE_P(hw_accuracy_scale_deconv, MyriadX_HW_Deconvolution_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(hw_accuracy_scale_deconv, MyriadX_HW_Deconvolution_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 120, 36, 36)) , ::testing::Values(MAKE_STRUCT(param_size, 5, 5)) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/myriad_hw_extra_tests.hpp b/inference-engine/tests_deprecated/functional/vpu/common/myriad_hw_extra_tests.hpp index f7c5b2bca0645d..41a4370feb3709 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/myriad_hw_extra_tests.hpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/myriad_hw_extra_tests.hpp @@ -8,7 +8,7 @@ TEST_F(MyriadX_HW_Tests_nightly, SeveralLayers) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } tensor_test_params dims1{1, 3, 224, 224}; @@ -78,7 +78,7 @@ TEST_F(MyriadX_HW_Tests_nightly, SeveralLayers) { TEST_F(MyriadX_HW_Tests_nightly, LargePoolWithConv) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } tensor_test_params dims1{1, 16, 448, 448}; @@ -139,7 +139,7 @@ TEST_F(MyriadX_HW_Tests_nightly, LargePoolWithConv) { TEST_F(MyriadX_HW_Tests_nightly, ConvWithPool) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } tensor_test_params dims1{1, 16, 4, 4}; @@ -202,7 +202,7 @@ TEST_F(MyriadX_HW_Tests_nightly, ConvWithPool) { TEST_F(MyriadX_HW_Tests_nightly, WithConcat) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } const std::string model = R"V0G0N( @@ -391,7 +391,7 @@ TEST_F(MyriadX_HW_Tests_nightly, WithConcat) { TEST_F(MyriadX_HW_Tests_nightly, WithConcatMisaligned) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } const std::string model = R"V0G0N( @@ -548,7 +548,7 @@ TEST_F(MyriadX_HW_Tests_nightly, WithConcatMisaligned) { TEST_F(MyriadX_HW_Tests_nightly, With_3_FC_Layers) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } const std::string model = R"V0G0N( @@ -693,7 +693,7 @@ TEST_F(MyriadX_HW_Tests_nightly, With_3_FC_Layers) { TEST_F(MyriadX_HW_Tests_nightly, WithEltwise) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } const std::string model = R"V0G0N( @@ -913,7 +913,7 @@ TEST_F(MyriadX_HW_Tests_nightly, WithEltwise) { TEST_F(MyriadX_HW_Tests_nightly, WithEltwiseReLU) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } const std::string model = R"V0G0N( @@ -1152,7 +1152,7 @@ TEST_F(MyriadX_HW_Tests_nightly, WithEltwiseReLU) { TEST_F(MyriadX_HW_Tests_nightly, PermuteFlattenConcat) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } const std::string model = R"V0G0N( @@ -1378,7 +1378,7 @@ TEST_F(MyriadX_HW_Tests_nightly, PermuteFlattenConcat) { TEST_F(MyriadX_HW_Tests_nightly, VGG_FirstTwoConvs) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } IN_OUT_desc in_tensor, out_tensor; diff --git a/inference-engine/tests_deprecated/functional/vpu/common/myriad_hw_fc_tests.hpp b/inference-engine/tests_deprecated/functional/vpu/common/myriad_hw_fc_tests.hpp index 5542538947785c..dd8cdaafb54975 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/myriad_hw_fc_tests.hpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/myriad_hw_fc_tests.hpp @@ -57,7 +57,7 @@ class MyriadX_HW_FullyConnected_Tests_nightly TEST_P(MyriadX_HW_FullyConnected_Tests_nightly, Single) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } AddFCLayer(); @@ -67,11 +67,11 @@ TEST_P(MyriadX_HW_FullyConnected_Tests_nightly, Single) { TEST_P(MyriadX_HW_FullyConnected_Tests_nightly, Single_NC) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } if (p.in.h != 1 || p.in.w != 1) { - SKIP() << "Non NC case"; + GTEST_SKIP() << "Non NC case"; } in_tensor.clear(); @@ -84,7 +84,7 @@ TEST_P(MyriadX_HW_FullyConnected_Tests_nightly, Single_NC) { TEST_P(MyriadX_HW_FullyConnected_Tests_nightly, WithReLU) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } AddFCLayer(); @@ -95,7 +95,7 @@ TEST_P(MyriadX_HW_FullyConnected_Tests_nightly, WithReLU) { TEST_P(MyriadX_HW_FullyConnected_Tests_nightly, MultipleInfer) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } AddFCLayer(); @@ -103,38 +103,38 @@ TEST_P(MyriadX_HW_FullyConnected_Tests_nightly, MultipleInfer) { CompareWithItself(100); } -INSTANTIATE_TEST_CASE_P(fc_1024to1000, MyriadX_HW_FullyConnected_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(fc_1024to1000, MyriadX_HW_FullyConnected_Tests_nightly, ::testing::Values(MAKE_STRUCT(fcon_test_params, {1, 1024, 1, 1}, 1000, 0.25f)) ); -INSTANTIATE_TEST_CASE_P(fc_4096to1000, MyriadX_HW_FullyConnected_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(fc_4096to1000, MyriadX_HW_FullyConnected_Tests_nightly, ::testing::Values(MAKE_STRUCT(fcon_test_params, {1, 4096, 1, 1}, 1000, 0.82f)) ); -INSTANTIATE_TEST_CASE_P(fc_4096to4096, MyriadX_HW_FullyConnected_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(fc_4096to4096, MyriadX_HW_FullyConnected_Tests_nightly, ::testing::Values(MAKE_STRUCT(fcon_test_params, {1, 4096, 1, 1}, 4096, 0.9f)) ); -INSTANTIATE_TEST_CASE_P(fc_16x16x16to16, MyriadX_HW_FullyConnected_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(fc_16x16x16to16, MyriadX_HW_FullyConnected_Tests_nightly, ::testing::Values(MAKE_STRUCT(fcon_test_params, {1, 16, 16, 16}, 16, 0.71f)) ); -INSTANTIATE_TEST_CASE_P(fc_512x7x7to4096, MyriadX_HW_FullyConnected_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(fc_512x7x7to4096, MyriadX_HW_FullyConnected_Tests_nightly, ::testing::Values(MAKE_STRUCT(fcon_test_params, {1, 512, 7, 7}, 4096, 4.38f)) ); -INSTANTIATE_TEST_CASE_P(fc_256x7x7to1470, MyriadX_HW_FullyConnected_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(fc_256x7x7to1470, MyriadX_HW_FullyConnected_Tests_nightly, ::testing::Values(MAKE_STRUCT(fcon_test_params, {1, 256, 7, 7}, 1470, 2.375f)) ); -INSTANTIATE_TEST_CASE_P(fc_576to128, MyriadX_HW_FullyConnected_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(fc_576to128, MyriadX_HW_FullyConnected_Tests_nightly, ::testing::Values(MAKE_STRUCT(fcon_test_params, {1, 576, 1, 1}, 128, 0.76f)) ); -INSTANTIATE_TEST_CASE_P(fc_1152to128, MyriadX_HW_FullyConnected_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(fc_1152to128, MyriadX_HW_FullyConnected_Tests_nightly, ::testing::Values(MAKE_STRUCT(fcon_test_params, {1, 1152, 1, 1}, 128, 0.76f)) ); -INSTANTIATE_TEST_CASE_P(fc_batch, MyriadX_HW_FullyConnected_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(fc_batch, MyriadX_HW_FullyConnected_Tests_nightly, ::testing::Values(MAKE_STRUCT(fcon_test_params, {100, 256, 1, 1}, 1024, 0.1f)) ); diff --git a/inference-engine/tests_deprecated/functional/vpu/common/myriad_hw_network_tests.hpp b/inference-engine/tests_deprecated/functional/vpu/common/myriad_hw_network_tests.hpp index 7d91bd5ee22a90..1df7a1307c82c3 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/myriad_hw_network_tests.hpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/myriad_hw_network_tests.hpp @@ -58,7 +58,7 @@ class MyriadX_HW_Networks_Tests_nightly : void RunAsyncTest(int numIters = 20) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } auto fnPtr = ngraph::builder::subgraph::makeSplitMultiConvConcat(); @@ -145,7 +145,7 @@ inline std::string getTestCaseName(const testing::TestParamInfo std::string((std::get<1>(param.param)).name()); } -INSTANTIATE_TEST_CASE_P(Input_Output_ExecMode, MyriadX_HW_Networks_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(Input_Output_ExecMode, MyriadX_HW_Networks_Tests_nightly, testing::Values( std::make_tuple(Precision::FP16, Precision::FP16) ), diff --git a/inference-engine/tests_deprecated/functional/vpu/common/myriad_hw_pool_tests.hpp b/inference-engine/tests_deprecated/functional/vpu/common/myriad_hw_pool_tests.hpp index 10f982b6945a65..e4fcf81a66a131 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/myriad_hw_pool_tests.hpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/myriad_hw_pool_tests.hpp @@ -70,7 +70,7 @@ class MyriadX_HW_Pooling_Tests_nightly void RunSingleTest(const std::string& poolMethod, float tolerance) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } AddPoolingLayer(poolMethod); @@ -80,7 +80,7 @@ class MyriadX_HW_Pooling_Tests_nightly void RunWithReLUTest(const std::string& poolMethod, float tolerance) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } AddPoolingLayer(poolMethod); @@ -91,7 +91,7 @@ class MyriadX_HW_Pooling_Tests_nightly void RunMultipleInferTest(const std::string& poolMethod) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } AddPoolingLayer(poolMethod); @@ -108,11 +108,11 @@ TEST_P(MyriadX_HW_Pooling_Tests_nightly, Avg_Single) { // this case is not supported by HW if (kernel.x == 3 && kernel.y == 3 && stride.x == 2 && stride.y == 2) { - SKIP() << "Unsupported case"; + GTEST_SKIP() << "Unsupported case"; } if ((kernel.x % 2 == 0 || kernel.y % 2 == 0) && (in_dims.w % 2 == 1 || in_dims.h % 2 == 1)) { - SKIP() << "Unsupported case"; + GTEST_SKIP() << "Unsupported case"; } RunSingleTest("avg", 0.0015f); @@ -126,11 +126,11 @@ TEST_P(MyriadX_HW_Pooling_Tests_nightly, Avg_WithReLU) { // this case is not supported by HW if (kernel.x == 3 && kernel.y == 3 && stride.x == 2 && stride.y == 2) { - SKIP() << "Unsupported case"; + GTEST_SKIP() << "Unsupported case"; } if ((kernel.x % 2 == 0 || kernel.y % 2 == 0) && (in_dims.w % 2 == 1 || in_dims.h % 2 == 1)) { - SKIP() << "Unsupported case"; + GTEST_SKIP() << "Unsupported case"; } RunWithReLUTest("avg", 0.0015f); @@ -144,17 +144,17 @@ TEST_P(MyriadX_HW_Pooling_Tests_nightly, Avg_MultipleInfer) { // this case is not supported by HW if (kernel.x == 3 && kernel.y == 3 && stride.x == 2 && stride.y == 2) { - SKIP() << "Unsupported case"; + GTEST_SKIP() << "Unsupported case"; } if ((kernel.x % 2 == 0 || kernel.y % 2 == 0) && (in_dims.w % 2 == 1 || in_dims.h % 2 == 1)) { - SKIP() << "Unsupported case"; + GTEST_SKIP() << "Unsupported case"; } RunMultipleInferTest("avg"); } -INSTANTIATE_TEST_CASE_P(pool_2x2s1p0, MyriadX_HW_Pooling_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(pool_2x2s1p0, MyriadX_HW_Pooling_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 64, 112, 112)) , ::testing::Values(MAKE_STRUCT(param_size, 2, 2)) @@ -163,7 +163,7 @@ INSTANTIATE_TEST_CASE_P(pool_2x2s1p0, MyriadX_HW_Pooling_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(pool_2x2s2p0, MyriadX_HW_Pooling_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(pool_2x2s2p0, MyriadX_HW_Pooling_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 64, 224, 224), MAKE_STRUCT(tensor_test_params, 1, 128, 112, 112), @@ -176,7 +176,7 @@ INSTANTIATE_TEST_CASE_P(pool_2x2s2p0, MyriadX_HW_Pooling_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(pool_2x2s2p0_yolo_tiny_v1, MyriadX_HW_Pooling_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(pool_2x2s2p0_yolo_tiny_v1, MyriadX_HW_Pooling_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 16, 448, 448)) , ::testing::Values(MAKE_STRUCT(param_size, 2, 2)) @@ -185,7 +185,7 @@ INSTANTIATE_TEST_CASE_P(pool_2x2s2p0_yolo_tiny_v1, MyriadX_HW_Pooling_Tests_nigh ) ); -INSTANTIATE_TEST_CASE_P(pool_3x3s1p0, MyriadX_HW_Pooling_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(pool_3x3s1p0, MyriadX_HW_Pooling_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 192, 28, 28), MAKE_STRUCT(tensor_test_params, 1, 100, 28, 28)) @@ -195,7 +195,7 @@ INSTANTIATE_TEST_CASE_P(pool_3x3s1p0, MyriadX_HW_Pooling_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(pool_3x3s1p1, MyriadX_HW_Pooling_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(pool_3x3s1p1, MyriadX_HW_Pooling_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 192, 28, 28)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -205,7 +205,7 @@ INSTANTIATE_TEST_CASE_P(pool_3x3s1p1, MyriadX_HW_Pooling_Tests_nightly, ); // TODO : 3x3s2p0 HW seems to work only for Max Pooling -INSTANTIATE_TEST_CASE_P(pool_3x3s2p0, MyriadX_HW_Pooling_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(pool_3x3s2p0, MyriadX_HW_Pooling_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 64, 112, 112)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -214,7 +214,7 @@ INSTANTIATE_TEST_CASE_P(pool_3x3s2p0, MyriadX_HW_Pooling_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(pool_3x3s2p1, MyriadX_HW_Pooling_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(pool_3x3s2p1, MyriadX_HW_Pooling_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 576, 7, 7), MAKE_STRUCT(tensor_test_params, 1, 16, 35, 35), @@ -226,7 +226,7 @@ INSTANTIATE_TEST_CASE_P(pool_3x3s2p1, MyriadX_HW_Pooling_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(pool_7x7s1p0, MyriadX_HW_Pooling_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(pool_7x7s1p0, MyriadX_HW_Pooling_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 1024, 7, 7)) , ::testing::Values(MAKE_STRUCT(param_size, 7, 7)) @@ -235,7 +235,7 @@ INSTANTIATE_TEST_CASE_P(pool_7x7s1p0, MyriadX_HW_Pooling_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(pool_14x14s1p0, MyriadX_HW_Pooling_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(pool_14x14s1p0, MyriadX_HW_Pooling_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 1024, 14, 14), MAKE_STRUCT(tensor_test_params, 1, 1000, 14, 14)) @@ -245,7 +245,7 @@ INSTANTIATE_TEST_CASE_P(pool_14x14s1p0, MyriadX_HW_Pooling_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(pool_15x15s1p0, MyriadX_HW_Pooling_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(pool_15x15s1p0, MyriadX_HW_Pooling_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 1024, 15, 15), MAKE_STRUCT(tensor_test_params, 1, 1000, 15, 15)) @@ -255,7 +255,7 @@ INSTANTIATE_TEST_CASE_P(pool_15x15s1p0, MyriadX_HW_Pooling_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(pool_2x2s1p1_odd, MyriadX_HW_Pooling_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(pool_2x2s1p1_odd, MyriadX_HW_Pooling_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 512, 13, 13)) , ::testing::Values(MAKE_STRUCT(param_size, 2, 2)) @@ -264,7 +264,7 @@ INSTANTIATE_TEST_CASE_P(pool_2x2s1p1_odd, MyriadX_HW_Pooling_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(pool_2x2s2p0_odd, MyriadX_HW_Pooling_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(pool_2x2s2p0_odd, MyriadX_HW_Pooling_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 256, 75, 75), MAKE_STRUCT(tensor_test_params, 2, 64, 75, 75), @@ -276,7 +276,7 @@ INSTANTIATE_TEST_CASE_P(pool_2x2s2p0_odd, MyriadX_HW_Pooling_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(pool_3x3s1p0_odd, MyriadX_HW_Pooling_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(pool_3x3s1p0_odd, MyriadX_HW_Pooling_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 192, 37, 37), MAKE_STRUCT(tensor_test_params, 1, 832, 9, 9), @@ -287,7 +287,7 @@ INSTANTIATE_TEST_CASE_P(pool_3x3s1p0_odd, MyriadX_HW_Pooling_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(pool_3x3s2p0_odd, MyriadX_HW_Pooling_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(pool_3x3s2p0_odd, MyriadX_HW_Pooling_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 96, 93, 93), MAKE_STRUCT(tensor_test_params, 1, 512, 23, 23), @@ -299,7 +299,7 @@ INSTANTIATE_TEST_CASE_P(pool_3x3s2p0_odd, MyriadX_HW_Pooling_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(pool_3x3s2p0_extra, MyriadX_HW_Pooling_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(pool_3x3s2p0_extra, MyriadX_HW_Pooling_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 96, 32, 52)) , ::testing::Values(MAKE_STRUCT(param_size, 3, 3)) @@ -308,7 +308,7 @@ INSTANTIATE_TEST_CASE_P(pool_3x3s2p0_extra, MyriadX_HW_Pooling_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(pool_7x7s7p0_rfcn_batch, MyriadX_HW_Pooling_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(pool_7x7s7p0_rfcn_batch, MyriadX_HW_Pooling_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 300, 5, 7, 7)) , ::testing::Values(MAKE_STRUCT(param_size, 7, 7)) @@ -368,7 +368,7 @@ class MyriadX_HW_PoolTF_Tests_nightly : TEST_P(MyriadX_HW_PoolTF_Tests_nightly, Single) { if (!CheckMyriadX()) { - SKIP() << "Non-MyriadX device"; + GTEST_SKIP() << "Non-MyriadX device"; } AddPoolingLayer(); @@ -376,7 +376,7 @@ TEST_P(MyriadX_HW_PoolTF_Tests_nightly, Single) { CompareWithSW(0.0f); } -INSTANTIATE_TEST_CASE_P(pool_2x2_3x3, MyriadX_HW_PoolTF_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(pool_2x2_3x3, MyriadX_HW_PoolTF_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 32, 128, 128)), ::testing::Values(MAKE_STRUCT(param_size, 2, 2), @@ -391,7 +391,7 @@ INSTANTIATE_TEST_CASE_P(pool_2x2_3x3, MyriadX_HW_PoolTF_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(pool4x4, MyriadX_HW_PoolTF_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(pool4x4, MyriadX_HW_PoolTF_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 32, 128, 128)), ::testing::Values(MAKE_STRUCT(param_size, 4, 4)), @@ -409,7 +409,7 @@ INSTANTIATE_TEST_CASE_P(pool4x4, MyriadX_HW_PoolTF_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(pool_with_large_width, MyriadX_HW_PoolTF_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(pool_with_large_width, MyriadX_HW_PoolTF_Tests_nightly, ::testing::Combine( ::testing::Values(MAKE_STRUCT(tensor_test_params, 1, 8, 640, 960), MAKE_STRUCT(tensor_test_params, 1, 64, 6, 1000)), @@ -422,7 +422,7 @@ INSTANTIATE_TEST_CASE_P(pool_with_large_width, MyriadX_HW_PoolTF_Tests_nightly, ) ); -INSTANTIATE_TEST_CASE_P(tf, MyriadX_HW_PoolTF_Tests_nightly, +INSTANTIATE_TEST_SUITE_P(tf, MyriadX_HW_PoolTF_Tests_nightly, ::testing::Values( std::make_tuple( MAKE_STRUCT(tensor_test_params, 1, 64, 112, 112), // input diff --git a/inference-engine/tests_deprecated/functional/vpu/common/myriad_merge_permute_tests.cpp b/inference-engine/tests_deprecated/functional/vpu/common/myriad_merge_permute_tests.cpp index 0c11efcf6eabe2..becb06c53853ff 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/myriad_merge_permute_tests.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/myriad_merge_permute_tests.cpp @@ -4,19 +4,19 @@ #include "myriad_merge_permute_tests.hpp" -INSTANTIATE_TEST_CASE_P(accuracy_3D, myriadLayersMergePermuteNDTests_nightly, +INSTANTIATE_TEST_SUITE_P(accuracy_3D, myriadLayersMergePermuteNDTests_nightly, ::testing::Combine( ::testing::ValuesIn(s_inTensors_3D) , ::testing::ValuesIn(s_permuteParams_3D) )); -INSTANTIATE_TEST_CASE_P(accuracy_4D, myriadLayersMergePermuteNDTests_nightly, +INSTANTIATE_TEST_SUITE_P(accuracy_4D, myriadLayersMergePermuteNDTests_nightly, ::testing::Combine( ::testing::ValuesIn(s_inTensors_4D) , ::testing::ValuesIn(s_permuteParams_4D) )); -INSTANTIATE_TEST_CASE_P(accuracy_5D, myriadLayersMergePermuteNDTests_nightly, +INSTANTIATE_TEST_SUITE_P(accuracy_5D, myriadLayersMergePermuteNDTests_nightly, ::testing::Combine( ::testing::ValuesIn(s_inTensors_5D) , ::testing::ValuesIn(s_permuteParams_5D) diff --git a/inference-engine/tests_deprecated/functional/vpu/common/regression/helpers/vpu_case_common.hpp b/inference-engine/tests_deprecated/functional/vpu/common/regression/helpers/vpu_case_common.hpp index 82217999d188f2..b3f3b15b3c7e19 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/regression/helpers/vpu_case_common.hpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/regression/helpers/vpu_case_common.hpp @@ -21,7 +21,7 @@ using namespace InferenceEngine; #define DISABLE_IF(expr) \ do { \ if (expr) { \ - SKIP() << "Disabled since " << #expr << std::endl; \ + GTEST_SKIP() << "Disabled since " << #expr << std::endl; \ } \ }while(false) @@ -33,7 +33,7 @@ using namespace InferenceEngine; #endif #if defined(__arm__) || defined(_M_ARM) || defined(__aarch64__) || defined(_M_ARM64) -# define DISABLE_ON_ARM SKIP() << "Disabled on ARM" << std::endl; +# define DISABLE_ON_ARM GTEST_SKIP() << "Disabled on ARM" << std::endl; # define VPU_REG_TEST_ARM_PLATFORM #else # define DISABLE_ON_ARM @@ -42,9 +42,9 @@ using namespace InferenceEngine; #define ENABLE_IF_MA2085 \ do { \ if (!CheckMA2085()) { \ - SKIP() << "Disabled since not on MA2085" << std::endl; \ + GTEST_SKIP() << "Disabled since not on MA2085" << std::endl; \ }\ - }while(false) + } while(false) extern bool CheckMyriadX(); extern bool CheckMA2085(); diff --git a/inference-engine/tests_deprecated/functional/vpu/graph_transformer/merge_permute_and_reorder_test.cpp b/inference-engine/tests_deprecated/functional/vpu/graph_transformer/merge_permute_and_reorder_test.cpp index ec6332dcc98231..f6105b9979cb58 100644 --- a/inference-engine/tests_deprecated/functional/vpu/graph_transformer/merge_permute_and_reorder_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/graph_transformer/merge_permute_and_reorder_test.cpp @@ -147,13 +147,13 @@ TEST_P(myriadGTMergePermuteNDTests_nightly, Permute) { std::cout << "Myriad time = non-optimized: " << executionMicroseconds << " us., optimized: " << executionMicrosecondsOptimized << " us.\n"; } -INSTANTIATE_TEST_CASE_P(accuracy_3D, myriadGTMergePermuteNDTests_nightly, +INSTANTIATE_TEST_SUITE_P(accuracy_3D, myriadGTMergePermuteNDTests_nightly, ::testing::Combine( ::testing::ValuesIn(s_inTensors_3D) , ::testing::ValuesIn(s_permuteParams_3D) )); -INSTANTIATE_TEST_CASE_P(accuracy_5D, myriadGTMergePermuteNDTests_nightly, +INSTANTIATE_TEST_SUITE_P(accuracy_5D, myriadGTMergePermuteNDTests_nightly, ::testing::Combine( ::testing::ValuesIn(s_inTensors_5D) , ::testing::ValuesIn(s_permuteParams_5D) diff --git a/inference-engine/tests_deprecated/functional/vpu/myriad_tests/myriad_configs_tests.cpp b/inference-engine/tests_deprecated/functional/vpu/myriad_tests/myriad_configs_tests.cpp index 074ed1a78ef2cb..8fc795322c815c 100644 --- a/inference-engine/tests_deprecated/functional/vpu/myriad_tests/myriad_configs_tests.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/myriad_tests/myriad_configs_tests.cpp @@ -100,14 +100,14 @@ static const std::vector myriadIncorrectPackageTypeConfigValues = { {{VPU_MYRIAD_CONFIG_KEY(MOVIDIUS_DDR_TYPE), "-MICRON_1GB"}}, }; -INSTANTIATE_TEST_CASE_P(MyriadConfigs, myriadCorrectModelsConfigsTests_nightly, +INSTANTIATE_TEST_SUITE_P(MyriadConfigs, myriadCorrectModelsConfigsTests_nightly, ::testing::ValuesIn(myriadCorrectPlatformConfigValues)); -INSTANTIATE_TEST_CASE_P(MyriadConfigs, myriadIncorrectModelsConfigsTests_nightly, +INSTANTIATE_TEST_SUITE_P(MyriadConfigs, myriadIncorrectModelsConfigsTests_nightly, ::testing::ValuesIn(myriadIncorrectPlatformConfigValues)); -INSTANTIATE_TEST_CASE_P(MyriadPackageConfigs, myriadCorrectModelsConfigsTests_nightly, +INSTANTIATE_TEST_SUITE_P(MyriadPackageConfigs, myriadCorrectModelsConfigsTests_nightly, ::testing::ValuesIn(myriadCorrectPackageTypeConfigValues)); -INSTANTIATE_TEST_CASE_P(MyriadPackageConfigs, myriadIncorrectModelsConfigsTests_nightly, +INSTANTIATE_TEST_SUITE_P(MyriadPackageConfigs, myriadIncorrectModelsConfigsTests_nightly, ::testing::ValuesIn(myriadIncorrectPackageTypeConfigValues)); diff --git a/inference-engine/tests_deprecated/functional/vpu/myriad_tests/myriad_multiple_graph_tests.cpp b/inference-engine/tests_deprecated/functional/vpu/myriad_tests/myriad_multiple_graph_tests.cpp index 19a626a90bb2bd..59dee4b72808eb 100644 --- a/inference-engine/tests_deprecated/functional/vpu/myriad_tests/myriad_multiple_graph_tests.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/myriad_tests/myriad_multiple_graph_tests.cpp @@ -23,6 +23,6 @@ TEST_P(myriadMultipleGraphsTests_nightly, LoadGraphsOnDevice) { } } -INSTANTIATE_TEST_CASE_P(numerOfGraphs, myriadMultipleGraphsTests_nightly, +INSTANTIATE_TEST_SUITE_P(numerOfGraphs, myriadMultipleGraphsTests_nightly, ::testing::Values(2, 4, 10) ); diff --git a/inference-engine/tests_deprecated/functional/vpu/myriad_tests/myriad_streams_configuration_tests.cpp b/inference-engine/tests_deprecated/functional/vpu/myriad_tests/myriad_streams_configuration_tests.cpp index a6d99e2367a3ea..93f4b4cc8d01f6 100644 --- a/inference-engine/tests_deprecated/functional/vpu/myriad_tests/myriad_streams_configuration_tests.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/myriad_tests/myriad_streams_configuration_tests.cpp @@ -24,6 +24,6 @@ TEST_P(myriadCorrectStreamsConfiguration_nightly, InfersWithConfiguredStreams) { ASSERT_TRUE(Infer()); } -INSTANTIATE_TEST_CASE_P(StreamsConfiguration, myriadCorrectStreamsConfiguration_nightly, testing::Values(1, 2, 3)); +INSTANTIATE_TEST_SUITE_P(StreamsConfiguration, myriadCorrectStreamsConfiguration_nightly, testing::Values(1, 2, 3)); } diff --git a/inference-engine/tests_deprecated/functional/vpu/shared_tests_instance/common_single_layer_tests/single_layer_tests.cpp b/inference-engine/tests_deprecated/functional/vpu/shared_tests_instance/common_single_layer_tests/single_layer_tests.cpp index 0b59f755bb1b80..6587fb3eaf96c2 100644 --- a/inference-engine/tests_deprecated/functional/vpu/shared_tests_instance/common_single_layer_tests/single_layer_tests.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/shared_tests_instance/common_single_layer_tests/single_layer_tests.cpp @@ -44,7 +44,7 @@ getTestCaseName(testing::TestParamInfogetType(); } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( // TODO: rewrite to ngraph to have reshape functionality DISABLED_Conv_nightly, CommonSingleLayerTest, ::testing::Combine( @@ -61,7 +61,7 @@ INSTANTIATE_TEST_CASE_P( ), getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( // TODO: rewrite to ngraph to have reshape functionality DISABLED_Deconv_nightly, CommonSingleLayerTest, ::testing::Combine( @@ -78,7 +78,7 @@ INSTANTIATE_TEST_CASE_P( ), getTestCaseName ); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( // TODO: rewrite to ngraph to have reshape functionality DISABLED_Pool_nightly, CommonSingleLayerTest, ::testing::Combine( diff --git a/inference-engine/tests_deprecated/functional/vpu/shared_tests_instance/input_tests/parser_tests.cpp b/inference-engine/tests_deprecated/functional/vpu/shared_tests_instance/input_tests/parser_tests.cpp index 616e2214011bed..14e48bcd2e4bf6 100644 --- a/inference-engine/tests_deprecated/functional/vpu/shared_tests_instance/input_tests/parser_tests.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/shared_tests_instance/input_tests/parser_tests.cpp @@ -30,6 +30,6 @@ ir_test_params ir_test_cases[] = { ir_test_params("MYRIAD", "FP16", negative_norm_k_case) }; -INSTANTIATE_TEST_CASE_P(FunctionalTest_nightly, IncorrectIRTests, +INSTANTIATE_TEST_SUITE_P(FunctionalTest_nightly, IncorrectIRTests, ::testing::ValuesIn(ir_test_cases), getTestName); diff --git a/inference-engine/tests_deprecated/functional/vpu/vpu_base/vpu_tests_config.hpp b/inference-engine/tests_deprecated/functional/vpu/vpu_base/vpu_tests_config.hpp index ab402644b3f3e0..bddbf9dd20efec 100644 --- a/inference-engine/tests_deprecated/functional/vpu/vpu_base/vpu_tests_config.hpp +++ b/inference-engine/tests_deprecated/functional/vpu/vpu_base/vpu_tests_config.hpp @@ -25,7 +25,7 @@ bool deviceForceReset(); // IE macro forcing gave us no ability to pass device name as variable. // So we create this two replacements to PLUGING_CASE_WITH_SUFFIX. #define VPU_PLUGING_CASE_WITH_SUFFIX(_suffix, _test, _params) \ - INSTANTIATE_TEST_CASE_P(VPU_run##_suffix, _test, ::testing::Combine(::testing::Values(::vpu::tests::deviceName()), _params) ) + INSTANTIATE_TEST_SUITE_P(VPU_run##_suffix, _test, ::testing::Combine(::testing::Values(::vpu::tests::deviceName()), _params) ) #define DISABLED_VPU_PLUGING_CASE_WITH_SUFFIX(_suffix, _test, _params) \ - INSTANTIATE_TEST_CASE_P(DISABLED_VPU_run##_suffix, _test, ::testing::Combine(::testing::Values(::vpu::tests::deviceName()), _params) ) + INSTANTIATE_TEST_SUITE_P(DISABLED_VPU_run##_suffix, _test, ::testing::Combine(::testing::Values(::vpu::tests::deviceName()), _params) ) diff --git a/inference-engine/tests_deprecated/helpers/tests_vpu_common.hpp b/inference-engine/tests_deprecated/helpers/tests_vpu_common.hpp index 5cfc76f825b486..18d17be9337dfc 100644 --- a/inference-engine/tests_deprecated/helpers/tests_vpu_common.hpp +++ b/inference-engine/tests_deprecated/helpers/tests_vpu_common.hpp @@ -24,7 +24,7 @@ static constexpr char ENV_HDDL_R[] = "IE_VPU_ENABLE_PER_LAYER_TESTS_HDDL"; #define DISABLE_IF(expression) \ { \ if (expression) { \ - SKIP() << "Disabled since " << #expression << std::endl; \ + GTEST_SKIP() << "Disabled since " << #expression << std::endl; \ } \ } diff --git a/inference-engine/tests_deprecated/unit/engines/gna/fp32_non_quantized_tests.cpp b/inference-engine/tests_deprecated/unit/engines/gna/fp32_non_quantized_tests.cpp index e321c50a77c9f7..3570511851511d 100644 --- a/inference-engine/tests_deprecated/unit/engines/gna/fp32_non_quantized_tests.cpp +++ b/inference-engine/tests_deprecated/unit/engines/gna/fp32_non_quantized_tests.cpp @@ -66,7 +66,7 @@ FP32TestParams gna_fp32_test_params[] = { {32, FP32TestParams::eSumm} }; -INSTANTIATE_TEST_CASE_P(GNAFP32Tests, GNAFP32ParametricTest, +INSTANTIATE_TEST_SUITE_P(GNAFP32Tests, GNAFP32ParametricTest, ::testing::ValuesIn(gna_fp32_test_params), getTestName); TEST_F(FP32NonQuantizedTest, SplitFollowedByFCAndEltwiseOnCPU) { diff --git a/inference-engine/tests_deprecated/unit/engines/gna/gna_input_precision_test.cpp b/inference-engine/tests_deprecated/unit/engines/gna/gna_input_precision_test.cpp index 34baad4349b68d..0efbeb83a72dd5 100644 --- a/inference-engine/tests_deprecated/unit/engines/gna/gna_input_precision_test.cpp +++ b/inference-engine/tests_deprecated/unit/engines/gna/gna_input_precision_test.cpp @@ -3,7 +3,7 @@ // #include -#include +#include #include "gna_matcher.hpp" #include "matchers/input_data_matcher.hpp" #include "test_irs.hpp" diff --git a/inference-engine/tests_deprecated/unit/engines/gna/gna_matcher.cpp b/inference-engine/tests_deprecated/unit/engines/gna/gna_matcher.cpp index 70f8c2d7ef0897..f6d611faffe9a9 100644 --- a/inference-engine/tests_deprecated/unit/engines/gna/gna_matcher.cpp +++ b/inference-engine/tests_deprecated/unit/engines/gna/gna_matcher.cpp @@ -17,7 +17,7 @@ #include "matchers/pool_matcher.hpp" #include "matchers/fill_with_data.hpp" #include "matchers/weights_matcher.hpp" -#include +#include #include #include diff --git a/inference-engine/tests_deprecated/unit/engines/gna/gna_proc_type_test.cpp b/inference-engine/tests_deprecated/unit/engines/gna/gna_proc_type_test.cpp index 8eed7282212857..0f8102468226ed 100644 --- a/inference-engine/tests_deprecated/unit/engines/gna/gna_proc_type_test.cpp +++ b/inference-engine/tests_deprecated/unit/engines/gna/gna_proc_type_test.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include "gna_plugin.hpp" #include "gna_mock_api.hpp" diff --git a/inference-engine/tests_deprecated/unit/engines/gna/layers/activation_test.cpp b/inference-engine/tests_deprecated/unit/engines/gna/layers/activation_test.cpp index 34b3c20761eff2..0d768f823a1c1c 100644 --- a/inference-engine/tests_deprecated/unit/engines/gna/layers/activation_test.cpp +++ b/inference-engine/tests_deprecated/unit/engines/gna/layers/activation_test.cpp @@ -89,7 +89,7 @@ static const ActivationCaseParam gna_activation_test_params[] = { {"softsign", 200, {-10, 10}}, }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( GNALayerTests, GNAActivationTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32, InferenceEngine::Precision::I16, InferenceEngine::Precision::I8), diff --git a/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_align_filter2_tests.cpp b/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_align_filter2_tests.cpp index 71db4e90376bb8..75fdc98b934934 100644 --- a/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_align_filter2_tests.cpp +++ b/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_align_filter2_tests.cpp @@ -170,7 +170,7 @@ TEST_P(GNAAlignFilterTest, concatWith_2_Inputs_accurate) { } } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( GNALayerTests, GNAAlignFilterTest, testing::Combine( diff --git a/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_conv1d_test.cpp b/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_conv1d_test.cpp index 310cf46d0f165e..9761edd803b793 100644 --- a/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_conv1d_test.cpp +++ b/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_conv1d_test.cpp @@ -100,7 +100,7 @@ TEST_P(GNAConv1DTest, SplitToConcatWith2Inputs) { } } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( GNALayerTests, GNAConv1DTest, testing::Combine( diff --git a/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_eltwise_test.cpp b/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_eltwise_test.cpp index 28c26e21af1924..c1e2ea788c3aa3 100644 --- a/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_eltwise_test.cpp +++ b/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_eltwise_test.cpp @@ -106,7 +106,7 @@ TEST_P(GNAEltwiseTest, FourBytesInputsViaReshape) { } } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( GNALayerTests, GNAEltwiseTest, ::testing::Combine( diff --git a/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_multi_input_to_concat_test.cpp b/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_multi_input_to_concat_test.cpp index 068b0f681e91b9..dac88c92cc7f62 100644 --- a/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_multi_input_to_concat_test.cpp +++ b/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_multi_input_to_concat_test.cpp @@ -106,7 +106,7 @@ TEST_P(GNAMultiInputToConcatTest, InputsToConcat) { } } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( GNALayerTests, GNAMultiInputToConcatTest, ::testing::Combine( diff --git a/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_permute_test.cpp b/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_permute_test.cpp index 3c0c7ffe33e386..8392de59122978 100644 --- a/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_permute_test.cpp +++ b/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_permute_test.cpp @@ -71,5 +71,5 @@ const Permute3dimTestParam gna_permute3d_test_params[] = { {{{2, 1, 0}, {2, 1, 4}}, false} }; -INSTANTIATE_TEST_CASE_P(GNALayerTests, GNAPermute3dTest, +INSTANTIATE_TEST_SUITE_P(GNALayerTests, GNAPermute3dTest, ::testing::ValuesIn(gna_permute3d_test_params), getPermute3dTestName); diff --git a/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_split_to_concat_test.cpp b/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_split_to_concat_test.cpp index 9ac1011ca6cb54..7e429f9edca85f 100644 --- a/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_split_to_concat_test.cpp +++ b/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_split_to_concat_test.cpp @@ -84,7 +84,7 @@ TEST_P(GNASplitToConcatTest, SplitToConcatWith2Inputs) { } } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( GNALayerTests, GNASplitToConcatTest, testing::Combine( diff --git a/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_squeeze_test.cpp b/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_squeeze_test.cpp index 603efb6578e9cd..ce015857859bbf 100644 --- a/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_squeeze_test.cpp +++ b/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_squeeze_test.cpp @@ -147,7 +147,7 @@ static const SqueezeCaseParam gna_squeeze_test_params[] = { {{1, 1, 1, 1, 1, 3}, {1, 3}} }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( GNALayerTests, GNASqueezeTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32, InferenceEngine::Precision::I16), @@ -155,7 +155,7 @@ INSTANTIATE_TEST_CASE_P( ::testing::ValuesIn(gna_squeeze_test_params)), GNAUnsqueezeTest::getTestName); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( GNALayerTests, GNAUnsqueezeTest, ::testing::Combine( ::testing::Values(InferenceEngine::Precision::FP32, InferenceEngine::Precision::I16), diff --git a/inference-engine/tests_deprecated/unit/engines/vpu/merge_parallel_fc.cpp b/inference-engine/tests_deprecated/unit/engines/vpu/merge_parallel_fc.cpp index 3ab1ab9dec0e76..45da2af742c9cc 100644 --- a/inference-engine/tests_deprecated/unit/engines/vpu/merge_parallel_fc.cpp +++ b/inference-engine/tests_deprecated/unit/engines/vpu/merge_parallel_fc.cpp @@ -346,12 +346,12 @@ TEST_P(VPU_NoMergeParallelFCTest, NoMergeParallelFCMergeCases) { AssertNotMergedCorrectly(testInputDimensions, testFCDescriptors); } -INSTANTIATE_TEST_CASE_P(MergeParallelFCTest, VPU_MergeParallelFCTest, testing::Combine( +INSTANTIATE_TEST_SUITE_P(MergeParallelFCTest, VPU_MergeParallelFCTest, testing::Combine( testing::ValuesIn(inputDimensions), testing::ValuesIn(FCDescriptorsMerge) )); -INSTANTIATE_TEST_CASE_P(NoMergeParallelFCTest, VPU_NoMergeParallelFCTest, testing::Combine( +INSTANTIATE_TEST_SUITE_P(NoMergeParallelFCTest, VPU_NoMergeParallelFCTest, testing::Combine( testing::ValuesIn(inputDimensions), testing::ValuesIn(FCDescriptorsNoMerge) )); diff --git a/inference-engine/tests_deprecated/unit/engines/vpu/mvnc/pthread_semaphore_tests.cpp b/inference-engine/tests_deprecated/unit/engines/vpu/mvnc/pthread_semaphore_tests.cpp index 8a2f6282aa4230..6f6f851ae4ecbc 100644 --- a/inference-engine/tests_deprecated/unit/engines/vpu/mvnc/pthread_semaphore_tests.cpp +++ b/inference-engine/tests_deprecated/unit/engines/vpu/mvnc/pthread_semaphore_tests.cpp @@ -366,7 +366,7 @@ TEST_P(PThreadBinSemaphoreTest, PostWakeUpOnlyOneWaiterOfMany) { th3.join(); } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( PThreadParametrizedTests, PThreadBinSemaphoreTest, ::testing::Values( diff --git a/inference-engine/tests_deprecated/unit/engines/vpu/mvnc/watchdog_tests.cpp b/inference-engine/tests_deprecated/unit/engines/vpu/mvnc/watchdog_tests.cpp index a4c2f50aa8b20c..8ae4110fc1a1ea 100644 --- a/inference-engine/tests_deprecated/unit/engines/vpu/mvnc/watchdog_tests.cpp +++ b/inference-engine/tests_deprecated/unit/engines/vpu/mvnc/watchdog_tests.cpp @@ -17,10 +17,10 @@ using ms = std::chrono::milliseconds; class MockWatchdogDevice : public Watchdog::IDevice { public: using time_point = Watchdog::IDevice::time_point; - MOCK_QUALIFIED_METHOD1(keepAlive, noexcept, void(const time_point &)); - MOCK_QUALIFIED_METHOD1(dueIn, const noexcept, std::chrono::milliseconds (const time_point ¤t_time)); - MOCK_QUALIFIED_METHOD0(isTimeout, const noexcept, bool ()); - MOCK_QUALIFIED_METHOD0(getHandle, const noexcept, void* ()); + MOCK_METHOD(void, keepAlive, (const time_point &), (noexcept)); + MOCK_METHOD(std::chrono::milliseconds, dueIn, (const time_point ¤t_time), (const, noexcept)); + MOCK_METHOD(bool, isTimeout, (), (const, noexcept)); + MOCK_METHOD(void *, getHandle, (), (const, noexcept)); }; class MVNCWatchdogTests: public TestsCommon { diff --git a/inference-engine/tests_deprecated/unit/engines/vpu/mvnc/xlink_device_tests.cpp b/inference-engine/tests_deprecated/unit/engines/vpu/mvnc/xlink_device_tests.cpp index 555caa04a95456..400c84e1cd0055 100644 --- a/inference-engine/tests_deprecated/unit/engines/vpu/mvnc/xlink_device_tests.cpp +++ b/inference-engine/tests_deprecated/unit/engines/vpu/mvnc/xlink_device_tests.cpp @@ -34,6 +34,6 @@ TEST_P(XLinkDeviceTestsWithParam, shouldNotCreateXlinkDeviceWithInvalidInterval) xlink_device_destroy(deviceHndl); } -INSTANTIATE_TEST_CASE_P(WatchdogDevice, +INSTANTIATE_TEST_SUITE_P(WatchdogDevice, XLinkDeviceTestsWithParam, testing::Values(0, -1, -WATCHDOG_MAX_PING_INTERVAL_MS)); diff --git a/inference-engine/tests_deprecated/unit/engines/vpu/myriad_tests/helpers/myriad_mvnc_stub.h b/inference-engine/tests_deprecated/unit/engines/vpu/myriad_tests/helpers/myriad_mvnc_stub.h index 2a52228fe938c4..b9541c789593cb 100644 --- a/inference-engine/tests_deprecated/unit/engines/vpu/myriad_tests/helpers/myriad_mvnc_stub.h +++ b/inference-engine/tests_deprecated/unit/engines/vpu/myriad_tests/helpers/myriad_mvnc_stub.h @@ -17,8 +17,8 @@ using namespace vpu::MyriadPlugin; class MvncStub : public IMvnc { public: //Operations - MOCK_QUALIFIED_METHOD0(AvailableDevicesNames, const, std::vector()); - MOCK_QUALIFIED_METHOD0(AvailableDevicesDesc, const, std::vector()); + MOCK_CONST_METHOD0(AvailableDevicesNames, std::vector()); + MOCK_CONST_METHOD0(AvailableDevicesDesc, std::vector()); MOCK_METHOD0(watchdogHndl, WatchdogHndl_t*()); diff --git a/inference-engine/tests_deprecated/unit/engines/vpu/myriad_tests/myriad_engine_tests.cpp b/inference-engine/tests_deprecated/unit/engines/vpu/myriad_tests/myriad_engine_tests.cpp index ab437ab8774455..5fc90e2e678241 100644 --- a/inference-engine/tests_deprecated/unit/engines/vpu/myriad_tests/myriad_engine_tests.cpp +++ b/inference-engine/tests_deprecated/unit/engines/vpu/myriad_tests/myriad_engine_tests.cpp @@ -104,32 +104,32 @@ static const std::vector myriadIncorrectPackageTypeConfigValues = { IE_SUPPRESS_DEPRECATED_END /// Platform -INSTANTIATE_TEST_CASE_P(MyriadPlatformConfigs, MyriadEngineSetCorrectConfigTest, +INSTANTIATE_TEST_SUITE_P(MyriadPlatformConfigs, MyriadEngineSetCorrectConfigTest, ::testing::ValuesIn(myriadCorrectPlatformConfigValues)); -INSTANTIATE_TEST_CASE_P(MyriadPlatformConfigs, MyriadEngineSetIncorrectConfigTest, +INSTANTIATE_TEST_SUITE_P(MyriadPlatformConfigs, MyriadEngineSetIncorrectConfigTest, ::testing::ValuesIn(myriadIncorrectPlatformConfigValues)); /// Protocol -INSTANTIATE_TEST_CASE_P(MyriadProtocolConfigs, MyriadEngineSetCorrectConfigTest, +INSTANTIATE_TEST_SUITE_P(MyriadProtocolConfigs, MyriadEngineSetCorrectConfigTest, ::testing::ValuesIn(myriadCorrectProtocolConfigValues)); -INSTANTIATE_TEST_CASE_P(MyriadProtocolConfigs, MyriadEngineSetIncorrectConfigTest, +INSTANTIATE_TEST_SUITE_P(MyriadProtocolConfigs, MyriadEngineSetIncorrectConfigTest, ::testing::ValuesIn(myriadIncorrectProtocolConfigValues)); /// Config combinations -INSTANTIATE_TEST_CASE_P(MyriadConfigOptionsCombination, MyriadEngineSetCorrectConfigTest, +INSTANTIATE_TEST_SUITE_P(MyriadConfigOptionsCombination, MyriadEngineSetCorrectConfigTest, ::testing::ValuesIn(myriadCorrectConfigCombinationValues)); /// Power Config -INSTANTIATE_TEST_CASE_P(MyriadPowerConfigs, MyriadEngineSetCorrectConfigTest, +INSTANTIATE_TEST_SUITE_P(MyriadPowerConfigs, MyriadEngineSetCorrectConfigTest, ::testing::ValuesIn(myriadCorrectPowerConfigValues)); -INSTANTIATE_TEST_CASE_P(MyriadPowerConfigs, MyriadEngineSetIncorrectConfigTest, +INSTANTIATE_TEST_SUITE_P(MyriadPowerConfigs, MyriadEngineSetIncorrectConfigTest, ::testing::ValuesIn(myriadIncorrectPowerConfigValues)); /// Package Config -INSTANTIATE_TEST_CASE_P(MyriadPackageConfigs, MyriadEngineSetCorrectConfigTest, +INSTANTIATE_TEST_SUITE_P(MyriadPackageConfigs, MyriadEngineSetCorrectConfigTest, ::testing::ValuesIn(myriadCorrectPackageTypeConfigValues)); -INSTANTIATE_TEST_CASE_P(MyriadPackageConfigs, MyriadEngineSetIncorrectConfigTest, +INSTANTIATE_TEST_SUITE_P(MyriadPackageConfigs, MyriadEngineSetIncorrectConfigTest, ::testing::ValuesIn(myriadIncorrectPackageTypeConfigValues)); diff --git a/inference-engine/tests_deprecated/unit/engines/vpu/myriad_tests/myriad_metrics_tests.cpp b/inference-engine/tests_deprecated/unit/engines/vpu/myriad_tests/myriad_metrics_tests.cpp index 55879599166831..2c27aea933f142 100644 --- a/inference-engine/tests_deprecated/unit/engines/vpu/myriad_tests/myriad_metrics_tests.cpp +++ b/inference-engine/tests_deprecated/unit/engines/vpu/myriad_tests/myriad_metrics_tests.cpp @@ -193,14 +193,14 @@ TEST_P(MyriadRangeInferMetricsTestWithParam, CheckValues) { ASSERT_TRUE(act_res == exp_range_); } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( MetricsTest, MyriadGetMetricsTestCaseWithParam, ::testing::Values(std::vector {}, std::vector {"2.1-ma2480"}, std::vector {"2.1-ma2480", "3.1-ma2085"})); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( MetricsTest, MyriadDeviceMetricsTestWithParam, Combine(::testing::Values(std::vector {}, @@ -210,7 +210,7 @@ INSTANTIATE_TEST_CASE_P( std::vector {"1.4-ma2455"}, std::vector {"1.1-ma2080", "3.3-ma2085"}))); -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( MetricsTest, MyriadRangeInferMetricsTestWithParam, ::testing::Values(std::tuple(range_type(3,6,1), "-1"), diff --git a/inference-engine/tests_deprecated/unit/graph_tools/graph_copy_tests.cpp b/inference-engine/tests_deprecated/unit/graph_tools/graph_copy_tests.cpp index c9a1e8bb2187eb..3dfe1293624717 100644 --- a/inference-engine/tests_deprecated/unit/graph_tools/graph_copy_tests.cpp +++ b/inference-engine/tests_deprecated/unit/graph_tools/graph_copy_tests.cpp @@ -7,9 +7,7 @@ #include #include #include -#include -#include -#include +#include #include "ie_common.h" #include #include "graph_test_base.hpp" diff --git a/inference-engine/tests_deprecated/unit/graph_tools/graph_tools_test.cpp b/inference-engine/tests_deprecated/unit/graph_tools/graph_tools_test.cpp index 71b1f6ec46d2b1..f96bf8e8abd75f 100644 --- a/inference-engine/tests_deprecated/unit/graph_tools/graph_tools_test.cpp +++ b/inference-engine/tests_deprecated/unit/graph_tools/graph_tools_test.cpp @@ -7,9 +7,7 @@ #include #include "graph_test_base.hpp" #include -#include -#include -#include +#include #include "ie_common.h" #include #include diff --git a/inference-engine/tests_deprecated/unit/inference_engine_tests/get_num_iterations_test.cpp b/inference-engine/tests_deprecated/unit/inference_engine_tests/get_num_iterations_test.cpp index 01fb9f61163ba5..830cab7cc4cc88 100644 --- a/inference-engine/tests_deprecated/unit/inference_engine_tests/get_num_iterations_test.cpp +++ b/inference-engine/tests_deprecated/unit/inference_engine_tests/get_num_iterations_test.cpp @@ -147,7 +147,7 @@ using GetNumIterationsInvalidAxisTests = GetNumIterationsNegativeTests; TEST_P(GetNumIterationsInvalidAxisTests, InvalidAxisThrowsAnException) { ASSERT_ANY_THROW(Run()); } -INSTANTIATE_TEST_CASE_P(NumIterationsTest, GetNumIterationsInvalidAxisTests, testing::Values( +INSTANTIATE_TEST_SUITE_P(NumIterationsTest, GetNumIterationsInvalidAxisTests, testing::Values( NegativeTestParams{{{1}}, {{From{0}, Axis{-2}, Start{0}, Stride{1}, End{1}}}, {}, {}}, NegativeTestParams{{{1}}, {{From{0}, Axis{10}, Start{0}, Stride{1}, End{1}}}, {}, {}}, NegativeTestParams{{{1}, {1, 2}}, {{From{0}, Axis{-2}, Start{0}, Stride{1}, End{1}}}, {}, {}}, @@ -177,7 +177,7 @@ using GetNumIterationsInvalidStartTests = GetNumIterationsNegativeTests; TEST_P(GetNumIterationsInvalidStartTests, InvalidStartThrowsAnException) { ASSERT_ANY_THROW(Run()); } -INSTANTIATE_TEST_CASE_P(NumIterationsTest, GetNumIterationsInvalidStartTests, testing::Values( +INSTANTIATE_TEST_SUITE_P(NumIterationsTest, GetNumIterationsInvalidStartTests, testing::Values( NegativeTestParams{{{1}}, {{From{0}, Axis{0}, Start{2}, Stride{1}, End{1}}}, {}, {}}, NegativeTestParams{{{1}, {1, 2}}, {{From{0}, Axis{0}, Start{2}, Stride{1}, End{1}}}, {}, {}}, NegativeTestParams{{{1}, {1, 2}}, {{From{1}, Axis{0}, Start{2}, Stride{1}, End{1}}}, {}, {}}, @@ -193,7 +193,7 @@ using GetNumIterationsInvalidEndTests = GetNumIterationsNegativeTests; TEST_P(GetNumIterationsInvalidEndTests, InvalidEndThrowsAnException) { ASSERT_ANY_THROW(Run()); } -INSTANTIATE_TEST_CASE_P(NumIterationsTest, GetNumIterationsInvalidEndTests, testing::Values( +INSTANTIATE_TEST_SUITE_P(NumIterationsTest, GetNumIterationsInvalidEndTests, testing::Values( NegativeTestParams{{}, {}, {{1}}, {{From{0}, Axis{0}, Start{0}, Stride{1}, End{2}}}}, NegativeTestParams{{}, {}, {{1}, {1, 2}}, {{From{0}, Axis{0}, Start{0}, Stride{1}, End{2}}}}, NegativeTestParams{{}, {}, {{1}, {1, 2}}, {{From{1}, Axis{0}, Start{0}, Stride{1}, End{2}}}} @@ -203,7 +203,7 @@ using GetNumIterationsInvalidStrideTests = GetNumIterationsNegativeTests; TEST_P(GetNumIterationsInvalidStrideTests, InvalidStrideThrowsAnException) { ASSERT_ANY_THROW(Run()); } -INSTANTIATE_TEST_CASE_P(NumIterationsTest, GetNumIterationsInvalidStrideTests, testing::Values( +INSTANTIATE_TEST_SUITE_P(NumIterationsTest, GetNumIterationsInvalidStrideTests, testing::Values( NegativeTestParams{{{1}}, {{From{0}, Axis{0}, Start{0}, Stride{0}, End{1}}}, {}, {}}, NegativeTestParams{{}, {}, {{1}}, {{From{0}, Axis{0}, Start{0}, Stride{0}, End{1}}}} )); @@ -212,7 +212,7 @@ using GetNumIterationsInvalidFromTests = GetNumIterationsNegativeTests; TEST_P(GetNumIterationsInvalidFromTests, InvalidFromThrowsAnException) { ASSERT_ANY_THROW(Run()); } -INSTANTIATE_TEST_CASE_P(NumIterationsTest, GetNumIterationsInvalidFromTests, testing::Values( +INSTANTIATE_TEST_SUITE_P(NumIterationsTest, GetNumIterationsInvalidFromTests, testing::Values( NegativeTestParams{{{1}}, {{From{-1}, Axis{0}, Start{0}, Stride{1}, End{1}}}, {}, {}}, NegativeTestParams{{{1}}, {{From{1}, Axis{0}, Start{0}, Stride{1}, End{1}}}, {}, {}}, @@ -224,7 +224,7 @@ using GetNumIterationsInvalidDirectionTests = GetNumIterationsNegativeTests; TEST_P(GetNumIterationsInvalidDirectionTests, InvalidDirectionThrowsAnException) { ASSERT_ANY_THROW(Run()); } -INSTANTIATE_TEST_CASE_P(NumIterationsTest, GetNumIterationsInvalidDirectionTests, testing::Values( +INSTANTIATE_TEST_SUITE_P(NumIterationsTest, GetNumIterationsInvalidDirectionTests, testing::Values( NegativeTestParams{{{10}}, {{From{0}, Axis{0}, Start{8}, Stride{1}, End{2}}}, {}, {}}, NegativeTestParams{{{10}}, {{From{0}, Axis{0}, Start{2}, Stride{-1}, End{8}}}, {}, {}}, @@ -236,7 +236,7 @@ using GetNumIterationsInvalidStepTests = GetNumIterationsNegativeTests; TEST_P(GetNumIterationsInvalidStepTests, InvalidStepThrowsAnException) { ASSERT_ANY_THROW(Run()); } -INSTANTIATE_TEST_CASE_P(NumIterationsTest, GetNumIterationsInvalidStepTests, testing::Values( +INSTANTIATE_TEST_SUITE_P(NumIterationsTest, GetNumIterationsInvalidStepTests, testing::Values( NegativeTestParams{{{10}}, {{From{0}, Axis{0}, Start{2}, Stride{3}, End{6}}}, {}, {}}, NegativeTestParams{{{10}}, {{From{0}, Axis{0}, Start{2}, Stride{8}, End{6}}}, {}, {}}, NegativeTestParams{{{10}}, {{From{0}, Axis{0}, Start{6}, Stride{-3}, End{2}}}, {}, {}}, @@ -252,7 +252,7 @@ using GetNumIterationsInvalidIterationNumbersTests = GetNumIterationsNegativeTes TEST_P(GetNumIterationsInvalidIterationNumbersTests, InvalidInterationNumbersThrowAnException) { ASSERT_ANY_THROW(Run()); } -INSTANTIATE_TEST_CASE_P(NumIterationsTest, GetNumIterationsInvalidIterationNumbersTests, testing::Values( +INSTANTIATE_TEST_SUITE_P(NumIterationsTest, GetNumIterationsInvalidIterationNumbersTests, testing::Values( NegativeTestParams{ { {1, 3, 24, 24}, @@ -473,6 +473,6 @@ std::vector g_positiveTestParameters = { {{{13}}, {{From{0}, Axis{0}, Start{ 10}, Stride{-1}, End{-11}}}, {}, {}, 7}, {{{13}}, {{From{0}, Axis{0}, Start{ 9}, Stride{-2}, End{-11}}}, {}, {}, 3} }; -INSTANTIATE_TEST_CASE_P(NumIterationsTest, GetNumIterationsPositiveTests, testing::ValuesIn(g_positiveTestParameters)); +INSTANTIATE_TEST_SUITE_P(NumIterationsTest, GetNumIterationsPositiveTests, testing::ValuesIn(g_positiveTestParameters)); } diff --git a/inference-engine/thirdparty/clDNN/CMakeLists.txt b/inference-engine/thirdparty/clDNN/CMakeLists.txt index 41833b58dc58f2..4106e0522cb9d2 100644 --- a/inference-engine/thirdparty/clDNN/CMakeLists.txt +++ b/inference-engine/thirdparty/clDNN/CMakeLists.txt @@ -92,9 +92,6 @@ set(CLDNN__OCL_ICD_DIR "${CLDNN__COMMON_DIR}/khronos_ocl_icd") # Path which points to directory with C++ bindings for OpenCL (header files + wrapper that disables specific warnings). set(CLDNN__KHR_CLHPP_DIR "${CLDNN__COMMON_DIR}/include") -# Path which points to directory with fused version of googletest framework (with fused googlemock as well). -set(CLDNN__GTEST_DIR "${CLDNN__COMMON_DIR}/googletest-fused") - # Build targets settings. # Path which points to default root directory for compilation output. diff --git a/inference-engine/thirdparty/clDNN/common/googletest-fused/License.txt b/inference-engine/thirdparty/clDNN/common/googletest-fused/License.txt deleted file mode 100644 index 65c76c50ce257c..00000000000000 --- a/inference-engine/thirdparty/clDNN/common/googletest-fused/License.txt +++ /dev/null @@ -1,28 +0,0 @@ -Copyright 2008, Google Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/inference-engine/thirdparty/clDNN/common/googletest-fused/gmock-gtest-all.cc b/inference-engine/thirdparty/clDNN/common/googletest-fused/gmock-gtest-all.cc deleted file mode 100644 index 272563d970d039..00000000000000 --- a/inference-engine/thirdparty/clDNN/common/googletest-fused/gmock-gtest-all.cc +++ /dev/null @@ -1,13278 +0,0 @@ -// Copyright 2008, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: mheule@google.com (Markus Heule) -// -// Google C++ Testing and Mocking Framework (Google Test) -// -// Sometimes it's desirable to build Google Test by compiling a single file. -// This file serves this purpose. - -// This line ensures that gtest.h can be compiled on its own, even -// when it's fused. -#include "gtest/gtest.h" - -// The following lines pull in the real gtest *.cc files. -// Copyright 2005, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) -// -// The Google C++ Testing and Mocking Framework (Google Test) - -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) -// -// Utilities for testing Google Test itself and code that uses Google Test -// (e.g. frameworks built on top of Google Test). - -#ifndef GTEST_INCLUDE_GTEST_GTEST_SPI_H_ -#define GTEST_INCLUDE_GTEST_GTEST_SPI_H_ - - -namespace testing { - -// This helper class can be used to mock out Google Test failure reporting -// so that we can test Google Test or code that builds on Google Test. -// -// An object of this class appends a TestPartResult object to the -// TestPartResultArray object given in the constructor whenever a Google Test -// failure is reported. It can either intercept only failures that are -// generated in the same thread that created this object or it can intercept -// all generated failures. The scope of this mock object can be controlled with -// the second argument to the two arguments constructor. -class GTEST_API_ ScopedFakeTestPartResultReporter - : public TestPartResultReporterInterface { - public: - // The two possible mocking modes of this object. - enum InterceptMode { - INTERCEPT_ONLY_CURRENT_THREAD, // Intercepts only thread local failures. - INTERCEPT_ALL_THREADS // Intercepts all failures. - }; - - // The c'tor sets this object as the test part result reporter used - // by Google Test. The 'result' parameter specifies where to report the - // results. This reporter will only catch failures generated in the current - // thread. DEPRECATED - explicit ScopedFakeTestPartResultReporter(TestPartResultArray* result); - - // Same as above, but you can choose the interception scope of this object. - ScopedFakeTestPartResultReporter(InterceptMode intercept_mode, - TestPartResultArray* result); - - // The d'tor restores the previous test part result reporter. - virtual ~ScopedFakeTestPartResultReporter(); - - // Appends the TestPartResult object to the TestPartResultArray - // received in the constructor. - // - // This method is from the TestPartResultReporterInterface - // interface. - virtual void ReportTestPartResult(const TestPartResult& result); - private: - void Init(); - - const InterceptMode intercept_mode_; - TestPartResultReporterInterface* old_reporter_; - TestPartResultArray* const result_; - - GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedFakeTestPartResultReporter); -}; - -namespace internal { - -// A helper class for implementing EXPECT_FATAL_FAILURE() and -// EXPECT_NONFATAL_FAILURE(). Its destructor verifies that the given -// TestPartResultArray contains exactly one failure that has the given -// type and contains the given substring. If that's not the case, a -// non-fatal failure will be generated. -class GTEST_API_ SingleFailureChecker { - public: - // The constructor remembers the arguments. - SingleFailureChecker(const TestPartResultArray* results, - TestPartResult::Type type, const std::string& substr); - ~SingleFailureChecker(); - private: - const TestPartResultArray* const results_; - const TestPartResult::Type type_; - const std::string substr_; - - GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker); -}; - -} // namespace internal - -} // namespace testing - -// A set of macros for testing Google Test assertions or code that's expected -// to generate Google Test fatal failures. It verifies that the given -// statement will cause exactly one fatal Google Test failure with 'substr' -// being part of the failure message. -// -// There are two different versions of this macro. EXPECT_FATAL_FAILURE only -// affects and considers failures generated in the current thread and -// EXPECT_FATAL_FAILURE_ON_ALL_THREADS does the same but for all threads. -// -// The verification of the assertion is done correctly even when the statement -// throws an exception or aborts the current function. -// -// Known restrictions: -// - 'statement' cannot reference local non-static variables or -// non-static members of the current object. -// - 'statement' cannot return a value. -// - You cannot stream a failure message to this macro. -// -// Note that even though the implementations of the following two -// macros are much alike, we cannot refactor them to use a common -// helper macro, due to some peculiarity in how the preprocessor -// works. The AcceptsMacroThatExpandsToUnprotectedComma test in -// gtest_unittest.cc will fail to compile if we do that. -#define EXPECT_FATAL_FAILURE(statement, substr) \ - do { \ - class GTestExpectFatalFailureHelper {\ - public:\ - static void Execute() { statement; }\ - };\ - ::testing::TestPartResultArray gtest_failures;\ - ::testing::internal::SingleFailureChecker gtest_checker(\ - >est_failures, ::testing::TestPartResult::kFatalFailure, (substr));\ - {\ - ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ - ::testing::ScopedFakeTestPartResultReporter:: \ - INTERCEPT_ONLY_CURRENT_THREAD, >est_failures);\ - GTestExpectFatalFailureHelper::Execute();\ - }\ - } while (::testing::internal::AlwaysFalse()) - -#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr) \ - do { \ - class GTestExpectFatalFailureHelper {\ - public:\ - static void Execute() { statement; }\ - };\ - ::testing::TestPartResultArray gtest_failures;\ - ::testing::internal::SingleFailureChecker gtest_checker(\ - >est_failures, ::testing::TestPartResult::kFatalFailure, (substr));\ - {\ - ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ - ::testing::ScopedFakeTestPartResultReporter:: \ - INTERCEPT_ALL_THREADS, >est_failures);\ - GTestExpectFatalFailureHelper::Execute();\ - }\ - } while (::testing::internal::AlwaysFalse()) - -// A macro for testing Google Test assertions or code that's expected to -// generate Google Test non-fatal failures. It asserts that the given -// statement will cause exactly one non-fatal Google Test failure with 'substr' -// being part of the failure message. -// -// There are two different versions of this macro. EXPECT_NONFATAL_FAILURE only -// affects and considers failures generated in the current thread and -// EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS does the same but for all threads. -// -// 'statement' is allowed to reference local variables and members of -// the current object. -// -// The verification of the assertion is done correctly even when the statement -// throws an exception or aborts the current function. -// -// Known restrictions: -// - You cannot stream a failure message to this macro. -// -// Note that even though the implementations of the following two -// macros are much alike, we cannot refactor them to use a common -// helper macro, due to some peculiarity in how the preprocessor -// works. If we do that, the code won't compile when the user gives -// EXPECT_NONFATAL_FAILURE() a statement that contains a macro that -// expands to code containing an unprotected comma. The -// AcceptsMacroThatExpandsToUnprotectedComma test in gtest_unittest.cc -// catches that. -// -// For the same reason, we have to write -// if (::testing::internal::AlwaysTrue()) { statement; } -// instead of -// GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) -// to avoid an MSVC warning on unreachable code. -#define EXPECT_NONFATAL_FAILURE(statement, substr) \ - do {\ - ::testing::TestPartResultArray gtest_failures;\ - ::testing::internal::SingleFailureChecker gtest_checker(\ - >est_failures, ::testing::TestPartResult::kNonFatalFailure, \ - (substr));\ - {\ - ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ - ::testing::ScopedFakeTestPartResultReporter:: \ - INTERCEPT_ONLY_CURRENT_THREAD, >est_failures);\ - if (::testing::internal::AlwaysTrue()) { statement; }\ - }\ - } while (::testing::internal::AlwaysFalse()) - -#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr) \ - do {\ - ::testing::TestPartResultArray gtest_failures;\ - ::testing::internal::SingleFailureChecker gtest_checker(\ - >est_failures, ::testing::TestPartResult::kNonFatalFailure, \ - (substr));\ - {\ - ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ - ::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS, \ - >est_failures);\ - if (::testing::internal::AlwaysTrue()) { statement; }\ - }\ - } while (::testing::internal::AlwaysFalse()) - -#endif // GTEST_INCLUDE_GTEST_GTEST_SPI_H_ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include // NOLINT -#include -#include - -#if GTEST_OS_LINUX - -// TODO(kenton@google.com): Use autoconf to detect availability of -// gettimeofday(). -# define GTEST_HAS_GETTIMEOFDAY_ 1 - -# include // NOLINT -# include // NOLINT -# include // NOLINT -// Declares vsnprintf(). This header is not available on Windows. -# include // NOLINT -# include // NOLINT -# include // NOLINT -# include // NOLINT -# include - -#elif GTEST_OS_SYMBIAN -# define GTEST_HAS_GETTIMEOFDAY_ 1 -# include // NOLINT - -#elif GTEST_OS_ZOS -# define GTEST_HAS_GETTIMEOFDAY_ 1 -# include // NOLINT - -// On z/OS we additionally need strings.h for strcasecmp. -# include // NOLINT - -#elif GTEST_OS_WINDOWS_MOBILE // We are on Windows CE. - -# include // NOLINT -# undef min - -#elif GTEST_OS_WINDOWS // We are on Windows proper. - -# include // NOLINT -# include // NOLINT -# include // NOLINT -# include // NOLINT - -# if GTEST_OS_WINDOWS_MINGW -// MinGW has gettimeofday() but not _ftime64(). -// TODO(kenton@google.com): Use autoconf to detect availability of -// gettimeofday(). -// TODO(kenton@google.com): There are other ways to get the time on -// Windows, like GetTickCount() or GetSystemTimeAsFileTime(). MinGW -// supports these. consider using them instead. -# define GTEST_HAS_GETTIMEOFDAY_ 1 -# include // NOLINT -# endif // GTEST_OS_WINDOWS_MINGW - -// cpplint thinks that the header is already included, so we want to -// silence it. -# include // NOLINT -# undef min - -#else - -// Assume other platforms have gettimeofday(). -// TODO(kenton@google.com): Use autoconf to detect availability of -// gettimeofday(). -# define GTEST_HAS_GETTIMEOFDAY_ 1 - -// cpplint thinks that the header is already included, so we want to -// silence it. -# include // NOLINT -# include // NOLINT - -#endif // GTEST_OS_LINUX - -#if GTEST_HAS_EXCEPTIONS -# include -#endif - -#if GTEST_CAN_STREAM_RESULTS_ -# include // NOLINT -# include // NOLINT -# include // NOLINT -# include // NOLINT -#endif - -// Copyright 2005, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Utility functions and classes used by the Google C++ testing framework. -// -// Author: wan@google.com (Zhanyong Wan) -// -// This file contains purely Google Test's internal implementation. Please -// DO NOT #INCLUDE IT IN A USER PROGRAM. - -#ifndef GTEST_SRC_GTEST_INTERNAL_INL_H_ -#define GTEST_SRC_GTEST_INTERNAL_INL_H_ - -#ifndef _WIN32_WCE -# include -#endif // !_WIN32_WCE -#include -#include // For strtoll/_strtoul64/malloc/free. -#include // For memmove. - -#include -#include -#include - - -#if GTEST_CAN_STREAM_RESULTS_ -# include // NOLINT -# include // NOLINT -#endif - -#if GTEST_OS_WINDOWS -# include // NOLINT -#endif // GTEST_OS_WINDOWS - - -namespace testing { - -// Declares the flags. -// -// We don't want the users to modify this flag in the code, but want -// Google Test's own unit tests to be able to access it. Therefore we -// declare it here as opposed to in gtest.h. -GTEST_DECLARE_bool_(death_test_use_fork); - -namespace internal { - -// The value of GetTestTypeId() as seen from within the Google Test -// library. This is solely for testing GetTestTypeId(). -GTEST_API_ extern const TypeId kTestTypeIdInGoogleTest; - -// Names of the flags (needed for parsing Google Test flags). -const char kAlsoRunDisabledTestsFlag[] = "also_run_disabled_tests"; -const char kBreakOnFailureFlag[] = "break_on_failure"; -const char kCatchExceptionsFlag[] = "catch_exceptions"; -const char kColorFlag[] = "color"; -const char kFilterFlag[] = "filter"; -const char kListTestsFlag[] = "list_tests"; -const char kOutputFlag[] = "output"; -const char kPrintTimeFlag[] = "print_time"; -const char kPrintUTF8Flag[] = "print_utf8"; -const char kRandomSeedFlag[] = "random_seed"; -const char kRepeatFlag[] = "repeat"; -const char kShuffleFlag[] = "shuffle"; -const char kStackTraceDepthFlag[] = "stack_trace_depth"; -const char kStreamResultToFlag[] = "stream_result_to"; -const char kThrowOnFailureFlag[] = "throw_on_failure"; -const char kFlagfileFlag[] = "flagfile"; - -// A valid random seed must be in [1, kMaxRandomSeed]. -const int kMaxRandomSeed = 99999; - -// g_help_flag is true iff the --help flag or an equivalent form is -// specified on the command line. -GTEST_API_ extern bool g_help_flag; - -// Returns the current time in milliseconds. -GTEST_API_ TimeInMillis GetTimeInMillis(); - -// Returns true iff Google Test should use colors in the output. -GTEST_API_ bool ShouldUseColor(bool stdout_is_tty); - -// Formats the given time in milliseconds as seconds. -GTEST_API_ std::string FormatTimeInMillisAsSeconds(TimeInMillis ms); - -// Converts the given time in milliseconds to a date string in the ISO 8601 -// format, without the timezone information. N.B.: due to the use the -// non-reentrant localtime() function, this function is not thread safe. Do -// not use it in any code that can be called from multiple threads. -GTEST_API_ std::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms); - -// Parses a string for an Int32 flag, in the form of "--flag=value". -// -// On success, stores the value of the flag in *value, and returns -// true. On failure, returns false without changing *value. -GTEST_API_ bool ParseInt32Flag( - const char* str, const char* flag, Int32* value); - -// Returns a random seed in range [1, kMaxRandomSeed] based on the -// given --gtest_random_seed flag value. -inline int GetRandomSeedFromFlag(Int32 random_seed_flag) { - const unsigned int raw_seed = (random_seed_flag == 0) ? - static_cast(GetTimeInMillis()) : - static_cast(random_seed_flag); - - // Normalizes the actual seed to range [1, kMaxRandomSeed] such that - // it's easy to type. - const int normalized_seed = - static_cast((raw_seed - 1U) % - static_cast(kMaxRandomSeed)) + 1; - return normalized_seed; -} - -// Returns the first valid random seed after 'seed'. The behavior is -// undefined if 'seed' is invalid. The seed after kMaxRandomSeed is -// considered to be 1. -inline int GetNextRandomSeed(int seed) { - GTEST_CHECK_(1 <= seed && seed <= kMaxRandomSeed) - << "Invalid random seed " << seed << " - must be in [1, " - << kMaxRandomSeed << "]."; - const int next_seed = seed + 1; - return (next_seed > kMaxRandomSeed) ? 1 : next_seed; -} - -// This class saves the values of all Google Test flags in its c'tor, and -// restores them in its d'tor. -class GTestFlagSaver { - public: - // The c'tor. - GTestFlagSaver() { - also_run_disabled_tests_ = GTEST_FLAG(also_run_disabled_tests); - break_on_failure_ = GTEST_FLAG(break_on_failure); - catch_exceptions_ = GTEST_FLAG(catch_exceptions); - color_ = GTEST_FLAG(color); - death_test_style_ = GTEST_FLAG(death_test_style); - death_test_use_fork_ = GTEST_FLAG(death_test_use_fork); - filter_ = GTEST_FLAG(filter); - internal_run_death_test_ = GTEST_FLAG(internal_run_death_test); - list_tests_ = GTEST_FLAG(list_tests); - output_ = GTEST_FLAG(output); - print_time_ = GTEST_FLAG(print_time); - print_utf8_ = GTEST_FLAG(print_utf8); - random_seed_ = GTEST_FLAG(random_seed); - repeat_ = GTEST_FLAG(repeat); - shuffle_ = GTEST_FLAG(shuffle); - stack_trace_depth_ = GTEST_FLAG(stack_trace_depth); - stream_result_to_ = GTEST_FLAG(stream_result_to); - throw_on_failure_ = GTEST_FLAG(throw_on_failure); - } - - // The d'tor is not virtual. DO NOT INHERIT FROM THIS CLASS. - ~GTestFlagSaver() { - GTEST_FLAG(also_run_disabled_tests) = also_run_disabled_tests_; - GTEST_FLAG(break_on_failure) = break_on_failure_; - GTEST_FLAG(catch_exceptions) = catch_exceptions_; - GTEST_FLAG(color) = color_; - GTEST_FLAG(death_test_style) = death_test_style_; - GTEST_FLAG(death_test_use_fork) = death_test_use_fork_; - GTEST_FLAG(filter) = filter_; - GTEST_FLAG(internal_run_death_test) = internal_run_death_test_; - GTEST_FLAG(list_tests) = list_tests_; - GTEST_FLAG(output) = output_; - GTEST_FLAG(print_time) = print_time_; - GTEST_FLAG(print_utf8) = print_utf8_; - GTEST_FLAG(random_seed) = random_seed_; - GTEST_FLAG(repeat) = repeat_; - GTEST_FLAG(shuffle) = shuffle_; - GTEST_FLAG(stack_trace_depth) = stack_trace_depth_; - GTEST_FLAG(stream_result_to) = stream_result_to_; - GTEST_FLAG(throw_on_failure) = throw_on_failure_; - } - - private: - // Fields for saving the original values of flags. - bool also_run_disabled_tests_; - bool break_on_failure_; - bool catch_exceptions_; - std::string color_; - std::string death_test_style_; - bool death_test_use_fork_; - std::string filter_; - std::string internal_run_death_test_; - bool list_tests_; - std::string output_; - bool print_time_; - bool print_utf8_; - internal::Int32 random_seed_; - internal::Int32 repeat_; - bool shuffle_; - internal::Int32 stack_trace_depth_; - std::string stream_result_to_; - bool throw_on_failure_; -} GTEST_ATTRIBUTE_UNUSED_; - -// Converts a Unicode code point to a narrow string in UTF-8 encoding. -// code_point parameter is of type UInt32 because wchar_t may not be -// wide enough to contain a code point. -// If the code_point is not a valid Unicode code point -// (i.e. outside of Unicode range U+0 to U+10FFFF) it will be converted -// to "(Invalid Unicode 0xXXXXXXXX)". -GTEST_API_ std::string CodePointToUtf8(UInt32 code_point); - -// Converts a wide string to a narrow string in UTF-8 encoding. -// The wide string is assumed to have the following encoding: -// UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin, Symbian OS) -// UTF-32 if sizeof(wchar_t) == 4 (on Linux) -// Parameter str points to a null-terminated wide string. -// Parameter num_chars may additionally limit the number -// of wchar_t characters processed. -1 is used when the entire string -// should be processed. -// If the string contains code points that are not valid Unicode code points -// (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output -// as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding -// and contains invalid UTF-16 surrogate pairs, values in those pairs -// will be encoded as individual Unicode characters from Basic Normal Plane. -GTEST_API_ std::string WideStringToUtf8(const wchar_t* str, int num_chars); - -// Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file -// if the variable is present. If a file already exists at this location, this -// function will write over it. If the variable is present, but the file cannot -// be created, prints an error and exits. -void WriteToShardStatusFileIfNeeded(); - -// Checks whether sharding is enabled by examining the relevant -// environment variable values. If the variables are present, -// but inconsistent (e.g., shard_index >= total_shards), prints -// an error and exits. If in_subprocess_for_death_test, sharding is -// disabled because it must only be applied to the original test -// process. Otherwise, we could filter out death tests we intended to execute. -GTEST_API_ bool ShouldShard(const char* total_shards_str, - const char* shard_index_str, - bool in_subprocess_for_death_test); - -// Parses the environment variable var as an Int32. If it is unset, -// returns default_val. If it is not an Int32, prints an error and -// and aborts. -GTEST_API_ Int32 Int32FromEnvOrDie(const char* env_var, Int32 default_val); - -// Given the total number of shards, the shard index, and the test id, -// returns true iff the test should be run on this shard. The test id is -// some arbitrary but unique non-negative integer assigned to each test -// method. Assumes that 0 <= shard_index < total_shards. -GTEST_API_ bool ShouldRunTestOnShard( - int total_shards, int shard_index, int test_id); - -// STL container utilities. - -// Returns the number of elements in the given container that satisfy -// the given predicate. -template -inline int CountIf(const Container& c, Predicate predicate) { - // Implemented as an explicit loop since std::count_if() in libCstd on - // Solaris has a non-standard signature. - int count = 0; - for (typename Container::const_iterator it = c.begin(); it != c.end(); ++it) { - if (predicate(*it)) - ++count; - } - return count; -} - -// Applies a function/functor to each element in the container. -template -void ForEach(const Container& c, Functor functor) { - std::for_each(c.begin(), c.end(), functor); -} - -// Returns the i-th element of the vector, or default_value if i is not -// in range [0, v.size()). -template -inline E GetElementOr(const std::vector& v, int i, E default_value) { - return (i < 0 || i >= static_cast(v.size())) ? default_value : v[i]; -} - -// Performs an in-place shuffle of a range of the vector's elements. -// 'begin' and 'end' are element indices as an STL-style range; -// i.e. [begin, end) are shuffled, where 'end' == size() means to -// shuffle to the end of the vector. -template -void ShuffleRange(internal::Random* random, int begin, int end, - std::vector* v) { - const int size = static_cast(v->size()); - GTEST_CHECK_(0 <= begin && begin <= size) - << "Invalid shuffle range start " << begin << ": must be in range [0, " - << size << "]."; - GTEST_CHECK_(begin <= end && end <= size) - << "Invalid shuffle range finish " << end << ": must be in range [" - << begin << ", " << size << "]."; - - // Fisher-Yates shuffle, from - // http://en.wikipedia.org/wiki/Fisher-Yates_shuffle - for (int range_width = end - begin; range_width >= 2; range_width--) { - const int last_in_range = begin + range_width - 1; - const int selected = begin + random->Generate(range_width); - std::swap((*v)[selected], (*v)[last_in_range]); - } -} - -// Performs an in-place shuffle of the vector's elements. -template -inline void Shuffle(internal::Random* random, std::vector* v) { - ShuffleRange(random, 0, static_cast(v->size()), v); -} - -// A function for deleting an object. Handy for being used as a -// functor. -template -static void Delete(T* x) { - delete x; -} - -// A predicate that checks the key of a TestProperty against a known key. -// -// TestPropertyKeyIs is copyable. -class TestPropertyKeyIs { - public: - // Constructor. - // - // TestPropertyKeyIs has NO default constructor. - explicit TestPropertyKeyIs(const std::string& key) : key_(key) {} - - // Returns true iff the test name of test property matches on key_. - bool operator()(const TestProperty& test_property) const { - return test_property.key() == key_; - } - - private: - std::string key_; -}; - -// Class UnitTestOptions. -// -// This class contains functions for processing options the user -// specifies when running the tests. It has only static members. -// -// In most cases, the user can specify an option using either an -// environment variable or a command line flag. E.g. you can set the -// test filter using either GTEST_FILTER or --gtest_filter. If both -// the variable and the flag are present, the latter overrides the -// former. -class GTEST_API_ UnitTestOptions { - public: - // Functions for processing the gtest_output flag. - - // Returns the output format, or "" for normal printed output. - static std::string GetOutputFormat(); - - // Returns the absolute path of the requested output file, or the - // default (test_detail.xml in the original working directory) if - // none was explicitly specified. - static std::string GetAbsolutePathToOutputFile(); - - // Functions for processing the gtest_filter flag. - - // Returns true iff the wildcard pattern matches the string. The - // first ':' or '\0' character in pattern marks the end of it. - // - // This recursive algorithm isn't very efficient, but is clear and - // works well enough for matching test names, which are short. - static bool PatternMatchesString(const char *pattern, const char *str); - - // Returns true iff the user-specified filter matches the test case - // name and the test name. - static bool FilterMatchesTest(const std::string &test_case_name, - const std::string &test_name); - -#if GTEST_OS_WINDOWS - // Function for supporting the gtest_catch_exception flag. - - // Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the - // given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise. - // This function is useful as an __except condition. - static int GTestShouldProcessSEH(DWORD exception_code); -#endif // GTEST_OS_WINDOWS - - // Returns true if "name" matches the ':' separated list of glob-style - // filters in "filter". - static bool MatchesFilter(const std::string& name, const char* filter); -}; - -// Returns the current application's name, removing directory path if that -// is present. Used by UnitTestOptions::GetOutputFile. -GTEST_API_ FilePath GetCurrentExecutableName(); - -// The role interface for getting the OS stack trace as a string. -class OsStackTraceGetterInterface { - public: - OsStackTraceGetterInterface() {} - virtual ~OsStackTraceGetterInterface() {} - - // Returns the current OS stack trace as an std::string. Parameters: - // - // max_depth - the maximum number of stack frames to be included - // in the trace. - // skip_count - the number of top frames to be skipped; doesn't count - // against max_depth. - virtual std::string CurrentStackTrace(int max_depth, int skip_count) = 0; - - // UponLeavingGTest() should be called immediately before Google Test calls - // user code. It saves some information about the current stack that - // CurrentStackTrace() will use to find and hide Google Test stack frames. - virtual void UponLeavingGTest() = 0; - - // This string is inserted in place of stack frames that are part of - // Google Test's implementation. - static const char* const kElidedFramesMarker; - - private: - GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetterInterface); -}; - -// A working implementation of the OsStackTraceGetterInterface interface. -class OsStackTraceGetter : public OsStackTraceGetterInterface { - public: - OsStackTraceGetter() {} - - virtual std::string CurrentStackTrace(int max_depth, int skip_count); - virtual void UponLeavingGTest(); - - private: -#if GTEST_HAS_ABSL - Mutex mutex_; // Protects all internal state. - - // We save the stack frame below the frame that calls user code. - // We do this because the address of the frame immediately below - // the user code changes between the call to UponLeavingGTest() - // and any calls to the stack trace code from within the user code. - void* caller_frame_ = nullptr; -#endif // GTEST_HAS_ABSL - - GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetter); -}; - -// Information about a Google Test trace point. -struct TraceInfo { - const char* file; - int line; - std::string message; -}; - -// This is the default global test part result reporter used in UnitTestImpl. -// This class should only be used by UnitTestImpl. -class DefaultGlobalTestPartResultReporter - : public TestPartResultReporterInterface { - public: - explicit DefaultGlobalTestPartResultReporter(UnitTestImpl* unit_test); - // Implements the TestPartResultReporterInterface. Reports the test part - // result in the current test. - virtual void ReportTestPartResult(const TestPartResult& result); - - private: - UnitTestImpl* const unit_test_; - - GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultGlobalTestPartResultReporter); -}; - -// This is the default per thread test part result reporter used in -// UnitTestImpl. This class should only be used by UnitTestImpl. -class DefaultPerThreadTestPartResultReporter - : public TestPartResultReporterInterface { - public: - explicit DefaultPerThreadTestPartResultReporter(UnitTestImpl* unit_test); - // Implements the TestPartResultReporterInterface. The implementation just - // delegates to the current global test part result reporter of *unit_test_. - virtual void ReportTestPartResult(const TestPartResult& result); - - private: - UnitTestImpl* const unit_test_; - - GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultPerThreadTestPartResultReporter); -}; - -// The private implementation of the UnitTest class. We don't protect -// the methods under a mutex, as this class is not accessible by a -// user and the UnitTest class that delegates work to this class does -// proper locking. -class GTEST_API_ UnitTestImpl { - public: - explicit UnitTestImpl(UnitTest* parent); - virtual ~UnitTestImpl(); - - // There are two different ways to register your own TestPartResultReporter. - // You can register your own repoter to listen either only for test results - // from the current thread or for results from all threads. - // By default, each per-thread test result repoter just passes a new - // TestPartResult to the global test result reporter, which registers the - // test part result for the currently running test. - - // Returns the global test part result reporter. - TestPartResultReporterInterface* GetGlobalTestPartResultReporter(); - - // Sets the global test part result reporter. - void SetGlobalTestPartResultReporter( - TestPartResultReporterInterface* reporter); - - // Returns the test part result reporter for the current thread. - TestPartResultReporterInterface* GetTestPartResultReporterForCurrentThread(); - - // Sets the test part result reporter for the current thread. - void SetTestPartResultReporterForCurrentThread( - TestPartResultReporterInterface* reporter); - - // Gets the number of successful test cases. - int successful_test_case_count() const; - - // Gets the number of failed test cases. - int failed_test_case_count() const; - - // Gets the number of all test cases. - int total_test_case_count() const; - - // Gets the number of all test cases that contain at least one test - // that should run. - int test_case_to_run_count() const; - - // Gets the number of successful tests. - int successful_test_count() const; - - // Gets the number of failed tests. - int failed_test_count() const; - - // Gets the number of disabled tests that will be reported in the XML report. - int reportable_disabled_test_count() const; - - // Gets the number of disabled tests. - int disabled_test_count() const; - - // Gets the number of tests to be printed in the XML report. - int reportable_test_count() const; - - // Gets the number of all tests. - int total_test_count() const; - - // Gets the number of tests that should run. - int test_to_run_count() const; - - // Gets the time of the test program start, in ms from the start of the - // UNIX epoch. - TimeInMillis start_timestamp() const { return start_timestamp_; } - - // Gets the elapsed time, in milliseconds. - TimeInMillis elapsed_time() const { return elapsed_time_; } - - // Returns true iff the unit test passed (i.e. all test cases passed). - bool Passed() const { return !Failed(); } - - // Returns true iff the unit test failed (i.e. some test case failed - // or something outside of all tests failed). - bool Failed() const { - return failed_test_case_count() > 0 || ad_hoc_test_result()->Failed(); - } - - // Gets the i-th test case among all the test cases. i can range from 0 to - // total_test_case_count() - 1. If i is not in that range, returns NULL. - const TestCase* GetTestCase(int i) const { - const int index = GetElementOr(test_case_indices_, i, -1); - return index < 0 ? NULL : test_cases_[i]; - } - - // Gets the i-th test case among all the test cases. i can range from 0 to - // total_test_case_count() - 1. If i is not in that range, returns NULL. - TestCase* GetMutableTestCase(int i) { - const int index = GetElementOr(test_case_indices_, i, -1); - return index < 0 ? NULL : test_cases_[index]; - } - - // Provides access to the event listener list. - TestEventListeners* listeners() { return &listeners_; } - - // Returns the TestResult for the test that's currently running, or - // the TestResult for the ad hoc test if no test is running. - TestResult* current_test_result(); - - // Returns the TestResult for the ad hoc test. - const TestResult* ad_hoc_test_result() const { return &ad_hoc_test_result_; } - - // Sets the OS stack trace getter. - // - // Does nothing if the input and the current OS stack trace getter - // are the same; otherwise, deletes the old getter and makes the - // input the current getter. - void set_os_stack_trace_getter(OsStackTraceGetterInterface* getter); - - // Returns the current OS stack trace getter if it is not NULL; - // otherwise, creates an OsStackTraceGetter, makes it the current - // getter, and returns it. - OsStackTraceGetterInterface* os_stack_trace_getter(); - - // Returns the current OS stack trace as an std::string. - // - // The maximum number of stack frames to be included is specified by - // the gtest_stack_trace_depth flag. The skip_count parameter - // specifies the number of top frames to be skipped, which doesn't - // count against the number of frames to be included. - // - // For example, if Foo() calls Bar(), which in turn calls - // CurrentOsStackTraceExceptTop(1), Foo() will be included in the - // trace but Bar() and CurrentOsStackTraceExceptTop() won't. - std::string CurrentOsStackTraceExceptTop(int skip_count) GTEST_NO_INLINE_; - - // Finds and returns a TestCase with the given name. If one doesn't - // exist, creates one and returns it. - // - // Arguments: - // - // test_case_name: name of the test case - // type_param: the name of the test's type parameter, or NULL if - // this is not a typed or a type-parameterized test. - // set_up_tc: pointer to the function that sets up the test case - // tear_down_tc: pointer to the function that tears down the test case - TestCase* GetTestCase(const char* test_case_name, - const char* type_param, - Test::SetUpTestCaseFunc set_up_tc, - Test::TearDownTestCaseFunc tear_down_tc); - - // Adds a TestInfo to the unit test. - // - // Arguments: - // - // set_up_tc: pointer to the function that sets up the test case - // tear_down_tc: pointer to the function that tears down the test case - // test_info: the TestInfo object - void AddTestInfo(Test::SetUpTestCaseFunc set_up_tc, - Test::TearDownTestCaseFunc tear_down_tc, - TestInfo* test_info) { - // In order to support thread-safe death tests, we need to - // remember the original working directory when the test program - // was first invoked. We cannot do this in RUN_ALL_TESTS(), as - // the user may have changed the current directory before calling - // RUN_ALL_TESTS(). Therefore we capture the current directory in - // AddTestInfo(), which is called to register a TEST or TEST_F - // before main() is reached. - if (original_working_dir_.IsEmpty()) { - original_working_dir_.Set(FilePath::GetCurrentDir()); - GTEST_CHECK_(!original_working_dir_.IsEmpty()) - << "Failed to get the current working directory."; - } - - GetTestCase(test_info->test_case_name(), - test_info->type_param(), - set_up_tc, - tear_down_tc)->AddTestInfo(test_info); - } - - // Returns ParameterizedTestCaseRegistry object used to keep track of - // value-parameterized tests and instantiate and register them. - internal::ParameterizedTestCaseRegistry& parameterized_test_registry() { - return parameterized_test_registry_; - } - - // Sets the TestCase object for the test that's currently running. - void set_current_test_case(TestCase* a_current_test_case) { - current_test_case_ = a_current_test_case; - } - - // Sets the TestInfo object for the test that's currently running. If - // current_test_info is NULL, the assertion results will be stored in - // ad_hoc_test_result_. - void set_current_test_info(TestInfo* a_current_test_info) { - current_test_info_ = a_current_test_info; - } - - // Registers all parameterized tests defined using TEST_P and - // INSTANTIATE_TEST_CASE_P, creating regular tests for each test/parameter - // combination. This method can be called more then once; it has guards - // protecting from registering the tests more then once. If - // value-parameterized tests are disabled, RegisterParameterizedTests is - // present but does nothing. - void RegisterParameterizedTests(); - - // Runs all tests in this UnitTest object, prints the result, and - // returns true if all tests are successful. If any exception is - // thrown during a test, this test is considered to be failed, but - // the rest of the tests will still be run. - bool RunAllTests(); - - // Clears the results of all tests, except the ad hoc tests. - void ClearNonAdHocTestResult() { - ForEach(test_cases_, TestCase::ClearTestCaseResult); - } - - // Clears the results of ad-hoc test assertions. - void ClearAdHocTestResult() { - ad_hoc_test_result_.Clear(); - } - - // Adds a TestProperty to the current TestResult object when invoked in a - // context of a test or a test case, or to the global property set. If the - // result already contains a property with the same key, the value will be - // updated. - void RecordProperty(const TestProperty& test_property); - - enum ReactionToSharding { - HONOR_SHARDING_PROTOCOL, - IGNORE_SHARDING_PROTOCOL - }; - - // Matches the full name of each test against the user-specified - // filter to decide whether the test should run, then records the - // result in each TestCase and TestInfo object. - // If shard_tests == HONOR_SHARDING_PROTOCOL, further filters tests - // based on sharding variables in the environment. - // Returns the number of tests that should run. - int FilterTests(ReactionToSharding shard_tests); - - // Prints the names of the tests matching the user-specified filter flag. - void ListTestsMatchingFilter(); - - const TestCase* current_test_case() const { return current_test_case_; } - TestInfo* current_test_info() { return current_test_info_; } - const TestInfo* current_test_info() const { return current_test_info_; } - - // Returns the vector of environments that need to be set-up/torn-down - // before/after the tests are run. - std::vector& environments() { return environments_; } - - // Getters for the per-thread Google Test trace stack. - std::vector& gtest_trace_stack() { - return *(gtest_trace_stack_.pointer()); - } - const std::vector& gtest_trace_stack() const { - return gtest_trace_stack_.get(); - } - -#if GTEST_HAS_DEATH_TEST - void InitDeathTestSubprocessControlInfo() { - internal_run_death_test_flag_.reset(ParseInternalRunDeathTestFlag()); - } - // Returns a pointer to the parsed --gtest_internal_run_death_test - // flag, or NULL if that flag was not specified. - // This information is useful only in a death test child process. - // Must not be called before a call to InitGoogleTest. - const InternalRunDeathTestFlag* internal_run_death_test_flag() const { - return internal_run_death_test_flag_.get(); - } - - // Returns a pointer to the current death test factory. - internal::DeathTestFactory* death_test_factory() { - return death_test_factory_.get(); - } - - void SuppressTestEventsIfInSubprocess(); - - friend class ReplaceDeathTestFactory; -#endif // GTEST_HAS_DEATH_TEST - - // Initializes the event listener performing XML output as specified by - // UnitTestOptions. Must not be called before InitGoogleTest. - void ConfigureXmlOutput(); - -#if GTEST_CAN_STREAM_RESULTS_ - // Initializes the event listener for streaming test results to a socket. - // Must not be called before InitGoogleTest. - void ConfigureStreamingOutput(); -#endif - - // Performs initialization dependent upon flag values obtained in - // ParseGoogleTestFlagsOnly. Is called from InitGoogleTest after the call to - // ParseGoogleTestFlagsOnly. In case a user neglects to call InitGoogleTest - // this function is also called from RunAllTests. Since this function can be - // called more than once, it has to be idempotent. - void PostFlagParsingInit(); - - // Gets the random seed used at the start of the current test iteration. - int random_seed() const { return random_seed_; } - - // Gets the random number generator. - internal::Random* random() { return &random_; } - - // Shuffles all test cases, and the tests within each test case, - // making sure that death tests are still run first. - void ShuffleTests(); - - // Restores the test cases and tests to their order before the first shuffle. - void UnshuffleTests(); - - // Returns the value of GTEST_FLAG(catch_exceptions) at the moment - // UnitTest::Run() starts. - bool catch_exceptions() const { return catch_exceptions_; } - - private: - friend class ::testing::UnitTest; - - // Used by UnitTest::Run() to capture the state of - // GTEST_FLAG(catch_exceptions) at the moment it starts. - void set_catch_exceptions(bool value) { catch_exceptions_ = value; } - - // The UnitTest object that owns this implementation object. - UnitTest* const parent_; - - // The working directory when the first TEST() or TEST_F() was - // executed. - internal::FilePath original_working_dir_; - - // The default test part result reporters. - DefaultGlobalTestPartResultReporter default_global_test_part_result_reporter_; - DefaultPerThreadTestPartResultReporter - default_per_thread_test_part_result_reporter_; - - // Points to (but doesn't own) the global test part result reporter. - TestPartResultReporterInterface* global_test_part_result_repoter_; - - // Protects read and write access to global_test_part_result_reporter_. - internal::Mutex global_test_part_result_reporter_mutex_; - - // Points to (but doesn't own) the per-thread test part result reporter. - internal::ThreadLocal - per_thread_test_part_result_reporter_; - - // The vector of environments that need to be set-up/torn-down - // before/after the tests are run. - std::vector environments_; - - // The vector of TestCases in their original order. It owns the - // elements in the vector. - std::vector test_cases_; - - // Provides a level of indirection for the test case list to allow - // easy shuffling and restoring the test case order. The i-th - // element of this vector is the index of the i-th test case in the - // shuffled order. - std::vector test_case_indices_; - - // ParameterizedTestRegistry object used to register value-parameterized - // tests. - internal::ParameterizedTestCaseRegistry parameterized_test_registry_; - - // Indicates whether RegisterParameterizedTests() has been called already. - bool parameterized_tests_registered_; - - // Index of the last death test case registered. Initially -1. - int last_death_test_case_; - - // This points to the TestCase for the currently running test. It - // changes as Google Test goes through one test case after another. - // When no test is running, this is set to NULL and Google Test - // stores assertion results in ad_hoc_test_result_. Initially NULL. - TestCase* current_test_case_; - - // This points to the TestInfo for the currently running test. It - // changes as Google Test goes through one test after another. When - // no test is running, this is set to NULL and Google Test stores - // assertion results in ad_hoc_test_result_. Initially NULL. - TestInfo* current_test_info_; - - // Normally, a user only writes assertions inside a TEST or TEST_F, - // or inside a function called by a TEST or TEST_F. Since Google - // Test keeps track of which test is current running, it can - // associate such an assertion with the test it belongs to. - // - // If an assertion is encountered when no TEST or TEST_F is running, - // Google Test attributes the assertion result to an imaginary "ad hoc" - // test, and records the result in ad_hoc_test_result_. - TestResult ad_hoc_test_result_; - - // The list of event listeners that can be used to track events inside - // Google Test. - TestEventListeners listeners_; - - // The OS stack trace getter. Will be deleted when the UnitTest - // object is destructed. By default, an OsStackTraceGetter is used, - // but the user can set this field to use a custom getter if that is - // desired. - OsStackTraceGetterInterface* os_stack_trace_getter_; - - // True iff PostFlagParsingInit() has been called. - bool post_flag_parse_init_performed_; - - // The random number seed used at the beginning of the test run. - int random_seed_; - - // Our random number generator. - internal::Random random_; - - // The time of the test program start, in ms from the start of the - // UNIX epoch. - TimeInMillis start_timestamp_; - - // How long the test took to run, in milliseconds. - TimeInMillis elapsed_time_; - -#if GTEST_HAS_DEATH_TEST - // The decomposed components of the gtest_internal_run_death_test flag, - // parsed when RUN_ALL_TESTS is called. - internal::scoped_ptr internal_run_death_test_flag_; - internal::scoped_ptr death_test_factory_; -#endif // GTEST_HAS_DEATH_TEST - - // A per-thread stack of traces created by the SCOPED_TRACE() macro. - internal::ThreadLocal > gtest_trace_stack_; - - // The value of GTEST_FLAG(catch_exceptions) at the moment RunAllTests() - // starts. - bool catch_exceptions_; - - GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTestImpl); -}; // class UnitTestImpl - -// Convenience function for accessing the global UnitTest -// implementation object. -inline UnitTestImpl* GetUnitTestImpl() { - return UnitTest::GetInstance()->impl(); -} - -#if GTEST_USES_SIMPLE_RE - -// Internal helper functions for implementing the simple regular -// expression matcher. -GTEST_API_ bool IsInSet(char ch, const char* str); -GTEST_API_ bool IsAsciiDigit(char ch); -GTEST_API_ bool IsAsciiPunct(char ch); -GTEST_API_ bool IsRepeat(char ch); -GTEST_API_ bool IsAsciiWhiteSpace(char ch); -GTEST_API_ bool IsAsciiWordChar(char ch); -GTEST_API_ bool IsValidEscape(char ch); -GTEST_API_ bool AtomMatchesChar(bool escaped, char pattern, char ch); -GTEST_API_ bool ValidateRegex(const char* regex); -GTEST_API_ bool MatchRegexAtHead(const char* regex, const char* str); -GTEST_API_ bool MatchRepetitionAndRegexAtHead( - bool escaped, char ch, char repeat, const char* regex, const char* str); -GTEST_API_ bool MatchRegexAnywhere(const char* regex, const char* str); - -#endif // GTEST_USES_SIMPLE_RE - -// Parses the command line for Google Test flags, without initializing -// other parts of Google Test. -GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, char** argv); -GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv); - -#if GTEST_HAS_DEATH_TEST - -// Returns the message describing the last system error, regardless of the -// platform. -GTEST_API_ std::string GetLastErrnoDescription(); - -// Attempts to parse a string into a positive integer pointed to by the -// number parameter. Returns true if that is possible. -// GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we can use -// it here. -template -bool ParseNaturalNumber(const ::std::string& str, Integer* number) { - // Fail fast if the given string does not begin with a digit; - // this bypasses strtoXXX's "optional leading whitespace and plus - // or minus sign" semantics, which are undesirable here. - if (str.empty() || !IsDigit(str[0])) { - return false; - } - errno = 0; - - char* end; - // BiggestConvertible is the largest integer type that system-provided - // string-to-number conversion routines can return. - -# if GTEST_OS_WINDOWS && !defined(__GNUC__) - - // MSVC and C++ Builder define __int64 instead of the standard long long. - typedef unsigned __int64 BiggestConvertible; - const BiggestConvertible parsed = _strtoui64(str.c_str(), &end, 10); - -# else - - typedef unsigned long long BiggestConvertible; // NOLINT - const BiggestConvertible parsed = strtoull(str.c_str(), &end, 10); - -# endif // GTEST_OS_WINDOWS && !defined(__GNUC__) - - const bool parse_success = *end == '\0' && errno == 0; - - // TODO(vladl@google.com): Convert this to compile time assertion when it is - // available. - GTEST_CHECK_(sizeof(Integer) <= sizeof(parsed)); - - const Integer result = static_cast(parsed); - if (parse_success && static_cast(result) == parsed) { - *number = result; - return true; - } - return false; -} -#endif // GTEST_HAS_DEATH_TEST - -// TestResult contains some private methods that should be hidden from -// Google Test user but are required for testing. This class allow our tests -// to access them. -// -// This class is supplied only for the purpose of testing Google Test's own -// constructs. Do not use it in user tests, either directly or indirectly. -class TestResultAccessor { - public: - static void RecordProperty(TestResult* test_result, - const std::string& xml_element, - const TestProperty& property) { - test_result->RecordProperty(xml_element, property); - } - - static void ClearTestPartResults(TestResult* test_result) { - test_result->ClearTestPartResults(); - } - - static const std::vector& test_part_results( - const TestResult& test_result) { - return test_result.test_part_results(); - } -}; - -#if GTEST_CAN_STREAM_RESULTS_ - -// Streams test results to the given port on the given host machine. -class StreamingListener : public EmptyTestEventListener { - public: - // Abstract base class for writing strings to a socket. - class AbstractSocketWriter { - public: - virtual ~AbstractSocketWriter() {} - - // Sends a string to the socket. - virtual void Send(const std::string& message) = 0; - - // Closes the socket. - virtual void CloseConnection() {} - - // Sends a string and a newline to the socket. - void SendLn(const std::string& message) { Send(message + "\n"); } - }; - - // Concrete class for actually writing strings to a socket. - class SocketWriter : public AbstractSocketWriter { - public: - SocketWriter(const std::string& host, const std::string& port) - : sockfd_(-1), host_name_(host), port_num_(port) { - MakeConnection(); - } - - virtual ~SocketWriter() { - if (sockfd_ != -1) - CloseConnection(); - } - - // Sends a string to the socket. - virtual void Send(const std::string& message) { - GTEST_CHECK_(sockfd_ != -1) - << "Send() can be called only when there is a connection."; - - const int len = static_cast(message.length()); - if (write(sockfd_, message.c_str(), len) != len) { - GTEST_LOG_(WARNING) - << "stream_result_to: failed to stream to " - << host_name_ << ":" << port_num_; - } - } - - private: - // Creates a client socket and connects to the server. - void MakeConnection(); - - // Closes the socket. - void CloseConnection() { - GTEST_CHECK_(sockfd_ != -1) - << "CloseConnection() can be called only when there is a connection."; - - close(sockfd_); - sockfd_ = -1; - } - - int sockfd_; // socket file descriptor - const std::string host_name_; - const std::string port_num_; - - GTEST_DISALLOW_COPY_AND_ASSIGN_(SocketWriter); - }; // class SocketWriter - - // Escapes '=', '&', '%', and '\n' characters in str as "%xx". - static std::string UrlEncode(const char* str); - - StreamingListener(const std::string& host, const std::string& port) - : socket_writer_(new SocketWriter(host, port)) { - Start(); - } - - explicit StreamingListener(AbstractSocketWriter* socket_writer) - : socket_writer_(socket_writer) { Start(); } - - void OnTestProgramStart(const UnitTest& /* unit_test */) { - SendLn("event=TestProgramStart"); - } - - void OnTestProgramEnd(const UnitTest& unit_test) { - // Note that Google Test current only report elapsed time for each - // test iteration, not for the entire test program. - SendLn("event=TestProgramEnd&passed=" + FormatBool(unit_test.Passed())); - - // Notify the streaming server to stop. - socket_writer_->CloseConnection(); - } - - void OnTestIterationStart(const UnitTest& /* unit_test */, int iteration) { - SendLn("event=TestIterationStart&iteration=" + - StreamableToString(iteration)); - } - - void OnTestIterationEnd(const UnitTest& unit_test, int /* iteration */) { - SendLn("event=TestIterationEnd&passed=" + - FormatBool(unit_test.Passed()) + "&elapsed_time=" + - StreamableToString(unit_test.elapsed_time()) + "ms"); - } - - void OnTestCaseStart(const TestCase& test_case) { - SendLn(std::string("event=TestCaseStart&name=") + test_case.name()); - } - - void OnTestCaseEnd(const TestCase& test_case) { - SendLn("event=TestCaseEnd&passed=" + FormatBool(test_case.Passed()) - + "&elapsed_time=" + StreamableToString(test_case.elapsed_time()) - + "ms"); - } - - void OnTestStart(const TestInfo& test_info) { - SendLn(std::string("event=TestStart&name=") + test_info.name()); - } - - void OnTestEnd(const TestInfo& test_info) { - SendLn("event=TestEnd&passed=" + - FormatBool((test_info.result())->Passed()) + - "&elapsed_time=" + - StreamableToString((test_info.result())->elapsed_time()) + "ms"); - } - - void OnTestPartResult(const TestPartResult& test_part_result) { - const char* file_name = test_part_result.file_name(); - if (file_name == NULL) - file_name = ""; - SendLn("event=TestPartResult&file=" + UrlEncode(file_name) + - "&line=" + StreamableToString(test_part_result.line_number()) + - "&message=" + UrlEncode(test_part_result.message())); - } - - private: - // Sends the given message and a newline to the socket. - void SendLn(const std::string& message) { socket_writer_->SendLn(message); } - - // Called at the start of streaming to notify the receiver what - // protocol we are using. - void Start() { SendLn("gtest_streaming_protocol_version=1.0"); } - - std::string FormatBool(bool value) { return value ? "1" : "0"; } - - const scoped_ptr socket_writer_; - - GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamingListener); -}; // class StreamingListener - -#endif // GTEST_CAN_STREAM_RESULTS_ - -} // namespace internal -} // namespace testing - -#endif // GTEST_SRC_GTEST_INTERNAL_INL_H_ - -#if GTEST_OS_WINDOWS -# define vsnprintf _vsnprintf -#endif // GTEST_OS_WINDOWS - -#if GTEST_HAS_ABSL -#include "absl/debugging/failure_signal_handler.h" -#include "absl/debugging/stacktrace.h" -#include "absl/debugging/symbolize.h" -#include "absl/strings/str_cat.h" -#endif // GTEST_HAS_ABSL - -namespace testing { - -using internal::CountIf; -using internal::ForEach; -using internal::GetElementOr; -using internal::Shuffle; - -// Constants. - -// A test whose test case name or test name matches this filter is -// disabled and not run. -static const char kDisableTestFilter[] = "DISABLED_*:*/DISABLED_*"; - -// A test case whose name matches this filter is considered a death -// test case and will be run before test cases whose name doesn't -// match this filter. -static const char kDeathTestCaseFilter[] = "*DeathTest:*DeathTest/*"; - -// A test filter that matches everything. -static const char kUniversalFilter[] = "*"; - -// The default output format. -static const char kDefaultOutputFormat[] = "xml"; -// The default output file. -static const char kDefaultOutputFile[] = "test_detail"; - -// The environment variable name for the test shard index. -static const char kTestShardIndex[] = "GTEST_SHARD_INDEX"; -// The environment variable name for the total number of test shards. -static const char kTestTotalShards[] = "GTEST_TOTAL_SHARDS"; -// The environment variable name for the test shard status file. -static const char kTestShardStatusFile[] = "GTEST_SHARD_STATUS_FILE"; - -namespace internal { - -// The text used in failure messages to indicate the start of the -// stack trace. -const char kStackTraceMarker[] = "\nStack trace:\n"; - -// g_help_flag is true iff the --help flag or an equivalent form is -// specified on the command line. -bool g_help_flag = false; - -} // namespace internal - -// Bazel passes in the argument to '--test_filter' via the TESTBRIDGE_TEST_ONLY -// environment variable. -static const char* GetDefaultFilter() { - const char* const testbridge_test_only = - internal::posix::GetEnv("TESTBRIDGE_TEST_ONLY"); - if (testbridge_test_only != NULL) { - return testbridge_test_only; - } - return kUniversalFilter; -} - -GTEST_DEFINE_bool_( - also_run_disabled_tests, - internal::BoolFromGTestEnv("also_run_disabled_tests", false), - "Run disabled tests too, in addition to the tests normally being run."); - -GTEST_DEFINE_bool_( - break_on_failure, - internal::BoolFromGTestEnv("break_on_failure", false), - "True iff a failed assertion should be a debugger break-point."); - -GTEST_DEFINE_bool_( - catch_exceptions, - internal::BoolFromGTestEnv("catch_exceptions", true), - "True iff " GTEST_NAME_ - " should catch exceptions and treat them as test failures."); - -GTEST_DEFINE_string_( - color, - internal::StringFromGTestEnv("color", "auto"), - "Whether to use colors in the output. Valid values: yes, no, " - "and auto. 'auto' means to use colors if the output is " - "being sent to a terminal and the TERM environment variable " - "is set to a terminal type that supports colors."); - -GTEST_DEFINE_string_( - filter, - internal::StringFromGTestEnv("filter", GetDefaultFilter()), - "A colon-separated list of glob (not regex) patterns " - "for filtering the tests to run, optionally followed by a " - "'-' and a : separated list of negative patterns (tests to " - "exclude). A test is run if it matches one of the positive " - "patterns and does not match any of the negative patterns."); - -GTEST_DEFINE_bool_( - install_failure_signal_handler, - internal::BoolFromGTestEnv("install_failure_signal_handler", false), - "If true and supported on the current platform, " GTEST_NAME_ " should " - "install a signal handler that dumps debugging information when fatal " - "signals are raised."); - -GTEST_DEFINE_bool_(list_tests, false, - "List all tests without running them."); - -// The net priority order after flag processing is thus: -// --gtest_output command line flag -// GTEST_OUTPUT environment variable -// XML_OUTPUT_FILE environment variable -// '' -GTEST_DEFINE_string_( - output, - internal::StringFromGTestEnv("output", - internal::OutputFlagAlsoCheckEnvVar().c_str()), - "A format (defaults to \"xml\" but can be specified to be \"json\"), " - "optionally followed by a colon and an output file name or directory. " - "A directory is indicated by a trailing pathname separator. " - "Examples: \"xml:filename.xml\", \"xml::directoryname/\". " - "If a directory is specified, output files will be created " - "within that directory, with file-names based on the test " - "executable's name and, if necessary, made unique by adding " - "digits."); - -GTEST_DEFINE_bool_( - print_time, - internal::BoolFromGTestEnv("print_time", true), - "True iff " GTEST_NAME_ - " should display elapsed time in text output."); - -GTEST_DEFINE_bool_( - print_utf8, - internal::BoolFromGTestEnv("print_utf8", true), - "True iff " GTEST_NAME_ - " prints UTF8 characters as text."); - -GTEST_DEFINE_int32_( - random_seed, - internal::Int32FromGTestEnv("random_seed", 0), - "Random number seed to use when shuffling test orders. Must be in range " - "[1, 99999], or 0 to use a seed based on the current time."); - -GTEST_DEFINE_int32_( - repeat, - internal::Int32FromGTestEnv("repeat", 1), - "How many times to repeat each test. Specify a negative number " - "for repeating forever. Useful for shaking out flaky tests."); - -GTEST_DEFINE_bool_( - show_internal_stack_frames, false, - "True iff " GTEST_NAME_ " should include internal stack frames when " - "printing test failure stack traces."); - -GTEST_DEFINE_bool_( - shuffle, - internal::BoolFromGTestEnv("shuffle", false), - "True iff " GTEST_NAME_ - " should randomize tests' order on every run."); - -GTEST_DEFINE_int32_( - stack_trace_depth, - internal::Int32FromGTestEnv("stack_trace_depth", kMaxStackTraceDepth), - "The maximum number of stack frames to print when an " - "assertion fails. The valid range is 0 through 100, inclusive."); - -GTEST_DEFINE_string_( - stream_result_to, - internal::StringFromGTestEnv("stream_result_to", ""), - "This flag specifies the host name and the port number on which to stream " - "test results. Example: \"localhost:555\". The flag is effective only on " - "Linux."); - -GTEST_DEFINE_bool_( - throw_on_failure, - internal::BoolFromGTestEnv("throw_on_failure", false), - "When this flag is specified, a failed assertion will throw an exception " - "if exceptions are enabled or exit the program with a non-zero code " - "otherwise. For use with an external test framework."); - -#if GTEST_USE_OWN_FLAGFILE_FLAG_ -GTEST_DEFINE_string_( - flagfile, - internal::StringFromGTestEnv("flagfile", ""), - "This flag specifies the flagfile to read command-line flags from."); -#endif // GTEST_USE_OWN_FLAGFILE_FLAG_ - -namespace internal { - -// Generates a random number from [0, range), using a Linear -// Congruential Generator (LCG). Crashes if 'range' is 0 or greater -// than kMaxRange. -UInt32 Random::Generate(UInt32 range) { - // These constants are the same as are used in glibc's rand(3). - // Use wider types than necessary to prevent unsigned overflow diagnostics. - state_ = static_cast(1103515245ULL*state_ + 12345U) % kMaxRange; - - GTEST_CHECK_(range > 0) - << "Cannot generate a number in the range [0, 0)."; - GTEST_CHECK_(range <= kMaxRange) - << "Generation of a number in [0, " << range << ") was requested, " - << "but this can only generate numbers in [0, " << kMaxRange << ")."; - - // Converting via modulus introduces a bit of downward bias, but - // it's simple, and a linear congruential generator isn't too good - // to begin with. - return state_ % range; -} - -// GTestIsInitialized() returns true iff the user has initialized -// Google Test. Useful for catching the user mistake of not initializing -// Google Test before calling RUN_ALL_TESTS(). -static bool GTestIsInitialized() { return GetArgvs().size() > 0; } - -// Iterates over a vector of TestCases, keeping a running sum of the -// results of calling a given int-returning method on each. -// Returns the sum. -static int SumOverTestCaseList(const std::vector& case_list, - int (TestCase::*method)() const) { - int sum = 0; - for (size_t i = 0; i < case_list.size(); i++) { - sum += (case_list[i]->*method)(); - } - return sum; -} - -// Returns true iff the test case passed. -static bool TestCasePassed(const TestCase* test_case) { - return test_case->should_run() && test_case->Passed(); -} - -// Returns true iff the test case failed. -static bool TestCaseFailed(const TestCase* test_case) { - return test_case->should_run() && test_case->Failed(); -} - -// Returns true iff test_case contains at least one test that should -// run. -static bool ShouldRunTestCase(const TestCase* test_case) { - return test_case->should_run(); -} - -// AssertHelper constructor. -AssertHelper::AssertHelper(TestPartResult::Type type, - const char* file, - int line, - const char* message) - : data_(new AssertHelperData(type, file, line, message)) { -} - -AssertHelper::~AssertHelper() { - delete data_; -} - -// Message assignment, for assertion streaming support. -void AssertHelper::operator=(const Message& message) const { - UnitTest::GetInstance()-> - AddTestPartResult(data_->type, data_->file, data_->line, - AppendUserMessage(data_->message, message), - UnitTest::GetInstance()->impl() - ->CurrentOsStackTraceExceptTop(1) - // Skips the stack frame for this function itself. - ); // NOLINT -} - -// Mutex for linked pointers. -GTEST_API_ GTEST_DEFINE_STATIC_MUTEX_(g_linked_ptr_mutex); - -// A copy of all command line arguments. Set by InitGoogleTest(). -::std::vector g_argvs; - -::std::vector GetArgvs() { -#if defined(GTEST_CUSTOM_GET_ARGVS_) - // GTEST_CUSTOM_GET_ARGVS_() may return a container of std::string or - // ::string. This code converts it to the appropriate type. - const auto& custom = GTEST_CUSTOM_GET_ARGVS_(); - return ::std::vector(custom.begin(), custom.end()); -#else // defined(GTEST_CUSTOM_GET_ARGVS_) - return g_argvs; -#endif // defined(GTEST_CUSTOM_GET_ARGVS_) -} - -// Returns the current application's name, removing directory path if that -// is present. -FilePath GetCurrentExecutableName() { - FilePath result; - -#if GTEST_OS_WINDOWS - result.Set(FilePath(GetArgvs()[0]).RemoveExtension("exe")); -#else - result.Set(FilePath(GetArgvs()[0])); -#endif // GTEST_OS_WINDOWS - - return result.RemoveDirectoryName(); -} - -// Functions for processing the gtest_output flag. - -// Returns the output format, or "" for normal printed output. -std::string UnitTestOptions::GetOutputFormat() { - const char* const gtest_output_flag = GTEST_FLAG(output).c_str(); - if (gtest_output_flag == NULL) return std::string(""); - - const char* const colon = strchr(gtest_output_flag, ':'); - return (colon == NULL) ? - std::string(gtest_output_flag) : - std::string(gtest_output_flag, colon - gtest_output_flag); -} - -// Returns the name of the requested output file, or the default if none -// was explicitly specified. -std::string UnitTestOptions::GetAbsolutePathToOutputFile() { - const char* const gtest_output_flag = GTEST_FLAG(output).c_str(); - if (gtest_output_flag == NULL) - return ""; - - std::string format = GetOutputFormat(); - if (format.empty()) - format = std::string(kDefaultOutputFormat); - - const char* const colon = strchr(gtest_output_flag, ':'); - if (colon == NULL) - return internal::FilePath::MakeFileName( - internal::FilePath( - UnitTest::GetInstance()->original_working_dir()), - internal::FilePath(kDefaultOutputFile), 0, - format.c_str()).string(); - - internal::FilePath output_name(colon + 1); - if (!output_name.IsAbsolutePath()) - // TODO(wan@google.com): on Windows \some\path is not an absolute - // path (as its meaning depends on the current drive), yet the - // following logic for turning it into an absolute path is wrong. - // Fix it. - output_name = internal::FilePath::ConcatPaths( - internal::FilePath(UnitTest::GetInstance()->original_working_dir()), - internal::FilePath(colon + 1)); - - if (!output_name.IsDirectory()) - return output_name.string(); - - internal::FilePath result(internal::FilePath::GenerateUniqueFileName( - output_name, internal::GetCurrentExecutableName(), - GetOutputFormat().c_str())); - return result.string(); -} - -// Returns true iff the wildcard pattern matches the string. The -// first ':' or '\0' character in pattern marks the end of it. -// -// This recursive algorithm isn't very efficient, but is clear and -// works well enough for matching test names, which are short. -bool UnitTestOptions::PatternMatchesString(const char *pattern, - const char *str) { - switch (*pattern) { - case '\0': - case ':': // Either ':' or '\0' marks the end of the pattern. - return *str == '\0'; - case '?': // Matches any single character. - return *str != '\0' && PatternMatchesString(pattern + 1, str + 1); - case '*': // Matches any string (possibly empty) of characters. - return (*str != '\0' && PatternMatchesString(pattern, str + 1)) || - PatternMatchesString(pattern + 1, str); - default: // Non-special character. Matches itself. - return *pattern == *str && - PatternMatchesString(pattern + 1, str + 1); - } -} - -bool UnitTestOptions::MatchesFilter( - const std::string& name, const char* filter) { - const char *cur_pattern = filter; - for (;;) { - if (PatternMatchesString(cur_pattern, name.c_str())) { - return true; - } - - // Finds the next pattern in the filter. - cur_pattern = strchr(cur_pattern, ':'); - - // Returns if no more pattern can be found. - if (cur_pattern == NULL) { - return false; - } - - // Skips the pattern separater (the ':' character). - cur_pattern++; - } -} - -// Returns true iff the user-specified filter matches the test case -// name and the test name. -bool UnitTestOptions::FilterMatchesTest(const std::string &test_case_name, - const std::string &test_name) { - const std::string& full_name = test_case_name + "." + test_name.c_str(); - - // Split --gtest_filter at '-', if there is one, to separate into - // positive filter and negative filter portions - const char* const p = GTEST_FLAG(filter).c_str(); - const char* const dash = strchr(p, '-'); - std::string positive; - std::string negative; - if (dash == NULL) { - positive = GTEST_FLAG(filter).c_str(); // Whole string is a positive filter - negative = ""; - } else { - positive = std::string(p, dash); // Everything up to the dash - negative = std::string(dash + 1); // Everything after the dash - if (positive.empty()) { - // Treat '-test1' as the same as '*-test1' - positive = kUniversalFilter; - } - } - - // A filter is a colon-separated list of patterns. It matches a - // test if any pattern in it matches the test. - return (MatchesFilter(full_name, positive.c_str()) && - !MatchesFilter(full_name, negative.c_str())); -} - -#if GTEST_HAS_SEH -// Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the -// given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise. -// This function is useful as an __except condition. -int UnitTestOptions::GTestShouldProcessSEH(DWORD exception_code) { - // Google Test should handle a SEH exception if: - // 1. the user wants it to, AND - // 2. this is not a breakpoint exception, AND - // 3. this is not a C++ exception (VC++ implements them via SEH, - // apparently). - // - // SEH exception code for C++ exceptions. - // (see http://support.microsoft.com/kb/185294 for more information). - const DWORD kCxxExceptionCode = 0xe06d7363; - - bool should_handle = true; - - if (!GTEST_FLAG(catch_exceptions)) - should_handle = false; - else if (exception_code == EXCEPTION_BREAKPOINT) - should_handle = false; - else if (exception_code == kCxxExceptionCode) - should_handle = false; - - return should_handle ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH; -} -#endif // GTEST_HAS_SEH - -} // namespace internal - -// The c'tor sets this object as the test part result reporter used by -// Google Test. The 'result' parameter specifies where to report the -// results. Intercepts only failures from the current thread. -ScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter( - TestPartResultArray* result) - : intercept_mode_(INTERCEPT_ONLY_CURRENT_THREAD), - result_(result) { - Init(); -} - -// The c'tor sets this object as the test part result reporter used by -// Google Test. The 'result' parameter specifies where to report the -// results. -ScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter( - InterceptMode intercept_mode, TestPartResultArray* result) - : intercept_mode_(intercept_mode), - result_(result) { - Init(); -} - -void ScopedFakeTestPartResultReporter::Init() { - internal::UnitTestImpl* const impl = internal::GetUnitTestImpl(); - if (intercept_mode_ == INTERCEPT_ALL_THREADS) { - old_reporter_ = impl->GetGlobalTestPartResultReporter(); - impl->SetGlobalTestPartResultReporter(this); - } else { - old_reporter_ = impl->GetTestPartResultReporterForCurrentThread(); - impl->SetTestPartResultReporterForCurrentThread(this); - } -} - -// The d'tor restores the test part result reporter used by Google Test -// before. -ScopedFakeTestPartResultReporter::~ScopedFakeTestPartResultReporter() { - internal::UnitTestImpl* const impl = internal::GetUnitTestImpl(); - if (intercept_mode_ == INTERCEPT_ALL_THREADS) { - impl->SetGlobalTestPartResultReporter(old_reporter_); - } else { - impl->SetTestPartResultReporterForCurrentThread(old_reporter_); - } -} - -// Increments the test part result count and remembers the result. -// This method is from the TestPartResultReporterInterface interface. -void ScopedFakeTestPartResultReporter::ReportTestPartResult( - const TestPartResult& result) { - result_->Append(result); -} - -namespace internal { - -// Returns the type ID of ::testing::Test. We should always call this -// instead of GetTypeId< ::testing::Test>() to get the type ID of -// testing::Test. This is to work around a suspected linker bug when -// using Google Test as a framework on Mac OS X. The bug causes -// GetTypeId< ::testing::Test>() to return different values depending -// on whether the call is from the Google Test framework itself or -// from user test code. GetTestTypeId() is guaranteed to always -// return the same value, as it always calls GetTypeId<>() from the -// gtest.cc, which is within the Google Test framework. -TypeId GetTestTypeId() { - return GetTypeId(); -} - -// The value of GetTestTypeId() as seen from within the Google Test -// library. This is solely for testing GetTestTypeId(). -extern const TypeId kTestTypeIdInGoogleTest = GetTestTypeId(); - -// This predicate-formatter checks that 'results' contains a test part -// failure of the given type and that the failure message contains the -// given substring. -static AssertionResult HasOneFailure(const char* /* results_expr */, - const char* /* type_expr */, - const char* /* substr_expr */, - const TestPartResultArray& results, - TestPartResult::Type type, - const std::string& substr) { - const std::string expected(type == TestPartResult::kFatalFailure ? - "1 fatal failure" : - "1 non-fatal failure"); - Message msg; - if (results.size() != 1) { - msg << "Expected: " << expected << "\n" - << " Actual: " << results.size() << " failures"; - for (int i = 0; i < results.size(); i++) { - msg << "\n" << results.GetTestPartResult(i); - } - return AssertionFailure() << msg; - } - - const TestPartResult& r = results.GetTestPartResult(0); - if (r.type() != type) { - return AssertionFailure() << "Expected: " << expected << "\n" - << " Actual:\n" - << r; - } - - if (strstr(r.message(), substr.c_str()) == NULL) { - return AssertionFailure() << "Expected: " << expected << " containing \"" - << substr << "\"\n" - << " Actual:\n" - << r; - } - - return AssertionSuccess(); -} - -// The constructor of SingleFailureChecker remembers where to look up -// test part results, what type of failure we expect, and what -// substring the failure message should contain. -SingleFailureChecker::SingleFailureChecker(const TestPartResultArray* results, - TestPartResult::Type type, - const std::string& substr) - : results_(results), type_(type), substr_(substr) {} - -// The destructor of SingleFailureChecker verifies that the given -// TestPartResultArray contains exactly one failure that has the given -// type and contains the given substring. If that's not the case, a -// non-fatal failure will be generated. -SingleFailureChecker::~SingleFailureChecker() { - EXPECT_PRED_FORMAT3(HasOneFailure, *results_, type_, substr_); -} - -DefaultGlobalTestPartResultReporter::DefaultGlobalTestPartResultReporter( - UnitTestImpl* unit_test) : unit_test_(unit_test) {} - -void DefaultGlobalTestPartResultReporter::ReportTestPartResult( - const TestPartResult& result) { - unit_test_->current_test_result()->AddTestPartResult(result); - unit_test_->listeners()->repeater()->OnTestPartResult(result); -} - -DefaultPerThreadTestPartResultReporter::DefaultPerThreadTestPartResultReporter( - UnitTestImpl* unit_test) : unit_test_(unit_test) {} - -void DefaultPerThreadTestPartResultReporter::ReportTestPartResult( - const TestPartResult& result) { - unit_test_->GetGlobalTestPartResultReporter()->ReportTestPartResult(result); -} - -// Returns the global test part result reporter. -TestPartResultReporterInterface* -UnitTestImpl::GetGlobalTestPartResultReporter() { - internal::MutexLock lock(&global_test_part_result_reporter_mutex_); - return global_test_part_result_repoter_; -} - -// Sets the global test part result reporter. -void UnitTestImpl::SetGlobalTestPartResultReporter( - TestPartResultReporterInterface* reporter) { - internal::MutexLock lock(&global_test_part_result_reporter_mutex_); - global_test_part_result_repoter_ = reporter; -} - -// Returns the test part result reporter for the current thread. -TestPartResultReporterInterface* -UnitTestImpl::GetTestPartResultReporterForCurrentThread() { - return per_thread_test_part_result_reporter_.get(); -} - -// Sets the test part result reporter for the current thread. -void UnitTestImpl::SetTestPartResultReporterForCurrentThread( - TestPartResultReporterInterface* reporter) { - per_thread_test_part_result_reporter_.set(reporter); -} - -// Gets the number of successful test cases. -int UnitTestImpl::successful_test_case_count() const { - return CountIf(test_cases_, TestCasePassed); -} - -// Gets the number of failed test cases. -int UnitTestImpl::failed_test_case_count() const { - return CountIf(test_cases_, TestCaseFailed); -} - -// Gets the number of all test cases. -int UnitTestImpl::total_test_case_count() const { - return static_cast(test_cases_.size()); -} - -// Gets the number of all test cases that contain at least one test -// that should run. -int UnitTestImpl::test_case_to_run_count() const { - return CountIf(test_cases_, ShouldRunTestCase); -} - -// Gets the number of successful tests. -int UnitTestImpl::successful_test_count() const { - return SumOverTestCaseList(test_cases_, &TestCase::successful_test_count); -} - -// Gets the number of failed tests. -int UnitTestImpl::failed_test_count() const { - return SumOverTestCaseList(test_cases_, &TestCase::failed_test_count); -} - -// Gets the number of disabled tests that will be reported in the XML report. -int UnitTestImpl::reportable_disabled_test_count() const { - return SumOverTestCaseList(test_cases_, - &TestCase::reportable_disabled_test_count); -} - -// Gets the number of disabled tests. -int UnitTestImpl::disabled_test_count() const { - return SumOverTestCaseList(test_cases_, &TestCase::disabled_test_count); -} - -// Gets the number of tests to be printed in the XML report. -int UnitTestImpl::reportable_test_count() const { - return SumOverTestCaseList(test_cases_, &TestCase::reportable_test_count); -} - -// Gets the number of all tests. -int UnitTestImpl::total_test_count() const { - return SumOverTestCaseList(test_cases_, &TestCase::total_test_count); -} - -// Gets the number of tests that should run. -int UnitTestImpl::test_to_run_count() const { - return SumOverTestCaseList(test_cases_, &TestCase::test_to_run_count); -} - -// Returns the current OS stack trace as an std::string. -// -// The maximum number of stack frames to be included is specified by -// the gtest_stack_trace_depth flag. The skip_count parameter -// specifies the number of top frames to be skipped, which doesn't -// count against the number of frames to be included. -// -// For example, if Foo() calls Bar(), which in turn calls -// CurrentOsStackTraceExceptTop(1), Foo() will be included in the -// trace but Bar() and CurrentOsStackTraceExceptTop() won't. -std::string UnitTestImpl::CurrentOsStackTraceExceptTop(int skip_count) { - return os_stack_trace_getter()->CurrentStackTrace( - static_cast(GTEST_FLAG(stack_trace_depth)), - skip_count + 1 - // Skips the user-specified number of frames plus this function - // itself. - ); // NOLINT -} - -// Returns the current time in milliseconds. -TimeInMillis GetTimeInMillis() { -#if GTEST_OS_WINDOWS_MOBILE || defined(__BORLANDC__) - // Difference between 1970-01-01 and 1601-01-01 in milliseconds. - // http://analogous.blogspot.com/2005/04/epoch.html - const TimeInMillis kJavaEpochToWinFileTimeDelta = - static_cast(116444736UL) * 100000UL; - const DWORD kTenthMicrosInMilliSecond = 10000; - - SYSTEMTIME now_systime; - FILETIME now_filetime; - ULARGE_INTEGER now_int64; - // TODO(kenton@google.com): Shouldn't this just use - // GetSystemTimeAsFileTime()? - GetSystemTime(&now_systime); - if (SystemTimeToFileTime(&now_systime, &now_filetime)) { - now_int64.LowPart = now_filetime.dwLowDateTime; - now_int64.HighPart = now_filetime.dwHighDateTime; - now_int64.QuadPart = (now_int64.QuadPart / kTenthMicrosInMilliSecond) - - kJavaEpochToWinFileTimeDelta; - return now_int64.QuadPart; - } - return 0; -#elif GTEST_OS_WINDOWS && !GTEST_HAS_GETTIMEOFDAY_ - __timeb64 now; - - // MSVC 8 deprecates _ftime64(), so we want to suppress warning 4996 - // (deprecated function) there. - // TODO(kenton@google.com): Use GetTickCount()? Or use - // SystemTimeToFileTime() - GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996) - _ftime64(&now); - GTEST_DISABLE_MSC_WARNINGS_POP_() - - return static_cast(now.time) * 1000 + now.millitm; -#elif GTEST_HAS_GETTIMEOFDAY_ - struct timeval now; - gettimeofday(&now, NULL); - return static_cast(now.tv_sec) * 1000 + now.tv_usec / 1000; -#else -# error "Don't know how to get the current time on your system." -#endif -} - -// Utilities - -// class String. - -#if GTEST_OS_WINDOWS_MOBILE -// Creates a UTF-16 wide string from the given ANSI string, allocating -// memory using new. The caller is responsible for deleting the return -// value using delete[]. Returns the wide string, or NULL if the -// input is NULL. -LPCWSTR String::AnsiToUtf16(const char* ansi) { - if (!ansi) return NULL; - const int length = strlen(ansi); - const int unicode_length = - MultiByteToWideChar(CP_ACP, 0, ansi, length, - NULL, 0); - WCHAR* unicode = new WCHAR[unicode_length + 1]; - MultiByteToWideChar(CP_ACP, 0, ansi, length, - unicode, unicode_length); - unicode[unicode_length] = 0; - return unicode; -} - -// Creates an ANSI string from the given wide string, allocating -// memory using new. The caller is responsible for deleting the return -// value using delete[]. Returns the ANSI string, or NULL if the -// input is NULL. -const char* String::Utf16ToAnsi(LPCWSTR utf16_str) { - if (!utf16_str) return NULL; - const int ansi_length = - WideCharToMultiByte(CP_ACP, 0, utf16_str, -1, - NULL, 0, NULL, NULL); - char* ansi = new char[ansi_length + 1]; - WideCharToMultiByte(CP_ACP, 0, utf16_str, -1, - ansi, ansi_length, NULL, NULL); - ansi[ansi_length] = 0; - return ansi; -} - -#endif // GTEST_OS_WINDOWS_MOBILE - -// Compares two C strings. Returns true iff they have the same content. -// -// Unlike strcmp(), this function can handle NULL argument(s). A NULL -// C string is considered different to any non-NULL C string, -// including the empty string. -bool String::CStringEquals(const char * lhs, const char * rhs) { - if ( lhs == NULL ) return rhs == NULL; - - if ( rhs == NULL ) return false; - - return strcmp(lhs, rhs) == 0; -} - -#if GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING - -// Converts an array of wide chars to a narrow string using the UTF-8 -// encoding, and streams the result to the given Message object. -static void StreamWideCharsToMessage(const wchar_t* wstr, size_t length, - Message* msg) { - for (size_t i = 0; i != length; ) { // NOLINT - if (wstr[i] != L'\0') { - *msg << WideStringToUtf8(wstr + i, static_cast(length - i)); - while (i != length && wstr[i] != L'\0') - i++; - } else { - *msg << '\0'; - i++; - } - } -} - -#endif // GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING - -void SplitString(const ::std::string& str, char delimiter, - ::std::vector< ::std::string>* dest) { - ::std::vector< ::std::string> parsed; - ::std::string::size_type pos = 0; - while (::testing::internal::AlwaysTrue()) { - const ::std::string::size_type colon = str.find(delimiter, pos); - if (colon == ::std::string::npos) { - parsed.push_back(str.substr(pos)); - break; - } else { - parsed.push_back(str.substr(pos, colon - pos)); - pos = colon + 1; - } - } - dest->swap(parsed); -} - -} // namespace internal - -// Constructs an empty Message. -// We allocate the stringstream separately because otherwise each use of -// ASSERT/EXPECT in a procedure adds over 200 bytes to the procedure's -// stack frame leading to huge stack frames in some cases; gcc does not reuse -// the stack space. -Message::Message() : ss_(new ::std::stringstream) { - // By default, we want there to be enough precision when printing - // a double to a Message. - *ss_ << std::setprecision(std::numeric_limits::digits10 + 2); -} - -// These two overloads allow streaming a wide C string to a Message -// using the UTF-8 encoding. -Message& Message::operator <<(const wchar_t* wide_c_str) { - return *this << internal::String::ShowWideCString(wide_c_str); -} -Message& Message::operator <<(wchar_t* wide_c_str) { - return *this << internal::String::ShowWideCString(wide_c_str); -} - -#if GTEST_HAS_STD_WSTRING -// Converts the given wide string to a narrow string using the UTF-8 -// encoding, and streams the result to this Message object. -Message& Message::operator <<(const ::std::wstring& wstr) { - internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this); - return *this; -} -#endif // GTEST_HAS_STD_WSTRING - -#if GTEST_HAS_GLOBAL_WSTRING -// Converts the given wide string to a narrow string using the UTF-8 -// encoding, and streams the result to this Message object. -Message& Message::operator <<(const ::wstring& wstr) { - internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this); - return *this; -} -#endif // GTEST_HAS_GLOBAL_WSTRING - -// Gets the text streamed to this object so far as an std::string. -// Each '\0' character in the buffer is replaced with "\\0". -std::string Message::GetString() const { - return internal::StringStreamToString(ss_.get()); -} - -// AssertionResult constructors. -// Used in EXPECT_TRUE/FALSE(assertion_result). -AssertionResult::AssertionResult(const AssertionResult& other) - : success_(other.success_), - message_(other.message_.get() != NULL ? - new ::std::string(*other.message_) : - static_cast< ::std::string*>(NULL)) { -} - -// Swaps two AssertionResults. -void AssertionResult::swap(AssertionResult& other) { - using std::swap; - swap(success_, other.success_); - swap(message_, other.message_); -} - -// Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE. -AssertionResult AssertionResult::operator!() const { - AssertionResult negation(!success_); - if (message_.get() != NULL) - negation << *message_; - return negation; -} - -// Makes a successful assertion result. -AssertionResult AssertionSuccess() { - return AssertionResult(true); -} - -// Makes a failed assertion result. -AssertionResult AssertionFailure() { - return AssertionResult(false); -} - -// Makes a failed assertion result with the given failure message. -// Deprecated; use AssertionFailure() << message. -AssertionResult AssertionFailure(const Message& message) { - return AssertionFailure() << message; -} - -namespace internal { - -namespace edit_distance { -std::vector CalculateOptimalEdits(const std::vector& left, - const std::vector& right) { - std::vector > costs( - left.size() + 1, std::vector(right.size() + 1)); - std::vector > best_move( - left.size() + 1, std::vector(right.size() + 1)); - - // Populate for empty right. - for (size_t l_i = 0; l_i < costs.size(); ++l_i) { - costs[l_i][0] = static_cast(l_i); - best_move[l_i][0] = kRemove; - } - // Populate for empty left. - for (size_t r_i = 1; r_i < costs[0].size(); ++r_i) { - costs[0][r_i] = static_cast(r_i); - best_move[0][r_i] = kAdd; - } - - for (size_t l_i = 0; l_i < left.size(); ++l_i) { - for (size_t r_i = 0; r_i < right.size(); ++r_i) { - if (left[l_i] == right[r_i]) { - // Found a match. Consume it. - costs[l_i + 1][r_i + 1] = costs[l_i][r_i]; - best_move[l_i + 1][r_i + 1] = kMatch; - continue; - } - - const double add = costs[l_i + 1][r_i]; - const double remove = costs[l_i][r_i + 1]; - const double replace = costs[l_i][r_i]; - if (add < remove && add < replace) { - costs[l_i + 1][r_i + 1] = add + 1; - best_move[l_i + 1][r_i + 1] = kAdd; - } else if (remove < add && remove < replace) { - costs[l_i + 1][r_i + 1] = remove + 1; - best_move[l_i + 1][r_i + 1] = kRemove; - } else { - // We make replace a little more expensive than add/remove to lower - // their priority. - costs[l_i + 1][r_i + 1] = replace + 1.00001; - best_move[l_i + 1][r_i + 1] = kReplace; - } - } - } - - // Reconstruct the best path. We do it in reverse order. - std::vector best_path; - for (size_t l_i = left.size(), r_i = right.size(); l_i > 0 || r_i > 0;) { - EditType move = best_move[l_i][r_i]; - best_path.push_back(move); - l_i -= move != kAdd; - r_i -= move != kRemove; - } - std::reverse(best_path.begin(), best_path.end()); - return best_path; -} - -namespace { - -// Helper class to convert string into ids with deduplication. -class InternalStrings { - public: - size_t GetId(const std::string& str) { - IdMap::iterator it = ids_.find(str); - if (it != ids_.end()) return it->second; - size_t id = ids_.size(); - return ids_[str] = id; - } - - private: - typedef std::map IdMap; - IdMap ids_; -}; - -} // namespace - -std::vector CalculateOptimalEdits( - const std::vector& left, - const std::vector& right) { - std::vector left_ids, right_ids; - { - InternalStrings intern_table; - for (size_t i = 0; i < left.size(); ++i) { - left_ids.push_back(intern_table.GetId(left[i])); - } - for (size_t i = 0; i < right.size(); ++i) { - right_ids.push_back(intern_table.GetId(right[i])); - } - } - return CalculateOptimalEdits(left_ids, right_ids); -} - -namespace { - -// Helper class that holds the state for one hunk and prints it out to the -// stream. -// It reorders adds/removes when possible to group all removes before all -// adds. It also adds the hunk header before printint into the stream. -class Hunk { - public: - Hunk(size_t left_start, size_t right_start) - : left_start_(left_start), - right_start_(right_start), - adds_(), - removes_(), - common_() {} - - void PushLine(char edit, const char* line) { - switch (edit) { - case ' ': - ++common_; - FlushEdits(); - hunk_.push_back(std::make_pair(' ', line)); - break; - case '-': - ++removes_; - hunk_removes_.push_back(std::make_pair('-', line)); - break; - case '+': - ++adds_; - hunk_adds_.push_back(std::make_pair('+', line)); - break; - } - } - - void PrintTo(std::ostream* os) { - PrintHeader(os); - FlushEdits(); - for (std::list >::const_iterator it = - hunk_.begin(); - it != hunk_.end(); ++it) { - *os << it->first << it->second << "\n"; - } - } - - bool has_edits() const { return adds_ || removes_; } - - private: - void FlushEdits() { - hunk_.splice(hunk_.end(), hunk_removes_); - hunk_.splice(hunk_.end(), hunk_adds_); - } - - // Print a unified diff header for one hunk. - // The format is - // "@@ -, +, @@" - // where the left/right parts are omitted if unnecessary. - void PrintHeader(std::ostream* ss) const { - *ss << "@@ "; - if (removes_) { - *ss << "-" << left_start_ << "," << (removes_ + common_); - } - if (removes_ && adds_) { - *ss << " "; - } - if (adds_) { - *ss << "+" << right_start_ << "," << (adds_ + common_); - } - *ss << " @@\n"; - } - - size_t left_start_, right_start_; - size_t adds_, removes_, common_; - std::list > hunk_, hunk_adds_, hunk_removes_; -}; - -} // namespace - -// Create a list of diff hunks in Unified diff format. -// Each hunk has a header generated by PrintHeader above plus a body with -// lines prefixed with ' ' for no change, '-' for deletion and '+' for -// addition. -// 'context' represents the desired unchanged prefix/suffix around the diff. -// If two hunks are close enough that their contexts overlap, then they are -// joined into one hunk. -std::string CreateUnifiedDiff(const std::vector& left, - const std::vector& right, - size_t context) { - const std::vector edits = CalculateOptimalEdits(left, right); - - size_t l_i = 0, r_i = 0, edit_i = 0; - std::stringstream ss; - while (edit_i < edits.size()) { - // Find first edit. - while (edit_i < edits.size() && edits[edit_i] == kMatch) { - ++l_i; - ++r_i; - ++edit_i; - } - - // Find the first line to include in the hunk. - const size_t prefix_context = std::min(l_i, context); - Hunk hunk(l_i - prefix_context + 1, r_i - prefix_context + 1); - for (size_t i = prefix_context; i > 0; --i) { - hunk.PushLine(' ', left[l_i - i].c_str()); - } - - // Iterate the edits until we found enough suffix for the hunk or the input - // is over. - size_t n_suffix = 0; - for (; edit_i < edits.size(); ++edit_i) { - if (n_suffix >= context) { - // Continue only if the next hunk is very close. - std::vector::const_iterator it = edits.begin() + edit_i; - while (it != edits.end() && *it == kMatch) ++it; - if (it == edits.end() || (it - edits.begin()) - edit_i >= context) { - // There is no next edit or it is too far away. - break; - } - } - - EditType edit = edits[edit_i]; - // Reset count when a non match is found. - n_suffix = edit == kMatch ? n_suffix + 1 : 0; - - if (edit == kMatch || edit == kRemove || edit == kReplace) { - hunk.PushLine(edit == kMatch ? ' ' : '-', left[l_i].c_str()); - } - if (edit == kAdd || edit == kReplace) { - hunk.PushLine('+', right[r_i].c_str()); - } - - // Advance indices, depending on edit type. - l_i += edit != kAdd; - r_i += edit != kRemove; - } - - if (!hunk.has_edits()) { - // We are done. We don't want this hunk. - break; - } - - hunk.PrintTo(&ss); - } - return ss.str(); -} - -} // namespace edit_distance - -namespace { - -// The string representation of the values received in EqFailure() are already -// escaped. Split them on escaped '\n' boundaries. Leave all other escaped -// characters the same. -std::vector SplitEscapedString(const std::string& str) { - std::vector lines; - size_t start = 0, end = str.size(); - if (end > 2 && str[0] == '"' && str[end - 1] == '"') { - ++start; - --end; - } - bool escaped = false; - for (size_t i = start; i + 1 < end; ++i) { - if (escaped) { - escaped = false; - if (str[i] == 'n') { - lines.push_back(str.substr(start, i - start - 1)); - start = i + 1; - } - } else { - escaped = str[i] == '\\'; - } - } - lines.push_back(str.substr(start, end - start)); - return lines; -} - -} // namespace - -// Constructs and returns the message for an equality assertion -// (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure. -// -// The first four parameters are the expressions used in the assertion -// and their values, as strings. For example, for ASSERT_EQ(foo, bar) -// where foo is 5 and bar is 6, we have: -// -// lhs_expression: "foo" -// rhs_expression: "bar" -// lhs_value: "5" -// rhs_value: "6" -// -// The ignoring_case parameter is true iff the assertion is a -// *_STRCASEEQ*. When it's true, the string "Ignoring case" will -// be inserted into the message. -AssertionResult EqFailure(const char* lhs_expression, - const char* rhs_expression, - const std::string& lhs_value, - const std::string& rhs_value, - bool ignoring_case) { - Message msg; - msg << "Expected equality of these values:"; - msg << "\n " << lhs_expression; - if (lhs_value != lhs_expression) { - msg << "\n Which is: " << lhs_value; - } - msg << "\n " << rhs_expression; - if (rhs_value != rhs_expression) { - msg << "\n Which is: " << rhs_value; - } - - if (ignoring_case) { - msg << "\nIgnoring case"; - } - - if (!lhs_value.empty() && !rhs_value.empty()) { - const std::vector lhs_lines = - SplitEscapedString(lhs_value); - const std::vector rhs_lines = - SplitEscapedString(rhs_value); - if (lhs_lines.size() > 1 || rhs_lines.size() > 1) { - msg << "\nWith diff:\n" - << edit_distance::CreateUnifiedDiff(lhs_lines, rhs_lines); - } - } - - return AssertionFailure() << msg; -} - -// Constructs a failure message for Boolean assertions such as EXPECT_TRUE. -std::string GetBoolAssertionFailureMessage( - const AssertionResult& assertion_result, - const char* expression_text, - const char* actual_predicate_value, - const char* expected_predicate_value) { - const char* actual_message = assertion_result.message(); - Message msg; - msg << "Value of: " << expression_text - << "\n Actual: " << actual_predicate_value; - if (actual_message[0] != '\0') - msg << " (" << actual_message << ")"; - msg << "\nExpected: " << expected_predicate_value; - return msg.GetString(); -} - -// Helper function for implementing ASSERT_NEAR. -AssertionResult DoubleNearPredFormat(const char* expr1, - const char* expr2, - const char* abs_error_expr, - double val1, - double val2, - double abs_error) { - const double diff = fabs(val1 - val2); - if (diff <= abs_error) return AssertionSuccess(); - - // TODO(wan): do not print the value of an expression if it's - // already a literal. - return AssertionFailure() - << "The difference between " << expr1 << " and " << expr2 - << " is " << diff << ", which exceeds " << abs_error_expr << ", where\n" - << expr1 << " evaluates to " << val1 << ",\n" - << expr2 << " evaluates to " << val2 << ", and\n" - << abs_error_expr << " evaluates to " << abs_error << "."; -} - - -// Helper template for implementing FloatLE() and DoubleLE(). -template -AssertionResult FloatingPointLE(const char* expr1, - const char* expr2, - RawType val1, - RawType val2) { - // Returns success if val1 is less than val2, - if (val1 < val2) { - return AssertionSuccess(); - } - - // or if val1 is almost equal to val2. - const FloatingPoint lhs(val1), rhs(val2); - if (lhs.AlmostEquals(rhs)) { - return AssertionSuccess(); - } - - // Note that the above two checks will both fail if either val1 or - // val2 is NaN, as the IEEE floating-point standard requires that - // any predicate involving a NaN must return false. - - ::std::stringstream val1_ss; - val1_ss << std::setprecision(std::numeric_limits::digits10 + 2) - << val1; - - ::std::stringstream val2_ss; - val2_ss << std::setprecision(std::numeric_limits::digits10 + 2) - << val2; - - return AssertionFailure() - << "Expected: (" << expr1 << ") <= (" << expr2 << ")\n" - << " Actual: " << StringStreamToString(&val1_ss) << " vs " - << StringStreamToString(&val2_ss); -} - -} // namespace internal - -// Asserts that val1 is less than, or almost equal to, val2. Fails -// otherwise. In particular, it fails if either val1 or val2 is NaN. -AssertionResult FloatLE(const char* expr1, const char* expr2, - float val1, float val2) { - return internal::FloatingPointLE(expr1, expr2, val1, val2); -} - -// Asserts that val1 is less than, or almost equal to, val2. Fails -// otherwise. In particular, it fails if either val1 or val2 is NaN. -AssertionResult DoubleLE(const char* expr1, const char* expr2, - double val1, double val2) { - return internal::FloatingPointLE(expr1, expr2, val1, val2); -} - -namespace internal { - -// The helper function for {ASSERT|EXPECT}_EQ with int or enum -// arguments. -AssertionResult CmpHelperEQ(const char* lhs_expression, - const char* rhs_expression, - BiggestInt lhs, - BiggestInt rhs) { - if (lhs == rhs) { - return AssertionSuccess(); - } - - return EqFailure(lhs_expression, - rhs_expression, - FormatForComparisonFailureMessage(lhs, rhs), - FormatForComparisonFailureMessage(rhs, lhs), - false); -} - -// A macro for implementing the helper functions needed to implement -// ASSERT_?? and EXPECT_?? with integer or enum arguments. It is here -// just to avoid copy-and-paste of similar code. -#define GTEST_IMPL_CMP_HELPER_(op_name, op)\ -AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \ - BiggestInt val1, BiggestInt val2) {\ - if (val1 op val2) {\ - return AssertionSuccess();\ - } else {\ - return AssertionFailure() \ - << "Expected: (" << expr1 << ") " #op " (" << expr2\ - << "), actual: " << FormatForComparisonFailureMessage(val1, val2)\ - << " vs " << FormatForComparisonFailureMessage(val2, val1);\ - }\ -} - -// Implements the helper function for {ASSERT|EXPECT}_NE with int or -// enum arguments. -GTEST_IMPL_CMP_HELPER_(NE, !=) -// Implements the helper function for {ASSERT|EXPECT}_LE with int or -// enum arguments. -GTEST_IMPL_CMP_HELPER_(LE, <=) -// Implements the helper function for {ASSERT|EXPECT}_LT with int or -// enum arguments. -GTEST_IMPL_CMP_HELPER_(LT, < ) -// Implements the helper function for {ASSERT|EXPECT}_GE with int or -// enum arguments. -GTEST_IMPL_CMP_HELPER_(GE, >=) -// Implements the helper function for {ASSERT|EXPECT}_GT with int or -// enum arguments. -GTEST_IMPL_CMP_HELPER_(GT, > ) - -#undef GTEST_IMPL_CMP_HELPER_ - -// The helper function for {ASSERT|EXPECT}_STREQ. -AssertionResult CmpHelperSTREQ(const char* lhs_expression, - const char* rhs_expression, - const char* lhs, - const char* rhs) { - if (String::CStringEquals(lhs, rhs)) { - return AssertionSuccess(); - } - - return EqFailure(lhs_expression, - rhs_expression, - PrintToString(lhs), - PrintToString(rhs), - false); -} - -// The helper function for {ASSERT|EXPECT}_STRCASEEQ. -AssertionResult CmpHelperSTRCASEEQ(const char* lhs_expression, - const char* rhs_expression, - const char* lhs, - const char* rhs) { - if (String::CaseInsensitiveCStringEquals(lhs, rhs)) { - return AssertionSuccess(); - } - - return EqFailure(lhs_expression, - rhs_expression, - PrintToString(lhs), - PrintToString(rhs), - true); -} - -// The helper function for {ASSERT|EXPECT}_STRNE. -AssertionResult CmpHelperSTRNE(const char* s1_expression, - const char* s2_expression, - const char* s1, - const char* s2) { - if (!String::CStringEquals(s1, s2)) { - return AssertionSuccess(); - } else { - return AssertionFailure() << "Expected: (" << s1_expression << ") != (" - << s2_expression << "), actual: \"" - << s1 << "\" vs \"" << s2 << "\""; - } -} - -// The helper function for {ASSERT|EXPECT}_STRCASENE. -AssertionResult CmpHelperSTRCASENE(const char* s1_expression, - const char* s2_expression, - const char* s1, - const char* s2) { - if (!String::CaseInsensitiveCStringEquals(s1, s2)) { - return AssertionSuccess(); - } else { - return AssertionFailure() - << "Expected: (" << s1_expression << ") != (" - << s2_expression << ") (ignoring case), actual: \"" - << s1 << "\" vs \"" << s2 << "\""; - } -} - -} // namespace internal - -namespace { - -// Helper functions for implementing IsSubString() and IsNotSubstring(). - -// This group of overloaded functions return true iff needle is a -// substring of haystack. NULL is considered a substring of itself -// only. - -bool IsSubstringPred(const char* needle, const char* haystack) { - if (needle == NULL || haystack == NULL) - return needle == haystack; - - return strstr(haystack, needle) != NULL; -} - -bool IsSubstringPred(const wchar_t* needle, const wchar_t* haystack) { - if (needle == NULL || haystack == NULL) - return needle == haystack; - - return wcsstr(haystack, needle) != NULL; -} - -// StringType here can be either ::std::string or ::std::wstring. -template -bool IsSubstringPred(const StringType& needle, - const StringType& haystack) { - return haystack.find(needle) != StringType::npos; -} - -// This function implements either IsSubstring() or IsNotSubstring(), -// depending on the value of the expected_to_be_substring parameter. -// StringType here can be const char*, const wchar_t*, ::std::string, -// or ::std::wstring. -template -AssertionResult IsSubstringImpl( - bool expected_to_be_substring, - const char* needle_expr, const char* haystack_expr, - const StringType& needle, const StringType& haystack) { - if (IsSubstringPred(needle, haystack) == expected_to_be_substring) - return AssertionSuccess(); - - const bool is_wide_string = sizeof(needle[0]) > 1; - const char* const begin_string_quote = is_wide_string ? "L\"" : "\""; - return AssertionFailure() - << "Value of: " << needle_expr << "\n" - << " Actual: " << begin_string_quote << needle << "\"\n" - << "Expected: " << (expected_to_be_substring ? "" : "not ") - << "a substring of " << haystack_expr << "\n" - << "Which is: " << begin_string_quote << haystack << "\""; -} - -} // namespace - -// IsSubstring() and IsNotSubstring() check whether needle is a -// substring of haystack (NULL is considered a substring of itself -// only), and return an appropriate error message when they fail. - -AssertionResult IsSubstring( - const char* needle_expr, const char* haystack_expr, - const char* needle, const char* haystack) { - return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack); -} - -AssertionResult IsSubstring( - const char* needle_expr, const char* haystack_expr, - const wchar_t* needle, const wchar_t* haystack) { - return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack); -} - -AssertionResult IsNotSubstring( - const char* needle_expr, const char* haystack_expr, - const char* needle, const char* haystack) { - return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack); -} - -AssertionResult IsNotSubstring( - const char* needle_expr, const char* haystack_expr, - const wchar_t* needle, const wchar_t* haystack) { - return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack); -} - -AssertionResult IsSubstring( - const char* needle_expr, const char* haystack_expr, - const ::std::string& needle, const ::std::string& haystack) { - return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack); -} - -AssertionResult IsNotSubstring( - const char* needle_expr, const char* haystack_expr, - const ::std::string& needle, const ::std::string& haystack) { - return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack); -} - -#if GTEST_HAS_STD_WSTRING -AssertionResult IsSubstring( - const char* needle_expr, const char* haystack_expr, - const ::std::wstring& needle, const ::std::wstring& haystack) { - return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack); -} - -AssertionResult IsNotSubstring( - const char* needle_expr, const char* haystack_expr, - const ::std::wstring& needle, const ::std::wstring& haystack) { - return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack); -} -#endif // GTEST_HAS_STD_WSTRING - -namespace internal { - -#if GTEST_OS_WINDOWS - -namespace { - -// Helper function for IsHRESULT{SuccessFailure} predicates -AssertionResult HRESULTFailureHelper(const char* expr, - const char* expected, - long hr) { // NOLINT -# if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_TV_TITLE - - // Windows CE doesn't support FormatMessage. - const char error_text[] = ""; - -# else - - // Looks up the human-readable system message for the HRESULT code - // and since we're not passing any params to FormatMessage, we don't - // want inserts expanded. - const DWORD kFlags = FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS; - const DWORD kBufSize = 4096; - // Gets the system's human readable message string for this HRESULT. - char error_text[kBufSize] = { '\0' }; - DWORD message_length = ::FormatMessageA(kFlags, - 0, // no source, we're asking system - hr, // the error - 0, // no line width restrictions - error_text, // output buffer - kBufSize, // buf size - NULL); // no arguments for inserts - // Trims tailing white space (FormatMessage leaves a trailing CR-LF) - for (; message_length && IsSpace(error_text[message_length - 1]); - --message_length) { - error_text[message_length - 1] = '\0'; - } - -# endif // GTEST_OS_WINDOWS_MOBILE - - const std::string error_hex("0x" + String::FormatHexInt(hr)); - return ::testing::AssertionFailure() - << "Expected: " << expr << " " << expected << ".\n" - << " Actual: " << error_hex << " " << error_text << "\n"; -} - -} // namespace - -AssertionResult IsHRESULTSuccess(const char* expr, long hr) { // NOLINT - if (SUCCEEDED(hr)) { - return AssertionSuccess(); - } - return HRESULTFailureHelper(expr, "succeeds", hr); -} - -AssertionResult IsHRESULTFailure(const char* expr, long hr) { // NOLINT - if (FAILED(hr)) { - return AssertionSuccess(); - } - return HRESULTFailureHelper(expr, "fails", hr); -} - -#endif // GTEST_OS_WINDOWS - -// Utility functions for encoding Unicode text (wide strings) in -// UTF-8. - -// A Unicode code-point can have up to 21 bits, and is encoded in UTF-8 -// like this: -// -// Code-point length Encoding -// 0 - 7 bits 0xxxxxxx -// 8 - 11 bits 110xxxxx 10xxxxxx -// 12 - 16 bits 1110xxxx 10xxxxxx 10xxxxxx -// 17 - 21 bits 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - -// The maximum code-point a one-byte UTF-8 sequence can represent. -const UInt32 kMaxCodePoint1 = (static_cast(1) << 7) - 1; - -// The maximum code-point a two-byte UTF-8 sequence can represent. -const UInt32 kMaxCodePoint2 = (static_cast(1) << (5 + 6)) - 1; - -// The maximum code-point a three-byte UTF-8 sequence can represent. -const UInt32 kMaxCodePoint3 = (static_cast(1) << (4 + 2*6)) - 1; - -// The maximum code-point a four-byte UTF-8 sequence can represent. -const UInt32 kMaxCodePoint4 = (static_cast(1) << (3 + 3*6)) - 1; - -// Chops off the n lowest bits from a bit pattern. Returns the n -// lowest bits. As a side effect, the original bit pattern will be -// shifted to the right by n bits. -inline UInt32 ChopLowBits(UInt32* bits, int n) { - const UInt32 low_bits = *bits & ((static_cast(1) << n) - 1); - *bits >>= n; - return low_bits; -} - -// Converts a Unicode code point to a narrow string in UTF-8 encoding. -// code_point parameter is of type UInt32 because wchar_t may not be -// wide enough to contain a code point. -// If the code_point is not a valid Unicode code point -// (i.e. outside of Unicode range U+0 to U+10FFFF) it will be converted -// to "(Invalid Unicode 0xXXXXXXXX)". -std::string CodePointToUtf8(UInt32 code_point) { - if (code_point > kMaxCodePoint4) { - return "(Invalid Unicode 0x" + String::FormatHexInt(code_point) + ")"; - } - - char str[5]; // Big enough for the largest valid code point. - if (code_point <= kMaxCodePoint1) { - str[1] = '\0'; - str[0] = static_cast(code_point); // 0xxxxxxx - } else if (code_point <= kMaxCodePoint2) { - str[2] = '\0'; - str[1] = static_cast(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx - str[0] = static_cast(0xC0 | code_point); // 110xxxxx - } else if (code_point <= kMaxCodePoint3) { - str[3] = '\0'; - str[2] = static_cast(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx - str[1] = static_cast(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx - str[0] = static_cast(0xE0 | code_point); // 1110xxxx - } else { // code_point <= kMaxCodePoint4 - str[4] = '\0'; - str[3] = static_cast(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx - str[2] = static_cast(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx - str[1] = static_cast(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx - str[0] = static_cast(0xF0 | code_point); // 11110xxx - } - return str; -} - -// The following two functions only make sense if the system -// uses UTF-16 for wide string encoding. All supported systems -// with 16 bit wchar_t (Windows, Cygwin, Symbian OS) do use UTF-16. - -// Determines if the arguments constitute UTF-16 surrogate pair -// and thus should be combined into a single Unicode code point -// using CreateCodePointFromUtf16SurrogatePair. -inline bool IsUtf16SurrogatePair(wchar_t first, wchar_t second) { - return sizeof(wchar_t) == 2 && - (first & 0xFC00) == 0xD800 && (second & 0xFC00) == 0xDC00; -} - -// Creates a Unicode code point from UTF16 surrogate pair. -inline UInt32 CreateCodePointFromUtf16SurrogatePair(wchar_t first, - wchar_t second) { - const UInt32 mask = (1 << 10) - 1; - return (sizeof(wchar_t) == 2) ? - (((first & mask) << 10) | (second & mask)) + 0x10000 : - // This function should not be called when the condition is - // false, but we provide a sensible default in case it is. - static_cast(first); -} - -// Converts a wide string to a narrow string in UTF-8 encoding. -// The wide string is assumed to have the following encoding: -// UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin, Symbian OS) -// UTF-32 if sizeof(wchar_t) == 4 (on Linux) -// Parameter str points to a null-terminated wide string. -// Parameter num_chars may additionally limit the number -// of wchar_t characters processed. -1 is used when the entire string -// should be processed. -// If the string contains code points that are not valid Unicode code points -// (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output -// as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding -// and contains invalid UTF-16 surrogate pairs, values in those pairs -// will be encoded as individual Unicode characters from Basic Normal Plane. -std::string WideStringToUtf8(const wchar_t* str, int num_chars) { - if (num_chars == -1) - num_chars = static_cast(wcslen(str)); - - ::std::stringstream stream; - for (int i = 0; i < num_chars; ++i) { - UInt32 unicode_code_point; - - if (str[i] == L'\0') { - break; - } else if (i + 1 < num_chars && IsUtf16SurrogatePair(str[i], str[i + 1])) { - unicode_code_point = CreateCodePointFromUtf16SurrogatePair(str[i], - str[i + 1]); - i++; - } else { - unicode_code_point = static_cast(str[i]); - } - - stream << CodePointToUtf8(unicode_code_point); - } - return StringStreamToString(&stream); -} - -// Converts a wide C string to an std::string using the UTF-8 encoding. -// NULL will be converted to "(null)". -std::string String::ShowWideCString(const wchar_t * wide_c_str) { - if (wide_c_str == NULL) return "(null)"; - - return internal::WideStringToUtf8(wide_c_str, -1); -} - -// Compares two wide C strings. Returns true iff they have the same -// content. -// -// Unlike wcscmp(), this function can handle NULL argument(s). A NULL -// C string is considered different to any non-NULL C string, -// including the empty string. -bool String::WideCStringEquals(const wchar_t * lhs, const wchar_t * rhs) { - if (lhs == NULL) return rhs == NULL; - - if (rhs == NULL) return false; - - return wcscmp(lhs, rhs) == 0; -} - -// Helper function for *_STREQ on wide strings. -AssertionResult CmpHelperSTREQ(const char* lhs_expression, - const char* rhs_expression, - const wchar_t* lhs, - const wchar_t* rhs) { - if (String::WideCStringEquals(lhs, rhs)) { - return AssertionSuccess(); - } - - return EqFailure(lhs_expression, - rhs_expression, - PrintToString(lhs), - PrintToString(rhs), - false); -} - -// Helper function for *_STRNE on wide strings. -AssertionResult CmpHelperSTRNE(const char* s1_expression, - const char* s2_expression, - const wchar_t* s1, - const wchar_t* s2) { - if (!String::WideCStringEquals(s1, s2)) { - return AssertionSuccess(); - } - - return AssertionFailure() << "Expected: (" << s1_expression << ") != (" - << s2_expression << "), actual: " - << PrintToString(s1) - << " vs " << PrintToString(s2); -} - -// Compares two C strings, ignoring case. Returns true iff they have -// the same content. -// -// Unlike strcasecmp(), this function can handle NULL argument(s). A -// NULL C string is considered different to any non-NULL C string, -// including the empty string. -bool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) { - if (lhs == NULL) - return rhs == NULL; - if (rhs == NULL) - return false; - return posix::StrCaseCmp(lhs, rhs) == 0; -} - - // Compares two wide C strings, ignoring case. Returns true iff they - // have the same content. - // - // Unlike wcscasecmp(), this function can handle NULL argument(s). - // A NULL C string is considered different to any non-NULL wide C string, - // including the empty string. - // NB: The implementations on different platforms slightly differ. - // On windows, this method uses _wcsicmp which compares according to LC_CTYPE - // environment variable. On GNU platform this method uses wcscasecmp - // which compares according to LC_CTYPE category of the current locale. - // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the - // current locale. -bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs, - const wchar_t* rhs) { - if (lhs == NULL) return rhs == NULL; - - if (rhs == NULL) return false; - -#if GTEST_OS_WINDOWS - return _wcsicmp(lhs, rhs) == 0; -#elif GTEST_OS_LINUX && !GTEST_OS_LINUX_ANDROID - return wcscasecmp(lhs, rhs) == 0; -#else - // Android, Mac OS X and Cygwin don't define wcscasecmp. - // Other unknown OSes may not define it either. - wint_t left, right; - do { - left = towlower(*lhs++); - right = towlower(*rhs++); - } while (left && left == right); - return left == right; -#endif // OS selector -} - -// Returns true iff str ends with the given suffix, ignoring case. -// Any string is considered to end with an empty suffix. -bool String::EndsWithCaseInsensitive( - const std::string& str, const std::string& suffix) { - const size_t str_len = str.length(); - const size_t suffix_len = suffix.length(); - return (str_len >= suffix_len) && - CaseInsensitiveCStringEquals(str.c_str() + str_len - suffix_len, - suffix.c_str()); -} - -// Formats an int value as "%02d". -std::string String::FormatIntWidth2(int value) { - std::stringstream ss; - ss << std::setfill('0') << std::setw(2) << value; - return ss.str(); -} - -// Formats an int value as "%X". -std::string String::FormatHexInt(int value) { - std::stringstream ss; - ss << std::hex << std::uppercase << value; - return ss.str(); -} - -// Formats a byte as "%02X". -std::string String::FormatByte(unsigned char value) { - std::stringstream ss; - ss << std::setfill('0') << std::setw(2) << std::hex << std::uppercase - << static_cast(value); - return ss.str(); -} - -// Converts the buffer in a stringstream to an std::string, converting NUL -// bytes to "\\0" along the way. -std::string StringStreamToString(::std::stringstream* ss) { - const ::std::string& str = ss->str(); - const char* const start = str.c_str(); - const char* const end = start + str.length(); - - std::string result; - result.reserve(2 * (end - start)); - for (const char* ch = start; ch != end; ++ch) { - if (*ch == '\0') { - result += "\\0"; // Replaces NUL with "\\0"; - } else { - result += *ch; - } - } - - return result; -} - -// Appends the user-supplied message to the Google-Test-generated message. -std::string AppendUserMessage(const std::string& gtest_msg, - const Message& user_msg) { - // Appends the user message if it's non-empty. - const std::string user_msg_string = user_msg.GetString(); - if (user_msg_string.empty()) { - return gtest_msg; - } - - return gtest_msg + "\n" + user_msg_string; -} - -} // namespace internal - -// class TestResult - -// Creates an empty TestResult. -TestResult::TestResult() - : death_test_count_(0), - elapsed_time_(0) { -} - -// D'tor. -TestResult::~TestResult() { -} - -// Returns the i-th test part result among all the results. i can -// range from 0 to total_part_count() - 1. If i is not in that range, -// aborts the program. -const TestPartResult& TestResult::GetTestPartResult(int i) const { - if (i < 0 || i >= total_part_count()) - internal::posix::Abort(); - return test_part_results_.at(i); -} - -// Returns the i-th test property. i can range from 0 to -// test_property_count() - 1. If i is not in that range, aborts the -// program. -const TestProperty& TestResult::GetTestProperty(int i) const { - if (i < 0 || i >= test_property_count()) - internal::posix::Abort(); - return test_properties_.at(i); -} - -// Clears the test part results. -void TestResult::ClearTestPartResults() { - test_part_results_.clear(); -} - -// Adds a test part result to the list. -void TestResult::AddTestPartResult(const TestPartResult& test_part_result) { - test_part_results_.push_back(test_part_result); -} - -// Adds a test property to the list. If a property with the same key as the -// supplied property is already represented, the value of this test_property -// replaces the old value for that key. -void TestResult::RecordProperty(const std::string& xml_element, - const TestProperty& test_property) { - if (!ValidateTestProperty(xml_element, test_property)) { - return; - } - internal::MutexLock lock(&test_properites_mutex_); - const std::vector::iterator property_with_matching_key = - std::find_if(test_properties_.begin(), test_properties_.end(), - internal::TestPropertyKeyIs(test_property.key())); - if (property_with_matching_key == test_properties_.end()) { - test_properties_.push_back(test_property); - return; - } - property_with_matching_key->SetValue(test_property.value()); -} - -// The list of reserved attributes used in the element of XML -// output. -static const char* const kReservedTestSuitesAttributes[] = { - "disabled", - "errors", - "failures", - "name", - "random_seed", - "tests", - "time", - "timestamp" -}; - -// The list of reserved attributes used in the element of XML -// output. -static const char* const kReservedTestSuiteAttributes[] = { - "disabled", - "errors", - "failures", - "name", - "tests", - "time" -}; - -// The list of reserved attributes used in the element of XML output. -static const char* const kReservedTestCaseAttributes[] = { - "classname", - "name", - "status", - "time", - "type_param", - "value_param" -}; - -template -std::vector ArrayAsVector(const char* const (&array)[kSize]) { - return std::vector(array, array + kSize); -} - -static std::vector GetReservedAttributesForElement( - const std::string& xml_element) { - if (xml_element == "testsuites") { - return ArrayAsVector(kReservedTestSuitesAttributes); - } else if (xml_element == "testsuite") { - return ArrayAsVector(kReservedTestSuiteAttributes); - } else if (xml_element == "testcase") { - return ArrayAsVector(kReservedTestCaseAttributes); - } else { - GTEST_CHECK_(false) << "Unrecognized xml_element provided: " << xml_element; - } - // This code is unreachable but some compilers may not realizes that. - return std::vector(); -} - -static std::string FormatWordList(const std::vector& words) { - Message word_list; - for (size_t i = 0; i < words.size(); ++i) { - if (i > 0 && words.size() > 2) { - word_list << ", "; - } - if (i == words.size() - 1) { - word_list << "and "; - } - word_list << "'" << words[i] << "'"; - } - return word_list.GetString(); -} - -static bool ValidateTestPropertyName( - const std::string& property_name, - const std::vector& reserved_names) { - if (std::find(reserved_names.begin(), reserved_names.end(), property_name) != - reserved_names.end()) { - ADD_FAILURE() << "Reserved key used in RecordProperty(): " << property_name - << " (" << FormatWordList(reserved_names) - << " are reserved by " << GTEST_NAME_ << ")"; - return false; - } - return true; -} - -// Adds a failure if the key is a reserved attribute of the element named -// xml_element. Returns true if the property is valid. -bool TestResult::ValidateTestProperty(const std::string& xml_element, - const TestProperty& test_property) { - return ValidateTestPropertyName(test_property.key(), - GetReservedAttributesForElement(xml_element)); -} - -// Clears the object. -void TestResult::Clear() { - test_part_results_.clear(); - test_properties_.clear(); - death_test_count_ = 0; - elapsed_time_ = 0; -} - -// Returns true iff the test failed. -bool TestResult::Failed() const { - for (int i = 0; i < total_part_count(); ++i) { - if (GetTestPartResult(i).failed()) - return true; - } - return false; -} - -// Returns true iff the test part fatally failed. -static bool TestPartFatallyFailed(const TestPartResult& result) { - return result.fatally_failed(); -} - -// Returns true iff the test fatally failed. -bool TestResult::HasFatalFailure() const { - return CountIf(test_part_results_, TestPartFatallyFailed) > 0; -} - -// Returns true iff the test part non-fatally failed. -static bool TestPartNonfatallyFailed(const TestPartResult& result) { - return result.nonfatally_failed(); -} - -// Returns true iff the test has a non-fatal failure. -bool TestResult::HasNonfatalFailure() const { - return CountIf(test_part_results_, TestPartNonfatallyFailed) > 0; -} - -// Gets the number of all test parts. This is the sum of the number -// of successful test parts and the number of failed test parts. -int TestResult::total_part_count() const { - return static_cast(test_part_results_.size()); -} - -// Returns the number of the test properties. -int TestResult::test_property_count() const { - return static_cast(test_properties_.size()); -} - -// class Test - -// Creates a Test object. - -// The c'tor saves the states of all flags. -Test::Test() - : gtest_flag_saver_(new GTEST_FLAG_SAVER_) { -} - -// The d'tor restores the states of all flags. The actual work is -// done by the d'tor of the gtest_flag_saver_ field, and thus not -// visible here. -Test::~Test() { -} - -// Sets up the test fixture. -// -// A sub-class may override this. -void Test::SetUp() { -} - -// Tears down the test fixture. -// -// A sub-class may override this. -void Test::TearDown() { -} - -// Allows user supplied key value pairs to be recorded for later output. -void Test::RecordProperty(const std::string& key, const std::string& value) { - UnitTest::GetInstance()->RecordProperty(key, value); -} - -// Allows user supplied key value pairs to be recorded for later output. -void Test::RecordProperty(const std::string& key, int value) { - Message value_message; - value_message << value; - RecordProperty(key, value_message.GetString().c_str()); -} - -namespace internal { - -void ReportFailureInUnknownLocation(TestPartResult::Type result_type, - const std::string& message) { - // This function is a friend of UnitTest and as such has access to - // AddTestPartResult. - UnitTest::GetInstance()->AddTestPartResult( - result_type, - NULL, // No info about the source file where the exception occurred. - -1, // We have no info on which line caused the exception. - message, - ""); // No stack trace, either. -} - -} // namespace internal - -// Google Test requires all tests in the same test case to use the same test -// fixture class. This function checks if the current test has the -// same fixture class as the first test in the current test case. If -// yes, it returns true; otherwise it generates a Google Test failure and -// returns false. -bool Test::HasSameFixtureClass() { - internal::UnitTestImpl* const impl = internal::GetUnitTestImpl(); - const TestCase* const test_case = impl->current_test_case(); - - // Info about the first test in the current test case. - const TestInfo* const first_test_info = test_case->test_info_list()[0]; - const internal::TypeId first_fixture_id = first_test_info->fixture_class_id_; - const char* const first_test_name = first_test_info->name(); - - // Info about the current test. - const TestInfo* const this_test_info = impl->current_test_info(); - const internal::TypeId this_fixture_id = this_test_info->fixture_class_id_; - const char* const this_test_name = this_test_info->name(); - - if (this_fixture_id != first_fixture_id) { - // Is the first test defined using TEST? - const bool first_is_TEST = first_fixture_id == internal::GetTestTypeId(); - // Is this test defined using TEST? - const bool this_is_TEST = this_fixture_id == internal::GetTestTypeId(); - - if (first_is_TEST || this_is_TEST) { - // Both TEST and TEST_F appear in same test case, which is incorrect. - // Tell the user how to fix this. - - // Gets the name of the TEST and the name of the TEST_F. Note - // that first_is_TEST and this_is_TEST cannot both be true, as - // the fixture IDs are different for the two tests. - const char* const TEST_name = - first_is_TEST ? first_test_name : this_test_name; - const char* const TEST_F_name = - first_is_TEST ? this_test_name : first_test_name; - - ADD_FAILURE() - << "All tests in the same test case must use the same test fixture\n" - << "class, so mixing TEST_F and TEST in the same test case is\n" - << "illegal. In test case " << this_test_info->test_case_name() - << ",\n" - << "test " << TEST_F_name << " is defined using TEST_F but\n" - << "test " << TEST_name << " is defined using TEST. You probably\n" - << "want to change the TEST to TEST_F or move it to another test\n" - << "case."; - } else { - // Two fixture classes with the same name appear in two different - // namespaces, which is not allowed. Tell the user how to fix this. - ADD_FAILURE() - << "All tests in the same test case must use the same test fixture\n" - << "class. However, in test case " - << this_test_info->test_case_name() << ",\n" - << "you defined test " << first_test_name - << " and test " << this_test_name << "\n" - << "using two different test fixture classes. This can happen if\n" - << "the two classes are from different namespaces or translation\n" - << "units and have the same name. You should probably rename one\n" - << "of the classes to put the tests into different test cases."; - } - return false; - } - - return true; -} - -#if GTEST_HAS_SEH - -// Adds an "exception thrown" fatal failure to the current test. This -// function returns its result via an output parameter pointer because VC++ -// prohibits creation of objects with destructors on stack in functions -// using __try (see error C2712). -static std::string* FormatSehExceptionMessage(DWORD exception_code, - const char* location) { - Message message; - message << "SEH exception with code 0x" << std::setbase(16) << - exception_code << std::setbase(10) << " thrown in " << location << "."; - - return new std::string(message.GetString()); -} - -#endif // GTEST_HAS_SEH - -namespace internal { - -#if GTEST_HAS_EXCEPTIONS - -// Adds an "exception thrown" fatal failure to the current test. -static std::string FormatCxxExceptionMessage(const char* description, - const char* location) { - Message message; - if (description != NULL) { - message << "C++ exception with description \"" << description << "\""; - } else { - message << "Unknown C++ exception"; - } - message << " thrown in " << location << "."; - - return message.GetString(); -} - -static std::string PrintTestPartResultToString( - const TestPartResult& test_part_result); - -GoogleTestFailureException::GoogleTestFailureException( - const TestPartResult& failure) - : ::std::runtime_error(PrintTestPartResultToString(failure).c_str()) {} - -#endif // GTEST_HAS_EXCEPTIONS - -// We put these helper functions in the internal namespace as IBM's xlC -// compiler rejects the code if they were declared static. - -// Runs the given method and handles SEH exceptions it throws, when -// SEH is supported; returns the 0-value for type Result in case of an -// SEH exception. (Microsoft compilers cannot handle SEH and C++ -// exceptions in the same function. Therefore, we provide a separate -// wrapper function for handling SEH exceptions.) -template -Result HandleSehExceptionsInMethodIfSupported( - T* object, Result (T::*method)(), const char* location) { -#if GTEST_HAS_SEH - __try { - return (object->*method)(); - } __except (internal::UnitTestOptions::GTestShouldProcessSEH( // NOLINT - GetExceptionCode())) { - // We create the exception message on the heap because VC++ prohibits - // creation of objects with destructors on stack in functions using __try - // (see error C2712). - std::string* exception_message = FormatSehExceptionMessage( - GetExceptionCode(), location); - internal::ReportFailureInUnknownLocation(TestPartResult::kFatalFailure, - *exception_message); - delete exception_message; - return static_cast(0); - } -#else - (void)location; - return (object->*method)(); -#endif // GTEST_HAS_SEH -} - -// Runs the given method and catches and reports C++ and/or SEH-style -// exceptions, if they are supported; returns the 0-value for type -// Result in case of an SEH exception. -template -Result HandleExceptionsInMethodIfSupported( - T* object, Result (T::*method)(), const char* location) { - // NOTE: The user code can affect the way in which Google Test handles - // exceptions by setting GTEST_FLAG(catch_exceptions), but only before - // RUN_ALL_TESTS() starts. It is technically possible to check the flag - // after the exception is caught and either report or re-throw the - // exception based on the flag's value: - // - // try { - // // Perform the test method. - // } catch (...) { - // if (GTEST_FLAG(catch_exceptions)) - // // Report the exception as failure. - // else - // throw; // Re-throws the original exception. - // } - // - // However, the purpose of this flag is to allow the program to drop into - // the debugger when the exception is thrown. On most platforms, once the - // control enters the catch block, the exception origin information is - // lost and the debugger will stop the program at the point of the - // re-throw in this function -- instead of at the point of the original - // throw statement in the code under test. For this reason, we perform - // the check early, sacrificing the ability to affect Google Test's - // exception handling in the method where the exception is thrown. - if (internal::GetUnitTestImpl()->catch_exceptions()) { -#if GTEST_HAS_EXCEPTIONS - try { - return HandleSehExceptionsInMethodIfSupported(object, method, location); - } catch (const AssertionException&) { // NOLINT - // This failure was reported already. - } catch (const internal::GoogleTestFailureException&) { // NOLINT - // This exception type can only be thrown by a failed Google - // Test assertion with the intention of letting another testing - // framework catch it. Therefore we just re-throw it. - throw; - } catch (const std::exception& e) { // NOLINT - internal::ReportFailureInUnknownLocation( - TestPartResult::kFatalFailure, - FormatCxxExceptionMessage(e.what(), location)); - } catch (...) { // NOLINT - internal::ReportFailureInUnknownLocation( - TestPartResult::kFatalFailure, - FormatCxxExceptionMessage(NULL, location)); - } - return static_cast(0); -#else - return HandleSehExceptionsInMethodIfSupported(object, method, location); -#endif // GTEST_HAS_EXCEPTIONS - } else { - return (object->*method)(); - } -} - -} // namespace internal - -// Runs the test and updates the test result. -void Test::Run() { - if (!HasSameFixtureClass()) return; - - internal::UnitTestImpl* const impl = internal::GetUnitTestImpl(); - impl->os_stack_trace_getter()->UponLeavingGTest(); - internal::HandleExceptionsInMethodIfSupported(this, &Test::SetUp, "SetUp()"); - // We will run the test only if SetUp() was successful. - if (!HasFatalFailure()) { - impl->os_stack_trace_getter()->UponLeavingGTest(); - internal::HandleExceptionsInMethodIfSupported( - this, &Test::TestBody, "the test body"); - } - - // However, we want to clean up as much as possible. Hence we will - // always call TearDown(), even if SetUp() or the test body has - // failed. - impl->os_stack_trace_getter()->UponLeavingGTest(); - internal::HandleExceptionsInMethodIfSupported( - this, &Test::TearDown, "TearDown()"); -} - -// Returns true iff the current test has a fatal failure. -bool Test::HasFatalFailure() { - return internal::GetUnitTestImpl()->current_test_result()->HasFatalFailure(); -} - -// Returns true iff the current test has a non-fatal failure. -bool Test::HasNonfatalFailure() { - return internal::GetUnitTestImpl()->current_test_result()-> - HasNonfatalFailure(); -} - -// class TestInfo - -// Constructs a TestInfo object. It assumes ownership of the test factory -// object. -TestInfo::TestInfo(const std::string& a_test_case_name, - const std::string& a_name, - const char* a_type_param, - const char* a_value_param, - internal::CodeLocation a_code_location, - internal::TypeId fixture_class_id, - internal::TestFactoryBase* factory) - : test_case_name_(a_test_case_name), - name_(a_name), - type_param_(a_type_param ? new std::string(a_type_param) : NULL), - value_param_(a_value_param ? new std::string(a_value_param) : NULL), - location_(a_code_location), - fixture_class_id_(fixture_class_id), - should_run_(false), - is_disabled_(false), - matches_filter_(false), - factory_(factory), - result_() {} - -// Destructs a TestInfo object. -TestInfo::~TestInfo() { delete factory_; } - -namespace internal { - -// Creates a new TestInfo object and registers it with Google Test; -// returns the created object. -// -// Arguments: -// -// test_case_name: name of the test case -// name: name of the test -// type_param: the name of the test's type parameter, or NULL if -// this is not a typed or a type-parameterized test. -// value_param: text representation of the test's value parameter, -// or NULL if this is not a value-parameterized test. -// code_location: code location where the test is defined -// fixture_class_id: ID of the test fixture class -// set_up_tc: pointer to the function that sets up the test case -// tear_down_tc: pointer to the function that tears down the test case -// factory: pointer to the factory that creates a test object. -// The newly created TestInfo instance will assume -// ownership of the factory object. -TestInfo* MakeAndRegisterTestInfo( - const char* test_case_name, - const char* name, - const char* type_param, - const char* value_param, - CodeLocation code_location, - TypeId fixture_class_id, - SetUpTestCaseFunc set_up_tc, - TearDownTestCaseFunc tear_down_tc, - TestFactoryBase* factory) { - TestInfo* const test_info = - new TestInfo(test_case_name, name, type_param, value_param, - code_location, fixture_class_id, factory); - GetUnitTestImpl()->AddTestInfo(set_up_tc, tear_down_tc, test_info); - return test_info; -} - -void ReportInvalidTestCaseType(const char* test_case_name, - CodeLocation code_location) { - Message errors; - errors - << "Attempted redefinition of test case " << test_case_name << ".\n" - << "All tests in the same test case must use the same test fixture\n" - << "class. However, in test case " << test_case_name << ", you tried\n" - << "to define a test using a fixture class different from the one\n" - << "used earlier. This can happen if the two fixture classes are\n" - << "from different namespaces and have the same name. You should\n" - << "probably rename one of the classes to put the tests into different\n" - << "test cases."; - - GTEST_LOG_(ERROR) << FormatFileLocation(code_location.file.c_str(), - code_location.line) - << " " << errors.GetString(); -} -} // namespace internal - -namespace { - -// A predicate that checks the test name of a TestInfo against a known -// value. -// -// This is used for implementation of the TestCase class only. We put -// it in the anonymous namespace to prevent polluting the outer -// namespace. -// -// TestNameIs is copyable. -class TestNameIs { - public: - // Constructor. - // - // TestNameIs has NO default constructor. - explicit TestNameIs(const char* name) - : name_(name) {} - - // Returns true iff the test name of test_info matches name_. - bool operator()(const TestInfo * test_info) const { - return test_info && test_info->name() == name_; - } - - private: - std::string name_; -}; - -} // namespace - -namespace internal { - -// This method expands all parameterized tests registered with macros TEST_P -// and INSTANTIATE_TEST_CASE_P into regular tests and registers those. -// This will be done just once during the program runtime. -void UnitTestImpl::RegisterParameterizedTests() { - if (!parameterized_tests_registered_) { - parameterized_test_registry_.RegisterTests(); - parameterized_tests_registered_ = true; - } -} - -} // namespace internal - -// Creates the test object, runs it, records its result, and then -// deletes it. -void TestInfo::Run() { - if (!should_run_) return; - - // Tells UnitTest where to store test result. - internal::UnitTestImpl* const impl = internal::GetUnitTestImpl(); - impl->set_current_test_info(this); - - TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater(); - - // Notifies the unit test event listeners that a test is about to start. - repeater->OnTestStart(*this); - - const TimeInMillis start = internal::GetTimeInMillis(); - - impl->os_stack_trace_getter()->UponLeavingGTest(); - - // Creates the test object. - Test* const test = internal::HandleExceptionsInMethodIfSupported( - factory_, &internal::TestFactoryBase::CreateTest, - "the test fixture's constructor"); - - // Runs the test only if the test object was created and its - // constructor didn't generate a fatal failure. - if ((test != NULL) && !Test::HasFatalFailure()) { - // This doesn't throw as all user code that can throw are wrapped into - // exception handling code. - test->Run(); - } - - // Deletes the test object. - impl->os_stack_trace_getter()->UponLeavingGTest(); - internal::HandleExceptionsInMethodIfSupported( - test, &Test::DeleteSelf_, "the test fixture's destructor"); - - result_.set_elapsed_time(internal::GetTimeInMillis() - start); - - // Notifies the unit test event listener that a test has just finished. - repeater->OnTestEnd(*this); - - // Tells UnitTest to stop associating assertion results to this - // test. - impl->set_current_test_info(NULL); -} - -// class TestCase - -// Gets the number of successful tests in this test case. -int TestCase::successful_test_count() const { - return CountIf(test_info_list_, TestPassed); -} - -// Gets the number of failed tests in this test case. -int TestCase::failed_test_count() const { - return CountIf(test_info_list_, TestFailed); -} - -// Gets the number of disabled tests that will be reported in the XML report. -int TestCase::reportable_disabled_test_count() const { - return CountIf(test_info_list_, TestReportableDisabled); -} - -// Gets the number of disabled tests in this test case. -int TestCase::disabled_test_count() const { - return CountIf(test_info_list_, TestDisabled); -} - -// Gets the number of tests to be printed in the XML report. -int TestCase::reportable_test_count() const { - return CountIf(test_info_list_, TestReportable); -} - -// Get the number of tests in this test case that should run. -int TestCase::test_to_run_count() const { - return CountIf(test_info_list_, ShouldRunTest); -} - -// Gets the number of all tests. -int TestCase::total_test_count() const { - return static_cast(test_info_list_.size()); -} - -// Creates a TestCase with the given name. -// -// Arguments: -// -// name: name of the test case -// a_type_param: the name of the test case's type parameter, or NULL if -// this is not a typed or a type-parameterized test case. -// set_up_tc: pointer to the function that sets up the test case -// tear_down_tc: pointer to the function that tears down the test case -TestCase::TestCase(const char* a_name, const char* a_type_param, - Test::SetUpTestCaseFunc set_up_tc, - Test::TearDownTestCaseFunc tear_down_tc) - : name_(a_name), - type_param_(a_type_param ? new std::string(a_type_param) : NULL), - set_up_tc_(set_up_tc), - tear_down_tc_(tear_down_tc), - should_run_(false), - elapsed_time_(0) { -} - -// Destructor of TestCase. -TestCase::~TestCase() { - // Deletes every Test in the collection. - ForEach(test_info_list_, internal::Delete); -} - -// Returns the i-th test among all the tests. i can range from 0 to -// total_test_count() - 1. If i is not in that range, returns NULL. -const TestInfo* TestCase::GetTestInfo(int i) const { - const int index = GetElementOr(test_indices_, i, -1); - return index < 0 ? NULL : test_info_list_[index]; -} - -// Returns the i-th test among all the tests. i can range from 0 to -// total_test_count() - 1. If i is not in that range, returns NULL. -TestInfo* TestCase::GetMutableTestInfo(int i) { - const int index = GetElementOr(test_indices_, i, -1); - return index < 0 ? NULL : test_info_list_[index]; -} - -// Adds a test to this test case. Will delete the test upon -// destruction of the TestCase object. -void TestCase::AddTestInfo(TestInfo * test_info) { - test_info_list_.push_back(test_info); - test_indices_.push_back(static_cast(test_indices_.size())); -} - -// Runs every test in this TestCase. -void TestCase::Run() { - if (!should_run_) return; - - internal::UnitTestImpl* const impl = internal::GetUnitTestImpl(); - impl->set_current_test_case(this); - - TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater(); - - repeater->OnTestCaseStart(*this); - impl->os_stack_trace_getter()->UponLeavingGTest(); - internal::HandleExceptionsInMethodIfSupported( - this, &TestCase::RunSetUpTestCase, "SetUpTestCase()"); - - const internal::TimeInMillis start = internal::GetTimeInMillis(); - for (int i = 0; i < total_test_count(); i++) { - GetMutableTestInfo(i)->Run(); - } - elapsed_time_ = internal::GetTimeInMillis() - start; - - impl->os_stack_trace_getter()->UponLeavingGTest(); - internal::HandleExceptionsInMethodIfSupported( - this, &TestCase::RunTearDownTestCase, "TearDownTestCase()"); - - repeater->OnTestCaseEnd(*this); - impl->set_current_test_case(NULL); -} - -// Clears the results of all tests in this test case. -void TestCase::ClearResult() { - ad_hoc_test_result_.Clear(); - ForEach(test_info_list_, TestInfo::ClearTestResult); -} - -// Shuffles the tests in this test case. -void TestCase::ShuffleTests(internal::Random* random) { - Shuffle(random, &test_indices_); -} - -// Restores the test order to before the first shuffle. -void TestCase::UnshuffleTests() { - for (size_t i = 0; i < test_indices_.size(); i++) { - test_indices_[i] = static_cast(i); - } -} - -// Formats a countable noun. Depending on its quantity, either the -// singular form or the plural form is used. e.g. -// -// FormatCountableNoun(1, "formula", "formuli") returns "1 formula". -// FormatCountableNoun(5, "book", "books") returns "5 books". -static std::string FormatCountableNoun(int count, - const char * singular_form, - const char * plural_form) { - return internal::StreamableToString(count) + " " + - (count == 1 ? singular_form : plural_form); -} - -// Formats the count of tests. -static std::string FormatTestCount(int test_count) { - return FormatCountableNoun(test_count, "test", "tests"); -} - -// Formats the count of test cases. -static std::string FormatTestCaseCount(int test_case_count) { - return FormatCountableNoun(test_case_count, "test case", "test cases"); -} - -// Converts a TestPartResult::Type enum to human-friendly string -// representation. Both kNonFatalFailure and kFatalFailure are translated -// to "Failure", as the user usually doesn't care about the difference -// between the two when viewing the test result. -static const char * TestPartResultTypeToString(TestPartResult::Type type) { - switch (type) { - case TestPartResult::kSuccess: - return "Success"; - - case TestPartResult::kNonFatalFailure: - case TestPartResult::kFatalFailure: -#ifdef _MSC_VER - return "error: "; -#else - return "Failure\n"; -#endif - default: - return "Unknown result type"; - } -} - -namespace internal { - -// Prints a TestPartResult to an std::string. -static std::string PrintTestPartResultToString( - const TestPartResult& test_part_result) { - return (Message() - << internal::FormatFileLocation(test_part_result.file_name(), - test_part_result.line_number()) - << " " << TestPartResultTypeToString(test_part_result.type()) - << test_part_result.message()).GetString(); -} - -// Prints a TestPartResult. -static void PrintTestPartResult(const TestPartResult& test_part_result) { - const std::string& result = - PrintTestPartResultToString(test_part_result); - printf("%s\n", result.c_str()); - fflush(stdout); - // If the test program runs in Visual Studio or a debugger, the - // following statements add the test part result message to the Output - // window such that the user can double-click on it to jump to the - // corresponding source code location; otherwise they do nothing. -#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE - // We don't call OutputDebugString*() on Windows Mobile, as printing - // to stdout is done by OutputDebugString() there already - we don't - // want the same message printed twice. - ::OutputDebugStringA(result.c_str()); - ::OutputDebugStringA("\n"); -#endif -} - -// class PrettyUnitTestResultPrinter - -enum GTestColor { - COLOR_DEFAULT, - COLOR_RED, - COLOR_GREEN, - COLOR_YELLOW -}; - -#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && \ - !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW - -// Returns the character attribute for the given color. -static WORD GetColorAttribute(GTestColor color) { - switch (color) { - case COLOR_RED: return FOREGROUND_RED; - case COLOR_GREEN: return FOREGROUND_GREEN; - case COLOR_YELLOW: return FOREGROUND_RED | FOREGROUND_GREEN; - default: return 0; - } -} - -static int GetBitOffset(WORD color_mask) { - if (color_mask == 0) return 0; - - int bitOffset = 0; - while ((color_mask & 1) == 0) { - color_mask >>= 1; - ++bitOffset; - } - return bitOffset; -} - -static WORD GetNewColor(GTestColor color, WORD old_color_attrs) { - // Let's reuse the BG - static const WORD background_mask = BACKGROUND_BLUE | BACKGROUND_GREEN | - BACKGROUND_RED | BACKGROUND_INTENSITY; - static const WORD foreground_mask = FOREGROUND_BLUE | FOREGROUND_GREEN | - FOREGROUND_RED | FOREGROUND_INTENSITY; - const WORD existing_bg = old_color_attrs & background_mask; - - WORD new_color = - GetColorAttribute(color) | existing_bg | FOREGROUND_INTENSITY; - static const int bg_bitOffset = GetBitOffset(background_mask); - static const int fg_bitOffset = GetBitOffset(foreground_mask); - - if (((new_color & background_mask) >> bg_bitOffset) == - ((new_color & foreground_mask) >> fg_bitOffset)) { - new_color ^= FOREGROUND_INTENSITY; // invert intensity - } - return new_color; -} - -#else - -// Returns the ANSI color code for the given color. COLOR_DEFAULT is -// an invalid input. -static const char* GetAnsiColorCode(GTestColor color) { - switch (color) { - case COLOR_RED: return "1"; - case COLOR_GREEN: return "2"; - case COLOR_YELLOW: return "3"; - default: return NULL; - }; -} - -#endif // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE - -// Returns true iff Google Test should use colors in the output. -bool ShouldUseColor(bool stdout_is_tty) { - const char* const gtest_color = GTEST_FLAG(color).c_str(); - - if (String::CaseInsensitiveCStringEquals(gtest_color, "auto")) { -#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW - // On Windows the TERM variable is usually not set, but the - // console there does support colors. - return stdout_is_tty; -#else - // On non-Windows platforms, we rely on the TERM variable. - const char* const term = posix::GetEnv("TERM"); - const bool term_supports_color = - String::CStringEquals(term, "xterm") || - String::CStringEquals(term, "xterm-color") || - String::CStringEquals(term, "xterm-256color") || - String::CStringEquals(term, "screen") || - String::CStringEquals(term, "screen-256color") || - String::CStringEquals(term, "tmux") || - String::CStringEquals(term, "tmux-256color") || - String::CStringEquals(term, "rxvt-unicode") || - String::CStringEquals(term, "rxvt-unicode-256color") || - String::CStringEquals(term, "linux") || - String::CStringEquals(term, "cygwin"); - return stdout_is_tty && term_supports_color; -#endif // GTEST_OS_WINDOWS - } - - return String::CaseInsensitiveCStringEquals(gtest_color, "yes") || - String::CaseInsensitiveCStringEquals(gtest_color, "true") || - String::CaseInsensitiveCStringEquals(gtest_color, "t") || - String::CStringEquals(gtest_color, "1"); - // We take "yes", "true", "t", and "1" as meaning "yes". If the - // value is neither one of these nor "auto", we treat it as "no" to - // be conservative. -} - -// Helpers for printing colored strings to stdout. Note that on Windows, we -// cannot simply emit special characters and have the terminal change colors. -// This routine must actually emit the characters rather than return a string -// that would be colored when printed, as can be done on Linux. -static void ColoredPrintf(GTestColor color, const char* fmt, ...) { - va_list args; - va_start(args, fmt); - -#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS || \ - GTEST_OS_IOS || GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT - const bool use_color = AlwaysFalse(); -#else - static const bool in_color_mode = - ShouldUseColor(posix::IsATTY(posix::FileNo(stdout)) != 0); - const bool use_color = in_color_mode && (color != COLOR_DEFAULT); -#endif // GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS - // The '!= 0' comparison is necessary to satisfy MSVC 7.1. - - if (!use_color) { - vprintf(fmt, args); - va_end(args); - return; - } - -#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && \ - !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW - const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE); - - // Gets the current text color. - CONSOLE_SCREEN_BUFFER_INFO buffer_info; - GetConsoleScreenBufferInfo(stdout_handle, &buffer_info); - const WORD old_color_attrs = buffer_info.wAttributes; - const WORD new_color = GetNewColor(color, old_color_attrs); - - // We need to flush the stream buffers into the console before each - // SetConsoleTextAttribute call lest it affect the text that is already - // printed but has not yet reached the console. - fflush(stdout); - SetConsoleTextAttribute(stdout_handle, new_color); - - vprintf(fmt, args); - - fflush(stdout); - // Restores the text color. - SetConsoleTextAttribute(stdout_handle, old_color_attrs); -#else - printf("\033[0;3%sm", GetAnsiColorCode(color)); - vprintf(fmt, args); - printf("\033[m"); // Resets the terminal to default. -#endif // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE - va_end(args); -} - -// Text printed in Google Test's text output and --gtest_list_tests -// output to label the type parameter and value parameter for a test. -static const char kTypeParamLabel[] = "TypeParam"; -static const char kValueParamLabel[] = "GetParam()"; - -static void PrintFullTestCommentIfPresent(const TestInfo& test_info) { - const char* const type_param = test_info.type_param(); - const char* const value_param = test_info.value_param(); - - if (type_param != NULL || value_param != NULL) { - printf(", where "); - if (type_param != NULL) { - printf("%s = %s", kTypeParamLabel, type_param); - if (value_param != NULL) - printf(" and "); - } - if (value_param != NULL) { - printf("%s = %s", kValueParamLabel, value_param); - } - } -} - -// This class implements the TestEventListener interface. -// -// Class PrettyUnitTestResultPrinter is copyable. -class PrettyUnitTestResultPrinter : public TestEventListener { - public: - PrettyUnitTestResultPrinter() {} - static void PrintTestName(const char * test_case, const char * test) { - printf("%s.%s", test_case, test); - } - - // The following methods override what's in the TestEventListener class. - virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {} - virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration); - virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test); - virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {} - virtual void OnTestCaseStart(const TestCase& test_case); - virtual void OnTestStart(const TestInfo& test_info); - virtual void OnTestPartResult(const TestPartResult& result); - virtual void OnTestEnd(const TestInfo& test_info); - virtual void OnTestCaseEnd(const TestCase& test_case); - virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test); - virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {} - virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration); - virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {} - - private: - static void PrintFailedTests(const UnitTest& unit_test); -}; - - // Fired before each iteration of tests starts. -void PrettyUnitTestResultPrinter::OnTestIterationStart( - const UnitTest& unit_test, int iteration) { - if (GTEST_FLAG(repeat) != 1) - printf("\nRepeating all tests (iteration %d) . . .\n\n", iteration + 1); - - const char* const filter = GTEST_FLAG(filter).c_str(); - - // Prints the filter if it's not *. This reminds the user that some - // tests may be skipped. - if (!String::CStringEquals(filter, kUniversalFilter)) { - ColoredPrintf(COLOR_YELLOW, - "Note: %s filter = %s\n", GTEST_NAME_, filter); - } - - if (internal::ShouldShard(kTestTotalShards, kTestShardIndex, false)) { - const Int32 shard_index = Int32FromEnvOrDie(kTestShardIndex, -1); - ColoredPrintf(COLOR_YELLOW, - "Note: This is test shard %d of %s.\n", - static_cast(shard_index) + 1, - internal::posix::GetEnv(kTestTotalShards)); - } - - if (GTEST_FLAG(shuffle)) { - ColoredPrintf(COLOR_YELLOW, - "Note: Randomizing tests' orders with a seed of %d .\n", - unit_test.random_seed()); - } - ColoredPrintf(COLOR_GREEN, "[==========] "); - printf("Running %s from %s.\n", - FormatTestCount(unit_test.test_to_run_count()).c_str(), - FormatTestCaseCount(unit_test.test_case_to_run_count()).c_str()); - fflush(stdout); -} - -void PrettyUnitTestResultPrinter::OnEnvironmentsSetUpStart( - const UnitTest& /*unit_test*/) { - ColoredPrintf(COLOR_GREEN, "[----------] "); - printf("Global test environment set-up.\n"); - fflush(stdout); -} - -void PrettyUnitTestResultPrinter::OnTestCaseStart(const TestCase& test_case) { - const std::string counts = - FormatCountableNoun(test_case.test_to_run_count(), "test", "tests"); - ColoredPrintf(COLOR_GREEN, "[----------] "); - printf("%s from %s", counts.c_str(), test_case.name()); - if (test_case.type_param() == NULL) { - printf("\n"); - } else { - printf(", where %s = %s\n", kTypeParamLabel, test_case.type_param()); - } - fflush(stdout); -} - -void PrettyUnitTestResultPrinter::OnTestStart(const TestInfo& test_info) { - ColoredPrintf(COLOR_GREEN, "[ RUN ] "); - PrintTestName(test_info.test_case_name(), test_info.name()); - printf("\n"); - fflush(stdout); -} - -// Called after an assertion failure. -void PrettyUnitTestResultPrinter::OnTestPartResult( - const TestPartResult& result) { - // If the test part succeeded, we don't need to do anything. - if (result.type() == TestPartResult::kSuccess) - return; - - // Print failure message from the assertion (e.g. expected this and got that). - PrintTestPartResult(result); - fflush(stdout); -} - -void PrettyUnitTestResultPrinter::OnTestEnd(const TestInfo& test_info) { - if (test_info.result()->Passed()) { - ColoredPrintf(COLOR_GREEN, "[ OK ] "); - } else { - ColoredPrintf(COLOR_RED, "[ FAILED ] "); - } - PrintTestName(test_info.test_case_name(), test_info.name()); - if (test_info.result()->Failed()) - PrintFullTestCommentIfPresent(test_info); - - if (GTEST_FLAG(print_time)) { - printf(" (%s ms)\n", internal::StreamableToString( - test_info.result()->elapsed_time()).c_str()); - } else { - printf("\n"); - } - fflush(stdout); -} - -void PrettyUnitTestResultPrinter::OnTestCaseEnd(const TestCase& test_case) { - if (!GTEST_FLAG(print_time)) return; - - const std::string counts = - FormatCountableNoun(test_case.test_to_run_count(), "test", "tests"); - ColoredPrintf(COLOR_GREEN, "[----------] "); - printf("%s from %s (%s ms total)\n\n", - counts.c_str(), test_case.name(), - internal::StreamableToString(test_case.elapsed_time()).c_str()); - fflush(stdout); -} - -void PrettyUnitTestResultPrinter::OnEnvironmentsTearDownStart( - const UnitTest& /*unit_test*/) { - ColoredPrintf(COLOR_GREEN, "[----------] "); - printf("Global test environment tear-down\n"); - fflush(stdout); -} - -// Internal helper for printing the list of failed tests. -void PrettyUnitTestResultPrinter::PrintFailedTests(const UnitTest& unit_test) { - const int failed_test_count = unit_test.failed_test_count(); - if (failed_test_count == 0) { - return; - } - - for (int i = 0; i < unit_test.total_test_case_count(); ++i) { - const TestCase& test_case = *unit_test.GetTestCase(i); - if (!test_case.should_run() || (test_case.failed_test_count() == 0)) { - continue; - } - for (int j = 0; j < test_case.total_test_count(); ++j) { - const TestInfo& test_info = *test_case.GetTestInfo(j); - if (!test_info.should_run() || test_info.result()->Passed()) { - continue; - } - ColoredPrintf(COLOR_RED, "[ FAILED ] "); - printf("%s.%s", test_case.name(), test_info.name()); - PrintFullTestCommentIfPresent(test_info); - printf("\n"); - } - } -} - -void PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test, - int /*iteration*/) { - ColoredPrintf(COLOR_GREEN, "[==========] "); - printf("%s from %s ran.", - FormatTestCount(unit_test.test_to_run_count()).c_str(), - FormatTestCaseCount(unit_test.test_case_to_run_count()).c_str()); - if (GTEST_FLAG(print_time)) { - printf(" (%s ms total)", - internal::StreamableToString(unit_test.elapsed_time()).c_str()); - } - printf("\n"); - ColoredPrintf(COLOR_GREEN, "[ PASSED ] "); - printf("%s.\n", FormatTestCount(unit_test.successful_test_count()).c_str()); - - int num_failures = unit_test.failed_test_count(); - if (!unit_test.Passed()) { - const int failed_test_count = unit_test.failed_test_count(); - ColoredPrintf(COLOR_RED, "[ FAILED ] "); - printf("%s, listed below:\n", FormatTestCount(failed_test_count).c_str()); - PrintFailedTests(unit_test); - printf("\n%2d FAILED %s\n", num_failures, - num_failures == 1 ? "TEST" : "TESTS"); - } - - int num_disabled = unit_test.reportable_disabled_test_count(); - if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) { - if (!num_failures) { - printf("\n"); // Add a spacer if no FAILURE banner is displayed. - } - ColoredPrintf(COLOR_YELLOW, - " YOU HAVE %d DISABLED %s\n\n", - num_disabled, - num_disabled == 1 ? "TEST" : "TESTS"); - } - // Ensure that Google Test output is printed before, e.g., heapchecker output. - fflush(stdout); -} - -// End PrettyUnitTestResultPrinter - -// class TestEventRepeater -// -// This class forwards events to other event listeners. -class TestEventRepeater : public TestEventListener { - public: - TestEventRepeater() : forwarding_enabled_(true) {} - virtual ~TestEventRepeater(); - void Append(TestEventListener *listener); - TestEventListener* Release(TestEventListener* listener); - - // Controls whether events will be forwarded to listeners_. Set to false - // in death test child processes. - bool forwarding_enabled() const { return forwarding_enabled_; } - void set_forwarding_enabled(bool enable) { forwarding_enabled_ = enable; } - - virtual void OnTestProgramStart(const UnitTest& unit_test); - virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration); - virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test); - virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test); - virtual void OnTestCaseStart(const TestCase& test_case); - virtual void OnTestStart(const TestInfo& test_info); - virtual void OnTestPartResult(const TestPartResult& result); - virtual void OnTestEnd(const TestInfo& test_info); - virtual void OnTestCaseEnd(const TestCase& test_case); - virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test); - virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test); - virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration); - virtual void OnTestProgramEnd(const UnitTest& unit_test); - - private: - // Controls whether events will be forwarded to listeners_. Set to false - // in death test child processes. - bool forwarding_enabled_; - // The list of listeners that receive events. - std::vector listeners_; - - GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventRepeater); -}; - -TestEventRepeater::~TestEventRepeater() { - ForEach(listeners_, Delete); -} - -void TestEventRepeater::Append(TestEventListener *listener) { - listeners_.push_back(listener); -} - -// TODO(vladl@google.com): Factor the search functionality into Vector::Find. -TestEventListener* TestEventRepeater::Release(TestEventListener *listener) { - for (size_t i = 0; i < listeners_.size(); ++i) { - if (listeners_[i] == listener) { - listeners_.erase(listeners_.begin() + i); - return listener; - } - } - - return NULL; -} - -// Since most methods are very similar, use macros to reduce boilerplate. -// This defines a member that forwards the call to all listeners. -#define GTEST_REPEATER_METHOD_(Name, Type) \ -void TestEventRepeater::Name(const Type& parameter) { \ - if (forwarding_enabled_) { \ - for (size_t i = 0; i < listeners_.size(); i++) { \ - listeners_[i]->Name(parameter); \ - } \ - } \ -} -// This defines a member that forwards the call to all listeners in reverse -// order. -#define GTEST_REVERSE_REPEATER_METHOD_(Name, Type) \ -void TestEventRepeater::Name(const Type& parameter) { \ - if (forwarding_enabled_) { \ - for (int i = static_cast(listeners_.size()) - 1; i >= 0; i--) { \ - listeners_[i]->Name(parameter); \ - } \ - } \ -} - -GTEST_REPEATER_METHOD_(OnTestProgramStart, UnitTest) -GTEST_REPEATER_METHOD_(OnEnvironmentsSetUpStart, UnitTest) -GTEST_REPEATER_METHOD_(OnTestCaseStart, TestCase) -GTEST_REPEATER_METHOD_(OnTestStart, TestInfo) -GTEST_REPEATER_METHOD_(OnTestPartResult, TestPartResult) -GTEST_REPEATER_METHOD_(OnEnvironmentsTearDownStart, UnitTest) -GTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsSetUpEnd, UnitTest) -GTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsTearDownEnd, UnitTest) -GTEST_REVERSE_REPEATER_METHOD_(OnTestEnd, TestInfo) -GTEST_REVERSE_REPEATER_METHOD_(OnTestCaseEnd, TestCase) -GTEST_REVERSE_REPEATER_METHOD_(OnTestProgramEnd, UnitTest) - -#undef GTEST_REPEATER_METHOD_ -#undef GTEST_REVERSE_REPEATER_METHOD_ - -void TestEventRepeater::OnTestIterationStart(const UnitTest& unit_test, - int iteration) { - if (forwarding_enabled_) { - for (size_t i = 0; i < listeners_.size(); i++) { - listeners_[i]->OnTestIterationStart(unit_test, iteration); - } - } -} - -void TestEventRepeater::OnTestIterationEnd(const UnitTest& unit_test, - int iteration) { - if (forwarding_enabled_) { - for (int i = static_cast(listeners_.size()) - 1; i >= 0; i--) { - listeners_[i]->OnTestIterationEnd(unit_test, iteration); - } - } -} - -// End TestEventRepeater - -// This class generates an XML output file. -class XmlUnitTestResultPrinter : public EmptyTestEventListener { - public: - explicit XmlUnitTestResultPrinter(const char* output_file); - - virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration); - - private: - // Is c a whitespace character that is normalized to a space character - // when it appears in an XML attribute value? - static bool IsNormalizableWhitespace(char c) { - return c == 0x9 || c == 0xA || c == 0xD; - } - - // May c appear in a well-formed XML document? - static bool IsValidXmlCharacter(char c) { - return IsNormalizableWhitespace(c) || c >= 0x20; - } - - // Returns an XML-escaped copy of the input string str. If - // is_attribute is true, the text is meant to appear as an attribute - // value, and normalizable whitespace is preserved by replacing it - // with character references. - static std::string EscapeXml(const std::string& str, bool is_attribute); - - // Returns the given string with all characters invalid in XML removed. - static std::string RemoveInvalidXmlCharacters(const std::string& str); - - // Convenience wrapper around EscapeXml when str is an attribute value. - static std::string EscapeXmlAttribute(const std::string& str) { - return EscapeXml(str, true); - } - - // Convenience wrapper around EscapeXml when str is not an attribute value. - static std::string EscapeXmlText(const char* str) { - return EscapeXml(str, false); - } - - // Verifies that the given attribute belongs to the given element and - // streams the attribute as XML. - static void OutputXmlAttribute(std::ostream* stream, - const std::string& element_name, - const std::string& name, - const std::string& value); - - // Streams an XML CDATA section, escaping invalid CDATA sequences as needed. - static void OutputXmlCDataSection(::std::ostream* stream, const char* data); - - // Streams an XML representation of a TestInfo object. - static void OutputXmlTestInfo(::std::ostream* stream, - const char* test_case_name, - const TestInfo& test_info); - - // Prints an XML representation of a TestCase object - static void PrintXmlTestCase(::std::ostream* stream, - const TestCase& test_case); - - // Prints an XML summary of unit_test to output stream out. - static void PrintXmlUnitTest(::std::ostream* stream, - const UnitTest& unit_test); - - // Produces a string representing the test properties in a result as space - // delimited XML attributes based on the property key="value" pairs. - // When the std::string is not empty, it includes a space at the beginning, - // to delimit this attribute from prior attributes. - static std::string TestPropertiesAsXmlAttributes(const TestResult& result); - - // Streams an XML representation of the test properties of a TestResult - // object. - static void OutputXmlTestProperties(std::ostream* stream, - const TestResult& result); - - // The output file. - const std::string output_file_; - - GTEST_DISALLOW_COPY_AND_ASSIGN_(XmlUnitTestResultPrinter); -}; - -// Creates a new XmlUnitTestResultPrinter. -XmlUnitTestResultPrinter::XmlUnitTestResultPrinter(const char* output_file) - : output_file_(output_file) { - if (output_file_.c_str() == NULL || output_file_.empty()) { - GTEST_LOG_(FATAL) << "XML output file may not be null"; - } -} - -// Called after the unit test ends. -void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test, - int /*iteration*/) { - FILE* xmlout = NULL; - FilePath output_file(output_file_); - FilePath output_dir(output_file.RemoveFileName()); - - if (output_dir.CreateDirectoriesRecursively()) { - xmlout = posix::FOpen(output_file_.c_str(), "w"); - } - if (xmlout == NULL) { - // TODO(wan): report the reason of the failure. - // - // We don't do it for now as: - // - // 1. There is no urgent need for it. - // 2. It's a bit involved to make the errno variable thread-safe on - // all three operating systems (Linux, Windows, and Mac OS). - // 3. To interpret the meaning of errno in a thread-safe way, - // we need the strerror_r() function, which is not available on - // Windows. - - GTEST_LOG_(FATAL) << "Unable to open file \"" << output_file_ << "\""; - } - std::stringstream stream; - PrintXmlUnitTest(&stream, unit_test); - fprintf(xmlout, "%s", StringStreamToString(&stream).c_str()); - fclose(xmlout); -} - -// Returns an XML-escaped copy of the input string str. If is_attribute -// is true, the text is meant to appear as an attribute value, and -// normalizable whitespace is preserved by replacing it with character -// references. -// -// Invalid XML characters in str, if any, are stripped from the output. -// It is expected that most, if not all, of the text processed by this -// module will consist of ordinary English text. -// If this module is ever modified to produce version 1.1 XML output, -// most invalid characters can be retained using character references. -// TODO(wan): It might be nice to have a minimally invasive, human-readable -// escaping scheme for invalid characters, rather than dropping them. -std::string XmlUnitTestResultPrinter::EscapeXml( - const std::string& str, bool is_attribute) { - Message m; - - for (size_t i = 0; i < str.size(); ++i) { - const char ch = str[i]; - switch (ch) { - case '<': - m << "<"; - break; - case '>': - m << ">"; - break; - case '&': - m << "&"; - break; - case '\'': - if (is_attribute) - m << "'"; - else - m << '\''; - break; - case '"': - if (is_attribute) - m << """; - else - m << '"'; - break; - default: - if (IsValidXmlCharacter(ch)) { - if (is_attribute && IsNormalizableWhitespace(ch)) - m << "&#x" << String::FormatByte(static_cast(ch)) - << ";"; - else - m << ch; - } - break; - } - } - - return m.GetString(); -} - -// Returns the given string with all characters invalid in XML removed. -// Currently invalid characters are dropped from the string. An -// alternative is to replace them with certain characters such as . or ?. -std::string XmlUnitTestResultPrinter::RemoveInvalidXmlCharacters( - const std::string& str) { - std::string output; - output.reserve(str.size()); - for (std::string::const_iterator it = str.begin(); it != str.end(); ++it) - if (IsValidXmlCharacter(*it)) - output.push_back(*it); - - return output; -} - -// The following routines generate an XML representation of a UnitTest -// object. -// -// This is how Google Test concepts map to the DTD: -// -// <-- corresponds to a UnitTest object -// <-- corresponds to a TestCase object -// <-- corresponds to a TestInfo object -// ... -// ... -// ... -// <-- individual assertion failures -// -// -// - -// Formats the given time in milliseconds as seconds. -std::string FormatTimeInMillisAsSeconds(TimeInMillis ms) { - ::std::stringstream ss; - ss << (static_cast(ms) * 1e-3); - return ss.str(); -} - -static bool PortableLocaltime(time_t seconds, struct tm* out) { -#if defined(_MSC_VER) - return localtime_s(out, &seconds) == 0; -#elif defined(__MINGW32__) || defined(__MINGW64__) - // MINGW provides neither localtime_r nor localtime_s, but uses - // Windows' localtime(), which has a thread-local tm buffer. - struct tm* tm_ptr = localtime(&seconds); // NOLINT - if (tm_ptr == NULL) - return false; - *out = *tm_ptr; - return true; -#else - return localtime_r(&seconds, out) != NULL; -#endif -} - -// Converts the given epoch time in milliseconds to a date string in the ISO -// 8601 format, without the timezone information. -std::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms) { - struct tm time_struct; - if (!PortableLocaltime(static_cast(ms / 1000), &time_struct)) - return ""; - // YYYY-MM-DDThh:mm:ss - return StreamableToString(time_struct.tm_year + 1900) + "-" + - String::FormatIntWidth2(time_struct.tm_mon + 1) + "-" + - String::FormatIntWidth2(time_struct.tm_mday) + "T" + - String::FormatIntWidth2(time_struct.tm_hour) + ":" + - String::FormatIntWidth2(time_struct.tm_min) + ":" + - String::FormatIntWidth2(time_struct.tm_sec); -} - -// Streams an XML CDATA section, escaping invalid CDATA sequences as needed. -void XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream, - const char* data) { - const char* segment = data; - *stream << ""); - if (next_segment != NULL) { - stream->write( - segment, static_cast(next_segment - segment)); - *stream << "]]>]]>"); - } else { - *stream << segment; - break; - } - } - *stream << "]]>"; -} - -void XmlUnitTestResultPrinter::OutputXmlAttribute( - std::ostream* stream, - const std::string& element_name, - const std::string& name, - const std::string& value) { - const std::vector& allowed_names = - GetReservedAttributesForElement(element_name); - - GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) != - allowed_names.end()) - << "Attribute " << name << " is not allowed for element <" << element_name - << ">."; - - *stream << " " << name << "=\"" << EscapeXmlAttribute(value) << "\""; -} - -// Prints an XML representation of a TestInfo object. -// TODO(wan): There is also value in printing properties with the plain printer. -void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream, - const char* test_case_name, - const TestInfo& test_info) { - const TestResult& result = *test_info.result(); - const std::string kTestcase = "testcase"; - - if (test_info.is_in_another_shard()) { - return; - } - - *stream << " \n"; - } - const std::string location = - internal::FormatCompilerIndependentFileLocation(part.file_name(), - part.line_number()); - const std::string summary = location + "\n" + part.summary(); - *stream << " "; - const std::string detail = location + "\n" + part.message(); - OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str()); - *stream << "\n"; - } - } - - if (failures == 0 && result.test_property_count() == 0) { - *stream << " />\n"; - } else { - if (failures == 0) { - *stream << ">\n"; - } - OutputXmlTestProperties(stream, result); - *stream << " \n"; - } -} - -// Prints an XML representation of a TestCase object -void XmlUnitTestResultPrinter::PrintXmlTestCase(std::ostream* stream, - const TestCase& test_case) { - const std::string kTestsuite = "testsuite"; - *stream << " <" << kTestsuite; - OutputXmlAttribute(stream, kTestsuite, "name", test_case.name()); - OutputXmlAttribute(stream, kTestsuite, "tests", - StreamableToString(test_case.reportable_test_count())); - OutputXmlAttribute(stream, kTestsuite, "failures", - StreamableToString(test_case.failed_test_count())); - OutputXmlAttribute( - stream, kTestsuite, "disabled", - StreamableToString(test_case.reportable_disabled_test_count())); - OutputXmlAttribute(stream, kTestsuite, "errors", "0"); - OutputXmlAttribute(stream, kTestsuite, "time", - FormatTimeInMillisAsSeconds(test_case.elapsed_time())); - *stream << TestPropertiesAsXmlAttributes(test_case.ad_hoc_test_result()) - << ">\n"; - - for (int i = 0; i < test_case.total_test_count(); ++i) { - if (test_case.GetTestInfo(i)->is_reportable()) - OutputXmlTestInfo(stream, test_case.name(), *test_case.GetTestInfo(i)); - } - *stream << " \n"; -} - -// Prints an XML summary of unit_test to output stream out. -void XmlUnitTestResultPrinter::PrintXmlUnitTest(std::ostream* stream, - const UnitTest& unit_test) { - const std::string kTestsuites = "testsuites"; - - *stream << "\n"; - *stream << "<" << kTestsuites; - - OutputXmlAttribute(stream, kTestsuites, "tests", - StreamableToString(unit_test.reportable_test_count())); - OutputXmlAttribute(stream, kTestsuites, "failures", - StreamableToString(unit_test.failed_test_count())); - OutputXmlAttribute( - stream, kTestsuites, "disabled", - StreamableToString(unit_test.reportable_disabled_test_count())); - OutputXmlAttribute(stream, kTestsuites, "errors", "0"); - OutputXmlAttribute( - stream, kTestsuites, "timestamp", - FormatEpochTimeInMillisAsIso8601(unit_test.start_timestamp())); - OutputXmlAttribute(stream, kTestsuites, "time", - FormatTimeInMillisAsSeconds(unit_test.elapsed_time())); - - if (GTEST_FLAG(shuffle)) { - OutputXmlAttribute(stream, kTestsuites, "random_seed", - StreamableToString(unit_test.random_seed())); - } - *stream << TestPropertiesAsXmlAttributes(unit_test.ad_hoc_test_result()); - - OutputXmlAttribute(stream, kTestsuites, "name", "AllTests"); - *stream << ">\n"; - - for (int i = 0; i < unit_test.total_test_case_count(); ++i) { - if (unit_test.GetTestCase(i)->reportable_test_count() > 0) - PrintXmlTestCase(stream, *unit_test.GetTestCase(i)); - } - *stream << "\n"; -} - -// Produces a string representing the test properties in a result as space -// delimited XML attributes based on the property key="value" pairs. -std::string XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes( - const TestResult& result) { - Message attributes; - for (int i = 0; i < result.test_property_count(); ++i) { - const TestProperty& property = result.GetTestProperty(i); - attributes << " " << property.key() << "=" - << "\"" << EscapeXmlAttribute(property.value()) << "\""; - } - return attributes.GetString(); -} - -void XmlUnitTestResultPrinter::OutputXmlTestProperties( - std::ostream* stream, const TestResult& result) { - const std::string kProperties = "properties"; - const std::string kProperty = "property"; - - if (result.test_property_count() <= 0) { - return; - } - - *stream << "<" << kProperties << ">\n"; - for (int i = 0; i < result.test_property_count(); ++i) { - const TestProperty& property = result.GetTestProperty(i); - *stream << "<" << kProperty; - *stream << " name=\"" << EscapeXmlAttribute(property.key()) << "\""; - *stream << " value=\"" << EscapeXmlAttribute(property.value()) << "\""; - *stream << "/>\n"; - } - *stream << "\n"; -} - -// End XmlUnitTestResultPrinter - - -// This class generates an JSON output file. -class JsonUnitTestResultPrinter : public EmptyTestEventListener { - public: - explicit JsonUnitTestResultPrinter(const char* output_file); - - virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration); - - private: - // Returns an JSON-escaped copy of the input string str. - static std::string EscapeJson(const std::string& str); - - //// Verifies that the given attribute belongs to the given element and - //// streams the attribute as JSON. - static void OutputJsonKey(std::ostream* stream, - const std::string& element_name, - const std::string& name, - const std::string& value, - const std::string& indent, - bool comma = true); - static void OutputJsonKey(std::ostream* stream, - const std::string& element_name, - const std::string& name, - int value, - const std::string& indent, - bool comma = true); - - // Streams a JSON representation of a TestInfo object. - static void OutputJsonTestInfo(::std::ostream* stream, - const char* test_case_name, - const TestInfo& test_info); - - // Prints a JSON representation of a TestCase object - static void PrintJsonTestCase(::std::ostream* stream, - const TestCase& test_case); - - // Prints a JSON summary of unit_test to output stream out. - static void PrintJsonUnitTest(::std::ostream* stream, - const UnitTest& unit_test); - - // Produces a string representing the test properties in a result as - // a JSON dictionary. - static std::string TestPropertiesAsJson(const TestResult& result, - const std::string& indent); - - // The output file. - const std::string output_file_; - - GTEST_DISALLOW_COPY_AND_ASSIGN_(JsonUnitTestResultPrinter); -}; - -// Creates a new JsonUnitTestResultPrinter. -JsonUnitTestResultPrinter::JsonUnitTestResultPrinter(const char* output_file) - : output_file_(output_file) { - if (output_file_.empty()) { - GTEST_LOG_(FATAL) << "JSON output file may not be null"; - } -} - -void JsonUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test, - int /*iteration*/) { - FILE* jsonout = NULL; - FilePath output_file(output_file_); - FilePath output_dir(output_file.RemoveFileName()); - - if (output_dir.CreateDirectoriesRecursively()) { - jsonout = posix::FOpen(output_file_.c_str(), "w"); - } - if (jsonout == NULL) { - // TODO(phosek): report the reason of the failure. - // - // We don't do it for now as: - // - // 1. There is no urgent need for it. - // 2. It's a bit involved to make the errno variable thread-safe on - // all three operating systems (Linux, Windows, and Mac OS). - // 3. To interpret the meaning of errno in a thread-safe way, - // we need the strerror_r() function, which is not available on - // Windows. - GTEST_LOG_(FATAL) << "Unable to open file \"" - << output_file_ << "\""; - } - std::stringstream stream; - PrintJsonUnitTest(&stream, unit_test); - fprintf(jsonout, "%s", StringStreamToString(&stream).c_str()); - fclose(jsonout); -} - -// Returns an JSON-escaped copy of the input string str. -std::string JsonUnitTestResultPrinter::EscapeJson(const std::string& str) { - Message m; - - for (size_t i = 0; i < str.size(); ++i) { - const char ch = str[i]; - switch (ch) { - case '\\': - case '"': - case '/': - m << '\\' << ch; - break; - case '\b': - m << "\\b"; - break; - case '\t': - m << "\\t"; - break; - case '\n': - m << "\\n"; - break; - case '\f': - m << "\\f"; - break; - case '\r': - m << "\\r"; - break; - default: - if (ch < ' ') { - m << "\\u00" << String::FormatByte(static_cast(ch)); - } else { - m << ch; - } - break; - } - } - - return m.GetString(); -} - -// The following routines generate an JSON representation of a UnitTest -// object. - -// Formats the given time in milliseconds as seconds. -static std::string FormatTimeInMillisAsDuration(TimeInMillis ms) { - ::std::stringstream ss; - ss << (static_cast(ms) * 1e-3) << "s"; - return ss.str(); -} - -// Converts the given epoch time in milliseconds to a date string in the -// RFC3339 format, without the timezone information. -static std::string FormatEpochTimeInMillisAsRFC3339(TimeInMillis ms) { - struct tm time_struct; - if (!PortableLocaltime(static_cast(ms / 1000), &time_struct)) - return ""; - // YYYY-MM-DDThh:mm:ss - return StreamableToString(time_struct.tm_year + 1900) + "-" + - String::FormatIntWidth2(time_struct.tm_mon + 1) + "-" + - String::FormatIntWidth2(time_struct.tm_mday) + "T" + - String::FormatIntWidth2(time_struct.tm_hour) + ":" + - String::FormatIntWidth2(time_struct.tm_min) + ":" + - String::FormatIntWidth2(time_struct.tm_sec) + "Z"; -} - -static inline std::string Indent(int width) { - return std::string(width, ' '); -} - -void JsonUnitTestResultPrinter::OutputJsonKey( - std::ostream* stream, - const std::string& element_name, - const std::string& name, - const std::string& value, - const std::string& indent, - bool comma) { - const std::vector& allowed_names = - GetReservedAttributesForElement(element_name); - - GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) != - allowed_names.end()) - << "Key \"" << name << "\" is not allowed for value \"" << element_name - << "\"."; - - *stream << indent << "\"" << name << "\": \"" << EscapeJson(value) << "\""; - if (comma) - *stream << ",\n"; -} - -void JsonUnitTestResultPrinter::OutputJsonKey( - std::ostream* stream, - const std::string& element_name, - const std::string& name, - int value, - const std::string& indent, - bool comma) { - const std::vector& allowed_names = - GetReservedAttributesForElement(element_name); - - GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) != - allowed_names.end()) - << "Key \"" << name << "\" is not allowed for value \"" << element_name - << "\"."; - - *stream << indent << "\"" << name << "\": " << StreamableToString(value); - if (comma) - *stream << ",\n"; -} - -// Prints a JSON representation of a TestInfo object. -void JsonUnitTestResultPrinter::OutputJsonTestInfo(::std::ostream* stream, - const char* test_case_name, - const TestInfo& test_info) { - const TestResult& result = *test_info.result(); - const std::string kTestcase = "testcase"; - const std::string kIndent = Indent(10); - - *stream << Indent(8) << "{\n"; - OutputJsonKey(stream, kTestcase, "name", test_info.name(), kIndent); - - if (test_info.value_param() != NULL) { - OutputJsonKey(stream, kTestcase, "value_param", - test_info.value_param(), kIndent); - } - if (test_info.type_param() != NULL) { - OutputJsonKey(stream, kTestcase, "type_param", test_info.type_param(), - kIndent); - } - - OutputJsonKey(stream, kTestcase, "status", - test_info.should_run() ? "RUN" : "NOTRUN", kIndent); - OutputJsonKey(stream, kTestcase, "time", - FormatTimeInMillisAsDuration(result.elapsed_time()), kIndent); - OutputJsonKey(stream, kTestcase, "classname", test_case_name, kIndent, false); - *stream << TestPropertiesAsJson(result, kIndent); - - int failures = 0; - for (int i = 0; i < result.total_part_count(); ++i) { - const TestPartResult& part = result.GetTestPartResult(i); - if (part.failed()) { - *stream << ",\n"; - if (++failures == 1) { - *stream << kIndent << "\"" << "failures" << "\": [\n"; - } - const std::string location = - internal::FormatCompilerIndependentFileLocation(part.file_name(), - part.line_number()); - const std::string message = EscapeJson(location + "\n" + part.message()); - *stream << kIndent << " {\n" - << kIndent << " \"failure\": \"" << message << "\",\n" - << kIndent << " \"type\": \"\"\n" - << kIndent << " }"; - } - } - - if (failures > 0) - *stream << "\n" << kIndent << "]"; - *stream << "\n" << Indent(8) << "}"; -} - -// Prints an JSON representation of a TestCase object -void JsonUnitTestResultPrinter::PrintJsonTestCase(std::ostream* stream, - const TestCase& test_case) { - const std::string kTestsuite = "testsuite"; - const std::string kIndent = Indent(6); - - *stream << Indent(4) << "{\n"; - OutputJsonKey(stream, kTestsuite, "name", test_case.name(), kIndent); - OutputJsonKey(stream, kTestsuite, "tests", test_case.reportable_test_count(), - kIndent); - OutputJsonKey(stream, kTestsuite, "failures", test_case.failed_test_count(), - kIndent); - OutputJsonKey(stream, kTestsuite, "disabled", - test_case.reportable_disabled_test_count(), kIndent); - OutputJsonKey(stream, kTestsuite, "errors", 0, kIndent); - OutputJsonKey(stream, kTestsuite, "time", - FormatTimeInMillisAsDuration(test_case.elapsed_time()), kIndent, - false); - *stream << TestPropertiesAsJson(test_case.ad_hoc_test_result(), kIndent) - << ",\n"; - - *stream << kIndent << "\"" << kTestsuite << "\": [\n"; - - bool comma = false; - for (int i = 0; i < test_case.total_test_count(); ++i) { - if (test_case.GetTestInfo(i)->is_reportable()) { - if (comma) { - *stream << ",\n"; - } else { - comma = true; - } - OutputJsonTestInfo(stream, test_case.name(), *test_case.GetTestInfo(i)); - } - } - *stream << "\n" << kIndent << "]\n" << Indent(4) << "}"; -} - -// Prints a JSON summary of unit_test to output stream out. -void JsonUnitTestResultPrinter::PrintJsonUnitTest(std::ostream* stream, - const UnitTest& unit_test) { - const std::string kTestsuites = "testsuites"; - const std::string kIndent = Indent(2); - *stream << "{\n"; - - OutputJsonKey(stream, kTestsuites, "tests", unit_test.reportable_test_count(), - kIndent); - OutputJsonKey(stream, kTestsuites, "failures", unit_test.failed_test_count(), - kIndent); - OutputJsonKey(stream, kTestsuites, "disabled", - unit_test.reportable_disabled_test_count(), kIndent); - OutputJsonKey(stream, kTestsuites, "errors", 0, kIndent); - if (GTEST_FLAG(shuffle)) { - OutputJsonKey(stream, kTestsuites, "random_seed", unit_test.random_seed(), - kIndent); - } - OutputJsonKey(stream, kTestsuites, "timestamp", - FormatEpochTimeInMillisAsRFC3339(unit_test.start_timestamp()), - kIndent); - OutputJsonKey(stream, kTestsuites, "time", - FormatTimeInMillisAsDuration(unit_test.elapsed_time()), kIndent, - false); - - *stream << TestPropertiesAsJson(unit_test.ad_hoc_test_result(), kIndent) - << ",\n"; - - OutputJsonKey(stream, kTestsuites, "name", "AllTests", kIndent); - *stream << kIndent << "\"" << kTestsuites << "\": [\n"; - - bool comma = false; - for (int i = 0; i < unit_test.total_test_case_count(); ++i) { - if (unit_test.GetTestCase(i)->reportable_test_count() > 0) { - if (comma) { - *stream << ",\n"; - } else { - comma = true; - } - PrintJsonTestCase(stream, *unit_test.GetTestCase(i)); - } - } - - *stream << "\n" << kIndent << "]\n" << "}\n"; -} - -// Produces a string representing the test properties in a result as -// a JSON dictionary. -std::string JsonUnitTestResultPrinter::TestPropertiesAsJson( - const TestResult& result, const std::string& indent) { - Message attributes; - for (int i = 0; i < result.test_property_count(); ++i) { - const TestProperty& property = result.GetTestProperty(i); - attributes << ",\n" << indent << "\"" << property.key() << "\": " - << "\"" << EscapeJson(property.value()) << "\""; - } - return attributes.GetString(); -} - -// End JsonUnitTestResultPrinter - -#if GTEST_CAN_STREAM_RESULTS_ - -// Checks if str contains '=', '&', '%' or '\n' characters. If yes, -// replaces them by "%xx" where xx is their hexadecimal value. For -// example, replaces "=" with "%3D". This algorithm is O(strlen(str)) -// in both time and space -- important as the input str may contain an -// arbitrarily long test failure message and stack trace. -std::string StreamingListener::UrlEncode(const char* str) { - std::string result; - result.reserve(strlen(str) + 1); - for (char ch = *str; ch != '\0'; ch = *++str) { - switch (ch) { - case '%': - case '=': - case '&': - case '\n': - result.append("%" + String::FormatByte(static_cast(ch))); - break; - default: - result.push_back(ch); - break; - } - } - return result; -} - -void StreamingListener::SocketWriter::MakeConnection() { - GTEST_CHECK_(sockfd_ == -1) - << "MakeConnection() can't be called when there is already a connection."; - - addrinfo hints; - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_UNSPEC; // To allow both IPv4 and IPv6 addresses. - hints.ai_socktype = SOCK_STREAM; - addrinfo* servinfo = NULL; - - // Use the getaddrinfo() to get a linked list of IP addresses for - // the given host name. - const int error_num = getaddrinfo( - host_name_.c_str(), port_num_.c_str(), &hints, &servinfo); - if (error_num != 0) { - GTEST_LOG_(WARNING) << "stream_result_to: getaddrinfo() failed: " - << gai_strerror(error_num); - } - - // Loop through all the results and connect to the first we can. - for (addrinfo* cur_addr = servinfo; sockfd_ == -1 && cur_addr != NULL; - cur_addr = cur_addr->ai_next) { - sockfd_ = socket( - cur_addr->ai_family, cur_addr->ai_socktype, cur_addr->ai_protocol); - if (sockfd_ != -1) { - // Connect the client socket to the server socket. - if (connect(sockfd_, cur_addr->ai_addr, cur_addr->ai_addrlen) == -1) { - close(sockfd_); - sockfd_ = -1; - } - } - } - - freeaddrinfo(servinfo); // all done with this structure - - if (sockfd_ == -1) { - GTEST_LOG_(WARNING) << "stream_result_to: failed to connect to " - << host_name_ << ":" << port_num_; - } -} - -// End of class Streaming Listener -#endif // GTEST_CAN_STREAM_RESULTS__ - -// class OsStackTraceGetter - -const char* const OsStackTraceGetterInterface::kElidedFramesMarker = - "... " GTEST_NAME_ " internal frames ..."; - -std::string OsStackTraceGetter::CurrentStackTrace(int max_depth, int skip_count) - GTEST_LOCK_EXCLUDED_(mutex_) { -#if GTEST_HAS_ABSL - std::string result; - - if (max_depth <= 0) { - return result; - } - - max_depth = std::min(max_depth, kMaxStackTraceDepth); - - std::vector raw_stack(max_depth); - // Skips the frames requested by the caller, plus this function. - const int raw_stack_size = - absl::GetStackTrace(&raw_stack[0], max_depth, skip_count + 1); - - void* caller_frame = nullptr; - { - MutexLock lock(&mutex_); - caller_frame = caller_frame_; - } - - for (int i = 0; i < raw_stack_size; ++i) { - if (raw_stack[i] == caller_frame && - !GTEST_FLAG(show_internal_stack_frames)) { - // Add a marker to the trace and stop adding frames. - absl::StrAppend(&result, kElidedFramesMarker, "\n"); - break; - } - - char tmp[1024]; - const char* symbol = "(unknown)"; - if (absl::Symbolize(raw_stack[i], tmp, sizeof(tmp))) { - symbol = tmp; - } - - char line[1024]; - snprintf(line, sizeof(line), " %p: %s\n", raw_stack[i], symbol); - result += line; - } - - return result; - -#else // !GTEST_HAS_ABSL - static_cast(max_depth); - static_cast(skip_count); - return ""; -#endif // GTEST_HAS_ABSL -} - -void OsStackTraceGetter::UponLeavingGTest() GTEST_LOCK_EXCLUDED_(mutex_) { -#if GTEST_HAS_ABSL - void* caller_frame = nullptr; - if (absl::GetStackTrace(&caller_frame, 1, 3) <= 0) { - caller_frame = nullptr; - } - - MutexLock lock(&mutex_); - caller_frame_ = caller_frame; -#endif // GTEST_HAS_ABSL -} - -// A helper class that creates the premature-exit file in its -// constructor and deletes the file in its destructor. -class ScopedPrematureExitFile { - public: - explicit ScopedPrematureExitFile(const char* premature_exit_filepath) - : premature_exit_filepath_(premature_exit_filepath ? - premature_exit_filepath : "") { - // If a path to the premature-exit file is specified... - if (!premature_exit_filepath_.empty()) { - // create the file with a single "0" character in it. I/O - // errors are ignored as there's nothing better we can do and we - // don't want to fail the test because of this. - FILE* pfile = posix::FOpen(premature_exit_filepath, "w"); - fwrite("0", 1, 1, pfile); - fclose(pfile); - } - } - - ~ScopedPrematureExitFile() { - if (!premature_exit_filepath_.empty()) { - int retval = remove(premature_exit_filepath_.c_str()); - if (retval) { - GTEST_LOG_(ERROR) << "Failed to remove premature exit filepath \"" - << premature_exit_filepath_ << "\" with error " - << retval; - } - } - } - - private: - const std::string premature_exit_filepath_; - - GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedPrematureExitFile); -}; - -} // namespace internal - -// class TestEventListeners - -TestEventListeners::TestEventListeners() - : repeater_(new internal::TestEventRepeater()), - default_result_printer_(NULL), - default_xml_generator_(NULL) { -} - -TestEventListeners::~TestEventListeners() { delete repeater_; } - -// Returns the standard listener responsible for the default console -// output. Can be removed from the listeners list to shut down default -// console output. Note that removing this object from the listener list -// with Release transfers its ownership to the user. -void TestEventListeners::Append(TestEventListener* listener) { - repeater_->Append(listener); -} - -// Removes the given event listener from the list and returns it. It then -// becomes the caller's responsibility to delete the listener. Returns -// NULL if the listener is not found in the list. -TestEventListener* TestEventListeners::Release(TestEventListener* listener) { - if (listener == default_result_printer_) - default_result_printer_ = NULL; - else if (listener == default_xml_generator_) - default_xml_generator_ = NULL; - return repeater_->Release(listener); -} - -// Returns repeater that broadcasts the TestEventListener events to all -// subscribers. -TestEventListener* TestEventListeners::repeater() { return repeater_; } - -// Sets the default_result_printer attribute to the provided listener. -// The listener is also added to the listener list and previous -// default_result_printer is removed from it and deleted. The listener can -// also be NULL in which case it will not be added to the list. Does -// nothing if the previous and the current listener objects are the same. -void TestEventListeners::SetDefaultResultPrinter(TestEventListener* listener) { - if (default_result_printer_ != listener) { - // It is an error to pass this method a listener that is already in the - // list. - delete Release(default_result_printer_); - default_result_printer_ = listener; - if (listener != NULL) - Append(listener); - } -} - -// Sets the default_xml_generator attribute to the provided listener. The -// listener is also added to the listener list and previous -// default_xml_generator is removed from it and deleted. The listener can -// also be NULL in which case it will not be added to the list. Does -// nothing if the previous and the current listener objects are the same. -void TestEventListeners::SetDefaultXmlGenerator(TestEventListener* listener) { - if (default_xml_generator_ != listener) { - // It is an error to pass this method a listener that is already in the - // list. - delete Release(default_xml_generator_); - default_xml_generator_ = listener; - if (listener != NULL) - Append(listener); - } -} - -// Controls whether events will be forwarded by the repeater to the -// listeners in the list. -bool TestEventListeners::EventForwardingEnabled() const { - return repeater_->forwarding_enabled(); -} - -void TestEventListeners::SuppressEventForwarding() { - repeater_->set_forwarding_enabled(false); -} - -// class UnitTest - -// Gets the singleton UnitTest object. The first time this method is -// called, a UnitTest object is constructed and returned. Consecutive -// calls will return the same object. -// -// We don't protect this under mutex_ as a user is not supposed to -// call this before main() starts, from which point on the return -// value will never change. -UnitTest* UnitTest::GetInstance() { - // When compiled with MSVC 7.1 in optimized mode, destroying the - // UnitTest object upon exiting the program messes up the exit code, - // causing successful tests to appear failed. We have to use a - // different implementation in this case to bypass the compiler bug. - // This implementation makes the compiler happy, at the cost of - // leaking the UnitTest object. - - // CodeGear C++Builder insists on a public destructor for the - // default implementation. Use this implementation to keep good OO - // design with private destructor. - -#if (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__) - static UnitTest* const instance = new UnitTest; - return instance; -#else - static UnitTest instance; - return &instance; -#endif // (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__) -} - -// Gets the number of successful test cases. -int UnitTest::successful_test_case_count() const { - return impl()->successful_test_case_count(); -} - -// Gets the number of failed test cases. -int UnitTest::failed_test_case_count() const { - return impl()->failed_test_case_count(); -} - -// Gets the number of all test cases. -int UnitTest::total_test_case_count() const { - return impl()->total_test_case_count(); -} - -// Gets the number of all test cases that contain at least one test -// that should run. -int UnitTest::test_case_to_run_count() const { - return impl()->test_case_to_run_count(); -} - -// Gets the number of successful tests. -int UnitTest::successful_test_count() const { - return impl()->successful_test_count(); -} - -// Gets the number of failed tests. -int UnitTest::failed_test_count() const { return impl()->failed_test_count(); } - -// Gets the number of disabled tests that will be reported in the XML report. -int UnitTest::reportable_disabled_test_count() const { - return impl()->reportable_disabled_test_count(); -} - -// Gets the number of disabled tests. -int UnitTest::disabled_test_count() const { - return impl()->disabled_test_count(); -} - -// Gets the number of tests to be printed in the XML report. -int UnitTest::reportable_test_count() const { - return impl()->reportable_test_count(); -} - -// Gets the number of all tests. -int UnitTest::total_test_count() const { return impl()->total_test_count(); } - -// Gets the number of tests that should run. -int UnitTest::test_to_run_count() const { return impl()->test_to_run_count(); } - -// Gets the time of the test program start, in ms from the start of the -// UNIX epoch. -internal::TimeInMillis UnitTest::start_timestamp() const { - return impl()->start_timestamp(); -} - -// Gets the elapsed time, in milliseconds. -internal::TimeInMillis UnitTest::elapsed_time() const { - return impl()->elapsed_time(); -} - -// Returns true iff the unit test passed (i.e. all test cases passed). -bool UnitTest::Passed() const { return impl()->Passed(); } - -// Returns true iff the unit test failed (i.e. some test case failed -// or something outside of all tests failed). -bool UnitTest::Failed() const { return impl()->Failed(); } - -// Gets the i-th test case among all the test cases. i can range from 0 to -// total_test_case_count() - 1. If i is not in that range, returns NULL. -const TestCase* UnitTest::GetTestCase(int i) const { - return impl()->GetTestCase(i); -} - -// Returns the TestResult containing information on test failures and -// properties logged outside of individual test cases. -const TestResult& UnitTest::ad_hoc_test_result() const { - return *impl()->ad_hoc_test_result(); -} - -// Gets the i-th test case among all the test cases. i can range from 0 to -// total_test_case_count() - 1. If i is not in that range, returns NULL. -TestCase* UnitTest::GetMutableTestCase(int i) { - return impl()->GetMutableTestCase(i); -} - -// Returns the list of event listeners that can be used to track events -// inside Google Test. -TestEventListeners& UnitTest::listeners() { - return *impl()->listeners(); -} - -// Registers and returns a global test environment. When a test -// program is run, all global test environments will be set-up in the -// order they were registered. After all tests in the program have -// finished, all global test environments will be torn-down in the -// *reverse* order they were registered. -// -// The UnitTest object takes ownership of the given environment. -// -// We don't protect this under mutex_, as we only support calling it -// from the main thread. -Environment* UnitTest::AddEnvironment(Environment* env) { - if (env == NULL) { - return NULL; - } - - impl_->environments().push_back(env); - return env; -} - -// Adds a TestPartResult to the current TestResult object. All Google Test -// assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc) eventually call -// this to report their results. The user code should use the -// assertion macros instead of calling this directly. -void UnitTest::AddTestPartResult( - TestPartResult::Type result_type, - const char* file_name, - int line_number, - const std::string& message, - const std::string& os_stack_trace) GTEST_LOCK_EXCLUDED_(mutex_) { - Message msg; - msg << message; - - internal::MutexLock lock(&mutex_); - if (impl_->gtest_trace_stack().size() > 0) { - msg << "\n" << GTEST_NAME_ << " trace:"; - - for (int i = static_cast(impl_->gtest_trace_stack().size()); - i > 0; --i) { - const internal::TraceInfo& trace = impl_->gtest_trace_stack()[i - 1]; - msg << "\n" << internal::FormatFileLocation(trace.file, trace.line) - << " " << trace.message; - } - } - - if (os_stack_trace.c_str() != NULL && !os_stack_trace.empty()) { - msg << internal::kStackTraceMarker << os_stack_trace; - } - - const TestPartResult result = - TestPartResult(result_type, file_name, line_number, - msg.GetString().c_str()); - impl_->GetTestPartResultReporterForCurrentThread()-> - ReportTestPartResult(result); - - if (result_type != TestPartResult::kSuccess) { - // gtest_break_on_failure takes precedence over - // gtest_throw_on_failure. This allows a user to set the latter - // in the code (perhaps in order to use Google Test assertions - // with another testing framework) and specify the former on the - // command line for debugging. - if (GTEST_FLAG(break_on_failure)) { -#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT - // Using DebugBreak on Windows allows gtest to still break into a debugger - // when a failure happens and both the --gtest_break_on_failure and - // the --gtest_catch_exceptions flags are specified. - DebugBreak(); -#elif (!defined(__native_client__)) && \ - ((defined(__clang__) || defined(__GNUC__)) && \ - (defined(__x86_64__) || defined(__i386__))) - // with clang/gcc we can achieve the same effect on x86 by invoking int3 - asm("int3"); -#else - // Dereference NULL through a volatile pointer to prevent the compiler - // from removing. We use this rather than abort() or __builtin_trap() for - // portability: Symbian doesn't implement abort() well, and some debuggers - // don't correctly trap abort(). - *static_cast(NULL) = 1; -#endif // GTEST_OS_WINDOWS - } else if (GTEST_FLAG(throw_on_failure)) { -#if GTEST_HAS_EXCEPTIONS - throw internal::GoogleTestFailureException(result); -#else - // We cannot call abort() as it generates a pop-up in debug mode - // that cannot be suppressed in VC 7.1 or below. - exit(1); -#endif - } - } -} - -// Adds a TestProperty to the current TestResult object when invoked from -// inside a test, to current TestCase's ad_hoc_test_result_ when invoked -// from SetUpTestCase or TearDownTestCase, or to the global property set -// when invoked elsewhere. If the result already contains a property with -// the same key, the value will be updated. -void UnitTest::RecordProperty(const std::string& key, - const std::string& value) { - impl_->RecordProperty(TestProperty(key, value)); -} - -// Runs all tests in this UnitTest object and prints the result. -// Returns 0 if successful, or 1 otherwise. -// -// We don't protect this under mutex_, as we only support calling it -// from the main thread. -int UnitTest::Run() { - const bool in_death_test_child_process = - internal::GTEST_FLAG(internal_run_death_test).length() > 0; - - // Google Test implements this protocol for catching that a test - // program exits before returning control to Google Test: - // - // 1. Upon start, Google Test creates a file whose absolute path - // is specified by the environment variable - // TEST_PREMATURE_EXIT_FILE. - // 2. When Google Test has finished its work, it deletes the file. - // - // This allows a test runner to set TEST_PREMATURE_EXIT_FILE before - // running a Google-Test-based test program and check the existence - // of the file at the end of the test execution to see if it has - // exited prematurely. - - // If we are in the child process of a death test, don't - // create/delete the premature exit file, as doing so is unnecessary - // and will confuse the parent process. Otherwise, create/delete - // the file upon entering/leaving this function. If the program - // somehow exits before this function has a chance to return, the - // premature-exit file will be left undeleted, causing a test runner - // that understands the premature-exit-file protocol to report the - // test as having failed. - const internal::ScopedPrematureExitFile premature_exit_file( - in_death_test_child_process ? - NULL : internal::posix::GetEnv("TEST_PREMATURE_EXIT_FILE")); - - // Captures the value of GTEST_FLAG(catch_exceptions). This value will be - // used for the duration of the program. - impl()->set_catch_exceptions(GTEST_FLAG(catch_exceptions)); - -#if GTEST_HAS_SEH - // Either the user wants Google Test to catch exceptions thrown by the - // tests or this is executing in the context of death test child - // process. In either case the user does not want to see pop-up dialogs - // about crashes - they are expected. - if (impl()->catch_exceptions() || in_death_test_child_process) { -# if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT - // SetErrorMode doesn't exist on CE. - SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT | - SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); -# endif // !GTEST_OS_WINDOWS_MOBILE - -# if (defined(_MSC_VER) || GTEST_OS_WINDOWS_MINGW) && !GTEST_OS_WINDOWS_MOBILE - // Death test children can be terminated with _abort(). On Windows, - // _abort() can show a dialog with a warning message. This forces the - // abort message to go to stderr instead. - _set_error_mode(_OUT_TO_STDERR); -# endif - -# if _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE - // In the debug version, Visual Studio pops up a separate dialog - // offering a choice to debug the aborted program. We need to suppress - // this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement - // executed. Google Test will notify the user of any unexpected - // failure via stderr. - // - // VC++ doesn't define _set_abort_behavior() prior to the version 8.0. - // Users of prior VC versions shall suffer the agony and pain of - // clicking through the countless debug dialogs. - // TODO(vladl@google.com): find a way to suppress the abort dialog() in the - // debug mode when compiled with VC 7.1 or lower. - if (!GTEST_FLAG(break_on_failure)) - _set_abort_behavior( - 0x0, // Clear the following flags: - _WRITE_ABORT_MSG | _CALL_REPORTFAULT); // pop-up window, core dump. -# endif - } -#endif // GTEST_HAS_SEH - - return internal::HandleExceptionsInMethodIfSupported( - impl(), - &internal::UnitTestImpl::RunAllTests, - "auxiliary test code (environments or event listeners)") ? 0 : 1; -} - -// Returns the working directory when the first TEST() or TEST_F() was -// executed. -const char* UnitTest::original_working_dir() const { - return impl_->original_working_dir_.c_str(); -} - -// Returns the TestCase object for the test that's currently running, -// or NULL if no test is running. -const TestCase* UnitTest::current_test_case() const - GTEST_LOCK_EXCLUDED_(mutex_) { - internal::MutexLock lock(&mutex_); - return impl_->current_test_case(); -} - -// Returns the TestInfo object for the test that's currently running, -// or NULL if no test is running. -const TestInfo* UnitTest::current_test_info() const - GTEST_LOCK_EXCLUDED_(mutex_) { - internal::MutexLock lock(&mutex_); - return impl_->current_test_info(); -} - -// Returns the random seed used at the start of the current test run. -int UnitTest::random_seed() const { return impl_->random_seed(); } - -// Returns ParameterizedTestCaseRegistry object used to keep track of -// value-parameterized tests and instantiate and register them. -internal::ParameterizedTestCaseRegistry& - UnitTest::parameterized_test_registry() - GTEST_LOCK_EXCLUDED_(mutex_) { - return impl_->parameterized_test_registry(); -} - -// Creates an empty UnitTest. -UnitTest::UnitTest() { - impl_ = new internal::UnitTestImpl(this); -} - -// Destructor of UnitTest. -UnitTest::~UnitTest() { - delete impl_; -} - -// Pushes a trace defined by SCOPED_TRACE() on to the per-thread -// Google Test trace stack. -void UnitTest::PushGTestTrace(const internal::TraceInfo& trace) - GTEST_LOCK_EXCLUDED_(mutex_) { - internal::MutexLock lock(&mutex_); - impl_->gtest_trace_stack().push_back(trace); -} - -// Pops a trace from the per-thread Google Test trace stack. -void UnitTest::PopGTestTrace() - GTEST_LOCK_EXCLUDED_(mutex_) { - internal::MutexLock lock(&mutex_); - impl_->gtest_trace_stack().pop_back(); -} - -namespace internal { - -UnitTestImpl::UnitTestImpl(UnitTest* parent) - : parent_(parent), - GTEST_DISABLE_MSC_WARNINGS_PUSH_(4355 /* using this in initializer */) - default_global_test_part_result_reporter_(this), - default_per_thread_test_part_result_reporter_(this), - GTEST_DISABLE_MSC_WARNINGS_POP_() - global_test_part_result_repoter_( - &default_global_test_part_result_reporter_), - per_thread_test_part_result_reporter_( - &default_per_thread_test_part_result_reporter_), - parameterized_test_registry_(), - parameterized_tests_registered_(false), - last_death_test_case_(-1), - current_test_case_(NULL), - current_test_info_(NULL), - ad_hoc_test_result_(), - os_stack_trace_getter_(NULL), - post_flag_parse_init_performed_(false), - random_seed_(0), // Will be overridden by the flag before first use. - random_(0), // Will be reseeded before first use. - start_timestamp_(0), - elapsed_time_(0), -#if GTEST_HAS_DEATH_TEST - death_test_factory_(new DefaultDeathTestFactory), -#endif - // Will be overridden by the flag before first use. - catch_exceptions_(false) { - listeners()->SetDefaultResultPrinter(new PrettyUnitTestResultPrinter); -} - -UnitTestImpl::~UnitTestImpl() { - // Deletes every TestCase. - ForEach(test_cases_, internal::Delete); - - // Deletes every Environment. - ForEach(environments_, internal::Delete); - - delete os_stack_trace_getter_; -} - -// Adds a TestProperty to the current TestResult object when invoked in a -// context of a test, to current test case's ad_hoc_test_result when invoke -// from SetUpTestCase/TearDownTestCase, or to the global property set -// otherwise. If the result already contains a property with the same key, -// the value will be updated. -void UnitTestImpl::RecordProperty(const TestProperty& test_property) { - std::string xml_element; - TestResult* test_result; // TestResult appropriate for property recording. - - if (current_test_info_ != NULL) { - xml_element = "testcase"; - test_result = &(current_test_info_->result_); - } else if (current_test_case_ != NULL) { - xml_element = "testsuite"; - test_result = &(current_test_case_->ad_hoc_test_result_); - } else { - xml_element = "testsuites"; - test_result = &ad_hoc_test_result_; - } - test_result->RecordProperty(xml_element, test_property); -} - -#if GTEST_HAS_DEATH_TEST -// Disables event forwarding if the control is currently in a death test -// subprocess. Must not be called before InitGoogleTest. -void UnitTestImpl::SuppressTestEventsIfInSubprocess() { - if (internal_run_death_test_flag_.get() != NULL) - listeners()->SuppressEventForwarding(); -} -#endif // GTEST_HAS_DEATH_TEST - -// Initializes event listeners performing XML output as specified by -// UnitTestOptions. Must not be called before InitGoogleTest. -void UnitTestImpl::ConfigureXmlOutput() { - const std::string& output_format = UnitTestOptions::GetOutputFormat(); - if (output_format == "xml") { - listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter( - UnitTestOptions::GetAbsolutePathToOutputFile().c_str())); - } else if (output_format == "json") { - listeners()->SetDefaultXmlGenerator(new JsonUnitTestResultPrinter( - UnitTestOptions::GetAbsolutePathToOutputFile().c_str())); - } else if (output_format != "") { - GTEST_LOG_(WARNING) << "WARNING: unrecognized output format \"" - << output_format << "\" ignored."; - } -} - -#if GTEST_CAN_STREAM_RESULTS_ -// Initializes event listeners for streaming test results in string form. -// Must not be called before InitGoogleTest. -void UnitTestImpl::ConfigureStreamingOutput() { - const std::string& target = GTEST_FLAG(stream_result_to); - if (!target.empty()) { - const size_t pos = target.find(':'); - if (pos != std::string::npos) { - listeners()->Append(new StreamingListener(target.substr(0, pos), - target.substr(pos+1))); - } else { - GTEST_LOG_(WARNING) << "unrecognized streaming target \"" << target - << "\" ignored."; - } - } -} -#endif // GTEST_CAN_STREAM_RESULTS_ - -// Performs initialization dependent upon flag values obtained in -// ParseGoogleTestFlagsOnly. Is called from InitGoogleTest after the call to -// ParseGoogleTestFlagsOnly. In case a user neglects to call InitGoogleTest -// this function is also called from RunAllTests. Since this function can be -// called more than once, it has to be idempotent. -void UnitTestImpl::PostFlagParsingInit() { - // Ensures that this function does not execute more than once. - if (!post_flag_parse_init_performed_) { - post_flag_parse_init_performed_ = true; - -#if defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_) - // Register to send notifications about key process state changes. - listeners()->Append(new GTEST_CUSTOM_TEST_EVENT_LISTENER_()); -#endif // defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_) - -#if GTEST_HAS_DEATH_TEST - InitDeathTestSubprocessControlInfo(); - SuppressTestEventsIfInSubprocess(); -#endif // GTEST_HAS_DEATH_TEST - - // Registers parameterized tests. This makes parameterized tests - // available to the UnitTest reflection API without running - // RUN_ALL_TESTS. - RegisterParameterizedTests(); - - // Configures listeners for XML output. This makes it possible for users - // to shut down the default XML output before invoking RUN_ALL_TESTS. - ConfigureXmlOutput(); - -#if GTEST_CAN_STREAM_RESULTS_ - // Configures listeners for streaming test results to the specified server. - ConfigureStreamingOutput(); -#endif // GTEST_CAN_STREAM_RESULTS_ - -#if GTEST_HAS_ABSL - if (GTEST_FLAG(install_failure_signal_handler)) { - absl::FailureSignalHandlerOptions options; - absl::InstallFailureSignalHandler(options); - } -#endif // GTEST_HAS_ABSL - } -} - -// A predicate that checks the name of a TestCase against a known -// value. -// -// This is used for implementation of the UnitTest class only. We put -// it in the anonymous namespace to prevent polluting the outer -// namespace. -// -// TestCaseNameIs is copyable. -class TestCaseNameIs { - public: - // Constructor. - explicit TestCaseNameIs(const std::string& name) - : name_(name) {} - - // Returns true iff the name of test_case matches name_. - bool operator()(const TestCase* test_case) const { - return test_case != NULL && strcmp(test_case->name(), name_.c_str()) == 0; - } - - private: - std::string name_; -}; - -// Finds and returns a TestCase with the given name. If one doesn't -// exist, creates one and returns it. It's the CALLER'S -// RESPONSIBILITY to ensure that this function is only called WHEN THE -// TESTS ARE NOT SHUFFLED. -// -// Arguments: -// -// test_case_name: name of the test case -// type_param: the name of the test case's type parameter, or NULL if -// this is not a typed or a type-parameterized test case. -// set_up_tc: pointer to the function that sets up the test case -// tear_down_tc: pointer to the function that tears down the test case -TestCase* UnitTestImpl::GetTestCase(const char* test_case_name, - const char* type_param, - Test::SetUpTestCaseFunc set_up_tc, - Test::TearDownTestCaseFunc tear_down_tc) { - // Can we find a TestCase with the given name? - const std::vector::const_reverse_iterator test_case = - std::find_if(test_cases_.rbegin(), test_cases_.rend(), - TestCaseNameIs(test_case_name)); - - if (test_case != test_cases_.rend()) - return *test_case; - - // No. Let's create one. - TestCase* const new_test_case = - new TestCase(test_case_name, type_param, set_up_tc, tear_down_tc); - - // Is this a death test case? - if (internal::UnitTestOptions::MatchesFilter(test_case_name, - kDeathTestCaseFilter)) { - // Yes. Inserts the test case after the last death test case - // defined so far. This only works when the test cases haven't - // been shuffled. Otherwise we may end up running a death test - // after a non-death test. - ++last_death_test_case_; - test_cases_.insert(test_cases_.begin() + last_death_test_case_, - new_test_case); - } else { - // No. Appends to the end of the list. - test_cases_.push_back(new_test_case); - } - - test_case_indices_.push_back(static_cast(test_case_indices_.size())); - return new_test_case; -} - -// Helpers for setting up / tearing down the given environment. They -// are for use in the ForEach() function. -static void SetUpEnvironment(Environment* env) { env->SetUp(); } -static void TearDownEnvironment(Environment* env) { env->TearDown(); } - -// Runs all tests in this UnitTest object, prints the result, and -// returns true if all tests are successful. If any exception is -// thrown during a test, the test is considered to be failed, but the -// rest of the tests will still be run. -// -// When parameterized tests are enabled, it expands and registers -// parameterized tests first in RegisterParameterizedTests(). -// All other functions called from RunAllTests() may safely assume that -// parameterized tests are ready to be counted and run. -bool UnitTestImpl::RunAllTests() { - // True iff Google Test is initialized before RUN_ALL_TESTS() is called. - const bool gtest_is_initialized_before_run_all_tests = GTestIsInitialized(); - - // Do not run any test if the --help flag was specified. - if (g_help_flag) - return true; - - // Repeats the call to the post-flag parsing initialization in case the - // user didn't call InitGoogleTest. - PostFlagParsingInit(); - - // Even if sharding is not on, test runners may want to use the - // GTEST_SHARD_STATUS_FILE to query whether the test supports the sharding - // protocol. - internal::WriteToShardStatusFileIfNeeded(); - - // True iff we are in a subprocess for running a thread-safe-style - // death test. - bool in_subprocess_for_death_test = false; - -#if GTEST_HAS_DEATH_TEST - in_subprocess_for_death_test = (internal_run_death_test_flag_.get() != NULL); -# if defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_) - if (in_subprocess_for_death_test) { - GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_(); - } -# endif // defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_) -#endif // GTEST_HAS_DEATH_TEST - - const bool should_shard = ShouldShard(kTestTotalShards, kTestShardIndex, - in_subprocess_for_death_test); - - // Compares the full test names with the filter to decide which - // tests to run. - const bool has_tests_to_run = FilterTests(should_shard - ? HONOR_SHARDING_PROTOCOL - : IGNORE_SHARDING_PROTOCOL) > 0; - - // Lists the tests and exits if the --gtest_list_tests flag was specified. - if (GTEST_FLAG(list_tests)) { - // This must be called *after* FilterTests() has been called. - ListTestsMatchingFilter(); - return true; - } - - random_seed_ = GTEST_FLAG(shuffle) ? - GetRandomSeedFromFlag(GTEST_FLAG(random_seed)) : 0; - - // True iff at least one test has failed. - bool failed = false; - - TestEventListener* repeater = listeners()->repeater(); - - start_timestamp_ = GetTimeInMillis(); - repeater->OnTestProgramStart(*parent_); - - // How many times to repeat the tests? We don't want to repeat them - // when we are inside the subprocess of a death test. - const int repeat = in_subprocess_for_death_test ? 1 : GTEST_FLAG(repeat); - // Repeats forever if the repeat count is negative. - const bool forever = repeat < 0; - for (int i = 0; forever || i != repeat; i++) { - // We want to preserve failures generated by ad-hoc test - // assertions executed before RUN_ALL_TESTS(). - ClearNonAdHocTestResult(); - - const TimeInMillis start = GetTimeInMillis(); - - // Shuffles test cases and tests if requested. - if (has_tests_to_run && GTEST_FLAG(shuffle)) { - random()->Reseed(random_seed_); - // This should be done before calling OnTestIterationStart(), - // such that a test event listener can see the actual test order - // in the event. - ShuffleTests(); - } - - // Tells the unit test event listeners that the tests are about to start. - repeater->OnTestIterationStart(*parent_, i); - - // Runs each test case if there is at least one test to run. - if (has_tests_to_run) { - // Sets up all environments beforehand. - repeater->OnEnvironmentsSetUpStart(*parent_); - ForEach(environments_, SetUpEnvironment); - repeater->OnEnvironmentsSetUpEnd(*parent_); - - // Runs the tests only if there was no fatal failure during global - // set-up. - if (!Test::HasFatalFailure()) { - for (int test_index = 0; test_index < total_test_case_count(); - test_index++) { - GetMutableTestCase(test_index)->Run(); - } - } - - // Tears down all environments in reverse order afterwards. - repeater->OnEnvironmentsTearDownStart(*parent_); - std::for_each(environments_.rbegin(), environments_.rend(), - TearDownEnvironment); - repeater->OnEnvironmentsTearDownEnd(*parent_); - } - - elapsed_time_ = GetTimeInMillis() - start; - - // Tells the unit test event listener that the tests have just finished. - repeater->OnTestIterationEnd(*parent_, i); - - // Gets the result and clears it. - if (!Passed()) { - failed = true; - } - - // Restores the original test order after the iteration. This - // allows the user to quickly repro a failure that happens in the - // N-th iteration without repeating the first (N - 1) iterations. - // This is not enclosed in "if (GTEST_FLAG(shuffle)) { ... }", in - // case the user somehow changes the value of the flag somewhere - // (it's always safe to unshuffle the tests). - UnshuffleTests(); - - if (GTEST_FLAG(shuffle)) { - // Picks a new random seed for each iteration. - random_seed_ = GetNextRandomSeed(random_seed_); - } - } - - repeater->OnTestProgramEnd(*parent_); - - if (!gtest_is_initialized_before_run_all_tests) { - ColoredPrintf( - COLOR_RED, - "\nIMPORTANT NOTICE - DO NOT IGNORE:\n" - "This test program did NOT call " GTEST_INIT_GOOGLE_TEST_NAME_ - "() before calling RUN_ALL_TESTS(). This is INVALID. Soon " GTEST_NAME_ - " will start to enforce the valid usage. " - "Please fix it ASAP, or IT WILL START TO FAIL.\n"); // NOLINT -#if GTEST_FOR_GOOGLE_ - ColoredPrintf(COLOR_RED, - "For more details, see http://wiki/Main/ValidGUnitMain.\n"); -#endif // GTEST_FOR_GOOGLE_ - } - - return !failed; -} - -// Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file -// if the variable is present. If a file already exists at this location, this -// function will write over it. If the variable is present, but the file cannot -// be created, prints an error and exits. -void WriteToShardStatusFileIfNeeded() { - const char* const test_shard_file = posix::GetEnv(kTestShardStatusFile); - if (test_shard_file != NULL) { - FILE* const file = posix::FOpen(test_shard_file, "w"); - if (file == NULL) { - ColoredPrintf(COLOR_RED, - "Could not write to the test shard status file \"%s\" " - "specified by the %s environment variable.\n", - test_shard_file, kTestShardStatusFile); - fflush(stdout); - exit(EXIT_FAILURE); - } - fclose(file); - } -} - -// Checks whether sharding is enabled by examining the relevant -// environment variable values. If the variables are present, -// but inconsistent (i.e., shard_index >= total_shards), prints -// an error and exits. If in_subprocess_for_death_test, sharding is -// disabled because it must only be applied to the original test -// process. Otherwise, we could filter out death tests we intended to execute. -bool ShouldShard(const char* total_shards_env, - const char* shard_index_env, - bool in_subprocess_for_death_test) { - if (in_subprocess_for_death_test) { - return false; - } - - const Int32 total_shards = Int32FromEnvOrDie(total_shards_env, -1); - const Int32 shard_index = Int32FromEnvOrDie(shard_index_env, -1); - - if (total_shards == -1 && shard_index == -1) { - return false; - } else if (total_shards == -1 && shard_index != -1) { - const Message msg = Message() - << "Invalid environment variables: you have " - << kTestShardIndex << " = " << shard_index - << ", but have left " << kTestTotalShards << " unset.\n"; - ColoredPrintf(COLOR_RED, msg.GetString().c_str()); - fflush(stdout); - exit(EXIT_FAILURE); - } else if (total_shards != -1 && shard_index == -1) { - const Message msg = Message() - << "Invalid environment variables: you have " - << kTestTotalShards << " = " << total_shards - << ", but have left " << kTestShardIndex << " unset.\n"; - ColoredPrintf(COLOR_RED, msg.GetString().c_str()); - fflush(stdout); - exit(EXIT_FAILURE); - } else if (shard_index < 0 || shard_index >= total_shards) { - const Message msg = Message() - << "Invalid environment variables: we require 0 <= " - << kTestShardIndex << " < " << kTestTotalShards - << ", but you have " << kTestShardIndex << "=" << shard_index - << ", " << kTestTotalShards << "=" << total_shards << ".\n"; - ColoredPrintf(COLOR_RED, msg.GetString().c_str()); - fflush(stdout); - exit(EXIT_FAILURE); - } - - return total_shards > 1; -} - -// Parses the environment variable var as an Int32. If it is unset, -// returns default_val. If it is not an Int32, prints an error -// and aborts. -Int32 Int32FromEnvOrDie(const char* var, Int32 default_val) { - const char* str_val = posix::GetEnv(var); - if (str_val == NULL) { - return default_val; - } - - Int32 result; - if (!ParseInt32(Message() << "The value of environment variable " << var, - str_val, &result)) { - exit(EXIT_FAILURE); - } - return result; -} - -// Given the total number of shards, the shard index, and the test id, -// returns true iff the test should be run on this shard. The test id is -// some arbitrary but unique non-negative integer assigned to each test -// method. Assumes that 0 <= shard_index < total_shards. -bool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id) { - return (test_id % total_shards) == shard_index; -} - -// Compares the name of each test with the user-specified filter to -// decide whether the test should be run, then records the result in -// each TestCase and TestInfo object. -// If shard_tests == true, further filters tests based on sharding -// variables in the environment - see -// https://github.com/google/googletest/blob/master/googletest/docs/advanced.md -// . Returns the number of tests that should run. -int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) { - const Int32 total_shards = shard_tests == HONOR_SHARDING_PROTOCOL ? - Int32FromEnvOrDie(kTestTotalShards, -1) : -1; - const Int32 shard_index = shard_tests == HONOR_SHARDING_PROTOCOL ? - Int32FromEnvOrDie(kTestShardIndex, -1) : -1; - - // num_runnable_tests are the number of tests that will - // run across all shards (i.e., match filter and are not disabled). - // num_selected_tests are the number of tests to be run on - // this shard. - int num_runnable_tests = 0; - int num_selected_tests = 0; - for (size_t i = 0; i < test_cases_.size(); i++) { - TestCase* const test_case = test_cases_[i]; - const std::string &test_case_name = test_case->name(); - test_case->set_should_run(false); - - for (size_t j = 0; j < test_case->test_info_list().size(); j++) { - TestInfo* const test_info = test_case->test_info_list()[j]; - const std::string test_name(test_info->name()); - // A test is disabled if test case name or test name matches - // kDisableTestFilter. - const bool is_disabled = - internal::UnitTestOptions::MatchesFilter(test_case_name, - kDisableTestFilter) || - internal::UnitTestOptions::MatchesFilter(test_name, - kDisableTestFilter); - test_info->is_disabled_ = is_disabled; - - const bool matches_filter = - internal::UnitTestOptions::FilterMatchesTest(test_case_name, - test_name); - test_info->matches_filter_ = matches_filter; - - const bool is_runnable = - (GTEST_FLAG(also_run_disabled_tests) || !is_disabled) && - matches_filter; - - const bool is_in_another_shard = - shard_tests != IGNORE_SHARDING_PROTOCOL && - !ShouldRunTestOnShard(total_shards, shard_index, num_runnable_tests); - test_info->is_in_another_shard_ = is_in_another_shard; - const bool is_selected = is_runnable && !is_in_another_shard; - - num_runnable_tests += is_runnable; - num_selected_tests += is_selected; - - test_info->should_run_ = is_selected; - test_case->set_should_run(test_case->should_run() || is_selected); - } - } - return num_selected_tests; -} - -// Prints the given C-string on a single line by replacing all '\n' -// characters with string "\\n". If the output takes more than -// max_length characters, only prints the first max_length characters -// and "...". -static void PrintOnOneLine(const char* str, int max_length) { - if (str != NULL) { - for (int i = 0; *str != '\0'; ++str) { - if (i >= max_length) { - printf("..."); - break; - } - if (*str == '\n') { - printf("\\n"); - i += 2; - } else { - printf("%c", *str); - ++i; - } - } - } -} - -// Prints the names of the tests matching the user-specified filter flag. -void UnitTestImpl::ListTestsMatchingFilter() { - // Print at most this many characters for each type/value parameter. - const int kMaxParamLength = 250; - - for (size_t i = 0; i < test_cases_.size(); i++) { - const TestCase* const test_case = test_cases_[i]; - bool printed_test_case_name = false; - - for (size_t j = 0; j < test_case->test_info_list().size(); j++) { - const TestInfo* const test_info = - test_case->test_info_list()[j]; - if (test_info->matches_filter_) { - if (!printed_test_case_name) { - printed_test_case_name = true; - printf("%s.", test_case->name()); - if (test_case->type_param() != NULL) { - printf(" # %s = ", kTypeParamLabel); - // We print the type parameter on a single line to make - // the output easy to parse by a program. - PrintOnOneLine(test_case->type_param(), kMaxParamLength); - } - printf("\n"); - } - printf(" %s", test_info->name()); - if (test_info->value_param() != NULL) { - printf(" # %s = ", kValueParamLabel); - // We print the value parameter on a single line to make the - // output easy to parse by a program. - PrintOnOneLine(test_info->value_param(), kMaxParamLength); - } - printf("\n"); - } - } - } - fflush(stdout); -} - -// Sets the OS stack trace getter. -// -// Does nothing if the input and the current OS stack trace getter are -// the same; otherwise, deletes the old getter and makes the input the -// current getter. -void UnitTestImpl::set_os_stack_trace_getter( - OsStackTraceGetterInterface* getter) { - if (os_stack_trace_getter_ != getter) { - delete os_stack_trace_getter_; - os_stack_trace_getter_ = getter; - } -} - -// Returns the current OS stack trace getter if it is not NULL; -// otherwise, creates an OsStackTraceGetter, makes it the current -// getter, and returns it. -OsStackTraceGetterInterface* UnitTestImpl::os_stack_trace_getter() { - if (os_stack_trace_getter_ == NULL) { -#ifdef GTEST_OS_STACK_TRACE_GETTER_ - os_stack_trace_getter_ = new GTEST_OS_STACK_TRACE_GETTER_; -#else - os_stack_trace_getter_ = new OsStackTraceGetter; -#endif // GTEST_OS_STACK_TRACE_GETTER_ - } - - return os_stack_trace_getter_; -} - -// Returns the most specific TestResult currently running. -TestResult* UnitTestImpl::current_test_result() { - if (current_test_info_ != NULL) { - return ¤t_test_info_->result_; - } - if (current_test_case_ != NULL) { - return ¤t_test_case_->ad_hoc_test_result_; - } - return &ad_hoc_test_result_; -} - -// Shuffles all test cases, and the tests within each test case, -// making sure that death tests are still run first. -void UnitTestImpl::ShuffleTests() { - // Shuffles the death test cases. - ShuffleRange(random(), 0, last_death_test_case_ + 1, &test_case_indices_); - - // Shuffles the non-death test cases. - ShuffleRange(random(), last_death_test_case_ + 1, - static_cast(test_cases_.size()), &test_case_indices_); - - // Shuffles the tests inside each test case. - for (size_t i = 0; i < test_cases_.size(); i++) { - test_cases_[i]->ShuffleTests(random()); - } -} - -// Restores the test cases and tests to their order before the first shuffle. -void UnitTestImpl::UnshuffleTests() { - for (size_t i = 0; i < test_cases_.size(); i++) { - // Unshuffles the tests in each test case. - test_cases_[i]->UnshuffleTests(); - // Resets the index of each test case. - test_case_indices_[i] = static_cast(i); - } -} - -// Returns the current OS stack trace as an std::string. -// -// The maximum number of stack frames to be included is specified by -// the gtest_stack_trace_depth flag. The skip_count parameter -// specifies the number of top frames to be skipped, which doesn't -// count against the number of frames to be included. -// -// For example, if Foo() calls Bar(), which in turn calls -// GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in -// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't. -std::string GetCurrentOsStackTraceExceptTop(UnitTest* /*unit_test*/, - int skip_count) { - // We pass skip_count + 1 to skip this wrapper function in addition - // to what the user really wants to skip. - return GetUnitTestImpl()->CurrentOsStackTraceExceptTop(skip_count + 1); -} - -// Used by the GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_ macro to -// suppress unreachable code warnings. -namespace { -class ClassUniqueToAlwaysTrue {}; -} - -bool IsTrue(bool condition) { return condition; } - -bool AlwaysTrue() { -#if GTEST_HAS_EXCEPTIONS - // This condition is always false so AlwaysTrue() never actually throws, - // but it makes the compiler think that it may throw. - if (IsTrue(false)) - throw ClassUniqueToAlwaysTrue(); -#endif // GTEST_HAS_EXCEPTIONS - return true; -} - -// If *pstr starts with the given prefix, modifies *pstr to be right -// past the prefix and returns true; otherwise leaves *pstr unchanged -// and returns false. None of pstr, *pstr, and prefix can be NULL. -bool SkipPrefix(const char* prefix, const char** pstr) { - const size_t prefix_len = strlen(prefix); - if (strncmp(*pstr, prefix, prefix_len) == 0) { - *pstr += prefix_len; - return true; - } - return false; -} - -// Parses a string as a command line flag. The string should have -// the format "--flag=value". When def_optional is true, the "=value" -// part can be omitted. -// -// Returns the value of the flag, or NULL if the parsing failed. -static const char* ParseFlagValue(const char* str, const char* flag, - bool def_optional) { - // str and flag must not be NULL. - if (str == NULL || flag == NULL) return NULL; - - // The flag must start with "--" followed by GTEST_FLAG_PREFIX_. - const std::string flag_str = std::string("--") + GTEST_FLAG_PREFIX_ + flag; - const size_t flag_len = flag_str.length(); - if (strncmp(str, flag_str.c_str(), flag_len) != 0) return NULL; - - // Skips the flag name. - const char* flag_end = str + flag_len; - - // When def_optional is true, it's OK to not have a "=value" part. - if (def_optional && (flag_end[0] == '\0')) { - return flag_end; - } - - // If def_optional is true and there are more characters after the - // flag name, or if def_optional is false, there must be a '=' after - // the flag name. - if (flag_end[0] != '=') return NULL; - - // Returns the string after "=". - return flag_end + 1; -} - -// Parses a string for a bool flag, in the form of either -// "--flag=value" or "--flag". -// -// In the former case, the value is taken as true as long as it does -// not start with '0', 'f', or 'F'. -// -// In the latter case, the value is taken as true. -// -// On success, stores the value of the flag in *value, and returns -// true. On failure, returns false without changing *value. -static bool ParseBoolFlag(const char* str, const char* flag, bool* value) { - // Gets the value of the flag as a string. - const char* const value_str = ParseFlagValue(str, flag, true); - - // Aborts if the parsing failed. - if (value_str == NULL) return false; - - // Converts the string value to a bool. - *value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F'); - return true; -} - -// Parses a string for an Int32 flag, in the form of -// "--flag=value". -// -// On success, stores the value of the flag in *value, and returns -// true. On failure, returns false without changing *value. -bool ParseInt32Flag(const char* str, const char* flag, Int32* value) { - // Gets the value of the flag as a string. - const char* const value_str = ParseFlagValue(str, flag, false); - - // Aborts if the parsing failed. - if (value_str == NULL) return false; - - // Sets *value to the value of the flag. - return ParseInt32(Message() << "The value of flag --" << flag, - value_str, value); -} - -// Parses a string for a string flag, in the form of -// "--flag=value". -// -// On success, stores the value of the flag in *value, and returns -// true. On failure, returns false without changing *value. -template -static bool ParseStringFlag(const char* str, const char* flag, String* value) { - // Gets the value of the flag as a string. - const char* const value_str = ParseFlagValue(str, flag, false); - - // Aborts if the parsing failed. - if (value_str == NULL) return false; - - // Sets *value to the value of the flag. - *value = value_str; - return true; -} - -// Determines whether a string has a prefix that Google Test uses for its -// flags, i.e., starts with GTEST_FLAG_PREFIX_ or GTEST_FLAG_PREFIX_DASH_. -// If Google Test detects that a command line flag has its prefix but is not -// recognized, it will print its help message. Flags starting with -// GTEST_INTERNAL_PREFIX_ followed by "internal_" are considered Google Test -// internal flags and do not trigger the help message. -static bool HasGoogleTestFlagPrefix(const char* str) { - return (SkipPrefix("--", &str) || - SkipPrefix("-", &str) || - SkipPrefix("/", &str)) && - !SkipPrefix(GTEST_FLAG_PREFIX_ "internal_", &str) && - (SkipPrefix(GTEST_FLAG_PREFIX_, &str) || - SkipPrefix(GTEST_FLAG_PREFIX_DASH_, &str)); -} - -// Prints a string containing code-encoded text. The following escape -// sequences can be used in the string to control the text color: -// -// @@ prints a single '@' character. -// @R changes the color to red. -// @G changes the color to green. -// @Y changes the color to yellow. -// @D changes to the default terminal text color. -// -// TODO(wan@google.com): Write tests for this once we add stdout -// capturing to Google Test. -static void PrintColorEncoded(const char* str) { - GTestColor color = COLOR_DEFAULT; // The current color. - - // Conceptually, we split the string into segments divided by escape - // sequences. Then we print one segment at a time. At the end of - // each iteration, the str pointer advances to the beginning of the - // next segment. - for (;;) { - const char* p = strchr(str, '@'); - if (p == NULL) { - ColoredPrintf(color, "%s", str); - return; - } - - ColoredPrintf(color, "%s", std::string(str, p).c_str()); - - const char ch = p[1]; - str = p + 2; - if (ch == '@') { - ColoredPrintf(color, "@"); - } else if (ch == 'D') { - color = COLOR_DEFAULT; - } else if (ch == 'R') { - color = COLOR_RED; - } else if (ch == 'G') { - color = COLOR_GREEN; - } else if (ch == 'Y') { - color = COLOR_YELLOW; - } else { - --str; - } - } -} - -static const char kColorEncodedHelpMessage[] = -"This program contains tests written using " GTEST_NAME_ ". You can use the\n" -"following command line flags to control its behavior:\n" -"\n" -"Test Selection:\n" -" @G--" GTEST_FLAG_PREFIX_ "list_tests@D\n" -" List the names of all tests instead of running them. The name of\n" -" TEST(Foo, Bar) is \"Foo.Bar\".\n" -" @G--" GTEST_FLAG_PREFIX_ "filter=@YPOSTIVE_PATTERNS" - "[@G-@YNEGATIVE_PATTERNS]@D\n" -" Run only the tests whose name matches one of the positive patterns but\n" -" none of the negative patterns. '?' matches any single character; '*'\n" -" matches any substring; ':' separates two patterns.\n" -" @G--" GTEST_FLAG_PREFIX_ "also_run_disabled_tests@D\n" -" Run all disabled tests too.\n" -"\n" -"Test Execution:\n" -" @G--" GTEST_FLAG_PREFIX_ "repeat=@Y[COUNT]@D\n" -" Run the tests repeatedly; use a negative count to repeat forever.\n" -" @G--" GTEST_FLAG_PREFIX_ "shuffle@D\n" -" Randomize tests' orders on every iteration.\n" -" @G--" GTEST_FLAG_PREFIX_ "random_seed=@Y[NUMBER]@D\n" -" Random number seed to use for shuffling test orders (between 1 and\n" -" 99999, or 0 to use a seed based on the current time).\n" -"\n" -"Test Output:\n" -" @G--" GTEST_FLAG_PREFIX_ "color=@Y(@Gyes@Y|@Gno@Y|@Gauto@Y)@D\n" -" Enable/disable colored output. The default is @Gauto@D.\n" -" -@G-" GTEST_FLAG_PREFIX_ "print_time=0@D\n" -" Don't print the elapsed time of each test.\n" -" @G--" GTEST_FLAG_PREFIX_ "output=@Y(@Gjson@Y|@Gxml@Y)[@G:@YDIRECTORY_PATH@G" - GTEST_PATH_SEP_ "@Y|@G:@YFILE_PATH]@D\n" -" Generate a JSON or XML report in the given directory or with the given\n" -" file name. @YFILE_PATH@D defaults to @Gtest_details.xml@D.\n" -# if GTEST_CAN_STREAM_RESULTS_ -" @G--" GTEST_FLAG_PREFIX_ "stream_result_to=@YHOST@G:@YPORT@D\n" -" Stream test results to the given server.\n" -# endif // GTEST_CAN_STREAM_RESULTS_ -"\n" -"Assertion Behavior:\n" -# if GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS -" @G--" GTEST_FLAG_PREFIX_ "death_test_style=@Y(@Gfast@Y|@Gthreadsafe@Y)@D\n" -" Set the default death test style.\n" -# endif // GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS -" @G--" GTEST_FLAG_PREFIX_ "break_on_failure@D\n" -" Turn assertion failures into debugger break-points.\n" -" @G--" GTEST_FLAG_PREFIX_ "throw_on_failure@D\n" -" Turn assertion failures into C++ exceptions for use by an external\n" -" test framework.\n" -" @G--" GTEST_FLAG_PREFIX_ "catch_exceptions=0@D\n" -" Do not report exceptions as test failures. Instead, allow them\n" -" to crash the program or throw a pop-up (on Windows).\n" -"\n" -"Except for @G--" GTEST_FLAG_PREFIX_ "list_tests@D, you can alternatively set " - "the corresponding\n" -"environment variable of a flag (all letters in upper-case). For example, to\n" -"disable colored text output, you can either specify @G--" GTEST_FLAG_PREFIX_ - "color=no@D or set\n" -"the @G" GTEST_FLAG_PREFIX_UPPER_ "COLOR@D environment variable to @Gno@D.\n" -"\n" -"For more information, please read the " GTEST_NAME_ " documentation at\n" -"@G" GTEST_PROJECT_URL_ "@D. If you find a bug in " GTEST_NAME_ "\n" -"(not one in your own code or tests), please report it to\n" -"@G<" GTEST_DEV_EMAIL_ ">@D.\n"; - -static bool ParseGoogleTestFlag(const char* const arg) { - return ParseBoolFlag(arg, kAlsoRunDisabledTestsFlag, - >EST_FLAG(also_run_disabled_tests)) || - ParseBoolFlag(arg, kBreakOnFailureFlag, - >EST_FLAG(break_on_failure)) || - ParseBoolFlag(arg, kCatchExceptionsFlag, - >EST_FLAG(catch_exceptions)) || - ParseStringFlag(arg, kColorFlag, >EST_FLAG(color)) || - ParseStringFlag(arg, kDeathTestStyleFlag, - >EST_FLAG(death_test_style)) || - ParseBoolFlag(arg, kDeathTestUseFork, - >EST_FLAG(death_test_use_fork)) || - ParseStringFlag(arg, kFilterFlag, >EST_FLAG(filter)) || - ParseStringFlag(arg, kInternalRunDeathTestFlag, - >EST_FLAG(internal_run_death_test)) || - ParseBoolFlag(arg, kListTestsFlag, >EST_FLAG(list_tests)) || - ParseStringFlag(arg, kOutputFlag, >EST_FLAG(output)) || - ParseBoolFlag(arg, kPrintTimeFlag, >EST_FLAG(print_time)) || - ParseBoolFlag(arg, kPrintUTF8Flag, >EST_FLAG(print_utf8)) || - ParseInt32Flag(arg, kRandomSeedFlag, >EST_FLAG(random_seed)) || - ParseInt32Flag(arg, kRepeatFlag, >EST_FLAG(repeat)) || - ParseBoolFlag(arg, kShuffleFlag, >EST_FLAG(shuffle)) || - ParseInt32Flag(arg, kStackTraceDepthFlag, - >EST_FLAG(stack_trace_depth)) || - ParseStringFlag(arg, kStreamResultToFlag, - >EST_FLAG(stream_result_to)) || - ParseBoolFlag(arg, kThrowOnFailureFlag, - >EST_FLAG(throw_on_failure)); -} - -#if GTEST_USE_OWN_FLAGFILE_FLAG_ -static void LoadFlagsFromFile(const std::string& path) { - FILE* flagfile = posix::FOpen(path.c_str(), "r"); - if (!flagfile) { - GTEST_LOG_(FATAL) << "Unable to open file \"" << GTEST_FLAG(flagfile) - << "\""; - } - std::string contents(ReadEntireFile(flagfile)); - posix::FClose(flagfile); - std::vector lines; - SplitString(contents, '\n', &lines); - for (size_t i = 0; i < lines.size(); ++i) { - if (lines[i].empty()) - continue; - if (!ParseGoogleTestFlag(lines[i].c_str())) - g_help_flag = true; - } -} -#endif // GTEST_USE_OWN_FLAGFILE_FLAG_ - -// Parses the command line for Google Test flags, without initializing -// other parts of Google Test. The type parameter CharType can be -// instantiated to either char or wchar_t. -template -void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) { - for (int i = 1; i < *argc; i++) { - const std::string arg_string = StreamableToString(argv[i]); - const char* const arg = arg_string.c_str(); - - using internal::ParseBoolFlag; - using internal::ParseInt32Flag; - using internal::ParseStringFlag; - - bool remove_flag = false; - if (ParseGoogleTestFlag(arg)) { - remove_flag = true; -#if GTEST_USE_OWN_FLAGFILE_FLAG_ - } else if (ParseStringFlag(arg, kFlagfileFlag, >EST_FLAG(flagfile))) { - LoadFlagsFromFile(GTEST_FLAG(flagfile)); - remove_flag = true; -#endif // GTEST_USE_OWN_FLAGFILE_FLAG_ - } else if (arg_string == "--help" || arg_string == "-h" || - arg_string == "-?" || arg_string == "/?" || - HasGoogleTestFlagPrefix(arg)) { - // Both help flag and unrecognized Google Test flags (excluding - // internal ones) trigger help display. - g_help_flag = true; - } - - if (remove_flag) { - // Shift the remainder of the argv list left by one. Note - // that argv has (*argc + 1) elements, the last one always being - // NULL. The following loop moves the trailing NULL element as - // well. - for (int j = i; j != *argc; j++) { - argv[j] = argv[j + 1]; - } - - // Decrements the argument count. - (*argc)--; - - // We also need to decrement the iterator as we just removed - // an element. - i--; - } - } - - if (g_help_flag) { - // We print the help here instead of in RUN_ALL_TESTS(), as the - // latter may not be called at all if the user is using Google - // Test with another testing framework. - PrintColorEncoded(kColorEncodedHelpMessage); - } -} - -// Parses the command line for Google Test flags, without initializing -// other parts of Google Test. -void ParseGoogleTestFlagsOnly(int* argc, char** argv) { - ParseGoogleTestFlagsOnlyImpl(argc, argv); -} -void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv) { - ParseGoogleTestFlagsOnlyImpl(argc, argv); -} - -// The internal implementation of InitGoogleTest(). -// -// The type parameter CharType can be instantiated to either char or -// wchar_t. -template -void InitGoogleTestImpl(int* argc, CharType** argv) { - // We don't want to run the initialization code twice. - if (GTestIsInitialized()) return; - - if (*argc <= 0) return; - - g_argvs.clear(); - for (int i = 0; i != *argc; i++) { - g_argvs.push_back(StreamableToString(argv[i])); - } - -#if GTEST_HAS_ABSL - absl::InitializeSymbolizer(g_argvs[0].c_str()); -#endif // GTEST_HAS_ABSL - - ParseGoogleTestFlagsOnly(argc, argv); - GetUnitTestImpl()->PostFlagParsingInit(); -} - -} // namespace internal - -// Initializes Google Test. This must be called before calling -// RUN_ALL_TESTS(). In particular, it parses a command line for the -// flags that Google Test recognizes. Whenever a Google Test flag is -// seen, it is removed from argv, and *argc is decremented. -// -// No value is returned. Instead, the Google Test flag variables are -// updated. -// -// Calling the function for the second time has no user-visible effect. -void InitGoogleTest(int* argc, char** argv) { -#if defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_) - GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_(argc, argv); -#else // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_) - internal::InitGoogleTestImpl(argc, argv); -#endif // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_) -} - -// This overloaded version can be used in Windows programs compiled in -// UNICODE mode. -void InitGoogleTest(int* argc, wchar_t** argv) { -#if defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_) - GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_(argc, argv); -#else // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_) - internal::InitGoogleTestImpl(argc, argv); -#endif // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_) -} - -std::string TempDir() { -#if defined(GTEST_CUSTOM_TEMPDIR_FUNCTION_) - return GTEST_CUSTOM_TEMPDIR_FUNCTION_(); -#endif - -#if GTEST_OS_WINDOWS_MOBILE - return "\\temp\\"; -#elif GTEST_OS_WINDOWS - const char* temp_dir = internal::posix::GetEnv("TEMP"); - if (temp_dir == NULL || temp_dir[0] == '\0') - return "\\temp\\"; - else if (temp_dir[strlen(temp_dir) - 1] == '\\') - return temp_dir; - else - return std::string(temp_dir) + "\\"; -#elif GTEST_OS_LINUX_ANDROID - return "/sdcard/"; -#else - return "/tmp/"; -#endif // GTEST_OS_WINDOWS_MOBILE -} - -// Class ScopedTrace - -// Pushes the given source file location and message onto a per-thread -// trace stack maintained by Google Test. -void ScopedTrace::PushTrace(const char* file, int line, std::string message) { - internal::TraceInfo trace; - trace.file = file; - trace.line = line; - trace.message.swap(message); - - UnitTest::GetInstance()->PushGTestTrace(trace); -} - -// Pops the info pushed by the c'tor. -ScopedTrace::~ScopedTrace() - GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) { - UnitTest::GetInstance()->PopGTestTrace(); -} - -} // namespace testing -// Copyright 2005, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan), vladl@google.com (Vlad Losev) -// -// This file implements death tests. - - -#if GTEST_HAS_DEATH_TEST - -# if GTEST_OS_MAC -# include -# endif // GTEST_OS_MAC - -# include -# include -# include - -# if GTEST_OS_LINUX -# include -# endif // GTEST_OS_LINUX - -# include - -# if GTEST_OS_WINDOWS -# include -# else -# include -# include -# endif // GTEST_OS_WINDOWS - -# if GTEST_OS_QNX -# include -# endif // GTEST_OS_QNX - -# if GTEST_OS_FUCHSIA -# include -# include -# include -# include -# endif // GTEST_OS_FUCHSIA - -#endif // GTEST_HAS_DEATH_TEST - - -namespace testing { - -// Constants. - -// The default death test style. -// -// This is defined in internal/gtest-port.h as "fast", but can be overridden by -// a definition in internal/custom/gtest-port.h. The recommended value, which is -// used internally at Google, is "threadsafe". -static const char kDefaultDeathTestStyle[] = GTEST_DEFAULT_DEATH_TEST_STYLE; - -GTEST_DEFINE_string_( - death_test_style, - internal::StringFromGTestEnv("death_test_style", kDefaultDeathTestStyle), - "Indicates how to run a death test in a forked child process: " - "\"threadsafe\" (child process re-executes the test binary " - "from the beginning, running only the specific death test) or " - "\"fast\" (child process runs the death test immediately " - "after forking)."); - -GTEST_DEFINE_bool_( - death_test_use_fork, - internal::BoolFromGTestEnv("death_test_use_fork", false), - "Instructs to use fork()/_exit() instead of clone() in death tests. " - "Ignored and always uses fork() on POSIX systems where clone() is not " - "implemented. Useful when running under valgrind or similar tools if " - "those do not support clone(). Valgrind 3.3.1 will just fail if " - "it sees an unsupported combination of clone() flags. " - "It is not recommended to use this flag w/o valgrind though it will " - "work in 99% of the cases. Once valgrind is fixed, this flag will " - "most likely be removed."); - -namespace internal { -GTEST_DEFINE_string_( - internal_run_death_test, "", - "Indicates the file, line number, temporal index of " - "the single death test to run, and a file descriptor to " - "which a success code may be sent, all separated by " - "the '|' characters. This flag is specified if and only if the current " - "process is a sub-process launched for running a thread-safe " - "death test. FOR INTERNAL USE ONLY."); -} // namespace internal - -#if GTEST_HAS_DEATH_TEST - -namespace internal { - -// Valid only for fast death tests. Indicates the code is running in the -// child process of a fast style death test. -# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA -static bool g_in_fast_death_test_child = false; -# endif - -// Returns a Boolean value indicating whether the caller is currently -// executing in the context of the death test child process. Tools such as -// Valgrind heap checkers may need this to modify their behavior in death -// tests. IMPORTANT: This is an internal utility. Using it may break the -// implementation of death tests. User code MUST NOT use it. -bool InDeathTestChild() { -# if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA - - // On Windows and Fuchsia, death tests are thread-safe regardless of the value - // of the death_test_style flag. - return !GTEST_FLAG(internal_run_death_test).empty(); - -# else - - if (GTEST_FLAG(death_test_style) == "threadsafe") - return !GTEST_FLAG(internal_run_death_test).empty(); - else - return g_in_fast_death_test_child; -#endif -} - -} // namespace internal - -// ExitedWithCode constructor. -ExitedWithCode::ExitedWithCode(int exit_code) : exit_code_(exit_code) { -} - -// ExitedWithCode function-call operator. -bool ExitedWithCode::operator()(int exit_status) const { -# if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA - - return exit_status == exit_code_; - -# else - - return WIFEXITED(exit_status) && WEXITSTATUS(exit_status) == exit_code_; - -# endif // GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA -} - -# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA -// KilledBySignal constructor. -KilledBySignal::KilledBySignal(int signum) : signum_(signum) { -} - -// KilledBySignal function-call operator. -bool KilledBySignal::operator()(int exit_status) const { -# if defined(GTEST_KILLED_BY_SIGNAL_OVERRIDE_) - { - bool result; - if (GTEST_KILLED_BY_SIGNAL_OVERRIDE_(signum_, exit_status, &result)) { - return result; - } - } -# endif // defined(GTEST_KILLED_BY_SIGNAL_OVERRIDE_) - return WIFSIGNALED(exit_status) && WTERMSIG(exit_status) == signum_; -} -# endif // !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA - -namespace internal { - -// Utilities needed for death tests. - -// Generates a textual description of a given exit code, in the format -// specified by wait(2). -static std::string ExitSummary(int exit_code) { - Message m; - -# if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA - - m << "Exited with exit status " << exit_code; - -# else - - if (WIFEXITED(exit_code)) { - m << "Exited with exit status " << WEXITSTATUS(exit_code); - } else if (WIFSIGNALED(exit_code)) { - m << "Terminated by signal " << WTERMSIG(exit_code); - } -# ifdef WCOREDUMP - if (WCOREDUMP(exit_code)) { - m << " (core dumped)"; - } -# endif -# endif // GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA - - return m.GetString(); -} - -// Returns true if exit_status describes a process that was terminated -// by a signal, or exited normally with a nonzero exit code. -bool ExitedUnsuccessfully(int exit_status) { - return !ExitedWithCode(0)(exit_status); -} - -# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA -// Generates a textual failure message when a death test finds more than -// one thread running, or cannot determine the number of threads, prior -// to executing the given statement. It is the responsibility of the -// caller not to pass a thread_count of 1. -static std::string DeathTestThreadWarning(size_t thread_count) { - Message msg; - msg << "Death tests use fork(), which is unsafe particularly" - << " in a threaded context. For this test, " << GTEST_NAME_ << " "; - if (thread_count == 0) - msg << "couldn't detect the number of threads."; - else - msg << "detected " << thread_count << " threads."; - return msg.GetString(); -} -# endif // !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA - -// Flag characters for reporting a death test that did not die. -static const char kDeathTestLived = 'L'; -static const char kDeathTestReturned = 'R'; -static const char kDeathTestThrew = 'T'; -static const char kDeathTestInternalError = 'I'; - -#if GTEST_OS_FUCHSIA - -// File descriptor used for the pipe in the child process. -static const int kFuchsiaReadPipeFd = 3; - -#endif - -// An enumeration describing all of the possible ways that a death test can -// conclude. DIED means that the process died while executing the test -// code; LIVED means that process lived beyond the end of the test code; -// RETURNED means that the test statement attempted to execute a return -// statement, which is not allowed; THREW means that the test statement -// returned control by throwing an exception. IN_PROGRESS means the test -// has not yet concluded. -// TODO(vladl@google.com): Unify names and possibly values for -// AbortReason, DeathTestOutcome, and flag characters above. -enum DeathTestOutcome { IN_PROGRESS, DIED, LIVED, RETURNED, THREW }; - -// Routine for aborting the program which is safe to call from an -// exec-style death test child process, in which case the error -// message is propagated back to the parent process. Otherwise, the -// message is simply printed to stderr. In either case, the program -// then exits with status 1. -static void DeathTestAbort(const std::string& message) { - // On a POSIX system, this function may be called from a threadsafe-style - // death test child process, which operates on a very small stack. Use - // the heap for any additional non-minuscule memory requirements. - const InternalRunDeathTestFlag* const flag = - GetUnitTestImpl()->internal_run_death_test_flag(); - if (flag != NULL) { - FILE* parent = posix::FDOpen(flag->write_fd(), "w"); - fputc(kDeathTestInternalError, parent); - fprintf(parent, "%s", message.c_str()); - fflush(parent); - _exit(1); - } else { - fprintf(stderr, "%s", message.c_str()); - fflush(stderr); - posix::Abort(); - } -} - -// A replacement for CHECK that calls DeathTestAbort if the assertion -// fails. -# define GTEST_DEATH_TEST_CHECK_(expression) \ - do { \ - if (!::testing::internal::IsTrue(expression)) { \ - DeathTestAbort( \ - ::std::string("CHECK failed: File ") + __FILE__ + ", line " \ - + ::testing::internal::StreamableToString(__LINE__) + ": " \ - + #expression); \ - } \ - } while (::testing::internal::AlwaysFalse()) - -// This macro is similar to GTEST_DEATH_TEST_CHECK_, but it is meant for -// evaluating any system call that fulfills two conditions: it must return -// -1 on failure, and set errno to EINTR when it is interrupted and -// should be tried again. The macro expands to a loop that repeatedly -// evaluates the expression as long as it evaluates to -1 and sets -// errno to EINTR. If the expression evaluates to -1 but errno is -// something other than EINTR, DeathTestAbort is called. -# define GTEST_DEATH_TEST_CHECK_SYSCALL_(expression) \ - do { \ - int gtest_retval; \ - do { \ - gtest_retval = (expression); \ - } while (gtest_retval == -1 && errno == EINTR); \ - if (gtest_retval == -1) { \ - DeathTestAbort( \ - ::std::string("CHECK failed: File ") + __FILE__ + ", line " \ - + ::testing::internal::StreamableToString(__LINE__) + ": " \ - + #expression + " != -1"); \ - } \ - } while (::testing::internal::AlwaysFalse()) - -// Returns the message describing the last system error in errno. -std::string GetLastErrnoDescription() { - return errno == 0 ? "" : posix::StrError(errno); -} - -// This is called from a death test parent process to read a failure -// message from the death test child process and log it with the FATAL -// severity. On Windows, the message is read from a pipe handle. On other -// platforms, it is read from a file descriptor. -static void FailFromInternalError(int fd) { - Message error; - char buffer[256]; - int num_read; - - do { - while ((num_read = posix::Read(fd, buffer, 255)) > 0) { - buffer[num_read] = '\0'; - error << buffer; - } - } while (num_read == -1 && errno == EINTR); - - if (num_read == 0) { - GTEST_LOG_(FATAL) << error.GetString(); - } else { - const int last_error = errno; - GTEST_LOG_(FATAL) << "Error while reading death test internal: " - << GetLastErrnoDescription() << " [" << last_error << "]"; - } -} - -// Death test constructor. Increments the running death test count -// for the current test. -DeathTest::DeathTest() { - TestInfo* const info = GetUnitTestImpl()->current_test_info(); - if (info == NULL) { - DeathTestAbort("Cannot run a death test outside of a TEST or " - "TEST_F construct"); - } -} - -// Creates and returns a death test by dispatching to the current -// death test factory. -bool DeathTest::Create(const char* statement, const RE* regex, - const char* file, int line, DeathTest** test) { - return GetUnitTestImpl()->death_test_factory()->Create( - statement, regex, file, line, test); -} - -const char* DeathTest::LastMessage() { - return last_death_test_message_.c_str(); -} - -void DeathTest::set_last_death_test_message(const std::string& message) { - last_death_test_message_ = message; -} - -std::string DeathTest::last_death_test_message_; - -// Provides cross platform implementation for some death functionality. -class DeathTestImpl : public DeathTest { - protected: - DeathTestImpl(const char* a_statement, const RE* a_regex) - : statement_(a_statement), - regex_(a_regex), - spawned_(false), - status_(-1), - outcome_(IN_PROGRESS), - read_fd_(-1), - write_fd_(-1) {} - - // read_fd_ is expected to be closed and cleared by a derived class. - ~DeathTestImpl() { GTEST_DEATH_TEST_CHECK_(read_fd_ == -1); } - - void Abort(AbortReason reason); - virtual bool Passed(bool status_ok); - - const char* statement() const { return statement_; } - const RE* regex() const { return regex_; } - bool spawned() const { return spawned_; } - void set_spawned(bool is_spawned) { spawned_ = is_spawned; } - int status() const { return status_; } - void set_status(int a_status) { status_ = a_status; } - DeathTestOutcome outcome() const { return outcome_; } - void set_outcome(DeathTestOutcome an_outcome) { outcome_ = an_outcome; } - int read_fd() const { return read_fd_; } - void set_read_fd(int fd) { read_fd_ = fd; } - int write_fd() const { return write_fd_; } - void set_write_fd(int fd) { write_fd_ = fd; } - - // Called in the parent process only. Reads the result code of the death - // test child process via a pipe, interprets it to set the outcome_ - // member, and closes read_fd_. Outputs diagnostics and terminates in - // case of unexpected codes. - void ReadAndInterpretStatusByte(); - - private: - // The textual content of the code this object is testing. This class - // doesn't own this string and should not attempt to delete it. - const char* const statement_; - // The regular expression which test output must match. DeathTestImpl - // doesn't own this object and should not attempt to delete it. - const RE* const regex_; - // True if the death test child process has been successfully spawned. - bool spawned_; - // The exit status of the child process. - int status_; - // How the death test concluded. - DeathTestOutcome outcome_; - // Descriptor to the read end of the pipe to the child process. It is - // always -1 in the child process. The child keeps its write end of the - // pipe in write_fd_. - int read_fd_; - // Descriptor to the child's write end of the pipe to the parent process. - // It is always -1 in the parent process. The parent keeps its end of the - // pipe in read_fd_. - int write_fd_; -}; - -// Called in the parent process only. Reads the result code of the death -// test child process via a pipe, interprets it to set the outcome_ -// member, and closes read_fd_. Outputs diagnostics and terminates in -// case of unexpected codes. -void DeathTestImpl::ReadAndInterpretStatusByte() { - char flag; - int bytes_read; - - // The read() here blocks until data is available (signifying the - // failure of the death test) or until the pipe is closed (signifying - // its success), so it's okay to call this in the parent before - // the child process has exited. - do { - bytes_read = posix::Read(read_fd(), &flag, 1); - } while (bytes_read == -1 && errno == EINTR); - - if (bytes_read == 0) { - set_outcome(DIED); - } else if (bytes_read == 1) { - switch (flag) { - case kDeathTestReturned: - set_outcome(RETURNED); - break; - case kDeathTestThrew: - set_outcome(THREW); - break; - case kDeathTestLived: - set_outcome(LIVED); - break; - case kDeathTestInternalError: - FailFromInternalError(read_fd()); // Does not return. - break; - default: - GTEST_LOG_(FATAL) << "Death test child process reported " - << "unexpected status byte (" - << static_cast(flag) << ")"; - } - } else { - GTEST_LOG_(FATAL) << "Read from death test child process failed: " - << GetLastErrnoDescription(); - } - GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Close(read_fd())); - set_read_fd(-1); -} - -// Signals that the death test code which should have exited, didn't. -// Should be called only in a death test child process. -// Writes a status byte to the child's status file descriptor, then -// calls _exit(1). -void DeathTestImpl::Abort(AbortReason reason) { - // The parent process considers the death test to be a failure if - // it finds any data in our pipe. So, here we write a single flag byte - // to the pipe, then exit. - const char status_ch = - reason == TEST_DID_NOT_DIE ? kDeathTestLived : - reason == TEST_THREW_EXCEPTION ? kDeathTestThrew : kDeathTestReturned; - - GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Write(write_fd(), &status_ch, 1)); - // We are leaking the descriptor here because on some platforms (i.e., - // when built as Windows DLL), destructors of global objects will still - // run after calling _exit(). On such systems, write_fd_ will be - // indirectly closed from the destructor of UnitTestImpl, causing double - // close if it is also closed here. On debug configurations, double close - // may assert. As there are no in-process buffers to flush here, we are - // relying on the OS to close the descriptor after the process terminates - // when the destructors are not run. - _exit(1); // Exits w/o any normal exit hooks (we were supposed to crash) -} - -// Returns an indented copy of stderr output for a death test. -// This makes distinguishing death test output lines from regular log lines -// much easier. -static ::std::string FormatDeathTestOutput(const ::std::string& output) { - ::std::string ret; - for (size_t at = 0; ; ) { - const size_t line_end = output.find('\n', at); - ret += "[ DEATH ] "; - if (line_end == ::std::string::npos) { - ret += output.substr(at); - break; - } - ret += output.substr(at, line_end + 1 - at); - at = line_end + 1; - } - return ret; -} - -// Assesses the success or failure of a death test, using both private -// members which have previously been set, and one argument: -// -// Private data members: -// outcome: An enumeration describing how the death test -// concluded: DIED, LIVED, THREW, or RETURNED. The death test -// fails in the latter three cases. -// status: The exit status of the child process. On *nix, it is in the -// in the format specified by wait(2). On Windows, this is the -// value supplied to the ExitProcess() API or a numeric code -// of the exception that terminated the program. -// regex: A regular expression object to be applied to -// the test's captured standard error output; the death test -// fails if it does not match. -// -// Argument: -// status_ok: true if exit_status is acceptable in the context of -// this particular death test, which fails if it is false -// -// Returns true iff all of the above conditions are met. Otherwise, the -// first failing condition, in the order given above, is the one that is -// reported. Also sets the last death test message string. -bool DeathTestImpl::Passed(bool status_ok) { - if (!spawned()) - return false; - - const std::string error_message = GetCapturedStderr(); - - bool success = false; - Message buffer; - - buffer << "Death test: " << statement() << "\n"; - switch (outcome()) { - case LIVED: - buffer << " Result: failed to die.\n" - << " Error msg:\n" << FormatDeathTestOutput(error_message); - break; - case THREW: - buffer << " Result: threw an exception.\n" - << " Error msg:\n" << FormatDeathTestOutput(error_message); - break; - case RETURNED: - buffer << " Result: illegal return in test statement.\n" - << " Error msg:\n" << FormatDeathTestOutput(error_message); - break; - case DIED: - if (status_ok) { -# if GTEST_USES_PCRE - // PCRE regexes support embedded NULs. - // GTEST_USES_PCRE is defined only in google3 mode - const bool matched = RE::PartialMatch(error_message, *regex()); -# else - const bool matched = RE::PartialMatch(error_message.c_str(), *regex()); -# endif // GTEST_USES_PCRE - if (matched) { - success = true; - } else { - buffer << " Result: died but not with expected error.\n" - << " Expected: " << regex()->pattern() << "\n" - << "Actual msg:\n" << FormatDeathTestOutput(error_message); - } - } else { - buffer << " Result: died but not with expected exit code:\n" - << " " << ExitSummary(status()) << "\n" - << "Actual msg:\n" << FormatDeathTestOutput(error_message); - } - break; - case IN_PROGRESS: - default: - GTEST_LOG_(FATAL) - << "DeathTest::Passed somehow called before conclusion of test"; - } - - DeathTest::set_last_death_test_message(buffer.GetString()); - return success; -} - -# if GTEST_OS_WINDOWS -// WindowsDeathTest implements death tests on Windows. Due to the -// specifics of starting new processes on Windows, death tests there are -// always threadsafe, and Google Test considers the -// --gtest_death_test_style=fast setting to be equivalent to -// --gtest_death_test_style=threadsafe there. -// -// A few implementation notes: Like the Linux version, the Windows -// implementation uses pipes for child-to-parent communication. But due to -// the specifics of pipes on Windows, some extra steps are required: -// -// 1. The parent creates a communication pipe and stores handles to both -// ends of it. -// 2. The parent starts the child and provides it with the information -// necessary to acquire the handle to the write end of the pipe. -// 3. The child acquires the write end of the pipe and signals the parent -// using a Windows event. -// 4. Now the parent can release the write end of the pipe on its side. If -// this is done before step 3, the object's reference count goes down to -// 0 and it is destroyed, preventing the child from acquiring it. The -// parent now has to release it, or read operations on the read end of -// the pipe will not return when the child terminates. -// 5. The parent reads child's output through the pipe (outcome code and -// any possible error messages) from the pipe, and its stderr and then -// determines whether to fail the test. -// -// Note: to distinguish Win32 API calls from the local method and function -// calls, the former are explicitly resolved in the global namespace. -// -class WindowsDeathTest : public DeathTestImpl { - public: - WindowsDeathTest(const char* a_statement, - const RE* a_regex, - const char* file, - int line) - : DeathTestImpl(a_statement, a_regex), file_(file), line_(line) {} - - // All of these virtual functions are inherited from DeathTest. - virtual int Wait(); - virtual TestRole AssumeRole(); - - private: - // The name of the file in which the death test is located. - const char* const file_; - // The line number on which the death test is located. - const int line_; - // Handle to the write end of the pipe to the child process. - AutoHandle write_handle_; - // Child process handle. - AutoHandle child_handle_; - // Event the child process uses to signal the parent that it has - // acquired the handle to the write end of the pipe. After seeing this - // event the parent can release its own handles to make sure its - // ReadFile() calls return when the child terminates. - AutoHandle event_handle_; -}; - -// Waits for the child in a death test to exit, returning its exit -// status, or 0 if no child process exists. As a side effect, sets the -// outcome data member. -int WindowsDeathTest::Wait() { - if (!spawned()) - return 0; - - // Wait until the child either signals that it has acquired the write end - // of the pipe or it dies. - const HANDLE wait_handles[2] = { child_handle_.Get(), event_handle_.Get() }; - switch (::WaitForMultipleObjects(2, - wait_handles, - FALSE, // Waits for any of the handles. - INFINITE)) { - case WAIT_OBJECT_0: - case WAIT_OBJECT_0 + 1: - break; - default: - GTEST_DEATH_TEST_CHECK_(false); // Should not get here. - } - - // The child has acquired the write end of the pipe or exited. - // We release the handle on our side and continue. - write_handle_.Reset(); - event_handle_.Reset(); - - ReadAndInterpretStatusByte(); - - // Waits for the child process to exit if it haven't already. This - // returns immediately if the child has already exited, regardless of - // whether previous calls to WaitForMultipleObjects synchronized on this - // handle or not. - GTEST_DEATH_TEST_CHECK_( - WAIT_OBJECT_0 == ::WaitForSingleObject(child_handle_.Get(), - INFINITE)); - DWORD status_code; - GTEST_DEATH_TEST_CHECK_( - ::GetExitCodeProcess(child_handle_.Get(), &status_code) != FALSE); - child_handle_.Reset(); - set_status(static_cast(status_code)); - return status(); -} - -// The AssumeRole process for a Windows death test. It creates a child -// process with the same executable as the current process to run the -// death test. The child process is given the --gtest_filter and -// --gtest_internal_run_death_test flags such that it knows to run the -// current death test only. -DeathTest::TestRole WindowsDeathTest::AssumeRole() { - const UnitTestImpl* const impl = GetUnitTestImpl(); - const InternalRunDeathTestFlag* const flag = - impl->internal_run_death_test_flag(); - const TestInfo* const info = impl->current_test_info(); - const int death_test_index = info->result()->death_test_count(); - - if (flag != NULL) { - // ParseInternalRunDeathTestFlag() has performed all the necessary - // processing. - set_write_fd(flag->write_fd()); - return EXECUTE_TEST; - } - - // WindowsDeathTest uses an anonymous pipe to communicate results of - // a death test. - SECURITY_ATTRIBUTES handles_are_inheritable = { - sizeof(SECURITY_ATTRIBUTES), NULL, TRUE }; - HANDLE read_handle, write_handle; - GTEST_DEATH_TEST_CHECK_( - ::CreatePipe(&read_handle, &write_handle, &handles_are_inheritable, - 0) // Default buffer size. - != FALSE); - set_read_fd(::_open_osfhandle(reinterpret_cast(read_handle), - O_RDONLY)); - write_handle_.Reset(write_handle); - event_handle_.Reset(::CreateEvent( - &handles_are_inheritable, - TRUE, // The event will automatically reset to non-signaled state. - FALSE, // The initial state is non-signalled. - NULL)); // The even is unnamed. - GTEST_DEATH_TEST_CHECK_(event_handle_.Get() != NULL); - const std::string filter_flag = - std::string("--") + GTEST_FLAG_PREFIX_ + kFilterFlag + "=" + - info->test_case_name() + "." + info->name(); - const std::string internal_flag = - std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + - "=" + file_ + "|" + StreamableToString(line_) + "|" + - StreamableToString(death_test_index) + "|" + - StreamableToString(static_cast(::GetCurrentProcessId())) + - // size_t has the same width as pointers on both 32-bit and 64-bit - // Windows platforms. - // See http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx. - "|" + StreamableToString(reinterpret_cast(write_handle)) + - "|" + StreamableToString(reinterpret_cast(event_handle_.Get())); - - char executable_path[_MAX_PATH + 1]; // NOLINT - GTEST_DEATH_TEST_CHECK_( - _MAX_PATH + 1 != ::GetModuleFileNameA(NULL, - executable_path, - _MAX_PATH)); - - std::string command_line = - std::string(::GetCommandLineA()) + " " + filter_flag + " \"" + - internal_flag + "\""; - - DeathTest::set_last_death_test_message(""); - - CaptureStderr(); - // Flush the log buffers since the log streams are shared with the child. - FlushInfoLog(); - - // The child process will share the standard handles with the parent. - STARTUPINFOA startup_info; - memset(&startup_info, 0, sizeof(STARTUPINFO)); - startup_info.dwFlags = STARTF_USESTDHANDLES; - startup_info.hStdInput = ::GetStdHandle(STD_INPUT_HANDLE); - startup_info.hStdOutput = ::GetStdHandle(STD_OUTPUT_HANDLE); - startup_info.hStdError = ::GetStdHandle(STD_ERROR_HANDLE); - - PROCESS_INFORMATION process_info; - GTEST_DEATH_TEST_CHECK_(::CreateProcessA( - executable_path, - const_cast(command_line.c_str()), - NULL, // Retuned process handle is not inheritable. - NULL, // Retuned thread handle is not inheritable. - TRUE, // Child inherits all inheritable handles (for write_handle_). - 0x0, // Default creation flags. - NULL, // Inherit the parent's environment. - UnitTest::GetInstance()->original_working_dir(), - &startup_info, - &process_info) != FALSE); - child_handle_.Reset(process_info.hProcess); - ::CloseHandle(process_info.hThread); - set_spawned(true); - return OVERSEE_TEST; -} - -# elif GTEST_OS_FUCHSIA - -class FuchsiaDeathTest : public DeathTestImpl { - public: - FuchsiaDeathTest(const char* a_statement, - const RE* a_regex, - const char* file, - int line) - : DeathTestImpl(a_statement, a_regex), file_(file), line_(line) {} - - // All of these virtual functions are inherited from DeathTest. - virtual int Wait(); - virtual TestRole AssumeRole(); - - private: - // The name of the file in which the death test is located. - const char* const file_; - // The line number on which the death test is located. - const int line_; - - zx_handle_t child_process_; -}; - -// Utility class for accumulating command-line arguments. -class Arguments { - public: - Arguments() { - args_.push_back(NULL); - } - - ~Arguments() { - for (std::vector::iterator i = args_.begin(); i != args_.end(); - ++i) { - free(*i); - } - } - void AddArgument(const char* argument) { - args_.insert(args_.end() - 1, posix::StrDup(argument)); - } - - template - void AddArguments(const ::std::vector& arguments) { - for (typename ::std::vector::const_iterator i = arguments.begin(); - i != arguments.end(); - ++i) { - args_.insert(args_.end() - 1, posix::StrDup(i->c_str())); - } - } - char* const* Argv() { - return &args_[0]; - } - - int size() { - return args_.size() - 1; - } - - private: - std::vector args_; -}; - -// Waits for the child in a death test to exit, returning its exit -// status, or 0 if no child process exists. As a side effect, sets the -// outcome data member. -int FuchsiaDeathTest::Wait() { - if (!spawned()) - return 0; - - // Wait for child process to terminate. - zx_status_t status_zx; - zx_signals_t signals; - status_zx = zx_object_wait_one( - child_process_, - ZX_PROCESS_TERMINATED, - ZX_TIME_INFINITE, - &signals); - GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK); - - ReadAndInterpretStatusByte(); - - zx_info_process_t buffer; - status_zx = zx_object_get_info( - child_process_, - ZX_INFO_PROCESS, - &buffer, - sizeof(buffer), - nullptr, - nullptr); - GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK); - - GTEST_DEATH_TEST_CHECK_(buffer.exited); - set_status(buffer.return_code); - return status(); -} - -// The AssumeRole process for a Fuchsia death test. It creates a child -// process with the same executable as the current process to run the -// death test. The child process is given the --gtest_filter and -// --gtest_internal_run_death_test flags such that it knows to run the -// current death test only. -DeathTest::TestRole FuchsiaDeathTest::AssumeRole() { - const UnitTestImpl* const impl = GetUnitTestImpl(); - const InternalRunDeathTestFlag* const flag = - impl->internal_run_death_test_flag(); - const TestInfo* const info = impl->current_test_info(); - const int death_test_index = info->result()->death_test_count(); - - if (flag != NULL) { - // ParseInternalRunDeathTestFlag() has performed all the necessary - // processing. - set_write_fd(kFuchsiaReadPipeFd); - return EXECUTE_TEST; - } - - CaptureStderr(); - // Flush the log buffers since the log streams are shared with the child. - FlushInfoLog(); - - // Build the child process command line. - const std::string filter_flag = - std::string("--") + GTEST_FLAG_PREFIX_ + kFilterFlag + "=" - + info->test_case_name() + "." + info->name(); - const std::string internal_flag = - std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + "=" - + file_ + "|" - + StreamableToString(line_) + "|" - + StreamableToString(death_test_index); - Arguments args; - args.AddArguments(GetInjectableArgvs()); - args.AddArgument(filter_flag.c_str()); - args.AddArgument(internal_flag.c_str()); - - // Build the pipe for communication with the child. - zx_status_t status; - zx_handle_t child_pipe_handle; - uint32_t type; - status = fdio_pipe_half(&child_pipe_handle, &type); - GTEST_DEATH_TEST_CHECK_(status >= 0); - set_read_fd(status); - - // Set the pipe handle for the child. - fdio_spawn_action_t add_handle_action = { - .action = FDIO_SPAWN_ACTION_ADD_HANDLE, - .h = { - .id = PA_HND(type, kFuchsiaReadPipeFd), - .handle = child_pipe_handle - } - }; - - // Spawn the child process. - status = fdio_spawn_etc(ZX_HANDLE_INVALID, FDIO_SPAWN_CLONE_ALL, - args.Argv()[0], args.Argv(), nullptr, 1, - &add_handle_action, &child_process_, nullptr); - GTEST_DEATH_TEST_CHECK_(status == ZX_OK); - - set_spawned(true); - return OVERSEE_TEST; -} - -#else // We are neither on Windows, nor on Fuchsia. - -// ForkingDeathTest provides implementations for most of the abstract -// methods of the DeathTest interface. Only the AssumeRole method is -// left undefined. -class ForkingDeathTest : public DeathTestImpl { - public: - ForkingDeathTest(const char* statement, const RE* regex); - - // All of these virtual functions are inherited from DeathTest. - virtual int Wait(); - - protected: - void set_child_pid(pid_t child_pid) { child_pid_ = child_pid; } - - private: - // PID of child process during death test; 0 in the child process itself. - pid_t child_pid_; -}; - -// Constructs a ForkingDeathTest. -ForkingDeathTest::ForkingDeathTest(const char* a_statement, const RE* a_regex) - : DeathTestImpl(a_statement, a_regex), - child_pid_(-1) {} - -// Waits for the child in a death test to exit, returning its exit -// status, or 0 if no child process exists. As a side effect, sets the -// outcome data member. -int ForkingDeathTest::Wait() { - if (!spawned()) - return 0; - - ReadAndInterpretStatusByte(); - - int status_value; - GTEST_DEATH_TEST_CHECK_SYSCALL_(waitpid(child_pid_, &status_value, 0)); - set_status(status_value); - return status_value; -} - -// A concrete death test class that forks, then immediately runs the test -// in the child process. -class NoExecDeathTest : public ForkingDeathTest { - public: - NoExecDeathTest(const char* a_statement, const RE* a_regex) : - ForkingDeathTest(a_statement, a_regex) { } - virtual TestRole AssumeRole(); -}; - -// The AssumeRole process for a fork-and-run death test. It implements a -// straightforward fork, with a simple pipe to transmit the status byte. -DeathTest::TestRole NoExecDeathTest::AssumeRole() { - const size_t thread_count = GetThreadCount(); - if (thread_count != 1) { - GTEST_LOG_(WARNING) << DeathTestThreadWarning(thread_count); - } - - int pipe_fd[2]; - GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1); - - DeathTest::set_last_death_test_message(""); - CaptureStderr(); - // When we fork the process below, the log file buffers are copied, but the - // file descriptors are shared. We flush all log files here so that closing - // the file descriptors in the child process doesn't throw off the - // synchronization between descriptors and buffers in the parent process. - // This is as close to the fork as possible to avoid a race condition in case - // there are multiple threads running before the death test, and another - // thread writes to the log file. - FlushInfoLog(); - - const pid_t child_pid = fork(); - GTEST_DEATH_TEST_CHECK_(child_pid != -1); - set_child_pid(child_pid); - if (child_pid == 0) { - GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[0])); - set_write_fd(pipe_fd[1]); - // Redirects all logging to stderr in the child process to prevent - // concurrent writes to the log files. We capture stderr in the parent - // process and append the child process' output to a log. - LogToStderr(); - // Event forwarding to the listeners of event listener API mush be shut - // down in death test subprocesses. - GetUnitTestImpl()->listeners()->SuppressEventForwarding(); - g_in_fast_death_test_child = true; - return EXECUTE_TEST; - } else { - GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1])); - set_read_fd(pipe_fd[0]); - set_spawned(true); - return OVERSEE_TEST; - } -} - -// A concrete death test class that forks and re-executes the main -// program from the beginning, with command-line flags set that cause -// only this specific death test to be run. -class ExecDeathTest : public ForkingDeathTest { - public: - ExecDeathTest(const char* a_statement, const RE* a_regex, - const char* file, int line) : - ForkingDeathTest(a_statement, a_regex), file_(file), line_(line) { } - virtual TestRole AssumeRole(); - private: - static ::std::vector GetArgvsForDeathTestChildProcess() { - ::std::vector args = GetInjectableArgvs(); -# if defined(GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_) - ::std::vector extra_args = - GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_(); - args.insert(args.end(), extra_args.begin(), extra_args.end()); -# endif // defined(GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_) - return args; - } - // The name of the file in which the death test is located. - const char* const file_; - // The line number on which the death test is located. - const int line_; -}; - -// Utility class for accumulating command-line arguments. -class Arguments { - public: - Arguments() { - args_.push_back(NULL); - } - - ~Arguments() { - for (std::vector::iterator i = args_.begin(); i != args_.end(); - ++i) { - free(*i); - } - } - void AddArgument(const char* argument) { - args_.insert(args_.end() - 1, posix::StrDup(argument)); - } - - template - void AddArguments(const ::std::vector& arguments) { - for (typename ::std::vector::const_iterator i = arguments.begin(); - i != arguments.end(); - ++i) { - args_.insert(args_.end() - 1, posix::StrDup(i->c_str())); - } - } - char* const* Argv() { - return &args_[0]; - } - - private: - std::vector args_; -}; - -// A struct that encompasses the arguments to the child process of a -// threadsafe-style death test process. -struct ExecDeathTestArgs { - char* const* argv; // Command-line arguments for the child's call to exec - int close_fd; // File descriptor to close; the read end of a pipe -}; - -# if GTEST_OS_MAC -inline char** GetEnviron() { - // When Google Test is built as a framework on MacOS X, the environ variable - // is unavailable. Apple's documentation (man environ) recommends using - // _NSGetEnviron() instead. - return *_NSGetEnviron(); -} -# else -// Some POSIX platforms expect you to declare environ. extern "C" makes -// it reside in the global namespace. -extern "C" char** environ; -inline char** GetEnviron() { return environ; } -# endif // GTEST_OS_MAC - -# if !GTEST_OS_QNX -// The main function for a threadsafe-style death test child process. -// This function is called in a clone()-ed process and thus must avoid -// any potentially unsafe operations like malloc or libc functions. -static int ExecDeathTestChildMain(void* child_arg) { - ExecDeathTestArgs* const args = static_cast(child_arg); - GTEST_DEATH_TEST_CHECK_SYSCALL_(close(args->close_fd)); - - // We need to execute the test program in the same environment where - // it was originally invoked. Therefore we change to the original - // working directory first. - const char* const original_dir = - UnitTest::GetInstance()->original_working_dir(); - // We can safely call chdir() as it's a direct system call. - if (chdir(original_dir) != 0) { - DeathTestAbort(std::string("chdir(\"") + original_dir + "\") failed: " + - GetLastErrnoDescription()); - return EXIT_FAILURE; - } - - // We can safely call execve() as it's a direct system call. We - // cannot use execvp() as it's a libc function and thus potentially - // unsafe. Since execve() doesn't search the PATH, the user must - // invoke the test program via a valid path that contains at least - // one path separator. - execve(args->argv[0], args->argv, GetEnviron()); - DeathTestAbort(std::string("execve(") + args->argv[0] + ", ...) in " + - original_dir + " failed: " + - GetLastErrnoDescription()); - return EXIT_FAILURE; -} -# endif // !GTEST_OS_QNX - -# if GTEST_HAS_CLONE -// Two utility routines that together determine the direction the stack -// grows. -// This could be accomplished more elegantly by a single recursive -// function, but we want to guard against the unlikely possibility of -// a smart compiler optimizing the recursion away. -// -// GTEST_NO_INLINE_ is required to prevent GCC 4.6 from inlining -// StackLowerThanAddress into StackGrowsDown, which then doesn't give -// correct answer. -static void StackLowerThanAddress(const void* ptr, - bool* result) GTEST_NO_INLINE_; -static void StackLowerThanAddress(const void* ptr, bool* result) { - int dummy; - *result = (&dummy < ptr); -} - -// Make sure AddressSanitizer does not tamper with the stack here. -GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ -static bool StackGrowsDown() { - int dummy; - bool result; - StackLowerThanAddress(&dummy, &result); - return result; -} -# endif // GTEST_HAS_CLONE - -// Spawns a child process with the same executable as the current process in -// a thread-safe manner and instructs it to run the death test. The -// implementation uses fork(2) + exec. On systems where clone(2) is -// available, it is used instead, being slightly more thread-safe. On QNX, -// fork supports only single-threaded environments, so this function uses -// spawn(2) there instead. The function dies with an error message if -// anything goes wrong. -static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) { - ExecDeathTestArgs args = { argv, close_fd }; - pid_t child_pid = -1; - -# if GTEST_OS_QNX - // Obtains the current directory and sets it to be closed in the child - // process. - const int cwd_fd = open(".", O_RDONLY); - GTEST_DEATH_TEST_CHECK_(cwd_fd != -1); - GTEST_DEATH_TEST_CHECK_SYSCALL_(fcntl(cwd_fd, F_SETFD, FD_CLOEXEC)); - // We need to execute the test program in the same environment where - // it was originally invoked. Therefore we change to the original - // working directory first. - const char* const original_dir = - UnitTest::GetInstance()->original_working_dir(); - // We can safely call chdir() as it's a direct system call. - if (chdir(original_dir) != 0) { - DeathTestAbort(std::string("chdir(\"") + original_dir + "\") failed: " + - GetLastErrnoDescription()); - return EXIT_FAILURE; - } - - int fd_flags; - // Set close_fd to be closed after spawn. - GTEST_DEATH_TEST_CHECK_SYSCALL_(fd_flags = fcntl(close_fd, F_GETFD)); - GTEST_DEATH_TEST_CHECK_SYSCALL_(fcntl(close_fd, F_SETFD, - fd_flags | FD_CLOEXEC)); - struct inheritance inherit = {0}; - // spawn is a system call. - child_pid = spawn(args.argv[0], 0, NULL, &inherit, args.argv, GetEnviron()); - // Restores the current working directory. - GTEST_DEATH_TEST_CHECK_(fchdir(cwd_fd) != -1); - GTEST_DEATH_TEST_CHECK_SYSCALL_(close(cwd_fd)); - -# else // GTEST_OS_QNX -# if GTEST_OS_LINUX - // When a SIGPROF signal is received while fork() or clone() are executing, - // the process may hang. To avoid this, we ignore SIGPROF here and re-enable - // it after the call to fork()/clone() is complete. - struct sigaction saved_sigprof_action; - struct sigaction ignore_sigprof_action; - memset(&ignore_sigprof_action, 0, sizeof(ignore_sigprof_action)); - sigemptyset(&ignore_sigprof_action.sa_mask); - ignore_sigprof_action.sa_handler = SIG_IGN; - GTEST_DEATH_TEST_CHECK_SYSCALL_(sigaction( - SIGPROF, &ignore_sigprof_action, &saved_sigprof_action)); -# endif // GTEST_OS_LINUX - -# if GTEST_HAS_CLONE - const bool use_fork = GTEST_FLAG(death_test_use_fork); - - if (!use_fork) { - static const bool stack_grows_down = StackGrowsDown(); - const size_t stack_size = getpagesize(); - // MMAP_ANONYMOUS is not defined on Mac, so we use MAP_ANON instead. - void* const stack = mmap(NULL, stack_size, PROT_READ | PROT_WRITE, - MAP_ANON | MAP_PRIVATE, -1, 0); - GTEST_DEATH_TEST_CHECK_(stack != MAP_FAILED); - - // Maximum stack alignment in bytes: For a downward-growing stack, this - // amount is subtracted from size of the stack space to get an address - // that is within the stack space and is aligned on all systems we care - // about. As far as I know there is no ABI with stack alignment greater - // than 64. We assume stack and stack_size already have alignment of - // kMaxStackAlignment. - const size_t kMaxStackAlignment = 64; - void* const stack_top = - static_cast(stack) + - (stack_grows_down ? stack_size - kMaxStackAlignment : 0); - GTEST_DEATH_TEST_CHECK_(stack_size > kMaxStackAlignment && - reinterpret_cast(stack_top) % kMaxStackAlignment == 0); - - child_pid = clone(&ExecDeathTestChildMain, stack_top, SIGCHLD, &args); - - GTEST_DEATH_TEST_CHECK_(munmap(stack, stack_size) != -1); - } -# else - const bool use_fork = true; -# endif // GTEST_HAS_CLONE - - if (use_fork && (child_pid = fork()) == 0) { - ExecDeathTestChildMain(&args); - _exit(0); - } -# endif // GTEST_OS_QNX -# if GTEST_OS_LINUX - GTEST_DEATH_TEST_CHECK_SYSCALL_( - sigaction(SIGPROF, &saved_sigprof_action, NULL)); -# endif // GTEST_OS_LINUX - - GTEST_DEATH_TEST_CHECK_(child_pid != -1); - return child_pid; -} - -// The AssumeRole process for a fork-and-exec death test. It re-executes the -// main program from the beginning, setting the --gtest_filter -// and --gtest_internal_run_death_test flags to cause only the current -// death test to be re-run. -DeathTest::TestRole ExecDeathTest::AssumeRole() { - const UnitTestImpl* const impl = GetUnitTestImpl(); - const InternalRunDeathTestFlag* const flag = - impl->internal_run_death_test_flag(); - const TestInfo* const info = impl->current_test_info(); - const int death_test_index = info->result()->death_test_count(); - - if (flag != NULL) { - set_write_fd(flag->write_fd()); - return EXECUTE_TEST; - } - - int pipe_fd[2]; - GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1); - // Clear the close-on-exec flag on the write end of the pipe, lest - // it be closed when the child process does an exec: - GTEST_DEATH_TEST_CHECK_(fcntl(pipe_fd[1], F_SETFD, 0) != -1); - - const std::string filter_flag = - std::string("--") + GTEST_FLAG_PREFIX_ + kFilterFlag + "=" - + info->test_case_name() + "." + info->name(); - const std::string internal_flag = - std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + "=" - + file_ + "|" + StreamableToString(line_) + "|" - + StreamableToString(death_test_index) + "|" - + StreamableToString(pipe_fd[1]); - Arguments args; - args.AddArguments(GetArgvsForDeathTestChildProcess()); - args.AddArgument(filter_flag.c_str()); - args.AddArgument(internal_flag.c_str()); - - DeathTest::set_last_death_test_message(""); - - CaptureStderr(); - // See the comment in NoExecDeathTest::AssumeRole for why the next line - // is necessary. - FlushInfoLog(); - - const pid_t child_pid = ExecDeathTestSpawnChild(args.Argv(), pipe_fd[0]); - GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1])); - set_child_pid(child_pid); - set_read_fd(pipe_fd[0]); - set_spawned(true); - return OVERSEE_TEST; -} - -# endif // !GTEST_OS_WINDOWS - -// Creates a concrete DeathTest-derived class that depends on the -// --gtest_death_test_style flag, and sets the pointer pointed to -// by the "test" argument to its address. If the test should be -// skipped, sets that pointer to NULL. Returns true, unless the -// flag is set to an invalid value. -bool DefaultDeathTestFactory::Create(const char* statement, const RE* regex, - const char* file, int line, - DeathTest** test) { - UnitTestImpl* const impl = GetUnitTestImpl(); - const InternalRunDeathTestFlag* const flag = - impl->internal_run_death_test_flag(); - const int death_test_index = impl->current_test_info() - ->increment_death_test_count(); - - if (flag != NULL) { - if (death_test_index > flag->index()) { - DeathTest::set_last_death_test_message( - "Death test count (" + StreamableToString(death_test_index) - + ") somehow exceeded expected maximum (" - + StreamableToString(flag->index()) + ")"); - return false; - } - - if (!(flag->file() == file && flag->line() == line && - flag->index() == death_test_index)) { - *test = NULL; - return true; - } - } - -# if GTEST_OS_WINDOWS - - if (GTEST_FLAG(death_test_style) == "threadsafe" || - GTEST_FLAG(death_test_style) == "fast") { - *test = new WindowsDeathTest(statement, regex, file, line); - } - -# elif GTEST_OS_FUCHSIA - - if (GTEST_FLAG(death_test_style) == "threadsafe" || - GTEST_FLAG(death_test_style) == "fast") { - *test = new FuchsiaDeathTest(statement, regex, file, line); - } - -# else - - if (GTEST_FLAG(death_test_style) == "threadsafe") { - *test = new ExecDeathTest(statement, regex, file, line); - } else if (GTEST_FLAG(death_test_style) == "fast") { - *test = new NoExecDeathTest(statement, regex); - } - -# endif // GTEST_OS_WINDOWS - - else { // NOLINT - this is more readable than unbalanced brackets inside #if. - DeathTest::set_last_death_test_message( - "Unknown death test style \"" + GTEST_FLAG(death_test_style) - + "\" encountered"); - return false; - } - - return true; -} - -# if GTEST_OS_WINDOWS -// Recreates the pipe and event handles from the provided parameters, -// signals the event, and returns a file descriptor wrapped around the pipe -// handle. This function is called in the child process only. -static int GetStatusFileDescriptor(unsigned int parent_process_id, - size_t write_handle_as_size_t, - size_t event_handle_as_size_t) { - AutoHandle parent_process_handle(::OpenProcess(PROCESS_DUP_HANDLE, - FALSE, // Non-inheritable. - parent_process_id)); - if (parent_process_handle.Get() == INVALID_HANDLE_VALUE) { - DeathTestAbort("Unable to open parent process " + - StreamableToString(parent_process_id)); - } - - // TODO(vladl@google.com): Replace the following check with a - // compile-time assertion when available. - GTEST_CHECK_(sizeof(HANDLE) <= sizeof(size_t)); - - const HANDLE write_handle = - reinterpret_cast(write_handle_as_size_t); - HANDLE dup_write_handle; - - // The newly initialized handle is accessible only in the parent - // process. To obtain one accessible within the child, we need to use - // DuplicateHandle. - if (!::DuplicateHandle(parent_process_handle.Get(), write_handle, - ::GetCurrentProcess(), &dup_write_handle, - 0x0, // Requested privileges ignored since - // DUPLICATE_SAME_ACCESS is used. - FALSE, // Request non-inheritable handler. - DUPLICATE_SAME_ACCESS)) { - DeathTestAbort("Unable to duplicate the pipe handle " + - StreamableToString(write_handle_as_size_t) + - " from the parent process " + - StreamableToString(parent_process_id)); - } - - const HANDLE event_handle = reinterpret_cast(event_handle_as_size_t); - HANDLE dup_event_handle; - - if (!::DuplicateHandle(parent_process_handle.Get(), event_handle, - ::GetCurrentProcess(), &dup_event_handle, - 0x0, - FALSE, - DUPLICATE_SAME_ACCESS)) { - DeathTestAbort("Unable to duplicate the event handle " + - StreamableToString(event_handle_as_size_t) + - " from the parent process " + - StreamableToString(parent_process_id)); - } - - const int write_fd = - ::_open_osfhandle(reinterpret_cast(dup_write_handle), O_APPEND); - if (write_fd == -1) { - DeathTestAbort("Unable to convert pipe handle " + - StreamableToString(write_handle_as_size_t) + - " to a file descriptor"); - } - - // Signals the parent that the write end of the pipe has been acquired - // so the parent can release its own write end. - ::SetEvent(dup_event_handle); - - return write_fd; -} -# endif // GTEST_OS_WINDOWS - -// Returns a newly created InternalRunDeathTestFlag object with fields -// initialized from the GTEST_FLAG(internal_run_death_test) flag if -// the flag is specified; otherwise returns NULL. -InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() { - if (GTEST_FLAG(internal_run_death_test) == "") return NULL; - - // GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we - // can use it here. - int line = -1; - int index = -1; - ::std::vector< ::std::string> fields; - SplitString(GTEST_FLAG(internal_run_death_test).c_str(), '|', &fields); - int write_fd = -1; - -# if GTEST_OS_WINDOWS - - unsigned int parent_process_id = 0; - size_t write_handle_as_size_t = 0; - size_t event_handle_as_size_t = 0; - - if (fields.size() != 6 - || !ParseNaturalNumber(fields[1], &line) - || !ParseNaturalNumber(fields[2], &index) - || !ParseNaturalNumber(fields[3], &parent_process_id) - || !ParseNaturalNumber(fields[4], &write_handle_as_size_t) - || !ParseNaturalNumber(fields[5], &event_handle_as_size_t)) { - DeathTestAbort("Bad --gtest_internal_run_death_test flag: " + - GTEST_FLAG(internal_run_death_test)); - } - write_fd = GetStatusFileDescriptor(parent_process_id, - write_handle_as_size_t, - event_handle_as_size_t); - -# elif GTEST_OS_FUCHSIA - - if (fields.size() != 3 - || !ParseNaturalNumber(fields[1], &line) - || !ParseNaturalNumber(fields[2], &index)) { - DeathTestAbort("Bad --gtest_internal_run_death_test flag: " - + GTEST_FLAG(internal_run_death_test)); - } - -# else - - if (fields.size() != 4 - || !ParseNaturalNumber(fields[1], &line) - || !ParseNaturalNumber(fields[2], &index) - || !ParseNaturalNumber(fields[3], &write_fd)) { - DeathTestAbort("Bad --gtest_internal_run_death_test flag: " - + GTEST_FLAG(internal_run_death_test)); - } - -# endif // GTEST_OS_WINDOWS - - return new InternalRunDeathTestFlag(fields[0], line, index, write_fd); -} - -} // namespace internal - -#endif // GTEST_HAS_DEATH_TEST - -} // namespace testing -// Copyright 2008, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -#include - -#if GTEST_OS_WINDOWS_MOBILE -# include -#elif GTEST_OS_WINDOWS -# include -# include -#elif GTEST_OS_SYMBIAN -// Symbian OpenC has PATH_MAX in sys/syslimits.h -# include -#else -# include -# include // Some Linux distributions define PATH_MAX here. -#endif // GTEST_OS_WINDOWS_MOBILE - - -#if GTEST_OS_WINDOWS -# define GTEST_PATH_MAX_ _MAX_PATH -#elif defined(PATH_MAX) -# define GTEST_PATH_MAX_ PATH_MAX -#elif defined(_XOPEN_PATH_MAX) -# define GTEST_PATH_MAX_ _XOPEN_PATH_MAX -#else -# define GTEST_PATH_MAX_ _POSIX_PATH_MAX -#endif // GTEST_OS_WINDOWS - -namespace testing { -namespace internal { - -#if GTEST_OS_WINDOWS -// On Windows, '\\' is the standard path separator, but many tools and the -// Windows API also accept '/' as an alternate path separator. Unless otherwise -// noted, a file path can contain either kind of path separators, or a mixture -// of them. -const char kPathSeparator = '\\'; -const char kAlternatePathSeparator = '/'; -const char kAlternatePathSeparatorString[] = "/"; -# if GTEST_OS_WINDOWS_MOBILE -// Windows CE doesn't have a current directory. You should not use -// the current directory in tests on Windows CE, but this at least -// provides a reasonable fallback. -const char kCurrentDirectoryString[] = "\\"; -// Windows CE doesn't define INVALID_FILE_ATTRIBUTES -const DWORD kInvalidFileAttributes = 0xffffffff; -# else -const char kCurrentDirectoryString[] = ".\\"; -# endif // GTEST_OS_WINDOWS_MOBILE -#else -const char kPathSeparator = '/'; -const char kCurrentDirectoryString[] = "./"; -#endif // GTEST_OS_WINDOWS - -// Returns whether the given character is a valid path separator. -static bool IsPathSeparator(char c) { -#if GTEST_HAS_ALT_PATH_SEP_ - return (c == kPathSeparator) || (c == kAlternatePathSeparator); -#else - return c == kPathSeparator; -#endif -} - -// Returns the current working directory, or "" if unsuccessful. -FilePath FilePath::GetCurrentDir() { -#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT - // Windows CE doesn't have a current directory, so we just return - // something reasonable. - return FilePath(kCurrentDirectoryString); -#elif GTEST_OS_WINDOWS - char cwd[GTEST_PATH_MAX_ + 1] = { '\0' }; - return FilePath(_getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd); -#else - char cwd[GTEST_PATH_MAX_ + 1] = { '\0' }; - char* result = getcwd(cwd, sizeof(cwd)); -# if GTEST_OS_NACL - // getcwd will likely fail in NaCl due to the sandbox, so return something - // reasonable. The user may have provided a shim implementation for getcwd, - // however, so fallback only when failure is detected. - return FilePath(result == NULL ? kCurrentDirectoryString : cwd); -# endif // GTEST_OS_NACL - return FilePath(result == NULL ? "" : cwd); -#endif // GTEST_OS_WINDOWS_MOBILE -} - -// Returns a copy of the FilePath with the case-insensitive extension removed. -// Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns -// FilePath("dir/file"). If a case-insensitive extension is not -// found, returns a copy of the original FilePath. -FilePath FilePath::RemoveExtension(const char* extension) const { - const std::string dot_extension = std::string(".") + extension; - if (String::EndsWithCaseInsensitive(pathname_, dot_extension)) { - return FilePath(pathname_.substr( - 0, pathname_.length() - dot_extension.length())); - } - return *this; -} - -// Returns a pointer to the last occurrence of a valid path separator in -// the FilePath. On Windows, for example, both '/' and '\' are valid path -// separators. Returns NULL if no path separator was found. -const char* FilePath::FindLastPathSeparator() const { - const char* const last_sep = strrchr(c_str(), kPathSeparator); -#if GTEST_HAS_ALT_PATH_SEP_ - const char* const last_alt_sep = strrchr(c_str(), kAlternatePathSeparator); - // Comparing two pointers of which only one is NULL is undefined. - if (last_alt_sep != NULL && - (last_sep == NULL || last_alt_sep > last_sep)) { - return last_alt_sep; - } -#endif - return last_sep; -} - -// Returns a copy of the FilePath with the directory part removed. -// Example: FilePath("path/to/file").RemoveDirectoryName() returns -// FilePath("file"). If there is no directory part ("just_a_file"), it returns -// the FilePath unmodified. If there is no file part ("just_a_dir/") it -// returns an empty FilePath (""). -// On Windows platform, '\' is the path separator, otherwise it is '/'. -FilePath FilePath::RemoveDirectoryName() const { - const char* const last_sep = FindLastPathSeparator(); - return last_sep ? FilePath(last_sep + 1) : *this; -} - -// RemoveFileName returns the directory path with the filename removed. -// Example: FilePath("path/to/file").RemoveFileName() returns "path/to/". -// If the FilePath is "a_file" or "/a_file", RemoveFileName returns -// FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does -// not have a file, like "just/a/dir/", it returns the FilePath unmodified. -// On Windows platform, '\' is the path separator, otherwise it is '/'. -FilePath FilePath::RemoveFileName() const { - const char* const last_sep = FindLastPathSeparator(); - std::string dir; - if (last_sep) { - dir = std::string(c_str(), last_sep + 1 - c_str()); - } else { - dir = kCurrentDirectoryString; - } - return FilePath(dir); -} - -// Helper functions for naming files in a directory for xml output. - -// Given directory = "dir", base_name = "test", number = 0, -// extension = "xml", returns "dir/test.xml". If number is greater -// than zero (e.g., 12), returns "dir/test_12.xml". -// On Windows platform, uses \ as the separator rather than /. -FilePath FilePath::MakeFileName(const FilePath& directory, - const FilePath& base_name, - int number, - const char* extension) { - std::string file; - if (number == 0) { - file = base_name.string() + "." + extension; - } else { - file = base_name.string() + "_" + StreamableToString(number) - + "." + extension; - } - return ConcatPaths(directory, FilePath(file)); -} - -// Given directory = "dir", relative_path = "test.xml", returns "dir/test.xml". -// On Windows, uses \ as the separator rather than /. -FilePath FilePath::ConcatPaths(const FilePath& directory, - const FilePath& relative_path) { - if (directory.IsEmpty()) - return relative_path; - const FilePath dir(directory.RemoveTrailingPathSeparator()); - return FilePath(dir.string() + kPathSeparator + relative_path.string()); -} - -// Returns true if pathname describes something findable in the file-system, -// either a file, directory, or whatever. -bool FilePath::FileOrDirectoryExists() const { -#if GTEST_OS_WINDOWS_MOBILE - LPCWSTR unicode = String::AnsiToUtf16(pathname_.c_str()); - const DWORD attributes = GetFileAttributes(unicode); - delete [] unicode; - return attributes != kInvalidFileAttributes; -#else - posix::StatStruct file_stat; - return posix::Stat(pathname_.c_str(), &file_stat) == 0; -#endif // GTEST_OS_WINDOWS_MOBILE -} - -// Returns true if pathname describes a directory in the file-system -// that exists. -bool FilePath::DirectoryExists() const { - bool result = false; -#if GTEST_OS_WINDOWS - // Don't strip off trailing separator if path is a root directory on - // Windows (like "C:\\"). - const FilePath& path(IsRootDirectory() ? *this : - RemoveTrailingPathSeparator()); -#else - const FilePath& path(*this); -#endif - -#if GTEST_OS_WINDOWS_MOBILE - LPCWSTR unicode = String::AnsiToUtf16(path.c_str()); - const DWORD attributes = GetFileAttributes(unicode); - delete [] unicode; - if ((attributes != kInvalidFileAttributes) && - (attributes & FILE_ATTRIBUTE_DIRECTORY)) { - result = true; - } -#else - posix::StatStruct file_stat; - result = posix::Stat(path.c_str(), &file_stat) == 0 && - posix::IsDir(file_stat); -#endif // GTEST_OS_WINDOWS_MOBILE - - return result; -} - -// Returns true if pathname describes a root directory. (Windows has one -// root directory per disk drive.) -bool FilePath::IsRootDirectory() const { -#if GTEST_OS_WINDOWS - // TODO(wan@google.com): on Windows a network share like - // \\server\share can be a root directory, although it cannot be the - // current directory. Handle this properly. - return pathname_.length() == 3 && IsAbsolutePath(); -#else - return pathname_.length() == 1 && IsPathSeparator(pathname_.c_str()[0]); -#endif -} - -// Returns true if pathname describes an absolute path. -bool FilePath::IsAbsolutePath() const { - const char* const name = pathname_.c_str(); -#if GTEST_OS_WINDOWS - return pathname_.length() >= 3 && - ((name[0] >= 'a' && name[0] <= 'z') || - (name[0] >= 'A' && name[0] <= 'Z')) && - name[1] == ':' && - IsPathSeparator(name[2]); -#else - return IsPathSeparator(name[0]); -#endif -} - -// Returns a pathname for a file that does not currently exist. The pathname -// will be directory/base_name.extension or -// directory/base_name_.extension if directory/base_name.extension -// already exists. The number will be incremented until a pathname is found -// that does not already exist. -// Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'. -// There could be a race condition if two or more processes are calling this -// function at the same time -- they could both pick the same filename. -FilePath FilePath::GenerateUniqueFileName(const FilePath& directory, - const FilePath& base_name, - const char* extension) { - FilePath full_pathname; - int number = 0; - do { - full_pathname.Set(MakeFileName(directory, base_name, number++, extension)); - } while (full_pathname.FileOrDirectoryExists()); - return full_pathname; -} - -// Returns true if FilePath ends with a path separator, which indicates that -// it is intended to represent a directory. Returns false otherwise. -// This does NOT check that a directory (or file) actually exists. -bool FilePath::IsDirectory() const { - return !pathname_.empty() && - IsPathSeparator(pathname_.c_str()[pathname_.length() - 1]); -} - -// Create directories so that path exists. Returns true if successful or if -// the directories already exist; returns false if unable to create directories -// for any reason. -bool FilePath::CreateDirectoriesRecursively() const { - if (!this->IsDirectory()) { - return false; - } - - if (pathname_.length() == 0 || this->DirectoryExists()) { - return true; - } - - const FilePath parent(this->RemoveTrailingPathSeparator().RemoveFileName()); - return parent.CreateDirectoriesRecursively() && this->CreateFolder(); -} - -// Create the directory so that path exists. Returns true if successful or -// if the directory already exists; returns false if unable to create the -// directory for any reason, including if the parent directory does not -// exist. Not named "CreateDirectory" because that's a macro on Windows. -bool FilePath::CreateFolder() const { -#if GTEST_OS_WINDOWS_MOBILE - FilePath removed_sep(this->RemoveTrailingPathSeparator()); - LPCWSTR unicode = String::AnsiToUtf16(removed_sep.c_str()); - int result = CreateDirectory(unicode, NULL) ? 0 : -1; - delete [] unicode; -#elif GTEST_OS_WINDOWS - int result = _mkdir(pathname_.c_str()); -#else - int result = mkdir(pathname_.c_str(), 0777); -#endif // GTEST_OS_WINDOWS_MOBILE - - if (result == -1) { - return this->DirectoryExists(); // An error is OK if the directory exists. - } - return true; // No error. -} - -// If input name has a trailing separator character, remove it and return the -// name, otherwise return the name string unmodified. -// On Windows platform, uses \ as the separator, other platforms use /. -FilePath FilePath::RemoveTrailingPathSeparator() const { - return IsDirectory() - ? FilePath(pathname_.substr(0, pathname_.length() - 1)) - : *this; -} - -// Removes any redundant separators that might be in the pathname. -// For example, "bar///foo" becomes "bar/foo". Does not eliminate other -// redundancies that might be in a pathname involving "." or "..". -// TODO(wan@google.com): handle Windows network shares (e.g. \\server\share). -void FilePath::Normalize() { - if (pathname_.c_str() == NULL) { - pathname_ = ""; - return; - } - const char* src = pathname_.c_str(); - char* const dest = new char[pathname_.length() + 1]; - char* dest_ptr = dest; - memset(dest_ptr, 0, pathname_.length() + 1); - - while (*src != '\0') { - *dest_ptr = *src; - if (!IsPathSeparator(*src)) { - src++; - } else { -#if GTEST_HAS_ALT_PATH_SEP_ - if (*dest_ptr == kAlternatePathSeparator) { - *dest_ptr = kPathSeparator; - } -#endif - while (IsPathSeparator(*src)) - src++; - } - dest_ptr++; - } - *dest_ptr = '\0'; - pathname_ = dest; - delete[] dest; -} - -} // namespace internal -} // namespace testing -// Copyright 2008, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) - - -#include -#include -#include -#include -#include - -#if GTEST_OS_WINDOWS -# include -# include -# include -# include // Used in ThreadLocal. -#else -# include -#endif // GTEST_OS_WINDOWS - -#if GTEST_OS_MAC -# include -# include -# include -#endif // GTEST_OS_MAC - -#if GTEST_OS_QNX -# include -# include -# include -#endif // GTEST_OS_QNX - -#if GTEST_OS_AIX -# include -# include -#endif // GTEST_OS_AIX - -#if GTEST_OS_FUCHSIA -# include -# include -#endif // GTEST_OS_FUCHSIA - - -namespace testing { -namespace internal { - -#if defined(_MSC_VER) || defined(__BORLANDC__) -// MSVC and C++Builder do not provide a definition of STDERR_FILENO. -const int kStdOutFileno = 1; -const int kStdErrFileno = 2; -#else -const int kStdOutFileno = STDOUT_FILENO; -const int kStdErrFileno = STDERR_FILENO; -#endif // _MSC_VER - -#if GTEST_OS_LINUX - -namespace { -template -T ReadProcFileField(const std::string& filename, int field) { - std::string dummy; - std::ifstream file(filename.c_str()); - while (field-- > 0) { - file >> dummy; - } - T output = 0; - file >> output; - return output; -} -} // namespace - -// Returns the number of active threads, or 0 when there is an error. -size_t GetThreadCount() { - const std::string filename = - (Message() << "/proc/" << getpid() << "/stat").GetString(); - return ReadProcFileField(filename, 19); -} - -#elif GTEST_OS_MAC - -size_t GetThreadCount() { - const task_t task = mach_task_self(); - mach_msg_type_number_t thread_count; - thread_act_array_t thread_list; - const kern_return_t status = task_threads(task, &thread_list, &thread_count); - if (status == KERN_SUCCESS) { - // task_threads allocates resources in thread_list and we need to free them - // to avoid leaks. - vm_deallocate(task, - reinterpret_cast(thread_list), - sizeof(thread_t) * thread_count); - return static_cast(thread_count); - } else { - return 0; - } -} - -#elif GTEST_OS_QNX - -// Returns the number of threads running in the process, or 0 to indicate that -// we cannot detect it. -size_t GetThreadCount() { - const int fd = open("/proc/self/as", O_RDONLY); - if (fd < 0) { - return 0; - } - procfs_info process_info; - const int status = - devctl(fd, DCMD_PROC_INFO, &process_info, sizeof(process_info), NULL); - close(fd); - if (status == EOK) { - return static_cast(process_info.num_threads); - } else { - return 0; - } -} - -#elif GTEST_OS_AIX - -size_t GetThreadCount() { - struct procentry64 entry; - pid_t pid = getpid(); - int status = getprocs64(&entry, sizeof(entry), NULL, 0, &pid, 1); - if (status == 1) { - return entry.pi_thcount; - } else { - return 0; - } -} - -#elif GTEST_OS_FUCHSIA - -size_t GetThreadCount() { - int dummy_buffer; - size_t avail; - zx_status_t status = zx_object_get_info( - zx_process_self(), - ZX_INFO_PROCESS_THREADS, - &dummy_buffer, - 0, - nullptr, - &avail); - if (status == ZX_OK) { - return avail; - } else { - return 0; - } -} - -#else - -size_t GetThreadCount() { - // There's no portable way to detect the number of threads, so we just - // return 0 to indicate that we cannot detect it. - return 0; -} - -#endif // GTEST_OS_LINUX - -#if GTEST_IS_THREADSAFE && GTEST_OS_WINDOWS - -void SleepMilliseconds(int n) { - ::Sleep(n); -} - -AutoHandle::AutoHandle() - : handle_(INVALID_HANDLE_VALUE) {} - -AutoHandle::AutoHandle(Handle handle) - : handle_(handle) {} - -AutoHandle::~AutoHandle() { - Reset(); -} - -AutoHandle::Handle AutoHandle::Get() const { - return handle_; -} - -void AutoHandle::Reset() { - Reset(INVALID_HANDLE_VALUE); -} - -void AutoHandle::Reset(HANDLE handle) { - // Resetting with the same handle we already own is invalid. - if (handle_ != handle) { - if (IsCloseable()) { - ::CloseHandle(handle_); - } - handle_ = handle; - } else { - GTEST_CHECK_(!IsCloseable()) - << "Resetting a valid handle to itself is likely a programmer error " - "and thus not allowed."; - } -} - -bool AutoHandle::IsCloseable() const { - // Different Windows APIs may use either of these values to represent an - // invalid handle. - return handle_ != NULL && handle_ != INVALID_HANDLE_VALUE; -} - -Notification::Notification() - : event_(::CreateEvent(NULL, // Default security attributes. - TRUE, // Do not reset automatically. - FALSE, // Initially unset. - NULL)) { // Anonymous event. - GTEST_CHECK_(event_.Get() != NULL); -} - -void Notification::Notify() { - GTEST_CHECK_(::SetEvent(event_.Get()) != FALSE); -} - -void Notification::WaitForNotification() { - GTEST_CHECK_( - ::WaitForSingleObject(event_.Get(), INFINITE) == WAIT_OBJECT_0); -} - -Mutex::Mutex() - : owner_thread_id_(0), - type_(kDynamic), - critical_section_init_phase_(0), - critical_section_(new CRITICAL_SECTION) { - ::InitializeCriticalSection(critical_section_); -} - -Mutex::~Mutex() { - // Static mutexes are leaked intentionally. It is not thread-safe to try - // to clean them up. - // TODO(yukawa): Switch to Slim Reader/Writer (SRW) Locks, which requires - // nothing to clean it up but is available only on Vista and later. - // http://msdn.microsoft.com/en-us/library/windows/desktop/aa904937.aspx - if (type_ == kDynamic) { - ::DeleteCriticalSection(critical_section_); - delete critical_section_; - critical_section_ = NULL; - } -} - -void Mutex::Lock() { - ThreadSafeLazyInit(); - ::EnterCriticalSection(critical_section_); - owner_thread_id_ = ::GetCurrentThreadId(); -} - -void Mutex::Unlock() { - ThreadSafeLazyInit(); - // We don't protect writing to owner_thread_id_ here, as it's the - // caller's responsibility to ensure that the current thread holds the - // mutex when this is called. - owner_thread_id_ = 0; - ::LeaveCriticalSection(critical_section_); -} - -// Does nothing if the current thread holds the mutex. Otherwise, crashes -// with high probability. -void Mutex::AssertHeld() { - ThreadSafeLazyInit(); - GTEST_CHECK_(owner_thread_id_ == ::GetCurrentThreadId()) - << "The current thread is not holding the mutex @" << this; -} - -// Initializes owner_thread_id_ and critical_section_ in static mutexes. -void Mutex::ThreadSafeLazyInit() { - // Dynamic mutexes are initialized in the constructor. - if (type_ == kStatic) { - switch ( - ::InterlockedCompareExchange(&critical_section_init_phase_, 1L, 0L)) { - case 0: - // If critical_section_init_phase_ was 0 before the exchange, we - // are the first to test it and need to perform the initialization. - owner_thread_id_ = 0; - critical_section_ = new CRITICAL_SECTION; - ::InitializeCriticalSection(critical_section_); - // Updates the critical_section_init_phase_ to 2 to signal - // initialization complete. - GTEST_CHECK_(::InterlockedCompareExchange( - &critical_section_init_phase_, 2L, 1L) == - 1L); - break; - case 1: - // Somebody else is already initializing the mutex; spin until they - // are done. - while (::InterlockedCompareExchange(&critical_section_init_phase_, - 2L, - 2L) != 2L) { - // Possibly yields the rest of the thread's time slice to other - // threads. - ::Sleep(0); - } - break; - - case 2: - break; // The mutex is already initialized and ready for use. - - default: - GTEST_CHECK_(false) - << "Unexpected value of critical_section_init_phase_ " - << "while initializing a static mutex."; - } - } -} - -namespace { - -class ThreadWithParamSupport : public ThreadWithParamBase { - public: - static HANDLE CreateThread(Runnable* runnable, - Notification* thread_can_start) { - ThreadMainParam* param = new ThreadMainParam(runnable, thread_can_start); - DWORD thread_id; - // TODO(yukawa): Consider to use _beginthreadex instead. - HANDLE thread_handle = ::CreateThread( - NULL, // Default security. - 0, // Default stack size. - &ThreadWithParamSupport::ThreadMain, - param, // Parameter to ThreadMainStatic - 0x0, // Default creation flags. - &thread_id); // Need a valid pointer for the call to work under Win98. - GTEST_CHECK_(thread_handle != NULL) << "CreateThread failed with error " - << ::GetLastError() << "."; - if (thread_handle == NULL) { - delete param; - } - return thread_handle; - } - - private: - struct ThreadMainParam { - ThreadMainParam(Runnable* runnable, Notification* thread_can_start) - : runnable_(runnable), - thread_can_start_(thread_can_start) { - } - scoped_ptr runnable_; - // Does not own. - Notification* thread_can_start_; - }; - - static DWORD WINAPI ThreadMain(void* ptr) { - // Transfers ownership. - scoped_ptr param(static_cast(ptr)); - if (param->thread_can_start_ != NULL) - param->thread_can_start_->WaitForNotification(); - param->runnable_->Run(); - return 0; - } - - // Prohibit instantiation. - ThreadWithParamSupport(); - - GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParamSupport); -}; - -} // namespace - -ThreadWithParamBase::ThreadWithParamBase(Runnable *runnable, - Notification* thread_can_start) - : thread_(ThreadWithParamSupport::CreateThread(runnable, - thread_can_start)) { -} - -ThreadWithParamBase::~ThreadWithParamBase() { - Join(); -} - -void ThreadWithParamBase::Join() { - GTEST_CHECK_(::WaitForSingleObject(thread_.Get(), INFINITE) == WAIT_OBJECT_0) - << "Failed to join the thread with error " << ::GetLastError() << "."; -} - -// Maps a thread to a set of ThreadIdToThreadLocals that have values -// instantiated on that thread and notifies them when the thread exits. A -// ThreadLocal instance is expected to persist until all threads it has -// values on have terminated. -class ThreadLocalRegistryImpl { - public: - // Registers thread_local_instance as having value on the current thread. - // Returns a value that can be used to identify the thread from other threads. - static ThreadLocalValueHolderBase* GetValueOnCurrentThread( - const ThreadLocalBase* thread_local_instance) { - DWORD current_thread = ::GetCurrentThreadId(); - MutexLock lock(&mutex_); - ThreadIdToThreadLocals* const thread_to_thread_locals = - GetThreadLocalsMapLocked(); - ThreadIdToThreadLocals::iterator thread_local_pos = - thread_to_thread_locals->find(current_thread); - if (thread_local_pos == thread_to_thread_locals->end()) { - thread_local_pos = thread_to_thread_locals->insert( - std::make_pair(current_thread, ThreadLocalValues())).first; - StartWatcherThreadFor(current_thread); - } - ThreadLocalValues& thread_local_values = thread_local_pos->second; - ThreadLocalValues::iterator value_pos = - thread_local_values.find(thread_local_instance); - if (value_pos == thread_local_values.end()) { - value_pos = - thread_local_values - .insert(std::make_pair( - thread_local_instance, - linked_ptr( - thread_local_instance->NewValueForCurrentThread()))) - .first; - } - return value_pos->second.get(); - } - - static void OnThreadLocalDestroyed( - const ThreadLocalBase* thread_local_instance) { - std::vector > value_holders; - // Clean up the ThreadLocalValues data structure while holding the lock, but - // defer the destruction of the ThreadLocalValueHolderBases. - { - MutexLock lock(&mutex_); - ThreadIdToThreadLocals* const thread_to_thread_locals = - GetThreadLocalsMapLocked(); - for (ThreadIdToThreadLocals::iterator it = - thread_to_thread_locals->begin(); - it != thread_to_thread_locals->end(); - ++it) { - ThreadLocalValues& thread_local_values = it->second; - ThreadLocalValues::iterator value_pos = - thread_local_values.find(thread_local_instance); - if (value_pos != thread_local_values.end()) { - value_holders.push_back(value_pos->second); - thread_local_values.erase(value_pos); - // This 'if' can only be successful at most once, so theoretically we - // could break out of the loop here, but we don't bother doing so. - } - } - } - // Outside the lock, let the destructor for 'value_holders' deallocate the - // ThreadLocalValueHolderBases. - } - - static void OnThreadExit(DWORD thread_id) { - GTEST_CHECK_(thread_id != 0) << ::GetLastError(); - std::vector > value_holders; - // Clean up the ThreadIdToThreadLocals data structure while holding the - // lock, but defer the destruction of the ThreadLocalValueHolderBases. - { - MutexLock lock(&mutex_); - ThreadIdToThreadLocals* const thread_to_thread_locals = - GetThreadLocalsMapLocked(); - ThreadIdToThreadLocals::iterator thread_local_pos = - thread_to_thread_locals->find(thread_id); - if (thread_local_pos != thread_to_thread_locals->end()) { - ThreadLocalValues& thread_local_values = thread_local_pos->second; - for (ThreadLocalValues::iterator value_pos = - thread_local_values.begin(); - value_pos != thread_local_values.end(); - ++value_pos) { - value_holders.push_back(value_pos->second); - } - thread_to_thread_locals->erase(thread_local_pos); - } - } - // Outside the lock, let the destructor for 'value_holders' deallocate the - // ThreadLocalValueHolderBases. - } - - private: - // In a particular thread, maps a ThreadLocal object to its value. - typedef std::map > ThreadLocalValues; - // Stores all ThreadIdToThreadLocals having values in a thread, indexed by - // thread's ID. - typedef std::map ThreadIdToThreadLocals; - - // Holds the thread id and thread handle that we pass from - // StartWatcherThreadFor to WatcherThreadFunc. - typedef std::pair ThreadIdAndHandle; - - static void StartWatcherThreadFor(DWORD thread_id) { - // The returned handle will be kept in thread_map and closed by - // watcher_thread in WatcherThreadFunc. - HANDLE thread = ::OpenThread(SYNCHRONIZE | THREAD_QUERY_INFORMATION, - FALSE, - thread_id); - GTEST_CHECK_(thread != NULL); - // We need to pass a valid thread ID pointer into CreateThread for it - // to work correctly under Win98. - DWORD watcher_thread_id; - HANDLE watcher_thread = ::CreateThread( - NULL, // Default security. - 0, // Default stack size - &ThreadLocalRegistryImpl::WatcherThreadFunc, - reinterpret_cast(new ThreadIdAndHandle(thread_id, thread)), - CREATE_SUSPENDED, - &watcher_thread_id); - GTEST_CHECK_(watcher_thread != NULL); - // Give the watcher thread the same priority as ours to avoid being - // blocked by it. - ::SetThreadPriority(watcher_thread, - ::GetThreadPriority(::GetCurrentThread())); - ::ResumeThread(watcher_thread); - ::CloseHandle(watcher_thread); - } - - // Monitors exit from a given thread and notifies those - // ThreadIdToThreadLocals about thread termination. - static DWORD WINAPI WatcherThreadFunc(LPVOID param) { - const ThreadIdAndHandle* tah = - reinterpret_cast(param); - GTEST_CHECK_( - ::WaitForSingleObject(tah->second, INFINITE) == WAIT_OBJECT_0); - OnThreadExit(tah->first); - ::CloseHandle(tah->second); - delete tah; - return 0; - } - - // Returns map of thread local instances. - static ThreadIdToThreadLocals* GetThreadLocalsMapLocked() { - mutex_.AssertHeld(); - static ThreadIdToThreadLocals* map = new ThreadIdToThreadLocals; - return map; - } - - // Protects access to GetThreadLocalsMapLocked() and its return value. - static Mutex mutex_; - // Protects access to GetThreadMapLocked() and its return value. - static Mutex thread_map_mutex_; -}; - -Mutex ThreadLocalRegistryImpl::mutex_(Mutex::kStaticMutex); -Mutex ThreadLocalRegistryImpl::thread_map_mutex_(Mutex::kStaticMutex); - -ThreadLocalValueHolderBase* ThreadLocalRegistry::GetValueOnCurrentThread( - const ThreadLocalBase* thread_local_instance) { - return ThreadLocalRegistryImpl::GetValueOnCurrentThread( - thread_local_instance); -} - -void ThreadLocalRegistry::OnThreadLocalDestroyed( - const ThreadLocalBase* thread_local_instance) { - ThreadLocalRegistryImpl::OnThreadLocalDestroyed(thread_local_instance); -} - -#endif // GTEST_IS_THREADSAFE && GTEST_OS_WINDOWS - -#if GTEST_USES_POSIX_RE - -// Implements RE. Currently only needed for death tests. - -RE::~RE() { - if (is_valid_) { - // regfree'ing an invalid regex might crash because the content - // of the regex is undefined. Since the regex's are essentially - // the same, one cannot be valid (or invalid) without the other - // being so too. - regfree(&partial_regex_); - regfree(&full_regex_); - } - free(const_cast(pattern_)); -} - -// Returns true iff regular expression re matches the entire str. -bool RE::FullMatch(const char* str, const RE& re) { - if (!re.is_valid_) return false; - - regmatch_t match; - return regexec(&re.full_regex_, str, 1, &match, 0) == 0; -} - -// Returns true iff regular expression re matches a substring of str -// (including str itself). -bool RE::PartialMatch(const char* str, const RE& re) { - if (!re.is_valid_) return false; - - regmatch_t match; - return regexec(&re.partial_regex_, str, 1, &match, 0) == 0; -} - -// Initializes an RE from its string representation. -void RE::Init(const char* regex) { - pattern_ = posix::StrDup(regex); - - // Reserves enough bytes to hold the regular expression used for a - // full match. - const size_t full_regex_len = strlen(regex) + 10; - char* const full_pattern = new char[full_regex_len]; - - snprintf(full_pattern, full_regex_len, "^(%s)$", regex); - is_valid_ = regcomp(&full_regex_, full_pattern, REG_EXTENDED) == 0; - // We want to call regcomp(&partial_regex_, ...) even if the - // previous expression returns false. Otherwise partial_regex_ may - // not be properly initialized can may cause trouble when it's - // freed. - // - // Some implementation of POSIX regex (e.g. on at least some - // versions of Cygwin) doesn't accept the empty string as a valid - // regex. We change it to an equivalent form "()" to be safe. - if (is_valid_) { - const char* const partial_regex = (*regex == '\0') ? "()" : regex; - is_valid_ = regcomp(&partial_regex_, partial_regex, REG_EXTENDED) == 0; - } - EXPECT_TRUE(is_valid_) - << "Regular expression \"" << regex - << "\" is not a valid POSIX Extended regular expression."; - - delete[] full_pattern; -} - -#elif GTEST_USES_SIMPLE_RE - -// Returns true iff ch appears anywhere in str (excluding the -// terminating '\0' character). -bool IsInSet(char ch, const char* str) { - return ch != '\0' && strchr(str, ch) != NULL; -} - -// Returns true iff ch belongs to the given classification. Unlike -// similar functions in , these aren't affected by the -// current locale. -bool IsAsciiDigit(char ch) { return '0' <= ch && ch <= '9'; } -bool IsAsciiPunct(char ch) { - return IsInSet(ch, "^-!\"#$%&'()*+,./:;<=>?@[\\]_`{|}~"); -} -bool IsRepeat(char ch) { return IsInSet(ch, "?*+"); } -bool IsAsciiWhiteSpace(char ch) { return IsInSet(ch, " \f\n\r\t\v"); } -bool IsAsciiWordChar(char ch) { - return ('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z') || - ('0' <= ch && ch <= '9') || ch == '_'; -} - -// Returns true iff "\\c" is a supported escape sequence. -bool IsValidEscape(char c) { - return (IsAsciiPunct(c) || IsInSet(c, "dDfnrsStvwW")); -} - -// Returns true iff the given atom (specified by escaped and pattern) -// matches ch. The result is undefined if the atom is invalid. -bool AtomMatchesChar(bool escaped, char pattern_char, char ch) { - if (escaped) { // "\\p" where p is pattern_char. - switch (pattern_char) { - case 'd': return IsAsciiDigit(ch); - case 'D': return !IsAsciiDigit(ch); - case 'f': return ch == '\f'; - case 'n': return ch == '\n'; - case 'r': return ch == '\r'; - case 's': return IsAsciiWhiteSpace(ch); - case 'S': return !IsAsciiWhiteSpace(ch); - case 't': return ch == '\t'; - case 'v': return ch == '\v'; - case 'w': return IsAsciiWordChar(ch); - case 'W': return !IsAsciiWordChar(ch); - } - return IsAsciiPunct(pattern_char) && pattern_char == ch; - } - - return (pattern_char == '.' && ch != '\n') || pattern_char == ch; -} - -// Helper function used by ValidateRegex() to format error messages. -static std::string FormatRegexSyntaxError(const char* regex, int index) { - return (Message() << "Syntax error at index " << index - << " in simple regular expression \"" << regex << "\": ").GetString(); -} - -// Generates non-fatal failures and returns false if regex is invalid; -// otherwise returns true. -bool ValidateRegex(const char* regex) { - if (regex == NULL) { - // TODO(wan@google.com): fix the source file location in the - // assertion failures to match where the regex is used in user - // code. - ADD_FAILURE() << "NULL is not a valid simple regular expression."; - return false; - } - - bool is_valid = true; - - // True iff ?, *, or + can follow the previous atom. - bool prev_repeatable = false; - for (int i = 0; regex[i]; i++) { - if (regex[i] == '\\') { // An escape sequence - i++; - if (regex[i] == '\0') { - ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1) - << "'\\' cannot appear at the end."; - return false; - } - - if (!IsValidEscape(regex[i])) { - ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1) - << "invalid escape sequence \"\\" << regex[i] << "\"."; - is_valid = false; - } - prev_repeatable = true; - } else { // Not an escape sequence. - const char ch = regex[i]; - - if (ch == '^' && i > 0) { - ADD_FAILURE() << FormatRegexSyntaxError(regex, i) - << "'^' can only appear at the beginning."; - is_valid = false; - } else if (ch == '$' && regex[i + 1] != '\0') { - ADD_FAILURE() << FormatRegexSyntaxError(regex, i) - << "'$' can only appear at the end."; - is_valid = false; - } else if (IsInSet(ch, "()[]{}|")) { - ADD_FAILURE() << FormatRegexSyntaxError(regex, i) - << "'" << ch << "' is unsupported."; - is_valid = false; - } else if (IsRepeat(ch) && !prev_repeatable) { - ADD_FAILURE() << FormatRegexSyntaxError(regex, i) - << "'" << ch << "' can only follow a repeatable token."; - is_valid = false; - } - - prev_repeatable = !IsInSet(ch, "^$?*+"); - } - } - - return is_valid; -} - -// Matches a repeated regex atom followed by a valid simple regular -// expression. The regex atom is defined as c if escaped is false, -// or \c otherwise. repeat is the repetition meta character (?, *, -// or +). The behavior is undefined if str contains too many -// characters to be indexable by size_t, in which case the test will -// probably time out anyway. We are fine with this limitation as -// std::string has it too. -bool MatchRepetitionAndRegexAtHead( - bool escaped, char c, char repeat, const char* regex, - const char* str) { - const size_t min_count = (repeat == '+') ? 1 : 0; - const size_t max_count = (repeat == '?') ? 1 : - static_cast(-1) - 1; - // We cannot call numeric_limits::max() as it conflicts with the - // max() macro on Windows. - - for (size_t i = 0; i <= max_count; ++i) { - // We know that the atom matches each of the first i characters in str. - if (i >= min_count && MatchRegexAtHead(regex, str + i)) { - // We have enough matches at the head, and the tail matches too. - // Since we only care about *whether* the pattern matches str - // (as opposed to *how* it matches), there is no need to find a - // greedy match. - return true; - } - if (str[i] == '\0' || !AtomMatchesChar(escaped, c, str[i])) - return false; - } - return false; -} - -// Returns true iff regex matches a prefix of str. regex must be a -// valid simple regular expression and not start with "^", or the -// result is undefined. -bool MatchRegexAtHead(const char* regex, const char* str) { - if (*regex == '\0') // An empty regex matches a prefix of anything. - return true; - - // "$" only matches the end of a string. Note that regex being - // valid guarantees that there's nothing after "$" in it. - if (*regex == '$') - return *str == '\0'; - - // Is the first thing in regex an escape sequence? - const bool escaped = *regex == '\\'; - if (escaped) - ++regex; - if (IsRepeat(regex[1])) { - // MatchRepetitionAndRegexAtHead() calls MatchRegexAtHead(), so - // here's an indirect recursion. It terminates as the regex gets - // shorter in each recursion. - return MatchRepetitionAndRegexAtHead( - escaped, regex[0], regex[1], regex + 2, str); - } else { - // regex isn't empty, isn't "$", and doesn't start with a - // repetition. We match the first atom of regex with the first - // character of str and recurse. - return (*str != '\0') && AtomMatchesChar(escaped, *regex, *str) && - MatchRegexAtHead(regex + 1, str + 1); - } -} - -// Returns true iff regex matches any substring of str. regex must be -// a valid simple regular expression, or the result is undefined. -// -// The algorithm is recursive, but the recursion depth doesn't exceed -// the regex length, so we won't need to worry about running out of -// stack space normally. In rare cases the time complexity can be -// exponential with respect to the regex length + the string length, -// but usually it's must faster (often close to linear). -bool MatchRegexAnywhere(const char* regex, const char* str) { - if (regex == NULL || str == NULL) - return false; - - if (*regex == '^') - return MatchRegexAtHead(regex + 1, str); - - // A successful match can be anywhere in str. - do { - if (MatchRegexAtHead(regex, str)) - return true; - } while (*str++ != '\0'); - return false; -} - -// Implements the RE class. - -RE::~RE() { - free(const_cast(pattern_)); - free(const_cast(full_pattern_)); -} - -// Returns true iff regular expression re matches the entire str. -bool RE::FullMatch(const char* str, const RE& re) { - return re.is_valid_ && MatchRegexAnywhere(re.full_pattern_, str); -} - -// Returns true iff regular expression re matches a substring of str -// (including str itself). -bool RE::PartialMatch(const char* str, const RE& re) { - return re.is_valid_ && MatchRegexAnywhere(re.pattern_, str); -} - -// Initializes an RE from its string representation. -void RE::Init(const char* regex) { - pattern_ = full_pattern_ = NULL; - if (regex != NULL) { - pattern_ = posix::StrDup(regex); - } - - is_valid_ = ValidateRegex(regex); - if (!is_valid_) { - // No need to calculate the full pattern when the regex is invalid. - return; - } - - const size_t len = strlen(regex); - // Reserves enough bytes to hold the regular expression used for a - // full match: we need space to prepend a '^', append a '$', and - // terminate the string with '\0'. - char* buffer = static_cast(malloc(len + 3)); - full_pattern_ = buffer; - - if (*regex != '^') - *buffer++ = '^'; // Makes sure full_pattern_ starts with '^'. - - // We don't use snprintf or strncpy, as they trigger a warning when - // compiled with VC++ 8.0. - memcpy(buffer, regex, len); - buffer += len; - - if (len == 0 || regex[len - 1] != '$') - *buffer++ = '$'; // Makes sure full_pattern_ ends with '$'. - - *buffer = '\0'; -} - -#endif // GTEST_USES_POSIX_RE - -const char kUnknownFile[] = "unknown file"; - -// Formats a source file path and a line number as they would appear -// in an error message from the compiler used to compile this code. -GTEST_API_ ::std::string FormatFileLocation(const char* file, int line) { - const std::string file_name(file == NULL ? kUnknownFile : file); - - if (line < 0) { - return file_name + ":"; - } -#ifdef _MSC_VER - return file_name + "(" + StreamableToString(line) + "):"; -#else - return file_name + ":" + StreamableToString(line) + ":"; -#endif // _MSC_VER -} - -// Formats a file location for compiler-independent XML output. -// Although this function is not platform dependent, we put it next to -// FormatFileLocation in order to contrast the two functions. -// Note that FormatCompilerIndependentFileLocation() does NOT append colon -// to the file location it produces, unlike FormatFileLocation(). -GTEST_API_ ::std::string FormatCompilerIndependentFileLocation( - const char* file, int line) { - const std::string file_name(file == NULL ? kUnknownFile : file); - - if (line < 0) - return file_name; - else - return file_name + ":" + StreamableToString(line); -} - -GTestLog::GTestLog(GTestLogSeverity severity, const char* file, int line) - : severity_(severity) { - const char* const marker = - severity == GTEST_INFO ? "[ INFO ]" : - severity == GTEST_WARNING ? "[WARNING]" : - severity == GTEST_ERROR ? "[ ERROR ]" : "[ FATAL ]"; - GetStream() << ::std::endl << marker << " " - << FormatFileLocation(file, line).c_str() << ": "; -} - -// Flushes the buffers and, if severity is GTEST_FATAL, aborts the program. -GTestLog::~GTestLog() { - GetStream() << ::std::endl; - if (severity_ == GTEST_FATAL) { - fflush(stderr); - posix::Abort(); - } -} - -// Disable Microsoft deprecation warnings for POSIX functions called from -// this class (creat, dup, dup2, and close) -GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996) - -#if GTEST_HAS_STREAM_REDIRECTION - -// Object that captures an output stream (stdout/stderr). -class CapturedStream { - public: - // The ctor redirects the stream to a temporary file. - explicit CapturedStream(int fd) : fd_(fd), uncaptured_fd_(dup(fd)) { -# if GTEST_OS_WINDOWS - char temp_dir_path[MAX_PATH + 1] = { '\0' }; // NOLINT - char temp_file_path[MAX_PATH + 1] = { '\0' }; // NOLINT - - ::GetTempPathA(sizeof(temp_dir_path), temp_dir_path); - const UINT success = ::GetTempFileNameA(temp_dir_path, - "gtest_redir", - 0, // Generate unique file name. - temp_file_path); - GTEST_CHECK_(success != 0) - << "Unable to create a temporary file in " << temp_dir_path; - const int captured_fd = creat(temp_file_path, _S_IREAD | _S_IWRITE); - GTEST_CHECK_(captured_fd != -1) << "Unable to open temporary file " - << temp_file_path; - filename_ = temp_file_path; -# else - // There's no guarantee that a test has write access to the current - // directory, so we create the temporary file in the /tmp directory - // instead. We use /tmp on most systems, and /sdcard on Android. - // That's because Android doesn't have /tmp. -# if GTEST_OS_LINUX_ANDROID - // Note: Android applications are expected to call the framework's - // Context.getExternalStorageDirectory() method through JNI to get - // the location of the world-writable SD Card directory. However, - // this requires a Context handle, which cannot be retrieved - // globally from native code. Doing so also precludes running the - // code as part of a regular standalone executable, which doesn't - // run in a Dalvik process (e.g. when running it through 'adb shell'). - // - // The location /sdcard is directly accessible from native code - // and is the only location (unofficially) supported by the Android - // team. It's generally a symlink to the real SD Card mount point - // which can be /mnt/sdcard, /mnt/sdcard0, /system/media/sdcard, or - // other OEM-customized locations. Never rely on these, and always - // use /sdcard. - char name_template[] = "/sdcard/gtest_captured_stream.XXXXXX"; -# else - char name_template[] = "/tmp/captured_stream.XXXXXX"; -# endif // GTEST_OS_LINUX_ANDROID - const int captured_fd = mkstemp(name_template); - filename_ = name_template; -# endif // GTEST_OS_WINDOWS - fflush(NULL); - dup2(captured_fd, fd_); - close(captured_fd); - } - - ~CapturedStream() { - remove(filename_.c_str()); - } - - std::string GetCapturedString() { - if (uncaptured_fd_ != -1) { - // Restores the original stream. - fflush(NULL); - dup2(uncaptured_fd_, fd_); - close(uncaptured_fd_); - uncaptured_fd_ = -1; - } - - FILE* const file = posix::FOpen(filename_.c_str(), "r"); - const std::string content = ReadEntireFile(file); - posix::FClose(file); - return content; - } - - private: - const int fd_; // A stream to capture. - int uncaptured_fd_; - // Name of the temporary file holding the stderr output. - ::std::string filename_; - - GTEST_DISALLOW_COPY_AND_ASSIGN_(CapturedStream); -}; - -GTEST_DISABLE_MSC_WARNINGS_POP_() - -static CapturedStream* g_captured_stderr = NULL; -static CapturedStream* g_captured_stdout = NULL; - -// Starts capturing an output stream (stdout/stderr). -static void CaptureStream(int fd, const char* stream_name, - CapturedStream** stream) { - if (*stream != NULL) { - GTEST_LOG_(FATAL) << "Only one " << stream_name - << " capturer can exist at a time."; - } - *stream = new CapturedStream(fd); -} - -// Stops capturing the output stream and returns the captured string. -static std::string GetCapturedStream(CapturedStream** captured_stream) { - const std::string content = (*captured_stream)->GetCapturedString(); - - delete *captured_stream; - *captured_stream = NULL; - - return content; -} - -// Starts capturing stdout. -void CaptureStdout() { - CaptureStream(kStdOutFileno, "stdout", &g_captured_stdout); -} - -// Starts capturing stderr. -void CaptureStderr() { - CaptureStream(kStdErrFileno, "stderr", &g_captured_stderr); -} - -// Stops capturing stdout and returns the captured string. -std::string GetCapturedStdout() { - return GetCapturedStream(&g_captured_stdout); -} - -// Stops capturing stderr and returns the captured string. -std::string GetCapturedStderr() { - return GetCapturedStream(&g_captured_stderr); -} - -#endif // GTEST_HAS_STREAM_REDIRECTION - - - - - -size_t GetFileSize(FILE* file) { - fseek(file, 0, SEEK_END); - return static_cast(ftell(file)); -} - -std::string ReadEntireFile(FILE* file) { - const size_t file_size = GetFileSize(file); - char* const buffer = new char[file_size]; - - size_t bytes_last_read = 0; // # of bytes read in the last fread() - size_t bytes_read = 0; // # of bytes read so far - - fseek(file, 0, SEEK_SET); - - // Keeps reading the file until we cannot read further or the - // pre-determined file size is reached. - do { - bytes_last_read = fread(buffer+bytes_read, 1, file_size-bytes_read, file); - bytes_read += bytes_last_read; - } while (bytes_last_read > 0 && bytes_read < file_size); - - const std::string content(buffer, bytes_read); - delete[] buffer; - - return content; -} - -#if GTEST_HAS_DEATH_TEST -static const std::vector* g_injected_test_argvs = NULL; // Owned. - -std::vector GetInjectableArgvs() { - if (g_injected_test_argvs != NULL) { - return *g_injected_test_argvs; - } - return GetArgvs(); -} - -void SetInjectableArgvs(const std::vector* new_argvs) { - if (g_injected_test_argvs != new_argvs) delete g_injected_test_argvs; - g_injected_test_argvs = new_argvs; -} - -void SetInjectableArgvs(const std::vector& new_argvs) { - SetInjectableArgvs( - new std::vector(new_argvs.begin(), new_argvs.end())); -} - -#if GTEST_HAS_GLOBAL_STRING -void SetInjectableArgvs(const std::vector< ::string>& new_argvs) { - SetInjectableArgvs( - new std::vector(new_argvs.begin(), new_argvs.end())); -} -#endif // GTEST_HAS_GLOBAL_STRING - -void ClearInjectableArgvs() { - delete g_injected_test_argvs; - g_injected_test_argvs = NULL; -} -#endif // GTEST_HAS_DEATH_TEST - -#if GTEST_OS_WINDOWS_MOBILE -namespace posix { -void Abort() { - DebugBreak(); - TerminateProcess(GetCurrentProcess(), 1); -} -} // namespace posix -#endif // GTEST_OS_WINDOWS_MOBILE - -// Returns the name of the environment variable corresponding to the -// given flag. For example, FlagToEnvVar("foo") will return -// "GTEST_FOO" in the open-source version. -static std::string FlagToEnvVar(const char* flag) { - const std::string full_flag = - (Message() << GTEST_FLAG_PREFIX_ << flag).GetString(); - - Message env_var; - for (size_t i = 0; i != full_flag.length(); i++) { - env_var << ToUpper(full_flag.c_str()[i]); - } - - return env_var.GetString(); -} - -// Parses 'str' for a 32-bit signed integer. If successful, writes -// the result to *value and returns true; otherwise leaves *value -// unchanged and returns false. -bool ParseInt32(const Message& src_text, const char* str, Int32* value) { - // Parses the environment variable as a decimal integer. - char* end = NULL; - const long long_value = strtol(str, &end, 10); // NOLINT - - // Has strtol() consumed all characters in the string? - if (*end != '\0') { - // No - an invalid character was encountered. - Message msg; - msg << "WARNING: " << src_text - << " is expected to be a 32-bit integer, but actually" - << " has value \"" << str << "\".\n"; - printf("%s", msg.GetString().c_str()); - fflush(stdout); - return false; - } - - // Is the parsed value in the range of an Int32? - const Int32 result = static_cast(long_value); - if (long_value == LONG_MAX || long_value == LONG_MIN || - // The parsed value overflows as a long. (strtol() returns - // LONG_MAX or LONG_MIN when the input overflows.) - result != long_value - // The parsed value overflows as an Int32. - ) { - Message msg; - msg << "WARNING: " << src_text - << " is expected to be a 32-bit integer, but actually" - << " has value " << str << ", which overflows.\n"; - printf("%s", msg.GetString().c_str()); - fflush(stdout); - return false; - } - - *value = result; - return true; -} - -// Reads and returns the Boolean environment variable corresponding to -// the given flag; if it's not set, returns default_value. -// -// The value is considered true iff it's not "0". -bool BoolFromGTestEnv(const char* flag, bool default_value) { -#if defined(GTEST_GET_BOOL_FROM_ENV_) - return GTEST_GET_BOOL_FROM_ENV_(flag, default_value); -#else - const std::string env_var = FlagToEnvVar(flag); - const char* const string_value = posix::GetEnv(env_var.c_str()); - return string_value == NULL ? - default_value : strcmp(string_value, "0") != 0; -#endif // defined(GTEST_GET_BOOL_FROM_ENV_) -} - -// Reads and returns a 32-bit integer stored in the environment -// variable corresponding to the given flag; if it isn't set or -// doesn't represent a valid 32-bit integer, returns default_value. -Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) { -#if defined(GTEST_GET_INT32_FROM_ENV_) - return GTEST_GET_INT32_FROM_ENV_(flag, default_value); -#else - const std::string env_var = FlagToEnvVar(flag); - const char* const string_value = posix::GetEnv(env_var.c_str()); - if (string_value == NULL) { - // The environment variable is not set. - return default_value; - } - - Int32 result = default_value; - if (!ParseInt32(Message() << "Environment variable " << env_var, - string_value, &result)) { - printf("The default value %s is used.\n", - (Message() << default_value).GetString().c_str()); - fflush(stdout); - return default_value; - } - - return result; -#endif // defined(GTEST_GET_INT32_FROM_ENV_) -} - -// As a special case for the 'output' flag, if GTEST_OUTPUT is not -// set, we look for XML_OUTPUT_FILE, which is set by the Bazel build -// system. The value of XML_OUTPUT_FILE is a filename without the -// "xml:" prefix of GTEST_OUTPUT. -// Note that this is meant to be called at the call site so it does -// not check that the flag is 'output' -// In essence this checks an env variable called XML_OUTPUT_FILE -// and if it is set we prepend "xml:" to its value, if it not set we return "" -std::string OutputFlagAlsoCheckEnvVar(){ - std::string default_value_for_output_flag = ""; - const char* xml_output_file_env = posix::GetEnv("XML_OUTPUT_FILE"); - if (NULL != xml_output_file_env) { - default_value_for_output_flag = std::string("xml:") + xml_output_file_env; - } - return default_value_for_output_flag; -} - -// Reads and returns the string environment variable corresponding to -// the given flag; if it's not set, returns default_value. -const char* StringFromGTestEnv(const char* flag, const char* default_value) { -#if defined(GTEST_GET_STRING_FROM_ENV_) - return GTEST_GET_STRING_FROM_ENV_(flag, default_value); -#else - const std::string env_var = FlagToEnvVar(flag); - const char* const value = posix::GetEnv(env_var.c_str()); - return value == NULL ? default_value : value; -#endif // defined(GTEST_GET_STRING_FROM_ENV_) -} - -} // namespace internal -} // namespace testing -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) - -// Google Test - The Google C++ Testing and Mocking Framework -// -// This file implements a universal value printer that can print a -// value of any type T: -// -// void ::testing::internal::UniversalPrinter::Print(value, ostream_ptr); -// -// It uses the << operator when possible, and prints the bytes in the -// object otherwise. A user can override its behavior for a class -// type Foo by defining either operator<<(::std::ostream&, const Foo&) -// or void PrintTo(const Foo&, ::std::ostream*) in the namespace that -// defines Foo. - -#include -#include -#include -#include // NOLINT -#include - -namespace testing { - -namespace { - -using ::std::ostream; - -// Prints a segment of bytes in the given object. -GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ -GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ -GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ -void PrintByteSegmentInObjectTo(const unsigned char* obj_bytes, size_t start, - size_t count, ostream* os) { - char text[5] = ""; - for (size_t i = 0; i != count; i++) { - const size_t j = start + i; - if (i != 0) { - // Organizes the bytes into groups of 2 for easy parsing by - // human. - if ((j % 2) == 0) - *os << ' '; - else - *os << '-'; - } - GTEST_SNPRINTF_(text, sizeof(text), "%02X", obj_bytes[j]); - *os << text; - } -} - -// Prints the bytes in the given value to the given ostream. -void PrintBytesInObjectToImpl(const unsigned char* obj_bytes, size_t count, - ostream* os) { - // Tells the user how big the object is. - *os << count << "-byte object <"; - - const size_t kThreshold = 132; - const size_t kChunkSize = 64; - // If the object size is bigger than kThreshold, we'll have to omit - // some details by printing only the first and the last kChunkSize - // bytes. - // TODO(wan): let the user control the threshold using a flag. - if (count < kThreshold) { - PrintByteSegmentInObjectTo(obj_bytes, 0, count, os); - } else { - PrintByteSegmentInObjectTo(obj_bytes, 0, kChunkSize, os); - *os << " ... "; - // Rounds up to 2-byte boundary. - const size_t resume_pos = (count - kChunkSize + 1)/2*2; - PrintByteSegmentInObjectTo(obj_bytes, resume_pos, count - resume_pos, os); - } - *os << ">"; -} - -} // namespace - -namespace internal2 { - -// Delegates to PrintBytesInObjectToImpl() to print the bytes in the -// given object. The delegation simplifies the implementation, which -// uses the << operator and thus is easier done outside of the -// ::testing::internal namespace, which contains a << operator that -// sometimes conflicts with the one in STL. -void PrintBytesInObjectTo(const unsigned char* obj_bytes, size_t count, - ostream* os) { - PrintBytesInObjectToImpl(obj_bytes, count, os); -} - -} // namespace internal2 - -namespace internal { - -// Depending on the value of a char (or wchar_t), we print it in one -// of three formats: -// - as is if it's a printable ASCII (e.g. 'a', '2', ' '), -// - as a hexadecimal escape sequence (e.g. '\x7F'), or -// - as a special escape sequence (e.g. '\r', '\n'). -enum CharFormat { - kAsIs, - kHexEscape, - kSpecialEscape -}; - -// Returns true if c is a printable ASCII character. We test the -// value of c directly instead of calling isprint(), which is buggy on -// Windows Mobile. -inline bool IsPrintableAscii(wchar_t c) { - return 0x20 <= c && c <= 0x7E; -} - -// Prints a wide or narrow char c as a character literal without the -// quotes, escaping it when necessary; returns how c was formatted. -// The template argument UnsignedChar is the unsigned version of Char, -// which is the type of c. -template -static CharFormat PrintAsCharLiteralTo(Char c, ostream* os) { - switch (static_cast(c)) { - case L'\0': - *os << "\\0"; - break; - case L'\'': - *os << "\\'"; - break; - case L'\\': - *os << "\\\\"; - break; - case L'\a': - *os << "\\a"; - break; - case L'\b': - *os << "\\b"; - break; - case L'\f': - *os << "\\f"; - break; - case L'\n': - *os << "\\n"; - break; - case L'\r': - *os << "\\r"; - break; - case L'\t': - *os << "\\t"; - break; - case L'\v': - *os << "\\v"; - break; - default: - if (IsPrintableAscii(c)) { - *os << static_cast(c); - return kAsIs; - } else { - ostream::fmtflags flags = os->flags(); - *os << "\\x" << std::hex << std::uppercase - << static_cast(static_cast(c)); - os->flags(flags); - return kHexEscape; - } - } - return kSpecialEscape; -} - -// Prints a wchar_t c as if it's part of a string literal, escaping it when -// necessary; returns how c was formatted. -static CharFormat PrintAsStringLiteralTo(wchar_t c, ostream* os) { - switch (c) { - case L'\'': - *os << "'"; - return kAsIs; - case L'"': - *os << "\\\""; - return kSpecialEscape; - default: - return PrintAsCharLiteralTo(c, os); - } -} - -// Prints a char c as if it's part of a string literal, escaping it when -// necessary; returns how c was formatted. -static CharFormat PrintAsStringLiteralTo(char c, ostream* os) { - return PrintAsStringLiteralTo( - static_cast(static_cast(c)), os); -} - -// Prints a wide or narrow character c and its code. '\0' is printed -// as "'\\0'", other unprintable characters are also properly escaped -// using the standard C++ escape sequence. The template argument -// UnsignedChar is the unsigned version of Char, which is the type of c. -template -void PrintCharAndCodeTo(Char c, ostream* os) { - // First, print c as a literal in the most readable form we can find. - *os << ((sizeof(c) > 1) ? "L'" : "'"); - const CharFormat format = PrintAsCharLiteralTo(c, os); - *os << "'"; - - // To aid user debugging, we also print c's code in decimal, unless - // it's 0 (in which case c was printed as '\\0', making the code - // obvious). - if (c == 0) - return; - *os << " (" << static_cast(c); - - // For more convenience, we print c's code again in hexadecimal, - // unless c was already printed in the form '\x##' or the code is in - // [1, 9]. - if (format == kHexEscape || (1 <= c && c <= 9)) { - // Do nothing. - } else { - *os << ", 0x" << String::FormatHexInt(static_cast(c)); - } - *os << ")"; -} - -void PrintTo(unsigned char c, ::std::ostream* os) { - PrintCharAndCodeTo(c, os); -} -void PrintTo(signed char c, ::std::ostream* os) { - PrintCharAndCodeTo(c, os); -} - -// Prints a wchar_t as a symbol if it is printable or as its internal -// code otherwise and also as its code. L'\0' is printed as "L'\\0'". -void PrintTo(wchar_t wc, ostream* os) { - PrintCharAndCodeTo(wc, os); -} - -// Prints the given array of characters to the ostream. CharType must be either -// char or wchar_t. -// The array starts at begin, the length is len, it may include '\0' characters -// and may not be NUL-terminated. -template -GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ -GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ -GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ -static CharFormat PrintCharsAsStringTo( - const CharType* begin, size_t len, ostream* os) { - const char* const kQuoteBegin = sizeof(CharType) == 1 ? "\"" : "L\""; - *os << kQuoteBegin; - bool is_previous_hex = false; - CharFormat print_format = kAsIs; - for (size_t index = 0; index < len; ++index) { - const CharType cur = begin[index]; - if (is_previous_hex && IsXDigit(cur)) { - // Previous character is of '\x..' form and this character can be - // interpreted as another hexadecimal digit in its number. Break string to - // disambiguate. - *os << "\" " << kQuoteBegin; - } - is_previous_hex = PrintAsStringLiteralTo(cur, os) == kHexEscape; - // Remember if any characters required hex escaping. - if (is_previous_hex) { - print_format = kHexEscape; - } - } - *os << "\""; - return print_format; -} - -// Prints a (const) char/wchar_t array of 'len' elements, starting at address -// 'begin'. CharType must be either char or wchar_t. -template -GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ -GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ -GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ -static void UniversalPrintCharArray( - const CharType* begin, size_t len, ostream* os) { - // The code - // const char kFoo[] = "foo"; - // generates an array of 4, not 3, elements, with the last one being '\0'. - // - // Therefore when printing a char array, we don't print the last element if - // it's '\0', such that the output matches the string literal as it's - // written in the source code. - if (len > 0 && begin[len - 1] == '\0') { - PrintCharsAsStringTo(begin, len - 1, os); - return; - } - - // If, however, the last element in the array is not '\0', e.g. - // const char kFoo[] = { 'f', 'o', 'o' }; - // we must print the entire array. We also print a message to indicate - // that the array is not NUL-terminated. - PrintCharsAsStringTo(begin, len, os); - *os << " (no terminating NUL)"; -} - -// Prints a (const) char array of 'len' elements, starting at address 'begin'. -void UniversalPrintArray(const char* begin, size_t len, ostream* os) { - UniversalPrintCharArray(begin, len, os); -} - -// Prints a (const) wchar_t array of 'len' elements, starting at address -// 'begin'. -void UniversalPrintArray(const wchar_t* begin, size_t len, ostream* os) { - UniversalPrintCharArray(begin, len, os); -} - -// Prints the given C string to the ostream. -void PrintTo(const char* s, ostream* os) { - if (s == NULL) { - *os << "NULL"; - } else { - *os << ImplicitCast_(s) << " pointing to "; - PrintCharsAsStringTo(s, strlen(s), os); - } -} - -// MSVC compiler can be configured to define whar_t as a typedef -// of unsigned short. Defining an overload for const wchar_t* in that case -// would cause pointers to unsigned shorts be printed as wide strings, -// possibly accessing more memory than intended and causing invalid -// memory accesses. MSVC defines _NATIVE_WCHAR_T_DEFINED symbol when -// wchar_t is implemented as a native type. -#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED) -// Prints the given wide C string to the ostream. -void PrintTo(const wchar_t* s, ostream* os) { - if (s == NULL) { - *os << "NULL"; - } else { - *os << ImplicitCast_(s) << " pointing to "; - PrintCharsAsStringTo(s, std::wcslen(s), os); - } -} -#endif // wchar_t is native - -namespace { - -bool ContainsUnprintableControlCodes(const char* str, size_t length) { - const unsigned char *s = reinterpret_cast(str); - - for (size_t i = 0; i < length; i++) { - unsigned char ch = *s++; - if (std::iscntrl(ch)) { - switch (ch) { - case '\t': - case '\n': - case '\r': - break; - default: - return true; - } - } - } - return false; -} - -bool IsUTF8TrailByte(unsigned char t) { return 0x80 <= t && t<= 0xbf; } - -bool IsValidUTF8(const char* str, size_t length) { - const unsigned char *s = reinterpret_cast(str); - - for (size_t i = 0; i < length;) { - unsigned char lead = s[i++]; - - if (lead <= 0x7f) { - continue; // single-byte character (ASCII) 0..7F - } - if (lead < 0xc2) { - return false; // trail byte or non-shortest form - } else if (lead <= 0xdf && (i + 1) <= length && IsUTF8TrailByte(s[i])) { - ++i; // 2-byte character - } else if (0xe0 <= lead && lead <= 0xef && (i + 2) <= length && - IsUTF8TrailByte(s[i]) && - IsUTF8TrailByte(s[i + 1]) && - // check for non-shortest form and surrogate - (lead != 0xe0 || s[i] >= 0xa0) && - (lead != 0xed || s[i] < 0xa0)) { - i += 2; // 3-byte character - } else if (0xf0 <= lead && lead <= 0xf4 && (i + 3) <= length && - IsUTF8TrailByte(s[i]) && - IsUTF8TrailByte(s[i + 1]) && - IsUTF8TrailByte(s[i + 2]) && - // check for non-shortest form - (lead != 0xf0 || s[i] >= 0x90) && - (lead != 0xf4 || s[i] < 0x90)) { - i += 3; // 4-byte character - } else { - return false; - } - } - return true; -} - -void ConditionalPrintAsText(const char* str, size_t length, ostream* os) { - if (!ContainsUnprintableControlCodes(str, length) && - IsValidUTF8(str, length)) { - *os << "\n As Text: \"" << str << "\""; - } -} - -} // anonymous namespace - -// Prints a ::string object. -#if GTEST_HAS_GLOBAL_STRING -void PrintStringTo(const ::string& s, ostream* os) { - if (PrintCharsAsStringTo(s.data(), s.size(), os) == kHexEscape) { - if (GTEST_FLAG(print_utf8)) { - ConditionalPrintAsText(s.data(), s.size(), os); - } - } -} -#endif // GTEST_HAS_GLOBAL_STRING - -void PrintStringTo(const ::std::string& s, ostream* os) { - if (PrintCharsAsStringTo(s.data(), s.size(), os) == kHexEscape) { - if (GTEST_FLAG(print_utf8)) { - ConditionalPrintAsText(s.data(), s.size(), os); - } - } -} - -// Prints a ::wstring object. -#if GTEST_HAS_GLOBAL_WSTRING -void PrintWideStringTo(const ::wstring& s, ostream* os) { - PrintCharsAsStringTo(s.data(), s.size(), os); -} -#endif // GTEST_HAS_GLOBAL_WSTRING - -#if GTEST_HAS_STD_WSTRING -void PrintWideStringTo(const ::std::wstring& s, ostream* os) { - PrintCharsAsStringTo(s.data(), s.size(), os); -} -#endif // GTEST_HAS_STD_WSTRING - -} // namespace internal - -} // namespace testing -// Copyright 2008, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: mheule@google.com (Markus Heule) -// -// The Google C++ Testing and Mocking Framework (Google Test) - - -namespace testing { - -using internal::GetUnitTestImpl; - -// Gets the summary of the failure message by omitting the stack trace -// in it. -std::string TestPartResult::ExtractSummary(const char* message) { - const char* const stack_trace = strstr(message, internal::kStackTraceMarker); - return stack_trace == NULL ? message : - std::string(message, stack_trace); -} - -// Prints a TestPartResult object. -std::ostream& operator<<(std::ostream& os, const TestPartResult& result) { - return os - << result.file_name() << ":" << result.line_number() << ": " - << (result.type() == TestPartResult::kSuccess ? "Success" : - result.type() == TestPartResult::kFatalFailure ? "Fatal failure" : - "Non-fatal failure") << ":\n" - << result.message() << std::endl; -} - -// Appends a TestPartResult to the array. -void TestPartResultArray::Append(const TestPartResult& result) { - array_.push_back(result); -} - -// Returns the TestPartResult at the given index (0-based). -const TestPartResult& TestPartResultArray::GetTestPartResult(int index) const { - if (index < 0 || index >= size()) { - printf("\nInvalid index (%d) into TestPartResultArray.\n", index); - internal::posix::Abort(); - } - - return array_[index]; -} - -// Returns the number of TestPartResult objects in the array. -int TestPartResultArray::size() const { - return static_cast(array_.size()); -} - -namespace internal { - -HasNewFatalFailureHelper::HasNewFatalFailureHelper() - : has_new_fatal_failure_(false), - original_reporter_(GetUnitTestImpl()-> - GetTestPartResultReporterForCurrentThread()) { - GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread(this); -} - -HasNewFatalFailureHelper::~HasNewFatalFailureHelper() { - GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread( - original_reporter_); -} - -void HasNewFatalFailureHelper::ReportTestPartResult( - const TestPartResult& result) { - if (result.fatally_failed()) - has_new_fatal_failure_ = true; - original_reporter_->ReportTestPartResult(result); -} - -} // namespace internal - -} // namespace testing -// Copyright 2008 Google Inc. -// All Rights Reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) - - - -namespace testing { -namespace internal { - -#if GTEST_HAS_TYPED_TEST_P - -// Skips to the first non-space char in str. Returns an empty string if str -// contains only whitespace characters. -static const char* SkipSpaces(const char* str) { - while (IsSpace(*str)) - str++; - return str; -} - -static std::vector SplitIntoTestNames(const char* src) { - std::vector name_vec; - src = SkipSpaces(src); - for (; src != NULL; src = SkipComma(src)) { - name_vec.push_back(StripTrailingSpaces(GetPrefixUntilComma(src))); - } - return name_vec; -} - -// Verifies that registered_tests match the test names in -// registered_tests_; returns registered_tests if successful, or -// aborts the program otherwise. -const char* TypedTestCasePState::VerifyRegisteredTestNames( - const char* file, int line, const char* registered_tests) { - typedef RegisteredTestsMap::const_iterator RegisteredTestIter; - registered_ = true; - - std::vector name_vec = SplitIntoTestNames(registered_tests); - - Message errors; - - std::set tests; - for (std::vector::const_iterator name_it = name_vec.begin(); - name_it != name_vec.end(); ++name_it) { - const std::string& name = *name_it; - if (tests.count(name) != 0) { - errors << "Test " << name << " is listed more than once.\n"; - continue; - } - - bool found = false; - for (RegisteredTestIter it = registered_tests_.begin(); - it != registered_tests_.end(); - ++it) { - if (name == it->first) { - found = true; - break; - } - } - - if (found) { - tests.insert(name); - } else { - errors << "No test named " << name - << " can be found in this test case.\n"; - } - } - - for (RegisteredTestIter it = registered_tests_.begin(); - it != registered_tests_.end(); - ++it) { - if (tests.count(it->first) == 0) { - errors << "You forgot to list test " << it->first << ".\n"; - } - } - - const std::string& errors_str = errors.GetString(); - if (errors_str != "") { - fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(), - errors_str.c_str()); - fflush(stderr); - posix::Abort(); - } - - return registered_tests; -} - -#endif // GTEST_HAS_TYPED_TEST_P - -} // namespace internal -} // namespace testing -// Copyright 2008, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) -// -// Google C++ Mocking Framework (Google Mock) -// -// This file #includes all Google Mock implementation .cc files. The -// purpose is to allow a user to build Google Mock by compiling this -// file alone. - -// This line ensures that gmock.h can be compiled on its own, even -// when it's fused. -#include "gmock/gmock.h" - -// The following lines pull in the real gmock *.cc files. -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) - -// Google Mock - a framework for writing C++ mock classes. -// -// This file implements cardinalities. - - -#include -#include // NOLINT -#include -#include - -namespace testing { - -namespace { - -// Implements the Between(m, n) cardinality. -class BetweenCardinalityImpl : public CardinalityInterface { - public: - BetweenCardinalityImpl(int min, int max) - : min_(min >= 0 ? min : 0), - max_(max >= min_ ? max : min_) { - std::stringstream ss; - if (min < 0) { - ss << "The invocation lower bound must be >= 0, " - << "but is actually " << min << "."; - internal::Expect(false, __FILE__, __LINE__, ss.str()); - } else if (max < 0) { - ss << "The invocation upper bound must be >= 0, " - << "but is actually " << max << "."; - internal::Expect(false, __FILE__, __LINE__, ss.str()); - } else if (min > max) { - ss << "The invocation upper bound (" << max - << ") must be >= the invocation lower bound (" << min - << ")."; - internal::Expect(false, __FILE__, __LINE__, ss.str()); - } - } - - // Conservative estimate on the lower/upper bound of the number of - // calls allowed. - virtual int ConservativeLowerBound() const { return min_; } - virtual int ConservativeUpperBound() const { return max_; } - - virtual bool IsSatisfiedByCallCount(int call_count) const { - return min_ <= call_count && call_count <= max_; - } - - virtual bool IsSaturatedByCallCount(int call_count) const { - return call_count >= max_; - } - - virtual void DescribeTo(::std::ostream* os) const; - - private: - const int min_; - const int max_; - - GTEST_DISALLOW_COPY_AND_ASSIGN_(BetweenCardinalityImpl); -}; - -// Formats "n times" in a human-friendly way. -inline std::string FormatTimes(int n) { - if (n == 1) { - return "once"; - } else if (n == 2) { - return "twice"; - } else { - std::stringstream ss; - ss << n << " times"; - return ss.str(); - } -} - -// Describes the Between(m, n) cardinality in human-friendly text. -void BetweenCardinalityImpl::DescribeTo(::std::ostream* os) const { - if (min_ == 0) { - if (max_ == 0) { - *os << "never called"; - } else if (max_ == INT_MAX) { - *os << "called any number of times"; - } else { - *os << "called at most " << FormatTimes(max_); - } - } else if (min_ == max_) { - *os << "called " << FormatTimes(min_); - } else if (max_ == INT_MAX) { - *os << "called at least " << FormatTimes(min_); - } else { - // 0 < min_ < max_ < INT_MAX - *os << "called between " << min_ << " and " << max_ << " times"; - } -} - -} // Unnamed namespace - -// Describes the given call count to an ostream. -void Cardinality::DescribeActualCallCountTo(int actual_call_count, - ::std::ostream* os) { - if (actual_call_count > 0) { - *os << "called " << FormatTimes(actual_call_count); - } else { - *os << "never called"; - } -} - -// Creates a cardinality that allows at least n calls. -GTEST_API_ Cardinality AtLeast(int n) { return Between(n, INT_MAX); } - -// Creates a cardinality that allows at most n calls. -GTEST_API_ Cardinality AtMost(int n) { return Between(0, n); } - -// Creates a cardinality that allows any number of calls. -GTEST_API_ Cardinality AnyNumber() { return AtLeast(0); } - -// Creates a cardinality that allows between min and max calls. -GTEST_API_ Cardinality Between(int min, int max) { - return Cardinality(new BetweenCardinalityImpl(min, max)); -} - -// Creates a cardinality that allows exactly n calls. -GTEST_API_ Cardinality Exactly(int n) { return Between(n, n); } - -} // namespace testing -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) - -// Google Mock - a framework for writing C++ mock classes. -// -// This file defines some utilities useful for implementing Google -// Mock. They are subject to change without notice, so please DO NOT -// USE THEM IN USER CODE. - - -#include -#include // NOLINT -#include - -namespace testing { -namespace internal { - -// Joins a vector of strings as if they are fields of a tuple; returns -// the joined string. -GTEST_API_ std::string JoinAsTuple(const Strings& fields) { - switch (fields.size()) { - case 0: - return ""; - case 1: - return fields[0]; - default: - std::string result = "(" + fields[0]; - for (size_t i = 1; i < fields.size(); i++) { - result += ", "; - result += fields[i]; - } - result += ")"; - return result; - } -} - -// Converts an identifier name to a space-separated list of lower-case -// words. Each maximum substring of the form [A-Za-z][a-z]*|\d+ is -// treated as one word. For example, both "FooBar123" and -// "foo_bar_123" are converted to "foo bar 123". -GTEST_API_ std::string ConvertIdentifierNameToWords(const char* id_name) { - std::string result; - char prev_char = '\0'; - for (const char* p = id_name; *p != '\0'; prev_char = *(p++)) { - // We don't care about the current locale as the input is - // guaranteed to be a valid C++ identifier name. - const bool starts_new_word = IsUpper(*p) || - (!IsAlpha(prev_char) && IsLower(*p)) || - (!IsDigit(prev_char) && IsDigit(*p)); - - if (IsAlNum(*p)) { - if (starts_new_word && result != "") - result += ' '; - result += ToLower(*p); - } - } - return result; -} - -// This class reports Google Mock failures as Google Test failures. A -// user can define another class in a similar fashion if they intend to -// use Google Mock with a testing framework other than Google Test. -class GoogleTestFailureReporter : public FailureReporterInterface { - public: - virtual void ReportFailure(FailureType type, const char* file, int line, - const std::string& message) { - AssertHelper(type == kFatal ? - TestPartResult::kFatalFailure : - TestPartResult::kNonFatalFailure, - file, - line, - message.c_str()) = Message(); - if (type == kFatal) { - posix::Abort(); - } - } -}; - -// Returns the global failure reporter. Will create a -// GoogleTestFailureReporter and return it the first time called. -GTEST_API_ FailureReporterInterface* GetFailureReporter() { - // Points to the global failure reporter used by Google Mock. gcc - // guarantees that the following use of failure_reporter is - // thread-safe. We may need to add additional synchronization to - // protect failure_reporter if we port Google Mock to other - // compilers. - static FailureReporterInterface* const failure_reporter = - new GoogleTestFailureReporter(); - return failure_reporter; -} - -// Protects global resources (stdout in particular) used by Log(). -static GTEST_DEFINE_STATIC_MUTEX_(g_log_mutex); - -// Returns true iff a log with the given severity is visible according -// to the --gmock_verbose flag. -GTEST_API_ bool LogIsVisible(LogSeverity severity) { - if (GMOCK_FLAG(verbose) == kInfoVerbosity) { - // Always show the log if --gmock_verbose=info. - return true; - } else if (GMOCK_FLAG(verbose) == kErrorVerbosity) { - // Always hide it if --gmock_verbose=error. - return false; - } else { - // If --gmock_verbose is neither "info" nor "error", we treat it - // as "warning" (its default value). - return severity == kWarning; - } -} - -// Prints the given message to stdout iff 'severity' >= the level -// specified by the --gmock_verbose flag. If stack_frames_to_skip >= -// 0, also prints the stack trace excluding the top -// stack_frames_to_skip frames. In opt mode, any positive -// stack_frames_to_skip is treated as 0, since we don't know which -// function calls will be inlined by the compiler and need to be -// conservative. -GTEST_API_ void Log(LogSeverity severity, const std::string& message, - int stack_frames_to_skip) { - if (!LogIsVisible(severity)) - return; - - // Ensures that logs from different threads don't interleave. - MutexLock l(&g_log_mutex); - - // "using ::std::cout;" doesn't work with Symbian's STLport, where cout is a - // macro. - - if (severity == kWarning) { - // Prints a GMOCK WARNING marker to make the warnings easily searchable. - std::cout << "\nGMOCK WARNING:"; - } - // Pre-pends a new-line to message if it doesn't start with one. - if (message.empty() || message[0] != '\n') { - std::cout << "\n"; - } - std::cout << message; - if (stack_frames_to_skip >= 0) { -#ifdef NDEBUG - // In opt mode, we have to be conservative and skip no stack frame. - const int actual_to_skip = 0; -#else - // In dbg mode, we can do what the caller tell us to do (plus one - // for skipping this function's stack frame). - const int actual_to_skip = stack_frames_to_skip + 1; -#endif // NDEBUG - - // Appends a new-line to message if it doesn't end with one. - if (!message.empty() && *message.rbegin() != '\n') { - std::cout << "\n"; - } - std::cout << "Stack trace:\n" - << ::testing::internal::GetCurrentOsStackTraceExceptTop( - ::testing::UnitTest::GetInstance(), actual_to_skip); - } - std::cout << ::std::flush; -} - -GTEST_API_ WithoutMatchers GetWithoutMatchers() { return WithoutMatchers(); } - -GTEST_API_ void IllegalDoDefault(const char* file, int line) { - internal::Assert( - false, file, line, - "You are using DoDefault() inside a composite action like " - "DoAll() or WithArgs(). This is not supported for technical " - "reasons. Please instead spell out the default action, or " - "assign the default action to an Action variable and use " - "the variable in various places."); -} - -} // namespace internal -} // namespace testing -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) - -// Google Mock - a framework for writing C++ mock classes. -// -// This file implements Matcher, Matcher, and -// utilities for defining matchers. - - -#include -#include -#include -#include - -namespace testing { - -// Constructs a matcher that matches a const std::string& whose value is -// equal to s. -Matcher::Matcher(const std::string& s) { *this = Eq(s); } - -#if GTEST_HAS_GLOBAL_STRING -// Constructs a matcher that matches a const std::string& whose value is -// equal to s. -Matcher::Matcher(const ::string& s) { - *this = Eq(static_cast(s)); -} -#endif // GTEST_HAS_GLOBAL_STRING - -// Constructs a matcher that matches a const std::string& whose value is -// equal to s. -Matcher::Matcher(const char* s) { - *this = Eq(std::string(s)); -} - -// Constructs a matcher that matches a std::string whose value is equal to -// s. -Matcher::Matcher(const std::string& s) { *this = Eq(s); } - -#if GTEST_HAS_GLOBAL_STRING -// Constructs a matcher that matches a std::string whose value is equal to -// s. -Matcher::Matcher(const ::string& s) { - *this = Eq(static_cast(s)); -} -#endif // GTEST_HAS_GLOBAL_STRING - -// Constructs a matcher that matches a std::string whose value is equal to -// s. -Matcher::Matcher(const char* s) { *this = Eq(std::string(s)); } - -#if GTEST_HAS_GLOBAL_STRING -// Constructs a matcher that matches a const ::string& whose value is -// equal to s. -Matcher::Matcher(const std::string& s) { - *this = Eq(static_cast<::string>(s)); -} - -// Constructs a matcher that matches a const ::string& whose value is -// equal to s. -Matcher::Matcher(const ::string& s) { *this = Eq(s); } - -// Constructs a matcher that matches a const ::string& whose value is -// equal to s. -Matcher::Matcher(const char* s) { *this = Eq(::string(s)); } - -// Constructs a matcher that matches a ::string whose value is equal to s. -Matcher<::string>::Matcher(const std::string& s) { - *this = Eq(static_cast<::string>(s)); -} - -// Constructs a matcher that matches a ::string whose value is equal to s. -Matcher<::string>::Matcher(const ::string& s) { *this = Eq(s); } - -// Constructs a matcher that matches a string whose value is equal to s. -Matcher<::string>::Matcher(const char* s) { *this = Eq(::string(s)); } -#endif // GTEST_HAS_GLOBAL_STRING - -#if GTEST_HAS_ABSL -// Constructs a matcher that matches a const absl::string_view& whose value is -// equal to s. -Matcher::Matcher(const std::string& s) { - *this = Eq(s); -} - -#if GTEST_HAS_GLOBAL_STRING -// Constructs a matcher that matches a const absl::string_view& whose value is -// equal to s. -Matcher::Matcher(const ::string& s) { *this = Eq(s); } -#endif // GTEST_HAS_GLOBAL_STRING - -// Constructs a matcher that matches a const absl::string_view& whose value is -// equal to s. -Matcher::Matcher(const char* s) { - *this = Eq(std::string(s)); -} - -// Constructs a matcher that matches a const absl::string_view& whose value is -// equal to s. -Matcher::Matcher(absl::string_view s) { - *this = Eq(std::string(s)); -} - -// Constructs a matcher that matches a absl::string_view whose value is equal to -// s. -Matcher::Matcher(const std::string& s) { *this = Eq(s); } - -#if GTEST_HAS_GLOBAL_STRING -// Constructs a matcher that matches a absl::string_view whose value is equal to -// s. -Matcher::Matcher(const ::string& s) { *this = Eq(s); } -#endif // GTEST_HAS_GLOBAL_STRING - -// Constructs a matcher that matches a absl::string_view whose value is equal to -// s. -Matcher::Matcher(const char* s) { - *this = Eq(std::string(s)); -} - -// Constructs a matcher that matches a absl::string_view whose value is equal to -// s. -Matcher::Matcher(absl::string_view s) { - *this = Eq(std::string(s)); -} -#endif // GTEST_HAS_ABSL - -namespace internal { - -// Returns the description for a matcher defined using the MATCHER*() -// macro where the user-supplied description string is "", if -// 'negation' is false; otherwise returns the description of the -// negation of the matcher. 'param_values' contains a list of strings -// that are the print-out of the matcher's parameters. -GTEST_API_ std::string FormatMatcherDescription(bool negation, - const char* matcher_name, - const Strings& param_values) { - std::string result = ConvertIdentifierNameToWords(matcher_name); - if (param_values.size() >= 1) result += " " + JoinAsTuple(param_values); - return negation ? "not (" + result + ")" : result; -} - -// FindMaxBipartiteMatching and its helper class. -// -// Uses the well-known Ford-Fulkerson max flow method to find a maximum -// bipartite matching. Flow is considered to be from left to right. -// There is an implicit source node that is connected to all of the left -// nodes, and an implicit sink node that is connected to all of the -// right nodes. All edges have unit capacity. -// -// Neither the flow graph nor the residual flow graph are represented -// explicitly. Instead, they are implied by the information in 'graph' and -// a vector called 'left_' whose elements are initialized to the -// value kUnused. This represents the initial state of the algorithm, -// where the flow graph is empty, and the residual flow graph has the -// following edges: -// - An edge from source to each left_ node -// - An edge from each right_ node to sink -// - An edge from each left_ node to each right_ node, if the -// corresponding edge exists in 'graph'. -// -// When the TryAugment() method adds a flow, it sets left_[l] = r for some -// nodes l and r. This induces the following changes: -// - The edges (source, l), (l, r), and (r, sink) are added to the -// flow graph. -// - The same three edges are removed from the residual flow graph. -// - The reverse edges (l, source), (r, l), and (sink, r) are added -// to the residual flow graph, which is a directional graph -// representing unused flow capacity. -// -// When the method augments a flow (moving left_[l] from some r1 to some -// other r2), this can be thought of as "undoing" the above steps with -// respect to r1 and "redoing" them with respect to r2. -// -// It bears repeating that the flow graph and residual flow graph are -// never represented explicitly, but can be derived by looking at the -// information in 'graph' and in left_. -// -// As an optimization, there is a second vector called right_ which -// does not provide any new information. Instead, it enables more -// efficient queries about edges entering or leaving the right-side nodes -// of the flow or residual flow graphs. The following invariants are -// maintained: -// -// left[l] == kUnused or right[left[l]] == l -// right[r] == kUnused or left[right[r]] == r -// -// . [ source ] . -// . ||| . -// . ||| . -// . ||\--> left[0]=1 ---\ right[0]=-1 ----\ . -// . || | | . -// . |\---> left[1]=-1 \--> right[1]=0 ---\| . -// . | || . -// . \----> left[2]=2 ------> right[2]=2 --\|| . -// . ||| . -// . elements matchers vvv . -// . [ sink ] . -// -// See Also: -// [1] Cormen, et al (2001). "Section 26.2: The Ford-Fulkerson method". -// "Introduction to Algorithms (Second ed.)", pp. 651-664. -// [2] "Ford-Fulkerson algorithm", Wikipedia, -// 'http://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm' -class MaxBipartiteMatchState { - public: - explicit MaxBipartiteMatchState(const MatchMatrix& graph) - : graph_(&graph), - left_(graph_->LhsSize(), kUnused), - right_(graph_->RhsSize(), kUnused) {} - - // Returns the edges of a maximal match, each in the form {left, right}. - ElementMatcherPairs Compute() { - // 'seen' is used for path finding { 0: unseen, 1: seen }. - ::std::vector seen; - // Searches the residual flow graph for a path from each left node to - // the sink in the residual flow graph, and if one is found, add flow - // to the graph. It's okay to search through the left nodes once. The - // edge from the implicit source node to each previously-visited left - // node will have flow if that left node has any path to the sink - // whatsoever. Subsequent augmentations can only add flow to the - // network, and cannot take away that previous flow unit from the source. - // Since the source-to-left edge can only carry one flow unit (or, - // each element can be matched to only one matcher), there is no need - // to visit the left nodes more than once looking for augmented paths. - // The flow is known to be possible or impossible by looking at the - // node once. - for (size_t ilhs = 0; ilhs < graph_->LhsSize(); ++ilhs) { - // Reset the path-marking vector and try to find a path from - // source to sink starting at the left_[ilhs] node. - GTEST_CHECK_(left_[ilhs] == kUnused) - << "ilhs: " << ilhs << ", left_[ilhs]: " << left_[ilhs]; - // 'seen' initialized to 'graph_->RhsSize()' copies of 0. - seen.assign(graph_->RhsSize(), 0); - TryAugment(ilhs, &seen); - } - ElementMatcherPairs result; - for (size_t ilhs = 0; ilhs < left_.size(); ++ilhs) { - size_t irhs = left_[ilhs]; - if (irhs == kUnused) continue; - result.push_back(ElementMatcherPair(ilhs, irhs)); - } - return result; - } - - private: - static const size_t kUnused = static_cast(-1); - - // Perform a depth-first search from left node ilhs to the sink. If a - // path is found, flow is added to the network by linking the left and - // right vector elements corresponding each segment of the path. - // Returns true if a path to sink was found, which means that a unit of - // flow was added to the network. The 'seen' vector elements correspond - // to right nodes and are marked to eliminate cycles from the search. - // - // Left nodes will only be explored at most once because they - // are accessible from at most one right node in the residual flow - // graph. - // - // Note that left_[ilhs] is the only element of left_ that TryAugment will - // potentially transition from kUnused to another value. Any other - // left_ element holding kUnused before TryAugment will be holding it - // when TryAugment returns. - // - bool TryAugment(size_t ilhs, ::std::vector* seen) { - for (size_t irhs = 0; irhs < graph_->RhsSize(); ++irhs) { - if ((*seen)[irhs]) continue; - if (!graph_->HasEdge(ilhs, irhs)) continue; - // There's an available edge from ilhs to irhs. - (*seen)[irhs] = 1; - // Next a search is performed to determine whether - // this edge is a dead end or leads to the sink. - // - // right_[irhs] == kUnused means that there is residual flow from - // right node irhs to the sink, so we can use that to finish this - // flow path and return success. - // - // Otherwise there is residual flow to some ilhs. We push flow - // along that path and call ourselves recursively to see if this - // ultimately leads to sink. - if (right_[irhs] == kUnused || TryAugment(right_[irhs], seen)) { - // Add flow from left_[ilhs] to right_[irhs]. - left_[ilhs] = irhs; - right_[irhs] = ilhs; - return true; - } - } - return false; - } - - const MatchMatrix* graph_; // not owned - // Each element of the left_ vector represents a left hand side node - // (i.e. an element) and each element of right_ is a right hand side - // node (i.e. a matcher). The values in the left_ vector indicate - // outflow from that node to a node on the right_ side. The values - // in the right_ indicate inflow, and specify which left_ node is - // feeding that right_ node, if any. For example, left_[3] == 1 means - // there's a flow from element #3 to matcher #1. Such a flow would also - // be redundantly represented in the right_ vector as right_[1] == 3. - // Elements of left_ and right_ are either kUnused or mutually - // referent. Mutually referent means that left_[right_[i]] = i and - // right_[left_[i]] = i. - ::std::vector left_; - ::std::vector right_; - - GTEST_DISALLOW_ASSIGN_(MaxBipartiteMatchState); -}; - -const size_t MaxBipartiteMatchState::kUnused; - -GTEST_API_ ElementMatcherPairs FindMaxBipartiteMatching(const MatchMatrix& g) { - return MaxBipartiteMatchState(g).Compute(); -} - -static void LogElementMatcherPairVec(const ElementMatcherPairs& pairs, - ::std::ostream* stream) { - typedef ElementMatcherPairs::const_iterator Iter; - ::std::ostream& os = *stream; - os << "{"; - const char* sep = ""; - for (Iter it = pairs.begin(); it != pairs.end(); ++it) { - os << sep << "\n (" - << "element #" << it->first << ", " - << "matcher #" << it->second << ")"; - sep = ","; - } - os << "\n}"; -} - -bool MatchMatrix::NextGraph() { - for (size_t ilhs = 0; ilhs < LhsSize(); ++ilhs) { - for (size_t irhs = 0; irhs < RhsSize(); ++irhs) { - char& b = matched_[SpaceIndex(ilhs, irhs)]; - if (!b) { - b = 1; - return true; - } - b = 0; - } - } - return false; -} - -void MatchMatrix::Randomize() { - for (size_t ilhs = 0; ilhs < LhsSize(); ++ilhs) { - for (size_t irhs = 0; irhs < RhsSize(); ++irhs) { - char& b = matched_[SpaceIndex(ilhs, irhs)]; - b = static_cast(rand() & 1); // NOLINT - } - } -} - -std::string MatchMatrix::DebugString() const { - ::std::stringstream ss; - const char* sep = ""; - for (size_t i = 0; i < LhsSize(); ++i) { - ss << sep; - for (size_t j = 0; j < RhsSize(); ++j) { - ss << HasEdge(i, j); - } - sep = ";"; - } - return ss.str(); -} - -void UnorderedElementsAreMatcherImplBase::DescribeToImpl( - ::std::ostream* os) const { - switch (match_flags()) { - case UnorderedMatcherRequire::ExactMatch: - if (matcher_describers_.empty()) { - *os << "is empty"; - return; - } - if (matcher_describers_.size() == 1) { - *os << "has " << Elements(1) << " and that element "; - matcher_describers_[0]->DescribeTo(os); - return; - } - *os << "has " << Elements(matcher_describers_.size()) - << " and there exists some permutation of elements such that:\n"; - break; - case UnorderedMatcherRequire::Superset: - *os << "a surjection from elements to requirements exists such that:\n"; - break; - case UnorderedMatcherRequire::Subset: - *os << "an injection from elements to requirements exists such that:\n"; - break; - } - - const char* sep = ""; - for (size_t i = 0; i != matcher_describers_.size(); ++i) { - *os << sep; - if (match_flags() == UnorderedMatcherRequire::ExactMatch) { - *os << " - element #" << i << " "; - } else { - *os << " - an element "; - } - matcher_describers_[i]->DescribeTo(os); - if (match_flags() == UnorderedMatcherRequire::ExactMatch) { - sep = ", and\n"; - } else { - sep = "\n"; - } - } -} - -void UnorderedElementsAreMatcherImplBase::DescribeNegationToImpl( - ::std::ostream* os) const { - switch (match_flags()) { - case UnorderedMatcherRequire::ExactMatch: - if (matcher_describers_.empty()) { - *os << "isn't empty"; - return; - } - if (matcher_describers_.size() == 1) { - *os << "doesn't have " << Elements(1) << ", or has " << Elements(1) - << " that "; - matcher_describers_[0]->DescribeNegationTo(os); - return; - } - *os << "doesn't have " << Elements(matcher_describers_.size()) - << ", or there exists no permutation of elements such that:\n"; - break; - case UnorderedMatcherRequire::Superset: - *os << "no surjection from elements to requirements exists such that:\n"; - break; - case UnorderedMatcherRequire::Subset: - *os << "no injection from elements to requirements exists such that:\n"; - break; - } - const char* sep = ""; - for (size_t i = 0; i != matcher_describers_.size(); ++i) { - *os << sep; - if (match_flags() == UnorderedMatcherRequire::ExactMatch) { - *os << " - element #" << i << " "; - } else { - *os << " - an element "; - } - matcher_describers_[i]->DescribeTo(os); - if (match_flags() == UnorderedMatcherRequire::ExactMatch) { - sep = ", and\n"; - } else { - sep = "\n"; - } - } -} - -// Checks that all matchers match at least one element, and that all -// elements match at least one matcher. This enables faster matching -// and better error reporting. -// Returns false, writing an explanation to 'listener', if and only -// if the success criteria are not met. -bool UnorderedElementsAreMatcherImplBase::VerifyMatchMatrix( - const ::std::vector& element_printouts, - const MatchMatrix& matrix, MatchResultListener* listener) const { - bool result = true; - ::std::vector element_matched(matrix.LhsSize(), 0); - ::std::vector matcher_matched(matrix.RhsSize(), 0); - - for (size_t ilhs = 0; ilhs < matrix.LhsSize(); ilhs++) { - for (size_t irhs = 0; irhs < matrix.RhsSize(); irhs++) { - char matched = matrix.HasEdge(ilhs, irhs); - element_matched[ilhs] |= matched; - matcher_matched[irhs] |= matched; - } - } - - if (match_flags() & UnorderedMatcherRequire::Superset) { - const char* sep = - "where the following matchers don't match any elements:\n"; - for (size_t mi = 0; mi < matcher_matched.size(); ++mi) { - if (matcher_matched[mi]) continue; - result = false; - if (listener->IsInterested()) { - *listener << sep << "matcher #" << mi << ": "; - matcher_describers_[mi]->DescribeTo(listener->stream()); - sep = ",\n"; - } - } - } - - if (match_flags() & UnorderedMatcherRequire::Subset) { - const char* sep = - "where the following elements don't match any matchers:\n"; - const char* outer_sep = ""; - if (!result) { - outer_sep = "\nand "; - } - for (size_t ei = 0; ei < element_matched.size(); ++ei) { - if (element_matched[ei]) continue; - result = false; - if (listener->IsInterested()) { - *listener << outer_sep << sep << "element #" << ei << ": " - << element_printouts[ei]; - sep = ",\n"; - outer_sep = ""; - } - } - } - return result; -} - -bool UnorderedElementsAreMatcherImplBase::FindPairing( - const MatchMatrix& matrix, MatchResultListener* listener) const { - ElementMatcherPairs matches = FindMaxBipartiteMatching(matrix); - - size_t max_flow = matches.size(); - if ((match_flags() & UnorderedMatcherRequire::Superset) && - max_flow < matrix.RhsSize()) { - if (listener->IsInterested()) { - *listener << "where no permutation of the elements can satisfy all " - "matchers, and the closest match is " - << max_flow << " of " << matrix.RhsSize() - << " matchers with the pairings:\n"; - LogElementMatcherPairVec(matches, listener->stream()); - } - return false; - } - if ((match_flags() & UnorderedMatcherRequire::Subset) && - max_flow < matrix.LhsSize()) { - if (listener->IsInterested()) { - *listener - << "where not all elements can be matched, and the closest match is " - << max_flow << " of " << matrix.RhsSize() - << " matchers with the pairings:\n"; - LogElementMatcherPairVec(matches, listener->stream()); - } - return false; - } - - if (matches.size() > 1) { - if (listener->IsInterested()) { - const char* sep = "where:\n"; - for (size_t mi = 0; mi < matches.size(); ++mi) { - *listener << sep << " - element #" << matches[mi].first - << " is matched by matcher #" << matches[mi].second; - sep = ",\n"; - } - } - } - return true; -} - -} // namespace internal -} // namespace testing -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) - -// Google Mock - a framework for writing C++ mock classes. -// -// This file implements the spec builder syntax (ON_CALL and -// EXPECT_CALL). - - -#include -#include // NOLINT -#include -#include -#include -#include - -#if GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC -# include // NOLINT -#endif - -// Silence C4800 (C4800: 'int *const ': forcing value -// to bool 'true' or 'false') for MSVC 14,15 -#ifdef _MSC_VER -#if _MSC_VER <= 1900 -# pragma warning(push) -# pragma warning(disable:4800) -#endif -#endif - -namespace testing { -namespace internal { - -// Protects the mock object registry (in class Mock), all function -// mockers, and all expectations. -GTEST_API_ GTEST_DEFINE_STATIC_MUTEX_(g_gmock_mutex); - -// Logs a message including file and line number information. -GTEST_API_ void LogWithLocation(testing::internal::LogSeverity severity, - const char* file, int line, - const std::string& message) { - ::std::ostringstream s; - s << file << ":" << line << ": " << message << ::std::endl; - Log(severity, s.str(), 0); -} - -// Constructs an ExpectationBase object. -ExpectationBase::ExpectationBase(const char* a_file, int a_line, - const std::string& a_source_text) - : file_(a_file), - line_(a_line), - source_text_(a_source_text), - cardinality_specified_(false), - cardinality_(Exactly(1)), - call_count_(0), - retired_(false), - extra_matcher_specified_(false), - repeated_action_specified_(false), - retires_on_saturation_(false), - last_clause_(kNone), - action_count_checked_(false) {} - -// Destructs an ExpectationBase object. -ExpectationBase::~ExpectationBase() {} - -// Explicitly specifies the cardinality of this expectation. Used by -// the subclasses to implement the .Times() clause. -void ExpectationBase::SpecifyCardinality(const Cardinality& a_cardinality) { - cardinality_specified_ = true; - cardinality_ = a_cardinality; -} - -// Retires all pre-requisites of this expectation. -void ExpectationBase::RetireAllPreRequisites() - GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { - if (is_retired()) { - // We can take this short-cut as we never retire an expectation - // until we have retired all its pre-requisites. - return; - } - - ::std::vector expectations(1, this); - while (!expectations.empty()) { - ExpectationBase* exp = expectations.back(); - expectations.pop_back(); - - for (ExpectationSet::const_iterator it = - exp->immediate_prerequisites_.begin(); - it != exp->immediate_prerequisites_.end(); ++it) { - ExpectationBase* next = it->expectation_base().get(); - if (!next->is_retired()) { - next->Retire(); - expectations.push_back(next); - } - } - } -} - -// Returns true iff all pre-requisites of this expectation have been -// satisfied. -bool ExpectationBase::AllPrerequisitesAreSatisfied() const - GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { - g_gmock_mutex.AssertHeld(); - ::std::vector expectations(1, this); - while (!expectations.empty()) { - const ExpectationBase* exp = expectations.back(); - expectations.pop_back(); - - for (ExpectationSet::const_iterator it = - exp->immediate_prerequisites_.begin(); - it != exp->immediate_prerequisites_.end(); ++it) { - const ExpectationBase* next = it->expectation_base().get(); - if (!next->IsSatisfied()) return false; - expectations.push_back(next); - } - } - return true; -} - -// Adds unsatisfied pre-requisites of this expectation to 'result'. -void ExpectationBase::FindUnsatisfiedPrerequisites(ExpectationSet* result) const - GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { - g_gmock_mutex.AssertHeld(); - ::std::vector expectations(1, this); - while (!expectations.empty()) { - const ExpectationBase* exp = expectations.back(); - expectations.pop_back(); - - for (ExpectationSet::const_iterator it = - exp->immediate_prerequisites_.begin(); - it != exp->immediate_prerequisites_.end(); ++it) { - const ExpectationBase* next = it->expectation_base().get(); - - if (next->IsSatisfied()) { - // If *it is satisfied and has a call count of 0, some of its - // pre-requisites may not be satisfied yet. - if (next->call_count_ == 0) { - expectations.push_back(next); - } - } else { - // Now that we know next is unsatisfied, we are not so interested - // in whether its pre-requisites are satisfied. Therefore we - // don't iterate into it here. - *result += *it; - } - } - } -} - -// Describes how many times a function call matching this -// expectation has occurred. -void ExpectationBase::DescribeCallCountTo(::std::ostream* os) const - GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { - g_gmock_mutex.AssertHeld(); - - // Describes how many times the function is expected to be called. - *os << " Expected: to be "; - cardinality().DescribeTo(os); - *os << "\n Actual: "; - Cardinality::DescribeActualCallCountTo(call_count(), os); - - // Describes the state of the expectation (e.g. is it satisfied? - // is it active?). - *os << " - " << (IsOverSaturated() ? "over-saturated" : - IsSaturated() ? "saturated" : - IsSatisfied() ? "satisfied" : "unsatisfied") - << " and " - << (is_retired() ? "retired" : "active"); -} - -// Checks the action count (i.e. the number of WillOnce() and -// WillRepeatedly() clauses) against the cardinality if this hasn't -// been done before. Prints a warning if there are too many or too -// few actions. -void ExpectationBase::CheckActionCountIfNotDone() const - GTEST_LOCK_EXCLUDED_(mutex_) { - bool should_check = false; - { - MutexLock l(&mutex_); - if (!action_count_checked_) { - action_count_checked_ = true; - should_check = true; - } - } - - if (should_check) { - if (!cardinality_specified_) { - // The cardinality was inferred - no need to check the action - // count against it. - return; - } - - // The cardinality was explicitly specified. - const int action_count = static_cast(untyped_actions_.size()); - const int upper_bound = cardinality().ConservativeUpperBound(); - const int lower_bound = cardinality().ConservativeLowerBound(); - bool too_many; // True if there are too many actions, or false - // if there are too few. - if (action_count > upper_bound || - (action_count == upper_bound && repeated_action_specified_)) { - too_many = true; - } else if (0 < action_count && action_count < lower_bound && - !repeated_action_specified_) { - too_many = false; - } else { - return; - } - - ::std::stringstream ss; - DescribeLocationTo(&ss); - ss << "Too " << (too_many ? "many" : "few") - << " actions specified in " << source_text() << "...\n" - << "Expected to be "; - cardinality().DescribeTo(&ss); - ss << ", but has " << (too_many ? "" : "only ") - << action_count << " WillOnce()" - << (action_count == 1 ? "" : "s"); - if (repeated_action_specified_) { - ss << " and a WillRepeatedly()"; - } - ss << "."; - Log(kWarning, ss.str(), -1); // -1 means "don't print stack trace". - } -} - -// Implements the .Times() clause. -void ExpectationBase::UntypedTimes(const Cardinality& a_cardinality) { - if (last_clause_ == kTimes) { - ExpectSpecProperty(false, - ".Times() cannot appear " - "more than once in an EXPECT_CALL()."); - } else { - ExpectSpecProperty(last_clause_ < kTimes, - ".Times() cannot appear after " - ".InSequence(), .WillOnce(), .WillRepeatedly(), " - "or .RetiresOnSaturation()."); - } - last_clause_ = kTimes; - - SpecifyCardinality(a_cardinality); -} - -// Points to the implicit sequence introduced by a living InSequence -// object (if any) in the current thread or NULL. -GTEST_API_ ThreadLocal g_gmock_implicit_sequence; - -// Reports an uninteresting call (whose description is in msg) in the -// manner specified by 'reaction'. -void ReportUninterestingCall(CallReaction reaction, const std::string& msg) { - // Include a stack trace only if --gmock_verbose=info is specified. - const int stack_frames_to_skip = - GMOCK_FLAG(verbose) == kInfoVerbosity ? 3 : -1; - switch (reaction) { - case kAllow: - Log(kInfo, msg, stack_frames_to_skip); - break; - case kWarn: - Log(kWarning, - msg + - "\nNOTE: You can safely ignore the above warning unless this " - "call should not happen. Do not suppress it by blindly adding " - "an EXPECT_CALL() if you don't mean to enforce the call. " - "See " - "https://github.com/google/googletest/blob/master/googlemock/" - "docs/CookBook.md#" - "knowing-when-to-expect for details.\n", - stack_frames_to_skip); - break; - default: // FAIL - Expect(false, NULL, -1, msg); - } -} - -UntypedFunctionMockerBase::UntypedFunctionMockerBase() - : mock_obj_(NULL), name_("") {} - -UntypedFunctionMockerBase::~UntypedFunctionMockerBase() {} - -// Sets the mock object this mock method belongs to, and registers -// this information in the global mock registry. Will be called -// whenever an EXPECT_CALL() or ON_CALL() is executed on this mock -// method. -void UntypedFunctionMockerBase::RegisterOwner(const void* mock_obj) - GTEST_LOCK_EXCLUDED_(g_gmock_mutex) { - { - MutexLock l(&g_gmock_mutex); - mock_obj_ = mock_obj; - } - Mock::Register(mock_obj, this); -} - -// Sets the mock object this mock method belongs to, and sets the name -// of the mock function. Will be called upon each invocation of this -// mock function. -void UntypedFunctionMockerBase::SetOwnerAndName(const void* mock_obj, - const char* name) - GTEST_LOCK_EXCLUDED_(g_gmock_mutex) { - // We protect name_ under g_gmock_mutex in case this mock function - // is called from two threads concurrently. - MutexLock l(&g_gmock_mutex); - mock_obj_ = mock_obj; - name_ = name; -} - -// Returns the name of the function being mocked. Must be called -// after RegisterOwner() or SetOwnerAndName() has been called. -const void* UntypedFunctionMockerBase::MockObject() const - GTEST_LOCK_EXCLUDED_(g_gmock_mutex) { - const void* mock_obj; - { - // We protect mock_obj_ under g_gmock_mutex in case this mock - // function is called from two threads concurrently. - MutexLock l(&g_gmock_mutex); - Assert(mock_obj_ != NULL, __FILE__, __LINE__, - "MockObject() must not be called before RegisterOwner() or " - "SetOwnerAndName() has been called."); - mock_obj = mock_obj_; - } - return mock_obj; -} - -// Returns the name of this mock method. Must be called after -// SetOwnerAndName() has been called. -const char* UntypedFunctionMockerBase::Name() const - GTEST_LOCK_EXCLUDED_(g_gmock_mutex) { - const char* name; - { - // We protect name_ under g_gmock_mutex in case this mock - // function is called from two threads concurrently. - MutexLock l(&g_gmock_mutex); - Assert(name_ != NULL, __FILE__, __LINE__, - "Name() must not be called before SetOwnerAndName() has " - "been called."); - name = name_; - } - return name; -} - -// Calculates the result of invoking this mock function with the given -// arguments, prints it, and returns it. The caller is responsible -// for deleting the result. -UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith( - void* const untyped_args) GTEST_LOCK_EXCLUDED_(g_gmock_mutex) { - // See the definition of untyped_expectations_ for why access to it - // is unprotected here. - if (untyped_expectations_.size() == 0) { - // No expectation is set on this mock method - we have an - // uninteresting call. - - // We must get Google Mock's reaction on uninteresting calls - // made on this mock object BEFORE performing the action, - // because the action may DELETE the mock object and make the - // following expression meaningless. - const CallReaction reaction = - Mock::GetReactionOnUninterestingCalls(MockObject()); - - // True iff we need to print this call's arguments and return - // value. This definition must be kept in sync with - // the behavior of ReportUninterestingCall(). - const bool need_to_report_uninteresting_call = - // If the user allows this uninteresting call, we print it - // only when they want informational messages. - reaction == kAllow ? LogIsVisible(kInfo) : - // If the user wants this to be a warning, we print - // it only when they want to see warnings. - reaction == kWarn - ? LogIsVisible(kWarning) - : - // Otherwise, the user wants this to be an error, and we - // should always print detailed information in the error. - true; - - if (!need_to_report_uninteresting_call) { - // Perform the action without printing the call information. - return this->UntypedPerformDefaultAction( - untyped_args, "Function call: " + std::string(Name())); - } - - // Warns about the uninteresting call. - ::std::stringstream ss; - this->UntypedDescribeUninterestingCall(untyped_args, &ss); - - // Calculates the function result. - UntypedActionResultHolderBase* const result = - this->UntypedPerformDefaultAction(untyped_args, ss.str()); - - // Prints the function result. - if (result != NULL) - result->PrintAsActionResult(&ss); - - ReportUninterestingCall(reaction, ss.str()); - return result; - } - - bool is_excessive = false; - ::std::stringstream ss; - ::std::stringstream why; - ::std::stringstream loc; - const void* untyped_action = NULL; - - // The UntypedFindMatchingExpectation() function acquires and - // releases g_gmock_mutex. - const ExpectationBase* const untyped_expectation = - this->UntypedFindMatchingExpectation( - untyped_args, &untyped_action, &is_excessive, - &ss, &why); - const bool found = untyped_expectation != NULL; - - // True iff we need to print the call's arguments and return value. - // This definition must be kept in sync with the uses of Expect() - // and Log() in this function. - const bool need_to_report_call = - !found || is_excessive || LogIsVisible(kInfo); - if (!need_to_report_call) { - // Perform the action without printing the call information. - return - untyped_action == NULL ? - this->UntypedPerformDefaultAction(untyped_args, "") : - this->UntypedPerformAction(untyped_action, untyped_args); - } - - ss << " Function call: " << Name(); - this->UntypedPrintArgs(untyped_args, &ss); - - // In case the action deletes a piece of the expectation, we - // generate the message beforehand. - if (found && !is_excessive) { - untyped_expectation->DescribeLocationTo(&loc); - } - - UntypedActionResultHolderBase* const result = - untyped_action == NULL ? - this->UntypedPerformDefaultAction(untyped_args, ss.str()) : - this->UntypedPerformAction(untyped_action, untyped_args); - if (result != NULL) - result->PrintAsActionResult(&ss); - ss << "\n" << why.str(); - - if (!found) { - // No expectation matches this call - reports a failure. - Expect(false, NULL, -1, ss.str()); - } else if (is_excessive) { - // We had an upper-bound violation and the failure message is in ss. - Expect(false, untyped_expectation->file(), - untyped_expectation->line(), ss.str()); - } else { - // We had an expected call and the matching expectation is - // described in ss. - Log(kInfo, loc.str() + ss.str(), 2); - } - - return result; -} - -// Returns an Expectation object that references and co-owns exp, -// which must be an expectation on this mock function. -Expectation UntypedFunctionMockerBase::GetHandleOf(ExpectationBase* exp) { - // See the definition of untyped_expectations_ for why access to it - // is unprotected here. - for (UntypedExpectations::const_iterator it = - untyped_expectations_.begin(); - it != untyped_expectations_.end(); ++it) { - if (it->get() == exp) { - return Expectation(*it); - } - } - - Assert(false, __FILE__, __LINE__, "Cannot find expectation."); - return Expectation(); - // The above statement is just to make the code compile, and will - // never be executed. -} - -// Verifies that all expectations on this mock function have been -// satisfied. Reports one or more Google Test non-fatal failures -// and returns false if not. -bool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked() - GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { - g_gmock_mutex.AssertHeld(); - bool expectations_met = true; - for (UntypedExpectations::const_iterator it = - untyped_expectations_.begin(); - it != untyped_expectations_.end(); ++it) { - ExpectationBase* const untyped_expectation = it->get(); - if (untyped_expectation->IsOverSaturated()) { - // There was an upper-bound violation. Since the error was - // already reported when it occurred, there is no need to do - // anything here. - expectations_met = false; - } else if (!untyped_expectation->IsSatisfied()) { - expectations_met = false; - ::std::stringstream ss; - ss << "Actual function call count doesn't match " - << untyped_expectation->source_text() << "...\n"; - // No need to show the source file location of the expectation - // in the description, as the Expect() call that follows already - // takes care of it. - untyped_expectation->MaybeDescribeExtraMatcherTo(&ss); - untyped_expectation->DescribeCallCountTo(&ss); - Expect(false, untyped_expectation->file(), - untyped_expectation->line(), ss.str()); - } - } - - // Deleting our expectations may trigger other mock objects to be deleted, for - // example if an action contains a reference counted smart pointer to that - // mock object, and that is the last reference. So if we delete our - // expectations within the context of the global mutex we may deadlock when - // this method is called again. Instead, make a copy of the set of - // expectations to delete, clear our set within the mutex, and then clear the - // copied set outside of it. - UntypedExpectations expectations_to_delete; - untyped_expectations_.swap(expectations_to_delete); - - g_gmock_mutex.Unlock(); - expectations_to_delete.clear(); - g_gmock_mutex.Lock(); - - return expectations_met; -} - -CallReaction intToCallReaction(int mock_behavior) { - if (mock_behavior >= kAllow && mock_behavior <= kFail) { - return static_cast(mock_behavior); - } - return kWarn; -} - -} // namespace internal - -// Class Mock. - -namespace { - -typedef std::set FunctionMockers; - -// The current state of a mock object. Such information is needed for -// detecting leaked mock objects and explicitly verifying a mock's -// expectations. -struct MockObjectState { - MockObjectState() - : first_used_file(NULL), first_used_line(-1), leakable(false) {} - - // Where in the source file an ON_CALL or EXPECT_CALL is first - // invoked on this mock object. - const char* first_used_file; - int first_used_line; - ::std::string first_used_test_case; - ::std::string first_used_test; - bool leakable; // true iff it's OK to leak the object. - FunctionMockers function_mockers; // All registered methods of the object. -}; - -// A global registry holding the state of all mock objects that are -// alive. A mock object is added to this registry the first time -// Mock::AllowLeak(), ON_CALL(), or EXPECT_CALL() is called on it. It -// is removed from the registry in the mock object's destructor. -class MockObjectRegistry { - public: - // Maps a mock object (identified by its address) to its state. - typedef std::map StateMap; - - // This destructor will be called when a program exits, after all - // tests in it have been run. By then, there should be no mock - // object alive. Therefore we report any living object as test - // failure, unless the user explicitly asked us to ignore it. - ~MockObjectRegistry() { - // "using ::std::cout;" doesn't work with Symbian's STLport, where cout is - // a macro. - - if (!GMOCK_FLAG(catch_leaked_mocks)) - return; - - int leaked_count = 0; - for (StateMap::const_iterator it = states_.begin(); it != states_.end(); - ++it) { - if (it->second.leakable) // The user said it's fine to leak this object. - continue; - - // TODO(wan@google.com): Print the type of the leaked object. - // This can help the user identify the leaked object. - std::cout << "\n"; - const MockObjectState& state = it->second; - std::cout << internal::FormatFileLocation(state.first_used_file, - state.first_used_line); - std::cout << " ERROR: this mock object"; - if (state.first_used_test != "") { - std::cout << " (used in test " << state.first_used_test_case << "." - << state.first_used_test << ")"; - } - std::cout << " should be deleted but never is. Its address is @" - << it->first << "."; - leaked_count++; - } - if (leaked_count > 0) { - std::cout << "\nERROR: " << leaked_count << " leaked mock " - << (leaked_count == 1 ? "object" : "objects") - << " found at program exit. Expectations on a mock object is " - "verified when the object is destructed. Leaking a mock " - "means that its expectations aren't verified, which is " - "usually a test bug. If you really intend to leak a mock, " - "you can suppress this error using " - "testing::Mock::AllowLeak(mock_object), or you may use a " - "fake or stub instead of a mock.\n"; - std::cout.flush(); - ::std::cerr.flush(); - // RUN_ALL_TESTS() has already returned when this destructor is - // called. Therefore we cannot use the normal Google Test - // failure reporting mechanism. - _exit(1); // We cannot call exit() as it is not reentrant and - // may already have been called. - } - } - - StateMap& states() { return states_; } - - private: - StateMap states_; -}; - -// Protected by g_gmock_mutex. -MockObjectRegistry g_mock_object_registry; - -// Maps a mock object to the reaction Google Mock should have when an -// uninteresting method is called. Protected by g_gmock_mutex. -std::map g_uninteresting_call_reaction; - -// Sets the reaction Google Mock should have when an uninteresting -// method of the given mock object is called. -void SetReactionOnUninterestingCalls(const void* mock_obj, - internal::CallReaction reaction) - GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { - internal::MutexLock l(&internal::g_gmock_mutex); - g_uninteresting_call_reaction[mock_obj] = reaction; -} - -} // namespace - -// Tells Google Mock to allow uninteresting calls on the given mock -// object. -void Mock::AllowUninterestingCalls(const void* mock_obj) - GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { - SetReactionOnUninterestingCalls(mock_obj, internal::kAllow); -} - -// Tells Google Mock to warn the user about uninteresting calls on the -// given mock object. -void Mock::WarnUninterestingCalls(const void* mock_obj) - GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { - SetReactionOnUninterestingCalls(mock_obj, internal::kWarn); -} - -// Tells Google Mock to fail uninteresting calls on the given mock -// object. -void Mock::FailUninterestingCalls(const void* mock_obj) - GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { - SetReactionOnUninterestingCalls(mock_obj, internal::kFail); -} - -// Tells Google Mock the given mock object is being destroyed and its -// entry in the call-reaction table should be removed. -void Mock::UnregisterCallReaction(const void* mock_obj) - GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { - internal::MutexLock l(&internal::g_gmock_mutex); - g_uninteresting_call_reaction.erase(mock_obj); -} - -// Returns the reaction Google Mock will have on uninteresting calls -// made on the given mock object. -internal::CallReaction Mock::GetReactionOnUninterestingCalls( - const void* mock_obj) - GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { - internal::MutexLock l(&internal::g_gmock_mutex); - return (g_uninteresting_call_reaction.count(mock_obj) == 0) ? - internal::intToCallReaction(GMOCK_FLAG(default_mock_behavior)) : - g_uninteresting_call_reaction[mock_obj]; -} - -// Tells Google Mock to ignore mock_obj when checking for leaked mock -// objects. -void Mock::AllowLeak(const void* mock_obj) - GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { - internal::MutexLock l(&internal::g_gmock_mutex); - g_mock_object_registry.states()[mock_obj].leakable = true; -} - -// Verifies and clears all expectations on the given mock object. If -// the expectations aren't satisfied, generates one or more Google -// Test non-fatal failures and returns false. -bool Mock::VerifyAndClearExpectations(void* mock_obj) - GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { - internal::MutexLock l(&internal::g_gmock_mutex); - return VerifyAndClearExpectationsLocked(mock_obj); -} - -// Verifies all expectations on the given mock object and clears its -// default actions and expectations. Returns true iff the -// verification was successful. -bool Mock::VerifyAndClear(void* mock_obj) - GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { - internal::MutexLock l(&internal::g_gmock_mutex); - ClearDefaultActionsLocked(mock_obj); - return VerifyAndClearExpectationsLocked(mock_obj); -} - -// Verifies and clears all expectations on the given mock object. If -// the expectations aren't satisfied, generates one or more Google -// Test non-fatal failures and returns false. -bool Mock::VerifyAndClearExpectationsLocked(void* mock_obj) - GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex) { - internal::g_gmock_mutex.AssertHeld(); - if (g_mock_object_registry.states().count(mock_obj) == 0) { - // No EXPECT_CALL() was set on the given mock object. - return true; - } - - // Verifies and clears the expectations on each mock method in the - // given mock object. - bool expectations_met = true; - FunctionMockers& mockers = - g_mock_object_registry.states()[mock_obj].function_mockers; - for (FunctionMockers::const_iterator it = mockers.begin(); - it != mockers.end(); ++it) { - if (!(*it)->VerifyAndClearExpectationsLocked()) { - expectations_met = false; - } - } - - // We don't clear the content of mockers, as they may still be - // needed by ClearDefaultActionsLocked(). - return expectations_met; -} - -// Registers a mock object and a mock method it owns. -void Mock::Register(const void* mock_obj, - internal::UntypedFunctionMockerBase* mocker) - GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { - internal::MutexLock l(&internal::g_gmock_mutex); - g_mock_object_registry.states()[mock_obj].function_mockers.insert(mocker); -} - -// Tells Google Mock where in the source code mock_obj is used in an -// ON_CALL or EXPECT_CALL. In case mock_obj is leaked, this -// information helps the user identify which object it is. -void Mock::RegisterUseByOnCallOrExpectCall(const void* mock_obj, - const char* file, int line) - GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { - internal::MutexLock l(&internal::g_gmock_mutex); - MockObjectState& state = g_mock_object_registry.states()[mock_obj]; - if (state.first_used_file == NULL) { - state.first_used_file = file; - state.first_used_line = line; - const TestInfo* const test_info = - UnitTest::GetInstance()->current_test_info(); - if (test_info != NULL) { - // TODO(wan@google.com): record the test case name when the - // ON_CALL or EXPECT_CALL is invoked from SetUpTestCase() or - // TearDownTestCase(). - state.first_used_test_case = test_info->test_case_name(); - state.first_used_test = test_info->name(); - } - } -} - -// Unregisters a mock method; removes the owning mock object from the -// registry when the last mock method associated with it has been -// unregistered. This is called only in the destructor of -// FunctionMockerBase. -void Mock::UnregisterLocked(internal::UntypedFunctionMockerBase* mocker) - GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex) { - internal::g_gmock_mutex.AssertHeld(); - for (MockObjectRegistry::StateMap::iterator it = - g_mock_object_registry.states().begin(); - it != g_mock_object_registry.states().end(); ++it) { - FunctionMockers& mockers = it->second.function_mockers; - if (mockers.erase(mocker) > 0) { - // mocker was in mockers and has been just removed. - if (mockers.empty()) { - g_mock_object_registry.states().erase(it); - } - return; - } - } -} - -// Clears all ON_CALL()s set on the given mock object. -void Mock::ClearDefaultActionsLocked(void* mock_obj) - GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex) { - internal::g_gmock_mutex.AssertHeld(); - - if (g_mock_object_registry.states().count(mock_obj) == 0) { - // No ON_CALL() was set on the given mock object. - return; - } - - // Clears the default actions for each mock method in the given mock - // object. - FunctionMockers& mockers = - g_mock_object_registry.states()[mock_obj].function_mockers; - for (FunctionMockers::const_iterator it = mockers.begin(); - it != mockers.end(); ++it) { - (*it)->ClearDefaultActionsLocked(); - } - - // We don't clear the content of mockers, as they may still be - // needed by VerifyAndClearExpectationsLocked(). -} - -Expectation::Expectation() {} - -Expectation::Expectation( - const internal::linked_ptr& an_expectation_base) - : expectation_base_(an_expectation_base) {} - -Expectation::~Expectation() {} - -// Adds an expectation to a sequence. -void Sequence::AddExpectation(const Expectation& expectation) const { - if (*last_expectation_ != expectation) { - if (last_expectation_->expectation_base() != NULL) { - expectation.expectation_base()->immediate_prerequisites_ - += *last_expectation_; - } - *last_expectation_ = expectation; - } -} - -// Creates the implicit sequence if there isn't one. -InSequence::InSequence() { - if (internal::g_gmock_implicit_sequence.get() == NULL) { - internal::g_gmock_implicit_sequence.set(new Sequence); - sequence_created_ = true; - } else { - sequence_created_ = false; - } -} - -// Deletes the implicit sequence if it was created by the constructor -// of this object. -InSequence::~InSequence() { - if (sequence_created_) { - delete internal::g_gmock_implicit_sequence.get(); - internal::g_gmock_implicit_sequence.set(NULL); - } -} - -} // namespace testing - -#ifdef _MSC_VER -#if _MSC_VER <= 1900 -# pragma warning(pop) -#endif -#endif -// Copyright 2008, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) - - -namespace testing { - -// TODO(wan@google.com): support using environment variables to -// control the flag values, like what Google Test does. - -GMOCK_DEFINE_bool_(catch_leaked_mocks, true, - "true iff Google Mock should report leaked mock objects " - "as failures."); - -GMOCK_DEFINE_string_(verbose, internal::kWarningVerbosity, - "Controls how verbose Google Mock's output is." - " Valid values:\n" - " info - prints all messages.\n" - " warning - prints warnings and errors.\n" - " error - prints errors only."); - -GMOCK_DEFINE_int32_(default_mock_behavior, 1, - "Controls the default behavior of mocks." - " Valid values:\n" - " 0 - by default, mocks act as NiceMocks.\n" - " 1 - by default, mocks act as NaggyMocks.\n" - " 2 - by default, mocks act as StrictMocks."); - -namespace internal { - -// Parses a string as a command line flag. The string should have the -// format "--gmock_flag=value". When def_optional is true, the -// "=value" part can be omitted. -// -// Returns the value of the flag, or NULL if the parsing failed. -static const char* ParseGoogleMockFlagValue(const char* str, - const char* flag, - bool def_optional) { - // str and flag must not be NULL. - if (str == NULL || flag == NULL) return NULL; - - // The flag must start with "--gmock_". - const std::string flag_str = std::string("--gmock_") + flag; - const size_t flag_len = flag_str.length(); - if (strncmp(str, flag_str.c_str(), flag_len) != 0) return NULL; - - // Skips the flag name. - const char* flag_end = str + flag_len; - - // When def_optional is true, it's OK to not have a "=value" part. - if (def_optional && (flag_end[0] == '\0')) { - return flag_end; - } - - // If def_optional is true and there are more characters after the - // flag name, or if def_optional is false, there must be a '=' after - // the flag name. - if (flag_end[0] != '=') return NULL; - - // Returns the string after "=". - return flag_end + 1; -} - -// Parses a string for a Google Mock bool flag, in the form of -// "--gmock_flag=value". -// -// On success, stores the value of the flag in *value, and returns -// true. On failure, returns false without changing *value. -static bool ParseGoogleMockBoolFlag(const char* str, const char* flag, - bool* value) { - // Gets the value of the flag as a string. - const char* const value_str = ParseGoogleMockFlagValue(str, flag, true); - - // Aborts if the parsing failed. - if (value_str == NULL) return false; - - // Converts the string value to a bool. - *value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F'); - return true; -} - -// Parses a string for a Google Mock string flag, in the form of -// "--gmock_flag=value". -// -// On success, stores the value of the flag in *value, and returns -// true. On failure, returns false without changing *value. -template -static bool ParseGoogleMockStringFlag(const char* str, const char* flag, - String* value) { - // Gets the value of the flag as a string. - const char* const value_str = ParseGoogleMockFlagValue(str, flag, false); - - // Aborts if the parsing failed. - if (value_str == NULL) return false; - - // Sets *value to the value of the flag. - *value = value_str; - return true; -} - -static bool ParseGoogleMockIntFlag(const char* str, const char* flag, - int* value) { - // Gets the value of the flag as a string. - const char* const value_str = ParseGoogleMockFlagValue(str, flag, true); - - // Aborts if the parsing failed. - if (value_str == NULL) return false; - - // Sets *value to the value of the flag. - return ParseInt32(Message() << "The value of flag --" << flag, - value_str, value); -} - -// The internal implementation of InitGoogleMock(). -// -// The type parameter CharType can be instantiated to either char or -// wchar_t. -template -void InitGoogleMockImpl(int* argc, CharType** argv) { - // Makes sure Google Test is initialized. InitGoogleTest() is - // idempotent, so it's fine if the user has already called it. - InitGoogleTest(argc, argv); - if (*argc <= 0) return; - - for (int i = 1; i != *argc; i++) { - const std::string arg_string = StreamableToString(argv[i]); - const char* const arg = arg_string.c_str(); - - // Do we see a Google Mock flag? - if (ParseGoogleMockBoolFlag(arg, "catch_leaked_mocks", - &GMOCK_FLAG(catch_leaked_mocks)) || - ParseGoogleMockStringFlag(arg, "verbose", &GMOCK_FLAG(verbose)) || - ParseGoogleMockIntFlag(arg, "default_mock_behavior", - &GMOCK_FLAG(default_mock_behavior))) { - // Yes. Shift the remainder of the argv list left by one. Note - // that argv has (*argc + 1) elements, the last one always being - // NULL. The following loop moves the trailing NULL element as - // well. - for (int j = i; j != *argc; j++) { - argv[j] = argv[j + 1]; - } - - // Decrements the argument count. - (*argc)--; - - // We also need to decrement the iterator as we just removed - // an element. - i--; - } - } -} - -} // namespace internal - -// Initializes Google Mock. This must be called before running the -// tests. In particular, it parses a command line for the flags that -// Google Mock recognizes. Whenever a Google Mock flag is seen, it is -// removed from argv, and *argc is decremented. -// -// No value is returned. Instead, the Google Mock flag variables are -// updated. -// -// Since Google Test is needed for Google Mock to work, this function -// also initializes Google Test and parses its flags, if that hasn't -// been done. -GTEST_API_ void InitGoogleMock(int* argc, char** argv) { - internal::InitGoogleMockImpl(argc, argv); -} - -// This overloaded version can be used in Windows programs compiled in -// UNICODE mode. -GTEST_API_ void InitGoogleMock(int* argc, wchar_t** argv) { - internal::InitGoogleMockImpl(argc, argv); -} - -} // namespace testing diff --git a/inference-engine/thirdparty/clDNN/common/googletest-fused/gmock/gmock.h b/inference-engine/thirdparty/clDNN/common/googletest-fused/gmock/gmock.h deleted file mode 100644 index b10aae379bfdba..00000000000000 --- a/inference-engine/thirdparty/clDNN/common/googletest-fused/gmock/gmock.h +++ /dev/null @@ -1,16697 +0,0 @@ -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) - -// Google Mock - a framework for writing C++ mock classes. -// -// This is the main header file a user should include. - -#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_H_ -#define GMOCK_INCLUDE_GMOCK_GMOCK_H_ - -// This file implements the following syntax: -// -// ON_CALL(mock_object.Method(...)) -// .With(...) ? -// .WillByDefault(...); -// -// where With() is optional and WillByDefault() must appear exactly -// once. -// -// EXPECT_CALL(mock_object.Method(...)) -// .With(...) ? -// .Times(...) ? -// .InSequence(...) * -// .WillOnce(...) * -// .WillRepeatedly(...) ? -// .RetiresOnSaturation() ? ; -// -// where all clauses are optional and WillOnce() can be repeated. - -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) - -// Google Mock - a framework for writing C++ mock classes. -// -// This file implements some commonly used actions. - -#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_ -#define GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_ - -#ifndef _WIN32_WCE -# include -#endif - -#include -#include - -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) - -// Google Mock - a framework for writing C++ mock classes. -// -// This file defines some utilities useful for implementing Google -// Mock. They are subject to change without notice, so please DO NOT -// USE THEM IN USER CODE. - -#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ -#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ - -#include -#include // NOLINT -#include -// This file was GENERATED by command: -// pump.py gmock-generated-internal-utils.h.pump -// DO NOT EDIT BY HAND!!! - -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) - -// Google Mock - a framework for writing C++ mock classes. -// -// This file contains template meta-programming utility classes needed -// for implementing Google Mock. - -#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_ -#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_ - -// Copyright 2008, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: vadimb@google.com (Vadim Berman) -// -// Low-level types and utilities for porting Google Mock to various -// platforms. All macros ending with _ and symbols defined in an -// internal namespace are subject to change without notice. Code -// outside Google Mock MUST NOT USE THEM DIRECTLY. Macros that don't -// end with _ are part of Google Mock's public API and can be used by -// code outside Google Mock. - -#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_ -#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_ - -#include -#include -#include - -// Most of the utilities needed for porting Google Mock are also -// required for Google Test and are defined in gtest-port.h. -// -// Note to maintainers: to reduce code duplication, prefer adding -// portability utilities to Google Test's gtest-port.h instead of -// here, as Google Mock depends on Google Test. Only add a utility -// here if it's truly specific to Google Mock. - -#include "gtest/gtest.h" -// Copyright 2015, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Injection point for custom user configurations. -// The following macros can be defined: -// -// Flag related macros: -// GMOCK_DECLARE_bool_(name) -// GMOCK_DECLARE_int32_(name) -// GMOCK_DECLARE_string_(name) -// GMOCK_DEFINE_bool_(name, default_val, doc) -// GMOCK_DEFINE_int32_(name, default_val, doc) -// GMOCK_DEFINE_string_(name, default_val, doc) -// -// ** Custom implementation starts here ** - -#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_ -#define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_ - -#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_ - -// For MS Visual C++, check the compiler version. At least VS 2003 is -// required to compile Google Mock. -#if defined(_MSC_VER) && _MSC_VER < 1310 -# error "At least Visual C++ 2003 (7.1) is required to compile Google Mock." -#endif - -// Macro for referencing flags. This is public as we want the user to -// use this syntax to reference Google Mock flags. -#define GMOCK_FLAG(name) FLAGS_gmock_##name - -#if !defined(GMOCK_DECLARE_bool_) - -// Macros for declaring flags. -# define GMOCK_DECLARE_bool_(name) extern GTEST_API_ bool GMOCK_FLAG(name) -# define GMOCK_DECLARE_int32_(name) \ - extern GTEST_API_ ::testing::internal::Int32 GMOCK_FLAG(name) -# define GMOCK_DECLARE_string_(name) \ - extern GTEST_API_ ::std::string GMOCK_FLAG(name) - -// Macros for defining flags. -# define GMOCK_DEFINE_bool_(name, default_val, doc) \ - GTEST_API_ bool GMOCK_FLAG(name) = (default_val) -# define GMOCK_DEFINE_int32_(name, default_val, doc) \ - GTEST_API_ ::testing::internal::Int32 GMOCK_FLAG(name) = (default_val) -# define GMOCK_DEFINE_string_(name, default_val, doc) \ - GTEST_API_ ::std::string GMOCK_FLAG(name) = (default_val) - -#endif // !defined(GMOCK_DECLARE_bool_) - -#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_ - -namespace testing { - -template -class Matcher; - -namespace internal { - -// An IgnoredValue object can be implicitly constructed from ANY value. -// This is used in implementing the IgnoreResult(a) action. -class IgnoredValue { - public: - // This constructor template allows any value to be implicitly - // converted to IgnoredValue. The object has no data member and - // doesn't try to remember anything about the argument. We - // deliberately omit the 'explicit' keyword in order to allow the - // conversion to be implicit. - template - IgnoredValue(const T& /* ignored */) {} // NOLINT(runtime/explicit) -}; - -// MatcherTuple::type is a tuple type where each field is a Matcher -// for the corresponding field in tuple type T. -template -struct MatcherTuple; - -template <> -struct MatcherTuple< ::testing::tuple<> > { - typedef ::testing::tuple< > type; -}; - -template -struct MatcherTuple< ::testing::tuple > { - typedef ::testing::tuple > type; -}; - -template -struct MatcherTuple< ::testing::tuple > { - typedef ::testing::tuple, Matcher > type; -}; - -template -struct MatcherTuple< ::testing::tuple > { - typedef ::testing::tuple, Matcher, Matcher > type; -}; - -template -struct MatcherTuple< ::testing::tuple > { - typedef ::testing::tuple, Matcher, Matcher, Matcher > - type; -}; - -template -struct MatcherTuple< ::testing::tuple > { - typedef ::testing::tuple, Matcher, Matcher, Matcher, - Matcher > - type; -}; - -template -struct MatcherTuple< ::testing::tuple > { - typedef ::testing::tuple, Matcher, Matcher, Matcher, - Matcher, Matcher > - type; -}; - -template -struct MatcherTuple< ::testing::tuple > { - typedef ::testing::tuple, Matcher, Matcher, Matcher, - Matcher, Matcher, Matcher > - type; -}; - -template -struct MatcherTuple< ::testing::tuple > { - typedef ::testing::tuple, Matcher, Matcher, Matcher, - Matcher, Matcher, Matcher, Matcher > - type; -}; - -template -struct MatcherTuple< ::testing::tuple > { - typedef ::testing::tuple, Matcher, Matcher, Matcher, - Matcher, Matcher, Matcher, Matcher, - Matcher > - type; -}; - -template -struct MatcherTuple< ::testing::tuple > { - typedef ::testing::tuple, Matcher, Matcher, Matcher, - Matcher, Matcher, Matcher, Matcher, - Matcher, Matcher > - type; -}; - -// Template struct Function, where F must be a function type, contains -// the following typedefs: -// -// Result: the function's return type. -// ArgumentN: the type of the N-th argument, where N starts with 1. -// ArgumentTuple: the tuple type consisting of all parameters of F. -// ArgumentMatcherTuple: the tuple type consisting of Matchers for all -// parameters of F. -// MakeResultVoid: the function type obtained by substituting void -// for the return type of F. -// MakeResultIgnoredValue: -// the function type obtained by substituting Something -// for the return type of F. -template -struct Function; - -template -struct Function { - typedef R Result; - typedef ::testing::tuple<> ArgumentTuple; - typedef typename MatcherTuple::type ArgumentMatcherTuple; - typedef void MakeResultVoid(); - typedef IgnoredValue MakeResultIgnoredValue(); -}; - -template -struct Function - : Function { - typedef A1 Argument1; - typedef ::testing::tuple ArgumentTuple; - typedef typename MatcherTuple::type ArgumentMatcherTuple; - typedef void MakeResultVoid(A1); - typedef IgnoredValue MakeResultIgnoredValue(A1); -}; - -template -struct Function - : Function { - typedef A2 Argument2; - typedef ::testing::tuple ArgumentTuple; - typedef typename MatcherTuple::type ArgumentMatcherTuple; - typedef void MakeResultVoid(A1, A2); - typedef IgnoredValue MakeResultIgnoredValue(A1, A2); -}; - -template -struct Function - : Function { - typedef A3 Argument3; - typedef ::testing::tuple ArgumentTuple; - typedef typename MatcherTuple::type ArgumentMatcherTuple; - typedef void MakeResultVoid(A1, A2, A3); - typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3); -}; - -template -struct Function - : Function { - typedef A4 Argument4; - typedef ::testing::tuple ArgumentTuple; - typedef typename MatcherTuple::type ArgumentMatcherTuple; - typedef void MakeResultVoid(A1, A2, A3, A4); - typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4); -}; - -template -struct Function - : Function { - typedef A5 Argument5; - typedef ::testing::tuple ArgumentTuple; - typedef typename MatcherTuple::type ArgumentMatcherTuple; - typedef void MakeResultVoid(A1, A2, A3, A4, A5); - typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5); -}; - -template -struct Function - : Function { - typedef A6 Argument6; - typedef ::testing::tuple ArgumentTuple; - typedef typename MatcherTuple::type ArgumentMatcherTuple; - typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6); - typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6); -}; - -template -struct Function - : Function { - typedef A7 Argument7; - typedef ::testing::tuple ArgumentTuple; - typedef typename MatcherTuple::type ArgumentMatcherTuple; - typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7); - typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7); -}; - -template -struct Function - : Function { - typedef A8 Argument8; - typedef ::testing::tuple ArgumentTuple; - typedef typename MatcherTuple::type ArgumentMatcherTuple; - typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8); - typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8); -}; - -template -struct Function - : Function { - typedef A9 Argument9; - typedef ::testing::tuple ArgumentTuple; - typedef typename MatcherTuple::type ArgumentMatcherTuple; - typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9); - typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8, - A9); -}; - -template -struct Function - : Function { - typedef A10 Argument10; - typedef ::testing::tuple ArgumentTuple; - typedef typename MatcherTuple::type ArgumentMatcherTuple; - typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10); - typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8, - A9, A10); -}; - -} // namespace internal - -} // namespace testing - -#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_ - -namespace testing { -namespace internal { - -// Silence MSVC C4100 (unreferenced formal parameter) and -// C4805('==': unsafe mix of type 'const int' and type 'const bool') -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable:4100) -# pragma warning(disable:4805) -#endif - -// Joins a vector of strings as if they are fields of a tuple; returns -// the joined string. -GTEST_API_ std::string JoinAsTuple(const Strings& fields); - -// Converts an identifier name to a space-separated list of lower-case -// words. Each maximum substring of the form [A-Za-z][a-z]*|\d+ is -// treated as one word. For example, both "FooBar123" and -// "foo_bar_123" are converted to "foo bar 123". -GTEST_API_ std::string ConvertIdentifierNameToWords(const char* id_name); - -// PointeeOf::type is the type of a value pointed to by a -// Pointer, which can be either a smart pointer or a raw pointer. The -// following default implementation is for the case where Pointer is a -// smart pointer. -template -struct PointeeOf { - // Smart pointer classes define type element_type as the type of - // their pointees. - typedef typename Pointer::element_type type; -}; -// This specialization is for the raw pointer case. -template -struct PointeeOf { typedef T type; }; // NOLINT - -// GetRawPointer(p) returns the raw pointer underlying p when p is a -// smart pointer, or returns p itself when p is already a raw pointer. -// The following default implementation is for the smart pointer case. -template -inline const typename Pointer::element_type* GetRawPointer(const Pointer& p) { - return p.get(); -} -// This overloaded version is for the raw pointer case. -template -inline Element* GetRawPointer(Element* p) { return p; } - -// This comparator allows linked_ptr to be stored in sets. -template -struct LinkedPtrLessThan { - bool operator()(const ::testing::internal::linked_ptr& lhs, - const ::testing::internal::linked_ptr& rhs) const { - return lhs.get() < rhs.get(); - } -}; - -// Symbian compilation can be done with wchar_t being either a native -// type or a typedef. Using Google Mock with OpenC without wchar_t -// should require the definition of _STLP_NO_WCHAR_T. -// -// MSVC treats wchar_t as a native type usually, but treats it as the -// same as unsigned short when the compiler option /Zc:wchar_t- is -// specified. It defines _NATIVE_WCHAR_T_DEFINED symbol when wchar_t -// is a native type. -#if (GTEST_OS_SYMBIAN && defined(_STLP_NO_WCHAR_T)) || \ - (defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED)) -// wchar_t is a typedef. -#else -# define GMOCK_WCHAR_T_IS_NATIVE_ 1 -#endif - -// signed wchar_t and unsigned wchar_t are NOT in the C++ standard. -// Using them is a bad practice and not portable. So DON'T use them. -// -// Still, Google Mock is designed to work even if the user uses signed -// wchar_t or unsigned wchar_t (obviously, assuming the compiler -// supports them). -// -// To gcc, -// wchar_t == signed wchar_t != unsigned wchar_t == unsigned int -#ifdef __GNUC__ -#if !defined(__WCHAR_UNSIGNED__) -// signed/unsigned wchar_t are valid types. -# define GMOCK_HAS_SIGNED_WCHAR_T_ 1 -#endif -#endif - -// In what follows, we use the term "kind" to indicate whether a type -// is bool, an integer type (excluding bool), a floating-point type, -// or none of them. This categorization is useful for determining -// when a matcher argument type can be safely converted to another -// type in the implementation of SafeMatcherCast. -enum TypeKind { - kBool, kInteger, kFloatingPoint, kOther -}; - -// KindOf::value is the kind of type T. -template struct KindOf { - enum { value = kOther }; // The default kind. -}; - -// This macro declares that the kind of 'type' is 'kind'. -#define GMOCK_DECLARE_KIND_(type, kind) \ - template <> struct KindOf { enum { value = kind }; } - -GMOCK_DECLARE_KIND_(bool, kBool); - -// All standard integer types. -GMOCK_DECLARE_KIND_(char, kInteger); -GMOCK_DECLARE_KIND_(signed char, kInteger); -GMOCK_DECLARE_KIND_(unsigned char, kInteger); -GMOCK_DECLARE_KIND_(short, kInteger); // NOLINT -GMOCK_DECLARE_KIND_(unsigned short, kInteger); // NOLINT -GMOCK_DECLARE_KIND_(int, kInteger); -GMOCK_DECLARE_KIND_(unsigned int, kInteger); -GMOCK_DECLARE_KIND_(long, kInteger); // NOLINT -GMOCK_DECLARE_KIND_(unsigned long, kInteger); // NOLINT - -#if GMOCK_WCHAR_T_IS_NATIVE_ -GMOCK_DECLARE_KIND_(wchar_t, kInteger); -#endif - -// Non-standard integer types. -GMOCK_DECLARE_KIND_(Int64, kInteger); -GMOCK_DECLARE_KIND_(UInt64, kInteger); - -// All standard floating-point types. -GMOCK_DECLARE_KIND_(float, kFloatingPoint); -GMOCK_DECLARE_KIND_(double, kFloatingPoint); -GMOCK_DECLARE_KIND_(long double, kFloatingPoint); - -#undef GMOCK_DECLARE_KIND_ - -// Evaluates to the kind of 'type'. -#define GMOCK_KIND_OF_(type) \ - static_cast< ::testing::internal::TypeKind>( \ - ::testing::internal::KindOf::value) - -// Evaluates to true iff integer type T is signed. -#define GMOCK_IS_SIGNED_(T) (static_cast(-1) < 0) - -// LosslessArithmeticConvertibleImpl::value -// is true iff arithmetic type From can be losslessly converted to -// arithmetic type To. -// -// It's the user's responsibility to ensure that both From and To are -// raw (i.e. has no CV modifier, is not a pointer, and is not a -// reference) built-in arithmetic types, kFromKind is the kind of -// From, and kToKind is the kind of To; the value is -// implementation-defined when the above pre-condition is violated. -template -struct LosslessArithmeticConvertibleImpl : public false_type {}; - -// Converting bool to bool is lossless. -template <> -struct LosslessArithmeticConvertibleImpl - : public true_type {}; // NOLINT - -// Converting bool to any integer type is lossless. -template -struct LosslessArithmeticConvertibleImpl - : public true_type {}; // NOLINT - -// Converting bool to any floating-point type is lossless. -template -struct LosslessArithmeticConvertibleImpl - : public true_type {}; // NOLINT - -// Converting an integer to bool is lossy. -template -struct LosslessArithmeticConvertibleImpl - : public false_type {}; // NOLINT - -// Converting an integer to another non-bool integer is lossless iff -// the target type's range encloses the source type's range. -template -struct LosslessArithmeticConvertibleImpl - : public bool_constant< - // When converting from a smaller size to a larger size, we are - // fine as long as we are not converting from signed to unsigned. - ((sizeof(From) < sizeof(To)) && - (!GMOCK_IS_SIGNED_(From) || GMOCK_IS_SIGNED_(To))) || - // When converting between the same size, the signedness must match. - ((sizeof(From) == sizeof(To)) && - (GMOCK_IS_SIGNED_(From) == GMOCK_IS_SIGNED_(To)))> {}; // NOLINT - -#undef GMOCK_IS_SIGNED_ - -// Converting an integer to a floating-point type may be lossy, since -// the format of a floating-point number is implementation-defined. -template -struct LosslessArithmeticConvertibleImpl - : public false_type {}; // NOLINT - -// Converting a floating-point to bool is lossy. -template -struct LosslessArithmeticConvertibleImpl - : public false_type {}; // NOLINT - -// Converting a floating-point to an integer is lossy. -template -struct LosslessArithmeticConvertibleImpl - : public false_type {}; // NOLINT - -// Converting a floating-point to another floating-point is lossless -// iff the target type is at least as big as the source type. -template -struct LosslessArithmeticConvertibleImpl< - kFloatingPoint, From, kFloatingPoint, To> - : public bool_constant {}; // NOLINT - -// LosslessArithmeticConvertible::value is true iff arithmetic -// type From can be losslessly converted to arithmetic type To. -// -// It's the user's responsibility to ensure that both From and To are -// raw (i.e. has no CV modifier, is not a pointer, and is not a -// reference) built-in arithmetic types; the value is -// implementation-defined when the above pre-condition is violated. -template -struct LosslessArithmeticConvertible - : public LosslessArithmeticConvertibleImpl< - GMOCK_KIND_OF_(From), From, GMOCK_KIND_OF_(To), To> {}; // NOLINT - -// This interface knows how to report a Google Mock failure (either -// non-fatal or fatal). -class FailureReporterInterface { - public: - // The type of a failure (either non-fatal or fatal). - enum FailureType { - kNonfatal, kFatal - }; - - virtual ~FailureReporterInterface() {} - - // Reports a failure that occurred at the given source file location. - virtual void ReportFailure(FailureType type, const char* file, int line, - const std::string& message) = 0; -}; - -// Returns the failure reporter used by Google Mock. -GTEST_API_ FailureReporterInterface* GetFailureReporter(); - -// Asserts that condition is true; aborts the process with the given -// message if condition is false. We cannot use LOG(FATAL) or CHECK() -// as Google Mock might be used to mock the log sink itself. We -// inline this function to prevent it from showing up in the stack -// trace. -inline void Assert(bool condition, const char* file, int line, - const std::string& msg) { - if (!condition) { - GetFailureReporter()->ReportFailure(FailureReporterInterface::kFatal, - file, line, msg); - } -} -inline void Assert(bool condition, const char* file, int line) { - Assert(condition, file, line, "Assertion failed."); -} - -// Verifies that condition is true; generates a non-fatal failure if -// condition is false. -inline void Expect(bool condition, const char* file, int line, - const std::string& msg) { - if (!condition) { - GetFailureReporter()->ReportFailure(FailureReporterInterface::kNonfatal, - file, line, msg); - } -} -inline void Expect(bool condition, const char* file, int line) { - Expect(condition, file, line, "Expectation failed."); -} - -// Severity level of a log. -enum LogSeverity { - kInfo = 0, - kWarning = 1 -}; - -// Valid values for the --gmock_verbose flag. - -// All logs (informational and warnings) are printed. -const char kInfoVerbosity[] = "info"; -// Only warnings are printed. -const char kWarningVerbosity[] = "warning"; -// No logs are printed. -const char kErrorVerbosity[] = "error"; - -// Returns true iff a log with the given severity is visible according -// to the --gmock_verbose flag. -GTEST_API_ bool LogIsVisible(LogSeverity severity); - -// Prints the given message to stdout iff 'severity' >= the level -// specified by the --gmock_verbose flag. If stack_frames_to_skip >= -// 0, also prints the stack trace excluding the top -// stack_frames_to_skip frames. In opt mode, any positive -// stack_frames_to_skip is treated as 0, since we don't know which -// function calls will be inlined by the compiler and need to be -// conservative. -GTEST_API_ void Log(LogSeverity severity, const std::string& message, - int stack_frames_to_skip); - -// A marker class that is used to resolve parameterless expectations to the -// correct overload. This must not be instantiable, to prevent client code from -// accidentally resolving to the overload; for example: -// -// ON_CALL(mock, Method({}, nullptr))... -// -class WithoutMatchers { - private: - WithoutMatchers() {} - friend GTEST_API_ WithoutMatchers GetWithoutMatchers(); -}; - -// Internal use only: access the singleton instance of WithoutMatchers. -GTEST_API_ WithoutMatchers GetWithoutMatchers(); - -// TODO(wan@google.com): group all type utilities together. - -// Type traits. - -// is_reference::value is non-zero iff T is a reference type. -template struct is_reference : public false_type {}; -template struct is_reference : public true_type {}; - -// type_equals::value is non-zero iff T1 and T2 are the same type. -template struct type_equals : public false_type {}; -template struct type_equals : public true_type {}; - -// remove_reference::type removes the reference from type T, if any. -template struct remove_reference { typedef T type; }; // NOLINT -template struct remove_reference { typedef T type; }; // NOLINT - -// DecayArray::type turns an array type U[N] to const U* and preserves -// other types. Useful for saving a copy of a function argument. -template struct DecayArray { typedef T type; }; // NOLINT -template struct DecayArray { - typedef const T* type; -}; -// Sometimes people use arrays whose size is not available at the use site -// (e.g. extern const char kNamePrefix[]). This specialization covers that -// case. -template struct DecayArray { - typedef const T* type; -}; - -// Disable MSVC warnings for infinite recursion, since in this case the -// the recursion is unreachable. -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable:4717) -#endif - -// Invalid() is usable as an expression of type T, but will terminate -// the program with an assertion failure if actually run. This is useful -// when a value of type T is needed for compilation, but the statement -// will not really be executed (or we don't care if the statement -// crashes). -template -inline T Invalid() { - Assert(false, "", -1, "Internal error: attempt to return invalid value"); - // This statement is unreachable, and would never terminate even if it - // could be reached. It is provided only to placate compiler warnings - // about missing return statements. - return Invalid(); -} - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - -// Given a raw type (i.e. having no top-level reference or const -// modifier) RawContainer that's either an STL-style container or a -// native array, class StlContainerView has the -// following members: -// -// - type is a type that provides an STL-style container view to -// (i.e. implements the STL container concept for) RawContainer; -// - const_reference is a type that provides a reference to a const -// RawContainer; -// - ConstReference(raw_container) returns a const reference to an STL-style -// container view to raw_container, which is a RawContainer. -// - Copy(raw_container) returns an STL-style container view of a -// copy of raw_container, which is a RawContainer. -// -// This generic version is used when RawContainer itself is already an -// STL-style container. -template -class StlContainerView { - public: - typedef RawContainer type; - typedef const type& const_reference; - - static const_reference ConstReference(const RawContainer& container) { - // Ensures that RawContainer is not a const type. - testing::StaticAssertTypeEq(); - return container; - } - static type Copy(const RawContainer& container) { return container; } -}; - -// This specialization is used when RawContainer is a native array type. -template -class StlContainerView { - public: - typedef GTEST_REMOVE_CONST_(Element) RawElement; - typedef internal::NativeArray type; - // NativeArray can represent a native array either by value or by - // reference (selected by a constructor argument), so 'const type' - // can be used to reference a const native array. We cannot - // 'typedef const type& const_reference' here, as that would mean - // ConstReference() has to return a reference to a local variable. - typedef const type const_reference; - - static const_reference ConstReference(const Element (&array)[N]) { - // Ensures that Element is not a const type. - testing::StaticAssertTypeEq(); -#if GTEST_OS_SYMBIAN - // The Nokia Symbian compiler confuses itself in template instantiation - // for this call without the cast to Element*: - // function call '[testing::internal::NativeArray].NativeArray( - // {lval} const char *[4], long, testing::internal::RelationToSource)' - // does not match - // 'testing::internal::NativeArray::NativeArray( - // char *const *, unsigned int, testing::internal::RelationToSource)' - // (instantiating: 'testing::internal::ContainsMatcherImpl - // ::Matches(const char * (&)[4]) const') - // (instantiating: 'testing::internal::StlContainerView:: - // ConstReference(const char * (&)[4])') - // (and though the N parameter type is mismatched in the above explicit - // conversion of it doesn't help - only the conversion of the array). - return type(const_cast(&array[0]), N, - RelationToSourceReference()); -#else - return type(array, N, RelationToSourceReference()); -#endif // GTEST_OS_SYMBIAN - } - static type Copy(const Element (&array)[N]) { -#if GTEST_OS_SYMBIAN - return type(const_cast(&array[0]), N, RelationToSourceCopy()); -#else - return type(array, N, RelationToSourceCopy()); -#endif // GTEST_OS_SYMBIAN - } -}; - -// This specialization is used when RawContainer is a native array -// represented as a (pointer, size) tuple. -template -class StlContainerView< ::testing::tuple > { - public: - typedef GTEST_REMOVE_CONST_( - typename internal::PointeeOf::type) RawElement; - typedef internal::NativeArray type; - typedef const type const_reference; - - static const_reference ConstReference( - const ::testing::tuple& array) { - return type(get<0>(array), get<1>(array), RelationToSourceReference()); - } - static type Copy(const ::testing::tuple& array) { - return type(get<0>(array), get<1>(array), RelationToSourceCopy()); - } -}; - -// The following specialization prevents the user from instantiating -// StlContainer with a reference type. -template class StlContainerView; - -// A type transform to remove constness from the first part of a pair. -// Pairs like that are used as the value_type of associative containers, -// and this transform produces a similar but assignable pair. -template -struct RemoveConstFromKey { - typedef T type; -}; - -// Partially specialized to remove constness from std::pair. -template -struct RemoveConstFromKey > { - typedef std::pair type; -}; - -// Mapping from booleans to types. Similar to boost::bool_ and -// std::integral_constant. -template -struct BooleanConstant {}; - -// Emit an assertion failure due to incorrect DoDefault() usage. Out-of-lined to -// reduce code size. -GTEST_API_ void IllegalDoDefault(const char* file, int line); - -#if GTEST_LANG_CXX11 -// Helper types for Apply() below. -template struct int_pack { typedef int_pack type; }; - -template struct append; -template -struct append, I> : int_pack {}; - -template -struct make_int_pack : append::type, C - 1> {}; -template <> struct make_int_pack<0> : int_pack<> {}; - -template -auto ApplyImpl(F&& f, Tuple&& args, int_pack) -> decltype( - std::forward(f)(std::get(std::forward(args))...)) { - return std::forward(f)(std::get(std::forward(args))...); -} - -// Apply the function to a tuple of arguments. -template -auto Apply(F&& f, Tuple&& args) - -> decltype(ApplyImpl(std::forward(f), std::forward(args), - make_int_pack::value>())) { - return ApplyImpl(std::forward(f), std::forward(args), - make_int_pack::value>()); -} -#endif - - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - -} // namespace internal -} // namespace testing - -#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ - -#if GTEST_LANG_CXX11 // Defined by gtest-port.h via gmock-port.h. -#include -#include -#endif // GTEST_LANG_CXX11 - -namespace testing { - -// To implement an action Foo, define: -// 1. a class FooAction that implements the ActionInterface interface, and -// 2. a factory function that creates an Action object from a -// const FooAction*. -// -// The two-level delegation design follows that of Matcher, providing -// consistency for extension developers. It also eases ownership -// management as Action objects can now be copied like plain values. - -namespace internal { - -template -class ActionAdaptor; - -// BuiltInDefaultValueGetter::Get() returns a -// default-constructed T value. BuiltInDefaultValueGetter::Get() crashes with an error. -// -// This primary template is used when kDefaultConstructible is true. -template -struct BuiltInDefaultValueGetter { - static T Get() { return T(); } -}; -template -struct BuiltInDefaultValueGetter { - static T Get() { - Assert(false, __FILE__, __LINE__, - "Default action undefined for the function return type."); - return internal::Invalid(); - // The above statement will never be reached, but is required in - // order for this function to compile. - } -}; - -// BuiltInDefaultValue::Get() returns the "built-in" default value -// for type T, which is NULL when T is a raw pointer type, 0 when T is -// a numeric type, false when T is bool, or "" when T is string or -// std::string. In addition, in C++11 and above, it turns a -// default-constructed T value if T is default constructible. For any -// other type T, the built-in default T value is undefined, and the -// function will abort the process. -template -class BuiltInDefaultValue { - public: -#if GTEST_LANG_CXX11 - // This function returns true iff type T has a built-in default value. - static bool Exists() { - return ::std::is_default_constructible::value; - } - - static T Get() { - return BuiltInDefaultValueGetter< - T, ::std::is_default_constructible::value>::Get(); - } - -#else // GTEST_LANG_CXX11 - // This function returns true iff type T has a built-in default value. - static bool Exists() { - return false; - } - - static T Get() { - return BuiltInDefaultValueGetter::Get(); - } - -#endif // GTEST_LANG_CXX11 -}; - -// This partial specialization says that we use the same built-in -// default value for T and const T. -template -class BuiltInDefaultValue { - public: - static bool Exists() { return BuiltInDefaultValue::Exists(); } - static T Get() { return BuiltInDefaultValue::Get(); } -}; - -// This partial specialization defines the default values for pointer -// types. -template -class BuiltInDefaultValue { - public: - static bool Exists() { return true; } - static T* Get() { return NULL; } -}; - -// The following specializations define the default values for -// specific types we care about. -#define GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(type, value) \ - template <> \ - class BuiltInDefaultValue { \ - public: \ - static bool Exists() { return true; } \ - static type Get() { return value; } \ - } - -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(void, ); // NOLINT -#if GTEST_HAS_GLOBAL_STRING -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(::string, ""); -#endif // GTEST_HAS_GLOBAL_STRING -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(::std::string, ""); -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(bool, false); -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned char, '\0'); -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed char, '\0'); -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(char, '\0'); - -// There's no need for a default action for signed wchar_t, as that -// type is the same as wchar_t for gcc, and invalid for MSVC. -// -// There's also no need for a default action for unsigned wchar_t, as -// that type is the same as unsigned int for gcc, and invalid for -// MSVC. -#if GMOCK_WCHAR_T_IS_NATIVE_ -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(wchar_t, 0U); // NOLINT -#endif - -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned short, 0U); // NOLINT -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed short, 0); // NOLINT -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned int, 0U); -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed int, 0); -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned long, 0UL); // NOLINT -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed long, 0L); // NOLINT -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(UInt64, 0); -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(Int64, 0); -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(float, 0); -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(double, 0); - -#undef GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_ - -} // namespace internal - -// When an unexpected function call is encountered, Google Mock will -// let it return a default value if the user has specified one for its -// return type, or if the return type has a built-in default value; -// otherwise Google Mock won't know what value to return and will have -// to abort the process. -// -// The DefaultValue class allows a user to specify the -// default value for a type T that is both copyable and publicly -// destructible (i.e. anything that can be used as a function return -// type). The usage is: -// -// // Sets the default value for type T to be foo. -// DefaultValue::Set(foo); -template -class DefaultValue { - public: - // Sets the default value for type T; requires T to be - // copy-constructable and have a public destructor. - static void Set(T x) { - delete producer_; - producer_ = new FixedValueProducer(x); - } - - // Provides a factory function to be called to generate the default value. - // This method can be used even if T is only move-constructible, but it is not - // limited to that case. - typedef T (*FactoryFunction)(); - static void SetFactory(FactoryFunction factory) { - delete producer_; - producer_ = new FactoryValueProducer(factory); - } - - // Unsets the default value for type T. - static void Clear() { - delete producer_; - producer_ = NULL; - } - - // Returns true iff the user has set the default value for type T. - static bool IsSet() { return producer_ != NULL; } - - // Returns true if T has a default return value set by the user or there - // exists a built-in default value. - static bool Exists() { - return IsSet() || internal::BuiltInDefaultValue::Exists(); - } - - // Returns the default value for type T if the user has set one; - // otherwise returns the built-in default value. Requires that Exists() - // is true, which ensures that the return value is well-defined. - static T Get() { - return producer_ == NULL ? - internal::BuiltInDefaultValue::Get() : producer_->Produce(); - } - - private: - class ValueProducer { - public: - virtual ~ValueProducer() {} - virtual T Produce() = 0; - }; - - class FixedValueProducer : public ValueProducer { - public: - explicit FixedValueProducer(T value) : value_(value) {} - virtual T Produce() { return value_; } - - private: - const T value_; - GTEST_DISALLOW_COPY_AND_ASSIGN_(FixedValueProducer); - }; - - class FactoryValueProducer : public ValueProducer { - public: - explicit FactoryValueProducer(FactoryFunction factory) - : factory_(factory) {} - virtual T Produce() { return factory_(); } - - private: - const FactoryFunction factory_; - GTEST_DISALLOW_COPY_AND_ASSIGN_(FactoryValueProducer); - }; - - static ValueProducer* producer_; -}; - -// This partial specialization allows a user to set default values for -// reference types. -template -class DefaultValue { - public: - // Sets the default value for type T&. - static void Set(T& x) { // NOLINT - address_ = &x; - } - - // Unsets the default value for type T&. - static void Clear() { - address_ = NULL; - } - - // Returns true iff the user has set the default value for type T&. - static bool IsSet() { return address_ != NULL; } - - // Returns true if T has a default return value set by the user or there - // exists a built-in default value. - static bool Exists() { - return IsSet() || internal::BuiltInDefaultValue::Exists(); - } - - // Returns the default value for type T& if the user has set one; - // otherwise returns the built-in default value if there is one; - // otherwise aborts the process. - static T& Get() { - return address_ == NULL ? - internal::BuiltInDefaultValue::Get() : *address_; - } - - private: - static T* address_; -}; - -// This specialization allows DefaultValue::Get() to -// compile. -template <> -class DefaultValue { - public: - static bool Exists() { return true; } - static void Get() {} -}; - -// Points to the user-set default value for type T. -template -typename DefaultValue::ValueProducer* DefaultValue::producer_ = NULL; - -// Points to the user-set default value for type T&. -template -T* DefaultValue::address_ = NULL; - -// Implement this interface to define an action for function type F. -template -class ActionInterface { - public: - typedef typename internal::Function::Result Result; - typedef typename internal::Function::ArgumentTuple ArgumentTuple; - - ActionInterface() {} - virtual ~ActionInterface() {} - - // Performs the action. This method is not const, as in general an - // action can have side effects and be stateful. For example, a - // get-the-next-element-from-the-collection action will need to - // remember the current element. - virtual Result Perform(const ArgumentTuple& args) = 0; - - private: - GTEST_DISALLOW_COPY_AND_ASSIGN_(ActionInterface); -}; - -// An Action is a copyable and IMMUTABLE (except by assignment) -// object that represents an action to be taken when a mock function -// of type F is called. The implementation of Action is just a -// linked_ptr to const ActionInterface, so copying is fairly cheap. -// Don't inherit from Action! -// -// You can view an object implementing ActionInterface as a -// concrete action (including its current state), and an Action -// object as a handle to it. -template -class Action { - public: - typedef typename internal::Function::Result Result; - typedef typename internal::Function::ArgumentTuple ArgumentTuple; - - // Constructs a null Action. Needed for storing Action objects in - // STL containers. - Action() {} - -#if GTEST_LANG_CXX11 - // Construct an Action from a specified callable. - // This cannot take std::function directly, because then Action would not be - // directly constructible from lambda (it would require two conversions). - template , G>::value>::type> - Action(G&& fun) : fun_(::std::forward(fun)) {} // NOLINT -#endif - - // Constructs an Action from its implementation. - explicit Action(ActionInterface* impl) : impl_(impl) {} - - // This constructor allows us to turn an Action object into an - // Action, as long as F's arguments can be implicitly converted - // to Func's and Func's return type can be implicitly converted to - // F's. - template - explicit Action(const Action& action); - - // Returns true iff this is the DoDefault() action. - bool IsDoDefault() const { -#if GTEST_LANG_CXX11 - return impl_ == nullptr && fun_ == nullptr; -#else - return impl_ == NULL; -#endif - } - - // Performs the action. Note that this method is const even though - // the corresponding method in ActionInterface is not. The reason - // is that a const Action means that it cannot be re-bound to - // another concrete action, not that the concrete action it binds to - // cannot change state. (Think of the difference between a const - // pointer and a pointer to const.) - Result Perform(ArgumentTuple args) const { - if (IsDoDefault()) { - internal::IllegalDoDefault(__FILE__, __LINE__); - } -#if GTEST_LANG_CXX11 - if (fun_ != nullptr) { - return internal::Apply(fun_, ::std::move(args)); - } -#endif - return impl_->Perform(args); - } - - private: - template - friend class internal::ActionAdaptor; - - template - friend class Action; - - // In C++11, Action can be implemented either as a generic functor (through - // std::function), or legacy ActionInterface. In C++98, only ActionInterface - // is available. The invariants are as follows: - // * in C++98, impl_ is null iff this is the default action - // * in C++11, at most one of fun_ & impl_ may be nonnull; both are null iff - // this is the default action -#if GTEST_LANG_CXX11 - ::std::function fun_; -#endif - internal::linked_ptr > impl_; -}; - -// The PolymorphicAction class template makes it easy to implement a -// polymorphic action (i.e. an action that can be used in mock -// functions of than one type, e.g. Return()). -// -// To define a polymorphic action, a user first provides a COPYABLE -// implementation class that has a Perform() method template: -// -// class FooAction { -// public: -// template -// Result Perform(const ArgumentTuple& args) const { -// // Processes the arguments and returns a result, using -// // tr1::get(args) to get the N-th (0-based) argument in the tuple. -// } -// ... -// }; -// -// Then the user creates the polymorphic action using -// MakePolymorphicAction(object) where object has type FooAction. See -// the definition of Return(void) and SetArgumentPointee(value) for -// complete examples. -template -class PolymorphicAction { - public: - explicit PolymorphicAction(const Impl& impl) : impl_(impl) {} - - template - operator Action() const { - return Action(new MonomorphicImpl(impl_)); - } - - private: - template - class MonomorphicImpl : public ActionInterface { - public: - typedef typename internal::Function::Result Result; - typedef typename internal::Function::ArgumentTuple ArgumentTuple; - - explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {} - - virtual Result Perform(const ArgumentTuple& args) { - return impl_.template Perform(args); - } - - private: - Impl impl_; - - GTEST_DISALLOW_ASSIGN_(MonomorphicImpl); - }; - - Impl impl_; - - GTEST_DISALLOW_ASSIGN_(PolymorphicAction); -}; - -// Creates an Action from its implementation and returns it. The -// created Action object owns the implementation. -template -Action MakeAction(ActionInterface* impl) { - return Action(impl); -} - -// Creates a polymorphic action from its implementation. This is -// easier to use than the PolymorphicAction constructor as it -// doesn't require you to explicitly write the template argument, e.g. -// -// MakePolymorphicAction(foo); -// vs -// PolymorphicAction(foo); -template -inline PolymorphicAction MakePolymorphicAction(const Impl& impl) { - return PolymorphicAction(impl); -} - -namespace internal { - -// Allows an Action object to pose as an Action, as long as F2 -// and F1 are compatible. -template -class ActionAdaptor : public ActionInterface { - public: - typedef typename internal::Function::Result Result; - typedef typename internal::Function::ArgumentTuple ArgumentTuple; - - explicit ActionAdaptor(const Action& from) : impl_(from.impl_) {} - - virtual Result Perform(const ArgumentTuple& args) { - return impl_->Perform(args); - } - - private: - const internal::linked_ptr > impl_; - - GTEST_DISALLOW_ASSIGN_(ActionAdaptor); -}; - -// Helper struct to specialize ReturnAction to execute a move instead of a copy -// on return. Useful for move-only types, but could be used on any type. -template -struct ByMoveWrapper { - explicit ByMoveWrapper(T value) : payload(internal::move(value)) {} - T payload; -}; - -// Implements the polymorphic Return(x) action, which can be used in -// any function that returns the type of x, regardless of the argument -// types. -// -// Note: The value passed into Return must be converted into -// Function::Result when this action is cast to Action rather than -// when that action is performed. This is important in scenarios like -// -// MOCK_METHOD1(Method, T(U)); -// ... -// { -// Foo foo; -// X x(&foo); -// EXPECT_CALL(mock, Method(_)).WillOnce(Return(x)); -// } -// -// In the example above the variable x holds reference to foo which leaves -// scope and gets destroyed. If copying X just copies a reference to foo, -// that copy will be left with a hanging reference. If conversion to T -// makes a copy of foo, the above code is safe. To support that scenario, we -// need to make sure that the type conversion happens inside the EXPECT_CALL -// statement, and conversion of the result of Return to Action is a -// good place for that. -// -// The real life example of the above scenario happens when an invocation -// of gtl::Container() is passed into Return. -// -template -class ReturnAction { - public: - // Constructs a ReturnAction object from the value to be returned. - // 'value' is passed by value instead of by const reference in order - // to allow Return("string literal") to compile. - explicit ReturnAction(R value) : value_(new R(internal::move(value))) {} - - // This template type conversion operator allows Return(x) to be - // used in ANY function that returns x's type. - template - operator Action() const { - // Assert statement belongs here because this is the best place to verify - // conditions on F. It produces the clearest error messages - // in most compilers. - // Impl really belongs in this scope as a local class but can't - // because MSVC produces duplicate symbols in different translation units - // in this case. Until MS fixes that bug we put Impl into the class scope - // and put the typedef both here (for use in assert statement) and - // in the Impl class. But both definitions must be the same. - typedef typename Function::Result Result; - GTEST_COMPILE_ASSERT_( - !is_reference::value, - use_ReturnRef_instead_of_Return_to_return_a_reference); - return Action(new Impl(value_)); - } - - private: - // Implements the Return(x) action for a particular function type F. - template - class Impl : public ActionInterface { - public: - typedef typename Function::Result Result; - typedef typename Function::ArgumentTuple ArgumentTuple; - - // The implicit cast is necessary when Result has more than one - // single-argument constructor (e.g. Result is std::vector) and R - // has a type conversion operator template. In that case, value_(value) - // won't compile as the compiler doesn't known which constructor of - // Result to call. ImplicitCast_ forces the compiler to convert R to - // Result without considering explicit constructors, thus resolving the - // ambiguity. value_ is then initialized using its copy constructor. - explicit Impl(const linked_ptr& value) - : value_before_cast_(*value), - value_(ImplicitCast_(value_before_cast_)) {} - - virtual Result Perform(const ArgumentTuple&) { return value_; } - - private: - GTEST_COMPILE_ASSERT_(!is_reference::value, - Result_cannot_be_a_reference_type); - // We save the value before casting just in case it is being cast to a - // wrapper type. - R value_before_cast_; - Result value_; - - GTEST_DISALLOW_COPY_AND_ASSIGN_(Impl); - }; - - // Partially specialize for ByMoveWrapper. This version of ReturnAction will - // move its contents instead. - template - class Impl, F> : public ActionInterface { - public: - typedef typename Function::Result Result; - typedef typename Function::ArgumentTuple ArgumentTuple; - - explicit Impl(const linked_ptr& wrapper) - : performed_(false), wrapper_(wrapper) {} - - virtual Result Perform(const ArgumentTuple&) { - GTEST_CHECK_(!performed_) - << "A ByMove() action should only be performed once."; - performed_ = true; - return internal::move(wrapper_->payload); - } - - private: - bool performed_; - const linked_ptr wrapper_; - - GTEST_DISALLOW_ASSIGN_(Impl); - }; - - const linked_ptr value_; - - GTEST_DISALLOW_ASSIGN_(ReturnAction); -}; - -// Implements the ReturnNull() action. -class ReturnNullAction { - public: - // Allows ReturnNull() to be used in any pointer-returning function. In C++11 - // this is enforced by returning nullptr, and in non-C++11 by asserting a - // pointer type on compile time. - template - static Result Perform(const ArgumentTuple&) { -#if GTEST_LANG_CXX11 - return nullptr; -#else - GTEST_COMPILE_ASSERT_(internal::is_pointer::value, - ReturnNull_can_be_used_to_return_a_pointer_only); - return NULL; -#endif // GTEST_LANG_CXX11 - } -}; - -// Implements the Return() action. -class ReturnVoidAction { - public: - // Allows Return() to be used in any void-returning function. - template - static void Perform(const ArgumentTuple&) { - CompileAssertTypesEqual(); - } -}; - -// Implements the polymorphic ReturnRef(x) action, which can be used -// in any function that returns a reference to the type of x, -// regardless of the argument types. -template -class ReturnRefAction { - public: - // Constructs a ReturnRefAction object from the reference to be returned. - explicit ReturnRefAction(T& ref) : ref_(ref) {} // NOLINT - - // This template type conversion operator allows ReturnRef(x) to be - // used in ANY function that returns a reference to x's type. - template - operator Action() const { - typedef typename Function::Result Result; - // Asserts that the function return type is a reference. This - // catches the user error of using ReturnRef(x) when Return(x) - // should be used, and generates some helpful error message. - GTEST_COMPILE_ASSERT_(internal::is_reference::value, - use_Return_instead_of_ReturnRef_to_return_a_value); - return Action(new Impl(ref_)); - } - - private: - // Implements the ReturnRef(x) action for a particular function type F. - template - class Impl : public ActionInterface { - public: - typedef typename Function::Result Result; - typedef typename Function::ArgumentTuple ArgumentTuple; - - explicit Impl(T& ref) : ref_(ref) {} // NOLINT - - virtual Result Perform(const ArgumentTuple&) { - return ref_; - } - - private: - T& ref_; - - GTEST_DISALLOW_ASSIGN_(Impl); - }; - - T& ref_; - - GTEST_DISALLOW_ASSIGN_(ReturnRefAction); -}; - -// Implements the polymorphic ReturnRefOfCopy(x) action, which can be -// used in any function that returns a reference to the type of x, -// regardless of the argument types. -template -class ReturnRefOfCopyAction { - public: - // Constructs a ReturnRefOfCopyAction object from the reference to - // be returned. - explicit ReturnRefOfCopyAction(const T& value) : value_(value) {} // NOLINT - - // This template type conversion operator allows ReturnRefOfCopy(x) to be - // used in ANY function that returns a reference to x's type. - template - operator Action() const { - typedef typename Function::Result Result; - // Asserts that the function return type is a reference. This - // catches the user error of using ReturnRefOfCopy(x) when Return(x) - // should be used, and generates some helpful error message. - GTEST_COMPILE_ASSERT_( - internal::is_reference::value, - use_Return_instead_of_ReturnRefOfCopy_to_return_a_value); - return Action(new Impl(value_)); - } - - private: - // Implements the ReturnRefOfCopy(x) action for a particular function type F. - template - class Impl : public ActionInterface { - public: - typedef typename Function::Result Result; - typedef typename Function::ArgumentTuple ArgumentTuple; - - explicit Impl(const T& value) : value_(value) {} // NOLINT - - virtual Result Perform(const ArgumentTuple&) { - return value_; - } - - private: - T value_; - - GTEST_DISALLOW_ASSIGN_(Impl); - }; - - const T value_; - - GTEST_DISALLOW_ASSIGN_(ReturnRefOfCopyAction); -}; - -// Implements the polymorphic DoDefault() action. -class DoDefaultAction { - public: - // This template type conversion operator allows DoDefault() to be - // used in any function. - template - operator Action() const { return Action(); } // NOLINT -}; - -// Implements the Assign action to set a given pointer referent to a -// particular value. -template -class AssignAction { - public: - AssignAction(T1* ptr, T2 value) : ptr_(ptr), value_(value) {} - - template - void Perform(const ArgumentTuple& /* args */) const { - *ptr_ = value_; - } - - private: - T1* const ptr_; - const T2 value_; - - GTEST_DISALLOW_ASSIGN_(AssignAction); -}; - -#if !GTEST_OS_WINDOWS_MOBILE - -// Implements the SetErrnoAndReturn action to simulate return from -// various system calls and libc functions. -template -class SetErrnoAndReturnAction { - public: - SetErrnoAndReturnAction(int errno_value, T result) - : errno_(errno_value), - result_(result) {} - template - Result Perform(const ArgumentTuple& /* args */) const { - errno = errno_; - return result_; - } - - private: - const int errno_; - const T result_; - - GTEST_DISALLOW_ASSIGN_(SetErrnoAndReturnAction); -}; - -#endif // !GTEST_OS_WINDOWS_MOBILE - -// Implements the SetArgumentPointee(x) action for any function -// whose N-th argument (0-based) is a pointer to x's type. The -// template parameter kIsProto is true iff type A is ProtocolMessage, -// proto2::Message, or a sub-class of those. -template -class SetArgumentPointeeAction { - public: - // Constructs an action that sets the variable pointed to by the - // N-th function argument to 'value'. - explicit SetArgumentPointeeAction(const A& value) : value_(value) {} - - template - void Perform(const ArgumentTuple& args) const { - CompileAssertTypesEqual(); - *::testing::get(args) = value_; - } - - private: - const A value_; - - GTEST_DISALLOW_ASSIGN_(SetArgumentPointeeAction); -}; - -template -class SetArgumentPointeeAction { - public: - // Constructs an action that sets the variable pointed to by the - // N-th function argument to 'proto'. Both ProtocolMessage and - // proto2::Message have the CopyFrom() method, so the same - // implementation works for both. - explicit SetArgumentPointeeAction(const Proto& proto) : proto_(new Proto) { - proto_->CopyFrom(proto); - } - - template - void Perform(const ArgumentTuple& args) const { - CompileAssertTypesEqual(); - ::testing::get(args)->CopyFrom(*proto_); - } - - private: - const internal::linked_ptr proto_; - - GTEST_DISALLOW_ASSIGN_(SetArgumentPointeeAction); -}; - -// Implements the InvokeWithoutArgs(f) action. The template argument -// FunctionImpl is the implementation type of f, which can be either a -// function pointer or a functor. InvokeWithoutArgs(f) can be used as an -// Action as long as f's type is compatible with F (i.e. f can be -// assigned to a tr1::function). -template -class InvokeWithoutArgsAction { - public: - // The c'tor makes a copy of function_impl (either a function - // pointer or a functor). - explicit InvokeWithoutArgsAction(FunctionImpl function_impl) - : function_impl_(function_impl) {} - - // Allows InvokeWithoutArgs(f) to be used as any action whose type is - // compatible with f. - template - Result Perform(const ArgumentTuple&) { return function_impl_(); } - - private: - FunctionImpl function_impl_; - - GTEST_DISALLOW_ASSIGN_(InvokeWithoutArgsAction); -}; - -// Implements the InvokeWithoutArgs(object_ptr, &Class::Method) action. -template -class InvokeMethodWithoutArgsAction { - public: - InvokeMethodWithoutArgsAction(Class* obj_ptr, MethodPtr method_ptr) - : obj_ptr_(obj_ptr), method_ptr_(method_ptr) {} - - template - Result Perform(const ArgumentTuple&) const { - return (obj_ptr_->*method_ptr_)(); - } - - private: - Class* const obj_ptr_; - const MethodPtr method_ptr_; - - GTEST_DISALLOW_ASSIGN_(InvokeMethodWithoutArgsAction); -}; - -// Implements the InvokeWithoutArgs(callback) action. -template -class InvokeCallbackWithoutArgsAction { - public: - // The c'tor takes ownership of the callback. - explicit InvokeCallbackWithoutArgsAction(CallbackType* callback) - : callback_(callback) { - callback->CheckIsRepeatable(); // Makes sure the callback is permanent. - } - - // This type conversion operator template allows Invoke(callback) to - // be used wherever the callback's return type can be implicitly - // converted to that of the mock function. - template - Result Perform(const ArgumentTuple&) const { return callback_->Run(); } - - private: - const internal::linked_ptr callback_; - - GTEST_DISALLOW_ASSIGN_(InvokeCallbackWithoutArgsAction); -}; - -// Implements the IgnoreResult(action) action. -template -class IgnoreResultAction { - public: - explicit IgnoreResultAction(const A& action) : action_(action) {} - - template - operator Action() const { - // Assert statement belongs here because this is the best place to verify - // conditions on F. It produces the clearest error messages - // in most compilers. - // Impl really belongs in this scope as a local class but can't - // because MSVC produces duplicate symbols in different translation units - // in this case. Until MS fixes that bug we put Impl into the class scope - // and put the typedef both here (for use in assert statement) and - // in the Impl class. But both definitions must be the same. - typedef typename internal::Function::Result Result; - - // Asserts at compile time that F returns void. - CompileAssertTypesEqual(); - - return Action(new Impl(action_)); - } - - private: - template - class Impl : public ActionInterface { - public: - typedef typename internal::Function::Result Result; - typedef typename internal::Function::ArgumentTuple ArgumentTuple; - - explicit Impl(const A& action) : action_(action) {} - - virtual void Perform(const ArgumentTuple& args) { - // Performs the action and ignores its result. - action_.Perform(args); - } - - private: - // Type OriginalFunction is the same as F except that its return - // type is IgnoredValue. - typedef typename internal::Function::MakeResultIgnoredValue - OriginalFunction; - - const Action action_; - - GTEST_DISALLOW_ASSIGN_(Impl); - }; - - const A action_; - - GTEST_DISALLOW_ASSIGN_(IgnoreResultAction); -}; - -// A ReferenceWrapper object represents a reference to type T, -// which can be either const or not. It can be explicitly converted -// from, and implicitly converted to, a T&. Unlike a reference, -// ReferenceWrapper can be copied and can survive template type -// inference. This is used to support by-reference arguments in the -// InvokeArgument(...) action. The idea was from "reference -// wrappers" in tr1, which we don't have in our source tree yet. -template -class ReferenceWrapper { - public: - // Constructs a ReferenceWrapper object from a T&. - explicit ReferenceWrapper(T& l_value) : pointer_(&l_value) {} // NOLINT - - // Allows a ReferenceWrapper object to be implicitly converted to - // a T&. - operator T&() const { return *pointer_; } - private: - T* pointer_; -}; - -// Allows the expression ByRef(x) to be printed as a reference to x. -template -void PrintTo(const ReferenceWrapper& ref, ::std::ostream* os) { - T& value = ref; - UniversalPrinter::Print(value, os); -} - -// Does two actions sequentially. Used for implementing the DoAll(a1, -// a2, ...) action. -template -class DoBothAction { - public: - DoBothAction(Action1 action1, Action2 action2) - : action1_(action1), action2_(action2) {} - - // This template type conversion operator allows DoAll(a1, ..., a_n) - // to be used in ANY function of compatible type. - template - operator Action() const { - return Action(new Impl(action1_, action2_)); - } - - private: - // Implements the DoAll(...) action for a particular function type F. - template - class Impl : public ActionInterface { - public: - typedef typename Function::Result Result; - typedef typename Function::ArgumentTuple ArgumentTuple; - typedef typename Function::MakeResultVoid VoidResult; - - Impl(const Action& action1, const Action& action2) - : action1_(action1), action2_(action2) {} - - virtual Result Perform(const ArgumentTuple& args) { - action1_.Perform(args); - return action2_.Perform(args); - } - - private: - const Action action1_; - const Action action2_; - - GTEST_DISALLOW_ASSIGN_(Impl); - }; - - Action1 action1_; - Action2 action2_; - - GTEST_DISALLOW_ASSIGN_(DoBothAction); -}; - -} // namespace internal - -// An Unused object can be implicitly constructed from ANY value. -// This is handy when defining actions that ignore some or all of the -// mock function arguments. For example, given -// -// MOCK_METHOD3(Foo, double(const string& label, double x, double y)); -// MOCK_METHOD3(Bar, double(int index, double x, double y)); -// -// instead of -// -// double DistanceToOriginWithLabel(const string& label, double x, double y) { -// return sqrt(x*x + y*y); -// } -// double DistanceToOriginWithIndex(int index, double x, double y) { -// return sqrt(x*x + y*y); -// } -// ... -// EXPECT_CALL(mock, Foo("abc", _, _)) -// .WillOnce(Invoke(DistanceToOriginWithLabel)); -// EXPECT_CALL(mock, Bar(5, _, _)) -// .WillOnce(Invoke(DistanceToOriginWithIndex)); -// -// you could write -// -// // We can declare any uninteresting argument as Unused. -// double DistanceToOrigin(Unused, double x, double y) { -// return sqrt(x*x + y*y); -// } -// ... -// EXPECT_CALL(mock, Foo("abc", _, _)).WillOnce(Invoke(DistanceToOrigin)); -// EXPECT_CALL(mock, Bar(5, _, _)).WillOnce(Invoke(DistanceToOrigin)); -typedef internal::IgnoredValue Unused; - -// This constructor allows us to turn an Action object into an -// Action, as long as To's arguments can be implicitly converted -// to From's and From's return type cann be implicitly converted to -// To's. -template -template -Action::Action(const Action& from) - : -#if GTEST_LANG_CXX11 - fun_(from.fun_), -#endif - impl_(from.impl_ == NULL ? NULL - : new internal::ActionAdaptor(from)) { -} - -// Creates an action that returns 'value'. 'value' is passed by value -// instead of const reference - otherwise Return("string literal") -// will trigger a compiler error about using array as initializer. -template -internal::ReturnAction Return(R value) { - return internal::ReturnAction(internal::move(value)); -} - -// Creates an action that returns NULL. -inline PolymorphicAction ReturnNull() { - return MakePolymorphicAction(internal::ReturnNullAction()); -} - -// Creates an action that returns from a void function. -inline PolymorphicAction Return() { - return MakePolymorphicAction(internal::ReturnVoidAction()); -} - -// Creates an action that returns the reference to a variable. -template -inline internal::ReturnRefAction ReturnRef(R& x) { // NOLINT - return internal::ReturnRefAction(x); -} - -// Creates an action that returns the reference to a copy of the -// argument. The copy is created when the action is constructed and -// lives as long as the action. -template -inline internal::ReturnRefOfCopyAction ReturnRefOfCopy(const R& x) { - return internal::ReturnRefOfCopyAction(x); -} - -// Modifies the parent action (a Return() action) to perform a move of the -// argument instead of a copy. -// Return(ByMove()) actions can only be executed once and will assert this -// invariant. -template -internal::ByMoveWrapper ByMove(R x) { - return internal::ByMoveWrapper(internal::move(x)); -} - -// Creates an action that does the default action for the give mock function. -inline internal::DoDefaultAction DoDefault() { - return internal::DoDefaultAction(); -} - -// Creates an action that sets the variable pointed by the N-th -// (0-based) function argument to 'value'. -template -PolymorphicAction< - internal::SetArgumentPointeeAction< - N, T, internal::IsAProtocolMessage::value> > -SetArgPointee(const T& x) { - return MakePolymorphicAction(internal::SetArgumentPointeeAction< - N, T, internal::IsAProtocolMessage::value>(x)); -} - -#if !((GTEST_GCC_VER_ && GTEST_GCC_VER_ < 40000) || GTEST_OS_SYMBIAN) -// This overload allows SetArgPointee() to accept a string literal. -// GCC prior to the version 4.0 and Symbian C++ compiler cannot distinguish -// this overload from the templated version and emit a compile error. -template -PolymorphicAction< - internal::SetArgumentPointeeAction > -SetArgPointee(const char* p) { - return MakePolymorphicAction(internal::SetArgumentPointeeAction< - N, const char*, false>(p)); -} - -template -PolymorphicAction< - internal::SetArgumentPointeeAction > -SetArgPointee(const wchar_t* p) { - return MakePolymorphicAction(internal::SetArgumentPointeeAction< - N, const wchar_t*, false>(p)); -} -#endif - -// The following version is DEPRECATED. -template -PolymorphicAction< - internal::SetArgumentPointeeAction< - N, T, internal::IsAProtocolMessage::value> > -SetArgumentPointee(const T& x) { - return MakePolymorphicAction(internal::SetArgumentPointeeAction< - N, T, internal::IsAProtocolMessage::value>(x)); -} - -// Creates an action that sets a pointer referent to a given value. -template -PolymorphicAction > Assign(T1* ptr, T2 val) { - return MakePolymorphicAction(internal::AssignAction(ptr, val)); -} - -#if !GTEST_OS_WINDOWS_MOBILE - -// Creates an action that sets errno and returns the appropriate error. -template -PolymorphicAction > -SetErrnoAndReturn(int errval, T result) { - return MakePolymorphicAction( - internal::SetErrnoAndReturnAction(errval, result)); -} - -#endif // !GTEST_OS_WINDOWS_MOBILE - -// Various overloads for InvokeWithoutArgs(). - -// Creates an action that invokes 'function_impl' with no argument. -template -PolymorphicAction > -InvokeWithoutArgs(FunctionImpl function_impl) { - return MakePolymorphicAction( - internal::InvokeWithoutArgsAction(function_impl)); -} - -// Creates an action that invokes the given method on the given object -// with no argument. -template -PolymorphicAction > -InvokeWithoutArgs(Class* obj_ptr, MethodPtr method_ptr) { - return MakePolymorphicAction( - internal::InvokeMethodWithoutArgsAction( - obj_ptr, method_ptr)); -} - -// Creates an action that performs an_action and throws away its -// result. In other words, it changes the return type of an_action to -// void. an_action MUST NOT return void, or the code won't compile. -template -inline internal::IgnoreResultAction IgnoreResult(const A& an_action) { - return internal::IgnoreResultAction(an_action); -} - -// Creates a reference wrapper for the given L-value. If necessary, -// you can explicitly specify the type of the reference. For example, -// suppose 'derived' is an object of type Derived, ByRef(derived) -// would wrap a Derived&. If you want to wrap a const Base& instead, -// where Base is a base class of Derived, just write: -// -// ByRef(derived) -template -inline internal::ReferenceWrapper ByRef(T& l_value) { // NOLINT - return internal::ReferenceWrapper(l_value); -} - -} // namespace testing - -#endif // GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_ -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) - -// Google Mock - a framework for writing C++ mock classes. -// -// This file implements some commonly used cardinalities. More -// cardinalities can be defined by the user implementing the -// CardinalityInterface interface if necessary. - -#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_ -#define GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_ - -#include -#include // NOLINT - -namespace testing { - -// To implement a cardinality Foo, define: -// 1. a class FooCardinality that implements the -// CardinalityInterface interface, and -// 2. a factory function that creates a Cardinality object from a -// const FooCardinality*. -// -// The two-level delegation design follows that of Matcher, providing -// consistency for extension developers. It also eases ownership -// management as Cardinality objects can now be copied like plain values. - -// The implementation of a cardinality. -class CardinalityInterface { - public: - virtual ~CardinalityInterface() {} - - // Conservative estimate on the lower/upper bound of the number of - // calls allowed. - virtual int ConservativeLowerBound() const { return 0; } - virtual int ConservativeUpperBound() const { return INT_MAX; } - - // Returns true iff call_count calls will satisfy this cardinality. - virtual bool IsSatisfiedByCallCount(int call_count) const = 0; - - // Returns true iff call_count calls will saturate this cardinality. - virtual bool IsSaturatedByCallCount(int call_count) const = 0; - - // Describes self to an ostream. - virtual void DescribeTo(::std::ostream* os) const = 0; -}; - -// A Cardinality is a copyable and IMMUTABLE (except by assignment) -// object that specifies how many times a mock function is expected to -// be called. The implementation of Cardinality is just a linked_ptr -// to const CardinalityInterface, so copying is fairly cheap. -// Don't inherit from Cardinality! -class GTEST_API_ Cardinality { - public: - // Constructs a null cardinality. Needed for storing Cardinality - // objects in STL containers. - Cardinality() {} - - // Constructs a Cardinality from its implementation. - explicit Cardinality(const CardinalityInterface* impl) : impl_(impl) {} - - // Conservative estimate on the lower/upper bound of the number of - // calls allowed. - int ConservativeLowerBound() const { return impl_->ConservativeLowerBound(); } - int ConservativeUpperBound() const { return impl_->ConservativeUpperBound(); } - - // Returns true iff call_count calls will satisfy this cardinality. - bool IsSatisfiedByCallCount(int call_count) const { - return impl_->IsSatisfiedByCallCount(call_count); - } - - // Returns true iff call_count calls will saturate this cardinality. - bool IsSaturatedByCallCount(int call_count) const { - return impl_->IsSaturatedByCallCount(call_count); - } - - // Returns true iff call_count calls will over-saturate this - // cardinality, i.e. exceed the maximum number of allowed calls. - bool IsOverSaturatedByCallCount(int call_count) const { - return impl_->IsSaturatedByCallCount(call_count) && - !impl_->IsSatisfiedByCallCount(call_count); - } - - // Describes self to an ostream - void DescribeTo(::std::ostream* os) const { impl_->DescribeTo(os); } - - // Describes the given actual call count to an ostream. - static void DescribeActualCallCountTo(int actual_call_count, - ::std::ostream* os); - - private: - internal::linked_ptr impl_; -}; - -// Creates a cardinality that allows at least n calls. -GTEST_API_ Cardinality AtLeast(int n); - -// Creates a cardinality that allows at most n calls. -GTEST_API_ Cardinality AtMost(int n); - -// Creates a cardinality that allows any number of calls. -GTEST_API_ Cardinality AnyNumber(); - -// Creates a cardinality that allows between min and max calls. -GTEST_API_ Cardinality Between(int min, int max); - -// Creates a cardinality that allows exactly n calls. -GTEST_API_ Cardinality Exactly(int n); - -// Creates a cardinality from its implementation. -inline Cardinality MakeCardinality(const CardinalityInterface* c) { - return Cardinality(c); -} - -} // namespace testing - -#endif // GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_ -// This file was GENERATED by command: -// pump.py gmock-generated-actions.h.pump -// DO NOT EDIT BY HAND!!! - -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) - -// Google Mock - a framework for writing C++ mock classes. -// -// This file implements some commonly used variadic actions. - -#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ -#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ - - -namespace testing { -namespace internal { - -// InvokeHelper knows how to unpack an N-tuple and invoke an N-ary -// function, method, or callback with the unpacked values, where F is -// a function type that takes N arguments. -template -class InvokeHelper; - -template -class InvokeHelper > { - public: - template - static R Invoke(Function function, const ::testing::tuple<>&) { - return function(); - } - - template - static R InvokeMethod(Class* obj_ptr, - MethodPtr method_ptr, - const ::testing::tuple<>&) { - return (obj_ptr->*method_ptr)(); - } - - template - static R InvokeCallback(CallbackType* callback, - const ::testing::tuple<>&) { - return callback->Run(); - } -}; - -template -class InvokeHelper > { - public: - template - static R Invoke(Function function, const ::testing::tuple& args) { - return function(get<0>(args)); - } - - template - static R InvokeMethod(Class* obj_ptr, - MethodPtr method_ptr, - const ::testing::tuple& args) { - return (obj_ptr->*method_ptr)(get<0>(args)); - } - - template - static R InvokeCallback(CallbackType* callback, - const ::testing::tuple& args) { - return callback->Run(get<0>(args)); - } -}; - -template -class InvokeHelper > { - public: - template - static R Invoke(Function function, const ::testing::tuple& args) { - return function(get<0>(args), get<1>(args)); - } - - template - static R InvokeMethod(Class* obj_ptr, - MethodPtr method_ptr, - const ::testing::tuple& args) { - return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args)); - } - - template - static R InvokeCallback(CallbackType* callback, - const ::testing::tuple& args) { - return callback->Run(get<0>(args), get<1>(args)); - } -}; - -template -class InvokeHelper > { - public: - template - static R Invoke(Function function, const ::testing::tuple& args) { - return function(get<0>(args), get<1>(args), get<2>(args)); - } - - template - static R InvokeMethod(Class* obj_ptr, - MethodPtr method_ptr, - const ::testing::tuple& args) { - return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), - get<2>(args)); - } - - template - static R InvokeCallback(CallbackType* callback, - const ::testing::tuple& args) { - return callback->Run(get<0>(args), get<1>(args), get<2>(args)); - } -}; - -template -class InvokeHelper > { - public: - template - static R Invoke(Function function, const ::testing::tuple& args) { - return function(get<0>(args), get<1>(args), get<2>(args), - get<3>(args)); - } - - template - static R InvokeMethod(Class* obj_ptr, - MethodPtr method_ptr, - const ::testing::tuple& args) { - return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), - get<2>(args), get<3>(args)); - } - - template - static R InvokeCallback(CallbackType* callback, - const ::testing::tuple& args) { - return callback->Run(get<0>(args), get<1>(args), get<2>(args), - get<3>(args)); - } -}; - -template -class InvokeHelper > { - public: - template - static R Invoke(Function function, const ::testing::tuple& args) { - return function(get<0>(args), get<1>(args), get<2>(args), - get<3>(args), get<4>(args)); - } - - template - static R InvokeMethod(Class* obj_ptr, - MethodPtr method_ptr, - const ::testing::tuple& args) { - return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), - get<2>(args), get<3>(args), get<4>(args)); - } - - template - static R InvokeCallback(CallbackType* callback, - const ::testing::tuple& args) { - return callback->Run(get<0>(args), get<1>(args), get<2>(args), - get<3>(args), get<4>(args)); - } -}; - -template -class InvokeHelper > { - public: - template - static R Invoke(Function function, const ::testing::tuple& args) { - return function(get<0>(args), get<1>(args), get<2>(args), - get<3>(args), get<4>(args), get<5>(args)); - } - - template - static R InvokeMethod(Class* obj_ptr, - MethodPtr method_ptr, - const ::testing::tuple& args) { - return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), - get<2>(args), get<3>(args), get<4>(args), get<5>(args)); - } - - // There is no InvokeCallback() for 6-tuples, as google3 callbacks - // support 5 arguments at most. -}; - -template -class InvokeHelper > { - public: - template - static R Invoke(Function function, const ::testing::tuple& args) { - return function(get<0>(args), get<1>(args), get<2>(args), - get<3>(args), get<4>(args), get<5>(args), get<6>(args)); - } - - template - static R InvokeMethod(Class* obj_ptr, - MethodPtr method_ptr, - const ::testing::tuple& args) { - return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), - get<2>(args), get<3>(args), get<4>(args), get<5>(args), - get<6>(args)); - } - - // There is no InvokeCallback() for 7-tuples, as google3 callbacks - // support 5 arguments at most. -}; - -template -class InvokeHelper > { - public: - template - static R Invoke(Function function, const ::testing::tuple& args) { - return function(get<0>(args), get<1>(args), get<2>(args), - get<3>(args), get<4>(args), get<5>(args), get<6>(args), - get<7>(args)); - } - - template - static R InvokeMethod(Class* obj_ptr, - MethodPtr method_ptr, - const ::testing::tuple& args) { - return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), - get<2>(args), get<3>(args), get<4>(args), get<5>(args), - get<6>(args), get<7>(args)); - } - - // There is no InvokeCallback() for 8-tuples, as google3 callbacks - // support 5 arguments at most. -}; - -template -class InvokeHelper > { - public: - template - static R Invoke(Function function, const ::testing::tuple& args) { - return function(get<0>(args), get<1>(args), get<2>(args), - get<3>(args), get<4>(args), get<5>(args), get<6>(args), - get<7>(args), get<8>(args)); - } - - template - static R InvokeMethod(Class* obj_ptr, - MethodPtr method_ptr, - const ::testing::tuple& args) { - return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), - get<2>(args), get<3>(args), get<4>(args), get<5>(args), - get<6>(args), get<7>(args), get<8>(args)); - } - - // There is no InvokeCallback() for 9-tuples, as google3 callbacks - // support 5 arguments at most. -}; - -template -class InvokeHelper > { - public: - template - static R Invoke(Function function, const ::testing::tuple& args) { - return function(get<0>(args), get<1>(args), get<2>(args), - get<3>(args), get<4>(args), get<5>(args), get<6>(args), - get<7>(args), get<8>(args), get<9>(args)); - } - - template - static R InvokeMethod(Class* obj_ptr, - MethodPtr method_ptr, - const ::testing::tuple& args) { - return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), - get<2>(args), get<3>(args), get<4>(args), get<5>(args), - get<6>(args), get<7>(args), get<8>(args), get<9>(args)); - } - - // There is no InvokeCallback() for 10-tuples, as google3 callbacks - // support 5 arguments at most. -}; - -// Implements the Invoke(callback) action. -template -class InvokeCallbackAction { - public: - // The c'tor takes ownership of the callback. - explicit InvokeCallbackAction(CallbackType* callback) - : callback_(callback) { - callback->CheckIsRepeatable(); // Makes sure the callback is permanent. - } - - // This type conversion operator template allows Invoke(callback) to - // be used wherever the callback's type is compatible with that of - // the mock function, i.e. if the mock function's arguments can be - // implicitly converted to the callback's arguments and the - // callback's result can be implicitly converted to the mock - // function's result. - template - Result Perform(const ArgumentTuple& args) const { - return InvokeHelper::InvokeCallback( - callback_.get(), args); - } - private: - const linked_ptr callback_; -}; - -// An INTERNAL macro for extracting the type of a tuple field. It's -// subject to change without notice - DO NOT USE IN USER CODE! -#define GMOCK_FIELD_(Tuple, N) \ - typename ::testing::tuple_element::type - -// SelectArgs::type is the -// type of an n-ary function whose i-th (1-based) argument type is the -// k{i}-th (0-based) field of ArgumentTuple, which must be a tuple -// type, and whose return type is Result. For example, -// SelectArgs, 0, 3>::type -// is int(bool, long). -// -// SelectArgs::Select(args) -// returns the selected fields (k1, k2, ..., k_n) of args as a tuple. -// For example, -// SelectArgs, 2, 0>::Select( -// ::testing::make_tuple(true, 'a', 2.5)) -// returns tuple (2.5, true). -// -// The numbers in list k1, k2, ..., k_n must be >= 0, where n can be -// in the range [0, 10]. Duplicates are allowed and they don't have -// to be in an ascending or descending order. - -template -class SelectArgs { - public: - typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), - GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), - GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5), - GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7), - GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9), - GMOCK_FIELD_(ArgumentTuple, k10)); - typedef typename Function::ArgumentTuple SelectedArgs; - static SelectedArgs Select(const ArgumentTuple& args) { - return SelectedArgs(get(args), get(args), get(args), - get(args), get(args), get(args), get(args), - get(args), get(args), get(args)); - } -}; - -template -class SelectArgs { - public: - typedef Result type(); - typedef typename Function::ArgumentTuple SelectedArgs; - static SelectedArgs Select(const ArgumentTuple& /* args */) { - return SelectedArgs(); - } -}; - -template -class SelectArgs { - public: - typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1)); - typedef typename Function::ArgumentTuple SelectedArgs; - static SelectedArgs Select(const ArgumentTuple& args) { - return SelectedArgs(get(args)); - } -}; - -template -class SelectArgs { - public: - typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), - GMOCK_FIELD_(ArgumentTuple, k2)); - typedef typename Function::ArgumentTuple SelectedArgs; - static SelectedArgs Select(const ArgumentTuple& args) { - return SelectedArgs(get(args), get(args)); - } -}; - -template -class SelectArgs { - public: - typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), - GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3)); - typedef typename Function::ArgumentTuple SelectedArgs; - static SelectedArgs Select(const ArgumentTuple& args) { - return SelectedArgs(get(args), get(args), get(args)); - } -}; - -template -class SelectArgs { - public: - typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), - GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), - GMOCK_FIELD_(ArgumentTuple, k4)); - typedef typename Function::ArgumentTuple SelectedArgs; - static SelectedArgs Select(const ArgumentTuple& args) { - return SelectedArgs(get(args), get(args), get(args), - get(args)); - } -}; - -template -class SelectArgs { - public: - typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), - GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), - GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5)); - typedef typename Function::ArgumentTuple SelectedArgs; - static SelectedArgs Select(const ArgumentTuple& args) { - return SelectedArgs(get(args), get(args), get(args), - get(args), get(args)); - } -}; - -template -class SelectArgs { - public: - typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), - GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), - GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5), - GMOCK_FIELD_(ArgumentTuple, k6)); - typedef typename Function::ArgumentTuple SelectedArgs; - static SelectedArgs Select(const ArgumentTuple& args) { - return SelectedArgs(get(args), get(args), get(args), - get(args), get(args), get(args)); - } -}; - -template -class SelectArgs { - public: - typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), - GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), - GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5), - GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7)); - typedef typename Function::ArgumentTuple SelectedArgs; - static SelectedArgs Select(const ArgumentTuple& args) { - return SelectedArgs(get(args), get(args), get(args), - get(args), get(args), get(args), get(args)); - } -}; - -template -class SelectArgs { - public: - typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), - GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), - GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5), - GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7), - GMOCK_FIELD_(ArgumentTuple, k8)); - typedef typename Function::ArgumentTuple SelectedArgs; - static SelectedArgs Select(const ArgumentTuple& args) { - return SelectedArgs(get(args), get(args), get(args), - get(args), get(args), get(args), get(args), - get(args)); - } -}; - -template -class SelectArgs { - public: - typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), - GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), - GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5), - GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7), - GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9)); - typedef typename Function::ArgumentTuple SelectedArgs; - static SelectedArgs Select(const ArgumentTuple& args) { - return SelectedArgs(get(args), get(args), get(args), - get(args), get(args), get(args), get(args), - get(args), get(args)); - } -}; - -#undef GMOCK_FIELD_ - -// Implements the WithArgs action. -template -class WithArgsAction { - public: - explicit WithArgsAction(const InnerAction& action) : action_(action) {} - - template - operator Action() const { return MakeAction(new Impl(action_)); } - - private: - template - class Impl : public ActionInterface { - public: - typedef typename Function::Result Result; - typedef typename Function::ArgumentTuple ArgumentTuple; - - explicit Impl(const InnerAction& action) : action_(action) {} - - virtual Result Perform(const ArgumentTuple& args) { - return action_.Perform(SelectArgs::Select(args)); - } - - private: - typedef typename SelectArgs::type InnerFunctionType; - - Action action_; - }; - - const InnerAction action_; - - GTEST_DISALLOW_ASSIGN_(WithArgsAction); -}; - -// A macro from the ACTION* family (defined later in this file) -// defines an action that can be used in a mock function. Typically, -// these actions only care about a subset of the arguments of the mock -// function. For example, if such an action only uses the second -// argument, it can be used in any mock function that takes >= 2 -// arguments where the type of the second argument is compatible. -// -// Therefore, the action implementation must be prepared to take more -// arguments than it needs. The ExcessiveArg type is used to -// represent those excessive arguments. In order to keep the compiler -// error messages tractable, we define it in the testing namespace -// instead of testing::internal. However, this is an INTERNAL TYPE -// and subject to change without notice, so a user MUST NOT USE THIS -// TYPE DIRECTLY. -struct ExcessiveArg {}; - -// A helper class needed for implementing the ACTION* macros. -template -class ActionHelper { - public: - static Result Perform(Impl* impl, const ::testing::tuple<>& args) { - return impl->template gmock_PerformImpl<>(args, ExcessiveArg(), - ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), - ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), - ExcessiveArg()); - } - - template - static Result Perform(Impl* impl, const ::testing::tuple& args) { - return impl->template gmock_PerformImpl(args, get<0>(args), - ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), - ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), - ExcessiveArg()); - } - - template - static Result Perform(Impl* impl, const ::testing::tuple& args) { - return impl->template gmock_PerformImpl(args, get<0>(args), - get<1>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), - ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), - ExcessiveArg()); - } - - template - static Result Perform(Impl* impl, const ::testing::tuple& args) { - return impl->template gmock_PerformImpl(args, get<0>(args), - get<1>(args), get<2>(args), ExcessiveArg(), ExcessiveArg(), - ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), - ExcessiveArg()); - } - - template - static Result Perform(Impl* impl, const ::testing::tuple& args) { - return impl->template gmock_PerformImpl(args, get<0>(args), - get<1>(args), get<2>(args), get<3>(args), ExcessiveArg(), - ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), - ExcessiveArg()); - } - - template - static Result Perform(Impl* impl, const ::testing::tuple& args) { - return impl->template gmock_PerformImpl(args, - get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args), - ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), - ExcessiveArg()); - } - - template - static Result Perform(Impl* impl, const ::testing::tuple& args) { - return impl->template gmock_PerformImpl(args, - get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args), - get<5>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), - ExcessiveArg()); - } - - template - static Result Perform(Impl* impl, const ::testing::tuple& args) { - return impl->template gmock_PerformImpl(args, - get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args), - get<5>(args), get<6>(args), ExcessiveArg(), ExcessiveArg(), - ExcessiveArg()); - } - - template - static Result Perform(Impl* impl, const ::testing::tuple& args) { - return impl->template gmock_PerformImpl(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args), - get<4>(args), get<5>(args), get<6>(args), get<7>(args), ExcessiveArg(), - ExcessiveArg()); - } - - template - static Result Perform(Impl* impl, const ::testing::tuple& args) { - return impl->template gmock_PerformImpl(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args), - get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args), - ExcessiveArg()); - } - - template - static Result Perform(Impl* impl, const ::testing::tuple& args) { - return impl->template gmock_PerformImpl(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args), - get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args), - get<9>(args)); - } -}; - -} // namespace internal - -// Various overloads for Invoke(). - -// WithArgs(an_action) creates an action that passes -// the selected arguments of the mock function to an_action and -// performs it. It serves as an adaptor between actions with -// different argument lists. C++ doesn't support default arguments for -// function templates, so we have to overload it. -template -inline internal::WithArgsAction -WithArgs(const InnerAction& action) { - return internal::WithArgsAction(action); -} - -template -inline internal::WithArgsAction -WithArgs(const InnerAction& action) { - return internal::WithArgsAction(action); -} - -template -inline internal::WithArgsAction -WithArgs(const InnerAction& action) { - return internal::WithArgsAction(action); -} - -template -inline internal::WithArgsAction -WithArgs(const InnerAction& action) { - return internal::WithArgsAction(action); -} - -template -inline internal::WithArgsAction -WithArgs(const InnerAction& action) { - return internal::WithArgsAction(action); -} - -template -inline internal::WithArgsAction -WithArgs(const InnerAction& action) { - return internal::WithArgsAction(action); -} - -template -inline internal::WithArgsAction -WithArgs(const InnerAction& action) { - return internal::WithArgsAction(action); -} - -template -inline internal::WithArgsAction -WithArgs(const InnerAction& action) { - return internal::WithArgsAction(action); -} - -template -inline internal::WithArgsAction -WithArgs(const InnerAction& action) { - return internal::WithArgsAction(action); -} - -template -inline internal::WithArgsAction -WithArgs(const InnerAction& action) { - return internal::WithArgsAction(action); -} - -// Creates an action that does actions a1, a2, ..., sequentially in -// each invocation. -template -inline internal::DoBothAction -DoAll(Action1 a1, Action2 a2) { - return internal::DoBothAction(a1, a2); -} - -template -inline internal::DoBothAction > -DoAll(Action1 a1, Action2 a2, Action3 a3) { - return DoAll(a1, DoAll(a2, a3)); -} - -template -inline internal::DoBothAction > > -DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4) { - return DoAll(a1, DoAll(a2, a3, a4)); -} - -template -inline internal::DoBothAction > > > -DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5) { - return DoAll(a1, DoAll(a2, a3, a4, a5)); -} - -template -inline internal::DoBothAction > > > > -DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6) { - return DoAll(a1, DoAll(a2, a3, a4, a5, a6)); -} - -template -inline internal::DoBothAction > > > > > -DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6, - Action7 a7) { - return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7)); -} - -template -inline internal::DoBothAction > > > > > > -DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6, - Action7 a7, Action8 a8) { - return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8)); -} - -template -inline internal::DoBothAction > > > > > > > -DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6, - Action7 a7, Action8 a8, Action9 a9) { - return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9)); -} - -template -inline internal::DoBothAction > > > > > > > > -DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6, - Action7 a7, Action8 a8, Action9 a9, Action10 a10) { - return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9, a10)); -} - -} // namespace testing - -// The ACTION* family of macros can be used in a namespace scope to -// define custom actions easily. The syntax: -// -// ACTION(name) { statements; } -// -// will define an action with the given name that executes the -// statements. The value returned by the statements will be used as -// the return value of the action. Inside the statements, you can -// refer to the K-th (0-based) argument of the mock function by -// 'argK', and refer to its type by 'argK_type'. For example: -// -// ACTION(IncrementArg1) { -// arg1_type temp = arg1; -// return ++(*temp); -// } -// -// allows you to write -// -// ...WillOnce(IncrementArg1()); -// -// You can also refer to the entire argument tuple and its type by -// 'args' and 'args_type', and refer to the mock function type and its -// return type by 'function_type' and 'return_type'. -// -// Note that you don't need to specify the types of the mock function -// arguments. However rest assured that your code is still type-safe: -// you'll get a compiler error if *arg1 doesn't support the ++ -// operator, or if the type of ++(*arg1) isn't compatible with the -// mock function's return type, for example. -// -// Sometimes you'll want to parameterize the action. For that you can use -// another macro: -// -// ACTION_P(name, param_name) { statements; } -// -// For example: -// -// ACTION_P(Add, n) { return arg0 + n; } -// -// will allow you to write: -// -// ...WillOnce(Add(5)); -// -// Note that you don't need to provide the type of the parameter -// either. If you need to reference the type of a parameter named -// 'foo', you can write 'foo_type'. For example, in the body of -// ACTION_P(Add, n) above, you can write 'n_type' to refer to the type -// of 'n'. -// -// We also provide ACTION_P2, ACTION_P3, ..., up to ACTION_P10 to support -// multi-parameter actions. -// -// For the purpose of typing, you can view -// -// ACTION_Pk(Foo, p1, ..., pk) { ... } -// -// as shorthand for -// -// template -// FooActionPk Foo(p1_type p1, ..., pk_type pk) { ... } -// -// In particular, you can provide the template type arguments -// explicitly when invoking Foo(), as in Foo(5, false); -// although usually you can rely on the compiler to infer the types -// for you automatically. You can assign the result of expression -// Foo(p1, ..., pk) to a variable of type FooActionPk. This can be useful when composing actions. -// -// You can also overload actions with different numbers of parameters: -// -// ACTION_P(Plus, a) { ... } -// ACTION_P2(Plus, a, b) { ... } -// -// While it's tempting to always use the ACTION* macros when defining -// a new action, you should also consider implementing ActionInterface -// or using MakePolymorphicAction() instead, especially if you need to -// use the action a lot. While these approaches require more work, -// they give you more control on the types of the mock function -// arguments and the action parameters, which in general leads to -// better compiler error messages that pay off in the long run. They -// also allow overloading actions based on parameter types (as opposed -// to just based on the number of parameters). -// -// CAVEAT: -// -// ACTION*() can only be used in a namespace scope. The reason is -// that C++ doesn't yet allow function-local types to be used to -// instantiate templates. The up-coming C++0x standard will fix this. -// Once that's done, we'll consider supporting using ACTION*() inside -// a function. -// -// MORE INFORMATION: -// -// To learn more about using these macros, please search for 'ACTION' -// on https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md - -// An internal macro needed for implementing ACTION*(). -#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_\ - const args_type& args GTEST_ATTRIBUTE_UNUSED_, \ - arg0_type arg0 GTEST_ATTRIBUTE_UNUSED_, \ - arg1_type arg1 GTEST_ATTRIBUTE_UNUSED_, \ - arg2_type arg2 GTEST_ATTRIBUTE_UNUSED_, \ - arg3_type arg3 GTEST_ATTRIBUTE_UNUSED_, \ - arg4_type arg4 GTEST_ATTRIBUTE_UNUSED_, \ - arg5_type arg5 GTEST_ATTRIBUTE_UNUSED_, \ - arg6_type arg6 GTEST_ATTRIBUTE_UNUSED_, \ - arg7_type arg7 GTEST_ATTRIBUTE_UNUSED_, \ - arg8_type arg8 GTEST_ATTRIBUTE_UNUSED_, \ - arg9_type arg9 GTEST_ATTRIBUTE_UNUSED_ - -// Sometimes you want to give an action explicit template parameters -// that cannot be inferred from its value parameters. ACTION() and -// ACTION_P*() don't support that. ACTION_TEMPLATE() remedies that -// and can be viewed as an extension to ACTION() and ACTION_P*(). -// -// The syntax: -// -// ACTION_TEMPLATE(ActionName, -// HAS_m_TEMPLATE_PARAMS(kind1, name1, ..., kind_m, name_m), -// AND_n_VALUE_PARAMS(p1, ..., p_n)) { statements; } -// -// defines an action template that takes m explicit template -// parameters and n value parameters. name_i is the name of the i-th -// template parameter, and kind_i specifies whether it's a typename, -// an integral constant, or a template. p_i is the name of the i-th -// value parameter. -// -// Example: -// -// // DuplicateArg(output) converts the k-th argument of the mock -// // function to type T and copies it to *output. -// ACTION_TEMPLATE(DuplicateArg, -// HAS_2_TEMPLATE_PARAMS(int, k, typename, T), -// AND_1_VALUE_PARAMS(output)) { -// *output = T(::testing::get(args)); -// } -// ... -// int n; -// EXPECT_CALL(mock, Foo(_, _)) -// .WillOnce(DuplicateArg<1, unsigned char>(&n)); -// -// To create an instance of an action template, write: -// -// ActionName(v1, ..., v_n) -// -// where the ts are the template arguments and the vs are the value -// arguments. The value argument types are inferred by the compiler. -// If you want to explicitly specify the value argument types, you can -// provide additional template arguments: -// -// ActionName(v1, ..., v_n) -// -// where u_i is the desired type of v_i. -// -// ACTION_TEMPLATE and ACTION/ACTION_P* can be overloaded on the -// number of value parameters, but not on the number of template -// parameters. Without the restriction, the meaning of the following -// is unclear: -// -// OverloadedAction(x); -// -// Are we using a single-template-parameter action where 'bool' refers -// to the type of x, or are we using a two-template-parameter action -// where the compiler is asked to infer the type of x? -// -// Implementation notes: -// -// GMOCK_INTERNAL_*_HAS_m_TEMPLATE_PARAMS and -// GMOCK_INTERNAL_*_AND_n_VALUE_PARAMS are internal macros for -// implementing ACTION_TEMPLATE. The main trick we use is to create -// new macro invocations when expanding a macro. For example, we have -// -// #define ACTION_TEMPLATE(name, template_params, value_params) -// ... GMOCK_INTERNAL_DECL_##template_params ... -// -// which causes ACTION_TEMPLATE(..., HAS_1_TEMPLATE_PARAMS(typename, T), ...) -// to expand to -// -// ... GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(typename, T) ... -// -// Since GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS is a macro, the -// preprocessor will continue to expand it to -// -// ... typename T ... -// -// This technique conforms to the C++ standard and is portable. It -// allows us to implement action templates using O(N) code, where N is -// the maximum number of template/value parameters supported. Without -// using it, we'd have to devote O(N^2) amount of code to implement all -// combinations of m and n. - -// Declares the template parameters. -#define GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(kind0, name0) kind0 name0 -#define GMOCK_INTERNAL_DECL_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \ - name1) kind0 name0, kind1 name1 -#define GMOCK_INTERNAL_DECL_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2) kind0 name0, kind1 name1, kind2 name2 -#define GMOCK_INTERNAL_DECL_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3) kind0 name0, kind1 name1, kind2 name2, \ - kind3 name3 -#define GMOCK_INTERNAL_DECL_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4) kind0 name0, kind1 name1, \ - kind2 name2, kind3 name3, kind4 name4 -#define GMOCK_INTERNAL_DECL_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5) kind0 name0, \ - kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5 -#define GMOCK_INTERNAL_DECL_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \ - name6) kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \ - kind5 name5, kind6 name6 -#define GMOCK_INTERNAL_DECL_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \ - kind7, name7) kind0 name0, kind1 name1, kind2 name2, kind3 name3, \ - kind4 name4, kind5 name5, kind6 name6, kind7 name7 -#define GMOCK_INTERNAL_DECL_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \ - kind7, name7, kind8, name8) kind0 name0, kind1 name1, kind2 name2, \ - kind3 name3, kind4 name4, kind5 name5, kind6 name6, kind7 name7, \ - kind8 name8 -#define GMOCK_INTERNAL_DECL_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \ - name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \ - name6, kind7, name7, kind8, name8, kind9, name9) kind0 name0, \ - kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5, \ - kind6 name6, kind7 name7, kind8 name8, kind9 name9 - -// Lists the template parameters. -#define GMOCK_INTERNAL_LIST_HAS_1_TEMPLATE_PARAMS(kind0, name0) name0 -#define GMOCK_INTERNAL_LIST_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \ - name1) name0, name1 -#define GMOCK_INTERNAL_LIST_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2) name0, name1, name2 -#define GMOCK_INTERNAL_LIST_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3) name0, name1, name2, name3 -#define GMOCK_INTERNAL_LIST_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4) name0, name1, name2, name3, \ - name4 -#define GMOCK_INTERNAL_LIST_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5) name0, name1, \ - name2, name3, name4, name5 -#define GMOCK_INTERNAL_LIST_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \ - name6) name0, name1, name2, name3, name4, name5, name6 -#define GMOCK_INTERNAL_LIST_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \ - kind7, name7) name0, name1, name2, name3, name4, name5, name6, name7 -#define GMOCK_INTERNAL_LIST_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \ - kind7, name7, kind8, name8) name0, name1, name2, name3, name4, name5, \ - name6, name7, name8 -#define GMOCK_INTERNAL_LIST_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \ - name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \ - name6, kind7, name7, kind8, name8, kind9, name9) name0, name1, name2, \ - name3, name4, name5, name6, name7, name8, name9 - -// Declares the types of value parameters. -#define GMOCK_INTERNAL_DECL_TYPE_AND_0_VALUE_PARAMS() -#define GMOCK_INTERNAL_DECL_TYPE_AND_1_VALUE_PARAMS(p0) , typename p0##_type -#define GMOCK_INTERNAL_DECL_TYPE_AND_2_VALUE_PARAMS(p0, p1) , \ - typename p0##_type, typename p1##_type -#define GMOCK_INTERNAL_DECL_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , \ - typename p0##_type, typename p1##_type, typename p2##_type -#define GMOCK_INTERNAL_DECL_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \ - typename p0##_type, typename p1##_type, typename p2##_type, \ - typename p3##_type -#define GMOCK_INTERNAL_DECL_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \ - typename p0##_type, typename p1##_type, typename p2##_type, \ - typename p3##_type, typename p4##_type -#define GMOCK_INTERNAL_DECL_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \ - typename p0##_type, typename p1##_type, typename p2##_type, \ - typename p3##_type, typename p4##_type, typename p5##_type -#define GMOCK_INTERNAL_DECL_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6) , typename p0##_type, typename p1##_type, typename p2##_type, \ - typename p3##_type, typename p4##_type, typename p5##_type, \ - typename p6##_type -#define GMOCK_INTERNAL_DECL_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6, p7) , typename p0##_type, typename p1##_type, typename p2##_type, \ - typename p3##_type, typename p4##_type, typename p5##_type, \ - typename p6##_type, typename p7##_type -#define GMOCK_INTERNAL_DECL_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6, p7, p8) , typename p0##_type, typename p1##_type, typename p2##_type, \ - typename p3##_type, typename p4##_type, typename p5##_type, \ - typename p6##_type, typename p7##_type, typename p8##_type -#define GMOCK_INTERNAL_DECL_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6, p7, p8, p9) , typename p0##_type, typename p1##_type, \ - typename p2##_type, typename p3##_type, typename p4##_type, \ - typename p5##_type, typename p6##_type, typename p7##_type, \ - typename p8##_type, typename p9##_type - -// Initializes the value parameters. -#define GMOCK_INTERNAL_INIT_AND_0_VALUE_PARAMS()\ - () -#define GMOCK_INTERNAL_INIT_AND_1_VALUE_PARAMS(p0)\ - (p0##_type gmock_p0) : p0(::testing::internal::move(gmock_p0)) -#define GMOCK_INTERNAL_INIT_AND_2_VALUE_PARAMS(p0, p1)\ - (p0##_type gmock_p0, \ - p1##_type gmock_p1) : p0(::testing::internal::move(gmock_p0)), \ - p1(::testing::internal::move(gmock_p1)) -#define GMOCK_INTERNAL_INIT_AND_3_VALUE_PARAMS(p0, p1, p2)\ - (p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2) : p0(::testing::internal::move(gmock_p0)), \ - p1(::testing::internal::move(gmock_p1)), \ - p2(::testing::internal::move(gmock_p2)) -#define GMOCK_INTERNAL_INIT_AND_4_VALUE_PARAMS(p0, p1, p2, p3)\ - (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3) : p0(::testing::internal::move(gmock_p0)), \ - p1(::testing::internal::move(gmock_p1)), \ - p2(::testing::internal::move(gmock_p2)), \ - p3(::testing::internal::move(gmock_p3)) -#define GMOCK_INTERNAL_INIT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)\ - (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, \ - p4##_type gmock_p4) : p0(::testing::internal::move(gmock_p0)), \ - p1(::testing::internal::move(gmock_p1)), \ - p2(::testing::internal::move(gmock_p2)), \ - p3(::testing::internal::move(gmock_p3)), \ - p4(::testing::internal::move(gmock_p4)) -#define GMOCK_INTERNAL_INIT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)\ - (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, \ - p5##_type gmock_p5) : p0(::testing::internal::move(gmock_p0)), \ - p1(::testing::internal::move(gmock_p1)), \ - p2(::testing::internal::move(gmock_p2)), \ - p3(::testing::internal::move(gmock_p3)), \ - p4(::testing::internal::move(gmock_p4)), \ - p5(::testing::internal::move(gmock_p5)) -#define GMOCK_INTERNAL_INIT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)\ - (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6) : p0(::testing::internal::move(gmock_p0)), \ - p1(::testing::internal::move(gmock_p1)), \ - p2(::testing::internal::move(gmock_p2)), \ - p3(::testing::internal::move(gmock_p3)), \ - p4(::testing::internal::move(gmock_p4)), \ - p5(::testing::internal::move(gmock_p5)), \ - p6(::testing::internal::move(gmock_p6)) -#define GMOCK_INTERNAL_INIT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)\ - (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6, \ - p7##_type gmock_p7) : p0(::testing::internal::move(gmock_p0)), \ - p1(::testing::internal::move(gmock_p1)), \ - p2(::testing::internal::move(gmock_p2)), \ - p3(::testing::internal::move(gmock_p3)), \ - p4(::testing::internal::move(gmock_p4)), \ - p5(::testing::internal::move(gmock_p5)), \ - p6(::testing::internal::move(gmock_p6)), \ - p7(::testing::internal::move(gmock_p7)) -#define GMOCK_INTERNAL_INIT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8)\ - (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6, p7##_type gmock_p7, \ - p8##_type gmock_p8) : p0(::testing::internal::move(gmock_p0)), \ - p1(::testing::internal::move(gmock_p1)), \ - p2(::testing::internal::move(gmock_p2)), \ - p3(::testing::internal::move(gmock_p3)), \ - p4(::testing::internal::move(gmock_p4)), \ - p5(::testing::internal::move(gmock_p5)), \ - p6(::testing::internal::move(gmock_p6)), \ - p7(::testing::internal::move(gmock_p7)), \ - p8(::testing::internal::move(gmock_p8)) -#define GMOCK_INTERNAL_INIT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8, p9)\ - (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \ - p9##_type gmock_p9) : p0(::testing::internal::move(gmock_p0)), \ - p1(::testing::internal::move(gmock_p1)), \ - p2(::testing::internal::move(gmock_p2)), \ - p3(::testing::internal::move(gmock_p3)), \ - p4(::testing::internal::move(gmock_p4)), \ - p5(::testing::internal::move(gmock_p5)), \ - p6(::testing::internal::move(gmock_p6)), \ - p7(::testing::internal::move(gmock_p7)), \ - p8(::testing::internal::move(gmock_p8)), \ - p9(::testing::internal::move(gmock_p9)) - -// Declares the fields for storing the value parameters. -#define GMOCK_INTERNAL_DEFN_AND_0_VALUE_PARAMS() -#define GMOCK_INTERNAL_DEFN_AND_1_VALUE_PARAMS(p0) p0##_type p0; -#define GMOCK_INTERNAL_DEFN_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0; \ - p1##_type p1; -#define GMOCK_INTERNAL_DEFN_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0; \ - p1##_type p1; p2##_type p2; -#define GMOCK_INTERNAL_DEFN_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0; \ - p1##_type p1; p2##_type p2; p3##_type p3; -#define GMOCK_INTERNAL_DEFN_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \ - p4) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; -#define GMOCK_INTERNAL_DEFN_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \ - p5) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \ - p5##_type p5; -#define GMOCK_INTERNAL_DEFN_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \ - p5##_type p5; p6##_type p6; -#define GMOCK_INTERNAL_DEFN_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \ - p5##_type p5; p6##_type p6; p7##_type p7; -#define GMOCK_INTERNAL_DEFN_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \ - p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8; -#define GMOCK_INTERNAL_DEFN_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8, p9) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \ - p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8; \ - p9##_type p9; - -// Lists the value parameters. -#define GMOCK_INTERNAL_LIST_AND_0_VALUE_PARAMS() -#define GMOCK_INTERNAL_LIST_AND_1_VALUE_PARAMS(p0) p0 -#define GMOCK_INTERNAL_LIST_AND_2_VALUE_PARAMS(p0, p1) p0, p1 -#define GMOCK_INTERNAL_LIST_AND_3_VALUE_PARAMS(p0, p1, p2) p0, p1, p2 -#define GMOCK_INTERNAL_LIST_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0, p1, p2, p3 -#define GMOCK_INTERNAL_LIST_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) p0, p1, \ - p2, p3, p4 -#define GMOCK_INTERNAL_LIST_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) p0, \ - p1, p2, p3, p4, p5 -#define GMOCK_INTERNAL_LIST_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6) p0, p1, p2, p3, p4, p5, p6 -#define GMOCK_INTERNAL_LIST_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7) p0, p1, p2, p3, p4, p5, p6, p7 -#define GMOCK_INTERNAL_LIST_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8) p0, p1, p2, p3, p4, p5, p6, p7, p8 -#define GMOCK_INTERNAL_LIST_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8, p9) p0, p1, p2, p3, p4, p5, p6, p7, p8, p9 - -// Lists the value parameter types. -#define GMOCK_INTERNAL_LIST_TYPE_AND_0_VALUE_PARAMS() -#define GMOCK_INTERNAL_LIST_TYPE_AND_1_VALUE_PARAMS(p0) , p0##_type -#define GMOCK_INTERNAL_LIST_TYPE_AND_2_VALUE_PARAMS(p0, p1) , p0##_type, \ - p1##_type -#define GMOCK_INTERNAL_LIST_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , p0##_type, \ - p1##_type, p2##_type -#define GMOCK_INTERNAL_LIST_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \ - p0##_type, p1##_type, p2##_type, p3##_type -#define GMOCK_INTERNAL_LIST_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \ - p0##_type, p1##_type, p2##_type, p3##_type, p4##_type -#define GMOCK_INTERNAL_LIST_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \ - p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type -#define GMOCK_INTERNAL_LIST_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \ - p6##_type -#define GMOCK_INTERNAL_LIST_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6, p7) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ - p5##_type, p6##_type, p7##_type -#define GMOCK_INTERNAL_LIST_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6, p7, p8) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ - p5##_type, p6##_type, p7##_type, p8##_type -#define GMOCK_INTERNAL_LIST_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6, p7, p8, p9) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ - p5##_type, p6##_type, p7##_type, p8##_type, p9##_type - -// Declares the value parameters. -#define GMOCK_INTERNAL_DECL_AND_0_VALUE_PARAMS() -#define GMOCK_INTERNAL_DECL_AND_1_VALUE_PARAMS(p0) p0##_type p0 -#define GMOCK_INTERNAL_DECL_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0, \ - p1##_type p1 -#define GMOCK_INTERNAL_DECL_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0, \ - p1##_type p1, p2##_type p2 -#define GMOCK_INTERNAL_DECL_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0, \ - p1##_type p1, p2##_type p2, p3##_type p3 -#define GMOCK_INTERNAL_DECL_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \ - p4) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4 -#define GMOCK_INTERNAL_DECL_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \ - p5) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \ - p5##_type p5 -#define GMOCK_INTERNAL_DECL_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \ - p5##_type p5, p6##_type p6 -#define GMOCK_INTERNAL_DECL_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \ - p5##_type p5, p6##_type p6, p7##_type p7 -#define GMOCK_INTERNAL_DECL_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ - p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8 -#define GMOCK_INTERNAL_DECL_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8, p9) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ - p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \ - p9##_type p9 - -// The suffix of the class template implementing the action template. -#define GMOCK_INTERNAL_COUNT_AND_0_VALUE_PARAMS() -#define GMOCK_INTERNAL_COUNT_AND_1_VALUE_PARAMS(p0) P -#define GMOCK_INTERNAL_COUNT_AND_2_VALUE_PARAMS(p0, p1) P2 -#define GMOCK_INTERNAL_COUNT_AND_3_VALUE_PARAMS(p0, p1, p2) P3 -#define GMOCK_INTERNAL_COUNT_AND_4_VALUE_PARAMS(p0, p1, p2, p3) P4 -#define GMOCK_INTERNAL_COUNT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) P5 -#define GMOCK_INTERNAL_COUNT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) P6 -#define GMOCK_INTERNAL_COUNT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) P7 -#define GMOCK_INTERNAL_COUNT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7) P8 -#define GMOCK_INTERNAL_COUNT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8) P9 -#define GMOCK_INTERNAL_COUNT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8, p9) P10 - -// The name of the class template implementing the action template. -#define GMOCK_ACTION_CLASS_(name, value_params)\ - GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params) - -#define ACTION_TEMPLATE(name, template_params, value_params)\ - template \ - class GMOCK_ACTION_CLASS_(name, value_params) {\ - public:\ - explicit GMOCK_ACTION_CLASS_(name, value_params)\ - GMOCK_INTERNAL_INIT_##value_params {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - explicit gmock_Impl GMOCK_INTERNAL_INIT_##value_params {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ - arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ - arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ - arg9_type arg9) const;\ - GMOCK_INTERNAL_DEFN_##value_params\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(\ - new gmock_Impl(GMOCK_INTERNAL_LIST_##value_params));\ - }\ - GMOCK_INTERNAL_DEFN_##value_params\ - private:\ - GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\ - };\ - template \ - inline GMOCK_ACTION_CLASS_(name, value_params)<\ - GMOCK_INTERNAL_LIST_##template_params\ - GMOCK_INTERNAL_LIST_TYPE_##value_params> name(\ - GMOCK_INTERNAL_DECL_##value_params) {\ - return GMOCK_ACTION_CLASS_(name, value_params)<\ - GMOCK_INTERNAL_LIST_##template_params\ - GMOCK_INTERNAL_LIST_TYPE_##value_params>(\ - GMOCK_INTERNAL_LIST_##value_params);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - GMOCK_ACTION_CLASS_(name, value_params)<\ - GMOCK_INTERNAL_LIST_##template_params\ - GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl::\ - gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -#define ACTION(name)\ - class name##Action {\ - public:\ - name##Action() {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - gmock_Impl() {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ - arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ - arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ - arg9_type arg9) const;\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(new gmock_Impl());\ - }\ - private:\ - GTEST_DISALLOW_ASSIGN_(name##Action);\ - };\ - inline name##Action name() {\ - return name##Action();\ - }\ - template \ - template \ - typename ::testing::internal::Function::Result\ - name##Action::gmock_Impl::gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -#define ACTION_P(name, p0)\ - template \ - class name##ActionP {\ - public:\ - explicit name##ActionP(p0##_type gmock_p0) : \ - p0(::testing::internal::forward(gmock_p0)) {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - explicit gmock_Impl(p0##_type gmock_p0) : \ - p0(::testing::internal::forward(gmock_p0)) {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ - arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ - arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ - arg9_type arg9) const;\ - p0##_type p0;\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(new gmock_Impl(p0));\ - }\ - p0##_type p0;\ - private:\ - GTEST_DISALLOW_ASSIGN_(name##ActionP);\ - };\ - template \ - inline name##ActionP name(p0##_type p0) {\ - return name##ActionP(p0);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - name##ActionP::gmock_Impl::gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -#define ACTION_P2(name, p0, p1)\ - template \ - class name##ActionP2 {\ - public:\ - name##ActionP2(p0##_type gmock_p0, \ - p1##_type gmock_p1) : p0(::testing::internal::forward(gmock_p0)), \ - p1(::testing::internal::forward(gmock_p1)) {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - gmock_Impl(p0##_type gmock_p0, \ - p1##_type gmock_p1) : p0(::testing::internal::forward(gmock_p0)), \ - p1(::testing::internal::forward(gmock_p1)) {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ - arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ - arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ - arg9_type arg9) const;\ - p0##_type p0;\ - p1##_type p1;\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(new gmock_Impl(p0, p1));\ - }\ - p0##_type p0;\ - p1##_type p1;\ - private:\ - GTEST_DISALLOW_ASSIGN_(name##ActionP2);\ - };\ - template \ - inline name##ActionP2 name(p0##_type p0, \ - p1##_type p1) {\ - return name##ActionP2(p0, p1);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - name##ActionP2::gmock_Impl::gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -#define ACTION_P3(name, p0, p1, p2)\ - template \ - class name##ActionP3 {\ - public:\ - name##ActionP3(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2) : p0(::testing::internal::forward(gmock_p0)), \ - p1(::testing::internal::forward(gmock_p1)), \ - p2(::testing::internal::forward(gmock_p2)) {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2) : p0(::testing::internal::forward(gmock_p0)), \ - p1(::testing::internal::forward(gmock_p1)), \ - p2(::testing::internal::forward(gmock_p2)) {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ - arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ - arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ - arg9_type arg9) const;\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(new gmock_Impl(p0, p1, p2));\ - }\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - private:\ - GTEST_DISALLOW_ASSIGN_(name##ActionP3);\ - };\ - template \ - inline name##ActionP3 name(p0##_type p0, \ - p1##_type p1, p2##_type p2) {\ - return name##ActionP3(p0, p1, p2);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - name##ActionP3::gmock_Impl::gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -#define ACTION_P4(name, p0, p1, p2, p3)\ - template \ - class name##ActionP4 {\ - public:\ - name##ActionP4(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2, \ - p3##_type gmock_p3) : p0(::testing::internal::forward(gmock_p0)), \ - p1(::testing::internal::forward(gmock_p1)), \ - p2(::testing::internal::forward(gmock_p2)), \ - p3(::testing::internal::forward(gmock_p3)) {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3) : p0(::testing::internal::forward(gmock_p0)), \ - p1(::testing::internal::forward(gmock_p1)), \ - p2(::testing::internal::forward(gmock_p2)), \ - p3(::testing::internal::forward(gmock_p3)) {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ - arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ - arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ - arg9_type arg9) const;\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(new gmock_Impl(p0, p1, p2, p3));\ - }\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - private:\ - GTEST_DISALLOW_ASSIGN_(name##ActionP4);\ - };\ - template \ - inline name##ActionP4 name(p0##_type p0, p1##_type p1, p2##_type p2, \ - p3##_type p3) {\ - return name##ActionP4(p0, p1, \ - p2, p3);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - name##ActionP4::gmock_Impl::gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -#define ACTION_P5(name, p0, p1, p2, p3, p4)\ - template \ - class name##ActionP5 {\ - public:\ - name##ActionP5(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2, p3##_type gmock_p3, \ - p4##_type gmock_p4) : p0(::testing::internal::forward(gmock_p0)), \ - p1(::testing::internal::forward(gmock_p1)), \ - p2(::testing::internal::forward(gmock_p2)), \ - p3(::testing::internal::forward(gmock_p3)), \ - p4(::testing::internal::forward(gmock_p4)) {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, \ - p4##_type gmock_p4) : p0(::testing::internal::forward(gmock_p0)), \ - p1(::testing::internal::forward(gmock_p1)), \ - p2(::testing::internal::forward(gmock_p2)), \ - p3(::testing::internal::forward(gmock_p3)), \ - p4(::testing::internal::forward(gmock_p4)) {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ - arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ - arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ - arg9_type arg9) const;\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(new gmock_Impl(p0, p1, p2, p3, p4));\ - }\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - private:\ - GTEST_DISALLOW_ASSIGN_(name##ActionP5);\ - };\ - template \ - inline name##ActionP5 name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ - p4##_type p4) {\ - return name##ActionP5(p0, p1, p2, p3, p4);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - name##ActionP5::gmock_Impl::gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -#define ACTION_P6(name, p0, p1, p2, p3, p4, p5)\ - template \ - class name##ActionP6 {\ - public:\ - name##ActionP6(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ - p5##_type gmock_p5) : p0(::testing::internal::forward(gmock_p0)), \ - p1(::testing::internal::forward(gmock_p1)), \ - p2(::testing::internal::forward(gmock_p2)), \ - p3(::testing::internal::forward(gmock_p3)), \ - p4(::testing::internal::forward(gmock_p4)), \ - p5(::testing::internal::forward(gmock_p5)) {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, \ - p5##_type gmock_p5) : p0(::testing::internal::forward(gmock_p0)), \ - p1(::testing::internal::forward(gmock_p1)), \ - p2(::testing::internal::forward(gmock_p2)), \ - p3(::testing::internal::forward(gmock_p3)), \ - p4(::testing::internal::forward(gmock_p4)), \ - p5(::testing::internal::forward(gmock_p5)) {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ - arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ - arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ - arg9_type arg9) const;\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - p5##_type p5;\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(new gmock_Impl(p0, p1, p2, p3, p4, p5));\ - }\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - p5##_type p5;\ - private:\ - GTEST_DISALLOW_ASSIGN_(name##ActionP6);\ - };\ - template \ - inline name##ActionP6 name(p0##_type p0, p1##_type p1, p2##_type p2, \ - p3##_type p3, p4##_type p4, p5##_type p5) {\ - return name##ActionP6(p0, p1, p2, p3, p4, p5);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - name##ActionP6::gmock_Impl::gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -#define ACTION_P7(name, p0, p1, p2, p3, p4, p5, p6)\ - template \ - class name##ActionP7 {\ - public:\ - name##ActionP7(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ - p5##_type gmock_p5, \ - p6##_type gmock_p6) : p0(::testing::internal::forward(gmock_p0)), \ - p1(::testing::internal::forward(gmock_p1)), \ - p2(::testing::internal::forward(gmock_p2)), \ - p3(::testing::internal::forward(gmock_p3)), \ - p4(::testing::internal::forward(gmock_p4)), \ - p5(::testing::internal::forward(gmock_p5)), \ - p6(::testing::internal::forward(gmock_p6)) {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6) : p0(::testing::internal::forward(gmock_p0)), \ - p1(::testing::internal::forward(gmock_p1)), \ - p2(::testing::internal::forward(gmock_p2)), \ - p3(::testing::internal::forward(gmock_p3)), \ - p4(::testing::internal::forward(gmock_p4)), \ - p5(::testing::internal::forward(gmock_p5)), \ - p6(::testing::internal::forward(gmock_p6)) {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ - arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ - arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ - arg9_type arg9) const;\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - p5##_type p5;\ - p6##_type p6;\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(new gmock_Impl(p0, p1, p2, p3, p4, p5, \ - p6));\ - }\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - p5##_type p5;\ - p6##_type p6;\ - private:\ - GTEST_DISALLOW_ASSIGN_(name##ActionP7);\ - };\ - template \ - inline name##ActionP7 name(p0##_type p0, p1##_type p1, \ - p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \ - p6##_type p6) {\ - return name##ActionP7(p0, p1, p2, p3, p4, p5, p6);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - name##ActionP7::gmock_Impl::gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -#define ACTION_P8(name, p0, p1, p2, p3, p4, p5, p6, p7)\ - template \ - class name##ActionP8 {\ - public:\ - name##ActionP8(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ - p5##_type gmock_p5, p6##_type gmock_p6, \ - p7##_type gmock_p7) : p0(::testing::internal::forward(gmock_p0)), \ - p1(::testing::internal::forward(gmock_p1)), \ - p2(::testing::internal::forward(gmock_p2)), \ - p3(::testing::internal::forward(gmock_p3)), \ - p4(::testing::internal::forward(gmock_p4)), \ - p5(::testing::internal::forward(gmock_p5)), \ - p6(::testing::internal::forward(gmock_p6)), \ - p7(::testing::internal::forward(gmock_p7)) {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6, \ - p7##_type gmock_p7) : p0(::testing::internal::forward(gmock_p0)), \ - p1(::testing::internal::forward(gmock_p1)), \ - p2(::testing::internal::forward(gmock_p2)), \ - p3(::testing::internal::forward(gmock_p3)), \ - p4(::testing::internal::forward(gmock_p4)), \ - p5(::testing::internal::forward(gmock_p5)), \ - p6(::testing::internal::forward(gmock_p6)), \ - p7(::testing::internal::forward(gmock_p7)) {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ - arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ - arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ - arg9_type arg9) const;\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - p5##_type p5;\ - p6##_type p6;\ - p7##_type p7;\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(new gmock_Impl(p0, p1, p2, p3, p4, p5, \ - p6, p7));\ - }\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - p5##_type p5;\ - p6##_type p6;\ - p7##_type p7;\ - private:\ - GTEST_DISALLOW_ASSIGN_(name##ActionP8);\ - };\ - template \ - inline name##ActionP8 name(p0##_type p0, \ - p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \ - p6##_type p6, p7##_type p7) {\ - return name##ActionP8(p0, p1, p2, p3, p4, p5, \ - p6, p7);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - name##ActionP8::gmock_Impl::gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -#define ACTION_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8)\ - template \ - class name##ActionP9 {\ - public:\ - name##ActionP9(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ - p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \ - p8##_type gmock_p8) : p0(::testing::internal::forward(gmock_p0)), \ - p1(::testing::internal::forward(gmock_p1)), \ - p2(::testing::internal::forward(gmock_p2)), \ - p3(::testing::internal::forward(gmock_p3)), \ - p4(::testing::internal::forward(gmock_p4)), \ - p5(::testing::internal::forward(gmock_p5)), \ - p6(::testing::internal::forward(gmock_p6)), \ - p7(::testing::internal::forward(gmock_p7)), \ - p8(::testing::internal::forward(gmock_p8)) {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6, p7##_type gmock_p7, \ - p8##_type gmock_p8) : p0(::testing::internal::forward(gmock_p0)), \ - p1(::testing::internal::forward(gmock_p1)), \ - p2(::testing::internal::forward(gmock_p2)), \ - p3(::testing::internal::forward(gmock_p3)), \ - p4(::testing::internal::forward(gmock_p4)), \ - p5(::testing::internal::forward(gmock_p5)), \ - p6(::testing::internal::forward(gmock_p6)), \ - p7(::testing::internal::forward(gmock_p7)), \ - p8(::testing::internal::forward(gmock_p8)) {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ - arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ - arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ - arg9_type arg9) const;\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - p5##_type p5;\ - p6##_type p6;\ - p7##_type p7;\ - p8##_type p8;\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(new gmock_Impl(p0, p1, p2, p3, p4, p5, \ - p6, p7, p8));\ - }\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - p5##_type p5;\ - p6##_type p6;\ - p7##_type p7;\ - p8##_type p8;\ - private:\ - GTEST_DISALLOW_ASSIGN_(name##ActionP9);\ - };\ - template \ - inline name##ActionP9 name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ - p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \ - p8##_type p8) {\ - return name##ActionP9(p0, p1, p2, \ - p3, p4, p5, p6, p7, p8);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - name##ActionP9::gmock_Impl::gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -#define ACTION_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)\ - template \ - class name##ActionP10 {\ - public:\ - name##ActionP10(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ - p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \ - p8##_type gmock_p8, \ - p9##_type gmock_p9) : p0(::testing::internal::forward(gmock_p0)), \ - p1(::testing::internal::forward(gmock_p1)), \ - p2(::testing::internal::forward(gmock_p2)), \ - p3(::testing::internal::forward(gmock_p3)), \ - p4(::testing::internal::forward(gmock_p4)), \ - p5(::testing::internal::forward(gmock_p5)), \ - p6(::testing::internal::forward(gmock_p6)), \ - p7(::testing::internal::forward(gmock_p7)), \ - p8(::testing::internal::forward(gmock_p8)), \ - p9(::testing::internal::forward(gmock_p9)) {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \ - p9##_type gmock_p9) : p0(::testing::internal::forward(gmock_p0)), \ - p1(::testing::internal::forward(gmock_p1)), \ - p2(::testing::internal::forward(gmock_p2)), \ - p3(::testing::internal::forward(gmock_p3)), \ - p4(::testing::internal::forward(gmock_p4)), \ - p5(::testing::internal::forward(gmock_p5)), \ - p6(::testing::internal::forward(gmock_p6)), \ - p7(::testing::internal::forward(gmock_p7)), \ - p8(::testing::internal::forward(gmock_p8)), \ - p9(::testing::internal::forward(gmock_p9)) {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ - arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ - arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ - arg9_type arg9) const;\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - p5##_type p5;\ - p6##_type p6;\ - p7##_type p7;\ - p8##_type p8;\ - p9##_type p9;\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(new gmock_Impl(p0, p1, p2, p3, p4, p5, \ - p6, p7, p8, p9));\ - }\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - p5##_type p5;\ - p6##_type p6;\ - p7##_type p7;\ - p8##_type p8;\ - p9##_type p9;\ - private:\ - GTEST_DISALLOW_ASSIGN_(name##ActionP10);\ - };\ - template \ - inline name##ActionP10 name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ - p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \ - p9##_type p9) {\ - return name##ActionP10(p0, \ - p1, p2, p3, p4, p5, p6, p7, p8, p9);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - name##ActionP10::gmock_Impl::gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -namespace testing { - - -// The ACTION*() macros trigger warning C4100 (unreferenced formal -// parameter) in MSVC with -W4. Unfortunately they cannot be fixed in -// the macro definition, as the warnings are generated when the macro -// is expanded and macro expansion cannot contain #pragma. Therefore -// we suppress them here. -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable:4100) -#endif - -// Various overloads for InvokeArgument(). -// -// The InvokeArgument(a1, a2, ..., a_k) action invokes the N-th -// (0-based) argument, which must be a k-ary callable, of the mock -// function, with arguments a1, a2, ..., a_k. -// -// Notes: -// -// 1. The arguments are passed by value by default. If you need to -// pass an argument by reference, wrap it inside ByRef(). For -// example, -// -// InvokeArgument<1>(5, string("Hello"), ByRef(foo)) -// -// passes 5 and string("Hello") by value, and passes foo by -// reference. -// -// 2. If the callable takes an argument by reference but ByRef() is -// not used, it will receive the reference to a copy of the value, -// instead of the original value. For example, when the 0-th -// argument of the mock function takes a const string&, the action -// -// InvokeArgument<0>(string("Hello")) -// -// makes a copy of the temporary string("Hello") object and passes a -// reference of the copy, instead of the original temporary object, -// to the callable. This makes it easy for a user to define an -// InvokeArgument action from temporary values and have it performed -// later. - -namespace internal { -namespace invoke_argument { - -// Appears in InvokeArgumentAdl's argument list to help avoid -// accidental calls to user functions of the same name. -struct AdlTag {}; - -// InvokeArgumentAdl - a helper for InvokeArgument. -// The basic overloads are provided here for generic functors. -// Overloads for other custom-callables are provided in the -// internal/custom/callback-actions.h header. - -template -R InvokeArgumentAdl(AdlTag, F f) { - return f(); -} -template -R InvokeArgumentAdl(AdlTag, F f, A1 a1) { - return f(a1); -} -template -R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2) { - return f(a1, a2); -} -template -R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3) { - return f(a1, a2, a3); -} -template -R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4) { - return f(a1, a2, a3, a4); -} -template -R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) { - return f(a1, a2, a3, a4, a5); -} -template -R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) { - return f(a1, a2, a3, a4, a5, a6); -} -template -R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, - A7 a7) { - return f(a1, a2, a3, a4, a5, a6, a7); -} -template -R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, - A7 a7, A8 a8) { - return f(a1, a2, a3, a4, a5, a6, a7, a8); -} -template -R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, - A7 a7, A8 a8, A9 a9) { - return f(a1, a2, a3, a4, a5, a6, a7, a8, a9); -} -template -R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, - A7 a7, A8 a8, A9 a9, A10 a10) { - return f(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); -} -} // namespace invoke_argument -} // namespace internal - -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), - AND_0_VALUE_PARAMS()) { - using internal::invoke_argument::InvokeArgumentAdl; - return InvokeArgumentAdl( - internal::invoke_argument::AdlTag(), - ::testing::get(args)); -} - -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), - AND_1_VALUE_PARAMS(p0)) { - using internal::invoke_argument::InvokeArgumentAdl; - return InvokeArgumentAdl( - internal::invoke_argument::AdlTag(), - ::testing::get(args), p0); -} - -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), - AND_2_VALUE_PARAMS(p0, p1)) { - using internal::invoke_argument::InvokeArgumentAdl; - return InvokeArgumentAdl( - internal::invoke_argument::AdlTag(), - ::testing::get(args), p0, p1); -} - -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), - AND_3_VALUE_PARAMS(p0, p1, p2)) { - using internal::invoke_argument::InvokeArgumentAdl; - return InvokeArgumentAdl( - internal::invoke_argument::AdlTag(), - ::testing::get(args), p0, p1, p2); -} - -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), - AND_4_VALUE_PARAMS(p0, p1, p2, p3)) { - using internal::invoke_argument::InvokeArgumentAdl; - return InvokeArgumentAdl( - internal::invoke_argument::AdlTag(), - ::testing::get(args), p0, p1, p2, p3); -} - -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), - AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) { - using internal::invoke_argument::InvokeArgumentAdl; - return InvokeArgumentAdl( - internal::invoke_argument::AdlTag(), - ::testing::get(args), p0, p1, p2, p3, p4); -} - -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), - AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) { - using internal::invoke_argument::InvokeArgumentAdl; - return InvokeArgumentAdl( - internal::invoke_argument::AdlTag(), - ::testing::get(args), p0, p1, p2, p3, p4, p5); -} - -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), - AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) { - using internal::invoke_argument::InvokeArgumentAdl; - return InvokeArgumentAdl( - internal::invoke_argument::AdlTag(), - ::testing::get(args), p0, p1, p2, p3, p4, p5, p6); -} - -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), - AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) { - using internal::invoke_argument::InvokeArgumentAdl; - return InvokeArgumentAdl( - internal::invoke_argument::AdlTag(), - ::testing::get(args), p0, p1, p2, p3, p4, p5, p6, p7); -} - -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), - AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) { - using internal::invoke_argument::InvokeArgumentAdl; - return InvokeArgumentAdl( - internal::invoke_argument::AdlTag(), - ::testing::get(args), p0, p1, p2, p3, p4, p5, p6, p7, p8); -} - -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), - AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) { - using internal::invoke_argument::InvokeArgumentAdl; - return InvokeArgumentAdl( - internal::invoke_argument::AdlTag(), - ::testing::get(args), p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); -} - -// Various overloads for ReturnNew(). -// -// The ReturnNew(a1, a2, ..., a_k) action returns a pointer to a new -// instance of type T, constructed on the heap with constructor arguments -// a1, a2, ..., and a_k. The caller assumes ownership of the returned value. -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_0_VALUE_PARAMS()) { - return new T(); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_1_VALUE_PARAMS(p0)) { - return new T(p0); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_2_VALUE_PARAMS(p0, p1)) { - return new T(p0, p1); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_3_VALUE_PARAMS(p0, p1, p2)) { - return new T(p0, p1, p2); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_4_VALUE_PARAMS(p0, p1, p2, p3)) { - return new T(p0, p1, p2, p3); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) { - return new T(p0, p1, p2, p3, p4); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) { - return new T(p0, p1, p2, p3, p4, p5); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) { - return new T(p0, p1, p2, p3, p4, p5, p6); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) { - return new T(p0, p1, p2, p3, p4, p5, p6, p7); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) { - return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) { - return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); -} - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - -} // namespace testing - -// Include any custom callback actions added by the local installation. -// We must include this header at the end to make sure it can use the -// declarations from this file. -// This file was GENERATED by command: -// pump.py gmock-generated-actions.h.pump -// DO NOT EDIT BY HAND!!! - -#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ -#define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ - -#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ - -#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ -// This file was GENERATED by command: -// pump.py gmock-generated-function-mockers.h.pump -// DO NOT EDIT BY HAND!!! - -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) - -// Google Mock - a framework for writing C++ mock classes. -// -// This file implements function mockers of various arities. - -#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_ -#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_ - -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) - -// Google Mock - a framework for writing C++ mock classes. -// -// This file implements the ON_CALL() and EXPECT_CALL() macros. -// -// A user can use the ON_CALL() macro to specify the default action of -// a mock method. The syntax is: -// -// ON_CALL(mock_object, Method(argument-matchers)) -// .With(multi-argument-matcher) -// .WillByDefault(action); -// -// where the .With() clause is optional. -// -// A user can use the EXPECT_CALL() macro to specify an expectation on -// a mock method. The syntax is: -// -// EXPECT_CALL(mock_object, Method(argument-matchers)) -// .With(multi-argument-matchers) -// .Times(cardinality) -// .InSequence(sequences) -// .After(expectations) -// .WillOnce(action) -// .WillRepeatedly(action) -// .RetiresOnSaturation(); -// -// where all clauses are optional, and .InSequence()/.After()/ -// .WillOnce() can appear any number of times. - -#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_ -#define GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_ - -#include -#include -#include -#include -#include -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) - -// Google Mock - a framework for writing C++ mock classes. -// -// This file implements some commonly used argument matchers. More -// matchers can be defined by the user implementing the -// MatcherInterface interface if necessary. - -#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_ -#define GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_ - -#include -#include -#include -#include -#include // NOLINT -#include -#include -#include -#include - -#if GTEST_HAS_STD_INITIALIZER_LIST_ -# include // NOLINT -- must be after gtest.h -#endif - -namespace testing { - -// To implement a matcher Foo for type T, define: -// 1. a class FooMatcherImpl that implements the -// MatcherInterface interface, and -// 2. a factory function that creates a Matcher object from a -// FooMatcherImpl*. -// -// The two-level delegation design makes it possible to allow a user -// to write "v" instead of "Eq(v)" where a Matcher is expected, which -// is impossible if we pass matchers by pointers. It also eases -// ownership management as Matcher objects can now be copied like -// plain values. - -// MatchResultListener is an abstract class. Its << operator can be -// used by a matcher to explain why a value matches or doesn't match. -// -// TODO(wan@google.com): add method -// bool InterestedInWhy(bool result) const; -// to indicate whether the listener is interested in why the match -// result is 'result'. -class MatchResultListener { - public: - // Creates a listener object with the given underlying ostream. The - // listener does not own the ostream, and does not dereference it - // in the constructor or destructor. - explicit MatchResultListener(::std::ostream* os) : stream_(os) {} - virtual ~MatchResultListener() = 0; // Makes this class abstract. - - // Streams x to the underlying ostream; does nothing if the ostream - // is NULL. - template - MatchResultListener& operator<<(const T& x) { - if (stream_ != NULL) - *stream_ << x; - return *this; - } - - // Returns the underlying ostream. - ::std::ostream* stream() { return stream_; } - - // Returns true iff the listener is interested in an explanation of - // the match result. A matcher's MatchAndExplain() method can use - // this information to avoid generating the explanation when no one - // intends to hear it. - bool IsInterested() const { return stream_ != NULL; } - - private: - ::std::ostream* const stream_; - - GTEST_DISALLOW_COPY_AND_ASSIGN_(MatchResultListener); -}; - -inline MatchResultListener::~MatchResultListener() { -} - -// An instance of a subclass of this knows how to describe itself as a -// matcher. -class MatcherDescriberInterface { - public: - virtual ~MatcherDescriberInterface() {} - - // Describes this matcher to an ostream. The function should print - // a verb phrase that describes the property a value matching this - // matcher should have. The subject of the verb phrase is the value - // being matched. For example, the DescribeTo() method of the Gt(7) - // matcher prints "is greater than 7". - virtual void DescribeTo(::std::ostream* os) const = 0; - - // Describes the negation of this matcher to an ostream. For - // example, if the description of this matcher is "is greater than - // 7", the negated description could be "is not greater than 7". - // You are not required to override this when implementing - // MatcherInterface, but it is highly advised so that your matcher - // can produce good error messages. - virtual void DescribeNegationTo(::std::ostream* os) const { - *os << "not ("; - DescribeTo(os); - *os << ")"; - } -}; - -// The implementation of a matcher. -template -class MatcherInterface : public MatcherDescriberInterface { - public: - // Returns true iff the matcher matches x; also explains the match - // result to 'listener' if necessary (see the next paragraph), in - // the form of a non-restrictive relative clause ("which ...", - // "whose ...", etc) that describes x. For example, the - // MatchAndExplain() method of the Pointee(...) matcher should - // generate an explanation like "which points to ...". - // - // Implementations of MatchAndExplain() should add an explanation of - // the match result *if and only if* they can provide additional - // information that's not already present (or not obvious) in the - // print-out of x and the matcher's description. Whether the match - // succeeds is not a factor in deciding whether an explanation is - // needed, as sometimes the caller needs to print a failure message - // when the match succeeds (e.g. when the matcher is used inside - // Not()). - // - // For example, a "has at least 10 elements" matcher should explain - // what the actual element count is, regardless of the match result, - // as it is useful information to the reader; on the other hand, an - // "is empty" matcher probably only needs to explain what the actual - // size is when the match fails, as it's redundant to say that the - // size is 0 when the value is already known to be empty. - // - // You should override this method when defining a new matcher. - // - // It's the responsibility of the caller (Google Mock) to guarantee - // that 'listener' is not NULL. This helps to simplify a matcher's - // implementation when it doesn't care about the performance, as it - // can talk to 'listener' without checking its validity first. - // However, in order to implement dummy listeners efficiently, - // listener->stream() may be NULL. - virtual bool MatchAndExplain(T x, MatchResultListener* listener) const = 0; - - // Inherits these methods from MatcherDescriberInterface: - // virtual void DescribeTo(::std::ostream* os) const = 0; - // virtual void DescribeNegationTo(::std::ostream* os) const; -}; - -namespace internal { - -// Converts a MatcherInterface to a MatcherInterface. -template -class MatcherInterfaceAdapter : public MatcherInterface { - public: - explicit MatcherInterfaceAdapter(const MatcherInterface* impl) - : impl_(impl) {} - virtual ~MatcherInterfaceAdapter() { delete impl_; } - - virtual void DescribeTo(::std::ostream* os) const { impl_->DescribeTo(os); } - - virtual void DescribeNegationTo(::std::ostream* os) const { - impl_->DescribeNegationTo(os); - } - - virtual bool MatchAndExplain(const T& x, - MatchResultListener* listener) const { - return impl_->MatchAndExplain(x, listener); - } - - private: - const MatcherInterface* const impl_; - - GTEST_DISALLOW_COPY_AND_ASSIGN_(MatcherInterfaceAdapter); -}; - -} // namespace internal - -// A match result listener that stores the explanation in a string. -class StringMatchResultListener : public MatchResultListener { - public: - StringMatchResultListener() : MatchResultListener(&ss_) {} - - // Returns the explanation accumulated so far. - std::string str() const { return ss_.str(); } - - // Clears the explanation accumulated so far. - void Clear() { ss_.str(""); } - - private: - ::std::stringstream ss_; - - GTEST_DISALLOW_COPY_AND_ASSIGN_(StringMatchResultListener); -}; - -namespace internal { - -struct AnyEq { - template - bool operator()(const A& a, const B& b) const { return a == b; } -}; -struct AnyNe { - template - bool operator()(const A& a, const B& b) const { return a != b; } -}; -struct AnyLt { - template - bool operator()(const A& a, const B& b) const { return a < b; } -}; -struct AnyGt { - template - bool operator()(const A& a, const B& b) const { return a > b; } -}; -struct AnyLe { - template - bool operator()(const A& a, const B& b) const { return a <= b; } -}; -struct AnyGe { - template - bool operator()(const A& a, const B& b) const { return a >= b; } -}; - -// A match result listener that ignores the explanation. -class DummyMatchResultListener : public MatchResultListener { - public: - DummyMatchResultListener() : MatchResultListener(NULL) {} - - private: - GTEST_DISALLOW_COPY_AND_ASSIGN_(DummyMatchResultListener); -}; - -// A match result listener that forwards the explanation to a given -// ostream. The difference between this and MatchResultListener is -// that the former is concrete. -class StreamMatchResultListener : public MatchResultListener { - public: - explicit StreamMatchResultListener(::std::ostream* os) - : MatchResultListener(os) {} - - private: - GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamMatchResultListener); -}; - -// An internal class for implementing Matcher, which will derive -// from it. We put functionalities common to all Matcher -// specializations here to avoid code duplication. -template -class MatcherBase { - public: - // Returns true iff the matcher matches x; also explains the match - // result to 'listener'. - bool MatchAndExplain(GTEST_REFERENCE_TO_CONST_(T) x, - MatchResultListener* listener) const { - return impl_->MatchAndExplain(x, listener); - } - - // Returns true iff this matcher matches x. - bool Matches(GTEST_REFERENCE_TO_CONST_(T) x) const { - DummyMatchResultListener dummy; - return MatchAndExplain(x, &dummy); - } - - // Describes this matcher to an ostream. - void DescribeTo(::std::ostream* os) const { impl_->DescribeTo(os); } - - // Describes the negation of this matcher to an ostream. - void DescribeNegationTo(::std::ostream* os) const { - impl_->DescribeNegationTo(os); - } - - // Explains why x matches, or doesn't match, the matcher. - void ExplainMatchResultTo(GTEST_REFERENCE_TO_CONST_(T) x, - ::std::ostream* os) const { - StreamMatchResultListener listener(os); - MatchAndExplain(x, &listener); - } - - // Returns the describer for this matcher object; retains ownership - // of the describer, which is only guaranteed to be alive when - // this matcher object is alive. - const MatcherDescriberInterface* GetDescriber() const { - return impl_.get(); - } - - protected: - MatcherBase() {} - - // Constructs a matcher from its implementation. - explicit MatcherBase( - const MatcherInterface* impl) - : impl_(impl) {} - - template - explicit MatcherBase( - const MatcherInterface* impl, - typename internal::EnableIf< - !internal::IsSame::value>::type* = - NULL) - : impl_(new internal::MatcherInterfaceAdapter(impl)) {} - - virtual ~MatcherBase() {} - - private: - // shared_ptr (util/gtl/shared_ptr.h) and linked_ptr have similar - // interfaces. The former dynamically allocates a chunk of memory - // to hold the reference count, while the latter tracks all - // references using a circular linked list without allocating - // memory. It has been observed that linked_ptr performs better in - // typical scenarios. However, shared_ptr can out-perform - // linked_ptr when there are many more uses of the copy constructor - // than the default constructor. - // - // If performance becomes a problem, we should see if using - // shared_ptr helps. - ::testing::internal::linked_ptr< - const MatcherInterface > - impl_; -}; - -} // namespace internal - -// A Matcher is a copyable and IMMUTABLE (except by assignment) -// object that can check whether a value of type T matches. The -// implementation of Matcher is just a linked_ptr to const -// MatcherInterface, so copying is fairly cheap. Don't inherit -// from Matcher! -template -class Matcher : public internal::MatcherBase { - public: - // Constructs a null matcher. Needed for storing Matcher objects in STL - // containers. A default-constructed matcher is not yet initialized. You - // cannot use it until a valid value has been assigned to it. - explicit Matcher() {} // NOLINT - - // Constructs a matcher from its implementation. - explicit Matcher(const MatcherInterface* impl) - : internal::MatcherBase(impl) {} - - template - explicit Matcher(const MatcherInterface* impl, - typename internal::EnableIf::value>::type* = NULL) - : internal::MatcherBase(impl) {} - - // Implicit constructor here allows people to write - // EXPECT_CALL(foo, Bar(5)) instead of EXPECT_CALL(foo, Bar(Eq(5))) sometimes - Matcher(T value); // NOLINT -}; - -// The following two specializations allow the user to write str -// instead of Eq(str) and "foo" instead of Eq("foo") when a std::string -// matcher is expected. -template <> -class GTEST_API_ Matcher - : public internal::MatcherBase { - public: - Matcher() {} - - explicit Matcher(const MatcherInterface* impl) - : internal::MatcherBase(impl) {} - - // Allows the user to write str instead of Eq(str) sometimes, where - // str is a std::string object. - Matcher(const std::string& s); // NOLINT - -#if GTEST_HAS_GLOBAL_STRING - // Allows the user to write str instead of Eq(str) sometimes, where - // str is a ::string object. - Matcher(const ::string& s); // NOLINT -#endif // GTEST_HAS_GLOBAL_STRING - - // Allows the user to write "foo" instead of Eq("foo") sometimes. - Matcher(const char* s); // NOLINT -}; - -template <> -class GTEST_API_ Matcher - : public internal::MatcherBase { - public: - Matcher() {} - - explicit Matcher(const MatcherInterface* impl) - : internal::MatcherBase(impl) {} - explicit Matcher(const MatcherInterface* impl) - : internal::MatcherBase(impl) {} - - // Allows the user to write str instead of Eq(str) sometimes, where - // str is a string object. - Matcher(const std::string& s); // NOLINT - -#if GTEST_HAS_GLOBAL_STRING - // Allows the user to write str instead of Eq(str) sometimes, where - // str is a ::string object. - Matcher(const ::string& s); // NOLINT -#endif // GTEST_HAS_GLOBAL_STRING - - // Allows the user to write "foo" instead of Eq("foo") sometimes. - Matcher(const char* s); // NOLINT -}; - -#if GTEST_HAS_GLOBAL_STRING -// The following two specializations allow the user to write str -// instead of Eq(str) and "foo" instead of Eq("foo") when a ::string -// matcher is expected. -template <> -class GTEST_API_ Matcher - : public internal::MatcherBase { - public: - Matcher() {} - - explicit Matcher(const MatcherInterface* impl) - : internal::MatcherBase(impl) {} - - // Allows the user to write str instead of Eq(str) sometimes, where - // str is a std::string object. - Matcher(const std::string& s); // NOLINT - - // Allows the user to write str instead of Eq(str) sometimes, where - // str is a ::string object. - Matcher(const ::string& s); // NOLINT - - // Allows the user to write "foo" instead of Eq("foo") sometimes. - Matcher(const char* s); // NOLINT -}; - -template <> -class GTEST_API_ Matcher< ::string> - : public internal::MatcherBase< ::string> { - public: - Matcher() {} - - explicit Matcher(const MatcherInterface* impl) - : internal::MatcherBase< ::string>(impl) {} - explicit Matcher(const MatcherInterface< ::string>* impl) - : internal::MatcherBase< ::string>(impl) {} - - // Allows the user to write str instead of Eq(str) sometimes, where - // str is a std::string object. - Matcher(const std::string& s); // NOLINT - - // Allows the user to write str instead of Eq(str) sometimes, where - // str is a ::string object. - Matcher(const ::string& s); // NOLINT - - // Allows the user to write "foo" instead of Eq("foo") sometimes. - Matcher(const char* s); // NOLINT -}; -#endif // GTEST_HAS_GLOBAL_STRING - -#if GTEST_HAS_ABSL -// The following two specializations allow the user to write str -// instead of Eq(str) and "foo" instead of Eq("foo") when a absl::string_view -// matcher is expected. -template <> -class GTEST_API_ Matcher - : public internal::MatcherBase { - public: - Matcher() {} - - explicit Matcher(const MatcherInterface* impl) - : internal::MatcherBase(impl) {} - - // Allows the user to write str instead of Eq(str) sometimes, where - // str is a std::string object. - Matcher(const std::string& s); // NOLINT - -#if GTEST_HAS_GLOBAL_STRING - // Allows the user to write str instead of Eq(str) sometimes, where - // str is a ::string object. - Matcher(const ::string& s); // NOLINT -#endif // GTEST_HAS_GLOBAL_STRING - - // Allows the user to write "foo" instead of Eq("foo") sometimes. - Matcher(const char* s); // NOLINT - - // Allows the user to pass absl::string_views directly. - Matcher(absl::string_view s); // NOLINT -}; - -template <> -class GTEST_API_ Matcher - : public internal::MatcherBase { - public: - Matcher() {} - - explicit Matcher(const MatcherInterface* impl) - : internal::MatcherBase(impl) {} - explicit Matcher(const MatcherInterface* impl) - : internal::MatcherBase(impl) {} - - // Allows the user to write str instead of Eq(str) sometimes, where - // str is a std::string object. - Matcher(const std::string& s); // NOLINT - -#if GTEST_HAS_GLOBAL_STRING - // Allows the user to write str instead of Eq(str) sometimes, where - // str is a ::string object. - Matcher(const ::string& s); // NOLINT -#endif // GTEST_HAS_GLOBAL_STRING - - // Allows the user to write "foo" instead of Eq("foo") sometimes. - Matcher(const char* s); // NOLINT - - // Allows the user to pass absl::string_views directly. - Matcher(absl::string_view s); // NOLINT -}; -#endif // GTEST_HAS_ABSL - -// Prints a matcher in a human-readable format. -template -std::ostream& operator<<(std::ostream& os, const Matcher& matcher) { - matcher.DescribeTo(&os); - return os; -} - -// The PolymorphicMatcher class template makes it easy to implement a -// polymorphic matcher (i.e. a matcher that can match values of more -// than one type, e.g. Eq(n) and NotNull()). -// -// To define a polymorphic matcher, a user should provide an Impl -// class that has a DescribeTo() method and a DescribeNegationTo() -// method, and define a member function (or member function template) -// -// bool MatchAndExplain(const Value& value, -// MatchResultListener* listener) const; -// -// See the definition of NotNull() for a complete example. -template -class PolymorphicMatcher { - public: - explicit PolymorphicMatcher(const Impl& an_impl) : impl_(an_impl) {} - - // Returns a mutable reference to the underlying matcher - // implementation object. - Impl& mutable_impl() { return impl_; } - - // Returns an immutable reference to the underlying matcher - // implementation object. - const Impl& impl() const { return impl_; } - - template - operator Matcher() const { - return Matcher(new MonomorphicImpl(impl_)); - } - - private: - template - class MonomorphicImpl : public MatcherInterface { - public: - explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {} - - virtual void DescribeTo(::std::ostream* os) const { - impl_.DescribeTo(os); - } - - virtual void DescribeNegationTo(::std::ostream* os) const { - impl_.DescribeNegationTo(os); - } - - virtual bool MatchAndExplain(T x, MatchResultListener* listener) const { - return impl_.MatchAndExplain(x, listener); - } - - private: - const Impl impl_; - - GTEST_DISALLOW_ASSIGN_(MonomorphicImpl); - }; - - Impl impl_; - - GTEST_DISALLOW_ASSIGN_(PolymorphicMatcher); -}; - -// Creates a matcher from its implementation. This is easier to use -// than the Matcher constructor as it doesn't require you to -// explicitly write the template argument, e.g. -// -// MakeMatcher(foo); -// vs -// Matcher(foo); -template -inline Matcher MakeMatcher(const MatcherInterface* impl) { - return Matcher(impl); -} - -// Creates a polymorphic matcher from its implementation. This is -// easier to use than the PolymorphicMatcher constructor as it -// doesn't require you to explicitly write the template argument, e.g. -// -// MakePolymorphicMatcher(foo); -// vs -// PolymorphicMatcher(foo); -template -inline PolymorphicMatcher MakePolymorphicMatcher(const Impl& impl) { - return PolymorphicMatcher(impl); -} - -// Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION -// and MUST NOT BE USED IN USER CODE!!! -namespace internal { - -// The MatcherCastImpl class template is a helper for implementing -// MatcherCast(). We need this helper in order to partially -// specialize the implementation of MatcherCast() (C++ allows -// class/struct templates to be partially specialized, but not -// function templates.). - -// This general version is used when MatcherCast()'s argument is a -// polymorphic matcher (i.e. something that can be converted to a -// Matcher but is not one yet; for example, Eq(value)) or a value (for -// example, "hello"). -template -class MatcherCastImpl { - public: - static Matcher Cast(const M& polymorphic_matcher_or_value) { - // M can be a polymorphic matcher, in which case we want to use - // its conversion operator to create Matcher. Or it can be a value - // that should be passed to the Matcher's constructor. - // - // We can't call Matcher(polymorphic_matcher_or_value) when M is a - // polymorphic matcher because it'll be ambiguous if T has an implicit - // constructor from M (this usually happens when T has an implicit - // constructor from any type). - // - // It won't work to unconditionally implict_cast - // polymorphic_matcher_or_value to Matcher because it won't trigger - // a user-defined conversion from M to T if one exists (assuming M is - // a value). - return CastImpl( - polymorphic_matcher_or_value, - BooleanConstant< - internal::ImplicitlyConvertible >::value>(), - BooleanConstant< - internal::ImplicitlyConvertible::value>()); - } - - private: - template - static Matcher CastImpl(const M& polymorphic_matcher_or_value, - BooleanConstant /* convertible_to_matcher */, - BooleanConstant) { - // M is implicitly convertible to Matcher, which means that either - // M is a polymorphic matcher or Matcher has an implicit constructor - // from M. In both cases using the implicit conversion will produce a - // matcher. - // - // Even if T has an implicit constructor from M, it won't be called because - // creating Matcher would require a chain of two user-defined conversions - // (first to create T from M and then to create Matcher from T). - return polymorphic_matcher_or_value; - } - - // M can't be implicitly converted to Matcher, so M isn't a polymorphic - // matcher. It's a value of a type implicitly convertible to T. Use direct - // initialization to create a matcher. - static Matcher CastImpl( - const M& value, BooleanConstant /* convertible_to_matcher */, - BooleanConstant /* convertible_to_T */) { - return Matcher(ImplicitCast_(value)); - } - - // M can't be implicitly converted to either Matcher or T. Attempt to use - // polymorphic matcher Eq(value) in this case. - // - // Note that we first attempt to perform an implicit cast on the value and - // only fall back to the polymorphic Eq() matcher afterwards because the - // latter calls bool operator==(const Lhs& lhs, const Rhs& rhs) in the end - // which might be undefined even when Rhs is implicitly convertible to Lhs - // (e.g. std::pair vs. std::pair). - // - // We don't define this method inline as we need the declaration of Eq(). - static Matcher CastImpl( - const M& value, BooleanConstant /* convertible_to_matcher */, - BooleanConstant /* convertible_to_T */); -}; - -// This more specialized version is used when MatcherCast()'s argument -// is already a Matcher. This only compiles when type T can be -// statically converted to type U. -template -class MatcherCastImpl > { - public: - static Matcher Cast(const Matcher& source_matcher) { - return Matcher(new Impl(source_matcher)); - } - - private: - class Impl : public MatcherInterface { - public: - explicit Impl(const Matcher& source_matcher) - : source_matcher_(source_matcher) {} - - // We delegate the matching logic to the source matcher. - virtual bool MatchAndExplain(T x, MatchResultListener* listener) const { -#if GTEST_LANG_CXX11 - using FromType = typename std::remove_cv::type>::type>::type; - using ToType = typename std::remove_cv::type>::type>::type; - // Do not allow implicitly converting base*/& to derived*/&. - static_assert( - // Do not trigger if only one of them is a pointer. That implies a - // regular conversion and not a down_cast. - (std::is_pointer::type>::value != - std::is_pointer::type>::value) || - std::is_same::value || - !std::is_base_of::value, - "Can't implicitly convert from to "); -#endif // GTEST_LANG_CXX11 - - return source_matcher_.MatchAndExplain(static_cast(x), listener); - } - - virtual void DescribeTo(::std::ostream* os) const { - source_matcher_.DescribeTo(os); - } - - virtual void DescribeNegationTo(::std::ostream* os) const { - source_matcher_.DescribeNegationTo(os); - } - - private: - const Matcher source_matcher_; - - GTEST_DISALLOW_ASSIGN_(Impl); - }; -}; - -// This even more specialized version is used for efficiently casting -// a matcher to its own type. -template -class MatcherCastImpl > { - public: - static Matcher Cast(const Matcher& matcher) { return matcher; } -}; - -} // namespace internal - -// In order to be safe and clear, casting between different matcher -// types is done explicitly via MatcherCast(m), which takes a -// matcher m and returns a Matcher. It compiles only when T can be -// statically converted to the argument type of m. -template -inline Matcher MatcherCast(const M& matcher) { - return internal::MatcherCastImpl::Cast(matcher); -} - -// Implements SafeMatcherCast(). -// -// We use an intermediate class to do the actual safe casting as Nokia's -// Symbian compiler cannot decide between -// template ... (M) and -// template ... (const Matcher&) -// for function templates but can for member function templates. -template -class SafeMatcherCastImpl { - public: - // This overload handles polymorphic matchers and values only since - // monomorphic matchers are handled by the next one. - template - static inline Matcher Cast(const M& polymorphic_matcher_or_value) { - return internal::MatcherCastImpl::Cast(polymorphic_matcher_or_value); - } - - // This overload handles monomorphic matchers. - // - // In general, if type T can be implicitly converted to type U, we can - // safely convert a Matcher to a Matcher (i.e. Matcher is - // contravariant): just keep a copy of the original Matcher, convert the - // argument from type T to U, and then pass it to the underlying Matcher. - // The only exception is when U is a reference and T is not, as the - // underlying Matcher may be interested in the argument's address, which - // is not preserved in the conversion from T to U. - template - static inline Matcher Cast(const Matcher& matcher) { - // Enforce that T can be implicitly converted to U. - GTEST_COMPILE_ASSERT_((internal::ImplicitlyConvertible::value), - T_must_be_implicitly_convertible_to_U); - // Enforce that we are not converting a non-reference type T to a reference - // type U. - GTEST_COMPILE_ASSERT_( - internal::is_reference::value || !internal::is_reference::value, - cannot_convert_non_reference_arg_to_reference); - // In case both T and U are arithmetic types, enforce that the - // conversion is not lossy. - typedef GTEST_REMOVE_REFERENCE_AND_CONST_(T) RawT; - typedef GTEST_REMOVE_REFERENCE_AND_CONST_(U) RawU; - const bool kTIsOther = GMOCK_KIND_OF_(RawT) == internal::kOther; - const bool kUIsOther = GMOCK_KIND_OF_(RawU) == internal::kOther; - GTEST_COMPILE_ASSERT_( - kTIsOther || kUIsOther || - (internal::LosslessArithmeticConvertible::value), - conversion_of_arithmetic_types_must_be_lossless); - return MatcherCast(matcher); - } -}; - -template -inline Matcher SafeMatcherCast(const M& polymorphic_matcher) { - return SafeMatcherCastImpl::Cast(polymorphic_matcher); -} - -// A() returns a matcher that matches any value of type T. -template -Matcher A(); - -// Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION -// and MUST NOT BE USED IN USER CODE!!! -namespace internal { - -// If the explanation is not empty, prints it to the ostream. -inline void PrintIfNotEmpty(const std::string& explanation, - ::std::ostream* os) { - if (explanation != "" && os != NULL) { - *os << ", " << explanation; - } -} - -// Returns true if the given type name is easy to read by a human. -// This is used to decide whether printing the type of a value might -// be helpful. -inline bool IsReadableTypeName(const std::string& type_name) { - // We consider a type name readable if it's short or doesn't contain - // a template or function type. - return (type_name.length() <= 20 || - type_name.find_first_of("<(") == std::string::npos); -} - -// Matches the value against the given matcher, prints the value and explains -// the match result to the listener. Returns the match result. -// 'listener' must not be NULL. -// Value cannot be passed by const reference, because some matchers take a -// non-const argument. -template -bool MatchPrintAndExplain(Value& value, const Matcher& matcher, - MatchResultListener* listener) { - if (!listener->IsInterested()) { - // If the listener is not interested, we do not need to construct the - // inner explanation. - return matcher.Matches(value); - } - - StringMatchResultListener inner_listener; - const bool match = matcher.MatchAndExplain(value, &inner_listener); - - UniversalPrint(value, listener->stream()); -#if GTEST_HAS_RTTI - const std::string& type_name = GetTypeName(); - if (IsReadableTypeName(type_name)) - *listener->stream() << " (of type " << type_name << ")"; -#endif - PrintIfNotEmpty(inner_listener.str(), listener->stream()); - - return match; -} - -// An internal helper class for doing compile-time loop on a tuple's -// fields. -template -class TuplePrefix { - public: - // TuplePrefix::Matches(matcher_tuple, value_tuple) returns true - // iff the first N fields of matcher_tuple matches the first N - // fields of value_tuple, respectively. - template - static bool Matches(const MatcherTuple& matcher_tuple, - const ValueTuple& value_tuple) { - return TuplePrefix::Matches(matcher_tuple, value_tuple) - && get(matcher_tuple).Matches(get(value_tuple)); - } - - // TuplePrefix::ExplainMatchFailuresTo(matchers, values, os) - // describes failures in matching the first N fields of matchers - // against the first N fields of values. If there is no failure, - // nothing will be streamed to os. - template - static void ExplainMatchFailuresTo(const MatcherTuple& matchers, - const ValueTuple& values, - ::std::ostream* os) { - // First, describes failures in the first N - 1 fields. - TuplePrefix::ExplainMatchFailuresTo(matchers, values, os); - - // Then describes the failure (if any) in the (N - 1)-th (0-based) - // field. - typename tuple_element::type matcher = - get(matchers); - typedef typename tuple_element::type Value; - GTEST_REFERENCE_TO_CONST_(Value) value = get(values); - StringMatchResultListener listener; - if (!matcher.MatchAndExplain(value, &listener)) { - // TODO(wan): include in the message the name of the parameter - // as used in MOCK_METHOD*() when possible. - *os << " Expected arg #" << N - 1 << ": "; - get(matchers).DescribeTo(os); - *os << "\n Actual: "; - // We remove the reference in type Value to prevent the - // universal printer from printing the address of value, which - // isn't interesting to the user most of the time. The - // matcher's MatchAndExplain() method handles the case when - // the address is interesting. - internal::UniversalPrint(value, os); - PrintIfNotEmpty(listener.str(), os); - *os << "\n"; - } - } -}; - -// The base case. -template <> -class TuplePrefix<0> { - public: - template - static bool Matches(const MatcherTuple& /* matcher_tuple */, - const ValueTuple& /* value_tuple */) { - return true; - } - - template - static void ExplainMatchFailuresTo(const MatcherTuple& /* matchers */, - const ValueTuple& /* values */, - ::std::ostream* /* os */) {} -}; - -// TupleMatches(matcher_tuple, value_tuple) returns true iff all -// matchers in matcher_tuple match the corresponding fields in -// value_tuple. It is a compiler error if matcher_tuple and -// value_tuple have different number of fields or incompatible field -// types. -template -bool TupleMatches(const MatcherTuple& matcher_tuple, - const ValueTuple& value_tuple) { - // Makes sure that matcher_tuple and value_tuple have the same - // number of fields. - GTEST_COMPILE_ASSERT_(tuple_size::value == - tuple_size::value, - matcher_and_value_have_different_numbers_of_fields); - return TuplePrefix::value>:: - Matches(matcher_tuple, value_tuple); -} - -// Describes failures in matching matchers against values. If there -// is no failure, nothing will be streamed to os. -template -void ExplainMatchFailureTupleTo(const MatcherTuple& matchers, - const ValueTuple& values, - ::std::ostream* os) { - TuplePrefix::value>::ExplainMatchFailuresTo( - matchers, values, os); -} - -// TransformTupleValues and its helper. -// -// TransformTupleValuesHelper hides the internal machinery that -// TransformTupleValues uses to implement a tuple traversal. -template -class TransformTupleValuesHelper { - private: - typedef ::testing::tuple_size TupleSize; - - public: - // For each member of tuple 't', taken in order, evaluates '*out++ = f(t)'. - // Returns the final value of 'out' in case the caller needs it. - static OutIter Run(Func f, const Tuple& t, OutIter out) { - return IterateOverTuple()(f, t, out); - } - - private: - template - struct IterateOverTuple { - OutIter operator() (Func f, const Tup& t, OutIter out) const { - *out++ = f(::testing::get(t)); - return IterateOverTuple()(f, t, out); - } - }; - template - struct IterateOverTuple { - OutIter operator() (Func /* f */, const Tup& /* t */, OutIter out) const { - return out; - } - }; -}; - -// Successively invokes 'f(element)' on each element of the tuple 't', -// appending each result to the 'out' iterator. Returns the final value -// of 'out'. -template -OutIter TransformTupleValues(Func f, const Tuple& t, OutIter out) { - return TransformTupleValuesHelper::Run(f, t, out); -} - -// Implements A(). -template -class AnyMatcherImpl : public MatcherInterface { - public: - virtual bool MatchAndExplain(GTEST_REFERENCE_TO_CONST_(T) /* x */, - MatchResultListener* /* listener */) const { - return true; - } - virtual void DescribeTo(::std::ostream* os) const { *os << "is anything"; } - virtual void DescribeNegationTo(::std::ostream* os) const { - // This is mostly for completeness' safe, as it's not very useful - // to write Not(A()). However we cannot completely rule out - // such a possibility, and it doesn't hurt to be prepared. - *os << "never matches"; - } -}; - -// Implements _, a matcher that matches any value of any -// type. This is a polymorphic matcher, so we need a template type -// conversion operator to make it appearing as a Matcher for any -// type T. -class AnythingMatcher { - public: - template - operator Matcher() const { return A(); } -}; - -// Implements a matcher that compares a given value with a -// pre-supplied value using one of the ==, <=, <, etc, operators. The -// two values being compared don't have to have the same type. -// -// The matcher defined here is polymorphic (for example, Eq(5) can be -// used to match an int, a short, a double, etc). Therefore we use -// a template type conversion operator in the implementation. -// -// The following template definition assumes that the Rhs parameter is -// a "bare" type (i.e. neither 'const T' nor 'T&'). -template -class ComparisonBase { - public: - explicit ComparisonBase(const Rhs& rhs) : rhs_(rhs) {} - template - operator Matcher() const { - return MakeMatcher(new Impl(rhs_)); - } - - private: - template - class Impl : public MatcherInterface { - public: - explicit Impl(const Rhs& rhs) : rhs_(rhs) {} - virtual bool MatchAndExplain( - Lhs lhs, MatchResultListener* /* listener */) const { - return Op()(lhs, rhs_); - } - virtual void DescribeTo(::std::ostream* os) const { - *os << D::Desc() << " "; - UniversalPrint(rhs_, os); - } - virtual void DescribeNegationTo(::std::ostream* os) const { - *os << D::NegatedDesc() << " "; - UniversalPrint(rhs_, os); - } - private: - Rhs rhs_; - GTEST_DISALLOW_ASSIGN_(Impl); - }; - Rhs rhs_; - GTEST_DISALLOW_ASSIGN_(ComparisonBase); -}; - -template -class EqMatcher : public ComparisonBase, Rhs, AnyEq> { - public: - explicit EqMatcher(const Rhs& rhs) - : ComparisonBase, Rhs, AnyEq>(rhs) { } - static const char* Desc() { return "is equal to"; } - static const char* NegatedDesc() { return "isn't equal to"; } -}; -template -class NeMatcher : public ComparisonBase, Rhs, AnyNe> { - public: - explicit NeMatcher(const Rhs& rhs) - : ComparisonBase, Rhs, AnyNe>(rhs) { } - static const char* Desc() { return "isn't equal to"; } - static const char* NegatedDesc() { return "is equal to"; } -}; -template -class LtMatcher : public ComparisonBase, Rhs, AnyLt> { - public: - explicit LtMatcher(const Rhs& rhs) - : ComparisonBase, Rhs, AnyLt>(rhs) { } - static const char* Desc() { return "is <"; } - static const char* NegatedDesc() { return "isn't <"; } -}; -template -class GtMatcher : public ComparisonBase, Rhs, AnyGt> { - public: - explicit GtMatcher(const Rhs& rhs) - : ComparisonBase, Rhs, AnyGt>(rhs) { } - static const char* Desc() { return "is >"; } - static const char* NegatedDesc() { return "isn't >"; } -}; -template -class LeMatcher : public ComparisonBase, Rhs, AnyLe> { - public: - explicit LeMatcher(const Rhs& rhs) - : ComparisonBase, Rhs, AnyLe>(rhs) { } - static const char* Desc() { return "is <="; } - static const char* NegatedDesc() { return "isn't <="; } -}; -template -class GeMatcher : public ComparisonBase, Rhs, AnyGe> { - public: - explicit GeMatcher(const Rhs& rhs) - : ComparisonBase, Rhs, AnyGe>(rhs) { } - static const char* Desc() { return "is >="; } - static const char* NegatedDesc() { return "isn't >="; } -}; - -// Implements the polymorphic IsNull() matcher, which matches any raw or smart -// pointer that is NULL. -class IsNullMatcher { - public: - template - bool MatchAndExplain(const Pointer& p, - MatchResultListener* /* listener */) const { -#if GTEST_LANG_CXX11 - return p == nullptr; -#else // GTEST_LANG_CXX11 - return GetRawPointer(p) == NULL; -#endif // GTEST_LANG_CXX11 - } - - void DescribeTo(::std::ostream* os) const { *os << "is NULL"; } - void DescribeNegationTo(::std::ostream* os) const { - *os << "isn't NULL"; - } -}; - -// Implements the polymorphic NotNull() matcher, which matches any raw or smart -// pointer that is not NULL. -class NotNullMatcher { - public: - template - bool MatchAndExplain(const Pointer& p, - MatchResultListener* /* listener */) const { -#if GTEST_LANG_CXX11 - return p != nullptr; -#else // GTEST_LANG_CXX11 - return GetRawPointer(p) != NULL; -#endif // GTEST_LANG_CXX11 - } - - void DescribeTo(::std::ostream* os) const { *os << "isn't NULL"; } - void DescribeNegationTo(::std::ostream* os) const { - *os << "is NULL"; - } -}; - -// Ref(variable) matches any argument that is a reference to -// 'variable'. This matcher is polymorphic as it can match any -// super type of the type of 'variable'. -// -// The RefMatcher template class implements Ref(variable). It can -// only be instantiated with a reference type. This prevents a user -// from mistakenly using Ref(x) to match a non-reference function -// argument. For example, the following will righteously cause a -// compiler error: -// -// int n; -// Matcher m1 = Ref(n); // This won't compile. -// Matcher m2 = Ref(n); // This will compile. -template -class RefMatcher; - -template -class RefMatcher { - // Google Mock is a generic framework and thus needs to support - // mocking any function types, including those that take non-const - // reference arguments. Therefore the template parameter T (and - // Super below) can be instantiated to either a const type or a - // non-const type. - public: - // RefMatcher() takes a T& instead of const T&, as we want the - // compiler to catch using Ref(const_value) as a matcher for a - // non-const reference. - explicit RefMatcher(T& x) : object_(x) {} // NOLINT - - template - operator Matcher() const { - // By passing object_ (type T&) to Impl(), which expects a Super&, - // we make sure that Super is a super type of T. In particular, - // this catches using Ref(const_value) as a matcher for a - // non-const reference, as you cannot implicitly convert a const - // reference to a non-const reference. - return MakeMatcher(new Impl(object_)); - } - - private: - template - class Impl : public MatcherInterface { - public: - explicit Impl(Super& x) : object_(x) {} // NOLINT - - // MatchAndExplain() takes a Super& (as opposed to const Super&) - // in order to match the interface MatcherInterface. - virtual bool MatchAndExplain( - Super& x, MatchResultListener* listener) const { - *listener << "which is located @" << static_cast(&x); - return &x == &object_; - } - - virtual void DescribeTo(::std::ostream* os) const { - *os << "references the variable "; - UniversalPrinter::Print(object_, os); - } - - virtual void DescribeNegationTo(::std::ostream* os) const { - *os << "does not reference the variable "; - UniversalPrinter::Print(object_, os); - } - - private: - const Super& object_; - - GTEST_DISALLOW_ASSIGN_(Impl); - }; - - T& object_; - - GTEST_DISALLOW_ASSIGN_(RefMatcher); -}; - -// Polymorphic helper functions for narrow and wide string matchers. -inline bool CaseInsensitiveCStringEquals(const char* lhs, const char* rhs) { - return String::CaseInsensitiveCStringEquals(lhs, rhs); -} - -inline bool CaseInsensitiveCStringEquals(const wchar_t* lhs, - const wchar_t* rhs) { - return String::CaseInsensitiveWideCStringEquals(lhs, rhs); -} - -// String comparison for narrow or wide strings that can have embedded NUL -// characters. -template -bool CaseInsensitiveStringEquals(const StringType& s1, - const StringType& s2) { - // Are the heads equal? - if (!CaseInsensitiveCStringEquals(s1.c_str(), s2.c_str())) { - return false; - } - - // Skip the equal heads. - const typename StringType::value_type nul = 0; - const size_t i1 = s1.find(nul), i2 = s2.find(nul); - - // Are we at the end of either s1 or s2? - if (i1 == StringType::npos || i2 == StringType::npos) { - return i1 == i2; - } - - // Are the tails equal? - return CaseInsensitiveStringEquals(s1.substr(i1 + 1), s2.substr(i2 + 1)); -} - -// String matchers. - -// Implements equality-based string matchers like StrEq, StrCaseNe, and etc. -template -class StrEqualityMatcher { - public: - StrEqualityMatcher(const StringType& str, bool expect_eq, - bool case_sensitive) - : string_(str), expect_eq_(expect_eq), case_sensitive_(case_sensitive) {} - -#if GTEST_HAS_ABSL - bool MatchAndExplain(const absl::string_view& s, - MatchResultListener* listener) const { - if (s.data() == NULL) { - return !expect_eq_; - } - // This should fail to compile if absl::string_view is used with wide - // strings. - const StringType& str = string(s); - return MatchAndExplain(str, listener); - } -#endif // GTEST_HAS_ABSL - - // Accepts pointer types, particularly: - // const char* - // char* - // const wchar_t* - // wchar_t* - template - bool MatchAndExplain(CharType* s, MatchResultListener* listener) const { - if (s == NULL) { - return !expect_eq_; - } - return MatchAndExplain(StringType(s), listener); - } - - // Matches anything that can convert to StringType. - // - // This is a template, not just a plain function with const StringType&, - // because absl::string_view has some interfering non-explicit constructors. - template - bool MatchAndExplain(const MatcheeStringType& s, - MatchResultListener* /* listener */) const { - const StringType& s2(s); - const bool eq = case_sensitive_ ? s2 == string_ : - CaseInsensitiveStringEquals(s2, string_); - return expect_eq_ == eq; - } - - void DescribeTo(::std::ostream* os) const { - DescribeToHelper(expect_eq_, os); - } - - void DescribeNegationTo(::std::ostream* os) const { - DescribeToHelper(!expect_eq_, os); - } - - private: - void DescribeToHelper(bool expect_eq, ::std::ostream* os) const { - *os << (expect_eq ? "is " : "isn't "); - *os << "equal to "; - if (!case_sensitive_) { - *os << "(ignoring case) "; - } - UniversalPrint(string_, os); - } - - const StringType string_; - const bool expect_eq_; - const bool case_sensitive_; - - GTEST_DISALLOW_ASSIGN_(StrEqualityMatcher); -}; - -// Implements the polymorphic HasSubstr(substring) matcher, which -// can be used as a Matcher as long as T can be converted to a -// string. -template -class HasSubstrMatcher { - public: - explicit HasSubstrMatcher(const StringType& substring) - : substring_(substring) {} - -#if GTEST_HAS_ABSL - bool MatchAndExplain(const absl::string_view& s, - MatchResultListener* listener) const { - if (s.data() == NULL) { - return false; - } - // This should fail to compile if absl::string_view is used with wide - // strings. - const StringType& str = string(s); - return MatchAndExplain(str, listener); - } -#endif // GTEST_HAS_ABSL - - // Accepts pointer types, particularly: - // const char* - // char* - // const wchar_t* - // wchar_t* - template - bool MatchAndExplain(CharType* s, MatchResultListener* listener) const { - return s != NULL && MatchAndExplain(StringType(s), listener); - } - - // Matches anything that can convert to StringType. - // - // This is a template, not just a plain function with const StringType&, - // because absl::string_view has some interfering non-explicit constructors. - template - bool MatchAndExplain(const MatcheeStringType& s, - MatchResultListener* /* listener */) const { - const StringType& s2(s); - return s2.find(substring_) != StringType::npos; - } - - // Describes what this matcher matches. - void DescribeTo(::std::ostream* os) const { - *os << "has substring "; - UniversalPrint(substring_, os); - } - - void DescribeNegationTo(::std::ostream* os) const { - *os << "has no substring "; - UniversalPrint(substring_, os); - } - - private: - const StringType substring_; - - GTEST_DISALLOW_ASSIGN_(HasSubstrMatcher); -}; - -// Implements the polymorphic StartsWith(substring) matcher, which -// can be used as a Matcher as long as T can be converted to a -// string. -template -class StartsWithMatcher { - public: - explicit StartsWithMatcher(const StringType& prefix) : prefix_(prefix) { - } - -#if GTEST_HAS_ABSL - bool MatchAndExplain(const absl::string_view& s, - MatchResultListener* listener) const { - if (s.data() == NULL) { - return false; - } - // This should fail to compile if absl::string_view is used with wide - // strings. - const StringType& str = string(s); - return MatchAndExplain(str, listener); - } -#endif // GTEST_HAS_ABSL - - // Accepts pointer types, particularly: - // const char* - // char* - // const wchar_t* - // wchar_t* - template - bool MatchAndExplain(CharType* s, MatchResultListener* listener) const { - return s != NULL && MatchAndExplain(StringType(s), listener); - } - - // Matches anything that can convert to StringType. - // - // This is a template, not just a plain function with const StringType&, - // because absl::string_view has some interfering non-explicit constructors. - template - bool MatchAndExplain(const MatcheeStringType& s, - MatchResultListener* /* listener */) const { - const StringType& s2(s); - return s2.length() >= prefix_.length() && - s2.substr(0, prefix_.length()) == prefix_; - } - - void DescribeTo(::std::ostream* os) const { - *os << "starts with "; - UniversalPrint(prefix_, os); - } - - void DescribeNegationTo(::std::ostream* os) const { - *os << "doesn't start with "; - UniversalPrint(prefix_, os); - } - - private: - const StringType prefix_; - - GTEST_DISALLOW_ASSIGN_(StartsWithMatcher); -}; - -// Implements the polymorphic EndsWith(substring) matcher, which -// can be used as a Matcher as long as T can be converted to a -// string. -template -class EndsWithMatcher { - public: - explicit EndsWithMatcher(const StringType& suffix) : suffix_(suffix) {} - -#if GTEST_HAS_ABSL - bool MatchAndExplain(const absl::string_view& s, - MatchResultListener* listener) const { - if (s.data() == NULL) { - return false; - } - // This should fail to compile if absl::string_view is used with wide - // strings. - const StringType& str = string(s); - return MatchAndExplain(str, listener); - } -#endif // GTEST_HAS_ABSL - - // Accepts pointer types, particularly: - // const char* - // char* - // const wchar_t* - // wchar_t* - template - bool MatchAndExplain(CharType* s, MatchResultListener* listener) const { - return s != NULL && MatchAndExplain(StringType(s), listener); - } - - // Matches anything that can convert to StringType. - // - // This is a template, not just a plain function with const StringType&, - // because absl::string_view has some interfering non-explicit constructors. - template - bool MatchAndExplain(const MatcheeStringType& s, - MatchResultListener* /* listener */) const { - const StringType& s2(s); - return s2.length() >= suffix_.length() && - s2.substr(s2.length() - suffix_.length()) == suffix_; - } - - void DescribeTo(::std::ostream* os) const { - *os << "ends with "; - UniversalPrint(suffix_, os); - } - - void DescribeNegationTo(::std::ostream* os) const { - *os << "doesn't end with "; - UniversalPrint(suffix_, os); - } - - private: - const StringType suffix_; - - GTEST_DISALLOW_ASSIGN_(EndsWithMatcher); -}; - -// Implements polymorphic matchers MatchesRegex(regex) and -// ContainsRegex(regex), which can be used as a Matcher as long as -// T can be converted to a string. -class MatchesRegexMatcher { - public: - MatchesRegexMatcher(const RE* regex, bool full_match) - : regex_(regex), full_match_(full_match) {} - -#if GTEST_HAS_ABSL - bool MatchAndExplain(const absl::string_view& s, - MatchResultListener* listener) const { - return s.data() && MatchAndExplain(string(s), listener); - } -#endif // GTEST_HAS_ABSL - - // Accepts pointer types, particularly: - // const char* - // char* - // const wchar_t* - // wchar_t* - template - bool MatchAndExplain(CharType* s, MatchResultListener* listener) const { - return s != NULL && MatchAndExplain(std::string(s), listener); - } - - // Matches anything that can convert to std::string. - // - // This is a template, not just a plain function with const std::string&, - // because absl::string_view has some interfering non-explicit constructors. - template - bool MatchAndExplain(const MatcheeStringType& s, - MatchResultListener* /* listener */) const { - const std::string& s2(s); - return full_match_ ? RE::FullMatch(s2, *regex_) : - RE::PartialMatch(s2, *regex_); - } - - void DescribeTo(::std::ostream* os) const { - *os << (full_match_ ? "matches" : "contains") - << " regular expression "; - UniversalPrinter::Print(regex_->pattern(), os); - } - - void DescribeNegationTo(::std::ostream* os) const { - *os << "doesn't " << (full_match_ ? "match" : "contain") - << " regular expression "; - UniversalPrinter::Print(regex_->pattern(), os); - } - - private: - const internal::linked_ptr regex_; - const bool full_match_; - - GTEST_DISALLOW_ASSIGN_(MatchesRegexMatcher); -}; - -// Implements a matcher that compares the two fields of a 2-tuple -// using one of the ==, <=, <, etc, operators. The two fields being -// compared don't have to have the same type. -// -// The matcher defined here is polymorphic (for example, Eq() can be -// used to match a tuple, a tuple, -// etc). Therefore we use a template type conversion operator in the -// implementation. -template -class PairMatchBase { - public: - template - operator Matcher< ::testing::tuple >() const { - return MakeMatcher(new Impl< ::testing::tuple >); - } - template - operator Matcher&>() const { - return MakeMatcher(new Impl&>); - } - - private: - static ::std::ostream& GetDesc(::std::ostream& os) { // NOLINT - return os << D::Desc(); - } - - template - class Impl : public MatcherInterface { - public: - virtual bool MatchAndExplain( - Tuple args, - MatchResultListener* /* listener */) const { - return Op()(::testing::get<0>(args), ::testing::get<1>(args)); - } - virtual void DescribeTo(::std::ostream* os) const { - *os << "are " << GetDesc; - } - virtual void DescribeNegationTo(::std::ostream* os) const { - *os << "aren't " << GetDesc; - } - }; -}; - -class Eq2Matcher : public PairMatchBase { - public: - static const char* Desc() { return "an equal pair"; } -}; -class Ne2Matcher : public PairMatchBase { - public: - static const char* Desc() { return "an unequal pair"; } -}; -class Lt2Matcher : public PairMatchBase { - public: - static const char* Desc() { return "a pair where the first < the second"; } -}; -class Gt2Matcher : public PairMatchBase { - public: - static const char* Desc() { return "a pair where the first > the second"; } -}; -class Le2Matcher : public PairMatchBase { - public: - static const char* Desc() { return "a pair where the first <= the second"; } -}; -class Ge2Matcher : public PairMatchBase { - public: - static const char* Desc() { return "a pair where the first >= the second"; } -}; - -// Implements the Not(...) matcher for a particular argument type T. -// We do not nest it inside the NotMatcher class template, as that -// will prevent different instantiations of NotMatcher from sharing -// the same NotMatcherImpl class. -template -class NotMatcherImpl : public MatcherInterface { - public: - explicit NotMatcherImpl(const Matcher& matcher) - : matcher_(matcher) {} - - virtual bool MatchAndExplain(GTEST_REFERENCE_TO_CONST_(T) x, - MatchResultListener* listener) const { - return !matcher_.MatchAndExplain(x, listener); - } - - virtual void DescribeTo(::std::ostream* os) const { - matcher_.DescribeNegationTo(os); - } - - virtual void DescribeNegationTo(::std::ostream* os) const { - matcher_.DescribeTo(os); - } - - private: - const Matcher matcher_; - - GTEST_DISALLOW_ASSIGN_(NotMatcherImpl); -}; - -// Implements the Not(m) matcher, which matches a value that doesn't -// match matcher m. -template -class NotMatcher { - public: - explicit NotMatcher(InnerMatcher matcher) : matcher_(matcher) {} - - // This template type conversion operator allows Not(m) to be used - // to match any type m can match. - template - operator Matcher() const { - return Matcher(new NotMatcherImpl(SafeMatcherCast(matcher_))); - } - - private: - InnerMatcher matcher_; - - GTEST_DISALLOW_ASSIGN_(NotMatcher); -}; - -// Implements the AllOf(m1, m2) matcher for a particular argument type -// T. We do not nest it inside the BothOfMatcher class template, as -// that will prevent different instantiations of BothOfMatcher from -// sharing the same BothOfMatcherImpl class. -template -class AllOfMatcherImpl - : public MatcherInterface { - public: - explicit AllOfMatcherImpl(std::vector > matchers) - : matchers_(internal::move(matchers)) {} - - virtual void DescribeTo(::std::ostream* os) const { - *os << "("; - for (size_t i = 0; i < matchers_.size(); ++i) { - if (i != 0) *os << ") and ("; - matchers_[i].DescribeTo(os); - } - *os << ")"; - } - - virtual void DescribeNegationTo(::std::ostream* os) const { - *os << "("; - for (size_t i = 0; i < matchers_.size(); ++i) { - if (i != 0) *os << ") or ("; - matchers_[i].DescribeNegationTo(os); - } - *os << ")"; - } - - virtual bool MatchAndExplain(GTEST_REFERENCE_TO_CONST_(T) x, - MatchResultListener* listener) const { - // If either matcher1_ or matcher2_ doesn't match x, we only need - // to explain why one of them fails. - std::string all_match_result; - - for (size_t i = 0; i < matchers_.size(); ++i) { - StringMatchResultListener slistener; - if (matchers_[i].MatchAndExplain(x, &slistener)) { - if (all_match_result.empty()) { - all_match_result = slistener.str(); - } else { - std::string result = slistener.str(); - if (!result.empty()) { - all_match_result += ", and "; - all_match_result += result; - } - } - } else { - *listener << slistener.str(); - return false; - } - } - - // Otherwise we need to explain why *both* of them match. - *listener << all_match_result; - return true; - } - - private: - const std::vector > matchers_; - - GTEST_DISALLOW_ASSIGN_(AllOfMatcherImpl); -}; - -#if GTEST_LANG_CXX11 -// VariadicMatcher is used for the variadic implementation of -// AllOf(m_1, m_2, ...) and AnyOf(m_1, m_2, ...). -// CombiningMatcher is used to recursively combine the provided matchers -// (of type Args...). -template