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

View File

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

View File

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

View File

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

View File

@ -2,30 +2,30 @@
// 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 "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;
namespace CPULayerTestsDefinitions {
namespace ov {
namespace test {
using BroadcastLayerTestParamsSet = typename std::tuple<
std::vector<ov::test::InputShape>, // Shapes
std::vector<int64_t>, // Target shapes
std::vector<int64_t>, // Axes mapping
ov::op::BroadcastType, // Broadcast mode
ov::element::Type_t, // Network precision
std::vector<bool>, // Const inputs
std::string>; // Device name
using BroadcastLayerTestParamsSet = typename std::tuple<std::vector<ov::test::InputShape>, // Shapes
std::vector<int64_t>, // Target shapes
std::vector<int64_t>, // Axes mapping
ov::op::BroadcastType, // Broadcast mode
ov::element::Type_t, // Network precision
std::vector<bool>, // Const inputs
std::string>; // Device name
using BroadcastLayerCPUTestParamsSet = typename std::tuple<
BroadcastLayerTestParamsSet,
CPUSpecificParams>;
using BroadcastLayerCPUTestParamsSet = typename std::tuple<BroadcastLayerTestParamsSet, CPUSpecificParams>;
class BroadcastLayerCPUTest : public testing::WithParamInterface<BroadcastLayerCPUTestParamsSet>,
virtual public ov::test::SubgraphBaseTest, public CPUTestsBase {
virtual public ov::test::SubgraphBaseTest,
public CPUTestsBase {
public:
static std::string getTestCaseName(testing::TestParamInfo<BroadcastLayerCPUTestParamsSet> obj) {
BroadcastLayerTestParamsSet basicParamsSet;
@ -38,7 +38,8 @@ public:
ov::element::Type_t netPrecision;
std::vector<bool> isConstInputs;
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;
result << "IS=(";
@ -51,11 +52,12 @@ public:
result << ov::test::utils::vec2str(item) << "_";
}
}
result << "targetShape=" << ov::test::utils::vec2str(targetShapes) << "_";
result << "axesMapping=" << ov::test::utils::vec2str(axesMapping) << "_";
result << "targetShape=" << ov::test::utils::vec2str(targetShapes) << "_";
result << "axesMapping=" << ov::test::utils::vec2str(axesMapping) << "_";
result << "mode=" << mode << "_";
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 << CPUTestsBase::getTestCaseName(cpuParams);
@ -73,22 +75,23 @@ protected:
ov::op::BroadcastType mode;
ov::element::Type_t netPrecision;
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];
const auto targetShapeRank = targetShape.size();
const auto axesMappingRank = axesMapping.size();
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) {
inputDynamicShapes.push_back(inputShapes.front().first);
if (!isTargetShapeConst) {
inputDynamicShapes.push_back({ static_cast<int64_t>(targetShape.size()) });
inputDynamicShapes.push_back({static_cast<int64_t>(targetShape.size())});
}
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();
@ -96,22 +99,25 @@ protected:
for (size_t i = 0lu; i < targetStaticShapeSize; ++i) {
targetStaticShapes[i].push_back(inputShapes.front().second[i]);
if (!isTargetShapeConst)
targetStaticShapes[i].push_back({ targetShape.size() });
targetStaticShapes[i].push_back({targetShape.size()});
if (!isAxesMapConst)
targetStaticShapes[i].push_back({ axesMapping.size() });
targetStaticShapes[i].push_back({axesMapping.size()});
}
ov::ParameterVector functionParams;
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 {
functionParams.push_back(std::make_shared<ov::op::v0::Parameter>(netPrecision, inputDynamicShapes.front()));
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");
}
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");
}
}
@ -131,27 +137,21 @@ protected:
} else {
axesMappingOp = functionParams.size() > 2 ? functionParams[2] : functionParams[1];
}
broadcastOp = std::make_shared<ov::op::v3::Broadcast>(functionParams[0],
targetShapeOp,
axesMappingOp,
mode);
broadcastOp =
std::make_shared<ov::op::v3::Broadcast>(functionParams[0], targetShapeOp, axesMappingOp, mode);
} else if (mode == ov::op::BroadcastType::NUMPY) {
if (isTargetShapeConst) {
auto targetShapeConst = ov::op::v0::Constant::create(ov::element::i64, {targetShapeRank}, targetShape);
broadcastOp = std::make_shared<ov::op::v3::Broadcast>(functionParams[0],
targetShapeConst,
mode);
broadcastOp = std::make_shared<ov::op::v3::Broadcast>(functionParams[0], targetShapeConst, mode);
} else {
broadcastOp = std::make_shared<ov::op::v3::Broadcast>(functionParams[0],
functionParams[1],
mode);
broadcastOp = std::make_shared<ov::op::v3::Broadcast>(functionParams[0], functionParams[1], mode);
}
}
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();
const auto& funcInputs = function->inputs();
for (size_t i = 0lu; i < funcInputs.size(); i++) {
@ -171,10 +171,14 @@ protected:
}
} else {
if (funcInput.get_element_type().is_real()) {
tensor = ov::test::utils::create_and_fill_tensor(
funcInput.get_element_type(), targetInputStaticShapes[i], 10, 0, 1000);
tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(),
targetInputStaticShapes[i],
10,
0,
1000);
} 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});
@ -192,277 +196,225 @@ TEST_P(BroadcastLayerCPUTest, CompareWithRefs) {
namespace {
/* CPU PARAMS */
const auto cpuParams_nChw16c = CPUSpecificParams {{nChw16c}, {nChw16c}, {}, "ref"};
const auto cpuParams_nCdhw16c = CPUSpecificParams {{nCdhw16c}, {nCdhw16c}, {}, "ref"};
const auto cpuParams_nChw16c = CPUSpecificParams{{nChw16c}, {nChw16c}, {}, "ref"};
const auto cpuParams_nCdhw16c = CPUSpecificParams{{nCdhw16c}, {nCdhw16c}, {}, "ref"};
const auto cpuParams_nChw8c = CPUSpecificParams {{nChw8c}, {nChw8c}, {}, "ref"};
const auto cpuParams_nCdhw8c = CPUSpecificParams {{nCdhw8c}, {nCdhw8c}, {}, "ref"};
const auto cpuParams_nChw8c = CPUSpecificParams{{nChw8c}, {nChw8c}, {}, "ref"};
const auto cpuParams_nCdhw8c = CPUSpecificParams{{nCdhw8c}, {nCdhw8c}, {}, "ref"};
const auto cpuParams_nhwc = CPUSpecificParams {{nhwc}, {nhwc}, {}, "ref"};
const auto cpuParams_ndhwc = CPUSpecificParams {{ndhwc}, {ndhwc}, {}, "ref"};
const auto cpuParams_nhwc = CPUSpecificParams{{nhwc}, {nhwc}, {}, "ref"};
const auto cpuParams_ndhwc = CPUSpecificParams{{ndhwc}, {ndhwc}, {}, "ref"};
/* ========== */
/* COMMON PARAMS */
const std::vector<ov::element::Type_t> inputPrecisions = {
ov::element::f32,
ov::element::bf16,
ov::element::i32,
ov::element::i8
};
const std::vector<ov::element::Type_t> inputPrecisions = {ov::element::f32,
ov::element::bf16,
ov::element::i32,
ov::element::i8};
/* ============= */
/* INSTANCES */
// 4D
const std::vector<CPUSpecificParams> CPUParams4D = {
cpuParams_nChw16c,
cpuParams_nChw8c,
cpuParams_nhwc
};
const std::vector<CPUSpecificParams> CPUParams4D = {cpuParams_nChw16c, cpuParams_nChw8c, cpuParams_nhwc};
const std::vector<std::vector<ov::test::InputShape>> staticInputShapes4D = {
{
{{},
{ // Static shapes
{1, 16, 1, 1}
}
}
},
{
{{},
{ // Static shapes
{50, 50}
}
}
}
};
const std::vector<std::vector<ov::test::InputShape>> staticInputShapes4D = {{{{},
{// Static shapes
{1, 16, 1, 1}}}},
{{{},
{// Static shapes
{50, 50}}}}};
INSTANTIATE_TEST_CASE_P(smoke_StaticShape4D, BroadcastLayerCPUTest,
::testing::Combine(
::testing::Combine(
::testing::Values(staticInputShapes4D[0]),
::testing::ValuesIn(std::vector<std::vector<int64_t>>{{1, 16, 3, 3}, {1, 16, 1, 3}}),
::testing::Values(std::vector<int64_t>{}),
::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::ValuesIn(inputPrecisions),
::testing::Values(std::vector<bool>{true, true}),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::ValuesIn(CPUParams4D)),
BroadcastLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(smoke_StaticShape4D,
BroadcastLayerCPUTest,
::testing::Combine(::testing::Combine(::testing::Values(staticInputShapes4D[0]),
::testing::ValuesIn(std::vector<std::vector<int64_t>>{
{1, 16, 3, 3},
{1, 16, 1, 3}}),
::testing::Values(std::vector<int64_t>{}),
::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::ValuesIn(inputPrecisions),
::testing::Values(std::vector<bool>{true, true}),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::ValuesIn(CPUParams4D)),
BroadcastLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(smoke_StaticShape4DE, BroadcastLayerCPUTest,
::testing::Combine(
::testing::Combine(
::testing::Values(staticInputShapes4D[1]),
::testing::Values(std::vector<int64_t>{1, 50, 50, 16}),
::testing::Values(std::vector<int64_t>{1, 2}),
::testing::Values(ov::op::BroadcastType::EXPLICIT),
::testing::ValuesIn(inputPrecisions),
::testing::Values(std::vector<bool>{true, true}),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})),
BroadcastLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(smoke_StaticShape4DE,
BroadcastLayerCPUTest,
::testing::Combine(::testing::Combine(::testing::Values(staticInputShapes4D[1]),
::testing::Values(std::vector<int64_t>{1, 50, 50, 16}),
::testing::Values(std::vector<int64_t>{1, 2}),
::testing::Values(ov::op::BroadcastType::EXPLICIT),
::testing::ValuesIn(inputPrecisions),
::testing::Values(std::vector<bool>{true, true}),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})),
BroadcastLayerCPUTest::getTestCaseName);
const std::vector<std::vector<ov::test::InputShape>> staticInputShapesScalar = {
{
{{},
{ // Static shapes
{1}
}
}
}
};
const std::vector<std::vector<ov::test::InputShape>> staticInputShapesScalar = {{{{},
{// Static shapes
{1}}}}};
INSTANTIATE_TEST_CASE_P(smoke_StaticShape4DScalar, BroadcastLayerCPUTest,
::testing::Combine(
::testing::Combine(
::testing::ValuesIn(staticInputShapesScalar),
::testing::Values(std::vector<int64_t>{1, 16, 3, 3}),
::testing::Values(std::vector<int64_t>{}),
::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::ValuesIn(inputPrecisions),
::testing::Values(std::vector<bool>{true, true}),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})),
BroadcastLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(smoke_StaticShape4DScalar,
BroadcastLayerCPUTest,
::testing::Combine(::testing::Combine(::testing::ValuesIn(staticInputShapesScalar),
::testing::Values(std::vector<int64_t>{1, 16, 3, 3}),
::testing::Values(std::vector<int64_t>{}),
::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::ValuesIn(inputPrecisions),
::testing::Values(std::vector<bool>{true, true}),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})),
BroadcastLayerCPUTest::getTestCaseName);
const std::vector<std::vector<ov::test::InputShape>> dynamicInputShapes4D = {
{
{ // Origin dynamic shapes
{ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20)},
{ // Dynamic shapes instances
{1, 16, 1, 1},
{8, 1, 1, 7},
{1, 1, 1, 7}
}
},
{// Origin dynamic shapes
{ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20)},
{// Dynamic shapes instances
{1, 16, 1, 1},
{8, 1, 1, 7},
{1, 1, 1, 7}}},
},
{
{ // Origin dynamic shapes
{-1, -1, -1, -1},
{ // Dynamic shapes instances
{{1, 16, 1, 1}},
{{8, 1, 1, 1}}
}
}
}
};
{{// Origin dynamic shapes
{-1, -1, -1, -1},
{// Dynamic shapes instances
{{1, 16, 1, 1}},
{{8, 1, 1, 1}}}}}};
INSTANTIATE_TEST_CASE_P(smoke_DynamicShape4D, BroadcastLayerCPUTest,
::testing::Combine(::testing::Combine(
::testing::ValuesIn(dynamicInputShapes4D),
::testing::ValuesIn(std::vector<std::vector<int64_t>>{{8, 16, 1, 7}, {8, 16, 10, 7}}),
::testing::Values(std::vector<int64_t>{}),
::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::ValuesIn(inputPrecisions),
::testing::ValuesIn(std::vector<std::vector<bool>>{{true, true}, {false, true}}),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})),
BroadcastLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(
smoke_DynamicShape4D,
BroadcastLayerCPUTest,
::testing::Combine(
::testing::Combine(::testing::ValuesIn(dynamicInputShapes4D),
::testing::ValuesIn(std::vector<std::vector<int64_t>>{{8, 16, 1, 7}, {8, 16, 10, 7}}),
::testing::Values(std::vector<int64_t>{}),
::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::ValuesIn(inputPrecisions),
::testing::ValuesIn(std::vector<std::vector<bool>>{{true, true}, {false, true}}),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})),
BroadcastLayerCPUTest::getTestCaseName);
const std::vector<std::vector<ov::test::InputShape>> dynamicInputShapesScalar = {
{
{ // Origin dynamic shapes
{-1},
{ // Dynamic shapes instances
{1},
{7}
}
}
}
};
const std::vector<std::vector<ov::test::InputShape>> dynamicInputShapesScalar = {{{// Origin dynamic shapes
{-1},
{// Dynamic shapes instances
{1},
{7}}}}};
INSTANTIATE_TEST_CASE_P(smoke_DynamicShape4DScalar, BroadcastLayerCPUTest,
::testing::Combine(::testing::Combine(
::testing::ValuesIn(dynamicInputShapesScalar),
::testing::Values(std::vector<int64_t>{8, 16, 1, 7}),
::testing::Values(std::vector<int64_t>{}),
::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::ValuesIn(inputPrecisions),
::testing::ValuesIn(std::vector<std::vector<bool>>{{true, true}, {false, true}}),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})),
BroadcastLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(smoke_DynamicShape4DScalar,
BroadcastLayerCPUTest,
::testing::Combine(::testing::Combine(::testing::ValuesIn(dynamicInputShapesScalar),
::testing::Values(std::vector<int64_t>{8, 16, 1, 7}),
::testing::Values(std::vector<int64_t>{}),
::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::ValuesIn(inputPrecisions),
::testing::ValuesIn(std::vector<std::vector<bool>>{
{true, true},
{false, true}}),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})),
BroadcastLayerCPUTest::getTestCaseName);
// 5D
const std::vector<std::vector<ov::test::InputShape>> staticInputShapes5D = {
{
{{},
{ // Static shapes
{1, 16, 1, 1, 1}
}
}
}
};
const std::vector<std::vector<ov::test::InputShape>> staticInputShapes5D = {{{{},
{// Static shapes
{1, 16, 1, 1, 1}}}}};
const std::vector<std::vector<ov::test::InputShape>> dynamicInputShapes5D = {
{
{ // Origin dynamic shapes
{ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20)},
{ // Dynamic shapes instances
{1, 16, 1, 1, 1},
{8, 1, 1, 7, 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}
}
}
}
};
std::vector<std::vector<int64_t>> targetShapes5D {
{8, 16, 1, 7, 1},
{8, 16, 10, 7, 4}
};
{{// Origin dynamic shapes
{ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20)},
{// Dynamic shapes instances
{1, 16, 1, 1, 1},
{8, 1, 1, 7, 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}}}}};
std::vector<std::vector<int64_t>> targetShapes5D{{8, 16, 1, 7, 1}, {8, 16, 10, 7, 4}};
const std::vector<CPUSpecificParams> CPUParams5D = {
cpuParams_nCdhw16c,
cpuParams_nCdhw8c,
cpuParams_ndhwc,
cpuParams_nCdhw16c,
cpuParams_nCdhw8c,
cpuParams_ndhwc,
};
INSTANTIATE_TEST_CASE_P(smoke_StaticShape5D, BroadcastLayerCPUTest,
::testing::Combine(
::testing::Combine(
::testing::ValuesIn(staticInputShapes5D),
::testing::ValuesIn(std::vector<std::vector<int64_t>>{{1, 16, 1, 1, 3}, {1, 16, 3, 1, 3}}),
::testing::Values(std::vector<int64_t>{}),
::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::ValuesIn(inputPrecisions),
::testing::Values(std::vector<bool>{true, true}),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::ValuesIn(CPUParams5D)),
BroadcastLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(smoke_StaticShape5D,
BroadcastLayerCPUTest,
::testing::Combine(::testing::Combine(::testing::ValuesIn(staticInputShapes5D),
::testing::ValuesIn(std::vector<std::vector<int64_t>>{
{1, 16, 1, 1, 3},
{1, 16, 3, 1, 3}}),
::testing::Values(std::vector<int64_t>{}),
::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::ValuesIn(inputPrecisions),
::testing::Values(std::vector<bool>{true, true}),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::ValuesIn(CPUParams5D)),
BroadcastLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(smoke_StaticShape5DScalar, BroadcastLayerCPUTest,
::testing::Combine(
::testing::Combine(
::testing::ValuesIn(staticInputShapesScalar),
::testing::Values(std::vector<int64_t>{1, 16, 3, 1, 3}),
::testing::Values(std::vector<int64_t>{}),
::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::ValuesIn(inputPrecisions),
::testing::Values(std::vector<bool>{true, true}),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})),
BroadcastLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(smoke_StaticShape5DScalar,
BroadcastLayerCPUTest,
::testing::Combine(::testing::Combine(::testing::ValuesIn(staticInputShapesScalar),
::testing::Values(std::vector<int64_t>{1, 16, 3, 1, 3}),
::testing::Values(std::vector<int64_t>{}),
::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::ValuesIn(inputPrecisions),
::testing::Values(std::vector<bool>{true, true}),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})),
BroadcastLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(smoke_DynamicShape5D, BroadcastLayerCPUTest,
::testing::Combine(
::testing::Combine(
::testing::ValuesIn(dynamicInputShapes5D),
::testing::ValuesIn(targetShapes5D),
::testing::Values(std::vector<int64_t>{}),
::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::ValuesIn(inputPrecisions),
::testing::ValuesIn(std::vector<std::vector<bool>>{{true, true}, {false, true}}),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})),
BroadcastLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(smoke_DynamicShape5D,
BroadcastLayerCPUTest,
::testing::Combine(::testing::Combine(::testing::ValuesIn(dynamicInputShapes5D),
::testing::ValuesIn(targetShapes5D),
::testing::Values(std::vector<int64_t>{}),
::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::ValuesIn(inputPrecisions),
::testing::ValuesIn(std::vector<std::vector<bool>>{
{true, true},
{false, true}}),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})),
BroadcastLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(smoke_DynamicShape5DScalar, BroadcastLayerCPUTest,
::testing::Combine(
::testing::Combine(
::testing::ValuesIn(dynamicInputShapesScalar),
::testing::Values(std::vector<int64_t>{8, 16, 1, 1, 7}),
::testing::Values(std::vector<int64_t>{}),
::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::ValuesIn(inputPrecisions),
::testing::ValuesIn(std::vector<std::vector<bool>>{{true, true}, {false, true}}),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})),
BroadcastLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(smoke_DynamicShape5DScalar,
BroadcastLayerCPUTest,
::testing::Combine(::testing::Combine(::testing::ValuesIn(dynamicInputShapesScalar),
::testing::Values(std::vector<int64_t>{8, 16, 1, 1, 7}),
::testing::Values(std::vector<int64_t>{}),
::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::ValuesIn(inputPrecisions),
::testing::ValuesIn(std::vector<std::vector<bool>>{
{true, true},
{false, true}}),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})),
BroadcastLayerCPUTest::getTestCaseName);
// 1D
const std::vector<std::vector<ov::test::InputShape>> dynamicShapes1D = {
{
{ // Origin dynamic shapes
{-1},
{ // Dynamic shapes instances
{1},
{1}
}
}
}
};
const std::vector<std::vector<ov::test::InputShape>> dynamicShapes1D = {{{// Origin dynamic shapes
{-1},
{// Dynamic shapes instances
{1},
{1}}}}};
INSTANTIATE_TEST_CASE_P(smoke_DynamicShapes1D, BroadcastLayerCPUTest,
::testing::Combine(::testing::Combine(
::testing::ValuesIn(dynamicShapes1D),
::testing::Values(std::vector<int64_t>{0}),
::testing::Values(std::vector<int64_t>{}),
::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::ValuesIn(inputPrecisions),
::testing::ValuesIn(std::vector<std::vector<bool>>{{false, true}}),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})),
BroadcastLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(smoke_DynamicShapes1D,
BroadcastLayerCPUTest,
::testing::Combine(::testing::Combine(::testing::ValuesIn(dynamicShapes1D),
::testing::Values(std::vector<int64_t>{0}),
::testing::Values(std::vector<int64_t>{}),
::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::ValuesIn(inputPrecisions),
::testing::ValuesIn(std::vector<std::vector<bool>>{
{false, true}}),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::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 "ov_models/builders.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "test_utils/cpu_test_utils.hpp"
using namespace InferenceEngine;
using namespace CPUTestUtils;
using namespace ngraph::opset3;
using namespace ov::test;
namespace CPULayerTestsDefinitions {
namespace ov {
namespace test {
using BucketizeCPUParamsTuple = std::tuple<InputShape, // Data shape
InputShape, // Buckets shape
@ -55,17 +53,17 @@ public:
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();
const auto& funcInputs = function->inputs();
auto data_size = shape_size(targetInputStaticShapes[0]);
ov::Tensor tensorData = ov::test::utils::create_and_fill_tensor(funcInputs[0].get_element_type(),
targetInputStaticShapes[0],
data_size * 5,
0,
10,
7235346);
targetInputStaticShapes[0],
data_size * 5,
0,
10,
7235346);
ov::Tensor tensorBucket =
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();
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");
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");
auto bucketize = std::make_shared<ngraph::op::v3::Bucketize>(data, buckets, netPrc, with_right_bound);
function = std::make_shared<ngraph::Function>(std::make_shared<ngraph::opset1::Result>(bucketize),
ngraph::ParameterVector{data, buckets},
"Bucketize");
auto bucketize = std::make_shared<ov::op::v3::Bucketize>(data, buckets, netPrc, with_right_bound);
function = std::make_shared<ov::Model>(std::make_shared<ov::op::v0::Result>(bucketize),
ov::ParameterVector{data, buckets},
"Bucketize");
}
};
@ -109,11 +107,11 @@ TEST_P(BucketizeLayerCPUTest, CompareWithRefs) {
namespace {
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}}},
{{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> outPrc = {ov::element::i64, ov::element::i32};
@ -142,4 +140,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_TestsBucketize_left_Dynamic,
BucketizeLayerCPUTest::getTestCaseName);
} // namespace
} // namespace CPULayerTestsDefinitions
} // namespace test
} // namespace ov

View File

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