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

This commit is contained in:
River Li authored and GitHub committed 2023-12-08 14:43:39 +04:00
1 parent 04db11e921
commit c565bf0c37
11 files changed
+272 -284

No files matched your search

@@ -5,7 +5,6 @@
#include "eltwise.hpp"
#include "common_test_utils/node_builders/eltwise.hpp"
#include "cpp_interfaces/interface/ie_internal_plugin_config.hpp"
#include "gtest/gtest.h"
#include "openvino/core/type/element_type.hpp"
#include "openvino/runtime/properties.hpp"
@@ -7,7 +7,6 @@
#include "openvino/core/type/element_type.hpp"
#include "openvino/runtime/properties.hpp"
#include "test_utils/cpu_test_utils.hpp"
#include "cpp_interfaces/interface/ie_internal_plugin_config.hpp"
#include "common_test_utils/ov_tensor_utils.hpp"
using namespace CPUTestUtils;
@@ -3,32 +3,29 @@
//
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "ov_models/builders.hpp"
#include "test_utils/cpu_test_utils.hpp"
#include <common_test_utils/ov_tensor_utils.hpp>
#include <openvino/opsets/opset9.hpp>
#include "common_test_utils/ov_tensor_utils.hpp"
using namespace CPUTestUtils;
using namespace ov::test;
using namespace ov;
namespace CPULayerTestsDefinitions {
namespace ov {
namespace test {
std::vector<element::Type> precisions{element::f32};
std::vector<ov::element::Type> precisions{ov::element::f32};
using RDFTTestCPUParams = std::tuple<std::vector<InputShape>,
std::vector<std::vector<int64_t>>, // axes
std::vector<std::vector<int64_t>>, // signal sizes
bool, // inverse
bool, // const axes if true
bool, // const signal sizes if true
bool, // inverse
bool, // const axes if true
bool, // const signal sizes if true
CPUSpecificParams>;
class RDFTTestCPU : public testing::WithParamInterface<std::tuple<element::Type, RDFTTestCPUParams>>,
class RDFTTestCPU : public testing::WithParamInterface<std::tuple<ov::element::Type, RDFTTestCPUParams>>,
virtual public test::SubgraphBaseTest, public CPUTestsBase {
public:
static std::string getTestCaseName(testing::TestParamInfo<std::tuple<element::Type, RDFTTestCPUParams>> obj) {
element::Type precision;
static std::string getTestCaseName(testing::TestParamInfo<std::tuple<ov::element::Type, RDFTTestCPUParams>> obj) {
ov::element::Type precision;
RDFTTestCPUParams params;
std::vector<InputShape> shapes;
std::vector<std::vector<int64_t>> axes;
@@ -76,7 +73,7 @@ public:
protected:
void SetUp() override {
element::Type precision;
ov::element::Type precision;
RDFTTestCPUParams params;
std::vector<InputShape> shapes;
bool inverse;
@@ -113,14 +110,14 @@ protected:
auto inputShapeIt = inputDynamicShapes.begin();
ParameterVector inputs;
auto param = std::make_shared<opset9::Parameter>(precision, *inputShapeIt++);
auto param = std::make_shared<ov::op::v0::Parameter>(precision, *inputShapeIt++);
inputs.push_back(param);
std::shared_ptr<Node> axesNode;
if (constAxes) {
axesNode = opset9::Constant::create(element::i64, Shape{axes[0].size()}, axes[0]);
axesNode = ov::op::v0::Constant::create(element::i64, Shape{axes[0].size()}, axes[0]);
} else {
ASSERT_NE(inputShapeIt, inputDynamicShapes.end());
auto param = std::make_shared<opset9::Parameter>(element::i64, *inputShapeIt++);
auto param = std::make_shared<ov::op::v0::Parameter>(element::i64, *inputShapeIt++);
axesNode = param;
inputs.push_back(param);
}
@@ -129,23 +126,23 @@ protected:
if (signalSizes.size() > 0) {
std::shared_ptr<Node> signalSizesNode;
if (constSignalSizes) {
signalSizesNode = opset9::Constant::create(element::i64, Shape{signalSizes[0].size()}, signalSizes[0]);
signalSizesNode = ov::op::v0::Constant::create(element::i64, Shape{signalSizes[0].size()}, signalSizes[0]);
} else {
ASSERT_NE(inputShapeIt, inputDynamicShapes.end());
auto param = std::make_shared<opset9::Parameter>(element::i64, *inputShapeIt);
auto param = std::make_shared<ov::op::v0::Parameter>(element::i64, *inputShapeIt);
signalSizesNode = param;
inputs.push_back(param);
}
if (inverse) {
rdft = std::make_shared<opset9::IRDFT>(param, axesNode, signalSizesNode);
rdft = std::make_shared<ov::op::v9::IRDFT>(param, axesNode, signalSizesNode);
} else {
rdft = std::make_shared<opset9::RDFT>(param, axesNode, signalSizesNode);
rdft = std::make_shared<ov::op::v9::RDFT>(param, axesNode, signalSizesNode);
}
} else {
if (inverse) {
rdft = std::make_shared<opset9::IRDFT>(param, axesNode);
rdft = std::make_shared<ov::op::v9::IRDFT>(param, axesNode);
} else {
rdft = std::make_shared<opset9::RDFT>(param, axesNode);
rdft = std::make_shared<ov::op::v9::RDFT>(param, axesNode);
}
}
function = std::make_shared<Model>(rdft, inputs);
@@ -191,11 +188,11 @@ TEST_P(RDFTTestCPU, CompareWithRefs) {
namespace {
CPUSpecificParams getCPUSpecificParams() {
if (InferenceEngine::with_cpu_x86_avx512_core()) {
if (ov::with_cpu_x86_avx512_core()) {
return CPUSpecificParams{{}, {}, {"jit_avx512"}, "jit_avx512"};
} else if (InferenceEngine::with_cpu_x86_avx2()) {
} else if (ov::with_cpu_x86_avx2()) {
return CPUSpecificParams{{}, {}, {"jit_avx2"}, "jit_avx2"};
} else if (InferenceEngine::with_cpu_x86_sse42()) {
} else if (ov::with_cpu_x86_sse42()) {
return CPUSpecificParams{{}, {}, {"jit_sse42"}, "jit_sse42"};
} else {
return CPUSpecificParams{{}, {}, {"ref"}, "ref"};
@@ -206,7 +203,7 @@ CPUSpecificParams getCPUSpecificParams() {
auto cpuParams = getCPUSpecificParams();
std::vector<RDFTTestCPUParams> getParams1D() {
if (InferenceEngine::with_cpu_x86_avx512_core()) {
if (ov::with_cpu_x86_avx512_core()) {
return {
{static_shapes_to_test_representation({Shape{14}}), {{0}}, {}, false, true, true, cpuParams},
{static_shapes_to_test_representation({Shape{13}}), {{0}}, {}, false, true, true, cpuParams},
@@ -243,7 +240,7 @@ std::vector<RDFTTestCPUParams> getParams1D() {
{static_shapes_to_test_representation({Shape{25, 2}}), {{0}}, {{32}}, true, true, true, cpuParams},
{static_shapes_to_test_representation({Shape{24, 2}}), {{0}}, {{16}}, true, true, true, cpuParams},
};
} else if (InferenceEngine::with_cpu_x86_avx2()) {
} else if (ov::with_cpu_x86_avx2()) {
return {
{static_shapes_to_test_representation({Shape{6}}), {{0}}, {}, false, true, true, cpuParams},
{static_shapes_to_test_representation({Shape{5}}), {{0}}, {}, false, true, true, cpuParams},
@@ -312,13 +309,13 @@ std::vector<RDFTTestCPUParams> getParams1D() {
return {};
}
INSTANTIATE_TEST_SUITE_P(smoke_RDFT_CPU_1D, RDFTTestCPU,
::testing::Combine(::testing::ValuesIn(precisions),
::testing::ValuesIn(getParams1D())),
INSTANTIATE_TEST_SUITE_P(smoke_RDFT_CPU_1D,
RDFTTestCPU,
::testing::Combine(::testing::ValuesIn(precisions), ::testing::ValuesIn(getParams1D())),
RDFTTestCPU::getTestCaseName);
std::vector<RDFTTestCPUParams> getParams2D() {
if (InferenceEngine::with_cpu_x86_avx512_core()) {
if (ov::with_cpu_x86_avx512_core()) {
return {
{static_shapes_to_test_representation({{46, 10}}), {{0}}, {}, false, true, true, cpuParams},
{static_shapes_to_test_representation({{45, 10}}), {{0}}, {}, false, true, true, cpuParams},
@@ -360,7 +357,7 @@ std::vector<RDFTTestCPUParams> getParams2D() {
{static_shapes_to_test_representation({{32, 513, 2}}), {{0, 1}}, {{32, 600}}, true, true, true, cpuParams},
{static_shapes_to_test_representation({{72, 1025, 2}}), {{0, 1}}, {{72, 100}}, true, true, true, cpuParams},
};
} else if (InferenceEngine::with_cpu_x86_avx2()) {
} else if (ov::with_cpu_x86_avx2()) {
return {
{static_shapes_to_test_representation({{38, 16}}), {{0}}, {}, false, true, true, cpuParams},
{static_shapes_to_test_representation({{37, 8}}), {{0}}, {}, false, true, true, cpuParams},
@@ -460,14 +457,14 @@ std::vector<RDFTTestCPUParams> getParams2D() {
return {};
}
INSTANTIATE_TEST_SUITE_P(smoke_RDFT_CPU_2D, RDFTTestCPU,
::testing::Combine(::testing::ValuesIn(precisions),
::testing::ValuesIn(getParams2D())),
INSTANTIATE_TEST_SUITE_P(smoke_RDFT_CPU_2D,
RDFTTestCPU,
::testing::Combine(::testing::ValuesIn(precisions), ::testing::ValuesIn(getParams2D())),
RDFTTestCPU::getTestCaseName);
std::vector<RDFTTestCPUParams> getParams4D() {
std::vector<RDFTTestCPUParams> params;
if (InferenceEngine::with_cpu_x86_avx512_core()) {
if (ov::with_cpu_x86_avx512_core()) {
params = {
{static_shapes_to_test_representation({{10, 46, 128, 65}}), {{1}}, {}, false, true, true, cpuParams},
{static_shapes_to_test_representation({{10, 46, 128, 65}}), {{0, 1}}, {}, false, true, true, cpuParams},
@@ -488,7 +485,7 @@ std::vector<RDFTTestCPUParams> getParams4D() {
// TODO: FIXME
//{static_shapes_to_test_representation({{46, 10, 128, 65, 2}}), {{0, 1, 2, 3}, {12, 15, 130, 40}, true, true, true, cpuParams},
};
} else if (InferenceEngine::with_cpu_x86_avx2()) {
} else if (ov::with_cpu_x86_avx2()) {
params = {
{static_shapes_to_test_representation({{9, 16, 32, 126}}), {{1}}, {}, false, true, true, cpuParams},
{static_shapes_to_test_representation({{9, 16, 32, 126}}), {{1, 0}}, {}, false, true, true, cpuParams},
@@ -593,10 +590,11 @@ std::vector<RDFTTestCPUParams> getParams4D() {
return params;
}
INSTANTIATE_TEST_SUITE_P(smoke_RDFT_CPU_4D, RDFTTestCPU,
::testing::Combine(::testing::ValuesIn(precisions),
::testing::ValuesIn(getParams4D())),
INSTANTIATE_TEST_SUITE_P(smoke_RDFT_CPU_4D,
RDFTTestCPU,
::testing::Combine(::testing::ValuesIn(precisions), ::testing::ValuesIn(getParams4D())),
RDFTTestCPU::getTestCaseName);
} // namespace
} // namespace CPULayerTestsDefinitions
} // namespace
} // namespace test
} // namespace ov
@@ -2,15 +2,13 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "ov_models/builders.hpp"
#include "test_utils/cpu_test_utils.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
using namespace InferenceEngine;
using namespace CPUTestUtils;
namespace CPULayerTestsDefinitions {
using namespace ov::test;
namespace ov {
namespace test {
struct regionYoloAttributes {
size_t classes;
@@ -21,15 +19,13 @@ struct regionYoloAttributes {
int end_axis;
};
using regionYoloParamsTuple = std::tuple<
InputShape, // Input Shape
regionYoloAttributes, // Params
std::vector<int64_t>, // mask
ov::test::ElementType, // Network input precision
ov::test::ElementType, // Network output precision
std::map<std::string, std::string>, // Additional network configuration
std::string>; // Device name
using regionYoloParamsTuple = std::tuple<InputShape, // Input Shape
regionYoloAttributes, // Params
std::vector<int64_t>, // mask
ov::test::ElementType, // Network input precision
ov::test::ElementType, // Network output precision
ov::AnyMap, // Additional network configuration
std::string>; // Device name
class RegionYoloCPULayerTest : public testing::WithParamInterface<regionYoloParamsTuple>,
virtual public ov::test::SubgraphBaseTest, public CPUTestsBase {
@@ -41,7 +37,7 @@ public:
ov::test::ElementType inpPrecision;
ov::test::ElementType outPrecision;
std::string targetName;
std::map<std::string, std::string> additionalConfig;
ov::AnyMap additionalConfig;
std::tie(inputShape, attributes, mask, inpPrecision, outPrecision, additionalConfig, targetName) = obj.param;
@@ -65,7 +61,7 @@ protected:
std::vector<int64_t> mask;
ov::test::ElementType inPrc;
ov::test::ElementType outPrc;
std::map<std::string, std::string> additionalConfig;
ov::AnyMap additionalConfig;
std::tie(inputShape, attributes, mask, inPrc, outPrc, additionalConfig, targetDevice) = this->GetParam();
@@ -78,14 +74,19 @@ protected:
configuration.insert(additionalConfig.begin(), additionalConfig.end());
selectedType = getPrimitiveType() + "_" + InferenceEngine::details::convertPrecision(inPrc).name();
selectedType = getPrimitiveType() + "_" + ov::element::Type(inPrc).to_string();
ov::ParameterVector paramRegionYolo;
for (auto&& shape : inputDynamicShapes) {
paramRegionYolo.push_back(std::make_shared<ov::op::v0::Parameter>(inPrc, shape));
}
const auto region_yolo = std::make_shared<ngraph::op::v0::RegionYolo>(paramRegionYolo[0],
attributes.coordinates, attributes.classes, attributes.num_regions,
attributes.do_softmax, mask, attributes.start_axis, attributes.end_axis);
const auto region_yolo = std::make_shared<ov::op::v0::RegionYolo>(paramRegionYolo[0],
attributes.coordinates,
attributes.classes,
attributes.num_regions,
attributes.do_softmax,
mask,
attributes.start_axis,
attributes.end_axis);
function = makeNgraphFunction(inPrc, paramRegionYolo, region_yolo, "RegionYolo");
}
@@ -99,15 +100,15 @@ TEST_P(RegionYoloCPULayerTest, CompareWithRefs) {
namespace {
const std::vector<ov::test::ElementType> inpOutPrc = {ov::test::ElementType::bf16, ov::test::ElementType::f32};
const std::map<std::string, std::string> additional_config;
const ov::AnyMap additional_config;
/* *======================* Static Shapes *======================* */
const std::vector<ngraph::Shape> inShapes_caffe = {
const std::vector<ov::Shape> inShapes_caffe = {
{1, 125, 13, 13}
};
const std::vector<ngraph::Shape> inShapes_mxnet = {
const std::vector<ov::Shape> inShapes_mxnet = {
{1, 75, 52, 52},
{1, 75, 32, 32},
{1, 75, 26, 26},
@@ -119,7 +120,7 @@ const std::vector<ngraph::Shape> inShapes_mxnet = {
{1, 303, 28, 28},
};
const std::vector<ngraph::Shape> inShapes_v3 = {
const std::vector<ov::Shape> inShapes_v3 = {
{1, 255, 52, 52},
{1, 255, 26, 26},
{1, 255, 13, 13}
@@ -225,5 +226,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_TestsRegionYoloMxnetCPUStatic, RegionYoloCPULayer
INSTANTIATE_TEST_SUITE_P(smoke_TestsRegionYoloMxnetCPUDynamic, RegionYoloCPULayerTest, testCase_yolov3_mxnet_dynamic, RegionYoloCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_TestsRegionYoloCaffeCPUStatic, RegionYoloCPULayerTest, testCase_yolov2_caffe, RegionYoloCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_TestsRegionYoloCaffeCPUDynamic, RegionYoloCPULayerTest, testCase_yolov2_caffe_dynamic, RegionYoloCPULayerTest::getTestCaseName);
} // namespace
} // namespace CPULayerTestsDefinitions
} // namespace
} // namespace test
} // namespace ov
@@ -2,17 +2,14 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <common_test_utils/ov_tensor_utils.hpp>
#include "ov_models/builders.hpp"
#include "common_test_utils/ov_tensor_utils.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 ReorgYoloCPUParamsTuple = typename std::tuple<InputShape, // Input Shape
size_t, // stride
@@ -48,11 +45,11 @@ protected:
init_input_shapes({inputShape});
auto param = std::make_shared<ngraph::op::Parameter>(ngraph::element::f32, inputDynamicShapes[0]);
auto reorg_yolo = std::make_shared<ngraph::op::v0::ReorgYolo>(param, stride);
function = std::make_shared<ngraph::Function>(std::make_shared<ngraph::opset1::Result>(reorg_yolo),
ngraph::ParameterVector{param},
"ReorgYolo");
auto param = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, inputDynamicShapes[0]);
auto reorg_yolo = std::make_shared<ov::op::v0::ReorgYolo>(param, stride);
function = std::make_shared<ov::Model>(std::make_shared<ov::op::v0::Result>(reorg_yolo),
ov::ParameterVector{param},
"ReorgYolo");
}
};
@@ -87,4 +84,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_stride3_DynamicShape,
testCase_stride3_Dynamic,
ReorgYoloLayerCPUTest::getTestCaseName);
}; // namespace CPULayerTestsDefinitions
} // namespace test
} // namespace ov
@@ -2,24 +2,24 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "ov_models/builders.hpp"
#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 "test_utils/cpu_test_utils.hpp"
using namespace CPUTestUtils;
using namespace ov::test;
namespace CPULayerTestsDefinitions {
namespace ov {
namespace test {
using ReverseSequenceCPUTestParams = typename std::tuple<
int64_t, // Index of the batch dimension
int64_t, // Index of the sequence dimension
InputShape, // Input shape
InputShape, // Shape of the input vector with sequence lengths to be reversed
ngraph::helpers::InputLayerType, // Secondary input type
InferenceEngine::Precision, // Network precision
std::string>; // Device name
using ReverseSequenceCPUTestParams =
typename std::tuple<int64_t, // Index of the batch dimension
int64_t, // Index of the sequence dimension
InputShape, // Input shape
InputShape, // Shape of the input vector with sequence lengths to be reversed
utils::InputLayerType, // Secondary input type
ov::element::Type, // Network precision
std::string>; // Device name
class ReverseSequenceLayerCPUTest : public testing::WithParamInterface<ReverseSequenceCPUTestParams>,
virtual public SubgraphBaseTest, public CPUTestsBase {
@@ -27,11 +27,11 @@ public:
static std::string getTestCaseName(testing::TestParamInfo<ReverseSequenceCPUTestParams> obj) {
int64_t batchAxisIndex;
int64_t seqAxisIndex;
InferenceEngine::Precision netPrecision;
ov::element::Type netPrecision;
std::string targetName;
InputShape dataInputShape;
InputShape seqLengthsShape;
ngraph::helpers::InputLayerType secondaryInputType;
utils::InputLayerType secondaryInputType;
std::tie(batchAxisIndex, seqAxisIndex, dataInputShape, seqLengthsShape, secondaryInputType, netPrecision, targetName) = obj.param;
@@ -49,7 +49,7 @@ public:
result << "secondaryInputType=" << secondaryInputType << "_";
result << "batchAxis=" << batchAxisIndex << "_";
result << "seqAxis=" << seqAxisIndex << "_";
result << "netPRC=" << netPrecision.name() << "_";
result << "netPRC=" << netPrecision.to_string() << "_";
result << "targetDevice=" << targetName;
return result.str();
@@ -57,25 +57,24 @@ public:
protected:
void SetUp() override {
InferenceEngine::Precision netPrecision;
ov::element::Type netPrecision;
int64_t batchAxisIndex;
int64_t seqAxisIndex;
InputShape dataInputShape;
InputShape seqLengthsShape;
ngraph::helpers::InputLayerType secondaryInputType;
utils::InputLayerType secondaryInputType;
std::tie(batchAxisIndex, seqAxisIndex, dataInputShape, seqLengthsShape, secondaryInputType, netPrecision, targetDevice) = GetParam();
m_seqAxisIndex = seqAxisIndex;
init_input_shapes({dataInputShape, seqLengthsShape});
const auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision);
ov::ParameterVector paramsIn{std::make_shared<ov::op::v0::Parameter>(ngPrc, inputDynamicShapes[0])};
ov::ParameterVector paramsIn{std::make_shared<ov::op::v0::Parameter>(netPrecision, inputDynamicShapes[0])};
constexpr auto seqLengthsPrc = ngraph::element::Type_t::i32; //according to the specification
std::shared_ptr<ngraph::Node> seqLengthsInput;
constexpr auto seqLengthsPrc = ov::element::Type_t::i32; //according to the specification
std::shared_ptr<ov::Node> seqLengthsInput;
if (secondaryInputType == ngraph::helpers::InputLayerType::PARAMETER) {
if (secondaryInputType == utils::InputLayerType::PARAMETER) {
auto param = std::make_shared<ov::op::v0::Parameter>(seqLengthsPrc, inputDynamicShapes[1]);
seqLengthsInput = param;
paramsIn.push_back(param);
@@ -84,9 +83,9 @@ protected:
seqLengthsInput = ngraph::builder::makeConstant<float>(seqLengthsPrc, seqLengthsShape.second.front(), {}, true, maxSeqLength);
}
const auto reverse = std::make_shared<ngraph::opset1::ReverseSequence>(paramsIn.front(), seqLengthsInput, batchAxisIndex, seqAxisIndex);
const ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(reverse)};
function = std::make_shared<ngraph::Function>(results, paramsIn, "ReverseSequence");
const auto reverse = std::make_shared<ov::op::v0::ReverseSequence>(paramsIn.front(), seqLengthsInput, batchAxisIndex, seqAxisIndex);
const ov::ResultVector results{std::make_shared<ov::op::v0::Result>(reverse)};
function = std::make_shared<ov::Model>(results, paramsIn, "ReverseSequence");
}
void generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) override {
@@ -118,9 +117,9 @@ TEST_P(ReverseSequenceLayerCPUTest, CompareWithRefs) {
namespace {
const std::vector<InferenceEngine::Precision> netPrecisions = {
InferenceEngine::Precision::FP32,
InferenceEngine::Precision::I32
const std::vector<ov::element::Type> netPrecisions = {
ov::element::f32,
ov::element::i32
};
const int64_t batchAxisIndex = 0L;
@@ -147,9 +146,9 @@ const std::vector<InputShape> dataInputDynamicShapes5D =
const std::vector<InputShape> seqLengthsDynamicShapes = {{{-1}, {{7}, {10}}}};
const std::vector<ngraph::helpers::InputLayerType> secondaryInputTypes = {
ngraph::helpers::InputLayerType::CONSTANT,
ngraph::helpers::InputLayerType::PARAMETER
const std::vector<utils::InputLayerType> secondaryInputTypes = {
utils::InputLayerType::CONSTANT,
utils::InputLayerType::PARAMETER
};
INSTANTIATE_TEST_SUITE_P(smoke_ReverseSequenceCPUStatic3D, ReverseSequenceLayerCPUTest,
@@ -191,7 +190,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_ReverseSequenceCPUDynamic3D, ReverseSequenceLayer
::testing::ValuesIn(seqAxisIndices),
::testing::ValuesIn(dataInputDynamicShapes3D),
::testing::ValuesIn(seqLengthsDynamicShapes),
::testing::Values(ngraph::helpers::InputLayerType::PARAMETER),
::testing::Values(utils::InputLayerType::PARAMETER),
::testing::ValuesIn(netPrecisions),
::testing::Values(ov::test::utils::DEVICE_CPU)),
ReverseSequenceLayerCPUTest::getTestCaseName);
@@ -202,7 +201,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_ReverseSequenceCPUDynamic4D, ReverseSequenceLayer
::testing::ValuesIn(seqAxisIndices),
::testing::ValuesIn(dataInputDynamicShapes4D),
::testing::ValuesIn(seqLengthsDynamicShapes),
::testing::Values(ngraph::helpers::InputLayerType::PARAMETER),
::testing::Values(utils::InputLayerType::PARAMETER),
::testing::ValuesIn(netPrecisions),
::testing::Values(ov::test::utils::DEVICE_CPU)),
ReverseSequenceLayerCPUTest::getTestCaseName);
@@ -213,10 +212,11 @@ INSTANTIATE_TEST_SUITE_P(smoke_ReverseSequenceCPUDynamic5D, ReverseSequenceLayer
::testing::ValuesIn(seqAxisIndices),
::testing::ValuesIn(dataInputDynamicShapes5D),
::testing::ValuesIn(seqLengthsDynamicShapes),
::testing::Values(ngraph::helpers::InputLayerType::PARAMETER),
::testing::Values(utils::InputLayerType::PARAMETER),
::testing::ValuesIn(netPrecisions),
::testing::Values(ov::test::utils::DEVICE_CPU)),
ReverseSequenceLayerCPUTest::getTestCaseName);
} // namespace
} // namespace CPULayerTestsDefinitions
} // namespace
} // namespace test
} // namespace ov
@@ -2,23 +2,22 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "common_test_utils/node_builders/rnn_cell.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "ov_models/builders.hpp"
#include "test_utils/cpu_test_utils.hpp"
using namespace CPUTestUtils;
using namespace ov::test;
namespace CPULayerTestsDefinitions {
namespace ov {
namespace test {
using RNNCellCPUParams = typename std::tuple<
std::vector<InputShape>, // Shapes
std::vector<std::string>, // Activations
float, // Clip
ElementType, // Network precision
CPUSpecificParams, // CPU specific params
std::map<std::string, std::string> // Additional config
>;
using RNNCellCPUParams = typename std::tuple<std::vector<InputShape>, // Shapes
std::vector<std::string>, // Activations
float, // Clip
ElementType, // Network precision
CPUSpecificParams, // CPU specific params
ov::AnyMap // Additional config
>;
class RNNCellCPUTest : public testing::WithParamInterface<RNNCellCPUParams>,
virtual public ov::test::SubgraphBaseTest, public CPUTestsBase {
@@ -29,7 +28,7 @@ public:
float clip = 0.f;
ElementType netPrecision;
CPUSpecificParams cpuParams;
std::map<std::string, std::string> additionalConfig;
ov::AnyMap additionalConfig;
std::tie(inputShapes, activations, clip, netPrecision, cpuParams, additionalConfig) = obj.param;
@@ -53,9 +52,8 @@ 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) {
result << "_" << item.first << "=" << item.second.as<std::string>();
}
}
@@ -69,7 +67,7 @@ protected:
float clip = 0.f;
ElementType netPrecision;
CPUSpecificParams cpuParams;
std::map<std::string, std::string> additionalConfig;
ov::AnyMap additionalConfig;
std::tie(inputShapes, activations, clip, netPrecision, cpuParams, additionalConfig) = this->GetParam();
std::tie(inFmts, outFmts, priority, selectedType) = cpuParams;
@@ -82,7 +80,8 @@ protected:
configuration.insert(additionalConfig.begin(), additionalConfig.end());
if (additionalConfig[InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16] == InferenceEngine::PluginConfigParams::YES) {
auto it = additionalConfig.find(ov::hint::inference_precision.name());
if (it != additionalConfig.end() && it->second.as<ov::element::Type>() == ov::element::bf16) {
selectedType = makeSelectedTypeStr(selectedType, ElementType::bf16);
} else {
selectedType = makeSelectedTypeStr(selectedType, netPrecision);
@@ -96,7 +95,7 @@ protected:
paramsOuts.push_back(param);
}
std::vector<ov::Shape> WRB = {{hiddenSize, inputSize}, {hiddenSize, hiddenSize}, {hiddenSize}};
auto rnnCellOp = ngraph::builder::makeRNN(paramsOuts, WRB, hiddenSize, activations, {}, {}, clip);
auto rnnCellOp = utils::make_rnn(paramsOuts, WRB, hiddenSize, activations, {}, {}, clip);
function = makeNgraphFunction(netPrecision, params, rnnCellOp, "RNNCellCPU");
}
@@ -109,10 +108,8 @@ TEST_P(RNNCellCPUTest, 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"};
std::vector<std::vector<std::string>> activations = {{"relu"}, {"sigmoid"}, {"tanh"}};
@@ -167,5 +164,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_dynamic, RNNCellCPUTest,
::testing::Values(cpuParams),
::testing::ValuesIn(additionalConfig)),
RNNCellCPUTest::getTestCaseName);
} // namespace
} // namespace CPULayerTestsDefinitions
} // namespace
} // namespace test
} // namespace ov
@@ -3,25 +3,26 @@
//
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "ov_models/builders.hpp"
#include "ov_models/utils/ov_helpers.hpp"
#include "common_test_utils/node_builders/rnn_cell.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 RNNSequenceCpuSpecificParams = typename std::tuple<
std::vector<InputShape>, // Shapes
ngraph::helpers::SequenceTestsMode, // Pure Sequence or TensorIterator
ov::test::utils::SequenceTestsMode, // Pure Sequence or TensorIterator
std::vector<std::string>, // Activations
float, // Clip
ov::op::RecurrentSequenceDirection, // Direction
ElementType, // Network precision
CPUSpecificParams, // CPU specific params
std::map<std::string, std::string> // Additional config
ov::AnyMap // Additional config
>;
class RNNSequenceCPUTest : public testing::WithParamInterface<RNNSequenceCpuSpecificParams>,
@@ -29,13 +30,13 @@ class RNNSequenceCPUTest : public testing::WithParamInterface<RNNSequenceCpuSpec
public:
static std::string getTestCaseName(const testing::TestParamInfo<RNNSequenceCpuSpecificParams> &obj) {
std::vector<InputShape> inputShapes;
ngraph::helpers::SequenceTestsMode seqMode;
ov::test::utils::SequenceTestsMode seqMode;
std::vector<std::string> activations;
float clip;
ov::op::RecurrentSequenceDirection direction;
ElementType netPrecision;
CPUSpecificParams cpuParams;
std::map<std::string, std::string> additionalConfig;
ov::AnyMap additionalConfig;
std::tie(inputShapes, seqMode, activations, clip, direction, netPrecision, cpuParams, additionalConfig) = obj.param;
@@ -61,9 +62,8 @@ 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) {
result << "_" << item.first << "=" << item.second.as<std::string>();
}
}
return result.str();
@@ -72,13 +72,13 @@ 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;
ov::op::RecurrentSequenceDirection direction;
ElementType netPrecision;
CPUSpecificParams cpuParams;
std::map<std::string, std::string> additionalConfig;
ov::AnyMap additionalConfig;
std::tie(inputShapes, seqMode, activations, clip, direction, netPrecision, cpuParams, additionalConfig) = this->GetParam();
std::tie(inFmts, outFmts, priority, selectedType) = cpuParams;
@@ -94,7 +94,8 @@ protected:
configuration.insert(additionalConfig.begin(), additionalConfig.end());
if (additionalConfig[InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16] == InferenceEngine::PluginConfigParams::YES) {
auto it = additionalConfig.find(ov::hint::inference_precision.name());
if (it != additionalConfig.end() && it->second.as<ov::element::Type>() == ov::element::bf16) {
selectedType = makeSelectedTypeStr(selectedType, ElementType::bf16);
} else {
selectedType = makeSelectedTypeStr(selectedType, netPrecision);
@@ -116,8 +117,8 @@ protected:
1lu;
if (inputDynamicShapes.size() > 2) {
if (!inputDynamicShapes[2].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[2]->set_element_type(ElementType::i64);
@@ -130,20 +131,12 @@ protected:
std::vector<ov::Shape> WRB = {{numDirections, hiddenSize, inputSize}, {numDirections, hiddenSize, hiddenSize}, {numDirections, hiddenSize},
{batchSize}};
auto rnn_sequence = ngraph::builder::makeRNN(paramsOuts,
WRB,
hiddenSize,
activations,
{},
{},
clip,
true,
direction,
seqMode);
auto rnn_sequence =
utils::make_rnn(paramsOuts, WRB, hiddenSize, activations, {}, {}, clip, true, direction, seqMode);
function = makeNgraphFunction(netPrecision, params, rnn_sequence, "rnnSequence");
if (seqMode != ngraph::helpers::SequenceTestsMode::PURE_SEQ) {
ngraph::pass::Manager manager;
if (seqMode != ov::test::utils::SequenceTestsMode::PURE_SEQ) {
ov::pass::Manager manager;
if (direction == ov::op::RecurrentSequenceDirection::BIDIRECTIONAL)
manager.register_pass<ov::pass::BidirectionalRNNSequenceDecomposition>();
manager.register_pass<ov::pass::ConvertRNNSequenceToTensorIterator>();
@@ -180,14 +173,13 @@ TEST_P(RNNSequenceCPUTest, 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, ntc}, {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<size_t> seq_lengths_zero_clip{ 2 };
std::vector<std::vector<std::string>> activations = {{"relu"}, {"sigmoid"}, {"tanh"}};
@@ -221,7 +213,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_static, RNNSequenceCPUTest,
::testing::ValuesIn(direction),
::testing::ValuesIn(netPrecisions),
::testing::Values(cpuParams),
::testing::Values(std::map<std::string, std::string>{})),
::testing::Values(ov::AnyMap{})),
RNNSequenceCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_static_BatchSizeOne, RNNSequenceCPUTest,
@@ -232,7 +224,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_static_BatchSizeOne, RNNSequenceCPUTest,
::testing::ValuesIn(direction),
::testing::ValuesIn(netPrecisions),
::testing::Values(cpuParamsBatchSizeOne),
::testing::Values(std::map<std::string, std::string>{})),
::testing::Values(ov::AnyMap{})),
RNNSequenceCPUTest::getTestCaseName);
const std::vector<std::vector<InputShape>> dynamicShapes = {
@@ -300,7 +292,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_dynamic, RNNSequenceCPUTest,
::testing::ValuesIn(direction),
::testing::ValuesIn(netPrecisions),
::testing::Values(cpuParams),
::testing::Values(std::map<std::string, std::string>{})),
::testing::Values(ov::AnyMap{})),
RNNSequenceCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_dynamic_BatchSizeOne, RNNSequenceCPUTest,
@@ -311,7 +303,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_dynamic_BatchSizeOne, RNNSequenceCPUTest,
::testing::ValuesIn(direction),
::testing::ValuesIn(netPrecisions),
::testing::Values(cpuParamsBatchSizeOne),
::testing::Values(std::map<std::string, std::string>{})),
::testing::Values(ov::AnyMap{})),
RNNSequenceCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(nightly_dynamic, RNNSequenceCPUTest,
@@ -322,7 +314,7 @@ INSTANTIATE_TEST_SUITE_P(nightly_dynamic, RNNSequenceCPUTest,
::testing::ValuesIn(direction),
::testing::ValuesIn(netPrecisions),
::testing::Values(cpuParams),
::testing::Values(std::map<std::string, std::string>{})),
::testing::Values(ov::AnyMap{})),
RNNSequenceCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(nightly_dynamic_bf16, RNNSequenceCPUTest,
@@ -335,5 +327,6 @@ INSTANTIATE_TEST_SUITE_P(nightly_dynamic_bf16, RNNSequenceCPUTest,
::testing::Values(cpuParams),
::testing::Values(additionalConfig[1])),
RNNSequenceCPUTest::getTestCaseName);
} // namespace
} // namespace CPULayerTestsDefinitions
} // namespace
} // namespace test
} // namespace ov
@@ -1,38 +1,35 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <shared_test_classes/single_layer/roi_pooling.hpp>
#include "shared_test_classes/single_layer/roi_pooling.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "common_test_utils/file_utils.hpp"
#include <common_test_utils/ov_tensor_utils.hpp>
#include "common_test_utils/ov_tensor_utils.hpp"
#include "common_test_utils/data_utils.hpp"
#include "ie_common.h"
#include "test_utils/cpu_test_utils.hpp"
#include "utils/bfloat16.hpp"
using namespace InferenceEngine;
using namespace CPUTestUtils;
using namespace ov::test;
namespace CPULayerTestsDefinitions {
namespace ov {
namespace test {
enum ProposalGenerationMode { RANDOM, ULTIMATE_RIGHT_BORDER };
using roiPoolingShapes = std::vector<InputShape>;
using roiPoolingParams = std::tuple<
roiPoolingShapes, // Input shapes
std::vector<size_t>, // Pooled shape {pooled_h, pooled_w}
float, // Spatial scale
ngraph::helpers::ROIPoolingTypes, // ROIPooling method
InferenceEngine::Precision, // Net precision
LayerTestsUtils::TargetDevice>; // Device name
using roiPoolingParams = std::tuple<roiPoolingShapes, // Input shapes
std::vector<size_t>, // Pooled shape {pooled_h, pooled_w}
float, // Spatial scale
utils::ROIPoolingTypes, // ROIPooling method
ov::element::Type, // Net precision
LayerTestsUtils::TargetDevice>; // Device name
using ROIPoolingCPUTestParamsSet = std::tuple<roiPoolingParams,
CPUSpecificParams,
ProposalGenerationMode,
std::map<std::string, std::string>>;
ov::AnyMap>;
class ROIPoolingCPULayerTest : public testing::WithParamInterface<ROIPoolingCPUTestParamsSet>,
public ov::test::SubgraphBaseTest,
@@ -42,20 +39,20 @@ public:
roiPoolingParams basicParamsSet;
CPUSpecificParams cpuParams;
ProposalGenerationMode propMode;
std::map<std::string, std::string> additionalConfig;
ov::AnyMap additionalConfig;
std::tie(basicParamsSet, cpuParams, propMode, additionalConfig) = obj.param;
roiPoolingShapes inputShapes;
std::vector<size_t> poolShape;
float spatial_scale;
ngraph::helpers::ROIPoolingTypes pool_method;
InferenceEngine::Precision netPrecision;
utils::ROIPoolingTypes pool_method;
ov::element::Type netPrecision;
std::string targetDevice;
std::tie(inputShapes, poolShape, spatial_scale, pool_method, netPrecision, targetDevice) = basicParamsSet;
std::ostringstream result;
result << "netPRC=" << netPrecision.name() << "_";
result << "netPRC=" << netPrecision.to_string() << "_";
for (const auto& shape : inputShapes) {
result << ov::test::utils::partialShape2str({ shape.first }) << "_";
}
@@ -74,19 +71,18 @@ public:
result << "PS=" << ov::test::utils::vec2str(poolShape) << "_";
result << "Scale=" << spatial_scale << "_";
switch (pool_method) {
case ngraph::helpers::ROIPoolingTypes::ROI_MAX:
case utils::ROIPoolingTypes::ROI_MAX:
result << "Max_";
break;
case ngraph::helpers::ROIPoolingTypes::ROI_BILINEAR:
case utils::ROIPoolingTypes::ROI_BILINEAR:
result << "Bilinear_";
break;
}
result << "trgDev=" << targetDevice;
if (!additionalConfig.empty()) {
result << "_PluginConf";
for (auto &item : additionalConfig) {
if (item.second == PluginConfigParams::YES)
result << "_" << item.first << "=" << item.second;
for (auto& item : additionalConfig) {
result << "_" << item.first << "=" << item.second.as<std::string>();
}
}
switch (propMode) {
@@ -103,16 +99,16 @@ public:
}
protected:
void generate_inputs(const std::vector<ngraph::Shape>& targetInputStaticShapes) override {
void generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) override {
const ProposalGenerationMode propMode = std::get<2>(this->GetParam());
const float spatial_scale = std::get<2>(std::get<0>(this->GetParam()));
const ngraph::helpers::ROIPoolingTypes pool_method = std::get<3>(std::get<0>(this->GetParam()));
const utils::ROIPoolingTypes pool_method = std::get<3>(std::get<0>(this->GetParam()));
inputs.clear();
const auto& funcInputs = function->inputs();
auto feat_map_shape = targetInputStaticShapes[0];
const auto is_roi_max_mode = (pool_method == ngraph::helpers::ROIPoolingTypes::ROI_MAX);
const auto is_roi_max_mode = (pool_method ==utils::ROIPoolingTypes::ROI_MAX);
const int height = is_roi_max_mode ? feat_map_shape[2] / spatial_scale : 1;
const int width = is_roi_max_mode ? feat_map_shape[3] / spatial_scale : 1;
@@ -128,7 +124,7 @@ protected:
// and as result excess of right limit for proposal value if the border case (current_h == pooled_h - 1)
// will not be handled explicitly
switch (funcInput.get_element_type()) {
case ngraph::element::f32: {
case ov::element::f32: {
auto* dataPtr = tensor.data<float>();
for (size_t i = 0; i < tensor.get_size(); i += 5) {
dataPtr[i] = 0;
@@ -139,14 +135,14 @@ protected:
}
break;
}
case ngraph::element::bf16: {
case ov::element::bf16: {
auto* dataPtr = tensor.data<std::int16_t>();
for (size_t i = 0; i < tensor.get_size(); i += 5) {
dataPtr[i] = static_cast<std::int16_t>(ngraph::float16(0.f).to_bits());
dataPtr[i + 1] = static_cast<std::int16_t>(ngraph::float16(0.f).to_bits());
dataPtr[i + 2] = static_cast<std::int16_t>(ngraph::float16(0.248046786f).to_bits());
dataPtr[i + 3] = static_cast<std::int16_t>(ngraph::float16(0.471333951f).to_bits());
dataPtr[i + 4] = static_cast<std::int16_t>(ngraph::float16(1.f).to_bits());
dataPtr[i] = static_cast<std::int16_t>(ov::float16(0.f).to_bits());
dataPtr[i + 1] = static_cast<std::int16_t>(ov::float16(0.f).to_bits());
dataPtr[i + 2] = static_cast<std::int16_t>(ov::float16(0.248046786f).to_bits());
dataPtr[i + 3] = static_cast<std::int16_t>(ov::float16(0.471333951f).to_bits());
dataPtr[i + 4] = static_cast<std::int16_t>(ov::float16(1.f).to_bits());
}
break;
}
@@ -176,35 +172,35 @@ protected:
roiPoolingParams basicParamsSet;
CPUSpecificParams cpuParams;
ProposalGenerationMode propMode;
std::map<std::string, std::string> additionalConfig;
ov::AnyMap additionalConfig;
std::tie(basicParamsSet, cpuParams, propMode, additionalConfig) = this->GetParam();
roiPoolingShapes inputShapes;
std::vector<size_t> poolShape;
float spatial_scale;
ngraph::helpers::ROIPoolingTypes pool_method;
InferenceEngine::Precision netPrecision;
utils::ROIPoolingTypes pool_method;
ov::element::Type netPrecision;
std::tie(inputShapes, poolShape, spatial_scale, pool_method, netPrecision, targetDevice) = basicParamsSet;
if (additionalConfig[PluginConfigParams::KEY_ENFORCE_BF16] == PluginConfigParams::YES)
netPrecision = Precision::BF16;
auto it = additionalConfig.find(ov::hint::inference_precision.name());
if (it != additionalConfig.end() && it->second.as<ov::element::Type>() == ov::element::bf16)
netPrecision = ov::element::bf16;
configuration.insert(additionalConfig.begin(), additionalConfig.end());
if (selectedType.empty()) {
selectedType = getPrimitiveType();
}
selectedType.push_back('_');
selectedType += netPrecision.name();
selectedType += netPrecision.to_string();
if (netPrecision == Precision::BF16) {
if (netPrecision == ov::element::bf16) {
rel_threshold = 1e-2;
}
init_input_shapes(inputShapes);
auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision);
ov::ParameterVector params;
for (auto&& shape : inputDynamicShapes)
params.push_back(std::make_shared<ov::op::v0::Parameter>(ngPrc, shape));
params.push_back(std::make_shared<ov::op::v0::Parameter>(netPrecision, shape));
std::shared_ptr<ov::Node> roi_pooling;
if (ov::test::utils::ROIPoolingTypes::ROI_MAX == pool_method) {
@@ -212,10 +208,10 @@ protected:
} else {
roi_pooling = std::make_shared<ov::op::v0::ROIPooling>(params[0], params[1], poolShape, spatial_scale, "bilinear");
}
ngraph::ResultVector results{std::make_shared<ngraph::opset3::Result>(roi_pooling)};
ov::ResultVector results{std::make_shared<ov::op::v0::Result>(roi_pooling)};
function = makeNgraphFunction(ngPrc, params, roi_pooling, "ROIPooling");
functionRefs = ngraph::clone_function(*function);
function = makeNgraphFunction(netPrecision, params, roi_pooling, "ROIPooling");
functionRefs = ov::clone_model(*function);
}
};
@@ -226,11 +222,8 @@ TEST_P(ROIPoolingCPULayerTest, CompareWithRefs) {
namespace {
std::vector<std::map<std::string, std::string>> additionalConfig{
{{PluginConfigParams::KEY_ENFORCE_BF16, PluginConfigParams::NO}},
{{PluginConfigParams::KEY_ENFORCE_BF16, PluginConfigParams::YES}}
};
std::vector<ov::AnyMap> additionalConfig = {{ov::hint::inference_precision(ov::element::f32)},
{ov::hint::inference_precision(ov::element::bf16)}};
/* have to select particular implementation type, since currently
* nodes always choose the best one */
std::vector<CPUSpecificParams> selectCPUInfoForDevice() {
@@ -329,21 +322,21 @@ const std::vector<std::vector<size_t>> pooledShapes_bilinear = {
{6, 6}
};
const std::vector<InferenceEngine::Precision> netPRCs = {InferenceEngine::Precision::FP32, InferenceEngine::Precision::BF16};
const std::vector<ov::element::Type> netPRCs = {ov::element::f32, ov::element::bf16};
const std::vector<float> spatial_scales = {0.625f, 1.f};
const auto test_ROIPooling_max = ::testing::Combine(::testing::ValuesIn(inShapes),
::testing::ValuesIn(pooledShapes_max),
::testing::ValuesIn(spatial_scales),
::testing::Values(ngraph::helpers::ROIPoolingTypes::ROI_MAX),
::testing::Values(utils::ROIPoolingTypes::ROI_MAX),
::testing::ValuesIn(netPRCs),
::testing::Values(ov::test::utils::DEVICE_CPU));
const auto test_ROIPooling_bilinear = ::testing::Combine(::testing::ValuesIn(inShapes),
::testing::ValuesIn(pooledShapes_bilinear),
::testing::Values(spatial_scales[1]),
::testing::Values(ngraph::helpers::ROIPoolingTypes::ROI_BILINEAR),
::testing::Values(utils::ROIPoolingTypes::ROI_BILINEAR),
::testing::ValuesIn(netPRCs),
::testing::Values(ov::test::utils::DEVICE_CPU));
@@ -363,18 +356,19 @@ INSTANTIATE_TEST_SUITE_P(smoke_ROIPoolingCPU_bilinear,
::testing::ValuesIn(additionalConfig)),
ROIPoolingCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_ROIPoolingCPU_bilinear_ultimateRightBorderProposal,
ROIPoolingCPULayerTest,
::testing::Combine(::testing::Combine(::testing::Values(roiPoolingShapes{{{}, {{1, 1, 50, 50}}}, {{}, {{1, 5}}}}),
::testing::Values(std::vector<size_t> { 4, 4 }),
::testing::Values(spatial_scales[1]),
::testing::Values(ngraph::helpers::ROIPoolingTypes::ROI_BILINEAR),
::testing::Values(InferenceEngine::Precision::FP32),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::ValuesIn(selectCPUInfoForDevice()),
::testing::Values(ProposalGenerationMode::ULTIMATE_RIGHT_BORDER),
::testing::Values(std::map<std::string, std::string>{
{{PluginConfigParams::KEY_ENFORCE_BF16, PluginConfigParams::NO}}})),
ROIPoolingCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(
smoke_ROIPoolingCPU_bilinear_ultimateRightBorderProposal,
ROIPoolingCPULayerTest,
::testing::Combine(::testing::Combine(::testing::Values(roiPoolingShapes{{{}, {{1, 1, 50, 50}}}, {{}, {{1, 5}}}}),
::testing::Values(std::vector<size_t>{4, 4}),
::testing::Values(spatial_scales[1]),
::testing::Values(utils::ROIPoolingTypes::ROI_BILINEAR),
::testing::Values(ov::element::f32),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::ValuesIn(selectCPUInfoForDevice()),
::testing::Values(ProposalGenerationMode::ULTIMATE_RIGHT_BORDER),
::testing::Values(ov::AnyMap{{ov::hint::inference_precision(ov::element::f32)}})),
ROIPoolingCPULayerTest::getTestCaseName);
} // namespace
} // namespace CPULayerTestsDefinitions
} // namespace test
} // namespace ov
@@ -3,17 +3,13 @@
//
#include "test_utils/cpu_test_utils.hpp"
#include <common_test_utils/ov_tensor_utils.hpp>
#include "common_test_utils/ov_tensor_utils.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "ov_models/builders.hpp"
#include "ov_models/utils/ov_helpers.hpp"
using namespace InferenceEngine;
using namespace CPUTestUtils;
using namespace ov::test;
namespace CPULayerTestsDefinitions {
namespace ov {
namespace test {
using ROIAlignShapes = std::vector<InputShape>;
using ROIAlignSpecificParams = std::tuple<
@@ -33,14 +29,14 @@ using ROIAlignLayerTestParams = std::tuple<
>;
using ROIAlignLayerCPUTestParamsSet = std::tuple<
CPULayerTestsDefinitions::ROIAlignLayerTestParams,
ROIAlignLayerTestParams,
CPUSpecificParams>;
class ROIAlignLayerCPUTest : public testing::WithParamInterface<ROIAlignLayerCPUTestParamsSet>,
public SubgraphBaseTest, public CPUTestsBase {
public:
static std::string getTestCaseName(testing::TestParamInfo<ROIAlignLayerCPUTestParamsSet> obj) {
CPULayerTestsDefinitions::ROIAlignLayerTestParams basicParamsSet;
ROIAlignLayerTestParams basicParamsSet;
CPUSpecificParams cpuParams;
std::tie(basicParamsSet, cpuParams) = obj.param;
std::string td;
@@ -82,7 +78,7 @@ public:
return result.str();
}
protected:
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();
@@ -104,10 +100,10 @@ protected:
} else if (coordsET == ElementType::bf16) {
auto coordsTensorData = static_cast<std::int16_t*>(coordsTensor.data());
for (size_t i = 0; i < coordsTensor.get_size(); i += 4) {
coordsTensorData[i] = static_cast<std::int16_t>(ngraph::bfloat16(1.f).to_bits());
coordsTensorData[i + 1] = static_cast<std::int16_t>(ngraph::bfloat16(1.f).to_bits());
coordsTensorData[i + 2] = static_cast<std::int16_t>(ngraph::bfloat16(19.f).to_bits());
coordsTensorData[i + 3] = static_cast<std::int16_t>(ngraph::bfloat16(19.f).to_bits());
coordsTensorData[i] = static_cast<std::int16_t>(ov::bfloat16(1.f).to_bits());
coordsTensorData[i + 1] = static_cast<std::int16_t>(ov::bfloat16(1.f).to_bits());
coordsTensorData[i + 2] = static_cast<std::int16_t>(ov::bfloat16(19.f).to_bits());
coordsTensorData[i + 3] = static_cast<std::int16_t>(ov::bfloat16(19.f).to_bits());
}
} else {
OPENVINO_THROW("roi align. Unsupported precision: ", coordsET);
@@ -127,12 +123,12 @@ protected:
}
void SetUp() override {
CPULayerTestsDefinitions::ROIAlignLayerTestParams basicParamsSet;
ROIAlignLayerTestParams basicParamsSet;
CPUSpecificParams cpuParams;
std::tie(basicParamsSet, cpuParams) = this->GetParam();
std::tie(inFmts, outFmts, priority, selectedType) = cpuParams;
CPULayerTestsDefinitions::ROIAlignSpecificParams roiAlignParams;
ROIAlignSpecificParams roiAlignParams;
ElementType inputPrecision;
std::tie(roiAlignParams, inputPrecision, targetDevice) = basicParamsSet;
@@ -151,19 +147,26 @@ protected:
for (auto&& shape : { inputDynamicShapes[0], inputDynamicShapes[1] }) {
float_params.push_back(std::make_shared<ov::op::v0::Parameter>(inputPrecision, shape));
}
auto int_param = std::make_shared<ov::op::v0::Parameter>(ngraph::element::i32, inputDynamicShapes[2]);
auto pooling_mode = ngraph::EnumNames<ngraph::opset9::ROIAlign::PoolingMode>::as_enum(mode);
auto aligned_mode = ngraph::EnumNames<ngraph::opset9::ROIAlign::AlignedMode>::as_enum(alignedMode);
auto int_param = std::make_shared<ov::op::v0::Parameter>(ov::element::i32, inputDynamicShapes[2]);
auto pooling_mode = ov::EnumNames<ov::op::v9::ROIAlign::PoolingMode>::as_enum(mode);
auto aligned_mode = ov::EnumNames<ov::op::v9::ROIAlign::AlignedMode>::as_enum(alignedMode);
auto roialign = std::make_shared<ngraph::opset9::ROIAlign>(float_params[0], float_params[1], int_param, pooledH, pooledW,
samplingRatio, spatialScale, pooling_mode, aligned_mode);
auto roialign = std::make_shared<ov::op::v9::ROIAlign>(float_params[0],
float_params[1],
int_param,
pooledH,
pooledW,
samplingRatio,
spatialScale,
pooling_mode,
aligned_mode);
selectedType = makeSelectedTypeStr(selectedType, inputPrecision);
if (inputPrecision == ElementType::bf16) {
rel_threshold = 1e-2;
}
ngraph::ParameterVector params{ float_params[0], float_params[1], int_param };
ov::ParameterVector params{ float_params[0], float_params[1], int_param };
function = makeNgraphFunction(inputPrecision, params, roialign, "ROIAlign");
}
};
@@ -178,15 +181,15 @@ namespace {
/* CPU PARAMS */
std::vector<CPUSpecificParams> filterCPUInfoForDevice() {
std::vector<CPUSpecificParams> resCPUParams;
if (InferenceEngine::with_cpu_x86_avx512f()) {
if (ov::with_cpu_x86_avx512f()) {
resCPUParams.push_back(CPUSpecificParams{{nchw, nc, x}, {nchw}, {"jit_avx512"}, {"jit_avx512"}});
resCPUParams.push_back(CPUSpecificParams{{nhwc, nc, x}, {nhwc}, {"jit_avx512"}, {"jit_avx512"}});
resCPUParams.push_back(CPUSpecificParams{{nChw16c, nc, x}, {nChw16c}, {"jit_avx512"}, {"jit_avx512"}});
} else if (InferenceEngine::with_cpu_x86_avx2()) {
} else if (ov::with_cpu_x86_avx2()) {
resCPUParams.push_back(CPUSpecificParams{{nchw, nc, x}, {nchw}, {"jit_avx2"}, {"jit_avx2"}});
resCPUParams.push_back(CPUSpecificParams{{nhwc, nc, x}, {nhwc}, {"jit_avx2"}, {"jit_avx2"}});
resCPUParams.push_back(CPUSpecificParams{{nChw8c, nc, x}, {nChw8c}, {"jit_avx2"}, {"jit_avx2"}});
} else if (InferenceEngine::with_cpu_x86_sse42()) {
} else if (ov::with_cpu_x86_sse42()) {
resCPUParams.push_back(CPUSpecificParams{{nchw, nc, x}, {nchw}, {"jit_sse42"}, {"jit_sse42"}});
resCPUParams.push_back(CPUSpecificParams{{nhwc, nc, x}, {nhwc}, {"jit_sse42"}, {"jit_sse42"}});
resCPUParams.push_back(CPUSpecificParams{{nChw8c, nc, x}, {nChw8c}, {"jit_sse42"}, {"jit_sse42"}});
@@ -265,5 +268,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_ROIAlignLayoutTest, ROIAlignLayerCPUTest,
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::ValuesIn(filterCPUInfoForDevice())),
ROIAlignLayerCPUTest::getTestCaseName);
} // namespace
} // namespace CPULayerTestsDefinitions
} // namespace
} // namespace test
} // namespace ov
@@ -7,9 +7,9 @@
#include "test_utils/cpu_test_utils.hpp"
using namespace CPUTestUtils;
using namespace ov::test;
namespace CPULayerTestsDefinitions {
namespace ov {
namespace test {
using RollCPUTestParams = typename std::tuple<
InputShape, // Input shape
@@ -58,12 +58,14 @@ protected:
for (auto&& shape : inputDynamicShapes) {
paramsIn.push_back(std::make_shared<ov::op::v0::Parameter>(inputPrecision, shape));
}
auto shiftNode = std::make_shared<ngraph::op::Constant>(ngraph::element::Type_t::i64, ngraph::Shape{shift.size()}, shift)->output(0);
auto axesNode = std::make_shared<ngraph::op::Constant>(ngraph::element::Type_t::i64, ngraph::Shape{axes.size()}, axes)->output(0);
auto shiftNode =
std::make_shared<ov::op::v0::Constant>(ov::element::i64, ov::Shape{shift.size()}, shift)->output(0);
auto axesNode =
std::make_shared<ov::op::v0::Constant>(ov::element::i64, ov::Shape{axes.size()}, axes)->output(0);
const auto roll = std::make_shared<ngraph::op::v7::Roll>(paramsIn[0], shiftNode, axesNode);
const ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(roll)};
function = std::make_shared<ngraph::Function>(results, paramsIn, "roll");
const auto roll = std::make_shared<ov::op::v7::Roll>(paramsIn[0], shiftNode, axesNode);
const ov::ResultVector results{std::make_shared<ov::op::v0::Result>(roll)};
function = std::make_shared<ov::Model>(results, paramsIn, "roll");
}
};
@@ -146,5 +148,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_RollCPU_5DRepeatingAxesNegativeShift, RollLayerCP
::testing::Values(ov::test::utils::DEVICE_CPU)),
RollLayerCPUTest::getTestCaseName);
} // namespace
} // namespace CPULayerTestsDefinitions
} // namespace
} // namespace test
} // namespace ov