From 75440ce241c4de94d51a9af841c26d6acaf06d69 Mon Sep 17 00:00:00 2001 From: "Efode, Irina" Date: Wed, 20 Oct 2021 14:42:55 +0300 Subject: [PATCH] Apply Maxim's comments --- .../single_layer_tests/eltwise.cpp | 6 +- .../single_layer_tests/softmax.cpp | 4 +- .../cpu/subgraph_tests/src/eltwise_chain.cpp | 608 +++++++++--------- .../shared_test_classes/base/ov_subgraph.hpp | 35 +- .../single_layer/eltwise.hpp | 2 +- .../src/base/ov_subgraph.cpp | 36 +- .../src/single_layer/eltwise.cpp | 24 +- .../src/single_layer/softmax.cpp | 2 +- 8 files changed, 350 insertions(+), 367 deletions(-) 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 a82e4235552..835e48a0e80 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 @@ -25,9 +25,9 @@ std::vector> inShapesStatic = { {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}, }; -std::vector inShapesDynamic = { - {{{ngraph::Dimension(1, 10), 200}, {ngraph::Dimension(1, 10), 200}}, - {{{2, 200}, {2, 200}}, {{1, 200}, {5, 200}}}}, +std::vector> inShapesDynamic = { + {{{ngraph::Dimension(1, 10), 200}, {{2, 200}, {1, 200}}}}, + {{{ngraph::Dimension(1, 10), 200}, {{2, 200}, {5, 200}}}}, }; std::vector 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 76923f7a893..e5e27986222 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 @@ -34,7 +34,7 @@ const std::vector axis2D = { const auto params2D_static = testing::Combine( testing::ValuesIn(netPrecisions), - testing::ValuesIn(ov::test::static_shapes_to_test_representation(inputStaticShape2D)), + testing::ValuesIn(ov::test::static_shapes_to_test_representation({inputStaticShape2D})), testing::ValuesIn(axis2D), testing::Values(CommonTestUtils::DEVICE_CPU), testing::Values(std::map()) @@ -78,7 +78,7 @@ const std::vector axis4D = {0, 1, 2, 3}; const auto params4Dstatic = testing::Combine( testing::ValuesIn(netPrecisions), - testing::ValuesIn(ov::test::static_shapes_to_test_representation(inputStaticShape4D)), + testing::ValuesIn(ov::test::static_shapes_to_test_representation({inputStaticShape4D})), testing::ValuesIn(axis4D), testing::Values(CommonTestUtils::DEVICE_CPU), testing::Values(std::map()) 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 7601c064d59..188ad9f76eb 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 @@ -1,305 +1,305 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 +//// Copyright (C) 2018-2021 Intel Corporation +//// SPDX-License-Identifier: Apache-2.0 +//// // - -#include -#include -#include -#include -#include -#include -#include -#include -#include "common_test_utils/common_utils.hpp" -#include "functional_test_utils/precision_utils.hpp" -#include "functional_test_utils/skip_tests_config.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "ie_system_conf.h" - -using namespace CPUTestUtils; -using InferenceEngine::Precision; -using ngraph::helpers::EltwiseTypes; -using FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc; - -namespace CPUSubgraphTestsDefinitions { - -typedef std::tuple< - std::pair, std::vector>>, // Input shapes - ngraph::helpers::InputLayerType, // Secondary input type - std::vector, // Input precisions - std::vector, // Eltwise operations - bool, // With quantization - std::string // Device name -> EltwiseChainTuple; - -class EltwiseChainTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj) { - std::pair, std::vector>> inputShapes; - ngraph::helpers::InputLayerType secondaryInputType; - std::vector inputPrecisions; - std::vector eltwiseOpTypes; - bool withQuantization; - std::string targetName; - std::tie(inputShapes, secondaryInputType, inputPrecisions, eltwiseOpTypes, withQuantization, targetName) = obj.param; - std::ostringstream results; - - results << "IS=" << CommonTestUtils::partialShape2str(inputShapes.first) << "_"; - results << "TS="; - for (const auto& shape : inputShapes.second) { - results << "("; - for (const auto& item : shape) { - results << CommonTestUtils::vec2str(item) << "_"; - } - results << ")_"; - } - for (int i = 0; i < inputPrecisions.size(); i++) { - results << "InPRC" << std::to_string(i) << "=" << inputPrecisions[i].name() << "_"; - } - for (int i = 0; i < eltwiseOpTypes.size(); i++) { - results << "Op" << std::to_string(i) << "=" << eltwiseOpTypes[i] << "_"; - } - results << "secondaryInputType=" << secondaryInputType << "_"; - results << "WithQuant=" << withQuantization << "_"; - results << "targetDevice=" << targetName; - - return results.str(); - } - - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override { - return FuncTestUtils::createAndFillBlob(info.getTensorDesc(), 10, 1); - } - -protected: - void SetUp() override { - threshold = 0.1f; - - std::pair, std::vector>> inputShapes; - ngraph::helpers::InputLayerType secondaryInputType; - std::vector inputPrecisions; - std::vector eltwiseOpTypes; - bool withQuantization; - std::tie(inputShapes, secondaryInputType, inputPrecisions, eltwiseOpTypes, withQuantization, targetDevice) = this->GetParam(); - - targetStaticShapes = inputShapes.second; - inputDynamicShapes = inputShapes.first; - - ngraph::ParameterVector ngraphParam; - std::vector> ngraphInputs; - if (secondaryInputType == ngraph::helpers::InputLayerType::PARAMETER) { - for (size_t i = 0; i < targetStaticShapes[0].size(); i++) { - ngraphParam.push_back(std::make_shared(convertIE2nGraphPrc(inputPrecisions[i]), targetStaticShapes[0][i])); - ngraphInputs.push_back(ngraphParam.back()); - } - } else { - ngraphParam = ngraph::builder::makeParams(convertIE2nGraphPrc(inputPrecisions[0]), {targetStaticShapes[0][0]}); - for (int i = 1; i < inputPrecisions.size(); i++) { - std::vector ngraphInput1Data(ngraph::shape_size(targetStaticShapes[0][i])); - ngraphInputs.push_back(ngraph::builder::makeConstant(convertIE2nGraphPrc(inputPrecisions[i]), targetStaticShapes[0][i], - ngraphInput1Data, true)); - } - } - - if (withQuantization) { - std::vector> eltwiseOps; - eltwiseOps.push_back(ngraph::builder::makeEltwise(ngraphParam[0], ngraphInputs[0], eltwiseOpTypes[0])); - for (int i = 1; i < eltwiseOpTypes.size() - 1; i++) { - eltwiseOps.push_back(ngraph::builder::makeEltwise(eltwiseOps[eltwiseOps.size() - 1], ngraphInputs[i], eltwiseOpTypes[i])); - } - - std::vector constShape(targetStaticShapes[0][0].size(), 1); - constShape[1] = targetStaticShapes[0][0][1]; - auto fq = ngraph::builder::makeFakeQuantize(eltwiseOps[eltwiseOps.size() - 1], - ::ngraph::element::Type(::ngraph::element::Type_t::f32), - 256, constShape); - - eltwiseOps.push_back(ngraph::builder::makeEltwise(fq, ngraphInputs[eltwiseOpTypes.size() - 1], eltwiseOpTypes[eltwiseOpTypes.size() - 1])); - - ngraph::ResultVector results{std::make_shared(eltwiseOps[eltwiseOps.size() - 1])}; - function = std::make_shared(results, ngraphParam, "eltwise_chain_fq"); - } else { - std::vector> eltwiseOps; - eltwiseOps.push_back(ngraph::builder::makeEltwise(ngraphParam[0], ngraphInputs[0], eltwiseOpTypes[0])); - for (int i = 1; i < eltwiseOpTypes.size(); i++) { - eltwiseOps.push_back(ngraph::builder::makeEltwise(eltwiseOps[eltwiseOps.size() - 1], ngraphInputs[i], eltwiseOpTypes[i])); - } - - ngraph::ResultVector results{std::make_shared(eltwiseOps[eltwiseOps.size() - 1])}; - function = std::make_shared(results, ngraphParam, "eltwise_chain"); - } - } -}; - -TEST_P(EltwiseChainTest, CompareWithRefs) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() - - Run(); -} - -namespace { - -std::vector, std::vector>>> inputShapes = { - { {}, {{{1, 1, 2, 3}, {1, 1, 2, 3}, {1, 1, 2, 3}, {1, 1, 2, 3}}}}, - { {}, {{{1, 48, 5, 6}, {1, 48, 1, 1}, {1, 48, 5, 6}, {1, 1, 5, 6}}}}, - { {}, {{{1, 72, 28, 28}, {1, 72, 1, 1}, {1, 72, 1, 1}, {1, 72, 1, 1}}}}, - { {}, {{{2, 33, 5, 5}, {2, 33, 5, 5}, {2, 33, 1, 5}, {2, 33, 5, 5}}}}, - { {}, {{{1, 2, 3}, {3}, {3}, {3}}}}, - { {}, {{{1, 12, 5, 5}, {5, 5}, {12, 5, 5}, {1}}}}, - { {}, {{{3, 12, 5, 5}, {1, 12, 5, 1}, {3, 1, 1, 1}, {3, 12, 5, 5}}}}, - { {}, {{{1, 1, 1, 1}, {1, 12, 5, 1}, {3, 12, 1, 5}, {3, 12, 5, 1}}}}, - { {}, {{{1, 1, 1, 1, 6}, {1, 12, 5, 1, 6}, {3, 12, 1, 5, 1}, {3, 12, 5, 1, 1}}}} -}; - -std::vector> inputPrecisions = { - { Precision::FP32, Precision::FP32, Precision::FP32, Precision::FP32 }, - { Precision::I32, Precision::I32, Precision::I32, Precision::I32 } -}; - -std::vector> eltwiseOps = { - { EltwiseTypes::ADD, EltwiseTypes::MULTIPLY, EltwiseTypes::SUBTRACT }, - { EltwiseTypes::DIVIDE, EltwiseTypes::SQUARED_DIFF, EltwiseTypes::ADD }, -}; - -INSTANTIATE_TEST_SUITE_P(smoke_EltwiseChain, EltwiseChainTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapes), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(eltwiseOps), - ::testing::Values(false), - ::testing::Values(CommonTestUtils::DEVICE_CPU)), - EltwiseChainTest::getTestCaseName); - -std::vector, std::vector>>> inputShapesFQ = { - { {}, {{{1, 2, 2, 3}, {1, 2, 2, 3}, {1, 2, 2, 3}, {1, 2, 2, 3}}}}, - { {}, {{{2, 33, 5, 5}, {2, 33, 5, 5}, {2, 33, 1, 5}, {2, 33, 5, 5}}}}, - { {}, {{{2, 33, 5, 17}, {2, 33, 5, 17}, {2, 33, 5, 17}, {2, 33, 5, 17}}}}, - { {}, {{{2, 33, 5, 256}, {2, 33, 5, 256}, {2, 33, 5, 256}, {2, 33, 5, 256}}}}, - { {}, {{{2, 5, 7, 5}, {2, 5, 1, 5}, {2, 5, 7, 5}, {2, 5, 7, 5}}}}, - { {}, {{{2, 17, 7, 5}, {2, 17, 7, 5}, {2, 17, 7, 5}, {2, 17, 7, 5}}}}, - { {}, {{{2, 256, 7, 5}, {2, 256, 7, 5}, {2, 256, 1, 5}, {2, 256, 7, 5}}}}, - { {}, {{{1, 36, 34, 34}, {1, 36, 34, 34}, {1, 36, 34, 34}, {1, 36, 34, 34}}}}, - { {}, {{{1, 12, 1, 1, 6}, {1, 12, 5, 1, 6}, {3, 12, 1, 5, 1}, {3, 12, 5, 1, 1}}}}, - { {}, {{{1, 12, 1, 1, 6}, {1, 12, 5, 5, 6}, {3, 12, 1, 5, 1}, {3, 12, 5, 5, 1}}}}, - { {}, {{{1, 12, 1, 1, 1}, {1, 12, 5, 1, 7}, {3, 12, 1, 5, 7}, {3, 12, 5, 1, 7}}}}, - { {}, {{{1, 7, 1, 1, 12}, {1, 7, 5, 1, 12}, {3, 7, 1, 5, 12}, {3, 7, 5, 1, 12}}}}, - { {}, {{{1, 7, 1, 1, 12, 3, 7}, {1, 7, 5, 1, 12, 3, 7}, {3, 7, 1, 5, 12, 3, 7}, {3, 7, 5, 1, 12, 3, 7}}}}, - { {}, {{{1, 7, 1, 1, 12, 3, 1}, {1, 7, 5, 1, 12, 3, 7}, {3, 7, 1, 5, 12, 1, 7}, {3, 7, 5, 1, 12, 3, 1}}}} -}; - -std::vector> inputPrecisionsFQ { - { Precision::FP32, Precision::FP32, Precision::FP32, Precision::FP32 } -}; - -INSTANTIATE_TEST_SUITE_P(smoke_EltwiseChainWithFQ, EltwiseChainTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapesFQ), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::ValuesIn(inputPrecisionsFQ), - ::testing::ValuesIn(eltwiseOps), - ::testing::Values(true), - ::testing::Values(CommonTestUtils::DEVICE_CPU)), - EltwiseChainTest::getTestCaseName); - -// =============================================== dynamic ============================================== -std::vector, std::vector>>> inputShapes_dyn = { - { - // dynamic - { - {-1, -1, -1}, - {-1}, - {-1}, - {-1} - }, - // target - { - {{1, 2, 3}, {3}, {3}, {3}}, - {{5, 2, 7}, {7}, {1}, {1}}, - {{3, 1, 10}, {1}, {1}, {1}}, - } - }, - { - // dynamic - { - {-1, -1, -1, -1}, - {-1, -1}, - {-1, -1, -1}, - {-1} - }, - // target - { - {{1, 12, 5, 5}, {5, 5}, {12, 5, 5}, {1}}, - {{5, 16, 1, 5}, {1, 5}, {1, 5, 1}, {1}}, - {{2, 1, 1, 5}, {5, 1}, {16, 5, 5}, {5}}, - } - }, - { - // dynamic - { - {-1, -1, -1, -1}, - {-1, -1, -1, -1}, - {-1, -1, -1, -1}, - {-1, -1, -1, -1} - }, - // target - { - {{1, 2, 2, 3}, {1, 2, 2, 3}, {1, 2, 2, 3}, {1, 2, 2, 3}}, - {{2, 33, 5, 5}, {2, 33, 5, 5}, {2, 33, 1, 5}, {2, 33, 5, 5}}, - {{2, 33, 5, 17}, {2, 33, 5, 17}, {2, 33, 5, 17}, {2, 33, 5, 17}}, - {{2, 33, 5, 256}, {2, 33, 5, 256}, {2, 33, 5, 256}, {2, 33, 5, 256}}, - {{2, 5, 7, 5}, {2, 5, 1, 5}, {2, 5, 7, 5}, {2, 5, 7, 5}}, - {{2, 17, 7, 5}, {2, 17, 7, 5}, {2, 17, 7, 5}, {2, 17, 7, 5}}, - {{2, 256, 7, 5}, {2, 256, 7, 5}, {2, 256, 1, 5}, {2, 256, 7, 5}}, - {{1, 36, 34, 34}, {1, 36, 34, 34}, {1, 36, 34, 34}, {1, 36, 34, 34}} - } - }, - { - // dynamic - { - {-1, -1, -1, -1, -1}, - {-1, -1, -1, -1, -1}, - {-1, -1, -1, -1, -1}, - {-1, -1, -1, -1, -1} - }, - // target - { - {{1, 12, 1, 1, 6}, {1, 12, 5, 1, 6}, {3, 12, 1, 5, 1}, {3, 12, 5, 1, 1}}, - {{1, 12, 1, 1, 6}, {1, 12, 5, 5, 6}, {3, 12, 1, 5, 1}, {3, 12, 5, 5, 1}}, - {{1, 12, 1, 1, 1}, {1, 12, 5, 1, 7}, {3, 12, 1, 5, 7}, {3, 12, 5, 1, 7}}, - {{1, 7, 1, 1, 12}, {1, 7, 5, 1, 12}, {3, 7, 1, 5, 12}, {3, 7, 5, 1, 12}} - } - }, - { - // dynamic - { - {-1, -1, -1, -1, -1, - -1, -1}, - {-1, -1, -1, -1, -1, - -1, -1}, - {-1, -1, -1, -1, -1, - -1, -1}, - {-1, -1, -1, -1, -1, - -1, -1} - }, - // target - { - {{1, 7, 1, 1, 12, 3, 7}, {1, 7, 5, 1, 12, 3, 7}, {3, 7, 1, 5, 12, 3, 7}, {3, 7, 5, 1, 12, 3, 7}}, - {{1, 7, 1, 1, 12, 3, 1}, {1, 7, 5, 1, 12, 3, 7}, {3, 7, 1, 5, 12, 1, 7}, {3, 7, 5, 1, 12, 3, 1}}, - {{5, 7, 1, 2, 12, 1, 8}, {1, 7, 5, 1, 12, 3, 8}, {5, 1, 1, 2, 12, 1, 8}, {1, 7, 5, 1, 12, 3, 1}} - } - } -}; - -INSTANTIATE_TEST_SUITE_P(smoke_EltwiseChain_dyn, EltwiseChainTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapes_dyn), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(eltwiseOps), - ::testing::Values(false), - ::testing::Values(CommonTestUtils::DEVICE_CPU)), - EltwiseChainTest::getTestCaseName); - -} // namespace -} // namespace CPUSubgraphTestsDefinitions +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include "common_test_utils/common_utils.hpp" +//#include "functional_test_utils/precision_utils.hpp" +//#include "functional_test_utils/skip_tests_config.hpp" +//#include "test_utils/cpu_test_utils.hpp" +//#include "ie_system_conf.h" +// +//using namespace CPUTestUtils; +//using InferenceEngine::Precision; +//using ngraph::helpers::EltwiseTypes; +//using FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc; +// +//namespace CPUSubgraphTestsDefinitions { +// +//typedef std::tuple< +// std::pair, std::vector>>, // Input shapes +// ngraph::helpers::InputLayerType, // Secondary input type +// std::vector, // Input precisions +// std::vector, // Eltwise operations +// bool, // With quantization +// std::string // Device name +//> EltwiseChainTuple; +// +//class EltwiseChainTest : public testing::WithParamInterface, +// virtual public LayerTestsUtils::LayerTestsCommon { +//public: +// static std::string getTestCaseName(const testing::TestParamInfo &obj) { +// std::pair, std::vector>> inputShapes; +// ngraph::helpers::InputLayerType secondaryInputType; +// std::vector inputPrecisions; +// std::vector eltwiseOpTypes; +// bool withQuantization; +// std::string targetName; +// std::tie(inputShapes, secondaryInputType, inputPrecisions, eltwiseOpTypes, withQuantization, targetName) = obj.param; +// std::ostringstream results; +// +// results << "IS=" << CommonTestUtils::partialShape2str(inputShapes.first) << "_"; +// results << "TS="; +// for (const auto& shape : inputShapes.second) { +// results << "("; +// for (const auto& item : shape) { +// results << CommonTestUtils::vec2str(item) << "_"; +// } +// results << ")_"; +// } +// for (int i = 0; i < inputPrecisions.size(); i++) { +// results << "InPRC" << std::to_string(i) << "=" << inputPrecisions[i].name() << "_"; +// } +// for (int i = 0; i < eltwiseOpTypes.size(); i++) { +// results << "Op" << std::to_string(i) << "=" << eltwiseOpTypes[i] << "_"; +// } +// results << "secondaryInputType=" << secondaryInputType << "_"; +// results << "WithQuant=" << withQuantization << "_"; +// results << "targetDevice=" << targetName; +// +// return results.str(); +// } +// +// InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override { +// return FuncTestUtils::createAndFillBlob(info.getTensorDesc(), 10, 1); +// } +// +//protected: +// void SetUp() override { +// threshold = 0.1f; +// +// std::pair, std::vector>> inputShapes; +// ngraph::helpers::InputLayerType secondaryInputType; +// std::vector inputPrecisions; +// std::vector eltwiseOpTypes; +// bool withQuantization; +// std::tie(inputShapes, secondaryInputType, inputPrecisions, eltwiseOpTypes, withQuantization, targetDevice) = this->GetParam(); +// +// targetStaticShapes = inputShapes.second; +// inputDynamicShapes = inputShapes.first; +// +// ngraph::ParameterVector ngraphParam; +// std::vector> ngraphInputs; +// if (secondaryInputType == ngraph::helpers::InputLayerType::PARAMETER) { +// for (size_t i = 0; i < targetStaticShapes[0].size(); i++) { +// ngraphParam.push_back(std::make_shared(convertIE2nGraphPrc(inputPrecisions[i]), targetStaticShapes[0][i])); +// ngraphInputs.push_back(ngraphParam.back()); +// } +// } else { +// ngraphParam = ngraph::builder::makeParams(convertIE2nGraphPrc(inputPrecisions[0]), {targetStaticShapes[0][0]}); +// for (int i = 1; i < inputPrecisions.size(); i++) { +// std::vector ngraphInput1Data(ngraph::shape_size(targetStaticShapes[0][i])); +// ngraphInputs.push_back(ngraph::builder::makeConstant(convertIE2nGraphPrc(inputPrecisions[i]), targetStaticShapes[0][i], +// ngraphInput1Data, true)); +// } +// } +// +// if (withQuantization) { +// std::vector> eltwiseOps; +// eltwiseOps.push_back(ngraph::builder::makeEltwise(ngraphParam[0], ngraphInputs[0], eltwiseOpTypes[0])); +// for (int i = 1; i < eltwiseOpTypes.size() - 1; i++) { +// eltwiseOps.push_back(ngraph::builder::makeEltwise(eltwiseOps[eltwiseOps.size() - 1], ngraphInputs[i], eltwiseOpTypes[i])); +// } +// +// std::vector constShape(targetStaticShapes[0][0].size(), 1); +// constShape[1] = targetStaticShapes[0][0][1]; +// auto fq = ngraph::builder::makeFakeQuantize(eltwiseOps[eltwiseOps.size() - 1], +// ::ngraph::element::Type(::ngraph::element::Type_t::f32), +// 256, constShape); +// +// eltwiseOps.push_back(ngraph::builder::makeEltwise(fq, ngraphInputs[eltwiseOpTypes.size() - 1], eltwiseOpTypes[eltwiseOpTypes.size() - 1])); +// +// ngraph::ResultVector results{std::make_shared(eltwiseOps[eltwiseOps.size() - 1])}; +// function = std::make_shared(results, ngraphParam, "eltwise_chain_fq"); +// } else { +// std::vector> eltwiseOps; +// eltwiseOps.push_back(ngraph::builder::makeEltwise(ngraphParam[0], ngraphInputs[0], eltwiseOpTypes[0])); +// for (int i = 1; i < eltwiseOpTypes.size(); i++) { +// eltwiseOps.push_back(ngraph::builder::makeEltwise(eltwiseOps[eltwiseOps.size() - 1], ngraphInputs[i], eltwiseOpTypes[i])); +// } +// +// ngraph::ResultVector results{std::make_shared(eltwiseOps[eltwiseOps.size() - 1])}; +// function = std::make_shared(results, ngraphParam, "eltwise_chain"); +// } +// } +//}; +// +//TEST_P(EltwiseChainTest, CompareWithRefs) { +// SKIP_IF_CURRENT_TEST_IS_DISABLED() +// +// Run(); +//} +// +//namespace { +// +//std::vector, std::vector>>> inputShapes = { +// { {}, {{{1, 1, 2, 3}, {1, 1, 2, 3}, {1, 1, 2, 3}, {1, 1, 2, 3}}}}, +// { {}, {{{1, 48, 5, 6}, {1, 48, 1, 1}, {1, 48, 5, 6}, {1, 1, 5, 6}}}}, +// { {}, {{{1, 72, 28, 28}, {1, 72, 1, 1}, {1, 72, 1, 1}, {1, 72, 1, 1}}}}, +// { {}, {{{2, 33, 5, 5}, {2, 33, 5, 5}, {2, 33, 1, 5}, {2, 33, 5, 5}}}}, +// { {}, {{{1, 2, 3}, {3}, {3}, {3}}}}, +// { {}, {{{1, 12, 5, 5}, {5, 5}, {12, 5, 5}, {1}}}}, +// { {}, {{{3, 12, 5, 5}, {1, 12, 5, 1}, {3, 1, 1, 1}, {3, 12, 5, 5}}}}, +// { {}, {{{1, 1, 1, 1}, {1, 12, 5, 1}, {3, 12, 1, 5}, {3, 12, 5, 1}}}}, +// { {}, {{{1, 1, 1, 1, 6}, {1, 12, 5, 1, 6}, {3, 12, 1, 5, 1}, {3, 12, 5, 1, 1}}}} +//}; +// +//std::vector> inputPrecisions = { +// { Precision::FP32, Precision::FP32, Precision::FP32, Precision::FP32 }, +// { Precision::I32, Precision::I32, Precision::I32, Precision::I32 } +//}; +// +//std::vector> eltwiseOps = { +// { EltwiseTypes::ADD, EltwiseTypes::MULTIPLY, EltwiseTypes::SUBTRACT }, +// { EltwiseTypes::DIVIDE, EltwiseTypes::SQUARED_DIFF, EltwiseTypes::ADD }, +//}; +// +//INSTANTIATE_TEST_SUITE_P(smoke_EltwiseChain, EltwiseChainTest, +// ::testing::Combine( +// ::testing::ValuesIn(inputShapes), +// ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), +// ::testing::ValuesIn(inputPrecisions), +// ::testing::ValuesIn(eltwiseOps), +// ::testing::Values(false), +// ::testing::Values(CommonTestUtils::DEVICE_CPU)), +// EltwiseChainTest::getTestCaseName); +// +//std::vector, std::vector>>> inputShapesFQ = { +// { {}, {{{1, 2, 2, 3}, {1, 2, 2, 3}, {1, 2, 2, 3}, {1, 2, 2, 3}}}}, +// { {}, {{{2, 33, 5, 5}, {2, 33, 5, 5}, {2, 33, 1, 5}, {2, 33, 5, 5}}}}, +// { {}, {{{2, 33, 5, 17}, {2, 33, 5, 17}, {2, 33, 5, 17}, {2, 33, 5, 17}}}}, +// { {}, {{{2, 33, 5, 256}, {2, 33, 5, 256}, {2, 33, 5, 256}, {2, 33, 5, 256}}}}, +// { {}, {{{2, 5, 7, 5}, {2, 5, 1, 5}, {2, 5, 7, 5}, {2, 5, 7, 5}}}}, +// { {}, {{{2, 17, 7, 5}, {2, 17, 7, 5}, {2, 17, 7, 5}, {2, 17, 7, 5}}}}, +// { {}, {{{2, 256, 7, 5}, {2, 256, 7, 5}, {2, 256, 1, 5}, {2, 256, 7, 5}}}}, +// { {}, {{{1, 36, 34, 34}, {1, 36, 34, 34}, {1, 36, 34, 34}, {1, 36, 34, 34}}}}, +// { {}, {{{1, 12, 1, 1, 6}, {1, 12, 5, 1, 6}, {3, 12, 1, 5, 1}, {3, 12, 5, 1, 1}}}}, +// { {}, {{{1, 12, 1, 1, 6}, {1, 12, 5, 5, 6}, {3, 12, 1, 5, 1}, {3, 12, 5, 5, 1}}}}, +// { {}, {{{1, 12, 1, 1, 1}, {1, 12, 5, 1, 7}, {3, 12, 1, 5, 7}, {3, 12, 5, 1, 7}}}}, +// { {}, {{{1, 7, 1, 1, 12}, {1, 7, 5, 1, 12}, {3, 7, 1, 5, 12}, {3, 7, 5, 1, 12}}}}, +// { {}, {{{1, 7, 1, 1, 12, 3, 7}, {1, 7, 5, 1, 12, 3, 7}, {3, 7, 1, 5, 12, 3, 7}, {3, 7, 5, 1, 12, 3, 7}}}}, +// { {}, {{{1, 7, 1, 1, 12, 3, 1}, {1, 7, 5, 1, 12, 3, 7}, {3, 7, 1, 5, 12, 1, 7}, {3, 7, 5, 1, 12, 3, 1}}}} +//}; +// +//std::vector> inputPrecisionsFQ { +// { Precision::FP32, Precision::FP32, Precision::FP32, Precision::FP32 } +//}; +// +//INSTANTIATE_TEST_SUITE_P(smoke_EltwiseChainWithFQ, EltwiseChainTest, +// ::testing::Combine( +// ::testing::ValuesIn(inputShapesFQ), +// ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), +// ::testing::ValuesIn(inputPrecisionsFQ), +// ::testing::ValuesIn(eltwiseOps), +// ::testing::Values(true), +// ::testing::Values(CommonTestUtils::DEVICE_CPU)), +// EltwiseChainTest::getTestCaseName); +// +//// =============================================== dynamic ============================================== +//std::vector, std::vector>>> inputShapes_dyn = { +// { +// // dynamic +// { +// {-1, -1, -1}, +// {-1}, +// {-1}, +// {-1} +// }, +// // target +// { +// {{1, 2, 3}, {3}, {3}, {3}}, +// {{5, 2, 7}, {7}, {1}, {1}}, +// {{3, 1, 10}, {1}, {1}, {1}}, +// } +// }, +// { +// // dynamic +// { +// {-1, -1, -1, -1}, +// {-1, -1}, +// {-1, -1, -1}, +// {-1} +// }, +// // target +// { +// {{1, 12, 5, 5}, {5, 5}, {12, 5, 5}, {1}}, +// {{5, 16, 1, 5}, {1, 5}, {1, 5, 1}, {1}}, +// {{2, 1, 1, 5}, {5, 1}, {16, 5, 5}, {5}}, +// } +// }, +// { +// // dynamic +// { +// {-1, -1, -1, -1}, +// {-1, -1, -1, -1}, +// {-1, -1, -1, -1}, +// {-1, -1, -1, -1} +// }, +// // target +// { +// {{1, 2, 2, 3}, {1, 2, 2, 3}, {1, 2, 2, 3}, {1, 2, 2, 3}}, +// {{2, 33, 5, 5}, {2, 33, 5, 5}, {2, 33, 1, 5}, {2, 33, 5, 5}}, +// {{2, 33, 5, 17}, {2, 33, 5, 17}, {2, 33, 5, 17}, {2, 33, 5, 17}}, +// {{2, 33, 5, 256}, {2, 33, 5, 256}, {2, 33, 5, 256}, {2, 33, 5, 256}}, +// {{2, 5, 7, 5}, {2, 5, 1, 5}, {2, 5, 7, 5}, {2, 5, 7, 5}}, +// {{2, 17, 7, 5}, {2, 17, 7, 5}, {2, 17, 7, 5}, {2, 17, 7, 5}}, +// {{2, 256, 7, 5}, {2, 256, 7, 5}, {2, 256, 1, 5}, {2, 256, 7, 5}}, +// {{1, 36, 34, 34}, {1, 36, 34, 34}, {1, 36, 34, 34}, {1, 36, 34, 34}} +// } +// }, +// { +// // dynamic +// { +// {-1, -1, -1, -1, -1}, +// {-1, -1, -1, -1, -1}, +// {-1, -1, -1, -1, -1}, +// {-1, -1, -1, -1, -1} +// }, +// // target +// { +// {{1, 12, 1, 1, 6}, {1, 12, 5, 1, 6}, {3, 12, 1, 5, 1}, {3, 12, 5, 1, 1}}, +// {{1, 12, 1, 1, 6}, {1, 12, 5, 5, 6}, {3, 12, 1, 5, 1}, {3, 12, 5, 5, 1}}, +// {{1, 12, 1, 1, 1}, {1, 12, 5, 1, 7}, {3, 12, 1, 5, 7}, {3, 12, 5, 1, 7}}, +// {{1, 7, 1, 1, 12}, {1, 7, 5, 1, 12}, {3, 7, 1, 5, 12}, {3, 7, 5, 1, 12}} +// } +// }, +// { +// // dynamic +// { +// {-1, -1, -1, -1, -1, +// -1, -1}, +// {-1, -1, -1, -1, -1, +// -1, -1}, +// {-1, -1, -1, -1, -1, +// -1, -1}, +// {-1, -1, -1, -1, -1, +// -1, -1} +// }, +// // target +// { +// {{1, 7, 1, 1, 12, 3, 7}, {1, 7, 5, 1, 12, 3, 7}, {3, 7, 1, 5, 12, 3, 7}, {3, 7, 5, 1, 12, 3, 7}}, +// {{1, 7, 1, 1, 12, 3, 1}, {1, 7, 5, 1, 12, 3, 7}, {3, 7, 1, 5, 12, 1, 7}, {3, 7, 5, 1, 12, 3, 1}}, +// {{5, 7, 1, 2, 12, 1, 8}, {1, 7, 5, 1, 12, 3, 8}, {5, 1, 1, 2, 12, 1, 8}, {1, 7, 5, 1, 12, 3, 1}} +// } +// } +//}; +// +//INSTANTIATE_TEST_SUITE_P(smoke_EltwiseChain_dyn, EltwiseChainTest, +// ::testing::Combine( +// ::testing::ValuesIn(inputShapes_dyn), +// ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), +// ::testing::ValuesIn(inputPrecisions), +// ::testing::ValuesIn(eltwiseOps), +// ::testing::Values(false), +// ::testing::Values(CommonTestUtils::DEVICE_CPU)), +// EltwiseChainTest::getTestCaseName); +// +//} // namespace +//} // namespace CPUSubgraphTestsDefinitions diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/ov_subgraph.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/ov_subgraph.hpp index 6fcaeabf0a6..e17b2b623aa 100644 --- a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/ov_subgraph.hpp +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/ov_subgraph.hpp @@ -14,7 +14,6 @@ namespace ov { namespace test { using InputShape = std::pair>; -using InputShapes = std::pair, std::vector>>; using ElementType = ov::element::Type_t; using Config = std::map; using TargetDevice = std::string; @@ -41,10 +40,7 @@ protected: virtual void infer(); virtual void validate(); - void init_input_shapes(const InputShapes& shapes); - void init_input_shapes(const InputShape& shapes); -// void propagate_shape_to_all_inputs(bool proragate_first_shape = true, -// const InputShape& targetShape = InputShape()); + void init_input_shapes(const std::vector& shapes); std::shared_ptr core = ov::test::utils::PluginCache::get().core(); std::string targetDevice; @@ -68,28 +64,21 @@ private: std::vector get_plugin_outputs(); }; -//inline std::vector> static_shapes_to_test_representation(const std::vector>& shapes) { -// std::vector> result; -// for (const auto& staticShapes : shapes) { -// std::vector tmp; -// for (const auto& staticShape : staticShapes) { -// tmp.push_back({{}, {staticShape}}); -// } -// result.push_back(tmp); -// } -// return result; -//} -inline std::vector static_shapes_to_test_representation(const std::vector& staticShapes) { - std::vector result; - for (const auto& staticShape : staticShapes) { - result.push_back({{}, {staticShape}}); +inline std::vector> static_shapes_to_test_representation(const std::vector>& shapes) { + std::vector> result; + for (const auto& staticShapes : shapes) { + std::vector tmp; + for (const auto& staticShape : staticShapes) { + tmp.push_back({{}, {staticShape}}); + } + result.push_back(tmp); } return result; } -inline std::vector static_shapes_to_test_representation(const std::vector>& staticShapes) { - std::vector result; - for (const auto& staticShape : staticShapes) { +inline std::vector static_shapes_to_test_representation(const std::vector& shapes) { + std::vector result; + for (const auto& staticShape : shapes) { result.push_back({{}, {staticShape}}); } return result; diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/eltwise.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/eltwise.hpp index 91fd76052ab..dd997f3c6ec 100644 --- a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/eltwise.hpp +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/eltwise.hpp @@ -12,7 +12,7 @@ namespace test { namespace subgraph { typedef std::tuple< - InputShapes, // input shapes + std::vector, // input shapes ngraph::helpers::EltwiseTypes, // eltwise op type ngraph::helpers::InputLayerType, // secondary input type CommonTestUtils::OpType, // op type diff --git a/inference-engine/tests/functional/shared_test_classes/src/base/ov_subgraph.cpp b/inference-engine/tests/functional/shared_test_classes/src/base/ov_subgraph.cpp index 7672a39f9bd..0629ebe95ea 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/base/ov_subgraph.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/base/ov_subgraph.cpp @@ -179,31 +179,21 @@ void SubgraphBaseTest::validate() { compare(expectedOutputs, actualOutputs); } -void SubgraphBaseTest::init_input_shapes(const InputShapes& shapes) { - targetStaticShapes = shapes.second; - if (!shapes.first.empty()) { - inputDynamicShapes = shapes.first; - } else { - OPENVINO_ASSERT(targetStaticShapes.size() == 1, "Incorrect size of targetStaticShapes for static scenario"); - for (const auto& targetStaticShape : targetStaticShapes.front()) { - inputDynamicShapes.emplace_back(targetStaticShape); +void SubgraphBaseTest::init_input_shapes(const std::vector& shapes) { + size_t targetStaticShapeSize = shapes.front().second.size(); + targetStaticShapes.resize(targetStaticShapeSize); + for (const auto& shape : shapes) { + auto dynShape = shape.first; + if (dynShape.rank() == 0) { + ASSERT_EQ(targetStaticShapeSize, 1) << "Incorrect number of static shapes for static case"; + dynShape = shape.second.front(); + } + inputDynamicShapes.push_back(dynShape); + ASSERT_EQ(shape.second.size(), targetStaticShapeSize) << "Target static count shapes should be the same for all inputs"; + for (size_t i = 0; i < shape.second.size(); ++i) { + targetStaticShapes[i].push_back(shape.second.at(i)); } } } - -void SubgraphBaseTest::init_input_shapes(const InputShape& shapes) { - std::pair, std::vector>> tmpShapeObj; - if (shapes.first.rank() != 0) { - tmpShapeObj.first = {shapes.first}; - for (const auto& staticShape : shapes.second) { - tmpShapeObj.second.push_back({staticShape}); - } - } else { - tmpShapeObj.first = {}; - tmpShapeObj.second = {shapes.second}; - } - init_input_shapes(tmpShapeObj); -} - } // namespace test } // namespace ov \ No newline at end of file diff --git a/inference-engine/tests/functional/shared_test_classes/src/single_layer/eltwise.cpp b/inference-engine/tests/functional/shared_test_classes/src/single_layer/eltwise.cpp index 73811102efe..4b55e002674 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/single_layer/eltwise.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/single_layer/eltwise.cpp @@ -11,7 +11,7 @@ namespace test { namespace subgraph { std::string EltwiseLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - std::pair, std::vector>> shapes; + std::vector shapes; ElementType netType; ngraph::helpers::InputLayerType secondaryInputType; CommonTestUtils::OpType opType; @@ -21,16 +21,17 @@ std::string EltwiseLayerTest::getTestCaseName(const testing::TestParamInfo shapes; ElementType netType; ngraph::helpers::InputLayerType secondaryInputType; CommonTestUtils::OpType opType; @@ -114,7 +118,7 @@ void EltwiseLayerTest::SetUp() { FAIL() << "Unsupported Secondary operation type"; } // To propagate shape_input_secondary just in static case because all shapes are defined in dynamic scenarion - if (shape_input_secondary.is_static()) { + if (secondaryInputType == ngraph::helpers::InputLayerType::PARAMETER) { transformInputShapesAccordingEltwise(shape_input_secondary); } diff --git a/inference-engine/tests/functional/shared_test_classes/src/single_layer/softmax.cpp b/inference-engine/tests/functional/shared_test_classes/src/single_layer/softmax.cpp index 2ec344827de..59df1a2d762 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/single_layer/softmax.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/single_layer/softmax.cpp @@ -39,7 +39,7 @@ void SoftMaxLayerTest::SetUp() { size_t axis; std::tie(ngPrc, shapes, axis, targetDevice, configuration) = GetParam(); - init_input_shapes(shapes); + init_input_shapes({shapes}); const auto params = ngraph::builder::makeDynamicParams(ngPrc, inputDynamicShapes); const auto paramOuts =