[CPU tests] migrate single layer test cases to be API 2.0 - part 2 (#21441)

* [CPU tests] migrate single layer test cases to be API 2.0 - part 2

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* [CPU][Single layer test] fix tests error

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* Update augru_sequence.cpp

---------

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>
This commit is contained in:
Xuejun Zhai 2023-12-08 17:22:10 +08:00 committed by GitHub
parent df2ff92d21
commit 9866bc4d37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 1786 additions and 1798 deletions

View File

@ -2,49 +2,42 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
#include <common_test_utils/ov_tensor_utils.hpp> #include "common_test_utils/ov_tensor_utils.hpp"
#include "ov_models/utils/ov_helpers.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp" #include "shared_test_classes/base/ov_subgraph.hpp"
#include "test_utils/cpu_test_utils.hpp" #include "test_utils/cpu_test_utils.hpp"
#include "ov_models/builders.hpp"
#include "ov_models/utils/ov_helpers.hpp"
using namespace InferenceEngine;
using namespace CPUTestUtils; using namespace CPUTestUtils;
using namespace ov::test;
namespace CPULayerTestsDefinitions { namespace ov {
namespace { namespace test {
std::vector<int> pooledSpatialShape;
std::string mode;
std::vector<InputShape> inputShape;
} // namespace
using AdaPoolSpecificParams = std::tuple< using AdaPoolSpecificParams = std::tuple<std::vector<int>, // pooled vector
std::vector<int>, // pooled vector std::vector<InputShape>>; // feature map shape
std::vector<InputShape>>; // feature map shape
using AdaPoolLayerTestParams = std::tuple< using AdaPoolLayerTestParams = std::tuple<AdaPoolSpecificParams,
AdaPoolSpecificParams, std::string, // mode
std::string, // mode bool, // second Input is Constant
bool, // second Input is Constant ElementType, // Net precision
ElementType, // Net precision TargetDevice>; // Device name
TargetDevice>; // Device name
using AdaPoolLayerCPUTestParamsSet = std::tuple< using AdaPoolLayerCPUTestParamsSet = std::tuple<AdaPoolLayerTestParams, CPUSpecificParams>;
CPULayerTestsDefinitions::AdaPoolLayerTestParams,
CPUSpecificParams>;
class AdaPoolLayerCPUTest : public testing::WithParamInterface<AdaPoolLayerCPUTestParamsSet>, class AdaPoolLayerCPUTest : public testing::WithParamInterface<AdaPoolLayerCPUTestParamsSet>,
virtual public SubgraphBaseTest, public CPUTestsBase { virtual public SubgraphBaseTest,
public CPUTestsBase {
public: public:
static std::string getTestCaseName(testing::TestParamInfo<AdaPoolLayerCPUTestParamsSet> obj) { static std::string getTestCaseName(testing::TestParamInfo<AdaPoolLayerCPUTestParamsSet> obj) {
CPULayerTestsDefinitions::AdaPoolLayerTestParams basicParamsSet; AdaPoolLayerTestParams basicParamsSet;
CPUSpecificParams cpuParams; CPUSpecificParams cpuParams;
std::tie(basicParamsSet, cpuParams) = obj.param; std::tie(basicParamsSet, cpuParams) = obj.param;
std::string td; std::string td;
ElementType netPr; ElementType netPr;
bool isStatic; bool isStatic;
AdaPoolSpecificParams adaPar; AdaPoolSpecificParams adaPar;
std::vector<int> pooledSpatialShape;
std::vector<InputShape> inputShape;
std::string mode;
std::tie(adaPar, mode, isStatic, netPr, td) = basicParamsSet; std::tie(adaPar, mode, isStatic, netPr, td) = basicParamsSet;
std::tie(pooledSpatialShape, inputShape) = adaPar; std::tie(pooledSpatialShape, inputShape) = adaPar;
std::ostringstream result; std::ostringstream result;
@ -66,22 +59,24 @@ public:
result << std::to_string(obj.index); result << std::to_string(obj.index);
return result.str(); return result.str();
} }
protected: protected:
void SetUp() override { void SetUp() override {
CPULayerTestsDefinitions::AdaPoolLayerTestParams basicParamsSet; AdaPoolLayerTestParams basicParamsSet;
CPUSpecificParams cpuParams; CPUSpecificParams cpuParams;
std::tie(basicParamsSet, cpuParams) = this->GetParam(); std::tie(basicParamsSet, cpuParams) = this->GetParam();
std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; std::tie(inFmts, outFmts, priority, selectedType) = cpuParams;
CPULayerTestsDefinitions::AdaPoolSpecificParams adaPoolParams; AdaPoolSpecificParams adaPoolParams;
ElementType netPrecision; ElementType netPrecision;
bool isStatic; bool isStatic;
std::vector<InputShape> inputShape;
std::tie(adaPoolParams, mode, isStatic, netPrecision, targetDevice) = basicParamsSet; std::tie(adaPoolParams, mode, isStatic, netPrecision, targetDevice) = basicParamsSet;
std::tie(pooledVector, inputShape) = adaPoolParams; std::tie(pooledVector, inputShape) = adaPoolParams;
init_input_shapes(inputShape); init_input_shapes(inputShape);
if (!isStatic) { if (!isStatic) {
for (auto &target : targetStaticShapes) { for (auto& target : targetStaticShapes) {
target.push_back({pooledVector.size()}); target.push_back({pooledVector.size()});
} }
} }
@ -105,34 +100,36 @@ protected:
} }
} }
std::shared_ptr<ngraph::Function> createFunction(bool secondInputConst) { std::shared_ptr<ov::Model> createFunction(bool secondInputConst) {
ov::ParameterVector params{std::make_shared<ov::op::v0::Parameter>(ngraph::element::f32, inputDynamicShapes[0])}; ov::ParameterVector params{std::make_shared<ov::op::v0::Parameter>(ov::element::f32, inputDynamicShapes[0])};
params.front()->set_friendly_name("ParamsInput"); params.front()->set_friendly_name("ParamsInput");
std::shared_ptr<ov::Node> secondInput; std::shared_ptr<ov::Node> secondInput;
if (secondInputConst) { if (secondInputConst) {
secondInput = ngraph::op::Constant::create(ngraph::element::i32, ngraph::Shape{pooledVector.size()}, pooledVector); secondInput = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{pooledVector.size()}, pooledVector);
} else { } else {
auto pooledParam = std::make_shared<ngraph::opset1::Parameter>(ngraph::element::i32, ngraph::Shape{pooledVector.size()}); auto pooledParam =
std::make_shared<ov::op::v0::Parameter>(ov::element::i32, ov::Shape{pooledVector.size()});
pooledParam->set_friendly_name("ParamSecondInput"); pooledParam->set_friendly_name("ParamSecondInput");
params.push_back(pooledParam); params.push_back(pooledParam);
secondInput = pooledParam; secondInput = pooledParam;
} }
auto adapoolMax = std::make_shared<ngraph::opset8::AdaptiveMaxPool>(params[0], secondInput, ngraph::element::i32); auto adapoolMax = std::make_shared<ov::op::v8::AdaptiveMaxPool>(params[0], secondInput, ov::element::i32);
adapoolMax->get_rt_info() = getCPUInfo(); adapoolMax->get_rt_info() = getCPUInfo();
auto adapoolAvg = std::make_shared<ngraph::opset8::AdaptiveAvgPool>(params[0], secondInput); auto adapoolAvg = std::make_shared<ov::op::v8::AdaptiveAvgPool>(params[0], secondInput);
adapoolAvg->get_rt_info() = getCPUInfo(); adapoolAvg->get_rt_info() = getCPUInfo();
auto function = (mode == "max" ? std::make_shared<ngraph::Function>(adapoolMax->outputs(), params, "AdaPoolMax") : auto function = (mode == "max" ? std::make_shared<ov::Model>(adapoolMax->outputs(), params, "AdaPoolMax")
std::make_shared<ngraph::Function>(adapoolAvg->outputs(), params, "AdaPoolAvg")); : std::make_shared<ov::Model>(adapoolAvg->outputs(), params, "AdaPoolAvg"));
return function; return function;
} }
void validate() override { void validate() override {
auto actualOutputs = get_plugin_outputs(); auto actualOutputs = get_plugin_outputs();
if (function->get_parameters().size() == 2) { if (function->get_parameters().size() == 2) {
auto pos = std::find_if(inputs.begin(), inputs.end(), auto pos = std::find_if(inputs.begin(),
[](const std::pair<std::shared_ptr<ov::Node>, ov::Tensor> &params) { inputs.end(),
[](const std::pair<std::shared_ptr<ov::Node>, ov::Tensor>& params) {
return params.first->get_friendly_name() == "ParamSecondInput"; return params.first->get_friendly_name() == "ParamSecondInput";
}); });
OPENVINO_ASSERT(pos != inputs.end()); OPENVINO_ASSERT(pos != inputs.end());
@ -140,10 +137,10 @@ protected:
} }
auto expectedOutputs = calculate_refs(); auto expectedOutputs = calculate_refs();
if (expectedOutputs.empty()) { if (expectedOutputs.empty()) {
return; return;
} }
ASSERT_EQ(actualOutputs.size(), expectedOutputs.size()) ASSERT_EQ(actualOutputs.size(), expectedOutputs.size())
<< "nGraph interpreter has " << expectedOutputs.size() << " outputs, while IE " << actualOutputs.size(); << "model interpreter has " << expectedOutputs.size() << " outputs, while IE " << actualOutputs.size();
compare(expectedOutputs, actualOutputs); compare(expectedOutputs, actualOutputs);
} }
@ -157,12 +154,16 @@ protected:
if (i == 1) { if (i == 1) {
tensor = ov::Tensor(funcInput.get_element_type(), targetInputStaticShapes[i]); tensor = ov::Tensor(funcInput.get_element_type(), targetInputStaticShapes[i]);
auto *dataPtr = tensor.data<int32_t>(); auto* dataPtr = tensor.data<int32_t>();
for (size_t i = 0; i < pooledVector.size(); i++) { for (size_t i = 0; i < pooledVector.size(); i++) {
dataPtr[i] = pooledVector[i]; dataPtr[i] = pooledVector[i];
} }
} else { } else {
tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i], 2560, 0, 256); tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(),
targetInputStaticShapes[i],
2560,
0,
256);
} }
inputs.insert({funcInput.get_node_shared_ptr(), tensor}); inputs.insert({funcInput.get_node_shared_ptr(), tensor});
} }
@ -170,6 +171,7 @@ protected:
private: private:
std::vector<int> pooledVector; std::vector<int> pooledVector;
std::string mode;
}; };
TEST_P(AdaPoolLayerCPUTest, CompareWithRefs) { TEST_P(AdaPoolLayerCPUTest, CompareWithRefs) {
@ -238,329 +240,275 @@ std::vector<CPUSpecificParams> filterCPUInfoForDevice(std::string dims = "3D", s
return resCPUParams; return resCPUParams;
} }
const std::vector<ElementType> netPrecisions = { const std::vector<ElementType> netPrecisions = {ElementType::f32, ElementType::bf16};
ElementType::f32,
ElementType::bf16
};
const std::vector<std::vector<int>> pooled3DVector = { const std::vector<std::vector<int>> pooled3DVector = {{1}, {3}, {5}};
{ 1 }, const std::vector<std::vector<int>> pooled4DVector = {{1, 1}, {3, 5}, {5, 5}};
{ 3 },
{ 5 }
};
const std::vector<std::vector<int>> pooled4DVector = {
{ 1, 1 },
{ 3, 5 },
{ 5, 5 }
};
const std::vector<std::vector<int>> pooled5DVector = { const std::vector<std::vector<int>> pooled5DVector = {
{ 1, 1, 1 }, {1, 1, 1},
{ 3, 5, 1 }, {3, 5, 1},
{ 3, 5, 3 }, {3, 5, 3},
}; };
std::vector<std::vector<ov::Shape>> staticInput3DShapeVector = {{{1, 17, 3}, {3, 7, 5}}}; std::vector<std::vector<ov::Shape>> staticInput3DShapeVector = {{{1, 17, 3}, {3, 7, 5}}};
const std::vector<std::vector<InputShape>> input3DShapeVector = { const std::vector<std::vector<InputShape>> input3DShapeVector = {
{ {{{{-1, 17, -1}, {{1, 17, 3}, {3, 17, 5}, {3, 17, 5}}}},
{{{-1, 17, -1}, {{1, 17, 3}, {3, 17, 5}, {3, 17, 5}}}}, {{{{1, 10}, 20, {1, 10}}, {{1, 20, 5}, {2, 20, 4}, {3, 20, 6}}}}}};
{{{{1, 10}, 20, {1, 10}}, {{1, 20, 5}, {2, 20, 4}, {3, 20, 6}}}}
}
};
std::vector<std::vector<ov::Shape>> staticInput4DShapeVector = {{{1, 3, 1, 1}, {3, 17, 5, 2}}}; std::vector<std::vector<ov::Shape>> staticInput4DShapeVector = {{{1, 3, 1, 1}, {3, 17, 5, 2}}};
const std::vector<std::vector<InputShape>> input4DShapeVector = { const std::vector<std::vector<InputShape>> input4DShapeVector = {
{ {{{{-1, 3, -1, -1}, {{1, 3, 1, 1}, {3, 3, 5, 2}, {3, 3, 5, 2}}}},
{{{-1, 3, -1, -1}, {{1, 3, 1, 1}, {3, 3, 5, 2}, {3, 3, 5, 2}}}}, {{{{1, 10}, 3, {1, 10}, {1, 10}}, {{2, 3, 10, 6}, {3, 3, 6, 5}, {3, 3, 6, 5}}}}}};
{{{{1, 10}, 3, {1, 10}, {1, 10}}, {{2, 3, 10, 6}, {3, 3, 6, 5}, {3, 3, 6, 5}}}}
}
};
std::vector<std::vector<ov::Shape>> staticInput5DShapeVector = {{{ 1, 17, 2, 5, 2}, {3, 17, 4, 5, 4}}}; std::vector<std::vector<ov::Shape>> staticInput5DShapeVector = {{{1, 17, 2, 5, 2}, {3, 17, 4, 5, 4}}};
const std::vector<std::vector<InputShape>> input5DShapeVector = { const std::vector<std::vector<InputShape>> input5DShapeVector = {
{ {{{{-1, 17, -1, -1, -1}, {{1, 17, 2, 5, 2}, {3, 17, 4, 5, 4}, {3, 17, 4, 5, 4}}}},
{{{-1, 17, -1, -1, -1}, {{1, 17, 2, 5, 2}, {3, 17, 4, 5, 4}, {3, 17, 4, 5, 4}}}}, {{{{1, 10}, 3, {1, 10}, {1, 10}, {1, 10}}, {{3, 3, 2, 5, 2}, {1, 3, 4, 5, 4}, {1, 3, 4, 5, 4}}}}}};
{{{{1, 10}, 3, {1, 10}, {1, 10}, {1, 10}}, {{3, 3, 2, 5, 2}, {1, 3, 4, 5, 4}, {1, 3, 4, 5, 4}}}}
}
};
const auto adaPool3DParams = ::testing::Combine( const auto adaPool3DParams = ::testing::Combine(::testing::ValuesIn(pooled3DVector), // output spatial shape
::testing::ValuesIn(pooled3DVector), // output spatial shape ::testing::ValuesIn(input3DShapeVector) // feature map shape
::testing::ValuesIn(input3DShapeVector) // feature map shape
); );
const auto adaPool4DParams = ::testing::Combine( const auto adaPool4DParams = ::testing::Combine(::testing::ValuesIn(pooled4DVector), // output spatial shape
::testing::ValuesIn(pooled4DVector), // output spatial shape ::testing::ValuesIn(input4DShapeVector) // feature map shape
::testing::ValuesIn(input4DShapeVector) // feature map shape
); );
const auto adaPool5DParams = ::testing::Combine( const auto adaPool5DParams = ::testing::Combine(::testing::ValuesIn(pooled5DVector), // output spatial shape
::testing::ValuesIn(pooled5DVector), // output spatial shape ::testing::ValuesIn(input5DShapeVector) // feature map shape
::testing::ValuesIn(input5DShapeVector) // feature map shape
); );
const auto staticAdaPool3DParams = ::testing::Combine( const auto staticAdaPool3DParams = ::testing::Combine(
::testing::ValuesIn(pooled3DVector), // output spatial shape ::testing::ValuesIn(pooled3DVector), // output spatial shape
::testing::ValuesIn(static_shapes_to_test_representation(staticInput3DShapeVector)) // feature map shape ::testing::ValuesIn(static_shapes_to_test_representation(staticInput3DShapeVector)) // feature map shape
); );
const auto staticAdaPool4DParams = ::testing::Combine( const auto staticAdaPool4DParams = ::testing::Combine(
::testing::ValuesIn(pooled4DVector), // output spatial shape ::testing::ValuesIn(pooled4DVector), // output spatial shape
::testing::ValuesIn(static_shapes_to_test_representation(staticInput4DShapeVector)) // feature map shape ::testing::ValuesIn(static_shapes_to_test_representation(staticInput4DShapeVector)) // feature map shape
); );
const auto staticAdaPool5DParams = ::testing::Combine( const auto staticAdaPool5DParams = ::testing::Combine(
::testing::ValuesIn(pooled5DVector), // output spatial shape ::testing::ValuesIn(pooled5DVector), // output spatial shape
::testing::ValuesIn(static_shapes_to_test_representation(staticInput5DShapeVector)) // feature map shape ::testing::ValuesIn(static_shapes_to_test_representation(staticInput5DShapeVector)) // feature map shape
); );
INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolAvg3DLayoutTest, AdaPoolLayerCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolAvg3DLayoutTest,
::testing::Combine( AdaPoolLayerCPUTest,
::testing::Combine( ::testing::Combine(::testing::Combine(adaPool3DParams,
adaPool3DParams, ::testing::Values("avg"),
::testing::Values("avg"), ::testing::Values(false),
::testing::Values(false), ::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice("3D", "avg"))),
::testing::ValuesIn(filterCPUInfoForDevice("3D", "avg"))),
AdaPoolLayerCPUTest::getTestCaseName); AdaPoolLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolAvg4DLayoutTest, AdaPoolLayerCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolAvg4DLayoutTest,
::testing::Combine( AdaPoolLayerCPUTest,
::testing::Combine( ::testing::Combine(::testing::Combine(adaPool4DParams,
adaPool4DParams, ::testing::Values("avg"),
::testing::Values("avg"), ::testing::Values(false),
::testing::Values(false), ::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice("4D", "avg"))),
::testing::ValuesIn(filterCPUInfoForDevice("4D", "avg"))),
AdaPoolLayerCPUTest::getTestCaseName); AdaPoolLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolAvg5DLayoutTest, AdaPoolLayerCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolAvg5DLayoutTest,
::testing::Combine( AdaPoolLayerCPUTest,
::testing::Combine( ::testing::Combine(::testing::Combine(adaPool5DParams,
adaPool5DParams, ::testing::Values("avg"),
::testing::Values("avg"), ::testing::Values(false),
::testing::Values(false), ::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice("5D", "avg"))),
::testing::ValuesIn(filterCPUInfoForDevice("5D", "avg"))),
AdaPoolLayerCPUTest::getTestCaseName); AdaPoolLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolMax3DLayoutTest, AdaPoolLayerCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolMax3DLayoutTest,
::testing::Combine( AdaPoolLayerCPUTest,
::testing::Combine( ::testing::Combine(::testing::Combine(adaPool3DParams,
adaPool3DParams, ::testing::Values("max"),
::testing::Values("max"), ::testing::Values(false),
::testing::Values(false), ::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice("3D", "max"))),
::testing::ValuesIn(filterCPUInfoForDevice("3D", "max"))),
AdaPoolLayerCPUTest::getTestCaseName); AdaPoolLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolMax4DLayoutTest, AdaPoolLayerCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolMax4DLayoutTest,
::testing::Combine( AdaPoolLayerCPUTest,
::testing::Combine( ::testing::Combine(::testing::Combine(adaPool4DParams,
adaPool4DParams, ::testing::Values("max"),
::testing::Values("max"), ::testing::Values(false),
::testing::Values(false), ::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice("4D", "max"))),
::testing::ValuesIn(filterCPUInfoForDevice("4D", "max"))),
AdaPoolLayerCPUTest::getTestCaseName); AdaPoolLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolMax5DLayoutTest, AdaPoolLayerCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolMax5DLayoutTest,
::testing::Combine( AdaPoolLayerCPUTest,
::testing::Combine( ::testing::Combine(::testing::Combine(adaPool5DParams,
adaPool5DParams, ::testing::Values("max"),
::testing::Values("max"), ::testing::Values(false),
::testing::Values(false), ::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice("5D", "max"))),
::testing::ValuesIn(filterCPUInfoForDevice("5D", "max"))),
AdaPoolLayerCPUTest::getTestCaseName); AdaPoolLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolAvg3DLayoutTest, AdaPoolLayerCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolAvg3DLayoutTest,
::testing::Combine( AdaPoolLayerCPUTest,
::testing::Combine( ::testing::Combine(::testing::Combine(staticAdaPool3DParams,
staticAdaPool3DParams, ::testing::Values("avg"),
::testing::Values("avg"), ::testing::Values(true),
::testing::Values(true), ::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice("3D", "avg"))),
::testing::ValuesIn(filterCPUInfoForDevice("3D", "avg"))),
AdaPoolLayerCPUTest::getTestCaseName); AdaPoolLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolAvg4DLayoutTest, AdaPoolLayerCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolAvg4DLayoutTest,
::testing::Combine( AdaPoolLayerCPUTest,
::testing::Combine( ::testing::Combine(::testing::Combine(staticAdaPool4DParams,
staticAdaPool4DParams, ::testing::Values("avg"),
::testing::Values("avg"), ::testing::Values(true),
::testing::Values(true), ::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice("4D", "avg"))),
::testing::ValuesIn(filterCPUInfoForDevice("4D", "avg"))),
AdaPoolLayerCPUTest::getTestCaseName); AdaPoolLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolAvg5DLayoutTest, AdaPoolLayerCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolAvg5DLayoutTest,
::testing::Combine( AdaPoolLayerCPUTest,
::testing::Combine( ::testing::Combine(::testing::Combine(staticAdaPool5DParams,
staticAdaPool5DParams, ::testing::Values("avg"),
::testing::Values("avg"), ::testing::Values(true),
::testing::Values(true), ::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice("5D", "avg"))),
::testing::ValuesIn(filterCPUInfoForDevice("5D", "avg"))),
AdaPoolLayerCPUTest::getTestCaseName); AdaPoolLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolMax3DLayoutTest, AdaPoolLayerCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolMax3DLayoutTest,
::testing::Combine( AdaPoolLayerCPUTest,
::testing::Combine( ::testing::Combine(::testing::Combine(staticAdaPool3DParams,
staticAdaPool3DParams, ::testing::Values("max"),
::testing::Values("max"), ::testing::Values(true),
::testing::Values(true), ::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice("3D", "max"))),
::testing::ValuesIn(filterCPUInfoForDevice("3D", "max"))),
AdaPoolLayerCPUTest::getTestCaseName); AdaPoolLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolMax4DLayoutTest, AdaPoolLayerCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolMax4DLayoutTest,
::testing::Combine( AdaPoolLayerCPUTest,
::testing::Combine( ::testing::Combine(::testing::Combine(staticAdaPool4DParams,
staticAdaPool4DParams, ::testing::Values("max"),
::testing::Values("max"), ::testing::Values(true),
::testing::Values(true), ::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice("4D", "max"))),
::testing::ValuesIn(filterCPUInfoForDevice("4D", "max"))),
AdaPoolLayerCPUTest::getTestCaseName); AdaPoolLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolMax5DLayoutTest, AdaPoolLayerCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolMax5DLayoutTest,
::testing::Combine( AdaPoolLayerCPUTest,
::testing::Combine( ::testing::Combine(::testing::Combine(staticAdaPool5DParams,
staticAdaPool5DParams, ::testing::Values("max"),
::testing::Values("max"), ::testing::Values(true),
::testing::Values(true), ::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice("5D", "max"))),
::testing::ValuesIn(filterCPUInfoForDevice("5D", "max"))),
AdaPoolLayerCPUTest::getTestCaseName); AdaPoolLayerCPUTest::getTestCaseName);
// in 1-channel cases {..., 1, 1, 1} shape cannot be correctly resolved on oneDnn level, so it was removed from
// in 1-channel cases {..., 1, 1, 1} shape cannot be correctly resolved on oneDnn level, so it was removed from instances // instances
const std::vector<std::vector<InputShape>> input3DShape1Channel = { const std::vector<std::vector<InputShape>> input3DShape1Channel = {
{ {{{{-1, -1, -1}, {{1, 1, 2}, {1, 1, 2}, {1, 1, 2}}}},
{{{-1, -1, -1}, {{1, 1, 2}, {1, 1, 2}, {1, 1, 2}}}}, {{{{1, 10}, {1, 10}, {1, 10}}, {{1, 1, 2}, {2, 1, 2}, {2, 1, 2}}}}}};
{{{{1, 10}, {1, 10}, {1, 10}}, {{1, 1, 2}, {2, 1, 2}, {2, 1, 2}}}}
}
};
const std::vector<std::vector<InputShape>> input4DShape1Channel = { const std::vector<std::vector<InputShape>> input4DShape1Channel = {
{ {{{{-1, -1, -1, -1}, {{1, 1, 1, 2}, {2, 1, 2, 1}, {2, 1, 2, 1}}}},
{{{-1, -1, -1, -1}, {{1, 1, 1, 2}, {2, 1, 2, 1}, {2, 1, 2, 1}}}}, {{{{1, 10}, {1, 10}, {1, 10}, {1, 10}}, {{1, 1, 1, 2}, {1, 1, 1, 2}, {2, 1, 2, 1}}}}}};
{{{{1, 10}, {1, 10}, {1, 10}, {1, 10}}, {{1, 1, 1, 2}, {1, 1, 1, 2}, {2, 1, 2, 1}}}}
}
};
const std::vector<std::vector<InputShape>> input5DShape1Channel = { const std::vector<std::vector<InputShape>> input5DShape1Channel = {
{ {{{{-1, -1, -1, -1, -1}, {{1, 1, 1, 1, 2}, {1, 1, 1, 1, 2}, {2, 1, 1, 2, 1}}}},
{{{-1, -1, -1, -1, -1}, {{1, 1, 1, 1, 2}, {1, 1, 1, 1, 2}, {2, 1, 1, 2, 1}}}}, {{{{1, 10}, {1, 10}, {1, 10}, {1, 10}, {1, 10}}, {{1, 1, 1, 1, 2}, {1, 1, 1, 1, 2}, {2, 1, 1, 2, 1}}}}}};
{{{{1, 10}, {1, 10}, {1, 10}, {1, 10}, {1, 10}}, {{1, 1, 1, 1, 2}, {1, 1, 1, 1, 2}, {2, 1, 1, 2, 1}}}}
}
};
INSTANTIATE_TEST_SUITE_P(smoke_AdaPool_1ch_Avg3DLayoutTest, AdaPoolLayerCPUTest, INSTANTIATE_TEST_SUITE_P(
::testing::Combine( smoke_AdaPool_1ch_Avg3DLayoutTest,
::testing::Combine( AdaPoolLayerCPUTest,
::testing::Combine( ::testing::Combine(::testing::Combine(::testing::Combine(::testing::ValuesIn(std::vector<std::vector<int>>{{1},
::testing::ValuesIn(std::vector<std::vector<int>> { {2}}),
{1}, {2}}), ::testing::ValuesIn(input3DShape1Channel)),
::testing::ValuesIn(input3DShape1Channel)), ::testing::Values("avg"),
::testing::Values("avg"), ::testing::Values(true),
::testing::Values(true), ::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::Values(CPUSpecificParams{{ncw, x}, {ncw}, {}, {}})),
::testing::Values(CPUSpecificParams{{ncw, x}, {ncw}, {}, {}})), AdaPoolLayerCPUTest::getTestCaseName);
AdaPoolLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_AdaPool_1ch_Avg4DLayoutTest, AdaPoolLayerCPUTest, INSTANTIATE_TEST_SUITE_P(
::testing::Combine( smoke_AdaPool_1ch_Avg4DLayoutTest,
::testing::Combine( AdaPoolLayerCPUTest,
::testing::Combine( ::testing::Combine(::testing::Combine(::testing::Combine(::testing::ValuesIn(std::vector<std::vector<int>>{{1, 1},
::testing::ValuesIn(std::vector<std::vector<int>> { {2, 2}}),
{1, 1}, ::testing::ValuesIn(input4DShape1Channel)),
{2, 2} ::testing::Values("avg"),
}), ::testing::Values(true),
::testing::ValuesIn(input4DShape1Channel)), ::testing::ValuesIn(netPrecisions),
::testing::Values("avg"), ::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(true), ::testing::Values(CPUSpecificParams{{nchw, x}, {nchw}, {}, {}})),
::testing::ValuesIn(netPrecisions), AdaPoolLayerCPUTest::getTestCaseName);
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(CPUSpecificParams{{nchw, x}, {nchw}, {}, {}})),
AdaPoolLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_AdaPool_1ch_Avg5DLayoutTest, AdaPoolLayerCPUTest, INSTANTIATE_TEST_SUITE_P(
::testing::Combine( smoke_AdaPool_1ch_Avg5DLayoutTest,
::testing::Combine( AdaPoolLayerCPUTest,
::testing::Combine( ::testing::Combine(
::testing::ValuesIn(std::vector<std::vector<int>> { ::testing::Combine(::testing::Combine(::testing::ValuesIn(std::vector<std::vector<int>>{{1, 1, 1}, {2, 2, 2}}),
{1, 1, 1}, {2, 2, 2}}), ::testing::ValuesIn(input5DShape1Channel)),
::testing::ValuesIn(input5DShape1Channel)), ::testing::Values("avg"),
::testing::Values("avg"), ::testing::Values(true),
::testing::Values(true), ::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::Values(CPUSpecificParams{{ncdhw, x}, {ncdhw}, {}, {}})),
::testing::Values(CPUSpecificParams{{ncdhw, x}, {ncdhw}, {}, {}})), AdaPoolLayerCPUTest::getTestCaseName);
AdaPoolLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(
smoke_AdaPool_1ch_Max3DLayoutTest,
AdaPoolLayerCPUTest,
::testing::Combine(::testing::Combine(::testing::Combine(::testing::ValuesIn(std::vector<std::vector<int>>{{1},
{2}}),
::testing::ValuesIn(input3DShape1Channel)),
::testing::Values("max"),
::testing::Values(true),
::testing::ValuesIn(netPrecisions),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(CPUSpecificParams{{ncw, x}, {ncw}, {}, {}})),
AdaPoolLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_AdaPool_1ch_Max3DLayoutTest, AdaPoolLayerCPUTest, INSTANTIATE_TEST_SUITE_P(
::testing::Combine( smoke_AdaPool_1ch_Max4DLayoutTest,
::testing::Combine( AdaPoolLayerCPUTest,
::testing::Combine( ::testing::Combine(::testing::Combine(::testing::Combine(::testing::ValuesIn(std::vector<std::vector<int>>{{1, 1},
::testing::ValuesIn(std::vector<std::vector<int>> { {2, 2}}),
{1}, {2}}), ::testing::ValuesIn(input4DShape1Channel)),
::testing::ValuesIn(input3DShape1Channel)), ::testing::Values("max"),
::testing::Values("max"), ::testing::Values(true),
::testing::Values(true), ::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::Values(CPUSpecificParams{{nchw, x}, {nchw}, {}, {}})),
::testing::Values(CPUSpecificParams{{ncw, x}, {ncw}, {}, {}})), AdaPoolLayerCPUTest::getTestCaseName);
AdaPoolLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_AdaPool_1ch_Max4DLayoutTest, AdaPoolLayerCPUTest, INSTANTIATE_TEST_SUITE_P(
::testing::Combine( smoke_AdaPool_1ch_Max5DLayoutTest,
::testing::Combine( AdaPoolLayerCPUTest,
::testing::Combine( ::testing::Combine(
::testing::ValuesIn(std::vector<std::vector<int>> { ::testing::Combine(::testing::Combine(::testing::ValuesIn(std::vector<std::vector<int>>{{1, 1, 1}, {2, 2, 2}}),
{1, 1}, {2, 2}}), ::testing::ValuesIn(input5DShape1Channel)),
::testing::ValuesIn(input4DShape1Channel)), ::testing::Values("max"),
::testing::Values("max"), ::testing::Values(true),
::testing::Values(true), ::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::Values(CPUSpecificParams{{ncdhw, x}, {ncdhw}, {}, {}})),
::testing::Values(CPUSpecificParams{{nchw, x}, {nchw}, {}, {}})), AdaPoolLayerCPUTest::getTestCaseName);
AdaPoolLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_AdaPool_1ch_Max5DLayoutTest, AdaPoolLayerCPUTest, } // namespace
::testing::Combine( } // namespace test
::testing::Combine( } // namespace ov
::testing::Combine(
::testing::ValuesIn(std::vector<std::vector<int>> {
{1, 1, 1},
{2, 2, 2}
}),
::testing::ValuesIn(input5DShape1Channel)),
::testing::Values("max"),
::testing::Values(true),
::testing::ValuesIn(netPrecisions),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(CPUSpecificParams{{ncdhw, x}, {ncdhw}, {}, {}})),
AdaPoolLayerCPUTest::getTestCaseName);
} // namespace
} // namespace CPULayerTestsDefinitions

View File

@ -2,39 +2,47 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "common_test_utils/node_builders/augru_cell.hpp" #include "common_test_utils/node_builders/augru_cell.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "test_utils/cpu_test_utils.hpp" #include "test_utils/cpu_test_utils.hpp"
using namespace CPUTestUtils; using namespace CPUTestUtils;
using namespace ov::test;
namespace CPULayerTestsDefinitions { namespace ov {
namespace test {
using AUGRUCellCpuSpecificParams = typename std::tuple< using AUGRUCellCpuSpecificParams = typename std::tuple<std::vector<InputShape>, // Shapes
std::vector<InputShape>, // Shapes bool, // Using decompose to sub-ops transformation
bool, // Using decompose to sub-ops transformation std::vector<std::string>, // Activations
std::vector<std::string>, // Activations float, // Clip
float, // Clip bool, // Linear before reset
bool, // Linear before reset ElementType, // Network precision
ElementType, // Network precision CPUSpecificParams, // CPU specific params
CPUSpecificParams, // CPU specific params ov::AnyMap // Additional config
std::map<std::string, std::string> // Additional config >;
>;
class AUGRUCellCPUTest : public testing::WithParamInterface<AUGRUCellCpuSpecificParams>, class AUGRUCellCPUTest : public testing::WithParamInterface<AUGRUCellCpuSpecificParams>,
virtual public ov::test::SubgraphBaseTest, public CPUTestsBase { virtual public ov::test::SubgraphBaseTest,
public CPUTestsBase {
public: public:
static std::string getTestCaseName(const testing::TestParamInfo<AUGRUCellCpuSpecificParams> &obj) { static std::string getTestCaseName(const testing::TestParamInfo<AUGRUCellCpuSpecificParams>& obj) {
std::vector<InputShape> inputShapes; std::vector<InputShape> inputShapes;
bool decompose, linearBeforeReset; bool decompose, linearBeforeReset;
std::vector<std::string> activations; std::vector<std::string> activations;
float clip = 0.f; float clip = 0.f;
ElementType netPrecision; ElementType netPrecision;
CPUSpecificParams cpuParams; CPUSpecificParams cpuParams;
std::map<std::string, std::string> additionalConfig; ov::AnyMap additionalConfig;
std::tie(inputShapes, decompose, activations, clip, linearBeforeReset, netPrecision, cpuParams, additionalConfig) = obj.param; std::tie(inputShapes,
decompose,
activations,
clip,
linearBeforeReset,
netPrecision,
cpuParams,
additionalConfig) = obj.param;
std::ostringstream result; std::ostringstream result;
result << "IS=("; result << "IS=(";
@ -50,7 +58,7 @@ public:
result << "}_"; result << "}_";
} }
result << "decompose=" << decompose << "_"; result << "decompose=" << decompose << "_";
result << "activations=" << ov::test::utils::vec2str(activations) << "_"; result << "activations=" << ov::test::utils::vec2str(activations) << "_";
result << "clip=" << clip << "_"; result << "clip=" << clip << "_";
result << "linear=" << linearBeforeReset << "_"; result << "linear=" << linearBeforeReset << "_";
result << "netPrec=" << netPrecision << "_"; result << "netPrec=" << netPrecision << "_";
@ -58,9 +66,9 @@ public:
if (!additionalConfig.empty()) { if (!additionalConfig.empty()) {
result << "_PluginConf"; result << "_PluginConf";
for (auto &item : additionalConfig) { for (auto& item : additionalConfig) {
if (item.second == InferenceEngine::PluginConfigParams::YES) if (item.second == ov::element::bf16)
result << "_" << item.first << "=" << item.second; result << "_" << item.first << "=" << ov::element::bf16.get_type_name();
} }
} }
return result.str(); return result.str();
@ -74,9 +82,16 @@ protected:
float clip = 0.f; float clip = 0.f;
ElementType netPrecision; ElementType netPrecision;
CPUSpecificParams cpuParams; CPUSpecificParams cpuParams;
std::map<std::string, std::string> additionalConfig; ov::AnyMap additionalConfig;
std::tie(inputShapes, decompose, activations, clip, linearBeforeReset, netPrecision, cpuParams, additionalConfig) = this->GetParam(); std::tie(inputShapes,
decompose,
activations,
clip,
linearBeforeReset,
netPrecision,
cpuParams,
additionalConfig) = this->GetParam();
std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; std::tie(inFmts, outFmts, priority, selectedType) = cpuParams;
targetDevice = ov::test::utils::DEVICE_CPU; targetDevice = ov::test::utils::DEVICE_CPU;
@ -87,7 +102,7 @@ protected:
configuration.insert(additionalConfig.begin(), additionalConfig.end()); configuration.insert(additionalConfig.begin(), additionalConfig.end());
if (additionalConfig[InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16] == InferenceEngine::PluginConfigParams::YES) { if (additionalConfig[ov::hint::inference_precision.name()] == ov::element::bf16) {
selectedType = makeSelectedTypeStr(selectedType, ElementType::bf16); selectedType = makeSelectedTypeStr(selectedType, ElementType::bf16);
} else { } else {
selectedType = makeSelectedTypeStr(selectedType, netPrecision); selectedType = makeSelectedTypeStr(selectedType, netPrecision);
@ -100,8 +115,11 @@ protected:
params.push_back(param); params.push_back(param);
paramsOuts.push_back(param); paramsOuts.push_back(param);
} }
std::vector<ngraph::Shape> WRB = {{3 * hiddenSize, inputSize}, {3 * hiddenSize, hiddenSize}, {(linearBeforeReset ? 4 : 3) * hiddenSize}}; std::vector<ov::Shape> WRB = {{3 * hiddenSize, inputSize},
auto augruCellOp = ov::test::utils::make_augru(paramsOuts, WRB, hiddenSize/*, activations, {}, {}, clip, linearBeforeReset*/); {3 * hiddenSize, hiddenSize},
{(linearBeforeReset ? 4 : 3) * hiddenSize}};
auto augruCellOp =
ov::test::utils::make_augru(paramsOuts, WRB, hiddenSize /*, activations, {}, {}, clip, linearBeforeReset*/);
function = makeNgraphFunction(netPrecision, params, augruCellOp, "AUGRUCell"); function = makeNgraphFunction(netPrecision, params, augruCellOp, "AUGRUCell");
} }
@ -114,9 +132,8 @@ TEST_P(AUGRUCellCPUTest, CompareWithRefs) {
namespace { namespace {
/* CPU PARAMS */ /* CPU PARAMS */
std::vector<std::map<std::string, std::string>> additionalConfig std::vector<ov::AnyMap> additionalConfig = {{ov::hint::inference_precision(ov::element::f32)},
= {{{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::NO}}, {ov::hint::inference_precision(ov::element::bf16)}};
{{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::YES}}};
CPUSpecificParams cpuParams{{nc, nc}, {nc}, {"ref_any"}, "ref_any"}; CPUSpecificParams cpuParams{{nc, nc}, {nc}, {"ref_any"}, "ref_any"};
@ -127,79 +144,80 @@ std::vector<std::vector<std::string>> activations = {{"sigmoid", "tanh"}};
std::vector<float> clip = {0.f}; std::vector<float> clip = {0.f};
// dev_api::augrucell does not support lbr so far. // dev_api::augrucell does not support lbr so far.
std::vector<bool> linearBeforeReset = {false}; std::vector<bool> linearBeforeReset = {false};
std::vector<ElementType> netPrecisions = { ElementType::f32 }; std::vector<ElementType> netPrecisions = {ElementType::f32};
const std::vector<std::vector<ov::test::InputShape>> staticShapes = { const std::vector<std::vector<ov::test::InputShape>> staticShapes = {{{{}, {{1, 1}}}, // Static shapes
{ { {}, { {1, 1} } }, // Static shapes {{}, {{1, 1}}},
{ {}, { {1, 1} } }, {{}, {{1, 1}}}},
{ {}, { {1, 1} } } }, {{{}, {{1, 1}}}, // Static shapes
{ { {}, { {1, 1} } }, // Static shapes {{}, {{1, 10}}},
{ {}, { {1, 10} } }, {{}, {{1, 1}}}},
{ {}, { {1, 1} } } }, {{{}, {{1, 30}}}, // Static shapes
{ { {}, { {1, 30} } }, // Static shapes {{}, {{1, 10}}},
{ {}, { {1, 10} } }, {{}, {{1, 1}}}},
{ {}, { {1, 1} } } }, {{{}, {{1, 30}}}, // Static shapes
{ { {}, { {1, 30} } }, // Static shapes {{}, {{1, 1}}},
{ {}, { {1, 1} } }, {{}, {{1, 1}}}},
{ {}, { {1, 1} } } }, {{{}, {{3, 1}}}, // Static shapes
{ { {}, { {3, 1} } }, // Static shapes {{}, {{3, 1}}},
{ {}, { {3, 1} } }, {{}, {{3, 1}}}},
{ {}, { {3, 1} } } }, {{{}, {{5, 1}}}, // Static shapes
{ { {}, { {5, 1} } }, // Static shapes {{}, {{5, 1}}},
{ {}, { {5, 1} } }, {{}, {{5, 1}}}},
{ {}, { {5, 1} } } }, {{{}, {{5, 30}}}, // Static shapes
{ { {}, { {5, 30} } }, // Static shapes {{}, {{5, 10}}},
{ {}, { {5, 10} } }, {{}, {{5, 1}}}}};
{ {}, { {5, 1} } } }
};
INSTANTIATE_TEST_SUITE_P(smoke_static, AUGRUCellCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_static,
::testing::Combine(::testing::ValuesIn(staticShapes), AUGRUCellCPUTest,
::testing::ValuesIn(shouldDecompose), ::testing::Combine(::testing::ValuesIn(staticShapes),
::testing::ValuesIn(activations), ::testing::ValuesIn(shouldDecompose),
::testing::ValuesIn(clip), ::testing::ValuesIn(activations),
::testing::ValuesIn(linearBeforeReset), ::testing::ValuesIn(clip),
::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(linearBeforeReset),
::testing::Values(cpuParams), ::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(additionalConfig)), ::testing::Values(cpuParams),
AUGRUCellCPUTest::getTestCaseName); ::testing::ValuesIn(additionalConfig)),
AUGRUCellCPUTest::getTestCaseName);
const std::vector<std::vector<ov::test::InputShape>> dynamicShapes = { const std::vector<std::vector<ov::test::InputShape>> dynamicShapes = {
{ { { {-1}, 1 }, // Dynamic shape 0 {{{{-1}, 1}, // Dynamic shape 0
{ {1, 1}, {3, 1}, {5, 1} } }, // Target shapes {{1, 1}, {3, 1}, {5, 1}}}, // Target shapes
{ { {-1}, 1 }, // Dynamic shape 1 {{{-1}, 1}, // Dynamic shape 1
{ {1, 1}, {3, 1}, {5, 1} } }, // Target shapes {{1, 1}, {3, 1}, {5, 1}}}, // Target shapes
{ { {-1}, 1 }, // Dynamic shape 2 {{{-1}, 1}, // Dynamic shape 2
{ {1, 1}, {3, 1}, {5, 1} } } }, // Target shapes {{1, 1}, {3, 1}, {5, 1}}}}, // Target shapes
{ { { {1, 10}, 30 }, // Dynamic shape 0 {{{{1, 10}, 30}, // Dynamic shape 0
{ {2, 30}, {5, 30}, {8, 30} } }, // Target shapes {{2, 30}, {5, 30}, {8, 30}}}, // Target shapes
{ { {1, 10}, 10 }, // Dynamic shape 1 {{{1, 10}, 10}, // Dynamic shape 1
{ {2, 10}, {5, 10}, {8, 10} } }, // Target shapes {{2, 10}, {5, 10}, {8, 10}}}, // Target shapes
{ { {1, 10}, 1 }, // Dynamic shape 2 {{{1, 10}, 1}, // Dynamic shape 2
{ {2, 1}, {5, 1}, {8, 1} } } }, // Target shapes {{2, 1}, {5, 1}, {8, 1}}}}, // Target shapes
{ { { {1, 10}, {25, 35} }, // Dynamic shape 0 {{{{1, 10}, {25, 35}}, // Dynamic shape 0
{ {2, 30}, {5, 30}, {8, 30} } }, // Target shapes {{2, 30}, {5, 30}, {8, 30}}}, // Target shapes
{ { {1, 10}, -1 }, // Dynamic shape 1 {{{1, 10}, -1}, // Dynamic shape 1
{ {2, 10}, {5, 10}, {8, 10} } }, // Target shapes {{2, 10}, {5, 10}, {8, 10}}}, // Target shapes
{ { {1, 10}, 1 }, // Dynamic shape 2 {{{1, 10}, 1}, // Dynamic shape 2
{ {2, 1}, {5, 1}, {8, 1} } } }, // Target shapes {{2, 1}, {5, 1}, {8, 1}}}}, // Target shapes
{ { { {1, 10}, {25, 35} }, // Dynamic shape 0 {{{{1, 10}, {25, 35}}, // Dynamic shape 0
{ {2, 30}, {5, 30}, {8, 30}, {2, 30}, {5, 30}, {8, 30} } }, // Target shapes {{2, 30}, {5, 30}, {8, 30}, {2, 30}, {5, 30}, {8, 30}}}, // Target shapes
{ { {1, 10}, -1 }, // Dynamic shape 1 {{{1, 10}, -1}, // Dynamic shape 1
{ {2, 10}, {5, 10}, {8, 10}, {2, 10}, {5, 10}, {8, 10} } }, // Target shapes {{2, 10}, {5, 10}, {8, 10}, {2, 10}, {5, 10}, {8, 10}}}, // Target shapes
{ { {1, 10}, 1 }, // Dynamic shape 2 {{{1, 10}, 1}, // Dynamic shape 2
{ {2, 1}, {5, 1}, {8, 1}, {2, 1}, {5, 1}, {8, 1} } } } // Target shapes {{2, 1}, {5, 1}, {8, 1}, {2, 1}, {5, 1}, {8, 1}}}} // Target shapes
}; };
INSTANTIATE_TEST_SUITE_P(smoke_dynamic, AUGRUCellCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_dynamic,
::testing::Combine(::testing::ValuesIn(dynamicShapes), AUGRUCellCPUTest,
::testing::ValuesIn(shouldDecompose), ::testing::Combine(::testing::ValuesIn(dynamicShapes),
::testing::ValuesIn(activations), ::testing::ValuesIn(shouldDecompose),
::testing::ValuesIn(clip), ::testing::ValuesIn(activations),
::testing::ValuesIn(linearBeforeReset), ::testing::ValuesIn(clip),
::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(linearBeforeReset),
::testing::Values(cpuParams), ::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(additionalConfig)), ::testing::Values(cpuParams),
AUGRUCellCPUTest::getTestCaseName); ::testing::ValuesIn(additionalConfig)),
} // namespace AUGRUCellCPUTest::getTestCaseName);
} // namespace CPULayerTestsDefinitions } // namespace
} // namespace test
} // namespace ov

View File

@ -2,44 +2,53 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "common_test_utils/node_builders/augru_cell.hpp" #include "common_test_utils/node_builders/augru_cell.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "test_utils/cpu_test_utils.hpp" #include "test_utils/cpu_test_utils.hpp"
#include "transformations/op_conversions/bidirectional_sequences_decomposition.hpp" #include "transformations/op_conversions/bidirectional_sequences_decomposition.hpp"
#include "transformations/op_conversions/convert_sequences_to_tensor_iterator.hpp" #include "transformations/op_conversions/convert_sequences_to_tensor_iterator.hpp"
using namespace CPUTestUtils; using namespace CPUTestUtils;
using namespace ov::test;
namespace CPULayerTestsDefinitions { namespace ov {
namespace test {
using AUGRUSequenceCpuSpecificParams = typename std::tuple< using AUGRUSequenceCpuSpecificParams =
std::vector<InputShape>, // Shapes typename std::tuple<std::vector<InputShape>, // Shapes
ngraph::helpers::SequenceTestsMode, // Pure Sequence or TensorIterator ov::test::utils::SequenceTestsMode, // Pure Sequence or TensorIterator
std::vector<std::string>, // Activations std::vector<std::string>, // Activations
float, // Clip float, // Clip
bool, // Linear_before_reset bool, // Linear_before_reset
ov::op::RecurrentSequenceDirection, // Direction ov::op::RecurrentSequenceDirection, // Direction
ElementType, // Network precision ElementType, // Network precision
CPUSpecificParams, // CPU specific params CPUSpecificParams, // CPU specific params
std::map<std::string, std::string> // Additional config ov::AnyMap // Additional config
>; >;
class AUGRUSequenceCPUTest : public testing::WithParamInterface<AUGRUSequenceCpuSpecificParams>, class AUGRUSequenceCPUTest : public testing::WithParamInterface<AUGRUSequenceCpuSpecificParams>,
virtual public ov::test::SubgraphBaseTest, public CPUTestsBase { virtual public ov::test::SubgraphBaseTest,
public CPUTestsBase {
public: public:
static std::string getTestCaseName(const testing::TestParamInfo<AUGRUSequenceCpuSpecificParams> &obj) { static std::string getTestCaseName(const testing::TestParamInfo<AUGRUSequenceCpuSpecificParams>& obj) {
std::vector<InputShape> inputShapes; std::vector<InputShape> inputShapes;
ngraph::helpers::SequenceTestsMode seqMode; ov::test::utils::SequenceTestsMode seqMode;
std::vector<std::string> activations; std::vector<std::string> activations;
float clip; float clip;
bool linearBeforeRest; bool linearBeforeRest;
ov::op::RecurrentSequenceDirection direction; ov::op::RecurrentSequenceDirection direction;
ElementType netPrecision; ElementType netPrecision;
CPUSpecificParams cpuParams; CPUSpecificParams cpuParams;
std::map<std::string, std::string> additionalConfig; ov::AnyMap additionalConfig;
std::tie(inputShapes, seqMode, activations, clip, linearBeforeRest, direction, netPrecision, cpuParams, additionalConfig) = obj.param; std::tie(inputShapes,
seqMode,
activations,
clip,
linearBeforeRest,
direction,
netPrecision,
cpuParams,
additionalConfig) = obj.param;
std::ostringstream result; std::ostringstream result;
result << "IS=("; result << "IS=(";
@ -55,7 +64,7 @@ public:
result << "}_"; result << "}_";
} }
result << "seqMode=" << seqMode << "_"; result << "seqMode=" << seqMode << "_";
result << "activations=" << ov::test::utils::vec2str(activations) << "_"; result << "activations=" << ov::test::utils::vec2str(activations) << "_";
result << "clip=" << clip << "_"; result << "clip=" << clip << "_";
result << "linear=" << linearBeforeRest << "_"; result << "linear=" << linearBeforeRest << "_";
result << "direction=" << direction << "_"; result << "direction=" << direction << "_";
@ -64,9 +73,9 @@ public:
if (!additionalConfig.empty()) { if (!additionalConfig.empty()) {
result << "_PluginConf"; result << "_PluginConf";
for (auto &item : additionalConfig) { for (auto& item : additionalConfig) {
if (item.second == InferenceEngine::PluginConfigParams::YES) if (item.second == ov::element::bf16)
result << "_" << item.first << "=" << item.second; result << "_" << item.first << "=" << ov::element::bf16.get_type_name();
} }
} }
return result.str(); return result.str();
@ -75,21 +84,30 @@ public:
protected: protected:
void SetUp() override { void SetUp() override {
std::vector<InputShape> inputShapes; std::vector<InputShape> inputShapes;
ngraph::helpers::SequenceTestsMode seqMode; ov::test::utils::SequenceTestsMode seqMode;
std::vector<std::string> activations; std::vector<std::string> activations;
float clip; float clip;
bool linearBeforeReset; bool linearBeforeReset;
ov::op::RecurrentSequenceDirection direction; ov::op::RecurrentSequenceDirection direction;
ElementType netPrecision; ElementType netPrecision;
CPUSpecificParams cpuParams; CPUSpecificParams cpuParams;
std::map<std::string, std::string> additionalConfig; ov::AnyMap additionalConfig;
std::tie(inputShapes, seqMode, activations, clip, linearBeforeReset, direction, netPrecision, cpuParams, additionalConfig) = this->GetParam(); std::tie(inputShapes,
seqMode,
activations,
clip,
linearBeforeReset,
direction,
netPrecision,
cpuParams,
additionalConfig) = this->GetParam();
std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; std::tie(inFmts, outFmts, priority, selectedType) = cpuParams;
targetDevice = ov::test::utils::DEVICE_CPU; targetDevice = ov::test::utils::DEVICE_CPU;
init_input_shapes(inputShapes); init_input_shapes(inputShapes);
if (inputDynamicShapes.size() == 2 && inputDynamicShapes[0][0].is_dynamic() && inputDynamicShapes[1][0].is_dynamic()) if (inputDynamicShapes.size() == 2 && inputDynamicShapes[0][0].is_dynamic() &&
inputDynamicShapes[1][0].is_dynamic())
throw std::runtime_error("Invalid test case. If 3rd input is constant, batch dimension must be static."); throw std::runtime_error("Invalid test case. If 3rd input is constant, batch dimension must be static.");
configuration.insert(additionalConfig.begin(), additionalConfig.end()); configuration.insert(additionalConfig.begin(), additionalConfig.end());
@ -98,7 +116,7 @@ protected:
const size_t inputSize = targetStaticShapes.front()[0][2]; const size_t inputSize = targetStaticShapes.front()[0][2];
const size_t numDirections = direction == ov::op::RecurrentSequenceDirection::BIDIRECTIONAL ? 2 : 1; const size_t numDirections = direction == ov::op::RecurrentSequenceDirection::BIDIRECTIONAL ? 2 : 1;
if (additionalConfig[InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16] == InferenceEngine::PluginConfigParams::YES) { if (additionalConfig[ov::hint::inference_precision.name()] == ov::element::bf16) {
selectedType = makeSelectedTypeStr(selectedType, ElementType::bf16); selectedType = makeSelectedTypeStr(selectedType, ElementType::bf16);
} else { } else {
selectedType = makeSelectedTypeStr(selectedType, netPrecision); selectedType = makeSelectedTypeStr(selectedType, netPrecision);
@ -108,23 +126,24 @@ protected:
for (auto&& shape : inputDynamicShapes) { for (auto&& shape : inputDynamicShapes) {
params.push_back(std::make_shared<ov::op::v0::Parameter>(netPrecision, shape)); params.push_back(std::make_shared<ov::op::v0::Parameter>(netPrecision, shape));
} }
const size_t batchSize = inputDynamicShapes[0][0].is_static() ? inputDynamicShapes[0][0].get_length() : const size_t batchSize = inputDynamicShapes[0][0].is_static() ? inputDynamicShapes[0][0].get_length()
inputDynamicShapes[1][0].is_static() ? inputDynamicShapes[1][0].get_length() : : inputDynamicShapes[1][0].is_static() ? inputDynamicShapes[1][0].get_length()
inputDynamicShapes.size() > 2 && inputDynamicShapes[2][0].is_static() ? inputDynamicShapes[2][0].get_length() : : inputDynamicShapes.size() > 2 && inputDynamicShapes[2][0].is_static()
1lu; ? inputDynamicShapes[2][0].get_length()
/** : 1lu;
* There are 2 options to paramter "in" when "make_sequence" is true. /**
* 0 1 2 3 * There are 2 options to paramter "in" when "make_sequence" is true.
* X init_hidden_state attention seq_length * 0 1 2 3
* or, * X init_hidden_state attention seq_length
* 0 1 2 * or,
* X init_hidden_state attention * 0 1 2
* * X init_hidden_state attention
*/ *
*/
if (inputDynamicShapes.size() > 3) { if (inputDynamicShapes.size() > 3) {
if (!inputDynamicShapes[3].is_dynamic() && if (!inputDynamicShapes[3].is_dynamic() &&
seqMode != ngraph::helpers::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_PARAM && seqMode != ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_PARAM &&
seqMode != ngraph::helpers::SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_PARAM) { seqMode != ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_PARAM) {
params.pop_back(); params.pop_back();
} else { } else {
params[3]->set_element_type(ElementType::i64); params[3]->set_element_type(ElementType::i64);
@ -134,18 +153,15 @@ protected:
for (const auto& param : params) for (const auto& param : params)
paramsOuts.push_back(param); paramsOuts.push_back(param);
std::vector<ov::Shape> WRB = {{numDirections, 3 * hiddenSize, inputSize}, {numDirections, 3 * hiddenSize, hiddenSize}, std::vector<ov::Shape> WRB = {{numDirections, 3 * hiddenSize, inputSize},
{numDirections, (linearBeforeReset ? 4 : 3) * hiddenSize}, {batchSize}}; {numDirections, 3 * hiddenSize, hiddenSize},
auto augruSequenceOp = ov::test::utils::make_augru(paramsOuts, {numDirections, (linearBeforeReset ? 4 : 3) * hiddenSize},
WRB, {batchSize}};
hiddenSize, auto augruSequenceOp = ov::test::utils::make_augru(paramsOuts, WRB, hiddenSize, true, direction, seqMode);
true,
direction,
seqMode);
function = makeNgraphFunction(netPrecision, params, augruSequenceOp, "augruSequenceOp"); function = makeNgraphFunction(netPrecision, params, augruSequenceOp, "augruSequenceOp");
if (seqMode != ngraph::helpers::SequenceTestsMode::PURE_SEQ) { if (seqMode != ov::test::utils::SequenceTestsMode::PURE_SEQ) {
// TODO: ConvertAUGRUSequenceToTensorIterator // TODO: ConvertAUGRUSequenceToTensorIterator
throw std::runtime_error("ConvertAUGRUSequenceToTensorIterator not implemented yet."); throw std::runtime_error("ConvertAUGRUSequenceToTensorIterator not implemented yet.");
} else { } else {
@ -178,14 +194,13 @@ TEST_P(AUGRUSequenceCPUTest, CompareWithRefs) {
namespace { namespace {
/* CPU PARAMS */ /* CPU PARAMS */
std::vector<std::map<std::string, std::string>> additionalConfig std::vector<ov::AnyMap> additionalConfig = {{ov::hint::inference_precision(ov::element::f32)},
= {{{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::NO}}, {ov::hint::inference_precision(ov::element::bf16)}};
{{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::YES}}};
CPUSpecificParams cpuParams{{ntc, tnc}, {ntc, tnc}, {"ref_any"}, "ref_any"}; CPUSpecificParams cpuParams{{ntc, tnc}, {ntc, tnc}, {"ref_any"}, "ref_any"};
CPUSpecificParams cpuParamsBatchSizeOne{{tnc, tnc}, {tnc, tnc}, {"ref_any"}, "ref_any"};; CPUSpecificParams cpuParamsBatchSizeOne{{tnc, tnc}, {tnc, tnc}, {"ref_any"}, "ref_any"};
std::vector<ngraph::helpers::SequenceTestsMode> mode{ngraph::helpers::SequenceTestsMode::PURE_SEQ}; std::vector<ov::test::utils::SequenceTestsMode> mode{ov::test::utils::SequenceTestsMode::PURE_SEQ};
// output values increase rapidly without clip, so use only seq_lengths = 2 // output values increase rapidly without clip, so use only seq_lengths = 2
std::vector<std::vector<std::string>> activations = {{"sigmoid", "tanh"}}; std::vector<std::vector<std::string>> activations = {{"sigmoid", "tanh"}};
// dev_api::augrucell does not support lbr so far. // dev_api::augrucell does not support lbr so far.
@ -194,190 +209,198 @@ std::vector<float> clip{0.f};
// dev_api::augrusequence only supports forward so far. // dev_api::augrusequence only supports forward so far.
std::vector<ov::op::RecurrentSequenceDirection> direction = {ov::op::RecurrentSequenceDirection::FORWARD}; std::vector<ov::op::RecurrentSequenceDirection> direction = {ov::op::RecurrentSequenceDirection::FORWARD};
std::vector<ElementType> netPrecisions = { ElementType::f32 }; std::vector<ElementType> netPrecisions = {ElementType::f32};
const std::vector<std::vector<InputShape>> staticShapes = { const std::vector<std::vector<InputShape>> staticShapes = {{{{}, {{10, 2, 10}}}, // #0. Static shapes
{ { {}, { {10, 2, 10} } }, // #0. Static shapes {{}, {{10, 1, 1}}},
{ {}, { {10, 1, 1} } }, {{}, {{10, 2, 1}}},
{ {}, { {10, 2, 1} } }, {{}, {{10}}}},
{ {}, { {10} } } }, {{{}, {{10, 2, 10}}}, // #1. Static shapes
{ { {}, { {10, 2, 10} } }, // #1. Static shapes {{}, {{10, 1, 10}}},
{ {}, { {10, 1, 10} } }, {{}, {{10, 2, 1}}},
{ {}, { {10, 2, 1} } }, {{}, {{10}}}},
{ {}, { {10} } } }, {{{}, {{1, 2, 10}}}, // #2. Static shapes
{ { {}, { {1, 2, 10} } }, // #2. Static shapes {{}, {{1, 1, 1}}},
{ {}, { {1, 1, 1} } }, {{}, {{1, 2, 1}}},
{ {}, { {1, 2, 1} } }, {{}, {{1}}}},
{ {}, { {1} } } }, {{{}, {{1, 2, 10}}}, // #3. Static shapes
{ { {}, { {1, 2, 10} } }, // #3. Static shapes {{}, {{1, 1, 10}}},
{ {}, { {1, 1, 10} } }, {{}, {{1, 2, 1}}},
{ {}, { {1, 2, 1} } }, {{}, {{1}}}},
{ {}, { {1} } } }, {{{}, {{10, 2, 10}}}, // #4. Static shapes
{ { {}, { {10, 2, 10} } }, // #4. Static shapes {{}, {{10, 1, 1}}},
{ {}, { {10, 1, 1} } }, {{}, {{10, 2, 1}}}},
{ {}, { {10, 2, 1} } } }, {{{}, {{10, 2, 10}}}, // #5. Static shapes
{ { {}, { {10, 2, 10} } }, // #5. Static shapes {{}, {{10, 1, 10}}},
{ {}, { {10, 1, 10} } }, {{}, {{10, 2, 1}}}}};
{ {}, { {10, 2, 1} } } }
};
INSTANTIATE_TEST_SUITE_P(smoke_static, AUGRUSequenceCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_static,
::testing::Combine(::testing::ValuesIn(std::vector<std::vector<InputShape>>{staticShapes[0], staticShapes[1]}), AUGRUSequenceCPUTest,
::testing::ValuesIn(mode), ::testing::Combine(::testing::ValuesIn(std::vector<std::vector<InputShape>>{staticShapes[0],
::testing::ValuesIn(activations), staticShapes[1]}),
::testing::ValuesIn(clip), ::testing::ValuesIn(mode),
::testing::ValuesIn(linearBeforeReset), ::testing::ValuesIn(activations),
::testing::ValuesIn(direction), ::testing::ValuesIn(clip),
::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(linearBeforeReset),
::testing::Values(cpuParams), ::testing::ValuesIn(direction),
::testing::Values(std::map<std::string, std::string>{})), ::testing::ValuesIn(netPrecisions),
AUGRUSequenceCPUTest::getTestCaseName); ::testing::Values(cpuParams),
::testing::Values(ov::AnyMap{})),
AUGRUSequenceCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_static_BatchSizeOne, AUGRUSequenceCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_static_BatchSizeOne,
::testing::Combine(::testing::ValuesIn(std::vector<std::vector<InputShape>>{staticShapes[3]}), AUGRUSequenceCPUTest,
::testing::ValuesIn(mode), ::testing::Combine(::testing::ValuesIn(std::vector<std::vector<InputShape>>{staticShapes[3]}),
::testing::ValuesIn(activations), ::testing::ValuesIn(mode),
::testing::ValuesIn(clip), ::testing::ValuesIn(activations),
::testing::ValuesIn(linearBeforeReset), ::testing::ValuesIn(clip),
::testing::ValuesIn(direction), ::testing::ValuesIn(linearBeforeReset),
::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(direction),
::testing::Values(cpuParamsBatchSizeOne), ::testing::ValuesIn(netPrecisions),
::testing::Values(std::map<std::string, std::string>{})), ::testing::Values(cpuParamsBatchSizeOne),
AUGRUSequenceCPUTest::getTestCaseName); ::testing::Values(ov::AnyMap{})),
AUGRUSequenceCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(nightly_static_bf16, AUGRUSequenceCPUTest, INSTANTIATE_TEST_SUITE_P(nightly_static_bf16,
::testing::Combine(::testing::ValuesIn(std::vector<std::vector<InputShape>>{staticShapes[4], staticShapes[5]}), AUGRUSequenceCPUTest,
::testing::ValuesIn(mode), ::testing::Combine(::testing::ValuesIn(std::vector<std::vector<InputShape>>{staticShapes[4],
::testing::ValuesIn(activations), staticShapes[5]}),
::testing::ValuesIn(clip), ::testing::ValuesIn(mode),
::testing::ValuesIn(linearBeforeReset), ::testing::ValuesIn(activations),
::testing::ValuesIn(direction), ::testing::ValuesIn(clip),
::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(linearBeforeReset),
::testing::Values(cpuParams), ::testing::ValuesIn(direction),
::testing::Values(additionalConfig[1])), ::testing::ValuesIn(netPrecisions),
AUGRUSequenceCPUTest::getTestCaseName); ::testing::Values(cpuParams),
::testing::Values(additionalConfig[1])),
AUGRUSequenceCPUTest::getTestCaseName);
const std::vector<std::vector<InputShape>> dynamicShapes = { const std::vector<std::vector<InputShape>> dynamicShapes = {
{ { {-1, {1, 5}, 10}, // #0. Dynamic shape 0 {{{-1, {1, 5}, 10}, // #0. Dynamic shape 0
{ {10, 2, 10}, {8, 3, 10}, {5, 4, 10} } }, // Target shapes {{10, 2, 10}, {8, 3, 10}, {5, 4, 10}}}, // Target shapes
{ {{0, 15}, 1, 1}, // Dynamic shape 1 {{{0, 15}, 1, 1}, // Dynamic shape 1
{ {10, 1, 1}, {8, 1, 1}, {5, 1, 1} } }, // Target shapes {{10, 1, 1}, {8, 1, 1}, {5, 1, 1}}}, // Target shapes
{ {-1, {1, 5}, 1}, // Dynamic shape 2 {{-1, {1, 5}, 1}, // Dynamic shape 2
{ {10, 2, 1}, {8, 3, 1}, {5, 4, 1} } }, // Target shapes {{10, 2, 1}, {8, 3, 1}, {5, 4, 1}}}, // Target shapes
{ {{0, 12}}, // Dynamic shape 3 {{{0, 12}}, // Dynamic shape 3
{ {10}, {8}, {5} } } }, // Target shapes {{10}, {8}, {5}}}}, // Target shapes
{ { {{0, 11}, -1, 10}, // #1. Dynamic shape 0 {{{{0, 11}, -1, 10}, // #1. Dynamic shape 0
{ {10, 2, 10}, {3, 4, 10}, {5, 5, 10} } }, // Target shapes {{10, 2, 10}, {3, 4, 10}, {5, 5, 10}}}, // Target shapes
{ {-1, 1, 10}, // Dynamic shape 1 {{-1, 1, 10}, // Dynamic shape 1
{ {10, 1, 10}, {3, 1, 10}, {5, 1, 10} } }, // Target shapes {{10, 1, 10}, {3, 1, 10}, {5, 1, 10}}}, // Target shapes
{ {{0, 11}, -1, 1}, // Dynamic shape 3 {{{0, 11}, -1, 1}, // Dynamic shape 3
{ {10, 2, 1}, {3, 4, 1}, {5, 5, 1} } }, // Target shapes {{10, 2, 1}, {3, 4, 1}, {5, 5, 1}}}, // Target shapes
{ {-1}, // Dynamic shape 2 {{-1}, // Dynamic shape 2
{ {10}, {3}, {5} } } }, // Target shapes {{10}, {3}, {5}}}}, // Target shapes
{ { {{0, 11}, -1, {7, 11}}, // #2. Dynamic shape 0 {{{{0, 11}, -1, {7, 11}}, // #2. Dynamic shape 0
{ {10, 2, 10}, {3, 4, 10}, {5, 5, 10} } }, // Target shapes {{10, 2, 10}, {3, 4, 10}, {5, 5, 10}}}, // Target shapes
{ {-1, 1, {8, 12}}, // Dynamic shape 1 {{-1, 1, {8, 12}}, // Dynamic shape 1
{ {10, 1, 10}, {3, 1, 10}, {5, 1, 10} } }, // Target shapes {{10, 1, 10}, {3, 1, 10}, {5, 1, 10}}}, // Target shapes
{ {{0, 11}, -1, 1}, // Dynamic shape 3 {{{0, 11}, -1, 1}, // Dynamic shape 3
{ {10, 2, 1}, {3, 4, 1}, {5, 5, 1} } } , // Target shapes {{10, 2, 1}, {3, 4, 1}, {5, 5, 1}}}, // Target shapes
{ {-1}, // Dynamic shape 2 {{-1}, // Dynamic shape 2
{ {10}, {3}, {5} } } }, // Target shapes {{10}, {3}, {5}}}}, // Target shapes
{ { {-1, {0, 7}, 10}, // #3. Dynamic shape 0 {{{-1, {0, 7}, 10}, // #3. Dynamic shape 0
{ {1, 2, 10}, {1, 3, 10}, {1, 6, 10} } }, // Target shapes {{1, 2, 10}, {1, 3, 10}, {1, 6, 10}}}, // Target shapes
{ {-1, 1, 1}, // Dynamic shape 1 {{-1, 1, 1}, // Dynamic shape 1
{ {1, 1, 1}, {1, 1, 1}, {1, 1, 1} } }, // Target shapes {{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}}, // Target shapes
{ {-1, {0, 7}, 1}, // Dynamic shape 3 {{-1, {0, 7}, 1}, // Dynamic shape 3
{ {1, 2, 1}, {1, 3, 1}, {1, 6, 1} } }, // Target shapes {{1, 2, 1}, {1, 3, 1}, {1, 6, 1}}}, // Target shapes
{ {-1}, // Dynamic shape 2 {{-1}, // Dynamic shape 2
{ {1}, {1}, {1} } } }, // Target shapes {{1}, {1}, {1}}}}, // Target shapes
{ { {1, -1, 10}, // #4. Dynamic shape 0 {{{1, -1, 10}, // #4. Dynamic shape 0
{ {1, 2, 10}, {1, 4, 10}, {1, 8, 10} } }, // Target shapes {{1, 2, 10}, {1, 4, 10}, {1, 8, 10}}}, // Target shapes
{ {1, 1, 10}, // Dynamic shape 1 {{1, 1, 10}, // Dynamic shape 1
{ {1, 1, 10}, {1, 1, 10}, {1, 1, 10} } }, // Target shapes {{1, 1, 10}, {1, 1, 10}, {1, 1, 10}}}, // Target shapes
{ {1, -1, 1}, // Dynamic shape 0 {{1, -1, 1}, // Dynamic shape 0
{ {1, 2, 1}, {1, 4, 1}, {1, 8, 1} } }, // Target shapes {{1, 2, 1}, {1, 4, 1}, {1, 8, 1}}}, // Target shapes
{ {-1}, // Dynamic shape 2 {{-1}, // Dynamic shape 2
{ {1}, {1}, {1} } } }, // Target shapes {{1}, {1}, {1}}}}, // Target shapes
{ { {-1, -1, -1}, // #5. Dynamic shape 0 {{{-1, -1, -1}, // #5. Dynamic shape 0
{ {1, 2, 10}, {1, 4, 10}, {1, 8, 10} } }, // Target shapes {{1, 2, 10}, {1, 4, 10}, {1, 8, 10}}}, // Target shapes
{ {-1, -1, -1}, // Dynamic shape 1 {{-1, -1, -1}, // Dynamic shape 1
{ {1, 1, 10}, {1, 1, 10}, {1, 1, 10} } }, // Target shapes {{1, 1, 10}, {1, 1, 10}, {1, 1, 10}}}, // Target shapes
{ {-1, -1, -1}, // Dynamic shape 0 {{-1, -1, -1}, // Dynamic shape 0
{ {1, 2, 1}, {1, 4, 1}, {1, 8, 1} } }, // Target shapes {{1, 2, 1}, {1, 4, 1}, {1, 8, 1}}}, // Target shapes
{ {-1}, // Dynamic shape 2 {{-1}, // Dynamic shape 2
{ {1}, {1}, {1} } } }, // Target shapes {{1}, {1}, {1}}}}, // Target shapes
{ { {2, {1, 5}, 10}, // #6. Dynamic shape 0 {{{2, {1, 5}, 10}, // #6. Dynamic shape 0
{ {2, 2, 10}, {2, 3, 10}, {2, 4, 10} } }, // Target shapes {{2, 2, 10}, {2, 3, 10}, {2, 4, 10}}}, // Target shapes
{ {2, 1, 1}, // Dynamic shape 1 {{2, 1, 1}, // Dynamic shape 1
{ {2, 1, 1}, {2, 1, 1}, {2, 1, 1} } }, // Target shapes {{2, 1, 1}, {2, 1, 1}, {2, 1, 1}}}, // Target shapes
{ {2, {1, 5}, 1}, // Dynamic shape 2 {{2, {1, 5}, 1}, // Dynamic shape 2
{ {2, 2, 1}, {2, 3, 1}, {2, 4, 1} } }, // Target shapes {{2, 2, 1}, {2, 3, 1}, {2, 4, 1}}}, // Target shapes
{ {-1}, // Dynamic shape 2 {{-1}, // Dynamic shape 2
{ {2}, {2}, {2} } } }, // Target shapes {{2}, {2}, {2}}}}, // Target shapes
{ { {5, -1, 10}, // #7. Dynamic shape 0 {{{5, -1, 10}, // #7. Dynamic shape 0
{ {5, 2, 10}, {5, 4, 10}, {5, 5, 10} } }, // Target shapes {{5, 2, 10}, {5, 4, 10}, {5, 5, 10}}}, // Target shapes
{ {5, 1, 10}, // Dynamic shape 1 {{5, 1, 10}, // Dynamic shape 1
{ {5, 1, 10}, {5, 1, 10}, {5, 1, 10} } }, // Target shapes {{5, 1, 10}, {5, 1, 10}, {5, 1, 10}}}, // Target shapes
{ {5, -1, 1}, // Dynamic shape 0 {{5, -1, 1}, // Dynamic shape 0
{ {5, 2, 1}, {5, 4, 1}, {5, 5, 1} } }, // Target shapes {{5, 2, 1}, {5, 4, 1}, {5, 5, 1}}}, // Target shapes
{ {-1}, // Dynamic shape 2 {{-1}, // Dynamic shape 2
{ {5}, {5}, {5} } } }, // Target shapes {{5}, {5}, {5}}}}, // Target shapes
{ { {{0, 11}, -1, {7, 11}}, // #8. Dynamic shape 0 {{{{0, 11}, -1, {7, 11}}, // #8. Dynamic shape 0
{ {10, 2, 10}, {3, 4, 10}, {5, 5, 10}, {10, 2, 10}, {5, 5, 10} } }, // Target shapes {{10, 2, 10}, {3, 4, 10}, {5, 5, 10}, {10, 2, 10}, {5, 5, 10}}}, // Target shapes
{ {-1, 1, {8, 12}}, // Dynamic shape 1 {{-1, 1, {8, 12}}, // Dynamic shape 1
{ {10, 1, 10}, {3, 1, 10}, {5, 1, 10}, {10, 1, 10}, {5, 1, 10} } }, // Target shapes {{10, 1, 10}, {3, 1, 10}, {5, 1, 10}, {10, 1, 10}, {5, 1, 10}}}, // Target shapes
{ {{0, 11}, -1, 1}, // Dynamic shape 3 {{{0, 11}, -1, 1}, // Dynamic shape 3
{ {10, 2, 1}, {3, 4, 1}, {5, 5, 1}, {10, 2, 1}, {5, 5, 1} } }, // Target shapes {{10, 2, 1}, {3, 4, 1}, {5, 5, 1}, {10, 2, 1}, {5, 5, 1}}}, // Target shapes
{ {-1}, // Dynamic shape 2 {{-1}, // Dynamic shape 2
{ {10}, {3}, {5}, {10}, {5} } } } // Target shapes {{10}, {3}, {5}, {10}, {5}}}} // Target shapes
}; };
INSTANTIATE_TEST_SUITE_P(smoke_dynamic, AUGRUSequenceCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_dynamic,
::testing::Combine(::testing::ValuesIn({dynamicShapes[0], dynamicShapes[1], dynamicShapes[2]}), AUGRUSequenceCPUTest,
::testing::ValuesIn(mode), ::testing::Combine(::testing::ValuesIn({dynamicShapes[0], dynamicShapes[1], dynamicShapes[2]}),
::testing::ValuesIn(activations), ::testing::ValuesIn(mode),
::testing::ValuesIn(clip), ::testing::ValuesIn(activations),
::testing::ValuesIn(linearBeforeReset), ::testing::ValuesIn(clip),
::testing::ValuesIn(direction), ::testing::ValuesIn(linearBeforeReset),
::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(direction),
::testing::Values(cpuParams), ::testing::ValuesIn(netPrecisions),
::testing::Values(std::map<std::string, std::string>{})), ::testing::Values(cpuParams),
AUGRUSequenceCPUTest::getTestCaseName); ::testing::Values(ov::AnyMap{})),
AUGRUSequenceCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_dynamic_BatchSizeOne, AUGRUSequenceCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_dynamic_BatchSizeOne,
::testing::Combine(::testing::ValuesIn({dynamicShapes[4]}), AUGRUSequenceCPUTest,
::testing::ValuesIn(mode), ::testing::Combine(::testing::ValuesIn({dynamicShapes[4]}),
::testing::ValuesIn(activations), ::testing::ValuesIn(mode),
::testing::ValuesIn(clip), ::testing::ValuesIn(activations),
::testing::ValuesIn(linearBeforeReset), ::testing::ValuesIn(clip),
::testing::ValuesIn(direction), ::testing::ValuesIn(linearBeforeReset),
::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(direction),
::testing::Values(cpuParamsBatchSizeOne), ::testing::ValuesIn(netPrecisions),
::testing::Values(std::map<std::string, std::string>{})), ::testing::Values(cpuParamsBatchSizeOne),
AUGRUSequenceCPUTest::getTestCaseName); ::testing::Values(ov::AnyMap{})),
AUGRUSequenceCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(nightly_dynamic, AUGRUSequenceCPUTest, INSTANTIATE_TEST_SUITE_P(nightly_dynamic,
::testing::Combine(::testing::ValuesIn({dynamicShapes[5], dynamicShapes[8]}), AUGRUSequenceCPUTest,
::testing::ValuesIn(mode), ::testing::Combine(::testing::ValuesIn({dynamicShapes[5], dynamicShapes[8]}),
::testing::ValuesIn(activations), ::testing::ValuesIn(mode),
::testing::ValuesIn(clip), ::testing::ValuesIn(activations),
::testing::ValuesIn(linearBeforeReset), ::testing::ValuesIn(clip),
::testing::ValuesIn(direction), ::testing::ValuesIn(linearBeforeReset),
::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(direction),
::testing::Values(cpuParams), ::testing::ValuesIn(netPrecisions),
::testing::Values(std::map<std::string, std::string>{})), ::testing::Values(cpuParams),
AUGRUSequenceCPUTest::getTestCaseName); ::testing::Values(ov::AnyMap{})),
AUGRUSequenceCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(nightly_dynamic_bf16, AUGRUSequenceCPUTest, INSTANTIATE_TEST_SUITE_P(nightly_dynamic_bf16,
::testing::Combine(::testing::ValuesIn({dynamicShapes[6], dynamicShapes[7]}), AUGRUSequenceCPUTest,
::testing::ValuesIn(mode), ::testing::Combine(::testing::ValuesIn({dynamicShapes[6], dynamicShapes[7]}),
::testing::ValuesIn(activations), ::testing::ValuesIn(mode),
::testing::ValuesIn(clip), ::testing::ValuesIn(activations),
::testing::ValuesIn(linearBeforeReset), ::testing::ValuesIn(clip),
::testing::ValuesIn(direction), ::testing::ValuesIn(linearBeforeReset),
::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(direction),
::testing::Values(cpuParams), ::testing::ValuesIn(netPrecisions),
::testing::Values(additionalConfig[1])), ::testing::Values(cpuParams),
AUGRUSequenceCPUTest::getTestCaseName); ::testing::Values(additionalConfig[1])),
} // namespace AUGRUSequenceCPUTest::getTestCaseName);
} // namespace CPULayerTestsDefinitions } // namespace
} // namespace test
} // namespace ov

View File

@ -3,32 +3,32 @@
// //
#include <common_test_utils/ov_tensor_utils.hpp> #include <common_test_utils/ov_tensor_utils.hpp>
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "ov_models/builders.hpp" #include "ov_models/builders.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "test_utils/cpu_test_utils.hpp" #include "test_utils/cpu_test_utils.hpp"
using namespace InferenceEngine;
using namespace CPUTestUtils; using namespace CPUTestUtils;
using namespace ov::test;
namespace CPULayerTestsDefinitions { namespace ov {
namespace test {
namespace { namespace {
std::vector<int64_t> blockShape, cropsBegin, cropsEnd; std::vector<int64_t> blockShape, cropsBegin, cropsEnd;
} // namespace } // namespace
using BatchToSpaceLayerTestCPUParams = std::tuple< using BatchToSpaceLayerTestCPUParams = std::tuple<std::vector<InputShape>, // Input shapes
std::vector<InputShape>, // Input shapes std::vector<int64_t>, // block shape
std::vector<int64_t>, // block shape std::vector<int64_t>, // crops begin
std::vector<int64_t>, // crops begin std::vector<int64_t>, // crops end
std::vector<int64_t>, // crops end ov::element::Type, // Network precision
ov::element::Type, // Network precision CPUSpecificParams>;
CPUSpecificParams>;
class BatchToSpaceCPULayerTest : public testing::WithParamInterface<BatchToSpaceLayerTestCPUParams>, class BatchToSpaceCPULayerTest : public testing::WithParamInterface<BatchToSpaceLayerTestCPUParams>,
virtual public SubgraphBaseTest, public CPUTestsBase { virtual public SubgraphBaseTest,
public CPUTestsBase {
public: public:
static std::string getTestCaseName(const testing::TestParamInfo<BatchToSpaceLayerTestCPUParams> &obj) { static std::string getTestCaseName(const testing::TestParamInfo<BatchToSpaceLayerTestCPUParams>& obj) {
std::vector<InputShape> inputShapes; std::vector<InputShape> inputShapes;
ov::element::Type model_type; ov::element::Type model_type;
CPUSpecificParams cpuParams; CPUSpecificParams cpuParams;
@ -36,7 +36,7 @@ public:
std::ostringstream result; std::ostringstream result;
if (inputShapes.front().first.size() != 0) { if (inputShapes.front().first.size() != 0) {
result << "IS=("; result << "IS=(";
for (const auto &shape : inputShapes) { for (const auto& shape : inputShapes) {
result << ov::test::utils::partialShape2str({shape.first}) << "_"; result << ov::test::utils::partialShape2str({shape.first}) << "_";
} }
result.seekp(-1, result.cur); result.seekp(-1, result.cur);
@ -65,24 +65,24 @@ public:
const auto& param_type = parameter->get_output_element_type(0); const auto& param_type = parameter->get_output_element_type(0);
const auto& static_shape = targetInputStaticShapes[i]; const auto& static_shape = targetInputStaticShapes[i];
switch (i) { switch (i) {
case 0: { case 0: {
tensor = ov::test::utils::create_and_fill_tensor(param_type, static_shape, 2560, 0, 256); tensor = ov::test::utils::create_and_fill_tensor(param_type, static_shape, 2560, 0, 256);
break; break;
} }
case 1: { case 1: {
ASSERT_EQ(ov::shape_size(static_shape), blockShape.size()); ASSERT_EQ(ov::shape_size(static_shape), blockShape.size());
tensor = ov::Tensor(param_type, static_shape, blockShape.data()); tensor = ov::Tensor(param_type, static_shape, blockShape.data());
break; break;
} }
case 2: case 2:
case 3: { case 3: {
ASSERT_EQ(ov::shape_size(static_shape), cropsEnd.size()); ASSERT_EQ(ov::shape_size(static_shape), cropsEnd.size());
tensor = ov::Tensor(param_type, static_shape, cropsEnd.data()); tensor = ov::Tensor(param_type, static_shape, cropsEnd.data());
break; break;
} }
default: { default: {
throw std::runtime_error("Incorrect parameter number!"); throw std::runtime_error("Incorrect parameter number!");
} }
} }
inputs.insert({parameter, tensor}); inputs.insert({parameter, tensor});
} }
@ -92,7 +92,7 @@ protected:
void SetUp() override { void SetUp() override {
targetDevice = ov::test::utils::DEVICE_CPU; targetDevice = ov::test::utils::DEVICE_CPU;
std::vector<InputShape> inputShapes; std::vector<InputShape> inputShapes;
ov::element::Type model_type; ov::element::Type model_type;
CPUSpecificParams cpuParams; CPUSpecificParams cpuParams;
std::tie(inputShapes, blockShape, cropsBegin, cropsEnd, model_type, cpuParams) = this->GetParam(); std::tie(inputShapes, blockShape, cropsBegin, cropsEnd, model_type, cpuParams) = this->GetParam();
@ -120,8 +120,8 @@ protected:
in3 = std::make_shared<ov::op::v0::Parameter>(ov::element::Type_t::i64, inputDynamicShapes[3]); in3 = std::make_shared<ov::op::v0::Parameter>(ov::element::Type_t::i64, inputDynamicShapes[3]);
auto btsNode = std::make_shared<ov::op::v1::BatchToSpace>(in0, in1, in2, in3); auto btsNode = std::make_shared<ov::op::v1::BatchToSpace>(in0, in1, in2, in3);
btsNode->get_rt_info() = getCPUInfo(); btsNode->get_rt_info() = getCPUInfo();
ngraph::ResultVector results{std::make_shared<ov::op::v0::Result>(btsNode)}; ov::ResultVector results{std::make_shared<ov::op::v0::Result>(btsNode)};
function = std::make_shared<ngraph::Function>(results, ov::ParameterVector{in0, in1, in2, in3}, "BatchToSpace"); function = std::make_shared<ov::Model>(results, ov::ParameterVector{in0, in1, in2, in3}, "BatchToSpace");
} }
}; };
@ -132,310 +132,273 @@ TEST_P(BatchToSpaceCPULayerTest, CompareWithRefs) {
namespace { namespace {
const std::vector<ov::element::Type> model_types = { const std::vector<ov::element::Type> model_types = {ov::element::Type_t::u8,
ov::element::Type_t::u8, ov::element::Type_t::i8,
ov::element::Type_t::i8, ov::element::Type_t::i32,
ov::element::Type_t::i32, ov::element::Type_t::f32,
ov::element::Type_t::f32, ov::element::Type_t::bf16};
ov::element::Type_t::bf16
};
const std::vector<std::vector<int64_t>> blockShape4D1 = {{1, 1, 1, 2}, {1, 2, 2, 1}}; const std::vector<std::vector<int64_t>> blockShape4D1 = {{1, 1, 1, 2}, {1, 2, 2, 1}};
const std::vector<std::vector<int64_t>> cropsBegin4D1 = {{0, 0, 0, 0}, {0, 0, 0, 1}, {0, 0, 2, 0}}; const std::vector<std::vector<int64_t>> cropsBegin4D1 = {{0, 0, 0, 0}, {0, 0, 0, 1}, {0, 0, 2, 0}};
const std::vector<std::vector<int64_t>> cropsEnd4D1 = {{0, 0, 0, 0}, {0, 0, 1, 0}, {0, 0, 1, 1}}; const std::vector<std::vector<int64_t>> cropsEnd4D1 = {{0, 0, 0, 0}, {0, 0, 1, 0}, {0, 0, 1, 1}};
std::vector<std::vector<ov::Shape>> staticInputShapes4D1 = { std::vector<std::vector<ov::Shape>> staticInputShapes4D1 = {{{8, 16, 10, 10}, {4}, {4}, {4}}};
{{8, 16, 10, 10}, {4}, {4}, {4}}
};
std::vector<std::vector<InputShape>> dynamicInputShapes4D1 = { std::vector<std::vector<InputShape>> dynamicInputShapes4D1 = {
{ {{{-1, -1, -1, -1}, {{8, 8, 6, 7}, {4, 10, 5, 5}, {12, 9, 7, 5}}},
{{-1, -1, -1, -1}, {{8, 8, 6, 7}, {4, 10, 5, 5}, {12, 9, 7, 5}}}, {{4}, {{4}, {4}, {4}}},
{{4}, {{4}, {4}, {4}}}, {{4}, {{4}, {4}, {4}}},
{{4}, {{4}, {4}, {4}}}, {{4}, {{4}, {4}, {4}}}},
{{4}, {{4}, {4}, {4}}} {{{{4, 12}, {8, 16}, 6, -1}, {{8, 8, 6, 7}, {4, 10, 6, 5}, {12, 9, 6, 5}}},
}, {{4}, {{4}, {4}, {4}}},
{ {{4}, {{4}, {4}, {4}}},
{{{4, 12}, {8, 16}, 6, -1}, {{8, 8, 6, 7}, {4, 10, 6, 5}, {12, 9, 6, 5}}}, {{4}, {{4}, {4}, {4}}}}};
{{4}, {{4}, {4}, {4}}},
{{4}, {{4}, {4}, {4}}},
{{4}, {{4}, {4}, {4}}}
}
};
std::vector<std::vector<InputShape>> dynamicInputShapes4D1Blocked = { std::vector<std::vector<InputShape>> dynamicInputShapes4D1Blocked = {
{ {{{-1, 16, -1, -1}, {{4, 16, 5, 8}, {8, 16, 7, 6}, {12, 16, 4, 5}}},
{{-1, 16, -1, -1}, {{4, 16, 5, 8}, {8, 16, 7, 6}, {12, 16, 4, 5}}}, {{4}, {{4}, {4}, {4}}},
{{4}, {{4}, {4}, {4}}}, {{4}, {{4}, {4}, {4}}},
{{4}, {{4}, {4}, {4}}}, {{4}, {{4}, {4}, {4}}}}};
{{4}, {{4}, {4}, {4}}}
}
};
const std::vector<std::vector<int64_t>> blockShape4D2 = {{1, 2, 3, 4}, {1, 3, 4, 2}}; const std::vector<std::vector<int64_t>> blockShape4D2 = {{1, 2, 3, 4}, {1, 3, 4, 2}};
const std::vector<std::vector<int64_t>> cropsBegin4D2 = {{0, 0, 0, 1}, {0, 0, 1, 2}}; const std::vector<std::vector<int64_t>> cropsBegin4D2 = {{0, 0, 0, 1}, {0, 0, 1, 2}};
const std::vector<std::vector<int64_t>> cropsEnd4D2 = {{0, 0, 1, 0}, {0, 0, 3, 1}}; const std::vector<std::vector<int64_t>> cropsEnd4D2 = {{0, 0, 1, 0}, {0, 0, 3, 1}};
std::vector<std::vector<ov::Shape>> staticInputShapes4D2 = { std::vector<std::vector<ov::Shape>> staticInputShapes4D2 = {{{24, 16, 7, 8}, {4}, {4}, {4}}};
{{24, 16, 7, 8}, {4}, {4}, {4}}
};
std::vector<std::vector<InputShape>> dynamicInputShapes4D2 = { std::vector<std::vector<InputShape>> dynamicInputShapes4D2 = {
{ {{{-1, -1, -1, -1}, {{48, 4, 7, 8}, {24, 8, 6, 7}, {24, 16, 5, 5}}},
{{-1, -1, -1, -1}, {{48, 4, 7, 8}, {24, 8, 6, 7}, {24, 16, 5, 5}}}, {{4}, {{4}, {4}, {4}}},
{{4}, {{4}, {4}, {4}}}, {{4}, {{4}, {4}, {4}}},
{{4}, {{4}, {4}, {4}}}, {{4}, {{4}, {4}, {4}}}},
{{4}, {{4}, {4}, {4}}} {{{24, {4, 10}, -1, -1}, {{24, 8, 6, 7}, {24, 6, 7, 5}, {24, 4, 5, 5}}},
}, {{4}, {{4}, {4}, {4}}},
{ {{4}, {{4}, {4}, {4}}},
{{24, {4, 10}, -1, -1}, {{24, 8, 6, 7}, {24, 6, 7, 5}, {24, 4, 5, 5}}}, {{4}, {{4}, {4}, {4}}}}};
{{4}, {{4}, {4}, {4}}},
{{4}, {{4}, {4}, {4}}},
{{4}, {{4}, {4}, {4}}}
}
};
std::vector<std::vector<InputShape>> dynamicInputShapes4D2Blocked = { std::vector<std::vector<InputShape>> dynamicInputShapes4D2Blocked = {
{ {{{-1, 16, -1, -1}, {{24, 16, 5, 5}, {24, 16, 6, 7}, {48, 16, 4, 4}}},
{{-1, 16, -1, -1}, {{24, 16, 5, 5}, {24, 16, 6, 7}, {48, 16, 4, 4}}}, {{4}, {{4}, {4}, {4}}},
{{4}, {{4}, {4}, {4}}}, {{4}, {{4}, {4}, {4}}},
{{4}, {{4}, {4}, {4}}}, {{4}, {{4}, {4}, {4}}}}};
{{4}, {{4}, {4}, {4}}}
}
};
const std::vector<CPUSpecificParams> cpuParamsWithBlock_4D = { const std::vector<CPUSpecificParams> cpuParamsWithBlock_4D = {CPUSpecificParams({nChw16c}, {nChw16c}, {}, {}),
CPUSpecificParams({nChw16c}, {nChw16c}, {}, {}), CPUSpecificParams({nChw8c}, {nChw8c}, {}, {}),
CPUSpecificParams({nChw8c}, {nChw8c}, {}, {}), CPUSpecificParams({nhwc}, {nhwc}, {}, {}),
CPUSpecificParams({nhwc}, {nhwc}, {}, {}), CPUSpecificParams({nchw}, {nchw}, {}, {})};
CPUSpecificParams({nchw}, {nchw}, {}, {})
};
const std::vector<CPUSpecificParams> cpuParams_4D = { const std::vector<CPUSpecificParams> cpuParams_4D = {CPUSpecificParams({nhwc}, {nhwc}, {}, {}),
CPUSpecificParams({nhwc}, {nhwc}, {}, {}), CPUSpecificParams({nchw}, {nchw}, {}, {})};
CPUSpecificParams({nchw}, {nchw}, {}, {})
};
const auto staticBatchToSpaceParamsSet4D1 = ::testing::Combine( const auto staticBatchToSpaceParamsSet4D1 =
::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes4D1)), ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes4D1)),
::testing::ValuesIn(blockShape4D1), ::testing::ValuesIn(blockShape4D1),
::testing::ValuesIn(cropsBegin4D1), ::testing::ValuesIn(cropsBegin4D1),
::testing::ValuesIn(cropsEnd4D1), ::testing::ValuesIn(cropsEnd4D1),
::testing::ValuesIn(model_types), ::testing::ValuesIn(model_types),
::testing::ValuesIn(cpuParamsWithBlock_4D)); ::testing::ValuesIn(cpuParamsWithBlock_4D));
const auto dynamicBatchToSpaceParamsSet4D1 = ::testing::Combine( const auto dynamicBatchToSpaceParamsSet4D1 = ::testing::Combine(::testing::ValuesIn(dynamicInputShapes4D1),
::testing::ValuesIn(dynamicInputShapes4D1), ::testing::ValuesIn(blockShape4D1),
::testing::ValuesIn(blockShape4D1), ::testing::ValuesIn(cropsBegin4D1),
::testing::ValuesIn(cropsBegin4D1), ::testing::ValuesIn(cropsEnd4D1),
::testing::ValuesIn(cropsEnd4D1), ::testing::ValuesIn(model_types),
::testing::ValuesIn(model_types), ::testing::ValuesIn(cpuParams_4D));
::testing::ValuesIn(cpuParams_4D));
const auto dynamicBatchToSpaceParamsWithBlockedSet4D1 = ::testing::Combine( const auto dynamicBatchToSpaceParamsWithBlockedSet4D1 =
::testing::ValuesIn(dynamicInputShapes4D1Blocked), ::testing::Combine(::testing::ValuesIn(dynamicInputShapes4D1Blocked),
::testing::ValuesIn(blockShape4D1), ::testing::ValuesIn(blockShape4D1),
::testing::ValuesIn(cropsBegin4D1), ::testing::ValuesIn(cropsBegin4D1),
::testing::ValuesIn(cropsEnd4D1), ::testing::ValuesIn(cropsEnd4D1),
::testing::ValuesIn(model_types), ::testing::ValuesIn(model_types),
::testing::ValuesIn(cpuParamsWithBlock_4D)); ::testing::ValuesIn(cpuParamsWithBlock_4D));
const auto staticBatchToSpaceParamsSet4D2 = ::testing::Combine( const auto staticBatchToSpaceParamsSet4D2 =
::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes4D2)), ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes4D2)),
::testing::ValuesIn(blockShape4D2), ::testing::ValuesIn(blockShape4D2),
::testing::ValuesIn(cropsBegin4D2), ::testing::ValuesIn(cropsBegin4D2),
::testing::ValuesIn(cropsEnd4D2), ::testing::ValuesIn(cropsEnd4D2),
::testing::ValuesIn(model_types), ::testing::ValuesIn(model_types),
::testing::ValuesIn(cpuParamsWithBlock_4D)); ::testing::ValuesIn(cpuParamsWithBlock_4D));
const auto dynamicBatchToSpaceParamsSet4D2 = ::testing::Combine( const auto dynamicBatchToSpaceParamsSet4D2 = ::testing::Combine(::testing::ValuesIn(dynamicInputShapes4D2),
::testing::ValuesIn(dynamicInputShapes4D2), ::testing::ValuesIn(blockShape4D2),
::testing::ValuesIn(blockShape4D2), ::testing::ValuesIn(cropsBegin4D2),
::testing::ValuesIn(cropsBegin4D2), ::testing::ValuesIn(cropsEnd4D2),
::testing::ValuesIn(cropsEnd4D2), ::testing::ValuesIn(model_types),
::testing::ValuesIn(model_types), ::testing::ValuesIn(cpuParams_4D));
::testing::ValuesIn(cpuParams_4D));
const auto dynamicBatchToSpaceParamsWithBlockedSet4D2 = ::testing::Combine( const auto dynamicBatchToSpaceParamsWithBlockedSet4D2 =
::testing::ValuesIn(dynamicInputShapes4D2Blocked), ::testing::Combine(::testing::ValuesIn(dynamicInputShapes4D2Blocked),
::testing::ValuesIn(blockShape4D2), ::testing::ValuesIn(blockShape4D2),
::testing::ValuesIn(cropsBegin4D2), ::testing::ValuesIn(cropsBegin4D2),
::testing::ValuesIn(cropsEnd4D2), ::testing::ValuesIn(cropsEnd4D2),
::testing::ValuesIn(model_types), ::testing::ValuesIn(model_types),
::testing::ValuesIn(cpuParamsWithBlock_4D)); ::testing::ValuesIn(cpuParamsWithBlock_4D));
INSTANTIATE_TEST_SUITE_P(smoke_StaticBatchToSpaceCPULayerTestCase1_4D, BatchToSpaceCPULayerTest, INSTANTIATE_TEST_SUITE_P(smoke_StaticBatchToSpaceCPULayerTestCase1_4D,
staticBatchToSpaceParamsSet4D1, BatchToSpaceCPULayerTest::getTestCaseName); BatchToSpaceCPULayerTest,
staticBatchToSpaceParamsSet4D1,
BatchToSpaceCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCase1_4D, BatchToSpaceCPULayerTest, INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCase1_4D,
dynamicBatchToSpaceParamsSet4D1, BatchToSpaceCPULayerTest::getTestCaseName); BatchToSpaceCPULayerTest,
dynamicBatchToSpaceParamsSet4D1,
BatchToSpaceCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCaseWithBlocked1_4D, BatchToSpaceCPULayerTest, INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCaseWithBlocked1_4D,
dynamicBatchToSpaceParamsWithBlockedSet4D1, BatchToSpaceCPULayerTest::getTestCaseName); BatchToSpaceCPULayerTest,
dynamicBatchToSpaceParamsWithBlockedSet4D1,
BatchToSpaceCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_StaticBatchToSpaceCPULayerTestCase2_4D, BatchToSpaceCPULayerTest, INSTANTIATE_TEST_SUITE_P(smoke_StaticBatchToSpaceCPULayerTestCase2_4D,
staticBatchToSpaceParamsSet4D2, BatchToSpaceCPULayerTest::getTestCaseName); BatchToSpaceCPULayerTest,
staticBatchToSpaceParamsSet4D2,
BatchToSpaceCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCase2_4D, BatchToSpaceCPULayerTest, INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCase2_4D,
dynamicBatchToSpaceParamsSet4D2, BatchToSpaceCPULayerTest::getTestCaseName); BatchToSpaceCPULayerTest,
dynamicBatchToSpaceParamsSet4D2,
BatchToSpaceCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCaseWithBlocked2_4D, BatchToSpaceCPULayerTest, INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCaseWithBlocked2_4D,
dynamicBatchToSpaceParamsWithBlockedSet4D2, BatchToSpaceCPULayerTest::getTestCaseName); BatchToSpaceCPULayerTest,
dynamicBatchToSpaceParamsWithBlockedSet4D2,
BatchToSpaceCPULayerTest::getTestCaseName);
const std::vector<std::vector<int64_t>> blockShape5D1 = {{1, 1, 2, 2, 1}, {1, 2, 1, 2, 2}}; const std::vector<std::vector<int64_t>> blockShape5D1 = {{1, 1, 2, 2, 1}, {1, 2, 1, 2, 2}};
const std::vector<std::vector<int64_t>> cropsBegin5D1 = {{0, 0, 0, 0, 0}, {0, 0, 0, 3, 3}}; const std::vector<std::vector<int64_t>> cropsBegin5D1 = {{0, 0, 0, 0, 0}, {0, 0, 0, 3, 3}};
const std::vector<std::vector<int64_t>> cropsEnd5D1 = {{0, 0, 0, 0, 0}, {0, 0, 1, 0, 1}}; const std::vector<std::vector<int64_t>> cropsEnd5D1 = {{0, 0, 0, 0, 0}, {0, 0, 1, 0, 1}};
std::vector<std::vector<ov::Shape>> staticInputShapes5D1 = {
{{8, 16, 4, 10, 10}, {5}, {5}, {5}}
};
std::vector<std::vector<ov::Shape>> staticInputShapes5D1 = {{{8, 16, 4, 10, 10}, {5}, {5}, {5}}};
std::vector<std::vector<InputShape>> dynamicInputShapes5D1 = { std::vector<std::vector<InputShape>> dynamicInputShapes5D1 = {
{ {{{-1, -1, -1, -1, -1}, {{8, 16, 4, 10, 10}, {16, 10, 5, 11, 9}, {24, 6, 6, 8, 8}}},
{{-1, -1, -1, -1, -1}, {{8, 16, 4, 10, 10}, {16, 10, 5, 11, 9}, {24, 6, 6, 8, 8}}}, {{5}, {{5}, {5}, {5}}},
{{5}, {{5}, {5}, {5}}}, {{5}, {{5}, {5}, {5}}},
{{5}, {{5}, {5}, {5}}}, {{5}, {{5}, {5}, {5}}}},
{{5}, {{5}, {5}, {5}}} {{{{8, 16}, {8, 16}, {2, 7}, -1, -1}, {{8, 16, 2, 6, 8}, {8, 10, 4, 7, 5}, {16, 8, 7, 5, 10}}},
}, {{5}, {{5}, {5}, {5}}},
{ {{5}, {{5}, {5}, {5}}},
{{{8, 16}, {8, 16}, {2, 7}, -1, -1}, {{8, 16, 2, 6, 8}, {8, 10, 4, 7, 5}, {16, 8, 7, 5, 10}}}, {{5}, {{5}, {5}, {5}}}}};
{{5}, {{5}, {5}, {5}}},
{{5}, {{5}, {5}, {5}}},
{{5}, {{5}, {5}, {5}}}
}
};
std::vector<std::vector<InputShape>> dynamicInputShapes5D1Blocked = { std::vector<std::vector<InputShape>> dynamicInputShapes5D1Blocked = {
{ {{{-1, 16, -1, -1, -1}, {{24, 16, 3, 6, 7}, {48, 16, 4, 5, 5}, {24, 16, 5, 8, 5}}},
{{-1, 16, -1, -1, -1}, {{24, 16, 3, 6, 7}, {48, 16, 4, 5, 5}, {24, 16, 5, 8, 5}}}, {{5}, {{5}, {5}, {5}}},
{{5}, {{5}, {5}, {5}}}, {{5}, {{5}, {5}, {5}}},
{{5}, {{5}, {5}, {5}}}, {{5}, {{5}, {5}, {5}}}}};
{{5}, {{5}, {5}, {5}}}
}
};
const std::vector<std::vector<int64_t>> blockShape5D2 = {{1, 2, 4, 3, 1}, {1, 1, 2, 4, 3}}; const std::vector<std::vector<int64_t>> blockShape5D2 = {{1, 2, 4, 3, 1}, {1, 1, 2, 4, 3}};
const std::vector<std::vector<int64_t>> cropsBegin5D2 = {{0, 0, 1, 2, 0}, {0, 0, 1, 0, 1}}; const std::vector<std::vector<int64_t>> cropsBegin5D2 = {{0, 0, 1, 2, 0}, {0, 0, 1, 0, 1}};
const std::vector<std::vector<int64_t>> cropsEnd5D2 = {{0, 0, 1, 0, 1}, {0, 0, 1, 1, 1}}; const std::vector<std::vector<int64_t>> cropsEnd5D2 = {{0, 0, 1, 0, 1}, {0, 0, 1, 1, 1}};
std::vector<std::vector<ov::Shape>> staticInputShapes5D2 = { std::vector<std::vector<ov::Shape>> staticInputShapes5D2 = {{{48, 16, 3, 3, 3}, {5}, {5}, {5}}};
{{48, 16, 3, 3, 3}, {5}, {5}, {5}}
};
std::vector<std::vector<InputShape>> dynamicInputShapes5D2 = { std::vector<std::vector<InputShape>> dynamicInputShapes5D2 = {
{ {{{-1, -1, -1, -1, -1}, {{48, 4, 3, 3, 3}, {24, 16, 5, 3, 5}, {24, 8, 7, 5, 5}}},
{{-1, -1, -1, -1, -1}, {{48, 4, 3, 3, 3}, {24, 16, 5, 3, 5}, {24, 8, 7, 5, 5}}}, {{5}, {{5}, {5}, {5}}},
{{5}, {{5}, {5}, {5}}}, {{5}, {{5}, {5}, {5}}},
{{5}, {{5}, {5}, {5}}}, {{5}, {{5}, {5}, {5}}}},
{{5}, {{5}, {5}, {5}}} {{{24, {8, 16}, {3, 5}, -1, -1}, {{24, 16, 3, 4, 3}, {24, 12, 5, 3, 5}, {24, 8, 4, 5, 5}}},
}, {{5}, {{5}, {5}, {5}}},
{ {{5}, {{5}, {5}, {5}}},
{{24, {8, 16}, {3, 5}, -1, -1}, {{24, 16, 3, 4, 3}, {24, 12, 5, 3, 5}, {24, 8, 4, 5, 5}}}, {{5}, {{5}, {5}, {5}}}},
{{5}, {{5}, {5}, {5}}}, {// special case
{{5}, {{5}, {5}, {5}}}, {{{1, 24}, {1, 16}, {1, 10}, {1, 10}, {1, 10}}, {{24, 16, 5, 3, 5}, {24, 16, 5, 3, 5}, {24, 16, 7, 5, 5}}},
{{5}, {{5}, {5}, {5}}} {{5}, {{5}, {5}, {5}}},
}, {{5}, {{5}, {5}, {5}}},
{ {{5}, {{5}, {5}, {5}}}}};
// special case
{{{1, 24}, {1, 16}, {1, 10}, {1, 10}, {1, 10}},
{
{24, 16, 5, 3, 5},
{24, 16, 5, 3, 5},
{24, 16, 7, 5, 5}
}},
{{5}, {{5}, {5}, {5}}},
{{5}, {{5}, {5}, {5}}},
{{5}, {{5}, {5}, {5}}}
}
};
std::vector<std::vector<InputShape>> dynamicInputShapes5D2Blocked = { std::vector<std::vector<InputShape>> dynamicInputShapes5D2Blocked = {
{ {{{-1, 16, -1, -1, -1}, {{24, 16, 4, 5, 5}, {48, 16, 3, 4, 3}, {24, 16, 5, 3, 5}}},
{{-1, 16, -1, -1, -1}, {{24, 16, 4, 5, 5}, {48, 16, 3, 4, 3}, {24, 16, 5, 3, 5}}}, {{5}, {{5}, {5}, {5}}},
{{5}, {{5}, {5}, {5}}}, {{5}, {{5}, {5}, {5}}},
{{5}, {{5}, {5}, {5}}}, {{5}, {{5}, {5}, {5}}}}};
{{5}, {{5}, {5}, {5}}}
}
};
const std::vector<CPUSpecificParams> cpuParamsWithBlock_5D = { const std::vector<CPUSpecificParams> cpuParamsWithBlock_5D = {CPUSpecificParams({nCdhw16c}, {nCdhw16c}, {}, {}),
CPUSpecificParams({nCdhw16c}, {nCdhw16c}, {}, {}), CPUSpecificParams({nCdhw8c}, {nCdhw8c}, {}, {}),
CPUSpecificParams({nCdhw8c}, {nCdhw8c}, {}, {}), CPUSpecificParams({ndhwc}, {ndhwc}, {}, {}),
CPUSpecificParams({ndhwc}, {ndhwc}, {}, {}), CPUSpecificParams({ncdhw}, {ncdhw}, {}, {})};
CPUSpecificParams({ncdhw}, {ncdhw}, {}, {})
};
const std::vector<CPUSpecificParams> cpuParams_5D = { const std::vector<CPUSpecificParams> cpuParams_5D = {CPUSpecificParams({ndhwc}, {ndhwc}, {}, {}),
CPUSpecificParams({ndhwc}, {ndhwc}, {}, {}), CPUSpecificParams({ncdhw}, {ncdhw}, {}, {})};
CPUSpecificParams({ncdhw}, {ncdhw}, {}, {})
};
const auto staticBatchToSpaceParamsSet5D1 = ::testing::Combine( const auto staticBatchToSpaceParamsSet5D1 =
::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes5D1)), ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes5D1)),
::testing::ValuesIn(blockShape5D1), ::testing::ValuesIn(blockShape5D1),
::testing::ValuesIn(cropsBegin5D1), ::testing::ValuesIn(cropsBegin5D1),
::testing::ValuesIn(cropsEnd5D1), ::testing::ValuesIn(cropsEnd5D1),
::testing::ValuesIn(model_types), ::testing::ValuesIn(model_types),
::testing::ValuesIn(cpuParamsWithBlock_5D)); ::testing::ValuesIn(cpuParamsWithBlock_5D));
const auto dynamicBatchToSpaceParamsSet5D1 = ::testing::Combine( const auto dynamicBatchToSpaceParamsSet5D1 = ::testing::Combine(::testing::ValuesIn(dynamicInputShapes5D1),
::testing::ValuesIn(dynamicInputShapes5D1), ::testing::ValuesIn(blockShape5D1),
::testing::ValuesIn(blockShape5D1), ::testing::ValuesIn(cropsBegin5D1),
::testing::ValuesIn(cropsBegin5D1), ::testing::ValuesIn(cropsEnd5D1),
::testing::ValuesIn(cropsEnd5D1), ::testing::ValuesIn(model_types),
::testing::ValuesIn(model_types), ::testing::ValuesIn(cpuParams_5D));
::testing::ValuesIn(cpuParams_5D));
const auto dynamicBatchToSpaceParamsWithBlockedSet5D1 = ::testing::Combine( const auto dynamicBatchToSpaceParamsWithBlockedSet5D1 =
::testing::ValuesIn(dynamicInputShapes5D1Blocked), ::testing::Combine(::testing::ValuesIn(dynamicInputShapes5D1Blocked),
::testing::ValuesIn(blockShape5D1), ::testing::ValuesIn(blockShape5D1),
::testing::ValuesIn(cropsBegin5D1), ::testing::ValuesIn(cropsBegin5D1),
::testing::ValuesIn(cropsEnd5D1), ::testing::ValuesIn(cropsEnd5D1),
::testing::ValuesIn(model_types), ::testing::ValuesIn(model_types),
::testing::ValuesIn(cpuParamsWithBlock_5D)); ::testing::ValuesIn(cpuParamsWithBlock_5D));
const auto staticBatchToSpaceParamsSet5D2 = ::testing::Combine( const auto staticBatchToSpaceParamsSet5D2 =
::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes5D2)), ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes5D2)),
::testing::ValuesIn(blockShape5D2), ::testing::ValuesIn(blockShape5D2),
::testing::ValuesIn(cropsBegin5D2), ::testing::ValuesIn(cropsBegin5D2),
::testing::ValuesIn(cropsEnd5D2), ::testing::ValuesIn(cropsEnd5D2),
::testing::ValuesIn(model_types), ::testing::ValuesIn(model_types),
::testing::ValuesIn(cpuParamsWithBlock_5D)); ::testing::ValuesIn(cpuParamsWithBlock_5D));
const auto dynamicBatchToSpaceParamsSet5D2 = ::testing::Combine( const auto dynamicBatchToSpaceParamsSet5D2 = ::testing::Combine(::testing::ValuesIn(dynamicInputShapes5D2),
::testing::ValuesIn(dynamicInputShapes5D2), ::testing::ValuesIn(blockShape5D2),
::testing::ValuesIn(blockShape5D2), ::testing::ValuesIn(cropsBegin5D2),
::testing::ValuesIn(cropsBegin5D2), ::testing::ValuesIn(cropsEnd5D2),
::testing::ValuesIn(cropsEnd5D2), ::testing::ValuesIn(model_types),
::testing::ValuesIn(model_types), ::testing::ValuesIn(cpuParams_5D));
::testing::ValuesIn(cpuParams_5D));
const auto dynamicBatchToSpaceParamsWithBlockedSet5D2 = ::testing::Combine( const auto dynamicBatchToSpaceParamsWithBlockedSet5D2 =
::testing::ValuesIn(dynamicInputShapes5D2Blocked), ::testing::Combine(::testing::ValuesIn(dynamicInputShapes5D2Blocked),
::testing::ValuesIn(blockShape5D2), ::testing::ValuesIn(blockShape5D2),
::testing::ValuesIn(cropsBegin5D2), ::testing::ValuesIn(cropsBegin5D2),
::testing::ValuesIn(cropsEnd5D2), ::testing::ValuesIn(cropsEnd5D2),
::testing::ValuesIn(model_types), ::testing::ValuesIn(model_types),
::testing::ValuesIn(cpuParamsWithBlock_5D)); ::testing::ValuesIn(cpuParamsWithBlock_5D));
INSTANTIATE_TEST_SUITE_P(smoke_StaticBatchToSpaceCPULayerTestCase1_5D, BatchToSpaceCPULayerTest, INSTANTIATE_TEST_SUITE_P(smoke_StaticBatchToSpaceCPULayerTestCase1_5D,
staticBatchToSpaceParamsSet5D1, BatchToSpaceCPULayerTest::getTestCaseName); BatchToSpaceCPULayerTest,
staticBatchToSpaceParamsSet5D1,
BatchToSpaceCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCase1_5D, BatchToSpaceCPULayerTest, INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCase1_5D,
dynamicBatchToSpaceParamsSet5D1, BatchToSpaceCPULayerTest::getTestCaseName); BatchToSpaceCPULayerTest,
dynamicBatchToSpaceParamsSet5D1,
BatchToSpaceCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCaseWithBlocked1_5D, BatchToSpaceCPULayerTest, INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCaseWithBlocked1_5D,
dynamicBatchToSpaceParamsWithBlockedSet5D1, BatchToSpaceCPULayerTest::getTestCaseName); BatchToSpaceCPULayerTest,
dynamicBatchToSpaceParamsWithBlockedSet5D1,
BatchToSpaceCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_StaticBatchToSpaceCPULayerTestCase2_5D, BatchToSpaceCPULayerTest, INSTANTIATE_TEST_SUITE_P(smoke_StaticBatchToSpaceCPULayerTestCase2_5D,
staticBatchToSpaceParamsSet5D2, BatchToSpaceCPULayerTest::getTestCaseName); BatchToSpaceCPULayerTest,
staticBatchToSpaceParamsSet5D2,
BatchToSpaceCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCase2_5D, BatchToSpaceCPULayerTest, INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCase2_5D,
dynamicBatchToSpaceParamsSet5D2, BatchToSpaceCPULayerTest::getTestCaseName); BatchToSpaceCPULayerTest,
dynamicBatchToSpaceParamsSet5D2,
BatchToSpaceCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCaseWithBlocked2_5D, BatchToSpaceCPULayerTest, INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCaseWithBlocked2_5D,
dynamicBatchToSpaceParamsWithBlockedSet5D2, BatchToSpaceCPULayerTest::getTestCaseName); BatchToSpaceCPULayerTest,
dynamicBatchToSpaceParamsWithBlockedSet5D2,
BatchToSpaceCPULayerTest::getTestCaseName);
} // namespace } // namespace
} // namespace CPULayerTestsDefinitions } // namespace test
} // namespace ov

View File

@ -2,30 +2,30 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
#include "test_utils/cpu_test_utils.hpp" #include <common_test_utils/ov_tensor_utils.hpp>
#include "ov_models/builders.hpp" #include "ov_models/builders.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp" #include "shared_test_classes/base/ov_subgraph.hpp"
#include <common_test_utils/ov_tensor_utils.hpp> #include "test_utils/cpu_test_utils.hpp"
using namespace CPUTestUtils; using namespace CPUTestUtils;
namespace CPULayerTestsDefinitions { namespace ov {
namespace test {
using BroadcastLayerTestParamsSet = typename std::tuple< using BroadcastLayerTestParamsSet = typename std::tuple<std::vector<ov::test::InputShape>, // Shapes
std::vector<ov::test::InputShape>, // Shapes std::vector<int64_t>, // Target shapes
std::vector<int64_t>, // Target shapes std::vector<int64_t>, // Axes mapping
std::vector<int64_t>, // Axes mapping ov::op::BroadcastType, // Broadcast mode
ov::op::BroadcastType, // Broadcast mode ov::element::Type_t, // Network precision
ov::element::Type_t, // Network precision std::vector<bool>, // Const inputs
std::vector<bool>, // Const inputs std::string>; // Device name
std::string>; // Device name
using BroadcastLayerCPUTestParamsSet = typename std::tuple< using BroadcastLayerCPUTestParamsSet = typename std::tuple<BroadcastLayerTestParamsSet, CPUSpecificParams>;
BroadcastLayerTestParamsSet,
CPUSpecificParams>;
class BroadcastLayerCPUTest : public testing::WithParamInterface<BroadcastLayerCPUTestParamsSet>, class BroadcastLayerCPUTest : public testing::WithParamInterface<BroadcastLayerCPUTestParamsSet>,
virtual public ov::test::SubgraphBaseTest, public CPUTestsBase { virtual public ov::test::SubgraphBaseTest,
public CPUTestsBase {
public: public:
static std::string getTestCaseName(testing::TestParamInfo<BroadcastLayerCPUTestParamsSet> obj) { static std::string getTestCaseName(testing::TestParamInfo<BroadcastLayerCPUTestParamsSet> obj) {
BroadcastLayerTestParamsSet basicParamsSet; BroadcastLayerTestParamsSet basicParamsSet;
@ -38,7 +38,8 @@ public:
ov::element::Type_t netPrecision; ov::element::Type_t netPrecision;
std::vector<bool> isConstInputs; std::vector<bool> isConstInputs;
std::string deviceName; std::string deviceName;
std::tie(inputShapes, targetShapes, axesMapping, mode, netPrecision, isConstInputs, deviceName) = basicParamsSet; std::tie(inputShapes, targetShapes, axesMapping, mode, netPrecision, isConstInputs, deviceName) =
basicParamsSet;
std::ostringstream result; std::ostringstream result;
result << "IS=("; result << "IS=(";
@ -51,11 +52,12 @@ public:
result << ov::test::utils::vec2str(item) << "_"; result << ov::test::utils::vec2str(item) << "_";
} }
} }
result << "targetShape=" << ov::test::utils::vec2str(targetShapes) << "_"; result << "targetShape=" << ov::test::utils::vec2str(targetShapes) << "_";
result << "axesMapping=" << ov::test::utils::vec2str(axesMapping) << "_"; result << "axesMapping=" << ov::test::utils::vec2str(axesMapping) << "_";
result << "mode=" << mode << "_"; result << "mode=" << mode << "_";
result << "netPrec=" << netPrecision << "_"; result << "netPrec=" << netPrecision << "_";
result << "constIn=(" << (isConstInputs[0] ? "True" : "False") << "." << (isConstInputs[1] ? "True" : "False") << ")_"; result << "constIn=(" << (isConstInputs[0] ? "True" : "False") << "." << (isConstInputs[1] ? "True" : "False")
<< ")_";
result << "trgDev=" << deviceName; result << "trgDev=" << deviceName;
result << CPUTestsBase::getTestCaseName(cpuParams); result << CPUTestsBase::getTestCaseName(cpuParams);
@ -73,22 +75,23 @@ protected:
ov::op::BroadcastType mode; ov::op::BroadcastType mode;
ov::element::Type_t netPrecision; ov::element::Type_t netPrecision;
std::vector<bool> isConstInput; std::vector<bool> isConstInput;
std::tie(inputShapes, targetShape, axesMapping, mode, netPrecision, isConstInput, targetDevice) = basicParamsSet; std::tie(inputShapes, targetShape, axesMapping, mode, netPrecision, isConstInput, targetDevice) =
basicParamsSet;
bool isTargetShapeConst = isConstInput[0], isAxesMapConst = isConstInput[1]; bool isTargetShapeConst = isConstInput[0], isAxesMapConst = isConstInput[1];
const auto targetShapeRank = targetShape.size(); const auto targetShapeRank = targetShape.size();
const auto axesMappingRank = axesMapping.size(); const auto axesMappingRank = axesMapping.size();
std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; std::tie(inFmts, outFmts, priority, selectedType) = cpuParams;
selectedType += std::string("_") + InferenceEngine::details::convertPrecision(netPrecision).name(); selectedType += std::string("_") + ov::element::Type(netPrecision).get_type_name();
if (inputShapes.front().first.rank() != 0) { if (inputShapes.front().first.rank() != 0) {
inputDynamicShapes.push_back(inputShapes.front().first); inputDynamicShapes.push_back(inputShapes.front().first);
if (!isTargetShapeConst) { if (!isTargetShapeConst) {
inputDynamicShapes.push_back({ static_cast<int64_t>(targetShape.size()) }); inputDynamicShapes.push_back({static_cast<int64_t>(targetShape.size())});
} }
if (!isAxesMapConst) { if (!isAxesMapConst) {
inputDynamicShapes.push_back({ static_cast<int64_t>(axesMapping.size()) }); inputDynamicShapes.push_back({static_cast<int64_t>(axesMapping.size())});
} }
} }
const size_t targetStaticShapeSize = inputShapes.front().second.size(); const size_t targetStaticShapeSize = inputShapes.front().second.size();
@ -96,22 +99,25 @@ protected:
for (size_t i = 0lu; i < targetStaticShapeSize; ++i) { for (size_t i = 0lu; i < targetStaticShapeSize; ++i) {
targetStaticShapes[i].push_back(inputShapes.front().second[i]); targetStaticShapes[i].push_back(inputShapes.front().second[i]);
if (!isTargetShapeConst) if (!isTargetShapeConst)
targetStaticShapes[i].push_back({ targetShape.size() }); targetStaticShapes[i].push_back({targetShape.size()});
if (!isAxesMapConst) if (!isAxesMapConst)
targetStaticShapes[i].push_back({ axesMapping.size() }); targetStaticShapes[i].push_back({axesMapping.size()});
} }
ov::ParameterVector functionParams; ov::ParameterVector functionParams;
if (inputDynamicShapes.empty()) { if (inputDynamicShapes.empty()) {
functionParams.push_back(std::make_shared<ov::op::v0::Parameter>(netPrecision, targetStaticShapes.front().front())); functionParams.push_back(
std::make_shared<ov::op::v0::Parameter>(netPrecision, targetStaticShapes.front().front()));
} else { } else {
functionParams.push_back(std::make_shared<ov::op::v0::Parameter>(netPrecision, inputDynamicShapes.front())); functionParams.push_back(std::make_shared<ov::op::v0::Parameter>(netPrecision, inputDynamicShapes.front()));
if (!isTargetShapeConst) { if (!isTargetShapeConst) {
functionParams.push_back(std::make_shared<ov::op::v0::Parameter>(ov::element::i64, inputDynamicShapes[1])); functionParams.push_back(
std::make_shared<ov::op::v0::Parameter>(ov::element::i64, inputDynamicShapes[1]));
functionParams.back()->set_friendly_name("targetShape"); functionParams.back()->set_friendly_name("targetShape");
} }
if (!isAxesMapConst) { if (!isAxesMapConst) {
functionParams.push_back(std::make_shared<ov::op::v0::Parameter>(ov::element::i64, inputDynamicShapes.back())); functionParams.push_back(
std::make_shared<ov::op::v0::Parameter>(ov::element::i64, inputDynamicShapes.back()));
functionParams.back()->set_friendly_name("axesMapping"); functionParams.back()->set_friendly_name("axesMapping");
} }
} }
@ -131,27 +137,21 @@ protected:
} else { } else {
axesMappingOp = functionParams.size() > 2 ? functionParams[2] : functionParams[1]; axesMappingOp = functionParams.size() > 2 ? functionParams[2] : functionParams[1];
} }
broadcastOp = std::make_shared<ov::op::v3::Broadcast>(functionParams[0], broadcastOp =
targetShapeOp, std::make_shared<ov::op::v3::Broadcast>(functionParams[0], targetShapeOp, axesMappingOp, mode);
axesMappingOp,
mode);
} else if (mode == ov::op::BroadcastType::NUMPY) { } else if (mode == ov::op::BroadcastType::NUMPY) {
if (isTargetShapeConst) { if (isTargetShapeConst) {
auto targetShapeConst = ov::op::v0::Constant::create(ov::element::i64, {targetShapeRank}, targetShape); auto targetShapeConst = ov::op::v0::Constant::create(ov::element::i64, {targetShapeRank}, targetShape);
broadcastOp = std::make_shared<ov::op::v3::Broadcast>(functionParams[0], broadcastOp = std::make_shared<ov::op::v3::Broadcast>(functionParams[0], targetShapeConst, mode);
targetShapeConst,
mode);
} else { } else {
broadcastOp = std::make_shared<ov::op::v3::Broadcast>(functionParams[0], broadcastOp = std::make_shared<ov::op::v3::Broadcast>(functionParams[0], functionParams[1], mode);
functionParams[1],
mode);
} }
} }
function = makeNgraphFunction(netPrecision, functionParams, broadcastOp, "Broadcast"); function = makeNgraphFunction(netPrecision, functionParams, broadcastOp, "Broadcast");
} }
void generate_inputs(const std::vector<ngraph::Shape>& targetInputStaticShapes) override { void generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) override {
inputs.clear(); inputs.clear();
const auto& funcInputs = function->inputs(); const auto& funcInputs = function->inputs();
for (size_t i = 0lu; i < funcInputs.size(); i++) { for (size_t i = 0lu; i < funcInputs.size(); i++) {
@ -171,10 +171,14 @@ protected:
} }
} else { } else {
if (funcInput.get_element_type().is_real()) { if (funcInput.get_element_type().is_real()) {
tensor = ov::test::utils::create_and_fill_tensor( tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(),
funcInput.get_element_type(), targetInputStaticShapes[i], 10, 0, 1000); targetInputStaticShapes[i],
10,
0,
1000);
} else { } else {
tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i]); tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(),
targetInputStaticShapes[i]);
} }
} }
inputs.insert({funcInput.get_node_shared_ptr(), tensor}); inputs.insert({funcInput.get_node_shared_ptr(), tensor});
@ -192,277 +196,225 @@ TEST_P(BroadcastLayerCPUTest, CompareWithRefs) {
namespace { namespace {
/* CPU PARAMS */ /* CPU PARAMS */
const auto cpuParams_nChw16c = CPUSpecificParams {{nChw16c}, {nChw16c}, {}, "ref"}; const auto cpuParams_nChw16c = CPUSpecificParams{{nChw16c}, {nChw16c}, {}, "ref"};
const auto cpuParams_nCdhw16c = CPUSpecificParams {{nCdhw16c}, {nCdhw16c}, {}, "ref"}; const auto cpuParams_nCdhw16c = CPUSpecificParams{{nCdhw16c}, {nCdhw16c}, {}, "ref"};
const auto cpuParams_nChw8c = CPUSpecificParams {{nChw8c}, {nChw8c}, {}, "ref"}; const auto cpuParams_nChw8c = CPUSpecificParams{{nChw8c}, {nChw8c}, {}, "ref"};
const auto cpuParams_nCdhw8c = CPUSpecificParams {{nCdhw8c}, {nCdhw8c}, {}, "ref"}; const auto cpuParams_nCdhw8c = CPUSpecificParams{{nCdhw8c}, {nCdhw8c}, {}, "ref"};
const auto cpuParams_nhwc = CPUSpecificParams {{nhwc}, {nhwc}, {}, "ref"}; const auto cpuParams_nhwc = CPUSpecificParams{{nhwc}, {nhwc}, {}, "ref"};
const auto cpuParams_ndhwc = CPUSpecificParams {{ndhwc}, {ndhwc}, {}, "ref"}; const auto cpuParams_ndhwc = CPUSpecificParams{{ndhwc}, {ndhwc}, {}, "ref"};
/* ========== */ /* ========== */
/* COMMON PARAMS */ /* COMMON PARAMS */
const std::vector<ov::element::Type_t> inputPrecisions = { const std::vector<ov::element::Type_t> inputPrecisions = {ov::element::f32,
ov::element::f32, ov::element::bf16,
ov::element::bf16, ov::element::i32,
ov::element::i32, ov::element::i8};
ov::element::i8
};
/* ============= */ /* ============= */
/* INSTANCES */ /* INSTANCES */
// 4D // 4D
const std::vector<CPUSpecificParams> CPUParams4D = { const std::vector<CPUSpecificParams> CPUParams4D = {cpuParams_nChw16c, cpuParams_nChw8c, cpuParams_nhwc};
cpuParams_nChw16c,
cpuParams_nChw8c,
cpuParams_nhwc
};
const std::vector<std::vector<ov::test::InputShape>> staticInputShapes4D = { const std::vector<std::vector<ov::test::InputShape>> staticInputShapes4D = {{{{},
{ {// Static shapes
{{}, {1, 16, 1, 1}}}},
{ // Static shapes {{{},
{1, 16, 1, 1} {// Static shapes
} {50, 50}}}}};
}
},
{
{{},
{ // Static shapes
{50, 50}
}
}
}
};
INSTANTIATE_TEST_CASE_P(smoke_StaticShape4D, BroadcastLayerCPUTest, INSTANTIATE_TEST_CASE_P(smoke_StaticShape4D,
::testing::Combine( BroadcastLayerCPUTest,
::testing::Combine( ::testing::Combine(::testing::Combine(::testing::Values(staticInputShapes4D[0]),
::testing::Values(staticInputShapes4D[0]), ::testing::ValuesIn(std::vector<std::vector<int64_t>>{
::testing::ValuesIn(std::vector<std::vector<int64_t>>{{1, 16, 3, 3}, {1, 16, 1, 3}}), {1, 16, 3, 3},
::testing::Values(std::vector<int64_t>{}), {1, 16, 1, 3}}),
::testing::Values(ov::op::BroadcastType::NUMPY), ::testing::Values(std::vector<int64_t>{}),
::testing::ValuesIn(inputPrecisions), ::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::Values(std::vector<bool>{true, true}), ::testing::ValuesIn(inputPrecisions),
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::Values(std::vector<bool>{true, true}),
::testing::ValuesIn(CPUParams4D)), ::testing::Values(ov::test::utils::DEVICE_CPU)),
BroadcastLayerCPUTest::getTestCaseName); ::testing::ValuesIn(CPUParams4D)),
BroadcastLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(smoke_StaticShape4DE, BroadcastLayerCPUTest, INSTANTIATE_TEST_CASE_P(smoke_StaticShape4DE,
::testing::Combine( BroadcastLayerCPUTest,
::testing::Combine( ::testing::Combine(::testing::Combine(::testing::Values(staticInputShapes4D[1]),
::testing::Values(staticInputShapes4D[1]), ::testing::Values(std::vector<int64_t>{1, 50, 50, 16}),
::testing::Values(std::vector<int64_t>{1, 50, 50, 16}), ::testing::Values(std::vector<int64_t>{1, 2}),
::testing::Values(std::vector<int64_t>{1, 2}), ::testing::Values(ov::op::BroadcastType::EXPLICIT),
::testing::Values(ov::op::BroadcastType::EXPLICIT), ::testing::ValuesIn(inputPrecisions),
::testing::ValuesIn(inputPrecisions), ::testing::Values(std::vector<bool>{true, true}),
::testing::Values(std::vector<bool>{true, true}), ::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), BroadcastLayerCPUTest::getTestCaseName);
BroadcastLayerCPUTest::getTestCaseName);
const std::vector<std::vector<ov::test::InputShape>> staticInputShapesScalar = { const std::vector<std::vector<ov::test::InputShape>> staticInputShapesScalar = {{{{},
{ {// Static shapes
{{}, {1}}}}};
{ // Static shapes
{1}
}
}
}
};
INSTANTIATE_TEST_CASE_P(smoke_StaticShape4DScalar, BroadcastLayerCPUTest, INSTANTIATE_TEST_CASE_P(smoke_StaticShape4DScalar,
::testing::Combine( BroadcastLayerCPUTest,
::testing::Combine( ::testing::Combine(::testing::Combine(::testing::ValuesIn(staticInputShapesScalar),
::testing::ValuesIn(staticInputShapesScalar), ::testing::Values(std::vector<int64_t>{1, 16, 3, 3}),
::testing::Values(std::vector<int64_t>{1, 16, 3, 3}), ::testing::Values(std::vector<int64_t>{}),
::testing::Values(std::vector<int64_t>{}), ::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::Values(ov::op::BroadcastType::NUMPY), ::testing::ValuesIn(inputPrecisions),
::testing::ValuesIn(inputPrecisions), ::testing::Values(std::vector<bool>{true, true}),
::testing::Values(std::vector<bool>{true, true}), ::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), BroadcastLayerCPUTest::getTestCaseName);
BroadcastLayerCPUTest::getTestCaseName);
const std::vector<std::vector<ov::test::InputShape>> dynamicInputShapes4D = { const std::vector<std::vector<ov::test::InputShape>> dynamicInputShapes4D = {
{ {
{ // Origin dynamic shapes {// Origin dynamic shapes
{ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20)}, {ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20)},
{ // Dynamic shapes instances {// Dynamic shapes instances
{1, 16, 1, 1}, {1, 16, 1, 1},
{8, 1, 1, 7}, {8, 1, 1, 7},
{1, 1, 1, 7} {1, 1, 1, 7}}},
}
},
}, },
{ {{// Origin dynamic shapes
{ // Origin dynamic shapes {-1, -1, -1, -1},
{-1, -1, -1, -1}, {// Dynamic shapes instances
{ // Dynamic shapes instances {{1, 16, 1, 1}},
{{1, 16, 1, 1}}, {{8, 1, 1, 1}}}}}};
{{8, 1, 1, 1}}
}
}
}
};
INSTANTIATE_TEST_CASE_P(smoke_DynamicShape4D, BroadcastLayerCPUTest, INSTANTIATE_TEST_CASE_P(
::testing::Combine(::testing::Combine( smoke_DynamicShape4D,
::testing::ValuesIn(dynamicInputShapes4D), BroadcastLayerCPUTest,
::testing::ValuesIn(std::vector<std::vector<int64_t>>{{8, 16, 1, 7}, {8, 16, 10, 7}}), ::testing::Combine(
::testing::Values(std::vector<int64_t>{}), ::testing::Combine(::testing::ValuesIn(dynamicInputShapes4D),
::testing::Values(ov::op::BroadcastType::NUMPY), ::testing::ValuesIn(std::vector<std::vector<int64_t>>{{8, 16, 1, 7}, {8, 16, 10, 7}}),
::testing::ValuesIn(inputPrecisions), ::testing::Values(std::vector<int64_t>{}),
::testing::ValuesIn(std::vector<std::vector<bool>>{{true, true}, {false, true}}), ::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::ValuesIn(inputPrecisions),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), ::testing::ValuesIn(std::vector<std::vector<bool>>{{true, true}, {false, true}}),
BroadcastLayerCPUTest::getTestCaseName); ::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})),
BroadcastLayerCPUTest::getTestCaseName);
const std::vector<std::vector<ov::test::InputShape>> dynamicInputShapesScalar = { const std::vector<std::vector<ov::test::InputShape>> dynamicInputShapesScalar = {{{// Origin dynamic shapes
{ {-1},
{ // Origin dynamic shapes {// Dynamic shapes instances
{-1}, {1},
{ // Dynamic shapes instances {7}}}}};
{1},
{7}
}
}
}
};
INSTANTIATE_TEST_CASE_P(smoke_DynamicShape4DScalar, BroadcastLayerCPUTest, INSTANTIATE_TEST_CASE_P(smoke_DynamicShape4DScalar,
::testing::Combine(::testing::Combine( BroadcastLayerCPUTest,
::testing::ValuesIn(dynamicInputShapesScalar), ::testing::Combine(::testing::Combine(::testing::ValuesIn(dynamicInputShapesScalar),
::testing::Values(std::vector<int64_t>{8, 16, 1, 7}), ::testing::Values(std::vector<int64_t>{8, 16, 1, 7}),
::testing::Values(std::vector<int64_t>{}), ::testing::Values(std::vector<int64_t>{}),
::testing::Values(ov::op::BroadcastType::NUMPY), ::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::ValuesIn(inputPrecisions), ::testing::ValuesIn(inputPrecisions),
::testing::ValuesIn(std::vector<std::vector<bool>>{{true, true}, {false, true}}), ::testing::ValuesIn(std::vector<std::vector<bool>>{
::testing::Values(ov::test::utils::DEVICE_CPU)), {true, true},
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), {false, true}}),
BroadcastLayerCPUTest::getTestCaseName); ::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})),
BroadcastLayerCPUTest::getTestCaseName);
// 5D // 5D
const std::vector<std::vector<ov::test::InputShape>> staticInputShapes5D = { const std::vector<std::vector<ov::test::InputShape>> staticInputShapes5D = {{{{},
{ {// Static shapes
{{}, {1, 16, 1, 1, 1}}}}};
{ // Static shapes
{1, 16, 1, 1, 1}
}
}
}
};
const std::vector<std::vector<ov::test::InputShape>> dynamicInputShapes5D = { const std::vector<std::vector<ov::test::InputShape>> dynamicInputShapes5D = {
{ {{// Origin dynamic shapes
{ // Origin dynamic shapes {ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20)},
{ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20)}, {// Dynamic shapes instances
{ // Dynamic shapes instances {1, 16, 1, 1, 1},
{1, 16, 1, 1, 1}, {8, 1, 1, 7, 1},
{8, 1, 1, 7, 1}, {8, 1, 1, 1, 1}}}},
{8, 1, 1, 1, 1} {{// Origin dynamic shapes
} {-1, -1, -1, -1, -1},
} {// Dynamic shapes instances
}, {1, 16, 1, 1, 1},
{ {8, 16, 1, 7, 1}}}}};
{ // Origin dynamic shapes std::vector<std::vector<int64_t>> targetShapes5D{{8, 16, 1, 7, 1}, {8, 16, 10, 7, 4}};
{-1, -1, -1, -1, -1},
{ // Dynamic shapes instances
{1, 16, 1, 1, 1},
{8, 16, 1, 7, 1}
}
}
}
};
std::vector<std::vector<int64_t>> targetShapes5D {
{8, 16, 1, 7, 1},
{8, 16, 10, 7, 4}
};
const std::vector<CPUSpecificParams> CPUParams5D = { const std::vector<CPUSpecificParams> CPUParams5D = {
cpuParams_nCdhw16c, cpuParams_nCdhw16c,
cpuParams_nCdhw8c, cpuParams_nCdhw8c,
cpuParams_ndhwc, cpuParams_ndhwc,
}; };
INSTANTIATE_TEST_CASE_P(smoke_StaticShape5D, BroadcastLayerCPUTest, INSTANTIATE_TEST_CASE_P(smoke_StaticShape5D,
::testing::Combine( BroadcastLayerCPUTest,
::testing::Combine( ::testing::Combine(::testing::Combine(::testing::ValuesIn(staticInputShapes5D),
::testing::ValuesIn(staticInputShapes5D), ::testing::ValuesIn(std::vector<std::vector<int64_t>>{
::testing::ValuesIn(std::vector<std::vector<int64_t>>{{1, 16, 1, 1, 3}, {1, 16, 3, 1, 3}}), {1, 16, 1, 1, 3},
::testing::Values(std::vector<int64_t>{}), {1, 16, 3, 1, 3}}),
::testing::Values(ov::op::BroadcastType::NUMPY), ::testing::Values(std::vector<int64_t>{}),
::testing::ValuesIn(inputPrecisions), ::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::Values(std::vector<bool>{true, true}), ::testing::ValuesIn(inputPrecisions),
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::Values(std::vector<bool>{true, true}),
::testing::ValuesIn(CPUParams5D)), ::testing::Values(ov::test::utils::DEVICE_CPU)),
BroadcastLayerCPUTest::getTestCaseName); ::testing::ValuesIn(CPUParams5D)),
BroadcastLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(smoke_StaticShape5DScalar, BroadcastLayerCPUTest, INSTANTIATE_TEST_CASE_P(smoke_StaticShape5DScalar,
::testing::Combine( BroadcastLayerCPUTest,
::testing::Combine( ::testing::Combine(::testing::Combine(::testing::ValuesIn(staticInputShapesScalar),
::testing::ValuesIn(staticInputShapesScalar), ::testing::Values(std::vector<int64_t>{1, 16, 3, 1, 3}),
::testing::Values(std::vector<int64_t>{1, 16, 3, 1, 3}), ::testing::Values(std::vector<int64_t>{}),
::testing::Values(std::vector<int64_t>{}), ::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::Values(ov::op::BroadcastType::NUMPY), ::testing::ValuesIn(inputPrecisions),
::testing::ValuesIn(inputPrecisions), ::testing::Values(std::vector<bool>{true, true}),
::testing::Values(std::vector<bool>{true, true}), ::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), BroadcastLayerCPUTest::getTestCaseName);
BroadcastLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(smoke_DynamicShape5D, BroadcastLayerCPUTest, INSTANTIATE_TEST_CASE_P(smoke_DynamicShape5D,
::testing::Combine( BroadcastLayerCPUTest,
::testing::Combine( ::testing::Combine(::testing::Combine(::testing::ValuesIn(dynamicInputShapes5D),
::testing::ValuesIn(dynamicInputShapes5D), ::testing::ValuesIn(targetShapes5D),
::testing::ValuesIn(targetShapes5D), ::testing::Values(std::vector<int64_t>{}),
::testing::Values(std::vector<int64_t>{}), ::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::Values(ov::op::BroadcastType::NUMPY), ::testing::ValuesIn(inputPrecisions),
::testing::ValuesIn(inputPrecisions), ::testing::ValuesIn(std::vector<std::vector<bool>>{
::testing::ValuesIn(std::vector<std::vector<bool>>{{true, true}, {false, true}}), {true, true},
::testing::Values(ov::test::utils::DEVICE_CPU)), {false, true}}),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), ::testing::Values(ov::test::utils::DEVICE_CPU)),
BroadcastLayerCPUTest::getTestCaseName); ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})),
BroadcastLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(smoke_DynamicShape5DScalar, BroadcastLayerCPUTest, INSTANTIATE_TEST_CASE_P(smoke_DynamicShape5DScalar,
::testing::Combine( BroadcastLayerCPUTest,
::testing::Combine( ::testing::Combine(::testing::Combine(::testing::ValuesIn(dynamicInputShapesScalar),
::testing::ValuesIn(dynamicInputShapesScalar), ::testing::Values(std::vector<int64_t>{8, 16, 1, 1, 7}),
::testing::Values(std::vector<int64_t>{8, 16, 1, 1, 7}), ::testing::Values(std::vector<int64_t>{}),
::testing::Values(std::vector<int64_t>{}), ::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::Values(ov::op::BroadcastType::NUMPY), ::testing::ValuesIn(inputPrecisions),
::testing::ValuesIn(inputPrecisions), ::testing::ValuesIn(std::vector<std::vector<bool>>{
::testing::ValuesIn(std::vector<std::vector<bool>>{{true, true}, {false, true}}), {true, true},
::testing::Values(ov::test::utils::DEVICE_CPU)), {false, true}}),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), ::testing::Values(ov::test::utils::DEVICE_CPU)),
BroadcastLayerCPUTest::getTestCaseName); ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})),
BroadcastLayerCPUTest::getTestCaseName);
// 1D // 1D
const std::vector<std::vector<ov::test::InputShape>> dynamicShapes1D = { const std::vector<std::vector<ov::test::InputShape>> dynamicShapes1D = {{{// Origin dynamic shapes
{ {-1},
{ // Origin dynamic shapes {// Dynamic shapes instances
{-1}, {1},
{ // Dynamic shapes instances {1}}}}};
{1},
{1}
}
}
}
};
INSTANTIATE_TEST_CASE_P(smoke_DynamicShapes1D, BroadcastLayerCPUTest, INSTANTIATE_TEST_CASE_P(smoke_DynamicShapes1D,
::testing::Combine(::testing::Combine( BroadcastLayerCPUTest,
::testing::ValuesIn(dynamicShapes1D), ::testing::Combine(::testing::Combine(::testing::ValuesIn(dynamicShapes1D),
::testing::Values(std::vector<int64_t>{0}), ::testing::Values(std::vector<int64_t>{0}),
::testing::Values(std::vector<int64_t>{}), ::testing::Values(std::vector<int64_t>{}),
::testing::Values(ov::op::BroadcastType::NUMPY), ::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::ValuesIn(inputPrecisions), ::testing::ValuesIn(inputPrecisions),
::testing::ValuesIn(std::vector<std::vector<bool>>{{false, true}}), ::testing::ValuesIn(std::vector<std::vector<bool>>{
::testing::Values(ov::test::utils::DEVICE_CPU)), {false, true}}),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), ::testing::Values(ov::test::utils::DEVICE_CPU)),
BroadcastLayerCPUTest::getTestCaseName); ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})),
BroadcastLayerCPUTest::getTestCaseName);
/* ========= */ /* ========= */
} // namespace } // namespace
} // namespace CPULayerTestsDefinitions } // namespace test
} // namespace ov

View File

@ -3,16 +3,14 @@
// //
#include <common_test_utils/ov_tensor_utils.hpp> #include <common_test_utils/ov_tensor_utils.hpp>
#include "ov_models/builders.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp" #include "shared_test_classes/base/ov_subgraph.hpp"
#include "test_utils/cpu_test_utils.hpp" #include "test_utils/cpu_test_utils.hpp"
using namespace InferenceEngine;
using namespace CPUTestUtils; using namespace CPUTestUtils;
using namespace ngraph::opset3;
using namespace ov::test;
namespace CPULayerTestsDefinitions { namespace ov {
namespace test {
using BucketizeCPUParamsTuple = std::tuple<InputShape, // Data shape using BucketizeCPUParamsTuple = std::tuple<InputShape, // Data shape
InputShape, // Buckets shape InputShape, // Buckets shape
@ -55,17 +53,17 @@ public:
return result.str(); return result.str();
} }
void generate_inputs(const std::vector<ngraph::Shape>& targetInputStaticShapes) override { void generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) override {
inputs.clear(); inputs.clear();
const auto& funcInputs = function->inputs(); const auto& funcInputs = function->inputs();
auto data_size = shape_size(targetInputStaticShapes[0]); auto data_size = shape_size(targetInputStaticShapes[0]);
ov::Tensor tensorData = ov::test::utils::create_and_fill_tensor(funcInputs[0].get_element_type(), ov::Tensor tensorData = ov::test::utils::create_and_fill_tensor(funcInputs[0].get_element_type(),
targetInputStaticShapes[0], targetInputStaticShapes[0],
data_size * 5, data_size * 5,
0, 0,
10, 10,
7235346); 7235346);
ov::Tensor tensorBucket = ov::Tensor tensorBucket =
ov::test::utils::create_and_fill_tensor_unique_sequence(funcInputs[1].get_element_type(), ov::test::utils::create_and_fill_tensor_unique_sequence(funcInputs[1].get_element_type(),
@ -91,14 +89,14 @@ protected:
std::tie(dataShape, bucketsShape, with_right_bound, inDataPrc, inBucketsPrc, netPrc) = this->GetParam(); std::tie(dataShape, bucketsShape, with_right_bound, inDataPrc, inBucketsPrc, netPrc) = this->GetParam();
init_input_shapes({dataShape, bucketsShape}); init_input_shapes({dataShape, bucketsShape});
auto data = std::make_shared<ngraph::op::Parameter>(inDataPrc, inputDynamicShapes[0]); auto data = std::make_shared<ov::op::v0::Parameter>(inDataPrc, inputDynamicShapes[0]);
data->set_friendly_name("a_data"); data->set_friendly_name("a_data");
auto buckets = std::make_shared<ngraph::op::Parameter>(inBucketsPrc, inputDynamicShapes[1]); auto buckets = std::make_shared<ov::op::v0::Parameter>(inBucketsPrc, inputDynamicShapes[1]);
buckets->set_friendly_name("b_buckets"); buckets->set_friendly_name("b_buckets");
auto bucketize = std::make_shared<ngraph::op::v3::Bucketize>(data, buckets, netPrc, with_right_bound); auto bucketize = std::make_shared<ov::op::v3::Bucketize>(data, buckets, netPrc, with_right_bound);
function = std::make_shared<ngraph::Function>(std::make_shared<ngraph::opset1::Result>(bucketize), function = std::make_shared<ov::Model>(std::make_shared<ov::op::v0::Result>(bucketize),
ngraph::ParameterVector{data, buckets}, ov::ParameterVector{data, buckets},
"Bucketize"); "Bucketize");
} }
}; };
@ -109,11 +107,11 @@ TEST_P(BucketizeLayerCPUTest, CompareWithRefs) {
namespace { namespace {
const std::vector<ov::test::InputShape> dataShapesDynamic = { const std::vector<ov::test::InputShape> dataShapesDynamic = {
{{ngraph::Dimension(1, 10), ngraph::Dimension::dynamic(), ngraph::Dimension::dynamic()}, {{ov::Dimension(1, 10), ov::Dimension::dynamic(), ov::Dimension::dynamic()},
{{1, 20, 20}, {3, 16, 16}, {10, 16, 16}}}, {{1, 20, 20}, {3, 16, 16}, {10, 16, 16}}},
{{ngraph::Dimension(1, 10), 3, 50, 50}, {{1, 3, 50, 50}, {2, 3, 50, 50}, {10, 3, 50, 50}}}}; {{ov::Dimension(1, 10), 3, 50, 50}, {{1, 3, 50, 50}, {2, 3, 50, 50}, {10, 3, 50, 50}}}};
const std::vector<ov::test::InputShape> bucketsShapesDynamic = {{{ngraph::Dimension::dynamic()}, {{5}, {20}, {100}}}}; const std::vector<ov::test::InputShape> bucketsShapesDynamic = {{{ov::Dimension::dynamic()}, {{5}, {20}, {100}}}};
const std::vector<ov::test::ElementType> inPrc = {ov::element::f32, ov::element::i64, ov::element::i32}; const std::vector<ov::test::ElementType> inPrc = {ov::element::f32, ov::element::i64, ov::element::i32};
const std::vector<ov::test::ElementType> outPrc = {ov::element::i64, ov::element::i32}; const std::vector<ov::test::ElementType> outPrc = {ov::element::i64, ov::element::i32};
@ -142,4 +140,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_TestsBucketize_left_Dynamic,
BucketizeLayerCPUTest::getTestCaseName); BucketizeLayerCPUTest::getTestCaseName);
} // namespace } // namespace
} // namespace CPULayerTestsDefinitions } // namespace test
} // namespace ov

View File

@ -2,35 +2,36 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
#include "test_utils/cpu_test_utils.hpp" #include "common_test_utils/node_builders/eltwise.hpp"
#include "ov_models/builders.hpp" #include "ov_models/builders.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "test_utils/cpu_test_utils.hpp"
using namespace ngraph;
using namespace InferenceEngine;
using namespace CPUTestUtils; using namespace CPUTestUtils;
namespace CPULayerTestsDefinitions { namespace ov {
namespace test {
using ConvertToPluginSpecificNodeParams = std::tuple<SizeVector, // non const input shape using ConvertToPluginSpecificNodeParams = std::tuple<ov::Shape, // non const input shape
SizeVector, // const input shape ov::Shape, // const input shape
Precision, // precision ov::element::Type, // element type
helpers::EltwiseTypes, // node type ov::test::utils::EltwiseTypes, // node type
size_t, // port for const input size_t, // port for const input
size_t>; // expected number of constant node size_t>; // expected number of constant node
class ConvertToPluginSpecificNode : public testing::WithParamInterface<ConvertToPluginSpecificNodeParams>, class ConvertToPluginSpecificNode : public testing::WithParamInterface<ConvertToPluginSpecificNodeParams>,
public LayerTestsUtils::LayerTestsCommon { public SubgraphBaseStaticTest {
public: public:
static std::string getTestCaseName(testing::TestParamInfo<ConvertToPluginSpecificNodeParams> obj) { static std::string getTestCaseName(testing::TestParamInfo<ConvertToPluginSpecificNodeParams> obj) {
SizeVector nonConstShape, constShape; ov::Shape nonConstShape, constShape;
Precision prc; ov::element::Type prc;
helpers::EltwiseTypes nodeType; ov::test::utils::EltwiseTypes nodeType;
size_t port, constNodeNum; size_t port, constNodeNum;
std::tie(nonConstShape, constShape, prc, nodeType, port, constNodeNum) = obj.param; std::tie(nonConstShape, constShape, prc, nodeType, port, constNodeNum) = obj.param;
std::ostringstream result; std::ostringstream result;
result << "IS_NON_CONST=" << ov::test::utils::vec2str(nonConstShape) << "_"; result << "IS_NON_CONST=" << nonConstShape << "_";
result << "IS_CONST=" << ov::test::utils::vec2str(constShape) << "_"; result << "IS_CONST=" << constShape << "_";
result << "PRC=" << prc << "_"; result << "PRC=" << prc << "_";
result << "NODE=" << nodeType << "_"; result << "NODE=" << nodeType << "_";
result << "PORT=" << port << "_"; result << "PORT=" << port << "_";
@ -45,39 +46,36 @@ protected:
void SetUp() override { void SetUp() override {
targetDevice = ov::test::utils::DEVICE_CPU; targetDevice = ov::test::utils::DEVICE_CPU;
SizeVector nonConstShape, constShape; ov::Shape nonConstShape, constShape;
Precision prc; ov::element::Type prc;
helpers::EltwiseTypes nodeType; ov::test::utils::EltwiseTypes nodeType;
size_t port; size_t port;
std::tie(nonConstShape, constShape, prc, nodeType, port, constNodeNum) = this->GetParam(); std::tie(nonConstShape, constShape, prc, nodeType, port, constNodeNum) = this->GetParam();
OPENVINO_ASSERT(shape_size(constShape) == 1); OPENVINO_ASSERT(shape_size(constShape) == 1);
const auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(prc); const auto param = std::make_shared<ov::op::v0::Parameter>(prc, ov::Shape(nonConstShape));
const auto param = std::make_shared<ngraph::opset1::Parameter>(ngPrc, ngraph::Shape(nonConstShape)); const auto constNode = ngraph::builder::makeConstant(prc, constShape, std::vector<float>{}, true);
const auto constNode = builder::makeConstant(ngPrc, ngraph::Shape(constShape), std::vector<float>{}, true);
OutputVector inputs(2); OutputVector inputs(2);
inputs[port] = constNode; inputs[port] = constNode;
inputs[1 - port] = param; inputs[1 - port] = param;
auto powerStatic = ngraph::builder::makeEltwise(inputs[0], inputs[1], nodeType); auto powerStatic = ov::test::utils::makeEltwise(inputs[0], inputs[1], nodeType);
function = std::make_shared<ngraph::Function>(powerStatic, ParameterVector{param}, "ConvertToPluginSpecificNode"); function = std::make_shared<ov::Model>(powerStatic, ParameterVector{param}, "ConvertToPluginSpecificNode");
} }
}; };
TEST_P(ConvertToPluginSpecificNode, CompareWithRefs) { TEST_P(ConvertToPluginSpecificNode, CompareWithRefs) {
Run(); run();
CheckNumberOfNodesWithType(executableNetwork, "Const", constNodeNum); CheckNumberOfNodesWithType(compiledModel, "Const", constNodeNum);
} }
namespace { namespace {
const std::vector<std::vector<size_t>> nonConstIS = { const std::vector<ov::Shape> nonConstIS = {{3, 4, 5, 6}};
{3, 4, 5, 6}
};
const std::vector<std::vector<size_t>> constIS = { const std::vector<ov::Shape> constIS = {
{}, {},
{1}, {1},
{1, 1}, {1, 1},
@ -85,34 +83,37 @@ const std::vector<std::vector<size_t>> constIS = {
{1, 1, 1, 1}, {1, 1, 1, 1},
}; };
std::vector<ngraph::helpers::EltwiseTypes> nodeTypes = { std::vector<ov::test::utils::EltwiseTypes> nodeTypes = {ov::test::utils::EltwiseTypes::ADD,
ngraph::helpers::EltwiseTypes::ADD, ov::test::utils::EltwiseTypes::SUBTRACT,
ngraph::helpers::EltwiseTypes::SUBTRACT, ov::test::utils::EltwiseTypes::MULTIPLY};
ngraph::helpers::EltwiseTypes::MULTIPLY
};
const std::vector<size_t> port = { const std::vector<size_t> port = {0, 1};
0, 1
};
const auto testParamsEltwise = ::testing::Combine(::testing::ValuesIn(nonConstIS), const auto testParamsEltwise = ::testing::Combine(::testing::ValuesIn(nonConstIS),
::testing::ValuesIn(constIS), ::testing::ValuesIn(constIS),
::testing::Values(Precision::FP32), ::testing::Values(ov::element::f32),
::testing::ValuesIn(nodeTypes), ::testing::ValuesIn(nodeTypes),
::testing::ValuesIn(port), ::testing::ValuesIn(port),
::testing::Values(0)); ::testing::Values(0));
INSTANTIATE_TEST_SUITE_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), const auto testParamsPower = ::testing::Combine(::testing::ValuesIn(nonConstIS),
::testing::ValuesIn(constIS), ::testing::ValuesIn(constIS),
::testing::Values(Precision::FP32), ::testing::Values(ov::element::f32),
::testing::Values(ngraph::helpers::EltwiseTypes::POWER), ::testing::Values(ov::test::utils::EltwiseTypes::POWER),
::testing::Values(1), ::testing::Values(1),
::testing::Values(0)); ::testing::Values(0));
INSTANTIATE_TEST_SUITE_P(smoke_CheckPower, ConvertToPluginSpecificNode, testParamsPower, ConvertToPluginSpecificNode::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_CheckPower,
ConvertToPluginSpecificNode,
testParamsPower,
ConvertToPluginSpecificNode::getTestCaseName);
} // namespace } // namespace
} // namespace CPULayerTestsDefinitions } // namespace test
} // namespace ov