Refactor DetectionOutputLayerTest, DFTLayerTest, EltwiseLayerTest (#19922)

* Refactor DetectionOutputLayerTest

* Refactor DFTLayerTest

* Refactor EltwiseLayerTest

* Fix

* Fix

* Disable tests
This commit is contained in:
Oleg Pipikin
2023-09-22 16:35:20 +04:00
committed by GitHub
parent 5611f7d65c
commit ce378739f0
14 changed files with 596 additions and 86 deletions
@@ -2,11 +2,11 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "single_layer_tests/detection_output.hpp"
using namespace LayerTestsDefinitions;
#include "single_op_tests/detection_output.hpp"
namespace {
using ov::test::DetectionOutputLayerTest;
using ov::test::ParamsWhichSizeDepends;
const int numClasses = 11;
const int backgroundLabelId = 0;
@@ -4,28 +4,30 @@
#include <vector>
#include "single_layer_tests/dft.hpp"
#include "single_op_tests/dft.hpp"
#include "common_test_utils/test_constants.hpp"
using namespace LayerTestsDefinitions;
namespace {
using ov::test::DFTLayerTest;
const std::vector<ngraph::helpers::DFTOpType> opTypes = {
ngraph::helpers::DFTOpType::FORWARD,
ngraph::helpers::DFTOpType::INVERSE
const std::vector<ov::test::utils::DFTOpType> op_types = {
ov::test::utils::DFTOpType::FORWARD,
ov::test::utils::DFTOpType::INVERSE
};
const std::vector<InferenceEngine::Precision> inputPrecision = {
InferenceEngine::Precision::FP32,
InferenceEngine::Precision::BF16
const std::vector<ov::element::Type> input_type = {
ov::element::f32,
ov::element::bf16
};
const std::vector<std::vector<size_t>> inputShapes = {
{10, 4, 20, 32, 2},
{2, 5, 7, 8, 2},
{1, 120, 128, 1, 2},
const std::vector<std::vector<ov::Shape>> input_shapes_static = {
{{10, 4, 20, 32, 2}},
{{2, 5, 7, 8, 2}},
{{1, 120, 128, 1, 2}},
};
/* 1D DFT */
const std::vector<std::vector<int64_t>> axes1D = {
{0}, {1}, {2}, {3}, {-2}
};
@@ -35,11 +37,11 @@ const std::vector<std::vector<int64_t>> signalSizes1D = {
};
const auto testCase1D = ::testing::Combine(
::testing::ValuesIn(inputShapes),
::testing::ValuesIn(inputPrecision),
::testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_static)),
::testing::ValuesIn(input_type),
::testing::ValuesIn(axes1D),
::testing::ValuesIn(signalSizes1D),
::testing::ValuesIn(opTypes),
::testing::ValuesIn(op_types),
::testing::Values(ov::test::utils::DEVICE_CPU)
);
@@ -53,15 +55,14 @@ const std::vector<std::vector<int64_t>> signalSizes2D = {
};
const auto testCase2D = ::testing::Combine(
::testing::ValuesIn(inputShapes),
::testing::ValuesIn(inputPrecision),
::testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_static)),
::testing::ValuesIn(input_type),
::testing::ValuesIn(axes2D),
::testing::ValuesIn(signalSizes2D),
::testing::ValuesIn(opTypes),
::testing::ValuesIn(op_types),
::testing::Values(ov::test::utils::DEVICE_CPU)
);
/* 3D DFT */
const std::vector<std::vector<int64_t>> axes3D = {
@@ -73,11 +74,11 @@ const std::vector<std::vector<int64_t>> signalSizes3D = {
};
const auto testCase3D = ::testing::Combine(
::testing::ValuesIn(inputShapes),
::testing::ValuesIn(inputPrecision),
::testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_static)),
::testing::ValuesIn(input_type),
::testing::ValuesIn(axes3D),
::testing::ValuesIn(signalSizes3D),
::testing::ValuesIn(opTypes),
::testing::ValuesIn(op_types),
::testing::Values(ov::test::utils::DEVICE_CPU)
);
@@ -92,16 +93,16 @@ const std::vector<std::vector<int64_t>> signalSizes4D = {
};
const auto testCase4D = ::testing::Combine(
::testing::ValuesIn(inputShapes),
::testing::ValuesIn(inputPrecision),
::testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_static)),
::testing::ValuesIn(input_type),
::testing::ValuesIn(axes4D),
::testing::ValuesIn(signalSizes4D),
::testing::ValuesIn(opTypes),
::testing::ValuesIn(op_types),
::testing::Values(ov::test::utils::DEVICE_CPU)
);
INSTANTIATE_TEST_SUITE_P(smoke_TestsDFT_1d, DFTLayerTest, testCase1D, DFTLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_TestsDFT_2d, DFTLayerTest, testCase2D, DFTLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_TestsDFT_3d, DFTLayerTest, testCase3D, DFTLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_TestsDFT_4d, DFTLayerTest, testCase4D, DFTLayerTest::getTestCaseName);
} // namespace
@@ -3,13 +3,16 @@
//
#include <vector>
#include "single_layer_tests/eltwise.hpp"
#include "single_op_tests/eltwise.hpp"
#include "common_test_utils/test_constants.hpp"
using namespace ov::test::subgraph;
namespace {
std::vector<std::vector<ov::Shape>> inShapesStatic = {
using ov::test::EltwiseLayerTest;
using ov::test::utils::InputLayerType;
using ov::test::utils::OpType;
using ov::test::utils::EltwiseTypes;
std::vector<std::vector<ov::Shape>> in_shapes_static = {
{{2}},
{{2, 200}},
{{10, 200}},
@@ -29,103 +32,103 @@ std::vector<std::vector<ov::Shape>> inShapesStatic = {
{{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}},
};
std::vector<std::vector<ov::Shape>> inShapesStaticCheckCollapse = {
std::vector<std::vector<ov::Shape>> in_shapes_static_check_collapse = {
{{16, 16, 16, 16}, {16, 16, 16, 1}},
{{16, 16, 16, 1}, {16, 16, 16, 1}},
{{16, 16, 16, 16}, {16, 16, 1, 16}},
{{16, 16, 1, 16}, {16, 16, 1, 16}},
};
std::vector<std::vector<ov::test::InputShape>> inShapesDynamic = {
std::vector<std::vector<ov::test::InputShape>> in_shapes_dynamic = {
{{{ngraph::Dimension(1, 10), 200}, {{2, 200}, {1, 200}}},
{{ngraph::Dimension(1, 10), 200}, {{2, 200}, {5, 200}}}},
};
std::vector<std::vector<ov::test::InputShape>> inShapesDynamicLargeUpperBound = {
std::vector<std::vector<ov::test::InputShape>> in_shapes_dynamic_large_upper_bound = {
{{{ngraph::Dimension(1, 1000000000000), 200}, {{2, 200}, {5, 200}}}},
};
std::vector<ov::test::ElementType> netPrecisions = {
std::vector<ov::test::ElementType> model_types = {
ov::element::f32,
ov::element::f16,
ov::element::i32,
};
std::vector<ngraph::helpers::InputLayerType> secondaryInputTypes = {
ngraph::helpers::InputLayerType::CONSTANT,
ngraph::helpers::InputLayerType::PARAMETER,
std::vector<InputLayerType> secondary_input_types = {
InputLayerType::CONSTANT,
InputLayerType::PARAMETER,
};
std::vector<ngraph::helpers::InputLayerType> secondaryInputTypesDynamic = {
ngraph::helpers::InputLayerType::PARAMETER,
std::vector<InputLayerType> secondary_input_types_dynamic = {
InputLayerType::PARAMETER,
};
std::vector<ov::test::utils::OpType> opTypes = {
ov::test::utils::OpType::SCALAR,
ov::test::utils::OpType::VECTOR,
std::vector<OpType> op_types = {
OpType::SCALAR,
OpType::VECTOR,
};
std::vector<ov::test::utils::OpType> opTypesDynamic = {
ov::test::utils::OpType::VECTOR,
std::vector<OpType> op_types_dynamic = {
OpType::VECTOR,
};
std::vector<ngraph::helpers::EltwiseTypes> eltwiseOpTypes = {
ngraph::helpers::EltwiseTypes::ADD,
ngraph::helpers::EltwiseTypes::MULTIPLY,
ngraph::helpers::EltwiseTypes::SUBTRACT,
ngraph::helpers::EltwiseTypes::DIVIDE,
ngraph::helpers::EltwiseTypes::FLOOR_MOD,
ngraph::helpers::EltwiseTypes::SQUARED_DIFF,
ngraph::helpers::EltwiseTypes::POWER,
ngraph::helpers::EltwiseTypes::MOD
std::vector<EltwiseTypes> eltwise_op_types = {
EltwiseTypes::ADD,
EltwiseTypes::MULTIPLY,
EltwiseTypes::SUBTRACT,
EltwiseTypes::DIVIDE,
EltwiseTypes::FLOOR_MOD,
EltwiseTypes::SQUARED_DIFF,
EltwiseTypes::POWER,
EltwiseTypes::MOD
};
std::vector<ngraph::helpers::EltwiseTypes> eltwiseOpTypesDynamic = {
ngraph::helpers::EltwiseTypes::ADD,
ngraph::helpers::EltwiseTypes::MULTIPLY,
ngraph::helpers::EltwiseTypes::SUBTRACT,
std::vector<EltwiseTypes> eltwise_op_types_dynamic = {
EltwiseTypes::ADD,
EltwiseTypes::MULTIPLY,
EltwiseTypes::SUBTRACT,
};
ov::test::Config additional_config = {};
const auto multiply_params = ::testing::Combine(
::testing::ValuesIn(ov::test::static_shapes_to_test_representation(inShapesStatic)),
::testing::ValuesIn(eltwiseOpTypes),
::testing::ValuesIn(secondaryInputTypes),
::testing::ValuesIn(opTypes),
::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(ov::test::static_shapes_to_test_representation(in_shapes_static)),
::testing::ValuesIn(eltwise_op_types),
::testing::ValuesIn(secondary_input_types),
::testing::ValuesIn(op_types),
::testing::ValuesIn(model_types),
::testing::Values(ov::element::undefined),
::testing::Values(ov::element::undefined),
::testing::Values(ov::test::utils::DEVICE_CPU),
::testing::Values(additional_config));
const auto collapsing_params = ::testing::Combine(
::testing::ValuesIn(ov::test::static_shapes_to_test_representation(inShapesStaticCheckCollapse)),
::testing::ValuesIn(eltwiseOpTypes),
::testing::ValuesIn(secondaryInputTypes),
::testing::Values(opTypes[1]),
::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(ov::test::static_shapes_to_test_representation(in_shapes_static_check_collapse)),
::testing::ValuesIn(eltwise_op_types),
::testing::ValuesIn(secondary_input_types),
::testing::Values(op_types[1]),
::testing::ValuesIn(model_types),
::testing::Values(ov::element::undefined),
::testing::Values(ov::element::undefined),
::testing::Values(ov::test::utils::DEVICE_CPU),
::testing::Values(additional_config));
const auto multiply_params_dynamic = ::testing::Combine(
::testing::ValuesIn(inShapesDynamic),
::testing::ValuesIn(eltwiseOpTypesDynamic),
::testing::ValuesIn(secondaryInputTypesDynamic),
::testing::ValuesIn(opTypesDynamic),
::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(in_shapes_dynamic),
::testing::ValuesIn(eltwise_op_types_dynamic),
::testing::ValuesIn(secondary_input_types_dynamic),
::testing::ValuesIn(op_types_dynamic),
::testing::ValuesIn(model_types),
::testing::Values(ov::element::undefined),
::testing::Values(ov::element::undefined),
::testing::Values(ov::test::utils::DEVICE_CPU),
::testing::Values(additional_config));
const auto multiply_params_dynamic_large_upper_bound = ::testing::Combine(
::testing::ValuesIn(inShapesDynamicLargeUpperBound),
::testing::Values(ngraph::helpers::EltwiseTypes::ADD),
::testing::ValuesIn(secondaryInputTypesDynamic),
::testing::ValuesIn(opTypesDynamic),
::testing::ValuesIn(in_shapes_dynamic_large_upper_bound),
::testing::Values(EltwiseTypes::ADD),
::testing::ValuesIn(secondary_input_types_dynamic),
::testing::ValuesIn(op_types_dynamic),
::testing::Values(ov::element::f32),
::testing::Values(ov::element::undefined),
::testing::Values(ov::element::undefined),
@@ -147,9 +150,9 @@ std::vector<std::vector<ov::Shape>> inShapesSingleThread = {
{{2, 1, 2, 1, 2, 2}},
};
std::vector<ngraph::helpers::EltwiseTypes> eltwiseOpTypesSingleThread = {
ngraph::helpers::EltwiseTypes::ADD,
ngraph::helpers::EltwiseTypes::POWER,
std::vector<EltwiseTypes> eltwise_op_typesSingleThread = {
EltwiseTypes::ADD,
EltwiseTypes::POWER,
};
ov::AnyMap additional_config_single_thread = {
@@ -158,10 +161,10 @@ ov::AnyMap additional_config_single_thread = {
const auto single_thread_params = ::testing::Combine(
::testing::ValuesIn(ov::test::static_shapes_to_test_representation(inShapesSingleThread)),
::testing::ValuesIn(eltwiseOpTypesSingleThread),
::testing::ValuesIn(secondaryInputTypes),
::testing::ValuesIn(opTypes),
::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(eltwise_op_typesSingleThread),
::testing::ValuesIn(secondary_input_types),
::testing::ValuesIn(op_types),
::testing::ValuesIn(model_types),
::testing::Values(ov::element::undefined),
::testing::Values(ov::element::undefined),
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -195,6 +195,8 @@ std::vector<std::string> disabledTestPatterns() {
R"(.*smoke_TopK/TopKLayerTest.Inference.*_k=7_axis=3_.*_modelType=f16_trgDev=CPU.*)",
R"(.*smoke_TopK/TopKLayerTest.Inference.*_k=18_.*_modelType=f16_trgDev=CPU.*)",
R"(.*smoke_TopK/TopKLayerTest.Inference.*_k=21_.*_sort=value_modelType=f16_trgDev=CPU.*)",
// Issue: 121228
R"(smoke_TestsDFT_(1|2|3|4)d/DFTLayerTest.Inference.*bf16.*)",
};
#if defined(__APPLE__) && defined(OPENVINO_ARCH_ARM64)
// Issue: 120950
@@ -238,6 +240,7 @@ std::vector<std::string> disabledTestPatterns() {
retVector.emplace_back(R"(smoke_ExecGraph/ExecGraphRuntimePrecision.CheckRuntimePrecision/Function=(EltwiseWithTwoDynamicInputs|FakeQuantizeRelu).*)");
// Issue 108803: bug in CPU scalar implementation
retVector.emplace_back(R"(smoke_TestsDFT_(1|2|3|4)d/DFTLayerTest.CompareWithRefs.*)");
retVector.emplace_back(R"(smoke_TestsDFT_(1|2|3|4)d/DFTLayerTest.Inference.*)");
// Issue 88764, 91647, 108802: accuracy issue
retVector.emplace_back(R"(MultipleLSTMCellTest/MultipleLSTMCellTest.CompareWithRefs.*)");
// int8 / code-generation specific
@@ -0,0 +1,15 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include "shared_test_classes/single_op/detection_output.hpp"
namespace ov {
namespace test {
TEST_P(DetectionOutputLayerTest, Inference) {
run();
};
} // namespace test
} // namespace ov
@@ -0,0 +1,15 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include "shared_test_classes/single_op/dft.hpp"
namespace ov {
namespace test {
TEST_P(DFTLayerTest, Inference) {
run();
};
} // namespace test
} // namespace ov
@@ -0,0 +1,15 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include "shared_test_classes/single_op/eltwise.hpp"
namespace ov {
namespace test {
TEST_P(EltwiseLayerTest, Inference) {
run();
}
} // namespace test
} // namespace ov
@@ -20,6 +20,9 @@
#include "ngraph/op/max.hpp"
#include "ngraph/op/min.hpp"
#include "openvino/op/dft.hpp"
#include "openvino/op/idft.hpp"
#include <map>
#include <vector>
@@ -82,6 +85,8 @@ static std::map<ov::NodeTypeInfo, std::vector<std::vector<InputGenerateData>>> i
{ ov::op::v4::Proposal::get_type_info_static(), {{{0, 1, 1000, 8234231}}, {{0, 1, 1000, 8234231}}} },
{ ov::op::v4::ReduceL1::get_type_info_static(), {{{0, 5}}, {{0, 5, 1000}}} },
{ ov::op::v4::ReduceL2::get_type_info_static(), {{{0, 5}}, {{0, 5, 1000}}} },
{ ov::op::v7::DFT::get_type_info_static(), {{{0, 1}}, {{0, 1, 1000000}}} },
{ ov::op::v7::IDFT::get_type_info_static(), {{{0, 1}}, {{0, 1, 1000000}}} },
};
} // namespace utils
@@ -0,0 +1,73 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <cstddef>
#include <vector>
#include <string>
#include <tuple>
#include "openvino/op/detection_output.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
namespace ov {
namespace test {
using Attributes = ov::op::v0::DetectionOutput::Attributes;
std::ostream& operator <<(std::ostream& os, const Attributes& inputShape);
enum {
idxLocation,
idxConfidence,
idxPriors,
idxArmConfidence,
idxArmLocation,
numInputs
};
using DetectionOutputAttributes = std::tuple<
int, // numClasses
int, // backgroundLabelId
int, // topK
std::vector<int>, // keepTopK
std::string, // codeType
float, // nmsThreshold
float, // confidenceThreshold
bool, // clip_afterNms
bool, // clip_beforeNms
bool // decreaseLabelId
>;
using ParamsWhichSizeDepends = std::tuple<
bool, // varianceEncodedInTarget
bool, // shareLocation
bool, // normalized
size_t, // inputHeight
size_t, // inputWidth
ov::Shape, // "Location" input
ov::Shape, // "Confidence" input
ov::Shape, // "Priors" input
ov::Shape, // "ArmConfidence" input
ov::Shape // "ArmLocation" input
>;
using DetectionOutputParams = std::tuple<
DetectionOutputAttributes,
ParamsWhichSizeDepends,
size_t, // Number of batch
float, // objectnessScore
std::string // Device name
>;
class DetectionOutputLayerTest : public testing::WithParamInterface<DetectionOutputParams>,
virtual public ov::test::SubgraphBaseTest {
public:
static std::string getTestCaseName(const testing::TestParamInfo<DetectionOutputParams>& obj);
protected:
void SetUp() override;
};
} // namespace test
} // namespace ov
@@ -0,0 +1,33 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <tuple>
#include <string>
#include <vector>
#include "common_test_utils/test_enums.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
namespace ov {
namespace test {
typedef std::tuple<
std::vector<InputShape>, // Input shapes
ov::element::Type, // Model type
std::vector<int64_t>, // Axes
std::vector<int64_t>, // Signal size
ov::test::utils::DFTOpType,
std::string> DFTParams; // Device name
class DFTLayerTest : public testing::WithParamInterface<DFTParams>,
virtual public ov::test::SubgraphBaseTest {
public:
static std::string getTestCaseName(const testing::TestParamInfo<DFTParams>& obj);
protected:
void SetUp() override;
};
} // namespace test
} // namespace ov
@@ -0,0 +1,38 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
// NOTE: WILL BE REWORKED (31905)
#pragma once
#include "common_test_utils/test_enums.hpp"
#include "common_test_utils/common_utils.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
namespace ov {
namespace test {
typedef std::tuple<
std::vector<InputShape>, // input shapes
ov::test::utils::EltwiseTypes, // eltwise op type
ov::test::utils::InputLayerType, // secondary input type
ov::test::utils::OpType, // op type
ElementType, // Model type
ElementType, // In type
ElementType, // Out type
TargetDevice, // Device name
ov::AnyMap // Additional network configuration
> EltwiseTestParams;
class EltwiseLayerTest : public testing::WithParamInterface<EltwiseTestParams>,
virtual public SubgraphBaseTest {
protected:
void SetUp() override;
public:
static std::string getTestCaseName(const testing::TestParamInfo<EltwiseTestParams>& obj);
private:
void transformInputShapesAccordingEltwise(const ov::PartialShape& secondInputShape);
};
} // namespace test
} // namespace ov
@@ -0,0 +1,116 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "shared_test_classes/single_op/detection_output.hpp"
namespace ov {
namespace test {
std::ostream& operator <<(std::ostream& result, const Attributes& attrs) {
result << "Classes=" << attrs.num_classes << "_";
result << "backgrId=" << attrs.background_label_id << "_";
result << "topK=" << attrs.top_k << "_";
result << "varEnc=" << attrs.variance_encoded_in_target << "_";
result << "keepTopK=" << ov::test::utils::vec2str(attrs.keep_top_k) << "_";
result << "codeType=" << attrs.code_type << "_";
result << "shareLoc=" << attrs.share_location << "_";
result << "nmsThr=" << attrs.nms_threshold << "_";
result << "confThr=" << attrs.confidence_threshold << "_";
result << "clipAfterNms=" << attrs.clip_after_nms << "_";
result << "clipBeforeNms=" << attrs.clip_before_nms << "_";
result << "decrId=" << attrs.decrease_label_id << "_";
result << "norm=" << attrs.normalized << "_";
result << "inH=" << attrs.input_height << "_";
result << "inW=" << attrs.input_width << "_";
result << "OS=" << attrs.objectness_score << "_";
return result;
}
std::string DetectionOutputLayerTest::getTestCaseName(const testing::TestParamInfo<DetectionOutputParams>& obj) {
DetectionOutputAttributes common_attrs;
ParamsWhichSizeDepends specific_attrs;
Attributes attrs;
size_t batch;
std::string targetDevice;
std::tie(common_attrs, specific_attrs, batch, attrs.objectness_score, targetDevice) = obj.param;
std::tie(attrs.num_classes, attrs.background_label_id, attrs.top_k, attrs.keep_top_k, attrs.code_type, attrs.nms_threshold, attrs.confidence_threshold,
attrs.clip_after_nms, attrs.clip_before_nms, attrs.decrease_label_id) = common_attrs;
const size_t numInputs = 5;
std::vector<InferenceEngine::SizeVector> input_shapes(numInputs);
std::tie(attrs.variance_encoded_in_target, attrs.share_location, attrs.normalized, attrs.input_height, attrs.input_width,
input_shapes[idxLocation], input_shapes[idxConfidence], input_shapes[idxPriors], input_shapes[idxArmConfidence],
input_shapes[idxArmLocation]) = specific_attrs;
if (input_shapes[idxArmConfidence].empty()) {
input_shapes.resize(3);
}
for (size_t i = 0; i < input_shapes.size(); i++) {
input_shapes[i][0] = batch;
}
std::ostringstream result;
result << "IS = { ";
result << "LOC=" << ov::test::utils::vec2str(input_shapes[0]) << "_";
result << "CONF=" << ov::test::utils::vec2str(input_shapes[1]) << "_";
result << "PRIOR=" << ov::test::utils::vec2str(input_shapes[2]);
std::string armConf, armLoc;
if (input_shapes.size() > 3) {
armConf = "_ARM_CONF=" + ov::test::utils::vec2str(input_shapes[3]) + "_";
armLoc = "ARM_LOC=" + ov::test::utils::vec2str(input_shapes[4]);
}
result << armConf;
result << armLoc << " }_";
result << attrs;
result << "TargetDevice=" << targetDevice;
return result.str();
}
void DetectionOutputLayerTest::SetUp() {
DetectionOutputAttributes common_attrs;
ParamsWhichSizeDepends specific_attrs;
size_t batch;
Attributes attrs;
std::tie(common_attrs, specific_attrs, batch, attrs.objectness_score, targetDevice) = this->GetParam();
std::tie(attrs.num_classes, attrs.background_label_id, attrs.top_k, attrs.keep_top_k, attrs.code_type, attrs.nms_threshold, attrs.confidence_threshold,
attrs.clip_after_nms, attrs.clip_before_nms, attrs.decrease_label_id) = common_attrs;
std::vector<ov::Shape> input_shapes;
input_shapes.resize(numInputs);
std::tie(attrs.variance_encoded_in_target, attrs.share_location, attrs.normalized, attrs.input_height, attrs.input_width,
input_shapes[idxLocation], input_shapes[idxConfidence], input_shapes[idxPriors], input_shapes[idxArmConfidence],
input_shapes[idxArmLocation]) = specific_attrs;
if (input_shapes[idxArmConfidence].empty()) {
input_shapes.resize(3);
}
for (size_t i = 0; i < input_shapes.size(); i++) {
input_shapes[i][0] = batch;
}
init_input_shapes(static_shapes_to_test_representation(input_shapes));
ov::ParameterVector params;
for (const auto& shape : inputDynamicShapes) {
params.push_back(std::make_shared<ov::op::v0::Parameter>(ov::element::f32, shape));
}
std::shared_ptr<ov::op::v0::DetectionOutput> det_out;
if (params.size() == 3)
det_out = std::make_shared<ov::op::v0::DetectionOutput>(params[0], params[1], params[2], attrs);
else if (params.size() == 5)
det_out = std::make_shared<ov::op::v0::DetectionOutput>(params[0],
params[1],
params[2],
params[3],
params[4],
attrs);
auto result = std::make_shared<ov::op::v0::Result>(det_out);
function = std::make_shared<ov::Model>(result, params, "DetectionOutput");
}
} // namespace test
} // namespace ov
@@ -0,0 +1,58 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "shared_test_classes/single_op/dft.hpp"
#include "ngraph_functions/builders.hpp"
namespace ov {
namespace test {
std::string DFTLayerTest::getTestCaseName(const testing::TestParamInfo<DFTParams>& obj) {
std::vector<InputShape> shapes;
ov::element::Type model_type;
std::vector<int64_t> axes;
std::vector<int64_t> signal_size;
ov::test::utils::DFTOpType op_type;
std::string target_device;
std::tie(shapes, model_type, axes, signal_size, op_type, target_device) = obj.param;
std::ostringstream result;
result << "IS=(";
for (size_t i = 0lu; i < shapes.size(); i++) {
result << ov::test::utils::partialShape2str({shapes[i].first}) << (i < shapes.size() - 1lu ? "_" : "");
}
result << ")_TS=";
for (size_t i = 0lu; i < shapes.front().second.size(); i++) {
result << "{";
for (size_t j = 0lu; j < shapes.size(); j++) {
result << ov::test::utils::vec2str(shapes[j].second[i]) << (j < shapes.size() - 1lu ? "_" : "");
}
result << "}_";
}
result << "Precision=" << model_type.get_type_name() << "_";
result << "Axes=" << ov::test::utils::vec2str(axes) << "_";
result << "signal_size=" << ov::test::utils::vec2str(signal_size) << "_";
result << "Inverse=" << (op_type == ov::test::utils::DFTOpType::INVERSE) << "_";
result << "TargetDevice=" << target_device;
return result.str();
}
void DFTLayerTest::SetUp() {
std::vector<InputShape> shapes;
ov::element::Type model_type;
std::vector<int64_t> axes;
std::vector<int64_t> signal_size;
ov::test::utils::DFTOpType op_type;
std::tie(shapes, model_type, axes, signal_size, op_type, targetDevice) = this->GetParam();
init_input_shapes(shapes);
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes.front());
auto dft = ngraph::builder::makeDFT(param, axes, signal_size, op_type);
auto result = std::make_shared<ov::op::v0::Result>(dft);
function = std::make_shared<ov::Model>(result, ov::ParameterVector{param}, "DFT");
}
} // namespace test
} // namespace ov
@@ -0,0 +1,135 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "common_test_utils/ov_tensor_utils.hpp"
#include "shared_test_classes/single_op/eltwise.hpp"
#include "common_test_utils/ov_tensor_utils.hpp"
#include "ngraph_functions/builders.hpp"
namespace ov {
namespace test {
using ov::test::utils::InputLayerType;
using ov::test::utils::OpType;
using ov::test::utils::EltwiseTypes;
std::string EltwiseLayerTest::getTestCaseName(const testing::TestParamInfo<EltwiseTestParams>& obj) {
std::vector<InputShape> shapes;
ElementType model_type, in_type, out_type;
InputLayerType secondary_input_type;
OpType op_type;
EltwiseTypes eltwise_op_type;
std::string device_name;
ov::AnyMap additional_config;
std::tie(shapes, eltwise_op_type, secondary_input_type, op_type, model_type, in_type, out_type, device_name, additional_config) = obj.param;
std::ostringstream results;
results << "IS=(";
for (const auto& shape : shapes) {
results << ov::test::utils::partialShape2str({shape.first}) << "_";
}
results << ")_TS=(";
for (const auto& shape : shapes) {
for (const auto& item : shape.second) {
results << ov::test::utils::vec2str(item) << "_";
}
}
results << ")_eltwise_op_type=" << eltwise_op_type << "_";
results << "secondary_input_type=" << secondary_input_type << "_";
results << "opType=" << op_type << "_";
results << "model_type=" << model_type << "_";
results << "InType=" << in_type << "_";
results << "OutType=" << out_type << "_";
results << "trgDev=" << device_name;
for (auto const& config_item : additional_config) {
results << "_config_item=" << config_item.first << "=";
config_item.second.print(results);
}
return results.str();
}
void EltwiseLayerTest::transformInputShapesAccordingEltwise(const ov::PartialShape& secondInputShape) {
// propagate shapes in case 1 shape is defined
if (inputDynamicShapes.size() == 1) {
inputDynamicShapes.push_back(inputDynamicShapes.front());
for (auto& staticShape : targetStaticShapes) {
staticShape.push_back(staticShape.front());
}
}
ASSERT_EQ(inputDynamicShapes.size(), 2) << "Incorrect inputs number!";
if (!secondInputShape.is_static()) {
return;
}
if (secondInputShape.get_shape() == ov::Shape{1}) {
inputDynamicShapes[1] = secondInputShape;
for (auto& staticShape : targetStaticShapes) {
staticShape[1] = secondInputShape.get_shape();
}
}
}
void EltwiseLayerTest::SetUp() {
std::vector<InputShape> shapes;
ElementType model_type;
InputLayerType secondary_input_type;
OpType op_type;
EltwiseTypes eltwise_type;
Config additional_config;
std::tie(shapes, eltwise_type, secondary_input_type, op_type, model_type, inType, outType, targetDevice, configuration) = this->GetParam();
init_input_shapes(shapes);
ov::ParameterVector parameters{std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes.front())};
ov::PartialShape shape_input_secondary;
switch (op_type) {
case OpType::SCALAR: {
shape_input_secondary = {1};
break;
}
case OpType::VECTOR:
shape_input_secondary = inputDynamicShapes.back();
break;
default:
FAIL() << "Unsupported Secondary operation type";
}
// To propagate shape_input_secondary just in static case because all shapes are defined in dynamic scenarion
if (secondary_input_type == InputLayerType::PARAMETER) {
transformInputShapesAccordingEltwise(shape_input_secondary);
}
std::shared_ptr<ov::Node> secondary_input;
if (secondary_input_type == InputLayerType::PARAMETER) {
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, shape_input_secondary);
secondary_input = param;
parameters.push_back(param);
} else {
ov::Shape shape = inputDynamicShapes.back().get_max_shape();
switch (eltwise_type) {
case EltwiseTypes::DIVIDE:
case EltwiseTypes::MOD:
case EltwiseTypes::FLOOR_MOD: {
auto tensor = ov::test::utils::create_and_fill_tensor(model_type, shape, 8, 2);
secondary_input = std::make_shared<ov::op::v0::Constant>(tensor);
break;
}
case EltwiseTypes::POWER: {
auto tensor = ov::test::utils::create_and_fill_tensor(model_type, shape, 2, 1);
secondary_input = std::make_shared<ov::op::v0::Constant>(tensor);
break;
}
default: {
auto tensor = ov::test::utils::create_and_fill_tensor(model_type, shape, 9, 1);
secondary_input = std::make_shared<ov::op::v0::Constant>(tensor);
}
}
}
parameters[0]->set_friendly_name("param0");
secondary_input->set_friendly_name("param1");
auto eltwise = ngraph::builder::makeEltwise(parameters[0], secondary_input, eltwise_type);
function = std::make_shared<ov::Model>(eltwise, parameters, "Eltwise");
}
} // namespace test
} // namespace ov