Apply Maxim's comments

This commit is contained in:
Efode, Irina 2021-10-20 14:42:55 +03:00
parent 230a1298b8
commit 75440ce241
8 changed files with 350 additions and 367 deletions

View File

@ -25,9 +25,9 @@ std::vector<std::vector<ov::Shape>> inShapesStatic = {
{{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<ov::test::InputShapes> inShapesDynamic = { std::vector<std::vector<ov::test::InputShape>> inShapesDynamic = {
{{{ngraph::Dimension(1, 10), 200}, {ngraph::Dimension(1, 10), 200}}, {{{ngraph::Dimension(1, 10), 200}, {{2, 200}, {1, 200}}}},
{{{2, 200}, {2, 200}}, {{1, 200}, {5, 200}}}}, {{{ngraph::Dimension(1, 10), 200}, {{2, 200}, {5, 200}}}},
}; };
std::vector<ov::test::ElementType> netPrecisions = { std::vector<ov::test::ElementType> netPrecisions = {

View File

@ -34,7 +34,7 @@ const std::vector<size_t> axis2D = {
const auto params2D_static = testing::Combine( const auto params2D_static = testing::Combine(
testing::ValuesIn(netPrecisions), 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::ValuesIn(axis2D),
testing::Values(CommonTestUtils::DEVICE_CPU), testing::Values(CommonTestUtils::DEVICE_CPU),
testing::Values(std::map<std::string, std::string>()) testing::Values(std::map<std::string, std::string>())
@ -78,7 +78,7 @@ const std::vector<size_t> axis4D = {0, 1, 2, 3};
const auto params4Dstatic = testing::Combine( const auto params4Dstatic = testing::Combine(
testing::ValuesIn(netPrecisions), 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::ValuesIn(axis4D),
testing::Values(CommonTestUtils::DEVICE_CPU), testing::Values(CommonTestUtils::DEVICE_CPU),
testing::Values(std::map<std::string, std::string>()) testing::Values(std::map<std::string, std::string>())

View File

@ -1,305 +1,305 @@
// Copyright (C) 2018-2021 Intel Corporation //// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0 //// SPDX-License-Identifier: Apache-2.0
////
// //
//#include <tuple>
#include <tuple> //#include <string>
#include <string> //#include <vector>
#include <vector> //#include <memory>
#include <memory> //#include <debug.h>
#include <debug.h> //#include <shared_test_classes/base/layer_test_utils.hpp>
#include <shared_test_classes/base/layer_test_utils.hpp> //#include <ngraph_functions/builders.hpp>
#include <ngraph_functions/builders.hpp> //#include <ie_precision.hpp>
#include <ie_precision.hpp> //#include "common_test_utils/common_utils.hpp"
#include "common_test_utils/common_utils.hpp" //#include "functional_test_utils/precision_utils.hpp"
#include "functional_test_utils/precision_utils.hpp" //#include "functional_test_utils/skip_tests_config.hpp"
#include "functional_test_utils/skip_tests_config.hpp" //#include "test_utils/cpu_test_utils.hpp"
#include "test_utils/cpu_test_utils.hpp" //#include "ie_system_conf.h"
#include "ie_system_conf.h" //
//using namespace CPUTestUtils;
using namespace CPUTestUtils; //using InferenceEngine::Precision;
using InferenceEngine::Precision; //using ngraph::helpers::EltwiseTypes;
using ngraph::helpers::EltwiseTypes; //using FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc;
using FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc; //
//namespace CPUSubgraphTestsDefinitions {
namespace CPUSubgraphTestsDefinitions { //
//typedef std::tuple<
typedef std::tuple< // std::pair<std::vector<ngraph::PartialShape>, std::vector<std::vector<ngraph::Shape>>>, // Input shapes
std::pair<std::vector<ngraph::PartialShape>, std::vector<std::vector<ngraph::Shape>>>, // Input shapes // ngraph::helpers::InputLayerType, // Secondary input type
ngraph::helpers::InputLayerType, // Secondary input type // std::vector<InferenceEngine::Precision>, // Input precisions
std::vector<InferenceEngine::Precision>, // Input precisions // std::vector<EltwiseTypes>, // Eltwise operations
std::vector<EltwiseTypes>, // Eltwise operations // bool, // With quantization
bool, // With quantization // std::string // Device name
std::string // Device name //> EltwiseChainTuple;
> EltwiseChainTuple; //
//class EltwiseChainTest : public testing::WithParamInterface<EltwiseChainTuple>,
class EltwiseChainTest : public testing::WithParamInterface<EltwiseChainTuple>, // virtual public LayerTestsUtils::LayerTestsCommon {
virtual public LayerTestsUtils::LayerTestsCommon { //public:
public: // static std::string getTestCaseName(const testing::TestParamInfo<EltwiseChainTuple> &obj) {
static std::string getTestCaseName(const testing::TestParamInfo<EltwiseChainTuple> &obj) { // std::pair<std::vector<ngraph::PartialShape>, std::vector<std::vector<ngraph::Shape>>> inputShapes;
std::pair<std::vector<ngraph::PartialShape>, std::vector<std::vector<ngraph::Shape>>> inputShapes; // ngraph::helpers::InputLayerType secondaryInputType;
ngraph::helpers::InputLayerType secondaryInputType; // std::vector<InferenceEngine::Precision> inputPrecisions;
std::vector<InferenceEngine::Precision> inputPrecisions; // std::vector<EltwiseTypes> eltwiseOpTypes;
std::vector<EltwiseTypes> eltwiseOpTypes; // bool withQuantization;
bool withQuantization; // std::string targetName;
std::string targetName; // std::tie(inputShapes, secondaryInputType, inputPrecisions, eltwiseOpTypes, withQuantization, targetName) = obj.param;
std::tie(inputShapes, secondaryInputType, inputPrecisions, eltwiseOpTypes, withQuantization, targetName) = obj.param; // std::ostringstream results;
std::ostringstream results; //
// results << "IS=" << CommonTestUtils::partialShape2str(inputShapes.first) << "_";
results << "IS=" << CommonTestUtils::partialShape2str(inputShapes.first) << "_"; // results << "TS=";
results << "TS="; // for (const auto& shape : inputShapes.second) {
for (const auto& shape : inputShapes.second) { // results << "(";
results << "("; // for (const auto& item : shape) {
for (const auto& item : shape) { // results << CommonTestUtils::vec2str(item) << "_";
results << CommonTestUtils::vec2str(item) << "_"; // }
} // results << ")_";
results << ")_"; // }
} // for (int i = 0; i < inputPrecisions.size(); i++) {
for (int i = 0; i < inputPrecisions.size(); i++) { // results << "InPRC" << std::to_string(i) << "=" << inputPrecisions[i].name() << "_";
results << "InPRC" << std::to_string(i) << "=" << inputPrecisions[i].name() << "_"; // }
} // for (int i = 0; i < eltwiseOpTypes.size(); i++) {
for (int i = 0; i < eltwiseOpTypes.size(); i++) { // results << "Op" << std::to_string(i) << "=" << eltwiseOpTypes[i] << "_";
results << "Op" << std::to_string(i) << "=" << eltwiseOpTypes[i] << "_"; // }
} // results << "secondaryInputType=" << secondaryInputType << "_";
results << "secondaryInputType=" << secondaryInputType << "_"; // results << "WithQuant=" << withQuantization << "_";
results << "WithQuant=" << withQuantization << "_"; // results << "targetDevice=" << targetName;
results << "targetDevice=" << targetName; //
// return results.str();
return results.str(); // }
} //
// InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override {
InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override { // return FuncTestUtils::createAndFillBlob(info.getTensorDesc(), 10, 1);
return FuncTestUtils::createAndFillBlob(info.getTensorDesc(), 10, 1); // }
} //
//protected:
protected: // void SetUp() override {
void SetUp() override { // threshold = 0.1f;
threshold = 0.1f; //
// std::pair<std::vector<ngraph::PartialShape>, std::vector<std::vector<ngraph::Shape>>> inputShapes;
std::pair<std::vector<ngraph::PartialShape>, std::vector<std::vector<ngraph::Shape>>> inputShapes; // ngraph::helpers::InputLayerType secondaryInputType;
ngraph::helpers::InputLayerType secondaryInputType; // std::vector<InferenceEngine::Precision> inputPrecisions;
std::vector<InferenceEngine::Precision> inputPrecisions; // std::vector<EltwiseTypes> eltwiseOpTypes;
std::vector<EltwiseTypes> eltwiseOpTypes; // bool withQuantization;
bool withQuantization; // std::tie(inputShapes, secondaryInputType, inputPrecisions, eltwiseOpTypes, withQuantization, targetDevice) = this->GetParam();
std::tie(inputShapes, secondaryInputType, inputPrecisions, eltwiseOpTypes, withQuantization, targetDevice) = this->GetParam(); //
// targetStaticShapes = inputShapes.second;
targetStaticShapes = inputShapes.second; // inputDynamicShapes = inputShapes.first;
inputDynamicShapes = inputShapes.first; //
// ngraph::ParameterVector ngraphParam;
ngraph::ParameterVector ngraphParam; // std::vector<std::shared_ptr<ngraph::Node>> ngraphInputs;
std::vector<std::shared_ptr<ngraph::Node>> ngraphInputs; // if (secondaryInputType == ngraph::helpers::InputLayerType::PARAMETER) {
if (secondaryInputType == ngraph::helpers::InputLayerType::PARAMETER) { // for (size_t i = 0; i < targetStaticShapes[0].size(); i++) {
for (size_t i = 0; i < targetStaticShapes[0].size(); i++) { // ngraphParam.push_back(std::make_shared<ngraph::opset1::Parameter>(convertIE2nGraphPrc(inputPrecisions[i]), targetStaticShapes[0][i]));
ngraphParam.push_back(std::make_shared<ngraph::opset1::Parameter>(convertIE2nGraphPrc(inputPrecisions[i]), targetStaticShapes[0][i])); // ngraphInputs.push_back(ngraphParam.back());
ngraphInputs.push_back(ngraphParam.back()); // }
} // } else {
} else { // ngraphParam = ngraph::builder::makeParams(convertIE2nGraphPrc(inputPrecisions[0]), {targetStaticShapes[0][0]});
ngraphParam = ngraph::builder::makeParams(convertIE2nGraphPrc(inputPrecisions[0]), {targetStaticShapes[0][0]}); // for (int i = 1; i < inputPrecisions.size(); i++) {
for (int i = 1; i < inputPrecisions.size(); i++) { // std::vector<float> ngraphInput1Data(ngraph::shape_size(targetStaticShapes[0][i]));
std::vector<float> ngraphInput1Data(ngraph::shape_size(targetStaticShapes[0][i])); // ngraphInputs.push_back(ngraph::builder::makeConstant(convertIE2nGraphPrc(inputPrecisions[i]), targetStaticShapes[0][i],
ngraphInputs.push_back(ngraph::builder::makeConstant(convertIE2nGraphPrc(inputPrecisions[i]), targetStaticShapes[0][i], // ngraphInput1Data, true));
ngraphInput1Data, true)); // }
} // }
} //
// if (withQuantization) {
if (withQuantization) { // std::vector<std::shared_ptr<ngraph::Node>> eltwiseOps;
std::vector<std::shared_ptr<ngraph::Node>> eltwiseOps; // eltwiseOps.push_back(ngraph::builder::makeEltwise(ngraphParam[0], ngraphInputs[0], eltwiseOpTypes[0]));
eltwiseOps.push_back(ngraph::builder::makeEltwise(ngraphParam[0], ngraphInputs[0], eltwiseOpTypes[0])); // for (int i = 1; i < eltwiseOpTypes.size() - 1; i++) {
for (int i = 1; i < eltwiseOpTypes.size() - 1; i++) { // eltwiseOps.push_back(ngraph::builder::makeEltwise(eltwiseOps[eltwiseOps.size() - 1], ngraphInputs[i], eltwiseOpTypes[i]));
eltwiseOps.push_back(ngraph::builder::makeEltwise(eltwiseOps[eltwiseOps.size() - 1], ngraphInputs[i], eltwiseOpTypes[i])); // }
} //
// std::vector<size_t> constShape(targetStaticShapes[0][0].size(), 1);
std::vector<size_t> constShape(targetStaticShapes[0][0].size(), 1); // constShape[1] = targetStaticShapes[0][0][1];
constShape[1] = targetStaticShapes[0][0][1]; // auto fq = ngraph::builder::makeFakeQuantize(eltwiseOps[eltwiseOps.size() - 1],
auto fq = ngraph::builder::makeFakeQuantize(eltwiseOps[eltwiseOps.size() - 1], // ::ngraph::element::Type(::ngraph::element::Type_t::f32),
::ngraph::element::Type(::ngraph::element::Type_t::f32), // 256, constShape);
256, constShape); //
// eltwiseOps.push_back(ngraph::builder::makeEltwise(fq, ngraphInputs[eltwiseOpTypes.size() - 1], eltwiseOpTypes[eltwiseOpTypes.size() - 1]));
eltwiseOps.push_back(ngraph::builder::makeEltwise(fq, ngraphInputs[eltwiseOpTypes.size() - 1], eltwiseOpTypes[eltwiseOpTypes.size() - 1])); //
// ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(eltwiseOps[eltwiseOps.size() - 1])};
ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(eltwiseOps[eltwiseOps.size() - 1])}; // function = std::make_shared<ngraph::Function>(results, ngraphParam, "eltwise_chain_fq");
function = std::make_shared<ngraph::Function>(results, ngraphParam, "eltwise_chain_fq"); // } else {
} else { // std::vector<std::shared_ptr<ngraph::Node>> eltwiseOps;
std::vector<std::shared_ptr<ngraph::Node>> eltwiseOps; // eltwiseOps.push_back(ngraph::builder::makeEltwise(ngraphParam[0], ngraphInputs[0], eltwiseOpTypes[0]));
eltwiseOps.push_back(ngraph::builder::makeEltwise(ngraphParam[0], ngraphInputs[0], eltwiseOpTypes[0])); // for (int i = 1; i < eltwiseOpTypes.size(); i++) {
for (int i = 1; i < eltwiseOpTypes.size(); i++) { // eltwiseOps.push_back(ngraph::builder::makeEltwise(eltwiseOps[eltwiseOps.size() - 1], ngraphInputs[i], eltwiseOpTypes[i]));
eltwiseOps.push_back(ngraph::builder::makeEltwise(eltwiseOps[eltwiseOps.size() - 1], ngraphInputs[i], eltwiseOpTypes[i])); // }
} //
// ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(eltwiseOps[eltwiseOps.size() - 1])};
ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(eltwiseOps[eltwiseOps.size() - 1])}; // function = std::make_shared<ngraph::Function>(results, ngraphParam, "eltwise_chain");
function = std::make_shared<ngraph::Function>(results, ngraphParam, "eltwise_chain"); // }
} // }
} //};
}; //
//TEST_P(EltwiseChainTest, CompareWithRefs) {
TEST_P(EltwiseChainTest, CompareWithRefs) { // SKIP_IF_CURRENT_TEST_IS_DISABLED()
SKIP_IF_CURRENT_TEST_IS_DISABLED() //
// Run();
Run(); //}
} //
//namespace {
namespace { //
//std::vector<std::pair<std::vector<ngraph::PartialShape>, std::vector<std::vector<ngraph::Shape>>>> inputShapes = {
std::vector<std::pair<std::vector<ngraph::PartialShape>, std::vector<std::vector<ngraph::Shape>>>> inputShapes = { // { {}, {{{1, 1, 2, 3}, {1, 1, 2, 3}, {1, 1, 2, 3}, {1, 1, 2, 3}}}},
{ {}, {{{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, 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}}}},
{ {}, {{{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}}}},
{ {}, {{{2, 33, 5, 5}, {2, 33, 5, 5}, {2, 33, 1, 5}, {2, 33, 5, 5}}}}, // { {}, {{{1, 2, 3}, {3}, {3}, {3}}}},
{ {}, {{{1, 2, 3}, {3}, {3}, {3}}}}, // { {}, {{{1, 12, 5, 5}, {5, 5}, {12, 5, 5}, {1}}}},
{ {}, {{{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}}}},
{ {}, {{{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}, {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}}}}
{ {}, {{{1, 1, 1, 1, 6}, {1, 12, 5, 1, 6}, {3, 12, 1, 5, 1}, {3, 12, 5, 1, 1}}}} //};
}; //
//std::vector<std::vector<InferenceEngine::Precision>> inputPrecisions = {
std::vector<std::vector<InferenceEngine::Precision>> inputPrecisions = { // { Precision::FP32, Precision::FP32, Precision::FP32, Precision::FP32 },
{ Precision::FP32, Precision::FP32, Precision::FP32, Precision::FP32 }, // { Precision::I32, Precision::I32, Precision::I32, Precision::I32 }
{ Precision::I32, Precision::I32, Precision::I32, Precision::I32 } //};
}; //
//std::vector<std::vector<EltwiseTypes>> eltwiseOps = {
std::vector<std::vector<EltwiseTypes>> eltwiseOps = { // { EltwiseTypes::ADD, EltwiseTypes::MULTIPLY, EltwiseTypes::SUBTRACT },
{ EltwiseTypes::ADD, EltwiseTypes::MULTIPLY, EltwiseTypes::SUBTRACT }, // { EltwiseTypes::DIVIDE, EltwiseTypes::SQUARED_DIFF, EltwiseTypes::ADD },
{ EltwiseTypes::DIVIDE, EltwiseTypes::SQUARED_DIFF, EltwiseTypes::ADD }, //};
}; //
//INSTANTIATE_TEST_SUITE_P(smoke_EltwiseChain, EltwiseChainTest,
INSTANTIATE_TEST_SUITE_P(smoke_EltwiseChain, EltwiseChainTest, // ::testing::Combine(
::testing::Combine( // ::testing::ValuesIn(inputShapes),
::testing::ValuesIn(inputShapes), // ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT),
::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), // ::testing::ValuesIn(inputPrecisions),
::testing::ValuesIn(inputPrecisions), // ::testing::ValuesIn(eltwiseOps),
::testing::ValuesIn(eltwiseOps), // ::testing::Values(false),
::testing::Values(false), // ::testing::Values(CommonTestUtils::DEVICE_CPU)),
::testing::Values(CommonTestUtils::DEVICE_CPU)), // EltwiseChainTest::getTestCaseName);
EltwiseChainTest::getTestCaseName); //
//std::vector<std::pair<std::vector<ngraph::PartialShape>, std::vector<std::vector<ngraph::Shape>>>> inputShapesFQ = {
std::vector<std::pair<std::vector<ngraph::PartialShape>, std::vector<std::vector<ngraph::Shape>>>> inputShapesFQ = { // { {}, {{{1, 2, 2, 3}, {1, 2, 2, 3}, {1, 2, 2, 3}, {1, 2, 2, 3}}}},
{ {}, {{{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, 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, 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, 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, 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, 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}}}},
{ {}, {{{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, 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, 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, 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, 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}, {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, 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}}}}
{ {}, {{{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<std::vector<InferenceEngine::Precision>> inputPrecisionsFQ {
std::vector<std::vector<InferenceEngine::Precision>> inputPrecisionsFQ { // { Precision::FP32, Precision::FP32, Precision::FP32, Precision::FP32 }
{ Precision::FP32, Precision::FP32, Precision::FP32, Precision::FP32 } //};
}; //
//INSTANTIATE_TEST_SUITE_P(smoke_EltwiseChainWithFQ, EltwiseChainTest,
INSTANTIATE_TEST_SUITE_P(smoke_EltwiseChainWithFQ, EltwiseChainTest, // ::testing::Combine(
::testing::Combine( // ::testing::ValuesIn(inputShapesFQ),
::testing::ValuesIn(inputShapesFQ), // ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT),
::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), // ::testing::ValuesIn(inputPrecisionsFQ),
::testing::ValuesIn(inputPrecisionsFQ), // ::testing::ValuesIn(eltwiseOps),
::testing::ValuesIn(eltwiseOps), // ::testing::Values(true),
::testing::Values(true), // ::testing::Values(CommonTestUtils::DEVICE_CPU)),
::testing::Values(CommonTestUtils::DEVICE_CPU)), // EltwiseChainTest::getTestCaseName);
EltwiseChainTest::getTestCaseName); //
//// =============================================== dynamic ==============================================
// =============================================== dynamic ============================================== //std::vector<std::pair<std::vector<ngraph::PartialShape>, std::vector<std::vector<ngraph::Shape>>>> inputShapes_dyn = {
std::vector<std::pair<std::vector<ngraph::PartialShape>, std::vector<std::vector<ngraph::Shape>>>> inputShapes_dyn = { // {
{ // // dynamic
// dynamic // {
{ // {-1, -1, -1},
{-1, -1, -1}, // {-1},
{-1}, // {-1},
{-1}, // {-1}
{-1} // },
}, // // target
// target // {
{ // {{1, 2, 3}, {3}, {3}, {3}},
{{1, 2, 3}, {3}, {3}, {3}}, // {{5, 2, 7}, {7}, {1}, {1}},
{{5, 2, 7}, {7}, {1}, {1}}, // {{3, 1, 10}, {1}, {1}, {1}},
{{3, 1, 10}, {1}, {1}, {1}}, // }
} // },
}, // {
{ // // dynamic
// dynamic // {
{ // {-1, -1, -1, -1},
{-1, -1, -1, -1}, // {-1, -1},
{-1, -1}, // {-1, -1, -1},
{-1, -1, -1}, // {-1}
{-1} // },
}, // // target
// target // {
{ // {{1, 12, 5, 5}, {5, 5}, {12, 5, 5}, {1}},
{{1, 12, 5, 5}, {5, 5}, {12, 5, 5}, {1}}, // {{5, 16, 1, 5}, {1, 5}, {1, 5, 1}, {1}},
{{5, 16, 1, 5}, {1, 5}, {1, 5, 1}, {1}}, // {{2, 1, 1, 5}, {5, 1}, {16, 5, 5}, {5}},
{{2, 1, 1, 5}, {5, 1}, {16, 5, 5}, {5}}, // }
} // },
}, // {
{ // // dynamic
// 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}
{-1, -1, -1, -1} // },
}, // // target
// target // {
{ // {{1, 2, 2, 3}, {1, 2, 2, 3}, {1, 2, 2, 3}, {1, 2, 2, 3}},
{{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, 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, 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, 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, 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, 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}},
{{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, 36, 34, 34}, {1, 36, 34, 34}, {1, 36, 34, 34}, {1, 36, 34, 34}} // }
} // },
}, // {
{ // // dynamic
// 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, -1, -1}, // {-1, -1, -1, -1, -1}
{-1, -1, -1, -1, -1} // },
}, // // target
// 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, 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, 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, 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}, {1, 7, 5, 1, 12}, {3, 7, 1, 5, 12}, {3, 7, 5, 1, 12}} // }
} // },
}, // {
{ // // dynamic
// 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}, // {-1, -1, -1, -1, -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
// 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, 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}},
{{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}}
{{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,
INSTANTIATE_TEST_SUITE_P(smoke_EltwiseChain_dyn, EltwiseChainTest, // ::testing::Combine(
::testing::Combine( // ::testing::ValuesIn(inputShapes_dyn),
::testing::ValuesIn(inputShapes_dyn), // ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER),
::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), // ::testing::ValuesIn(inputPrecisions),
::testing::ValuesIn(inputPrecisions), // ::testing::ValuesIn(eltwiseOps),
::testing::ValuesIn(eltwiseOps), // ::testing::Values(false),
::testing::Values(false), // ::testing::Values(CommonTestUtils::DEVICE_CPU)),
::testing::Values(CommonTestUtils::DEVICE_CPU)), // EltwiseChainTest::getTestCaseName);
EltwiseChainTest::getTestCaseName); //
//} // namespace
} // namespace //} // namespace CPUSubgraphTestsDefinitions
} // namespace CPUSubgraphTestsDefinitions

View File

@ -14,7 +14,6 @@ namespace ov {
namespace test { namespace test {
using InputShape = std::pair<ov::PartialShape, std::vector<ov::Shape>>; using InputShape = std::pair<ov::PartialShape, std::vector<ov::Shape>>;
using InputShapes = std::pair<std::vector<ov::PartialShape>, std::vector<std::vector<ov::Shape>>>;
using ElementType = ov::element::Type_t; using ElementType = ov::element::Type_t;
using Config = std::map<std::string, std::string>; using Config = std::map<std::string, std::string>;
using TargetDevice = std::string; using TargetDevice = std::string;
@ -41,10 +40,7 @@ protected:
virtual void infer(); virtual void infer();
virtual void validate(); virtual void validate();
void init_input_shapes(const InputShapes& shapes); void init_input_shapes(const std::vector<InputShape>& shapes);
void init_input_shapes(const InputShape& shapes);
// void propagate_shape_to_all_inputs(bool proragate_first_shape = true,
// const InputShape& targetShape = InputShape());
std::shared_ptr<ov::runtime::Core> core = ov::test::utils::PluginCache::get().core(); std::shared_ptr<ov::runtime::Core> core = ov::test::utils::PluginCache::get().core();
std::string targetDevice; std::string targetDevice;
@ -68,28 +64,21 @@ private:
std::vector<ov::runtime::Tensor> get_plugin_outputs(); std::vector<ov::runtime::Tensor> get_plugin_outputs();
}; };
//inline std::vector<std::vector<InputShape>> static_shapes_to_test_representation(const std::vector<std::vector<ov::Shape>>& shapes) { inline std::vector<std::vector<InputShape>> static_shapes_to_test_representation(const std::vector<std::vector<ov::Shape>>& shapes) {
// std::vector<std::vector<InputShape>> result; std::vector<std::vector<InputShape>> result;
// for (const auto& staticShapes : shapes) { for (const auto& staticShapes : shapes) {
// std::vector<InputShape> tmp; std::vector<InputShape> tmp;
// for (const auto& staticShape : staticShapes) { for (const auto& staticShape : staticShapes) {
// tmp.push_back({{}, {staticShape}}); tmp.push_back({{}, {staticShape}});
// } }
// result.push_back(tmp); result.push_back(tmp);
// }
// return result;
//}
inline std::vector<InputShape> static_shapes_to_test_representation(const std::vector<ov::Shape>& staticShapes) {
std::vector<InputShape> result;
for (const auto& staticShape : staticShapes) {
result.push_back({{}, {staticShape}});
} }
return result; return result;
} }
inline std::vector<InputShapes> static_shapes_to_test_representation(const std::vector<std::vector<ov::Shape>>& staticShapes) { inline std::vector<InputShape> static_shapes_to_test_representation(const std::vector<ov::Shape>& shapes) {
std::vector<InputShapes> result; std::vector<InputShape> result;
for (const auto& staticShape : staticShapes) { for (const auto& staticShape : shapes) {
result.push_back({{}, {staticShape}}); result.push_back({{}, {staticShape}});
} }
return result; return result;

View File

@ -12,7 +12,7 @@ namespace test {
namespace subgraph { namespace subgraph {
typedef std::tuple< typedef std::tuple<
InputShapes, // input shapes std::vector<InputShape>, // input shapes
ngraph::helpers::EltwiseTypes, // eltwise op type ngraph::helpers::EltwiseTypes, // eltwise op type
ngraph::helpers::InputLayerType, // secondary input type ngraph::helpers::InputLayerType, // secondary input type
CommonTestUtils::OpType, // op type CommonTestUtils::OpType, // op type

View File

@ -179,31 +179,21 @@ void SubgraphBaseTest::validate() {
compare(expectedOutputs, actualOutputs); compare(expectedOutputs, actualOutputs);
} }
void SubgraphBaseTest::init_input_shapes(const InputShapes& shapes) { void SubgraphBaseTest::init_input_shapes(const std::vector<InputShape>& shapes) {
targetStaticShapes = shapes.second; size_t targetStaticShapeSize = shapes.front().second.size();
if (!shapes.first.empty()) { targetStaticShapes.resize(targetStaticShapeSize);
inputDynamicShapes = shapes.first; for (const auto& shape : shapes) {
} else { auto dynShape = shape.first;
OPENVINO_ASSERT(targetStaticShapes.size() == 1, "Incorrect size of targetStaticShapes for static scenario"); if (dynShape.rank() == 0) {
for (const auto& targetStaticShape : targetStaticShapes.front()) { ASSERT_EQ(targetStaticShapeSize, 1) << "Incorrect number of static shapes for static case";
inputDynamicShapes.emplace_back(targetStaticShape); 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<ov::PartialShape>, std::vector<std::vector<ov::Shape>>> 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 test
} // namespace ov } // namespace ov

View File

@ -11,7 +11,7 @@ namespace test {
namespace subgraph { namespace subgraph {
std::string EltwiseLayerTest::getTestCaseName(const testing::TestParamInfo<EltwiseTestParams>& obj) { std::string EltwiseLayerTest::getTestCaseName(const testing::TestParamInfo<EltwiseTestParams>& obj) {
std::pair<std::vector<ngraph::PartialShape>, std::vector<std::vector<ngraph::Shape>>> shapes; std::vector<InputShape> shapes;
ElementType netType; ElementType netType;
ngraph::helpers::InputLayerType secondaryInputType; ngraph::helpers::InputLayerType secondaryInputType;
CommonTestUtils::OpType opType; CommonTestUtils::OpType opType;
@ -21,16 +21,17 @@ std::string EltwiseLayerTest::getTestCaseName(const testing::TestParamInfo<Eltwi
std::tie(shapes, eltwiseOpType, secondaryInputType, opType, netType, targetName, additional_config) = obj.param; std::tie(shapes, eltwiseOpType, secondaryInputType, opType, netType, targetName, additional_config) = obj.param;
std::ostringstream results; std::ostringstream results;
results << "IS=" << CommonTestUtils::partialShape2str(shapes.first) << "_"; results << "IS=(";
results << "TS="; for (const auto& shape : shapes) {
for (const auto& shape : shapes.second) { results << CommonTestUtils::partialShape2str({shape.first}) << "_";
results << "("; }
for (const auto& item : shape) { results << ")_TS=(";
for (const auto& shape : shapes) {
for (const auto& item : shape.second) {
results << CommonTestUtils::vec2str(item) << "_"; results << CommonTestUtils::vec2str(item) << "_";
} }
results << ")_";
} }
results << "eltwiseOpType=" << eltwiseOpType << "_"; results << ")_eltwiseOpType=" << eltwiseOpType << "_";
results << "secondaryInputType=" << secondaryInputType << "_"; results << "secondaryInputType=" << secondaryInputType << "_";
results << "opType=" << opType << "_"; results << "opType=" << opType << "_";
results << "NetType=" << netType << "_"; results << "NetType=" << netType << "_";
@ -79,6 +80,9 @@ void EltwiseLayerTest::transformInputShapesAccordingEltwise(const ov::PartialSha
} }
} }
ASSERT_EQ(inputDynamicShapes.size(), 2) << "Incorrect inputs number!"; ASSERT_EQ(inputDynamicShapes.size(), 2) << "Incorrect inputs number!";
if (secondInputShape.is_dynamic()) {
return;
}
if (secondInputShape.get_shape() == ov::Shape{1}) { if (secondInputShape.get_shape() == ov::Shape{1}) {
inputDynamicShapes[1] = secondInputShape; inputDynamicShapes[1] = secondInputShape;
for (auto& staticShape : targetStaticShapes) { for (auto& staticShape : targetStaticShapes) {
@ -88,7 +92,7 @@ void EltwiseLayerTest::transformInputShapesAccordingEltwise(const ov::PartialSha
} }
void EltwiseLayerTest::SetUp() { void EltwiseLayerTest::SetUp() {
InputShapes shapes; std::vector<InputShape> shapes;
ElementType netType; ElementType netType;
ngraph::helpers::InputLayerType secondaryInputType; ngraph::helpers::InputLayerType secondaryInputType;
CommonTestUtils::OpType opType; CommonTestUtils::OpType opType;
@ -114,7 +118,7 @@ void EltwiseLayerTest::SetUp() {
FAIL() << "Unsupported Secondary operation type"; FAIL() << "Unsupported Secondary operation type";
} }
// To propagate shape_input_secondary just in static case because all shapes are defined in dynamic scenarion // 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); transformInputShapesAccordingEltwise(shape_input_secondary);
} }

View File

@ -39,7 +39,7 @@ void SoftMaxLayerTest::SetUp() {
size_t axis; size_t axis;
std::tie(ngPrc, shapes, axis, targetDevice, configuration) = GetParam(); 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 params = ngraph::builder::makeDynamicParams(ngPrc, inputDynamicShapes);
const auto paramOuts = const auto paramOuts =